From 0f6f30a94df4222e2c82b86c8fa573500b6c5d90 Mon Sep 17 00:00:00 2001 From: chohongm Date: Thu, 22 Jun 2023 17:42:47 +0900 Subject: [PATCH] v4.9.3 --- CHANGELOG.md | 9 +- groupChannel.js | 2 +- index.js | 2 +- lib/__bundle-361d5a90.js | 1 + lib/__bundle-3707a8af.js | 1 - lib/__bundle-528a3094.js | 1 - lib/__bundle-6587ce7b.js | 1 - lib/__bundle-75942676.js | 1 + lib/__bundle-84f74e8d.js | 1 + lib/__bundle-8cd94b6f.js | 1 - ...undle-ad3243e0.js => __bundle-8fdac8b9.js} | 2 +- lib/__bundle-a8606dd4.js | 1 - lib/__bundle-ad161b2c.js | 1 + lib/__bundle-e875840b.js | 1 + lib/__bundle-e99277d8.js | 1 - lib/__bundle-fd51cf65.js | 1 + lib/__definition.d.ts | 268 +++++++++--------- message.js | 2 +- openChannel.js | 2 +- package.json | 2 +- poll.js | 2 +- sendbird.min.js | 2 +- 22 files changed, 152 insertions(+), 153 deletions(-) create mode 100644 lib/__bundle-361d5a90.js delete mode 100644 lib/__bundle-3707a8af.js delete mode 100644 lib/__bundle-528a3094.js delete mode 100644 lib/__bundle-6587ce7b.js create mode 100644 lib/__bundle-75942676.js create mode 100644 lib/__bundle-84f74e8d.js delete mode 100644 lib/__bundle-8cd94b6f.js rename lib/{__bundle-ad3243e0.js => __bundle-8fdac8b9.js} (71%) delete mode 100644 lib/__bundle-a8606dd4.js create mode 100644 lib/__bundle-ad161b2c.js create mode 100644 lib/__bundle-e875840b.js delete mode 100644 lib/__bundle-e99277d8.js create mode 100644 lib/__bundle-fd51cf65.js diff --git a/CHANGELOG.md b/CHANGELOG.md index 4ab7480..0d70a87 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,16 +1,23 @@ # Changelog +## v4.9.3 (Jun 22, 2023) +### **Improvements** +- Fixed a bug where `sb.connect()` fails when `localCacheEnabled` set to false in browsers with disabled Cookies +- Fixed a bug where `GroupChannelCollection` displays channels in wrong order for `GroupChannelListOrder.LATEST_LAST_MESSAGE` + ## v4.9.2 (Jun 14, 2023) #### **IMPORTANT NOTICE** ```diff - JS Chat SDK version `4.9.1` and `4.9.2` has a CRTICAL BUG where FileMessage is NOT received when sent from an Android device. Please SKIP version `4.9.0` and `4.9.1`, and update to version `4.9.2` or above instead. ``` -​ + +## v4.9.1 (Jun 05, 2023) ### **Improvements** - Fixed a bug where FileMessage is sent as a MultipleFilesMessage## v4.9.1 (Jun 05, 2023) ### **Features** ### **Improvements** - Fixed a bug where the name, size, and type of FileMessage's PendingMessage were set to default values + ## v4.9.0 (Jun 01, 2023) ### **Features** ### MultipleFilesMessage diff --git a/groupChannel.js b/groupChannel.js index 0e43ff8..511d8f3 100644 --- a/groupChannel.js +++ b/groupChannel.js @@ -1 +1 @@ -import{_ as e,e as r,g as s,K as i,T as a,O as o,U as u,$ as c,aE as h,q as d,r as f,b as _,c as m,J as v,m as g,a as y,i as C,a6 as E,I as b,aD as M,aF as N,aw as S,aG as U,aj as T,ai as I,A,d as w,f as D,h as L,aH as k,ag as x,aI as R,a9 as F,W as O,a2 as H,B as V,S as q,t as B,V as j,Q as z,aC as Q,y as W,ah as K,s as Y,ac as J,aJ as X,E as Z,w as $,x as ee,af as te,aa as ne,aK as re,aL as se,aM as ie,u as ae,a4 as oe,aN as ue,al as ce,a3 as le,aB as he,ad as de,M as pe,n as fe,am as _e}from"./lib/__bundle-a8606dd4.js";export{ah as MessageEventSource}from"./lib/__bundle-a8606dd4.js";import{g as me,N as ve,p as ge,q as ye,r as Ce,t as Ee,u as be,w as Me,x as Ne,y as Se,P as Ue,z as Te,A as Ie,C as Ae,E as we,D as De,G as Le,H as ke,I as Pe,J as xe,f as Re,K as Fe,L as Oe}from"./lib/__bundle-e99277d8.js";import{G as He,g as Ge,D as Ve,l as qe,m as Be,n as je,j as ze,i as Qe,o as We,R as Ke,p as Ye,k as Je,U as Xe,e as Ze,f as $e,s as et,d as tt,S as nt,v as rt,q as st,r as it,P as at,t as ot}from"./lib/__bundle-528a3094.js";export{n as GroupChannelEventSource,G as GroupChannelListOrder,p as MessageFilter,P as PublicGroupChannelListOrder,t as ScheduledMessageListOrder}from"./lib/__bundle-528a3094.js";import{C as ut,a as ct,O as lt,P as ht,M as dt,T as pt,R as ft,U as _t,A as mt,B as vt}from"./lib/__bundle-6587ce7b.js";import{l as gt,S as yt,I as Ct,p as Et,U as bt,F as Mt,m as Nt,c as St,T as Ut,d as Tt,A as It,n as At,g as wt,h as Dt,o as Lt,q as kt}from"./lib/__bundle-8cd94b6f.js";export{l as ScheduledStatus}from"./lib/__bundle-8cd94b6f.js";import{b as Pt}from"./lib/__bundle-3707a8af.js";var xt;!function(e){e.NONE="none",e.JOINED="joined",e.INVITED="invited",e.LEFT="left"}(xt||(xt={}));var Rt,Ft,Ot,Ht,Gt,Vt,qt,Bt,jt=function(t){function n(e,n){var r=t.call(this,e,n)||this;return r.state=null,r.role=null,r.isMuted=!1,r.isBlockedByMe=!1,r.isBlockingMe=!1,r.state=i(xt,n.state)?n.state:null,r.role=i(a,n.role)?n.role:null,Object.prototype.hasOwnProperty.call(n,"is_muted")&&(r.isMuted=n.is_muted),Object.prototype.hasOwnProperty.call(n,"is_blocked_by_me")&&(r.isBlockedByMe=n.is_blocked_by_me),Object.prototype.hasOwnProperty.call(n,"is_blocking_me")&&(r.isBlockingMe=n.is_blocking_me),r}return e(n,t),n.payloadify=function(e){return e?r(s(s({},t.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},n}(me),zt=function(t){function n(e,n){var r,s,i=this;return(i=t.call(this,e)||this).channelUrl=null!==(r=n.channel_url)&&void 0!==r?r:"",i.channelType=null!==(s=n.channel_type)&&void 0!==s?s:o.GROUP,i.reader=new u(i._iid,n.user),i.readAt=n.ts,i}return e(n,t),n}(c);!function(e){e.ALL="all",e.PUBLIC="public",e.PRIVATE="private"}(Rt||(Rt={})),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"}(Ft||(Ft={})),function(e){e.ALL="all",e.SUPER="super",e.NON_SUPER="nonsuper",e.BROADCAST_ONLY="broadcast_only",e.EXCLUSIVE_ONLY="exclusive_only"}(Ot||(Ot={})),function(e){e.ALL="all",e.UNREAD_MESSAGE="unread_message"}(Ht||(Ht={})),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"}(Gt||(Gt={})),function(e){e.ALL="all",e.OPERATOR="operator",e.NONOPERATOR="nonoperator"}(Vt||(Vt={})),function(e){e.AND="AND",e.OR="OR"}(qt||(qt={})),function(e){e.MEMBER_NICKNAME="member_nickname",e.CHANNEL_NAME="channel_name"}(Bt||(Bt={}));var Qt,Wt=function(){function e(){this._searchFilter=null,this._userIdsFilter=null,this.includeEmpty=!1,this.nicknameContainsFilter=null,this.nicknameStartsWithFilter=null,this.nicknameExactMatchFilter=null,this.channelNameContainsFilter="",this.myMemberStateFilter=Ft.ALL,this.customTypesFilter=null,this.channelUrlsFilter=null,this.superChannelFilter=Ot.ALL,this.publicChannelFilter=Rt.ALL,this.customTypeStartsWithFilter=null,this.unreadChannelFilter=Ht.ALL,this.hiddenChannelFilter=Gt.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=qt.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 Bt.CHANNEL_NAME:return e.name.toLowerCase().includes(r.toLowerCase());case Bt.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,u=i.queryType,c=e.members.map((function(e){return e.userId}));if(o){if(a.length>0)switch(u){case qt.AND:if(a.some((function(e){return!c.includes(e)})))return!1;break;case qt.OR:if(a.every((function(e){return!c.includes(e)})))return!1}}else{if(a.includes(t)||a.push(t),e.members.length>a.length)return!1;if(!h(a,c))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 l=this.nicknameContainsFilter.toLowerCase();if(!e.members.some((function(e){return e.userId!==t&&e.nickname.toLowerCase().includes(l)})))return!1}if(this.nicknameStartsWithFilter){var d=this.nicknameStartsWithFilter.toLowerCase();if(!e.members.some((function(e){return e.userId!==t&&e.nickname.toLowerCase().startsWith(d)})))return!1}if(this.nicknameExactMatchFilter){var p=this.nicknameExactMatchFilter.toLowerCase();if(!e.members.some((function(e){return e.userId!==t&&e.nickname.toLowerCase()!=p})))return!1}if(this.channelUrlsFilter&&this.channelUrlsFilter.length>0&&!this.channelUrlsFilter.includes(e.url))return!1;if(this.myMemberStateFilter)switch(this.myMemberStateFilter){case Ft.JOINED:if("joined"!==e.myMemberState)return!1;break;case Ft.INVITED:if("invited"!==e.myMemberState)return!1;break;case Ft.INVITED_BY_FRIEND:if("invited"!==e.myMemberState||!this._isFriend(e.inviter))return!1;break;case Ft.INVITED_BY_NON_FRIEND:if("invited"!==e.myMemberState||this._isFriend(e.inviter))return!1}if(this.hiddenChannelFilter)switch(this.hiddenChannelFilter){case Gt.UNHIDDEN:if(e.isHidden||"unhidden"!==e.hiddenState)return!1;break;case Gt.HIDDEN:if(!e.isHidden)return!1;break;case Gt.HIDDEN_ALLOW_AUTO_UNHIDE:if(!e.isHidden||"hidden_allow_auto_unhide"!==e.hiddenState)return!1;break;case Gt.HIDDEN_PREVENT_AUTO_UNHIDE:if(!e.isHidden||"hidden_prevent_auto_unhide"!==e.hiddenState)return!1}if(this.unreadChannelFilter&&this.unreadChannelFilter===Ht.UNREAD_MESSAGE)if(0===e.unreadMessageCount)return!1;if(this.publicChannelFilter)switch(this.publicChannelFilter){case Rt.PUBLIC:if(!e.isPublic)return!1;break;case Rt.PRIVATE:if(e.isPublic)return!1}if(this.superChannelFilter)switch(this.superChannelFilter){case Ot.SUPER:if(!e.isSuper)return!1;break;case Ot.NON_SUPER:if(e.isSuper)return!1}return!0},e}(),Kt=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(ve):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 er.of(this._iid).buildGroupChannelFromSerializedData(e)},Object.defineProperty(n.prototype,"channels",{get:function(){return d([],f(this._channels.values()),!1)},enumerable:!1,configurable:!0}),n.prototype.isCachedInMemory=function(e){return this._channels.has(e)},n.prototype.filterOffsetChanged=function(e){var t=this;return e.filter((function(e){if(t._channels.has(e.url))return t._channels.get(e.url).messageOffsetTimestamp0)return!1;if(h&&h===e.url)return!1;break;case He.CHRONOLOGICAL:if(!i&&e.createdAt>t||i&&e.createdAtt||i&&e.lastMessageUpdatedAt0?[4,this.upsert(r)]:[3,2];case 1:m.sent(),m.label=2;case 2:return[2]}}))}))},n.prototype.block=function(e,t){return _(this,void 0,void 0,(function(){return m(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 _(this,void 0,void 0,(function(){return m(this,(function(n){switch(n.label){case 0:return[4,this._setBlockStateOfAllChannels(e,t,!1)];case 1:return n.sent(),[2]}}))}))},n.prototype.markAsRead=function(e,t){return void 0===t&&(t=d([],f(this._channels.keys()),!1)),_(this,void 0,void 0,(function(){var n,r,s,i,a,o,u,c;return m(this,(function(l){switch(l.label){case 0:n=[],l.label=1;case 1:l.trys.push([1,6,7,8]),r=v(t),s=r.next(),l.label=2;case 2:return s.done?[3,5]:(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}(c),Yt={invitedUserIds:null,channelUrl:null,coverUrl:null,coverImage:null,isDistinct:null,isSuper:null,isBroadcast:null,isExclusive:null,isPublic:null,isDiscoverable:null,isStrict:null,isEphemeral:null,accessCode:null,name:null,data:null,customType:null,operatorUserIds:null,messageSurvivalSeconds:null},Jt=function(e){return g("string",e.invitedUserIds,!0)&&y("string",e.channelUrl,!0)&&y("string",e.coverUrl,!0)&&(C(e.coverImage)||y("string",e.coverImage)||null===e.coverImage)&&y("boolean",e.isDistinct,!0)&&y("boolean",e.isSuper,!0)&&y("boolean",e.isBroadcast,!0)&&y("boolean",e.isExclusive,!0)&&y("boolean",e.isPublic,!0)&&y("boolean",e.isStrict,!0)&&y("boolean",e.isDiscoverable,!0)&&y("boolean",e.isEphemeral,!0)&&y("string",e.accessCode,!0)&&y("string",e.name,!0)&&y("string",e.data,!0)&&y("string",e.customType,!0)&&g("string",e.operatorUserIds,!0)&&y("number",e.messageSurvivalSeconds,!0)},Xt={customTypes:null,includeEmpty:!1,includeFrozen:!0},Zt=function(e){return g("string",e.customTypes,!0)&&y("boolean",e.includeEmpty)&&y("boolean",e.includeFrozen)},$t={myMemberStateFilter:Ft.ALL},en=function(e){return i(Ft,e.myMemberStateFilter)};!function(e){e.GROUP_CHANNEL_UNREAD_MENTION_COUNT="group_channel_unread_mention_count",e.NONSUPER_UNREAD_MENTION_COUNT="non_super_group_channel_unread_mention_count",e.SUPER_UNREAD_MENTION_COUNT="super_group_channel_unread_mention_count",e.GROUP_CHANNEL_UNREAD_MESSAGE_COUNT="group_channel_unread_message_count",e.NONSUPER_UNREAD_MESSAGE_COUNT="non_super_group_channel_unread_message_count",e.SUPER_UNREAD_MESSAGE_COUNT="super_group_channel_unread_message_count",e.GROUP_CHANNEL_INVITATION_COUNT="group_channel_invitation_count",e.NONSUPER_INVITATION_COUNT="non_super_group_channel_invitation_count",e.SUPER_INVITATION_COUNT="super_group_channel_invitation_count"}(Qt||(Qt={}));var tn={keys:[]},nn={channelCustomTypesFilter:null,superChannelFilter:Ot.ALL},rn={channelUrl:null,scheduledStatus:null,messageTypeFilter:E.ALL},sn=function(){function e(e){var t=e.groupChannelCache,n=e.messageCache,r=e.unsentMessageCache,s=e.dispatcher,i=this;this._observers=new Map,s.on((function(e){return _(i,void 0,void 0,(function(){var s,i,a,o,u,c,l,h,d,p,f,g,y,C=this;return m(this,(function(E){switch(E.label){case 0:if(!(e instanceof Be))return[3,10];s=e.channels,f=e.source,i=e.data,a=s.filter((function(e){return e instanceof os})),o=t.filterOffsetChanged(a),E.label=1;case 1:E.trys.push([1,6,7,8]),u=v(o),c=u.next(),E.label=2;case 2:return c.done?[3,5]:(l=c.value,[4,n.removeUnderOffset(l.url,l.messageOffsetTimestamp)]);case 3:E.sent(),E.label=4;case 4:return c=u.next(),[3,2];case 5:return[3,8];case 6:return h=E.sent(),g={error:h},[3,8];case 7:try{c&&!c.done&&(y=u.return)&&y.call(u)}finally{if(g)throw g.error}return[7];case 8:return[4,t.upsert(a)];case 9:return d=E.sent(),this._broadcastUpdateEvent(d,f,i),[3,15];case 10:return e instanceof qe?(p=e.channelUrls,f=e.source,[4,t.remove(p)]):[3,13];case 11:return E.sent(),[4,b((function(){return _(C,void 0,void 0,(function(){var e,t,s,i,a,o;return m(this,(function(u){switch(u.label){case 0:u.trys.push([0,6,7,8]),e=v(p),t=e.next(),u.label=1;case 1:return t.done?[3,5]:(s=t.value,[4,n.removeMessagesOfChannel(s)]);case 2:return u.sent(),[4,r.removeMessagesOfChannel(s)];case 3:u.sent(),u.label=4;case 4:return t=e.next(),[3,1];case 5:return[3,8];case 6:return i=u.sent(),a={error:i},[3,8];case 7:try{t&&!t.done&&(o=e.return)&&o.call(e)}finally{if(a)throw a.error}return[7];case 8:return[2]}}))}))}))];case 12:return E.sent(),this._broadcastRemoveEvent(p,f),[3,15];case 13:return e instanceof Ve?[4,t.fetch({token:Number.MAX_SAFE_INTEGER,limit:Number.MAX_SAFE_INTEGER})]:[3,15];case 14:E.sent(),E.label=15;case 15:return[2]}}))}))}))}return e.prototype._broadcastUpdateEvent=function(e,t,n){var r,s;try{for(var i=v(this._observers.values()),a=i.next();!a.done;a=i.next()){a.value.onUpdate(e,t,n)}}catch(e){r={error:e}}finally{try{a&&!a.done&&(s=i.return)&&s.call(i)}finally{if(r)throw r.error}}},e.prototype._broadcastRemoveEvent=function(e,t){var n,r;try{for(var s=v(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.subscribe=function(e,t){this._observers.set(e,t)},e.prototype.unsubscribe=function(e){this._observers.delete(e)},e.prototype.unsubscribeAll=function(){this._observers.clear()},e}(),an=function(){function e(e){var t=e.cacheContext,n=e.messageCache,r=e.unsentMessageCache,s=e.dispatcher,i=e.logger,a=this;this._cacheContext=null,this._observers=new Map,this._logger=null,this._cacheContext=t,this._logger=i,s.on((function(e){return _(a,void 0,void 0,(function(){var t,s,i,a,o,u,c,l,h,d,p,f,v,g=this;return m(this,(function(y){switch(y.label){case 0:return e instanceof I?(t=e.messages,f=e.source,s=t.filter((function(e){return e.messageId>0})),i=t.filter((function(e){return 0===e.messageId})),s.length>0?[4,b((function(){return _(g,void 0,void 0,(function(){return m(this,(function(e){switch(e.label){case 0:return[4,n.upsert(s)];case 1:return e.sent(),[4,r.remove(s.map((function(e){return e instanceof yt?e.reqId:null})).filter((function(e){return null!==e})))];case 2:return e.sent(),[2]}}))}))}))]:[3,2]):[3,5];case 1:y.sent(),this._broadcastUpdateEvent(s,f),y.label=2;case 2:return i.length>0?[4,b((function(){return _(g,void 0,void 0,(function(){return m(this,(function(e){switch(e.label){case 0:return[4,r.upsert(i)];case 1:return e.sent(),[2]}}))}))}))]:[3,4];case 3:y.sent(),this._broadcastUpdateEvent(i,f),y.label=4;case 4:return[3,21];case 5:return e instanceof T?(a=e.messageIds,f=e.source,[4,b((function(){return _(g,void 0,void 0,(function(){return m(this,(function(e){switch(e.label){case 0:return[4,n.remove(a)];case 1:return e.sent(),[2]}}))}))}))]):[3,7];case 6:return y.sent(),this._broadcastRemoveEvent(a,f),[3,21];case 7:return e instanceof U?(o=e.reqId,f=e.source,[4,b((function(){return _(g,void 0,void 0,(function(){return m(this,(function(e){switch(e.label){case 0:return[4,r.remove([o])];case 1:return e.sent(),[2]}}))}))}))]):[3,9];case 8:return y.sent(),this._broadcastRemoveUnsentEvent(o,f),[3,21];case 9:return e instanceof S?(u=e.polls,f=e.source,this._cacheContext.localCacheEnabled?(c=u.map((function(e){return e.messageId})),[4,Promise.all(c.map((function(e){return n.get(e)})))]):[3,12]):[3,13];case 10:return(l=y.sent().filter((function(e){return e}))).length>0&&u.forEach((function(e){var t=l.find((function(t){return t.messageId===e.messageId}));t&&t.applyPoll(e)})),[4,b((function(){return _(g,void 0,void 0,(function(){return m(this,(function(e){switch(e.label){case 0:return[4,n.upsert(l)];case 1:return[2,e.sent()]}}))}))}))];case 11:y.sent(),y.label=12;case 12:return this._broadcastPollChangeLogEvent(u,f),[3,21];case 13:return e instanceof N?(h=e.event,f=e.source,[4,n.get(h.messageId)]):[3,17];case 14:return(d=y.sent())&&d.isUserMessage()&&d.poll&&d.poll.applyPollUpdateEvent(h)?[4,b((function(){return _(g,void 0,void 0,(function(){return m(this,(function(e){switch(e.label){case 0:return[4,n.upsert([d])];case 1:return[2,e.sent()]}}))}))}))]:[3,16];case 15:y.sent(),y.label=16;case 16:return this._broadcastPollUpdateEvent(h,f),[3,21];case 17:return e instanceof M?(p=e.event,f=e.source,[4,n.get(p.messageId)]):[3,21];case 18:return(v=y.sent())&&v.isUserMessage()&&v.poll&&v.poll.applyPollVoteEvent(p)?[4,b((function(){return _(g,void 0,void 0,(function(){return m(this,(function(e){switch(e.label){case 0:return[4,n.upsert([v])];case 1:return[2,e.sent()]}}))}))}))]:[3,20];case 19:y.sent(),y.label=20;case 20:this._broadcastPollVoteEvent(p,f),y.label=21;case 21:return[2]}}))}))}))}return e.prototype._broadcastUpdateEvent=function(e,t){var n,r;try{for(var s=v(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._broadcastPollChangeLogEvent=function(e,t){var n,r;try{for(var s=v(this._observers.values()),i=s.next();!i.done;i=s.next()){i.value.onPollChangeLogUpdate(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._broadcastPollUpdateEvent=function(e,t){var n,r;try{for(var s=v(this._observers.values()),i=s.next();!i.done;i=s.next()){i.value.onPollUpdate(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._broadcastPollVoteEvent=function(e,t){var n,r;try{for(var s=v(this._observers.values()),i=s.next();!i.done;i=s.next()){i.value.onPollVote(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=v(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=v(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.prototype.unsubscribeAll=function(){this._observers.clear()},e}(),on=function(t){function n(e){var n=e.userId,i=e.ts,a=e.token,o=e.filter,u=t.call(this)||this,c=s(s({},Xt),o),l=c.customTypes,h=c.includeEmpty,d=c.includeFrozen;return u.method=A.GET,u.path="".concat(w,"/").concat(encodeURIComponent(n),"/my_group_channels/changelogs"),u.params=r({show_delivery_receipt:!0,show_member:!0,show_read_receipt:!0,change_ts:i>0?i:null,token:a,custom_types:l,show_empty:h,show_frozen:d}),u}return e(n,t),n}(D),un=function(t){function n(e,n){var r=t.call(this,e,n)||this;return r.updatedChannels=n.updated.map((function(t){return new os(e,t)})),r.deletedChannelUrls=n.deleted,r.hasMore=n.has_more,r.token=n.next,r}return e(n,t),n}(L),cn=function(t){function n(e){var n=e.channelUrl,r=e.isInternalCall,s=t.call(this)||this;return s.method=A.GET,s.path="".concat(r?k:x,"/").concat(encodeURIComponent(n)),s.params={show_member:!0,show_read_receipt:!0,show_delivery_receipt:!0},s}return e(n,t),n}(D),ln=function(t){function n(e,n){var r=t.call(this,e,n)||this;return r.channel=null,r.channel=new os(e,n),r}return e(n,t),n}(L),hn=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.myMemberStateFilter,l=e.superChannelFilter,h=e.publicChannelFilter,d=e.unreadChannelFilter,p=e.nicknameContainsFilter,f=e.nicknameStartsWithFilter,_=e.nicknameExactMatchFilter,m=e.channelNameContainsFilter,v=e.channelUrlsFilter,g=e.customTypesFilter,y=e.customTypeStartsWithFilter,C=e.hiddenChannelFilter,E=e.metadataOrderKeyFilter,b=e.metadataKey,M=e.metadataValues,N=e.metadataValueStartsWith,S=e.includeFrozen,U=e.includeMetaData,T=e.searchFilter,I=e.userIdsFilter;return(n=t.call(this)||this).method=A.GET,n.path="".concat(w,"/").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:p,members_nickname_startswith:f,members_nickname:_,name_contains:m,channel_urls:v,custom_types:g,custom_type_startswith:y,hidden_mode:C,metadata_order_key:E,metadata_key:b,metadata_values:M,metadata_value_startswith:N,show_frozen:S,show_metadata:U}),T&&T.query&&T.fields&&(n.params.search_query=T.query,n.params.search_fields=T.fields),I&&I.userIds&&I.userIds.length>0&&(I.includeMode?(n.params.members_include_in=I.userIds,n.params.query_type=I.queryType.toUpperCase()):n.params.members_exactly_in=I.userIds),n}return e(n,t),n}(D),dn=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 os(e,t)}))),r.ts=null!=a?a:null,r}return e(n,t),n}(L),pn=function(t){function n(e){var n=e.userId,r=e.filter,s=t.call(this)||this,i=r.myMemberStateFilter;return s.method=A.GET,s.path="".concat(w,"/").concat(encodeURIComponent(n),"/group_channel_count"),s.params={state:null!=i?i:Ft.ALL},s}return e(n,t),n}(D),fn=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}(L),_n=function(t){function n(e){var n=e.userId,r=e.filter,s=t.call(this)||this,i=r.keys;return s.method=A.GET,s.path="".concat(w,"/").concat(encodeURIComponent(n),"/unread_item_count"),s.params={item_keys:i},s}return e(n,t),n}(D),mn=function(t){function n(e,n){var r=t.call(this,e,n)||this;return"number"==typeof n[Qt.GROUP_CHANNEL_UNREAD_MENTION_COUNT]&&(r.groupChannelUnreadMentionCount=n[Qt.GROUP_CHANNEL_UNREAD_MENTION_COUNT]),"number"==typeof n[Qt.GROUP_CHANNEL_UNREAD_MESSAGE_COUNT]&&(r.groupChannelUnreadMessageCount=n[Qt.GROUP_CHANNEL_UNREAD_MESSAGE_COUNT]),"number"==typeof n[Qt.GROUP_CHANNEL_INVITATION_COUNT]&&(r.groupChannelInvitationCount=n[Qt.GROUP_CHANNEL_INVITATION_COUNT]),"number"==typeof n[Qt.SUPER_UNREAD_MENTION_COUNT]&&(r.superGroupChannelUnreadMentionCount=n[Qt.SUPER_UNREAD_MENTION_COUNT]),"number"==typeof n[Qt.SUPER_UNREAD_MESSAGE_COUNT]&&(r.superGroupChannelUnreadMessageCount=n[Qt.SUPER_UNREAD_MESSAGE_COUNT]),"number"==typeof n[Qt.SUPER_INVITATION_COUNT]&&(r.superGroupChannelInvitationCount=n[Qt.SUPER_INVITATION_COUNT]),"number"==typeof n[Qt.NONSUPER_UNREAD_MENTION_COUNT]&&(r.nonSuperGroupChannelUnreadMentionCount=n[Qt.NONSUPER_UNREAD_MENTION_COUNT]),"number"==typeof n[Qt.NONSUPER_UNREAD_MESSAGE_COUNT]&&(r.nonSuperGroupChannelUnreadMessageCount=n[Qt.NONSUPER_UNREAD_MESSAGE_COUNT]),"number"==typeof n[Qt.NONSUPER_INVITATION_COUNT]&&(r.nonSuperGroupChannelInvitationCount=n[Qt.NONSUPER_INVITATION_COUNT]),r}return e(n,t),n}(L),vn=function(t){function n(e){var n=e.userId,r=t.call(this)||this;return r.method=A.GET,r.path="".concat(w,"/").concat(encodeURIComponent(n),"/unread_channel_count"),r}return e(n,t),n}(D),gn=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}(L),yn=function(t){function n(e){var n=e.userId,r=e.filter,s=t.call(this)||this,i=r.channelCustomTypesFilter,a=r.superChannelFilter;return s.method=A.GET,s.path="".concat(w,"/").concat(encodeURIComponent(n),"/unread_message_count"),s.params={super_mode:null!=a?a:Ot.ALL,custom_types:i},s}return e(n,t),n}(D),Cn=function(t){function n(e,n){var r=t.call(this,e,n)||this;return r.unreadCount=n.unread_count,r}return e(n,t),n}(L),En=function(t){function n(e){var n=e.channelUrl,r=e.scheduledStatus,s=e.messageTypeFilter,i=t.call(this)||this;return i.method=A.GET,i.path="".concat(R,"/count"),i.params={channel_url:n,status:Mn(r)},s&&(i.params.message_type=s),i}return e(n,t),n}(D),bn=function(t){function n(e,n){var r=t.call(this,e,n)||this;return r.count=n.count,r}return e(n,t),n}(L),Mn=function(e){if(e){var t=[];return e.forEach((function(e){switch(e){case gt.PENDING:t.push(Ct.PENDING);break;case gt.SENT:t.push(Ct.IN_QUEUE),t.push(Ct.SENT);break;case gt.CANCELED:t.push(Ct.CANCELED);break;case gt.FAILED:t.push(Ct.FAILED)}})),t}},Nn=function(t){function n(e){var n=this,s=e.userId,i=e.channelUrl,a=e.coverUrl,o=e.coverImage,u=e.isDistinct,c=e.isSuper,l=e.isBroadcast,h=e.isPublic,p=e.isExclusive,_=e.isDiscoverable,m=e.isStrict,v=e.isEphemeral,g=e.accessCode,y=e.name,C=e.data,E=e.customType,b=e.messageSurvivalSeconds,M=e.invitedUserIds,N=e.operatorUserIds;return(n=t.call(this)||this).method=A.POST,n.path=x,n.params=r({user_ids:d([s],f(null!=M?M:[]),!1).filter((function(e,t,n){return t===n.indexOf(e)})),channel_url:i,cover_url:a,cover_file:o,is_distinct:u,is_super:c,is_broadcast:l,is_exclusive:p,is_public:h,is_discoverable:_,strict:m,is_ephemeral:v,access_code:g,name:y,data:C,custom_type:E,operator_ids:N,message_survival_seconds:b}),n}return e(n,t),n}(D),Sn=function(t){function n(e,n){var r=t.call(this,e,n)||this;return r.channel=new os(e,n),r.isCreated=n.is_created,r}return e(n,t),n}(L),Un=function(t){function n(e){var n=e.userId,r=e.channelUrls,s=t.call(this)||this;return s.method=A.PUT,s.path="".concat(w,"/").concat(encodeURIComponent(n),"/mark_as_read_all"),s.params={channel_urls:r},s}return e(n,t),n}(D);!function(t){function n(){return null!==t&&t.apply(this,arguments)||this}e(n,t)}(L);var Tn=function(t){function n(e){var n=this,r=e.channelUrl,s=e.userId,i=e.accessCode;return(n=t.call(this)||this).method=A.PUT,n.path="".concat(x,"/").concat(encodeURIComponent(r),"/join"),n.params={user_id:s,access_code:i},n}return e(n,t),n}(D),In=function(t){function n(e,n){var r=t.call(this,e,n)||this;return r.channel=new os(e,n),r}return e(n,t),n}(L),An=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 jt(e,t)})):[new jt(e,r.data)],s}return e(n,t),n}(ut),wn=function(t){function n(e){var n=this,r=e.channelUrl,s=e.userId,i=e.shouldRemoveOperatorStatus;return(n=t.call(this)||this).method=A.PUT,n.path="".concat(x,"/").concat(encodeURIComponent(r),"/leave"),n.params={user_id:s,should_remove_operator_status:i},n}return e(n,t),n}(D);!function(t){function n(e,n){return t.call(this,e,n)||this}e(n,t)}(L);var Dn=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 jt(s._iid,r.data),s}return e(n,t),n}(ut),Ln=function(t){function n(e){var n=this,r=e.channelUrl,s=e.userIds;return(n=t.call(this)||this).method=A.POST,n.path="".concat(x,"/").concat(encodeURIComponent(r),"/invite"),n.params={user_ids:s},n}return e(n,t),n}(D),kn=function(t){function n(e,n){var r=t.call(this,e,n)||this;return r.channel=new os(e,n),r}return e(n,t),n}(L),Pn=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,c=i.joined_member_count,l=void 0===c?null:c,h=i.inviter,d=void 0===h?null:h,p=i.invitees,f=void 0===p?[]:p;return s.memberCount=o,s.joinedMemberCount=l,s.inviter=d?new u(e,d):null,s.invitees=f.map((function(t){return new jt(e,t)})),s}return e(n,t),n}(ut),xn=function(t){function n(e){var n=this,r=e.channelUrl,s=e.userId;return(n=t.call(this)||this).method=A.PUT,n.path="".concat(x,"/").concat(encodeURIComponent(r),"/decline"),n.params={user_id:s},n}return e(n,t),n}(D);!function(t){function n(e,n){var r=t.call(this,e,n)||this;return r.channel=new os(e,n),r.channel.myMemberState=xt.NONE,r}e(n,t)}(L);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,c=i.joined_member_count,l=void 0===c?null:c,h=i.inviter,d=void 0===h?null:h,p=i.invitee,f=void 0===p?null:p;return s.memberCount=o,s.joinedMemberCount=l,s.inviter=d?new u(e,d):null,s.invitee=f?new jt(e,f):null,s}return e(n,t),n}(ut),Fn=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}(F),On=function(t){function n(e,n,r){var s=t.call(this,e,"READ",r)||this;return s.readStatus=new zt(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=A.PUT,i.path="".concat(x,"/").concat(encodeURIComponent(n),"/messages/mark_as_delivered"),i.params=r({userId:s}),i}return e(n,t),n}(D);!function(t){function n(){return null!==t&&t.apply(this,arguments)||this}e(n,t)}(L);var Gn,Vn=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),qn=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=A.PUT,n.path="".concat(x,"/").concat(encodeURIComponent(r),"/hide"),n.params={user_id:s,hide_previous_messages:i,allow_auto_unhide:a},n}return e(n,t),n}(D),Bn=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}(L),jn=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),zn=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}(F),Qn=function(t){function n(e,n,r){var s=t.call(this,e,"SYEV",r)||this;return s.user=new u(e,r.data),s}return e(n,t),n}(O),Wn=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}(F),Kn=function(t){function n(e,n,r){var s=t.call(this,e,"SYEV",r)||this;return s.user=new u(e,r.data),s}return e(n,t),n}(O),Yn=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}(F),Jn=function(t){function n(e,n){var r,s,i,a,o,u,c,l,h,d,p,f,_,m,v,g,y,C,E,b,M,N,S=this;return(S=t.call(this,e,n)||this).includeEmpty=!1,S.includeFrozen=!0,S.includeMetaData=!0,S.channelUrlsFilter=null,S.customTypesFilter=null,S.customTypeStartsWithFilter=null,S.nicknameContainsFilter=null,S.nicknameStartsWithFilter=null,S.nicknameExactMatchFilter=null,S.channelNameContainsFilter="",S.myMemberStateFilter=Ft.ALL,S.unreadChannelFilter=Ht.ALL,S.superChannelFilter=Ot.ALL,S.publicChannelFilter=Rt.ALL,S.hiddenChannelFilter=Gt.UNHIDDEN,S.searchFilter={fields:[],query:null},S.userIdsFilter={userIds:[],includeMode:!0,queryType:qt.AND},S.metadataKey=null,S.metadataValues=null,S.metadataOrderKeyFilter=null,S.metadataValueStartsWith=null,S.order=He.LATEST_LAST_MESSAGE,S.includeEmpty=null!==(r=n.includeEmpty)&&void 0!==r&&r,S.includeFrozen=null===(s=n.includeFrozen)||void 0===s||s,S.includeMetaData=null===(i=n.includeMetaData)||void 0===i||i,S.channelUrlsFilter=null!==(a=n.channelUrlsFilter)&&void 0!==a?a:null,S.customTypesFilter=null!==(o=n.customTypesFilter)&&void 0!==o?o:null,S.customTypeStartsWithFilter=null!==(u=n.customTypeStartsWithFilter)&&void 0!==u?u:"",S.nicknameContainsFilter=null!==(c=n.nicknameContainsFilter)&&void 0!==c?c:null,S.nicknameStartsWithFilter=null!==(l=n.nicknameStartsWithFilter)&&void 0!==l?l:null,S.nicknameExactMatchFilter=null!==(h=n.nicknameExactMatchFilter)&&void 0!==h?h:null,S.channelNameContainsFilter=null!==(d=n.channelNameContainsFilter)&&void 0!==d?d:"",S.myMemberStateFilter=null!==(p=n.myMemberStateFilter)&&void 0!==p?p:Ft.ALL,S.unreadChannelFilter=null!==(f=n.unreadChannelFilter)&&void 0!==f?f:Ht.ALL,S.superChannelFilter=null!==(_=n.superChannelFilter)&&void 0!==_?_:Ot.ALL,S.publicChannelFilter=null!==(m=n.publicChannelFilter)&&void 0!==m?m:Rt.ALL,S.hiddenChannelFilter=null!==(v=n.hiddenChannelFilter)&&void 0!==v?v:Gt.UNHIDDEN,S.searchFilter=null!==(g=n.searchFilter)&&void 0!==g?g:{fields:[],query:null},S.userIdsFilter=null!==(y=n.userIdsFilter)&&void 0!==y?y:{userIds:[],includeMode:!0,queryType:qt.AND},S.metadataKey=null!==(C=n.metadataKey)&&void 0!==C?C:null,S.metadataValues=null!==(E=n.metadataValues)&&void 0!==E?E:null,S.metadataOrderKeyFilter=null!==(b=n.metadataOrderKeyFilter)&&void 0!==b?b:null,S.metadataValueStartsWith=null!==(M=n.metadataValueStartsWith)&&void 0!==M?M:null,S.order=null!==(N=n.order)&&void 0!==N?N:He.LATEST_LAST_MESSAGE,S}return e(n,t),n.prototype._validate=function(){return t.prototype._validate.call(this)&&y("boolean",this.includeEmpty)&&y("boolean",this.includeFrozen)&&y("boolean",this.includeMetaData)&&y("string",this.channelNameContainsFilter)&&g("string",this.channelUrlsFilter,!0)&&g("string",this.customTypesFilter,!0)&&y("string",this.customTypeStartsWithFilter)&&y("string",this.nicknameContainsFilter,!0)&&y("string",this.nicknameStartsWithFilter,!0)&&y("string",this.nicknameExactMatchFilter,!0)&&i(Ft,this.myMemberStateFilter)&&i(Ot,this.superChannelFilter)&&i(Rt,this.publicChannelFilter)&&i(Ht,this.unreadChannelFilter)&&i(Gt,this.hiddenChannelFilter)&&g(Bt,this.searchFilter.fields)&&y("string",this.searchFilter.query,!0)&&g("string",this.userIdsFilter.userIds)&&y("boolean",this.userIdsFilter.includeMode)&&i(qt,this.userIdsFilter.queryType)&&i(He,this.order)&&y("string",this.metadataOrderKeyFilter,!0)&&y("string",this.metadataKey,!0)&&g("string",this.metadataValues,!0)&&y("string",this.metadataValueStartsWith,!0)},n.prototype.serialize=function(){return H(this)},n.prototype.next=function(){return _(this,void 0,void 0,(function(){var e,t,n;return m(this,(function(r){switch(r.label){case 0:return this._validate()?this._isLoading?[3,3]:this._hasNext?(this._isLoading=!0,[4,er.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 q.queryInProgress;case 4:return[3,6];case 5:throw q.invalidParameters;case 6:return[2]}}))}))},n}(V),Xn=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||w.unreadMentionCount>0)&&(w._updateUnreadCount(0,0),this._dispatcher.dispatch(new Be({channels:[w],source:je.EVENT_CHANNEL_READ})),W((function(){return _(En,void 0,void 0,(function(){var e,t,n,r;return m(this,(function(s){try{for(e=v(this._groupChannelHandlers.values()),t=e.next();!t.done;t=e.next())t.value.onChannelChanged(w)}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!==w.unreadMessageCount&&0!==w.unreadMentionCount||(this._dispatcher.dispatch(new Be({channels:[w],source:je.EVENT_CHANNEL_READ})),W((function(){return _(En,void 0,void 0,(function(){var e,t,n,r;return m(this,(function(s){try{for(e=v(this._groupChannelHandlers.values()),t=e.next();!t.done;t=e.next())t.value.onChannelChanged(w)}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 Be({channels:[w],source:je.EVENT_CHANNEL_READ})),W((function(){return _(En,void 0,void 0,(function(){var e,t,n,r;return m(this,(function(s){try{for(e=v(this._groupChannelHandlers.values()),t=e.next();!t.done;t=e.next())t.value.onUnreadMemberStatusUpdated(w)}catch(e){n={error:e}}finally{try{t&&!t.done&&(r=e.return)&&r.call(e)}finally{if(n)throw n.error}}return[2]}))}))}))),bn.label=12;case 12:return[3,79];case 13:return D=e.as(Vn),ue=D.channelUrl,L=D.deliveredStateUpdate,k=void 0===L?{}:L,P=this._groupChannelCache.isCachedInMemory(ue),[4,this.getChannel(ue,!0)];case 14:if(x=bn.sent(),P)for(R in k)x._updateUndeliveredMemberState(R,k[R]);return Object.keys(k).some((function(e){return e!==En._sdkState.userId}))&&(this._dispatcher.dispatch(new Be({channels:[x],source:je.EVENT_CHANNEL_DELIVERED})),W((function(){return _(En,void 0,void 0,(function(){var e,t,n,r;return m(this,(function(s){try{for(e=v(this._groupChannelHandlers.values()),t=e.next();!t.done;t=e.next())t.value.onUndeliveredMemberStatusUpdated(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]}))}))}))),[3,79];case 15:return F=e.as(ft),ue=F.channelUrl,ce=F.channelType,O=F.event,ce!==o.GROUP?[3,18]:[4,this.getChannel(ue,!0)];case 16:return H=bn.sent(),[4,this.getMessageFromCache(O.messageId)];case 17:(q=bn.sent())&&(q.applyReactionEvent(O),this._dispatcher.dispatch(new I({messages:[q],source:K.EVENT_MESSAGE_REACTION_UPDATED}))),W((function(){return _(En,void 0,void 0,(function(){var e,t,n,r;return m(this,(function(s){try{for(e=v(this._groupChannelHandlers.values()),t=e.next();!t.done;t=e.next())t.value.onReactionUpdated(H,O)}catch(e){n={error:e}}finally{try{t&&!t.done&&(r=e.return)&&r.call(e)}finally{if(n)throw n.error}}return[2]}))}))})),bn.label=18;case 18:return[3,79];case 19:return(G=e.as(pt).event).channelType!==o.GROUP?[3,22]:[4,this.getChannel(G.channelUrl,!0)];case 20:return V=bn.sent(),[4,this.getMessageFromCache(G.targetMessageId)];case 21:(q=bn.sent())&&(q.applyThreadInfoUpdateEvent(G),this._dispatcher.dispatch(new I({messages:[q],source:K.EVENT_MESSAGE_THREADINFO_UPDATED}))),W((function(){return _(En,void 0,void 0,(function(){var e,t,n,r;return m(this,(function(s){try{for(e=v(this._groupChannelHandlers.values()),t=e.next();!t.done;t=e.next())t.value.onThreadInfoUpdated(V,G)}catch(e){n={error:e}}finally{try{t&&!t.done&&(r=e.return)&&r.call(e)}finally{if(n)throw n.error}}return[2]}))}))})),bn.label=22;case 22:return[3,79];case 23:B=e.as(dt).groupChannelMemberCounts,z=[],bn.label=24;case 24:bn.trys.push([24,29,30,31]),Y=v(B),J=Y.next(),bn.label=25;case 25:return J.done?[3,28]:(Z=J.value,ue=Z.channelUrl,nt=Z.memberCount,rt=Z.joinedMemberCount,$=Z.updatedAt,[4,this.getChannelFromCache(ue)]);case 26:(ee=bn.sent())&&ee._setLatestMemberCount(nt,rt,$)&&z.push(ee),bn.label=27;case 27:return J=Y.next(),[3,25];case 28:return[3,31];case 29:return te=bn.sent(),pn={error:te},[3,31];case 30:try{J&&!J.done&&(fn=Y.return)&&fn.call(Y)}finally{if(pn)throw pn.error}return[7];case 31:return z.length>0&&(this._dispatcher.dispatch(new Be({channels:z,source:je.EVENT_CHANNEL_MEMBER_COUNT_UPDATED})),W((function(){return _(En,void 0,void 0,(function(){var e,t,n,r;return m(this,(function(s){try{for(e=v(this._groupChannelHandlers.values()),t=e.next();!t.done;t=e.next())t.value.onChannelMemberCountChanged(z)}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,79];case 32:return ne=e.as(ht),re=ne.event,se=ne.status,ue=ne.channelUrl,ce=ne.channelType,ue&&ce===o.GROUP?[4,this.getChannel(ue,!0)]:[3,34];case 33:ie=bn.sent(),this._dispatcher.dispatch(new N({event:re,source:K.EVENT_POLL_UPDATED})),W(se===X?function(){return _(En,void 0,void 0,(function(){var e,t,n,r;return m(this,(function(s){try{for(e=v(this._groupChannelHandlers.values()),t=e.next();!t.done;t=e.next())t.value.onPollDeleted(ie,re.pollId)}catch(e){n={error:e}}finally{try{t&&!t.done&&(r=e.return)&&r.call(e)}finally{if(n)throw n.error}}return[2]}))}))}:function(){return _(En,void 0,void 0,(function(){var e,t,n,r;return m(this,(function(s){try{for(e=v(this._groupChannelHandlers.values()),t=e.next();!t.done;t=e.next())t.value.onPollUpdated(ie,re)}catch(e){n={error:e}}finally{try{t&&!t.done&&(r=e.return)&&r.call(e)}finally{if(n)throw n.error}}return[2]}))}))}),bn.label=34;case 34:return[3,79];case 35:return ae=e.as(Ue),oe=ae.event,ue=ae.channelUrl,ce=ae.channelType,ue&&ce===o.GROUP?[4,this.getChannel(ue,!0)]:[3,37];case 36:le=bn.sent(),this._dispatcher.dispatch(new M({event:oe,source:K.EVENT_POLL_VOTED})),W((function(){return _(En,void 0,void 0,(function(){var e,t,n,r;return m(this,(function(s){try{for(e=v(this._groupChannelHandlers.values()),t=e.next();!t.done;t=e.next())t.value.onPollVoted(le,oe)}catch(e){n={error:e}}finally{try{t&&!t.done&&(r=e.return)&&r.call(e)}finally{if(n)throw n.error}}return[2]}))}))})),bn.label=37;case 37:return[3,79];case 38:if(!(he=e.as(ut).event).isGroupChannelEvent)return[3,77];switch(he.category){case ct.CHANNEL_JOIN:return[3,39];case ct.CHANNEL_LEAVE:return[3,41];case ct.CHANNEL_OPERATOR_UPDATE:return[3,45];case ct.CHANNEL_INVITE:return[3,47];case ct.CHANNEL_DECLINE_INVITE:return[3,49];case ct.TYPING_START:case ct.TYPING_END:return[3,51];case ct.USER_CHANNEL_MUTE:case ct.USER_CHANNEL_UNMUTE:return[3,53];case ct.USER_CHANNEL_BAN:return[3,55];case ct.USER_CHANNEL_UNBAN:return[3,59];case ct.CHANNEL_FREEZE:case ct.CHANNEL_UNFREEZE:return[3,61];case ct.CHANNEL_HIDE:return[3,63];case ct.CHANNEL_UNHIDE:return[3,65];case ct.CHANNEL_DELETED:return[3,67];case ct.CHANNEL_PROP_CHANGED:return[3,69];case ct.CHANNEL_META_DATA_CHANGED:return[3,71];case ct.CHANNEL_META_COUNTERS_CHANGED:return[3,73];case ct.PINNED_MESSAGE_CHANGED:return[3,75]}return[3,77];case 39:return[4,this.getChannel(he.channelUrl,!0)];case 40:return de=bn.sent(),pe=e.as(An),fe=pe.memberCount,_e=pe.joinedMemberCount,me=pe.members,ve=!1,me.forEach((function(e){de.isExclusive||de.isSuper||de.isBroadcast?ve=ve||de._setLatestMemberCount(fe,_e,he.ts):(e.state=xt.JOINED,de.addMember(e,he.ts),En._updateJoinedMemberCount(de)),e.userId===En._sdkState.userId&&(de.myMemberState=xt.JOINED)})),this._dispatcher.dispatch(new Be({channels:[de],source:je.EVENT_CHANNEL_JOINED})),W((function(){return _(En,void 0,void 0,(function(){return m(this,(function(e){return this._groupChannelHandlers.forEach((function(e){var t,n;try{for(var r=v(me),s=r.next();!s.done;s=r.next()){var i=s.value;e.onUserJoined(de,i)}}catch(e){t={error:e}}finally{try{s&&!s.done&&(n=r.return)&&n.call(r)}finally{if(t)throw t.error}}de.isBroadcast&&ve&&e.onChannelMemberCountChanged([de])})),[2]}))}))})),[3,77];case 41:return(Ut=this._leftChannels.get(he.channelUrl))?(De=Ut.channel,[3,44]):[3,42];case 42:return[4,this.getChannel(he.channelUrl,!0)];case 43:De=bn.sent(),bn.label=44;case 44:return ge=De,Le=e.as(Dn),nt=Le.memberCount,rt=Le.joinedMemberCount,ke=Le.member,Pe=!1,xe=j.of(this._iid).appInfo,ge.isExclusive||ge.isSuper||ge.isBroadcast?Pe=ge._setLatestMemberCount(nt,rt,he.ts):(xe.enabledChannelMemberShipHistory?(ge.members.find((function(e){return e.userId===ke.userId})).state=xt.LEFT,ge.memberCount=nt):ge.removeMember(ke),this._updateJoinedMemberCount(ge)),ke.userId===this._sdkState.userId?(ge.myMemberState=xt.NONE,ge.invitedAt=0,ge.joinedAt=0,ge._updateUnreadCount(0,0),ge.isPublic?this._dispatcher.dispatch(new Be({channels:[ge],source:je.EVENT_CHANNEL_LEFT})):(this._markAsLeave(ge),this._dispatcher.dispatch(new qe({channelUrls:[ge.url],source:je.EVENT_CHANNEL_LEFT})))):this._dispatcher.dispatch(new Be({channels:[ge],source:je.EVENT_CHANNEL_LEFT})),W((function(){return _(En,void 0,void 0,(function(){return m(this,(function(e){return this._groupChannelHandlers.forEach((function(e){e.onUserLeft(ge,ke),ge.isBroadcast&&Pe&&e.onChannelMemberCountChanged([ge])})),[2]}))}))})),[3,77];case 45:return[4,this.getChannel(he.channelUrl,!0)];case 46:Re=bn.sent(),Fe=e.as(lt).operators,Oe=Fe.map((function(e){return e.userId}));try{for(He=v(Re.members),Ge=He.next();!Ge.done;Ge=He.next())(St=Ge.value).role=Oe.includes(St.userId)?a.OPERATOR:a.NONE}catch(e){_n={error:e}}finally{try{Ge&&!Ge.done&&(mn=He.return)&&mn.call(He)}finally{if(_n)throw _n.error}}return Re.myRole=Oe.includes(this._sdkState.userId)?a.OPERATOR:a.NONE,this._dispatcher.dispatch(new Be({channels:[Re],source:je.EVENT_CHANNEL_OPERATOR_UPDATED})),W((function(){return _(En,void 0,void 0,(function(){return m(this,(function(e){return this._groupChannelHandlers.forEach((function(e){e.onOperatorUpdated(Re,Fe)})),[2]}))}))})),[3,77];case 47:return[4,this.getChannel(he.channelUrl,!0)];case 48:Ve=bn.sent(),ze=e.as(Pn),nt=ze.memberCount,rt=ze.joinedMemberCount,Qe=ze.inviter,(We=ze.invitees).forEach((function(e){return e.state=xt.INVITED}));try{for(Ke=v(We),Ye=Ke.next();!Ye.done;Ye=Ke.next())Je=Ye.value,Ve.isExclusive||Ve.isSuper||Ve.isBroadcast?Ve._setLatestMemberCount(nt,rt,he.ts):Ve.addMember(Je,he.ts),this._sdkState.userId===Je.userId&&(Ve.hiddenState=ts.UNHIDDEN,Ve.myMemberState!==xt.JOINED&&(Ve.myMemberState=xt.INVITED),Ve.invitedAt=he.ts)}catch(e){vn={error:e}}finally{try{Ye&&!Ye.done&&(gn=Ke.return)&&gn.call(Ke)}finally{if(vn)throw vn.error}}return this._dispatcher.dispatch(new Be({channels:[Ve],source:je.EVENT_CHANNEL_INVITED})),W((function(){return _(En,void 0,void 0,(function(){return m(this,(function(e){return this._groupChannelHandlers.forEach((function(e){e.onUserReceivedInvitation(Ve,Qe,We)})),[2]}))}))})),[3,77];case 49:return[4,this.getChannel(he.channelUrl,!0)];case 50:return et=bn.sent(),tt=e.as(Rn),nt=tt.memberCount,rt=tt.joinedMemberCount,st=tt.inviter,it=tt.invitee,et.isExclusive||et.isSuper||et.isBroadcast?et._setLatestMemberCount(nt,rt,he.ts):et.removeMember(it),this._sdkState.userId===it.userId?(et.invitedAt=0,et.myMemberState=xt.NONE,et.isPublic?this._dispatcher.dispatch(new Be({channels:[et],source:je.EVENT_CHANNEL_DECLINED_INVITE})):this._dispatcher.dispatch(new qe({channelUrls:[et.url],source:je.EVENT_CHANNEL_DECLINED_INVITE}))):this._dispatcher.dispatch(new Be({channels:[et],source:je.EVENT_CHANNEL_DECLINED_INVITE})),W((function(){return _(En,void 0,void 0,(function(){return m(this,(function(e){return this._groupChannelHandlers.forEach((function(e){e.onUserDeclinedInvitation(et,st,it)})),[2]}))}))})),[3,77];case 51:return[4,this.getChannel(he.channelUrl,!0)];case 52:return at=bn.sent(),ot=he.category===ct.TYPING_START,vt=e.as(ot?Qn:Kn).user,at._updateTypingStatus(vt,ot?he.ts:0),this._dispatcher.dispatch(new Be({channels:[at],source:je.EVENT_CHANNEL_TYPING_STATUS_UPDATE})),W((function(){return _(En,void 0,void 0,(function(){return m(this,(function(e){return this._groupChannelHandlers.forEach((function(e){e.onTypingStatusUpdated(at)})),[2]}))}))})),[3,77];case 53:return[4,this.getChannel(he.channelUrl,!0)];case 54:gt=bn.sent(),Ct=he.category===ct.USER_CHANNEL_MUTE,(Et=e.as(Ct?Ne:Se).user).userId===this._sdkState.userId&&(gt.myMutedState=Ct?es.MUTED:es.UNMUTED,gt._myMutedRemainingTime=Et.restrictionInfo.remainingDuration);try{for(bt=v(gt.members),Mt=bt.next();!Mt.done;Mt=bt.next())if((St=Mt.value).userId===Et.userId){St.isMuted=Ct;break}}catch(e){yn={error:e}}finally{try{Mt&&!Mt.done&&(Cn=bt.return)&&Cn.call(bt)}finally{if(yn)throw yn.error}}return this._dispatcher.dispatch(new Be({channels:[gt],source:Ct?je.EVENT_CHANNEL_MUTED:je.EVENT_CHANNEL_UNMUTED,data:Et.userId})),W((function(){return _(En,void 0,void 0,(function(){return m(this,(function(e){return this._groupChannelHandlers.forEach((function(e){Ct?e.onUserMuted(gt,Et):e.onUserUnmuted(gt,Et)})),[2]}))}))})),[3,77];case 55:return(Ut=this._leftChannels.get(he.channelUrl))?(It=Ut.channel,[3,58]):[3,56];case 56:return[4,this.getChannel(he.channelUrl,!0)];case 57:It=bn.sent(),bn.label=58;case 58:return Tt=It,this._markAsLeave(Tt),At=e.as(Me).user,W((function(){return _(En,void 0,void 0,(function(){return m(this,(function(e){return this._groupChannelHandlers.forEach((function(e){e.onUserBanned(Tt,At)})),[2]}))}))})),[3,77];case 59:return[4,this.getChannel(he.channelUrl,!0)];case 60:return wt=bn.sent(),Dt=e.as(be).user,W((function(){return _(En,void 0,void 0,(function(){return m(this,(function(e){return this._groupChannelHandlers.forEach((function(e){e.onUserUnbanned(wt,Dt)})),[2]}))}))})),[3,77];case 61:return[4,this.getChannel(he.channelUrl,!0)];case 62:return Lt=bn.sent(),kt=e.as(Ee).freeze,Lt.isFrozen=kt,this._dispatcher.dispatch(new Be({channels:[Lt],source:kt?je.EVENT_CHANNEL_FROZEN:je.EVENT_CHANNEL_UNFROZEN})),W((function(){return _(En,void 0,void 0,(function(){return m(this,(function(e){return this._groupChannelHandlers.forEach((function(e){kt?e.onChannelFrozen(Lt):e.onChannelUnfrozen(Lt)})),[2]}))}))})),[3,77];case 63:return[4,this.getChannel(he.channelUrl,!0)];case 64:return Pt=bn.sent(),Rt=e.as(jn),Ft=Rt.allowAutoUnhide,Ot=Rt.hidePreviousMessages,Ht=Rt.messageOffsetTimestamp,null!==Ft&&(Pt.hiddenState=Ft?ts.HIDDEN_ALLOW_AUTO_UNHIDE:ts.HIDDEN_PREVENT_AUTO_UNHIDE),null!==Ot&&Ot&&Pt._updateUnreadCount(0,0),null!==Ht&&(Pt.messageOffsetTimestamp=Ht),this._dispatcher.dispatch(new Be({channels:[Pt],source:je.EVENT_CHANNEL_HIDDEN})),W((function(){return _(En,void 0,void 0,(function(){return m(this,(function(e){return this._groupChannelHandlers.forEach((function(e){e.onChannelHidden(Pt)})),[2]}))}))})),[3,77];case 65:return[4,this.getChannel(he.channelUrl,!0)];case 66:return(Gt=bn.sent()).hiddenState=ts.UNHIDDEN,this._dispatcher.dispatch(new Be({channels:[Gt],source:je.EVENT_CHANNEL_UNHIDDEN})),W((function(){return _(En,void 0,void 0,(function(){return m(this,(function(e){return this._groupChannelHandlers.forEach((function(e){e.onChannelChanged(Gt)})),[2]}))}))})),[3,77];case 67:return[4,this.getChannel(he.channelUrl,!0)];case 68:return Vt=bn.sent(),this._dispatcher.dispatch(new qe({channelUrls:[he.channelUrl],source:je.EVENT_CHANNEL_DELETED})),W((function(){return _(En,void 0,void 0,(function(){return m(this,(function(e){return this._groupChannelHandlers.forEach((function(e){e.onChannelDeleted(Vt.url,Vt.channelType)})),[2]}))}))})),[3,77];case 69:return[4,this.getChannelWithoutCache(he.channelUrl,!0)];case 70:return qt=bn.sent(),this._dispatcher.dispatch(new Be({channels:[qt],source:je.EVENT_CHANNEL_UPDATED})),W((function(){return _(En,void 0,void 0,(function(){return m(this,(function(e){return this._groupChannelHandlers.forEach((function(e){e.onChannelChanged(qt)})),[2]}))}))})),[3,77];case 71:return[4,this.getChannel(he.channelUrl,!0)];case 72:return Bt=bn.sent(),jt=e.as(Ce),zt=jt.created,Qt=jt.updated,Wt=jt.deleted,zt&&Bt._upsertCachedMetaData(zt,he.ts),Qt&&Bt._upsertCachedMetaData(Qt,he.ts),Wt&&Bt._removeFromCachedMetaData(Wt,he.ts),W((function(){return _(En,void 0,void 0,(function(){return m(this,(function(e){return this._groupChannelHandlers.forEach((function(e){zt&&e.onMetaDataCreated(Bt,zt),Qt&&e.onMetaDataUpdated(Bt,Qt),Wt&&e.onMetaDataDeleted(Bt,Wt)})),[2]}))}))})),[3,77];case 73:return[4,this.getChannel(he.channelUrl,!0)];case 74:return Kt=bn.sent(),Yt=e.as(ye),Jt=Yt.created,Xt=Yt.updated,Zt=Yt.deleted,W((function(){return _(En,void 0,void 0,(function(){return m(this,(function(e){return this._groupChannelHandlers.forEach((function(e){Jt&&e.onMetaCounterCreated(Kt,Jt),Xt&&e.onMetaCounterUpdated(Kt,Xt),Zt&&e.onMetaCounterDeleted(Kt,Zt)})),[2]}))}))})),[3,77];case 75:return[4,this.getChannel(he.channelUrl,!0)];case 76:return $t=bn.sent(),en=e.as(Zn),tn=en.pinnedMessageIds,nn=en.latestPinnedMessage,(rn=en.ts)>$t._pinnedMessagesUpdatedAt&&($t.pinnedMessageIds=tn,$t.lastPinnedMessage=nn,$t._pinnedMessagesUpdatedAt=rn,this._dispatcher.dispatch(new Be({channels:[$t],source:je.EVENT_PINNED_MESSAGE_UPDATED})),W((function(){return _(En,void 0,void 0,(function(){var e,t,n,r;return m(this,(function(s){try{for(e=v(this._groupChannelHandlers.values()),t=e.next();!t.done;t=e.next())t.value.onChannelChanged($t)}catch(e){n={error:e}}finally{try{t&&!t.done&&(r=e.return)&&r.call(e)}finally{if(n)throw n.error}}return[2]}))}))})),W((function(){return _(En,void 0,void 0,(function(){return m(this,(function(e){return this._groupChannelHandlers.forEach((function(e){e.onPinnedMessageUpdated($t)})),[2]}))}))}))),[3,77];case 77:return[3,79];case 78:switch((sn=e.as(Xe).event).category){case Ze.USER_BLOCK:an=$e.getDataAsUserBlockEvent(this._iid,sn),un=an.blocker,cn=an.blockee,this._groupChannelCache.block(un.userId,cn.userId);break;case Ze.USER_UNBLOCK:on=$e.getDataAsUserBlockEvent(this._iid,sn),un=on.blocker,cn=on.blockee,this._groupChannelCache.unblock(un.userId,cn.userId)}return[3,79];case 79:return[3,81];case 80:if(ln=bn.sent(),Q(ln))throw ln;return[3,81];case 81: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===xt.JOINED})).length},e.prototype.getChannel=function(e,t){return void 0===t&&(t=!1),_(this,void 0,void 0,(function(){var n;return m(this,(function(r){switch(r.label){case 0:Y(y("string",e)).throw(q.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),_(this,void 0,void 0,(function(){var n,r,s,i,a;return m(this,(function(o){switch(o.label){case 0:return Y(y("string",e)).throw(q.invalidParameters),n=new cn({channelUrl:e,isInternalCall:t}),[4,this._requestQueue.send(n)];case 1:switch(r=o.sent(),s=r.as(ln).channel,i=s.unreadMessageCount,a=s.unreadMentionCount,s.myCountPreference){case $r.UNREAD_MESSAGE_COUNT_ONLY:a=0;break;case $r.UNREAD_MENTION_COUNT_ONLY:i=0;break;case $r.OFF:i=0,a=0}return s._updateUnreadCount(i,a),[4,this.upsertChannelsToCache([s])];case 2:return[2,o.sent()[0]]}}))}))},e.prototype.refreshChannel=function(e,t,n){return void 0===t&&(t=!0),void 0===n&&(n=je.REFRESH_CHANNEL),_(this,void 0,void 0,(function(){var r,s,i,a,o;return m(this,(function(u){switch(u.label){case 0:return u.trys.push([0,5,,6]),r=new cn({channelUrl:e,isInternalCall:t}),[4,this._requestQueue.send(r)];case 1:return s=u.sent(),(i=s.as(ln).channel).myMemberState!==xt.NONE?[3,2]:(this._dispatcher.dispatch(new qe({channelUrls:[i.url],source:n})),[3,4]);case 2:return[4,this.upsertChannelsToCache([i])];case 3:a=u.sent(),this._dispatcher.dispatch(new Be({channels:a,source:n})),u.label=4;case 4:return[3,6];case 5:return(o=u.sent()).code!==J.NON_AUTHORIZED&&o.code!==J.NOT_FOUND_IN_DATABASE||this._dispatcher.dispatch(new qe({channelUrls:[e],source:n})),[3,6];case 6:return[2]}}))}))},e.prototype.getMyGroupChannels=function(e,t,n,r){return void 0===r&&(r=je.REQUEST_CHANNEL),_(this,void 0,void 0,(function(){var i,a,o,u,c;return m(this,(function(l){switch(l.label){case 0:return i=new hn(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(dn),u=o.channels,c=o.token,this._dispatcher.dispatch(new Be({channels:u,source:r})),[2,{channels:u,token:c}]}}))}))},e.prototype.getMessageFromCache=function(e){return _(this,void 0,void 0,(function(){return m(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=De),_(this,void 0,void 0,(function(){return m(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.getPollMessagesFromCache=function(e,t,n,r){return void 0===r&&(r=De),_(this,void 0,void 0,(function(){return m(this,(function(s){switch(s.label){case 0:return[4,this._messageCache.fetch({channelUrl:e,token:t,limit:r,filter:n,backward:!1,isPollOnly:!0})];case 1:return[2,s.sent()]}}))}))},e.prototype.getUnsentMessagesFromCache=function(e,t){return _(this,void 0,void 0,(function(){return m(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 _(this,void 0,void 0,(function(){return m(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 _(this,void 0,void 0,(function(){return m(this,(function(s){switch(s.label){case 0:return[4,this._messageCache.countBetween(e,t,new Xn({top:n,bottom:r}))];case 1:return[2,s.sent()]}}))}))},e.prototype.getMyGroupChannelChangeLogs=function(e,t,n){return void 0===n&&(n=je.REQUEST_CHANNEL_CHANGELOGS),_(this,void 0,void 0,(function(){var i,a,o,u,c,l,h;return m(this,(function(d){switch(d.label){case 0:return i=s(s({},Xt),t),Y((y("string",e)||y("number",e))&&Zt(i)).throw(q.invalidParameters),a=new on(r({userId:this._sdkState.userId,ts:"number"==typeof e?e:null,token:"string"==typeof e?e:null,filter:i})),[4,this._requestQueue.send(a)];case 1:return o=d.sent(),u=o.as(un),c=u.updatedChannels,l=u.deletedChannelUrls,h=u.hasMore,c.length>0&&this._dispatcher.dispatch(new Be({channels:c,source:n})),l.length>0&&this._dispatcher.dispatch(new qe({channelUrls:l,source:n})),[2,{updatedChannels:c,deletedChannelUrls:l,hasMore:h,token:u.token}]}}))}))},e.prototype.getGroupChannelCount=function(e){return _(this,void 0,void 0,(function(){var t,n,r;return m(this,(function(i){switch(i.label){case 0:return t=s(s({},$t),e),Y(en(t)).throw(q.invalidParameters),n=new pn({userId:this._sdkState.userId,filter:t}),[4,this._requestQueue.send(n)];case 1:return r=i.sent(),[2,r.as(fn).groupChannelCount]}}))}))},e.prototype.getUnreadItemCount=function(e){return _(this,void 0,void 0,(function(){var t,n,i,a,o,u,c,l,h,d,p,f,_,v,y,C;return m(this,(function(m){switch(m.label){case 0:return t=s(s({},tn),e),Y(function(e){return g(Qt,e.keys)}(t)).throw(q.invalidParameters),n=j.of(this._iid),i=n.sdkState,a=n.requestQueue,o=new _n({userId:i.userId,filter:t}),[4,a.send(o)];case 1:return u=m.sent(),c=u.as(mn),l=c.groupChannelUnreadMentionCount,h=c.groupChannelUnreadMessageCount,d=c.groupChannelInvitationCount,p=c.superGroupChannelUnreadMentionCount,f=c.superGroupChannelUnreadMessageCount,_=c.superGroupChannelInvitationCount,v=c.nonSuperGroupChannelUnreadMentionCount,y=c.nonSuperGroupChannelUnreadMessageCount,C=c.nonSuperGroupChannelInvitationCount,[2,r({groupChannelUnreadMentionCount:l,groupChannelUnreadMessageCount:h,groupChannelInvitationCount:d,superGroupChannelUnreadMentionCount:p,superGroupChannelUnreadMessageCount:f,superGroupChannelInvitationCount:_,nonSuperGroupChannelUnreadMentionCount:v,nonSuperGroupChannelUnreadMessageCount:y,nonSuperGroupChannelInvitationCount:C})]}}))}))},e.prototype.getTotalUnreadChannelCount=function(){return _(this,void 0,void 0,(function(){var e,t,n,r,s;return m(this,(function(i){switch(i.label){case 0:return e=j.of(this._iid),t=e.sdkState,n=e.requestQueue,r=new vn({userId:t.userId}),[4,n.send(r)];case 1:return s=i.sent(),[2,s.as(gn).unreadCount]}}))}))},e.prototype.getTotalUnreadMessageCount=function(e){return _(this,void 0,void 0,(function(){var t,n,r,a,o,u;return m(this,(function(c){switch(c.label){case 0:return t=s(s({},nn),e),Y(function(e){return g("string",e.channelCustomTypesFilter,!0)&&i(Ot,e.superChannelFilter)}(t)).throw(q.invalidParameters),n=j.of(this._iid),r=n.sdkState,a=n.requestQueue,o=new yn({userId:r.userId,filter:t}),[4,a.send(o)];case 1:return u=c.sent(),[2,u.as(Cn).unreadCount]}}))}))},e.prototype.getTotalScheduledMessageCount=function(e){return void 0===e&&(e={}),_(this,void 0,void 0,(function(){var t,n,r,a;return m(this,(function(o){switch(o.label){case 0:return t=s(s({},rn),e),Y(function(e){return y("string",e.channelUrl,!0)&&g(gt,e.scheduledStatus,!0)&&i(E,e.messageTypeFilter)}(t)).throw(q.invalidParameters),n=j.of(this._iid).requestQueue,r=new En(t),[4,n.send(r)];case 1:return a=o.sent(),[2,a.as(bn).count]}}))}))},e.prototype.getSubscribedTotalUnreadMessageCount=function(){var e=j.of(this._iid).subscribedUnreadMessageCount;return e.all>=0?e.all:0},e.prototype.getSubscribedCustomTypeTotalUnreadMessageCount=function(){var e=0,t=j.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=j.of(this._iid).subscribedUnreadMessageCount.customTypes[e])&&void 0!==t?t:0},e.prototype.createChannel=function(e){return _(this,void 0,void 0,(function(){var t,n,r,i;return m(this,(function(a){switch(a.label){case 0:return t=s(s({},Yt),e),Y(Jt(t)).throw(q.invalidParameters),t.isPublic||(t.accessCode=null),n=new Nn(s({userId:this._sdkState.userId},t)),[4,this._requestQueue.send(n)];case 1:return r=a.sent(),i=r.as(Sn).channel,[4,this.upsertChannelsToCache([i])];case 2:return a.sent(),[2,i]}}))}))},e.prototype.markAsReadAll=function(){return _(this,void 0,void 0,(function(){var e,t,n,r,s,i,a,o;return m(this,(function(u){switch(u.label){case 0:return e=Date.now(),Y(e-this._markAsReadAllLastSentAt>=1e3).throw(q.markAsReadAllRateLimitExceeded),this._markAsReadAllLastSentAt=e,t=new Un({userId:this._sdkState.userId}),[4,this._requestQueue.send(t)];case 1:u.sent(),n=this._groupChannelCache.channels;try{for(r=v(n),s=r.next();!s.done;s=r.next())(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.upsertChannelsToCache(n)]:[3,3];case 2:u.sent(),u.label=3;case 3:return[2]}}))}))},e.prototype.markAsReadWithChannelUrls=function(e){return _(this,void 0,void 0,(function(){var t,n,r,s,i,a,o,u,c;return m(this,(function(l){switch(l.label){case 0:return t=Date.now(),Y(g("string",e)&&t-this._markAsReadAllLastSentAt>=1e3).throw(q.markAsReadAllRateLimitExceeded),this._markAsReadAllLastSentAt=t,n=new Un({userId:this._sdkState.userId,channelUrls:e}),[4,this._requestQueue.send(n)];case 1:l.sent(),r=this._groupChannelCache.channels,s=[];try{for(i=v(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.upsertChannelsToCache(s)]:[3,3];case 2:l.sent(),l.label=3;case 3:return[2]}}))}))},e.prototype.markAsDelivered=function(e){return _(this,void 0,void 0,(function(){return m(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}();!function(e){e[e.IDLE=0]="IDLE",e[e.RUNNING=1]="RUNNING",e[e.END=2]="END"}(Gn||(Gn={}));var tr,nr=function(t){function n(e,n,r,s){var i=t.call(this)||this;return i._worker=null,i._state=Gn.IDLE,i._semaphore=null,i._retryCount=0,i._retryLimit=3,i.priority=0,i._worker=n,i}return e(n,t),Object.defineProperty(n.prototype,"isIdle",{get:function(){return this._state===Gn.IDLE},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"isRunning",{get:function(){return this._state===Gn.RUNNING},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"isDone",{get:function(){return this._state===Gn.END},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"retryCount",{get:function(){return this._retryCount},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"retryLimit",{get:function(){return this._retryLimit},enumerable:!1,configurable:!0}),n.prototype._run=function(e){return _(this,void 0,void 0,(function(){var t,n;return m(this,(function(r){switch(r.label){case 0:if(!this.isRunning)return[3,4];r.label=1;case 1:return r.trys.push([1,3,,4]),[4,this._worker(e)];case 2:return t=r.sent(),this._retryCount=0,this.dispatch("progress",t),t.hasNext?this._run(t.nextToken):this.end(),[3,4];case 3:return n=r.sent(),this.dispatch("error",n),this._retryCount0&&(r=n.map((function(e){return e.createdAt})),(i=this._metadata.range).intersect.apply(i,d([],f(r),!1))?this.extendRange(n):this._metadata={range:new Xn({top:Math.min.apply(Math,d([],f(r),!1)),bottom:Math.max.apply(Math,d([],f(r),!1))}),previousComplete:!1}),t.hasNext=n.length>=this._limit&&this._prevSyncLoopCount<1,t.nextToken=this._metadata.range.top,this._metadata.previousComplete=n.length0&&(r=n.map((function(e){return e.createdAt})),(i=this._metadata.range).intersect.apply(i,d([],f(r),!1))?this.extendRange(n):this._metadata={range:new Xn({top:Math.min.apply(Math,d([],f(r),!1)),bottom:Math.max.apply(Math,d([],f(r),!1))}),previousComplete:!1}),t.hasNext=n.length>=this._limit&&this._nextSyncLoopCount<1,t.nextToken=this._metadata.range.bottom,h.debug("message background next sync progress",t),[4,this.saveMetadata()];case 4:return u.sent(),[3,6];case 5:throw s=u.sent(),h.debug("message background next sync error",s),s;case 6:return[2,t]}}))}))})),this._connectionEventContext=l.on((function(e){if(e instanceof $)if(e.stateType===ee.CONNECTED)i.resume();else i.pause()}))}return e.of=function(t,n){return ir[t]||(ir[t]={}),ir[t][n.url]||(ir[t][n.url]=new e({_iid:t,channel:n})),ir[t][n.url].ref++,ir[t][n.url]},e.clear=function(e,t){ir[e]&&ir[e][t]&&(ir[e][t].close(),delete ir[e])},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,d([],f(e.map((function(e){return e.createdAt}))),!1))},e.prototype.extendRange=function(e){var t;this._metadata&&(t=this._metadata.range).extends.apply(t,d([],f(e.map((function(e){return e.createdAt}))),!1))},e.prototype.loadMetadata=function(e){return _(this,void 0,void 0,(function(){var t;return m(this,(function(n){switch(n.label){case 0:return this._metadata?[3,2]:[4,j.of(this._iid).cacheContext.preference.get(this._metadataKey)];case 1:(t=n.sent())?t.range.bottom0||r.length>0)&&(this._metadata.token=i),o.debug("message changelog sync progress",e),[4,this.saveMetadata()];case 4:return c.sent(),[3,8];case 5:return a=c.sent(),o.debug("message changelog sync error",a),a instanceof q&&a.isInvalidTokenError?[4,this.clearMetadata()]:[3,7];case 6:c.sent(),c.label=7;case 7:throw a;case 8:return[2,e]}}))}))})),this._connectionEventContext=c.on((function(e){if(e instanceof $)if(e.stateType===ee.CONNECTED)r.resume();else r.pause()}))}return e.of=function(t,n){return or[t]||(or[t]={}),or[t][n.url]||(or[t][n.url]=new e({_iid:t,channel:n})),or[t][n.url].ref++,or[t][n.url]},e.clear=function(e,t){or[e]&&or[e][t]&&(or[e][t].close(),delete or[e])},e.prototype.loadMetadata=function(){return _(this,void 0,void 0,(function(){var e,t,n,r;return m(this,(function(s){switch(s.label){case 0:return this._metadata?[3,2]:(e=j.of(this._iid),t=e.cacheContext,n=e.firstConnectedAt,[4,t.preference.get(this._metadataKey)]);case 1:r=s.sent(),this._metadata={token:r?r.token:n},s.label=2;case 2:return[2,this._metadata]}}))}))},e.prototype.saveMetadata=function(){return _(this,void 0,void 0,(function(){return m(this,(function(e){switch(e.label){case 0:return this._metadata?[4,j.of(this._iid).cacheContext.preference.set(this._metadataKey,this._metadata)]:[3,2];case 1:return e.sent(),[2,!0];case 2:return[2,!1]}}))}))},e.prototype.clearMetadata=function(){return _(this,void 0,void 0,(function(){return m(this,(function(e){switch(e.label){case 0:return[4,j.of(this._iid).cacheContext.preference.remove(this._metadataKey)];case 1:return e.sent(),this._metadata=null,[2]}}))}))},e.prototype.resume=function(){var e=j.of(this._iid),t=e.logger;e.connectionManager.isConnected&&(t.debug("message changelog sync resume()"),this._sync.start(0))},e.prototype.pause=function(){var e=j.of(this._iid),t=e.logger;e.connectionManager.isConnected&&(t.debug("message changelog sync pause()"),this._sync.stop())},e.prototype.close=function(){this.ref--,this.ref<=0&&(this.ref=0,this.pause(),this._connectionEventContext.close(),delete or[this._iid][this._channel.url])},e}(),cr={},lr=function(){function e(e){var t=e._iid,n=e.channel,r=e.hasPollMessage,s=this;this._sync=null,this.ref=0,this._metadata=null,this._iid=t,this._channel=n;var i,a,o=j.of(this._iid),u=o.logger,c=o.sdkState,l=o.dispatcher;this._metadataKey=(i=c.userId,a=n.url,"sendbird:".concat(i,"@groupchannel/").concat(a,"/poll/changelogs.meta"));var h=function(e,t){return"sendbird:".concat(e,"@groupchannel/").concat(t,"/poll/changelogs")}(c.userId,this._channel.url);this._sync=new nr(h,(function(){return _(s,void 0,void 0,(function(){var e,t,n,s,i,a,o,c;return m(this,(function(l){switch(l.label){case 0:return e={hasNext:!0,nextToken:0},[4,this.loadMetadata()];case 1:return l.sent(),u.debug("poll changelog sync from",null===(c=this._metadata)||void 0===c?void 0:c.token),(t=!this._metadata||!this._metadata.token)?[4,r()]:[3,3];case 2:t=!l.sent(),l.label=3;case 3:if(t)return[2,{hasNext:!1,nextToken:0}];this._metadata||(n=j.of(this._iid).firstConnectedAt,this._metadata={token:n}),l.label=4;case 4:return l.trys.push([4,7,,10]),[4,Pt.of(this._iid).getPollChangeLogs(this._channel.url,this._channel.channelType,this._metadata.token)];case 5:return s=l.sent(),i=s.hasMore,a=s.token,e.hasNext=i,e.nextToken=a,this._metadata.token=a,u.debug("poll changelog sync progress",e),[4,this.saveMetadata()];case 6:return l.sent(),[3,10];case 7:return o=l.sent(),u.debug("poll changelog sync error",o),o instanceof q&&o.isInvalidTokenError?[4,this.clearMetadata()]:[3,9];case 8:l.sent(),l.label=9;case 9:throw o;case 10:return[2,e]}}))}))})),this._connectionEventContext=l.on((function(e){if(e instanceof $)if(e.stateType===ee.CONNECTED)s.resume();else s.pause()}))}return e.of=function(t,n,r){return cr[t]||(cr[t]={}),cr[t][n.url]||(cr[t][n.url]=new e({_iid:t,channel:n,hasPollMessage:r})),cr[t][n.url].ref++,cr[t][n.url]},e.prototype.loadMetadata=function(){return _(this,void 0,void 0,(function(){var e;return m(this,(function(t){switch(t.label){case 0:return this._metadata?[3,2]:[4,j.of(this._iid).cacheContext.preference.get(this._metadataKey)];case 1:e=t.sent(),this._metadata=e?{token:e.token}:null,t.label=2;case 2:return[2]}}))}))},e.prototype.saveMetadata=function(){return _(this,void 0,void 0,(function(){return m(this,(function(e){switch(e.label){case 0:return this._metadata?[4,j.of(this._iid).cacheContext.preference.set(this._metadataKey,this._metadata)]:[3,2];case 1:e.sent(),e.label=2;case 2:return[2]}}))}))},e.prototype.clearMetadata=function(){return _(this,void 0,void 0,(function(){return m(this,(function(e){switch(e.label){case 0:return[4,j.of(this._iid).cacheContext.preference.remove(this._metadataKey)];case 1:return e.sent(),this._metadata=null,[2]}}))}))},e.prototype.resume=function(){j.of(this._iid).logger.debug("poll changelog sync resume()"),this._sync.start(0)},e.prototype.pause=function(){j.of(this._iid).logger.debug("poll changelog sync pause()"),this._sync.stop()},e.prototype.close=function(){this.ref--,this.ref<=0&&(this.ref=0,this.pause(),this._connectionEventContext.close(),delete cr[this._iid][this._channel.url])},e}(),hr=function(t){function n(e){var n,s,i,a,o,u,c=this;return(c=t.call(this)||this).method=A.GET,c.path="".concat(ne(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,include_poll_details:!0,checking_continuous_messages:e.checkingContinuousMessages}),c}return e(n,t),n}(D),dr=function(t){function n(e,n){var r,s,i,a,o,u,c=this;return(c=t.call(this,e,n)||this).isHugeGap=n.is_huge_gap,c.prevMessages=(null!==(r=n.prev_messages)&&void 0!==r?r:[]).map((function(t){return Et(e,t)})),c.prevHasMore=null!==(s=n.prev_hasmore)&&void 0!==s&&s,c.isContinuousPrevMessages=null!==(i=n.is_continuous_prev_messages)&&void 0!==i&&i,c.nextMessages=(null!==(a=n.next_messages)&&void 0!==a?a:[]).map((function(t){return Et(e,t)})),c.nextHasmore=null!==(o=n.next_hasmore)&&void 0!==o&&o,c.isContinuousNextMessages=null!==(u=n.is_continuous_next_messages)&&void 0!==u&&u,c}return e(n,t),n}(L),pr=function(e,t){return e.findIndex((function(e){return e.isIdentical(t)}))},fr=function(e,t,n){if(e.length>0){for(var r=pr(e,t),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,oldPosition:r};s=a+1,a=Math.floor((s+i)/2)}}return{place:_r(e[a],t,n)>=0?a:a+1,oldPosition:r}}return{place:e.length,oldPosition:-1}},_r=function(e,t,n){switch(n){case He.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 He.CHRONOLOGICAL:return t.createdAt-e.createdAt;case He.CHANNEL_NAME_ALPHABETICAL:var r=e.name.localeCompare(t.name);return 0===r?e.createdAt-t.createdAt:r}},mr=function(e,t){return t instanceof yt?e.findIndex((function(e){return e instanceof yt&&t.isIdentical(e)})):e.findIndex((function(e){return e.isIdentical(t)}))},vr=function(e,t){return e.findIndex((function(e){return e.messageId===t}))},gr=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},yr=6e5;!function(e){e.CACHE_AND_REPLACE_BY_API="cache_and_replace_by_api"}(tr||(tr={}));var Cr,Er,br,Mr=function(){function e(){}return e.prototype._invokeResponse=function(e,t,n){var r=this;W((function(){return _(r,void 0,void 0,(function(){return m(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}(),Nr=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._backgroundSync=null,this._changelogSync=null,this._pollChangelogSync=null,this._checkMyMutedStateTimer=null,this._iid=e,this._key="mc-".concat(ae()),this.filter=null!=r?r:new Ye,this._channel=n,this._syncRange=new Xn({}),this._hasPrevious=!0,this._hasNext=!0,this._startingPoint="number"==typeof s?s:Date.now()+yr,this._limit=i||De;var o=er.of(this._iid);o.subscribeGroupChannelEvent(this._key,{onUpdate:function(e,t,n){var r=pr(e,a._channel);if(r>=0){switch(a._channel=e[r],t){case je.EVENT_CHANNEL_UPDATED:var s=!1;for(var i in a._messages){if(a._messages[i].createdAt>=a._channel.messageOffsetTimestamp){s=!0;var o=parseInt(i);if(o>0){var u=a._messages.splice(0,o);a._removeMessagesFromView(u.map((function(e){return e.messageId})),K.EVENT_MESSAGE_OFFSET_UPDATED)}break}}!s&&a._messages.length>0&&a._removeMessagesFromView(a._messages.map((function(e){return e.messageId})),K.EVENT_MESSAGE_OFFSET_UPDATED);break;case je.EVENT_CHANNEL_UNMUTED:var c=n;j.of(a._iid).sdkState.userId===c&&a._clearCheckMyMutedTimer();break;case je.EVENT_CHANNEL_MUTED:var l=n;j.of(a._iid).sdkState.userId===l&&-1!==a.channel._myMutedRemainingTime&&a._startCheckMyMutedTimer(a.channel._myMutedRemainingTime);break;case je.EVENT_CHANNEL_LEFT:a.channel.isPublic&&a._clearCheckMyMutedTimer()}W((function(){return _(a,void 0,void 0,(function(){var e,n;return m(this,(function(r){return e=new rr(t),et(t)&&(null===(n=this._handler)||void 0===n?void 0:n.onChannelUpdated)&&this._handler.onChannelUpdated(e,this.channel),[2]}))}))}))}},onRemove:function(e,t){e.indexOf(a.channel.url)>=0&&(a._clearCheckMyMutedTimer(),W((function(){return _(a,void 0,void 0,(function(){var e,n;return m(this,(function(r){return e=new rr(t),(null===(n=this._handler)||void 0===n?void 0:n.onChannelDeleted)&&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=v(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(re(t)){if(s.length>0)switch(t){case K.EVENT_MESSAGE_SENT_FAILED:case K.EVENT_MESSAGE_SENT_SUCCESS:case K.EVENT_MESSAGE_UPDATED:case K.EVENT_MESSAGE_THREADINFO_UPDATED:case K.EVENT_MESSAGE_REACTION_UPDATED:case K.SYNC_MESSAGE_CHANGELOGS:a._updateMessagesToView(s,t);break;case K.EVENT_MESSAGE_SENT_PENDING:a._addMessagesToView(s,t);break;case K.EVENT_MESSAGE_RECEIVED:a.hasNext||a._addMessagesToView(s,t);break;case K.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)},onPollChangeLogUpdate:function(e,t){a._updatePollsToView(e,t)},onPollUpdate:function(e,t){a._applyPollUpdateEventToView(e,t)},onPollVote:function(e,t){a._applyPollVoteEventToView(e,t)}});var u=j.of(this._iid),c=u.cacheContext,l=u.dispatcher,h=u.logger;this._channel._updateMessageCollectionLastAccessedAt(),l.dispatch(new Be({channels:[this._channel],source:je.CHANNEL_LASTACCESSEDAT_UPDATED})),!this._channel.isSuper&&c.localCacheEnabled&&(this._backgroundSync=ar.of(this._iid,this._channel),this._backgroundSync.resume(this._startingPoint)),this._changelogSync=ur.of(this._iid,this._channel),this._changelogSync.resume(),this._pollChangelogSync=lr.of(this._iid,this._channel,this._hasPollMessage.bind(this)),this._pollChangelogSync.resume(),this._prevFill=new nr(this._key,(function(e){return _(a,void 0,void 0,(function(){var t,n,r,s,i;return m(this,(function(a){switch(a.label){case 0:return[4,this._getRemoteMessages(e,{prevLimit:this._limit,source:K.SYNC_MESSAGE_FILL,checkingContinuousMessages:c.localCacheEnabled})];case 1:return t=a.sent(),n=t.messages,r=t.isContinuousMessages,n.length>0?(s=Math.min.apply(Math,d([],f(n.map((function(e){return e.createdAt}))),!1)),this._syncRange.extends(s),r&&(null===(i=this._backgroundSync)||void 0===i||i.range.extends(s)),[2,{hasNext:n.length>=this._limit&&this.viewTop0?(s=Math.max.apply(Math,d([],f(n.map((function(e){return e.createdAt}))),!1)),this._syncRange.extends(s),r&&(null===(i=this._backgroundSync)||void 0===i||i.range.extends(s)),[2,{hasNext:!(n.length>=this._limit&&this._hasNext)||this.viewBottom>s,nextToken:this._syncRange.bottom}]):[2,{hasNext:!1,nextToken:0}]}}))}))})),this._connectionEventContext=l.on((function(e){if(e instanceof $)switch(e.stateType){case ee.CONNECTED:a._refreshChannel(je.SYNC_CHANNEL_CHANGELOGS),b((function(){return _(a,void 0,void 0,(function(){var e;return m(this,(function(t){switch(t.label){case 0:return[4,this.channel.getMyMutedInfo()];case 1:return(e=t.sent()).isMuted&&-1!==e.remainingDuration&&this._startCheckMyMutedTimer(e.remainingDuration),[2]}}))}))})),h.debug("check huge gap"),a._checkHugeGap();break;case ee.LOGOUT:a.dispose();break;default:a._clearCheckMyMutedTimer(),a._prevFill.stop(),a._nextFill.stop()}})),j.of(this._iid).statLogCollector.put(new se({type:ie.FEATURE_LOCALCACHE,data:{use_local_cache:c.localCacheEnabled,collection_interface:{message:!0}}}))}return Object.defineProperty(e.prototype,"channel",{get:function(){return this._channel},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"succeededMessages",{get:function(){return d([],f(this._messages),!1)},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"failedMessages",{get:function(){return this._unsentMessages.filter((function(e){return e.sendingStatus===oe.FAILED}))},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"pendingMessages",{get:function(){return this._unsentMessages.filter((function(e){return e.sendingStatus===oe.PENDING}))},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"hasPrevious",{get:function(){return this._hasPrevious},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"hasNext",{get:function(){return this._hasNext},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"viewTop",{get:function(){return Math.min.apply(Math,d(d([],f(this._messages.map((function(e){return e.createdAt}))),!1),[Number.MAX_SAFE_INTEGER],!1))},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"viewBottom",{get:function(){return Math.max.apply(Math,d(d([],f(this._messages.map((function(e){return e.createdAt}))),!1),[0],!1))},enumerable:!1,configurable:!0}),e.prototype.setMessageCollectionHandler=function(e){this._handler=e},e.prototype._filterUnderOffsetMessage=function(e){return e},e.prototype._addMessagesToView=function(e,t){var n,r,s=this,i=this._filterUnderOffsetMessage(e),a=[],o=[];try{for(var u=v(i),c=u.next();!c.done;c=u.next()){var l=c.value;if(t===K.SYNC_MESSAGE_FILL){if(l.messageId>0){if((y=mr(this._messages,l))<0){mr(this._unsentMessages,l)<0&&a.push(l);var h=gr(this._messages,l);this._messages.splice(h,0,l)}}else if(l instanceof yt){(y=mr(this._unsentMessages,l))<0&&mr(this._messages,l)<0&&(this._unsentMessages.push(l),a.push(l))}}else if(l.messageId>0){if((y=mr(this._messages,l))<0){var p=mr(this._unsentMessages,l);p<0?a.push(l):(this._unsentMessages.splice(p,1),o.push(l));h=gr(this._messages,l);this._messages.splice(h,0,l)}else o.push(l),this._messages[y]=l;if(l.updatedAt>0){var g=this._updateChildMessagesInView(l);o.push.apply(o,d([],f(g),!1))}}else if(l instanceof yt){var y;(y=mr(this._unsentMessages,l))<0?mr(this._messages,l)<0&&(this._unsentMessages.push(l),a.push(l)):(o.push(l),this._unsentMessages[y]=l)}}}catch(e){n={error:e}}finally{try{c&&!c.done&&(r=u.return)&&r.call(u)}finally{if(n)throw n.error}}re(t)&&W((function(){return _(s,void 0,void 0,(function(){var e,n,r;return m(this,(function(s){return e=new sr(t),a.length>0&&(null===(n=this._handler)||void 0===n||n.onMessagesAdded(e,this.channel,a)),o.length>0&&(null===(r=this._handler)||void 0===r||r.onMessagesUpdated(e,this.channel,o)),[2]}))}))}))},e.prototype._updateChildMessagesInView=function(e){var t=[];return this._messages.forEach((function(n){n.applyParentMessage(e)&&t.push(n)})),t},e.prototype._updatePollsToView=function(e,t){var n,r,s=this,i=[];try{for(var a=v(e),o=a.next();!o.done;o=a.next()){var u=o.value,c=vr(this._messages,u.messageId);if(c>=0){var l=this._messages[c];l&&l.applyPoll(u),i.push(l)}}}catch(e){n={error:e}}finally{try{o&&!o.done&&(r=a.return)&&r.call(a)}finally{if(n)throw n.error}}return i.length>0&&re(t)&&W((function(){return _(s,void 0,void 0,(function(){var e,n;return m(this,(function(r){return e=new sr(t),i.length>0&&(null===(n=this._handler)||void 0===n||n.onMessagesUpdated(e,this.channel,i)),[2]}))}))})),i},e.prototype._applyPollUpdateEventToView=function(e,t){var n=this,r=vr(this._messages,e.messageId);if(r>=0){var s=this._messages[r];s&&s.isUserMessage()&&s.poll&&s.poll.applyPollUpdateEvent(e)&&re(t)&&W((function(){return _(n,void 0,void 0,(function(){var e,n;return m(this,(function(r){return e=new sr(t),null===(n=this._handler)||void 0===n||n.onMessagesUpdated(e,this.channel,[s]),[2]}))}))}))}},e.prototype._applyPollVoteEventToView=function(e,t){var n=this,r=vr(this._messages,e.messageId);if(r>=0){var s=this._messages[r];s&&s.isUserMessage()&&s.poll&&s.poll.applyPollVoteEvent(e)&&re(t)&&W((function(){return _(n,void 0,void 0,(function(){var e,n;return m(this,(function(r){return e=new sr(t),null===(n=this._handler)||void 0===n||n.onMessagesUpdated(e,this.channel,[s]),[2]}))}))}))}},e.prototype._updateMessagesToView=function(e,t){var n,r,s=this,i=[],a=[];try{for(var o=v(e),u=o.next();!u.done;u=o.next()){var c,l=u.value;if(l.messageId>0)if((c=mr(this._messages,l))>=0)i.push(l),this._messages[c]=l;else{var h=mr(this._unsentMessages,l);if(h>=0){var d=this._unsentMessages.splice(h,1);if(this.hasNext&&d.length>0)a.push(d[0]);else{i.push(l);var p=gr(this._messages,l);this._messages.splice(p,0,l)}}}else if(l instanceof yt)(c=mr(this._unsentMessages,l))>=0&&(i.push(l),this._unsentMessages[c]=l)}}catch(e){n={error:e}}finally{try{u&&!u.done&&(r=o.return)&&r.call(o)}finally{if(n)throw n.error}}return re(t)&&W((function(){return _(s,void 0,void 0,(function(){var e,n,r;return m(this,(function(s){return e=new sr(t),i.length>0?null===(n=this._handler)||void 0===n||n.onMessagesUpdated(e,this.channel,i):a.length>0&&(null===(r=this._handler)||void 0===r||r.onMessagesDeleted(e,this.channel,[],a)),[2]}))}))})),i},e.prototype._removeMessagesFromView=function(e,t){var n,r,s=this,i=[],a=[],o=function(e){var t=u._messages.findIndex((function(t){return t.messageId===e}));if(t>=0){var n=u._messages[t];i.push(n.messageId),a.push(n),u._messages.splice(t,1)}},u=this;try{for(var c=v(e),l=c.next();!l.done;l=c.next()){o(l.value)}}catch(e){n={error:e}}finally{try{l&&!l.done&&(r=c.return)&&r.call(c)}finally{if(n)throw n.error}}return re(t)&&a.length>0&&W((function(){return _(s,void 0,void 0,(function(){var e,n;return m(this,(function(r){return e=new sr(t),null===(n=this._handler)||void 0===n||n.onMessagesDeleted(e,this.channel,i,a),[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 _(this,void 0,void 0,(function(){var t,n,s,a,o,u,c;return m(this,(function(l){switch(l.label){case 0:return t=er.of(this._iid),r>0?[4,t.getMessagesFromCache(this._channel.url,e,"prev",this.filter,r)]:[3,2];case 1:return s=l.sent(),[3,3];case 2:s=[],l.label=3;case 3:return n=s,i>0?[4,t.getMessagesFromCache(this._channel.url,e,"next",this.filter,i)]:[3,5];case 4:return o=l.sent(),[3,6];case 5:o=[],l.label=6;case 6:if(a=o,n.length>0&&a.length>0)for(c in u=n.map((function(e){return e.messageId})),a)if(u.includes(a[c].messageId)){a.splice(parseInt(c),1);break}return[2,d(d([],f(n),!1),f(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?K.REQUEST_MESSAGE:o,c=t.reverse,l=void 0!==c&&c,h=t.checkingContinuousMessages,d=void 0!==h&&h;return _(this,void 0,void 0,(function(){var t,n;return m(this,(function(i){switch(i.label){case 0:return t=St.of(this._iid),r>0||a>0?[4,t._getMessagesByTimestampForCollection(this._channel.url,this._channel.channelType,e,s(s({},this.filter),{isInclusive:!0,reverse:l,prevResultSize:r,nextResultSize:a,includeMetaArray:!0,includeReactions:!0,includeThreadInfo:!0,includeParentMessageInfo:!0}),u,d)]:[3,2];case 1:return n=i.sent(),[3,3];case 2:n={messages:[],isContinuousMessages:!1},i.label=3;case 3:return[2,n]}}))}))},e.prototype._checkHugeGap=function(){var e;return _(this,void 0,void 0,(function(){var t,n,r,i,a,o,u,c,l,h,p,v,g,y,C,E,b,M,N,S,U=this;return m(this,(function(T){switch(T.label){case 0:return this._messages.length>0?(t=this._syncRange.top,n=this.viewTop,r=this._syncRange.bottom,i=this.hasNext?this.viewBottom:Number.MAX_SAFE_INTEGER,[4,(a=er.of(this._iid)).getCachedMessageCountBetween(this._channel.url,this.filter,n,t)]):[3,4];case 1:return o=T.sent(),[4,a.getCachedMessageCountBetween(this._channel.url,this.filter,r,i)];case 2:return u=T.sent(),[4,ue((function(){return _(U,void 0,void 0,(function(){var e,a,c,l,h,p,v,g,y,C,E,b,M,N,S,U,T,A,w,D,L,k=this;return m(this,(function(P){switch(P.label){case 0:return e=j.of(this._iid),a=e.dispatcher,c=e.requestQueue,l=e.cacheContext,h=new hr(s({channelUrl:this._channel.url,channelType:this._channel.channelType,prevStart:n,prevEnd:t,prevCount:o,nextStart:r,nextEnd:i,nextCount:u,checkingContinuousMessages:l.localCacheEnabled},this.filter)),[4,c.send(h)];case 1:return p=P.sent(),v=p.as(dr),g=v.isHugeGap,y=v.prevMessages,C=void 0===y?[]:y,E=v.prevHasMore,b=v.isContinuousPrevMessages,M=v.nextMessages,N=void 0===M?[]:M,S=v.nextHasmore,U=v.isContinuousNextMessages,g?W((function(){return _(k,void 0,void 0,(function(){var e;return m(this,(function(t){return null===(e=this._handler)||void 0===e||e.onHugeGapDetected(),[2]}))}))})):(this._hasPrevious=E,this._hasNext=S,T=this.viewTop,A=this.viewBottom,w=Math.min.apply(Math,d([Number.MAX_SAFE_INTEGER,T],f(C.map((function(e){return e.createdAt}))),!1)),D=Math.max.apply(Math,d([0,A],f(N.map((function(e){return e.createdAt}))),!1)),a.dispatch(new I({messages:C,source:K.SYNC_MESSAGE_FILL})),a.dispatch(new I({messages:N,source:K.SYNC_MESSAGE_FILL})),this._syncRange.extends(w,D),(b||U)&&(null===(L=this._backgroundSync)||void 0===L||L.range.extends(w,D)),TD&&this._nextFill.start(D)),[2]}}))}))}),1)];case 3:return T.sent(),[3,8];case 4:c=j.of(this._iid).cacheContext,l=Math.floor(this._limit/2),h=Date.now(),T.label=5;case 5:return T.trys.push([5,7,,8]),[4,this._getRemoteMessages(h,{prevLimit:l,nextLimit:l,source:K.SYNC_MESSAGE_FILL,checkingContinuousMessages:c.localCacheEnabled})];case 6:if(p=T.sent(),v=p.messages,g=p.isContinuousMessages,v.length>0){for(y=v.map((function(e){return e.createdAt})),C=0,E=0,b=0;b=h&&E++;this._hasPrevious=C>=l,this._hasNext=E>=l,(S=this._syncRange).extends.apply(S,d([],f(y),!1)),g&&(null===(e=this._backgroundSync)||void 0===e||e.range.extends(this._syncRange.top,this._syncRange.bottom)),this._addMessagesToView(v,K.SYNC_MESSAGE_FILL)}else this._hasPrevious=!1,this._hasNext=!1;return[3,8];case 7:return(N=T.sent())instanceof q&&N.code===J.NOT_FOUND_IN_DATABASE&&(this._hasPrevious=!1,this._hasNext=!1),[3,8];case 8:return[2]}}))}))},e.prototype._loadUnsentMessages=function(){return _(this,void 0,void 0,(function(){var e,t;return m(this,(function(n){switch(n.label){case 0:return e=er.of(this._iid),t=this,[4,e.getUnsentMessagesFromCache(this._channel.url,this.filter)];case 1:return t._unsentMessages=n.sent(),[2]}}))}))},e.prototype._hasPollMessage=function(){return _(this,void 0,void 0,(function(){return m(this,(function(e){switch(e.label){case 0:return[4,er.of(this._iid).getPollMessagesFromCache(this._channel.url,Date.now()+yr,this.filter,1)];case 1:return e.sent().length>0?[2,!0]:[2,!1]}}))}))},e.prototype._refreshChannel=function(e){er.of(this._iid).refreshChannel(this.channel.url,!0,e)},e.prototype._startCheckMyMutedTimer=function(e){var t=this;this._clearCheckMyMutedTimer(),this._checkMyMutedStateTimer=setTimeout((function(){return _(t,void 0,void 0,(function(){var e,t,n,r;return m(this,(function(s){switch(s.label){case 0:this._checkMyMutedStateTimer=null,e=!0,s.label=1;case 1:return s.trys.push([1,3,4,5]),[4,this._channel.getMyMutedInfo()];case 2:return t=s.sent(),e=!t.isMuted,[3,5];case 3:return s.sent(),e=!0,[3,5];case 4:return e&&(this.channel.myMutedState=es.UNMUTED,n=new rr(je.EVENT_CHANNEL_UNMUTED),null===(r=this._handler)||void 0===r||r.onChannelUpdated(n,this.channel)),[7];case 5:return[2]}}))}))}),e+1e3)},e.prototype._clearCheckMyMutedTimer=function(){this._checkMyMutedStateTimer&&(clearTimeout(this._checkMyMutedStateTimer),this._checkMyMutedStateTimer=null)},e.prototype.initialize=function(e){var t=this,n=new Mr;this._messages=[],this._unsentMessages=[],this._syncRange=new Xn({}),this._hasNext=!0,this._hasPrevious=!0,this._refreshChannel(je.REFRESH_CHANNEL),b((function(){return _(t,void 0,void 0,(function(){var e;return m(this,(function(t){switch(t.label){case 0:return[4,this.channel.getMyMutedInfo()];case 1:return(e=t.sent()).isMuted&&-1!==e.remainingDuration&&this._startCheckMyMutedTimer(e.remainingDuration),[2]}}))}))}));var r=Math.floor(this._limit/2);if(e===tr.CACHE_AND_REPLACE_BY_API)this._getLocalMessages(this._startingPoint,{prevLimit:r,nextLimit:r}).then((function(e){return _(t,void 0,void 0,(function(){var t;return m(this,(function(r){switch(r.label){case 0:return t=this._filterUnderOffsetMessage(e),this._addMessagesToView(t,K.REQUEST_MESSAGE),[4,this._loadUnsentMessages()];case 1:return r.sent(),n._invokeResponse("local",null,t),[2]}}))}))})).catch((function(e){if(Q(e))throw e;n._invokeResponse("local",e,null)})).finally((function(){var e=j.of(t._iid).cacheContext;t._getRemoteMessages(t._startingPoint,{prevLimit:r,nextLimit:r,reverse:!0,checkingContinuousMessages:e.localCacheEnabled}).then((function(e){var s,i,a=e.messages,o=e.isContinuousMessages;t._messages=[];var u=t._filterUnderOffsetMessage(a);if(u.length>0){for(var c=u.map((function(e){return e.createdAt})),l=0,h=0,p=0;p=t._startingPoint&&h++}t._hasPrevious=l>=r,t._hasNext=h>=r,(s=t._syncRange).extends.apply(s,d([],f(u.map((function(e){return e.createdAt}))),!1)),o&&(null===(i=t._backgroundSync)||void 0===i||i.range.extends(t._syncRange.top,t._syncRange.bottom)),t._addMessagesToView(u,K.REQUEST_MESSAGE)}else t._hasPrevious=!1,t._hasNext=!1;n._invokeResponse("remote",null,u)})).catch((function(e){if(Q(e))throw e;n._invokeResponse("remote",e,null)}))}));var s=j.of(this._iid),i=s.cacheContext;return s.statLogCollector.put(new se({type:ie.FEATURE_LOCALCACHE,data:{use_local_cache:i.localCacheEnabled,collection_interface:{message_init_policy:e}}})),n},e.prototype.loadPrevious=function(){return _(this,void 0,void 0,(function(){var e,t,n,r=this;return m(this,(function(s){switch(s.label){case 0:return this._hasPrevious?(e=this.viewTop,t=[],[4,b((function(){return _(r,void 0,void 0,(function(){var n;return m(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 s.sent(),0!==t.length&&this._backgroundSync&&this._backgroundSync.isWrappingMessages(t)?[3,3]:[4,b((function(){return _(r,void 0,void 0,(function(){var n,r,s,i,a;return m(this,(function(o){switch(o.label){case 0:return n=j.of(this._iid).cacheContext,[4,this._getRemoteMessages(e,{prevLimit:this._limit,checkingContinuousMessages:n.localCacheEnabled})];case 1:return r=o.sent(),t=this._filterUnderOffsetMessage(r.messages),this._hasPrevious=t.length>=this._limit,t.length>0&&((s=this._syncRange).extends.apply(s,d([],f(t.map((function(e){return e.createdAt}))),!1)),(null===(i=this._backgroundSync)||void 0===i?void 0:i.range.overlap(this._syncRange))&&r.isContinuousMessages&&(null===(a=this._backgroundSync)||void 0===a||a.range.extends(this._syncRange.top))),[2]}}))}))}))];case 2:return s.sent(),this._addMessagesToView(t,K.REQUEST_MESSAGE),[3,4];case 3:this._hasPrevious=t.length>=this._limit,t.length>0&&((n=this._syncRange).extends.apply(n,d([],f(t.map((function(e){return e.createdAt}))),!1)),this._addMessagesToView(t,K.REQUEST_MESSAGE)),s.label=4;case 4:return[2,t];case 5:return[2,[]]}}))}))},e.prototype.loadNext=function(){var e;return _(this,void 0,void 0,(function(){var t,n,r,s=this;return m(this,(function(i){switch(i.label){case 0:return this._hasNext?(t=this.viewBottom,n=[],[4,b((function(){return _(s,void 0,void 0,(function(){var e;return m(this,(function(r){switch(r.label){case 0:return e=this._filterUnderOffsetMessage,[4,this._getLocalMessages(t,{nextLimit:this._limit})];case 1:return n=e.apply(this,[r.sent()]),[2]}}))}))}))]):[2,[]];case 1:return i.sent(),0!==n.length&&(null===(e=this._backgroundSync)||void 0===e?void 0:e.isWrappingMessages(n))?[3,3]:[4,b((function(){return _(s,void 0,void 0,(function(){var e,r,s,i,a;return m(this,(function(o){switch(o.label){case 0:return e=j.of(this._iid).cacheContext,[4,this._getRemoteMessages(t,{nextLimit:this._limit,checkingContinuousMessages:e.localCacheEnabled})];case 1:return r=o.sent(),n=this._filterUnderOffsetMessage(r.messages),this._hasNext=n.length>=this._limit,n.length>0&&((s=this._syncRange).extends.apply(s,d([],f(n.map((function(e){return e.createdAt}))),!1)),(null===(i=this._backgroundSync)||void 0===i?void 0:i.range.overlap(this._syncRange))&&r.isContinuousMessages&&(null===(a=this._backgroundSync)||void 0===a||a.range.extends(this._syncRange.bottom))),[2]}}))}))}))];case 2:return i.sent(),this._addMessagesToView(n,K.REQUEST_MESSAGE),[3,4];case 3:this._hasNext=n.length>=this._limit,n.length>0&&((r=this._syncRange).extends.apply(r,d([],f(n.map((function(e){return e.createdAt}))),!1)),this._addMessagesToView(n,K.REQUEST_MESSAGE)),i.label=4;case 4:return[2,n]}}))}))},e.prototype.removeFailedMessage=function(e){return _(this,void 0,void 0,(function(){var t;return m(this,(function(n){switch(n.label){case 0:return[4,er.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,t,n,r=j.of(this._iid),s=r.cacheContext,i=r.dispatcher;this._clearCheckMyMutedTimer(),this._channel._updateMessageCollectionLastAccessedAt(),i.dispatch(new Be({channels:[this._channel],source:je.CHANNEL_LASTACCESSEDAT_UPDATED})),s.localCacheEnabled&&(this._prevFill.stop(),this._nextFill.stop()),null===(e=this._backgroundSync)||void 0===e||e.close(),null===(t=this._changelogSync)||void 0===t||t.close(),null===(n=this._pollChangelogSync)||void 0===n||n.close();var a=er.of(this._iid);a.unsubscribeGroupChannelEvent(this._key),a.unsubscribeMessageEvent(this._key),this._connectionEventContext&&this._connectionEventContext.close()},e}(),Sr={coverUrl:null,coverImage:null,isDistinct:null,isPublic:null,isDiscoverable:null,accessCode:null,name:null,data:null,customType:null,operatorUserIds:null,messageSurvivalSeconds:null},Ur={hidePreviousMessages:!1,allowAutoUnhide:!0},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=A.GET,n.path="".concat(x,"/").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}(D),Ir=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 jt(e,t)}))),r}return e(n,t),n}(L);!function(e){e.ALL="all",e.MUTED="muted",e.UNMUTED="unmuted"}(Cr||(Cr={})),function(e){e.MEMBER_NICKNAME_ALPHABETICAL="member_nickname_alphabetical",e.OPERATOR_THEN_MEMBER_ALPHABETICAL="operator_then_member_alphabetical"}(Er||(Er={})),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"}(br||(br={}));var Ar=function(t){function n(e,n,r){var s,i,a,u,c=this;return(c=t.call(this,e,n,o.GROUP,r)||this).mutedMemberFilter=Cr.ALL,c.memberStateFilter=br.ALL,c.nicknameStartsWithFilter=null,c.operatorFilter=Vt.ALL,c.order=Er.MEMBER_NICKNAME_ALPHABETICAL,c.mutedMemberFilter=null!==(s=r.mutedMemberFilter)&&void 0!==s?s:Cr.ALL,c.memberStateFilter=null!==(i=r.memberStateFilter)&&void 0!==i?i:br.ALL,c.nicknameStartsWithFilter=null!==(a=r.nicknameStartsWithFilter)&&void 0!==a?a:null,c.order=null!==(u=r.order)&&void 0!==u?u:Er.MEMBER_NICKNAME_ALPHABETICAL,c}return e(n,t),n.prototype._validate=function(){return t.prototype._validate.call(this)&&i(Cr,this.mutedMemberFilter)&&i(br,this.memberStateFilter)&&(y("string",this.nicknameStartsWithFilter)||null===this.nicknameStartsWithFilter)&&i(Vt,this.operatorFilter)&&i(Er,this.order)},n.prototype.next=function(){return _(this,void 0,void 0,(function(){var e,t,n,r,i,a;return m(this,(function(o){switch(o.label){case 0:return this._validate()?this._isLoading?[3,3]:this._hasNext?(this._isLoading=!0,e=j.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(Ir),i=r.members,a=r.token,this._token=a,this._hasNext=!!a,this._isLoading=!1,[2,i];case 2:return[2,[]];case 3:throw q.queryInProgress;case 4:return[3,6];case 5:throw q.invalidParameters;case 6:return[2]}}))}))},n}(ce),wr=function(t){function n(e){var n=this,r=e.channelUrl,s=e.userId,i=e.accessCode;return(n=t.call(this)||this).method=A.PUT,n.path="".concat(x,"/").concat(encodeURIComponent(r),"/accept"),n.params={user_id:s,access_code:i},n}return e(n,t),n}(D),Dr=function(t){function n(e,n){var r=t.call(this,e,n)||this;return r.channel=new os(e,n),r.channel.myMemberState=xt.JOINED,r}return e(n,t),n}(L),Lr=function(t){function n(e){var n=this,s=e.channelUrl,i=e.isDistinct,a=e.isPublic,o=e.isDiscoverable,u=e.coverUrl,c=e.coverImage,l=e.accessCode,h=e.name,d=e.data,p=e.customType,f=e.operatorUserIds,_=e.messageSurvivalSeconds;return(n=t.call(this)||this).method=A.PUT,n.path="".concat(x,"/").concat(encodeURIComponent(s)),n.params=r({is_distinct:i,is_public:a,is_discoverable:o,name:h,data:d,custom_type:p,cover_url:u,cover_file:c,access_code:l,operator_ids:f,message_survival_seconds:_}),n}return e(n,t),n}(D),kr=function(t){function n(e,n){var r=t.call(this,e,n)||this;return r.channel=new os(e,n),r}return e(n,t),n}(L),Pr=function(t){function n(e){var n=this,r=e.channelUrl;return(n=t.call(this)||this).method=A.DELETE,n.path="".concat(x,"/").concat(encodeURIComponent(r)),n}return e(n,t),n}(D);!function(t){function n(e,n){return t.call(this,e,n)||this}e(n,t)}(L);var xr=function(t){function n(e){var n=this,r=e.channelUrl;return(n=t.call(this)||this).method=A.DELETE,n.path="".concat(x,"/").concat(encodeURIComponent(r),"/hide"),n}return e(n,t),n}(D);!function(t){function n(){return null!==t&&t.apply(this,arguments)||this}e(n,t)}(L);var Rr=function(t){function n(e){var n=e.userId,r=e.channelUrl,s=e.countPreference,i=t.call(this)||this;return i.method=A.PUT,i.path="".concat(w,"/").concat(encodeURIComponent(n),"/count_preference/").concat(encodeURIComponent(r)),i.params={count_preference:s},i}return e(n,t),n}(D),Fr=function(t){function n(e,n){var r=t.call(this,e,n)||this;return r.countPreference=n.count_preference,r}return e(n,t),n}(L),Or=function(t){function n(e){var n=this,r=e.channelUrl;return(n=t.call(this)||this).method=A.PUT,n.path="".concat(x,"/").concat(encodeURIComponent(r),"/reset_user_history"),n}return e(n,t),n}(D),Hr=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}(L),Gr=s(s({},Le),{scheduledAt:null,file:null,fileUrl:null,fileName:null,mimeType:null,fileSize:null,thumbnailSizes:null,requireAuth:!1}),Vr=s(s({},Pe),{scheduledAt:null}),qr=function(t){function n(e){var n,s=this;s=t.call(this)||this;var i=null;e.mentionType===le.USERS&&(e.mentionedUserIds?i=e.mentionedUserIds:e.mentionedUsers&&(i=e.mentionedUsers.map((function(e){return e.userId}))));var a=e.channelType,o=e.channelUrl,u=e.scheduledMessageId;return s.method=A.PUT,s.path="".concat(ne(a),"/").concat(encodeURIComponent(o),"/scheduled_messages/").concat(encodeURIComponent(u)),s.params=r({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?e.thumbnailSizes.map((function(e){return Ut.payloadify(e)})):[],custom_type:e.customType,data:e.data,require_auth:e.requireAuth,mention_type:e.mentionType,mentioned_user_ids:i,sorted_metaarray:null===(n=e.metaArrays)||void 0===n?void 0:n.map((function(e){return Tt.payloadify(e)})),apple_critical_alert_options:It.payloadify(e.appleCriticalAlertOptions),push_option:e.pushNotificationDeliveryOption}),s}return e(n,t),n}(D),Br=function(t){function n(e,n){var r=t.call(this,e,n)||this;return r.message=new Mt(e,n),r}return e(n,t),n}(L),jr=function(t){function n(e){var n,s=this;s=t.call(this)||this;var i=null;e.mentionType===le.USERS&&(e.mentionedUserIds?i=e.mentionedUserIds:e.mentionedUsers&&(i=e.mentionedUsers.map((function(e){return e.userId}))));var a=e.channelType,o=e.channelUrl,u=e.scheduledMessageId;return s.method=A.PUT,s.path="".concat(ne(a),"/").concat(encodeURIComponent(o),"/scheduled_messages/").concat(encodeURIComponent(u)),s.params=r({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:i,sorted_metaarray:null===(n=e.metaArrays)||void 0===n?void 0:n.map((function(e){return Tt.payloadify(e)})),apple_critical_alert_options:It.payloadify(e.appleCriticalAlertOptions),target_langs:e.translationTargetLanguages,push_option:e.pushNotificationDeliveryOption}),s}return e(n,t),n}(D);!function(t){function n(e,n){var r=t.call(this,e,n)||this;return r.message=new bt(e,n),r}e(n,t)}(L);var zr=function(t){function n(e){var n=t.call(this)||this,r=e.channelType,s=e.channelUrl,i=e.scheduledMessageId;return n.method=A.DELETE,n.path="".concat(ne(r),"/").concat(encodeURIComponent(s),"/scheduled_messages/").concat(encodeURIComponent(i)),n}return e(n,t),n}(D),Qr=function(t){function n(e){var n=t.call(this)||this,r=e.channelType,s=e.channelUrl,i=e.scheduledMessageId;return n.method=A.POST,n.path="".concat(ne(r),"/").concat(encodeURIComponent(s),"/scheduled_messages/").concat(encodeURIComponent(i),"/send_now"),n}return e(n,t),n}(D),Wr=function(t){function n(e){var n=e.userId,r=e.channelUrl,s=e.pushTriggerOption,i=t.call(this)||this;return i.method=A.PUT,i.path="".concat(w,"/").concat(encodeURIComponent(n),"/push_preference/").concat(encodeURIComponent(r)),i.params={push_trigger_option:s},i}return e(n,t),n}(D),Kr=function(t){function n(e,n){var r=t.call(this,e,n)||this;return r.pushTriggerOption=n.push_trigger_option,r.enabled=n.enable,r}return e(n,t),n}(L),Yr=function(t){function n(e){var n=e.userId,r=e.channelUrl,s=t.call(this)||this;return s.method=A.GET,s.path="".concat(w,"/").concat(encodeURIComponent(n),"/push_preference/").concat(encodeURIComponent(r)),s}return e(n,t),n}(D),Jr=function(t){function n(e,n){var r=t.call(this,e,n)||this;return r.pushTriggerOption=n.push_trigger_option,r.enabled=n.enable,r}return e(n,t),n}(L),Xr=function(t){function n(e){var n=e.channelType,r=e.channelUrl,s=e.messageId,i=t.call(this)||this;return i.method=A.POST,i.path="".concat(ne(n),"/").concat(encodeURIComponent(r),"/messages/").concat(s,"/pin"),i}return e(n,t),n}(D);!function(t){function n(e,n){return t.call(this,e,n)||this}e(n,t)}(L);var Zr=function(t){function n(e){var n=e.channelType,r=e.channelUrl,s=e.messageId,i=t.call(this)||this;return i.method=A.DELETE,i.path="".concat(ne(n),"/").concat(encodeURIComponent(r),"/messages/").concat(s,"/pin"),i}return e(n,t),n}(D);!function(t){function n(e,n){return t.call(this,e,n)||this}e(n,t)}(L);var $r,es,ts,ns=function(t){function n(e,n){var r=t.call(this,e)||this;return r.message=Et(e,n.message),r}return e(n,t),n}(c),rs=function(t){function n(e){var n=this,s=e.channelType,i=e.channelUrl,a=e.limit,o=e.token,u=e.includeReactions,c=e.includeMetaArray,l=e.includeParentMessageInfo,h=e.includeThreadInfo,d=e.includePollDetails;return(n=t.call(this)||this).method=A.GET,n.path="".concat(ne(s),"/").concat(encodeURIComponent(i),"/pinned_messages"),n.params=r({limit:a,token:o,include_reactions:u,with_sorted_meta_array:c,include_thread_info:h,include_parent_message_info:l,include_poll_details:d}),n}return e(n,t),n}(D),ss=function(t){function n(e,n){var r=t.call(this,e,n)||this;r.hasMore=null,r.token=null;var s=n.pinned_messages,i=n.has_more,a=n.next;return r.pinnedMessages=s.map((function(t){return new ns(e,t)})),r.hasMore=i,r.token=a,r}return e(n,t),n}(L),is=function(t){function n(e,n,r,s){var i=t.call(this,e,n,r,s)||this;return i.includeMetaArray=s.includeMetaArray,i.includeReactions=s.includeReactions,i.includeParentMessageInfo=s.includeParentMessageInfo,i.includeThreadInfo=s.includeThreadInfo,i.includePollDetails=s.includePollDetails,i}return e(n,t),n.prototype._validate=function(){return t.prototype._validate.call(this)&&y("boolean",this.includeMetaArray,!0)&&y("boolean",this.includeReactions,!0)&&y("boolean",this.includeParentMessageInfo,!0)&&y("boolean",this.includeThreadInfo,!0)&&y("boolean",this.includePollDetails,!0)},n.prototype.next=function(){return _(this,void 0,void 0,(function(){var e,t,n,r,i,a,o;return m(this,(function(u){switch(u.label){case 0:return this._validate()?this._isLoading?[3,3]:this._hasNext?(this._isLoading=!0,e=j.of(this._iid).requestQueue,t=new rs(s(s({},this),{token:this._token})),[4,e.send(t)]):[3,2]:[3,5];case 1:return n=u.sent(),r=n.as(ss),i=r.pinnedMessages,a=r.hasMore,o=r.token,this._token=o,this._hasNext=!!a,this._isLoading=!1,[2,i];case 2:return[2,[]];case 3:throw q.queryInProgress;case 4:return[3,6];case 5:throw q.invalidParameters;case 6:return[2]}}))}))},n}(ce);!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"}($r||($r={})),function(e){e.MUTED="muted",e.UNMUTED="unmuted"}(es||(es={})),function(e){e.UNHIDDEN="unhidden",e.HIDDEN_ALLOW_AUTO_UNHIDE="hidden_allow_auto_unhide",e.HIDDEN_PREVENT_AUTO_UNHIDE="hidden_prevent_auto_unhide"}(ts||(ts={}));var as,os=function(t){function n(e,n){var r,c,l,h,p,_,m,v,g,C,E,b,M,N,S,U,T,I,A,w=this;return(w=t.call(this,e,n)||this)._unreadMemberStateMap=new Map,w._undeliveredMemberStateMap=new Map,w._typingStatus=new Map,w._lastMemberCountUpdated=0,w._typingStarted=0,w._typingEnded=0,w.isDistinct=!1,w.isSuper=!1,w.isBroadcast=!1,w.isExclusive=!1,w.isPublic=!1,w.isDiscoverable=!0,w.isAccessCodeRequired=!1,w.isPushEnabled=!1,w.unreadMessageCount=0,w.unreadMentionCount=0,w.members=[],w.memberCount=0,w.joinedMemberCount=0,w.hiddenState=ts.UNHIDDEN,w.lastMessage=null,w.messageOffsetTimestamp=0,w.messageSurvivalSeconds=-1,w.myMemberState=xt.NONE,w.myRole=a.NONE,w.myMutedState=es.UNMUTED,w.myLastRead=0,w.myCountPreference=$r.ALL,w.myPushTriggerOption=pe.DEFAULT,w.inviter=null,w.invitedAt=0,w.joinedAt=0,w.pinnedMessageIds=[],w.lastPinnedMessage=null,w._pinnedMessagesUpdatedAt=0,w._myMutedRemainingTime=-1,w.channelType=o.GROUP,w.isDistinct=null!==(c=n.is_distinct)&&void 0!==c&&c,w.isSuper=null!==(l=n.is_super)&&void 0!==l&&l,w.isBroadcast=null!==(h=n.is_broadcast)&&void 0!==h&&h,w.isExclusive=null!==(p=n.is_exclusive)&&void 0!==p&&p,w.isPublic=null!==(_=n.is_public)&&void 0!==_&&_,w.isDiscoverable=null!==(m=n.is_discoverable)&&void 0!==m?m:w.isPublic,w.isAccessCodeRequired=null!==(v=n.is_access_code_required)&&void 0!==v&&v,w.isPushEnabled=null!==(g=n.is_push_enabled)&&void 0!==g&&g,Array.isArray(n.members)&&(r=w.members).push.apply(r,d([],f(n.members.map((function(e){return new jt(w._iid,e)}))),!1)),w.memberCount=null!==(C=n.member_count)&&void 0!==C?C:0,w.joinedMemberCount=null!==(E=n.joined_member_count)&&void 0!==E?E:0,w.hiddenState=i(ts,n.hidden_state)?n.hidden_state:ts.UNHIDDEN,w.messageOffsetTimestamp=null!==(b=n.ts_message_offset)&&void 0!==b?b:0,w.messageSurvivalSeconds=null!==(M=n.message_survival_seconds)&&void 0!==M?M:-1,w.lastMessage=n.last_message?Et(w._iid,s({channel_type:w.channelType},n.last_message)):null,n.read_receipt&&Object.keys(n.read_receipt).forEach((function(e){y("number",n.read_receipt[e])&&w._updateUnreadMemberState(e,n.read_receipt[e])})),n.delivery_receipt&&Object.keys(n.delivery_receipt).forEach((function(e){y("number",n.delivery_receipt[e])&&w._updateUndeliveredMemberState(e,n.delivery_receipt[e])})),w.myMemberState=i(xt,n.member_state)?n.member_state:xt.NONE,w.myRole=i(a,n.my_role)?n.my_role:a.NONE,i(es,n.is_muted)?w.myMutedState=n.is_muted:y("boolean",n.is_muted)?w.myMutedState=n.is_muted?es.MUTED:es.UNMUTED:w.myMutedState=es.UNMUTED,w.myCountPreference=i($r,n.count_preference)?n.count_preference:$r.ALL,w.myPushTriggerOption=i(pe,n.push_trigger_option)?n.push_trigger_option:pe.ALL,w.myLastRead=null!==(N=n.user_last_read)&&void 0!==N?N:0,w.inviter=n.inviter?new u(w._iid,n.inviter):null,w.invitedAt=null!==(S=n.invited_at)&&void 0!==S?S:0,w.joinedAt=null!==(U=n.joined_ts)&&void 0!==U?U:0,w._updateUnreadCount(null!==(T=n.unread_message_count)&&void 0!==T?T:0,null!==(I=n.unread_mention_count)&&void 0!==I?I:0),w.pinnedMessageIds=null!==(A=n.pinned_message_ids)&&void 0!==A?A:[],w.lastPinnedMessage=n.latest_pinned_message?Et(w._iid,s({channel_type:w.channelType},n.latest_pinned_message)):null,w}return e(n,t),Object.defineProperty(n.prototype,"isHidden",{get:function(){return this.hiddenState!==ts.UNHIDDEN},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"isTyping",{get:function(){return this._typingStatus.size>0},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"cachedUnreadMemberState",{get:function(){var e,t,n={};try{for(var r=v(this._unreadMemberStateMap),s=r.next();!s.done;s=r.next()){var i=f(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(n.prototype,"cachedUndeliveredMemberState",{get:function(){var e,t,n={};try{for(var r=v(this._undeliveredMemberStateMap),s=r.next();!s.done;s=r.next()){var i=f(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}),n.payloadify=function(e){return e?r(s(s({},t.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 jt.payloadify(e)})),last_message:At(e.lastMessage),inviter:e.inviter?u.payloadify(e.inviter):null,invited_at:e.invitedAt,joined_ts:e.joinedAt,pinned_message_ids:e.pinnedMessageIds,latest_pinned_message:At(e.lastPinnedMessage)})):null},n.prototype._shouldUpdateLastMessageWith=function(e){return!(e instanceof yt&&e.parentMessageId>0&&!e.replyToChannel)&&(!this.lastMessage||this.lastMessage.createdAt=0)if(this.myCountPreference===$r.ALL||this.myCountPreference===$r.UNREAD_MESSAGE_COUNT_ONLY)if(this.isExclusive||this.isSuper||this.isBroadcast){var n=j.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===$r.ALL||this.myCountPreference===$r.UNREAD_MENTION_COUNT_ONLY)?this.unreadMentionCount=t:this.unreadMentionCount=0},n.prototype._updateUnreadMemberState=function(e,t){var n=this._unreadMemberStateMap.get(e);return(!n||n0?this._typingStatus.set(e.userId,{user:e,ts:t}):this._typingStatus.delete(e.userId)},n.prototype._clearTypingStatus=function(){this._typingStatus.clear(),this._typingStarted=0,this._typingEnded=0},n.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},n.prototype.isReadMessage=function(e){var t=j.of(this._iid).sdkState,n=this._unreadMemberStateMap.get(t.userId);return n&&n>=e.createdAt},n.prototype.serialize=function(){var e=this;return H(this,(function(t){t.cachedUnreadMemberState=e.cachedUnreadMemberState,t.cachedUndeliveredMemberState=e.cachedUndeliveredMemberState}))},n.prototype.createMessageCollection=function(e){return void 0===e&&(e={}),new Nr(this._iid,s({channel:this},e))},n.prototype.createMemberListQuery=function(e){return void 0===e&&(e={}),new Ar(this._iid,this.url,e)},n.prototype.createPinnedMessageListQuery=function(e){return void 0===e&&(e={}),new is(this._iid,this.url,this.channelType,e)},n.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===xt.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)}},n.prototype.removeMember=function(e){if(!this.isExclusive&&!this.isSuper&&!this.isBroadcast){var t=e instanceof jt?e.userId:e,n=this.members.findIndex((function(e){return e.userId===t}));if(n>-1)return this.members.splice(n,1),this.memberCount--,!0}return!1},n.prototype.getUnreadMemberCount=function(e){var t,n;if(e instanceof yt&&!this.isExclusive&&!this.isSuper&&!this.isBroadcast){var r=j.of(this._iid).sdkState,s=e.createdAt,i=0;try{for(var a=v(this.members),o=a.next();!o.done;o=a.next()){var u=o.value;if(r.userId!==u.userId&&u.state===xt.JOINED&&e.sender.userId!==u.userId)(this.cachedUnreadMemberState[u.userId]||0)=e.createdAt&&i.push(a))})),i},n.prototype.getUnreadMembers=function(e,t){var n=this;void 0===t&&(t=!1);var r=j.of(this._iid).sdkState;if(!r.userId||this.isExclusive||this.isSuper||this.isBroadcast)return[];var s=e instanceof yt?e.sender:null,i=[];return this.members.forEach((function(a){(t||a.userId!==r.userId&&a.userId!==(null==s?void 0:s.userId))&&(n._unreadMemberStateMap.get(a.userId)=t&&(e._typingStatus.delete(i),r=!0)})),r},n.prototype.refresh=function(){return _(this,void 0,void 0,(function(){var e,t,n,r,s,i;return m(this,(function(a){switch(a.label){case 0:return e=j.of(this._iid),t=e.requestQueue,n=e.dispatcher,r=new cn({channelUrl:this.url}),[4,t.send(r)];case 1:return s=a.sent(),i=s.as(ln).channel,this._update(i),n.dispatch(new Be({channels:[i],source:je.REQUEST_CHANNEL})),[2,this]}}))}))},n.prototype.freeze=function(){return _(this,void 0,void 0,(function(){return m(this,(function(e){switch(e.label){case 0:return[4,t.prototype.freeze.call(this)];case 1:return e.sent(),j.of(this._iid).dispatcher.dispatch(new Be({channels:[this],source:je.EVENT_CHANNEL_HIDDEN})),[2]}}))}))},n.prototype.unfreeze=function(){return _(this,void 0,void 0,(function(){return m(this,(function(e){switch(e.label){case 0:return[4,t.prototype.unfreeze.call(this)];case 1:return e.sent(),j.of(this._iid).dispatcher.dispatch(new Be({channels:[this],source:je.EVENT_CHANNEL_UNHIDDEN})),[2]}}))}))},n.prototype.updateChannel=function(e){return _(this,void 0,void 0,(function(){var t,n,r,i,a,o,u;return m(this,(function(c){switch(c.label){case 0:return t=s(s({},Sr),e),Y(function(e){return y("string",e.coverUrl,!0)&&(C(e.coverImage)||y("string",e.coverImage)||null===e.coverImage)&&y("boolean",e.isDistinct,!0)&&y("boolean",e.isPublic,!0)&&y("boolean",e.isDiscoverable,!0)&&y("string",e.accessCode,!0)&&y("string",e.name,!0)&&y("string",e.data,!0)&&y("string",e.customType,!0)&&g("string",e.operatorUserIds,!0)&&y("number",e.messageSurvivalSeconds,!0)}(t)).throw(q.invalidParameters),n=j.of(this._iid),r=n.dispatcher,i=n.requestQueue,a=new Lr(s({channelUrl:this.url},t)),[4,i.send(a)];case 1:return o=c.sent(),u=o.as(kr).channel,this._update(u),r.dispatch(new Be({channels:[u],source:je.EVENT_CHANNEL_UPDATED})),[2,this]}}))}))},n.prototype.invite=function(e){return _(this,void 0,void 0,(function(){return m(this,(function(t){return Y(e.every((function(e){return e instanceof u}))).throw(q.invalidParameters),[2,this.inviteWithUserIds(e.map((function(e){return e.userId})))]}))}))},n.prototype.inviteWithUserIds=function(e){return _(this,void 0,void 0,(function(){var t,n,r,s,i,a;return m(this,(function(o){switch(o.label){case 0:return Y(g("string",e)).throw(q.invalidParameters),t=j.of(this._iid),n=t.dispatcher,r=t.requestQueue,s=new Ln({channelUrl:this.url,userIds:e}),[4,r.send(s)];case 1:return i=o.sent(),a=i.as(kn).channel,this._update(a),n.dispatch(new Be({channels:[a],source:je.EVENT_CHANNEL_INVITED})),[2,this]}}))}))},n.prototype.join=function(e){return void 0===e&&(e=null),_(this,void 0,void 0,(function(){var t,n,r,s,i,a,o;return m(this,(function(u){switch(u.label){case 0:return Y(y("string",e)||null===e).throw(q.invalidParameters),t=j.of(this._iid),n=t.dispatcher,r=t.sdkState,s=t.requestQueue,i=new Tn({channelUrl:this.url,userId:r.userId,accessCode:e}),[4,s.send(i)];case 1:return a=u.sent(),(o=a.as(In).channel).myMemberState=this.myMemberState=xt.JOINED,this._update(o),n.dispatch(new Be({channels:[o],source:je.EVENT_CHANNEL_JOINED})),[2,this]}}))}))},n.prototype.leave=function(e){return void 0===e&&(e=!1),_(this,void 0,void 0,(function(){var t,n,r,s;return m(this,(function(i){switch(i.label){case 0:return t=j.of(this._iid),n=t.sdkState,r=t.requestQueue,s=new wn({channelUrl:this.url,userId:n.userId,shouldRemoveOperatorStatus:e}),[4,r.send(s)];case 1:return i.sent(),this.myMemberState=xt.NONE,[2]}}))}))},n.prototype.acceptInvitation=function(e){return void 0===e&&(e=null),_(this,void 0,void 0,(function(){var t,n,r,s,i,a,o;return m(this,(function(u){switch(u.label){case 0:return Y(y("string",e)||null===e).throw(q.invalidParameters),t=j.of(this._iid),n=t.dispatcher,r=t.sdkState,s=t.requestQueue,i=new wr({channelUrl:this.url,userId:r.userId,accessCode:e}),[4,s.send(i)];case 1:return a=u.sent(),(o=a.as(Dr).channel).myMemberState=this.myMemberState=xt.JOINED,this._update(o),n.dispatch(new Be({channels:[o],source:je.EVENT_CHANNEL_ACCEPTED_INVITE})),[2,this]}}))}))},n.prototype.declineInvitation=function(){return _(this,void 0,void 0,(function(){var e,t,n,r;return m(this,(function(s){switch(s.label){case 0:return e=j.of(this._iid),t=e.sdkState,n=e.requestQueue,r=new xn({channelUrl:this.url,userId:t.userId}),[4,n.send(r)];case 1:return s.sent(),this.myMemberState=xt.NONE,[2,this]}}))}))},n.prototype.sendUserMessage=function(e){var n=this,r=new Dt,s=j.of(this._iid).dispatcher,i=tt.of(this._iid);return t.prototype.sendUserMessage.call(this,e).onPending((function(e){i.completeCurrentAndProcessNextAutoResend(e),r._trigger(null,e)})).onFailed((function(e,t){t&&i.completeCurrentAndProcessNextAutoResend(t),r._trigger(e,t)})).onSucceeded((function(e){n.hiddenState===ts.HIDDEN_ALLOW_AUTO_UNHIDE&&(n.hiddenState=ts.UNHIDDEN),i.completeCurrentAndProcessNextAutoResend(e),n._shouldUpdateLastMessageWith(e)&&(n.lastMessage=e),er.of(n._iid).handlers.map((function(e){return e.onChannelChanged(n)})),s.dispatch(new Be({channels:[n],source:je.EVENT_MESSAGE_SENT})),r._trigger(null,e)})),r},n.prototype.updateUserMessage=function(e,n){return _(this,void 0,void 0,(function(){var r,s,i,a,o=this;return m(this,(function(u){switch(u.label){case 0:return r=j.of(this._iid).dispatcher,[4,t.prototype.updateUserMessage.call(this,e,n)];case 1:return s=u.sent(),i=!1,!s.silent&&this._shouldUpdateLastMessageWith(s)&&(this.lastMessage=s,i=!0),a=!1,this.lastPinnedMessage&&this.lastPinnedMessage.messageId===s.messageId&&(this.lastPinnedMessage=s,i=!0,a=!0),i&&(er.of(this._iid).handlers.map((function(e){return e.onChannelChanged(o)})),r.dispatch(new Be({channels:[this],source:a?je.EVENT_PINNED_MESSAGE_UPDATED:je.EVENT_MESSAGE_UPDATED}))),a&&er.of(this._iid).handlers.map((function(e){return e.onPinnedMessageUpdated(o)})),r.dispatch(new I({messages:[s],source:K.EVENT_MESSAGE_UPDATED})),[2,s]}}))}))},n.prototype._autoResendUserMessage=function(e){var n=this,r=new Dt,s=j.of(this._iid).dispatcher,i=tt.of(this._iid);return t.prototype._autoResendUserMessage.call(this,e).onPending((function(e){i.completeCurrentAndProcessNextAutoResend(e),r._trigger(null,e)})).onFailed((function(e,t){i.completeCurrentAndProcessNextAutoResend(t),r._trigger(e,t)})).onSucceeded((function(e){var t=er.of(n._iid);i.completeCurrentAndProcessNextAutoResend(e),n._shouldUpdateLastMessageWith(e)&&(n.lastMessage=e),t.handlers.map((function(e){return e.onChannelChanged(n)})),s.dispatch(new Be({channels:[n],source:je.EVENT_MESSAGE_SENT})),r._trigger(null,e)})),r},n.prototype.sendFileMessage=function(e){var n=this,r=new Dt,s=j.of(this._iid).dispatcher,i=tt.of(this._iid);return t.prototype.sendFileMessage.call(this,e).onPending((function(e){i.completeCurrentAndProcessNextAutoResend(e),r._trigger(null,e)})).onFailed((function(e,t){t&&i.completeCurrentAndProcessNextAutoResend(t),r._trigger(e,t)})).onSucceeded((function(e){var t=er.of(n._iid);i.completeCurrentAndProcessNextAutoResend(e),n._shouldUpdateLastMessageWith(e)&&(n.lastMessage=e),t.handlers.map((function(e){return e.onChannelChanged(n)})),s.dispatch(new Be({channels:[n],source:je.EVENT_MESSAGE_SENT})),r._trigger(null,e)})),r},n.prototype.sendMultipleFilesMessage=function(e){var n=this,r=new wt,s=j.of(this._iid).dispatcher;return t.prototype.sendMultipleFilesMessage.call(this,e).onPending((function(e){r._trigger(null,e)})).onFailed((function(e,t){r._trigger(e,t)})).onSucceeded((function(e){var t=er.of(n._iid);n._shouldUpdateLastMessageWith(e)&&(n.lastMessage=e),t.handlers.map((function(e){return e.onChannelChanged(n)})),s.dispatch(new Be({channels:[n],source:je.EVENT_MESSAGE_SENT})),r._trigger(null,e)})).onFileUploaded((function(e,t,n,s){r._triggerOnFileUploaded(e,t,n,s)})),r},n.prototype.updateFileMessage=function(e,n){return _(this,void 0,void 0,(function(){var r,s,i,a,o=this;return m(this,(function(u){switch(u.label){case 0:return r=j.of(this._iid).dispatcher,[4,t.prototype.updateFileMessage.call(this,e,n)];case 1:return s=u.sent(),i=!1,!s.silent&&this._shouldUpdateLastMessageWith(s)&&(this.lastMessage=s,i=!0),a=!1,this.lastPinnedMessage&&this.lastPinnedMessage.messageId===s.messageId&&(this.lastPinnedMessage=s,i=!0,a=!0),i&&(er.of(this._iid).handlers.map((function(e){return e.onChannelChanged(o)})),r.dispatch(new Be({channels:[this],source:a?je.EVENT_PINNED_MESSAGE_UPDATED:je.EVENT_MESSAGE_UPDATED}))),a&&er.of(this._iid).handlers.map((function(e){return e.onPinnedMessageUpdated(o)})),r.dispatch(new I({messages:[s],source:K.EVENT_MESSAGE_UPDATED})),[2,s]}}))}))},n.prototype._autoResendFileMessage=function(e){var n=this,r=new Dt,s=j.of(this._iid).dispatcher,i=tt.of(this._iid);return t.prototype._autoResendFileMessage.call(this,e).onPending((function(e){i.completeCurrentAndProcessNextAutoResend(e),r._trigger(null,e)})).onFailed((function(e,t){i.completeCurrentAndProcessNextAutoResend(t),r._trigger(e,t)})).onSucceeded((function(e){var t=er.of(n._iid);i.completeCurrentAndProcessNextAutoResend(e),n._shouldUpdateLastMessageWith(e)&&(n.lastMessage=e),t.handlers.map((function(e){return e.onChannelChanged(n)})),s.dispatch(new Be({channels:[n],source:je.EVENT_MESSAGE_SENT})),r._trigger(null,e)})),r},n.prototype.deleteMessage=function(e){return _(this,void 0,void 0,(function(){return m(this,(function(n){switch(n.label){case 0:return[4,t.prototype.deleteMessage.call(this,e)];case 1:return n.sent(),0===e.messageId&&e instanceof yt&&j.of(this._iid).dispatcher.dispatch(new U({reqId:e.reqId,source:K.EVENT_MESSAGE_DELETED})),[2]}}))}))},n.prototype.hide=function(e){return _(this,void 0,void 0,(function(){var t,n,r,i,a,o,u,c;return m(this,(function(l){switch(l.label){case 0:return t=s(s({},Ur),e),Y(function(e){return y("boolean",e.hidePreviousMessages)&&y("boolean",e.allowAutoUnhide)}(t)).throw(q.invalidParameters),n=j.of(this._iid),r=n.dispatcher,i=n.sdkState,a=n.requestQueue,o=new qn(s({channelUrl:this.url,userId:i.userId},t)),[4,a.send(o)];case 1:return u=l.sent(),c=u.as(Bn).messageOffsetTimestamp,this.hiddenState=t.allowAutoUnhide?ts.HIDDEN_ALLOW_AUTO_UNHIDE:ts.HIDDEN_PREVENT_AUTO_UNHIDE,t.hidePreviousMessages&&this._updateUnreadCount(0,0),c&&(this.messageOffsetTimestamp=c),r.dispatch(new Be({channels:[this],source:je.EVENT_CHANNEL_HIDDEN})),[2,this]}}))}))},n.prototype.unhide=function(){return _(this,void 0,void 0,(function(){var e,t,n,r;return m(this,(function(s){switch(s.label){case 0:return e=j.of(this._iid),t=e.dispatcher,n=e.requestQueue,r=new xr({channelUrl:this.url}),[4,n.send(r)];case 1:return s.sent(),this.hiddenState=ts.UNHIDDEN,t.dispatch(new Be({channels:[this],source:je.EVENT_CHANNEL_UNHIDDEN})),[2,this]}}))}))},n.prototype.delete=function(){return _(this,void 0,void 0,(function(){var e,t;return m(this,(function(n){switch(n.label){case 0:return e=j.of(this._iid).requestQueue,t=new Pr({channelUrl:this.url}),[4,e.send(t)];case 1:return n.sent(),[2]}}))}))},n.prototype.markAsRead=function(){return _(this,void 0,void 0,(function(){var e,t,n,r,s,i,a,o=this;return m(this,(function(u){switch(u.label){case 0:return e=j.of(this._iid),t=e.sdkState,n=e.dispatcher,r=e.requestQueue,s=new Fn({channelUrl:this.url}),[4,r.send(s)];case 1:return i=u.sent(),a=i.as(On).readStatus,this._updateUnreadMemberState(t.userId,a.readAt),(this.unreadMessageCount>0||this.unreadMentionCount>0)&&(this._updateUnreadCount(0,0),er.of(this._iid).handlers.map((function(e){return e.onChannelChanged(o)}))),n.dispatch(new Be({channels:[this],source:je.EVENT_CHANNEL_READ})),[2]}}))}))},n.prototype.markAsDelivered=function(){return _(this,void 0,void 0,(function(){var e,t,n,r;return m(this,(function(s){switch(s.label){case 0:return e=j.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]}}))}))},n.prototype.startTyping=function(){return _(this,void 0,void 0,(function(){var e,t,n,r,s;return m(this,(function(i){return e=j.of(this._iid),t=e.requestQueue,n=e.typingIndicatorThrottle,(r=(new Date).getTime())-this._typingStarted>=n&&(this._typingStarted=r,this._typingEnded=0,s=new zn({channelUrl:this.url,time:this._typingStarted}),t.send(s)),[2]}))}))},n.prototype.endTyping=function(){return _(this,void 0,void 0,(function(){var e,t,n,r,s;return m(this,(function(i){return e=j.of(this._iid),t=e.requestQueue,n=e.typingIndicatorThrottle,(r=(new Date).getTime())-this._typingEnded>=n&&(this._typingStarted=0,this._typingEnded=r,s=new Wn({channelUrl:this.url,time:this._typingStarted}),t.send(s)),[2]}))}))},n.prototype.createScheduledUserMessage=function(e){e=s(s({},nt),e),Y(rt(e)).throw(q.invalidParameters);var t=new Dt;return this._createScheduledUserMessage(e,t),t},n.prototype.updateScheduledUserMessage=function(e,t){return _(this,void 0,void 0,(function(){var n,r,i,a;return m(this,(function(o){switch(o.label){case 0:return n=s(s({},Vr),t),Y(function(e){return xe(e)&&y("number",e.scheduledAt,!0)}(n)).throw(q.invalidParameters),r=j.of(this._iid).requestQueue,i=new jr(s({reqId:this._generateRequestId(),scheduledMessageId:e,channelType:this.channelType,channelUrl:this.url},n)),[4,r.send(i)];case 1:return a=o.sent(),[2,a.as(Fe).message]}}))}))},n.prototype.createScheduledFileMessage=function(e){var t=this;e=s(s({},st),e),Y(it(e)).throw(q.invalidParameters);var n=Date.now(),r=this._generateRequestId(),i=new Dt;return de(Oe).then((function(){var s=t._createPendingScheduledFileMessage(e,r,n);W((function(){return _(t,void 0,void 0,(function(){return m(this,(function(e){return[2,i._trigger(null,s)]}))}))}))})),C(e.file)?this._uploadFileAndUpdateParams(e).then((function(){return t._createScheduledFileMessage(e,i,r,n)})):this._createScheduledFileMessage(e,i,r,n),i},n.prototype.updateScheduledFileMessage=function(e,t){return _(this,void 0,void 0,(function(){var n,r,i;return m(this,(function(a){switch(a.label){case 0:return n=s(s({},Gr),t),Y(function(e){return ke(e)&&y("number",e.scheduledAt,!0)&&(C(e.file)||y("string",e.fileUrl))&&y("string",e.fileName,!0)&&y("string",e.mimeType,!0)&&y("number",e.fileSize,!0)&&(null===e.thumbnailSizes||void 0===e.thumbnailSizes||e.thumbnailSizes.every((function(e){return y("object",e)&&e.maxWidth>0&&e.maxHeight>0})))}(n)).throw(q.invalidParameters),C(n.file)?[4,this._uploadFileAndUpdateParams(n)]:[3,2];case 1:a.sent(),a.label=2;case 2:return r=new qr(s({reqId:this._generateRequestId(),scheduledMessageId:e,channelType:this.channelType,channelUrl:this.url},n)),[4,j.of(this._iid).requestQueue.send(r)];case 3:return i=a.sent(),[2,i.as(Br).message]}}))}))},n.prototype.cancelScheduledMessage=function(e){return _(this,void 0,void 0,(function(){var t;return m(this,(function(n){switch(n.label){case 0:return t=new zr({scheduledMessageId:e,channelType:this.channelType,channelUrl:this.url}),[4,j.of(this._iid).requestQueue.send(t)];case 1:return n.sent(),[2]}}))}))},n.prototype.sendScheduledMessageNow=function(e){return _(this,void 0,void 0,(function(){var t;return m(this,(function(n){switch(n.label){case 0:return t=new Qr({scheduledMessageId:e,channelType:this.channelType,channelUrl:this.url}),[4,j.of(this._iid).requestQueue.send(t)];case 1:return n.sent(),[2]}}))}))},n.prototype.getMyPushTriggerOption=function(){return _(this,void 0,void 0,(function(){var e,t,n,r,s,i;return m(this,(function(a){switch(a.label){case 0:return e=j.of(this._iid),t=e.sdkState,n=e.requestQueue,r=new Yr({userId:t.userId,channelUrl:this.url}),[4,n.send(r)];case 1:return s=a.sent(),i=s.as(Jr).pushTriggerOption,this.myPushTriggerOption=i,[2,i]}}))}))},n.prototype.setMyPushTriggerOption=function(e){return _(this,void 0,void 0,(function(){var t,n,r,s,a,o,u;return m(this,(function(c){switch(c.label){case 0:return Y(i(pe,e)).throw(q.invalidParameters),t=j.of(this._iid),n=t.dispatcher,r=t.sdkState,s=t.requestQueue,a=new Wr({userId:r.userId,channelUrl:this.url,pushTriggerOption:e}),[4,s.send(a)];case 1:return o=c.sent(),u=o.as(Kr).pushTriggerOption,this.myPushTriggerOption=u,n.dispatch(new Be({channels:[this],source:je.EVENT_CHANNEL_UPDATED})),[2,u]}}))}))},n.prototype.setMyCountPreference=function(e){return _(this,void 0,void 0,(function(){var t,n,r,s,a,o,u;return m(this,(function(c){switch(c.label){case 0:return Y(i($r,e)).throw(q.invalidParameters),t=j.of(this._iid),n=t.dispatcher,r=t.sdkState,s=t.requestQueue,a=new Rr({channelUrl:this.url,userId:r.userId,countPreference:e}),[4,s.send(a)];case 1:return o=c.sent(),u=o.as(Fr).countPreference,this.myCountPreference=u,this._updateUnreadCount(this.unreadMessageCount,this.unreadMentionCount),n.dispatch(new Be({channels:[this],source:je.EVENT_CHANNEL_UPDATED})),[2,u]}}))}))},n.prototype.resetMyHistory=function(){return _(this,void 0,void 0,(function(){var e,t,n,r,s,i;return m(this,(function(a){switch(a.label){case 0:return e=j.of(this._iid),t=e.dispatcher,n=e.requestQueue,r=new Or({channelUrl:this.url}),[4,n.send(r)];case 1:return s=a.sent(),i=s.as(Hr).messageOffsetTimestamp,this.messageOffsetTimestamp=i,t.dispatch(new Be({channels:[this],source:je.EVENT_CHANNEL_RESET_HISTORY})),[2,this]}}))}))},n.prototype.pinMessage=function(e){return _(this,void 0,void 0,(function(){var t,n;return m(this,(function(r){switch(r.label){case 0:return Y(y("number",e)&&e>0).throw(q.invalidParameters),t=j.of(this._iid).requestQueue,n=new Xr({channelType:this.channelType,channelUrl:this.url,messageId:e}),[4,t.send(n)];case 1:return r.sent(),[2]}}))}))},n.prototype.unpinMessage=function(e){return _(this,void 0,void 0,(function(){var t,n;return m(this,(function(r){switch(r.label){case 0:return Y(y("number",e)&&e>0).throw(q.invalidParameters),t=j.of(this._iid).requestQueue,n=new Zr({channelType:this.channelType,channelUrl:this.url,messageId:e}),[4,t.send(n)];case 1:return r.sent(),[2]}}))}))},n.prototype._uploadFileAndUpdateParams=function(e){return _(this,void 0,void 0,(function(){var t,n,r,s,i,a,o,u,c,l,h;return m(this,(function(d){switch(d.label){case 0:return C(e.file)?(t=j.of(this._iid).requestQueue,n=new kt({file:e.file,channelUrl:this.url,thumbnailSizes:e.thumbnailSizes,requestId:this._generateRequestId()}),[4,t.send(n)]):[3,2];case 1:r=d.sent(),s=r.as(Lt),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]}}))}))},n}(Re),us={},cs=function(){function e(e){var t=e._iid,n=e.limit,r=void 0===n?100:n,s=this;this._sync=null,this._connectionEventContext=null,this.ref=0,this._metadata=null,this._iid=t,this._limit=r;var i,a=j.of(this._iid),o=a.sdkState,u=a.dispatcher,c=a.logger;this._metadataKey=(i=o.userId,"sendbird:".concat(i,"@groupchannel/sync.meta"));var l=function(e){return"sendbird:".concat(e,"@groupchannel/sync")}(o.userId);this._sync=new nr(l,(function(){return _(s,void 0,void 0,(function(){var e,t,n,r,s,i;return m(this,(function(a){switch(a.label){case 0:return e={hasNext:!0,nextToken:""},[4,this.loadMetadata()];case 1:if(a.sent(),c.debug("channel background sync from",this._metadata.token),this._metadata.completed)return[3,9];a.label=2;case 2:return a.trys.push([2,5,,8]),[4,er.of(this._iid).getMyGroupChannels(this._metadata.token,{includeEmpty:!0,order:He.CHRONOLOGICAL},this._limit,je.SYNC_CHANNEL_BACKGROUND)];case 3:return t=a.sent(),n=t.channels,r=t.token,e.hasNext=n.length>=this._limit&&!!r,e.nextToken=r,this._metadata.token=r,(i=this._metadata.range).extends.apply(i,d([],f(n.map((function(e){return e.createdAt}))),!1)),this._metadata.completed=!e.hasNext,c.debug("channel background sync progress",e),[4,this.saveMetadata()];case 4:return a.sent(),[3,8];case 5:return s=a.sent(),c.debug("channel background sync error",s),s instanceof q&&s.isInvalidTokenError?[4,this.clearMetaData()]:[3,7];case 6:a.sent(),a.label=7;case 7:throw s;case 8:return[3,10];case 9:e.hasNext=!1,e.nextToken="",a.label=10;case 10:return[2,e]}}))}))})),this._connectionEventContext=u.on((function(e){if(e instanceof $)if(e.stateType===ee.CONNECTED)s.resume();else s.pause()}))}return e.of=function(t){return us[t]||(us[t]=new e({_iid:t})),us[t].ref++,us[t]},e.clear=function(e){us[e]&&(us[e].close(),delete us[e])},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,"completed",{get:function(){var e;return!!(null===(e=this._metadata)||void 0===e?void 0:e.completed)},enumerable:!1,configurable:!0}),e.prototype.loadMetadata=function(){return _(this,void 0,void 0,(function(){var e;return m(this,(function(t){switch(t.label){case 0:return this._metadata?[3,2]:[4,j.of(this._iid).cacheContext.preference.get(this._metadataKey)];case 1:e=t.sent(),this._metadata={token:e?e.token:"",range:new Xn(e?e.range:{top:Number.MAX_SAFE_INTEGER,bottom:0}),completed:!!e&&e.completed},t.label=2;case 2:return[2,this._metadata]}}))}))},e.prototype.saveMetadata=function(){return _(this,void 0,void 0,(function(){return m(this,(function(e){switch(e.label){case 0:return this._metadata?[4,j.of(this._iid).cacheContext.preference.set(this._metadataKey,this._metadata)]:[3,2];case 1:return e.sent(),[2,!0];case 2:return[2,!1]}}))}))},e.prototype.clearMetaData=function(){return _(this,void 0,void 0,(function(){return m(this,(function(e){switch(e.label){case 0:return[4,j.of(this._iid).cacheContext.preference.remove(this._metadataKey)];case 1:return e.sent(),this._metadata=null,[2]}}))}))},e.prototype.resume=function(){var e,t,n=j.of(this._iid),r=n.logger;n.connectionManager.isConnected&&(r.debug("channel background sync resume()"),this._sync.start(null!==(t=null===(e=this._metadata)||void 0===e?void 0:e.token)&&void 0!==t?t:""))},e.prototype.pause=function(){j.of(this._iid).logger.debug("channel background sync stop()"),this._sync.stop()},e.prototype.close=function(){this.ref--,this.ref<=0&&(this.ref=0,this.pause(),this._connectionEventContext.close(),delete us[this._iid])},e}(),ls={},hs=function(){function e(e){var t=e._iid,n=this;this._sync=null,this._connectionEventContext=null,this.ref=0,this._metadataKey=null,this._metadata=null,this._iid=t;var r,s=j.of(this._iid),i=s.logger,a=s.sdkState,o=s.dispatcher;this._metadataKey=(r=a.userId,"sendbird:".concat(r,"@groupchannel/changelogs.meta"));var u=function(e){return"sendbird:".concat(e,"@groupchannel/changelogs")}(a.userId);this._sync=new nr(u,(function(){return _(n,void 0,void 0,(function(){var e,t,n,r,s;return m(this,(function(a){switch(a.label){case 0:return e={hasNext:!0,nextToken:0},[4,this.loadMetadata()];case 1:a.sent(),i.debug("channel changelog sync from",this._metadata.token),a.label=2;case 2:return a.trys.push([2,5,,8]),[4,er.of(this._iid).getMyGroupChannelChangeLogs(this._metadata.token,{includeEmpty:!0},je.SYNC_CHANNEL_CHANGELOGS)];case 3:return t=a.sent(),n=t.hasMore,r=t.token,e.hasNext=n,e.nextToken=r,this._metadata.token=r,i.debug("channel changelog sync progress",e),[4,this.saveMetadata()];case 4:return a.sent(),[3,8];case 5:return s=a.sent(),i.debug("channel changelog sync error",s),s instanceof q&&s.isInvalidTokenError?[4,this.clearMetadata()]:[3,7];case 6:a.sent(),a.label=7;case 7:throw s;case 8:return[2,e]}}))}))})),this._connectionEventContext=o.on((function(e){if(e instanceof $)if(e.stateType===ee.CONNECTED)n.resume();else n.pause()}))}return e.of=function(t){return ls[t]||(ls[t]=new e({_iid:t})),ls[t].ref++,ls[t]},e.clear=function(e){ls[e]&&(ls[e].close(),delete ls[e])},e.prototype.loadMetadata=function(){return _(this,void 0,void 0,(function(){var e,t,n,r;return m(this,(function(s){switch(s.label){case 0:return this._metadata?[3,2]:(e=j.of(this._iid),t=e.cacheContext,n=e.firstConnectedAt,[4,t.preference.get(this._metadataKey)]);case 1:r=s.sent(),this._metadata={token:r?r.token:n},s.label=2;case 2:return[2,this._metadata]}}))}))},e.prototype.saveMetadata=function(){return _(this,void 0,void 0,(function(){return m(this,(function(e){switch(e.label){case 0:return this._metadata?[4,j.of(this._iid).cacheContext.preference.set(this._metadataKey,this._metadata)]:[3,2];case 1:return e.sent(),[2,!0];case 2:return[2,!1]}}))}))},e.prototype.clearMetadata=function(){return _(this,void 0,void 0,(function(){return m(this,(function(e){switch(e.label){case 0:return[4,j.of(this._iid).cacheContext.preference.remove(this._metadataKey)];case 1:return e.sent(),this._metadata=null,[2]}}))}))},e.prototype.resume=function(){j.of(this._iid).connectionManager.isConnected&&this._sync.start(0)},e.prototype.pause=function(){this._sync.stop()},e.prototype.close=function(){this.ref--,this.ref<=0&&(this.ref=0,this.pause(),this._connectionEventContext.close(),delete ls[this._iid])},e}(),ds=function(){function e(e,t){var n=t.filter,r=t.order,s=t.limit,i=this;this.channels=[],this._backgroundSync=null,this._changelogSync=null,this._iid=e,this._key="gcc-".concat(ae()),this._isDisposed=!1,this._isGetRemoteChannelsSucceeded=!0,this.filter=null!=n?n:new Wt,this.order=null!=r?r:He.LATEST_LAST_MESSAGE,this._hasMore=!0,this._token="",this._limit=null!=s?s:ge;var a=j.of(this._iid),o=a.sdkState,u=a.cacheContext,c=a.dispatcher;u.localCacheEnabled&&(this._backgroundSync=cs.of(e),this._backgroundSync.resume()),this._changelogSync=hs.of(e),this._changelogSync.resume(),er.of(this._iid).subscribeGroupChannelEvent(this._key,{onUpdate:function(e,t){if(et(t)){var n=e.filter((function(e){return i.filter.match(e,o.userId)})),r=e.filter((function(e){return!i.filter.match(e,o.userId)})).map((function(e){return e.url}));n.length>0&&i._addChannelsToView(n,t),r.length>0&&i._removeChannelsFromView(r,t)}},onRemove:function(e,t){i._removeChannelsFromView(e,t)}}),j.of(this._iid).statLogCollector.put(new se({type:ie.FEATURE_LOCALCACHE,data:{use_local_cache:u.localCacheEnabled,collection_interface:{group_channel:!0}}})),c.on((function(e){e instanceof $&&(e.stateType===ee.CONNECTED?i._isGetRemoteChannelsSucceeded||_(i,void 0,void 0,(function(){return m(this,(function(e){switch(e.label){case 0:return[4,this._revokeLoadMore()];case 1:return e.sent(),[2]}}))})):e.stateType===ee.LOGOUT&&i.dispose())}))}return Object.defineProperty(e.prototype,"hasMore",{get:function(){return!this._isDisposed&&this._hasMore},enumerable:!1,configurable:!0}),e.prototype.setGroupChannelCollectionHandler=function(e){this._handler=e},e.prototype._addChannelsToView=function(e,t,n){var r,s,i,a,o=this;void 0===n&&(n=!1);var u=[],c=[],l=[];try{for(var h=v(e),d=h.next();!d.done;d=h.next()){var p=d.value,f=fr(this.channels,p,this.order),g=f.place,y=f.oldPosition;if(-1===y)g===this.channels.length?!n&&this._hasMore||(u.push(p),this.channels.push(p)):(u.push(p),this.channels.splice(g,0,p));else switch(t){case je.EVENT_CHANNEL_UPDATED:case je.EVENT_MESSAGE_RECEIVED:case je.SYNC_CHANNEL_CHANGELOGS:case je.EVENT_MESSAGE_SENT:g!==y?this._hasMore&&g===this.channels.length?l.push(p):(this.channels.splice(y,1),this.channels.splice(y0)try{for(var C=v(l),E=C.next();!E.done;E=C.next()){p=E.value;var b=pr(this.channels,p);-1!==b&&this.channels.splice(b,1)}}catch(e){i={error:e}}finally{try{E&&!E.done&&(a=C.return)&&a.call(C)}finally{if(i)throw i.error}}et(t)&&W((function(){return _(o,void 0,void 0,(function(){var e,n,r,s;return m(this,(function(i){return e=new rr(t),u.length>0&&(null===(n=this._handler)||void 0===n?void 0:n.onChannelsAdded)&&this._handler.onChannelsAdded(e,u),c.length>0&&(null===(r=this._handler)||void 0===r?void 0:r.onChannelsUpdated)&&this._handler.onChannelsUpdated(e,c),l.length>0&&(null===(s=this._handler)||void 0===s?void 0:s.onChannelsDeleted)&&this._handler.onChannelsDeleted(e,l.map((function(e){return e.url}))),[2]}))}))}))},e.prototype._removeChannelsFromView=function(e,t){var n,r,s=this,i=[],a=function(e){var t=o.channels.findIndex((function(t){return t.url===e}));t>=0&&(i.push(o.channels[t].url),o.channels.splice(t,1))},o=this;try{for(var u=v(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 et(t)&&i.length>0&&W((function(){return _(s,void 0,void 0,(function(){var e,n;return m(this,(function(r){return e=new rr(t),(null===(n=this._handler)||void 0===n?void 0:n.onChannelsDeleted)&&this._handler.onChannelsDeleted(e,i),[2]}))}))})),i},e.prototype._getLocalChannels=function(){return _(this,void 0,void 0,(function(){var e,t;return m(this,(function(n){switch(n.label){case 0:return e=er.of(this._iid),t=this.channels.length>0?function(e,t){var n,r;switch(t){case He.LATEST_LAST_MESSAGE:return null!==(r=null===(n=e.lastMessage)||void 0===n?void 0:n.createdAt)&&void 0!==r?r:e.createdAt;case He.CHRONOLOGICAL:return e.createdAt;case He.CHANNEL_NAME_ALPHABETICAL:return e.name}return null}(this.channels[this.channels.length-1],this.order):null,[4,e.getChannelsFromCache(t,this.filter,this.order,this._limit,t?this.channels[this.channels.length-1].url:null)];case 1:return[2,n.sent()]}}))}))},e.prototype._getRemoteChannels=function(){return _(this,void 0,void 0,(function(){var e,t,n;return m(this,(function(r){switch(r.label){case 0:return[4,er.of(this._iid).getMyGroupChannels(this._token,s(s({},this.filter),{order:this.order}),this._limit)];case 1:return e=r.sent(),t=e.channels,n=e.token,this._token=n,this._hasMore=!!n,[2,t]}}))}))},e.prototype._revokeLoadMore=function(){return _(this,void 0,void 0,(function(){var e;return m(this,(function(t){switch(t.label){case 0:if(this._isDisposed)return[2];t.label=1;case 1:return t.trys.push([1,3,,4]),[4,this._getRemoteChannels()];case 2:return e=t.sent(),this._isGetRemoteChannelsSucceeded=!0,this._addChannelsToView(e,je.REQUEST_CHANNEL,!0),[3,4];case 3:return t.sent(),this._isGetRemoteChannelsSucceeded=!1,[3,4];case 4:return[2]}}))}))},e.prototype.loadMore=function(){return _(this,void 0,void 0,(function(){var e,t,n=this;return m(this,(function(r){switch(r.label){case 0:if(this._isDisposed)throw new q({code:J.COLLECTION_DISPOSED,message:"Collection has been disposed."});return this._hasMore?(e=j.of(this._iid).cacheContext,t=[],e.localCacheEnabled&&this._backgroundSync.completed?[4,b((function(){return _(n,void 0,void 0,(function(){return m(this,(function(e){switch(e.label){case 0:return[4,this._getLocalChannels()];case 1:return t=e.sent(),[2]}}))}))}))]:[3,2]):[3,6];case 1:return r.sent(),this._hasMore=t.length>=this._limit,[3,5];case 2:return r.trys.push([2,4,,5]),[4,this._getRemoteChannels()];case 3:return t=r.sent(),this._isGetRemoteChannelsSucceeded=!0,[3,5];case 4:return r.sent(),this._isGetRemoteChannelsSucceeded=!1,[3,5];case 5:return this._addChannelsToView(t,je.REQUEST_CHANNEL,!0),[2,t];case 6:return[2,[]]}}))}))},e.prototype.dispose=function(){var e,t;this._isDisposed||(this._isDisposed=!0,this.channels.length>0&&this.channels.splice(0,this.channels.length),null===(e=this._backgroundSync)||void 0===e||e.close(),null===(t=this._changelogSync)||void 0===t||t.close(),er.of(this._iid).unsubscribeGroupChannelEvent(this._key))},e}(),ps=function(t){function n(e){var n=this,s=e.token,i=e.limit,a=e.order,o=e.includeEmpty,u=e.membershipFilter,c=e.channelNameContainsFilter,l=e.channelUrlsFilter,h=e.customTypesFilter,d=e.customTypeStartsWithFilter,p=e.superChannelFilter,f=e.metadataOrderKeyFilter,_=e.metadataKey,m=e.metadataValues,v=e.metadataValueStartsWith,g=e.includeFrozen,y=e.includeMetaData;return(n=t.call(this)||this).method=A.GET,n.path=x,n.params=r({token:s,limit:i,order:a,show_member:!0,show_read_receipt:!0,show_delivery_receipt:!0,show_empty:o,public_mode:Rt.PUBLIC,public_membership_mode:u,name_contains:c,channel_urls:l,custom_types:h,custom_type_startswith:d,super_mode:p,metadata_order_key:f,metadata_key:_,metadata_values:m,metadata_value_startswith:v,show_frozen:g,show_metadata:y}),n}return e(n,t),n}(D),fs=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 os(e,t)}))),r.ts="number"==typeof a?a:null,r}return e(n,t),n}(L);!function(e){e.ALL="all",e.JOINED="joined"}(as||(as={}));var _s=function(t){function n(e,n){var r,s,i,a,o,u,c,l,h,d,p,f,_,m,v=this;return(v=t.call(this,e,n)||this).includeEmpty=!1,v.includeFrozen=!0,v.includeMetaData=!0,v.channelUrlsFilter=null,v.customTypesFilter=null,v.customTypeStartsWithFilter=null,v.channelNameContainsFilter=null,v.membershipFilter=as.ALL,v.superChannelFilter=Ot.ALL,v.metadataKey=null,v.metadataValues=null,v.metadataOrderKeyFilter=null,v.metadataValueStartsWith=null,v.order=at.CHRONOLOGICAL,v.includeEmpty=null!==(r=n.includeEmpty)&&void 0!==r&&r,v.includeFrozen=null===(s=n.includeFrozen)||void 0===s||s,v.includeMetaData=null===(i=n.includeMetaData)||void 0===i||i,v.channelUrlsFilter=null!==(a=n.channelUrlsFilter)&&void 0!==a?a:null,v.customTypesFilter=null!==(o=n.customTypesFilter)&&void 0!==o?o:null,v.customTypeStartsWithFilter=null!==(u=n.customTypeStartsWithFilter)&&void 0!==u?u:null,v.channelNameContainsFilter=null!==(c=n.channelNameContainsFilter)&&void 0!==c?c:null,v.membershipFilter=null!==(l=n.membershipFilter)&&void 0!==l?l:as.ALL,v.superChannelFilter=null!==(h=n.superChannelFilter)&&void 0!==h?h:Ot.ALL,v.metadataKey=null!==(d=n.metadataKey)&&void 0!==d?d:null,v.metadataValues=null!==(p=n.metadataValues)&&void 0!==p?p:null,v.metadataOrderKeyFilter=null!==(f=n.metadataOrderKeyFilter)&&void 0!==f?f:null,v.metadataValueStartsWith=null!==(_=n.metadataValueStartsWith)&&void 0!==_?_:null,v.order=null!==(m=n.order)&&void 0!==m?m:at.CHRONOLOGICAL,v}return e(n,t),n.prototype._validate=function(){return t.prototype._validate.call(this)&&y("boolean",this.includeEmpty)&&y("boolean",this.includeFrozen)&&y("boolean",this.includeMetaData)&&y("string",this.channelNameContainsFilter,!0)&&g("string",this.channelUrlsFilter,!0)&&g("string",this.customTypesFilter,!0)&&y("string",this.customTypeStartsWithFilter,!0)&&i(as,this.membershipFilter)&&i(Ot,this.superChannelFilter)&&i(at,this.order)&&y("string",this.metadataOrderKeyFilter,!0)&&y("string",this.metadataKey,!0)&&g("string",this.metadataValues,!0)&&y("string",this.metadataValueStartsWith,!0)},n.prototype.next=function(){return _(this,void 0,void 0,(function(){var e,t,n,r,i,a,o,u;return m(this,(function(c){switch(c.label){case 0:return this._validate()?this._isLoading?[3,3]:(e=[],this._hasNext?(this._isLoading=!0,t=j.of(this._iid),n=t.requestQueue,t.dispatcher,r=new ps(s(s({},this),{token:this._token})),[4,n.send(r)]):[3,2]):[3,5];case 1:return i=c.sent(),a=i.as(fs),o=a.channels,u=a.token,this._token=u,this._hasNext=!!u,this._isLoading=!1,[2,o];case 2:return[2,e];case 3:throw q.queryInProgress;case 4:return[3,6];case 5:throw q.invalidParameters;case 6:return[2]}}))}))},n}(V),ms=function(t){function n(e){void 0===e&&(e={});var n=t.call(this)||this;return Object.keys(e).forEach((function(t){n.hasOwnProperty(t)&&(n[t]=e[t])})),n}return e(n,t),n}(function(t){function n(){var e=null!==t&&t.apply(this,arguments)||this;return e.onUserJoined=fe,e.onUserLeft=fe,e.onUserReceivedInvitation=fe,e.onUserDeclinedInvitation=fe,e.onChannelHidden=fe,e.onUnreadMemberStatusUpdated=fe,e.onUndeliveredMemberStatusUpdated=fe,e.onTypingStatusUpdated=fe,e.onPollUpdated=fe,e.onPollVoted=fe,e.onPollDeleted=fe,e.onPinnedMessageUpdated=fe,e}return e(n,t),n}(vt)),vs=function(t){function n(e){var n=this,s=e.token,i=e.limit,a=e.order,o=e.reverse,u=e.channelUrl,c=e.messageTypeFilter,l=e.scheduledStatus;return(n=t.call(this)||this).method=A.GET,n.path="".concat(R),n.params=r({token:s,limit:i,reverse:o,channel_url:u,order:a,message_type:c,status:l}),n}return e(n,t),n}(D),gs=function(t){function n(e,n){var r=t.call(this,e,n)||this;r.token=null,r.scheduledMessages=[];var s=n.next,i=n.scheduled_messages;return r.token=s,r.scheduledMessages=i.map((function(t){return Et(e,t)})),r}return e(n,t),n}(L),ys=function(t){function n(e,n){var r,s,i,a,o,u=this;return(u=t.call(this,e,n)||this).channelUrl=null,u.order=null,u.reverse=!1,u.scheduledStatus=null,u.messageTypeFilter=E.ALL,u.channelUrl=null!==(r=n.channelUrl)&&void 0!==r?r:null,u.order=null!==(s=n.order)&&void 0!==s?s:null,u.reverse=null!==(i=n.reverse)&&void 0!==i&&i,u.scheduledStatus=null!==(a=n.scheduledStatus)&&void 0!==a?a:null,u.messageTypeFilter=null!==(o=n.messageTypeFilter)&&void 0!==o?o:E.ALL,u}return e(n,t),n.prototype._validate=function(){return t.prototype._validate.call(this)&&y("string",this.channelUrl,!0)&&(i(ot,this.order)||null===this.order)&&y("boolean",this.reverse)&&(g(gt,this.scheduledStatus)||null===this.scheduledStatus)&&i(E,this.messageTypeFilter)},n.prototype.next=function(){return _(this,void 0,void 0,(function(){var e,t,n,r,i,a;return m(this,(function(o){switch(o.label){case 0:return this._validate()?this._isLoading?[3,3]:this._hasNext?(this._isLoading=!0,e=j.of(this._iid).requestQueue,t=new vs(s(s({},this),{token:this._token})),[4,e.send(t)]):[3,2]:[3,5];case 1:return n=o.sent(),r=n.as(gs),i=r.scheduledMessages,a=r.token,this._token=a,this._hasNext=!!a,this._isLoading=!1,[2,i];case 2:return[2,[]];case 3:throw q.queryInProgress;case 4:return[3,6];case 5:throw q.invalidParameters;case 6:return[2]}}))}))},n}(V),Cs=function(t){function n(){var e=null!==t&&t.apply(this,arguments)||this;return e.name="groupChannel",e}return e(n,t),n.prototype.init=function(e,n){var r=n.sdkState,s=n.dispatcher,i=n.sessionManager,a=n.requestQueue,o=n.logger,u=n.onlineDetector,c=n.cacheContext;t.prototype.init.call(this,e,{sdkState:r,dispatcher:s,sessionManager:i,requestQueue:a,logger:o,onlineDetector:u,cacheContext:c}),this._manager=new er(e,{sdkState:r,cacheContext:c,dispatcher:s,sessionManager:i,requestQueue:a,logger:o})},n.prototype.createGroupChannelCollection=function(e){return void 0===e&&(e={}),new ds(this._iid,e)},n.prototype.createMyGroupChannelListQuery=function(e){return void 0===e&&(e={}),new Jn(this._iid,e)},n.prototype.createPublicGroupChannelListQuery=function(e){return void 0===e&&(e={}),new _s(this._iid,e)},n.prototype.createScheduledMessageListQuery=function(e){return void 0===e&&(e={}),new ys(this._iid,e)},n.prototype.addGroupChannelHandler=function(e,t){Y(y("string",e)&&t instanceof ms).throw(q.invalidParameters),this._manager.addHandler(e,t)},n.prototype.removeGroupChannelHandler=function(e){Y(y("string",e)).throw(q.invalidParameters),this._manager.removeHandler(e)},n.prototype.removeAllGroupChannelHandlers=function(){this._manager.clearHandler()},n.prototype.buildGroupChannelFromSerializedData=function(e){return this._manager.buildGroupChannelFromSerializedData(e)},n.prototype.buildGroupChannelListQueryFromSerializedData=function(e){return this._manager.buildGroupChannelListQueryFromSerializedData(e)},n.prototype.buildMemberFromSerializedData=function(e){return this._manager.buildMemberFromSerializedData(e)},n.prototype.getChannel=function(e){return _(this,void 0,void 0,(function(){return m(this,(function(t){return Y(y("string",e)).throw(q.invalidParameters),[2,this._manager.getChannel(e)]}))}))},n.prototype.getChannelWithoutCache=function(e){return _(this,void 0,void 0,(function(){return m(this,(function(t){return Y(y("string",e)).throw(q.invalidParameters),[2,this._manager.getChannelWithoutCache(e)]}))}))},n.prototype.getMyGroupChannelChangeLogsByToken=function(e,t){return void 0===t&&(t={}),_(this,void 0,void 0,(function(){var n;return m(this,(function(r){switch(r.label){case 0:return n=s(s({},Xt),t),Y(y("string",e)&&Zt(n)).throw(q.invalidParameters),[4,this._manager.getMyGroupChannelChangeLogs(e,n)];case 1:return[2,r.sent()]}}))}))},n.prototype.getMyGroupChannelChangeLogsByTimestamp=function(e,t){return void 0===t&&(t={}),_(this,void 0,void 0,(function(){var n;return m(this,(function(r){switch(r.label){case 0:return n=s(s({},Xt),t),Y(y("number",e)&&Zt(n)).throw(q.invalidParameters),[4,this._manager.getMyGroupChannelChangeLogs(e,n)];case 1:return[2,r.sent()]}}))}))},n.prototype.getGroupChannelCount=function(e){return _(this,void 0,void 0,(function(){var t;return m(this,(function(n){return t=s(s({},$t),e),Y(en(t)).throw(q.invalidParameters),[2,this._manager.getGroupChannelCount(t)]}))}))},n.prototype.getUnreadItemCount=function(e){return void 0===e&&(e={}),_(this,void 0,void 0,(function(){return m(this,(function(t){switch(t.label){case 0:return[4,this._manager.getUnreadItemCount(e)];case 1:return[2,t.sent()]}}))}))},n.prototype.getTotalUnreadChannelCount=function(){return _(this,void 0,void 0,(function(){return m(this,(function(e){switch(e.label){case 0:return[4,this._manager.getTotalUnreadChannelCount()];case 1:return[2,e.sent()]}}))}))},n.prototype.getTotalUnreadMessageCount=function(e){return void 0===e&&(e={}),_(this,void 0,void 0,(function(){return m(this,(function(t){switch(t.label){case 0:return[4,this._manager.getTotalUnreadMessageCount(e)];case 1:return[2,t.sent()]}}))}))},n.prototype.getTotalScheduledMessageCount=function(e){return void 0===e&&(e={}),_(this,void 0,void 0,(function(){return m(this,(function(t){switch(t.label){case 0:return[4,this._manager.getTotalScheduledMessageCount(e)];case 1:return[2,t.sent()]}}))}))},n.prototype.getSubscribedTotalUnreadMessageCount=function(){return this._manager.getSubscribedTotalUnreadMessageCount()},n.prototype.getSubscribedCustomTypeTotalUnreadMessageCount=function(){return this._manager.getSubscribedCustomTypeTotalUnreadMessageCount()},n.prototype.getSubscribedCustomTypeUnreadMessageCount=function(e){return this._manager.getSubscribedCustomTypeUnreadMessageCount(e)},n.prototype.createChannel=function(e){return void 0===e&&(e={}),_(this,void 0,void 0,(function(){var t;return m(this,(function(n){return t=s(s({},Yt),e),Y(Jt(t)).throw(q.invalidParameters),[2,this._manager.createChannel(t)]}))}))},n.prototype.createDistinctChannelIfNotExist=function(e){return void 0===e&&(e={}),_(this,void 0,void 0,(function(){var t;return m(this,(function(n){return t=s(s({},Yt),e),Y(Jt(t)).throw(q.invalidParameters),t&&(t.isDistinct=!0),[2,this.createChannel(t)]}))}))},n.prototype.createChannelWithUserIds=function(e,t,n,r,i,a){return void 0===t&&(t=!1),void 0===n&&(n=null),void 0===r&&(r=null),void 0===i&&(i=""),void 0===a&&(a=""),_(this,void 0,void 0,(function(){var o;return m(this,(function(u){return o=s(s({},Yt),{invitedUserIds:e,isDistinct:t,name:n,data:i,customType:a}),"string"==typeof r?o.coverUrl=r:o.coverImage=r,[2,this.createChannel(o)]}))}))},n.prototype.markAsReadAll=function(){return _(this,void 0,void 0,(function(){return m(this,(function(e){return this._manager.markAsReadAll(),[2]}))}))},n.prototype.markAsReadWithChannelUrls=function(e){return _(this,void 0,void 0,(function(){return m(this,(function(t){return Y(g("string",e)).throw(q.invalidParameters),this._manager.markAsReadWithChannelUrls(e),[2]}))}))},n.prototype.markAsDelivered=function(e){return _(this,void 0,void 0,(function(){return m(this,(function(t){switch(t.label){case 0:return Y(y("string",e)).throw(q.invalidParameters),[4,this.getChannel(e)];case 1:return[4,t.sent().markAsDelivered()];case 2:return t.sent(),[2]}}))}))},n}(_e);export{$r as CountPreference,os as GroupChannel,ds as GroupChannelCollection,rr as GroupChannelEventContext,Wt as GroupChannelFilter,ms as GroupChannelHandler,Jn as GroupChannelListQuery,Cs as GroupChannelModule,Bt as GroupChannelSearchField,Gt as HiddenChannelFilter,ts as HiddenState,jt as Member,Er as MemberListOrder,Ar as MemberListQuery,xt as MemberState,br as MemberStateFilter,as as MembershipFilter,Nr as MessageCollection,Mr as MessageCollectionInitHandler,tr as MessageCollectionInitPolicy,sr as MessageEventContext,Cr as MutedMemberFilter,es as MutedState,Ft as MyMemberStateFilter,Vt as OperatorFilter,ns as PinnedMessage,is as PinnedMessageListQuery,Rt as PublicChannelFilter,_s as PublicGroupChannelListQuery,qt as QueryType,zt as ReadStatus,ys as ScheduledMessageListQuery,Ot as SuperChannelFilter,Ht as UnreadChannelFilter,Qt as UnreadItemKey}; +import{_ as e,e as r,u as s,g as i,M as a,X as o,Q as u,U as c,a0 as h,aF as d,t as f,S as _,r as m,s as v,b as g,c as y,K as C,m as E,a as b,i as M,a7 as N,J as U,aE as S,aG as T,ax as A,aH as I,ak as w,aj as L,A as D,d as k,f as R,h as F,aI as x,ah as O,aJ as H,aa as V,W as q,a3 as B,B as W,w as z,V as j,R as Q,aD as K,z as Y,ai as J,ad as X,aK as Z,E as $,x as ee,y as te,ag as ne,ab as re,aL as se,aM as ie,aN as ae,p as oe,a5 as ue,aO as ce,am as le,a4 as he,aC as de,ae as pe,N as fe,n as _e,an as me}from"./lib/__bundle-75942676.js";export{ai as MessageEventSource}from"./lib/__bundle-75942676.js";import{g as ve,N as ge,p as ye,q as Ce,r as Ee,t as be,u as Me,w as Ne,x as Ue,y as Se,P as Te,z as Ae,A as Ie,C as we,E as Le,D as De,G as ke,H as Pe,I as Re,J as Fe,f as xe,K as Oe,L as He}from"./lib/__bundle-e875840b.js";import{G as Ge,g as Ve,D as qe,l as Be,m as We,n as ze,j as je,i as Qe,o as Ke,R as Ye,p as Je,k as Xe,U as Ze,e as $e,f as et,s as tt,d as nt,S as rt,v as st,q as it,r as at,P as ot,t as ut}from"./lib/__bundle-fd51cf65.js";export{n as GroupChannelEventSource,G as GroupChannelListOrder,p as MessageFilter,P as PublicGroupChannelListOrder,t as ScheduledMessageListOrder}from"./lib/__bundle-fd51cf65.js";import{C as ct,a as lt,O as ht,P as dt,M as pt,T as ft,R as _t,U as mt,A as vt,B as gt}from"./lib/__bundle-361d5a90.js";import{l as yt,S as Ct,I as Et,p as bt,U as Mt,F as Nt,m as Ut,c as St,T as Tt,d as At,A as It,n as wt,g as Lt,h as Dt,o as kt,q as Pt}from"./lib/__bundle-84f74e8d.js";export{l as ScheduledStatus}from"./lib/__bundle-84f74e8d.js";import{b as Rt}from"./lib/__bundle-ad161b2c.js";var Ft;!function(e){e.NONE="none",e.JOINED="joined",e.INVITED="invited",e.LEFT="left"}(Ft||(Ft={}));var xt,Ot,Ht,Gt,Vt,qt,Bt,Wt,zt=function(t){function n(e,n){var r=t.call(this,e,n)||this;return r.state=null,r.role=null,r.isMuted=!1,r.isBlockedByMe=!1,r.isBlockingMe=!1,r.state=a(Ft,n.state)?n.state:null,r.role=a(o,n.role)?n.role:null,"boolean"==typeof n.is_muted&&(r.isMuted=n.is_muted),"boolean"==typeof n.is_blocked_by_me&&(r.isBlockedByMe=n.is_blocked_by_me),"boolean"==typeof n.is_blocking_me&&(r.isBlockingMe=n.is_blocking_me),r}return e(n,t),n.payloadify=function(e){return r(s(i(i({},t.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})))},n}(ve),jt=function(t){function n(e,n){var r,s,i=this;return(i=t.call(this,e)||this).channelUrl=null!==(r=n.channel_url)&&void 0!==r?r:"",i.channelType=null!==(s=n.channel_type)&&void 0!==s?s:u.GROUP,i.reader=new c(i._iid,n.user),i.readAt=n.ts,i}return e(n,t),n}(h);!function(e){e.ALL="all",e.PUBLIC="public",e.PRIVATE="private"}(xt||(xt={})),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"}(Ot||(Ot={})),function(e){e.ALL="all",e.SUPER="super",e.NON_SUPER="nonsuper",e.BROADCAST_ONLY="broadcast_only",e.EXCLUSIVE_ONLY="exclusive_only"}(Ht||(Ht={})),function(e){e.ALL="all",e.UNREAD_MESSAGE="unread_message"}(Gt||(Gt={})),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"}(Vt||(Vt={})),function(e){e.ALL="all",e.OPERATOR="operator",e.NONOPERATOR="nonoperator"}(qt||(qt={})),function(e){e.AND="AND",e.OR="OR"}(Bt||(Bt={})),function(e){e.MEMBER_NICKNAME="member_nickname",e.CHANNEL_NAME="channel_name"}(Wt||(Wt={}));var Qt,Kt=function(){function e(){this._searchFilter=null,this._userIdsFilter=null,this.includeEmpty=!1,this.nicknameContainsFilter=null,this.nicknameStartsWithFilter=null,this.nicknameExactMatchFilter=null,this.channelNameContainsFilter="",this.myMemberStateFilter=Ot.ALL,this.customTypesFilter=null,this.channelUrlsFilter=null,this.superChannelFilter=Ht.ALL,this.publicChannelFilter=xt.ALL,this.customTypeStartsWithFilter=null,this.unreadChannelFilter=Gt.ALL,this.hiddenChannelFilter=Vt.UNHIDDEN,this.includeFrozen=!0}return e.prototype._isFriend=function(e){return!(!e||!e.friendDiscoveryKey&&!e.friendName)},Object.defineProperty(e.prototype,"searchFilter",{get:function(){return this._searchFilter},enumerable:!1,configurable:!0}),e.prototype.setSearchFilter=function(e,t){Array.isArray(e)&&0!==e.length&&"string"==typeof t&&t&&(this._searchFilter={query:t,fields:e})},Object.defineProperty(e.prototype,"userIdsFilter",{get:function(){return this._userIdsFilter},enumerable:!1,configurable:!0}),e.prototype.setUserIdsFilter=function(e,t,n){void 0===n&&(n=Bt.AND),this._userIdsFilter={userIds:e,includeMode:t,queryType:n}},e.prototype.clone=function(){var t,n=new e;this.searchFilter&&n.setSearchFilter(this.searchFilter.fields,null!==(t=this.searchFilter.query)&&void 0!==t?t:void 0),this.userIdsFilter&&n.setUserIdsFilter(this.userIdsFilter.userIds,this.userIdsFilter.includeMode,this.userIdsFilter.queryType);var r=JSON.parse(JSON.stringify(this));return Object.keys(r).forEach((function(e){n[e]=r[e]})),n},e.prototype.match=function(e,t){if(this._searchFilter){var n=this._searchFilter,r=n.query,s=n.fields;if(r&&s&&s.length>0&&!s.some((function(t){switch(t){case Wt.CHANNEL_NAME:return e.name.toLowerCase().includes(r.toLowerCase());case Wt.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,u=i.queryType,c=e.members.map((function(e){return e.userId}));if(o){if(a.length>0)switch(u){case Bt.AND:if(a.some((function(e){return!c.includes(e)})))return!1;break;case Bt.OR:if(a.every((function(e){return!c.includes(e)})))return!1}}else{if(a.includes(t)||a.push(t),e.members.length>a.length)return!1;if(!d(a,c))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 l=this.nicknameContainsFilter.toLowerCase();if(!e.members.some((function(e){return e.userId!==t&&e.nickname.toLowerCase().includes(l)})))return!1}if(this.nicknameStartsWithFilter){var h=this.nicknameStartsWithFilter.toLowerCase();if(!e.members.some((function(e){return e.userId!==t&&e.nickname.toLowerCase().startsWith(h)})))return!1}if(this.nicknameExactMatchFilter){var p=this.nicknameExactMatchFilter.toLowerCase();if(!e.members.some((function(e){return e.userId!==t&&e.nickname.toLowerCase()!=p})))return!1}if(this.channelUrlsFilter&&this.channelUrlsFilter.length>0&&!this.channelUrlsFilter.includes(e.url))return!1;if(this.myMemberStateFilter)switch(this.myMemberStateFilter){case Ot.JOINED:if("joined"!==e.myMemberState)return!1;break;case Ot.INVITED:if("invited"!==e.myMemberState)return!1;break;case Ot.INVITED_BY_FRIEND:if("invited"!==e.myMemberState||!this._isFriend(e.inviter))return!1;break;case Ot.INVITED_BY_NON_FRIEND:if("invited"!==e.myMemberState||this._isFriend(e.inviter))return!1}if(this.hiddenChannelFilter)switch(this.hiddenChannelFilter){case Vt.UNHIDDEN:if(e.isHidden||"unhidden"!==e.hiddenState)return!1;break;case Vt.HIDDEN:if(!e.isHidden)return!1;break;case Vt.HIDDEN_ALLOW_AUTO_UNHIDE:if(!e.isHidden||"hidden_allow_auto_unhide"!==e.hiddenState)return!1;break;case Vt.HIDDEN_PREVENT_AUTO_UNHIDE:if(!e.isHidden||"hidden_prevent_auto_unhide"!==e.hiddenState)return!1}if(this.unreadChannelFilter&&this.unreadChannelFilter===Gt.UNREAD_MESSAGE)if(0===e.unreadMessageCount)return!1;if(this.publicChannelFilter)switch(this.publicChannelFilter){case xt.PUBLIC:if(!e.isPublic)return!1;break;case xt.PRIVATE:if(e.isPublic)return!1}if(this.superChannelFilter)switch(this.superChannelFilter){case Ht.SUPER:if(!e.isSuper)return!1;break;case Ht.NON_SUPER:if(e.isSuper)return!1}return!0},e}(),Yt=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 f(!!e).throw(_.databaseError),e.collection(ge)},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),i(i({},e.serialize()),{lastMessageUpdatedAt:e.lastMessage?e.lastMessage.createdAt:0,syncIndex:t})},n.prototype._deserialize=function(e){return rr.of(this._iid).buildGroupChannelFromSerializedData(e)},Object.defineProperty(n.prototype,"channels",{get:function(){return m([],v(this._channels.values()),!1)},enumerable:!1,configurable:!0}),n.prototype.isCachedInMemory=function(e){return this._channels.has(e)},n.prototype.filterOffsetChanged=function(e){var t=this;return e.filter((function(e){if(t._channels.has(e.url))return t._channels.get(e.url).messageOffsetTimestamp0)return!1;if(l&&l===e.url)return!1;break;case Ge.CHRONOLOGICAL:if(!i&&e.createdAt>t||i&&e.createdAtt||i&&e.lastMessageUpdatedAt0?[4,this.upsert(r)]:[3,2];case 1:y.sent(),y.label=2;case 2:return[2]}}))}))},n.prototype.block=function(e,t){return g(this,void 0,void 0,(function(){return y(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 g(this,void 0,void 0,(function(){return y(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=m([],v(this._channels.keys()),!1)),g(this,void 0,void 0,(function(){var n,r,s,i,a,o,u,c;return y(this,(function(l){switch(l.label){case 0:n=[],l.label=1;case 1:l.trys.push([1,6,7,8]),r=C(t),s=r.next(),l.label=2;case 2:return s.done?[3,5]:(i=s.value,[4,this.get(i)]);case 3:(null==(a=l.sent())?void 0:a._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}(h),Jt={invitedUserIds:void 0,channelUrl:void 0,coverUrl:void 0,coverImage:void 0,isDistinct:void 0,isSuper:void 0,isBroadcast:void 0,isExclusive:void 0,isPublic:void 0,isDiscoverable:void 0,isStrict:void 0,isEphemeral:void 0,accessCode:void 0,name:void 0,data:void 0,customType:void 0,operatorUserIds:void 0,messageSurvivalSeconds:void 0},Xt=function(e){return E("string",e.invitedUserIds,!0)&&b("string",e.channelUrl,!0)&&b("string",e.coverUrl,!0)&&(M(e.coverImage)||b("string",e.coverImage,!0))&&b("boolean",e.isDistinct,!0)&&b("boolean",e.isSuper,!0)&&b("boolean",e.isBroadcast,!0)&&b("boolean",e.isExclusive,!0)&&b("boolean",e.isPublic,!0)&&b("boolean",e.isStrict,!0)&&b("boolean",e.isDiscoverable,!0)&&b("boolean",e.isEphemeral,!0)&&b("string",e.accessCode,!0)&&b("string",e.name,!0)&&b("string",e.data,!0)&&b("string",e.customType,!0)&&E("string",e.operatorUserIds,!0)&&b("number",e.messageSurvivalSeconds,!0)},Zt={customTypes:void 0,includeEmpty:!1,includeFrozen:!0},$t=function(e){return E("string",e.customTypes,!0)&&b("boolean",e.includeEmpty)&&b("boolean",e.includeFrozen)},en={myMemberStateFilter:Ot.ALL},tn=function(e){return a(Ot,e.myMemberStateFilter)};!function(e){e.GROUP_CHANNEL_UNREAD_MENTION_COUNT="group_channel_unread_mention_count",e.NONSUPER_UNREAD_MENTION_COUNT="non_super_group_channel_unread_mention_count",e.SUPER_UNREAD_MENTION_COUNT="super_group_channel_unread_mention_count",e.GROUP_CHANNEL_UNREAD_MESSAGE_COUNT="group_channel_unread_message_count",e.NONSUPER_UNREAD_MESSAGE_COUNT="non_super_group_channel_unread_message_count",e.SUPER_UNREAD_MESSAGE_COUNT="super_group_channel_unread_message_count",e.GROUP_CHANNEL_INVITATION_COUNT="group_channel_invitation_count",e.NONSUPER_INVITATION_COUNT="non_super_group_channel_invitation_count",e.SUPER_INVITATION_COUNT="super_group_channel_invitation_count"}(Qt||(Qt={}));var nn={keys:[]},rn={channelCustomTypesFilter:void 0,superChannelFilter:Ht.ALL},sn={channelUrl:void 0,scheduledStatus:void 0,messageTypeFilter:N.ALL},an=function(){function e(e){var t=e.groupChannelCache,n=e.messageCache,r=e.unsentMessageCache,s=e.dispatcher,i=this;this._observers=new Map,s.on((function(e){return g(i,void 0,void 0,(function(){var s,i,a,o,u,c,l,h,d,p,f,_,m,v,E=this;return y(this,(function(b){switch(b.label){case 0:if(!(e instanceof We))return[3,10];s=e.channels,f=e.source,_=e.isWebSocketEventComing,i=e.data,a=s.filter((function(e){return e instanceof cs})),o=t.filterOffsetChanged(a),b.label=1;case 1:b.trys.push([1,6,7,8]),u=C(o),c=u.next(),b.label=2;case 2:return c.done?[3,5]:(l=c.value,[4,n.removeUnderOffset(l.url,l.messageOffsetTimestamp)]);case 3:b.sent(),b.label=4;case 4:return c=u.next(),[3,2];case 5:return[3,8];case 6:return h=b.sent(),m={error:h},[3,8];case 7:try{c&&!c.done&&(v=u.return)&&v.call(u)}finally{if(m)throw m.error}return[7];case 8:return[4,t.upsert(a)];case 9:return d=b.sent(),_||this._broadcastUpdateEvent(d,f,i),[3,15];case 10:return e instanceof Be?(p=e.channelUrls,f=e.source,_=e.isWebSocketEventComing,[4,t.remove(p)]):[3,13];case 11:return b.sent(),[4,U((function(){return g(E,void 0,void 0,(function(){var e,t,s,i,a,o;return y(this,(function(u){switch(u.label){case 0:u.trys.push([0,6,7,8]),e=C(p),t=e.next(),u.label=1;case 1:return t.done?[3,5]:(s=t.value,[4,n.removeMessagesOfChannel(s)]);case 2:return u.sent(),[4,r.removeMessagesOfChannel(s)];case 3:u.sent(),u.label=4;case 4:return t=e.next(),[3,1];case 5:return[3,8];case 6:return i=u.sent(),a={error:i},[3,8];case 7:try{t&&!t.done&&(o=e.return)&&o.call(e)}finally{if(a)throw a.error}return[7];case 8:return[2]}}))}))}))];case 12:return b.sent(),_||this._broadcastRemoveEvent(p,f),[3,15];case 13:return e instanceof qe?[4,t.fetch({token:Number.MAX_SAFE_INTEGER,limit:Number.MAX_SAFE_INTEGER})]:[3,15];case 14:b.sent(),b.label=15;case 15:return[2]}}))}))}))}return e.prototype._broadcastUpdateEvent=function(e,t,n){var r,s;try{for(var i=C(this._observers.values()),a=i.next();!a.done;a=i.next()){var o=a.value;o.onUpdate&&o.onUpdate(e,t,n)}}catch(e){r={error:e}}finally{try{a&&!a.done&&(s=i.return)&&s.call(i)}finally{if(r)throw r.error}}},e.prototype._broadcastRemoveEvent=function(e,t){var n,r;try{for(var s=C(this._observers.values()),i=s.next();!i.done;i=s.next()){var a=i.value;a.onRemove&&a.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.subscribe=function(e,t){this._observers.set(e,t)},e.prototype.unsubscribe=function(e){this._observers.delete(e)},e.prototype.unsubscribeAll=function(){this._observers.clear()},e}(),on=function(){function e(e){var t=e.cacheContext,n=e.messageCache,r=e.unsentMessageCache,s=e.dispatcher,i=e.logger,a=this;this._observers=new Map,this._cacheContext=t,this._logger=i,s.on((function(e){return g(a,void 0,void 0,(function(){var t,s,i,a,o,u,c,l,h,d,p,f,_,m,v=this;return y(this,(function(C){switch(C.label){case 0:return e instanceof L?(t=e.messages,_=e.source,o=e.isWebSocketEventComing,s=t.filter((function(e){return e.messageId>0})),i=t.filter((function(e){return 0===e.messageId})),s.length>0?[4,U((function(){return g(v,void 0,void 0,(function(){return y(this,(function(e){switch(e.label){case 0:return[4,n.upsert(s)];case 1:return e.sent(),[4,r.remove(s.map((function(e){return e instanceof Ct?e.reqId:null})).filter((function(e){return null!==e})))];case 2:return e.sent(),[2]}}))}))}))]:[3,2]):[3,5];case 1:C.sent(),o||this._broadcastUpdateEvent(s,_),C.label=2;case 2:return i.length>0?[4,U((function(){return g(v,void 0,void 0,(function(){return y(this,(function(e){switch(e.label){case 0:return[4,r.upsert(i)];case 1:return e.sent(),[2]}}))}))}))]:[3,4];case 3:C.sent(),o||this._broadcastUpdateEvent(i,_),C.label=4;case 4:return[3,21];case 5:return e instanceof w?(a=e.messageIds,_=e.source,o=e.isWebSocketEventComing,[4,U((function(){return g(v,void 0,void 0,(function(){return y(this,(function(e){switch(e.label){case 0:return[4,n.remove(a)];case 1:return e.sent(),[2]}}))}))}))]):[3,7];case 6:return C.sent(),o||this._broadcastRemoveEvent(a,_),[3,21];case 7:return e instanceof I?(u=e.reqId,_=e.source,[4,U((function(){return g(v,void 0,void 0,(function(){return y(this,(function(e){switch(e.label){case 0:return[4,r.remove([u])];case 1:return e.sent(),[2]}}))}))}))]):[3,9];case 8:return C.sent(),this._broadcastRemoveUnsentEvent(u,_),[3,21];case 9:return e instanceof A?(c=e.polls,_=e.source,this._cacheContext.localCacheEnabled?(l=c.map((function(e){return e.messageId})),[4,Promise.all(l.map((function(e){return n.get(e)})))]):[3,12]):[3,13];case 10:return(h=C.sent().filter((function(e){return e}))).length>0&&c.forEach((function(e){var t=h.find((function(t){return t.messageId===e.messageId}));t&&t.applyPoll(e)})),[4,U((function(){return g(v,void 0,void 0,(function(){return y(this,(function(e){switch(e.label){case 0:return[4,n.upsert(h)];case 1:return[2,e.sent()]}}))}))}))];case 11:C.sent(),C.label=12;case 12:return this._broadcastPollChangeLogEvent(c,_),[3,21];case 13:return e instanceof T?(d=e.event,_=e.source,[4,n.get(d.messageId)]):[3,17];case 14:return(p=C.sent())&&p.isUserMessage()&&p.poll&&p.poll.applyPollUpdateEvent(d)?[4,U((function(){return g(v,void 0,void 0,(function(){return y(this,(function(e){switch(e.label){case 0:return[4,n.upsert([p])];case 1:return[2,e.sent()]}}))}))}))]:[3,16];case 15:C.sent(),C.label=16;case 16:return this._broadcastPollUpdateEvent(d,_),[3,21];case 17:return e instanceof S?(f=e.event,_=e.source,[4,n.get(f.messageId)]):[3,21];case 18:return(m=C.sent())&&m.isUserMessage()&&m.poll&&m.poll.applyPollVoteEvent(f)?[4,U((function(){return g(v,void 0,void 0,(function(){return y(this,(function(e){switch(e.label){case 0:return[4,n.upsert([m])];case 1:return[2,e.sent()]}}))}))}))]:[3,20];case 19:C.sent(),C.label=20;case 20:this._broadcastPollVoteEvent(f,_),C.label=21;case 21:return[2]}}))}))}))}return e.prototype._broadcastUpdateEvent=function(e,t){var n,r;try{for(var s=C(this._observers.values()),i=s.next();!i.done;i=s.next()){var a=i.value;a.onUpdate&&a.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._broadcastPollChangeLogEvent=function(e,t){var n,r;try{for(var s=C(this._observers.values()),i=s.next();!i.done;i=s.next()){var a=i.value;a.onPollChangeLogUpdate&&a.onPollChangeLogUpdate(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._broadcastPollUpdateEvent=function(e,t){var n,r;try{for(var s=C(this._observers.values()),i=s.next();!i.done;i=s.next()){var a=i.value;a.onPollUpdate&&a.onPollUpdate(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._broadcastPollVoteEvent=function(e,t){var n,r;try{for(var s=C(this._observers.values()),i=s.next();!i.done;i=s.next()){var a=i.value;a.onPollVote&&a.onPollVote(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=C(this._observers.values()),i=s.next();!i.done;i=s.next()){var a=i.value;a.onRemove&&a.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=C(this._observers.values()),i=s.next();!i.done;i=s.next()){var a=i.value;a.onRemoveUnsent&&a.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.prototype.unsubscribeAll=function(){this._observers.clear()},e}(),un=function(t){function n(e){var n=e.userId,a=e.ts,o=e.token,u=e.filter,c=t.call(this)||this,l=i(i({},Zt),u),h=l.customTypes,d=l.includeEmpty,p=l.includeFrozen;return c.method=D.GET,c.path="".concat(k,"/").concat(encodeURIComponent(n),"/my_group_channels/changelogs"),c.params=r(s({show_delivery_receipt:!0,show_member:!0,show_read_receipt:!0,change_ts:a||null,token:o,custom_types:h,show_empty:d,show_frozen:p})),c}return e(n,t),n}(R),cn=function(t){function n(e,n){var r=t.call(this,e,n)||this;return r.updatedChannels=n.updated.map((function(t){return new cs(e,t)})),r.deletedChannelUrls=n.deleted,r.hasMore=n.has_more,r.token=n.next,r}return e(n,t),n}(F),ln=function(t){function n(e){var n=e.channelUrl,r=e.isInternalCall,s=t.call(this)||this;return s.method=D.GET,s.path="".concat(r?x:O,"/").concat(encodeURIComponent(n)),s.params={show_member:!0,show_read_receipt:!0,show_delivery_receipt:!0},s}return e(n,t),n}(R),hn=function(t){function n(e,n){var r=t.call(this,e,n)||this;return r.channel=new cs(e,n),r}return e(n,t),n}(F),dn={includeEmpty:!1,includeFrozen:!0,includeMetaData:!0,channelUrlsFilter:void 0,customTypesFilter:void 0,customTypeStartsWithFilter:void 0,nicknameContainsFilter:void 0,nicknameStartsWithFilter:void 0,nicknameExactMatchFilter:void 0,channelNameContainsFilter:void 0,myMemberStateFilter:Ot.ALL,unreadChannelFilter:Gt.ALL,superChannelFilter:Ht.ALL,publicChannelFilter:xt.ALL,hiddenChannelFilter:Vt.ALL,userIdsFilter:{userIds:[],includeMode:!0,queryType:Bt.AND},searchFilter:{query:void 0,fields:[]},metadataKey:void 0,metadataValues:void 0,metadataOrderKeyFilter:void 0,metadataValueStartsWith:void 0,order:Ge.LATEST_LAST_MESSAGE},pn=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.myMemberStateFilter,l=e.superChannelFilter,h=e.publicChannelFilter,d=e.unreadChannelFilter,p=e.nicknameContainsFilter,f=e.nicknameStartsWithFilter,_=e.nicknameExactMatchFilter,m=e.channelNameContainsFilter,v=e.channelUrlsFilter,g=e.customTypesFilter,y=e.customTypeStartsWithFilter,C=e.hiddenChannelFilter,E=e.metadataOrderKeyFilter,b=e.metadataKey,M=e.metadataValues,N=e.metadataValueStartsWith,U=e.includeFrozen,S=e.includeMetaData,T=e.searchFilter,A=e.userIdsFilter;return(n=t.call(this)||this).method=D.GET,n.path="".concat(k,"/").concat(encodeURIComponent(s),"/my_group_channels"),n.params=r({token:i,limit:a,order:null!=o?o:dn.order,show_member:!0,show_read_receipt:!0,show_delivery_receipt:!0,show_empty:null!=u?u:dn.includeEmpty,member_state_filter:null!=c?c:dn.myMemberStateFilter,super_mode:null!=l?l:dn.superChannelFilter,public_mode:null!=h?h:dn.publicChannelFilter,unread_filter:null!=d?d:dn.unreadChannelFilter,members_nickname_contains:p,members_nickname_startswith:f,members_nickname:_,name_contains:m,channel_urls:v,custom_types:g,custom_type_startswith:y,hidden_mode:C,metadata_order_key:E,metadata_key:b,metadata_values:M,metadata_value_startswith:N,show_frozen:U,show_metadata:S}),T&&T.query&&T.fields&&(n.params.search_query=T.query,n.params.search_fields=T.fields),A&&A.userIds&&A.userIds.length>0&&(A.includeMode?(n.params.members_include_in=A.userIds,n.params.query_type=A.queryType.toUpperCase()):n.params.members_exactly_in=A.userIds),n}return e(n,t),n}(R),fn=function(t){function n(e,n){var r=t.call(this,e,n)||this;r.channels=[];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 cs(e,t)}))),r.ts=null!=a?a:0,r}return e(n,t),n}(F),_n=function(t){function n(e){var n=e.userId,r=e.filter,s=t.call(this)||this,i=r.myMemberStateFilter;return s.method=D.GET,s.path="".concat(k,"/").concat(encodeURIComponent(n),"/group_channel_count"),s.params={state:null!=i?i:Ot.ALL},s}return e(n,t),n}(R),mn=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}(F),vn=function(t){function n(e){var n=e.userId,s=e.filter,i=t.call(this)||this,a=s.keys;return i.method=D.GET,i.path="".concat(k,"/").concat(encodeURIComponent(n),"/unread_item_count"),i.params=r({item_keys:a}),i}return e(n,t),n}(R),gn=function(t){function n(e,n){var r=t.call(this,e,n)||this;return"number"==typeof n[Qt.GROUP_CHANNEL_UNREAD_MENTION_COUNT]&&(r.groupChannelUnreadMentionCount=n[Qt.GROUP_CHANNEL_UNREAD_MENTION_COUNT]),"number"==typeof n[Qt.GROUP_CHANNEL_UNREAD_MESSAGE_COUNT]&&(r.groupChannelUnreadMessageCount=n[Qt.GROUP_CHANNEL_UNREAD_MESSAGE_COUNT]),"number"==typeof n[Qt.GROUP_CHANNEL_INVITATION_COUNT]&&(r.groupChannelInvitationCount=n[Qt.GROUP_CHANNEL_INVITATION_COUNT]),"number"==typeof n[Qt.SUPER_UNREAD_MENTION_COUNT]&&(r.superGroupChannelUnreadMentionCount=n[Qt.SUPER_UNREAD_MENTION_COUNT]),"number"==typeof n[Qt.SUPER_UNREAD_MESSAGE_COUNT]&&(r.superGroupChannelUnreadMessageCount=n[Qt.SUPER_UNREAD_MESSAGE_COUNT]),"number"==typeof n[Qt.SUPER_INVITATION_COUNT]&&(r.superGroupChannelInvitationCount=n[Qt.SUPER_INVITATION_COUNT]),"number"==typeof n[Qt.NONSUPER_UNREAD_MENTION_COUNT]&&(r.nonSuperGroupChannelUnreadMentionCount=n[Qt.NONSUPER_UNREAD_MENTION_COUNT]),"number"==typeof n[Qt.NONSUPER_UNREAD_MESSAGE_COUNT]&&(r.nonSuperGroupChannelUnreadMessageCount=n[Qt.NONSUPER_UNREAD_MESSAGE_COUNT]),"number"==typeof n[Qt.NONSUPER_INVITATION_COUNT]&&(r.nonSuperGroupChannelInvitationCount=n[Qt.NONSUPER_INVITATION_COUNT]),r}return e(n,t),n}(F),yn=function(t){function n(e){var n=e.userId,r=t.call(this)||this;return r.method=D.GET,r.path="".concat(k,"/").concat(encodeURIComponent(n),"/unread_channel_count"),r}return e(n,t),n}(R),Cn=function(t){function n(e,n){var r=t.call(this,e,n)||this;return r.unreadCount=n.unread_count,r}return e(n,t),n}(F),En=function(t){function n(e){var n=e.userId,r=e.filter,s=t.call(this)||this,i=r.channelCustomTypesFilter,a=r.superChannelFilter;return s.method=D.GET,s.path="".concat(k,"/").concat(encodeURIComponent(n),"/unread_message_count"),s.params={super_mode:null!=a?a:Ht.ALL,custom_types:i},s}return e(n,t),n}(R),bn=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}(F),Mn=function(t){function n(e){var n=e.channelUrl,r=e.scheduledStatus,s=e.messageTypeFilter,i=t.call(this)||this;return i.method=D.GET,i.path="".concat(H,"/count"),i.params={channel_url:n,status:Un(r)},s&&(i.params.message_type=s),i}return e(n,t),n}(R),Nn=function(t){function n(e,n){var r=t.call(this,e,n)||this;return r.count=n.count,r}return e(n,t),n}(F),Un=function(e){if(!e)return[];var t=[];return e.forEach((function(e){switch(e){case yt.PENDING:t.push(Et.PENDING);break;case yt.SENT:t.push(Et.IN_QUEUE),t.push(Et.SENT);break;case yt.CANCELED:t.push(Et.CANCELED);break;case yt.FAILED:t.push(Et.FAILED)}})),t},Sn=function(t){function n(e){var n=this,s=e.userId,i=e.channelUrl,a=e.coverUrl,o=e.coverImage,u=e.isDistinct,c=e.isSuper,l=e.isBroadcast,h=e.isPublic,d=e.isExclusive,p=e.isDiscoverable,f=e.isStrict,_=e.isEphemeral,g=e.accessCode,y=e.name,C=e.data,E=e.customType,b=e.messageSurvivalSeconds,M=e.invitedUserIds,N=e.operatorUserIds;return(n=t.call(this)||this).method=D.POST,n.path=O,n.params=r({user_ids:m([s],v(null!=M?M:[]),!1).filter((function(e,t,n){return t===n.indexOf(e)})),channel_url:i,cover_url:a,cover_file:o,is_distinct:u,is_super:c,is_broadcast:l,is_exclusive:d,is_public:h,is_discoverable:p,strict:f,is_ephemeral:_,access_code:g,name:y,data:C,custom_type:E,operator_ids:N,message_survival_seconds:b}),n}return e(n,t),n}(R),Tn=function(t){function n(e,n){var r,s=this;return(s=t.call(this,e,n)||this).channel=new cs(e,n),s.isCreated=null===(r=n.is_created)||void 0===r||r,s}return e(n,t),n}(F),An=function(t){function n(e){var n=e.userId,r=e.channelUrls,s=t.call(this)||this;return s.method=D.PUT,s.path="".concat(k,"/").concat(encodeURIComponent(n),"/mark_as_read_all"),s.params={channel_urls:r},s}return e(n,t),n}(R);!function(t){function n(){return null!==t&&t.apply(this,arguments)||this}e(n,t)}(F);var In=function(t){function n(e){var n=this,r=e.channelUrl,s=e.userId,i=e.accessCode;return(n=t.call(this)||this).method=D.PUT,n.path="".concat(O,"/").concat(encodeURIComponent(r),"/join"),n.params={user_id:s,access_code:i},n}return e(n,t),n}(R),wn=function(t){function n(e,n){var r=t.call(this,e,n)||this;return r.channel=new cs(e,n),r}return e(n,t),n}(F),Ln=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?0:a,u=i.joined_member_count,c=void 0===u?0: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 zt(e,t)})):[new zt(e,r.data)],s}return e(n,t),n}(ct),Dn=function(t){function n(e){var n=this,r=e.channelUrl,s=e.userId,i=e.shouldRemoveOperatorStatus;return(n=t.call(this)||this).method=D.PUT,n.path="".concat(O,"/").concat(encodeURIComponent(r),"/leave"),n.params={user_id:s,should_remove_operator_status:i},n}return e(n,t),n}(R);!function(t){function n(e,n){return t.call(this,e,n)||this}e(n,t)}(F);var kn=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?0:a,u=i.joined_member_count,c=void 0===u?0:u;return s.memberCount=o,s.joinedMemberCount=c,s.member=new zt(s._iid,r.data),s}return e(n,t),n}(ct),Pn=function(t){function n(e){var n=this,r=e.channelUrl,s=e.userIds;return(n=t.call(this)||this).method=D.POST,n.path="".concat(O,"/").concat(encodeURIComponent(r),"/invite"),n.params={user_ids:s},n}return e(n,t),n}(R),Rn=function(t){function n(e,n){var r=t.call(this,e,n)||this;return r.channel=new cs(e,n),r}return e(n,t),n}(F),Fn=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?0:a,u=i.joined_member_count,l=void 0===u?0:u,h=i.inviter,d=i.invitees,p=void 0===d?[]:d;return s.memberCount=o,s.joinedMemberCount=l,s.inviter=new c(e,h),s.invitees=p.map((function(t){return new zt(e,t)})),s}return e(n,t),n}(ct),xn=function(t){function n(e){var n=this,r=e.channelUrl,s=e.userId;return(n=t.call(this)||this).method=D.PUT,n.path="".concat(O,"/").concat(encodeURIComponent(r),"/decline"),n.params={user_id:s},n}return e(n,t),n}(R);!function(t){function n(e,n){var r=t.call(this,e,n)||this;return r.channel=new cs(e,n),r.channel.myMemberState=Ft.NONE,r}e(n,t)}(F);var On=function(t){function n(e,n,r){var s=t.call(this,e,n,r)||this,i=r.data,a=i.member_count,o=i.joined_member_count,u=i.inviter,l=i.invitee;return s.memberCount=null!=a?a:0,s.joinedMemberCount=null!=o?o:0,s.inviter=new c(e,u),s.invitee=new zt(e,l),s}return e(n,t),n}(ct),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}(V),Gn=function(t){function n(e,n,r){var s=t.call(this,e,"READ",r)||this;return s.readStatus=new jt(e,r),s}return e(n,t),n}(q),Vn=function(t){function n(e){var n=e.channelUrl,s=e.userId,i=t.call(this)||this;return(i=t.call(this)||this).method=D.PUT,i.path="".concat(O,"/").concat(encodeURIComponent(n),"/messages/mark_as_delivered"),i.params=r({userId:s}),i}return e(n,t),n}(R);!function(t){function n(){return null!==t&&t.apply(this,arguments)||this}e(n,t)}(F);var qn,Bn=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}(q),Wn={hidePreviousMessages:!1,allowAutoUnhide:!0},zn=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=D.PUT,n.path="".concat(O,"/").concat(encodeURIComponent(r),"/hide"),n.params={user_id:s,hide_previous_messages:null!=i?i:Wn.hidePreviousMessages,allow_auto_unhide:null!=a?a:Wn.allowAutoUnhide},n}return e(n,t),n}(R),jn=function(t){function n(e,n){var r=t.call(this,e,n)||this,s=n.ts_message_offset;return r.messageOffsetTimestamp=s,r}return e(n,t),n}(F),Qn=function(t){function n(e,n,r){var s,i,a,o=this;return(o=t.call(this,e,"SYEV",r)||this).allowAutoUnhide=null,o.hidePreviousMessages=null,o.messageOffsetTimestamp=null,r.data&&(o.allowAutoUnhide=null!==(s=r.data.allow_auto_unhide)&&void 0!==s?s:null,o.hidePreviousMessages=null!==(i=r.data.hide_previous_messages)&&void 0!==i?i:null),o.messageOffsetTimestamp=null!==(a=r.ts_message_offset)&&void 0!==a?a:null,o}return e(n,t),n}(q),Kn=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}(V),Yn=function(t){function n(e,n,r){var s=t.call(this,e,"SYEV",r)||this;return s.user=new c(e,r.data),s}return e(n,t),n}(q),Jn=function(t){function n(e){var n=e.channelUrl,r=e.time;return t.call(this,{code:"TPEN",ackRequired:!1,payload:{channel_url:n,time:r}})||this}return e(n,t),n}(V),Xn=function(t){function n(e,n,r){var s=t.call(this,e,"SYEV",r)||this;return s.user=new c(e,r.data),s}return e(n,t),n}(q),Zn=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}(V),$n=function(t){function n(e,n){var r,s,i,a,o,u,c,l,h,d,p,f,_,m,v,g,y,C,E,b,M,N,U=this;return(U=t.call(this,e,n)||this).includeEmpty=!1,U.includeFrozen=!0,U.includeMetaData=!0,U.channelUrlsFilter=null,U.customTypesFilter=null,U.customTypeStartsWithFilter=null,U.nicknameContainsFilter=null,U.nicknameStartsWithFilter=null,U.nicknameExactMatchFilter=null,U.channelNameContainsFilter="",U.myMemberStateFilter=Ot.ALL,U.unreadChannelFilter=Gt.ALL,U.superChannelFilter=Ht.ALL,U.publicChannelFilter=xt.ALL,U.hiddenChannelFilter=Vt.UNHIDDEN,U.searchFilter={fields:[],query:null},U.userIdsFilter={userIds:[],includeMode:!0,queryType:Bt.AND},U.metadataKey=null,U.metadataValues=null,U.metadataOrderKeyFilter=null,U.metadataValueStartsWith=null,U.order=Ge.LATEST_LAST_MESSAGE,U.includeEmpty=null!==(r=n.includeEmpty)&&void 0!==r&&r,U.includeFrozen=null===(s=n.includeFrozen)||void 0===s||s,U.includeMetaData=null===(i=n.includeMetaData)||void 0===i||i,U.channelUrlsFilter=null!==(a=n.channelUrlsFilter)&&void 0!==a?a:null,U.customTypesFilter=null!==(o=n.customTypesFilter)&&void 0!==o?o:null,U.customTypeStartsWithFilter=null!==(u=n.customTypeStartsWithFilter)&&void 0!==u?u:"",U.nicknameContainsFilter=null!==(c=n.nicknameContainsFilter)&&void 0!==c?c:null,U.nicknameStartsWithFilter=null!==(l=n.nicknameStartsWithFilter)&&void 0!==l?l:null,U.nicknameExactMatchFilter=null!==(h=n.nicknameExactMatchFilter)&&void 0!==h?h:null,U.channelNameContainsFilter=null!==(d=n.channelNameContainsFilter)&&void 0!==d?d:"",U.myMemberStateFilter=null!==(p=n.myMemberStateFilter)&&void 0!==p?p:Ot.ALL,U.unreadChannelFilter=null!==(f=n.unreadChannelFilter)&&void 0!==f?f:Gt.ALL,U.superChannelFilter=null!==(_=n.superChannelFilter)&&void 0!==_?_:Ht.ALL,U.publicChannelFilter=null!==(m=n.publicChannelFilter)&&void 0!==m?m:xt.ALL,U.hiddenChannelFilter=null!==(v=n.hiddenChannelFilter)&&void 0!==v?v:Vt.UNHIDDEN,U.searchFilter=null!==(g=n.searchFilter)&&void 0!==g?g:{fields:[],query:null},U.userIdsFilter=null!==(y=n.userIdsFilter)&&void 0!==y?y:{userIds:[],includeMode:!0,queryType:Bt.AND},U.metadataKey=null!==(C=n.metadataKey)&&void 0!==C?C:null,U.metadataValues=null!==(E=n.metadataValues)&&void 0!==E?E:null,U.metadataOrderKeyFilter=null!==(b=n.metadataOrderKeyFilter)&&void 0!==b?b:null,U.metadataValueStartsWith=null!==(M=n.metadataValueStartsWith)&&void 0!==M?M:null,U.order=null!==(N=n.order)&&void 0!==N?N:Ge.LATEST_LAST_MESSAGE,U}return e(n,t),n.prototype._validate=function(){return t.prototype._validate.call(this)&&b("boolean",this.includeEmpty)&&b("boolean",this.includeFrozen)&&b("boolean",this.includeMetaData)&&b("string",this.channelNameContainsFilter)&&E("string",this.channelUrlsFilter,!0)&&E("string",this.customTypesFilter,!0)&&b("string",this.customTypeStartsWithFilter)&&b("string",this.nicknameContainsFilter,!0)&&b("string",this.nicknameStartsWithFilter,!0)&&b("string",this.nicknameExactMatchFilter,!0)&&a(Ot,this.myMemberStateFilter)&&a(Ht,this.superChannelFilter)&&a(xt,this.publicChannelFilter)&&a(Gt,this.unreadChannelFilter)&&a(Vt,this.hiddenChannelFilter)&&E(Wt,this.searchFilter.fields)&&b("string",this.searchFilter.query,!0)&&E("string",this.userIdsFilter.userIds)&&b("boolean",this.userIdsFilter.includeMode)&&a(Bt,this.userIdsFilter.queryType)&&a(Ge,this.order)&&b("string",this.metadataOrderKeyFilter,!0)&&b("string",this.metadataKey,!0)&&E("string",this.metadataValues,!0)&&b("string",this.metadataValueStartsWith,!0)},n.prototype.serialize=function(){return B(this)},n.prototype.next=function(){return g(this,void 0,void 0,(function(){var e,t,n;return y(this,(function(r){switch(r.label){case 0:return this._validate()?this._isLoading?[3,3]:this._hasNext?(this._isLoading=!0,[4,rr.of(this._iid).getMyGroupChannels(this._token,s(i({},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 _.queryInProgress;case 4:return[3,6];case 5:throw _.invalidParameters;case 6:return[2]}}))}))},n}(W),er=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||D.unreadMentionCount>0)&&(D._updateUnreadCount(0,0),this._dispatcher.dispatch(new We({channels:[D],source:ze.EVENT_CHANNEL_READ})),Y((function(){return g(Nn,void 0,void 0,(function(){var e,t,n,r,s;return y(this,(function(i){try{for(e=C(this._groupChannelHandlers.values()),t=e.next();!t.done;t=e.next())(n=t.value).onChannelChanged&&n.onChannelChanged(D)}catch(e){r={error:e}}finally{try{t&&!t.done&&(s=e.return)&&s.call(e)}finally{if(r)throw r.error}}return[2]}))}))}))):0!==D.unreadMessageCount&&0!==D.unreadMentionCount||(this._dispatcher.dispatch(new We({channels:[D],source:ze.EVENT_CHANNEL_READ})),Y((function(){return g(Nn,void 0,void 0,(function(){var e,t,n,r,s;return y(this,(function(i){try{for(e=C(this._groupChannelHandlers.values()),t=e.next();!t.done;t=e.next())(n=t.value).onChannelChanged&&n.onChannelChanged(D)}catch(e){r={error:e}}finally{try{t&&!t.done&&(s=e.return)&&s.call(e)}finally{if(r)throw r.error}}return[2]}))}))}))):(this._dispatcher.dispatch(new We({channels:[D],source:ze.EVENT_CHANNEL_READ})),Y((function(){return g(Nn,void 0,void 0,(function(){var e,t,n,r,s;return y(this,(function(i){try{for(e=C(this._groupChannelHandlers.values()),t=e.next();!t.done;t=e.next())(n=t.value).onUnreadMemberStatusUpdated&&n.onUnreadMemberStatusUpdated(D)}catch(e){r={error:e}}finally{try{t&&!t.done&&(s=e.return)&&s.call(e)}finally{if(r)throw r.error}}return[2]}))}))}))),Un.label=12;case 12:return[3,79];case 13:return k=e.as(Bn),le=k.channelUrl,P=k.deliveredStateUpdate,R=void 0===P?{}:P,F=this._groupChannelCache.isCachedInMemory(le),[4,this.getChannel(le,!0)];case 14:if(x=Un.sent(),F)for(O in R)x._updateUndeliveredMemberState(O,R[O]);return Object.keys(R).some((function(e){return e!==Nn._sdkState.userId}))&&(this._dispatcher.dispatch(new We({channels:[x],source:ze.EVENT_CHANNEL_DELIVERED})),Y((function(){return g(Nn,void 0,void 0,(function(){var e,t,n,r,s;return y(this,(function(i){try{for(e=C(this._groupChannelHandlers.values()),t=e.next();!t.done;t=e.next())(n=t.value).onUndeliveredMemberStatusUpdated&&n.onUndeliveredMemberStatusUpdated(x)}catch(e){r={error:e}}finally{try{t&&!t.done&&(s=e.return)&&s.call(e)}finally{if(r)throw r.error}}return[2]}))}))}))),[3,79];case 15:return H=e.as(_t),le=H.channelUrl,he=H.channelType,G=H.event,he!==u.GROUP?[3,18]:[4,this.getChannel(le,!0)];case 16:return V=Un.sent(),[4,this.getMessageFromCache(G.messageId)];case 17:(W=Un.sent())&&(W.applyReactionEvent(G),this._dispatcher.dispatch(new L({messages:[W],source:J.EVENT_MESSAGE_REACTION_UPDATED}))),Y((function(){return g(Nn,void 0,void 0,(function(){var e,t,n,r,s;return y(this,(function(i){try{for(e=C(this._groupChannelHandlers.values()),t=e.next();!t.done;t=e.next())(n=t.value).onReactionUpdated&&n.onReactionUpdated(V,G)}catch(e){r={error:e}}finally{try{t&&!t.done&&(s=e.return)&&s.call(e)}finally{if(r)throw r.error}}return[2]}))}))})),Un.label=18;case 18:return[3,79];case 19:return(q=e.as(ft).event).channelType!==u.GROUP?[3,22]:[4,this.getChannel(q.channelUrl,!0)];case 20:return B=Un.sent(),[4,this.getMessageFromCache(q.targetMessageId)];case 21:(W=Un.sent())&&(W.applyThreadInfoUpdateEvent(q),this._dispatcher.dispatch(new L({messages:[W],source:J.EVENT_MESSAGE_THREADINFO_UPDATED}))),Y((function(){return g(Nn,void 0,void 0,(function(){var e,t,n,r,s;return y(this,(function(i){try{for(e=C(this._groupChannelHandlers.values()),t=e.next();!t.done;t=e.next())(n=t.value).onThreadInfoUpdated&&n.onThreadInfoUpdated(B,q)}catch(e){r={error:e}}finally{try{t&&!t.done&&(s=e.return)&&s.call(e)}finally{if(r)throw r.error}}return[2]}))}))})),Un.label=22;case 22:return[3,79];case 23:z=e.as(pt).groupChannelMemberCounts,Q=[],Un.label=24;case 24:Un.trys.push([24,29,30,31]),X=C(z),$=X.next(),Un.label=25;case 25:return $.done?[3,28]:(ee=$.value,le=ee.channelUrl,it=ee.memberCount,at=ee.joinedMemberCount,te=ee.updatedAt,[4,this.getChannelFromCache(le)]);case 26:(ne=Un.sent())&&ne._setLatestMemberCount(it,at,te)&&Q.push(ne),Un.label=27;case 27:return $=X.next(),[3,25];case 28:return[3,31];case 29:return re=Un.sent(),mn={error:re},[3,31];case 30:try{$&&!$.done&&(vn=X.return)&&vn.call(X)}finally{if(mn)throw mn.error}return[7];case 31:return Q.length>0&&(this._dispatcher.dispatch(new We({channels:Q,source:ze.EVENT_CHANNEL_MEMBER_COUNT_UPDATED})),Y((function(){return g(Nn,void 0,void 0,(function(){var e,t,n,r,s;return y(this,(function(i){try{for(e=C(this._groupChannelHandlers.values()),t=e.next();!t.done;t=e.next())(n=t.value).onChannelMemberCountChanged&&n.onChannelMemberCountChanged(Q)}catch(e){r={error:e}}finally{try{t&&!t.done&&(s=e.return)&&s.call(e)}finally{if(r)throw r.error}}return[2]}))}))}))),[3,79];case 32:return se=e.as(dt),ie=se.event,ae=se.status,le=se.channelUrl,he=se.channelType,le&&he===u.GROUP?[4,this.getChannel(le,!0)]:[3,34];case 33:oe=Un.sent(),this._dispatcher.dispatch(new T({event:ie,source:J.EVENT_POLL_UPDATED})),Y(ae===Z?function(){return g(Nn,void 0,void 0,(function(){var e,t,n,r,s;return y(this,(function(i){try{for(e=C(this._groupChannelHandlers.values()),t=e.next();!t.done;t=e.next())(n=t.value).onPollDeleted&&n.onPollDeleted(oe,ie.pollId)}catch(e){r={error:e}}finally{try{t&&!t.done&&(s=e.return)&&s.call(e)}finally{if(r)throw r.error}}return[2]}))}))}:function(){return g(Nn,void 0,void 0,(function(){var e,t,n,r,s;return y(this,(function(i){try{for(e=C(this._groupChannelHandlers.values()),t=e.next();!t.done;t=e.next())(n=t.value).onPollUpdated&&n.onPollUpdated(oe,ie)}catch(e){r={error:e}}finally{try{t&&!t.done&&(s=e.return)&&s.call(e)}finally{if(r)throw r.error}}return[2]}))}))}),Un.label=34;case 34:return[3,79];case 35:return ue=e.as(Te),ce=ue.event,le=ue.channelUrl,he=ue.channelType,le&&he===u.GROUP?[4,this.getChannel(le,!0)]:[3,37];case 36:de=Un.sent(),this._dispatcher.dispatch(new S({event:ce,source:J.EVENT_POLL_VOTED})),Y((function(){return g(Nn,void 0,void 0,(function(){var e,t,n,r,s;return y(this,(function(i){try{for(e=C(this._groupChannelHandlers.values()),t=e.next();!t.done;t=e.next())(n=t.value).onPollVoted&&n.onPollVoted(de,ce)}catch(e){r={error:e}}finally{try{t&&!t.done&&(s=e.return)&&s.call(e)}finally{if(r)throw r.error}}return[2]}))}))})),Un.label=37;case 37:return[3,79];case 38:if(!(pe=e.as(ct).event).isGroupChannelEvent)return[3,77];switch(pe.category){case lt.CHANNEL_JOIN:return[3,39];case lt.CHANNEL_LEAVE:return[3,41];case lt.CHANNEL_OPERATOR_UPDATE:return[3,45];case lt.CHANNEL_INVITE:return[3,47];case lt.CHANNEL_DECLINE_INVITE:return[3,49];case lt.TYPING_START:case lt.TYPING_END:return[3,51];case lt.USER_CHANNEL_MUTE:case lt.USER_CHANNEL_UNMUTE:return[3,53];case lt.USER_CHANNEL_BAN:return[3,55];case lt.USER_CHANNEL_UNBAN:return[3,59];case lt.CHANNEL_FREEZE:case lt.CHANNEL_UNFREEZE:return[3,61];case lt.CHANNEL_HIDE:return[3,63];case lt.CHANNEL_UNHIDE:return[3,65];case lt.CHANNEL_DELETED:return[3,67];case lt.CHANNEL_PROP_CHANGED:return[3,69];case lt.CHANNEL_META_DATA_CHANGED:return[3,71];case lt.CHANNEL_META_COUNTERS_CHANGED:return[3,73];case lt.PINNED_MESSAGE_CHANGED:return[3,75]}return[3,77];case 39:return[4,this.getChannel(pe.channelUrl,!0)];case 40:return fe=Un.sent(),_e=e.as(Ln),me=_e.memberCount,ve=_e.joinedMemberCount,ge=_e.members,ye=!1,ge.forEach((function(e){fe.isExclusive||fe.isSuper||fe.isBroadcast?ye=ye||fe._setLatestMemberCount(me,ve,pe.ts):(e.state=Ft.JOINED,fe.addMember(e,pe.ts),Nn._updateJoinedMemberCount(fe)),e.userId===Nn._sdkState.userId&&(fe.myMemberState=Ft.JOINED)})),this._dispatcher.dispatch(new We({channels:[fe],source:ze.EVENT_CHANNEL_JOINED})),Y((function(){return g(Nn,void 0,void 0,(function(){return y(this,(function(e){return this._groupChannelHandlers.forEach((function(e){var t,n;try{for(var r=C(ge),s=r.next();!s.done;s=r.next()){var i=s.value;e.onUserJoined&&e.onUserJoined(fe,i)}}catch(e){t={error:e}}finally{try{s&&!s.done&&(n=r.return)&&n.call(r)}finally{if(t)throw t.error}}fe.isBroadcast&&ye&&e.onChannelMemberCountChanged&&e.onChannelMemberCountChanged([fe])})),[2]}))}))})),[3,77];case 41:return(It=this._leftChannels.get(pe.channelUrl))?(ke=It.channel,[3,44]):[3,42];case 42:return[4,this.getChannel(pe.channelUrl,!0)];case 43:ke=Un.sent(),Un.label=44;case 44:return De=ke,Pe=e.as(kn),it=Pe.memberCount,at=Pe.joinedMemberCount,Re=Pe.member,Fe=!1,xe=j.of(this._iid).appInfo,De.isExclusive||De.isSuper||De.isBroadcast?Fe=De._setLatestMemberCount(it,at,pe.ts):((null==xe?void 0:xe.enabledChannelMemberShipHistory)?((Oe=De.members.find((function(e){return e.userId===Oe.userId})))&&(Oe.state=Ft.LEFT),De.memberCount=it):De.removeMember(Re),this._updateJoinedMemberCount(De)),Re.userId===this._sdkState.userId?(De.myMemberState=Ft.NONE,De.invitedAt=0,De.joinedAt=0,De._updateUnreadCount(0,0),De.isPublic?this._dispatcher.dispatch(new We({channels:[De],source:ze.EVENT_CHANNEL_LEFT})):(this._markAsLeave(De),this._dispatcher.dispatch(new Be({channelUrls:[De.url],source:ze.EVENT_CHANNEL_LEFT})))):this._dispatcher.dispatch(new We({channels:[De],source:ze.EVENT_CHANNEL_LEFT})),Y((function(){return g(Nn,void 0,void 0,(function(){return y(this,(function(e){return this._groupChannelHandlers.forEach((function(e){e.onUserLeft&&e.onUserLeft(De,Re),De.isBroadcast&&Fe&&e.onChannelMemberCountChanged&&e.onChannelMemberCountChanged([De])})),[2]}))}))})),[3,77];case 45:return[4,this.getChannel(pe.channelUrl,!0)];case 46:He=Un.sent(),Ge=e.as(ht).operators,Ve=Ge.map((function(e){return e.userId}));try{for(qe=C(He.members),je=qe.next();!je.done;je=qe.next())(At=je.value).role=Ve.includes(At.userId)?o.OPERATOR:o.NONE}catch(e){gn={error:e}}finally{try{je&&!je.done&&(yn=qe.return)&&yn.call(qe)}finally{if(gn)throw gn.error}}return He.myRole=Ve.includes(this._sdkState.userId)?o.OPERATOR:o.NONE,this._dispatcher.dispatch(new We({channels:[He],source:ze.EVENT_CHANNEL_OPERATOR_UPDATED})),Y((function(){return g(Nn,void 0,void 0,(function(){return y(this,(function(e){return this._groupChannelHandlers.forEach((function(e){e.onOperatorUpdated&&e.onOperatorUpdated(He,Ge)})),[2]}))}))})),[3,77];case 47:return[4,this.getChannel(pe.channelUrl,!0)];case 48:Qe=Un.sent(),Ke=e.as(Fn),it=Ke.memberCount,at=Ke.joinedMemberCount,Ye=Ke.inviter,(Je=Ke.invitees).forEach((function(e){return e.state=Ft.INVITED}));try{for(Xe=C(Je),tt=Xe.next();!tt.done;tt=Xe.next())nt=tt.value,Qe.isExclusive||Qe.isSuper||Qe.isBroadcast?Qe._setLatestMemberCount(it,at,pe.ts):Qe.addMember(nt,pe.ts),this._sdkState.userId===nt.userId&&(Qe.hiddenState=rs.UNHIDDEN,Qe.myMemberState!==Ft.JOINED&&(Qe.myMemberState=Ft.INVITED),Qe.invitedAt=pe.ts)}catch(e){Cn={error:e}}finally{try{tt&&!tt.done&&(En=Xe.return)&&En.call(Xe)}finally{if(Cn)throw Cn.error}}return this._dispatcher.dispatch(new We({channels:[Qe],source:ze.EVENT_CHANNEL_INVITED})),Y((function(){return g(Nn,void 0,void 0,(function(){return y(this,(function(e){return this._groupChannelHandlers.forEach((function(e){e.onUserReceivedInvitation&&e.onUserReceivedInvitation(Qe,Ye,Je)})),[2]}))}))})),[3,77];case 49:return[4,this.getChannel(pe.channelUrl,!0)];case 50:return rt=Un.sent(),st=e.as(On),it=st.memberCount,at=st.joinedMemberCount,ot=st.inviter,ut=st.invitee,rt.isExclusive||rt.isSuper||rt.isBroadcast?rt._setLatestMemberCount(it,at,pe.ts):rt.removeMember(ut),this._sdkState.userId===ut.userId?(rt.invitedAt=0,rt.myMemberState=Ft.NONE,rt.isPublic?this._dispatcher.dispatch(new We({channels:[rt],source:ze.EVENT_CHANNEL_DECLINED_INVITE})):this._dispatcher.dispatch(new Be({channelUrls:[rt.url],source:ze.EVENT_CHANNEL_DECLINED_INVITE}))):this._dispatcher.dispatch(new We({channels:[rt],source:ze.EVENT_CHANNEL_DECLINED_INVITE})),Y((function(){return g(Nn,void 0,void 0,(function(){return y(this,(function(e){return this._groupChannelHandlers.forEach((function(e){e.onUserDeclinedInvitation&&e.onUserDeclinedInvitation(rt,ot,ut)})),[2]}))}))})),[3,77];case 51:return[4,this.getChannel(pe.channelUrl,!0)];case 52:return gt=Un.sent(),yt=pe.category===lt.TYPING_START,Et=e.as(yt?Yn:Xn).user,gt._updateTypingStatus(Et,yt?pe.ts:0),this._dispatcher.dispatch(new We({channels:[gt],source:ze.EVENT_CHANNEL_TYPING_STATUS_UPDATE})),Y((function(){return g(Nn,void 0,void 0,(function(){return y(this,(function(e){return this._groupChannelHandlers.forEach((function(e){e.onTypingStatusUpdated&&e.onTypingStatusUpdated(gt)})),[2]}))}))})),[3,77];case 53:return[4,this.getChannel(pe.channelUrl,!0)];case 54:bt=Un.sent(),Mt=pe.category===lt.USER_CHANNEL_MUTE,(Nt=e.as(Mt?Ue:Se).user).userId===this._sdkState.userId&&(bt.myMutedState=Mt?ns.MUTED:ns.UNMUTED,bt._myMutedRemainingTime=Nt.restrictionInfo.remainingDuration);try{for(St=C(bt.members),Tt=St.next();!Tt.done;Tt=St.next())if((At=Tt.value).userId===Nt.userId){At.isMuted=Mt;break}}catch(e){bn={error:e}}finally{try{Tt&&!Tt.done&&(Mn=St.return)&&Mn.call(St)}finally{if(bn)throw bn.error}}return this._dispatcher.dispatch(new We({channels:[bt],source:Mt?ze.EVENT_CHANNEL_MUTED:ze.EVENT_CHANNEL_UNMUTED,data:Nt.userId})),Y((function(){return g(Nn,void 0,void 0,(function(){return y(this,(function(e){return this._groupChannelHandlers.forEach((function(e){Mt?e.onUserMuted&&e.onUserMuted(bt,Nt):e.onUserUnmuted&&e.onUserUnmuted(bt,Nt)})),[2]}))}))})),[3,77];case 55:return(It=this._leftChannels.get(pe.channelUrl))?(Lt=It.channel,[3,58]):[3,56];case 56:return[4,this.getChannel(pe.channelUrl,!0)];case 57:Lt=Un.sent(),Un.label=58;case 58:return wt=Lt,this._markAsLeave(wt),Dt=e.as(Ne).user,Y((function(){return g(Nn,void 0,void 0,(function(){return y(this,(function(e){return this._groupChannelHandlers.forEach((function(e){e.onUserBanned&&e.onUserBanned(wt,Dt)})),[2]}))}))})),[3,77];case 59:return[4,this.getChannel(pe.channelUrl,!0)];case 60:return kt=Un.sent(),Pt=e.as(Me).user,Y((function(){return g(Nn,void 0,void 0,(function(){return y(this,(function(e){return this._groupChannelHandlers.forEach((function(e){e.onUserUnbanned&&e.onUserUnbanned(kt,Pt)})),[2]}))}))})),[3,77];case 61:return[4,this.getChannel(pe.channelUrl,!0)];case 62:return Rt=Un.sent(),xt=e.as(be).freeze,Rt.isFrozen=xt,this._dispatcher.dispatch(new We({channels:[Rt],source:xt?ze.EVENT_CHANNEL_FROZEN:ze.EVENT_CHANNEL_UNFROZEN})),Y((function(){return g(Nn,void 0,void 0,(function(){return y(this,(function(e){return this._groupChannelHandlers.forEach((function(e){xt?e.onChannelFrozen&&e.onChannelFrozen(Rt):e.onChannelUnfrozen&&e.onChannelUnfrozen(Rt)})),[2]}))}))})),[3,77];case 63:return[4,this.getChannel(pe.channelUrl,!0)];case 64:return Ot=Un.sent(),Ht=e.as(Qn),Gt=Ht.allowAutoUnhide,Vt=Ht.hidePreviousMessages,qt=Ht.messageOffsetTimestamp,null!==Gt&&(Ot.hiddenState=Gt?rs.HIDDEN_ALLOW_AUTO_UNHIDE:rs.HIDDEN_PREVENT_AUTO_UNHIDE),null!==Vt&&Vt&&Ot._updateUnreadCount(0,0),null!==qt&&(Ot.messageOffsetTimestamp=qt),this._dispatcher.dispatch(new We({channels:[Ot],source:ze.EVENT_CHANNEL_HIDDEN})),Y((function(){return g(Nn,void 0,void 0,(function(){return y(this,(function(e){return this._groupChannelHandlers.forEach((function(e){e.onChannelHidden&&e.onChannelHidden(Ot)})),[2]}))}))})),[3,77];case 65:return[4,this.getChannel(pe.channelUrl,!0)];case 66:return(Bt=Un.sent()).hiddenState=rs.UNHIDDEN,this._dispatcher.dispatch(new We({channels:[Bt],source:ze.EVENT_CHANNEL_UNHIDDEN})),Y((function(){return g(Nn,void 0,void 0,(function(){return y(this,(function(e){return this._groupChannelHandlers.forEach((function(e){e.onChannelChanged&&e.onChannelChanged(Bt)})),[2]}))}))})),[3,77];case 67:return[4,this.getChannel(pe.channelUrl,!0)];case 68:return Wt=Un.sent(),this._dispatcher.dispatch(new Be({channelUrls:[pe.channelUrl],source:ze.EVENT_CHANNEL_DELETED})),Y((function(){return g(Nn,void 0,void 0,(function(){return y(this,(function(e){return this._groupChannelHandlers.forEach((function(e){e.onChannelDeleted&&e.onChannelDeleted(Wt.url,Wt.channelType)})),[2]}))}))})),[3,77];case 69:return[4,this.getChannelWithoutCache(pe.channelUrl,!0)];case 70:return zt=Un.sent(),this._dispatcher.dispatch(new We({channels:[zt],source:ze.EVENT_CHANNEL_UPDATED})),Y((function(){return g(Nn,void 0,void 0,(function(){return y(this,(function(e){return this._groupChannelHandlers.forEach((function(e){e.onChannelChanged&&e.onChannelChanged(zt)})),[2]}))}))})),[3,77];case 71:return[4,this.getChannel(pe.channelUrl,!0)];case 72:return jt=Un.sent(),Qt=e.as(Ee),Kt=Qt.created,Yt=Qt.updated,Jt=Qt.deleted,Kt&&jt._upsertCachedMetaData(Kt,pe.ts),Yt&&jt._upsertCachedMetaData(Yt,pe.ts),Jt&&jt._removeFromCachedMetaData(Jt,pe.ts),Y((function(){return g(Nn,void 0,void 0,(function(){return y(this,(function(e){return this._groupChannelHandlers.forEach((function(e){Kt&&e.onMetaDataCreated&&e.onMetaDataCreated(jt,Kt),Yt&&e.onMetaDataUpdated&&e.onMetaDataUpdated(jt,Yt),Jt&&e.onMetaDataDeleted&&e.onMetaDataDeleted(jt,Jt)})),[2]}))}))})),[3,77];case 73:return[4,this.getChannel(pe.channelUrl,!0)];case 74:return Xt=Un.sent(),Zt=e.as(Ce),$t=Zt.created,en=Zt.updated,tn=Zt.deleted,Y((function(){return g(Nn,void 0,void 0,(function(){return y(this,(function(e){return this._groupChannelHandlers.forEach((function(e){$t&&e.onMetaCounterCreated&&e.onMetaCounterCreated(Xt,$t),en&&e.onMetaCounterUpdated&&e.onMetaCounterUpdated(Xt,en),tn&&e.onMetaCounterDeleted&&e.onMetaCounterDeleted(Xt,tn)})),[2]}))}))})),[3,77];case 75:return[4,this.getChannel(pe.channelUrl,!0)];case 76:return nn=Un.sent(),rn=e.as(tr),sn=rn.pinnedMessageIds,an=rn.latestPinnedMessage,(on=rn.ts)>nn._pinnedMessagesUpdatedAt&&(nn.pinnedMessageIds=sn,nn.lastPinnedMessage=an,nn._pinnedMessagesUpdatedAt=on,this._dispatcher.dispatch(new We({channels:[nn],source:ze.EVENT_PINNED_MESSAGE_UPDATED})),Y((function(){return g(Nn,void 0,void 0,(function(){var e,t,n,r,s;return y(this,(function(i){try{for(e=C(this._groupChannelHandlers.values()),t=e.next();!t.done;t=e.next())(n=t.value).onChannelChanged&&n.onChannelChanged(nn)}catch(e){r={error:e}}finally{try{t&&!t.done&&(s=e.return)&&s.call(e)}finally{if(r)throw r.error}}return[2]}))}))})),Y((function(){return g(Nn,void 0,void 0,(function(){return y(this,(function(e){return this._groupChannelHandlers.forEach((function(e){e.onPinnedMessageUpdated&&e.onPinnedMessageUpdated(nn)})),[2]}))}))}))),[3,77];case 77:return[3,79];case 78:switch((un=e.as(Ze).event).category){case $e.USER_BLOCK:cn=et.getDataAsUserBlockEvent(this._iid,un),hn=cn.blocker,dn=cn.blockee,this._groupChannelCache.block(hn.userId,dn.userId);break;case $e.USER_UNBLOCK:ln=et.getDataAsUserBlockEvent(this._iid,un),hn=ln.blocker,dn=ln.blockee,this._groupChannelCache.unblock(hn.userId,dn.userId)}return[3,79];case 79:return[3,81];case 80:if(pn=Un.sent(),K(pn))throw pn;return[3,81];case 81: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===Ft.JOINED})).length},e.prototype.getChannel=function(e,t){return void 0===t&&(t=!1),g(this,void 0,void 0,(function(){var n;return y(this,(function(r){switch(r.label){case 0:f(b("string",e)).throw(_.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),g(this,void 0,void 0,(function(){var n,r,s,i,a;return y(this,(function(o){switch(o.label){case 0:return f(b("string",e)).throw(_.invalidParameters),n=new ln({channelUrl:e,isInternalCall:t}),[4,this._requestQueue.send(n)];case 1:switch(r=o.sent(),s=r.as(hn).channel,i=s.unreadMessageCount,a=s.unreadMentionCount,s.myCountPreference){case ts.UNREAD_MESSAGE_COUNT_ONLY:a=0;break;case ts.UNREAD_MENTION_COUNT_ONLY:i=0;break;case ts.OFF:i=0,a=0}return s._updateUnreadCount(i,a),[4,this.upsertChannelsToCache([s])];case 2:return[2,o.sent()[0]]}}))}))},e.prototype.refreshChannel=function(e,t,n){return void 0===t&&(t=!0),void 0===n&&(n=ze.REFRESH_CHANNEL),g(this,void 0,void 0,(function(){var r,s,i,a,o;return y(this,(function(u){switch(u.label){case 0:return u.trys.push([0,5,,6]),r=new ln({channelUrl:e,isInternalCall:t}),[4,this._requestQueue.send(r)];case 1:return s=u.sent(),(i=s.as(hn).channel).myMemberState!==Ft.NONE?[3,2]:(this._dispatcher.dispatch(new Be({channelUrls:[i.url],source:n})),[3,4]);case 2:return[4,this.upsertChannelsToCache([i])];case 3:a=u.sent(),this._dispatcher.dispatch(new We({channels:a,source:n})),u.label=4;case 4:return[3,6];case 5:return(o=u.sent()).code!==X.NON_AUTHORIZED&&o.code!==X.NOT_FOUND_IN_DATABASE||this._dispatcher.dispatch(new Be({channelUrls:[e],source:n})),[3,6];case 6:return[2]}}))}))},e.prototype.getMyGroupChannels=function(e,t,n,r){return void 0===r&&(r=ze.REQUEST_CHANNEL),g(this,void 0,void 0,(function(){var s,a,o,u,c;return y(this,(function(l){switch(l.label){case 0:return s=new pn(i(i({},t),{userId:this._sdkState.userId,token:e,limit:n})),[4,this._requestQueue.send(s)];case 1:return a=l.sent(),o=a.as(fn),u=o.channels,c=o.token,this._dispatcher.dispatch(new We({channels:u,source:r})),[2,{channels:u,token:c}]}}))}))},e.prototype.getMessageFromCache=function(e){var t;return g(this,void 0,void 0,(function(){return y(this,(function(n){switch(n.label){case 0:return[4,this._messageCache.get(e)];case 1:return[2,null!==(t=n.sent())&&void 0!==t?t:null]}}))}))},e.prototype.getMessagesFromCache=function(e,t,n,r,s){return void 0===s&&(s=De),g(this,void 0,void 0,(function(){return y(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.getPollMessagesFromCache=function(e,t,n,r){return void 0===r&&(r=De),g(this,void 0,void 0,(function(){return y(this,(function(s){switch(s.label){case 0:return[4,this._messageCache.fetch({channelUrl:e,token:t,limit:r,filter:n,backward:!1,isPollOnly:!0})];case 1:return[2,s.sent()]}}))}))},e.prototype.getUnsentMessagesFromCache=function(e,t){return g(this,void 0,void 0,(function(){return y(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 g(this,void 0,void 0,(function(){return y(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 g(this,void 0,void 0,(function(){return y(this,(function(s){switch(s.label){case 0:return[4,this._messageCache.countBetween(e,t,new er({top:n,bottom:r}))];case 1:return[2,s.sent()]}}))}))},e.prototype.getMyGroupChannelChangeLogs=function(e,t,n){return void 0===n&&(n=ze.REQUEST_CHANNEL_CHANGELOGS),g(this,void 0,void 0,(function(){var r,a,o,u,c,l,h;return y(this,(function(d){switch(d.label){case 0:return r=i(i({},Zt),t),f((b("string",e)||b("number",e))&&$t(r)).throw(_.invalidParameters),a=new un(s({userId:this._sdkState.userId,ts:"number"==typeof e?e:null,token:"string"==typeof e?e:null,filter:r})),[4,this._requestQueue.send(a)];case 1:return o=d.sent(),u=o.as(cn),c=u.updatedChannels,l=u.deletedChannelUrls,h=u.hasMore,c.length>0&&this._dispatcher.dispatch(new We({channels:c,source:n})),l.length>0&&this._dispatcher.dispatch(new Be({channelUrls:l,source:n})),[2,{updatedChannels:c,deletedChannelUrls:l,hasMore:h,token:u.token}]}}))}))},e.prototype.getGroupChannelCount=function(e){return g(this,void 0,void 0,(function(){var t,n,r;return y(this,(function(s){switch(s.label){case 0:return t=i(i({},en),e),f(tn(t)).throw(_.invalidParameters),n=new _n({userId:this._sdkState.userId,filter:t}),[4,this._requestQueue.send(n)];case 1:return r=s.sent(),[2,r.as(mn).groupChannelCount]}}))}))},e.prototype.getUnreadItemCount=function(e){return g(this,void 0,void 0,(function(){var t,n,s,a,o,u,c,l,h,d,p,m,v,g,C,b;return y(this,(function(y){switch(y.label){case 0:return t=i(i({},nn),e),f(function(e){return E(Qt,e.keys)}(t)).throw(_.invalidParameters),n=j.of(this._iid),s=n.sdkState,a=n.requestQueue,o=new vn({userId:s.userId,filter:t}),[4,a.send(o)];case 1:return u=y.sent(),c=u.as(gn),l=c.groupChannelUnreadMentionCount,h=c.groupChannelUnreadMessageCount,d=c.groupChannelInvitationCount,p=c.superGroupChannelUnreadMentionCount,m=c.superGroupChannelUnreadMessageCount,v=c.superGroupChannelInvitationCount,g=c.nonSuperGroupChannelUnreadMentionCount,C=c.nonSuperGroupChannelUnreadMessageCount,b=c.nonSuperGroupChannelInvitationCount,[2,r({groupChannelUnreadMentionCount:l,groupChannelUnreadMessageCount:h,groupChannelInvitationCount:d,superGroupChannelUnreadMentionCount:p,superGroupChannelUnreadMessageCount:m,superGroupChannelInvitationCount:v,nonSuperGroupChannelUnreadMentionCount:g,nonSuperGroupChannelUnreadMessageCount:C,nonSuperGroupChannelInvitationCount:b})]}}))}))},e.prototype.getTotalUnreadChannelCount=function(){return g(this,void 0,void 0,(function(){var e,t,n,r,s;return y(this,(function(i){switch(i.label){case 0:return e=j.of(this._iid),t=e.sdkState,n=e.requestQueue,r=new yn({userId:t.userId}),[4,n.send(r)];case 1:return s=i.sent(),[2,s.as(Cn).unreadCount]}}))}))},e.prototype.getTotalUnreadMessageCount=function(e){return g(this,void 0,void 0,(function(){var t,n,r,s,o,u;return y(this,(function(c){switch(c.label){case 0:return t=i(i({},rn),e),f(function(e){return E("string",e.channelCustomTypesFilter,!0)&&a(Ht,e.superChannelFilter)}(t)).throw(_.invalidParameters),n=j.of(this._iid),r=n.sdkState,s=n.requestQueue,o=new En({userId:r.userId,filter:t}),[4,s.send(o)];case 1:return u=c.sent(),[2,u.as(bn).unreadCount]}}))}))},e.prototype.getTotalScheduledMessageCount=function(e){return void 0===e&&(e={}),g(this,void 0,void 0,(function(){var t,n,r,s;return y(this,(function(o){switch(o.label){case 0:return t=i(i({},sn),e),f(function(e){return b("string",e.channelUrl,!0)&&E(yt,e.scheduledStatus,!0)&&a(N,e.messageTypeFilter)}(t)).throw(_.invalidParameters),n=j.of(this._iid).requestQueue,r=new Mn(t),[4,n.send(r)];case 1:return s=o.sent(),[2,s.as(Nn).count]}}))}))},e.prototype.getSubscribedTotalUnreadMessageCount=function(){var e=j.of(this._iid).subscribedUnreadMessageCount;return e.all>=0?e.all:0},e.prototype.getSubscribedCustomTypeTotalUnreadMessageCount=function(){var e=0,t=j.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=j.of(this._iid).subscribedUnreadMessageCount.customTypes[e])&&void 0!==t?t:0},e.prototype.createChannel=function(e){return g(this,void 0,void 0,(function(){var t,n,r,s;return y(this,(function(a){switch(a.label){case 0:return t=i(i({},Jt),e),f(Xt(t)).throw(_.invalidParameters),t.isPublic||(t.accessCode=void 0),n=new Sn(i({userId:this._sdkState.userId},t)),[4,this._requestQueue.send(n)];case 1:return r=a.sent(),s=r.as(Tn).channel,[4,this.upsertChannelsToCache([s])];case 2:return a.sent(),[2,s]}}))}))},e.prototype.markAsReadAll=function(){return g(this,void 0,void 0,(function(){var e,t,n,r,s,i,a,o;return y(this,(function(u){switch(u.label){case 0:return e=Date.now(),f(e-this._markAsReadAllLastSentAt>=1e3).throw(_.markAsReadAllRateLimitExceeded),this._markAsReadAllLastSentAt=e,t=new An({userId:this._sdkState.userId}),[4,this._requestQueue.send(t)];case 1:u.sent(),n=this._groupChannelCache.channels;try{for(r=C(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.upsertChannelsToCache(n)]:[3,3];case 2:u.sent(),u.label=3;case 3:return[2]}}))}))},e.prototype.markAsReadWithChannelUrls=function(e){return g(this,void 0,void 0,(function(){var t,n,r,s,i,a,o,u,c;return y(this,(function(l){switch(l.label){case 0:return t=Date.now(),f(E("string",e)&&t-this._markAsReadAllLastSentAt>=1e3).throw(_.markAsReadAllRateLimitExceeded),this._markAsReadAllLastSentAt=t,n=new An({userId:this._sdkState.userId,channelUrls:e}),[4,this._requestQueue.send(n)];case 1:l.sent(),r=this._groupChannelCache.channels,s=[];try{for(i=C(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.upsertChannelsToCache(s)]:[3,3];case 2:l.sent(),l.label=3;case 3:return[2]}}))}))},e.prototype.markAsDelivered=function(e){return g(this,void 0,void 0,(function(){return y(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}();!function(e){e[e.IDLE=0]="IDLE",e[e.RUNNING=1]="RUNNING",e[e.END=2]="END"}(qn||(qn={}));var sr,ir=function(t){function n(e,n,r,s){var i=t.call(this)||this;return i._state=qn.IDLE,i._retryCount=0,i._retryLimit=3,i.priority=0,i._worker=n,i}return e(n,t),Object.defineProperty(n.prototype,"isIdle",{get:function(){return this._state===qn.IDLE},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"isRunning",{get:function(){return this._state===qn.RUNNING},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"isDone",{get:function(){return this._state===qn.END},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"retryCount",{get:function(){return this._retryCount},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"retryLimit",{get:function(){return this._retryLimit},enumerable:!1,configurable:!0}),n.prototype._run=function(e){return g(this,void 0,void 0,(function(){var t,n;return y(this,(function(r){switch(r.label){case 0:if(!this.isRunning)return[3,4];r.label=1;case 1:return r.trys.push([1,3,,4]),[4,this._worker(e)];case 2:return t=r.sent(),this._retryCount=0,this.dispatch("progress",t),t.hasNext?this._run(t.nextToken):this.end(),[3,4];case 3:return n=r.sent(),this.dispatch("error",n),this._retryCount0&&(r=n.map((function(e){return e.createdAt})),(null===(l=this._metadata)||void 0===l?void 0:(i=l.range).intersect.apply(i,m([],v(r),!1)))?this.extendRange(n):this._metadata={range:new er({top:Math.min.apply(Math,m([],v(r),!1)),bottom:Math.max.apply(Math,m([],v(r),!1))}),previousComplete:!1}),t.hasNext=n.length>=this._limit&&this._prevSyncLoopCount<1,this._metadata&&(t.nextToken=this._metadata.range.top,this._metadata.previousComplete=n.length0&&(r=n.map((function(e){return e.createdAt})),(null===(c=this._metadata)||void 0===c?void 0:(i=c.range).intersect.apply(i,m([],v(r),!1)))?this.extendRange(n):this._metadata={range:new er({top:Math.min.apply(Math,m([],v(r),!1)),bottom:Math.max.apply(Math,m([],v(r),!1))}),previousComplete:!1}),t.hasNext=n.length>=this._limit&&this._nextSyncLoopCount<1,this._metadata&&(t.nextToken=this._metadata.range.bottom),h.debug("message background next sync progress",t),[4,this.saveMetadata()];case 4:return l.sent(),[3,6];case 5:throw s=l.sent(),h.debug("message background next sync error",s),s;case 6:return[2,t]}}))}))})),this._connectionEventContext=l.on((function(e){if(e instanceof ee)if(e.stateType===te.CONNECTED)i.resume();else i.pause()}))}return e.of=function(t,n){return ur[t]||(ur[t]={}),ur[t][n.url]||(ur[t][n.url]=new e({_iid:t,channel:n})),ur[t][n.url].ref++,ur[t][n.url]},e.clear=function(e,t){ur[e]&&ur[e][t]&&(ur[e][t].close(),delete ur[e])},Object.defineProperty(e.prototype,"range",{get:function(){var e,t;return null!==(t=null===(e=this._metadata)||void 0===e?void 0:e.range)&&void 0!==t?t:new er({})},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,m([],v(e.map((function(e){return e.createdAt}))),!1))},e.prototype.extendRange=function(e){var t;this._metadata&&(t=this._metadata.range).extends.apply(t,m([],v(e.map((function(e){return e.createdAt}))),!1))},e.prototype.loadMetadata=function(e){return g(this,void 0,void 0,(function(){var t;return y(this,(function(n){switch(n.label){case 0:return this._metadata?[3,2]:[4,j.of(this._iid).cacheContext.preference.get(this._metadataKey)];case 1:(t=n.sent())?t.range.bottom0||r.length>0)&&this._metadata&&(this._metadata.token=i),o.debug("message changelog sync progress",e),[4,this.saveMetadata()];case 4:return c.sent(),[3,8];case 5:return a=c.sent(),o.debug("message changelog sync error",a),a instanceof _&&a.isInvalidTokenError?[4,this.clearMetadata()]:[3,7];case 6:c.sent(),c.label=7;case 7:throw a;case 8:return[2,e]}}))}))})),this._connectionEventContext=c.on((function(e){if(e instanceof ee)if(e.stateType===te.CONNECTED)r.resume();else r.pause()}))}return e.of=function(t,n){return lr[t]||(lr[t]={}),lr[t][n.url]||(lr[t][n.url]=new e({_iid:t,channel:n})),lr[t][n.url].ref++,lr[t][n.url]},e.clear=function(e,t){lr[e]&&lr[e][t]&&(lr[e][t].close(),delete lr[e])},e.prototype.loadMetadata=function(){return g(this,void 0,void 0,(function(){var e,t,n,r;return y(this,(function(s){switch(s.label){case 0:return this._metadata?[3,2]:(e=j.of(this._iid),t=e.cacheContext,n=e.firstConnectedAt,[4,t.preference.get(this._metadataKey)]);case 1:r=s.sent(),this._metadata={token:r?r.token:n},s.label=2;case 2:return[2,this._metadata]}}))}))},e.prototype.saveMetadata=function(){return g(this,void 0,void 0,(function(){return y(this,(function(e){switch(e.label){case 0:return this._metadata?[4,j.of(this._iid).cacheContext.preference.set(this._metadataKey,this._metadata)]:[3,2];case 1:return e.sent(),[2,!0];case 2:return[2,!1]}}))}))},e.prototype.clearMetadata=function(){return g(this,void 0,void 0,(function(){return y(this,(function(e){switch(e.label){case 0:return[4,j.of(this._iid).cacheContext.preference.remove(this._metadataKey)];case 1:return e.sent(),this._metadata=void 0,[2]}}))}))},e.prototype.resume=function(){var e=j.of(this._iid),t=e.logger;e.connectionManager.isConnected&&(t.debug("message changelog sync resume()"),this._sync.start(0))},e.prototype.pause=function(){var e=j.of(this._iid),t=e.logger;e.connectionManager.isConnected&&(t.debug("message changelog sync pause()"),this._sync.stop())},e.prototype.close=function(){this.ref--,this.ref<=0&&(this.ref=0,this.pause(),this._connectionEventContext.close(),delete lr[this._iid][this._channel.url])},e}(),dr={},pr=function(){function e(e){var t=e._iid,n=e.channel,r=e.hasPollMessage,s=this;this.ref=0,this._iid=t,this._channel=n;var i,a,o=j.of(this._iid),u=o.logger,c=o.sdkState,l=o.dispatcher;this._metadataKey=(i=c.userId,a=n.url,"sendbird:".concat(i,"@groupchannel/").concat(a,"/poll/changelogs.meta"));var h=function(e,t){return"sendbird:".concat(e,"@groupchannel/").concat(t,"/poll/changelogs")}(c.userId,this._channel.url);this._sync=new ir(h,(function(){return g(s,void 0,void 0,(function(){var e,t,n,s,i,a,o,c;return y(this,(function(l){switch(l.label){case 0:return e={hasNext:!0,nextToken:0},[4,this.loadMetadata()];case 1:return l.sent(),u.debug("poll changelog sync from",null===(c=this._metadata)||void 0===c?void 0:c.token),(t=!this._metadata||!this._metadata.token)?[4,r()]:[3,3];case 2:t=!l.sent(),l.label=3;case 3:if(t)return[2,{hasNext:!1,nextToken:0}];this._metadata||(n=j.of(this._iid).firstConnectedAt,this._metadata={token:n}),l.label=4;case 4:return l.trys.push([4,7,,10]),[4,Rt.of(this._iid).getPollChangeLogs(this._channel.url,this._channel.channelType,this._metadata.token)];case 5:return s=l.sent(),i=s.hasMore,a=s.token,e.hasNext=i,e.nextToken=a,this._metadata.token=a,u.debug("poll changelog sync progress",e),[4,this.saveMetadata()];case 6:return l.sent(),[3,10];case 7:return o=l.sent(),u.debug("poll changelog sync error",o),o instanceof _&&o.isInvalidTokenError?[4,this.clearMetadata()]:[3,9];case 8:l.sent(),l.label=9;case 9:throw o;case 10:return[2,e]}}))}))})),this._connectionEventContext=l.on((function(e){if(e instanceof ee)if(e.stateType===te.CONNECTED)s.resume();else s.pause()}))}return e.of=function(t,n,r){return dr[t]||(dr[t]={}),dr[t][n.url]||(dr[t][n.url]=new e({_iid:t,channel:n,hasPollMessage:r})),dr[t][n.url].ref++,dr[t][n.url]},e.prototype.loadMetadata=function(){return g(this,void 0,void 0,(function(){var e;return y(this,(function(t){switch(t.label){case 0:return this._metadata?[3,2]:[4,j.of(this._iid).cacheContext.preference.get(this._metadataKey)];case 1:e=t.sent(),this._metadata=e?{token:e.token}:void 0,t.label=2;case 2:return[2]}}))}))},e.prototype.saveMetadata=function(){return g(this,void 0,void 0,(function(){return y(this,(function(e){switch(e.label){case 0:return this._metadata?[4,j.of(this._iid).cacheContext.preference.set(this._metadataKey,this._metadata)]:[3,2];case 1:e.sent(),e.label=2;case 2:return[2]}}))}))},e.prototype.clearMetadata=function(){return g(this,void 0,void 0,(function(){return y(this,(function(e){switch(e.label){case 0:return[4,j.of(this._iid).cacheContext.preference.remove(this._metadataKey)];case 1:return e.sent(),this._metadata=void 0,[2]}}))}))},e.prototype.resume=function(){j.of(this._iid).logger.debug("poll changelog sync resume()"),this._sync.start(0)},e.prototype.pause=function(){j.of(this._iid).logger.debug("poll changelog sync pause()"),this._sync.stop()},e.prototype.close=function(){this.ref--,this.ref<=0&&(this.ref=0,this.pause(),this._connectionEventContext.close(),delete dr[this._iid][this._channel.url])},e}(),fr=function(t){function n(e){var n,s,i,a,o,u,c=this;return(c=t.call(this)||this).method=D.GET,c.path="".concat(re(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,include_poll_details:!0,checking_continuous_messages:e.checkingContinuousMessages}),c}return e(n,t),n}(R),_r=function(t){function n(e,n){var r,s,i,a,o,u,c=this;return(c=t.call(this,e,n)||this).isHugeGap=n.is_huge_gap,c.prevMessages=(null!==(r=n.prev_messages)&&void 0!==r?r:[]).map((function(t){return bt(e,t)})),c.prevHasMore=null!==(s=n.prev_hasmore)&&void 0!==s&&s,c.isContinuousPrevMessages=null!==(i=n.is_continuous_prev_messages)&&void 0!==i&&i,c.nextMessages=(null!==(a=n.next_messages)&&void 0!==a?a:[]).map((function(t){return bt(e,t)})),c.nextHasmore=null!==(o=n.next_hasmore)&&void 0!==o&&o,c.isContinuousNextMessages=null!==(u=n.is_continuous_next_messages)&&void 0!==u&&u,c}return e(n,t),n}(F),mr=function(e,t){return e.findIndex((function(e){return e.isIdentical(t)}))},vr=function(e,t,n){if(e.length>0){for(var r=mr(e,t),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,oldPosition:r};s=a+1,a=Math.floor((s+i)/2)}}return{place:gr(e[a],t,n)>=0?a:a+1,oldPosition:r}}return{place:e.length,oldPosition:-1}},gr=function(e,t,n){switch(n){case Ge.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 Ge.CHRONOLOGICAL:return t.createdAt-e.createdAt;case Ge.CHANNEL_NAME_ALPHABETICAL:var r=e.name.localeCompare(t.name);return 0===r?e.createdAt-t.createdAt:r;default:return 0}},yr=function(e,t){return t instanceof Ct?e.findIndex((function(e){return e instanceof Ct&&t.isIdentical(e)})):e.findIndex((function(e){return e.isIdentical(t)}))},Cr=function(e,t){return e.findIndex((function(e){return e.messageId===t}))},Er=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},br=6e5;!function(e){e.CACHE_AND_REPLACE_BY_API="cache_and_replace_by_api"}(sr||(sr={}));var Mr,Nr,Ur,Sr=function(){function e(){}return e.prototype._invokeResponse=function(e,t,n){var r=this;Y((function(){return g(r,void 0,void 0,(function(){return y(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}(),Tr=function(){function e(e,t){var n=t.channel,r=t.filter,s=t.startingPoint,i=t.limit,a=this;this._messages=[],this._unsentMessages=[],this._iid=e,this._key="mc-".concat(oe()),this.filter=null!=r?r:new Je,this._channel=n,this._syncRange=new er({}),this._hasPrevious=!0,this._hasNext=!0,this._startingPoint="number"==typeof s?s:Date.now()+br,this._limit=i||De;var o=rr.of(this._iid);o.subscribeGroupChannelEvent(this._key,{onUpdate:function(e,t,n){var r=mr(e,a._channel);if(r>=0){switch(a._channel=e[r],t){case ze.EVENT_CHANNEL_UPDATED:var s=!1;for(var i in a._messages){if(a._messages[i].createdAt>=a._channel.messageOffsetTimestamp){s=!0;var o=parseInt(i);if(o>0){var u=a._messages.splice(0,o);a._removeMessagesFromView(u.map((function(e){return e.messageId})),J.EVENT_MESSAGE_OFFSET_UPDATED)}break}}!s&&a._messages.length>0&&a._removeMessagesFromView(a._messages.map((function(e){return e.messageId})),J.EVENT_MESSAGE_OFFSET_UPDATED);break;case ze.EVENT_CHANNEL_UNMUTED:var c=n;j.of(a._iid).sdkState.userId===c&&a._clearCheckMyMutedTimer();break;case ze.EVENT_CHANNEL_MUTED:var l=n;j.of(a._iid).sdkState.userId===l&&-1!==a.channel._myMutedRemainingTime&&a._startCheckMyMutedTimer(a.channel._myMutedRemainingTime);break;case ze.EVENT_CHANNEL_LEFT:a.channel.isPublic&&a._clearCheckMyMutedTimer()}Y((function(){return g(a,void 0,void 0,(function(){var e,n;return y(this,(function(r){return e=new ar(t),tt(t)&&(null===(n=this._handler)||void 0===n?void 0:n.onChannelUpdated)&&this._handler.onChannelUpdated(e,this.channel),[2]}))}))}))}},onRemove:function(e,t){e.indexOf(a.channel.url)>=0&&(a._clearCheckMyMutedTimer(),Y((function(){return g(a,void 0,void 0,(function(){var e,n;return y(this,(function(r){return e=new ar(t),(null===(n=this._handler)||void 0===n?void 0:n.onChannelDeleted)&&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=C(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(se(t)){if(s.length>0)switch(t){case J.EVENT_MESSAGE_SENT_FAILED:case J.EVENT_MESSAGE_SENT_SUCCESS:case J.EVENT_MESSAGE_UPDATED:case J.EVENT_MESSAGE_THREADINFO_UPDATED:case J.EVENT_MESSAGE_REACTION_UPDATED:case J.SYNC_MESSAGE_CHANGELOGS:a._updateMessagesToView(s,t);break;case J.EVENT_MESSAGE_SENT_PENDING:a._addMessagesToView(s,t);break;case J.EVENT_MESSAGE_RECEIVED:a.hasNext||a._addMessagesToView(s,t);break;case J.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)},onPollChangeLogUpdate:function(e,t){a._updatePollsToView(e,t)},onPollUpdate:function(e,t){a._applyPollUpdateEventToView(e,t)},onPollVote:function(e,t){a._applyPollVoteEventToView(e,t)}});var u=j.of(this._iid),c=u.cacheContext,l=u.dispatcher,h=u.logger;this._channel._updateMessageCollectionLastAccessedAt(),l.dispatch(new We({channels:[this._channel],source:ze.CHANNEL_LASTACCESSEDAT_UPDATED})),!this._channel.isSuper&&c.localCacheEnabled&&(this._backgroundSync=cr.of(this._iid,this._channel),this._backgroundSync.resume(this._startingPoint)),this._changelogSync=hr.of(this._iid,this._channel),this._changelogSync.resume(),this._pollChangelogSync=pr.of(this._iid,this._channel,this._hasPollMessage.bind(this)),this._pollChangelogSync.resume(),this._prevFill=new ir(this._key,(function(e){return g(a,void 0,void 0,(function(){var t,n,r,s,i;return y(this,(function(a){switch(a.label){case 0:return[4,this._getRemoteMessages(e,{prevLimit:this._limit,source:J.SYNC_MESSAGE_FILL,checkingContinuousMessages:c.localCacheEnabled})];case 1:return t=a.sent(),n=t.messages,r=t.isContinuousMessages,n.length>0?(s=Math.min.apply(Math,m([],v(n.map((function(e){return e.createdAt}))),!1)),this._syncRange.extends(s),r&&(null===(i=this._backgroundSync)||void 0===i||i.range.extends(s)),[2,{hasNext:n.length>=this._limit&&this.viewTop0?(s=Math.max.apply(Math,m([],v(n.map((function(e){return e.createdAt}))),!1)),this._syncRange.extends(s),r&&(null===(i=this._backgroundSync)||void 0===i||i.range.extends(s)),[2,{hasNext:!(n.length>=this._limit&&this._hasNext)||this.viewBottom>s,nextToken:this._syncRange.bottom}]):[2,{hasNext:!1,nextToken:0}]}}))}))})),this._connectionEventContext=l.on((function(e){if(e instanceof ee)switch(e.stateType){case te.CONNECTED:a._refreshChannel(ze.SYNC_CHANNEL_CHANGELOGS),U((function(){return g(a,void 0,void 0,(function(){var e;return y(this,(function(t){switch(t.label){case 0:return[4,this.channel.getMyMutedInfo()];case 1:return(e=t.sent()).isMuted&&-1!==e.remainingDuration&&this._startCheckMyMutedTimer(e.remainingDuration),[2]}}))}))})),h.debug("check huge gap"),a._checkHugeGap();break;case te.LOGOUT:a.dispose();break;default:a._clearCheckMyMutedTimer(),a._prevFill.stop(),a._nextFill.stop()}})),j.of(this._iid).statLogCollector.put(new ie({type:ae.FEATURE_LOCALCACHE,data:{use_local_cache:c.localCacheEnabled,collection_interface:{message:!0}}}))}return Object.defineProperty(e.prototype,"channel",{get:function(){return this._channel},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"succeededMessages",{get:function(){return m([],v(this._messages),!1)},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"failedMessages",{get:function(){return this._unsentMessages.filter((function(e){return e.sendingStatus===ue.FAILED}))},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"pendingMessages",{get:function(){return this._unsentMessages.filter((function(e){return e.sendingStatus===ue.PENDING}))},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"hasPrevious",{get:function(){return this._hasPrevious},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"hasNext",{get:function(){return this._hasNext},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"viewTop",{get:function(){return Math.min.apply(Math,m(m([],v(this._messages.map((function(e){return e.createdAt}))),!1),[Number.MAX_SAFE_INTEGER],!1))},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"viewBottom",{get:function(){return Math.max.apply(Math,m(m([],v(this._messages.map((function(e){return e.createdAt}))),!1),[0],!1))},enumerable:!1,configurable:!0}),e.prototype.setMessageCollectionHandler=function(e){this._handler=e},e.prototype._filterUnderOffsetMessage=function(e){return e},e.prototype._addMessagesToView=function(e,t){var n,r,s=this,i=this._filterUnderOffsetMessage(e),a=[],o=[];try{for(var u=C(i),c=u.next();!c.done;c=u.next()){var l=c.value;if(t===J.SYNC_MESSAGE_FILL){if(l.messageId>0){if((f=yr(this._messages,l))<0){yr(this._unsentMessages,l)<0&&a.push(l);var h=Er(this._messages,l);this._messages.splice(h,0,l)}}else if(l instanceof Ct){(f=yr(this._unsentMessages,l))<0&&yr(this._messages,l)<0&&(this._unsentMessages.push(l),a.push(l))}}else if(l.messageId>0){if((f=yr(this._messages,l))<0){var d=yr(this._unsentMessages,l);d<0?a.push(l):(this._unsentMessages.splice(d,1),o.push(l));h=Er(this._messages,l);this._messages.splice(h,0,l)}else o.push(l),this._messages[f]=l;if(l.updatedAt>0){var p=this._updateChildMessagesInView(l);o.push.apply(o,m([],v(p),!1))}}else if(l instanceof Ct){var f;(f=yr(this._unsentMessages,l))<0?yr(this._messages,l)<0&&(this._unsentMessages.push(l),a.push(l)):(o.push(l),this._unsentMessages[f]=l)}}}catch(e){n={error:e}}finally{try{c&&!c.done&&(r=u.return)&&r.call(u)}finally{if(n)throw n.error}}se(t)&&Y((function(){return g(s,void 0,void 0,(function(){var e,n,r;return y(this,(function(s){return e=new or(t),a.length>0&&(null===(n=this._handler)||void 0===n||n.onMessagesAdded(e,this.channel,a)),o.length>0&&(null===(r=this._handler)||void 0===r||r.onMessagesUpdated(e,this.channel,o)),[2]}))}))}))},e.prototype._updateChildMessagesInView=function(e){var t=[];return this._messages.forEach((function(n){n.applyParentMessage(e)&&t.push(n)})),t},e.prototype._updatePollsToView=function(e,t){var n,r,s=this,i=[];try{for(var a=C(e),o=a.next();!o.done;o=a.next()){var u=o.value,c=Cr(this._messages,u.messageId);if(c>=0){var l=this._messages[c];l&&l.applyPoll(u),i.push(l)}}}catch(e){n={error:e}}finally{try{o&&!o.done&&(r=a.return)&&r.call(a)}finally{if(n)throw n.error}}return i.length>0&&se(t)&&Y((function(){return g(s,void 0,void 0,(function(){var e,n;return y(this,(function(r){return e=new or(t),i.length>0&&(null===(n=this._handler)||void 0===n||n.onMessagesUpdated(e,this.channel,i)),[2]}))}))})),i},e.prototype._applyPollUpdateEventToView=function(e,t){var n=this,r=Cr(this._messages,e.messageId);if(r>=0){var s=this._messages[r];s&&s.isUserMessage()&&s.poll&&s.poll.applyPollUpdateEvent(e)&&se(t)&&Y((function(){return g(n,void 0,void 0,(function(){var e,n;return y(this,(function(r){return e=new or(t),null===(n=this._handler)||void 0===n||n.onMessagesUpdated(e,this.channel,[s]),[2]}))}))}))}},e.prototype._applyPollVoteEventToView=function(e,t){var n=this,r=Cr(this._messages,e.messageId);if(r>=0){var s=this._messages[r];s&&s.isUserMessage()&&s.poll&&s.poll.applyPollVoteEvent(e)&&se(t)&&Y((function(){return g(n,void 0,void 0,(function(){var e,n;return y(this,(function(r){return e=new or(t),null===(n=this._handler)||void 0===n||n.onMessagesUpdated(e,this.channel,[s]),[2]}))}))}))}},e.prototype._updateMessagesToView=function(e,t){var n,r,s=this,i=[],a=[];try{for(var o=C(e),u=o.next();!u.done;u=o.next()){var c,l=u.value;if(l.messageId>0)if((c=yr(this._messages,l))>=0)i.push(l),this._messages[c]=l;else{var h=yr(this._unsentMessages,l);if(h>=0){var d=this._unsentMessages.splice(h,1);if(this.hasNext&&d.length>0)a.push(d[0]);else{i.push(l);var p=Er(this._messages,l);this._messages.splice(p,0,l)}}}else if(l instanceof Ct)(c=yr(this._unsentMessages,l))>=0&&(i.push(l),this._unsentMessages[c]=l)}}catch(e){n={error:e}}finally{try{u&&!u.done&&(r=o.return)&&r.call(o)}finally{if(n)throw n.error}}return se(t)&&Y((function(){return g(s,void 0,void 0,(function(){var e,n,r;return y(this,(function(s){return e=new or(t),i.length>0?null===(n=this._handler)||void 0===n||n.onMessagesUpdated(e,this.channel,i):a.length>0&&(null===(r=this._handler)||void 0===r||r.onMessagesDeleted(e,this.channel,[],a)),[2]}))}))})),i},e.prototype._removeMessagesFromView=function(e,t){var n,r,s=this,i=[],a=[],o=function(e){var t=u._messages.findIndex((function(t){return t.messageId===e}));if(t>=0){var n=u._messages[t];i.push(n.messageId),a.push(n),u._messages.splice(t,1)}},u=this;try{for(var c=C(e),l=c.next();!l.done;l=c.next()){o(l.value)}}catch(e){n={error:e}}finally{try{l&&!l.done&&(r=c.return)&&r.call(c)}finally{if(n)throw n.error}}return se(t)&&a.length>0&&Y((function(){return g(s,void 0,void 0,(function(){var e,n;return y(this,(function(r){return e=new or(t),null===(n=this._handler)||void 0===n||n.onMessagesDeleted(e,this.channel,i,a),[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 g(this,void 0,void 0,(function(){var t,n,s,a,o,u,c;return y(this,(function(l){switch(l.label){case 0:return t=rr.of(this._iid),r>0?[4,t.getMessagesFromCache(this._channel.url,e,"prev",this.filter,r)]:[3,2];case 1:return s=l.sent(),[3,3];case 2:s=[],l.label=3;case 3:return n=s,i>0?[4,t.getMessagesFromCache(this._channel.url,e,"next",this.filter,i)]:[3,5];case 4:return o=l.sent(),[3,6];case 5:o=[],l.label=6;case 6:if(a=o,n.length>0&&a.length>0)for(c in u=n.map((function(e){return e.messageId})),a)if(u.includes(a[c].messageId)){a.splice(parseInt(c),1);break}return[2,m(m([],v(n),!1),v(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,a=t.nextLimit,o=void 0===a?0:a,u=t.source,c=void 0===u?J.REQUEST_MESSAGE:u,l=t.reverse,h=void 0!==l&&l,d=t.checkingContinuousMessages,p=void 0!==d&&d;return g(this,void 0,void 0,(function(){var t,n;return y(this,(function(a){switch(a.label){case 0:return t=St.of(this._iid),r>0||o>0?[4,t._getMessagesByTimestampForCollection(this._channel.url,this._channel.channelType,e,s(i(i({},this.filter),{isInclusive:!0,reverse:h,prevResultSize:r,nextResultSize:o,includeMetaArray:!0,includeReactions:!0,includeThreadInfo:!0,includeParentMessageInfo:!0})),c,p)]:[3,2];case 1:return n=a.sent(),[3,3];case 2:n={messages:[],isContinuousMessages:!1},a.label=3;case 3:return[2,n]}}))}))},e.prototype._checkHugeGap=function(){var e;return g(this,void 0,void 0,(function(){var t,n,r,s,a,o,u,c,l,h,d,p,f,C,E,b,M,N,U,S,T=this;return y(this,(function(A){switch(A.label){case 0:return this._messages.length>0?(t=this._syncRange.top,n=this.viewTop,r=this._syncRange.bottom,s=this.hasNext?this.viewBottom:Number.MAX_SAFE_INTEGER,[4,(a=rr.of(this._iid)).getCachedMessageCountBetween(this._channel.url,this.filter,n,t)]):[3,4];case 1:return o=A.sent(),[4,a.getCachedMessageCountBetween(this._channel.url,this.filter,r,s)];case 2:return u=A.sent(),[4,ce((function(){return g(T,void 0,void 0,(function(){var e,a,c,l,h,d,p,f,_,C,E,b,M,N,U,S,T,A,I,w,D,k=this;return y(this,(function(P){switch(P.label){case 0:return e=j.of(this._iid),a=e.dispatcher,c=e.requestQueue,l=e.cacheContext,h=new fr(i({channelUrl:this._channel.url,channelType:this._channel.channelType,prevStart:n,prevEnd:t,prevCount:o,nextStart:r,nextEnd:s,nextCount:u,checkingContinuousMessages:l.localCacheEnabled},this.filter)),[4,c.send(h)];case 1:return d=P.sent(),p=d.as(_r),f=p.isHugeGap,_=p.prevMessages,C=void 0===_?[]:_,E=p.prevHasMore,b=p.isContinuousPrevMessages,M=p.nextMessages,N=void 0===M?[]:M,U=p.nextHasmore,S=p.isContinuousNextMessages,f?Y((function(){return g(k,void 0,void 0,(function(){var e;return y(this,(function(t){return null===(e=this._handler)||void 0===e||e.onHugeGapDetected(),[2]}))}))})):(this._hasPrevious=E,this._hasNext=U,T=this.viewTop,A=this.viewBottom,I=Math.min.apply(Math,m([Number.MAX_SAFE_INTEGER,T],v(C.map((function(e){return e.createdAt}))),!1)),w=Math.max.apply(Math,m([0,A],v(N.map((function(e){return e.createdAt}))),!1)),a.dispatch(new L({messages:C,source:J.SYNC_MESSAGE_FILL})),a.dispatch(new L({messages:N,source:J.SYNC_MESSAGE_FILL})),this._syncRange.extends(I,w),(b||S)&&(null===(D=this._backgroundSync)||void 0===D||D.range.extends(I,w)),Tw&&this._nextFill.start(w)),[2]}}))}))}),1)];case 3:return A.sent(),[3,8];case 4:c=j.of(this._iid).cacheContext,l=Math.floor(this._limit/2),h=Date.now(),A.label=5;case 5:return A.trys.push([5,7,,8]),[4,this._getRemoteMessages(h,{prevLimit:l,nextLimit:l,source:J.SYNC_MESSAGE_FILL,checkingContinuousMessages:c.localCacheEnabled})];case 6:if(d=A.sent(),p=d.messages,f=d.isContinuousMessages,p.length>0){for(C=p.map((function(e){return e.createdAt})),E=0,b=0,M=0;M=h&&b++;this._hasPrevious=E>=l,this._hasNext=b>=l,(S=this._syncRange).extends.apply(S,m([],v(C),!1)),f&&(null===(e=this._backgroundSync)||void 0===e||e.range.extends(this._syncRange.top,this._syncRange.bottom)),this._addMessagesToView(p,J.SYNC_MESSAGE_FILL)}else this._hasPrevious=!1,this._hasNext=!1;return[3,8];case 7:return(U=A.sent())instanceof _&&U.code===X.NOT_FOUND_IN_DATABASE&&(this._hasPrevious=!1,this._hasNext=!1),[3,8];case 8:return[2]}}))}))},e.prototype._loadUnsentMessages=function(){return g(this,void 0,void 0,(function(){var e,t;return y(this,(function(n){switch(n.label){case 0:return e=rr.of(this._iid),t=this,[4,e.getUnsentMessagesFromCache(this._channel.url,this.filter)];case 1:return t._unsentMessages=n.sent(),[2]}}))}))},e.prototype._hasPollMessage=function(){return g(this,void 0,void 0,(function(){return y(this,(function(e){switch(e.label){case 0:return[4,rr.of(this._iid).getPollMessagesFromCache(this._channel.url,Date.now()+br,this.filter,1)];case 1:return e.sent().length>0?[2,!0]:[2,!1]}}))}))},e.prototype._refreshChannel=function(e){rr.of(this._iid).refreshChannel(this.channel.url,!0,e)},e.prototype._startCheckMyMutedTimer=function(e){var t=this;this._clearCheckMyMutedTimer(),this._checkMyMutedStateTimer=setTimeout((function(){return g(t,void 0,void 0,(function(){var e,t,n,r;return y(this,(function(s){switch(s.label){case 0:this._checkMyMutedStateTimer=void 0,e=!0,s.label=1;case 1:return s.trys.push([1,3,4,5]),[4,this._channel.getMyMutedInfo()];case 2:return t=s.sent(),e=!t.isMuted,[3,5];case 3:return s.sent(),e=!0,[3,5];case 4:return e&&(this.channel.myMutedState=ns.UNMUTED,n=new ar(ze.EVENT_CHANNEL_UNMUTED),null===(r=this._handler)||void 0===r||r.onChannelUpdated(n,this.channel)),[7];case 5:return[2]}}))}))}),e+1e3)},e.prototype._clearCheckMyMutedTimer=function(){this._checkMyMutedStateTimer&&(clearTimeout(this._checkMyMutedStateTimer),this._checkMyMutedStateTimer=void 0)},e.prototype.initialize=function(e){var t=this,n=new Sr;this._messages=[],this._unsentMessages=[],this._syncRange=new er({}),this._hasNext=!0,this._hasPrevious=!0,this._refreshChannel(ze.REFRESH_CHANNEL),U((function(){return g(t,void 0,void 0,(function(){var e;return y(this,(function(t){switch(t.label){case 0:return[4,this.channel.getMyMutedInfo()];case 1:return(e=t.sent()).isMuted&&-1!==e.remainingDuration&&this._startCheckMyMutedTimer(e.remainingDuration),[2]}}))}))}));var r=Math.floor(this._limit/2);if(e===sr.CACHE_AND_REPLACE_BY_API)this._getLocalMessages(this._startingPoint,{prevLimit:r,nextLimit:r}).then((function(e){return g(t,void 0,void 0,(function(){var t;return y(this,(function(r){switch(r.label){case 0:return t=this._filterUnderOffsetMessage(e),this._addMessagesToView(t,J.REQUEST_MESSAGE),[4,this._loadUnsentMessages()];case 1:return r.sent(),n._invokeResponse("local",null,t),[2]}}))}))})).catch((function(e){if(K(e))throw e;n._invokeResponse("local",e,null)})).finally((function(){var e=j.of(t._iid).cacheContext;t._getRemoteMessages(t._startingPoint,{prevLimit:r,nextLimit:r,reverse:!0,checkingContinuousMessages:e.localCacheEnabled}).then((function(e){var s,i,a=e.messages,o=e.isContinuousMessages;t._messages=[];var u=t._filterUnderOffsetMessage(a);if(u.length>0){for(var c=u.map((function(e){return e.createdAt})),l=0,h=0,d=0;d=t._startingPoint&&h++}t._hasPrevious=l>=r,t._hasNext=h>=r,(s=t._syncRange).extends.apply(s,m([],v(u.map((function(e){return e.createdAt}))),!1)),o&&(null===(i=t._backgroundSync)||void 0===i||i.range.extends(t._syncRange.top,t._syncRange.bottom)),t._addMessagesToView(u,J.REQUEST_MESSAGE)}else t._hasPrevious=!1,t._hasNext=!1;n._invokeResponse("remote",null,u)})).catch((function(e){if(K(e))throw e;n._invokeResponse("remote",e,null)}))}));var s=j.of(this._iid),i=s.cacheContext;return s.statLogCollector.put(new ie({type:ae.FEATURE_LOCALCACHE,data:{use_local_cache:i.localCacheEnabled,collection_interface:{message_init_policy:e}}})),n},e.prototype.loadPrevious=function(){return g(this,void 0,void 0,(function(){var e,t,n,r=this;return y(this,(function(s){switch(s.label){case 0:return this._hasPrevious?(e=this.viewTop,t=[],[4,U((function(){return g(r,void 0,void 0,(function(){var n;return y(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 s.sent(),0!==t.length&&this._backgroundSync&&this._backgroundSync.isWrappingMessages(t)?[3,3]:[4,U((function(){return g(r,void 0,void 0,(function(){var n,r,s,i,a;return y(this,(function(o){switch(o.label){case 0:return n=j.of(this._iid).cacheContext,[4,this._getRemoteMessages(e,{prevLimit:this._limit,checkingContinuousMessages:n.localCacheEnabled})];case 1:return r=o.sent(),t=this._filterUnderOffsetMessage(r.messages),this._hasPrevious=t.length>=this._limit,t.length>0&&((s=this._syncRange).extends.apply(s,m([],v(t.map((function(e){return e.createdAt}))),!1)),(null===(i=this._backgroundSync)||void 0===i?void 0:i.range.overlap(this._syncRange))&&r.isContinuousMessages&&(null===(a=this._backgroundSync)||void 0===a||a.range.extends(this._syncRange.top))),[2]}}))}))}))];case 2:return s.sent(),this._addMessagesToView(t,J.REQUEST_MESSAGE),[3,4];case 3:this._hasPrevious=t.length>=this._limit,t.length>0&&((n=this._syncRange).extends.apply(n,m([],v(t.map((function(e){return e.createdAt}))),!1)),this._addMessagesToView(t,J.REQUEST_MESSAGE)),s.label=4;case 4:return[2,t];case 5:return[2,[]]}}))}))},e.prototype.loadNext=function(){var e;return g(this,void 0,void 0,(function(){var t,n,r,s=this;return y(this,(function(i){switch(i.label){case 0:return this._hasNext?(t=this.viewBottom,n=[],[4,U((function(){return g(s,void 0,void 0,(function(){var e;return y(this,(function(r){switch(r.label){case 0:return e=this._filterUnderOffsetMessage,[4,this._getLocalMessages(t,{nextLimit:this._limit})];case 1:return n=e.apply(this,[r.sent()]),[2]}}))}))}))]):[2,[]];case 1:return i.sent(),0!==n.length&&(null===(e=this._backgroundSync)||void 0===e?void 0:e.isWrappingMessages(n))?[3,3]:[4,U((function(){return g(s,void 0,void 0,(function(){var e,r,s,i,a;return y(this,(function(o){switch(o.label){case 0:return e=j.of(this._iid).cacheContext,[4,this._getRemoteMessages(t,{nextLimit:this._limit,checkingContinuousMessages:e.localCacheEnabled})];case 1:return r=o.sent(),n=this._filterUnderOffsetMessage(r.messages),this._hasNext=n.length>=this._limit,n.length>0&&((s=this._syncRange).extends.apply(s,m([],v(n.map((function(e){return e.createdAt}))),!1)),(null===(i=this._backgroundSync)||void 0===i?void 0:i.range.overlap(this._syncRange))&&r.isContinuousMessages&&(null===(a=this._backgroundSync)||void 0===a||a.range.extends(this._syncRange.bottom))),[2]}}))}))}))];case 2:return i.sent(),this._addMessagesToView(n,J.REQUEST_MESSAGE),[3,4];case 3:this._hasNext=n.length>=this._limit,n.length>0&&((r=this._syncRange).extends.apply(r,m([],v(n.map((function(e){return e.createdAt}))),!1)),this._addMessagesToView(n,J.REQUEST_MESSAGE)),i.label=4;case 4:return[2,n]}}))}))},e.prototype.removeFailedMessage=function(e){return g(this,void 0,void 0,(function(){var t;return y(this,(function(n){switch(n.label){case 0:return[4,rr.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,t,n,r=j.of(this._iid),s=r.cacheContext,i=r.dispatcher;this._clearCheckMyMutedTimer(),this._channel._updateMessageCollectionLastAccessedAt(),i.dispatch(new We({channels:[this._channel],source:ze.CHANNEL_LASTACCESSEDAT_UPDATED})),s.localCacheEnabled&&(this._prevFill.stop(),this._nextFill.stop()),null===(e=this._backgroundSync)||void 0===e||e.close(),null===(t=this._changelogSync)||void 0===t||t.close(),null===(n=this._pollChangelogSync)||void 0===n||n.close();var a=rr.of(this._iid);a.unsubscribeGroupChannelEvent(this._key),a.unsubscribeMessageEvent(this._key),this._connectionEventContext&&this._connectionEventContext.close()},e}(),Ar={coverUrl:void 0,coverImage:void 0,isDistinct:void 0,isPublic:void 0,isDiscoverable:void 0,accessCode:void 0,name:void 0,data:void 0,customType:void 0,operatorUserIds:void 0,messageSurvivalSeconds:void 0},Ir=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=D.GET,n.path="".concat(O,"/").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}(R),wr=function(t){function n(e,n){var r=t.call(this,e,n)||this;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 zt(e,t)}))),r}return e(n,t),n}(F);!function(e){e.ALL="all",e.MUTED="muted",e.UNMUTED="unmuted"}(Mr||(Mr={})),function(e){e.MEMBER_NICKNAME_ALPHABETICAL="member_nickname_alphabetical",e.OPERATOR_THEN_MEMBER_ALPHABETICAL="operator_then_member_alphabetical"}(Nr||(Nr={})),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"}(Ur||(Ur={}));var Lr=function(t){function n(e,n,r){var s,i,a,o,c=this;return(c=t.call(this,e,n,u.GROUP,r)||this).mutedMemberFilter=Mr.ALL,c.memberStateFilter=Ur.ALL,c.nicknameStartsWithFilter=null,c.operatorFilter=qt.ALL,c.order=Nr.MEMBER_NICKNAME_ALPHABETICAL,c.mutedMemberFilter=null!==(s=r.mutedMemberFilter)&&void 0!==s?s:Mr.ALL,c.memberStateFilter=null!==(i=r.memberStateFilter)&&void 0!==i?i:Ur.ALL,c.nicknameStartsWithFilter=null!==(a=r.nicknameStartsWithFilter)&&void 0!==a?a:null,c.order=null!==(o=r.order)&&void 0!==o?o:Nr.MEMBER_NICKNAME_ALPHABETICAL,c}return e(n,t),n.prototype._validate=function(){return t.prototype._validate.call(this)&&a(Mr,this.mutedMemberFilter)&&a(Ur,this.memberStateFilter)&&(b("string",this.nicknameStartsWithFilter)||null===this.nicknameStartsWithFilter)&&a(qt,this.operatorFilter)&&a(Nr,this.order)},n.prototype.next=function(){return g(this,void 0,void 0,(function(){var e,t,n,r,a,o;return y(this,(function(u){switch(u.label){case 0:return this._validate()?this._isLoading?[3,3]:this._hasNext?(this._isLoading=!0,e=j.of(this._iid).requestQueue,t=new Ir(s(i(i({},this),{token:this._token}))),[4,e.send(t)]):[3,2]:[3,5];case 1:return n=u.sent(),r=n.as(wr),a=r.members,o=r.token,this._token=o,this._hasNext=!!o,this._isLoading=!1,[2,a];case 2:return[2,[]];case 3:throw _.queryInProgress;case 4:return[3,6];case 5:throw _.invalidParameters;case 6:return[2]}}))}))},n}(le),Dr=function(t){function n(e){var n=this,r=e.channelUrl,s=e.userId,i=e.accessCode;return(n=t.call(this)||this).method=D.PUT,n.path="".concat(O,"/").concat(encodeURIComponent(r),"/accept"),n.params={user_id:s,access_code:i},n}return e(n,t),n}(R),kr=function(t){function n(e,n){var r=t.call(this,e,n)||this;return r.channel=new cs(e,n),r.channel.myMemberState=Ft.JOINED,r}return e(n,t),n}(F),Pr=function(t){function n(e){var n=this,s=e.channelUrl,i=e.isDistinct,a=e.isPublic,o=e.isDiscoverable,u=e.coverUrl,c=e.coverImage,l=e.accessCode,h=e.name,d=e.data,p=e.customType,f=e.operatorUserIds,_=e.messageSurvivalSeconds;return(n=t.call(this)||this).method=D.PUT,n.path="".concat(O,"/").concat(encodeURIComponent(s)),n.params=r({is_distinct:i,is_public:a,is_discoverable:o,name:h,data:d,custom_type:p,cover_url:u,cover_file:c,access_code:l,operator_ids:f,message_survival_seconds:_}),n}return e(n,t),n}(R),Rr=function(t){function n(e,n){var r=t.call(this,e,n)||this;return r.channel=new cs(e,n),r}return e(n,t),n}(F),Fr=function(t){function n(e){var n=this,r=e.channelUrl;return(n=t.call(this)||this).method=D.DELETE,n.path="".concat(O,"/").concat(encodeURIComponent(r)),n}return e(n,t),n}(R);!function(t){function n(e,n){return t.call(this,e,n)||this}e(n,t)}(F);var xr=function(t){function n(e){var n=this,r=e.channelUrl;return(n=t.call(this)||this).method=D.DELETE,n.path="".concat(O,"/").concat(encodeURIComponent(r),"/hide"),n}return e(n,t),n}(R);!function(t){function n(){return null!==t&&t.apply(this,arguments)||this}e(n,t)}(F);var Or=function(t){function n(e){var n=e.userId,r=e.channelUrl,s=e.countPreference,i=t.call(this)||this;return i.method=D.PUT,i.path="".concat(k,"/").concat(encodeURIComponent(n),"/count_preference/").concat(encodeURIComponent(r)),i.params={count_preference:s},i}return e(n,t),n}(R),Hr=function(t){function n(e,n){var r=t.call(this,e,n)||this;return r.countPreference=n.count_preference,r}return e(n,t),n}(F),Gr=function(t){function n(e){var n=this,r=e.channelUrl;return(n=t.call(this)||this).method=D.PUT,n.path="".concat(O,"/").concat(encodeURIComponent(r),"/reset_user_history"),n}return e(n,t),n}(R),Vr=function(t){function n(e,n){var r=t.call(this,e,n)||this,s=n.ts_message_offset;return r.messageOffsetTimestamp=s,r}return e(n,t),n}(F),qr=i(i({},ke),{scheduledAt:void 0,file:void 0,fileUrl:void 0,fileName:void 0,mimeType:void 0,fileSize:void 0,thumbnailSizes:void 0,requireAuth:!1}),Br=i(i({},Re),{scheduledAt:void 0}),Wr=function(t){function n(e){var n,i=this;i=t.call(this)||this;var a=[];e.mentionType===he.USERS&&(e.mentionedUserIds?a=e.mentionedUserIds:e.mentionedUsers&&(a=e.mentionedUsers.map((function(e){return e.userId}))));var o=e.channelType,u=e.channelUrl,c=e.scheduledMessageId;return i.method=D.PUT,i.path="".concat(re(o),"/").concat(encodeURIComponent(u),"/scheduled_messages/").concat(encodeURIComponent(c)),i.params=r(s({req_id:e.reqId,scheduled_at:e.scheduledAt,message_type:de.FILE,url:e.fileUrl,file_name:e.fileName,file_size:e.fileSize,file_type:e.mimeType,thumbnails:e.thumbnailSizes?e.thumbnailSizes.map((function(e){return Tt.payloadify(e)})):[],custom_type:e.customType,data:e.data,require_auth:e.requireAuth,mention_type:e.mentionType,mentioned_user_ids:a,sorted_metaarray:null===(n=e.metaArrays)||void 0===n?void 0:n.map((function(e){return At.payloadify(e)})),apple_critical_alert_options:e.appleCriticalAlertOptions?It.payloadify(e.appleCriticalAlertOptions):null,push_option:e.pushNotificationDeliveryOption})),i}return e(n,t),n}(R),zr=function(t){function n(e,n){var r=t.call(this,e,n)||this;return r.message=new Nt(e,n),r}return e(n,t),n}(F),jr=function(t){function n(e){var n,i=this;i=t.call(this)||this;var a=[];e.mentionType===he.USERS&&(e.mentionedUserIds?a=e.mentionedUserIds:e.mentionedUsers&&(a=e.mentionedUsers.map((function(e){return e.userId}))));var o=e.channelType,u=e.channelUrl,c=e.scheduledMessageId;return i.method=D.PUT,i.path="".concat(re(o),"/").concat(encodeURIComponent(u),"/scheduled_messages/").concat(encodeURIComponent(c)),i.params=r(s({req_id:e.reqId,scheduled_at:e.scheduledAt,message_type:de.USER,message:e.message,custom_type:e.customType,data:e.data,mention_type:e.mentionType,mentioned_user_ids:a,sorted_metaarray:null===(n=e.metaArrays)||void 0===n?void 0:n.map((function(e){return At.payloadify(e)})),apple_critical_alert_options:e.appleCriticalAlertOptions?It.payloadify(e.appleCriticalAlertOptions):null,target_langs:e.translationTargetLanguages,push_option:e.pushNotificationDeliveryOption})),i}return e(n,t),n}(R);!function(t){function n(e,n){var r=t.call(this,e,n)||this;return r.message=new Mt(e,n),r}e(n,t)}(F);var Qr=function(t){function n(e){var n=t.call(this)||this,r=e.channelType,s=e.channelUrl,i=e.scheduledMessageId;return n.method=D.DELETE,n.path="".concat(re(r),"/").concat(encodeURIComponent(s),"/scheduled_messages/").concat(encodeURIComponent(i)),n}return e(n,t),n}(R),Kr=function(t){function n(e){var n=t.call(this)||this,r=e.channelType,s=e.channelUrl,i=e.scheduledMessageId;return n.method=D.POST,n.path="".concat(re(r),"/").concat(encodeURIComponent(s),"/scheduled_messages/").concat(encodeURIComponent(i),"/send_now"),n}return e(n,t),n}(R),Yr=function(t){function n(e){var n=e.userId,r=e.channelUrl,s=e.pushTriggerOption,i=t.call(this)||this;return i.method=D.PUT,i.path="".concat(k,"/").concat(encodeURIComponent(n),"/push_preference/").concat(encodeURIComponent(r)),i.params={push_trigger_option:s},i}return e(n,t),n}(R),Jr=function(t){function n(e,n){var r=t.call(this,e,n)||this;return r.pushTriggerOption=n.push_trigger_option,r.enabled=n.enable,r}return e(n,t),n}(F),Xr=function(t){function n(e){var n=e.userId,r=e.channelUrl,s=t.call(this)||this;return s.method=D.GET,s.path="".concat(k,"/").concat(encodeURIComponent(n),"/push_preference/").concat(encodeURIComponent(r)),s}return e(n,t),n}(R),Zr=function(t){function n(e,n){var r=t.call(this,e,n)||this;return r.pushTriggerOption=n.push_trigger_option,r.enabled=n.enable,r}return e(n,t),n}(F),$r=function(t){function n(e){var n=e.channelType,r=e.channelUrl,s=e.messageId,i=t.call(this)||this;return i.method=D.POST,i.path="".concat(re(n),"/").concat(encodeURIComponent(r),"/messages/").concat(s,"/pin"),i}return e(n,t),n}(R);!function(t){function n(e,n){return t.call(this,e,n)||this}e(n,t)}(F);var es=function(t){function n(e){var n=e.channelType,r=e.channelUrl,s=e.messageId,i=t.call(this)||this;return i.method=D.DELETE,i.path="".concat(re(n),"/").concat(encodeURIComponent(r),"/messages/").concat(s,"/pin"),i}return e(n,t),n}(R);!function(t){function n(e,n){return t.call(this,e,n)||this}e(n,t)}(F);var ts,ns,rs,ss=function(t){function n(e,n){var r=t.call(this,e)||this;return r.message=bt(e,n.message),r}return e(n,t),n}(h),is=function(t){function n(e){var n=this,s=e.channelType,i=e.channelUrl,a=e.limit,o=e.token,u=e.includeReactions,c=e.includeMetaArray,l=e.includeParentMessageInfo,h=e.includeThreadInfo,d=e.includePollDetails;return(n=t.call(this)||this).method=D.GET,n.path="".concat(re(s),"/").concat(encodeURIComponent(i),"/pinned_messages"),n.params=r({limit:a,token:o,include_reactions:u,with_sorted_meta_array:c,include_thread_info:h,include_parent_message_info:l,include_poll_details:d}),n}return e(n,t),n}(R),as=function(t){function n(e,n){var r=t.call(this,e,n)||this,s=n.pinned_messages,i=n.has_more,a=n.next;return r.pinnedMessages=s.map((function(t){return new ss(e,t)})),r.hasMore=i,r.token=a,r}return e(n,t),n}(F),os=function(t){function n(e,n,r,s){var i=t.call(this,e,n,r,s)||this;return i.includeMetaArray=s.includeMetaArray,i.includeReactions=s.includeReactions,i.includeParentMessageInfo=s.includeParentMessageInfo,i.includeThreadInfo=s.includeThreadInfo,i.includePollDetails=s.includePollDetails,i}return e(n,t),n.prototype._validate=function(){return t.prototype._validate.call(this)&&b("boolean",this.includeMetaArray,!0)&&b("boolean",this.includeReactions,!0)&&b("boolean",this.includeParentMessageInfo,!0)&&b("boolean",this.includeThreadInfo,!0)&&b("boolean",this.includePollDetails,!0)},n.prototype.next=function(){return g(this,void 0,void 0,(function(){var e,t,n,r,s,a,o;return y(this,(function(u){switch(u.label){case 0:return this._validate()?this._isLoading?[3,3]:this._hasNext?(this._isLoading=!0,e=j.of(this._iid).requestQueue,t=new is(i(i({},this),{token:this._token})),[4,e.send(t)]):[3,2]:[3,5];case 1:return n=u.sent(),r=n.as(as),s=r.pinnedMessages,a=r.hasMore,o=r.token,this._token=o,this._hasNext=!!a,this._isLoading=!1,[2,s];case 2:return[2,[]];case 3:throw _.queryInProgress;case 4:return[3,6];case 5:throw _.invalidParameters;case 6:return[2]}}))}))},n}(le);!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"}(ts||(ts={})),function(e){e.MUTED="muted",e.UNMUTED="unmuted"}(ns||(ns={})),function(e){e.UNHIDDEN="unhidden",e.HIDDEN_ALLOW_AUTO_UNHIDE="hidden_allow_auto_unhide",e.HIDDEN_PREVENT_AUTO_UNHIDE="hidden_prevent_auto_unhide"}(rs||(rs={}));var us,cs=function(t){function n(e,n){var r,s,l,h,d,p,f,_,g,y,C,E,M,N,U,S,T,A,I,w=this;return(w=t.call(this,e,n)||this)._unreadMemberStateMap=new Map,w._undeliveredMemberStateMap=new Map,w._typingStatus=new Map,w._lastMemberCountUpdated=0,w._typingStarted=0,w._typingEnded=0,w.isDistinct=!1,w.isSuper=!1,w.isBroadcast=!1,w.isExclusive=!1,w.isPublic=!1,w.isDiscoverable=!0,w.isAccessCodeRequired=!1,w.isPushEnabled=!1,w.unreadMessageCount=0,w.unreadMentionCount=0,w.members=[],w.memberCount=0,w.joinedMemberCount=0,w.hiddenState=rs.UNHIDDEN,w.lastMessage=null,w.messageOffsetTimestamp=0,w.messageSurvivalSeconds=-1,w.myMemberState=Ft.NONE,w.myRole=o.NONE,w.myMutedState=ns.UNMUTED,w.myLastRead=0,w.myCountPreference=ts.ALL,w.myPushTriggerOption=fe.DEFAULT,w.inviter=null,w.invitedAt=0,w.joinedAt=0,w.pinnedMessageIds=[],w.lastPinnedMessage=null,w._pinnedMessagesUpdatedAt=0,w._myMutedRemainingTime=-1,w.channelType=u.GROUP,w.isDistinct=null!==(s=n.is_distinct)&&void 0!==s&&s,w.isSuper=null!==(l=n.is_super)&&void 0!==l&&l,w.isBroadcast=null!==(h=n.is_broadcast)&&void 0!==h&&h,w.isExclusive=null!==(d=n.is_exclusive)&&void 0!==d&&d,w.isPublic=null!==(p=n.is_public)&&void 0!==p&&p,w.isDiscoverable=null!==(f=n.is_discoverable)&&void 0!==f?f:w.isPublic,w.isAccessCodeRequired=null!==(_=n.is_access_code_required)&&void 0!==_&&_,w.isPushEnabled=null!==(g=n.is_push_enabled)&&void 0!==g&&g,Array.isArray(n.members)&&(r=w.members).push.apply(r,m([],v(n.members.map((function(e){return new zt(w._iid,e)}))),!1)),w.memberCount=null!==(y=n.member_count)&&void 0!==y?y:0,w.joinedMemberCount=null!==(C=n.joined_member_count)&&void 0!==C?C:0,w.hiddenState=a(rs,n.hidden_state)?n.hidden_state:rs.UNHIDDEN,w.messageOffsetTimestamp=null!==(E=n.ts_message_offset)&&void 0!==E?E:0,w.messageSurvivalSeconds=null!==(M=n.message_survival_seconds)&&void 0!==M?M:-1,w.lastMessage=n.last_message?bt(w._iid,i({channel_type:w.channelType},n.last_message)):null,n.read_receipt&&Object.keys(n.read_receipt).forEach((function(e){b("number",n.read_receipt[e])&&w._updateUnreadMemberState(e,n.read_receipt[e])})),n.delivery_receipt&&Object.keys(n.delivery_receipt).forEach((function(e){b("number",n.delivery_receipt[e])&&w._updateUndeliveredMemberState(e,n.delivery_receipt[e])})),w.myMemberState=a(Ft,n.member_state)?n.member_state:Ft.NONE,w.myRole=a(o,n.my_role)?n.my_role:o.NONE,a(ns,n.is_muted)?w.myMutedState=n.is_muted:b("boolean",n.is_muted)?w.myMutedState=n.is_muted?ns.MUTED:ns.UNMUTED:w.myMutedState=ns.UNMUTED,w.myCountPreference=a(ts,n.count_preference)?n.count_preference:ts.ALL,w.myPushTriggerOption=a(fe,n.push_trigger_option)?n.push_trigger_option:fe.ALL,w.myLastRead=null!==(N=n.user_last_read)&&void 0!==N?N:0,w.inviter=n.inviter?new c(w._iid,n.inviter):null,w.invitedAt=null!==(U=n.invited_at)&&void 0!==U?U:0,w.joinedAt=null!==(S=n.joined_ts)&&void 0!==S?S:0,w._updateUnreadCount(null!==(T=n.unread_message_count)&&void 0!==T?T:0,null!==(A=n.unread_mention_count)&&void 0!==A?A:0),w.pinnedMessageIds=null!==(I=n.pinned_message_ids)&&void 0!==I?I:[],w.lastPinnedMessage=n.latest_pinned_message?bt(w._iid,i({channel_type:w.channelType},n.latest_pinned_message)):null,w}return e(n,t),Object.defineProperty(n.prototype,"isHidden",{get:function(){return this.hiddenState!==rs.UNHIDDEN},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"isTyping",{get:function(){return this._typingStatus.size>0},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"cachedUnreadMemberState",{get:function(){var e,t,n={};try{for(var r=C(this._unreadMemberStateMap),s=r.next();!s.done;s=r.next()){var i=v(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(n.prototype,"cachedUndeliveredMemberState",{get:function(){var e,t,n={};try{for(var r=C(this._undeliveredMemberStateMap),s=r.next();!s.done;s=r.next()){var i=v(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}),n.payloadify=function(e){return r(s(i(i({},t.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 zt.payloadify(e)})),last_message:e.lastMessage?wt(e.lastMessage):null,inviter:e.inviter?c.payloadify(e.inviter):null,invited_at:e.invitedAt,joined_ts:e.joinedAt,pinned_message_ids:e.pinnedMessageIds,latest_pinned_message:e.lastPinnedMessage?wt(e.lastPinnedMessage):null})))},n.prototype._shouldUpdateLastMessageWith=function(e){return!(e instanceof Ct&&e.parentMessageId>0&&!e.replyToChannel)&&(!this.lastMessage||this.lastMessage.createdAt=0)if(this.myCountPreference===ts.ALL||this.myCountPreference===ts.UNREAD_MESSAGE_COUNT_ONLY)if(this.isExclusive||this.isSuper||this.isBroadcast){var n=j.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===ts.ALL||this.myCountPreference===ts.UNREAD_MENTION_COUNT_ONLY)?this.unreadMentionCount=t:this.unreadMentionCount=0},n.prototype._updateUnreadMemberState=function(e,t){var n=this._unreadMemberStateMap.get(e);return(!n||n0?this._typingStatus.set(e.userId,{user:e,ts:t}):this._typingStatus.delete(e.userId)},n.prototype._clearTypingStatus=function(){this._typingStatus.clear(),this._typingStarted=0,this._typingEnded=0},n.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},n.prototype.isReadMessage=function(e){var t=j.of(this._iid).sdkState,n=this._unreadMemberStateMap.get(t.userId);return!!n&&n>=e.createdAt},n.prototype.serialize=function(){var e=this;return B(this,(function(t){t.cachedUnreadMemberState=e.cachedUnreadMemberState,t.cachedUndeliveredMemberState=e.cachedUndeliveredMemberState}))},n.prototype.createMessageCollection=function(e){return void 0===e&&(e={}),new Tr(this._iid,i({channel:this},e))},n.prototype.createMemberListQuery=function(e){return void 0===e&&(e={}),new Lr(this._iid,this.url,e)},n.prototype.createPinnedMessageListQuery=function(e){return void 0===e&&(e={}),new os(this._iid,this.url,this.channelType,e)},n.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===Ft.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)}},n.prototype.removeMember=function(e){if(!this.isExclusive&&!this.isSuper&&!this.isBroadcast){var t=e instanceof zt?e.userId:e,n=this.members.findIndex((function(e){return e.userId===t}));if(n>-1)return this.members.splice(n,1),this.memberCount--,!0}return!1},n.prototype.getUnreadMemberCount=function(e){var t,n;if(e instanceof Ct&&!this.isExclusive&&!this.isSuper&&!this.isBroadcast){var r=j.of(this._iid).sdkState,s=e.createdAt,i=0;try{for(var a=C(this.members),o=a.next();!o.done;o=a.next()){var u=o.value;if(r.userId!==u.userId&&u.state===Ft.JOINED&&e.sender.userId!==u.userId)(this.cachedUnreadMemberState[u.userId]||0)=e.createdAt&&i.push(a)}})),i},n.prototype.getUnreadMembers=function(e,t){var n=this;void 0===t&&(t=!1);var r=j.of(this._iid).sdkState;if(!r.userId||this.isExclusive||this.isSuper||this.isBroadcast)return[];var s=e instanceof Ct?e.sender:null,i=[];return this.members.forEach((function(a){if(t||a.userId!==r.userId&&a.userId!==(null==s?void 0:s.userId)){var o=n._unreadMemberStateMap.get(a.userId);o&&o=t&&(e._typingStatus.delete(i),r=!0)})),r},n.prototype.refresh=function(){return g(this,void 0,void 0,(function(){var e,t,n,r,s,i;return y(this,(function(a){switch(a.label){case 0:return e=j.of(this._iid),t=e.requestQueue,n=e.dispatcher,r=new ln({channelUrl:this.url}),[4,t.send(r)];case 1:return s=a.sent(),i=s.as(hn).channel,this._update(i),n.dispatch(new We({channels:[i],source:ze.REQUEST_CHANNEL})),[2,this]}}))}))},n.prototype.freeze=function(){return g(this,void 0,void 0,(function(){return y(this,(function(e){switch(e.label){case 0:return[4,t.prototype.freeze.call(this)];case 1:return e.sent(),j.of(this._iid).dispatcher.dispatch(new We({channels:[this],source:ze.EVENT_CHANNEL_FROZEN,isWebSocketEventComing:!0})),[2]}}))}))},n.prototype.unfreeze=function(){return g(this,void 0,void 0,(function(){return y(this,(function(e){switch(e.label){case 0:return[4,t.prototype.unfreeze.call(this)];case 1:return e.sent(),j.of(this._iid).dispatcher.dispatch(new We({channels:[this],source:ze.EVENT_CHANNEL_UNFROZEN,isWebSocketEventComing:!0})),[2]}}))}))},n.prototype.updateChannel=function(e){return g(this,void 0,void 0,(function(){var t,n,r,s,a,o,u;return y(this,(function(c){switch(c.label){case 0:return t=i(i({},Ar),e),f(function(e){return b("string",e.coverUrl,!0)&&(M(e.coverImage)||b("string",e.coverImage,!0))&&b("boolean",e.isDistinct,!0)&&b("boolean",e.isPublic,!0)&&b("boolean",e.isDiscoverable,!0)&&b("string",e.accessCode,!0)&&b("string",e.name,!0)&&b("string",e.data,!0)&&b("string",e.customType,!0)&&E("string",e.operatorUserIds,!0)&&b("number",e.messageSurvivalSeconds,!0)}(t)).throw(_.invalidParameters),n=j.of(this._iid),r=n.dispatcher,s=n.requestQueue,a=new Pr(i({channelUrl:this.url},t)),[4,s.send(a)];case 1:return o=c.sent(),u=o.as(Rr).channel,this._update(u),r.dispatch(new We({channels:[u],source:ze.EVENT_CHANNEL_UPDATED,isWebSocketEventComing:!0})),[2,this]}}))}))},n.prototype.invite=function(e){return g(this,void 0,void 0,(function(){return y(this,(function(t){return f(e.every((function(e){return e instanceof c}))).throw(_.invalidParameters),[2,this.inviteWithUserIds(e.map((function(e){return e.userId})))]}))}))},n.prototype.inviteWithUserIds=function(e){return g(this,void 0,void 0,(function(){var t,n,r,s,i,a;return y(this,(function(o){switch(o.label){case 0:return f(E("string",e)).throw(_.invalidParameters),t=j.of(this._iid),n=t.dispatcher,r=t.requestQueue,s=new Pn({channelUrl:this.url,userIds:e}),[4,r.send(s)];case 1:return i=o.sent(),a=i.as(Rn).channel,this._update(a),n.dispatch(new We({channels:[a],source:ze.EVENT_CHANNEL_INVITED,isWebSocketEventComing:!0})),[2,this]}}))}))},n.prototype.join=function(e){return g(this,void 0,void 0,(function(){var t,n,r,s,i,a,o;return y(this,(function(u){switch(u.label){case 0:return f(b("string",e,!0)).throw(_.invalidParameters),t=j.of(this._iid),n=t.dispatcher,r=t.sdkState,s=t.requestQueue,i=new In({channelUrl:this.url,userId:r.userId,accessCode:e}),[4,s.send(i)];case 1:return a=u.sent(),(o=a.as(wn).channel).myMemberState=this.myMemberState=Ft.JOINED,this._update(o),n.dispatch(new We({channels:[o],source:ze.EVENT_CHANNEL_JOINED,isWebSocketEventComing:!0})),[2,this]}}))}))},n.prototype.leave=function(e){return void 0===e&&(e=!1),g(this,void 0,void 0,(function(){var t,n,r,s;return y(this,(function(i){switch(i.label){case 0:return t=j.of(this._iid),n=t.sdkState,r=t.requestQueue,s=new Dn({channelUrl:this.url,userId:n.userId,shouldRemoveOperatorStatus:e}),[4,r.send(s)];case 1:return i.sent(),this.myMemberState=Ft.NONE,[2]}}))}))},n.prototype.acceptInvitation=function(e){return g(this,void 0,void 0,(function(){var t,n,r,s,i,a,o;return y(this,(function(u){switch(u.label){case 0:return f(b("string",e,!0)).throw(_.invalidParameters),t=j.of(this._iid),n=t.dispatcher,r=t.sdkState,s=t.requestQueue,i=new Dr({channelUrl:this.url,userId:r.userId,accessCode:e}),[4,s.send(i)];case 1:return a=u.sent(),(o=a.as(kr).channel).myMemberState=this.myMemberState=Ft.JOINED,this._update(o),n.dispatch(new We({channels:[o],source:ze.EVENT_CHANNEL_ACCEPTED_INVITE,isWebSocketEventComing:!0})),[2,this]}}))}))},n.prototype.declineInvitation=function(){return g(this,void 0,void 0,(function(){var e,t,n,r;return y(this,(function(s){switch(s.label){case 0:return e=j.of(this._iid),t=e.sdkState,n=e.requestQueue,r=new xn({channelUrl:this.url,userId:t.userId}),[4,n.send(r)];case 1:return s.sent(),this.myMemberState=Ft.NONE,[2,this]}}))}))},n.prototype.sendUserMessage=function(e){var n=this,r=new Dt,s=j.of(this._iid).dispatcher,i=nt.of(this._iid);return t.prototype.sendUserMessage.call(this,e).onPending((function(e){i.completeCurrentAndProcessNextAutoResend(e),r._trigger(null,e)})).onFailed((function(e,t){t&&i.completeCurrentAndProcessNextAutoResend(t),r._trigger(e,t)})).onSucceeded((function(e){n.hiddenState===rs.HIDDEN_ALLOW_AUTO_UNHIDE&&(n.hiddenState=rs.UNHIDDEN),i.completeCurrentAndProcessNextAutoResend(e),n._shouldUpdateLastMessageWith(e)&&(n.lastMessage=e),rr.of(n._iid).handlers.map((function(e){e.onChannelChanged&&e.onChannelChanged(n)})),s.dispatch(new We({channels:[n],source:ze.EVENT_MESSAGE_SENT})),r._trigger(null,e)})),r},n.prototype.updateUserMessage=function(e,n){return g(this,void 0,void 0,(function(){var r,s,i,a,o=this;return y(this,(function(u){switch(u.label){case 0:return r=j.of(this._iid).dispatcher,[4,t.prototype.updateUserMessage.call(this,e,n)];case 1:return s=u.sent(),i=!1,!s.silent&&this._shouldUpdateLastMessageWith(s)&&(this.lastMessage=s,i=!0),a=!1,this.lastPinnedMessage&&this.lastPinnedMessage.messageId===s.messageId&&(this.lastPinnedMessage=s,i=!0,a=!0),i&&(rr.of(this._iid).handlers.map((function(e){e.onChannelChanged&&e.onChannelChanged(o)})),r.dispatch(new We({channels:[this],source:a?ze.EVENT_PINNED_MESSAGE_UPDATED:ze.EVENT_MESSAGE_UPDATED}))),a&&rr.of(this._iid).handlers.map((function(e){e.onPinnedMessageUpdated&&e.onPinnedMessageUpdated(o)})),r.dispatch(new L({messages:[s],source:J.EVENT_MESSAGE_UPDATED})),[2,s]}}))}))},n.prototype._autoResendUserMessage=function(e){var n=this,r=new Dt,s=j.of(this._iid).dispatcher,i=nt.of(this._iid);return t.prototype._autoResendUserMessage.call(this,e).onPending((function(e){i.completeCurrentAndProcessNextAutoResend(e),r._trigger(null,e)})).onFailed((function(e,t){i.completeCurrentAndProcessNextAutoResend(t),r._trigger(e,t)})).onSucceeded((function(e){var t=rr.of(n._iid);i.completeCurrentAndProcessNextAutoResend(e),n._shouldUpdateLastMessageWith(e)&&(n.lastMessage=e),t.handlers.map((function(e){e.onChannelChanged&&e.onChannelChanged(n)})),s.dispatch(new We({channels:[n],source:ze.EVENT_MESSAGE_SENT})),r._trigger(null,e)})),r},n.prototype.sendFileMessage=function(e){var n=this,r=new Dt,s=j.of(this._iid).dispatcher,i=nt.of(this._iid);return t.prototype.sendFileMessage.call(this,e).onPending((function(e){i.completeCurrentAndProcessNextAutoResend(e),r._trigger(null,e)})).onFailed((function(e,t){t&&i.completeCurrentAndProcessNextAutoResend(t),r._trigger(e,t)})).onSucceeded((function(e){var t=rr.of(n._iid);i.completeCurrentAndProcessNextAutoResend(e),n._shouldUpdateLastMessageWith(e)&&(n.lastMessage=e),t.handlers.map((function(e){e.onChannelChanged&&e.onChannelChanged(n)})),s.dispatch(new We({channels:[n],source:ze.EVENT_MESSAGE_SENT})),r._trigger(null,e)})),r},n.prototype.sendMultipleFilesMessage=function(e){var n=this,r=new Lt,s=j.of(this._iid).dispatcher;return t.prototype.sendMultipleFilesMessage.call(this,e).onPending((function(e){r._trigger(null,e)})).onFailed((function(e,t){r._trigger(e,t)})).onSucceeded((function(e){var t=rr.of(n._iid);n._shouldUpdateLastMessageWith(e)&&(n.lastMessage=e),t.handlers.map((function(e){e.onChannelChanged&&e.onChannelChanged(n)})),s.dispatch(new We({channels:[n],source:ze.EVENT_MESSAGE_SENT})),r._trigger(null,e)})).onFileUploaded((function(e,t,n,s){r._triggerOnFileUploaded(e,t,n,s)})),r},n.prototype.updateFileMessage=function(e,n){return g(this,void 0,void 0,(function(){var r,s,i,a,o=this;return y(this,(function(u){switch(u.label){case 0:return r=j.of(this._iid).dispatcher,[4,t.prototype.updateFileMessage.call(this,e,n)];case 1:return s=u.sent(),i=!1,!s.silent&&this._shouldUpdateLastMessageWith(s)&&(this.lastMessage=s,i=!0),a=!1,this.lastPinnedMessage&&this.lastPinnedMessage.messageId===s.messageId&&(this.lastPinnedMessage=s,i=!0,a=!0),i&&(rr.of(this._iid).handlers.map((function(e){e.onChannelChanged&&e.onChannelChanged(o)})),r.dispatch(new We({channels:[this],source:a?ze.EVENT_PINNED_MESSAGE_UPDATED:ze.EVENT_MESSAGE_UPDATED}))),a&&rr.of(this._iid).handlers.map((function(e){e.onPinnedMessageUpdated&&e.onPinnedMessageUpdated(o)})),r.dispatch(new L({messages:[s],source:J.EVENT_MESSAGE_UPDATED})),[2,s]}}))}))},n.prototype._autoResendFileMessage=function(e){var n=this,r=new Dt,s=j.of(this._iid).dispatcher,i=nt.of(this._iid);return t.prototype._autoResendFileMessage.call(this,e).onPending((function(e){i.completeCurrentAndProcessNextAutoResend(e),r._trigger(null,e)})).onFailed((function(e,t){i.completeCurrentAndProcessNextAutoResend(t),r._trigger(e,t)})).onSucceeded((function(e){var t=rr.of(n._iid);i.completeCurrentAndProcessNextAutoResend(e),n._shouldUpdateLastMessageWith(e)&&(n.lastMessage=e),t.handlers.map((function(e){e.onChannelChanged&&e.onChannelChanged(n)})),s.dispatch(new We({channels:[n],source:ze.EVENT_MESSAGE_SENT})),r._trigger(null,e)})),r},n.prototype.deleteMessage=function(e){return g(this,void 0,void 0,(function(){return y(this,(function(n){switch(n.label){case 0:return[4,t.prototype.deleteMessage.call(this,e)];case 1:return n.sent(),0===e.messageId&&e instanceof Ct&&j.of(this._iid).dispatcher.dispatch(new I({reqId:e.reqId,source:J.EVENT_MESSAGE_DELETED})),[2]}}))}))},n.prototype.hide=function(e){return g(this,void 0,void 0,(function(){var t,n,r,s,a,o,u,c;return y(this,(function(l){switch(l.label){case 0:return t=i(i({},Wn),e),f(function(e){return b("boolean",e.hidePreviousMessages,!0)&&b("boolean",e.allowAutoUnhide,!0)}(t)).throw(_.invalidParameters),n=j.of(this._iid),r=n.dispatcher,s=n.sdkState,a=n.requestQueue,o=new zn(i({channelUrl:this.url,userId:s.userId},t)),[4,a.send(o)];case 1:return u=l.sent(),c=u.as(jn).messageOffsetTimestamp,this.hiddenState=t.allowAutoUnhide?rs.HIDDEN_ALLOW_AUTO_UNHIDE:rs.HIDDEN_PREVENT_AUTO_UNHIDE,t.hidePreviousMessages&&this._updateUnreadCount(0,0),c&&(this.messageOffsetTimestamp=c),r.dispatch(new We({channels:[this],source:ze.EVENT_CHANNEL_HIDDEN,isWebSocketEventComing:!0})),[2,this]}}))}))},n.prototype.unhide=function(){return g(this,void 0,void 0,(function(){var e,t,n,r;return y(this,(function(s){switch(s.label){case 0:return e=j.of(this._iid),t=e.dispatcher,n=e.requestQueue,r=new xr({channelUrl:this.url}),[4,n.send(r)];case 1:return s.sent(),this.hiddenState=rs.UNHIDDEN,t.dispatch(new We({channels:[this],source:ze.EVENT_CHANNEL_UNHIDDEN,isWebSocketEventComing:!0})),[2,this]}}))}))},n.prototype.delete=function(){return g(this,void 0,void 0,(function(){var e,t;return y(this,(function(n){switch(n.label){case 0:return e=j.of(this._iid).requestQueue,t=new Fr({channelUrl:this.url}),[4,e.send(t)];case 1:return n.sent(),[2]}}))}))},n.prototype.markAsRead=function(){return g(this,void 0,void 0,(function(){var e,t,n,r,s,i,a,o=this;return y(this,(function(u){switch(u.label){case 0:return e=j.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(Gn).readStatus,this._updateUnreadMemberState(t.userId,a.readAt),(this.unreadMessageCount>0||this.unreadMentionCount>0)&&(this._updateUnreadCount(0,0),rr.of(this._iid).handlers.map((function(e){e.onChannelChanged&&e.onChannelChanged(o)}))),n.dispatch(new We({channels:[this],source:ze.EVENT_CHANNEL_READ})),[2]}}))}))},n.prototype.markAsDelivered=function(){return g(this,void 0,void 0,(function(){var e,t,n,r;return y(this,(function(s){switch(s.label){case 0:return e=j.of(this._iid),t=e.sdkState,n=e.requestQueue,r=new Vn({channelUrl:this.url,userId:t.userId}),[4,n.send(r)];case 1:return s.sent(),[2]}}))}))},n.prototype.startTyping=function(){return g(this,void 0,void 0,(function(){var e,t,n,r,s;return y(this,(function(i){return e=j.of(this._iid),t=e.requestQueue,n=e.typingIndicatorThrottle,(r=(new Date).getTime())-this._typingStarted>=n&&(this._typingStarted=r,this._typingEnded=0,s=new Kn({channelUrl:this.url,time:this._typingStarted}),t.send(s)),[2]}))}))},n.prototype.endTyping=function(){return g(this,void 0,void 0,(function(){var e,t,n,r,s;return y(this,(function(i){return e=j.of(this._iid),t=e.requestQueue,n=e.typingIndicatorThrottle,(r=(new Date).getTime())-this._typingEnded>=n&&(this._typingStarted=0,this._typingEnded=r,s=new Jn({channelUrl:this.url,time:this._typingStarted}),t.send(s)),[2]}))}))},n.prototype.createScheduledUserMessage=function(e){e=i(i({},rt),e),f(st(e)).throw(_.invalidParameters);var t=new Dt;return this._createScheduledUserMessage(e,t),t},n.prototype.updateScheduledUserMessage=function(e,t){return g(this,void 0,void 0,(function(){var n,r,s,a;return y(this,(function(o){switch(o.label){case 0:return n=i(i({},Br),t),f(function(e){return Fe(e)&&b("number",e.scheduledAt,!0)}(n)).throw(_.invalidParameters),r=j.of(this._iid).requestQueue,s=new jr(i({reqId:this._generateRequestId(),scheduledMessageId:e,channelType:this.channelType,channelUrl:this.url},n)),[4,r.send(s)];case 1:return a=o.sent(),[2,a.as(Oe).message]}}))}))},n.prototype.createScheduledFileMessage=function(e){var t=this;e=i(i({},it),e),f(at(e)).throw(_.invalidParameters);var n=Date.now(),r=this._generateRequestId(),s=new Dt;return pe(He).then((function(){var i=t._createPendingScheduledFileMessage(e,r,n);Y((function(){return g(t,void 0,void 0,(function(){return y(this,(function(e){return[2,s._trigger(null,i)]}))}))}))})),M(e.file)?this._uploadFileAndUpdateParams(e).then((function(){return t._createScheduledFileMessage(e,s,r,n)})):this._createScheduledFileMessage(e,s,r,n),s},n.prototype.updateScheduledFileMessage=function(e,t){return g(this,void 0,void 0,(function(){var n,r,s;return y(this,(function(a){switch(a.label){case 0:return n=i(i({},qr),t),f(function(e){return Pe(e)&&b("number",e.scheduledAt,!0)&&(M(e.file)||b("string",e.fileUrl))&&b("string",e.fileName,!0)&&b("string",e.mimeType,!0)&&b("number",e.fileSize,!0)&&(null===e.thumbnailSizes||void 0===e.thumbnailSizes||e.thumbnailSizes.every((function(e){return b("object",e)&&e.maxWidth>0&&e.maxHeight>0})))}(n)).throw(_.invalidParameters),M(n.file)?[4,this._uploadFileAndUpdateParams(n)]:[3,2];case 1:a.sent(),a.label=2;case 2:return r=new Wr(i({reqId:this._generateRequestId(),scheduledMessageId:e,channelType:this.channelType,channelUrl:this.url},n)),[4,j.of(this._iid).requestQueue.send(r)];case 3:return s=a.sent(),[2,s.as(zr).message]}}))}))},n.prototype.cancelScheduledMessage=function(e){return g(this,void 0,void 0,(function(){var t;return y(this,(function(n){switch(n.label){case 0:return t=new Qr({scheduledMessageId:e,channelType:this.channelType,channelUrl:this.url}),[4,j.of(this._iid).requestQueue.send(t)];case 1:return n.sent(),[2]}}))}))},n.prototype.sendScheduledMessageNow=function(e){return g(this,void 0,void 0,(function(){var t;return y(this,(function(n){switch(n.label){case 0:return t=new Kr({scheduledMessageId:e,channelType:this.channelType,channelUrl:this.url}),[4,j.of(this._iid).requestQueue.send(t)];case 1:return n.sent(),[2]}}))}))},n.prototype.getMyPushTriggerOption=function(){return g(this,void 0,void 0,(function(){var e,t,n,r,s,i;return y(this,(function(a){switch(a.label){case 0:return e=j.of(this._iid),t=e.sdkState,n=e.requestQueue,r=new Xr({userId:t.userId,channelUrl:this.url}),[4,n.send(r)];case 1:return s=a.sent(),i=s.as(Zr).pushTriggerOption,this.myPushTriggerOption=i,[2,i]}}))}))},n.prototype.setMyPushTriggerOption=function(e){return g(this,void 0,void 0,(function(){var t,n,r,s,i,o,u;return y(this,(function(c){switch(c.label){case 0:return f(a(fe,e)).throw(_.invalidParameters),t=j.of(this._iid),n=t.dispatcher,r=t.sdkState,s=t.requestQueue,i=new Yr({userId:r.userId,channelUrl:this.url,pushTriggerOption:e}),[4,s.send(i)];case 1:return o=c.sent(),u=o.as(Jr).pushTriggerOption,this.myPushTriggerOption=u,n.dispatch(new We({channels:[this],source:ze.EVENT_CHANNEL_UPDATED,isWebSocketEventComing:!0})),[2,u]}}))}))},n.prototype.setMyCountPreference=function(e){return g(this,void 0,void 0,(function(){var t,n,r,s,i,o,u;return y(this,(function(c){switch(c.label){case 0:return f(a(ts,e)).throw(_.invalidParameters),t=j.of(this._iid),n=t.dispatcher,r=t.sdkState,s=t.requestQueue,i=new Or({channelUrl:this.url,userId:r.userId,countPreference:e}),[4,s.send(i)];case 1:return o=c.sent(),u=o.as(Hr).countPreference,this.myCountPreference=u,this._updateUnreadCount(this.unreadMessageCount,this.unreadMentionCount),n.dispatch(new We({channels:[this],source:ze.EVENT_CHANNEL_UPDATED,isWebSocketEventComing:!0})),[2,u]}}))}))},n.prototype.resetMyHistory=function(){return g(this,void 0,void 0,(function(){var e,t,n,r,s,i;return y(this,(function(a){switch(a.label){case 0:return e=j.of(this._iid),t=e.dispatcher,n=e.requestQueue,r=new Gr({channelUrl:this.url}),[4,n.send(r)];case 1:return s=a.sent(),i=s.as(Vr).messageOffsetTimestamp,this.messageOffsetTimestamp=i,t.dispatch(new We({channels:[this],source:ze.EVENT_CHANNEL_RESET_HISTORY,isWebSocketEventComing:!0})),[2,this]}}))}))},n.prototype.pinMessage=function(e){return g(this,void 0,void 0,(function(){var t,n;return y(this,(function(r){switch(r.label){case 0:return f(b("number",e)&&e>0).throw(_.invalidParameters),t=j.of(this._iid).requestQueue,n=new $r({channelType:this.channelType,channelUrl:this.url,messageId:e}),[4,t.send(n)];case 1:return r.sent(),[2]}}))}))},n.prototype.unpinMessage=function(e){return g(this,void 0,void 0,(function(){var t,n;return y(this,(function(r){switch(r.label){case 0:return f(b("number",e)&&e>0).throw(_.invalidParameters),t=j.of(this._iid).requestQueue,n=new es({channelType:this.channelType,channelUrl:this.url,messageId:e}),[4,t.send(n)];case 1:return r.sent(),[2]}}))}))},n.prototype._uploadFileAndUpdateParams=function(e){return g(this,void 0,void 0,(function(){var t,n,r,s,i,a,o,u,c,l,h;return y(this,(function(d){switch(d.label){case 0:return M(e.file)?(t=j.of(this._iid).requestQueue,n=new Pt({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(kt),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]}}))}))},n}(xe),ls={},hs=function(){function e(e){var t=e._iid,n=e.limit,r=void 0===n?100:n,s=this;this.ref=0,this._iid=t,this._limit=r;var i,a=j.of(this._iid),o=a.sdkState,u=a.dispatcher,c=a.logger;this._metadataKey=(i=o.userId,"sendbird:".concat(i,"@groupchannel/sync.meta"));var l=function(e){return"sendbird:".concat(e,"@groupchannel/sync")}(o.userId);this._sync=new ir(l,(function(){return g(s,void 0,void 0,(function(){var e,t,n,r,s,i,a,o,u,l;return y(this,(function(h){switch(h.label){case 0:return e={hasNext:!0,nextToken:""},[4,this.loadMetadata()];case 1:if(h.sent(),c.debug("channel background sync from",null===(a=this._metadata)||void 0===a?void 0:a.token),null===(o=this._metadata)||void 0===o?void 0:o.completed)return[3,9];h.label=2;case 2:return h.trys.push([2,5,,8]),[4,rr.of(this._iid).getMyGroupChannels(null!==(l=null===(u=this._metadata)||void 0===u?void 0:u.token)&&void 0!==l?l:"",{includeEmpty:!0,order:Ge.CHRONOLOGICAL},this._limit,ze.SYNC_CHANNEL_BACKGROUND)];case 3:return t=h.sent(),n=t.channels,r=t.token,e.hasNext=n.length>=this._limit&&!!r,e.nextToken=r,this._metadata&&(this._metadata.token=r,(i=this._metadata.range).extends.apply(i,m([],v(n.map((function(e){return e.createdAt}))),!1)),this._metadata.completed=!e.hasNext),c.debug("channel background sync progress",e),[4,this.saveMetadata()];case 4:return h.sent(),[3,8];case 5:return s=h.sent(),c.debug("channel background sync error",s),s instanceof _&&s.isInvalidTokenError?[4,this.clearMetaData()]:[3,7];case 6:h.sent(),h.label=7;case 7:throw s;case 8:return[3,10];case 9:e.hasNext=!1,e.nextToken="",h.label=10;case 10:return[2,e]}}))}))})),this._connectionEventContext=u.on((function(e){if(e instanceof ee)if(e.stateType===te.CONNECTED)s.resume();else s.pause()}))}return e.of=function(t){return ls[t]||(ls[t]=new e({_iid:t})),ls[t].ref++,ls[t]},e.clear=function(e){ls[e]&&(ls[e].close(),delete ls[e])},Object.defineProperty(e.prototype,"range",{get:function(){var e,t;return null!==(t=null===(e=this._metadata)||void 0===e?void 0:e.range)&&void 0!==t?t:new er({})},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"completed",{get:function(){var e;return!!(null===(e=this._metadata)||void 0===e?void 0:e.completed)},enumerable:!1,configurable:!0}),e.prototype.loadMetadata=function(){return g(this,void 0,void 0,(function(){var e;return y(this,(function(t){switch(t.label){case 0:return this._metadata?[3,2]:[4,j.of(this._iid).cacheContext.preference.get(this._metadataKey)];case 1:e=t.sent(),this._metadata={token:e?e.token:"",range:new er(e?e.range:{top:Number.MAX_SAFE_INTEGER,bottom:0}),completed:!!e&&e.completed},t.label=2;case 2:return[2,this._metadata]}}))}))},e.prototype.saveMetadata=function(){return g(this,void 0,void 0,(function(){return y(this,(function(e){switch(e.label){case 0:return this._metadata?[4,j.of(this._iid).cacheContext.preference.set(this._metadataKey,this._metadata)]:[3,2];case 1:return e.sent(),[2,!0];case 2:return[2,!1]}}))}))},e.prototype.clearMetaData=function(){return g(this,void 0,void 0,(function(){return y(this,(function(e){switch(e.label){case 0:return[4,j.of(this._iid).cacheContext.preference.remove(this._metadataKey)];case 1:return e.sent(),this._metadata=void 0,[2]}}))}))},e.prototype.resume=function(){var e,t,n=j.of(this._iid),r=n.logger;n.connectionManager.isConnected&&(r.debug("channel background sync resume()"),this._sync.start(null!==(t=null===(e=this._metadata)||void 0===e?void 0:e.token)&&void 0!==t?t:""))},e.prototype.pause=function(){j.of(this._iid).logger.debug("channel background sync stop()"),this._sync.stop()},e.prototype.close=function(){this.ref--,this.ref<=0&&(this.ref=0,this.pause(),this._connectionEventContext.close(),delete ls[this._iid])},e}(),ds={},ps=function(){function e(e){var t=e._iid,n=this;this.ref=0,this._iid=t;var r,s=j.of(this._iid),i=s.logger,a=s.sdkState,o=s.dispatcher;this._metadataKey=(r=a.userId,"sendbird:".concat(r,"@groupchannel/changelogs.meta"));var u=function(e){return"sendbird:".concat(e,"@groupchannel/changelogs")}(a.userId);this._sync=new ir(u,(function(){return g(n,void 0,void 0,(function(){var e,t,n,r,s,a,o,u;return y(this,(function(c){switch(c.label){case 0:return e={hasNext:!0,nextToken:0},[4,this.loadMetadata()];case 1:c.sent(),i.debug("channel changelog sync from",null===(a=this._metadata)||void 0===a?void 0:a.token),c.label=2;case 2:return c.trys.push([2,5,,8]),[4,rr.of(this._iid).getMyGroupChannelChangeLogs(null!==(u=null===(o=this._metadata)||void 0===o?void 0:o.token)&&void 0!==u?u:"",{includeEmpty:!0},ze.SYNC_CHANNEL_CHANGELOGS)];case 3:return t=c.sent(),n=t.hasMore,r=t.token,e.hasNext=n,e.nextToken=r,this._metadata&&(this._metadata.token=r),i.debug("channel changelog sync progress",e),[4,this.saveMetadata()];case 4:return c.sent(),[3,8];case 5:return s=c.sent(),i.debug("channel changelog sync error",s),s instanceof _&&s.isInvalidTokenError?[4,this.clearMetadata()]:[3,7];case 6:c.sent(),c.label=7;case 7:throw s;case 8:return[2,e]}}))}))})),this._connectionEventContext=o.on((function(e){if(e instanceof ee)if(e.stateType===te.CONNECTED)n.resume();else n.pause()}))}return e.of=function(t){return ds[t]||(ds[t]=new e({_iid:t})),ds[t].ref++,ds[t]},e.clear=function(e){ds[e]&&(ds[e].close(),delete ds[e])},e.prototype.loadMetadata=function(){return g(this,void 0,void 0,(function(){var e,t,n,r;return y(this,(function(s){switch(s.label){case 0:return this._metadata?[3,2]:(e=j.of(this._iid),t=e.cacheContext,n=e.firstConnectedAt,[4,t.preference.get(this._metadataKey)]);case 1:r=s.sent(),this._metadata={token:r?r.token:n},s.label=2;case 2:return[2,this._metadata]}}))}))},e.prototype.saveMetadata=function(){return g(this,void 0,void 0,(function(){return y(this,(function(e){switch(e.label){case 0:return this._metadata?[4,j.of(this._iid).cacheContext.preference.set(this._metadataKey,this._metadata)]:[3,2];case 1:return e.sent(),[2,!0];case 2:return[2,!1]}}))}))},e.prototype.clearMetadata=function(){return g(this,void 0,void 0,(function(){return y(this,(function(e){switch(e.label){case 0:return[4,j.of(this._iid).cacheContext.preference.remove(this._metadataKey)];case 1:return e.sent(),this._metadata=void 0,[2]}}))}))},e.prototype.resume=function(){j.of(this._iid).connectionManager.isConnected&&this._sync.start(0)},e.prototype.pause=function(){this._sync.stop()},e.prototype.close=function(){this.ref--,this.ref<=0&&(this.ref=0,this.pause(),this._connectionEventContext.close(),delete ds[this._iid])},e}(),fs=function(){function e(e,t){var n=t.filter,r=t.order,s=t.limit,i=this;this.channels=[],this._iid=e,this._key="gcc-".concat(oe()),this._isDisposed=!1,this._isGetRemoteChannelsSucceeded=!0,this.filter=null!=n?n:new Kt,this.order=null!=r?r:Ge.LATEST_LAST_MESSAGE,this._hasMore=!0,this._token="",this._limit=null!=s?s:ye;var a=j.of(this._iid),o=a.sdkState,u=a.cacheContext,c=a.dispatcher;u.localCacheEnabled&&(this._backgroundSync=hs.of(e),this._backgroundSync.resume()),this._changelogSync=ps.of(e),this._changelogSync.resume(),rr.of(this._iid).subscribeGroupChannelEvent(this._key,{onUpdate:function(e,t){if(tt(t)){var n=e.filter((function(e){return i.filter.match(e,o.userId)})),r=e.filter((function(e){return!i.filter.match(e,o.userId)})).map((function(e){return e.url}));n.length>0&&i._addChannelsToView(n,t),r.length>0&&i._removeChannelsFromView(r,t)}},onRemove:function(e,t){i._removeChannelsFromView(e,t)}}),j.of(this._iid).statLogCollector.put(new ie({type:ae.FEATURE_LOCALCACHE,data:{use_local_cache:u.localCacheEnabled,collection_interface:{group_channel:!0}}})),c.on((function(e){e instanceof ee&&(e.stateType===te.CONNECTED?i._isGetRemoteChannelsSucceeded||g(i,void 0,void 0,(function(){return y(this,(function(e){switch(e.label){case 0:return[4,this._revokeLoadMore()];case 1:return e.sent(),[2]}}))})):e.stateType===te.LOGOUT&&i.dispose())}))}return Object.defineProperty(e.prototype,"hasMore",{get:function(){return!this._isDisposed&&this._hasMore},enumerable:!1,configurable:!0}),e.prototype.setGroupChannelCollectionHandler=function(e){this._handler=e},e.prototype._addChannelsToView=function(e,t,n){var r,s,i,a,o=this;void 0===n&&(n=!1);var u=[],c=[],l=[];try{for(var h=C(e),d=h.next();!d.done;d=h.next()){var p=d.value,f=mr(this.channels,p);f>=0&&this.channels.splice(f,1);var _=vr(this.channels,p,this.order).place;if(f<0)_===this.channels.length?!n&&this._hasMore||(u.push(p),this.channels.push(p)):(u.push(p),this.channels.splice(_,0,p));else switch(t){case ze.EVENT_CHANNEL_UPDATED:case ze.EVENT_MESSAGE_RECEIVED:case ze.SYNC_CHANNEL_CHANGELOGS:case ze.EVENT_MESSAGE_SENT:_!==f&&this._hasMore&&_===this.channels.length?l.push(p):(this.channels.splice(_,0,p),c.push(p));break;default:this.channels.splice(_,0,p),c.push(p)}}}catch(e){r={error:e}}finally{try{d&&!d.done&&(s=h.return)&&s.call(h)}finally{if(r)throw r.error}}if(l.length>0)try{for(var m=C(l),v=m.next();!v.done;v=m.next()){p=v.value;var E=mr(this.channels,p);-1!==E&&this.channels.splice(E,1)}}catch(e){i={error:e}}finally{try{v&&!v.done&&(a=m.return)&&a.call(m)}finally{if(i)throw i.error}}tt(t)&&Y((function(){return g(o,void 0,void 0,(function(){var e,n,r,s;return y(this,(function(i){return e=new ar(t),u.length>0&&(null===(n=this._handler)||void 0===n?void 0:n.onChannelsAdded)&&this._handler.onChannelsAdded(e,u),c.length>0&&(null===(r=this._handler)||void 0===r?void 0:r.onChannelsUpdated)&&this._handler.onChannelsUpdated(e,c),l.length>0&&(null===(s=this._handler)||void 0===s?void 0:s.onChannelsDeleted)&&this._handler.onChannelsDeleted(e,l.map((function(e){return e.url}))),[2]}))}))}))},e.prototype._removeChannelsFromView=function(e,t){var n,r,s=this,i=[],a=function(e){var t=o.channels.findIndex((function(t){return t.url===e}));t>=0&&(i.push(o.channels[t].url),o.channels.splice(t,1))},o=this;try{for(var u=C(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 tt(t)&&i.length>0&&Y((function(){return g(s,void 0,void 0,(function(){var e,n;return y(this,(function(r){return e=new ar(t),(null===(n=this._handler)||void 0===n?void 0:n.onChannelsDeleted)&&this._handler.onChannelsDeleted(e,i),[2]}))}))})),i},e.prototype._getLocalChannels=function(){return g(this,void 0,void 0,(function(){var e,t;return y(this,(function(n){switch(n.label){case 0:return e=rr.of(this._iid),t=this.channels.length>0?function(e,t){var n,r,s,i;switch(t){case Ge.LATEST_LAST_MESSAGE:return null!==(r=null===(n=e.lastMessage)||void 0===n?void 0:n.createdAt)&&void 0!==r?r:e.createdAt;case Ge.CHRONOLOGICAL:return e.createdAt;case Ge.CHANNEL_NAME_ALPHABETICAL:return e.name;default:return null!==(i=null===(s=e.lastMessage)||void 0===s?void 0:s.createdAt)&&void 0!==i?i:e.createdAt}}(this.channels[this.channels.length-1],this.order):null,[4,e.getChannelsFromCache(t,this.filter,this.order,this._limit,t?this.channels[this.channels.length-1].url:void 0)];case 1:return[2,n.sent()]}}))}))},e.prototype._getRemoteChannels=function(){return g(this,void 0,void 0,(function(){var e,t,n;return y(this,(function(r){switch(r.label){case 0:return[4,rr.of(this._iid).getMyGroupChannels(this._token,s(i(i({},this.filter),{order:this.order})),this._limit)];case 1:return e=r.sent(),t=e.channels,n=e.token,this._token=n,this._hasMore=!!n,[2,t]}}))}))},e.prototype._revokeLoadMore=function(){return g(this,void 0,void 0,(function(){var e;return y(this,(function(t){switch(t.label){case 0:if(this._isDisposed)return[2];t.label=1;case 1:return t.trys.push([1,3,,4]),[4,this._getRemoteChannels()];case 2:return e=t.sent(),this._isGetRemoteChannelsSucceeded=!0,this._addChannelsToView(e,ze.REQUEST_CHANNEL,!0),[3,4];case 3:return t.sent(),this._isGetRemoteChannelsSucceeded=!1,[3,4];case 4:return[2]}}))}))},e.prototype.loadMore=function(){return g(this,void 0,void 0,(function(){var e,t,n=this;return y(this,(function(r){switch(r.label){case 0:if(this._isDisposed)throw new _({code:X.COLLECTION_DISPOSED,message:"Collection has been disposed."});return this._hasMore?(e=j.of(this._iid).cacheContext,t=[],e.localCacheEnabled&&this._backgroundSync.completed?[4,U((function(){return g(n,void 0,void 0,(function(){return y(this,(function(e){switch(e.label){case 0:return[4,this._getLocalChannels()];case 1:return t=e.sent(),[2]}}))}))}))]:[3,2]):[3,6];case 1:return r.sent(),this._hasMore=t.length>=this._limit,[3,5];case 2:return r.trys.push([2,4,,5]),[4,this._getRemoteChannels()];case 3:return t=r.sent(),this._isGetRemoteChannelsSucceeded=!0,[3,5];case 4:return r.sent(),this._isGetRemoteChannelsSucceeded=!1,[3,5];case 5:return this._addChannelsToView(t,ze.REQUEST_CHANNEL,!0),[2,t];case 6:return[2,[]]}}))}))},e.prototype.dispose=function(){var e,t;this._isDisposed||(this._isDisposed=!0,this.channels.length>0&&this.channels.splice(0,this.channels.length),null===(e=this._backgroundSync)||void 0===e||e.close(),null===(t=this._changelogSync)||void 0===t||t.close(),rr.of(this._iid).unsubscribeGroupChannelEvent(this._key))},e}(),_s=function(t){function n(e){var n=this,i=e.token,a=e.limit,o=e.order,u=e.includeEmpty,c=e.membershipFilter,l=e.channelNameContainsFilter,h=e.channelUrlsFilter,d=e.customTypesFilter,p=e.customTypeStartsWithFilter,f=e.superChannelFilter,_=e.metadataOrderKeyFilter,m=e.metadataKey,v=e.metadataValues,g=e.metadataValueStartsWith,y=e.includeFrozen,C=e.includeMetaData;return(n=t.call(this)||this).method=D.GET,n.path=O,n.params=r(s({token:i,limit:a,order:o,show_member:!0,show_read_receipt:!0,show_delivery_receipt:!0,show_empty:u,public_mode:xt.PUBLIC,public_membership_mode:c,name_contains:l,channel_urls:h,custom_types:d,custom_type_startswith:p,super_mode:f,metadata_order_key:_,metadata_key:m,metadata_values:v,metadata_value_startswith:g,show_frozen:y,show_metadata:C})),n}return e(n,t),n}(R),ms=function(t){function n(e,n){var r=t.call(this,e,n)||this;r.channels=[];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 cs(e,t)}))),r.ts="number"==typeof a?a:0,r}return e(n,t),n}(F);!function(e){e.ALL="all",e.JOINED="joined"}(us||(us={}));var vs=function(t){function n(e,n){var r,s,i,a,o,u,c,l,h,d,p,f,_,m,v=this;return(v=t.call(this,e,n)||this).includeEmpty=!1,v.includeFrozen=!0,v.includeMetaData=!0,v.channelUrlsFilter=null,v.customTypesFilter=null,v.customTypeStartsWithFilter=null,v.channelNameContainsFilter=null,v.membershipFilter=us.ALL,v.superChannelFilter=Ht.ALL,v.metadataKey=null,v.metadataValues=null,v.metadataOrderKeyFilter=null,v.metadataValueStartsWith=null,v.order=ot.CHRONOLOGICAL,v.includeEmpty=null!==(r=n.includeEmpty)&&void 0!==r&&r,v.includeFrozen=null===(s=n.includeFrozen)||void 0===s||s,v.includeMetaData=null===(i=n.includeMetaData)||void 0===i||i,v.channelUrlsFilter=null!==(a=n.channelUrlsFilter)&&void 0!==a?a:null,v.customTypesFilter=null!==(o=n.customTypesFilter)&&void 0!==o?o:null,v.customTypeStartsWithFilter=null!==(u=n.customTypeStartsWithFilter)&&void 0!==u?u:null,v.channelNameContainsFilter=null!==(c=n.channelNameContainsFilter)&&void 0!==c?c:null,v.membershipFilter=null!==(l=n.membershipFilter)&&void 0!==l?l:us.ALL,v.superChannelFilter=null!==(h=n.superChannelFilter)&&void 0!==h?h:Ht.ALL,v.metadataKey=null!==(d=n.metadataKey)&&void 0!==d?d:null,v.metadataValues=null!==(p=n.metadataValues)&&void 0!==p?p:null,v.metadataOrderKeyFilter=null!==(f=n.metadataOrderKeyFilter)&&void 0!==f?f:null,v.metadataValueStartsWith=null!==(_=n.metadataValueStartsWith)&&void 0!==_?_:null,v.order=null!==(m=n.order)&&void 0!==m?m:ot.CHRONOLOGICAL,v}return e(n,t),n.prototype._validate=function(){return t.prototype._validate.call(this)&&b("boolean",this.includeEmpty)&&b("boolean",this.includeFrozen)&&b("boolean",this.includeMetaData)&&b("string",this.channelNameContainsFilter,!0)&&E("string",this.channelUrlsFilter,!0)&&E("string",this.customTypesFilter,!0)&&b("string",this.customTypeStartsWithFilter,!0)&&a(us,this.membershipFilter)&&a(Ht,this.superChannelFilter)&&a(ot,this.order)&&b("string",this.metadataOrderKeyFilter,!0)&&b("string",this.metadataKey,!0)&&E("string",this.metadataValues,!0)&&b("string",this.metadataValueStartsWith,!0)},n.prototype.next=function(){return g(this,void 0,void 0,(function(){var e,t,n,r,a,o,u,c;return y(this,(function(l){switch(l.label){case 0:return this._validate()?this._isLoading?[3,3]:(e=[],this._hasNext?(this._isLoading=!0,t=j.of(this._iid),n=t.requestQueue,t.dispatcher,r=new _s(s(i(i({},this),{token:this._token}))),[4,n.send(r)]):[3,2]):[3,5];case 1:return a=l.sent(),o=a.as(ms),u=o.channels,c=o.token,this._token=c,this._hasNext=!!c,this._isLoading=!1,[2,u];case 2:return[2,e];case 3:throw _.queryInProgress;case 4:return[3,6];case 5:throw _.invalidParameters;case 6:return[2]}}))}))},n}(W),gs=function(t){function n(e){void 0===e&&(e={});var n=t.call(this)||this;return Object.keys(e).forEach((function(t){n.hasOwnProperty(t)&&(n[t]=e[t])})),n}return e(n,t),n}(function(t){function n(){var e=null!==t&&t.apply(this,arguments)||this;return e.onUserJoined=_e,e.onUserLeft=_e,e.onUserReceivedInvitation=_e,e.onUserDeclinedInvitation=_e,e.onChannelHidden=_e,e.onUnreadMemberStatusUpdated=_e,e.onUndeliveredMemberStatusUpdated=_e,e.onTypingStatusUpdated=_e,e.onPollUpdated=_e,e.onPollVoted=_e,e.onPollDeleted=_e,e.onPinnedMessageUpdated=_e,e}return e(n,t),n}(gt)),ys=function(t){function n(e){var n=this,i=e.token,a=e.limit,o=e.order,u=e.reverse,c=e.channelUrl,l=e.messageTypeFilter,h=e.scheduledStatus;return(n=t.call(this)||this).method=D.GET,n.path="".concat(H),n.params=r(s({token:i,limit:a,reverse:u,channel_url:c,order:o,message_type:l,status:h})),n}return e(n,t),n}(R),Cs=function(t){function n(e,n){var r=t.call(this,e,n)||this;r.scheduledMessages=[];var s=n.next,i=n.scheduled_messages;return r.token=s,r.scheduledMessages=i.map((function(t){return bt(e,t)})),r}return e(n,t),n}(F),Es=function(t){function n(e,n){var r,s,i,a,o,u=this;return(u=t.call(this,e,n)||this).channelUrl=null,u.order=null,u.reverse=!1,u.scheduledStatus=null,u.messageTypeFilter=N.ALL,u.channelUrl=null!==(r=n.channelUrl)&&void 0!==r?r:null,u.order=null!==(s=n.order)&&void 0!==s?s:null,u.reverse=null!==(i=n.reverse)&&void 0!==i&&i,u.scheduledStatus=null!==(a=n.scheduledStatus)&&void 0!==a?a:null,u.messageTypeFilter=null!==(o=n.messageTypeFilter)&&void 0!==o?o:N.ALL,u}return e(n,t),n.prototype._validate=function(){return t.prototype._validate.call(this)&&b("string",this.channelUrl,!0)&&(a(ut,this.order)||null===this.order)&&b("boolean",this.reverse)&&(E(yt,this.scheduledStatus)||null===this.scheduledStatus)&&a(N,this.messageTypeFilter)},n.prototype.next=function(){return g(this,void 0,void 0,(function(){var e,t,n,r,a,o;return y(this,(function(u){switch(u.label){case 0:return this._validate()?this._isLoading?[3,3]:this._hasNext?(this._isLoading=!0,e=j.of(this._iid).requestQueue,t=new ys(s(i(i({},this),{token:this._token}))),[4,e.send(t)]):[3,2]:[3,5];case 1:return n=u.sent(),r=n.as(Cs),a=r.scheduledMessages,o=r.token,this._token=o,this._hasNext=!!o,this._isLoading=!1,[2,a];case 2:return[2,[]];case 3:throw _.queryInProgress;case 4:return[3,6];case 5:throw _.invalidParameters;case 6:return[2]}}))}))},n}(W),bs=function(t){function n(){var e=null!==t&&t.apply(this,arguments)||this;return e.name="groupChannel",e}return e(n,t),n.prototype.init=function(e,n){var r=n.sdkState,s=n.dispatcher,i=n.sessionManager,a=n.requestQueue,o=n.logger,u=n.onlineDetector,c=n.cacheContext;t.prototype.init.call(this,e,{sdkState:r,dispatcher:s,sessionManager:i,requestQueue:a,logger:o,onlineDetector:u,cacheContext:c}),this._manager=new rr(e,{sdkState:r,cacheContext:c,dispatcher:s,sessionManager:i,requestQueue:a,logger:o})},n.prototype.createGroupChannelCollection=function(e){return void 0===e&&(e={}),new fs(this._iid,e)},n.prototype.createMyGroupChannelListQuery=function(e){return void 0===e&&(e={}),new $n(this._iid,e)},n.prototype.createPublicGroupChannelListQuery=function(e){return void 0===e&&(e={}),new vs(this._iid,e)},n.prototype.createScheduledMessageListQuery=function(e){return void 0===e&&(e={}),new Es(this._iid,e)},n.prototype.addGroupChannelHandler=function(e,t){f(b("string",e)&&t instanceof gs).throw(_.invalidParameters),this._manager.addHandler(e,t)},n.prototype.removeGroupChannelHandler=function(e){f(b("string",e)).throw(_.invalidParameters),this._manager.removeHandler(e)},n.prototype.removeAllGroupChannelHandlers=function(){this._manager.clearHandler()},n.prototype.buildGroupChannelFromSerializedData=function(e){return this._manager.buildGroupChannelFromSerializedData(e)},n.prototype.buildGroupChannelListQueryFromSerializedData=function(e){return this._manager.buildGroupChannelListQueryFromSerializedData(e)},n.prototype.buildMemberFromSerializedData=function(e){return this._manager.buildMemberFromSerializedData(e)},n.prototype.getChannel=function(e){return g(this,void 0,void 0,(function(){return y(this,(function(t){return f(b("string",e)).throw(_.invalidParameters),[2,this._manager.getChannel(e)]}))}))},n.prototype.getChannelWithoutCache=function(e){return g(this,void 0,void 0,(function(){return y(this,(function(t){return f(b("string",e)).throw(_.invalidParameters),[2,this._manager.getChannelWithoutCache(e)]}))}))},n.prototype.getMyGroupChannelChangeLogsByToken=function(e,t){return void 0===t&&(t={}),g(this,void 0,void 0,(function(){var n;return y(this,(function(r){switch(r.label){case 0:return n=i(i({},Zt),t),f(b("string",e)&&$t(n)).throw(_.invalidParameters),[4,this._manager.getMyGroupChannelChangeLogs(e,n)];case 1:return[2,r.sent()]}}))}))},n.prototype.getMyGroupChannelChangeLogsByTimestamp=function(e,t){return void 0===t&&(t={}),g(this,void 0,void 0,(function(){var n;return y(this,(function(r){switch(r.label){case 0:return n=i(i({},Zt),t),f(b("number",e)&&$t(n)).throw(_.invalidParameters),[4,this._manager.getMyGroupChannelChangeLogs(e,n)];case 1:return[2,r.sent()]}}))}))},n.prototype.getGroupChannelCount=function(e){return g(this,void 0,void 0,(function(){var t;return y(this,(function(n){return t=i(i({},en),e),f(tn(t)).throw(_.invalidParameters),[2,this._manager.getGroupChannelCount(t)]}))}))},n.prototype.getUnreadItemCount=function(e){return void 0===e&&(e={}),g(this,void 0,void 0,(function(){return y(this,(function(t){switch(t.label){case 0:return[4,this._manager.getUnreadItemCount(e)];case 1:return[2,t.sent()]}}))}))},n.prototype.getTotalUnreadChannelCount=function(){return g(this,void 0,void 0,(function(){return y(this,(function(e){switch(e.label){case 0:return[4,this._manager.getTotalUnreadChannelCount()];case 1:return[2,e.sent()]}}))}))},n.prototype.getTotalUnreadMessageCount=function(e){return void 0===e&&(e={}),g(this,void 0,void 0,(function(){return y(this,(function(t){switch(t.label){case 0:return[4,this._manager.getTotalUnreadMessageCount(e)];case 1:return[2,t.sent()]}}))}))},n.prototype.getTotalScheduledMessageCount=function(e){return void 0===e&&(e={}),g(this,void 0,void 0,(function(){return y(this,(function(t){switch(t.label){case 0:return[4,this._manager.getTotalScheduledMessageCount(e)];case 1:return[2,t.sent()]}}))}))},n.prototype.getSubscribedTotalUnreadMessageCount=function(){return this._manager.getSubscribedTotalUnreadMessageCount()},n.prototype.getSubscribedCustomTypeTotalUnreadMessageCount=function(){return this._manager.getSubscribedCustomTypeTotalUnreadMessageCount()},n.prototype.getSubscribedCustomTypeUnreadMessageCount=function(e){return this._manager.getSubscribedCustomTypeUnreadMessageCount(e)},n.prototype.createChannel=function(e){return void 0===e&&(e={}),g(this,void 0,void 0,(function(){var t;return y(this,(function(n){return t=i(i({},Jt),e),f(Xt(t)).throw(_.invalidParameters),[2,this._manager.createChannel(t)]}))}))},n.prototype.createDistinctChannelIfNotExist=function(e){return void 0===e&&(e={}),g(this,void 0,void 0,(function(){var t;return y(this,(function(n){return t=i(i({},Jt),e),f(Xt(t)).throw(_.invalidParameters),t&&(t.isDistinct=!0),[2,this.createChannel(t)]}))}))},n.prototype.createChannelWithUserIds=function(e,t,n,r,s,a){return void 0===t&&(t=!1),void 0===s&&(s=""),void 0===a&&(a=""),g(this,void 0,void 0,(function(){var o;return y(this,(function(u){return o=i(i({},Jt),{invitedUserIds:e,isDistinct:t,name:n,data:s,customType:a}),"string"==typeof r?o.coverUrl=r:o.coverImage=r,[2,this.createChannel(o)]}))}))},n.prototype.markAsReadAll=function(){return g(this,void 0,void 0,(function(){return y(this,(function(e){return this._manager.markAsReadAll(),[2]}))}))},n.prototype.markAsReadWithChannelUrls=function(e){return g(this,void 0,void 0,(function(){return y(this,(function(t){return f(E("string",e)).throw(_.invalidParameters),this._manager.markAsReadWithChannelUrls(e),[2]}))}))},n.prototype.markAsDelivered=function(e){return g(this,void 0,void 0,(function(){return y(this,(function(t){switch(t.label){case 0:return f(b("string",e)).throw(_.invalidParameters),[4,this.getChannel(e)];case 1:return[4,t.sent().markAsDelivered()];case 2:return t.sent(),[2]}}))}))},n}(me);export{ts as CountPreference,cs as GroupChannel,fs as GroupChannelCollection,ar as GroupChannelEventContext,Kt as GroupChannelFilter,gs as GroupChannelHandler,$n as GroupChannelListQuery,bs as GroupChannelModule,Wt as GroupChannelSearchField,Vt as HiddenChannelFilter,rs as HiddenState,zt as Member,Nr as MemberListOrder,Lr as MemberListQuery,Ft as MemberState,Ur as MemberStateFilter,us as MembershipFilter,Tr as MessageCollection,Sr as MessageCollectionInitHandler,sr as MessageCollectionInitPolicy,or as MessageEventContext,Mr as MutedMemberFilter,ns as MutedState,Ot as MyMemberStateFilter,qt as OperatorFilter,ss as PinnedMessage,os as PinnedMessageListQuery,xt as PublicChannelFilter,vs as PublicGroupChannelListQuery,Bt as QueryType,jt as ReadStatus,Es as ScheduledMessageListQuery,Ht as SuperChannelFilter,Gt as UnreadChannelFilter,Qt as UnreadItemKey}; diff --git a/index.js b/index.js index 4111e37..2b84d22 100644 --- a/index.js +++ b/index.js @@ -1 +1 @@ -import{i as e,a as t,_ as n,n as r,b as s,c as a,E as u,A as d,d as l,e as p,f as v,U as _,g as m,h as y,P as b,j as w,k,l as I,m as E,B as D,S as A,V as F,o as j,L as q,u as z,p as x,q as G,r as W,v as K,C as V,s as J,t as Z,w as $,x as ee,W as te,y as ne,z as re,D as ie,F as se,G as oe,H as ae,I as ue,J as ce,K as de,M as le,N as he}from"./lib/__bundle-a8606dd4.js";export{Q as CachedChannelInfo,O as ChannelType,C as ConnectionState,L as LocalCacheConfig,R as LogLevel,N as PushTemplate,H as PushTokenRegistrationState,P as PushTokenType,M as PushTriggerOption,T as Role,o as SendbirdChatOptions,S as SendbirdError,X as UIKitConfigInfo,U as User,Y as UserOnlineState}from"./lib/__bundle-a8606dd4.js";import{M as fe,a as pe}from"./lib/__bundle-8cd94b6f.js";export{P as Plugin}from"./lib/__bundle-8cd94b6f.js";import{PollModule as ve}from"./poll.js";import{N as _e,a as ge,b as me,c as ye,d as be,e as we}from"./lib/__bundle-e99277d8.js";export{B as BannedUserListQuery,f as BaseChannel,M as MutedUserListQuery,O as OperatorListQuery,R as ReportCategory,g as RestrictedUser,h as RestrictionInfo,i as RestrictionType}from"./lib/__bundle-e99277d8.js";import{g as ke,G as Ie,a as Ce,M as Se,N as Te,b as Pe,c as Ee,A as De,I as Ue,d as Oe,U as Le,e as Ne,f as Ae,D as Me,h as Re,i as Fe,j as je,R as qe,k as ze}from"./lib/__bundle-528a3094.js";export{c as MemoryStore}from"./lib/__bundle-528a3094.js";import{P as Qe,a as xe}from"./lib/__bundle-3707a8af.js";export{P as Participant}from"./lib/__bundle-ad3243e0.js";var He={profileImage:null,profileUrl:null,nickname:null},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 n(t,e),t}((function(){this.onSessionExpired=r,this.onSessionTokenRequired=function(e){return e(null)},this.onSessionError=r,this.onSessionRefreshed=r,this.onSessionClosed=r})),We=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 n(t,e),t}((function(){this.onConnected=r,this.onReconnectStarted=r,this.onReconnectSucceeded=r,this.onReconnectFailed=r,this.onDisconnected=r})),Ke=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 n(t,e),t}((function(){this.onFriendsDiscovered=r,this.onTotalUnreadMessageCountUpdated=r})),Ve=function(e,t){return function(n,r){if(1===n)e.clear().then((function(){t.clear().then((function(){(function(e){return s(void 0,void 0,void 0,(function(){return a(this,(function(t){return[2,e.commitSchema([{collectionName:_e,keyName:ge,index:[ke(Ie.LATEST_LAST_MESSAGE),ke(Ie.CHRONOLOGICAL),ke(Ie.CHANNEL_NAME_ALPHABETICAL)]},{collectionName:me,keyName:ye,index:[Ce(Se.CHANNEL_LATEST),Ce(Se.NEWEST_CHILD_MESSAGE)]},{collectionName:Te,keyName:Pe,index:[Ce(Se.CHANNEL_LATEST),Ce(Se.NEWEST_CHILD_MESSAGE)]},{collectionName:be,keyName:we}])]}))}))})(e).then((function(){return r()})).catch((function(e){return r(e)}))})).catch((function(e){return r(e)}))})).catch((function(e){return r(e)}));else r()}},Be=function(){return"undefined"!=typeof document?document.visibilityState:"visible"},Je=function(e){function t(t){var n=t.getVisibilityState,r=void 0===n?Be:n,i=t.initialState,s=void 0===i?"visible":i,o=t.isEnabled,a=void 0===o||o,u=t.pauseCheckDelay,c=void 0===u?3e4:u,d=e.call(this)||this;return d._pauseCheckDelay=3e4,d._pauseDelayTimer=null,d._currentState="visible",d._getVisibilityState=r,d._pauseCheckDelay=c,d._currentState=s,d._isEnabled=a,d._boundToggleState=d._toggleState.bind(d),d}return n(t,e),Object.defineProperty(t.prototype,"currentState",{get:function(){return this._currentState},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"isAvailable",{get:function(){return"undefined"!=typeof window&&!!window.addEventListener&&!!window.removeEventListener},enumerable:!1,configurable:!0}),t.prototype._toggleState=function(){var e=this,t=this._getVisibilityState();"hidden"!==t?"hidden"===this._currentState&&(this._pauseDelayTimer&&(clearTimeout(this._pauseDelayTimer),this._pauseDelayTimer=null),this.dispatch("resume")):"hidden"!==this._currentState&&(this._pauseDelayTimer=setTimeout((function(){e._pauseDelayTimer=null,e.dispatch("pause")}),this._pauseCheckDelay)),this._currentState=t},t.prototype.start=function(){this._isEnabled&&this.isAvailable&&(this._boundToggleState=this._toggleState.bind(this),window.addEventListener("visibilitychange",this._boundToggleState,{capture:!0}))},t.prototype.stop=function(){this._isEnabled&&this.isAvailable&&this._boundToggleState&&window.removeEventListener("visibilitychange",this._boundToggleState,{capture:!0})},t}(u),Xe=function(){function e(e){var t=e.logger,n=e.connectionDelegate,r=void 0===n?null:n,i=this;this._onlineWorker=function(){var e;return null===(e=i.connectionDelegate)||void 0===e?void 0:e.reconnect()},this._offlineWorker=function(){var e;return null===(e=i.connectionDelegate)||void 0===e?void 0:e.disconnect()},this.unsubscribes=[],this._onlineListener=function(e){if(i.isAvailableOnWeb)return window.addEventListener("online",e),function(){return window.removeEventListener("online",e,!1)}},this._offlineListener=function(e){if(i.isAvailableOnWeb)return window.addEventListener("offline",e),function(){return window.removeEventListener("offline",e,!1)}},this.logger=t,r&&(this.connectionDelegate=r)}return Object.defineProperty(e.prototype,"isAvailableOnWeb",{get:function(){return"undefined"!=typeof window&&window.addEventListener&&"ononline"in window&&"onoffline"in window&&"undefined"!=typeof navigator&&void 0!==navigator.onLine},enumerable:!1,configurable:!0}),e.prototype.setOnlineListener=function(e){Boolean(e)&&"function"==typeof e&&(this._onlineListener=e)},e.prototype.setOfflineListener=function(e){Boolean(e)&&"function"==typeof e&&(this._offlineListener=e)},e.prototype.start=function(){this.unsubscribes=[this._onlineListener(this._onlineWorker),this._offlineListener(this._offlineWorker)]},e.prototype.stop=function(){var e=this;this.unsubscribes.forEach((function(t){try{null==t||t()}catch(t){e.logger.warn(t.message)}})),this.unsubscribes=[]},e.prototype.isOnline=function(){return s(this,void 0,void 0,(function(){return a(this,(function(e){return this.isAvailableOnWeb?[2,navigator.onLine]:[2,new Promise((function(e){fetch("https://www.google.com",{method:d.GET,mode:"no-cors"}).then((function(){return e(!0)})).catch((function(){return e(!1)}))}))]}))}))},e}(),Ye=function(e){function t(t){var n=t.userId,r=t.nickname,i=void 0===r?null:r,s=t.profileUrl,o=void 0===s?null:s,a=t.profileImage,u=void 0===a?null:a,c=t.preferredLanguages,h=void 0===c?null:c,f=e.call(this)||this;return f.method=d.PUT,f.path="".concat(l,"/").concat(encodeURIComponent(n)),f.params=p({nickname:i,profile_url:o,profile_file:u,preferred_languages:h}),f}return n(t,e),t}(v),Ze=function(e){function t(t,n){var r=e.call(this,t,n)||this;return r.user=null,r.user=new _(t,m({},n)),r}return n(t,e),t}(y),$e=function(e){function t(t){var n=t.userId,r=t.token,i=e.call(this)||this;return i.method=d.POST,i.path="".concat(l,"/").concat(encodeURIComponent(n),"/push/apns"),i.params={apns_device_token:r,always_push:!0},i}return n(t,e),t}(v);!function(e){function t(t,n){var r=e.call(this,t,n)||this;return r.token=n.token,r.type=n.type?b[n.type.toLowerCase()]:b.UNKNOWN,r.user=new _(t,n.user),r}n(t,e)}(y);var et=function(e){function t(t){var n=t.userId,r=t.token,i=e.call(this)||this;return i.method=d.POST,i.path="".concat(l,"/").concat(encodeURIComponent(n),"/push/gcm"),i.params={gcm_reg_token:r,always_push:!0},i}return n(t,e),t}(v);!function(e){function t(t,n){var r=e.call(this,t,n)||this;return r.token=n.token,r.type=n.type?b[n.type.toLowerCase()]:b.UNKNOWN,r.user=new _(t,n.user),r}n(t,e)}(y);var tt=function(e){function t(t){var n=t.userId,r=t.token,i=e.call(this)||this;return i.method=d.DELETE,i.path="".concat(l,"/").concat(encodeURIComponent(n),"/push/apns/").concat(encodeURIComponent(r)),i}return n(t,e),t}(v);!function(e){function t(t,n){var r=e.call(this,t,n)||this;return r.token=n.token,r.user=new _(t,n.user),r.lastDeletedAt=n.device_token_last_deleted_at,r}n(t,e)}(y);var nt=function(e){function t(t){var n=t.userId,r=t.token,i=e.call(this)||this;return i.method=d.DELETE,i.path="".concat(l,"/").concat(encodeURIComponent(n),"/push/gcm/").concat(encodeURIComponent(r)),i}return n(t,e),t}(v);!function(e){function t(t,n){var r=e.call(this,t,n)||this;return r.token=n.token,r.user=new _(t,n.user),r.lastDeletedAt=n.device_token_last_deleted_at,r}n(t,e)}(y);var rt=function(e){function t(t){var n=t.userId,r=e.call(this)||this;return r.method=d.DELETE,r.path="".concat(l,"/").concat(encodeURIComponent(n),"/push/apns"),r}return n(t,e),t}(v);!function(e){function t(t,n){var r=e.call(this,t,n)||this;return r.type=n.type?b[n.type.toLowerCase()]:b.UNKNOWN,r.user=new _(t,n.user),r.lastDeletedAt=n.device_token_last_deleted_at,r}n(t,e)}(y);var it=function(e){function t(t){var n=t.userId,r=e.call(this)||this;return r.method=d.DELETE,r.path="".concat(l,"/").concat(encodeURIComponent(n),"/push/gcm"),r}return n(t,e),t}(v);!function(e){function t(t,n){var r=e.call(this,t,n)||this;return r.type=n.type?b[n.type.toLowerCase()]:b.UNKNOWN,r.user=new _(t,n.user),r.lastDeletedAt=n.device_token_last_deleted_at,r}n(t,e)}(y);var st=function(e){function t(t){var n=t.userId,r=t.type,i=t.token,s=t.ts,o=e.call(this)||this;return o.method=d.GET,o.path="".concat(l,"/").concat(encodeURIComponent(n),"/push/").concat(encodeURIComponent(r),"/device_tokens"),o.params={created_ts:s,token:i},o}return n(t,e),t}(v),ot=function(e){function t(t,n){var r=e.call(this,t,n)||this;return r.pushTokens={type:n.type?b[n.type.toLowerCase()]:b.UNKNOWN,deviceTokens:n.device_tokens,hasMore:n.has_more,token:n.token},r}return n(t,e),t}(y),at=function(e){function t(t){var n=t.userId,r=e.call(this)||this;return r.method=d.GET,r.path="".concat(l,"/").concat(encodeURIComponent(n),"/channel_invitation_preference"),r}return n(t,e),t}(v),ut=function(e){function t(t,n){var r=e.call(this,t,n)||this;return r.autoAccept=n.auto_accept,r}return n(t,e),t}(y),ct=function(e){function t(t){var n=t.userId,r=t.willAutoAccept,i=e.call(this)||this;return i.method=d.PUT,i.path="".concat(l,"/").concat(encodeURIComponent(n),"/channel_invitation_preference"),i.params={auto_accept:r},i}return n(t,e),t}(v),dt=function(e){function t(t,n){var r=e.call(this,t,n)||this;return r.autoAccept=n.auto_accept,r}return n(t,e),t}(y),lt=function(e){function t(t){var n=t.userId,r=e.call(this)||this;return r.method=d.GET,r.path="".concat(l,"/").concat(encodeURIComponent(n),"/push_preference"),r}return n(t,e),t}(v),ht=function(e){function t(t,n){var r=e.call(this,t,n)||this;return r.preference={doNotDisturbOn:n.do_not_disturb,startHour:n.start_hour,startMin:n.start_min,endHour:n.end_hour,endMin:n.end_min,timezone:n.timezone},r}return n(t,e),t}(y),ft=function(e){function t(t){var n=t.userId,r=t.doNotDisturbOn,i=t.startHour,s=t.startMin,o=t.endHour,a=t.endMin,u=t.timezone,c=e.call(this)||this;return c.method=d.PUT,c.path="".concat(l,"/").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 n(t,e),t}(v),pt=function(e){function t(t,n){var r=e.call(this,t,n)||this;return r.preference={doNotDisturbOn:n.do_not_disturb,startHour:n.start_hour,startMin:n.start_min,endHour:n.end_hour,endMin:n.end_min,timezone:n.timezone},r}return n(t,e),t}(y),vt=function(e){function t(t){var n=t.userId,r=e.call(this)||this;return r.method=d.GET,r.path="".concat(l,"/").concat(encodeURIComponent(n),"/push_preference"),r}return n(t,e),t}(v),_t=function(e){function t(t,n){var r=e.call(this,t,n)||this;return r.snoozePeriod={isSnoozeOn:n.snooze_enabled},"number"==typeof n.snooze_start_ts&&(r.snoozePeriod.startTs=n.snooze_start_ts),"number"==typeof n.snooze_end_ts&&(r.snoozePeriod.endTs=n.snooze_end_ts),r}return n(t,e),t}(y),gt=function(e){function t(t){var n=t.userId,r=t.snoozeOn,i=t.startTs,s=t.endTs,o=e.call(this)||this;return o.method=d.PUT,o.path="".concat(l,"/").concat(encodeURIComponent(n),"/push_preference"),o.params={snooze_enabled:r,snooze_start_ts:i,snooze_end_ts:s},o}return n(t,e),t}(v),mt=function(e){function t(t,n){var r=e.call(this,t,n)||this;return r.snoozePeriod={isSnoozeOn:n.snooze_enabled},"number"==typeof n.snooze_start_ts&&(r.snoozePeriod.startTs=n.snooze_start_ts),"number"==typeof n.snooze_end_ts&&(r.snoozePeriod.endTs=n.snooze_end_ts),r}return n(t,e),t}(y),yt=function(e){function t(t){var n=t.userId,r=t.blockedUserId,i=e.call(this)||this;return i.method=d.POST,i.path="".concat(l,"/").concat(encodeURIComponent(n),"/block"),i.params={target_id:r},i}return n(t,e),t}(v);!function(e){function t(t,n){var r=e.call(this,t,n)||this;return r.user=new _(t,n),r}n(t,e)}(y);var bt=function(e){function t(t){var n=t.userId,r=t.unblockedUserId,i=e.call(this)||this;return i.method=d.DELETE,i.path="".concat(l,"/").concat(encodeURIComponent(n),"/block/").concat(encodeURIComponent(r)),i}return n(t,e),t}(v);!function(e){function t(){return null!==e&&e.apply(this,arguments)||this}n(t,e)}(y);var wt=function(e){function t(t){var n=t.userId,r=e.call(this)||this;return r.method=d.GET,r.path="".concat(l,"/").concat(encodeURIComponent(n),"/push_preference"),r}return n(t,e),t}(v),kt=function(e){function t(t,n){var r=e.call(this,t,n)||this;return r.pushTriggerOption=n.push_trigger_option,r}return n(t,e),t}(y),It=function(e){function t(t){var n=t.userId,r=t.pushTriggerOption,i=e.call(this)||this;return i.method=d.PUT,i.path="".concat(l,"/").concat(encodeURIComponent(n),"/push_preference"),i.params={push_trigger_option:r},i}return n(t,e),t}(v),Ct=function(e){function t(t,n){var r=e.call(this,t,n)||this;return r.pushTriggerOption=n.push_trigger_option,r}return n(t,e),t}(y),St=function(e){function t(t){var n=t.userId,r=e.call(this)||this;return r.method=d.GET,r.path="".concat(l,"/").concat(encodeURIComponent(n),"/push/template"),r}return n(t,e),t}(v),Tt=function(e){function t(t,n){var r=e.call(this,t,n)||this;return r.name=n.name,r}return n(t,e),t}(y),Pt=function(e){function t(t){var n=t.userId,r=t.templateName,i=e.call(this)||this;return i.method=d.PUT,i.path="".concat(l,"/").concat(encodeURIComponent(n),"/push/template"),i.params={name:r},i}return n(t,e),t}(v),Et=function(e){function t(t,n){var r=e.call(this,t,n)||this;return r.name=n.name,r}return n(t,e),t}(y),Dt=function(e){function t(t){var n=t.userId,r=t.token,i=e.call(this)||this;return i.method=d.GET,i.path="".concat(l,"/").concat(encodeURIComponent(n),"/friends/changelogs"),i.params={token:r},i}return n(t,e),t}(v),Ut=function(e){function t(t,n){var r=e.call(this,t,n)||this;return r.changelogs={addedUsers:n.added.map((function(e){return new _(t,e)})),updatedUsers:n.updated.map((function(e){return new _(t,e)})),deletedUserIds:n.deleted,hasMore:n.has_more,token:n.next},r}return n(t,e),t}(y),Ot=function(e){function t(t){var n=t.userId,r=t.discoveries,i=e.call(this)||this;return i.method=d.PUT,i.path="".concat(l,"/").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 n(t,e),t}(v),Lt=function(e){function t(t,n){var r=e.call(this,t,n)||this;return r.friendDiscoveryRequestId=n.friend_discovery_request_id,r}return n(t,e),t}(y),Nt=function(e){function t(t){var n=t.userId,r=t.discoveryKeys,i=e.call(this)||this;return i.method=d.DELETE,i.path="".concat(l,"/").concat(encodeURIComponent(n),"/friend_discoveries"),i.params={friend_discovery_keys:r},i}return n(t,e),t}(v);!function(e){function t(){return null!==e&&e.apply(this,arguments)||this}n(t,e)}(y);var At=function(e){function t(t){var n=t.userId,r=t.userIds,i=e.call(this)||this;return i.method=d.POST,i.path="".concat(l,"/").concat(encodeURIComponent(n),"/friends"),i.params={user_ids:r},i}return n(t,e),t}(v),Mt=function(e){function t(t,n){var r=e.call(this,t,n)||this;return r.users=n.users.map((function(e){return new _(t,e)})),r}return n(t,e),t}(y),Rt=function(e){function t(t){var n=t.userId,r=t.userIds,i=e.call(this)||this;return i.method=d.DELETE,i.path="".concat(l,"/").concat(encodeURIComponent(n),"/friends"),i.params={user_ids:r},i}return n(t,e),t}(v);!function(e){function t(){return null!==e&&e.apply(this,arguments)||this}n(t,e)}(y);var Ft=function(e){function t(t){var n=t.userId,r=e.call(this)||this;return r.method=d.GET,r.path="".concat(l,"/").concat(n,"/allow_friend_discovery"),r.params={},r}return n(t,e),t}(v),jt=function(e){function t(t,n){var r=e.call(this,t,n)||this;return r.allowFriendDiscovery=n.allow_friend_discovery,r}return n(t,e),t}(y),qt=function(e){function t(t){var n=t.userId,r=t.allowFriendDiscovery,i=e.call(this)||this;return i.method=d.PUT,i.path="".concat(l,"/").concat(n,"/allow_friend_discovery"),i.params={allow_friend_discovery:r},i}return n(t,e),t}(v);!function(e){function t(){return null!==e&&e.apply(this,arguments)||this}n(t,e)}(y);var zt=function(e){this.key=null,this.url=null,this.key=e.key,this.url=e.url},Qt=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 zt(e)})):[]},xt=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 Qt(e)})):[]},Ht=function(e){function t(){var t=e.call(this)||this;return t.method=d.GET,t.path=w,t}return n(t,e),t}(v),Gt=function(e){function t(t,n){var r=e.call(this,t,n)||this;return r.emojiContainer=new xt(n),r}return n(t,e),t}(y),Wt=function(e){function t(t){var n=t.categoryId,r=e.call(this)||this;return r.method=d.GET,r.path="".concat(w,"/").concat(n),r}return n(t,e),t}(v),Kt=function(e){function t(t,n){var r=e.call(this,t,n)||this;return r.emojiCategory=new Qt(n),r}return n(t,e),t}(y),Vt=function(e){function t(t){var n=t.key,r=e.call(this)||this;return r.method=d.GET,r.path="".concat(k,"/").concat(n),r}return n(t,e),t}(v),Bt=function(e){function t(t,n){var r=e.call(this,t,n)||this;return r.emoji=new zt(n),r}return n(t,e),t}(y),Jt=function(e){function t(){var t=e.call(this)||this;return t.method=d.GET,t.path="".concat(I),t}return n(t,e),t}(v),Xt=function(e){function t(t,n){var r,i=this,s=null!=n?n:{};return(i=e.call(this,t,n)||this).uikitConfiguration={string:JSON.stringify(s),json:s},i.updatedAt=null!==(r=null==n?void 0:n.updated_at)&&void 0!==r?r:0,i}return n(t,e),t}(y),Yt=function(e){function t(t){var n=t.limit,r=t.token,i=t.userIdsFilter,s=t.metaDataKeyFilter,o=t.metaDataValuesFilter,a=t.nicknameStartsWithFilter,u=e.call(this)||this;return u.method=d.GET,u.path=l,u.params=p({limit:n,token:r,user_ids:i,metadatakey:s,metadatavalues_in:o,nickname_startswith:a}),u}return n(t,e),t}(v),Zt=function(e){function t(t,n){var r=e.call(this,t,n)||this;return r.users=n.users.map((function(e){return new _(t,e)})),r.next=n.next,r}return n(t,e),t}(y),$t=function(e){function r(t,n){var r,i,s,o=this;return(o=e.call(this,t,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 n(r,e),r.prototype._validate=function(){return e.prototype._validate.call(this)&&E("string",this.userIdsFilter,!0)&&t("string",this.metaDataKeyFilter,!0)&&E("string",this.metaDataValuesFilter,!0)&&t("string",this.metaDataKeyFilter,!0)},r.prototype.next=function(){return s(this,void 0,void 0,(function(){var e,t,n,r,i,s;return a(this,(function(o){switch(o.label){case 0:return this._validate()?this._isLoading?[3,3]:this._hasNext?(this._isLoading=!0,e=F.of(this._iid).requestQueue,t=new Yt(m(m({},this),{token:this._token})),[4,e.send(t)]):[3,2]:[3,5];case 1:return n=o.sent(),r=n.as(Zt),i=r.users,s=r.next,this._token=s,this._hasNext=!!s,this._isLoading=!1,[2,i];case 2:return[2,[]];case 3:throw A.queryInProgress;case 4:return[3,6];case 5:throw A.invalidParameters;case 6:return[2]}}))}))},r}(D),en=function(e){function t(t){var n=t.userId,r=t.limit,i=t.token,s=t.userIdsFilter,o=e.call(this)||this;return o.method=d.GET,o.path="".concat(l,"/").concat(n,"/block"),o.params=p({limit:r,token:i,user_ids:s}),o}return n(t,e),t}(v),tn=function(e){function t(t,n){var r=e.call(this,t,n)||this;return r.users=n.users.map((function(e){return new _(t,e)})),r.next=n.next,r}return n(t,e),t}(y),nn=function(e){function t(t,n){var r,i=this;return(i=e.call(this,t,n)||this).userIdsFilter=null,i.userIdsFilter=null!==(r=n.userIdsFilter)&&void 0!==r?r:null,i}return n(t,e),t.prototype._validate=function(){return e.prototype._validate.call(this)&&E("string",this.userIdsFilter,!0)},t.prototype.next=function(){return s(this,void 0,void 0,(function(){var e,t,n,r,i,s,o,u;return a(this,(function(a){switch(a.label){case 0:return this._validate()?this._isLoading?[3,3]:this._hasNext?(this._isLoading=!0,e=F.of(this._iid),t=e.sdkState,n=e.requestQueue,r=new en(m(m({},this),{userId:t.userId,token:this._token})),[4,n.send(r)]):[3,2]:[3,5];case 1:return i=a.sent(),s=i.as(tn),o=s.users,u=s.next,this._token=u,this._hasNext=!!u,this._isLoading=!1,[2,o];case 2:return[2,[]];case 3:throw A.queryInProgress;case 4:return[3,6];case 5:throw A.invalidParameters;case 6:return[2]}}))}))},t}(D),rn=function(e){function t(t){var n=t.userId,r=t.limit,i=t.token,s=e.call(this)||this;return s.method=d.GET,s.path="".concat(l,"/").concat(encodeURIComponent(n),"/friends"),s.params={limit:r,token:i},s}return n(t,e),t}(v),sn=function(e){function t(t,n){var r=e.call(this,t,n)||this;return r.hasMore=n.has_more,r.users=n.users.map((function(e){return new _(t,e)})),r.next=n.next,r}return n(t,e),t}(y),on=function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return n(t,e),t.prototype._validate=function(){return e.prototype._validate.call(this)},t.prototype.next=function(){return s(this,void 0,void 0,(function(){var e,t,n,r,i,s,o,u,c;return a(this,(function(a){switch(a.label){case 0:return this._validate()?this._isLoading?[3,3]:this._hasNext?(this._isLoading=!0,e=F.of(this._iid),t=e.sdkState,n=e.requestQueue,r=new rn(m(m({},this),{userId:t.userId,token:this._token})),[4,n.send(r)]):[3,2]:[3,5];case 1:return i=a.sent(),s=i.as(sn),o=s.users,u=s.hasMore,c=s.next,this._token=c,this._hasNext=u,this._isLoading=!1,[2,o];case 2:return[2,[]];case 3:throw A.queryInProgress;case 4:return[3,6];case 5:throw A.invalidParameters;case 6:return[2]}}))}))},t}(D),an=null,un=function(){function n(e,t,n){var r=this;this._storeInitialized=!1,this._fcmPushToken=null,this._apnsPushToken=null,this._iid=e,this.options=t;var i=F.of(e),o=i.sdkState,u=i.cacheContext,c=i.dispatcher,d=i.sessionManager,l=i.requestQueue,h=i.logger,f=i.userEventHandlers,p=i.appStateToggleEnabled;this._onlineDetector=new Xe({logger:h,connectionDelegate:{reconnect:function(){var t=F.of(e),n=t.sdkState,r=t.connectionManager,i=t.sessionManager;i.auth.hasSession?"foreground"===n.appState&&r.resetAndReconnect():r.connect(i.auth.authToken)},disconnect:function(){F.of(e).connectionManager.disconnect()}}});var v=new Oe(e,{localCacheEnabled:u.localCacheEnabled,dispatcher:c,sdkState:o,logger:h});n.forEach((function(t){t.init(e,{sdkState:o,cacheContext:u,dispatcher:c,sessionManager:d,requestQueue:l,logger:h,onlineDetector:r._onlineDetector}),r[t.name]=t})),this._appStateChangeDetector=new Je({isEnabled:p}),this._appStateChangeDetector.on("resume",(function(){h.debug("the page resumes from freeze"),r.setForegroundState()})).on("pause",(function(){h.debug("the page freezes"),r.setBackgroundState()})),c.on((function(t){if(t instanceof $){if(t.stateType===ee.CONNECTED)v.processNonAutoResendRegisteredPendingMessages()}else if(t instanceof te){if("USEV"===t.code){var n=t.as(Le).event;if(n.category===Ne.FRIEND_DISCOVERED){var i=Ae.getDataAsFriendDiscoveredEvent(e,n).friendDiscoveries;ne((function(){return s(r,void 0,void 0,(function(){return a(this,(function(e){return[2,f.forEach((function(e){e.onFriendsDiscovered(i)}))]}))}))}))}}}else if(t instanceof re){var c=F.of(r._iid).subscribedUnreadMessageCount,d=!1,l=t.ts;if("number"==typeof l&&l>c.ts){if(c.all!==t.all&&(d=!0),c.all=t.all>=0?t.all:0,t.customTypes)for(var p in t.customTypes)c.customTypes[p]!==t.customTypes[p]&&(d=!0),c.customTypes[p]=t.customTypes[p];d=d&&c.ts>0,c.ts=l}d&&ne((function(){return s(r,void 0,void 0,(function(){return a(this,(function(e){return[2,f.forEach((function(e){e.onTotalUnreadMessageCountUpdated(c.all,c.customTypes)}))]}))}))}))}else t instanceof ie?u.preference.set(r._getUserProfileCacheKey(o.userId),se.payloadify(t.userProfile)):t instanceof oe&&t.error&&t.error.isSessionRevokedError&&(h.debug("session revoked."),r.disconnect())}))}return n.init=function(e){var t=e.appId,r=e.appVersion,i=void 0===r?null:r,s=e.modules,o=void 0===s?[]:s,a=e.options,u=void 0===a?new j:a,c=e.debugMode,d=void 0!==c&&c,l=e.customApiHost,h=e.customWebSocketHost,f=e.newInstance,p=void 0!==f&&f,v=e.logLevel,_=e.localCacheEnabled,g=void 0!==_&&_,m=e.localCacheConfig,y=void 0===m?new q:m,b=e.localCacheEncryption,w=e.useAsyncStorageStore,k=void 0===w?null:w,I=e.appStateToggleEnabled,C=void 0===I||I;if(!an||p){var S="su-".concat(z()),T=null!=b?b:{encrypt:function(e){return e},decrypt:function(e){return e}},P=new Ee({encryption:T});d||(P=x()?k?new De({AsyncStorage:k,encryption:T}):new Ee({encryption:T}):new Ue({encryption:T})),new F(S,{appId:t,appVersion:i,options:u,apiHost:null!=l?l:"https://api-".concat(t,".sendbird.com"),websocketHost:null!=h?h:"wss://ws-".concat(t,".sendbird.com"),store:P,encryption:T,logLevel:v,localCacheEnabled:g,localCacheConfig:y,debugMode:d,appStateToggleEnabled:C});var E=[new fe,new ve],D=new n(S,u,G(G([],W(o),!1),W(E),!1));return an||(an=D),D}return an},Object.defineProperty(n,"instance",{get:function(){return an},enumerable:!1,configurable:!0}),Object.defineProperty(n,"version",{get:function(){return K},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"appId",{get:function(){return F.of(this._iid).sdkState.appId},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"appInfo",{get:function(){return F.of(this._iid).appInfo},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"appVersion",{get:function(){var e;return null!==(e=F.of(this._iid).sdkState.appVersion)&&void 0!==e?e:""},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"debugMode",{get:function(){return F.of(this._iid).debugMode},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"logLevel",{get:function(){return F.of(this._iid).logger.level},set:function(e){F.of(this._iid).logger.level=e},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"isCacheEnabled",{get:function(){return F.of(this._iid).cacheContext.localCacheEnabled},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"localCacheConfig",{get:function(){var e=F.of(this._iid).cacheContext;return e.localCacheEnabled?e.localCacheConfig:null},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"ekey",{get:function(){return F.of(this._iid).sessionManager.ekey},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"currentUser",{get:function(){var e;return null!==(e=F.of(this._iid).sessionManager.currentUser)&&void 0!==e?e:null},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"connectionState",{get:function(){var e=F.of(this._iid).connectionManager;return e.isConnected?V.OPEN:e.isConnecting?V.CONNECTING:V.CLOSED},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"lastConnectedAt",{get:function(){var e=F.of(this._iid),t=e.connectedAt;return e.connectionManager.isConnected?t:0},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"fcmPushToken",{get:function(){return this._fcmPushToken},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"apnsPushToken",{get:function(){return this._apnsPushToken},enumerable:!1,configurable:!0}),n.prototype._getCurrentPreferenceVersion=function(){return 1},n.prototype._getPreferenceCacheKey=function(e){return"sendbird@".concat(this.appId,"/").concat(e,".pref")},n.prototype._getUserProfileCacheKey=function(e){return"sendbird@".concat(this.appId,"/").concat(e,".profile")},n.prototype.getMemoryStoreForDebugging=function(){var e=F.of(this._iid),t=e.debugMode,n=e.cacheContext;if(t)return n.store instanceof Ee?n.store:null;throw A.debugModeRequired},n.prototype.addExtension=function(e,t){var n=F.of(this._iid).sdkState;["sb_uikit","sb_syncmanager","device-os-platform"].indexOf(e)>-1&&(n.extensions[e]=t)},n.prototype.setOnlineListener=function(e){this._onlineDetector.setOnlineListener(e)},n.prototype.setOfflineListener=function(e){this._onlineDetector.setOfflineListener(e)},n.prototype._safeInitializeStore=function(e){return s(this,void 0,void 0,(function(){var t;return a(this,(function(n){switch(n.label){case 0:t=F.of(this._iid).cacheContext,n.label=1;case 1:return n.trys.push([1,3,,5]),[4,t.store.init(e)];case 2:return n.sent(),this._storeInitialized=!0,[3,5];case 3:return n.sent(),t.store=new Ee,[4,this._safeInitializeStore(e)];case 4:return n.sent(),[3,5];case 5:return[2]}}))}))},n.prototype.initializeCache=function(e){return s(this,void 0,void 0,(function(){var t,n,r,i,s,o,u,c,d;return a(this,(function(a){switch(a.label){case 0:return t=F.of(this._iid),n=t.sdkState,r=t.cacheContext,i=t.connectionManager,s=t.dispatcher,o=t.logger,n.userId&&n.userId===e?[3,10]:[4,i.logout()];case 1:if(a.sent(),u="sendbird@".concat(n.appId,"/").concat(e,".db"),!r.localCacheEnabled)return[3,8];a.label=2;case 2:return a.trys.push([2,5,,7]),r.nestdb&&r.nestdb.state!==ze.CLOSED&&r.nestdb.name===u?[3,4]:((c=r.nestdb=new Re({name:"sendbird@".concat(n.appId,"/").concat(e,".db"),version:2,store:r.store})).on("upgrade",Ve(c,r.store)),c.on("storeReplaced",(function(e){r.replaceStore(e),r.localCacheEnabled=!1,c.on("upgrade",Ve(c,r.store))})),[4,c.open()]);case 3:a.sent(),this._storeInitialized=!0,s.dispatch(new Me(this._iid,{userId:e})),a.label=4;case 4:return n.userId=e,[3,7];case 5:return d=a.sent(),o.warn("Nest DB Open Failed. ",d),[4,this._safeInitializeStore(u)];case 6:throw a.sent(),n.userId=e,A.databaseError;case 7:return[3,10];case 8:return[4,this._safeInitializeStore(u)];case 9:a.sent(),n.userId=e,a.label=10;case 10:return[2]}}))}))},n.prototype.getCacheDataSize=function(){return s(this,void 0,void 0,(function(){var e;return a(this,(function(t){switch(t.label){case 0:return(e=F.of(this._iid).cacheContext).localCacheEnabled&&e.nestdb?[4,e.nestdb.estimateUsage()]:[3,2];case 1:return[2,t.sent()];case 2:return[2,0]}}))}))},n.prototype.clearCachedData=function(){return s(this,void 0,void 0,(function(){var e;return a(this,(function(t){switch(t.label){case 0:return(e=F.of(this._iid).cacheContext).localCacheEnabled&&e.nestdb?[4,e.nestdb.clear()]:[3,2];case 1:t.sent(),t.label=2;case 2:return this._storeInitialized?[4,e.preference.clear()]:[3,4];case 3:t.sent(),t.label=4;case 4:return[2]}}))}))},n.prototype.clearCachedMessages=function(e){return s(this,void 0,void 0,(function(){var t,n,r=this;return a(this,(function(i){switch(i.label){case 0:return J(E("string",e)).throw(A.invalidParameters),t=Fe.of(this._iid),n=je.of(this._iid),t&&n?[4,Promise.all(e.map((function(e){return s(r,void 0,void 0,(function(){return a(this,(function(r){switch(r.label){case 0:return[4,t.removeMessagesOfChannel(e)];case 1:return r.sent(),[4,n.removeMessagesOfChannel(e)];case 2:return r.sent(),[2]}}))}))})))]:[3,2];case 1:i.sent(),i.label=2;case 2:return[2]}}))}))},n.prototype.connect=function(e,n){return void 0===n&&(n=null),s(this,void 0,void 0,(function(){var r,i,s,o,u,c,d;return a(this,(function(a){switch(a.label){case 0:J(t("string",e)&&t("string",n,!0)).throw(A.invalidParameters),r=F.of(this._iid),i=r.sdkState,s=r.cacheContext,o=r.connectionManager,u=r.statLogCollector,a.label=1;case 1:return a.trys.push([1,3,,4]),[4,this.initializeCache(e)];case 2:return a.sent(),F.of(this._iid).dispatcher.dispatch(new qe),[3,4];case 3:return a.sent(),c=F.of(this._iid).logger,s.localCacheEnabled=!1,c.warn("Cache initialization failed - cache is not available."),[3,4];case 4:return[4,s.preference.init(this._getPreferenceCacheKey(e),this._getCurrentPreferenceVersion())];case 5:return a.sent(),[4,s.preference.get(this._getUserProfileCacheKey(e))];case 6:return(d=a.sent())&&new se(this._iid,d).apply(),[4,u.init("sendbird@".concat(i.appId,"/").concat(e,".statlog"))];case 7:a.sent(),a.label=8;case 8:return a.trys.push([8,,10,11]),[4,o.connect(n)];case 9:return a.sent(),[3,11];case 10:return this._onlineDetector.start(),this._appStateChangeDetector.start(),[7];case 11:return[2,this.currentUser]}}))}))},n.prototype.reconnect=function(){var e=F.of(this._iid),t=e.connectionManager,n=e.sdkState,r=e.sessionManager.auth.hasSession;return r&&(this._appStateChangeDetector.start(),this._onlineDetector.start(),t.resetAndReconnect().then((function(){n.appState="foreground"})).catch((function(){}))),r},n.prototype.disconnect=function(){return s(this,void 0,void 0,(function(){var e,t,n;return a(this,(function(r){switch(r.label){case 0:return e=F.of(this._iid),t=e.connectionManager,n=e.requestQueue,this._appStateChangeDetector.stop(),this._onlineDetector.stop(),n.cancelAll(),[4,t.logout()];case 1:return r.sent(),[4,this.clearCachedData()];case 2:return r.sent(),[2]}}))}))},n.prototype.disconnectWebSocket=function(){return s(this,void 0,void 0,(function(){var e,t,n;return a(this,(function(r){switch(r.label){case 0:return e=F.of(this._iid),t=e.connectionManager,n=e.requestQueue,this._appStateChangeDetector.stop(),this._onlineDetector.stop(),n.cancelAll(),[4,t.disconnectWebSocket()];case 1:return r.sent(),[2]}}))}))},n.prototype.setBackgroundState=function(){var e=F.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())},n.prototype.setForegroundState=function(){var e=F.of(this._iid),t=e.connectionManager,n=e.sdkState,r=e.logger;"background"===n.appState&&(n.appState="foreground",r.debug("going foreground state"),t.resetAndReconnect())},n.prototype.setSessionHandler=function(e){J(e instanceof Ge).throw(A.invalidParameters),F.of(this._iid).sessionManager.handler=e},n.prototype.addUserEventHandler=function(e,n){J(t("string",e)&&n instanceof Ke).throw(A.invalidParameters),F.of(this._iid).userEventHandlers.set(e,n)},n.prototype.removeUserEventHandler=function(e){F.of(this._iid).userEventHandlers.delete(e)},n.prototype.removeAllUserEventHandler=function(){F.of(this._iid).userEventHandlers.clear()},n.prototype.addConnectionHandler=function(e,n){J(t("string",e)&&n instanceof We).throw(A.invalidParameters),F.of(this._iid).connectionHandlers.set(e,n)},n.prototype.removeConnectionHandler=function(e){F.of(this._iid).connectionHandlers.delete(e)},n.prototype.removeAllConnectionHandler=function(){F.of(this._iid).connectionHandlers.clear()},n.prototype.createApplicationUserListQuery=function(e){return void 0===e&&(e={}),new $t(this._iid,e)},n.prototype.createBlockedUserListQuery=function(e){return void 0===e&&(e={}),new nn(this._iid,e)},n.prototype.createFriendListQuery=function(e){return void 0===e&&(e={}),new on(this._iid,e)},n.prototype.createMessageSearchQuery=function(e){return new pe(this._iid,e)},n.prototype.createPollListQuery=function(e){return new Qe(this._iid,m({},e))},n.prototype.createPollVoterListQuery=function(e){return new xe(this._iid,m({},e))},n.prototype.buildUserFromSerializedData=function(e){var t=Z(e);return new _(this._iid,_.payloadify(t))},n.prototype.updateCurrentUserInfo=function(n){return void 0===n&&(n={}),s(this,void 0,void 0,(function(){var r,i,s,o,u,c,d;return a(this,(function(a){switch(a.label){case 0:return r=m(m({},He),n),J(function(n){return e(n.profileImage,!0)&&t("string",n.profileUrl,!0)&&t("string",n.nickname,!0)}(r)).throw(A.invalidParameters),this.currentUser?(i=F.of(this._iid),s=i.sdkState,o=i.requestQueue,u=new Ye(m({userId:s.userId},r)),[4,o.send(u)]):[3,2];case 1:return c=a.sent(),d=c.as(Ze).user,this.currentUser&&(r.nickname&&(this.currentUser.nickname=d.nickname),(r.profileUrl||r.profileImage)&&(this.currentUser.plainProfileUrl=d.profileUrl)),[2,d];case 2:throw A.connectionRequired}}))}))},n.prototype.updateCurrentUserInfoWithPreferredLanguages=function(e){return s(this,void 0,void 0,(function(){var t,n,r,i,s,o;return a(this,(function(a){switch(a.label){case 0:return J(E("string",e)).throw(A.invalidParameters),this.currentUser?(t=F.of(this._iid),n=t.sdkState,r=t.requestQueue,i=new Ye({userId:n.userId,preferredLanguages:e}),[4,r.send(i)]):[3,2];case 1:return s=a.sent(),o=s.as(Ze).user,this.currentUser&&(this.currentUser.preferredLanguages=o.preferredLanguages),[2,o];case 2:throw A.connectionRequired}}))}))},n.prototype.registerFCMPushTokenForCurrentUser=function(e){return s(this,void 0,void 0,(function(){var n,r,i,o,u,c=this;return a(this,(function(d){switch(d.label){case 0:if(J(t("string",e)).throw(A.invalidParameters),!this.currentUser)return[3,6];d.label=1;case 1:return d.trys.push([1,4,,5]),n=F.of(this._iid),r=n.sessionManager,i=n.sdkState,o=n.requestQueue,r.hasDeviceToken(b.FCM,e)?[2,ae.SUCCESS]:(u=new et({userId:i.userId,token:e}),[4,o.send(u)]);case 2:return d.sent(),[4,ue((function(){return s(c,void 0,void 0,(function(){return a(this,(function(t){switch(t.label){case 0:return r.setDeviceToken(b.FCM,e),[4,r.saveDeviceToken()];case 1:return t.sent(),[2]}}))}))}))];case 3:return d.sent(),this._fcmPushToken="",[2,ae.SUCCESS];case 4:return d.sent(),[2,ae.ERROR];case 5:return[3,7];case 6:return this._fcmPushToken=e,[2,ae.PENDING];case 7:return[2]}}))}))},n.prototype.unregisterFCMPushTokenForCurrentUser=function(e){return s(this,void 0,void 0,(function(){var n,r,i,o,u,c,d=this;return a(this,(function(l){switch(l.label){case 0:if(J(t("string",e)).throw(A.invalidParameters),!this.currentUser)return[3,6];l.label=1;case 1:return l.trys.push([1,4,,5]),n=F.of(this._iid),r=n.sessionManager,i=n.sdkState,o=n.requestQueue,u=new nt({userId:i.userId,token:e}),[4,o.send(u)];case 2:return c=l.sent().lastDeletedAt,[4,ue((function(){return s(d,void 0,void 0,(function(){return a(this,(function(t){switch(t.label){case 0:return r.unsetDeviceToken(b.FCM,e),r.setDeviceTokenDeletedAt(c),[4,r.saveDeviceToken()];case 1:return t.sent(),[2]}}))}))}))];case 3:return l.sent(),this._fcmPushToken="",[2,ae.SUCCESS];case 4:return l.sent(),[2,ae.ERROR];case 5:return[3,7];case 6:return this._fcmPushToken=e,[2,ae.PENDING];case 7:return[2]}}))}))},n.prototype.unregisterFCMPushTokenAllForCurrentUser=function(){return s(this,void 0,void 0,(function(){var e,t,n,r,i,o,u=this;return a(this,(function(c){switch(c.label){case 0:return this.currentUser?(e=F.of(this._iid),t=e.sessionManager,n=e.sdkState,r=e.requestQueue,i=new it({userId:n.userId}),[4,r.send(i)]):[3,3];case 1:return o=c.sent().lastDeletedAt,[4,ue((function(){return s(u,void 0,void 0,(function(){return a(this,(function(e){switch(e.label){case 0:return t.unsetDeviceTokens(b.FCM),t.setDeviceTokenDeletedAt(o),[4,t.saveDeviceToken()];case 1:return e.sent(),[2]}}))}))}))];case 2:c.sent(),c.label=3;case 3:return[2]}}))}))},n.prototype.registerAPNSPushTokenForCurrentUser=function(e){return s(this,void 0,void 0,(function(){var n,r,i,o,u,c=this;return a(this,(function(d){switch(d.label){case 0:if(J(t("string",e)).throw(A.invalidParameters),!this.currentUser)return[3,6];d.label=1;case 1:return d.trys.push([1,4,,5]),n=F.of(this._iid),r=n.sessionManager,i=n.sdkState,o=n.requestQueue,r.hasDeviceToken(b.APNS,e)?[2,ae.SUCCESS]:(u=new $e({userId:i.userId,token:e}),[4,o.send(u)]);case 2:return d.sent(),[4,ue((function(){return s(c,void 0,void 0,(function(){return a(this,(function(t){switch(t.label){case 0:return r.setDeviceToken(b.APNS,e),[4,r.saveDeviceToken()];case 1:return t.sent(),[2]}}))}))}))];case 3:return d.sent(),this._apnsPushToken="",[2,ae.SUCCESS];case 4:return d.sent(),[2,ae.ERROR];case 5:return[3,7];case 6:return this._apnsPushToken=e,[2,ae.PENDING];case 7:return[2]}}))}))},n.prototype.unregisterAPNSPushTokenForCurrentUser=function(e){return s(this,void 0,void 0,(function(){var n,r,i,o,u,c,d=this;return a(this,(function(l){switch(l.label){case 0:if(J(t("string",e)).throw(A.invalidParameters),!this.currentUser)return[3,6];l.label=1;case 1:return l.trys.push([1,4,,5]),n=F.of(this._iid),r=n.sessionManager,i=n.sdkState,o=n.requestQueue,u=new tt({userId:i.userId,token:e}),[4,o.send(u)];case 2:return c=l.sent().lastDeletedAt,[4,ue((function(){return s(d,void 0,void 0,(function(){return a(this,(function(t){switch(t.label){case 0:return r.unsetDeviceToken(b.APNS,e),r.setDeviceTokenDeletedAt(c),[4,r.saveDeviceToken()];case 1:return t.sent(),[2]}}))}))}))];case 3:return l.sent(),this._apnsPushToken="",[2,ae.SUCCESS];case 4:return l.sent(),[2,ae.ERROR];case 5:return[3,7];case 6:return this._apnsPushToken=e,[2,ae.PENDING];case 7:return[2]}}))}))},n.prototype.unregisterAPNSPushTokenAllForCurrentUser=function(){return s(this,void 0,void 0,(function(){var e,t,n,r,i,o,u=this;return a(this,(function(c){switch(c.label){case 0:return this.currentUser?(e=F.of(this._iid),t=e.sessionManager,n=e.sdkState,r=e.requestQueue,i=new rt({userId:n.userId}),[4,r.send(i)]):[3,3];case 1:return o=c.sent().lastDeletedAt,[4,ue((function(){return s(u,void 0,void 0,(function(){return a(this,(function(e){switch(e.label){case 0:return t.unsetDeviceTokens(b.APNS),t.setDeviceTokenDeletedAt(o),[4,t.saveDeviceToken()];case 1:return e.sent(),[2]}}))}))}))];case 2:c.sent(),c.label=3;case 3:return[2]}}))}))},n.prototype.getChannelInvitationPreference=function(){return s(this,void 0,void 0,(function(){var e,t,n,r,i;return a(this,(function(s){switch(s.label){case 0:return e=F.of(this._iid),t=e.sdkState,n=e.requestQueue,r=new at({userId:t.userId}),[4,n.send(r)];case 1:return i=s.sent(),[2,{autoAccept:i.as(ut).autoAccept}]}}))}))},n.prototype.setChannelInvitationPreference=function(e){return s(this,void 0,void 0,(function(){var n,r,i,s,o;return a(this,(function(a){switch(a.label){case 0:return J(t("boolean",e)).throw(A.invalidParameters),n=F.of(this._iid),r=n.sdkState,i=n.requestQueue,s=new ct({userId:r.userId,willAutoAccept:e}),[4,i.send(s)];case 1:return o=a.sent(),[2,{autoAccept:o.as(dt).autoAccept}]}}))}))},n.prototype.getDoNotDisturb=function(){return s(this,void 0,void 0,(function(){var e,t,n,r,i;return a(this,(function(s){switch(s.label){case 0:return e=F.of(this._iid),t=e.sdkState,n=e.requestQueue,r=new lt({userId:t.userId}),[4,n.send(r)];case 1:return i=s.sent(),[2,i.as(ht).preference]}}))}))},n.prototype.setDoNotDisturb=function(e,n,r,i,o,u){return void 0===n&&(n=0),void 0===r&&(r=0),void 0===i&&(i=0),void 0===o&&(o=0),void 0===u&&(u=""),s(this,void 0,void 0,(function(){var s,c,d,l,h;return a(this,(function(a){switch(a.label){case 0:return J(t("boolean",e)&&t("number",n)&&t("number",r)&&t("number",i)&&t("number",o)&&t("string",u)).throw(A.invalidParameters),s=F.of(this._iid),c=s.sdkState,d=s.requestQueue,l=new ft({userId:c.userId,doNotDisturbOn:e,startHour:n,startMin:r,endHour:i,endMin:o,timezone:u}),[4,d.send(l)];case 1:return h=a.sent(),[2,h.as(pt).preference]}}))}))},n.prototype.getSnoozePeriod=function(){return s(this,void 0,void 0,(function(){var e,t,n,r,i;return a(this,(function(s){switch(s.label){case 0:return e=F.of(this._iid),t=e.sdkState,n=e.requestQueue,r=new vt({userId:t.userId}),[4,n.send(r)];case 1:return i=s.sent(),[2,i.as(_t).snoozePeriod]}}))}))},n.prototype.setSnoozePeriod=function(e,n,r){return void 0===n&&(n=0),void 0===r&&(r=0),s(this,void 0,void 0,(function(){var i,s,o,u,c;return a(this,(function(a){switch(a.label){case 0:return J(t("boolean",e)&&t("number",n)&&t("number",r)).throw(A.invalidParameters),i=F.of(this._iid),s=i.sdkState,o=i.requestQueue,u=new gt({userId:s.userId,snoozeOn:e,startTs:n,endTs:r}),[4,o.send(u)];case 1:return c=a.sent(),[2,c.as(mt).snoozePeriod]}}))}))},n.prototype.getMyPushTokensByToken=function(e,n){return s(this,void 0,void 0,(function(){var r,i,s,o,u,c,d,l,h,f,p,v;return a(this,(function(a){switch(a.label){case 0:return J(t("string",e)&&de(b,n)).throw(A.invalidParameters),r=F.of(this._iid),i=r.sdkState,s=r.requestQueue,o=r.sessionManager,u=new st({userId:i.userId,type:n,token:e}),[4,s.send(u)];case 1:c=a.sent(),d=c.as(ot).pushTokens;try{for(l=ce(d.deviceTokens),h=l.next();!h.done;h=l.next())f=h.value,o.setDeviceToken(d.type,f)}catch(e){p={error:e}}finally{try{h&&!h.done&&(v=l.return)&&v.call(l)}finally{if(p)throw p.error}}return[4,o.saveDeviceToken()];case 2:return a.sent(),[2,d]}}))}))},n.prototype.getPushTriggerOption=function(){return s(this,void 0,void 0,(function(){var e,t,n,r;return a(this,(function(i){switch(i.label){case 0:return e=F.of(this._iid),t=e.sdkState,n=e.requestQueue,r=new wt({userId:t.userId}),[4,n.send(r)];case 1:return[2,i.sent().as(kt).pushTriggerOption]}}))}))},n.prototype.setPushTriggerOption=function(e){return s(this,void 0,void 0,(function(){var t,n,r,i;return a(this,(function(s){switch(s.label){case 0:return J(de(le,e)).throw(A.invalidParameters),t=F.of(this._iid),n=t.sdkState,r=t.requestQueue,i=new It({userId:n.userId,pushTriggerOption:e}),[4,r.send(i)];case 1:return[2,s.sent().as(Ct).pushTriggerOption]}}))}))},n.prototype.getPushTemplate=function(){return s(this,void 0,void 0,(function(){var e,t,n,r;return a(this,(function(i){switch(i.label){case 0:return e=F.of(this._iid),t=e.sdkState,n=e.requestQueue,r=new St({userId:t.userId}),[4,n.send(r)];case 1:return[2,i.sent().as(Tt).name]}}))}))},n.prototype.setPushTemplate=function(e){return s(this,void 0,void 0,(function(){var t,n,r,i;return a(this,(function(s){switch(s.label){case 0:return J(de(he,e)).throw(A.invalidParameters),t=F.of(this._iid),n=t.sdkState,r=t.requestQueue,i=new Pt({userId:n.userId,templateName:e}),[4,r.send(i)];case 1:return[2,s.sent().as(Et).name]}}))}))},n.prototype.blockUser=function(e){return s(this,void 0,void 0,(function(){var n,r,i,s;return a(this,(function(o){switch(o.label){case 0:return J(e instanceof _||t("string",e)).throw(A.invalidParameters),n=F.of(this._iid),r=n.sdkState,i=n.requestQueue,s=new yt({userId:r.userId,blockedUserId:e instanceof _?e.userId:e}),[4,i.send(s)];case 1:return o.sent(),[2]}}))}))},n.prototype.blockUserWithUserId=function(e){return s(this,void 0,void 0,(function(){return a(this,(function(t){return[2,this.blockUser(e)]}))}))},n.prototype.unblockUser=function(e){return s(this,void 0,void 0,(function(){var n,r,i,s;return a(this,(function(o){switch(o.label){case 0:return J(e instanceof _||t("string",e)).throw(A.invalidParameters),n=F.of(this._iid),r=n.sdkState,i=n.requestQueue,s=new bt({userId:r.userId,unblockedUserId:e instanceof _?e.userId:e}),[4,i.send(s)];case 1:return o.sent(),[2]}}))}))},n.prototype.unblockUserWithUserId=function(e){return s(this,void 0,void 0,(function(){return a(this,(function(t){return[2,this.unblockUser(e)]}))}))},n.prototype.getFriendChangeLogsByToken=function(e){return s(this,void 0,void 0,(function(){var n,r,i,s,o;return a(this,(function(a){switch(a.label){case 0:return J(t("string",e)).throw(A.invalidParameters),n=F.of(this._iid),r=n.sdkState,i=n.requestQueue,s=new Dt({userId:r.userId,token:e}),[4,i.send(s)];case 1:return o=a.sent(),[2,o.as(Ut).changelogs]}}))}))},n.prototype.getAllowFriendDiscovery=function(){return s(this,void 0,void 0,(function(){var e,t,n,r,i;return a(this,(function(s){switch(s.label){case 0:return e=F.of(this._iid),t=e.sdkState,n=e.requestQueue,r=new Ft({userId:t.userId}),[4,n.send(r)];case 1:return i=s.sent(),[2,i.as(jt).allowFriendDiscovery]}}))}))},n.prototype.setAllowFriendDiscovery=function(e){return s(this,void 0,void 0,(function(){var n,r,i,s;return a(this,(function(o){switch(o.label){case 0:return J(t("boolean",e)).throw(A.invalidParameters),n=F.of(this._iid),r=n.sdkState,i=n.requestQueue,s=new qt({userId:r.userId,allowFriendDiscovery:e}),[4,i.send(s)];case 1:return o.sent(),[2,e]}}))}))},n.prototype.uploadFriendDiscoveries=function(e){return s(this,void 0,void 0,(function(){var t,n,r,i,s;return a(this,(function(o){switch(o.label){case 0:return t=F.of(this._iid),n=t.sdkState,r=t.requestQueue,i=new Ot({userId:n.userId,discoveries:e}),[4,r.send(i)];case 1:return s=o.sent(),[2,s.as(Lt).friendDiscoveryRequestId]}}))}))},n.prototype.deleteFriendDiscovery=function(e){return s(this,void 0,void 0,(function(){return a(this,(function(t){return[2,this.deleteFriendDiscoveries([e])]}))}))},n.prototype.deleteFriendDiscoveries=function(e){return s(this,void 0,void 0,(function(){var t,n,r,i;return a(this,(function(s){switch(s.label){case 0:return J(E("string",e)).throw(A.invalidParameters),t=F.of(this._iid),n=t.sdkState,r=t.requestQueue,i=new Nt({userId:n.userId,discoveryKeys:e}),[4,r.send(i)];case 1:return s.sent(),[2]}}))}))},n.prototype.addFriends=function(e){return s(this,void 0,void 0,(function(){var t,n,r,i,s;return a(this,(function(o){switch(o.label){case 0:return J(E("string",e)).throw(A.invalidParameters),t=F.of(this._iid),n=t.sdkState,r=t.requestQueue,i=new At({userId:n.userId,userIds:e}),[4,r.send(i)];case 1:return s=o.sent(),[2,s.as(Mt).users]}}))}))},n.prototype.deleteFriend=function(e){return s(this,void 0,void 0,(function(){return a(this,(function(t){return[2,this.deleteFriends([e])]}))}))},n.prototype.deleteFriends=function(e){return s(this,void 0,void 0,(function(){var t,n,r,i;return a(this,(function(s){switch(s.label){case 0:return J(E("string",e)).throw(A.invalidParameters),t=F.of(this._iid),n=t.sdkState,r=t.requestQueue,i=new Rt({userId:n.userId,userIds:e}),[4,r.send(i)];case 1:return s.sent(),[2]}}))}))},n.prototype.getAllEmoji=function(){return s(this,void 0,void 0,(function(){var e,t,n;return a(this,(function(r){switch(r.label){case 0:return e=F.of(this._iid).requestQueue,t=new Ht,[4,e.send(t)];case 1:return n=r.sent(),[2,n.as(Gt).emojiContainer]}}))}))},n.prototype.getEmojiCategory=function(e){return s(this,void 0,void 0,(function(){var t,n,r;return a(this,(function(i){switch(i.label){case 0:return t=F.of(this._iid).requestQueue,n=new Wt({categoryId:e}),[4,t.send(n)];case 1:return r=i.sent(),[2,r.as(Kt).emojiCategory]}}))}))},n.prototype.getEmoji=function(e){return s(this,void 0,void 0,(function(){var t,n,r;return a(this,(function(i){switch(i.label){case 0:return t=F.of(this._iid).requestQueue,n=new Vt({key:e}),[4,t.send(n)];case 1:return r=i.sent(),[2,r.as(Bt).emoji]}}))}))},n.prototype.getUIKitConfiguration=function(){return s(this,void 0,void 0,(function(){var e,t,n,r;return a(this,(function(i){switch(i.label){case 0:return e=F.of(this._iid),J(e.hasExtension("sb_uikit")).throw(A.notSupportedError),t=e.requestQueue,n=new Jt,[4,t.send(n)];case 1:return r=i.sent(),[2,r.as(Xt).uikitConfiguration]}}))}))},n}();export{$t as ApplicationUserListQuery,nn as BlockedUserListQuery,We as ConnectionHandler,zt as Emoji,Qt as EmojiCategory,xt as EmojiContainer,on as FriendListQuery,Ge as SessionHandler,Ke as UserEventHandler,un as default}; +import{i as e,a as t,_ as n,n as r,b as s,c as a,E as u,A as d,d as l,e as p,u as v,f as _,U as m,g as b,h as y,P as w,j as k,k as E,l as D,m as A,B as F,S as j,V as q,o as z,L as x,p as H,q as G,r as W,s as K,v as V,C as J,t as $,w as ee,x as te,y as ne,W as re,z as ie,D as se,F as oe,G as ae,H as ue,I as ce,J as de,K as le,M as he,N as fe,O as pe}from"./lib/__bundle-75942676.js";export{R as CachedChannelInfo,Q as ChannelType,C as ConnectionState,L as LocalCacheConfig,T as LogLevel,O as PushTemplate,I as PushTokenRegistrationState,P as PushTokenType,N as PushTriggerOption,X as Role,o as SendbirdChatOptions,S as SendbirdError,Y as UIKitConfigInfo,U as User,Z as UserOnlineState}from"./lib/__bundle-75942676.js";import{M as ve,a as _e}from"./lib/__bundle-84f74e8d.js";export{P as Plugin}from"./lib/__bundle-84f74e8d.js";import{PollModule as ge}from"./poll.js";import{N as me,a as be,b as ye,c as we,d as ke,e as Ie}from"./lib/__bundle-e875840b.js";export{B as BannedUserListQuery,f as BaseChannel,M as MutedUserListQuery,O as OperatorListQuery,R as ReportCategory,g as RestrictedUser,h as RestrictionInfo,i as RestrictionType}from"./lib/__bundle-e875840b.js";import{g as Se,G as Ce,a as Te,M as Pe,N as Ee,b as De,c as Ue,A as Oe,I as Le,d as Ne,U as Ae,e as Me,f as Re,D as Fe,h as je,i as qe,j as ze,R as Qe,k as xe}from"./lib/__bundle-fd51cf65.js";export{c as MemoryStore}from"./lib/__bundle-fd51cf65.js";import{P as He,a as Ge}from"./lib/__bundle-ad161b2c.js";export{P as Participant}from"./lib/__bundle-8fdac8b9.js";var We={profileImage:void 0,profileUrl:void 0,nickname:void 0},Ke=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 n(t,e),t}((function(){this.onSessionExpired=r,this.onSessionTokenRequired=function(e){return e(null)},this.onSessionError=r,this.onSessionRefreshed=r,this.onSessionClosed=r})),Ve=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 n(t,e),t}((function(){this.onConnected=r,this.onReconnectStarted=r,this.onReconnectSucceeded=r,this.onReconnectFailed=r,this.onDisconnected=r})),Be=function(e){function t(t){void 0===t&&(t={});var n=e.call(this)||this;return Object.keys(t).forEach((function(e){n.hasOwnProperty(e)&&(n[e]=t[e])})),n}return n(t,e),t}((function(){this.onFriendsDiscovered=r,this.onTotalUnreadMessageCountUpdated=r})),Je=function(e,t){return function(n,r){if(1===n)e.clear().then((function(){t.clear().then((function(){(function(e){return s(void 0,void 0,void 0,(function(){return a(this,(function(t){return[2,e.commitSchema([{collectionName:me,keyName:be,index:[Se(Ce.LATEST_LAST_MESSAGE),Se(Ce.CHRONOLOGICAL),Se(Ce.CHANNEL_NAME_ALPHABETICAL)]},{collectionName:ye,keyName:we,index:[Te(Pe.CHANNEL_LATEST),Te(Pe.NEWEST_CHILD_MESSAGE)]},{collectionName:Ee,keyName:De,index:[Te(Pe.CHANNEL_LATEST),Te(Pe.NEWEST_CHILD_MESSAGE)]},{collectionName:ke,keyName:Ie}])]}))}))})(e).then((function(){return r()})).catch((function(e){return r(e)}))})).catch((function(e){return r(e)}))})).catch((function(e){return r(e)}));else r()}},Xe=function(){return"undefined"!=typeof document?document.visibilityState:"visible"},Ye=function(e){function t(t){var n=t.getVisibilityState,r=void 0===n?Xe:n,i=t.initialState,s=void 0===i?"visible":i,o=t.isEnabled,a=void 0===o||o,u=t.pauseCheckDelay,c=void 0===u?3e4:u,d=e.call(this)||this;return d._pauseCheckDelay=3e4,d._currentState="visible",d._getVisibilityState=r,d._pauseCheckDelay=c,d._currentState=s,d._isEnabled=a,d._boundToggleState=d._toggleState.bind(d),d}return n(t,e),Object.defineProperty(t.prototype,"currentState",{get:function(){return this._currentState},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"isAvailable",{get:function(){return"undefined"!=typeof window&&!!window.addEventListener&&!!window.removeEventListener},enumerable:!1,configurable:!0}),t.prototype._toggleState=function(){var e=this,t=this._getVisibilityState();"hidden"!==t?"hidden"===this._currentState&&(this._pauseDelayTimer&&(clearTimeout(this._pauseDelayTimer),this._pauseDelayTimer=void 0),this.dispatch("resume")):"hidden"!==this._currentState&&(this._pauseDelayTimer=setTimeout((function(){e._pauseDelayTimer=void 0,e.dispatch("pause")}),this._pauseCheckDelay)),this._currentState=t},t.prototype.start=function(){this._isEnabled&&this.isAvailable&&(this._boundToggleState=this._toggleState.bind(this),window.addEventListener("visibilitychange",this._boundToggleState,{capture:!0}))},t.prototype.stop=function(){this._isEnabled&&this.isAvailable&&this._boundToggleState&&window.removeEventListener("visibilitychange",this._boundToggleState,{capture:!0})},t}(u),Ze=function(){function e(e){var t=e.logger,n=e.connectionDelegate,r=void 0===n?null:n,i=this;this._onlineWorker=function(){var e;return null===(e=i.connectionDelegate)||void 0===e?void 0:e.reconnect()},this._offlineWorker=function(){var e;return null===(e=i.connectionDelegate)||void 0===e?void 0:e.disconnect()},this.unsubscribes=[],this._onlineListener=function(e){if(i.isAvailableOnWeb)return window.addEventListener("online",e),function(){return window.removeEventListener("online",e,!1)}},this._offlineListener=function(e){if(i.isAvailableOnWeb)return window.addEventListener("offline",e),function(){return window.removeEventListener("offline",e,!1)}},this.logger=t,r&&(this.connectionDelegate=r)}return Object.defineProperty(e.prototype,"isAvailableOnWeb",{get:function(){return"undefined"!=typeof window&&!!window.addEventListener&&"ononline"in window&&"onoffline"in window&&"undefined"!=typeof navigator&&void 0!==navigator.onLine},enumerable:!1,configurable:!0}),e.prototype.setOnlineListener=function(e){Boolean(e)&&"function"==typeof e&&(this._onlineListener=e)},e.prototype.setOfflineListener=function(e){Boolean(e)&&"function"==typeof e&&(this._offlineListener=e)},e.prototype.start=function(){this.unsubscribes=[this._onlineListener(this._onlineWorker),this._offlineListener(this._offlineWorker)]},e.prototype.stop=function(){var e=this;this.unsubscribes.forEach((function(t){try{null==t||t()}catch(t){e.logger.warn(t.message)}})),this.unsubscribes=[]},e.prototype.isOnline=function(){return s(this,void 0,void 0,(function(){return a(this,(function(e){return this.isAvailableOnWeb?[2,navigator.onLine]:[2,new Promise((function(e){fetch("https://www.google.com",{method:d.GET,mode:"no-cors"}).then((function(){return e(!0)})).catch((function(){return e(!1)}))}))]}))}))},e}(),$e=function(e){function t(t){var n=t.userId,r=t.nickname,i=t.profileUrl,s=t.profileImage,o=t.preferredLanguages,a=e.call(this)||this;return a.method=d.PUT,a.path="".concat(l,"/").concat(encodeURIComponent(n)),a.params=p(v({nickname:r,profile_url:i,profile_file:s,preferred_languages:o})),a}return n(t,e),t}(_),et=function(e){function t(t,n){var r=e.call(this,t,n)||this;return r.user=new m(t,b({},n)),r}return n(t,e),t}(y),tt=function(e){function t(t){var n=t.userId,r=t.token,i=e.call(this)||this;return i.method=d.POST,i.path="".concat(l,"/").concat(encodeURIComponent(n),"/push/apns"),i.params={apns_device_token:r,always_push:!0},i}return n(t,e),t}(_);!function(e){function t(t,n){var r=e.call(this,t,n)||this;return r.token=n.token,r.type=n.type?w[n.type.toLowerCase()]:w.UNKNOWN,r.user=new m(t,n.user),r}n(t,e)}(y);var nt=function(e){function t(t){var n=t.userId,r=t.token,i=e.call(this)||this;return i.method=d.POST,i.path="".concat(l,"/").concat(encodeURIComponent(n),"/push/gcm"),i.params={gcm_reg_token:r,always_push:!0},i}return n(t,e),t}(_);!function(e){function t(t,n){var r=e.call(this,t,n)||this;return r.token=n.token,r.type=n.type?w[n.type.toLowerCase()]:w.UNKNOWN,r.user=new m(t,n.user),r}n(t,e)}(y);var rt=function(e){function t(t){var n=t.userId,r=t.token,i=e.call(this)||this;return i.method=d.DELETE,i.path="".concat(l,"/").concat(encodeURIComponent(n),"/push/apns/").concat(encodeURIComponent(r)),i}return n(t,e),t}(_);!function(e){function t(t,n){var r=e.call(this,t,n)||this;return r.token=n.token,r.user=new m(t,n.user),r.lastDeletedAt=n.device_token_last_deleted_at,r}n(t,e)}(y);var it=function(e){function t(t){var n=t.userId,r=t.token,i=e.call(this)||this;return i.method=d.DELETE,i.path="".concat(l,"/").concat(encodeURIComponent(n),"/push/gcm/").concat(encodeURIComponent(r)),i}return n(t,e),t}(_);!function(e){function t(t,n){var r=e.call(this,t,n)||this;return r.token=n.token,r.user=new m(t,n.user),r.lastDeletedAt=n.device_token_last_deleted_at,r}n(t,e)}(y);var st=function(e){function t(t){var n=t.userId,r=e.call(this)||this;return r.method=d.DELETE,r.path="".concat(l,"/").concat(encodeURIComponent(n),"/push/apns"),r}return n(t,e),t}(_);!function(e){function t(t,n){var r=e.call(this,t,n)||this;return r.type=n.type?w[n.type.toLowerCase()]:w.UNKNOWN,r.user=new m(t,n.user),r.lastDeletedAt=n.device_token_last_deleted_at,r}n(t,e)}(y);var ot=function(e){function t(t){var n=t.userId,r=e.call(this)||this;return r.method=d.DELETE,r.path="".concat(l,"/").concat(encodeURIComponent(n),"/push/gcm"),r}return n(t,e),t}(_);!function(e){function t(t,n){var r=e.call(this,t,n)||this;return r.type=n.type?w[n.type.toLowerCase()]:w.UNKNOWN,r.user=new m(t,n.user),r.lastDeletedAt=n.device_token_last_deleted_at,r}n(t,e)}(y);var at=function(e){function t(t){var n=t.userId,r=t.type,i=t.token,s=t.ts,o=e.call(this)||this;return o.method=d.GET,o.path="".concat(l,"/").concat(encodeURIComponent(n),"/push/").concat(encodeURIComponent(r),"/device_tokens"),o.params={created_ts:s,token:i},o}return n(t,e),t}(_),ut=function(e){function t(t,n){var r=e.call(this,t,n)||this;return r.pushTokens={type:n.type?w[n.type.toLowerCase()]:w.UNKNOWN,deviceTokens:n.device_tokens,hasMore:n.has_more,token:n.token},r}return n(t,e),t}(y),ct=function(e){function t(t){var n=t.userId,r=e.call(this)||this;return r.method=d.GET,r.path="".concat(l,"/").concat(encodeURIComponent(n),"/channel_invitation_preference"),r}return n(t,e),t}(_),dt=function(e){function t(t,n){var r=e.call(this,t,n)||this;return r.autoAccept=n.auto_accept,r}return n(t,e),t}(y),lt=function(e){function t(t){var n=t.userId,r=t.willAutoAccept,i=e.call(this)||this;return i.method=d.PUT,i.path="".concat(l,"/").concat(encodeURIComponent(n),"/channel_invitation_preference"),i.params={auto_accept:r},i}return n(t,e),t}(_),ht=function(e){function t(t,n){var r=e.call(this,t,n)||this;return r.autoAccept=n.auto_accept,r}return n(t,e),t}(y),ft=function(e){function t(t){var n=t.userId,r=e.call(this)||this;return r.method=d.GET,r.path="".concat(l,"/").concat(encodeURIComponent(n),"/push_preference"),r}return n(t,e),t}(_),pt=function(e){function t(t,n){var r=e.call(this,t,n)||this;return r.preference={doNotDisturbOn:n.do_not_disturb,startHour:n.start_hour,startMin:n.start_min,endHour:n.end_hour,endMin:n.end_min,timezone:n.timezone},r}return n(t,e),t}(y),vt=function(e){function t(t){var n=t.userId,r=t.doNotDisturbOn,i=t.startHour,s=t.startMin,o=t.endHour,a=t.endMin,u=t.timezone,c=e.call(this)||this;return c.method=d.PUT,c.path="".concat(l,"/").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 n(t,e),t}(_),_t=function(e){function t(t,n){var r=e.call(this,t,n)||this;return r.preference={doNotDisturbOn:n.do_not_disturb,startHour:n.start_hour,startMin:n.start_min,endHour:n.end_hour,endMin:n.end_min,timezone:n.timezone},r}return n(t,e),t}(y),gt=function(e){function t(t){var n=t.userId,r=e.call(this)||this;return r.method=d.GET,r.path="".concat(l,"/").concat(encodeURIComponent(n),"/push_preference"),r}return n(t,e),t}(_),mt=function(e){function t(t,n){var r=e.call(this,t,n)||this;return r.snoozePeriod={isSnoozeOn:n.snooze_enabled},"number"==typeof n.snooze_start_ts&&(r.snoozePeriod.startTs=n.snooze_start_ts),"number"==typeof n.snooze_end_ts&&(r.snoozePeriod.endTs=n.snooze_end_ts),r}return n(t,e),t}(y),bt=function(e){function t(t){var n=t.userId,r=t.snoozeOn,i=t.startTs,s=t.endTs,o=e.call(this)||this;return o.method=d.PUT,o.path="".concat(l,"/").concat(encodeURIComponent(n),"/push_preference"),o.params={snooze_enabled:r,snooze_start_ts:i,snooze_end_ts:s},o}return n(t,e),t}(_),yt=function(e){function t(t,n){var r=e.call(this,t,n)||this;return r.snoozePeriod={isSnoozeOn:n.snooze_enabled},"number"==typeof n.snooze_start_ts&&(r.snoozePeriod.startTs=n.snooze_start_ts),"number"==typeof n.snooze_end_ts&&(r.snoozePeriod.endTs=n.snooze_end_ts),r}return n(t,e),t}(y),wt=function(e){function t(t){var n=t.userId,r=t.blockedUserId,i=e.call(this)||this;return i.method=d.POST,i.path="".concat(l,"/").concat(encodeURIComponent(n),"/block"),i.params={target_id:r},i}return n(t,e),t}(_);!function(e){function t(t,n){var r=e.call(this,t,n)||this;return r.user=new m(t,n),r}n(t,e)}(y);var kt=function(e){function t(t){var n=t.userId,r=t.unblockedUserId,i=e.call(this)||this;return i.method=d.DELETE,i.path="".concat(l,"/").concat(encodeURIComponent(n),"/block/").concat(encodeURIComponent(r)),i}return n(t,e),t}(_);!function(e){function t(){return null!==e&&e.apply(this,arguments)||this}n(t,e)}(y);var It=function(e){function t(t){var n=t.userId,r=e.call(this)||this;return r.method=d.GET,r.path="".concat(l,"/").concat(encodeURIComponent(n),"/push_preference"),r}return n(t,e),t}(_),St=function(e){function t(t,n){var r=e.call(this,t,n)||this;return r.pushTriggerOption=n.push_trigger_option,r}return n(t,e),t}(y),Ct=function(e){function t(t){var n=t.userId,r=t.pushTriggerOption,i=e.call(this)||this;return i.method=d.PUT,i.path="".concat(l,"/").concat(encodeURIComponent(n),"/push_preference"),i.params={push_trigger_option:r},i}return n(t,e),t}(_),Tt=function(e){function t(t,n){var r=e.call(this,t,n)||this;return r.pushTriggerOption=n.push_trigger_option,r}return n(t,e),t}(y),Pt=function(e){function t(t){var n=t.userId,r=e.call(this)||this;return r.method=d.GET,r.path="".concat(l,"/").concat(encodeURIComponent(n),"/push/template"),r}return n(t,e),t}(_),Et=function(e){function t(t,n){var r=e.call(this,t,n)||this;return r.name=n.name,r}return n(t,e),t}(y),Dt=function(e){function t(t){var n=t.userId,r=t.templateName,i=e.call(this)||this;return i.method=d.PUT,i.path="".concat(l,"/").concat(encodeURIComponent(n),"/push/template"),i.params={name:r},i}return n(t,e),t}(_),Ut=function(e){function t(t,n){var r=e.call(this,t,n)||this;return r.name=n.name,r}return n(t,e),t}(y),Ot=function(e){function t(t){var n=t.userId,r=t.token,i=e.call(this)||this;return i.method=d.GET,i.path="".concat(l,"/").concat(encodeURIComponent(n),"/friends/changelogs"),i.params={token:r},i}return n(t,e),t}(_),Lt=function(e){function t(t,n){var r=e.call(this,t,n)||this;return r.changelogs={addedUsers:n.added.map((function(e){return new m(t,e)})),updatedUsers:n.updated.map((function(e){return new m(t,e)})),deletedUserIds:n.deleted,hasMore:n.has_more,token:n.next},r}return n(t,e),t}(y),Nt=function(e){function t(t){var n=t.userId,r=t.discoveries,i=e.call(this)||this;return i.method=d.PUT,i.path="".concat(l,"/").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 n(t,e),t}(_),At=function(e){function t(t,n){var r=e.call(this,t,n)||this;return r.friendDiscoveryRequestId=n.friend_discovery_request_id,r}return n(t,e),t}(y),Mt=function(e){function t(t){var n=t.userId,r=t.discoveryKeys,i=e.call(this)||this;return i.method=d.DELETE,i.path="".concat(l,"/").concat(encodeURIComponent(n),"/friend_discoveries"),i.params={friend_discovery_keys:r},i}return n(t,e),t}(_);!function(e){function t(){return null!==e&&e.apply(this,arguments)||this}n(t,e)}(y);var Rt=function(e){function t(t){var n=t.userId,r=t.userIds,i=e.call(this)||this;return i.method=d.POST,i.path="".concat(l,"/").concat(encodeURIComponent(n),"/friends"),i.params={user_ids:r},i}return n(t,e),t}(_),Ft=function(e){function t(t,n){var r=e.call(this,t,n)||this;return r.users=n.users.map((function(e){return new m(t,e)})),r}return n(t,e),t}(y),jt=function(e){function t(t){var n=t.userId,r=t.userIds,i=e.call(this)||this;return i.method=d.DELETE,i.path="".concat(l,"/").concat(encodeURIComponent(n),"/friends"),i.params={user_ids:r},i}return n(t,e),t}(_);!function(e){function t(){return null!==e&&e.apply(this,arguments)||this}n(t,e)}(y);var qt=function(e){function t(t){var n=t.userId,r=e.call(this)||this;return r.method=d.GET,r.path="".concat(l,"/").concat(n,"/allow_friend_discovery"),r.params={},r}return n(t,e),t}(_),zt=function(e){function t(t,n){var r=e.call(this,t,n)||this;return r.allowFriendDiscovery=n.allow_friend_discovery,r}return n(t,e),t}(y),Qt=function(e){function t(t){var n=t.userId,r=t.allowFriendDiscovery,i=e.call(this)||this;return i.method=d.PUT,i.path="".concat(l,"/").concat(n,"/allow_friend_discovery"),i.params={allow_friend_discovery:r},i}return n(t,e),t}(_);!function(e){function t(){return null!==e&&e.apply(this,arguments)||this}n(t,e)}(y);var xt,Ht=function(e){this.key=e.key,this.url=e.url},Gt=function(e){this.id=e.id,this.name=e.name,this.url=e.url,this.emojis=e.emojis?e.emojis.map((function(e){return new Ht(e)})):[]},Wt=function(e){this.emojiHash=e.emoji_hash||"",this.emojiCategories=e.emoji_categories?e.emoji_categories.map((function(e){return new Gt(e)})):[]},Kt=function(e){function t(){var t=e.call(this)||this;return t.method=d.GET,t.path=k,t}return n(t,e),t}(_),Vt=function(e){function t(t,n){var r=e.call(this,t,n)||this;return r.emojiContainer=new Wt(n),r}return n(t,e),t}(y),Bt=function(e){function t(t){var n=t.categoryId,r=e.call(this)||this;return r.method=d.GET,r.path="".concat(k,"/").concat(n),r}return n(t,e),t}(_),Jt=function(e){function t(t,n){var r=e.call(this,t,n)||this;return r.emojiCategory=new Gt(n),r}return n(t,e),t}(y),Xt=function(e){function t(t){var n=t.key,r=e.call(this)||this;return r.method=d.GET,r.path="".concat(E,"/").concat(n),r}return n(t,e),t}(_),Yt=function(e){function t(t,n){var r=e.call(this,t,n)||this;return r.emoji=new Ht(n),r}return n(t,e),t}(y),Zt=function(e){function t(){var t=e.call(this)||this;return t.method=d.GET,t.path="".concat(D),t}return n(t,e),t}(_),$t=function(e){function t(t,n){var r,i=this,s=null!=n?n:{};return(i=e.call(this,t,n)||this).uikitConfiguration={string:JSON.stringify(s),json:s},i.updatedAt=null!==(r=null==n?void 0:n.updated_at)&&void 0!==r?r:0,i}return n(t,e),t}(y),en=function(e){function t(t){var n=t.limit,r=t.token,i=t.userIdsFilter,s=t.metaDataKeyFilter,o=t.metaDataValuesFilter,a=t.nicknameStartsWithFilter,u=e.call(this)||this;return u.method=d.GET,u.path=l,u.params=p({limit:n,token:r,user_ids:i,metadatakey:s,metadatavalues_in:o,nickname_startswith:a}),u}return n(t,e),t}(_),tn=function(e){function t(t,n){var r=e.call(this,t,n)||this;return r.users=n.users.map((function(e){return new m(t,e)})),r.next=n.next,r}return n(t,e),t}(y),nn=function(e){function r(t,n){var r,i,s,o=this;return(o=e.call(this,t,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 n(r,e),r.prototype._validate=function(){return e.prototype._validate.call(this)&&A("string",this.userIdsFilter,!0)&&t("string",this.metaDataKeyFilter,!0)&&A("string",this.metaDataValuesFilter,!0)&&t("string",this.metaDataKeyFilter,!0)},r.prototype.next=function(){return s(this,void 0,void 0,(function(){var e,t,n,r,i,s;return a(this,(function(o){switch(o.label){case 0:return this._validate()?this._isLoading?[3,3]:this._hasNext?(this._isLoading=!0,e=q.of(this._iid).requestQueue,t=new en(v(b(b({},this),{token:this._token}))),[4,e.send(t)]):[3,2]:[3,5];case 1:return n=o.sent(),r=n.as(tn),i=r.users,s=r.next,this._token=s,this._hasNext=!!s,this._isLoading=!1,[2,i];case 2:return[2,[]];case 3:throw j.queryInProgress;case 4:return[3,6];case 5:throw j.invalidParameters;case 6:return[2]}}))}))},r}(F),rn=function(e){function t(t){var n=t.userId,r=t.limit,i=t.token,s=t.userIdsFilter,o=e.call(this)||this;return o.method=d.GET,o.path="".concat(l,"/").concat(n,"/block"),o.params=p({limit:r,token:i,user_ids:s}),o}return n(t,e),t}(_),sn=function(e){function t(t,n){var r=e.call(this,t,n)||this;return r.users=n.users.map((function(e){return new m(t,e)})),r.next=n.next,r}return n(t,e),t}(y),on=function(e){function t(t,n){var r,i=this;return(i=e.call(this,t,n)||this).userIdsFilter=null,i.userIdsFilter=null!==(r=n.userIdsFilter)&&void 0!==r?r:null,i}return n(t,e),t.prototype._validate=function(){return e.prototype._validate.call(this)&&A("string",this.userIdsFilter,!0)},t.prototype.next=function(){return s(this,void 0,void 0,(function(){var e,t,n,r,i,s,o,u;return a(this,(function(a){switch(a.label){case 0:return this._validate()?this._isLoading?[3,3]:this._hasNext?(this._isLoading=!0,e=q.of(this._iid),t=e.sdkState,n=e.requestQueue,r=new rn(v(b(b({},this),{userId:t.userId,token:this._token}))),[4,n.send(r)]):[3,2]:[3,5];case 1:return i=a.sent(),s=i.as(sn),o=s.users,u=s.next,this._token=u,this._hasNext=!!u,this._isLoading=!1,[2,o];case 2:return[2,[]];case 3:throw j.queryInProgress;case 4:return[3,6];case 5:throw j.invalidParameters;case 6:return[2]}}))}))},t}(F),an=function(e){function t(t){var n=t.userId,r=t.limit,i=t.token,s=e.call(this)||this;return s.method=d.GET,s.path="".concat(l,"/").concat(encodeURIComponent(n),"/friends"),s.params={limit:r,token:i},s}return n(t,e),t}(_),un=function(e){function t(t,n){var r=e.call(this,t,n)||this;return r.hasMore=n.has_more,r.users=n.users.map((function(e){return new m(t,e)})),r.next=n.next,r}return n(t,e),t}(y),cn=function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return n(t,e),t.prototype._validate=function(){return e.prototype._validate.call(this)},t.prototype.next=function(){return s(this,void 0,void 0,(function(){var e,t,n,r,i,s,o,u,c;return a(this,(function(a){switch(a.label){case 0:return this._validate()?this._isLoading?[3,3]:this._hasNext?(this._isLoading=!0,e=q.of(this._iid),t=e.sdkState,n=e.requestQueue,r=new an(b(b({},this),{userId:t.userId,token:this._token})),[4,n.send(r)]):[3,2]:[3,5];case 1:return i=a.sent(),s=i.as(un),o=s.users,u=s.hasMore,c=s.next,this._token=c,this._hasNext=u,this._isLoading=!1,[2,o];case 2:return[2,[]];case 3:throw j.queryInProgress;case 4:return[3,6];case 5:throw j.invalidParameters;case 6:return[2]}}))}))},t}(F),dn=function(){function n(e,t,n){var r=this;this._storeInitialized=!1,this._iid=e,this.options=t;var i=q.of(e),o=i.sdkState,u=i.cacheContext,c=i.dispatcher,d=i.sessionManager,l=i.requestQueue,h=i.logger,f=i.userEventHandlers,p=i.appStateToggleEnabled;this._onlineDetector=new Ze({logger:h,connectionDelegate:{reconnect:function(){var t=q.of(e),n=t.sdkState,r=t.connectionManager,i=t.sessionManager;i.auth.hasSession?"foreground"===n.appState&&r.resetAndReconnect():r.connect(i.auth.authToken)},disconnect:function(){q.of(e).connectionManager.disconnect()}}});var v=new Ne(e,{localCacheEnabled:u.localCacheEnabled,dispatcher:c,sdkState:o,logger:h});n.forEach((function(t){t.init(e,{sdkState:o,cacheContext:u,dispatcher:c,sessionManager:d,requestQueue:l,logger:h,onlineDetector:r._onlineDetector}),r[t.name]=t})),this._appStateChangeDetector=new Ye({isEnabled:p}),this._appStateChangeDetector.on("resume",(function(){h.debug("the page resumes from freeze"),r.setForegroundState()})).on("pause",(function(){h.debug("the page freezes"),r.setBackgroundState()})),c.on((function(t){if(t instanceof te){if(t.stateType===ne.CONNECTED)v.processNonAutoResendRegisteredPendingMessages()}else if(t instanceof re){if("USEV"===t.code){var n=t.as(Ae).event;if(n.category===Me.FRIEND_DISCOVERED){var i=Re.getDataAsFriendDiscoveredEvent(e,n).friendDiscoveries;ie((function(){return s(r,void 0,void 0,(function(){return a(this,(function(e){return[2,f.forEach((function(e){e.onFriendsDiscovered&&e.onFriendsDiscovered(i)}))]}))}))}))}}}else if(t instanceof se){var c=q.of(r._iid).subscribedUnreadMessageCount,d=!1,l=t.ts;if("number"==typeof l&&l>c.ts){if(c.all!==t.all&&(d=!0),c.all=t.all>=0?t.all:0,t.customTypes)for(var p in t.customTypes)c.customTypes[p]!==t.customTypes[p]&&(d=!0),c.customTypes[p]=t.customTypes[p];d=d&&c.ts>0,c.ts=l}d&&ie((function(){return s(r,void 0,void 0,(function(){return a(this,(function(e){return[2,f.forEach((function(e){e.onTotalUnreadMessageCountUpdated&&e.onTotalUnreadMessageCountUpdated(c.all,c.customTypes)}))]}))}))}))}else t instanceof oe?u.preference.set(r._getUserProfileCacheKey(o.userId),ae.payloadify(t.userProfile)):t instanceof ue&&t.error&&t.error.isSessionRevokedError&&(h.debug("session revoked."),r.disconnect())}))}return n.init=function(e){var t=e.appId,r=e.appVersion,i=e.modules,s=void 0===i?[]:i,o=e.options,a=void 0===o?new z:o,u=e.debugMode,c=void 0!==u&&u,d=e.customApiHost,l=e.customWebSocketHost,h=e.newInstance,f=void 0!==h&&h,p=e.logLevel,v=e.localCacheEnabled,_=void 0!==v&&v,g=e.localCacheConfig,m=void 0===g?new x:g,b=e.localCacheEncryption,y=e.useAsyncStorageStore,w=void 0===y?null:y,k=e.appStateToggleEnabled,I=void 0===k||k;if(!xt||f){var S="su-".concat(H()),C=null!=b?b:{encrypt:function(e){return e},decrypt:function(e){return e}},T=new Ue({encryption:C});c||(T=G()?w?new Oe({AsyncStorage:w,encryption:C}):new Ue({encryption:C}):new Le({encryption:C})),new q(S,{appId:t,appVersion:r,options:a,apiHost:null!=d?d:"https://api-".concat(t,".sendbird.com"),websocketHost:null!=l?l:"wss://ws-".concat(t,".sendbird.com"),store:T,encryption:C,logLevel:p,localCacheEnabled:_,localCacheConfig:m,debugMode:c,appStateToggleEnabled:I});var P=[new ve,new ge],E=new n(S,a,W(W([],K(s),!1),K(P),!1));return xt||(xt=E),E}return xt},Object.defineProperty(n,"instance",{get:function(){return xt},enumerable:!1,configurable:!0}),Object.defineProperty(n,"version",{get:function(){return V},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"appId",{get:function(){return q.of(this._iid).sdkState.appId},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"appInfo",{get:function(){var e=q.of(this._iid).appInfo;return null!=e?e:null},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"appVersion",{get:function(){var e;return null!==(e=q.of(this._iid).sdkState.appVersion)&&void 0!==e?e:""},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"debugMode",{get:function(){return!!q.of(this._iid).debugMode},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"logLevel",{get:function(){return q.of(this._iid).logger.level},set:function(e){q.of(this._iid).logger.level=e},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"isCacheEnabled",{get:function(){return q.of(this._iid).cacheContext.localCacheEnabled},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"localCacheConfig",{get:function(){var e=q.of(this._iid).cacheContext;return e.localCacheEnabled?e.localCacheConfig:null},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"ekey",{get:function(){return q.of(this._iid).sessionManager.ekey},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"currentUser",{get:function(){var e;return null!==(e=q.of(this._iid).sessionManager.currentUser)&&void 0!==e?e:null},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"connectionState",{get:function(){var e=q.of(this._iid).connectionManager;return e.isConnected?J.OPEN:e.isConnecting?J.CONNECTING:J.CLOSED},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"lastConnectedAt",{get:function(){var e=q.of(this._iid),t=e.connectedAt;return e.connectionManager.isConnected?t:0},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"fcmPushToken",{get:function(){var e;return null!==(e=this._fcmPushToken)&&void 0!==e?e:null},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"apnsPushToken",{get:function(){var e;return null!==(e=this._apnsPushToken)&&void 0!==e?e:null},enumerable:!1,configurable:!0}),n.prototype._getCurrentPreferenceVersion=function(){return 1},n.prototype._getPreferenceCacheKey=function(e){return"sendbird@".concat(this.appId,"/").concat(e,".pref")},n.prototype._getUserProfileCacheKey=function(e){return"sendbird@".concat(this.appId,"/").concat(e,".profile")},n.prototype.getMemoryStoreForDebugging=function(){var e=q.of(this._iid),t=e.debugMode,n=e.cacheContext;if(t)return n.store instanceof Ue?n.store:null;throw j.debugModeRequired},n.prototype.addExtension=function(e,t){var n=q.of(this._iid).sdkState;["sb_uikit","sb_syncmanager","device-os-platform"].indexOf(e)>-1&&n.extensions&&(n.extensions[e]=t)},n.prototype.setOnlineListener=function(e){this._onlineDetector.setOnlineListener(e)},n.prototype.setOfflineListener=function(e){this._onlineDetector.setOfflineListener(e)},n.prototype._safeInitializeStore=function(e){return s(this,void 0,void 0,(function(){var t;return a(this,(function(n){switch(n.label){case 0:t=q.of(this._iid).cacheContext,n.label=1;case 1:return n.trys.push([1,3,,5]),[4,t.store.init(e)];case 2:return n.sent(),this._storeInitialized=!0,[3,5];case 3:return n.sent(),t.replaceStore(new Ue),[4,this._safeInitializeStore(e)];case 4:return n.sent(),[3,5];case 5:return[2]}}))}))},n.prototype.initializeCache=function(e){return s(this,void 0,void 0,(function(){var t,n,r,i,s,o,u,c,d;return a(this,(function(a){switch(a.label){case 0:return t=q.of(this._iid),n=t.sdkState,r=t.cacheContext,i=t.connectionManager,s=t.dispatcher,o=t.logger,n.userId&&n.userId===e?[3,10]:[4,i.logout()];case 1:if(a.sent(),u="sendbird@".concat(n.appId,"/").concat(e,".db"),!r.localCacheEnabled)return[3,8];a.label=2;case 2:return a.trys.push([2,5,,7]),r.nestdb&&r.nestdb.state!==xe.CLOSED&&r.nestdb.name===u?[3,4]:((c=r.nestdb=new je({name:"sendbird@".concat(n.appId,"/").concat(e,".db"),version:2,store:r.store})).on("upgrade",Je(c,r.store)),c.on("storeReplaced",(function(e){r.replaceStore(e),r.localCacheEnabled=!1,c.on("upgrade",Je(c,r.store))})),[4,c.open()]);case 3:a.sent(),this._storeInitialized=!0,s.dispatch(new Fe(this._iid,{userId:e})),a.label=4;case 4:return n.userId=e,[3,7];case 5:return d=a.sent(),o.warn("Nest DB Open Failed. ",d),[4,this._safeInitializeStore(u)];case 6:throw a.sent(),n.userId=e,j.databaseError;case 7:return[3,10];case 8:return[4,this._safeInitializeStore(u)];case 9:a.sent(),n.userId=e,a.label=10;case 10:return[2]}}))}))},n.prototype.getCacheDataSize=function(){return s(this,void 0,void 0,(function(){var e;return a(this,(function(t){switch(t.label){case 0:return(e=q.of(this._iid).cacheContext).localCacheEnabled&&e.nestdb?[4,e.nestdb.estimateUsage()]:[3,2];case 1:return[2,t.sent()];case 2:return[2,0]}}))}))},n.prototype.clearCachedData=function(){return s(this,void 0,void 0,(function(){var e;return a(this,(function(t){switch(t.label){case 0:return(e=q.of(this._iid).cacheContext).localCacheEnabled&&e.nestdb?[4,e.nestdb.clear()]:[3,2];case 1:t.sent(),t.label=2;case 2:return this._storeInitialized?[4,e.preference.clear()]:[3,4];case 3:t.sent(),t.label=4;case 4:return[2]}}))}))},n.prototype.clearCachedMessages=function(e){return s(this,void 0,void 0,(function(){var t,n,r=this;return a(this,(function(i){switch(i.label){case 0:return $(A("string",e)).throw(j.invalidParameters),t=qe.of(this._iid),n=ze.of(this._iid),t&&n?[4,Promise.all(e.map((function(e){return s(r,void 0,void 0,(function(){return a(this,(function(r){switch(r.label){case 0:return[4,t.removeMessagesOfChannel(e)];case 1:return r.sent(),[4,n.removeMessagesOfChannel(e)];case 2:return r.sent(),[2]}}))}))})))]:[3,2];case 1:i.sent(),i.label=2;case 2:return[2]}}))}))},n.prototype.connect=function(e,n){return s(this,void 0,void 0,(function(){var r,i,s,o,u,c,d;return a(this,(function(a){switch(a.label){case 0:$(t("string",e)&&t("string",n,!0)).throw(j.invalidParameters),r=q.of(this._iid),i=r.sdkState,s=r.cacheContext,o=r.connectionManager,u=r.statLogCollector,a.label=1;case 1:return a.trys.push([1,3,,4]),[4,this.initializeCache(e)];case 2:return a.sent(),q.of(this._iid).dispatcher.dispatch(new Qe),[3,4];case 3:return a.sent(),c=q.of(this._iid).logger,s.localCacheEnabled=!1,c.warn("Cache initialization failed - cache is not available."),[3,4];case 4:return[4,s.preference.init(this._getPreferenceCacheKey(e),this._getCurrentPreferenceVersion())];case 5:return a.sent(),[4,s.preference.get(this._getUserProfileCacheKey(e))];case 6:return(d=a.sent())&&new ae(this._iid,d).apply(),[4,u.init("sendbird@".concat(i.appId,"/").concat(e,".statlog"))];case 7:a.sent(),a.label=8;case 8:return a.trys.push([8,,10,11]),[4,o.connect(n)];case 9:return a.sent(),[3,11];case 10:return this._onlineDetector.start(),this._appStateChangeDetector.start(),[7];case 11:return[2,this.currentUser]}}))}))},n.prototype.reconnect=function(){var e=q.of(this._iid),t=e.connectionManager,n=e.sdkState,r=e.sessionManager.auth.hasSession;return r&&(this._appStateChangeDetector.start(),this._onlineDetector.start(),t.resetAndReconnect().then((function(){n.appState="foreground"})).catch((function(){}))),r},n.prototype.disconnect=function(){return s(this,void 0,void 0,(function(){var e,t,n;return a(this,(function(r){switch(r.label){case 0:return e=q.of(this._iid),t=e.connectionManager,n=e.requestQueue,this._appStateChangeDetector.stop(),this._onlineDetector.stop(),n.cancelAll(),[4,t.logout()];case 1:return r.sent(),[4,this.clearCachedData()];case 2:return r.sent(),[2]}}))}))},n.prototype.disconnectWebSocket=function(){return s(this,void 0,void 0,(function(){var e,t,n;return a(this,(function(r){switch(r.label){case 0:return e=q.of(this._iid),t=e.connectionManager,n=e.requestQueue,this._appStateChangeDetector.stop(),this._onlineDetector.stop(),n.cancelAll(),[4,t.disconnectWebSocket()];case 1:return r.sent(),[2]}}))}))},n.prototype.setBackgroundState=function(){var e=q.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())},n.prototype.setForegroundState=function(){var e=q.of(this._iid),t=e.connectionManager,n=e.sdkState,r=e.logger;"background"===n.appState&&(n.appState="foreground",r.debug("going foreground state"),t.resetAndReconnect())},n.prototype.setSessionHandler=function(e){$(e instanceof Ke).throw(j.invalidParameters),q.of(this._iid).sessionManager.handler=e},n.prototype.addUserEventHandler=function(e,n){$(t("string",e)&&n instanceof Be).throw(j.invalidParameters),q.of(this._iid).userEventHandlers.set(e,n)},n.prototype.removeUserEventHandler=function(e){q.of(this._iid).userEventHandlers.delete(e)},n.prototype.removeAllUserEventHandler=function(){q.of(this._iid).userEventHandlers.clear()},n.prototype.addConnectionHandler=function(e,n){$(t("string",e)&&n instanceof Ve).throw(j.invalidParameters),q.of(this._iid).connectionHandlers.set(e,n)},n.prototype.removeConnectionHandler=function(e){q.of(this._iid).connectionHandlers.delete(e)},n.prototype.removeAllConnectionHandler=function(){q.of(this._iid).connectionHandlers.clear()},n.prototype.createApplicationUserListQuery=function(e){return void 0===e&&(e={}),new nn(this._iid,e)},n.prototype.createBlockedUserListQuery=function(e){return void 0===e&&(e={}),new on(this._iid,e)},n.prototype.createFriendListQuery=function(e){return void 0===e&&(e={}),new cn(this._iid,e)},n.prototype.createMessageSearchQuery=function(e){return new _e(this._iid,e)},n.prototype.createPollListQuery=function(e){return new He(this._iid,b({},e))},n.prototype.createPollVoterListQuery=function(e){return new Ge(this._iid,b({},e))},n.prototype.buildUserFromSerializedData=function(e){var t=ee(e);return new m(this._iid,m.payloadify(t))},n.prototype.updateCurrentUserInfo=function(n){return void 0===n&&(n={}),s(this,void 0,void 0,(function(){var r,i,s,o,u,c,d;return a(this,(function(a){switch(a.label){case 0:return r=b(b({},We),n),$(function(n){return e(n.profileImage,!0)&&t("string",n.profileUrl,!0)&&t("string",n.nickname,!0)}(r)).throw(j.invalidParameters),this.currentUser?(i=q.of(this._iid),s=i.sdkState,o=i.requestQueue,u=new $e(b({userId:s.userId},r)),[4,o.send(u)]):[3,2];case 1:return c=a.sent(),d=c.as(et).user,this.currentUser&&(r.nickname&&(this.currentUser.nickname=d.nickname),(r.profileUrl||r.profileImage)&&(this.currentUser.plainProfileUrl=d.profileUrl)),[2,d];case 2:throw j.connectionRequired}}))}))},n.prototype.updateCurrentUserInfoWithPreferredLanguages=function(e){return s(this,void 0,void 0,(function(){var t,n,r,i,s,o;return a(this,(function(a){switch(a.label){case 0:return $(A("string",e)).throw(j.invalidParameters),this.currentUser?(t=q.of(this._iid),n=t.sdkState,r=t.requestQueue,i=new $e({userId:n.userId,preferredLanguages:e}),[4,r.send(i)]):[3,2];case 1:return s=a.sent(),o=s.as(et).user,this.currentUser&&(this.currentUser.preferredLanguages=o.preferredLanguages),[2,o];case 2:throw j.connectionRequired}}))}))},n.prototype.registerFCMPushTokenForCurrentUser=function(e){return s(this,void 0,void 0,(function(){var n,r,i,o,u,c=this;return a(this,(function(d){switch(d.label){case 0:if($(t("string",e)).throw(j.invalidParameters),!this.currentUser)return[3,6];d.label=1;case 1:return d.trys.push([1,4,,5]),n=q.of(this._iid),r=n.sessionManager,i=n.sdkState,o=n.requestQueue,r.hasDeviceToken(w.FCM,e)?[2,ce.SUCCESS]:(u=new nt({userId:i.userId,token:e}),[4,o.send(u)]);case 2:return d.sent(),[4,de((function(){return s(c,void 0,void 0,(function(){return a(this,(function(t){switch(t.label){case 0:return r.setDeviceToken(w.FCM,e),[4,r.saveDeviceToken()];case 1:return t.sent(),[2]}}))}))}))];case 3:return d.sent(),this._fcmPushToken="",[2,ce.SUCCESS];case 4:return d.sent(),[2,ce.ERROR];case 5:return[3,7];case 6:return this._fcmPushToken=e,[2,ce.PENDING];case 7:return[2]}}))}))},n.prototype.unregisterFCMPushTokenForCurrentUser=function(e){return s(this,void 0,void 0,(function(){var n,r,i,o,u,c,d=this;return a(this,(function(l){switch(l.label){case 0:if($(t("string",e)).throw(j.invalidParameters),!this.currentUser)return[3,6];l.label=1;case 1:return l.trys.push([1,4,,5]),n=q.of(this._iid),r=n.sessionManager,i=n.sdkState,o=n.requestQueue,u=new it({userId:i.userId,token:e}),[4,o.send(u)];case 2:return c=l.sent().lastDeletedAt,[4,de((function(){return s(d,void 0,void 0,(function(){return a(this,(function(t){switch(t.label){case 0:return r.unsetDeviceToken(w.FCM,e),r.setDeviceTokenDeletedAt(c),[4,r.saveDeviceToken()];case 1:return t.sent(),[2]}}))}))}))];case 3:return l.sent(),this._fcmPushToken="",[2,ce.SUCCESS];case 4:return l.sent(),[2,ce.ERROR];case 5:return[3,7];case 6:return this._fcmPushToken=e,[2,ce.PENDING];case 7:return[2]}}))}))},n.prototype.unregisterFCMPushTokenAllForCurrentUser=function(){return s(this,void 0,void 0,(function(){var e,t,n,r,i,o,u=this;return a(this,(function(c){switch(c.label){case 0:return this.currentUser?(e=q.of(this._iid),t=e.sessionManager,n=e.sdkState,r=e.requestQueue,i=new ot({userId:n.userId}),[4,r.send(i)]):[3,3];case 1:return o=c.sent().lastDeletedAt,[4,de((function(){return s(u,void 0,void 0,(function(){return a(this,(function(e){switch(e.label){case 0:return t.unsetDeviceTokens(w.FCM),t.setDeviceTokenDeletedAt(o),[4,t.saveDeviceToken()];case 1:return e.sent(),[2]}}))}))}))];case 2:c.sent(),c.label=3;case 3:return[2]}}))}))},n.prototype.registerAPNSPushTokenForCurrentUser=function(e){return s(this,void 0,void 0,(function(){var n,r,i,o,u,c=this;return a(this,(function(d){switch(d.label){case 0:if($(t("string",e)).throw(j.invalidParameters),!this.currentUser)return[3,6];d.label=1;case 1:return d.trys.push([1,4,,5]),n=q.of(this._iid),r=n.sessionManager,i=n.sdkState,o=n.requestQueue,r.hasDeviceToken(w.APNS,e)?[2,ce.SUCCESS]:(u=new tt({userId:i.userId,token:e}),[4,o.send(u)]);case 2:return d.sent(),[4,de((function(){return s(c,void 0,void 0,(function(){return a(this,(function(t){switch(t.label){case 0:return r.setDeviceToken(w.APNS,e),[4,r.saveDeviceToken()];case 1:return t.sent(),[2]}}))}))}))];case 3:return d.sent(),this._apnsPushToken="",[2,ce.SUCCESS];case 4:return d.sent(),[2,ce.ERROR];case 5:return[3,7];case 6:return this._apnsPushToken=e,[2,ce.PENDING];case 7:return[2]}}))}))},n.prototype.unregisterAPNSPushTokenForCurrentUser=function(e){return s(this,void 0,void 0,(function(){var n,r,i,o,u,c,d=this;return a(this,(function(l){switch(l.label){case 0:if($(t("string",e)).throw(j.invalidParameters),!this.currentUser)return[3,6];l.label=1;case 1:return l.trys.push([1,4,,5]),n=q.of(this._iid),r=n.sessionManager,i=n.sdkState,o=n.requestQueue,u=new rt({userId:i.userId,token:e}),[4,o.send(u)];case 2:return c=l.sent().lastDeletedAt,[4,de((function(){return s(d,void 0,void 0,(function(){return a(this,(function(t){switch(t.label){case 0:return r.unsetDeviceToken(w.APNS,e),r.setDeviceTokenDeletedAt(c),[4,r.saveDeviceToken()];case 1:return t.sent(),[2]}}))}))}))];case 3:return l.sent(),this._apnsPushToken="",[2,ce.SUCCESS];case 4:return l.sent(),[2,ce.ERROR];case 5:return[3,7];case 6:return this._apnsPushToken=e,[2,ce.PENDING];case 7:return[2]}}))}))},n.prototype.unregisterAPNSPushTokenAllForCurrentUser=function(){return s(this,void 0,void 0,(function(){var e,t,n,r,i,o,u=this;return a(this,(function(c){switch(c.label){case 0:return this.currentUser?(e=q.of(this._iid),t=e.sessionManager,n=e.sdkState,r=e.requestQueue,i=new st({userId:n.userId}),[4,r.send(i)]):[3,3];case 1:return o=c.sent().lastDeletedAt,[4,de((function(){return s(u,void 0,void 0,(function(){return a(this,(function(e){switch(e.label){case 0:return t.unsetDeviceTokens(w.APNS),t.setDeviceTokenDeletedAt(o),[4,t.saveDeviceToken()];case 1:return e.sent(),[2]}}))}))}))];case 2:c.sent(),c.label=3;case 3:return[2]}}))}))},n.prototype.getChannelInvitationPreference=function(){return s(this,void 0,void 0,(function(){var e,t,n,r,i;return a(this,(function(s){switch(s.label){case 0:return e=q.of(this._iid),t=e.sdkState,n=e.requestQueue,r=new ct({userId:t.userId}),[4,n.send(r)];case 1:return i=s.sent(),[2,{autoAccept:i.as(dt).autoAccept}]}}))}))},n.prototype.setChannelInvitationPreference=function(e){return s(this,void 0,void 0,(function(){var n,r,i,s,o;return a(this,(function(a){switch(a.label){case 0:return $(t("boolean",e)).throw(j.invalidParameters),n=q.of(this._iid),r=n.sdkState,i=n.requestQueue,s=new lt({userId:r.userId,willAutoAccept:e}),[4,i.send(s)];case 1:return o=a.sent(),[2,{autoAccept:o.as(ht).autoAccept}]}}))}))},n.prototype.getDoNotDisturb=function(){return s(this,void 0,void 0,(function(){var e,t,n,r,i;return a(this,(function(s){switch(s.label){case 0:return e=q.of(this._iid),t=e.sdkState,n=e.requestQueue,r=new ft({userId:t.userId}),[4,n.send(r)];case 1:return i=s.sent(),[2,i.as(pt).preference]}}))}))},n.prototype.setDoNotDisturb=function(e,n,r,i,o,u){return void 0===n&&(n=0),void 0===r&&(r=0),void 0===i&&(i=0),void 0===o&&(o=0),void 0===u&&(u=""),s(this,void 0,void 0,(function(){var s,c,d,l,h;return a(this,(function(a){switch(a.label){case 0:return $(t("boolean",e)&&t("number",n)&&t("number",r)&&t("number",i)&&t("number",o)&&t("string",u)).throw(j.invalidParameters),s=q.of(this._iid),c=s.sdkState,d=s.requestQueue,l=new vt({userId:c.userId,doNotDisturbOn:e,startHour:n,startMin:r,endHour:i,endMin:o,timezone:u}),[4,d.send(l)];case 1:return h=a.sent(),[2,h.as(_t).preference]}}))}))},n.prototype.getSnoozePeriod=function(){return s(this,void 0,void 0,(function(){var e,t,n,r,i;return a(this,(function(s){switch(s.label){case 0:return e=q.of(this._iid),t=e.sdkState,n=e.requestQueue,r=new gt({userId:t.userId}),[4,n.send(r)];case 1:return i=s.sent(),[2,i.as(mt).snoozePeriod]}}))}))},n.prototype.setSnoozePeriod=function(e,n,r){return void 0===n&&(n=0),void 0===r&&(r=0),s(this,void 0,void 0,(function(){var i,s,o,u,c;return a(this,(function(a){switch(a.label){case 0:return $(t("boolean",e)&&t("number",n)&&t("number",r)).throw(j.invalidParameters),i=q.of(this._iid),s=i.sdkState,o=i.requestQueue,u=new bt({userId:s.userId,snoozeOn:e,startTs:n,endTs:r}),[4,o.send(u)];case 1:return c=a.sent(),[2,c.as(yt).snoozePeriod]}}))}))},n.prototype.getMyPushTokensByToken=function(e,n){return s(this,void 0,void 0,(function(){var r,i,s,o,u,c,d,l,h,f,p,v;return a(this,(function(a){switch(a.label){case 0:return $(t("string",e)&&he(w,n)).throw(j.invalidParameters),r=q.of(this._iid),i=r.sdkState,s=r.requestQueue,o=r.sessionManager,u=new at({userId:i.userId,type:n,token:e}),[4,s.send(u)];case 1:c=a.sent(),d=c.as(ut).pushTokens;try{for(l=le(d.deviceTokens),h=l.next();!h.done;h=l.next())f=h.value,o.setDeviceToken(d.type,f)}catch(e){p={error:e}}finally{try{h&&!h.done&&(v=l.return)&&v.call(l)}finally{if(p)throw p.error}}return[4,o.saveDeviceToken()];case 2:return a.sent(),[2,d]}}))}))},n.prototype.getPushTriggerOption=function(){return s(this,void 0,void 0,(function(){var e,t,n,r;return a(this,(function(i){switch(i.label){case 0:return e=q.of(this._iid),t=e.sdkState,n=e.requestQueue,r=new It({userId:t.userId}),[4,n.send(r)];case 1:return[2,i.sent().as(St).pushTriggerOption]}}))}))},n.prototype.setPushTriggerOption=function(e){return s(this,void 0,void 0,(function(){var t,n,r,i;return a(this,(function(s){switch(s.label){case 0:return $(he(fe,e)).throw(j.invalidParameters),t=q.of(this._iid),n=t.sdkState,r=t.requestQueue,i=new Ct({userId:n.userId,pushTriggerOption:e}),[4,r.send(i)];case 1:return[2,s.sent().as(Tt).pushTriggerOption]}}))}))},n.prototype.getPushTemplate=function(){return s(this,void 0,void 0,(function(){var e,t,n,r;return a(this,(function(i){switch(i.label){case 0:return e=q.of(this._iid),t=e.sdkState,n=e.requestQueue,r=new Pt({userId:t.userId}),[4,n.send(r)];case 1:return[2,i.sent().as(Et).name]}}))}))},n.prototype.setPushTemplate=function(e){return s(this,void 0,void 0,(function(){var t,n,r,i;return a(this,(function(s){switch(s.label){case 0:return $(he(pe,e)).throw(j.invalidParameters),t=q.of(this._iid),n=t.sdkState,r=t.requestQueue,i=new Dt({userId:n.userId,templateName:e}),[4,r.send(i)];case 1:return[2,s.sent().as(Ut).name]}}))}))},n.prototype.blockUser=function(e){return s(this,void 0,void 0,(function(){var n,r,i,s;return a(this,(function(o){switch(o.label){case 0:return $(e instanceof m||t("string",e)).throw(j.invalidParameters),n=q.of(this._iid),r=n.sdkState,i=n.requestQueue,s=new wt({userId:r.userId,blockedUserId:e instanceof m?e.userId:e}),[4,i.send(s)];case 1:return o.sent(),[2]}}))}))},n.prototype.blockUserWithUserId=function(e){return s(this,void 0,void 0,(function(){return a(this,(function(t){return[2,this.blockUser(e)]}))}))},n.prototype.unblockUser=function(e){return s(this,void 0,void 0,(function(){var n,r,i,s;return a(this,(function(o){switch(o.label){case 0:return $(e instanceof m||t("string",e)).throw(j.invalidParameters),n=q.of(this._iid),r=n.sdkState,i=n.requestQueue,s=new kt({userId:r.userId,unblockedUserId:e instanceof m?e.userId:e}),[4,i.send(s)];case 1:return o.sent(),[2]}}))}))},n.prototype.unblockUserWithUserId=function(e){return s(this,void 0,void 0,(function(){return a(this,(function(t){return[2,this.unblockUser(e)]}))}))},n.prototype.getFriendChangeLogsByToken=function(e){return s(this,void 0,void 0,(function(){var n,r,i,s,o;return a(this,(function(a){switch(a.label){case 0:return $(t("string",e)).throw(j.invalidParameters),n=q.of(this._iid),r=n.sdkState,i=n.requestQueue,s=new Ot({userId:r.userId,token:e}),[4,i.send(s)];case 1:return o=a.sent(),[2,o.as(Lt).changelogs]}}))}))},n.prototype.getAllowFriendDiscovery=function(){return s(this,void 0,void 0,(function(){var e,t,n,r,i;return a(this,(function(s){switch(s.label){case 0:return e=q.of(this._iid),t=e.sdkState,n=e.requestQueue,r=new qt({userId:t.userId}),[4,n.send(r)];case 1:return i=s.sent(),[2,i.as(zt).allowFriendDiscovery]}}))}))},n.prototype.setAllowFriendDiscovery=function(e){return s(this,void 0,void 0,(function(){var n,r,i,s;return a(this,(function(o){switch(o.label){case 0:return $(t("boolean",e)).throw(j.invalidParameters),n=q.of(this._iid),r=n.sdkState,i=n.requestQueue,s=new Qt({userId:r.userId,allowFriendDiscovery:e}),[4,i.send(s)];case 1:return o.sent(),[2,e]}}))}))},n.prototype.uploadFriendDiscoveries=function(e){return s(this,void 0,void 0,(function(){var t,n,r,i,s;return a(this,(function(o){switch(o.label){case 0:return t=q.of(this._iid),n=t.sdkState,r=t.requestQueue,i=new Nt({userId:n.userId,discoveries:e}),[4,r.send(i)];case 1:return s=o.sent(),[2,s.as(At).friendDiscoveryRequestId]}}))}))},n.prototype.deleteFriendDiscovery=function(e){return s(this,void 0,void 0,(function(){return a(this,(function(t){return[2,this.deleteFriendDiscoveries([e])]}))}))},n.prototype.deleteFriendDiscoveries=function(e){return s(this,void 0,void 0,(function(){var t,n,r,i;return a(this,(function(s){switch(s.label){case 0:return $(A("string",e)).throw(j.invalidParameters),t=q.of(this._iid),n=t.sdkState,r=t.requestQueue,i=new Mt({userId:n.userId,discoveryKeys:e}),[4,r.send(i)];case 1:return s.sent(),[2]}}))}))},n.prototype.addFriends=function(e){return s(this,void 0,void 0,(function(){var t,n,r,i,s;return a(this,(function(o){switch(o.label){case 0:return $(A("string",e)).throw(j.invalidParameters),t=q.of(this._iid),n=t.sdkState,r=t.requestQueue,i=new Rt({userId:n.userId,userIds:e}),[4,r.send(i)];case 1:return s=o.sent(),[2,s.as(Ft).users]}}))}))},n.prototype.deleteFriend=function(e){return s(this,void 0,void 0,(function(){return a(this,(function(t){return[2,this.deleteFriends([e])]}))}))},n.prototype.deleteFriends=function(e){return s(this,void 0,void 0,(function(){var t,n,r,i;return a(this,(function(s){switch(s.label){case 0:return $(A("string",e)).throw(j.invalidParameters),t=q.of(this._iid),n=t.sdkState,r=t.requestQueue,i=new jt({userId:n.userId,userIds:e}),[4,r.send(i)];case 1:return s.sent(),[2]}}))}))},n.prototype.getAllEmoji=function(){return s(this,void 0,void 0,(function(){var e,t,n;return a(this,(function(r){switch(r.label){case 0:return e=q.of(this._iid).requestQueue,t=new Kt,[4,e.send(t)];case 1:return n=r.sent(),[2,n.as(Vt).emojiContainer]}}))}))},n.prototype.getEmojiCategory=function(e){return s(this,void 0,void 0,(function(){var t,n,r;return a(this,(function(i){switch(i.label){case 0:return t=q.of(this._iid).requestQueue,n=new Bt({categoryId:e}),[4,t.send(n)];case 1:return r=i.sent(),[2,r.as(Jt).emojiCategory]}}))}))},n.prototype.getEmoji=function(e){return s(this,void 0,void 0,(function(){var t,n,r;return a(this,(function(i){switch(i.label){case 0:return t=q.of(this._iid).requestQueue,n=new Xt({key:e}),[4,t.send(n)];case 1:return r=i.sent(),[2,r.as(Yt).emoji]}}))}))},n.prototype.getUIKitConfiguration=function(){return s(this,void 0,void 0,(function(){var e,t,n,r;return a(this,(function(i){switch(i.label){case 0:return e=q.of(this._iid),$(e.hasExtension("sb_uikit")).throw(j.notSupportedError),t=e.requestQueue,n=new Zt,[4,t.send(n)];case 1:return r=i.sent(),[2,r.as($t).uikitConfiguration]}}))}))},n}();export{nn as ApplicationUserListQuery,on as BlockedUserListQuery,Ve as ConnectionHandler,Ht as Emoji,Gt as EmojiCategory,Wt as EmojiContainer,cn as FriendListQuery,Ke as SessionHandler,Be as UserEventHandler,dn as default}; diff --git a/lib/__bundle-361d5a90.js b/lib/__bundle-361d5a90.js new file mode 100644 index 0000000..13c504b --- /dev/null +++ b/lib/__bundle-361d5a90.js @@ -0,0 +1 @@ +import{Q as e,_ as n,W as t,U as a,V as s,ac as r,aB as o,u as E,aP as N,n as i}from"./__bundle-75942676.js";import{r as u,R as _,s as l}from"./__bundle-84f74e8d.js";import{h as C}from"./__bundle-ad161b2c.js";var d;!function(e){e[e.NONE=0]="NONE",e[e.CHANNEL_ENTER=10102]="CHANNEL_ENTER",e[e.CHANNEL_EXIT=10103]="CHANNEL_EXIT",e[e.USER_CHANNEL_MUTE=10201]="USER_CHANNEL_MUTE",e[e.USER_CHANNEL_UNMUTE=10200]="USER_CHANNEL_UNMUTE",e[e.USER_CHANNEL_BAN=10601]="USER_CHANNEL_BAN",e[e.USER_CHANNEL_UNBAN=10600]="USER_CHANNEL_UNBAN",e[e.CHANNEL_FREEZE=10701]="CHANNEL_FREEZE",e[e.CHANNEL_UNFREEZE=10700]="CHANNEL_UNFREEZE",e[e.TYPING_START=10900]="TYPING_START",e[e.TYPING_END=10901]="TYPING_END",e[e.CHANNEL_JOIN=1e4]="CHANNEL_JOIN",e[e.CHANNEL_LEAVE=10001]="CHANNEL_LEAVE",e[e.CHANNEL_OPERATOR_UPDATE=10002]="CHANNEL_OPERATOR_UPDATE",e[e.CHANNEL_INVITE=10020]="CHANNEL_INVITE",e[e.CHANNEL_ACCEPT_INVITE=10021]="CHANNEL_ACCEPT_INVITE",e[e.CHANNEL_DECLINE_INVITE=10022]="CHANNEL_DECLINE_INVITE",e[e.CHANNEL_PROP_CHANGED=11e3]="CHANNEL_PROP_CHANGED",e[e.CHANNEL_DELETED=12e3]="CHANNEL_DELETED",e[e.CHANNEL_META_DATA_CHANGED=11100]="CHANNEL_META_DATA_CHANGED",e[e.CHANNEL_META_COUNTERS_CHANGED=11200]="CHANNEL_META_COUNTERS_CHANGED",e[e.CHANNEL_HIDE=13e3]="CHANNEL_HIDE",e[e.CHANNEL_UNHIDE=13001]="CHANNEL_UNHIDE",e[e.PINNED_MESSAGE_CHANGED=11300]="PINNED_MESSAGE_CHANGED"}(d||(d={}));var h=function(){function n(e){var n;this.channelUrl=e.channel_url,this.channelType=e.channel_type,this.category=e.cat,this.data=null!==(n=e.data)&&void 0!==n?n:{},this.ts=e.ts}return Object.defineProperty(n.prototype,"isGroupChannelEvent",{get:function(){return this.channelType===e.GROUP},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"isOpenChannelEvent",{get:function(){return this.channelType===e.OPEN},enumerable:!1,configurable:!0}),n}(),A=function(e){function t(n,t,a){var s=e.call(this,n,"SYEV",a)||this;return s.event=new h(a),s}return n(t,e),t}(t),c=function(e){function t(n,t,s){var r=e.call(this,n,t,s)||this,o=s.data.operators,E=void 0===o?[]:o;return r.operators=E.map((function(e){return new a(r._iid,e)})),r}return n(t,e),t}(A),p=function(e){function t(n,t,a){var s=e.call(this,n,"MCNT",a)||this;return s.groupChannelMemberCounts=a.group_channels.map((function(e){return{channelUrl:e.channel_url,memberCount:e.member_count,joinedMemberCount:e.joined_member_count,updatedAt:e.ts}})),s.openChannelMemberCounts=a.open_channels.map((function(e){return{channelUrl:e.channel_url,participantCount:e.participant_count,updatedAt:e.ts}})),s}return n(t,e),t}(t),H=function(e){function t(n,t,a){var o,E,N,i,_=this;(_=e.call(this,n,"ADMM",a)||this).message=new u(n,a);var l=s.of(n).sdkState;return _.isMentioned=r(_.message.mentionType,null!==(N=null!==(o=_.message.mentionedUserIds)&&void 0!==o?o:null===(E=_.message.mentionedUsers)||void 0===E?void 0:E.map((function(e){return e.userId})))&&void 0!==N?N:[],l.userId),_.forceUpdateLastMessage=null!==(i=a.force_update_last_message)&&void 0!==i&&i,_}return n(t,e),t}(t),T=function(e){function t(n,t,a){var r,N,i,_,l,C=this;(C=e.call(this,n,"AEDI",a)||this).message=new u(n,a);var d=s.of(n).sdkState;return C.mentionCountChange=o({mentionType:null===(r=a.old_values)||void 0===r?void 0:r.mention_type,mentionedUserIds:null!==(i=null===(N=a.old_values)||void 0===N?void 0:N.mentioned_user_ids)&&void 0!==i?i:[]},E({mentionType:C.message.mentionType,mentionedUserIds:null!==(_=C.message.mentionedUserIds)&&void 0!==_?_:null===(l=C.message.mentionedUsers)||void 0===l?void 0:l.map((function(e){return e.userId}))}),d.userId),C}return n(t,e),t}(t),U=function(e){function t(n,t,a){var s=e.call(this,n,"MRCT",a)||this;return s.channelUrl=a.channel_url,s.channelType=a.channel_type,s.event=new _(a),s}return n(t,e),t}(t),L=function(e){function t(n,t,a){var s=e.call(this,n,"MTHD",a)||this;return s.event=new l(n,a),s}return n(t,e),t}(t),m=function(e){function t(n,t,a){var s=e.call(this,n,"PEDI",a)||this;return s.event=new C(n,a),s.status=N(a.poll.status)||a.poll.status,s.channelUrl=a.channel_url,s.channelType=a.channel_type,s}return n(t,e),t}(t),f=function(){this.onUserMuted=i,this.onUserUnmuted=i,this.onUserBanned=i,this.onUserUnbanned=i,this.onChannelChanged=i,this.onChannelDeleted=i,this.onChannelFrozen=i,this.onChannelUnfrozen=i,this.onOperatorUpdated=i,this.onChannelMemberCountChanged=i,this.onMetaDataCreated=i,this.onMetaDataUpdated=i,this.onMetaDataDeleted=i,this.onMetaCounterCreated=i,this.onMetaCounterUpdated=i,this.onMetaCounterDeleted=i,this.onMessageReceived=i,this.onMessageUpdated=i,this.onMessageDeleted=i,this.onMentionReceived=i,this.onReactionUpdated=i,this.onThreadInfoUpdated=i};export{H as A,f as B,A as C,p as M,c as O,m as P,U as R,L as T,T as U,d as a}; diff --git a/lib/__bundle-3707a8af.js b/lib/__bundle-3707a8af.js deleted file mode 100644 index 8e00e98..0000000 --- a/lib/__bundle-3707a8af.js +++ /dev/null @@ -1 +0,0 @@ -import{_ as t,A as n,at as e,f as o,a7 as s,h as l,an as a,aa as i,e as r,a as u,au as c,av as h,K as p,O as d,t as f,b as _,c as m,ah as v,s as g,S as I,g as w,aw as y,al as T,V as U,U as k}from"./__bundle-a8606dd4.js";var b=function(o){function s(t){var s=t.title,l=t.optionTexts,a=t.data,i=t.allowUserSuggestion,r=t.allowMultipleVotes,u=t.closeAt,c=o.call(this)||this;return c.method=n.POST,c.path=e,c.params={title:s,options:l,data:a,allow_user_suggestion:i,allow_multiple_votes:r,close_at:u},c}return t(s,o),s}(o),P=function(n){function e(t,e){var o=n.call(this,t,e)||this;return o.poll=new s(t,e),o}return t(e,n),e}(l),O=function(o){function s(t){var s=t.channelUrl,l=t.channelType,a=t.pollId,i=o.call(this)||this;return i.method=n.GET,i.path="".concat(e,"/").concat(encodeURIComponent(a)),i.params={channel_url:s,channel_type:l},i}return t(s,o),s}(o),x=function(n){function e(t,e){var o=n.call(this,t,e)||this;return o.poll=new s(t,e),o}return t(e,n),e}(l),q=function(o){function s(t){var s=t.channelUrl,l=t.channelType,a=t.pollId,i=t.pollOptionId,r=o.call(this)||this;return r.method=n.GET,r.path="".concat(e,"/").concat(encodeURIComponent(a),"/options/").concat(encodeURIComponent(i)),r.params={channel_url:s,channel_type:l},r}return t(s,o),s}(o),L=function(n){function e(t,e){var o=n.call(this,t,e)||this;return o.pollOption=new a(t,e),o}return t(e,n),e}(l),S=function(e){function o(t){var o=t.channelType,s=t.channelUrl,l=t.timestamp,a=t.token,u=e.call(this)||this;return u.method=n.GET,u.path="".concat(i(o),"/").concat(encodeURIComponent(s),"/polls/changelogs"),u.params=r({change_ts:l,token:a}),u}return t(o,e),o}(o),C=function(n){function e(t,e){var o=n.call(this,t,e)||this;return o.updatedPolls=e.updated.map((function(n){return function(t,n){return n?new s(t,n):null}(t,n)})),o.deletedPollIds=e.deleted.map((function(t){return t})),o.hasMore=e.has_more,o.nextToken=e.next,o}return t(e,n),e}(l),M={title:null,optionTexts:null,data:null,allowUserSuggestion:null,allowMultipleVotes:null,closeAt:-1},Q=function(t){return u("string",t.title)&&c(t.optionTexts)&&h(t.data)&&u("boolean",t.allowUserSuggestion,!0)&&u("boolean",t.allowMultipleVotes,!0)&&u("number",t.closeAt,!0)},G={channelUrl:null,channelType:null,pollId:null,pollOptionId:null},E=function(t){return u("string",t.channelUrl)&&p(d,t.channelType)&&u("number",t.pollId)&&u("number",t.pollOptionId)},N={channelUrl:null,channelType:null,pollId:null},R=function(t){return u("string",t.channelUrl)&&""!==t.channelUrl&&p(d,t.channelType)&&u("number",t.pollId)},A={},V=function(){function t(t,n){var e=n.sdkState,o=n.dispatcher,s=n.sessionManager,l=n.requestQueue,a=n.logger;this._iid=t,this._sdkState=e,this._sessionManager=s,this._requestQueue=l,this._dispatcher=o,this._logger=a,A[t]=this}return t.of=function(t){return A[t]},t.prototype.buildPollFromSerializedData=function(t){var n=f(t);return new s(this._iid,s.payloadify(n))},t.prototype.get=function(t){return _(this,void 0,void 0,(function(){var n,e;return m(this,(function(o){switch(o.label){case 0:return g(R(t)).throw(I.invalidParameters),n=new O(w({},t)),[4,this._requestQueue.send(n)];case 1:return e=o.sent(),[2,e.as(x).poll]}}))}))},t.prototype.create=function(t){return _(this,void 0,void 0,(function(){var n,e,o;return m(this,(function(s){switch(s.label){case 0:return g(Q(t)).throw(I.invalidParameters),n=t.data,e=new b(w(w({},t),{data:n})),[4,this._requestQueue.send(e)];case 1:return o=s.sent(),[2,o.as(P).poll]}}))}))},t.prototype.getOption=function(t){return _(this,void 0,void 0,(function(){var n,e;return m(this,(function(o){switch(o.label){case 0:return g(E(t)).throw(I.invalidParameters),n=new q(w({},t)),[4,this._requestQueue.send(n)];case 1:return e=o.sent(),[2,e.as(L).pollOption]}}))}))},t.prototype.getPollChangeLogs=function(t,n,e,o){return void 0===o&&(o=v.SYNC_POLL_CHANGELOGS),_(this,void 0,void 0,(function(){var s,l,a,i,u,c,h;return m(this,(function(p){switch(p.label){case 0:return s=new S(r({channelType:n,channelUrl:t,timestamp:"number"==typeof e?e:null,token:"string"==typeof e?e:null})),[4,this._requestQueue.send(s)];case 1:return l=p.sent(),a=l.as(C),i=a.updatedPolls,u=a.deletedPollIds,c=a.hasMore,h=a.nextToken,i.length>0&&this._dispatcher.dispatch(new y({polls:i,source:o})),[2,{updatedPolls:i,deletedPollIds:u,hasMore:c,token:h}]}}))}))},t}(),j=function(t,n){this.pollId=0,this.messageId=0,this.pollId=n.poll.id,this.messageId=n.poll.message_id,this._iid=t,this._payload=n},z=function(t){this.pollId=0,this.messageId=0,this.pollId=t.poll_id,this.messageId=t.message_id,this._payload=t},D=function(o){function s(t){var s=t.channelUrl,l=t.channelType,a=t.token,i=t.limit,r=o.call(this)||this;return r.method=n.GET,r.path=e,r.params={channel_url:s,channel_type:l,token:a,limit:i},r}return t(s,o),s}(o),F=function(n){function e(t,e){var o,l=this;return(l=n.call(this,t,e)||this).polls=(null!==(o=e.polls)&&void 0!==o?o:[]).map((function(n){return new s(t,n)})),l.token=e.next,l}return t(e,n),e}(l),H=function(n){function e(t,e){return n.call(this,t,e.channelUrl,e.channelType,e)||this}return t(e,n),e.prototype.next=function(){return _(this,void 0,void 0,(function(){var t,n,e,o,s,l;return m(this,(function(a){switch(a.label){case 0:return this._validate()?this._isLoading?[3,3]:this._hasNext?(this._isLoading=!0,t=U.of(this._iid).requestQueue,n=new D(w(w({},this),{token:this._token})),[4,t.send(n)]):[3,2]:[3,5];case 1:return e=a.sent(),o=e.as(F),s=o.polls,l=o.token,this._token=l,this._hasNext=!!l,this._isLoading=!1,[2,s];case 2:return[2,[]];case 3:throw I.queryInProgress;case 4:return[3,6];case 5:throw I.invalidParameters;case 6:return[2]}}))}))},e}(T),K=function(o){function s(t){var s=t.channelUrl,l=t.channelType,a=t.pollId,i=t.pollOptionId,r=t.token,u=t.limit,c=o.call(this)||this;return c.method=n.GET,c.path="".concat(e,"/").concat(encodeURIComponent(a),"/options/").concat(encodeURIComponent(i),"/voters"),c.params={channel_url:s,channel_type:l,token:r,limit:u},c}return t(s,o),s}(o),Y=function(n){function e(t,e){var o,s=this;return(s=n.call(this,t,e)||this).voters=(null!==(o=e.voters)&&void 0!==o?o:[]).map((function(n){return new k(t,n)})),s.token=e.next,s}return t(e,n),e}(l),B=function(n){function e(t,e){var o=n.call(this,t,e.channelUrl,e.channelType,e)||this;return o.pollId=e.pollId,o.pollOptionId=e.pollOptionId,o}return t(e,n),e.prototype._validate=function(){return n.prototype._validate.call(this)&&u("number",this.pollId)&&u("number",this.pollOptionId)},e.prototype.next=function(){return _(this,void 0,void 0,(function(){var t,n,e,o,s,l;return m(this,(function(a){switch(a.label){case 0:return this._validate()?this._isLoading?[3,3]:this._hasNext?(this._isLoading=!0,t=U.of(this._iid).requestQueue,n=new K(w(w({},this),{pollId:this.pollId,pollOptionId:this.pollOptionId,token:this._token})),[4,t.send(n)]):[3,2]:[3,5];case 1:return e=a.sent(),o=e.as(Y),s=o.voters,l=o.token,this._token=l,this._hasNext=!!l,this._isLoading=!1,[2,s];case 2:return[2,[]];case 3:throw I.queryInProgress;case 4:return[3,6];case 5:throw I.invalidParameters;case 6:return[2]}}))}))},e}(T);export{H as P,B as a,V as b,M as c,N as d,R as e,G as f,E as g,j as h,z as i,Q as v}; diff --git a/lib/__bundle-528a3094.js b/lib/__bundle-528a3094.js deleted file mode 100644 index 691acc3..0000000 --- a/lib/__bundle-528a3094.js +++ /dev/null @@ -1 +0,0 @@ -import{a6 as e,a1 as t,af as n,b as r,J as i,c as s,g as a,a as o,i as c,_ as u,S as l,$ as h,ap as d,a4 as f,aq as _,w as p,x as m,ac as v,ai as y,ah as b,U as E,W as g,q as N,r as I,ar as w,as as T}from"./__bundle-a8606dd4.js";import{U as A,s as O,v as C,j as S,k as L,l as k,m as R,n as x,F as D,o as P,b as M,D as B}from"./__bundle-e99277d8.js";import{S as H,U,F as V,b as K,c as q}from"./__bundle-8cd94b6f.js";var F,j,G;!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"}(F||(F={})),function(e){e.CHRONOLOGICAL="chronological",e.CHANNEL_NAME_ALPHABETICAL="channel_name_alphabetical",e.METADATA_VALUE_ALPHABETICAL="metadata_value_alphabetical"}(j||(j={})),function(e){e.CREATED_AT="created_at",e.SCHEDULED_AT="scheduled_at"}(G||(G={}));var z,W=function(e){switch(e){case F.LATEST_LAST_MESSAGE:return["-lastMessageUpdatedAt","-createdAt","syncIndex"];case F.CHRONOLOGICAL:return["-createdAt","syncIndex"];case F.CHANNEL_NAME_ALPHABETICAL:return["name"]}},Y=function(){function r(){this.messageTypeFilter=e.ALL,this.customTypesFilter=null,this.senderUserIdsFilter=null,this.replyType=n.NONE}return r.prototype.clone=function(){var e=new r,t=JSON.parse(JSON.stringify(this));return Object.keys(t).forEach((function(n){e[n]=t[n]})),e},r.prototype.match=function(r){switch(this.messageTypeFilter){case e.USER:if(r.messageType!==t.USER)return!1;break;case e.FILE:if(r.messageType!==t.FILE)return!1;break;case e.ADMIN:if(r.messageType!==t.ADMIN)return!1}if(this.customTypesFilter&&this.customTypesFilter.length>0&&!this.customTypesFilter.includes(r.customType))return!1;if(this.senderUserIdsFilter&&this.senderUserIdsFilter.length>0){if(!(r instanceof H))return!1;if(!this.senderUserIdsFilter.includes(r.sender.userId))return!1}switch(this.replyType){case n.NONE:if(r.parentMessageId>0)return!1;break;case n.ONLY_REPLY_TO_CHANNEL:if(r instanceof H&&r.parentMessageId>0&&!r.replyToChannel)return!1}return!0},r}();!function(e){e.CHANNEL_LATEST="channel_latest",e.NEWEST_CHILD_MESSAGE="newest_child_message"}(z||(z={}));var Q,J,Z=function(e){switch(e){case z.CHANNEL_LATEST:return["channelUrl","-createdAt","-messageId"];case z.NEWEST_CHILD_MESSAGE:return["channelUrl","-parentMessageId","-createdAt","-messageId"]}},X=function(){return"undefined"!=typeof document&&"undefined"!=typeof navigator&&"ReactNative"!==navigator.product},$=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"}(Q||(Q={})),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"}(J||(J={}));var ee,te={},ne=function(){function e(e,t){void 0===t&&(t={});var n=this;return this._state=Q.PROCESSING,this._queue=[],this._activationQueue=[],te[e]&&!t.forceCreate||(this.nodeId=$(),this.key=e,X()&&(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,s=e.data,a=s.nodeId,o=s.requestId,c=s.key,u=s.op,l=s.data;if(a!==n.nodeId&&c===n.key)switch(u){case J.NEWNODE:n._sendSync();break;case J.CLAIM_HOST:n._sendSync(),n._hostId=a;break;case J.SYNC_HOST:if(!n.isInSync){n._activationTimeout&&clearTimeout(n._activationTimeout);var h=l,d=h.currentItemRequestId,f=h.queue,_=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:J.REQUEST_LOCK,ts:e.ts})};try{for(var p=i(f),m=p.next();!m.done;m=p.next()){_(m.value)}}catch(e){t={error:e}}finally{try{m&&!m.done&&(r=p.return)&&r.call(p)}finally{if(t)throw t.error}}n._currentItem=n._queue.find((function(e){return e.requestId===d})),n._completeSync()}break;case J.REMOVENODE:n._queue=n._queue.filter((function(e){return e.nodeId!==s.nodeId})),n._currentItem&&n._currentItem.nodeId===s.nodeId&&(n._currentItem=void 0,n._acquire(n._queue[0]));break;case J.REQUEST_LOCK:n._requestLock(s);break;case J.ACQUIRE_LOCK:var v=n._queue.find((function(e){return e.requestId===o}));n._acquire(v);break;case J.RELEASE_LOCK:n._release(o)}})),window.addEventListener("beforeunload",(function(){n._send(J.REMOVENODE)}))),te[e]=this),te[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==Q.DONE},enumerable:!1,configurable:!0}),e.prototype._send=function(e,t){var n;void 0===t&&(t={});var r={nodeId:this.nodeId,requestId:null!==(n=null==t?void 0:t.requestId)&&void 0!==n?n:$(),key:this.key,op:e,data:t.data,ts:Date.now()};return X()&&window.postMessage(r,"*"),r},e.prototype._acquire=function(e){e?(this._currentItem=e,this._currentItem.onAcquired&&this._currentItem.onAcquired(e.requestId)):this._currentItem=void 0},e.prototype._release=function(e){if(this._currentItem&&this._currentItem.requestId===e){var t=this._currentItem;this._currentItem=void 0,t.nodeId===this.nodeId&&this._send(J.RELEASE_LOCK,{requestId:t.requestId});var n=this._queue.findIndex((function(t){return t.requestId===e}));n>-1&&this._queue.splice(n,1),t.onReleased&&t.onReleased(e)}},e.prototype._requestLock=function(e){var t=this;return new Promise((function(n){var r={nodeId:e.nodeId,requestId:e.requestId,ts:e.ts,onAcquired:function(e){t.isHost&&t._send(J.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(J.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 r(this,void 0,void 0,(function(){var e=this;return s(this,(function(t){return this.isHost&&!this.isInSync?[2,new Promise((function(t){e._activationQueue.push(t)}))]:[2]}))}))},e.prototype._waitSync=function(){var e=this;this.isInSync||(this._activationTimeout=setTimeout((function(){e._completeSync()}),8))},e.prototype._completeSync=function(){this.isInSync||(this._state=Q.DONE,this._activationQueue.forEach((function(e){return e()})),this._activationQueue=[])},e.prototype.registerNode=function(){this._send(J.NEWNODE),this._waitSync()},e.prototype.claimHost=function(){this._hostId=this.nodeId,this._send(J.CLAIM_HOST),this._waitSync()},e.prototype.lock=function(){return r(this,void 0,void 0,(function(){var e;return s(this,(function(t){switch(t.label){case 0:return[4,this._waitUntilSyncCompleted()];case 1:return t.sent(),e=this._send(J.REQUEST_LOCK),[4,this._requestLock(e)];case 2:return t.sent(),[2]}}))}))},e.prototype.unlock=function(){var e;(null===(e=this._currentItem)||void 0===e?void 0:e.requestId)&&this._release(this._currentItem.requestId)},e}(),re=a(a({},A),{scheduledAt:null}),ie=function(e){return C(e)&&o("number",e.scheduledAt,!0)},se=a(a({},S),{scheduledAt:null,file:null,fileUrl:null,fileName:null,mimeType:null,fileSize:null,thumbnailSizes:null,requireAuth:!1}),ae=function(e){return k(e)&&o("number",e.scheduledAt)&&(c(e.file)||o("string",e.fileUrl))&&o("string",e.fileName,!0)&&o("string",e.mimeType,!0)&&o("number",e.fileSize,!0)&&(null===e.thumbnailSizes||void 0===e.thumbnailSizes||e.thumbnailSizes.every((function(e){return o("object",e)&&e.maxWidth>0&&e.maxHeight>0})))},oe="UnsentMessage",ce="reqId",ue={},le=function(e){function t(t,n){var r=n.sdkState,i=n.cacheContext,s=e.call(this,t)||this;return s._sdkState=r,s._cacheContext=i,ue[t]=s,s._mutex=new ne("unsendmessagecache.lock"),s}return u(t,e),t.of=function(e){return ue[e]},Object.defineProperty(t.prototype,"collection",{get:function(){var e=this._cacheContext.nestdb;return e&&e.collection(oe)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"localCacheEnabled",{get:function(){return this._cacheContext.localCacheEnabled&&!!this.collection},enumerable:!1,configurable:!0}),t.prototype._serialize=function(e){if(e.messageId>0)throw l.invalidParameters;var t,n=a({},e.serialize());return e instanceof U?(e.messageParams&&(n.messageParams=O(e.messageParams)),e.scheduledInfo&&e.scheduledInfo.scheduledMessageParams&&(n.scheduledInfo.scheduledMessageParams=(t=e.scheduledInfo.scheduledMessageParams,a(a({},O(t)),{scheduledAt:t.scheduledAt})))):e instanceof V?(e.messageParams&&(n.messageParams=L(e.messageParams)),e.scheduledInfo&&e.scheduledInfo.scheduledMessageParams&&(n.scheduledInfo.scheduledMessageParams=function(e){return a(a({},L(e)),{scheduledAt:e.scheduledAt})}(e.scheduledInfo.scheduledMessageParams))):e instanceof K&&e.messageParams&&(n.messageParams=R(e.messageParams)),n},t.prototype._deserialize=function(e){return e?(e=a(a({},e),{messageId:parseInt(e.messageId)}),q.of(this._iid).buildMessageFromSerializedData(e)):null},t.prototype._deserializeWithMessageCreateParams=function(e){return r(this,void 0,void 0,(function(){var t,n,i,a,o,c,u=this;return s(this,(function(l){switch(l.label){case 0:return t=q.of(this._iid),n=this._deserialize(e),e.messageParams?n instanceof U?(a=e.messageParams,n.messageParams=t.buildUserMessageCreateParamsFromSerializedData(a,n),[3,6]):[3,1]:[3,6];case 1:return n instanceof V?(a=e.messageParams).fileKey&&"string"==typeof a.fileKey&&x(a.fileType)?(i=a,[4,this.collection.getBlob(a.fileKey)]):[3,3]:[3,4];case 2:i.file=l.sent(),l.label=3;case 3:return n.messageParams=t.buildFileMessageCreateParamsFromSerializedData(a,n),[3,6];case 4:return n instanceof K&&((a=e.messageParams)&&a.fileInfoList)?(n.messageParams=t.buildMultipleFilesMessageCreateParamsFromSerializedData(a,n),[4,Promise.all(n.messageParams.fileInfoList.map((function(e){return r(u,void 0,void 0,(function(){var t,n,r;return s(this,(function(i){switch(i.label){case 0:return"string"==typeof(null===(n=e._uploadedMetaData)||void 0===n?void 0:n.fileKey)&&x(null===(r=e._uploadedMetaData)||void 0===r?void 0:r.fileType)?(t=e,[4,this.collection.getBlob(e._uploadedMetaData.fileKey)]):[3,2];case 1:t.file=i.sent(),i.label=2;case 2:return[2]}}))}))})))]):[3,6];case 5:l.sent(),l.label=6;case 6:return n.scheduledInfo&&e.scheduledInfo&&e.scheduledInfo.scheduledMessageParams?n instanceof U?(o=e.scheduledInfo.scheduledMessageParams,n.scheduledInfo.scheduledMessageParams=t.buildScheduledUserMessageCreateParamsFromSerializedData(o,n),[3,10]):[3,7]:[3,10];case 7:return n instanceof V?(o=e.scheduledInfo.scheduledMessageParams).fileKey&&"string"==typeof o.fileKey&&x(o.fileType)?(c=o,[4,this.collection.getBlob(o.fileKey)]):[3,9]:[3,10];case 8:c.file=l.sent(),l.label=9;case 9:n.scheduledInfo.scheduledMessageParams=t.buildScheduledFileMessageCreateParamsFromSerializedData(o,n),l.label=10;case 10:return[2,n]}}))}))},t.prototype._getFileInfoBlobKey=function(e,t){return"".concat(e,".").concat(t)},t.prototype.get=function(e){return r(this,void 0,void 0,(function(){var t;return s(this,(function(n){switch(n.label){case 0:return this.localCacheEnabled?[4,this.collection.getByKey("".concat(e))]:[3,2];case 1:if(t=n.sent())return[2,this._deserializeWithMessageCreateParams(t)];n.label=2;case 2:return[2,null]}}))}))},t.prototype.fetch=function(e){var t=e.channelUrl,n=void 0===t?null:t,i=e.filter,a=void 0===i?new Y:i,o=e.order,c=void 0===o?z.CHANNEL_LATEST:o,u=e.sendingStatus,l=void 0===u?null:u,h=e.backward,d=void 0!==h&&h,f=e.parentMessageId,_=void 0===f?null:f;return r(this,void 0,void 0,(function(){var e,t,i,o,u=this;return s(this,(function(h){switch(h.label){case 0:return this.localCacheEnabled?(e=Z(c),t={"/where":function(e){return!!(c!==z.NEWEST_CHILD_MESSAGE||_&&0!==e.parentMessageId&&e.parentMessageId===_)&&a.match(u._deserialize(e))}},n&&(t.channelUrl=n),l&&(t.sendingStatus=l),i={where:t,index:e,backward:d},[4,this.collection.query(i)]):[3,3];case 1:return[4,h.sent().fetch({})];case 2:return o=h.sent(),[2,Promise.all(o.map((function(e){return r(u,void 0,void 0,(function(){return s(this,(function(t){switch(t.label){case 0:return[4,this._deserializeWithMessageCreateParams(e)];case 1:return[2,t.sent()]}}))}))})))];case 3:return[2,[]]}}))}))},t.prototype.getAllChildMessages=function(e,t){return void 0===t&&(t=new Y),r(this,void 0,void 0,(function(){return s(this,(function(n){switch(n.label){case 0:return[4,this.fetch({filter:t,order:z.NEWEST_CHILD_MESSAGE,channelUrl:e.channelUrl,backward:!1,parentMessageId:e.messageId})];case 1:return[2,n.sent()]}}))}))},t.prototype.upsert=function(e){return r(this,void 0,void 0,(function(){var t=this;return s(this,(function(n){switch(n.label){case 0:return this.localCacheEnabled?[4,Promise.all(e.map((function(e){return r(t,void 0,void 0,(function(){var t;return s(this,(function(n){switch(n.label){case 0:return e instanceof V||e instanceof K?[4,this._mutex.lock()]:[3,4];case 1:return n.sent(),[4,this.saveBlob(e)];case 2:return n.sent(),[4,this._mutex.unlock()];case 3:n.sent(),n.label=4;case 4:return t=this._serialize(e),[4,this.collection.upsertOne(t)];case 5:return n.sent(),[2]}}))}))})))]:[3,2];case 1:n.sent(),n.label=2;case 2:return[2]}}))}))},t.prototype.upsertChildMessages=function(e){return r(this,void 0,void 0,(function(){var t=this;return s(this,(function(n){switch(n.label){case 0:return this.localCacheEnabled?[4,Promise.all(e.map((function(e){return r(t,void 0,void 0,(function(){var t,n;return s(this,(function(r){switch(r.label){case 0:return t=[],(null===(n=e.threadInfo)||void 0===n?void 0:n.replyCount)>0?[4,this.getAllChildMessages(e)]:[3,2];case 1:t=r.sent(),r.label=2;case 2:return t.length>0?(t.forEach((function(t){return t.applyParentMessage(e)})),[4,this.upsert(t)]):[3,4];case 3:r.sent(),r.label=4;case 4:return[2]}}))}))})))]:[3,2];case 1:n.sent(),n.label=2;case 2:return[2]}}))}))},t.prototype.remove=function(e){return r(this,void 0,void 0,(function(){var t,n,r,a,o,c;return s(this,(function(s){switch(s.label){case 0:if(!this.localCacheEnabled)return[3,8];s.label=1;case 1:s.trys.push([1,6,7,8]),t=i(e),n=t.next(),s.label=2;case 2:return n.done?[3,5]:(r=n.value,[4,this.collection.remove(r)]);case 3:s.sent(),s.label=4;case 4:return n=t.next(),[3,2];case 5:return[3,8];case 6:return a=s.sent(),o={error:a},[3,8];case 7:try{n&&!n.done&&(c=t.return)&&c.call(t)}finally{if(o)throw o.error}return[7];case 8:return[2]}}))}))},t.prototype.removeMessagesOfChannel=function(e){return r(this,void 0,void 0,(function(){return s(this,(function(t){switch(t.label){case 0:return this.localCacheEnabled?[4,this.collection.removeIf({where:{channelUrl:e}})]:[3,2];case 1:t.sent(),t.label=2;case 2:return[2]}}))}))},t.prototype.clear=function(){return r(this,void 0,void 0,(function(){return s(this,(function(e){switch(e.label){case 0:return this.localCacheEnabled?[4,this.collection.clear()]:[3,2];case 1:e.sent(),e.label=2;case 2:return[2]}}))}))},t.prototype.saveBlob=function(e){return r(this,void 0,void 0,(function(){var t,n,i,a=this;return s(this,(function(o){switch(o.label){case 0:return e instanceof V?e.messageParams&&(i=e.messageParams).file&&P(i.file)?[4,this.collection.saveBlob(i.file,e.reqId)]:[3,2]:[3,5];case 1:n=o.sent(),i.fileKey=n,i.fileType=D.BLOB,o.label=2;case 2:return e.scheduledInfo&&e.scheduledInfo.scheduledMessageParams&&((t=e.scheduledInfo.scheduledMessageParams).file&&P(t.file))?[4,this.collection.saveBlob(t.file,e.reqId)]:[3,4];case 3:n=o.sent(),t.fileKey=n,t.fileType=D.BLOB,o.label=4;case 4:return[3,7];case 5:return e instanceof K&&((i=e.messageParams)&&i.fileInfoList&&Array.isArray(i.fileInfoList))?[4,Promise.all(i.fileInfoList.map((function(t,n){return r(a,void 0,void 0,(function(){var r,i;return s(this,(function(s){switch(s.label){case 0:return(r=t.file)&&P(r)?[4,this.collection.saveBlob(r,this._getFileInfoBlobKey(e.reqId,n))]:[3,2];case 1:i=s.sent(),t._uploadedMetaData||(t._uploadedMetaData={}),t._uploadedMetaData.fileKey=i,t._uploadedMetaData.fileType=D.BLOB,s.label=2;case 2:return[2]}}))}))})))]:[3,7];case 6:o.sent(),o.label=7;case 7:return[2]}}))}))},t}(h),he={},de=function(e){function t(t,n){var r=n.sdkState,i=n.cacheContext,s=n.unsentMessageCache,a=e.call(this,t)||this;return a._sdkState=r,a._cacheContext=i,a._unsentMessageCache=s,he[t]=a,a}return u(t,e),t.of=function(e){return he[e]},Object.defineProperty(t.prototype,"collection",{get:function(){var e=this._cacheContext.nestdb;return e?e.collection(M):null},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"localCacheEnabled",{get:function(){return this._cacheContext.localCacheEnabled&&!!this.collection},enumerable:!1,configurable:!0}),t.prototype._serialize=function(e){return a(a({},e.serialize()),{messageId:"".concat(e.messageId)})},t.prototype._deserialize=function(e){return e=a(a({},e),{messageId:parseInt(e.messageId)}),q.of(this._iid).buildMessageFromSerializedData(e)},t.prototype.get=function(e){return r(this,void 0,void 0,(function(){var t;return s(this,(function(n){switch(n.label){case 0:return this.localCacheEnabled?[4,this.collection.getByKey("".concat(e))]:[3,2];case 1:if(t=n.sent())return[2,this._deserialize(t)];n.label=2;case 2:return[2,null]}}))}))},t.prototype.fetch=function(e){var t=e.channelUrl,n=e.token,i=e.limit,a=void 0===i?B:i,o=e.filter,c=void 0===o?new Y:o,u=e.order,l=void 0===u?z.CHANNEL_LATEST:u,h=e.backward,d=void 0!==h&&h,f=e.parentMessageId,_=void 0===f?null:f,p=e.isPollOnly,m=void 0!==p&&p;return r(this,void 0,void 0,(function(){var e,i,o,u=this;return s(this,(function(h){switch(h.label){case 0:return this.localCacheEnabled?(e=Z(l),i={where:{channelUrl:t,"/where":function(e){if(n)switch(l){case z.CHANNEL_LATEST:if(!d&&e.createdAt>n||d&&e.createdAt0?[4,this.getAllChildMessages(e)]:[3,2];case 1:t=r.sent(),r.label=2;case 2:return t.length>0?(t.forEach((function(t){return t.applyParentMessage(e)})),[4,this.upsert(t)]):[3,4];case 3:r.sent(),r.label=4;case 4:return[2]}}))}))})))]:[3,2];case 1:n.sent(),n.label=2;case 2:return[2]}}))}))},t.prototype.remove=function(e){return r(this,void 0,void 0,(function(){var t,n,r,a,o,c;return s(this,(function(s){switch(s.label){case 0:if(!this.localCacheEnabled)return[3,8];s.label=1;case 1:s.trys.push([1,6,7,8]),t=i(e),n=t.next(),s.label=2;case 2:return n.done?[3,5]:(r=n.value,[4,this.collection.remove("".concat(r))]);case 3:s.sent(),s.label=4;case 4:return n=t.next(),[3,2];case 5:return[3,8];case 6:return a=s.sent(),o={error:a},[3,8];case 7:try{n&&!n.done&&(c=t.return)&&c.call(t)}finally{if(o)throw o.error}return[7];case 8:return[2]}}))}))},t.prototype.removeMessagesOfChannel=function(e){return r(this,void 0,void 0,(function(){var t;return s(this,(function(n){switch(n.label){case 0:return this.localCacheEnabled?[4,this.collection.removeIf({where:{channelUrl:e},index:Z(z.CHANNEL_LATEST)})]:[3,6];case 1:return n.sent(),[4,(t=this._cacheContext.preference).remove("sendbird:".concat(this._sdkState.userId,"@groupchannel/").concat(e,"/message/sync"))];case 2:return n.sent(),[4,t.remove("sendbird:".concat(this._sdkState.userId,"@groupchannel/").concat(e,"/message/sync.meta"))];case 3:return n.sent(),[4,t.remove("sendbird:".concat(this._sdkState.userId,"@groupchannel/").concat(e,"/message/changelogs"))];case 4:return n.sent(),[4,t.remove("sendbird:".concat(this._sdkState.userId,"@groupchannel/").concat(e,"/message/changelogs.meta"))];case 5:n.sent(),n.label=6;case 6:return[2]}}))}))},t.prototype.removeUnderOffset=function(e,t){return r(this,void 0,void 0,(function(){return s(this,(function(n){switch(n.label){case 0:return this.localCacheEnabled?[4,this.collection.removeIf({where:{channelUrl:e,createdAt:{"<":t}},index:Z(z.CHANNEL_LATEST)})]:[3,2];case 1:n.sent(),n.label=2;case 2:return[2]}}))}))},t.prototype.clear=function(){return r(this,void 0,void 0,(function(){return s(this,(function(e){switch(e.label){case 0:return this.localCacheEnabled?[4,this.collection.clear()]:[3,2];case 1:e.sent(),e.label=2;case 2:return[2]}}))}))},t.prototype.countBetween=function(e,t,n){return r(this,void 0,void 0,(function(){var r,i=this;return s(this,(function(s){switch(s.label){case 0:return this.localCacheEnabled?(r=Z(z.CHANNEL_LATEST),[4,this.collection.query({where:{channelUrl:e,"/where":function(e){var r=i._deserialize(e);return n.includes(r.createdAt)&&t.match(r)}},index:r}).count()]):[3,2];case 1:return[2,s.sent()];case 2:return[2,0]}}))}))},t.prototype.saveBlobs=function(e){return r(this,void 0,void 0,(function(){var t=this;return s(this,(function(n){switch(n.label){case 0:return[4,Promise.all(e.map((function(e){return r(t,void 0,void 0,(function(){var t,n;return s(this,(function(r){switch(r.label){case 0:return e instanceof V&&e.messageParams&&((t=e.messageParams).file&&P(t.file))?[4,this.collection.saveBlob(t.file,e.reqId)]:[3,2];case 1:n=r.sent(),t.fileKey=n,r.label=2;case 2:return[2]}}))}))})))];case 1:return n.sent(),[2]}}))}))},t.prototype._getGroupChannelPreferenceSize=function(e){return r(this,void 0,void 0,(function(){var t,n,r,i,a,o;return s(this,(function(s){switch(s.label){case 0:return t=0,[4,(n=this._cacheContext.preference).get("sendbird:".concat(this._sdkState.userId,"@groupchannel/").concat(e,"/message/sync"))];case 1:return r=s.sent(),[4,n.get("sendbird:".concat(this._sdkState.userId,"@groupchannel/").concat(e,"/message/sync.meta"))];case 2:return i=s.sent(),[4,n.get("sendbird:".concat(this._sdkState.userId,"@groupchannel/").concat(e,"/message/changelogs"))];case 3:return a=s.sent(),[4,n.get("sendbird:".concat(this._sdkState.userId,"@groupchannel/").concat(e,"/message/changelogs.meta"))];case 4:return o=s.sent(),r&&(t+=JSON.stringify(r).length),i&&(t+=JSON.stringify(i).length),a&&(t+=JSON.stringify(a).length),o&&(t+=JSON.stringify(o).length),[2,t]}}))}))},t}(h),fe=function(e){function t(t){var n=t.message,r=e.call(this)||this;return r.message=n,r}return u(t,e),t}(d),_e={},pe=function(){function e(e,t){var n=t.localCacheEnabled,r=t.dispatcher,i=t.sdkState,s=t.logger,a=this;this._iid=e,_e[e]=this,this._localCacheEnabled=n,this._isProcessingAutoResend=!1,this._autoResendQueue=[],this._dispatcher=r,this._logger=s,this._sdkState=i,this._localCacheEnabled&&r.on((function(e){if(e instanceof p)switch(e.stateType){case m.CONNECTED:a._isProcessingAutoResend||a.processAutoResendRegisteredPendingMessages().then((function(){return a._processNextAutoResend()}));break;case m.INTERNAL_DISCONNECTED:case m.EXTERNAL_DISCONNECTED:a._isProcessingAutoResend=!1}}))}return e.of=function(e){return _e[e]},e.prototype.processNonAutoResendRegisteredPendingMessages=function(){return r(this,void 0,void 0,(function(){var e,t,n,r,a,o;return s(this,(function(s){switch(s.label){case 0:return[4,this._fetchAllCachedPendingMessages()];case 1:e=s.sent();try{for(t=i(e),n=t.next();!n.done;n=t.next())0===(r=n.value).errorCode&&(this._logger.debug("cached pending message is not auto-resend registered. changing its sending status to failed: ",r.reqId),r.sendingStatus=f.FAILED,r.errorCode=v.ACK_TIMEOUT,this._dispatcher.dispatch(new y({messages:[r],source:b.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.processAutoResendRegisteredPendingMessages=function(){return r(this,void 0,void 0,(function(){var e,t,n,r,a,o,c,u;return s(this,(function(s){switch(s.label){case 0:return[4,this._fetchAllCachedPendingMessages()];case 1:e=s.sent();try{for(t=i(e),n=t.next();!n.done;n=t.next())(r=n.value).errorCode&&_(r.errorCode)&&(a=(new Date).getTime(),o=r.createdAt+2592e5,a<=o?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(o).toLocaleString()),r.sendingStatus=f.FAILED,this._dispatcher.dispatch(new y({messages:[r],source:b.LOCAL_MESSAGE_FAILED}))))}catch(e){c={error:e}}finally{try{n&&!n.done&&(u=t.return)&&u.call(t)}finally{if(c)throw c.error}}return[2]}}))}))},e.prototype.completeCurrentAndProcessNextAutoResend=function(e){if(this._localCacheEnabled&&(e.sendingStatus===f.SUCCEEDED||e.sendingStatus===f.FAILED&&!_(e.errorCode))){var t=this.indexOf(e);t>=0&&this._autoResendQueue.splice(t,1),0===t&&this._processNextAutoResend()}},e.prototype._fetchAllCachedPendingMessages=function(){return r(this,void 0,void 0,(function(){var e,t;return s(this,(function(n){switch(n.label){case 0:return(e=le.of(this._iid))?[4,e.fetch({sendingStatus:f.PENDING,backward:!0})]:[3,2];case 1:return t=n.sent(),[3,3];case 2:t=[],n.label=3;case 3:return[2,t]}}))}))},e.prototype.indexOf=function(e){return this._autoResendQueue.length>0?this._autoResendQueue.map((function(e){return e.reqId})).indexOf(e.reqId):-1},e.prototype._isNotInQueue=function(e){return-1===this._autoResendQueue.map((function(e){return e.reqId})).indexOf(e.reqId)},e.prototype._processNextAutoResend=function(){return r(this,void 0,void 0,(function(){var e;return s(this,(function(t){if(this._localCacheEnabled&&"foreground"===this._sdkState.appState)try{this._autoResendQueue.length>0?(this._isProcessingAutoResend||(this._logger.debug("auto-resend queue started."),this._isProcessingAutoResend=!0),e=this._autoResendQueue[0],this._dispatcher.dispatch(new fe({message:e})),this._logger.debug("processing auto-resend for message request id: ",e.reqId)):(this._logger.debug("auto-resend queue finished."),this._isProcessingAutoResend=!1)}catch(e){this._logger.warn("process auto-resend error: ",e),this._isProcessingAutoResend=!1}return[2]}))}))},e}();!function(e){e[e.USER_BLOCK=20001]="USER_BLOCK",e[e.USER_UNBLOCK=2e4]="USER_UNBLOCK",e[e.FRIEND_DISCOVERED=20900]="FRIEND_DISCOVERED"}(ee||(ee={}));var me,ve=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,i=n.blockee;return{blocker:new E(e,r),blockee:new E(e,i)}},e.getDataAsFriendDiscoveredEvent=function(e,t){var n=t.data.friend_discoveries;return{friendDiscoveries:Array.isArray(n)?n.map((function(t){return new E(e,t)})):[]}},e}(),ye=function(e){function t(t,n){var r=n.userId,i=e.call(this)||this;return i._iid=t,i.userId=r,i}return u(t,e),t}(d);!function(e){e.UNKNOWN="UNKNOWN",e.EVENT_CHANNEL_CREATED="EVENT_CHANNEL_CREATED",e.EVENT_CHANNEL_UPDATED="EVENT_CHANNEL_UPDATED",e.EVENT_CHANNEL_DELETED="EVENT_CHANNEL_DELETED",e.EVENT_CHANNEL_READ="EVENT_CHANNEL_READ",e.EVENT_CHANNEL_DELIVERED="EVENT_CHANNEL_DELIVERED",e.EVENT_CHANNEL_INVITED="EVENT_CHANNEL_INVITED",e.EVENT_CHANNEL_JOINED="EVENT_CHANNEL_JOINED",e.EVENT_CHANNEL_LEFT="EVENT_CHANNEL_LEFT",e.EVENT_CHANNEL_ACCEPTED_INVITE="EVENT_CHANNEL_ACCEPTED_INVITE",e.EVENT_CHANNEL_DECLINED_INVITE="EVENT_CHANNEL_DECLINED_INVITE",e.EVENT_CHANNEL_OPERATOR_UPDATED="EVENT_CHANNEL_OPERATOR_UPDATED",e.EVENT_CHANNEL_MUTED="EVENT_CHANNEL_MUTED",e.EVENT_CHANNEL_UNMUTED="EVENT_CHANNEL_UNMUTED",e.EVENT_CHANNEL_FROZEN="EVENT_CHANNEL_FROZEN",e.EVENT_CHANNEL_UNFROZEN="EVENT_CHANNEL_UNFROZEN",e.EVENT_CHANNEL_HIDDEN="EVENT_CHANNEL_HIDDEN",e.EVENT_CHANNEL_UNHIDDEN="EVENT_CHANNEL_UNHIDDEN",e.EVENT_CHANNEL_RESET_HISTORY="EVENT_CHANNEL_RESET_HISTORY",e.EVENT_CHANNEL_TYPING_STATUS_UPDATE="EVENT_CHANNEL_TYPING_STATUS_UPDATE",e.EVENT_CHANNEL_MEMBER_COUNT_UPDATED="EVENT_CHANNEL_MEMBER_COUNT_UPDATED",e.EVENT_MESSAGE_SENT="EVENT_MESSAGE_SENT",e.EVENT_MESSAGE_RECEIVED="EVENT_MESSAGE_RECEIVED",e.EVENT_MESSAGE_UPDATED="EVENT_MESSAGE_UPDATED",e.EVENT_PINNED_MESSAGE_UPDATED="EVENT_PINNED_MESSAGE_UPDATED",e.REQUEST_CHANNEL="REQUEST_CHANNEL",e.REQUEST_CHANNEL_CHANGELOGS="REQUEST_CHANNEL_CHANGELOGS",e.REFRESH_CHANNEL="REFRESH_CHANNEL",e.CHANNEL_LASTACCESSEDAT_UPDATED="CHANNEL_LASTACCESSEDAT_UPDATED",e.SYNC_CHANNEL_BACKGROUND="SYNC_CHANNEL_BACKGROUND",e.SYNC_CHANNEL_CHANGELOGS="SYNC_CHANNEL_CHANGELOGS"}(me||(me={}));var be,Ee=function(e){return e.startsWith("EVENT_")||e===me.SYNC_CHANNEL_CHANGELOGS||e===me.REFRESH_CHANNEL},ge=function(e){function t(t){var n=t.channels,r=t.source,i=t.data,s=void 0===i?null:i,a=e.call(this)||this;return a.channels=n,a.source=r,a.data=s,a}return u(t,e),t}(d),Ne=function(e){function t(t){var n=t.channelUrls,r=t.source,i=e.call(this)||this;return i.channelUrls=n,i.source=r,i}return u(t,e),t}(d),Ie=function(e){function t(){return e.call(this)||this}return u(t,e),t}(d),we=function(e){function t(t,n,r){var i=e.call(this,t,"USEV",r)||this;return i.event=new ve(r),i}return u(t,e),t}(g),Te={},Ae=function(){function e(e){var t=e.dbname,n=e.itemSizeLimit,r=void 0===n?1048576:n,i=e.cacheLimit,s=void 0===i?256:i,a=e.blockHashBase,o=void 0===a?2:a,c=e.blockHashMultiplier,u=void 0===c?10:c,l=e.blockHashConstant,h=void 0===l?11:l,d=e.transactionApplyDelay,f=void 0===d?200:d,_=e.disableLogger,p=void 0!==_&&_;return Te[t]||(this.itemSizeLimit=r,this.cacheLimit=s,this.blockHashBase=o,this.blockHashMultiplier=u,this.blockHashConstant=h,this.transactionApplyDelay=f,this.disableLogger=p,Te[t]=this),Te[t]}return e.get=function(e){return Te[e]},e}();!function(e){e[e.UNKNOWN_ERROR=6e7]="UNKNOWN_ERROR",e[e.STORE_NOT_DEFINED=61001e3]="STORE_NOT_DEFINED",e[e.STORE_NOT_AVAILABLE=61001001]="STORE_NOT_AVAILABLE",e[e.STORE_NOT_AVAILABLE_IN_PRIVATE_BROWSING=61001002]="STORE_NOT_AVAILABLE_IN_PRIVATE_BROWSING",e[e.STORE_IS_FULL=61001003]="STORE_IS_FULL",e[e.STORE_NOT_INITIALIZED=61001004]="STORE_NOT_INITIALIZED",e[e.STORE_INVALID_KEY_TYPE=61002e3]="STORE_INVALID_KEY_TYPE",e[e.STORE_BROKEN_INTEGRITY=61002001]="STORE_BROKEN_INTEGRITY",e[e.STORE_BROKEN_BLOB=61002002]="STORE_BROKEN_BLOB",e[e.STORE_ENCRYPTION_INVALID=61002003]="STORE_ENCRYPTION_INVALID",e[e.STORE_ITEM_SIZE_LIMIT_EXCEEDED=61017e3]="STORE_ITEM_SIZE_LIMIT_EXCEEDED",e[e.STORE_READ_FAILED=61017001]="STORE_READ_FAILED",e[e.STORE_WRITE_FAILED=61017002]="STORE_WRITE_FAILED",e[e.DATABASE_SCHEMA_NOT_ON_UPGRADE=62002e3]="DATABASE_SCHEMA_NOT_ON_UPGRADE",e[e.COLLECTION_NOT_READY=63001e3]="COLLECTION_NOT_READY",e[e.COLLECTION_KEY_NOT_MATCH=63002e3]="COLLECTION_KEY_NOT_MATCH",e[e.COLLECTION_QUERY_NOT_VALID=63002001]="COLLECTION_QUERY_NOT_VALID",e[e.COLLECTION_KEY_NOT_FOUND=63004e3]="COLLECTION_KEY_NOT_FOUND",e[e.COLLECTION_KEY_NOT_GIVEN=63004001]="COLLECTION_KEY_NOT_GIVEN",e[e.COLLECTION_INSERT_DUPLICATE=63009e3]="COLLECTION_INSERT_DUPLICATE",e[e.COLLECTION_WRITE_FAILED=63017e3]="COLLECTION_WRITE_FAILED",e[e.COLLECTION_ITEM_SIZE_LIMIT_EXCEEDED=63017001]="COLLECTION_ITEM_SIZE_LIMIT_EXCEEDED",e[e.INDEX_TABLE_IS_REQUIRED=65001e3]="INDEX_TABLE_IS_REQUIRED",e[e.INDEX_TYPE_NOT_MATCH=65002e3]="INDEX_TYPE_NOT_MATCH",e[e.COMPARE_TYPE_NOT_MATCH=69002001]="COMPARE_TYPE_NOT_MATCH",e[e.CIRCULAR_REFERENCE_FOUND=69002002]="CIRCULAR_REFERENCE_FOUND"}(be||(be={}));var Oe,Ce=function(e){function t(n){var r=n.code,i=void 0===r?be.UNKNOWN_ERROR:r,s=n.message,a=void 0===s?"Unknown error occurred.":s,o=e.call(this,a)||this;return o.code=i,Object.setPrototypeOf(o,t.prototype),o}return u(t,e),Object.defineProperty(t,"storeNotDefined",{get:function(){return new t({code:be.STORE_NOT_DEFINED,message:"Store is not defined. Specify the store on NestDB()"})},enumerable:!1,configurable:!0}),Object.defineProperty(t,"storeNotAvailable",{get:function(){return new t({code:be.STORE_NOT_AVAILABLE,message:"Store is not available. Check your environment settings."})},enumerable:!1,configurable:!0}),Object.defineProperty(t,"storeNotAvailableInPrivateBrowsing",{get:function(){return new t({code:be.STORE_NOT_AVAILABLE_IN_PRIVATE_BROWSING,message:"Store is not available because it is in private browsing."})},enumerable:!1,configurable:!0}),Object.defineProperty(t,"storeIsFull",{get:function(){return new t({code:be.STORE_IS_FULL,message:"Store is full."})},enumerable:!1,configurable:!0}),Object.defineProperty(t,"storeNotInitialized",{get:function(){return new t({code:be.STORE_NOT_INITIALIZED,message:"Store is not initialized."})},enumerable:!1,configurable:!0}),Object.defineProperty(t,"storeKeyTypeIsInvalid",{get:function(){return new t({code:be.STORE_INVALID_KEY_TYPE,message:"Store key should be string type."})},enumerable:!1,configurable:!0}),Object.defineProperty(t,"storeBrokenIntegrity",{get:function(){return new t({code:be.STORE_BROKEN_INTEGRITY,message:"Data should be in a store but it does not. Integrity is broken."})},enumerable:!1,configurable:!0}),Object.defineProperty(t,"storeBrokenBlob",{get:function(){return new t({code:be.STORE_BROKEN_BLOB,message:"Data should be in a store but it does not. Blob data is broken."})},enumerable:!1,configurable:!0}),Object.defineProperty(t,"storeEncryptionInvalid",{get:function(){return new t({code:be.STORE_ENCRYPTION_INVALID,message:"Encryption algorithm has changed. All the store should reset."})},enumerable:!1,configurable:!0}),Object.defineProperty(t,"storeItemSizeExceeded",{get:function(){return new t({code:be.STORE_ITEM_SIZE_LIMIT_EXCEEDED,message:"The size of the item exceeds the limit that the store allows."})},enumerable:!1,configurable:!0}),Object.defineProperty(t,"storeReadFailed",{get:function(){return new t({code:be.STORE_READ_FAILED,message:"Failed to read from store."})},enumerable:!1,configurable:!0}),Object.defineProperty(t,"storeWriteFailed",{get:function(){return new t({code:be.STORE_WRITE_FAILED,message:"Failed to write to store."})},enumerable:!1,configurable:!0}),Object.defineProperty(t,"databaseSchemaNotOnUpgrade",{get:function(){return new t({code:be.DATABASE_SCHEMA_NOT_ON_UPGRADE,message:"Committing schema is not allowed when upgrade is not running."})},enumerable:!1,configurable:!0}),Object.defineProperty(t,"collectionNotReady",{get:function(){return new t({code:be.COLLECTION_NOT_READY,message:"Collection is not ready due to an error during initialization."})},enumerable:!1,configurable:!0}),Object.defineProperty(t,"collectionKeyNotMatch",{get:function(){return new t({code:be.COLLECTION_KEY_NOT_MATCH,message:"keyName of collection could not change."})},enumerable:!1,configurable:!0}),Object.defineProperty(t,"collectionQueryNotValid",{get:function(){return new t({code:be.COLLECTION_QUERY_NOT_VALID,message:"Query parameter is not a valid format."})},enumerable:!1,configurable:!0}),Object.defineProperty(t,"collectionInsertDuplicate",{get:function(){return new t({code:be.COLLECTION_INSERT_DUPLICATE,message:"The key already exists."})},enumerable:!1,configurable:!0}),Object.defineProperty(t,"collectionKeyNotFound",{get:function(){return new t({code:be.COLLECTION_KEY_NOT_FOUND,message:"The key is not found."})},enumerable:!1,configurable:!0}),Object.defineProperty(t,"collectionKeyNotGiven",{get:function(){return new t({code:be.COLLECTION_KEY_NOT_GIVEN,message:"The item should contain [keyName] property."})},enumerable:!1,configurable:!0}),Object.defineProperty(t,"collectionWriteFailed",{get:function(){return new t({code:be.COLLECTION_WRITE_FAILED,message:"Failed to write an item."})},enumerable:!1,configurable:!0}),Object.defineProperty(t,"collectionItemSizeExceeded",{get:function(){return new t({code:be.COLLECTION_ITEM_SIZE_LIMIT_EXCEEDED,message:"The size of the item exceeds the limit that a collection allows."})},enumerable:!1,configurable:!0}),Object.defineProperty(t,"indexTableIsRequired",{get:function(){return new t({code:be.INDEX_TABLE_IS_REQUIRED,message:"Index table is required."})},enumerable:!1,configurable:!0}),Object.defineProperty(t,"indexTypesNotMatch",{get:function(){return new t({code:be.INDEX_TYPE_NOT_MATCH,message:"Indexed column should have primitive type."})},enumerable:!1,configurable:!0}),Object.defineProperty(t,"compareTypesNotMatch",{get:function(){return new t({code:be.COMPARE_TYPE_NOT_MATCH,message:"Values to compare have different types."})},enumerable:!1,configurable:!0}),Object.defineProperty(t,"circularReferenceFound",{get:function(){return new t({code:be.CIRCULAR_REFERENCE_FOUND,message:"Cannot handle circular referenced object."})},enumerable:!1,configurable:!0}),t}(Error);!function(e){e.INIT="init",e.READY="ready",e.CLOSED="closed"}(Oe||(Oe={}));var Se,Le=function(e,t){if(void 0===t&&(t=new WeakMap),"object"==typeof e&&null!==e){if(t.has(e))throw Ce.circularReferenceFound;t.set(e,!0);var n=void 0;if(Array.isArray(e))n=e.map((function(e){return Le(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]=Le(e[r],t);return t.delete(e),n}return e},ke=function(e,t){if(null==t)return 1;if(null==e)return-1;if(typeof e!=typeof t)throw Ce.compareTypesNotMatch;var n=0;switch(typeof e){case"boolean":case"number":n=e-t;break;case"string":n=e.localeCompare(t)}return n},Re=function(e,t){for(var n=0,r=0;r>>0)%t},xe=function(e){return new Promise((function(t){setTimeout((function(){return t()}),e)}))},De=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!De(e,t)})))return!1}else if(["/or","||"].includes(n)){if(e[n].every((function(e){return!De(e,t)})))return!1}else if("/where"===n){if(!(0,e[n])(t))return!1}else{var r=n;if("object"==typeof e[r]){var i=e[r];for(var s in i)switch(s){case"/eq":case"=":if((a=t[r])!==(o=i[s]))return!1;break;case"/neq":case"!=":if((a=t[r])===(o=i[s]))return!1;break;case"/gt":case">":var a=t[r],o=i[s];if(!(ke(a,o)>0))return!1;break;case"/gte":case">=":a=t[r],o=i[s];if(!(ke(a,o)>=0))return!1;break;case"/lt":case"<":a=t[r],o=i[s];if(!(ke(a,o)<0))return!1;break;case"/lte":case"<=":a=t[r],o=i[s];if(!(ke(a,o)<=0))return!1;break;case"/in":a=t[r];if(!(o=i[s]).includes(a))return!1;break;case"/nin":a=t[r];if((o=i[s]).includes(a))return!1;break;case"/contain":a=t[r],o=i[s];if(!a.includes(o))return!1;break;case"/regex":a=t[r];if(!(o=i[s]).test(a))return!1;break;case"/where":a=t[r];if(!(0,i[s])(a))return!1}}else if("function"==typeof e[r]){if(!e[r](t[r]))return!1}else if(e[r]!==t[r])return!1}}return!0}return e(t)},Pe=function(){},Me=function(){return Promise.resolve()},Be=function(e){return e},He=function(e,t){t()};!function(e){e[e.FORWARD=0]="FORWARD",e[e.BACKWARD=1]="BACKWARD"}(Se||(Se={}));var Ue,Ve,Ke,qe=function(){function e(e){var t=e.initialPrevValue,n=void 0===t?null:t,r=e.initialNextValue,i=void 0===r?null:r,s=e.iterator,a=e.map,o=void 0===a?Be:a,c=e.backward,u=void 0===c?Me:c,l=e.forward,h=void 0===l?Me:l,d=e.complete,f=void 0===d?Pe:d;this._prevValue=n,this._nextValue=i,this._error=null,this._map=o,this._backward=u,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 r(this,void 0,void 0,(function(){var e,t,n;return s(this,(function(r){switch(r.label){case 0:if(!this.hasPrevious)return[3,6];r.label=1;case 1:return r.trys.push([1,3,,4]),e=this._prevValue,t=this,[4,this._backward()];case 2:return t._prevValue=r.sent()||null,this._nextValue=e,[3,4];case 3:return n=r.sent(),this._error=n,[3,4];case 4:return[4,this._iterator(this)];case 5:return[2,r.sent()];case 6:this._complete(),r.label=7;case 7:return[2]}}))}))},e.prototype.next=function(){return r(this,void 0,void 0,(function(){var e,t,n;return s(this,(function(r){switch(r.label){case 0:if(!this.hasNext)return[3,6];r.label=1;case 1:return r.trys.push([1,3,,4]),e=this._nextValue,t=this,[4,this._forward()];case 2:return t._nextValue=r.sent()||null,this._prevValue=e,[3,4];case 3:return n=r.sent(),this._error=n,[3,4];case 4:return[4,this._iterator(this)];case 5:return[2,r.sent()];case 6:this._complete(),r.label=7;case 7:return[2]}}))}))},e.prototype.stop=function(){this._prevValue=null,this._nextValue=null,this._complete()},e}(),Fe=function(){function e(e){var t=e.condition,n=void 0===t?{}:t,r=e.backward,i=void 0!==r&&r,s=e.blockManager,a=e.indexer;this.condition=n,this.backward=i,this._blockManager=s,this._indexer=a}return e.prototype.findOptimizedStartPosition=function(){var e=this,t=["=","/eq",">",">=","/gt","/gte"],n=["=","/eq","<","<=","/lt","/lte"];if(this.backward){var r=this._indexer.origin.length-1;if("function"!=typeof this.condition)for(var i in this._indexer.fields){var s=this._indexer.fields[i],a=1;if("-"===s[0]&&(s=s.slice(1),a=-1),this.condition[s])if("object"==typeof this.condition[s]){var o=a>0?n:t;for(var c in this.condition[s])if(o.includes(c))for(var u=r;u>=0;u--)if(a*ke(this._indexer.origin[u].columnValues[i],this.condition[s][c])<=0){r=u;break}}else for(u=r;u>=0;u--)if(a*ke(this._indexer.origin[u].columnValues[i],this.condition[s])<=0){r=u;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(a){if((s>0?t:n).includes(a))for(var o=l;o=0){l=o;break}}));else for(var a=l;a=0){l=a;break}},d=this,i=0;i-1){var r=this._items[n];return t===Ke.PERSISTENT&&(r.state=Ve.PERSISTENT),t!==Ke.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)Xe.includes(this._items[r].state)&&Xe.includes(e.state)?(this._items.splice(r,1),this._items.push(e)):(this._items[r].state=e.state,this._items[r].value=e.value);else{this._items.push(e);var s=this._items.filter((function(e){return e.state===Ve.VOLATILE})),a=s.length-this._limit;if(a>0){var o=[];try{for(var c=i(this._items),u=c.next();!u.done;u=c.next()){var l=u.value;l.state===Ve.VOLATILE&&a>0?a--:o.push(l)}}catch(e){t={error:e}}finally{try{u&&!u.done&&(n=c.return)&&n.call(c)}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!==Ve.VOLATILE}))},e}(),tt=function(){function e(e){var t=e.dbname,n=e.collectionName,r=e.store;this._requests=[],this._onCommit=new Map,this._onWrite=new Map,this._onError=new Map,this.dbname=t,this.collectionName=n,this.metadataKey=function(e,t){return"".concat(ze(e,t),"/trans.metadata")}(t,n),this.recordsetKey=function(e,t){return"".concat(ze(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=[]),r(this,void 0,void 0,(function(){var t;return s(this,(function(n){switch(n.label){case 0:return[4,this._store.get(this.recordsetKey)];case 1:return(t=n.sent()||[]).push.apply(t,N([],I(e),!1)),[2,this._reduceRecordSet(t)]}}))}))},e.prototype._reduceRecordSet=function(e){for(var t=[],n={},r=e.length-1;r>=0;r--){for(var i=e[r],s=[],a=i.requests.length-1;a>=0;a--){var o=i.requests[a],c=o.data;n[c.key]||(s.unshift(o),n[c.key]=!0)}s.length>0&&(i.requests=s,t.unshift(i))}return t},e.prototype._applyRecord=function(e,t){return r(this,void 0,void 0,(function(){var n,r,i,o,c,u,l,h,d;return s(this,(function(s){switch(s.label){case 0:n=et.get(this.dbname),r=t.generation,i=t.requests,o=null,s.label=1;case 1:return s.trys.push([1,3,,4]),[4,this._store.setMany(i.map((function(e){return a(a({},e.data),{generation:r})})))];case 2:for(c=s.sent(),u=0;u0))return[3,4];for(t=[],n={},u=e.length-1;u>=0;u--)r=e[u],h=r.data,n[h.key]||(n[h.key]=!0,t.unshift(r));return i={generation:this.generation,requests:t},[4,this._getReducedRecordset([i])];case 1:return o=s.sent(),[4,this._store.set({key:this.recordsetKey,value:o})];case 2:return s.sent(),this._metadata.generation++,[4,this._store.set({key:this.metadataKey,value:this._metadata})];case 3:for(s.sent(),c=et.get(this.dbname),u=0;u0?(r=this.createBlockId(e,n),[4,t.find(this._store,r)]):[3,4];case 2:if((i=s.sent())&&(a=nt.createFromCacheItem(i),null==a?void 0:a.getItemByKey(e)))return[2,a];s.label=3;case 3:return n--,[3,1];case 4:return[2,null]}}))}))},e.prototype.getFromBlock=function(e){return r(this,void 0,void 0,(function(){var t;return s(this,(function(n){switch(n.label){case 0:return[4,this._findBlock(e)];case 1:return[2,(t=n.sent())?t.getItemByKey(e):null]}}))}))},e.prototype.putToBlock=function(e,t){return r(this,void 0,void 0,(function(){var n,r,i,a,o;return s(this,(function(s){switch(s.label){case 0:return n=Ae.get(this.dbname),r=this.createBlockId(e),i=Math.floor(this._store.itemSizeLimit/n.itemSizeLimit),[4,et.get(this.dbname).find(this._store,r)];case 1:return a=s.sent(),(null==(o=a?nt.createFromCacheItem(a):new nt({blockId:r,keyName:this.keyName,items:[],limit:i}))?void 0:o.add(t))?(this._transaction.requestWrite({key:o.blockId,value:o.serialize()}),[2,!0]):[2,!1]}}))}))},e.prototype.removeFromBlock=function(e){return r(this,void 0,void 0,(function(){var t;return s(this,(function(n){switch(n.label){case 0:return[4,this._findBlock(e)];case 1:return(t=n.sent())&&t.remove(e)?(this._transaction.requestWrite({key:t.blockId,value:t.serialize()}),[2,!0]):[2,!1]}}))}))},e.prototype.clearAllBlocks=function(){return r(this,void 0,void 0,(function(){var e,t,n;return s(this,(function(r){switch(r.label){case 0:return e=Ye(this.dbname,this.collectionName),[4,this._store.getAllKeys()];case 1:return t=r.sent(),n=t.filter((function(t){return t.startsWith(e)})),[4,this._store.removeMany(n)];case 2:return r.sent(),[4,this._transaction.clear()];case 3:return r.sent(),et.get(this.dbname).clearByCondition((function(t){return t.key.startsWith(e)})),[2]}}))}))},e}(),it={},st=function(){function e(e){var t=e.dbname,n=e.collectionName,r=e.keyName,i=e.fields,s=e.transaction,a=e.store,o=this;this._origin=[],this._table=[];var c=function(e,t,n){return"".concat(ze(e,t),"/index.").concat(n)}(t,n,i.join(">"));return it[c]||(this.dbname=t,this.collectionName=n,this.keyName=r,this.fields=i,this.indexerKey=c,this._transaction=s,this._store=a,this._transaction.on(Ue.COMMIT,this.indexerKey,(function(){return o.commit()})),this._transaction.on(Ue.ERROR,this.indexerKey,(function(){return o.abort()}))),it[c]}return e.createKey=function(e){return e.join(">")},e.parseKey=function(e){return e.split(">")},e.clearIndexerMap=function(){for(var e in it)delete it[e]},e.prototype._addItem=function(e){var t=e[this.keyName],n=this.getColumnValues(e),r=I(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=I(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,s,a=[];try{for(var o=i(this.fields),c=o.next();!c.done;c=o.next()){var u=c.value;if("-"===u[0]&&(u=u.slice(1)),r=e[u],s=void 0,s=typeof r,null!==r&&"undefined"!==s&&"boolean"!==s&&"number"!==s&&"string"!==s)throw Ce.indexTypesNotMatch;a.push(e[u])}}catch(e){t={error:e}}finally{try{c&&!c.done&&(n=o.return)&&n.call(o)}finally{if(t)throw t.error}}return a},e.prototype.diff=function(e,t){for(var n in this.fields){var r="-"===this.fields[n][0]?-1:1,i=ke(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 r(this,void 0,void 0,(function(){var e,t,n,r,a,o,c,u,l,h,d,f,_,p,m,v,y;return s(this,(function(s){switch(s.label){case 0:return[4,(e=et.get(this.dbname)).find(this._store,this.indexerKey,Ke.PERSISTENT)];case 1:return(t=s.sent())?[3,11]:(n=Ye(this.dbname,this.collectionName),[4,this._store.getAllKeys()]);case 2:r=s.sent(),s.label=3;case 3:s.trys.push([3,8,9,10]),a=i(r),o=a.next(),s.label=4;case 4:return o.done?[3,7]:(c=o.value).startsWith(n)?[4,e.find(this._store,c,Ke.NO_CACHE)]:[3,6];case 5:if(u=s.sent(),l=nt.createFromCacheItem(u))try{for(v=void 0,h=i(l.items),d=h.next();!d.done;d=h.next())f=d.value,this._addItem(f)}catch(e){v={error:e}}finally{try{d&&!d.done&&(y=h.return)&&y.call(h)}finally{if(v)throw v.error}}s.label=6;case 6:return o=a.next(),[3,4];case 7:return[3,10];case 8:return _=s.sent(),p={error:_},[3,10];case 9:try{o&&!o.done&&(m=a.return)&&m.call(a)}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=Le(this._origin),s.label=12;case 12:return it[this.indexerKey]=this,[2]}}))}))},e.prototype.drop=function(){return r(this,void 0,void 0,(function(){return s(this,(function(e){switch(e.label){case 0:return et.get(this.dbname).remove(this.indexerKey),[4,this._store.remove(this.indexerKey)];case 1:return e.sent(),delete it[this.indexerKey],[2]}}))}))},e.prototype.addItem=function(e){return r(this,void 0,void 0,(function(){return s(this,(function(t){return this._addItem(e)&&this._transaction.requestWrite({key:this.indexerKey,value:this._table},{persistent:!0}),[2]}))}))},e.prototype.removeItem=function(e){return r(this,void 0,void 0,(function(){return s(this,(function(t){return this._removeItem(e)&&this._transaction.requestWrite({key:this.indexerKey,value:this._table},{persistent:!0}),[2]}))}))},e.prototype.clear=function(){return r(this,void 0,void 0,(function(){return s(this,(function(e){return this._table=[],this._transaction.requestWrite({key:this.indexerKey,value:this._table},{persistent:!0}),[2]}))}))},e.prototype.commit=function(){this._origin=this._table,this._table=Le(this._origin)},e.prototype.abort=function(){this._table=Le(this._origin)},e}(),at=function(){function e(e){var t=e.dbname,n=e.collectionName,r=e.keyName,i=e.keyHash,s=e.indexes,a=e.store,o=this;this._state=Oe.INIT,this._indexers=[],this.dbname=t,this.name=n,this.keyName=r,this.indexes=N([[r]],I(s.filter((function(e){return st.createKey(e)!==o.keyName}))),!1),this._keyHash=i,this._store=a,this._mutex=new ne(function(e,t){return"".concat(ze(e,t),".lock")}(t,n)),this._blobContainer=new Je({dbname:t,collectionName:n,store:a}),this._transaction=new tt({dbname:t,collectionName:n,store:a})}return e.metadataOf=function(e,t,n){return r(this,void 0,void 0,(function(){var r;return s(this,(function(i){switch(i.label){case 0:return r=We(e,t),[4,n.get(r)];case 1:return[2,i.sent()]}}))}))},Object.defineProperty(e.prototype,"state",{get:function(){return this._state},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"isReady",{get:function(){return this._state===Oe.READY},enumerable:!1,configurable:!0}),e.prototype.init=function(){return r(this,void 0,void 0,(function(){var t,n,r,a,o,c,u,l,h,d,f,_,p,m,v=this;return s(this,(function(s){switch(s.label){case 0:return[4,this._mutex.lock()];case 1:s.sent(),s.label=2;case 2:return s.trys.push([2,9,,10]),t=Ae.get(this.dbname),[4,e.metadataOf(this.dbname,this.name,this._store)];case 3:return n=s.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:s.sent(),this._blockManager=new rt({dbname:this.dbname,collectionName:this.name,hashFunction:this._keyHash,metadata:this._metadata,transaction:this._transaction,store:this._store}),r=N([],I(this.indexes),!1),a=[],o=r.map((function(e){return st.createKey(e)})),c=n?n.indexes.map((function(e){return st.createKey(e)})):[];try{for(u=i(c),l=u.next();!l.done;l=u.next())h=l.value,o.includes(h)||a.push(st.parseKey(h))}catch(e){p={error:e}}finally{try{l&&!l.done&&(m=u.return)&&m.call(u)}finally{if(p)throw p.error}}return(d=[]).push.apply(d,N([],I(r.map((function(e){var t=new st({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)),d.push.apply(d,N([],I(a.map((function(e){return new st({dbname:v.dbname,collectionName:v.name,keyName:v.keyName,fields:e,transaction:v._transaction,store:v._store}).drop()}))),!1)),[4,Promise.all(d)];case 5:return s.sent(),[4,this._transaction.commit()];case 6:return s.sent(),o.sort().join(",")===c.sort().join(",")?[3,8]:(f=We(this.dbname,this.name),this._metadata.indexes=r,[4,this._store.set({key:f,value:this._metadata})]);case 7:s.sent(),s.label=8;case 8:return this._state=Oe.READY,this._mutex.unlock(),[3,10];case 9:throw _=s.sent(),this._mutex.unlock(),_;case 10:return[2]}}))}))},e.prototype.close=function(){this._state=Oe.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=st.createKey(e);try{for(var s=i(this._indexers),a=s.next();!a.done;a=s.next()){var o=a.value;if(r===st.createKey(o.fields))return o}}catch(e){t={error:e}}finally{try{a&&!a.done&&(n=s.return)&&n.call(s)}finally{if(t)throw t.error}}throw Ce.indexTableIsRequired},e.prototype._upgradeBlockLevel=function(){return r(this,void 0,void 0,(function(){var e;return s(this,(function(t){switch(t.label){case 0:return e=We(this.dbname,this.name),this._metadata.blockLevel++,[4,this._store.set({key:e,value:this._metadata})];case 1:return t.sent(),[2]}}))}))},e.prototype._requestInsert=function(e){return r(this,void 0,void 0,(function(){var t,n,r,a,o,c;return s(this,(function(s){switch(s.label){case 0:return t=e[this.keyName],[4,this._blockManager.getFromBlock(t)];case 1:return s.sent()?[3,13]:[4,this._blockManager.putToBlock(t,e)];case 2:return s.sent()?[3,5]:[4,this._upgradeBlockLevel()];case 3:return s.sent(),[4,this._blockManager.putToBlock(t,e)];case 4:s.sent(),s.label=5;case 5:s.trys.push([5,10,11,12]),n=i(this._indexers),r=n.next(),s.label=6;case 6:return r.done?[3,9]:[4,r.value.addItem(e)];case 7:s.sent(),s.label=8;case 8:return r=n.next(),[3,6];case 9:return[3,12];case 10:return a=s.sent(),o={error:a},[3,12];case 11:try{r&&!r.done&&(c=n.return)&&c.call(n)}finally{if(o)throw o.error}return[7];case 12:return[3,14];case 13:throw Ce.collectionInsertDuplicate;case 14:return[2]}}))}))},e.prototype._requestUpsert=function(e){return r(this,void 0,void 0,(function(){var t,n,r,a,o,c,u,l,h,d,f,_,p;return s(this,(function(s){switch(s.label){case 0:return t=e[this.keyName],[4,this._blockManager.getFromBlock(t)];case 1:return(n=s.sent())?[3,13]:[4,this._blockManager.putToBlock(t,e)];case 2:return s.sent()?[3,5]:[4,this._upgradeBlockLevel()];case 3:return s.sent(),[4,this._blockManager.putToBlock(t,e)];case 4:s.sent(),s.label=5;case 5:s.trys.push([5,10,11,12]),r=i(this._indexers),a=r.next(),s.label=6;case 6:return a.done?[3,9]:[4,(l=a.value).addItem(e)];case 7:s.sent(),s.label=8;case 8:return a=r.next(),[3,6];case 9:return[3,12];case 10:return o=s.sent(),d={error:o},[3,12];case 11:try{a&&!a.done&&(f=r.return)&&f.call(r)}finally{if(d)throw d.error}return[7];case 12:return[3,23];case 13:return[4,this._blockManager.putToBlock(t,e)];case 14:s.sent(),s.label=15;case 15:s.trys.push([15,21,22,23]),c=i(this._indexers),u=c.next(),s.label=16;case 16:return u.done?[3,20]:0===(l=u.value).diff(l.getColumnValues(n),l.getColumnValues(e))?[3,19]:[4,l.removeItem(n)];case 17:return s.sent(),[4,l.addItem(e)];case 18:s.sent(),s.label=19;case 19:return u=c.next(),[3,16];case 20:return[3,23];case 21:return h=s.sent(),_={error:h},[3,23];case 22:try{u&&!u.done&&(p=c.return)&&p.call(c)}finally{if(_)throw _.error}return[7];case 23:return[2]}}))}))},e.prototype._requestUpdate=function(e){return r(this,void 0,void 0,(function(){var t,n,r,a,o,c,u,l;return s(this,(function(s){switch(s.label){case 0:return t=e[this.keyName],[4,this._blockManager.getFromBlock(t)];case 1:return(n=s.sent())?[4,this._blockManager.putToBlock(t,e)]:[3,11];case 2:s.sent(),s.label=3;case 3:s.trys.push([3,9,10,11]),r=i(this._indexers),a=r.next(),s.label=4;case 4:return a.done?[3,8]:0===(o=a.value).diff(o.getColumnValues(n),o.getColumnValues(e))?[3,7]:[4,o.removeItem(n)];case 5:return s.sent(),[4,o.addItem(e)];case 6:s.sent(),s.label=7;case 7:return a=r.next(),[3,4];case 8:return[3,11];case 9:return c=s.sent(),u={error:c},[3,11];case 10:try{a&&!a.done&&(l=r.return)&&l.call(r)}finally{if(u)throw u.error}return[7];case 11:return[2]}}))}))},e.prototype._requestRemove=function(e){return r(this,void 0,void 0,(function(){var t,n,r,a,o,c;return s(this,(function(s){switch(s.label){case 0:return[4,this._blockManager.getFromBlock(e)];case 1:return(t=s.sent())?[4,this._blockManager.removeFromBlock(e)]:[3,10];case 2:s.sent(),s.label=3;case 3:s.trys.push([3,8,9,10]),n=i(this._indexers),r=n.next(),s.label=4;case 4:return r.done?[3,7]:[4,r.value.removeItem(t)];case 5:s.sent(),s.label=6;case 6:return r=n.next(),[3,4];case 7:return[3,10];case 8:return a=s.sent(),o={error:a},[3,10];case 9:try{r&&!r.done&&(c=n.return)&&c.call(n)}finally{if(o)throw o.error}return[7];case 10:return[2]}}))}))},e.prototype._requestClear=function(){return r(this,void 0,void 0,(function(){var e,t,n,r,a;return s(this,(function(s){switch(s.label){case 0:return[4,this._blockManager.clearAllBlocks()];case 1:s.sent(),s.label=2;case 2:s.trys.push([2,7,8,9]),e=i(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&&(a=e.return)&&a.call(e)}finally{if(r)throw r.error}return[7];case 9:return[2]}}))}))},e.prototype.getByKey=function(e){return r(this,void 0,void 0,(function(){var t,n;return s(this,(function(r){switch(r.label){case 0:return this.isReady?[4,this._mutex.lock()]:[3,6];case 1:r.sent(),r.label=2;case 2:return r.trys.push([2,4,,5]),[4,this._blockManager.getFromBlock(e)];case 3:return t=r.sent(),this._mutex.unlock(),[2,Le(t)];case 4:throw n=r.sent(),this._mutex.unlock(),n;case 5:return[3,7];case 6:throw Ce.collectionNotReady;case 7:return[2]}}))}))},e.prototype.query=function(e){if(void 0===e&&(e={}),this.isReady)return new je({condition:e.where,mutex:this._mutex,blockManager:this._blockManager,indexer:this._getIndexerBy(e.index),backward:!!e.backward});throw Ce.collectionNotReady},e.prototype.insertOne=function(e){return r(this,void 0,void 0,(function(){var t;return s(this,(function(n){switch(n.label){case 0:return this.isReady?[4,this._mutex.lock()]:[3,8];case 1:n.sent(),n.label=2;case 2:if(n.trys.push([2,5,,7]),!this._hasPropertyOfKeyName(e))throw Ce.collectionKeyNotGiven;return[4,this._requestInsert(Le(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 Ce.collectionNotReady;case 9:return[2]}}))}))},e.prototype.insertMany=function(e){return r(this,void 0,void 0,(function(){var t,n,r,a,o,c,u,l=this;return s(this,(function(s){switch(s.label){case 0:return this.isReady?[4,this._mutex.lock()]:[3,15];case 1:s.sent(),s.label=2;case 2:if(s.trys.push([2,12,,14]),e.some((function(e){return!l._hasPropertyOfKeyName(e)})))throw Ce.collectionKeyNotGiven;s.label=3;case 3:s.trys.push([3,8,9,10]),t=i(e),n=t.next(),s.label=4;case 4:return n.done?[3,7]:(r=n.value,[4,this._requestInsert(Le(r))]);case 5:s.sent(),s.label=6;case 6:return n=t.next(),[3,4];case 7:return[3,10];case 8:return a=s.sent(),c={error:a},[3,10];case 9:try{n&&!n.done&&(u=t.return)&&u.call(t)}finally{if(c)throw c.error}return[7];case 10:return[4,this._transaction.commit()];case 11:return s.sent(),this._mutex.unlock(),[2,e];case 12:return o=s.sent(),[4,this._transaction.clear()];case 13:throw s.sent(),this._mutex.unlock(),o;case 14:return[3,16];case 15:throw Ce.collectionNotReady;case 16:return[2]}}))}))},e.prototype.upsertOne=function(e){return r(this,void 0,void 0,(function(){var t;return s(this,(function(n){switch(n.label){case 0:return this.isReady?[4,this._mutex.lock()]:[3,8];case 1:n.sent(),n.label=2;case 2:if(n.trys.push([2,5,,7]),!this._hasPropertyOfKeyName(e))throw Ce.collectionKeyNotGiven;return[4,this._requestUpsert(Le(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 Ce.collectionNotReady;case 9:return[2]}}))}))},e.prototype.upsertMany=function(e){return r(this,void 0,void 0,(function(){var t,n,r,a,o,c,u,l=this;return s(this,(function(s){switch(s.label){case 0:return this.isReady?[4,this._mutex.lock()]:[3,15];case 1:s.sent(),s.label=2;case 2:if(s.trys.push([2,12,,14]),e.some((function(e){return!l._hasPropertyOfKeyName(e)})))throw Ce.collectionKeyNotGiven;s.label=3;case 3:s.trys.push([3,8,9,10]),t=i(e),n=t.next(),s.label=4;case 4:return n.done?[3,7]:(r=n.value,[4,this._requestUpsert(Le(r))]);case 5:s.sent(),s.label=6;case 6:return n=t.next(),[3,4];case 7:return[3,10];case 8:return a=s.sent(),c={error:a},[3,10];case 9:try{n&&!n.done&&(u=t.return)&&u.call(t)}finally{if(c)throw c.error}return[7];case 10:return[4,this._transaction.commit()];case 11:return s.sent(),this._mutex.unlock(),[2,e];case 12:return o=s.sent(),[4,this._transaction.clear()];case 13:throw s.sent(),this._mutex.unlock(),o;case 14:return[3,16];case 15:throw Ce.collectionNotReady;case 16:return[2]}}))}))},e.prototype.update=function(e){return r(this,void 0,void 0,(function(){var t;return s(this,(function(n){switch(n.label){case 0:return this.isReady?[4,this._mutex.lock()]:[3,8];case 1:n.sent(),n.label=2;case 2:if(n.trys.push([2,5,,7]),!this._hasPropertyOfKeyName(e))throw Ce.collectionKeyNotGiven;return[4,this._requestUpdate(Le(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 Ce.collectionNotReady;case 9:return[2]}}))}))},e.prototype.updateIf=function(e,t){return r(this,void 0,void 0,(function(){var n,a,o,c,u,l,h,d,f,_,p,m,v,y,b=this;return s(this,(function(E){switch(E.label){case 0:return this.isReady?[4,this._mutex.lock()]:[3,16];case 1:E.sent(),E.label=2;case 2:return E.trys.push([2,13,,15]),n=e.where,a=void 0===n?{}:n,o=e.index,c=void 0===o?null:o,u=e.backward,l=void 0!==u&&u,h=[],[4,new Fe({condition:a,blockManager:this._blockManager,backward:l,indexer:this._getIndexerBy(c)}).each((function(e){return r(b,void 0,void 0,(function(){var n,r;return s(this,(function(i){if(e.error)throw e.stop(),e.error;if(e.hasNext){if(n=e.nextValue,De(a,n)&&t.set){if("function"!=typeof t.set)for(r in t.set)n[r]=t.set[r];else t.set(n);h.push(n)}e.next()}else e.stop();return[2]}))}))}))];case 3:E.sent(),E.label=4;case 4:E.trys.push([4,9,10,11]),d=i(h),f=d.next(),E.label=5;case 5:return f.done?[3,8]:(_=f.value,[4,this._requestUpdate(Le(_))]);case 6:E.sent(),E.label=7;case 7:return f=d.next(),[3,5];case 8:return[3,11];case 9:return p=E.sent(),v={error:p},[3,11];case 10:try{f&&!f.done&&(y=d.return)&&y.call(d)}finally{if(v)throw v.error}return[7];case 11:return[4,this._transaction.commit()];case 12:return E.sent(),this._mutex.unlock(),[2,h];case 13:return m=E.sent(),[4,this._transaction.clear()];case 14:throw E.sent(),this._mutex.unlock(),m;case 15:return[3,17];case 16:throw this._transaction.clear(),Ce.collectionNotReady;case 17:return[2]}}))}))},e.prototype.remove=function(e){return r(this,void 0,void 0,(function(){var t;return s(this,(function(n){switch(n.label){case 0:return this.isReady?[4,this._mutex.lock()]:[3,8];case 1:n.sent(),n.label=2;case 2:return n.trys.push([2,5,,7]),[4,this._requestRemove(e)];case 3:return n.sent(),[4,this._transaction.commit()];case 4:return n.sent(),this._mutex.unlock(),[3,7];case 5:return t=n.sent(),[4,this._transaction.clear()];case 6:throw n.sent(),this._mutex.unlock(),t;case 7:return[3,9];case 8:throw Ce.collectionNotReady;case 9:return[2]}}))}))},e.prototype.removeIf=function(e){return r(this,void 0,void 0,(function(){var t,n,a,o,c,u,l,h,d,f,_,p,m,v,y=this;return s(this,(function(b){switch(b.label){case 0:return this.isReady?[4,this._mutex.lock()]:[3,15];case 1:b.sent(),b.label=2;case 2:return b.trys.push([2,13,,14]),t=e.where,n=void 0===t?{}:t,a=e.index,o=void 0===a?null:a,c=e.backward,u=void 0!==c&&c,l=[],[4,new Fe({condition:n,blockManager:this._blockManager,backward:u,indexer:this._getIndexerBy(o)}).each((function(e){return r(y,void 0,void 0,(function(){var t,r;return s(this,(function(i){if(e.error)throw e.stop(),e.error;return e.hasNext?(t=e.nextValue,De(n,t)&&(r=t[this.keyName],l.push(r)),e.next()):e.stop(),[2]}))}))}))];case 3:b.sent(),b.label=4;case 4:b.trys.push([4,9,10,11]),h=i(l),d=h.next(),b.label=5;case 5:return d.done?[3,8]:(f=d.value,[4,this._requestRemove(f)]);case 6:b.sent(),b.label=7;case 7:return d=h.next(),[3,5];case 8:return[3,11];case 9:return _=b.sent(),m={error:_},[3,11];case 10:try{d&&!d.done&&(v=h.return)&&v.call(h)}finally{if(m)throw m.error}return[7];case 11:return[4,this._transaction.commit()];case 12:return b.sent(),this._mutex.unlock(),[2,l];case 13:throw p=b.sent(),this._mutex.unlock(),p;case 14:return[3,16];case 15:throw this._transaction.clear(),Ce.collectionNotReady;case 16:return[2]}}))}))},e.prototype.clear=function(){return r(this,void 0,void 0,(function(){var e;return s(this,(function(t){switch(t.label){case 0:return this.isReady?[4,this._mutex.lock()]:[3,8];case 1:t.sent(),t.label=2;case 2:return t.trys.push([2,5,,7]),[4,this._requestClear()];case 3:return t.sent(),[4,this._transaction.commit()];case 4:return t.sent(),this._mutex.unlock(),[3,7];case 5:return e=t.sent(),[4,this._transaction.clear()];case 6:throw t.sent(),this._mutex.unlock(),e;case 7:return[3,9];case 8:throw Ce.collectionNotReady;case 9:return[2]}}))}))},e.prototype.getBlob=function(e){return r(this,void 0,void 0,(function(){return s(this,(function(t){switch(t.label){case 0:return[4,this._blobContainer.get(e)];case 1:return[2,t.sent()]}}))}))},e.prototype.saveBlob=function(e,t){return r(this,void 0,void 0,(function(){return s(this,(function(n){switch(n.label){case 0:return[4,this._blobContainer.save(e,t)];case 1:return[2,n.sent()]}}))}))},e.prototype.removeBlob=function(e){return r(this,void 0,void 0,(function(){return s(this,(function(t){switch(t.label){case 0:return[4,this._blobContainer.remove(e)];case 1:return t.sent(),[2]}}))}))},e.prototype.removeAllBlobs=function(){return r(this,void 0,void 0,(function(){return s(this,(function(e){switch(e.label){case 0:return[4,this._blobContainer.clear()];case 1:return e.sent(),[2]}}))}))},e}(),ot=function(){function e(e){var t,n,r;this.encryption=null!==(t=e.encryption)&&void 0!==t?t:w,this.itemSizeLimit=null!==(n=e.itemSizeLimit)&&void 0!==n?n:4194304,this.metadataBuffer=null!==(r=e.metadataBuffer)&&void 0!==r?r:256}return e.prototype._getRawKey=function(e,t){return void 0===t&&(t=""),"".concat(e).concat(t)},e.prototype._generateShardPostfixArray=function(e){return void 0===e&&(e=1),N([],I(Array(e).keys()),!1)},e.prototype._shardify=function(e){var t=this,n=e.key,r=e.value,i=JSON.stringify(this.encryption.encrypt(r)),s=Math.ceil(i.length/this.adjustedItemSizeLimit);return this._generateShardPostfixArray(s).map((function(e){var r={key:t._getRawKey(n,".".concat(e)),data:i.substring(e*t.adjustedItemSizeLimit,(e+1)*t.adjustedItemSizeLimit)};return 0===e&&(r.metadata={shards:s}),r}))},Object.defineProperty(e.prototype,"adjustedItemSizeLimit",{get:function(){return Math.max(this.itemSizeLimit-this.metadataBuffer,4)},enumerable:!1,configurable:!0}),e.prototype.usage=function(){return r(this,void 0,void 0,(function(){var e,t,n,r,a,o,c,u,l;return s(this,(function(s){switch(s.label){case 0:return e=0,[4,this._getAllRawKeys()];case 1:t=s.sent(),s.label=2;case 2:s.trys.push([2,7,8,9]),n=i(t),r=n.next(),s.label=3;case 3:return r.done?[3,6]:(a=r.value,[4,this._getRaw(a)]);case 4:(o=s.sent())&&(e+=JSON.stringify(o).length),s.label=5;case 5:return r=n.next(),[3,3];case 6:return[3,9];case 7:return c=s.sent(),u={error:c},[3,9];case 8:try{r&&!r.done&&(l=n.return)&&l.call(n)}finally{if(u)throw u.error}return[7];case 9:return[2,e]}}))}))},e.prototype.getAllKeys=function(){return r(this,void 0,void 0,(function(){return s(this,(function(e){switch(e.label){case 0:return[4,this._getAllRawKeys()];case 1:return[2,e.sent().filter((function(e){return e.endsWith(".0")})).map((function(e){return e.replace(/\.0$/,"")}))]}}))}))},e.prototype.get=function(e){return r(this,void 0,void 0,(function(){var t,n,i,a,o,c,u=this;return s(this,(function(l){switch(l.label){case 0:return t=this._getRawKey(e,".0"),[4,this._getRaw(t)];case 1:if(!(n=l.sent()))return[3,7];l.label=2;case 2:return l.trys.push([2,6,,7]),i=n.data,(null==(a=n.metadata)?void 0:a.shards)&&a.shards>1?[4,Promise.all(this._generateShardPostfixArray(null==a?void 0:a.shards).map((function(t){return r(u,void 0,void 0,(function(){var n,r;return s(this,(function(s){switch(s.label){case 0:return t>0?(n=this._getRawKey(e,".".concat(t)),[4,this._getRaw(n)]):[3,2];case 1:if(!(r=s.sent()))throw Ce.storeBrokenIntegrity;return[2,r.data];case 2:return[2,i]}}))}))})))]:[3,4];case 3:return c=l.sent(),[3,5];case 4:c=[i],l.label=5;case 5:return o=c,[2,this.encryption.decrypt(JSON.parse(o.join("")))];case 6:return l.sent(),[2,null];case 7:return[2,null]}}))}))},e.prototype.set=function(e){return r(this,void 0,void 0,(function(){var t;return s(this,(function(n){switch(n.label){case 0:return t=this._shardify(e),[4,this._setRaw(t)];case 1:return n.sent(),[2,a({},e.value)]}}))}))},e.prototype.setMany=function(e){return r(this,void 0,void 0,(function(){var t,n=this;return s(this,(function(r){switch(r.label){case 0:return t=[],[4,this._setRaw(t.concat.apply(t,N([],I(e.map((function(e){return n._shardify(e)}))),!1)))];case 1:return r.sent(),[2,e.map((function(e){return e.value}))]}}))}))},e.prototype.remove=function(e){return r(this,void 0,void 0,(function(){var t,n,r,i=this;return s(this,(function(s){switch(s.label){case 0:return t=this._getRawKey(e,".0"),[4,this._getRaw(t)];case 1:return(n=s.sent())?(r=n.metadata,[4,this._removeRaw(this._generateShardPostfixArray(null==r?void 0:r.shards).map((function(t){return i._getRawKey(e,".".concat(t))})))]):[3,3];case 2:return s.sent(),[2,!0];case 3:return[2,!1]}}))}))},e.prototype.removeMany=function(e){return r(this,void 0,void 0,(function(){var t,n,r,a,o,c,u,l,h,d=this;return s(this,(function(f){switch(f.label){case 0:t=[],n=function(e){var n,i,a;return s(this,(function(s){switch(s.label){case 0:return n=r._getRawKey(e,".0"),[4,r._getRaw(n)];case 1:return(i=s.sent())&&(a=i.metadata,t.push.apply(t,N([],I(r._generateShardPostfixArray(null==a?void 0:a.shards).map((function(t){return d._getRawKey(e,".".concat(t))}))),!1))),[2]}}))},r=this,f.label=1;case 1:f.trys.push([1,6,7,8]),a=i(e),o=a.next(),f.label=2;case 2:return o.done?[3,5]:(c=o.value,[5,n(c)]);case 3:f.sent(),f.label=4;case 4:return o=a.next(),[3,2];case 5:return[3,8];case 6:return u=f.sent(),l={error:u},[3,8];case 7:try{o&&!o.done&&(h=a.return)&&h.call(a)}finally{if(l)throw l.error}return[7];case 8:return t.length>0?[4,this._removeRaw(t)]:[3,10];case 9:f.sent(),f.label=10;case 10:return[2,e]}}))}))},e}(),ct={},ut=function(e){function t(t){void 0===t&&(t={});var n,r=this;r=e.call(this,a(a({},t),{itemSizeLimit:null!==(n=t.itemSizeLimit)&&void 0!==n?n:4194304}))||this;var i=t.delay,s=void 0===i?1:i;return r.delay=s,r.observer={},r}return u(t,e),Object.defineProperty(t.prototype,"rawData",{get:function(){return ct[this.dbname]},set:function(e){ct[this.dbname]=e},enumerable:!1,configurable:!0}),t.prototype._getAllRawKeys=function(){return r(this,void 0,void 0,(function(){return s(this,(function(e){if(ct[this.dbname])return[2,Object.keys(ct[this.dbname])];throw Ce.storeNotAvailable}))}))},t.prototype._getRaw=function(e){return r(this,void 0,void 0,(function(){return s(this,(function(t){switch(t.label){case 0:return ct[this.dbname]?[4,xe(this.delay)]:[3,2];case 1:return t.sent(),[2,ct[this.dbname][e]?a({key:e},ct[this.dbname][e]):null];case 2:throw Ce.storeNotAvailable}}))}))},t.prototype._setRaw=function(e){return r(this,void 0,void 0,(function(){var t,n,r,a,o,c,u,l;return s(this,(function(s){switch(s.label){case 0:return ct[this.dbname]?[4,xe(this.delay)]:[3,2];case 1:s.sent();try{for(t=i(e),n=t.next();!n.done;n=t.next())r=n.value,a=r.key,o=r.data,c=r.metadata,ct[this.dbname][a]=Object.freeze({data:o,metadata:c})}catch(e){u={error:e}}finally{try{n&&!n.done&&(l=t.return)&&l.call(t)}finally{if(u)throw u.error}}return[3,3];case 2:throw Ce.storeNotAvailable;case 3:return[2]}}))}))},t.prototype._removeRaw=function(e){return r(this,void 0,void 0,(function(){var t,n,r,a,o;return s(this,(function(s){switch(s.label){case 0:return ct[this.dbname]?[4,xe(this.delay)]:[3,2];case 1:s.sent();try{for(t=i(e),n=t.next();!n.done;n=t.next())r=n.value,ct[this.dbname][r]&&delete ct[this.dbname][r]}catch(e){a={error:e}}finally{try{n&&!n.done&&(o=t.return)&&o.call(t)}finally{if(a)throw a.error}}return[3,3];case 2:throw Ce.storeNotAvailable;case 3:return[2]}}))}))},t.prototype.observe=function(e,t,n){var r=this;this.observer[e]||(this.observer[e]={}),t.forEach((function(t){return r.observer[e][t]=n}))},t.prototype.checkAvailability=function(){return r(this,void 0,void 0,(function(){return s(this,(function(e){return[2]}))}))},t.prototype.init=function(e){return r(this,void 0,void 0,(function(){return s(this,(function(t){return this.dbname=e,ct[this.dbname]={},[2]}))}))},t.prototype.set=function(t){return r(this,void 0,void 0,(function(){var n,r;return s(this,(function(i){if((n=this.observer[t.key])&&"function"==typeof n.set&&(r=n.set()))throw r;return[2,e.prototype.set.call(this,t)]}))}))},t.prototype.setMany=function(t){return r(this,void 0,void 0,(function(){var n,r,a,o,c,u,l;return s(this,(function(s){try{for(n=i(t),r=n.next();!r.done;r=n.next())if(a=r.value,(o=this.observer[a.key])&&"function"==typeof o.set&&(c=o.set()))throw c}catch(e){u={error:e}}finally{try{r&&!r.done&&(l=n.return)&&l.call(n)}finally{if(u)throw u.error}}return[2,e.prototype.setMany.call(this,t)]}))}))},t.prototype.clear=function(){return r(this,void 0,void 0,(function(){return s(this,(function(e){switch(e.label){case 0:return[4,xe(this.delay)];case 1:return e.sent(),ct[this.dbname]={},[2]}}))}))},t}(ot),lt="NestDBStore";!function(e){e[e.UNINITIALIZED=0]="UNINITIALIZED",e[e.OPENING=1]="OPENING",e[e.OPEN=2]="OPEN",e[e.CLOSED=3]="CLOSED"}(Ze||(Ze={}));var ht=function(e){function t(t){void 0===t&&(t={});var n,r=this;return(r=e.call(this,a(a({},t),{itemSizeLimit:null!==(n=t.itemSizeLimit)&&void 0!==n?n:104857600}))||this)._storeName=lt,r._state=Ze.UNINITIALIZED,r._openJobQueue=[],r._window="undefined"!=typeof window?window:void 0,r._indexedDb=r._window?r._window.indexedDB||r._window.mozIndexedDB||r._window.webkitIndexedDB||r._window.msIndexedDB:void 0,r}return u(t,e),Object.defineProperty(t.prototype,"state",{get:function(){return this._state},enumerable:!1,configurable:!0}),t.prototype._openDatabase=function(e){var t=this;return new Promise((function(n,r){if(t._indexedDb){t._state=Ze.OPENING;var i=t._indexedDb.open(e);i.addEventListener("upgradeneeded",(function(e){e.target.result.createObjectStore(lt,{keyPath:"key"})})),i.addEventListener("success",(function(r){t._state=Ze.OPEN,t._database=r.target.result,t._openJobQueue.forEach((function(e){return e()})),t._openJobQueue=[],t._database.onclose=function(){t._database=void 0,t._state=Ze.OPENING,setTimeout((function(){t._openDatabase(e)}),5)},n(t._database)})),i.addEventListener("error",(function(e){t._state=Ze.UNINITIALIZED,r(e.target.error)}))}else r(Ce.storeNotAvailable)}))},t.prototype._getObjectStore=function(e){return r(this,void 0,void 0,(function(){var t=this;return s(this,(function(n){switch(n.label){case 0:return this._database?[2,this._database.transaction(this._storeName,e).objectStore(this._storeName)]:[3,1];case 1:switch(this._state){case Ze.UNINITIALIZED:case Ze.OPEN:return[3,2];case Ze.OPENING:case Ze.CLOSED:return[3,3]}return[3,4];case 2:throw Ce.storeNotInitialized;case 3:return[2,new Promise((function(n){t._openJobQueue.push((function(){return n(t._getObjectStore(e))}))}))];case 4:return[4,this._getObjectStore(e)];case 5:return[2,n.sent()]}}))}))},t.prototype._getAllRawKeys=function(){return r(this,void 0,void 0,(function(){var e;return s(this,(function(t){switch(t.label){case 0:return[4,this._getObjectStore("readonly")];case 1:return e=t.sent(),[4,new Promise((function(t,n){var r=e.getAllKeys();r.addEventListener("success",(function(e){t(e.target.result)})),r.addEventListener("error",(function(e){return n(e.target.error)}))}))];case 2:return[2,t.sent()]}}))}))},t.prototype._getRaw=function(e){return r(this,void 0,void 0,(function(){var t;return s(this,(function(n){switch(n.label){case 0:return[4,this._getObjectStore("readonly")];case 1:return t=n.sent(),[4,new Promise((function(n,r){var i=t.get(e);i.addEventListener("success",(function(e){var t;n(null===(t=null==e?void 0:e.target)||void 0===t?void 0:t.result)})),i.addEventListener("error",(function(e){return r(e.target.error)}))}))];case 2:return[2,n.sent()]}}))}))},t.prototype._setRaw=function(e){return r(this,void 0,void 0,(function(){var t;return s(this,(function(n){switch(n.label){case 0:return[4,this._getObjectStore("readwrite")];case 1:return t=n.sent(),[4,Promise.all(e.map((function(e){return new Promise((function(n,r){var i=t.put(e);i.addEventListener("success",(function(e){n(e.target.result)})),i.addEventListener("error",(function(){r("Failed to write.")}))}))})))];case 2:return n.sent(),[2]}}))}))},t.prototype._removeRaw=function(e){return r(this,void 0,void 0,(function(){var t;return s(this,(function(n){switch(n.label){case 0:return[4,this._getObjectStore("readwrite")];case 1:return t=n.sent(),[4,Promise.all(e.map((function(e){return new Promise((function(n,r){var i=t.delete(e);i.addEventListener("success",(function(){return n(e)})),i.addEventListener("error",(function(e){return r(e.target.error)}))}))})))];case 2:return n.sent(),[2]}}))}))},t.prototype._triggerDatabaseClose=function(){this._database&&this._database.onclose&&this._database.onclose(new Event("dummy"))},t.prototype.checkAvailability=function(){return r(this,void 0,void 0,(function(){var e,t=this;return s(this,(function(n){switch(n.label){case 0:if(!((null==(e="undefined"!=typeof window?window:null)?void 0:e.indexedDB)||(null==e?void 0:e.mozIndexedDB)||(null==e?void 0:e.webkitIndexedDB)||(null==e?void 0:e.msIndexedDB)))return[3,6];if(this._indexedDb=e.indexedDB||e.mozIndexedDB||e.webkitIndexedDB||e.msIndexedDB,!this._window||!X())return[3,4];if(!(X()&&navigator.userAgent&&navigator.userAgent.includes("Edge/")))return[3,1];if(!this._window.indexedDB&&(e.PointerEvent||e.MSPointerEvent))throw Ce.storeNotAvailableInPrivateBrowsing;return[3,3];case 1:return[4,new Promise((function(e,n){if(t._indexedDb)try{var r=t._indexedDb.open("_testMozilla");r.onerror=function(){return n(Ce.storeNotAvailableInPrivateBrowsing)},r.onsuccess=function(){return e()}}catch(e){n(Ce.storeNotAvailableInPrivateBrowsing)}else n(Ce.storeNotAvailable)}))];case 2:n.sent(),n.label=3;case 3:return[3,5];case 4:throw Ce.storeNotAvailable;case 5:return[3,7];case 6:throw Ce.storeNotAvailable;case 7:return[2]}}))}))},t.prototype.init=function(e){return r(this,void 0,void 0,(function(){return s(this,(function(t){switch(t.label){case 0:return this.dbname=e,[4,this.checkAvailability()];case 1:return t.sent(),[4,this._openDatabase(e)];case 2:return t.sent(),[2]}}))}))},t.prototype.clear=function(){return r(this,void 0,void 0,(function(){var e;return s(this,(function(t){switch(t.label){case 0:return[4,this._getObjectStore("readwrite")];case 1:return e=t.sent(),[4,new Promise((function(t,n){var r=e.clear();r.addEventListener("success",(function(){return t()})),r.addEventListener("error",(function(e){return n(e.target.error)}))}))];case 2:return[2,t.sent()]}}))}))},t}(ot),dt=function(e){function t(t){var n=this,r=t.AsyncStorage,i=t.itemSizeLimit,s=void 0===i?6291456:i,o=T(t,["AsyncStorage","itemSizeLimit"]);return(n=e.call(this,a(a({},o),{itemSizeLimit:s}))||this)._asyncStorage=r,n}return u(t,e),t.prototype._isBelonging=function(e){return e.startsWith("".concat(this.dbname,"/"))},t.prototype._getActualKey=function(e){return"".concat(this.dbname,"/").concat(e)},t.prototype._getAllRawKeys=function(){return r(this,void 0,void 0,(function(){var e,t=this;return s(this,(function(n){switch(n.label){case 0:return[4,this._asyncStorage.getAllKeys()];case 1:return e=n.sent(),[2,e.filter((function(e){return t._isBelonging(e)})).map((function(e){return e.substring("".concat(t.dbname,"/").length)}))]}}))}))},t.prototype._getRaw=function(e){return r(this,void 0,void 0,(function(){var t;return s(this,(function(n){switch(n.label){case 0:return[4,this._asyncStorage.getItem(this._getActualKey(e))];case 1:return[2,(t=n.sent())?JSON.parse(t):null]}}))}))},t.prototype._setRaw=function(e){return r(this,void 0,void 0,(function(){var t,n,r,a,o,c,u;return s(this,(function(s){switch(s.label){case 0:t=[];try{for(n=i(e),r=n.next();!r.done;r=n.next())a=r.value,o=a.key,a.data.length<=this.adjustedItemSizeLimit&&t.push([this._getActualKey(o),JSON.stringify(a)])}catch(e){c={error:e}}finally{try{r&&!r.done&&(u=n.return)&&u.call(n)}finally{if(c)throw c.error}}return[4,this._asyncStorage.multiSet(t)];case 1:return s.sent(),[2]}}))}))},t.prototype._removeRaw=function(e){return r(this,void 0,void 0,(function(){var t=this;return s(this,(function(n){switch(n.label){case 0:return[4,this._asyncStorage.multiRemove(e.map((function(e){return t._getActualKey(e)})))];case 1:return n.sent(),[2]}}))}))},t.prototype.checkAvailability=function(){return r(this,void 0,void 0,(function(){return s(this,(function(e){if(!this._asyncStorage)throw Ce.storeNotAvailable;return[2]}))}))},t.prototype.init=function(e){return r(this,void 0,void 0,(function(){return s(this,(function(t){return this.dbname=e,[2]}))}))},t.prototype.clear=function(){return r(this,void 0,void 0,(function(){var e;return s(this,(function(t){switch(t.label){case 0:return[4,this.getAllKeys()];case 1:return e=t.sent(),[4,this.removeMany(e)];case 2:return t.sent(),[2]}}))}))},t}(ot);!function(e){function t(t){var n,r=this;return(r=e.call(this,a(a({},t),{itemSizeLimit:null!==(n=t.itemSizeLimit)&&void 0!==n?n:6291456}))||this)._mmkv=t.MMKV,r}u(t,e),t.prototype._isBelonging=function(e){return e.startsWith("".concat(this.dbname,"/"))},t.prototype._getActualKey=function(e){return"".concat(this.dbname,"/").concat(e)},t.prototype._getAllRawKeys=function(){return r(this,void 0,void 0,(function(){var e,t=this;return s(this,(function(n){switch(n.label){case 0:return[4,this._mmkv.getAllKeys()];case 1:return e=n.sent(),[2,e.filter((function(e){return t._isBelonging(e)})).map((function(e){return e.substring("".concat(t.dbname,"/").length)}))]}}))}))},t.prototype._getRaw=function(e){return r(this,void 0,void 0,(function(){var t;return s(this,(function(n){switch(n.label){case 0:return[4,this._mmkv.getString(this._getActualKey(e))];case 1:return[2,(t=n.sent())?JSON.parse(t):null]}}))}))},t.prototype._setRaw=function(e){return r(this,void 0,void 0,(function(){var t,n,r,a,o,c;return s(this,(function(s){try{for(t=i(e),n=t.next();!n.done;n=t.next())r=n.value,a=r.key,r.data.length<=this.adjustedItemSizeLimit&&this._mmkv.set(this._getActualKey(a),JSON.stringify(r))}catch(e){o={error:e}}finally{try{n&&!n.done&&(c=t.return)&&c.call(t)}finally{if(o)throw o.error}}return[2]}))}))},t.prototype._removeRaw=function(e){return r(this,void 0,void 0,(function(){var t,n,r,a,o;return s(this,(function(s){try{for(t=i(e),n=t.next();!n.done;n=t.next())r=n.value,this._mmkv.delete(this._getActualKey(r))}catch(e){a={error:e}}finally{try{n&&!n.done&&(o=t.return)&&o.call(t)}finally{if(a)throw a.error}}return[2]}))}))},t.prototype.checkAvailability=function(){return r(this,void 0,void 0,(function(){return s(this,(function(e){if(!this._mmkv)throw Ce.storeNotAvailable;return[2]}))}))},t.prototype.init=function(e){return r(this,void 0,void 0,(function(){return s(this,(function(t){return this.dbname=e,[2]}))}))},t.prototype.clear=function(){return r(this,void 0,void 0,(function(){var e;return s(this,(function(t){switch(t.label){case 0:return[4,this.getAllKeys()];case 1:return e=t.sent(),[4,this.removeMany(e)];case 2:return t.sent(),[2]}}))}))}}(ot);var ft,_t="[NESTDB]",pt=!0,mt=function(){function e(){}return e.off=function(){pt=!1},e.log=function(){for(var e=[],t=0;t0&&i[i.length-1])||6!==a[0]&&2!==a[0])){s=0;continue}if(3===a[0]&&(!i||a[1]>i[0]&&a[1]=e.length&&(e=void 0),{value:e&&e[r++],done:!e}}};throw new TypeError(t?"Object is not iterable.":"Symbol.iterator is not defined.")}function a(e,t){var n="function"==typeof Symbol&&e[Symbol.iterator];if(!n)return e;var r,i,o=n.call(e),s=[];try{for(;(void 0===t||t-- >0)&&!(r=o.next()).done;)s.push(r.value)}catch(e){i={error:e}}finally{try{r&&!r.done&&(n=o.return)&&n.call(o)}finally{if(i)throw i.error}}return s}function c(e,t,n){if(n||2===arguments.length)for(var r,i=0,o=t.length;i0&&b.indexOf(e)>=0},O=function(e){return e>0&&m.indexOf(e)>=0},A=function(e,t){if(void 0===t&&(t=!1),t&&null==e)return!0;var n="object"==typeof e&&null!==e&&e.hasOwnProperty("name")&&"string"==typeof e.name&&e.hasOwnProperty("uri")&&"string"==typeof e.uri&&e.hasOwnProperty("type")&&"string"==typeof e.type;if(!n){if("undefined"!=typeof Blob)return e instanceof Blob;if("undefined"!=typeof File)return e instanceof File}return n},N=function(e,t){if(e===t)return!0;if(null==e||null==t)return!1;if(e.length!==t.length)return!1;for(var n=c([],a(e),!1).sort(),r=c([],a(t),!1).sort(),i=0;i=1e3&&e<=9e3&&(this._typingIndicatorThrottle=e)},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"websocketResponseTimeout",{get:function(){return this._websocketResponseTimeout},set:function(e){w("number",e)&&e>=5e3&&e<=3e4&&(this._websocketResponseTimeout=e)},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"sessionTokenRefreshTimeout",{get:function(){return this._sessionTokenRefreshTimeout},set:function(e){w("number",e)&&(e<60?e=60:e>1800&&(e=1800),this._sessionTokenRefreshTimeout=e)},enumerable:!1,configurable:!0}),e}(),I={encrypt:function(e){return e},decrypt:function(e){return e}},D=function(){function e(e){var t=e.store;this._preference=new Map,this._store=t}return e.prototype._savePreferenceKeys=function(){return i(this,void 0,void 0,(function(){return o(this,(function(e){switch(e.label){case 0:return[4,this._store.set({key:this._keysAddress,value:c([],a(this._preference.keys()),!1)})];case 1:return e.sent(),[2]}}))}))},e.prototype.init=function(e,t){var n;return void 0===t&&(t=1),i(this,void 0,void 0,(function(){var r,i,a,c,u,l,h,d,_,f;return o(this,(function(o){switch(o.label){case 0:return this._version=t,this._keysAddress=e,r="".concat(e,".metadata.version"),[4,this._store.get(r)];case 1:return i=o.sent(),[4,this._store.get(e)];case 2:return a=null!==(n=o.sent())&&void 0!==n?n:[],!i||i.versiont.channel.messageCollectionLastAccessedAt?1:-1},this._maxSize=Math.max(r,64),s?(this._clearOrder=o,this._customClearOrderComparator=s):this._clearOrder=g.MESSAGE_COLLECTION_ACCESSED_AT}return Object.defineProperty(e.prototype,"maxSize",{get:function(){return this._maxSize},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"clearOrder",{get:function(){return this._clearOrder},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"clearOrderComparator",{get:function(){var e;return this._clearOrder===g.MESSAGE_COLLECTION_ACCESSED_AT?this._clearOrderComparatorUseMessageCollectionAccessedAt:null!==(e=this._customClearOrderComparator)&&void 0!==e?e:this._clearOrderComparatorUseMessageCollectionAccessedAt},enumerable:!1,configurable:!0}),e}(),V=function(){function e(){}return Object.defineProperty(e.prototype,"hasSession",{get:function(){return!!this.sessionKey},enumerable:!1,configurable:!0}),e.prototype.clear=function(){this.authToken=void 0,this.sessionKey=void 0},e}(),Z=function(){var e=(new Date).getTime();return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,(function(t){var n=(e+16*Math.random())%16|0;return e=Math.floor(e/16),("x"===t?n:3&n|8).toString(16)}))},H=function(){function e(e){var t=e.container;this._container={},this._container=t,this.key=Z()}return e.prototype._register=function(e,t,n){var r;return e in this._container||(this._container[e]=new Map),null===(r=this._container[e])||void 0===r||r.set(this.key,{occurence:t,handler:n}),this},e.prototype.on=function(e,t){return this._register(e,-1,t)},e.prototype.once=function(e,t){return this._register(e,1,t)},e.prototype.close=function(){var e;for(var t in this._container)null===(e=this._container[t])||void 0===e||e.delete(this.key)},e}(),W=function(){function e(){this._container={}}return e.prototype.on=function(e,t){return new H({container:this._container}).on(e,t)},e.prototype.once=function(e,t){return new H({container:this._container}).once(e,t)},e.prototype.dispatch=function(e,t){var n,r,i=this._container[e];if(i){var o=[];try{for(var a=s(i.keys()),c=a.next();!c.done;c=a.next()){var u=c.value,l=i.get(u);l.handler(t),l.occurence>0&&(l.occurence--,0===l.occurence&&o.push(u))}}catch(e){n={error:e}}finally{try{c&&!c.done&&(r=a.return)&&r.call(a)}finally{if(n)throw n.error}}o.forEach((function(e){return i.delete(e)}))}},e}(),Q=function(){function e(){this._dispatcher=new W}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}(),Y=function(){},X=function(e){var t={};return e&&Object.keys(e).forEach((function(n){void 0===e[n]||Number.isNaN(e[n])||null===e[n]||(t[n]=e[n])})),t},J=function(e){if(null!=e){if("object"==typeof e){if(Array.isArray(e)){var t=c([],a(e),!1);for(var n in t)t[n]=J(t[n]);return t}for(var r in e)null===e[r]&&delete e[r];return e}return e}};!function(e){e.BASE="base",e.GROUP="group",e.OPEN="open"}(x||(x={})),function(e){e.OPERATOR="operator",e.NONE="none"}(M||(M={})),function(e){e.BASE="base",e.USER="user",e.FILE="file",e.ADMIN="admin"}(P||(P={})),function(e){e.ALL="",e.USER="MESG",e.FILE="FILE",e.ADMIN="ADMM"}(U||(U={})),function(e){e.USER="MESG",e.FILE="FILE",e.ADMIN="ADMM"}(z||(z={})),function(e){e.USERS="users",e.CHANNEL="channel"}(F||(F={})),function(e){e.ALL="all",e.NONE="none",e.ONLY_REPLY_TO_CHANNEL="only_reply_to_channel"}(q||(q={})),function(e){e.DEFAULT="default",e.SUPPRESS="suppress"}(G||(G={})),function(e){e.PENDING="pending",e.SCHEDULED="scheduled",e.SUCCEEDED="succeeded",e.FAILED="failed",e.CANCELED="canceled"}(j||(j={}));var $,ee="v3",te="/".concat(ee,"/users"),ne="/".concat(ee,"/storage/file"),re="/".concat(ee,"/group_channels"),ie="/".concat(ee,"/sdk/group_channels"),oe="/".concat(ee,"/open_channels"),se="/".concat(ee,"/sdk/open_channels"),ae="/".concat(ee,"/search"),ce="/".concat(ee,"/report"),ue="/".concat(ee,"/emojis"),le="/".concat(ee,"/emoji_categories"),he="/".concat(ee,"/polls"),de="/".concat(ee,"/scheduled_messages"),_e="/".concat(ee,"/sdk/ui_kit/configuration"),fe="/".concat(ee,"/sdk/statistics"),pe=function(e){switch(e){case x.GROUP:return re;case x.OPEN:return oe;default:return null}},ge=function(e){switch(e){case x.GROUP:return"".concat(ce,"/group_channels");case x.OPEN:return"".concat(ce,"/open_channels");default:return null}},ve=function(e,t,n){var r,i;switch(e){case F.CHANNEL:return!0;case F.USERS:if(t)try{for(var o=s(t),a=o.next();!a.done;a=o.next()){if(a.value===n)return!0}}catch(e){r={error:e}}finally{try{a&&!a.done&&(i=o.return)&&i.call(o)}finally{if(r)throw r.error}}}return!1},Ee=function(e,t,n){var r,i,o,s,a=ve(null!==(r=e.mentionType)&&void 0!==r?r:null,null!==(i=e.mentionedUserIds)&&void 0!==i?i:[],n),c=ve(null!==(o=t.mentionType)&&void 0!==o?o:null,null!==(s=t.mentionedUserIds)&&void 0!==s?s:[],n);return!a&&c?1:a&&!c?-1:0},be=function(e,t,n){var r,i=t||new FormData;for(var o in e)if(Object.prototype.hasOwnProperty.call(e,o)){var s=e[o],a=n?"".concat(n,"[").concat(o,"]"):o;A(s)?i.append(a,s,null!==(r=s.name)&&void 0!==r?r:"filename"):"object"!=typeof s||null===s||Array.isArray(s)||s instanceof Blob?i.append(a,String(s)):i=be(s,i,a)}return i};!function(e){e.GET="GET",e.POST="POST",e.PUT="PUT",e.DELETE="DELETE"}($||($={}));var me,ye=function(e){function n(){var t=null!==e&&e.apply(this,arguments)||this;return t.params={},t.requireAuth=!0,t.headers={},t.requestId=Z(),t}return t(n,e),n.prototype.encodeParams=function(e){var t=this;return null==e||""===e?encodeURIComponent(""):Array.isArray(e)?e.map((function(e){return t.encodeParams(e)})).join(","):"object"==typeof e?encodeURIComponent(JSON.stringify(e)):encodeURIComponent(String(e))},Object.defineProperty(n.prototype,"query",{get:function(){var e=this,t=X(this.params);return"?".concat(Object.keys(t).map((function(n){return"".concat(encodeURIComponent(n),"=").concat(e.encodeParams(t[n]))})).join("&"))},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"payload",{get:function(){var e=X(this.params);return Object.keys(e).some((function(t){return A(e[t])}))?be(e):JSON.stringify(e)},enumerable:!1,configurable:!0}),n}(Y),we=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}(Y),Se=function(e){function n(t){var n=e.call(this)||this;return n.requestId=t,n}return t(n,e),n}(Y),ke=function(e){function n(t){var n=t.expires_in,r=t.reason,i=void 0===r?u.SESSION_KEY_EXPIRED:r,o=e.call(this)||this;switch(o.expiresIn=null!=n?n:0,i){case u.SESSION_KEY_EXPIRED:case u.SESSION_TOKEN_EXPIRED:case u.SESSION_REVOKED:o.error=new E({code:i})}return o}return t(n,e),Object.defineProperty(n.prototype,"invalidateSessionToken",{get:function(){var e;return!!(null===(e=this.error)||void 0===e?void 0:e.isSessionTokenExpiredError)},enumerable:!1,configurable:!0}),n}(Y),Te=function(e){function n(t){var n=e.call(this)||this;return n.statLog=t,n}return t(n,e),n}(Y);!function(e){e.FEATURE_LOCALCACHE="feature:local_cache",e.WEBSOCKET_CONNECT="ws:connect",e.API_RESULT="api:result"}(me||(me={}));var Ce=function(){function e(e){var t=e.type,n=e.data,r=e.ts,i=void 0===r?Date.now():r;this.type=t,this.createdAt=i,this.data=n}return e.payloadify=function(e){return X({stat_type:e.type,ts:e.createdAt,data:X(e.data)})},e}(),Oe=function(){return"undefined"==typeof document&&"undefined"!=typeof navigator&&"ReactNative"==navigator.product},Ae=function(){function e(e,t){var n=t.auth,r=t.sdkState,i=t.dispatcher,o=t.logger,s=t.useFetchCompat,a=void 0!==s&&s,c=this;this._abortControl=new Map,this._shouldImportFetchCompat=!1,this._iid=e,this._auth=n,this._sdkState=r,this._dispatcher=i,this._dispatcher.on((function(e){e instanceof Se&&c.cancel(e.requestId)})),this._logger=o,this._shouldImportFetchCompat=a}return Object.defineProperty(e.prototype,"_userAgentWithExtension",{get:function(){var e=this._sdkState.extensions,t=Oe()?"reactnative":"JS",n="//";if(e){var r=e.sb_syncmanager?"s".concat(e.sb_syncmanager):"",i=e.sb_uikit?"u".concat(e.sb_uikit):"",o=e["device-os-platform"]?"o".concat(e["device-os-platform"]):"";n="".concat(r,"/").concat(i,"/").concat(o)}return"".concat(t,"/c").concat(h.SDK_VERSION,"/").concat(n)},enumerable:!1,configurable:!0}),e.prototype._createHeader=function(e,t){var r=this._sdkState,i=r.appId,o=r.appVersion,s=n(n({},e.headers),{SendBird:"JS,".concat(h.OS_VERSION,",").concat(h.SDK_VERSION,",").concat(i).concat(o?",".concat(o):""),"SB-User-Agent":encodeURIComponent(this._userAgentWithExtension),"Request-Sent-Timestamp":Date.now().toString()});return t||(s["Content-Type"]="application/json; charset=utf-8"),e.requireAuth&&this._auth.hasSession&&(s["Session-Key"]=this._auth.sessionKey),this._auth&&this._auth.authToken&&(s["App-Id"]=i,s["Access-Token"]=this._auth.authToken),s},e.prototype._statLogApiResult=function(e,t,n){this._dispatcher.dispatch(new Te(new Ce({type:me.API_RESULT,data:{endpoint:e.path,method:e.method,success:!n,latency:Date.now()-t,error_code:null==n?void 0:n.code,error_description:null==n?void 0:n.message}})))},e.prototype.send=function(e){return i(this,void 0,void 0,(function(){var t,n,r,i,s,a,c,u,l,h,d,_,f,p,g;return o(this,(function(o){switch(o.label){case 0:t=e.path,n=e.method,r=![$.GET,$.DELETE].includes(n),i=this._sdkState.api,s="".concat(i.host).concat(t).concat(r?"":e.query),a=r?e.payload:null,c=this._createHeader(e,a instanceof FormData?a:void 0),u=new AbortController,l=u.signal,this._abortControl.set(e.requestId,u),h=Date.now(),o.label=1;case 1:return o.trys.push([1,8,,9]),this._shouldImportFetchCompat&&(this._shouldImportFetchCompat=!1,("undefined"!=typeof globalThis&&globalThis||"undefined"!=typeof self&&self||"undefined"!=typeof global&&global||{fetch:null}).fetch=null),"undefined"!=typeof AbortController?[3,3]:[4,import("./__bundle-2aa1a987.js")];case 2:o.sent(),o.label=3;case 3:return"function"==typeof fetch?[3,5]:[4,import("./__bundle-57274663.js")];case 4:o.sent(),o.label=5;case 5:return[4,fetch(s,{method:n,body:a,headers:c,signal:l})];case 6:return[4,(d=o.sent()).json()];case 7:if(_=o.sent(),d.ok||d.redirected)return this._logger.debug("receive api response",e.requestId),this._statLogApiResult(e,h),[2,new we(this._iid,_)];throw _?(((f=new E(_)).isSessionKeyExpiredError||f.isSessionTokenExpiredError)&&this._dispatcher.dispatch(new ke({reason:f.code})),this._statLogApiResult(e,h,f),f):(f=E.requestFailed,this._statLogApiResult(e,h,f),f);case 8:throw p=o.sent(),this._statLogApiResult(e,h,p),p instanceof E?(this._logger.debug("fail api request",p),p):"AbortError"===p.name?E.requestCanceled:(g=E.networkError,this._logger.debug("fail api request",g),g);case 9:return[2]}}))}))},e.prototype.cancel=function(e){this._abortControl.has(e)&&(this._abortControl.get(e).abort(),this._abortControl.delete(e))},e.prototype.cancelAll=function(){var e,t;try{for(var n=s(this._abortControl.values()),r=n.next();!r.done;r=n.next()){r.value.abort()}}catch(t){e={error:t}}finally{try{r&&!r.done&&(t=n.return)&&t.call(n)}finally{if(e)throw e.error}}this._abortControl.clear()},e}(),Ne=function(e){function n(t,n,r,i){void 0===i&&(i="");var o,s=this;return(s=e.call(this)||this)._iid=t,s.code=n,s.payload=r,s.requestId=null!==(o=r.req_id)&&void 0!==o?o:i,s}return t(n,e),n.createFromRawMessage=function(e,t){var r=t.substring(0,4),i={};try{i=JSON.parse(t.substring(4))}catch(e){r="NOOP"}finally{return new n(e,r,i)}},n.prototype.convertToMessage=function(){return"".concat(this.code).concat(JSON.stringify(this.payload),"\n")},n.prototype.as=function(e){return new e(this._iid,this.code,this.payload)},n}(Y),Re=function(){};function Ie(e){let t=e.length;for(;--t>=0;)e[t]=0}const De=256,Le=286,xe=30,Me=15,Pe=new Uint8Array([0,0,0,0,0,0,0,0,1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4,5,5,5,5,0]),Ue=new Uint8Array([0,0,0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9,9,10,10,11,11,12,12,13,13]),ze=new Uint8Array([0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,3,7]),Fe=new Uint8Array([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),qe=new Array(576);Ie(qe);const Ge=new Array(60);Ie(Ge);const je=new Array(512);Ie(je);const Ke=new Array(256);Ie(Ke);const Be=new Array(29);Ie(Be);const Ve=new Array(xe);function Ze(e,t,n,r,i){this.static_tree=e,this.extra_bits=t,this.extra_base=n,this.elems=r,this.max_length=i,this.has_stree=e&&e.length}let He,We,Qe;function Ye(e,t){this.dyn_tree=e,this.max_code=0,this.stat_desc=t}Ie(Ve);const Xe=e=>e<256?je[e]:je[256+(e>>>7)],Je=(e,t)=>{e.pending_buf[e.pending++]=255&t,e.pending_buf[e.pending++]=t>>>8&255},$e=(e,t,n)=>{e.bi_valid>16-n?(e.bi_buf|=t<>16-e.bi_valid,e.bi_valid+=n-16):(e.bi_buf|=t<{$e(e,n[2*t],n[2*t+1])},tt=(e,t)=>{let n=0;do{n|=1&e,e>>>=1,n<<=1}while(--t>0);return n>>>1},nt=(e,t,n)=>{const r=new Array(16);let i,o,s=0;for(i=1;i<=Me;i++)s=s+n[i-1]<<1,r[i]=s;for(o=0;o<=t;o++){let t=e[2*o+1];0!==t&&(e[2*o]=tt(r[t]++,t))}},rt=e=>{let t;for(t=0;t{e.bi_valid>8?Je(e,e.bi_buf):e.bi_valid>0&&(e.pending_buf[e.pending++]=e.bi_buf),e.bi_buf=0,e.bi_valid=0},ot=(e,t,n,r)=>{const i=2*t,o=2*n;return e[i]{const r=e.heap[n];let i=n<<1;for(;i<=e.heap_len&&(i{let r,i,o,s,a=0;if(0!==e.sym_next)do{r=255&e.pending_buf[e.sym_buf+a++],r+=(255&e.pending_buf[e.sym_buf+a++])<<8,i=e.pending_buf[e.sym_buf+a++],0===r?et(e,i,t):(o=Ke[i],et(e,o+De+1,t),s=Pe[o],0!==s&&(i-=Be[o],$e(e,i,s)),r--,o=Xe(r),et(e,o,n),s=Ue[o],0!==s&&(r-=Ve[o],$e(e,r,s)))}while(a{const n=t.dyn_tree,r=t.stat_desc.static_tree,i=t.stat_desc.has_stree,o=t.stat_desc.elems;let s,a,c,u=-1;for(e.heap_len=0,e.heap_max=573,s=0;s>1;s>=1;s--)st(e,n,s);c=o;do{s=e.heap[1],e.heap[1]=e.heap[e.heap_len--],st(e,n,1),a=e.heap[1],e.heap[--e.heap_max]=s,e.heap[--e.heap_max]=a,n[2*c]=n[2*s]+n[2*a],e.depth[c]=(e.depth[s]>=e.depth[a]?e.depth[s]:e.depth[a])+1,n[2*s+1]=n[2*a+1]=c,e.heap[1]=c++,st(e,n,1)}while(e.heap_len>=2);e.heap[--e.heap_max]=e.heap[1],((e,t)=>{const n=t.dyn_tree,r=t.max_code,i=t.stat_desc.static_tree,o=t.stat_desc.has_stree,s=t.stat_desc.extra_bits,a=t.stat_desc.extra_base,c=t.stat_desc.max_length;let u,l,h,d,_,f,p=0;for(d=0;d<=Me;d++)e.bl_count[d]=0;for(n[2*e.heap[e.heap_max]+1]=0,u=e.heap_max+1;u<573;u++)l=e.heap[u],d=n[2*n[2*l+1]+1]+1,d>c&&(d=c,p++),n[2*l+1]=d,l>r||(e.bl_count[d]++,_=0,l>=a&&(_=s[l-a]),f=n[2*l],e.opt_len+=f*(d+_),o&&(e.static_len+=f*(i[2*l+1]+_)));if(0!==p){do{for(d=c-1;0===e.bl_count[d];)d--;e.bl_count[d]--,e.bl_count[d+1]+=2,e.bl_count[c]--,p-=2}while(p>0);for(d=c;0!==d;d--)for(l=e.bl_count[d];0!==l;)h=e.heap[--u],h>r||(n[2*h+1]!==d&&(e.opt_len+=(d-n[2*h+1])*n[2*h],n[2*h+1]=d),l--)}})(e,t),nt(n,u,e.bl_count)},ut=(e,t,n)=>{let r,i,o=-1,s=t[1],a=0,c=7,u=4;for(0===s&&(c=138,u=3),t[2*(n+1)+1]=65535,r=0;r<=n;r++)i=s,s=t[2*(r+1)+1],++a{let r,i,o=-1,s=t[1],a=0,c=7,u=4;for(0===s&&(c=138,u=3),r=0;r<=n;r++)if(i=s,s=t[2*(r+1)+1],!(++a{$e(e,0+(r?1:0),3),it(e),Je(e,n),Je(e,~n),n&&e.pending_buf.set(e.window.subarray(t,t+n),e.pending),e.pending+=n};var _t=(e,t,n,r)=>{let i,o,s=0;e.level>0?(2===e.strm.data_type&&(e.strm.data_type=(e=>{let t,n=4093624447;for(t=0;t<=31;t++,n>>>=1)if(1&n&&0!==e.dyn_ltree[2*t])return 0;if(0!==e.dyn_ltree[18]||0!==e.dyn_ltree[20]||0!==e.dyn_ltree[26])return 1;for(t=32;t{let t;for(ut(e,e.dyn_ltree,e.l_desc.max_code),ut(e,e.dyn_dtree,e.d_desc.max_code),ct(e,e.bl_desc),t=18;t>=3&&0===e.bl_tree[2*Fe[t]+1];t--);return e.opt_len+=3*(t+1)+5+5+4,t})(e),i=e.opt_len+3+7>>>3,o=e.static_len+3+7>>>3,o<=i&&(i=o)):i=o=n+5,n+4<=i&&-1!==t?dt(e,t,n,r):4===e.strategy||o===i?($e(e,2+(r?1:0),3),at(e,qe,Ge)):($e(e,4+(r?1:0),3),((e,t,n,r)=>{let i;for($e(e,t-257,5),$e(e,n-1,5),$e(e,r-4,4),i=0;i{ht||((()=>{let e,t,n,r,i;const o=new Array(16);for(n=0,r=0;r<28;r++)for(Be[r]=n,e=0;e<1<>=7;r(e.pending_buf[e.sym_buf+e.sym_next++]=t,e.pending_buf[e.sym_buf+e.sym_next++]=t>>8,e.pending_buf[e.sym_buf+e.sym_next++]=n,0===t?e.dyn_ltree[2*n]++:(e.matches++,t--,e.dyn_ltree[2*(Ke[n]+De+1)]++,e.dyn_dtree[2*Xe(t)]++),e.sym_next===e.sym_end),_tr_align:e=>{$e(e,2,3),et(e,256,qe),(e=>{16===e.bi_valid?(Je(e,e.bi_buf),e.bi_buf=0,e.bi_valid=0):e.bi_valid>=8&&(e.pending_buf[e.pending++]=255&e.bi_buf,e.bi_buf>>=8,e.bi_valid-=8)})(e)}};var pt=(e,t,n,r)=>{let i=65535&e|0,o=e>>>16&65535|0,s=0;for(;0!==n;){s=n>2e3?2e3:n,n-=s;do{i=i+t[r++]|0,o=o+i|0}while(--s);i%=65521,o%=65521}return i|o<<16|0};const gt=new Uint32Array((()=>{let e,t=[];for(var n=0;n<256;n++){e=n;for(var r=0;r<8;r++)e=1&e?3988292384^e>>>1:e>>>1;t[n]=e}return t})());var vt=(e,t,n,r)=>{const i=gt,o=r+n;e^=-1;for(let n=r;n>>8^i[255&(e^t[n])];return-1^e},Et={2:"need dictionary",1:"stream end",0:"","-1":"file error","-2":"stream error","-3":"data error","-4":"insufficient memory","-5":"buffer error","-6":"incompatible version"},bt={Z_NO_FLUSH:0,Z_PARTIAL_FLUSH:1,Z_SYNC_FLUSH:2,Z_FULL_FLUSH:3,Z_FINISH:4,Z_BLOCK:5,Z_TREES:6,Z_OK:0,Z_STREAM_END:1,Z_NEED_DICT:2,Z_ERRNO:-1,Z_STREAM_ERROR:-2,Z_DATA_ERROR:-3,Z_MEM_ERROR:-4,Z_BUF_ERROR:-5,Z_NO_COMPRESSION:0,Z_BEST_SPEED:1,Z_BEST_COMPRESSION:9,Z_DEFAULT_COMPRESSION:-1,Z_FILTERED:1,Z_HUFFMAN_ONLY:2,Z_RLE:3,Z_FIXED:4,Z_DEFAULT_STRATEGY:0,Z_BINARY:0,Z_TEXT:1,Z_UNKNOWN:2,Z_DEFLATED:8};const{_tr_init:mt,_tr_stored_block:yt,_tr_flush_block:wt,_tr_tally:St,_tr_align:kt}=ft,{Z_NO_FLUSH:Tt,Z_PARTIAL_FLUSH:Ct,Z_FULL_FLUSH:Ot,Z_FINISH:At,Z_BLOCK:Nt,Z_OK:Rt,Z_STREAM_END:It,Z_STREAM_ERROR:Dt,Z_DATA_ERROR:Lt,Z_BUF_ERROR:xt,Z_DEFAULT_COMPRESSION:Mt,Z_FILTERED:Pt,Z_HUFFMAN_ONLY:Ut,Z_RLE:zt,Z_FIXED:Ft,Z_DEFAULT_STRATEGY:qt,Z_UNKNOWN:Gt,Z_DEFLATED:jt}=bt,Kt=258,Bt=262,Vt=42,Zt=113,Ht=666,Wt=(e,t)=>(e.msg=Et[t],t),Qt=e=>2*e-(e>4?9:0),Yt=e=>{let t=e.length;for(;--t>=0;)e[t]=0},Xt=e=>{let t,n,r,i=e.w_size;t=e.hash_size,r=t;do{n=e.head[--r],e.head[r]=n>=i?n-i:0}while(--t);t=i,r=t;do{n=e.prev[--r],e.prev[r]=n>=i?n-i:0}while(--t)};let Jt=(e,t,n)=>(t<{const t=e.state;let n=t.pending;n>e.avail_out&&(n=e.avail_out),0!==n&&(e.output.set(t.pending_buf.subarray(t.pending_out,t.pending_out+n),e.next_out),e.next_out+=n,t.pending_out+=n,e.total_out+=n,e.avail_out-=n,t.pending-=n,0===t.pending&&(t.pending_out=0))},en=(e,t)=>{wt(e,e.block_start>=0?e.block_start:-1,e.strstart-e.block_start,t),e.block_start=e.strstart,$t(e.strm)},tn=(e,t)=>{e.pending_buf[e.pending++]=t},nn=(e,t)=>{e.pending_buf[e.pending++]=t>>>8&255,e.pending_buf[e.pending++]=255&t},rn=(e,t,n,r)=>{let i=e.avail_in;return i>r&&(i=r),0===i?0:(e.avail_in-=i,t.set(e.input.subarray(e.next_in,e.next_in+i),n),1===e.state.wrap?e.adler=pt(e.adler,t,i,n):2===e.state.wrap&&(e.adler=vt(e.adler,t,i,n)),e.next_in+=i,e.total_in+=i,i)},on=(e,t)=>{let n,r,i=e.max_chain_length,o=e.strstart,s=e.prev_length,a=e.nice_match;const c=e.strstart>e.w_size-Bt?e.strstart-(e.w_size-Bt):0,u=e.window,l=e.w_mask,h=e.prev,d=e.strstart+Kt;let _=u[o+s-1],f=u[o+s];e.prev_length>=e.good_match&&(i>>=2),a>e.lookahead&&(a=e.lookahead);do{if(n=t,u[n+s]===f&&u[n+s-1]===_&&u[n]===u[o]&&u[++n]===u[o+1]){o+=2,n++;do{}while(u[++o]===u[++n]&&u[++o]===u[++n]&&u[++o]===u[++n]&&u[++o]===u[++n]&&u[++o]===u[++n]&&u[++o]===u[++n]&&u[++o]===u[++n]&&u[++o]===u[++n]&&os){if(e.match_start=t,s=r,r>=a)break;_=u[o+s-1],f=u[o+s]}}}while((t=h[t&l])>c&&0!=--i);return s<=e.lookahead?s:e.lookahead},sn=e=>{const t=e.w_size;let n,r,i;do{if(r=e.window_size-e.lookahead-e.strstart,e.strstart>=t+(t-Bt)&&(e.window.set(e.window.subarray(t,t+t-r),0),e.match_start-=t,e.strstart-=t,e.block_start-=t,e.insert>e.strstart&&(e.insert=e.strstart),Xt(e),r+=t),0===e.strm.avail_in)break;if(n=rn(e.strm,e.window,e.strstart+e.lookahead,r),e.lookahead+=n,e.lookahead+e.insert>=3)for(i=e.strstart-e.insert,e.ins_h=e.window[i],e.ins_h=Jt(e,e.ins_h,e.window[i+1]);e.insert&&(e.ins_h=Jt(e,e.ins_h,e.window[i+3-1]),e.prev[i&e.w_mask]=e.head[e.ins_h],e.head[e.ins_h]=i,i++,e.insert--,!(e.lookahead+e.insert<3)););}while(e.lookahead{let n,r,i,o=e.pending_buf_size-5>e.w_size?e.w_size:e.pending_buf_size-5,s=0,a=e.strm.avail_in;do{if(n=65535,i=e.bi_valid+42>>3,e.strm.avail_outr+e.strm.avail_in&&(n=r+e.strm.avail_in),n>i&&(n=i),n>8,e.pending_buf[e.pending-2]=~n,e.pending_buf[e.pending-1]=~n>>8,$t(e.strm),r&&(r>n&&(r=n),e.strm.output.set(e.window.subarray(e.block_start,e.block_start+r),e.strm.next_out),e.strm.next_out+=r,e.strm.avail_out-=r,e.strm.total_out+=r,e.block_start+=r,n-=r),n&&(rn(e.strm,e.strm.output,e.strm.next_out,n),e.strm.next_out+=n,e.strm.avail_out-=n,e.strm.total_out+=n)}while(0===s);return a-=e.strm.avail_in,a&&(a>=e.w_size?(e.matches=2,e.window.set(e.strm.input.subarray(e.strm.next_in-e.w_size,e.strm.next_in),0),e.strstart=e.w_size,e.insert=e.strstart):(e.window_size-e.strstart<=a&&(e.strstart-=e.w_size,e.window.set(e.window.subarray(e.w_size,e.w_size+e.strstart),0),e.matches<2&&e.matches++,e.insert>e.strstart&&(e.insert=e.strstart)),e.window.set(e.strm.input.subarray(e.strm.next_in-a,e.strm.next_in),e.strstart),e.strstart+=a,e.insert+=a>e.w_size-e.insert?e.w_size-e.insert:a),e.block_start=e.strstart),e.high_wateri&&e.block_start>=e.w_size&&(e.block_start-=e.w_size,e.strstart-=e.w_size,e.window.set(e.window.subarray(e.w_size,e.w_size+e.strstart),0),e.matches<2&&e.matches++,i+=e.w_size,e.insert>e.strstart&&(e.insert=e.strstart)),i>e.strm.avail_in&&(i=e.strm.avail_in),i&&(rn(e.strm,e.window,e.strstart,i),e.strstart+=i,e.insert+=i>e.w_size-e.insert?e.w_size-e.insert:i),e.high_water>3,i=e.pending_buf_size-i>65535?65535:e.pending_buf_size-i,o=i>e.w_size?e.w_size:i,r=e.strstart-e.block_start,(r>=o||(r||t===At)&&t!==Tt&&0===e.strm.avail_in&&r<=i)&&(n=r>i?i:r,s=t===At&&0===e.strm.avail_in&&n===r?1:0,yt(e,e.block_start,n,s),e.block_start+=n,$t(e.strm)),s?3:1)},cn=(e,t)=>{let n,r;for(;;){if(e.lookahead=3&&(e.ins_h=Jt(e,e.ins_h,e.window[e.strstart+3-1]),n=e.prev[e.strstart&e.w_mask]=e.head[e.ins_h],e.head[e.ins_h]=e.strstart),0!==n&&e.strstart-n<=e.w_size-Bt&&(e.match_length=on(e,n)),e.match_length>=3)if(r=St(e,e.strstart-e.match_start,e.match_length-3),e.lookahead-=e.match_length,e.match_length<=e.max_lazy_match&&e.lookahead>=3){e.match_length--;do{e.strstart++,e.ins_h=Jt(e,e.ins_h,e.window[e.strstart+3-1]),n=e.prev[e.strstart&e.w_mask]=e.head[e.ins_h],e.head[e.ins_h]=e.strstart}while(0!=--e.match_length);e.strstart++}else e.strstart+=e.match_length,e.match_length=0,e.ins_h=e.window[e.strstart],e.ins_h=Jt(e,e.ins_h,e.window[e.strstart+1]);else r=St(e,0,e.window[e.strstart]),e.lookahead--,e.strstart++;if(r&&(en(e,!1),0===e.strm.avail_out))return 1}return e.insert=e.strstart<2?e.strstart:2,t===At?(en(e,!0),0===e.strm.avail_out?3:4):e.sym_next&&(en(e,!1),0===e.strm.avail_out)?1:2},un=(e,t)=>{let n,r,i;for(;;){if(e.lookahead=3&&(e.ins_h=Jt(e,e.ins_h,e.window[e.strstart+3-1]),n=e.prev[e.strstart&e.w_mask]=e.head[e.ins_h],e.head[e.ins_h]=e.strstart),e.prev_length=e.match_length,e.prev_match=e.match_start,e.match_length=2,0!==n&&e.prev_length4096)&&(e.match_length=2)),e.prev_length>=3&&e.match_length<=e.prev_length){i=e.strstart+e.lookahead-3,r=St(e,e.strstart-1-e.prev_match,e.prev_length-3),e.lookahead-=e.prev_length-1,e.prev_length-=2;do{++e.strstart<=i&&(e.ins_h=Jt(e,e.ins_h,e.window[e.strstart+3-1]),n=e.prev[e.strstart&e.w_mask]=e.head[e.ins_h],e.head[e.ins_h]=e.strstart)}while(0!=--e.prev_length);if(e.match_available=0,e.match_length=2,e.strstart++,r&&(en(e,!1),0===e.strm.avail_out))return 1}else if(e.match_available){if(r=St(e,0,e.window[e.strstart-1]),r&&en(e,!1),e.strstart++,e.lookahead--,0===e.strm.avail_out)return 1}else e.match_available=1,e.strstart++,e.lookahead--}return e.match_available&&(r=St(e,0,e.window[e.strstart-1]),e.match_available=0),e.insert=e.strstart<2?e.strstart:2,t===At?(en(e,!0),0===e.strm.avail_out?3:4):e.sym_next&&(en(e,!1),0===e.strm.avail_out)?1:2};function ln(e,t,n,r,i){this.good_length=e,this.max_lazy=t,this.nice_length=n,this.max_chain=r,this.func=i}const hn=[new ln(0,0,0,0,an),new ln(4,4,8,4,cn),new ln(4,5,16,8,cn),new ln(4,6,32,32,cn),new ln(4,4,16,16,un),new ln(8,16,32,32,un),new ln(8,16,128,128,un),new ln(8,32,128,256,un),new ln(32,128,258,1024,un),new ln(32,258,258,4096,un)];function dn(){this.strm=null,this.status=0,this.pending_buf=null,this.pending_buf_size=0,this.pending_out=0,this.pending=0,this.wrap=0,this.gzhead=null,this.gzindex=0,this.method=jt,this.last_flush=-1,this.w_size=0,this.w_bits=0,this.w_mask=0,this.window=null,this.window_size=0,this.prev=null,this.head=null,this.ins_h=0,this.hash_size=0,this.hash_bits=0,this.hash_mask=0,this.hash_shift=0,this.block_start=0,this.match_length=0,this.prev_match=0,this.match_available=0,this.strstart=0,this.match_start=0,this.lookahead=0,this.prev_length=0,this.max_chain_length=0,this.max_lazy_match=0,this.level=0,this.strategy=0,this.good_match=0,this.nice_match=0,this.dyn_ltree=new Uint16Array(1146),this.dyn_dtree=new Uint16Array(122),this.bl_tree=new Uint16Array(78),Yt(this.dyn_ltree),Yt(this.dyn_dtree),Yt(this.bl_tree),this.l_desc=null,this.d_desc=null,this.bl_desc=null,this.bl_count=new Uint16Array(16),this.heap=new Uint16Array(573),Yt(this.heap),this.heap_len=0,this.heap_max=0,this.depth=new Uint16Array(573),Yt(this.depth),this.sym_buf=0,this.lit_bufsize=0,this.sym_next=0,this.sym_end=0,this.opt_len=0,this.static_len=0,this.matches=0,this.insert=0,this.bi_buf=0,this.bi_valid=0}const _n=e=>{if(!e)return 1;const t=e.state;return!t||t.strm!==e||t.status!==Vt&&57!==t.status&&69!==t.status&&73!==t.status&&91!==t.status&&103!==t.status&&t.status!==Zt&&t.status!==Ht?1:0},fn=e=>{if(_n(e))return Wt(e,Dt);e.total_in=e.total_out=0,e.data_type=Gt;const t=e.state;return t.pending=0,t.pending_out=0,t.wrap<0&&(t.wrap=-t.wrap),t.status=2===t.wrap?57:t.wrap?Vt:Zt,e.adler=2===t.wrap?0:1,t.last_flush=-2,mt(t),Rt},pn=e=>{const t=fn(e);var n;return t===Rt&&((n=e.state).window_size=2*n.w_size,Yt(n.head),n.max_lazy_match=hn[n.level].max_lazy,n.good_match=hn[n.level].good_length,n.nice_match=hn[n.level].nice_length,n.max_chain_length=hn[n.level].max_chain,n.strstart=0,n.block_start=0,n.lookahead=0,n.insert=0,n.match_length=n.prev_length=2,n.match_available=0,n.ins_h=0),t},gn=(e,t,n,r,i,o)=>{if(!e)return Dt;let s=1;if(t===Mt&&(t=6),r<0?(s=0,r=-r):r>15&&(s=2,r-=16),i<1||i>9||n!==jt||r<8||r>15||t<0||t>9||o<0||o>Ft||8===r&&1!==s)return Wt(e,Dt);8===r&&(r=9);const a=new dn;return e.state=a,a.strm=e,a.status=Vt,a.wrap=s,a.gzhead=null,a.w_bits=r,a.w_size=1<gn(e,t,jt,15,8,qt),deflateInit2:gn,deflateReset:pn,deflateResetKeep:fn,deflateSetHeader:(e,t)=>_n(e)||2!==e.state.wrap?Dt:(e.state.gzhead=t,Rt),deflate:(e,t)=>{if(_n(e)||t>Nt||t<0)return e?Wt(e,Dt):Dt;const n=e.state;if(!e.output||0!==e.avail_in&&!e.input||n.status===Ht&&t!==At)return Wt(e,0===e.avail_out?xt:Dt);const r=n.last_flush;if(n.last_flush=t,0!==n.pending){if($t(e),0===e.avail_out)return n.last_flush=-1,Rt}else if(0===e.avail_in&&Qt(t)<=Qt(r)&&t!==At)return Wt(e,xt);if(n.status===Ht&&0!==e.avail_in)return Wt(e,xt);if(n.status===Vt&&0===n.wrap&&(n.status=Zt),n.status===Vt){let t=jt+(n.w_bits-8<<4)<<8,r=-1;if(r=n.strategy>=Ut||n.level<2?0:n.level<6?1:6===n.level?2:3,t|=r<<6,0!==n.strstart&&(t|=32),t+=31-t%31,nn(n,t),0!==n.strstart&&(nn(n,e.adler>>>16),nn(n,65535&e.adler)),e.adler=1,n.status=Zt,$t(e),0!==n.pending)return n.last_flush=-1,Rt}if(57===n.status)if(e.adler=0,tn(n,31),tn(n,139),tn(n,8),n.gzhead)tn(n,(n.gzhead.text?1:0)+(n.gzhead.hcrc?2:0)+(n.gzhead.extra?4:0)+(n.gzhead.name?8:0)+(n.gzhead.comment?16:0)),tn(n,255&n.gzhead.time),tn(n,n.gzhead.time>>8&255),tn(n,n.gzhead.time>>16&255),tn(n,n.gzhead.time>>24&255),tn(n,9===n.level?2:n.strategy>=Ut||n.level<2?4:0),tn(n,255&n.gzhead.os),n.gzhead.extra&&n.gzhead.extra.length&&(tn(n,255&n.gzhead.extra.length),tn(n,n.gzhead.extra.length>>8&255)),n.gzhead.hcrc&&(e.adler=vt(e.adler,n.pending_buf,n.pending,0)),n.gzindex=0,n.status=69;else if(tn(n,0),tn(n,0),tn(n,0),tn(n,0),tn(n,0),tn(n,9===n.level?2:n.strategy>=Ut||n.level<2?4:0),tn(n,3),n.status=Zt,$t(e),0!==n.pending)return n.last_flush=-1,Rt;if(69===n.status){if(n.gzhead.extra){let t=n.pending,r=(65535&n.gzhead.extra.length)-n.gzindex;for(;n.pending+r>n.pending_buf_size;){let i=n.pending_buf_size-n.pending;if(n.pending_buf.set(n.gzhead.extra.subarray(n.gzindex,n.gzindex+i),n.pending),n.pending=n.pending_buf_size,n.gzhead.hcrc&&n.pending>t&&(e.adler=vt(e.adler,n.pending_buf,n.pending-t,t)),n.gzindex+=i,$t(e),0!==n.pending)return n.last_flush=-1,Rt;t=0,r-=i}let i=new Uint8Array(n.gzhead.extra);n.pending_buf.set(i.subarray(n.gzindex,n.gzindex+r),n.pending),n.pending+=r,n.gzhead.hcrc&&n.pending>t&&(e.adler=vt(e.adler,n.pending_buf,n.pending-t,t)),n.gzindex=0}n.status=73}if(73===n.status){if(n.gzhead.name){let t,r=n.pending;do{if(n.pending===n.pending_buf_size){if(n.gzhead.hcrc&&n.pending>r&&(e.adler=vt(e.adler,n.pending_buf,n.pending-r,r)),$t(e),0!==n.pending)return n.last_flush=-1,Rt;r=0}t=n.gzindexr&&(e.adler=vt(e.adler,n.pending_buf,n.pending-r,r)),n.gzindex=0}n.status=91}if(91===n.status){if(n.gzhead.comment){let t,r=n.pending;do{if(n.pending===n.pending_buf_size){if(n.gzhead.hcrc&&n.pending>r&&(e.adler=vt(e.adler,n.pending_buf,n.pending-r,r)),$t(e),0!==n.pending)return n.last_flush=-1,Rt;r=0}t=n.gzindexr&&(e.adler=vt(e.adler,n.pending_buf,n.pending-r,r))}n.status=103}if(103===n.status){if(n.gzhead.hcrc){if(n.pending+2>n.pending_buf_size&&($t(e),0!==n.pending))return n.last_flush=-1,Rt;tn(n,255&e.adler),tn(n,e.adler>>8&255),e.adler=0}if(n.status=Zt,$t(e),0!==n.pending)return n.last_flush=-1,Rt}if(0!==e.avail_in||0!==n.lookahead||t!==Tt&&n.status!==Ht){let r=0===n.level?an(n,t):n.strategy===Ut?((e,t)=>{let n;for(;;){if(0===e.lookahead&&(sn(e),0===e.lookahead)){if(t===Tt)return 1;break}if(e.match_length=0,n=St(e,0,e.window[e.strstart]),e.lookahead--,e.strstart++,n&&(en(e,!1),0===e.strm.avail_out))return 1}return e.insert=0,t===At?(en(e,!0),0===e.strm.avail_out?3:4):e.sym_next&&(en(e,!1),0===e.strm.avail_out)?1:2})(n,t):n.strategy===zt?((e,t)=>{let n,r,i,o;const s=e.window;for(;;){if(e.lookahead<=Kt){if(sn(e),e.lookahead<=Kt&&t===Tt)return 1;if(0===e.lookahead)break}if(e.match_length=0,e.lookahead>=3&&e.strstart>0&&(i=e.strstart-1,r=s[i],r===s[++i]&&r===s[++i]&&r===s[++i])){o=e.strstart+Kt;do{}while(r===s[++i]&&r===s[++i]&&r===s[++i]&&r===s[++i]&&r===s[++i]&&r===s[++i]&&r===s[++i]&&r===s[++i]&&ie.lookahead&&(e.match_length=e.lookahead)}if(e.match_length>=3?(n=St(e,1,e.match_length-3),e.lookahead-=e.match_length,e.strstart+=e.match_length,e.match_length=0):(n=St(e,0,e.window[e.strstart]),e.lookahead--,e.strstart++),n&&(en(e,!1),0===e.strm.avail_out))return 1}return e.insert=0,t===At?(en(e,!0),0===e.strm.avail_out?3:4):e.sym_next&&(en(e,!1),0===e.strm.avail_out)?1:2})(n,t):hn[n.level].func(n,t);if(3!==r&&4!==r||(n.status=Ht),1===r||3===r)return 0===e.avail_out&&(n.last_flush=-1),Rt;if(2===r&&(t===Ct?kt(n):t!==Nt&&(yt(n,0,0,!1),t===Ot&&(Yt(n.head),0===n.lookahead&&(n.strstart=0,n.block_start=0,n.insert=0))),$t(e),0===e.avail_out))return n.last_flush=-1,Rt}return t!==At?Rt:n.wrap<=0?It:(2===n.wrap?(tn(n,255&e.adler),tn(n,e.adler>>8&255),tn(n,e.adler>>16&255),tn(n,e.adler>>24&255),tn(n,255&e.total_in),tn(n,e.total_in>>8&255),tn(n,e.total_in>>16&255),tn(n,e.total_in>>24&255)):(nn(n,e.adler>>>16),nn(n,65535&e.adler)),$t(e),n.wrap>0&&(n.wrap=-n.wrap),0!==n.pending?Rt:It)},deflateEnd:e=>{if(_n(e))return Dt;const t=e.state.status;return e.state=null,t===Zt?Wt(e,Lt):Rt},deflateSetDictionary:(e,t)=>{let n=t.length;if(_n(e))return Dt;const r=e.state,i=r.wrap;if(2===i||1===i&&r.status!==Vt||r.lookahead)return Dt;if(1===i&&(e.adler=pt(e.adler,t,n,0)),r.wrap=0,n>=r.w_size){0===i&&(Yt(r.head),r.strstart=0,r.block_start=0,r.insert=0);let e=new Uint8Array(r.w_size);e.set(t.subarray(n-r.w_size,n),0),t=e,n=r.w_size}const o=e.avail_in,s=e.next_in,a=e.input;for(e.avail_in=n,e.next_in=0,e.input=t,sn(r);r.lookahead>=3;){let e=r.strstart,t=r.lookahead-2;do{r.ins_h=Jt(r,r.ins_h,r.window[e+3-1]),r.prev[e&r.w_mask]=r.head[r.ins_h],r.head[r.ins_h]=e,e++}while(--t);r.strstart=e,r.lookahead=2,sn(r)}return r.strstart+=r.lookahead,r.block_start=r.strstart,r.insert=r.lookahead,r.lookahead=0,r.match_length=r.prev_length=2,r.match_available=0,e.next_in=s,e.input=a,e.avail_in=o,r.wrap=i,Rt},deflateInfo:"pako deflate (from Nodeca project)"};const En=(e,t)=>Object.prototype.hasOwnProperty.call(e,t);var bn={assign:function(e){const t=Array.prototype.slice.call(arguments,1);for(;t.length;){const n=t.shift();if(n){if("object"!=typeof n)throw new TypeError(n+"must be non-object");for(const t in n)En(n,t)&&(e[t]=n[t])}}return e},flattenChunks:e=>{let t=0;for(let n=0,r=e.length;n=252?6:e>=248?5:e>=240?4:e>=224?3:e>=192?2:1;yn[254]=yn[254]=1;var wn={string2buf:e=>{if("function"==typeof TextEncoder&&TextEncoder.prototype.encode)return(new TextEncoder).encode(e);let t,n,r,i,o,s=e.length,a=0;for(i=0;i>>6,t[o++]=128|63&n):n<65536?(t[o++]=224|n>>>12,t[o++]=128|n>>>6&63,t[o++]=128|63&n):(t[o++]=240|n>>>18,t[o++]=128|n>>>12&63,t[o++]=128|n>>>6&63,t[o++]=128|63&n);return t},buf2string:(e,t)=>{const n=t||e.length;if("function"==typeof TextDecoder&&TextDecoder.prototype.decode)return(new TextDecoder).decode(e.subarray(0,t));let r,i;const o=new Array(2*n);for(i=0,r=0;r4)o[i++]=65533,r+=s-1;else{for(t&=2===s?31:3===s?15:7;s>1&&r1?o[i++]=65533:t<65536?o[i++]=t:(t-=65536,o[i++]=55296|t>>10&1023,o[i++]=56320|1023&t)}}return((e,t)=>{if(t<65534&&e.subarray&&mn)return String.fromCharCode.apply(null,e.length===t?e:e.subarray(0,t));let n="";for(let r=0;r{(t=t||e.length)>e.length&&(t=e.length);let n=t-1;for(;n>=0&&128==(192&e[n]);)n--;return n<0||0===n?t:n+yn[e[n]]>t?n:t}};var Sn=function(){this.input=null,this.next_in=0,this.avail_in=0,this.total_in=0,this.output=null,this.next_out=0,this.avail_out=0,this.total_out=0,this.msg="",this.state=null,this.data_type=2,this.adler=0};const kn=Object.prototype.toString,{Z_NO_FLUSH:Tn,Z_SYNC_FLUSH:Cn,Z_FULL_FLUSH:On,Z_FINISH:An,Z_OK:Nn,Z_STREAM_END:Rn,Z_DEFAULT_COMPRESSION:In,Z_DEFAULT_STRATEGY:Dn,Z_DEFLATED:Ln}=bt;function xn(e){this.options=bn.assign({level:In,method:Ln,chunkSize:16384,windowBits:15,memLevel:8,strategy:Dn},e||{});let t=this.options;t.raw&&t.windowBits>0?t.windowBits=-t.windowBits:t.gzip&&t.windowBits>0&&t.windowBits<16&&(t.windowBits+=16),this.err=0,this.msg="",this.ended=!1,this.chunks=[],this.strm=new Sn,this.strm.avail_out=0;let n=vn.deflateInit2(this.strm,t.level,t.method,t.windowBits,t.memLevel,t.strategy);if(n!==Nn)throw new Error(Et[n]);if(t.header&&vn.deflateSetHeader(this.strm,t.header),t.dictionary){let e;if(e="string"==typeof t.dictionary?wn.string2buf(t.dictionary):"[object ArrayBuffer]"===kn.call(t.dictionary)?new Uint8Array(t.dictionary):t.dictionary,n=vn.deflateSetDictionary(this.strm,e),n!==Nn)throw new Error(Et[n]);this._dict_set=!0}}function Mn(e,t){const n=new xn(t);if(n.push(e,!0),n.err)throw n.msg||Et[n.err];return n.result}xn.prototype.push=function(e,t){const n=this.strm,r=this.options.chunkSize;let i,o;if(this.ended)return!1;for(o=t===~~t?t:!0===t?An:Tn,"string"==typeof e?n.input=wn.string2buf(e):"[object ArrayBuffer]"===kn.call(e)?n.input=new Uint8Array(e):n.input=e,n.next_in=0,n.avail_in=n.input.length;;)if(0===n.avail_out&&(n.output=new Uint8Array(r),n.next_out=0,n.avail_out=r),(o===Cn||o===On)&&n.avail_out<=6)this.onData(n.output.subarray(0,n.next_out)),n.avail_out=0;else{if(i=vn.deflate(n,o),i===Rn)return n.next_out>0&&this.onData(n.output.subarray(0,n.next_out)),i=vn.deflateEnd(this.strm),this.onEnd(i),this.ended=!0,i===Nn;if(0!==n.avail_out){if(o>0&&n.next_out>0)this.onData(n.output.subarray(0,n.next_out)),n.avail_out=0;else if(0===n.avail_in)break}else this.onData(n.output)}return!0},xn.prototype.onData=function(e){this.chunks.push(e)},xn.prototype.onEnd=function(e){e===Nn&&(this.result=bn.flattenChunks(this.chunks)),this.chunks=[],this.err=e,this.msg=this.strm.msg};var Pn={Deflate:xn,deflate:Mn,deflateRaw:function(e,t){return(t=t||{}).raw=!0,Mn(e,t)},gzip:function(e,t){return(t=t||{}).gzip=!0,Mn(e,t)},constants:bt};const Un=16209;var zn=function(e,t){let n,r,i,o,s,a,c,u,l,h,d,_,f,p,g,v,E,b,m,y,w,S,k,T;const C=e.state;n=e.next_in,k=e.input,r=n+(e.avail_in-5),i=e.next_out,T=e.output,o=i-(t-e.avail_out),s=i+(e.avail_out-257),a=C.dmax,c=C.wsize,u=C.whave,l=C.wnext,h=C.window,d=C.hold,_=C.bits,f=C.lencode,p=C.distcode,g=(1<>>24,d>>>=b,_-=b,b=E>>>16&255,0===b)T[i++]=65535&E;else{if(!(16&b)){if(0==(64&b)){E=f[(65535&E)+(d&(1<>>=b,_-=b),_<15&&(d+=k[n++]<<_,_+=8,d+=k[n++]<<_,_+=8),E=p[d&v];n:for(;;){if(b=E>>>24,d>>>=b,_-=b,b=E>>>16&255,!(16&b)){if(0==(64&b)){E=p[(65535&E)+(d&(1<a){e.msg="invalid distance too far back",C.mode=Un;break e}if(d>>>=b,_-=b,b=i-o,y>b){if(b=y-b,b>u&&C.sane){e.msg="invalid distance too far back",C.mode=Un;break e}if(w=0,S=h,0===l){if(w+=c-b,b2;)T[i++]=S[w++],T[i++]=S[w++],T[i++]=S[w++],m-=3;m&&(T[i++]=S[w++],m>1&&(T[i++]=S[w++]))}else{w=i-y;do{T[i++]=T[w++],T[i++]=T[w++],T[i++]=T[w++],m-=3}while(m>2);m&&(T[i++]=T[w++],m>1&&(T[i++]=T[w++]))}break}}break}}while(n>3,n-=m,_-=m<<3,d&=(1<<_)-1,e.next_in=n,e.next_out=i,e.avail_in=n{const c=a.bits;let u,l,h,d,_,f,p=0,g=0,v=0,E=0,b=0,m=0,y=0,w=0,S=0,k=0,T=null;const C=new Uint16Array(16),O=new Uint16Array(16);let A,N,R,I=null;for(p=0;p<=Fn;p++)C[p]=0;for(g=0;g=1&&0===C[E];E--);if(b>E&&(b=E),0===E)return i[o++]=20971520,i[o++]=20971520,a.bits=1,0;for(v=1;v0&&(0===e||1!==E))return-1;for(O[1]=0,p=1;p852||2===e&&S>592)return 1;for(;;){A=p-y,s[g]+1=f?(N=I[s[g]-f],R=T[s[g]-f]):(N=96,R=0),u=1<>y)+l]=A<<24|N<<16|R|0}while(0!==l);for(u=1<>=1;if(0!==u?(k&=u-1,k+=u):k=0,g++,0==--C[p]){if(p===E)break;p=t[n+s[g]]}if(p>b&&(k&d)!==h){for(0===y&&(y=b),_+=v,m=p-y,w=1<852||2===e&&S>592)return 1;h=k&d,i[h]=b<<24|m<<16|_-o|0}}return 0!==k&&(i[_+k]=p-y<<24|64<<16|0),a.bits=b,0};const{Z_FINISH:Vn,Z_BLOCK:Zn,Z_TREES:Hn,Z_OK:Wn,Z_STREAM_END:Qn,Z_NEED_DICT:Yn,Z_STREAM_ERROR:Xn,Z_DATA_ERROR:Jn,Z_MEM_ERROR:$n,Z_BUF_ERROR:er,Z_DEFLATED:tr}=bt,nr=16180,rr=16190,ir=16191,or=16192,sr=16194,ar=16199,cr=16200,ur=16206,lr=16209,hr=e=>(e>>>24&255)+(e>>>8&65280)+((65280&e)<<8)+((255&e)<<24);function dr(){this.strm=null,this.mode=0,this.last=!1,this.wrap=0,this.havedict=!1,this.flags=0,this.dmax=0,this.check=0,this.total=0,this.head=null,this.wbits=0,this.wsize=0,this.whave=0,this.wnext=0,this.window=null,this.hold=0,this.bits=0,this.length=0,this.offset=0,this.extra=0,this.lencode=null,this.distcode=null,this.lenbits=0,this.distbits=0,this.ncode=0,this.nlen=0,this.ndist=0,this.have=0,this.next=null,this.lens=new Uint16Array(320),this.work=new Uint16Array(288),this.lendyn=null,this.distdyn=null,this.sane=0,this.back=0,this.was=0}const _r=e=>{if(!e)return 1;const t=e.state;return!t||t.strm!==e||t.mode16211?1:0},fr=e=>{if(_r(e))return Xn;const t=e.state;return e.total_in=e.total_out=t.total=0,e.msg="",t.wrap&&(e.adler=1&t.wrap),t.mode=nr,t.last=0,t.havedict=0,t.flags=-1,t.dmax=32768,t.head=null,t.hold=0,t.bits=0,t.lencode=t.lendyn=new Int32Array(852),t.distcode=t.distdyn=new Int32Array(592),t.sane=1,t.back=-1,Wn},pr=e=>{if(_r(e))return Xn;const t=e.state;return t.wsize=0,t.whave=0,t.wnext=0,fr(e)},gr=(e,t)=>{let n;if(_r(e))return Xn;const r=e.state;return t<0?(n=0,t=-t):(n=5+(t>>4),t<48&&(t&=15)),t&&(t<8||t>15)?Xn:(null!==r.window&&r.wbits!==t&&(r.window=null),r.wrap=n,r.wbits=t,pr(e))},vr=(e,t)=>{if(!e)return Xn;const n=new dr;e.state=n,n.strm=e,n.window=null,n.mode=nr;const r=gr(e,t);return r!==Wn&&(e.state=null),r};let Er,br,mr=!0;const yr=e=>{if(mr){Er=new Int32Array(512),br=new Int32Array(32);let t=0;for(;t<144;)e.lens[t++]=8;for(;t<256;)e.lens[t++]=9;for(;t<280;)e.lens[t++]=7;for(;t<288;)e.lens[t++]=8;for(Bn(1,e.lens,0,288,Er,0,e.work,{bits:9}),t=0;t<32;)e.lens[t++]=5;Bn(2,e.lens,0,32,br,0,e.work,{bits:5}),mr=!1}e.lencode=Er,e.lenbits=9,e.distcode=br,e.distbits=5},wr=(e,t,n,r)=>{let i;const o=e.state;return null===o.window&&(o.wsize=1<=o.wsize?(o.window.set(t.subarray(n-o.wsize,n),0),o.wnext=0,o.whave=o.wsize):(i=o.wsize-o.wnext,i>r&&(i=r),o.window.set(t.subarray(n-r,n-r+i),o.wnext),(r-=i)?(o.window.set(t.subarray(n-r,n),0),o.wnext=r,o.whave=o.wsize):(o.wnext+=i,o.wnext===o.wsize&&(o.wnext=0),o.whavevr(e,15),inflateInit2:vr,inflate:(e,t)=>{let n,r,i,o,s,a,c,u,l,h,d,_,f,p,g,v,E,b,m,y,w,S,k=0;const T=new Uint8Array(4);let C,O;const A=new Uint8Array([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]);if(_r(e)||!e.output||!e.input&&0!==e.avail_in)return Xn;n=e.state,n.mode===ir&&(n.mode=or),s=e.next_out,i=e.output,c=e.avail_out,o=e.next_in,r=e.input,a=e.avail_in,u=n.hold,l=n.bits,h=a,d=c,S=Wn;e:for(;;)switch(n.mode){case nr:if(0===n.wrap){n.mode=or;break}for(;l<16;){if(0===a)break e;a--,u+=r[o++]<>>8&255,n.check=vt(n.check,T,2,0),u=0,l=0,n.mode=16181;break}if(n.head&&(n.head.done=!1),!(1&n.wrap)||(((255&u)<<8)+(u>>8))%31){e.msg="incorrect header check",n.mode=lr;break}if((15&u)!==tr){e.msg="unknown compression method",n.mode=lr;break}if(u>>>=4,l-=4,w=8+(15&u),0===n.wbits&&(n.wbits=w),w>15||w>n.wbits){e.msg="invalid window size",n.mode=lr;break}n.dmax=1<>8&1),512&n.flags&&4&n.wrap&&(T[0]=255&u,T[1]=u>>>8&255,n.check=vt(n.check,T,2,0)),u=0,l=0,n.mode=16182;case 16182:for(;l<32;){if(0===a)break e;a--,u+=r[o++]<>>8&255,T[2]=u>>>16&255,T[3]=u>>>24&255,n.check=vt(n.check,T,4,0)),u=0,l=0,n.mode=16183;case 16183:for(;l<16;){if(0===a)break e;a--,u+=r[o++]<>8),512&n.flags&&4&n.wrap&&(T[0]=255&u,T[1]=u>>>8&255,n.check=vt(n.check,T,2,0)),u=0,l=0,n.mode=16184;case 16184:if(1024&n.flags){for(;l<16;){if(0===a)break e;a--,u+=r[o++]<>>8&255,n.check=vt(n.check,T,2,0)),u=0,l=0}else n.head&&(n.head.extra=null);n.mode=16185;case 16185:if(1024&n.flags&&(_=n.length,_>a&&(_=a),_&&(n.head&&(w=n.head.extra_len-n.length,n.head.extra||(n.head.extra=new Uint8Array(n.head.extra_len)),n.head.extra.set(r.subarray(o,o+_),w)),512&n.flags&&4&n.wrap&&(n.check=vt(n.check,r,_,o)),a-=_,o+=_,n.length-=_),n.length))break e;n.length=0,n.mode=16186;case 16186:if(2048&n.flags){if(0===a)break e;_=0;do{w=r[o+_++],n.head&&w&&n.length<65536&&(n.head.name+=String.fromCharCode(w))}while(w&&_>9&1,n.head.done=!0),e.adler=n.check=0,n.mode=ir;break;case 16189:for(;l<32;){if(0===a)break e;a--,u+=r[o++]<>>=7&l,l-=7&l,n.mode=ur;break}for(;l<3;){if(0===a)break e;a--,u+=r[o++]<>>=1,l-=1,3&u){case 0:n.mode=16193;break;case 1:if(yr(n),n.mode=ar,t===Hn){u>>>=2,l-=2;break e}break;case 2:n.mode=16196;break;case 3:e.msg="invalid block type",n.mode=lr}u>>>=2,l-=2;break;case 16193:for(u>>>=7&l,l-=7&l;l<32;){if(0===a)break e;a--,u+=r[o++]<>>16^65535)){e.msg="invalid stored block lengths",n.mode=lr;break}if(n.length=65535&u,u=0,l=0,n.mode=sr,t===Hn)break e;case sr:n.mode=16195;case 16195:if(_=n.length,_){if(_>a&&(_=a),_>c&&(_=c),0===_)break e;i.set(r.subarray(o,o+_),s),a-=_,o+=_,c-=_,s+=_,n.length-=_;break}n.mode=ir;break;case 16196:for(;l<14;){if(0===a)break e;a--,u+=r[o++]<>>=5,l-=5,n.ndist=1+(31&u),u>>>=5,l-=5,n.ncode=4+(15&u),u>>>=4,l-=4,n.nlen>286||n.ndist>30){e.msg="too many length or distance symbols",n.mode=lr;break}n.have=0,n.mode=16197;case 16197:for(;n.have>>=3,l-=3}for(;n.have<19;)n.lens[A[n.have++]]=0;if(n.lencode=n.lendyn,n.lenbits=7,C={bits:n.lenbits},S=Bn(0,n.lens,0,19,n.lencode,0,n.work,C),n.lenbits=C.bits,S){e.msg="invalid code lengths set",n.mode=lr;break}n.have=0,n.mode=16198;case 16198:for(;n.have>>24,v=k>>>16&255,E=65535&k,!(g<=l);){if(0===a)break e;a--,u+=r[o++]<>>=g,l-=g,n.lens[n.have++]=E;else{if(16===E){for(O=g+2;l>>=g,l-=g,0===n.have){e.msg="invalid bit length repeat",n.mode=lr;break}w=n.lens[n.have-1],_=3+(3&u),u>>>=2,l-=2}else if(17===E){for(O=g+3;l>>=g,l-=g,w=0,_=3+(7&u),u>>>=3,l-=3}else{for(O=g+7;l>>=g,l-=g,w=0,_=11+(127&u),u>>>=7,l-=7}if(n.have+_>n.nlen+n.ndist){e.msg="invalid bit length repeat",n.mode=lr;break}for(;_--;)n.lens[n.have++]=w}}if(n.mode===lr)break;if(0===n.lens[256]){e.msg="invalid code -- missing end-of-block",n.mode=lr;break}if(n.lenbits=9,C={bits:n.lenbits},S=Bn(1,n.lens,0,n.nlen,n.lencode,0,n.work,C),n.lenbits=C.bits,S){e.msg="invalid literal/lengths set",n.mode=lr;break}if(n.distbits=6,n.distcode=n.distdyn,C={bits:n.distbits},S=Bn(2,n.lens,n.nlen,n.ndist,n.distcode,0,n.work,C),n.distbits=C.bits,S){e.msg="invalid distances set",n.mode=lr;break}if(n.mode=ar,t===Hn)break e;case ar:n.mode=cr;case cr:if(a>=6&&c>=258){e.next_out=s,e.avail_out=c,e.next_in=o,e.avail_in=a,n.hold=u,n.bits=l,zn(e,d),s=e.next_out,i=e.output,c=e.avail_out,o=e.next_in,r=e.input,a=e.avail_in,u=n.hold,l=n.bits,n.mode===ir&&(n.back=-1);break}for(n.back=0;k=n.lencode[u&(1<>>24,v=k>>>16&255,E=65535&k,!(g<=l);){if(0===a)break e;a--,u+=r[o++]<>b)],g=k>>>24,v=k>>>16&255,E=65535&k,!(b+g<=l);){if(0===a)break e;a--,u+=r[o++]<>>=b,l-=b,n.back+=b}if(u>>>=g,l-=g,n.back+=g,n.length=E,0===v){n.mode=16205;break}if(32&v){n.back=-1,n.mode=ir;break}if(64&v){e.msg="invalid literal/length code",n.mode=lr;break}n.extra=15&v,n.mode=16201;case 16201:if(n.extra){for(O=n.extra;l>>=n.extra,l-=n.extra,n.back+=n.extra}n.was=n.length,n.mode=16202;case 16202:for(;k=n.distcode[u&(1<>>24,v=k>>>16&255,E=65535&k,!(g<=l);){if(0===a)break e;a--,u+=r[o++]<>b)],g=k>>>24,v=k>>>16&255,E=65535&k,!(b+g<=l);){if(0===a)break e;a--,u+=r[o++]<>>=b,l-=b,n.back+=b}if(u>>>=g,l-=g,n.back+=g,64&v){e.msg="invalid distance code",n.mode=lr;break}n.offset=E,n.extra=15&v,n.mode=16203;case 16203:if(n.extra){for(O=n.extra;l>>=n.extra,l-=n.extra,n.back+=n.extra}if(n.offset>n.dmax){e.msg="invalid distance too far back",n.mode=lr;break}n.mode=16204;case 16204:if(0===c)break e;if(_=d-c,n.offset>_){if(_=n.offset-_,_>n.whave&&n.sane){e.msg="invalid distance too far back",n.mode=lr;break}_>n.wnext?(_-=n.wnext,f=n.wsize-_):f=n.wnext-_,_>n.length&&(_=n.length),p=n.window}else p=i,f=s-n.offset,_=n.length;_>c&&(_=c),c-=_,n.length-=_;do{i[s++]=p[f++]}while(--_);0===n.length&&(n.mode=cr);break;case 16205:if(0===c)break e;i[s++]=n.length,c--,n.mode=cr;break;case ur:if(n.wrap){for(;l<32;){if(0===a)break e;a--,u|=r[o++]<{if(_r(e))return Xn;let t=e.state;return t.window&&(t.window=null),e.state=null,Wn},inflateGetHeader:(e,t)=>{if(_r(e))return Xn;const n=e.state;return 0==(2&n.wrap)?Xn:(n.head=t,t.done=!1,Wn)},inflateSetDictionary:(e,t)=>{const n=t.length;let r,i,o;return _r(e)?Xn:(r=e.state,0!==r.wrap&&r.mode!==rr?Xn:r.mode===rr&&(i=1,i=pt(i,t,n,0),i!==r.check)?Jn:(o=wr(e,t,n,n),o?(r.mode=16210,$n):(r.havedict=1,Wn)))},inflateInfo:"pako inflate (from Nodeca project)"};var kr=function(){this.text=0,this.time=0,this.xflags=0,this.os=0,this.extra=null,this.extra_len=0,this.name="",this.comment="",this.hcrc=0,this.done=!1};const Tr=Object.prototype.toString,{Z_NO_FLUSH:Cr,Z_FINISH:Or,Z_OK:Ar,Z_STREAM_END:Nr,Z_NEED_DICT:Rr,Z_STREAM_ERROR:Ir,Z_DATA_ERROR:Dr,Z_MEM_ERROR:Lr}=bt;function xr(e){this.options=bn.assign({chunkSize:65536,windowBits:15,to:""},e||{});const t=this.options;t.raw&&t.windowBits>=0&&t.windowBits<16&&(t.windowBits=-t.windowBits,0===t.windowBits&&(t.windowBits=-15)),!(t.windowBits>=0&&t.windowBits<16)||e&&e.windowBits||(t.windowBits+=32),t.windowBits>15&&t.windowBits<48&&0==(15&t.windowBits)&&(t.windowBits|=15),this.err=0,this.msg="",this.ended=!1,this.chunks=[],this.strm=new Sn,this.strm.avail_out=0;let n=Sr.inflateInit2(this.strm,t.windowBits);if(n!==Ar)throw new Error(Et[n]);if(this.header=new kr,Sr.inflateGetHeader(this.strm,this.header),t.dictionary&&("string"==typeof t.dictionary?t.dictionary=wn.string2buf(t.dictionary):"[object ArrayBuffer]"===Tr.call(t.dictionary)&&(t.dictionary=new Uint8Array(t.dictionary)),t.raw&&(n=Sr.inflateSetDictionary(this.strm,t.dictionary),n!==Ar)))throw new Error(Et[n])}function Mr(e,t){const n=new xr(t);if(n.push(e),n.err)throw n.msg||Et[n.err];return n.result}xr.prototype.push=function(e,t){const n=this.strm,r=this.options.chunkSize,i=this.options.dictionary;let o,s,a;if(this.ended)return!1;for(s=t===~~t?t:!0===t?Or:Cr,"[object ArrayBuffer]"===Tr.call(e)?n.input=new Uint8Array(e):n.input=e,n.next_in=0,n.avail_in=n.input.length;;){for(0===n.avail_out&&(n.output=new Uint8Array(r),n.next_out=0,n.avail_out=r),o=Sr.inflate(n,s),o===Rr&&i&&(o=Sr.inflateSetDictionary(n,i),o===Ar?o=Sr.inflate(n,s):o===Dr&&(o=Rr));n.avail_in>0&&o===Nr&&n.state.wrap>0&&0!==e[n.next_in];)Sr.inflateReset(n),o=Sr.inflate(n,s);switch(o){case Ir:case Dr:case Rr:case Lr:return this.onEnd(o),this.ended=!0,!1}if(a=n.avail_out,n.next_out&&(0===n.avail_out||o===Nr))if("string"===this.options.to){let e=wn.utf8border(n.output,n.next_out),t=n.next_out-e,i=wn.buf2string(n.output,e);n.next_out=t,n.avail_out=r-t,t&&n.output.set(n.output.subarray(e,e+t),0),this.onData(i)}else this.onData(n.output.length===n.next_out?n.output:n.output.subarray(0,n.next_out));if(o!==Ar||0!==a){if(o===Nr)return o=Sr.inflateEnd(this.strm),this.onEnd(o),this.ended=!0,!0;if(0===n.avail_in)break}}return!0},xr.prototype.onData=function(e){this.chunks.push(e)},xr.prototype.onEnd=function(e){e===Ar&&("string"===this.options.to?this.result=this.chunks.join(""):this.result=bn.flattenChunks(this.chunks)),this.chunks=[],this.err=e,this.msg=this.strm.msg};var Pr={Inflate:xr,inflate:Mr,inflateRaw:function(e,t){return(t=t||{}).raw=!0,Mr(e,t)},ungzip:Mr,constants:bt};const{Deflate:Ur,deflate:zr,deflateRaw:Fr,gzip:qr}=Pn,{Inflate:Gr,inflate:jr,inflateRaw:Kr,ungzip:Br}=Pr;var Vr,Zr={Deflate:Ur,deflate:zr,deflateRaw:Fr,gzip:qr,Inflate:Gr,inflate:jr,inflateRaw:Kr,ungzip:Br,constants:bt};!function(e){e.CONNECTING="CONNECTING",e.OPEN="OPEN",e.CLOSED="CLOSED"}(Vr||(Vr={}));var Hr,Wr=function(e){function n(t,n){var r=n.sdkState,i=n.dispatcher,o=n.logger,s=e.call(this)||this;return s.lastActive=0,s._iid=t,s._sdkState=r,s._dispatcher=i,s._logger=o,s}return t(n,e),Object.defineProperty(n.prototype,"isOpen",{get:function(){return this.connectionState===Vr.OPEN},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"connectionState",{get:function(){if(this._ws)switch(this._ws.readyState){case 0:return Vr.CONNECTING;case 1:return Vr.OPEN}return Vr.CLOSED},enumerable:!1,configurable:!0}),n.prototype._handleMessage=function(e){var t=this;e.split("\n").forEach((function(e){if(e){var n=Ne.createFromRawMessage(t._iid,e);if(t._logger.debug("receive websocket event",n),"LOGI"===n.code)t.dispatch("message",n);else if("PONG"===n.code)t.dispatch("pong");else if("EXPR"===n.code){if(n.payload){var r=new ke(n.payload);r.expiresIn>=0&&t._dispatcher.dispatch(r)}}else"NOOP"===n.code||t.dispatch("message",n)}}))},n.prototype.connect=function(e){var t=this;this._ws=new WebSocket(e),this._ws.onopen=function(){t._logger.debug("websocket open"),t.dispatch("open")},this._ws.onmessage=function(e){return i(t,void 0,void 0,(function(){var t,n,r=this;return o(this,(function(s){return(null===(n=this._sdkState.websocket)||void 0===n?void 0:n.compression)?e.data instanceof Blob?((t=new FileReader).readAsArrayBuffer(e.data),t.onloadend=function(){return i(r,void 0,void 0,(function(){var e;return o(this,(function(n){switch(n.label){case 0:return[4,(r=t.result,i(void 0,void 0,void 0,(function(){var e;return o(this,(function(t){return e=Zr.ungzip(r),[2,String.fromCharCode.apply(null,e)]}))})))];case 1:return e=n.sent(),this._handleMessage(e),[2]}var r}))}))}):"string"==typeof e.data&&this._handleMessage(e.data):this._handleMessage(e.data),[2]}))}))},this._ws.onerror=function(){t._logger.debug("websocket error"),t.dispatch("error",E.networkError)},this._ws.onclose=function(){t._logger.debug("websocket close"),t.dispatch("close")},this.lastActive=Date.now()},n.prototype.disconnect=function(){var e=this;return new Promise((function(t){e._logger.debug("websocket disconnect"),e._ws&&e.connectionState!==Vr.CLOSED?(e._ws.onopen=Re,e._ws.onmessage=Re,e._ws.onerror=Re,e._ws.onclose=function(){e.dispatch("close"),t()},e._ws.close(),e._ws=void 0):t()}))},n.prototype.send=function(e){if(!this._ws)throw E.connectionClosed;"PING"!==e.code?this.dispatch("ping-refresh"):this._logger.debug("send ping",e),this._ws.send(e.convertToMessage())},n.prototype.error=function(e){this._logger.debug("websocket error",e),this.dispatch("error",e)},n}(W),Qr=function(e){function n(t){var n,r=t.code,i=t.ackRequired,o=t.payload,s=void 0===o?{}:o,a=this;return(a=e.call(this)||this).code=r,a.payload=s,a.requestId=null!==(n=a.payload.req_id)&&void 0!==n?n:Z(),a.ackRequired=i,a.payload.req_id=a.requestId,a}return t(n,e),n.prototype.convertToMessage=function(){return"".concat(this.code).concat(JSON.stringify(this.payload),"\n")},n}(Y),Yr=function(e){function n(t){var n=t.all,r=t.custom_types,i=t.ts,o=e.call(this)||this;return o.all=n,o.customTypes=r,o.ts=i,o}return t(n,e),n}(Y),Xr=function(){var e=this;this.promise=new Promise((function(t,n){e.resolve=t,e.reject=n}))},Jr=function(){function e(e,t){var n=t.auth,r=t.sdkState,i=t.dispatcher,o=t.logger,s=t.useFetchCompat,a=void 0!==s&&s,c=this;this._ackStateMap=new Map,this._sdkState=r,this._dispatcher=i,this._logger=o,this.apiClient=new Ae(e,{auth:n,sdkState:r,dispatcher:i,logger:o,useFetchCompat:a}),this.websocketClient=new Wr(e,{sdkState:r,dispatcher:i,logger:o}),this.websocketClient.on("message",(function(e){if(e.payload.unread_cnt&&c._dispatcher.dispatch(new Yr(e.payload.unread_cnt)),e.requestId){if(c._ackStateMap.has(e.requestId)){var t=c._ackStateMap.get(e.requestId);"EROR"!==e.code?t.resolve(e):t.reject(new E({code:e.payload.code,message:e.payload.message}))}}else c._dispatcher.dispatch(e)})).on("close",(function(){c._ackStateMap.forEach((function(e){e.reject(E.connectionClosed)})),c._ackStateMap.clear()}))}return e.prototype._sendApiRequest=function(e){return i(this,void 0,void 0,(function(){return o(this,(function(t){switch(t.label){case 0:return[4,this.apiClient.send(e)];case 1:return[2,t.sent()]}}))}))},e.prototype._sendWebsocketRequest=function(e){return i(this,void 0,void 0,(function(){var t,n,r,i=this;return o(this,(function(o){if(!this._sdkState.websocket)throw E.connectionRequired;if(t=new Xr,e.ackRequired){r=function(r,o){i._ackStateMap.has(e.requestId)&&(i._ackStateMap.delete(e.requestId),n&&(clearTimeout(n),n=null),r?(i._logger.debug("fail websocket request",r),t.reject(r)):(i._logger.debug("receive websocket ack",e.requestId),t.resolve(o)))};try{n=setTimeout((function(){return r(E.noAckTimeout)}),this._sdkState.websocket.responseTimeout),this._ackStateMap.set(e.requestId,{resolve:function(e){return r(void 0,e)},reject:function(e){return r(e)}}),this.websocketClient.send(e)}catch(e){r(e)}}else try{this.websocketClient.send(e),t.resolve()}catch(e){t.reject(e)}return[2,t.promise]}))}))},e.prototype.send=function(e){return i(this,void 0,void 0,(function(){return o(this,(function(t){switch(t.label){case 0:return e instanceof ye?[4,this._sendApiRequest(e)]:[3,2];case 1:case 3:return[2,t.sent()];case 2:return e instanceof Qr?[4,this._sendWebsocketRequest(e)]:[3,4];case 4:throw E.invalidParameters}}))}))},e.prototype.cancel=function(e){this.apiClient.cancel(e)},e.prototype.cancelAll=function(){this.apiClient.cancelAll()},e}();!function(e){e[e.NONE=0]="NONE",e[e.INITIALIZED=1]="INITIALIZED",e[e.CONNECTING=2]="CONNECTING",e[e.CONNECTED=3]="CONNECTED",e[e.RECONNECTING=4]="RECONNECTING",e[e.INTERNAL_DISCONNECTED=5]="INTERNAL_DISCONNECTED",e[e.EXTERNAL_DISCONNECTED=6]="EXTERNAL_DISCONNECTED",e[e.LOGOUT=7]="LOGOUT"}(Hr||(Hr={}));var $r=function(e){function n(t){var n=t.stateType,r=e.call(this)||this;return r.stateType=n,r}return t(n,e),n}(Y),ei=function(){function e(e,t){var n=t.auth,r=t.sdkState,s=t.dispatcher,a=t.logger,c=t.useFetchCompat,u=void 0!==c&&c,l=this;this._currentConnectionStateType=Hr.INITIALIZED,this._lazyCallQueue=[],this.commandRouter=new Jr(e,{auth:n,sdkState:r,dispatcher:s,logger:a,useFetchCompat:u}),this._auth=n,this._logger=a,this._dispatcher=s,this._dispatcher.on((function(e){if(e instanceof $r){var t=e.stateType;switch(l._currentConnectionStateType=t,t){case Hr.CONNECTED:var n=l._lazyCallQueue;l._lazyCallQueue=[],n.forEach((function(e){return i(l,void 0,void 0,(function(){var t,n,r,i,s;return o(this,(function(o){switch(o.label){case 0:t=e.command,n=e.deferred,r=e.timeout,clearTimeout(r),o.label=1;case 1:return o.trys.push([1,3,,4]),[4,this.send(t)];case 2:return i=o.sent(),n.resolve(i),[3,4];case 3:return s=o.sent(),n.reject(s),[3,4];case 4:return[2]}}))}))}));break;case Hr.INITIALIZED:case Hr.INTERNAL_DISCONNECTED:case Hr.EXTERNAL_DISCONNECTED:case Hr.LOGOUT:n=l._lazyCallQueue;l._lazyCallQueue=[],n.forEach((function(e){return i(l,void 0,void 0,(function(){var t,n;return o(this,(function(r){return t=e.deferred,n=e.timeout,clearTimeout(n),this._auth&&this._auth.hasSession?t.reject(E.connectionClosed):t.reject(E.connectionRequired),[2]}))}))}))}}}))}return Object.defineProperty(e.prototype,"isReady",{get:function(){return this._currentConnectionStateType===Hr.CONNECTED},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"isLazyCallActivated",{get:function(){return this._currentConnectionStateType===Hr.CONNECTING||this._currentConnectionStateType===Hr.RECONNECTING},enumerable:!1,configurable:!0}),e.prototype.send=function(e){return i(this,void 0,void 0,(function(){var t,n,r=this;return o(this,(function(i){switch(i.label){case 0:return e instanceof Qr?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 Xr,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"),E.connectionRequired;case 3:case 7:return[3,9];case 4:return e instanceof ye?this._auth.hasSession?(this._logger.debug("send api request",e),[4,this.commandRouter.send(e)]):[3,6]:[3,8];case 6:if(this.isLazyCallActivated)return this._logger.debug("wait api request",e),t=new Xr,this._lazyCallQueue.push({command:e,deferred:t,timeout:setTimeout((function(){return r.timeout(e.requestId)}),1e4)}),[2,t.promise];throw n=E.connectionRequired,this._logger.debug("fail api request",n),n;case 8:throw E.invalidCommand;case 9:return[2]}}))}))},e.prototype.forceSend=function(e){return i(this,void 0,void 0,(function(){return o(this,(function(t){switch(t.label){case 0:return this._logger.debug("send forced request",e),[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(E.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}(),ti="sendbird@devicetokens",ni=function(){function e(e){var t=e.type,n=e.token;this.type=t,this.token=n}return e.payloadify=function(e){return X(J({type:e.type,token:e.token}))},e}(),ri=function(e){function n(t){var n=t.userId,r=t.authToken,i=t.expiringSession,o=void 0===i||i,s=e.call(this)||this;return s.path="".concat(te,"/").concat(n,"/session_key"),s.method=$.POST,s.params={token:r,expiring_session:!!o},s.requireAuth=!1,s}return t(n,e),n}(ye),ii=function(e){function n(t){var n=t.authToken,r=t.expiringSession,i=void 0===r||r,o=t.requestId,s=void 0===o?"":o;return e.call(this,{code:"LOGI",payload:{token:n,expiring_session:i?1:0,req_id:s},ackRequired:!0})||this}return t(n,e),n}(Qr),oi=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}(we),si=function(e){function n(t,n,r){var i,o=this;return(o=e.call(this,t,"LOGI",r)||this).error=null,o.newKey=null,o.newKey=null!==(i=r.new_key)&&void 0!==i?i:null,o.error=r.error?new E(r.error):null,o}return t(n,e),n}(Ne),ai=function(e){function n(){return null!==e&&e.apply(this,arguments)||this}return t(n,e),n}(Y),ci=function(e){return i(void 0,void 0,void 0,(function(){return o(this,(function(t){return[2,new Promise((function(t){return setTimeout(t,e)}))]}))}))},ui=function(){function e(){}return e.prototype.calcTimeout=function(){return 0},e}(),li=function(e,t,n){return void 0===n&&(n=new ui),i(void 0,void 0,void 0,(function(){var r,i,s,a,c,u;return o(this,(function(o){switch(o.label){case 0:r=0,i=null,s=function(e){return i=null!=e?e:new Error("Halted")},a=function(){r=0},o.label=1;case 1:if(!(-1===t||r=0},n.prototype.createRefreshWebsocketCommand=function(e,t){return new ii({authToken:e,expiringSession:!0,requestId:t})},n.prototype._refreshSessionKeyByWebSocket=function(e){return i(this,void 0,void 0,(function(){var t,n,r,i,s;return o(this,(function(o){switch(o.label){case 0:return t=this.createRefreshWebsocketCommand(e),[4,this._requestQueue.forceSend(t)];case 1:if(n=o.sent(),r=n.as(si),i=r.newKey,s=r.error)throw s;return this.auth.sessionKey=null!=i?i:this.auth.sessionKey,[2]}}))}))},n.prototype._refreshSessionKeyByApi=function(e){return i(this,void 0,void 0,(function(){var t,n=this;return o(this,(function(r){switch(r.label){case 0:return t=new ri({userId:this._sdkState.userId,authToken:e,expiringSession:!0}),[4,li((function(e){return i(n,void 0,void 0,(function(){var n,r,i;return o(this,(function(o){switch(o.label){case 0:return o.trys.push([0,2,,3]),[4,this._requestQueue.forceSend(t)];case 1:return n=o.sent(),r=n.as(oi).key,this.auth.sessionKey=r,[3,3];case 2:if(i=o.sent(),!this._isSessionRelatedError(i))throw i;return e(i),[3,3];case 3:return[2]}}))}))}),3)];case 1:return r.sent(),[2]}}))}))},n.prototype._refreshSessionKey=function(e,t){return void 0===t&&(t=!0),i(this,void 0,void 0,(function(){var n,r,i;return o(this,(function(o){switch(o.label){case 0:if(this._currentConnectionStateType!==Hr.CONNECTED)return[3,10];o.label=1;case 1:return o.trys.push([1,3,,10]),[4,this._refreshSessionKeyByWebSocket(e)];case 2:return o.sent(),this.complete(),[2];case 3:return n=o.sent(),this._isSessionRelatedError(n)&&t?[4,this._receiveNewAuthToken()]:[3,9];case 4:return(i=o.sent())?(this.auth.authToken=i,[4,this._refreshSessionKey(this.auth.authToken,!1)]):[3,6];case 5:return o.sent(),this.complete(),[3,8];case 6:return[4,this.clear()];case 7:o.sent(),this.close(),o.label=8;case 8:return[2];case 9:return[3,10];case 10:return o.trys.push([10,12,,22]),[4,this._refreshSessionKeyByApi(e)];case 11:return o.sent(),this.complete(),[3,22];case 12:return r=o.sent(),this._isSessionRelatedError(r)?t?[4,this._receiveNewAuthToken()]:[3,18]:[3,20];case 13:return(i=o.sent())?(this.auth.authToken=i,[4,this._refreshSessionKeyByApi(this.auth.authToken)]):[3,15];case 14:return o.sent(),this.complete(),[3,17];case 15:return[4,this.clear()];case 16:o.sent(),this.close(),o.label=17;case 17:return[3,19];case 18:throw r;case 19:return[3,21];case 20:throw r;case 21:return[3,22];case 22:return[2]}}))}))},n.prototype._receiveNewAuthToken=function(){var e=this,t=new Xr;return hi((function(){return i(e,void 0,void 0,(function(){var e,n,r=this;return o(this,(function(i){return this._isRefreshingAuthToken=!0,this.auth.clear(),e=null,n=function(){e&&(clearTimeout(e),e=null)},e=setTimeout((function(){r._isRefreshingAuthToken=!1,t.reject()}),1e3*this._sdkState.sessionTokenRefreshTimeout),this.handler.onSessionTokenRequired?this.handler.onSessionTokenRequired((function(e){n(),r._isRefreshingAuthToken&&(r._isRefreshingAuthToken=!1,r.dispatch("refresh-authtoken"),t.resolve(e))}),(function(e){n(),r._isRefreshingAuthToken=!1,t.reject(e)})):t.resolve(null),[2]}))}))})),t.promise},n.prototype._isSessionRelatedError=function(e){return e instanceof E&&(e.isSessionKeyExpiredError||e.isSessionTokenExpiredError||e.isSessionRevokedError)},Object.defineProperty(n.prototype,"isSessionKeyRefreshing",{get:function(){return this._isRefreshingSessionKey},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"isRefreshingAuthToken",{get:function(){return this._isRefreshingAuthToken},enumerable:!1,configurable:!0}),n.prototype.login=function(e){var t;return i(this,void 0,void 0,(function(){var n,r,i,s,a,c,u;return o(this,(function(o){switch(o.label){case 0:return n=e.key,r=e.ekey,i=e.userProfile,s=e.deviceTokenLastDeletedAt,a=void 0===s?0:s,this.auth.sessionKey=n,_i.set(this,r),this._deviceTokenCacheEnabled=null===(t=null==i?void 0:i.appInfo)||void 0===t?void 0:t.deviceTokenCache,c=this._cacheContext.preference,this._deviceTokenCacheEnabled?[4,c.get(ti)]:[3,5];case 1:return!(u=o.sent())||u.lastDeletedAt=0&&this._deviceTokens.splice(n,1)}},n.prototype.unsetDeviceTokens=function(e){this._deviceTokenCacheEnabled&&(this._deviceTokens=e?this._deviceTokens.filter((function(t){return t.type!==e})):[])},n.prototype.setDeviceTokenDeletedAt=function(e){e>0&&(this._deviceTokenLastDeletedAt=e)},n.prototype.saveDeviceToken=function(){return i(this,void 0,void 0,(function(){return o(this,(function(e){switch(e.label){case 0:return this._deviceTokenCacheEnabled?[4,this._cacheContext.preference.set(ti,{tokens:this._deviceTokens,lastDeletedAt:this._deviceTokenLastDeletedAt})]:[3,2];case 1:e.sent(),e.label=2;case 2:return[2]}}))}))},n.prototype.clear=function(){return i(this,void 0,void 0,(function(){return o(this,(function(e){switch(e.label){case 0:return this.currentUser=null,this.auth.clear(),this.close(),_i.delete(this),this._deviceTokens=[],this._deviceTokenLastDeletedAt=0,[4,this.saveDeviceToken()];case 1:return e.sent(),[2]}}))}))},n}(W),pi=function(){function e(){this.type=Hr.NONE,this.name="none"}return e.prototype.run=function(e){return i(this,void 0,void 0,(function(){return o(this,(function(e){return[2]}))}))},e.prototype.onConnect=function(e,t){return i(this,void 0,void 0,(function(){return o(this,(function(e){return[2]}))}))},e.prototype.onReconnect=function(e,t){return t.resetReconnectCount,i(this,void 0,void 0,(function(){return o(this,(function(e){return[2]}))}))},e.prototype.onDisconnect=function(e,t){return t.error,t.autoReconnect,i(this,void 0,void 0,(function(){return o(this,(function(e){return[2]}))}))},e.prototype.onDisconnectWebSocket=function(e){return i(this,void 0,void 0,(function(){return o(this,(function(e){return[2]}))}))},e.prototype.onLogout=function(e){return i(this,void 0,void 0,(function(){return o(this,(function(e){return[2]}))}))},e}(),gi=function(e){function n(){var t=null!==e&&e.apply(this,arguments)||this;return t.type=Hr.LOGOUT,t.name="logout",t}return t(n,e),n.prototype.run=function(e){return i(this,void 0,void 0,(function(){var t,n,r=this;return o(this,(function(s){switch(s.label){case 0:return t=Date.now(),n=e.sdkState.userId,[4,e.logout()];case 1:return s.sent(),[4,e.changeState(new wi,t)];case 2:return s.sent(),hi((function(){return i(r,void 0,void 0,(function(){return o(this,(function(t){return e.connectionHandlers.forEach((function(e){e.onDisconnected&&e.onDisconnected(n)})),[2]}))}))})),[2]}}))}))},n}(pi),vi=function(e){function n(){var t=e.call(this)||this;return t.type=Hr.EXTERNAL_DISCONNECTED,t.name="externaldisconnected",t}return t(n,e),n.prototype.run=function(e){return i(this,void 0,void 0,(function(){return o(this,(function(t){switch(t.label){case 0:return[4,e.disconnect()];case 1:return t.sent(),[2]}}))}))},n.prototype.onConnect=function(e,t){return i(this,void 0,void 0,(function(){var n;return o(this,(function(r){switch(r.label){case 0:return n=Date.now(),[4,e.disconnect()];case 1:return r.sent(),[4,e.changeState(new yi({authToken:t}),n)];case 2:return r.sent(),[2]}}))}))},n.prototype.onReconnect=function(e){return i(this,void 0,void 0,(function(){var t;return o(this,(function(n){switch(n.label){case 0:return t=Date.now(),[4,e.changeState(new bi,t)];case 1:return n.sent(),[2]}}))}))},n.prototype.onLogout=function(e){return i(this,void 0,void 0,(function(){var t;return o(this,(function(n){switch(n.label){case 0:return t=Date.now(),[4,e.changeState(new gi,t)];case 1:return n.sent(),[2]}}))}))},n}(pi),Ei=function(e){function n(t){var n=t.autoReconnect,r=e.call(this)||this;return r.type=Hr.INTERNAL_DISCONNECTED,r.name="internaldisconnected",r._autoReconnect=!1,r._autoReconnect=n,r}return t(n,e),n.prototype.run=function(e){return i(this,void 0,void 0,(function(){var t;return o(this,(function(n){switch(n.label){case 0:return t=Date.now(),[4,e.disconnect()];case 1:return n.sent(),this._autoReconnect?[4,e.changeState(new bi,t)]:[3,3];case 2:n.sent(),n.label=3;case 3:return[2]}}))}))},n.prototype.onConnect=function(e,t){return i(this,void 0,void 0,(function(){var n;return o(this,(function(r){switch(r.label){case 0:return n=Date.now(),[4,e.disconnect()];case 1:return r.sent(),[4,e.changeState(new yi({authToken:t}),n)];case 2:return r.sent(),[2]}}))}))},n.prototype.onReconnect=function(e){return i(this,void 0,void 0,(function(){var t;return o(this,(function(n){switch(n.label){case 0:return t=Date.now(),[4,e.changeState(new bi,t)];case 1:return n.sent(),[2]}}))}))},n.prototype.onDisconnectWebSocket=function(e){return i(this,void 0,void 0,(function(){var t;return o(this,(function(n){switch(n.label){case 0:return t=Date.now(),[4,e.changeState(new vi,t)];case 1:return n.sent(),[2]}}))}))},n.prototype.onLogout=function(e){return i(this,void 0,void 0,(function(){var t;return o(this,(function(n){switch(n.label){case 0:return t=Date.now(),[4,e.changeState(new gi,t)];case 1:return n.sent(),[2]}}))}))},n}(pi),bi=function(e){function n(){var t=null!==e&&e.apply(this,arguments)||this;return t.type=Hr.RECONNECTING,t.name="reconnecting",t._callbacks=[],t}return t(n,e),n.prototype._halt=function(e){this._haltConnect&&(this._haltConnect(e),this._haltConnect=void 0)},n.prototype._flushCallbacks=function(e){this._haltConnect=void 0,this._resetConnect=void 0,this._callbacks.forEach((function(t){return t(e)}))},n.prototype.run=function(e){return i(this,void 0,void 0,(function(){var t,n,r,s,a,c,l=this;return o(this,(function(h){switch(h.label){case 0:t=Date.now(),n=new Xr,this._callbacks.push((function(e){return e?n.reject(e):n.resolve()})),hi((function(){return i(l,void 0,void 0,(function(){return o(this,(function(t){return e.connectionHandlers.forEach((function(e){e.onReconnectStarted&&e.onReconnectStarted()})),[2]}))}))})),h.label=1;case 1:return h.trys.push([1,4,,9]),r=e.sdkState.websocket,s=r.reconnectMaxRetry,a=r.reconnectRetryStrategy,[4,li((function(t,n){return i(l,void 0,void 0,(function(){var r;return o(this,(function(i){switch(i.label){case 0:this._haltConnect=t,this._resetConnect=n,i.label=1;case 1:return i.trys.push([1,3,,4]),[4,e.connect()];case 2:return i.sent(),[3,4];case 3:if(r=i.sent(),e.clearLoginTimer(),r instanceof E&&r.code===u.CONNECTION_CANCELED)return t(r),[2];throw r;case 4:return[2]}}))}))}),s,a)];case 2:return h.sent(),[4,e.changeState(new mi,t)];case 3:return h.sent(),hi((function(){return i(l,void 0,void 0,(function(){return o(this,(function(t){return this._flushCallbacks(),e.connectionHandlers.forEach((function(e){e.onReconnectSucceeded&&e.onReconnectSucceeded()})),[2]}))}))})),[3,9];case 4:return c=h.sent(),v(c)?[3,7]:c instanceof E?c.code===u.CONNECTION_CANCELED?[3,6]:[4,e.changeState(new Ei({autoReconnect:!1}),t)]:[3,6];case 5:h.sent(),h.label=6;case 6:return hi((function(){return i(l,void 0,void 0,(function(){return o(this,(function(t){return this._flushCallbacks(c),e.connectionHandlers.forEach((function(e){e.onReconnectFailed&&e.onReconnectFailed()})),[2]}))}))})),[3,8];case 7:throw c;case 8:return[3,9];case 9:return[2,n.promise]}}))}))},n.prototype.onConnect=function(e,t){return i(this,void 0,void 0,(function(){var n;return o(this,(function(r){return n=new Xr,this._halt(E.connectionCanceled),e.cancelConnectForRetry(),this._callbacks.push((function(){var r=Date.now();e.changeState(new yi({authToken:t}),r).then((function(){n.resolve()})).catch((function(e){n.reject(e)}))})),[2,n.promise]}))}))},n.prototype.onReconnect=function(e,t){var n=t.resetReconnectCount,r=void 0!==n&&n;return i(this,void 0,void 0,(function(){var e;return o(this,(function(t){return e=new Xr,this._resetConnect&&r&&this._resetConnect(),this._callbacks.push((function(t){return t?e.reject(t):e.resolve()})),[2,e.promise]}))}))},n.prototype.onDisconnect=function(e,t){t.error;var n=t.autoReconnect,r=void 0===n||n;return i(this,void 0,void 0,(function(){var t;return o(this,(function(n){switch(n.label){case 0:return t=Date.now(),this._halt(E.connectionCanceled),[4,e.changeState(new Ei({autoReconnect:r}),t)];case 1:return n.sent(),[2]}}))}))},n.prototype.onDisconnectWebSocket=function(e){return i(this,void 0,void 0,(function(){var t;return o(this,(function(n){switch(n.label){case 0:return t=Date.now(),this._halt(E.connectionCanceled),[4,e.changeState(new vi,t)];case 1:return n.sent(),[2]}}))}))},n.prototype.onLogout=function(e){return i(this,void 0,void 0,(function(){var t;return o(this,(function(n){switch(n.label){case 0:return t=Date.now(),this._halt(E.connectionCanceled),[4,e.changeState(new gi,t)];case 1:return n.sent(),[2]}}))}))},n}(pi),mi=function(e){function n(){var t=null!==e&&e.apply(this,arguments)||this;return t.type=Hr.CONNECTED,t.name="connected",t}return t(n,e),n.prototype.onReconnect=function(e){return i(this,void 0,void 0,(function(){var t;return o(this,(function(n){switch(n.label){case 0:return t=Date.now(),[4,e.disconnect()];case 1:return n.sent(),[4,e.changeState(new bi,t)];case 2:return n.sent(),[2]}}))}))},n.prototype.onDisconnect=function(e,t){var n=t.autoReconnect;return i(this,void 0,void 0,(function(){var t;return o(this,(function(r){switch(r.label){case 0:return t=Date.now(),[4,e.changeState(new Ei({autoReconnect:n}),t)];case 1:return r.sent(),[2]}}))}))},n.prototype.onDisconnectWebSocket=function(e){return i(this,void 0,void 0,(function(){var t;return o(this,(function(n){switch(n.label){case 0:return t=Date.now(),[4,e.changeState(new vi,t)];case 1:return n.sent(),[2]}}))}))},n.prototype.onLogout=function(e){return i(this,void 0,void 0,(function(){var t;return o(this,(function(n){switch(n.label){case 0:return t=Date.now(),[4,e.changeState(new gi,t)];case 1:return n.sent(),[2]}}))}))},n}(pi),yi=function(e){function n(t){var n=t.authToken,r=e.call(this)||this;return r.type=Hr.CONNECTING,r.name="connecting",r._authToken="",r._callbacks=[],r._authToken=n,r}return t(n,e),n.prototype._halt=function(e){this._haltConnect&&(this._haltConnect(e),this._haltConnect=void 0)},n.prototype._flushCallbacks=function(e){this._haltConnect=void 0,this._callbacks.forEach((function(t){return t(e)}))},n.prototype.run=function(e){return i(this,void 0,void 0,(function(){var t,n,r,s=this;return o(this,(function(a){switch(a.label){case 0:t=Date.now(),n=new Xr,this._callbacks.push((function(e){return e?n.reject(e):n.resolve()})),a.label=1;case 1:return a.trys.push([1,4,,10]),[4,li((function(t){return i(s,void 0,void 0,(function(){var n;return o(this,(function(r){switch(r.label){case 0:this._haltConnect=t,r.label=1;case 1:return r.trys.push([1,3,,4]),[4,e.connect(this._authToken)];case 2:return r.sent(),[3,4];case 3:if(n=r.sent(),e.clearLoginTimer(),n instanceof E&&n.code===u.CONNECTION_CANCELED)return t(n),[2];throw n;case 4:return[2]}}))}))}),e.sdkState.websocket.connectMaxRetry)];case 2:return a.sent(),[4,e.changeState(new mi,t)];case 3:return a.sent(),hi((function(){return i(s,void 0,void 0,(function(){return o(this,(function(t){return this._flushCallbacks(),e.connectionHandlers.forEach((function(t){t.onConnected&&t.onConnected(e.sdkState.userId)})),[2]}))}))})),[3,10];case 4:return r=a.sent(),v(r)?[3,8]:[4,e.disconnect()];case 5:return a.sent(),r instanceof E?r.code===u.CONNECTION_CANCELED?[3,7]:[4,e.changeState(new wi,t)]:[3,7];case 6:a.sent(),a.label=7;case 7:return hi((function(){return i(s,void 0,void 0,(function(){return o(this,(function(e){return this._flushCallbacks(r),[2]}))}))})),[3,9];case 8:throw r;case 9:return[3,10];case 10:return[2,n.promise]}}))}))},n.prototype.onConnect=function(e){return i(this,void 0,void 0,(function(){var e;return o(this,(function(t){return e=new Xr,this._callbacks.push((function(t){return t?e.reject(t):e.resolve()})),[2,e.promise]}))}))},n.prototype.onDisconnect=function(e,t){var n=t.error,r=void 0===n?null:n,s=t.autoReconnect,a=void 0!==s&&s;return i(this,void 0,void 0,(function(){var t;return o(this,(function(n){switch(n.label){case 0:return t=Date.now(),this._halt(null!=r?r:E.connectionCanceled),e.hasSession?[4,e.changeState(new Ei({autoReconnect:a}),t)]:[3,2];case 1:return n.sent(),[3,4];case 2:return[4,e.changeState(new gi,t)];case 3:n.sent(),n.label=4;case 4:return[2]}}))}))},n.prototype.onDisconnectWebSocket=function(e){return i(this,void 0,void 0,(function(){var t;return o(this,(function(n){switch(n.label){case 0:return t=Date.now(),this._halt(E.connectionCanceled),e.hasSession?[4,e.changeState(new vi,t)]:[3,2];case 1:return n.sent(),[3,4];case 2:return[4,e.changeState(new gi,t)];case 3:n.sent(),n.label=4;case 4:return[2]}}))}))},n.prototype.onLogout=function(e){return i(this,void 0,void 0,(function(){var t;return o(this,(function(n){switch(n.label){case 0:return t=Date.now(),this._halt(E.connectionCanceled),[4,e.changeState(new gi,t)];case 1:return n.sent(),[2]}}))}))},n}(pi),wi=function(e){function n(){var t=null!==e&&e.apply(this,arguments)||this;return t.type=Hr.INITIALIZED,t.name="initialized",t}return t(n,e),n.prototype.onConnect=function(e,t){return i(this,void 0,void 0,(function(){var n;return o(this,(function(r){switch(r.label){case 0:return n=Date.now(),[4,e.changeState(new yi({authToken:t}),n)];case 1:return r.sent(),[2]}}))}))},n}(pi),Si=function(e){function n(){return e.call(this,{code:"PING",payload:{id:Date.now(),active:1},ackRequired:!1})||this}return t(n,e),n}(Qr),ki=function(){function e(e){var t=e.pingDelegate,n=e.sdkState,r=e.logger;this.pingDelegate=t,this.sdkState=n,this._logger=r}return Object.defineProperty(e.prototype,"isWaiting",{get:function(){return!!this._pingTimeoutTimer},enumerable:!1,configurable:!0}),e.prototype.ping=function(){var e,t=this;if(!this.sdkState.websocket)throw E.connectionRequired;var n=new Si;try{var r=null!==(e=this.sdkState.websocket.pongTimeout)&&void 0!==e?e:5e3;this._pingTimeoutTimer=setTimeout((function(){t._logger.debug("pinger.ping() timeout"),t.pingDelegate.error()}),r),this.pingDelegate.send(n),this._logger.debug("pinger.ping()")}catch(e){this._logger.debug("pinger.ping() error",e),this._pingTimeoutTimer&&(clearTimeout(this._pingTimeoutTimer),this._pingTimeoutTimer=void 0),this.pingDelegate.error()}return n},e.prototype.pong=function(){this._logger.debug("pinger.pong()"),this._pingTimeoutTimer&&(clearTimeout(this._pingTimeoutTimer),this._pingTimeoutTimer=void 0)},e.prototype.refreshTimer=function(){var e,t=this;if(!this.sdkState.websocket)throw E.connectionRequired;this._logger.debug("pinger.refreshTimer()");var n=null!==(e=this.sdkState.websocket.pingInterval)&&void 0!==e?e:15e3;this.stop(),this._pingTimer=setInterval((function(){t.ping()}),n)},e.prototype.start=function(){this._logger.debug("pinger.start()"),this.refreshTimer(),this.ping()},e.prototype.stop=function(){this._logger.debug("pinger.stop()"),this._pingTimer&&(clearInterval(this._pingTimer),this._pingTimer=void 0),this._pingTimeoutTimer&&(clearTimeout(this._pingTimeoutTimer),this._pingTimeoutTimer=void 0)},e}(),Ti=function(){function e(e){var t;this.lastUpdatedAt=null!==(t=e.last_updated_at)&&void 0!==t?t:0}return e.payloadify=function(e){return X(J({last_updated_at:e.lastUpdatedAt}))},e}(),Ci=1048576,Oi=5,Ai=function(){function e(e){var t,n,r,i,o;void 0===e&&(e={}),this.emojiHash=e.emoji_hash||"",this.uploadSizeLimit=e.file_upload_size_limit?e.file_upload_size_limit*Ci:Number.MAX_SAFE_INTEGER,this.useReaction=!!e.use_reaction,this.applicationAttributes=null!==(t=e.application_attributes)&&void 0!==t?t:[],this.premiumFeatureList=null!==(n=e.premium_feature_list)&&void 0!==n?n:[],this.deviceTokenCache=this.applicationAttributes.includes("sdk_device_token_cache"),this.enabledChannelMemberShipHistory=this.applicationAttributes.includes("channel_membership_history"),this.multipleFilesMessageFileCountLimit=null!==(r=e.multiple_file_send_max_size)&&void 0!==r?r:5,this.allowSdkStatsUpload=null===(i=e.allow_sdk_log_ingestion)||void 0===i||i,this.uikitConfigInfo=new Ti(null!==(o=e.uikit_config)&&void 0!==o?o:{})}return e.payloadify=function(e){return X(J({emoji_hash:e.emojiHash,file_upload_size_limit:e.uploadSizeLimit/Ci,application_attributes:e.applicationAttributes,premium_feature_list:e.premiumFeatureList,use_reaction:e.useReaction,allow_sdk_log_ingestion:e.allowSdkStatsUpload,uikit_config:e.uikitConfigInfo?Ti.payloadify(e.uikitConfigInfo):null}))},e}(),Ni=function(){function e(e){this._iid="",this._iid=e}return e.payloadify=function(e){return{}},e}(),Ri=function(e){function n(t){var n=t.userId,r=t.metadata,i=e.call(this)||this;return i.method=$.POST,i.path="".concat(te,"/").concat(n,"/metadata"),i.params={metadata:r},i}return t(n,e),n}(ye),Ii=function(e){function n(t,n){var r=e.call(this,t,n)||this;return r.metaData=n,r}return t(n,e),n}(we),Di=function(e){function n(t){var n=t.userId,r=t.metadata,i=t.upsert,o=e.call(this)||this;return o.method=$.PUT,o.path="".concat(te,"/").concat(n,"/metadata"),o.params={metadata:r,upsert:i},o}return t(n,e),n}(ye),Li=function(e){function n(t,n){var r=e.call(this,t,n)||this;return r.metadata=n,r}return t(n,e),n}(we),xi=function(e){function n(t){var n=t.userId,r=t.metadataKey,i=e.call(this)||this;return i.method=$.DELETE,i.path="".concat(te,"/").concat(n,"/metadata/").concat(r),i}return t(n,e),n}(ye);!function(e){function n(){return null!==e&&e.apply(this,arguments)||this}t(n,e)}(we);var Mi=function(e){function n(t){var n=t.userId,r=e.call(this)||this;return r.method=$.DELETE,r.path="".concat(te,"/").concat(n,"/metadata"),r}return t(n,e),n}(ye);!function(e){function n(){return null!==e&&e.apply(this,arguments)||this}t(n,e)}(we);var Pi,Ui=function(e,t){var n=JSON.parse(JSON.stringify(e));return n._iid&&delete n._iid,t&&t(n),n},zi=function(e,t){var n=JSON.parse(JSON.stringify(e));return t&&t(n),n},Fi=function(e){return{do:function(t){e||t()},throw:function(t){if(!e)throw t}}};!function(e){e.ONLINE="online",e.OFFLINE="offline",e.NON_AVAILABLE="nonavailable"}(Pi||(Pi={}));var qi,Gi=function(e){function r(t,n){var r,i,o,s,u,l,h,d,_,f,p,g,v=this;return(v=e.call(this,t)||this).userId=null!==(i=null!==(r=n.guest_id)&&void 0!==r?r:n.user_id)&&void 0!==i?i:"",v.nickname=null!==(s=null!==(o=n.nickname)&&void 0!==o?o:n.name)&&void 0!==s?s:"",v.plainProfileUrl=null!==(l=null!==(u=n.profile_url)&&void 0!==u?u:n.image)&&void 0!==l?l:"",v.requireAuth=null!==(h=n.require_auth_for_profile_image)&&void 0!==h&&h,v.metaData=null!==(d=n.metadata)&&void 0!==d?d:{},v.connectionStatus=Pi.NON_AVAILABLE,S(Pi,n.is_online)?v.connectionStatus=n.is_online:w("boolean",n.is_online)&&(v.connectionStatus=n.is_online?Pi.ONLINE:Pi.OFFLINE),v.isActive=null===(_=n.is_active)||void 0===_||_,v.lastSeenAt=null!==(f=n.last_seen_at)&&void 0!==f?f:null,v.preferredLanguages=n.preferred_languages?c([],a(n.preferred_languages),!1):null,v.friendDiscoveryKey=null!==(p=n.friend_discovery_key)&&void 0!==p?p:null,v.friendName=null!==(g=n.friend_name)&&void 0!==g?g:null,v}return t(r,e),r.payloadify=function(t){return X(J(n(n({},e.payloadify.call(this,t)),{user_id:t.userId,nickname:t.nickname,profile_url:t.plainProfileUrl,require_auth_for_profile_image:t.requireAuth,metadata:t.metaData,is_online:t.connectionStatus,is_active:t.isActive,last_seen_at:t.lastSeenAt,preferred_languages:t.preferredLanguages,friend_discovery_key:t.friendDiscoveryKey,friend_name:t.friendName})))},Object.defineProperty(r.prototype,"profileUrl",{get:function(){var e=no.of(this._iid).sessionManager;return this.requireAuth?"".concat(this.plainProfileUrl,"?auth=").concat(e.ekey):this.plainProfileUrl},enumerable:!1,configurable:!0}),r.prototype.serialize=function(){return Ui(this)},r.prototype._isValidMetaData=function(e){return!Array.isArray(e)&&Object.keys(e).length>0&&Object.keys(e).map((function(t){return e[t]})).every((function(e){return w("string",e)}))},r.prototype._applyMetaData=function(e,t){var n=this;void 0===t&&(t=!1),Object.keys(e).forEach((function(r){t?delete n.metaData[r]:n.metaData[r]=e[r]}))},r.prototype.createMetaData=function(e){return i(this,void 0,void 0,(function(){var t,n,r,i,s,a;return o(this,(function(o){switch(o.label){case 0:return Fi(this._isValidMetaData(e)).throw(E.invalidParameters),t=no.of(this._iid),n=t.sdkState,r=t.requestQueue,i=new Ri({userId:n.userId,metadata:e}),[4,r.send(i)];case 1:return s=o.sent(),a=s.as(Ii).metaData,this._applyMetaData(a),[2,this.metaData]}}))}))},r.prototype.updateMetaData=function(e,t){return void 0===t&&(t=!1),i(this,void 0,void 0,(function(){var n,r,i,s,a,c;return o(this,(function(o){switch(o.label){case 0:return Fi(this._isValidMetaData(e)).throw(E.invalidParameters),n=no.of(this._iid),r=n.sdkState,i=n.requestQueue,s=new Di({userId:r.userId,metadata:e,upsert:t}),[4,i.send(s)];case 1:return a=o.sent(),c=a.as(Li).metadata,this._applyMetaData(c),[2,this.metaData]}}))}))},r.prototype.deleteMetaData=function(e){return i(this,void 0,void 0,(function(){var t,n,r,i,s;return o(this,(function(o){switch(o.label){case 0:return Fi(w("string",e)).throw(E.invalidParameters),t=no.of(this._iid),n=t.sdkState,r=t.requestQueue,i=new xi({userId:n.userId,metadataKey:e}),[4,r.send(i)];case 1:return o.sent(),this._applyMetaData(((s={})[e]=!0,s),!0),[2,this.metaData]}}))}))},r.prototype.deleteAllMetaData=function(){return i(this,void 0,void 0,(function(){var e,t,n,r;return o(this,(function(i){switch(i.label){case 0:return e=no.of(this._iid),t=e.sdkState,n=e.requestQueue,r=new Mi({userId:t.userId}),[4,n.send(r)];case 1:return i.sent(),this.metaData={},[2]}}))}))},r}(Ni),ji=function(e){function n(t){var n=t.userProfile,r=e.call(this)||this;return r.userProfile=n,r}return t(n,e),n}(Y),Ki=function(){function e(e,t){var n,r,i,o,s,a,c,u,l,h,d,_,f,p;this._iid=e,this.appInfo=new Ai(t),this.user=new Gi(e,t),this.connectedAt=null!==(n=t.login_ts)&&void 0!==n?n:0,this.firstConnectedAt=0,this.pingInterval=null!==(r=t.ping_interval)&&void 0!==r?r:15e3,this.pongTimeout=null!==(i=t.pong_timeout)&&void 0!==i?i:5e3,this.reconnectInterval=null!==(s=null===(o=t.reconnect)||void 0===o?void 0:o.interval)&&void 0!==s?s:3e3,this.reconnectMaxInterval=null!==(c=null===(a=t.reconnect)||void 0===a?void 0:a.max_interval)&&void 0!==c?c:6e4,this.reconnectRetryCount=null!==(l=null===(u=t.reconnect)||void 0===u?void 0:u.retry_cnt)&&void 0!==l?l:5,this.reconnectIntervalMultiple=null!==(d=null===(h=t.reconnect)||void 0===h?void 0:h.mul)&&void 0!==d?d:2,this.maxUnreadCountOnSuperGroup=null!==(_=t.max_unread_cnt_on_super_group)&&void 0!==_?_:100,this.profileImageEncryption=!!t.profile_image_encryption,this.concurrentCallLimit=null!==(f=t.concurrent_call_limit)&&void 0!==f?f:5,this.backOffDelay=null!==(p=t.back_off_delay)&&void 0!==p?p:100}return e.payloadify=function(e){return X(J(n(n(n({},Gi.payloadify(e.user)),Ai.payloadify(e.appInfo)),{login_ts:e.connectedAt,ping_interval:e.pingInterval,pong_timeout:e.pongTimeout,reconnect:{interval:e.reconnectInterval,max_interval:e.reconnectMaxInterval,retry_cnt:e.reconnectRetryCount,mul:e.reconnectIntervalMultiple},max_unread_cnt_on_super_group:e.maxUnreadCountOnSuperGroup,profile_image_encryption:e.profileImageEncryption,concurrent_call_limit:e.concurrentCallLimit,back_off_delay:e.backOffDelay})))},e.prototype.apply=function(){var e=this.reconnectInterval,t=this.reconnectMaxInterval,n=this.reconnectIntervalMultiple,r=no.of(this._iid);r.sdkState.websocket&&(r.sdkState.websocket.pingInterval=1e3*this.pingInterval,r.sdkState.websocket.pongTimeout=1e3*this.pongTimeout,r.sdkState.websocket.reconnectMaxRetry=this.reconnectRetryCount,r.sdkState.websocket.reconnectRetryStrategy={calcTimeout:function(r){return r>0?1e3*Math.min(e*Math.pow(n,r-1),t):10}}),r.appInfo=this.appInfo,r.sessionManager.currentUser=this.user,r.connectedAt=this.connectedAt,this.firstConnectedAt||(r.firstConnectedAt=this.connectedAt),r.maxSuperGroupChannelUnreadCount=this.maxUnreadCountOnSuperGroup,r.concurrentCallLimit=this.concurrentCallLimit,r.backOffDelay=this.backOffDelay,r.dispatcher.dispatch(new ji({userProfile:this}))},e}(),Bi=function(e){function r(t,n,r){var i,o,s,a=this;return(a=e.call(this,t,n,r)||this).error=null,a.userProfile=new Ki(t,r),a.deviceTokenLastDeletedAt=null!==(i=r.device_token_last_deleted_at)&&void 0!==i?i:0,a.key=null!==(o=r.key)&&void 0!==o?o:"",a.ekey=null!==(s=r.ekey)&&void 0!==s?s:"",a.error=r.error?new E(r):null,a}return t(r,e),r.asError=function(e){return new r("","LOGI",n({user_id:"",error:!0},e))},r.prototype.applyTo=function(e){return i(this,void 0,void 0,(function(){var t;return o(this,(function(n){switch(n.label){case 0:return this.error?[3,4]:(t=no.of(e))?[4,t.sessionManager.login(this)]:[3,2];case 1:return n.sent(),this.userProfile.apply(),[3,3];case 2:throw E.lostInstance;case 3:return[3,5];case 4:throw this.error;case 5:return[2]}}))}))},r}(Ne),Vi=function(e){function r(t){var r=t.request,i=void 0===r||r,o=t.features,s=void 0===o?{}:o,a=t.options,c=void 0===a?{}:a,u=e.call(this)||this;return u.request=i,u.features=n({localCache:!0},s),u.options=n({ingestion:!0},c),u}return t(r,e),r}(Y),Zi=function(e){function n(t,n){var r,i=n.sdkState,o=n.cacheContext,s=n.connectionHandlers,a=n.sessionManager,c=n.websocketClient,u=n.dispatcher,l=n.logger,h=n.entryState,d=void 0===h?new wi:h,_=this;return(_=e.call(this)||this)._stateUpdatedAt=0,_._connectingAt=0,_._connectionRequestQueue=[],_._iid=t,_.sdkState=i,_.cacheContext=o,_.connectionHandlers=s,_._sessionManager=a,_._websocketClient=c,_._dispatcher=u,_._logger=l,_._currentState=d,(null===(r=_.sdkState.websocket)||void 0===r?void 0:r.pingerDisabled)||(_._pinger=new ki({pingDelegate:{send:function(e){return _._websocketClient.send(e)},error:function(e){return _._websocketClient.error(e)}},sdkState:_.sdkState,logger:l})),_._websocketClient.on("open",(function(){_._tryResolveConnectionRequest()})).on("message",(function(e){if("LOGI"===e.code)_.clearLoginTimer(),_._dispatcher.dispatch(e.as(Bi))})).on("ping-refresh",(function(){var e;return null===(e=_._pinger)||void 0===e?void 0:e.refreshTimer()})).on("pong",(function(){var e;return null===(e=_._pinger)||void 0===e?void 0:e.pong()})).on("error",(function(){var e;return null===(e=_._pinger)||void 0===e?void 0:e.stop()})).on("close",(function(){_._logiProcessingTimer=setTimeout((function(){_._logiProcessingTimer=void 0,_._unresolvedLogi||_._rejectConnectionRequest(E.networkError)}),500)})),_._dispatcher.on((function(e){e instanceof Bi&&(_._unresolvedLogi=e,_._tryResolveConnectionRequest())})),_}return t(n,e),Object.defineProperty(n.prototype,"currentState",{get:function(){return this._currentState},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"hasSession",{get:function(){return this._sessionManager.auth.hasSession},enumerable:!1,configurable:!0}),n.prototype.changeState=function(e,t){return i(this,void 0,void 0,(function(){return o(this,(function(n){switch(n.label){case 0:return t>=this._stateUpdatedAt?(this._currentState=e,this._stateUpdatedAt=t,this._dispatcher.dispatch(new $r({stateType:e.type})),this._logger.debug("connection state changes to ".concat(e.name)),[4,this._currentState.run(this)]):[3,2];case 1:return n.sent(),[2,!0];case 2:return[2,!1]}}))}))},n.prototype._tryResolveConnectionRequest=function(){var e;return i(this,void 0,void 0,(function(){var t,n;return o(this,(function(r){switch(r.label){case 0:return t=this._unresolvedLogi,this._websocketClient.isOpen&&t?(this._unresolvedLogi=void 0,t.error?[3,2]:[4,t.applyTo(this._iid)]):[3,3];case 1:return r.sent(),n=t.userProfile,this._enableStatLog({request:n.appInfo.applicationAttributes.includes("allow_sdk_request_log_publish"),features:{localCache:n.appInfo.applicationAttributes.includes("allow_sdk_feature_local_cache_log_publish")},options:{ingestion:n.appInfo.allowSdkStatsUpload}}),this._statLogConnection(),null===(e=this._pinger)||void 0===e||e.start(),this._connectionRequestQueue.forEach((function(e){return e.resolve()})),this._connectionRequestQueue=[],this.sdkState.appState="foreground",[3,3];case 2:this._sessionManager.auth.authToken=void 0,(t.error.isSessionKeyExpiredError||t.error.isSessionTokenExpiredError)&&this._dispatcher.dispatch(new ke({reason:t.error.code})),this._rejectConnectionRequest(t.error),r.label=3;case 3:return[2]}}))}))},n.prototype._rejectConnectionRequest=function(e){var t;if(null===(t=this._pinger)||void 0===t||t.stop(),this.clearLoginTimer(),this._connectionRequestQueue.length>0){var n=this._connectionRequestQueue;this._connectionRequestQueue=[],n.forEach((function(t){return t.reject(e)})),this._statLogConnection(e)}},n.prototype._url=function(e){var t,n,r;void 0===e&&(e="");var i=this.sdkState,o=i.appId,s=i.appVersion,a=i.userId;i.extensions;var c=this.cacheContext.localCacheEnabled,u=this._sessionManager.auth,l=null===(t=this.sdkState.websocket)||void 0===t?void 0:t.compression,d=null!==(n=this.sdkState.extensions)&&void 0!==n?n:{},_=!!d.sb_uikit,f=d.sb_syncmanager?"s".concat(d.sb_syncmanager):"",p=d.sb_uikit?"u".concat(d.sb_uikit):"",g="JS/c".concat(h.SDK_VERSION,"/").concat(f,"/").concat(p);return"".concat(null===(r=this.sdkState.websocket)||void 0===r?void 0:r.host,"/?p=JS&pv=").concat(encodeURIComponent(h.OS_VERSION),"&sv=").concat(encodeURIComponent(h.SDK_VERSION),"&ai=").concat(o).concat(s?"&av=".concat(s):"").concat(u.hasSession?"&key=".concat(encodeURIComponent(u.sessionKey)):"&user_id=".concat(encodeURIComponent(a),"&access_token=").concat(encodeURIComponent(e)),"&pmce=").concat(l?1:0,"&active=1&device_token_types=").concat(encodeURIComponent(["gcm","huawei","apns"].join(",")),"&SB-User-Agent=").concat(g,"&Request-Sent-Timestamp=").concat(Date.now().toString(),"&include_extra_data=").concat(encodeURIComponent(String(["premium_feature_list","file_upload_size_limit","application_attributes","emoji_hash","multiple_file_send_max_size"]))).concat(this._sessionManager.handler?"&expiring_session=1":"","&use_local_cache=").concat(c?1:0,"&include_poll_details=1").concat(_?"&uikit_config=1":"")},n.prototype._enableStatLog=function(e){var t=e.request,n=e.features,r=e.options,i=void 0===r?{}:r;this._dispatcher.dispatch(new Vi({request:t,features:n,options:i}))},n.prototype._statLogConnection=function(e){var t;this._dispatcher.dispatch(new Te(new Ce({type:me.WEBSOCKET_CONNECT,data:{host_url:null===(t=this.sdkState.websocket)||void 0===t?void 0:t.host,success:!e,latency:Date.now()-this._connectingAt,error_code:null==e?void 0:e.code,error_description:null==e?void 0:e.message}})))},n.prototype.connect=function(e){var t;return void 0===e&&(e=""),i(this,void 0,void 0,(function(){var n,r,i=this;return o(this,(function(o){return this._logiProcessingTimer&&(clearTimeout(this._logiProcessingTimer),this._logiProcessingTimer=void 0,this._rejectConnectionRequest(E.connectionCanceled)),n=this._url(e),r=new Xr,this._connectionRequestQueue.push(r),1===this._connectionRequestQueue.length&&(this._connectingAt=Date.now(),this._loginTimer=setTimeout((function(){i._loginTimer=void 0,i._rejectConnectionRequest(E.loginTimeout)}),null===(t=this.sdkState.websocket)||void 0===t?void 0:t.responseTimeout),e&&(this._sessionManager.auth.authToken=e),this._websocketClient.connect(n)),[2,r.promise]}))}))},n.prototype.cancelConnectForRetry=function(){this._dispatcher.dispatch(Bi.asError(E.connectionRenew))},n.prototype.disconnect=function(){return i(this,void 0,void 0,(function(){return o(this,(function(e){switch(e.label){case 0:return[4,this._websocketClient.disconnect()];case 1:return e.sent(),[2]}}))}))},n.prototype.logout=function(){return i(this,void 0,void 0,(function(){return o(this,(function(e){switch(e.label){case 0:return this.sdkState.userId=void 0,this._unresolvedLogi=void 0,[4,this._sessionManager.clear()];case 1:return e.sent(),[4,this.disconnect()];case 2:return e.sent(),[2]}}))}))},n.prototype.clearLoginTimer=function(){this._loginTimer&&(clearTimeout(this._loginTimer),this._loginTimer=void 0)},n}(W),Hi=function(){function e(e,t){var n=t.sdkState,r=t.cacheContext,i=t.connectionHandlers,o=t.sessionManager,s=t.websocketClient,a=t.dispatcher,c=t.logger,u=t.disableWebSocketCloseEventHandling,l=void 0!==u&&u;this._disableWebSocketCloseEventHandling=!1,this._externalCalledWebSocketClose=!1,this._logger=c,this._disableWebSocketCloseEventHandling=l,this._context=new Zi(e,{sdkState:n,cacheContext:r,connectionHandlers:i,sessionManager:o,websocketClient:s,dispatcher:a,logger:c}),this._sdkState=n,this._sessionManager=o,this._websocketClient=s}return e.prototype._registerEventDispatcher=function(){var e=this;this._disableWebSocketCloseEventHandling||(this._clearEventDispatcher(),this._sessionEventDispatcherContext=this._sessionManager.on("refresh-authtoken",(function(){e.isConnected||(e._logger.debug("try reconnect by session token refresh"),e.reconnect())})).on("refresh",(function(){e.isConnecting||e.isConnected||(e._logger.debug("try reconnect by session key refresh"),e.reconnect())})),this._websocketEventDispatcherContext=this._websocketClient.on("close",(function(){"foreground"!==e._sdkState.appState||e._externalCalledWebSocketClose||e._sessionManager.isRefreshingAuthToken||(e._logger.debug("try reconnect by websocket connection closed"),e.reconnect())})))},e.prototype._clearEventDispatcher=function(){this._sessionEventDispatcherContext&&(this._sessionEventDispatcherContext.close(),this._sessionEventDispatcherContext=void 0),this._websocketEventDispatcherContext&&(this._websocketEventDispatcherContext.close(),this._websocketEventDispatcherContext=void 0)},Object.defineProperty(e.prototype,"isConnected",{get:function(){return this._context.currentState.type===Hr.CONNECTED},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"isConnecting",{get:function(){var e=this._context.currentState;return e.type===Hr.CONNECTING||e.type===Hr.RECONNECTING},enumerable:!1,configurable:!0}),e.prototype.connect=function(e){return i(this,void 0,void 0,(function(){var t;return o(this,(function(n){switch(n.label){case 0:return t=this._context.currentState,this._externalCalledWebSocketClose=!1,[4,t.onConnect(this._context,e)];case 1:return n.sent(),this._registerEventDispatcher(),[2]}}))}))},e.prototype.reconnect=function(){return i(this,void 0,void 0,(function(){var e;return o(this,(function(t){switch(t.label){case 0:return e=this._context.currentState,this._externalCalledWebSocketClose=!1,[4,e.onReconnect(this._context,{})];case 1:return t.sent(),[2]}}))}))},e.prototype.resetAndReconnect=function(){return i(this,void 0,void 0,(function(){var e;return o(this,(function(t){switch(t.label){case 0:return e=this._context.currentState,this._externalCalledWebSocketClose=!1,[4,e.onReconnect(this._context,{resetReconnectCount:!0})];case 1:return t.sent(),[2]}}))}))},e.prototype.background=function(){return i(this,void 0,void 0,(function(){var e;return o(this,(function(t){switch(t.label){case 0:return e=this._context.currentState,this._externalCalledWebSocketClose=!0,[4,e.onDisconnect(this._context,{autoReconnect:!1})];case 1:return t.sent(),[2]}}))}))},e.prototype.disconnect=function(e){return i(this,void 0,void 0,(function(){return o(this,(function(t){switch(t.label){case 0:return[4,this._context.currentState.onDisconnect(this._context,{error:e,autoReconnect:!0})];case 1:return t.sent(),[2]}}))}))},e.prototype.disconnectWebSocket=function(){return i(this,void 0,void 0,(function(){var e;return o(this,(function(t){switch(t.label){case 0:return e=this._context.currentState,this._externalCalledWebSocketClose=!0,[4,e.onDisconnectWebSocket(this._context)];case 1:return t.sent(),[2]}}))}))},e.prototype.logout=function(){return i(this,void 0,void 0,(function(){var e;return o(this,(function(t){switch(t.label){case 0:return e=this._context.currentState,this._clearEventDispatcher(),[4,e.onLogout(this._context)];case 1:return t.sent(),[2]}}))}))},e}(),Wi=function(e){function n(t){var n,r,i,o,s=t.type,a=t.data,c=t.ts,u=void 0===c?Date.now():c,l=e.call(this,{type:s,data:a,ts:u})||this;return l.date=new Date(u),l.key="".concat((n=l.date,r=n.getFullYear(),i=String(n.getMonth()+1).padStart(2,"0"),o=String(n.getDate()).padStart(2,"0"),"".concat(r).concat(i).concat(o)),"_").concat(s),l}return t(n,e),n}(Ce),Qi=function(e){function n(t){var n=t.deviceId,r=t.statLogs,i=e.call(this)||this;return i.method=$.POST,i.path="".concat(fe),i.params={device_id:n,log_entries:r.map((function(e){return Ce.payloadify(e)}))},i}return t(n,e),n}(ye),Yi=function(e,t){var n,r;if(null!==e&&null!==t){var i=Object.keys(e),o=Object.keys(t),u=c([],a(new Set(c(c([],a(i),!1),a(o),!1))),!1),l={};try{for(var h=s(u),d=h.next();!d.done;d=h.next()){var _=d.value,f=typeof e[_],p=typeof t[_];"undefined"===f?l[_]=t[_]:"undefined"===p?l[_]=e[_]:f!==p?l[_]=t[_]:"object"===f&&e[_]&&t[_]?l[_]=Yi(e[_],t[_]):l[_]=t[_]}}catch(e){n={error:e}}finally{try{d&&!d.done&&(r=h.return)&&r.call(h)}finally{if(n)throw n.error}}return l}return t};!function(e){e[e.PENDING=0]="PENDING",e[e.COLLECT_ONLY=1]="COLLECT_ONLY",e[e.ENABLED=2]="ENABLED",e[e.DISABLED=3]="DISABLED"}(qi||(qi={}));var Xi,Ji=function(e){function n(t){var n=t.cacheContext,r=t.requestQueue,i=t.dispatcher,o=t.baseLimit,s=void 0===o?100:o,a=t.maxLimit,c=void 0===a?1e3:a,u=t.minLimit,l=void 0===u?10:u,h=e.call(this)||this;return h.queue=[],h.enabledState=qi.PENDING,h.isFlushing=!1,h.generation=1,h.lastFlushedAt=0,h._collectRequestStat=!0,h._collectFeatureLocalCacheStat=!0,h.deviceId=Z(),h.cacheContext=n,h.requestQueue=r,h.dispatcher=i,h.baseLimit=s,h.limit=s,h.maxLimit=c,h.minLimit=l,h}return t(n,e),Object.defineProperty(n.prototype,"isEnabled",{get:function(){return this.enabledState===qi.ENABLED},enumerable:!1,configurable:!0}),n.prototype._arrangeStat=function(){var e=[];this._collectRequestStat&&e.push.apply(e,c([],a(this.queue.filter((function(e){return e.type===me.API_RESULT||e.type===me.WEBSOCKET_CONNECT}))),!1)),this._collectFeatureLocalCacheStat&&e.push.apply(e,c([],a(this.queue.filter((function(e){return e.type===me.FEATURE_LOCALCACHE}))),!1)),this.queue=e},n.prototype._save=function(){return i(this,void 0,void 0,(function(){return o(this,(function(e){switch(e.label){case 0:return this.enabledState!==qi.ENABLED?[3,2]:[4,this.cacheContext.preference.set(this.key,{deviceId:this.deviceId,statLogs:this.queue.map((function(e){return Ce.payloadify(e)})),generation:this.generation++,lastFlushedAt:this.lastFlushedAt})];case 1:e.sent(),this.dispatch("save",c([],a(this.queue),!1)),e.label=2;case 2:return[2]}}))}))},n.prototype._flush=function(){return i(this,void 0,void 0,(function(){var e,t,n,r,i;return o(this,(function(o){switch(o.label){case 0:if(!this.isEnabled)return[3,10];if(this.isFlushing)return[3,10];this.isFlushing=!0,o.label=1;case 1:return o.trys.push([1,5,9,10]),this._arrangeStat(),e=this.queue.filter((function(e){if(e instanceof Wi){var t=new Date,n=a([e.date.getFullYear(),t.getFullYear()],2),r=n[0],i=n[1];if(r0?(r=new Qi({deviceId:this.deviceId,statLogs:n}),[4,this.requestQueue.send(r)]):[3,4];case 2:return o.sent(),this.dispatch("flush",n),this.queue=c(c([],a(e),!1),a(t),!1).slice(n.length),[4,this._save()];case 3:o.sent(),o.label=4;case 4:return this.limit=this.baseLimit,this.lastFlushedAt=Date.now(),[3,10];case 5:return(i=o.sent())instanceof E?i.code!==u.STAT_LOG_NOT_ALLOWED?[3,7]:[4,this.clear()]:[3,8];case 6:return o.sent(),this.enabledState=qi.DISABLED,[3,8];case 7:i.code===u.STAT_UPLOAD_NOT_ALLOWED&&(this.enabledState=qi.COLLECT_ONLY),o.label=8;case 8:return this.limit=this.limit+20,[3,10];case 9:return this.isFlushing=!1,[7];case 10:return[2]}}))}))},n.prototype.init=function(e){return i(this,void 0,void 0,(function(){var t,n,r=this;return o(this,(function(i){switch(i.label){case 0:return this.key=e,[4,this.cacheContext.preference.get(this.key)];case 1:return(t=i.sent())?(this.deviceId=t.deviceId,this.queue=t.statLogs.map((function(e){return new Ce({type:e.stat_type,ts:e.ts,data:e.data})})),this.generation=t.generation,this.lastFlushedAt=t.lastFlushedAt,Date.now()-this.lastFlushedAt>=108e5&&this.queue.length>=this.minLimit?(n=Math.min(Math.floor(18e4*Math.random()),100),[4,ci(n)]):[3,4]):[3,4];case 2:return i.sent(),[4,this._flush()];case 3:i.sent(),i.label=4;case 4:return this.commandEventContext||(this.commandEventContext=this.dispatcher.on((function(e){if(e instanceof Te){var t=e.statLog;r.put(t)}else if(e instanceof Vi){var n=e.request,i=e.features,o=e.options;r._collectRequestStat=n,r._collectFeatureLocalCacheStat=null==i?void 0:i.localCache,r._arrangeStat(),r._collectRequestStat||r._collectFeatureLocalCacheStat?r.enabledState=o.ingestion?qi.ENABLED:qi.COLLECT_ONLY:r.enabledState=qi.DISABLED,r.isEnabled?r.queue.length>=r.limit&&r._flush():r.clear()}}))),[2]}}))}))},n.prototype.put=function(e){return i(this,void 0,void 0,(function(){var t,n;return o(this,(function(r){switch(r.label){case 0:return this.enabledState===qi.DISABLED?[3,3]:(e instanceof Wi?this._collectFeatureLocalCacheStat&&(t=a(this.queue.filter((function(t){return t instanceof Wi&&t.key===e.key})),1),(n=t[0])?n.data=Yi(n.data,e.data):this.queue.push(e)):this._collectRequestStat&&this.queue.push(e),[4,this._save()]);case 1:return r.sent(),this.queue.length>=this.limit?[4,this._flush()]:[3,3];case 2:r.sent(),r.label=3;case 3:return[2]}}))}))},n.prototype.clear=function(){return i(this,void 0,void 0,(function(){return o(this,(function(e){switch(e.label){case 0:return this.queue=[],this.generation=1,[4,this._save()];case 1:return e.sent(),[2]}}))}))},n.prototype.close=function(){this.commandEventContext&&(this.commandEventContext.close(),this.commandEventContext=void 0)},n}(W);!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"}(Xi||(Xi={}));var $i,eo=function(){function e(){this.level=Xi.WARN}return e.prototype.verbose=function(){for(var e=[],t=0;t0})).map((function(e){return e.id}))),this.allowUserSuggestion=null!==(a=e.allow_user_suggestion)&&void 0!==a?a:this.allowUserSuggestion,this.allowMultipleVotes=null!==(c=e.allow_multiple_votes)&&void 0!==c?c:this.allowMultipleVotes},r.payloadify=function(t){return X(J(n(n({},e.payloadify.call(this,t)),{id:t.id,title:t.title,created_at:t.createdAt,updated_at:t.updatedAt,close_at:t.closeAt,status:t.status,message_id:t.messageId,data:t.data,voter_count:t.voterCount,options:t.options.map((function(e){return uo.payloadify(e)})),created_by:t.createdBy,allow_user_suggestion:t.allowUserSuggestion,allow_multiple_votes:t.allowMultipleVotes,voted_option_ids:t.votedPollOptionIds})))},r.prototype.applyPollUpdateEvent=function(e){var t=e._payload.poll;return!(!t||this.id!==t.id||t.updated_at-1){var o=t[r];i>=o._lastVotedAt&&(o.voteCount=e.vote_count,o._lastVotedAt=i)}})),r.req_id&&r.voted_option_ids&&(this.votedPollOptionIds=r.voted_option_ids),!0},r.prototype.serialize=function(){return Ui(this)},r}(Ni);!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.EVENT_POLL_UPDATED="EVENT_POLL_UPDATED",e.EVENT_POLL_VOTED="EVENT_POLL_VOTED",e.SYNC_POLL_CHANGELOGS="SYNC_POLL_CHANGELOGS",e.REQUEST_RESEND_MESSAGE="REQUEST_RESEND_MESSAGE",e.REQUEST_THREADED_MESSAGE="REQUEST_THREADED_MESSAGE",e.REQUEST_MESSAGE_CHANGELOGS="REQUEST_MESSAGE_CHANGELOGS",e.SYNC_MESSAGE_FILL="SYNC_MESSAGE_FILL",e.SYNC_MESSAGE_BACKGROUND="SYNC_MESSAGE_BACKGROUND",e.SYNC_MESSAGE_CHANGELOGS="SYNC_MESSAGE_CHANGELOGS",e.LOCAL_MESSAGE_PENDING_CREATED="LOCAL_MESSAGE_PENDING_CREATED",e.LOCAL_MESSAGE_FAILED="LOCAL_MESSAGE_FAILED",e.LOCAL_MESSAGE_CANCELED="LOCAL_MESSAGE_CANCELED",e.LOCAL_MESSAGE_RESEND_STARTED="LOCAL_MESSAGE_RESEND_STARTED"}(io||(io={}));var ho=function(e){return e.startsWith("EVENT_")||e===io.SYNC_MESSAGE_FILL||e===io.SYNC_MESSAGE_CHANGELOGS||e===io.SYNC_POLL_CHANGELOGS},_o=function(e){function n(t){var n=t.messages,r=t.source,i=t.isWebSocketEventComing,o=void 0!==i&&i,s=e.call(this)||this;return s.messages=n,s.source=r,s.isWebSocketEventComing=o,s}return t(n,e),n}(Y),fo=function(e){function n(t){var n=t.messageIds,r=t.source,i=t.isWebSocketEventComing,o=void 0!==i&&i,s=e.call(this)||this;return s.messageIds=n,s.source=r,s.isWebSocketEventComing=o,s}return t(n,e),n}(Y),po=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}(Y),go=function(e){function n(t){var n=t.polls,r=t.source,i=e.call(this)||this;return i.polls=n,i.source=r,i}return t(n,e),n}(Y),vo=function(e){function n(t){var n=t.event,r=t.source,i=e.call(this)||this;return i.event=n,i.source=r,i}return t(n,e),n}(Y),Eo=function(e){function n(t){var n=t.event,r=t.source,i=e.call(this)||this;return i.event=n,i.source=r,i}return t(n,e),n}(Y),bo=function(){function e(e,t){var n;this.limit=20,this._isLoading=!1,this._hasNext=!0,this._token="",this._iid=e,this.limit=null!==(n=t.limit)&&void 0!==n?n:20}return Object.defineProperty(e.prototype,"hasNext",{get:function(){return this._hasNext},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"isLoading",{get:function(){return this._isLoading},enumerable:!1,configurable:!0}),e.prototype._validate=function(){return w("number",this.limit)&&this.limit>0},e}(),mo=function(e){function n(t,n,r,i){var o=e.call(this,t,i)||this;return o.channelUrl=n,o.channelType=r,o}return t(n,e),n.prototype._validate=function(){return e.prototype._validate.call(this)&&w("string",this.channelUrl)&&S(x,this.channelType)},n}(bo);export{ne as $,$ as A,bo as B,Vr as C,Yr as D,W as E,ji as F,Ki as G,ke as H,d as I,di as J,s as K,B as L,S as M,_ as N,p as O,f as P,x as Q,K as R,E as S,Xi as T,Gi as U,no as V,Ne as W,M as X,Ti as Y,Pi as Z,t as _,w as a,Ni as a0,y as a1,P as a2,Ui as a3,F as a4,j as a5,C as a6,U as a7,lo as a8,G as a9,ce as aA,Ee as aB,z as aC,v as aD,Eo as aE,N as aF,vo as aG,po as aH,ie as aI,de as aJ,oo as aK,ho as aL,Wi as aM,me as aN,li as aO,so as aP,se as aQ,oe as aR,Qr as aa,pe as ab,ve as ac,u as ad,ci as ae,Xr as af,q as ag,re as ah,io as ai,_o as aj,fo as ak,ae as al,mo as am,ro as an,uo as ao,$i as ap,Y as aq,O as ar,I as as,r as at,he as au,co as av,ao as aw,go as ax,Oi as ay,ge as az,i as b,o as c,te as d,X as e,ye as f,n as g,we as h,A as i,le as j,ue as k,_e as l,T as m,Re as n,R as o,Z as p,Oe as q,c as r,a as s,Fi as t,J as u,l as v,zi as w,$r as x,Hr as y,hi as z}; diff --git a/lib/__bundle-84f74e8d.js b/lib/__bundle-84f74e8d.js new file mode 100644 index 0000000..ec3c662 --- /dev/null +++ b/lib/__bundle-84f74e8d.js @@ -0,0 +1 @@ +import{_ as e,A as t,$ as n,e as s,f as a,h as i,u as r,g as l,U as u,a0 as o,m as d,a as c,M as h,r as p,s as m,K as f,X as g,a1 as y,a2 as _,a3 as v,Q as I,a4 as M,a5 as T,a6 as S,a7 as A,b,c as U,t as E,S as w,a8 as F,V as q,a9 as D,aa as N,ab as P,ac as C,W as R,x as L,y as O,ad as k,ae as z,i as x,af as Q,ag as G,ah as B,w as j,ai as H,aj as W,ak as K,n as V,al as X,B as $,am as J,an as Y}from"./__bundle-75942676.js";var Z,ee=function(a){function i(e){var i=a.call(this)||this;if(i.method=t.POST,i.path="".concat(n),i.params=s({file:e.file,channel_url:e.channelUrl}),e.thumbnailSizes)for(var r=0;r0&&c("number",r)&&(this.key=a,this.userIds=i,this.updatedAt=r);var l={};try{for(var u=f(this.userIds),o=u.next();!o.done;o=u.next()){l[o.value]=this.updatedAt}}catch(e){t={error:e}}finally{try{o&&!o.done&&(n=u.return)&&n.call(u)}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 s(r({key:e.key,user_ids:e.userIds,updated_at:e.updatedAt}))},e.prototype.applyEvent=function(e){if(e.key===this.key&&this.updatedAt<=e.updatedAt){if(!this._version[e.userId]||this._version[e.userId]<=e.updatedAt){var t=this.userIds.indexOf(e.userId);switch(e.operation){case Z.ADD:t<0&&this.userIds.push(e.userId);break;case Z.DELETE:t>=0&&this.userIds.splice(t,1)}this._version[e.userId]=e.updatedAt}this.updatedAt=Math.max(this.updatedAt,e.updatedAt)}},e}(),le=function(){function e(e){this.key=e.key,this.value=d("string",e.value)?p([],m(e.value),!1):[]}return e.payloadify=function(e){var t;return s(r({key:e.key,value:null!==(t=e.value)&&void 0!==t?t:[]}))},e}(),ue=function(){function e(e){this.secureUrl=null,this.type=null,this.width=0,this.height=0,this.alt=null,this.url=e.url,e.secure_url&&(this.secureUrl=e.secure_url),e.type&&(this.type=e.type),e.width&&(this.width=e.width),e.height&&(this.height=e.height),e.alt&&(this.alt=e.alt)}return e.payloadify=function(e){var t,n;return s(r({url:e.url,secure_url:e.secureUrl,type:e.type,width:null!==(t=e.width)&&void 0!==t?t:0,height:null!==(n=e.height)&&void 0!==n?n:0,alt:e.alt}))},e}(),oe=function(){function e(e){this.title=null,this.url=null,this.description=null,this.defaultImage=null,e["og:title"]&&(this.title=e["og:title"]),e["og:url"]&&(this.url=e["og:url"]),e["og:description"]&&(this.description=e["og:description"]),e["og:image"]&&(this.defaultImage=new ue(e["og:image"]))}return e.payloadify=function(e){return s(r({"og:title":e.title,"og:url":e.url,"og:description":e.description,"og:image":e.defaultImage?ue.payloadify(e.defaultImage):null}))},e}(),de=function(){function e(e){var t,n;this.volume=0,this.name=null!==(t=e.name)&&void 0!==t?t:"default",this.volume=null!==(n=e.volume)&&void 0!==n?n:1}return e.prototype.serialize=function(){return{name:this.name,volume:this.volume}},e.payloadify=function(e){return s(r({name:e.name,volume:e.volume}))},e}(),ce=function(t){function n(e,n){var s,a=this;return(a=t.call(this,e,n)||this).isBlockedByMe=!1,a.role=h(g,n.role)?n.role:g.NONE,a.isBlockedByMe=null!==(s=n.is_blocked_by_me)&&void 0!==s&&s,a}return e(n,t),n.payloadify=function(e){return s(r(l(l({},t.payloadify.call(this,e)),{role:e.role,is_blocked_by_me:e.isBlockedByMe})))},n}(u);!function(e){e.PENDING="pending",e.SENT="sent",e.FAILED="failed",e.CANCELED="canceled"}(se||(se={})),function(e){e.PENDING="pending",e.IN_QUEUE="in_queue",e.SENT="sent",e.FAILED="failed",e.CANCELED="canceled",e.REMOVED="removed"}(ae||(ae={}));var he=function(e){switch(e){case _.BASE:return"";case _.USER:return"MESG";case _.FILE:return"FILE";case _.ADMIN:return"ADMM"}},pe=function(t){function n(e,n){var s,a,i,r,l,o,d,c,p,m,f,g,y,v,T,S,A=this;(A=t.call(this,e)||this).channelType=I.BASE,A.parentMessage=null,A.silent=!1,A.isOperatorMessage=!1,A.messageType=_.BASE,A.mentionType=null,A.threadInfo=null,A.reactions=[],A.metaArrays=[],A.appleCriticalAlertOptions=null,A.createdAt=0,A.updatedAt=0,A.scheduledInfo=null,A.extendedMessage={},A._isContinuousMessages=!1,A._scheduledStatus=null,A.messageId=null!==(a=null!==(s=n.msg_id)&&void 0!==s?s:n.message_id)&&void 0!==a?a:0,A.channelUrl=n.channel_url,A.channelType=h(I,n.channel_type)?n.channel_type:I.GROUP,n.channel&&(n.channel.channel_url&&(A.channelUrl=n.channel.channel_url),n.channel.channel_type&&(A.channelType=n.channel.channel_type)),A.parentMessageId=null!==(i="string"==typeof n.parent_message_id?parseInt(n.parent_message_id):n.parent_message_id)&&void 0!==i?i:0,A.data=null!==(r=n.data)&&void 0!==r?r:"",A.customType=null!==(l=n.custom_type)&&void 0!==l?l:"",A.mentionType=h(M,n.mention_type)?n.mention_type:null,A.mentionedUsers=n.mentioned_users?n.mentioned_users.map((function(e){return new u(A._iid,e)})):null,A.mentionedUserIds=null!==(o=n.mentioned_user_ids)&&void 0!==o?o:null,A.mentionedUsers&&!A.mentionedUserIds&&(A.mentionedUserIds=A.mentionedUsers.map((function(e){return e.userId}))),A.mentionedMessageTemplate=null!==(d=n.mentioned_message_template)&&void 0!==d?d:"",A.threadInfo=n.thread_info?new ne(A._iid,n.thread_info):null,A.reactions=n.reactions?n.reactions.map((function(e){return new re(e)})):[];var b=null!==(c=n.metaarray)&&void 0!==c?c:{},U=null!==(p=n.metaarray_key_order)&&void 0!==p?p:Object.keys(b).sort((function(e,t){return e.localeCompare(t)}));A.metaArrays=[];for(var E=0;E=t)return this.parentMessage=e,!0}return!1},n}(o),me=function(t){function n(e,n){var s,a,i,r,l=this;if((l=t.call(this,e,n)||this).reqId="",l.replyToChannel=!1,l.errorCode=0,l.sender=n.user?new ce(l._iid,n.user):n.sender_id,l.reqId=null!==(a=null!==(s=n.req_id)&&void 0!==s?s:n.request_id)&&void 0!==a?a:"",l.replyToChannel=null!==(i=n.is_reply_to_channel)&&void 0!==i&&i,n.request_state&&h(T,n.request_state)&&(l.sendingStatus=n.request_state),!l.sendingStatus)if(l.messageId>0)l.sendingStatus=T.SUCCEEDED;else if(l.scheduledInfo)switch(n.scheduled_status&&(l._scheduledStatus=n.scheduled_status),n.scheduled_status){case ae.SENT:case ae.IN_QUEUE:l.sendingStatus=T.SUCCEEDED;break;case ae.PENDING:l.sendingStatus=T.SCHEDULED;break;case ae.FAILED:case ae.REMOVED:l.sendingStatus=T.FAILED;break;case ae.CANCELED:l.sendingStatus=T.CANCELED}else l.sendingStatus=T.PENDING;return l.errorCode=null!==(r=n.error_code)&&void 0!==r?r:0,l}return e(n,t),n.payloadify=function(e){return s(r(l(l({},t.payloadify.call(this,e)),{user:ce.payloadify(e.sender),req_id:e.reqId,is_reply_to_channel:e.replyToChannel,request_state:e.sendingStatus,error_code:e.errorCode})))},Object.defineProperty(n.prototype,"isResendable",{get:function(){return this.sendingStatus===T.FAILED&&S(this.errorCode)},enumerable:!1,configurable:!0}),n.prototype.isIdentical=function(e){return this.messageId>0&&e.messageId>0?this.messageId===e.messageId:this.reqId===e.reqId},n}(pe),fe=function(){function e(e){var t,n;this.width=0,this.height=0,this.realWidth=0,this.realHeight=0,this.url=e.url,this.width=e.width,this.height=e.height,this.realWidth=null!==(t=e.real_width)&&void 0!==t?t:e.width,this.realHeight=null!==(n=e.real_height)&&void 0!==n?n:e.height}return e.payloadify=function(e){return s(r({url:"",width:e.maxWidth,height:e.maxHeight,real_width:0,real_height:0}))},Object.defineProperty(e.prototype,"plainUrl",{get:function(){return this.url.split("?auth=")[0]},enumerable:!1,configurable:!0}),e}(),ge={prevResultSize:0,nextResultSize:0,isInclusive:!1,reverse:!1,messageTypeFilter:A.ALL,customTypesFilter:void 0,senderUserIdsFilter:void 0,includeReactions:!1,includeMetaArray:!1,includeParentMessageInfo:!1},ye=function(e){return c("number",e.prevResultSize)&&c("number",e.nextResultSize)&&c("boolean",e.isInclusive)&&c("boolean",e.reverse)&&c("string",e.messageTypeFilter)&&h(A,e.messageTypeFilter)&&d("string",e.customTypesFilter,!0)&&d("string",e.senderUserIdsFilter,!0)&&c("boolean",e.includeMetaArray)&&c("boolean",e.includeReactions)&&c("boolean",e.includeParentMessageInfo)},_e=function(t){function n(e,n){var a,i,u,o,d=this;if((d=t.call(this,e,n)||this).translations={},d.message=null!==(a=n.message)&&void 0!==a?a:"",d.messageType=_.ADMIN,d.translations=null!==(i=n.translations)&&void 0!==i?i:{},n.parent_message_info){var c=n.parent_message_info;d.parentMessage=Ae(e,s(r(l(l({},c),{message_id:d.parentMessageId,channel_url:d.channelUrl,channel_type:d.channelType,file:c.file,url:null===(u=c.file)||void 0===u?void 0:u.url,require_auth:null===(o=c.file)||void 0===o?void 0:o.require_auth}))))}return d}return e(n,t),n.payloadify=function(e){return s(r(l(l({},t.payloadify.call(this,e)),{message:e.message,translations:e.translations,parent_message_info:e.parentMessage?t._getParentMessageInfoPayload.call(this,e.parentMessage):null})))},n.prototype.getThreadedMessagesByTimestamp=function(e,t){return b(this,void 0,void 0,(function(){var n;return U(this,(function(s){switch(s.label){case 0:return n=l(l({},ge),t),E(this.messageId>0&&c("number",e)&&ye(n)).throw(w.invalidParameters),[4,Ke.of(this._iid).getThreadedMessagesByTimestamp(this,e,n)];case 1:return[2,s.sent()]}}))}))},n}(pe),ve=function(){function e(e){var t,n;this.detail={},this.type=null!==(t=e.type)&&void 0!==t?t:"",this.vendor=null!==(n=e.vendor)&&void 0!==n?n:"",e.detail&&c("object",e.detail)&&!Array.isArray(e.detail)&&(this.detail=e.detail)}return e.payloadify=function(e){return s(r({type:e.type,vendor:e.vendor,detail:e.detail}))},e}(),Ie=function(t){function n(e,n){var a,i,u,o,d,c,h,p=this;if((p=t.call(this,e,n)||this).message="",p.messageParams=null,p.translations={},p.translationTargetLanguages=[],p.messageSurvivalSeconds=-1,p.plugins=[],p._poll=null,p.message=n.message,p.messageType=_.USER,p.translations=null!==(u=n.translations)&&void 0!==u?u:{},p.translationTargetLanguages=null!==(o=n.target_langs)&&void 0!==o?o:[],0===Object.keys(p.translations).length&&p.translationTargetLanguages.length>0)try{for(var m=f(p.translationTargetLanguages),g=m.next();!g.done;g=m.next()){var y=g.value;p.translations[y]=""}}catch(e){a={error:e}}finally{try{g&&!g.done&&(i=m.return)&&i.call(m)}finally{if(a)throw a.error}}if(p.messageSurvivalSeconds=null!==(d=n.message_survival_seconds)&&void 0!==d?d:-1,p.plugins=n.plugins?n.plugins.map((function(e){return new ve(e)})):[],p._poll=n.poll?new F(p._iid,n.poll):null,n.parent_message_info){var v=n.parent_message_info;p.parentMessage=Ae(e,s(r(l(l({},v),{created_at:v.ts,message_id:p.parentMessageId,channel_url:p.channelUrl,channel_type:p.channelType,file:v.file,url:null===(c=v.file)||void 0===c?void 0:c.url,require_auth:null===(h=v.file)||void 0===h?void 0:h.require_auth}))))}return p}return e(n,t),n.payloadify=function(e){return s(r(l(l({},t.payloadify.call(this,e)),{message:e.message,translations:e.translations,message_survival_seconds:e.messageSurvivalSeconds,plugins:e.plugins.map((function(e){return ve.payloadify(e)})),poll:e._poll?F.payloadify(e._poll):null,parent_message_info:e.parentMessage?t._getParentMessageInfoPayload.call(this,e.parentMessage):null})))},n.prototype.getThreadedMessagesByTimestamp=function(e,t){return b(this,void 0,void 0,(function(){var n;return U(this,(function(s){switch(s.label){case 0:return n=l(l({},ge),t),E(this.messageId>0&&c("number",e)&&ye(n)).throw(w.invalidParameters),[4,Ke.of(this._iid).getThreadedMessagesByTimestamp(this,e,n)];case 1:return[2,s.sent()]}}))}))},n.prototype.applyPoll=function(e){return!(this._poll&&this._poll.id===e.id&&this._poll.updatedAt>e.updatedAt)&&(this._poll=e,!0)},Object.defineProperty(n.prototype,"poll",{get:function(){return this._poll},enumerable:!1,configurable:!0}),n}(me),Me=function(t){function n(e,n){var s,a,i,r,u,o=this;(o=t.call(this,e)||this).plainUrl="",o.fileName=null,o.mimeType=null,o.fileSize=0,o.thumbnails=[],o._requireAuth=!1,o.plainUrl=null!==(s=n.url)&&void 0!==s?s:"",o.fileName=null!==(a=n.file_name)&&void 0!==a?a:null,o.mimeType=null!==(i=n.file_type)&&void 0!==i?i:null,o.fileSize=null!==(r=n.file_size)&&void 0!==r?r:0,o._requireAuth=null!==(u=n.require_auth)&&void 0!==u&&u;var d=q.of(o._iid).sessionManager;return o.thumbnails=n.thumbnails?n.thumbnails.map((function(e){return new fe(l(l({},e),{url:"".concat(e.url.split("?auth=")[0]).concat(o._requireAuth?"?auth=".concat(d.ekey):"")}))})):[],o}return e(n,t),n.payloadify=function(e){var t;return s(r({url:e.plainUrl,file_name:e.fileName,file_type:e.mimeType,file_size:e.fileSize,thumbnails:null===(t=e.thumbnails)||void 0===t?void 0:t.map((function(e){return{url:e.url,width:e.width,height:e.height,real_width:e.realWidth,real_height:e.realHeight}})),require_auth:e._requireAuth}))},Object.defineProperty(n.prototype,"url",{get:function(){var e=q.of(this._iid).sessionManager;return this._requireAuth?"".concat(this.plainUrl,"?auth=").concat(e.ekey):this.plainUrl},enumerable:!1,configurable:!0}),n}(o),Te=function(t){function n(e,n){var a,i,u,o,d,c=this;if((c=t.call(this,e,n)||this).messageParams=null,c.fileInfoList=[],c.messageSurvivalSeconds=-1,c.messageType=_.FILE,c.fileInfoList=null!==(i=null===(a=n.files)||void 0===a?void 0:a.map((function(t){return new Me(e,t)})))&&void 0!==i?i:[],c.messageSurvivalSeconds=null!==(u=n.message_survival_seconds)&&void 0!==u?u:-1,n.parent_message_info){var h=n.parent_message_info;c.parentMessage=Ae(e,s(r(l(l({},h),{created_at:h.ts,message_id:c.parentMessageId,channel_url:c.channelUrl,channel_type:c.channelType,file:h.file,url:null===(o=h.file)||void 0===o?void 0:o.url,require_auth:null===(d=h.file)||void 0===d?void 0:d.require_auth}))))}return c}return e(n,t),n.prototype.getThreadedMessagesByTimestamp=function(e,t){return b(this,void 0,void 0,(function(){var n;return U(this,(function(s){switch(s.label){case 0:return n=l(l({},ge),t),E(this.messageId>0&&c("number",e)&&ye(n)).throw(w.invalidParameters),[4,Ke.of(this._iid).getThreadedMessagesByTimestamp(this,e,n)];case 1:return[2,s.sent()]}}))}))},n.payloadify=function(e){return s(r(l(l({},t.payloadify.call(this,e)),{files:e.fileInfoList&&e.fileInfoList&&Array.isArray(e.fileInfoList)?e.fileInfoList.map((function(e){return Me.payloadify(e)})):null,message_survival_seconds:e.messageSurvivalSeconds,parent_message_info:e.parentMessage?t._getParentMessageInfoPayload.call(this,e.parentMessage):null})))},n._isMultipleFilesMessagePayload=function(e){var t=e.files;return Array.isArray(t)&&t.length>=2},n._isMultipleFilesMessageSerializedData=function(e){var t=e.fileInfoList;return Array.isArray(t)},n}(me),Se=function(e){switch(e.messageType){case _.USER:return Ie.payloadify(e);case _.FILE:return e.fileInfoList?Te.payloadify(e):be.payloadify(e);case _.ADMIN:return _e.payloadify(e);default:throw w.unknown}},Ae=function(e,t){switch(t.type){case"MESG":return new Ie(e,t);case"FILE":return Te._isMultipleFilesMessagePayload(t)?new Te(e,t):new be(e,t);case"ADMM":case"BRDM":return new _e(e,t)}throw w.unknown},be=function(t){function n(e,n){var a,i,u,o,d,c,h,p,m,f,g,y,v,I,M=this;(M=t.call(this,e,n)||this).messageParams=null,M.plainUrl="",M.requireAuth=!1,M.thumbnails=[],M.messageSurvivalSeconds=-1,M.messageType=_.FILE;var T=n.file;M.plainUrl=(null!==(i=null!==(a=null==T?void 0:T.url)&&void 0!==a?a:n.url)&&void 0!==i?i:"").split("?auth=")[0],M.name=null!==(o=null!==(u=null==T?void 0:T.name)&&void 0!==u?u:n.name)&&void 0!==o?o:"File",M.size=null!==(c=null!==(d=null==T?void 0:T.size)&&void 0!==d?d:n.size)&&void 0!==c?c:0,M.data=null!==(p=null!==(h=null==T?void 0:T.data)&&void 0!==h?h:n.custom)&&void 0!==p?p:"",M.type=T?null!==(m=T.type)&&void 0!==m?m:"":null!==(f=n.type)&&void 0!==f?f:"";var S=q.of(M._iid).sessionManager;if(M.requireAuth=null!==(g=n.require_auth)&&void 0!==g&&g,M.thumbnails=n.thumbnails?n.thumbnails.map((function(e){return new fe(l(l({},e),{url:"".concat(e.url.split("?auth=")[0]).concat(M.requireAuth?"?auth=".concat(S.ekey):"")}))})):[],M.messageSurvivalSeconds=null!==(y=n.message_survival_seconds)&&void 0!==y?y:-1,n.parent_message_info){var A=n.parent_message_info;M.parentMessage=Ae(e,s(r(l(l({},A),{created_at:A.ts,message_id:M.parentMessageId,channel_url:M.channelUrl,channel_type:M.channelType,file:A.file,url:null===(v=A.file)||void 0===v?void 0:v.url,require_auth:null===(I=A.file)||void 0===I?void 0:I.require_auth}))))}return M}return e(n,t),n.payloadify=function(e){var n;return s(r(l(l({},t.payloadify.call(this,e)),{url:e.plainUrl,require_auth:e.requireAuth,file:{name:e.name,size:e.size,type:e.type,data:e.data},thumbnails:null===(n=e.thumbnails)||void 0===n?void 0:n.map((function(e){return{url:e.url,width:e.width,height:e.height,real_width:e.realWidth,real_height:e.realHeight}})),message_survival_seconds:e.messageSurvivalSeconds,parent_message_info:e.parentMessage?t._getParentMessageInfoPayload.call(this,e.parentMessage):null})))},Object.defineProperty(n.prototype,"url",{get:function(){var e=q.of(this._iid).sessionManager;return this.requireAuth?"".concat(this.plainUrl,"?auth=").concat(e.ekey):this.plainUrl},enumerable:!1,configurable:!0}),n.prototype.getThreadedMessagesByTimestamp=function(e,t){return b(this,void 0,void 0,(function(){var n;return U(this,(function(s){switch(s.label){case 0:return n=l(l({},ge),t),E(this.messageId>0&&c("number",e)&&ye(n)).throw(w.invalidParameters),[4,Ke.of(this._iid).getThreadedMessagesByTimestamp(this,e,n)];case 1:return[2,s.sent()]}}))}))},n}(me),Ue=function(t){function n(e){var n,a,i,l=[];return e.mentionType===M.USERS&&(e.mentionedUserIds?l=e.mentionedUserIds:e.mentionedUsers&&(l=e.mentionedUsers.map((function(e){return e.userId})))),t.call(this,{code:"FILE",ackRequired:!0,payload:s(r({channel_url:e.channelUrl,files:e.files?qe(e.files):null,url:e.url,name:null!==(n=e.fileName)&&void 0!==n?n:"",type:null!==(a=e.mimeType)&&void 0!==a?a:"",size:null!==(i=e.fileSize)&&void 0!==i?i:0,custom:e.data,custom_type:e.customType,thumbnails:e.thumbnailSizes,require_auth:e.requireAuth,metaarray:e.metaArrays,mention_type:e.mentionType,mentioned_user_ids:l,push_option:e.pushNotificationDeliveryOption&&e.pushNotificationDeliveryOption!==D.DEFAULT?e.pushNotificationDeliveryOption:void 0,apple_critical_alert_options:e.appleCriticalAlertOptions?de.payloadify(e.appleCriticalAlertOptions):null,silent:e.silent,reply_to_channel:e.isReplyToChannel,parent_message_id:e.parentMessageId?e.parentMessageId:null,req_id:e.reqId,pin_message:e.isPinnedMessage}))})||this}return e(n,t),n}(N),Ee=function(n){function a(e){var a,i,l=this;l=n.call(this)||this;var u=[];return e.mentionType===M.USERS&&(e.mentionedUserIds?u=e.mentionedUserIds:e.mentionedUsers&&(u=e.mentionedUsers.map((function(e){return e.userId})))),l.method=t.POST,l.path="".concat(P(e.channelType),"/").concat(encodeURIComponent(e.channelUrl),"/messages"),l.params=s(r({message_type:_.FILE,user_id:e.userId,files:e.files?qe(e.files):null,url:e.fileUrl,mention_type:e.mentionType,mentioned_user_ids:u,file_name:e.fileName,file_size:e.fileSize,file_type:e.mimeType,data:e.data,custom_type:e.customType,thumbnails:null===(a=e.thumbnailSizes)||void 0===a?void 0:a.map((function(e){return fe.payloadify(e)})),require_auth:e.requireAuth,sorted_metaarray:null===(i=e.metaArrays)||void 0===i?void 0:i.map((function(e){return le.payloadify(e)})),push_option:e.pushNotificationDeliveryOption,parent_message_id:e.parentMessageId?e.parentMessageId:null,apple_critical_alert_options:e.appleCriticalAlertOptions?de.payloadify(e.appleCriticalAlertOptions):null,reply_to_channel:e.isReplyToChannel,req_id:e.reqId,pin_message:e.isPinnedMessage})),l}return e(a,n),a}(a),we=function(t){function n(e,n,s){var a,i,r,l,u=this;(u=t.call(this,e,"FILE",s)||this).message=s.files&&s.files.length>=2?new Te(e,s):new be(e,s);var o=q.of(e).sdkState;return u.isMentioned=C(u.message.mentionType,null!==(r=null!==(a=u.message.mentionedUserIds)&&void 0!==a?a:null===(i=u.message.mentionedUsers)||void 0===i?void 0:i.map((function(e){return e.userId})))&&void 0!==r?r:[],o.userId),u.forceUpdateLastMessage=null!==(l=s.force_update_last_message)&&void 0!==l&&l,u}return e(n,t),n}(R),Fe=function(t){function n(e,n){var s,a,i,r,l=this;(l=t.call(this,e,n)||this).message=n.files&&n.files.length>=2?new Te(e,n):new be(e,n);var u=q.of(e).sdkState;return l.isMentioned=C(l.message.mentionType,null!==(i=null!==(s=l.message.mentionedUserIds)&&void 0!==s?s:null===(a=l.message.mentionedUsers)||void 0===a?void 0:a.map((function(e){return e.userId})))&&void 0!==i?i:[],u.userId),l.forceUpdateLastMessage=null!==(r=n.force_update_last_message)&&void 0!==r&&r,l}return e(n,t),n}(i);function qe(e){return e.map((function(e){var t,n;return s(r({url:e.fileUrl,file_name:e.fileName,file_type:e.mimeType,file_size:e.fileSize,thumbnails:null===(t=e.thumbnailSizes)||void 0===t?void 0:t.map((function(e){return fe.payloadify(e)})),require_auth:null===(n=e._uploadedMetaData)||void 0===n?void 0:n.requireAuth}))}))}var De;!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"}(De||(De={}));var Ne=function(){function e(e,t){var n=t.sdkState,s=t.dispatcher,a=t.requestQueue,i=t.onlineDetector,r=t.cacheContext,l=this;this._queueMap=new Map,this._iid=e,this._sdkState=n,this._requestQueue=a,this._cacheContext=r,this._dispatcher=s,this._dispatcher.on((function(e){e instanceof L&&(l._connectionState=e.stateType)})),this._onlineDetector=i}return Object.defineProperty(e.prototype,"_shouldSendThroughWebSocket",{get:function(){return this._connectionState===O.CONNECTED||this._connectionState===O.CONNECTING||this._connectionState===O.RECONNECTING},enumerable:!1,configurable:!0}),e.prototype._sendFileMessage=function(e,t){return b(this,void 0,void 0,(function(){var n,s,a;return U(this,(function(i){switch(i.label){case 0:return n=this._createSendFileMessageRequestParams(e,t),this._shouldSendThroughWebSocket?(s=new Ue(n),[4,this._requestQueue.send(s)]):[3,2];case 1:return a=i.sent(),[2,a.as(we).message];case 2:return s=new Ee(l(l({},n),{userId:this._sdkState.userId})),[4,this._requestQueue.send(s)];case 3:return a=i.sent(),[2,a.as(Fe).message]}}))}))},e.prototype._createSendFileMessageRequestParams=function(e,t){var n=l(l({},t.params),{channelUrl:e.url,channelType:e.channelType,reqId:t.requestId,url:""});if(t.multipleFileUploadInfo){var s=t.params;n.files=s.fileInfoList}else{s=t.params;n.url=s.fileUrl,n.requireAuth=s.requireAuth}return n},e.prototype._resolveMessageQueue=function(e){var t;return b(this,void 0,void 0,(function(){var n,s,a,i,r,l,u,o,d,c,h,p,m;return U(this,(function(g){switch(g.label){case 0:if(!(n=this._queueMap.get(e.url)))return[3,21];if(n.isResolving)return[3,20];n.isResolving=!0,s=[],a=!0,g.label=1;case 1:g.trys.push([1,15,16,17]),i=f(n.messageQueue),r=i.next(),g.label=2;case 2:if(r.done)return[3,14];switch(l=r.value,l.state){case De.PENDING:case De.UPLOADING:return[3,3];case De.UPLOADED:return[3,4];case De.FAILED:return[3,12]}return[3,13];case 3:return a=!1,s.push(l),[3,13];case 4:if(!a)return[3,10];g.label=5;case 5:return g.trys.push([5,8,,9]),l.state=De.SENDING,[4,this._sendFileMessage(e,l)];case 6:return u=g.sent(),l.deferred.resolve(u),[4,z(100)];case 7:return g.sent(),[3,9];case 8:return o=g.sent(),l.deferred.reject(o),[3,9];case 9:return[3,11];case 10:s.push(l),g.label=11;case 11:return[3,13];case 12:return d=null!==(t=l.error)&&void 0!==t?t:w.unknown,l.deferred.reject(d.code===k.REQUEST_CANCELED?w.fileUploadCanceled:d),[3,13];case 13:return r=i.next(),[3,2];case 14:return[3,17];case 15:return c=g.sent(),p={error:c},[3,17];case 16:try{r&&!r.done&&(m=i.return)&&m.call(i)}finally{if(p)throw p.error}return[7];case 17:return h=n.isResolveRequestPending,n.messageQueue=s,n.isResolving=!1,n.isResolveRequestPending=!1,h?[4,this._resolveMessageQueue(e)]:[3,19];case 18:g.sent(),g.label=19;case 19:return[3,21];case 20:n.isResolveRequestPending=!0,g.label=21;case 21:return[2]}}))}))},e.prototype._uploadNextPendingItem=function(e){var t;return b(this,void 0,void 0,(function(){var n,s,a,i,r,l,u,o,d;return U(this,(function(c){switch(c.label){case 0:return(n=this._queueMap.get(e.url))&&(s=n.messageQueue.find((function(e){return e.state===De.PENDING})))?s.multipleFileUploadInfo?(a=s.multipleFileUploadInfo,i=a.uploadIndex,r=a.uploadCount,l=a.requestHandler,d=s.params,u=d.fileInfoList[i],!x(u.file)||(null===(t=u._uploadedMetaData)||void 0===t?void 0:t.isUploaded)?[3,2]:[4,this._tryUploadNextItemAndUpdateItemState(e,n,s)]):[3,4]:[3,9];case 1:return c.sent(),[3,3];case 2:s.state=i=0&&e.uploadQueue.splice(n,1)},e.prototype._uploadNextFileForSingleFileItemAndUpdateParams=function(e,t,n){var s,a,i;return b(this,void 0,void 0,(function(){var r,l,u,o,d,c,h,p,m,f;return U(this,(function(g){switch(g.label){case 0:return r=new ee({file:n.file,channelUrl:e.url,thumbnailSizes:n.thumbnailSizes,requestId:t.requestId}),[4,this._requestQueue.send(r)];case 1:return l=g.sent(),u=l.as(te),o=u.url,d=u.fileSize,c=void 0===d?n.fileSize:d,h=u.thumbnailSizes,p=void 0===h?n.thumbnailSizes:h,m=u.requireAuth,f=void 0!==m&&m,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!==(i=n.fileSize)&&void 0!==i?i:n.file.size,n.fileUrl=o,n.fileSize=c,n.thumbnailSizes=p,n.requireAuth=f,[2]}}))}))},e.prototype._uploadNextFileForMultipleFilesItemAndUpdateParams=function(e,t,n){var s,a,i;return b(this,void 0,void 0,(function(){var r,u,o,d,c,h,p,m,f,g,y,_;return U(this,(function(v){switch(v.label){case 0:return r=t.multipleFileUploadInfo.uploadIndex,u=n.fileInfoList[r],o=new ee({file:u.file,channelUrl:e.url,thumbnailSizes:u.thumbnailSizes,requestId:t.requestId}),[4,this._requestQueue.send(o)];case 1:return d=v.sent(),c=d.as(te),h=c.url,p=c.fileSize,m=void 0===p?u.fileSize:p,f=c.thumbnailSizes,g=void 0===f?u.thumbnailSizes:f,y=c.requireAuth,_=void 0!==y&&y,u.fileName=null!==(s=u.fileName)&&void 0!==s?s:u.file.name,u.mimeType=null!==(a=u.mimeType)&&void 0!==a?a:u.file.type,u.fileSize=null!==(i=u.fileSize)&&void 0!==i?i:u.file.size,u.file=void 0,u.fileUrl=h,u.fileSize=m,u.thumbnailSizes=g,u._uploadedMetaData=l(l({},u._uploadedMetaData),{requireAuth:_,isUploaded:!0}),[2]}}))}))},e.prototype.request=function(e,t,n,s){return b(this,void 0,void 0,(function(){var a,i,r,l,u;return U(this,(function(o){return this._queueMap.has(e.url)||(a={messageQueue:[],uploadQueue:[],isResolving:!1,isResolveRequestPending:!1},this._queueMap.set(e.url,a)),i=this._queueMap.get(e.url),r=new Q,l={requestId:t,params:n,state:De.PENDING,deferred:r},function(e){return"fileInfoList"in e}(n)&&(u={uploadIndex:0,uploadCount:n.fileInfoList.length,requestHandler:s},l.multipleFileUploadInfo=u),i.messageQueue.push(l),this._uploadNextPendingItem(e),[2,r.promise]}))}))},e.prototype.cancel=function(e,t){var n,s,a=this._queueMap.get(e.url);if(a){var i=t?[a.messageQueue.find((function(e){return e.requestId===t}))]:p([],m(a.messageQueue),!1);try{for(var r=f(i),l=r.next();!l.done;l=r.next()){var u=l.value;if(u)switch(u.state){case De.PENDING:u.state=De.FAILED,u.error=w.requestCanceled,this._resolveMessageQueue(e);break;case De.UPLOADING:this._requestQueue.cancel(u.requestId)}}}catch(e){n={error:e}}finally{try{l&&!l.done&&(s=r.return)&&s.call(r)}finally{if(n)throw n.error}}}},e}();var Pe,Ce={prevResultSize:0,nextResultSize:0,isInclusive:!1,reverse:!1,messageTypeFilter:A.ALL,customTypesFilter:void 0,senderUserIdsFilter:void 0,replyType:G.NONE,includeReactions:!1,includeMetaArray:!1,includeParentMessageInfo:!1,includeThreadInfo:!1,showSubchannelMessagesOnly:!1},Re=function(e){return c("number",e.prevResultSize)&&c("number",e.nextResultSize)&&c("boolean",e.isInclusive)&&c("boolean",e.reverse)&&c("string",e.messageTypeFilter)&&h(A,e.messageTypeFilter)&&d("string",e.customTypesFilter,!0)&&d("string",e.senderUserIdsFilter,!0)&&h(G,e.replyType)&&c("boolean",e.includeMetaArray)&&c("boolean",e.includeReactions)&&c("boolean",e.includeParentMessageInfo)&&c("boolean",e.includeThreadInfo)&&c("boolean",e.showSubchannelMessagesOnly)},Le={replyType:G.NONE,includeReactions:!1,includeThreadInfo:!1,includeMetaArray:!1,includeParentMessageInfo:!1},Oe=function(e){return h(G,e.replyType)&&c("boolean",e.includeReactions)&&c("boolean",e.includeMetaArray)&&c("boolean",e.includeParentMessageInfo)&&c("boolean",e.includeThreadInfo)},ke=function(n){function s(e){var s=e.channelType,a=e.channelUrl,i=e.messageId,r=e.includeMetaArray,l=e.includeReactions,u=e.includeThreadInfo,o=e.includeParentMessageInfo,d=n.call(this)||this;return d.method=t.GET,d.path="".concat(P(s),"/").concat(encodeURIComponent(a),"/messages/").concat(encodeURIComponent(i)),d.params={is_sdk:!0,with_sorted_meta_array:r,include_reactions:l,include_thread_info:u,include_parent_message_info:o,include_poll_details:!0},d}return e(s,n),s}(a),ze=function(t){function n(e,n){var s=t.call(this,e,n)||this;return s.message=n?Ae(e,l({},n)):null,s}return e(n,t),n}(i),xe=function(n){function a(e){var a=e.channelType,i=e.channelUrl,l=e.timestamp,u=e.token,o=e.prevResultSize,d=e.nextResultSize,c=e.isInclusive,h=e.reverse,p=e.messageTypeFilter,m=e.customTypesFilter,f=e.senderUserIdsFilter,g=e.replyType,y=e.includeMetaArray,_=e.includeReactions,v=e.parentMessageId,I=e.includeThreadInfo,M=e.includeParentMessageInfo,T=e.showSubchannelMessagesOnly,S=e.checkingContinuousMessages,A=n.call(this)||this;return A.method=t.GET,A.path="".concat(P(a),"/").concat(encodeURIComponent(i),"/messages"),A.params=s(r({is_sdk:!0,prev_limit:o,next_limit:d,include:c,reverse:h,message_ts:l,message_id:u,message_type:null!=p?p:null,custom_types:m,sender_ids:f,include_reply_type:g,with_sorted_meta_array:y,include_reactions:_,parent_message_id:v,include_thread_info:I,include_parent_message_info:M,show_subchannel_message_only:T,include_poll_details:!0,checking_continuous_messages:S})),A}return e(a,n),a}(a),Qe=function(t){function n(e,n){var s=t.call(this,e,n)||this;return s.messages=n.messages.map((function(t){return Ae(e,t)})),s}return e(n,t),n}(i),Ge=function(n){function s(e){var s=e.channelType,a=e.channelUrl,i=e.timestamp,r=e.token,l=e.replyType,u=e.includeMetaArray,o=e.includeReactions,d=e.includeThreadInfo,c=e.includeParentMessageInfo,h=n.call(this)||this;return h.method=t.GET,h.path="".concat(P(s),"/").concat(encodeURIComponent(a),"/messages/changelogs"),h.params={change_ts:i,token:r,with_sorted_meta_array:u,include_reactions:o,include_thread_info:d,include_reply_type:l,include_parent_message_info:c,include_poll_details:!0},h}return e(s,n),s}(a),Be=function(t){function n(e,n){var s=t.call(this,e,n)||this;return s.updatedMessages=n.updated.map((function(t){return Ae(e,t)})),s.deletedMessagesInfo=n.deleted.map((function(e){return{messageId:e.message_id,deletedAt:e.deleted_at}})),s.hasMore=n.has_more,s.nextToken=n.next,s}return e(n,t),n}(i),je=function(n){function s(e){var s=e.channelUrl,a=e.scheduledMessageId,i=n.call(this)||this;return i.method=t.GET,i.path="".concat(B,"/").concat(encodeURIComponent(s),"/scheduled_messages/").concat(encodeURIComponent(a)),i.params={},i}return e(s,n),s}(a),He=function(t){function n(e,n){var s=t.call(this,e,n)||this;return s.message=n?Ae(e,l({},n)):null,s}return e(n,t),n}(i),We={},Ke=function(){function e(e,t){var n=t.sdkState,s=t.dispatcher,a=t.requestQueue,i=t.onlineDetector,r=t.cacheContext;this._iid=e,this._sdkState=n,this._requestQueue=a,this._dispatcher=s,this._cacheContext=r,this.fileMessageQueue=new Ne(e,{sdkState:n,dispatcher:s,requestQueue:a,onlineDetector:i,cacheContext:r}),We[e]=this}return e.of=function(e){return We[e]},e.prototype.buildMessageFromSerializedData=function(e){var t=j(e);switch(t.messageType){case _.USER:return new Ie(this._iid,Ie.payloadify(t));case _.FILE:return Te._isMultipleFilesMessageSerializedData(t)?new Te(this._iid,Te.payloadify(t)):new be(this._iid,be.payloadify(t));case _.ADMIN:return new _e(this._iid,_e.payloadify(t))}throw w.invalidParameters},e.prototype.buildUserMessageCreateParamsFromSerializedData=function(e,t){return s(r({data:t.data,customType:t.customType,mentionType:t.mentionType,mentionedUserIds:t.mentionedUserIds,mentionedUsers:t.mentionedUsers,mentionedMessageTemplate:t.mentionedMessageTemplate,metaArrays:t.metaArrays,parentMessageId:t.parentMessageId,isReplyToChannel:e.isReplyToChannel,pushNotificationDeliveryOption:e.pushNotificationDeliveryOption,appleCriticalAlertOptions:t.appleCriticalAlertOptions,reqId:t.reqId,message:t.message,translationTargetLanguages:Object.keys(t.translations),pollId:e.pollId}))},e.prototype.buildFileMessageCreateParamsFromSerializedData=function(e,t){var n;return s(r({data:t.data,customType:t.customType,mentionType:t.mentionType,mentionedUserIds:t.mentionedUserIds,mentionedUsers:t.mentionedUsers,mentionedMessageTemplate:t.mentionedMessageTemplate,metaArrays:t.metaArrays,parentMessageId:t.parentMessageId,isReplyToChannel:e.isReplyToChannel,pushNotificationDeliveryOption:e.pushNotificationDeliveryOption,appleCriticalAlertOptions:t.appleCriticalAlertOptions,reqId:t.reqId,file:e.file,fileKey:e.fileKey,fileUrl:t.plainUrl,fileName:t.name,fileSize:t.size,mimeType:t.type,thumbnailSizes:null===(n=t.thumbnails)||void 0===n?void 0:n.map((function(e){return{maxWidth:e.width,maxHeight:e.height}})),fileType:e.fileType,requireAuth:t.requireAuth}))},e.prototype.buildMultipleFilesMessageCreateParamsFromSerializedData=function(e,t){return s({data:t.data,customType:t.customType,mentionType:t.mentionType,mentionedUserIds:t.mentionedUserIds,mentionedUsers:t.mentionedUsers,mentionedMessageTemplate:t.mentionedMessageTemplate,metaArrays:t.metaArrays,parentMessageId:t.parentMessageId,isReplyToChannel:e.isReplyToChannel,pushNotificationDeliveryOption:e.pushNotificationDeliveryOption,appleCriticalAlertOptions:t.appleCriticalAlertOptions,reqId:t.reqId,fileInfoList:e.fileInfoList})},e.prototype.buildScheduledUserMessageCreateParamsFromSerializedData=function(e,t){return l(l({},this.buildUserMessageCreateParamsFromSerializedData(e,t)),{scheduledAt:e.scheduledAt})},e.prototype.buildScheduledFileMessageCreateParamsFromSerializedData=function(e,t){return l(l({},this.buildFileMessageCreateParamsFromSerializedData(e,t)),{scheduledAt:e.scheduledAt})},e.prototype.buildSenderFromSerializedData=function(e){var t=j(e);return new ce(this._iid,ce.payloadify(t))},e.prototype.getMessage=function(e){return b(this,void 0,void 0,(function(){var t,n;return U(this,(function(s){switch(s.label){case 0:return t=new ke(e),[4,this._requestQueue.send(t)];case 1:return n=s.sent(),[2,n.as(ze).message]}}))}))},e.prototype.getScheduledMessage=function(e){return b(this,void 0,void 0,(function(){var t,n;return U(this,(function(s){switch(s.label){case 0:return t=new je(e),[4,this._requestQueue.send(t)];case 1:return n=s.sent(),[2,n.as(He).message]}}))}))},e.prototype.getMessagesByMessageId=function(e,t,n,s,a){return void 0===a&&(a=H.REQUEST_MESSAGE),b(this,void 0,void 0,(function(){var i,r,u;return U(this,(function(o){switch(o.label){case 0:return i=new xe(l(l({channelType:t,channelUrl:e,token:String(n)},Ce),s)),[4,this._requestQueue.send(i)];case 1:return r=o.sent(),u=r.as(Qe).messages,this._dispatcher.dispatch(new W({messages:u,source:a})),[2,u]}}))}))},e.prototype.getMessagesByTimestamp=function(e,t,n,s,a){return void 0===a&&(a=H.REQUEST_MESSAGE),b(this,void 0,void 0,(function(){var i,r,u;return U(this,(function(o){switch(o.label){case 0:return i=new xe(l(l({channelType:t,channelUrl:e,timestamp:n},Ce),s)),[4,this._requestQueue.send(i)];case 1:return r=o.sent(),u=r.as(Qe).messages,this._dispatcher.dispatch(new W({messages:u,source:a})),[2,u]}}))}))},e.prototype._getMessagesByTimestampForCollection=function(e,t,n,s,a,i){return void 0===a&&(a=H.REQUEST_MESSAGE),b(this,void 0,void 0,(function(){var r,u,o,d;return U(this,(function(c){switch(c.label){case 0:return r=new xe(l(l(l({channelType:t,channelUrl:e,timestamp:n},Ce),s),{checkingContinuousMessages:i})),[4,this._requestQueue.send(r)];case 1:return u=c.sent(),o=u.payload,d=u.as(Qe).messages,this._dispatcher.dispatch(new W({messages:d,source:a})),[2,{messages:d,isContinuousMessages:o}]}}))}))},e.prototype.getThreadedMessagesByTimestamp=function(e,t,n,s){return void 0===s&&(s=H.REQUEST_THREADED_MESSAGE),b(this,void 0,void 0,(function(){var a,i,r,u;return U(this,(function(o){switch(o.label){case 0:return a=new xe(l(l(l({channelUrl:e.channelUrl,channelType:e.channelType,timestamp:t},ge),n),{replyType:G.ALL,parentMessageId:e.messageId,includeThreadInfo:!0})),[4,this._requestQueue.send(a)];case 1:return i=o.sent(),r=i.as(Qe).messages,(u=r.slice(1)).forEach((function(t){t.parentMessage=e})),this._dispatcher.dispatch(new W({messages:u,source:s})),[2,{parentMessage:r[0],threadedMessages:u}]}}))}))},e.prototype.getMessageChangelogs=function(e,t,n,a,i){return void 0===i&&(i=H.REQUEST_MESSAGE_CHANGELOGS),b(this,void 0,void 0,(function(){var u,o,d,c,h,p,m,f;return U(this,(function(g){switch(g.label){case 0:return u=new Ge(s(r(l(l({channelType:t,channelUrl:e,timestamp:"number"==typeof n?n:null,token:"string"==typeof n?n:null},Le),a)))),[4,this._requestQueue.send(u)];case 1:return o=g.sent(),d=o.as(Be),c=d.updatedMessages,h=d.deletedMessagesInfo,p=d.hasMore,m=d.nextToken,f=h.map((function(e){return e.messageId})),c.length>0&&this._dispatcher.dispatch(new W({messages:c,source:i})),f.length>0&&this._dispatcher.dispatch(new K({messageIds:f,source:i})),[2,{updatedMessages:c,deletedMessageIds:f,hasMore:p,token:m}]}}))}))},e}(),Ve=function(){function e(){this._onPending=V,this._onFailed=V,this._onSucceeded=V}return e.prototype._trigger=function(e,t){switch(null==t?void 0:t.sendingStatus){case T.PENDING:0===t.errorCode&&this._onPending(t);break;case T.FAILED:case T.CANCELED:this._onFailed(e,t.scheduledInfo?null:t);break;case T.SCHEDULED:case T.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}(),Xe=function(t){function n(e,n){var s=t.call(this,e)||this;s.targetMessageId=0;var a=n.thread_info,i=n.parent_message_id,r=n.channel_url,l=n.channel_type;return a&&c("object",a)&&c("number",i)&&c("string",r)&&c("string",l)&&(s.threadInfo=new ne(e,a),s.targetMessageId=i,s.channelUrl=r,s.channelType=l),s}return e(n,t),n}(o),$e={channelUrl:"",channelType:I.BASE,messageId:0,includeReactions:!1,includeMetaArray:!1,includeParentMessageInfo:!1,includeThreadInfo:!1},Je=function(n){function s(e){var s=e.channelCustomType,a=e.keyword,i=e.limit,r=e.reverse,l=e.exactMatch,u=e.channelUrl,o=e.order,d=e.messageTimestampFrom,c=e.messageTimestampTo,h=e.advancedQuery,p=e.targetFields,m=e.nextToken,f=n.call(this)||this;return f.method=t.GET,f.path="".concat(X,"/messages"),f.params={custom_type:s,query:a,limit:i,reverse:r,exact_match:l,channel_url:u,message_ts_from:d,message_ts_to:c,sort_field:o,advanced_query:h,target_fields:p,after:m},f}return e(s,n),s}(a),Ye=function(t){function n(e,n){var s=t.call(this,e,n)||this;return s.messages=n.results.map((function(t){return Ae(e,t)})),s.hasNext=n.has_next,s.nextToken=n.end_cursor,s.totalCount=n.total_count,s}return e(n,t),n}(i);!function(e){e.SCORE="score",e.TIMESTAMP="ts"}(Pe||(Pe={}));var Ze=function(t){function n(e,n){var s,a,i,r,l,u,o,d,c,h=this;return(h=t.call(this,e,n)||this).keyword="",h.reverse=!1,h.exactMatch=!1,h.channelUrl="",h.channelCustomType="",h.messageTimestampFrom=null,h.messageTimestampTo=null,h.order=Pe.SCORE,h.advancedQuery=!1,h.targetFields=null,h._nextToken="",h.totalCount=-1,h.keyword=n.keyword,h.reverse=null!==(s=n.reverse)&&void 0!==s&&s,h.exactMatch=null!==(a=n.exactMatch)&&void 0!==a&&a,h.channelUrl=null!==(i=n.channelUrl)&&void 0!==i?i:"",h.channelCustomType=null!==(r=n.channelCustomType)&&void 0!==r?r:"",h.messageTimestampFrom=null!==(l=n.messageTimestampFrom)&&void 0!==l?l:null,h.messageTimestampTo=null!==(u=n.messageTimestampTo)&&void 0!==u?u:null,h.order=null!==(o=n.order)&&void 0!==o?o:Pe.SCORE,h.advancedQuery=null!==(d=n.advancedQuery)&&void 0!==d&&d,h.targetFields=null!==(c=n.targetFields)&&void 0!==c?c:null,h}return e(n,t),n.prototype._validate=function(){return t.prototype._validate.call(this)&&c("string",this.keyword)&&this.keyword.length>0&&c("boolean",this.reverse)&&c("boolean",this.exactMatch)&&c("string",this.channelUrl)&&c("string",this.channelCustomType)&&(c("number",this.messageTimestampFrom)||null===this.messageTimestampFrom)&&(c("number",this.messageTimestampTo)||null===this.messageTimestampTo)&&h(Pe,this.order)&&c("boolean",this.advancedQuery)&&d("string",this.targetFields,!0)},n.prototype.next=function(){return b(this,void 0,void 0,(function(){var e,t,n,s,a,i,u,o;return U(this,(function(d){switch(d.label){case 0:return this._validate()?this._isLoading?[3,3]:this._hasNext?(this._isLoading=!0,e=q.of(this._iid).requestQueue,t=new Je(r(l(l({},this),{nextToken:this._nextToken?this._nextToken:null}))),[4,e.send(t)]):[3,2]:[3,5];case 1:return n=d.sent(),s=n.as(Ye),a=s.messages,i=s.hasNext,u=s.nextToken,o=s.totalCount,this._nextToken=u,this._hasNext=i,this._isLoading=!1,this.totalCount=o,[2,a];case 2:return[2,[]];case 3:throw w.queryInProgress;case 4:return[3,6];case 5:throw w.invalidParameters;case 6:return[2]}}))}))},n}($),et=function(t){function n(e,n,s,a){var i,r,l,u,o,d,c,h,p,m,f=this;return(f=t.call(this,e,n,s,a)||this).reverse=!1,f.messageTypeFilter=A.ALL,f.customTypesFilter=null,f.senderUserIdsFilter=null,f.replyType=G.NONE,f.includeMetaArray=!1,f.includeReactions=!1,f.includeParentMessageInfo=!1,f.includeThreadInfo=!1,f.showSubchannelMessagesOnly=!1,f._edge=Number.MAX_SAFE_INTEGER,f.reverse=null!==(i=a.reverse)&&void 0!==i&&i,f.messageTypeFilter=null!==(r=a.messageTypeFilter)&&void 0!==r?r:A.ALL,f.customTypesFilter=null!==(l=a.customTypesFilter)&&void 0!==l?l:null,f.senderUserIdsFilter=null!==(u=a.senderUserIdsFilter)&&void 0!==u?u:null,f.replyType=null!==(o=a.replyType)&&void 0!==o?o:G.NONE,f.includeMetaArray=null!==(d=a.includeMetaArray)&&void 0!==d&&d,f.includeReactions=null!==(c=a.includeReactions)&&void 0!==c&&c,f.includeParentMessageInfo=null!==(h=a.includeParentMessageInfo)&&void 0!==h&&h,f.includeThreadInfo=null!==(p=a.includeThreadInfo)&&void 0!==p&&p,f.showSubchannelMessagesOnly=null!==(m=a.showSubchannelMessagesOnly)&&void 0!==m&&m,f}return e(n,t),n.prototype._validate=function(){return t.prototype._validate.call(this)&&c("boolean",this.reverse)&&h(A,this.messageTypeFilter)&&h(G,this.replyType)&&d("string",this.customTypesFilter,!0)&&d("string",this.senderUserIdsFilter,!0)&&c("boolean",this.includeMetaArray)&&c("boolean",this.includeReactions)&&c("boolean",this.includeParentMessageInfo)&&c("boolean",this.includeThreadInfo)&&c("boolean",this.showSubchannelMessagesOnly)},n.prototype.load=function(){return b(this,void 0,void 0,(function(){var e;return U(this,(function(t){switch(t.label){case 0:return this._validate()?this._isLoading?[3,3]:this._hasNext?(this._isLoading=!0,[4,Ke.of(this._iid).getMessagesByTimestamp(this.channelUrl,this.channelType,this._edge,r({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,p([Number.MAX_SAFE_INTEGER],m(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 w.queryInProgress;case 4:return[3,6];case 5:throw w.invalidParameters;case 6:return[2]}}))}))},n}(J),tt={channelUrl:"",scheduledMessageId:0},nt=function(t){function n(){var e=null!==t&&t.apply(this,arguments)||this;return e._onFileUploaded=V,e}return e(n,t),n.prototype._triggerOnFileUploaded=function(e,t,n,s){this._onFileUploaded(e,t,n,s)},n.prototype.onFileUploaded=function(e){return this._onFileUploaded=e,this},n.prototype.onPending=function(e){return t.prototype.onPending.call(this,e),this},n.prototype.onFailed=function(e){return t.prototype.onFailed.call(this,e),this},n.prototype.onSucceeded=function(e){return t.prototype.onSucceeded.call(this,e),this},n}(Ve),st=function(t){function n(){var e=null!==t&&t.apply(this,arguments)||this;return e.name="message",e}return e(n,t),n.prototype.init=function(e,n){var s=n.sdkState,a=n.dispatcher,i=n.sessionManager,r=n.requestQueue,l=n.logger,u=n.onlineDetector,o=n.cacheContext;t.prototype.init.call(this,e,{sdkState:s,dispatcher:a,sessionManager:i,requestQueue:r,logger:l,onlineDetector:u,cacheContext:o}),this._manager=new Ke(e,{sdkState:s,dispatcher:a,requestQueue:r,onlineDetector:u,cacheContext:o})},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 b(this,void 0,void 0,(function(){var t;return U(this,(function(n){return t=l(l({},$e),e),E(function(e){return c("string",e.channelUrl)&&h(I,e.channelType)&&c("number",e.messageId)&&c("boolean",e.includeReactions,!0)&&c("boolean",e.includeMetaArray,!0)&&c("boolean",e.includeParentMessageInfo,!0)&&c("boolean",e.includeThreadInfo,!0)}(t)).throw(w.invalidParameters),[2,this._manager.getMessage(t)]}))}))},n.prototype.getScheduledMessage=function(e){return b(this,void 0,void 0,(function(){var t;return U(this,(function(n){return t=l(l({},tt),e),E(function(e){return c("string",e.channelUrl)&&""!==e.channelUrl&&c("number",e.scheduledMessageId)&&e.scheduledMessageId>0}(t)).throw(w.invalidParameters),[2,this._manager.getScheduledMessage(t)]}))}))},n}(Y);export{de as A,pe as B,be as F,ae as I,st as M,ue as O,ve as P,ie as R,me as S,fe as T,Ie as U,Ze as a,Te as b,Ke as c,le as d,et as e,ce as f,nt as g,Ve as h,Ce as i,Le as j,Oe as k,se as l,we as m,Se as n,te as o,Ae as p,ee as q,_e as r,Xe as s,Pe as t,oe as u,Re as v,re as w,Z as x,ne as y,Me as z}; diff --git a/lib/__bundle-8cd94b6f.js b/lib/__bundle-8cd94b6f.js deleted file mode 100644 index 8858aa5..0000000 --- a/lib/__bundle-8cd94b6f.js +++ /dev/null @@ -1 +0,0 @@ -import{_ as e,A as t,Z as n,e as s,f as a,h as i,g as r,U as l,$ as u,m as o,a as d,K as c,q as h,r as p,J as m,T as f,a0 as g,a1 as y,a2 as _,O as v,a3 as I,a4 as T,a5 as M,a6 as S,b as U,c as b,s as A,S as E,a7 as w,V as F,a8 as q,a9 as D,aa as P,ab as N,W as C,w as R,x as O,ac as L,ad as k,i as z,ae as x,af as Q,ag as G,t as B,ah as j,ai as H,aj as W,n as K,ak as V,B as X,al as J,am as Z}from"./__bundle-a8606dd4.js";var $,Y=function(a){function i(e){var i=a.call(this)||this;if(i.method=t.POST,i.path="".concat(n),i.params=s({file:e.file,channel_url:e.channelUrl}),e.thumbnailSizes)for(var r=0;r0&&d("number",r)&&(this.key=a,this.userIds=i,this.updatedAt=r);var l={};try{for(var u=m(this.userIds),c=u.next();!c.done;c=u.next()){l[c.value]=this.updatedAt}}catch(e){t={error:e}}finally{try{c&&!c.done&&(n=u.return)&&n.call(u)}finally{if(t)throw t.error}}this._version=l}return Object.defineProperty(e.prototype,"isEmpty",{get:function(){return 0===this.userIds.length},enumerable:!1,configurable:!0}),e.payloadify=function(e){return e?s({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 $.ADD:t<0&&this.userIds.push(e.userId);break;case $.DELETE:t>=0&&this.userIds.splice(t,1)}this._version[e.userId]=e.updatedAt}this.updatedAt=Math.max(this.updatedAt,e.updatedAt)}},e}(),re=function(){function e(e){this.key=e.key,this.value=o("string",e.value)?h([],p(e.value),!1):[]}return e.payloadify=function(e){var t;return e?s({key:e.key,value:null!==(t=e.value)&&void 0!==t?t:[]}):null},e}(),le=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?s({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}(),ue=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 le(e["og:image"]))}return e.payloadify=function(e){return e?s({"og:title":e.title,"og:url":e.url,"og:description":e.description,"og:image":e.defaultImage?le.payloadify(e.defaultImage):null}):null},e}(),oe=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.prototype.serialize=function(){return{name:this.name,volume:this.volume}},e.payloadify=function(e){return e?s({name:e.name,volume:e.volume}):null},e}(),de=function(t){function n(e,n){var s=t.call(this,e,n)||this;return s.role=null,s.isBlockedByMe=!1,s.role=c(f,n.role)?n.role:f.NONE,n.hasOwnProperty("is_blocked_by_me")&&(s.isBlockedByMe=n.is_blocked_by_me),s}return e(n,t),n.payloadify=function(e){return e?s(r(r({},t.payloadify.call(this,e)),{role:e.role,is_blocked_by_me:e.isBlockedByMe})):null},n}(l);!function(e){e.PENDING="pending",e.SENT="sent",e.FAILED="failed",e.CANCELED="canceled"}(ne||(ne={})),function(e){e.PENDING="pending",e.IN_QUEUE="in_queue",e.SENT="sent",e.FAILED="failed",e.CANCELED="canceled",e.REMOVED="removed"}(se||(se={}));var ce=function(e){switch(e){case y.BASE:return"";case y.USER:return"MESG";case y.FILE:return"FILE";case y.ADMIN:return"ADMM"}},he=function(t){function n(e,n){var s,a,i,r,u,o,d,h,p,m,f,g,_,T,M,S=this;(S=t.call(this,e)||this).channelUrl=null,S.channelType=v.BASE,S.messageId=0,S.parentMessageId=null,S.parentMessage=null,S.silent=!1,S.isOperatorMessage=!1,S.messageType=y.BASE,S.data=null,S.customType=null,S.mentionType=null,S.mentionedUsers=[],S.mentionedUserIds=[],S.mentionedMessageTemplate=null,S.threadInfo=null,S.reactions=[],S.metaArrays=[],S.ogMetaData=null,S.appleCriticalAlertOptions=null,S.createdAt=0,S.updatedAt=0,S.scheduledInfo=null,S.extendedMessage={},S._isContinuousMessages=!1,S._scheduledStatus=null,S.messageId=null!==(a=null!==(s=n.msg_id)&&void 0!==s?s:n.message_id)&&void 0!==a?a:0,S.channelUrl=n.channel_url,S.channelType=c(v,n.channel_type)?n.channel_type:v.GROUP,n.channel&&(n.channel.channel_url&&(S.channelUrl=n.channel.channel_url),n.channel.channel_type&&(S.channelType=n.channel.channel_type)),S.parentMessageId=null!==(i="string"==typeof n.parent_message_id?parseInt(n.parent_message_id):n.parent_message_id)&&void 0!==i?i:0,S.data=null!==(r=n.data)&&void 0!==r?r:"",S.customType=null!==(u=n.custom_type)&&void 0!==u?u:"",S.mentionType=c(I,n.mention_type)?n.mention_type:null;var U=n.mentioned_users;S.mentionedUsers=U?U.map((function(e){return new l(S._iid,e)})):null;var b=n.mentioned_user_ids;S.mentionedUserIds=null!=b?b:null,S.mentionedUsers&&!S.mentionedUserIds&&(S.mentionedUserIds=S.mentionedUsers.map((function(e){return e.userId}))),S.mentionedMessageTemplate=null!==(o=n.mentioned_message_template)&&void 0!==o?o:"",S.threadInfo=n.thread_info?new te(S._iid,n.thread_info):null,S.reactions=n.reactions?n.reactions.map((function(e){return new ie(e)})):[];for(var A=null!==(d=n.metaarray)&&void 0!==d?d:{},E=null!==(h=n.metaarray_key_order)&&void 0!==h?h:Object.keys(A).sort((function(e,t){return e.localeCompare(t)})),w=0;w=t)return this.parentMessage=e,!0}return!1},n}(u),pe=function(t){function n(e,n){var s,a,i,r,l=this;if((l=t.call(this,e,n)||this).sender=null,l.reqId="",l.replyToChannel=!1,l.sendingStatus=null,l.errorCode=0,l.sender=n.user?new de(l._iid,n.user):n.sender_id,l.reqId=null!==(a=null!==(s=n.req_id)&&void 0!==s?s:n.request_id)&&void 0!==a?a:"",l.replyToChannel=null!==(i=n.is_reply_to_channel)&&void 0!==i&&i,n.request_state&&c(T,n.request_state)&&(l.sendingStatus=n.request_state),!l.sendingStatus)if(l.messageId>0)l.sendingStatus=T.SUCCEEDED;else if(l.scheduledInfo)switch(l._scheduledStatus=n.scheduled_status,n.scheduled_status){case se.SENT:case se.IN_QUEUE:l.sendingStatus=T.SUCCEEDED;break;case se.PENDING:l.sendingStatus=T.SCHEDULED;break;case se.FAILED:case se.REMOVED:l.sendingStatus=T.FAILED;break;case se.CANCELED:l.sendingStatus=T.CANCELED}else l.sendingStatus=T.PENDING;return l.errorCode=null!==(r=n.error_code)&&void 0!==r?r:0,l}return e(n,t),n.payloadify=function(e){return e?s(r(r({},t.payloadify.call(this,e)),{user:de.payloadify(e.sender),req_id:e.reqId,is_reply_to_channel:e.replyToChannel,request_state:e.sendingStatus,error_code:e.errorCode})):null},Object.defineProperty(n.prototype,"isResendable",{get:function(){return this.sendingStatus===T.FAILED&&M(this.errorCode)},enumerable:!1,configurable:!0}),n.prototype.isIdentical=function(e){return this.messageId>0&&e.messageId>0?this.messageId===e.messageId:this.reqId===e.reqId},n}(he),me=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?s({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}(),fe={prevResultSize:0,nextResultSize:0,isInclusive:!1,reverse:!1,messageTypeFilter:S.ALL,customTypesFilter:null,senderUserIdsFilter:null,includeReactions:!1,includeMetaArray:!1,includeParentMessageInfo:!1},ge=function(e){return d("number",e.prevResultSize)&&d("number",e.nextResultSize)&&d("boolean",e.isInclusive)&&d("boolean",e.reverse)&&d("string",e.messageTypeFilter)&&c(S,e.messageTypeFilter)&&o("string",e.customTypesFilter,!0)&&o("string",e.senderUserIdsFilter,!0)&&d("boolean",e.includeMetaArray)&&d("boolean",e.includeReactions)&&d("boolean",e.includeParentMessageInfo)},ye=function(t){function n(e,n){var a,i,l,u,o=this;if((o=t.call(this,e,n)||this).message=null,o.translations={},o.message=null!==(a=n.message)&&void 0!==a?a:"",o.messageType=y.ADMIN,o.translations=null!==(i=n.translations)&&void 0!==i?i:{},n.parent_message_info){var d=n.parent_message_info,c=s(r(r({},d),{message_id:o.parentMessageId,channel_url:o.channelUrl,channel_type:o.channelType,file:d.file,url:null===(l=d.file)||void 0===l?void 0:l.url,require_auth:null===(u=d.file)||void 0===u?void 0:u.require_auth}));o.parentMessage=Se(e,c)}return o}return e(n,t),n.payloadify=function(e){return e?s(r(r({},t.payloadify.call(this,e)),{message:e.message,translations:e.translations,parent_message_info:t._getParentMessageInfoPayload.call(this,e.parentMessage)})):null},n.prototype.getThreadedMessagesByTimestamp=function(e,t){return U(this,void 0,void 0,(function(){var n;return b(this,(function(s){switch(s.label){case 0:return n=r(r({},fe),t),A(this.messageId>0&&d("number",e)&&ge(n)).throw(E.invalidParameters),[4,We.of(this._iid).getThreadedMessagesByTimestamp(this,e,n)];case 1:return[2,s.sent()]}}))}))},n}(he),_e=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")&&d("object",e.detail)&&!Array.isArray(e.detail)&&(this.detail=e.detail)}return e.payloadify=function(e){return e?s({type:e.type,vendor:e.vendor,detail:e.detail}):null},e}(),ve=function(t){function n(e,n){var a,i,l,u,o,d,c,h=this;if((h=t.call(this,e,n)||this).message="",h.messageParams=null,h.translations={},h.translationTargetLanguages=[],h.messageSurvivalSeconds=-1,h.plugins=[],h._poll=null,h.message=n.message,h.messageType=y.USER,h.translations=null!==(l=n.translations)&&void 0!==l?l:{},h.translationTargetLanguages=null!==(u=n.target_langs)&&void 0!==u?u:[],0===Object.keys(h.translations).length&&h.translationTargetLanguages.length>0)try{for(var p=m(h.translationTargetLanguages),f=p.next();!f.done;f=p.next()){var g=f.value;h.translations[g]=""}}catch(e){a={error:e}}finally{try{f&&!f.done&&(i=p.return)&&i.call(p)}finally{if(a)throw a.error}}if(h.messageSurvivalSeconds=null!==(o=n.message_survival_seconds)&&void 0!==o?o:-1,h.plugins=n.plugins?n.plugins.map((function(e){return new _e(e)})):[],h._poll=n.poll?new w(h._iid,n.poll):null,n.parent_message_info){var _=n.parent_message_info,v=s(r(r({},_),{created_at:_.ts,message_id:h.parentMessageId,channel_url:h.channelUrl,channel_type:h.channelType,file:_.file,url:null===(d=_.file)||void 0===d?void 0:d.url,require_auth:null===(c=_.file)||void 0===c?void 0:c.require_auth}));h.parentMessage=Se(e,s(v))}return h}return e(n,t),n.payloadify=function(e){return e?s(r(r({},t.payloadify.call(this,e)),{message:e.message,translations:e.translations,message_survival_seconds:e.messageSurvivalSeconds,plugins:e.plugins.map((function(e){return _e.payloadify(e)})),poll:w.payloadify(e._poll),parent_message_info:t._getParentMessageInfoPayload.call(this,e.parentMessage)})):null},n.prototype.getThreadedMessagesByTimestamp=function(e,t){return U(this,void 0,void 0,(function(){var n;return b(this,(function(s){switch(s.label){case 0:return n=r(r({},fe),t),A(this.messageId>0&&d("number",e)&&ge(n)).throw(E.invalidParameters),[4,We.of(this._iid).getThreadedMessagesByTimestamp(this,e,n)];case 1:return[2,s.sent()]}}))}))},n.prototype.applyPoll=function(e){return!(this._poll&&this._poll.id===e.id&&this._poll.updatedAt>e.updatedAt)&&(this._poll=e,!0)},Object.defineProperty(n.prototype,"poll",{get:function(){return this._poll},enumerable:!1,configurable:!0}),n}(pe),Ie=function(t){function n(e,n){var s,a,i,l,u=this;(u=t.call(this,e)||this).plainUrl="",u.fileName=null,u.mimeType=null,u.fileSize=0,u.thumbnails=[],u._requireAuth=!1,u.plainUrl=n.url,u.fileName=null!==(s=n.file_name)&&void 0!==s?s:null,u.mimeType=null!==(a=n.file_type)&&void 0!==a?a:null,u.fileSize=null!==(i=n.file_size)&&void 0!==i?i:0;var o=F.of(u._iid).sessionManager;return u._requireAuth=null!==(l=n.require_auth)&&void 0!==l&&l,u.thumbnails=n.thumbnails?n.thumbnails.map((function(e){return new me(r(r({},e),{url:"".concat(e.url.split("?auth=")[0]).concat(u._requireAuth?"?auth=".concat(o.ekey):"")}))})):[],u}return e(n,t),n.payloadify=function(e){var t;return{url:e.plainUrl,file_name:e.fileName,file_type:e.mimeType,file_size:e.fileSize,thumbnails:null===(t=e.thumbnails)||void 0===t?void 0:t.map((function(e){return{url:e.url,width:e.width,height:e.height,real_width:e.realWidth,real_height:e.realHeight}})),require_auth:e._requireAuth}},Object.defineProperty(n.prototype,"url",{get:function(){var e=F.of(this._iid).sessionManager;return this._requireAuth?"".concat(this.plainUrl,"?auth=").concat(e.ekey):this.plainUrl},enumerable:!1,configurable:!0}),n}(u),Te=function(t){function n(e,n){var s,a,i,l,u,o=this;if((o=t.call(this,e,n)||this).messageParams=null,o.fileInfoList=[],o.messageSurvivalSeconds=-1,o.messageType=y.FILE,o.fileInfoList=null!==(a=null===(s=n.files)||void 0===s?void 0:s.map((function(t){return new Ie(e,t)})))&&void 0!==a?a:[],o.messageSurvivalSeconds=null!==(i=n.message_survival_seconds)&&void 0!==i?i:-1,n.parent_message_info){var d=n.parent_message_info,c=r(r({},d),{message_id:o.parentMessageId,channel_url:o.channelUrl,channel_type:o.channelType,file:d.file,url:null===(l=d.file)||void 0===l?void 0:l.url,require_auth:null===(u=d.file)||void 0===u?void 0:u.require_auth});o.parentMessage=Se(e,c)}return o}return e(n,t),n.prototype.getThreadedMessagesByTimestamp=function(e,t){return U(this,void 0,void 0,(function(){var n;return b(this,(function(s){switch(s.label){case 0:return n=r(r({},fe),t),A(this.messageId>0&&d("number",e)&&ge(n)).throw(E.invalidParameters),[4,We.of(this._iid).getThreadedMessagesByTimestamp(this,e,n)];case 1:return[2,s.sent()]}}))}))},n.payloadify=function(e){return e?s(r(r({},t.payloadify.call(this,e)),{files:e.fileInfoList&&e.fileInfoList&&Array.isArray(e.fileInfoList)?e.fileInfoList.map((function(e){return Ie.payloadify(e)})):void 0,message_survival_seconds:e.messageSurvivalSeconds,parent_message_info:t._getParentMessageInfoPayload.call(this,e.parentMessage)})):null},n._isMultipleFilesMessagePayload=function(e){var t=e.files;return Array.isArray(t)&&t.length>=2},n._isMultipleFilesMessageSerializedData=function(e){var t=e.fileInfoList;return Array.isArray(t)},n}(pe),Me=function(e){if(e)switch(e.messageType){case y.USER:return ve.payloadify(e);case y.FILE:return Ue.payloadify(e);case y.ADMIN:return ye.payloadify(e)}return null},Se=function(e,t){switch(t.type){case"MESG":return new ve(e,t);case"FILE":return Te._isMultipleFilesMessagePayload(t)?new Te(e,t):new Ue(e,t);case"ADMM":case"BRDM":return new ye(e,t)}return null},Ue=function(t){function n(e,n){var a,i,l,u,o,d,c,h,p,m,f,g,_,v,I,T=this;(T=t.call(this,e,n)||this).messageParams=null,T.plainUrl="",T.requireAuth=!1,T.name=null,T.size=0,T.type=null,T.thumbnails=[],T.messageSurvivalSeconds=-1,T.messageType=y.FILE;var M=null!==(a=n.file)&&void 0!==a?a:null;T.plainUrl=(null!==(l=null!==(i=null==M?void 0:M.url)&&void 0!==i?i:n.url)&&void 0!==l?l:"").split("?auth=")[0],T.name=null!==(o=null!==(u=null==M?void 0:M.name)&&void 0!==u?u:n.name)&&void 0!==o?o:"File",T.size=null!==(c=null!==(d=null==M?void 0:M.size)&&void 0!==d?d:n.size)&&void 0!==c?c:0,T.data=null!==(p=null!==(h=null==M?void 0:M.data)&&void 0!==h?h:n.custom)&&void 0!==p?p:"",T.type=M?null!==(m=M.type)&&void 0!==m?m:"":null!==(f=n.type)&&void 0!==f?f:"";var S=F.of(T._iid).sessionManager;if(T.requireAuth=null!==(g=n.require_auth)&&void 0!==g&&g,T.thumbnails=n.thumbnails?n.thumbnails.map((function(e){return new me(r(r({},e),{url:"".concat(e.url.split("?auth=")[0]).concat(T.requireAuth?"?auth=".concat(S.ekey):"")}))})):[],T.messageSurvivalSeconds=null!==(_=n.message_survival_seconds)&&void 0!==_?_:-1,n.parent_message_info){var U=n.parent_message_info,b=s(r(r({},U),{message_id:T.parentMessageId,channel_url:T.channelUrl,channel_type:T.channelType,file:U.file,url:null===(v=U.file)||void 0===v?void 0:v.url,require_auth:null===(I=U.file)||void 0===I?void 0:I.require_auth}));T.parentMessage=Se(e,b)}return T}return e(n,t),n.payloadify=function(e){var n;return e?s(r(r({},t.payloadify.call(this,e)),{url:e.plainUrl,require_auth:e.requireAuth,file:{name:e.name,size:e.size,type:e.type,data:e.data},thumbnails:null===(n=e.thumbnails)||void 0===n?void 0:n.map((function(e){return{url:e.url,width:e.width,height:e.height,real_width:e.realWidth,real_height:e.realHeight}})),message_survival_seconds:e.messageSurvivalSeconds,parent_message_info:t._getParentMessageInfoPayload.call(this,e.parentMessage)})):null},Object.defineProperty(n.prototype,"url",{get:function(){var e=F.of(this._iid).sessionManager;return this.requireAuth?"".concat(this.plainUrl,"?auth=").concat(e.ekey):this.plainUrl},enumerable:!1,configurable:!0}),n.prototype.getThreadedMessagesByTimestamp=function(e,t){return U(this,void 0,void 0,(function(){var n;return b(this,(function(s){switch(s.label){case 0:return n=r(r({},fe),t),A(this.messageId>0&&d("number",e)&&ge(n)).throw(E.invalidParameters),[4,We.of(this._iid).getThreadedMessagesByTimestamp(this,e,n)];case 1:return[2,s.sent()]}}))}))},n}(pe),be=function(t){function n(e){var n,a,i,r=[];return e.mentionType===I.USERS&&(e.mentionedUserIds?r=e.mentionedUserIds:e.mentionedUsers&&(r=e.mentionedUsers.map((function(e){return e.userId})))),t.call(this,{code:"FILE",ackRequired:!0,payload:s({channel_url:e.channelUrl,files:Fe(e.files),url:e.url,name:null!==(n=e.fileName)&&void 0!==n?n:"",type:null!==(a=e.mimeType)&&void 0!==a?a:"",size:null!==(i=e.fileSize)&&void 0!==i?i:0,custom:e.data,custom_type:e.customType,thumbnails:e.thumbnailSizes,require_auth:e.requireAuth,metaarray:e.metaArrays,mention_type:e.mentionType,mentioned_user_ids:r,push_option:e.pushNotificationDeliveryOption&&e.pushNotificationDeliveryOption!==q.DEFAULT?e.pushNotificationDeliveryOption:void 0,apple_critical_alert_options:e.appleCriticalAlertOptions,silent:e.silent,reply_to_channel:e.isReplyToChannel,parent_message_id:e.parentMessageId>0?e.parentMessageId:null,req_id:e.reqId,pin_message:e.isPinnedMessage})})||this}return e(n,t),n}(D),Ae=function(n){function a(e){var a,i,r=this;r=n.call(this)||this;var l=[];return e.mentionType===I.USERS&&(e.mentionedUserIds?l=e.mentionedUserIds:e.mentionedUsers&&(l=e.mentionedUsers.map((function(e){return e.userId})))),r.method=t.POST,r.path="".concat(P(e.channelType),"/").concat(encodeURIComponent(e.channelUrl),"/messages"),r.params=s({message_type:y.FILE,user_id:e.userId,files:Fe(e.files),url:e.fileUrl,mention_type:e.mentionType,mentioned_user_ids:l,file_name:e.fileName,file_size:e.fileSize,file_type:e.mimeType,data:e.data,custom_type:e.customType,thumbnails:null===(a=e.thumbnailSizes)||void 0===a?void 0:a.map((function(e){return me.payloadify(e)})),require_auth:e.requireAuth,sorted_metaarray:null===(i=e.metaArrays)||void 0===i?void 0:i.map((function(e){return re.payloadify(e)})),push_option:e.pushNotificationDeliveryOption,parent_message_id:e.parentMessageId>0?e.parentMessageId:null,apple_critical_alert_options:oe.payloadify(e.appleCriticalAlertOptions),reply_to_channel:e.isReplyToChannel,req_id:e.reqId,pin_message:e.isPinnedMessage}),r}return e(a,n),a}(a),Ee=function(t){function n(e,n,s){var a,i,r,l=this;(l=t.call(this,e,"FILE",s)||this).message=s.files&&s.files.length>=2?new Te(e,s):new Ue(e,s);var u=F.of(e).sdkState;return l.isMentioned=N(l.message.mentionType,null!==(a=l.message.mentionedUserIds)&&void 0!==a?a:null===(i=l.message.mentionedUsers)||void 0===i?void 0:i.map((function(e){return e.userId})),u.userId),l.forceUpdateLastMessage=null!==(r=s.force_update_last_message)&&void 0!==r&&r,l}return e(n,t),n}(C),we=function(t){function n(e,n){var s,a,i=this;(i=t.call(this,e,n)||this).message=n.files&&n.files.length>=2?new Te(e,n):new Ue(e,n);var r=F.of(e).sdkState;return i.isMentioned=N(i.message.mentionType,null!==(s=i.message.mentionedUserIds)&&void 0!==s?s:i.message.mentionedUsers.map((function(e){return e.userId})),r.userId),i.forceUpdateLastMessage=null!==(a=n.force_update_last_message)&&void 0!==a&&a,i}return e(n,t),n}(i);function Fe(e){return null==e?void 0:e.map((function(e){var t,n;return s({url:e.fileUrl,file_name:e.fileName,file_type:e.mimeType,file_size:e.fileSize,thumbnails:null===(t=e.thumbnailSizes)||void 0===t?void 0:t.map((function(e){return me.payloadify(e)})),require_auth:null===(n=e._uploadedMetaData)||void 0===n?void 0:n.requireAuth})}))}var qe;!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"}(qe||(qe={}));var De=function(){function e(e,t){var n=t.sdkState,s=t.dispatcher,a=t.requestQueue,i=t.onlineDetector,r=t.cacheContext,l=this;this._queueMap=new Map,this._connectionState=null,this._onlineDetector=null,this._iid=e,this._sdkState=n,this._requestQueue=a,this._cacheContext=r,this._dispatcher=s,this._dispatcher.on((function(e){e instanceof R&&(l._connectionState=e.stateType)})),this._onlineDetector=i}return Object.defineProperty(e.prototype,"_shouldSendThroughWebSocket",{get:function(){return this._connectionState===O.CONNECTED||this._connectionState===O.CONNECTING||this._connectionState===O.RECONNECTING},enumerable:!1,configurable:!0}),e.prototype._sendFileMessage=function(e,t){return U(this,void 0,void 0,(function(){var n,s,a;return b(this,(function(i){switch(i.label){case 0:return n=this._createSendFileMessageRequestParams(e,t),this._shouldSendThroughWebSocket?(s=new be(n),[4,this._requestQueue.send(s)]):[3,2];case 1:return a=i.sent(),[2,a.as(Ee).message];case 2:return s=new Ae(r(r({},n),{userId:this._sdkState.userId})),[4,this._requestQueue.send(s)];case 3:return a=i.sent(),[2,a.as(we).message]}}))}))},e.prototype._createSendFileMessageRequestParams=function(e,t){var n=r(r({},t.params),{channelUrl:e.url,channelType:e.channelType,reqId:t.requestId,url:""});if(t.multipleFileUploadInfo){var s=t.params;n.files=s.fileInfoList}else{s=t.params;n.url=s.fileUrl,n.requireAuth=s.requireAuth}return n},e.prototype._resolveMessageQueue=function(e){return U(this,void 0,void 0,(function(){var t,n,s,a,i,r,l,u,o,d,c,h;return b(this,(function(p){switch(p.label){case 0:if(!(t=this._queueMap.get(e.url)))return[3,21];if(t.isResolving)return[3,20];t.isResolving=!0,n=[],s=!0,p.label=1;case 1:p.trys.push([1,15,16,17]),a=m(t.messageQueue),i=a.next(),p.label=2;case 2:if(i.done)return[3,14];switch(r=i.value,r.state){case qe.PENDING:case qe.UPLOADING:return[3,3];case qe.UPLOADED:return[3,4];case qe.FAILED:return[3,12]}return[3,13];case 3:return s=!1,n.push(r),[3,13];case 4:if(!s)return[3,10];p.label=5;case 5:return p.trys.push([5,8,,9]),r.state=qe.SENDING,[4,this._sendFileMessage(e,r)];case 6:return l=p.sent(),r.deferred.resolve(l),[4,k(100)];case 7:return p.sent(),[3,9];case 8:return u=p.sent(),r.deferred.reject(u),[3,9];case 9:return[3,11];case 10:n.push(r),p.label=11;case 11:return[3,13];case 12:return r.deferred.reject(r.error.code===L.REQUEST_CANCELED?E.fileUploadCanceled:r.error),[3,13];case 13:return i=a.next(),[3,2];case 14:return[3,17];case 15:return o=p.sent(),c={error:o},[3,17];case 16:try{i&&!i.done&&(h=a.return)&&h.call(a)}finally{if(c)throw c.error}return[7];case 17:return d=t.isResolveRequestPending,t.messageQueue=n,t.isResolving=!1,t.isResolveRequestPending=!1,d?[4,this._resolveMessageQueue(e)]:[3,19];case 18:p.sent(),p.label=19;case 19:return[3,21];case 20:t.isResolveRequestPending=!0,p.label=21;case 21:return[2]}}))}))},e.prototype._uploadNextPendingItem=function(e){var t;return U(this,void 0,void 0,(function(){var n,s,a,i,r,l,u,o,d;return b(this,(function(c){switch(c.label){case 0:return n=this._queueMap.get(e.url),(s=n.messageQueue.find((function(e){return e.state===qe.PENDING})))?s.multipleFileUploadInfo?(a=s.multipleFileUploadInfo,i=a.uploadIndex,r=a.uploadCount,l=a.requestHandler,d=s.params,u=d.fileInfoList[i],!z(u.file)||(null===(t=u._uploadedMetaData)||void 0===t?void 0:t.isUploaded)?[3,2]:[4,this._tryUploadNextItemAndUpdateItemState(e,n,s)]):[3,4]:[3,9];case 1:return c.sent(),[3,3];case 2:s.state=i=0&&e.uploadQueue.splice(n,1)},e.prototype._uploadNextFileForSingleFileItemAndUpdateParams=function(e,t,n){var s,a,i;return U(this,void 0,void 0,(function(){var r,l,u,o,d,c,h,p,m,f;return b(this,(function(g){switch(g.label){case 0:return r=new Y({file:n.file,channelUrl:e.url,thumbnailSizes:n.thumbnailSizes,requestId:t.requestId}),[4,this._requestQueue.send(r)];case 1:return l=g.sent(),u=l.as(ee),o=u.url,d=u.fileSize,c=void 0===d?n.fileSize:d,h=u.thumbnailSizes,p=void 0===h?n.thumbnailSizes:h,m=u.requireAuth,f=void 0!==m&&m,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!==(i=n.fileSize)&&void 0!==i?i:n.file.size,n.fileUrl=o,n.fileSize=c,n.thumbnailSizes=p,n.requireAuth=f,[2]}}))}))},e.prototype._uploadNextFileForMultipleFilesItemAndUpdateParams=function(e,t,n){var s,a,i;return U(this,void 0,void 0,(function(){var l,u,o,d,c,h,p,m,f,g,y,_;return b(this,(function(v){switch(v.label){case 0:return l=t.multipleFileUploadInfo.uploadIndex,u=n.fileInfoList[l],o=new Y({file:u.file,channelUrl:e.url,thumbnailSizes:u.thumbnailSizes,requestId:t.requestId}),[4,this._requestQueue.send(o)];case 1:return d=v.sent(),c=d.as(ee),h=c.url,p=c.fileSize,m=void 0===p?u.fileSize:p,f=c.thumbnailSizes,g=void 0===f?u.thumbnailSizes:f,y=c.requireAuth,_=void 0!==y&&y,u.fileName=null!==(s=u.fileName)&&void 0!==s?s:u.file.name,u.mimeType=null!==(a=u.mimeType)&&void 0!==a?a:u.file.type,u.fileSize=null!==(i=u.fileSize)&&void 0!==i?i:u.file.size,u.file=null,u.fileUrl=h,u.fileSize=m,u.thumbnailSizes=g,u._uploadedMetaData=r(r({},u._uploadedMetaData),{requireAuth:_,isUploaded:!0}),[2]}}))}))},e.prototype.request=function(e,t,n,s){return void 0===s&&(s=null),U(this,void 0,void 0,(function(){var a,i,r,l,u;return b(this,(function(o){return this._queueMap.has(e.url)||(a={messageQueue:[],uploadQueue:[],isResolving:!1,isResolveRequestPending:!1},this._queueMap.set(e.url,a)),i=this._queueMap.get(e.url),r=new x,l={requestId:t,params:n,state:qe.PENDING,deferred:r},function(e){return"fileInfoList"in e}(n)&&(u={uploadIndex:0,uploadCount:n.fileInfoList.length,requestHandler:s},l.multipleFileUploadInfo=u),i.messageQueue.push(l),this._uploadNextPendingItem(e),[2,r.promise]}))}))},e.prototype.cancel=function(e,t){var n,s;void 0===t&&(t=null);var a=this._queueMap.get(e.url);if(a){var i=t?[a.messageQueue.find((function(e){return e.requestId===t}))]:h([],p(a.messageQueue),!1);try{for(var r=m(i),l=r.next();!l.done;l=r.next()){var u=l.value;if(u)switch(u.state){case qe.PENDING:u.state=qe.FAILED,u.error=E.requestCanceled,this._resolveMessageQueue(e);break;case qe.UPLOADING:this._requestQueue.cancel(u.requestId)}}}catch(e){n={error:e}}finally{try{l&&!l.done&&(s=r.return)&&s.call(r)}finally{if(n)throw n.error}}}},e}();var Pe,Ne={prevResultSize:0,nextResultSize:0,isInclusive:!1,reverse:!1,messageTypeFilter:S.ALL,customTypesFilter:null,senderUserIdsFilter:null,replyType:Q.NONE,includeReactions:!1,includeMetaArray:!1,includeParentMessageInfo:!1,includeThreadInfo:!1,showSubchannelMessagesOnly:!1},Ce=function(e){return d("number",e.prevResultSize)&&d("number",e.nextResultSize)&&d("boolean",e.isInclusive)&&d("boolean",e.reverse)&&d("string",e.messageTypeFilter)&&c(S,e.messageTypeFilter)&&o("string",e.customTypesFilter,!0)&&o("string",e.senderUserIdsFilter,!0)&&c(Q,e.replyType)&&d("boolean",e.includeMetaArray)&&d("boolean",e.includeReactions)&&d("boolean",e.includeParentMessageInfo)&&d("boolean",e.includeThreadInfo)&&d("boolean",e.showSubchannelMessagesOnly)},Re={replyType:Q.NONE,includeReactions:!1,includeThreadInfo:!1,includeMetaArray:!1,includeParentMessageInfo:!1},Oe=function(e){return c(Q,e.replyType)&&d("boolean",e.includeReactions)&&d("boolean",e.includeMetaArray)&&d("boolean",e.includeParentMessageInfo)&&d("boolean",e.includeThreadInfo)},Le=function(n){function s(e){var s=e.channelType,a=e.channelUrl,i=e.messageId,r=e.includeMetaArray,l=e.includeReactions,u=e.includeThreadInfo,o=e.includeParentMessageInfo,d=n.call(this)||this;return d.method=t.GET,d.path="".concat(P(s),"/").concat(encodeURIComponent(a),"/messages/").concat(encodeURIComponent(i)),d.params={is_sdk:!0,with_sorted_meta_array:r,include_reactions:l,include_thread_info:u,include_parent_message_info:o,include_poll_details:!0},d}return e(s,n),s}(a),ke=function(t){function n(e,n){var s=t.call(this,e,n)||this;return s.message=n?Se(e,r({},n)):null,s}return e(n,t),n}(i),ze=function(n){function a(e){var a=e.channelType,i=e.channelUrl,r=e.timestamp,l=void 0===r?null:r,u=e.token,o=void 0===u?null:u,d=e.prevResultSize,c=e.nextResultSize,h=e.isInclusive,p=e.reverse,m=e.messageTypeFilter,f=e.customTypesFilter,g=e.senderUserIdsFilter,y=e.replyType,_=e.includeMetaArray,v=e.includeReactions,I=e.parentMessageId,T=e.includeThreadInfo,M=e.includeParentMessageInfo,S=e.showSubchannelMessagesOnly,U=e.checkingContinuousMessages,b=n.call(this)||this;return b.method=t.GET,b.path="".concat(P(a),"/").concat(encodeURIComponent(i),"/messages"),b.params=s({is_sdk:!0,prev_limit:d,next_limit:c,include:h,reverse:p,message_ts:l,message_id:o,message_type:null!=m?m:null,custom_types:f,sender_ids:g,include_reply_type:y,with_sorted_meta_array:_,include_reactions:v,parent_message_id:I,include_thread_info:T,include_parent_message_info:M,show_subchannel_message_only:S,include_poll_details:!0,checking_continuous_messages:U}),b}return e(a,n),a}(a),xe=function(t){function n(e,n){var s=t.call(this,e,n)||this;return s.messages=n.messages.map((function(t){return Se(e,t)})),s}return e(n,t),n}(i),Qe=function(n){function s(e){var s=e.channelType,a=e.channelUrl,i=e.timestamp,r=e.token,l=e.replyType,u=e.includeMetaArray,o=e.includeReactions,d=e.includeThreadInfo,c=e.includeParentMessageInfo,h=n.call(this)||this;return h.method=t.GET,h.path="".concat(P(s),"/").concat(encodeURIComponent(a),"/messages/changelogs"),h.params={change_ts:i,token:r,with_sorted_meta_array:u,include_reactions:o,include_thread_info:d,include_reply_type:l,include_parent_message_info:c,include_poll_details:!0},h}return e(s,n),s}(a),Ge=function(t){function n(e,n){var s=t.call(this,e,n)||this;return s.updatedMessages=n.updated.map((function(t){return Se(e,t)})),s.deletedMessagesInfo=n.deleted.map((function(e){return{messageId:e.message_id,deletedAt:e.deleted_at}})),s.hasMore=n.has_more,s.nextToken=n.next,s}return e(n,t),n}(i),Be=function(n){function s(e){var s=e.channelUrl,a=e.scheduledMessageId,i=n.call(this)||this;return i.method=t.GET,i.path="".concat(G,"/").concat(encodeURIComponent(s),"/scheduled_messages/").concat(encodeURIComponent(a)),i.params={},i}return e(s,n),s}(a),je=function(t){function n(e,n){var s=t.call(this,e,n)||this;return s.message=n?Se(e,r({},n)):null,s}return e(n,t),n}(i),He={},We=function(){function e(e,t){var n=t.sdkState,s=t.dispatcher,a=t.requestQueue,i=t.onlineDetector,r=t.cacheContext;this._iid=e,this._sdkState=n,this._requestQueue=a,this._dispatcher=s,this._cacheContext=r,this.fileMessageQueue=new De(e,{sdkState:n,dispatcher:s,requestQueue:a,onlineDetector:i,cacheContext:r}),He[e]=this}return e.of=function(e){return He[e]},e.prototype.buildMessageFromSerializedData=function(e){var t=B(e);switch(t.messageType){case y.USER:return new ve(this._iid,ve.payloadify(t));case y.FILE:return Te._isMultipleFilesMessageSerializedData(t)?new Te(this._iid,Te.payloadify(t)):new Ue(this._iid,Ue.payloadify(t));case y.ADMIN:return new ye(this._iid,ye.payloadify(t))}return null},e.prototype.buildUserMessageCreateParamsFromSerializedData=function(e,t){return s({data:t.data,customType:t.customType,mentionType:t.mentionType,mentionedUserIds:t.mentionedUserIds,mentionedUsers:t.mentionedUsers,mentionedMessageTemplate:t.mentionedMessageTemplate,metaArrays:t.metaArrays,parentMessageId:t.parentMessageId,isReplyToChannel:e.isReplyToChannel,pushNotificationDeliveryOption:e.pushNotificationDeliveryOption,appleCriticalAlertOptions:t.appleCriticalAlertOptions,reqId:t.reqId,message:t.message,translationTargetLanguages:Object.keys(t.translations),pollId:e.pollId})},e.prototype.buildFileMessageCreateParamsFromSerializedData=function(e,t){var n;return s({data:t.data,customType:t.customType,mentionType:t.mentionType,mentionedUserIds:t.mentionedUserIds,mentionedUsers:t.mentionedUsers,mentionedMessageTemplate:t.mentionedMessageTemplate,metaArrays:t.metaArrays,parentMessageId:t.parentMessageId,isReplyToChannel:e.isReplyToChannel,pushNotificationDeliveryOption:e.pushNotificationDeliveryOption,appleCriticalAlertOptions:t.appleCriticalAlertOptions,reqId:t.reqId,file:e.file,fileKey:e.fileKey,fileUrl:t.plainUrl,fileName:t.name,fileSize:t.size,mimeType:t.type,thumbnailSizes:null===(n=t.thumbnails)||void 0===n?void 0:n.map((function(e){return{maxWidth:e.width,maxHeight:e.height}})),fileType:e.fileType,requireAuth:t.requireAuth})},e.prototype.buildMultipleFilesMessageCreateParamsFromSerializedData=function(e,t){return s({data:t.data,customType:t.customType,mentionType:t.mentionType,mentionedUserIds:t.mentionedUserIds,mentionedUsers:t.mentionedUsers,mentionedMessageTemplate:t.mentionedMessageTemplate,metaArrays:t.metaArrays,parentMessageId:t.parentMessageId,isReplyToChannel:e.isReplyToChannel,pushNotificationDeliveryOption:e.pushNotificationDeliveryOption,appleCriticalAlertOptions:t.appleCriticalAlertOptions,reqId:t.reqId,fileInfoList:e.fileInfoList})},e.prototype.buildScheduledUserMessageCreateParamsFromSerializedData=function(e,t){return r(r({},this.buildUserMessageCreateParamsFromSerializedData(e,t)),{scheduledAt:e.scheduledAt})},e.prototype.buildScheduledFileMessageCreateParamsFromSerializedData=function(e,t){return r(r({},this.buildFileMessageCreateParamsFromSerializedData(e,t)),{scheduledAt:e.scheduledAt})},e.prototype.buildSenderFromSerializedData=function(e){var t=B(e);return new de(this._iid,de.payloadify(t))},e.prototype.getMessage=function(e){return U(this,void 0,void 0,(function(){var t,n;return b(this,(function(s){switch(s.label){case 0:return t=new Le(e),[4,this._requestQueue.send(t)];case 1:return n=s.sent(),[2,n.as(ke).message]}}))}))},e.prototype.getScheduledMessage=function(e){return U(this,void 0,void 0,(function(){var t,n;return b(this,(function(s){switch(s.label){case 0:return t=new Be(e),[4,this._requestQueue.send(t)];case 1:return n=s.sent(),[2,n.as(je).message]}}))}))},e.prototype.getMessagesByMessageId=function(e,t,n,s,a){return void 0===a&&(a=j.REQUEST_MESSAGE),U(this,void 0,void 0,(function(){var i,l,u;return b(this,(function(o){switch(o.label){case 0:return i=new ze(r(r({channelType:t,channelUrl:e,token:String(n)},Ne),s)),[4,this._requestQueue.send(i)];case 1:return l=o.sent(),u=l.as(xe).messages,this._dispatcher.dispatch(new H({messages:u,source:a})),[2,u]}}))}))},e.prototype.getMessagesByTimestamp=function(e,t,n,s,a){return void 0===a&&(a=j.REQUEST_MESSAGE),U(this,void 0,void 0,(function(){var i,l,u;return b(this,(function(o){switch(o.label){case 0:return i=new ze(r(r({channelType:t,channelUrl:e,timestamp:n},Ne),s)),[4,this._requestQueue.send(i)];case 1:return l=o.sent(),u=l.as(xe).messages,this._dispatcher.dispatch(new H({messages:u,source:a})),[2,u]}}))}))},e.prototype._getMessagesByTimestampForCollection=function(e,t,n,s,a,i){return void 0===a&&(a=j.REQUEST_MESSAGE),U(this,void 0,void 0,(function(){var l,u,o,d;return b(this,(function(c){switch(c.label){case 0:return l=new ze(r(r(r({channelType:t,channelUrl:e,timestamp:n},Ne),s),{checkingContinuousMessages:i})),[4,this._requestQueue.send(l)];case 1:return u=c.sent(),o=u.payload,d=u.as(xe).messages,this._dispatcher.dispatch(new H({messages:d,source:a})),[2,{messages:d,isContinuousMessages:o}]}}))}))},e.prototype.getThreadedMessagesByTimestamp=function(e,t,n,s){return void 0===s&&(s=j.REQUEST_THREADED_MESSAGE),U(this,void 0,void 0,(function(){var a,i,l,u;return b(this,(function(o){switch(o.label){case 0:return a=new ze(r(r(r({channelUrl:e.channelUrl,channelType:e.channelType,timestamp:t},fe),n),{replyType:Q.ALL,parentMessageId:e.messageId,includeThreadInfo:!0})),[4,this._requestQueue.send(a)];case 1:return i=o.sent(),l=i.as(xe).messages,(u=l.slice(1)).forEach((function(t){t.parentMessage=e})),this._dispatcher.dispatch(new H({messages:u,source:s})),[2,{parentMessage:l[0],threadedMessages:u}]}}))}))},e.prototype.getMessageChangelogs=function(e,t,n,a,i){return void 0===i&&(i=j.REQUEST_MESSAGE_CHANGELOGS),U(this,void 0,void 0,(function(){var l,u,o,d,c,h,p,m;return b(this,(function(f){switch(f.label){case 0:return l=new Qe(s(r(r({channelType:t,channelUrl:e,timestamp:"number"==typeof n?n:null,token:"string"==typeof n?n:null},Re),a))),[4,this._requestQueue.send(l)];case 1:return u=f.sent(),o=u.as(Ge),d=o.updatedMessages,c=o.deletedMessagesInfo,h=o.hasMore,p=o.nextToken,m=c.map((function(e){return e.messageId})),d.length>0&&this._dispatcher.dispatch(new H({messages:d,source:i})),m.length>0&&this._dispatcher.dispatch(new W({messageIds:m,source:i})),[2,{updatedMessages:d,deletedMessageIds:m,hasMore:h,token:p}]}}))}))},e}(),Ke=function(){function e(){this._onPending=K,this._onFailed=K,this._onSucceeded=K}return e.prototype._trigger=function(e,t){switch(t.sendingStatus){case T.PENDING:0===t.errorCode&&this._onPending(t);break;case T.FAILED:case T.CANCELED:this._onFailed(e,t.scheduledInfo?null:t);break;case T.SCHEDULED:case T.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}(),Ve=function(t){function n(e,n){var s=t.call(this,e)||this;s.threadInfo=null,s.targetMessageId=0,s.channelUrl=null,s.channelType=null;var a=n.thread_info,i=n.parent_message_id,r=n.channel_url,l=n.channel_type;return a&&d("object",a)&&d("number",i)&&d("string",r)&&d("string",l)&&(s.threadInfo=new te(e,a),s.targetMessageId=i,s.channelUrl=r,s.channelType=l),s}return e(n,t),n}(u),Xe={channelUrl:null,channelType:null,messageId:0,includeReactions:!1,includeMetaArray:!1,includeParentMessageInfo:!1,includeThreadInfo:!1},Je=function(n){function s(e){var s=e.channelCustomType,a=e.keyword,i=e.limit,r=e.reverse,l=e.exactMatch,u=e.channelUrl,o=e.order,d=e.messageTimestampFrom,c=e.messageTimestampTo,h=e.advancedQuery,p=e.targetFields,m=e.nextToken,f=n.call(this)||this;return f.method=t.GET,f.path="".concat(V,"/messages"),f.params={custom_type:s,query:a,limit:i,reverse:r,exact_match:l,channel_url:u,message_ts_from:d,message_ts_to:c,sort_field:o,advanced_query:h,target_fields:p,after:m},f}return e(s,n),s}(a),Ze=function(t){function n(e,n){var s=t.call(this,e,n)||this;return s.messages=n.results.map((function(t){return Se(e,t)})),s.hasNext=n.has_next,s.nextToken=n.end_cursor,s.totalCount=n.total_count,s}return e(n,t),n}(i);!function(e){e.SCORE="score",e.TIMESTAMP="ts"}(Pe||(Pe={}));var $e=function(t){function n(e,n){var s,a,i,r,l,u,o,d,c,h=this;return(h=t.call(this,e,n)||this).keyword="",h.reverse=!1,h.exactMatch=!1,h.channelUrl="",h.channelCustomType="",h.messageTimestampFrom=null,h.messageTimestampTo=null,h.order=Pe.SCORE,h.advancedQuery=!1,h.targetFields=null,h._nextToken="",h.totalCount=-1,h.keyword=n.keyword,h.reverse=null!==(s=n.reverse)&&void 0!==s&&s,h.exactMatch=null!==(a=n.exactMatch)&&void 0!==a&&a,h.channelUrl=null!==(i=n.channelUrl)&&void 0!==i?i:"",h.channelCustomType=null!==(r=n.channelCustomType)&&void 0!==r?r:"",h.messageTimestampFrom=null!==(l=n.messageTimestampFrom)&&void 0!==l?l:null,h.messageTimestampTo=null!==(u=n.messageTimestampTo)&&void 0!==u?u:null,h.order=null!==(o=n.order)&&void 0!==o?o:Pe.SCORE,h.advancedQuery=null!==(d=n.advancedQuery)&&void 0!==d&&d,h.targetFields=null!==(c=n.targetFields)&&void 0!==c?c:null,h}return e(n,t),n.prototype._validate=function(){return t.prototype._validate.call(this)&&d("string",this.keyword)&&this.keyword.length>0&&d("boolean",this.reverse)&&d("boolean",this.exactMatch)&&d("string",this.channelUrl)&&d("string",this.channelCustomType)&&(d("number",this.messageTimestampFrom)||null===this.messageTimestampFrom)&&(d("number",this.messageTimestampTo)||null===this.messageTimestampTo)&&c(Pe,this.order)&&d("boolean",this.advancedQuery)&&o("string",this.targetFields,!0)},n.prototype.next=function(){return U(this,void 0,void 0,(function(){var e,t,n,s,a,i,l,u;return b(this,(function(o){switch(o.label){case 0:return this._validate()?this._isLoading?[3,3]:this._hasNext?(this._isLoading=!0,e=F.of(this._iid).requestQueue,t=new Je(r(r({},this),{nextToken:this._nextToken?this._nextToken:null})),[4,e.send(t)]):[3,2]:[3,5];case 1:return n=o.sent(),s=n.as(Ze),a=s.messages,i=s.hasNext,l=s.nextToken,u=s.totalCount,this._nextToken=l,this._hasNext=i,this._isLoading=!1,this.totalCount=u,[2,a];case 2:return[2,[]];case 3:throw E.queryInProgress;case 4:return[3,6];case 5:throw E.invalidParameters;case 6:return[2]}}))}))},n}(X),Ye=function(t){function n(e,n,s,a){var i,r,l,u,o,d,c,h,p,m,f=this;return(f=t.call(this,e,n,s,a)||this).reverse=!1,f.messageTypeFilter=S.ALL,f.customTypesFilter=null,f.senderUserIdsFilter=null,f.replyType=Q.NONE,f.includeMetaArray=!1,f.includeReactions=!1,f.includeParentMessageInfo=!1,f.includeThreadInfo=!1,f.showSubchannelMessagesOnly=!1,f._edge=Number.MAX_SAFE_INTEGER,f.reverse=null!==(i=a.reverse)&&void 0!==i&&i,f.messageTypeFilter=null!==(r=a.messageTypeFilter)&&void 0!==r?r:S.ALL,f.customTypesFilter=null!==(l=a.customTypesFilter)&&void 0!==l?l:null,f.senderUserIdsFilter=null!==(u=a.senderUserIdsFilter)&&void 0!==u?u:null,f.replyType=null!==(o=a.replyType)&&void 0!==o?o:Q.NONE,f.includeMetaArray=null!==(d=a.includeMetaArray)&&void 0!==d&&d,f.includeReactions=null!==(c=a.includeReactions)&&void 0!==c&&c,f.includeParentMessageInfo=null!==(h=a.includeParentMessageInfo)&&void 0!==h&&h,f.includeThreadInfo=null!==(p=a.includeThreadInfo)&&void 0!==p&&p,f.showSubchannelMessagesOnly=null!==(m=a.showSubchannelMessagesOnly)&&void 0!==m&&m,f}return e(n,t),n.prototype._validate=function(){return t.prototype._validate.call(this)&&d("boolean",this.reverse)&&c(S,this.messageTypeFilter)&&c(Q,this.replyType)&&o("string",this.customTypesFilter,!0)&&o("string",this.senderUserIdsFilter,!0)&&d("boolean",this.includeMetaArray)&&d("boolean",this.includeReactions)&&d("boolean",this.includeParentMessageInfo)&&d("boolean",this.includeThreadInfo)&&d("boolean",this.showSubchannelMessagesOnly)},n.prototype.load=function(){return U(this,void 0,void 0,(function(){var e;return b(this,(function(t){switch(t.label){case 0:return this._validate()?this._isLoading?[3,3]:this._hasNext?(this._isLoading=!0,[4,We.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,h([Number.MAX_SAFE_INTEGER],p(e.map((function(e){return e.createdAt}))),!1)),this._hasNext=e.length>=this.limit,this._isLoading=!1,[2,e];case 2:return[2,[]];case 3:throw E.queryInProgress;case 4:return[3,6];case 5:throw E.invalidParameters;case 6:return[2]}}))}))},n}(J),et={channelUrl:null,scheduledMessageId:0},tt=function(t){function n(){var e=null!==t&&t.apply(this,arguments)||this;return e._onFileUploaded=K,e}return e(n,t),n.prototype._triggerOnFileUploaded=function(e,t,n,s){this._onFileUploaded(e,t,n,s)},n.prototype.onFileUploaded=function(e){return this._onFileUploaded=e,this},n.prototype.onPending=function(e){return t.prototype.onPending.call(this,e),this},n.prototype.onFailed=function(e){return t.prototype.onFailed.call(this,e),this},n.prototype.onSucceeded=function(e){return t.prototype.onSucceeded.call(this,e),this},n}(Ke),nt=function(t){function n(){var e=null!==t&&t.apply(this,arguments)||this;return e.name="message",e}return e(n,t),n.prototype.init=function(e,n){var s=n.sdkState,a=n.dispatcher,i=n.sessionManager,r=n.requestQueue,l=n.logger,u=n.onlineDetector,o=n.cacheContext;t.prototype.init.call(this,e,{sdkState:s,dispatcher:a,sessionManager:i,requestQueue:r,logger:l,onlineDetector:u,cacheContext:o}),this._manager=new We(e,{sdkState:s,dispatcher:a,requestQueue:r,onlineDetector:u,cacheContext:o})},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 U(this,void 0,void 0,(function(){var t;return b(this,(function(n){return t=r(r({},Xe),e),A(function(e){return d("string",e.channelUrl)&&d("string",e.channelType)&&c(v,e.channelType)&&d("number",e.messageId)&&d("boolean",e.includeMetaArray)&&d("boolean",e.includeParentMessageInfo)&&d("boolean",e.includeThreadInfo)}(t)).throw(E.invalidParameters),[2,this._manager.getMessage(t)]}))}))},n.prototype.getScheduledMessage=function(e){return U(this,void 0,void 0,(function(){var t;return b(this,(function(n){return t=r(r({},et),e),A(function(e){return d("string",e.channelUrl)&&d("number",e.scheduledMessageId)}(t)).throw(E.invalidParameters),[2,this._manager.getScheduledMessage(t)]}))}))},n}(Z);export{oe as A,he as B,Ue as F,se as I,nt as M,le as O,_e as P,ae as R,pe as S,me as T,ve as U,$e as a,Te as b,We as c,re as d,Ye as e,de as f,tt as g,Ke as h,Ne as i,Re as j,Oe as k,ne as l,Ee as m,Me as n,ee as o,Se as p,Y as q,ye as r,Ve as s,Pe as t,ue as u,Ce as v,ie as w,$ as x,te as y,Ie as z}; diff --git a/lib/__bundle-ad3243e0.js b/lib/__bundle-8fdac8b9.js similarity index 71% rename from lib/__bundle-ad3243e0.js rename to lib/__bundle-8fdac8b9.js index 3098185..f5a56b2 100644 --- a/lib/__bundle-ad3243e0.js +++ b/lib/__bundle-8fdac8b9.js @@ -1 +1 @@ -import{_ as t,U as i}from"./__bundle-a8606dd4.js";var s=function(i){function s(t,s){var r,u=this;return(u=i.call(this,t,s)||this).isMuted=!1,u.isMuted=null!==(r=s.is_muted)&&void 0!==r&&r,u}return t(s,i),s}(i);export{s as P}; +import{_ as t,U as i}from"./__bundle-75942676.js";var s=function(i){function s(t,s){var r,u=this;return(u=i.call(this,t,s)||this).isMuted=!1,u.isMuted=null!==(r=s.is_muted)&&void 0!==r&&r,u}return t(s,i),s}(i);export{s as P}; diff --git a/lib/__bundle-a8606dd4.js b/lib/__bundle-a8606dd4.js deleted file mode 100644 index aabc9ba..0000000 --- a/lib/__bundle-a8606dd4.js +++ /dev/null @@ -1 +0,0 @@ -var e=function(t,n){return e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n])},e(t,n)};function t(t,n){if("function"!=typeof n&&null!==n)throw new TypeError("Class extends value "+String(n)+" is not a constructor or null");function r(){this.constructor=t}e(t,n),t.prototype=null===n?Object.create(n):(r.prototype=n.prototype,new r)}var n=function(){return n=Object.assign||function(e){for(var t,n=1,r=arguments.length;n0&&i[i.length-1])||6!==a[0]&&2!==a[0])){s=0;continue}if(3===a[0]&&(!i||a[1]>i[0]&&a[1]=e.length&&(e=void 0),{value:e&&e[r++],done:!e}}};throw new TypeError(t?"Object is not iterable.":"Symbol.iterator is not defined.")}function a(e,t){var n="function"==typeof Symbol&&e[Symbol.iterator];if(!n)return e;var r,i,o=n.call(e),s=[];try{for(;(void 0===t||t-- >0)&&!(r=o.next()).done;)s.push(r.value)}catch(e){i={error:e}}finally{try{r&&!r.done&&(n=o.return)&&n.call(o)}finally{if(i)throw i.error}}return s}function c(e,t,n){if(n||2===arguments.length)for(var r,i=0,o=t.length;i0&&b.indexOf(e)>=0},O=function(e){return e>0&&m.indexOf(e)>=0},A=function(e,t){if(void 0===t&&(t=!1),t&&null===e)return!0;var n=w("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},N=function(e,t){if(e===t)return!0;if(null==e||null==t)return!1;if(e.length!==t.length)return!1;for(var n=c([],a(e),!1).sort(),r=c([],a(t),!1).sort(),i=0;i=1e3&&e<=9e3&&(this._typingIndicatorThrottle=e)},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"websocketResponseTimeout",{get:function(){return this._websocketResponseTimeout},set:function(e){w("number",e)&&e>=5e3&&e<=3e4&&(this._websocketResponseTimeout=e)},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"sessionTokenRefreshTimeout",{get:function(){return this._sessionTokenRefreshTimeout},set:function(e){w("number",e)&&(e<60?e=60:e>1800&&(e=1800),this._sessionTokenRefreshTimeout=e)},enumerable:!1,configurable:!0}),e}(),R={encrypt:function(e){return e},decrypt:function(e){return e}},D=function(){function e(e){var t=e.store;this._preference=new Map,this._store=t}return e.prototype._savePreferenceKeys=function(){return i(this,void 0,void 0,(function(){return o(this,(function(e){switch(e.label){case 0:return[4,this._store.set({key:this._keysAddress,value:c([],a(this._preference.keys()),!1)})];case 1:return e.sent(),[2]}}))}))},e.prototype.init=function(e,t){var n;return void 0===t&&(t=1),i(this,void 0,void 0,(function(){var r,i,a,c,u,l,h,d,_,f;return o(this,(function(o){switch(o.label){case 0:return this._version=t,this._keysAddress=e,r="".concat(e,".metadata.version"),[4,this._store.get(r)];case 1:return i=o.sent(),[4,this._store.get(e)];case 2:return a=null!==(n=o.sent())&&void 0!==n?n:[],!i||i.versiont.channel.messageCollectionLastAccessedAt?1:-1},this._maxSize=Math.max(r,64),a?(this._clearOrder=o,this._customClearOrderComparator=a):this._clearOrder=g.MESSAGE_COLLECTION_ACCESSED_AT}return Object.defineProperty(e.prototype,"maxSize",{get:function(){return this._maxSize},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"clearOrder",{get:function(){return this._clearOrder},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"clearOrderComparator",{get:function(){var e;return this._clearOrder===g.MESSAGE_COLLECTION_ACCESSED_AT?this._clearOrderComparatorUseMessageCollectionAccessedAt:null!==(e=this._customClearOrderComparator)&&void 0!==e?e:this._clearOrderComparatorUseMessageCollectionAccessedAt},enumerable:!1,configurable:!0}),e}(),Z=function(){function e(){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}(),V=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)}))},H=function(){function e(e){var t=e.container;this._container={},this._container=t,this.key=V()}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}(),W=function(){function e(){this._container={}}return e.prototype.on=function(e,t){return new H({container:this._container}).on(e,t)},e.prototype.once=function(e,t){return new H({container:this._container}).once(e,t)},e.prototype.dispatch=function(e,t){var n,r,i=this._container[e];if(i){var o=[];try{for(var a=s(i.keys()),c=a.next();!c.done;c=a.next()){var u=c.value,l=i.get(u);l.handler(t),l.occurence>0&&(l.occurence--,0===l.occurence&&o.push(u))}}catch(e){n={error:e}}finally{try{c&&!c.done&&(r=a.return)&&r.call(a)}finally{if(n)throw n.error}}o.forEach((function(e){return i.delete(e)}))}},e}(),Q=function(){function e(){this._dispatcher=new W}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}(),Y=function(){},X=function(e){var t={};return e&&Object.keys(e).forEach((function(n){void 0===e[n]||Number.isNaN(e[n])||null===e[n]||(t[n]=e[n])})),t};!function(e){e.BASE="base",e.GROUP="group",e.OPEN="open"}(x||(x={})),function(e){e.OPERATOR="operator",e.NONE="none"}(M||(M={})),function(e){e.BASE="base",e.USER="user",e.FILE="file",e.ADMIN="admin"}(P||(P={})),function(e){e.ALL="",e.USER="MESG",e.FILE="FILE",e.ADMIN="ADMM"}(U||(U={})),function(e){e.USER="MESG",e.FILE="FILE",e.ADMIN="ADMM"}(z||(z={})),function(e){e.USERS="users",e.CHANNEL="channel"}(F||(F={})),function(e){e.ALL="all",e.NONE="none",e.ONLY_REPLY_TO_CHANNEL="only_reply_to_channel"}(q||(q={})),function(e){e.DEFAULT="default",e.SUPPRESS="suppress"}(G||(G={})),function(e){e.PENDING="pending",e.SCHEDULED="scheduled",e.SUCCEEDED="succeeded",e.FAILED="failed",e.CANCELED="canceled"}(j||(j={}));var J,$="v3",ee="/".concat($,"/users"),te="/".concat($,"/storage/file"),ne="/".concat($,"/group_channels"),re="/".concat($,"/sdk/group_channels"),ie="/".concat($,"/open_channels"),oe="/".concat($,"/sdk/open_channels"),se="/".concat($,"/search"),ae="/".concat($,"/report"),ce="/".concat($,"/emojis"),ue="/".concat($,"/emoji_categories"),le="/".concat($,"/polls"),he="/".concat($,"/scheduled_messages"),de="/".concat($,"/sdk/ui_kit/configuration"),_e="/".concat($,"/sdk/statistics"),fe=function(e){switch(e){case x.GROUP:return ne;case x.OPEN:return ie;default:return null}},pe=function(e){switch(e){case x.GROUP:return"".concat(ae,"/group_channels");case x.OPEN:return"".concat(ae,"/open_channels");default:return null}},ge=function(e,t,n){var r,i;switch(e){case F.CHANNEL:return!0;case F.USERS:if(t)try{for(var o=s(t),a=o.next();!a.done;a=o.next()){if(a.value===n)return!0}}catch(e){r={error:e}}finally{try{a&&!a.done&&(i=o.return)&&i.call(o)}finally{if(r)throw r.error}}}return!1},ve=function(e,t,n){var r=ge(e.mentionType,e.mentionedUserIds,n),i=ge(t.mentionType,t.mentionedUserIds,n);return!r&&i?1:r&&!i?-1:0},Ee=function(e,t,n){var r,i=t||new FormData;for(var o in e)if(o in e){var s=e[o],a=n?"".concat(n,"[").concat(o,"]"):o;A(s)?i.append(a,s,null!==(r=s.name)&&void 0!==r?r:"filename"):"object"!=typeof s||null===s||Array.isArray(s)||s instanceof Blob?i.append(a,String(s)):i=Ee(s,i,a)}return i};!function(e){e.GET="GET",e.POST="POST",e.PUT="PUT",e.DELETE="DELETE"}(J||(J={}));var be,me=function(e){function n(){var t=null!==e&&e.apply(this,arguments)||this;return t.params={},t.requireAuth=!0,t.headers={},t.requestId=V(),t}return t(n,e),n.prototype.encodeParams=function(e){var t=this;return null==e||""===e?encodeURIComponent(""):Array.isArray(e)?e.map((function(e){return t.encodeParams(e)})).join(","):"object"==typeof e?encodeURIComponent(JSON.stringify(e)):encodeURIComponent(String(e))},Object.defineProperty(n.prototype,"query",{get:function(){var e=this,t=X(this.params);return"?".concat(Object.keys(t).map((function(n){return"".concat(encodeURIComponent(n),"=").concat(e.encodeParams(t[n]))})).join("&"))},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"payload",{get:function(){var e=X(this.params);return Object.keys(e).some((function(t){return A(e[t])}))?Ee(e):JSON.stringify(e)},enumerable:!1,configurable:!0}),n}(Y),ye=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}(Y),we=function(e){function n(t){var n=e.call(this)||this;return n.requestId=t,n}return t(n,e),n}(Y),Se=function(e){function n(t){var n=t.expires_in,r=t.reason,i=void 0===r?u.SESSION_KEY_EXPIRED:r,o=e.call(this)||this;switch(o.expiresIn=null!=n?n:0,i){case u.SESSION_KEY_EXPIRED:case u.SESSION_TOKEN_EXPIRED:case u.SESSION_REVOKED:o.error=new E({code:i})}return o}return t(n,e),Object.defineProperty(n.prototype,"invalidateSessionToken",{get:function(){var e;return null===(e=this.error)||void 0===e?void 0:e.isSessionTokenExpiredError},enumerable:!1,configurable:!0}),n}(Y),ke=function(e){function n(t){var n=e.call(this)||this;return n.statLog=t,n}return t(n,e),n}(Y);!function(e){e.FEATURE_LOCALCACHE="feature:local_cache",e.WEBSOCKET_CONNECT="ws:connect",e.API_RESULT="api:result"}(be||(be={}));var Te=function(){function e(e){var t=e.type,n=e.data,r=e.ts,i=void 0===r?Date.now():r;this.type=t,this.createdAt=i,this.data=n}return e.payloadify=function(e){return X({stat_type:e.type,ts:e.createdAt,data:X(e.data)})},e}(),Ce=function(){return"undefined"==typeof document&&"undefined"!=typeof navigator&&"ReactNative"==navigator.product},Oe=function(){function e(e,t){var n=t.auth,r=t.sdkState,i=t.dispatcher,o=t.logger,s=t.useFetchCompat,a=void 0!==s&&s,c=this;this._abortControl=new Map,this._shouldImportFetchCompat=!1,this._iid=e,this._auth=n,this._sdkState=r,this._dispatcher=i,this._dispatcher.on((function(e){e instanceof we&&c.cancel(e.requestId)})),this._logger=o,this._shouldImportFetchCompat=a}return Object.defineProperty(e.prototype,"_userAgentWithExtension",{get:function(){var e=this._sdkState.extensions,t=Ce()?"reactnative":"JS",n=e.sb_syncmanager?"s".concat(e.sb_syncmanager):"",r=e.sb_uikit?"u".concat(e.sb_uikit):"",i=e["device-os-platform"]?"o".concat(e["device-os-platform"]):"";return"".concat(t,"/c").concat(h.SDK_VERSION,"/").concat(n,"/").concat(r,"/").concat(i)},enumerable:!1,configurable:!0}),e.prototype._createHeader=function(e,t){void 0===t&&(t=null);var r=this._sdkState,i=r.appId,o=r.appVersion,s=n(n({},e.headers),{SendBird:"JS,".concat(h.OS_VERSION,",").concat(h.SDK_VERSION,",").concat(i).concat(o?",".concat(o):""),"SB-User-Agent":encodeURIComponent(this._userAgentWithExtension),"Request-Sent-Timestamp":Date.now().toString()});return t||(s["Content-Type"]="application/json; charset=utf-8"),e.requireAuth&&this._auth.hasSession&&(s["Session-Key"]=this._auth.sessionKey),this._auth&&this._auth.authToken&&(s["App-Id"]=i,s["Access-Token"]=this._auth.authToken),s},e.prototype._statLogApiResult=function(e,t,n){this._dispatcher.dispatch(new ke(new Te({type:be.API_RESULT,data:{endpoint:e.path,method:e.method,success:!n,latency:Date.now()-t,error_code:null==n?void 0:n.code,error_description:null==n?void 0:n.message}})))},e.prototype.send=function(e){return i(this,void 0,void 0,(function(){var t,n,r,i,s,a,c,u,l,h,d,_,f,p,g;return o(this,(function(o){switch(o.label){case 0:t=e.path,n=e.method,r=![J.GET,J.DELETE].includes(n),i=this._sdkState.api,s="".concat(i.host).concat(t).concat(r?"":e.query),a=r?e.payload:null,c=this._createHeader(e,a instanceof FormData?a:null),u=new AbortController,l=u.signal,this._abortControl.set(e.requestId,u),h=Date.now(),o.label=1;case 1:return o.trys.push([1,8,,9]),this._shouldImportFetchCompat&&(this._shouldImportFetchCompat=!1,("undefined"!=typeof globalThis&&globalThis||"undefined"!=typeof self&&self||"undefined"!=typeof global&&global||{fetch:null}).fetch=void 0),"undefined"!=typeof AbortController?[3,3]:[4,import("./__bundle-2aa1a987.js")];case 2:o.sent(),o.label=3;case 3:return"function"==typeof fetch?[3,5]:[4,import("./__bundle-57274663.js")];case 4:o.sent(),o.label=5;case 5:return[4,fetch(s,{method:n,body:a,headers:c,signal:l})];case 6:return[4,(d=o.sent()).json()];case 7:if(_=o.sent(),d.ok||d.redirected)return this._logger.debug("receive api response",e.requestId),this._statLogApiResult(e,h,null),[2,new ye(this._iid,_)];throw _?(((f=new E(_)).isSessionKeyExpiredError||f.isSessionTokenExpiredError)&&this._dispatcher.dispatch(new Se({reason:f.code})),this._statLogApiResult(e,h,f),f):(f=E.requestFailed,this._statLogApiResult(e,h,f),f);case 8:throw p=o.sent(),this._statLogApiResult(e,h,p),p instanceof E?(this._logger.debug("fail api request",p),p):"AbortError"===p.name?E.requestCanceled:(g=E.networkError,this._logger.debug("fail api request",g),g);case 9:return[2]}}))}))},e.prototype.cancel=function(e){this._abortControl.has(e)&&(this._abortControl.get(e).abort(),this._abortControl.delete(e))},e.prototype.cancelAll=function(){var e,t;try{for(var n=s(this._abortControl.values()),r=n.next();!r.done;r=n.next()){r.value.abort()}}catch(t){e={error:t}}finally{try{r&&!r.done&&(t=n.return)&&t.call(n)}finally{if(e)throw e.error}}this._abortControl.clear()},e}(),Ae=function(e){function n(t,n,r,i){void 0===i&&(i="");var o=e.call(this)||this;return o._iid=t,o.code=n,o.payload=r,o.requestId=r?r.req_id:i,o}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}(Y),Ne=function(){};function Ie(e){let t=e.length;for(;--t>=0;)e[t]=0}const Re=256,De=286,Le=30,xe=15,Me=new Uint8Array([0,0,0,0,0,0,0,0,1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4,5,5,5,5,0]),Pe=new Uint8Array([0,0,0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9,9,10,10,11,11,12,12,13,13]),Ue=new Uint8Array([0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,3,7]),ze=new Uint8Array([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),Fe=new Array(576);Ie(Fe);const qe=new Array(60);Ie(qe);const Ge=new Array(512);Ie(Ge);const je=new Array(256);Ie(je);const Ke=new Array(29);Ie(Ke);const Be=new Array(Le);function Ze(e,t,n,r,i){this.static_tree=e,this.extra_bits=t,this.extra_base=n,this.elems=r,this.max_length=i,this.has_stree=e&&e.length}let Ve,He,We;function Qe(e,t){this.dyn_tree=e,this.max_code=0,this.stat_desc=t}Ie(Be);const Ye=e=>e<256?Ge[e]:Ge[256+(e>>>7)],Xe=(e,t)=>{e.pending_buf[e.pending++]=255&t,e.pending_buf[e.pending++]=t>>>8&255},Je=(e,t,n)=>{e.bi_valid>16-n?(e.bi_buf|=t<>16-e.bi_valid,e.bi_valid+=n-16):(e.bi_buf|=t<{Je(e,n[2*t],n[2*t+1])},et=(e,t)=>{let n=0;do{n|=1&e,e>>>=1,n<<=1}while(--t>0);return n>>>1},tt=(e,t,n)=>{const r=new Array(16);let i,o,s=0;for(i=1;i<=xe;i++)s=s+n[i-1]<<1,r[i]=s;for(o=0;o<=t;o++){let t=e[2*o+1];0!==t&&(e[2*o]=et(r[t]++,t))}},nt=e=>{let t;for(t=0;t{e.bi_valid>8?Xe(e,e.bi_buf):e.bi_valid>0&&(e.pending_buf[e.pending++]=e.bi_buf),e.bi_buf=0,e.bi_valid=0},it=(e,t,n,r)=>{const i=2*t,o=2*n;return e[i]{const r=e.heap[n];let i=n<<1;for(;i<=e.heap_len&&(i{let r,i,o,s,a=0;if(0!==e.sym_next)do{r=255&e.pending_buf[e.sym_buf+a++],r+=(255&e.pending_buf[e.sym_buf+a++])<<8,i=e.pending_buf[e.sym_buf+a++],0===r?$e(e,i,t):(o=je[i],$e(e,o+Re+1,t),s=Me[o],0!==s&&(i-=Ke[o],Je(e,i,s)),r--,o=Ye(r),$e(e,o,n),s=Pe[o],0!==s&&(r-=Be[o],Je(e,r,s)))}while(a{const n=t.dyn_tree,r=t.stat_desc.static_tree,i=t.stat_desc.has_stree,o=t.stat_desc.elems;let s,a,c,u=-1;for(e.heap_len=0,e.heap_max=573,s=0;s>1;s>=1;s--)ot(e,n,s);c=o;do{s=e.heap[1],e.heap[1]=e.heap[e.heap_len--],ot(e,n,1),a=e.heap[1],e.heap[--e.heap_max]=s,e.heap[--e.heap_max]=a,n[2*c]=n[2*s]+n[2*a],e.depth[c]=(e.depth[s]>=e.depth[a]?e.depth[s]:e.depth[a])+1,n[2*s+1]=n[2*a+1]=c,e.heap[1]=c++,ot(e,n,1)}while(e.heap_len>=2);e.heap[--e.heap_max]=e.heap[1],((e,t)=>{const n=t.dyn_tree,r=t.max_code,i=t.stat_desc.static_tree,o=t.stat_desc.has_stree,s=t.stat_desc.extra_bits,a=t.stat_desc.extra_base,c=t.stat_desc.max_length;let u,l,h,d,_,f,p=0;for(d=0;d<=xe;d++)e.bl_count[d]=0;for(n[2*e.heap[e.heap_max]+1]=0,u=e.heap_max+1;u<573;u++)l=e.heap[u],d=n[2*n[2*l+1]+1]+1,d>c&&(d=c,p++),n[2*l+1]=d,l>r||(e.bl_count[d]++,_=0,l>=a&&(_=s[l-a]),f=n[2*l],e.opt_len+=f*(d+_),o&&(e.static_len+=f*(i[2*l+1]+_)));if(0!==p){do{for(d=c-1;0===e.bl_count[d];)d--;e.bl_count[d]--,e.bl_count[d+1]+=2,e.bl_count[c]--,p-=2}while(p>0);for(d=c;0!==d;d--)for(l=e.bl_count[d];0!==l;)h=e.heap[--u],h>r||(n[2*h+1]!==d&&(e.opt_len+=(d-n[2*h+1])*n[2*h],n[2*h+1]=d),l--)}})(e,t),tt(n,u,e.bl_count)},ct=(e,t,n)=>{let r,i,o=-1,s=t[1],a=0,c=7,u=4;for(0===s&&(c=138,u=3),t[2*(n+1)+1]=65535,r=0;r<=n;r++)i=s,s=t[2*(r+1)+1],++a{let r,i,o=-1,s=t[1],a=0,c=7,u=4;for(0===s&&(c=138,u=3),r=0;r<=n;r++)if(i=s,s=t[2*(r+1)+1],!(++a{Je(e,0+(r?1:0),3),rt(e),Xe(e,n),Xe(e,~n),n&&e.pending_buf.set(e.window.subarray(t,t+n),e.pending),e.pending+=n};var dt=(e,t,n,r)=>{let i,o,s=0;e.level>0?(2===e.strm.data_type&&(e.strm.data_type=(e=>{let t,n=4093624447;for(t=0;t<=31;t++,n>>>=1)if(1&n&&0!==e.dyn_ltree[2*t])return 0;if(0!==e.dyn_ltree[18]||0!==e.dyn_ltree[20]||0!==e.dyn_ltree[26])return 1;for(t=32;t{let t;for(ct(e,e.dyn_ltree,e.l_desc.max_code),ct(e,e.dyn_dtree,e.d_desc.max_code),at(e,e.bl_desc),t=18;t>=3&&0===e.bl_tree[2*ze[t]+1];t--);return e.opt_len+=3*(t+1)+5+5+4,t})(e),i=e.opt_len+3+7>>>3,o=e.static_len+3+7>>>3,o<=i&&(i=o)):i=o=n+5,n+4<=i&&-1!==t?ht(e,t,n,r):4===e.strategy||o===i?(Je(e,2+(r?1:0),3),st(e,Fe,qe)):(Je(e,4+(r?1:0),3),((e,t,n,r)=>{let i;for(Je(e,t-257,5),Je(e,n-1,5),Je(e,r-4,4),i=0;i{lt||((()=>{let e,t,n,r,i;const o=new Array(16);for(n=0,r=0;r<28;r++)for(Ke[r]=n,e=0;e<1<>=7;r(e.pending_buf[e.sym_buf+e.sym_next++]=t,e.pending_buf[e.sym_buf+e.sym_next++]=t>>8,e.pending_buf[e.sym_buf+e.sym_next++]=n,0===t?e.dyn_ltree[2*n]++:(e.matches++,t--,e.dyn_ltree[2*(je[n]+Re+1)]++,e.dyn_dtree[2*Ye(t)]++),e.sym_next===e.sym_end),_tr_align:e=>{Je(e,2,3),$e(e,256,Fe),(e=>{16===e.bi_valid?(Xe(e,e.bi_buf),e.bi_buf=0,e.bi_valid=0):e.bi_valid>=8&&(e.pending_buf[e.pending++]=255&e.bi_buf,e.bi_buf>>=8,e.bi_valid-=8)})(e)}};var ft=(e,t,n,r)=>{let i=65535&e|0,o=e>>>16&65535|0,s=0;for(;0!==n;){s=n>2e3?2e3:n,n-=s;do{i=i+t[r++]|0,o=o+i|0}while(--s);i%=65521,o%=65521}return i|o<<16|0};const pt=new Uint32Array((()=>{let e,t=[];for(var n=0;n<256;n++){e=n;for(var r=0;r<8;r++)e=1&e?3988292384^e>>>1:e>>>1;t[n]=e}return t})());var gt=(e,t,n,r)=>{const i=pt,o=r+n;e^=-1;for(let n=r;n>>8^i[255&(e^t[n])];return-1^e},vt={2:"need dictionary",1:"stream end",0:"","-1":"file error","-2":"stream error","-3":"data error","-4":"insufficient memory","-5":"buffer error","-6":"incompatible version"},Et={Z_NO_FLUSH:0,Z_PARTIAL_FLUSH:1,Z_SYNC_FLUSH:2,Z_FULL_FLUSH:3,Z_FINISH:4,Z_BLOCK:5,Z_TREES:6,Z_OK:0,Z_STREAM_END:1,Z_NEED_DICT:2,Z_ERRNO:-1,Z_STREAM_ERROR:-2,Z_DATA_ERROR:-3,Z_MEM_ERROR:-4,Z_BUF_ERROR:-5,Z_NO_COMPRESSION:0,Z_BEST_SPEED:1,Z_BEST_COMPRESSION:9,Z_DEFAULT_COMPRESSION:-1,Z_FILTERED:1,Z_HUFFMAN_ONLY:2,Z_RLE:3,Z_FIXED:4,Z_DEFAULT_STRATEGY:0,Z_BINARY:0,Z_TEXT:1,Z_UNKNOWN:2,Z_DEFLATED:8};const{_tr_init:bt,_tr_stored_block:mt,_tr_flush_block:yt,_tr_tally:wt,_tr_align:St}=_t,{Z_NO_FLUSH:kt,Z_PARTIAL_FLUSH:Tt,Z_FULL_FLUSH:Ct,Z_FINISH:Ot,Z_BLOCK:At,Z_OK:Nt,Z_STREAM_END:It,Z_STREAM_ERROR:Rt,Z_DATA_ERROR:Dt,Z_BUF_ERROR:Lt,Z_DEFAULT_COMPRESSION:xt,Z_FILTERED:Mt,Z_HUFFMAN_ONLY:Pt,Z_RLE:Ut,Z_FIXED:zt,Z_DEFAULT_STRATEGY:Ft,Z_UNKNOWN:qt,Z_DEFLATED:Gt}=Et,jt=258,Kt=262,Bt=42,Zt=113,Vt=666,Ht=(e,t)=>(e.msg=vt[t],t),Wt=e=>2*e-(e>4?9:0),Qt=e=>{let t=e.length;for(;--t>=0;)e[t]=0},Yt=e=>{let t,n,r,i=e.w_size;t=e.hash_size,r=t;do{n=e.head[--r],e.head[r]=n>=i?n-i:0}while(--t);t=i,r=t;do{n=e.prev[--r],e.prev[r]=n>=i?n-i:0}while(--t)};let Xt=(e,t,n)=>(t<{const t=e.state;let n=t.pending;n>e.avail_out&&(n=e.avail_out),0!==n&&(e.output.set(t.pending_buf.subarray(t.pending_out,t.pending_out+n),e.next_out),e.next_out+=n,t.pending_out+=n,e.total_out+=n,e.avail_out-=n,t.pending-=n,0===t.pending&&(t.pending_out=0))},$t=(e,t)=>{yt(e,e.block_start>=0?e.block_start:-1,e.strstart-e.block_start,t),e.block_start=e.strstart,Jt(e.strm)},en=(e,t)=>{e.pending_buf[e.pending++]=t},tn=(e,t)=>{e.pending_buf[e.pending++]=t>>>8&255,e.pending_buf[e.pending++]=255&t},nn=(e,t,n,r)=>{let i=e.avail_in;return i>r&&(i=r),0===i?0:(e.avail_in-=i,t.set(e.input.subarray(e.next_in,e.next_in+i),n),1===e.state.wrap?e.adler=ft(e.adler,t,i,n):2===e.state.wrap&&(e.adler=gt(e.adler,t,i,n)),e.next_in+=i,e.total_in+=i,i)},rn=(e,t)=>{let n,r,i=e.max_chain_length,o=e.strstart,s=e.prev_length,a=e.nice_match;const c=e.strstart>e.w_size-Kt?e.strstart-(e.w_size-Kt):0,u=e.window,l=e.w_mask,h=e.prev,d=e.strstart+jt;let _=u[o+s-1],f=u[o+s];e.prev_length>=e.good_match&&(i>>=2),a>e.lookahead&&(a=e.lookahead);do{if(n=t,u[n+s]===f&&u[n+s-1]===_&&u[n]===u[o]&&u[++n]===u[o+1]){o+=2,n++;do{}while(u[++o]===u[++n]&&u[++o]===u[++n]&&u[++o]===u[++n]&&u[++o]===u[++n]&&u[++o]===u[++n]&&u[++o]===u[++n]&&u[++o]===u[++n]&&u[++o]===u[++n]&&os){if(e.match_start=t,s=r,r>=a)break;_=u[o+s-1],f=u[o+s]}}}while((t=h[t&l])>c&&0!=--i);return s<=e.lookahead?s:e.lookahead},on=e=>{const t=e.w_size;let n,r,i;do{if(r=e.window_size-e.lookahead-e.strstart,e.strstart>=t+(t-Kt)&&(e.window.set(e.window.subarray(t,t+t-r),0),e.match_start-=t,e.strstart-=t,e.block_start-=t,e.insert>e.strstart&&(e.insert=e.strstart),Yt(e),r+=t),0===e.strm.avail_in)break;if(n=nn(e.strm,e.window,e.strstart+e.lookahead,r),e.lookahead+=n,e.lookahead+e.insert>=3)for(i=e.strstart-e.insert,e.ins_h=e.window[i],e.ins_h=Xt(e,e.ins_h,e.window[i+1]);e.insert&&(e.ins_h=Xt(e,e.ins_h,e.window[i+3-1]),e.prev[i&e.w_mask]=e.head[e.ins_h],e.head[e.ins_h]=i,i++,e.insert--,!(e.lookahead+e.insert<3)););}while(e.lookahead{let n,r,i,o=e.pending_buf_size-5>e.w_size?e.w_size:e.pending_buf_size-5,s=0,a=e.strm.avail_in;do{if(n=65535,i=e.bi_valid+42>>3,e.strm.avail_outr+e.strm.avail_in&&(n=r+e.strm.avail_in),n>i&&(n=i),n>8,e.pending_buf[e.pending-2]=~n,e.pending_buf[e.pending-1]=~n>>8,Jt(e.strm),r&&(r>n&&(r=n),e.strm.output.set(e.window.subarray(e.block_start,e.block_start+r),e.strm.next_out),e.strm.next_out+=r,e.strm.avail_out-=r,e.strm.total_out+=r,e.block_start+=r,n-=r),n&&(nn(e.strm,e.strm.output,e.strm.next_out,n),e.strm.next_out+=n,e.strm.avail_out-=n,e.strm.total_out+=n)}while(0===s);return a-=e.strm.avail_in,a&&(a>=e.w_size?(e.matches=2,e.window.set(e.strm.input.subarray(e.strm.next_in-e.w_size,e.strm.next_in),0),e.strstart=e.w_size,e.insert=e.strstart):(e.window_size-e.strstart<=a&&(e.strstart-=e.w_size,e.window.set(e.window.subarray(e.w_size,e.w_size+e.strstart),0),e.matches<2&&e.matches++,e.insert>e.strstart&&(e.insert=e.strstart)),e.window.set(e.strm.input.subarray(e.strm.next_in-a,e.strm.next_in),e.strstart),e.strstart+=a,e.insert+=a>e.w_size-e.insert?e.w_size-e.insert:a),e.block_start=e.strstart),e.high_wateri&&e.block_start>=e.w_size&&(e.block_start-=e.w_size,e.strstart-=e.w_size,e.window.set(e.window.subarray(e.w_size,e.w_size+e.strstart),0),e.matches<2&&e.matches++,i+=e.w_size,e.insert>e.strstart&&(e.insert=e.strstart)),i>e.strm.avail_in&&(i=e.strm.avail_in),i&&(nn(e.strm,e.window,e.strstart,i),e.strstart+=i,e.insert+=i>e.w_size-e.insert?e.w_size-e.insert:i),e.high_water>3,i=e.pending_buf_size-i>65535?65535:e.pending_buf_size-i,o=i>e.w_size?e.w_size:i,r=e.strstart-e.block_start,(r>=o||(r||t===Ot)&&t!==kt&&0===e.strm.avail_in&&r<=i)&&(n=r>i?i:r,s=t===Ot&&0===e.strm.avail_in&&n===r?1:0,mt(e,e.block_start,n,s),e.block_start+=n,Jt(e.strm)),s?3:1)},an=(e,t)=>{let n,r;for(;;){if(e.lookahead=3&&(e.ins_h=Xt(e,e.ins_h,e.window[e.strstart+3-1]),n=e.prev[e.strstart&e.w_mask]=e.head[e.ins_h],e.head[e.ins_h]=e.strstart),0!==n&&e.strstart-n<=e.w_size-Kt&&(e.match_length=rn(e,n)),e.match_length>=3)if(r=wt(e,e.strstart-e.match_start,e.match_length-3),e.lookahead-=e.match_length,e.match_length<=e.max_lazy_match&&e.lookahead>=3){e.match_length--;do{e.strstart++,e.ins_h=Xt(e,e.ins_h,e.window[e.strstart+3-1]),n=e.prev[e.strstart&e.w_mask]=e.head[e.ins_h],e.head[e.ins_h]=e.strstart}while(0!=--e.match_length);e.strstart++}else e.strstart+=e.match_length,e.match_length=0,e.ins_h=e.window[e.strstart],e.ins_h=Xt(e,e.ins_h,e.window[e.strstart+1]);else r=wt(e,0,e.window[e.strstart]),e.lookahead--,e.strstart++;if(r&&($t(e,!1),0===e.strm.avail_out))return 1}return e.insert=e.strstart<2?e.strstart:2,t===Ot?($t(e,!0),0===e.strm.avail_out?3:4):e.sym_next&&($t(e,!1),0===e.strm.avail_out)?1:2},cn=(e,t)=>{let n,r,i;for(;;){if(e.lookahead=3&&(e.ins_h=Xt(e,e.ins_h,e.window[e.strstart+3-1]),n=e.prev[e.strstart&e.w_mask]=e.head[e.ins_h],e.head[e.ins_h]=e.strstart),e.prev_length=e.match_length,e.prev_match=e.match_start,e.match_length=2,0!==n&&e.prev_length4096)&&(e.match_length=2)),e.prev_length>=3&&e.match_length<=e.prev_length){i=e.strstart+e.lookahead-3,r=wt(e,e.strstart-1-e.prev_match,e.prev_length-3),e.lookahead-=e.prev_length-1,e.prev_length-=2;do{++e.strstart<=i&&(e.ins_h=Xt(e,e.ins_h,e.window[e.strstart+3-1]),n=e.prev[e.strstart&e.w_mask]=e.head[e.ins_h],e.head[e.ins_h]=e.strstart)}while(0!=--e.prev_length);if(e.match_available=0,e.match_length=2,e.strstart++,r&&($t(e,!1),0===e.strm.avail_out))return 1}else if(e.match_available){if(r=wt(e,0,e.window[e.strstart-1]),r&&$t(e,!1),e.strstart++,e.lookahead--,0===e.strm.avail_out)return 1}else e.match_available=1,e.strstart++,e.lookahead--}return e.match_available&&(r=wt(e,0,e.window[e.strstart-1]),e.match_available=0),e.insert=e.strstart<2?e.strstart:2,t===Ot?($t(e,!0),0===e.strm.avail_out?3:4):e.sym_next&&($t(e,!1),0===e.strm.avail_out)?1:2};function un(e,t,n,r,i){this.good_length=e,this.max_lazy=t,this.nice_length=n,this.max_chain=r,this.func=i}const ln=[new un(0,0,0,0,sn),new un(4,4,8,4,an),new un(4,5,16,8,an),new un(4,6,32,32,an),new un(4,4,16,16,cn),new un(8,16,32,32,cn),new un(8,16,128,128,cn),new un(8,32,128,256,cn),new un(32,128,258,1024,cn),new un(32,258,258,4096,cn)];function hn(){this.strm=null,this.status=0,this.pending_buf=null,this.pending_buf_size=0,this.pending_out=0,this.pending=0,this.wrap=0,this.gzhead=null,this.gzindex=0,this.method=Gt,this.last_flush=-1,this.w_size=0,this.w_bits=0,this.w_mask=0,this.window=null,this.window_size=0,this.prev=null,this.head=null,this.ins_h=0,this.hash_size=0,this.hash_bits=0,this.hash_mask=0,this.hash_shift=0,this.block_start=0,this.match_length=0,this.prev_match=0,this.match_available=0,this.strstart=0,this.match_start=0,this.lookahead=0,this.prev_length=0,this.max_chain_length=0,this.max_lazy_match=0,this.level=0,this.strategy=0,this.good_match=0,this.nice_match=0,this.dyn_ltree=new Uint16Array(1146),this.dyn_dtree=new Uint16Array(122),this.bl_tree=new Uint16Array(78),Qt(this.dyn_ltree),Qt(this.dyn_dtree),Qt(this.bl_tree),this.l_desc=null,this.d_desc=null,this.bl_desc=null,this.bl_count=new Uint16Array(16),this.heap=new Uint16Array(573),Qt(this.heap),this.heap_len=0,this.heap_max=0,this.depth=new Uint16Array(573),Qt(this.depth),this.sym_buf=0,this.lit_bufsize=0,this.sym_next=0,this.sym_end=0,this.opt_len=0,this.static_len=0,this.matches=0,this.insert=0,this.bi_buf=0,this.bi_valid=0}const dn=e=>{if(!e)return 1;const t=e.state;return!t||t.strm!==e||t.status!==Bt&&57!==t.status&&69!==t.status&&73!==t.status&&91!==t.status&&103!==t.status&&t.status!==Zt&&t.status!==Vt?1:0},_n=e=>{if(dn(e))return Ht(e,Rt);e.total_in=e.total_out=0,e.data_type=qt;const t=e.state;return t.pending=0,t.pending_out=0,t.wrap<0&&(t.wrap=-t.wrap),t.status=2===t.wrap?57:t.wrap?Bt:Zt,e.adler=2===t.wrap?0:1,t.last_flush=-2,bt(t),Nt},fn=e=>{const t=_n(e);var n;return t===Nt&&((n=e.state).window_size=2*n.w_size,Qt(n.head),n.max_lazy_match=ln[n.level].max_lazy,n.good_match=ln[n.level].good_length,n.nice_match=ln[n.level].nice_length,n.max_chain_length=ln[n.level].max_chain,n.strstart=0,n.block_start=0,n.lookahead=0,n.insert=0,n.match_length=n.prev_length=2,n.match_available=0,n.ins_h=0),t},pn=(e,t,n,r,i,o)=>{if(!e)return Rt;let s=1;if(t===xt&&(t=6),r<0?(s=0,r=-r):r>15&&(s=2,r-=16),i<1||i>9||n!==Gt||r<8||r>15||t<0||t>9||o<0||o>zt||8===r&&1!==s)return Ht(e,Rt);8===r&&(r=9);const a=new hn;return e.state=a,a.strm=e,a.status=Bt,a.wrap=s,a.gzhead=null,a.w_bits=r,a.w_size=1<pn(e,t,Gt,15,8,Ft),deflateInit2:pn,deflateReset:fn,deflateResetKeep:_n,deflateSetHeader:(e,t)=>dn(e)||2!==e.state.wrap?Rt:(e.state.gzhead=t,Nt),deflate:(e,t)=>{if(dn(e)||t>At||t<0)return e?Ht(e,Rt):Rt;const n=e.state;if(!e.output||0!==e.avail_in&&!e.input||n.status===Vt&&t!==Ot)return Ht(e,0===e.avail_out?Lt:Rt);const r=n.last_flush;if(n.last_flush=t,0!==n.pending){if(Jt(e),0===e.avail_out)return n.last_flush=-1,Nt}else if(0===e.avail_in&&Wt(t)<=Wt(r)&&t!==Ot)return Ht(e,Lt);if(n.status===Vt&&0!==e.avail_in)return Ht(e,Lt);if(n.status===Bt&&0===n.wrap&&(n.status=Zt),n.status===Bt){let t=Gt+(n.w_bits-8<<4)<<8,r=-1;if(r=n.strategy>=Pt||n.level<2?0:n.level<6?1:6===n.level?2:3,t|=r<<6,0!==n.strstart&&(t|=32),t+=31-t%31,tn(n,t),0!==n.strstart&&(tn(n,e.adler>>>16),tn(n,65535&e.adler)),e.adler=1,n.status=Zt,Jt(e),0!==n.pending)return n.last_flush=-1,Nt}if(57===n.status)if(e.adler=0,en(n,31),en(n,139),en(n,8),n.gzhead)en(n,(n.gzhead.text?1:0)+(n.gzhead.hcrc?2:0)+(n.gzhead.extra?4:0)+(n.gzhead.name?8:0)+(n.gzhead.comment?16:0)),en(n,255&n.gzhead.time),en(n,n.gzhead.time>>8&255),en(n,n.gzhead.time>>16&255),en(n,n.gzhead.time>>24&255),en(n,9===n.level?2:n.strategy>=Pt||n.level<2?4:0),en(n,255&n.gzhead.os),n.gzhead.extra&&n.gzhead.extra.length&&(en(n,255&n.gzhead.extra.length),en(n,n.gzhead.extra.length>>8&255)),n.gzhead.hcrc&&(e.adler=gt(e.adler,n.pending_buf,n.pending,0)),n.gzindex=0,n.status=69;else if(en(n,0),en(n,0),en(n,0),en(n,0),en(n,0),en(n,9===n.level?2:n.strategy>=Pt||n.level<2?4:0),en(n,3),n.status=Zt,Jt(e),0!==n.pending)return n.last_flush=-1,Nt;if(69===n.status){if(n.gzhead.extra){let t=n.pending,r=(65535&n.gzhead.extra.length)-n.gzindex;for(;n.pending+r>n.pending_buf_size;){let i=n.pending_buf_size-n.pending;if(n.pending_buf.set(n.gzhead.extra.subarray(n.gzindex,n.gzindex+i),n.pending),n.pending=n.pending_buf_size,n.gzhead.hcrc&&n.pending>t&&(e.adler=gt(e.adler,n.pending_buf,n.pending-t,t)),n.gzindex+=i,Jt(e),0!==n.pending)return n.last_flush=-1,Nt;t=0,r-=i}let i=new Uint8Array(n.gzhead.extra);n.pending_buf.set(i.subarray(n.gzindex,n.gzindex+r),n.pending),n.pending+=r,n.gzhead.hcrc&&n.pending>t&&(e.adler=gt(e.adler,n.pending_buf,n.pending-t,t)),n.gzindex=0}n.status=73}if(73===n.status){if(n.gzhead.name){let t,r=n.pending;do{if(n.pending===n.pending_buf_size){if(n.gzhead.hcrc&&n.pending>r&&(e.adler=gt(e.adler,n.pending_buf,n.pending-r,r)),Jt(e),0!==n.pending)return n.last_flush=-1,Nt;r=0}t=n.gzindexr&&(e.adler=gt(e.adler,n.pending_buf,n.pending-r,r)),n.gzindex=0}n.status=91}if(91===n.status){if(n.gzhead.comment){let t,r=n.pending;do{if(n.pending===n.pending_buf_size){if(n.gzhead.hcrc&&n.pending>r&&(e.adler=gt(e.adler,n.pending_buf,n.pending-r,r)),Jt(e),0!==n.pending)return n.last_flush=-1,Nt;r=0}t=n.gzindexr&&(e.adler=gt(e.adler,n.pending_buf,n.pending-r,r))}n.status=103}if(103===n.status){if(n.gzhead.hcrc){if(n.pending+2>n.pending_buf_size&&(Jt(e),0!==n.pending))return n.last_flush=-1,Nt;en(n,255&e.adler),en(n,e.adler>>8&255),e.adler=0}if(n.status=Zt,Jt(e),0!==n.pending)return n.last_flush=-1,Nt}if(0!==e.avail_in||0!==n.lookahead||t!==kt&&n.status!==Vt){let r=0===n.level?sn(n,t):n.strategy===Pt?((e,t)=>{let n;for(;;){if(0===e.lookahead&&(on(e),0===e.lookahead)){if(t===kt)return 1;break}if(e.match_length=0,n=wt(e,0,e.window[e.strstart]),e.lookahead--,e.strstart++,n&&($t(e,!1),0===e.strm.avail_out))return 1}return e.insert=0,t===Ot?($t(e,!0),0===e.strm.avail_out?3:4):e.sym_next&&($t(e,!1),0===e.strm.avail_out)?1:2})(n,t):n.strategy===Ut?((e,t)=>{let n,r,i,o;const s=e.window;for(;;){if(e.lookahead<=jt){if(on(e),e.lookahead<=jt&&t===kt)return 1;if(0===e.lookahead)break}if(e.match_length=0,e.lookahead>=3&&e.strstart>0&&(i=e.strstart-1,r=s[i],r===s[++i]&&r===s[++i]&&r===s[++i])){o=e.strstart+jt;do{}while(r===s[++i]&&r===s[++i]&&r===s[++i]&&r===s[++i]&&r===s[++i]&&r===s[++i]&&r===s[++i]&&r===s[++i]&&ie.lookahead&&(e.match_length=e.lookahead)}if(e.match_length>=3?(n=wt(e,1,e.match_length-3),e.lookahead-=e.match_length,e.strstart+=e.match_length,e.match_length=0):(n=wt(e,0,e.window[e.strstart]),e.lookahead--,e.strstart++),n&&($t(e,!1),0===e.strm.avail_out))return 1}return e.insert=0,t===Ot?($t(e,!0),0===e.strm.avail_out?3:4):e.sym_next&&($t(e,!1),0===e.strm.avail_out)?1:2})(n,t):ln[n.level].func(n,t);if(3!==r&&4!==r||(n.status=Vt),1===r||3===r)return 0===e.avail_out&&(n.last_flush=-1),Nt;if(2===r&&(t===Tt?St(n):t!==At&&(mt(n,0,0,!1),t===Ct&&(Qt(n.head),0===n.lookahead&&(n.strstart=0,n.block_start=0,n.insert=0))),Jt(e),0===e.avail_out))return n.last_flush=-1,Nt}return t!==Ot?Nt:n.wrap<=0?It:(2===n.wrap?(en(n,255&e.adler),en(n,e.adler>>8&255),en(n,e.adler>>16&255),en(n,e.adler>>24&255),en(n,255&e.total_in),en(n,e.total_in>>8&255),en(n,e.total_in>>16&255),en(n,e.total_in>>24&255)):(tn(n,e.adler>>>16),tn(n,65535&e.adler)),Jt(e),n.wrap>0&&(n.wrap=-n.wrap),0!==n.pending?Nt:It)},deflateEnd:e=>{if(dn(e))return Rt;const t=e.state.status;return e.state=null,t===Zt?Ht(e,Dt):Nt},deflateSetDictionary:(e,t)=>{let n=t.length;if(dn(e))return Rt;const r=e.state,i=r.wrap;if(2===i||1===i&&r.status!==Bt||r.lookahead)return Rt;if(1===i&&(e.adler=ft(e.adler,t,n,0)),r.wrap=0,n>=r.w_size){0===i&&(Qt(r.head),r.strstart=0,r.block_start=0,r.insert=0);let e=new Uint8Array(r.w_size);e.set(t.subarray(n-r.w_size,n),0),t=e,n=r.w_size}const o=e.avail_in,s=e.next_in,a=e.input;for(e.avail_in=n,e.next_in=0,e.input=t,on(r);r.lookahead>=3;){let e=r.strstart,t=r.lookahead-2;do{r.ins_h=Xt(r,r.ins_h,r.window[e+3-1]),r.prev[e&r.w_mask]=r.head[r.ins_h],r.head[r.ins_h]=e,e++}while(--t);r.strstart=e,r.lookahead=2,on(r)}return r.strstart+=r.lookahead,r.block_start=r.strstart,r.insert=r.lookahead,r.lookahead=0,r.match_length=r.prev_length=2,r.match_available=0,e.next_in=s,e.input=a,e.avail_in=o,r.wrap=i,Nt},deflateInfo:"pako deflate (from Nodeca project)"};const vn=(e,t)=>Object.prototype.hasOwnProperty.call(e,t);var En={assign:function(e){const t=Array.prototype.slice.call(arguments,1);for(;t.length;){const n=t.shift();if(n){if("object"!=typeof n)throw new TypeError(n+"must be non-object");for(const t in n)vn(n,t)&&(e[t]=n[t])}}return e},flattenChunks:e=>{let t=0;for(let n=0,r=e.length;n=252?6:e>=248?5:e>=240?4:e>=224?3:e>=192?2:1;mn[254]=mn[254]=1;var yn={string2buf:e=>{if("function"==typeof TextEncoder&&TextEncoder.prototype.encode)return(new TextEncoder).encode(e);let t,n,r,i,o,s=e.length,a=0;for(i=0;i>>6,t[o++]=128|63&n):n<65536?(t[o++]=224|n>>>12,t[o++]=128|n>>>6&63,t[o++]=128|63&n):(t[o++]=240|n>>>18,t[o++]=128|n>>>12&63,t[o++]=128|n>>>6&63,t[o++]=128|63&n);return t},buf2string:(e,t)=>{const n=t||e.length;if("function"==typeof TextDecoder&&TextDecoder.prototype.decode)return(new TextDecoder).decode(e.subarray(0,t));let r,i;const o=new Array(2*n);for(i=0,r=0;r4)o[i++]=65533,r+=s-1;else{for(t&=2===s?31:3===s?15:7;s>1&&r1?o[i++]=65533:t<65536?o[i++]=t:(t-=65536,o[i++]=55296|t>>10&1023,o[i++]=56320|1023&t)}}return((e,t)=>{if(t<65534&&e.subarray&&bn)return String.fromCharCode.apply(null,e.length===t?e:e.subarray(0,t));let n="";for(let r=0;r{(t=t||e.length)>e.length&&(t=e.length);let n=t-1;for(;n>=0&&128==(192&e[n]);)n--;return n<0||0===n?t:n+mn[e[n]]>t?n:t}};var wn=function(){this.input=null,this.next_in=0,this.avail_in=0,this.total_in=0,this.output=null,this.next_out=0,this.avail_out=0,this.total_out=0,this.msg="",this.state=null,this.data_type=2,this.adler=0};const Sn=Object.prototype.toString,{Z_NO_FLUSH:kn,Z_SYNC_FLUSH:Tn,Z_FULL_FLUSH:Cn,Z_FINISH:On,Z_OK:An,Z_STREAM_END:Nn,Z_DEFAULT_COMPRESSION:In,Z_DEFAULT_STRATEGY:Rn,Z_DEFLATED:Dn}=Et;function Ln(e){this.options=En.assign({level:In,method:Dn,chunkSize:16384,windowBits:15,memLevel:8,strategy:Rn},e||{});let t=this.options;t.raw&&t.windowBits>0?t.windowBits=-t.windowBits:t.gzip&&t.windowBits>0&&t.windowBits<16&&(t.windowBits+=16),this.err=0,this.msg="",this.ended=!1,this.chunks=[],this.strm=new wn,this.strm.avail_out=0;let n=gn.deflateInit2(this.strm,t.level,t.method,t.windowBits,t.memLevel,t.strategy);if(n!==An)throw new Error(vt[n]);if(t.header&&gn.deflateSetHeader(this.strm,t.header),t.dictionary){let e;if(e="string"==typeof t.dictionary?yn.string2buf(t.dictionary):"[object ArrayBuffer]"===Sn.call(t.dictionary)?new Uint8Array(t.dictionary):t.dictionary,n=gn.deflateSetDictionary(this.strm,e),n!==An)throw new Error(vt[n]);this._dict_set=!0}}function xn(e,t){const n=new Ln(t);if(n.push(e,!0),n.err)throw n.msg||vt[n.err];return n.result}Ln.prototype.push=function(e,t){const n=this.strm,r=this.options.chunkSize;let i,o;if(this.ended)return!1;for(o=t===~~t?t:!0===t?On:kn,"string"==typeof e?n.input=yn.string2buf(e):"[object ArrayBuffer]"===Sn.call(e)?n.input=new Uint8Array(e):n.input=e,n.next_in=0,n.avail_in=n.input.length;;)if(0===n.avail_out&&(n.output=new Uint8Array(r),n.next_out=0,n.avail_out=r),(o===Tn||o===Cn)&&n.avail_out<=6)this.onData(n.output.subarray(0,n.next_out)),n.avail_out=0;else{if(i=gn.deflate(n,o),i===Nn)return n.next_out>0&&this.onData(n.output.subarray(0,n.next_out)),i=gn.deflateEnd(this.strm),this.onEnd(i),this.ended=!0,i===An;if(0!==n.avail_out){if(o>0&&n.next_out>0)this.onData(n.output.subarray(0,n.next_out)),n.avail_out=0;else if(0===n.avail_in)break}else this.onData(n.output)}return!0},Ln.prototype.onData=function(e){this.chunks.push(e)},Ln.prototype.onEnd=function(e){e===An&&(this.result=En.flattenChunks(this.chunks)),this.chunks=[],this.err=e,this.msg=this.strm.msg};var Mn={Deflate:Ln,deflate:xn,deflateRaw:function(e,t){return(t=t||{}).raw=!0,xn(e,t)},gzip:function(e,t){return(t=t||{}).gzip=!0,xn(e,t)},constants:Et};const Pn=16209;var Un=function(e,t){let n,r,i,o,s,a,c,u,l,h,d,_,f,p,g,v,E,b,m,y,w,S,k,T;const C=e.state;n=e.next_in,k=e.input,r=n+(e.avail_in-5),i=e.next_out,T=e.output,o=i-(t-e.avail_out),s=i+(e.avail_out-257),a=C.dmax,c=C.wsize,u=C.whave,l=C.wnext,h=C.window,d=C.hold,_=C.bits,f=C.lencode,p=C.distcode,g=(1<>>24,d>>>=b,_-=b,b=E>>>16&255,0===b)T[i++]=65535&E;else{if(!(16&b)){if(0==(64&b)){E=f[(65535&E)+(d&(1<>>=b,_-=b),_<15&&(d+=k[n++]<<_,_+=8,d+=k[n++]<<_,_+=8),E=p[d&v];n:for(;;){if(b=E>>>24,d>>>=b,_-=b,b=E>>>16&255,!(16&b)){if(0==(64&b)){E=p[(65535&E)+(d&(1<a){e.msg="invalid distance too far back",C.mode=Pn;break e}if(d>>>=b,_-=b,b=i-o,y>b){if(b=y-b,b>u&&C.sane){e.msg="invalid distance too far back",C.mode=Pn;break e}if(w=0,S=h,0===l){if(w+=c-b,b2;)T[i++]=S[w++],T[i++]=S[w++],T[i++]=S[w++],m-=3;m&&(T[i++]=S[w++],m>1&&(T[i++]=S[w++]))}else{w=i-y;do{T[i++]=T[w++],T[i++]=T[w++],T[i++]=T[w++],m-=3}while(m>2);m&&(T[i++]=T[w++],m>1&&(T[i++]=T[w++]))}break}}break}}while(n>3,n-=m,_-=m<<3,d&=(1<<_)-1,e.next_in=n,e.next_out=i,e.avail_in=n{const c=a.bits;let u,l,h,d,_,f,p=0,g=0,v=0,E=0,b=0,m=0,y=0,w=0,S=0,k=0,T=null;const C=new Uint16Array(16),O=new Uint16Array(16);let A,N,I,R=null;for(p=0;p<=zn;p++)C[p]=0;for(g=0;g=1&&0===C[E];E--);if(b>E&&(b=E),0===E)return i[o++]=20971520,i[o++]=20971520,a.bits=1,0;for(v=1;v0&&(0===e||1!==E))return-1;for(O[1]=0,p=1;p852||2===e&&S>592)return 1;for(;;){A=p-y,s[g]+1=f?(N=R[s[g]-f],I=T[s[g]-f]):(N=96,I=0),u=1<>y)+l]=A<<24|N<<16|I|0}while(0!==l);for(u=1<>=1;if(0!==u?(k&=u-1,k+=u):k=0,g++,0==--C[p]){if(p===E)break;p=t[n+s[g]]}if(p>b&&(k&d)!==h){for(0===y&&(y=b),_+=v,m=p-y,w=1<852||2===e&&S>592)return 1;h=k&d,i[h]=b<<24|m<<16|_-o|0}}return 0!==k&&(i[_+k]=p-y<<24|64<<16|0),a.bits=b,0};const{Z_FINISH:Bn,Z_BLOCK:Zn,Z_TREES:Vn,Z_OK:Hn,Z_STREAM_END:Wn,Z_NEED_DICT:Qn,Z_STREAM_ERROR:Yn,Z_DATA_ERROR:Xn,Z_MEM_ERROR:Jn,Z_BUF_ERROR:$n,Z_DEFLATED:er}=Et,tr=16180,nr=16190,rr=16191,ir=16192,or=16194,sr=16199,ar=16200,cr=16206,ur=16209,lr=e=>(e>>>24&255)+(e>>>8&65280)+((65280&e)<<8)+((255&e)<<24);function hr(){this.strm=null,this.mode=0,this.last=!1,this.wrap=0,this.havedict=!1,this.flags=0,this.dmax=0,this.check=0,this.total=0,this.head=null,this.wbits=0,this.wsize=0,this.whave=0,this.wnext=0,this.window=null,this.hold=0,this.bits=0,this.length=0,this.offset=0,this.extra=0,this.lencode=null,this.distcode=null,this.lenbits=0,this.distbits=0,this.ncode=0,this.nlen=0,this.ndist=0,this.have=0,this.next=null,this.lens=new Uint16Array(320),this.work=new Uint16Array(288),this.lendyn=null,this.distdyn=null,this.sane=0,this.back=0,this.was=0}const dr=e=>{if(!e)return 1;const t=e.state;return!t||t.strm!==e||t.mode16211?1:0},_r=e=>{if(dr(e))return Yn;const t=e.state;return e.total_in=e.total_out=t.total=0,e.msg="",t.wrap&&(e.adler=1&t.wrap),t.mode=tr,t.last=0,t.havedict=0,t.flags=-1,t.dmax=32768,t.head=null,t.hold=0,t.bits=0,t.lencode=t.lendyn=new Int32Array(852),t.distcode=t.distdyn=new Int32Array(592),t.sane=1,t.back=-1,Hn},fr=e=>{if(dr(e))return Yn;const t=e.state;return t.wsize=0,t.whave=0,t.wnext=0,_r(e)},pr=(e,t)=>{let n;if(dr(e))return Yn;const r=e.state;return t<0?(n=0,t=-t):(n=5+(t>>4),t<48&&(t&=15)),t&&(t<8||t>15)?Yn:(null!==r.window&&r.wbits!==t&&(r.window=null),r.wrap=n,r.wbits=t,fr(e))},gr=(e,t)=>{if(!e)return Yn;const n=new hr;e.state=n,n.strm=e,n.window=null,n.mode=tr;const r=pr(e,t);return r!==Hn&&(e.state=null),r};let vr,Er,br=!0;const mr=e=>{if(br){vr=new Int32Array(512),Er=new Int32Array(32);let t=0;for(;t<144;)e.lens[t++]=8;for(;t<256;)e.lens[t++]=9;for(;t<280;)e.lens[t++]=7;for(;t<288;)e.lens[t++]=8;for(Kn(1,e.lens,0,288,vr,0,e.work,{bits:9}),t=0;t<32;)e.lens[t++]=5;Kn(2,e.lens,0,32,Er,0,e.work,{bits:5}),br=!1}e.lencode=vr,e.lenbits=9,e.distcode=Er,e.distbits=5},yr=(e,t,n,r)=>{let i;const o=e.state;return null===o.window&&(o.wsize=1<=o.wsize?(o.window.set(t.subarray(n-o.wsize,n),0),o.wnext=0,o.whave=o.wsize):(i=o.wsize-o.wnext,i>r&&(i=r),o.window.set(t.subarray(n-r,n-r+i),o.wnext),(r-=i)?(o.window.set(t.subarray(n-r,n),0),o.wnext=r,o.whave=o.wsize):(o.wnext+=i,o.wnext===o.wsize&&(o.wnext=0),o.whavegr(e,15),inflateInit2:gr,inflate:(e,t)=>{let n,r,i,o,s,a,c,u,l,h,d,_,f,p,g,v,E,b,m,y,w,S,k=0;const T=new Uint8Array(4);let C,O;const A=new Uint8Array([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]);if(dr(e)||!e.output||!e.input&&0!==e.avail_in)return Yn;n=e.state,n.mode===rr&&(n.mode=ir),s=e.next_out,i=e.output,c=e.avail_out,o=e.next_in,r=e.input,a=e.avail_in,u=n.hold,l=n.bits,h=a,d=c,S=Hn;e:for(;;)switch(n.mode){case tr:if(0===n.wrap){n.mode=ir;break}for(;l<16;){if(0===a)break e;a--,u+=r[o++]<>>8&255,n.check=gt(n.check,T,2,0),u=0,l=0,n.mode=16181;break}if(n.head&&(n.head.done=!1),!(1&n.wrap)||(((255&u)<<8)+(u>>8))%31){e.msg="incorrect header check",n.mode=ur;break}if((15&u)!==er){e.msg="unknown compression method",n.mode=ur;break}if(u>>>=4,l-=4,w=8+(15&u),0===n.wbits&&(n.wbits=w),w>15||w>n.wbits){e.msg="invalid window size",n.mode=ur;break}n.dmax=1<>8&1),512&n.flags&&4&n.wrap&&(T[0]=255&u,T[1]=u>>>8&255,n.check=gt(n.check,T,2,0)),u=0,l=0,n.mode=16182;case 16182:for(;l<32;){if(0===a)break e;a--,u+=r[o++]<>>8&255,T[2]=u>>>16&255,T[3]=u>>>24&255,n.check=gt(n.check,T,4,0)),u=0,l=0,n.mode=16183;case 16183:for(;l<16;){if(0===a)break e;a--,u+=r[o++]<>8),512&n.flags&&4&n.wrap&&(T[0]=255&u,T[1]=u>>>8&255,n.check=gt(n.check,T,2,0)),u=0,l=0,n.mode=16184;case 16184:if(1024&n.flags){for(;l<16;){if(0===a)break e;a--,u+=r[o++]<>>8&255,n.check=gt(n.check,T,2,0)),u=0,l=0}else n.head&&(n.head.extra=null);n.mode=16185;case 16185:if(1024&n.flags&&(_=n.length,_>a&&(_=a),_&&(n.head&&(w=n.head.extra_len-n.length,n.head.extra||(n.head.extra=new Uint8Array(n.head.extra_len)),n.head.extra.set(r.subarray(o,o+_),w)),512&n.flags&&4&n.wrap&&(n.check=gt(n.check,r,_,o)),a-=_,o+=_,n.length-=_),n.length))break e;n.length=0,n.mode=16186;case 16186:if(2048&n.flags){if(0===a)break e;_=0;do{w=r[o+_++],n.head&&w&&n.length<65536&&(n.head.name+=String.fromCharCode(w))}while(w&&_>9&1,n.head.done=!0),e.adler=n.check=0,n.mode=rr;break;case 16189:for(;l<32;){if(0===a)break e;a--,u+=r[o++]<>>=7&l,l-=7&l,n.mode=cr;break}for(;l<3;){if(0===a)break e;a--,u+=r[o++]<>>=1,l-=1,3&u){case 0:n.mode=16193;break;case 1:if(mr(n),n.mode=sr,t===Vn){u>>>=2,l-=2;break e}break;case 2:n.mode=16196;break;case 3:e.msg="invalid block type",n.mode=ur}u>>>=2,l-=2;break;case 16193:for(u>>>=7&l,l-=7&l;l<32;){if(0===a)break e;a--,u+=r[o++]<>>16^65535)){e.msg="invalid stored block lengths",n.mode=ur;break}if(n.length=65535&u,u=0,l=0,n.mode=or,t===Vn)break e;case or:n.mode=16195;case 16195:if(_=n.length,_){if(_>a&&(_=a),_>c&&(_=c),0===_)break e;i.set(r.subarray(o,o+_),s),a-=_,o+=_,c-=_,s+=_,n.length-=_;break}n.mode=rr;break;case 16196:for(;l<14;){if(0===a)break e;a--,u+=r[o++]<>>=5,l-=5,n.ndist=1+(31&u),u>>>=5,l-=5,n.ncode=4+(15&u),u>>>=4,l-=4,n.nlen>286||n.ndist>30){e.msg="too many length or distance symbols",n.mode=ur;break}n.have=0,n.mode=16197;case 16197:for(;n.have>>=3,l-=3}for(;n.have<19;)n.lens[A[n.have++]]=0;if(n.lencode=n.lendyn,n.lenbits=7,C={bits:n.lenbits},S=Kn(0,n.lens,0,19,n.lencode,0,n.work,C),n.lenbits=C.bits,S){e.msg="invalid code lengths set",n.mode=ur;break}n.have=0,n.mode=16198;case 16198:for(;n.have>>24,v=k>>>16&255,E=65535&k,!(g<=l);){if(0===a)break e;a--,u+=r[o++]<>>=g,l-=g,n.lens[n.have++]=E;else{if(16===E){for(O=g+2;l>>=g,l-=g,0===n.have){e.msg="invalid bit length repeat",n.mode=ur;break}w=n.lens[n.have-1],_=3+(3&u),u>>>=2,l-=2}else if(17===E){for(O=g+3;l>>=g,l-=g,w=0,_=3+(7&u),u>>>=3,l-=3}else{for(O=g+7;l>>=g,l-=g,w=0,_=11+(127&u),u>>>=7,l-=7}if(n.have+_>n.nlen+n.ndist){e.msg="invalid bit length repeat",n.mode=ur;break}for(;_--;)n.lens[n.have++]=w}}if(n.mode===ur)break;if(0===n.lens[256]){e.msg="invalid code -- missing end-of-block",n.mode=ur;break}if(n.lenbits=9,C={bits:n.lenbits},S=Kn(1,n.lens,0,n.nlen,n.lencode,0,n.work,C),n.lenbits=C.bits,S){e.msg="invalid literal/lengths set",n.mode=ur;break}if(n.distbits=6,n.distcode=n.distdyn,C={bits:n.distbits},S=Kn(2,n.lens,n.nlen,n.ndist,n.distcode,0,n.work,C),n.distbits=C.bits,S){e.msg="invalid distances set",n.mode=ur;break}if(n.mode=sr,t===Vn)break e;case sr:n.mode=ar;case ar:if(a>=6&&c>=258){e.next_out=s,e.avail_out=c,e.next_in=o,e.avail_in=a,n.hold=u,n.bits=l,Un(e,d),s=e.next_out,i=e.output,c=e.avail_out,o=e.next_in,r=e.input,a=e.avail_in,u=n.hold,l=n.bits,n.mode===rr&&(n.back=-1);break}for(n.back=0;k=n.lencode[u&(1<>>24,v=k>>>16&255,E=65535&k,!(g<=l);){if(0===a)break e;a--,u+=r[o++]<>b)],g=k>>>24,v=k>>>16&255,E=65535&k,!(b+g<=l);){if(0===a)break e;a--,u+=r[o++]<>>=b,l-=b,n.back+=b}if(u>>>=g,l-=g,n.back+=g,n.length=E,0===v){n.mode=16205;break}if(32&v){n.back=-1,n.mode=rr;break}if(64&v){e.msg="invalid literal/length code",n.mode=ur;break}n.extra=15&v,n.mode=16201;case 16201:if(n.extra){for(O=n.extra;l>>=n.extra,l-=n.extra,n.back+=n.extra}n.was=n.length,n.mode=16202;case 16202:for(;k=n.distcode[u&(1<>>24,v=k>>>16&255,E=65535&k,!(g<=l);){if(0===a)break e;a--,u+=r[o++]<>b)],g=k>>>24,v=k>>>16&255,E=65535&k,!(b+g<=l);){if(0===a)break e;a--,u+=r[o++]<>>=b,l-=b,n.back+=b}if(u>>>=g,l-=g,n.back+=g,64&v){e.msg="invalid distance code",n.mode=ur;break}n.offset=E,n.extra=15&v,n.mode=16203;case 16203:if(n.extra){for(O=n.extra;l>>=n.extra,l-=n.extra,n.back+=n.extra}if(n.offset>n.dmax){e.msg="invalid distance too far back",n.mode=ur;break}n.mode=16204;case 16204:if(0===c)break e;if(_=d-c,n.offset>_){if(_=n.offset-_,_>n.whave&&n.sane){e.msg="invalid distance too far back",n.mode=ur;break}_>n.wnext?(_-=n.wnext,f=n.wsize-_):f=n.wnext-_,_>n.length&&(_=n.length),p=n.window}else p=i,f=s-n.offset,_=n.length;_>c&&(_=c),c-=_,n.length-=_;do{i[s++]=p[f++]}while(--_);0===n.length&&(n.mode=ar);break;case 16205:if(0===c)break e;i[s++]=n.length,c--,n.mode=ar;break;case cr:if(n.wrap){for(;l<32;){if(0===a)break e;a--,u|=r[o++]<{if(dr(e))return Yn;let t=e.state;return t.window&&(t.window=null),e.state=null,Hn},inflateGetHeader:(e,t)=>{if(dr(e))return Yn;const n=e.state;return 0==(2&n.wrap)?Yn:(n.head=t,t.done=!1,Hn)},inflateSetDictionary:(e,t)=>{const n=t.length;let r,i,o;return dr(e)?Yn:(r=e.state,0!==r.wrap&&r.mode!==nr?Yn:r.mode===nr&&(i=1,i=ft(i,t,n,0),i!==r.check)?Xn:(o=yr(e,t,n,n),o?(r.mode=16210,Jn):(r.havedict=1,Hn)))},inflateInfo:"pako inflate (from Nodeca project)"};var Sr=function(){this.text=0,this.time=0,this.xflags=0,this.os=0,this.extra=null,this.extra_len=0,this.name="",this.comment="",this.hcrc=0,this.done=!1};const kr=Object.prototype.toString,{Z_NO_FLUSH:Tr,Z_FINISH:Cr,Z_OK:Or,Z_STREAM_END:Ar,Z_NEED_DICT:Nr,Z_STREAM_ERROR:Ir,Z_DATA_ERROR:Rr,Z_MEM_ERROR:Dr}=Et;function Lr(e){this.options=En.assign({chunkSize:65536,windowBits:15,to:""},e||{});const t=this.options;t.raw&&t.windowBits>=0&&t.windowBits<16&&(t.windowBits=-t.windowBits,0===t.windowBits&&(t.windowBits=-15)),!(t.windowBits>=0&&t.windowBits<16)||e&&e.windowBits||(t.windowBits+=32),t.windowBits>15&&t.windowBits<48&&0==(15&t.windowBits)&&(t.windowBits|=15),this.err=0,this.msg="",this.ended=!1,this.chunks=[],this.strm=new wn,this.strm.avail_out=0;let n=wr.inflateInit2(this.strm,t.windowBits);if(n!==Or)throw new Error(vt[n]);if(this.header=new Sr,wr.inflateGetHeader(this.strm,this.header),t.dictionary&&("string"==typeof t.dictionary?t.dictionary=yn.string2buf(t.dictionary):"[object ArrayBuffer]"===kr.call(t.dictionary)&&(t.dictionary=new Uint8Array(t.dictionary)),t.raw&&(n=wr.inflateSetDictionary(this.strm,t.dictionary),n!==Or)))throw new Error(vt[n])}function xr(e,t){const n=new Lr(t);if(n.push(e),n.err)throw n.msg||vt[n.err];return n.result}Lr.prototype.push=function(e,t){const n=this.strm,r=this.options.chunkSize,i=this.options.dictionary;let o,s,a;if(this.ended)return!1;for(s=t===~~t?t:!0===t?Cr:Tr,"[object ArrayBuffer]"===kr.call(e)?n.input=new Uint8Array(e):n.input=e,n.next_in=0,n.avail_in=n.input.length;;){for(0===n.avail_out&&(n.output=new Uint8Array(r),n.next_out=0,n.avail_out=r),o=wr.inflate(n,s),o===Nr&&i&&(o=wr.inflateSetDictionary(n,i),o===Or?o=wr.inflate(n,s):o===Rr&&(o=Nr));n.avail_in>0&&o===Ar&&n.state.wrap>0&&0!==e[n.next_in];)wr.inflateReset(n),o=wr.inflate(n,s);switch(o){case Ir:case Rr:case Nr:case Dr:return this.onEnd(o),this.ended=!0,!1}if(a=n.avail_out,n.next_out&&(0===n.avail_out||o===Ar))if("string"===this.options.to){let e=yn.utf8border(n.output,n.next_out),t=n.next_out-e,i=yn.buf2string(n.output,e);n.next_out=t,n.avail_out=r-t,t&&n.output.set(n.output.subarray(e,e+t),0),this.onData(i)}else this.onData(n.output.length===n.next_out?n.output:n.output.subarray(0,n.next_out));if(o!==Or||0!==a){if(o===Ar)return o=wr.inflateEnd(this.strm),this.onEnd(o),this.ended=!0,!0;if(0===n.avail_in)break}}return!0},Lr.prototype.onData=function(e){this.chunks.push(e)},Lr.prototype.onEnd=function(e){e===Or&&("string"===this.options.to?this.result=this.chunks.join(""):this.result=En.flattenChunks(this.chunks)),this.chunks=[],this.err=e,this.msg=this.strm.msg};var Mr={Inflate:Lr,inflate:xr,inflateRaw:function(e,t){return(t=t||{}).raw=!0,xr(e,t)},ungzip:xr,constants:Et};const{Deflate:Pr,deflate:Ur,deflateRaw:zr,gzip:Fr}=Mn,{Inflate:qr,inflate:Gr,inflateRaw:jr,ungzip:Kr}=Mr;var Br,Zr={Deflate:Pr,deflate:Ur,deflateRaw:zr,gzip:Fr,Inflate:qr,inflate:Gr,inflateRaw:jr,ungzip:Kr,constants:Et};!function(e){e.CONNECTING="CONNECTING",e.OPEN="OPEN",e.CLOSED="CLOSED"}(Br||(Br={}));var Vr,Hr=function(e){function n(t,n){var r=n.sdkState,i=n.dispatcher,o=n.logger,s=e.call(this)||this;return s.lastActive=0,s._iid=t,s._sdkState=r,s._dispatcher=i,s._logger=o,s}return t(n,e),Object.defineProperty(n.prototype,"isOpen",{get:function(){return this.connectionState===Br.OPEN},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"connectionState",{get:function(){if(this._ws)switch(this._ws.readyState){case 0:return Br.CONNECTING;case 1:return Br.OPEN}return Br.CLOSED},enumerable:!1,configurable:!0}),n.prototype._handleMessage=function(e){var t=this;e.split("\n").forEach((function(e){if(e){var n=Ae.createFromRawMessage(t._iid,e);if(t._logger.debug("receive websocket event",n),"LOGI"===n.code)t.dispatch("message",n);else if("PONG"===n.code)t.dispatch("pong");else if("EXPR"===n.code){if(n.payload){var r=new Se(n.payload);r.expiresIn>=0&&t._dispatcher.dispatch(r)}}else"NOOP"===n.code||t.dispatch("message",n)}}))},n.prototype.connect=function(e){var t=this;this._ws=new WebSocket(e),this._ws.onopen=function(){t._logger.debug("websocket open"),t.dispatch("open")},this._ws.onmessage=function(e){return i(t,void 0,void 0,(function(){var t,n,r=this;return o(this,(function(s){return(null===(n=this._sdkState.websocket)||void 0===n?void 0:n.compression)?e.data instanceof Blob?((t=new FileReader).readAsArrayBuffer(e.data),t.onloadend=function(){return i(r,void 0,void 0,(function(){var e;return o(this,(function(n){switch(n.label){case 0:return[4,(r=t.result,i(void 0,void 0,void 0,(function(){var e;return o(this,(function(t){return e=Zr.ungzip(r),[2,String.fromCharCode.apply(null,e)]}))})))];case 1:return e=n.sent(),this._handleMessage(e),[2]}var r}))}))}):"string"==typeof e.data&&this._handleMessage(e.data):this._handleMessage(e.data),[2]}))}))},this._ws.onerror=function(){t._logger.debug("websocket error"),t.dispatch("error",E.networkError)},this._ws.onclose=function(){t._logger.debug("websocket close"),t.dispatch("close")},this.lastActive=Date.now()},n.prototype.disconnect=function(){var e=this;return new Promise((function(t){e._logger.debug("websocket disconnect"),e._ws&&e.connectionState!==Br.CLOSED?(e._ws.onopen=Ne,e._ws.onmessage=Ne,e._ws.onerror=Ne,e._ws.onclose=function(){e.dispatch("close"),t()},e._ws.close(),e._ws=null):t()}))},n.prototype.send=function(e){if(!this._ws)throw E.connectionClosed;"PING"!==e.code?this.dispatch("ping-refresh"):this._logger.debug("send ping",e),this._ws.send(e.convertToMessage())},n.prototype.error=function(e){this._logger.debug("websocket error",e),this.dispatch("error",e)},n}(W),Wr=function(e){function n(t){var n,r=t.code,i=t.ackRequired,o=t.payload,s=void 0===o?null:o,a=this;return(a=e.call(this)||this).code=r,a.payload=s,a.requestId=null!==(n=a.payload.req_id)&&void 0!==n?n:V(),a.ackRequired=i,a.payload.req_id=a.requestId,a}return t(n,e),n.prototype.convertToMessage=function(){return"".concat(this.code).concat(JSON.stringify(this.payload),"\n")},n}(Y),Qr=function(e){function n(t){var n=t.all,r=t.custom_types,i=t.ts,o=e.call(this)||this;return o.all=n,o.customTypes=r,o.ts=i,o}return t(n,e),n}(Y),Yr=function(){var e=this;this.promise=new Promise((function(t,n){e.resolve=t,e.reject=n}))},Xr=function(){function e(e,t){var n=t.auth,r=t.sdkState,i=t.dispatcher,o=t.logger,s=t.useFetchCompat,a=void 0!==s&&s,c=this;this._ackStateMap=new Map,this._sdkState=r,this._dispatcher=i,this._logger=o,this.apiClient=new Oe(e,{auth:n,sdkState:r,dispatcher:i,logger:o,useFetchCompat:a}),this.websocketClient=new Hr(e,{sdkState:r,dispatcher:i,logger:o}),this.websocketClient.on("message",(function(e){if(e.payload.unread_cnt&&c._dispatcher.dispatch(new Qr(e.payload.unread_cnt)),e.requestId){if(c._ackStateMap.has(e.requestId)){var t=c._ackStateMap.get(e.requestId);"EROR"!==e.code?t.resolve(e):t.reject(new E({code:e.payload.code,message:e.payload.message}))}}else c._dispatcher.dispatch(e)})).on("close",(function(){c._ackStateMap.forEach((function(e){e.reject(E.connectionClosed)})),c._ackStateMap.clear()}))}return e.prototype._sendApiRequest=function(e){return i(this,void 0,void 0,(function(){return o(this,(function(t){switch(t.label){case 0:return[4,this.apiClient.send(e)];case 1:return[2,t.sent()]}}))}))},e.prototype._sendWebsocketRequest=function(e){return i(this,void 0,void 0,(function(){var t,n,r,i=this;return o(this,(function(o){if(t=new Yr,e.ackRequired){n=null,r=function(r,o){void 0===r&&(r=null),void 0===o&&(o=null),i._ackStateMap.has(e.requestId)&&(i._ackStateMap.delete(e.requestId),n&&(clearTimeout(n),n=null),r?(i._logger.debug("fail websocket request",r),t.reject(r)):(i._logger.debug("receive websocket ack",e.requestId),t.resolve(o)))};try{n=setTimeout((function(){return r(E.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 i(this,void 0,void 0,(function(){return o(this,(function(t){switch(t.label){case 0:return e instanceof me?[4,this._sendApiRequest(e)]:[3,2];case 1:case 3:return[2,t.sent()];case 2:return e instanceof Wr?[4,this._sendWebsocketRequest(e)]:[3,4];case 4:throw E.invalidParameters}}))}))},e.prototype.cancel=function(e){this.apiClient.cancel(e)},e.prototype.cancelAll=function(){this.apiClient.cancelAll()},e}();!function(e){e[e.NONE=0]="NONE",e[e.INITIALIZED=1]="INITIALIZED",e[e.CONNECTING=2]="CONNECTING",e[e.CONNECTED=3]="CONNECTED",e[e.RECONNECTING=4]="RECONNECTING",e[e.INTERNAL_DISCONNECTED=5]="INTERNAL_DISCONNECTED",e[e.EXTERNAL_DISCONNECTED=6]="EXTERNAL_DISCONNECTED",e[e.LOGOUT=7]="LOGOUT"}(Vr||(Vr={}));var Jr=function(e){function n(t){var n=t.stateType,r=e.call(this)||this;return r.stateType=n,r}return t(n,e),n}(Y),$r=function(){function e(e,t){var n=t.auth,r=t.sdkState,s=t.dispatcher,a=t.logger,c=t.useFetchCompat,u=void 0!==c&&c,l=this;this._currentConnectionStateType=Vr.INITIALIZED,this._lazyCallQueue=[],this.commandRouter=new Xr(e,{auth:n,sdkState:r,dispatcher:s,logger:a,useFetchCompat:u}),this._auth=n,this._logger=a,this._dispatcher=s,this._dispatcher.on((function(e){if(e instanceof Jr){var t=e.stateType;switch(l._currentConnectionStateType=t,t){case Vr.CONNECTED:var n=l._lazyCallQueue;l._lazyCallQueue=[],n.forEach((function(e){return i(l,void 0,void 0,(function(){var t,n,r,i,s;return o(this,(function(o){switch(o.label){case 0:t=e.command,n=e.deferred,r=e.timeout,clearTimeout(r),o.label=1;case 1:return o.trys.push([1,3,,4]),[4,this.send(t)];case 2:return i=o.sent(),n.resolve(i),[3,4];case 3:return s=o.sent(),n.reject(s),[3,4];case 4:return[2]}}))}))}));break;case Vr.INITIALIZED:case Vr.INTERNAL_DISCONNECTED:case Vr.EXTERNAL_DISCONNECTED:case Vr.LOGOUT:n=l._lazyCallQueue;l._lazyCallQueue=[],n.forEach((function(e){return i(l,void 0,void 0,(function(){var t,n;return o(this,(function(r){return t=e.deferred,n=e.timeout,clearTimeout(n),this._auth&&this._auth.hasSession?t.reject(E.connectionClosed):t.reject(E.connectionRequired),[2]}))}))}))}}}))}return Object.defineProperty(e.prototype,"isReady",{get:function(){return this._currentConnectionStateType===Vr.CONNECTED},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"isLazyCallActivated",{get:function(){return this._currentConnectionStateType===Vr.CONNECTING||this._currentConnectionStateType===Vr.RECONNECTING},enumerable:!1,configurable:!0}),e.prototype.send=function(e){return i(this,void 0,void 0,(function(){var t,n,r=this;return o(this,(function(i){switch(i.label){case 0:return e instanceof Wr?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 Yr,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"),E.connectionRequired;case 3:return[3,7];case 4:return e instanceof me?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 Yr,this._lazyCallQueue.push({command:e,deferred:t,timeout:setTimeout((function(){return r.timeout(e.requestId)}),1e4)}),[2,t.promise];throw n=E.connectionRequired,this._logger.debug("fail api request",n),n;case 7:return[2]}}))}))},e.prototype.forceSend=function(e){return i(this,void 0,void 0,(function(){return o(this,(function(t){switch(t.label){case 0:return this._logger.debug("send forced request",e),[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(E.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}(),ei="sendbird@devicetokens",ti=function(){function e(e){var t=e.type,n=e.token;this.type=t,this.token=n}return e.payloadify=function(e){return{type:e.type,token:e.token}},e}(),ni=function(e){function n(t){var n=t.userId,r=t.authToken,i=t.expiringSession,o=void 0===i||i,s=e.call(this)||this;return s.path="".concat(ee,"/").concat(n,"/session_key"),s.method=J.POST,s.params={token:r,expiring_session:!!o},s.requireAuth=!1,s}return t(n,e),n}(me),ri=function(e){function n(t){var n=t.authToken,r=t.expiringSession,i=void 0===r||r,o=t.requestId,s=void 0===o?null:o;return e.call(this,{code:"LOGI",payload:{token:n,expiring_session:i?1:0,req_id:s},ackRequired:!0})||this}return t(n,e),n}(Wr),ii=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}(ye),oi=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 E(r.error):null,i}return t(n,e),n}(Ae),si=function(e){function n(){return null!==e&&e.apply(this,arguments)||this}return t(n,e),n}(Y),ai=function(e){return i(void 0,void 0,void 0,(function(){return o(this,(function(t){return[2,new Promise((function(t){return setTimeout(t,e)}))]}))}))},ci=function(){function e(){}return e.prototype.calcTimeout=function(){return 0},e}(),ui=function(e,t,n){return void 0===n&&(n=new ci),i(void 0,void 0,void 0,(function(){var r,i,s,a,c,u;return o(this,(function(o){switch(o.label){case 0:r=0,i=null,s=function(e){return void 0===e&&(e=null),i=null!=e?e:new Error("Halted")},a=function(){r=0},o.label=1;case 1:if(!(-1===t||r=0},n.prototype.createRefreshWebsocketCommand=function(e,t){return void 0===t&&(t=null),new ri({authToken:e,expiringSession:!0,requestId:t})},n.prototype._refreshSessionKeyByWebSocket=function(e){return i(this,void 0,void 0,(function(){var t,n,r,i,s;return o(this,(function(o){switch(o.label){case 0:return t=this.createRefreshWebsocketCommand(e),[4,this._requestQueue.forceSend(t)];case 1:if(n=o.sent(),r=n.as(oi),i=r.newKey,s=r.error)throw s;return this.auth.sessionKey=null!=i?i:this.auth.sessionKey,[2]}}))}))},n.prototype._refreshSessionKeyByApi=function(e){return i(this,void 0,void 0,(function(){var t,n=this;return o(this,(function(r){switch(r.label){case 0:return t=new ni({userId:this._sdkState.userId,authToken:e,expiringSession:!0}),[4,ui((function(e){return i(n,void 0,void 0,(function(){var n,r,i;return o(this,(function(o){switch(o.label){case 0:return o.trys.push([0,2,,3]),[4,this._requestQueue.forceSend(t)];case 1:return n=o.sent(),r=n.as(ii).key,this.auth.sessionKey=r,[3,3];case 2:if(i=o.sent(),!this._isSessionRelatedError(i))throw i;return e(i),[3,3];case 3:return[2]}}))}))}),3)];case 1:return r.sent(),[2]}}))}))},n.prototype._refreshSessionKey=function(e,t){return void 0===t&&(t=!0),i(this,void 0,void 0,(function(){var n,r,i,s;return o(this,(function(o){switch(o.label){case 0:if(this._currentConnectionStateType!==Vr.CONNECTED)return[3,10];o.label=1;case 1:return o.trys.push([1,3,,10]),[4,this._refreshSessionKeyByWebSocket(e)];case 2:return o.sent(),this.complete(),[2];case 3:return n=o.sent(),this._isSessionRelatedError(n)?t?(r=this.auth,[4,this._receiveNewAuthToken()]):[3,9]:[3,9];case 4:return r.authToken=o.sent(),this.auth.authToken?[4,this._refreshSessionKey(this.auth.authToken,!1)]:[3,6];case 5:return o.sent(),this.complete(),[3,8];case 6:return[4,this.clear()];case 7:o.sent(),this.close(),o.label=8;case 8:return[2];case 9:return[3,10];case 10:return o.trys.push([10,12,,22]),[4,this._refreshSessionKeyByApi(e)];case 11:return o.sent(),this.complete(),[3,22];case 12:return i=o.sent(),this._isSessionRelatedError(i)?t?(s=this.auth,[4,this._receiveNewAuthToken()]):[3,18]:[3,20];case 13:return s.authToken=o.sent(),this.auth.authToken?[4,this._refreshSessionKeyByApi(this.auth.authToken)]:[3,15];case 14:return o.sent(),this.complete(),[3,17];case 15:return[4,this.clear()];case 16:o.sent(),this.close(),o.label=17;case 17:return[3,19];case 18:throw i;case 19:return[3,21];case 20:throw i;case 21:return[3,22];case 22:return[2]}}))}))},n.prototype._receiveNewAuthToken=function(){var e=this,t=new Yr;return li((function(){return i(e,void 0,void 0,(function(){var e,n,r=this;return o(this,(function(i){return this._isRefreshingAuthToken=!0,this.auth.clear(),e=null,n=function(){e&&(clearTimeout(e),e=null)},e=setTimeout((function(){r._isRefreshingAuthToken=!1,t.reject()}),1e3*this._sdkState.sessionTokenRefreshTimeout),this.handler.onSessionTokenRequired?this.handler.onSessionTokenRequired((function(e){n(),r._isRefreshingAuthToken&&(r._isRefreshingAuthToken=!1,r.dispatch("refresh-authtoken"),t.resolve(e))}),(function(e){n(),r._isRefreshingAuthToken=!1,t.reject(e)})):t.resolve(null),[2]}))}))})),t.promise},n.prototype._isSessionRelatedError=function(e){return e instanceof E&&(e.isSessionKeyExpiredError||e.isSessionTokenExpiredError||e.isSessionRevokedError)},Object.defineProperty(n.prototype,"isSessionKeyRefreshing",{get:function(){return this._isRefreshingSessionKey},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"isRefreshingAuthToken",{get:function(){return this._isRefreshingAuthToken},enumerable:!1,configurable:!0}),n.prototype.login=function(e){var t;return i(this,void 0,void 0,(function(){var n,r,i,s,a,c,u;return o(this,(function(o){switch(o.label){case 0:return n=e.key,r=e.ekey,i=e.userProfile,s=e.deviceTokenLastDeletedAt,a=void 0===s?0:s,this.auth.sessionKey=n,di.set(this,r),this._deviceTokenCacheEnabled=null===(t=null==i?void 0:i.appInfo)||void 0===t?void 0:t.deviceTokenCache,c=this._cacheContext.preference,this._deviceTokenCacheEnabled?[4,c.get(ei)]:[3,5];case 1:return!(u=o.sent())||u.lastDeletedAt=0&&this._deviceTokens.splice(n,1)}},n.prototype.unsetDeviceTokens=function(e){this._deviceTokenCacheEnabled&&(this._deviceTokens=e?this._deviceTokens.filter((function(t){return t.type!==e})):[])},n.prototype.setDeviceTokenDeletedAt=function(e){e>0&&(this._deviceTokenLastDeletedAt=e)},n.prototype.saveDeviceToken=function(){return i(this,void 0,void 0,(function(){return o(this,(function(e){switch(e.label){case 0:return this._deviceTokenCacheEnabled?[4,this._cacheContext.preference.set(ei,{tokens:this._deviceTokens,lastDeletedAt:this._deviceTokenLastDeletedAt})]:[3,2];case 1:e.sent(),e.label=2;case 2:return[2]}}))}))},n.prototype.clear=function(){return i(this,void 0,void 0,(function(){return o(this,(function(e){switch(e.label){case 0:return this.currentUser=null,this.auth.clear(),this.close(),di.delete(this),this._deviceTokens=[],this._deviceTokenLastDeletedAt=0,[4,this.saveDeviceToken()];case 1:return e.sent(),[2]}}))}))},n}(W),fi=function(){function e(){this.type=Vr.NONE,this.name="none"}return e.prototype.run=function(e){return i(this,void 0,void 0,(function(){return o(this,(function(e){return[2]}))}))},e.prototype.onConnect=function(e,t){return i(this,void 0,void 0,(function(){return o(this,(function(e){return[2]}))}))},e.prototype.onReconnect=function(e,t){return t.resetReconnectCount,i(this,void 0,void 0,(function(){return o(this,(function(e){return[2]}))}))},e.prototype.onDisconnect=function(e,t){return t.error,t.autoReconnect,i(this,void 0,void 0,(function(){return o(this,(function(e){return[2]}))}))},e.prototype.onDisconnectWebSocket=function(e){return i(this,void 0,void 0,(function(){return o(this,(function(e){return[2]}))}))},e.prototype.onLogout=function(e){return i(this,void 0,void 0,(function(){return o(this,(function(e){return[2]}))}))},e}(),pi=function(e){function n(){var t=null!==e&&e.apply(this,arguments)||this;return t.type=Vr.LOGOUT,t.name="logout",t}return t(n,e),n.prototype.run=function(e){return i(this,void 0,void 0,(function(){var t,n,r=this;return o(this,(function(s){switch(s.label){case 0:return t=Date.now(),n=e.sdkState.userId,[4,e.logout()];case 1:return s.sent(),[4,e.changeState(new yi,t)];case 2:return s.sent(),li((function(){return i(r,void 0,void 0,(function(){return o(this,(function(t){return e.connectionHandlers.forEach((function(e){e.onDisconnected(n)})),[2]}))}))})),[2]}}))}))},n}(fi),gi=function(e){function n(){var t=e.call(this)||this;return t.type=Vr.EXTERNAL_DISCONNECTED,t.name="externaldisconnected",t}return t(n,e),n.prototype.run=function(e){return i(this,void 0,void 0,(function(){return o(this,(function(t){switch(t.label){case 0:return[4,e.disconnect()];case 1:return t.sent(),[2]}}))}))},n.prototype.onConnect=function(e,t){return i(this,void 0,void 0,(function(){var n;return o(this,(function(r){switch(r.label){case 0:return n=Date.now(),[4,e.disconnect()];case 1:return r.sent(),[4,e.changeState(new mi({authToken:t}),n)];case 2:return r.sent(),[2]}}))}))},n.prototype.onReconnect=function(e){return i(this,void 0,void 0,(function(){var t;return o(this,(function(n){switch(n.label){case 0:return t=Date.now(),[4,e.changeState(new Ei,t)];case 1:return n.sent(),[2]}}))}))},n.prototype.onLogout=function(e){return i(this,void 0,void 0,(function(){var t;return o(this,(function(n){switch(n.label){case 0:return t=Date.now(),[4,e.changeState(new pi,t)];case 1:return n.sent(),[2]}}))}))},n}(fi),vi=function(e){function n(t){var n=t.autoReconnect,r=e.call(this)||this;return r.type=Vr.INTERNAL_DISCONNECTED,r.name="internaldisconnected",r._autoReconnect=!1,r._autoReconnect=n,r}return t(n,e),n.prototype.run=function(e){return i(this,void 0,void 0,(function(){var t;return o(this,(function(n){switch(n.label){case 0:return t=Date.now(),[4,e.disconnect()];case 1:return n.sent(),this._autoReconnect?[4,e.changeState(new Ei,t)]:[3,3];case 2:n.sent(),n.label=3;case 3:return[2]}}))}))},n.prototype.onConnect=function(e,t){return i(this,void 0,void 0,(function(){var n;return o(this,(function(r){switch(r.label){case 0:return n=Date.now(),[4,e.disconnect()];case 1:return r.sent(),[4,e.changeState(new mi({authToken:t}),n)];case 2:return r.sent(),[2]}}))}))},n.prototype.onReconnect=function(e){return i(this,void 0,void 0,(function(){var t;return o(this,(function(n){switch(n.label){case 0:return t=Date.now(),[4,e.changeState(new Ei,t)];case 1:return n.sent(),[2]}}))}))},n.prototype.onDisconnectWebSocket=function(e){return i(this,void 0,void 0,(function(){var t;return o(this,(function(n){switch(n.label){case 0:return t=Date.now(),[4,e.changeState(new gi,t)];case 1:return n.sent(),[2]}}))}))},n.prototype.onLogout=function(e){return i(this,void 0,void 0,(function(){var t;return o(this,(function(n){switch(n.label){case 0:return t=Date.now(),[4,e.changeState(new pi,t)];case 1:return n.sent(),[2]}}))}))},n}(fi),Ei=function(e){function n(){var t=null!==e&&e.apply(this,arguments)||this;return t.type=Vr.RECONNECTING,t.name="reconnecting",t._haltConnect=null,t._resetConnect=null,t._callbacks=[],t}return t(n,e),n.prototype._halt=function(e){this._haltConnect&&(this._haltConnect(e),this._haltConnect=null)},n.prototype._flushCallbacks=function(e){void 0===e&&(e=null),this._haltConnect=null,this._resetConnect=null,this._callbacks.forEach((function(t){return t(e)}))},n.prototype.run=function(e){return i(this,void 0,void 0,(function(){var t,n,r,s,a,c,l=this;return o(this,(function(h){switch(h.label){case 0:t=Date.now(),n=new Yr,this._callbacks.push((function(e){return e?n.reject(e):n.resolve()})),li((function(){return i(l,void 0,void 0,(function(){return o(this,(function(t){return e.connectionHandlers.forEach((function(e){e.onReconnectStarted()})),[2]}))}))})),h.label=1;case 1:return h.trys.push([1,4,,9]),r=e.sdkState.websocket,s=r.reconnectMaxRetry,a=r.reconnectRetryStrategy,[4,ui((function(t,n){return i(l,void 0,void 0,(function(){var r;return o(this,(function(i){switch(i.label){case 0:this._haltConnect=t,this._resetConnect=n,i.label=1;case 1:return i.trys.push([1,3,,4]),[4,e.connect()];case 2:return i.sent(),[3,4];case 3:if(r=i.sent(),e.clearLoginTimer(),r instanceof E&&r.code===u.CONNECTION_CANCELED)return t(r),[2];throw r;case 4:return[2]}}))}))}),s,a)];case 2:return h.sent(),[4,e.changeState(new bi,t)];case 3:return h.sent(),li((function(){return i(l,void 0,void 0,(function(){return o(this,(function(t){return this._flushCallbacks(null),e.connectionHandlers.forEach((function(e){e.onReconnectSucceeded()})),[2]}))}))})),[3,9];case 4:return c=h.sent(),v(c)?[3,7]:c instanceof E?c.code===u.CONNECTION_CANCELED?[3,6]:[4,e.changeState(new vi({autoReconnect:!1}),t)]:[3,6];case 5:h.sent(),h.label=6;case 6:return li((function(){return i(l,void 0,void 0,(function(){return o(this,(function(t){return this._flushCallbacks(c),e.connectionHandlers.forEach((function(e){e.onReconnectFailed()})),[2]}))}))})),[3,8];case 7:throw c;case 8:return[3,9];case 9:return[2,n.promise]}}))}))},n.prototype.onConnect=function(e,t){return i(this,void 0,void 0,(function(){var n;return o(this,(function(r){return n=new Yr,this._halt(E.connectionCanceled),e.cancelConnectForRetry(),this._callbacks.push((function(){var r=Date.now();e.changeState(new mi({authToken:t}),r).then((function(){n.resolve()})).catch((function(e){n.reject(e)}))})),[2,n.promise]}))}))},n.prototype.onReconnect=function(e,t){var n=t.resetReconnectCount,r=void 0!==n&&n;return i(this,void 0,void 0,(function(){var e;return o(this,(function(t){return e=new Yr,this._resetConnect&&r&&this._resetConnect(),this._callbacks.push((function(t){return t?e.reject(t):e.resolve()})),[2,e.promise]}))}))},n.prototype.onDisconnect=function(e,t){t.error;var n=t.autoReconnect,r=void 0===n||n;return i(this,void 0,void 0,(function(){var t;return o(this,(function(n){switch(n.label){case 0:return t=Date.now(),this._halt(E.connectionCanceled),[4,e.changeState(new vi({autoReconnect:r}),t)];case 1:return n.sent(),[2]}}))}))},n.prototype.onDisconnectWebSocket=function(e){return i(this,void 0,void 0,(function(){var t;return o(this,(function(n){switch(n.label){case 0:return t=Date.now(),this._halt(E.connectionCanceled),[4,e.changeState(new gi,t)];case 1:return n.sent(),[2]}}))}))},n.prototype.onLogout=function(e){return i(this,void 0,void 0,(function(){var t;return o(this,(function(n){switch(n.label){case 0:return t=Date.now(),this._halt(E.connectionCanceled),[4,e.changeState(new pi,t)];case 1:return n.sent(),[2]}}))}))},n}(fi),bi=function(e){function n(){var t=null!==e&&e.apply(this,arguments)||this;return t.type=Vr.CONNECTED,t.name="connected",t}return t(n,e),n.prototype.onReconnect=function(e){return i(this,void 0,void 0,(function(){var t;return o(this,(function(n){switch(n.label){case 0:return t=Date.now(),[4,e.disconnect()];case 1:return n.sent(),[4,e.changeState(new Ei,t)];case 2:return n.sent(),[2]}}))}))},n.prototype.onDisconnect=function(e,t){var n=t.autoReconnect;return i(this,void 0,void 0,(function(){var t;return o(this,(function(r){switch(r.label){case 0:return t=Date.now(),[4,e.changeState(new vi({autoReconnect:n}),t)];case 1:return r.sent(),[2]}}))}))},n.prototype.onDisconnectWebSocket=function(e){return i(this,void 0,void 0,(function(){var t;return o(this,(function(n){switch(n.label){case 0:return t=Date.now(),[4,e.changeState(new gi,t)];case 1:return n.sent(),[2]}}))}))},n.prototype.onLogout=function(e){return i(this,void 0,void 0,(function(){var t;return o(this,(function(n){switch(n.label){case 0:return t=Date.now(),[4,e.changeState(new pi,t)];case 1:return n.sent(),[2]}}))}))},n}(fi),mi=function(e){function n(t){var n=t.authToken,r=e.call(this)||this;return r.type=Vr.CONNECTING,r.name="connecting",r._authToken="",r._haltConnect=null,r._callbacks=[],r._authToken=n,r}return t(n,e),n.prototype._halt=function(e){this._haltConnect&&(this._haltConnect(e),this._haltConnect=null)},n.prototype._flushCallbacks=function(e){void 0===e&&(e=null),this._haltConnect=null,this._callbacks.forEach((function(t){return t(e)}))},n.prototype.run=function(e){return i(this,void 0,void 0,(function(){var t,n,r,s=this;return o(this,(function(a){switch(a.label){case 0:t=Date.now(),n=new Yr,this._callbacks.push((function(e){return e?n.reject(e):n.resolve()})),a.label=1;case 1:return a.trys.push([1,4,,10]),[4,ui((function(t){return i(s,void 0,void 0,(function(){var n;return o(this,(function(r){switch(r.label){case 0:this._haltConnect=t,r.label=1;case 1:return r.trys.push([1,3,,4]),[4,e.connect(this._authToken)];case 2:return r.sent(),[3,4];case 3:if(n=r.sent(),e.clearLoginTimer(),n instanceof E&&n.code===u.CONNECTION_CANCELED)return t(n),[2];throw n;case 4:return[2]}}))}))}),e.sdkState.websocket.connectMaxRetry)];case 2:return a.sent(),[4,e.changeState(new bi,t)];case 3:return a.sent(),li((function(){return i(s,void 0,void 0,(function(){return o(this,(function(t){return this._flushCallbacks(null),e.connectionHandlers.forEach((function(t){t.onConnected(e.sdkState.userId)})),[2]}))}))})),[3,10];case 4:return r=a.sent(),v(r)?[3,8]:[4,e.disconnect()];case 5:return a.sent(),r instanceof E?r.code===u.CONNECTION_CANCELED?[3,7]:[4,e.changeState(new yi,t)]:[3,7];case 6:a.sent(),a.label=7;case 7:return li((function(){return i(s,void 0,void 0,(function(){return o(this,(function(e){return this._flushCallbacks(r),[2]}))}))})),[3,9];case 8:throw r;case 9:return[3,10];case 10:return[2,n.promise]}}))}))},n.prototype.onConnect=function(e){return i(this,void 0,void 0,(function(){var e;return o(this,(function(t){return e=new Yr,this._callbacks.push((function(t){return t?e.reject(t):e.resolve()})),[2,e.promise]}))}))},n.prototype.onDisconnect=function(e,t){var n=t.error,r=void 0===n?null:n,s=t.autoReconnect;return i(this,void 0,void 0,(function(){var t;return o(this,(function(n){switch(n.label){case 0:return t=Date.now(),this._halt(null!=r?r:E.connectionCanceled),e.hasSession?[4,e.changeState(new vi({autoReconnect:s}),t)]:[3,2];case 1:return n.sent(),[3,4];case 2:return[4,e.changeState(new pi,t)];case 3:n.sent(),n.label=4;case 4:return[2]}}))}))},n.prototype.onDisconnectWebSocket=function(e){return i(this,void 0,void 0,(function(){var t;return o(this,(function(n){switch(n.label){case 0:return t=Date.now(),this._halt(E.connectionCanceled),e.hasSession?[4,e.changeState(new gi,t)]:[3,2];case 1:return n.sent(),[3,4];case 2:return[4,e.changeState(new pi,t)];case 3:n.sent(),n.label=4;case 4:return[2]}}))}))},n.prototype.onLogout=function(e){return i(this,void 0,void 0,(function(){var t;return o(this,(function(n){switch(n.label){case 0:return t=Date.now(),this._halt(E.connectionCanceled),[4,e.changeState(new pi,t)];case 1:return n.sent(),[2]}}))}))},n}(fi),yi=function(e){function n(){var t=null!==e&&e.apply(this,arguments)||this;return t.type=Vr.INITIALIZED,t.name="initialized",t}return t(n,e),n.prototype.onConnect=function(e,t){return i(this,void 0,void 0,(function(){var n;return o(this,(function(r){switch(r.label){case 0:return n=Date.now(),[4,e.changeState(new mi({authToken:t}),n)];case 1:return r.sent(),[2]}}))}))},n}(fi),wi=function(e){function n(){return e.call(this,{code:"PING",payload:{id:Date.now(),active:1},ackRequired:!1})||this}return t(n,e),n}(Wr),Si=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 wi;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}(),ki=function(){function e(e){var t;this.lastUpdatedAt=null!==(t=e.last_updated_at)&&void 0!==t?t:0}return e.payloadify=function(e){return X({last_updated_at:e.lastUpdatedAt})},e}(),Ti=1048576,Ci=5,Oi=function(){function e(e){var t,n,r,i,o;void 0===e&&(e={}),this.emojiHash=e.emoji_hash||"",this.uploadSizeLimit=e.file_upload_size_limit?e.file_upload_size_limit*Ti:Number.MAX_SAFE_INTEGER,this.useReaction=!!e.use_reaction,this.applicationAttributes=null!==(t=e.application_attributes)&&void 0!==t?t:[],this.premiumFeatureList=null!==(n=e.premium_feature_list)&&void 0!==n?n:[],this.deviceTokenCache=this.applicationAttributes.includes("sdk_device_token_cache"),this.enabledChannelMemberShipHistory=this.applicationAttributes.includes("channel_membership_history"),this.multipleFilesMessageFileCountLimit=null!==(r=e.multiple_file_send_max_size)&&void 0!==r?r:5,this.allowSdkStatsUpload=null===(i=e.allow_sdk_log_ingestion)||void 0===i||i,this.uikitConfigInfo=new ki(null!==(o=e.uikit_config)&&void 0!==o?o:{})}return e.payloadify=function(e){return{emoji_hash:e.emojiHash,file_upload_size_limit:e.uploadSizeLimit/Ti,application_attributes:e.applicationAttributes,premium_feature_list:e.premiumFeatureList,use_reaction:e.useReaction,allow_sdk_log_ingestion:e.allowSdkStatsUpload,uikit_config:e.uikitConfigInfo?ki.payloadify(e.uikitConfigInfo):void 0}},e}(),Ai=function(){function e(e){this._iid="",this._iid=e}return e.payloadify=function(e){return e?{}:null},e}(),Ni=function(e){function n(t){var n=t.userId,r=t.metadata,i=e.call(this)||this;return i.method=J.POST,i.path="".concat(ee,"/").concat(n,"/metadata"),i.params={metadata:r},i}return t(n,e),n}(me),Ii=function(e){function n(t,n){var r=e.call(this,t,n)||this;return r.metaData=n,r}return t(n,e),n}(ye),Ri=function(e){function n(t){var n=t.userId,r=t.metadata,i=t.upsert,o=e.call(this)||this;return o.method=J.PUT,o.path="".concat(ee,"/").concat(n,"/metadata"),o.params={metadata:r,upsert:i},o}return t(n,e),n}(me),Di=function(e){function n(t,n){var r=e.call(this,t,n)||this;return r.metadata=n,r}return t(n,e),n}(ye),Li=function(e){function n(t){var n=t.userId,r=t.metadataKey,i=e.call(this)||this;return i.method=J.DELETE,i.path="".concat(ee,"/").concat(n,"/metadata/").concat(r),i}return t(n,e),n}(me);!function(e){function n(){return null!==e&&e.apply(this,arguments)||this}t(n,e)}(ye);var xi=function(e){function n(t){var n=t.userId,r=e.call(this)||this;return r.method=J.DELETE,r.path="".concat(ee,"/").concat(n,"/metadata"),r}return t(n,e),n}(me);!function(e){function n(){return null!==e&&e.apply(this,arguments)||this}t(n,e)}(ye);var Mi,Pi=function(e,t){void 0===t&&(t=null);var n=JSON.parse(JSON.stringify(e));return n._iid&&delete n._iid,t&&t(n),n},Ui=function(e,t){void 0===t&&(t=null);var n=JSON.parse(JSON.stringify(e));return t&&t(n),n},zi=function(e){return{do:function(t){e||t()},throw:function(t){if(!e)throw t}}};!function(e){e.ONLINE="online",e.OFFLINE="offline",e.NON_AVAILABLE="nonavailable"}(Mi||(Mi={}));var Fi,qi=function(e){function r(t,n){var r,i,o,s,u,l,h,d,_,f,p,g,v=this;return(v=e.call(this,t)||this).userId=null!==(i=null!==(r=n.guest_id)&&void 0!==r?r:n.user_id)&&void 0!==i?i:"",v.nickname=null!==(s=null!==(o=n.nickname)&&void 0!==o?o:n.name)&&void 0!==s?s:"",v.plainProfileUrl=null!==(l=null!==(u=n.profile_url)&&void 0!==u?u:n.image)&&void 0!==l?l:"",v.requireAuth=null!==(h=n.require_auth_for_profile_image)&&void 0!==h&&h,v.metaData=null!==(d=n.metadata)&&void 0!==d?d:{},v.connectionStatus=Mi.NON_AVAILABLE,S(Mi,n.is_online)?v.connectionStatus=n.is_online:w("boolean",n.is_online)&&(v.connectionStatus=n.is_online?Mi.ONLINE:Mi.OFFLINE),v.isActive=null===(_=n.is_active)||void 0===_||_,v.lastSeenAt=null!==(f=n.last_seen_at)&&void 0!==f?f:null,v.preferredLanguages=n.preferred_languages?c([],a(n.preferred_languages),!1):null,v.friendDiscoveryKey=null!==(p=n.friend_discovery_key)&&void 0!==p?p:null,v.friendName=null!==(g=n.friend_name)&&void 0!==g?g:null,v}return t(r,e),r.payloadify=function(t){return t?X(n(n({},e.payloadify.call(this,t)),{user_id:t.userId,nickname:t.nickname,profile_url:t.plainProfileUrl,require_auth_for_profile_image:t.requireAuth,metadata:t.metaData,is_online:t.connectionStatus,is_active:t.isActive,last_seen_at:t.lastSeenAt,preferred_languages:t.preferredLanguages,friend_discovery_key:t.friendDiscoveryKey,friend_name:t.friendName})):null},Object.defineProperty(r.prototype,"profileUrl",{get:function(){var e=to.of(this._iid).sessionManager;return this.requireAuth?"".concat(this.plainProfileUrl,"?auth=").concat(e.ekey):this.plainProfileUrl},enumerable:!1,configurable:!0}),r.prototype.serialize=function(){return Pi(this)},r.prototype._isValidMetaData=function(e){return!Array.isArray(e)&&Object.keys(e).length>0&&Object.keys(e).map((function(t){return e[t]})).every((function(e){return w("string",e)}))},r.prototype._applyMetaData=function(e,t){var n=this;void 0===t&&(t=!1),Object.keys(e).forEach((function(r){t?delete n.metaData[r]:n.metaData[r]=e[r]}))},r.prototype.createMetaData=function(e){return i(this,void 0,void 0,(function(){var t,n,r,i,s,a;return o(this,(function(o){switch(o.label){case 0:return zi(this._isValidMetaData(e)).throw(E.invalidParameters),t=to.of(this._iid),n=t.sdkState,r=t.requestQueue,i=new Ni({userId:n.userId,metadata:e}),[4,r.send(i)];case 1:return s=o.sent(),a=s.as(Ii).metaData,this._applyMetaData(a),[2,this.metaData]}}))}))},r.prototype.updateMetaData=function(e,t){return void 0===t&&(t=!1),i(this,void 0,void 0,(function(){var n,r,i,s,a,c;return o(this,(function(o){switch(o.label){case 0:return zi(this._isValidMetaData(e)).throw(E.invalidParameters),n=to.of(this._iid),r=n.sdkState,i=n.requestQueue,s=new Ri({userId:r.userId,metadata:e,upsert:t}),[4,i.send(s)];case 1:return a=o.sent(),c=a.as(Di).metadata,this._applyMetaData(c),[2,this.metaData]}}))}))},r.prototype.deleteMetaData=function(e){return i(this,void 0,void 0,(function(){var t,n,r,i,s;return o(this,(function(o){switch(o.label){case 0:return zi(w("string",e)).throw(E.invalidParameters),t=to.of(this._iid),n=t.sdkState,r=t.requestQueue,i=new Li({userId:n.userId,metadataKey:e}),[4,r.send(i)];case 1:return o.sent(),this._applyMetaData(((s={})[e]=!0,s),!0),[2,this.metaData]}}))}))},r.prototype.deleteAllMetaData=function(){return i(this,void 0,void 0,(function(){var e,t,n,r;return o(this,(function(i){switch(i.label){case 0:return e=to.of(this._iid),t=e.sdkState,n=e.requestQueue,r=new xi({userId:t.userId}),[4,n.send(r)];case 1:return i.sent(),this.metaData={},[2]}}))}))},r}(Ai),Gi=function(e){function n(t){var n=t.userProfile,r=e.call(this)||this;return r.userProfile=n,r}return t(n,e),n}(Y),ji=function(){function e(e,t){var n,r,i,o,s,a,c,u,l,h,d,_,f,p;this._iid=e,this.appInfo=new Oi(t),this.user=new qi(e,t),this.connectedAt=null!==(n=t.login_ts)&&void 0!==n?n:0,this.firstConnectedAt=0,this.pingInterval=null!==(r=t.ping_interval)&&void 0!==r?r:15e3,this.pongTimeout=null!==(i=t.pong_timeout)&&void 0!==i?i:5e3,this.reconnectInterval=null!==(s=null===(o=t.reconnect)||void 0===o?void 0:o.interval)&&void 0!==s?s:3e3,this.reconnectMaxInterval=null!==(c=null===(a=t.reconnect)||void 0===a?void 0:a.max_interval)&&void 0!==c?c:6e4,this.reconnectRetryCount=null!==(l=null===(u=t.reconnect)||void 0===u?void 0:u.retry_cnt)&&void 0!==l?l:5,this.reconnectIntervalMultiple=null!==(d=null===(h=t.reconnect)||void 0===h?void 0:h.mul)&&void 0!==d?d:2,this.maxUnreadCountOnSuperGroup=null!==(_=t.max_unread_cnt_on_super_group)&&void 0!==_?_:100,this.profileImageEncryption=!!t.profile_image_encryption,this.concurrentCallLimit=null!==(f=t.concurrent_call_limit)&&void 0!==f?f:5,this.backOffDelay=null!==(p=t.back_off_delay)&&void 0!==p?p:100}return e.payloadify=function(e){return n(n(n({},qi.payloadify(e.user)),Oi.payloadify(e.appInfo)),{login_ts:e.connectedAt,ping_interval:e.pingInterval,pong_timeout:e.pongTimeout,reconnect:{interval:e.reconnectInterval,max_interval:e.reconnectMaxInterval,retry_cnt:e.reconnectRetryCount,mul:e.reconnectIntervalMultiple},max_unread_cnt_on_super_group:e.maxUnreadCountOnSuperGroup,profile_image_encryption:e.profileImageEncryption,concurrent_call_limit:e.concurrentCallLimit,back_off_delay:e.backOffDelay})},e.prototype.apply=function(){var e=this.reconnectInterval,t=this.reconnectMaxInterval,n=this.reconnectIntervalMultiple,r=to.of(this._iid);r.sdkState.websocket.pingInterval=1e3*this.pingInterval,r.sdkState.websocket.pongTimeout=1e3*this.pongTimeout,r.sdkState.websocket.reconnectMaxRetry=this.reconnectRetryCount,r.sdkState.websocket.reconnectRetryStrategy={calcTimeout:function(r){return r>0?1e3*Math.min(e*Math.pow(n,r-1),t):10}},r.appInfo=this.appInfo,r.sessionManager.currentUser=this.user,r.connectedAt=this.connectedAt,this.firstConnectedAt||(r.firstConnectedAt=this.connectedAt),r.maxSuperGroupChannelUnreadCount=this.maxUnreadCountOnSuperGroup,r.concurrentCallLimit=this.concurrentCallLimit,r.backOffDelay=this.backOffDelay,r.dispatcher.dispatch(new Gi({userProfile:this}))},e}(),Ki=function(e){function r(t,n,r){var i,o=this;return(o=e.call(this,t,n,r)||this).error=null,o.userProfile=new ji(t,r),o.deviceTokenLastDeletedAt=r.device_token_last_deleted_at,o.key=r.key,o.ekey=null!==(i=r.ekey)&&void 0!==i?i:"",o.error=r.error?new E(r):null,o}return t(r,e),r.asError=function(e){return new r(null,"LOGI",n({user_id:null,error:!0},e))},r.prototype.applyTo=function(e){return i(this,void 0,void 0,(function(){var t;return o(this,(function(n){switch(n.label){case 0:return this.error?[3,4]:(t=to.of(e))?[4,t.sessionManager.login(this)]:[3,2];case 1:return n.sent(),this.userProfile.apply(),[3,3];case 2:throw E.lostInstance;case 3:return[3,5];case 4:throw this.error;case 5:return[2]}}))}))},r}(Ae),Bi=function(e){function r(t){var r=t.request,i=void 0===r||r,o=t.features,s=void 0===o?{}:o,a=t.options,c=void 0===a?{}:a,u=e.call(this)||this;return u.request=i,u.features=n({localCache:!0},s),u.options=n({ingestion:!0},c),u}return t(r,e),r}(Y),Zi=function(e){function n(t,n){var r=n.sdkState,i=n.cacheContext,o=n.connectionHandlers,s=n.sessionManager,a=n.websocketClient,c=n.dispatcher,u=n.logger,l=n.entryState,h=void 0===l?new yi:l,d=e.call(this)||this;return d._currentState=null,d._loginTimer=null,d._logiProcessingTimer=null,d._unresolvedLogi=null,d._stateUpdatedAt=0,d._connectingAt=0,d._connectionRequestQueue=[],d._iid=t,d.sdkState=r,d.cacheContext=i,d.connectionHandlers=o,d._sessionManager=s,d._websocketClient=a,d._dispatcher=c,d._logger=u,d._currentState=h,d.sdkState.websocket.pingerDisabled||(d._pinger=new Si({pingDelegate:{send:function(e){return d._websocketClient.send(e)},error:function(e){return d._websocketClient.error(e)}},sdkState:d.sdkState,logger:u})),d._websocketClient.on("open",(function(){d._tryResolveConnectionRequest()})).on("message",(function(e){if("LOGI"===e.code)d.clearLoginTimer(),d._dispatcher.dispatch(e.as(Ki))})).on("ping-refresh",(function(){var e;return null===(e=d._pinger)||void 0===e?void 0:e.refreshTimer()})).on("pong",(function(){var e;return null===(e=d._pinger)||void 0===e?void 0:e.pong()})).on("error",(function(){var e;return null===(e=d._pinger)||void 0===e?void 0:e.stop()})).on("close",(function(){d._logiProcessingTimer=setTimeout((function(){d._logiProcessingTimer=null,d._unresolvedLogi||d._rejectConnectionRequest(E.networkError)}),500)})),d._dispatcher.on((function(e){e instanceof Ki&&(d._unresolvedLogi=e,d._tryResolveConnectionRequest())})),d}return t(n,e),Object.defineProperty(n.prototype,"currentState",{get:function(){return this._currentState},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"hasSession",{get:function(){return this._sessionManager.auth.hasSession},enumerable:!1,configurable:!0}),n.prototype.changeState=function(e,t){return i(this,void 0,void 0,(function(){return o(this,(function(n){switch(n.label){case 0:return t>=this._stateUpdatedAt?(this._currentState=e,this._stateUpdatedAt=t,this._dispatcher.dispatch(new Jr({stateType:e.type})),this._logger.debug("connection state changes to ".concat(e.name)),[4,this._currentState.run(this)]):[3,2];case 1:return n.sent(),[2,!0];case 2:return[2,!1]}}))}))},n.prototype._tryResolveConnectionRequest=function(){var e;return i(this,void 0,void 0,(function(){var t,n;return o(this,(function(r){switch(r.label){case 0:return t=this._unresolvedLogi,this._websocketClient.isOpen&&t?(this._unresolvedLogi=null,t.error?[3,2]:[4,t.applyTo(this._iid)]):[3,3];case 1:return r.sent(),n=t.userProfile,this._enableStatLog({request:n.appInfo.applicationAttributes.includes("allow_sdk_request_log_publish"),features:{localCache:n.appInfo.applicationAttributes.includes("allow_sdk_feature_local_cache_log_publish")},options:{ingestion:n.appInfo.allowSdkStatsUpload}}),this._statLogConnection(null),null===(e=this._pinger)||void 0===e||e.start(),this._connectionRequestQueue.forEach((function(e){return e.resolve()})),this._connectionRequestQueue=[],this.sdkState.appState="foreground",[3,3];case 2:this._sessionManager.auth.authToken=null,(t.error.isSessionKeyExpiredError||t.error.isSessionTokenExpiredError)&&this._dispatcher.dispatch(new Se({reason:t.error.code})),this._rejectConnectionRequest(t.error),r.label=3;case 3:return[2]}}))}))},n.prototype._rejectConnectionRequest=function(e){var t;if(null===(t=this._pinger)||void 0===t||t.stop(),this.clearLoginTimer(),this._connectionRequestQueue.length>0){var n=this._connectionRequestQueue;this._connectionRequestQueue=[],n.forEach((function(t){return t.reject(e)})),this._statLogConnection(e)}},n.prototype._url=function(e){var t;void 0===e&&(e="");var n=this.sdkState,r=n.appId,i=n.appVersion,o=n.userId,s=n.extensions,a=this.cacheContext.localCacheEnabled,c=this._sessionManager.auth,u=null===(t=this.sdkState.websocket)||void 0===t?void 0:t.compression,l=!!this.sdkState.extensions.sb_uikit,d=s.sb_syncmanager?"s".concat(s.sb_syncmanager):"",_=s.sb_uikit?"u".concat(s.sb_uikit):"",f="JS/c".concat(h.SDK_VERSION,"/").concat(d,"/").concat(_);return"".concat(this.sdkState.websocket.host,"/?p=JS&pv=").concat(encodeURIComponent(h.OS_VERSION),"&sv=").concat(encodeURIComponent(h.SDK_VERSION),"&ai=").concat(r).concat(i?"&av=".concat(i):"").concat(c.hasSession?"&key=".concat(encodeURIComponent(c.sessionKey)):"&user_id=".concat(encodeURIComponent(o),"&access_token=").concat(encodeURIComponent(e)),"&pmce=").concat(u?1:0,"&active=1&device_token_types=").concat(encodeURIComponent(["gcm","huawei","apns"].join(",")),"&SB-User-Agent=").concat(f,"&Request-Sent-Timestamp=").concat(Date.now().toString(),"&include_extra_data=").concat(encodeURIComponent(String(["premium_feature_list","file_upload_size_limit","application_attributes","emoji_hash","multiple_file_send_max_size"]))).concat(this._sessionManager.handler?"&expiring_session=1":"","&use_local_cache=").concat(a?1:0,"&include_poll_details=1").concat(l?"&uikit_config=1":"")},n.prototype._enableStatLog=function(e){var t=e.request,n=e.features,r=e.options,i=void 0===r?{}:r;this._dispatcher.dispatch(new Bi({request:t,features:n,options:i}))},n.prototype._statLogConnection=function(e){this._dispatcher.dispatch(new ke(new Te({type:be.WEBSOCKET_CONNECT,data:{host_url:this.sdkState.websocket.host,success:!e,latency:Date.now()-this._connectingAt,error_code:null==e?void 0:e.code,error_description:null==e?void 0:e.message}})))},n.prototype.connect=function(e){return void 0===e&&(e=""),i(this,void 0,void 0,(function(){var t,n,r=this;return o(this,(function(i){return this._logiProcessingTimer&&(clearTimeout(this._logiProcessingTimer),this._logiProcessingTimer=null,this._rejectConnectionRequest(E.connectionCanceled)),t=this._url(e),n=new Yr,this._connectionRequestQueue.push(n),1===this._connectionRequestQueue.length&&(this._connectingAt=Date.now(),this._loginTimer=setTimeout((function(){r._loginTimer=null,r._rejectConnectionRequest(E.loginTimeout)}),this.sdkState.websocket.responseTimeout),e&&(this._sessionManager.auth.authToken=e),this._websocketClient.connect(t)),[2,n.promise]}))}))},n.prototype.cancelConnectForRetry=function(){this._dispatcher.dispatch(Ki.asError(E.connectionRenew))},n.prototype.disconnect=function(){return i(this,void 0,void 0,(function(){return o(this,(function(e){switch(e.label){case 0:return[4,this._websocketClient.disconnect()];case 1:return e.sent(),[2]}}))}))},n.prototype.logout=function(){return i(this,void 0,void 0,(function(){return o(this,(function(e){switch(e.label){case 0:return this.sdkState.userId=null,this._unresolvedLogi=null,[4,this._sessionManager.clear()];case 1:return e.sent(),[4,this.disconnect()];case 2:return e.sent(),[2]}}))}))},n.prototype.clearLoginTimer=function(){this._loginTimer&&(clearTimeout(this._loginTimer),this._loginTimer=null)},n}(W),Vi=function(){function e(e,t){var n=t.sdkState,r=t.cacheContext,i=t.connectionHandlers,o=t.sessionManager,s=t.websocketClient,a=t.dispatcher,c=t.logger,u=t.disableWebSocketCloseEventHandling,l=void 0!==u&&u;this._context=null,this._disableWebSocketCloseEventHandling=!1,this._externalCalledWebSocketClose=!1,this._logger=c,this._disableWebSocketCloseEventHandling=l,this._context=new Zi(e,{sdkState:n,cacheContext:r,connectionHandlers:i,sessionManager:o,websocketClient:s,dispatcher:a,logger:c}),this._sdkState=n,this._sessionManager=o,this._websocketClient=s}return e.prototype._registerEventDispatcher=function(){var e=this;this._disableWebSocketCloseEventHandling||(this._clearEventDispatcher(),this._sessionEventDispatcherContext=this._sessionManager.on("refresh-authtoken",(function(){e.isConnected||(e._logger.debug("try reconnect by session token refresh"),e.reconnect())})).on("refresh",(function(){e.isConnecting||e.isConnected||(e._logger.debug("try reconnect by session key refresh"),e.reconnect())})),this._websocketEventDispatcherContext=this._websocketClient.on("close",(function(){"foreground"!==e._sdkState.appState||e._externalCalledWebSocketClose||e._sessionManager.isRefreshingAuthToken||(e._logger.debug("try reconnect by websocket connection closed"),e.reconnect())})))},e.prototype._clearEventDispatcher=function(){this._sessionEventDispatcherContext&&(this._sessionEventDispatcherContext.close(),this._sessionEventDispatcherContext=null),this._websocketEventDispatcherContext&&(this._websocketEventDispatcherContext.close(),this._websocketEventDispatcherContext=null)},Object.defineProperty(e.prototype,"isConnected",{get:function(){return this._context.currentState.type===Vr.CONNECTED},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"isConnecting",{get:function(){var e=this._context.currentState;return e.type===Vr.CONNECTING||e.type===Vr.RECONNECTING},enumerable:!1,configurable:!0}),e.prototype.connect=function(e){return i(this,void 0,void 0,(function(){var t;return o(this,(function(n){switch(n.label){case 0:return t=this._context.currentState,this._externalCalledWebSocketClose=!1,[4,t.onConnect(this._context,e)];case 1:return n.sent(),this._registerEventDispatcher(),[2]}}))}))},e.prototype.reconnect=function(){return i(this,void 0,void 0,(function(){var e;return o(this,(function(t){switch(t.label){case 0:return e=this._context.currentState,this._externalCalledWebSocketClose=!1,[4,e.onReconnect(this._context,{})];case 1:return t.sent(),[2]}}))}))},e.prototype.resetAndReconnect=function(){return i(this,void 0,void 0,(function(){var e;return o(this,(function(t){switch(t.label){case 0:return e=this._context.currentState,this._externalCalledWebSocketClose=!1,[4,e.onReconnect(this._context,{resetReconnectCount:!0})];case 1:return t.sent(),[2]}}))}))},e.prototype.background=function(){return i(this,void 0,void 0,(function(){var e;return o(this,(function(t){switch(t.label){case 0:return e=this._context.currentState,this._externalCalledWebSocketClose=!0,[4,e.onDisconnect(this._context,{autoReconnect:!1})];case 1:return t.sent(),[2]}}))}))},e.prototype.disconnect=function(e){return void 0===e&&(e=null),i(this,void 0,void 0,(function(){return o(this,(function(t){switch(t.label){case 0:return[4,this._context.currentState.onDisconnect(this._context,{error:e,autoReconnect:!0})];case 1:return t.sent(),[2]}}))}))},e.prototype.disconnectWebSocket=function(){return i(this,void 0,void 0,(function(){var e;return o(this,(function(t){switch(t.label){case 0:return e=this._context.currentState,this._externalCalledWebSocketClose=!0,[4,e.onDisconnectWebSocket(this._context)];case 1:return t.sent(),[2]}}))}))},e.prototype.logout=function(){return i(this,void 0,void 0,(function(){var e;return o(this,(function(t){switch(t.label){case 0:return e=this._context.currentState,this._clearEventDispatcher(),[4,e.onLogout(this._context)];case 1:return t.sent(),[2]}}))}))},e}(),Hi=function(e){function n(t){var n,r,i,o,s=t.type,a=t.data,c=t.ts,u=void 0===c?Date.now():c,l=e.call(this,{type:s,data:a,ts:u})||this;return l.date=new Date(u),l.key="".concat((n=l.date,r=n.getFullYear(),i=String(n.getMonth()+1).padStart(2,"0"),o=String(n.getDate()).padStart(2,"0"),"".concat(r).concat(i).concat(o)),"_").concat(s),l}return t(n,e),n}(Te),Wi=function(e){function n(t){var n=t.deviceId,r=t.statLogs,i=e.call(this)||this;return i.method=J.POST,i.path="".concat(_e),i.params={device_id:n,log_entries:r.map((function(e){return Te.payloadify(e)}))},i}return t(n,e),n}(me),Qi=function(e,t){var n,r;if(null!==e&&null!==t){var i=Object.keys(e),o=Object.keys(t),u=c([],a(new Set(c(c([],a(i),!1),a(o),!1))),!1),l={};try{for(var h=s(u),d=h.next();!d.done;d=h.next()){var _=d.value,f=typeof e[_],p=typeof t[_];"undefined"===f?l[_]=t[_]:"undefined"===p?l[_]=e[_]:f!==p?l[_]=t[_]:"object"===f&&e[_]&&t[_]?l[_]=Qi(e[_],t[_]):l[_]=t[_]}}catch(e){n={error:e}}finally{try{d&&!d.done&&(r=h.return)&&r.call(h)}finally{if(n)throw n.error}}return l}return t};!function(e){e[e.PENDING=0]="PENDING",e[e.COLLECT_ONLY=1]="COLLECT_ONLY",e[e.ENABLED=2]="ENABLED",e[e.DISABLED=3]="DISABLED"}(Fi||(Fi={}));var Yi,Xi=function(e){function n(t){var n=t.cacheContext,r=t.requestQueue,i=t.dispatcher,o=t.baseLimit,s=void 0===o?100:o,a=t.maxLimit,c=void 0===a?1e3:a,u=t.minLimit,l=void 0===u?10:u,h=e.call(this)||this;return h.queue=[],h.enabledState=Fi.PENDING,h.isFlushing=!1,h.generation=1,h.lastFlushedAt=0,h.commandEventContext=null,h._collectRequestStat=!0,h._collectFeatureLocalCacheStat=!0,h.deviceId=V(),h.cacheContext=n,h.requestQueue=r,h.dispatcher=i,h.baseLimit=s,h.limit=s,h.maxLimit=c,h.minLimit=l,h}return t(n,e),Object.defineProperty(n.prototype,"isEnabled",{get:function(){return this.enabledState===Fi.ENABLED},enumerable:!1,configurable:!0}),n.prototype._arrangeStat=function(){var e=[];this._collectRequestStat&&e.push.apply(e,c([],a(this.queue.filter((function(e){return e.type===be.API_RESULT||e.type===be.WEBSOCKET_CONNECT}))),!1)),this._collectFeatureLocalCacheStat&&e.push.apply(e,c([],a(this.queue.filter((function(e){return e.type===be.FEATURE_LOCALCACHE}))),!1)),this.queue=e},n.prototype._save=function(){return i(this,void 0,void 0,(function(){return o(this,(function(e){switch(e.label){case 0:return this.enabledState!==Fi.ENABLED?[3,2]:[4,this.cacheContext.preference.set(this.key,{deviceId:this.deviceId,statLogs:this.queue.map((function(e){return Te.payloadify(e)})),generation:this.generation++,lastFlushedAt:this.lastFlushedAt})];case 1:e.sent(),this.dispatch("save",c([],a(this.queue),!1)),e.label=2;case 2:return[2]}}))}))},n.prototype._flush=function(){return i(this,void 0,void 0,(function(){var e,t,n,r,i;return o(this,(function(o){switch(o.label){case 0:if(!this.isEnabled)return[3,10];if(this.isFlushing)return[3,10];this.isFlushing=!0,o.label=1;case 1:return o.trys.push([1,5,9,10]),this._arrangeStat(),e=this.queue.filter((function(e){if(e instanceof Hi){var t=new Date,n=a([e.date.getFullYear(),t.getFullYear()],2),r=n[0],i=n[1];if(r0?(r=new Wi({deviceId:this.deviceId,statLogs:n}),[4,this.requestQueue.send(r)]):[3,4];case 2:return o.sent(),this.dispatch("flush",n),this.queue=c(c([],a(e),!1),a(t),!1).slice(n.length),[4,this._save()];case 3:o.sent(),o.label=4;case 4:return this.limit=this.baseLimit,this.lastFlushedAt=Date.now(),[3,10];case 5:return(i=o.sent())instanceof E?i.code!==u.STAT_LOG_NOT_ALLOWED?[3,7]:[4,this.clear()]:[3,8];case 6:return o.sent(),this.enabledState=Fi.DISABLED,[3,8];case 7:i.code===u.STAT_UPLOAD_NOT_ALLOWED&&(this.enabledState=Fi.COLLECT_ONLY),o.label=8;case 8:return this.limit=this.limit+20,[3,10];case 9:return this.isFlushing=!1,[7];case 10:return[2]}}))}))},n.prototype.init=function(e){return i(this,void 0,void 0,(function(){var t,n,r=this;return o(this,(function(i){switch(i.label){case 0:return this.key=e,[4,this.cacheContext.preference.get(this.key)];case 1:return(t=i.sent())?(this.deviceId=t.deviceId,this.queue=t.statLogs.map((function(e){return new Te({type:e.stat_type,ts:e.ts,data:e.data})})),this.generation=t.generation,this.lastFlushedAt=t.lastFlushedAt,Date.now()-this.lastFlushedAt>=108e5&&this.queue.length>=this.minLimit?(n=Math.min(Math.floor(18e4*Math.random()),100),[4,ai(n)]):[3,4]):[3,4];case 2:return i.sent(),[4,this._flush()];case 3:i.sent(),i.label=4;case 4:return this.commandEventContext||(this.commandEventContext=this.dispatcher.on((function(e){if(e instanceof ke){var t=e.statLog;r.put(t)}else if(e instanceof Bi){var n=e.request,i=e.features,o=e.options;r._collectRequestStat=n,r._collectFeatureLocalCacheStat=null==i?void 0:i.localCache,r._arrangeStat(),r._collectRequestStat||r._collectFeatureLocalCacheStat?r.enabledState=o.ingestion?Fi.ENABLED:Fi.COLLECT_ONLY:r.enabledState=Fi.DISABLED,r.isEnabled?r.queue.length>=r.limit&&r._flush():r.clear()}}))),[2]}}))}))},n.prototype.put=function(e){return i(this,void 0,void 0,(function(){var t,n;return o(this,(function(r){switch(r.label){case 0:return this.enabledState===Fi.DISABLED?[3,3]:(e instanceof Hi?this._collectFeatureLocalCacheStat&&(t=a(this.queue.filter((function(t){return t instanceof Hi&&t.key===e.key})),1),(n=t[0])?n.data=Qi(n.data,e.data):this.queue.push(e)):this._collectRequestStat&&this.queue.push(e),[4,this._save()]);case 1:return r.sent(),this.queue.length>=this.limit?[4,this._flush()]:[3,3];case 2:r.sent(),r.label=3;case 3:return[2]}}))}))},n.prototype.clear=function(){return i(this,void 0,void 0,(function(){return o(this,(function(e){switch(e.label){case 0:return this.queue=[],this.generation=1,[4,this._save()];case 1:return e.sent(),[2]}}))}))},n.prototype.close=function(){this.commandEventContext&&(this.commandEventContext.close(),this.commandEventContext=null)},n}(W);!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"}(Yi||(Yi={}));var Ji,$i=function(){function e(){this.level=Yi.WARN}return e.prototype.verbose=function(){for(var e=[],t=0;t0})).map((function(e){return e.id}))),this.allowUserSuggestion=null!==(a=e.allow_user_suggestion)&&void 0!==a?a:this.allowUserSuggestion,this.allowMultipleVotes=null!==(c=e.allow_multiple_votes)&&void 0!==c?c:this.allowMultipleVotes},r.payloadify=function(t){return t?X(n(n({},e.payloadify.call(this,t)),{id:t.id,title:t.title,created_at:t.createdAt,updated_at:t.updatedAt,close_at:t.closeAt,status:t.status,message_id:t.messageId,data:t.data,voter_count:t.voterCount,options:t.options.map((function(e){return co.payloadify(e)})),created_by:t.createdBy,allow_user_suggestion:t.allowUserSuggestion,allow_multiple_votes:t.allowMultipleVotes,voted_option_ids:t.votedPollOptionIds})):null},r.prototype.applyPollUpdateEvent=function(e){var t=e._payload.poll;return!(!t||this.id!==t.id||t.updated_at-1){var o=t[r];i>=o._lastVotedAt&&(o.voteCount=e.vote_count,o._lastVotedAt=i)}})),r.req_id&&r.voted_option_ids&&(this.votedPollOptionIds=r.voted_option_ids),!0},r.prototype.serialize=function(){return Pi(this)},r}(Ai);!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.EVENT_POLL_UPDATED="EVENT_POLL_UPDATED",e.EVENT_POLL_VOTED="EVENT_POLL_VOTED",e.SYNC_POLL_CHANGELOGS="SYNC_POLL_CHANGELOGS",e.REQUEST_RESEND_MESSAGE="REQUEST_RESEND_MESSAGE",e.REQUEST_THREADED_MESSAGE="REQUEST_THREADED_MESSAGE",e.REQUEST_MESSAGE_CHANGELOGS="REQUEST_MESSAGE_CHANGELOGS",e.SYNC_MESSAGE_FILL="SYNC_MESSAGE_FILL",e.SYNC_MESSAGE_BACKGROUND="SYNC_MESSAGE_BACKGROUND",e.SYNC_MESSAGE_CHANGELOGS="SYNC_MESSAGE_CHANGELOGS",e.LOCAL_MESSAGE_PENDING_CREATED="LOCAL_MESSAGE_PENDING_CREATED",e.LOCAL_MESSAGE_FAILED="LOCAL_MESSAGE_FAILED",e.LOCAL_MESSAGE_CANCELED="LOCAL_MESSAGE_CANCELED",e.LOCAL_MESSAGE_RESEND_STARTED="LOCAL_MESSAGE_RESEND_STARTED"}(ro||(ro={}));var lo=function(e){return e.startsWith("EVENT_")||e===ro.SYNC_MESSAGE_FILL||e===ro.SYNC_MESSAGE_CHANGELOGS||e===ro.SYNC_POLL_CHANGELOGS},ho=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}(Y),_o=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}(Y),fo=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}(Y),po=function(e){function n(t){var n=t.polls,r=t.source,i=e.call(this)||this;return i.polls=n,i.source=r,i}return t(n,e),n}(Y),go=function(e){function n(t){var n=t.event,r=t.source,i=e.call(this)||this;return i.event=n,i.source=r,i}return t(n,e),n}(Y),vo=function(e){function n(t){var n=t.event,r=t.source,i=e.call(this)||this;return i.event=null,i.source=null,i.event=n,i.source=r,i}return t(n,e),n}(Y),Eo=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 w("number",this.limit)&&this.limit>0},e}(),bo=function(e){function n(t,n,r,i){var o=e.call(this,t,i)||this;return o.channelUrl=n,o.channelType=r,o}return t(n,e),n.prototype._validate=function(){return e.prototype._validate.call(this)&&w("string",this.channelUrl)&&S(x,this.channelType)},n}(Eo);export{Ai as $,J as A,Eo as B,Br as C,Gi as D,W as E,ji as F,Se as G,d as H,hi as I,s as J,S as K,B as L,_ as M,p as N,x as O,f as P,K as Q,Yi as R,E as S,M as T,qi as U,to as V,Ae as W,ki as X,Mi as Y,te as Z,t as _,w as a,y as a0,P as a1,Pi as a2,F as a3,j as a4,C as a5,U as a6,uo as a7,G as a8,Wr as a9,ve as aA,z as aB,v as aC,vo as aD,N as aE,go as aF,fo as aG,re as aH,he as aI,io as aJ,lo as aK,Hi as aL,be as aM,ui as aN,oo as aO,oe as aP,ie as aQ,fe as aa,ge as ab,u as ac,ai as ad,Yr as ae,q as af,ne as ag,ro as ah,ho as ai,_o as aj,se as ak,bo as al,no as am,co as an,Ji as ao,Y as ap,O as aq,R as ar,r as as,le as at,ao as au,so as av,po as aw,Ci as ax,pe as ay,ae as az,i as b,o as c,ee as d,X as e,me as f,n as g,ye as h,A as i,ue as j,ce as k,de as l,T as m,Ne as n,I as o,Ce as p,c as q,a as r,zi as s,Ui as t,V as u,l as v,Jr as w,Vr as x,li as y,Qr as z}; diff --git a/lib/__bundle-ad161b2c.js b/lib/__bundle-ad161b2c.js new file mode 100644 index 0000000..7d1c139 --- /dev/null +++ b/lib/__bundle-ad161b2c.js @@ -0,0 +1 @@ +import{_ as t,A as n,au as e,f as o,a8 as s,h as a,ao as i,ab as r,e as l,a as u,av as c,aw as h,Q as p,M as d,w as f,b as _,c as v,ai as m,t as g,S as I,g as w,ax as y,u as U,am as T,V as k,U as b}from"./__bundle-75942676.js";var P=function(o){function s(t){var s=t.title,a=t.optionTexts,i=t.data,r=t.allowUserSuggestion,l=t.allowMultipleVotes,u=t.closeAt,c=o.call(this)||this;return c.method=n.POST,c.path=e,c.params={title:s,options:a,data:i,allow_user_suggestion:r,allow_multiple_votes:l,close_at:u},c}return t(s,o),s}(o),x=function(n){function e(t,e){var o=n.call(this,t,e)||this;return o.poll=new s(t,e),o}return t(e,n),e}(a),O=function(o){function s(t){var s=t.channelUrl,a=t.channelType,i=t.pollId,r=o.call(this)||this;return r.method=n.GET,r.path="".concat(e,"/").concat(encodeURIComponent(i)),r.params={channel_url:s,channel_type:a},r}return t(s,o),s}(o),S=function(n){function e(t,e){var o=n.call(this,t,e)||this;return o.poll=new s(t,e),o}return t(e,n),e}(a),q=function(o){function s(t){var s=t.channelUrl,a=t.channelType,i=t.pollId,r=t.pollOptionId,l=o.call(this)||this;return l.method=n.GET,l.path="".concat(e,"/").concat(encodeURIComponent(i),"/options/").concat(encodeURIComponent(r)),l.params={channel_url:s,channel_type:a},l}return t(s,o),s}(o),L=function(n){function e(t,e){var o=n.call(this,t,e)||this;return o.pollOption=new i(t,e),o}return t(e,n),e}(a),C=function(e){function o(t){var o=t.channelType,s=t.channelUrl,a=t.timestamp,i=t.token,u=e.call(this)||this;return u.method=n.GET,u.path="".concat(r(o),"/").concat(encodeURIComponent(s),"/polls/changelogs"),u.params=l({change_ts:a,token:i}),u}return t(o,e),o}(o),M=function(n){function e(t,e){var o=n.call(this,t,e)||this;return o.updatedPolls=e.updated.map((function(n){return function(t,n){return new s(t,n)}(t,n)})),o.deletedPollIds=e.deleted.map((function(t){return t})),o.hasMore=e.has_more,o.nextToken=e.next,o}return t(e,n),e}(a),Q={title:"",optionTexts:[],data:void 0,allowUserSuggestion:void 0,allowMultipleVotes:void 0,closeAt:-1},E=function(t){return u("string",t.title)&&c(t.optionTexts)&&h(t.data)&&u("boolean",t.allowUserSuggestion,!0)&&u("boolean",t.allowMultipleVotes,!0)&&u("number",t.closeAt,!0)},A={channelUrl:"",channelType:p.BASE,pollId:0,pollOptionId:0},G=function(t){return u("string",t.channelUrl)&&""!==t.channelUrl&&d(p,t.channelType)&&u("number",t.pollId)&&t.pollId>0&&u("number",t.pollOptionId)&&t.pollOptionId>0},N={channelUrl:"",channelType:p.BASE,pollId:0},R=function(t){return u("string",t.channelUrl)&&""!==t.channelUrl&&d(p,t.channelType)&&u("number",t.pollId)},V={},B=function(){function t(t,n){var e=n.sdkState,o=n.dispatcher,s=n.sessionManager,a=n.requestQueue,i=n.logger;this._iid=t,this._sdkState=e,this._sessionManager=s,this._requestQueue=a,this._dispatcher=o,this._logger=i,V[t]=this}return t.of=function(t){return V[t]},t.prototype.buildPollFromSerializedData=function(t){var n=f(t);return new s(this._iid,s.payloadify(n))},t.prototype.get=function(t){return _(this,void 0,void 0,(function(){var n,e;return v(this,(function(o){switch(o.label){case 0:return g(R(t)).throw(I.invalidParameters),n=new O(w({},t)),[4,this._requestQueue.send(n)];case 1:return e=o.sent(),[2,e.as(S).poll]}}))}))},t.prototype.create=function(t){return _(this,void 0,void 0,(function(){var n,e;return v(this,(function(o){switch(o.label){case 0:return g(E(t)).throw(I.invalidParameters),n=new P(w({},t)),[4,this._requestQueue.send(n)];case 1:return e=o.sent(),[2,e.as(x).poll]}}))}))},t.prototype.getOption=function(t){return _(this,void 0,void 0,(function(){var n,e;return v(this,(function(o){switch(o.label){case 0:return g(G(t)).throw(I.invalidParameters),n=new q(w({},t)),[4,this._requestQueue.send(n)];case 1:return e=o.sent(),[2,e.as(L).pollOption]}}))}))},t.prototype.getPollChangeLogs=function(t,n,e,o){return void 0===o&&(o=m.SYNC_POLL_CHANGELOGS),_(this,void 0,void 0,(function(){var s,a,i,r,l,u,c;return v(this,(function(h){switch(h.label){case 0:return s=new C(U({channelType:n,channelUrl:t,timestamp:"number"==typeof e?e:null,token:"string"==typeof e?e:null})),[4,this._requestQueue.send(s)];case 1:return a=h.sent(),i=a.as(M),r=i.updatedPolls,l=i.deletedPollIds,u=i.hasMore,c=i.nextToken,r.length>0&&this._dispatcher.dispatch(new y({polls:r,source:o})),[2,{updatedPolls:r,deletedPollIds:l,hasMore:u,token:c}]}}))}))},t}(),j=function(t,n){this.pollId=0,this.messageId=0,this.pollId=n.poll.id,this.messageId=n.poll.message_id,this._iid=t,this._payload=n},z=function(t){this.pollId=0,this.messageId=0,this.pollId=t.poll_id,this.messageId=t.message_id,this._payload=t},D=function(o){function s(t){var s=t.channelUrl,a=t.channelType,i=t.token,r=t.limit,l=o.call(this)||this;return l.method=n.GET,l.path=e,l.params={channel_url:s,channel_type:a,token:i,limit:r},l}return t(s,o),s}(o),F=function(n){function e(t,e){var o,a=this;return(a=n.call(this,t,e)||this).polls=(null!==(o=e.polls)&&void 0!==o?o:[]).map((function(n){return new s(t,n)})),a.token=e.next,a}return t(e,n),e}(a),H=function(n){function e(t,e){return n.call(this,t,e.channelUrl,e.channelType,e)||this}return t(e,n),e.prototype.next=function(){return _(this,void 0,void 0,(function(){var t,n,e,o,s,a;return v(this,(function(i){switch(i.label){case 0:return this._validate()?this._isLoading?[3,3]:this._hasNext?(this._isLoading=!0,t=k.of(this._iid).requestQueue,n=new D(w(w({},this),{token:this._token})),[4,t.send(n)]):[3,2]:[3,5];case 1:return e=i.sent(),o=e.as(F),s=o.polls,a=o.token,this._token=a,this._hasNext=!!a,this._isLoading=!1,[2,s];case 2:return[2,[]];case 3:throw I.queryInProgress;case 4:return[3,6];case 5:throw I.invalidParameters;case 6:return[2]}}))}))},e}(T),Y=function(o){function s(t){var s=t.channelUrl,a=t.channelType,i=t.pollId,r=t.pollOptionId,l=t.token,u=t.limit,c=o.call(this)||this;return c.method=n.GET,c.path="".concat(e,"/").concat(encodeURIComponent(i),"/options/").concat(encodeURIComponent(r),"/voters"),c.params={channel_url:s,channel_type:a,token:l,limit:u},c}return t(s,o),s}(o),J=function(n){function e(t,e){var o,s=this;return(s=n.call(this,t,e)||this).voters=(null!==(o=e.voters)&&void 0!==o?o:[]).map((function(n){return new b(t,n)})),s.token=e.next,s}return t(e,n),e}(a),K=function(n){function e(t,e){var o=n.call(this,t,e.channelUrl,e.channelType,e)||this;return o.pollId=e.pollId,o.pollOptionId=e.pollOptionId,o}return t(e,n),e.prototype._validate=function(){return n.prototype._validate.call(this)&&u("number",this.pollId)&&u("number",this.pollOptionId)},e.prototype.next=function(){return _(this,void 0,void 0,(function(){var t,n,e,o,s,a;return v(this,(function(i){switch(i.label){case 0:return this._validate()?this._isLoading?[3,3]:this._hasNext?(this._isLoading=!0,t=k.of(this._iid).requestQueue,n=new Y(w(w({},this),{pollId:this.pollId,pollOptionId:this.pollOptionId,token:this._token})),[4,t.send(n)]):[3,2]:[3,5];case 1:return e=i.sent(),o=e.as(J),s=o.voters,a=o.token,this._token=a,this._hasNext=!!a,this._isLoading=!1,[2,s];case 2:return[2,[]];case 3:throw I.queryInProgress;case 4:return[3,6];case 5:throw I.invalidParameters;case 6:return[2]}}))}))},e}(T);export{H as P,K as a,B as b,Q as c,N as d,R as e,A as f,G as g,j as h,z as i,E as v}; diff --git a/lib/__bundle-e875840b.js b/lib/__bundle-e875840b.js new file mode 100644 index 0000000..f90b905 --- /dev/null +++ b/lib/__bundle-e875840b.js @@ -0,0 +1 @@ +import{a4 as e,a as t,M as n,m as r,U as i,a9 as a,g as s,e as o,u,i as c,ay as l,_ as d,A as h,ab as p,f,h as m,b as v,am as y,c as g,S as _,V as T,W as U,az as I,aA as w,Q as M,aa as E,ac as b,aB as S,aC as P,aw as C,au as A,a8 as D,p as R,a1 as q,a5 as O,K as L,a2 as N,ad as F,t as k,ae as Q,aj as z,ai as x,z as G,aD as V,ar as j,a0 as B,r as W,s as K,af as H,aE as Y}from"./__bundle-75942676.js";import{d as J,A as X,U as Z,F as $,R as ee,T as te,e as ne,f as re,b as ie,c as ae,g as se,h as oe,i as ue,v as ce,j as le,k as de,B as he,S as pe}from"./__bundle-84f74e8d.js";import{i as fe,P as me,a as ve,b as ye}from"./__bundle-ad161b2c.js";var ge,_e=100,Te="GroupChannel",Ue="url",Ie=100,we="Message",Me="messageId",Ee="Poll",be="pollId",Se={data:void 0,customType:void 0,mentionType:e.USERS,mentionedUserIds:void 0,mentionedUsers:void 0,mentionedMessageTemplate:void 0,metaArrays:void 0,parentMessageId:void 0,isReplyToChannel:!1,pushNotificationDeliveryOption:void 0,appleCriticalAlertOptions:void 0,isPinnedMessage:!1},Pe=function(s){return t("string",s.data,!0)&&t("string",s.customType,!0)&&n(e,s.mentionType)&&r("string",s.mentionedUserIds,!0)&&r(i,s.mentionedUsers,!0)&&t("string",s.mentionedMessageTemplate,!0)&&r(J,s.metaArrays,!0)&&t("number",s.parentMessageId,!0)&&t("boolean",s.isReplyToChannel)&&n(a,s.pushNotificationDeliveryOption,!0)&&t(X,s.appleCriticalAlertOptions,!0)&&t("boolean",s.isPinnedMessage,!0)},Ce=function(e){return{isReplyToChannel:e.isReplyToChannel,pushNotificationDeliveryOption:e.pushNotificationDeliveryOption,pollId:e.pollId}},Ae=s(s({},Se),{message:"",translationTargetLanguages:void 0,pollId:void 0}),De=function(e){return Pe(e)&&t("string",e.message)&&r("string",e.translationTargetLanguages,!0)&&t("number",e.pollId,!0)};!function(e){e.FILE="file",e.BLOB="blob",e.BLOB_LIKE_OBJECT="blobLikeObject",e.URL="url"}(ge||(ge={}));var Re,qe=function(e){return"undefined"!=typeof window&&"Blob"in window&&"undefined"!=typeof Blob&&e instanceof Blob},Oe=function(e){return e===ge.BLOB||e===ge.FILE},Le=function(e){return{file:e.file,fileKey:e.fileKey,fileType:e.fileType,isReplyToChannel:e.isReplyToChannel,pushNotificationDeliveryOption:e.pushNotificationDeliveryOption}},Ne=s(s({},Se),{file:void 0,fileKey:void 0,fileUrl:void 0,fileName:void 0,fileType:void 0,fileSize:void 0,mimeType:void 0,thumbnailSizes:void 0,requireAuth:!1}),Fe=function(e){return Pe(e)&&(c(e.file)||t("string",e.fileUrl))&&t("string",e.fileName,!0)&&t("string",e.mimeType,!0)&&t("number",e.fileSize,!0)&&(null===e.thumbnailSizes||void 0===e.thumbnailSizes||Array.isArray(e.thumbnailSizes)&&e.thumbnailSizes.every((function(e){return t("object",e)&&e.maxWidth>0&&e.maxHeight>0})))},ke=function(e){return o({fileInfoList:e.fileInfoList,isReplyToChannel:e.isReplyToChannel,pushNotificationDeliveryOption:e.pushNotificationDeliveryOption})},Qe=s(s({},Se),{fileInfoList:[]}),ze=function(e){return(c(e.file)||t("string",e.fileUrl))&&t("string",e.fileName,!0)&&t("string",e.mimeType,!0)&&t("number",e.fileSize,!0)&&(void 0===e.thumbnailSizes||Array.isArray(e.thumbnailSizes)&&e.thumbnailSizes.every((function(e){return e.maxWidth>0&&e.maxHeight>0})))};!function(e){e.MUTED="muted",e.BANNED="banned"}(Re||(Re={}));var xe,Ge=function(){function e(e){var t,r,i,a;this.restrictionType=null,n(Re,e.restriction_type)&&(this.restrictionType=e.restriction_type),this.description=null!==(t=e.description)&&void 0!==t?t:null,this.endAt=null!==(i=null!==(r=e.end_at)&&void 0!==r?r:e.muted_end_at)&&void 0!==i?i:-1,this.remainingDuration=null!==(a=e.remaining_duration)&&void 0!==a?a:-1}return e.payloadify=function(e){return o(u({restriction_type:e.restrictionType,description:e.description,end_at:e.endAt,remaining_duration:e.remainingDuration}))},e}(),Ve=function(e){function t(t,n){var r=e.call(this,t,n)||this;return r.restrictionInfo=new Ge(n),r}return d(t,e),t.payloadify=function(t){return o(u(s(s({},e.payloadify.call(this,t)),Ge.payloadify(t.restrictionInfo))))},t}(i),je={data:void 0,customType:void 0,mentionType:e.USERS,mentionedUserIds:void 0,mentionedUsers:void 0,mentionedMessageTemplate:void 0,metaArrays:void 0,pushNotificationDeliveryOption:void 0,appleCriticalAlertOptions:void 0},Be=function(s){return t("string",s.data,!0)&&t("string",s.customType,!0)&&n(e,s.mentionType)&&r("string",s.mentionedUserIds,!0)&&r(i,s.mentionedUsers,!0)&&t("string",s.mentionedMessageTemplate,!0)&&r(J,s.metaArrays,!0)&&n(a,s.pushNotificationDeliveryOption,!0)&&t(X,s.appleCriticalAlertOptions,!0)},We=s(s({},je),{message:void 0,translationTargetLanguages:void 0,pollId:void 0}),Ke=function(e){return Be(e)&&t("string",e.message,!0)&&r("string",e.translationTargetLanguages,!0)&&t("number",e.pollId,!0)},He=s({},je),Ye=function(e){function t(t){var n=t.channelUrl,r=t.channelType,i=t.token,a=t.limit,s=e.call(this)||this;return s.method=h.GET,s.path="".concat(p(r),"/").concat(encodeURIComponent(n),"/operators"),s.params={token:i,limit:a},s}return d(t,e),t}(f),Je=function(e){function t(t,n){var r=e.call(this,t,n)||this;return r.operators=n.operators.map((function(e){return new i(t,e)})),r.token=n.next,r}return d(t,e),t}(m),Xe=function(e){function t(t,n,r,i){return e.call(this,t,n,r,i)||this}return d(t,e),t.prototype._validate=function(){return e.prototype._validate.call(this)},t.prototype.next=function(){return v(this,void 0,void 0,(function(){var e,t,n,r,i,a,o;return g(this,(function(u){switch(u.label){case 0:return this._validate()?this._isLoading?[3,3]:(e=[],this._hasNext?(this._isLoading=!0,t=T.of(this._iid).requestQueue,n=new Ye(s(s({},this),{channelUrl:this.channelUrl,token:this._token})),[4,t.send(n)]):[3,2]):[3,5];case 1:return r=u.sent(),i=r.as(Je),a=i.operators,o=i.token,this._token=o,this._hasNext=!!o,this._isLoading=!1,[2,a];case 2:return[2,e];case 3:throw _.queryInProgress;case 4:return[3,6];case 5:throw _.invalidParameters;case 6:return[2]}}))}))},t}(y),Ze=function(e){function t(t){var n=this,r=t.channelUrl,i=t.channelType,a=t.limit,s=t.token;return(n=e.call(this)||this).method=h.GET,n.path="".concat(p(i),"/").concat(encodeURIComponent(r),"/mute"),n.params={limit:a,token:s},n}return d(t,e),t}(f),$e=function(e){function t(t,n){var r=e.call(this,t,n)||this;r.mutedUsers=[];var i=n.next,a=n.muted_list;return r.token=i,a&&a.length>0&&(r.mutedUsers=a.map((function(e){return new Ve(t,e)}))),r}return d(t,e),t}(m),et=function(e){function t(t,n,r,i){return e.call(this,t,n,r,i)||this}return d(t,e),t.prototype.next=function(){return v(this,void 0,void 0,(function(){var e,t,n,r,i,a;return g(this,(function(o){switch(o.label){case 0:return this._validate()?this._isLoading?[3,3]:this._hasNext?(this._isLoading=!0,e=T.of(this._iid).requestQueue,t=new Ze(s(s({},this),{token:this._token})),[4,e.send(t)]):[3,2]:[3,5];case 1:return n=o.sent(),r=n.as($e),i=r.mutedUsers,a=r.token,this._token=a,this._hasNext=!!a,this._isLoading=!1,[2,i];case 2:return[2,[]];case 3:throw _.queryInProgress;case 4:return[3,6];case 5:throw _.invalidParameters;case 6:return[2]}}))}))},t}(y),tt=function(e){function t(t){var n=this,r=t.channelUrl,i=t.channelType,a=t.limit,s=t.token;return(n=e.call(this)||this).method=h.GET,n.path="".concat(p(i),"/").concat(encodeURIComponent(r),"/ban"),n.params=o({limit:a,token:s}),n}return d(t,e),t}(f),nt=function(e){function t(t,n){var r=e.call(this,t,n)||this;r.bannedUsers=[];var i=n.next,a=n.banned_list;return r.token=i,a&&a.length>0&&(r.bannedUsers=a.map((function(e){return new Ve(t,e.user)}))),r}return d(t,e),t}(m),rt=function(e){function t(t,n,r,i){return e.call(this,t,n,r,i)||this}return d(t,e),t.prototype._validate=function(){return e.prototype._validate.call(this)},t.prototype.next=function(){return v(this,void 0,void 0,(function(){var e,t,n,r,i,a;return g(this,(function(o){switch(o.label){case 0:return this._validate()?this._isLoading?[3,3]:this._hasNext?(this._isLoading=!0,e=T.of(this._iid).requestQueue,t=new tt(s(s({},this),{token:this._token})),[4,e.send(t)]):[3,2]:[3,5];case 1:return n=o.sent(),r=n.as(nt),i=r.bannedUsers,a=r.token,this._token=a,this._hasNext=!!a,this._isLoading=!1,[2,i];case 2:return[2,[]];case 3:throw _.queryInProgress;case 4:return[3,6];case 5:throw _.invalidParameters;case 6:return[2]}}))}))},t}(y);!function(e){e.SPAM="spam",e.HARASSING="harassing",e.SUSPICIOUS="suspicious",e.INAPPROPRIATE="inappropriate"}(xe||(xe={}));var it=function(e){function t(t){var n=this,r=t.channelUrl,i=t.channelType,a=t.operatorUserIds;return(n=e.call(this)||this).method=h.POST,n.path="".concat(p(i),"/").concat(encodeURIComponent(r),"/operators"),n.params={operator_ids:a},n}return d(t,e),t}(f);!function(e){function t(){return null!==e&&e.apply(this,arguments)||this}d(t,e)}(m);var at=function(e){function t(t){var n=this,r=t.channelUrl,i=t.channelType,a=t.operatorUserIds;return(n=e.call(this)||this).method=h.DELETE,n.path="".concat(p(i),"/").concat(encodeURIComponent(r),"/operators"),n.params={operator_ids:a},n}return d(t,e),t}(f);!function(e){function t(t,n){return e.call(this,t,n)||this}d(t,e)}(m);var st=function(e){function t(t){var n=this,r=t.channelUrl,i=t.channelType,a=t.userId;return(n=e.call(this)||this).method=h.GET,n.path="".concat(p(i),"/").concat(encodeURIComponent(r),"/mute/").concat(a),n}return d(t,e),t}(f),ot=function(e){function t(t,n){var r=e.call(this,t,n)||this;r.isMuted=!1,r.startAt=0,r.endAt=0;var i=n.is_muted,a=n.start_at,s=n.end_at,o=n.remaining_duration,u=n.description;return r.isMuted=i,r.startAt=a,r.endAt=s,r.remainingDuration=o,r.description=u,r}return d(t,e),t}(m),ut=function(e){function t(t){var n=this,r=t.channelUrl,i=t.channelType,a=t.keys;return(n=e.call(this)||this).method=h.GET,n.path="".concat(p(i),"/").concat(encodeURIComponent(r),"/metadata"),n.params={keys:a,include_ts:!0},n}return d(t,e),t}(f),ct=function(e){function t(t,n){var r=e.call(this,t,n)||this,i=n.metadata,a=n.ts;return r.metadata=i,r.ts=a,r}return d(t,e),t}(m),lt=function(e){function t(t){var n=this,r=t.channelUrl,i=t.channelType,a=t.metadata;return(n=e.call(this)||this).method=h.POST,n.path="".concat(p(i),"/").concat(encodeURIComponent(r),"/metadata"),n.params={metadata:a,include_ts:!0},n}return d(t,e),t}(f),dt=function(e){function t(t,n){var r,i,a=this;return(a=e.call(this,t,n)||this).metaData=null!==(r=n.metadata)&&void 0!==r?r:{},a.ts=null!==(i=n.ts)&&void 0!==i?i:null,a}return d(t,e),t}(m),ht=function(e){function t(t){var n=this,r=t.channelUrl,i=t.channelType,a=t.metadata,s=t.upsert;return(n=e.call(this)||this).method=h.PUT,n.path="".concat(p(i),"/").concat(encodeURIComponent(r),"/metadata"),n.params={metadata:a,include_ts:!0,upsert:null!=s&&s},n}return d(t,e),t}(f),pt=function(e){function t(t,n){var r=e.call(this,t,n)||this,i=n.metadata,a=n.ts;return r.metadata=i,r.ts=a,r}return d(t,e),t}(m),ft=function(e){function t(t,n,r){var i=e.call(this,t,"SYEV",r)||this;return r.data&&(i.created=r.data.created,i.updated=r.data.updated,i.deleted=r.data.deleted),i}return d(t,e),t}(U),mt=function(e){function t(t){var n=this,r=t.channelUrl,i=t.channelType,a=t.key;return(n=e.call(this)||this).method=h.DELETE,n.path="".concat(p(i),"/").concat(encodeURIComponent(r),"/metadata/").concat(a),n.params={include_ts:!0},n}return d(t,e),t}(f),vt=function(e){function t(t,n){var r=e.call(this,t,n)||this,i=n.ts;return r.ts=i,r}return d(t,e),t}(m),yt=function(e){function t(t){var n=this,r=t.channelUrl,i=t.channelType;return(n=e.call(this)||this).method=h.DELETE,n.path="".concat(p(i),"/").concat(encodeURIComponent(r),"/metadata"),n.params={include_ts:!0},n}return d(t,e),t}(f),gt=function(e){function t(t,n){var r=e.call(this,t,n)||this,i=n.ts;return r.ts=i,r}return d(t,e),t}(m),_t=function(e){function t(t){var n=this,r=t.channelUrl,i=t.channelType,a=t.keys;return(n=e.call(this)||this).method=h.GET,n.path="".concat(p(i),"/").concat(encodeURIComponent(r),"/metacounter"),n.params={keys:a},n}return d(t,e),t}(f),Tt=function(e){function t(t,n){var r=e.call(this,t,n)||this;return r.metaCounter=n,r}return d(t,e),t}(m),Ut=function(e){function t(t){var n=this,r=t.channelUrl,i=t.channelType,a=t.metaCounter;return(n=e.call(this)||this).method=h.POST,n.path="".concat(p(i),"/").concat(encodeURIComponent(r),"/metacounter"),n.params={metacounter:a},n}return d(t,e),t}(f),It=function(e){function t(t,n){var r=e.call(this,t,n)||this;return r.metaCounter=n,r}return d(t,e),t}(m),wt=function(e){function t(t){var n=this,r=t.channelUrl,i=t.channelType,a=t.metaCounter,s=t.upsert,o=void 0!==s&&s,u=t.mode,c=void 0===u?"set":u;return(n=e.call(this)||this).method=h.PUT,n.path="".concat(p(i),"/").concat(encodeURIComponent(r),"/metacounter"),n.params={metacounter:a,upsert:o,mode:c},n}return d(t,e),t}(f),Mt=function(e){function t(t,n){var r=e.call(this,t,n)||this;return r.metaCounter=n,r}return d(t,e),t}(m),Et=function(e){function t(t,n,r){var i=e.call(this,t,"SYEV",r)||this;return r.data&&(i.created=r.data.created,i.updated=r.data.updated,i.deleted=r.data.deleted),i}return d(t,e),t}(U),bt=function(e){function t(t){var n=this,r=t.channelUrl,i=t.channelType,a=t.key;return(n=e.call(this)||this).method=h.DELETE,n.path="".concat(p(i),"/").concat(encodeURIComponent(r),"/metacounter/").concat(a),n.params={},n}return d(t,e),t}(f);!function(e){function t(t,n){return e.call(this,t,n)||this}d(t,e)}(m);var St=function(e){function t(t){var n=this,r=t.channelUrl,i=t.channelType;return(n=e.call(this)||this).method=h.DELETE,n.path="".concat(p(i),"/").concat(encodeURIComponent(r),"/metacounter"),n.params={},n}return d(t,e),t}(f);!function(e){function t(){return null!==e&&e.apply(this,arguments)||this}d(t,e)}(m);var Pt=function(e){function t(t){var n=this,r=t.channelUrl,i=t.channelType,a=t.userId,s=t.seconds,o=t.description;return(n=e.call(this)||this).method=h.POST,n.path="".concat(p(i),"/").concat(encodeURIComponent(r),"/mute"),n.params={user_id:a,seconds:s,description:o},n}return d(t,e),t}(f);!function(e){function t(t,n){return e.call(this,t,n)||this}d(t,e)}(m);var Ct=function(e){function t(t,n,r){var i=e.call(this,t,"SYEV",r)||this;return i.user=new Ve(t,r.data),i}return d(t,e),t}(U),At=function(e){function t(t){var n=this,r=t.channelUrl,i=t.channelType,a=t.userId;return(n=e.call(this)||this).method=h.DELETE,n.path="".concat(p(i),"/").concat(encodeURIComponent(r),"/mute/").concat(encodeURIComponent(a)),n}return d(t,e),t}(f);!function(e){function t(){return null!==e&&e.apply(this,arguments)||this}d(t,e)}(m);var Dt=function(e){function t(t,n,r){var i=e.call(this,t,"SYEV",r)||this;return i.user=new Ve(t,r.data),i}return d(t,e),t}(U),Rt=function(e){function t(t){var n=this,r=t.channelUrl,i=t.channelType,a=t.userId,s=t.seconds,u=t.description;return(n=e.call(this)||this).method=h.POST,n.path="".concat(p(i),"/").concat(encodeURIComponent(r),"/ban"),n.params=o({user_id:a,seconds:s,description:u}),n}return d(t,e),t}(f);!function(e){function t(){return null!==e&&e.apply(this,arguments)||this}d(t,e)}(m);var qt=function(e){function t(t,n,r){var i=e.call(this,t,"SYEV",r)||this;return i.user=new Ve(t,r.data),r.data.member_count&&(i.memberCount=r.data.member_count),r.data.joined_member_count&&(i.joinedMemberCount=r.data.joined_member_count),i}return d(t,e),t}(U),Ot=function(e){function t(t){var n=this,r=t.channelUrl,i=t.channelType,a=t.userId;return(n=e.call(this)||this).method=h.DELETE,n.path="".concat(p(i),"/").concat(encodeURIComponent(r),"/ban/").concat(encodeURIComponent(a)),n}return d(t,e),t}(f);!function(e){function t(){return null!==e&&e.apply(this,arguments)||this}d(t,e)}(m);var Lt=function(e){function t(t,n,r){var i=e.call(this,t,"SYEV",r)||this;return i.user=new Ve(t,r.data),i}return d(t,e),t}(U),Nt=function(e){function t(t){var n=this,r=t.channelUrl,i=t.channelType,a=t.freezing;return(n=e.call(this)||this).method=h.PUT,n.path="".concat(p(i),"/").concat(encodeURIComponent(r),"/freeze"),n.params={freeze:a},n}return d(t,e),t}(f);!function(e){function t(){return null!==e&&e.apply(this,arguments)||this}d(t,e)}(m);var Ft=function(e){function t(t,n,r){var i=e.call(this,t,"SYEV",r)||this;return i.freeze=r.data.freeze,i}return d(t,e),t}(U),kt=function(e){function t(t){var n=this,r=t.channelUrl,i=t.channelType,a=t.category,s=t.userId,o=t.description;return(n=e.call(this)||this).method=h.POST,n.path="".concat(I(i),"/").concat(encodeURIComponent(r)),n.params={report_category:a,reporting_user_id:s,report_description:o},n}return d(t,e),t}(f),Qt=function(e){function t(t){var n=this,r=t.channelUrl,i=t.channelType,a=t.category,s=t.userId,o=t.offendingUserId,u=t.description;return(n=e.call(this)||this).method=h.POST,n.path="".concat(w,"/users/").concat(o),n.params={channel_url:r,channel_type:i===M.OPEN?"open_channels":"group_channels",report_category:a,reporting_user_id:s,report_description:u},n}return d(t,e),t}(f),zt=function(e){function t(t){var n=this,r=t.channelUrl,i=t.channelType,a=t.category,s=t.userId,o=t.offendingUserId,u=t.messageId,c=t.description;return(n=e.call(this)||this).method=h.POST,n.path="".concat(I(i),"/").concat(encodeURIComponent(r),"/messages/").concat(u),n.params={report_category:a,reporting_user_id:s,report_description:c,offending_user_id:o},n}return d(t,e),t}(f),xt=function(t){function n(n){var r=[];return n.mentionType===e.USERS&&(n.mentionedUserIds?r=n.mentionedUserIds:n.mentionedUsers&&(r=n.mentionedUsers.map((function(e){return e.userId})))),t.call(this,{code:"MESG",ackRequired:!0,payload:o(u({channel_url:n.channelUrl,message:n.message,data:n.data,custom_type:n.customType,metaarray:n.metaArrays,mention_type:n.mentionType,mentioned_user_ids:r,mentioned_message_template:n.mentionedMessageTemplate,target_langs:n.translationTargetLanguages,push_option:n.pushNotificationDeliveryOption&&n.pushNotificationDeliveryOption!==a.DEFAULT?n.pushNotificationDeliveryOption:void 0,apple_critical_alert_options:n.appleCriticalAlertOptions,silent:n.silent,reply_to_channel:n.isReplyToChannel,parent_message_id:n.parentMessageId?n.parentMessageId:null,req_id:n.reqId,poll_id:n.pollId,pin_message:n.isPinnedMessage}))})||this}return d(n,t),n}(E),Gt=function(e){function t(t,n,r){var i,a,s,o,u=this;(u=e.call(this,t,"MESG",r)||this).message=new Z(t,r);var c=T.of(t).sdkState;return u.isMentioned=b(u.message.mentionType,null!==(s=null!==(i=u.message.mentionedUserIds)&&void 0!==i?i:null===(a=u.message.mentionedUsers)||void 0===a?void 0:a.map((function(e){return e.userId})))&&void 0!==s?s:[],c.userId),u.forceUpdateLastMessage=null!==(o=r.force_update_last_message)&&void 0!==o&&o,u}return d(t,e),t}(U),Vt=function(t){function n(n){var r=null;return n.mentionType===e.USERS&&(n.mentionedUserIds?r=n.mentionedUserIds:n.mentionedUsers&&(r=n.mentionedUsers.map((function(e){return e.userId})))),t.call(this,{code:"MEDI",ackRequired:!0,payload:o(u({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:r,mentioned_message_template:n.mentionedMessageTemplate,apple_critical_alert_options:n.appleCriticalAlertOptions?X.payloadify(n.appleCriticalAlertOptions):null,poll_id:n.pollId}))})||this}return d(n,t),n}(E),jt=function(e){function t(t,n,r){var i,a,s,o,c,l=this;(l=e.call(this,t,"MEDI",r)||this).message=new Z(t,r);var d=T.of(t).sdkState;return l.mentionCountChange=S({mentionType:null===(i=r.old_values)||void 0===i?void 0:i.mention_type,mentionedUserIds:null!==(s=null===(a=r.old_values)||void 0===a?void 0:a.mentioned_user_ids)&&void 0!==s?s:[]},u({mentionType:l.message.mentionType,mentionedUserIds:null!==(o=l.message.mentionedUserIds)&&void 0!==o?o:null===(c=l.message.mentionedUsers)||void 0===c?void 0:c.map((function(e){return e.userId}))}),d.userId),l}return d(t,e),t}(U),Bt=function(t){function n(n){var r=null;return n.mentionType===e.USERS&&(n.mentionedUserIds?r=n.mentionedUserIds:n.mentionedUsers&&(r=n.mentionedUsers.map((function(e){return e.userId})))),t.call(this,{code:"FEDI",ackRequired:!0,payload:o(u({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:r,apple_critical_alert_options:n.appleCriticalAlertOptions}))})||this}return d(n,t),n}(E),Wt=function(e){function t(t,n,r){var i,a,s,o,c,l=this;(l=e.call(this,t,"FEDI",r)||this).message=new $(t,r);var d=T.of(t).sdkState;return l.mentionCountChange=S({mentionType:null===(i=r.old_values)||void 0===i?void 0:i.mention_type,mentionedUserIds:null!==(s=null===(a=r.old_values)||void 0===a?void 0:a.mentioned_user_ids)&&void 0!==s?s:[]},u({mentionType:l.message.mentionType,mentionedUserIds:null!==(o=l.message.mentionedUserIds)&&void 0!==o?o:null===(c=l.message.mentionedUsers)||void 0===c?void 0:c.map((function(e){return e.userId}))}),d.userId),l}return d(t,e),t}(U),Kt=function(e){function t(t){var n=e.call(this)||this;return n.method=h.DELETE,n.path="".concat(p(t.channelType),"/").concat(t.channelUrl,"/messages/").concat(t.messageId),n}return d(t,e),t}(f);!function(e){function t(){return null!==e&&e.apply(this,arguments)||this}d(t,e)}(m);var Ht=function(e){function t(t,n,r){var i=e.call(this,t,"DELM",r)||this;return i.channelUrl=r.channel_url,i.channelType=r.channel_type,i.messageId=Number(r.msg_id),i}return d(t,e),t}(U),Yt=function(e){function t(t){var n=t.channelType,r=t.channelUrl,i=t.messageId,a=t.reactionKey,s=e.call(this)||this;return s.method=h.POST,s.path="".concat(p(n),"/").concat(encodeURIComponent(r),"/messages/").concat(i,"/reactions"),s.params={reaction:a},s}return d(t,e),t}(f),Jt=function(e){function t(t,n){var r=e.call(this,t,n)||this;return r.reactionEvent=new ee(n),r}return d(t,e),t}(m),Xt=function(e){function t(t){var n=t.channelType,r=t.channelUrl,i=t.messageId,a=t.reactionKey,s=e.call(this)||this;return s.method=h.DELETE,s.path="".concat(p(n),"/").concat(encodeURIComponent(r),"/messages/").concat(i,"/reactions"),s.params={reaction:a},s}return d(t,e),t}(f),Zt=function(e){function t(t,n){var r=e.call(this,t,n)||this;return r.reactionEvent=new ee(s({},n)),r}return d(t,e),t}(m),$t=function(e){function t(t){var n=t.channelType,r=t.channelUrl,i=t.messageId,a=t.translationTargetLanguages,s=e.call(this)||this;return s.method=h.POST,s.path="".concat(p(n),"/").concat(encodeURIComponent(r),"/messages/").concat(encodeURIComponent(i),"/translation"),s.params={target_langs:a},s}return d(t,e),t}(f),en=function(e){function t(t,n){var r=e.call(this,t,n)||this;return r.message=new Z(t,n),r}return d(t,e),t}(m),tn=function(t){function n(n){var r,i=this;i=t.call(this)||this;var a=[];n.mentionType===e.USERS&&(n.mentionedUserIds?a=n.mentionedUserIds:n.mentionedUsers&&(a=n.mentionedUsers.map((function(e){return e.userId}))));var s=n.channelType,c=n.channelUrl;return i.method=h.POST,i.path="".concat(p(s),"/").concat(encodeURIComponent(c),"/scheduled_messages"),i.params=o(u({req_id:n.reqId,scheduled_at:n.scheduledAt,message_type:P.USER,message:n.message,custom_type:n.customType,data:n.data,mention_type:n.mentionType,mentioned_user_ids:a,sorted_metaarray:null===(r=n.metaArrays)||void 0===r?void 0:r.map((function(e){return J.payloadify(e)})),apple_critical_alert_options:n.appleCriticalAlertOptions?X.payloadify(n.appleCriticalAlertOptions):null,target_langs:n.translationTargetLanguages,push_option:n.pushNotificationDeliveryOption})),i}return d(n,t),n}(f),nn=function(e){function t(t,n){var r=e.call(this,t,n)||this;return r.message=new Z(t,n),r}return d(t,e),t}(m),rn=function(t){function n(n){var r,i=this;i=t.call(this)||this;var a=[];n.mentionType===e.USERS&&(n.mentionedUserIds?a=n.mentionedUserIds:n.mentionedUsers&&(a=n.mentionedUsers.map((function(e){return e.userId}))));var s=n.channelType,o=n.channelUrl;return i.method=h.POST,i.path="".concat(p(s),"/").concat(encodeURIComponent(o),"/scheduled_messages"),i.params=u({req_id:n.reqId,scheduled_at:n.scheduledAt,message_type:P.FILE,url:n.fileUrl,file_name:n.fileName,file_size:n.fileSize,file_type:n.mimeType,thumbnails:n.thumbnailSizes?n.thumbnailSizes.map((function(e){return te.payloadify(e)})):[],custom_type:n.customType,data:n.data,require_auth:n.requireAuth,mention_type:n.mentionType,mentioned_user_ids:a,sorted_metaarray:null===(r=n.metaArrays)||void 0===r?void 0:r.map((function(e){return J.payloadify(e)})),apple_critical_alert_options:n.appleCriticalAlertOptions?X.payloadify(n.appleCriticalAlertOptions):null,push_option:n.pushNotificationDeliveryOption}),i}return d(n,t),n}(f),an=function(e){function t(t,n){var r=e.call(this,t,n)||this;return r.message=new $(t,n),r}return d(t,e),t}(m),sn=function(e){function t(t){var n=t.pollId,r=t.title,i=t.data,a=t.allowUserSuggestion,s=t.allowMultipleVotes,o=t.closeAt,u=e.call(this)||this;return u.method=h.PUT,u.path="".concat(A,"/").concat(encodeURIComponent(n)),u.params={title:r,data:i,allow_user_suggestion:a,allow_multiple_votes:s,close_at:o},u}return d(t,e),t}(f),on=function(e){function t(t,n){var r=e.call(this,t,n)||this;return r.poll=new D(t,n),r}return d(t,e),t}(m),un=function(e){function t(t){var n=t.pollId,r=e.call(this)||this;return r.method=h.DELETE,r.path="".concat(A,"/").concat(encodeURIComponent(n)),r}return d(t,e),t}(f);!function(e){function t(){return null!==e&&e.apply(this,arguments)||this}d(t,e)}(m);var cn=function(e){function t(t){var n=t.pollId,r=e.call(this)||this;return r.method=h.PUT,r.path="".concat(A,"/").concat(encodeURIComponent(n),"/close"),r}return d(t,e),t}(f),ln=function(e){function t(t,n){var r=e.call(this,t,n)||this;return r.poll=new D(t,n),r}return d(t,e),t}(m),dn=function(e){function t(t){var n=t.channelUrl,r=t.channelType,i=t.pollId,a=t.optionText,s=e.call(this)||this;return s.method=h.POST,s.path="".concat(A,"/").concat(encodeURIComponent(i),"/options"),s.params={channel_url:n,channel_type:r,text:a},s}return d(t,e),t}(f),hn=function(e){function t(t,n){var r=e.call(this,t,n)||this;return r.poll=new D(t,n),r}return d(t,e),t}(m),pn=function(e){function t(t){var n=t.pollId,r=t.pollOptionId,i=t.optionText,a=e.call(this)||this;return a.method=h.PUT,a.path="".concat(A,"/").concat(encodeURIComponent(n),"/options/").concat(encodeURIComponent(r)),a.params={text:i},a}return d(t,e),t}(f),fn=function(e){function t(t,n){var r=e.call(this,t,n)||this;return r.poll=new D(t,n),r}return d(t,e),t}(m),mn=function(e){function t(t){var n=t.pollId,r=t.pollOptionId,i=e.call(this)||this;return i.method=h.DELETE,i.path="".concat(A,"/").concat(encodeURIComponent(n),"/options/").concat(encodeURIComponent(r)),i}return d(t,e),t}(f);!function(e){function t(){return null!==e&&e.apply(this,arguments)||this}d(t,e)}(m);var vn=function(e){function t(t){var n=t.reqId,r=t.channelType,i=t.channelUrl,a=t.pollId,s=t.pollOptionIds;return e.call(this,{code:"VOTE",ackRequired:!0,payload:o({req_id:n,channel_type:r===M.OPEN?"open_channels":"group_channels",channel_url:i,poll_id:a,option_ids:s})})||this}return d(t,e),t}(E),yn=function(e){function t(t,n,r){var i=e.call(this,t,"VOTE",r)||this;return i.event=new fe(r),i.channelUrl=r.channel_url,i.channelType=r.channel_type,i}return d(t,e),t}(U),gn=2,_n=function(e){function h(n,r){var a,s,o,u,c=this;return(c=e.call(this,n)||this).channelType=M.BASE,c.name="",c.coverUrl="",c.customType="",c.data="",c.isFrozen=!1,c.isEphemeral=!1,c.creator=null,c.createdAt=0,c._messageCollectionLastAccessedAt=0,c.url=r.channel_url,c.name=null!==(a=r.name)&&void 0!==a?a:"",c.coverUrl=null!==(s=r.cover_url)&&void 0!==s?s:"",c.customType=null!==(o=r.custom_type)&&void 0!==o?o:"",c.data=null!==(u=r.data)&&void 0!==u?u:"",c.isFrozen=!!t("boolean",r.freeze)&&r.freeze,c.isEphemeral=!!t("boolean",r.is_ephemeral)&&r.is_ephemeral,c.creator=r.created_by?new i(c._iid,r.created_by):null,c.createdAt=1e3*r.created_at,r.metadata&&Object.keys(r.metadata).length>0&&r.ts&&(c._cachedMetaData=new Map,Object.keys(r.metadata).forEach((function(e){c._cachedMetaData.set(e,{value:r.metadata[e],isRemoved:!1,updatedAt:r.ts})}))),c}return d(h,e),h.payloadify=function(t){return o(u(s(s({},e.payloadify.call(this,t)),{channel_url:t.url,name:t.name,cover_url:t.coverUrl,custom_type:t.customType,data:t.data,freeze:t.isFrozen,is_ephemeral:t.isEphemeral,created_by:t.creator?i.payloadify(t.creator):null,created_at:t.createdAt/1e3})))},h.prototype.isGroupChannel=function(){return this.channelType===M.GROUP},h.prototype.isOpenChannel=function(){return this.channelType===M.OPEN},Object.defineProperty(h.prototype,"cachedMetaData",{get:function(){var e={};return this._cachedMetaData?(this._cachedMetaData.forEach((function(t,n){t.isRemoved||(e[n]=t.value)})),e):e},enumerable:!1,configurable:!0}),Object.defineProperty(h.prototype,"messageCollectionLastAccessedAt",{get:function(){return this._messageCollectionLastAccessedAt},enumerable:!1,configurable:!0}),h.prototype._updateMessageCollectionLastAccessedAt=function(){this._messageCollectionLastAccessedAt=Date.now()},h.prototype._update=function(e){var t=o(e);Object.assign(this,t)},h.prototype._upsertCachedMetaData=function(e,t){var n=this;Object.keys(e).forEach((function(r){n._cachedMetaData||(n._cachedMetaData=new Map);var i=n._cachedMetaData.get(r);(!i||i.updatedAt<=t)&&n._cachedMetaData.set(r,{value:e[r],isRemoved:!1,updatedAt:t})}))},h.prototype._removeFromCachedMetaData=function(e,t){var n=this;this._cachedMetaData&&e.forEach((function(e){var r=n._cachedMetaData.get(e);r&&r.updatedAt0&&r("string",t)).throw(_.invalidParameters),n=T.of(this._iid).requestQueue,i=new $t({channelType:this.channelType,channelUrl:this.url,messageId:e.messageId,translationTargetLanguages:t}),[4,n.send(i)];case 1:return a=s.sent(),[2,a.as(en).message]}}))}))},h.prototype._createScheduledUserMessage=function(e,t){var n=this,r=T.of(this._iid).requestQueue,i=Date.now(),a=this._generateRequestId();Q(2).then((function(){var r=n._createPendingScheduledUserMessage(e,a,i);G((function(){return v(n,void 0,void 0,(function(){return g(this,(function(e){return[2,t._trigger(null,r)]}))}))}))}));var o=new tn(s({reqId:a,channelType:this.channelType,channelUrl:this.url},e));r.send(o).then((function(e){var r=e.as(nn).message;G((function(){return v(n,void 0,void 0,(function(){return g(this,(function(e){return[2,t._trigger(null,r)]}))}))}))})).catch((function(r){if(V(r))throw r;Q(2).then((function(){var s=n._createPendingScheduledUserMessage(e,a,i);n._markMessageAsFailed(s,r),G((function(){return v(n,void 0,void 0,(function(){return g(this,(function(e){return[2,t._trigger(r,s)]}))}))}))}))}))},h.prototype.sendFileMessage=function(e){var t=s(s({},Ne),e);return k(Fe(t)).throw(_.invalidParameters),this._sendFileMessage(t)},h.prototype.sendMultipleFilesMessage=function(e){var t,n=s(s({},Qe),e),r=T.of(this._iid);k(function(e,t){return void 0===t&&(t=l),Pe(e)&&Array.isArray(e.fileInfoList)&&e.fileInfoList.length>=2&&e.fileInfoList.length<=t&&e.fileInfoList.every((function(e){return ze(e)}))}(n,null===(t=r.appInfo)||void 0===t?void 0:t.multipleFilesMessageFileCountLimit)).throw(_.invalidParameters);var i=!!e.fileInfoList.find((function(e){var t=r.appInfo.uploadSizeLimit;return e.file instanceof Blob&&e.file.size>t||e.fileSize>t}));return k(!i).throw(_.fileSizeLimitExceededError),this._sendMultipleFilesMessage(n)},h.prototype._sendFileMessage=function(e,t){var n=this,r=T.of(this._iid),i=r.dispatcher;r.sessionManager;var a=ae.of(this._iid).fileMessageQueue,s=null!=t?t:this._generateRequestId(),o=Date.now(),u=new oe;return Q(2).then((function(){var t=n._createPendingFileMessage(e,s,o);i.dispatch(new z({messages:[t],source:x.EVENT_MESSAGE_SENT_PENDING})),G((function(){return v(n,void 0,void 0,(function(){return g(this,(function(e){return[2,u._trigger(null,t)]}))}))})),a.request(n,s,e).then((function(e){i.dispatch(new z({messages:[e],source:x.EVENT_MESSAGE_SENT_SUCCESS})),G((function(){return v(n,void 0,void 0,(function(){return g(this,(function(t){return[2,u._trigger(null,e)]}))}))}))})).catch((function(t){if(V(t))throw t;var r=n._createPendingFileMessage(e,s,o),a=T.of(n._iid).cacheContext.localCacheEnabled&&j(t.code);n._markMessageAsFailed(r,t,a),i.dispatch(new z({messages:[r],source:r.sendingStatus===O.PENDING?x.REQUEST_RESEND_MESSAGE:x.EVENT_MESSAGE_SENT_FAILED})),G((function(){return v(n,void 0,void 0,(function(){return g(this,(function(e){return[2,u._trigger(t,r)]}))}))}))}))})),u},h.prototype._autoResendFileMessage=function(e){k(e instanceof $&&!!e.messageParams).throw(_.invalidParameters);var t=T.of(this._iid).logger;return t.debug("autoResendFileMessage pending",e),this._sendFileMessage(e.messageParams,e.reqId).onFailed((function(e){t.debug("autoResendFileMessage failed",e)})).onSucceeded((function(e){t.debug("autoResendFileMessage success",e)}))},h.prototype._sendMultipleFilesMessage=function(e,t){var n=this,r=T.of(this._iid),i=r.dispatcher;r.sessionManager;var a=ae.of(this._iid).fileMessageQueue,s=null!=t?t:this._generateRequestId(),o=Date.now(),u=new se;return Q(2).then((function(){var t=n._createPendingMultipleFilesMessage(e,s,o);i.dispatch(new z({messages:[t],source:x.EVENT_MESSAGE_SENT_PENDING})),G((function(){return v(n,void 0,void 0,(function(){return g(this,(function(e){return[2,u._trigger(null,t)]}))}))})),a.request(n,s,e,u).then((function(e){i.dispatch(new z({messages:[e],source:x.EVENT_MESSAGE_SENT_SUCCESS})),G((function(){return v(n,void 0,void 0,(function(){return g(this,(function(t){return[2,u._trigger(null,e)]}))}))}))})).catch((function(t){if(V(t))throw t;var r=n._createPendingMultipleFilesMessage(e,s,o);n._markMessageAsFailed(r,t),i.dispatch(new z({messages:[r],source:x.EVENT_MESSAGE_SENT_FAILED})),G((function(){return v(n,void 0,void 0,(function(){return g(this,(function(e){return[2,u._trigger(t,r)]}))}))}))}))})),u},h.prototype._createScheduledFileMessage=function(e,t,n,r){var i=this,a=T.of(this._iid).requestQueue,o=new rn(s(s({reqId:n,channelType:this.channelType,channelUrl:this.url},e),{fileUrl:e.fileUrl,requireAuth:e.requireAuth}));a.send(o).then((function(e){var n=e.as(an).message;G((function(){return v(i,void 0,void 0,(function(){return g(this,(function(e){return[2,t._trigger(null,n)]}))}))}))})).catch((function(a){if(V(a))throw a;Q(2).then((function(){var s=i._createPendingScheduledFileMessage(e,n,r);i._markMessageAsFailed(s,a),G((function(){return v(i,void 0,void 0,(function(){return g(this,(function(e){return[2,t._trigger(a,s)]}))}))}))}))}))},h.prototype.sendFileMessages=function(e){var t,n;k(e.every((function(e){return Fe(s(s({},Ne),e))}))).throw(_.invalidParameters);var r=new oe;try{for(var i=L(e),a=i.next();!a.done;a=i.next()){var o=a.value;this.sendFileMessage(o).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{a&&!a.done&&(n=i.return)&&n.call(i)}finally{if(t)throw t.error}}return r},h.prototype.resendFileMessage=function(e,t){var n;return v(this,void 0,void 0,(function(){var r,i,a;return g(this,(function(s){return r=Boolean(e.url)||c(t)||c(null===(n=e.messageParams)||void 0===n?void 0:n.file),k(e instanceof $&&r&&!e.scheduledInfo).throw(_.invalidParameters),i=new H,a=function(e,t){var n;return e.messageParams?(!e.url&&c(t)&&(e.messageParams.file=t),e.messageParams):o(u({data:e.data,customType:e.customType,mentionType:e.mentionType,mentionedUsers:e.mentionedUsers,mentionedUserIds:e.mentionedUserIds,metaArrays:e.metaArrays,parentMessageId:e.parentMessageId,appleCriticalAlertOptions:e.appleCriticalAlertOptions,file:t,fileUrl:e.url,fileName:e.name,fileSize:e.size,mimeType:e.type,thumbnailSizes:null===(n=e.thumbnails)||void 0===n?void 0:n.map((function(e){return{maxWidth:e.width,maxHeight:e.height}}))}))}(e,t),this._sendFileMessage(a,e.reqId).onFailed((function(e){return i.reject(e)})).onSucceeded((function(e){return i.resolve(e)})),[2,i.promise]}))}))},h.prototype.updateFileMessage=function(e,n){return v(this,void 0,void 0,(function(){var r,i,a,o;return g(this,(function(u){switch(u.label){case 0:return r=s(s({},He),n),k(t("number",e)&&function(e){return Be(e)}(r)).throw(_.invalidParameters),i=T.of(this._iid).requestQueue,a=new Bt(s({channelType:this.channelType,channelUrl:this.url,messageId:e},r)),[4,i.send(a)];case 1:return o=u.sent(),[2,o.as(Wt).message]}}))}))},h.prototype.cancelUploadingFileMessage=function(e){return v(this,void 0,void 0,(function(){return g(this,(function(n){return k(t("string",e)).throw(_.invalidParameters),ae.of(this._iid).fileMessageQueue.cancel(this,e),[2,!0]}))}))},h.prototype.copyFileMessage=function(e,t){var n,r,i;return v(this,void 0,void 0,(function(){var o,c;return g(this,(function(l){return k(e instanceof h&&t instanceof $&&t.sendingStatus===O.SUCCEEDED&&this.url===t.channelUrl&&!t.scheduledInfo).throw(_.invalidParameters),o=new H,c=u(s(s({},t),{fileUrl:t.url,fileName:t.name,fileSize:t.size,mimeType:t.type,mentionType:t.mentionType,mentionedUserIds:null!==(n=t.mentionedUserIds)&&void 0!==n?n:null===(r=t.mentionedUsers)||void 0===r?void 0:r.map((function(e){return e.userId})),pushNotificationDeliveryOption:a.DEFAULT,parentMessageId:null,isReplyToChannel:!1,thumbnailSizes:null===(i=t.thumbnails)||void 0===i?void 0:i.map((function(e){return{maxWidth:e.width,maxHeight:e.height}})),requireAuth:t.requireAuth,isPinnedMessage:!1})),e._sendFileMessage(c).onSucceeded((function(e){return o.resolve(e)})).onFailed((function(e){return o.reject(e)})),[2,o.promise]}))}))},h.prototype.deleteMessage=function(e){return v(this,void 0,void 0,(function(){var t,n;return g(this,(function(r){switch(r.label){case 0:return k(e instanceof he).throw(_.invalidParameters),e.messageId>0?(t=T.of(this._iid).requestQueue,n=new Kt({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]}}))}))},h.prototype.addReaction=function(e,n){return v(this,void 0,void 0,(function(){var r,i,a;return g(this,(function(s){switch(s.label){case 0:return k(e instanceof he&&e.messageId>0&&t("string",n)).throw(_.invalidParameters),r=T.of(this._iid).requestQueue,i=new Yt({channelType:this.channelType,channelUrl:this.url,messageId:e.messageId,reactionKey:n}),[4,r.send(i)];case 1:return a=s.sent(),[2,a.as(Jt).reactionEvent]}}))}))},h.prototype.deleteReaction=function(e,n){return v(this,void 0,void 0,(function(){var r,i,a;return g(this,(function(s){switch(s.label){case 0:return k(e instanceof he&&e.messageId>0&&t("string",n)).throw(_.invalidParameters),r=T.of(this._iid).requestQueue,i=new Xt({channelType:this.channelType,channelUrl:this.url,messageId:e.messageId,reactionKey:n}),[4,r.send(i)];case 1:return a=s.sent(),[2,a.as(Zt).reactionEvent]}}))}))},h.prototype._updateUserMessageMetaArray=function(e,t,n,r){return v(this,void 0,void 0,(function(){var i,a,s,o,u,c;return g(this,(function(l){switch(l.label){case 0:return i=T.of(this._iid),a=i.dispatcher,s=i.requestQueue,o=new Vt({channelType:this.channelType,channelUrl:this.url,messageId:e,metaArrayParams:{array:t,mode:n,upsert:r}}),[4,s.send(o)];case 1:return u=l.sent(),c=u.as(jt).message,a.dispatch(new z({messages:[c],source:x.EVENT_MESSAGE_UPDATED})),[2,c]}}))}))},h.prototype._updateFileMessageMetaArray=function(e,t,n,r){return v(this,void 0,void 0,(function(){var i,a,s,o,u,c;return g(this,(function(l){switch(l.label){case 0:return i=T.of(this._iid),a=i.dispatcher,s=i.requestQueue,o=new Bt({channelType:this.channelType,channelUrl:this.url,messageId:e,metaArrayParams:{array:t,mode:n,upsert:r}}),[4,s.send(o)];case 1:return u=l.sent(),c=u.as(Wt).message,a.dispatch(new z({messages:[c],source:x.EVENT_MESSAGE_UPDATED})),[2,c]}}))}))},h.prototype.createMessageMetaArrayKeys=function(e,t){return v(this,void 0,void 0,(function(){var n;return g(this,(function(i){return k(e instanceof he&&e.messageId>0&&r("string",t)).throw(_.invalidParameters),n=t.map((function(e){return new J({key:e})})),e instanceof $?[2,this._updateFileMessageMetaArray(e.messageId,n,"add",!0)]:[2,this._updateUserMessageMetaArray(e.messageId,n,"add",!0)]}))}))},h.prototype.deleteMessageMetaArrayKeys=function(e,t){return v(this,void 0,void 0,(function(){var n;return g(this,(function(i){return k(e instanceof he&&e.messageId>0&&r("string",t)).throw(_.invalidParameters),n=t.map((function(e){return new J({key:e})})),e instanceof $?[2,this._updateFileMessageMetaArray(e.messageId,n,"remove",!0)]:[2,this._updateUserMessageMetaArray(e.messageId,n,"remove",!0)]}))}))},h.prototype.addMessageMetaArrayValues=function(e,t){return v(this,void 0,void 0,(function(){return g(this,(function(n){return k(e instanceof he&&e.messageId>0&&t.every((function(e){return e instanceof J}))).throw(_.invalidParameters),e instanceof $?[2,this._updateFileMessageMetaArray(e.messageId,t,"add",!0)]:[2,this._updateUserMessageMetaArray(e.messageId,t,"add",!0)]}))}))},h.prototype.removeMessageMetaArrayValues=function(e,t){return v(this,void 0,void 0,(function(){return g(this,(function(n){return k(e instanceof he&&e.messageId>0&&t.every((function(e){return e instanceof J}))).throw(_.invalidParameters),e instanceof $?[2,this._updateFileMessageMetaArray(e.messageId,t,"remove",!0)]:[2,this._updateUserMessageMetaArray(e.messageId,t,"remove",!0)]}))}))},h.prototype.report=function(e,r){return v(this,void 0,void 0,(function(){var i,a,s,o;return g(this,(function(u){switch(u.label){case 0:return k(n(xe,e)&&t("string",r)).throw(_.invalidParameters),i=T.of(this._iid),a=i.sdkState,s=i.requestQueue,o=new kt({channelUrl:this.url,channelType:this.channelType,userId:a.userId,category:e,description:r}),[4,s.send(o)];case 1:return u.sent(),[2]}}))}))},h.prototype.reportUser=function(e,r,a){return v(this,void 0,void 0,(function(){var s,o,u,c;return g(this,(function(l){switch(l.label){case 0:return k(e instanceof i&&n(xe,r)&&t("string",a)).throw(_.invalidParameters),s=T.of(this._iid),o=s.sdkState,u=s.requestQueue,c=new Qt({channelUrl:this.url,channelType:this.channelType,userId:o.userId,offendingUserId:e.userId,category:r,description:a}),[4,u.send(c)];case 1:return l.sent(),[2]}}))}))},h.prototype.reportMessage=function(e,r,i){return v(this,void 0,void 0,(function(){var a,s,o,u;return g(this,(function(c){switch(c.label){case 0:return k(e instanceof pe&&n(xe,r)&&t("string",i)).throw(_.invalidParameters),a=T.of(this._iid),s=a.sdkState,o=a.requestQueue,u=new zt({channelUrl:this.url,channelType:this.channelType,userId:s.userId,offendingUserId:e.sender.userId,messageId:e.messageId,category:r,description:i}),[4,o.send(u)];case 1:return c.sent(),[2]}}))}))},h.prototype.updatePoll=function(e,n){return v(this,void 0,void 0,(function(){var r,i,a;return g(this,(function(o){switch(o.label){case 0:return k(t("number",e)&&function(e){return t("string",e.title,!0)&&C(e.data)&&t("boolean",e.allowUserSuggestion,!0)&&t("boolean",e.allowMultipleVotes,!0)&&t("number",e.closeAt,!0)}(n)).throw(_.invalidParameters),r=T.of(this._iid).requestQueue,i=new sn(s({pollId:e},n)),[4,r.send(i)];case 1:return a=o.sent(),[2,a.as(on).poll]}}))}))},h.prototype.deletePoll=function(e){return v(this,void 0,void 0,(function(){var n,r,i;return g(this,(function(a){switch(a.label){case 0:return n=t("number",e),k(n).throw(_.invalidParameters),r=T.of(this._iid).requestQueue,i=new un({pollId:e}),[4,r.send(i)];case 1:return a.sent(),[2]}}))}))},h.prototype.closePoll=function(e){return v(this,void 0,void 0,(function(){var n,r,i,a;return g(this,(function(s){switch(s.label){case 0:return n=t("number",e),k(n).throw(_.invalidParameters),r=T.of(this._iid).requestQueue,i=new cn({pollId:e}),[4,r.send(i)];case 1:return a=s.sent(),[2,a.as(ln).poll]}}))}))},h.prototype.addPollOption=function(e,n){return v(this,void 0,void 0,(function(){var r,i,a,s;return g(this,(function(o){switch(o.label){case 0:return r=t("number",e)&&t("string",n)&&""!==n.trim(),k(r).throw(_.invalidParameters),i=T.of(this._iid).requestQueue,a=new dn({channelUrl:this.url,channelType:this.channelType,pollId:e,optionText:n}),[4,i.send(a)];case 1:return s=o.sent(),[2,s.as(hn).poll]}}))}))},h.prototype.updatePollOption=function(e,n,r){return v(this,void 0,void 0,(function(){var i,a,s,o;return g(this,(function(u){switch(u.label){case 0:return i=t("number",e)&&t("number",n)&&t("string",r)&&""!==r.trim(),k(i).throw(_.invalidParameters),a=T.of(this._iid).requestQueue,s=new pn({pollId:e,pollOptionId:n,optionText:r}),[4,a.send(s)];case 1:return o=u.sent(),[2,o.as(fn).poll]}}))}))},h.prototype.deletePollOption=function(e,n){return v(this,void 0,void 0,(function(){var r,i,a;return g(this,(function(s){switch(s.label){case 0:return r=t("number",e)&&t("number",n),k(r).throw(_.invalidParameters),i=T.of(this._iid).requestQueue,a=new mn({pollId:e,pollOptionId:n}),[4,i.send(a)];case 1:return s.sent(),[2]}}))}))},h.prototype.votePoll=function(e,n){return v(this,void 0,void 0,(function(){var i,a,s,o,u,c,l;return g(this,(function(d){switch(d.label){case 0:return i=t("number",e)&&r("number",n),k(i).throw(_.invalidParameters),a=T.of(this._iid),s=a.requestQueue,o=a.dispatcher,u=new vn({reqId:this._generateRequestId(),channelUrl:this.url,channelType:this.channelType,pollId:e,pollOptionIds:n}),[4,s.send(u)];case 1:return c=d.sent(),l=c.as(yn).event,o.dispatch(new Y({event:l,source:x.EVENT_POLL_VOTED})),[2,l]}}))}))},h.prototype.getPollChangeLogsSinceTimestamp=function(e){return v(this,void 0,void 0,(function(){return g(this,(function(n){switch(n.label){case 0:return k(t("number",e)).throw(_.invalidParameters),[4,ye.of(this._iid).getPollChangeLogs(this.url,this.channelType,e)];case 1:return[2,n.sent()]}}))}))},h.prototype.getPollChangeLogsSinceToken=function(e){return v(this,void 0,void 0,(function(){return g(this,(function(n){switch(n.label){case 0:return k(t("string",e,!0)),[4,ye.of(this._iid).getPollChangeLogs(this.url,this.channelType,e)];case 1:return[2,n.sent()]}}))}))},h.prototype.createPollListQuery=function(e){return void 0===e&&(e=10),new me(this._iid,{channelUrl:this.url,channelType:this.channelType,limit:e})},h.prototype.createPollVoterListQuery=function(e,t,n){return void 0===n&&(n=20),new ve(this._iid,{channelUrl:this.url,channelType:this.channelType,pollId:e,pollOptionId:t,limit:n})},h}(B);export{jt as A,rt as B,Wt as C,Ie as D,Gt as E,ge as F,je as G,Be as H,We as I,Ke as J,nn as K,gn as L,et as M,Te as N,Xe as O,yn as P,xe as R,Ae as U,Ue as a,we as b,Me as c,Ee as d,be as e,_n as f,Ve as g,Ge as h,Re as i,Se as j,Le as k,Pe as l,ke as m,Oe as n,qe as o,_e as p,Et as q,ft as r,Ce as s,Ft as t,Lt as u,De as v,qt as w,Ct as x,Dt as y,Ht as z}; diff --git a/lib/__bundle-e99277d8.js b/lib/__bundle-e99277d8.js deleted file mode 100644 index 57d1753..0000000 --- a/lib/__bundle-e99277d8.js +++ /dev/null @@ -1 +0,0 @@ -import{a3 as e,a as t,K as n,m as r,U as i,a8 as a,g as s,e as o,i as u,ax as l,_ as c,A as d,aa as h,f as p,h as f,b as m,al as v,c as y,S as g,V as _,W as T,ay as U,az as I,O as w,a9 as M,ab as E,aA as b,aB as S,av as P,at as C,a7 as A,u as D,a0 as q,a4 as R,J as L,a1 as O,ac as N,s as F,ad as k,ai as Q,ah as z,y as x,aC as G,aq as V,$ as j,q as B,r as W,ae as K,aD as H}from"./__bundle-a8606dd4.js";import{d as Y,A as J,U as $,F as X,R as Z,T as ee,e as te,f as ne,b as re,c as ie,g as ae,h as se,i as oe,v as ue,j as le,k as ce,B as de,S as he}from"./__bundle-8cd94b6f.js";import{i as pe,P as fe,a as me,b as ve}from"./__bundle-3707a8af.js";var ye,ge=100,_e="GroupChannel",Te="url",Ue=100,Ie="Message",we="messageId",Me="Poll",Ee="pollId",be={data:null,customType:null,mentionType:e.USERS,mentionedUserIds:null,mentionedUsers:null,mentionedMessageTemplate:null,metaArrays:null,parentMessageId:null,isReplyToChannel:!1,pushNotificationDeliveryOption:null,appleCriticalAlertOptions:null,isPinnedMessage:!1},Se=function(s){return t("string",s.data,!0)&&t("string",s.customType,!0)&&n(e,s.mentionType)&&r("string",s.mentionedUserIds,!0)&&r(i,s.mentionedUsers,!0)&&t("string",s.mentionedMessageTemplate,!0)&&r(Y,s.metaArrays,!0)&&t("number",s.parentMessageId,!0)&&t("boolean",s.isReplyToChannel)&&n(a,s.pushNotificationDeliveryOption,!0)&&t(J,s.appleCriticalAlertOptions,!0)&&t("boolean",s.isPinnedMessage,!0)},Pe=function(e){return e?{isReplyToChannel:e.isReplyToChannel,pushNotificationDeliveryOption:e.pushNotificationDeliveryOption,pollId:e.pollId}:null},Ce=s(s({},be),{message:null,translationTargetLanguages:null,pollId:null}),Ae=function(e){return Se(e)&&t("string",e.message)&&r("string",e.translationTargetLanguages,!0)&&t("number",e.pollId,!0)};!function(e){e.FILE="file",e.BLOB="blob",e.BLOB_LIKE_OBJECT="blobLikeObject",e.URL="url"}(ye||(ye={}));var De,qe=function(e){return"undefined"!=typeof window&&"Blob"in window&&"undefined"!=typeof Blob&&e instanceof Blob},Re=function(e){return e===ye.BLOB||e===ye.FILE},Le=function(e){return e?{file:e.file,fileKey:e.fileKey,fileType:e.fileType,isReplyToChannel:e.isReplyToChannel,pushNotificationDeliveryOption:e.pushNotificationDeliveryOption}:null},Oe=s(s({},be),{file:null,fileKey:null,fileUrl:null,fileName:null,fileType:null,fileSize:null,mimeType:null,thumbnailSizes:null,requireAuth:!1}),Ne=function(e){return Se(e)&&(u(e.file)||t("string",e.fileUrl))&&t("string",e.fileName,!0)&&t("string",e.mimeType,!0)&&t("number",e.fileSize,!0)&&(null===e.thumbnailSizes||void 0===e.thumbnailSizes||Array.isArray(e.thumbnailSizes)&&e.thumbnailSizes.every((function(e){return t("object",e)&&e.maxWidth>0&&e.maxHeight>0})))},Fe=function(e){return e?o({fileInfoList:e.fileInfoList,isReplyToChannel:e.isReplyToChannel,pushNotificationDeliveryOption:e.pushNotificationDeliveryOption}):null},ke=s(s({},be),{fileInfoList:null}),Qe=function(e){return(u(e.file)||t("string",e.fileUrl))&&t("string",e.fileName,!0)&&t("string",e.mimeType,!0)&&t("number",e.fileSize,!0)&&(void 0===e.thumbnailSizes||Array.isArray(e.thumbnailSizes)&&e.thumbnailSizes.every((function(e){return e.maxWidth>0&&e.maxHeight>0})))};!function(e){e.MUTED="muted",e.BANNED="banned"}(De||(De={}));var ze,xe=function(){function e(e){var t,r,i,a;this.restrictionType=null,this.description=null,this.endAt=-1,this.remainingDuration=-1,n(De,e.restriction_type)&&(this.restrictionType=e.restriction_type),this.description=null!==(t=e.description)&&void 0!==t?t:null,this.endAt=null!==(i=null!==(r=e.end_at)&&void 0!==r?r:e.muted_end_at)&&void 0!==i?i:-1,this.remainingDuration=null!==(a=e.remaining_duration)&&void 0!==a?a:-1}return e.payloadify=function(e){return e?o({restriction_type:e.restrictionType,description:e.description,end_at:e.endAt,remaining_duration:e.remainingDuration}):null},e}(),Ge=function(e){function t(t,n){var r=e.call(this,t,n)||this;return r.restrictionInfo=null,r.restrictionInfo=new xe(n),r}return c(t,e),t.payloadify=function(t){return t?o(s(s({},e.payloadify.call(this,t)),xe.payloadify(t.restrictionInfo))):null},t}(i),Ve={data:null,customType:null,mentionType:e.USERS,mentionedUserIds:null,mentionedUsers:null,mentionedMessageTemplate:null,metaArrays:null,pushNotificationDeliveryOption:null,appleCriticalAlertOptions:null},je=function(s){return t("string",s.data,!0)&&t("string",s.customType,!0)&&n(e,s.mentionType)&&r("string",s.mentionedUserIds,!0)&&r(i,s.mentionedUsers,!0)&&t("string",s.mentionedMessageTemplate,!0)&&r(Y,s.metaArrays,!0)&&n(a,s.pushNotificationDeliveryOption,!0)&&t(J,s.appleCriticalAlertOptions,!0)},Be=s(s({},Ve),{message:null,translationTargetLanguages:null,pollId:null}),We=function(e){return je(e)&&t("string",e.message,!0)&&r("string",e.translationTargetLanguages,!0)&&t("number",e.pollId,!0)},Ke=s({},Ve),He=function(e){function t(t){var n=t.channelUrl,r=t.channelType,i=t.token,a=t.limit,s=e.call(this)||this;return s.method=d.GET,s.path="".concat(h(r),"/").concat(encodeURIComponent(n),"/operators"),s.params={token:i,limit:a},s}return c(t,e),t}(p),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 i(t,e)})),r.token=n.next,r}return c(t,e),t}(f),Je=function(e){function t(t,n,r,i){return e.call(this,t,n,r,i)||this}return c(t,e),t.prototype._validate=function(){return e.prototype._validate.call(this)},t.prototype.next=function(){return m(this,void 0,void 0,(function(){var e,t,n,r,i,a,o;return y(this,(function(u){switch(u.label){case 0:return this._validate()?this._isLoading?[3,3]:(e=[],this._hasNext?(this._isLoading=!0,t=_.of(this._iid).requestQueue,n=new He(s(s({},this),{channelUrl:this.channelUrl,token:this._token})),[4,t.send(n)]):[3,2]):[3,5];case 1:return r=u.sent(),i=r.as(Ye),a=i.operators,o=i.token,this._token=o,this._hasNext=!!o,this._isLoading=!1,[2,a];case 2:return[2,e];case 3:throw g.queryInProgress;case 4:return[3,6];case 5:throw g.invalidParameters;case 6:return[2]}}))}))},t}(v),$e=function(e){function t(t){var n=this,r=t.channelUrl,i=t.channelType,a=t.limit,s=t.token;return(n=e.call(this)||this).method=d.GET,n.path="".concat(h(i),"/").concat(encodeURIComponent(r),"/mute"),n.params={limit:a,token:s},n}return c(t,e),t}(p),Xe=function(e){function t(t,n){var r=e.call(this,t,n)||this;r.token=null,r.mutedUsers=[];var i=n.next,a=n.muted_list;return r.token=i,a&&a.length>0&&(r.mutedUsers=a.map((function(e){return new Ge(t,e)}))),r}return c(t,e),t}(f),Ze=function(e){function t(t,n,r,i){return e.call(this,t,n,r,i)||this}return c(t,e),t.prototype.next=function(){return m(this,void 0,void 0,(function(){var e,t,n,r,i,a;return y(this,(function(o){switch(o.label){case 0:return this._validate()?this._isLoading?[3,3]:this._hasNext?(this._isLoading=!0,e=_.of(this._iid).requestQueue,t=new $e(s(s({},this),{token:this._token})),[4,e.send(t)]):[3,2]:[3,5];case 1:return n=o.sent(),r=n.as(Xe),i=r.mutedUsers,a=r.token,this._token=a,this._hasNext=!!a,this._isLoading=!1,[2,i];case 2:return[2,[]];case 3:throw g.queryInProgress;case 4:return[3,6];case 5:throw g.invalidParameters;case 6:return[2]}}))}))},t}(v),et=function(e){function t(t){var n=this,r=t.channelUrl,i=t.channelType,a=t.limit,s=t.token;return(n=e.call(this)||this).method=d.GET,n.path="".concat(h(i),"/").concat(encodeURIComponent(r),"/ban"),n.params=o({limit:a,token:s}),n}return c(t,e),t}(p),tt=function(e){function t(t,n){var r=e.call(this,t,n)||this;r.token=null,r.bannedUsers=[];var i=n.next,a=n.banned_list;return r.token=i,a&&a.length>0&&(r.bannedUsers=a.map((function(e){return new Ge(t,e.user)}))),r}return c(t,e),t}(f),nt=function(e){function t(t,n,r,i){return e.call(this,t,n,r,i)||this}return c(t,e),t.prototype._validate=function(){return e.prototype._validate.call(this)},t.prototype.next=function(){return m(this,void 0,void 0,(function(){var e,t,n,r,i,a;return y(this,(function(o){switch(o.label){case 0:return this._validate()?this._isLoading?[3,3]:this._hasNext?(this._isLoading=!0,e=_.of(this._iid).requestQueue,t=new et(s(s({},this),{token:this._token})),[4,e.send(t)]):[3,2]:[3,5];case 1:return n=o.sent(),r=n.as(tt),i=r.bannedUsers,a=r.token,this._token=a,this._hasNext=!!a,this._isLoading=!1,[2,i];case 2:return[2,[]];case 3:throw g.queryInProgress;case 4:return[3,6];case 5:throw g.invalidParameters;case 6:return[2]}}))}))},t}(v);!function(e){e.SPAM="spam",e.HARASSING="harassing",e.SUSPICIOUS="suspicious",e.INAPPROPRIATE="inappropriate"}(ze||(ze={}));var rt=function(e){function t(t){var n=this,r=t.channelUrl,i=t.channelType,a=t.operatorUserIds;return(n=e.call(this)||this).method=d.POST,n.path="".concat(h(i),"/").concat(encodeURIComponent(r),"/operators"),n.params={operator_ids:a},n}return c(t,e),t}(p);!function(e){function t(){return null!==e&&e.apply(this,arguments)||this}c(t,e)}(f);var it=function(e){function t(t){var n=this,r=t.channelUrl,i=t.channelType,a=t.operatorUserIds;return(n=e.call(this)||this).method=d.DELETE,n.path="".concat(h(i),"/").concat(encodeURIComponent(r),"/operators"),n.params={operator_ids:a},n}return c(t,e),t}(p);!function(e){function t(t,n){return e.call(this,t,n)||this}c(t,e)}(f);var at=function(e){function t(t){var n=this,r=t.channelUrl,i=t.channelType,a=t.userId;return(n=e.call(this)||this).method=d.GET,n.path="".concat(h(i),"/").concat(encodeURIComponent(r),"/mute/").concat(a),n}return c(t,e),t}(p),st=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 i=n.is_muted,a=n.start_at,s=n.end_at,o=n.remaining_duration,u=n.description;return r.isMuted=i,r.startAt=a,r.endAt=s,r.remainingDuration=o,r.description=u,r}return c(t,e),t}(f),ot=function(e){function t(t){var n=this,r=t.channelUrl,i=t.channelType,a=t.keys;return(n=e.call(this)||this).method=d.GET,n.path="".concat(h(i),"/").concat(encodeURIComponent(r),"/metadata"),n.params={keys:a,include_ts:!0},n}return c(t,e),t}(p),ut=function(e){function t(t,n){var r=e.call(this,t,n)||this;r.ts=null;var i=n.metadata,a=n.ts;return r.metadata=i,r.ts=null!=a?a:null,r}return c(t,e),t}(f),lt=function(e){function t(t){var n=this,r=t.channelUrl,i=t.channelType,a=t.metadata;return(n=e.call(this)||this).method=d.POST,n.path="".concat(h(i),"/").concat(encodeURIComponent(r),"/metadata"),n.params={metadata:a,include_ts:!0},n}return c(t,e),t}(p),ct=function(e){function t(t,n){var r,i,a=this;return(a=e.call(this,t,n)||this).metaData=null!==(r=n.metadata)&&void 0!==r?r:{},a.ts=null!==(i=n.ts)&&void 0!==i?i:null,a}return c(t,e),t}(f),dt=function(e){function t(t){var n=this,r=t.channelUrl,i=t.channelType,a=t.metadata,s=t.upsert;return(n=e.call(this)||this).method=d.PUT,n.path="".concat(h(i),"/").concat(encodeURIComponent(r),"/metadata"),n.params={metadata:a,include_ts:!0,upsert:null!=s&&s},n}return c(t,e),t}(p),ht=function(e){function t(t,n){var r=e.call(this,t,n)||this;r.ts=null;var i=n.metadata,a=n.ts;return r.metadata=i,r.ts=null!=a?a:null,r}return c(t,e),t}(f),pt=function(e){function t(t,n,r){var i=e.call(this,t,"SYEV",r)||this;return i.created=null,i.updated=null,i.deleted=null,r.data&&(i.created=r.data.created,i.updated=r.data.updated,i.deleted=r.data.deleted),i}return c(t,e),t}(T),ft=function(e){function t(t){var n=this,r=t.channelUrl,i=t.channelType,a=t.key;return(n=e.call(this)||this).method=d.DELETE,n.path="".concat(h(i),"/").concat(encodeURIComponent(r),"/metadata/").concat(a),n.params={include_ts:!0},n}return c(t,e),t}(p),mt=function(e){function t(t,n){var r=e.call(this,t,n)||this;r.ts=null;var i=n.ts;return r.ts=null!=i?i:null,r}return c(t,e),t}(f),vt=function(e){function t(t){var n=this,r=t.channelUrl,i=t.channelType;return(n=e.call(this)||this).method=d.DELETE,n.path="".concat(h(i),"/").concat(encodeURIComponent(r),"/metadata"),n.params={include_ts:!0},n}return c(t,e),t}(p),yt=function(e){function t(t,n){var r=e.call(this,t,n)||this;r.ts=null;var i=n.ts;return r.ts=null!=i?i:null,r}return c(t,e),t}(f),gt=function(e){function t(t){var n=this,r=t.channelUrl,i=t.channelType,a=t.keys;return(n=e.call(this)||this).method=d.GET,n.path="".concat(h(i),"/").concat(encodeURIComponent(r),"/metacounter"),n.params={keys:a},n}return c(t,e),t}(p),_t=function(e){function t(t,n){var r=e.call(this,t,n)||this;return r.metaCounter=n,r}return c(t,e),t}(f),Tt=function(e){function t(t){var n=this,r=t.channelUrl,i=t.channelType,a=t.metaCounter;return(n=e.call(this)||this).method=d.POST,n.path="".concat(h(i),"/").concat(encodeURIComponent(r),"/metacounter"),n.params={metacounter:a},n}return c(t,e),t}(p),Ut=function(e){function t(t,n){var r=e.call(this,t,n)||this;return r.metaCounter=n,r}return c(t,e),t}(f),It=function(e){function t(t){var n=this,r=t.channelUrl,i=t.channelType,a=t.metaCounter,s=t.upsert,o=void 0!==s&&s,u=t.mode,l=void 0===u?"set":u;return(n=e.call(this)||this).method=d.PUT,n.path="".concat(h(i),"/").concat(encodeURIComponent(r),"/metacounter"),n.params={metacounter:a,upsert:o,mode:l},n}return c(t,e),t}(p),wt=function(e){function t(t,n){var r=e.call(this,t,n)||this;return r.metaCounter=n,r}return c(t,e),t}(f),Mt=function(e){function t(t,n,r){var i=e.call(this,t,"SYEV",r)||this;return i.created=null,i.updated=null,i.deleted=null,r.data&&(i.created=r.data.created,i.updated=r.data.updated,i.deleted=r.data.deleted),i}return c(t,e),t}(T),Et=function(e){function t(t){var n=this,r=t.channelUrl,i=t.channelType,a=t.key;return(n=e.call(this)||this).method=d.DELETE,n.path="".concat(h(i),"/").concat(encodeURIComponent(r),"/metacounter/").concat(a),n.params=null,n}return c(t,e),t}(p);!function(e){function t(t,n){return e.call(this,t,n)||this}c(t,e)}(f);var bt=function(e){function t(t){var n=this,r=t.channelUrl,i=t.channelType;return(n=e.call(this)||this).method=d.DELETE,n.path="".concat(h(i),"/").concat(encodeURIComponent(r),"/metacounter"),n.params=null,n}return c(t,e),t}(p);!function(e){function t(){return null!==e&&e.apply(this,arguments)||this}c(t,e)}(f);var St=function(e){function t(t){var n=this,r=t.channelUrl,i=t.channelType,a=t.userId,s=t.seconds,o=t.description;return(n=e.call(this)||this).method=d.POST,n.path="".concat(h(i),"/").concat(encodeURIComponent(r),"/mute"),n.params={user_id:a,seconds:s,description:o},n}return c(t,e),t}(p);!function(e){function t(t,n){return e.call(this,t,n)||this}c(t,e)}(f);var Pt=function(e){function t(t,n,r){var i=e.call(this,t,"SYEV",r)||this;return i.user=new Ge(t,r.data),i}return c(t,e),t}(T),Ct=function(e){function t(t){var n=this,r=t.channelUrl,i=t.channelType,a=t.userId;return(n=e.call(this)||this).method=d.DELETE,n.path="".concat(h(i),"/").concat(encodeURIComponent(r),"/mute/").concat(encodeURIComponent(a)),n}return c(t,e),t}(p);!function(e){function t(){return null!==e&&e.apply(this,arguments)||this}c(t,e)}(f);var At=function(e){function t(t,n,r){var i=e.call(this,t,"SYEV",r)||this;return i.user=new Ge(t,r.data),i}return c(t,e),t}(T),Dt=function(e){function t(t){var n=this,r=t.channelUrl,i=t.channelType,a=t.userId,s=t.seconds,u=t.description;return(n=e.call(this)||this).method=d.POST,n.path="".concat(h(i),"/").concat(encodeURIComponent(r),"/ban"),n.params=o({user_id:a,seconds:s,description:u}),n}return c(t,e),t}(p);!function(e){function t(){return null!==e&&e.apply(this,arguments)||this}c(t,e)}(f);var qt=function(e){function t(t,n,r){var i=e.call(this,t,"SYEV",r)||this;return i.memberCount=null,i.joinedMemberCount=null,i.user=new Ge(t,r.data),r.data.member_count&&(i.memberCount=r.data.member_count),r.data.joined_member_count&&(i.joinedMemberCount=r.data.joined_member_count),i}return c(t,e),t}(T),Rt=function(e){function t(t){var n=this,r=t.channelUrl,i=t.channelType,a=t.userId;return(n=e.call(this)||this).method=d.DELETE,n.path="".concat(h(i),"/").concat(encodeURIComponent(r),"/ban/").concat(encodeURIComponent(a)),n}return c(t,e),t}(p);!function(e){function t(){return null!==e&&e.apply(this,arguments)||this}c(t,e)}(f);var Lt=function(e){function t(t,n,r){var i=e.call(this,t,"SYEV",r)||this;return i.user=new Ge(t,r.data),i}return c(t,e),t}(T),Ot=function(e){function t(t){var n=this,r=t.channelUrl,i=t.channelType,a=t.freezing;return(n=e.call(this)||this).method=d.PUT,n.path="".concat(h(i),"/").concat(encodeURIComponent(r),"/freeze"),n.params={freeze:a},n}return c(t,e),t}(p);!function(e){function t(){return null!==e&&e.apply(this,arguments)||this}c(t,e)}(f);var Nt=function(e){function t(t,n,r){var i=e.call(this,t,"SYEV",r)||this;return i.freeze=r.data.freeze,i}return c(t,e),t}(T),Ft=function(e){function t(t){var n=this,r=t.channelUrl,i=t.channelType,a=t.category,s=t.userId,o=t.description;return(n=e.call(this)||this).method=d.POST,n.path="".concat(U(i),"/").concat(encodeURIComponent(r)),n.params={report_category:a,reporting_user_id:s,report_description:o},n}return c(t,e),t}(p),kt=function(e){function t(t){var n=this,r=t.channelUrl,i=t.channelType,a=t.category,s=t.userId,o=t.offendingUserId,u=t.description;return(n=e.call(this)||this).method=d.POST,n.path="".concat(I,"/users/").concat(o),n.params={channel_url:r,channel_type:i===w.OPEN?"open_channels":"group_channels",report_category:a,reporting_user_id:s,report_description:u},n}return c(t,e),t}(p),Qt=function(e){function t(t){var n=this,r=t.channelUrl,i=t.channelType,a=t.category,s=t.userId,o=t.offendingUserId,u=t.messageId,l=t.description;return(n=e.call(this)||this).method=d.POST,n.path="".concat(U(i),"/").concat(encodeURIComponent(r),"/messages/").concat(u),n.params={report_category:a,reporting_user_id:s,report_description:l,offending_user_id:o},n}return c(t,e),t}(p),zt=function(t){function n(n){var r=[];return n.mentionType===e.USERS&&(n.mentionedUserIds?r=n.mentionedUserIds:n.mentionedUsers&&(r=n.mentionedUsers.map((function(e){return e.userId})))),t.call(this,{code:"MESG",ackRequired:!0,payload:o({channel_url:n.channelUrl,message:n.message,data:n.data,custom_type:n.customType,metaarray:n.metaArrays,mention_type:n.mentionType,mentioned_user_ids:r,mentioned_message_template:n.mentionedMessageTemplate,target_langs:n.translationTargetLanguages,push_option:n.pushNotificationDeliveryOption&&n.pushNotificationDeliveryOption!==a.DEFAULT?n.pushNotificationDeliveryOption:void 0,apple_critical_alert_options:n.appleCriticalAlertOptions,silent:n.silent,reply_to_channel:n.isReplyToChannel,parent_message_id:n.parentMessageId>0?n.parentMessageId:null,req_id:n.reqId,poll_id:n.pollId,pin_message:n.isPinnedMessage})})||this}return c(n,t),n}(M),xt=function(e){function t(t,n,r){var i,a,s,o=this;(o=e.call(this,t,"MESG",r)||this).message=new $(t,r);var u=_.of(t).sdkState;return o.isMentioned=E(o.message.mentionType,null!==(i=o.message.mentionedUserIds)&&void 0!==i?i:null===(a=o.message.mentionedUsers)||void 0===a?void 0:a.map((function(e){return e.userId})),u.userId),o.forceUpdateLastMessage=null!==(s=r.force_update_last_message)&&void 0!==s&&s,o}return c(t,e),t}(T),Gt=function(t){function n(n){var r,i=null;return n.mentionType===e.USERS&&(n.mentionedUserIds?i=n.mentionedUserIds:n.mentionedUsers&&(i=n.mentionedUsers.map((function(e){return e.userId})))),t.call(this,{code:"MEDI",ackRequired:!0,payload:o({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:i,mentioned_message_template:n.mentionedMessageTemplate,apple_critical_alert_options:null===(r=n.appleCriticalAlertOptions)||void 0===r?void 0:r.serialize(),poll_id:n.pollId})})||this}return c(n,t),n}(M),Vt=function(e){function t(t,n,r){var i,a,s,o,u,l,c=this;(c=e.call(this,t,"MEDI",r)||this).message=new $(t,r);var d=_.of(t).sdkState;return c.mentionCountChange=b({mentionType:null!==(a=null===(i=r.old_values)||void 0===i?void 0:i.mention_type)&&void 0!==a?a:null,mentionedUserIds:null!==(o=null===(s=r.old_values)||void 0===s?void 0:s.mentioned_user_ids)&&void 0!==o?o:[]},{mentionType:c.message.mentionType,mentionedUserIds:null!==(u=c.message.mentionedUserIds)&&void 0!==u?u:null===(l=c.message.mentionedUsers)||void 0===l?void 0:l.map((function(e){return e.userId}))},d.userId),c}return c(t,e),t}(T),jt=function(t){function n(n){var r=null;return n.mentionType===e.USERS&&(n.mentionedUserIds?r=n.mentionedUserIds:n.mentionedUsers&&(r=n.mentionedUsers.map((function(e){return e.userId})))),t.call(this,{code:"FEDI",ackRequired:!0,payload:o({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:r,apple_critical_alert_options:n.appleCriticalAlertOptions})})||this}return c(n,t),n}(M),Bt=function(e){function t(t,n,r){var i,a,s,o,u,l,c=this;(c=e.call(this,t,"FEDI",r)||this).message=new X(t,r);var d=_.of(t).sdkState;return c.mentionCountChange=b({mentionType:null!==(a=null===(i=r.old_values)||void 0===i?void 0:i.mention_type)&&void 0!==a?a:null,mentionedUserIds:null!==(o=null===(s=r.old_values)||void 0===s?void 0:s.mentioned_user_ids)&&void 0!==o?o:[]},{mentionType:c.message.mentionType,mentionedUserIds:null!==(u=c.message.mentionedUserIds)&&void 0!==u?u:null===(l=c.message.mentionedUsers)||void 0===l?void 0:l.map((function(e){return e.userId}))},d.userId),c}return c(t,e),t}(T),Wt=function(e){function t(t){var n=e.call(this)||this;return n.method=d.DELETE,n.path="".concat(h(t.channelType),"/").concat(t.channelUrl,"/messages/").concat(t.messageId),n}return c(t,e),t}(p);!function(e){function t(){return null!==e&&e.apply(this,arguments)||this}c(t,e)}(f);var Kt=function(e){function t(t,n,r){var i=e.call(this,t,"DELM",r)||this;return i.channelUrl=r.channel_url,i.channelType=r.channel_type,i.messageId=Number(r.msg_id),i}return c(t,e),t}(T),Ht=function(e){function t(t){var n=t.channelType,r=t.channelUrl,i=t.messageId,a=t.reactionKey,s=e.call(this)||this;return s.method=d.POST,s.path="".concat(h(n),"/").concat(encodeURIComponent(r),"/messages/").concat(i,"/reactions"),s.params={reaction:a},s}return c(t,e),t}(p),Yt=function(e){function t(t,n){var r=e.call(this,t,n)||this;return r.reactionEvent=new Z(n),r}return c(t,e),t}(f),Jt=function(e){function t(t){var n=t.channelType,r=t.channelUrl,i=t.messageId,a=t.reactionKey,s=e.call(this)||this;return s.method=d.DELETE,s.path="".concat(h(n),"/").concat(encodeURIComponent(r),"/messages/").concat(i,"/reactions"),s.params={reaction:a},s}return c(t,e),t}(p),$t=function(e){function t(t,n){var r=e.call(this,t,n)||this;return r.reactionEvent=new Z(s({},n)),r}return c(t,e),t}(f),Xt=function(e){function t(t){var n=t.channelType,r=t.channelUrl,i=t.messageId,a=t.translationTargetLanguages,s=e.call(this)||this;return s.method=d.POST,s.path="".concat(h(n),"/").concat(encodeURIComponent(r),"/messages/").concat(encodeURIComponent(i),"/translation"),s.params={target_langs:a},s}return c(t,e),t}(p),Zt=function(e){function t(t,n){var r=e.call(this,t,n)||this;return r.message=new $(t,n),r}return c(t,e),t}(f),en=function(t){function n(n){var r,i=this;i=t.call(this)||this;var a=[];n.mentionType===e.USERS&&(n.mentionedUserIds?a=n.mentionedUserIds:n.mentionedUsers&&(a=n.mentionedUsers.map((function(e){return e.userId}))));var s=n.channelType,o=n.channelUrl;return i.method=d.POST,i.path="".concat(h(s),"/").concat(encodeURIComponent(o),"/scheduled_messages"),i.params={req_id:n.reqId,scheduled_at:n.scheduledAt,message_type:S.USER,message:n.message,custom_type:n.customType,data:n.data,mention_type:n.mentionType,mentioned_user_ids:a,sorted_metaarray:null===(r=n.metaArrays)||void 0===r?void 0:r.map((function(e){return Y.payloadify(e)})),apple_critical_alert_options:J.payloadify(n.appleCriticalAlertOptions),target_langs:n.translationTargetLanguages,push_option:n.pushNotificationDeliveryOption},i}return c(n,t),n}(p),tn=function(e){function t(t,n){var r=e.call(this,t,n)||this;return r.message=new $(t,n),r}return c(t,e),t}(f),nn=function(t){function n(n){var r,i=this;i=t.call(this)||this;var a=[];n.mentionType===e.USERS&&(n.mentionedUserIds?a=n.mentionedUserIds:n.mentionedUsers&&(a=n.mentionedUsers.map((function(e){return e.userId}))));var s=n.channelType,o=n.channelUrl;return i.method=d.POST,i.path="".concat(h(s),"/").concat(encodeURIComponent(o),"/scheduled_messages"),i.params={req_id:n.reqId,scheduled_at:n.scheduledAt,message_type:S.FILE,url:n.fileUrl,file_name:n.fileName,file_size:n.fileSize,file_type:n.mimeType,thumbnails:n.thumbnailSizes?n.thumbnailSizes.map((function(e){return ee.payloadify(e)})):[],custom_type:n.customType,data:n.data,require_auth:n.requireAuth,mention_type:n.mentionType,mentioned_user_ids:a,sorted_metaarray:null===(r=n.metaArrays)||void 0===r?void 0:r.map((function(e){return Y.payloadify(e)})),apple_critical_alert_options:J.payloadify(n.appleCriticalAlertOptions),push_option:n.pushNotificationDeliveryOption},i}return c(n,t),n}(p),rn=function(e){function t(t,n){var r=e.call(this,t,n)||this;return r.message=new X(t,n),r}return c(t,e),t}(f),an=function(e){function t(t){var n=t.pollId,r=t.title,i=t.data,a=t.allowUserSuggestion,s=t.allowMultipleVotes,o=t.closeAt,u=e.call(this)||this;return u.method=d.PUT,u.path="".concat(C,"/").concat(encodeURIComponent(n)),u.params={title:r,data:i,allow_user_suggestion:a,allow_multiple_votes:s,close_at:o},u}return c(t,e),t}(p),sn=function(e){function t(t,n){var r=e.call(this,t,n)||this;return r.poll=new A(t,n),r}return c(t,e),t}(f),on=function(e){function t(t){var n=t.pollId,r=e.call(this)||this;return r.method=d.DELETE,r.path="".concat(C,"/").concat(encodeURIComponent(n)),r}return c(t,e),t}(p);!function(e){function t(){return null!==e&&e.apply(this,arguments)||this}c(t,e)}(f);var un=function(e){function t(t){var n=t.pollId,r=e.call(this)||this;return r.method=d.PUT,r.path="".concat(C,"/").concat(encodeURIComponent(n),"/close"),r}return c(t,e),t}(p),ln=function(e){function t(t,n){var r=e.call(this,t,n)||this;return r.poll=new A(t,n),r}return c(t,e),t}(f),cn=function(e){function t(t){var n=t.channelUrl,r=t.channelType,i=t.pollId,a=t.optionText,s=e.call(this)||this;return s.method=d.POST,s.path="".concat(C,"/").concat(encodeURIComponent(i),"/options"),s.params={channel_url:n,channel_type:r,text:a},s}return c(t,e),t}(p),dn=function(e){function t(t,n){var r=e.call(this,t,n)||this;return r.poll=new A(t,n),r}return c(t,e),t}(f),hn=function(e){function t(t){var n=t.pollId,r=t.pollOptionId,i=t.optionText,a=e.call(this)||this;return a.method=d.PUT,a.path="".concat(C,"/").concat(encodeURIComponent(n),"/options/").concat(encodeURIComponent(r)),a.params={text:i},a}return c(t,e),t}(p),pn=function(e){function t(t,n){var r=e.call(this,t,n)||this;return r.poll=new A(t,n),r}return c(t,e),t}(f),fn=function(e){function t(t){var n=t.pollId,r=t.pollOptionId,i=e.call(this)||this;return i.method=d.DELETE,i.path="".concat(C,"/").concat(encodeURIComponent(n),"/options/").concat(encodeURIComponent(r)),i}return c(t,e),t}(p);!function(e){function t(){return null!==e&&e.apply(this,arguments)||this}c(t,e)}(f);var mn=function(e){function t(t){var n=t.reqId,r=t.channelType,i=t.channelUrl,a=t.pollId,s=t.pollOptionIds;return e.call(this,{code:"VOTE",ackRequired:!0,payload:o({req_id:n,channel_type:r===w.OPEN?"open_channels":"group_channels",channel_url:i,poll_id:a,option_ids:s})})||this}return c(t,e),t}(M),vn=function(e){function t(t,n,r){var i=e.call(this,t,"VOTE",r)||this;return i.event=null,i.channelUrl=null,i.channelType=null,i.event=new pe(r),i.channelUrl=r.channel_url,i.channelType=r.channel_type,i}return c(t,e),t}(T),yn=2,gn=function(e){function d(n,r){var a,s,o,u,l=this;return(l=e.call(this,n)||this).url="",l.channelType=w.BASE,l.name="",l.coverUrl="",l.customType="",l.data="",l.isFrozen=!1,l.isEphemeral=!1,l.creator=null,l.createdAt=0,l._messageCollectionLastAccessedAt=0,l.url=r.channel_url,l.name=null!==(a=r.name)&&void 0!==a?a:"",l.coverUrl=null!==(s=r.cover_url)&&void 0!==s?s:"",l.customType=null!==(o=r.custom_type)&&void 0!==o?o:"",l.data=null!==(u=r.data)&&void 0!==u?u:"",l.isFrozen=!!t("boolean",r.freeze)&&r.freeze,l.isEphemeral=!!t("boolean",r.is_ephemeral)&&r.is_ephemeral,l.creator=r.created_by?new i(l._iid,r.created_by):null,l.createdAt=1e3*r.created_at,r.metadata&&Object.keys(r.metadata).length>0&&r.ts&&(l._cachedMetaData=new Map,Object.keys(r.metadata).forEach((function(e){l._cachedMetaData.set(e,{value:r.metadata[e],isRemoved:!1,updatedAt:r.ts})}))),l}return c(d,e),d.payloadify=function(t){return o(s(s({},e.payloadify.call(this,t)),{channel_url:t.url,name:t.name,cover_url:t.coverUrl,custom_type:t.customType,data:t.data,freeze:t.isFrozen,is_ephemeral:t.isEphemeral,created_by:i.payloadify(t.creator),created_at:t.createdAt/1e3}))},d.prototype.isGroupChannel=function(){return this.channelType===w.GROUP},d.prototype.isOpenChannel=function(){return this.channelType===w.OPEN},Object.defineProperty(d.prototype,"cachedMetaData",{get:function(){var e={};return this._cachedMetaData?(this._cachedMetaData.forEach((function(t,n){t.isRemoved||(e[n]=t.value)})),e):e},enumerable:!1,configurable:!0}),Object.defineProperty(d.prototype,"messageCollectionLastAccessedAt",{get:function(){return this._messageCollectionLastAccessedAt},enumerable:!1,configurable:!0}),d.prototype._updateMessageCollectionLastAccessedAt=function(){this._messageCollectionLastAccessedAt=Date.now()},d.prototype._update=function(e){var t=o(e);Object.assign(this,t)},d.prototype._upsertCachedMetaData=function(e,t){var n=this;Object.keys(e).forEach((function(r){n._cachedMetaData||(n._cachedMetaData=new Map);var i=n._cachedMetaData.get(r);(!i||i.updatedAt<=t)&&n._cachedMetaData.set(r,{value:e[r],isRemoved:!1,updatedAt:t})}))},d.prototype._removeFromCachedMetaData=function(e,t){var n=this;this._cachedMetaData&&e.forEach((function(e){var r=n._cachedMetaData.get(e);r&&r.updatedAt0&&r("string",t)).throw(g.invalidParameters),n=_.of(this._iid).requestQueue,i=new Xt({channelType:this.channelType,channelUrl:this.url,messageId:e.messageId,translationTargetLanguages:t}),[4,n.send(i)];case 1:return a=s.sent(),[2,a.as(Zt).message]}}))}))},d.prototype._createScheduledUserMessage=function(e,t){var n=this,r=_.of(this._iid).requestQueue,i=Date.now(),a=this._generateRequestId();k(2).then((function(){var r=n._createPendingScheduledUserMessage(e,a,i);x((function(){return m(n,void 0,void 0,(function(){return y(this,(function(e){return[2,t._trigger(null,r)]}))}))}))}));var o=new en(s({reqId:a,channelType:this.channelType,channelUrl:this.url},e));r.send(o).then((function(e){var r=e.as(tn).message;x((function(){return m(n,void 0,void 0,(function(){return y(this,(function(e){return[2,t._trigger(null,r)]}))}))}))})).catch((function(r){if(G(r))throw r;k(2).then((function(){var s=n._createPendingScheduledUserMessage(e,a,i);n._markMessageAsFailed(s,r),x((function(){return m(n,void 0,void 0,(function(){return y(this,(function(e){return[2,t._trigger(r,s)]}))}))}))}))}))},d.prototype.sendFileMessage=function(e){var t=s(s({},Oe),e);return F(Ne(t)).throw(g.invalidParameters),this._sendFileMessage(t)},d.prototype.sendMultipleFilesMessage=function(e){var t=s(s({},ke),e),n=_.of(this._iid);F(function(e,t){return void 0===t&&(t=l),Se(e)&&Array.isArray(e.fileInfoList)&&e.fileInfoList.length>=2&&e.fileInfoList.length<=t&&e.fileInfoList.every((function(e){return Qe(e)}))}(t,n.appInfo.multipleFilesMessageFileCountLimit)).throw(g.invalidParameters);var r=!!e.fileInfoList.find((function(e){var t=n.appInfo.uploadSizeLimit;return e.file instanceof Blob&&e.file.size>t||e.fileSize>t}));return F(!r).throw(g.fileSizeLimitExceededError),this._sendMultipleFilesMessage(t)},d.prototype._sendFileMessage=function(e,t){var n=this;void 0===t&&(t=null);var r=_.of(this._iid).dispatcher,i=ie.of(this._iid).fileMessageQueue,a=t,s=Date.now(),o=new se;return a||(a=this._generateRequestId(),k(2).then((function(){var t=n._createPendingFileMessage(e,a,s);r.dispatch(new Q({messages:[t],source:z.EVENT_MESSAGE_SENT_PENDING})),x((function(){return m(n,void 0,void 0,(function(){return y(this,(function(e){return[2,o._trigger(null,t)]}))}))})),i.request(n,a,e).then((function(e){r.dispatch(new Q({messages:[e],source:z.EVENT_MESSAGE_SENT_SUCCESS})),x((function(){return m(n,void 0,void 0,(function(){return y(this,(function(t){return[2,o._trigger(null,e)]}))}))}))})).catch((function(t){if(G(t))throw t;k(2).then((function(){var i=n._createPendingFileMessage(e,a,s),u=_.of(n._iid).cacheContext.localCacheEnabled&&V(t.code);n._markMessageAsFailed(i,t,u),r.dispatch(new Q({messages:[i],source:i.sendingStatus===R.PENDING?z.REQUEST_RESEND_MESSAGE:z.EVENT_MESSAGE_SENT_FAILED})),x((function(){return m(n,void 0,void 0,(function(){return y(this,(function(e){return[2,o._trigger(t,i)]}))}))}))}))}))}))),o},d.prototype._autoResendFileMessage=function(e){F(e instanceof X).throw(g.invalidParameters);var t=_.of(this._iid).logger;return t.debug("autoResendFileMessage pending",e),this._sendFileMessage(e.messageParams,e.reqId).onFailed((function(e){t.debug("autoResendFileMessage failed",e)})).onSucceeded((function(e){t.debug("autoResendFileMessage success",e)}))},d.prototype._sendMultipleFilesMessage=function(e,t){var n=this;void 0===t&&(t=null);var r=_.of(this._iid).dispatcher,i=ie.of(this._iid).fileMessageQueue,a=t,s=Date.now(),o=new ae;return a||(a=this._generateRequestId(),k(2).then((function(){var t=n._createPendingMultipleFilesMessage(e,a,s);r.dispatch(new Q({messages:[t],source:z.EVENT_MESSAGE_SENT_PENDING})),x((function(){return m(n,void 0,void 0,(function(){return y(this,(function(e){return[2,o._trigger(null,t)]}))}))})),i.request(n,a,e,o).then((function(e){r.dispatch(new Q({messages:[e],source:z.EVENT_MESSAGE_SENT_SUCCESS})),x((function(){return m(n,void 0,void 0,(function(){return y(this,(function(t){return[2,o._trigger(null,e)]}))}))}))})).catch((function(t){if(G(t))throw t;k(2).then((function(){var i=n._createPendingMultipleFilesMessage(e,a,s);n._markMessageAsFailed(i,t),r.dispatch(new Q({messages:[i],source:z.EVENT_MESSAGE_SENT_FAILED})),x((function(){return m(n,void 0,void 0,(function(){return y(this,(function(e){return[2,o._trigger(t,i)]}))}))}))}))}))}))),o},d.prototype._createScheduledFileMessage=function(e,t,n,r){var i=this,a=_.of(this._iid).requestQueue,o=new nn(s(s({reqId:n,channelType:this.channelType,channelUrl:this.url},e),{fileUrl:e.fileUrl,requireAuth:e.requireAuth}));a.send(o).then((function(e){var n=e.as(rn).message;x((function(){return m(i,void 0,void 0,(function(){return y(this,(function(e){return[2,t._trigger(null,n)]}))}))}))})).catch((function(a){if(G(a))throw a;k(2).then((function(){var s=i._createPendingScheduledFileMessage(e,n,r);i._markMessageAsFailed(s,a),x((function(){return m(i,void 0,void 0,(function(){return y(this,(function(e){return[2,t._trigger(a,s)]}))}))}))}))}))},d.prototype.sendFileMessages=function(e){var t,n;F(e.every((function(e){return Ne(s(s({},Oe),e))}))).throw(g.invalidParameters);var r=new se;try{for(var i=L(e),a=i.next();!a.done;a=i.next()){var o=a.value;this.sendFileMessage(o).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{a&&!a.done&&(n=i.return)&&n.call(i)}finally{if(t)throw t.error}}return r},d.prototype.resendFileMessage=function(e,t){var n;return m(this,void 0,void 0,(function(){var r,i,a;return y(this,(function(s){return r=Boolean(e.url)||u(t)||u(null===(n=e.messageParams)||void 0===n?void 0:n.file),F(e instanceof X&&r&&!e.scheduledInfo).throw(g.invalidParameters),i=new K,a=function(e,t){var n,r;return void 0===t&&(t=null),e.messageParams?(!e.url&&u(t)&&(e.messageParams.file=t),e.messageParams):o({data:e.data,customType:e.customType,mentionType:e.mentionType,mentionedUsers:e.mentionedUsers,mentionedUserIds:e.mentionedUserIds,metaArrays:e.metaArrays,parentMessageId:e.parentMessageId,appleCriticalAlertOptions:e.appleCriticalAlertOptions,file:null!=t?t:null===(n=e.messageParams)||void 0===n?void 0:n.file,fileUrl:e.url,fileName:e.name,fileSize:e.size,mimeType:e.type,thumbnailSizes:null===(r=e.thumbnails)||void 0===r?void 0:r.map((function(e){return{maxWidth:e.width,maxHeight:e.height}}))})}(e,t),this._sendFileMessage(a,e.reqId).onFailed((function(e){return i.reject(e)})).onSucceeded((function(e){return i.resolve(e)})),[2,i.promise]}))}))},d.prototype.updateFileMessage=function(e,n){return m(this,void 0,void 0,(function(){var r,i,a,o;return y(this,(function(u){switch(u.label){case 0:return r=s(s({},Ke),n),F(t("number",e)&&function(e){return je(e)}(r)).throw(g.invalidParameters),i=_.of(this._iid).requestQueue,a=new jt(s({channelType:this.channelType,channelUrl:this.url,messageId:e},r)),[4,i.send(a)];case 1:return o=u.sent(),[2,o.as(Bt).message]}}))}))},d.prototype.cancelUploadingFileMessage=function(e){return m(this,void 0,void 0,(function(){return y(this,(function(n){return F(t("string",e)).throw(g.invalidParameters),ie.of(this._iid).fileMessageQueue.cancel(this,e),[2,!0]}))}))},d.prototype.copyFileMessage=function(e,t){var n,r,i;return m(this,void 0,void 0,(function(){var o,u;return y(this,(function(l){return F(e instanceof d&&t instanceof X&&t.sendingStatus===R.SUCCEEDED&&this.url===t.channelUrl&&!t.scheduledInfo).throw(g.invalidParameters),o=new K,u=s(s({},t),{fileUrl:t.url,fileName:t.name,fileSize:t.size,mimeType:t.type,mentionType:t.mentionType,mentionedUserIds:null!==(n=t.mentionedUserIds)&&void 0!==n?n:null===(r=t.mentionedUsers)||void 0===r?void 0:r.map((function(e){return e.userId})),pushNotificationDeliveryOption:a.DEFAULT,parentMessageId:null,isReplyToChannel:!1,thumbnailSizes:null===(i=t.thumbnails)||void 0===i?void 0:i.map((function(e){return{maxWidth:e.width,maxHeight:e.height}})),requireAuth:t.requireAuth,isPinnedMessage:!1}),e._sendFileMessage(u).onSucceeded((function(e){return o.resolve(e)})).onFailed((function(e){return o.reject(e)})),[2,o.promise]}))}))},d.prototype.deleteMessage=function(e){return m(this,void 0,void 0,(function(){var t,n;return y(this,(function(r){switch(r.label){case 0:return F(e instanceof de).throw(g.invalidParameters),e.messageId>0?(t=_.of(this._iid).requestQueue,n=new Wt({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]}}))}))},d.prototype.addReaction=function(e,n){return m(this,void 0,void 0,(function(){var r,i,a;return y(this,(function(s){switch(s.label){case 0:return F(e instanceof de&&e.messageId>0&&t("string",n)).throw(g.invalidParameters),r=_.of(this._iid).requestQueue,i=new Ht({channelType:this.channelType,channelUrl:this.url,messageId:e.messageId,reactionKey:n}),[4,r.send(i)];case 1:return a=s.sent(),[2,a.as(Yt).reactionEvent]}}))}))},d.prototype.deleteReaction=function(e,n){return m(this,void 0,void 0,(function(){var r,i,a;return y(this,(function(s){switch(s.label){case 0:return F(e instanceof de&&e.messageId>0&&t("string",n)).throw(g.invalidParameters),r=_.of(this._iid).requestQueue,i=new Jt({channelType:this.channelType,channelUrl:this.url,messageId:e.messageId,reactionKey:n}),[4,r.send(i)];case 1:return a=s.sent(),[2,a.as($t).reactionEvent]}}))}))},d.prototype._updateUserMessageMetaArray=function(e,t,n,r){return m(this,void 0,void 0,(function(){var i,a,s,o,u,l;return y(this,(function(c){switch(c.label){case 0:return i=_.of(this._iid),a=i.dispatcher,s=i.requestQueue,o=new Gt({channelType:this.channelType,channelUrl:this.url,messageId:e,metaArrayParams:{array:t,mode:n,upsert:r}}),[4,s.send(o)];case 1:return u=c.sent(),l=u.as(Vt).message,a.dispatch(new Q({messages:[l],source:z.EVENT_MESSAGE_UPDATED})),[2,l]}}))}))},d.prototype._updateFileMessageMetaArray=function(e,t,n,r){return m(this,void 0,void 0,(function(){var i,a,s,o,u,l;return y(this,(function(c){switch(c.label){case 0:return i=_.of(this._iid),a=i.dispatcher,s=i.requestQueue,o=new jt({channelType:this.channelType,channelUrl:this.url,messageId:e,metaArrayParams:{array:t,mode:n,upsert:r}}),[4,s.send(o)];case 1:return u=c.sent(),l=u.as(Bt).message,a.dispatch(new Q({messages:[l],source:z.EVENT_MESSAGE_UPDATED})),[2,l]}}))}))},d.prototype.createMessageMetaArrayKeys=function(e,t){return m(this,void 0,void 0,(function(){var n;return y(this,(function(i){return F(e instanceof de&&e.messageId>0&&r("string",t)).throw(g.invalidParameters),n=t.map((function(e){return new Y({key:e})})),e instanceof X?[2,this._updateFileMessageMetaArray(e.messageId,n,"add",!0)]:[2,this._updateUserMessageMetaArray(e.messageId,n,"add",!0)]}))}))},d.prototype.deleteMessageMetaArrayKeys=function(e,t){return m(this,void 0,void 0,(function(){var n;return y(this,(function(i){return F(e instanceof de&&e.messageId>0&&r("string",t)).throw(g.invalidParameters),n=t.map((function(e){return new Y({key:e})})),e instanceof X?[2,this._updateFileMessageMetaArray(e.messageId,n,"remove",!0)]:[2,this._updateUserMessageMetaArray(e.messageId,n,"remove",!0)]}))}))},d.prototype.addMessageMetaArrayValues=function(e,t){return m(this,void 0,void 0,(function(){return y(this,(function(n){return F(e instanceof de&&e.messageId>0&&t.every((function(e){return e instanceof Y}))).throw(g.invalidParameters),e instanceof X?[2,this._updateFileMessageMetaArray(e.messageId,t,"add",!0)]:[2,this._updateUserMessageMetaArray(e.messageId,t,"add",!0)]}))}))},d.prototype.removeMessageMetaArrayValues=function(e,t){return m(this,void 0,void 0,(function(){return y(this,(function(n){return F(e instanceof de&&e.messageId>0&&t.every((function(e){return e instanceof Y}))).throw(g.invalidParameters),e instanceof X?[2,this._updateFileMessageMetaArray(e.messageId,t,"remove",!0)]:[2,this._updateUserMessageMetaArray(e.messageId,t,"remove",!0)]}))}))},d.prototype.report=function(e,r){return m(this,void 0,void 0,(function(){var i,a,s,o;return y(this,(function(u){switch(u.label){case 0:return F(n(ze,e)&&t("string",r)).throw(g.invalidParameters),i=_.of(this._iid),a=i.sdkState,s=i.requestQueue,o=new Ft({channelUrl:this.url,channelType:this.channelType,userId:a.userId,category:e,description:r}),[4,s.send(o)];case 1:return u.sent(),[2]}}))}))},d.prototype.reportUser=function(e,r,a){return m(this,void 0,void 0,(function(){var s,o,u,l;return y(this,(function(c){switch(c.label){case 0:return F(e instanceof i&&n(ze,r)&&t("string",a)).throw(g.invalidParameters),s=_.of(this._iid),o=s.sdkState,u=s.requestQueue,l=new kt({channelUrl:this.url,channelType:this.channelType,userId:o.userId,offendingUserId:e.userId,category:r,description:a}),[4,u.send(l)];case 1:return c.sent(),[2]}}))}))},d.prototype.reportMessage=function(e,r,i){return m(this,void 0,void 0,(function(){var a,s,o,u;return y(this,(function(l){switch(l.label){case 0:return F(e instanceof he&&n(ze,r)&&t("string",i)).throw(g.invalidParameters),a=_.of(this._iid),s=a.sdkState,o=a.requestQueue,u=new Qt({channelUrl:this.url,channelType:this.channelType,userId:s.userId,offendingUserId:e.sender.userId,messageId:e.messageId,category:r,description:i}),[4,o.send(u)];case 1:return l.sent(),[2]}}))}))},d.prototype.updatePoll=function(e,n){return m(this,void 0,void 0,(function(){var r,i,a;return y(this,(function(o){switch(o.label){case 0:return F(t("number",e)&&function(e){return t("string",e.title,!0)&&P(e.data)&&t("boolean",e.allowUserSuggestion,!0)&&t("boolean",e.allowMultipleVotes,!0)&&t("number",e.closeAt,!0)}(n)).throw(g.invalidParameters),r=_.of(this._iid).requestQueue,i=new an(s({pollId:e},n)),[4,r.send(i)];case 1:return a=o.sent(),[2,a.as(sn).poll]}}))}))},d.prototype.deletePoll=function(e){return m(this,void 0,void 0,(function(){var n,r,i;return y(this,(function(a){switch(a.label){case 0:return n=t("number",e),F(n).throw(g.invalidParameters),r=_.of(this._iid).requestQueue,i=new on({pollId:e}),[4,r.send(i)];case 1:return a.sent(),[2]}}))}))},d.prototype.closePoll=function(e){return m(this,void 0,void 0,(function(){var n,r,i,a;return y(this,(function(s){switch(s.label){case 0:return n=t("number",e),F(n).throw(g.invalidParameters),r=_.of(this._iid).requestQueue,i=new un({pollId:e}),[4,r.send(i)];case 1:return a=s.sent(),[2,a.as(ln).poll]}}))}))},d.prototype.addPollOption=function(e,n){return m(this,void 0,void 0,(function(){var r,i,a,s;return y(this,(function(o){switch(o.label){case 0:return r=t("number",e)&&t("string",n)&&""!==n.trim(),F(r).throw(g.invalidParameters),i=_.of(this._iid).requestQueue,a=new cn({channelUrl:this.url,channelType:this.channelType,pollId:e,optionText:n}),[4,i.send(a)];case 1:return s=o.sent(),[2,s.as(dn).poll]}}))}))},d.prototype.updatePollOption=function(e,n,r){return m(this,void 0,void 0,(function(){var i,a,s,o;return y(this,(function(u){switch(u.label){case 0:return i=t("number",e)&&t("number",n)&&t("string",r)&&""!==r.trim(),F(i).throw(g.invalidParameters),a=_.of(this._iid).requestQueue,s=new hn({pollId:e,pollOptionId:n,optionText:r}),[4,a.send(s)];case 1:return o=u.sent(),[2,o.as(pn).poll]}}))}))},d.prototype.deletePollOption=function(e,n){return m(this,void 0,void 0,(function(){var r,i,a;return y(this,(function(s){switch(s.label){case 0:return r=t("number",e)&&t("number",n),F(r).throw(g.invalidParameters),i=_.of(this._iid).requestQueue,a=new fn({pollId:e,pollOptionId:n}),[4,i.send(a)];case 1:return s.sent(),[2]}}))}))},d.prototype.votePoll=function(e,n){return m(this,void 0,void 0,(function(){var i,a,s,o,u,l,c;return y(this,(function(d){switch(d.label){case 0:return i=t("number",e)&&r("number",n),F(i).throw(g.invalidParameters),a=_.of(this._iid),s=a.requestQueue,o=a.dispatcher,u=new mn({reqId:this._generateRequestId(),channelUrl:this.url,channelType:this.channelType,pollId:e,pollOptionIds:n}),[4,s.send(u)];case 1:return l=d.sent(),c=l.as(vn).event,o.dispatch(new H({event:c,source:z.EVENT_POLL_VOTED})),[2,c]}}))}))},d.prototype.getPollChangeLogsSinceTimestamp=function(e){return m(this,void 0,void 0,(function(){return y(this,(function(n){switch(n.label){case 0:return F(t("number",e)).throw(g.invalidParameters),[4,ve.of(this._iid).getPollChangeLogs(this.url,this.channelType,e)];case 1:return[2,n.sent()]}}))}))},d.prototype.getPollChangeLogsSinceToken=function(e){return m(this,void 0,void 0,(function(){return y(this,(function(n){switch(n.label){case 0:return F(t("string",e,!0)),[4,ve.of(this._iid).getPollChangeLogs(this.url,this.channelType,e)];case 1:return[2,n.sent()]}}))}))},d.prototype.createPollListQuery=function(e){return void 0===e&&(e=10),new fe(this._iid,{channelUrl:this.url,channelType:this.channelType,limit:e})},d.prototype.createPollVoterListQuery=function(e,t,n){return void 0===n&&(n=20),new me(this._iid,{channelUrl:this.url,channelType:this.channelType,pollId:e,pollOptionId:t,limit:n})},d}(j);export{Vt as A,nt as B,Bt as C,Ue as D,xt as E,ye as F,Ve as G,je as H,Be as I,We as J,tn as K,yn as L,Ze as M,_e as N,Je as O,vn as P,ze as R,Ce as U,Te as a,Ie as b,we as c,Me as d,Ee as e,gn as f,Ge as g,xe as h,De as i,be as j,Le as k,Se as l,Fe as m,Re as n,qe as o,ge as p,Mt as q,pt as r,Pe as s,Nt as t,Lt as u,Ae as v,qt as w,Pt as x,At as y,Kt as z}; diff --git a/lib/__bundle-fd51cf65.js b/lib/__bundle-fd51cf65.js new file mode 100644 index 0000000..5eafa66 --- /dev/null +++ b/lib/__bundle-fd51cf65.js @@ -0,0 +1 @@ +import{a7 as e,a2 as t,ag as n,b as r,K as i,c as s,g as a,a as o,i as c,_ as u,S as l,a0 as h,t as d,aq as f,a5 as _,ar as v,x as p,y as m,ad as y,aj as b,ai as E,U as g,W as N,r as I,s as w,as as A,at as T}from"./__bundle-75942676.js";import{U as O,s as C,v as S,j as L,k,l as R,m as x,n as D,F as P,o as M,b as B,D as H}from"./__bundle-e875840b.js";import{S as U,U as V,F as K,b as q,c as F}from"./__bundle-84f74e8d.js";var j,G,z;!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"}(j||(j={})),function(e){e.CHRONOLOGICAL="chronological",e.CHANNEL_NAME_ALPHABETICAL="channel_name_alphabetical",e.METADATA_VALUE_ALPHABETICAL="metadata_value_alphabetical"}(G||(G={})),function(e){e.CREATED_AT="created_at",e.SCHEDULED_AT="scheduled_at"}(z||(z={}));var W,Y=function(e){switch(e){case j.LATEST_LAST_MESSAGE:return["-lastMessageUpdatedAt","-createdAt","syncIndex"];case j.CHRONOLOGICAL:return["-createdAt","syncIndex"];case j.CHANNEL_NAME_ALPHABETICAL:return["name"];default:return["-lastMessageUpdatedAt","-createdAt","syncIndex"]}},Q=function(){function r(){this.messageTypeFilter=e.ALL,this.customTypesFilter=null,this.senderUserIdsFilter=null,this.replyType=n.NONE}return r.prototype.clone=function(){var e=new r,t=JSON.parse(JSON.stringify(this));return Object.keys(t).forEach((function(n){e[n]=t[n]})),e},r.prototype.match=function(r){switch(this.messageTypeFilter){case e.USER:if(r.messageType!==t.USER)return!1;break;case e.FILE:if(r.messageType!==t.FILE)return!1;break;case e.ADMIN:if(r.messageType!==t.ADMIN)return!1}if(this.customTypesFilter&&this.customTypesFilter.length>0&&!this.customTypesFilter.includes(r.customType))return!1;if(this.senderUserIdsFilter&&this.senderUserIdsFilter.length>0){if(!(r instanceof U))return!1;if(!this.senderUserIdsFilter.includes(r.sender.userId))return!1}switch(this.replyType){case n.NONE:if(r.parentMessageId>0)return!1;break;case n.ONLY_REPLY_TO_CHANNEL:if(r instanceof U&&r.parentMessageId>0&&!r.replyToChannel)return!1}return!0},r}();!function(e){e.CHANNEL_LATEST="channel_latest",e.NEWEST_CHILD_MESSAGE="newest_child_message"}(W||(W={}));var J,Z,X=function(e){switch(e){case W.CHANNEL_LATEST:return["channelUrl","-createdAt","-messageId"];case W.NEWEST_CHILD_MESSAGE:return["channelUrl","-parentMessageId","-createdAt","-messageId"]}},$=function(){return"undefined"!=typeof document&&"undefined"!=typeof navigator&&"ReactNative"!==navigator.product},ee=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"}(J||(J={})),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"}(Z||(Z={}));var te,ne={},re=function(){function e(e,t){void 0===t&&(t={});var n=this;return this._state=J.PROCESSING,this._queue=[],this._activationQueue=[],ne[e]&&!t.forceCreate||(this.nodeId=ee(),this.key=e,$()&&(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,s=e.data,a=s.nodeId,o=s.requestId,c=s.key,u=s.op,l=s.data;if(a!==n.nodeId&&c===n.key)switch(u){case Z.NEWNODE:n._sendSync();break;case Z.CLAIM_HOST:n._sendSync(),n._hostId=a;break;case Z.SYNC_HOST:if(!n.isInSync){n._activationTimeout&&clearTimeout(n._activationTimeout);var h=l,d=h.currentItemRequestId,f=h.queue,_=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:Z.REQUEST_LOCK,ts:e.ts})};try{for(var v=i(f),p=v.next();!p.done;p=v.next()){_(p.value)}}catch(e){t={error:e}}finally{try{p&&!p.done&&(r=v.return)&&r.call(v)}finally{if(t)throw t.error}}n._currentItem=n._queue.find((function(e){return e.requestId===d})),n._completeSync()}break;case Z.REMOVENODE:n._queue=n._queue.filter((function(e){return e.nodeId!==s.nodeId})),n._currentItem&&n._currentItem.nodeId===s.nodeId&&(n._currentItem=void 0,n._acquire(n._queue[0]));break;case Z.REQUEST_LOCK:n._requestLock(s);break;case Z.ACQUIRE_LOCK:var m=n._queue.find((function(e){return e.requestId===o}));n._acquire(m);break;case Z.RELEASE_LOCK:n._release(o)}})),window.addEventListener("beforeunload",(function(){n._send(Z.REMOVENODE)}))),ne[e]=this),ne[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==J.DONE},enumerable:!1,configurable:!0}),e.prototype._send=function(e,t){var n;void 0===t&&(t={});var r={nodeId:this.nodeId,requestId:null!==(n=null==t?void 0:t.requestId)&&void 0!==n?n:ee(),key:this.key,op:e,data:t.data,ts:Date.now()};return $()&&window.postMessage(r,"*"),r},e.prototype._acquire=function(e){e?(this._currentItem=e,this._currentItem.onAcquired&&this._currentItem.onAcquired(e.requestId)):this._currentItem=void 0},e.prototype._release=function(e){if(this._currentItem&&this._currentItem.requestId===e){var t=this._currentItem;this._currentItem=void 0,t.nodeId===this.nodeId&&this._send(Z.RELEASE_LOCK,{requestId:t.requestId});var n=this._queue.findIndex((function(t){return t.requestId===e}));n>-1&&this._queue.splice(n,1),t.onReleased&&t.onReleased(e)}},e.prototype._requestLock=function(e){var t=this;return new Promise((function(n){var r={nodeId:e.nodeId,requestId:e.requestId,ts:e.ts,onAcquired:function(e){t.isHost&&t._send(Z.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(Z.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 r(this,void 0,void 0,(function(){var e=this;return s(this,(function(t){return this.isHost&&!this.isInSync?[2,new Promise((function(t){e._activationQueue.push(t)}))]:[2]}))}))},e.prototype._waitSync=function(){var e=this;this.isInSync||(this._activationTimeout=setTimeout((function(){e._completeSync()}),8))},e.prototype._completeSync=function(){this.isInSync||(this._state=J.DONE,this._activationQueue.forEach((function(e){return e()})),this._activationQueue=[])},e.prototype.registerNode=function(){this._send(Z.NEWNODE),this._waitSync()},e.prototype.claimHost=function(){this._hostId=this.nodeId,this._send(Z.CLAIM_HOST),this._waitSync()},e.prototype.lock=function(){return r(this,void 0,void 0,(function(){var e;return s(this,(function(t){switch(t.label){case 0:return[4,this._waitUntilSyncCompleted()];case 1:return t.sent(),e=this._send(Z.REQUEST_LOCK),[4,this._requestLock(e)];case 2:return t.sent(),[2]}}))}))},e.prototype.unlock=function(){var e;(null===(e=this._currentItem)||void 0===e?void 0:e.requestId)&&this._release(this._currentItem.requestId)},e}(),ie=a(a({},O),{scheduledAt:void 0}),se=function(e){return S(e)&&o("number",e.scheduledAt,!0)},ae=a(a({},L),{scheduledAt:0,file:void 0,fileUrl:void 0,fileName:void 0,mimeType:void 0,fileSize:void 0,thumbnailSizes:void 0,requireAuth:!1}),oe=function(e){return R(e)&&o("number",e.scheduledAt)&&(c(e.file)||o("string",e.fileUrl))&&o("string",e.fileName,!0)&&o("string",e.mimeType,!0)&&o("number",e.fileSize,!0)&&(null===e.thumbnailSizes||void 0===e.thumbnailSizes||e.thumbnailSizes.every((function(e){return o("object",e)&&e.maxWidth>0&&e.maxHeight>0})))},ce="UnsentMessage",ue="reqId",le={},he=function(e){function t(t,n){var r=n.sdkState,i=n.cacheContext,s=e.call(this,t)||this;return s._sdkState=r,s._cacheContext=i,le[t]=s,s._mutex=new re("unsendmessagecache.lock"),s}return u(t,e),t.of=function(e){return le[e]},Object.defineProperty(t.prototype,"collection",{get:function(){var e=this._cacheContext.nestdb,t=null==e?void 0:e.collection(ce);if(!t)throw l.databaseError;return t},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"localCacheEnabled",{get:function(){return this._cacheContext.localCacheEnabled&&!!this.collection},enumerable:!1,configurable:!0}),t.prototype._serialize=function(e){if(e.messageId>0)throw l.invalidParameters;var t,n=a({},e.serialize());return e instanceof V?(e.messageParams&&(n.messageParams=C(e.messageParams)),e.scheduledInfo&&e.scheduledInfo.scheduledMessageParams&&(n.scheduledInfo.scheduledMessageParams=(t=e.scheduledInfo.scheduledMessageParams,a(a({},C(t)),{scheduledAt:t.scheduledAt})))):e instanceof K?(e.messageParams&&(n.messageParams=k(e.messageParams)),e.scheduledInfo&&e.scheduledInfo.scheduledMessageParams&&(n.scheduledInfo.scheduledMessageParams=function(e){return a(a({},k(e)),{scheduledAt:e.scheduledAt})}(e.scheduledInfo.scheduledMessageParams))):e instanceof q&&e.messageParams&&(n.messageParams=x(e.messageParams)),n},t.prototype._deserialize=function(e){return e=a(a({},e),{messageId:parseInt(e.messageId)}),F.of(this._iid).buildMessageFromSerializedData(e)},t.prototype._deserializeWithMessageCreateParams=function(e){var t,n,i;return r(this,void 0,void 0,(function(){var a,o,c,u,l,h,d=this;return s(this,(function(f){switch(f.label){case 0:return a=F.of(this._iid),o=this._deserialize(e),e.messageParams?o instanceof V?(u=e.messageParams,o.messageParams=a.buildUserMessageCreateParamsFromSerializedData(u,o),[3,6]):[3,1]:[3,6];case 1:return o instanceof K?(u=e.messageParams).fileKey&&"string"==typeof u.fileKey&&D(null!==(t=u.fileType)&&void 0!==t?t:"")?(c=u,[4,this.collection.getBlob(u.fileKey)]):[3,3]:[3,4];case 2:c.file=null!==(n=f.sent())&&void 0!==n?n:void 0,f.label=3;case 3:return o.messageParams=a.buildFileMessageCreateParamsFromSerializedData(u,o),[3,6];case 4:return o instanceof q&&((u=e.messageParams)&&u.fileInfoList)?(o.messageParams=a.buildMultipleFilesMessageCreateParamsFromSerializedData(u,o),[4,Promise.all(o.messageParams.fileInfoList.map((function(e){return r(d,void 0,void 0,(function(){var t,n,r,i,a;return s(this,(function(s){switch(s.label){case 0:return"string"==typeof(null===(n=e._uploadedMetaData)||void 0===n?void 0:n.fileKey)&&D(null!==(i=null===(r=e._uploadedMetaData)||void 0===r?void 0:r.fileType)&&void 0!==i?i:"")?(t=e,[4,this.collection.getBlob(e._uploadedMetaData.fileKey)]):[3,2];case 1:t.file=null!==(a=s.sent())&&void 0!==a?a:void 0,s.label=2;case 2:return[2]}}))}))})))]):[3,6];case 5:f.sent(),f.label=6;case 6:return o.scheduledInfo&&e.scheduledInfo&&e.scheduledInfo.scheduledMessageParams?o instanceof V?(l=e.scheduledInfo.scheduledMessageParams,o.scheduledInfo.scheduledMessageParams=a.buildScheduledUserMessageCreateParamsFromSerializedData(l,o),[3,10]):[3,7]:[3,10];case 7:return o instanceof K?(l=e.scheduledInfo.scheduledMessageParams).fileKey&&"string"==typeof l.fileKey&&"string"==typeof l.fileType&&D(l.fileType)?(h=l,[4,this.collection.getBlob(l.fileKey)]):[3,9]:[3,10];case 8:h.file=null!==(i=f.sent())&&void 0!==i?i:void 0,f.label=9;case 9:o.scheduledInfo.scheduledMessageParams=a.buildScheduledFileMessageCreateParamsFromSerializedData(l,o),f.label=10;case 10:return[2,o]}}))}))},t.prototype._getFileInfoBlobKey=function(e,t){return"".concat(e,".").concat(t)},t.prototype.get=function(e){return r(this,void 0,void 0,(function(){var t;return s(this,(function(n){switch(n.label){case 0:return this.localCacheEnabled?[4,this.collection.getByKey("".concat(e))]:[3,2];case 1:if(t=n.sent())return[2,this._deserializeWithMessageCreateParams(t)];n.label=2;case 2:return[2,void 0]}}))}))},t.prototype.fetch=function(e){var t=e.channelUrl,n=e.filter,i=void 0===n?new Q:n,a=e.order,o=void 0===a?W.CHANNEL_LATEST:a,c=e.sendingStatus,u=e.backward,l=void 0!==u&&u,h=e.parentMessageId;return r(this,void 0,void 0,(function(){var e,n,a,u,d=this;return s(this,(function(f){switch(f.label){case 0:return this.localCacheEnabled?(e=X(o),n={"/where":function(e){return!!(o!==W.NEWEST_CHILD_MESSAGE||h&&0!==e.parentMessageId&&e.parentMessageId===h)&&i.match(d._deserialize(e))}},t&&(n.channelUrl=t),c&&(n.sendingStatus=c),a={where:n,index:e,backward:l},[4,this.collection.query(a)]):[3,3];case 1:return[4,f.sent().fetch({})];case 2:return u=f.sent(),[2,Promise.all(u.map((function(e){return r(d,void 0,void 0,(function(){return s(this,(function(t){switch(t.label){case 0:return[4,this._deserializeWithMessageCreateParams(e)];case 1:return[2,t.sent()]}}))}))})))];case 3:return[2,[]]}}))}))},t.prototype.getAllChildMessages=function(e,t){return void 0===t&&(t=new Q),r(this,void 0,void 0,(function(){return s(this,(function(n){switch(n.label){case 0:return[4,this.fetch({filter:t,order:W.NEWEST_CHILD_MESSAGE,channelUrl:e.channelUrl,backward:!1,parentMessageId:e.messageId})];case 1:return[2,n.sent()]}}))}))},t.prototype.upsert=function(e){return r(this,void 0,void 0,(function(){var t=this;return s(this,(function(n){switch(n.label){case 0:return this.localCacheEnabled?[4,Promise.all(e.map((function(e){return r(t,void 0,void 0,(function(){var t;return s(this,(function(n){switch(n.label){case 0:return e instanceof K||e instanceof q?[4,this._mutex.lock()]:[3,4];case 1:return n.sent(),[4,this.saveBlob(e)];case 2:return n.sent(),[4,this._mutex.unlock()];case 3:n.sent(),n.label=4;case 4:return t=this._serialize(e),[4,this.collection.upsertOne(t)];case 5:return n.sent(),[2]}}))}))})))]:[3,2];case 1:n.sent(),n.label=2;case 2:return[2]}}))}))},t.prototype.upsertChildMessages=function(e){return r(this,void 0,void 0,(function(){var t=this;return s(this,(function(n){switch(n.label){case 0:return this.localCacheEnabled?[4,Promise.all(e.map((function(e){return r(t,void 0,void 0,(function(){var t;return s(this,(function(n){switch(n.label){case 0:return t=[],e.threadInfo&&e.threadInfo.replyCount>0?[4,this.getAllChildMessages(e)]:[3,2];case 1:t=n.sent(),n.label=2;case 2:return t.length>0?(t.forEach((function(t){return t.applyParentMessage(e)})),[4,this.upsert(t)]):[3,4];case 3:n.sent(),n.label=4;case 4:return[2]}}))}))})))]:[3,2];case 1:n.sent(),n.label=2;case 2:return[2]}}))}))},t.prototype.remove=function(e){return r(this,void 0,void 0,(function(){var t,n,r,a,o,c;return s(this,(function(s){switch(s.label){case 0:if(!this.localCacheEnabled)return[3,8];s.label=1;case 1:s.trys.push([1,6,7,8]),t=i(e),n=t.next(),s.label=2;case 2:return n.done?[3,5]:(r=n.value,[4,this.collection.remove(r)]);case 3:s.sent(),s.label=4;case 4:return n=t.next(),[3,2];case 5:return[3,8];case 6:return a=s.sent(),o={error:a},[3,8];case 7:try{n&&!n.done&&(c=t.return)&&c.call(t)}finally{if(o)throw o.error}return[7];case 8:return[2]}}))}))},t.prototype.removeMessagesOfChannel=function(e){return r(this,void 0,void 0,(function(){return s(this,(function(t){switch(t.label){case 0:return this.localCacheEnabled?[4,this.collection.removeIf({where:{channelUrl:e}})]:[3,2];case 1:t.sent(),t.label=2;case 2:return[2]}}))}))},t.prototype.clear=function(){return r(this,void 0,void 0,(function(){return s(this,(function(e){switch(e.label){case 0:return this.localCacheEnabled?[4,this.collection.clear()]:[3,2];case 1:e.sent(),e.label=2;case 2:return[2]}}))}))},t.prototype.saveBlob=function(e){return r(this,void 0,void 0,(function(){var t,n,i,a=this;return s(this,(function(o){switch(o.label){case 0:return e instanceof K?e.messageParams&&(i=e.messageParams).file&&M(i.file)?[4,this.collection.saveBlob(i.file,e.reqId)]:[3,2]:[3,5];case 1:n=o.sent(),i.fileKey=n,i.fileType=P.BLOB,o.label=2;case 2:return e.scheduledInfo&&e.scheduledInfo.scheduledMessageParams&&((t=e.scheduledInfo.scheduledMessageParams).file&&M(t.file))?[4,this.collection.saveBlob(t.file,e.reqId)]:[3,4];case 3:n=o.sent(),t.fileKey=n,t.fileType=P.BLOB,o.label=4;case 4:return[3,7];case 5:return e instanceof q&&((i=e.messageParams)&&i.fileInfoList&&Array.isArray(i.fileInfoList))?[4,Promise.all(i.fileInfoList.map((function(t,n){return r(a,void 0,void 0,(function(){var r;return s(this,(function(i){switch(i.label){case 0:return t.file&&M(t.file)?[4,this.collection.saveBlob(t.file,this._getFileInfoBlobKey(e.reqId,n))]:[3,2];case 1:r=i.sent(),t._uploadedMetaData||(t._uploadedMetaData={}),t._uploadedMetaData.fileKey=r,t._uploadedMetaData.fileType=P.BLOB,i.label=2;case 2:return[2]}}))}))})))]:[3,7];case 6:o.sent(),o.label=7;case 7:return[2]}}))}))},t}(h),de={},fe=function(e){function t(t,n){var r=n.sdkState,i=n.cacheContext,s=n.unsentMessageCache,a=e.call(this,t)||this;return a._sdkState=r,a._cacheContext=i,a._unsentMessageCache=s,de[t]=a,a}return u(t,e),t.of=function(e){return de[e]},Object.defineProperty(t.prototype,"collection",{get:function(){var e=this._cacheContext.nestdb;return d(!!e).throw(l.databaseError),e.collection(B)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"localCacheEnabled",{get:function(){return this._cacheContext.localCacheEnabled&&!!this.collection},enumerable:!1,configurable:!0}),t.prototype._serialize=function(e){return a(a({},e.serialize()),{messageId:"".concat(e.messageId)})},t.prototype._deserialize=function(e){return e=a(a({},e),{messageId:parseInt(e.messageId)}),F.of(this._iid).buildMessageFromSerializedData(e)},t.prototype.get=function(e){return r(this,void 0,void 0,(function(){var t;return s(this,(function(n){switch(n.label){case 0:return this.localCacheEnabled?[4,this.collection.getByKey("".concat(e))]:[3,2];case 1:if(t=n.sent())return[2,this._deserialize(t)];n.label=2;case 2:return[2,void 0]}}))}))},t.prototype.fetch=function(e){var t=e.channelUrl,n=e.token,i=e.limit,a=void 0===i?H:i,o=e.filter,c=void 0===o?new Q:o,u=e.order,l=void 0===u?W.CHANNEL_LATEST:u,h=e.backward,d=void 0!==h&&h,f=e.parentMessageId,_=e.isPollOnly,v=void 0!==_&&_;return r(this,void 0,void 0,(function(){var e,i,o,u=this;return s(this,(function(h){switch(h.label){case 0:return this.localCacheEnabled?(e=X(l),i={where:{channelUrl:t,"/where":function(e){if(n)switch(l){case W.CHANNEL_LATEST:if(!d&&e.createdAt>n||d&&e.createdAt0?[4,this.getAllChildMessages(e)]:[3,2];case 1:t=r.sent(),r.label=2;case 2:return t.length>0?(t.forEach((function(t){return t.applyParentMessage(e)})),[4,this.upsert(t)]):[3,4];case 3:r.sent(),r.label=4;case 4:return[2]}}))}))})))]:[3,2];case 1:n.sent(),n.label=2;case 2:return[2]}}))}))},t.prototype.remove=function(e){return r(this,void 0,void 0,(function(){var t,n,r,a,o,c;return s(this,(function(s){switch(s.label){case 0:if(!this.localCacheEnabled)return[3,8];s.label=1;case 1:s.trys.push([1,6,7,8]),t=i(e),n=t.next(),s.label=2;case 2:return n.done?[3,5]:(r=n.value,[4,this.collection.remove("".concat(r))]);case 3:s.sent(),s.label=4;case 4:return n=t.next(),[3,2];case 5:return[3,8];case 6:return a=s.sent(),o={error:a},[3,8];case 7:try{n&&!n.done&&(c=t.return)&&c.call(t)}finally{if(o)throw o.error}return[7];case 8:return[2]}}))}))},t.prototype.removeMessagesOfChannel=function(e){return r(this,void 0,void 0,(function(){var t;return s(this,(function(n){switch(n.label){case 0:return this.localCacheEnabled?[4,this.collection.removeIf({where:{channelUrl:e},index:X(W.CHANNEL_LATEST)})]:[3,6];case 1:return n.sent(),[4,(t=this._cacheContext.preference).remove("sendbird:".concat(this._sdkState.userId,"@groupchannel/").concat(e,"/message/sync"))];case 2:return n.sent(),[4,t.remove("sendbird:".concat(this._sdkState.userId,"@groupchannel/").concat(e,"/message/sync.meta"))];case 3:return n.sent(),[4,t.remove("sendbird:".concat(this._sdkState.userId,"@groupchannel/").concat(e,"/message/changelogs"))];case 4:return n.sent(),[4,t.remove("sendbird:".concat(this._sdkState.userId,"@groupchannel/").concat(e,"/message/changelogs.meta"))];case 5:n.sent(),n.label=6;case 6:return[2]}}))}))},t.prototype.removeUnderOffset=function(e,t){return r(this,void 0,void 0,(function(){return s(this,(function(n){switch(n.label){case 0:return this.localCacheEnabled?[4,this.collection.removeIf({where:{channelUrl:e,createdAt:{"<":t}},index:X(W.CHANNEL_LATEST)})]:[3,2];case 1:n.sent(),n.label=2;case 2:return[2]}}))}))},t.prototype.clear=function(){return r(this,void 0,void 0,(function(){return s(this,(function(e){switch(e.label){case 0:return this.localCacheEnabled?[4,this.collection.clear()]:[3,2];case 1:e.sent(),e.label=2;case 2:return[2]}}))}))},t.prototype.countBetween=function(e,t,n){return r(this,void 0,void 0,(function(){var r,i=this;return s(this,(function(s){switch(s.label){case 0:return this.localCacheEnabled?(r=X(W.CHANNEL_LATEST),[4,this.collection.query({where:{channelUrl:e,"/where":function(e){var r=i._deserialize(e);return n.includes(r.createdAt)&&t.match(r)}},index:r}).count()]):[3,2];case 1:return[2,s.sent()];case 2:return[2,0]}}))}))},t.prototype.saveBlobs=function(e){return r(this,void 0,void 0,(function(){var t=this;return s(this,(function(n){switch(n.label){case 0:return[4,Promise.all(e.map((function(e){return r(t,void 0,void 0,(function(){var t,n;return s(this,(function(r){switch(r.label){case 0:return e instanceof K&&e.messageParams&&((t=e.messageParams).file&&M(t.file))?[4,this.collection.saveBlob(t.file,e.reqId)]:[3,2];case 1:n=r.sent(),t.fileKey=n,r.label=2;case 2:return[2]}}))}))})))];case 1:return n.sent(),[2]}}))}))},t.prototype._getGroupChannelPreferenceSize=function(e){return r(this,void 0,void 0,(function(){var t,n,r,i,a,o;return s(this,(function(s){switch(s.label){case 0:return t=0,[4,(n=this._cacheContext.preference).get("sendbird:".concat(this._sdkState.userId,"@groupchannel/").concat(e,"/message/sync"))];case 1:return r=s.sent(),[4,n.get("sendbird:".concat(this._sdkState.userId,"@groupchannel/").concat(e,"/message/sync.meta"))];case 2:return i=s.sent(),[4,n.get("sendbird:".concat(this._sdkState.userId,"@groupchannel/").concat(e,"/message/changelogs"))];case 3:return a=s.sent(),[4,n.get("sendbird:".concat(this._sdkState.userId,"@groupchannel/").concat(e,"/message/changelogs.meta"))];case 4:return o=s.sent(),r&&(t+=JSON.stringify(r).length),i&&(t+=JSON.stringify(i).length),a&&(t+=JSON.stringify(a).length),o&&(t+=JSON.stringify(o).length),[2,t]}}))}))},t}(h),_e=function(e){function t(t){var n=t.message,r=e.call(this)||this;return r.message=n,r}return u(t,e),t}(f),ve={},pe=function(){function e(e,t){var n=t.localCacheEnabled,r=t.dispatcher,i=t.sdkState,s=t.logger,a=this;this._iid=e,ve[e]=this,this._localCacheEnabled=n,this._isProcessingAutoResend=!1,this._autoResendQueue=[],this._dispatcher=r,this._logger=s,this._sdkState=i,this._localCacheEnabled&&r.on((function(e){if(e instanceof p)switch(e.stateType){case m.CONNECTED:a._isProcessingAutoResend||a.processAutoResendRegisteredPendingMessages().then((function(){return a._processNextAutoResend()}));break;case m.INTERNAL_DISCONNECTED:case m.EXTERNAL_DISCONNECTED:a._isProcessingAutoResend=!1}}))}return e.of=function(e){return ve[e]},e.prototype.processNonAutoResendRegisteredPendingMessages=function(){return r(this,void 0,void 0,(function(){var e,t,n,r,a,o;return s(this,(function(s){switch(s.label){case 0:return[4,this._fetchAllCachedPendingMessages()];case 1:e=s.sent();try{for(t=i(e),n=t.next();!n.done;n=t.next())0===(r=n.value).errorCode&&(this._logger.debug("cached pending message is not auto-resend registered. changing its sending status to failed: ",r.reqId),r.sendingStatus=_.FAILED,r.errorCode=y.ACK_TIMEOUT,this._dispatcher.dispatch(new b({messages:[r],source:E.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.processAutoResendRegisteredPendingMessages=function(){return r(this,void 0,void 0,(function(){var e,t,n,r,a,o,c,u;return s(this,(function(s){switch(s.label){case 0:return[4,this._fetchAllCachedPendingMessages()];case 1:e=s.sent();try{for(t=i(e),n=t.next();!n.done;n=t.next())(r=n.value).errorCode&&v(r.errorCode)&&(a=(new Date).getTime(),o=r.createdAt+2592e5,a<=o?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(o).toLocaleString()),r.sendingStatus=_.FAILED,this._dispatcher.dispatch(new b({messages:[r],source:E.LOCAL_MESSAGE_FAILED}))))}catch(e){c={error:e}}finally{try{n&&!n.done&&(u=t.return)&&u.call(t)}finally{if(c)throw c.error}}return[2]}}))}))},e.prototype.completeCurrentAndProcessNextAutoResend=function(e){if(this._localCacheEnabled&&(e.sendingStatus===_.SUCCEEDED||e.sendingStatus===_.FAILED&&!v(e.errorCode))){var t=this.indexOf(e);t>=0&&this._autoResendQueue.splice(t,1),0===t&&this._processNextAutoResend()}},e.prototype._fetchAllCachedPendingMessages=function(){return r(this,void 0,void 0,(function(){var e,t;return s(this,(function(n){switch(n.label){case 0:return(e=he.of(this._iid))?[4,e.fetch({sendingStatus:_.PENDING,backward:!0})]:[3,2];case 1:return t=n.sent(),[3,3];case 2:t=[],n.label=3;case 3:return[2,t]}}))}))},e.prototype.indexOf=function(e){return this._autoResendQueue.length>0?this._autoResendQueue.map((function(e){return e.reqId})).indexOf(e.reqId):-1},e.prototype._isNotInQueue=function(e){return-1===this._autoResendQueue.map((function(e){return e.reqId})).indexOf(e.reqId)},e.prototype._processNextAutoResend=function(){return r(this,void 0,void 0,(function(){var e;return s(this,(function(t){if(this._localCacheEnabled&&"foreground"===this._sdkState.appState)try{this._autoResendQueue.length>0?(this._isProcessingAutoResend||(this._logger.debug("auto-resend queue started."),this._isProcessingAutoResend=!0),e=this._autoResendQueue[0],this._dispatcher.dispatch(new _e({message:e})),this._logger.debug("processing auto-resend for message request id: ",e.reqId)):(this._logger.debug("auto-resend queue finished."),this._isProcessingAutoResend=!1)}catch(e){this._logger.warn("process auto-resend error: ",e),this._isProcessingAutoResend=!1}return[2]}))}))},e}();!function(e){e[e.USER_BLOCK=20001]="USER_BLOCK",e[e.USER_UNBLOCK=2e4]="USER_UNBLOCK",e[e.FRIEND_DISCOVERED=20900]="FRIEND_DISCOVERED"}(te||(te={}));var me,ye=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,i=n.blockee;return{blocker:new g(e,r),blockee:new g(e,i)}},e.getDataAsFriendDiscoveredEvent=function(e,t){var n=t.data.friend_discoveries;return{friendDiscoveries:Array.isArray(n)?n.map((function(t){return new g(e,t)})):[]}},e}(),be=function(e){function t(t,n){var r=n.userId,i=e.call(this)||this;return i._iid=t,i.userId=r,i}return u(t,e),t}(f);!function(e){e.UNKNOWN="UNKNOWN",e.EVENT_CHANNEL_CREATED="EVENT_CHANNEL_CREATED",e.EVENT_CHANNEL_UPDATED="EVENT_CHANNEL_UPDATED",e.EVENT_CHANNEL_DELETED="EVENT_CHANNEL_DELETED",e.EVENT_CHANNEL_READ="EVENT_CHANNEL_READ",e.EVENT_CHANNEL_DELIVERED="EVENT_CHANNEL_DELIVERED",e.EVENT_CHANNEL_INVITED="EVENT_CHANNEL_INVITED",e.EVENT_CHANNEL_JOINED="EVENT_CHANNEL_JOINED",e.EVENT_CHANNEL_LEFT="EVENT_CHANNEL_LEFT",e.EVENT_CHANNEL_ACCEPTED_INVITE="EVENT_CHANNEL_ACCEPTED_INVITE",e.EVENT_CHANNEL_DECLINED_INVITE="EVENT_CHANNEL_DECLINED_INVITE",e.EVENT_CHANNEL_OPERATOR_UPDATED="EVENT_CHANNEL_OPERATOR_UPDATED",e.EVENT_CHANNEL_MUTED="EVENT_CHANNEL_MUTED",e.EVENT_CHANNEL_UNMUTED="EVENT_CHANNEL_UNMUTED",e.EVENT_CHANNEL_FROZEN="EVENT_CHANNEL_FROZEN",e.EVENT_CHANNEL_UNFROZEN="EVENT_CHANNEL_UNFROZEN",e.EVENT_CHANNEL_HIDDEN="EVENT_CHANNEL_HIDDEN",e.EVENT_CHANNEL_UNHIDDEN="EVENT_CHANNEL_UNHIDDEN",e.EVENT_CHANNEL_RESET_HISTORY="EVENT_CHANNEL_RESET_HISTORY",e.EVENT_CHANNEL_TYPING_STATUS_UPDATE="EVENT_CHANNEL_TYPING_STATUS_UPDATE",e.EVENT_CHANNEL_MEMBER_COUNT_UPDATED="EVENT_CHANNEL_MEMBER_COUNT_UPDATED",e.EVENT_MESSAGE_SENT="EVENT_MESSAGE_SENT",e.EVENT_MESSAGE_RECEIVED="EVENT_MESSAGE_RECEIVED",e.EVENT_MESSAGE_UPDATED="EVENT_MESSAGE_UPDATED",e.EVENT_PINNED_MESSAGE_UPDATED="EVENT_PINNED_MESSAGE_UPDATED",e.REQUEST_CHANNEL="REQUEST_CHANNEL",e.REQUEST_CHANNEL_CHANGELOGS="REQUEST_CHANNEL_CHANGELOGS",e.REFRESH_CHANNEL="REFRESH_CHANNEL",e.CHANNEL_LASTACCESSEDAT_UPDATED="CHANNEL_LASTACCESSEDAT_UPDATED",e.SYNC_CHANNEL_BACKGROUND="SYNC_CHANNEL_BACKGROUND",e.SYNC_CHANNEL_CHANGELOGS="SYNC_CHANNEL_CHANGELOGS"}(me||(me={}));var Ee,ge=function(e){return e.startsWith("EVENT_")||e===me.SYNC_CHANNEL_CHANGELOGS||e===me.REFRESH_CHANNEL},Ne=function(e){function t(t){var n=t.channels,r=t.source,i=t.isWebSocketEventComing,s=void 0!==i&&i,a=t.data,o=void 0===a?null:a,c=e.call(this)||this;return c.channels=n,c.source=r,c.isWebSocketEventComing=s,c.data=o,c}return u(t,e),t}(f),Ie=function(e){function t(t){var n=t.channelUrls,r=t.source,i=t.isWebSocketEventComing,s=void 0!==i&&i,a=e.call(this)||this;return a.channelUrls=n,a.source=r,a.isWebSocketEventComing=s,a}return u(t,e),t}(f),we=function(e){function t(){return e.call(this)||this}return u(t,e),t}(f),Ae=function(e){function t(t,n,r){var i=e.call(this,t,"USEV",r)||this;return i.event=new ye(r),i}return u(t,e),t}(N),Te={},Oe=function(){function e(e){var t=e.dbname,n=e.itemSizeLimit,r=void 0===n?1048576:n,i=e.cacheLimit,s=void 0===i?256:i,a=e.blockHashBase,o=void 0===a?2:a,c=e.blockHashMultiplier,u=void 0===c?10:c,l=e.blockHashConstant,h=void 0===l?11:l,d=e.transactionApplyDelay,f=void 0===d?200:d,_=e.disableLogger,v=void 0!==_&&_;return Te[t]||(this.itemSizeLimit=r,this.cacheLimit=s,this.blockHashBase=o,this.blockHashMultiplier=u,this.blockHashConstant=h,this.transactionApplyDelay=f,this.disableLogger=v,Te[t]=this),Te[t]}return e.get=function(e){return Te[e]},e}();!function(e){e[e.UNKNOWN_ERROR=6e7]="UNKNOWN_ERROR",e[e.STORE_NOT_DEFINED=61001e3]="STORE_NOT_DEFINED",e[e.STORE_NOT_AVAILABLE=61001001]="STORE_NOT_AVAILABLE",e[e.STORE_NOT_AVAILABLE_IN_PRIVATE_BROWSING=61001002]="STORE_NOT_AVAILABLE_IN_PRIVATE_BROWSING",e[e.STORE_IS_FULL=61001003]="STORE_IS_FULL",e[e.STORE_NOT_INITIALIZED=61001004]="STORE_NOT_INITIALIZED",e[e.STORE_INVALID_KEY_TYPE=61002e3]="STORE_INVALID_KEY_TYPE",e[e.STORE_BROKEN_INTEGRITY=61002001]="STORE_BROKEN_INTEGRITY",e[e.STORE_BROKEN_BLOB=61002002]="STORE_BROKEN_BLOB",e[e.STORE_ENCRYPTION_INVALID=61002003]="STORE_ENCRYPTION_INVALID",e[e.STORE_ITEM_SIZE_LIMIT_EXCEEDED=61017e3]="STORE_ITEM_SIZE_LIMIT_EXCEEDED",e[e.STORE_READ_FAILED=61017001]="STORE_READ_FAILED",e[e.STORE_WRITE_FAILED=61017002]="STORE_WRITE_FAILED",e[e.DATABASE_SCHEMA_NOT_ON_UPGRADE=62002e3]="DATABASE_SCHEMA_NOT_ON_UPGRADE",e[e.COLLECTION_NOT_READY=63001e3]="COLLECTION_NOT_READY",e[e.COLLECTION_KEY_NOT_MATCH=63002e3]="COLLECTION_KEY_NOT_MATCH",e[e.COLLECTION_QUERY_NOT_VALID=63002001]="COLLECTION_QUERY_NOT_VALID",e[e.COLLECTION_KEY_NOT_FOUND=63004e3]="COLLECTION_KEY_NOT_FOUND",e[e.COLLECTION_KEY_NOT_GIVEN=63004001]="COLLECTION_KEY_NOT_GIVEN",e[e.COLLECTION_INSERT_DUPLICATE=63009e3]="COLLECTION_INSERT_DUPLICATE",e[e.COLLECTION_WRITE_FAILED=63017e3]="COLLECTION_WRITE_FAILED",e[e.COLLECTION_ITEM_SIZE_LIMIT_EXCEEDED=63017001]="COLLECTION_ITEM_SIZE_LIMIT_EXCEEDED",e[e.INDEX_TABLE_IS_REQUIRED=65001e3]="INDEX_TABLE_IS_REQUIRED",e[e.INDEX_TYPE_NOT_MATCH=65002e3]="INDEX_TYPE_NOT_MATCH",e[e.COMPARE_TYPE_NOT_MATCH=69002001]="COMPARE_TYPE_NOT_MATCH",e[e.CIRCULAR_REFERENCE_FOUND=69002002]="CIRCULAR_REFERENCE_FOUND"}(Ee||(Ee={}));var Ce,Se=function(e){function t(n){var r=n.code,i=void 0===r?Ee.UNKNOWN_ERROR:r,s=n.message,a=void 0===s?"Unknown error occurred.":s,o=e.call(this,a)||this;return o.code=i,Object.setPrototypeOf(o,t.prototype),o}return u(t,e),Object.defineProperty(t,"storeNotDefined",{get:function(){return new t({code:Ee.STORE_NOT_DEFINED,message:"Store is not defined. Specify the store on NestDB()"})},enumerable:!1,configurable:!0}),Object.defineProperty(t,"storeNotAvailable",{get:function(){return new t({code:Ee.STORE_NOT_AVAILABLE,message:"Store is not available. Check your environment settings."})},enumerable:!1,configurable:!0}),Object.defineProperty(t,"storeNotAvailableInPrivateBrowsing",{get:function(){return new t({code:Ee.STORE_NOT_AVAILABLE_IN_PRIVATE_BROWSING,message:"Store is not available because it is in private browsing."})},enumerable:!1,configurable:!0}),Object.defineProperty(t,"storeIsFull",{get:function(){return new t({code:Ee.STORE_IS_FULL,message:"Store is full."})},enumerable:!1,configurable:!0}),Object.defineProperty(t,"storeNotInitialized",{get:function(){return new t({code:Ee.STORE_NOT_INITIALIZED,message:"Store is not initialized."})},enumerable:!1,configurable:!0}),Object.defineProperty(t,"storeKeyTypeIsInvalid",{get:function(){return new t({code:Ee.STORE_INVALID_KEY_TYPE,message:"Store key should be string type."})},enumerable:!1,configurable:!0}),Object.defineProperty(t,"storeBrokenIntegrity",{get:function(){return new t({code:Ee.STORE_BROKEN_INTEGRITY,message:"Data should be in a store but it does not. Integrity is broken."})},enumerable:!1,configurable:!0}),Object.defineProperty(t,"storeBrokenBlob",{get:function(){return new t({code:Ee.STORE_BROKEN_BLOB,message:"Data should be in a store but it does not. Blob data is broken."})},enumerable:!1,configurable:!0}),Object.defineProperty(t,"storeEncryptionInvalid",{get:function(){return new t({code:Ee.STORE_ENCRYPTION_INVALID,message:"Encryption algorithm has changed. All the store should reset."})},enumerable:!1,configurable:!0}),Object.defineProperty(t,"storeItemSizeExceeded",{get:function(){return new t({code:Ee.STORE_ITEM_SIZE_LIMIT_EXCEEDED,message:"The size of the item exceeds the limit that the store allows."})},enumerable:!1,configurable:!0}),Object.defineProperty(t,"storeReadFailed",{get:function(){return new t({code:Ee.STORE_READ_FAILED,message:"Failed to read from store."})},enumerable:!1,configurable:!0}),Object.defineProperty(t,"storeWriteFailed",{get:function(){return new t({code:Ee.STORE_WRITE_FAILED,message:"Failed to write to store."})},enumerable:!1,configurable:!0}),Object.defineProperty(t,"databaseSchemaNotOnUpgrade",{get:function(){return new t({code:Ee.DATABASE_SCHEMA_NOT_ON_UPGRADE,message:"Committing schema is not allowed when upgrade is not running."})},enumerable:!1,configurable:!0}),Object.defineProperty(t,"collectionNotReady",{get:function(){return new t({code:Ee.COLLECTION_NOT_READY,message:"Collection is not ready due to an error during initialization."})},enumerable:!1,configurable:!0}),Object.defineProperty(t,"collectionKeyNotMatch",{get:function(){return new t({code:Ee.COLLECTION_KEY_NOT_MATCH,message:"keyName of collection could not change."})},enumerable:!1,configurable:!0}),Object.defineProperty(t,"collectionQueryNotValid",{get:function(){return new t({code:Ee.COLLECTION_QUERY_NOT_VALID,message:"Query parameter is not a valid format."})},enumerable:!1,configurable:!0}),Object.defineProperty(t,"collectionInsertDuplicate",{get:function(){return new t({code:Ee.COLLECTION_INSERT_DUPLICATE,message:"The key already exists."})},enumerable:!1,configurable:!0}),Object.defineProperty(t,"collectionKeyNotFound",{get:function(){return new t({code:Ee.COLLECTION_KEY_NOT_FOUND,message:"The key is not found."})},enumerable:!1,configurable:!0}),Object.defineProperty(t,"collectionKeyNotGiven",{get:function(){return new t({code:Ee.COLLECTION_KEY_NOT_GIVEN,message:"The item should contain [keyName] property."})},enumerable:!1,configurable:!0}),Object.defineProperty(t,"collectionWriteFailed",{get:function(){return new t({code:Ee.COLLECTION_WRITE_FAILED,message:"Failed to write an item."})},enumerable:!1,configurable:!0}),Object.defineProperty(t,"collectionItemSizeExceeded",{get:function(){return new t({code:Ee.COLLECTION_ITEM_SIZE_LIMIT_EXCEEDED,message:"The size of the item exceeds the limit that a collection allows."})},enumerable:!1,configurable:!0}),Object.defineProperty(t,"indexTableIsRequired",{get:function(){return new t({code:Ee.INDEX_TABLE_IS_REQUIRED,message:"Index table is required."})},enumerable:!1,configurable:!0}),Object.defineProperty(t,"indexTypesNotMatch",{get:function(){return new t({code:Ee.INDEX_TYPE_NOT_MATCH,message:"Indexed column should have primitive type."})},enumerable:!1,configurable:!0}),Object.defineProperty(t,"compareTypesNotMatch",{get:function(){return new t({code:Ee.COMPARE_TYPE_NOT_MATCH,message:"Values to compare have different types."})},enumerable:!1,configurable:!0}),Object.defineProperty(t,"circularReferenceFound",{get:function(){return new t({code:Ee.CIRCULAR_REFERENCE_FOUND,message:"Cannot handle circular referenced object."})},enumerable:!1,configurable:!0}),t}(Error);!function(e){e.INIT="init",e.READY="ready",e.CLOSED="closed"}(Ce||(Ce={}));var Le,ke=function(e,t){if(void 0===t&&(t=new WeakMap),"object"==typeof e&&null!==e){if(t.has(e))throw Se.circularReferenceFound;t.set(e,!0);var n=void 0;if(Array.isArray(e))n=e.map((function(e){return ke(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]=ke(e[r],t);return t.delete(e),n}return e},Re=function(e,t){if(null==t)return 1;if(null==e)return-1;if(typeof e!=typeof t)throw Se.compareTypesNotMatch;var n=0;switch(typeof e){case"boolean":case"number":n=e-t;break;case"string":n=e.localeCompare(t)}return n},xe=function(e,t){for(var n=0,r=0;r>>0)%t},De=function(e){return new Promise((function(t){setTimeout((function(){return t()}),e)}))},Pe=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!Pe(e,t)})))return!1}else if(["/or","||"].includes(n)){if(e[n].every((function(e){return!Pe(e,t)})))return!1}else if("/where"===n){if(!(0,e[n])(t))return!1}else{var r=n;if("object"==typeof e[r]){var i=e[r];for(var s in i)switch(s){case"/eq":case"=":if((a=t[r])!==(o=i[s]))return!1;break;case"/neq":case"!=":if((a=t[r])===(o=i[s]))return!1;break;case"/gt":case">":var a=t[r],o=i[s];if(!(Re(a,o)>0))return!1;break;case"/gte":case">=":a=t[r],o=i[s];if(!(Re(a,o)>=0))return!1;break;case"/lt":case"<":a=t[r],o=i[s];if(!(Re(a,o)<0))return!1;break;case"/lte":case"<=":a=t[r],o=i[s];if(!(Re(a,o)<=0))return!1;break;case"/in":a=t[r];if(!(o=i[s]).includes(a))return!1;break;case"/nin":a=t[r];if((o=i[s]).includes(a))return!1;break;case"/contain":a=t[r],o=i[s];if(!a.includes(o))return!1;break;case"/regex":a=t[r];if(!(o=i[s]).test(a))return!1;break;case"/where":a=t[r];if(!(0,i[s])(a))return!1}}else if("function"==typeof e[r]){if(!e[r](t[r]))return!1}else if(e[r]!==t[r])return!1}}return!0}return e(t)},Me=function(){},Be=function(){return Promise.resolve()},He=function(e){return e},Ue=function(e,t){t()};!function(e){e[e.FORWARD=0]="FORWARD",e[e.BACKWARD=1]="BACKWARD"}(Le||(Le={}));var Ve,Ke,qe,Fe=function(){function e(e){var t=e.initialPrevValue,n=void 0===t?null:t,r=e.initialNextValue,i=void 0===r?null:r,s=e.iterator,a=e.map,o=void 0===a?He:a,c=e.backward,u=void 0===c?Be:c,l=e.forward,h=void 0===l?Be:l,d=e.complete,f=void 0===d?Me:d;this._prevValue=n,this._nextValue=i,this._error=null,this._map=o,this._backward=u,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 r(this,void 0,void 0,(function(){var e,t,n;return s(this,(function(r){switch(r.label){case 0:if(!this.hasPrevious)return[3,6];r.label=1;case 1:return r.trys.push([1,3,,4]),e=this._prevValue,t=this,[4,this._backward()];case 2:return t._prevValue=r.sent()||null,this._nextValue=e,[3,4];case 3:return n=r.sent(),this._error=n,[3,4];case 4:return[4,this._iterator(this)];case 5:return[2,r.sent()];case 6:this._complete(),r.label=7;case 7:return[2]}}))}))},e.prototype.next=function(){return r(this,void 0,void 0,(function(){var e,t,n;return s(this,(function(r){switch(r.label){case 0:if(!this.hasNext)return[3,6];r.label=1;case 1:return r.trys.push([1,3,,4]),e=this._nextValue,t=this,[4,this._forward()];case 2:return t._nextValue=r.sent()||null,this._prevValue=e,[3,4];case 3:return n=r.sent(),this._error=n,[3,4];case 4:return[4,this._iterator(this)];case 5:return[2,r.sent()];case 6:this._complete(),r.label=7;case 7:return[2]}}))}))},e.prototype.stop=function(){this._prevValue=null,this._nextValue=null,this._complete()},e}(),je=function(){function e(e){var t=e.condition,n=void 0===t?{}:t,r=e.backward,i=void 0!==r&&r,s=e.blockManager,a=e.indexer;this.condition=n,this.backward=i,this._blockManager=s,this._indexer=a}return e.prototype.findOptimizedStartPosition=function(){var e=this,t=["=","/eq",">",">=","/gt","/gte"],n=["=","/eq","<","<=","/lt","/lte"];if(this.backward){var r=this._indexer.origin.length-1;if("function"!=typeof this.condition)for(var i in this._indexer.fields){var s=this._indexer.fields[i],a=1;if("-"===s[0]&&(s=s.slice(1),a=-1),this.condition[s])if("object"==typeof this.condition[s]){var o=a>0?n:t;for(var c in this.condition[s])if(o.includes(c))for(var u=r;u>=0;u--)if(a*Re(this._indexer.origin[u].columnValues[i],this.condition[s][c])<=0){r=u;break}}else for(u=r;u>=0;u--)if(a*Re(this._indexer.origin[u].columnValues[i],this.condition[s])<=0){r=u;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(a){if((s>0?t:n).includes(a))for(var o=l;o=0){l=o;break}}));else for(var a=l;a=0){l=a;break}},d=this,i=0;i-1){var r=this._items[n];return t===qe.PERSISTENT&&(r.state=Ke.PERSISTENT),t!==qe.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)$e.includes(this._items[r].state)&&$e.includes(e.state)?(this._items.splice(r,1),this._items.push(e)):(this._items[r].state=e.state,this._items[r].value=e.value);else{this._items.push(e);var s=this._items.filter((function(e){return e.state===Ke.VOLATILE})),a=s.length-this._limit;if(a>0){var o=[];try{for(var c=i(this._items),u=c.next();!u.done;u=c.next()){var l=u.value;l.state===Ke.VOLATILE&&a>0?a--:o.push(l)}}catch(e){t={error:e}}finally{try{u&&!u.done&&(n=c.return)&&n.call(c)}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!==Ke.VOLATILE}))},e}(),nt=function(){function e(e){var t=e.dbname,n=e.collectionName,r=e.store;this._requests=[],this._onCommit=new Map,this._onWrite=new Map,this._onError=new Map,this.dbname=t,this.collectionName=n,this.metadataKey=function(e,t){return"".concat(We(e,t),"/trans.metadata")}(t,n),this.recordsetKey=function(e,t){return"".concat(We(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=[]),r(this,void 0,void 0,(function(){var t;return s(this,(function(n){switch(n.label){case 0:return[4,this._store.get(this.recordsetKey)];case 1:return(t=n.sent()||[]).push.apply(t,I([],w(e),!1)),[2,this._reduceRecordSet(t)]}}))}))},e.prototype._reduceRecordSet=function(e){for(var t=[],n={},r=e.length-1;r>=0;r--){for(var i=e[r],s=[],a=i.requests.length-1;a>=0;a--){var o=i.requests[a],c=o.data;n[c.key]||(s.unshift(o),n[c.key]=!0)}s.length>0&&(i.requests=s,t.unshift(i))}return t},e.prototype._applyRecord=function(e,t){return r(this,void 0,void 0,(function(){var n,r,i,o,c,u,l,h,d;return s(this,(function(s){switch(s.label){case 0:n=tt.get(this.dbname),r=t.generation,i=t.requests,o=null,s.label=1;case 1:return s.trys.push([1,3,,4]),[4,this._store.setMany(i.map((function(e){return a(a({},e.data),{generation:r})})))];case 2:for(c=s.sent(),u=0;u0))return[3,4];for(t=[],n={},u=e.length-1;u>=0;u--)r=e[u],h=r.data,n[h.key]||(n[h.key]=!0,t.unshift(r));return i={generation:this.generation,requests:t},[4,this._getReducedRecordset([i])];case 1:return o=s.sent(),[4,this._store.set({key:this.recordsetKey,value:o})];case 2:return s.sent(),this._metadata.generation++,[4,this._store.set({key:this.metadataKey,value:this._metadata})];case 3:for(s.sent(),c=tt.get(this.dbname),u=0;u0?(r=this.createBlockId(e,n),[4,t.find(this._store,r)]):[3,4];case 2:if((i=s.sent())&&(a=rt.createFromCacheItem(i),null==a?void 0:a.getItemByKey(e)))return[2,a];s.label=3;case 3:return n--,[3,1];case 4:return[2,null]}}))}))},e.prototype.getFromBlock=function(e){return r(this,void 0,void 0,(function(){var t;return s(this,(function(n){switch(n.label){case 0:return[4,this._findBlock(e)];case 1:return[2,(t=n.sent())?t.getItemByKey(e):null]}}))}))},e.prototype.putToBlock=function(e,t){return r(this,void 0,void 0,(function(){var n,r,i,a,o;return s(this,(function(s){switch(s.label){case 0:return n=Oe.get(this.dbname),r=this.createBlockId(e),i=Math.floor(this._store.itemSizeLimit/n.itemSizeLimit),[4,tt.get(this.dbname).find(this._store,r)];case 1:return a=s.sent(),(null==(o=a?rt.createFromCacheItem(a):new rt({blockId:r,keyName:this.keyName,items:[],limit:i}))?void 0:o.add(t))?(this._transaction.requestWrite({key:o.blockId,value:o.serialize()}),[2,!0]):[2,!1]}}))}))},e.prototype.removeFromBlock=function(e){return r(this,void 0,void 0,(function(){var t;return s(this,(function(n){switch(n.label){case 0:return[4,this._findBlock(e)];case 1:return(t=n.sent())&&t.remove(e)?(this._transaction.requestWrite({key:t.blockId,value:t.serialize()}),[2,!0]):[2,!1]}}))}))},e.prototype.clearAllBlocks=function(){return r(this,void 0,void 0,(function(){var e,t,n;return s(this,(function(r){switch(r.label){case 0:return e=Qe(this.dbname,this.collectionName),[4,this._store.getAllKeys()];case 1:return t=r.sent(),n=t.filter((function(t){return t.startsWith(e)})),[4,this._store.removeMany(n)];case 2:return r.sent(),[4,this._transaction.clear()];case 3:return r.sent(),tt.get(this.dbname).clearByCondition((function(t){return t.key.startsWith(e)})),[2]}}))}))},e}(),st={},at=function(){function e(e){var t=e.dbname,n=e.collectionName,r=e.keyName,i=e.fields,s=e.transaction,a=e.store,o=this;this._origin=[],this._table=[];var c=function(e,t,n){return"".concat(We(e,t),"/index.").concat(n)}(t,n,i.join(">"));return st[c]||(this.dbname=t,this.collectionName=n,this.keyName=r,this.fields=i,this.indexerKey=c,this._transaction=s,this._store=a,this._transaction.on(Ve.COMMIT,this.indexerKey,(function(){return o.commit()})),this._transaction.on(Ve.ERROR,this.indexerKey,(function(){return o.abort()}))),st[c]}return e.createKey=function(e){return e.join(">")},e.parseKey=function(e){return e.split(">")},e.clearIndexerMap=function(){for(var e in st)delete st[e]},e.prototype._addItem=function(e){var t=e[this.keyName],n=this.getColumnValues(e),r=w(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=w(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,s,a=[];try{for(var o=i(this.fields),c=o.next();!c.done;c=o.next()){var u=c.value;if("-"===u[0]&&(u=u.slice(1)),r=e[u],s=void 0,s=typeof r,null!==r&&"undefined"!==s&&"boolean"!==s&&"number"!==s&&"string"!==s)throw Se.indexTypesNotMatch;a.push(e[u])}}catch(e){t={error:e}}finally{try{c&&!c.done&&(n=o.return)&&n.call(o)}finally{if(t)throw t.error}}return a},e.prototype.diff=function(e,t){for(var n in this.fields){var r="-"===this.fields[n][0]?-1:1,i=Re(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 r(this,void 0,void 0,(function(){var e,t,n,r,a,o,c,u,l,h,d,f,_,v,p,m,y;return s(this,(function(s){switch(s.label){case 0:return[4,(e=tt.get(this.dbname)).find(this._store,this.indexerKey,qe.PERSISTENT)];case 1:return(t=s.sent())?[3,11]:(n=Qe(this.dbname,this.collectionName),[4,this._store.getAllKeys()]);case 2:r=s.sent(),s.label=3;case 3:s.trys.push([3,8,9,10]),a=i(r),o=a.next(),s.label=4;case 4:return o.done?[3,7]:(c=o.value).startsWith(n)?[4,e.find(this._store,c,qe.NO_CACHE)]:[3,6];case 5:if(u=s.sent(),l=rt.createFromCacheItem(u))try{for(m=void 0,h=i(l.items),d=h.next();!d.done;d=h.next())f=d.value,this._addItem(f)}catch(e){m={error:e}}finally{try{d&&!d.done&&(y=h.return)&&y.call(h)}finally{if(m)throw m.error}}s.label=6;case 6:return o=a.next(),[3,4];case 7:return[3,10];case 8:return _=s.sent(),v={error:_},[3,10];case 9:try{o&&!o.done&&(p=a.return)&&p.call(a)}finally{if(v)throw v.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=ke(this._origin),s.label=12;case 12:return st[this.indexerKey]=this,[2]}}))}))},e.prototype.drop=function(){return r(this,void 0,void 0,(function(){return s(this,(function(e){switch(e.label){case 0:return tt.get(this.dbname).remove(this.indexerKey),[4,this._store.remove(this.indexerKey)];case 1:return e.sent(),delete st[this.indexerKey],[2]}}))}))},e.prototype.addItem=function(e){return r(this,void 0,void 0,(function(){return s(this,(function(t){return this._addItem(e)&&this._transaction.requestWrite({key:this.indexerKey,value:this._table},{persistent:!0}),[2]}))}))},e.prototype.removeItem=function(e){return r(this,void 0,void 0,(function(){return s(this,(function(t){return this._removeItem(e)&&this._transaction.requestWrite({key:this.indexerKey,value:this._table},{persistent:!0}),[2]}))}))},e.prototype.clear=function(){return r(this,void 0,void 0,(function(){return s(this,(function(e){return this._table=[],this._transaction.requestWrite({key:this.indexerKey,value:this._table},{persistent:!0}),[2]}))}))},e.prototype.commit=function(){this._origin=this._table,this._table=ke(this._origin)},e.prototype.abort=function(){this._table=ke(this._origin)},e}(),ot=function(){function e(e){var t=e.dbname,n=e.collectionName,r=e.keyName,i=e.keyHash,s=e.indexes,a=e.store,o=this;this._state=Ce.INIT,this._indexers=[],this.dbname=t,this.name=n,this.keyName=r,this.indexes=I([[r]],w(s.filter((function(e){return at.createKey(e)!==o.keyName}))),!1),this._keyHash=i,this._store=a,this._mutex=new re(function(e,t){return"".concat(We(e,t),".lock")}(t,n)),this._blobContainer=new Ze({dbname:t,collectionName:n,store:a}),this._transaction=new nt({dbname:t,collectionName:n,store:a})}return e.metadataOf=function(e,t,n){return r(this,void 0,void 0,(function(){var r;return s(this,(function(i){switch(i.label){case 0:return r=Ye(e,t),[4,n.get(r)];case 1:return[2,i.sent()]}}))}))},Object.defineProperty(e.prototype,"state",{get:function(){return this._state},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"isReady",{get:function(){return this._state===Ce.READY},enumerable:!1,configurable:!0}),e.prototype.init=function(){return r(this,void 0,void 0,(function(){var t,n,r,a,o,c,u,l,h,d,f,_,v,p,m=this;return s(this,(function(s){switch(s.label){case 0:return[4,this._mutex.lock()];case 1:s.sent(),s.label=2;case 2:return s.trys.push([2,9,,10]),t=Oe.get(this.dbname),[4,e.metadataOf(this.dbname,this.name,this._store)];case 3:return n=s.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:s.sent(),this._blockManager=new it({dbname:this.dbname,collectionName:this.name,hashFunction:this._keyHash,metadata:this._metadata,transaction:this._transaction,store:this._store}),r=I([],w(this.indexes),!1),a=[],o=r.map((function(e){return at.createKey(e)})),c=n?n.indexes.map((function(e){return at.createKey(e)})):[];try{for(u=i(c),l=u.next();!l.done;l=u.next())h=l.value,o.includes(h)||a.push(at.parseKey(h))}catch(e){v={error:e}}finally{try{l&&!l.done&&(p=u.return)&&p.call(u)}finally{if(v)throw v.error}}return(d=[]).push.apply(d,I([],w(r.map((function(e){var t=new at({dbname:m.dbname,collectionName:m.name,keyName:m.keyName,fields:e,transaction:m._transaction,store:m._store});return m._indexers.push(t),t.ensure()}))),!1)),d.push.apply(d,I([],w(a.map((function(e){return new at({dbname:m.dbname,collectionName:m.name,keyName:m.keyName,fields:e,transaction:m._transaction,store:m._store}).drop()}))),!1)),[4,Promise.all(d)];case 5:return s.sent(),[4,this._transaction.commit()];case 6:return s.sent(),o.sort().join(",")===c.sort().join(",")?[3,8]:(f=Ye(this.dbname,this.name),this._metadata.indexes=r,[4,this._store.set({key:f,value:this._metadata})]);case 7:s.sent(),s.label=8;case 8:return this._state=Ce.READY,this._mutex.unlock(),[3,10];case 9:throw _=s.sent(),this._mutex.unlock(),_;case 10:return[2]}}))}))},e.prototype.close=function(){this._state=Ce.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=at.createKey(e);try{for(var s=i(this._indexers),a=s.next();!a.done;a=s.next()){var o=a.value;if(r===at.createKey(o.fields))return o}}catch(e){t={error:e}}finally{try{a&&!a.done&&(n=s.return)&&n.call(s)}finally{if(t)throw t.error}}throw Se.indexTableIsRequired},e.prototype._upgradeBlockLevel=function(){return r(this,void 0,void 0,(function(){var e;return s(this,(function(t){switch(t.label){case 0:return e=Ye(this.dbname,this.name),this._metadata.blockLevel++,[4,this._store.set({key:e,value:this._metadata})];case 1:return t.sent(),[2]}}))}))},e.prototype._requestInsert=function(e){return r(this,void 0,void 0,(function(){var t,n,r,a,o,c;return s(this,(function(s){switch(s.label){case 0:return t=e[this.keyName],[4,this._blockManager.getFromBlock(t)];case 1:return s.sent()?[3,13]:[4,this._blockManager.putToBlock(t,e)];case 2:return s.sent()?[3,5]:[4,this._upgradeBlockLevel()];case 3:return s.sent(),[4,this._blockManager.putToBlock(t,e)];case 4:s.sent(),s.label=5;case 5:s.trys.push([5,10,11,12]),n=i(this._indexers),r=n.next(),s.label=6;case 6:return r.done?[3,9]:[4,r.value.addItem(e)];case 7:s.sent(),s.label=8;case 8:return r=n.next(),[3,6];case 9:return[3,12];case 10:return a=s.sent(),o={error:a},[3,12];case 11:try{r&&!r.done&&(c=n.return)&&c.call(n)}finally{if(o)throw o.error}return[7];case 12:return[3,14];case 13:throw Se.collectionInsertDuplicate;case 14:return[2]}}))}))},e.prototype._requestUpsert=function(e){return r(this,void 0,void 0,(function(){var t,n,r,a,o,c,u,l,h,d,f,_,v;return s(this,(function(s){switch(s.label){case 0:return t=e[this.keyName],[4,this._blockManager.getFromBlock(t)];case 1:return(n=s.sent())?[3,13]:[4,this._blockManager.putToBlock(t,e)];case 2:return s.sent()?[3,5]:[4,this._upgradeBlockLevel()];case 3:return s.sent(),[4,this._blockManager.putToBlock(t,e)];case 4:s.sent(),s.label=5;case 5:s.trys.push([5,10,11,12]),r=i(this._indexers),a=r.next(),s.label=6;case 6:return a.done?[3,9]:[4,(l=a.value).addItem(e)];case 7:s.sent(),s.label=8;case 8:return a=r.next(),[3,6];case 9:return[3,12];case 10:return o=s.sent(),d={error:o},[3,12];case 11:try{a&&!a.done&&(f=r.return)&&f.call(r)}finally{if(d)throw d.error}return[7];case 12:return[3,23];case 13:return[4,this._blockManager.putToBlock(t,e)];case 14:s.sent(),s.label=15;case 15:s.trys.push([15,21,22,23]),c=i(this._indexers),u=c.next(),s.label=16;case 16:return u.done?[3,20]:0===(l=u.value).diff(l.getColumnValues(n),l.getColumnValues(e))?[3,19]:[4,l.removeItem(n)];case 17:return s.sent(),[4,l.addItem(e)];case 18:s.sent(),s.label=19;case 19:return u=c.next(),[3,16];case 20:return[3,23];case 21:return h=s.sent(),_={error:h},[3,23];case 22:try{u&&!u.done&&(v=c.return)&&v.call(c)}finally{if(_)throw _.error}return[7];case 23:return[2]}}))}))},e.prototype._requestUpdate=function(e){return r(this,void 0,void 0,(function(){var t,n,r,a,o,c,u,l;return s(this,(function(s){switch(s.label){case 0:return t=e[this.keyName],[4,this._blockManager.getFromBlock(t)];case 1:return(n=s.sent())?[4,this._blockManager.putToBlock(t,e)]:[3,11];case 2:s.sent(),s.label=3;case 3:s.trys.push([3,9,10,11]),r=i(this._indexers),a=r.next(),s.label=4;case 4:return a.done?[3,8]:0===(o=a.value).diff(o.getColumnValues(n),o.getColumnValues(e))?[3,7]:[4,o.removeItem(n)];case 5:return s.sent(),[4,o.addItem(e)];case 6:s.sent(),s.label=7;case 7:return a=r.next(),[3,4];case 8:return[3,11];case 9:return c=s.sent(),u={error:c},[3,11];case 10:try{a&&!a.done&&(l=r.return)&&l.call(r)}finally{if(u)throw u.error}return[7];case 11:return[2]}}))}))},e.prototype._requestRemove=function(e){return r(this,void 0,void 0,(function(){var t,n,r,a,o,c;return s(this,(function(s){switch(s.label){case 0:return[4,this._blockManager.getFromBlock(e)];case 1:return(t=s.sent())?[4,this._blockManager.removeFromBlock(e)]:[3,10];case 2:s.sent(),s.label=3;case 3:s.trys.push([3,8,9,10]),n=i(this._indexers),r=n.next(),s.label=4;case 4:return r.done?[3,7]:[4,r.value.removeItem(t)];case 5:s.sent(),s.label=6;case 6:return r=n.next(),[3,4];case 7:return[3,10];case 8:return a=s.sent(),o={error:a},[3,10];case 9:try{r&&!r.done&&(c=n.return)&&c.call(n)}finally{if(o)throw o.error}return[7];case 10:return[2]}}))}))},e.prototype._requestClear=function(){return r(this,void 0,void 0,(function(){var e,t,n,r,a;return s(this,(function(s){switch(s.label){case 0:return[4,this._blockManager.clearAllBlocks()];case 1:s.sent(),s.label=2;case 2:s.trys.push([2,7,8,9]),e=i(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&&(a=e.return)&&a.call(e)}finally{if(r)throw r.error}return[7];case 9:return[2]}}))}))},e.prototype.getByKey=function(e){return r(this,void 0,void 0,(function(){var t,n;return s(this,(function(r){switch(r.label){case 0:return this.isReady?[4,this._mutex.lock()]:[3,6];case 1:r.sent(),r.label=2;case 2:return r.trys.push([2,4,,5]),[4,this._blockManager.getFromBlock(e)];case 3:return t=r.sent(),this._mutex.unlock(),[2,ke(t)];case 4:throw n=r.sent(),this._mutex.unlock(),n;case 5:return[3,7];case 6:throw Se.collectionNotReady;case 7:return[2]}}))}))},e.prototype.query=function(e){if(void 0===e&&(e={}),this.isReady)return new Ge({condition:e.where,mutex:this._mutex,blockManager:this._blockManager,indexer:this._getIndexerBy(e.index),backward:!!e.backward});throw Se.collectionNotReady},e.prototype.insertOne=function(e){return r(this,void 0,void 0,(function(){var t;return s(this,(function(n){switch(n.label){case 0:return this.isReady?[4,this._mutex.lock()]:[3,8];case 1:n.sent(),n.label=2;case 2:if(n.trys.push([2,5,,7]),!this._hasPropertyOfKeyName(e))throw Se.collectionKeyNotGiven;return[4,this._requestInsert(ke(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 Se.collectionNotReady;case 9:return[2]}}))}))},e.prototype.insertMany=function(e){return r(this,void 0,void 0,(function(){var t,n,r,a,o,c,u,l=this;return s(this,(function(s){switch(s.label){case 0:return this.isReady?[4,this._mutex.lock()]:[3,15];case 1:s.sent(),s.label=2;case 2:if(s.trys.push([2,12,,14]),e.some((function(e){return!l._hasPropertyOfKeyName(e)})))throw Se.collectionKeyNotGiven;s.label=3;case 3:s.trys.push([3,8,9,10]),t=i(e),n=t.next(),s.label=4;case 4:return n.done?[3,7]:(r=n.value,[4,this._requestInsert(ke(r))]);case 5:s.sent(),s.label=6;case 6:return n=t.next(),[3,4];case 7:return[3,10];case 8:return a=s.sent(),c={error:a},[3,10];case 9:try{n&&!n.done&&(u=t.return)&&u.call(t)}finally{if(c)throw c.error}return[7];case 10:return[4,this._transaction.commit()];case 11:return s.sent(),this._mutex.unlock(),[2,e];case 12:return o=s.sent(),[4,this._transaction.clear()];case 13:throw s.sent(),this._mutex.unlock(),o;case 14:return[3,16];case 15:throw Se.collectionNotReady;case 16:return[2]}}))}))},e.prototype.upsertOne=function(e){return r(this,void 0,void 0,(function(){var t;return s(this,(function(n){switch(n.label){case 0:return this.isReady?[4,this._mutex.lock()]:[3,8];case 1:n.sent(),n.label=2;case 2:if(n.trys.push([2,5,,7]),!this._hasPropertyOfKeyName(e))throw Se.collectionKeyNotGiven;return[4,this._requestUpsert(ke(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 Se.collectionNotReady;case 9:return[2]}}))}))},e.prototype.upsertMany=function(e){return r(this,void 0,void 0,(function(){var t,n,r,a,o,c,u,l=this;return s(this,(function(s){switch(s.label){case 0:return this.isReady?[4,this._mutex.lock()]:[3,15];case 1:s.sent(),s.label=2;case 2:if(s.trys.push([2,12,,14]),e.some((function(e){return!l._hasPropertyOfKeyName(e)})))throw Se.collectionKeyNotGiven;s.label=3;case 3:s.trys.push([3,8,9,10]),t=i(e),n=t.next(),s.label=4;case 4:return n.done?[3,7]:(r=n.value,[4,this._requestUpsert(ke(r))]);case 5:s.sent(),s.label=6;case 6:return n=t.next(),[3,4];case 7:return[3,10];case 8:return a=s.sent(),c={error:a},[3,10];case 9:try{n&&!n.done&&(u=t.return)&&u.call(t)}finally{if(c)throw c.error}return[7];case 10:return[4,this._transaction.commit()];case 11:return s.sent(),this._mutex.unlock(),[2,e];case 12:return o=s.sent(),[4,this._transaction.clear()];case 13:throw s.sent(),this._mutex.unlock(),o;case 14:return[3,16];case 15:throw Se.collectionNotReady;case 16:return[2]}}))}))},e.prototype.update=function(e){return r(this,void 0,void 0,(function(){var t;return s(this,(function(n){switch(n.label){case 0:return this.isReady?[4,this._mutex.lock()]:[3,8];case 1:n.sent(),n.label=2;case 2:if(n.trys.push([2,5,,7]),!this._hasPropertyOfKeyName(e))throw Se.collectionKeyNotGiven;return[4,this._requestUpdate(ke(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 Se.collectionNotReady;case 9:return[2]}}))}))},e.prototype.updateIf=function(e,t){return r(this,void 0,void 0,(function(){var n,a,o,c,u,l,h,d,f,_,v,p,m,y,b=this;return s(this,(function(E){switch(E.label){case 0:return this.isReady?[4,this._mutex.lock()]:[3,16];case 1:E.sent(),E.label=2;case 2:return E.trys.push([2,13,,15]),n=e.where,a=void 0===n?{}:n,o=e.index,c=void 0===o?null:o,u=e.backward,l=void 0!==u&&u,h=[],[4,new je({condition:a,blockManager:this._blockManager,backward:l,indexer:this._getIndexerBy(c)}).each((function(e){return r(b,void 0,void 0,(function(){var n,r;return s(this,(function(i){if(e.error)throw e.stop(),e.error;if(e.hasNext){if(n=e.nextValue,Pe(a,n)&&t.set){if("function"!=typeof t.set)for(r in t.set)n[r]=t.set[r];else t.set(n);h.push(n)}e.next()}else e.stop();return[2]}))}))}))];case 3:E.sent(),E.label=4;case 4:E.trys.push([4,9,10,11]),d=i(h),f=d.next(),E.label=5;case 5:return f.done?[3,8]:(_=f.value,[4,this._requestUpdate(ke(_))]);case 6:E.sent(),E.label=7;case 7:return f=d.next(),[3,5];case 8:return[3,11];case 9:return v=E.sent(),m={error:v},[3,11];case 10:try{f&&!f.done&&(y=d.return)&&y.call(d)}finally{if(m)throw m.error}return[7];case 11:return[4,this._transaction.commit()];case 12:return E.sent(),this._mutex.unlock(),[2,h];case 13:return p=E.sent(),[4,this._transaction.clear()];case 14:throw E.sent(),this._mutex.unlock(),p;case 15:return[3,17];case 16:throw this._transaction.clear(),Se.collectionNotReady;case 17:return[2]}}))}))},e.prototype.remove=function(e){return r(this,void 0,void 0,(function(){var t;return s(this,(function(n){switch(n.label){case 0:return this.isReady?[4,this._mutex.lock()]:[3,8];case 1:n.sent(),n.label=2;case 2:return n.trys.push([2,5,,7]),[4,this._requestRemove(e)];case 3:return n.sent(),[4,this._transaction.commit()];case 4:return n.sent(),this._mutex.unlock(),[3,7];case 5:return t=n.sent(),[4,this._transaction.clear()];case 6:throw n.sent(),this._mutex.unlock(),t;case 7:return[3,9];case 8:throw Se.collectionNotReady;case 9:return[2]}}))}))},e.prototype.removeIf=function(e){return r(this,void 0,void 0,(function(){var t,n,a,o,c,u,l,h,d,f,_,v,p,m,y=this;return s(this,(function(b){switch(b.label){case 0:return this.isReady?[4,this._mutex.lock()]:[3,15];case 1:b.sent(),b.label=2;case 2:return b.trys.push([2,13,,14]),t=e.where,n=void 0===t?{}:t,a=e.index,o=void 0===a?null:a,c=e.backward,u=void 0!==c&&c,l=[],[4,new je({condition:n,blockManager:this._blockManager,backward:u,indexer:this._getIndexerBy(o)}).each((function(e){return r(y,void 0,void 0,(function(){var t,r;return s(this,(function(i){if(e.error)throw e.stop(),e.error;return e.hasNext?(t=e.nextValue,Pe(n,t)&&(r=t[this.keyName],l.push(r)),e.next()):e.stop(),[2]}))}))}))];case 3:b.sent(),b.label=4;case 4:b.trys.push([4,9,10,11]),h=i(l),d=h.next(),b.label=5;case 5:return d.done?[3,8]:(f=d.value,[4,this._requestRemove(f)]);case 6:b.sent(),b.label=7;case 7:return d=h.next(),[3,5];case 8:return[3,11];case 9:return _=b.sent(),p={error:_},[3,11];case 10:try{d&&!d.done&&(m=h.return)&&m.call(h)}finally{if(p)throw p.error}return[7];case 11:return[4,this._transaction.commit()];case 12:return b.sent(),this._mutex.unlock(),[2,l];case 13:throw v=b.sent(),this._mutex.unlock(),v;case 14:return[3,16];case 15:throw this._transaction.clear(),Se.collectionNotReady;case 16:return[2]}}))}))},e.prototype.clear=function(){return r(this,void 0,void 0,(function(){var e;return s(this,(function(t){switch(t.label){case 0:return this.isReady?[4,this._mutex.lock()]:[3,8];case 1:t.sent(),t.label=2;case 2:return t.trys.push([2,5,,7]),[4,this._requestClear()];case 3:return t.sent(),[4,this._transaction.commit()];case 4:return t.sent(),this._mutex.unlock(),[3,7];case 5:return e=t.sent(),[4,this._transaction.clear()];case 6:throw t.sent(),this._mutex.unlock(),e;case 7:return[3,9];case 8:throw Se.collectionNotReady;case 9:return[2]}}))}))},e.prototype.getBlob=function(e){return r(this,void 0,void 0,(function(){return s(this,(function(t){switch(t.label){case 0:return[4,this._blobContainer.get(e)];case 1:return[2,t.sent()]}}))}))},e.prototype.saveBlob=function(e,t){return r(this,void 0,void 0,(function(){return s(this,(function(n){switch(n.label){case 0:return[4,this._blobContainer.save(e,t)];case 1:return[2,n.sent()]}}))}))},e.prototype.removeBlob=function(e){return r(this,void 0,void 0,(function(){return s(this,(function(t){switch(t.label){case 0:return[4,this._blobContainer.remove(e)];case 1:return t.sent(),[2]}}))}))},e.prototype.removeAllBlobs=function(){return r(this,void 0,void 0,(function(){return s(this,(function(e){switch(e.label){case 0:return[4,this._blobContainer.clear()];case 1:return e.sent(),[2]}}))}))},e}(),ct=function(){function e(e){var t,n,r;this.encryption=null!==(t=e.encryption)&&void 0!==t?t:A,this.itemSizeLimit=null!==(n=e.itemSizeLimit)&&void 0!==n?n:4194304,this.metadataBuffer=null!==(r=e.metadataBuffer)&&void 0!==r?r:256}return e.prototype._getRawKey=function(e,t){return void 0===t&&(t=""),"".concat(e).concat(t)},e.prototype._generateShardPostfixArray=function(e){return void 0===e&&(e=1),I([],w(Array(e).keys()),!1)},e.prototype._shardify=function(e){var t=this,n=e.key,r=e.value,i=JSON.stringify(this.encryption.encrypt(r)),s=Math.ceil(i.length/this.adjustedItemSizeLimit);return this._generateShardPostfixArray(s).map((function(e){var r={key:t._getRawKey(n,".".concat(e)),data:i.substring(e*t.adjustedItemSizeLimit,(e+1)*t.adjustedItemSizeLimit)};return 0===e&&(r.metadata={shards:s}),r}))},Object.defineProperty(e.prototype,"adjustedItemSizeLimit",{get:function(){return Math.max(this.itemSizeLimit-this.metadataBuffer,4)},enumerable:!1,configurable:!0}),e.prototype.usage=function(){return r(this,void 0,void 0,(function(){var e,t,n,r,a,o,c,u,l;return s(this,(function(s){switch(s.label){case 0:return e=0,[4,this._getAllRawKeys()];case 1:t=s.sent(),s.label=2;case 2:s.trys.push([2,7,8,9]),n=i(t),r=n.next(),s.label=3;case 3:return r.done?[3,6]:(a=r.value,[4,this._getRaw(a)]);case 4:(o=s.sent())&&(e+=JSON.stringify(o).length),s.label=5;case 5:return r=n.next(),[3,3];case 6:return[3,9];case 7:return c=s.sent(),u={error:c},[3,9];case 8:try{r&&!r.done&&(l=n.return)&&l.call(n)}finally{if(u)throw u.error}return[7];case 9:return[2,e]}}))}))},e.prototype.getAllKeys=function(){return r(this,void 0,void 0,(function(){return s(this,(function(e){switch(e.label){case 0:return[4,this._getAllRawKeys()];case 1:return[2,e.sent().filter((function(e){return e.endsWith(".0")})).map((function(e){return e.replace(/\.0$/,"")}))]}}))}))},e.prototype.get=function(e){return r(this,void 0,void 0,(function(){var t,n,i,a,o,c,u=this;return s(this,(function(l){switch(l.label){case 0:return t=this._getRawKey(e,".0"),[4,this._getRaw(t)];case 1:if(!(n=l.sent()))return[3,7];l.label=2;case 2:return l.trys.push([2,6,,7]),i=n.data,(null==(a=n.metadata)?void 0:a.shards)&&a.shards>1?[4,Promise.all(this._generateShardPostfixArray(null==a?void 0:a.shards).map((function(t){return r(u,void 0,void 0,(function(){var n,r;return s(this,(function(s){switch(s.label){case 0:return t>0?(n=this._getRawKey(e,".".concat(t)),[4,this._getRaw(n)]):[3,2];case 1:if(!(r=s.sent()))throw Se.storeBrokenIntegrity;return[2,r.data];case 2:return[2,i]}}))}))})))]:[3,4];case 3:return c=l.sent(),[3,5];case 4:c=[i],l.label=5;case 5:return o=c,[2,this.encryption.decrypt(JSON.parse(o.join("")))];case 6:return l.sent(),[2,null];case 7:return[2,null]}}))}))},e.prototype.set=function(e){return r(this,void 0,void 0,(function(){var t;return s(this,(function(n){switch(n.label){case 0:return t=this._shardify(e),[4,this._setRaw(t)];case 1:return n.sent(),[2,a({},e.value)]}}))}))},e.prototype.setMany=function(e){return r(this,void 0,void 0,(function(){var t,n=this;return s(this,(function(r){switch(r.label){case 0:return t=[],[4,this._setRaw(t.concat.apply(t,I([],w(e.map((function(e){return n._shardify(e)}))),!1)))];case 1:return r.sent(),[2,e.map((function(e){return e.value}))]}}))}))},e.prototype.remove=function(e){return r(this,void 0,void 0,(function(){var t,n,r,i=this;return s(this,(function(s){switch(s.label){case 0:return t=this._getRawKey(e,".0"),[4,this._getRaw(t)];case 1:return(n=s.sent())?(r=n.metadata,[4,this._removeRaw(this._generateShardPostfixArray(null==r?void 0:r.shards).map((function(t){return i._getRawKey(e,".".concat(t))})))]):[3,3];case 2:return s.sent(),[2,!0];case 3:return[2,!1]}}))}))},e.prototype.removeMany=function(e){return r(this,void 0,void 0,(function(){var t,n,r,a,o,c,u,l,h,d=this;return s(this,(function(f){switch(f.label){case 0:t=[],n=function(e){var n,i,a;return s(this,(function(s){switch(s.label){case 0:return n=r._getRawKey(e,".0"),[4,r._getRaw(n)];case 1:return(i=s.sent())&&(a=i.metadata,t.push.apply(t,I([],w(r._generateShardPostfixArray(null==a?void 0:a.shards).map((function(t){return d._getRawKey(e,".".concat(t))}))),!1))),[2]}}))},r=this,f.label=1;case 1:f.trys.push([1,6,7,8]),a=i(e),o=a.next(),f.label=2;case 2:return o.done?[3,5]:(c=o.value,[5,n(c)]);case 3:f.sent(),f.label=4;case 4:return o=a.next(),[3,2];case 5:return[3,8];case 6:return u=f.sent(),l={error:u},[3,8];case 7:try{o&&!o.done&&(h=a.return)&&h.call(a)}finally{if(l)throw l.error}return[7];case 8:return t.length>0?[4,this._removeRaw(t)]:[3,10];case 9:f.sent(),f.label=10;case 10:return[2,e]}}))}))},e}(),ut={},lt=function(e){function t(t){void 0===t&&(t={});var n,r=this;r=e.call(this,a(a({},t),{itemSizeLimit:null!==(n=t.itemSizeLimit)&&void 0!==n?n:4194304}))||this;var i=t.delay,s=void 0===i?1:i;return r.delay=s,r.observer={},r}return u(t,e),Object.defineProperty(t.prototype,"rawData",{get:function(){return ut[this.dbname]},set:function(e){ut[this.dbname]=e},enumerable:!1,configurable:!0}),t.prototype._getAllRawKeys=function(){return r(this,void 0,void 0,(function(){return s(this,(function(e){if(ut[this.dbname])return[2,Object.keys(ut[this.dbname])];throw Se.storeNotAvailable}))}))},t.prototype._getRaw=function(e){return r(this,void 0,void 0,(function(){return s(this,(function(t){switch(t.label){case 0:return ut[this.dbname]?[4,De(this.delay)]:[3,2];case 1:return t.sent(),[2,ut[this.dbname][e]?a({key:e},ut[this.dbname][e]):null];case 2:throw Se.storeNotAvailable}}))}))},t.prototype._setRaw=function(e){return r(this,void 0,void 0,(function(){var t,n,r,a,o,c,u,l;return s(this,(function(s){switch(s.label){case 0:return ut[this.dbname]?[4,De(this.delay)]:[3,2];case 1:s.sent();try{for(t=i(e),n=t.next();!n.done;n=t.next())r=n.value,a=r.key,o=r.data,c=r.metadata,ut[this.dbname][a]=Object.freeze({data:o,metadata:c})}catch(e){u={error:e}}finally{try{n&&!n.done&&(l=t.return)&&l.call(t)}finally{if(u)throw u.error}}return[3,3];case 2:throw Se.storeNotAvailable;case 3:return[2]}}))}))},t.prototype._removeRaw=function(e){return r(this,void 0,void 0,(function(){var t,n,r,a,o;return s(this,(function(s){switch(s.label){case 0:return ut[this.dbname]?[4,De(this.delay)]:[3,2];case 1:s.sent();try{for(t=i(e),n=t.next();!n.done;n=t.next())r=n.value,ut[this.dbname][r]&&delete ut[this.dbname][r]}catch(e){a={error:e}}finally{try{n&&!n.done&&(o=t.return)&&o.call(t)}finally{if(a)throw a.error}}return[3,3];case 2:throw Se.storeNotAvailable;case 3:return[2]}}))}))},t.prototype.observe=function(e,t,n){var r=this;this.observer[e]||(this.observer[e]={}),t.forEach((function(t){return r.observer[e][t]=n}))},t.prototype.checkAvailability=function(){return r(this,void 0,void 0,(function(){return s(this,(function(e){return[2]}))}))},t.prototype.init=function(e){return r(this,void 0,void 0,(function(){return s(this,(function(t){return this.dbname=e,ut[this.dbname]={},[2]}))}))},t.prototype.set=function(t){return r(this,void 0,void 0,(function(){var n,r;return s(this,(function(i){if((n=this.observer[t.key])&&"function"==typeof n.set&&(r=n.set()))throw r;return[2,e.prototype.set.call(this,t)]}))}))},t.prototype.setMany=function(t){return r(this,void 0,void 0,(function(){var n,r,a,o,c,u,l;return s(this,(function(s){try{for(n=i(t),r=n.next();!r.done;r=n.next())if(a=r.value,(o=this.observer[a.key])&&"function"==typeof o.set&&(c=o.set()))throw c}catch(e){u={error:e}}finally{try{r&&!r.done&&(l=n.return)&&l.call(n)}finally{if(u)throw u.error}}return[2,e.prototype.setMany.call(this,t)]}))}))},t.prototype.clear=function(){return r(this,void 0,void 0,(function(){return s(this,(function(e){switch(e.label){case 0:return[4,De(this.delay)];case 1:return e.sent(),ut[this.dbname]={},[2]}}))}))},t}(ct),ht="NestDBStore";!function(e){e[e.UNINITIALIZED=0]="UNINITIALIZED",e[e.OPENING=1]="OPENING",e[e.OPEN=2]="OPEN",e[e.CLOSED=3]="CLOSED"}(Xe||(Xe={}));var dt=function(e){function t(t){void 0===t&&(t={});var n,r=this;return(r=e.call(this,a(a({},t),{itemSizeLimit:null!==(n=t.itemSizeLimit)&&void 0!==n?n:104857600}))||this)._storeName=ht,r._state=Xe.UNINITIALIZED,r._openJobQueue=[],r._window="undefined"!=typeof window?window:void 0,r._indexedDb=r._window?r._window.indexedDB||r._window.mozIndexedDB||r._window.webkitIndexedDB||r._window.msIndexedDB:void 0,r}return u(t,e),Object.defineProperty(t.prototype,"state",{get:function(){return this._state},enumerable:!1,configurable:!0}),t.prototype._openDatabase=function(e){var t=this;return new Promise((function(n,r){if(t._indexedDb){t._state=Xe.OPENING;var i=t._indexedDb.open(e);i.addEventListener("upgradeneeded",(function(e){e.target.result.createObjectStore(ht,{keyPath:"key"})})),i.addEventListener("success",(function(r){t._state=Xe.OPEN,t._database=r.target.result,t._openJobQueue.forEach((function(e){return e()})),t._openJobQueue=[],t._database.onclose=function(){t._database=void 0,t._state=Xe.OPENING,setTimeout((function(){t._openDatabase(e)}),5)},n(t._database)})),i.addEventListener("error",(function(e){t._state=Xe.UNINITIALIZED,r(e.target.error)}))}else r(Se.storeNotAvailable)}))},t.prototype._getObjectStore=function(e){return r(this,void 0,void 0,(function(){var t=this;return s(this,(function(n){switch(n.label){case 0:return this._database?[2,this._database.transaction(this._storeName,e).objectStore(this._storeName)]:[3,1];case 1:switch(this._state){case Xe.UNINITIALIZED:case Xe.OPEN:return[3,2];case Xe.OPENING:case Xe.CLOSED:return[3,3]}return[3,4];case 2:throw Se.storeNotInitialized;case 3:return[2,new Promise((function(n){t._openJobQueue.push((function(){return n(t._getObjectStore(e))}))}))];case 4:return[4,this._getObjectStore(e)];case 5:return[2,n.sent()]}}))}))},t.prototype._getAllRawKeys=function(){return r(this,void 0,void 0,(function(){var e;return s(this,(function(t){switch(t.label){case 0:return[4,this._getObjectStore("readonly")];case 1:return e=t.sent(),[4,new Promise((function(t,n){var r=e.getAllKeys();r.addEventListener("success",(function(e){t(e.target.result)})),r.addEventListener("error",(function(e){return n(e.target.error)}))}))];case 2:return[2,t.sent()]}}))}))},t.prototype._getRaw=function(e){return r(this,void 0,void 0,(function(){var t;return s(this,(function(n){switch(n.label){case 0:return[4,this._getObjectStore("readonly")];case 1:return t=n.sent(),[4,new Promise((function(n,r){var i=t.get(e);i.addEventListener("success",(function(e){var t;n(null===(t=null==e?void 0:e.target)||void 0===t?void 0:t.result)})),i.addEventListener("error",(function(e){return r(e.target.error)}))}))];case 2:return[2,n.sent()]}}))}))},t.prototype._setRaw=function(e){return r(this,void 0,void 0,(function(){var t;return s(this,(function(n){switch(n.label){case 0:return[4,this._getObjectStore("readwrite")];case 1:return t=n.sent(),[4,Promise.all(e.map((function(e){return new Promise((function(n,r){var i=t.put(e);i.addEventListener("success",(function(e){n(e.target.result)})),i.addEventListener("error",(function(){r("Failed to write.")}))}))})))];case 2:return n.sent(),[2]}}))}))},t.prototype._removeRaw=function(e){return r(this,void 0,void 0,(function(){var t;return s(this,(function(n){switch(n.label){case 0:return[4,this._getObjectStore("readwrite")];case 1:return t=n.sent(),[4,Promise.all(e.map((function(e){return new Promise((function(n,r){var i=t.delete(e);i.addEventListener("success",(function(){return n(e)})),i.addEventListener("error",(function(e){return r(e.target.error)}))}))})))];case 2:return n.sent(),[2]}}))}))},t.prototype._triggerDatabaseClose=function(){this._database&&this._database.onclose&&this._database.onclose(new Event("dummy"))},t.prototype.checkAvailability=function(){return r(this,void 0,void 0,(function(){var e,t=this;return s(this,(function(n){switch(n.label){case 0:if(!((null==(e="undefined"!=typeof window?window:null)?void 0:e.indexedDB)||(null==e?void 0:e.mozIndexedDB)||(null==e?void 0:e.webkitIndexedDB)||(null==e?void 0:e.msIndexedDB)))return[3,6];if(this._indexedDb=e.indexedDB||e.mozIndexedDB||e.webkitIndexedDB||e.msIndexedDB,!this._window||!$())return[3,4];if(!($()&&navigator.userAgent&&navigator.userAgent.includes("Edge/")))return[3,1];if(!this._window.indexedDB&&(e.PointerEvent||e.MSPointerEvent))throw Se.storeNotAvailableInPrivateBrowsing;return[3,3];case 1:return[4,new Promise((function(e,n){if(t._indexedDb)try{var r=t._indexedDb.open("_testMozilla");r.onerror=function(){return n(Se.storeNotAvailableInPrivateBrowsing)},r.onsuccess=function(){return e()}}catch(e){n(Se.storeNotAvailableInPrivateBrowsing)}else n(Se.storeNotAvailable)}))];case 2:n.sent(),n.label=3;case 3:return[3,5];case 4:throw Se.storeNotAvailable;case 5:return[3,7];case 6:throw Se.storeNotAvailable;case 7:return[2]}}))}))},t.prototype.init=function(e){return r(this,void 0,void 0,(function(){return s(this,(function(t){switch(t.label){case 0:return this.dbname=e,[4,this.checkAvailability()];case 1:return t.sent(),[4,this._openDatabase(e)];case 2:return t.sent(),[2]}}))}))},t.prototype.clear=function(){return r(this,void 0,void 0,(function(){var e;return s(this,(function(t){switch(t.label){case 0:return[4,this._getObjectStore("readwrite")];case 1:return e=t.sent(),[4,new Promise((function(t,n){var r=e.clear();r.addEventListener("success",(function(){return t()})),r.addEventListener("error",(function(e){return n(e.target.error)}))}))];case 2:return[2,t.sent()]}}))}))},t}(ct),ft=function(e){function t(t){var n=this,r=t.AsyncStorage,i=t.itemSizeLimit,s=void 0===i?6291456:i,o=T(t,["AsyncStorage","itemSizeLimit"]);return(n=e.call(this,a(a({},o),{itemSizeLimit:s}))||this)._asyncStorage=r,n}return u(t,e),t.prototype._isBelonging=function(e){return e.startsWith("".concat(this.dbname,"/"))},t.prototype._getActualKey=function(e){return"".concat(this.dbname,"/").concat(e)},t.prototype._getAllRawKeys=function(){return r(this,void 0,void 0,(function(){var e,t=this;return s(this,(function(n){switch(n.label){case 0:return[4,this._asyncStorage.getAllKeys()];case 1:return e=n.sent(),[2,e.filter((function(e){return t._isBelonging(e)})).map((function(e){return e.substring("".concat(t.dbname,"/").length)}))]}}))}))},t.prototype._getRaw=function(e){return r(this,void 0,void 0,(function(){var t;return s(this,(function(n){switch(n.label){case 0:return[4,this._asyncStorage.getItem(this._getActualKey(e))];case 1:return[2,(t=n.sent())?JSON.parse(t):null]}}))}))},t.prototype._setRaw=function(e){return r(this,void 0,void 0,(function(){var t,n,r,a,o,c,u;return s(this,(function(s){switch(s.label){case 0:t=[];try{for(n=i(e),r=n.next();!r.done;r=n.next())a=r.value,o=a.key,a.data.length<=this.adjustedItemSizeLimit&&t.push([this._getActualKey(o),JSON.stringify(a)])}catch(e){c={error:e}}finally{try{r&&!r.done&&(u=n.return)&&u.call(n)}finally{if(c)throw c.error}}return[4,this._asyncStorage.multiSet(t)];case 1:return s.sent(),[2]}}))}))},t.prototype._removeRaw=function(e){return r(this,void 0,void 0,(function(){var t=this;return s(this,(function(n){switch(n.label){case 0:return[4,this._asyncStorage.multiRemove(e.map((function(e){return t._getActualKey(e)})))];case 1:return n.sent(),[2]}}))}))},t.prototype.checkAvailability=function(){return r(this,void 0,void 0,(function(){return s(this,(function(e){if(!this._asyncStorage)throw Se.storeNotAvailable;return[2]}))}))},t.prototype.init=function(e){return r(this,void 0,void 0,(function(){return s(this,(function(t){return this.dbname=e,[2]}))}))},t.prototype.clear=function(){return r(this,void 0,void 0,(function(){var e;return s(this,(function(t){switch(t.label){case 0:return[4,this.getAllKeys()];case 1:return e=t.sent(),[4,this.removeMany(e)];case 2:return t.sent(),[2]}}))}))},t}(ct);!function(e){function t(t){var n,r=this;return(r=e.call(this,a(a({},t),{itemSizeLimit:null!==(n=t.itemSizeLimit)&&void 0!==n?n:6291456}))||this)._mmkv=t.MMKV,r}u(t,e),t.prototype._isBelonging=function(e){return e.startsWith("".concat(this.dbname,"/"))},t.prototype._getActualKey=function(e){return"".concat(this.dbname,"/").concat(e)},t.prototype._getAllRawKeys=function(){return r(this,void 0,void 0,(function(){var e,t=this;return s(this,(function(n){switch(n.label){case 0:return[4,this._mmkv.getAllKeys()];case 1:return e=n.sent(),[2,e.filter((function(e){return t._isBelonging(e)})).map((function(e){return e.substring("".concat(t.dbname,"/").length)}))]}}))}))},t.prototype._getRaw=function(e){return r(this,void 0,void 0,(function(){var t;return s(this,(function(n){switch(n.label){case 0:return[4,this._mmkv.getString(this._getActualKey(e))];case 1:return[2,(t=n.sent())?JSON.parse(t):null]}}))}))},t.prototype._setRaw=function(e){return r(this,void 0,void 0,(function(){var t,n,r,a,o,c;return s(this,(function(s){try{for(t=i(e),n=t.next();!n.done;n=t.next())r=n.value,a=r.key,r.data.length<=this.adjustedItemSizeLimit&&this._mmkv.set(this._getActualKey(a),JSON.stringify(r))}catch(e){o={error:e}}finally{try{n&&!n.done&&(c=t.return)&&c.call(t)}finally{if(o)throw o.error}}return[2]}))}))},t.prototype._removeRaw=function(e){return r(this,void 0,void 0,(function(){var t,n,r,a,o;return s(this,(function(s){try{for(t=i(e),n=t.next();!n.done;n=t.next())r=n.value,this._mmkv.delete(this._getActualKey(r))}catch(e){a={error:e}}finally{try{n&&!n.done&&(o=t.return)&&o.call(t)}finally{if(a)throw a.error}}return[2]}))}))},t.prototype.checkAvailability=function(){return r(this,void 0,void 0,(function(){return s(this,(function(e){if(!this._mmkv)throw Se.storeNotAvailable;return[2]}))}))},t.prototype.init=function(e){return r(this,void 0,void 0,(function(){return s(this,(function(t){return this.dbname=e,[2]}))}))},t.prototype.clear=function(){return r(this,void 0,void 0,(function(){var e;return s(this,(function(t){switch(t.label){case 0:return[4,this.getAllKeys()];case 1:return e=t.sent(),[4,this.removeMany(e)];case 2:return t.sent(),[2]}}))}))}}(ct);var _t,vt="[NESTDB]",pt=!0,mt=function(){function e(){}return e.off=function(){pt=!1},e.log=function(){for(var e=[],t=0;t; } @@ -52,7 +52,7 @@ export declare class BannedUserListQuery extends ChannelDataListQuery { export type BannedUserListQueryParams = BaseListQueryParams; export declare class BaseChannel { - url: string; + readonly url: string; channelType: ChannelType; name: string; coverUrl: string; @@ -60,7 +60,7 @@ export declare class BaseChannel { data: string; isFrozen: boolean; isEphemeral: boolean; - creator: User; + creator: User | null; createdAt: number; isGroupChannel(): this is GroupChannel; isOpenChannel(): this is OpenChannel; @@ -132,7 +132,7 @@ export declare class BaseChannel { deletePollOption(pollId: number, pollOptionId: number): Promise; votePoll(pollId: number, pollOptionIds: number[]): Promise; getPollChangeLogsSinceTimestamp(ts: number): Promise; - getPollChangeLogsSinceToken(token: string): Promise; + getPollChangeLogsSinceToken(token: string | null): Promise; createPollListQuery(limit?: number): PollListQuery; createPollVoterListQuery(pollId: number, pollOptionId: number, limit?: number): PollVoterListQuery; } @@ -148,29 +148,29 @@ declare interface BaseListQueryParams { } export declare class BaseMessage { - channelUrl: string; - channelType: ChannelType; + readonly channelUrl: string; + readonly channelType: ChannelType; messageId: number; - parentMessageId?: number; - parentMessage?: BaseMessage; - silent?: boolean; - isOperatorMessage?: boolean; - messageType?: MessageType; - data?: string; - customType?: string; - mentionType?: MentionType; - mentionedUsers?: User[]; - mentionedUserIds?: string[]; - mentionedMessageTemplate?: string; - threadInfo?: ThreadInfo; - reactions?: Reaction[]; - metaArrays?: MessageMetaArray[]; - ogMetaData?: OGMetaData; - appleCriticalAlertOptions?: AppleCriticalAlertOptions; + parentMessageId: number; + parentMessage: BaseMessage | null; + silent: boolean; + isOperatorMessage: boolean; + messageType: MessageType; + data: string; + customType: string; + mentionType: MentionType | null; + mentionedUsers: User[] | null; + mentionedUserIds: string[] | null; + mentionedMessageTemplate: string; + threadInfo: ThreadInfo | null; + reactions: Reaction[]; + metaArrays: MessageMetaArray[]; + ogMetaData: OGMetaData | null; + appleCriticalAlertOptions: AppleCriticalAlertOptions | null; createdAt: number; - updatedAt?: number; - scheduledInfo?: ScheduledInfo; - extendedMessage?: object; + updatedAt: number; + scheduledInfo: ScheduledInfo | null; + extendedMessage: object; isIdentical(message: BaseMessage): boolean; isEqual(message: BaseMessage): boolean; isUserMessage(): this is UserMessage; @@ -237,7 +237,7 @@ declare interface BaseStoreParams { } export declare class BlockedUserListQuery extends BaseListQuery { - readonly userIdsFilter: string[]; + readonly userIdsFilter: string[] | null; next(): Promise; } @@ -329,7 +329,7 @@ export declare interface Encryption { decrypt: (encrypted: object) => object; } -export declare type FailedMessageHandler = (err: Error, message: SendableMessage) => void; +export declare type FailedMessageHandler = (err: Error | null, message: SendableMessage | null) => void; export declare type FileCompat = File | Blob | FileInfo; @@ -340,7 +340,7 @@ export declare interface FileInfo { } export declare class FileMessage extends SendableMessage { - messageParams: FileMessageCreateParams; + messageParams: FileMessageCreateParams | null; readonly plainUrl: string; readonly requireAuth: boolean; readonly name: string; @@ -415,7 +415,7 @@ export declare class GroupChannel extends BaseChannel { memberCount: number; joinedMemberCount: number; hiddenState: HiddenState; - lastMessage: BaseMessage; + lastMessage: BaseMessage | null; messageOffsetTimestamp: number; messageSurvivalSeconds: number; myMemberState: MemberState; @@ -424,11 +424,11 @@ export declare class GroupChannel extends BaseChannel { myLastRead: number; myCountPreference: CountPreference; myPushTriggerOption: PushTriggerOption; - inviter: User; + inviter: User | null; invitedAt: number; joinedAt: number; pinnedMessageIds: number[]; - lastPinnedMessage: BaseMessage; + lastPinnedMessage: BaseMessage | null; get isHidden(): boolean; get isTyping(): boolean; get cachedUnreadMemberState(): object; @@ -446,7 +446,7 @@ export declare class GroupChannel extends BaseChannel { getUnreadMembers(message: BaseMessage, includeAllMembers?: boolean): Member[]; getReadStatus(includeAllMembers?: boolean): { [key: string]: ReadStatus; - }; + } | null; getTypingUsers(): Member[]; invalidateTypingStatus(): boolean; refresh(): Promise; @@ -560,15 +560,7 @@ export declare interface InvitationPreference { } export declare class LocalCacheConfig { - constructor({ - maxSize, - clearOrder, - customClearOrderComparator, - }?: { - maxSize?: number; - clearOrder?: CachedDataClearOrder; - customClearOrderComparator?: any; - }); + constructor({ maxSize, clearOrder, customClearOrderComparator }?: LocalCacheConfigParams); get maxSize(): number; get clearOrder(): CachedDataClearOrder; get clearOrderComparator(): Comparator; @@ -584,8 +576,8 @@ export declare enum LogLevel { } export declare class Member extends RestrictedUser { - state: MemberState; - role: Role; + state: MemberState | null; + role: Role | null; isMuted: boolean; isBlockedByMe: boolean; isBlockingMe: boolean; @@ -599,7 +591,7 @@ export declare enum MemberListOrder { export declare class MemberListQuery extends ChannelDataListQuery { readonly mutedMemberFilter: MutedMemberFilter; readonly memberStateFilter: MemberStateFilter; - readonly nicknameStartsWithFilter: string; + readonly nicknameStartsWithFilter: string | null; readonly operatorFilter: OperatorFilter; readonly order: MemberListOrder; next(): Promise; @@ -711,7 +703,7 @@ export declare enum MessageCollectionInitPolicy { CACHE_AND_REPLACE_BY_API = 'cache_and_replace_by_api', } -export declare type MessageCollectionInitResultHandler = (err: Error, messages: BaseMessage[]) => void; +export declare type MessageCollectionInitResultHandler = (err: Error | null, messages: BaseMessage[] | null) => void; export declare interface MessageCollectionParams { filter?: MessageFilter; @@ -760,8 +752,8 @@ export declare enum MessageEventSource { export declare class MessageFilter { messageTypeFilter: MessageTypeFilter; - customTypesFilter: string[]; - senderUserIdsFilter: string[]; + customTypesFilter: string[] | null; + senderUserIdsFilter: string[] | null; replyType: ReplyType; clone(): MessageFilter; match(message: BaseMessage): boolean; @@ -792,16 +784,16 @@ export declare class MessageMetaArray { } declare interface MessageMetaArrayPayload { - 'key': string; - 'value'?: string[]; + key: string; + value?: string[]; } export declare class MessageModule extends Module { name: 'message'; buildMessageFromSerializedData(serialized: object): UserMessage | FileMessage | MultipleFilesMessage | AdminMessage; buildSenderFromSerializedData(serialized: object): Sender; - getMessage(params: MessageRetrievalParams): Promise; - getScheduledMessage(params: ScheduledMessageRetrievalParams): Promise; + getMessage(params: MessageRetrievalParams): Promise; + getScheduledMessage(params: ScheduledMessageRetrievalParams): Promise; } export declare class MessageRequestHandler { @@ -831,11 +823,11 @@ export declare class MessageSearchQuery extends BaseListQuery { readonly exactMatch: boolean; readonly channelUrl: string; readonly channelCustomType: string; - readonly messageTimestampFrom: number; - readonly messageTimestampTo: number; + readonly messageTimestampFrom: number | null; + readonly messageTimestampTo: number | null; readonly order: MessageSearchOrder; readonly advancedQuery: boolean; - readonly targetFields: string[]; + readonly targetFields: string[] | null; totalCount: number; next(): Promise; } @@ -889,7 +881,7 @@ declare type ModuleNamespaces void) => (() => void) | undefined; @@ -1012,11 +1004,11 @@ export declare class PinnedMessage { } export declare class PinnedMessageListQuery extends ChannelDataListQuery { - readonly includeMetaArray: boolean; - readonly includeReactions: boolean; - readonly includeParentMessageInfo: boolean; - readonly includeThreadInfo: boolean; - readonly includePollDetails: boolean; + readonly includeMetaArray?: boolean; + readonly includeReactions?: boolean; + readonly includeParentMessageInfo?: boolean; + readonly includeThreadInfo?: boolean; + readonly includePollDetails?: boolean; next(): Promise; } @@ -1036,16 +1028,16 @@ export declare class Plugin { export declare class Poll { id: number; - title: string; + title: string | null; createdAt: number; updatedAt: number; closeAt: number; status: PollStatus; messageId: number; - data?: PollData; + data: PollData | null; voterCount: number; options: PollOption[]; - createdBy?: string; + createdBy: string | null; allowUserSuggestion: boolean; allowMultipleVotes: boolean; votedPollOptionIds: number[]; @@ -1091,9 +1083,9 @@ export declare class PollModule extends Module { export declare class PollOption { pollId: number; id: number; - text: string; + text: string | null; voteCount: number; - createdBy?: string; + createdBy: string | null; createdAt: number; updatedAt: number; } @@ -1148,8 +1140,8 @@ export declare interface PollVoterListQueryParams extends ChannelDataListQueryPa export declare class PreviousMessageListQuery extends ChannelDataListQuery { readonly reverse: boolean; readonly messageTypeFilter: MessageTypeFilter; - readonly customTypesFilter: string[]; - readonly senderUserIdsFilter: string[]; + readonly customTypesFilter: string[] | null; + readonly senderUserIdsFilter: string[] | null; readonly replyType: ReplyType; readonly includeMetaArray: boolean; readonly includeReactions: boolean; @@ -1220,7 +1212,7 @@ export declare class ReactionEvent { readonly messageId: number; readonly userId: string; readonly key: string; - readonly operation: ReactionEventOperation; + readonly operation: ReactionEventOperation | null; readonly updatedAt: number; } @@ -1254,8 +1246,8 @@ export declare class RestrictedUser extends User { } export declare class RestrictionInfo { - readonly restrictionType: RestrictionType; - readonly description: string; + readonly restrictionType: RestrictionType | null; + readonly description: string | null; readonly endAt: number; } @@ -1296,7 +1288,7 @@ export declare interface ScheduledMessageRetrievalParams { } export declare interface ScheduledUserMessageCreateParams extends UserMessageCreateParams { - scheduledAt: number; + scheduledAt?: number; } export declare interface ScheduledUserMessageUpdateParams extends UserMessageUpdateParams { @@ -1304,7 +1296,7 @@ export declare interface ScheduledUserMessageUpdateParams extends UserMessageUpd } declare class SendableMessage extends BaseMessage { - sender: Sender; + readonly sender: Sender; reqId: string; replyToChannel: boolean; sendingStatus: SendingStatus; @@ -1323,20 +1315,20 @@ export declare class SendbirdChat { static get instance(): SendbirdChat; static get version(): string; get appId(): string; - get appInfo(): AppInfo; + get appInfo(): AppInfo | null; get appVersion(): string; get debugMode(): boolean; get logLevel(): LogLevel; set logLevel(val: LogLevel); get isCacheEnabled(): boolean; - get localCacheConfig(): LocalCacheConfig; + get localCacheConfig(): LocalCacheConfig | null; get ekey(): string; - get currentUser(): User; + get currentUser(): User | null; get connectionState(): ConnectionState; get lastConnectedAt(): number; - get fcmPushToken(): string; - get apnsPushToken(): string; - getMemoryStoreForDebugging(): MemoryStore; + get fcmPushToken(): string | null; + get apnsPushToken(): string | null; + getMemoryStoreForDebugging(): MemoryStore | null; addExtension(key: string, version: string): void; setOnlineListener(listener: OnlineDetectorListener): void; setOfflineListener(listener: OnlineDetectorListener): void; @@ -1344,7 +1336,7 @@ export declare class SendbirdChat { getCacheDataSize(): Promise; clearCachedData(): Promise; clearCachedMessages(channelUrls: string[]): Promise; - connect(userId: string, authToken?: string): Promise; + connect(userId: string, authToken?: string): Promise; reconnect(): boolean; disconnect(): Promise; disconnectWebSocket(): Promise; @@ -1419,12 +1411,12 @@ export declare class SendbirdChatOptions { websocketPayloadDecompression, sessionTokenRefreshTimeout, }?: { - useMemberInfoInMessage?: boolean; - typingIndicatorInvalidateTime?: number; - typingIndicatorThrottle?: number; - websocketResponseTimeout?: number; - websocketPayloadDecompression?: boolean; - sessionTokenRefreshTimeout?: number; + useMemberInfoInMessage?: boolean | undefined; + typingIndicatorInvalidateTime?: number | undefined; + typingIndicatorThrottle?: number | undefined; + websocketResponseTimeout?: number | undefined; + websocketPayloadDecompression?: boolean | undefined; + sessionTokenRefreshTimeout?: number | undefined; }); get useMemberInfoInMessage(): boolean; set useMemberInfoInMessage(value: boolean); @@ -1489,7 +1481,7 @@ declare abstract class SessionHandlerParams { declare type SessionTokenRefreshReject = (err: Error) => void; -declare type SessionTokenRefreshResolve = (authToken: string) => void; +declare type SessionTokenRefreshResolve = (authToken: string | null) => void; export declare interface SnoozePeriod { isSnoozeOn: boolean; @@ -1563,8 +1555,8 @@ export declare interface UploadableFileInfo { export declare class UploadedFileInfo { readonly plainUrl: string; - readonly fileName: string; - readonly mimeType: string; + readonly fileName: string | null; + readonly mimeType: string | null; readonly fileSize: number; readonly thumbnails: Thumbnail[]; get url(): string; @@ -1578,10 +1570,10 @@ export declare class User { metaData: object; connectionStatus: UserOnlineState; isActive: boolean; - lastSeenAt: number; - preferredLanguages: string[]; - friendDiscoveryKey: string; - friendName: string; + lastSeenAt: number | null; + preferredLanguages: string[] | null; + friendDiscoveryKey: string | null; + friendName: string | null; get profileUrl(): string; serialize(): object; createMetaData(input: MetaData): Promise; @@ -1601,7 +1593,7 @@ declare abstract class UserEventHandlerParams { export declare class UserMessage extends SendableMessage { message: string; - messageParams: UserMessageCreateParams; + messageParams: UserMessageCreateParams | null; readonly translations: object; readonly translationTargetLanguages: string[]; readonly messageSurvivalSeconds: number; @@ -1614,7 +1606,7 @@ export declare class UserMessage extends SendableMessage { threadedMessages: BaseMessage[]; }>; applyPoll(poll: Poll): boolean; - get poll(): Poll; + get poll(): Poll | null; } export declare interface UserMessageCreateParams extends BaseMessageCreateParams { @@ -1728,22 +1720,22 @@ export declare interface GroupChannelCreateParams { export declare class GroupChannelFilter { includeEmpty: boolean; - nicknameContainsFilter: string; - nicknameStartsWithFilter: string; - nicknameExactMatchFilter: string; + nicknameContainsFilter: string | null; + nicknameStartsWithFilter: string | null; + nicknameExactMatchFilter: string | null; channelNameContainsFilter: string; myMemberStateFilter: MyMemberStateFilter; - customTypesFilter: string[]; - channelUrlsFilter: string[]; + customTypesFilter: string[] | null; + channelUrlsFilter: string[] | null; superChannelFilter: SuperChannelFilter; publicChannelFilter: PublicChannelFilter; - customTypeStartsWithFilter: string; + customTypeStartsWithFilter: string | null; unreadChannelFilter: UnreadChannelFilter; hiddenChannelFilter: HiddenChannelFilter; includeFrozen: boolean; - get searchFilter(): GroupChannelSearchFilter; - setSearchFilter(fields: GroupChannelSearchField[], query: string): void; - get userIdsFilter(): GroupChannelUserIdsFilter; + get searchFilter(): GroupChannelSearchFilter | null; + setSearchFilter(fields?: GroupChannelSearchField[], query?: string): void; + get userIdsFilter(): GroupChannelUserIdsFilter | null; setUserIdsFilter(userIds: string[], includeMode: boolean, queryType?: QueryType): void; clone(): GroupChannelFilter; match(channel: GroupChannel, currentUserId: string): boolean; @@ -1804,12 +1796,12 @@ export declare class GroupChannelListQuery extends BaseListQuery { readonly includeEmpty: boolean; readonly includeFrozen: boolean; readonly includeMetaData: boolean; - readonly channelUrlsFilter: string[]; - readonly customTypesFilter: string[]; - readonly customTypeStartsWithFilter: string; - readonly nicknameContainsFilter: string; - readonly nicknameStartsWithFilter: string; - readonly nicknameExactMatchFilter: string; + readonly channelUrlsFilter: string[] | null; + readonly customTypesFilter: string[] | null; + readonly customTypeStartsWithFilter: string | null; + readonly nicknameContainsFilter: string | null; + readonly nicknameStartsWithFilter: string | null; + readonly nicknameExactMatchFilter: string | null; readonly channelNameContainsFilter: string; readonly myMemberStateFilter: MyMemberStateFilter; readonly unreadChannelFilter: UnreadChannelFilter; @@ -1818,10 +1810,10 @@ export declare class GroupChannelListQuery extends BaseListQuery { readonly hiddenChannelFilter: HiddenChannelFilter; readonly searchFilter: GroupChannelSearchFilter; readonly userIdsFilter: GroupChannelUserIdsFilter; - readonly metadataKey: string; - readonly metadataValues: string[]; - readonly metadataOrderKeyFilter: string; - readonly metadataValueStartsWith: string; + readonly metadataKey: string | null; + readonly metadataValues: string[] | null; + readonly metadataOrderKeyFilter: string | null; + readonly metadataValueStartsWith: string | null; readonly order: GroupChannelListOrder; serialize(): object; next(): Promise; @@ -1880,7 +1872,7 @@ export declare enum GroupChannelSearchField { } export declare interface GroupChannelSearchFilter { - query?: string; + query?: string | null; fields?: GroupChannelSearchField[]; } @@ -1927,16 +1919,16 @@ export declare class PublicGroupChannelListQuery extends BaseListQuery { readonly includeEmpty: boolean; readonly includeFrozen: boolean; readonly includeMetaData: boolean; - readonly channelUrlsFilter: string[]; - readonly customTypesFilter: string[]; - readonly customTypeStartsWithFilter: string; - readonly channelNameContainsFilter: string; + readonly channelUrlsFilter: string[] | null; + readonly customTypesFilter: string[] | null; + readonly customTypeStartsWithFilter: string | null; + readonly channelNameContainsFilter: string | null; readonly membershipFilter: MembershipFilter; readonly superChannelFilter: SuperChannelFilter; - readonly metadataKey: string; - readonly metadataValues: string[]; - readonly metadataOrderKeyFilter: string; - readonly metadataValueStartsWith: string; + readonly metadataKey: string | null; + readonly metadataValues: string[] | null; + readonly metadataOrderKeyFilter: string | null; + readonly metadataValueStartsWith: string | null; readonly order: PublicGroupChannelListOrder; next(): Promise; } @@ -1969,10 +1961,10 @@ export declare enum ScheduledMessageListOrder { } export declare class ScheduledMessageListQuery extends BaseListQuery { - readonly channelUrl: string; - readonly order: ScheduledMessageListOrder; + readonly channelUrl: string | null; + readonly order: ScheduledMessageListOrder | null; readonly reverse: boolean; - readonly scheduledStatus: ScheduledStatus[]; + readonly scheduledStatus: ScheduledStatus[] | null; readonly messageTypeFilter: MessageTypeFilter; next(): Promise; } @@ -2074,9 +2066,9 @@ declare abstract class OpenChannelHandlerParams extends BaseChannelHandlerParams export declare class OpenChannelListQuery extends BaseListQuery { readonly includeFrozen: boolean; readonly includeMetaData: boolean; - readonly nameKeyword: string; - readonly urlKeyword: string; - readonly customTypes: string[]; + readonly nameKeyword: string | null; + readonly urlKeyword: string | null; + readonly customTypes: string[] | null; next(): Promise; } diff --git a/message.js b/message.js index 59f8e75..16cc86b 100644 --- a/message.js +++ b/message.js @@ -1 +1 @@ -export{a3 as MentionType,a1 as MessageType,a6 as MessageTypeFilter,a8 as PushNotificationDeliveryOption,af as ReplyType,a4 as SendingStatus}from"./lib/__bundle-a8606dd4.js";export{r as AdminMessage,A as AppleCriticalAlertOptions,B as BaseMessage,F as FileMessage,d as MessageMetaArray,M as MessageModule,h as MessageRequestHandler,t as MessageSearchOrder,a as MessageSearchQuery,b as MultipleFilesMessage,g as MultipleFilesMessageRequestHandler,O as OGImage,u as OGMetaData,e as PreviousMessageListQuery,w as Reaction,R as ReactionEvent,x as ReactionEventOperation,f as Sender,y as ThreadInfo,s as ThreadInfoUpdateEvent,T as Thumbnail,z as UploadedFileInfo,U as UserMessage}from"./lib/__bundle-8cd94b6f.js"; +export{a4 as MentionType,a2 as MessageType,a7 as MessageTypeFilter,a9 as PushNotificationDeliveryOption,ag as ReplyType,a5 as SendingStatus}from"./lib/__bundle-75942676.js";export{r as AdminMessage,A as AppleCriticalAlertOptions,B as BaseMessage,F as FileMessage,d as MessageMetaArray,M as MessageModule,h as MessageRequestHandler,t as MessageSearchOrder,a as MessageSearchQuery,b as MultipleFilesMessage,g as MultipleFilesMessageRequestHandler,O as OGImage,u as OGMetaData,e as PreviousMessageListQuery,w as Reaction,R as ReactionEvent,x as ReactionEventOperation,f as Sender,y as ThreadInfo,s as ThreadInfoUpdateEvent,T as Thumbnail,z as UploadedFileInfo,U as UserMessage}from"./lib/__bundle-84f74e8d.js"; diff --git a/openChannel.js b/openChannel.js index ae8b29e..e91feec 100644 --- a/openChannel.js +++ b/openChannel.js @@ -1 +1 @@ -import{_ as e,b as n,c as t,$ as r,m as a,a as i,i as s,A as o,aP as u,aQ as l,f as c,h,e as d,a9 as p,U as f,W as v,w as C,x as _,J as y,t as m,aC as E,y as g,aD as U,ah as w,O as T,aF as N,s as b,S as M,g as P,aJ as O,al as H,V as x,a2 as D,n as I,B as A,am as L}from"./lib/__bundle-a8606dd4.js";import{q as R,r as F,t as k,w as S,u as q,x as Q,y as z,P as K,z as j,A as V,C as W,E as B,f as G}from"./lib/__bundle-e99277d8.js";import{C as X,a as J,O as Y,P as Z,M as $,T as ee,R as ne,U as te,A as re,B as ae}from"./lib/__bundle-6587ce7b.js";import{m as ie,c as se}from"./lib/__bundle-8cd94b6f.js";import{P as oe}from"./lib/__bundle-ad3243e0.js";import"./lib/__bundle-3707a8af.js";var ue=function(r){function a(){var e=null!==r&&r.apply(this,arguments)||this;return e._channels=new Map,e._enteredChannelUrls=[],e}return e(a,r),Object.defineProperty(a.prototype,"enteredChannels",{get:function(){var e=this;return this._enteredChannelUrls.map((function(n){return e._channels.get(n)})).filter((function(e){return null!==e}))},enumerable:!1,configurable:!0}),a.prototype.isEnteredChannel=function(e){return this._enteredChannelUrls.includes(e)},a.prototype.enter=function(e){this._enteredChannelUrls.indexOf(e)<0&&this._enteredChannelUrls.push(e)},a.prototype.exit=function(e){var n=this._enteredChannelUrls.indexOf(e);n>=0&&this._enteredChannelUrls.splice(n,1)},a.prototype.exitAll=function(){this._enteredChannelUrls=[]},a.prototype.get=function(e){var r;return n(this,void 0,void 0,(function(){return t(this,(function(n){return[2,null!==(r=this._channels.get(e))&&void 0!==r?r:null]}))}))},a.prototype.upsert=function(e){return n(this,void 0,void 0,(function(){var n,r=this;return t(this,(function(t){return n=[],e.forEach((function(e){if(r._channels.has(e.url)){var t=r._channels.get(e.url);Object.assign(t,e),n.push(t)}else r._channels.set(e.url,e),n.push(e)})),[2,n]}))}))},a.prototype.remove=function(e){return n(this,void 0,void 0,(function(){return t(this,(function(n){return this._channels.delete(e),this.exit(e),[2]}))}))},a.prototype.clear=function(){return n(this,void 0,void 0,(function(){return t(this,(function(e){return this._channels.clear(),this._enteredChannelUrls=[],[2]}))}))},a}(r),le={channelUrl:null,name:null,coverUrlOrImage:null,data:null,customType:null,operatorUserIds:null,isEphemeral:null},ce=function(n){function t(e){var t=e.channelUrl,r=e.isInternalCall,a=n.call(this)||this;return a.method=o.GET,a.path="".concat(r?u:l,"/").concat(encodeURIComponent(t)),a}return e(t,n),t}(c),he=function(n){function t(e,t){var r=n.call(this,e,t)||this;return r.channel=null,r.channel=new be(e,t),r}return e(t,n),t}(h),de=function(n){function t(e){var t=this,r=e.channelUrl,a=e.coverUrlOrImage,u=e.name,c=e.data,h=e.customType,p=e.operatorUserIds,f=e.isEphemeral;return(t=n.call(this)||this).method=o.POST,t.path=l,t.params=d({channel_url:r,cover_url:i("string",a)?a:null,cover_file:s(a)?a:null,name:u,data:c,custom_type:h,operators:p,is_ephemeral:f}),t}return e(t,n),t}(c);!function(n){function t(e,t){var r=n.call(this,e,t)||this;return r.channel=new be(e,t),r}e(t,n)}(h);var pe=function(n){function t(e){var t=e.channelUrl;return n.call(this,{code:"ENTR",payload:{channel_url:t},ackRequired:!0})||this}return e(t,n),t}(p),fe=function(n){function t(e,t,r){var a,i,s=this;return s=n.call(this,e,"SYEV",r)||this,r.data&&(s.participantCount=null!==(a=r.data.participant_count)&&void 0!==a?a:0,s.user=new f(e,r.data),s.ts=null!==(i=r.data.edge_ts)&&void 0!==i?i:0),s}return e(t,n),t}(X),ve=function(n){function t(e){var t=e.channelUrl;return n.call(this,{code:"EXIT",payload:{channel_url:t},ackRequired:!0})||this}return e(t,n),t}(p),Ce=function(n){function t(e,t,r){var a,i,s=this;return s=n.call(this,e,"EXIT",r)||this,r.data&&(s.participantCount=null!==(a=r.data.participant_count)&&void 0!==a?a:0,s.user=new f(e,r.data),s.ts=null!==(i=r.data.edge_ts)&&void 0!==i?i:0),s}return e(t,n),t}(X),_e={},ye=function(){function e(e,n){var t=n.sdkState,r=n.dispatcher,a=n.requestQueue,i=this;return _e[e]||(this._iid=e,this._sdkState=t,this._requestQueue=a,this._dispatcher=r,this._openChannelCache=new ue(e),this._openChannelHandlers=new Map,this._dispatcher.on((function(e){var n,t;if(e instanceof v)i._handleEvent(e);else if(e instanceof C&&e.stateType===_.CONNECTED){var r=i._openChannelCache.enteredChannels;try{for(var a=y(r),s=a.next();!s.done;s=a.next()){s.value.enter()}}catch(e){n={error:e}}finally{try{s&&!s.done&&(t=a.return)&&t.call(a)}finally{if(n)throw n.error}}}})),_e[e]=this),_e[e]}return e.of=function(e){return _e[e]},e.prototype.buildOpenChannelFromSerializedData=function(e){var n=m(e);return new be(this._iid,be.payloadify(n))},e.prototype.getChannelFromCache=function(e){return n(this,void 0,void 0,(function(){return t(this,(function(n){switch(n.label){case 0:return[4,this._openChannelCache.get(e)];case 1:return[2,n.sent()]}}))}))},e.prototype.upsertChannelsToCache=function(e){return n(this,void 0,void 0,(function(){return t(this,(function(n){switch(n.label){case 0:return[4,this._openChannelCache.upsert(e)];case 1:return[2,n.sent()]}}))}))},e.prototype.removeChannelsFromCache=function(e){return n(this,void 0,void 0,(function(){var n,r,a,i,s,o;return t(this,(function(t){switch(t.label){case 0:t.trys.push([0,5,6,7]),n=y(e),r=n.next(),t.label=1;case 1:return r.done?[3,4]:(a=r.value,[4,this._openChannelCache.remove(a)]);case 2:t.sent(),t.label=3;case 3:return r=n.next(),[3,1];case 4:return[3,7];case 5:return i=t.sent(),s={error:i},[3,7];case 6:try{r&&!r.done&&(o=n.return)&&o.call(n)}finally{if(s)throw s.error}return[7];case 7:return[2]}}))}))},e.prototype.setEnteredToCache=function(e){this._openChannelCache.enter(e.url)},e.prototype.setExitedToCache=function(e){this._openChannelCache.exit(e.url)},e.prototype._handleEvent=function(e){return n(this,void 0,void 0,(function(){var r,a,i,s,o,u,l,c,h,d,p,f,v,C,_,m,b,M,P,H,x,D,I,A,L,G,ae,se,oe,ue,le,ce,he,de,pe,ve,_e,ye,me,Ee,ge,Ue,we,Te,Ne,be,Me,Pe,Oe,He,xe,De,Ie,Ae,Le,Re,Fe,ke,Se,qe,Qe,ze,Ke,je,Ve,We,Be,Ge,Xe=this;return t(this,(function(Je){switch(Je.label){case 0:switch(Je.trys.push([0,57,,58]),e.code){case"MESG":case"FILE":case"ADMM":case"BRDM":return[3,1];case"MEDI":case"FEDI":case"AEDI":return[3,4];case"DELM":return[3,7];case"MRCT":return[3,10];case"MTHD":return[3,13];case"MCNT":return[3,16];case"PEDI":return[3,27];case"VOTE":return[3,30];case"SYEV":return[3,33]}return[3,56];case 1:return s=null,"MESG"===e.code?s=e.as(B):"FILE"===e.code?s=e.as(ie):"ADMM"!==e.code&&"BRDM"!=e.code||(s=e.as(re)),s?(r=s.message,a=s.isMentioned,r.channelType!==T.OPEN?[3,3]:[4,this.getChannel(r.channelUrl,!0)]):[3,3];case 2:i=Je.sent(),g((function(){return n(Xe,void 0,void 0,(function(){var e,n,s,o,u;return t(this,(function(t){try{for(e=y(this._openChannelHandlers.values()),n=e.next();!n.done;n=e.next())s=n.value,this._openChannelCache.isEnteredChannel(i.url)&&(s.onMessageReceived(i,r),a&&s.onMentionReceived(i,r))}catch(e){o={error:e}}finally{try{n&&!n.done&&(u=e.return)&&u.call(e)}finally{if(o)throw o.error}}return[2]}))}))})),Je.label=3;case 3:return[3,56];case 4:return s=null,"MEDI"===e.code?s=e.as(V):"FEDI"===e.code?s=e.as(W):"AEDI"===e.code&&(s=e.as(te)),s?(o=s.message,u=s.mentionCountChange,o.channelType!==T.OPEN?[3,6]:[4,this.getChannel(o.channelUrl,!0)]):[3,6];case 5:l=Je.sent(),g((function(){return n(Xe,void 0,void 0,(function(){var e,n,r,a,i;return t(this,(function(t){try{for(e=y(this._openChannelHandlers.values()),n=e.next();!n.done;n=e.next())r=n.value,this._openChannelCache.isEnteredChannel(l.url)&&(r.onMessageUpdated(l,o),u>0&&r.onMentionReceived(l,o))}catch(e){a={error:e}}finally{try{n&&!n.done&&(i=e.return)&&i.call(e)}finally{if(a)throw a.error}}return[2]}))}))})),Je.label=6;case 6:return[3,56];case 7:return c=e.as(j),le=c.channelUrl,ce=c.channelType,h=c.messageId,ce!==T.OPEN?[3,9]:[4,this.getChannel(le,!0)];case 8:d=Je.sent(),g((function(){return n(Xe,void 0,void 0,(function(){var e,n,r,a,i;return t(this,(function(t){try{for(e=y(this._openChannelHandlers.values()),n=e.next();!n.done;n=e.next())r=n.value,this._openChannelCache.isEnteredChannel(d.url)&&r.onMessageDeleted(d,h)}catch(e){a={error:e}}finally{try{n&&!n.done&&(i=e.return)&&i.call(e)}finally{if(a)throw a.error}}return[2]}))}))})),Je.label=9;case 9:return[3,56];case 10:return p=e.as(ne),le=p.channelUrl,ce=p.channelType,f=p.event,ce!==T.OPEN?[3,12]:[4,this.getChannel(le,!0)];case 11:v=Je.sent(),g((function(){return n(Xe,void 0,void 0,(function(){var e,n,r,a,i;return t(this,(function(t){try{for(e=y(this._openChannelHandlers.values()),n=e.next();!n.done;n=e.next())r=n.value,this._openChannelCache.isEnteredChannel(v.url)&&r.onReactionUpdated(v,f)}catch(e){a={error:e}}finally{try{n&&!n.done&&(i=e.return)&&i.call(e)}finally{if(a)throw a.error}}return[2]}))}))})),Je.label=12;case 12:return[3,56];case 13:return(C=e.as(ee).event).channelType!==T.OPEN?[3,15]:[4,this.getChannel(C.channelUrl,!0)];case 14:_=Je.sent(),g((function(){return n(Xe,void 0,void 0,(function(){var e,n,r,a,i;return t(this,(function(t){try{for(e=y(this._openChannelHandlers.values()),n=e.next();!n.done;n=e.next())r=n.value,this._openChannelCache.isEnteredChannel(_.url)&&r.onThreadInfoUpdated(_,C)}catch(e){a={error:e}}finally{try{n&&!n.done&&(i=e.return)&&i.call(e)}finally{if(a)throw a.error}}return[2]}))}))})),Je.label=15;case 15:return[3,56];case 16:m=e.as($).openChannelMemberCounts,b=[],Je.label=17;case 17:Je.trys.push([17,22,23,24]),M=y(m),P=M.next(),Je.label=18;case 18:return P.done?[3,21]:(H=P.value,le=H.channelUrl,ge=H.participantCount,x=H.updatedAt,[4,this.getChannelFromCache(le)]);case 19:(D=Je.sent())&&D._updateParticipantCount(ge,x)&&b.push(D),Je.label=20;case 20:return P=M.next(),[3,18];case 21:return[3,24];case 22:return I=Je.sent(),Be={error:I},[3,24];case 23:try{P&&!P.done&&(Ge=M.return)&&Ge.call(M)}finally{if(Be)throw Be.error}return[7];case 24:return b.length>0?[4,this.upsertChannelsToCache(b)]:[3,26];case 25:A=Je.sent(),g((function(){return n(Xe,void 0,void 0,(function(){var e,n,r,a;return t(this,(function(t){try{for(e=y(this._openChannelHandlers.values()),n=e.next();!n.done;n=e.next())n.value.onChannelMemberCountChanged(A)}catch(e){r={error:e}}finally{try{n&&!n.done&&(a=e.return)&&a.call(e)}finally{if(r)throw r.error}}return[2]}))}))})),Je.label=26;case 26:return[3,56];case 27:return L=e.as(Z),G=L.event,ae=L.status,le=L.channelUrl,ce=L.channelType,le&&ce===T.OPEN?[4,this.getChannel(le,!0)]:[3,29];case 28:se=Je.sent(),this._dispatcher.dispatch(new N({event:G,source:w.EVENT_POLL_UPDATED})),g(ae===O?function(){return n(Xe,void 0,void 0,(function(){var e,n,r,a;return t(this,(function(t){try{for(e=y(this._openChannelHandlers.values()),n=e.next();!n.done;n=e.next())n.value.onPollDeleted(se,G.pollId)}catch(e){r={error:e}}finally{try{n&&!n.done&&(a=e.return)&&a.call(e)}finally{if(r)throw r.error}}return[2]}))}))}:function(){return n(Xe,void 0,void 0,(function(){var e,n,r,a;return t(this,(function(t){try{for(e=y(this._openChannelHandlers.values()),n=e.next();!n.done;n=e.next())n.value.onPollUpdated(se,G)}catch(e){r={error:e}}finally{try{n&&!n.done&&(a=e.return)&&a.call(e)}finally{if(r)throw r.error}}return[2]}))}))}),Je.label=29;case 29:return[3,56];case 30:return oe=e.as(K),ue=oe.event,le=oe.channelUrl,ce=oe.channelType,le&&ce===T.OPEN?[4,this.getChannel(le,!0)]:[3,32];case 31:he=Je.sent(),this._dispatcher.dispatch(new U({event:ue,source:w.EVENT_POLL_VOTED})),g((function(){return n(Xe,void 0,void 0,(function(){var e,n,r,a;return t(this,(function(t){try{for(e=y(this._openChannelHandlers.values()),n=e.next();!n.done;n=e.next())n.value.onPollVoted(he,ue)}catch(e){r={error:e}}finally{try{n&&!n.done&&(a=e.return)&&a.call(e)}finally{if(r)throw r.error}}return[2]}))}))})),Je.label=32;case 32:return[3,56];case 33:if(!(de=e.as(X).event).isOpenChannelEvent)return[3,55];switch(de.category){case J.CHANNEL_ENTER:return[3,34];case J.CHANNEL_EXIT:return[3,36];case J.CHANNEL_OPERATOR_UPDATE:return[3,38];case J.USER_CHANNEL_MUTE:case J.USER_CHANNEL_UNMUTE:return[3,40];case J.USER_CHANNEL_BAN:case J.USER_CHANNEL_UNBAN:return[3,42];case J.CHANNEL_FREEZE:case J.CHANNEL_UNFREEZE:return[3,44];case J.CHANNEL_DELETED:return[3,46];case J.CHANNEL_PROP_CHANGED:return[3,49];case J.CHANNEL_META_DATA_CHANGED:return[3,51];case J.CHANNEL_META_COUNTERS_CHANGED:return[3,53]}return[3,55];case 34:return[4,this.getChannel(de.channelUrl,!0)];case 35:return pe=Je.sent(),ve=e.as(fe),ge=ve.participantCount,_e=ve.user,ye=pe._updateParticipantCount(ge,de.ts),g((function(){return n(Xe,void 0,void 0,(function(){return t(this,(function(e){return this._openChannelHandlers.forEach((function(e){e.onUserEntered(pe,_e),ye&&e.onChannelParticipantCountChanged(pe)})),[2]}))}))})),[3,55];case 36:return[4,this.getChannel(de.channelUrl,!0)];case 37:return me=Je.sent(),Ee=e.as(Ce),ge=Ee.participantCount,Ue=Ee.user,we=me._updateParticipantCount(ge,de.ts),g((function(){return n(Xe,void 0,void 0,(function(){return t(this,(function(e){return this._openChannelHandlers.forEach((function(e){e.onUserExited(me,Ue),we&&e.onChannelParticipantCountChanged(me)})),[2]}))}))})),[3,55];case 38:return[4,this.getChannel(de.channelUrl,!0)];case 39:return Te=Je.sent(),Ne=e.as(Y).operators,Te.operators=Ne,this.upsertChannelsToCache([Te]),g((function(){return n(Xe,void 0,void 0,(function(){return t(this,(function(e){return this._openChannelHandlers.forEach((function(e){e.onOperatorUpdated(Te,Ne)})),[2]}))}))})),[3,55];case 40:return[4,this.getChannel(de.channelUrl,!0)];case 41:return be=Je.sent(),Me=de.category===J.USER_CHANNEL_MUTE,Pe=e.as(Me?Q:z).user,g((function(){return n(Xe,void 0,void 0,(function(){return t(this,(function(e){return this._openChannelHandlers.forEach((function(e){Me?e.onUserMuted(be,Pe):e.onUserUnmuted(be,Pe)})),[2]}))}))})),[3,55];case 42:return[4,this.getChannel(de.channelUrl,!0)];case 43:return Oe=Je.sent(),He=de.category===J.USER_CHANNEL_BAN,xe=e.as(He?S:q).user,g((function(){return n(Xe,void 0,void 0,(function(){return t(this,(function(e){return this._openChannelHandlers.forEach((function(e){He?e.onUserBanned(Oe,xe):e.onUserUnbanned(Oe,xe)})),[2]}))}))})),[3,55];case 44:return[4,this.getChannel(de.channelUrl,!0)];case 45:return De=Je.sent(),Ie=e.as(k).freeze,De.isFrozen=Ie,this.upsertChannelsToCache([De]),g((function(){return n(Xe,void 0,void 0,(function(){return t(this,(function(e){return this._openChannelHandlers.forEach((function(e){Ie?e.onChannelFrozen(De):e.onChannelUnfrozen(De)})),[2]}))}))})),[3,55];case 46:return[4,this.getChannel(de.channelUrl,!0)];case 47:return Ae=Je.sent(),[4,this.removeChannelsFromCache([Ae.url])];case 48:return Je.sent(),g((function(){return n(Xe,void 0,void 0,(function(){return t(this,(function(e){return this._openChannelHandlers.forEach((function(e){e.onChannelDeleted(Ae.url,Ae.channelType)})),[2]}))}))})),[3,55];case 49:return[4,this.getChannelWithoutCache(de.channelUrl,!0)];case 50:return Le=Je.sent(),g((function(){return n(Xe,void 0,void 0,(function(){return t(this,(function(e){return this._openChannelHandlers.forEach((function(e){e.onChannelChanged(Le)})),[2]}))}))})),[3,55];case 51:return[4,this.getChannel(de.channelUrl,!0)];case 52:return Re=Je.sent(),Fe=e.as(F),ke=Fe.created,Se=Fe.updated,qe=Fe.deleted,ke&&Re._upsertCachedMetaData(ke,de.ts),Se&&Re._upsertCachedMetaData(Se,de.ts),qe&&Re._removeFromCachedMetaData(qe,de.ts),g((function(){return n(Xe,void 0,void 0,(function(){return t(this,(function(e){return this._openChannelHandlers.forEach((function(e){ke&&e.onMetaDataCreated(Re,ke),Se&&e.onMetaDataUpdated(Re,Se),qe&&e.onMetaDataDeleted(Re,qe)})),[2]}))}))})),[3,55];case 53:return[4,this.getChannel(de.channelUrl,!0)];case 54:return Qe=Je.sent(),ze=e.as(R),Ke=ze.created,je=ze.updated,Ve=ze.deleted,g((function(){return n(Xe,void 0,void 0,(function(){return t(this,(function(e){return this._openChannelHandlers.forEach((function(e){Ke&&e.onMetaCounterCreated(Qe,Ke),je&&e.onMetaCounterUpdated(Qe,je),Ve&&e.onMetaCounterDeleted(Qe,Ve)})),[2]}))}))})),[3,55];case 55:return[3,56];case 56:return[3,58];case 57:if(We=Je.sent(),E(We))throw We;return[3,58];case 58:return[2]}}))}))},e.prototype.addHandler=function(e,n){this._openChannelHandlers.set(e,n)},e.prototype.removeHandler=function(e){this._openChannelHandlers.delete(e)},e.prototype.clearHandler=function(){this._openChannelHandlers.clear()},e.prototype.getChannel=function(e,r){return n(this,void 0,void 0,(function(){var n;return t(this,(function(t){switch(t.label){case 0:b(i("string",e)).throw(M.invalidParameters),t.label=1;case 1:return t.trys.push([1,3,,4]),[4,this.getChannelFromCache(e)];case 2:return(n=t.sent())?[2,n]:[3,4];case 3:return t.sent(),[3,4];case 4:return[4,this.getChannelWithoutCache(e)];case 5:return[2,t.sent()]}}))}))},e.prototype.getChannelWithoutCache=function(e,r){return void 0===r&&(r=!1),n(this,void 0,void 0,(function(){var n,a,s;return t(this,(function(t){switch(t.label){case 0:return b(i("string",e)).throw(M.invalidParameters),n=new ce({channelUrl:e,isInternalCall:r}),[4,this._requestQueue.send(n)];case 1:return a=t.sent(),s=a.as(he).channel,[4,this.upsertChannelsToCache([s])];case 2:return[2,t.sent()[0]]}}))}))},e.prototype.createChannel=function(e){return n(this,void 0,void 0,(function(){var n,r,o,u;return t(this,(function(t){switch(t.label){case 0:return n=P(P({},le),e),b(function(e){return a("string",e.operatorUserIds,!0)&&(i("string",e.coverUrlOrImage)||s(e.coverUrlOrImage)||null===e.coverUrlOrImage)&&i("string",e.name,!0)&&i("string",e.data,!0)&&i("string",e.customType,!0)&&(i("string",e.channelUrl)&&/^\w+$/.test(e.channelUrl)||null===e.channelUrl)&&i("boolean",e.isEphemeral,!0)}(n)).throw(M.invalidParameters),r=new de(n),[4,this._requestQueue.send(r)];case 1:return o=t.sent(),u=o.as(he).channel,this.upsertChannelsToCache([u]),[2,u]}}))}))},e}(),me={name:null,coverUrlOrImage:null,data:null,customType:null,operatorUserIds:null},Ee=function(n){function t(e){var t=this,r=e.channelUrl,a=e.token,i=e.limit;return(t=n.call(this)||this).method=o.GET,t.path="".concat(l,"/").concat(encodeURIComponent(r),"/participants"),t.params={token:a,limit:i},t}return e(t,n),t}(c),ge=function(n){function t(e,t){var r=n.call(this,e,t)||this;r.token=null,r.participants=[];var a=t.next,i=t.participants;return r.token=a,r.participants=i.map((function(n){return new oe(e,n)})),r}return e(t,n),t}(h),Ue=function(r){function a(e,n,t){return r.call(this,e,n,T.OPEN,t)||this}return e(a,r),a.prototype._validate=function(){return r.prototype._validate.call(this)},a.prototype.next=function(){return n(this,void 0,void 0,(function(){var e,n,r,a,i,s;return t(this,(function(t){switch(t.label){case 0:return this._validate()?this._isLoading?[3,3]:this._hasNext?(this._isLoading=!0,e=x.of(this._iid).requestQueue,n=new Ee(P(P({},this),{token:this._token})),[4,e.send(n)]):[3,2]:[3,5];case 1:return r=t.sent(),a=r.as(ge),i=a.participants,s=a.token,this._token=s,this._hasNext=!!s,this._isLoading=!1,[2,i];case 2:return[2,[]];case 3:throw M.queryInProgress;case 4:return[3,6];case 5:throw M.invalidParameters;case 6:return[2]}}))}))},a}(H),we=function(n){function t(e){var t=this,r=e.channelUrl,a=e.coverUrlOrImage,u=e.name,c=e.data,h=e.customType,p=e.operatorUserIds;return(t=n.call(this)||this).method=o.PUT,t.path="".concat(l,"/").concat(encodeURIComponent(r)),t.params=d({cover_url:i("string",a)?a:null,cover_file:s(a)?a:null,name:u,data:c,custom_type:h,operators:p}),t}return e(t,n),t}(c),Te=function(n){function t(e,t){var r=n.call(this,e,t)||this;return r.channel=new be(e,t),r}return e(t,n),t}(h),Ne=function(n){function t(e){var t=this,r=e.channelUrl;return(t=n.call(this)||this).method=o.DELETE,t.path="".concat(l,"/").concat(encodeURIComponent(r)),t}return e(t,n),t}(c);!function(n){function t(e,t){return n.call(this,e,t)||this}e(t,n)}(h);var be=function(r){function o(e,n){var t,a=this;return(a=r.call(this,e,n)||this)._lastParticipantCountUpdated=0,a.participantCount=0,a.operators=[],a.channelType=T.OPEN,a.participantCount=null!==(t=n.participant_count)&&void 0!==t?t:0,a.operators=Array.isArray(n.operators)?n.operators.map((function(n){return new f(e,n)})):[],a}return e(o,r),o.payloadify=function(e){return e?d(P(P({},G.payloadify(e)),{participant_count:e.participantCount,operators:e.operators.map((function(e){return f.payloadify(e)}))})):null},o.prototype.serialize=function(){return D(this)},o.prototype.isOperator=function(e){return e instanceof f?this.isOperator(e.userId):this.operators.some((function(n){return n.userId===e}))},o.prototype._updateParticipantCount=function(e,n){return n>this._lastParticipantCountUpdated&&(this.participantCount=e,this._lastParticipantCountUpdated=n,!0)},o.prototype.createParticipantListQuery=function(e){return new Ue(this._iid,this.url,e)},o.prototype.refresh=function(){return n(this,void 0,void 0,(function(){return t(this,(function(e){switch(e.label){case 0:return[4,ye.of(this._iid).getChannelWithoutCache(this.url)];case 1:return[2,e.sent()]}}))}))},o.prototype.enter=function(){return n(this,void 0,void 0,(function(){var e,n,r,a,i,s;return t(this,(function(t){switch(t.label){case 0:return e=x.of(this._iid).requestQueue,n=new pe({channelUrl:this.url}),[4,e.send(n)];case 1:return r=t.sent(),a=r.as(fe),i=a.participantCount,s=a.ts,this._updateParticipantCount(i,s),ye.of(this._iid).setEnteredToCache(this),[2]}}))}))},o.prototype.exit=function(){return n(this,void 0,void 0,(function(){var e,n,r,a,i,s;return t(this,(function(t){switch(t.label){case 0:return e=x.of(this._iid).requestQueue,n=new ve({channelUrl:this.url}),[4,e.send(n)];case 1:return r=t.sent(),a=r.as(Ce),i=a.participantCount,s=a.ts,this._updateParticipantCount(i,s),ye.of(this._iid).setExitedToCache(this),se.of(this._iid).fileMessageQueue.cancel(this),[2]}}))}))},o.prototype.updateChannel=function(e){return n(this,void 0,void 0,(function(){var n,r,o,u,l;return t(this,(function(t){switch(t.label){case 0:return n=P(P({},me),e),b(function(e){return a("string",e.operatorUserIds,!0)&&(i("string",e.coverUrlOrImage)||s(e.coverUrlOrImage)||null===e.coverUrlOrImage)&&i("string",e.name,!0)&&i("string",e.data,!0)&&i("string",e.customType,!0)}(n)).throw(M.invalidParameters),r=x.of(this._iid).requestQueue,o=new we(P({channelUrl:this.url},n)),[4,r.send(o)];case 1:return u=t.sent(),l=u.as(Te).channel,this._update(l),[4,ye.of(this._iid).upsertChannelsToCache([l])];case 2:return t.sent(),[2,this]}}))}))},o.prototype.updateChannelWithOperatorUserIds=function(e,r,a,i,s){return n(this,void 0,void 0,(function(){var n;return t(this,(function(t){return n=P(P({},me),{name:e,coverUrlOrImage:r,data:a,operatorUserIds:i,customType:s}),[2,this.updateChannel(n)]}))}))},o.prototype.delete=function(){return n(this,void 0,void 0,(function(){var e,n;return t(this,(function(t){switch(t.label){case 0:return e=x.of(this._iid).requestQueue,n=new Ne({channelUrl:this.url}),[4,e.send(n)];case 1:return t.sent(),[4,ye.of(this._iid).removeChannelsFromCache([this.url])];case 2:return t.sent(),[2]}}))}))},o.prototype.sendUserMessage=function(e){return b(!e.isPinnedMessage).throw(M.notSupportedError),r.prototype.sendUserMessage.call(this,e)},o.prototype.sendFileMessage=function(e){return b(!e.isPinnedMessage).throw(M.notSupportedError),r.prototype.sendFileMessage.call(this,e)},o}(G),Me=function(n){function t(e){void 0===e&&(e={});var t=n.call(this)||this;return Object.keys(e).forEach((function(n){t.hasOwnProperty(n)&&(t[n]=e[n])})),t}return e(t,n),t}(function(n){function t(){var e=null!==n&&n.apply(this,arguments)||this;return e.onUserEntered=I,e.onUserExited=I,e.onChannelParticipantCountChanged=I,e.onPollUpdated=I,e.onPollVoted=I,e.onPollDeleted=I,e}return e(t,n),t}(ae)),Pe=function(n){function t(e){var t=this,r=e.token,a=e.limit,i=e.nameKeyword,s=e.urlKeyword,u=e.customTypes,c=e.includeFrozen,h=e.includeMetaData;return(t=n.call(this)||this).method=o.GET,t.path=l,t.params=d({token:r,limit:a,name_contains:i,url_contains:s,custom_types:u,show_frozen:c,show_metadata:h}),t}return e(t,n),t}(c),Oe=function(n){function t(e,t){var r=n.call(this,e,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(n){return new be(e,n)}))),r.ts="number"==typeof s?s:null,r}return e(t,n),t}(h),He=function(r){function s(e,n){var t,a,i,s,o,u=this;return(u=r.call(this,e,n)||this).includeFrozen=!0,u.includeMetaData=!0,u.nameKeyword=null,u.urlKeyword=null,u.customTypes=null,u.includeFrozen=null===(t=n.includeFrozen)||void 0===t||t,u.includeMetaData=null===(a=n.includeMetaData)||void 0===a||a,u.nameKeyword=null!==(i=n.nameKeyword)&&void 0!==i?i:null,u.urlKeyword=null!==(s=n.urlKeyword)&&void 0!==s?s:null,u.customTypes=null!==(o=n.customTypes)&&void 0!==o?o:null,u}return e(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 n(this,void 0,void 0,(function(){var e,n,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,e=x.of(this._iid).requestQueue,n=new Pe(P(P({},this),{token:this._token})),[4,e.send(n)]):[3,3]:[3,6];case 1:return r=t.sent(),a=r.as(Oe),i=a.channels,s=a.token,this._token=s,this._hasNext=!!s,[4,ye.of(this._iid).upsertChannelsToCache(i)];case 2:return t.sent(),this._isLoading=!1,[2,i];case 3:return[2,[]];case 4:throw M.queryInProgress;case 5:return[3,7];case 6:throw M.invalidParameters;case 7:return[2]}}))}))},s}(A),xe=function(r){function a(){var e=null!==r&&r.apply(this,arguments)||this;return e.name="openChannel",e}return e(a,r),a.prototype.init=function(e,n){var t=n.sdkState,a=n.dispatcher,i=n.sessionManager,s=n.requestQueue,o=n.logger,u=n.onlineDetector,l=n.cacheContext;r.prototype.init.call(this,e,{sdkState:t,dispatcher:a,sessionManager:i,requestQueue:s,logger:o,onlineDetector:u,cacheContext:l}),this._manager=new ye(e,{sdkState:t,dispatcher:a,requestQueue:s})},a.prototype.createOpenChannelListQuery=function(e){return void 0===e&&(e={}),new He(this._iid,e)},a.prototype.addOpenChannelHandler=function(e,n){this._manager.addHandler(e,n)},a.prototype.removeOpenChannelHandler=function(e){this._manager.removeHandler(e)},a.prototype.removeAllOpenChannelHandlers=function(){this._manager.clearHandler()},a.prototype.buildOpenChannelFromSerializedData=function(e){return this._manager.buildOpenChannelFromSerializedData(e)},a.prototype.getChannel=function(e){return n(this,void 0,void 0,(function(){return t(this,(function(n){return[2,this._manager.getChannel(e)]}))}))},a.prototype.getChannelWithoutCache=function(e){return n(this,void 0,void 0,(function(){return t(this,(function(n){return[2,this._manager.getChannelWithoutCache(e)]}))}))},a.prototype.createChannel=function(e){return void 0===e&&(e={}),n(this,void 0,void 0,(function(){return t(this,(function(n){return[2,this._manager.createChannel(e)]}))}))},a.prototype.createChannelWithOperatorUserIds=function(e,r,a,i,s){return n(this,void 0,void 0,(function(){var n;return t(this,(function(t){return(n=P({},le)).name=e,n.coverUrlOrImage=r,n.data=a,n.operatorUserIds=i,n.customType=s,[2,this._manager.createChannel(n)]}))}))},a}(L);export{be as OpenChannel,Me as OpenChannelHandler,He as OpenChannelListQuery,xe as OpenChannelModule,Ue as ParticipantListQuery}; +import{_ as e,b as n,c as t,a0 as r,m as a,a as i,i as o,A as s,aQ as u,aR as c,f as l,h,e as d,u as p,aa as f,U as v,W as C,x as _,y,K as m,w as U,aD as E,z as g,aE as w,ai as T,Q as M,aG as b,t as N,S as P,g as D,aK as H,am as O,V as x,a3 as I,n as A,B as R,an as L}from"./lib/__bundle-75942676.js";import{q as F,r as S,t as k,w as q,u as z,x as Q,y as K,P as V,z as j,A as B,C as G,E as W,f as X}from"./lib/__bundle-e875840b.js";import{C as Y,a as Z,O as $,P as J,M as ee,T as ne,R as te,U as re,A as ae,B as ie}from"./lib/__bundle-361d5a90.js";import{m as oe,c as se}from"./lib/__bundle-84f74e8d.js";import{P as ue}from"./lib/__bundle-8fdac8b9.js";import"./lib/__bundle-ad161b2c.js";var ce=function(r){function a(){var e=null!==r&&r.apply(this,arguments)||this;return e._channels=new Map,e._enteredChannelUrls=[],e}return e(a,r),Object.defineProperty(a.prototype,"enteredChannels",{get:function(){var e=this;return this._enteredChannelUrls.map((function(n){return e._channels.get(n)})).filter((function(e){return!!e}))},enumerable:!1,configurable:!0}),a.prototype.isEnteredChannel=function(e){return this._enteredChannelUrls.includes(e)},a.prototype.enter=function(e){this._enteredChannelUrls.indexOf(e)<0&&this._enteredChannelUrls.push(e)},a.prototype.exit=function(e){var n=this._enteredChannelUrls.indexOf(e);n>=0&&this._enteredChannelUrls.splice(n,1)},a.prototype.exitAll=function(){this._enteredChannelUrls=[]},a.prototype.get=function(e){return n(this,void 0,void 0,(function(){return t(this,(function(n){return[2,this._channels.get(e)]}))}))},a.prototype.upsert=function(e){return n(this,void 0,void 0,(function(){var n,r=this;return t(this,(function(t){return n=[],e.forEach((function(e){if(r._channels.has(e.url)){var t=r._channels.get(e.url);Object.assign(t,e),n.push(t)}else r._channels.set(e.url,e),n.push(e)})),[2,n]}))}))},a.prototype.remove=function(e){return n(this,void 0,void 0,(function(){return t(this,(function(n){return this._channels.delete(e),this.exit(e),[2]}))}))},a.prototype.clear=function(){return n(this,void 0,void 0,(function(){return t(this,(function(e){return this._channels.clear(),this._enteredChannelUrls=[],[2]}))}))},a}(r),le={channelUrl:void 0,name:void 0,coverUrlOrImage:void 0,data:void 0,customType:void 0,operatorUserIds:void 0,isEphemeral:void 0},he=function(n){function t(e){var t=e.channelUrl,r=e.isInternalCall,a=n.call(this)||this;return a.method=s.GET,a.path="".concat(r?u:c,"/").concat(encodeURIComponent(t)),a}return e(t,n),t}(l),de=function(n){function t(e,t){var r=n.call(this,e,t)||this;return r.channel=new Ne(e,t),r}return e(t,n),t}(h),pe=function(n){function t(e){var t=this,r=e.channelUrl,a=e.coverUrlOrImage,u=e.name,l=e.data,h=e.customType,f=e.operatorUserIds,v=e.isEphemeral;return(t=n.call(this)||this).method=s.POST,t.path=c,t.params=d(p({channel_url:r,cover_url:i("string",a)?a:null,cover_file:o(a)?a:null,name:u,data:l,custom_type:h,operators:f,is_ephemeral:v})),t}return e(t,n),t}(l);!function(n){function t(e,t){var r=n.call(this,e,t)||this;return r.channel=new Ne(e,t),r}e(t,n)}(h);var fe=function(n){function t(e){var t=e.channelUrl;return n.call(this,{code:"ENTR",payload:{channel_url:t},ackRequired:!0})||this}return e(t,n),t}(f),ve=function(n){function t(e,t,r){var a,i,o=this;return o=n.call(this,e,"SYEV",r)||this,r.data&&(o.participantCount=null!==(a=r.data.participant_count)&&void 0!==a?a:0,o.user=new v(e,r.data),o.ts=null!==(i=r.data.edge_ts)&&void 0!==i?i:0),o}return e(t,n),t}(Y),Ce=function(n){function t(e){var t=e.channelUrl;return n.call(this,{code:"EXIT",payload:{channel_url:t},ackRequired:!0})||this}return e(t,n),t}(f),_e=function(n){function t(e,t,r){var a,i,o=this;return o=n.call(this,e,"EXIT",r)||this,r.data&&(o.participantCount=null!==(a=r.data.participant_count)&&void 0!==a?a:0,o.user=new v(e,r.data),o.ts=null!==(i=r.data.edge_ts)&&void 0!==i?i:0),o}return e(t,n),t}(Y),ye={},me=function(){function e(e,n){var t=n.sdkState,r=n.dispatcher,a=n.requestQueue,i=this;return ye[e]||(this._iid=e,this._sdkState=t,this._requestQueue=a,this._dispatcher=r,this._openChannelCache=new ce(e),this._openChannelHandlers=new Map,this._dispatcher.on((function(e){var n,t;if(e instanceof C)i._handleEvent(e);else if(e instanceof _&&e.stateType===y.CONNECTED){var r=i._openChannelCache.enteredChannels;try{for(var a=m(r),o=a.next();!o.done;o=a.next()){o.value.enter()}}catch(e){n={error:e}}finally{try{o&&!o.done&&(t=a.return)&&t.call(a)}finally{if(n)throw n.error}}}})),ye[e]=this),ye[e]}return e.of=function(e){return ye[e]},e.prototype.buildOpenChannelFromSerializedData=function(e){var n=U(e);return new Ne(this._iid,Ne.payloadify(n))},e.prototype.getChannelFromCache=function(e){var r;return n(this,void 0,void 0,(function(){return t(this,(function(n){switch(n.label){case 0:return[4,this._openChannelCache.get(e)];case 1:return[2,null!==(r=n.sent())&&void 0!==r?r:null]}}))}))},e.prototype.upsertChannelsToCache=function(e){return n(this,void 0,void 0,(function(){return t(this,(function(n){switch(n.label){case 0:return[4,this._openChannelCache.upsert(e)];case 1:return[2,n.sent()]}}))}))},e.prototype.removeChannelsFromCache=function(e){return n(this,void 0,void 0,(function(){var n,r,a,i,o,s;return t(this,(function(t){switch(t.label){case 0:t.trys.push([0,5,6,7]),n=m(e),r=n.next(),t.label=1;case 1:return r.done?[3,4]:(a=r.value,[4,this._openChannelCache.remove(a)]);case 2:t.sent(),t.label=3;case 3:return r=n.next(),[3,1];case 4:return[3,7];case 5:return i=t.sent(),o={error:i},[3,7];case 6:try{r&&!r.done&&(s=n.return)&&s.call(n)}finally{if(o)throw o.error}return[7];case 7:return[2]}}))}))},e.prototype.setEnteredToCache=function(e){this._openChannelCache.enter(e.url)},e.prototype.setExitedToCache=function(e){this._openChannelCache.exit(e.url)},e.prototype._handleEvent=function(e){return n(this,void 0,void 0,(function(){var r,a,i,o,s,u,c,l,h,d,p,f,v,C,_,y,U,N,P,D,O,x,I,A,R,L,X,ie,se,ue,ce,le,he,de,pe,fe,Ce,ye,me,Ue,Ee,ge,we,Te,Me,be,Ne,Pe,De,He,Oe,xe,Ie,Ae,Re,Le,Fe,Se,ke,qe,ze,Qe,Ke,Ve,je,Be,Ge,We,Xe=this;return t(this,(function(Ye){switch(Ye.label){case 0:switch(Ye.trys.push([0,57,,58]),e.code){case"MESG":case"FILE":case"ADMM":case"BRDM":return[3,1];case"MEDI":case"FEDI":case"AEDI":return[3,4];case"DELM":return[3,7];case"MRCT":return[3,10];case"MTHD":return[3,13];case"MCNT":return[3,16];case"PEDI":return[3,27];case"VOTE":return[3,30];case"SYEV":return[3,33]}return[3,56];case 1:return o=null,"MESG"===e.code?o=e.as(W):"FILE"===e.code?o=e.as(oe):"ADMM"!==e.code&&"BRDM"!=e.code||(o=e.as(ae)),o?(r=o.message,a=o.isMentioned,r.channelType!==M.OPEN?[3,3]:[4,this.getChannel(r.channelUrl,!0)]):[3,3];case 2:i=Ye.sent(),g((function(){return n(Xe,void 0,void 0,(function(){var e,n,o,s,u;return t(this,(function(t){try{for(e=m(this._openChannelHandlers.values()),n=e.next();!n.done;n=e.next())o=n.value,this._openChannelCache.isEnteredChannel(i.url)&&(o.onMessageReceived&&o.onMessageReceived(i,r),a&&o.onMentionReceived&&o.onMentionReceived(i,r))}catch(e){s={error:e}}finally{try{n&&!n.done&&(u=e.return)&&u.call(e)}finally{if(s)throw s.error}}return[2]}))}))})),Ye.label=3;case 3:return[3,56];case 4:return o=null,"MEDI"===e.code?o=e.as(B):"FEDI"===e.code?o=e.as(G):"AEDI"===e.code&&(o=e.as(re)),o?(s=o.message,u=o.mentionCountChange,s.channelType!==M.OPEN?[3,6]:[4,this.getChannel(s.channelUrl,!0)]):[3,6];case 5:c=Ye.sent(),g((function(){return n(Xe,void 0,void 0,(function(){var e,n,r,a,i;return t(this,(function(t){try{for(e=m(this._openChannelHandlers.values()),n=e.next();!n.done;n=e.next())r=n.value,this._openChannelCache.isEnteredChannel(c.url)&&(r.onMessageUpdated&&r.onMessageUpdated(c,s),u>0&&r.onMentionReceived&&r.onMentionReceived(c,s))}catch(e){a={error:e}}finally{try{n&&!n.done&&(i=e.return)&&i.call(e)}finally{if(a)throw a.error}}return[2]}))}))})),Ye.label=6;case 6:return[3,56];case 7:return l=e.as(j),ce=l.channelUrl,le=l.channelType,h=l.messageId,le!==M.OPEN?[3,9]:[4,this.getChannel(ce,!0)];case 8:d=Ye.sent(),g((function(){return n(Xe,void 0,void 0,(function(){var e,n,r,a,i;return t(this,(function(t){try{for(e=m(this._openChannelHandlers.values()),n=e.next();!n.done;n=e.next())r=n.value,this._openChannelCache.isEnteredChannel(d.url)&&r.onMessageDeleted&&r.onMessageDeleted(d,h)}catch(e){a={error:e}}finally{try{n&&!n.done&&(i=e.return)&&i.call(e)}finally{if(a)throw a.error}}return[2]}))}))})),Ye.label=9;case 9:return[3,56];case 10:return p=e.as(te),ce=p.channelUrl,le=p.channelType,f=p.event,le!==M.OPEN?[3,12]:[4,this.getChannel(ce,!0)];case 11:v=Ye.sent(),g((function(){return n(Xe,void 0,void 0,(function(){var e,n,r,a,i;return t(this,(function(t){try{for(e=m(this._openChannelHandlers.values()),n=e.next();!n.done;n=e.next())r=n.value,this._openChannelCache.isEnteredChannel(v.url)&&r.onReactionUpdated&&r.onReactionUpdated(v,f)}catch(e){a={error:e}}finally{try{n&&!n.done&&(i=e.return)&&i.call(e)}finally{if(a)throw a.error}}return[2]}))}))})),Ye.label=12;case 12:return[3,56];case 13:return(C=e.as(ne).event).channelType!==M.OPEN?[3,15]:[4,this.getChannel(C.channelUrl,!0)];case 14:_=Ye.sent(),g((function(){return n(Xe,void 0,void 0,(function(){var e,n,r,a,i;return t(this,(function(t){try{for(e=m(this._openChannelHandlers.values()),n=e.next();!n.done;n=e.next())r=n.value,this._openChannelCache.isEnteredChannel(_.url)&&r.onThreadInfoUpdated&&r.onThreadInfoUpdated(_,C)}catch(e){a={error:e}}finally{try{n&&!n.done&&(i=e.return)&&i.call(e)}finally{if(a)throw a.error}}return[2]}))}))})),Ye.label=15;case 15:return[3,56];case 16:y=e.as(ee).openChannelMemberCounts,U=[],Ye.label=17;case 17:Ye.trys.push([17,22,23,24]),N=m(y),P=N.next(),Ye.label=18;case 18:return P.done?[3,21]:(D=P.value,ce=D.channelUrl,Ee=D.participantCount,O=D.updatedAt,[4,this.getChannelFromCache(ce)]);case 19:(x=Ye.sent())&&x._updateParticipantCount(Ee,O)&&U.push(x),Ye.label=20;case 20:return P=N.next(),[3,18];case 21:return[3,24];case 22:return I=Ye.sent(),Ge={error:I},[3,24];case 23:try{P&&!P.done&&(We=N.return)&&We.call(N)}finally{if(Ge)throw Ge.error}return[7];case 24:return U.length>0?[4,this.upsertChannelsToCache(U)]:[3,26];case 25:A=Ye.sent(),g((function(){return n(Xe,void 0,void 0,(function(){var e,n,r,a,i;return t(this,(function(t){try{for(e=m(this._openChannelHandlers.values()),n=e.next();!n.done;n=e.next())(r=n.value).onChannelMemberCountChanged&&r.onChannelMemberCountChanged(A)}catch(e){a={error:e}}finally{try{n&&!n.done&&(i=e.return)&&i.call(e)}finally{if(a)throw a.error}}return[2]}))}))})),Ye.label=26;case 26:return[3,56];case 27:return R=e.as(J),L=R.event,X=R.status,ce=R.channelUrl,le=R.channelType,ce&&le===M.OPEN?[4,this.getChannel(ce,!0)]:[3,29];case 28:ie=Ye.sent(),this._dispatcher.dispatch(new b({event:L,source:T.EVENT_POLL_UPDATED})),g(X===H?function(){return n(Xe,void 0,void 0,(function(){var e,n,r,a,i;return t(this,(function(t){try{for(e=m(this._openChannelHandlers.values()),n=e.next();!n.done;n=e.next())(r=n.value).onPollDeleted&&r.onPollDeleted(ie,L.pollId)}catch(e){a={error:e}}finally{try{n&&!n.done&&(i=e.return)&&i.call(e)}finally{if(a)throw a.error}}return[2]}))}))}:function(){return n(Xe,void 0,void 0,(function(){var e,n,r,a,i;return t(this,(function(t){try{for(e=m(this._openChannelHandlers.values()),n=e.next();!n.done;n=e.next())(r=n.value).onPollUpdated&&r.onPollUpdated(ie,L)}catch(e){a={error:e}}finally{try{n&&!n.done&&(i=e.return)&&i.call(e)}finally{if(a)throw a.error}}return[2]}))}))}),Ye.label=29;case 29:return[3,56];case 30:return se=e.as(V),ue=se.event,ce=se.channelUrl,le=se.channelType,ce&&le===M.OPEN?[4,this.getChannel(ce,!0)]:[3,32];case 31:he=Ye.sent(),this._dispatcher.dispatch(new w({event:ue,source:T.EVENT_POLL_VOTED})),g((function(){return n(Xe,void 0,void 0,(function(){var e,n,r,a,i;return t(this,(function(t){try{for(e=m(this._openChannelHandlers.values()),n=e.next();!n.done;n=e.next())(r=n.value).onPollVoted&&r.onPollVoted(he,ue)}catch(e){a={error:e}}finally{try{n&&!n.done&&(i=e.return)&&i.call(e)}finally{if(a)throw a.error}}return[2]}))}))})),Ye.label=32;case 32:return[3,56];case 33:if(!(de=e.as(Y).event).isOpenChannelEvent)return[3,55];switch(de.category){case Z.CHANNEL_ENTER:return[3,34];case Z.CHANNEL_EXIT:return[3,36];case Z.CHANNEL_OPERATOR_UPDATE:return[3,38];case Z.USER_CHANNEL_MUTE:case Z.USER_CHANNEL_UNMUTE:return[3,40];case Z.USER_CHANNEL_BAN:case Z.USER_CHANNEL_UNBAN:return[3,42];case Z.CHANNEL_FREEZE:case Z.CHANNEL_UNFREEZE:return[3,44];case Z.CHANNEL_DELETED:return[3,46];case Z.CHANNEL_PROP_CHANGED:return[3,49];case Z.CHANNEL_META_DATA_CHANGED:return[3,51];case Z.CHANNEL_META_COUNTERS_CHANGED:return[3,53]}return[3,55];case 34:return[4,this.getChannel(de.channelUrl,!0)];case 35:return pe=Ye.sent(),fe=e.as(ve),Ee=fe.participantCount,Ce=fe.user,ye=pe._updateParticipantCount(Ee,de.ts),g((function(){return n(Xe,void 0,void 0,(function(){return t(this,(function(e){return this._openChannelHandlers.forEach((function(e){e.onUserEntered&&e.onUserEntered(pe,Ce),ye&&e.onChannelParticipantCountChanged&&e.onChannelParticipantCountChanged(pe)})),[2]}))}))})),[3,55];case 36:return[4,this.getChannel(de.channelUrl,!0)];case 37:return me=Ye.sent(),Ue=e.as(_e),Ee=Ue.participantCount,ge=Ue.user,we=me._updateParticipantCount(Ee,de.ts),g((function(){return n(Xe,void 0,void 0,(function(){return t(this,(function(e){return this._openChannelHandlers.forEach((function(e){e.onUserExited&&e.onUserExited(me,ge),we&&e.onChannelParticipantCountChanged&&e.onChannelParticipantCountChanged(me)})),[2]}))}))})),[3,55];case 38:return[4,this.getChannel(de.channelUrl,!0)];case 39:return Te=Ye.sent(),Me=e.as($).operators,Te.operators=Me,this.upsertChannelsToCache([Te]),g((function(){return n(Xe,void 0,void 0,(function(){return t(this,(function(e){return this._openChannelHandlers.forEach((function(e){e.onOperatorUpdated&&e.onOperatorUpdated(Te,Me)})),[2]}))}))})),[3,55];case 40:return[4,this.getChannel(de.channelUrl,!0)];case 41:return be=Ye.sent(),Ne=de.category===Z.USER_CHANNEL_MUTE,Pe=e.as(Ne?Q:K).user,g((function(){return n(Xe,void 0,void 0,(function(){return t(this,(function(e){return this._openChannelHandlers.forEach((function(e){Ne?e.onUserMuted&&e.onUserMuted(be,Pe):e.onUserUnmuted&&e.onUserUnmuted(be,Pe)})),[2]}))}))})),[3,55];case 42:return[4,this.getChannel(de.channelUrl,!0)];case 43:return De=Ye.sent(),He=de.category===Z.USER_CHANNEL_BAN,Oe=e.as(He?q:z).user,g((function(){return n(Xe,void 0,void 0,(function(){return t(this,(function(e){return this._openChannelHandlers.forEach((function(e){He?e.onUserBanned&&e.onUserBanned(De,Oe):e.onUserUnbanned&&e.onUserUnbanned(De,Oe)})),[2]}))}))})),[3,55];case 44:return[4,this.getChannel(de.channelUrl,!0)];case 45:return xe=Ye.sent(),Ie=e.as(k).freeze,xe.isFrozen=Ie,this.upsertChannelsToCache([xe]),g((function(){return n(Xe,void 0,void 0,(function(){return t(this,(function(e){return this._openChannelHandlers.forEach((function(e){Ie?e.onChannelFrozen&&e.onChannelFrozen(xe):e.onChannelUnfrozen&&e.onChannelUnfrozen(xe)})),[2]}))}))})),[3,55];case 46:return[4,this.getChannel(de.channelUrl,!0)];case 47:return Ae=Ye.sent(),[4,this.removeChannelsFromCache([Ae.url])];case 48:return Ye.sent(),g((function(){return n(Xe,void 0,void 0,(function(){return t(this,(function(e){return this._openChannelHandlers.forEach((function(e){e.onChannelDeleted&&e.onChannelDeleted(Ae.url,Ae.channelType)})),[2]}))}))})),[3,55];case 49:return[4,this.getChannelWithoutCache(de.channelUrl,!0)];case 50:return Re=Ye.sent(),g((function(){return n(Xe,void 0,void 0,(function(){return t(this,(function(e){return this._openChannelHandlers.forEach((function(e){e.onChannelChanged&&e.onChannelChanged(Re)})),[2]}))}))})),[3,55];case 51:return[4,this.getChannel(de.channelUrl,!0)];case 52:return Le=Ye.sent(),Fe=e.as(S),Se=Fe.created,ke=Fe.updated,qe=Fe.deleted,Se&&Le._upsertCachedMetaData(Se,de.ts),ke&&Le._upsertCachedMetaData(ke,de.ts),qe&&Le._removeFromCachedMetaData(qe,de.ts),g((function(){return n(Xe,void 0,void 0,(function(){return t(this,(function(e){return this._openChannelHandlers.forEach((function(e){Se&&e.onMetaDataCreated&&e.onMetaDataCreated(Le,Se),ke&&e.onMetaDataUpdated&&e.onMetaDataUpdated(Le,ke),qe&&e.onMetaDataDeleted&&e.onMetaDataDeleted(Le,qe)})),[2]}))}))})),[3,55];case 53:return[4,this.getChannel(de.channelUrl,!0)];case 54:return ze=Ye.sent(),Qe=e.as(F),Ke=Qe.created,Ve=Qe.updated,je=Qe.deleted,g((function(){return n(Xe,void 0,void 0,(function(){return t(this,(function(e){return this._openChannelHandlers.forEach((function(e){Ke&&e.onMetaCounterCreated&&e.onMetaCounterCreated(ze,Ke),Ve&&e.onMetaCounterUpdated&&e.onMetaCounterUpdated(ze,Ve),je&&e.onMetaCounterDeleted&&e.onMetaCounterDeleted(ze,je)})),[2]}))}))})),[3,55];case 55:return[3,56];case 56:return[3,58];case 57:if(Be=Ye.sent(),E(Be))throw Be;return[3,58];case 58:return[2]}}))}))},e.prototype.addHandler=function(e,n){this._openChannelHandlers.set(e,n)},e.prototype.removeHandler=function(e){this._openChannelHandlers.delete(e)},e.prototype.clearHandler=function(){this._openChannelHandlers.clear()},e.prototype.getChannel=function(e,r){return n(this,void 0,void 0,(function(){var n;return t(this,(function(t){switch(t.label){case 0:N(i("string",e)).throw(P.invalidParameters),t.label=1;case 1:return t.trys.push([1,3,,4]),[4,this.getChannelFromCache(e)];case 2:return(n=t.sent())?[2,n]:[3,4];case 3:return t.sent(),[3,4];case 4:return[4,this.getChannelWithoutCache(e)];case 5:return[2,t.sent()]}}))}))},e.prototype.getChannelWithoutCache=function(e,r){return void 0===r&&(r=!1),n(this,void 0,void 0,(function(){var n,a,o;return t(this,(function(t){switch(t.label){case 0:return N(i("string",e)).throw(P.invalidParameters),n=new he({channelUrl:e,isInternalCall:r}),[4,this._requestQueue.send(n)];case 1:return a=t.sent(),o=a.as(de).channel,[4,this.upsertChannelsToCache([o])];case 2:return[2,t.sent()[0]]}}))}))},e.prototype.createChannel=function(e){return n(this,void 0,void 0,(function(){var n,r,s,u;return t(this,(function(t){switch(t.label){case 0:return n=D(D({},le),e),N(function(e){return a("string",e.operatorUserIds,!0)&&(i("string",e.coverUrlOrImage,!0)||o(e.coverUrlOrImage,!0))&&i("string",e.name,!0)&&i("string",e.data,!0)&&i("string",e.customType,!0)&&(i("string",e.channelUrl)&&/^\w+$/.test(e.channelUrl)||null===e.channelUrl||void 0===e.channelUrl)&&i("boolean",e.isEphemeral,!0)}(n)).throw(P.invalidParameters),r=new pe(n),[4,this._requestQueue.send(r)];case 1:return s=t.sent(),u=s.as(de).channel,this.upsertChannelsToCache([u]),[2,u]}}))}))},e}(),Ue={name:void 0,coverUrlOrImage:void 0,data:void 0,customType:void 0,operatorUserIds:void 0},Ee=function(n){function t(e){var t=this,r=e.channelUrl,a=e.token,i=e.limit;return(t=n.call(this)||this).method=s.GET,t.path="".concat(c,"/").concat(encodeURIComponent(r),"/participants"),t.params={token:a,limit:i},t}return e(t,n),t}(l),ge=function(n){function t(e,t){var r=n.call(this,e,t)||this;r.participants=[];var a=t.next,i=t.participants;return r.token=a,r.participants=i.map((function(n){return new ue(e,n)})),r}return e(t,n),t}(h),we=function(r){function a(e,n,t){return r.call(this,e,n,M.OPEN,t)||this}return e(a,r),a.prototype._validate=function(){return r.prototype._validate.call(this)},a.prototype.next=function(){return n(this,void 0,void 0,(function(){var e,n,r,a,i,o;return t(this,(function(t){switch(t.label){case 0:return this._validate()?this._isLoading?[3,3]:this._hasNext?(this._isLoading=!0,e=x.of(this._iid).requestQueue,n=new Ee(D(D({},this),{token:this._token})),[4,e.send(n)]):[3,2]:[3,5];case 1:return r=t.sent(),a=r.as(ge),i=a.participants,o=a.token,this._token=o,this._hasNext=!!o,this._isLoading=!1,[2,i];case 2:return[2,[]];case 3:throw P.queryInProgress;case 4:return[3,6];case 5:throw P.invalidParameters;case 6:return[2]}}))}))},a}(O),Te=function(n){function t(e){var t=this,r=e.channelUrl,a=e.coverUrlOrImage,u=e.name,l=e.data,h=e.customType,f=e.operatorUserIds;return(t=n.call(this)||this).method=s.PUT,t.path="".concat(c,"/").concat(encodeURIComponent(r)),t.params=d(p({cover_url:i("string",a)?a:null,cover_file:o(a)?a:null,name:u,data:l,custom_type:h,operators:f})),t}return e(t,n),t}(l),Me=function(n){function t(e,t){var r=n.call(this,e,t)||this;return r.channel=new Ne(e,t),r}return e(t,n),t}(h),be=function(n){function t(e){var t=this,r=e.channelUrl;return(t=n.call(this)||this).method=s.DELETE,t.path="".concat(c,"/").concat(encodeURIComponent(r)),t}return e(t,n),t}(l);!function(n){function t(e,t){return n.call(this,e,t)||this}e(t,n)}(h);var Ne=function(r){function s(e,n){var t,a=this;return(a=r.call(this,e,n)||this)._lastParticipantCountUpdated=0,a.participantCount=0,a.operators=[],a.channelType=M.OPEN,a.participantCount=null!==(t=n.participant_count)&&void 0!==t?t:0,a.operators=Array.isArray(n.operators)?n.operators.map((function(n){return new v(e,n)})):[],a}return e(s,r),s.payloadify=function(e){return d(p(D(D({},X.payloadify(e)),{participant_count:e.participantCount,operators:e.operators.map((function(e){return v.payloadify(e)}))})))},s.prototype.serialize=function(){return I(this)},s.prototype.isOperator=function(e){return e instanceof v?this.isOperator(e.userId):this.operators.some((function(n){return n.userId===e}))},s.prototype._updateParticipantCount=function(e,n){return n>this._lastParticipantCountUpdated&&(this.participantCount=e,this._lastParticipantCountUpdated=n,!0)},s.prototype.createParticipantListQuery=function(e){return new we(this._iid,this.url,e)},s.prototype.refresh=function(){return n(this,void 0,void 0,(function(){return t(this,(function(e){switch(e.label){case 0:return[4,me.of(this._iid).getChannelWithoutCache(this.url)];case 1:return[2,e.sent()]}}))}))},s.prototype.enter=function(){return n(this,void 0,void 0,(function(){var e,n,r,a,i,o;return t(this,(function(t){switch(t.label){case 0:return e=x.of(this._iid).requestQueue,n=new fe({channelUrl:this.url}),[4,e.send(n)];case 1:return r=t.sent(),a=r.as(ve),i=a.participantCount,o=a.ts,this._updateParticipantCount(i,o),me.of(this._iid).setEnteredToCache(this),[2]}}))}))},s.prototype.exit=function(){return n(this,void 0,void 0,(function(){var e,n,r,a,i,o;return t(this,(function(t){switch(t.label){case 0:return e=x.of(this._iid).requestQueue,n=new Ce({channelUrl:this.url}),[4,e.send(n)];case 1:return r=t.sent(),a=r.as(_e),i=a.participantCount,o=a.ts,this._updateParticipantCount(i,o),me.of(this._iid).setExitedToCache(this),se.of(this._iid).fileMessageQueue.cancel(this),[2]}}))}))},s.prototype.updateChannel=function(e){return n(this,void 0,void 0,(function(){var n,r,s,u,c;return t(this,(function(t){switch(t.label){case 0:return n=D(D({},Ue),e),N(function(e){return a("string",e.operatorUserIds,!0)&&(i("string",e.coverUrlOrImage)||o(e.coverUrlOrImage)||null===e.coverUrlOrImage)&&i("string",e.name,!0)&&i("string",e.data,!0)&&i("string",e.customType,!0)}(n)).throw(P.invalidParameters),r=x.of(this._iid).requestQueue,s=new Te(D({channelUrl:this.url},n)),[4,r.send(s)];case 1:return u=t.sent(),c=u.as(Me).channel,this._update(c),[4,me.of(this._iid).upsertChannelsToCache([c])];case 2:return t.sent(),[2,this]}}))}))},s.prototype.updateChannelWithOperatorUserIds=function(e,r,a,i,o){return n(this,void 0,void 0,(function(){var n;return t(this,(function(t){return n=D(D({},Ue),{name:e,coverUrlOrImage:r,data:a,operatorUserIds:i,customType:o}),[2,this.updateChannel(n)]}))}))},s.prototype.delete=function(){return n(this,void 0,void 0,(function(){var e,n;return t(this,(function(t){switch(t.label){case 0:return e=x.of(this._iid).requestQueue,n=new be({channelUrl:this.url}),[4,e.send(n)];case 1:return t.sent(),[4,me.of(this._iid).removeChannelsFromCache([this.url])];case 2:return t.sent(),[2]}}))}))},s.prototype.sendUserMessage=function(e){return N(!e.isPinnedMessage).throw(P.notSupportedError),r.prototype.sendUserMessage.call(this,e)},s.prototype.sendFileMessage=function(e){return N(!e.isPinnedMessage).throw(P.notSupportedError),r.prototype.sendFileMessage.call(this,e)},s}(X),Pe=function(n){function t(e){void 0===e&&(e={});var t=n.call(this)||this;return Object.keys(e).forEach((function(n){t.hasOwnProperty(n)&&(t[n]=e[n])})),t}return e(t,n),t}(function(n){function t(){var e=null!==n&&n.apply(this,arguments)||this;return e.onUserEntered=A,e.onUserExited=A,e.onChannelParticipantCountChanged=A,e.onPollUpdated=A,e.onPollVoted=A,e.onPollDeleted=A,e}return e(t,n),t}(ie)),De=function(n){function t(e){var t=this,r=e.token,a=e.limit,i=e.nameKeyword,o=e.urlKeyword,u=e.customTypes,l=e.includeFrozen,h=e.includeMetaData;return(t=n.call(this)||this).method=s.GET,t.path=c,t.params=d({token:r,limit:a,name_contains:i,url_contains:o,custom_types:u,show_frozen:l,show_metadata:h}),t}return e(t,n),t}(l),He=function(n){function t(e,t){var r=n.call(this,e,t)||this;r.channels=[];var a=t.next,i=t.channels,o=t.ts;return r.token=a,i&&i.length>0&&(r.channels=i.map((function(n){return new Ne(e,n)}))),r.ts="number"==typeof o?o:null,r}return e(t,n),t}(h),Oe=function(r){function o(e,n){var t,a,i,o,s,u=this;return(u=r.call(this,e,n)||this).includeFrozen=!0,u.includeMetaData=!0,u.nameKeyword=null,u.urlKeyword=null,u.customTypes=null,u.includeFrozen=null===(t=n.includeFrozen)||void 0===t||t,u.includeMetaData=null===(a=n.includeMetaData)||void 0===a||a,u.nameKeyword=null!==(i=n.nameKeyword)&&void 0!==i?i:null,u.urlKeyword=null!==(o=n.urlKeyword)&&void 0!==o?o:null,u.customTypes=null!==(s=n.customTypes)&&void 0!==s?s:null,u}return e(o,r),o.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)},o.prototype.next=function(){return n(this,void 0,void 0,(function(){var e,n,r,a,i,o;return t(this,(function(t){switch(t.label){case 0:return this._validate()?this._isLoading?[3,4]:this._hasNext?(this._isLoading=!0,e=x.of(this._iid).requestQueue,n=new De(p(D(D({},this),{token:this._token}))),[4,e.send(n)]):[3,3]:[3,6];case 1:return r=t.sent(),a=r.as(He),i=a.channels,o=a.token,this._token=o,this._hasNext=!!o,[4,me.of(this._iid).upsertChannelsToCache(i)];case 2:return t.sent(),this._isLoading=!1,[2,i];case 3:return[2,[]];case 4:throw P.queryInProgress;case 5:return[3,7];case 6:throw P.invalidParameters;case 7:return[2]}}))}))},o}(R),xe=function(r){function a(){var e=null!==r&&r.apply(this,arguments)||this;return e.name="openChannel",e}return e(a,r),a.prototype.init=function(e,n){var t=n.sdkState,a=n.dispatcher,i=n.sessionManager,o=n.requestQueue,s=n.logger,u=n.onlineDetector,c=n.cacheContext;r.prototype.init.call(this,e,{sdkState:t,dispatcher:a,sessionManager:i,requestQueue:o,logger:s,onlineDetector:u,cacheContext:c}),this._manager=new me(e,{sdkState:t,dispatcher:a,requestQueue:o})},a.prototype.createOpenChannelListQuery=function(e){return void 0===e&&(e={}),new Oe(this._iid,e)},a.prototype.addOpenChannelHandler=function(e,n){this._manager.addHandler(e,n)},a.prototype.removeOpenChannelHandler=function(e){this._manager.removeHandler(e)},a.prototype.removeAllOpenChannelHandlers=function(){this._manager.clearHandler()},a.prototype.buildOpenChannelFromSerializedData=function(e){return this._manager.buildOpenChannelFromSerializedData(e)},a.prototype.getChannel=function(e){return n(this,void 0,void 0,(function(){return t(this,(function(n){return[2,this._manager.getChannel(e)]}))}))},a.prototype.getChannelWithoutCache=function(e){return n(this,void 0,void 0,(function(){return t(this,(function(n){return[2,this._manager.getChannelWithoutCache(e)]}))}))},a.prototype.createChannel=function(e){return void 0===e&&(e={}),n(this,void 0,void 0,(function(){return t(this,(function(n){return[2,this._manager.createChannel(e)]}))}))},a.prototype.createChannelWithOperatorUserIds=function(e,r,a,i,o){return n(this,void 0,void 0,(function(){var n;return t(this,(function(t){return(n=D({},le)).name=e,n.coverUrlOrImage=r,n.data=a,n.operatorUserIds=i,n.customType=o,[2,this._manager.createChannel(n)]}))}))},a}(L);export{Ne as OpenChannel,Pe as OpenChannelHandler,Oe as OpenChannelListQuery,xe as OpenChannelModule,we as ParticipantListQuery}; diff --git a/package.json b/package.json index 778b62e..f1b9e68 100644 --- a/package.json +++ b/package.json @@ -1,5 +1,5 @@ { - "version": "4.9.2", + "version": "4.9.3", "description": "Sendbird SDK for JavaScript", "name": "@sendbird/chat", "author": "Sendbird ", diff --git a/poll.js b/poll.js index 899ec8c..fb866d1 100644 --- a/poll.js +++ b/poll.js @@ -1 +1 @@ -import{_ as t,b as e,am as r,c as n,g as o,s,S as l}from"./lib/__bundle-a8606dd4.js";export{a7 as Poll,an as PollOption,ao as PollStatus}from"./lib/__bundle-a8606dd4.js";import{b as u,c,v as d,d as p,e as f,f as g,g as m}from"./lib/__bundle-3707a8af.js";export{P as PollListQuery,h as PollUpdateEvent,i as PollVoteEvent,a as PollVoterListQuery}from"./lib/__bundle-3707a8af.js";var v=function(a){function r(){var t=null!==a&&a.apply(this,arguments)||this;return t.name="poll",t}return t(r,a),r.prototype.init=function(t,e){var r=e.sdkState,n=e.dispatcher,o=e.sessionManager,i=e.requestQueue,s=e.logger,l=e.onlineDetector,c=e.cacheContext;a.prototype.init.call(this,t,{sdkState:r,dispatcher:n,sessionManager:o,requestQueue:i,logger:s,onlineDetector:l,cacheContext:c}),this._manager=new u(t,{sdkState:r,dispatcher:n,sessionManager:o,requestQueue:i,logger:s,onlineDetector:l,cacheContext:c})},r.prototype.create=function(t){return e(this,void 0,void 0,(function(){var e;return n(this,(function(a){return e=o(o({},c),t),s(d(e)).throw(l.invalidParameters),[2,this._manager.create(e)]}))}))},r.prototype.get=function(t){return e(this,void 0,void 0,(function(){var e;return n(this,(function(a){return e=o(o({},p),t),s(f(e)).throw(l.invalidParameters),[2,this._manager.get(e)]}))}))},r.prototype.getOption=function(t){return e(this,void 0,void 0,(function(){var e;return n(this,(function(a){return e=o(o({},g),t),s(m(e)).throw(l.invalidParameters),[2,this._manager.getOption(e)]}))}))},r.prototype.buildPollFromSerializedData=function(t){return this._manager.buildPollFromSerializedData(t)},r}(r);export{v as PollModule}; +import{_ as t,b as e,an as r,c as n,g as o,t as s,S as l}from"./lib/__bundle-75942676.js";export{a8 as Poll,ao as PollOption,ap as PollStatus}from"./lib/__bundle-75942676.js";import{b as u,c,v as p,d,e as g,f,g as v}from"./lib/__bundle-ad161b2c.js";export{P as PollListQuery,h as PollUpdateEvent,i as PollVoteEvent,a as PollVoterListQuery}from"./lib/__bundle-ad161b2c.js";var m=function(r){function a(){var t=null!==r&&r.apply(this,arguments)||this;return t.name="poll",t}return t(a,r),a.prototype.init=function(t,e){var a=e.sdkState,n=e.dispatcher,o=e.sessionManager,i=e.requestQueue,s=e.logger,l=e.onlineDetector,c=e.cacheContext;r.prototype.init.call(this,t,{sdkState:a,dispatcher:n,sessionManager:o,requestQueue:i,logger:s,onlineDetector:l,cacheContext:c}),this._manager=new u(t,{sdkState:a,dispatcher:n,sessionManager:o,requestQueue:i,logger:s,onlineDetector:l,cacheContext:c})},a.prototype.create=function(t){return e(this,void 0,void 0,(function(){var e;return n(this,(function(r){return e=o(o({},c),t),s(p(e)).throw(l.invalidParameters),[2,this._manager.create(e)]}))}))},a.prototype.get=function(t){return e(this,void 0,void 0,(function(){var e;return n(this,(function(r){return e=o(o({},d),t),s(g(e)).throw(l.invalidParameters),[2,this._manager.get(e)]}))}))},a.prototype.getOption=function(t){return e(this,void 0,void 0,(function(){var e;return n(this,(function(r){return e=o(o({},f),t),s(v(e)).throw(l.invalidParameters),[2,this._manager.getOption(e)]}))}))},a.prototype.buildPollFromSerializedData=function(t){return this._manager.buildPollFromSerializedData(t)},a}(r);export{m as PollModule}; diff --git a/sendbird.min.js b/sendbird.min.js index f50ca5d..e1b90a5 100644 --- a/sendbird.min.js +++ b/sendbird.min.js @@ -1 +1 @@ -var Sendbird=function(e){"use strict";function t(){t=function(){return e};var e={},n=Object.prototype,r=n.hasOwnProperty,a=Object.defineProperty||function(e,t,n){e[t]=n.value},s="function"==typeof Symbol?Symbol:{},i=s.iterator||"@@iterator",o=s.asyncIterator||"@@asyncIterator",u=s.toStringTag||"@@toStringTag";function c(e,t,n){return Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}),e[t]}try{c({},"")}catch(e){c=function(e,t,n){return e[t]=n}}function l(e,t,n,r){var s=t&&t.prototype instanceof f?t:f,i=Object.create(s.prototype),o=new T(r||[]);return a(i,"_invoke",{value:E(e,n,o)}),i}function h(e,t,n){try{return{type:"normal",arg:e.call(t,n)}}catch(e){return{type:"throw",arg:e}}}e.wrap=l;var d={};function f(){}function p(){}function v(){}var _={};c(_,i,(function(){return this}));var m=Object.getPrototypeOf,g=m&&m(m(S([])));g&&g!==n&&r.call(g,i)&&(_=g);var y=v.prototype=f.prototype=Object.create(_);function k(e){["next","throw","return"].forEach((function(t){c(e,t,(function(e){return this._invoke(t,e)}))}))}function b(e,t){function n(a,s,i,o){var u=h(e[a],e,s);if("throw"!==u.type){var c=u.arg,l=c.value;return l&&"object"==typeof l&&r.call(l,"__await")?t.resolve(l.__await).then((function(e){n("next",e,i,o)}),(function(e){n("throw",e,i,o)})):t.resolve(l).then((function(e){c.value=e,i(c)}),(function(e){return n("throw",e,i,o)}))}o(u.arg)}var s;a(this,"_invoke",{value:function(e,r){function a(){return new t((function(t,a){n(e,r,t,a)}))}return s=s?s.then(a,a):a()}})}function E(e,t,n){var r="suspendedStart";return function(a,s){if("executing"===r)throw new Error("Generator is already running");if("completed"===r){if("throw"===a)throw s;return I()}for(n.method=a,n.arg=s;;){var i=n.delegate;if(i){var o=w(i,n);if(o){if(o===d)continue;return o}}if("next"===n.method)n.sent=n._sent=n.arg;else if("throw"===n.method){if("suspendedStart"===r)throw r="completed",n.arg;n.dispatchException(n.arg)}else"return"===n.method&&n.abrupt("return",n.arg);r="executing";var u=h(e,t,n);if("normal"===u.type){if(r=n.done?"completed":"suspendedYield",u.arg===d)continue;return{value:u.arg,done:n.done}}"throw"===u.type&&(r="completed",n.method="throw",n.arg=u.arg)}}}function w(e,t){var n=t.method,r=e.iterator[n];if(void 0===r)return t.delegate=null,"throw"===n&&e.iterator.return&&(t.method="return",t.arg=void 0,w(e,t),"throw"===t.method)||"return"!==n&&(t.method="throw",t.arg=new TypeError("The iterator does not provide a '"+n+"' method")),d;var a=h(r,e.iterator,t.arg);if("throw"===a.type)return t.method="throw",t.arg=a.arg,t.delegate=null,d;var s=a.arg;return s?s.done?(t[e.resultName]=s.value,t.next=e.nextLoc,"return"!==t.method&&(t.method="next",t.arg=void 0),t.delegate=null,d):s:(t.method="throw",t.arg=new TypeError("iterator result is not an object"),t.delegate=null,d)}function x(e){var t={tryLoc:e[0]};1 in e&&(t.catchLoc=e[1]),2 in e&&(t.finallyLoc=e[2],t.afterLoc=e[3]),this.tryEntries.push(t)}function C(e){var t=e.completion||{};t.type="normal",delete t.arg,e.completion=t}function T(e){this.tryEntries=[{tryLoc:"root"}],e.forEach(x,this),this.reset(!0)}function S(e){if(e){var t=e[i];if(t)return t.call(e);if("function"==typeof e.next)return e;if(!isNaN(e.length)){var n=-1,a=function t(){for(;++n=0;--a){var s=this.tryEntries[a],i=s.completion;if("root"===s.tryLoc)return n("end");if(s.tryLoc<=this.prev){var o=r.call(s,"catchLoc"),u=r.call(s,"finallyLoc");if(o&&u){if(this.prev=0;--n){var a=this.tryEntries[n];if(a.tryLoc<=this.prev&&r.call(a,"finallyLoc")&&this.prev=0;--t){var n=this.tryEntries[t];if(n.finallyLoc===e)return this.complete(n.completion,n.afterLoc),C(n),d}},catch:function(e){for(var t=this.tryEntries.length-1;t>=0;--t){var n=this.tryEntries[t];if(n.tryLoc===e){var r=n.completion;if("throw"===r.type){var a=r.arg;C(n)}return a}}throw new Error("illegal catch attempt")},delegateYield:function(e,t,n){return this.delegate={iterator:S(e),resultName:t,nextLoc:n},"next"===this.method&&(this.arg=void 0),d}},e}function n(e){return n="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},n(e)}function r(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function a(e,t){for(var n=0;ne.length)&&(t=e.length);for(var n=0,r=new Array(t);n=e.length?{done:!0}:{done:!1,value:e[r++]}},e:function(e){throw e},f:a}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var s,i=!0,o=!1;return{s:function(){n=n.call(e)},n:function(){var e=n.next();return i=e.done,e},e:function(e){o=!0,s=e},f:function(){try{i||null==n.return||n.return()}finally{if(o)throw s}}}}function k(e){var t=function(e,t){if("object"!=typeof e||null===e)return e;var n=e[Symbol.toPrimitive];if(void 0!==n){var r=n.call(e,t||"default");if("object"!=typeof r)return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(e,"string");return"symbol"==typeof t?t:String(t)}function b(e,t,n,r){return new(n||(n=Promise))((function(a,s){function i(e){try{u(r.next(e))}catch(e){s(e)}}function o(e){try{u(r.throw(e))}catch(e){s(e)}}function u(e){var t;e.done?a(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(i,o)}u((r=r.apply(e,t||[])).next())}))}var E,w="4.9.2",x=function(){function e(){r(this,e)}return s(e,null,[{key:"OS_VERSION",get:function(){return"undefined"!=typeof navigator&&navigator.userAgent?navigator.userAgent.replace(/,/g,"."):"noAgent"}},{key:"SDK_VERSION",get:function(){return w}},{key:"SDK_MAJOR_VERSION",get:function(){return e.SDK_VERSION.split(".")[0]}},{key:"DEFAULT_MAX_UNREAD_COUNT_OF_SUPER_GROUP_CHANNEL",get:function(){return 100}},{key:"INTERNAL_CALL",get:function(){return"ic"}}]),e}();!function(e){e[e.STAT_LOG_NOT_ALLOWED=400108]="STAT_LOG_NOT_ALLOWED",e[e.NON_AUTHORIZED=400108]="NON_AUTHORIZED",e[e.INVALID_TOKEN=400111]="INVALID_TOKEN",e[e.NOT_FOUND_IN_DATABASE=400201]="NOT_FOUND_IN_DATABASE",e[e.SESSION_TOKEN_EXPIRED=400302]="SESSION_TOKEN_EXPIRED",e[e.SESSION_KEY_EXPIRED=400309]="SESSION_KEY_EXPIRED",e[e.SESSION_REVOKED=400310]="SESSION_REVOKED",e[e.STAT_UPLOAD_NOT_ALLOWED=403200]="STAT_UPLOAD_NOT_ALLOWED",e[e.INTERNAL_SERVER_ERROR=500901]="INTERNAL_SERVER_ERROR",e[e.RATE_LIMIT_EXCEEDED=500910]="RATE_LIMIT_EXCEEDED",e[e.UNKNOWN_SERVER_ERROR=900200]="UNKNOWN_SERVER_ERROR",e[e.DEBUG_MODE_REQUIRED=7e5]="DEBUG_MODE_REQUIRED",e[e.LOST_INSTANCE=700100]="LOST_INSTANCE",e[e.CONNECTION_RENEW=700102]="CONNECTION_RENEW",e[e.INVALID_CONNECTION_STATE_TRANSITION=700200]="INVALID_CONNECTION_STATE_TRANSITION",e[e.INVALID_INITIALIZATION=800100]="INVALID_INITIALIZATION",e[e.CONNECTION_REQUIRED=800101]="CONNECTION_REQUIRED",e[e.CONNECTION_CANCELED=800102]="CONNECTION_CANCELED",e[e.INVALID_PARAMETER=800110]="INVALID_PARAMETER",e[e.NOT_SUPPORTED_ERROR=800111]="NOT_SUPPORTED_ERROR",e[e.NETWORK_ERROR=800120]="NETWORK_ERROR",e[e.NETWORK_ROUTING_ERROR=800121]="NETWORK_ROUTING_ERROR",e[e.MALFORMED_DATA=800130]="MALFORMED_DATA",e[e.MALFORMED_ERROR_DATA=800140]="MALFORMED_ERROR_DATA",e[e.WRONG_CHANNEL_TYPE=800150]="WRONG_CHANNEL_TYPE",e[e.MARK_AS_READ_RATE_LIMIT_EXCEEDED=800160]="MARK_AS_READ_RATE_LIMIT_EXCEEDED",e[e.QUERY_IN_PROGRESS=800170]="QUERY_IN_PROGRESS",e[e.ACK_TIMEOUT=800180]="ACK_TIMEOUT",e[e.LOGIN_TIMEOUT=800190]="LOGIN_TIMEOUT",e[e.WEBSOCKET_CONNECTION_CLOSED=800200]="WEBSOCKET_CONNECTION_CLOSED",e[e.WEBSOCKET_CONNECTION_FAILED=800210]="WEBSOCKET_CONNECTION_FAILED",e[e.REQUEST_FAILED=800220]="REQUEST_FAILED",e[e.FILE_UPLOAD_CANCEL_FAILED=800230]="FILE_UPLOAD_CANCEL_FAILED",e[e.REQUEST_CANCELED=800240]="REQUEST_CANCELED",e[e.REQUEST_DUPLICATED=800250]="REQUEST_DUPLICATED",e[e.FILE_SIZE_LIMIT_EXCEEDED=800260]="FILE_SIZE_LIMIT_EXCEEDED",e[e.SESSION_TOKEN_REQUEST_FAILED=800500]="SESSION_TOKEN_REQUEST_FAILED",e[e.SESSION_TOKEN_REFRESHED=800501]="SESSION_TOKEN_REFRESHED",e[e.SESSION_TOKEN_REFRESH_FAILED=800502]="SESSION_TOKEN_REFRESH_FAILED",e[e.COLLECTION_DISPOSED=800600]="COLLECTION_DISPOSED",e[e.DATABASE_ERROR=800700]="DATABASE_ERROR"}(E||(E={}));var C,T,S,I,N,M=function(e){return!(e instanceof A&&!e.shouldThrowOutside)},A=function(e){i(n,e);var t=f(n);function n(e){var a,s=e.code,i=void 0===s?0:s,o=e.message,u=void 0===o?"":o;return r(this,n),(a=t.call(this,u)).shouldThrowOutside=!1,a.name="SendbirdError",a.code=i,Object.setPrototypeOf(d(a),n.prototype),a}return s(n,[{key:"isInvalidTokenError",get:function(){return this.code===E.INVALID_TOKEN}},{key:"isSessionTokenExpiredError",get:function(){return this.code===E.SESSION_TOKEN_EXPIRED}},{key:"isSessionKeyExpiredError",get:function(){return this.code===E.SESSION_KEY_EXPIRED}},{key:"isSessionRevokedError",get:function(){return this.code===E.SESSION_REVOKED}},{key:"throwOutside",value:function(){throw this.shouldThrowOutside=!0,this}}],[{key:"debugModeRequired",get:function(){return new n({code:E.DEBUG_MODE_REQUIRED,message:"Cannot run this operation in production mode."})}},{key:"lostInstance",get:function(){return new n({code:E.LOST_INSTANCE,message:"Instance ID is missing. It should belong to an instance."})}},{key:"connectionRenew",get:function(){return new n({code:E.CONNECTION_RENEW,message:"Connection restarts."})}},{key:"invalidConnectionStateTransition",get:function(){return new n({code:E.INVALID_CONNECTION_STATE_TRANSITION,message:"Invalid connection state transition."})}},{key:"connectionRequired",get:function(){return new n({code:E.CONNECTION_REQUIRED,message:"Connection is required."})}},{key:"connectionCanceled",get:function(){return new n({code:E.CONNECTION_CANCELED,message:"Connection is canceled."})}},{key:"invalidParameters",get:function(){return new n({code:E.INVALID_PARAMETER,message:"Invalid parameters."})}},{key:"notSupportedError",get:function(){return new n({code:E.NOT_SUPPORTED_ERROR,message:"Given parameters are not supported."})}},{key:"networkError",get:function(){return new n({code:E.NETWORK_ERROR,message:"There was a network error."})}},{key:"markAsReadAllRateLimitExceeded",get:function(){return new n({code:E.MARK_AS_READ_RATE_LIMIT_EXCEEDED,message:"markAsRead rate limit exceeded."})}},{key:"queryInProgress",get:function(){return new n({code:E.QUERY_IN_PROGRESS,message:"Query in progress."})}},{key:"noAckTimeout",get:function(){return new n({code:E.ACK_TIMEOUT,message:"Command received no ack."})}},{key:"loginTimeout",get:function(){return new n({code:E.LOGIN_TIMEOUT,message:"Connection timeout."})}},{key:"connectionClosed",get:function(){return new n({code:E.WEBSOCKET_CONNECTION_CLOSED,message:"Connection is closed. Please reconnect."})}},{key:"requestFailed",get:function(){return new n({code:E.REQUEST_FAILED,message:"Request failed."})}},{key:"fileUploadCanceled",get:function(){return new n({code:E.FILE_UPLOAD_CANCEL_FAILED,message:"File upload has been canceled."})}},{key:"requestCanceled",get:function(){return new n({code:E.REQUEST_CANCELED,message:"Request has been canceled."})}},{key:"sessionTokenRefreshFailed",get:function(){return new n({code:E.SESSION_TOKEN_REFRESH_FAILED,message:"Failed to refresh the session key."})}},{key:"sessionTokenRequestFailed",get:function(){return new n({code:E.SESSION_TOKEN_REQUEST_FAILED,message:"Failed to get the session token."})}},{key:"databaseError",get:function(){return new n({code:E.DATABASE_ERROR,message:"Database error."})}},{key:"fileSizeLimitExceededError",get:function(){return new n({code:E.FILE_SIZE_LIMIT_EXCEEDED,message:"File size exceeds the file size limit."})}}]),n}(h(Error)),O=[E.CONNECTION_REQUIRED,E.NETWORK_ERROR,E.ACK_TIMEOUT,E.WEBSOCKET_CONNECTION_CLOSED,E.WEBSOCKET_CONNECTION_FAILED,E.FILE_UPLOAD_CANCEL_FAILED,E.REQUEST_CANCELED,E.INTERNAL_SERVER_ERROR,E.RATE_LIMIT_EXCEEDED,E.UNKNOWN_SERVER_ERROR],U=[E.WEBSOCKET_CONNECTION_CLOSED,E.WEBSOCKET_CONNECTION_FAILED,E.CONNECTION_REQUIRED],R=function(e,t){if(e!==t){var n=Object.assign({},e),r=Object.assign({},t);return(!n.hasOwnProperty("messageId")||!r.hasOwnProperty("messageId")||n.messageId===r.messageId)&&((!n.hasOwnProperty("reqId")||!r.hasOwnProperty("reqId")||n.reqId===r.reqId)&&(n.hasOwnProperty("messageId")&&delete n.messageId,n.hasOwnProperty("reqId")&&delete n.reqId,r.hasOwnProperty("messageId")&&delete r.messageId,r.hasOwnProperty("reqId")&&delete r.reqId,JSON.stringify(n)===JSON.stringify(r)))}return!0},L=function(e,t){return!(!(arguments.length>2&&void 0!==arguments[2]&&arguments[2])||null!=t)||("string"!=typeof e?"object"===n(e)?D(e,t):P(e,t):n(t)===e)},D=function(e,t){return!(!(arguments.length>2&&void 0!==arguments[2]&&arguments[2])||null!=t)||Object.values(e).includes(t)},P=function(e,t){return t instanceof e},F=function(e,t){return!(!(arguments.length>2&&void 0!==arguments[2]&&arguments[2])||null!=t)||Array.isArray(t)&&t.every((function(t){return L(e,t)}))},G=function(e){return e>0&&U.indexOf(e)>=0},q=function(e){if(arguments.length>1&&void 0!==arguments[1]&&arguments[1]&&null===e)return!0;var t=L("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(!t){if("undefined"!=typeof Blob)return e instanceof Blob;if("undefined"!=typeof File)return e instanceof File}return t},H=function(){function e(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},n=t.useMemberInfoInMessage,a=void 0===n||n,s=t.typingIndicatorInvalidateTime,i=void 0===s?1e4:s,o=t.typingIndicatorThrottle,u=void 0===o?1e3:o,c=t.websocketResponseTimeout,l=void 0===c?1e4:c,h=t.websocketPayloadDecompression,d=void 0===h||h,f=t.sessionTokenRefreshTimeout,p=void 0===f?60:f;r(this,e),this._useMemberInfoInMessage=!0,this._typingIndicatorInvalidateTime=1e4,this._typingIndicatorThrottle=1e3,this._websocketResponseTimeout=1e4,this._sessionTokenRefreshTimeout=60,this._useMemberInfoInMessage=a,this._typingIndicatorInvalidateTime=i,this._typingIndicatorThrottle=u,this._websocketResponseTimeout=l,this._sessionTokenRefreshTimeout=p,this.websocketPayloadDecompression=d}return s(e,[{key:"useMemberInfoInMessage",get:function(){return this._useMemberInfoInMessage},set:function(e){L("boolean",e)&&(this._useMemberInfoInMessage=e)}},{key:"typingIndicatorInvalidateTime",get:function(){return this._typingIndicatorInvalidateTime},set:function(e){L("number",e)&&(this._typingIndicatorInvalidateTime=e)}},{key:"typingIndicatorThrottle",get:function(){return this._typingIndicatorThrottle},set:function(e){L("number",e)&&e>=1e3&&e<=9e3&&(this._typingIndicatorThrottle=e)}},{key:"websocketResponseTimeout",get:function(){return this._websocketResponseTimeout},set:function(e){L("number",e)&&e>=5e3&&e<=3e4&&(this._websocketResponseTimeout=e)}},{key:"sessionTokenRefreshTimeout",get:function(){return this._sessionTokenRefreshTimeout},set:function(e){L("number",e)&&(e<60?e=60:e>1800&&(e=1800),this._sessionTokenRefreshTimeout=e)}}]),e}(),j={encrypt:function(e){return e},decrypt:function(e){return e}},z=function(){function e(t){var n=t.store;r(this,e),this._preference=new Map,this._store=n}return s(e,[{key:"_savePreferenceKeys",value:function(){return b(this,void 0,void 0,t().mark((function e(){return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this._store.set({key:this._keysAddress,value:_(this._preference.keys())});case 2:case"end":return e.stop()}}),e,this)})))}},{key:"init",value:function(e){var n,r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:1;return b(this,void 0,void 0,t().mark((function a(){var s,i,o,u,c,l,h;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return this._version=r,this._keysAddress=e,s="".concat(e,".metadata.version"),t.next=5,this._store.get(s);case 5:return i=t.sent,t.next=8,this._store.get(e);case 8:if(t.t1=n=t.sent,t.t0=null!==t.t1,!t.t0){t.next=12;break}t.t0=void 0!==n;case 12:if(!t.t0){t.next=16;break}t.t2=n,t.next=17;break;case 16:t.t2=[];case 17:if(o=t.t2,i&&!(i.version0&&void 0!==arguments[0]?arguments[0]:{},n=t.maxSize,a=void 0===n?256:n,s=t.clearOrder,i=void 0===s?N.MESSAGE_COLLECTION_ACCESSED_AT:s,o=t.customClearOrderComparator,u=void 0===o?null:o;r(this,e),this._customClearOrderComparator=null,this._clearOrderComparatorUseMessageCollectionAccessedAt=function(e,t){return e.channel.messageCollectionLastAccessedAt===t.channel.messageCollectionLastAccessedAt?e.channel.lastMessage&&!t.channel.lastMessage?1:!e.channel.lastMessage&&t.channel.lastMessage?-1:e.channel.lastMessage.createdAt-t.channel.lastMessage.createdAt:e.channel.messageCollectionLastAccessedAt>t.channel.messageCollectionLastAccessedAt?1:-1},this._maxSize=Math.max(a,64),u?(this._clearOrder=i,this._customClearOrderComparator=u):this._clearOrder=N.MESSAGE_COLLECTION_ACCESSED_AT}return s(e,[{key:"maxSize",get:function(){return this._maxSize}},{key:"clearOrder",get:function(){return this._clearOrder}},{key:"clearOrderComparator",get:function(){var e;return this._clearOrder===N.MESSAGE_COLLECTION_ACCESSED_AT?this._clearOrderComparatorUseMessageCollectionAccessedAt:null!==(e=this._customClearOrderComparator)&&void 0!==e?e:this._clearOrderComparatorUseMessageCollectionAccessedAt}}]),e}(),ne=function(){function e(){r(this,e),this.sessionKey=null,this.authToken=null}return s(e,[{key:"hasSession",get:function(){return!!this.sessionKey}},{key:"clear",value:function(){this.authToken=null,this.sessionKey=null}}]),e}(),re=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)}))},ae=function(){function e(t){var n=t.container;r(this,e),this._container={},this._container=n,this.key=re()}return s(e,[{key:"_register",value: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}},{key:"on",value:function(e,t){return this._register(e,-1,t)}},{key:"once",value:function(e,t){return this._register(e,1,t)}},{key:"close",value:function(){for(var e in this._container)this._container[e].delete(this.key)}}]),e}(),se=function(){function e(){r(this,e),this._container={}}return s(e,[{key:"on",value:function(e,t){return new ae({container:this._container}).on(e,t)}},{key:"once",value:function(e,t){return new ae({container:this._container}).once(e,t)}},{key:"dispatch",value:function(e,t){var n=this._container[e];if(n){var r,a=[],s=y(n.keys());try{for(s.s();!(r=s.n()).done;){var i=r.value,o=n.get(i);o.handler(t),o.occurence>0&&(o.occurence--,0===o.occurence&&a.push(i))}}catch(e){s.e(e)}finally{s.f()}a.forEach((function(e){return n.delete(e)}))}}}]),e}(),ie=function(){function e(){r(this,e),this._dispatcher=new se}return s(e,[{key:"on",value:function(e){return this._dispatcher.on("event",e)}},{key:"once",value:function(e){return this._dispatcher.once("event",e)}},{key:"dispatch",value:function(e){this._dispatcher.dispatch("event",e)}}]),e}(),oe=s((function e(){r(this,e)})),ue=function(e){var t={};return e&&Object.keys(e).forEach((function(n){void 0===e[n]||Number.isNaN(e[n])||null===e[n]||(t[n]=e[n])})),t};e.ChannelType=void 0,(B=e.ChannelType||(e.ChannelType={})).BASE="base",B.GROUP="group",B.OPEN="open",e.Role=void 0,(Q=e.Role||(e.Role={})).OPERATOR="operator",Q.NONE="none",e.MessageType=void 0,(K=e.MessageType||(e.MessageType={})).BASE="base",K.USER="user",K.FILE="file",K.ADMIN="admin",e.MessageTypeFilter=void 0,(W=e.MessageTypeFilter||(e.MessageTypeFilter={})).ALL="",W.USER="MESG",W.FILE="FILE",W.ADMIN="ADMM",function(e){e.USER="MESG",e.FILE="FILE",e.ADMIN="ADMM"}(Y||(Y={})),e.MentionType=void 0,(Z=e.MentionType||(e.MentionType={})).USERS="users",Z.CHANNEL="channel",e.ReplyType=void 0,(J=e.ReplyType||(e.ReplyType={})).ALL="all",J.NONE="none",J.ONLY_REPLY_TO_CHANNEL="only_reply_to_channel",e.PushNotificationDeliveryOption=void 0,(X=e.PushNotificationDeliveryOption||(e.PushNotificationDeliveryOption={})).DEFAULT="default",X.SUPPRESS="suppress",e.SendingStatus=void 0,($=e.SendingStatus||(e.SendingStatus={})).PENDING="pending",$.SCHEDULED="scheduled",$.SUCCEEDED="succeeded",$.FAILED="failed",$.CANCELED="canceled";var ce,le="v3",he="/".concat(le,"/users"),de="/".concat(le,"/storage/file"),fe="/".concat(le,"/group_channels"),pe="/".concat(le,"/sdk/group_channels"),ve="/".concat(le,"/open_channels"),_e="/".concat(le,"/sdk/open_channels"),me="/".concat(le,"/search"),ge="/".concat(le,"/report"),ye="/".concat(le,"/emojis"),ke="/".concat(le,"/emoji_categories"),be="/".concat(le,"/polls"),Ee="/".concat(le,"/scheduled_messages"),we="/".concat(le,"/sdk/ui_kit/configuration"),xe="/".concat(le,"/sdk/statistics"),Ce=function(t){switch(t){case e.ChannelType.GROUP:return fe;case e.ChannelType.OPEN:return ve;default:return null}},Te=function(t){switch(t){case e.ChannelType.GROUP:return"".concat(ge,"/group_channels");case e.ChannelType.OPEN:return"".concat(ge,"/open_channels");default:return null}},Se=function(t,n,r){switch(t){case e.MentionType.CHANNEL:return!0;case e.MentionType.USERS:if(n){var a,s=y(n);try{for(s.s();!(a=s.n()).done;){if(a.value===r)return!0}}catch(e){s.e(e)}finally{s.f()}}}return!1},Ie=function(e,t,n){var r=Se(e.mentionType,e.mentionedUserIds,n),a=Se(t.mentionType,t.mentionedUserIds,n);return!r&&a?1:r&&!a?-1:0},Ne=function e(t,r,a){var s,i=r||new FormData;for(var o in t)if(o in t){var u=t[o],c=a?"".concat(a,"[").concat(o,"]"):o;q(u)?i.append(c,u,null!==(s=u.name)&&void 0!==s?s:"filename"):"object"!==n(u)||null===u||Array.isArray(u)||u instanceof Blob?i.append(c,String(u)):i=e(u,i,c)}return i};!function(e){e.GET="GET",e.POST="POST",e.PUT="PUT",e.DELETE="DELETE"}(ce||(ce={}));var Me,Ae=function(e){i(a,e);var t=f(a);function a(){var e;return r(this,a),(e=t.apply(this,arguments)).params={},e.requireAuth=!0,e.headers={},e.requestId=re(),e}return s(a,[{key:"encodeParams",value:function(e){var t=this;return null==e||""===e?encodeURIComponent(""):Array.isArray(e)?e.map((function(e){return t.encodeParams(e)})).join(","):"object"===n(e)?encodeURIComponent(JSON.stringify(e)):encodeURIComponent(String(e))}},{key:"query",get:function(){var e=this,t=ue(this.params);return"?".concat(Object.keys(t).map((function(n){return"".concat(encodeURIComponent(n),"=").concat(e.encodeParams(t[n]))})).join("&"))}},{key:"payload",get:function(){var e=ue(this.params);return Object.keys(e).some((function(t){return q(e[t])}))?Ne(e):JSON.stringify(e)}}]),a}(oe),Oe=function(e){i(n,e);var t=f(n);function n(e,a){var s;return r(this,n),(s=t.call(this))._iid=e,s._payload=a,s}return s(n,[{key:"payload",get:function(){return Object.assign({},this._payload)}},{key:"as",value:function(e){return new e(this._iid,this.payload)}}]),n}(oe),Ue=function(e){i(n,e);var t=f(n);function n(e){var a;return r(this,n),(a=t.call(this)).requestId=e,a}return s(n)}(oe),Re=function(e){i(n,e);var t=f(n);function n(e){var a,s=e.expires_in,i=e.reason,o=void 0===i?E.SESSION_KEY_EXPIRED:i;switch(r(this,n),(a=t.call(this)).expiresIn=null!=s?s:0,o){case E.SESSION_KEY_EXPIRED:case E.SESSION_TOKEN_EXPIRED:case E.SESSION_REVOKED:a.error=new A({code:o})}return a}return s(n,[{key:"invalidateSessionToken",get:function(){var e;return null===(e=this.error)||void 0===e?void 0:e.isSessionTokenExpiredError}}]),n}(oe),Le=function(e){i(n,e);var t=f(n);function n(e){var a;return r(this,n),(a=t.call(this)).statLog=e,a}return s(n)}(oe);!function(e){e.FEATURE_LOCALCACHE="feature:local_cache",e.WEBSOCKET_CONNECT="ws:connect",e.API_RESULT="api:result"}(Me||(Me={}));var De=function(){function e(t){var n=t.type,a=t.data,s=t.ts,i=void 0===s?Date.now():s;r(this,e),this.type=n,this.createdAt=i,this.data=a}return s(e,null,[{key:"payloadify",value:function(e){return ue({stat_type:e.type,ts:e.createdAt,data:ue(e.data)})}}]),e}(),Pe=function(){return"undefined"==typeof document&&"undefined"!=typeof navigator&&"ReactNative"==navigator.product},Fe=function(){function e(t,n){var a=this,s=n.auth,i=n.sdkState,o=n.dispatcher,u=n.logger,c=n.useFetchCompat,l=void 0!==c&&c;r(this,e),this._abortControl=new Map,this._shouldImportFetchCompat=!1,this._iid=t,this._auth=s,this._sdkState=i,this._dispatcher=o,this._dispatcher.on((function(e){e instanceof Ue&&a.cancel(e.requestId)})),this._logger=u,this._shouldImportFetchCompat=l}return s(e,[{key:"_userAgentWithExtension",get:function(){var e=this._sdkState.extensions,t=Pe()?"reactnative":"JS",n=e.sb_syncmanager?"s".concat(e.sb_syncmanager):"",r=e.sb_uikit?"u".concat(e.sb_uikit):"",a=e["device-os-platform"]?"o".concat(e["device-os-platform"]):"";return"".concat(t,"/c").concat(x.SDK_VERSION,"/").concat(n,"/").concat(r,"/").concat(a)}},{key:"_createHeader",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null,n=this._sdkState,r=n.appId,a=n.appVersion,s=Object.assign(Object.assign({},e.headers),{SendBird:"JS,".concat(x.OS_VERSION,",").concat(x.SDK_VERSION,",").concat(r).concat(a?",".concat(a):""),"SB-User-Agent":encodeURIComponent(this._userAgentWithExtension),"Request-Sent-Timestamp":Date.now().toString()});return t||(s["Content-Type"]="application/json; charset=utf-8"),e.requireAuth&&this._auth.hasSession&&(s["Session-Key"]=this._auth.sessionKey),this._auth&&this._auth.authToken&&(s["App-Id"]=r,s["Access-Token"]=this._auth.authToken),s}},{key:"_statLogApiResult",value:function(e,t,n){this._dispatcher.dispatch(new Le(new De({type:Me.API_RESULT,data:{endpoint:e.path,method:e.method,success:!n,latency:Date.now()-t,error_code:null==n?void 0:n.code,error_description:null==n?void 0:n.message}})))}},{key:"send",value:function(e){return b(this,void 0,void 0,t().mark((function n(){var r,a,s,i,o,u,c,l,h,d,f,p,v,_,m;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(r=e.path,a=e.method,s=![ce.GET,ce.DELETE].includes(a),i=this._sdkState.api,o="".concat(i.host).concat(r).concat(s?"":e.query),u=s?e.payload:null,c=this._createHeader(e,u instanceof FormData?u:null),l=new AbortController,h=l.signal,this._abortControl.set(e.requestId,l),d=Date.now(),t.prev=10,this._shouldImportFetchCompat&&(this._shouldImportFetchCompat=!1,("undefined"!=typeof globalThis&&globalThis||"undefined"!=typeof self&&self||"undefined"!=typeof global&&global||{fetch:null}).fetch=void 0),"undefined"!=typeof AbortController){t.next=15;break}return t.next=15,Promise.resolve().then((function(){return Lv}));case 15:if("function"==typeof fetch){t.next=18;break}return t.next=18,Promise.resolve().then((function(){return n_}));case 18:return t.next=20,fetch(o,{method:a,body:u,headers:c,signal:h});case 20:return f=t.sent,t.next=23,f.json();case 23:if(p=t.sent,!f.ok&&!f.redirected){t.next=30;break}return this._logger.debug("receive api response",e.requestId),this._statLogApiResult(e,d,null),t.abrupt("return",new Oe(this._iid,p));case 30:if(!p){t.next=37;break}throw((v=new A(p)).isSessionKeyExpiredError||v.isSessionTokenExpiredError)&&this._dispatcher.dispatch(new Re({reason:v.code})),this._statLogApiResult(e,d,v),v;case 37:throw _=A.requestFailed,this._statLogApiResult(e,d,_),_;case 40:t.next=57;break;case 42:if(t.prev=42,t.t0=t.catch(10),this._statLogApiResult(e,d,t.t0),!(t.t0 instanceof A)){t.next=50;break}throw this._logger.debug("fail api request",t.t0),t.t0;case 50:if("AbortError"!==t.t0.name){t.next=54;break}throw A.requestCanceled;case 54:throw m=A.networkError,this._logger.debug("fail api request",m),m;case 57:case"end":return t.stop()}}),n,this,[[10,42]])})))}},{key:"cancel",value:function(e){this._abortControl.has(e)&&(this._abortControl.get(e).abort(),this._abortControl.delete(e))}},{key:"cancelAll",value:function(){var e,t=y(this._abortControl.values());try{for(t.s();!(e=t.n()).done;){e.value.abort()}}catch(e){t.e(e)}finally{t.f()}this._abortControl.clear()}}]),e}(),Ge=function(e){i(n,e);var t=f(n);function n(e,a,s){var i,o=arguments.length>3&&void 0!==arguments[3]?arguments[3]:"";return r(this,n),(i=t.call(this))._iid=e,i.code=a,i.payload=s,i.requestId=s?s.req_id:o,i}return s(n,[{key:"convertToMessage",value:function(){return"".concat(this.code).concat(JSON.stringify(this.payload),"\n")}},{key:"as",value:function(e){return new e(this._iid,this.code,this.payload)}}],[{key:"createFromRawMessage",value:function(e,t){var r=t.substring(0,4),a=null;try{a=JSON.parse(t.substring(4))}catch(e){r="NOOP"}finally{return new n(e,r,a)}}}]),n}(oe),qe=function(){};function He(e){let t=e.length;for(;--t>=0;)e[t]=0}const je=256,ze=286,Ve=30,Be=15,Qe=new Uint8Array([0,0,0,0,0,0,0,0,1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4,5,5,5,5,0]),Ke=new Uint8Array([0,0,0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9,9,10,10,11,11,12,12,13,13]),We=new Uint8Array([0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,3,7]),Ye=new Uint8Array([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),Ze=new Array(576);He(Ze);const Je=new Array(60);He(Je);const Xe=new Array(512);He(Xe);const $e=new Array(256);He($e);const et=new Array(29);He(et);const tt=new Array(Ve);function nt(e,t,n,r,a){this.static_tree=e,this.extra_bits=t,this.extra_base=n,this.elems=r,this.max_length=a,this.has_stree=e&&e.length}let rt,at,st;function it(e,t){this.dyn_tree=e,this.max_code=0,this.stat_desc=t}He(tt);const ot=e=>e<256?Xe[e]:Xe[256+(e>>>7)],ut=(e,t)=>{e.pending_buf[e.pending++]=255&t,e.pending_buf[e.pending++]=t>>>8&255},ct=(e,t,n)=>{e.bi_valid>16-n?(e.bi_buf|=t<>16-e.bi_valid,e.bi_valid+=n-16):(e.bi_buf|=t<{ct(e,n[2*t],n[2*t+1])},ht=(e,t)=>{let n=0;do{n|=1&e,e>>>=1,n<<=1}while(--t>0);return n>>>1},dt=(e,t,n)=>{const r=new Array(16);let a,s,i=0;for(a=1;a<=Be;a++)i=i+n[a-1]<<1,r[a]=i;for(s=0;s<=t;s++){let t=e[2*s+1];0!==t&&(e[2*s]=ht(r[t]++,t))}},ft=e=>{let t;for(t=0;t{e.bi_valid>8?ut(e,e.bi_buf):e.bi_valid>0&&(e.pending_buf[e.pending++]=e.bi_buf),e.bi_buf=0,e.bi_valid=0},vt=(e,t,n,r)=>{const a=2*t,s=2*n;return e[a]{const r=e.heap[n];let a=n<<1;for(;a<=e.heap_len&&(a{let r,a,s,i,o=0;if(0!==e.sym_next)do{r=255&e.pending_buf[e.sym_buf+o++],r+=(255&e.pending_buf[e.sym_buf+o++])<<8,a=e.pending_buf[e.sym_buf+o++],0===r?lt(e,a,t):(s=$e[a],lt(e,s+je+1,t),i=Qe[s],0!==i&&(a-=et[s],ct(e,a,i)),r--,s=ot(r),lt(e,s,n),i=Ke[s],0!==i&&(r-=tt[s],ct(e,r,i)))}while(o{const n=t.dyn_tree,r=t.stat_desc.static_tree,a=t.stat_desc.has_stree,s=t.stat_desc.elems;let i,o,u,c=-1;for(e.heap_len=0,e.heap_max=573,i=0;i>1;i>=1;i--)_t(e,n,i);u=s;do{i=e.heap[1],e.heap[1]=e.heap[e.heap_len--],_t(e,n,1),o=e.heap[1],e.heap[--e.heap_max]=i,e.heap[--e.heap_max]=o,n[2*u]=n[2*i]+n[2*o],e.depth[u]=(e.depth[i]>=e.depth[o]?e.depth[i]:e.depth[o])+1,n[2*i+1]=n[2*o+1]=u,e.heap[1]=u++,_t(e,n,1)}while(e.heap_len>=2);e.heap[--e.heap_max]=e.heap[1],((e,t)=>{const n=t.dyn_tree,r=t.max_code,a=t.stat_desc.static_tree,s=t.stat_desc.has_stree,i=t.stat_desc.extra_bits,o=t.stat_desc.extra_base,u=t.stat_desc.max_length;let c,l,h,d,f,p,v=0;for(d=0;d<=Be;d++)e.bl_count[d]=0;for(n[2*e.heap[e.heap_max]+1]=0,c=e.heap_max+1;c<573;c++)l=e.heap[c],d=n[2*n[2*l+1]+1]+1,d>u&&(d=u,v++),n[2*l+1]=d,l>r||(e.bl_count[d]++,f=0,l>=o&&(f=i[l-o]),p=n[2*l],e.opt_len+=p*(d+f),s&&(e.static_len+=p*(a[2*l+1]+f)));if(0!==v){do{for(d=u-1;0===e.bl_count[d];)d--;e.bl_count[d]--,e.bl_count[d+1]+=2,e.bl_count[u]--,v-=2}while(v>0);for(d=u;0!==d;d--)for(l=e.bl_count[d];0!==l;)h=e.heap[--c],h>r||(n[2*h+1]!==d&&(e.opt_len+=(d-n[2*h+1])*n[2*h],n[2*h+1]=d),l--)}})(e,t),dt(n,c,e.bl_count)},yt=(e,t,n)=>{let r,a,s=-1,i=t[1],o=0,u=7,c=4;for(0===i&&(u=138,c=3),t[2*(n+1)+1]=65535,r=0;r<=n;r++)a=i,i=t[2*(r+1)+1],++o{let r,a,s=-1,i=t[1],o=0,u=7,c=4;for(0===i&&(u=138,c=3),r=0;r<=n;r++)if(a=i,i=t[2*(r+1)+1],!(++o{ct(e,0+(r?1:0),3),pt(e),ut(e,n),ut(e,~n),n&&e.pending_buf.set(e.window.subarray(t,t+n),e.pending),e.pending+=n};var wt=(e,t,n,r)=>{let a,s,i=0;e.level>0?(2===e.strm.data_type&&(e.strm.data_type=(e=>{let t,n=4093624447;for(t=0;t<=31;t++,n>>>=1)if(1&n&&0!==e.dyn_ltree[2*t])return 0;if(0!==e.dyn_ltree[18]||0!==e.dyn_ltree[20]||0!==e.dyn_ltree[26])return 1;for(t=32;t{let t;for(yt(e,e.dyn_ltree,e.l_desc.max_code),yt(e,e.dyn_dtree,e.d_desc.max_code),gt(e,e.bl_desc),t=18;t>=3&&0===e.bl_tree[2*Ye[t]+1];t--);return e.opt_len+=3*(t+1)+5+5+4,t})(e),a=e.opt_len+3+7>>>3,s=e.static_len+3+7>>>3,s<=a&&(a=s)):a=s=n+5,n+4<=a&&-1!==t?Et(e,t,n,r):4===e.strategy||s===a?(ct(e,2+(r?1:0),3),mt(e,Ze,Je)):(ct(e,4+(r?1:0),3),((e,t,n,r)=>{let a;for(ct(e,t-257,5),ct(e,n-1,5),ct(e,r-4,4),a=0;a{bt||((()=>{let e,t,n,r,a;const s=new Array(16);for(n=0,r=0;r<28;r++)for(et[r]=n,e=0;e<1<>=7;r(e.pending_buf[e.sym_buf+e.sym_next++]=t,e.pending_buf[e.sym_buf+e.sym_next++]=t>>8,e.pending_buf[e.sym_buf+e.sym_next++]=n,0===t?e.dyn_ltree[2*n]++:(e.matches++,t--,e.dyn_ltree[2*($e[n]+je+1)]++,e.dyn_dtree[2*ot(t)]++),e.sym_next===e.sym_end),_tr_align:e=>{ct(e,2,3),lt(e,256,Ze),(e=>{16===e.bi_valid?(ut(e,e.bi_buf),e.bi_buf=0,e.bi_valid=0):e.bi_valid>=8&&(e.pending_buf[e.pending++]=255&e.bi_buf,e.bi_buf>>=8,e.bi_valid-=8)})(e)}};var Ct=(e,t,n,r)=>{let a=65535&e|0,s=e>>>16&65535|0,i=0;for(;0!==n;){i=n>2e3?2e3:n,n-=i;do{a=a+t[r++]|0,s=s+a|0}while(--i);a%=65521,s%=65521}return a|s<<16|0};const Tt=new Uint32Array((()=>{let e,t=[];for(var n=0;n<256;n++){e=n;for(var r=0;r<8;r++)e=1&e?3988292384^e>>>1:e>>>1;t[n]=e}return t})());var St=(e,t,n,r)=>{const a=Tt,s=r+n;e^=-1;for(let n=r;n>>8^a[255&(e^t[n])];return-1^e},It={2:"need dictionary",1:"stream end",0:"","-1":"file error","-2":"stream error","-3":"data error","-4":"insufficient memory","-5":"buffer error","-6":"incompatible version"},Nt={Z_NO_FLUSH:0,Z_PARTIAL_FLUSH:1,Z_SYNC_FLUSH:2,Z_FULL_FLUSH:3,Z_FINISH:4,Z_BLOCK:5,Z_TREES:6,Z_OK:0,Z_STREAM_END:1,Z_NEED_DICT:2,Z_ERRNO:-1,Z_STREAM_ERROR:-2,Z_DATA_ERROR:-3,Z_MEM_ERROR:-4,Z_BUF_ERROR:-5,Z_NO_COMPRESSION:0,Z_BEST_SPEED:1,Z_BEST_COMPRESSION:9,Z_DEFAULT_COMPRESSION:-1,Z_FILTERED:1,Z_HUFFMAN_ONLY:2,Z_RLE:3,Z_FIXED:4,Z_DEFAULT_STRATEGY:0,Z_BINARY:0,Z_TEXT:1,Z_UNKNOWN:2,Z_DEFLATED:8};const{_tr_init:Mt,_tr_stored_block:At,_tr_flush_block:Ot,_tr_tally:Ut,_tr_align:Rt}=xt,{Z_NO_FLUSH:Lt,Z_PARTIAL_FLUSH:Dt,Z_FULL_FLUSH:Pt,Z_FINISH:Ft,Z_BLOCK:Gt,Z_OK:qt,Z_STREAM_END:Ht,Z_STREAM_ERROR:jt,Z_DATA_ERROR:zt,Z_BUF_ERROR:Vt,Z_DEFAULT_COMPRESSION:Bt,Z_FILTERED:Qt,Z_HUFFMAN_ONLY:Kt,Z_RLE:Wt,Z_FIXED:Yt,Z_DEFAULT_STRATEGY:Zt,Z_UNKNOWN:Jt,Z_DEFLATED:Xt}=Nt,$t=258,en=262,tn=42,nn=113,rn=666,an=(e,t)=>(e.msg=It[t],t),sn=e=>2*e-(e>4?9:0),on=e=>{let t=e.length;for(;--t>=0;)e[t]=0},un=e=>{let t,n,r,a=e.w_size;t=e.hash_size,r=t;do{n=e.head[--r],e.head[r]=n>=a?n-a:0}while(--t);t=a,r=t;do{n=e.prev[--r],e.prev[r]=n>=a?n-a:0}while(--t)};let cn=(e,t,n)=>(t<{const t=e.state;let n=t.pending;n>e.avail_out&&(n=e.avail_out),0!==n&&(e.output.set(t.pending_buf.subarray(t.pending_out,t.pending_out+n),e.next_out),e.next_out+=n,t.pending_out+=n,e.total_out+=n,e.avail_out-=n,t.pending-=n,0===t.pending&&(t.pending_out=0))},hn=(e,t)=>{Ot(e,e.block_start>=0?e.block_start:-1,e.strstart-e.block_start,t),e.block_start=e.strstart,ln(e.strm)},dn=(e,t)=>{e.pending_buf[e.pending++]=t},fn=(e,t)=>{e.pending_buf[e.pending++]=t>>>8&255,e.pending_buf[e.pending++]=255&t},pn=(e,t,n,r)=>{let a=e.avail_in;return a>r&&(a=r),0===a?0:(e.avail_in-=a,t.set(e.input.subarray(e.next_in,e.next_in+a),n),1===e.state.wrap?e.adler=Ct(e.adler,t,a,n):2===e.state.wrap&&(e.adler=St(e.adler,t,a,n)),e.next_in+=a,e.total_in+=a,a)},vn=(e,t)=>{let n,r,a=e.max_chain_length,s=e.strstart,i=e.prev_length,o=e.nice_match;const u=e.strstart>e.w_size-en?e.strstart-(e.w_size-en):0,c=e.window,l=e.w_mask,h=e.prev,d=e.strstart+$t;let f=c[s+i-1],p=c[s+i];e.prev_length>=e.good_match&&(a>>=2),o>e.lookahead&&(o=e.lookahead);do{if(n=t,c[n+i]===p&&c[n+i-1]===f&&c[n]===c[s]&&c[++n]===c[s+1]){s+=2,n++;do{}while(c[++s]===c[++n]&&c[++s]===c[++n]&&c[++s]===c[++n]&&c[++s]===c[++n]&&c[++s]===c[++n]&&c[++s]===c[++n]&&c[++s]===c[++n]&&c[++s]===c[++n]&&si){if(e.match_start=t,i=r,r>=o)break;f=c[s+i-1],p=c[s+i]}}}while((t=h[t&l])>u&&0!=--a);return i<=e.lookahead?i:e.lookahead},_n=e=>{const t=e.w_size;let n,r,a;do{if(r=e.window_size-e.lookahead-e.strstart,e.strstart>=t+(t-en)&&(e.window.set(e.window.subarray(t,t+t-r),0),e.match_start-=t,e.strstart-=t,e.block_start-=t,e.insert>e.strstart&&(e.insert=e.strstart),un(e),r+=t),0===e.strm.avail_in)break;if(n=pn(e.strm,e.window,e.strstart+e.lookahead,r),e.lookahead+=n,e.lookahead+e.insert>=3)for(a=e.strstart-e.insert,e.ins_h=e.window[a],e.ins_h=cn(e,e.ins_h,e.window[a+1]);e.insert&&(e.ins_h=cn(e,e.ins_h,e.window[a+3-1]),e.prev[a&e.w_mask]=e.head[e.ins_h],e.head[e.ins_h]=a,a++,e.insert--,!(e.lookahead+e.insert<3)););}while(e.lookahead{let n,r,a,s=e.pending_buf_size-5>e.w_size?e.w_size:e.pending_buf_size-5,i=0,o=e.strm.avail_in;do{if(n=65535,a=e.bi_valid+42>>3,e.strm.avail_outr+e.strm.avail_in&&(n=r+e.strm.avail_in),n>a&&(n=a),n>8,e.pending_buf[e.pending-2]=~n,e.pending_buf[e.pending-1]=~n>>8,ln(e.strm),r&&(r>n&&(r=n),e.strm.output.set(e.window.subarray(e.block_start,e.block_start+r),e.strm.next_out),e.strm.next_out+=r,e.strm.avail_out-=r,e.strm.total_out+=r,e.block_start+=r,n-=r),n&&(pn(e.strm,e.strm.output,e.strm.next_out,n),e.strm.next_out+=n,e.strm.avail_out-=n,e.strm.total_out+=n)}while(0===i);return o-=e.strm.avail_in,o&&(o>=e.w_size?(e.matches=2,e.window.set(e.strm.input.subarray(e.strm.next_in-e.w_size,e.strm.next_in),0),e.strstart=e.w_size,e.insert=e.strstart):(e.window_size-e.strstart<=o&&(e.strstart-=e.w_size,e.window.set(e.window.subarray(e.w_size,e.w_size+e.strstart),0),e.matches<2&&e.matches++,e.insert>e.strstart&&(e.insert=e.strstart)),e.window.set(e.strm.input.subarray(e.strm.next_in-o,e.strm.next_in),e.strstart),e.strstart+=o,e.insert+=o>e.w_size-e.insert?e.w_size-e.insert:o),e.block_start=e.strstart),e.high_watera&&e.block_start>=e.w_size&&(e.block_start-=e.w_size,e.strstart-=e.w_size,e.window.set(e.window.subarray(e.w_size,e.w_size+e.strstart),0),e.matches<2&&e.matches++,a+=e.w_size,e.insert>e.strstart&&(e.insert=e.strstart)),a>e.strm.avail_in&&(a=e.strm.avail_in),a&&(pn(e.strm,e.window,e.strstart,a),e.strstart+=a,e.insert+=a>e.w_size-e.insert?e.w_size-e.insert:a),e.high_water>3,a=e.pending_buf_size-a>65535?65535:e.pending_buf_size-a,s=a>e.w_size?e.w_size:a,r=e.strstart-e.block_start,(r>=s||(r||t===Ft)&&t!==Lt&&0===e.strm.avail_in&&r<=a)&&(n=r>a?a:r,i=t===Ft&&0===e.strm.avail_in&&n===r?1:0,At(e,e.block_start,n,i),e.block_start+=n,ln(e.strm)),i?3:1)},gn=(e,t)=>{let n,r;for(;;){if(e.lookahead=3&&(e.ins_h=cn(e,e.ins_h,e.window[e.strstart+3-1]),n=e.prev[e.strstart&e.w_mask]=e.head[e.ins_h],e.head[e.ins_h]=e.strstart),0!==n&&e.strstart-n<=e.w_size-en&&(e.match_length=vn(e,n)),e.match_length>=3)if(r=Ut(e,e.strstart-e.match_start,e.match_length-3),e.lookahead-=e.match_length,e.match_length<=e.max_lazy_match&&e.lookahead>=3){e.match_length--;do{e.strstart++,e.ins_h=cn(e,e.ins_h,e.window[e.strstart+3-1]),n=e.prev[e.strstart&e.w_mask]=e.head[e.ins_h],e.head[e.ins_h]=e.strstart}while(0!=--e.match_length);e.strstart++}else e.strstart+=e.match_length,e.match_length=0,e.ins_h=e.window[e.strstart],e.ins_h=cn(e,e.ins_h,e.window[e.strstart+1]);else r=Ut(e,0,e.window[e.strstart]),e.lookahead--,e.strstart++;if(r&&(hn(e,!1),0===e.strm.avail_out))return 1}return e.insert=e.strstart<2?e.strstart:2,t===Ft?(hn(e,!0),0===e.strm.avail_out?3:4):e.sym_next&&(hn(e,!1),0===e.strm.avail_out)?1:2},yn=(e,t)=>{let n,r,a;for(;;){if(e.lookahead=3&&(e.ins_h=cn(e,e.ins_h,e.window[e.strstart+3-1]),n=e.prev[e.strstart&e.w_mask]=e.head[e.ins_h],e.head[e.ins_h]=e.strstart),e.prev_length=e.match_length,e.prev_match=e.match_start,e.match_length=2,0!==n&&e.prev_length4096)&&(e.match_length=2)),e.prev_length>=3&&e.match_length<=e.prev_length){a=e.strstart+e.lookahead-3,r=Ut(e,e.strstart-1-e.prev_match,e.prev_length-3),e.lookahead-=e.prev_length-1,e.prev_length-=2;do{++e.strstart<=a&&(e.ins_h=cn(e,e.ins_h,e.window[e.strstart+3-1]),n=e.prev[e.strstart&e.w_mask]=e.head[e.ins_h],e.head[e.ins_h]=e.strstart)}while(0!=--e.prev_length);if(e.match_available=0,e.match_length=2,e.strstart++,r&&(hn(e,!1),0===e.strm.avail_out))return 1}else if(e.match_available){if(r=Ut(e,0,e.window[e.strstart-1]),r&&hn(e,!1),e.strstart++,e.lookahead--,0===e.strm.avail_out)return 1}else e.match_available=1,e.strstart++,e.lookahead--}return e.match_available&&(r=Ut(e,0,e.window[e.strstart-1]),e.match_available=0),e.insert=e.strstart<2?e.strstart:2,t===Ft?(hn(e,!0),0===e.strm.avail_out?3:4):e.sym_next&&(hn(e,!1),0===e.strm.avail_out)?1:2};function kn(e,t,n,r,a){this.good_length=e,this.max_lazy=t,this.nice_length=n,this.max_chain=r,this.func=a}const bn=[new kn(0,0,0,0,mn),new kn(4,4,8,4,gn),new kn(4,5,16,8,gn),new kn(4,6,32,32,gn),new kn(4,4,16,16,yn),new kn(8,16,32,32,yn),new kn(8,16,128,128,yn),new kn(8,32,128,256,yn),new kn(32,128,258,1024,yn),new kn(32,258,258,4096,yn)];function En(){this.strm=null,this.status=0,this.pending_buf=null,this.pending_buf_size=0,this.pending_out=0,this.pending=0,this.wrap=0,this.gzhead=null,this.gzindex=0,this.method=Xt,this.last_flush=-1,this.w_size=0,this.w_bits=0,this.w_mask=0,this.window=null,this.window_size=0,this.prev=null,this.head=null,this.ins_h=0,this.hash_size=0,this.hash_bits=0,this.hash_mask=0,this.hash_shift=0,this.block_start=0,this.match_length=0,this.prev_match=0,this.match_available=0,this.strstart=0,this.match_start=0,this.lookahead=0,this.prev_length=0,this.max_chain_length=0,this.max_lazy_match=0,this.level=0,this.strategy=0,this.good_match=0,this.nice_match=0,this.dyn_ltree=new Uint16Array(1146),this.dyn_dtree=new Uint16Array(122),this.bl_tree=new Uint16Array(78),on(this.dyn_ltree),on(this.dyn_dtree),on(this.bl_tree),this.l_desc=null,this.d_desc=null,this.bl_desc=null,this.bl_count=new Uint16Array(16),this.heap=new Uint16Array(573),on(this.heap),this.heap_len=0,this.heap_max=0,this.depth=new Uint16Array(573),on(this.depth),this.sym_buf=0,this.lit_bufsize=0,this.sym_next=0,this.sym_end=0,this.opt_len=0,this.static_len=0,this.matches=0,this.insert=0,this.bi_buf=0,this.bi_valid=0}const wn=e=>{if(!e)return 1;const t=e.state;return!t||t.strm!==e||t.status!==tn&&57!==t.status&&69!==t.status&&73!==t.status&&91!==t.status&&103!==t.status&&t.status!==nn&&t.status!==rn?1:0},xn=e=>{if(wn(e))return an(e,jt);e.total_in=e.total_out=0,e.data_type=Jt;const t=e.state;return t.pending=0,t.pending_out=0,t.wrap<0&&(t.wrap=-t.wrap),t.status=2===t.wrap?57:t.wrap?tn:nn,e.adler=2===t.wrap?0:1,t.last_flush=-2,Mt(t),qt},Cn=e=>{const t=xn(e);var n;return t===qt&&((n=e.state).window_size=2*n.w_size,on(n.head),n.max_lazy_match=bn[n.level].max_lazy,n.good_match=bn[n.level].good_length,n.nice_match=bn[n.level].nice_length,n.max_chain_length=bn[n.level].max_chain,n.strstart=0,n.block_start=0,n.lookahead=0,n.insert=0,n.match_length=n.prev_length=2,n.match_available=0,n.ins_h=0),t},Tn=(e,t,n,r,a,s)=>{if(!e)return jt;let i=1;if(t===Bt&&(t=6),r<0?(i=0,r=-r):r>15&&(i=2,r-=16),a<1||a>9||n!==Xt||r<8||r>15||t<0||t>9||s<0||s>Yt||8===r&&1!==i)return an(e,jt);8===r&&(r=9);const o=new En;return e.state=o,o.strm=e,o.status=tn,o.wrap=i,o.gzhead=null,o.w_bits=r,o.w_size=1<Tn(e,t,Xt,15,8,Zt),deflateInit2:Tn,deflateReset:Cn,deflateResetKeep:xn,deflateSetHeader:(e,t)=>wn(e)||2!==e.state.wrap?jt:(e.state.gzhead=t,qt),deflate:(e,t)=>{if(wn(e)||t>Gt||t<0)return e?an(e,jt):jt;const n=e.state;if(!e.output||0!==e.avail_in&&!e.input||n.status===rn&&t!==Ft)return an(e,0===e.avail_out?Vt:jt);const r=n.last_flush;if(n.last_flush=t,0!==n.pending){if(ln(e),0===e.avail_out)return n.last_flush=-1,qt}else if(0===e.avail_in&&sn(t)<=sn(r)&&t!==Ft)return an(e,Vt);if(n.status===rn&&0!==e.avail_in)return an(e,Vt);if(n.status===tn&&0===n.wrap&&(n.status=nn),n.status===tn){let t=Xt+(n.w_bits-8<<4)<<8,r=-1;if(r=n.strategy>=Kt||n.level<2?0:n.level<6?1:6===n.level?2:3,t|=r<<6,0!==n.strstart&&(t|=32),t+=31-t%31,fn(n,t),0!==n.strstart&&(fn(n,e.adler>>>16),fn(n,65535&e.adler)),e.adler=1,n.status=nn,ln(e),0!==n.pending)return n.last_flush=-1,qt}if(57===n.status)if(e.adler=0,dn(n,31),dn(n,139),dn(n,8),n.gzhead)dn(n,(n.gzhead.text?1:0)+(n.gzhead.hcrc?2:0)+(n.gzhead.extra?4:0)+(n.gzhead.name?8:0)+(n.gzhead.comment?16:0)),dn(n,255&n.gzhead.time),dn(n,n.gzhead.time>>8&255),dn(n,n.gzhead.time>>16&255),dn(n,n.gzhead.time>>24&255),dn(n,9===n.level?2:n.strategy>=Kt||n.level<2?4:0),dn(n,255&n.gzhead.os),n.gzhead.extra&&n.gzhead.extra.length&&(dn(n,255&n.gzhead.extra.length),dn(n,n.gzhead.extra.length>>8&255)),n.gzhead.hcrc&&(e.adler=St(e.adler,n.pending_buf,n.pending,0)),n.gzindex=0,n.status=69;else if(dn(n,0),dn(n,0),dn(n,0),dn(n,0),dn(n,0),dn(n,9===n.level?2:n.strategy>=Kt||n.level<2?4:0),dn(n,3),n.status=nn,ln(e),0!==n.pending)return n.last_flush=-1,qt;if(69===n.status){if(n.gzhead.extra){let t=n.pending,r=(65535&n.gzhead.extra.length)-n.gzindex;for(;n.pending+r>n.pending_buf_size;){let a=n.pending_buf_size-n.pending;if(n.pending_buf.set(n.gzhead.extra.subarray(n.gzindex,n.gzindex+a),n.pending),n.pending=n.pending_buf_size,n.gzhead.hcrc&&n.pending>t&&(e.adler=St(e.adler,n.pending_buf,n.pending-t,t)),n.gzindex+=a,ln(e),0!==n.pending)return n.last_flush=-1,qt;t=0,r-=a}let a=new Uint8Array(n.gzhead.extra);n.pending_buf.set(a.subarray(n.gzindex,n.gzindex+r),n.pending),n.pending+=r,n.gzhead.hcrc&&n.pending>t&&(e.adler=St(e.adler,n.pending_buf,n.pending-t,t)),n.gzindex=0}n.status=73}if(73===n.status){if(n.gzhead.name){let t,r=n.pending;do{if(n.pending===n.pending_buf_size){if(n.gzhead.hcrc&&n.pending>r&&(e.adler=St(e.adler,n.pending_buf,n.pending-r,r)),ln(e),0!==n.pending)return n.last_flush=-1,qt;r=0}t=n.gzindexr&&(e.adler=St(e.adler,n.pending_buf,n.pending-r,r)),n.gzindex=0}n.status=91}if(91===n.status){if(n.gzhead.comment){let t,r=n.pending;do{if(n.pending===n.pending_buf_size){if(n.gzhead.hcrc&&n.pending>r&&(e.adler=St(e.adler,n.pending_buf,n.pending-r,r)),ln(e),0!==n.pending)return n.last_flush=-1,qt;r=0}t=n.gzindexr&&(e.adler=St(e.adler,n.pending_buf,n.pending-r,r))}n.status=103}if(103===n.status){if(n.gzhead.hcrc){if(n.pending+2>n.pending_buf_size&&(ln(e),0!==n.pending))return n.last_flush=-1,qt;dn(n,255&e.adler),dn(n,e.adler>>8&255),e.adler=0}if(n.status=nn,ln(e),0!==n.pending)return n.last_flush=-1,qt}if(0!==e.avail_in||0!==n.lookahead||t!==Lt&&n.status!==rn){let r=0===n.level?mn(n,t):n.strategy===Kt?((e,t)=>{let n;for(;;){if(0===e.lookahead&&(_n(e),0===e.lookahead)){if(t===Lt)return 1;break}if(e.match_length=0,n=Ut(e,0,e.window[e.strstart]),e.lookahead--,e.strstart++,n&&(hn(e,!1),0===e.strm.avail_out))return 1}return e.insert=0,t===Ft?(hn(e,!0),0===e.strm.avail_out?3:4):e.sym_next&&(hn(e,!1),0===e.strm.avail_out)?1:2})(n,t):n.strategy===Wt?((e,t)=>{let n,r,a,s;const i=e.window;for(;;){if(e.lookahead<=$t){if(_n(e),e.lookahead<=$t&&t===Lt)return 1;if(0===e.lookahead)break}if(e.match_length=0,e.lookahead>=3&&e.strstart>0&&(a=e.strstart-1,r=i[a],r===i[++a]&&r===i[++a]&&r===i[++a])){s=e.strstart+$t;do{}while(r===i[++a]&&r===i[++a]&&r===i[++a]&&r===i[++a]&&r===i[++a]&&r===i[++a]&&r===i[++a]&&r===i[++a]&&ae.lookahead&&(e.match_length=e.lookahead)}if(e.match_length>=3?(n=Ut(e,1,e.match_length-3),e.lookahead-=e.match_length,e.strstart+=e.match_length,e.match_length=0):(n=Ut(e,0,e.window[e.strstart]),e.lookahead--,e.strstart++),n&&(hn(e,!1),0===e.strm.avail_out))return 1}return e.insert=0,t===Ft?(hn(e,!0),0===e.strm.avail_out?3:4):e.sym_next&&(hn(e,!1),0===e.strm.avail_out)?1:2})(n,t):bn[n.level].func(n,t);if(3!==r&&4!==r||(n.status=rn),1===r||3===r)return 0===e.avail_out&&(n.last_flush=-1),qt;if(2===r&&(t===Dt?Rt(n):t!==Gt&&(At(n,0,0,!1),t===Pt&&(on(n.head),0===n.lookahead&&(n.strstart=0,n.block_start=0,n.insert=0))),ln(e),0===e.avail_out))return n.last_flush=-1,qt}return t!==Ft?qt:n.wrap<=0?Ht:(2===n.wrap?(dn(n,255&e.adler),dn(n,e.adler>>8&255),dn(n,e.adler>>16&255),dn(n,e.adler>>24&255),dn(n,255&e.total_in),dn(n,e.total_in>>8&255),dn(n,e.total_in>>16&255),dn(n,e.total_in>>24&255)):(fn(n,e.adler>>>16),fn(n,65535&e.adler)),ln(e),n.wrap>0&&(n.wrap=-n.wrap),0!==n.pending?qt:Ht)},deflateEnd:e=>{if(wn(e))return jt;const t=e.state.status;return e.state=null,t===nn?an(e,zt):qt},deflateSetDictionary:(e,t)=>{let n=t.length;if(wn(e))return jt;const r=e.state,a=r.wrap;if(2===a||1===a&&r.status!==tn||r.lookahead)return jt;if(1===a&&(e.adler=Ct(e.adler,t,n,0)),r.wrap=0,n>=r.w_size){0===a&&(on(r.head),r.strstart=0,r.block_start=0,r.insert=0);let e=new Uint8Array(r.w_size);e.set(t.subarray(n-r.w_size,n),0),t=e,n=r.w_size}const s=e.avail_in,i=e.next_in,o=e.input;for(e.avail_in=n,e.next_in=0,e.input=t,_n(r);r.lookahead>=3;){let e=r.strstart,t=r.lookahead-2;do{r.ins_h=cn(r,r.ins_h,r.window[e+3-1]),r.prev[e&r.w_mask]=r.head[r.ins_h],r.head[r.ins_h]=e,e++}while(--t);r.strstart=e,r.lookahead=2,_n(r)}return r.strstart+=r.lookahead,r.block_start=r.strstart,r.insert=r.lookahead,r.lookahead=0,r.match_length=r.prev_length=2,r.match_available=0,e.next_in=i,e.input=o,e.avail_in=s,r.wrap=a,qt},deflateInfo:"pako deflate (from Nodeca project)"};const In=(e,t)=>Object.prototype.hasOwnProperty.call(e,t);var Nn={assign:function(e){const t=Array.prototype.slice.call(arguments,1);for(;t.length;){const n=t.shift();if(n){if("object"!=typeof n)throw new TypeError(n+"must be non-object");for(const t in n)In(n,t)&&(e[t]=n[t])}}return e},flattenChunks:e=>{let t=0;for(let n=0,r=e.length;n=252?6:e>=248?5:e>=240?4:e>=224?3:e>=192?2:1;An[254]=An[254]=1;var On={string2buf:e=>{if("function"==typeof TextEncoder&&TextEncoder.prototype.encode)return(new TextEncoder).encode(e);let t,n,r,a,s,i=e.length,o=0;for(a=0;a>>6,t[s++]=128|63&n):n<65536?(t[s++]=224|n>>>12,t[s++]=128|n>>>6&63,t[s++]=128|63&n):(t[s++]=240|n>>>18,t[s++]=128|n>>>12&63,t[s++]=128|n>>>6&63,t[s++]=128|63&n);return t},buf2string:(e,t)=>{const n=t||e.length;if("function"==typeof TextDecoder&&TextDecoder.prototype.decode)return(new TextDecoder).decode(e.subarray(0,t));let r,a;const s=new Array(2*n);for(a=0,r=0;r4)s[a++]=65533,r+=i-1;else{for(t&=2===i?31:3===i?15:7;i>1&&r1?s[a++]=65533:t<65536?s[a++]=t:(t-=65536,s[a++]=55296|t>>10&1023,s[a++]=56320|1023&t)}}return((e,t)=>{if(t<65534&&e.subarray&&Mn)return String.fromCharCode.apply(null,e.length===t?e:e.subarray(0,t));let n="";for(let r=0;r{(t=t||e.length)>e.length&&(t=e.length);let n=t-1;for(;n>=0&&128==(192&e[n]);)n--;return n<0||0===n?t:n+An[e[n]]>t?n:t}};var Un=function(){this.input=null,this.next_in=0,this.avail_in=0,this.total_in=0,this.output=null,this.next_out=0,this.avail_out=0,this.total_out=0,this.msg="",this.state=null,this.data_type=2,this.adler=0};const Rn=Object.prototype.toString,{Z_NO_FLUSH:Ln,Z_SYNC_FLUSH:Dn,Z_FULL_FLUSH:Pn,Z_FINISH:Fn,Z_OK:Gn,Z_STREAM_END:qn,Z_DEFAULT_COMPRESSION:Hn,Z_DEFAULT_STRATEGY:jn,Z_DEFLATED:zn}=Nt;function Vn(e){this.options=Nn.assign({level:Hn,method:zn,chunkSize:16384,windowBits:15,memLevel:8,strategy:jn},e||{});let t=this.options;t.raw&&t.windowBits>0?t.windowBits=-t.windowBits:t.gzip&&t.windowBits>0&&t.windowBits<16&&(t.windowBits+=16),this.err=0,this.msg="",this.ended=!1,this.chunks=[],this.strm=new Un,this.strm.avail_out=0;let n=Sn.deflateInit2(this.strm,t.level,t.method,t.windowBits,t.memLevel,t.strategy);if(n!==Gn)throw new Error(It[n]);if(t.header&&Sn.deflateSetHeader(this.strm,t.header),t.dictionary){let e;if(e="string"==typeof t.dictionary?On.string2buf(t.dictionary):"[object ArrayBuffer]"===Rn.call(t.dictionary)?new Uint8Array(t.dictionary):t.dictionary,n=Sn.deflateSetDictionary(this.strm,e),n!==Gn)throw new Error(It[n]);this._dict_set=!0}}function Bn(e,t){const n=new Vn(t);if(n.push(e,!0),n.err)throw n.msg||It[n.err];return n.result}Vn.prototype.push=function(e,t){const n=this.strm,r=this.options.chunkSize;let a,s;if(this.ended)return!1;for(s=t===~~t?t:!0===t?Fn:Ln,"string"==typeof e?n.input=On.string2buf(e):"[object ArrayBuffer]"===Rn.call(e)?n.input=new Uint8Array(e):n.input=e,n.next_in=0,n.avail_in=n.input.length;;)if(0===n.avail_out&&(n.output=new Uint8Array(r),n.next_out=0,n.avail_out=r),(s===Dn||s===Pn)&&n.avail_out<=6)this.onData(n.output.subarray(0,n.next_out)),n.avail_out=0;else{if(a=Sn.deflate(n,s),a===qn)return n.next_out>0&&this.onData(n.output.subarray(0,n.next_out)),a=Sn.deflateEnd(this.strm),this.onEnd(a),this.ended=!0,a===Gn;if(0!==n.avail_out){if(s>0&&n.next_out>0)this.onData(n.output.subarray(0,n.next_out)),n.avail_out=0;else if(0===n.avail_in)break}else this.onData(n.output)}return!0},Vn.prototype.onData=function(e){this.chunks.push(e)},Vn.prototype.onEnd=function(e){e===Gn&&(this.result=Nn.flattenChunks(this.chunks)),this.chunks=[],this.err=e,this.msg=this.strm.msg};var Qn={Deflate:Vn,deflate:Bn,deflateRaw:function(e,t){return(t=t||{}).raw=!0,Bn(e,t)},gzip:function(e,t){return(t=t||{}).gzip=!0,Bn(e,t)},constants:Nt};const Kn=16209;var Wn=function(e,t){let n,r,a,s,i,o,u,c,l,h,d,f,p,v,_,m,g,y,k,b,E,w,x,C;const T=e.state;n=e.next_in,x=e.input,r=n+(e.avail_in-5),a=e.next_out,C=e.output,s=a-(t-e.avail_out),i=a+(e.avail_out-257),o=T.dmax,u=T.wsize,c=T.whave,l=T.wnext,h=T.window,d=T.hold,f=T.bits,p=T.lencode,v=T.distcode,_=(1<>>24,d>>>=y,f-=y,y=g>>>16&255,0===y)C[a++]=65535&g;else{if(!(16&y)){if(0==(64&y)){g=p[(65535&g)+(d&(1<>>=y,f-=y),f<15&&(d+=x[n++]<>>24,d>>>=y,f-=y,y=g>>>16&255,!(16&y)){if(0==(64&y)){g=v[(65535&g)+(d&(1<o){e.msg="invalid distance too far back",T.mode=Kn;break e}if(d>>>=y,f-=y,y=a-s,b>y){if(y=b-y,y>c&&T.sane){e.msg="invalid distance too far back",T.mode=Kn;break e}if(E=0,w=h,0===l){if(E+=u-y,y2;)C[a++]=w[E++],C[a++]=w[E++],C[a++]=w[E++],k-=3;k&&(C[a++]=w[E++],k>1&&(C[a++]=w[E++]))}else{E=a-b;do{C[a++]=C[E++],C[a++]=C[E++],C[a++]=C[E++],k-=3}while(k>2);k&&(C[a++]=C[E++],k>1&&(C[a++]=C[E++]))}break}}break}}while(n>3,n-=k,f-=k<<3,d&=(1<{const u=o.bits;let c,l,h,d,f,p,v=0,_=0,m=0,g=0,y=0,k=0,b=0,E=0,w=0,x=0,C=null;const T=new Uint16Array(16),S=new Uint16Array(16);let I,N,M,A=null;for(v=0;v<=Yn;v++)T[v]=0;for(_=0;_=1&&0===T[g];g--);if(y>g&&(y=g),0===g)return a[s++]=20971520,a[s++]=20971520,o.bits=1,0;for(m=1;m0&&(0===e||1!==g))return-1;for(S[1]=0,v=1;v852||2===e&&w>592)return 1;for(;;){I=v-b,i[_]+1=p?(N=A[i[_]-p],M=C[i[_]-p]):(N=96,M=0),c=1<>b)+l]=I<<24|N<<16|M|0}while(0!==l);for(c=1<>=1;if(0!==c?(x&=c-1,x+=c):x=0,_++,0==--T[v]){if(v===g)break;v=t[n+i[_]]}if(v>y&&(x&d)!==h){for(0===b&&(b=y),f+=m,k=v-b,E=1<852||2===e&&w>592)return 1;h=x&d,a[h]=y<<24|k<<16|f-s|0}}return 0!==x&&(a[f+x]=v-b<<24|64<<16|0),o.bits=y,0};const{Z_FINISH:tr,Z_BLOCK:nr,Z_TREES:rr,Z_OK:ar,Z_STREAM_END:sr,Z_NEED_DICT:ir,Z_STREAM_ERROR:or,Z_DATA_ERROR:ur,Z_MEM_ERROR:cr,Z_BUF_ERROR:lr,Z_DEFLATED:hr}=Nt,dr=16180,fr=16190,pr=16191,vr=16192,_r=16194,mr=16199,gr=16200,yr=16206,kr=16209,br=e=>(e>>>24&255)+(e>>>8&65280)+((65280&e)<<8)+((255&e)<<24);function Er(){this.strm=null,this.mode=0,this.last=!1,this.wrap=0,this.havedict=!1,this.flags=0,this.dmax=0,this.check=0,this.total=0,this.head=null,this.wbits=0,this.wsize=0,this.whave=0,this.wnext=0,this.window=null,this.hold=0,this.bits=0,this.length=0,this.offset=0,this.extra=0,this.lencode=null,this.distcode=null,this.lenbits=0,this.distbits=0,this.ncode=0,this.nlen=0,this.ndist=0,this.have=0,this.next=null,this.lens=new Uint16Array(320),this.work=new Uint16Array(288),this.lendyn=null,this.distdyn=null,this.sane=0,this.back=0,this.was=0}const wr=e=>{if(!e)return 1;const t=e.state;return!t||t.strm!==e||t.mode16211?1:0},xr=e=>{if(wr(e))return or;const t=e.state;return e.total_in=e.total_out=t.total=0,e.msg="",t.wrap&&(e.adler=1&t.wrap),t.mode=dr,t.last=0,t.havedict=0,t.flags=-1,t.dmax=32768,t.head=null,t.hold=0,t.bits=0,t.lencode=t.lendyn=new Int32Array(852),t.distcode=t.distdyn=new Int32Array(592),t.sane=1,t.back=-1,ar},Cr=e=>{if(wr(e))return or;const t=e.state;return t.wsize=0,t.whave=0,t.wnext=0,xr(e)},Tr=(e,t)=>{let n;if(wr(e))return or;const r=e.state;return t<0?(n=0,t=-t):(n=5+(t>>4),t<48&&(t&=15)),t&&(t<8||t>15)?or:(null!==r.window&&r.wbits!==t&&(r.window=null),r.wrap=n,r.wbits=t,Cr(e))},Sr=(e,t)=>{if(!e)return or;const n=new Er;e.state=n,n.strm=e,n.window=null,n.mode=dr;const r=Tr(e,t);return r!==ar&&(e.state=null),r};let Ir,Nr,Mr=!0;const Ar=e=>{if(Mr){Ir=new Int32Array(512),Nr=new Int32Array(32);let t=0;for(;t<144;)e.lens[t++]=8;for(;t<256;)e.lens[t++]=9;for(;t<280;)e.lens[t++]=7;for(;t<288;)e.lens[t++]=8;for(er(1,e.lens,0,288,Ir,0,e.work,{bits:9}),t=0;t<32;)e.lens[t++]=5;er(2,e.lens,0,32,Nr,0,e.work,{bits:5}),Mr=!1}e.lencode=Ir,e.lenbits=9,e.distcode=Nr,e.distbits=5},Or=(e,t,n,r)=>{let a;const s=e.state;return null===s.window&&(s.wsize=1<=s.wsize?(s.window.set(t.subarray(n-s.wsize,n),0),s.wnext=0,s.whave=s.wsize):(a=s.wsize-s.wnext,a>r&&(a=r),s.window.set(t.subarray(n-r,n-r+a),s.wnext),(r-=a)?(s.window.set(t.subarray(n-r,n),0),s.wnext=r,s.whave=s.wsize):(s.wnext+=a,s.wnext===s.wsize&&(s.wnext=0),s.whaveSr(e,15),inflateInit2:Sr,inflate:(e,t)=>{let n,r,a,s,i,o,u,c,l,h,d,f,p,v,_,m,g,y,k,b,E,w,x=0;const C=new Uint8Array(4);let T,S;const I=new Uint8Array([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]);if(wr(e)||!e.output||!e.input&&0!==e.avail_in)return or;n=e.state,n.mode===pr&&(n.mode=vr),i=e.next_out,a=e.output,u=e.avail_out,s=e.next_in,r=e.input,o=e.avail_in,c=n.hold,l=n.bits,h=o,d=u,w=ar;e:for(;;)switch(n.mode){case dr:if(0===n.wrap){n.mode=vr;break}for(;l<16;){if(0===o)break e;o--,c+=r[s++]<>>8&255,n.check=St(n.check,C,2,0),c=0,l=0,n.mode=16181;break}if(n.head&&(n.head.done=!1),!(1&n.wrap)||(((255&c)<<8)+(c>>8))%31){e.msg="incorrect header check",n.mode=kr;break}if((15&c)!==hr){e.msg="unknown compression method",n.mode=kr;break}if(c>>>=4,l-=4,E=8+(15&c),0===n.wbits&&(n.wbits=E),E>15||E>n.wbits){e.msg="invalid window size",n.mode=kr;break}n.dmax=1<>8&1),512&n.flags&&4&n.wrap&&(C[0]=255&c,C[1]=c>>>8&255,n.check=St(n.check,C,2,0)),c=0,l=0,n.mode=16182;case 16182:for(;l<32;){if(0===o)break e;o--,c+=r[s++]<>>8&255,C[2]=c>>>16&255,C[3]=c>>>24&255,n.check=St(n.check,C,4,0)),c=0,l=0,n.mode=16183;case 16183:for(;l<16;){if(0===o)break e;o--,c+=r[s++]<>8),512&n.flags&&4&n.wrap&&(C[0]=255&c,C[1]=c>>>8&255,n.check=St(n.check,C,2,0)),c=0,l=0,n.mode=16184;case 16184:if(1024&n.flags){for(;l<16;){if(0===o)break e;o--,c+=r[s++]<>>8&255,n.check=St(n.check,C,2,0)),c=0,l=0}else n.head&&(n.head.extra=null);n.mode=16185;case 16185:if(1024&n.flags&&(f=n.length,f>o&&(f=o),f&&(n.head&&(E=n.head.extra_len-n.length,n.head.extra||(n.head.extra=new Uint8Array(n.head.extra_len)),n.head.extra.set(r.subarray(s,s+f),E)),512&n.flags&&4&n.wrap&&(n.check=St(n.check,r,f,s)),o-=f,s+=f,n.length-=f),n.length))break e;n.length=0,n.mode=16186;case 16186:if(2048&n.flags){if(0===o)break e;f=0;do{E=r[s+f++],n.head&&E&&n.length<65536&&(n.head.name+=String.fromCharCode(E))}while(E&&f>9&1,n.head.done=!0),e.adler=n.check=0,n.mode=pr;break;case 16189:for(;l<32;){if(0===o)break e;o--,c+=r[s++]<>>=7&l,l-=7&l,n.mode=yr;break}for(;l<3;){if(0===o)break e;o--,c+=r[s++]<>>=1,l-=1,3&c){case 0:n.mode=16193;break;case 1:if(Ar(n),n.mode=mr,t===rr){c>>>=2,l-=2;break e}break;case 2:n.mode=16196;break;case 3:e.msg="invalid block type",n.mode=kr}c>>>=2,l-=2;break;case 16193:for(c>>>=7&l,l-=7&l;l<32;){if(0===o)break e;o--,c+=r[s++]<>>16^65535)){e.msg="invalid stored block lengths",n.mode=kr;break}if(n.length=65535&c,c=0,l=0,n.mode=_r,t===rr)break e;case _r:n.mode=16195;case 16195:if(f=n.length,f){if(f>o&&(f=o),f>u&&(f=u),0===f)break e;a.set(r.subarray(s,s+f),i),o-=f,s+=f,u-=f,i+=f,n.length-=f;break}n.mode=pr;break;case 16196:for(;l<14;){if(0===o)break e;o--,c+=r[s++]<>>=5,l-=5,n.ndist=1+(31&c),c>>>=5,l-=5,n.ncode=4+(15&c),c>>>=4,l-=4,n.nlen>286||n.ndist>30){e.msg="too many length or distance symbols",n.mode=kr;break}n.have=0,n.mode=16197;case 16197:for(;n.have>>=3,l-=3}for(;n.have<19;)n.lens[I[n.have++]]=0;if(n.lencode=n.lendyn,n.lenbits=7,T={bits:n.lenbits},w=er(0,n.lens,0,19,n.lencode,0,n.work,T),n.lenbits=T.bits,w){e.msg="invalid code lengths set",n.mode=kr;break}n.have=0,n.mode=16198;case 16198:for(;n.have>>24,m=x>>>16&255,g=65535&x,!(_<=l);){if(0===o)break e;o--,c+=r[s++]<>>=_,l-=_,n.lens[n.have++]=g;else{if(16===g){for(S=_+2;l>>=_,l-=_,0===n.have){e.msg="invalid bit length repeat",n.mode=kr;break}E=n.lens[n.have-1],f=3+(3&c),c>>>=2,l-=2}else if(17===g){for(S=_+3;l>>=_,l-=_,E=0,f=3+(7&c),c>>>=3,l-=3}else{for(S=_+7;l>>=_,l-=_,E=0,f=11+(127&c),c>>>=7,l-=7}if(n.have+f>n.nlen+n.ndist){e.msg="invalid bit length repeat",n.mode=kr;break}for(;f--;)n.lens[n.have++]=E}}if(n.mode===kr)break;if(0===n.lens[256]){e.msg="invalid code -- missing end-of-block",n.mode=kr;break}if(n.lenbits=9,T={bits:n.lenbits},w=er(1,n.lens,0,n.nlen,n.lencode,0,n.work,T),n.lenbits=T.bits,w){e.msg="invalid literal/lengths set",n.mode=kr;break}if(n.distbits=6,n.distcode=n.distdyn,T={bits:n.distbits},w=er(2,n.lens,n.nlen,n.ndist,n.distcode,0,n.work,T),n.distbits=T.bits,w){e.msg="invalid distances set",n.mode=kr;break}if(n.mode=mr,t===rr)break e;case mr:n.mode=gr;case gr:if(o>=6&&u>=258){e.next_out=i,e.avail_out=u,e.next_in=s,e.avail_in=o,n.hold=c,n.bits=l,Wn(e,d),i=e.next_out,a=e.output,u=e.avail_out,s=e.next_in,r=e.input,o=e.avail_in,c=n.hold,l=n.bits,n.mode===pr&&(n.back=-1);break}for(n.back=0;x=n.lencode[c&(1<>>24,m=x>>>16&255,g=65535&x,!(_<=l);){if(0===o)break e;o--,c+=r[s++]<>y)],_=x>>>24,m=x>>>16&255,g=65535&x,!(y+_<=l);){if(0===o)break e;o--,c+=r[s++]<>>=y,l-=y,n.back+=y}if(c>>>=_,l-=_,n.back+=_,n.length=g,0===m){n.mode=16205;break}if(32&m){n.back=-1,n.mode=pr;break}if(64&m){e.msg="invalid literal/length code",n.mode=kr;break}n.extra=15&m,n.mode=16201;case 16201:if(n.extra){for(S=n.extra;l>>=n.extra,l-=n.extra,n.back+=n.extra}n.was=n.length,n.mode=16202;case 16202:for(;x=n.distcode[c&(1<>>24,m=x>>>16&255,g=65535&x,!(_<=l);){if(0===o)break e;o--,c+=r[s++]<>y)],_=x>>>24,m=x>>>16&255,g=65535&x,!(y+_<=l);){if(0===o)break e;o--,c+=r[s++]<>>=y,l-=y,n.back+=y}if(c>>>=_,l-=_,n.back+=_,64&m){e.msg="invalid distance code",n.mode=kr;break}n.offset=g,n.extra=15&m,n.mode=16203;case 16203:if(n.extra){for(S=n.extra;l>>=n.extra,l-=n.extra,n.back+=n.extra}if(n.offset>n.dmax){e.msg="invalid distance too far back",n.mode=kr;break}n.mode=16204;case 16204:if(0===u)break e;if(f=d-u,n.offset>f){if(f=n.offset-f,f>n.whave&&n.sane){e.msg="invalid distance too far back",n.mode=kr;break}f>n.wnext?(f-=n.wnext,p=n.wsize-f):p=n.wnext-f,f>n.length&&(f=n.length),v=n.window}else v=a,p=i-n.offset,f=n.length;f>u&&(f=u),u-=f,n.length-=f;do{a[i++]=v[p++]}while(--f);0===n.length&&(n.mode=gr);break;case 16205:if(0===u)break e;a[i++]=n.length,u--,n.mode=gr;break;case yr:if(n.wrap){for(;l<32;){if(0===o)break e;o--,c|=r[s++]<{if(wr(e))return or;let t=e.state;return t.window&&(t.window=null),e.state=null,ar},inflateGetHeader:(e,t)=>{if(wr(e))return or;const n=e.state;return 0==(2&n.wrap)?or:(n.head=t,t.done=!1,ar)},inflateSetDictionary:(e,t)=>{const n=t.length;let r,a,s;return wr(e)?or:(r=e.state,0!==r.wrap&&r.mode!==fr?or:r.mode===fr&&(a=1,a=Ct(a,t,n,0),a!==r.check)?ur:(s=Or(e,t,n,n),s?(r.mode=16210,cr):(r.havedict=1,ar)))},inflateInfo:"pako inflate (from Nodeca project)"};var Rr=function(){this.text=0,this.time=0,this.xflags=0,this.os=0,this.extra=null,this.extra_len=0,this.name="",this.comment="",this.hcrc=0,this.done=!1};const Lr=Object.prototype.toString,{Z_NO_FLUSH:Dr,Z_FINISH:Pr,Z_OK:Fr,Z_STREAM_END:Gr,Z_NEED_DICT:qr,Z_STREAM_ERROR:Hr,Z_DATA_ERROR:jr,Z_MEM_ERROR:zr}=Nt;function Vr(e){this.options=Nn.assign({chunkSize:65536,windowBits:15,to:""},e||{});const t=this.options;t.raw&&t.windowBits>=0&&t.windowBits<16&&(t.windowBits=-t.windowBits,0===t.windowBits&&(t.windowBits=-15)),!(t.windowBits>=0&&t.windowBits<16)||e&&e.windowBits||(t.windowBits+=32),t.windowBits>15&&t.windowBits<48&&0==(15&t.windowBits)&&(t.windowBits|=15),this.err=0,this.msg="",this.ended=!1,this.chunks=[],this.strm=new Un,this.strm.avail_out=0;let n=Ur.inflateInit2(this.strm,t.windowBits);if(n!==Fr)throw new Error(It[n]);if(this.header=new Rr,Ur.inflateGetHeader(this.strm,this.header),t.dictionary&&("string"==typeof t.dictionary?t.dictionary=On.string2buf(t.dictionary):"[object ArrayBuffer]"===Lr.call(t.dictionary)&&(t.dictionary=new Uint8Array(t.dictionary)),t.raw&&(n=Ur.inflateSetDictionary(this.strm,t.dictionary),n!==Fr)))throw new Error(It[n])}function Br(e,t){const n=new Vr(t);if(n.push(e),n.err)throw n.msg||It[n.err];return n.result}Vr.prototype.push=function(e,t){const n=this.strm,r=this.options.chunkSize,a=this.options.dictionary;let s,i,o;if(this.ended)return!1;for(i=t===~~t?t:!0===t?Pr:Dr,"[object ArrayBuffer]"===Lr.call(e)?n.input=new Uint8Array(e):n.input=e,n.next_in=0,n.avail_in=n.input.length;;){for(0===n.avail_out&&(n.output=new Uint8Array(r),n.next_out=0,n.avail_out=r),s=Ur.inflate(n,i),s===qr&&a&&(s=Ur.inflateSetDictionary(n,a),s===Fr?s=Ur.inflate(n,i):s===jr&&(s=qr));n.avail_in>0&&s===Gr&&n.state.wrap>0&&0!==e[n.next_in];)Ur.inflateReset(n),s=Ur.inflate(n,i);switch(s){case Hr:case jr:case qr:case zr:return this.onEnd(s),this.ended=!0,!1}if(o=n.avail_out,n.next_out&&(0===n.avail_out||s===Gr))if("string"===this.options.to){let e=On.utf8border(n.output,n.next_out),t=n.next_out-e,a=On.buf2string(n.output,e);n.next_out=t,n.avail_out=r-t,t&&n.output.set(n.output.subarray(e,e+t),0),this.onData(a)}else this.onData(n.output.length===n.next_out?n.output:n.output.subarray(0,n.next_out));if(s!==Fr||0!==o){if(s===Gr)return s=Ur.inflateEnd(this.strm),this.onEnd(s),this.ended=!0,!0;if(0===n.avail_in)break}}return!0},Vr.prototype.onData=function(e){this.chunks.push(e)},Vr.prototype.onEnd=function(e){e===Fr&&("string"===this.options.to?this.result=this.chunks.join(""):this.result=Nn.flattenChunks(this.chunks)),this.chunks=[],this.err=e,this.msg=this.strm.msg};var Qr={Inflate:Vr,inflate:Br,inflateRaw:function(e,t){return(t=t||{}).raw=!0,Br(e,t)},ungzip:Br,constants:Nt};const{Deflate:Kr,deflate:Wr,deflateRaw:Yr,gzip:Zr}=Qn,{Inflate:Jr,inflate:Xr,inflateRaw:$r,ungzip:ea}=Qr;var ta,na={Deflate:Kr,deflate:Wr,deflateRaw:Yr,gzip:Zr,Inflate:Jr,inflate:Xr,inflateRaw:$r,ungzip:ea,constants:Nt},ra=function(e){return b(void 0,void 0,void 0,t().mark((function n(){var r;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return r=na.ungzip(e),t.abrupt("return",String.fromCharCode.apply(null,r));case 2:case"end":return t.stop()}}),n)})))};e.ConnectionState=void 0,(ta=e.ConnectionState||(e.ConnectionState={})).CONNECTING="CONNECTING",ta.OPEN="OPEN",ta.CLOSED="CLOSED";var aa,sa=function(n){i(o,n);var a=f(o);function o(e,t){var n,s=t.sdkState,i=t.dispatcher,u=t.logger;return r(this,o),(n=a.call(this)).lastActive=0,n._iid=e,n._sdkState=s,n._dispatcher=i,n._logger=u,n}return s(o,[{key:"isOpen",get:function(){return this.connectionState===e.ConnectionState.OPEN}},{key:"connectionState",get:function(){if(this._ws)switch(this._ws.readyState){case 0:return e.ConnectionState.CONNECTING;case 1:return e.ConnectionState.OPEN}return e.ConnectionState.CLOSED}},{key:"_handleMessage",value:function(e){var t=this;e.split("\n").forEach((function(e){if(e){var n=Ge.createFromRawMessage(t._iid,e);if(t._logger.debug("receive websocket event",n),"LOGI"===n.code)t.dispatch("message",n);else if("PONG"===n.code)t.dispatch("pong");else if("EXPR"===n.code){if(n.payload){var r=new Re(n.payload);r.expiresIn>=0&&t._dispatcher.dispatch(r)}}else"NOOP"===n.code||t.dispatch("message",n)}}))}},{key:"connect",value:function(e){var n=this;this._ws=new WebSocket(e),this._ws.onopen=function(){n._logger.debug("websocket open"),n.dispatch("open")},this._ws.onmessage=function(e){return b(n,void 0,void 0,t().mark((function n(){var r,a,s=this;return t().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:(null===(r=this._sdkState.websocket)||void 0===r?void 0:r.compression)?e.data instanceof Blob?((a=new FileReader).readAsArrayBuffer(e.data),a.onloadend=function(){return b(s,void 0,void 0,t().mark((function e(){var n;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,ra(a.result);case 2:n=e.sent,this._handleMessage(n);case 4:case"end":return e.stop()}}),e,this)})))}):"string"==typeof e.data&&this._handleMessage(e.data):this._handleMessage(e.data);case 1:case"end":return n.stop()}}),n,this)})))},this._ws.onerror=function(){n._logger.debug("websocket error"),n.dispatch("error",A.networkError)},this._ws.onclose=function(){n._logger.debug("websocket close"),n.dispatch("close")},this.lastActive=Date.now()}},{key:"disconnect",value:function(){var t=this;return new Promise((function(n){t._logger.debug("websocket disconnect"),t._ws&&t.connectionState!==e.ConnectionState.CLOSED?(t._ws.onopen=qe,t._ws.onmessage=qe,t._ws.onerror=qe,t._ws.onclose=function(){t.dispatch("close"),n()},t._ws.close(),t._ws=null):n()}))}},{key:"send",value:function(e){if(!this._ws)throw A.connectionClosed;"PING"!==e.code?this.dispatch("ping-refresh"):this._logger.debug("send ping",e),this._ws.send(e.convertToMessage())}},{key:"error",value:function(e){this._logger.debug("websocket error",e),this.dispatch("error",e)}}]),o}(se),ia=function(e){i(n,e);var t=f(n);function n(e){var a,s,i=e.code,o=e.ackRequired,u=e.payload,c=void 0===u?null:u;return r(this,n),(a=t.call(this)).code=i,a.payload=c,a.requestId=null!==(s=a.payload.req_id)&&void 0!==s?s:re(),a.ackRequired=o,a.payload.req_id=a.requestId,a}return s(n,[{key:"convertToMessage",value:function(){return"".concat(this.code).concat(JSON.stringify(this.payload),"\n")}}]),n}(oe),oa=function(e){i(n,e);var t=f(n);function n(e){var a,s=e.all,i=e.custom_types,o=e.ts;return r(this,n),(a=t.call(this)).all=s,a.customTypes=i,a.ts=o,a}return s(n)}(oe),ua=s((function e(){var t=this;r(this,e),this.promise=new Promise((function(e,n){t.resolve=e,t.reject=n}))})),ca=function(){function e(t,n){var a=this,s=n.auth,i=n.sdkState,o=n.dispatcher,u=n.logger,c=n.useFetchCompat,l=void 0!==c&&c;r(this,e),this._ackStateMap=new Map,this._sdkState=i,this._dispatcher=o,this._logger=u,this.apiClient=new Fe(t,{auth:s,sdkState:i,dispatcher:o,logger:u,useFetchCompat:l}),this.websocketClient=new sa(t,{sdkState:i,dispatcher:o,logger:u}),this.websocketClient.on("message",(function(e){if(e.payload.unread_cnt&&a._dispatcher.dispatch(new oa(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 A({code:e.payload.code,message:e.payload.message}))}}else a._dispatcher.dispatch(e)})).on("close",(function(){a._ackStateMap.forEach((function(e){e.reject(A.connectionClosed)})),a._ackStateMap.clear()}))}return s(e,[{key:"_sendApiRequest",value:function(e){return b(this,void 0,void 0,t().mark((function n(){return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,this.apiClient.send(e);case 2:return t.abrupt("return",t.sent);case 3:case"end":return t.stop()}}),n,this)})))}},{key:"_sendWebsocketRequest",value:function(e){return b(this,void 0,void 0,t().mark((function n(){var r,a,s,i=this;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(r=new ua,e.ackRequired){a=null,s=function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:null,n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null;i._ackStateMap.has(e.requestId)&&(i._ackStateMap.delete(e.requestId),a&&(clearTimeout(a),a=null),t?(i._logger.debug("fail websocket request",t),r.reject(t)):(i._logger.debug("receive websocket ack",e.requestId),r.resolve(n)))};try{a=setTimeout((function(){return s(A.noAckTimeout)}),this._sdkState.websocket.responseTimeout),this._ackStateMap.set(e.requestId,{resolve:function(e){return s(null,e)},reject:function(e){return s(e)}}),this.websocketClient.send(e)}catch(e){s(e)}}else try{this.websocketClient.send(e),r.resolve(null)}catch(e){r.reject(e)}return t.abrupt("return",r.promise);case 3:case"end":return t.stop()}}),n,this)})))}},{key:"send",value:function(e){return b(this,void 0,void 0,t().mark((function n(){return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(!(e instanceof Ae)){t.next=6;break}return t.next=3,this._sendApiRequest(e);case 3:case 9:return t.abrupt("return",t.sent);case 6:if(!(e instanceof ia)){t.next=10;break}return t.next=9,this._sendWebsocketRequest(e);case 10:throw A.invalidParameters;case 11:case"end":return t.stop()}}),n,this)})))}},{key:"cancel",value:function(e){this.apiClient.cancel(e)}},{key:"cancelAll",value:function(){this.apiClient.cancelAll()}}]),e}();!function(e){e[e.NONE=0]="NONE",e[e.INITIALIZED=1]="INITIALIZED",e[e.CONNECTING=2]="CONNECTING",e[e.CONNECTED=3]="CONNECTED",e[e.RECONNECTING=4]="RECONNECTING",e[e.INTERNAL_DISCONNECTED=5]="INTERNAL_DISCONNECTED",e[e.EXTERNAL_DISCONNECTED=6]="EXTERNAL_DISCONNECTED",e[e.LOGOUT=7]="LOGOUT"}(aa||(aa={}));var la,ha=function(e){i(n,e);var t=f(n);function n(e){var a,s=e.stateType;return r(this,n),(a=t.call(this)).stateType=s,a}return s(n)}(oe),da=function(){function e(n,a){var s=this,i=a.auth,o=a.sdkState,u=a.dispatcher,c=a.logger,l=a.useFetchCompat,h=void 0!==l&&l;r(this,e),this._currentConnectionStateType=aa.INITIALIZED,this._lazyCallQueue=[],this.commandRouter=new ca(n,{auth:i,sdkState:o,dispatcher:u,logger:c,useFetchCompat:h}),this._auth=i,this._logger=c,this._dispatcher=u,this._dispatcher.on((function(e){if(e instanceof ha){var n=e.stateType;switch(s._currentConnectionStateType=n,n){case aa.CONNECTED:var r=s._lazyCallQueue;s._lazyCallQueue=[],r.forEach((function(e){return b(s,void 0,void 0,t().mark((function n(){var r,a,s,i;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return r=e.command,a=e.deferred,s=e.timeout,clearTimeout(s),t.prev=2,t.next=5,this.send(r);case 5:i=t.sent,a.resolve(i),t.next=12;break;case 9:t.prev=9,t.t0=t.catch(2),a.reject(t.t0);case 12:case"end":return t.stop()}}),n,this,[[2,9]])})))}));break;case aa.INITIALIZED:case aa.INTERNAL_DISCONNECTED:case aa.EXTERNAL_DISCONNECTED:case aa.LOGOUT:var a=s._lazyCallQueue;s._lazyCallQueue=[],a.forEach((function(e){return b(s,void 0,void 0,t().mark((function n(){var r,a;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:r=e.deferred,a=e.timeout,clearTimeout(a),this._auth&&this._auth.hasSession?r.reject(A.connectionClosed):r.reject(A.connectionRequired);case 3:case"end":return t.stop()}}),n,this)})))}))}}}))}return s(e,[{key:"isReady",get:function(){return this._currentConnectionStateType===aa.CONNECTED}},{key:"isLazyCallActivated",get:function(){return this._currentConnectionStateType===aa.CONNECTING||this._currentConnectionStateType===aa.RECONNECTING}},{key:"send",value:function(e){return b(this,void 0,void 0,t().mark((function n(){var r,a,s,i=this;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(!(e instanceof ia)){t.next=19;break}if(!this.isReady){t.next=8;break}return this._logger.debug("send websocket request",e),t.next=5,this.commandRouter.send(e);case 5:case 24:return t.abrupt("return",t.sent);case 8:if(!this.isLazyCallActivated){t.next=15;break}return this._logger.debug("wait websocket request",e),r=new ua,this._lazyCallQueue.push({command:e,deferred:r,timeout:setTimeout((function(){return i.timeout(e.requestId)}),1e4)}),t.abrupt("return",r.promise);case 15:throw this._logger.debug("fail websocket request"),A.connectionRequired;case 17:t.next=37;break;case 19:if(!(e instanceof Ae)){t.next=37;break}if(!this._auth.hasSession){t.next=27;break}return this._logger.debug("send api request",e),t.next=24,this.commandRouter.send(e);case 27:if(!this.isLazyCallActivated){t.next=34;break}return this._logger.debug("wait api request",e),a=new ua,this._lazyCallQueue.push({command:e,deferred:a,timeout:setTimeout((function(){return i.timeout(e.requestId)}),1e4)}),t.abrupt("return",a.promise);case 34:throw s=A.connectionRequired,this._logger.debug("fail api request",s),s;case 37:case"end":return t.stop()}}),n,this)})))}},{key:"forceSend",value:function(e){return b(this,void 0,void 0,t().mark((function n(){return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return this._logger.debug("send forced request",e),t.next=3,this.commandRouter.send(e);case 3:return t.abrupt("return",t.sent);case 4:case"end":return t.stop()}}),n,this)})))}},{key:"timeout",value:function(e){this._logger.debug("timeout request",e);var t=this._lazyCallQueue.findIndex((function(t){return t.command.requestId===e}));t>-1&&(this._lazyCallQueue[t].deferred.reject(A.connectionRequired),this._lazyCallQueue.splice(t,1))}},{key:"cancel",value:function(e){this._logger.debug("cancel api request",e),this.commandRouter.cancel(e)}},{key:"cancelAll",value:function(){this._logger.debug("cancel all api requests"),this.commandRouter.cancelAll()}}]),e}(),fa="sendbird@devicetokens",pa=function(){function e(t){var n=t.type,a=t.token;r(this,e),this.type=n,this.token=a}return s(e,null,[{key:"payloadify",value:function(e){return{type:e.type,token:e.token}}}]),e}(),va=function(e){i(n,e);var t=f(n);function n(e){var a,s=e.userId,i=e.authToken,o=e.expiringSession,u=void 0===o||o;return r(this,n),(a=t.call(this)).path="".concat(he,"/").concat(s,"/session_key"),a.method=ce.POST,a.params={token:i,expiring_session:!!u},a.requireAuth=!1,a}return s(n)}(Ae),_a=function(e){i(n,e);var t=f(n);function n(e){var a=e.authToken,s=e.expiringSession,i=void 0===s||s,o=e.requestId,u=void 0===o?null:o;return r(this,n),t.call(this,{code:"LOGI",payload:{token:a,expiring_session:i?1:0,req_id:u},ackRequired:!0})}return s(n)}(ia),ma=function(e){i(n,e);var t=f(n);function n(e,a){var s;r(this,n),s=t.call(this,e,a);var i=a.key;return s.key=i,s}return s(n)}(Oe),ga=function(e){i(n,e);var t=f(n);function n(e,a,s){var i;return r(this,n),(i=t.call(this,e,"LOGI",s)).error=null,i.newKey=s.new_key,i.error=s.error?new A(s.error):null,i}return s(n)}(Ge),ya=function(e){i(n,e);var t=f(n);function n(){return r(this,n),t.apply(this,arguments)}return s(n)}(oe),ka=function(e){return b(void 0,void 0,void 0,t().mark((function n(){return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.abrupt("return",new Promise((function(t){return setTimeout(t,e)})));case 1:case"end":return t.stop()}}),n)})))},ba=function(){function e(){r(this,e)}return s(e,[{key:"calcTimeout",value:function(){return 0}}]),e}(),Ea=function(e,n){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:new ba;return b(void 0,void 0,void 0,t().mark((function a(){var s,i,o,u,c;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:s=0,i=null,o=function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:null;return i=null!=e?e:new Error("Halted")},u=function(){s=0};case 4:if(!(-1===n||s=0}},{key:"createRefreshWebsocketCommand",value:function(e){return new _a({authToken:e,expiringSession:!0,requestId:arguments.length>1&&void 0!==arguments[1]?arguments[1]:null})}},{key:"_refreshSessionKeyByWebSocket",value:function(e){return b(this,void 0,void 0,t().mark((function n(){var r,a,s,i,o;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return r=this.createRefreshWebsocketCommand(e),t.next=3,this._requestQueue.forceSend(r);case 3:if(a=t.sent,s=a.as(ga),i=s.newKey,!(o=s.error)){t.next=7;break}throw o;case 7:this.auth.sessionKey=null!=i?i:this.auth.sessionKey;case 8:case"end":return t.stop()}}),n,this)})))}},{key:"_refreshSessionKeyByApi",value:function(e){return b(this,void 0,void 0,t().mark((function n(){var r,a=this;return t().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return r=new va({userId:this._sdkState.userId,authToken:e,expiringSession:!0}),n.next=3,Ea((function(e){return b(a,void 0,void 0,t().mark((function n(){var a,s,i;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.prev=0,t.next=3,this._requestQueue.forceSend(r);case 3:a=t.sent,s=a.as(ma),i=s.key,this.auth.sessionKey=i,t.next=15;break;case 8:if(t.prev=8,t.t0=t.catch(0),!this._isSessionRelatedError(t.t0)){t.next=14;break}e(t.t0),t.next=15;break;case 14:throw t.t0;case 15:case"end":return t.stop()}}),n,this,[[0,8]])})))}),3);case 3:case"end":return n.stop()}}),n,this)})))}},{key:"_refreshSessionKey",value:function(e){var n=!(arguments.length>1&&void 0!==arguments[1])||arguments[1];return b(this,void 0,void 0,t().mark((function r(){return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(this._currentConnectionStateType!==aa.CONNECTED){t.next=25;break}return t.prev=1,t.next=4,this._refreshSessionKeyByWebSocket(e);case 4:return this.complete(),t.abrupt("return");case 8:if(t.prev=8,t.t0=t.catch(1),!this._isSessionRelatedError(t.t0)){t.next=25;break}if(!n){t.next=25;break}return t.next=14,this._receiveNewAuthToken();case 14:if(this.auth.authToken=t.sent,!this.auth.authToken){t.next=21;break}return t.next=18,this._refreshSessionKey(this.auth.authToken,!1);case 18:this.complete(),t.next=24;break;case 21:return t.next=23,this.clear();case 23:this.close();case 24:return t.abrupt("return");case 25:return t.prev=25,t.next=28,this._refreshSessionKeyByApi(e);case 28:this.complete(),t.next=53;break;case 31:if(t.prev=31,t.t1=t.catch(25),!this._isSessionRelatedError(t.t1)){t.next=52;break}if(!n){t.next=49;break}return t.next=37,this._receiveNewAuthToken();case 37:if(this.auth.authToken=t.sent,!this.auth.authToken){t.next=44;break}return t.next=41,this._refreshSessionKeyByApi(this.auth.authToken);case 41:this.complete(),t.next=47;break;case 44:return t.next=46,this.clear();case 46:this.close();case 47:t.next=50;break;case 49:throw t.t1;case 50:t.next=53;break;case 52:throw t.t1;case 53:case"end":return t.stop()}}),r,this,[[1,8],[25,31]])})))}},{key:"_receiveNewAuthToken",value:function(){var e=this,n=new ua;return wa((function(){return b(e,void 0,void 0,t().mark((function e(){var r,a,s=this;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:this._isRefreshingAuthToken=!0,this.auth.clear(),r=null,a=function(){r&&(clearTimeout(r),r=null)},r=setTimeout((function(){s._isRefreshingAuthToken=!1,n.reject()}),1e3*this._sdkState.sessionTokenRefreshTimeout),this.handler.onSessionTokenRequired?this.handler.onSessionTokenRequired((function(e){a(),s._isRefreshingAuthToken&&(s._isRefreshingAuthToken=!1,s.dispatch("refresh-authtoken"),n.resolve(e))}),(function(e){a(),s._isRefreshingAuthToken=!1,n.reject(e)})):n.resolve(null);case 6:case"end":return e.stop()}}),e,this)})))})),n.promise}},{key:"_isSessionRelatedError",value:function(e){return e instanceof A&&(e.isSessionKeyExpiredError||e.isSessionTokenExpiredError||e.isSessionRevokedError)}},{key:"isSessionKeyRefreshing",get:function(){return this._isRefreshingSessionKey}},{key:"isRefreshingAuthToken",get:function(){return this._isRefreshingAuthToken}},{key:"login",value:function(e){var n;return b(this,void 0,void 0,t().mark((function r(){var a,s,i,o,u,c,l;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(a=e.key,s=e.ekey,i=e.userProfile,o=e.deviceTokenLastDeletedAt,u=void 0===o?0:o,this.auth.sessionKey=a,Ca.set(this,s),this._deviceTokenCacheEnabled=null===(n=null==i?void 0:i.appInfo)||void 0===n?void 0:n.deviceTokenCache,c=this._cacheContext.preference,!this._deviceTokenCacheEnabled){t.next=20;break}return t.next=8,c.get(fa);case 8:if((l=t.sent)&&!(l.lastDeletedAt=0&&this._deviceTokens.splice(n,1)}}},{key:"unsetDeviceTokens",value:function(e){this._deviceTokenCacheEnabled&&(this._deviceTokens=e?this._deviceTokens.filter((function(t){return t.type!==e})):[])}},{key:"setDeviceTokenDeletedAt",value:function(e){e>0&&(this._deviceTokenLastDeletedAt=e)}},{key:"saveDeviceToken",value:function(){return b(this,void 0,void 0,t().mark((function e(){var n;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!this._deviceTokenCacheEnabled){e.next=4;break}return n=this._cacheContext.preference,e.next=4,n.set(fa,{tokens:this._deviceTokens,lastDeletedAt:this._deviceTokenLastDeletedAt});case 4:case"end":return e.stop()}}),e,this)})))}},{key:"clear",value:function(){return b(this,void 0,void 0,t().mark((function e(){return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return this.currentUser=null,this.auth.clear(),this.close(),Ca.delete(this),this._deviceTokens=[],this._deviceTokenLastDeletedAt=0,e.next=8,this.saveDeviceToken();case 8:case"end":return e.stop()}}),e,this)})))}}]),a}(se),Sa=function(){function e(){r(this,e),this.type=aa.NONE,this.name="none"}return s(e,[{key:"run",value:function(e){return b(this,void 0,void 0,t().mark((function e(){return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:case"end":return e.stop()}}),e)})))}},{key:"onConnect",value:function(e,n){return b(this,void 0,void 0,t().mark((function e(){return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:case"end":return e.stop()}}),e)})))}},{key:"onReconnect",value:function(e,n){return n.resetReconnectCount,b(this,void 0,void 0,t().mark((function e(){return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:case"end":return e.stop()}}),e)})))}},{key:"onDisconnect",value:function(e,n){return n.error,n.autoReconnect,b(this,void 0,void 0,t().mark((function e(){return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:case"end":return e.stop()}}),e)})))}},{key:"onDisconnectWebSocket",value:function(e){return b(this,void 0,void 0,t().mark((function e(){return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:case"end":return e.stop()}}),e)})))}},{key:"onLogout",value:function(e){return b(this,void 0,void 0,t().mark((function e(){return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:case"end":return e.stop()}}),e)})))}}]),e}(),Ia=function(e){i(a,e);var n=f(a);function a(){var e;return r(this,a),(e=n.apply(this,arguments)).type=aa.LOGOUT,e.name="logout",e}return s(a,[{key:"run",value:function(e){return b(this,void 0,void 0,t().mark((function n(){var r,a,s=this;return t().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return r=Date.now(),a=e.sdkState.userId,n.next=4,e.logout();case 4:return n.next=6,e.changeState(new Ra,r);case 6:wa((function(){return b(s,void 0,void 0,t().mark((function n(){return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:e.connectionHandlers.forEach((function(e){e.onDisconnected(a)}));case 1:case"end":return t.stop()}}),n)})))}));case 7:case"end":return n.stop()}}),n)})))}}]),a}(Sa),Na=function(e){i(a,e);var n=f(a);function a(){var e;return r(this,a),(e=n.call(this)).type=aa.EXTERNAL_DISCONNECTED,e.name="externaldisconnected",e}return s(a,[{key:"run",value:function(e){return b(this,void 0,void 0,t().mark((function n(){return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,e.disconnect();case 2:case"end":return t.stop()}}),n)})))}},{key:"onConnect",value:function(e,n){return b(this,void 0,void 0,t().mark((function r(){var a;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return a=Date.now(),t.next=3,e.disconnect();case 3:return t.next=5,e.changeState(new Ua({authToken:n}),a);case 5:case"end":return t.stop()}}),r)})))}},{key:"onReconnect",value:function(e){return b(this,void 0,void 0,t().mark((function n(){var r;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return r=Date.now(),t.next=3,e.changeState(new Aa,r);case 3:case"end":return t.stop()}}),n)})))}},{key:"onLogout",value:function(e){return b(this,void 0,void 0,t().mark((function n(){var r;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return r=Date.now(),t.next=3,e.changeState(new Ia,r);case 3:case"end":return t.stop()}}),n)})))}}]),a}(Sa),Ma=function(e){i(a,e);var n=f(a);function a(e){var t,s=e.autoReconnect;return r(this,a),(t=n.call(this)).type=aa.INTERNAL_DISCONNECTED,t.name="internaldisconnected",t._autoReconnect=!1,t._autoReconnect=s,t}return s(a,[{key:"run",value:function(e){return b(this,void 0,void 0,t().mark((function n(){var r;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return r=Date.now(),t.next=3,e.disconnect();case 3:if(!this._autoReconnect){t.next=6;break}return t.next=6,e.changeState(new Aa,r);case 6:case"end":return t.stop()}}),n,this)})))}},{key:"onConnect",value:function(e,n){return b(this,void 0,void 0,t().mark((function r(){var a;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return a=Date.now(),t.next=3,e.disconnect();case 3:return t.next=5,e.changeState(new Ua({authToken:n}),a);case 5:case"end":return t.stop()}}),r)})))}},{key:"onReconnect",value:function(e){return b(this,void 0,void 0,t().mark((function n(){var r;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return r=Date.now(),t.next=3,e.changeState(new Aa,r);case 3:case"end":return t.stop()}}),n)})))}},{key:"onDisconnectWebSocket",value:function(e){return b(this,void 0,void 0,t().mark((function n(){var r;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return r=Date.now(),t.next=3,e.changeState(new Na,r);case 3:case"end":return t.stop()}}),n)})))}},{key:"onLogout",value:function(e){return b(this,void 0,void 0,t().mark((function n(){var r;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return r=Date.now(),t.next=3,e.changeState(new Ia,r);case 3:case"end":return t.stop()}}),n)})))}}]),a}(Sa),Aa=function(e){i(a,e);var n=f(a);function a(){var e;return r(this,a),(e=n.apply(this,arguments)).type=aa.RECONNECTING,e.name="reconnecting",e._haltConnect=null,e._resetConnect=null,e._callbacks=[],e}return s(a,[{key:"_halt",value:function(e){this._haltConnect&&(this._haltConnect(e),this._haltConnect=null)}},{key:"_flushCallbacks",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:null;this._haltConnect=null,this._resetConnect=null,this._callbacks.forEach((function(t){return t(e)}))}},{key:"run",value:function(e){return b(this,void 0,void 0,t().mark((function n(){var r,a,s,i,o,u=this;return t().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return r=Date.now(),a=new ua,this._callbacks.push((function(e){return e?a.reject(e):a.resolve()})),wa((function(){return b(u,void 0,void 0,t().mark((function n(){return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:e.connectionHandlers.forEach((function(e){e.onReconnectStarted()}));case 1:case"end":return t.stop()}}),n)})))})),n.prev=4,s=e.sdkState.websocket,i=s.reconnectMaxRetry,o=s.reconnectRetryStrategy,n.next=8,Ea((function(n,r){return b(u,void 0,void 0,t().mark((function a(){return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return this._haltConnect=n,this._resetConnect=r,t.prev=2,t.next=5,e.connect();case 5:t.next=17;break;case 7:if(t.prev=7,t.t0=t.catch(2),e.clearLoginTimer(),!(t.t0 instanceof A)){t.next=16;break}t.t1=t.t0.code,t.next=t.t1===E.CONNECTION_CANCELED?14:16;break;case 14:return n(t.t0),t.abrupt("return");case 16:throw t.t0;case 17:case"end":return t.stop()}}),a,this,[[2,7]])})))}),i,o);case 8:return n.next=10,e.changeState(new Oa,r);case 10:wa((function(){return b(u,void 0,void 0,t().mark((function n(){return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:this._flushCallbacks(null),e.connectionHandlers.forEach((function(e){e.onReconnectSucceeded()}));case 2:case"end":return t.stop()}}),n,this)})))})),n.next=24;break;case 13:if(n.prev=13,n.t0=n.catch(4),M(n.t0)){n.next=23;break}if(!(n.t0 instanceof A)){n.next=20;break}if(n.t0.code===E.CONNECTION_CANCELED){n.next=20;break}return n.next=20,e.changeState(new Ma({autoReconnect:!1}),r);case 20:wa((function(){return b(u,void 0,void 0,t().mark((function r(){return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:this._flushCallbacks(n.t0),e.connectionHandlers.forEach((function(e){e.onReconnectFailed()}));case 2:case"end":return t.stop()}}),r,this)})))})),n.next=24;break;case 23:throw n.t0;case 24:return n.abrupt("return",a.promise);case 25:case"end":return n.stop()}}),n,this,[[4,13]])})))}},{key:"onConnect",value:function(e,n){return b(this,void 0,void 0,t().mark((function r(){var a;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return a=new ua,this._halt(A.connectionCanceled),e.cancelConnectForRetry(),this._callbacks.push((function(){var t=Date.now();e.changeState(new Ua({authToken:n}),t).then((function(){a.resolve()})).catch((function(e){a.reject(e)}))})),t.abrupt("return",a.promise);case 5:case"end":return t.stop()}}),r,this)})))}},{key:"onReconnect",value:function(e,n){var r=n.resetReconnectCount,a=void 0!==r&&r;return b(this,void 0,void 0,t().mark((function e(){var n;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n=new ua,this._resetConnect&&a&&this._resetConnect(),this._callbacks.push((function(e){return e?n.reject(e):n.resolve()})),e.abrupt("return",n.promise);case 4:case"end":return e.stop()}}),e,this)})))}},{key:"onDisconnect",value:function(e,n){n.error;var r=n.autoReconnect,a=void 0===r||r;return b(this,void 0,void 0,t().mark((function n(){var r;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return r=Date.now(),this._halt(A.connectionCanceled),t.next=4,e.changeState(new Ma({autoReconnect:a}),r);case 4:case"end":return t.stop()}}),n,this)})))}},{key:"onDisconnectWebSocket",value:function(e){return b(this,void 0,void 0,t().mark((function n(){var r;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return r=Date.now(),this._halt(A.connectionCanceled),t.next=4,e.changeState(new Na,r);case 4:case"end":return t.stop()}}),n,this)})))}},{key:"onLogout",value:function(e){return b(this,void 0,void 0,t().mark((function n(){var r;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return r=Date.now(),this._halt(A.connectionCanceled),t.next=4,e.changeState(new Ia,r);case 4:case"end":return t.stop()}}),n,this)})))}}]),a}(Sa),Oa=function(e){i(a,e);var n=f(a);function a(){var e;return r(this,a),(e=n.apply(this,arguments)).type=aa.CONNECTED,e.name="connected",e}return s(a,[{key:"onReconnect",value:function(e){return b(this,void 0,void 0,t().mark((function n(){var r;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return r=Date.now(),t.next=3,e.disconnect();case 3:return t.next=5,e.changeState(new Aa,r);case 5:case"end":return t.stop()}}),n)})))}},{key:"onDisconnect",value:function(e,n){var r=n.autoReconnect;return b(this,void 0,void 0,t().mark((function n(){var a;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return a=Date.now(),t.next=3,e.changeState(new Ma({autoReconnect:r}),a);case 3:case"end":return t.stop()}}),n)})))}},{key:"onDisconnectWebSocket",value:function(e){return b(this,void 0,void 0,t().mark((function n(){var r;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return r=Date.now(),t.next=3,e.changeState(new Na,r);case 3:case"end":return t.stop()}}),n)})))}},{key:"onLogout",value:function(e){return b(this,void 0,void 0,t().mark((function n(){var r;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return r=Date.now(),t.next=3,e.changeState(new Ia,r);case 3:case"end":return t.stop()}}),n)})))}}]),a}(Sa),Ua=function(e){i(a,e);var n=f(a);function a(e){var t,s=e.authToken;return r(this,a),(t=n.call(this)).type=aa.CONNECTING,t.name="connecting",t._authToken="",t._haltConnect=null,t._callbacks=[],t._authToken=s,t}return s(a,[{key:"_halt",value:function(e){this._haltConnect&&(this._haltConnect(e),this._haltConnect=null)}},{key:"_flushCallbacks",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:null;this._haltConnect=null,this._callbacks.forEach((function(t){return t(e)}))}},{key:"run",value:function(e){return b(this,void 0,void 0,t().mark((function n(){var r,a,s=this;return t().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return r=Date.now(),a=new ua,this._callbacks.push((function(e){return e?a.reject(e):a.resolve()})),n.prev=3,n.next=6,Ea((function(n){return b(s,void 0,void 0,t().mark((function r(){return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return this._haltConnect=n,t.prev=1,t.next=4,e.connect(this._authToken);case 4:t.next=16;break;case 6:if(t.prev=6,t.t0=t.catch(1),e.clearLoginTimer(),!(t.t0 instanceof A)){t.next=15;break}t.t1=t.t0.code,t.next=t.t1===E.CONNECTION_CANCELED?13:15;break;case 13:return n(t.t0),t.abrupt("return");case 15:throw t.t0;case 16:case"end":return t.stop()}}),r,this,[[1,6]])})))}),e.sdkState.websocket.connectMaxRetry);case 6:return n.next=8,e.changeState(new Oa,r);case 8:wa((function(){return b(s,void 0,void 0,t().mark((function n(){return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:this._flushCallbacks(null),e.connectionHandlers.forEach((function(t){t.onConnected(e.sdkState.userId)}));case 2:case"end":return t.stop()}}),n,this)})))})),n.next=24;break;case 11:if(n.prev=11,n.t0=n.catch(3),M(n.t0)){n.next=23;break}return n.next=16,e.disconnect();case 16:if(!(n.t0 instanceof A)){n.next=20;break}if(n.t0.code===E.CONNECTION_CANCELED){n.next=20;break}return n.next=20,e.changeState(new Ra,r);case 20:wa((function(){return b(s,void 0,void 0,t().mark((function e(){return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:this._flushCallbacks(n.t0);case 1:case"end":return e.stop()}}),e,this)})))})),n.next=24;break;case 23:throw n.t0;case 24:return n.abrupt("return",a.promise);case 25:case"end":return n.stop()}}),n,this,[[3,11]])})))}},{key:"onConnect",value:function(e){return b(this,void 0,void 0,t().mark((function e(){var n;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n=new ua,this._callbacks.push((function(e){return e?n.reject(e):n.resolve()})),e.abrupt("return",n.promise);case 3:case"end":return e.stop()}}),e,this)})))}},{key:"onDisconnect",value:function(e,n){var r=n.error,a=void 0===r?null:r,s=n.autoReconnect;return b(this,void 0,void 0,t().mark((function n(){var r;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(r=Date.now(),this._halt(null!=a?a:A.connectionCanceled),!e.hasSession){t.next=7;break}return t.next=5,e.changeState(new Ma({autoReconnect:s}),r);case 5:t.next=9;break;case 7:return t.next=9,e.changeState(new Ia,r);case 9:case"end":return t.stop()}}),n,this)})))}},{key:"onDisconnectWebSocket",value:function(e){return b(this,void 0,void 0,t().mark((function n(){var r;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(r=Date.now(),this._halt(A.connectionCanceled),!e.hasSession){t.next=7;break}return t.next=5,e.changeState(new Na,r);case 5:t.next=9;break;case 7:return t.next=9,e.changeState(new Ia,r);case 9:case"end":return t.stop()}}),n,this)})))}},{key:"onLogout",value:function(e){return b(this,void 0,void 0,t().mark((function n(){var r;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return r=Date.now(),this._halt(A.connectionCanceled),t.next=4,e.changeState(new Ia,r);case 4:case"end":return t.stop()}}),n,this)})))}}]),a}(Sa),Ra=function(e){i(a,e);var n=f(a);function a(){var e;return r(this,a),(e=n.apply(this,arguments)).type=aa.INITIALIZED,e.name="initialized",e}return s(a,[{key:"onConnect",value:function(e,n){return b(this,void 0,void 0,t().mark((function r(){var a;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return a=Date.now(),t.next=3,e.changeState(new Ua({authToken:n}),a);case 3:case"end":return t.stop()}}),r)})))}}]),a}(Sa),La=function(e){i(n,e);var t=f(n);function n(){return r(this,n),t.call(this,{code:"PING",payload:{id:Date.now(),active:1},ackRequired:!1})}return s(n)}(ia),Da=function(){function e(t){var n=t.pingDelegate,a=t.sdkState,s=t.logger;r(this,e),this._pingTimer=null,this._pingTimeoutTimer=null,this.pingDelegate=n,this.sdkState=a,this._logger=s}return s(e,[{key:"isWaiting",get:function(){return!!this._pingTimeoutTimer}},{key:"ping",value:function(){var e,t=this,n=new La;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}},{key:"pong",value:function(){this._logger.debug("pinger.pong()"),this._pingTimeoutTimer&&(clearTimeout(this._pingTimeoutTimer),this._pingTimeoutTimer=null)}},{key:"refreshTimer",value: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)}},{key:"start",value:function(){this._logger.debug("pinger.start()"),this.refreshTimer(),this.ping()}},{key:"stop",value:function(){this._logger.debug("pinger.stop()"),this._pingTimer&&(clearInterval(this._pingTimer),this._pingTimer=null),this._pingTimeoutTimer&&(clearTimeout(this._pingTimeoutTimer),this._pingTimeoutTimer=null)}}]),e}(),Pa=function(){function e(t){var n;r(this,e),this.lastUpdatedAt=null!==(n=t.last_updated_at)&&void 0!==n?n:0}return s(e,null,[{key:"payloadify",value:function(e){return ue({last_updated_at:e.lastUpdatedAt})}}]),e}(),Fa=1048576,Ga=function(){function e(){var t,n,a,s,i,o=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};r(this,e),this.emojiHash=o.emoji_hash||"",this.uploadSizeLimit=o.file_upload_size_limit?o.file_upload_size_limit*Fa:Number.MAX_SAFE_INTEGER,this.useReaction=!!o.use_reaction,this.applicationAttributes=null!==(t=o.application_attributes)&&void 0!==t?t:[],this.premiumFeatureList=null!==(n=o.premium_feature_list)&&void 0!==n?n:[],this.deviceTokenCache=this.applicationAttributes.includes("sdk_device_token_cache"),this.enabledChannelMemberShipHistory=this.applicationAttributes.includes("channel_membership_history"),this.multipleFilesMessageFileCountLimit=null!==(a=o.multiple_file_send_max_size)&&void 0!==a?a:5,this.allowSdkStatsUpload=null===(s=o.allow_sdk_log_ingestion)||void 0===s||s,this.uikitConfigInfo=new Pa(null!==(i=o.uikit_config)&&void 0!==i?i:{})}return s(e,null,[{key:"payloadify",value:function(e){return{emoji_hash:e.emojiHash,file_upload_size_limit:e.uploadSizeLimit/Fa,application_attributes:e.applicationAttributes,premium_feature_list:e.premiumFeatureList,use_reaction:e.useReaction,allow_sdk_log_ingestion:e.allowSdkStatsUpload,uikit_config:e.uikitConfigInfo?Pa.payloadify(e.uikitConfigInfo):void 0}}}]),e}(),qa=function(){function e(t){r(this,e),this._iid="",this._iid=t}return s(e,null,[{key:"payloadify",value:function(e){return e?{}:null}}]),e}(),Ha=function(e){i(n,e);var t=f(n);function n(e){var a,s=e.userId,i=e.metadata;return r(this,n),(a=t.call(this)).method=ce.POST,a.path="".concat(he,"/").concat(s,"/metadata"),a.params={metadata:i},a}return s(n)}(Ae),ja=function(e){i(n,e);var t=f(n);function n(e,a){var s;return r(this,n),(s=t.call(this,e,a)).metaData=a,s}return s(n)}(Oe),za=function(e){i(n,e);var t=f(n);function n(e){var a,s=e.userId,i=e.metadata,o=e.upsert;return r(this,n),(a=t.call(this)).method=ce.PUT,a.path="".concat(he,"/").concat(s,"/metadata"),a.params={metadata:i,upsert:o},a}return s(n)}(Ae),Va=function(e){i(n,e);var t=f(n);function n(e,a){var s;return r(this,n),(s=t.call(this,e,a)).metadata=a,s}return s(n)}(Oe),Ba=function(e){i(n,e);var t=f(n);function n(e){var a,s=e.userId,i=e.metadataKey;return r(this,n),(a=t.call(this)).method=ce.DELETE,a.path="".concat(he,"/").concat(s,"/metadata/").concat(i),a}return s(n)}(Ae),Qa=function(e){i(n,e);var t=f(n);function n(e){var a,s=e.userId;return r(this,n),(a=t.call(this)).method=ce.DELETE,a.path="".concat(he,"/").concat(s,"/metadata"),a}return s(n)}(Ae),Ka=function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null,n=JSON.parse(JSON.stringify(e));return n._iid&&delete n._iid,t&&t(n),n},Wa=function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null,n=JSON.parse(JSON.stringify(e));return t&&t(n),n},Ya=function(e){return{do:function(t){e||t()},throw:function(t){if(!e)throw t}}};e.UserOnlineState=void 0,(la=e.UserOnlineState||(e.UserOnlineState={})).ONLINE="online",la.OFFLINE="offline",la.NON_AVAILABLE="nonavailable";var Za,Ja=function(n){i(u,n);var a=f(u);function u(t,n){var s,i,o,c,l,h,d,f,p,v,m,g,y;return r(this,u),(s=a.call(this,t)).userId=null!==(o=null!==(i=n.guest_id)&&void 0!==i?i:n.user_id)&&void 0!==o?o:"",s.nickname=null!==(l=null!==(c=n.nickname)&&void 0!==c?c:n.name)&&void 0!==l?l:"",s.plainProfileUrl=null!==(d=null!==(h=n.profile_url)&&void 0!==h?h:n.image)&&void 0!==d?d:"",s.requireAuth=null!==(f=n.require_auth_for_profile_image)&&void 0!==f&&f,s.metaData=null!==(p=n.metadata)&&void 0!==p?p:{},s.connectionStatus=e.UserOnlineState.NON_AVAILABLE,D(e.UserOnlineState,n.is_online)?s.connectionStatus=n.is_online:L("boolean",n.is_online)&&(s.connectionStatus=n.is_online?e.UserOnlineState.ONLINE:e.UserOnlineState.OFFLINE),s.isActive=null===(v=n.is_active)||void 0===v||v,s.lastSeenAt=null!==(m=n.last_seen_at)&&void 0!==m?m:null,s.preferredLanguages=n.preferred_languages?_(n.preferred_languages):null,s.friendDiscoveryKey=null!==(g=n.friend_discovery_key)&&void 0!==g?g:null,s.friendName=null!==(y=n.friend_name)&&void 0!==y?y:null,s}return s(u,[{key:"profileUrl",get:function(){var e=ds.of(this._iid).sessionManager;return this.requireAuth?"".concat(this.plainProfileUrl,"?auth=").concat(e.ekey):this.plainProfileUrl}},{key:"serialize",value:function(){return Ka(this)}},{key:"_isValidMetaData",value:function(e){return!Array.isArray(e)&&Object.keys(e).length>0&&Object.keys(e).map((function(t){return e[t]})).every((function(e){return L("string",e)}))}},{key:"_applyMetaData",value:function(e){var t=this,n=arguments.length>1&&void 0!==arguments[1]&&arguments[1];Object.keys(e).forEach((function(r){n?delete t.metaData[r]:t.metaData[r]=e[r]}))}},{key:"createMetaData",value:function(e){return b(this,void 0,void 0,t().mark((function n(){var r,a,s,i,o,u,c;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return Ya(this._isValidMetaData(e)).throw(A.invalidParameters),r=ds.of(this._iid),a=r.sdkState,s=r.requestQueue,i=new Ha({userId:a.userId,metadata:e}),t.next=5,s.send(i);case 5:return o=t.sent,u=o.as(ja),c=u.metaData,this._applyMetaData(c),t.abrupt("return",this.metaData);case 9:case"end":return t.stop()}}),n,this)})))}},{key:"updateMetaData",value:function(e){var n=arguments.length>1&&void 0!==arguments[1]&&arguments[1];return b(this,void 0,void 0,t().mark((function r(){var a,s,i,o,u,c,l;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return Ya(this._isValidMetaData(e)).throw(A.invalidParameters),a=ds.of(this._iid),s=a.sdkState,i=a.requestQueue,o=new za({userId:s.userId,metadata:e,upsert:n}),t.next=5,i.send(o);case 5:return u=t.sent,c=u.as(Va),l=c.metadata,this._applyMetaData(l),t.abrupt("return",this.metaData);case 9:case"end":return t.stop()}}),r,this)})))}},{key:"deleteMetaData",value:function(e){return b(this,void 0,void 0,t().mark((function n(){var r,a,s,i;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return Ya(L("string",e)).throw(A.invalidParameters),r=ds.of(this._iid),a=r.sdkState,s=r.requestQueue,i=new Ba({userId:a.userId,metadataKey:e}),t.next=5,s.send(i);case 5:return this._applyMetaData((n={},u=!0,(o=k(o=e))in n?Object.defineProperty(n,o,{value:u,enumerable:!0,configurable:!0,writable:!0}):n[o]=u,n),!0),t.abrupt("return",this.metaData);case 7:case"end":return t.stop()}var n,o,u}),n,this)})))}},{key:"deleteAllMetaData",value:function(){return b(this,void 0,void 0,t().mark((function e(){var n,r,a,s;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n=ds.of(this._iid),r=n.sdkState,a=n.requestQueue,s=new Qa({userId:r.userId}),e.next=4,a.send(s);case 4:this.metaData={};case 5:case"end":return e.stop()}}),e,this)})))}}],[{key:"payloadify",value:function(e){return e?ue(Object.assign(Object.assign({},p(o(u),"payloadify",this).call(this,e)),{user_id:e.userId,nickname:e.nickname,profile_url:e.plainProfileUrl,require_auth_for_profile_image:e.requireAuth,metadata:e.metaData,is_online:e.connectionStatus,is_active:e.isActive,last_seen_at:e.lastSeenAt,preferred_languages:e.preferredLanguages,friend_discovery_key:e.friendDiscoveryKey,friend_name:e.friendName})):null}}]),u}(qa),Xa=function(e){i(n,e);var t=f(n);function n(e){var a,s=e.userProfile;return r(this,n),(a=t.call(this)).userProfile=s,a}return s(n)}(oe),$a=function(){function e(t,n){var a,s,i,o,u,c,l,h,d,f,p,v,_,m;r(this,e),this._iid=t,this.appInfo=new Ga(n),this.user=new Ja(t,n),this.connectedAt=null!==(a=n.login_ts)&&void 0!==a?a:0,this.firstConnectedAt=0,this.pingInterval=null!==(s=n.ping_interval)&&void 0!==s?s:15e3,this.pongTimeout=null!==(i=n.pong_timeout)&&void 0!==i?i:5e3,this.reconnectInterval=null!==(u=null===(o=n.reconnect)||void 0===o?void 0:o.interval)&&void 0!==u?u:3e3,this.reconnectMaxInterval=null!==(l=null===(c=n.reconnect)||void 0===c?void 0:c.max_interval)&&void 0!==l?l:6e4,this.reconnectRetryCount=null!==(d=null===(h=n.reconnect)||void 0===h?void 0:h.retry_cnt)&&void 0!==d?d:5,this.reconnectIntervalMultiple=null!==(p=null===(f=n.reconnect)||void 0===f?void 0:f.mul)&&void 0!==p?p:2,this.maxUnreadCountOnSuperGroup=null!==(v=n.max_unread_cnt_on_super_group)&&void 0!==v?v:100,this.profileImageEncryption=!!n.profile_image_encryption,this.concurrentCallLimit=null!==(_=n.concurrent_call_limit)&&void 0!==_?_:5,this.backOffDelay=null!==(m=n.back_off_delay)&&void 0!==m?m:100}return s(e,[{key:"apply",value:function(){var e=this.reconnectInterval,t=this.reconnectMaxInterval,n=this.reconnectIntervalMultiple,r=ds.of(this._iid);r.sdkState.websocket.pingInterval=1e3*this.pingInterval,r.sdkState.websocket.pongTimeout=1e3*this.pongTimeout,r.sdkState.websocket.reconnectMaxRetry=this.reconnectRetryCount,r.sdkState.websocket.reconnectRetryStrategy={calcTimeout:function(r){return r>0?1e3*Math.min(e*Math.pow(n,r-1),t):10}},r.appInfo=this.appInfo,r.sessionManager.currentUser=this.user,r.connectedAt=this.connectedAt,this.firstConnectedAt||(r.firstConnectedAt=this.connectedAt),r.maxSuperGroupChannelUnreadCount=this.maxUnreadCountOnSuperGroup,r.concurrentCallLimit=this.concurrentCallLimit,r.backOffDelay=this.backOffDelay,r.dispatcher.dispatch(new Xa({userProfile:this}))}}],[{key:"payloadify",value:function(e){return Object.assign(Object.assign(Object.assign({},Ja.payloadify(e.user)),Ga.payloadify(e.appInfo)),{login_ts:e.connectedAt,ping_interval:e.pingInterval,pong_timeout:e.pongTimeout,reconnect:{interval:e.reconnectInterval,max_interval:e.reconnectMaxInterval,retry_cnt:e.reconnectRetryCount,mul:e.reconnectIntervalMultiple},max_unread_cnt_on_super_group:e.maxUnreadCountOnSuperGroup,profile_image_encryption:e.profileImageEncryption,concurrent_call_limit:e.concurrentCallLimit,back_off_delay:e.backOffDelay})}}]),e}(),es=function(e){i(a,e);var n=f(a);function a(e,t,s){var i,o;return r(this,a),(i=n.call(this,e,t,s)).error=null,i.userProfile=new $a(e,s),i.deviceTokenLastDeletedAt=s.device_token_last_deleted_at,i.key=s.key,i.ekey=null!==(o=s.ekey)&&void 0!==o?o:"",i.error=s.error?new A(s):null,i}return s(a,[{key:"applyTo",value:function(e){return b(this,void 0,void 0,t().mark((function n(){var r,a;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(this.error){t.next=12;break}if(!(r=ds.of(e))){t.next=9;break}return a=r.sessionManager,t.next=6,a.login(this);case 6:this.userProfile.apply(),t.next=10;break;case 9:throw A.lostInstance;case 10:t.next=13;break;case 12:throw this.error;case 13:case"end":return t.stop()}}),n,this)})))}}],[{key:"asError",value:function(e){return new a(null,"LOGI",Object.assign({user_id:null,error:!0},e))}}]),a}(Ge),ts=function(e){i(n,e);var t=f(n);function n(e){var a,s=e.request,i=void 0===s||s,o=e.features,u=void 0===o?{}:o,c=e.options,l=void 0===c?{}:c;return r(this,n),(a=t.call(this)).request=i,a.features=Object.assign({localCache:!0},u),a.options=Object.assign({ingestion:!0},l),a}return s(n)}(oe),ns=function(e){i(a,e);var n=f(a);function a(e,t){var s,i=t.sdkState,o=t.cacheContext,u=t.connectionHandlers,c=t.sessionManager,l=t.websocketClient,h=t.dispatcher,d=t.logger,f=t.entryState,p=void 0===f?new Ra:f;return r(this,a),(s=n.call(this))._currentState=null,s._loginTimer=null,s._logiProcessingTimer=null,s._unresolvedLogi=null,s._stateUpdatedAt=0,s._connectingAt=0,s._connectionRequestQueue=[],s._iid=e,s.sdkState=i,s.cacheContext=o,s.connectionHandlers=u,s._sessionManager=c,s._websocketClient=l,s._dispatcher=h,s._logger=d,s._currentState=p,s.sdkState.websocket.pingerDisabled||(s._pinger=new Da({pingDelegate:{send:function(e){return s._websocketClient.send(e)},error:function(e){return s._websocketClient.error(e)}},sdkState:s.sdkState,logger:d})),s._websocketClient.on("open",(function(){s._tryResolveConnectionRequest()})).on("message",(function(e){if("LOGI"===e.code)s.clearLoginTimer(),s._dispatcher.dispatch(e.as(es))})).on("ping-refresh",(function(){var e;return null===(e=s._pinger)||void 0===e?void 0:e.refreshTimer()})).on("pong",(function(){var e;return null===(e=s._pinger)||void 0===e?void 0:e.pong()})).on("error",(function(){var e;return null===(e=s._pinger)||void 0===e?void 0:e.stop()})).on("close",(function(){s._logiProcessingTimer=setTimeout((function(){s._logiProcessingTimer=null,s._unresolvedLogi||s._rejectConnectionRequest(A.networkError)}),500)})),s._dispatcher.on((function(e){e instanceof es&&(s._unresolvedLogi=e,s._tryResolveConnectionRequest())})),s}return s(a,[{key:"currentState",get:function(){return this._currentState}},{key:"hasSession",get:function(){return this._sessionManager.auth.hasSession}},{key:"changeState",value:function(e,n){return b(this,void 0,void 0,t().mark((function r(){return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(!(n>=this._stateUpdatedAt)){t.next=8;break}return this._currentState=e,this._stateUpdatedAt=n,this._dispatcher.dispatch(new ha({stateType:e.type})),this._logger.debug("connection state changes to ".concat(e.name)),t.next=7,this._currentState.run(this);case 7:return t.abrupt("return",!0);case 8:return t.abrupt("return",!1);case 9:case"end":return t.stop()}}),r,this)})))}},{key:"_tryResolveConnectionRequest",value:function(){var e;return b(this,void 0,void 0,t().mark((function n(){var r,a;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(r=this._unresolvedLogi,!this._websocketClient.isOpen||!r){t.next=18;break}if(this._unresolvedLogi=null,r.error){t.next=15;break}return t.next=6,r.applyTo(this._iid);case 6:a=r.userProfile,this._enableStatLog({request:a.appInfo.applicationAttributes.includes("allow_sdk_request_log_publish"),features:{localCache:a.appInfo.applicationAttributes.includes("allow_sdk_feature_local_cache_log_publish")},options:{ingestion:a.appInfo.allowSdkStatsUpload}}),this._statLogConnection(null),null===(e=this._pinger)||void 0===e||e.start(),this._connectionRequestQueue.forEach((function(e){return e.resolve()})),this._connectionRequestQueue=[],this.sdkState.appState="foreground",t.next=18;break;case 15:this._sessionManager.auth.authToken=null,(r.error.isSessionKeyExpiredError||r.error.isSessionTokenExpiredError)&&this._dispatcher.dispatch(new Re({reason:r.error.code})),this._rejectConnectionRequest(r.error);case 18:case"end":return t.stop()}}),n,this)})))}},{key:"_rejectConnectionRequest",value:function(e){var t;if(null===(t=this._pinger)||void 0===t||t.stop(),this.clearLoginTimer(),this._connectionRequestQueue.length>0){var n=this._connectionRequestQueue;this._connectionRequestQueue=[],n.forEach((function(t){return t.reject(e)})),this._statLogConnection(e)}}},{key:"_url",value:function(){var e,t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"",n=this.sdkState,r=n.appId,a=n.appVersion,s=n.userId,i=n.extensions,o=this.cacheContext.localCacheEnabled,u=this._sessionManager.auth,c=null===(e=this.sdkState.websocket)||void 0===e?void 0:e.compression,l=!!this.sdkState.extensions.sb_uikit,h=i.sb_syncmanager?"s".concat(i.sb_syncmanager):"",d=i.sb_uikit?"u".concat(i.sb_uikit):"",f="JS/c".concat(x.SDK_VERSION,"/").concat(h,"/").concat(d);return"".concat(this.sdkState.websocket.host,"/?p=JS&pv=").concat(encodeURIComponent(x.OS_VERSION),"&sv=").concat(encodeURIComponent(x.SDK_VERSION),"&ai=").concat(r).concat(a?"&av=".concat(a):"").concat(u.hasSession?"&key=".concat(encodeURIComponent(u.sessionKey)):"&user_id=".concat(encodeURIComponent(s),"&access_token=").concat(encodeURIComponent(t)),"&pmce=").concat(c?1:0,"&active=1&device_token_types=").concat(encodeURIComponent(["gcm","huawei","apns"].join(",")),"&SB-User-Agent=").concat(f,"&Request-Sent-Timestamp=").concat(Date.now().toString(),"&include_extra_data=").concat(encodeURIComponent(String(["premium_feature_list","file_upload_size_limit","application_attributes","emoji_hash","multiple_file_send_max_size"]))).concat(this._sessionManager.handler?"&expiring_session=1":"","&use_local_cache=").concat(o?1:0,"&include_poll_details=1").concat(l?"&uikit_config=1":"")}},{key:"_enableStatLog",value:function(e){var t=e.request,n=e.features,r=e.options,a=void 0===r?{}:r;this._dispatcher.dispatch(new ts({request:t,features:n,options:a}))}},{key:"_statLogConnection",value:function(e){this._dispatcher.dispatch(new Le(new De({type:Me.WEBSOCKET_CONNECT,data:{host_url:this.sdkState.websocket.host,success:!e,latency:Date.now()-this._connectingAt,error_code:null==e?void 0:e.code,error_description:null==e?void 0:e.message}})))}},{key:"connect",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"";return b(this,void 0,void 0,t().mark((function n(){var r,a,s=this;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return this._logiProcessingTimer&&(clearTimeout(this._logiProcessingTimer),this._logiProcessingTimer=null,this._rejectConnectionRequest(A.connectionCanceled)),r=this._url(e),a=new ua,this._connectionRequestQueue.push(a),1===this._connectionRequestQueue.length&&(this._connectingAt=Date.now(),this._loginTimer=setTimeout((function(){s._loginTimer=null,s._rejectConnectionRequest(A.loginTimeout)}),this.sdkState.websocket.responseTimeout),e&&(this._sessionManager.auth.authToken=e),this._websocketClient.connect(r)),t.abrupt("return",a.promise);case 6:case"end":return t.stop()}}),n,this)})))}},{key:"cancelConnectForRetry",value:function(){this._dispatcher.dispatch(es.asError(A.connectionRenew))}},{key:"disconnect",value:function(){return b(this,void 0,void 0,t().mark((function e(){return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this._websocketClient.disconnect();case 2:case"end":return e.stop()}}),e,this)})))}},{key:"logout",value:function(){return b(this,void 0,void 0,t().mark((function e(){return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return this.sdkState.userId=null,this._unresolvedLogi=null,e.next=4,this._sessionManager.clear();case 4:return e.next=6,this.disconnect();case 6:case"end":return e.stop()}}),e,this)})))}},{key:"clearLoginTimer",value:function(){this._loginTimer&&(clearTimeout(this._loginTimer),this._loginTimer=null)}}]),a}(se),rs=function(){function e(t,n){var a=n.sdkState,s=n.cacheContext,i=n.connectionHandlers,o=n.sessionManager,u=n.websocketClient,c=n.dispatcher,l=n.logger,h=n.disableWebSocketCloseEventHandling,d=void 0!==h&&h;r(this,e),this._context=null,this._disableWebSocketCloseEventHandling=!1,this._externalCalledWebSocketClose=!1,this._logger=l,this._disableWebSocketCloseEventHandling=d,this._context=new ns(t,{sdkState:a,cacheContext:s,connectionHandlers:i,sessionManager:o,websocketClient:u,dispatcher:c,logger:l}),this._sdkState=a,this._sessionManager=o,this._websocketClient=u}return s(e,[{key:"_registerEventDispatcher",value:function(){var e=this;this._disableWebSocketCloseEventHandling||(this._clearEventDispatcher(),this._sessionEventDispatcherContext=this._sessionManager.on("refresh-authtoken",(function(){e.isConnected||(e._logger.debug("try reconnect by session token refresh"),e.reconnect())})).on("refresh",(function(){e.isConnecting||e.isConnected||(e._logger.debug("try reconnect by session key refresh"),e.reconnect())})),this._websocketEventDispatcherContext=this._websocketClient.on("close",(function(){"foreground"!==e._sdkState.appState||e._externalCalledWebSocketClose||e._sessionManager.isRefreshingAuthToken||(e._logger.debug("try reconnect by websocket connection closed"),e.reconnect())})))}},{key:"_clearEventDispatcher",value:function(){this._sessionEventDispatcherContext&&(this._sessionEventDispatcherContext.close(),this._sessionEventDispatcherContext=null),this._websocketEventDispatcherContext&&(this._websocketEventDispatcherContext.close(),this._websocketEventDispatcherContext=null)}},{key:"isConnected",get:function(){return this._context.currentState.type===aa.CONNECTED}},{key:"isConnecting",get:function(){var e=this._context.currentState;return e.type===aa.CONNECTING||e.type===aa.RECONNECTING}},{key:"connect",value:function(e){return b(this,void 0,void 0,t().mark((function n(){var r;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return r=this._context.currentState,this._externalCalledWebSocketClose=!1,t.next=4,r.onConnect(this._context,e);case 4:this._registerEventDispatcher();case 5:case"end":return t.stop()}}),n,this)})))}},{key:"reconnect",value:function(){return b(this,void 0,void 0,t().mark((function e(){var n;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n=this._context.currentState,this._externalCalledWebSocketClose=!1,e.next=4,n.onReconnect(this._context,{});case 4:case"end":return e.stop()}}),e,this)})))}},{key:"resetAndReconnect",value:function(){return b(this,void 0,void 0,t().mark((function e(){var n;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n=this._context.currentState,this._externalCalledWebSocketClose=!1,e.next=4,n.onReconnect(this._context,{resetReconnectCount:!0});case 4:case"end":return e.stop()}}),e,this)})))}},{key:"background",value:function(){return b(this,void 0,void 0,t().mark((function e(){var n;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n=this._context.currentState,this._externalCalledWebSocketClose=!0,e.next=4,n.onDisconnect(this._context,{autoReconnect:!1});case 4:case"end":return e.stop()}}),e,this)})))}},{key:"disconnect",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:null;return b(this,void 0,void 0,t().mark((function n(){var r;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return r=this._context.currentState,t.next=3,r.onDisconnect(this._context,{error:e,autoReconnect:!0});case 3:case"end":return t.stop()}}),n,this)})))}},{key:"disconnectWebSocket",value:function(){return b(this,void 0,void 0,t().mark((function e(){var n;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n=this._context.currentState,this._externalCalledWebSocketClose=!0,e.next=4,n.onDisconnectWebSocket(this._context);case 4:case"end":return e.stop()}}),e,this)})))}},{key:"logout",value:function(){return b(this,void 0,void 0,t().mark((function e(){var n;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n=this._context.currentState,this._clearEventDispatcher(),e.next=4,n.onLogout(this._context);case 4:case"end":return e.stop()}}),e,this)})))}}]),e}(),as=function(e){i(n,e);var t=f(n);function n(e){var a,s,i,o,u,c=e.type,l=e.data,h=e.ts,d=void 0===h?Date.now():h;return r(this,n),(a=t.call(this,{type:c,data:l,ts:d})).date=new Date(d),a.key="".concat((s=a.date,i=s.getFullYear(),o=String(s.getMonth()+1).padStart(2,"0"),u=String(s.getDate()).padStart(2,"0"),"".concat(i).concat(o).concat(u)),"_").concat(c),a}return s(n)}(De),ss=function(e){i(n,e);var t=f(n);function n(e){var a,s=e.deviceId,i=e.statLogs;return r(this,n),(a=t.call(this)).method=ce.POST,a.path="".concat(xe),a.params={device_id:s,log_entries:i.map((function(e){return De.payloadify(e)}))},a}return s(n)}(Ae),is=function e(t,r){if(null!==t&&null!==r){var a,s=Object.keys(t),i=Object.keys(r),o={},u=y(_(new Set([].concat(s,i))));try{for(u.s();!(a=u.n()).done;){var c=a.value,l=n(t[c]),h=n(r[c]);"undefined"===l?o[c]=r[c]:"undefined"===h?o[c]=t[c]:l!==h?o[c]=r[c]:"object"===l&&t[c]&&r[c]?o[c]=e(t[c],r[c]):o[c]=r[c]}}catch(e){u.e(e)}finally{u.f()}return o}return r};!function(e){e[e.PENDING=0]="PENDING",e[e.COLLECT_ONLY=1]="COLLECT_ONLY",e[e.ENABLED=2]="ENABLED",e[e.DISABLED=3]="DISABLED"}(Za||(Za={}));var os,us=function(e){i(a,e);var n=f(a);function a(e){var t,s=e.cacheContext,i=e.requestQueue,o=e.dispatcher,u=e.baseLimit,c=void 0===u?100:u,l=e.maxLimit,h=void 0===l?1e3:l,d=e.minLimit,f=void 0===d?10:d;return r(this,a),(t=n.call(this)).queue=[],t.enabledState=Za.PENDING,t.isFlushing=!1,t.generation=1,t.lastFlushedAt=0,t.commandEventContext=null,t._collectRequestStat=!0,t._collectFeatureLocalCacheStat=!0,t.deviceId=re(),t.cacheContext=s,t.requestQueue=i,t.dispatcher=o,t.baseLimit=c,t.limit=c,t.maxLimit=h,t.minLimit=f,t}return s(a,[{key:"isEnabled",get:function(){return this.enabledState===Za.ENABLED}},{key:"_arrangeStat",value:function(){var e=[];this._collectRequestStat&&e.push.apply(e,_(this.queue.filter((function(e){return e.type===Me.API_RESULT||e.type===Me.WEBSOCKET_CONNECT})))),this._collectFeatureLocalCacheStat&&e.push.apply(e,_(this.queue.filter((function(e){return e.type===Me.FEATURE_LOCALCACHE})))),this.queue=e}},{key:"_save",value:function(){return b(this,void 0,void 0,t().mark((function e(){return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(this.enabledState!==Za.ENABLED){e.next=4;break}return e.next=3,this.cacheContext.preference.set(this.key,{deviceId:this.deviceId,statLogs:this.queue.map((function(e){return De.payloadify(e)})),generation:this.generation++,lastFlushedAt:this.lastFlushedAt});case 3:this.dispatch("save",_(this.queue));case 4:case"end":return e.stop()}}),e,this)})))}},{key:"_flush",value:function(){return b(this,void 0,void 0,t().mark((function e(){var n,r,a,s;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!this.isEnabled){e.next=34;break}if(this.isFlushing){e.next=34;break}if(this.isFlushing=!0,e.prev=3,this._arrangeStat(),n=this.queue.filter((function(e){if(e instanceof as){var t=new Date,n=[e.date.getFullYear(),t.getFullYear()],r=n[0],a=n[1];if(r0)){e.next=16;break}return s=new ss({deviceId:this.deviceId,statLogs:a}),e.next=12,this.requestQueue.send(s);case 12:return this.dispatch("flush",a),this.queue=[].concat(_(n),_(r)).slice(a.length),e.next=16,this._save();case 16:this.limit=this.baseLimit,this.lastFlushedAt=Date.now(),e.next=31;break;case 20:if(e.prev=20,e.t0=e.catch(3),!(e.t0 instanceof A)){e.next=30;break}if(e.t0.code!==E.STAT_LOG_NOT_ALLOWED){e.next=29;break}return e.next=26,this.clear();case 26:this.enabledState=Za.DISABLED,e.next=30;break;case 29:e.t0.code===E.STAT_UPLOAD_NOT_ALLOWED&&(this.enabledState=Za.COLLECT_ONLY);case 30:this.limit=this.limit+20;case 31:return e.prev=31,this.isFlushing=!1,e.finish(31);case 34:case"end":return e.stop()}}),e,this,[[3,20,31,34]])})))}},{key:"init",value:function(e){return b(this,void 0,void 0,t().mark((function n(){var r,a,s=this;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return this.key=e,t.next=3,this.cacheContext.preference.get(this.key);case 3:if(!(r=t.sent)){t.next=15;break}if(this.deviceId=r.deviceId,this.queue=r.statLogs.map((function(e){return new De({type:e.stat_type,ts:e.ts,data:e.data})})),this.generation=r.generation,this.lastFlushedAt=r.lastFlushedAt,!(Date.now()-this.lastFlushedAt>=108e5&&this.queue.length>=this.minLimit)){t.next=15;break}return a=Math.min(Math.floor(18e4*Math.random()),100),t.next=13,ka(a);case 13:return t.next=15,this._flush();case 15:this.commandEventContext||(this.commandEventContext=this.dispatcher.on((function(e){if(e instanceof Le){var t=e.statLog;s.put(t)}else if(e instanceof ts){var n=e.request,r=e.features,a=e.options;s._collectRequestStat=n,s._collectFeatureLocalCacheStat=null==r?void 0:r.localCache,s._arrangeStat(),s._collectRequestStat||s._collectFeatureLocalCacheStat?s.enabledState=a.ingestion?Za.ENABLED:Za.COLLECT_ONLY:s.enabledState=Za.DISABLED,s.isEnabled?s.queue.length>=s.limit&&s._flush():s.clear()}})));case 16:case"end":return t.stop()}}),n,this)})))}},{key:"put",value:function(e){return b(this,void 0,void 0,t().mark((function n(){var r,a,s;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(this.enabledState===Za.DISABLED){t.next=7;break}return e instanceof as?this._collectFeatureLocalCacheStat&&(r=this.queue.filter((function(t){return t instanceof as&&t.key===e.key})),a=v(r,1),(s=a[0])?s.data=is(s.data,e.data):this.queue.push(e)):this._collectRequestStat&&this.queue.push(e),t.next=4,this._save();case 4:if(!(this.queue.length>=this.limit)){t.next=7;break}return t.next=7,this._flush();case 7:case"end":return t.stop()}}),n,this)})))}},{key:"clear",value:function(){return b(this,void 0,void 0,t().mark((function e(){return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return this.queue=[],this.generation=1,e.next=4,this._save();case 4:case"end":return e.stop()}}),e,this)})))}},{key:"close",value:function(){this.commandEventContext&&(this.commandEventContext.close(),this.commandEventContext=null)}}]),a}(se);e.LogLevel=void 0,(os=e.LogLevel||(e.LogLevel={}))[os.NONE=0]="NONE",os[os.VERBOSE=1]="VERBOSE",os[os.DEBUG=2]="DEBUG",os[os.INFO=3]="INFO",os[os.WARN=4]="WARN",os[os.ERROR=5]="ERROR";var cs,ls=function(){function t(){r(this,t),this.level=e.LogLevel.WARN}return s(t,[{key:"verbose",value:function(){if(this.level<=e.LogLevel.VERBOSE){for(var t,n=arguments.length,r=new Array(n),a=0;a0&&L("number",i)&&(this.key=a,this.userIds=s,this.updatedAt=i);var o,u={},c=y(this.userIds);try{for(c.s();!(o=c.n()).done;){u[o.value]=this.updatedAt}}catch(e){c.e(e)}finally{c.f()}this._version=u}return s(t,[{key:"isEmpty",get:function(){return 0===this.userIds.length}},{key:"applyEvent",value:function(t){if(t.key===this.key&&this.updatedAt<=t.updatedAt){if(!this._version[t.userId]||this._version[t.userId]<=t.updatedAt){var n=this.userIds.indexOf(t.userId);switch(t.operation){case e.ReactionEventOperation.ADD:n<0&&this.userIds.push(t.userId);break;case e.ReactionEventOperation.DELETE:n>=0&&this.userIds.splice(n,1)}this._version[t.userId]=t.updatedAt}this.updatedAt=Math.max(this.updatedAt,t.updatedAt)}}}],[{key:"payloadify",value:function(e){return e?ue({key:e.key,user_ids:e.userIds,updated_at:e.updatedAt}):null}}]),t}(),bs=function(){function e(t){r(this,e),this.key=t.key,this.value=F("string",t.value)?_(t.value):[]}return s(e,null,[{key:"payloadify",value:function(e){var t;return e?ue({key:e.key,value:null!==(t=e.value)&&void 0!==t?t:[]}):null}}]),e}(),Es=function(){function e(t){r(this,e),this.url=null,this.secureUrl=null,this.type=null,this.width=0,this.height=0,this.alt=null,this.url=t.url,t.hasOwnProperty("secure_url")&&(this.secureUrl=t.secure_url),t.hasOwnProperty("type")&&(this.type=t.type),t.hasOwnProperty("width")&&(this.width=t.width),t.hasOwnProperty("height")&&(this.height=t.height),t.hasOwnProperty("alt")&&(this.alt=t.alt)}return s(e,null,[{key:"payloadify",value:function(e){var t,n;return e?ue({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}(),ws=function(){function e(t){r(this,e),this.title=null,this.url=null,this.description=null,this.defaultImage=null,t.hasOwnProperty("og:title")&&(this.title=t["og:title"]),t.hasOwnProperty("og:url")&&(this.url=t["og:url"]),t.hasOwnProperty("og:description")&&(this.description=t["og:description"]),t.hasOwnProperty("og:image")&&(this.defaultImage=new Es(t["og:image"]))}return s(e,null,[{key:"payloadify",value:function(e){return e?ue({"og:title":e.title,"og:url":e.url,"og:description":e.description,"og:image":e.defaultImage?Es.payloadify(e.defaultImage):null}):null}}]),e}(),xs=function(){function e(t){var n,a;r(this,e),this.name=null,this.volume=0,this.name=null!==(n=t.name)&&void 0!==n?n:"default",this.volume=null!==(a=t.volume)&&void 0!==a?a:1}return s(e,[{key:"serialize",value:function(){return{name:this.name,volume:this.volume}}}],[{key:"payloadify",value:function(e){return e?ue({name:e.name,volume:e.volume}):null}}]),e}(),Cs=function(t){i(a,t);var n=f(a);function a(t,s){var i;return r(this,a),(i=n.call(this,t,s)).role=null,i.isBlockedByMe=!1,i.role=D(e.Role,s.role)?s.role:e.Role.NONE,s.hasOwnProperty("is_blocked_by_me")&&(i.isBlockedByMe=s.is_blocked_by_me),i}return s(a,null,[{key:"payloadify",value:function(e){return e?ue(Object.assign(Object.assign({},p(o(a),"payloadify",this).call(this,e)),{role:e.role,is_blocked_by_me:e.isBlockedByMe})):null}}]),a}(Ja);e.ScheduledStatus=void 0,(ms=e.ScheduledStatus||(e.ScheduledStatus={})).PENDING="pending",ms.SENT="sent",ms.FAILED="failed",ms.CANCELED="canceled",function(e){e.PENDING="pending",e.IN_QUEUE="in_queue",e.SENT="sent",e.FAILED="failed",e.CANCELED="canceled",e.REMOVED="removed"}(gs||(gs={}));var Ts,Ss=function(t){switch(t){case e.MessageType.BASE:return"";case e.MessageType.USER:return"MESG";case e.MessageType.FILE:return"FILE";case e.MessageType.ADMIN:return"ADMM"}},Is=function(t){i(a,t);var n=f(a);function a(t,s){var i,o,u,c,l,h,d,f,p,v,_,m,g,y,k,b;r(this,a),(i=n.call(this,t)).channelUrl=null,i.channelType=e.ChannelType.BASE,i.messageId=0,i.parentMessageId=null,i.parentMessage=null,i.silent=!1,i.isOperatorMessage=!1,i.messageType=e.MessageType.BASE,i.data=null,i.customType=null,i.mentionType=null,i.mentionedUsers=[],i.mentionedUserIds=[],i.mentionedMessageTemplate=null,i.threadInfo=null,i.reactions=[],i.metaArrays=[],i.ogMetaData=null,i.appleCriticalAlertOptions=null,i.createdAt=0,i.updatedAt=0,i.scheduledInfo=null,i.extendedMessage={},i._isContinuousMessages=!1,i._scheduledStatus=null,i.messageId=null!==(u=null!==(o=s.msg_id)&&void 0!==o?o:s.message_id)&&void 0!==u?u:0,i.channelUrl=s.channel_url,i.channelType=D(e.ChannelType,s.channel_type)?s.channel_type:e.ChannelType.GROUP,s.channel&&(s.channel.channel_url&&(i.channelUrl=s.channel.channel_url),s.channel.channel_type&&(i.channelType=s.channel.channel_type)),i.parentMessageId=null!==(c="string"==typeof s.parent_message_id?parseInt(s.parent_message_id):s.parent_message_id)&&void 0!==c?c:0,i.data=null!==(l=s.data)&&void 0!==l?l:"",i.customType=null!==(h=s.custom_type)&&void 0!==h?h:"",i.mentionType=D(e.MentionType,s.mention_type)?s.mention_type:null;var E=s.mentioned_users;i.mentionedUsers=E?E.map((function(e){return new Ja(i._iid,e)})):null;var w=s.mentioned_user_ids;i.mentionedUserIds=null!=w?w:null,i.mentionedUsers&&!i.mentionedUserIds&&(i.mentionedUserIds=i.mentionedUsers.map((function(e){return e.userId}))),i.mentionedMessageTemplate=null!==(d=s.mentioned_message_template)&&void 0!==d?d:"",i.threadInfo=s.thread_info?new _s(i._iid,s.thread_info):null,i.reactions=s.reactions?s.reactions.map((function(e){return new ks(e)})):[];for(var x=null!==(f=s.metaarray)&&void 0!==f?f:{},C=null!==(p=s.metaarray_key_order)&&void 0!==p?p:Object.keys(x).sort((function(e,t){return e.localeCompare(t)})),T=0;T=t)return this.parentMessage=e,!0}return!1}}],[{key:"payloadify",value:function(e){var t,n,r,s;return e?ue(Object.assign(Object.assign({},p(o(a),"payloadify",this).call(this,e)),{channel_url:e.channelUrl,channel_type:e.channelType,message_id:e.messageId,type:Ss(e.messageType),parent_message_id:e.parentMessageId,data:e.data,custom_type:e.customType,mention_type:e.mentionType,mentioned_user_ids:e.mentionedUserIds,mentioned_users:null===(t=e.mentionedUsers)||void 0===t?void 0:t.map((function(e){return Ja.payloadify(e)})),mentioned_message_template:e.mentionedMessageTemplate,thread_info:e.threadInfo?_s.payloadify(e.threadInfo):null,reactions:e.reactions.map((function(e){return ks.payloadify(e)})),sorted_metaarray:null===(n=e.metaArrays)||void 0===n?void 0:n.map((function(e){return bs.payloadify(e)})),og_tag:ws.payloadify(e.ogMetaData),silent:e.silent,is_op_msg:e.isOperatorMessage,apple_critical_alert_options:xs.payloadify(e.appleCriticalAlertOptions),created_at:e.createdAt,updated_at:e.updatedAt,scheduled_message_id:null===(r=e.scheduledInfo)||void 0===r?void 0:r.scheduledMessageId,scheduled_at:null===(s=e.scheduledInfo)||void 0===s?void 0:s.scheduledAt,scheduled_status:e._scheduledStatus,extended_message:e.extendedMessage})):null}},{key:"_getParentMessageInfoPayload",value:function(e){return e?ue({type:e.messageType,ts:e.createdAt,user:Cs.payloadify(e.sender),message:e.message,file:{url:e.plainUrl,name:e.name,type:e.type,require_auth:e.requireAuth}}):null}}]),a}(qa),Ns=function(t){i(a,t);var n=f(a);function a(t,s){var i,o,u,c,l;if(r(this,a),(i=n.call(this,t,s)).sender=null,i.reqId="",i.replyToChannel=!1,i.sendingStatus=null,i.errorCode=0,i.sender=s.user?new Cs(i._iid,s.user):s.sender_id,i.reqId=null!==(u=null!==(o=s.req_id)&&void 0!==o?o:s.request_id)&&void 0!==u?u:"",i.replyToChannel=null!==(c=s.is_reply_to_channel)&&void 0!==c&&c,s.request_state&&D(e.SendingStatus,s.request_state)&&(i.sendingStatus=s.request_state),!i.sendingStatus)if(i.messageId>0)i.sendingStatus=e.SendingStatus.SUCCEEDED;else if(i.scheduledInfo)switch(i._scheduledStatus=s.scheduled_status,s.scheduled_status){case gs.SENT:case gs.IN_QUEUE:i.sendingStatus=e.SendingStatus.SUCCEEDED;break;case gs.PENDING:i.sendingStatus=e.SendingStatus.SCHEDULED;break;case gs.FAILED:case gs.REMOVED:i.sendingStatus=e.SendingStatus.FAILED;break;case gs.CANCELED:i.sendingStatus=e.SendingStatus.CANCELED}else i.sendingStatus=e.SendingStatus.PENDING;return i.errorCode=null!==(l=s.error_code)&&void 0!==l?l:0,i}return s(a,[{key:"isResendable",get:function(){return this.sendingStatus===e.SendingStatus.FAILED&&((t=this.errorCode)>0&&O.indexOf(t)>=0);var t}},{key:"isIdentical",value:function(e){return this.messageId>0&&e.messageId>0?this.messageId===e.messageId:this.reqId===e.reqId}}],[{key:"payloadify",value:function(e){return e?ue(Object.assign(Object.assign({},p(o(a),"payloadify",this).call(this,e)),{user:Cs.payloadify(e.sender),req_id:e.reqId,is_reply_to_channel:e.replyToChannel,request_state:e.sendingStatus,error_code:e.errorCode})):null}}]),a}(Is),Ms=function(){function e(t){var n,a;r(this,e),this.url=null,this.width=0,this.height=0,this.realWidth=0,this.realHeight=0,this.url=t.url,this.width=t.width,this.height=t.height,this.realWidth=null!==(n=t.real_width)&&void 0!==n?n:t.width,this.realHeight=null!==(a=t.real_height)&&void 0!==a?a:t.height}return s(e,[{key:"plainUrl",get:function(){return this.url.split("?auth=")[0]}}],[{key:"payloadify",value:function(e){return e?ue({url:"",width:e.maxWidth,height:e.maxHeight,real_width:0,real_height:0}):null}}]),e}(),As={prevResultSize:0,nextResultSize:0,isInclusive:!1,reverse:!1,messageTypeFilter:e.MessageTypeFilter.ALL,customTypesFilter:null,senderUserIdsFilter:null,includeReactions:!1,includeMetaArray:!1,includeParentMessageInfo:!1},Os=function(t){return L("number",t.prevResultSize)&&L("number",t.nextResultSize)&&L("boolean",t.isInclusive)&&L("boolean",t.reverse)&&L("string",t.messageTypeFilter)&&D(e.MessageTypeFilter,t.messageTypeFilter)&&F("string",t.customTypesFilter,!0)&&F("string",t.senderUserIdsFilter,!0)&&L("boolean",t.includeMetaArray)&&L("boolean",t.includeReactions)&&L("boolean",t.includeParentMessageInfo)},Us=function(n){i(u,n);var a=f(u);function u(t,n){var s,i,o,c,l;if(r(this,u),(s=a.call(this,t,n)).message=null,s.translations={},s.message=null!==(i=n.message)&&void 0!==i?i:"",s.messageType=e.MessageType.ADMIN,s.translations=null!==(o=n.translations)&&void 0!==o?o:{},n.parent_message_info){var h=n.parent_message_info,d=ue(Object.assign(Object.assign({},h),{message_id:s.parentMessageId,channel_url:s.channelUrl,channel_type:s.channelType,file:h.file,url:null===(c=h.file)||void 0===c?void 0:c.url,require_auth:null===(l=h.file)||void 0===l?void 0:l.require_auth}));s.parentMessage=Vs(t,d)}return s}return s(u,[{key:"getThreadedMessagesByTimestamp",value:function(e,n){return b(this,void 0,void 0,t().mark((function r(){var a,s;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return a=Object.assign(Object.assign({},As),n),Ya(this.messageId>0&&L("number",e)&&Os(a)).throw(A.invalidParameters),s=Ei.of(this._iid),t.next=5,s.getThreadedMessagesByTimestamp(this,e,a);case 5:return t.abrupt("return",t.sent);case 6:case"end":return t.stop()}}),r,this)})))}}],[{key:"payloadify",value:function(e){return e?ue(Object.assign(Object.assign({},p(o(u),"payloadify",this).call(this,e)),{message:e.message,translations:e.translations,parent_message_info:p(o(u),"_getParentMessageInfoPayload",this).call(this,e.parentMessage)})):null}}]),u}(Is),Rs=function(){function e(t){var n,a;r(this,e),this.type=null,this.vendor=null,this.detail={},this.type=null!==(n=t.type)&&void 0!==n?n:"",this.vendor=null!==(a=t.vendor)&&void 0!==a?a:"",t.hasOwnProperty("detail")&&L("object",t.detail)&&!Array.isArray(t.detail)&&(this.detail=t.detail)}return s(e,null,[{key:"payloadify",value:function(e){return e?ue({type:e.type,vendor:e.vendor,detail:e.detail}):null}}]),e}();!function(e){e.OPEN="open",e.CLOSED="closed"}(Ts||(Ts={}));var Ls="removed",Ds=function(e){switch(e){case Ts.OPEN:return Ts.OPEN;case Ts.CLOSED:return Ts.CLOSED}},Ps=function(e){return!e||e.text&&L("string",e.text)},Fs=function(e){i(n,e);var t=f(n);function n(e,a){var s,i,o,u,c,l,h,d;return r(this,n),(s=t.call(this,e)).pollId=0,s.id=0,s.text=null,s.voteCount=0,s.createdBy=null,s.createdAt=0,s.updatedAt=0,s._lastVotedAt=0,s.pollId=null!==(i=a.poll_id)&&void 0!==i?i:0,s.id=null!==(o=a.id)&&void 0!==o?o:0,s.text=null!==(u=a.text)&&void 0!==u?u:null,s.voteCount=null!==(c=a.vote_count)&&void 0!==c?c:0,s.createdBy=null!==(l=a.created_by)&&void 0!==l?l:null,s.createdAt=null!==(h=a.created_at)&&void 0!==h?h:0,s.updatedAt=null!==(d=a.updated_at)&&void 0!==d?d:0,s}return s(n,null,[{key:"payloadify",value:function(e){return e?ue(Object.assign(Object.assign({},p(o(n),"payloadify",this).call(this,e)),{vote_count:e.voteCount,poll_id:e.pollId,text:e.text,created_at:e.createdAt,id:e.id,created_by:e.createdBy,updated_at:e.updatedAt})):null}}]),n}(qa),Gs=function(e){i(n,e);var t=f(n);function n(e,a){var s,i,o,u,c,l,h,d,f,p,v,_,m,g;return r(this,n),(s=t.call(this,e)).id=0,s.title=null,s.createdAt=0,s.updatedAt=0,s.closeAt=-1,s.status=Ts.CLOSED,s.messageId=0,s.data=null,s.voterCount=-1,s.options=[],s.createdBy=null,s.allowUserSuggestion=!1,s.allowMultipleVotes=!1,s.votedPollOptionIds=[],s.id=null!==(i=a.id)&&void 0!==i?i:0,s.title=null!==(o=a.title)&&void 0!==o?o:null,s.createdAt=null!==(u=a.created_at)&&void 0!==u?u:0,s.updatedAt=null!==(c=a.updated_at)&&void 0!==c?c:0,s.closeAt=null!==(l=a.close_at)&&void 0!==l?l:-1,s.status=null!==(h=Ds(a.status))&&void 0!==h?h:Ts.CLOSED,s.messageId=null!==(d=a.message_id)&&void 0!==d?d:0,s.data=null!==(f=a.data)&&void 0!==f?f:null,s.voterCount=null!==(p=a.voter_count)&&void 0!==p?p:-1,s.options=a.options?a.options.map((function(e){return new Fs(s._iid,e)})):[],s.createdBy=null!==(v=a.created_by)&&void 0!==v?v:null,s.allowUserSuggestion=null!==(_=a.allow_user_suggestion)&&void 0!==_&&_,s.allowMultipleVotes=null!==(m=a.allow_multiple_votes)&&void 0!==m&&m,s.votedPollOptionIds=null!==(g=a.voted_option_ids)&&void 0!==g?g:[],s}return s(n,[{key:"_applyPollUpdatePayload",value:function(e){var t,n,r,a,s,i,o,u,c=this;this.title=null!==(t=e.title)&&void 0!==t?t:this.title,this.updatedAt=null!==(n=e.updated_at)&&void 0!==n?n:this.updatedAt,this.closeAt=null!==(r=e.close_at)&&void 0!==r?r:this.closeAt,this.status=null!==(a=Ds(e.status))&&void 0!==a?a:this.status,this.data=null!==(s=e.data)&&void 0!==s?s:this.data,this.voterCount=null!==(i=e.voter_count)&&void 0!==i?i:this.voterCount,e.options&&(this.options=e.options.map((function(e){return new Fs(c._iid,e)})),this.votedPollOptionIds=e.options.filter((function(e){return e.vote_count>0})).map((function(e){return e.id}))),this.allowUserSuggestion=null!==(o=e.allow_user_suggestion)&&void 0!==o?o:this.allowUserSuggestion,this.allowMultipleVotes=null!==(u=e.allow_multiple_votes)&&void 0!==u?u:this.allowMultipleVotes}},{key:"applyPollUpdateEvent",value:function(e){var t=e._payload.poll;return!(!t||this.id!==t.id||t.updated_at-1){var s=t[r];a>=s._lastVotedAt&&(s.voteCount=e.vote_count,s._lastVotedAt=a)}})),r.req_id&&r.voted_option_ids&&(this.votedPollOptionIds=r.voted_option_ids),!0}},{key:"serialize",value:function(){return Ka(this)}}],[{key:"payloadify",value:function(e){return e?ue(Object.assign(Object.assign({},p(o(n),"payloadify",this).call(this,e)),{id:e.id,title:e.title,created_at:e.createdAt,updated_at:e.updatedAt,close_at:e.closeAt,status:e.status,message_id:e.messageId,data:e.data,voter_count:e.voterCount,options:e.options.map((function(e){return Fs.payloadify(e)})),created_by:e.createdBy,allow_user_suggestion:e.allowUserSuggestion,allow_multiple_votes:e.allowMultipleVotes,voted_option_ids:e.votedPollOptionIds})):null}}]),n}(qa),qs=function(n){i(u,n);var a=f(u);function u(t,n){var s,i,o,c,l,h;if(r(this,u),(s=a.call(this,t,n)).message="",s.messageParams=null,s.translations={},s.translationTargetLanguages=[],s.messageSurvivalSeconds=-1,s.plugins=[],s._poll=null,s.message=n.message,s.messageType=e.MessageType.USER,s.translations=null!==(i=n.translations)&&void 0!==i?i:{},s.translationTargetLanguages=null!==(o=n.target_langs)&&void 0!==o?o:[],0===Object.keys(s.translations).length&&s.translationTargetLanguages.length>0){var d,f=y(s.translationTargetLanguages);try{for(f.s();!(d=f.n()).done;){var p=d.value;s.translations[p]=""}}catch(e){f.e(e)}finally{f.f()}}if(s.messageSurvivalSeconds=null!==(c=n.message_survival_seconds)&&void 0!==c?c:-1,s.plugins=n.plugins?n.plugins.map((function(e){return new Rs(e)})):[],s._poll=n.poll?new Gs(s._iid,n.poll):null,n.parent_message_info){var v=n.parent_message_info,_=ue(Object.assign(Object.assign({},v),{created_at:v.ts,message_id:s.parentMessageId,channel_url:s.channelUrl,channel_type:s.channelType,file:v.file,url:null===(l=v.file)||void 0===l?void 0:l.url,require_auth:null===(h=v.file)||void 0===h?void 0:h.require_auth}));s.parentMessage=Vs(t,ue(_))}return s}return s(u,[{key:"getThreadedMessagesByTimestamp",value:function(e,n){return b(this,void 0,void 0,t().mark((function r(){var a,s;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return a=Object.assign(Object.assign({},As),n),Ya(this.messageId>0&&L("number",e)&&Os(a)).throw(A.invalidParameters),s=Ei.of(this._iid),t.next=5,s.getThreadedMessagesByTimestamp(this,e,a);case 5:return t.abrupt("return",t.sent);case 6:case"end":return t.stop()}}),r,this)})))}},{key:"applyPoll",value:function(e){return!(this._poll&&this._poll.id===e.id&&this._poll.updatedAt>e.updatedAt)&&(this._poll=e,!0)}},{key:"poll",get:function(){return this._poll}}],[{key:"payloadify",value:function(e){return e?ue(Object.assign(Object.assign({},p(o(u),"payloadify",this).call(this,e)),{message:e.message,translations:e.translations,message_survival_seconds:e.messageSurvivalSeconds,plugins:e.plugins.map((function(e){return Rs.payloadify(e)})),poll:Gs.payloadify(e._poll),parent_message_info:p(o(u),"_getParentMessageInfoPayload",this).call(this,e.parentMessage)})):null}}]),u}(Ns),Hs=function(e){i(n,e);var t=f(n);function n(e,a){var s,i,o,u,c;r(this,n),(s=t.call(this,e)).plainUrl="",s.fileName=null,s.mimeType=null,s.fileSize=0,s.thumbnails=[],s._requireAuth=!1,s.plainUrl=a.url,s.fileName=null!==(i=a.file_name)&&void 0!==i?i:null,s.mimeType=null!==(o=a.file_type)&&void 0!==o?o:null,s.fileSize=null!==(u=a.file_size)&&void 0!==u?u:0;var l=ds.of(s._iid).sessionManager;return s._requireAuth=null!==(c=a.require_auth)&&void 0!==c&&c,s.thumbnails=a.thumbnails?a.thumbnails.map((function(e){return new Ms(Object.assign(Object.assign({},e),{url:"".concat(e.url.split("?auth=")[0]).concat(s._requireAuth?"?auth=".concat(l.ekey):"")}))})):[],s}return s(n,[{key:"url",get:function(){var e=ds.of(this._iid).sessionManager;return this._requireAuth?"".concat(this.plainUrl,"?auth=").concat(e.ekey):this.plainUrl}}],[{key:"payloadify",value:function(e){var t;return{url:e.plainUrl,file_name:e.fileName,file_type:e.mimeType,file_size:e.fileSize,thumbnails:null===(t=e.thumbnails)||void 0===t?void 0:t.map((function(e){return{url:e.url,width:e.width,height:e.height,real_width:e.realWidth,real_height:e.realHeight}})),require_auth:e._requireAuth}}}]),n}(qa),js=function(n){i(u,n);var a=f(u);function u(t,n){var s,i,o,c,l,h;if(r(this,u),(s=a.call(this,t,n)).messageParams=null,s.fileInfoList=[],s.messageSurvivalSeconds=-1,s.messageType=e.MessageType.FILE,s.fileInfoList=null!==(o=null===(i=n.files)||void 0===i?void 0:i.map((function(e){return new Hs(t,e)})))&&void 0!==o?o:[],s.messageSurvivalSeconds=null!==(c=n.message_survival_seconds)&&void 0!==c?c:-1,n.parent_message_info){var d=n.parent_message_info,f=Object.assign(Object.assign({},d),{message_id:s.parentMessageId,channel_url:s.channelUrl,channel_type:s.channelType,file:d.file,url:null===(l=d.file)||void 0===l?void 0:l.url,require_auth:null===(h=d.file)||void 0===h?void 0:h.require_auth});s.parentMessage=Vs(t,f)}return s}return s(u,[{key:"getThreadedMessagesByTimestamp",value:function(e,n){return b(this,void 0,void 0,t().mark((function r(){var a,s;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return a=Object.assign(Object.assign({},As),n),Ya(this.messageId>0&&L("number",e)&&Os(a)).throw(A.invalidParameters),s=Ei.of(this._iid),t.next=5,s.getThreadedMessagesByTimestamp(this,e,a);case 5:return t.abrupt("return",t.sent);case 6:case"end":return t.stop()}}),r,this)})))}}],[{key:"payloadify",value:function(e){return e?ue(Object.assign(Object.assign({},p(o(u),"payloadify",this).call(this,e)),{files:e.fileInfoList&&e.fileInfoList&&Array.isArray(e.fileInfoList)?e.fileInfoList.map((function(e){return Hs.payloadify(e)})):void 0,message_survival_seconds:e.messageSurvivalSeconds,parent_message_info:p(o(u),"_getParentMessageInfoPayload",this).call(this,e.parentMessage)})):null}},{key:"_isMultipleFilesMessagePayload",value:function(e){var t=e.files;return Array.isArray(t)&&t.length>=2}},{key:"_isMultipleFilesMessageSerializedData",value:function(e){var t=e.fileInfoList;return Array.isArray(t)}}]),u}(Ns),zs=function(t){if(t)switch(t.messageType){case e.MessageType.USER:return qs.payloadify(t);case e.MessageType.FILE:return Bs.payloadify(t);case e.MessageType.ADMIN:return Us.payloadify(t)}return null},Vs=function(e,t){switch(t.type){case"MESG":return new qs(e,t);case"FILE":return js._isMultipleFilesMessagePayload(t)?new js(e,t):new Bs(e,t);case"ADMM":case"BRDM":return new Us(e,t)}return null},Bs=function(n){i(u,n);var a=f(u);function u(t,n){var s,i,o,c,l,h,d,f,p,v,_,m,g,y,k,b;r(this,u),(s=a.call(this,t,n)).messageParams=null,s.plainUrl="",s.requireAuth=!1,s.name=null,s.size=0,s.type=null,s.thumbnails=[],s.messageSurvivalSeconds=-1,s.messageType=e.MessageType.FILE;var E=null!==(i=n.file)&&void 0!==i?i:null;s.plainUrl=(null!==(c=null!==(o=null==E?void 0:E.url)&&void 0!==o?o:n.url)&&void 0!==c?c:"").split("?auth=")[0],s.name=null!==(h=null!==(l=null==E?void 0:E.name)&&void 0!==l?l:n.name)&&void 0!==h?h:"File",s.size=null!==(f=null!==(d=null==E?void 0:E.size)&&void 0!==d?d:n.size)&&void 0!==f?f:0,s.data=null!==(v=null!==(p=null==E?void 0:E.data)&&void 0!==p?p:n.custom)&&void 0!==v?v:"",s.type=E?null!==(_=E.type)&&void 0!==_?_:"":null!==(m=n.type)&&void 0!==m?m:"";var w=ds.of(s._iid).sessionManager;if(s.requireAuth=null!==(g=n.require_auth)&&void 0!==g&&g,s.thumbnails=n.thumbnails?n.thumbnails.map((function(e){return new Ms(Object.assign(Object.assign({},e),{url:"".concat(e.url.split("?auth=")[0]).concat(s.requireAuth?"?auth=".concat(w.ekey):"")}))})):[],s.messageSurvivalSeconds=null!==(y=n.message_survival_seconds)&&void 0!==y?y:-1,n.parent_message_info){var x=n.parent_message_info,C=ue(Object.assign(Object.assign({},x),{message_id:s.parentMessageId,channel_url:s.channelUrl,channel_type:s.channelType,file:x.file,url:null===(k=x.file)||void 0===k?void 0:k.url,require_auth:null===(b=x.file)||void 0===b?void 0:b.require_auth}));s.parentMessage=Vs(t,C)}return s}return s(u,[{key:"url",get:function(){var e=ds.of(this._iid).sessionManager;return this.requireAuth?"".concat(this.plainUrl,"?auth=").concat(e.ekey):this.plainUrl}},{key:"getThreadedMessagesByTimestamp",value:function(e,n){return b(this,void 0,void 0,t().mark((function r(){var a,s;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return a=Object.assign(Object.assign({},As),n),Ya(this.messageId>0&&L("number",e)&&Os(a)).throw(A.invalidParameters),s=Ei.of(this._iid),t.next=5,s.getThreadedMessagesByTimestamp(this,e,a);case 5:return t.abrupt("return",t.sent);case 6:case"end":return t.stop()}}),r,this)})))}}],[{key:"payloadify",value:function(e){var t;return e?ue(Object.assign(Object.assign({},p(o(u),"payloadify",this).call(this,e)),{url:e.plainUrl,require_auth:e.requireAuth,file:{name:e.name,size:e.size,type:e.type,data:e.data},thumbnails:null===(t=e.thumbnails)||void 0===t?void 0:t.map((function(e){return{url:e.url,width:e.width,height:e.height,real_width:e.realWidth,real_height:e.realHeight}})),message_survival_seconds:e.messageSurvivalSeconds,parent_message_info:p(o(u),"_getParentMessageInfoPayload",this).call(this,e.parentMessage)})):null}}]),u}(Ns),Qs=function(t){i(a,t);var n=f(a);function a(t){var s,i,o;r(this,a);var u=[];return t.mentionType===e.MentionType.USERS&&(t.mentionedUserIds?u=t.mentionedUserIds:t.mentionedUsers&&(u=t.mentionedUsers.map((function(e){return e.userId})))),n.call(this,{code:"FILE",ackRequired:!0,payload:ue({channel_url:t.channelUrl,files:Zs(t.files),url:t.url,name:null!==(s=t.fileName)&&void 0!==s?s:"",type:null!==(i=t.mimeType)&&void 0!==i?i:"",size:null!==(o=t.fileSize)&&void 0!==o?o:0,custom:t.data,custom_type:t.customType,thumbnails:t.thumbnailSizes,require_auth:t.requireAuth,metaarray:t.metaArrays,mention_type:t.mentionType,mentioned_user_ids:u,push_option:t.pushNotificationDeliveryOption&&t.pushNotificationDeliveryOption!==e.PushNotificationDeliveryOption.DEFAULT?t.pushNotificationDeliveryOption:void 0,apple_critical_alert_options:t.appleCriticalAlertOptions,silent:t.silent,reply_to_channel:t.isReplyToChannel,parent_message_id:t.parentMessageId>0?t.parentMessageId:null,req_id:t.reqId,pin_message:t.isPinnedMessage})})}return s(a)}(ia),Ks=function(t){i(a,t);var n=f(a);function a(t){var s,i,o;r(this,a),s=n.call(this);var u=[];return t.mentionType===e.MentionType.USERS&&(t.mentionedUserIds?u=t.mentionedUserIds:t.mentionedUsers&&(u=t.mentionedUsers.map((function(e){return e.userId})))),s.method=ce.POST,s.path="".concat(Ce(t.channelType),"/").concat(encodeURIComponent(t.channelUrl),"/messages"),s.params=ue({message_type:e.MessageType.FILE,user_id:t.userId,files:Zs(t.files),url:t.fileUrl,mention_type:t.mentionType,mentioned_user_ids:u,file_name:t.fileName,file_size:t.fileSize,file_type:t.mimeType,data:t.data,custom_type:t.customType,thumbnails:null===(i=t.thumbnailSizes)||void 0===i?void 0:i.map((function(e){return Ms.payloadify(e)})),require_auth:t.requireAuth,sorted_metaarray:null===(o=t.metaArrays)||void 0===o?void 0:o.map((function(e){return bs.payloadify(e)})),push_option:t.pushNotificationDeliveryOption,parent_message_id:t.parentMessageId>0?t.parentMessageId:null,apple_critical_alert_options:xs.payloadify(t.appleCriticalAlertOptions),reply_to_channel:t.isReplyToChannel,req_id:t.reqId,pin_message:t.isPinnedMessage}),s}return s(a)}(Ae),Ws=function(e){i(n,e);var t=f(n);function n(e,a,s){var i,o,u,c;r(this,n),(i=t.call(this,e,"FILE",s)).message=s.files&&s.files.length>=2?new js(e,s):new Bs(e,s);var l=ds.of(e).sdkState;return i.isMentioned=Se(i.message.mentionType,null!==(o=i.message.mentionedUserIds)&&void 0!==o?o:null===(u=i.message.mentionedUsers)||void 0===u?void 0:u.map((function(e){return e.userId})),l.userId),i.forceUpdateLastMessage=null!==(c=s.force_update_last_message)&&void 0!==c&&c,i}return s(n)}(Ge),Ys=function(e){i(n,e);var t=f(n);function n(e,a){var s,i,o;r(this,n),(s=t.call(this,e,a)).message=a.files&&a.files.length>=2?new js(e,a):new Bs(e,a);var u=ds.of(e).sdkState;return s.isMentioned=Se(s.message.mentionType,null!==(i=s.message.mentionedUserIds)&&void 0!==i?i:s.message.mentionedUsers.map((function(e){return e.userId})),u.userId),s.forceUpdateLastMessage=null!==(o=a.force_update_last_message)&&void 0!==o&&o,s}return s(n)}(Oe);function Zs(e){return null==e?void 0:e.map((function(e){var t,n;return ue({url:e.fileUrl,file_name:e.fileName,file_type:e.mimeType,file_size:e.fileSize,thumbnails:null===(t=e.thumbnailSizes)||void 0===t?void 0:t.map((function(e){return Ms.payloadify(e)})),require_auth:null===(n=e._uploadedMetaData)||void 0===n?void 0:n.requireAuth})}))}var Js;!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"}(Js||(Js={}));var Xs=function(){function e(t,n){var a=this,s=n.sdkState,i=n.dispatcher,o=n.requestQueue,u=n.onlineDetector,c=n.cacheContext;r(this,e),this._queueMap=new Map,this._connectionState=null,this._onlineDetector=null,this._iid=t,this._sdkState=s,this._requestQueue=o,this._cacheContext=c,this._dispatcher=i,this._dispatcher.on((function(e){e instanceof ha&&(a._connectionState=e.stateType)})),this._onlineDetector=u}return s(e,[{key:"_shouldSendThroughWebSocket",get:function(){return this._connectionState===aa.CONNECTED||this._connectionState===aa.CONNECTING||this._connectionState===aa.RECONNECTING}},{key:"_sendFileMessage",value:function(e,n){return b(this,void 0,void 0,t().mark((function r(){var a,s,i,o,u,c,l,h,d;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(a=this._createSendFileMessageRequestParams(e,n),!this._shouldSendThroughWebSocket){t.next=10;break}return s=new Qs(a),t.next=5,this._requestQueue.send(s);case 5:return i=t.sent,o=i.as(Ws),u=o.message,t.abrupt("return",u);case 10:return c=new Ks(Object.assign(Object.assign({},a),{userId:this._sdkState.userId})),t.next=13,this._requestQueue.send(c);case 13:return l=t.sent,h=l.as(Ys),d=h.message,t.abrupt("return",d);case 16:case"end":return t.stop()}}),r,this)})))}},{key:"_createSendFileMessageRequestParams",value:function(e,t){var n=Object.assign(Object.assign({},t.params),{channelUrl:e.url,channelType:e.channelType,reqId:t.requestId,url:""});if(t.multipleFileUploadInfo){var r=t.params;n.files=r.fileInfoList}else{var a=t.params;n.url=a.fileUrl,n.requireAuth=a.requireAuth}return n}},{key:"_resolveMessageQueue",value:function(e){return b(this,void 0,void 0,t().mark((function n(){var r,a,s,i,o,u,c,l;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(!(r=this._queueMap.get(e.url))){t.next=57;break}if(r.isResolving){t.next=56;break}r.isResolving=!0,a=[],s=!0,i=y(r.messageQueue),t.prev=7,i.s();case 9:if((o=i.n()).done){t.next=39;break}u=o.value,t.t0=u.state,t.next=t.t0===Js.PENDING||t.t0===Js.UPLOADING?14:t.t0===Js.UPLOADED?17:t.t0===Js.FAILED?35:37;break;case 14:return s=!1,a.push(u),t.abrupt("break",37);case 17:if(!s){t.next=33;break}return t.prev=18,u.state=Js.SENDING,t.next=22,this._sendFileMessage(e,u);case 22:return c=t.sent,u.deferred.resolve(c),t.next=26,ka(100);case 26:t.next=31;break;case 28:t.prev=28,t.t1=t.catch(18),u.deferred.reject(t.t1);case 31:t.next=34;break;case 33:a.push(u);case 34:return t.abrupt("break",37);case 35:return u.deferred.reject(u.error.code===E.REQUEST_CANCELED?A.fileUploadCanceled:u.error),t.abrupt("break",37);case 37:t.next=9;break;case 39:t.next=44;break;case 41:t.prev=41,t.t2=t.catch(7),i.e(t.t2);case 44:return t.prev=44,i.f(),t.finish(44);case 47:if(l=r.isResolveRequestPending,r.messageQueue=a,r.isResolving=!1,r.isResolveRequestPending=!1,!l){t.next=54;break}return t.next=54,this._resolveMessageQueue(e);case 54:t.next=57;break;case 56:r.isResolveRequestPending=!0;case 57:case"end":return t.stop()}}),n,this,[[7,41,44,47],[18,28]])})))}},{key:"_uploadNextPendingItem",value:function(e){var n;return b(this,void 0,void 0,t().mark((function r(){var a,s,i,o,u,c,l,h,d,f;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(a=this._queueMap.get(e.url),!(s=a.messageQueue.find((function(e){return e.state===Js.PENDING})))){t.next=29;break}if(!s.multipleFileUploadInfo){t.next=18;break}if(i=s.multipleFileUploadInfo,o=i.uploadIndex,u=i.uploadCount,c=i.requestHandler,l=s.params,h=l.fileInfoList[o],!q(h.file)||(null===(n=h._uploadedMetaData)||void 0===n?void 0:n.isUploaded)){t.next=12;break}return t.next=10,this._tryUploadNextItemAndUpdateItemState(e,a,s);case 10:t.next=13;break;case 12:s.state=o=0&&e.uploadQueue.splice(n,1)}},{key:"_uploadNextFileForSingleFileItemAndUpdateParams",value:function(e,n,r){var a,s,i;return b(this,void 0,void 0,t().mark((function o(){var u,c,l,h,d,f,p,v,_,m;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return u=new ps({file:r.file,channelUrl:e.url,thumbnailSizes:r.thumbnailSizes,requestId:n.requestId}),t.next=3,this._requestQueue.send(u);case 3:c=t.sent,l=c.as(vs),h=l.url,d=l.fileSize,f=void 0===d?r.fileSize:d,p=l.thumbnailSizes,v=void 0===p?r.thumbnailSizes:p,_=l.requireAuth,m=void 0!==_&&_,r.fileName=null!==(a=r.fileName)&&void 0!==a?a:r.file.name,r.mimeType=null!==(s=r.mimeType)&&void 0!==s?s:r.file.type,r.fileSize=null!==(i=r.fileSize)&&void 0!==i?i:r.file.size,r.fileUrl=h,r.fileSize=f,r.thumbnailSizes=v,r.requireAuth=m;case 12:case"end":return t.stop()}}),o,this)})))}},{key:"_uploadNextFileForMultipleFilesItemAndUpdateParams",value:function(e,n,r){var a,s,i;return b(this,void 0,void 0,t().mark((function o(){var u,c,l,h,d,f,p,v,_,m,g,y;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return u=n.multipleFileUploadInfo.uploadIndex,c=r.fileInfoList[u],l=new ps({file:c.file,channelUrl:e.url,thumbnailSizes:c.thumbnailSizes,requestId:n.requestId}),t.next=5,this._requestQueue.send(l);case 5:h=t.sent,d=h.as(vs),f=d.url,p=d.fileSize,v=void 0===p?c.fileSize:p,_=d.thumbnailSizes,m=void 0===_?c.thumbnailSizes:_,g=d.requireAuth,y=void 0!==g&&g,c.fileName=null!==(a=c.fileName)&&void 0!==a?a:c.file.name,c.mimeType=null!==(s=c.mimeType)&&void 0!==s?s:c.file.type,c.fileSize=null!==(i=c.fileSize)&&void 0!==i?i:c.file.size,c.file=null,c.fileUrl=f,c.fileSize=v,c.thumbnailSizes=m,c._uploadedMetaData=Object.assign(Object.assign({},c._uploadedMetaData),{requireAuth:y,isUploaded:!0});case 15:case"end":return t.stop()}}),o,this)})))}},{key:"request",value:function(e,n,r){var a=arguments.length>3&&void 0!==arguments[3]?arguments[3]:null;return b(this,void 0,void 0,t().mark((function s(){var i,o,u,c,l;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return this._queueMap.has(e.url)||(i={messageQueue:[],uploadQueue:[],isResolving:!1,isResolveRequestPending:!1},this._queueMap.set(e.url,i)),o=this._queueMap.get(e.url),u=new ua,c={requestId:n,params:r,state:Js.PENDING,deferred:u},$s(r)&&(l={uploadIndex:0,uploadCount:r.fileInfoList.length,requestHandler:a},c.multipleFileUploadInfo=l),o.messageQueue.push(c),this._uploadNextPendingItem(e),t.abrupt("return",u.promise);case 8:case"end":return t.stop()}}),s,this)})))}},{key:"cancel",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null,n=this._queueMap.get(e.url);if(n){var r,a=t?[n.messageQueue.find((function(e){return e.requestId===t}))]:_(n.messageQueue),s=y(a);try{for(s.s();!(r=s.n()).done;){var i=r.value;if(i)switch(i.state){case Js.PENDING:i.state=Js.FAILED,i.error=A.requestCanceled,this._resolveMessageQueue(e);break;case Js.UPLOADING:this._requestQueue.cancel(i.requestId)}}}catch(e){s.e(e)}finally{s.f()}}}}]),e}();function $s(e){return"fileInfoList"in e}var ei,ti={prevResultSize:0,nextResultSize:0,isInclusive:!1,reverse:!1,messageTypeFilter:e.MessageTypeFilter.ALL,customTypesFilter:null,senderUserIdsFilter:null,replyType:e.ReplyType.NONE,includeReactions:!1,includeMetaArray:!1,includeParentMessageInfo:!1,includeThreadInfo:!1,showSubchannelMessagesOnly:!1},ni=function(t){return L("number",t.prevResultSize)&&L("number",t.nextResultSize)&&L("boolean",t.isInclusive)&&L("boolean",t.reverse)&&L("string",t.messageTypeFilter)&&D(e.MessageTypeFilter,t.messageTypeFilter)&&F("string",t.customTypesFilter,!0)&&F("string",t.senderUserIdsFilter,!0)&&D(e.ReplyType,t.replyType)&&L("boolean",t.includeMetaArray)&&L("boolean",t.includeReactions)&&L("boolean",t.includeParentMessageInfo)&&L("boolean",t.includeThreadInfo)&&L("boolean",t.showSubchannelMessagesOnly)},ri={replyType:e.ReplyType.NONE,includeReactions:!1,includeThreadInfo:!1,includeMetaArray:!1,includeParentMessageInfo:!1},ai=function(t){return D(e.ReplyType,t.replyType)&&L("boolean",t.includeReactions)&&L("boolean",t.includeMetaArray)&&L("boolean",t.includeParentMessageInfo)&&L("boolean",t.includeThreadInfo)};e.MessageEventSource=void 0,(ei=e.MessageEventSource||(e.MessageEventSource={})).UNKNOWN="UNKNOWN",ei.EVENT_MESSAGE_SENT_SUCCESS="EVENT_MESSAGE_SENT_SUCCESS",ei.EVENT_MESSAGE_SENT_FAILED="EVENT_MESSAGE_SENT_FAILED",ei.EVENT_MESSAGE_SENT_PENDING="EVENT_MESSAGE_SENT_PENDING",ei.EVENT_MESSAGE_RECEIVED="EVENT_MESSAGE_RECEIVED",ei.EVENT_MESSAGE_UPDATED="EVENT_MESSAGE_UPDATED",ei.EVENT_MESSAGE_DELETED="EVENT_MESSAGE_DELETED",ei.EVENT_MESSAGE_READ="EVENT_MESSAGE_READ",ei.EVENT_MESSAGE_DELIVERED="EVENT_MESSAGE_DELIVERED",ei.EVENT_MESSAGE_REACTION_UPDATED="EVENT_MESSAGE_REACTION_UPDATED",ei.EVENT_MESSAGE_THREADINFO_UPDATED="EVENT_MESSAGE_THREADINFO_UPDATED",ei.EVENT_MESSAGE_OFFSET_UPDATED="EVENT_MESSAGE_OFFSET_UPDATED",ei.REQUEST_MESSAGE="REQUEST_MESSAGE",ei.EVENT_POLL_UPDATED="EVENT_POLL_UPDATED",ei.EVENT_POLL_VOTED="EVENT_POLL_VOTED",ei.SYNC_POLL_CHANGELOGS="SYNC_POLL_CHANGELOGS",ei.REQUEST_RESEND_MESSAGE="REQUEST_RESEND_MESSAGE",ei.REQUEST_THREADED_MESSAGE="REQUEST_THREADED_MESSAGE",ei.REQUEST_MESSAGE_CHANGELOGS="REQUEST_MESSAGE_CHANGELOGS",ei.SYNC_MESSAGE_FILL="SYNC_MESSAGE_FILL",ei.SYNC_MESSAGE_BACKGROUND="SYNC_MESSAGE_BACKGROUND",ei.SYNC_MESSAGE_CHANGELOGS="SYNC_MESSAGE_CHANGELOGS",ei.LOCAL_MESSAGE_PENDING_CREATED="LOCAL_MESSAGE_PENDING_CREATED",ei.LOCAL_MESSAGE_FAILED="LOCAL_MESSAGE_FAILED",ei.LOCAL_MESSAGE_CANCELED="LOCAL_MESSAGE_CANCELED",ei.LOCAL_MESSAGE_RESEND_STARTED="LOCAL_MESSAGE_RESEND_STARTED";var si,ii=function(t){return t.startsWith("EVENT_")||t===e.MessageEventSource.SYNC_MESSAGE_FILL||t===e.MessageEventSource.SYNC_MESSAGE_CHANGELOGS||t===e.MessageEventSource.SYNC_POLL_CHANGELOGS},oi=function(e){i(n,e);var t=f(n);function n(e){var a,s=e.messages,i=e.source;return r(this,n),(a=t.call(this)).messages=s,a.source=i,a}return s(n)}(oe),ui=function(e){i(n,e);var t=f(n);function n(e){var a,s=e.messageIds,i=e.source;return r(this,n),(a=t.call(this)).messageIds=s,a.source=i,a}return s(n)}(oe),ci=function(e){i(n,e);var t=f(n);function n(e){var a,s=e.reqId,i=e.source;return r(this,n),(a=t.call(this)).reqId=s,a.source=i,a}return s(n)}(oe),li=function(e){i(n,e);var t=f(n);function n(e){var a,s=e.polls,i=e.source;return r(this,n),(a=t.call(this)).polls=s,a.source=i,a}return s(n)}(oe),hi=function(e){i(n,e);var t=f(n);function n(e){var a,s=e.event,i=e.source;return r(this,n),(a=t.call(this)).event=s,a.source=i,a}return s(n)}(oe),di=function(e){i(n,e);var t=f(n);function n(e){var a,s=e.event,i=e.source;return r(this,n),(a=t.call(this)).event=null,a.source=null,a.event=s,a.source=i,a}return s(n)}(oe),fi=function(e){i(n,e);var t=f(n);function n(e){var a,s=e.channelType,i=e.channelUrl,o=e.messageId,u=e.includeMetaArray,c=e.includeReactions,l=e.includeThreadInfo,h=e.includeParentMessageInfo;return r(this,n),(a=t.call(this)).method=ce.GET,a.path="".concat(Ce(s),"/").concat(encodeURIComponent(i),"/messages/").concat(encodeURIComponent(o)),a.params={is_sdk:!0,with_sorted_meta_array:u,include_reactions:c,include_thread_info:l,include_parent_message_info:h,include_poll_details:!0},a}return s(n)}(Ae),pi=function(e){i(n,e);var t=f(n);function n(e,a){var s;return r(this,n),(s=t.call(this,e,a)).message=a?Vs(e,Object.assign({},a)):null,s}return s(n)}(Oe),vi=function(e){i(n,e);var t=f(n);function n(e){var a,s=e.channelType,i=e.channelUrl,o=e.timestamp,u=void 0===o?null:o,c=e.token,l=void 0===c?null:c,h=e.prevResultSize,d=e.nextResultSize,f=e.isInclusive,p=e.reverse,v=e.messageTypeFilter,_=e.customTypesFilter,m=e.senderUserIdsFilter,g=e.replyType,y=e.includeMetaArray,k=e.includeReactions,b=e.parentMessageId,E=e.includeThreadInfo,w=e.includeParentMessageInfo,x=e.showSubchannelMessagesOnly,C=e.checkingContinuousMessages;return r(this,n),(a=t.call(this)).method=ce.GET,a.path="".concat(Ce(s),"/").concat(encodeURIComponent(i),"/messages"),a.params=ue({is_sdk:!0,prev_limit:h,next_limit:d,include:f,reverse:p,message_ts:u,message_id:l,message_type:null!=v?v:null,custom_types:_,sender_ids:m,include_reply_type:g,with_sorted_meta_array:y,include_reactions:k,parent_message_id:b,include_thread_info:E,include_parent_message_info:w,show_subchannel_message_only:x,include_poll_details:!0,checking_continuous_messages:C}),a}return s(n)}(Ae),_i=function(e){i(n,e);var t=f(n);function n(e,a){var s;return r(this,n),(s=t.call(this,e,a)).messages=a.messages.map((function(t){return Vs(e,t)})),s}return s(n)}(Oe),mi=function(e){i(n,e);var t=f(n);function n(e){var a,s=e.channelType,i=e.channelUrl,o=e.timestamp,u=e.token,c=e.replyType,l=e.includeMetaArray,h=e.includeReactions,d=e.includeThreadInfo,f=e.includeParentMessageInfo;return r(this,n),(a=t.call(this)).method=ce.GET,a.path="".concat(Ce(s),"/").concat(encodeURIComponent(i),"/messages/changelogs"),a.params={change_ts:o,token:u,with_sorted_meta_array:l,include_reactions:h,include_thread_info:d,include_reply_type:c,include_parent_message_info:f,include_poll_details:!0},a}return s(n)}(Ae),gi=function(e){i(n,e);var t=f(n);function n(e,a){var s;return r(this,n),(s=t.call(this,e,a)).updatedMessages=a.updated.map((function(t){return Vs(e,t)})),s.deletedMessagesInfo=a.deleted.map((function(e){return{messageId:e.message_id,deletedAt:e.deleted_at}})),s.hasMore=a.has_more,s.nextToken=a.next,s}return s(n)}(Oe),yi=function(e){i(n,e);var t=f(n);function n(e){var a,s=e.channelUrl,i=e.scheduledMessageId;return r(this,n),(a=t.call(this)).method=ce.GET,a.path="".concat(fe,"/").concat(encodeURIComponent(s),"/scheduled_messages/").concat(encodeURIComponent(i)),a.params={},a}return s(n)}(Ae),ki=function(e){i(n,e);var t=f(n);function n(e,a){var s;return r(this,n),(s=t.call(this,e,a)).message=a?Vs(e,Object.assign({},a)):null,s}return s(n)}(Oe),bi={},Ei=function(){function n(e,t){var a=t.sdkState,s=t.dispatcher,i=t.requestQueue,o=t.onlineDetector,u=t.cacheContext;r(this,n),this._iid=e,this._sdkState=a,this._requestQueue=i,this._dispatcher=s,this._cacheContext=u,this.fileMessageQueue=new Xs(e,{sdkState:a,dispatcher:s,requestQueue:i,onlineDetector:o,cacheContext:u}),bi[e]=this}return s(n,[{key:"buildMessageFromSerializedData",value:function(t){var n=Wa(t);switch(n.messageType){case e.MessageType.USER:return new qs(this._iid,qs.payloadify(n));case e.MessageType.FILE:return js._isMultipleFilesMessageSerializedData(n)?new js(this._iid,js.payloadify(n)):new Bs(this._iid,Bs.payloadify(n));case e.MessageType.ADMIN:return new Us(this._iid,Us.payloadify(n))}return null}},{key:"buildUserMessageCreateParamsFromSerializedData",value:function(e,t){return ue({data:t.data,customType:t.customType,mentionType:t.mentionType,mentionedUserIds:t.mentionedUserIds,mentionedUsers:t.mentionedUsers,mentionedMessageTemplate:t.mentionedMessageTemplate,metaArrays:t.metaArrays,parentMessageId:t.parentMessageId,isReplyToChannel:e.isReplyToChannel,pushNotificationDeliveryOption:e.pushNotificationDeliveryOption,appleCriticalAlertOptions:t.appleCriticalAlertOptions,reqId:t.reqId,message:t.message,translationTargetLanguages:Object.keys(t.translations),pollId:e.pollId})}},{key:"buildFileMessageCreateParamsFromSerializedData",value:function(e,t){var n;return ue({data:t.data,customType:t.customType,mentionType:t.mentionType,mentionedUserIds:t.mentionedUserIds,mentionedUsers:t.mentionedUsers,mentionedMessageTemplate:t.mentionedMessageTemplate,metaArrays:t.metaArrays,parentMessageId:t.parentMessageId,isReplyToChannel:e.isReplyToChannel,pushNotificationDeliveryOption:e.pushNotificationDeliveryOption,appleCriticalAlertOptions:t.appleCriticalAlertOptions,reqId:t.reqId,file:e.file,fileKey:e.fileKey,fileUrl:t.plainUrl,fileName:t.name,fileSize:t.size,mimeType:t.type,thumbnailSizes:null===(n=t.thumbnails)||void 0===n?void 0:n.map((function(e){return{maxWidth:e.width,maxHeight:e.height}})),fileType:e.fileType,requireAuth:t.requireAuth})}},{key:"buildMultipleFilesMessageCreateParamsFromSerializedData",value:function(e,t){return ue({data:t.data,customType:t.customType,mentionType:t.mentionType,mentionedUserIds:t.mentionedUserIds,mentionedUsers:t.mentionedUsers,mentionedMessageTemplate:t.mentionedMessageTemplate,metaArrays:t.metaArrays,parentMessageId:t.parentMessageId,isReplyToChannel:e.isReplyToChannel,pushNotificationDeliveryOption:e.pushNotificationDeliveryOption,appleCriticalAlertOptions:t.appleCriticalAlertOptions,reqId:t.reqId,fileInfoList:e.fileInfoList})}},{key:"buildScheduledUserMessageCreateParamsFromSerializedData",value:function(e,t){return Object.assign(Object.assign({},this.buildUserMessageCreateParamsFromSerializedData(e,t)),{scheduledAt:e.scheduledAt})}},{key:"buildScheduledFileMessageCreateParamsFromSerializedData",value:function(e,t){return Object.assign(Object.assign({},this.buildFileMessageCreateParamsFromSerializedData(e,t)),{scheduledAt:e.scheduledAt})}},{key:"buildSenderFromSerializedData",value:function(e){var t=Wa(e);return new Cs(this._iid,Cs.payloadify(t))}},{key:"getMessage",value:function(e){return b(this,void 0,void 0,t().mark((function n(){var r,a,s,i;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return r=new fi(e),t.next=3,this._requestQueue.send(r);case 3:return a=t.sent,s=a.as(pi),i=s.message,t.abrupt("return",i);case 6:case"end":return t.stop()}}),n,this)})))}},{key:"getScheduledMessage",value:function(e){return b(this,void 0,void 0,t().mark((function n(){var r,a,s,i;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return r=new yi(e),t.next=3,this._requestQueue.send(r);case 3:return a=t.sent,s=a.as(ki),i=s.message,t.abrupt("return",i);case 6:case"end":return t.stop()}}),n,this)})))}},{key:"getMessagesByMessageId",value:function(n,r,a,s){var i=arguments.length>4&&void 0!==arguments[4]?arguments[4]:e.MessageEventSource.REQUEST_MESSAGE;return b(this,void 0,void 0,t().mark((function e(){var o,u,c,l;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return o=new vi(Object.assign(Object.assign({channelType:r,channelUrl:n,token:String(a)},ti),s)),e.next=3,this._requestQueue.send(o);case 3:return u=e.sent,c=u.as(_i),l=c.messages,this._dispatcher.dispatch(new oi({messages:l,source:i})),e.abrupt("return",l);case 7:case"end":return e.stop()}}),e,this)})))}},{key:"getMessagesByTimestamp",value:function(n,r,a,s){var i=arguments.length>4&&void 0!==arguments[4]?arguments[4]:e.MessageEventSource.REQUEST_MESSAGE;return b(this,void 0,void 0,t().mark((function e(){var o,u,c,l;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return o=new vi(Object.assign(Object.assign({channelType:r,channelUrl:n,timestamp:a},ti),s)),e.next=3,this._requestQueue.send(o);case 3:return u=e.sent,c=u.as(_i),l=c.messages,this._dispatcher.dispatch(new oi({messages:l,source:i})),e.abrupt("return",l);case 7:case"end":return e.stop()}}),e,this)})))}},{key:"_getMessagesByTimestampForCollection",value:function(n,r,a,s){var i=arguments.length>4&&void 0!==arguments[4]?arguments[4]:e.MessageEventSource.REQUEST_MESSAGE,o=arguments.length>5?arguments[5]:void 0;return b(this,void 0,void 0,t().mark((function e(){var u,c,l,h,d;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return u=new vi(Object.assign(Object.assign(Object.assign({channelType:r,channelUrl:n,timestamp:a},ti),s),{checkingContinuousMessages:o})),e.next=3,this._requestQueue.send(u);case 3:return c=e.sent,l=c.payload,h=c.as(_i),d=h.messages,this._dispatcher.dispatch(new oi({messages:d,source:i})),e.abrupt("return",{messages:d,isContinuousMessages:l});case 8:case"end":return e.stop()}}),e,this)})))}},{key:"getThreadedMessagesByTimestamp",value:function(n,r,a){var s=arguments.length>3&&void 0!==arguments[3]?arguments[3]:e.MessageEventSource.REQUEST_THREADED_MESSAGE;return b(this,void 0,void 0,t().mark((function i(){var o,u,c,l,h;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return o=new vi(Object.assign(Object.assign(Object.assign({channelUrl:n.channelUrl,channelType:n.channelType,timestamp:r},As),a),{replyType:e.ReplyType.ALL,parentMessageId:n.messageId,includeThreadInfo:!0})),t.next=3,this._requestQueue.send(o);case 3:return u=t.sent,c=u.as(_i),l=c.messages,(h=l.slice(1)).forEach((function(e){e.parentMessage=n})),this._dispatcher.dispatch(new oi({messages:h,source:s})),t.abrupt("return",{parentMessage:l[0],threadedMessages:h});case 9:case"end":return t.stop()}}),i,this)})))}},{key:"getMessageChangelogs",value:function(n,r,a,s){var i=arguments.length>4&&void 0!==arguments[4]?arguments[4]:e.MessageEventSource.REQUEST_MESSAGE_CHANGELOGS;return b(this,void 0,void 0,t().mark((function e(){var o,u,c,l,h,d,f,p;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return o=new mi(ue(Object.assign(Object.assign({channelType:r,channelUrl:n,timestamp:"number"==typeof a?a:null,token:"string"==typeof a?a:null},ri),s))),e.next=3,this._requestQueue.send(o);case 3:return u=e.sent,c=u.as(gi),l=c.updatedMessages,h=c.deletedMessagesInfo,d=c.hasMore,f=c.nextToken,p=h.map((function(e){return e.messageId})),l.length>0&&this._dispatcher.dispatch(new oi({messages:l,source:i})),p.length>0&&this._dispatcher.dispatch(new ui({messageIds:p,source:i})),e.abrupt("return",{updatedMessages:l,deletedMessageIds:p,hasMore:d,token:f});case 9:case"end":return e.stop()}}),e,this)})))}}],[{key:"of",value:function(e){return bi[e]}}]),n}(),wi=function(){function t(){r(this,t),this._onPending=qe,this._onFailed=qe,this._onSucceeded=qe}return s(t,[{key:"_trigger",value:function(t,n){switch(n.sendingStatus){case e.SendingStatus.PENDING:0===n.errorCode&&this._onPending(n);break;case e.SendingStatus.FAILED:case e.SendingStatus.CANCELED:this._onFailed(t,n.scheduledInfo?null:n);break;case e.SendingStatus.SCHEDULED:case e.SendingStatus.SUCCEEDED:this._onSucceeded(n)}}},{key:"onPending",value:function(e){return this._onPending=e,this}},{key:"onFailed",value:function(e){return this._onFailed=e,this}},{key:"onSucceeded",value:function(e){return this._onSucceeded=e,this}}]),t}(),xi=function(e){i(n,e);var t=f(n);function n(e,a){var s;r(this,n),(s=t.call(this,e)).threadInfo=null,s.targetMessageId=0,s.channelUrl=null,s.channelType=null;var i=a.thread_info,o=a.parent_message_id,u=a.channel_url,c=a.channel_type;return i&&L("object",i)&&L("number",o)&&L("string",u)&&L("string",c)&&(s.threadInfo=new _s(e,i),s.targetMessageId=o,s.channelUrl=u,s.channelType=c),s}return s(n)}(qa),Ci={channelUrl:null,channelType:null,messageId:0,includeReactions:!1,includeMetaArray:!1,includeParentMessageInfo:!1,includeThreadInfo:!1},Ti=function(t){return L("string",t.channelUrl)&&L("string",t.channelType)&&D(e.ChannelType,t.channelType)&&L("number",t.messageId)&&L("boolean",t.includeMetaArray)&&L("boolean",t.includeParentMessageInfo)&&L("boolean",t.includeThreadInfo)},Si=function(){function e(t,n){var a;r(this,e),this._iid=null,this.limit=20,this._isLoading=!1,this._hasNext=!0,this._token="",this._iid=t,this.limit=null!==(a=n.limit)&&void 0!==a?a:20}return s(e,[{key:"hasNext",get:function(){return this._hasNext}},{key:"isLoading",get:function(){return this._isLoading}},{key:"_validate",value:function(){return L("number",this.limit)&&this.limit>0}}]),e}(),Ii=function(e){i(n,e);var t=f(n);function n(e){var a,s=e.channelCustomType,i=e.keyword,o=e.limit,u=e.reverse,c=e.exactMatch,l=e.channelUrl,h=e.order,d=e.messageTimestampFrom,f=e.messageTimestampTo,p=e.advancedQuery,v=e.targetFields,_=e.nextToken;return r(this,n),(a=t.call(this)).method=ce.GET,a.path="".concat(me,"/messages"),a.params={custom_type:s,query:i,limit:o,reverse:u,exact_match:c,channel_url:l,message_ts_from:d,message_ts_to:f,sort_field:h,advanced_query:p,target_fields:v,after:_},a}return s(n)}(Ae),Ni=function(e){i(n,e);var t=f(n);function n(e,a){var s;return r(this,n),(s=t.call(this,e,a)).messages=a.results.map((function(t){return Vs(e,t)})),s.hasNext=a.has_next,s.nextToken=a.end_cursor,s.totalCount=a.total_count,s}return s(n)}(Oe);e.MessageSearchOrder=void 0,(si=e.MessageSearchOrder||(e.MessageSearchOrder={})).SCORE="score",si.TIMESTAMP="ts";var Mi,Ai,Oi,Ui=function(n){i(u,n);var a=f(u);function u(t,n){var s,i,o,c,l,h,d,f,p,v;return r(this,u),(s=a.call(this,t,n)).keyword="",s.reverse=!1,s.exactMatch=!1,s.channelUrl="",s.channelCustomType="",s.messageTimestampFrom=null,s.messageTimestampTo=null,s.order=e.MessageSearchOrder.SCORE,s.advancedQuery=!1,s.targetFields=null,s._nextToken="",s.totalCount=-1,s.keyword=n.keyword,s.reverse=null!==(i=n.reverse)&&void 0!==i&&i,s.exactMatch=null!==(o=n.exactMatch)&&void 0!==o&&o,s.channelUrl=null!==(c=n.channelUrl)&&void 0!==c?c:"",s.channelCustomType=null!==(l=n.channelCustomType)&&void 0!==l?l:"",s.messageTimestampFrom=null!==(h=n.messageTimestampFrom)&&void 0!==h?h:null,s.messageTimestampTo=null!==(d=n.messageTimestampTo)&&void 0!==d?d:null,s.order=null!==(f=n.order)&&void 0!==f?f:e.MessageSearchOrder.SCORE,s.advancedQuery=null!==(p=n.advancedQuery)&&void 0!==p&&p,s.targetFields=null!==(v=n.targetFields)&&void 0!==v?v:null,s}return s(u,[{key:"_validate",value:function(){return p(o(u.prototype),"_validate",this).call(this)&&L("string",this.keyword)&&this.keyword.length>0&&L("boolean",this.reverse)&&L("boolean",this.exactMatch)&&L("string",this.channelUrl)&&L("string",this.channelCustomType)&&(L("number",this.messageTimestampFrom)||null===this.messageTimestampFrom)&&(L("number",this.messageTimestampTo)||null===this.messageTimestampTo)&&D(e.MessageSearchOrder,this.order)&&L("boolean",this.advancedQuery)&&F("string",this.targetFields,!0)}},{key:"next",value:function(){return b(this,void 0,void 0,t().mark((function e(){var n,r,a,s,i,o,u,c,l;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!this._validate()){e.next=21;break}if(this._isLoading){e.next=18;break}if(!this._hasNext){e.next=15;break}return this._isLoading=!0,n=ds.of(this._iid),r=n.requestQueue,a=new Ii(Object.assign(Object.assign({},this),{nextToken:this._nextToken?this._nextToken:null})),e.next=8,r.send(a);case 8:return s=e.sent,i=s.as(Ni),o=i.messages,u=i.hasNext,c=i.nextToken,l=i.totalCount,this._nextToken=c,this._hasNext=u,this._isLoading=!1,this.totalCount=l,e.abrupt("return",o);case 15:return e.abrupt("return",[]);case 18:throw A.queryInProgress;case 19:e.next=22;break;case 21:throw A.invalidParameters;case 22:case"end":return e.stop()}}),e,this)})))}}]),u}(Si),Ri=function(t){i(a,t);var n=f(a);function a(e,t,s,i){var o;return r(this,a),(o=n.call(this,e,i)).channelUrl=t,o.channelType=s,o}return s(a,[{key:"_validate",value:function(){return p(o(a.prototype),"_validate",this).call(this)&&L("string",this.channelUrl)&&D(e.ChannelType,this.channelType)}}]),a}(Si),Li=function(n){i(u,n);var a=f(u);function u(t,n,s,i){var o,c,l,h,d,f,p,v,_,m,g;return r(this,u),(o=a.call(this,t,n,s,i)).reverse=!1,o.messageTypeFilter=e.MessageTypeFilter.ALL,o.customTypesFilter=null,o.senderUserIdsFilter=null,o.replyType=e.ReplyType.NONE,o.includeMetaArray=!1,o.includeReactions=!1,o.includeParentMessageInfo=!1,o.includeThreadInfo=!1,o.showSubchannelMessagesOnly=!1,o._edge=Number.MAX_SAFE_INTEGER,o.reverse=null!==(c=i.reverse)&&void 0!==c&&c,o.messageTypeFilter=null!==(l=i.messageTypeFilter)&&void 0!==l?l:e.MessageTypeFilter.ALL,o.customTypesFilter=null!==(h=i.customTypesFilter)&&void 0!==h?h:null,o.senderUserIdsFilter=null!==(d=i.senderUserIdsFilter)&&void 0!==d?d:null,o.replyType=null!==(f=i.replyType)&&void 0!==f?f:e.ReplyType.NONE,o.includeMetaArray=null!==(p=i.includeMetaArray)&&void 0!==p&&p,o.includeReactions=null!==(v=i.includeReactions)&&void 0!==v&&v,o.includeParentMessageInfo=null!==(_=i.includeParentMessageInfo)&&void 0!==_&&_,o.includeThreadInfo=null!==(m=i.includeThreadInfo)&&void 0!==m&&m,o.showSubchannelMessagesOnly=null!==(g=i.showSubchannelMessagesOnly)&&void 0!==g&&g,o}return s(u,[{key:"_validate",value:function(){return p(o(u.prototype),"_validate",this).call(this)&&L("boolean",this.reverse)&&D(e.MessageTypeFilter,this.messageTypeFilter)&&D(e.ReplyType,this.replyType)&&F("string",this.customTypesFilter,!0)&&F("string",this.senderUserIdsFilter,!0)&&L("boolean",this.includeMetaArray)&&L("boolean",this.includeReactions)&&L("boolean",this.includeParentMessageInfo)&&L("boolean",this.includeThreadInfo)&&L("boolean",this.showSubchannelMessagesOnly)}},{key:"load",value:function(){return b(this,void 0,void 0,t().mark((function e(){var n,r;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!this._validate()){e.next=18;break}if(this._isLoading){e.next=15;break}if(!this._hasNext){e.next=12;break}return this._isLoading=!0,n=Ei.of(this._iid),e.next=7,n.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});case 7:return r=e.sent,this._edge=Math.min.apply(Math,[Number.MAX_SAFE_INTEGER].concat(_(r.map((function(e){return e.createdAt}))))),this._hasNext=r.length>=this.limit,this._isLoading=!1,e.abrupt("return",r);case 12:return e.abrupt("return",[]);case 15:throw A.queryInProgress;case 16:e.next=19;break;case 18:throw A.invalidParameters;case 19:case"end":return e.stop()}}),e,this)})))}}]),u}(Ri),Di={channelUrl:null,scheduledMessageId:0},Pi=function(e){return L("string",e.channelUrl)&&L("number",e.scheduledMessageId)},Fi=function(e){i(n,e);var t=f(n);function n(){var e;return r(this,n),(e=t.apply(this,arguments))._onFileUploaded=qe,e}return s(n,[{key:"_triggerOnFileUploaded",value:function(e,t,n,r){this._onFileUploaded(e,t,n,r)}},{key:"onFileUploaded",value:function(e){return this._onFileUploaded=e,this}},{key:"onPending",value:function(e){return p(o(n.prototype),"onPending",this).call(this,e),this}},{key:"onFailed",value:function(e){return p(o(n.prototype),"onFailed",this).call(this,e),this}},{key:"onSucceeded",value:function(e){return p(o(n.prototype),"onSucceeded",this).call(this,e),this}}]),n}(wi),Gi=function(e){i(a,e);var n=f(a);function a(){var e;return r(this,a),(e=n.apply(this,arguments)).name="message",e}return s(a,[{key:"init",value:function(e,t){var n=t.sdkState,r=t.dispatcher,s=t.sessionManager,i=t.requestQueue,u=t.logger,c=t.onlineDetector,l=t.cacheContext;p(o(a.prototype),"init",this).call(this,e,{sdkState:n,dispatcher:r,sessionManager:s,requestQueue:i,logger:u,onlineDetector:c,cacheContext:l}),this._manager=new Ei(e,{sdkState:n,dispatcher:r,requestQueue:i,onlineDetector:c,cacheContext:l})}},{key:"buildMessageFromSerializedData",value:function(e){return this._manager.buildMessageFromSerializedData(e)}},{key:"buildSenderFromSerializedData",value:function(e){return this._manager.buildSenderFromSerializedData(e)}},{key:"getMessage",value:function(e){return b(this,void 0,void 0,t().mark((function n(){var r;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return r=Object.assign(Object.assign({},Ci),e),Ya(Ti(r)).throw(A.invalidParameters),t.abrupt("return",this._manager.getMessage(r));case 3:case"end":return t.stop()}}),n,this)})))}},{key:"getScheduledMessage",value:function(e){return b(this,void 0,void 0,t().mark((function n(){var r;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return r=Object.assign(Object.assign({},Di),e),Ya(Pi(r)).throw(A.invalidParameters),t.abrupt("return",this._manager.getScheduledMessage(r));case 3:case"end":return t.stop()}}),n,this)})))}}]),a}(fs),qi=function(e){i(n,e);var t=f(n);function n(e){var a,s=e.title,i=e.optionTexts,o=e.data,u=e.allowUserSuggestion,c=e.allowMultipleVotes,l=e.closeAt;return r(this,n),(a=t.call(this)).method=ce.POST,a.path=be,a.params={title:s,options:i,data:o,allow_user_suggestion:u,allow_multiple_votes:c,close_at:l},a}return s(n)}(Ae),Hi=function(e){i(n,e);var t=f(n);function n(e,a){var s;return r(this,n),(s=t.call(this,e,a)).poll=new Gs(e,a),s}return s(n)}(Oe),ji=function(e){i(n,e);var t=f(n);function n(e){var a,s=e.channelUrl,i=e.channelType,o=e.pollId;return r(this,n),(a=t.call(this)).method=ce.GET,a.path="".concat(be,"/").concat(encodeURIComponent(o)),a.params={channel_url:s,channel_type:i},a}return s(n)}(Ae),zi=function(e){i(n,e);var t=f(n);function n(e,a){var s;return r(this,n),(s=t.call(this,e,a)).poll=new Gs(e,a),s}return s(n)}(Oe),Vi=function(e){i(n,e);var t=f(n);function n(e){var a,s=e.channelUrl,i=e.channelType,o=e.pollId,u=e.pollOptionId;return r(this,n),(a=t.call(this)).method=ce.GET,a.path="".concat(be,"/").concat(encodeURIComponent(o),"/options/").concat(encodeURIComponent(u)),a.params={channel_url:s,channel_type:i},a}return s(n)}(Ae),Bi=function(e){i(n,e);var t=f(n);function n(e,a){var s;return r(this,n),(s=t.call(this,e,a)).pollOption=new Fs(e,a),s}return s(n)}(Oe),Qi=function(e){i(n,e);var t=f(n);function n(e){var a,s=e.channelType,i=e.channelUrl,o=e.timestamp,u=e.token;return r(this,n),(a=t.call(this)).method=ce.GET,a.path="".concat(Ce(s),"/").concat(encodeURIComponent(i),"/polls/changelogs"),a.params=ue({change_ts:o,token:u}),a}return s(n)}(Ae),Ki=function(e){i(n,e);var t=f(n);function n(e,a){var s;return r(this,n),(s=t.call(this,e,a)).updatedPolls=a.updated.map((function(t){return function(e,t){return t?new Gs(e,t):null}(e,t)})),s.deletedPollIds=a.deleted.map((function(e){return e})),s.hasMore=a.has_more,s.nextToken=a.next,s}return s(n)}(Oe),Wi={title:null,optionTexts:null,data:null,allowUserSuggestion:null,allowMultipleVotes:null,closeAt:-1},Yi=function(e){return L("string",e.title)&&(t=e.optionTexts,F("string",t)&&t.every((function(e){return""!==e.trim()})))&&Ps(e.data)&&L("boolean",e.allowUserSuggestion,!0)&&L("boolean",e.allowMultipleVotes,!0)&&L("number",e.closeAt,!0);var t},Zi={channelUrl:null,channelType:null,pollId:null,pollOptionId:null},Ji=function(t){return L("string",t.channelUrl)&&D(e.ChannelType,t.channelType)&&L("number",t.pollId)&&L("number",t.pollOptionId)},Xi={channelUrl:null,channelType:null,pollId:null},$i=function(t){return L("string",t.channelUrl)&&""!==t.channelUrl&&D(e.ChannelType,t.channelType)&&L("number",t.pollId)},eo={},to=function(){function n(e,t){var a=t.sdkState,s=t.dispatcher,i=t.sessionManager,o=t.requestQueue,u=t.logger;r(this,n),this._iid=e,this._sdkState=a,this._sessionManager=i,this._requestQueue=o,this._dispatcher=s,this._logger=u,eo[e]=this}return s(n,[{key:"buildPollFromSerializedData",value:function(e){var t=Wa(e);return new Gs(this._iid,Gs.payloadify(t))}},{key:"get",value:function(e){return b(this,void 0,void 0,t().mark((function n(){var r,a,s,i;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return Ya($i(e)).throw(A.invalidParameters),r=new ji(Object.assign({},e)),t.next=4,this._requestQueue.send(r);case 4:return a=t.sent,s=a.as(zi),i=s.poll,t.abrupt("return",i);case 7:case"end":return t.stop()}}),n,this)})))}},{key:"create",value:function(e){return b(this,void 0,void 0,t().mark((function n(){var r,a,s,i,o;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return Ya(Yi(e)).throw(A.invalidParameters),r=e.data,a=new qi(Object.assign(Object.assign({},e),{data:r})),t.next=5,this._requestQueue.send(a);case 5:return s=t.sent,i=s.as(Hi),o=i.poll,t.abrupt("return",o);case 8:case"end":return t.stop()}}),n,this)})))}},{key:"getOption",value:function(e){return b(this,void 0,void 0,t().mark((function n(){var r,a,s,i;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return Ya(Ji(e)).throw(A.invalidParameters),r=new Vi(Object.assign({},e)),t.next=4,this._requestQueue.send(r);case 4:return a=t.sent,s=a.as(Bi),i=s.pollOption,t.abrupt("return",i);case 7:case"end":return t.stop()}}),n,this)})))}},{key:"getPollChangeLogs",value:function(n,r,a){var s=arguments.length>3&&void 0!==arguments[3]?arguments[3]:e.MessageEventSource.SYNC_POLL_CHANGELOGS;return b(this,void 0,void 0,t().mark((function e(){var i,o,u,c,l,h,d;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return i=new Qi(ue({channelType:r,channelUrl:n,timestamp:"number"==typeof a?a:null,token:"string"==typeof a?a:null})),e.next=3,this._requestQueue.send(i);case 3:return o=e.sent,u=o.as(Ki),c=u.updatedPolls,l=u.deletedPollIds,h=u.hasMore,d=u.nextToken,c.length>0&&this._dispatcher.dispatch(new li({polls:c,source:s})),e.abrupt("return",{updatedPolls:c,deletedPollIds:l,hasMore:h,token:d});case 7:case"end":return e.stop()}}),e,this)})))}}],[{key:"of",value:function(e){return eo[e]}}]),n}(),no=s((function e(t,n){r(this,e),this.pollId=0,this.messageId=0,this.pollId=n.poll.id,this.messageId=n.poll.message_id,this._iid=t,this._payload=n})),ro=s((function e(t){r(this,e),this.pollId=0,this.messageId=0,this.pollId=t.poll_id,this.messageId=t.message_id,this._payload=t})),ao=function(e){i(n,e);var t=f(n);function n(e){var a,s=e.channelUrl,i=e.channelType,o=e.token,u=e.limit;return r(this,n),(a=t.call(this)).method=ce.GET,a.path=be,a.params={channel_url:s,channel_type:i,token:o,limit:u},a}return s(n)}(Ae),so=function(e){i(n,e);var t=f(n);function n(e,a){var s,i;return r(this,n),(s=t.call(this,e,a)).polls=(null!==(i=a.polls)&&void 0!==i?i:[]).map((function(t){return new Gs(e,t)})),s.token=a.next,s}return s(n)}(Oe),io=function(e){i(a,e);var n=f(a);function a(e,t){return r(this,a),n.call(this,e,t.channelUrl,t.channelType,t)}return s(a,[{key:"next",value:function(){return b(this,void 0,void 0,t().mark((function e(){var n,r,a,s,i,o,u;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!this._validate()){e.next=20;break}if(this._isLoading){e.next=17;break}if(!this._hasNext){e.next=14;break}return this._isLoading=!0,n=ds.of(this._iid),r=n.requestQueue,a=new ao(Object.assign(Object.assign({},this),{token:this._token})),e.next=8,r.send(a);case 8:return s=e.sent,i=s.as(so),o=i.polls,u=i.token,this._token=u,this._hasNext=!!u,this._isLoading=!1,e.abrupt("return",o);case 14:return e.abrupt("return",[]);case 17:throw A.queryInProgress;case 18:e.next=21;break;case 20:throw A.invalidParameters;case 21:case"end":return e.stop()}}),e,this)})))}}]),a}(Ri),oo=function(e){i(n,e);var t=f(n);function n(e){var a,s=e.channelUrl,i=e.channelType,o=e.pollId,u=e.pollOptionId,c=e.token,l=e.limit;return r(this,n),(a=t.call(this)).method=ce.GET,a.path="".concat(be,"/").concat(encodeURIComponent(o),"/options/").concat(encodeURIComponent(u),"/voters"),a.params={channel_url:s,channel_type:i,token:c,limit:l},a}return s(n)}(Ae),uo=function(e){i(n,e);var t=f(n);function n(e,a){var s,i;return r(this,n),(s=t.call(this,e,a)).voters=(null!==(i=a.voters)&&void 0!==i?i:[]).map((function(t){return new Ja(e,t)})),s.token=a.next,s}return s(n)}(Oe),co=function(e){i(a,e);var n=f(a);function a(e,t){var s;return r(this,a),(s=n.call(this,e,t.channelUrl,t.channelType,t)).pollId=t.pollId,s.pollOptionId=t.pollOptionId,s}return s(a,[{key:"_validate",value:function(){return p(o(a.prototype),"_validate",this).call(this)&&L("number",this.pollId)&&L("number",this.pollOptionId)}},{key:"next",value:function(){return b(this,void 0,void 0,t().mark((function e(){var n,r,a,s,i,o,u;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!this._validate()){e.next=20;break}if(this._isLoading){e.next=17;break}if(!this._hasNext){e.next=14;break}return this._isLoading=!0,n=ds.of(this._iid),r=n.requestQueue,a=new oo(Object.assign(Object.assign({},this),{pollId:this.pollId,pollOptionId:this.pollOptionId,token:this._token})),e.next=8,r.send(a);case 8:return s=e.sent,i=s.as(uo),o=i.voters,u=i.token,this._token=u,this._hasNext=!!u,this._isLoading=!1,e.abrupt("return",o);case 14:return e.abrupt("return",[]);case 17:throw A.queryInProgress;case 18:e.next=21;break;case 20:throw A.invalidParameters;case 21:case"end":return e.stop()}}),e,this)})))}}]),a}(Ri),lo=function(e){i(a,e);var n=f(a);function a(){var e;return r(this,a),(e=n.apply(this,arguments)).name="poll",e}return s(a,[{key:"init",value:function(e,t){var n=t.sdkState,r=t.dispatcher,s=t.sessionManager,i=t.requestQueue,u=t.logger,c=t.onlineDetector,l=t.cacheContext;p(o(a.prototype),"init",this).call(this,e,{sdkState:n,dispatcher:r,sessionManager:s,requestQueue:i,logger:u,onlineDetector:c,cacheContext:l}),this._manager=new to(e,{sdkState:n,dispatcher:r,sessionManager:s,requestQueue:i,logger:u,onlineDetector:c,cacheContext:l})}},{key:"create",value:function(e){return b(this,void 0,void 0,t().mark((function n(){var r;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return r=Object.assign(Object.assign({},Wi),e),Ya(Yi(r)).throw(A.invalidParameters),t.abrupt("return",this._manager.create(r));case 3:case"end":return t.stop()}}),n,this)})))}},{key:"get",value:function(e){return b(this,void 0,void 0,t().mark((function n(){var r;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return r=Object.assign(Object.assign({},Xi),e),Ya($i(r)).throw(A.invalidParameters),t.abrupt("return",this._manager.get(r));case 3:case"end":return t.stop()}}),n,this)})))}},{key:"getOption",value:function(e){return b(this,void 0,void 0,t().mark((function n(){var r;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return r=Object.assign(Object.assign({},Zi),e),Ya(Ji(r)).throw(A.invalidParameters),t.abrupt("return",this._manager.getOption(r));case 3:case"end":return t.stop()}}),n,this)})))}},{key:"buildPollFromSerializedData",value:function(e){return this._manager.buildPollFromSerializedData(e)}}]),a}(fs),ho={profileImage:null,profileUrl:null,nickname:null},fo=function(e){return q(e.profileImage,!0)&&L("string",e.profileUrl,!0)&&L("string",e.nickname,!0)},po=function(e){i(n,e);var t=f(n);function n(){var e,a=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return r(this,n),e=t.call(this),Object.keys(a).forEach((function(t){e.hasOwnProperty(t)&&(e[t]=a[t])})),e}return s(n)}(s((function e(){r(this,e),this.onSessionExpired=qe,this.onSessionTokenRequired=function(e){return e(null)},this.onSessionError=qe,this.onSessionRefreshed=qe,this.onSessionClosed=qe}))),vo=function(e){i(n,e);var t=f(n);function n(){var e,a=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return r(this,n),e=t.call(this),Object.keys(a).forEach((function(t){e.hasOwnProperty(t)&&(e[t]=a[t])})),e}return s(n)}(s((function e(){r(this,e),this.onConnected=qe,this.onReconnectStarted=qe,this.onReconnectSucceeded=qe,this.onReconnectFailed=qe,this.onDisconnected=qe}))),_o=function(e){i(n,e);var t=f(n);function n(){var e,a=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return r(this,n),e=t.call(this),Object.keys(a).forEach((function(t){e.hasOwnProperty(t)&&(e[t]=a[t])})),e}return s(n)}(s((function e(){r(this,e),this.onFriendsDiscovered=qe,this.onTotalUnreadMessageCountUpdated=qe}))),mo="GroupChannel",go=100,yo="Message";e.GroupChannelListOrder=void 0,(Mi=e.GroupChannelListOrder||(e.GroupChannelListOrder={})).LATEST_LAST_MESSAGE="latest_last_message",Mi.CHRONOLOGICAL="chronological",Mi.CHANNEL_NAME_ALPHABETICAL="channel_name_alphabetical",Mi.METADATA_VALUE_ALPHABETICAL="metadata_value_alphabetical",e.PublicGroupChannelListOrder=void 0,(Ai=e.PublicGroupChannelListOrder||(e.PublicGroupChannelListOrder={})).CHRONOLOGICAL="chronological",Ai.CHANNEL_NAME_ALPHABETICAL="channel_name_alphabetical",Ai.METADATA_VALUE_ALPHABETICAL="metadata_value_alphabetical",e.ScheduledMessageListOrder=void 0,(Oi=e.ScheduledMessageListOrder||(e.ScheduledMessageListOrder={})).CREATED_AT="created_at",Oi.SCHEDULED_AT="scheduled_at";var ko,bo=function(t){switch(t){case e.GroupChannelListOrder.LATEST_LAST_MESSAGE:return["-lastMessageUpdatedAt","-createdAt","syncIndex"];case e.GroupChannelListOrder.CHRONOLOGICAL:return["-createdAt","syncIndex"];case e.GroupChannelListOrder.CHANNEL_NAME_ALPHABETICAL:return["name"]}},Eo=function(){function t(){r(this,t),this.messageTypeFilter=e.MessageTypeFilter.ALL,this.customTypesFilter=null,this.senderUserIdsFilter=null,this.replyType=e.ReplyType.NONE}return s(t,[{key:"clone",value:function(){var e=new t,n=JSON.parse(JSON.stringify(this));return Object.keys(n).forEach((function(t){e[t]=n[t]})),e}},{key:"match",value:function(t){switch(this.messageTypeFilter){case e.MessageTypeFilter.USER:if(t.messageType!==e.MessageType.USER)return!1;break;case e.MessageTypeFilter.FILE:if(t.messageType!==e.MessageType.FILE)return!1;break;case e.MessageTypeFilter.ADMIN:if(t.messageType!==e.MessageType.ADMIN)return!1}if(this.customTypesFilter&&this.customTypesFilter.length>0&&!this.customTypesFilter.includes(t.customType))return!1;if(this.senderUserIdsFilter&&this.senderUserIdsFilter.length>0){if(!(t instanceof Ns))return!1;if(!this.senderUserIdsFilter.includes(t.sender.userId))return!1}switch(this.replyType){case e.ReplyType.NONE:if(t.parentMessageId>0)return!1;break;case e.ReplyType.ONLY_REPLY_TO_CHANNEL:if(t instanceof Ns&&t.parentMessageId>0&&!t.replyToChannel)return!1}return!0}}]),t}();!function(e){e.CHANNEL_LATEST="channel_latest",e.NEWEST_CHILD_MESSAGE="newest_child_message"}(ko||(ko={}));var wo,xo=function(e){switch(e){case ko.CHANNEL_LATEST:return["channelUrl","-createdAt","-messageId"];case ko.NEWEST_CHILD_MESSAGE:return["channelUrl","-parentMessageId","-createdAt","-messageId"]}},Co={data:null,customType:null,mentionType:e.MentionType.USERS,mentionedUserIds:null,mentionedUsers:null,mentionedMessageTemplate:null,metaArrays:null,parentMessageId:null,isReplyToChannel:!1,pushNotificationDeliveryOption:null,appleCriticalAlertOptions:null,isPinnedMessage:!1},To=function(t){return L("string",t.data,!0)&&L("string",t.customType,!0)&&D(e.MentionType,t.mentionType)&&F("string",t.mentionedUserIds,!0)&&F(Ja,t.mentionedUsers,!0)&&L("string",t.mentionedMessageTemplate,!0)&&F(bs,t.metaArrays,!0)&&L("number",t.parentMessageId,!0)&&L("boolean",t.isReplyToChannel)&&D(e.PushNotificationDeliveryOption,t.pushNotificationDeliveryOption,!0)&&L(xs,t.appleCriticalAlertOptions,!0)&&L("boolean",t.isPinnedMessage,!0)},So=function(e){return e?{isReplyToChannel:e.isReplyToChannel,pushNotificationDeliveryOption:e.pushNotificationDeliveryOption,pollId:e.pollId}:null},Io=Object.assign(Object.assign({},Co),{message:null,translationTargetLanguages:null,pollId:null}),No=function(e){var t;return ue({data:e.data,customType:e.customType,mentionType:e.mentionType,mentionedUsers:e.mentionedUsers,mentionedUserIds:e.mentionedUserIds,mentionedMessageTemplate:e.mentionedMessageTemplate,metaArrays:e.metaArrays,pollId:null===(t=e.poll)||void 0===t?void 0:t.id,parentMessageId:e.parentMessageId,appleCriticalAlertOptions:e.appleCriticalAlertOptions,message:e.message,translationTargetLanguages:Object.keys(e.translations)})},Mo=function(e){return To(e)&&L("string",e.message)&&F("string",e.translationTargetLanguages,!0)&&L("number",e.pollId,!0)};!function(e){e.FILE="file",e.BLOB="blob",e.BLOB_LIKE_OBJECT="blobLikeObject",e.URL="url"}(wo||(wo={}));var Ao,Oo,Uo=function(e){return"undefined"!=typeof window&&"Blob"in window&&"undefined"!=typeof Blob&&e instanceof Blob},Ro=function(e){return e===wo.BLOB||e===wo.FILE},Lo=function(e){return e?{file:e.file,fileKey:e.fileKey,fileType:e.fileType,isReplyToChannel:e.isReplyToChannel,pushNotificationDeliveryOption:e.pushNotificationDeliveryOption}:null},Do=Object.assign(Object.assign({},Co),{file:null,fileKey:null,fileUrl:null,fileName:null,fileType:null,fileSize:null,mimeType:null,thumbnailSizes:null,requireAuth:!1}),Po=function(e){var t,n,r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null;return e.messageParams?(!e.url&&q(r)&&(e.messageParams.file=r),e.messageParams):ue({data:e.data,customType:e.customType,mentionType:e.mentionType,mentionedUsers:e.mentionedUsers,mentionedUserIds:e.mentionedUserIds,metaArrays:e.metaArrays,parentMessageId:e.parentMessageId,appleCriticalAlertOptions:e.appleCriticalAlertOptions,file:null!=r?r:null===(t=e.messageParams)||void 0===t?void 0:t.file,fileUrl:e.url,fileName:e.name,fileSize:e.size,mimeType:e.type,thumbnailSizes:null===(n=e.thumbnails)||void 0===n?void 0:n.map((function(e){return{maxWidth:e.width,maxHeight:e.height}}))})},Fo=function(e){return To(e)&&(q(e.file)||L("string",e.fileUrl))&&L("string",e.fileName,!0)&&L("string",e.mimeType,!0)&&L("number",e.fileSize,!0)&&(null===e.thumbnailSizes||void 0===e.thumbnailSizes||Array.isArray(e.thumbnailSizes)&&e.thumbnailSizes.every((function(e){return L("object",e)&&e.maxWidth>0&&e.maxHeight>0})))},Go=function(){return"undefined"!=typeof document&&"undefined"!=typeof navigator&&"ReactNative"!==navigator.product},qo=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"}(Ao||(Ao={})),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"}(Oo||(Oo={}));var Ho,jo={},zo=function(){function e(t){var n=this,a=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return r(this,e),this._state=Ao.PROCESSING,this._queue=[],this._activationQueue=[],jo[t]&&!a.forceCreate||(this.nodeId=qo(),this.key=t,Go()&&(a.startAsInvisible?this.registerNode():"visible"===document.visibilityState?this.claimHost():this.registerNode(),document.addEventListener("visibilitychange",(function(){"visible"===document.visibilityState&&n.claimHost()})),window.addEventListener("message",(function(e){var t=e.data,r=t.nodeId,a=t.requestId,s=t.key,i=t.op,o=t.data;if(r!==n.nodeId&&s===n.key)switch(i){case Oo.NEWNODE:n._sendSync();break;case Oo.CLAIM_HOST:n._sendSync(),n._hostId=r;break;case Oo.SYNC_HOST:if(!n.isInSync){n._activationTimeout&&clearTimeout(n._activationTimeout);var u,c=o.currentItemRequestId,l=y(o.queue);try{var h=function(){var e=u.value,t=n._queue.findIndex((function(t){return t.requestId===e.requestId}));t<0&&n._requestLock({nodeId:e.nodeId,requestId:e.requestId,key:n.key,op:Oo.REQUEST_LOCK,ts:e.ts})};for(l.s();!(u=l.n()).done;)h()}catch(e){l.e(e)}finally{l.f()}n._currentItem=n._queue.find((function(e){return e.requestId===c})),n._completeSync()}break;case Oo.REMOVENODE:n._queue=n._queue.filter((function(e){return e.nodeId!==t.nodeId})),n._currentItem&&n._currentItem.nodeId===t.nodeId&&(n._currentItem=void 0,n._acquire(n._queue[0]));break;case Oo.REQUEST_LOCK:n._requestLock(t);break;case Oo.ACQUIRE_LOCK:var d=n._queue.find((function(e){return e.requestId===a}));n._acquire(d);break;case Oo.RELEASE_LOCK:n._release(a)}})),window.addEventListener("beforeunload",(function(){n._send(Oo.REMOVENODE)}))),jo[t]=this),jo[t]}return s(e,[{key:"locked",get:function(){return!!this._currentItem}},{key:"isHost",get:function(){return this._hostId===this.nodeId}},{key:"isInSync",get:function(){return this._state==Ao.DONE}},{key:"_send",value:function(e){var t,n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},r={nodeId:this.nodeId,requestId:null!==(t=null==n?void 0:n.requestId)&&void 0!==t?t:qo(),key:this.key,op:e,data:n.data,ts:Date.now()};return Go()&&window.postMessage(r,"*"),r}},{key:"_acquire",value:function(e){e?(this._currentItem=e,this._currentItem.onAcquired&&this._currentItem.onAcquired(e.requestId)):this._currentItem=void 0}},{key:"_release",value:function(e){if(this._currentItem&&this._currentItem.requestId===e){var t=this._currentItem;this._currentItem=void 0,t.nodeId===this.nodeId&&this._send(Oo.RELEASE_LOCK,{requestId:t.requestId});var n=this._queue.findIndex((function(t){return t.requestId===e}));n>-1&&this._queue.splice(n,1),t.onReleased&&t.onReleased(e)}}},{key:"_requestLock",value:function(e){var t=this;return new Promise((function(n){var r={nodeId:e.nodeId,requestId:e.requestId,ts:e.ts,onAcquired:function(e){t.isHost&&t._send(Oo.ACQUIRE_LOCK,{requestId:e}),n()},onReleased:function(){t._acquire(t._queue[0])}},a=!1;for(var s in t._queue)if(t._queue[s].ts>r.ts){t._queue.splice(parseInt(s),0,r),a=!0;break}a||t._queue.push(r),t._currentItem||t._acquire(t._queue[0])}))}},{key:"_sendSync",value:function(){var e;this.isHost&&this._send(Oo.SYNC_HOST,{data:{currentItemRequestId:null===(e=this._currentItem)||void 0===e?void 0:e.requestId,queue:this._queue.map((function(e){return{nodeId:e.nodeId,requestId:e.requestId,ts:e.ts}}))}})}},{key:"_waitUntilSyncCompleted",value:function(){return b(this,void 0,void 0,t().mark((function e(){var n=this;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!this.isHost||this.isInSync){e.next=2;break}return e.abrupt("return",new Promise((function(e){n._activationQueue.push(e)})));case 2:case"end":return e.stop()}}),e,this)})))}},{key:"_waitSync",value:function(){var e=this;this.isInSync||(this._activationTimeout=setTimeout((function(){e._completeSync()}),8))}},{key:"_completeSync",value:function(){this.isInSync||(this._state=Ao.DONE,this._activationQueue.forEach((function(e){return e()})),this._activationQueue=[])}},{key:"registerNode",value:function(){this._send(Oo.NEWNODE),this._waitSync()}},{key:"claimHost",value:function(){this._hostId=this.nodeId,this._send(Oo.CLAIM_HOST),this._waitSync()}},{key:"lock",value:function(){return b(this,void 0,void 0,t().mark((function e(){var n;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this._waitUntilSyncCompleted();case 2:return n=this._send(Oo.REQUEST_LOCK),e.next=5,this._requestLock(n);case 5:case"end":return e.stop()}}),e,this)})))}},{key:"unlock",value:function(){var e;(null===(e=this._currentItem)||void 0===e?void 0:e.requestId)&&this._release(this._currentItem.requestId)}}]),e}(),Vo=Object.assign(Object.assign({},Io),{scheduledAt:null}),Bo=Object.assign(Object.assign({},Co),{scheduledAt:null,file:null,fileUrl:null,fileName:null,mimeType:null,fileSize:null,thumbnailSizes:null,requireAuth:!1}),Qo=Object.assign(Object.assign({},Co),{fileInfoList:null}),Ko=function(e){return(q(e.file)||L("string",e.fileUrl))&&L("string",e.fileName,!0)&&L("string",e.mimeType,!0)&&L("number",e.fileSize,!0)&&(void 0===e.thumbnailSizes||Array.isArray(e.thumbnailSizes)&&e.thumbnailSizes.every((function(e){return e.maxWidth>0&&e.maxHeight>0})))},Wo="UnsentMessage",Yo={},Zo=function(e){i(a,e);var n=f(a);function a(e,t){var s,i=t.sdkState,o=t.cacheContext;return r(this,a),(s=n.call(this,e))._sdkState=i,s._cacheContext=o,Yo[e]=d(s),s._mutex=new zo("unsendmessagecache.lock"),s}return s(a,[{key:"collection",get:function(){var e=this._cacheContext.nestdb;return e&&e.collection(Wo)}},{key:"localCacheEnabled",get:function(){return this._cacheContext.localCacheEnabled&&!!this.collection}},{key:"_serialize",value:function(e){if(e.messageId>0)throw A.invalidParameters;var t,n=Object.assign({},e.serialize());return e instanceof qs?(e.messageParams&&(n.messageParams=So(e.messageParams)),e.scheduledInfo&&e.scheduledInfo.scheduledMessageParams&&(n.scheduledInfo.scheduledMessageParams=(t=e.scheduledInfo.scheduledMessageParams,Object.assign(Object.assign({},So(t)),{scheduledAt:t.scheduledAt})))):e instanceof Bs?(e.messageParams&&(n.messageParams=Lo(e.messageParams)),e.scheduledInfo&&e.scheduledInfo.scheduledMessageParams&&(n.scheduledInfo.scheduledMessageParams=function(e){return Object.assign(Object.assign({},Lo(e)),{scheduledAt:e.scheduledAt})}(e.scheduledInfo.scheduledMessageParams))):e instanceof js&&e.messageParams&&(n.messageParams=function(e){return e?ue({fileInfoList:e.fileInfoList,isReplyToChannel:e.isReplyToChannel,pushNotificationDeliveryOption:e.pushNotificationDeliveryOption}):null}(e.messageParams)),n}},{key:"_deserialize",value:function(e){return e?(e=Object.assign(Object.assign({},e),{messageId:parseInt(e.messageId)}),Ei.of(this._iid).buildMessageFromSerializedData(e)):null}},{key:"_deserializeWithMessageCreateParams",value:function(e){return b(this,void 0,void 0,t().mark((function n(){var r,a,s,i,o,u,c,l=this;return t().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:if(r=Ei.of(this._iid),a=this._deserialize(e),!e.messageParams){n.next=23;break}if(!(a instanceof qs)){n.next=8;break}s=e.messageParams,a.messageParams=r.buildUserMessageCreateParamsFromSerializedData(s,a),n.next=23;break;case 8:if(!(a instanceof Bs)){n.next=17;break}if(!(i=e.messageParams).fileKey||"string"!=typeof i.fileKey||!Ro(i.fileType)){n.next=14;break}return n.next=13,this.collection.getBlob(i.fileKey);case 13:i.file=n.sent;case 14:a.messageParams=r.buildFileMessageCreateParamsFromSerializedData(i,a),n.next=23;break;case 17:if(!(a instanceof js)){n.next=23;break}if(!(o=e.messageParams)||!o.fileInfoList){n.next=23;break}return a.messageParams=r.buildMultipleFilesMessageCreateParamsFromSerializedData(o,a),n.next=23,Promise.all(a.messageParams.fileInfoList.map((function(e){return b(l,void 0,void 0,t().mark((function n(){var r,a;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if("string"!=typeof(null===(r=e._uploadedMetaData)||void 0===r?void 0:r.fileKey)||!Ro(null===(a=e._uploadedMetaData)||void 0===a?void 0:a.fileType)){t.next=4;break}return t.next=3,this.collection.getBlob(e._uploadedMetaData.fileKey);case 3:e.file=t.sent;case 4:case"end":return t.stop()}}),n,this)})))})));case 23:if(!(a.scheduledInfo&&e.scheduledInfo&&e.scheduledInfo.scheduledMessageParams)){n.next=36;break}if(!(a instanceof qs)){n.next=29;break}u=e.scheduledInfo.scheduledMessageParams,a.scheduledInfo.scheduledMessageParams=r.buildScheduledUserMessageCreateParamsFromSerializedData(u,a),n.next=36;break;case 29:if(!(a instanceof Bs)){n.next=36;break}if(!(c=e.scheduledInfo.scheduledMessageParams).fileKey||"string"!=typeof c.fileKey||!Ro(c.fileType)){n.next=35;break}return n.next=34,this.collection.getBlob(c.fileKey);case 34:c.file=n.sent;case 35:a.scheduledInfo.scheduledMessageParams=r.buildScheduledFileMessageCreateParamsFromSerializedData(c,a);case 36:return n.abrupt("return",a);case 37:case"end":return n.stop()}}),n,this)})))}},{key:"_getFileInfoBlobKey",value:function(e,t){return"".concat(e,".").concat(t)}},{key:"get",value:function(e){return b(this,void 0,void 0,t().mark((function n(){var r;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(!this.localCacheEnabled){t.next=6;break}return t.next=3,this.collection.getByKey("".concat(e));case 3:if(!(r=t.sent)){t.next=6;break}return t.abrupt("return",this._deserializeWithMessageCreateParams(r));case 6:return t.abrupt("return",null);case 7:case"end":return t.stop()}}),n,this)})))}},{key:"fetch",value:function(e){var n=e.channelUrl,r=void 0===n?null:n,a=e.filter,s=void 0===a?new Eo:a,i=e.order,o=void 0===i?ko.CHANNEL_LATEST:i,u=e.sendingStatus,c=void 0===u?null:u,l=e.backward,h=void 0!==l&&l,d=e.parentMessageId,f=void 0===d?null:d;return b(this,void 0,void 0,t().mark((function e(){var n,a,i,u,l,d=this;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!this.localCacheEnabled){e.next=13;break}return n=xo(o),a={"/where":function(e){return!!(o!==ko.NEWEST_CHILD_MESSAGE||f&&0!==e.parentMessageId&&e.parentMessageId===f)&&s.match(d._deserialize(e))}},r&&(a.channelUrl=r),c&&(a.sendingStatus=c),i={where:a,index:n,backward:h},e.next=8,this.collection.query(i);case 8:return u=e.sent,e.next=11,u.fetch({});case 11:return l=e.sent,e.abrupt("return",Promise.all(l.map((function(e){return b(d,void 0,void 0,t().mark((function n(){return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,this._deserializeWithMessageCreateParams(e);case 2:return t.abrupt("return",t.sent);case 3:case"end":return t.stop()}}),n,this)})))}))));case 13:return e.abrupt("return",[]);case 14:case"end":return e.stop()}}),e,this)})))}},{key:"getAllChildMessages",value:function(e){var n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:new Eo;return b(this,void 0,void 0,t().mark((function r(){return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,this.fetch({filter:n,order:ko.NEWEST_CHILD_MESSAGE,channelUrl:e.channelUrl,backward:!1,parentMessageId:e.messageId});case 2:return t.abrupt("return",t.sent);case 3:case"end":return t.stop()}}),r,this)})))}},{key:"upsert",value:function(e){return b(this,void 0,void 0,t().mark((function n(){var r=this;return t().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:if(!this.localCacheEnabled){n.next=3;break}return n.next=3,Promise.all(e.map((function(e){return b(r,void 0,void 0,t().mark((function n(){var r;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(!(e instanceof Bs||e instanceof js)){t.next=7;break}return t.next=3,this._mutex.lock();case 3:return t.next=5,this.saveBlob(e);case 5:return t.next=7,this._mutex.unlock();case 7:return r=this._serialize(e),t.next=10,this.collection.upsertOne(r);case 10:case"end":return t.stop()}}),n,this)})))})));case 3:case"end":return n.stop()}}),n,this)})))}},{key:"upsertChildMessages",value:function(e){return b(this,void 0,void 0,t().mark((function n(){var r=this;return t().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:if(!this.localCacheEnabled){n.next=3;break}return n.next=3,Promise.all(e.map((function(e){return b(r,void 0,void 0,t().mark((function n(){var r,a;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(a=[],!((null===(r=e.threadInfo)||void 0===r?void 0:r.replyCount)>0)){t.next=5;break}return t.next=4,this.getAllChildMessages(e);case 4:a=t.sent;case 5:if(!(a.length>0)){t.next=9;break}return a.forEach((function(t){return t.applyParentMessage(e)})),t.next=9,this.upsert(a);case 9:case"end":return t.stop()}}),n,this)})))})));case 3:case"end":return n.stop()}}),n,this)})))}},{key:"remove",value:function(e){return b(this,void 0,void 0,t().mark((function n(){var r,a,s;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(!this.localCacheEnabled){t.next=18;break}r=y(e),t.prev=2,r.s();case 4:if((a=r.n()).done){t.next=10;break}return s=a.value,t.next=8,this.collection.remove(s);case 8:t.next=4;break;case 10:t.next=15;break;case 12:t.prev=12,t.t0=t.catch(2),r.e(t.t0);case 15:return t.prev=15,r.f(),t.finish(15);case 18:case"end":return t.stop()}}),n,this,[[2,12,15,18]])})))}},{key:"removeMessagesOfChannel",value:function(e){return b(this,void 0,void 0,t().mark((function n(){return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(!this.localCacheEnabled){t.next=3;break}return t.next=3,this.collection.removeIf({where:{channelUrl:e}});case 3:case"end":return t.stop()}}),n,this)})))}},{key:"clear",value:function(){return b(this,void 0,void 0,t().mark((function e(){return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!this.localCacheEnabled){e.next=3;break}return e.next=3,this.collection.clear();case 3:case"end":return e.stop()}}),e,this)})))}},{key:"saveBlob",value:function(e){return b(this,void 0,void 0,t().mark((function n(){var r,a,s,i,o,u=this;return t().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:if(!(e instanceof Bs)){n.next=19;break}if(!e.messageParams){n.next=9;break}if(!(r=e.messageParams).file||!Uo(r.file)){n.next=9;break}return n.next=6,this.collection.saveBlob(r.file,e.reqId);case 6:a=n.sent,r.fileKey=a,r.fileType=wo.BLOB;case 9:if(!e.scheduledInfo||!e.scheduledInfo.scheduledMessageParams){n.next=17;break}if(!(s=e.scheduledInfo.scheduledMessageParams).file||!Uo(s.file)){n.next=17;break}return n.next=14,this.collection.saveBlob(s.file,e.reqId);case 14:i=n.sent,s.fileKey=i,s.fileType=wo.BLOB;case 17:n.next=24;break;case 19:if(!(e instanceof js)){n.next=24;break}if(!((o=e.messageParams)&&o.fileInfoList&&Array.isArray(o.fileInfoList))){n.next=24;break}return n.next=24,Promise.all(o.fileInfoList.map((function(n,r){return b(u,void 0,void 0,t().mark((function a(){var s,i;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(!(s=n.file)||!Uo(s)){t.next=8;break}return t.next=4,this.collection.saveBlob(s,this._getFileInfoBlobKey(e.reqId,r));case 4:i=t.sent,n._uploadedMetaData||(n._uploadedMetaData={}),n._uploadedMetaData.fileKey=i,n._uploadedMetaData.fileType=wo.BLOB;case 8:case"end":return t.stop()}}),a,this)})))})));case 24:case"end":return n.stop()}}),n,this)})))}}],[{key:"of",value:function(e){return Yo[e]}}]),a}(qa),Jo=function(n,r){return function(a,s){if(1===a)n.clear().then((function(){r.clear().then((function(){(function(n){return b(void 0,void 0,void 0,t().mark((function r(){return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.abrupt("return",n.commitSchema([{collectionName:mo,keyName:"url",index:[bo(e.GroupChannelListOrder.LATEST_LAST_MESSAGE),bo(e.GroupChannelListOrder.CHRONOLOGICAL),bo(e.GroupChannelListOrder.CHANNEL_NAME_ALPHABETICAL)]},{collectionName:yo,keyName:"messageId",index:[xo(ko.CHANNEL_LATEST),xo(ko.NEWEST_CHILD_MESSAGE)]},{collectionName:Wo,keyName:"reqId",index:[xo(ko.CHANNEL_LATEST),xo(ko.NEWEST_CHILD_MESSAGE)]},{collectionName:"Poll",keyName:"pollId"}]));case 1:case"end":return t.stop()}}),r)})))})(n).then((function(){return s()})).catch((function(e){return s(e)}))})).catch((function(e){return s(e)}))})).catch((function(e){return s(e)}));else s()}},Xo={},$o=function(e){i(a,e);var n=f(a);function a(e,t){var s,i=t.sdkState,o=t.cacheContext,u=t.unsentMessageCache;return r(this,a),(s=n.call(this,e))._sdkState=i,s._cacheContext=o,s._unsentMessageCache=u,Xo[e]=d(s),s}return s(a,[{key:"collection",get:function(){var e=this._cacheContext.nestdb;return e?e.collection(yo):null}},{key:"localCacheEnabled",get:function(){return this._cacheContext.localCacheEnabled&&!!this.collection}},{key:"_serialize",value:function(e){return Object.assign(Object.assign({},e.serialize()),{messageId:"".concat(e.messageId)})}},{key:"_deserialize",value:function(e){return e=Object.assign(Object.assign({},e),{messageId:parseInt(e.messageId)}),Ei.of(this._iid).buildMessageFromSerializedData(e)}},{key:"get",value:function(e){return b(this,void 0,void 0,t().mark((function n(){var r;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(!this.localCacheEnabled){t.next=6;break}return t.next=3,this.collection.getByKey("".concat(e));case 3:if(!(r=t.sent)){t.next=6;break}return t.abrupt("return",this._deserialize(r));case 6:return t.abrupt("return",null);case 7:case"end":return t.stop()}}),n,this)})))}},{key:"fetch",value:function(e){var n=e.channelUrl,r=e.token,a=e.limit,s=void 0===a?go:a,i=e.filter,o=void 0===i?new Eo:i,u=e.order,c=void 0===u?ko.CHANNEL_LATEST:u,l=e.backward,h=void 0!==l&&l,d=e.parentMessageId,f=void 0===d?null:d,p=e.isPollOnly,v=void 0!==p&&p;return b(this,void 0,void 0,t().mark((function e(){var a,i,u,l,d=this;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!this.localCacheEnabled){e.next=10;break}return a=xo(c),i={where:{channelUrl:n,"/where":function(e){if(r)switch(c){case ko.CHANNEL_LATEST:if(!h&&e.createdAt>r||h&&e.createdAt1&&void 0!==arguments[1]?arguments[1]:new Eo;return b(this,void 0,void 0,t().mark((function r(){return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,this.fetch({channelUrl:e.channelUrl,token:Date.now(),limit:null,backward:!1,filter:n,order:ko.NEWEST_CHILD_MESSAGE,parentMessageId:e.messageId});case 2:return t.abrupt("return",t.sent);case 3:case"end":return t.stop()}}),r,this)})))}},{key:"upsert",value:function(e){return b(this,void 0,void 0,t().mark((function n(){var r,a=this;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(!this.localCacheEnabled){t.next=10;break}return t.next=3,this.saveBlobs(e);case 3:return r=e.map((function(e){return a._serialize(e)})),t.next=6,this.collection.upsertMany(r);case 6:return t.next=8,this.upsertChildMessages(e);case 8:return t.next=10,this._unsentMessageCache.upsertChildMessages(e);case 10:case"end":return t.stop()}}),n,this)})))}},{key:"upsertChildMessages",value:function(e){return b(this,void 0,void 0,t().mark((function n(){var r=this;return t().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:if(!this.localCacheEnabled){n.next=3;break}return n.next=3,Promise.all(e.map((function(e){return b(r,void 0,void 0,t().mark((function n(){var r,a;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(a=[],!((null===(r=e.threadInfo)||void 0===r?void 0:r.replyCount)>0)){t.next=5;break}return t.next=4,this.getAllChildMessages(e);case 4:a=t.sent;case 5:if(!(a.length>0)){t.next=9;break}return a.forEach((function(t){return t.applyParentMessage(e)})),t.next=9,this.upsert(a);case 9:case"end":return t.stop()}}),n,this)})))})));case 3:case"end":return n.stop()}}),n,this)})))}},{key:"remove",value:function(e){return b(this,void 0,void 0,t().mark((function n(){var r,a,s;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(!this.localCacheEnabled){t.next=18;break}r=y(e),t.prev=2,r.s();case 4:if((a=r.n()).done){t.next=10;break}return s=a.value,t.next=8,this.collection.remove("".concat(s));case 8:t.next=4;break;case 10:t.next=15;break;case 12:t.prev=12,t.t0=t.catch(2),r.e(t.t0);case 15:return t.prev=15,r.f(),t.finish(15);case 18:case"end":return t.stop()}}),n,this,[[2,12,15,18]])})))}},{key:"removeMessagesOfChannel",value:function(e){return b(this,void 0,void 0,t().mark((function n(){var r;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(!this.localCacheEnabled){t.next=12;break}return t.next=3,this.collection.removeIf({where:{channelUrl:e},index:xo(ko.CHANNEL_LATEST)});case 3:return r=this._cacheContext.preference,t.next=6,r.remove("sendbird:".concat(this._sdkState.userId,"@groupchannel/").concat(e,"/message/sync"));case 6:return t.next=8,r.remove("sendbird:".concat(this._sdkState.userId,"@groupchannel/").concat(e,"/message/sync.meta"));case 8:return t.next=10,r.remove("sendbird:".concat(this._sdkState.userId,"@groupchannel/").concat(e,"/message/changelogs"));case 10:return t.next=12,r.remove("sendbird:".concat(this._sdkState.userId,"@groupchannel/").concat(e,"/message/changelogs.meta"));case 12:case"end":return t.stop()}}),n,this)})))}},{key:"removeUnderOffset",value:function(e,n){return b(this,void 0,void 0,t().mark((function r(){return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(!this.localCacheEnabled){t.next=3;break}return t.next=3,this.collection.removeIf({where:{channelUrl:e,createdAt:{"<":n}},index:xo(ko.CHANNEL_LATEST)});case 3:case"end":return t.stop()}}),r,this)})))}},{key:"clear",value:function(){return b(this,void 0,void 0,t().mark((function e(){return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!this.localCacheEnabled){e.next=3;break}return e.next=3,this.collection.clear();case 3:case"end":return e.stop()}}),e,this)})))}},{key:"countBetween",value:function(e,n,r){return b(this,void 0,void 0,t().mark((function a(){var s,i,o=this;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(!this.localCacheEnabled){t.next=6;break}return s=xo(ko.CHANNEL_LATEST),i=this.collection.query({where:{channelUrl:e,"/where":function(e){var t=o._deserialize(e);return r.includes(t.createdAt)&&n.match(t)}},index:s}),t.next=5,i.count();case 5:return t.abrupt("return",t.sent);case 6:return t.abrupt("return",0);case 7:case"end":return t.stop()}}),a,this)})))}},{key:"saveBlobs",value:function(e){return b(this,void 0,void 0,t().mark((function n(){var r=this;return t().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return n.next=2,Promise.all(e.map((function(e){return b(r,void 0,void 0,t().mark((function n(){var r,a;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(!(e instanceof Bs&&e.messageParams)){t.next=7;break}if(!(r=e.messageParams).file||!Uo(r.file)){t.next=7;break}return t.next=5,this.collection.saveBlob(r.file,e.reqId);case 5:a=t.sent,r.fileKey=a;case 7:case"end":return t.stop()}}),n,this)})))})));case 2:case"end":return n.stop()}}),n)})))}},{key:"_getGroupChannelPreferenceSize",value:function(e){return b(this,void 0,void 0,t().mark((function n(){var r,a,s,i,o,u;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return r=0,a=this._cacheContext.preference,t.next=4,a.get("sendbird:".concat(this._sdkState.userId,"@groupchannel/").concat(e,"/message/sync"));case 4:return s=t.sent,t.next=7,a.get("sendbird:".concat(this._sdkState.userId,"@groupchannel/").concat(e,"/message/sync.meta"));case 7:return i=t.sent,t.next=10,a.get("sendbird:".concat(this._sdkState.userId,"@groupchannel/").concat(e,"/message/changelogs"));case 10:return o=t.sent,t.next=13,a.get("sendbird:".concat(this._sdkState.userId,"@groupchannel/").concat(e,"/message/changelogs.meta"));case 13:return u=t.sent,s&&(r+=JSON.stringify(s).length),i&&(r+=JSON.stringify(i).length),o&&(r+=JSON.stringify(o).length),u&&(r+=JSON.stringify(u).length),t.abrupt("return",r);case 19:case"end":return t.stop()}}),n,this)})))}}],[{key:"of",value:function(e){return Xo[e]}}]),a}(qa),eu=function(){return"undefined"!=typeof document?document.visibilityState:"visible"},tu=function(e){i(n,e);var t=f(n);function n(e){var a,s=e.getVisibilityState,i=void 0===s?eu:s,o=e.initialState,u=void 0===o?"visible":o,c=e.isEnabled,l=void 0===c||c,h=e.pauseCheckDelay,f=void 0===h?3e4:h;return r(this,n),(a=t.call(this))._pauseCheckDelay=3e4,a._pauseDelayTimer=null,a._currentState="visible",a._getVisibilityState=i,a._pauseCheckDelay=f,a._currentState=u,a._isEnabled=l,a._boundToggleState=a._toggleState.bind(d(a)),a}return s(n,[{key:"currentState",get:function(){return this._currentState}},{key:"isAvailable",get:function(){return"undefined"!=typeof window&&!!window.addEventListener&&!!window.removeEventListener}},{key:"_toggleState",value:function(){var e=this,t=this._getVisibilityState();"hidden"!==t?"hidden"===this._currentState&&(this._pauseDelayTimer&&(clearTimeout(this._pauseDelayTimer),this._pauseDelayTimer=null),this.dispatch("resume")):"hidden"!==this._currentState&&(this._pauseDelayTimer=setTimeout((function(){e._pauseDelayTimer=null,e.dispatch("pause")}),this._pauseCheckDelay)),this._currentState=t}},{key:"start",value:function(){this._isEnabled&&this.isAvailable&&(this._boundToggleState=this._toggleState.bind(this),window.addEventListener("visibilitychange",this._boundToggleState,{capture:!0}))}},{key:"stop",value:function(){this._isEnabled&&this.isAvailable&&this._boundToggleState&&window.removeEventListener("visibilitychange",this._boundToggleState,{capture:!0})}}]),n}(se),nu=function(){function e(t){var n=this,a=t.logger,s=t.connectionDelegate,i=void 0===s?null:s;r(this,e),this._onlineWorker=function(){var e;return null===(e=n.connectionDelegate)||void 0===e?void 0:e.reconnect()},this._offlineWorker=function(){var e;return null===(e=n.connectionDelegate)||void 0===e?void 0:e.disconnect()},this.unsubscribes=[],this._onlineListener=function(e){if(n.isAvailableOnWeb)return window.addEventListener("online",e),function(){return window.removeEventListener("online",e,!1)}},this._offlineListener=function(e){if(n.isAvailableOnWeb)return window.addEventListener("offline",e),function(){return window.removeEventListener("offline",e,!1)}},this.logger=a,i&&(this.connectionDelegate=i)}return s(e,[{key:"isAvailableOnWeb",get:function(){return"undefined"!=typeof window&&window.addEventListener&&"ononline"in window&&"onoffline"in window&&"undefined"!=typeof navigator&&void 0!==navigator.onLine}},{key:"setOnlineListener",value:function(e){Boolean(e)&&"function"==typeof e&&(this._onlineListener=e)}},{key:"setOfflineListener",value:function(e){Boolean(e)&&"function"==typeof e&&(this._offlineListener=e)}},{key:"start",value:function(){this.unsubscribes=[this._onlineListener(this._onlineWorker),this._offlineListener(this._offlineWorker)]}},{key:"stop",value:function(){var e=this;this.unsubscribes.forEach((function(t){try{null==t||t()}catch(t){e.logger.warn(t.message)}})),this.unsubscribes=[]}},{key:"isOnline",value:function(){return b(this,void 0,void 0,t().mark((function e(){return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!this.isAvailableOnWeb){e.next=4;break}return e.abrupt("return",navigator.onLine);case 4:return e.abrupt("return",new Promise((function(e){fetch("https://www.google.com",{method:ce.GET,mode:"no-cors"}).then((function(){return e(!0)})).catch((function(){return e(!1)}))})));case 5:case"end":return e.stop()}}),e,this)})))}}]),e}(),ru=function(e){i(n,e);var t=f(n);function n(e){var a,s=e.message;return r(this,n),(a=t.call(this)).message=s,a}return s(n)}(oe),au={},su=function(){function n(e,t){var a=this,s=t.localCacheEnabled,i=t.dispatcher,o=t.sdkState,u=t.logger;r(this,n),this._iid=e,au[e]=this,this._localCacheEnabled=s,this._isProcessingAutoResend=!1,this._autoResendQueue=[],this._dispatcher=i,this._logger=u,this._sdkState=o,this._localCacheEnabled&&i.on((function(e){if(e instanceof ha)switch(e.stateType){case aa.CONNECTED:a._isProcessingAutoResend||a.processAutoResendRegisteredPendingMessages().then((function(){return a._processNextAutoResend()}));break;case aa.INTERNAL_DISCONNECTED:case aa.EXTERNAL_DISCONNECTED:a._isProcessingAutoResend=!1}}))}return s(n,[{key:"processNonAutoResendRegisteredPendingMessages",value:function(){return b(this,void 0,void 0,t().mark((function n(){var r,a,s,i;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,this._fetchAllCachedPendingMessages();case 2:r=t.sent,a=y(r);try{for(a.s();!(s=a.n()).done;)0===(i=s.value).errorCode&&(this._logger.debug("cached pending message is not auto-resend registered. changing its sending status to failed: ",i.reqId),i.sendingStatus=e.SendingStatus.FAILED,i.errorCode=E.ACK_TIMEOUT,this._dispatcher.dispatch(new oi({messages:[i],source:e.MessageEventSource.LOCAL_MESSAGE_FAILED})))}catch(e){a.e(e)}finally{a.f()}case 5:case"end":return t.stop()}}),n,this)})))}},{key:"processAutoResendRegisteredPendingMessages",value:function(){return b(this,void 0,void 0,t().mark((function n(){var r,a,s,i,o,u;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,this._fetchAllCachedPendingMessages();case 2:r=t.sent,a=y(r);try{for(a.s();!(s=a.n()).done;)(i=s.value).errorCode&&G(i.errorCode)&&(o=(new Date).getTime(),u=i.createdAt+2592e5,o<=u?this._autoResendQueue.map((function(e){return e.reqId})).indexOf(i.reqId)<0&&this._autoResendQueue.push(i):(this._logger.debug("auto-resend registered pending messaged expired. expiration date: ",new Date(u).toLocaleString()),i.sendingStatus=e.SendingStatus.FAILED,this._dispatcher.dispatch(new oi({messages:[i],source:e.MessageEventSource.LOCAL_MESSAGE_FAILED}))))}catch(e){a.e(e)}finally{a.f()}case 5:case"end":return t.stop()}}),n,this)})))}},{key:"completeCurrentAndProcessNextAutoResend",value:function(t){if(this._localCacheEnabled&&(t.sendingStatus===e.SendingStatus.SUCCEEDED||t.sendingStatus===e.SendingStatus.FAILED&&!G(t.errorCode))){var n=this.indexOf(t);n>=0&&this._autoResendQueue.splice(n,1),0===n&&this._processNextAutoResend()}}},{key:"_fetchAllCachedPendingMessages",value:function(){return b(this,void 0,void 0,t().mark((function n(){var r;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(!(r=Zo.of(this._iid))){t.next=7;break}return t.next=4,r.fetch({sendingStatus:e.SendingStatus.PENDING,backward:!0});case 4:t.t0=t.sent,t.next=8;break;case 7:t.t0=[];case 8:return t.abrupt("return",t.t0);case 9:case"end":return t.stop()}}),n,this)})))}},{key:"indexOf",value:function(e){return this._autoResendQueue.length>0?this._autoResendQueue.map((function(e){return e.reqId})).indexOf(e.reqId):-1}},{key:"_isNotInQueue",value:function(e){return-1===this._autoResendQueue.map((function(e){return e.reqId})).indexOf(e.reqId)}},{key:"_processNextAutoResend",value:function(){return b(this,void 0,void 0,t().mark((function e(){var n;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(this._localCacheEnabled&&"foreground"===this._sdkState.appState)try{this._autoResendQueue.length>0?(this._isProcessingAutoResend||(this._logger.debug("auto-resend queue started."),this._isProcessingAutoResend=!0),n=this._autoResendQueue[0],this._dispatcher.dispatch(new ru({message:n})),this._logger.debug("processing auto-resend for message request id: ",n.reqId)):(this._logger.debug("auto-resend queue finished."),this._isProcessingAutoResend=!1)}catch(e){this._logger.warn("process auto-resend error: ",e),this._isProcessingAutoResend=!1}case 1:case"end":return e.stop()}}),e,this)})))}}],[{key:"of",value:function(e){return au[e]}}]),n}();!function(e){e[e.USER_BLOCK=20001]="USER_BLOCK",e[e.USER_UNBLOCK=2e4]="USER_UNBLOCK",e[e.FRIEND_DISCOVERED=20900]="FRIEND_DISCOVERED"}(Ho||(Ho={}));var iu,ou=function(){function e(t){r(this,e),this.category=t.cat,this.data=t.data}return s(e,null,[{key:"getDataAsUserBlockEvent",value:function(e,t){var n=t.data,r=n.blocker,a=n.blockee;return{blocker:new Ja(e,r),blockee:new Ja(e,a)}}},{key:"getDataAsFriendDiscoveredEvent",value:function(e,t){var n=t.data.friend_discoveries;return{friendDiscoveries:Array.isArray(n)?n.map((function(t){return new Ja(e,t)})):[]}}}]),e}(),uu=function(e){i(n,e);var t=f(n);function n(e,a){var s,i=a.userId;return r(this,n),(s=t.call(this))._iid=e,s.userId=i,s}return s(n)}(oe);e.GroupChannelEventSource=void 0,(iu=e.GroupChannelEventSource||(e.GroupChannelEventSource={})).UNKNOWN="UNKNOWN",iu.EVENT_CHANNEL_CREATED="EVENT_CHANNEL_CREATED",iu.EVENT_CHANNEL_UPDATED="EVENT_CHANNEL_UPDATED",iu.EVENT_CHANNEL_DELETED="EVENT_CHANNEL_DELETED",iu.EVENT_CHANNEL_READ="EVENT_CHANNEL_READ",iu.EVENT_CHANNEL_DELIVERED="EVENT_CHANNEL_DELIVERED",iu.EVENT_CHANNEL_INVITED="EVENT_CHANNEL_INVITED",iu.EVENT_CHANNEL_JOINED="EVENT_CHANNEL_JOINED",iu.EVENT_CHANNEL_LEFT="EVENT_CHANNEL_LEFT",iu.EVENT_CHANNEL_ACCEPTED_INVITE="EVENT_CHANNEL_ACCEPTED_INVITE",iu.EVENT_CHANNEL_DECLINED_INVITE="EVENT_CHANNEL_DECLINED_INVITE",iu.EVENT_CHANNEL_OPERATOR_UPDATED="EVENT_CHANNEL_OPERATOR_UPDATED",iu.EVENT_CHANNEL_MUTED="EVENT_CHANNEL_MUTED",iu.EVENT_CHANNEL_UNMUTED="EVENT_CHANNEL_UNMUTED",iu.EVENT_CHANNEL_FROZEN="EVENT_CHANNEL_FROZEN",iu.EVENT_CHANNEL_UNFROZEN="EVENT_CHANNEL_UNFROZEN",iu.EVENT_CHANNEL_HIDDEN="EVENT_CHANNEL_HIDDEN",iu.EVENT_CHANNEL_UNHIDDEN="EVENT_CHANNEL_UNHIDDEN",iu.EVENT_CHANNEL_RESET_HISTORY="EVENT_CHANNEL_RESET_HISTORY",iu.EVENT_CHANNEL_TYPING_STATUS_UPDATE="EVENT_CHANNEL_TYPING_STATUS_UPDATE",iu.EVENT_CHANNEL_MEMBER_COUNT_UPDATED="EVENT_CHANNEL_MEMBER_COUNT_UPDATED",iu.EVENT_MESSAGE_SENT="EVENT_MESSAGE_SENT",iu.EVENT_MESSAGE_RECEIVED="EVENT_MESSAGE_RECEIVED",iu.EVENT_MESSAGE_UPDATED="EVENT_MESSAGE_UPDATED",iu.EVENT_PINNED_MESSAGE_UPDATED="EVENT_PINNED_MESSAGE_UPDATED",iu.REQUEST_CHANNEL="REQUEST_CHANNEL",iu.REQUEST_CHANNEL_CHANGELOGS="REQUEST_CHANNEL_CHANGELOGS",iu.REFRESH_CHANNEL="REFRESH_CHANNEL",iu.CHANNEL_LASTACCESSEDAT_UPDATED="CHANNEL_LASTACCESSEDAT_UPDATED",iu.SYNC_CHANNEL_BACKGROUND="SYNC_CHANNEL_BACKGROUND",iu.SYNC_CHANNEL_CHANGELOGS="SYNC_CHANNEL_CHANGELOGS";var cu,lu=function(t){return t.startsWith("EVENT_")||t===e.GroupChannelEventSource.SYNC_CHANNEL_CHANGELOGS||t===e.GroupChannelEventSource.REFRESH_CHANNEL},hu=function(e){i(n,e);var t=f(n);function n(e){var a,s=e.channels,i=e.source,o=e.data,u=void 0===o?null:o;return r(this,n),(a=t.call(this)).channels=s,a.source=i,a.data=u,a}return s(n)}(oe),du=function(e){i(n,e);var t=f(n);function n(e){var a,s=e.channelUrls,i=e.source;return r(this,n),(a=t.call(this)).channelUrls=s,a.source=i,a}return s(n)}(oe),fu=function(e){i(n,e);var t=f(n);function n(){return r(this,n),t.call(this)}return s(n)}(oe),pu=function(e){i(n,e);var t=f(n);function n(e,a,s){var i;return r(this,n),(i=t.call(this,e,"USEV",s)).event=new ou(s),i}return s(n)}(Ge),vu=function(e){i(n,e);var t=f(n);function n(e){var a,s=e.userId,i=e.nickname,o=void 0===i?null:i,u=e.profileUrl,c=void 0===u?null:u,l=e.profileImage,h=void 0===l?null:l,d=e.preferredLanguages,f=void 0===d?null:d;return r(this,n),(a=t.call(this)).method=ce.PUT,a.path="".concat(he,"/").concat(encodeURIComponent(s)),a.params=ue({nickname:o,profile_url:c,profile_file:h,preferred_languages:f}),a}return s(n)}(Ae),_u=function(e){i(n,e);var t=f(n);function n(e,a){var s;return r(this,n),(s=t.call(this,e,a)).user=null,s.user=new Ja(e,Object.assign({},a)),s}return s(n)}(Oe),mu=function(e){i(n,e);var t=f(n);function n(e){var a,s=e.userId,i=e.token;return r(this,n),(a=t.call(this)).method=ce.POST,a.path="".concat(he,"/").concat(encodeURIComponent(s),"/push/apns"),a.params={apns_device_token:i,always_push:!0},a}return s(n)}(Ae),gu=function(e){i(n,e);var t=f(n);function n(e){var a,s=e.userId,i=e.token;return r(this,n),(a=t.call(this)).method=ce.POST,a.path="".concat(he,"/").concat(encodeURIComponent(s),"/push/gcm"),a.params={gcm_reg_token:i,always_push:!0},a}return s(n)}(Ae),yu=function(e){i(n,e);var t=f(n);function n(e){var a,s=e.userId,i=e.token;return r(this,n),(a=t.call(this)).method=ce.DELETE,a.path="".concat(he,"/").concat(encodeURIComponent(s),"/push/apns/").concat(encodeURIComponent(i)),a}return s(n)}(Ae),ku=function(e){i(n,e);var t=f(n);function n(e){var a,s=e.userId,i=e.token;return r(this,n),(a=t.call(this)).method=ce.DELETE,a.path="".concat(he,"/").concat(encodeURIComponent(s),"/push/gcm/").concat(encodeURIComponent(i)),a}return s(n)}(Ae),bu=function(e){i(n,e);var t=f(n);function n(e){var a,s=e.userId;return r(this,n),(a=t.call(this)).method=ce.DELETE,a.path="".concat(he,"/").concat(encodeURIComponent(s),"/push/apns"),a}return s(n)}(Ae),Eu=function(e){i(n,e);var t=f(n);function n(e){var a,s=e.userId;return r(this,n),(a=t.call(this)).method=ce.DELETE,a.path="".concat(he,"/").concat(encodeURIComponent(s),"/push/gcm"),a}return s(n)}(Ae),wu=function(e){i(n,e);var t=f(n);function n(e){var a,s=e.userId,i=e.type,o=e.token,u=e.ts;return r(this,n),(a=t.call(this)).method=ce.GET,a.path="".concat(he,"/").concat(encodeURIComponent(s),"/push/").concat(encodeURIComponent(i),"/device_tokens"),a.params={created_ts:u,token:o},a}return s(n)}(Ae),xu=function(t){i(a,t);var n=f(a);function a(t,s){var i;return r(this,a),(i=n.call(this,t,s)).pushTokens={type:s.type?e.PushTokenType[s.type.toLowerCase()]:e.PushTokenType.UNKNOWN,deviceTokens:s.device_tokens,hasMore:s.has_more,token:s.token},i}return s(a)}(Oe),Cu=function(e){i(n,e);var t=f(n);function n(e){var a,s=e.userId;return r(this,n),(a=t.call(this)).method=ce.GET,a.path="".concat(he,"/").concat(encodeURIComponent(s),"/channel_invitation_preference"),a}return s(n)}(Ae),Tu=function(e){i(n,e);var t=f(n);function n(e,a){var s;return r(this,n),(s=t.call(this,e,a)).autoAccept=a.auto_accept,s}return s(n)}(Oe),Su=function(e){i(n,e);var t=f(n);function n(e){var a,s=e.userId,i=e.willAutoAccept;return r(this,n),(a=t.call(this)).method=ce.PUT,a.path="".concat(he,"/").concat(encodeURIComponent(s),"/channel_invitation_preference"),a.params={auto_accept:i},a}return s(n)}(Ae),Iu=function(e){i(n,e);var t=f(n);function n(e,a){var s;return r(this,n),(s=t.call(this,e,a)).autoAccept=a.auto_accept,s}return s(n)}(Oe),Nu=function(e){i(n,e);var t=f(n);function n(e){var a,s=e.userId;return r(this,n),(a=t.call(this)).method=ce.GET,a.path="".concat(he,"/").concat(encodeURIComponent(s),"/push_preference"),a}return s(n)}(Ae),Mu=function(e){i(n,e);var t=f(n);function n(e,a){var s;return r(this,n),(s=t.call(this,e,a)).preference={doNotDisturbOn:a.do_not_disturb,startHour:a.start_hour,startMin:a.start_min,endHour:a.end_hour,endMin:a.end_min,timezone:a.timezone},s}return s(n)}(Oe),Au=function(e){i(n,e);var t=f(n);function n(e){var a,s=e.userId,i=e.doNotDisturbOn,o=e.startHour,u=e.startMin,c=e.endHour,l=e.endMin,h=e.timezone;return r(this,n),(a=t.call(this)).method=ce.PUT,a.path="".concat(he,"/").concat(encodeURIComponent(s),"/push_preference"),a.params={do_not_disturb:i,start_hour:o,start_min:u,end_hour:c,end_min:l,timezone:h},a}return s(n)}(Ae),Ou=function(e){i(n,e);var t=f(n);function n(e,a){var s;return r(this,n),(s=t.call(this,e,a)).preference={doNotDisturbOn:a.do_not_disturb,startHour:a.start_hour,startMin:a.start_min,endHour:a.end_hour,endMin:a.end_min,timezone:a.timezone},s}return s(n)}(Oe),Uu=function(e){i(n,e);var t=f(n);function n(e){var a,s=e.userId;return r(this,n),(a=t.call(this)).method=ce.GET,a.path="".concat(he,"/").concat(encodeURIComponent(s),"/push_preference"),a}return s(n)}(Ae),Ru=function(e){i(n,e);var t=f(n);function n(e,a){var s;return r(this,n),(s=t.call(this,e,a)).snoozePeriod={isSnoozeOn:a.snooze_enabled},"number"==typeof a.snooze_start_ts&&(s.snoozePeriod.startTs=a.snooze_start_ts),"number"==typeof a.snooze_end_ts&&(s.snoozePeriod.endTs=a.snooze_end_ts),s}return s(n)}(Oe),Lu=function(e){i(n,e);var t=f(n);function n(e){var a,s=e.userId,i=e.snoozeOn,o=e.startTs,u=e.endTs;return r(this,n),(a=t.call(this)).method=ce.PUT,a.path="".concat(he,"/").concat(encodeURIComponent(s),"/push_preference"),a.params={snooze_enabled:i,snooze_start_ts:o,snooze_end_ts:u},a}return s(n)}(Ae),Du=function(e){i(n,e);var t=f(n);function n(e,a){var s;return r(this,n),(s=t.call(this,e,a)).snoozePeriod={isSnoozeOn:a.snooze_enabled},"number"==typeof a.snooze_start_ts&&(s.snoozePeriod.startTs=a.snooze_start_ts),"number"==typeof a.snooze_end_ts&&(s.snoozePeriod.endTs=a.snooze_end_ts),s}return s(n)}(Oe),Pu=function(e){i(n,e);var t=f(n);function n(e){var a,s=e.userId,i=e.blockedUserId;return r(this,n),(a=t.call(this)).method=ce.POST,a.path="".concat(he,"/").concat(encodeURIComponent(s),"/block"),a.params={target_id:i},a}return s(n)}(Ae),Fu=function(e){i(n,e);var t=f(n);function n(e){var a,s=e.userId,i=e.unblockedUserId;return r(this,n),(a=t.call(this)).method=ce.DELETE,a.path="".concat(he,"/").concat(encodeURIComponent(s),"/block/").concat(encodeURIComponent(i)),a}return s(n)}(Ae),Gu=function(e){i(n,e);var t=f(n);function n(e){var a,s=e.userId;return r(this,n),(a=t.call(this)).method=ce.GET,a.path="".concat(he,"/").concat(encodeURIComponent(s),"/push_preference"),a}return s(n)}(Ae),qu=function(e){i(n,e);var t=f(n);function n(e,a){var s;return r(this,n),(s=t.call(this,e,a)).pushTriggerOption=a.push_trigger_option,s}return s(n)}(Oe),Hu=function(e){i(n,e);var t=f(n);function n(e){var a,s=e.userId,i=e.pushTriggerOption;return r(this,n),(a=t.call(this)).method=ce.PUT,a.path="".concat(he,"/").concat(encodeURIComponent(s),"/push_preference"),a.params={push_trigger_option:i},a}return s(n)}(Ae),ju=function(e){i(n,e);var t=f(n);function n(e,a){var s;return r(this,n),(s=t.call(this,e,a)).pushTriggerOption=a.push_trigger_option,s}return s(n)}(Oe),zu=function(e){i(n,e);var t=f(n);function n(e){var a,s=e.userId;return r(this,n),(a=t.call(this)).method=ce.GET,a.path="".concat(he,"/").concat(encodeURIComponent(s),"/push/template"),a}return s(n)}(Ae),Vu=function(e){i(n,e);var t=f(n);function n(e,a){var s;return r(this,n),(s=t.call(this,e,a)).name=a.name,s}return s(n)}(Oe),Bu=function(e){i(n,e);var t=f(n);function n(e){var a,s=e.userId,i=e.templateName;return r(this,n),(a=t.call(this)).method=ce.PUT,a.path="".concat(he,"/").concat(encodeURIComponent(s),"/push/template"),a.params={name:i},a}return s(n)}(Ae),Qu=function(e){i(n,e);var t=f(n);function n(e,a){var s;return r(this,n),(s=t.call(this,e,a)).name=a.name,s}return s(n)}(Oe),Ku=function(e){i(n,e);var t=f(n);function n(e){var a,s=e.userId,i=e.token;return r(this,n),(a=t.call(this)).method=ce.GET,a.path="".concat(he,"/").concat(encodeURIComponent(s),"/friends/changelogs"),a.params={token:i},a}return s(n)}(Ae),Wu=function(e){i(n,e);var t=f(n);function n(e,a){var s;return r(this,n),(s=t.call(this,e,a)).changelogs={addedUsers:a.added.map((function(t){return new Ja(e,t)})),updatedUsers:a.updated.map((function(t){return new Ja(e,t)})),deletedUserIds:a.deleted,hasMore:a.has_more,token:a.next},s}return s(n)}(Oe),Yu=function(e){i(n,e);var t=f(n);function n(e){var a,s=e.userId,i=e.discoveries;return r(this,n),(a=t.call(this)).method=ce.PUT,a.path="".concat(he,"/").concat(encodeURIComponent(s),"/friend_discoveries"),a.params={friend_discoveries:i.map((function(e){return{friend_discovery_key:e.friendDiscoveryKey,friend_name:e.friendName}}))},a}return s(n)}(Ae),Zu=function(e){i(n,e);var t=f(n);function n(e,a){var s;return r(this,n),(s=t.call(this,e,a)).friendDiscoveryRequestId=a.friend_discovery_request_id,s}return s(n)}(Oe),Ju=function(e){i(n,e);var t=f(n);function n(e){var a,s=e.userId,i=e.discoveryKeys;return r(this,n),(a=t.call(this)).method=ce.DELETE,a.path="".concat(he,"/").concat(encodeURIComponent(s),"/friend_discoveries"),a.params={friend_discovery_keys:i},a}return s(n)}(Ae),Xu=function(e){i(n,e);var t=f(n);function n(e){var a,s=e.userId,i=e.userIds;return r(this,n),(a=t.call(this)).method=ce.POST,a.path="".concat(he,"/").concat(encodeURIComponent(s),"/friends"),a.params={user_ids:i},a}return s(n)}(Ae),$u=function(e){i(n,e);var t=f(n);function n(e,a){var s;return r(this,n),(s=t.call(this,e,a)).users=a.users.map((function(t){return new Ja(e,t)})),s}return s(n)}(Oe),ec=function(e){i(n,e);var t=f(n);function n(e){var a,s=e.userId,i=e.userIds;return r(this,n),(a=t.call(this)).method=ce.DELETE,a.path="".concat(he,"/").concat(encodeURIComponent(s),"/friends"),a.params={user_ids:i},a}return s(n)}(Ae),tc=function(e){i(n,e);var t=f(n);function n(e){var a,s=e.userId;return r(this,n),(a=t.call(this)).method=ce.GET,a.path="".concat(he,"/").concat(s,"/allow_friend_discovery"),a.params={},a}return s(n)}(Ae),nc=function(e){i(n,e);var t=f(n);function n(e,a){var s;return r(this,n),(s=t.call(this,e,a)).allowFriendDiscovery=a.allow_friend_discovery,s}return s(n)}(Oe),rc=function(e){i(n,e);var t=f(n);function n(e){var a,s=e.userId,i=e.allowFriendDiscovery;return r(this,n),(a=t.call(this)).method=ce.PUT,a.path="".concat(he,"/").concat(s,"/allow_friend_discovery"),a.params={allow_friend_discovery:i},a}return s(n)}(Ae),ac=s((function e(t){r(this,e),this.key=null,this.url=null,this.key=t.key,this.url=t.url})),sc=s((function e(t){var n,a,s;r(this,e),this.id=0,this.name=null,this.url=null,this.emojis=[],this.id=null!==(n=t.id)&&void 0!==n?n:0,this.name=null!==(a=t.name)&&void 0!==a?a:"",this.url=null!==(s=t.url)&&void 0!==s?s:"",this.emojis=t.emojis?t.emojis.map((function(e){return new ac(e)})):[]})),ic=s((function e(t){r(this,e),this.emojiHash=null,this.emojiCategories=[],this.emojiHash=t.emoji_hash||"",this.emojiCategories=t.emoji_categories?t.emoji_categories.map((function(e){return new sc(e)})):[]})),oc=function(e){i(n,e);var t=f(n);function n(){var e;return r(this,n),(e=t.call(this)).method=ce.GET,e.path=ke,e}return s(n)}(Ae),uc=function(e){i(n,e);var t=f(n);function n(e,a){var s;return r(this,n),(s=t.call(this,e,a)).emojiContainer=new ic(a),s}return s(n)}(Oe),cc=function(e){i(n,e);var t=f(n);function n(e){var a,s=e.categoryId;return r(this,n),(a=t.call(this)).method=ce.GET,a.path="".concat(ke,"/").concat(s),a}return s(n)}(Ae),lc=function(e){i(n,e);var t=f(n);function n(e,a){var s;return r(this,n),(s=t.call(this,e,a)).emojiCategory=new sc(a),s}return s(n)}(Oe),hc=function(e){i(n,e);var t=f(n);function n(e){var a,s=e.key;return r(this,n),(a=t.call(this)).method=ce.GET,a.path="".concat(ye,"/").concat(s),a}return s(n)}(Ae),dc=function(e){i(n,e);var t=f(n);function n(e,a){var s;return r(this,n),(s=t.call(this,e,a)).emoji=new ac(a),s}return s(n)}(Oe),fc=function(e){i(n,e);var t=f(n);function n(){var e;return r(this,n),(e=t.call(this)).method=ce.GET,e.path="".concat(we),e}return s(n)}(Ae),pc=function(e){i(n,e);var t=f(n);function n(e,a){var s,i;r(this,n);var o=null!=a?a:{};return(s=t.call(this,e,a)).uikitConfiguration={string:JSON.stringify(o),json:o},s.updatedAt=null!==(i=null==a?void 0:a.updated_at)&&void 0!==i?i:0,s}return s(n)}(Oe),vc=function(e){i(n,e);var t=f(n);function n(e){var a,s=e.limit,i=e.token,o=e.userIdsFilter,u=e.metaDataKeyFilter,c=e.metaDataValuesFilter,l=e.nicknameStartsWithFilter;return r(this,n),(a=t.call(this)).method=ce.GET,a.path=he,a.params=ue({limit:s,token:i,user_ids:o,metadatakey:u,metadatavalues_in:c,nickname_startswith:l}),a}return s(n)}(Ae),_c=function(e){i(n,e);var t=f(n);function n(e,a){var s;return r(this,n),(s=t.call(this,e,a)).users=a.users.map((function(t){return new Ja(e,t)})),s.next=a.next,s}return s(n)}(Oe),mc=function(e){i(a,e);var n=f(a);function a(e,t){var s,i,o,u;return r(this,a),(s=n.call(this,e,t)).userIdsFilter=null,s.metaDataKeyFilter=null,s.metaDataValuesFilter=null,s.nicknameStartsWithFilter=null,s.userIdsFilter=null!==(i=t.userIdsFilter)&&void 0!==i?i:null,s.metaDataKeyFilter=null!==(o=t.metaDataKeyFilter)&&void 0!==o?o:null,s.metaDataValuesFilter=null!==(u=t.metaDataValuesFilter)&&void 0!==u?u:null,s.nicknameStartsWithFilter=t.nicknameStartsWithFilter||null,s}return s(a,[{key:"_validate",value:function(){return p(o(a.prototype),"_validate",this).call(this)&&F("string",this.userIdsFilter,!0)&&L("string",this.metaDataKeyFilter,!0)&&F("string",this.metaDataValuesFilter,!0)&&L("string",this.metaDataKeyFilter,!0)}},{key:"next",value:function(){return b(this,void 0,void 0,t().mark((function e(){var n,r,a,s,i,o,u;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!this._validate()){e.next=20;break}if(this._isLoading){e.next=17;break}if(!this._hasNext){e.next=14;break}return this._isLoading=!0,n=ds.of(this._iid),r=n.requestQueue,a=new vc(Object.assign(Object.assign({},this),{token:this._token})),e.next=8,r.send(a);case 8:return s=e.sent,i=s.as(_c),o=i.users,u=i.next,this._token=u,this._hasNext=!!u,this._isLoading=!1,e.abrupt("return",o);case 14:return e.abrupt("return",[]);case 17:throw A.queryInProgress;case 18:e.next=21;break;case 20:throw A.invalidParameters;case 21:case"end":return e.stop()}}),e,this)})))}}]),a}(Si),gc=function(e){i(n,e);var t=f(n);function n(e){var a,s=e.userId,i=e.limit,o=e.token,u=e.userIdsFilter;return r(this,n),(a=t.call(this)).method=ce.GET,a.path="".concat(he,"/").concat(s,"/block"),a.params=ue({limit:i,token:o,user_ids:u}),a}return s(n)}(Ae),yc=function(e){i(n,e);var t=f(n);function n(e,a){var s;return r(this,n),(s=t.call(this,e,a)).users=a.users.map((function(t){return new Ja(e,t)})),s.next=a.next,s}return s(n)}(Oe),kc=function(e){i(a,e);var n=f(a);function a(e,t){var s,i;return r(this,a),(s=n.call(this,e,t)).userIdsFilter=null,s.userIdsFilter=null!==(i=t.userIdsFilter)&&void 0!==i?i:null,s}return s(a,[{key:"_validate",value:function(){return p(o(a.prototype),"_validate",this).call(this)&&F("string",this.userIdsFilter,!0)}},{key:"next",value:function(){return b(this,void 0,void 0,t().mark((function e(){var n,r,a,s,i,o,u,c;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!this._validate()){e.next=20;break}if(this._isLoading){e.next=17;break}if(!this._hasNext){e.next=14;break}return this._isLoading=!0,n=ds.of(this._iid),r=n.sdkState,a=n.requestQueue,s=new gc(Object.assign(Object.assign({},this),{userId:r.userId,token:this._token})),e.next=8,a.send(s);case 8:return i=e.sent,o=i.as(yc),u=o.users,c=o.next,this._token=c,this._hasNext=!!c,this._isLoading=!1,e.abrupt("return",u);case 14:return e.abrupt("return",[]);case 17:throw A.queryInProgress;case 18:e.next=21;break;case 20:throw A.invalidParameters;case 21:case"end":return e.stop()}}),e,this)})))}}]),a}(Si),bc=function(e){i(n,e);var t=f(n);function n(e){var a,s=e.userId,i=e.limit,o=e.token;return r(this,n),(a=t.call(this)).method=ce.GET,a.path="".concat(he,"/").concat(encodeURIComponent(s),"/friends"),a.params={limit:i,token:o},a}return s(n)}(Ae),Ec=function(e){i(n,e);var t=f(n);function n(e,a){var s;return r(this,n),(s=t.call(this,e,a)).hasMore=a.has_more,s.users=a.users.map((function(t){return new Ja(e,t)})),s.next=a.next,s}return s(n)}(Oe),wc=function(e){i(a,e);var n=f(a);function a(){return r(this,a),n.apply(this,arguments)}return s(a,[{key:"_validate",value:function(){return p(o(a.prototype),"_validate",this).call(this)}},{key:"next",value:function(){return b(this,void 0,void 0,t().mark((function e(){var n,r,a,s,i,o,u,c,l;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!this._validate()){e.next=20;break}if(this._isLoading){e.next=17;break}if(!this._hasNext){e.next=14;break}return this._isLoading=!0,n=ds.of(this._iid),r=n.sdkState,a=n.requestQueue,s=new bc(Object.assign(Object.assign({},this),{userId:r.userId,token:this._token})),e.next=8,a.send(s);case 8:return i=e.sent,o=i.as(Ec),u=o.users,c=o.hasMore,l=o.next,this._token=l,this._hasNext=c,this._isLoading=!1,e.abrupt("return",u);case 14:return e.abrupt("return",[]);case 17:throw A.queryInProgress;case 18:e.next=21;break;case 20:throw A.invalidParameters;case 21:case"end":return e.stop()}}),e,this)})))}}]),a}(Si),xc={},Cc=function(){function e(t){var n=t.dbname,a=t.itemSizeLimit,s=void 0===a?1048576:a,i=t.cacheLimit,o=void 0===i?256:i,u=t.blockHashBase,c=void 0===u?2:u,l=t.blockHashMultiplier,h=void 0===l?10:l,d=t.blockHashConstant,f=void 0===d?11:d,p=t.transactionApplyDelay,v=void 0===p?200:p,_=t.disableLogger,m=void 0!==_&&_;return r(this,e),xc[n]||(this.itemSizeLimit=s,this.cacheLimit=o,this.blockHashBase=c,this.blockHashMultiplier=h,this.blockHashConstant=f,this.transactionApplyDelay=v,this.disableLogger=m,xc[n]=this),xc[n]}return s(e,null,[{key:"get",value:function(e){return xc[e]}}]),e}();!function(e){e[e.UNKNOWN_ERROR=6e7]="UNKNOWN_ERROR",e[e.STORE_NOT_DEFINED=61001e3]="STORE_NOT_DEFINED",e[e.STORE_NOT_AVAILABLE=61001001]="STORE_NOT_AVAILABLE",e[e.STORE_NOT_AVAILABLE_IN_PRIVATE_BROWSING=61001002]="STORE_NOT_AVAILABLE_IN_PRIVATE_BROWSING",e[e.STORE_IS_FULL=61001003]="STORE_IS_FULL",e[e.STORE_NOT_INITIALIZED=61001004]="STORE_NOT_INITIALIZED",e[e.STORE_INVALID_KEY_TYPE=61002e3]="STORE_INVALID_KEY_TYPE",e[e.STORE_BROKEN_INTEGRITY=61002001]="STORE_BROKEN_INTEGRITY",e[e.STORE_BROKEN_BLOB=61002002]="STORE_BROKEN_BLOB",e[e.STORE_ENCRYPTION_INVALID=61002003]="STORE_ENCRYPTION_INVALID",e[e.STORE_ITEM_SIZE_LIMIT_EXCEEDED=61017e3]="STORE_ITEM_SIZE_LIMIT_EXCEEDED",e[e.STORE_READ_FAILED=61017001]="STORE_READ_FAILED",e[e.STORE_WRITE_FAILED=61017002]="STORE_WRITE_FAILED",e[e.DATABASE_SCHEMA_NOT_ON_UPGRADE=62002e3]="DATABASE_SCHEMA_NOT_ON_UPGRADE",e[e.COLLECTION_NOT_READY=63001e3]="COLLECTION_NOT_READY",e[e.COLLECTION_KEY_NOT_MATCH=63002e3]="COLLECTION_KEY_NOT_MATCH",e[e.COLLECTION_QUERY_NOT_VALID=63002001]="COLLECTION_QUERY_NOT_VALID",e[e.COLLECTION_KEY_NOT_FOUND=63004e3]="COLLECTION_KEY_NOT_FOUND",e[e.COLLECTION_KEY_NOT_GIVEN=63004001]="COLLECTION_KEY_NOT_GIVEN",e[e.COLLECTION_INSERT_DUPLICATE=63009e3]="COLLECTION_INSERT_DUPLICATE",e[e.COLLECTION_WRITE_FAILED=63017e3]="COLLECTION_WRITE_FAILED",e[e.COLLECTION_ITEM_SIZE_LIMIT_EXCEEDED=63017001]="COLLECTION_ITEM_SIZE_LIMIT_EXCEEDED",e[e.INDEX_TABLE_IS_REQUIRED=65001e3]="INDEX_TABLE_IS_REQUIRED",e[e.INDEX_TYPE_NOT_MATCH=65002e3]="INDEX_TYPE_NOT_MATCH",e[e.COMPARE_TYPE_NOT_MATCH=69002001]="COMPARE_TYPE_NOT_MATCH",e[e.CIRCULAR_REFERENCE_FOUND=69002002]="CIRCULAR_REFERENCE_FOUND"}(cu||(cu={}));var Tc,Sc=function(e){i(n,e);var t=f(n);function n(e){var a,s=e.code,i=void 0===s?cu.UNKNOWN_ERROR:s,o=e.message,u=void 0===o?"Unknown error occurred.":o;return r(this,n),(a=t.call(this,u)).code=i,Object.setPrototypeOf(d(a),n.prototype),a}return s(n,null,[{key:"storeNotDefined",get:function(){return new n({code:cu.STORE_NOT_DEFINED,message:"Store is not defined. Specify the store on NestDB()"})}},{key:"storeNotAvailable",get:function(){return new n({code:cu.STORE_NOT_AVAILABLE,message:"Store is not available. Check your environment settings."})}},{key:"storeNotAvailableInPrivateBrowsing",get:function(){return new n({code:cu.STORE_NOT_AVAILABLE_IN_PRIVATE_BROWSING,message:"Store is not available because it is in private browsing."})}},{key:"storeIsFull",get:function(){return new n({code:cu.STORE_IS_FULL,message:"Store is full."})}},{key:"storeNotInitialized",get:function(){return new n({code:cu.STORE_NOT_INITIALIZED,message:"Store is not initialized."})}},{key:"storeKeyTypeIsInvalid",get:function(){return new n({code:cu.STORE_INVALID_KEY_TYPE,message:"Store key should be string type."})}},{key:"storeBrokenIntegrity",get:function(){return new n({code:cu.STORE_BROKEN_INTEGRITY,message:"Data should be in a store but it does not. Integrity is broken."})}},{key:"storeBrokenBlob",get:function(){return new n({code:cu.STORE_BROKEN_BLOB,message:"Data should be in a store but it does not. Blob data is broken."})}},{key:"storeEncryptionInvalid",get:function(){return new n({code:cu.STORE_ENCRYPTION_INVALID,message:"Encryption algorithm has changed. All the store should reset."})}},{key:"storeItemSizeExceeded",get:function(){return new n({code:cu.STORE_ITEM_SIZE_LIMIT_EXCEEDED,message:"The size of the item exceeds the limit that the store allows."})}},{key:"storeReadFailed",get:function(){return new n({code:cu.STORE_READ_FAILED,message:"Failed to read from store."})}},{key:"storeWriteFailed",get:function(){return new n({code:cu.STORE_WRITE_FAILED,message:"Failed to write to store."})}},{key:"databaseSchemaNotOnUpgrade",get:function(){return new n({code:cu.DATABASE_SCHEMA_NOT_ON_UPGRADE,message:"Committing schema is not allowed when upgrade is not running."})}},{key:"collectionNotReady",get:function(){return new n({code:cu.COLLECTION_NOT_READY,message:"Collection is not ready due to an error during initialization."})}},{key:"collectionKeyNotMatch",get:function(){return new n({code:cu.COLLECTION_KEY_NOT_MATCH,message:"keyName of collection could not change."})}},{key:"collectionQueryNotValid",get:function(){return new n({code:cu.COLLECTION_QUERY_NOT_VALID,message:"Query parameter is not a valid format."})}},{key:"collectionInsertDuplicate",get:function(){return new n({code:cu.COLLECTION_INSERT_DUPLICATE,message:"The key already exists."})}},{key:"collectionKeyNotFound",get:function(){return new n({code:cu.COLLECTION_KEY_NOT_FOUND,message:"The key is not found."})}},{key:"collectionKeyNotGiven",get:function(){return new n({code:cu.COLLECTION_KEY_NOT_GIVEN,message:"The item should contain [keyName] property."})}},{key:"collectionWriteFailed",get:function(){return new n({code:cu.COLLECTION_WRITE_FAILED,message:"Failed to write an item."})}},{key:"collectionItemSizeExceeded",get:function(){return new n({code:cu.COLLECTION_ITEM_SIZE_LIMIT_EXCEEDED,message:"The size of the item exceeds the limit that a collection allows."})}},{key:"indexTableIsRequired",get:function(){return new n({code:cu.INDEX_TABLE_IS_REQUIRED,message:"Index table is required."})}},{key:"indexTypesNotMatch",get:function(){return new n({code:cu.INDEX_TYPE_NOT_MATCH,message:"Indexed column should have primitive type."})}},{key:"compareTypesNotMatch",get:function(){return new n({code:cu.COMPARE_TYPE_NOT_MATCH,message:"Values to compare have different types."})}},{key:"circularReferenceFound",get:function(){return new n({code:cu.CIRCULAR_REFERENCE_FOUND,message:"Cannot handle circular referenced object."})}}]),n}(h(Error));!function(e){e.INIT="init",e.READY="ready",e.CLOSED="closed"}(Tc||(Tc={}));var Ic,Nc=function e(t){var r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:new WeakMap;if("object"===n(t)&&null!==t){if(r.has(t))throw Sc.circularReferenceFound;var a;if(r.set(t,!0),Array.isArray(t))a=t.map((function(t){return e(t,r)}));else if(t instanceof RegExp)a=t;else if(t instanceof Date)a=t;else for(var s in a={},t)a[s]=e(t[s],r);return r.delete(t),a}return t},Mc=function(e,t){if(null==t)return 1;if(null==e)return-1;if(n(e)!==n(t))throw Sc.compareTypesNotMatch;var r=0;switch(n(e)){case"boolean":case"number":r=e-t;break;case"string":r=e.localeCompare(t)}return r},Ac=function(e,t){for(var n=0,r=0;r>>0)%t},Oc=function(e){return new Promise((function(t){setTimeout((function(){return t()}),e)}))},Uc=function e(t,r){if(!r)return!1;if("function"!=typeof t){for(var a in t){if(["/and","&&"].includes(a)){if(t[a].some((function(t){return!e(t,r)})))return!1}else if(["/or","||"].includes(a)){if(t[a].every((function(t){return!e(t,r)})))return!1}else if("/where"===a){if(!(0,t[a])(r))return!1}else{var s=a;if("object"===n(t[s])){var i=t[s];for(var o in i)switch(o){case"/eq":case"=":if(r[s]!==i[o])return!1;break;case"/neq":case"!=":if(r[s]===i[o])return!1;break;case"/gt":case">":var u=r[s],c=i[o];if(!(Mc(u,c)>0))return!1;break;case"/gte":case">=":var l=r[s],h=i[o];if(!(Mc(l,h)>=0))return!1;break;case"/lt":case"<":var d=r[s],f=i[o];if(!(Mc(d,f)<0))return!1;break;case"/lte":case"<=":var p=r[s],v=i[o];if(!(Mc(p,v)<=0))return!1;break;case"/in":var _=r[s];if(!i[o].includes(_))return!1;break;case"/nin":var m=r[s];if(i[o].includes(m))return!1;break;case"/contain":var g=r[s],y=i[o];if(!g.includes(y))return!1;break;case"/regex":var k=r[s];if(!i[o].test(k))return!1;break;case"/where":var b=r[s];if(!(0,i[o])(b))return!1}}else if("function"==typeof t[s]){if(!t[s](r[s]))return!1}else if(t[s]!==r[s])return!1}}return!0}return t(r)},Rc=function(){},Lc=function(){return Promise.resolve()},Dc=function(e){return e},Pc=function(e,t){t()};!function(e){e[e.FORWARD=0]="FORWARD",e[e.BACKWARD=1]="BACKWARD"}(Ic||(Ic={}));var Fc,Gc,qc,Hc=function(){function e(t){var n=t.initialPrevValue,a=void 0===n?null:n,s=t.initialNextValue,i=void 0===s?null:s,o=t.iterator,u=t.map,c=void 0===u?Dc:u,l=t.backward,h=void 0===l?Lc:l,d=t.forward,f=void 0===d?Lc:d,p=t.complete,v=void 0===p?Rc:p;r(this,e),this._prevValue=a,this._nextValue=i,this._error=null,this._map=c,this._backward=h,this._forward=f,this._iterator=o,this._complete=v}return s(e,[{key:"prevValue",get:function(){return this._map(this._prevValue)}},{key:"nextValue",get:function(){return this._map(this._nextValue)}},{key:"error",get:function(){return this._error}},{key:"hasPrevious",get:function(){return!!this._prevValue}},{key:"hasNext",get:function(){return!!this._nextValue}},{key:"prev",value:function(){return b(this,void 0,void 0,t().mark((function e(){var n;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!this.hasPrevious){e.next=20;break}return e.prev=1,n=this._prevValue,e.next=5,this._backward();case 5:if(e.t0=e.sent,e.t0){e.next=8;break}e.t0=null;case 8:this._prevValue=e.t0,this._nextValue=n,e.next=15;break;case 12:e.prev=12,e.t1=e.catch(1),this._error=e.t1;case 15:return e.next=17,this._iterator(this);case 17:return e.abrupt("return",e.sent);case 20:this._complete();case 21:case"end":return e.stop()}}),e,this,[[1,12]])})))}},{key:"next",value:function(){return b(this,void 0,void 0,t().mark((function e(){var n;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!this.hasNext){e.next=20;break}return e.prev=1,n=this._nextValue,e.next=5,this._forward();case 5:if(e.t0=e.sent,e.t0){e.next=8;break}e.t0=null;case 8:this._nextValue=e.t0,this._prevValue=n,e.next=15;break;case 12:e.prev=12,e.t1=e.catch(1),this._error=e.t1;case 15:return e.next=17,this._iterator(this);case 17:return e.abrupt("return",e.sent);case 20:this._complete();case 21:case"end":return e.stop()}}),e,this,[[1,12]])})))}},{key:"stop",value:function(){this._prevValue=null,this._nextValue=null,this._complete()}}]),e}(),jc=function(){function e(t){var n=t.condition,a=void 0===n?{}:n,s=t.backward,i=void 0!==s&&s,o=t.blockManager,u=t.indexer;r(this,e),this.condition=a,this.backward=i,this._blockManager=o,this._indexer=u}return s(e,[{key:"findOptimizedStartPosition",value:function(){var e=this,t=["=","/eq",">",">=","/gt","/gte"],r=["=","/eq","<","<=","/lt","/lte"];if(this.backward){var a=this._indexer.origin.length-1;if("function"!=typeof this.condition)for(var s in this._indexer.fields){var i=this._indexer.fields[s],o=1;if("-"===i[0]&&(i=i.slice(1),o=-1),this.condition[i])if("object"===n(this.condition[i])){var u=o>0?r:t;for(var c in this.condition[i])if(u.includes(c))for(var l=a;l>=0;l--)if(o*Mc(this._indexer.origin[l].columnValues[s],this.condition[i][c])<=0){a=l;break}}else for(var h=a;h>=0;h--)if(o*Mc(this._indexer.origin[h].columnValues[s],this.condition[i])<=0){a=h;break}}return Math.min(a+1,this._indexer.origin.length-1)}var d=0;if("function"!=typeof this.condition)for(var f=function(a){var s=e._indexer.fields[a],i=1;if("-"===s[0]&&(s=s.slice(1),i=-1),e.condition[s])if("object"===n(e.condition[s]))Object.keys(e.condition[s]).forEach((function(n){if((i>0?t:r).includes(n))for(var o=d;o=0){d=o;break}}));else for(var o=d;o=0){d=o;break}},p=0;p0&&void 0!==arguments[0]?arguments[0]:{};return b(this,void 0,void 0,t().mark((function n(){var r,a,s,i=this;return t().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:if(r=Math.max(e.offset||0,0),0!==(a="number"==typeof e.limit?e.limit:Number.MAX_SAFE_INTEGER)){n.next=6;break}return n.abrupt("return",[]);case 6:if(!(a<0)){n.next=8;break}throw Sc.collectionQueryNotValid;case 8:return n.prev=8,s=[],n.next=12,this._mutex.lock();case 12:return n.next=14,this._iterator.each((function(e){return b(i,void 0,void 0,t().mark((function n(){return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:e.error?e.stop():e.hasNext?0===r?(s.push(e.nextValue),03&&void 0!==arguments[3]?arguments[3]:0;return"".concat(Wc(e,t)).concat(n,".").concat(r)},Zc=function(){function e(t){var n=t.dbname,a=t.collectionName,s=t.store;r(this,e),this.dbname=n,this.collectionName=a,this.store=s}return s(e,[{key:"get",value:function(e){return b(this,void 0,void 0,t().mark((function n(){var r,a,s,i,o,u,c,l,h,d;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,this.store.get(e);case 2:if(!(r=t.sent)){t.next=19;break}if(a=r.data,s=r.type,"undefined"==typeof fetch){t.next=14;break}return t.next=8,fetch(a);case 8:return i=t.sent,t.next=11,i.blob();case 11:return t.abrupt("return",t.sent);case 14:for(512,o=[],u=atob(a.split(",")[1]),c=0;c1&&void 0!==arguments[1]?arguments[1]:"".concat(Date.now());return b(this,void 0,void 0,t().mark((function r(){var a,s,i,o,u=this;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,new Promise((function(t){var r=Yc(u.dbname,u.collectionName,n),a=new FileReader;a.onload=function(){t({blobId:r,data:a.result,type:e.type})},a.readAsDataURL(e)}));case 2:return a=t.sent,s=a.blobId,i=a.data,o=a.type,t.next=8,this.store.set({key:s,value:{data:i,type:o}});case 8:return t.abrupt("return",s);case 9:case"end":return t.stop()}}),r,this)})))}},{key:"remove",value:function(e){return b(this,void 0,void 0,t().mark((function n(){return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,this.store.remove(e);case 2:case"end":return t.stop()}}),n,this)})))}},{key:"clear",value:function(){return b(this,void 0,void 0,t().mark((function e(){var n,r,a=this;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n=Wc(this.dbname,this.collectionName),e.next=3,this.store.getAllKeys();case 3:return r=e.sent,e.next=6,Promise.all(r.filter((function(e){return e.startsWith(n)})).map((function(e){return b(a,void 0,void 0,t().mark((function n(){return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,this.store.remove(e);case 2:return t.abrupt("return",t.sent);case 3:case"end":return t.stop()}}),n,this)})))})));case 6:case"end":return e.stop()}}),e,this)})))}}]),e}();!function(e){e[e.COMMIT=0]="COMMIT",e[e.WRITE=1]="WRITE",e[e.ERROR=2]="ERROR"}(Fc||(Fc={})),function(e){e.PENDING="pending",e.PERSISTENT="persistent",e.VOLATILE="volatile"}(Gc||(Gc={})),function(e){e[e.NO_CACHE=0]="NO_CACHE",e[e.DEFAULT=1]="DEFAULT",e[e.PERSISTENT=2]="PERSISTENT"}(qc||(qc={}));var Jc,Xc=[Gc.PENDING,Gc.VOLATILE],$c={},el=function(){function e(t){var n=t.dbname,a=t.limit,s=void 0===a?256:a;return r(this,e),$c[n]||(this.dbname=n,this._items=[],this._limit=s,$c[n]=this),$c[n]}return s(e,[{key:"items",get:function(){return this._items}},{key:"find",value:function(e,n){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:qc.DEFAULT;return b(this,void 0,void 0,t().mark((function a(){var s,i;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(s=this.get(n)){t.next=8;break}return t.next=4,e.get(n);case 4:(i=t.sent)&&(s={key:n,value:i,state:r===qc.PERSISTENT?Gc.PERSISTENT:Gc.VOLATILE},this.put(s)),t.next=9;break;case 8:r===qc.PERSISTENT&&(s.state=Gc.PERSISTENT);case 9:return t.abrupt("return",s);case 10:case"end":return t.stop()}}),a,this)})))}},{key:"get",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:qc.DEFAULT,n=this._items.map((function(e){return e.key})).indexOf(e);if(n>-1){var r=this._items[n];return t===qc.PERSISTENT&&(r.state=Gc.PERSISTENT),t!==qc.NO_CACHE&&this.put(r),r}return null}},{key:"put",value:function(e){if(this._limit>0){var t=this._items.map((function(e){return e.key})).indexOf(e.key);if(t>-1)Xc.includes(this._items[t].state)&&Xc.includes(e.state)?(this._items.splice(t,1),this._items.push(e)):(this._items[t].state=e.state,this._items[t].value=e.value);else{this._items.push(e);var n=this._items.filter((function(e){return e.state===Gc.VOLATILE})),r=n.length-this._limit;if(r>0){var a,s=[],i=y(this._items);try{for(i.s();!(a=i.n()).done;){var o=a.value;o.state===Gc.VOLATILE&&r>0?r--:s.push(o)}}catch(e){i.e(e)}finally{i.f()}this._items=s}}}}},{key:"remove",value:function(e){var t=this._items.map((function(e){return e.key})).indexOf(e);t>-1&&this._items.splice(t,1)}},{key:"clearByCondition",value:function(e){this._items=this._items.filter((function(t){return!e(t)}))}},{key:"clear",value:function(){var e=arguments.length>0&&void 0!==arguments[0]&&arguments[0];this._items=e?[]:this._items.filter((function(e){return e.state!==Gc.VOLATILE}))}}],[{key:"get",value:function(e){return $c[e]}}]),e}(),tl=function(){function e(t){var n=t.dbname,a=t.collectionName,s=t.store;r(this,e),this._requests=[],this._onCommit=new Map,this._onWrite=new Map,this._onError=new Map,this.dbname=n,this.collectionName=a,this.metadataKey=function(e,t){return"".concat(Bc(e,t),"/trans.metadata")}(n,a),this.recordsetKey=function(e,t){return"".concat(Bc(e,t),"/trans.recordset")}(n,a),this._store=s}return s(e,[{key:"generation",get:function(){return this._metadata?this._metadata.generation:0}},{key:"requestCount",get:function(){return this._requests.length}},{key:"_getReducedRecordset",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[];return b(this,void 0,void 0,t().mark((function n(){var r;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,this._store.get(this.recordsetKey);case 2:if(t.t0=t.sent,t.t0){t.next=5;break}t.t0=[];case 5:return(r=t.t0).push.apply(r,_(e)),t.abrupt("return",this._reduceRecordSet(r));case 8:case"end":return t.stop()}}),n,this)})))}},{key:"_reduceRecordSet",value:function(e){for(var t=[],n={},r=e.length-1;r>=0;r--){for(var a=e[r],s=[],i=a.requests.length-1;i>=0;i--){var o=a.requests[i],u=o.data;n[u.key]||(s.unshift(o),n[u.key]=!0)}s.length>0&&(a.requests=s,t.unshift(a))}return t}},{key:"_applyRecord",value:function(e,n){return b(this,void 0,void 0,t().mark((function r(){var a,s,i,o,u,c,l,h;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return a=el.get(this.dbname),s=n.generation,i=n.requests,o=null,t.prev=3,t.next=6,this._store.setMany(i.map((function(e){return Object.assign(Object.assign({},e.data),{generation:s})})));case 6:for(u=t.sent,c=0;c0)){e.next=20;break}for(r=[],a={},s=n.length-1;s>=0;s--)i=n[s],o=i.data,a[o.key]||(a[o.key]=!0,r.unshift(i));return u={generation:this.generation,requests:r},e.next=8,this._getReducedRecordset([u]);case 8:return c=e.sent,e.next=11,this._store.set({key:this.recordsetKey,value:c});case 11:return this._metadata.generation++,e.next=14,this._store.set({key:this.metadataKey,value:this._metadata});case 14:for(l=el.get(this.dbname),h=0;h1&&void 0!==arguments[1]?arguments[1]:this.metadata.blockLevel;return t=this.dbname,n=this.collectionName,r=s,a="".concat(function(e,t,n){var r=n.base*Math.pow(n.multiplier,t)+n.constant;return(n.hashFunction||Ac)(e,r)}(e,s,{hashFunction:this.hashFunction,base:this.metadata.blockHashBase,multiplier:this.metadata.blockHashMultiplier,constant:this.metadata.blockHashConstant})),"".concat(Kc(t,n)).concat(r,".").concat(a)}},{key:"_findBlock",value:function(e){return b(this,void 0,void 0,t().mark((function n(){var r,a,s,i,o;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:r=el.get(this.dbname),a=this.metadata.blockLevel;case 2:if(!(a>0)){t.next=15;break}return s=this.createBlockId(e,a),t.next=6,r.find(this._store,s);case 6:if(!(i=t.sent)){t.next=12;break}if(o=nl.createFromCacheItem(i),!(null==o?void 0:o.getItemByKey(e))){t.next=12;break}return t.abrupt("return",o);case 12:a--,t.next=2;break;case 15:return t.abrupt("return",null);case 16:case"end":return t.stop()}}),n,this)})))}},{key:"getFromBlock",value:function(e){return b(this,void 0,void 0,t().mark((function n(){var r;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,this._findBlock(e);case 2:return r=t.sent,t.abrupt("return",r?r.getItemByKey(e):null);case 4:case"end":return t.stop()}}),n,this)})))}},{key:"putToBlock",value:function(e,n){return b(this,void 0,void 0,t().mark((function r(){var a,s,i,o,u,c;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return a=Cc.get(this.dbname),s=this.createBlockId(e),i=Math.floor(this._store.itemSizeLimit/a.itemSizeLimit),o=el.get(this.dbname),t.next=6,o.find(this._store,s);case 6:if(u=t.sent,!(null==(c=u?nl.createFromCacheItem(u):new nl({blockId:s,keyName:this.keyName,items:[],limit:i}))?void 0:c.add(n))){t.next=11;break}return this._transaction.requestWrite({key:c.blockId,value:c.serialize()}),t.abrupt("return",!0);case 11:return t.abrupt("return",!1);case 12:case"end":return t.stop()}}),r,this)})))}},{key:"removeFromBlock",value:function(e){return b(this,void 0,void 0,t().mark((function n(){var r;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,this._findBlock(e);case 2:if(!(r=t.sent)){t.next=7;break}if(!r.remove(e)){t.next=7;break}return this._transaction.requestWrite({key:r.blockId,value:r.serialize()}),t.abrupt("return",!0);case 7:return t.abrupt("return",!1);case 8:case"end":return t.stop()}}),n,this)})))}},{key:"clearAllBlocks",value:function(){return b(this,void 0,void 0,t().mark((function e(){var n,r,a;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n=Kc(this.dbname,this.collectionName),e.next=3,this._store.getAllKeys();case 3:return r=e.sent,a=r.filter((function(e){return e.startsWith(n)})),e.next=7,this._store.removeMany(a);case 7:return e.next=9,this._transaction.clear();case 9:el.get(this.dbname).clearByCondition((function(e){return e.key.startsWith(n)}));case 11:case"end":return e.stop()}}),e,this)})))}}]),e}(),al={},sl=function(){function e(t){var n=this,a=t.dbname,s=t.collectionName,i=t.keyName,o=t.fields,u=t.transaction,c=t.store;r(this,e),this._origin=[],this._table=[];var l=function(e,t,n){return"".concat(Bc(e,t),"/index.").concat(n)}(a,s,o.join(">"));return al[l]||(this.dbname=a,this.collectionName=s,this.keyName=i,this.fields=o,this.indexerKey=l,this._transaction=u,this._store=c,this._transaction.on(Fc.COMMIT,this.indexerKey,(function(){return n.commit()})),this._transaction.on(Fc.ERROR,this.indexerKey,(function(){return n.abort()}))),al[l]}return s(e,[{key:"_addItem",value:function(e){var t=e[this.keyName],n=this.getColumnValues(e),r=v(this.indexOf(n),2),a=r[0];return r[1]?!this._table[a].keys.includes(t)&&(this._table[a].keys.push(t),!0):(this._table.splice(a,0,{columnValues:n,keys:[t]}),!0)}},{key:"_removeItem",value:function(e){var t=e[this.keyName],n=this.getColumnValues(e),r=v(this.indexOf(n),2),a=r[0];if(r[1]){var s=this._table[a].keys.indexOf(t);if(s>-1)return this._table[a].keys.splice(s,1),0===this._table[a].keys.length&&this._table.splice(a,1),!0}return!1}},{key:"origin",get:function(){return this._origin}},{key:"table",get:function(){return this._table}},{key:"getColumnValues",value:function(e){var t,r,a,s=[],i=y(this.fields);try{for(i.s();!(t=i.n()).done;){var o=t.value;if("-"===o[0]&&(o=o.slice(1)),r=e[o],a=void 0,a=n(r),null!==r&&"undefined"!==a&&"boolean"!==a&&"number"!==a&&"string"!==a)throw Sc.indexTypesNotMatch;s.push(e[o])}}catch(e){i.e(e)}finally{i.f()}return s}},{key:"diff",value:function(e,t){for(var n in this.fields){var r="-"===this.fields[n][0]?-1:1,a=Mc(e[n],t[n]);if(0!==a)return r*a}return 0}},{key:"indexOf",value:function(e){if(this._table.length>0){for(var t=0,n=this._table.length-1;t<=n;){var r=Math.floor((t+n)/2),a=this.diff(e,this._table[r].columnValues);if(a>0)t=r+1;else{if(!(a<0))return[r,!0];n=r-1}}return[t,!1]}return[0,!1]}},{key:"ensure",value:function(){return b(this,void 0,void 0,t().mark((function e(){var n,r,a,s,i,o,u,c,l,h,d,f;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n=el.get(this.dbname),e.next=3,n.find(this._store,this.indexerKey,qc.PERSISTENT);case 3:if(r=e.sent){e.next=33;break}return a=Kc(this.dbname,this.collectionName),e.next=8,this._store.getAllKeys();case 8:s=e.sent,i=y(s),e.prev=10,i.s();case 12:if((o=i.n()).done){e.next=22;break}if(!(u=o.value).startsWith(a)){e.next=20;break}return e.next=17,n.find(this._store,u,qc.NO_CACHE);case 17:if(c=e.sent,l=nl.createFromCacheItem(c)){h=y(l.items);try{for(h.s();!(d=h.n()).done;)f=d.value,this._addItem(f)}catch(e){h.e(e)}finally{h.f()}}case 20:e.next=12;break;case 22:e.next=27;break;case 24:e.prev=24,e.t0=e.catch(10),i.e(e.t0);case 27:return e.prev=27,i.f(),e.finish(27);case 30:this._transaction.requestWrite({key:this.indexerKey,value:this._table},{persistent:!0}),e.next=35;break;case 33:this._origin=r.value,this._table=Nc(this._origin);case 35:al[this.indexerKey]=this;case 36:case"end":return e.stop()}}),e,this,[[10,24,27,30]])})))}},{key:"drop",value:function(){return b(this,void 0,void 0,t().mark((function e(){return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return el.get(this.dbname).remove(this.indexerKey),e.next=4,this._store.remove(this.indexerKey);case 4:delete al[this.indexerKey];case 5:case"end":return e.stop()}}),e,this)})))}},{key:"addItem",value:function(e){return b(this,void 0,void 0,t().mark((function n(){return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:this._addItem(e)&&this._transaction.requestWrite({key:this.indexerKey,value:this._table},{persistent:!0});case 1:case"end":return t.stop()}}),n,this)})))}},{key:"removeItem",value:function(e){return b(this,void 0,void 0,t().mark((function n(){return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:this._removeItem(e)&&this._transaction.requestWrite({key:this.indexerKey,value:this._table},{persistent:!0});case 1:case"end":return t.stop()}}),n,this)})))}},{key:"clear",value:function(){return b(this,void 0,void 0,t().mark((function e(){return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:this._table=[],this._transaction.requestWrite({key:this.indexerKey,value:this._table},{persistent:!0});case 2:case"end":return e.stop()}}),e,this)})))}},{key:"commit",value:function(){this._origin=this._table,this._table=Nc(this._origin)}},{key:"abort",value:function(){this._table=Nc(this._origin)}}],[{key:"createKey",value:function(e){return e.join(">")}},{key:"parseKey",value:function(e){return e.split(">")}},{key:"clearIndexerMap",value:function(){for(var e in al)delete al[e]}}]),e}(),il=function(){function e(t){var n=this,a=t.dbname,s=t.collectionName,i=t.keyName,o=t.keyHash,u=t.indexes,c=t.store;r(this,e),this._state=Tc.INIT,this._indexers=[],this.dbname=a,this.name=s,this.keyName=i,this.indexes=[[i]].concat(_(u.filter((function(e){return sl.createKey(e)!==n.keyName})))),this._keyHash=o,this._store=c,this._mutex=new zo(function(e,t){return"".concat(Bc(e,t),".lock")}(a,s)),this._blobContainer=new Zc({dbname:a,collectionName:s,store:c}),this._transaction=new tl({dbname:a,collectionName:s,store:c})}return s(e,[{key:"state",get:function(){return this._state}},{key:"isReady",get:function(){return this._state===Tc.READY}},{key:"init",value:function(){return b(this,void 0,void 0,t().mark((function n(){var r,a,s,i,o,u,c,l,h,d,f,p=this;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,this._mutex.lock();case 2:return t.prev=2,r=Cc.get(this.dbname),t.next=6,e.metadataOf(this.dbname,this.name,this._store);case 6:return a=t.sent,this._metadata=a||{keyName:this.keyName,blockLevel:1,blockHashBase:r.blockHashBase,blockHashMultiplier:r.blockHashMultiplier,blockHashConstant:r.blockHashConstant,indexes:this.indexes},t.next=10,this._transaction.init();case 10:this._blockManager=new rl({dbname:this.dbname,collectionName:this.name,hashFunction:this._keyHash,metadata:this._metadata,transaction:this._transaction,store:this._store}),s=_(this.indexes),i=[],o=s.map((function(e){return sl.createKey(e)})),u=a?a.indexes.map((function(e){return sl.createKey(e)})):[],c=y(u);try{for(c.s();!(l=c.n()).done;)h=l.value,o.includes(h)||i.push(sl.parseKey(h))}catch(e){c.e(e)}finally{c.f()}return(d=[]).push.apply(d,_(s.map((function(e){var t=new sl({dbname:p.dbname,collectionName:p.name,keyName:p.keyName,fields:e,transaction:p._transaction,store:p._store});return p._indexers.push(t),t.ensure()})))),d.push.apply(d,_(i.map((function(e){return new sl({dbname:p.dbname,collectionName:p.name,keyName:p.keyName,fields:e,transaction:p._transaction,store:p._store}).drop()})))),t.next=22,Promise.all(d);case 22:return t.next=24,this._transaction.commit();case 24:if(o.sort().join(",")===u.sort().join(",")){t.next=29;break}return f=Qc(this.dbname,this.name),this._metadata.indexes=s,t.next=29,this._store.set({key:f,value:this._metadata});case 29:this._state=Tc.READY,this._mutex.unlock(),t.next=37;break;case 33:throw t.prev=33,t.t0=t.catch(2),this._mutex.unlock(),t.t0;case 37:case"end":return t.stop()}}),n,this,[[2,33]])})))}},{key:"close",value:function(){this._state=Tc.CLOSED}},{key:"_hasPropertyOfKeyName",value:function(e){var t=e[this.keyName];return"string"==typeof t&&!!t}},{key:"_getIndexerBy",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:null;e||(e=[this.keyName]);var t,n=sl.createKey(e),r=y(this._indexers);try{for(r.s();!(t=r.n()).done;){var a=t.value;if(n===sl.createKey(a.fields))return a}}catch(e){r.e(e)}finally{r.f()}throw Sc.indexTableIsRequired}},{key:"_upgradeBlockLevel",value:function(){return b(this,void 0,void 0,t().mark((function e(){var n;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n=Qc(this.dbname,this.name),this._metadata.blockLevel++,e.next=4,this._store.set({key:n,value:this._metadata});case 4:case"end":return e.stop()}}),e,this)})))}},{key:"_requestInsert",value:function(e){return b(this,void 0,void 0,t().mark((function n(){var r,a,s,i;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return r=e[this.keyName],t.next=3,this._blockManager.getFromBlock(r);case 3:if(t.sent){t.next=32;break}return t.next=7,this._blockManager.putToBlock(r,e);case 7:if(t.sent){t.next=13;break}return t.next=11,this._upgradeBlockLevel();case 11:return t.next=13,this._blockManager.putToBlock(r,e);case 13:a=y(this._indexers),t.prev=14,a.s();case 16:if((s=a.n()).done){t.next=22;break}return i=s.value,t.next=20,i.addItem(e);case 20:t.next=16;break;case 22:t.next=27;break;case 24:t.prev=24,t.t0=t.catch(14),a.e(t.t0);case 27:return t.prev=27,a.f(),t.finish(27);case 30:t.next=33;break;case 32:throw Sc.collectionInsertDuplicate;case 33:case"end":return t.stop()}}),n,this,[[14,24,27,30]])})))}},{key:"_requestUpsert",value:function(e){return b(this,void 0,void 0,t().mark((function n(){var r,a,s,i,o,u,c,l;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return r=e[this.keyName],t.next=3,this._blockManager.getFromBlock(r);case 3:if(a=t.sent){t.next=32;break}return t.next=7,this._blockManager.putToBlock(r,e);case 7:if(t.sent){t.next=13;break}return t.next=11,this._upgradeBlockLevel();case 11:return t.next=13,this._blockManager.putToBlock(r,e);case 13:s=y(this._indexers),t.prev=14,s.s();case 16:if((i=s.n()).done){t.next=22;break}return o=i.value,t.next=20,o.addItem(e);case 20:t.next=16;break;case 22:t.next=27;break;case 24:t.prev=24,t.t0=t.catch(14),s.e(t.t0);case 27:return t.prev=27,s.f(),t.finish(27);case 30:t.next=54;break;case 32:return t.next=34,this._blockManager.putToBlock(r,e);case 34:u=y(this._indexers),t.prev=35,u.s();case 37:if((c=u.n()).done){t.next=46;break}if(0===(l=c.value).diff(l.getColumnValues(a),l.getColumnValues(e))){t.next=44;break}return t.next=42,l.removeItem(a);case 42:return t.next=44,l.addItem(e);case 44:t.next=37;break;case 46:t.next=51;break;case 48:t.prev=48,t.t1=t.catch(35),u.e(t.t1);case 51:return t.prev=51,u.f(),t.finish(51);case 54:case"end":return t.stop()}}),n,this,[[14,24,27,30],[35,48,51,54]])})))}},{key:"_requestUpdate",value:function(e){return b(this,void 0,void 0,t().mark((function n(){var r,a,s,i,o;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return r=e[this.keyName],t.next=3,this._blockManager.getFromBlock(r);case 3:if(!(a=t.sent)){t.next=27;break}return t.next=7,this._blockManager.putToBlock(r,e);case 7:s=y(this._indexers),t.prev=8,s.s();case 10:if((i=s.n()).done){t.next=19;break}if(0===(o=i.value).diff(o.getColumnValues(a),o.getColumnValues(e))){t.next=17;break}return t.next=15,o.removeItem(a);case 15:return t.next=17,o.addItem(e);case 17:t.next=10;break;case 19:t.next=24;break;case 21:t.prev=21,t.t0=t.catch(8),s.e(t.t0);case 24:return t.prev=24,s.f(),t.finish(24);case 27:case"end":return t.stop()}}),n,this,[[8,21,24,27]])})))}},{key:"_requestRemove",value:function(e){return b(this,void 0,void 0,t().mark((function n(){var r,a,s,i;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,this._blockManager.getFromBlock(e);case 2:if(!(r=t.sent)){t.next=23;break}return t.next=6,this._blockManager.removeFromBlock(e);case 6:a=y(this._indexers),t.prev=7,a.s();case 9:if((s=a.n()).done){t.next=15;break}return i=s.value,t.next=13,i.removeItem(r);case 13:t.next=9;break;case 15:t.next=20;break;case 17:t.prev=17,t.t0=t.catch(7),a.e(t.t0);case 20:return t.prev=20,a.f(),t.finish(20);case 23:case"end":return t.stop()}}),n,this,[[7,17,20,23]])})))}},{key:"_requestClear",value:function(){return b(this,void 0,void 0,t().mark((function e(){var n,r,a;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this._blockManager.clearAllBlocks();case 2:n=y(this._indexers),e.prev=3,n.s();case 5:if((r=n.n()).done){e.next=11;break}return a=r.value,e.next=9,a.clear();case 9:e.next=5;break;case 11:e.next=16;break;case 13:e.prev=13,e.t0=e.catch(3),n.e(e.t0);case 16:return e.prev=16,n.f(),e.finish(16);case 19:case"end":return e.stop()}}),e,this,[[3,13,16,19]])})))}},{key:"getByKey",value:function(e){return b(this,void 0,void 0,t().mark((function n(){var r;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(!this.isReady){t.next=17;break}return t.next=3,this._mutex.lock();case 3:return t.prev=3,t.next=6,this._blockManager.getFromBlock(e);case 6:return r=t.sent,this._mutex.unlock(),t.abrupt("return",Nc(r));case 11:throw t.prev=11,t.t0=t.catch(3),this._mutex.unlock(),t.t0;case 15:t.next=18;break;case 17:throw Sc.collectionNotReady;case 18:case"end":return t.stop()}}),n,this,[[3,11]])})))}},{key:"query",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};if(this.isReady)return new zc({condition:e.where,mutex:this._mutex,blockManager:this._blockManager,indexer:this._getIndexerBy(e.index),backward:!!e.backward});throw Sc.collectionNotReady}},{key:"insertOne",value:function(e){return b(this,void 0,void 0,t().mark((function n(){return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(!this.isReady){t.next=22;break}return t.next=3,this._mutex.lock();case 3:if(t.prev=3,this._hasPropertyOfKeyName(e)){t.next=6;break}throw Sc.collectionKeyNotGiven;case 6:return t.next=8,this._requestInsert(Nc(e));case 8:return t.next=10,this._transaction.commit();case 10:return this._mutex.unlock(),t.abrupt("return",e);case 14:return t.prev=14,t.t0=t.catch(3),t.next=18,this._transaction.clear();case 18:throw this._mutex.unlock(),t.t0;case 20:t.next=23;break;case 22:throw Sc.collectionNotReady;case 23:case"end":return t.stop()}}),n,this,[[3,14]])})))}},{key:"insertMany",value:function(e){return b(this,void 0,void 0,t().mark((function n(){var r,a,s,i=this;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(!this.isReady){t.next=37;break}return t.next=3,this._mutex.lock();case 3:if(t.prev=3,!e.some((function(e){return!i._hasPropertyOfKeyName(e)}))){t.next=6;break}throw Sc.collectionKeyNotGiven;case 6:r=y(e),t.prev=7,r.s();case 9:if((a=r.n()).done){t.next=15;break}return s=a.value,t.next=13,this._requestInsert(Nc(s));case 13:t.next=9;break;case 15:t.next=20;break;case 17:t.prev=17,t.t0=t.catch(7),r.e(t.t0);case 20:return t.prev=20,r.f(),t.finish(20);case 23:return t.next=25,this._transaction.commit();case 25:return this._mutex.unlock(),t.abrupt("return",e);case 29:return t.prev=29,t.t1=t.catch(3),t.next=33,this._transaction.clear();case 33:throw this._mutex.unlock(),t.t1;case 35:t.next=38;break;case 37:throw Sc.collectionNotReady;case 38:case"end":return t.stop()}}),n,this,[[3,29],[7,17,20,23]])})))}},{key:"upsertOne",value:function(e){return b(this,void 0,void 0,t().mark((function n(){return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(!this.isReady){t.next=22;break}return t.next=3,this._mutex.lock();case 3:if(t.prev=3,this._hasPropertyOfKeyName(e)){t.next=6;break}throw Sc.collectionKeyNotGiven;case 6:return t.next=8,this._requestUpsert(Nc(e));case 8:return t.next=10,this._transaction.commit();case 10:return this._mutex.unlock(),t.abrupt("return",e);case 14:return t.prev=14,t.t0=t.catch(3),t.next=18,this._transaction.clear();case 18:throw this._mutex.unlock(),t.t0;case 20:t.next=23;break;case 22:throw Sc.collectionNotReady;case 23:case"end":return t.stop()}}),n,this,[[3,14]])})))}},{key:"upsertMany",value:function(e){return b(this,void 0,void 0,t().mark((function n(){var r,a,s,i=this;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(!this.isReady){t.next=37;break}return t.next=3,this._mutex.lock();case 3:if(t.prev=3,!e.some((function(e){return!i._hasPropertyOfKeyName(e)}))){t.next=6;break}throw Sc.collectionKeyNotGiven;case 6:r=y(e),t.prev=7,r.s();case 9:if((a=r.n()).done){t.next=15;break}return s=a.value,t.next=13,this._requestUpsert(Nc(s));case 13:t.next=9;break;case 15:t.next=20;break;case 17:t.prev=17,t.t0=t.catch(7),r.e(t.t0);case 20:return t.prev=20,r.f(),t.finish(20);case 23:return t.next=25,this._transaction.commit();case 25:return this._mutex.unlock(),t.abrupt("return",e);case 29:return t.prev=29,t.t1=t.catch(3),t.next=33,this._transaction.clear();case 33:throw this._mutex.unlock(),t.t1;case 35:t.next=38;break;case 37:throw Sc.collectionNotReady;case 38:case"end":return t.stop()}}),n,this,[[3,29],[7,17,20,23]])})))}},{key:"update",value:function(e){return b(this,void 0,void 0,t().mark((function n(){return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(!this.isReady){t.next=22;break}return t.next=3,this._mutex.lock();case 3:if(t.prev=3,this._hasPropertyOfKeyName(e)){t.next=6;break}throw Sc.collectionKeyNotGiven;case 6:return t.next=8,this._requestUpdate(Nc(e));case 8:return t.next=10,this._transaction.commit();case 10:return this._mutex.unlock(),t.abrupt("return",e);case 14:return t.prev=14,t.t0=t.catch(3),t.next=18,this._transaction.clear();case 18:throw this._mutex.unlock(),t.t0;case 20:t.next=23;break;case 22:throw Sc.collectionNotReady;case 23:case"end":return t.stop()}}),n,this,[[3,14]])})))}},{key:"updateIf",value:function(e,n){return b(this,void 0,void 0,t().mark((function r(){var a,s,i,o,u,c,l,h,d,f,p,v=this;return t().wrap((function(r){for(;;)switch(r.prev=r.next){case 0:if(!this.isReady){r.next=31;break}return r.next=3,this._mutex.lock();case 3:return r.prev=3,a=e.where,s=void 0===a?{}:a,i=e.index,o=void 0===i?null:i,u=e.backward,c=void 0!==u&&u,l=[],h=new jc({condition:s,blockManager:this._blockManager,backward:c,indexer:this._getIndexerBy(o)}),r.next=9,h.each((function(e){return b(v,void 0,void 0,t().mark((function r(){var a,i;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(e.error){t.next=4;break}if(e.hasNext){if(a=e.nextValue,Uc(s,a)&&n.set){if("function"!=typeof n.set)for(i in n.set)a[i]=n.set[i];else n.set(a);l.push(a)}e.next()}else e.stop();t.next=6;break;case 4:throw e.stop(),e.error;case 6:case"end":return t.stop()}}),r)})))}));case 9:d=0,f=l;case 10:if(!(d1&&void 0!==arguments[1]?arguments[1]:"";return"".concat(e).concat(t)}},{key:"_generateShardPostfixArray",value:function(){return _(Array(arguments.length>0&&void 0!==arguments[0]?arguments[0]:1).keys())}},{key:"_shardify",value:function(e){var t=this,n=e.key,r=e.value,a=JSON.stringify(this.encryption.encrypt(r)),s=Math.ceil(a.length/this.adjustedItemSizeLimit);return this._generateShardPostfixArray(s).map((function(e){var r={key:t._getRawKey(n,".".concat(e)),data:a.substring(e*t.adjustedItemSizeLimit,(e+1)*t.adjustedItemSizeLimit)};return 0===e&&(r.metadata={shards:s}),r}))}},{key:"adjustedItemSizeLimit",get:function(){return Math.max(this.itemSizeLimit-this.metadataBuffer,4)}},{key:"usage",value:function(){return b(this,void 0,void 0,t().mark((function e(){var n,r,a,s,i,o;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n=0,e.next=3,this._getAllRawKeys();case 3:r=e.sent,a=y(r),e.prev=5,a.s();case 7:if((s=a.n()).done){e.next=15;break}return i=s.value,e.next=11,this._getRaw(i);case 11:(o=e.sent)&&(n+=JSON.stringify(o).length);case 13:e.next=7;break;case 15:e.next=20;break;case 17:e.prev=17,e.t0=e.catch(5),a.e(e.t0);case 20:return e.prev=20,a.f(),e.finish(20);case 23:return e.abrupt("return",n);case 24:case"end":return e.stop()}}),e,this,[[5,17,20,23]])})))}},{key:"getAllKeys",value:function(){return b(this,void 0,void 0,t().mark((function e(){var n;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this._getAllRawKeys();case 2:return n=e.sent,e.abrupt("return",n.filter((function(e){return e.endsWith(".0")})).map((function(e){return e.replace(/\.0$/,"")})));case 4:case"end":return e.stop()}}),e,this)})))}},{key:"get",value:function(e){return b(this,void 0,void 0,t().mark((function n(){var r,a,s,i,o,u=this;return t().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return r=this._getRawKey(e,".0"),n.next=3,this._getRaw(r);case 3:if(!(a=n.sent)){n.next=21;break}if(n.prev=5,s=a.data,!((null==(i=a.metadata)?void 0:i.shards)&&i.shards>1)){n.next=13;break}return n.next=10,Promise.all(this._generateShardPostfixArray(null==i?void 0:i.shards).map((function(n){return b(u,void 0,void 0,t().mark((function r(){var a,i;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(!(n>0)){t.next=10;break}return a=this._getRawKey(e,".".concat(n)),t.next=4,this._getRaw(a);case 4:if(i=t.sent){t.next=7;break}throw Sc.storeBrokenIntegrity;case 7:return t.abrupt("return",i.data);case 10:return t.abrupt("return",s);case 11:case"end":return t.stop()}}),r,this)})))})));case 10:n.t0=n.sent,n.next=14;break;case 13:n.t0=[s];case 14:return o=n.t0,n.abrupt("return",this.encryption.decrypt(JSON.parse(o.join(""))));case 18:return n.prev=18,n.t1=n.catch(5),n.abrupt("return",null);case 21:return n.abrupt("return",null);case 22:case"end":return n.stop()}}),n,this,[[5,18]])})))}},{key:"set",value:function(e){return b(this,void 0,void 0,t().mark((function n(){var r;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return r=this._shardify(e),t.next=3,this._setRaw(r);case 3:return t.abrupt("return",Object.assign({},e.value));case 4:case"end":return t.stop()}}),n,this)})))}},{key:"setMany",value:function(e){return b(this,void 0,void 0,t().mark((function n(){var r,a=this;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return r=[],t.next=3,this._setRaw(r.concat.apply(r,_(e.map((function(e){return a._shardify(e)})))));case 3:return t.abrupt("return",e.map((function(e){return e.value})));case 4:case"end":return t.stop()}}),n,this)})))}},{key:"remove",value:function(e){return b(this,void 0,void 0,t().mark((function n(){var r,a,s,i=this;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return r=this._getRawKey(e,".0"),t.next=3,this._getRaw(r);case 3:if(!(a=t.sent)){t.next=9;break}return s=a.metadata,t.next=8,this._removeRaw(this._generateShardPostfixArray(null==s?void 0:s.shards).map((function(t){return i._getRawKey(e,".".concat(t))})));case 8:return t.abrupt("return",!0);case 9:return t.abrupt("return",!1);case 10:case"end":return t.stop()}}),n,this)})))}},{key:"removeMany",value:function(e){return b(this,void 0,void 0,t().mark((function n(){var r,a,s,i,o=this;return t().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:r=[],a=y(e),n.prev=2,i=t().mark((function e(){var n,a,i,u;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n=s.value,a=o._getRawKey(n,".0"),e.next=4,o._getRaw(a);case 4:(i=e.sent)&&(u=i.metadata,r.push.apply(r,_(o._generateShardPostfixArray(null==u?void 0:u.shards).map((function(e){return o._getRawKey(n,".".concat(e))})))));case 6:case"end":return e.stop()}}),e)})),a.s();case 5:if((s=a.n()).done){n.next=9;break}return n.delegateYield(i(),"t0",7);case 7:n.next=5;break;case 9:n.next=14;break;case 11:n.prev=11,n.t1=n.catch(2),a.e(n.t1);case 14:return n.prev=14,a.f(),n.finish(14);case 17:if(!(r.length>0)){n.next=20;break}return n.next=20,this._removeRaw(r);case 20:return n.abrupt("return",e);case 21:case"end":return n.stop()}}),n,this,[[2,11,14,17]])})))}}]),e}(),ul={},cl=function(e){i(a,e);var n=f(a);function a(){var e,t,s=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};r(this,a),e=n.call(this,Object.assign(Object.assign({},s),{itemSizeLimit:null!==(t=s.itemSizeLimit)&&void 0!==t?t:4194304}));var i=s.delay,o=void 0===i?1:i;return e.delay=o,e.observer={},e}return s(a,[{key:"rawData",get:function(){return ul[this.dbname]},set:function(e){ul[this.dbname]=e}},{key:"_getAllRawKeys",value:function(){return b(this,void 0,void 0,t().mark((function e(){return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!ul[this.dbname]){e.next=4;break}return e.abrupt("return",Object.keys(ul[this.dbname]));case 4:throw Sc.storeNotAvailable;case 5:case"end":return e.stop()}}),e,this)})))}},{key:"_getRaw",value:function(e){return b(this,void 0,void 0,t().mark((function n(){return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(!ul[this.dbname]){t.next=6;break}return t.next=3,Oc(this.delay);case 3:return t.abrupt("return",ul[this.dbname][e]?Object.assign({key:e},ul[this.dbname][e]):null);case 6:throw Sc.storeNotAvailable;case 7:case"end":return t.stop()}}),n,this)})))}},{key:"_setRaw",value:function(e){return b(this,void 0,void 0,t().mark((function n(){var r,a,s,i,o,u;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(!ul[this.dbname]){t.next=7;break}return t.next=3,Oc(this.delay);case 3:r=y(e);try{for(r.s();!(a=r.n()).done;)s=a.value,i=s.key,o=s.data,u=s.metadata,ul[this.dbname][i]=Object.freeze({data:o,metadata:u})}catch(e){r.e(e)}finally{r.f()}t.next=8;break;case 7:throw Sc.storeNotAvailable;case 8:case"end":return t.stop()}}),n,this)})))}},{key:"_removeRaw",value:function(e){return b(this,void 0,void 0,t().mark((function n(){var r,a,s;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(!ul[this.dbname]){t.next=7;break}return t.next=3,Oc(this.delay);case 3:r=y(e);try{for(r.s();!(a=r.n()).done;)s=a.value,ul[this.dbname][s]&&delete ul[this.dbname][s]}catch(e){r.e(e)}finally{r.f()}t.next=8;break;case 7:throw Sc.storeNotAvailable;case 8:case"end":return t.stop()}}),n,this)})))}},{key:"observe",value:function(e,t,n){var r=this;this.observer[e]||(this.observer[e]={}),t.forEach((function(t){return r.observer[e][t]=n}))}},{key:"checkAvailability",value:function(){return b(this,void 0,void 0,t().mark((function e(){return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:case"end":return e.stop()}}),e)})))}},{key:"init",value:function(e){return b(this,void 0,void 0,t().mark((function n(){return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:this.dbname=e,ul[this.dbname]={};case 2:case"end":return t.stop()}}),n,this)})))}},{key:"set",value:function(e){var n=this,r=Object.create(null,{set:{get:function(){return p(o(a.prototype),"set",n)}}});return b(this,void 0,void 0,t().mark((function n(){var a,s;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(!(a=this.observer[e.key])||"function"!=typeof a.set){t.next=5;break}if(!(s=a.set())){t.next=5;break}throw s;case 5:return t.abrupt("return",r.set.call(this,e));case 6:case"end":return t.stop()}}),n,this)})))}},{key:"setMany",value:function(e){var n=this,r=Object.create(null,{setMany:{get:function(){return p(o(a.prototype),"setMany",n)}}});return b(this,void 0,void 0,t().mark((function n(){var a,s,i,o,u;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:a=y(e),t.prev=1,a.s();case 3:if((s=a.n()).done){t.next=12;break}if(i=s.value,!(o=this.observer[i.key])||"function"!=typeof o.set){t.next=10;break}if(!(u=o.set())){t.next=10;break}throw u;case 10:t.next=3;break;case 12:t.next=17;break;case 14:t.prev=14,t.t0=t.catch(1),a.e(t.t0);case 17:return t.prev=17,a.f(),t.finish(17);case 20:return t.abrupt("return",r.setMany.call(this,e));case 21:case"end":return t.stop()}}),n,this,[[1,14,17,20]])})))}},{key:"clear",value:function(){return b(this,void 0,void 0,t().mark((function e(){return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,Oc(this.delay);case 2:ul[this.dbname]={};case 3:case"end":return e.stop()}}),e,this)})))}}]),a}(ol),ll="NestDBStore";!function(e){e[e.UNINITIALIZED=0]="UNINITIALIZED",e[e.OPENING=1]="OPENING",e[e.OPEN=2]="OPEN",e[e.CLOSED=3]="CLOSED"}(Jc||(Jc={}));var hl,dl=function(e){i(a,e);var n=f(a);function a(){var e,t,s=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return r(this,a),(e=n.call(this,Object.assign(Object.assign({},s),{itemSizeLimit:null!==(t=s.itemSizeLimit)&&void 0!==t?t:104857600})))._storeName=ll,e._state=Jc.UNINITIALIZED,e._openJobQueue=[],e._window="undefined"!=typeof window?window:void 0,e._indexedDb=e._window?e._window.indexedDB||e._window.mozIndexedDB||e._window.webkitIndexedDB||e._window.msIndexedDB:void 0,e}return s(a,[{key:"state",get:function(){return this._state}},{key:"_openDatabase",value:function(e){var t=this;return new Promise((function(n,r){if(t._indexedDb){t._state=Jc.OPENING;var a=t._indexedDb.open(e);a.addEventListener("upgradeneeded",(function(e){e.target.result.createObjectStore(ll,{keyPath:"key"})})),a.addEventListener("success",(function(r){t._state=Jc.OPEN,t._database=r.target.result,t._openJobQueue.forEach((function(e){return e()})),t._openJobQueue=[],t._database.onclose=function(){t._database=void 0,t._state=Jc.OPENING,setTimeout((function(){t._openDatabase(e)}),5)},n(t._database)})),a.addEventListener("error",(function(e){t._state=Jc.UNINITIALIZED,r(e.target.error)}))}else r(Sc.storeNotAvailable)}))}},{key:"_getObjectStore",value:function(e){return b(this,void 0,void 0,t().mark((function n(){var r=this;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(!this._database){t.next=4;break}return t.abrupt("return",this._database.transaction(this._storeName,e).objectStore(this._storeName));case 4:t.t0=this._state,t.next=t.t0===Jc.UNINITIALIZED||t.t0===Jc.OPEN?7:t.t0===Jc.OPENING||t.t0===Jc.CLOSED?8:9;break;case 7:throw Sc.storeNotInitialized;case 8:return t.abrupt("return",new Promise((function(t){r._openJobQueue.push((function(){return t(r._getObjectStore(e))}))})));case 9:return t.next=11,this._getObjectStore(e);case 11:return t.abrupt("return",t.sent);case 12:case"end":return t.stop()}}),n,this)})))}},{key:"_getAllRawKeys",value:function(){return b(this,void 0,void 0,t().mark((function e(){var n;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this._getObjectStore("readonly");case 2:return n=e.sent,e.next=5,new Promise((function(e,t){var r=n.getAllKeys();r.addEventListener("success",(function(t){e(t.target.result)})),r.addEventListener("error",(function(e){return t(e.target.error)}))}));case 5:return e.abrupt("return",e.sent);case 6:case"end":return e.stop()}}),e,this)})))}},{key:"_getRaw",value:function(e){return b(this,void 0,void 0,t().mark((function n(){var r;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,this._getObjectStore("readonly");case 2:return r=t.sent,t.next=5,new Promise((function(t,n){var a=r.get(e);a.addEventListener("success",(function(e){var n;t(null===(n=null==e?void 0:e.target)||void 0===n?void 0:n.result)})),a.addEventListener("error",(function(e){return n(e.target.error)}))}));case 5:return t.abrupt("return",t.sent);case 6:case"end":return t.stop()}}),n,this)})))}},{key:"_setRaw",value:function(e){return b(this,void 0,void 0,t().mark((function n(){var r;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,this._getObjectStore("readwrite");case 2:return r=t.sent,t.next=5,Promise.all(e.map((function(e){return new Promise((function(t,n){var a=r.put(e);a.addEventListener("success",(function(e){t(e.target.result)})),a.addEventListener("error",(function(){n("Failed to write.")}))}))})));case 5:case"end":return t.stop()}}),n,this)})))}},{key:"_removeRaw",value:function(e){return b(this,void 0,void 0,t().mark((function n(){var r;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,this._getObjectStore("readwrite");case 2:return r=t.sent,t.next=5,Promise.all(e.map((function(e){return new Promise((function(t,n){var a=r.delete(e);a.addEventListener("success",(function(){return t(e)})),a.addEventListener("error",(function(e){return n(e.target.error)}))}))})));case 5:case"end":return t.stop()}}),n,this)})))}},{key:"_triggerDatabaseClose",value:function(){this._database&&this._database.onclose&&this._database.onclose(new Event("dummy"))}},{key:"checkAvailability",value:function(){return b(this,void 0,void 0,t().mark((function e(){var n,r=this;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!((null==(n="undefined"!=typeof window?window:null)?void 0:n.indexedDB)||(null==n?void 0:n.mozIndexedDB)||(null==n?void 0:n.webkitIndexedDB)||(null==n?void 0:n.msIndexedDB))){e.next=16;break}if(this._indexedDb=n.indexedDB||n.mozIndexedDB||n.webkitIndexedDB||n.msIndexedDB,!this._window||!Go()){e.next=13;break}if(!(Go()&&navigator.userAgent&&navigator.userAgent.includes("Edge/"))){e.next=9;break}if(this._window.indexedDB||!n.PointerEvent&&!n.MSPointerEvent){e.next=7;break}throw Sc.storeNotAvailableInPrivateBrowsing;case 7:e.next=11;break;case 9:return e.next=11,new Promise((function(e,t){if(r._indexedDb)try{var n=r._indexedDb.open("_testMozilla");n.onerror=function(){return t(Sc.storeNotAvailableInPrivateBrowsing)},n.onsuccess=function(){return e()}}catch(e){t(Sc.storeNotAvailableInPrivateBrowsing)}else t(Sc.storeNotAvailable)}));case 11:e.next=14;break;case 13:case 16:throw Sc.storeNotAvailable;case 14:e.next=17;break;case 17:case"end":return e.stop()}}),e,this)})))}},{key:"init",value:function(e){return b(this,void 0,void 0,t().mark((function n(){return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return this.dbname=e,t.next=3,this.checkAvailability();case 3:return t.next=5,this._openDatabase(e);case 5:case"end":return t.stop()}}),n,this)})))}},{key:"clear",value:function(){return b(this,void 0,void 0,t().mark((function e(){var n;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this._getObjectStore("readwrite");case 2:return n=e.sent,e.next=5,new Promise((function(e,t){var r=n.clear();r.addEventListener("success",(function(){return e()})),r.addEventListener("error",(function(e){return t(e.target.error)}))}));case 5:return e.abrupt("return",e.sent);case 6:case"end":return e.stop()}}),e,this)})))}}]),a}(ol),fl=function(e){i(a,e);var n=f(a);function a(e){var t;r(this,a);var s=e.AsyncStorage,i=e.itemSizeLimit,o=void 0===i?6291456:i,u=function(e,t){var n={};for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&t.indexOf(r)<0&&(n[r]=e[r]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var a=0;for(r=Object.getOwnPropertySymbols(e);a0&&(s.mutedUsers=o.map((function(t){return new El(e,t)}))),s}return s(n)}(Oe),Ll=function(e){i(a,e);var n=f(a);function a(e,t,s,i){return r(this,a),n.call(this,e,t,s,i)}return s(a,[{key:"next",value:function(){return b(this,void 0,void 0,t().mark((function e(){var n,r,a,s,i,o,u;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!this._validate()){e.next=20;break}if(this._isLoading){e.next=17;break}if(!this._hasNext){e.next=14;break}return this._isLoading=!0,n=ds.of(this._iid),r=n.requestQueue,a=new Ul(Object.assign(Object.assign({},this),{token:this._token})),e.next=8,r.send(a);case 8:return s=e.sent,i=s.as(Rl),o=i.mutedUsers,u=i.token,this._token=u,this._hasNext=!!u,this._isLoading=!1,e.abrupt("return",o);case 14:return e.abrupt("return",[]);case 17:throw A.queryInProgress;case 18:e.next=21;break;case 20:throw A.invalidParameters;case 21:case"end":return e.stop()}}),e,this)})))}}]),a}(Ri),Dl=function(e){i(n,e);var t=f(n);function n(e){var a;r(this,n);var s=e.channelUrl,i=e.channelType,o=e.limit,u=e.token;return(a=t.call(this)).method=ce.GET,a.path="".concat(Ce(i),"/").concat(encodeURIComponent(s),"/ban"),a.params=ue({limit:o,token:u}),a}return s(n)}(Ae),Pl=function(e){i(n,e);var t=f(n);function n(e,a){var s;r(this,n),(s=t.call(this,e,a)).token=null,s.bannedUsers=[];var i=a.next,o=a.banned_list;return s.token=i,o&&o.length>0&&(s.bannedUsers=o.map((function(t){return new El(e,t.user)}))),s}return s(n)}(Oe),Fl=function(e){i(a,e);var n=f(a);function a(e,t,s,i){return r(this,a),n.call(this,e,t,s,i)}return s(a,[{key:"_validate",value:function(){return p(o(a.prototype),"_validate",this).call(this)}},{key:"next",value:function(){return b(this,void 0,void 0,t().mark((function e(){var n,r,a,s,i,o,u;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!this._validate()){e.next=20;break}if(this._isLoading){e.next=17;break}if(!this._hasNext){e.next=14;break}return this._isLoading=!0,n=ds.of(this._iid),r=n.requestQueue,a=new Dl(Object.assign(Object.assign({},this),{token:this._token})),e.next=8,r.send(a);case 8:return s=e.sent,i=s.as(Pl),o=i.bannedUsers,u=i.token,this._token=u,this._hasNext=!!u,this._isLoading=!1,e.abrupt("return",o);case 14:return e.abrupt("return",[]);case 17:throw A.queryInProgress;case 18:e.next=21;break;case 20:throw A.invalidParameters;case 21:case"end":return e.stop()}}),e,this)})))}}]),a}(Ri);e.ReportCategory=void 0,(kl=e.ReportCategory||(e.ReportCategory={})).SPAM="spam",kl.HARASSING="harassing",kl.SUSPICIOUS="suspicious",kl.INAPPROPRIATE="inappropriate";var Gl,ql=function(e){i(n,e);var t=f(n);function n(e){var a;r(this,n);var s=e.channelUrl,i=e.channelType,o=e.operatorUserIds;return(a=t.call(this)).method=ce.POST,a.path="".concat(Ce(i),"/").concat(encodeURIComponent(s),"/operators"),a.params={operator_ids:o},a}return s(n)}(Ae),Hl=function(e){i(n,e);var t=f(n);function n(e){var a;r(this,n);var s=e.channelUrl,i=e.channelType,o=e.operatorUserIds;return(a=t.call(this)).method=ce.DELETE,a.path="".concat(Ce(i),"/").concat(encodeURIComponent(s),"/operators"),a.params={operator_ids:o},a}return s(n)}(Ae),jl=function(e){i(n,e);var t=f(n);function n(e){var a;r(this,n);var s=e.channelUrl,i=e.channelType,o=e.userId;return(a=t.call(this)).method=ce.GET,a.path="".concat(Ce(i),"/").concat(encodeURIComponent(s),"/mute/").concat(o),a}return s(n)}(Ae),zl=function(e){i(n,e);var t=f(n);function n(e,a){var s;r(this,n),(s=t.call(this,e,a)).isMuted=!1,s.startAt=null,s.endAt=null,s.remainingDuration=null,s.description=null;var i=a.is_muted,o=a.start_at,u=a.end_at,c=a.remaining_duration,l=a.description;return s.isMuted=i,s.startAt=o,s.endAt=u,s.remainingDuration=c,s.description=l,s}return s(n)}(Oe),Vl=function(e){i(n,e);var t=f(n);function n(e){var a;r(this,n);var s=e.channelUrl,i=e.channelType,o=e.keys;return(a=t.call(this)).method=ce.GET,a.path="".concat(Ce(i),"/").concat(encodeURIComponent(s),"/metadata"),a.params={keys:o,include_ts:!0},a}return s(n)}(Ae),Bl=function(e){i(n,e);var t=f(n);function n(e,a){var s;r(this,n),(s=t.call(this,e,a)).ts=null;var i=a.metadata,o=a.ts;return s.metadata=i,s.ts=null!=o?o:null,s}return s(n)}(Oe),Ql=function(e){i(n,e);var t=f(n);function n(e){var a;r(this,n);var s=e.channelUrl,i=e.channelType,o=e.metadata;return(a=t.call(this)).method=ce.POST,a.path="".concat(Ce(i),"/").concat(encodeURIComponent(s),"/metadata"),a.params={metadata:o,include_ts:!0},a}return s(n)}(Ae),Kl=function(e){i(n,e);var t=f(n);function n(e,a){var s,i,o;return r(this,n),(s=t.call(this,e,a)).metaData=null!==(i=a.metadata)&&void 0!==i?i:{},s.ts=null!==(o=a.ts)&&void 0!==o?o:null,s}return s(n)}(Oe),Wl=function(e){i(n,e);var t=f(n);function n(e){var a;r(this,n);var s=e.channelUrl,i=e.channelType,o=e.metadata,u=e.upsert;return(a=t.call(this)).method=ce.PUT,a.path="".concat(Ce(i),"/").concat(encodeURIComponent(s),"/metadata"),a.params={metadata:o,include_ts:!0,upsert:null!=u&&u},a}return s(n)}(Ae),Yl=function(e){i(n,e);var t=f(n);function n(e,a){var s;r(this,n),(s=t.call(this,e,a)).ts=null;var i=a.metadata,o=a.ts;return s.metadata=i,s.ts=null!=o?o:null,s}return s(n)}(Oe),Zl=function(e){i(n,e);var t=f(n);function n(e,a,s){var i;return r(this,n),(i=t.call(this,e,"SYEV",s)).created=null,i.updated=null,i.deleted=null,s.data&&(i.created=s.data.created,i.updated=s.data.updated,i.deleted=s.data.deleted),i}return s(n)}(Ge),Jl=function(e){i(n,e);var t=f(n);function n(e){var a;r(this,n);var s=e.channelUrl,i=e.channelType,o=e.key;return(a=t.call(this)).method=ce.DELETE,a.path="".concat(Ce(i),"/").concat(encodeURIComponent(s),"/metadata/").concat(o),a.params={include_ts:!0},a}return s(n)}(Ae),Xl=function(e){i(n,e);var t=f(n);function n(e,a){var s;r(this,n),(s=t.call(this,e,a)).ts=null;var i=a.ts;return s.ts=null!=i?i:null,s}return s(n)}(Oe),$l=function(e){i(n,e);var t=f(n);function n(e){var a;r(this,n);var s=e.channelUrl,i=e.channelType;return(a=t.call(this)).method=ce.DELETE,a.path="".concat(Ce(i),"/").concat(encodeURIComponent(s),"/metadata"),a.params={include_ts:!0},a}return s(n)}(Ae),eh=function(e){i(n,e);var t=f(n);function n(e,a){var s;r(this,n),(s=t.call(this,e,a)).ts=null;var i=a.ts;return s.ts=null!=i?i:null,s}return s(n)}(Oe),th=function(e){i(n,e);var t=f(n);function n(e){var a;r(this,n);var s=e.channelUrl,i=e.channelType,o=e.keys;return(a=t.call(this)).method=ce.GET,a.path="".concat(Ce(i),"/").concat(encodeURIComponent(s),"/metacounter"),a.params={keys:o},a}return s(n)}(Ae),nh=function(e){i(n,e);var t=f(n);function n(e,a){var s;return r(this,n),(s=t.call(this,e,a)).metaCounter=a,s}return s(n)}(Oe),rh=function(e){i(n,e);var t=f(n);function n(e){var a;r(this,n);var s=e.channelUrl,i=e.channelType,o=e.metaCounter;return(a=t.call(this)).method=ce.POST,a.path="".concat(Ce(i),"/").concat(encodeURIComponent(s),"/metacounter"),a.params={metacounter:o},a}return s(n)}(Ae),ah=function(e){i(n,e);var t=f(n);function n(e,a){var s;return r(this,n),(s=t.call(this,e,a)).metaCounter=a,s}return s(n)}(Oe),sh=function(e){i(n,e);var t=f(n);function n(e){var a;r(this,n);var s=e.channelUrl,i=e.channelType,o=e.metaCounter,u=e.upsert,c=void 0!==u&&u,l=e.mode,h=void 0===l?"set":l;return(a=t.call(this)).method=ce.PUT,a.path="".concat(Ce(i),"/").concat(encodeURIComponent(s),"/metacounter"),a.params={metacounter:o,upsert:c,mode:h},a}return s(n)}(Ae),ih=function(e){i(n,e);var t=f(n);function n(e,a){var s;return r(this,n),(s=t.call(this,e,a)).metaCounter=a,s}return s(n)}(Oe),oh=function(e){i(n,e);var t=f(n);function n(e,a,s){var i;return r(this,n),(i=t.call(this,e,"SYEV",s)).created=null,i.updated=null,i.deleted=null,s.data&&(i.created=s.data.created,i.updated=s.data.updated,i.deleted=s.data.deleted),i}return s(n)}(Ge),uh=function(e){i(n,e);var t=f(n);function n(e){var a;r(this,n);var s=e.channelUrl,i=e.channelType,o=e.key;return(a=t.call(this)).method=ce.DELETE,a.path="".concat(Ce(i),"/").concat(encodeURIComponent(s),"/metacounter/").concat(o),a.params=null,a}return s(n)}(Ae),ch=function(e){i(n,e);var t=f(n);function n(e){var a;r(this,n);var s=e.channelUrl,i=e.channelType;return(a=t.call(this)).method=ce.DELETE,a.path="".concat(Ce(i),"/").concat(encodeURIComponent(s),"/metacounter"),a.params=null,a}return s(n)}(Ae),lh=function(e){i(n,e);var t=f(n);function n(e){var a;r(this,n);var s=e.channelUrl,i=e.channelType,o=e.userId,u=e.seconds,c=e.description;return(a=t.call(this)).method=ce.POST,a.path="".concat(Ce(i),"/").concat(encodeURIComponent(s),"/mute"),a.params={user_id:o,seconds:u,description:c},a}return s(n)}(Ae),hh=function(e){i(n,e);var t=f(n);function n(e,a,s){var i;return r(this,n),(i=t.call(this,e,"SYEV",s)).user=new El(e,s.data),i}return s(n)}(Ge),dh=function(e){i(n,e);var t=f(n);function n(e){var a;r(this,n);var s=e.channelUrl,i=e.channelType,o=e.userId;return(a=t.call(this)).method=ce.DELETE,a.path="".concat(Ce(i),"/").concat(encodeURIComponent(s),"/mute/").concat(encodeURIComponent(o)),a}return s(n)}(Ae),fh=function(e){i(n,e);var t=f(n);function n(e,a,s){var i;return r(this,n),(i=t.call(this,e,"SYEV",s)).user=new El(e,s.data),i}return s(n)}(Ge),ph=function(e){i(n,e);var t=f(n);function n(e){var a;r(this,n);var s=e.channelUrl,i=e.channelType,o=e.userId,u=e.seconds,c=e.description;return(a=t.call(this)).method=ce.POST,a.path="".concat(Ce(i),"/").concat(encodeURIComponent(s),"/ban"),a.params=ue({user_id:o,seconds:u,description:c}),a}return s(n)}(Ae),vh=function(e){i(n,e);var t=f(n);function n(e,a,s){var i;return r(this,n),(i=t.call(this,e,"SYEV",s)).memberCount=null,i.joinedMemberCount=null,i.user=new El(e,s.data),s.data.member_count&&(i.memberCount=s.data.member_count),s.data.joined_member_count&&(i.joinedMemberCount=s.data.joined_member_count),i}return s(n)}(Ge),_h=function(e){i(n,e);var t=f(n);function n(e){var a;r(this,n);var s=e.channelUrl,i=e.channelType,o=e.userId;return(a=t.call(this)).method=ce.DELETE,a.path="".concat(Ce(i),"/").concat(encodeURIComponent(s),"/ban/").concat(encodeURIComponent(o)),a}return s(n)}(Ae),mh=function(e){i(n,e);var t=f(n);function n(e,a,s){var i;return r(this,n),(i=t.call(this,e,"SYEV",s)).user=new El(e,s.data),i}return s(n)}(Ge),gh=function(e){i(n,e);var t=f(n);function n(e){var a;r(this,n);var s=e.channelUrl,i=e.channelType,o=e.freezing;return(a=t.call(this)).method=ce.PUT,a.path="".concat(Ce(i),"/").concat(encodeURIComponent(s),"/freeze"),a.params={freeze:o},a}return s(n)}(Ae),yh=function(e){i(n,e);var t=f(n);function n(e,a,s){var i;return r(this,n),(i=t.call(this,e,"SYEV",s)).freeze=s.data.freeze,i}return s(n)}(Ge),kh=function(e){i(n,e);var t=f(n);function n(e){var a;r(this,n);var s=e.channelUrl,i=e.channelType,o=e.category,u=e.userId,c=e.description;return(a=t.call(this)).method=ce.POST,a.path="".concat(Te(i),"/").concat(encodeURIComponent(s)),a.params={report_category:o,reporting_user_id:u,report_description:c},a}return s(n)}(Ae),bh=function(t){i(a,t);var n=f(a);function a(t){var s;r(this,a);var i=t.channelUrl,o=t.channelType,u=t.category,c=t.userId,l=t.offendingUserId,h=t.description;return(s=n.call(this)).method=ce.POST,s.path="".concat(ge,"/users/").concat(l),s.params={channel_url:i,channel_type:o===e.ChannelType.OPEN?"open_channels":"group_channels",report_category:u,reporting_user_id:c,report_description:h},s}return s(a)}(Ae),Eh=function(e){i(n,e);var t=f(n);function n(e){var a;r(this,n);var s=e.channelUrl,i=e.channelType,o=e.category,u=e.userId,c=e.offendingUserId,l=e.messageId,h=e.description;return(a=t.call(this)).method=ce.POST,a.path="".concat(Te(i),"/").concat(encodeURIComponent(s),"/messages/").concat(l),a.params={report_category:o,reporting_user_id:u,report_description:h,offending_user_id:c},a}return s(n)}(Ae),wh=function(t){i(a,t);var n=f(a);function a(t){r(this,a);var s=[];return t.mentionType===e.MentionType.USERS&&(t.mentionedUserIds?s=t.mentionedUserIds:t.mentionedUsers&&(s=t.mentionedUsers.map((function(e){return e.userId})))),n.call(this,{code:"MESG",ackRequired:!0,payload:ue({channel_url:t.channelUrl,message:t.message,data:t.data,custom_type:t.customType,metaarray:t.metaArrays,mention_type:t.mentionType,mentioned_user_ids:s,mentioned_message_template:t.mentionedMessageTemplate,target_langs:t.translationTargetLanguages,push_option:t.pushNotificationDeliveryOption&&t.pushNotificationDeliveryOption!==e.PushNotificationDeliveryOption.DEFAULT?t.pushNotificationDeliveryOption:void 0,apple_critical_alert_options:t.appleCriticalAlertOptions,silent:t.silent,reply_to_channel:t.isReplyToChannel,parent_message_id:t.parentMessageId>0?t.parentMessageId:null,req_id:t.reqId,poll_id:t.pollId,pin_message:t.isPinnedMessage})})}return s(a)}(ia),xh=function(e){i(n,e);var t=f(n);function n(e,a,s){var i,o,u,c;r(this,n),(i=t.call(this,e,"MESG",s)).message=new qs(e,s);var l=ds.of(e).sdkState;return i.isMentioned=Se(i.message.mentionType,null!==(o=i.message.mentionedUserIds)&&void 0!==o?o:null===(u=i.message.mentionedUsers)||void 0===u?void 0:u.map((function(e){return e.userId})),l.userId),i.forceUpdateLastMessage=null!==(c=s.force_update_last_message)&&void 0!==c&&c,i}return s(n)}(Ge),Ch=function(t){i(a,t);var n=f(a);function a(t){var s;r(this,a);var i=null;return t.mentionType===e.MentionType.USERS&&(t.mentionedUserIds?i=t.mentionedUserIds:t.mentionedUsers&&(i=t.mentionedUsers.map((function(e){return e.userId})))),n.call(this,{code:"MEDI",ackRequired:!0,payload:ue({channel_url:t.channelUrl,msg_id:t.messageId,message:t.message,data:t.data,custom_type:t.customType,metaarray:t.metaArrayParams,mention_type:t.mentionType,mentioned_user_ids:i,mentioned_message_template:t.mentionedMessageTemplate,apple_critical_alert_options:null===(s=t.appleCriticalAlertOptions)||void 0===s?void 0:s.serialize(),poll_id:t.pollId})})}return s(a)}(ia),Th=function(e){i(n,e);var t=f(n);function n(e,a,s){var i,o,u,c,l,h,d;r(this,n),(i=t.call(this,e,"MEDI",s)).message=new qs(e,s);var f=ds.of(e).sdkState;return i.mentionCountChange=Ie({mentionType:null!==(u=null===(o=s.old_values)||void 0===o?void 0:o.mention_type)&&void 0!==u?u:null,mentionedUserIds:null!==(l=null===(c=s.old_values)||void 0===c?void 0:c.mentioned_user_ids)&&void 0!==l?l:[]},{mentionType:i.message.mentionType,mentionedUserIds:null!==(h=i.message.mentionedUserIds)&&void 0!==h?h:null===(d=i.message.mentionedUsers)||void 0===d?void 0:d.map((function(e){return e.userId}))},f.userId),i}return s(n)}(Ge),Sh=function(t){i(a,t);var n=f(a);function a(t){r(this,a);var s=null;return t.mentionType===e.MentionType.USERS&&(t.mentionedUserIds?s=t.mentionedUserIds:t.mentionedUsers&&(s=t.mentionedUsers.map((function(e){return e.userId})))),n.call(this,{code:"FEDI",ackRequired:!0,payload:ue({channel_url:t.channelUrl,msg_id:t.messageId,data:t.data,custom_type:t.customType,metaarray:t.metaArrayParams,mention_type:t.mentionType,mentioned_user_ids:s,apple_critical_alert_options:t.appleCriticalAlertOptions})})}return s(a)}(ia),Ih=function(e){i(n,e);var t=f(n);function n(e,a,s){var i,o,u,c,l,h,d;r(this,n),(i=t.call(this,e,"FEDI",s)).message=new Bs(e,s);var f=ds.of(e).sdkState;return i.mentionCountChange=Ie({mentionType:null!==(u=null===(o=s.old_values)||void 0===o?void 0:o.mention_type)&&void 0!==u?u:null,mentionedUserIds:null!==(l=null===(c=s.old_values)||void 0===c?void 0:c.mentioned_user_ids)&&void 0!==l?l:[]},{mentionType:i.message.mentionType,mentionedUserIds:null!==(h=i.message.mentionedUserIds)&&void 0!==h?h:null===(d=i.message.mentionedUsers)||void 0===d?void 0:d.map((function(e){return e.userId}))},f.userId),i}return s(n)}(Ge),Nh=function(e){i(n,e);var t=f(n);function n(e){var a;return r(this,n),(a=t.call(this)).method=ce.DELETE,a.path="".concat(Ce(e.channelType),"/").concat(e.channelUrl,"/messages/").concat(e.messageId),a}return s(n)}(Ae),Mh=function(e){i(n,e);var t=f(n);function n(e,a,s){var i;return r(this,n),(i=t.call(this,e,"DELM",s)).channelUrl=s.channel_url,i.channelType=s.channel_type,i.messageId=Number(s.msg_id),i}return s(n)}(Ge),Ah=function(e){i(n,e);var t=f(n);function n(e){var a,s=e.channelType,i=e.channelUrl,o=e.messageId,u=e.reactionKey;return r(this,n),(a=t.call(this)).method=ce.POST,a.path="".concat(Ce(s),"/").concat(encodeURIComponent(i),"/messages/").concat(o,"/reactions"),a.params={reaction:u},a}return s(n)}(Ae),Oh=function(e){i(n,e);var t=f(n);function n(e,a){var s;return r(this,n),(s=t.call(this,e,a)).reactionEvent=new ys(a),s}return s(n)}(Oe),Uh=function(e){i(n,e);var t=f(n);function n(e){var a,s=e.channelType,i=e.channelUrl,o=e.messageId,u=e.reactionKey;return r(this,n),(a=t.call(this)).method=ce.DELETE,a.path="".concat(Ce(s),"/").concat(encodeURIComponent(i),"/messages/").concat(o,"/reactions"),a.params={reaction:u},a}return s(n)}(Ae),Rh=function(e){i(n,e);var t=f(n);function n(e,a){var s;return r(this,n),(s=t.call(this,e,a)).reactionEvent=new ys(Object.assign({},a)),s}return s(n)}(Oe),Lh=function(e){i(n,e);var t=f(n);function n(e){var a,s=e.channelType,i=e.channelUrl,o=e.messageId,u=e.translationTargetLanguages;return r(this,n),(a=t.call(this)).method=ce.POST,a.path="".concat(Ce(s),"/").concat(encodeURIComponent(i),"/messages/").concat(encodeURIComponent(o),"/translation"),a.params={target_langs:u},a}return s(n)}(Ae),Dh=function(e){i(n,e);var t=f(n);function n(e,a){var s;return r(this,n),(s=t.call(this,e,a)).message=new qs(e,a),s}return s(n)}(Oe),Ph=function(t){i(a,t);var n=f(a);function a(t){var s,i;r(this,a),s=n.call(this);var o=[];t.mentionType===e.MentionType.USERS&&(t.mentionedUserIds?o=t.mentionedUserIds:t.mentionedUsers&&(o=t.mentionedUsers.map((function(e){return e.userId}))));var u=t.channelType,c=t.channelUrl;return s.method=ce.POST,s.path="".concat(Ce(u),"/").concat(encodeURIComponent(c),"/scheduled_messages"),s.params={req_id:t.reqId,scheduled_at:t.scheduledAt,message_type:Y.USER,message:t.message,custom_type:t.customType,data:t.data,mention_type:t.mentionType,mentioned_user_ids:o,sorted_metaarray:null===(i=t.metaArrays)||void 0===i?void 0:i.map((function(e){return bs.payloadify(e)})),apple_critical_alert_options:xs.payloadify(t.appleCriticalAlertOptions),target_langs:t.translationTargetLanguages,push_option:t.pushNotificationDeliveryOption},s}return s(a)}(Ae),Fh=function(e){i(n,e);var t=f(n);function n(e,a){var s;return r(this,n),(s=t.call(this,e,a)).message=new qs(e,a),s}return s(n)}(Oe),Gh=function(t){i(a,t);var n=f(a);function a(t){var s,i;r(this,a),s=n.call(this);var o=[];t.mentionType===e.MentionType.USERS&&(t.mentionedUserIds?o=t.mentionedUserIds:t.mentionedUsers&&(o=t.mentionedUsers.map((function(e){return e.userId}))));var u=t.channelType,c=t.channelUrl;return s.method=ce.POST,s.path="".concat(Ce(u),"/").concat(encodeURIComponent(c),"/scheduled_messages"),s.params={req_id:t.reqId,scheduled_at:t.scheduledAt,message_type:Y.FILE,url:t.fileUrl,file_name:t.fileName,file_size:t.fileSize,file_type:t.mimeType,thumbnails:t.thumbnailSizes?t.thumbnailSizes.map((function(e){return Ms.payloadify(e)})):[],custom_type:t.customType,data:t.data,require_auth:t.requireAuth,mention_type:t.mentionType,mentioned_user_ids:o,sorted_metaarray:null===(i=t.metaArrays)||void 0===i?void 0:i.map((function(e){return bs.payloadify(e)})),apple_critical_alert_options:xs.payloadify(t.appleCriticalAlertOptions),push_option:t.pushNotificationDeliveryOption},s}return s(a)}(Ae),qh=function(e){i(n,e);var t=f(n);function n(e,a){var s;return r(this,n),(s=t.call(this,e,a)).message=new Bs(e,a),s}return s(n)}(Oe),Hh=function(e){return L("string",e.title,!0)&&Ps(e.data)&&L("boolean",e.allowUserSuggestion,!0)&&L("boolean",e.allowMultipleVotes,!0)&&L("number",e.closeAt,!0)},jh=function(e){i(n,e);var t=f(n);function n(e){var a,s=e.pollId,i=e.title,o=e.data,u=e.allowUserSuggestion,c=e.allowMultipleVotes,l=e.closeAt;return r(this,n),(a=t.call(this)).method=ce.PUT,a.path="".concat(be,"/").concat(encodeURIComponent(s)),a.params={title:i,data:o,allow_user_suggestion:u,allow_multiple_votes:c,close_at:l},a}return s(n)}(Ae),zh=function(e){i(n,e);var t=f(n);function n(e,a){var s;return r(this,n),(s=t.call(this,e,a)).poll=new Gs(e,a),s}return s(n)}(Oe),Vh=function(e){i(n,e);var t=f(n);function n(e){var a,s=e.pollId;return r(this,n),(a=t.call(this)).method=ce.DELETE,a.path="".concat(be,"/").concat(encodeURIComponent(s)),a}return s(n)}(Ae),Bh=function(e){i(n,e);var t=f(n);function n(e){var a,s=e.pollId;return r(this,n),(a=t.call(this)).method=ce.PUT,a.path="".concat(be,"/").concat(encodeURIComponent(s),"/close"),a}return s(n)}(Ae),Qh=function(e){i(n,e);var t=f(n);function n(e,a){var s;return r(this,n),(s=t.call(this,e,a)).poll=new Gs(e,a),s}return s(n)}(Oe),Kh=function(e){i(n,e);var t=f(n);function n(e){var a,s=e.channelUrl,i=e.channelType,o=e.pollId,u=e.optionText;return r(this,n),(a=t.call(this)).method=ce.POST,a.path="".concat(be,"/").concat(encodeURIComponent(o),"/options"),a.params={channel_url:s,channel_type:i,text:u},a}return s(n)}(Ae),Wh=function(e){i(n,e);var t=f(n);function n(e,a){var s;return r(this,n),(s=t.call(this,e,a)).poll=new Gs(e,a),s}return s(n)}(Oe),Yh=function(e){i(n,e);var t=f(n);function n(e){var a,s=e.pollId,i=e.pollOptionId,o=e.optionText;return r(this,n),(a=t.call(this)).method=ce.PUT,a.path="".concat(be,"/").concat(encodeURIComponent(s),"/options/").concat(encodeURIComponent(i)),a.params={text:o},a}return s(n)}(Ae),Zh=function(e){i(n,e);var t=f(n);function n(e,a){var s;return r(this,n),(s=t.call(this,e,a)).poll=new Gs(e,a),s}return s(n)}(Oe),Jh=function(e){i(n,e);var t=f(n);function n(e){var a,s=e.pollId,i=e.pollOptionId;return r(this,n),(a=t.call(this)).method=ce.DELETE,a.path="".concat(be,"/").concat(encodeURIComponent(s),"/options/").concat(encodeURIComponent(i)),a}return s(n)}(Ae),Xh=function(t){i(a,t);var n=f(a);function a(t){var s=t.reqId,i=t.channelType,o=t.channelUrl,u=t.pollId,c=t.pollOptionIds;return r(this,a),n.call(this,{code:"VOTE",ackRequired:!0,payload:ue({req_id:s,channel_type:i===e.ChannelType.OPEN?"open_channels":"group_channels",channel_url:o,poll_id:u,option_ids:c})})}return s(a)}(ia),$h=function(e){i(n,e);var t=f(n);function n(e,a,s){var i;return r(this,n),(i=t.call(this,e,"VOTE",s)).event=null,i.channelUrl=null,i.channelType=null,i.event=new ro(s),i.channelUrl=s.channel_url,i.channelType=s.channel_type,i}return s(n)}(Ge),ed=function(n){i(u,n);var a=f(u);function u(t,n){var s,i,o,c,l;return r(this,u),(s=a.call(this,t)).url="",s.channelType=e.ChannelType.BASE,s.name="",s.coverUrl="",s.customType="",s.data="",s.isFrozen=!1,s.isEphemeral=!1,s.creator=null,s.createdAt=0,s._messageCollectionLastAccessedAt=0,s.url=n.channel_url,s.name=null!==(i=n.name)&&void 0!==i?i:"",s.coverUrl=null!==(o=n.cover_url)&&void 0!==o?o:"",s.customType=null!==(c=n.custom_type)&&void 0!==c?c:"",s.data=null!==(l=n.data)&&void 0!==l?l:"",s.isFrozen=!!L("boolean",n.freeze)&&n.freeze,s.isEphemeral=!!L("boolean",n.is_ephemeral)&&n.is_ephemeral,s.creator=n.created_by?new Ja(s._iid,n.created_by):null,s.createdAt=1e3*n.created_at,n.metadata&&Object.keys(n.metadata).length>0&&n.ts&&(s._cachedMetaData=new Map,Object.keys(n.metadata).forEach((function(e){s._cachedMetaData.set(e,{value:n.metadata[e],isRemoved:!1,updatedAt:n.ts})}))),s}return s(u,[{key:"isGroupChannel",value:function(){return this.channelType===e.ChannelType.GROUP}},{key:"isOpenChannel",value:function(){return this.channelType===e.ChannelType.OPEN}},{key:"cachedMetaData",get:function(){var e={};return this._cachedMetaData?(this._cachedMetaData.forEach((function(t,n){t.isRemoved||(e[n]=t.value)})),e):e}},{key:"messageCollectionLastAccessedAt",get:function(){return this._messageCollectionLastAccessedAt}},{key:"_updateMessageCollectionLastAccessedAt",value:function(){this._messageCollectionLastAccessedAt=Date.now()}},{key:"_update",value:function(e){var t=ue(e);Object.assign(this,t)}},{key:"_upsertCachedMetaData",value:function(e,t){var n=this;Object.keys(e).forEach((function(r){n._cachedMetaData||(n._cachedMetaData=new Map);var a=n._cachedMetaData.get(r);(!a||a.updatedAt<=t)&&n._cachedMetaData.set(r,{value:e[r],isRemoved:!1,updatedAt:t})}))}},{key:"_removeFromCachedMetaData",value:function(e,t){var n=this;this._cachedMetaData&&e.forEach((function(e){var r=n._cachedMetaData.get(e);r&&r.updatedAt0&&void 0!==arguments[0]?arguments[0]:{};return new Ol(this._iid,this.url,this.channelType,e)}},{key:"createMutedUserListQuery",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return new Ll(this._iid,this.url,this.channelType,e)}},{key:"createBannedUserListQuery",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return new Fl(this._iid,this.url,this.channelType,e)}},{key:"createPreviousMessageListQuery",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return new Li(this._iid,this.url,this.channelType,e)}},{key:"addOperators",value:function(e){return b(this,void 0,void 0,t().mark((function n(){var r,a,s;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return Ya(F("string",e)).throw(A.invalidParameters),r=ds.of(this._iid),a=r.requestQueue,s=new ql({channelUrl:this.url,channelType:this.channelType,operatorUserIds:e}),t.next=5,a.send(s);case 5:case"end":return t.stop()}}),n,this)})))}},{key:"removeOperators",value:function(e){return b(this,void 0,void 0,t().mark((function n(){var r,a,s;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return Ya(F("string",e)).throw(A.invalidParameters),r=ds.of(this._iid),a=r.requestQueue,s=new Hl({channelUrl:this.url,channelType:this.channelType,operatorUserIds:e}),t.next=5,a.send(s);case 5:case"end":return t.stop()}}),n,this)})))}},{key:"getMyMutedInfo",value:function(){return b(this,void 0,void 0,t().mark((function e(){var n,r,a,s,i,o,u,c,l,h,d;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n=ds.of(this._iid),r=n.sdkState,a=n.requestQueue,s=new jl({channelUrl:this.url,channelType:this.channelType,userId:r.userId}),e.next=4,a.send(s);case 4:return i=e.sent,o=i.as(zl),u=o.isMuted,c=o.startAt,l=o.endAt,h=o.remainingDuration,d=o.description,e.abrupt("return",{isMuted:u,startAt:c,endAt:l,remainingDuration:h,description:d});case 7:case"end":return e.stop()}}),e,this)})))}},{key:"getMetaData",value:function(e){return b(this,void 0,void 0,t().mark((function n(){var r,a,s,i,o,u,c;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return Ya(F("string",e)).throw(A.invalidParameters),r=ds.of(this._iid),a=r.requestQueue,s=new Vl({channelUrl:this.url,channelType:this.channelType,keys:e}),t.next=5,a.send(s);case 5:return i=t.sent,o=i.as(Bl),u=o.metadata,c=o.ts,this._upsertCachedMetaData(u,c),t.abrupt("return",u);case 9:case"end":return t.stop()}}),n,this)})))}},{key:"getAllMetaData",value:function(){return b(this,void 0,void 0,t().mark((function e(){var n,r,a,s,i,o,u;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n=ds.of(this._iid),r=n.requestQueue,a=new Vl({channelUrl:this.url,channelType:this.channelType,keys:[]}),e.next=4,r.send(a);case 4:return s=e.sent,i=s.as(Bl),o=i.metadata,u=i.ts,this._upsertCachedMetaData(o,u),e.abrupt("return",o);case 8:case"end":return e.stop()}}),e,this)})))}},{key:"createMetaData",value:function(e){return b(this,void 0,void 0,t().mark((function n(){var r,a,s,i,o,u;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return r=ds.of(this._iid),a=r.requestQueue,s=new Ql({channelUrl:this.url,channelType:this.channelType,metadata:e}),t.next=4,a.send(s);case 4:return i=t.sent,o=i.as(Kl),u=o.metaData,this._upsertCachedMetaData(u,0),t.abrupt("return",u);case 8:case"end":return t.stop()}}),n,this)})))}},{key:"updateMetaData",value:function(e){var n=arguments.length>1&&void 0!==arguments[1]&&arguments[1];return b(this,void 0,void 0,t().mark((function r(){var a,s,i,o,u,c,l;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return a=ds.of(this._iid),s=a.requestQueue,i=new Wl({channelUrl:this.url,channelType:this.channelType,metadata:e,upsert:n}),t.next=4,s.send(i);case 4:return o=t.sent,u=o.as(Yl),c=u.metadata,l=u.ts,this._upsertCachedMetaData(c,l),t.abrupt("return",c);case 8:case"end":return t.stop()}}),r,this)})))}},{key:"deleteMetaData",value:function(e){return b(this,void 0,void 0,t().mark((function n(){var r,a,s,i,o,u;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return Ya(L("string",e)).throw(A.invalidParameters),r=ds.of(this._iid),a=r.requestQueue,s=new Jl({channelUrl:this.url,channelType:this.channelType,key:e}),t.next=5,a.send(s);case 5:i=t.sent,o=i.as(Xl),u=o.ts,this._removeFromCachedMetaData([e],u);case 8:case"end":return t.stop()}}),n,this)})))}},{key:"deleteAllMetaData",value:function(){return b(this,void 0,void 0,t().mark((function e(){var n,r,a,s,i,o;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n=ds.of(this._iid),r=n.requestQueue,a=new $l({channelUrl:this.url,channelType:this.channelType}),e.next=4,r.send(a);case 4:s=e.sent,i=s.as(eh),o=i.ts,this._removeFromCachedMetaData(_(this._cachedMetaData.keys()),o);case 7:case"end":return e.stop()}}),e,this)})))}},{key:"getMetaCounters",value:function(e){return b(this,void 0,void 0,t().mark((function n(){var r,a,s,i,o,u;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return Ya(F("string",e)).throw(A.invalidParameters),r=ds.of(this._iid),a=r.requestQueue,s=new th({channelUrl:this.url,channelType:this.channelType,keys:e}),t.next=5,a.send(s);case 5:return i=t.sent,o=i.as(nh),u=o.metaCounter,t.abrupt("return",u);case 8:case"end":return t.stop()}}),n,this)})))}},{key:"getAllMetaCounters",value:function(){return b(this,void 0,void 0,t().mark((function e(){var n,r,a,s,i,o;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n=ds.of(this._iid),r=n.requestQueue,a=new th({channelUrl:this.url,channelType:this.channelType,keys:[]}),e.next=4,r.send(a);case 4:return s=e.sent,i=s.as(nh),o=i.metaCounter,e.abrupt("return",o);case 7:case"end":return e.stop()}}),e,this)})))}},{key:"createMetaCounters",value:function(e){return b(this,void 0,void 0,t().mark((function n(){var r,a,s,i,o,u;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return r=ds.of(this._iid),a=r.requestQueue,s=new rh({channelUrl:this.url,channelType:this.channelType,metaCounter:e}),t.next=4,a.send(s);case 4:return i=t.sent,o=i.as(ah),u=o.metaCounter,t.abrupt("return",u);case 7:case"end":return t.stop()}}),n,this)})))}},{key:"updateMetaCounters",value:function(e){var n=arguments.length>1&&void 0!==arguments[1]&&arguments[1];return b(this,void 0,void 0,t().mark((function r(){var a,s,i,o,u,c;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return a=ds.of(this._iid),s=a.requestQueue,i=new sh({channelUrl:this.url,channelType:this.channelType,metaCounter:e,upsert:n}),t.next=4,s.send(i);case 4:return o=t.sent,u=o.as(ih),c=u.metaCounter,t.abrupt("return",c);case 7:case"end":return t.stop()}}),r,this)})))}},{key:"increaseMetaCounters",value:function(e){return b(this,void 0,void 0,t().mark((function n(){var r,a,s,i,o,u;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return r=ds.of(this._iid),a=r.requestQueue,s=new sh({channelUrl:this.url,channelType:this.channelType,metaCounter:e,upsert:!1,mode:"increase"}),t.next=4,a.send(s);case 4:return i=t.sent,o=i.as(ih),u=o.metaCounter,t.abrupt("return",u);case 7:case"end":return t.stop()}}),n,this)})))}},{key:"decreaseMetaCounters",value:function(e){return b(this,void 0,void 0,t().mark((function n(){var r,a,s,i,o,u;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return r=ds.of(this._iid),a=r.requestQueue,s=new sh({channelUrl:this.url,channelType:this.channelType,metaCounter:e,upsert:!1,mode:"decrease"}),t.next=4,a.send(s);case 4:return i=t.sent,o=i.as(ih),u=o.metaCounter,t.abrupt("return",u);case 7:case"end":return t.stop()}}),n,this)})))}},{key:"deleteMetaCounter",value:function(e){return b(this,void 0,void 0,t().mark((function n(){var r,a,s;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return Ya(L("string",e)).throw(A.invalidParameters),r=ds.of(this._iid),a=r.requestQueue,s=new uh({channelUrl:this.url,channelType:this.channelType,key:e}),t.next=5,a.send(s);case 5:case"end":return t.stop()}}),n,this)})))}},{key:"deleteAllMetaCounters",value:function(){return b(this,void 0,void 0,t().mark((function e(){var n,r,a;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n=ds.of(this._iid),r=n.requestQueue,a=new ch({channelUrl:this.url,channelType:this.channelType}),e.next=4,r.send(a);case 4:case"end":return e.stop()}}),e,this)})))}},{key:"muteUser",value:function(e,n,r){return b(this,void 0,void 0,t().mark((function a(){return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.abrupt("return",this.muteUserWithUserId(e.userId,n,r));case 1:case"end":return t.stop()}}),a,this)})))}},{key:"muteUserWithUserId",value:function(e,n,r){return b(this,void 0,void 0,t().mark((function a(){var s,i,o;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return Ya(L("string",e)&&L("number",n,!0)&&L("string",r,!0)).throw(A.invalidParameters),s=ds.of(this._iid),i=s.requestQueue,o=new lh({channelUrl:this.url,channelType:this.channelType,userId:e,seconds:n,description:r}),t.next=5,i.send(o);case 5:case"end":return t.stop()}}),a,this)})))}},{key:"unmuteUser",value:function(e){return b(this,void 0,void 0,t().mark((function n(){return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.abrupt("return",this.unmuteUserWithUserId(e.userId));case 1:case"end":return t.stop()}}),n,this)})))}},{key:"unmuteUserWithUserId",value:function(e){return b(this,void 0,void 0,t().mark((function n(){var r,a,s;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return Ya(L("string",e)).throw(A.invalidParameters),r=ds.of(this._iid),a=r.requestQueue,s=new dh({channelUrl:this.url,channelType:this.channelType,userId:e}),t.next=5,a.send(s);case 5:case"end":return t.stop()}}),n,this)})))}},{key:"banUser",value:function(e,n,r){return b(this,void 0,void 0,t().mark((function a(){return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.abrupt("return",this.banUserWithUserId(e.userId,n,r));case 1:case"end":return t.stop()}}),a,this)})))}},{key:"banUserWithUserId",value:function(e,n,r){return b(this,void 0,void 0,t().mark((function a(){var s,i,o;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return Ya(L("string",e)&&L("number",n,!0)&&L("string",r,!0)).throw(A.invalidParameters),s=ds.of(this._iid),i=s.requestQueue,o=new ph({channelUrl:this.url,channelType:this.channelType,userId:e,seconds:n,description:r}),t.next=5,i.send(o);case 5:case"end":return t.stop()}}),a,this)})))}},{key:"unbanUser",value:function(e){return b(this,void 0,void 0,t().mark((function n(){return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.abrupt("return",this.unbanUserWithUserId(e.userId));case 1:case"end":return t.stop()}}),n,this)})))}},{key:"unbanUserWithUserId",value:function(e){return b(this,void 0,void 0,t().mark((function n(){var r,a,s;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return Ya(L("string",e)).throw(A.invalidParameters),r=ds.of(this._iid),a=r.requestQueue,s=new _h({channelUrl:this.url,channelType:this.channelType,userId:e}),t.next=5,a.send(s);case 5:case"end":return t.stop()}}),n,this)})))}},{key:"freeze",value:function(){return b(this,void 0,void 0,t().mark((function e(){var n,r,a;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n=ds.of(this._iid),r=n.requestQueue,a=new gh({channelUrl:this.url,channelType:this.channelType,freezing:!0}),e.next=4,r.send(a);case 4:this.isFrozen=!0;case 5:case"end":return e.stop()}}),e,this)})))}},{key:"unfreeze",value:function(){return b(this,void 0,void 0,t().mark((function e(){var n,r,a;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n=ds.of(this._iid),r=n.requestQueue,a=new gh({channelUrl:this.url,channelType:this.channelType,freezing:!1}),e.next=4,r.send(a);case 4:this.isFrozen=!1;case 5:case"end":return e.stop()}}),e,this)})))}},{key:"getMessagesByMessageId",value:function(e,n){return b(this,void 0,void 0,t().mark((function r(){var a,s;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return a=Object.assign(Object.assign({},ti),n),Ya(L("number",e)&&ni(a)).throw(A.invalidParameters),s=Ei.of(this._iid),t.next=5,s.getMessagesByMessageId(this.url,this.channelType,e,a);case 5:return t.abrupt("return",t.sent);case 6:case"end":return t.stop()}}),r,this)})))}},{key:"getMessagesByTimestamp",value:function(e,n){return b(this,void 0,void 0,t().mark((function r(){var a,s;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return a=Object.assign(Object.assign({},ti),n),Ya(L("number",e)&&ni(a)).throw(A.invalidParameters),s=Ei.of(this._iid),t.next=5,s.getMessagesByTimestamp(this.url,this.channelType,e,a);case 5:return t.abrupt("return",t.sent);case 6:case"end":return t.stop()}}),r,this)})))}},{key:"getMessageChangeLogsSinceTimestamp",value:function(e){var n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return b(this,void 0,void 0,t().mark((function r(){var a,s;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return a=Object.assign(Object.assign({},ri),n),Ya(L("number",e)&&ai(a)).throw(A.invalidParameters),s=Ei.of(this._iid),t.next=5,s.getMessageChangelogs(this.url,this.channelType,e,a);case 5:return t.abrupt("return",t.sent);case 6:case"end":return t.stop()}}),r,this)})))}},{key:"getMessageChangeLogsSinceToken",value:function(e){var n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return b(this,void 0,void 0,t().mark((function r(){var a,s;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return a=Object.assign(Object.assign({},ri),n),Ya(L("string",e)&&ai(a)).throw(A.invalidParameters),s=Ei.of(this._iid),t.next=5,s.getMessageChangelogs(this.url,this.channelType,e,a);case 5:return t.abrupt("return",t.sent);case 6:case"end":return t.stop()}}),r,this)})))}},{key:"_createPendingSendableMessagePayload",value:function(t,n,r){var a,s=ds.of(this._iid).sessionManager;return ue({channel_url:this.url,channel_type:this.channelType,msg_id:0,parent_message_id:t.parentMessageId,data:t.data,custom_type:t.customType,mention_type:t.mentionType,sorted_metaarray:t.metaArrays?t.metaArrays.map((function(e){return bs.payloadify(e)})):null,apple_critical_alert_options:t.appleCriticalAlertOptions?xs.payloadify(t.appleCriticalAlertOptions):null,created_at:r,user:Cs.payloadify(s.currentUser),req_id:n,request_state:e.SendingStatus.PENDING,mentioned_user_ids:t.mentionedUserIds,mentioned_users:null===(a=t.mentionedUsers)||void 0===a?void 0:a.map((function(e){return Ja.payloadify(e)}))})}},{key:"_createPendingUserMessage",value:function(t,n,r){var a={};if(t.translationTargetLanguages){var s,i=y(t.translationTargetLanguages);try{for(i.s();!(s=i.n()).done;){a[s.value]=""}}catch(e){i.e(e)}finally{i.f()}}var o=ue(Object.assign(Object.assign({},this._createPendingSendableMessagePayload(t,n,r)),{type:e.MessageType.USER,message:t.message,translations:a})),u=new qs(this._iid,o);return u.messageParams=t,u}},{key:"_createPendingScheduledUserMessage",value:function(e,t,n){var r=this._createPendingUserMessage(e,t,n);return r.scheduledInfo={scheduledMessageId:0,scheduledAt:e.scheduledAt,scheduledMessageParams:e},r}},{key:"_createPendingFileMessage",value:function(t,n,r){var a,s,i,o,u,c,l=ue(Object.assign(Object.assign({},this._createPendingSendableMessagePayload(t,n,r)),{type:e.MessageType.FILE,url:t.fileUrl,file:{name:null!==(a=t.fileName)&&void 0!==a?a:null===(s=t.file)||void 0===s?void 0:s.name,size:null!==(i=t.fileSize)&&void 0!==i?i:null===(o=t.file)||void 0===o?void 0:o.size,type:null!==(u=t.mimeType)&&void 0!==u?u:null===(c=t.file)||void 0===c?void 0:c.type,data:t.data},thumbnails:t.thumbnailSizes?t.thumbnailSizes.map((function(e){return{url:"",width:e.maxWidth,height:e.maxHeight}})):[]})),h=new Bs(this._iid,l);return h.messageParams=t,h}},{key:"_createPendingMultipleFilesMessage",value:function(t,n,r){var a=ue(Object.assign(Object.assign({},this._createPendingSendableMessagePayload(t,n,r)),{type:e.MessageType.FILE})),s=new js(this._iid,a);return s.messageParams=t,s}},{key:"_createPendingScheduledFileMessage",value:function(e,t,n){var r=this._createPendingFileMessage(e,t,n);return r.scheduledInfo={scheduledMessageId:0,scheduledAt:e.scheduledAt,scheduledMessageParams:e},r}},{key:"_markMessageAsFailed",value:function(t,n){var r=arguments.length>2&&void 0!==arguments[2]&&arguments[2];t.errorCode=n.code,n.code===E.REQUEST_CANCELED?t.sendingStatus=e.SendingStatus.CANCELED:r||(t.sendingStatus=e.SendingStatus.FAILED)}},{key:"sendUserMessage",value:function(e){var t=Object.assign(Object.assign({},Io),e);return Ya(Mo(t)).throw(A.invalidParameters),this._sendUserMessage(t)}},{key:"_sendUserMessage",value:function(n){var r=this,a=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null,s=ds.of(this._iid),i=s.dispatcher,o=s.requestQueue,u=a,c=Date.now(),l=new wi;return u||(u=this._generateRequestId(),ka(2).then((function(){var a=new wh(Object.assign(Object.assign({},n),{channelUrl:r.url,channelType:r.channelType,reqId:u}));o.send(a).then((function(n){var a=n.as(xh).message;i.dispatch(new oi({messages:[a],source:e.MessageEventSource.EVENT_MESSAGE_SENT_SUCCESS})),wa((function(){return b(r,void 0,void 0,t().mark((function e(){return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",l._trigger(null,a));case 1:case"end":return e.stop()}}),e)})))}))})).catch((function(a){if(M(a))throw a;ka(2).then((function(){var s=r._createPendingUserMessage(n,u,c),o=ds.of(r._iid).cacheContext.localCacheEnabled&&G(a.code);r._markMessageAsFailed(s,a,o),i.dispatch(new oi({messages:[s],source:s.sendingStatus===e.SendingStatus.PENDING?e.MessageEventSource.REQUEST_RESEND_MESSAGE:e.MessageEventSource.EVENT_MESSAGE_SENT_FAILED})),wa((function(){return b(r,void 0,void 0,t().mark((function e(){return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",l._trigger(a,s));case 1:case"end":return e.stop()}}),e)})))}))}))}));var s=r._createPendingUserMessage(n,u,c);i.dispatch(new oi({messages:[s],source:e.MessageEventSource.EVENT_MESSAGE_SENT_PENDING})),wa((function(){return b(r,void 0,void 0,t().mark((function e(){return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",l._trigger(null,s));case 1:case"end":return e.stop()}}),e)})))}))}))),l}},{key:"_autoResendUserMessage",value:function(e){return Ya(e instanceof qs).throw(A.invalidParameters),this._sendUserMessage(e.messageParams,e.reqId)}},{key:"resendUserMessage",value:function(e){var n;return b(this,void 0,void 0,t().mark((function r(){var a,s;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return Ya(e instanceof qs&&!e.scheduledInfo).throw(A.invalidParameters),a=new ua,s=null!==(n=e.messageParams)&&void 0!==n?n:No(e),this._sendUserMessage(s,e.reqId).onFailed((function(e){return a.reject(e)})).onSucceeded((function(e){return a.resolve(e)})),t.abrupt("return",a.promise);case 5:case"end":return t.stop()}}),r,this)})))}},{key:"updateUserMessage",value:function(e,n){return b(this,void 0,void 0,t().mark((function r(){var a,s,i,o,u,c,l;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return a=Object.assign(Object.assign({},Tl),n),Ya(L("number",e)&&Sl(a)).throw(A.invalidParameters),s=ds.of(this._iid),i=s.requestQueue,o=new Ch(Object.assign({channelType:this.channelType,channelUrl:this.url,messageId:e},a)),t.next=6,i.send(o);case 6:return u=t.sent,c=u.as(Th),l=c.message,t.abrupt("return",l);case 9:case"end":return t.stop()}}),r,this)})))}},{key:"copyUserMessage",value:function(n,r){var a,s,i;return b(this,void 0,void 0,t().mark((function o(){var c,l;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return Ya(n instanceof u&&r instanceof qs&&r.sendingStatus===e.SendingStatus.SUCCEEDED&&this.url===r.channelUrl&&!r.scheduledInfo).throw(A.invalidParameters),Ya(!r.poll).throw(A.notSupportedError),c=new ua,l=null!==(a=r.messageParams)&&void 0!==a?a:Object.assign(Object.assign({},r),{mentionType:r.mentionType,mentionedUserIds:null!==(s=r.mentionedUserIds)&&void 0!==s?s:null===(i=r.mentionedUsers)||void 0===i?void 0:i.map((function(e){return e.userId})),translationTargetLanguages:Object.keys(r.translations),pushNotificationDeliveryOption:e.PushNotificationDeliveryOption.DEFAULT,parentMessageId:null,isReplyToChannel:!1,isPinnedMessage:!1}),n._sendUserMessage(l).onSucceeded((function(e){c.resolve(e)})).onFailed((function(e){return c.reject(e)})),t.abrupt("return",c.promise);case 6:case"end":return t.stop()}}),o,this)})))}},{key:"translateUserMessage",value:function(e,n){return b(this,void 0,void 0,t().mark((function r(){var a,s,i,o,u,c;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return Ya(e instanceof qs&&e.messageId>0&&F("string",n)).throw(A.invalidParameters),a=ds.of(this._iid),s=a.requestQueue,i=new Lh({channelType:this.channelType,channelUrl:this.url,messageId:e.messageId,translationTargetLanguages:n}),t.next=5,s.send(i);case 5:return o=t.sent,u=o.as(Dh),c=u.message,t.abrupt("return",c);case 8:case"end":return t.stop()}}),r,this)})))}},{key:"_createScheduledUserMessage",value:function(e,n){var r=this,a=ds.of(this._iid).requestQueue,s=Date.now(),i=this._generateRequestId();ka(2).then((function(){var a=r._createPendingScheduledUserMessage(e,i,s);wa((function(){return b(r,void 0,void 0,t().mark((function e(){return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",n._trigger(null,a));case 1:case"end":return e.stop()}}),e)})))}))}));var o=new Ph(Object.assign({reqId:i,channelType:this.channelType,channelUrl:this.url},e));a.send(o).then((function(e){var a=e.as(Fh).message;wa((function(){return b(r,void 0,void 0,t().mark((function e(){return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",n._trigger(null,a));case 1:case"end":return e.stop()}}),e)})))}))})).catch((function(a){if(M(a))throw a;ka(2).then((function(){var o=r._createPendingScheduledUserMessage(e,i,s);r._markMessageAsFailed(o,a),wa((function(){return b(r,void 0,void 0,t().mark((function e(){return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",n._trigger(a,o));case 1:case"end":return e.stop()}}),e)})))}))}))}))}},{key:"sendFileMessage",value:function(e){var t=Object.assign(Object.assign({},Do),e);return Ya(Fo(t)).throw(A.invalidParameters),this._sendFileMessage(t)}},{key:"sendMultipleFilesMessage",value:function(e){var t=Object.assign(Object.assign({},Qo),e),n=ds.of(this._iid);Ya(function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:5;return To(e)&&Array.isArray(e.fileInfoList)&&e.fileInfoList.length>=2&&e.fileInfoList.length<=t&&e.fileInfoList.every((function(e){return Ko(e)}))}(t,n.appInfo.multipleFilesMessageFileCountLimit)).throw(A.invalidParameters);var r=!!e.fileInfoList.find((function(e){var t=n.appInfo.uploadSizeLimit;return e.file instanceof Blob&&e.file.size>t||e.fileSize>t}));return Ya(!r).throw(A.fileSizeLimitExceededError),this._sendMultipleFilesMessage(t)}},{key:"_sendFileMessage",value:function(n){var r=this,a=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null,s=ds.of(this._iid).dispatcher,i=Ei.of(this._iid).fileMessageQueue,o=a,u=Date.now(),c=new wi;return o||(o=this._generateRequestId(),ka(2).then((function(){var a=r._createPendingFileMessage(n,o,u);s.dispatch(new oi({messages:[a],source:e.MessageEventSource.EVENT_MESSAGE_SENT_PENDING})),wa((function(){return b(r,void 0,void 0,t().mark((function e(){return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",c._trigger(null,a));case 1:case"end":return e.stop()}}),e)})))})),i.request(r,o,n).then((function(n){s.dispatch(new oi({messages:[n],source:e.MessageEventSource.EVENT_MESSAGE_SENT_SUCCESS})),wa((function(){return b(r,void 0,void 0,t().mark((function e(){return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",c._trigger(null,n));case 1:case"end":return e.stop()}}),e)})))}))})).catch((function(a){if(M(a))throw a;ka(2).then((function(){var i=r._createPendingFileMessage(n,o,u),l=ds.of(r._iid).cacheContext.localCacheEnabled&&G(a.code);r._markMessageAsFailed(i,a,l),s.dispatch(new oi({messages:[i],source:i.sendingStatus===e.SendingStatus.PENDING?e.MessageEventSource.REQUEST_RESEND_MESSAGE:e.MessageEventSource.EVENT_MESSAGE_SENT_FAILED})),wa((function(){return b(r,void 0,void 0,t().mark((function e(){return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",c._trigger(a,i));case 1:case"end":return e.stop()}}),e)})))}))}))}))}))),c}},{key:"_autoResendFileMessage",value:function(e){Ya(e instanceof Bs).throw(A.invalidParameters);var t=ds.of(this._iid).logger;return t.debug("autoResendFileMessage pending",e),this._sendFileMessage(e.messageParams,e.reqId).onFailed((function(e){t.debug("autoResendFileMessage failed",e)})).onSucceeded((function(e){t.debug("autoResendFileMessage success",e)}))}},{key:"_sendMultipleFilesMessage",value:function(n){var r=this,a=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null,s=ds.of(this._iid).dispatcher,i=Ei.of(this._iid).fileMessageQueue,o=a,u=Date.now(),c=new Fi;return o||(o=this._generateRequestId(),ka(2).then((function(){var a=r._createPendingMultipleFilesMessage(n,o,u);s.dispatch(new oi({messages:[a],source:e.MessageEventSource.EVENT_MESSAGE_SENT_PENDING})),wa((function(){return b(r,void 0,void 0,t().mark((function e(){return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",c._trigger(null,a));case 1:case"end":return e.stop()}}),e)})))})),i.request(r,o,n,c).then((function(n){s.dispatch(new oi({messages:[n],source:e.MessageEventSource.EVENT_MESSAGE_SENT_SUCCESS})),wa((function(){return b(r,void 0,void 0,t().mark((function e(){return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",c._trigger(null,n));case 1:case"end":return e.stop()}}),e)})))}))})).catch((function(a){if(M(a))throw a;ka(2).then((function(){var i=r._createPendingMultipleFilesMessage(n,o,u);r._markMessageAsFailed(i,a),s.dispatch(new oi({messages:[i],source:e.MessageEventSource.EVENT_MESSAGE_SENT_FAILED})),wa((function(){return b(r,void 0,void 0,t().mark((function e(){return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",c._trigger(a,i));case 1:case"end":return e.stop()}}),e)})))}))}))}))}))),c}},{key:"_createScheduledFileMessage",value:function(e,n,r,a){var s=this,i=ds.of(this._iid).requestQueue,o=new Gh(Object.assign(Object.assign({reqId:r,channelType:this.channelType,channelUrl:this.url},e),{fileUrl:e.fileUrl,requireAuth:e.requireAuth}));i.send(o).then((function(e){var r=e.as(qh).message;wa((function(){return b(s,void 0,void 0,t().mark((function e(){return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",n._trigger(null,r));case 1:case"end":return e.stop()}}),e)})))}))})).catch((function(i){if(M(i))throw i;ka(2).then((function(){var o=s._createPendingScheduledFileMessage(e,r,a);s._markMessageAsFailed(o,i),wa((function(){return b(s,void 0,void 0,t().mark((function e(){return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",n._trigger(i,o));case 1:case"end":return e.stop()}}),e)})))}))}))}))}},{key:"sendFileMessages",value:function(e){Ya(e.every((function(e){return Fo(Object.assign(Object.assign({},Do),e))}))).throw(A.invalidParameters);var t,n=new wi,r=y(e);try{for(r.s();!(t=r.n()).done;){var a=t.value;this.sendFileMessage(a).onPending((function(e){return n._trigger(null,e)})).onFailed((function(e,t){return n._trigger(e,t)})).onSucceeded((function(e){return n._trigger(null,e)}))}}catch(e){r.e(e)}finally{r.f()}return n}},{key:"resendFileMessage",value:function(e,n){var r;return b(this,void 0,void 0,t().mark((function a(){var s,i,o;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return s=Boolean(e.url)||q(n)||q(null===(r=e.messageParams)||void 0===r?void 0:r.file),Ya(e instanceof Bs&&s&&!e.scheduledInfo).throw(A.invalidParameters),i=new ua,o=Po(e,n),this._sendFileMessage(o,e.reqId).onFailed((function(e){return i.reject(e)})).onSucceeded((function(e){return i.resolve(e)})),t.abrupt("return",i.promise);case 6:case"end":return t.stop()}}),a,this)})))}},{key:"updateFileMessage",value:function(e,n){return b(this,void 0,void 0,t().mark((function r(){var a,s,i,o,u,c,l;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return a=Object.assign(Object.assign({},Il),n),Ya(L("number",e)&&Nl(a)).throw(A.invalidParameters),s=ds.of(this._iid),i=s.requestQueue,o=new Sh(Object.assign({channelType:this.channelType,channelUrl:this.url,messageId:e},a)),t.next=6,i.send(o);case 6:return u=t.sent,c=u.as(Ih),l=c.message,t.abrupt("return",l);case 9:case"end":return t.stop()}}),r,this)})))}},{key:"cancelUploadingFileMessage",value:function(e){return b(this,void 0,void 0,t().mark((function n(){var r;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return Ya(L("string",e)).throw(A.invalidParameters),r=Ei.of(this._iid),r.fileMessageQueue.cancel(this,e),t.abrupt("return",!0);case 4:case"end":return t.stop()}}),n,this)})))}},{key:"copyFileMessage",value:function(n,r){var a,s,i;return b(this,void 0,void 0,t().mark((function o(){var c,l;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return Ya(n instanceof u&&r instanceof Bs&&r.sendingStatus===e.SendingStatus.SUCCEEDED&&this.url===r.channelUrl&&!r.scheduledInfo).throw(A.invalidParameters),c=new ua,l=Object.assign(Object.assign({},r),{fileUrl:r.url,fileName:r.name,fileSize:r.size,mimeType:r.type,mentionType:r.mentionType,mentionedUserIds:null!==(a=r.mentionedUserIds)&&void 0!==a?a:null===(s=r.mentionedUsers)||void 0===s?void 0:s.map((function(e){return e.userId})),pushNotificationDeliveryOption:e.PushNotificationDeliveryOption.DEFAULT,parentMessageId:null,isReplyToChannel:!1,thumbnailSizes:null===(i=r.thumbnails)||void 0===i?void 0:i.map((function(e){return{maxWidth:e.width,maxHeight:e.height}})),requireAuth:r.requireAuth,isPinnedMessage:!1}),n._sendFileMessage(l).onSucceeded((function(e){return c.resolve(e)})).onFailed((function(e){return c.reject(e)})),t.abrupt("return",c.promise);case 5:case"end":return t.stop()}}),o,this)})))}},{key:"deleteMessage",value:function(e){return b(this,void 0,void 0,t().mark((function n(){var r,a,s;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(Ya(e instanceof Is).throw(A.invalidParameters),!(e.messageId>0)){t.next=6;break}return r=ds.of(this._iid),a=r.requestQueue,s=new Nh({channelType:this.channelType,channelUrl:this.url,messageId:e.messageId}),t.next=6,a.send(s);case 6:case"end":return t.stop()}}),n,this)})))}},{key:"addReaction",value:function(e,n){return b(this,void 0,void 0,t().mark((function r(){var a,s,i,o,u,c;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return Ya(e instanceof Is&&e.messageId>0&&L("string",n)).throw(A.invalidParameters),a=ds.of(this._iid),s=a.requestQueue,i=new Ah({channelType:this.channelType,channelUrl:this.url,messageId:e.messageId,reactionKey:n}),t.next=5,s.send(i);case 5:return o=t.sent,u=o.as(Oh),c=u.reactionEvent,t.abrupt("return",c);case 8:case"end":return t.stop()}}),r,this)})))}},{key:"deleteReaction",value:function(e,n){return b(this,void 0,void 0,t().mark((function r(){var a,s,i,o,u,c;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return Ya(e instanceof Is&&e.messageId>0&&L("string",n)).throw(A.invalidParameters),a=ds.of(this._iid),s=a.requestQueue,i=new Uh({channelType:this.channelType,channelUrl:this.url,messageId:e.messageId,reactionKey:n}),t.next=5,s.send(i);case 5:return o=t.sent,u=o.as(Rh),c=u.reactionEvent,t.abrupt("return",c);case 8:case"end":return t.stop()}}),r,this)})))}},{key:"_updateUserMessageMetaArray",value:function(n,r,a,s){return b(this,void 0,void 0,t().mark((function i(){var o,u,c,l,h,d,f;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return o=ds.of(this._iid),u=o.dispatcher,c=o.requestQueue,l=new Ch({channelType:this.channelType,channelUrl:this.url,messageId:n,metaArrayParams:{array:r,mode:a,upsert:s}}),t.next=4,c.send(l);case 4:return h=t.sent,d=h.as(Th),f=d.message,u.dispatch(new oi({messages:[f],source:e.MessageEventSource.EVENT_MESSAGE_UPDATED})),t.abrupt("return",f);case 8:case"end":return t.stop()}}),i,this)})))}},{key:"_updateFileMessageMetaArray",value:function(n,r,a,s){return b(this,void 0,void 0,t().mark((function i(){var o,u,c,l,h,d,f;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return o=ds.of(this._iid),u=o.dispatcher,c=o.requestQueue,l=new Sh({channelType:this.channelType,channelUrl:this.url,messageId:n,metaArrayParams:{array:r,mode:a,upsert:s}}),t.next=4,c.send(l);case 4:return h=t.sent,d=h.as(Ih),f=d.message,u.dispatch(new oi({messages:[f],source:e.MessageEventSource.EVENT_MESSAGE_UPDATED})),t.abrupt("return",f);case 8:case"end":return t.stop()}}),i,this)})))}},{key:"createMessageMetaArrayKeys",value:function(e,n){return b(this,void 0,void 0,t().mark((function r(){var a;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(Ya(e instanceof Is&&e.messageId>0&&F("string",n)).throw(A.invalidParameters),a=n.map((function(e){return new bs({key:e})})),!(e instanceof Bs)){t.next=6;break}return t.abrupt("return",this._updateFileMessageMetaArray(e.messageId,a,"add",!0));case 6:return t.abrupt("return",this._updateUserMessageMetaArray(e.messageId,a,"add",!0));case 7:case"end":return t.stop()}}),r,this)})))}},{key:"deleteMessageMetaArrayKeys",value:function(e,n){return b(this,void 0,void 0,t().mark((function r(){var a;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(Ya(e instanceof Is&&e.messageId>0&&F("string",n)).throw(A.invalidParameters),a=n.map((function(e){return new bs({key:e})})),!(e instanceof Bs)){t.next=6;break}return t.abrupt("return",this._updateFileMessageMetaArray(e.messageId,a,"remove",!0));case 6:return t.abrupt("return",this._updateUserMessageMetaArray(e.messageId,a,"remove",!0));case 7:case"end":return t.stop()}}),r,this)})))}},{key:"addMessageMetaArrayValues",value:function(e,n){return b(this,void 0,void 0,t().mark((function r(){return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(Ya(e instanceof Is&&e.messageId>0&&n.every((function(e){return e instanceof bs}))).throw(A.invalidParameters),!(e instanceof Bs)){t.next=5;break}return t.abrupt("return",this._updateFileMessageMetaArray(e.messageId,n,"add",!0));case 5:return t.abrupt("return",this._updateUserMessageMetaArray(e.messageId,n,"add",!0));case 6:case"end":return t.stop()}}),r,this)})))}},{key:"removeMessageMetaArrayValues",value:function(e,n){return b(this,void 0,void 0,t().mark((function r(){return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(Ya(e instanceof Is&&e.messageId>0&&n.every((function(e){return e instanceof bs}))).throw(A.invalidParameters),!(e instanceof Bs)){t.next=5;break}return t.abrupt("return",this._updateFileMessageMetaArray(e.messageId,n,"remove",!0));case 5:return t.abrupt("return",this._updateUserMessageMetaArray(e.messageId,n,"remove",!0));case 6:case"end":return t.stop()}}),r,this)})))}},{key:"report",value:function(n,r){return b(this,void 0,void 0,t().mark((function a(){var s,i,o,u;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return Ya(D(e.ReportCategory,n)&&L("string",r)).throw(A.invalidParameters),s=ds.of(this._iid),i=s.sdkState,o=s.requestQueue,u=new kh({channelUrl:this.url,channelType:this.channelType,userId:i.userId,category:n,description:r}),t.next=5,o.send(u);case 5:case"end":return t.stop()}}),a,this)})))}},{key:"reportUser",value:function(n,r,a){return b(this,void 0,void 0,t().mark((function s(){var i,o,u,c;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return Ya(n instanceof Ja&&D(e.ReportCategory,r)&&L("string",a)).throw(A.invalidParameters),i=ds.of(this._iid),o=i.sdkState,u=i.requestQueue,c=new bh({channelUrl:this.url,channelType:this.channelType,userId:o.userId,offendingUserId:n.userId,category:r,description:a}),t.next=5,u.send(c);case 5:case"end":return t.stop()}}),s,this)})))}},{key:"reportMessage",value:function(n,r,a){return b(this,void 0,void 0,t().mark((function s(){var i,o,u,c;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return Ya(n instanceof Ns&&D(e.ReportCategory,r)&&L("string",a)).throw(A.invalidParameters),i=ds.of(this._iid),o=i.sdkState,u=i.requestQueue,c=new Eh({channelUrl:this.url,channelType:this.channelType,userId:o.userId,offendingUserId:n.sender.userId,messageId:n.messageId,category:r,description:a}),t.next=5,u.send(c);case 5:case"end":return t.stop()}}),s,this)})))}},{key:"updatePoll",value:function(e,n){return b(this,void 0,void 0,t().mark((function r(){var a,s,i,o,u,c;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return Ya(L("number",e)&&Hh(n)).throw(A.invalidParameters),a=ds.of(this._iid),s=a.requestQueue,i=new jh(Object.assign({pollId:e},n)),t.next=5,s.send(i);case 5:return o=t.sent,u=o.as(zh),c=u.poll,t.abrupt("return",c);case 8:case"end":return t.stop()}}),r,this)})))}},{key:"deletePoll",value:function(e){return b(this,void 0,void 0,t().mark((function n(){var r,a,s,i;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return r=L("number",e),Ya(r).throw(A.invalidParameters),a=ds.of(this._iid),s=a.requestQueue,i=new Vh({pollId:e}),t.next=6,s.send(i);case 6:case"end":return t.stop()}}),n,this)})))}},{key:"closePoll",value:function(e){return b(this,void 0,void 0,t().mark((function n(){var r,a,s,i,o,u,c;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return r=L("number",e),Ya(r).throw(A.invalidParameters),a=ds.of(this._iid),s=a.requestQueue,i=new Bh({pollId:e}),t.next=6,s.send(i);case 6:return o=t.sent,u=o.as(Qh),c=u.poll,t.abrupt("return",c);case 9:case"end":return t.stop()}}),n,this)})))}},{key:"addPollOption",value:function(e,n){return b(this,void 0,void 0,t().mark((function r(){var a,s,i,o,u,c,l;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return a=L("number",e)&&L("string",n)&&""!==n.trim(),Ya(a).throw(A.invalidParameters),s=ds.of(this._iid),i=s.requestQueue,o=new Kh({channelUrl:this.url,channelType:this.channelType,pollId:e,optionText:n}),t.next=6,i.send(o);case 6:return u=t.sent,c=u.as(Wh),l=c.poll,t.abrupt("return",l);case 9:case"end":return t.stop()}}),r,this)})))}},{key:"updatePollOption",value:function(e,n,r){return b(this,void 0,void 0,t().mark((function a(){var s,i,o,u,c,l,h;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return s=L("number",e)&&L("number",n)&&L("string",r)&&""!==r.trim(),Ya(s).throw(A.invalidParameters),i=ds.of(this._iid),o=i.requestQueue,u=new Yh({pollId:e,pollOptionId:n,optionText:r}),t.next=6,o.send(u);case 6:return c=t.sent,l=c.as(Zh),h=l.poll,t.abrupt("return",h);case 9:case"end":return t.stop()}}),a,this)})))}},{key:"deletePollOption",value:function(e,n){return b(this,void 0,void 0,t().mark((function r(){var a,s,i,o;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return a=L("number",e)&&L("number",n),Ya(a).throw(A.invalidParameters),s=ds.of(this._iid),i=s.requestQueue,o=new Jh({pollId:e,pollOptionId:n}),t.next=6,i.send(o);case 6:case"end":return t.stop()}}),r,this)})))}},{key:"votePoll",value:function(n,r){return b(this,void 0,void 0,t().mark((function a(){var s,i,o,u,c,l,h,d;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return s=L("number",n)&&F("number",r),Ya(s).throw(A.invalidParameters),i=ds.of(this._iid),o=i.requestQueue,u=i.dispatcher,c=new Xh({reqId:this._generateRequestId(),channelUrl:this.url,channelType:this.channelType,pollId:n,pollOptionIds:r}),t.next=6,o.send(c);case 6:return l=t.sent,h=l.as($h),d=h.event,u.dispatch(new di({event:d,source:e.MessageEventSource.EVENT_POLL_VOTED})),t.abrupt("return",d);case 10:case"end":return t.stop()}}),a,this)})))}},{key:"getPollChangeLogsSinceTimestamp",value:function(e){return b(this,void 0,void 0,t().mark((function n(){var r;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return Ya(L("number",e)).throw(A.invalidParameters),r=to.of(this._iid),t.next=4,r.getPollChangeLogs(this.url,this.channelType,e);case 4:return t.abrupt("return",t.sent);case 5:case"end":return t.stop()}}),n,this)})))}},{key:"getPollChangeLogsSinceToken",value:function(e){return b(this,void 0,void 0,t().mark((function n(){var r;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return Ya(L("string",e,!0)),r=to.of(this._iid),t.next=4,r.getPollChangeLogs(this.url,this.channelType,e);case 4:return t.abrupt("return",t.sent);case 5:case"end":return t.stop()}}),n,this)})))}},{key:"createPollListQuery",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:10;return new io(this._iid,{channelUrl:this.url,channelType:this.channelType,limit:e})}},{key:"createPollVoterListQuery",value:function(e,t){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:20;return new co(this._iid,{channelUrl:this.url,channelType:this.channelType,pollId:e,pollOptionId:t,limit:n})}}],[{key:"payloadify",value:function(e){return ue(Object.assign(Object.assign({},p(o(u),"payloadify",this).call(this,e)),{channel_url:e.url,name:e.name,cover_url:e.coverUrl,custom_type:e.customType,data:e.data,freeze:e.isFrozen,is_ephemeral:e.isEphemeral,created_by:Ja.payloadify(e.creator),created_at:e.createdAt/1e3}))}}]),u}(qa),td=null,nd=function(){function n(e,a,s){var i=this;r(this,n),this._storeInitialized=!1,this._fcmPushToken=null,this._apnsPushToken=null,this._iid=e,this.options=a;var o=ds.of(e),u=o.sdkState,c=o.cacheContext,l=o.dispatcher,h=o.sessionManager,d=o.requestQueue,f=o.logger,p=o.userEventHandlers,v=o.appStateToggleEnabled;this._onlineDetector=new nu({logger:f,connectionDelegate:{reconnect:function(){var t=ds.of(e),n=t.sdkState,r=t.connectionManager,a=t.sessionManager;a.auth.hasSession?"foreground"===n.appState&&r.resetAndReconnect():r.connect(a.auth.authToken)},disconnect:function(){ds.of(e).connectionManager.disconnect()}}});var _=new su(e,{localCacheEnabled:c.localCacheEnabled,dispatcher:l,sdkState:u,logger:f});s.forEach((function(t){t.init(e,{sdkState:u,cacheContext:c,dispatcher:l,sessionManager:h,requestQueue:d,logger:f,onlineDetector:i._onlineDetector}),i[t.name]=t})),this._appStateChangeDetector=new tu({isEnabled:v}),this._appStateChangeDetector.on("resume",(function(){f.debug("the page resumes from freeze"),i.setForegroundState()})).on("pause",(function(){f.debug("the page freezes"),i.setBackgroundState()})),l.on((function(n){if(n instanceof ha){if(n.stateType===aa.CONNECTED)_.processNonAutoResendRegisteredPendingMessages()}else if(n instanceof Ge){if("USEV"===n.code){var r=n.as(pu).event;if(r.category===Ho.FRIEND_DISCOVERED){var a=ou.getDataAsFriendDiscoveredEvent(e,r).friendDiscoveries;wa((function(){return b(i,void 0,void 0,t().mark((function e(){return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",p.forEach((function(e){e.onFriendsDiscovered(a)})));case 1:case"end":return e.stop()}}),e)})))}))}}}else if(n instanceof oa){var s=ds.of(i._iid).subscribedUnreadMessageCount,o=!1,l=n.ts;if("number"==typeof l&&l>s.ts){if(s.all!==n.all&&(o=!0),s.all=n.all>=0?n.all:0,n.customTypes)for(var h in n.customTypes)s.customTypes[h]!==n.customTypes[h]&&(o=!0),s.customTypes[h]=n.customTypes[h];o=o&&s.ts>0,s.ts=l}o&&wa((function(){return b(i,void 0,void 0,t().mark((function e(){return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",p.forEach((function(e){e.onTotalUnreadMessageCountUpdated(s.all,s.customTypes)})));case 1:case"end":return e.stop()}}),e)})))}))}else n instanceof Xa?c.preference.set(i._getUserProfileCacheKey(u.userId),$a.payloadify(n.userProfile)):n instanceof Re&&n.error&&n.error.isSessionRevokedError&&(f.debug("session revoked."),i.disconnect())}))}return s(n,[{key:"appId",get:function(){return ds.of(this._iid).sdkState.appId}},{key:"appInfo",get:function(){return ds.of(this._iid).appInfo}},{key:"appVersion",get:function(){var e;return null!==(e=ds.of(this._iid).sdkState.appVersion)&&void 0!==e?e:""}},{key:"debugMode",get:function(){return ds.of(this._iid).debugMode}},{key:"logLevel",get:function(){return ds.of(this._iid).logger.level},set:function(e){ds.of(this._iid).logger.level=e}},{key:"isCacheEnabled",get:function(){return ds.of(this._iid).cacheContext.localCacheEnabled}},{key:"localCacheConfig",get:function(){var e=ds.of(this._iid).cacheContext;return e.localCacheEnabled?e.localCacheConfig:null}},{key:"ekey",get:function(){return ds.of(this._iid).sessionManager.ekey}},{key:"currentUser",get:function(){var e;return null!==(e=ds.of(this._iid).sessionManager.currentUser)&&void 0!==e?e:null}},{key:"connectionState",get:function(){var t=ds.of(this._iid).connectionManager;return t.isConnected?e.ConnectionState.OPEN:t.isConnecting?e.ConnectionState.CONNECTING:e.ConnectionState.CLOSED}},{key:"lastConnectedAt",get:function(){var e=ds.of(this._iid),t=e.connectedAt;return e.connectionManager.isConnected?t:0}},{key:"fcmPushToken",get:function(){return this._fcmPushToken}},{key:"apnsPushToken",get:function(){return this._apnsPushToken}},{key:"_getCurrentPreferenceVersion",value:function(){return 1}},{key:"_getPreferenceCacheKey",value:function(e){return"sendbird@".concat(this.appId,"/").concat(e,".pref")}},{key:"_getUserProfileCacheKey",value:function(e){return"sendbird@".concat(this.appId,"/").concat(e,".profile")}},{key:"getMemoryStoreForDebugging",value:function(){var e=ds.of(this._iid),t=e.debugMode,n=e.cacheContext;if(t)return n.store instanceof cl?n.store:null;throw A.debugModeRequired}},{key:"addExtension",value:function(e,t){var n=ds.of(this._iid).sdkState;["sb_uikit","sb_syncmanager","device-os-platform"].indexOf(e)>-1&&(n.extensions[e]=t)}},{key:"setOnlineListener",value:function(e){this._onlineDetector.setOnlineListener(e)}},{key:"setOfflineListener",value:function(e){this._onlineDetector.setOfflineListener(e)}},{key:"_safeInitializeStore",value:function(e){return b(this,void 0,void 0,t().mark((function n(){var r,a;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return r=ds.of(this._iid),a=r.cacheContext,t.prev=1,t.next=4,a.store.init(e);case 4:this._storeInitialized=!0,t.next=12;break;case 7:return t.prev=7,t.t0=t.catch(1),a.store=new cl,t.next=12,this._safeInitializeStore(e);case 12:case"end":return t.stop()}}),n,this,[[1,7]])})))}},{key:"initializeCache",value:function(e){return b(this,void 0,void 0,t().mark((function n(){var r,a,s,i,o,u,c,l;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(r=ds.of(this._iid),a=r.sdkState,s=r.cacheContext,i=r.connectionManager,o=r.dispatcher,u=r.logger,a.userId&&a.userId===e){t.next=30;break}return t.next=4,i.logout();case 4:if(c="sendbird@".concat(a.appId,"/").concat(e,".db"),!s.localCacheEnabled){t.next=27;break}if(t.prev=6,s.nestdb&&s.nestdb.state!==hl.CLOSED&&s.nestdb.name===c){t.next=15;break}return(l=s.nestdb=new yl({name:"sendbird@".concat(a.appId,"/").concat(e,".db"),version:2,store:s.store})).on("upgrade",Jo(l,s.store)),l.on("storeReplaced",(function(e){s.replaceStore(e),s.localCacheEnabled=!1,l.on("upgrade",Jo(l,s.store))})),t.next=13,l.open();case 13:this._storeInitialized=!0,o.dispatch(new uu(this._iid,{userId:e}));case 15:a.userId=e,t.next=25;break;case 18:return t.prev=18,t.t0=t.catch(6),u.warn("Nest DB Open Failed. ",t.t0),t.next=23,this._safeInitializeStore(c);case 23:throw a.userId=e,A.databaseError;case 25:t.next=30;break;case 27:return t.next=29,this._safeInitializeStore(c);case 29:a.userId=e;case 30:case"end":return t.stop()}}),n,this,[[6,18]])})))}},{key:"getCacheDataSize",value:function(){return b(this,void 0,void 0,t().mark((function e(){var n,r;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(n=ds.of(this._iid),!(r=n.cacheContext).localCacheEnabled||!r.nestdb){e.next=5;break}return e.next=4,r.nestdb.estimateUsage();case 4:return e.abrupt("return",e.sent);case 5:return e.abrupt("return",0);case 6:case"end":return e.stop()}}),e,this)})))}},{key:"clearCachedData",value:function(){return b(this,void 0,void 0,t().mark((function e(){var n,r;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(n=ds.of(this._iid),!(r=n.cacheContext).localCacheEnabled){e.next=5;break}if(!r.nestdb){e.next=5;break}return e.next=5,r.nestdb.clear();case 5:if(!this._storeInitialized){e.next=8;break}return e.next=8,r.preference.clear();case 8:case"end":return e.stop()}}),e,this)})))}},{key:"clearCachedMessages",value:function(e){return b(this,void 0,void 0,t().mark((function n(){var r,a,s=this;return t().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:if(Ya(F("string",e)).throw(A.invalidParameters),r=$o.of(this._iid),a=Zo.of(this._iid),!r||!a){n.next=6;break}return n.next=6,Promise.all(e.map((function(e){return b(s,void 0,void 0,t().mark((function n(){return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,r.removeMessagesOfChannel(e);case 2:return t.next=4,a.removeMessagesOfChannel(e);case 4:case"end":return t.stop()}}),n)})))})));case 6:case"end":return n.stop()}}),n,this)})))}},{key:"connect",value:function(e){var n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null;return b(this,void 0,void 0,t().mark((function r(){var a,s,i,o,u,c,l,h,d;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return Ya(L("string",e)&&L("string",n,!0)).throw(A.invalidParameters),a=ds.of(this._iid),s=a.sdkState,i=a.cacheContext,o=a.connectionManager,u=a.statLogCollector,t.prev=2,t.next=5,this.initializeCache(e);case 5:c=ds.of(this._iid),c.dispatcher.dispatch(new fu),t.next=14;break;case 9:t.prev=9,t.t0=t.catch(2),l=ds.of(this._iid),h=l.logger,i.localCacheEnabled=!1,h.warn("Cache initialization failed - cache is not available.");case 14:return t.next=16,i.preference.init(this._getPreferenceCacheKey(e),this._getCurrentPreferenceVersion());case 16:return t.next=18,i.preference.get(this._getUserProfileCacheKey(e));case 18:return(d=t.sent)&&new $a(this._iid,d).apply(),t.next=22,u.init("sendbird@".concat(s.appId,"/").concat(e,".statlog"));case 22:return t.prev=22,t.next=25,o.connect(n);case 25:return t.prev=25,this._onlineDetector.start(),this._appStateChangeDetector.start(),t.finish(25);case 29:return t.abrupt("return",this.currentUser);case 30:case"end":return t.stop()}}),r,this,[[2,9],[22,,25,29]])})))}},{key:"reconnect",value:function(){var e=ds.of(this._iid),t=e.connectionManager,n=e.sdkState,r=e.sessionManager.auth.hasSession;return r&&(this._appStateChangeDetector.start(),this._onlineDetector.start(),t.resetAndReconnect().then((function(){n.appState="foreground"})).catch((function(){}))),r}},{key:"disconnect",value:function(){return b(this,void 0,void 0,t().mark((function e(){var n,r,a;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n=ds.of(this._iid),r=n.connectionManager,a=n.requestQueue,this._appStateChangeDetector.stop(),this._onlineDetector.stop(),a.cancelAll(),e.next=6,r.logout();case 6:return e.next=8,this.clearCachedData();case 8:case"end":return e.stop()}}),e,this)})))}},{key:"disconnectWebSocket",value:function(){return b(this,void 0,void 0,t().mark((function e(){var n,r,a;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n=ds.of(this._iid),r=n.connectionManager,a=n.requestQueue,this._appStateChangeDetector.stop(),this._onlineDetector.stop(),a.cancelAll(),e.next=6,r.disconnectWebSocket();case 6:case"end":return e.stop()}}),e,this)})))}},{key:"setBackgroundState",value:function(){var e=ds.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())}},{key:"setForegroundState",value:function(){var e=ds.of(this._iid),t=e.connectionManager,n=e.sdkState,r=e.logger;"background"===n.appState&&(n.appState="foreground",r.debug("going foreground state"),t.resetAndReconnect())}},{key:"setSessionHandler",value:function(e){Ya(e instanceof po).throw(A.invalidParameters),ds.of(this._iid).sessionManager.handler=e}},{key:"addUserEventHandler",value:function(e,t){Ya(L("string",e)&&t instanceof _o).throw(A.invalidParameters),ds.of(this._iid).userEventHandlers.set(e,t)}},{key:"removeUserEventHandler",value:function(e){ds.of(this._iid).userEventHandlers.delete(e)}},{key:"removeAllUserEventHandler",value:function(){ds.of(this._iid).userEventHandlers.clear()}},{key:"addConnectionHandler",value:function(e,t){Ya(L("string",e)&&t instanceof vo).throw(A.invalidParameters),ds.of(this._iid).connectionHandlers.set(e,t)}},{key:"removeConnectionHandler",value:function(e){ds.of(this._iid).connectionHandlers.delete(e)}},{key:"removeAllConnectionHandler",value:function(){ds.of(this._iid).connectionHandlers.clear()}},{key:"createApplicationUserListQuery",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return new mc(this._iid,e)}},{key:"createBlockedUserListQuery",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return new kc(this._iid,e)}},{key:"createFriendListQuery",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return new wc(this._iid,e)}},{key:"createMessageSearchQuery",value:function(e){return new Ui(this._iid,e)}},{key:"createPollListQuery",value:function(e){return new io(this._iid,Object.assign({},e))}},{key:"createPollVoterListQuery",value:function(e){return new co(this._iid,Object.assign({},e))}},{key:"buildUserFromSerializedData",value:function(e){var t=Wa(e);return new Ja(this._iid,Ja.payloadify(t))}},{key:"updateCurrentUserInfo",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return b(this,void 0,void 0,t().mark((function n(){var r,a,s,i,o,u,c,l;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(r=Object.assign(Object.assign({},ho),e),Ya(fo(r)).throw(A.invalidParameters),!this.currentUser){t.next=13;break}return a=ds.of(this._iid),s=a.sdkState,i=a.requestQueue,o=new vu(Object.assign({userId:s.userId},r)),t.next=7,i.send(o);case 7:return u=t.sent,c=u.as(_u),l=c.user,this.currentUser&&(r.nickname&&(this.currentUser.nickname=l.nickname),(r.profileUrl||r.profileImage)&&(this.currentUser.plainProfileUrl=l.profileUrl)),t.abrupt("return",l);case 13:throw A.connectionRequired;case 14:case"end":return t.stop()}}),n,this)})))}},{key:"updateCurrentUserInfoWithPreferredLanguages",value:function(e){return b(this,void 0,void 0,t().mark((function n(){var r,a,s,i,o,u,c;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(Ya(F("string",e)).throw(A.invalidParameters),!this.currentUser){t.next=12;break}return r=ds.of(this._iid),a=r.sdkState,s=r.requestQueue,i=new vu({userId:a.userId,preferredLanguages:e}),t.next=6,s.send(i);case 6:return o=t.sent,u=o.as(_u),c=u.user,this.currentUser&&(this.currentUser.preferredLanguages=c.preferredLanguages),t.abrupt("return",c);case 12:throw A.connectionRequired;case 13:case"end":return t.stop()}}),n,this)})))}},{key:"registerFCMPushTokenForCurrentUser",value:function(n){return b(this,void 0,void 0,t().mark((function r(){var a,s,i,o,u,c=this;return t().wrap((function(r){for(;;)switch(r.prev=r.next){case 0:if(Ya(L("string",n)).throw(A.invalidParameters),!this.currentUser){r.next=20;break}if(r.prev=2,a=ds.of(this._iid),s=a.sessionManager,i=a.sdkState,o=a.requestQueue,!s.hasDeviceToken(e.PushTokenType.FCM,n)){r.next=6;break}return r.abrupt("return",e.PushTokenRegistrationState.SUCCESS);case 6:return u=new gu({userId:i.userId,token:n}),r.next=9,o.send(u);case 9:return r.next=11,xa((function(){return b(c,void 0,void 0,t().mark((function r(){return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return s.setDeviceToken(e.PushTokenType.FCM,n),t.next=3,s.saveDeviceToken();case 3:case"end":return t.stop()}}),r)})))}));case 11:return this._fcmPushToken="",r.abrupt("return",e.PushTokenRegistrationState.SUCCESS);case 15:return r.prev=15,r.t0=r.catch(2),r.abrupt("return",e.PushTokenRegistrationState.ERROR);case 18:r.next=22;break;case 20:return this._fcmPushToken=n,r.abrupt("return",e.PushTokenRegistrationState.PENDING);case 22:case"end":return r.stop()}}),r,this,[[2,15]])})))}},{key:"unregisterFCMPushTokenForCurrentUser",value:function(n){return b(this,void 0,void 0,t().mark((function r(){var a,s,i,o,u,c,l,h=this;return t().wrap((function(r){for(;;)switch(r.prev=r.next){case 0:if(Ya(L("string",n)).throw(A.invalidParameters),!this.currentUser){r.next=20;break}return r.prev=2,a=ds.of(this._iid),s=a.sessionManager,i=a.sdkState,o=a.requestQueue,u=new ku({userId:i.userId,token:n}),r.next=7,o.send(u);case 7:return c=r.sent,l=c.lastDeletedAt,r.next=11,xa((function(){return b(h,void 0,void 0,t().mark((function r(){return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return s.unsetDeviceToken(e.PushTokenType.FCM,n),s.setDeviceTokenDeletedAt(l),t.next=4,s.saveDeviceToken();case 4:case"end":return t.stop()}}),r)})))}));case 11:return this._fcmPushToken="",r.abrupt("return",e.PushTokenRegistrationState.SUCCESS);case 15:return r.prev=15,r.t0=r.catch(2),r.abrupt("return",e.PushTokenRegistrationState.ERROR);case 18:r.next=22;break;case 20:return this._fcmPushToken=n,r.abrupt("return",e.PushTokenRegistrationState.PENDING);case 22:case"end":return r.stop()}}),r,this,[[2,15]])})))}},{key:"unregisterFCMPushTokenAllForCurrentUser",value:function(){return b(this,void 0,void 0,t().mark((function n(){var r,a,s,i,o,u,c,l=this;return t().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:if(!this.currentUser){n.next=9;break}return r=ds.of(this._iid),a=r.sessionManager,s=r.sdkState,i=r.requestQueue,o=new Eu({userId:s.userId}),n.next=5,i.send(o);case 5:return u=n.sent,c=u.lastDeletedAt,n.next=9,xa((function(){return b(l,void 0,void 0,t().mark((function n(){return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return a.unsetDeviceTokens(e.PushTokenType.FCM),a.setDeviceTokenDeletedAt(c),t.next=4,a.saveDeviceToken();case 4:case"end":return t.stop()}}),n)})))}));case 9:case"end":return n.stop()}}),n,this)})))}},{key:"registerAPNSPushTokenForCurrentUser",value:function(n){return b(this,void 0,void 0,t().mark((function r(){var a,s,i,o,u,c=this;return t().wrap((function(r){for(;;)switch(r.prev=r.next){case 0:if(Ya(L("string",n)).throw(A.invalidParameters),!this.currentUser){r.next=20;break}if(r.prev=2,a=ds.of(this._iid),s=a.sessionManager,i=a.sdkState,o=a.requestQueue,!s.hasDeviceToken(e.PushTokenType.APNS,n)){r.next=6;break}return r.abrupt("return",e.PushTokenRegistrationState.SUCCESS);case 6:return u=new mu({userId:i.userId,token:n}),r.next=9,o.send(u);case 9:return r.next=11,xa((function(){return b(c,void 0,void 0,t().mark((function r(){return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return s.setDeviceToken(e.PushTokenType.APNS,n),t.next=3,s.saveDeviceToken();case 3:case"end":return t.stop()}}),r)})))}));case 11:return this._apnsPushToken="",r.abrupt("return",e.PushTokenRegistrationState.SUCCESS);case 15:return r.prev=15,r.t0=r.catch(2),r.abrupt("return",e.PushTokenRegistrationState.ERROR);case 18:r.next=22;break;case 20:return this._apnsPushToken=n,r.abrupt("return",e.PushTokenRegistrationState.PENDING);case 22:case"end":return r.stop()}}),r,this,[[2,15]])})))}},{key:"unregisterAPNSPushTokenForCurrentUser",value:function(n){return b(this,void 0,void 0,t().mark((function r(){var a,s,i,o,u,c,l,h=this;return t().wrap((function(r){for(;;)switch(r.prev=r.next){case 0:if(Ya(L("string",n)).throw(A.invalidParameters),!this.currentUser){r.next=20;break}return r.prev=2,a=ds.of(this._iid),s=a.sessionManager,i=a.sdkState,o=a.requestQueue,u=new yu({userId:i.userId,token:n}),r.next=7,o.send(u);case 7:return c=r.sent,l=c.lastDeletedAt,r.next=11,xa((function(){return b(h,void 0,void 0,t().mark((function r(){return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return s.unsetDeviceToken(e.PushTokenType.APNS,n),s.setDeviceTokenDeletedAt(l),t.next=4,s.saveDeviceToken();case 4:case"end":return t.stop()}}),r)})))}));case 11:return this._apnsPushToken="",r.abrupt("return",e.PushTokenRegistrationState.SUCCESS);case 15:return r.prev=15,r.t0=r.catch(2),r.abrupt("return",e.PushTokenRegistrationState.ERROR);case 18:r.next=22;break;case 20:return this._apnsPushToken=n,r.abrupt("return",e.PushTokenRegistrationState.PENDING);case 22:case"end":return r.stop()}}),r,this,[[2,15]])})))}},{key:"unregisterAPNSPushTokenAllForCurrentUser",value:function(){return b(this,void 0,void 0,t().mark((function n(){var r,a,s,i,o,u,c,l=this;return t().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:if(!this.currentUser){n.next=9;break}return r=ds.of(this._iid),a=r.sessionManager,s=r.sdkState,i=r.requestQueue,o=new bu({userId:s.userId}),n.next=5,i.send(o);case 5:return u=n.sent,c=u.lastDeletedAt,n.next=9,xa((function(){return b(l,void 0,void 0,t().mark((function n(){return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return a.unsetDeviceTokens(e.PushTokenType.APNS),a.setDeviceTokenDeletedAt(c),t.next=4,a.saveDeviceToken();case 4:case"end":return t.stop()}}),n)})))}));case 9:case"end":return n.stop()}}),n,this)})))}},{key:"getChannelInvitationPreference",value:function(){return b(this,void 0,void 0,t().mark((function e(){var n,r,a,s,i,o,u;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n=ds.of(this._iid),r=n.sdkState,a=n.requestQueue,s=new Cu({userId:r.userId}),e.next=4,a.send(s);case 4:return i=e.sent,o=i.as(Tu),u=o.autoAccept,e.abrupt("return",{autoAccept:u});case 7:case"end":return e.stop()}}),e,this)})))}},{key:"setChannelInvitationPreference",value:function(e){return b(this,void 0,void 0,t().mark((function n(){var r,a,s,i,o,u,c;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return Ya(L("boolean",e)).throw(A.invalidParameters),r=ds.of(this._iid),a=r.sdkState,s=r.requestQueue,i=new Su({userId:a.userId,willAutoAccept:e}),t.next=5,s.send(i);case 5:return o=t.sent,u=o.as(Iu),c=u.autoAccept,t.abrupt("return",{autoAccept:c});case 8:case"end":return t.stop()}}),n,this)})))}},{key:"getDoNotDisturb",value:function(){return b(this,void 0,void 0,t().mark((function e(){var n,r,a,s,i,o,u;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n=ds.of(this._iid),r=n.sdkState,a=n.requestQueue,s=new Nu({userId:r.userId}),e.next=4,a.send(s);case 4:return i=e.sent,o=i.as(Mu),u=o.preference,e.abrupt("return",u);case 7:case"end":return e.stop()}}),e,this)})))}},{key:"setDoNotDisturb",value:function(e){var n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:0,a=arguments.length>3&&void 0!==arguments[3]?arguments[3]:0,s=arguments.length>4&&void 0!==arguments[4]?arguments[4]:0,i=arguments.length>5&&void 0!==arguments[5]?arguments[5]:"";return b(this,void 0,void 0,t().mark((function o(){var u,c,l,h,d,f,p;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return Ya(L("boolean",e)&&L("number",n)&&L("number",r)&&L("number",a)&&L("number",s)&&L("string",i)).throw(A.invalidParameters),u=ds.of(this._iid),c=u.sdkState,l=u.requestQueue,h=new Au({userId:c.userId,doNotDisturbOn:e,startHour:n,startMin:r,endHour:a,endMin:s,timezone:i}),t.next=5,l.send(h);case 5:return d=t.sent,f=d.as(Ou),p=f.preference,t.abrupt("return",p);case 8:case"end":return t.stop()}}),o,this)})))}},{key:"getSnoozePeriod",value:function(){return b(this,void 0,void 0,t().mark((function e(){var n,r,a,s,i,o,u;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n=ds.of(this._iid),r=n.sdkState,a=n.requestQueue,s=new Uu({userId:r.userId}),e.next=4,a.send(s);case 4:return i=e.sent,o=i.as(Ru),u=o.snoozePeriod,e.abrupt("return",u);case 7:case"end":return e.stop()}}),e,this)})))}},{key:"setSnoozePeriod",value:function(e){var n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:0;return b(this,void 0,void 0,t().mark((function a(){var s,i,o,u,c,l,h;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return Ya(L("boolean",e)&&L("number",n)&&L("number",r)).throw(A.invalidParameters),s=ds.of(this._iid),i=s.sdkState,o=s.requestQueue,u=new Lu({userId:i.userId,snoozeOn:e,startTs:n,endTs:r}),t.next=5,o.send(u);case 5:return c=t.sent,l=c.as(Du),h=l.snoozePeriod,t.abrupt("return",h);case 8:case"end":return t.stop()}}),a,this)})))}},{key:"getMyPushTokensByToken",value:function(n,r){return b(this,void 0,void 0,t().mark((function a(){var s,i,o,u,c,l,h,d,f,p,v;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return Ya(L("string",n)&&D(e.PushTokenType,r)).throw(A.invalidParameters),s=ds.of(this._iid),i=s.sdkState,o=s.requestQueue,u=s.sessionManager,c=new wu({userId:i.userId,type:r,token:n}),t.next=5,o.send(c);case 5:l=t.sent,h=l.as(xu),d=h.pushTokens,f=y(d.deviceTokens);try{for(f.s();!(p=f.n()).done;)v=p.value,u.setDeviceToken(d.type,v)}catch(e){f.e(e)}finally{f.f()}return t.next=11,u.saveDeviceToken();case 11:return t.abrupt("return",d);case 12:case"end":return t.stop()}}),a,this)})))}},{key:"getPushTriggerOption",value:function(){return b(this,void 0,void 0,t().mark((function e(){var n,r,a,s,i;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n=ds.of(this._iid),r=n.sdkState,a=n.requestQueue,s=new Gu({userId:r.userId}),e.next=4,a.send(s);case 4:return i=e.sent,e.abrupt("return",i.as(qu).pushTriggerOption);case 6:case"end":return e.stop()}}),e,this)})))}},{key:"setPushTriggerOption",value:function(n){return b(this,void 0,void 0,t().mark((function r(){var a,s,i,o,u;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return Ya(D(e.PushTriggerOption,n)).throw(A.invalidParameters),a=ds.of(this._iid),s=a.sdkState,i=a.requestQueue,o=new Hu({userId:s.userId,pushTriggerOption:n}),t.next=5,i.send(o);case 5:return u=t.sent,t.abrupt("return",u.as(ju).pushTriggerOption);case 7:case"end":return t.stop()}}),r,this)})))}},{key:"getPushTemplate",value:function(){return b(this,void 0,void 0,t().mark((function e(){var n,r,a,s,i;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n=ds.of(this._iid),r=n.sdkState,a=n.requestQueue,s=new zu({userId:r.userId}),e.next=4,a.send(s);case 4:return i=e.sent,e.abrupt("return",i.as(Vu).name);case 6:case"end":return e.stop()}}),e,this)})))}},{key:"setPushTemplate",value:function(n){return b(this,void 0,void 0,t().mark((function r(){var a,s,i,o,u;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return Ya(D(e.PushTemplate,n)).throw(A.invalidParameters),a=ds.of(this._iid),s=a.sdkState,i=a.requestQueue,o=new Bu({userId:s.userId,templateName:n}),t.next=5,i.send(o);case 5:return u=t.sent,t.abrupt("return",u.as(Qu).name);case 7:case"end":return t.stop()}}),r,this)})))}},{key:"blockUser",value:function(e){return b(this,void 0,void 0,t().mark((function n(){var r,a,s,i;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return Ya(e instanceof Ja||L("string",e)).throw(A.invalidParameters),r=ds.of(this._iid),a=r.sdkState,s=r.requestQueue,i=new Pu({userId:a.userId,blockedUserId:e instanceof Ja?e.userId:e}),t.next=5,s.send(i);case 5:case"end":return t.stop()}}),n,this)})))}},{key:"blockUserWithUserId",value:function(e){return b(this,void 0,void 0,t().mark((function n(){return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.abrupt("return",this.blockUser(e));case 1:case"end":return t.stop()}}),n,this)})))}},{key:"unblockUser",value:function(e){return b(this,void 0,void 0,t().mark((function n(){var r,a,s,i;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return Ya(e instanceof Ja||L("string",e)).throw(A.invalidParameters),r=ds.of(this._iid),a=r.sdkState,s=r.requestQueue,i=new Fu({userId:a.userId,unblockedUserId:e instanceof Ja?e.userId:e}),t.next=5,s.send(i);case 5:case"end":return t.stop()}}),n,this)})))}},{key:"unblockUserWithUserId",value:function(e){return b(this,void 0,void 0,t().mark((function n(){return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.abrupt("return",this.unblockUser(e));case 1:case"end":return t.stop()}}),n,this)})))}},{key:"getFriendChangeLogsByToken",value:function(e){return b(this,void 0,void 0,t().mark((function n(){var r,a,s,i,o,u,c;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return Ya(L("string",e)).throw(A.invalidParameters),r=ds.of(this._iid),a=r.sdkState,s=r.requestQueue,i=new Ku({userId:a.userId,token:e}),t.next=5,s.send(i);case 5:return o=t.sent,u=o.as(Wu),c=u.changelogs,t.abrupt("return",c);case 8:case"end":return t.stop()}}),n,this)})))}},{key:"getAllowFriendDiscovery",value:function(){return b(this,void 0,void 0,t().mark((function e(){var n,r,a,s,i,o,u;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n=ds.of(this._iid),r=n.sdkState,a=n.requestQueue,s=new tc({userId:r.userId}),e.next=4,a.send(s);case 4:return i=e.sent,o=i.as(nc),u=o.allowFriendDiscovery,e.abrupt("return",u);case 7:case"end":return e.stop()}}),e,this)})))}},{key:"setAllowFriendDiscovery",value:function(e){return b(this,void 0,void 0,t().mark((function n(){var r,a,s,i;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return Ya(L("boolean",e)).throw(A.invalidParameters),r=ds.of(this._iid),a=r.sdkState,s=r.requestQueue,i=new rc({userId:a.userId,allowFriendDiscovery:e}),t.next=5,s.send(i);case 5:return t.abrupt("return",e);case 6:case"end":return t.stop()}}),n,this)})))}},{key:"uploadFriendDiscoveries",value:function(e){return b(this,void 0,void 0,t().mark((function n(){var r,a,s,i,o,u,c;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return r=ds.of(this._iid),a=r.sdkState,s=r.requestQueue,i=new Yu({userId:a.userId,discoveries:e}),t.next=4,s.send(i);case 4:return o=t.sent,u=o.as(Zu),c=u.friendDiscoveryRequestId,t.abrupt("return",c);case 7:case"end":return t.stop()}}),n,this)})))}},{key:"deleteFriendDiscovery",value:function(e){return b(this,void 0,void 0,t().mark((function n(){return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.abrupt("return",this.deleteFriendDiscoveries([e]));case 1:case"end":return t.stop()}}),n,this)})))}},{key:"deleteFriendDiscoveries",value:function(e){return b(this,void 0,void 0,t().mark((function n(){var r,a,s,i;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return Ya(F("string",e)).throw(A.invalidParameters),r=ds.of(this._iid),a=r.sdkState,s=r.requestQueue,i=new Ju({userId:a.userId,discoveryKeys:e}),t.next=5,s.send(i);case 5:case"end":return t.stop()}}),n,this)})))}},{key:"addFriends",value:function(e){return b(this,void 0,void 0,t().mark((function n(){var r,a,s,i,o,u,c;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return Ya(F("string",e)).throw(A.invalidParameters),r=ds.of(this._iid),a=r.sdkState,s=r.requestQueue,i=new Xu({userId:a.userId,userIds:e}),t.next=5,s.send(i);case 5:return o=t.sent,u=o.as($u),c=u.users,t.abrupt("return",c);case 8:case"end":return t.stop()}}),n,this)})))}},{key:"deleteFriend",value:function(e){return b(this,void 0,void 0,t().mark((function n(){return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.abrupt("return",this.deleteFriends([e]));case 1:case"end":return t.stop()}}),n,this)})))}},{key:"deleteFriends",value:function(e){return b(this,void 0,void 0,t().mark((function n(){var r,a,s,i;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return Ya(F("string",e)).throw(A.invalidParameters),r=ds.of(this._iid),a=r.sdkState,s=r.requestQueue,i=new ec({userId:a.userId,userIds:e}),t.next=5,s.send(i);case 5:case"end":return t.stop()}}),n,this)})))}},{key:"getAllEmoji",value:function(){return b(this,void 0,void 0,t().mark((function e(){var n,r,a,s,i,o;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n=ds.of(this._iid),r=n.requestQueue,a=new oc,e.next=4,r.send(a);case 4:return s=e.sent,i=s.as(uc),o=i.emojiContainer,e.abrupt("return",o);case 7:case"end":return e.stop()}}),e,this)})))}},{key:"getEmojiCategory",value:function(e){return b(this,void 0,void 0,t().mark((function n(){var r,a,s,i,o,u;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return r=ds.of(this._iid),a=r.requestQueue,s=new cc({categoryId:e}),t.next=4,a.send(s);case 4:return i=t.sent,o=i.as(lc),u=o.emojiCategory,t.abrupt("return",u);case 7:case"end":return t.stop()}}),n,this)})))}},{key:"getEmoji",value:function(e){return b(this,void 0,void 0,t().mark((function n(){var r,a,s,i,o,u;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return r=ds.of(this._iid),a=r.requestQueue,s=new hc({key:e}),t.next=4,a.send(s);case 4:return i=t.sent,o=i.as(dc),u=o.emoji,t.abrupt("return",u);case 7:case"end":return t.stop()}}),n,this)})))}},{key:"getUIKitConfiguration",value:function(){return b(this,void 0,void 0,t().mark((function e(){var n,r,a,s,i,o;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n=ds.of(this._iid),Ya(n.hasExtension("sb_uikit")).throw(A.notSupportedError),r=n.requestQueue,a=new fc,e.next=6,r.send(a);case 6:return s=e.sent,i=s.as(pc),o=i.uikitConfiguration,e.abrupt("return",o);case 9:case"end":return e.stop()}}),e,this)})))}}],[{key:"init",value:function(e){var t=e.appId,r=e.appVersion,a=void 0===r?null:r,s=e.modules,i=void 0===s?[]:s,o=e.options,u=void 0===o?new H:o,c=e.debugMode,l=void 0!==c&&c,h=e.customApiHost,d=e.customWebSocketHost,f=e.newInstance,p=void 0!==f&&f,v=e.logLevel,m=e.localCacheEnabled,g=void 0!==m&&m,y=e.localCacheConfig,k=void 0===y?new te:y,b=e.localCacheEncryption,E=e.useAsyncStorageStore,w=void 0===E?null:E,x=e.appStateToggleEnabled,C=void 0===x||x;if(!td||p){var T="su-".concat(re()),S=null!=b?b:{encrypt:function(e){return e},decrypt:function(e){return e}},I=new cl({encryption:S});l||(I=Pe()?w?new fl({AsyncStorage:w,encryption:S}):new cl({encryption:S}):new dl({encryption:S})),new ds(T,{appId:t,appVersion:a,options:u,apiHost:null!=h?h:"https://api-".concat(t,".sendbird.com"),websocketHost:null!=d?d:"wss://ws-".concat(t,".sendbird.com"),store:I,encryption:S,logLevel:v,localCacheEnabled:g,localCacheConfig:k,debugMode:l,appStateToggleEnabled:C});var N=[new Gi,new lo],M=new n(T,u,[].concat(_(i),N));return td||(td=M),M}return td}},{key:"instance",get:function(){return td}},{key:"version",get:function(){return w}}]),n}();e.MemberState=void 0,(Gl=e.MemberState||(e.MemberState={})).NONE="none",Gl.JOINED="joined",Gl.INVITED="invited",Gl.LEFT="left";var rd,ad,sd,id,od,ud,cd,ld,hd=function(t){i(a,t);var n=f(a);function a(t,s){var i;return r(this,a),(i=n.call(this,t,s)).state=null,i.role=null,i.isMuted=!1,i.isBlockedByMe=!1,i.isBlockingMe=!1,i.state=D(e.MemberState,s.state)?s.state:null,i.role=D(e.Role,s.role)?s.role:null,Object.prototype.hasOwnProperty.call(s,"is_muted")&&(i.isMuted=s.is_muted),Object.prototype.hasOwnProperty.call(s,"is_blocked_by_me")&&(i.isBlockedByMe=s.is_blocked_by_me),Object.prototype.hasOwnProperty.call(s,"is_blocking_me")&&(i.isBlockingMe=s.is_blocking_me),i}return s(a,null,[{key:"payloadify",value:function(e){return e?ue(Object.assign(Object.assign({},p(o(a),"payloadify",this).call(this,e)),{state:e.state,role:e.role,is_muted:e.isMuted,is_blocked_by_me:e.isBlockedByMe,is_blocking_me:e.isBlockingMe})):null}}]),a}(El),dd=function(t){i(a,t);var n=f(a);function a(t,s){var i,o,u;return r(this,a),(i=n.call(this,t)).channelUrl=null!==(o=s.channel_url)&&void 0!==o?o:"",i.channelType=null!==(u=s.channel_type)&&void 0!==u?u:e.ChannelType.GROUP,i.reader=new Ja(i._iid,s.user),i.readAt=s.ts,i}return s(a)}(qa);e.PublicChannelFilter=void 0,(rd=e.PublicChannelFilter||(e.PublicChannelFilter={})).ALL="all",rd.PUBLIC="public",rd.PRIVATE="private",e.MyMemberStateFilter=void 0,(ad=e.MyMemberStateFilter||(e.MyMemberStateFilter={})).ALL="all",ad.JOINED="joined_only",ad.INVITED="invited_only",ad.INVITED_BY_FRIEND="invited_by_friend",ad.INVITED_BY_NON_FRIEND="invited_by_non_friend",e.SuperChannelFilter=void 0,(sd=e.SuperChannelFilter||(e.SuperChannelFilter={})).ALL="all",sd.SUPER="super",sd.NON_SUPER="nonsuper",sd.BROADCAST_ONLY="broadcast_only",sd.EXCLUSIVE_ONLY="exclusive_only",e.UnreadChannelFilter=void 0,(id=e.UnreadChannelFilter||(e.UnreadChannelFilter={})).ALL="all",id.UNREAD_MESSAGE="unread_message",e.HiddenChannelFilter=void 0,(od=e.HiddenChannelFilter||(e.HiddenChannelFilter={})).ALL="all",od.UNHIDDEN="unhidden_only",od.HIDDEN="hidden_only",od.HIDDEN_ALLOW_AUTO_UNHIDE="hidden_allow_auto_unhide",od.HIDDEN_PREVENT_AUTO_UNHIDE="hidden_prevent_auto_unhide",e.OperatorFilter=void 0,(ud=e.OperatorFilter||(e.OperatorFilter={})).ALL="all",ud.OPERATOR="operator",ud.NONOPERATOR="nonoperator",e.QueryType=void 0,(cd=e.QueryType||(e.QueryType={})).AND="AND",cd.OR="OR",e.GroupChannelSearchField=void 0,(ld=e.GroupChannelSearchField||(e.GroupChannelSearchField={})).MEMBER_NICKNAME="member_nickname",ld.CHANNEL_NAME="channel_name";var fd,pd=function(){function t(){r(this,t),this._searchFilter=null,this._userIdsFilter=null,this.includeEmpty=!1,this.nicknameContainsFilter=null,this.nicknameStartsWithFilter=null,this.nicknameExactMatchFilter=null,this.channelNameContainsFilter="",this.myMemberStateFilter=e.MyMemberStateFilter.ALL,this.customTypesFilter=null,this.channelUrlsFilter=null,this.superChannelFilter=e.SuperChannelFilter.ALL,this.publicChannelFilter=e.PublicChannelFilter.ALL,this.customTypeStartsWithFilter=null,this.unreadChannelFilter=e.UnreadChannelFilter.ALL,this.hiddenChannelFilter=e.HiddenChannelFilter.UNHIDDEN,this.includeFrozen=!0}return s(t,[{key:"_isFriend",value:function(e){return!!e.friendDiscoveryKey||!!e.friendName}},{key:"searchFilter",get:function(){return this._searchFilter}},{key:"setSearchFilter",value:function(e,t){Array.isArray(e)&&0!==e.length&&"string"==typeof t&&t&&(this._searchFilter={query:t,fields:e})}},{key:"userIdsFilter",get:function(){return this._userIdsFilter}},{key:"setUserIdsFilter",value:function(t,n){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:e.QueryType.AND;this._userIdsFilter={userIds:t,includeMode:n,queryType:r}}},{key:"clone",value:function(){var e=new t;this.searchFilter&&e.setSearchFilter(this.searchFilter.fields,this.searchFilter.query),this.userIdsFilter&&e.setUserIdsFilter(this.userIdsFilter.userIds,this.userIdsFilter.includeMode,this.userIdsFilter.queryType);var n=JSON.parse(JSON.stringify(this));return Object.keys(n).forEach((function(t){e[t]=n[t]})),e}},{key:"match",value:function(t,n){if(this._searchFilter){var r=this._searchFilter,a=r.query,s=r.fields;if(a&&s&&s.length>0&&!s.some((function(n){switch(n){case e.GroupChannelSearchField.CHANNEL_NAME:return t.name.toLowerCase().includes(a.toLowerCase());case e.GroupChannelSearchField.MEMBER_NICKNAME:return t.members.some((function(e){return e.nickname.toLowerCase().includes(a.toLowerCase())}));default:return!0}})))return!1}if(this._userIdsFilter){var i=this._userIdsFilter,o=i.userIds,u=i.includeMode,c=i.queryType,l=t.members.map((function(e){return e.userId}));if(u){if(o.length>0)switch(c){case e.QueryType.AND:if(o.some((function(e){return!l.includes(e)})))return!1;break;case e.QueryType.OR:if(o.every((function(e){return!l.includes(e)})))return!1}}else{if(o.includes(n)||o.push(n),t.members.length>o.length)return!1;if(!function(e,t){if(e===t)return!0;if(null==e||null==t)return!1;if(e.length!==t.length)return!1;for(var n=_(e).sort(),r=_(t).sort(),a=0;a0&&!this.customTypesFilter.includes(t.customType))return!1;if(this.customTypeStartsWithFilter&&!new RegExp("^".concat(this.customTypeStartsWithFilter)).test(t.customType))return!1;if(this.channelNameContainsFilter&&!t.name.toLowerCase().includes(this.channelNameContainsFilter.toLowerCase()))return!1;if(this.nicknameContainsFilter){var h=this.nicknameContainsFilter.toLowerCase();if(!t.members.some((function(e){return e.userId!==n&&e.nickname.toLowerCase().includes(h)})))return!1}if(this.nicknameStartsWithFilter){var d=this.nicknameStartsWithFilter.toLowerCase();if(!t.members.some((function(e){return e.userId!==n&&e.nickname.toLowerCase().startsWith(d)})))return!1}if(this.nicknameExactMatchFilter){var f=this.nicknameExactMatchFilter.toLowerCase();if(!t.members.some((function(e){return e.userId!==n&&e.nickname.toLowerCase()!=f})))return!1}if(this.channelUrlsFilter&&this.channelUrlsFilter.length>0&&!this.channelUrlsFilter.includes(t.url))return!1;if(this.myMemberStateFilter)switch(this.myMemberStateFilter){case e.MyMemberStateFilter.JOINED:if("joined"!==t.myMemberState)return!1;break;case e.MyMemberStateFilter.INVITED:if("invited"!==t.myMemberState)return!1;break;case e.MyMemberStateFilter.INVITED_BY_FRIEND:if("invited"!==t.myMemberState||!this._isFriend(t.inviter))return!1;break;case e.MyMemberStateFilter.INVITED_BY_NON_FRIEND:if("invited"!==t.myMemberState||this._isFriend(t.inviter))return!1}if(this.hiddenChannelFilter)switch(this.hiddenChannelFilter){case e.HiddenChannelFilter.UNHIDDEN:if(t.isHidden||"unhidden"!==t.hiddenState)return!1;break;case e.HiddenChannelFilter.HIDDEN:if(!t.isHidden)return!1;break;case e.HiddenChannelFilter.HIDDEN_ALLOW_AUTO_UNHIDE:if(!t.isHidden||"hidden_allow_auto_unhide"!==t.hiddenState)return!1;break;case e.HiddenChannelFilter.HIDDEN_PREVENT_AUTO_UNHIDE:if(!t.isHidden||"hidden_prevent_auto_unhide"!==t.hiddenState)return!1}if(this.unreadChannelFilter&&this.unreadChannelFilter===e.UnreadChannelFilter.UNREAD_MESSAGE)if(0===t.unreadMessageCount)return!1;if(this.publicChannelFilter)switch(this.publicChannelFilter){case e.PublicChannelFilter.PUBLIC:if(!t.isPublic)return!1;break;case e.PublicChannelFilter.PRIVATE:if(t.isPublic)return!1}if(this.superChannelFilter)switch(this.superChannelFilter){case e.SuperChannelFilter.SUPER:if(!t.isSuper)return!1;break;case e.SuperChannelFilter.NON_SUPER:if(t.isSuper)return!1}return!0}}]),t}(),vd=function(n){i(o,n);var a=f(o);function o(e,t){var n,s=t.sdkState,i=t.cacheContext;return r(this,o),(n=a.call(this,e))._channels=new Map,n._sdkState=s,n._cacheContext=i,n}return s(o,[{key:"collection",get:function(){var e=this._cacheContext.nestdb;return e?e.collection(mo):null}},{key:"localCacheEnabled",get:function(){return this._cacheContext.localCacheEnabled&&!!this.collection}},{key:"_serialize",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0;return Object.assign(Object.assign({},e.serialize()),{lastMessageUpdatedAt:e.lastMessage?e.lastMessage.createdAt:0,syncIndex:t})}},{key:"_deserialize",value:function(e){return Rf.of(this._iid).buildGroupChannelFromSerializedData(e)}},{key:"channels",get:function(){return _(this._channels.values())}},{key:"isCachedInMemory",value:function(e){return this._channels.has(e)}},{key:"filterOffsetChanged",value:function(e){var t=this;return e.filter((function(e){if(t._channels.has(e.url))return t._channels.get(e.url).messageOffsetTimestamp0)return!1;if(f&&f===t.url)return!1;break;case e.GroupChannelListOrder.CHRONOLOGICAL:if(!o&&t.createdAt>r||o&&t.createdAtr||o&&t.lastMessageUpdatedAt0)){t.next=76;break}return t.next=76,this.upsert(s);case 76:case"end":return t.stop()}}),a,this,[[3,30,33,36],[8,20,23,26],[40,67,70,73],[45,57,60,63]])})))}},{key:"block",value:function(e,n){return b(this,void 0,void 0,t().mark((function r(){return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,this._setBlockStateOfAllChannels(e,n,!0);case 2:case"end":return t.stop()}}),r,this)})))}},{key:"unblock",value:function(e,n){return b(this,void 0,void 0,t().mark((function r(){return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,this._setBlockStateOfAllChannels(e,n,!1);case 2:case"end":return t.stop()}}),r,this)})))}},{key:"markAsRead",value:function(e){var n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:_(this._channels.keys());return b(this,void 0,void 0,t().mark((function r(){var a,s,i,o,u;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:a=[],s=y(n),t.prev=2,s.s();case 4:if((i=s.n()).done){t.next=12;break}return o=i.value,t.next=8,this.get(o);case 8:(u=t.sent)._updateUnreadMemberState(this._sdkState.userId,e)&&(u._updateUnreadCount(0,0),a.push(u));case 10:t.next=4;break;case 12:t.next=17;break;case 14:t.prev=14,t.t0=t.catch(2),s.e(t.t0);case 17:return t.prev=17,s.f(),t.finish(17);case 20:if(!(a.length>0)){t.next=23;break}return t.next=23,this.upsert(a);case 23:case"end":return t.stop()}}),r,this,[[2,14,17,20]])})))}}]),o}(qa);!function(e){e[e.NONE=0]="NONE",e[e.CHANNEL_ENTER=10102]="CHANNEL_ENTER",e[e.CHANNEL_EXIT=10103]="CHANNEL_EXIT",e[e.USER_CHANNEL_MUTE=10201]="USER_CHANNEL_MUTE",e[e.USER_CHANNEL_UNMUTE=10200]="USER_CHANNEL_UNMUTE",e[e.USER_CHANNEL_BAN=10601]="USER_CHANNEL_BAN",e[e.USER_CHANNEL_UNBAN=10600]="USER_CHANNEL_UNBAN",e[e.CHANNEL_FREEZE=10701]="CHANNEL_FREEZE",e[e.CHANNEL_UNFREEZE=10700]="CHANNEL_UNFREEZE",e[e.TYPING_START=10900]="TYPING_START",e[e.TYPING_END=10901]="TYPING_END",e[e.CHANNEL_JOIN=1e4]="CHANNEL_JOIN",e[e.CHANNEL_LEAVE=10001]="CHANNEL_LEAVE",e[e.CHANNEL_OPERATOR_UPDATE=10002]="CHANNEL_OPERATOR_UPDATE",e[e.CHANNEL_INVITE=10020]="CHANNEL_INVITE",e[e.CHANNEL_ACCEPT_INVITE=10021]="CHANNEL_ACCEPT_INVITE",e[e.CHANNEL_DECLINE_INVITE=10022]="CHANNEL_DECLINE_INVITE",e[e.CHANNEL_PROP_CHANGED=11e3]="CHANNEL_PROP_CHANGED",e[e.CHANNEL_DELETED=12e3]="CHANNEL_DELETED",e[e.CHANNEL_META_DATA_CHANGED=11100]="CHANNEL_META_DATA_CHANGED",e[e.CHANNEL_META_COUNTERS_CHANGED=11200]="CHANNEL_META_COUNTERS_CHANGED",e[e.CHANNEL_HIDE=13e3]="CHANNEL_HIDE",e[e.CHANNEL_UNHIDE=13001]="CHANNEL_UNHIDE",e[e.PINNED_MESSAGE_CHANGED=11300]="PINNED_MESSAGE_CHANGED"}(fd||(fd={}));var _d,md=function(){function t(e){r(this,t),this.channelUrl=e.channel_url,this.channelType=e.channel_type,this.category=e.cat,this.data=e.data,this.ts=e.ts}return s(t,[{key:"isGroupChannelEvent",get:function(){return this.channelType===e.ChannelType.GROUP}},{key:"isOpenChannelEvent",get:function(){return this.channelType===e.ChannelType.OPEN}}]),t}(),gd={invitedUserIds:null,channelUrl:null,coverUrl:null,coverImage:null,isDistinct:null,isSuper:null,isBroadcast:null,isExclusive:null,isPublic:null,isDiscoverable:null,isStrict:null,isEphemeral:null,accessCode:null,name:null,data:null,customType:null,operatorUserIds:null,messageSurvivalSeconds:null},yd=function(e){return F("string",e.invitedUserIds,!0)&&L("string",e.channelUrl,!0)&&L("string",e.coverUrl,!0)&&(q(e.coverImage)||L("string",e.coverImage)||null===e.coverImage)&&L("boolean",e.isDistinct,!0)&&L("boolean",e.isSuper,!0)&&L("boolean",e.isBroadcast,!0)&&L("boolean",e.isExclusive,!0)&&L("boolean",e.isPublic,!0)&&L("boolean",e.isStrict,!0)&&L("boolean",e.isDiscoverable,!0)&&L("boolean",e.isEphemeral,!0)&&L("string",e.accessCode,!0)&&L("string",e.name,!0)&&L("string",e.data,!0)&&L("string",e.customType,!0)&&F("string",e.operatorUserIds,!0)&&L("number",e.messageSurvivalSeconds,!0)},kd={customTypes:null,includeEmpty:!1,includeFrozen:!0},bd=function(e){return F("string",e.customTypes,!0)&&L("boolean",e.includeEmpty)&&L("boolean",e.includeFrozen)},Ed={myMemberStateFilter:e.MyMemberStateFilter.ALL},wd=function(t){return D(e.MyMemberStateFilter,t.myMemberStateFilter)};e.UnreadItemKey=void 0,(_d=e.UnreadItemKey||(e.UnreadItemKey={})).GROUP_CHANNEL_UNREAD_MENTION_COUNT="group_channel_unread_mention_count",_d.NONSUPER_UNREAD_MENTION_COUNT="non_super_group_channel_unread_mention_count",_d.SUPER_UNREAD_MENTION_COUNT="super_group_channel_unread_mention_count",_d.GROUP_CHANNEL_UNREAD_MESSAGE_COUNT="group_channel_unread_message_count",_d.NONSUPER_UNREAD_MESSAGE_COUNT="non_super_group_channel_unread_message_count",_d.SUPER_UNREAD_MESSAGE_COUNT="super_group_channel_unread_message_count",_d.GROUP_CHANNEL_INVITATION_COUNT="group_channel_invitation_count",_d.NONSUPER_INVITATION_COUNT="non_super_group_channel_invitation_count",_d.SUPER_INVITATION_COUNT="super_group_channel_invitation_count";var xd,Cd={keys:[]},Td=function(t){return F(e.UnreadItemKey,t.keys)},Sd={channelCustomTypesFilter:null,superChannelFilter:e.SuperChannelFilter.ALL},Id=function(t){return F("string",t.channelCustomTypesFilter,!0)&&D(e.SuperChannelFilter,t.superChannelFilter)},Nd={channelUrl:null,scheduledStatus:null,messageTypeFilter:e.MessageTypeFilter.ALL},Md=function(t){return L("string",t.channelUrl,!0)&&F(e.ScheduledStatus,t.scheduledStatus,!0)&&D(e.MessageTypeFilter,t.messageTypeFilter)},Ad=function(){function e(n){var a=this,s=n.groupChannelCache,i=n.messageCache,o=n.unsentMessageCache,u=n.dispatcher;r(this,e),this._observers=new Map,u.on((function(e){return b(a,void 0,void 0,t().mark((function n(){var r,a,u,c,l,h,d,f,p,v,_,m=this;return t().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:if(!(e instanceof hu)){n.next=27;break}r=e.channels,a=e.source,u=e.data,c=r.filter((function(e){return e instanceof Bp})),l=s.filterOffsetChanged(c),h=y(l),n.prev=5,h.s();case 7:if((d=h.n()).done){n.next=13;break}return f=d.value,n.next=11,i.removeUnderOffset(f.url,f.messageOffsetTimestamp);case 11:n.next=7;break;case 13:n.next=18;break;case 15:n.prev=15,n.t0=n.catch(5),h.e(n.t0);case 18:return n.prev=18,h.f(),n.finish(18);case 21:return n.next=23,s.upsert(c);case 23:p=n.sent,this._broadcastUpdateEvent(p,a,u),n.next=39;break;case 27:if(!(e instanceof du)){n.next=36;break}return v=e.channelUrls,_=e.source,n.next=31,s.remove(v);case 31:return n.next=33,xa((function(){return b(m,void 0,void 0,t().mark((function e(){var n,r,a;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:n=y(v),e.prev=1,n.s();case 3:if((r=n.n()).done){e.next=11;break}return a=r.value,e.next=7,i.removeMessagesOfChannel(a);case 7:return e.next=9,o.removeMessagesOfChannel(a);case 9:e.next=3;break;case 11:e.next=16;break;case 13:e.prev=13,e.t0=e.catch(1),n.e(e.t0);case 16:return e.prev=16,n.f(),e.finish(16);case 19:case"end":return e.stop()}}),e,null,[[1,13,16,19]])})))}));case 33:this._broadcastRemoveEvent(v,_),n.next=39;break;case 36:if(!(e instanceof uu)){n.next=39;break}return n.next=39,s.fetch({token:Number.MAX_SAFE_INTEGER,limit:Number.MAX_SAFE_INTEGER});case 39:case"end":return n.stop()}}),n,this,[[5,15,18,21]])})))}))}return s(e,[{key:"_broadcastUpdateEvent",value:function(e,t,n){var r,a=y(this._observers.values());try{for(a.s();!(r=a.n()).done;){r.value.onUpdate(e,t,n)}}catch(e){a.e(e)}finally{a.f()}}},{key:"_broadcastRemoveEvent",value:function(e,t){var n,r=y(this._observers.values());try{for(r.s();!(n=r.n()).done;){n.value.onRemove(e,t)}}catch(e){r.e(e)}finally{r.f()}}},{key:"subscribe",value:function(e,t){this._observers.set(e,t)}},{key:"unsubscribe",value:function(e){this._observers.delete(e)}},{key:"unsubscribeAll",value:function(){this._observers.clear()}}]),e}(),Od=function(){function e(n){var a=this,s=n.cacheContext,i=n.messageCache,o=n.unsentMessageCache,u=n.dispatcher,c=n.logger;r(this,e),this._cacheContext=null,this._observers=new Map,this._logger=null,this._cacheContext=s,this._logger=c,u.on((function(e){return b(a,void 0,void 0,t().mark((function n(){var r,a,s,u,c,l,h,d,f,p,v,_,m,g,y,k,E,w,x=this;return t().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:if(!(e instanceof oi)){n.next=14;break}if(r=e.messages,a=e.source,s=r.filter((function(e){return e.messageId>0})),u=r.filter((function(e){return 0===e.messageId})),!(s.length>0)){n.next=8;break}return n.next=7,xa((function(){return b(x,void 0,void 0,t().mark((function e(){return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,i.upsert(s);case 2:return e.next=4,o.remove(s.map((function(e){return e instanceof Ns?e.reqId:null})).filter((function(e){return null!==e})));case 4:case"end":return e.stop()}}),e)})))}));case 7:this._broadcastUpdateEvent(s,a);case 8:if(!(u.length>0)){n.next=12;break}return n.next=11,xa((function(){return b(x,void 0,void 0,t().mark((function e(){return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,o.upsert(u);case 2:case"end":return e.stop()}}),e)})))}));case 11:this._broadcastUpdateEvent(u,a);case 12:n.next=61;break;case 14:if(!(e instanceof ui)){n.next=21;break}return c=e.messageIds,l=e.source,n.next=18,xa((function(){return b(x,void 0,void 0,t().mark((function e(){return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,i.remove(c);case 2:case"end":return e.stop()}}),e)})))}));case 18:this._broadcastRemoveEvent(c,l),n.next=61;break;case 21:if(!(e instanceof ci)){n.next=28;break}return h=e.reqId,d=e.source,n.next=25,xa((function(){return b(x,void 0,void 0,t().mark((function e(){return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,o.remove([h]);case 2:case"end":return e.stop()}}),e)})))}));case 25:this._broadcastRemoveUnsentEvent(h,d),n.next=61;break;case 28:if(!(e instanceof li)){n.next=41;break}if(f=e.polls,p=e.source,!this._cacheContext.localCacheEnabled){n.next=38;break}return v=f.map((function(e){return e.messageId})),n.next=34,Promise.all(v.map((function(e){return i.get(e)})));case 34:return _=n.sent.filter((function(e){return e})),_.length>0&&f.forEach((function(e){var t=_.find((function(t){return t.messageId===e.messageId}));t&&t.applyPoll(e)})),n.next=38,xa((function(){return b(x,void 0,void 0,t().mark((function e(){return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,i.upsert(_);case 2:return e.abrupt("return",e.sent);case 3:case"end":return e.stop()}}),e)})))}));case 38:this._broadcastPollChangeLogEvent(f,p),n.next=61;break;case 41:if(!(e instanceof hi)){n.next=52;break}return m=e.event,g=e.source,n.next=45,i.get(m.messageId);case 45:if(!((y=n.sent)&&y.isUserMessage()&&y.poll&&y.poll.applyPollUpdateEvent(m))){n.next=49;break}return n.next=49,xa((function(){return b(x,void 0,void 0,t().mark((function e(){return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,i.upsert([y]);case 2:return e.abrupt("return",e.sent);case 3:case"end":return e.stop()}}),e)})))}));case 49:this._broadcastPollUpdateEvent(m,g),n.next=61;break;case 52:if(!(e instanceof di)){n.next=61;break}return k=e.event,E=e.source,n.next=56,i.get(k.messageId);case 56:if(!((w=n.sent)&&w.isUserMessage()&&w.poll&&w.poll.applyPollVoteEvent(k))){n.next=60;break}return n.next=60,xa((function(){return b(x,void 0,void 0,t().mark((function e(){return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,i.upsert([w]);case 2:return e.abrupt("return",e.sent);case 3:case"end":return e.stop()}}),e)})))}));case 60:this._broadcastPollVoteEvent(k,E);case 61:case"end":return n.stop()}}),n,this)})))}))}return s(e,[{key:"_broadcastUpdateEvent",value:function(e,t){var n,r=y(this._observers.values());try{for(r.s();!(n=r.n()).done;){n.value.onUpdate(e,t)}}catch(e){r.e(e)}finally{r.f()}}},{key:"_broadcastPollChangeLogEvent",value:function(e,t){var n,r=y(this._observers.values());try{for(r.s();!(n=r.n()).done;){n.value.onPollChangeLogUpdate(e,t)}}catch(e){r.e(e)}finally{r.f()}}},{key:"_broadcastPollUpdateEvent",value:function(e,t){var n,r=y(this._observers.values());try{for(r.s();!(n=r.n()).done;){n.value.onPollUpdate(e,t)}}catch(e){r.e(e)}finally{r.f()}}},{key:"_broadcastPollVoteEvent",value:function(e,t){var n,r=y(this._observers.values());try{for(r.s();!(n=r.n()).done;){n.value.onPollVote(e,t)}}catch(e){r.e(e)}finally{r.f()}}},{key:"_broadcastRemoveEvent",value:function(e,t){var n,r=y(this._observers.values());try{for(r.s();!(n=r.n()).done;){n.value.onRemove(e,t)}}catch(e){r.e(e)}finally{r.f()}}},{key:"_broadcastRemoveUnsentEvent",value:function(e,t){var n,r=y(this._observers.values());try{for(r.s();!(n=r.n()).done;){n.value.onRemoveUnsent(e,t)}}catch(e){r.e(e)}finally{r.f()}}},{key:"subscribe",value:function(e,t){this._observers.set(e,t)}},{key:"unsubscribe",value:function(e){this._observers.delete(e)}},{key:"unsubscribeAll",value:function(){this._observers.clear()}}]),e}(),Ud=function(e){i(n,e);var t=f(n);function n(e){var a,s=e.userId,i=e.ts,o=e.token,u=e.filter;r(this,n),a=t.call(this);var c=Object.assign(Object.assign({},kd),u),l=c.customTypes,h=c.includeEmpty,d=c.includeFrozen;return a.method=ce.GET,a.path="".concat(he,"/").concat(encodeURIComponent(s),"/my_group_channels/changelogs"),a.params=ue({show_delivery_receipt:!0,show_member:!0,show_read_receipt:!0,change_ts:i>0?i:null,token:o,custom_types:l,show_empty:h,show_frozen:d}),a}return s(n)}(Ae),Rd=function(e){i(n,e);var t=f(n);function n(e,a){var s;return r(this,n),(s=t.call(this,e,a)).updatedChannels=a.updated.map((function(t){return new Bp(e,t)})),s.deletedChannelUrls=a.deleted,s.hasMore=a.has_more,s.token=a.next,s}return s(n)}(Oe),Ld=function(e){i(n,e);var t=f(n);function n(e){var a,s=e.channelUrl,i=e.isInternalCall;return r(this,n),(a=t.call(this)).method=ce.GET,a.path="".concat(i?pe:fe,"/").concat(encodeURIComponent(s)),a.params={show_member:!0,show_read_receipt:!0,show_delivery_receipt:!0},a}return s(n)}(Ae),Dd=function(e){i(n,e);var t=f(n);function n(e,a){var s;return r(this,n),(s=t.call(this,e,a)).channel=null,s.channel=new Bp(e,a),s}return s(n)}(Oe),Pd=function(e){i(n,e);var t=f(n);function n(e){var a;r(this,n);var s=e.userId,i=e.token,o=e.limit,u=e.order,c=e.includeEmpty,l=e.myMemberStateFilter,h=e.superChannelFilter,d=e.publicChannelFilter,f=e.unreadChannelFilter,p=e.nicknameContainsFilter,v=e.nicknameStartsWithFilter,_=e.nicknameExactMatchFilter,m=e.channelNameContainsFilter,g=e.channelUrlsFilter,y=e.customTypesFilter,k=e.customTypeStartsWithFilter,b=e.hiddenChannelFilter,E=e.metadataOrderKeyFilter,w=e.metadataKey,x=e.metadataValues,C=e.metadataValueStartsWith,T=e.includeFrozen,S=e.includeMetaData,I=e.searchFilter,N=e.userIdsFilter;return(a=t.call(this)).method=ce.GET,a.path="".concat(he,"/").concat(encodeURIComponent(s),"/my_group_channels"),a.params=ue({token:i,limit:o,order:u,show_member:!0,show_read_receipt:!0,show_delivery_receipt:!0,show_empty:c,member_state_filter:l,super_mode:h,public_mode:d,unread_filter:f,members_nickname_contains:p,members_nickname_startswith:v,members_nickname:_,name_contains:m,channel_urls:g,custom_types:y,custom_type_startswith:k,hidden_mode:b,metadata_order_key:E,metadata_key:w,metadata_values:x,metadata_value_startswith:C,show_frozen:T,show_metadata:S}),I&&I.query&&I.fields&&(a.params.search_query=I.query,a.params.search_fields=I.fields),N&&N.userIds&&N.userIds.length>0&&(N.includeMode?(a.params.members_include_in=N.userIds,a.params.query_type=N.queryType.toUpperCase()):a.params.members_exactly_in=N.userIds),a}return s(n)}(Ae),Fd=function(e){i(n,e);var t=f(n);function n(e,a){var s;r(this,n),(s=t.call(this,e,a)).token=null,s.channels=[],s.ts=null;var i=a.next,o=a.channels,u=a.ts;return s.token=i,o&&o.length>0&&(s.channels=o.map((function(t){return t.ts=u,new Bp(e,t)}))),s.ts=null!=u?u:null,s}return s(n)}(Oe),Gd=function(t){i(a,t);var n=f(a);function a(t){var s,i=t.userId,o=t.filter;r(this,a),s=n.call(this);var u=o.myMemberStateFilter;return s.method=ce.GET,s.path="".concat(he,"/").concat(encodeURIComponent(i),"/group_channel_count"),s.params={state:null!=u?u:e.MyMemberStateFilter.ALL},s}return s(a)}(Ae),qd=function(e){i(n,e);var t=f(n);function n(e,a){var s;return r(this,n),(s=t.call(this,e,a)).groupChannelCount=a.group_channel_count,s}return s(n)}(Oe),Hd=function(e){i(n,e);var t=f(n);function n(e){var a,s=e.userId,i=e.filter;r(this,n),a=t.call(this);var o=i.keys;return a.method=ce.GET,a.path="".concat(he,"/").concat(encodeURIComponent(s),"/unread_item_count"),a.params={item_keys:o},a}return s(n)}(Ae),jd=function(t){i(a,t);var n=f(a);function a(t,s){var i;return r(this,a),i=n.call(this,t,s),"number"==typeof s[e.UnreadItemKey.GROUP_CHANNEL_UNREAD_MENTION_COUNT]&&(i.groupChannelUnreadMentionCount=s[e.UnreadItemKey.GROUP_CHANNEL_UNREAD_MENTION_COUNT]),"number"==typeof s[e.UnreadItemKey.GROUP_CHANNEL_UNREAD_MESSAGE_COUNT]&&(i.groupChannelUnreadMessageCount=s[e.UnreadItemKey.GROUP_CHANNEL_UNREAD_MESSAGE_COUNT]),"number"==typeof s[e.UnreadItemKey.GROUP_CHANNEL_INVITATION_COUNT]&&(i.groupChannelInvitationCount=s[e.UnreadItemKey.GROUP_CHANNEL_INVITATION_COUNT]),"number"==typeof s[e.UnreadItemKey.SUPER_UNREAD_MENTION_COUNT]&&(i.superGroupChannelUnreadMentionCount=s[e.UnreadItemKey.SUPER_UNREAD_MENTION_COUNT]),"number"==typeof s[e.UnreadItemKey.SUPER_UNREAD_MESSAGE_COUNT]&&(i.superGroupChannelUnreadMessageCount=s[e.UnreadItemKey.SUPER_UNREAD_MESSAGE_COUNT]),"number"==typeof s[e.UnreadItemKey.SUPER_INVITATION_COUNT]&&(i.superGroupChannelInvitationCount=s[e.UnreadItemKey.SUPER_INVITATION_COUNT]),"number"==typeof s[e.UnreadItemKey.NONSUPER_UNREAD_MENTION_COUNT]&&(i.nonSuperGroupChannelUnreadMentionCount=s[e.UnreadItemKey.NONSUPER_UNREAD_MENTION_COUNT]),"number"==typeof s[e.UnreadItemKey.NONSUPER_UNREAD_MESSAGE_COUNT]&&(i.nonSuperGroupChannelUnreadMessageCount=s[e.UnreadItemKey.NONSUPER_UNREAD_MESSAGE_COUNT]),"number"==typeof s[e.UnreadItemKey.NONSUPER_INVITATION_COUNT]&&(i.nonSuperGroupChannelInvitationCount=s[e.UnreadItemKey.NONSUPER_INVITATION_COUNT]),i}return s(a)}(Oe),zd=function(e){i(n,e);var t=f(n);function n(e){var a,s=e.userId;return r(this,n),(a=t.call(this)).method=ce.GET,a.path="".concat(he,"/").concat(encodeURIComponent(s),"/unread_channel_count"),a}return s(n)}(Ae),Vd=function(e){i(n,e);var t=f(n);function n(e,a){var s;return r(this,n),(s=t.call(this,e,a)).unreadCount=a.unread_count,s}return s(n)}(Oe),Bd=function(t){i(a,t);var n=f(a);function a(t){var s,i=t.userId,o=t.filter;r(this,a),s=n.call(this);var u=o.channelCustomTypesFilter,c=o.superChannelFilter;return s.method=ce.GET,s.path="".concat(he,"/").concat(encodeURIComponent(i),"/unread_message_count"),s.params={super_mode:null!=c?c:e.SuperChannelFilter.ALL,custom_types:u},s}return s(a)}(Ae),Qd=function(e){i(n,e);var t=f(n);function n(e,a){var s;return r(this,n),(s=t.call(this,e,a)).unreadCount=a.unread_count,s}return s(n)}(Oe),Kd=function(e){i(n,e);var t=f(n);function n(e){var a,s=e.channelUrl,i=e.scheduledStatus,o=e.messageTypeFilter;return r(this,n),(a=t.call(this)).method=ce.GET,a.path="".concat(Ee,"/count"),a.params={channel_url:s,status:Yd(i)},o&&(a.params.message_type=o),a}return s(n)}(Ae),Wd=function(e){i(n,e);var t=f(n);function n(e,a){var s;return r(this,n),(s=t.call(this,e,a)).count=a.count,s}return s(n)}(Oe),Yd=function(t){if(t){var n=[];return t.forEach((function(t){switch(t){case e.ScheduledStatus.PENDING:n.push(gs.PENDING);break;case e.ScheduledStatus.SENT:n.push(gs.IN_QUEUE),n.push(gs.SENT);break;case e.ScheduledStatus.CANCELED:n.push(gs.CANCELED);break;case e.ScheduledStatus.FAILED:n.push(gs.FAILED)}})),n}},Zd=function(e){i(n,e);var t=f(n);function n(e){var a;r(this,n);var s=e.userId,i=e.channelUrl,o=e.coverUrl,u=e.coverImage,c=e.isDistinct,l=e.isSuper,h=e.isBroadcast,d=e.isPublic,f=e.isExclusive,p=e.isDiscoverable,v=e.isStrict,m=e.isEphemeral,g=e.accessCode,y=e.name,k=e.data,b=e.customType,E=e.messageSurvivalSeconds,w=e.invitedUserIds,x=e.operatorUserIds;return(a=t.call(this)).method=ce.POST,a.path=fe,a.params=ue({user_ids:[s].concat(_(null!=w?w:[])).filter((function(e,t,n){return t===n.indexOf(e)})),channel_url:i,cover_url:o,cover_file:u,is_distinct:c,is_super:l,is_broadcast:h,is_exclusive:f,is_public:d,is_discoverable:p,strict:v,is_ephemeral:m,access_code:g,name:y,data:k,custom_type:b,operator_ids:x,message_survival_seconds:E}),a}return s(n)}(Ae),Jd=function(e){i(n,e);var t=f(n);function n(e,a){var s;return r(this,n),(s=t.call(this,e,a)).channel=new Bp(e,a),s.isCreated=a.is_created,s}return s(n)}(Oe),Xd=function(e){i(n,e);var t=f(n);function n(e){var a,s=e.userId,i=e.channelUrls;return r(this,n),(a=t.call(this)).method=ce.PUT,a.path="".concat(he,"/").concat(encodeURIComponent(s),"/mark_as_read_all"),a.params={channel_urls:i},a}return s(n)}(Ae),$d=function(e){i(n,e);var t=f(n);function n(e,a,s){var i;return r(this,n),(i=t.call(this,e,"SYEV",s)).event=new md(s),i}return s(n)}(Ge),ef=function(e){i(n,e);var t=f(n);function n(e){var a;r(this,n);var s=e.channelUrl,i=e.userId,o=e.accessCode;return(a=t.call(this)).method=ce.PUT,a.path="".concat(fe,"/").concat(encodeURIComponent(s),"/join"),a.params={user_id:i,access_code:o},a}return s(n)}(Ae),tf=function(e){i(n,e);var t=f(n);function n(e,a){var s;return r(this,n),(s=t.call(this,e,a)).channel=new Bp(e,a),s}return s(n)}(Oe),nf=function(e){i(n,e);var t=f(n);function n(e,a,s){var i;r(this,n),i=t.call(this,e,a,s);var o=s.data,u=o.member_count,c=void 0===u?null:u,l=o.joined_member_count,h=void 0===l?null:l,d=o.users,f=void 0===d?null:d;return i.memberCount=c,i.joinedMemberCount=h,i.members=Array.isArray(f)?f.map((function(t){return new hd(e,t)})):[new hd(e,s.data)],i}return s(n)}($d),rf=function(e){i(n,e);var t=f(n);function n(e){var a;r(this,n);var s=e.channelUrl,i=e.userId,o=e.shouldRemoveOperatorStatus;return(a=t.call(this)).method=ce.PUT,a.path="".concat(fe,"/").concat(encodeURIComponent(s),"/leave"),a.params={user_id:i,should_remove_operator_status:o},a}return s(n)}(Ae),af=function(e){i(n,e);var t=f(n);function n(e,a,s){var i;r(this,n),i=t.call(this,e,a,s);var o=s.data,u=o.member_count,c=void 0===u?null:u,l=o.joined_member_count,h=void 0===l?null:l;return i.memberCount=c,i.joinedMemberCount=h,i.member=new hd(i._iid,s.data),i}return s(n)}($d),sf=function(e){i(n,e);var t=f(n);function n(e){var a;r(this,n);var s=e.channelUrl,i=e.userIds;return(a=t.call(this)).method=ce.POST,a.path="".concat(fe,"/").concat(encodeURIComponent(s),"/invite"),a.params={user_ids:i},a}return s(n)}(Ae),of=function(e){i(n,e);var t=f(n);function n(e,a){var s;return r(this,n),(s=t.call(this,e,a)).channel=new Bp(e,a),s}return s(n)}(Oe),uf=function(e){i(n,e);var t=f(n);function n(e,a,s){var i;r(this,n),i=t.call(this,e,a,s);var o=s.data,u=o.member_count,c=void 0===u?null:u,l=o.joined_member_count,h=void 0===l?null:l,d=o.inviter,f=void 0===d?null:d,p=o.invitees,v=void 0===p?[]:p;return i.memberCount=c,i.joinedMemberCount=h,i.inviter=f?new Ja(e,f):null,i.invitees=v.map((function(t){return new hd(e,t)})),i}return s(n)}($d),cf=function(e){i(n,e);var t=f(n);function n(e){var a;r(this,n);var s=e.channelUrl,i=e.userId;return(a=t.call(this)).method=ce.PUT,a.path="".concat(fe,"/").concat(encodeURIComponent(s),"/decline"),a.params={user_id:i},a}return s(n)}(Ae),lf=function(e){i(n,e);var t=f(n);function n(e,a,s){var i;r(this,n),i=t.call(this,e,a,s);var o=s.data,u=o.member_count,c=void 0===u?null:u,l=o.joined_member_count,h=void 0===l?null:l,d=o.inviter,f=void 0===d?null:d,p=o.invitee,v=void 0===p?null:p;return i.memberCount=c,i.joinedMemberCount=h,i.inviter=f?new Ja(e,f):null,i.invitee=v?new hd(e,v):null,i}return s(n)}($d),hf=function(e){i(n,e);var t=f(n);function n(e){var a=e.channelUrl;return r(this,n),t.call(this,{code:"READ",ackRequired:!0,payload:{channel_url:a}})}return s(n)}(ia),df=function(e){i(n,e);var t=f(n);function n(e,a,s){var i;return r(this,n),(i=t.call(this,e,"READ",s)).readStatus=new dd(e,s),i}return s(n)}(Ge),ff=function(e){i(n,e);var t=f(n);function n(e){var a,s=e.channelUrl,i=e.userId;return r(this,n),a=t.call(this),(a=t.call(this)).method=ce.PUT,a.path="".concat(fe,"/").concat(encodeURIComponent(s),"/messages/mark_as_delivered"),a.params=ue({userId:i}),a}return s(n)}(Ae),pf=function(e){i(n,e);var t=f(n);function n(e,a,s){var i;return r(this,n),(i=t.call(this,e,"DLVR",s)).channelUrl=s.channel_url,i.deliveredStateUpdate=s.updated,i}return s(n)}(Ge),vf=function(e){i(n,e);var t=f(n);function n(e){var a;r(this,n);var s=e.channelUrl,i=e.userId,o=e.hidePreviousMessages,u=e.allowAutoUnhide;return(a=t.call(this)).method=ce.PUT,a.path="".concat(fe,"/").concat(encodeURIComponent(s),"/hide"),a.params={user_id:i,hide_previous_messages:o,allow_auto_unhide:u},a}return s(n)}(Ae),_f=function(e){i(n,e);var t=f(n);function n(e,a){var s;r(this,n),(s=t.call(this,e,a)).messageOffsetTimestamp=null;var i=a.ts_message_offset;return s.messageOffsetTimestamp=null!=i?i:null,s}return s(n)}(Oe),mf=function(e){i(n,e);var t=f(n);function n(e,a,s){var i;return r(this,n),(i=t.call(this,e,"SYEV",s)).allowAutoUnhide=null,i.hidePreviousMessages=null,i.messageOffsetTimestamp=null,s.data&&(i.allowAutoUnhide=s.data.allow_auto_unhide,i.hidePreviousMessages=s.data.hide_previous_messages),i.messageOffsetTimestamp=s.ts_message_offset,i}return s(n)}(Ge),gf=function(e){i(n,e);var t=f(n);function n(e){var a=e.channelUrl,s=e.time;return r(this,n),t.call(this,{code:"TPST",ackRequired:!1,payload:{channel_url:a,time:s}})}return s(n)}(ia),yf=function(e){i(n,e);var t=f(n);function n(e,a,s){var i;return r(this,n),(i=t.call(this,e,"SYEV",s)).user=new Ja(e,s.data),i}return s(n)}(Ge),kf=function(e){i(n,e);var t=f(n);function n(e){var a=e.channelUrl,s=e.time;return r(this,n),t.call(this,{code:"TPEN",ackRequired:!1,payload:{channel_url:a,time:s}})}return s(n)}(ia),bf=function(e){i(n,e);var t=f(n);function n(e,a,s){var i;return r(this,n),(i=t.call(this,e,"SYEV",s)).user=new Ja(e,s.data),i}return s(n)}(Ge),Ef=function(e){i(n,e);var t=f(n);function n(e,a,s){var i;r(this,n),i=t.call(this,e,a,s);var o=s.data.operators,u=void 0===o?[]:o;return i.operators=u.map((function(e){return new Ja(i._iid,e)})),i}return s(n)}($d),wf=function(e){i(n,e);var t=f(n);function n(e,a,s){var i;return r(this,n),(i=t.call(this,e,"MCNT",s)).groupChannelMemberCounts=s.group_channels.map((function(e){return{channelUrl:e.channel_url,memberCount:e.member_count,joinedMemberCount:e.joined_member_count,updatedAt:e.ts}})),i.openChannelMemberCounts=s.open_channels.map((function(e){return{channelUrl:e.channel_url,participantCount:e.participant_count,updatedAt:e.ts}})),i}return s(n)}(Ge),xf=function(e){i(n,e);var t=f(n);function n(e){var a=e.channelUrl,s=e.messageId;return r(this,n),t.call(this,{code:"MACK",ackRequired:!1,payload:{channel_url:a,msg_id:s}})}return s(n)}(ia),Cf=function(e){i(n,e);var t=f(n);function n(e,a,s){var i,o,u,c;r(this,n),(i=t.call(this,e,"ADMM",s)).message=new Us(e,s);var l=ds.of(e).sdkState;return i.isMentioned=Se(i.message.mentionType,null!==(o=i.message.mentionedUserIds)&&void 0!==o?o:null===(u=i.message.mentionedUsers)||void 0===u?void 0:u.map((function(e){return e.userId})),l.userId),i.forceUpdateLastMessage=null!==(c=s.force_update_last_message)&&void 0!==c&&c,i}return s(n)}(Ge),Tf=function(e){i(n,e);var t=f(n);function n(e,a,s){var i,o,u,c,l,h,d;r(this,n),(i=t.call(this,e,"AEDI",s)).message=new Us(e,s);var f=ds.of(e).sdkState;return i.mentionCountChange=Ie({mentionType:null!==(u=null===(o=s.old_values)||void 0===o?void 0:o.mention_type)&&void 0!==u?u:null,mentionedUserIds:null!==(l=null===(c=s.old_values)||void 0===c?void 0:c.mentioned_user_ids)&&void 0!==l?l:[]},{mentionType:i.message.mentionType,mentionedUserIds:null!==(h=i.message.mentionedUserIds)&&void 0!==h?h:null===(d=i.message.mentionedUsers)||void 0===d?void 0:d.map((function(e){return e.userId}))},f.userId),i}return s(n)}(Ge),Sf=function(e){i(n,e);var t=f(n);function n(e,a,s){var i;return r(this,n),(i=t.call(this,e,"MRCT",s)).channelUrl=s.channel_url,i.channelType=s.channel_type,i.event=new ys(s),i}return s(n)}(Ge),If=function(e){i(n,e);var t=f(n);function n(e,a,s){var i;return r(this,n),(i=t.call(this,e,"MTHD",s)).event=new xi(e,s),i}return s(n)}(Ge),Nf=function(e){i(n,e);var t=f(n);function n(e,a,s){var i;return r(this,n),(i=t.call(this,e,"PEDI",s)).event=null,i.status=null,i.channelUrl=null,i.channelType=null,i.event=new no(e,s),i.status=Ds(s.poll.status)||s.poll.status,i.channelUrl=s.channel_url,i.channelType=s.channel_type,i}return s(n)}(Ge),Mf=function(n){i(u,n);var a=f(u);function u(t,n){var s,i,o,c,l,h,d,f,p,v,_,m,g,y,k,b,E,w,x,C,T,S,I;return r(this,u),(s=a.call(this,t,n)).includeEmpty=!1,s.includeFrozen=!0,s.includeMetaData=!0,s.channelUrlsFilter=null,s.customTypesFilter=null,s.customTypeStartsWithFilter=null,s.nicknameContainsFilter=null,s.nicknameStartsWithFilter=null,s.nicknameExactMatchFilter=null,s.channelNameContainsFilter="",s.myMemberStateFilter=e.MyMemberStateFilter.ALL,s.unreadChannelFilter=e.UnreadChannelFilter.ALL,s.superChannelFilter=e.SuperChannelFilter.ALL,s.publicChannelFilter=e.PublicChannelFilter.ALL,s.hiddenChannelFilter=e.HiddenChannelFilter.UNHIDDEN,s.searchFilter={fields:[],query:null},s.userIdsFilter={userIds:[],includeMode:!0,queryType:e.QueryType.AND},s.metadataKey=null,s.metadataValues=null,s.metadataOrderKeyFilter=null,s.metadataValueStartsWith=null,s.order=e.GroupChannelListOrder.LATEST_LAST_MESSAGE,s.includeEmpty=null!==(i=n.includeEmpty)&&void 0!==i&&i,s.includeFrozen=null===(o=n.includeFrozen)||void 0===o||o,s.includeMetaData=null===(c=n.includeMetaData)||void 0===c||c,s.channelUrlsFilter=null!==(l=n.channelUrlsFilter)&&void 0!==l?l:null,s.customTypesFilter=null!==(h=n.customTypesFilter)&&void 0!==h?h:null,s.customTypeStartsWithFilter=null!==(d=n.customTypeStartsWithFilter)&&void 0!==d?d:"",s.nicknameContainsFilter=null!==(f=n.nicknameContainsFilter)&&void 0!==f?f:null,s.nicknameStartsWithFilter=null!==(p=n.nicknameStartsWithFilter)&&void 0!==p?p:null,s.nicknameExactMatchFilter=null!==(v=n.nicknameExactMatchFilter)&&void 0!==v?v:null,s.channelNameContainsFilter=null!==(_=n.channelNameContainsFilter)&&void 0!==_?_:"",s.myMemberStateFilter=null!==(m=n.myMemberStateFilter)&&void 0!==m?m:e.MyMemberStateFilter.ALL,s.unreadChannelFilter=null!==(g=n.unreadChannelFilter)&&void 0!==g?g:e.UnreadChannelFilter.ALL,s.superChannelFilter=null!==(y=n.superChannelFilter)&&void 0!==y?y:e.SuperChannelFilter.ALL,s.publicChannelFilter=null!==(k=n.publicChannelFilter)&&void 0!==k?k:e.PublicChannelFilter.ALL,s.hiddenChannelFilter=null!==(b=n.hiddenChannelFilter)&&void 0!==b?b:e.HiddenChannelFilter.UNHIDDEN,s.searchFilter=null!==(E=n.searchFilter)&&void 0!==E?E:{fields:[],query:null},s.userIdsFilter=null!==(w=n.userIdsFilter)&&void 0!==w?w:{userIds:[],includeMode:!0,queryType:e.QueryType.AND},s.metadataKey=null!==(x=n.metadataKey)&&void 0!==x?x:null,s.metadataValues=null!==(C=n.metadataValues)&&void 0!==C?C:null,s.metadataOrderKeyFilter=null!==(T=n.metadataOrderKeyFilter)&&void 0!==T?T:null,s.metadataValueStartsWith=null!==(S=n.metadataValueStartsWith)&&void 0!==S?S:null,s.order=null!==(I=n.order)&&void 0!==I?I:e.GroupChannelListOrder.LATEST_LAST_MESSAGE,s}return s(u,[{key:"_validate",value:function(){return p(o(u.prototype),"_validate",this).call(this)&&L("boolean",this.includeEmpty)&&L("boolean",this.includeFrozen)&&L("boolean",this.includeMetaData)&&L("string",this.channelNameContainsFilter)&&F("string",this.channelUrlsFilter,!0)&&F("string",this.customTypesFilter,!0)&&L("string",this.customTypeStartsWithFilter)&&L("string",this.nicknameContainsFilter,!0)&&L("string",this.nicknameStartsWithFilter,!0)&&L("string",this.nicknameExactMatchFilter,!0)&&D(e.MyMemberStateFilter,this.myMemberStateFilter)&&D(e.SuperChannelFilter,this.superChannelFilter)&&D(e.PublicChannelFilter,this.publicChannelFilter)&&D(e.UnreadChannelFilter,this.unreadChannelFilter)&&D(e.HiddenChannelFilter,this.hiddenChannelFilter)&&F(e.GroupChannelSearchField,this.searchFilter.fields)&&L("string",this.searchFilter.query,!0)&&F("string",this.userIdsFilter.userIds)&&L("boolean",this.userIdsFilter.includeMode)&&D(e.QueryType,this.userIdsFilter.queryType)&&D(e.GroupChannelListOrder,this.order)&&L("string",this.metadataOrderKeyFilter,!0)&&L("string",this.metadataKey,!0)&&F("string",this.metadataValues,!0)&&L("string",this.metadataValueStartsWith,!0)}},{key:"serialize",value:function(){return Ka(this)}},{key:"next",value:function(){return b(this,void 0,void 0,t().mark((function e(){var n,r,a,s;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!this._validate()){e.next=20;break}if(this._isLoading){e.next=17;break}if(!this._hasNext){e.next=14;break}return this._isLoading=!0,n=Rf.of(this._iid),e.next=7,n.getMyGroupChannels(this._token,this,this.limit);case 7:return r=e.sent,a=r.channels,s=r.token,this._token=s,this._hasNext=!!s,this._isLoading=!1,e.abrupt("return",a);case 14:return e.abrupt("return",[]);case 17:throw A.queryInProgress;case 18:e.next=21;break;case 20:throw A.invalidParameters;case 21:case"end":return e.stop()}}),e,this)})))}}]),u}(Si),Af=function(){function e(t){var n=t.top,a=void 0===n?Number.MAX_SAFE_INTEGER:n,s=t.bottom,i=void 0===s?0:s;r(this,e),this.top=a,this.bottom=i}return s(e,[{key:"includes",value:function(){for(var e=this,t=arguments.length,n=new Array(t),r=0;r0||G.unreadMentionCount>0)&&(G._updateUnreadCount(0,0),this._dispatcher.dispatch(new hu({channels:[G],source:e.GroupChannelEventSource.EVENT_CHANNEL_READ})),wa((function(){return b(cn,void 0,void 0,t().mark((function e(){var n,r;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:n=y(this._groupChannelHandlers.values());try{for(n.s();!(r=n.n()).done;)r.value.onChannelChanged(G)}catch(e){n.e(e)}finally{n.f()}case 2:case"end":return e.stop()}}),e,this)})))}))):0!==G.unreadMessageCount&&0!==G.unreadMentionCount||(this._dispatcher.dispatch(new hu({channels:[G],source:e.GroupChannelEventSource.EVENT_CHANNEL_READ})),wa((function(){return b(cn,void 0,void 0,t().mark((function e(){var n,r;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:n=y(this._groupChannelHandlers.values());try{for(n.s();!(r=n.n()).done;)r.value.onChannelChanged(G)}catch(e){n.e(e)}finally{n.f()}case 2:case"end":return e.stop()}}),e,this)})))}))):(this._dispatcher.dispatch(new hu({channels:[G],source:e.GroupChannelEventSource.EVENT_CHANNEL_READ})),wa((function(){return b(cn,void 0,void 0,t().mark((function e(){var n,r;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:n=y(this._groupChannelHandlers.values());try{for(n.s();!(r=n.n()).done;)r.value.onUnreadMemberStatusUpdated(G)}catch(e){n.e(e)}finally{n.f()}case 2:case"end":return e.stop()}}),e,this)})))})));case 80:return r.abrupt("break",335);case 81:return q=n.as(pf),H=q.channelUrl,j=q.deliveredStateUpdate,z=void 0===j?{}:j,V=this._groupChannelCache.isCachedInMemory(H),r.next=85,this.getChannel(H,!0);case 85:if(B=r.sent,V)for(Q in z)B._updateUndeliveredMemberState(Q,z[Q]);return Object.keys(z).some((function(e){return e!==cn._sdkState.userId}))&&(this._dispatcher.dispatch(new hu({channels:[B],source:e.GroupChannelEventSource.EVENT_CHANNEL_DELIVERED})),wa((function(){return b(cn,void 0,void 0,t().mark((function e(){var n,r;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:n=y(this._groupChannelHandlers.values());try{for(n.s();!(r=n.n()).done;)r.value.onUndeliveredMemberStatusUpdated(B)}catch(e){n.e(e)}finally{n.f()}case 2:case"end":return e.stop()}}),e,this)})))}))),r.abrupt("break",335);case 89:if(K=n.as(Sf),W=K.channelUrl,Y=K.channelType,Z=K.event,Y!==e.ChannelType.GROUP){r.next=99;break}return r.next=93,this.getChannel(W,!0);case 93:return J=r.sent,r.next=96,this.getMessageFromCache(Z.messageId);case 96:(X=r.sent)&&(X.applyReactionEvent(Z),this._dispatcher.dispatch(new oi({messages:[X],source:e.MessageEventSource.EVENT_MESSAGE_REACTION_UPDATED}))),wa((function(){return b(cn,void 0,void 0,t().mark((function e(){var n,r;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:n=y(this._groupChannelHandlers.values());try{for(n.s();!(r=n.n()).done;)r.value.onReactionUpdated(J,Z)}catch(e){n.e(e)}finally{n.f()}case 2:case"end":return e.stop()}}),e,this)})))}));case 99:return r.abrupt("break",335);case 100:if($=n.as(If),(ee=$.event).channelType!==e.ChannelType.GROUP){r.next=110;break}return r.next=104,this.getChannel(ee.channelUrl,!0);case 104:return te=r.sent,r.next=107,this.getMessageFromCache(ee.targetMessageId);case 107:(ne=r.sent)&&(ne.applyThreadInfoUpdateEvent(ee),this._dispatcher.dispatch(new oi({messages:[ne],source:e.MessageEventSource.EVENT_MESSAGE_THREADINFO_UPDATED}))),wa((function(){return b(cn,void 0,void 0,t().mark((function e(){var n,r;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:n=y(this._groupChannelHandlers.values());try{for(n.s();!(r=n.n()).done;)r.value.onThreadInfoUpdated(te,ee)}catch(e){n.e(e)}finally{n.f()}case 2:case"end":return e.stop()}}),e,this)})))}));case 110:return r.abrupt("break",335);case 111:re=n.as(wf),ae=re.groupChannelMemberCounts,se=[],ie=y(ae),r.prev=114,ie.s();case 116:if((oe=ie.n()).done){r.next=125;break}return ue=oe.value,ce=ue.channelUrl,le=ue.memberCount,he=ue.joinedMemberCount,de=ue.updatedAt,r.next=121,this.getChannelFromCache(ce);case 121:(fe=r.sent)&&fe._setLatestMemberCount(le,he,de)&&se.push(fe);case 123:r.next=116;break;case 125:r.next=130;break;case 127:r.prev=127,r.t2=r.catch(114),ie.e(r.t2);case 130:return r.prev=130,ie.f(),r.finish(130);case 133:return se.length>0&&(this._dispatcher.dispatch(new hu({channels:se,source:e.GroupChannelEventSource.EVENT_CHANNEL_MEMBER_COUNT_UPDATED})),wa((function(){return b(cn,void 0,void 0,t().mark((function e(){var n,r;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:n=y(this._groupChannelHandlers.values());try{for(n.s();!(r=n.n()).done;)r.value.onChannelMemberCountChanged(se)}catch(e){n.e(e)}finally{n.f()}case 2:case"end":return e.stop()}}),e,this)})))}))),r.abrupt("break",335);case 135:if(pe=n.as(Nf),ve=pe.event,_e=pe.status,me=pe.channelUrl,ge=pe.channelType,!me||ge!==e.ChannelType.GROUP){r.next=142;break}return r.next=139,this.getChannel(me,!0);case 139:ye=r.sent,this._dispatcher.dispatch(new hi({event:ve,source:e.MessageEventSource.EVENT_POLL_UPDATED})),wa(_e===Ls?function(){return b(cn,void 0,void 0,t().mark((function e(){var n,r;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:n=y(this._groupChannelHandlers.values());try{for(n.s();!(r=n.n()).done;)r.value.onPollDeleted(ye,ve.pollId)}catch(e){n.e(e)}finally{n.f()}case 2:case"end":return e.stop()}}),e,this)})))}:function(){return b(cn,void 0,void 0,t().mark((function e(){var n,r;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:n=y(this._groupChannelHandlers.values());try{for(n.s();!(r=n.n()).done;)r.value.onPollUpdated(ye,ve)}catch(e){n.e(e)}finally{n.f()}case 2:case"end":return e.stop()}}),e,this)})))});case 142:return r.abrupt("break",335);case 143:if(ke=n.as($h),be=ke.event,Ee=ke.channelUrl,we=ke.channelType,!Ee||we!==e.ChannelType.GROUP){r.next=150;break}return r.next=147,this.getChannel(Ee,!0);case 147:xe=r.sent,this._dispatcher.dispatch(new di({event:be,source:e.MessageEventSource.EVENT_POLL_VOTED})),wa((function(){return b(cn,void 0,void 0,t().mark((function e(){var n,r;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:n=y(this._groupChannelHandlers.values());try{for(n.s();!(r=n.n()).done;)r.value.onPollVoted(xe,be)}catch(e){n.e(e)}finally{n.f()}case 2:case"end":return e.stop()}}),e,this)})))}));case 150:return r.abrupt("break",335);case 151:if(Ce=n.as($d),!(Te=Ce.event).isGroupChannelEvent){r.next=323;break}r.t3=Te.category,r.next=r.t3===fd.CHANNEL_JOIN?156:r.t3===fd.CHANNEL_LEAVE?165:r.t3===fd.CHANNEL_OPERATOR_UPDATE?181:r.t3===fd.CHANNEL_INVITE?192:r.t3===fd.CHANNEL_DECLINE_INVITE?202:r.t3===fd.TYPING_START||r.t3===fd.TYPING_END?210:r.t3===fd.USER_CHANNEL_MUTE||r.t3===fd.USER_CHANNEL_UNMUTE?219:r.t3===fd.USER_CHANNEL_BAN?246:r.t3===fd.USER_CHANNEL_UNBAN?259:r.t3===fd.CHANNEL_FREEZE||r.t3===fd.CHANNEL_UNFREEZE?265:r.t3===fd.CHANNEL_HIDE?273:r.t3===fd.CHANNEL_UNHIDE?283:r.t3===fd.CHANNEL_DELETED?290:r.t3===fd.CHANNEL_PROP_CHANGED?296:r.t3===fd.CHANNEL_META_DATA_CHANGED?302:r.t3===fd.CHANNEL_META_COUNTERS_CHANGED?311:r.t3===fd.PINNED_MESSAGE_CHANGED?317:323;break;case 156:return r.next=158,this.getChannel(Te.channelUrl,!0);case 158:return Se=r.sent,Ie=n.as(nf),Ne=Ie.memberCount,Me=Ie.joinedMemberCount,Ae=Ie.members,Oe=!1,Ae.forEach((function(t){Se.isExclusive||Se.isSuper||Se.isBroadcast?Oe=Oe||Se._setLatestMemberCount(Ne,Me,Te.ts):(t.state=e.MemberState.JOINED,Se.addMember(t,Te.ts),cn._updateJoinedMemberCount(Se)),t.userId===cn._sdkState.userId&&(Se.myMemberState=e.MemberState.JOINED)})),this._dispatcher.dispatch(new hu({channels:[Se],source:e.GroupChannelEventSource.EVENT_CHANNEL_JOINED})),wa((function(){return b(cn,void 0,void 0,t().mark((function e(){return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:this._groupChannelHandlers.forEach((function(e){var t,n=y(Ae);try{for(n.s();!(t=n.n()).done;){var r=t.value;e.onUserJoined(Se,r)}}catch(e){n.e(e)}finally{n.f()}Se.isBroadcast&&Oe&&e.onChannelMemberCountChanged([Se])}));case 1:case"end":return e.stop()}}),e,this)})))})),r.abrupt("break",323);case 165:if(!(Ue=this._leftChannels.get(Te.channelUrl))){r.next=170;break}r.t4=Ue.channel,r.next=173;break;case 170:return r.next=172,this.getChannel(Te.channelUrl,!0);case 172:r.t4=r.sent;case 173:return Re=r.t4,Le=n.as(af),De=Le.memberCount,Pe=Le.joinedMemberCount,Fe=Le.member,Ge=!1,qe=ds.of(this._iid),He=qe.appInfo,Re.isExclusive||Re.isSuper||Re.isBroadcast?Ge=Re._setLatestMemberCount(De,Pe,Te.ts):(He.enabledChannelMemberShipHistory?(Re.members.find((function(e){return e.userId===Fe.userId})).state=e.MemberState.LEFT,Re.memberCount=De):Re.removeMember(Fe),this._updateJoinedMemberCount(Re)),Fe.userId===this._sdkState.userId?(Re.myMemberState=e.MemberState.NONE,Re.invitedAt=0,Re.joinedAt=0,Re._updateUnreadCount(0,0),Re.isPublic?this._dispatcher.dispatch(new hu({channels:[Re],source:e.GroupChannelEventSource.EVENT_CHANNEL_LEFT})):(this._markAsLeave(Re),this._dispatcher.dispatch(new du({channelUrls:[Re.url],source:e.GroupChannelEventSource.EVENT_CHANNEL_LEFT})))):this._dispatcher.dispatch(new hu({channels:[Re],source:e.GroupChannelEventSource.EVENT_CHANNEL_LEFT})),wa((function(){return b(cn,void 0,void 0,t().mark((function e(){return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:this._groupChannelHandlers.forEach((function(e){e.onUserLeft(Re,Fe),Re.isBroadcast&&Ge&&e.onChannelMemberCountChanged([Re])}));case 1:case"end":return e.stop()}}),e,this)})))})),r.abrupt("break",323);case 181:return r.next=183,this.getChannel(Te.channelUrl,!0);case 183:je=r.sent,ze=n.as(Ef),Ve=ze.operators,Be=Ve.map((function(e){return e.userId})),Qe=y(je.members);try{for(Qe.s();!(Ke=Qe.n()).done;)(We=Ke.value).role=Be.includes(We.userId)?e.Role.OPERATOR:e.Role.NONE}catch(e){Qe.e(e)}finally{Qe.f()}return je.myRole=Be.includes(this._sdkState.userId)?e.Role.OPERATOR:e.Role.NONE,this._dispatcher.dispatch(new hu({channels:[je],source:e.GroupChannelEventSource.EVENT_CHANNEL_OPERATOR_UPDATED})),wa((function(){return b(cn,void 0,void 0,t().mark((function e(){return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:this._groupChannelHandlers.forEach((function(e){e.onOperatorUpdated(je,Ve)}));case 1:case"end":return e.stop()}}),e,this)})))})),r.abrupt("break",323);case 192:return r.next=194,this.getChannel(Te.channelUrl,!0);case 194:Ye=r.sent,Ze=n.as(uf),Je=Ze.memberCount,Xe=Ze.joinedMemberCount,$e=Ze.inviter,(et=Ze.invitees).forEach((function(t){return t.state=e.MemberState.INVITED})),tt=y(et);try{for(tt.s();!(nt=tt.n()).done;)rt=nt.value,Ye.isExclusive||Ye.isSuper||Ye.isBroadcast?Ye._setLatestMemberCount(Je,Xe,Te.ts):Ye.addMember(rt,Te.ts),this._sdkState.userId===rt.userId&&(Ye.hiddenState=e.HiddenState.UNHIDDEN,Ye.myMemberState!==e.MemberState.JOINED&&(Ye.myMemberState=e.MemberState.INVITED),Ye.invitedAt=Te.ts)}catch(e){tt.e(e)}finally{tt.f()}return this._dispatcher.dispatch(new hu({channels:[Ye],source:e.GroupChannelEventSource.EVENT_CHANNEL_INVITED})),wa((function(){return b(cn,void 0,void 0,t().mark((function e(){return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:this._groupChannelHandlers.forEach((function(e){e.onUserReceivedInvitation(Ye,$e,et)}));case 1:case"end":return e.stop()}}),e,this)})))})),r.abrupt("break",323);case 202:return r.next=204,this.getChannel(Te.channelUrl,!0);case 204:return at=r.sent,st=n.as(lf),it=st.memberCount,ot=st.joinedMemberCount,ut=st.inviter,ct=st.invitee,at.isExclusive||at.isSuper||at.isBroadcast?at._setLatestMemberCount(it,ot,Te.ts):at.removeMember(ct),this._sdkState.userId===ct.userId?(at.invitedAt=0,at.myMemberState=e.MemberState.NONE,at.isPublic?this._dispatcher.dispatch(new hu({channels:[at],source:e.GroupChannelEventSource.EVENT_CHANNEL_DECLINED_INVITE})):this._dispatcher.dispatch(new du({channelUrls:[at.url],source:e.GroupChannelEventSource.EVENT_CHANNEL_DECLINED_INVITE}))):this._dispatcher.dispatch(new hu({channels:[at],source:e.GroupChannelEventSource.EVENT_CHANNEL_DECLINED_INVITE})),wa((function(){return b(cn,void 0,void 0,t().mark((function e(){return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:this._groupChannelHandlers.forEach((function(e){e.onUserDeclinedInvitation(at,ut,ct)}));case 1:case"end":return e.stop()}}),e,this)})))})),r.abrupt("break",323);case 210:return r.next=212,this.getChannel(Te.channelUrl,!0);case 212:return lt=r.sent,ht=Te.category===fd.TYPING_START,dt=n.as(ht?yf:bf),ft=dt.user,lt._updateTypingStatus(ft,ht?Te.ts:0),this._dispatcher.dispatch(new hu({channels:[lt],source:e.GroupChannelEventSource.EVENT_CHANNEL_TYPING_STATUS_UPDATE})),wa((function(){return b(cn,void 0,void 0,t().mark((function e(){return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:this._groupChannelHandlers.forEach((function(e){e.onTypingStatusUpdated(lt)}));case 1:case"end":return e.stop()}}),e,this)})))})),r.abrupt("break",323);case 219:return r.next=221,this.getChannel(Te.channelUrl,!0);case 221:pt=r.sent,vt=Te.category===fd.USER_CHANNEL_MUTE,_t=n.as(vt?hh:fh),(mt=_t.user).userId===this._sdkState.userId&&(pt.myMutedState=vt?e.MutedState.MUTED:e.MutedState.UNMUTED,pt._myMutedRemainingTime=mt.restrictionInfo.remainingDuration),gt=y(pt.members),r.prev=226,gt.s();case 228:if((yt=gt.n()).done){r.next=235;break}if((kt=yt.value).userId!==mt.userId){r.next=233;break}return kt.isMuted=vt,r.abrupt("break",235);case 233:r.next=228;break;case 235:r.next=240;break;case 237:r.prev=237,r.t5=r.catch(226),gt.e(r.t5);case 240:return r.prev=240,gt.f(),r.finish(240);case 243:return this._dispatcher.dispatch(new hu({channels:[pt],source:vt?e.GroupChannelEventSource.EVENT_CHANNEL_MUTED:e.GroupChannelEventSource.EVENT_CHANNEL_UNMUTED,data:mt.userId})),wa((function(){return b(cn,void 0,void 0,t().mark((function e(){return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:this._groupChannelHandlers.forEach((function(e){vt?e.onUserMuted(pt,mt):e.onUserUnmuted(pt,mt)}));case 1:case"end":return e.stop()}}),e,this)})))})),r.abrupt("break",323);case 246:if(!(bt=this._leftChannels.get(Te.channelUrl))){r.next=251;break}r.t6=bt.channel,r.next=254;break;case 251:return r.next=253,this.getChannel(Te.channelUrl,!0);case 253:r.t6=r.sent;case 254:return Et=r.t6,this._markAsLeave(Et),wt=n.as(vh),xt=wt.user,wa((function(){return b(cn,void 0,void 0,t().mark((function e(){return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:this._groupChannelHandlers.forEach((function(e){e.onUserBanned(Et,xt)}));case 1:case"end":return e.stop()}}),e,this)})))})),r.abrupt("break",323);case 259:return r.next=261,this.getChannel(Te.channelUrl,!0);case 261:return Ct=r.sent,Tt=n.as(mh),St=Tt.user,wa((function(){return b(cn,void 0,void 0,t().mark((function e(){return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:this._groupChannelHandlers.forEach((function(e){e.onUserUnbanned(Ct,St)}));case 1:case"end":return e.stop()}}),e,this)})))})),r.abrupt("break",323);case 265:return r.next=267,this.getChannel(Te.channelUrl,!0);case 267:return It=r.sent,Nt=n.as(yh),Mt=Nt.freeze,It.isFrozen=Mt,this._dispatcher.dispatch(new hu({channels:[It],source:Mt?e.GroupChannelEventSource.EVENT_CHANNEL_FROZEN:e.GroupChannelEventSource.EVENT_CHANNEL_UNFROZEN})),wa((function(){return b(cn,void 0,void 0,t().mark((function e(){return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:this._groupChannelHandlers.forEach((function(e){Mt?e.onChannelFrozen(It):e.onChannelUnfrozen(It)}));case 1:case"end":return e.stop()}}),e,this)})))})),r.abrupt("break",323);case 273:return r.next=275,this.getChannel(Te.channelUrl,!0);case 275:return At=r.sent,Ot=n.as(mf),Ut=Ot.allowAutoUnhide,Rt=Ot.hidePreviousMessages,Lt=Ot.messageOffsetTimestamp,null!==Ut&&(At.hiddenState=Ut?e.HiddenState.HIDDEN_ALLOW_AUTO_UNHIDE:e.HiddenState.HIDDEN_PREVENT_AUTO_UNHIDE),null!==Rt&&Rt&&At._updateUnreadCount(0,0),null!==Lt&&(At.messageOffsetTimestamp=Lt),this._dispatcher.dispatch(new hu({channels:[At],source:e.GroupChannelEventSource.EVENT_CHANNEL_HIDDEN})),wa((function(){return b(cn,void 0,void 0,t().mark((function e(){return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:this._groupChannelHandlers.forEach((function(e){e.onChannelHidden(At)}));case 1:case"end":return e.stop()}}),e,this)})))})),r.abrupt("break",323);case 283:return r.next=285,this.getChannel(Te.channelUrl,!0);case 285:return(Dt=r.sent).hiddenState=e.HiddenState.UNHIDDEN,this._dispatcher.dispatch(new hu({channels:[Dt],source:e.GroupChannelEventSource.EVENT_CHANNEL_UNHIDDEN})),wa((function(){return b(cn,void 0,void 0,t().mark((function e(){return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:this._groupChannelHandlers.forEach((function(e){e.onChannelChanged(Dt)}));case 1:case"end":return e.stop()}}),e,this)})))})),r.abrupt("break",323);case 290:return r.next=292,this.getChannel(Te.channelUrl,!0);case 292:return Pt=r.sent,this._dispatcher.dispatch(new du({channelUrls:[Te.channelUrl],source:e.GroupChannelEventSource.EVENT_CHANNEL_DELETED})),wa((function(){return b(cn,void 0,void 0,t().mark((function e(){return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:this._groupChannelHandlers.forEach((function(e){e.onChannelDeleted(Pt.url,Pt.channelType)}));case 1:case"end":return e.stop()}}),e,this)})))})),r.abrupt("break",323);case 296:return r.next=298,this.getChannelWithoutCache(Te.channelUrl,!0);case 298:return Ft=r.sent,this._dispatcher.dispatch(new hu({channels:[Ft],source:e.GroupChannelEventSource.EVENT_CHANNEL_UPDATED})),wa((function(){return b(cn,void 0,void 0,t().mark((function e(){return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:this._groupChannelHandlers.forEach((function(e){e.onChannelChanged(Ft)}));case 1:case"end":return e.stop()}}),e,this)})))})),r.abrupt("break",323);case 302:return r.next=304,this.getChannel(Te.channelUrl,!0);case 304:return Gt=r.sent,qt=n.as(Zl),Ht=qt.created,jt=qt.updated,zt=qt.deleted,Ht&&Gt._upsertCachedMetaData(Ht,Te.ts),jt&&Gt._upsertCachedMetaData(jt,Te.ts),zt&&Gt._removeFromCachedMetaData(zt,Te.ts),wa((function(){return b(cn,void 0,void 0,t().mark((function e(){return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:this._groupChannelHandlers.forEach((function(e){Ht&&e.onMetaDataCreated(Gt,Ht),jt&&e.onMetaDataUpdated(Gt,jt),zt&&e.onMetaDataDeleted(Gt,zt)}));case 1:case"end":return e.stop()}}),e,this)})))})),r.abrupt("break",323);case 311:return r.next=313,this.getChannel(Te.channelUrl,!0);case 313:return Vt=r.sent,Bt=n.as(oh),Qt=Bt.created,Kt=Bt.updated,Wt=Bt.deleted,wa((function(){return b(cn,void 0,void 0,t().mark((function e(){return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:this._groupChannelHandlers.forEach((function(e){Qt&&e.onMetaCounterCreated(Vt,Qt),Kt&&e.onMetaCounterUpdated(Vt,Kt),Wt&&e.onMetaCounterDeleted(Vt,Wt)}));case 1:case"end":return e.stop()}}),e,this)})))})),r.abrupt("break",323);case 317:return r.next=319,this.getChannel(Te.channelUrl,!0);case 319:return Yt=r.sent,Zt=n.as(Of),Jt=Zt.pinnedMessageIds,Xt=Zt.latestPinnedMessage,($t=Zt.ts)>Yt._pinnedMessagesUpdatedAt&&(Yt.pinnedMessageIds=Jt,Yt.lastPinnedMessage=Xt,Yt._pinnedMessagesUpdatedAt=$t,this._dispatcher.dispatch(new hu({channels:[Yt],source:e.GroupChannelEventSource.EVENT_PINNED_MESSAGE_UPDATED})),wa((function(){return b(cn,void 0,void 0,t().mark((function e(){var n,r;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:n=y(this._groupChannelHandlers.values());try{for(n.s();!(r=n.n()).done;)r.value.onChannelChanged(Yt)}catch(e){n.e(e)}finally{n.f()}case 2:case"end":return e.stop()}}),e,this)})))})),wa((function(){return b(cn,void 0,void 0,t().mark((function e(){return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:this._groupChannelHandlers.forEach((function(e){e.onPinnedMessageUpdated(Yt)}));case 1:case"end":return e.stop()}}),e,this)})))}))),r.abrupt("break",323);case 323:return r.abrupt("break",335);case 324:en=n.as(pu),tn=en.event,r.t7=tn.category,r.next=r.t7===Ho.USER_BLOCK?328:r.t7===Ho.USER_UNBLOCK?331:334;break;case 328:return nn=ou.getDataAsUserBlockEvent(this._iid,tn),rn=nn.blocker,an=nn.blockee,this._groupChannelCache.block(rn.userId,an.userId),r.abrupt("break",334);case 331:return sn=ou.getDataAsUserBlockEvent(this._iid,tn),on=sn.blocker,un=sn.blockee,this._groupChannelCache.unblock(on.userId,un.userId),r.abrupt("break",334);case 334:return r.abrupt("break",335);case 335:r.next=341;break;case 337:if(r.prev=337,r.t8=r.catch(0),!M(r.t8)){r.next=341;break}throw r.t8;case 341:case"end":return r.stop()}}),r,this,[[0,337],[19,30,33,36],[114,127,130,133],[226,237,240,243]])})))}},{key:"_markAsLeave",value:function(e){var t,n=this,r=null!==(t=this._leftChannels.get(e.url))&&void 0!==t?t:{channel:e,ref:0};r.ref++,this._leftChannels.set(e.url,r),setTimeout((function(){r.ref--,0===r.ref&&n._leftChannels.delete(e.url)}),1e4)}},{key:"addHandler",value:function(e,t){this._groupChannelHandlers.set(e,t)}},{key:"removeHandler",value:function(e){this._groupChannelHandlers.delete(e)}},{key:"clearHandler",value:function(){this._groupChannelHandlers.clear()}},{key:"subscribeGroupChannelEvent",value:function(e,t){this._groupChannelBroadcast.subscribe(e,t)}},{key:"unsubscribeGroupChannelEvent",value:function(e){this._groupChannelBroadcast.unsubscribe(e)}},{key:"subscribeMessageEvent",value:function(e,t){this._messageBroadcast.subscribe(e,t)}},{key:"unsubscribeMessageEvent",value:function(e){this._messageBroadcast.unsubscribe(e)}},{key:"_updateJoinedMemberCount",value:function(t){t.joinedMemberCount=t.members.filter((function(t){return t.state===e.MemberState.JOINED})).length}},{key:"getChannel",value:function(e){var n=arguments.length>1&&void 0!==arguments[1]&&arguments[1];return b(this,void 0,void 0,t().mark((function r(){var a;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return Ya(L("string",e)).throw(A.invalidParameters),t.prev=1,t.next=4,this.getChannelFromCache(e);case 4:if(!(a=t.sent)){t.next=7;break}return t.abrupt("return",a);case 7:t.next=11;break;case 9:t.prev=9,t.t0=t.catch(1);case 11:return t.next=13,this.getChannelWithoutCache(e,n);case 13:return t.abrupt("return",t.sent);case 14:case"end":return t.stop()}}),r,this,[[1,9]])})))}},{key:"getChannelWithoutCache",value:function(n){var r=arguments.length>1&&void 0!==arguments[1]&&arguments[1];return b(this,void 0,void 0,t().mark((function a(){var s,i,o,u,c,l;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return Ya(L("string",n)).throw(A.invalidParameters),s=new Ld({channelUrl:n,isInternalCall:r}),t.next=4,this._requestQueue.send(s);case 4:i=t.sent,o=i.as(Dd),u=o.channel,c=u.unreadMessageCount,l=u.unreadMentionCount,t.t0=u.myCountPreference,t.next=t.t0===e.CountPreference.UNREAD_MESSAGE_COUNT_ONLY?10:t.t0===e.CountPreference.UNREAD_MENTION_COUNT_ONLY?12:t.t0===e.CountPreference.OFF?14:17;break;case 10:return l=0,t.abrupt("break",17);case 12:return c=0,t.abrupt("break",17);case 14:return c=0,l=0,t.abrupt("break",17);case 17:return u._updateUnreadCount(c,l),t.next=20,this.upsertChannelsToCache([u]);case 20:return t.abrupt("return",t.sent[0]);case 21:case"end":return t.stop()}}),a,this)})))}},{key:"refreshChannel",value:function(n){var r=!(arguments.length>1&&void 0!==arguments[1])||arguments[1],a=arguments.length>2&&void 0!==arguments[2]?arguments[2]:e.GroupChannelEventSource.REFRESH_CHANNEL;return b(this,void 0,void 0,t().mark((function s(){var i,o,u,c,l;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.prev=0,i=new Ld({channelUrl:n,isInternalCall:r}),t.next=4,this._requestQueue.send(i);case 4:if(o=t.sent,u=o.as(Dd),(c=u.channel).myMemberState!==e.MemberState.NONE){t.next=10;break}this._dispatcher.dispatch(new du({channelUrls:[c.url],source:a})),t.next=14;break;case 10:return t.next=12,this.upsertChannelsToCache([c]);case 12:l=t.sent,this._dispatcher.dispatch(new hu({channels:l,source:a}));case 14:t.next=19;break;case 16:t.prev=16,t.t0=t.catch(0),t.t0.code!==E.NON_AUTHORIZED&&t.t0.code!==E.NOT_FOUND_IN_DATABASE||this._dispatcher.dispatch(new du({channelUrls:[n],source:a}));case 19:case"end":return t.stop()}}),s,this,[[0,16]])})))}},{key:"getMyGroupChannels",value:function(n,r,a){var s=arguments.length>3&&void 0!==arguments[3]?arguments[3]:e.GroupChannelEventSource.REQUEST_CHANNEL;return b(this,void 0,void 0,t().mark((function e(){var i,o,u,c,l;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return i=new Pd(Object.assign(Object.assign({},r),{userId:this._sdkState.userId,token:n,limit:a})),e.next=3,this._requestQueue.send(i);case 3:return o=e.sent,u=o.as(Fd),c=u.channels,l=u.token,this._dispatcher.dispatch(new hu({channels:c,source:s})),e.abrupt("return",{channels:c,token:l});case 7:case"end":return e.stop()}}),e,this)})))}},{key:"getMessageFromCache",value:function(e){return b(this,void 0,void 0,t().mark((function n(){return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,this._messageCache.get(e);case 2:return t.abrupt("return",t.sent);case 3:case"end":return t.stop()}}),n,this)})))}},{key:"getMessagesFromCache",value:function(e,n,r,a){var s=arguments.length>4&&void 0!==arguments[4]?arguments[4]:go;return b(this,void 0,void 0,t().mark((function i(){return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,this._messageCache.fetch({channelUrl:e,token:n,limit:s,filter:a,backward:"next"===r});case 2:return t.abrupt("return",t.sent);case 3:case"end":return t.stop()}}),i,this)})))}},{key:"getPollMessagesFromCache",value:function(e,n,r){var a=arguments.length>3&&void 0!==arguments[3]?arguments[3]:go;return b(this,void 0,void 0,t().mark((function s(){return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,this._messageCache.fetch({channelUrl:e,token:n,limit:a,filter:r,backward:!1,isPollOnly:!0});case 2:return t.abrupt("return",t.sent);case 3:case"end":return t.stop()}}),s,this)})))}},{key:"getUnsentMessagesFromCache",value:function(e,n){return b(this,void 0,void 0,t().mark((function r(){return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,this._unsentMessageCache.fetch({channelUrl:e,filter:n});case 2:return t.abrupt("return",t.sent);case 3:case"end":return t.stop()}}),r,this)})))}},{key:"removeFailedMessageFromCache",value:function(e){return b(this,void 0,void 0,t().mark((function n(){return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,this._unsentMessageCache.remove([e]);case 2:case"end":return t.stop()}}),n,this)})))}},{key:"getCachedMessageCountBetween",value:function(e,n,r,a){return b(this,void 0,void 0,t().mark((function s(){return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,this._messageCache.countBetween(e,n,new Af({top:r,bottom:a}));case 2:return t.abrupt("return",t.sent);case 3:case"end":return t.stop()}}),s,this)})))}},{key:"getMyGroupChannelChangeLogs",value:function(n,r){var a=arguments.length>2&&void 0!==arguments[2]?arguments[2]:e.GroupChannelEventSource.REQUEST_CHANNEL_CHANGELOGS;return b(this,void 0,void 0,t().mark((function e(){var s,i,o,u,c,l,h;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return s=Object.assign(Object.assign({},kd),r),Ya((L("string",n)||L("number",n))&&bd(s)).throw(A.invalidParameters),i=new Ud(ue({userId:this._sdkState.userId,ts:"number"==typeof n?n:null,token:"string"==typeof n?n:null,filter:s})),e.next=5,this._requestQueue.send(i);case 5:return o=e.sent,u=o.as(Rd),c=u.updatedChannels,l=u.deletedChannelUrls,h=u.hasMore,c.length>0&&this._dispatcher.dispatch(new hu({channels:c,source:a})),l.length>0&&this._dispatcher.dispatch(new du({channelUrls:l,source:a})),e.abrupt("return",{updatedChannels:c,deletedChannelUrls:l,hasMore:h,token:u.token});case 11:case"end":return e.stop()}}),e,this)})))}},{key:"getGroupChannelCount",value:function(e){return b(this,void 0,void 0,t().mark((function n(){var r,a,s,i,o;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return r=Object.assign(Object.assign({},Ed),e),Ya(wd(r)).throw(A.invalidParameters),a=new Gd({userId:this._sdkState.userId,filter:r}),t.next=5,this._requestQueue.send(a);case 5:return s=t.sent,i=s.as(qd),o=i.groupChannelCount,t.abrupt("return",o);case 8:case"end":return t.stop()}}),n,this)})))}},{key:"getUnreadItemCount",value:function(e){return b(this,void 0,void 0,t().mark((function n(){var r,a,s,i,o,u,c,l,h,d,f,p,v,_,m,g;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return r=Object.assign(Object.assign({},Cd),e),Ya(Td(r)).throw(A.invalidParameters),a=ds.of(this._iid),s=a.sdkState,i=a.requestQueue,o=new Hd({userId:s.userId,filter:r}),t.next=6,i.send(o);case 6:return u=t.sent,c=u.as(jd),l=c.groupChannelUnreadMentionCount,h=c.groupChannelUnreadMessageCount,d=c.groupChannelInvitationCount,f=c.superGroupChannelUnreadMentionCount,p=c.superGroupChannelUnreadMessageCount,v=c.superGroupChannelInvitationCount,_=c.nonSuperGroupChannelUnreadMentionCount,m=c.nonSuperGroupChannelUnreadMessageCount,g=c.nonSuperGroupChannelInvitationCount,t.abrupt("return",ue({groupChannelUnreadMentionCount:l,groupChannelUnreadMessageCount:h,groupChannelInvitationCount:d,superGroupChannelUnreadMentionCount:f,superGroupChannelUnreadMessageCount:p,superGroupChannelInvitationCount:v,nonSuperGroupChannelUnreadMentionCount:_,nonSuperGroupChannelUnreadMessageCount:m,nonSuperGroupChannelInvitationCount:g}));case 9:case"end":return t.stop()}}),n,this)})))}},{key:"getTotalUnreadChannelCount",value:function(){return b(this,void 0,void 0,t().mark((function e(){var n,r,a,s,i,o,u;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n=ds.of(this._iid),r=n.sdkState,a=n.requestQueue,s=new zd({userId:r.userId}),e.next=4,a.send(s);case 4:return i=e.sent,o=i.as(Vd),u=o.unreadCount,e.abrupt("return",u);case 7:case"end":return e.stop()}}),e,this)})))}},{key:"getTotalUnreadMessageCount",value:function(e){return b(this,void 0,void 0,t().mark((function n(){var r,a,s,i,o,u,c,l;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return r=Object.assign(Object.assign({},Sd),e),Ya(Id(r)).throw(A.invalidParameters),a=ds.of(this._iid),s=a.sdkState,i=a.requestQueue,o=new Bd({userId:s.userId,filter:r}),t.next=6,i.send(o);case 6:return u=t.sent,c=u.as(Qd),l=c.unreadCount,t.abrupt("return",l);case 9:case"end":return t.stop()}}),n,this)})))}},{key:"getTotalScheduledMessageCount",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return b(this,void 0,void 0,t().mark((function n(){var r,a,s,i,o,u,c;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return r=Object.assign(Object.assign({},Nd),e),Ya(Md(r)).throw(A.invalidParameters),a=ds.of(this._iid),s=a.requestQueue,i=new Kd(r),t.next=6,s.send(i);case 6:return o=t.sent,u=o.as(Wd),c=u.count,t.abrupt("return",c);case 9:case"end":return t.stop()}}),n,this)})))}},{key:"getSubscribedTotalUnreadMessageCount",value:function(){var e=ds.of(this._iid).subscribedUnreadMessageCount;return e.all>=0?e.all:0}},{key:"getSubscribedCustomTypeTotalUnreadMessageCount",value:function(){var e=0,t=ds.of(this._iid).subscribedUnreadMessageCount;for(var n in t.customTypes)e+=t.customTypes[n];return e}},{key:"getSubscribedCustomTypeUnreadMessageCount",value:function(e){var t;return null!==(t=ds.of(this._iid).subscribedUnreadMessageCount.customTypes[e])&&void 0!==t?t:0}},{key:"createChannel",value:function(e){return b(this,void 0,void 0,t().mark((function n(){var r,a,s,i,o;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return r=Object.assign(Object.assign({},gd),e),Ya(yd(r)).throw(A.invalidParameters),r.isPublic||(r.accessCode=null),a=new Zd(Object.assign({userId:this._sdkState.userId},r)),t.next=6,this._requestQueue.send(a);case 6:return s=t.sent,i=s.as(Jd),o=i.channel,t.next=10,this.upsertChannelsToCache([o]);case 10:return t.abrupt("return",o);case 11:case"end":return t.stop()}}),n,this)})))}},{key:"markAsReadAll",value:function(){return b(this,void 0,void 0,t().mark((function e(){var n,r,a,s,i,o;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n=Date.now(),Ya(n-this._markAsReadAllLastSentAt>=1e3).throw(A.markAsReadAllRateLimitExceeded),this._markAsReadAllLastSentAt=n,r=new Xd({userId:this._sdkState.userId}),e.next=6,this._requestQueue.send(r);case 6:a=this._groupChannelCache.channels,s=y(a);try{for(s.s();!(i=s.n()).done;)(o=i.value)._updateUnreadMemberState(this._sdkState.userId,n),o._updateUnreadCount(0,0)}catch(e){s.e(e)}finally{s.f()}if(!(a.length>0)){e.next=12;break}return e.next=12,this.upsertChannelsToCache(a);case 12:case"end":return e.stop()}}),e,this)})))}},{key:"markAsReadWithChannelUrls",value:function(e){return b(this,void 0,void 0,t().mark((function n(){var r,a,s,i,o,u,c;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return r=Date.now(),Ya(F("string",e)&&r-this._markAsReadAllLastSentAt>=1e3).throw(A.markAsReadAllRateLimitExceeded),this._markAsReadAllLastSentAt=r,a=new Xd({userId:this._sdkState.userId,channelUrls:e}),t.next=6,this._requestQueue.send(a);case 6:s=this._groupChannelCache.channels,i=[],o=y(s);try{for(o.s();!(u=o.n()).done;)c=u.value,e.includes(c.url)&&(c._updateUnreadMemberState(this._sdkState.userId,r),c._updateUnreadCount(0,0),i.push(c))}catch(e){o.e(e)}finally{o.f()}if(!(i.length>0)){t.next=13;break}return t.next=13,this.upsertChannelsToCache(i);case 13:case"end":return t.stop()}}),n,this)})))}},{key:"markAsDelivered",value:function(e){return b(this,void 0,void 0,t().mark((function n(){var r;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,this.getChannel(e);case 2:return r=t.sent,t.next=5,r.markAsDelivered();case 5:case"end":return t.stop()}}),n,this)})))}}],[{key:"of",value:function(e){return Uf[e]}},{key:"clear",value:function(e){Uf[e]&&delete Uf[e]}}]),n}();!function(e){e[e.IDLE=0]="IDLE",e[e.RUNNING=1]="RUNNING",e[e.END=2]="END"}(xd||(xd={}));var Lf=function(e){i(a,e);var n=f(a);function a(e,t){var s;return r(this,a),(s=n.call(this))._worker=null,s._state=xd.IDLE,s._semaphore=null,s._retryCount=0,s._retryLimit=3,s.priority=0,s._worker=t,s}return s(a,[{key:"isIdle",get:function(){return this._state===xd.IDLE}},{key:"isRunning",get:function(){return this._state===xd.RUNNING}},{key:"isDone",get:function(){return this._state===xd.END}},{key:"retryCount",get:function(){return this._retryCount}},{key:"retryLimit",get:function(){return this._retryLimit}},{key:"_run",value:function(e){return b(this,void 0,void 0,t().mark((function n(){var r;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(!this.isRunning){t.next=14;break}return t.prev=1,t.next=4,this._worker(e);case 4:r=t.sent,this._retryCount=0,this.dispatch("progress",r),r.hasNext?this._run(r.nextToken):this.end(),t.next=14;break;case 10:t.prev=10,t.t0=t.catch(1),this.dispatch("error",t.t0),this._retryCount0&&(l=u.map((function(e){return e.createdAt})),(c=this._metadata.range).intersect.apply(c,_(l))?this.extendRange(u):this._metadata={range:new Af({top:Math.min.apply(Math,_(l)),bottom:Math.max.apply(Math,_(l))}),previousComplete:!1}),i.hasNext=u.length>=this._limit&&this._prevSyncLoopCount<1,i.nextToken=this._metadata.range.top,this._metadata.previousComplete=u.length0&&(l=u.map((function(e){return e.createdAt})),(c=this._metadata.range).intersect.apply(c,_(l))?this.extendRange(u):this._metadata={range:new Af({top:Math.min.apply(Math,_(l)),bottom:Math.max.apply(Math,_(l))}),previousComplete:!1}),i.hasNext=u.length>=this._limit&&this._nextSyncLoopCount<1,i.nextToken=this._metadata.range.bottom,v.debug("message background next sync progress",i),t.next=16,this.saveMetadata();case 16:t.next=22;break;case 18:throw t.prev=18,t.t0=t.catch(5),v.debug("message background next sync error",t.t0),t.t0;case 22:return t.abrupt("return",i);case 23:case"end":return t.stop()}}),r,this,[[5,18]])})))})),this._connectionEventContext=p.on((function(e){if(e instanceof ha)if(e.stateType===aa.CONNECTED)s.resume();else s.pause()}))}return s(n,[{key:"range",get:function(){var e;return null===(e=this._metadata)||void 0===e?void 0:e.range}},{key:"previousComplete",get:function(){var e;return!!(null===(e=this._metadata)||void 0===e?void 0:e.previousComplete)}},{key:"isWrappingMessages",value:function(e){var t,n;return null===(n=this.range)||void 0===n?void 0:(t=n).includes.apply(t,_(e.map((function(e){return e.createdAt}))))}},{key:"extendRange",value:function(e){var t;this._metadata&&(t=this._metadata.range).extends.apply(t,_(e.map((function(e){return e.createdAt}))))}},{key:"loadMetadata",value:function(e){return b(this,void 0,void 0,t().mark((function n(){var r,a,s;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(this._metadata){t.next=6;break}return r=ds.of(this._iid),a=r.cacheContext,t.next=4,a.preference.get(this._metadataKey);case 4:(s=t.sent)?s.range.bottom0&&void 0!==arguments[0]?arguments[0]:Date.now(),s=ds.of(this._iid),i=s.logger;s.connectionManager.isConnected&&(i.debug("message background sync resume()"),this._prevSyncLoopCount=this._nextSyncLoopCount=0,this._metadata&&this._metadata.previousComplete||this._prevSync.start(null!==(t=null===(e=this._metadata)||void 0===e?void 0:e.range.top)&&void 0!==t?t:a),this._nextSync.start(null!==(r=null===(n=this._metadata)||void 0===n?void 0:n.range.bottom)&&void 0!==r?r:a))}},{key:"pause",value:function(){ds.of(this._iid).logger.debug("message background sync stop()"),this._prevSync.stop(),this._nextSync.stop()}},{key:"close",value:function(){this.ref--,this.ref<=0&&(this.ref=0,this.pause(),this._connectionEventContext.close(),delete Ff[this._iid][this._channel.url])}}],[{key:"of",value:function(e,t){return Ff[e]||(Ff[e]={}),Ff[e][t.url]||(Ff[e][t.url]=new n({_iid:e,channel:t})),Ff[e][t.url].ref++,Ff[e][t.url]}},{key:"clear",value:function(e,t){Ff[e]&&Ff[e][t]&&(Ff[e][t].close(),delete Ff[e])}}]),n}(),qf={},Hf=function(){function n(a){var s=this,i=a._iid,o=a.channel;r(this,n),this._sync=null,this._connectionEventContext=null,this.ref=0,this._metadata=null,this._iid=i,this._channel=o;var u,c,l=ds.of(this._iid),h=l.logger,d=l.sdkState,f=l.dispatcher;this._metadataKey=(u=d.userId,c=o.url,"sendbird:".concat(u,"@groupchannel/").concat(c,"/message/changelogs.meta"));var p=function(e,t){return"sendbird:".concat(e,"@groupchannel/").concat(t,"/message/changelogs")}(d.userId,this._channel.url);this._sync=new Lf(p,(function(){return b(s,void 0,void 0,t().mark((function n(){var r,a,s,i,o,u,c,l;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return a={hasNext:!0,nextToken:0},t.next=3,this.loadMetadata();case 3:return h.debug("message changelog sync from",null===(r=this._metadata)||void 0===r?void 0:r.token),t.prev=4,s=Ei.of(this._iid),t.next=8,s.getMessageChangelogs(this._channel.url,this._channel.channelType,this._metadata.token,{replyType:e.ReplyType.ALL,includeReactions:!0,includeThreadInfo:!0,includeMetaArray:!0,includeParentMessageInfo:!0},e.MessageEventSource.SYNC_MESSAGE_CHANGELOGS);case 8:return i=t.sent,o=i.updatedMessages,u=i.deletedMessageIds,c=i.hasMore,l=i.token,a.hasNext=c,a.nextToken=l,(o.length>0||u.length>0)&&(this._metadata.token=l),h.debug("message changelog sync progress",a),t.next=19,this.saveMetadata();case 19:t.next=28;break;case 21:if(t.prev=21,t.t0=t.catch(4),h.debug("message changelog sync error",t.t0),!(t.t0 instanceof A&&t.t0.isInvalidTokenError)){t.next=27;break}return t.next=27,this.clearMetadata();case 27:throw t.t0;case 28:return t.abrupt("return",a);case 29:case"end":return t.stop()}}),n,this,[[4,21]])})))})),this._connectionEventContext=f.on((function(e){if(e instanceof ha)if(e.stateType===aa.CONNECTED)s.resume();else s.pause()}))}return s(n,[{key:"loadMetadata",value:function(){return b(this,void 0,void 0,t().mark((function e(){var n,r,a,s;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(this._metadata){e.next=6;break}return n=ds.of(this._iid),r=n.cacheContext,a=n.firstConnectedAt,e.next=4,r.preference.get(this._metadataKey);case 4:s=e.sent,this._metadata={token:s?s.token:a};case 6:return e.abrupt("return",this._metadata);case 7:case"end":return e.stop()}}),e,this)})))}},{key:"saveMetadata",value:function(){return b(this,void 0,void 0,t().mark((function e(){var n,r;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!this._metadata){e.next=5;break}return n=ds.of(this._iid),r=n.cacheContext,e.next=4,r.preference.set(this._metadataKey,this._metadata);case 4:return e.abrupt("return",!0);case 5:return e.abrupt("return",!1);case 6:case"end":return e.stop()}}),e,this)})))}},{key:"clearMetadata",value:function(){return b(this,void 0,void 0,t().mark((function e(){var n,r;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n=ds.of(this._iid),r=n.cacheContext,e.next=3,r.preference.remove(this._metadataKey);case 3:this._metadata=null;case 4:case"end":return e.stop()}}),e,this)})))}},{key:"resume",value:function(){var e=ds.of(this._iid),t=e.logger;e.connectionManager.isConnected&&(t.debug("message changelog sync resume()"),this._sync.start(0))}},{key:"pause",value:function(){var e=ds.of(this._iid),t=e.logger;e.connectionManager.isConnected&&(t.debug("message changelog sync pause()"),this._sync.stop())}},{key:"close",value:function(){this.ref--,this.ref<=0&&(this.ref=0,this.pause(),this._connectionEventContext.close(),delete qf[this._iid][this._channel.url])}}],[{key:"of",value:function(e,t){return qf[e]||(qf[e]={}),qf[e][t.url]||(qf[e][t.url]=new n({_iid:e,channel:t})),qf[e][t.url].ref++,qf[e][t.url]}},{key:"clear",value:function(e,t){qf[e]&&qf[e][t]&&(qf[e][t].close(),delete qf[e])}}]),n}(),jf={},zf=function(){function e(n){var a=this,s=n._iid,i=n.channel,o=n.hasPollMessage;r(this,e),this._sync=null,this.ref=0,this._metadata=null,this._iid=s,this._channel=i;var u,c,l=ds.of(this._iid),h=l.logger,d=l.sdkState,f=l.dispatcher;this._metadataKey=(u=d.userId,c=i.url,"sendbird:".concat(u,"@groupchannel/").concat(c,"/poll/changelogs.meta"));var p=function(e,t){return"sendbird:".concat(e,"@groupchannel/").concat(t,"/poll/changelogs")}(d.userId,this._channel.url);this._sync=new Lf(p,(function(){return b(a,void 0,void 0,t().mark((function e(){var n,r,a,s,i,u,c,l,d;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return r={hasNext:!0,nextToken:0},e.next=3,this.loadMetadata();case 3:if(h.debug("poll changelog sync from",null===(n=this._metadata)||void 0===n?void 0:n.token),e.t0=!this._metadata||!this._metadata.token,!e.t0){e.next=9;break}return e.next=8,o();case 8:e.t0=!e.sent;case 9:if(!e.t0){e.next=12;break}return a={hasNext:!1,nextToken:0},e.abrupt("return",a);case 12:return this._metadata||(s=ds.of(this._iid),i=s.firstConnectedAt,this._metadata={token:i}),e.prev=13,u=to.of(this._iid),e.next=17,u.getPollChangeLogs(this._channel.url,this._channel.channelType,this._metadata.token);case 17:return c=e.sent,l=c.hasMore,d=c.token,r.hasNext=l,r.nextToken=d,this._metadata.token=d,h.debug("poll changelog sync progress",r),e.next=26,this.saveMetadata();case 26:e.next=35;break;case 28:if(e.prev=28,e.t1=e.catch(13),h.debug("poll changelog sync error",e.t1),!(e.t1 instanceof A&&e.t1.isInvalidTokenError)){e.next=34;break}return e.next=34,this.clearMetadata();case 34:throw e.t1;case 35:return e.abrupt("return",r);case 36:case"end":return e.stop()}}),e,this,[[13,28]])})))})),this._connectionEventContext=f.on((function(e){if(e instanceof ha)if(e.stateType===aa.CONNECTED)a.resume();else a.pause()}))}return s(e,[{key:"loadMetadata",value:function(){return b(this,void 0,void 0,t().mark((function e(){var n,r,a;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(this._metadata){e.next=6;break}return n=ds.of(this._iid),r=n.cacheContext,e.next=4,r.preference.get(this._metadataKey);case 4:a=e.sent,this._metadata=a?{token:a.token}:null;case 6:case"end":return e.stop()}}),e,this)})))}},{key:"saveMetadata",value:function(){return b(this,void 0,void 0,t().mark((function e(){var n,r;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!this._metadata){e.next=4;break}return n=ds.of(this._iid),r=n.cacheContext,e.next=4,r.preference.set(this._metadataKey,this._metadata);case 4:case"end":return e.stop()}}),e,this)})))}},{key:"clearMetadata",value:function(){return b(this,void 0,void 0,t().mark((function e(){var n,r;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n=ds.of(this._iid),r=n.cacheContext,e.next=3,r.preference.remove(this._metadataKey);case 3:this._metadata=null;case 4:case"end":return e.stop()}}),e,this)})))}},{key:"resume",value:function(){ds.of(this._iid).logger.debug("poll changelog sync resume()"),this._sync.start(0)}},{key:"pause",value:function(){ds.of(this._iid).logger.debug("poll changelog sync pause()"),this._sync.stop()}},{key:"close",value:function(){this.ref--,this.ref<=0&&(this.ref=0,this.pause(),this._connectionEventContext.close(),delete jf[this._iid][this._channel.url])}}],[{key:"of",value:function(t,n,r){return jf[t]||(jf[t]={}),jf[t][n.url]||(jf[t][n.url]=new e({_iid:t,channel:n,hasPollMessage:r})),jf[t][n.url].ref++,jf[t][n.url]}}]),e}(),Vf=function(e){i(n,e);var t=f(n);function n(e){var a,s,i,o,u,c,l;return r(this,n),(a=t.call(this)).method=ce.GET,a.path="".concat(Ce(e.channelType),"/").concat(e.channelUrl,"/messages_gap"),a.params=ue({prev_start_ts:e.prevStart,prev_end_ts:e.prevEnd,prev_cache_count:e.prevCount,next_start_ts:e.nextStart,next_end_ts:e.nextEnd,next_cache_count:e.nextCount,huge_gap_threshold:null!==(s=e.threshold)&&void 0!==s?s:null,reverse:!0,custom_types:null!==(i=e.customTypes)&&void 0!==i?i:["*"],message_type:null!==(o=e.messageType)&&void 0!==o?o:null,include_reactions:null===(u=e.includeReactions)||void 0===u||u,with_sorted_meta_array:null===(c=e.includeMetaArray)||void 0===c||c,show_subchannel_messages_only:null!==(l=e.showSubchannelMessagesOnly)&&void 0!==l&&l,include_poll_details:!0,checking_continuous_messages:e.checkingContinuousMessages}),a}return s(n)}(Ae),Bf=function(e){i(n,e);var t=f(n);function n(e,a){var s,i,o,u,c,l,h;return r(this,n),(s=t.call(this,e,a)).isHugeGap=a.is_huge_gap,s.prevMessages=(null!==(i=a.prev_messages)&&void 0!==i?i:[]).map((function(t){return Vs(e,t)})),s.prevHasMore=null!==(o=a.prev_hasmore)&&void 0!==o&&o,s.isContinuousPrevMessages=null!==(u=a.is_continuous_prev_messages)&&void 0!==u&&u,s.nextMessages=(null!==(c=a.next_messages)&&void 0!==c?c:[]).map((function(t){return Vs(e,t)})),s.nextHasmore=null!==(l=a.next_hasmore)&&void 0!==l&&l,s.isContinuousNextMessages=null!==(h=a.is_continuous_next_messages)&&void 0!==h&&h,s}return s(n)}(Oe),Qf=function(t,n){var r,a;switch(n){case e.GroupChannelListOrder.LATEST_LAST_MESSAGE:return null!==(a=null===(r=t.lastMessage)||void 0===r?void 0:r.createdAt)&&void 0!==a?a:t.createdAt;case e.GroupChannelListOrder.CHRONOLOGICAL:return t.createdAt;case e.GroupChannelListOrder.CHANNEL_NAME_ALPHABETICAL:return t.name}return null},Kf=function(e,t){return e.findIndex((function(e){return e.isIdentical(t)}))},Wf=function(e,t,n){if(e.length>0){for(var r=Kf(e,t),a=0,s=e.length-1,i=Math.floor((a+s)/2);a0)s=i,i=Math.floor((a+s)/2);else{if(!(o<0))return{place:i,oldPosition:r};a=i+1,i=Math.floor((a+s)/2)}}return{place:Yf(e[i],t,n)>=0?i:i+1,oldPosition:r}}return{place:e.length,oldPosition:-1}},Yf=function(t,n,r){switch(r){case e.GroupChannelListOrder.LATEST_LAST_MESSAGE:return t.lastMessage&&n.lastMessage?n.lastMessage.createdAt-t.lastMessage.createdAt:t.lastMessage?-1:n.lastMessage?1:n.createdAt-t.createdAt;case e.GroupChannelListOrder.CHRONOLOGICAL:return n.createdAt-t.createdAt;case e.GroupChannelListOrder.CHANNEL_NAME_ALPHABETICAL:var a=t.name.localeCompare(n.name);return 0===a?t.createdAt-n.createdAt:a}},Zf=function(e,t){return t instanceof Ns?e.findIndex((function(e){return e instanceof Ns&&t.isIdentical(e)})):e.findIndex((function(e){return e.isIdentical(t)}))},Jf=function(e,t){return e.findIndex((function(e){return e.messageId===t}))},Xf=function(e,t){if(e.length>0){for(var n=0,r=e.length-1,a=Math.floor((n+r)/2);n0)r=a,a=Math.floor((n+r)/2);else{if(!(s<0))return a;n=a+1,a=Math.floor((n+r)/2)}}return e[a].createdAt>t.createdAt?a:a+1}return e.length},$f=6e5;e.MessageCollectionInitPolicy=void 0,(e.MessageCollectionInitPolicy||(e.MessageCollectionInitPolicy={})).CACHE_AND_REPLACE_BY_API="cache_and_replace_by_api";var ep,tp,np,rp=function(){function e(){r(this,e)}return s(e,[{key:"_invokeResponse",value:function(e,n,r){var a=this;wa((function(){return b(a,void 0,void 0,t().mark((function a(){return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:t.t0=e,t.next="local"===t.t0?3:"remote"===t.t0?5:7;break;case 3:return this._onCacheResult(n,r),t.abrupt("break",7);case 5:return this._onApiResult(n,r),t.abrupt("break",7);case 7:case"end":return t.stop()}}),a,this)})))}))}},{key:"onCacheResult",value:function(e){return this._onCacheResult=e,this}},{key:"onApiResult",value:function(e){return this._onApiResult=e,this}}]),e}(),ap=function(){function n(a,s){var i=this,o=s.channel,u=s.filter,c=s.startingPoint,l=s.limit;r(this,n),this._channel=null,this._messages=[],this._unsentMessages=[],this._backgroundSync=null,this._changelogSync=null,this._pollChangelogSync=null,this._checkMyMutedStateTimer=null,this._iid=a,this._key="mc-".concat(re()),this.filter=null!=u?u:new Eo,this._channel=o,this._syncRange=new Af({}),this._hasPrevious=!0,this._hasNext=!0,this._startingPoint="number"==typeof c?c:Date.now()+$f,this._limit=l||go;var h=Rf.of(this._iid);h.subscribeGroupChannelEvent(this._key,{onUpdate:function(n,r,a){var s=Kf(n,i._channel);if(s>=0){switch(i._channel=n[s],r){case e.GroupChannelEventSource.EVENT_CHANNEL_UPDATED:var o=!1;for(var u in i._messages){if(i._messages[u].createdAt>=i._channel.messageOffsetTimestamp){o=!0;var c=parseInt(u);if(c>0){var l=i._messages.splice(0,c);i._removeMessagesFromView(l.map((function(e){return e.messageId})),e.MessageEventSource.EVENT_MESSAGE_OFFSET_UPDATED)}break}}!o&&i._messages.length>0&&i._removeMessagesFromView(i._messages.map((function(e){return e.messageId})),e.MessageEventSource.EVENT_MESSAGE_OFFSET_UPDATED);break;case e.GroupChannelEventSource.EVENT_CHANNEL_UNMUTED:var h=a;ds.of(i._iid).sdkState.userId===h&&i._clearCheckMyMutedTimer();break;case e.GroupChannelEventSource.EVENT_CHANNEL_MUTED:var d=a;ds.of(i._iid).sdkState.userId===d&&-1!==i.channel._myMutedRemainingTime&&i._startCheckMyMutedTimer(i.channel._myMutedRemainingTime);break;case e.GroupChannelEventSource.EVENT_CHANNEL_LEFT:i.channel.isPublic&&i._clearCheckMyMutedTimer()}wa((function(){return b(i,void 0,void 0,t().mark((function e(){var n,a;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:a=new Df(r),lu(r)&&(null===(n=this._handler)||void 0===n?void 0:n.onChannelUpdated)&&this._handler.onChannelUpdated(a,this.channel);case 2:case"end":return e.stop()}}),e,this)})))}))}},onRemove:function(e,n){e.indexOf(i.channel.url)>=0&&(i._clearCheckMyMutedTimer(),wa((function(){return b(i,void 0,void 0,t().mark((function e(){var r,a;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:a=new Df(n),(null===(r=this._handler)||void 0===r?void 0:r.onChannelDeleted)&&this._handler.onChannelDeleted(a,this.channel.url);case 2:case"end":return e.stop()}}),e,this)})))})))}}),h.subscribeMessageEvent(this._key,{onUpdate:function(t,n){var r,a=[],s=[],o=y(t);try{for(o.s();!(r=o.n()).done;){var u=r.value;u.channelUrl===i._channel.url&&(i.filter.match(u)?a.push(u):s.push(u.messageId))}}catch(e){o.e(e)}finally{o.f()}if(ii(n)){if(a.length>0)switch(n){case e.MessageEventSource.EVENT_MESSAGE_SENT_FAILED:case e.MessageEventSource.EVENT_MESSAGE_SENT_SUCCESS:case e.MessageEventSource.EVENT_MESSAGE_UPDATED:case e.MessageEventSource.EVENT_MESSAGE_THREADINFO_UPDATED:case e.MessageEventSource.EVENT_MESSAGE_REACTION_UPDATED:case e.MessageEventSource.SYNC_MESSAGE_CHANGELOGS:i._updateMessagesToView(a,n);break;case e.MessageEventSource.EVENT_MESSAGE_SENT_PENDING:i._addMessagesToView(a,n);break;case e.MessageEventSource.EVENT_MESSAGE_RECEIVED:i.hasNext||i._addMessagesToView(a,n);break;case e.MessageEventSource.SYNC_MESSAGE_FILL:i._addMessagesToView(a,n)}s.length>0&&i._removeMessagesFromView(s,n)}},onRemove:function(e,t){i._removeMessagesFromView(e,t)},onRemoveUnsent:function(e,t){i._removeUnsentMessageFromView(e,t)},onPollChangeLogUpdate:function(e,t){i._updatePollsToView(e,t)},onPollUpdate:function(e,t){i._applyPollUpdateEventToView(e,t)},onPollVote:function(e,t){i._applyPollVoteEventToView(e,t)}});var d=ds.of(this._iid),f=d.cacheContext,p=d.dispatcher,v=d.logger;this._channel._updateMessageCollectionLastAccessedAt(),p.dispatch(new hu({channels:[this._channel],source:e.GroupChannelEventSource.CHANNEL_LASTACCESSEDAT_UPDATED})),!this._channel.isSuper&&f.localCacheEnabled&&(this._backgroundSync=Gf.of(this._iid,this._channel),this._backgroundSync.resume(this._startingPoint)),this._changelogSync=Hf.of(this._iid,this._channel),this._changelogSync.resume(),this._pollChangelogSync=zf.of(this._iid,this._channel,this._hasPollMessage.bind(this)),this._pollChangelogSync.resume(),this._prevFill=new Lf(this._key,(function(n){return b(i,void 0,void 0,t().mark((function r(){var a,s,i,o,u;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,this._getRemoteMessages(n,{prevLimit:this._limit,source:e.MessageEventSource.SYNC_MESSAGE_FILL,checkingContinuousMessages:f.localCacheEnabled});case 2:if(s=t.sent,i=s.messages,o=s.isContinuousMessages,!(i.length>0)){t.next=10;break}return u=Math.min.apply(Math,_(i.map((function(e){return e.createdAt})))),this._syncRange.extends(u),o&&(null===(a=this._backgroundSync)||void 0===a||a.range.extends(u)),t.abrupt("return",{hasNext:i.length>=this._limit&&this.viewTop0)){t.next=10;break}return u=Math.max.apply(Math,_(i.map((function(e){return e.createdAt})))),this._syncRange.extends(u),o&&(null===(a=this._backgroundSync)||void 0===a||a.range.extends(u)),t.abrupt("return",{hasNext:!(i.length>=this._limit&&this._hasNext)||this.viewBottom>u,nextToken:this._syncRange.bottom});case 10:return t.abrupt("return",{hasNext:!1,nextToken:0});case 11:case"end":return t.stop()}}),r,this)})))})),this._connectionEventContext=p.on((function(n){if(n instanceof ha)switch(n.stateType){case aa.CONNECTED:i._refreshChannel(e.GroupChannelEventSource.SYNC_CHANNEL_CHANGELOGS),xa((function(){return b(i,void 0,void 0,t().mark((function e(){var n;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this.channel.getMyMutedInfo();case 2:(n=e.sent).isMuted&&-1!==n.remainingDuration&&this._startCheckMyMutedTimer(n.remainingDuration);case 4:case"end":return e.stop()}}),e,this)})))})),v.debug("check huge gap"),i._checkHugeGap();break;case aa.LOGOUT:i.dispose();break;default:i._clearCheckMyMutedTimer(),i._prevFill.stop(),i._nextFill.stop()}})),ds.of(this._iid).statLogCollector.put(new as({type:Me.FEATURE_LOCALCACHE,data:{use_local_cache:f.localCacheEnabled,collection_interface:{message:!0}}}))}return s(n,[{key:"channel",get:function(){return this._channel}},{key:"succeededMessages",get:function(){return _(this._messages)}},{key:"failedMessages",get:function(){return this._unsentMessages.filter((function(t){return t.sendingStatus===e.SendingStatus.FAILED}))}},{key:"pendingMessages",get:function(){return this._unsentMessages.filter((function(t){return t.sendingStatus===e.SendingStatus.PENDING}))}},{key:"hasPrevious",get:function(){return this._hasPrevious}},{key:"hasNext",get:function(){return this._hasNext}},{key:"viewTop",get:function(){return Math.min.apply(Math,_(this._messages.map((function(e){return e.createdAt}))).concat([Number.MAX_SAFE_INTEGER]))}},{key:"viewBottom",get:function(){return Math.max.apply(Math,_(this._messages.map((function(e){return e.createdAt}))).concat([0]))}},{key:"setMessageCollectionHandler",value:function(e){this._handler=e}},{key:"_filterUnderOffsetMessage",value:function(e){return e}},{key:"_addMessagesToView",value:function(n,r){var a,s=this,i=this._filterUnderOffsetMessage(n),o=[],u=[],c=y(i);try{for(c.s();!(a=c.n()).done;){var l=a.value;if(r===e.MessageEventSource.SYNC_MESSAGE_FILL){if(l.messageId>0){if(Zf(this._messages,l)<0){Zf(this._unsentMessages,l)<0&&o.push(l);var h=Xf(this._messages,l);this._messages.splice(h,0,l)}}else if(l instanceof Ns){Zf(this._unsentMessages,l)<0&&Zf(this._messages,l)<0&&(this._unsentMessages.push(l),o.push(l))}}else if(l.messageId>0){var d=Zf(this._messages,l);if(d<0){var f=Zf(this._unsentMessages,l);f<0?o.push(l):(this._unsentMessages.splice(f,1),u.push(l));var p=Xf(this._messages,l);this._messages.splice(p,0,l)}else u.push(l),this._messages[d]=l;if(l.updatedAt>0){var v=this._updateChildMessagesInView(l);u.push.apply(u,_(v))}}else if(l instanceof Ns){var m=Zf(this._unsentMessages,l);m<0?Zf(this._messages,l)<0&&(this._unsentMessages.push(l),o.push(l)):(u.push(l),this._unsentMessages[m]=l)}}}catch(e){c.e(e)}finally{c.f()}ii(r)&&wa((function(){return b(s,void 0,void 0,t().mark((function e(){var n,a,s;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:s=new Pf(r),o.length>0&&(null===(n=this._handler)||void 0===n||n.onMessagesAdded(s,this.channel,o)),u.length>0&&(null===(a=this._handler)||void 0===a||a.onMessagesUpdated(s,this.channel,u));case 3:case"end":return e.stop()}}),e,this)})))}))}},{key:"_updateChildMessagesInView",value:function(e){var t=[];return this._messages.forEach((function(n){n.applyParentMessage(e)&&t.push(n)})),t}},{key:"_updatePollsToView",value:function(e,n){var r,a=this,s=[],i=y(e);try{for(i.s();!(r=i.n()).done;){var o=r.value,u=Jf(this._messages,o.messageId);if(u>=0){var c=this._messages[u];c&&c.applyPoll(o),s.push(c)}}}catch(e){i.e(e)}finally{i.f()}return s.length>0&&ii(n)&&wa((function(){return b(a,void 0,void 0,t().mark((function e(){var r,a;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:a=new Pf(n),s.length>0&&(null===(r=this._handler)||void 0===r||r.onMessagesUpdated(a,this.channel,s));case 2:case"end":return e.stop()}}),e,this)})))})),s}},{key:"_applyPollUpdateEventToView",value:function(e,n){var r=this,a=Jf(this._messages,e.messageId);if(a>=0){var s=this._messages[a];s&&s.isUserMessage()&&s.poll&&s.poll.applyPollUpdateEvent(e)&&ii(n)&&wa((function(){return b(r,void 0,void 0,t().mark((function e(){var r,a;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:a=new Pf(n),null===(r=this._handler)||void 0===r||r.onMessagesUpdated(a,this.channel,[s]);case 2:case"end":return e.stop()}}),e,this)})))}))}}},{key:"_applyPollVoteEventToView",value:function(e,n){var r=this,a=Jf(this._messages,e.messageId);if(a>=0){var s=this._messages[a];s&&s.isUserMessage()&&s.poll&&s.poll.applyPollVoteEvent(e)&&ii(n)&&wa((function(){return b(r,void 0,void 0,t().mark((function e(){var r,a;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:a=new Pf(n),null===(r=this._handler)||void 0===r||r.onMessagesUpdated(a,this.channel,[s]);case 2:case"end":return e.stop()}}),e,this)})))}))}}},{key:"_updateMessagesToView",value:function(e,n){var r,a=this,s=[],i=[],o=y(e);try{for(o.s();!(r=o.n()).done;){var u=r.value;if(u.messageId>0){var c=Zf(this._messages,u);if(c>=0)s.push(u),this._messages[c]=u;else{var l=Zf(this._unsentMessages,u);if(l>=0){var h=this._unsentMessages.splice(l,1);if(this.hasNext&&h.length>0)i.push(h[0]);else{s.push(u);var d=Xf(this._messages,u);this._messages.splice(d,0,u)}}}}else if(u instanceof Ns){var f=Zf(this._unsentMessages,u);f>=0&&(s.push(u),this._unsentMessages[f]=u)}}}catch(e){o.e(e)}finally{o.f()}return ii(n)&&wa((function(){return b(a,void 0,void 0,t().mark((function e(){var r,a,o;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:o=new Pf(n),s.length>0?null===(r=this._handler)||void 0===r||r.onMessagesUpdated(o,this.channel,s):i.length>0&&(null===(a=this._handler)||void 0===a||a.onMessagesDeleted(o,this.channel,[],i));case 2:case"end":return e.stop()}}),e,this)})))})),s}},{key:"_removeMessagesFromView",value:function(e,n){var r,a=this,s=[],i=[],o=y(e);try{var u=function(){var e=r.value,t=a._messages.findIndex((function(t){return t.messageId===e}));if(t>=0){var n=a._messages[t];s.push(n.messageId),i.push(n),a._messages.splice(t,1)}};for(o.s();!(r=o.n()).done;)u()}catch(e){o.e(e)}finally{o.f()}return ii(n)&&i.length>0&&wa((function(){return b(a,void 0,void 0,t().mark((function e(){var r,a;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:a=new Pf(n),null===(r=this._handler)||void 0===r||r.onMessagesDeleted(a,this.channel,s,i);case 2:case"end":return e.stop()}}),e,this)})))})),s}},{key:"_removeUnsentMessageFromView",value:function(e,t){var n=this._unsentMessages.findIndex((function(t){return t.reqId===e}));n>=0&&this._unsentMessages.splice(n,1)}},{key:"_getLocalMessages",value:function(e,n){var r=n.prevLimit,a=void 0===r?0:r,s=n.nextLimit,i=void 0===s?0:s;return b(this,void 0,void 0,t().mark((function n(){var r,s,o,u,c;return t().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:if(r=Rf.of(this._iid),!(a>0)){n.next=7;break}return n.next=4,r.getMessagesFromCache(this._channel.url,e,"prev",this.filter,a);case 4:n.t0=n.sent,n.next=8;break;case 7:n.t0=[];case 8:if(s=n.t0,!(i>0)){n.next=15;break}return n.next=12,r.getMessagesFromCache(this._channel.url,e,"next",this.filter,i);case 12:n.t1=n.sent,n.next=16;break;case 15:n.t1=[];case 16:if(o=n.t1,!(s.length>0&&o.length>0)){n.next=27;break}u=s.map((function(e){return e.messageId})),n.t2=t().keys(o);case 20:if((n.t3=n.t2()).done){n.next=27;break}if(c=n.t3.value,!u.includes(o[c].messageId)){n.next=25;break}return o.splice(parseInt(c),1),n.abrupt("break",27);case 25:n.next=20;break;case 27:return n.abrupt("return",[].concat(_(s),_(o)).sort((function(e,t){return t.createdAt-e.createdAt})));case 28:case"end":return n.stop()}}),n,this)})))}},{key:"_getRemoteMessages",value:function(n,r){var a=r.prevLimit,s=void 0===a?0:a,i=r.nextLimit,o=void 0===i?0:i,u=r.source,c=void 0===u?e.MessageEventSource.REQUEST_MESSAGE:u,l=r.reverse,h=void 0!==l&&l,d=r.checkingContinuousMessages,f=void 0!==d&&d;return b(this,void 0,void 0,t().mark((function e(){var r;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(r=Ei.of(this._iid),!(s>0||o>0)){e.next=7;break}return e.next=4,r._getMessagesByTimestampForCollection(this._channel.url,this._channel.channelType,n,Object.assign(Object.assign({},this.filter),{isInclusive:!0,reverse:h,prevResultSize:s,nextResultSize:o,includeMetaArray:!0,includeReactions:!0,includeThreadInfo:!0,includeParentMessageInfo:!0}),c,f);case 4:e.t0=e.sent,e.next=8;break;case 7:e.t0={messages:[],isContinuousMessages:!1};case 8:return e.abrupt("return",e.t0);case 9:case"end":return e.stop()}}),e,this)})))}},{key:"_checkHugeGap",value:function(){var n;return b(this,void 0,void 0,t().mark((function r(){var a,s,i,o,u,c,l,h,d,f,p,v,m,g,y,k,w,x,C,T,S=this;return t().wrap((function(r){for(;;)switch(r.prev=r.next){case 0:if(!(this._messages.length>0)){r.next=16;break}return a=this._syncRange.top,s=this.viewTop,i=this._syncRange.bottom,o=this.hasNext?this.viewBottom:Number.MAX_SAFE_INTEGER,u=Rf.of(this._iid),r.next=8,u.getCachedMessageCountBetween(this._channel.url,this.filter,s,a);case 8:return c=r.sent,r.next=11,u.getCachedMessageCountBetween(this._channel.url,this.filter,i,o);case 11:return l=r.sent,r.next=14,Ea((function(){return b(S,void 0,void 0,t().mark((function n(){var r,u,h,d,f,p,v,m,g,y,k,E,w,x,C,T,S,I,N,M,A,O=this;return t().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return u=ds.of(this._iid),h=u.dispatcher,d=u.requestQueue,f=u.cacheContext,p=new Vf(Object.assign({channelUrl:this._channel.url,channelType:this._channel.channelType,prevStart:s,prevEnd:a,prevCount:c,nextStart:i,nextEnd:o,nextCount:l,checkingContinuousMessages:f.localCacheEnabled},this.filter)),n.next=4,d.send(p);case 4:v=n.sent,m=v.as(Bf),g=m.isHugeGap,y=m.prevMessages,k=void 0===y?[]:y,E=m.prevHasMore,w=m.isContinuousPrevMessages,x=m.nextMessages,C=void 0===x?[]:x,T=m.nextHasmore,S=m.isContinuousNextMessages,g?wa((function(){return b(O,void 0,void 0,t().mark((function e(){var n;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:null===(n=this._handler)||void 0===n||n.onHugeGapDetected();case 1:case"end":return e.stop()}}),e,this)})))})):(this._hasPrevious=E,this._hasNext=T,I=this.viewTop,N=this.viewBottom,M=Math.min.apply(Math,[Number.MAX_SAFE_INTEGER,I].concat(_(k.map((function(e){return e.createdAt}))))),A=Math.max.apply(Math,[0,N].concat(_(C.map((function(e){return e.createdAt}))))),h.dispatch(new oi({messages:k,source:e.MessageEventSource.SYNC_MESSAGE_FILL})),h.dispatch(new oi({messages:C,source:e.MessageEventSource.SYNC_MESSAGE_FILL})),this._syncRange.extends(M,A),(w||S)&&(null===(r=this._backgroundSync)||void 0===r||r.range.extends(M,A)),IA&&this._nextFill.start(A));case 7:case"end":return n.stop()}}),n,this)})))}),1);case 14:r.next=31;break;case 16:return h=ds.of(this._iid),d=h.cacheContext,f=Math.floor(this._limit/2),p=Date.now(),r.prev=19,r.next=22,this._getRemoteMessages(p,{prevLimit:f,nextLimit:f,source:e.MessageEventSource.SYNC_MESSAGE_FILL,checkingContinuousMessages:d.localCacheEnabled});case 22:if(v=r.sent,m=v.messages,g=v.isContinuousMessages,m.length>0){for(k=m.map((function(e){return e.createdAt})),w=0,x=0,C=0;C=p&&x++;this._hasPrevious=w>=f,this._hasNext=x>=f,(y=this._syncRange).extends.apply(y,_(k)),g&&(null===(n=this._backgroundSync)||void 0===n||n.range.extends(this._syncRange.top,this._syncRange.bottom)),this._addMessagesToView(m,e.MessageEventSource.SYNC_MESSAGE_FILL)}else this._hasPrevious=!1,this._hasNext=!1;r.next=31;break;case 28:r.prev=28,r.t0=r.catch(19),r.t0 instanceof A&&r.t0.code===E.NOT_FOUND_IN_DATABASE&&(this._hasPrevious=!1,this._hasNext=!1);case 31:case"end":return r.stop()}}),r,this,[[19,28]])})))}},{key:"_loadUnsentMessages",value:function(){return b(this,void 0,void 0,t().mark((function e(){var n;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n=Rf.of(this._iid),e.next=3,n.getUnsentMessagesFromCache(this._channel.url,this.filter);case 3:this._unsentMessages=e.sent;case 4:case"end":return e.stop()}}),e,this)})))}},{key:"_hasPollMessage",value:function(){return b(this,void 0,void 0,t().mark((function e(){var n;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n=Rf.of(this._iid),e.next=3,n.getPollMessagesFromCache(this._channel.url,Date.now()+$f,this.filter,1);case 3:if(!(e.sent.length>0)){e.next=6;break}return e.abrupt("return",!0);case 6:return e.abrupt("return",!1);case 7:case"end":return e.stop()}}),e,this)})))}},{key:"_refreshChannel",value:function(e){Rf.of(this._iid).refreshChannel(this.channel.url,!0,e)}},{key:"_startCheckMyMutedTimer",value:function(n){var r=this;this._clearCheckMyMutedTimer(),this._checkMyMutedStateTimer=setTimeout((function(){return b(r,void 0,void 0,t().mark((function n(){var r,a,s,i;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return this._checkMyMutedStateTimer=null,a=!0,t.prev=2,t.next=5,this._channel.getMyMutedInfo();case 5:s=t.sent,a=!s.isMuted,t.next=12;break;case 9:t.prev=9,t.t0=t.catch(2),a=!0;case 12:return t.prev=12,a&&(this.channel.myMutedState=e.MutedState.UNMUTED,i=new Df(e.GroupChannelEventSource.EVENT_CHANNEL_UNMUTED),null===(r=this._handler)||void 0===r||r.onChannelUpdated(i,this.channel)),t.finish(12);case 15:case"end":return t.stop()}}),n,this,[[2,9,12,15]])})))}),n+1e3)}},{key:"_clearCheckMyMutedTimer",value:function(){this._checkMyMutedStateTimer&&(clearTimeout(this._checkMyMutedStateTimer),this._checkMyMutedStateTimer=null)}},{key:"initialize",value:function(n){var r=this,a=new rp;this._messages=[],this._unsentMessages=[],this._syncRange=new Af({}),this._hasNext=!0,this._hasPrevious=!0,this._refreshChannel(e.GroupChannelEventSource.REFRESH_CHANNEL),xa((function(){return b(r,void 0,void 0,t().mark((function e(){var n;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this.channel.getMyMutedInfo();case 2:(n=e.sent).isMuted&&-1!==n.remainingDuration&&this._startCheckMyMutedTimer(n.remainingDuration);case 4:case"end":return e.stop()}}),e,this)})))}));var s=Math.floor(this._limit/2);if(n===e.MessageCollectionInitPolicy.CACHE_AND_REPLACE_BY_API)this._getLocalMessages(this._startingPoint,{prevLimit:s,nextLimit:s}).then((function(n){return b(r,void 0,void 0,t().mark((function r(){var s;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return s=this._filterUnderOffsetMessage(n),this._addMessagesToView(s,e.MessageEventSource.REQUEST_MESSAGE),t.next=4,this._loadUnsentMessages();case 4:a._invokeResponse("local",null,s);case 5:case"end":return t.stop()}}),r,this)})))})).catch((function(e){if(M(e))throw e;a._invokeResponse("local",e,null)})).finally((function(){var t=ds.of(r._iid).cacheContext;r._getRemoteMessages(r._startingPoint,{prevLimit:s,nextLimit:s,reverse:!0,checkingContinuousMessages:t.localCacheEnabled}).then((function(t){var n,i=t.messages,o=t.isContinuousMessages;r._messages=[];var u=r._filterUnderOffsetMessage(i);if(u.length>0){for(var c,l=u.map((function(e){return e.createdAt})),h=0,d=0,f=0;f=r._startingPoint&&d++}r._hasPrevious=h>=s,r._hasNext=d>=s,(c=r._syncRange).extends.apply(c,_(u.map((function(e){return e.createdAt})))),o&&(null===(n=r._backgroundSync)||void 0===n||n.range.extends(r._syncRange.top,r._syncRange.bottom)),r._addMessagesToView(u,e.MessageEventSource.REQUEST_MESSAGE)}else r._hasPrevious=!1,r._hasNext=!1;a._invokeResponse("remote",null,u)})).catch((function(e){if(M(e))throw e;a._invokeResponse("remote",e,null)}))}));var i=ds.of(this._iid),o=i.cacheContext;return i.statLogCollector.put(new as({type:Me.FEATURE_LOCALCACHE,data:{use_local_cache:o.localCacheEnabled,collection_interface:{message_init_policy:n}}})),a}},{key:"loadPrevious",value:function(){return b(this,void 0,void 0,t().mark((function n(){var r,a,s,i=this;return t().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:if(!this._hasPrevious){n.next=14;break}return r=this.viewTop,a=[],n.next=5,xa((function(){return b(i,void 0,void 0,t().mark((function e(){return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.t0=this,e.next=3,this._getLocalMessages(r,{prevLimit:this._limit});case 3:e.t1=e.sent,a=e.t0._filterUnderOffsetMessage.call(e.t0,e.t1);case 5:case"end":return e.stop()}}),e,this)})))}));case 5:if(0!==a.length&&this._backgroundSync&&this._backgroundSync.isWrappingMessages(a)){n.next=11;break}return n.next=8,xa((function(){return b(i,void 0,void 0,t().mark((function e(){var n,s,i,o,u,c;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return i=ds.of(this._iid),o=i.cacheContext,e.next=3,this._getRemoteMessages(r,{prevLimit:this._limit,checkingContinuousMessages:o.localCacheEnabled});case 3:u=e.sent,a=this._filterUnderOffsetMessage(u.messages),this._hasPrevious=a.length>=this._limit,a.length>0&&((c=this._syncRange).extends.apply(c,_(a.map((function(e){return e.createdAt})))),(null===(n=this._backgroundSync)||void 0===n?void 0:n.range.overlap(this._syncRange))&&u.isContinuousMessages&&(null===(s=this._backgroundSync)||void 0===s||s.range.extends(this._syncRange.top)));case 7:case"end":return e.stop()}}),e,this)})))}));case 8:this._addMessagesToView(a,e.MessageEventSource.REQUEST_MESSAGE),n.next=13;break;case 11:this._hasPrevious=a.length>=this._limit,a.length>0&&((s=this._syncRange).extends.apply(s,_(a.map((function(e){return e.createdAt})))),this._addMessagesToView(a,e.MessageEventSource.REQUEST_MESSAGE));case 13:return n.abrupt("return",a);case 14:return n.abrupt("return",[]);case 15:case"end":return n.stop()}}),n,this)})))}},{key:"loadNext",value:function(){var n;return b(this,void 0,void 0,t().mark((function r(){var a,s,i,o=this;return t().wrap((function(r){for(;;)switch(r.prev=r.next){case 0:if(this._hasNext){r.next=2;break}return r.abrupt("return",[]);case 2:return a=this.viewBottom,s=[],r.next=6,xa((function(){return b(o,void 0,void 0,t().mark((function e(){return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.t0=this,e.next=3,this._getLocalMessages(a,{nextLimit:this._limit});case 3:e.t1=e.sent,s=e.t0._filterUnderOffsetMessage.call(e.t0,e.t1);case 5:case"end":return e.stop()}}),e,this)})))}));case 6:if(0!==s.length&&(null===(n=this._backgroundSync)||void 0===n?void 0:n.isWrappingMessages(s))){r.next=12;break}return r.next=9,xa((function(){return b(o,void 0,void 0,t().mark((function e(){var n,r,i,o,u,c;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return i=ds.of(this._iid),o=i.cacheContext,e.next=3,this._getRemoteMessages(a,{nextLimit:this._limit,checkingContinuousMessages:o.localCacheEnabled});case 3:u=e.sent,s=this._filterUnderOffsetMessage(u.messages),this._hasNext=s.length>=this._limit,s.length>0&&((c=this._syncRange).extends.apply(c,_(s.map((function(e){return e.createdAt})))),(null===(n=this._backgroundSync)||void 0===n?void 0:n.range.overlap(this._syncRange))&&u.isContinuousMessages&&(null===(r=this._backgroundSync)||void 0===r||r.range.extends(this._syncRange.bottom)));case 7:case"end":return e.stop()}}),e,this)})))}));case 9:this._addMessagesToView(s,e.MessageEventSource.REQUEST_MESSAGE),r.next=14;break;case 12:this._hasNext=s.length>=this._limit,s.length>0&&((i=this._syncRange).extends.apply(i,_(s.map((function(e){return e.createdAt})))),this._addMessagesToView(s,e.MessageEventSource.REQUEST_MESSAGE));case 14:return r.abrupt("return",s);case 15:case"end":return r.stop()}}),r,this)})))}},{key:"removeFailedMessage",value:function(e){return b(this,void 0,void 0,t().mark((function n(){var r,a;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return r=Rf.of(this._iid),t.next=3,r.removeFailedMessageFromCache(e);case 3:(a=this._unsentMessages.findIndex((function(t){return t.reqId===e})))>-1&&this._unsentMessages.splice(a,1);case 5:case"end":return t.stop()}}),n,this)})))}},{key:"dispose",value:function(){var t,n,r,a=ds.of(this._iid),s=a.cacheContext,i=a.dispatcher;this._clearCheckMyMutedTimer(),this._channel._updateMessageCollectionLastAccessedAt(),i.dispatch(new hu({channels:[this._channel],source:e.GroupChannelEventSource.CHANNEL_LASTACCESSEDAT_UPDATED})),s.localCacheEnabled&&(this._prevFill.stop(),this._nextFill.stop()),null===(t=this._backgroundSync)||void 0===t||t.close(),null===(n=this._changelogSync)||void 0===n||n.close(),null===(r=this._pollChangelogSync)||void 0===r||r.close();var o=Rf.of(this._iid);o.unsubscribeGroupChannelEvent(this._key),o.unsubscribeMessageEvent(this._key),this._connectionEventContext&&this._connectionEventContext.close()}}]),n}(),sp={coverUrl:null,coverImage:null,isDistinct:null,isPublic:null,isDiscoverable:null,accessCode:null,name:null,data:null,customType:null,operatorUserIds:null,messageSurvivalSeconds:null},ip=function(e){return L("string",e.coverUrl,!0)&&(q(e.coverImage)||L("string",e.coverImage)||null===e.coverImage)&&L("boolean",e.isDistinct,!0)&&L("boolean",e.isPublic,!0)&&L("boolean",e.isDiscoverable,!0)&&L("string",e.accessCode,!0)&&L("string",e.name,!0)&&L("string",e.data,!0)&&L("string",e.customType,!0)&&F("string",e.operatorUserIds,!0)&&L("number",e.messageSurvivalSeconds,!0)},op={hidePreviousMessages:!1,allowAutoUnhide:!0},up=function(e){return L("boolean",e.hidePreviousMessages)&&L("boolean",e.allowAutoUnhide)},cp=function(e){i(n,e);var t=f(n);function n(e){var a;r(this,n);var s=e.channelUrl,i=e.token,o=e.limit,u=e.order,c=e.mutedMemberFilter,l=e.memberStateFilter,h=e.nicknameStartsWithFilter,d=e.operatorFilter;return(a=t.call(this)).method=ce.GET,a.path="".concat(fe,"/").concat(encodeURIComponent(s),"/members"),a.params={token:i,limit:o,order:u,muted_member_filter:c,member_state_filter:l,nickname_startswith:h,operator_filter:d,show_member_is_muted:!0,show_read_receipt:!0,show_delivery_receipt:!0},a}return s(n)}(Ae),lp=function(e){i(n,e);var t=f(n);function n(e,a){var s;r(this,n),(s=t.call(this,e,a)).token=null,s.members=[];var i=a.next,o=a.members;return s.token=i,o&&o.length>0&&(s.members=o.map((function(t){return new hd(e,t)}))),s}return s(n)}(Oe);e.MutedMemberFilter=void 0,(ep=e.MutedMemberFilter||(e.MutedMemberFilter={})).ALL="all",ep.MUTED="muted",ep.UNMUTED="unmuted",e.MemberListOrder=void 0,(tp=e.MemberListOrder||(e.MemberListOrder={})).MEMBER_NICKNAME_ALPHABETICAL="member_nickname_alphabetical",tp.OPERATOR_THEN_MEMBER_ALPHABETICAL="operator_then_member_alphabetical",e.MemberStateFilter=void 0,(np=e.MemberStateFilter||(e.MemberStateFilter={})).ALL="all",np.JOINED="joined_only",np.INVITED="invited_only",np.INVITED_BY_FRIEND="invited_by_friend",np.INVITED_BY_NON_FRIEND="invited_by_non_friend";var hp,dp,fp,pp=function(n){i(u,n);var a=f(u);function u(t,n,s){var i,o,c,l,h;return r(this,u),(i=a.call(this,t,n,e.ChannelType.GROUP,s)).mutedMemberFilter=e.MutedMemberFilter.ALL,i.memberStateFilter=e.MemberStateFilter.ALL,i.nicknameStartsWithFilter=null,i.operatorFilter=e.OperatorFilter.ALL,i.order=e.MemberListOrder.MEMBER_NICKNAME_ALPHABETICAL,i.mutedMemberFilter=null!==(o=s.mutedMemberFilter)&&void 0!==o?o:e.MutedMemberFilter.ALL,i.memberStateFilter=null!==(c=s.memberStateFilter)&&void 0!==c?c:e.MemberStateFilter.ALL,i.nicknameStartsWithFilter=null!==(l=s.nicknameStartsWithFilter)&&void 0!==l?l:null,i.order=null!==(h=s.order)&&void 0!==h?h:e.MemberListOrder.MEMBER_NICKNAME_ALPHABETICAL,i}return s(u,[{key:"_validate",value:function(){return p(o(u.prototype),"_validate",this).call(this)&&D(e.MutedMemberFilter,this.mutedMemberFilter)&&D(e.MemberStateFilter,this.memberStateFilter)&&(L("string",this.nicknameStartsWithFilter)||null===this.nicknameStartsWithFilter)&&D(e.OperatorFilter,this.operatorFilter)&&D(e.MemberListOrder,this.order)}},{key:"next",value:function(){return b(this,void 0,void 0,t().mark((function e(){var n,r,a,s,i,o,u;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!this._validate()){e.next=20;break}if(this._isLoading){e.next=17;break}if(!this._hasNext){e.next=14;break}return this._isLoading=!0,n=ds.of(this._iid),r=n.requestQueue,a=new cp(Object.assign(Object.assign({},this),{token:this._token})),e.next=8,r.send(a);case 8:return s=e.sent,i=s.as(lp),o=i.members,u=i.token,this._token=u,this._hasNext=!!u,this._isLoading=!1,e.abrupt("return",o);case 14:return e.abrupt("return",[]);case 17:throw A.queryInProgress;case 18:e.next=21;break;case 20:throw A.invalidParameters;case 21:case"end":return e.stop()}}),e,this)})))}}]),u}(Ri),vp=function(e){i(n,e);var t=f(n);function n(e){var a;r(this,n);var s=e.channelUrl,i=e.userId,o=e.accessCode;return(a=t.call(this)).method=ce.PUT,a.path="".concat(fe,"/").concat(encodeURIComponent(s),"/accept"),a.params={user_id:i,access_code:o},a}return s(n)}(Ae),_p=function(t){i(a,t);var n=f(a);function a(t,s){var i;return r(this,a),(i=n.call(this,t,s)).channel=new Bp(t,s),i.channel.myMemberState=e.MemberState.JOINED,i}return s(a)}(Oe),mp=function(e){i(n,e);var t=f(n);function n(e){var a;r(this,n);var s=e.channelUrl,i=e.isDistinct,o=e.isPublic,u=e.isDiscoverable,c=e.coverUrl,l=e.coverImage,h=e.accessCode,d=e.name,f=e.data,p=e.customType,v=e.operatorUserIds,_=e.messageSurvivalSeconds;return(a=t.call(this)).method=ce.PUT,a.path="".concat(fe,"/").concat(encodeURIComponent(s)),a.params=ue({is_distinct:i,is_public:o,is_discoverable:u,name:d,data:f,custom_type:p,cover_url:c,cover_file:l,access_code:h,operator_ids:v,message_survival_seconds:_}),a}return s(n)}(Ae),gp=function(e){i(n,e);var t=f(n);function n(e,a){var s;return r(this,n),(s=t.call(this,e,a)).channel=new Bp(e,a),s}return s(n)}(Oe),yp=function(e){i(n,e);var t=f(n);function n(e){var a;r(this,n);var s=e.channelUrl;return(a=t.call(this)).method=ce.DELETE,a.path="".concat(fe,"/").concat(encodeURIComponent(s)),a}return s(n)}(Ae),kp=function(e){i(n,e);var t=f(n);function n(e){var a;r(this,n);var s=e.channelUrl;return(a=t.call(this)).method=ce.DELETE,a.path="".concat(fe,"/").concat(encodeURIComponent(s),"/hide"),a}return s(n)}(Ae),bp=function(e){i(n,e);var t=f(n);function n(e){var a,s=e.userId,i=e.channelUrl,o=e.countPreference;return r(this,n),(a=t.call(this)).method=ce.PUT,a.path="".concat(he,"/").concat(encodeURIComponent(s),"/count_preference/").concat(encodeURIComponent(i)),a.params={count_preference:o},a}return s(n)}(Ae),Ep=function(e){i(n,e);var t=f(n);function n(e,a){var s;return r(this,n),(s=t.call(this,e,a)).countPreference=a.count_preference,s}return s(n)}(Oe),wp=function(e){i(n,e);var t=f(n);function n(e){var a;r(this,n);var s=e.channelUrl;return(a=t.call(this)).method=ce.PUT,a.path="".concat(fe,"/").concat(encodeURIComponent(s),"/reset_user_history"),a}return s(n)}(Ae),xp=function(e){i(n,e);var t=f(n);function n(e,a){var s;r(this,n),(s=t.call(this,e,a)).messageOffsetTimestamp=null;var i=a.ts_message_offset;return s.messageOffsetTimestamp=null!=i?i:null,s}return s(n)}(Oe),Cp=Object.assign(Object.assign({},xl),{scheduledAt:null,file:null,fileUrl:null,fileName:null,mimeType:null,fileSize:null,thumbnailSizes:null,requireAuth:!1}),Tp=function(e){return Cl(e)&&L("number",e.scheduledAt,!0)&&(q(e.file)||L("string",e.fileUrl))&&L("string",e.fileName,!0)&&L("string",e.mimeType,!0)&&L("number",e.fileSize,!0)&&(null===e.thumbnailSizes||void 0===e.thumbnailSizes||e.thumbnailSizes.every((function(e){return L("object",e)&&e.maxWidth>0&&e.maxHeight>0})))},Sp=Object.assign(Object.assign({},Tl),{scheduledAt:null}),Ip=function(e){return Sl(e)&&L("number",e.scheduledAt,!0)},Np=function(t){i(a,t);var n=f(a);function a(t){var s,i;r(this,a),s=n.call(this);var o=null;t.mentionType===e.MentionType.USERS&&(t.mentionedUserIds?o=t.mentionedUserIds:t.mentionedUsers&&(o=t.mentionedUsers.map((function(e){return e.userId}))));var u=t.channelType,c=t.channelUrl,l=t.scheduledMessageId;return s.method=ce.PUT,s.path="".concat(Ce(u),"/").concat(encodeURIComponent(c),"/scheduled_messages/").concat(encodeURIComponent(l)),s.params=ue({req_id:t.reqId,scheduled_at:t.scheduledAt,message_type:Y.FILE,url:t.fileUrl,file_name:t.fileName,file_size:t.fileSize,file_type:t.mimeType,thumbnails:t.thumbnailSizes?t.thumbnailSizes.map((function(e){return Ms.payloadify(e)})):[],custom_type:t.customType,data:t.data,require_auth:t.requireAuth,mention_type:t.mentionType,mentioned_user_ids:o,sorted_metaarray:null===(i=t.metaArrays)||void 0===i?void 0:i.map((function(e){return bs.payloadify(e)})),apple_critical_alert_options:xs.payloadify(t.appleCriticalAlertOptions),push_option:t.pushNotificationDeliveryOption}),s}return s(a)}(Ae),Mp=function(e){i(n,e);var t=f(n);function n(e,a){var s;return r(this,n),(s=t.call(this,e,a)).message=new Bs(e,a),s}return s(n)}(Oe),Ap=function(t){i(a,t);var n=f(a);function a(t){var s,i;r(this,a),s=n.call(this);var o=null;t.mentionType===e.MentionType.USERS&&(t.mentionedUserIds?o=t.mentionedUserIds:t.mentionedUsers&&(o=t.mentionedUsers.map((function(e){return e.userId}))));var u=t.channelType,c=t.channelUrl,l=t.scheduledMessageId;return s.method=ce.PUT,s.path="".concat(Ce(u),"/").concat(encodeURIComponent(c),"/scheduled_messages/").concat(encodeURIComponent(l)),s.params=ue({req_id:t.reqId,scheduled_at:t.scheduledAt,message_type:Y.USER,message:t.message,custom_type:t.customType,data:t.data,mention_type:t.mentionType,mentioned_user_ids:o,sorted_metaarray:null===(i=t.metaArrays)||void 0===i?void 0:i.map((function(e){return bs.payloadify(e)})),apple_critical_alert_options:xs.payloadify(t.appleCriticalAlertOptions),target_langs:t.translationTargetLanguages,push_option:t.pushNotificationDeliveryOption}),s}return s(a)}(Ae),Op=function(e){i(n,e);var t=f(n);function n(e){var a;r(this,n),a=t.call(this);var s=e.channelType,i=e.channelUrl,o=e.scheduledMessageId;return a.method=ce.DELETE,a.path="".concat(Ce(s),"/").concat(encodeURIComponent(i),"/scheduled_messages/").concat(encodeURIComponent(o)),a}return s(n)}(Ae),Up=function(e){i(n,e);var t=f(n);function n(e){var a;r(this,n),a=t.call(this);var s=e.channelType,i=e.channelUrl,o=e.scheduledMessageId;return a.method=ce.POST,a.path="".concat(Ce(s),"/").concat(encodeURIComponent(i),"/scheduled_messages/").concat(encodeURIComponent(o),"/send_now"),a}return s(n)}(Ae),Rp=function(e){i(n,e);var t=f(n);function n(e){var a,s=e.userId,i=e.channelUrl,o=e.pushTriggerOption;return r(this,n),(a=t.call(this)).method=ce.PUT,a.path="".concat(he,"/").concat(encodeURIComponent(s),"/push_preference/").concat(encodeURIComponent(i)),a.params={push_trigger_option:o},a}return s(n)}(Ae),Lp=function(e){i(n,e);var t=f(n);function n(e,a){var s;return r(this,n),(s=t.call(this,e,a)).pushTriggerOption=a.push_trigger_option,s.enabled=a.enable,s}return s(n)}(Oe),Dp=function(e){i(n,e);var t=f(n);function n(e){var a,s=e.userId,i=e.channelUrl;return r(this,n),(a=t.call(this)).method=ce.GET,a.path="".concat(he,"/").concat(encodeURIComponent(s),"/push_preference/").concat(encodeURIComponent(i)),a}return s(n)}(Ae),Pp=function(e){i(n,e);var t=f(n);function n(e,a){var s;return r(this,n),(s=t.call(this,e,a)).pushTriggerOption=a.push_trigger_option,s.enabled=a.enable,s}return s(n)}(Oe),Fp=function(e){i(n,e);var t=f(n);function n(e){var a,s=e.channelType,i=e.channelUrl,o=e.messageId;return r(this,n),(a=t.call(this)).method=ce.POST,a.path="".concat(Ce(s),"/").concat(encodeURIComponent(i),"/messages/").concat(o,"/pin"),a}return s(n)}(Ae),Gp=function(e){i(n,e);var t=f(n);function n(e){var a,s=e.channelType,i=e.channelUrl,o=e.messageId;return r(this,n),(a=t.call(this)).method=ce.DELETE,a.path="".concat(Ce(s),"/").concat(encodeURIComponent(i),"/messages/").concat(o,"/pin"),a}return s(n)}(Ae),qp=function(e){i(n,e);var t=f(n);function n(e,a){var s;return r(this,n),(s=t.call(this,e)).message=Vs(e,a.message),s}return s(n)}(qa),Hp=function(e){i(n,e);var t=f(n);function n(e){var a;r(this,n);var s=e.channelType,i=e.channelUrl,o=e.limit,u=e.token,c=e.includeReactions,l=e.includeMetaArray,h=e.includeParentMessageInfo,d=e.includeThreadInfo,f=e.includePollDetails;return(a=t.call(this)).method=ce.GET,a.path="".concat(Ce(s),"/").concat(encodeURIComponent(i),"/pinned_messages"),a.params=ue({limit:o,token:u,include_reactions:c,with_sorted_meta_array:l,include_thread_info:d,include_parent_message_info:h,include_poll_details:f}),a}return s(n)}(Ae),jp=function(e){i(n,e);var t=f(n);function n(e,a){var s;r(this,n),(s=t.call(this,e,a)).hasMore=null,s.token=null;var i=a.pinned_messages,o=a.has_more,u=a.next;return s.pinnedMessages=i.map((function(t){return new qp(e,t)})),s.hasMore=o,s.token=u,s}return s(n)}(Oe),zp=function(e){i(a,e);var n=f(a);function a(e,t,s,i){var o;return r(this,a),(o=n.call(this,e,t,s,i)).includeMetaArray=i.includeMetaArray,o.includeReactions=i.includeReactions,o.includeParentMessageInfo=i.includeParentMessageInfo,o.includeThreadInfo=i.includeThreadInfo,o.includePollDetails=i.includePollDetails,o}return s(a,[{key:"_validate",value:function(){return p(o(a.prototype),"_validate",this).call(this)&&L("boolean",this.includeMetaArray,!0)&&L("boolean",this.includeReactions,!0)&&L("boolean",this.includeParentMessageInfo,!0)&&L("boolean",this.includeThreadInfo,!0)&&L("boolean",this.includePollDetails,!0)}},{key:"next",value:function(){return b(this,void 0,void 0,t().mark((function e(){var n,r,a,s,i,o,u,c;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!this._validate()){e.next=20;break}if(this._isLoading){e.next=17;break}if(!this._hasNext){e.next=14;break}return this._isLoading=!0,n=ds.of(this._iid),r=n.requestQueue,a=new Hp(Object.assign(Object.assign({},this),{token:this._token})),e.next=8,r.send(a);case 8:return s=e.sent,i=s.as(jp),o=i.pinnedMessages,u=i.hasMore,c=i.token,this._token=c,this._hasNext=!!u,this._isLoading=!1,e.abrupt("return",o);case 14:return e.abrupt("return",[]);case 17:throw A.queryInProgress;case 18:e.next=21;break;case 20:throw A.invalidParameters;case 21:case"end":return e.stop()}}),e,this)})))}}]),a}(Ri);e.CountPreference=void 0,(hp=e.CountPreference||(e.CountPreference={})).ALL="all",hp.UNREAD_MESSAGE_COUNT_ONLY="unread_message_count_only",hp.UNREAD_MENTION_COUNT_ONLY="unread_mention_count_only",hp.OFF="off",e.MutedState=void 0,(dp=e.MutedState||(e.MutedState={})).MUTED="muted",dp.UNMUTED="unmuted",e.HiddenState=void 0,(fp=e.HiddenState||(e.HiddenState={})).UNHIDDEN="unhidden",fp.HIDDEN_ALLOW_AUTO_UNHIDE="hidden_allow_auto_unhide",fp.HIDDEN_PREVENT_AUTO_UNHIDE="hidden_prevent_auto_unhide";var Vp,Bp=function(n){i(u,n);var a=f(u);function u(t,n){var s,i,o,c,l,h,d,f,p,v,m,g,y,k,b,E,w,x,C,T;(r(this,u),(s=a.call(this,t,n))._unreadMemberStateMap=new Map,s._undeliveredMemberStateMap=new Map,s._typingStatus=new Map,s._lastMemberCountUpdated=0,s._typingStarted=0,s._typingEnded=0,s.isDistinct=!1,s.isSuper=!1,s.isBroadcast=!1,s.isExclusive=!1,s.isPublic=!1,s.isDiscoverable=!0,s.isAccessCodeRequired=!1,s.isPushEnabled=!1,s.unreadMessageCount=0,s.unreadMentionCount=0,s.members=[],s.memberCount=0,s.joinedMemberCount=0,s.hiddenState=e.HiddenState.UNHIDDEN,s.lastMessage=null,s.messageOffsetTimestamp=0,s.messageSurvivalSeconds=-1,s.myMemberState=e.MemberState.NONE,s.myRole=e.Role.NONE,s.myMutedState=e.MutedState.UNMUTED,s.myLastRead=0,s.myCountPreference=e.CountPreference.ALL,s.myPushTriggerOption=e.PushTriggerOption.DEFAULT,s.inviter=null,s.invitedAt=0,s.joinedAt=0,s.pinnedMessageIds=[],s.lastPinnedMessage=null,s._pinnedMessagesUpdatedAt=0,s._myMutedRemainingTime=-1,s.channelType=e.ChannelType.GROUP,s.isDistinct=null!==(i=n.is_distinct)&&void 0!==i&&i,s.isSuper=null!==(o=n.is_super)&&void 0!==o&&o,s.isBroadcast=null!==(c=n.is_broadcast)&&void 0!==c&&c,s.isExclusive=null!==(l=n.is_exclusive)&&void 0!==l&&l,s.isPublic=null!==(h=n.is_public)&&void 0!==h&&h,s.isDiscoverable=null!==(d=n.is_discoverable)&&void 0!==d?d:s.isPublic,s.isAccessCodeRequired=null!==(f=n.is_access_code_required)&&void 0!==f&&f,s.isPushEnabled=null!==(p=n.is_push_enabled)&&void 0!==p&&p,Array.isArray(n.members))&&(T=s.members).push.apply(T,_(n.members.map((function(e){return new hd(s._iid,e)}))));return s.memberCount=null!==(v=n.member_count)&&void 0!==v?v:0,s.joinedMemberCount=null!==(m=n.joined_member_count)&&void 0!==m?m:0,s.hiddenState=D(e.HiddenState,n.hidden_state)?n.hidden_state:e.HiddenState.UNHIDDEN,s.messageOffsetTimestamp=null!==(g=n.ts_message_offset)&&void 0!==g?g:0,s.messageSurvivalSeconds=null!==(y=n.message_survival_seconds)&&void 0!==y?y:-1,s.lastMessage=n.last_message?Vs(s._iid,Object.assign({channel_type:s.channelType},n.last_message)):null,n.read_receipt&&Object.keys(n.read_receipt).forEach((function(e){L("number",n.read_receipt[e])&&s._updateUnreadMemberState(e,n.read_receipt[e])})),n.delivery_receipt&&Object.keys(n.delivery_receipt).forEach((function(e){L("number",n.delivery_receipt[e])&&s._updateUndeliveredMemberState(e,n.delivery_receipt[e])})),s.myMemberState=D(e.MemberState,n.member_state)?n.member_state:e.MemberState.NONE,s.myRole=D(e.Role,n.my_role)?n.my_role:e.Role.NONE,D(e.MutedState,n.is_muted)?s.myMutedState=n.is_muted:L("boolean",n.is_muted)?s.myMutedState=n.is_muted?e.MutedState.MUTED:e.MutedState.UNMUTED:s.myMutedState=e.MutedState.UNMUTED,s.myCountPreference=D(e.CountPreference,n.count_preference)?n.count_preference:e.CountPreference.ALL,s.myPushTriggerOption=D(e.PushTriggerOption,n.push_trigger_option)?n.push_trigger_option:e.PushTriggerOption.ALL,s.myLastRead=null!==(k=n.user_last_read)&&void 0!==k?k:0,s.inviter=n.inviter?new Ja(s._iid,n.inviter):null,s.invitedAt=null!==(b=n.invited_at)&&void 0!==b?b:0,s.joinedAt=null!==(E=n.joined_ts)&&void 0!==E?E:0,s._updateUnreadCount(null!==(w=n.unread_message_count)&&void 0!==w?w:0,null!==(x=n.unread_mention_count)&&void 0!==x?x:0),s.pinnedMessageIds=null!==(C=n.pinned_message_ids)&&void 0!==C?C:[],s.lastPinnedMessage=n.latest_pinned_message?Vs(s._iid,Object.assign({channel_type:s.channelType},n.latest_pinned_message)):null,s}return s(u,[{key:"isHidden",get:function(){return this.hiddenState!==e.HiddenState.UNHIDDEN}},{key:"isTyping",get:function(){return this._typingStatus.size>0}},{key:"cachedUnreadMemberState",get:function(){var e,t={},n=y(this._unreadMemberStateMap);try{for(n.s();!(e=n.n()).done;){var r=v(e.value,2),a=r[0],s=r[1];t[a]=s}}catch(e){n.e(e)}finally{n.f()}return t}},{key:"cachedUndeliveredMemberState",get:function(){var e,t={},n=y(this._undeliveredMemberStateMap);try{for(n.s();!(e=n.n()).done;){var r=v(e.value,2),a=r[0],s=r[1];t[a]=s}}catch(e){n.e(e)}finally{n.f()}return t}},{key:"_shouldUpdateLastMessageWith",value:function(e){return!(e instanceof Ns&&e.parentMessageId>0&&!e.replyToChannel)&&(!this.lastMessage||this.lastMessage.createdAt=0)if(this.myCountPreference===e.CountPreference.ALL||this.myCountPreference===e.CountPreference.UNREAD_MESSAGE_COUNT_ONLY)if(this.isExclusive||this.isSuper||this.isBroadcast){var r=ds.of(this._iid).maxSuperGroupChannelUnreadCount;this.unreadMessageCount=r&&t>=r?r:t}else this.unreadMessageCount=t;else this.unreadMessageCount=0;else this.unreadMessageCount=0;"number"==typeof n&&n>=0&&(this.myCountPreference===e.CountPreference.ALL||this.myCountPreference===e.CountPreference.UNREAD_MENTION_COUNT_ONLY)?this.unreadMentionCount=n:this.unreadMentionCount=0}},{key:"_updateUnreadMemberState",value:function(e,t){var n=this._unreadMemberStateMap.get(e);return(!n||n1&&void 0!==arguments[1]?arguments[1]:(new Date).getTime();t>0?this._typingStatus.set(e.userId,{user:e,ts:t}):this._typingStatus.delete(e.userId)}},{key:"_clearTypingStatus",value:function(){this._typingStatus.clear(),this._typingStarted=0,this._typingEnded=0}},{key:"_setLatestMemberCount",value:function(e,t,n){var r=!1;return n>=this._lastMemberCountUpdated&&(this._lastMemberCountUpdated=n,r=e!==this.memberCount||t!==this.joinedMemberCount,this.memberCount=e,this.joinedMemberCount=t),r}},{key:"isReadMessage",value:function(e){var t=ds.of(this._iid).sdkState,n=this._unreadMemberStateMap.get(t.userId);return n&&n>=e.createdAt}},{key:"serialize",value:function(){var e=this;return Ka(this,(function(t){t.cachedUnreadMemberState=e.cachedUnreadMemberState,t.cachedUndeliveredMemberState=e.cachedUndeliveredMemberState}))}},{key:"createMessageCollection",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return new ap(this._iid,Object.assign({channel:this},e))}},{key:"createMemberListQuery",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return new pp(this._iid,this.url,e)}},{key:"createPinnedMessageListQuery",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return new zp(this._iid,this.url,this.channelType,e)}},{key:"addMember",value:function(t){var n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0;if(!this.isExclusive&&!this.isSuper&&!this.isBroadcast){var r=this.members.findIndex((function(e){return e.userId===t.userId}));if(r>-1){var a=this.members[r];a.state===e.MemberState.JOINED&&(t.state=a.state),this.members.splice(r,1),this.memberCount--}this.members.push(t),this.memberCount++,this._updateUnreadMemberState(t.userId,n),this._updateUndeliveredMemberState(t.userId,n)}}},{key:"removeMember",value:function(e){if(!this.isExclusive&&!this.isSuper&&!this.isBroadcast){var t=e instanceof hd?e.userId:e,n=this.members.findIndex((function(e){return e.userId===t}));if(n>-1)return this.members.splice(n,1),this.memberCount--,!0}return!1}},{key:"getUnreadMemberCount",value:function(t){if(t instanceof Ns&&!this.isExclusive&&!this.isSuper&&!this.isBroadcast){var n,r=ds.of(this._iid).sdkState,a=t.createdAt,s=0,i=y(this.members);try{for(i.s();!(n=i.n()).done;){var o=n.value;if(r.userId!==o.userId&&o.state===e.MemberState.JOINED&&t.sender.userId!==o.userId)(this.cachedUnreadMemberState[o.userId]||0)1&&void 0!==arguments[1]&&arguments[1],r=ds.of(this._iid).sdkState;if(!r.userId||this.isExclusive||this.isSuper||this.isBroadcast)return[];var a=e instanceof Ns?e.sender:null,s=[];return this.members.forEach((function(i){(n||i.userId!==r.userId&&i.userId!==(null==a?void 0:a.userId))&&(t._unreadMemberStateMap.get(i.userId)>=e.createdAt&&s.push(i))})),s}},{key:"getUnreadMembers",value:function(e){var t=this,n=arguments.length>1&&void 0!==arguments[1]&&arguments[1],r=ds.of(this._iid).sdkState;if(!r.userId||this.isExclusive||this.isSuper||this.isBroadcast)return[];var a=e instanceof Ns?e.sender:null,s=[];return this.members.forEach((function(i){(n||i.userId!==r.userId&&i.userId!==(null==a?void 0:a.userId))&&(t._unreadMemberStateMap.get(i.userId)0&&void 0!==arguments[0]&&arguments[0],n=ds.of(this._iid).sdkState;if(!n.userId||this.isExclusive||this.isSuper||this.isBroadcast)return null;var r={};return this.members.forEach((function(a){if(t||a.userId!==n.userId){var s=e._unreadMemberStateMap.get(a.userId);r[a.userId]=new dd(e._iid,{channel_url:e.url,channel_type:e.channelType,user:hd.payloadify(a),ts:s})}})),r}},{key:"getTypingUsers",value:function(){var e=[];return this._typingStatus.forEach((function(t){var n=t.user;e.push(n)})),e}},{key:"invalidateTypingStatus",value:function(){var e=this,t=ds.of(this._iid).typingIndicatorInvalidateTime,n=Date.now(),r=!1;return this._typingStatus.forEach((function(a,s){var i=a.ts;n-i>=t&&(e._typingStatus.delete(s),r=!0)})),r}},{key:"refresh",value:function(){return b(this,void 0,void 0,t().mark((function n(){var r,a,s,i,o,u,c;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return r=ds.of(this._iid),a=r.requestQueue,s=r.dispatcher,i=new Ld({channelUrl:this.url}),t.next=4,a.send(i);case 4:return o=t.sent,u=o.as(Dd),c=u.channel,this._update(c),s.dispatch(new hu({channels:[c],source:e.GroupChannelEventSource.REQUEST_CHANNEL})),t.abrupt("return",this);case 9:case"end":return t.stop()}}),n,this)})))}},{key:"freeze",value:function(){var n=this,r=Object.create(null,{freeze:{get:function(){return p(o(u.prototype),"freeze",n)}}});return b(this,void 0,void 0,t().mark((function n(){var a;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,r.freeze.call(this);case 2:a=ds.of(this._iid),a.dispatcher.dispatch(new hu({channels:[this],source:e.GroupChannelEventSource.EVENT_CHANNEL_HIDDEN}));case 4:case"end":return t.stop()}}),n,this)})))}},{key:"unfreeze",value:function(){var n=this,r=Object.create(null,{unfreeze:{get:function(){return p(o(u.prototype),"unfreeze",n)}}});return b(this,void 0,void 0,t().mark((function n(){var a;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,r.unfreeze.call(this);case 2:a=ds.of(this._iid),a.dispatcher.dispatch(new hu({channels:[this],source:e.GroupChannelEventSource.EVENT_CHANNEL_UNHIDDEN}));case 4:case"end":return t.stop()}}),n,this)})))}},{key:"updateChannel",value:function(n){return b(this,void 0,void 0,t().mark((function r(){var a,s,i,o,u,c,l,h;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return a=Object.assign(Object.assign({},sp),n),Ya(ip(a)).throw(A.invalidParameters),s=ds.of(this._iid),i=s.dispatcher,o=s.requestQueue,u=new mp(Object.assign({channelUrl:this.url},a)),t.next=6,o.send(u);case 6:return c=t.sent,l=c.as(gp),h=l.channel,this._update(h),i.dispatch(new hu({channels:[h],source:e.GroupChannelEventSource.EVENT_CHANNEL_UPDATED})),t.abrupt("return",this);case 11:case"end":return t.stop()}}),r,this)})))}},{key:"invite",value:function(e){return b(this,void 0,void 0,t().mark((function n(){return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return Ya(e.every((function(e){return e instanceof Ja}))).throw(A.invalidParameters),t.abrupt("return",this.inviteWithUserIds(e.map((function(e){return e.userId}))));case 2:case"end":return t.stop()}}),n,this)})))}},{key:"inviteWithUserIds",value:function(n){return b(this,void 0,void 0,t().mark((function r(){var a,s,i,o,u,c,l;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return Ya(F("string",n)).throw(A.invalidParameters),a=ds.of(this._iid),s=a.dispatcher,i=a.requestQueue,o=new sf({channelUrl:this.url,userIds:n}),t.next=5,i.send(o);case 5:return u=t.sent,c=u.as(of),l=c.channel,this._update(l),s.dispatch(new hu({channels:[l],source:e.GroupChannelEventSource.EVENT_CHANNEL_INVITED})),t.abrupt("return",this);case 10:case"end":return t.stop()}}),r,this)})))}},{key:"join",value:function(){var n=arguments.length>0&&void 0!==arguments[0]?arguments[0]:null;return b(this,void 0,void 0,t().mark((function r(){var a,s,i,o,u,c,l,h;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return Ya(L("string",n)||null===n).throw(A.invalidParameters),a=ds.of(this._iid),s=a.dispatcher,i=a.sdkState,o=a.requestQueue,u=new ef({channelUrl:this.url,userId:i.userId,accessCode:n}),t.next=5,o.send(u);case 5:return c=t.sent,l=c.as(tf),(h=l.channel).myMemberState=this.myMemberState=e.MemberState.JOINED,this._update(h),s.dispatch(new hu({channels:[h],source:e.GroupChannelEventSource.EVENT_CHANNEL_JOINED})),t.abrupt("return",this);case 11:case"end":return t.stop()}}),r,this)})))}},{key:"leave",value:function(){var n=arguments.length>0&&void 0!==arguments[0]&&arguments[0];return b(this,void 0,void 0,t().mark((function r(){var a,s,i,o;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return a=ds.of(this._iid),s=a.sdkState,i=a.requestQueue,o=new rf({channelUrl:this.url,userId:s.userId,shouldRemoveOperatorStatus:n}),t.next=4,i.send(o);case 4:this.myMemberState=e.MemberState.NONE;case 5:case"end":return t.stop()}}),r,this)})))}},{key:"acceptInvitation",value:function(){var n=arguments.length>0&&void 0!==arguments[0]?arguments[0]:null;return b(this,void 0,void 0,t().mark((function r(){var a,s,i,o,u,c,l,h;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return Ya(L("string",n)||null===n).throw(A.invalidParameters),a=ds.of(this._iid),s=a.dispatcher,i=a.sdkState,o=a.requestQueue,u=new vp({channelUrl:this.url,userId:i.userId,accessCode:n}),t.next=5,o.send(u);case 5:return c=t.sent,l=c.as(_p),(h=l.channel).myMemberState=this.myMemberState=e.MemberState.JOINED,this._update(h),s.dispatch(new hu({channels:[h],source:e.GroupChannelEventSource.EVENT_CHANNEL_ACCEPTED_INVITE})),t.abrupt("return",this);case 11:case"end":return t.stop()}}),r,this)})))}},{key:"declineInvitation",value:function(){return b(this,void 0,void 0,t().mark((function n(){var r,a,s,i;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return r=ds.of(this._iid),a=r.sdkState,s=r.requestQueue,i=new cf({channelUrl:this.url,userId:a.userId}),t.next=4,s.send(i);case 4:return this.myMemberState=e.MemberState.NONE,t.abrupt("return",this);case 6:case"end":return t.stop()}}),n,this)})))}},{key:"sendUserMessage",value:function(t){var n=this,r=new wi,a=ds.of(this._iid).dispatcher,s=su.of(this._iid);return p(o(u.prototype),"sendUserMessage",this).call(this,t).onPending((function(e){s.completeCurrentAndProcessNextAutoResend(e),r._trigger(null,e)})).onFailed((function(e,t){t&&s.completeCurrentAndProcessNextAutoResend(t),r._trigger(e,t)})).onSucceeded((function(t){n.hiddenState===e.HiddenState.HIDDEN_ALLOW_AUTO_UNHIDE&&(n.hiddenState=e.HiddenState.UNHIDDEN),s.completeCurrentAndProcessNextAutoResend(t),n._shouldUpdateLastMessageWith(t)&&(n.lastMessage=t),Rf.of(n._iid).handlers.map((function(e){return e.onChannelChanged(n)})),a.dispatch(new hu({channels:[n],source:e.GroupChannelEventSource.EVENT_MESSAGE_SENT})),r._trigger(null,t)})),r}},{key:"updateUserMessage",value:function(n,r){var a=this,s=Object.create(null,{updateUserMessage:{get:function(){return p(o(u.prototype),"updateUserMessage",a)}}});return b(this,void 0,void 0,t().mark((function a(){var i,o,u,c,l,h=this;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return i=ds.of(this._iid),o=i.dispatcher,t.next=3,s.updateUserMessage.call(this,n,r);case 3:return u=t.sent,c=!1,!u.silent&&this._shouldUpdateLastMessageWith(u)&&(this.lastMessage=u,c=!0),l=!1,this.lastPinnedMessage&&this.lastPinnedMessage.messageId===u.messageId&&(this.lastPinnedMessage=u,c=!0,l=!0),c&&(Rf.of(this._iid).handlers.map((function(e){return e.onChannelChanged(h)})),o.dispatch(new hu({channels:[this],source:l?e.GroupChannelEventSource.EVENT_PINNED_MESSAGE_UPDATED:e.GroupChannelEventSource.EVENT_MESSAGE_UPDATED}))),l&&Rf.of(this._iid).handlers.map((function(e){return e.onPinnedMessageUpdated(h)})),o.dispatch(new oi({messages:[u],source:e.MessageEventSource.EVENT_MESSAGE_UPDATED})),t.abrupt("return",u);case 12:case"end":return t.stop()}}),a,this)})))}},{key:"_autoResendUserMessage",value:function(t){var n=this,r=new wi,a=ds.of(this._iid).dispatcher,s=su.of(this._iid);return p(o(u.prototype),"_autoResendUserMessage",this).call(this,t).onPending((function(e){s.completeCurrentAndProcessNextAutoResend(e),r._trigger(null,e)})).onFailed((function(e,t){s.completeCurrentAndProcessNextAutoResend(t),r._trigger(e,t)})).onSucceeded((function(t){var i=Rf.of(n._iid);s.completeCurrentAndProcessNextAutoResend(t),n._shouldUpdateLastMessageWith(t)&&(n.lastMessage=t),i.handlers.map((function(e){return e.onChannelChanged(n)})),a.dispatch(new hu({channels:[n],source:e.GroupChannelEventSource.EVENT_MESSAGE_SENT})),r._trigger(null,t)})),r}},{key:"sendFileMessage",value:function(t){var n=this,r=new wi,a=ds.of(this._iid).dispatcher,s=su.of(this._iid);return p(o(u.prototype),"sendFileMessage",this).call(this,t).onPending((function(e){s.completeCurrentAndProcessNextAutoResend(e),r._trigger(null,e)})).onFailed((function(e,t){t&&s.completeCurrentAndProcessNextAutoResend(t),r._trigger(e,t)})).onSucceeded((function(t){var i=Rf.of(n._iid);s.completeCurrentAndProcessNextAutoResend(t),n._shouldUpdateLastMessageWith(t)&&(n.lastMessage=t),i.handlers.map((function(e){return e.onChannelChanged(n)})),a.dispatch(new hu({channels:[n],source:e.GroupChannelEventSource.EVENT_MESSAGE_SENT})),r._trigger(null,t)})),r}},{key:"sendMultipleFilesMessage",value:function(t){var n=this,r=new Fi,a=ds.of(this._iid).dispatcher;return p(o(u.prototype),"sendMultipleFilesMessage",this).call(this,t).onPending((function(e){r._trigger(null,e)})).onFailed((function(e,t){r._trigger(e,t)})).onSucceeded((function(t){var s=Rf.of(n._iid);n._shouldUpdateLastMessageWith(t)&&(n.lastMessage=t),s.handlers.map((function(e){return e.onChannelChanged(n)})),a.dispatch(new hu({channels:[n],source:e.GroupChannelEventSource.EVENT_MESSAGE_SENT})),r._trigger(null,t)})).onFileUploaded((function(e,t,n,a){r._triggerOnFileUploaded(e,t,n,a)})),r}},{key:"updateFileMessage",value:function(n,r){var a=this,s=Object.create(null,{updateFileMessage:{get:function(){return p(o(u.prototype),"updateFileMessage",a)}}});return b(this,void 0,void 0,t().mark((function a(){var i,o,u,c,l,h=this;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return i=ds.of(this._iid),o=i.dispatcher,t.next=3,s.updateFileMessage.call(this,n,r);case 3:return u=t.sent,c=!1,!u.silent&&this._shouldUpdateLastMessageWith(u)&&(this.lastMessage=u,c=!0),l=!1,this.lastPinnedMessage&&this.lastPinnedMessage.messageId===u.messageId&&(this.lastPinnedMessage=u,c=!0,l=!0),c&&(Rf.of(this._iid).handlers.map((function(e){return e.onChannelChanged(h)})),o.dispatch(new hu({channels:[this],source:l?e.GroupChannelEventSource.EVENT_PINNED_MESSAGE_UPDATED:e.GroupChannelEventSource.EVENT_MESSAGE_UPDATED}))),l&&Rf.of(this._iid).handlers.map((function(e){return e.onPinnedMessageUpdated(h)})),o.dispatch(new oi({messages:[u],source:e.MessageEventSource.EVENT_MESSAGE_UPDATED})),t.abrupt("return",u);case 12:case"end":return t.stop()}}),a,this)})))}},{key:"_autoResendFileMessage",value:function(t){var n=this,r=new wi,a=ds.of(this._iid).dispatcher,s=su.of(this._iid);return p(o(u.prototype),"_autoResendFileMessage",this).call(this,t).onPending((function(e){s.completeCurrentAndProcessNextAutoResend(e),r._trigger(null,e)})).onFailed((function(e,t){s.completeCurrentAndProcessNextAutoResend(t),r._trigger(e,t)})).onSucceeded((function(t){var i=Rf.of(n._iid);s.completeCurrentAndProcessNextAutoResend(t),n._shouldUpdateLastMessageWith(t)&&(n.lastMessage=t),i.handlers.map((function(e){return e.onChannelChanged(n)})),a.dispatch(new hu({channels:[n],source:e.GroupChannelEventSource.EVENT_MESSAGE_SENT})),r._trigger(null,t)})),r}},{key:"deleteMessage",value:function(n){var r=this,a=Object.create(null,{deleteMessage:{get:function(){return p(o(u.prototype),"deleteMessage",r)}}});return b(this,void 0,void 0,t().mark((function r(){var s;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,a.deleteMessage.call(this,n);case 2:0===n.messageId&&n instanceof Ns&&(s=ds.of(this._iid),s.dispatcher.dispatch(new ci({reqId:n.reqId,source:e.MessageEventSource.EVENT_MESSAGE_DELETED})));case 3:case"end":return t.stop()}}),r,this)})))}},{key:"hide",value:function(n){return b(this,void 0,void 0,t().mark((function r(){var a,s,i,o,u,c,l,h,d;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return a=Object.assign(Object.assign({},op),n),Ya(up(a)).throw(A.invalidParameters),s=ds.of(this._iid),i=s.dispatcher,o=s.sdkState,u=s.requestQueue,c=new vf(Object.assign({channelUrl:this.url,userId:o.userId},a)),t.next=6,u.send(c);case 6:return l=t.sent,h=l.as(_f),d=h.messageOffsetTimestamp,this.hiddenState=a.allowAutoUnhide?e.HiddenState.HIDDEN_ALLOW_AUTO_UNHIDE:e.HiddenState.HIDDEN_PREVENT_AUTO_UNHIDE,a.hidePreviousMessages&&this._updateUnreadCount(0,0),d&&(this.messageOffsetTimestamp=d),i.dispatch(new hu({channels:[this],source:e.GroupChannelEventSource.EVENT_CHANNEL_HIDDEN})),t.abrupt("return",this);case 13:case"end":return t.stop()}}),r,this)})))}},{key:"unhide",value:function(){return b(this,void 0,void 0,t().mark((function n(){var r,a,s,i;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return r=ds.of(this._iid),a=r.dispatcher,s=r.requestQueue,i=new kp({channelUrl:this.url}),t.next=4,s.send(i);case 4:return this.hiddenState=e.HiddenState.UNHIDDEN,a.dispatch(new hu({channels:[this],source:e.GroupChannelEventSource.EVENT_CHANNEL_UNHIDDEN})),t.abrupt("return",this);case 7:case"end":return t.stop()}}),n,this)})))}},{key:"delete",value:function(){return b(this,void 0,void 0,t().mark((function e(){var n,r,a;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n=ds.of(this._iid),r=n.requestQueue,a=new yp({channelUrl:this.url}),e.next=4,r.send(a);case 4:case"end":return e.stop()}}),e,this)})))}},{key:"markAsRead",value:function(){return b(this,void 0,void 0,t().mark((function n(){var r,a,s,i,o,u,c,l,h=this;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return r=ds.of(this._iid),a=r.sdkState,s=r.dispatcher,i=r.requestQueue,o=new hf({channelUrl:this.url}),t.next=4,i.send(o);case 4:u=t.sent,c=u.as(df),l=c.readStatus,this._updateUnreadMemberState(a.userId,l.readAt),(this.unreadMessageCount>0||this.unreadMentionCount>0)&&(this._updateUnreadCount(0,0),Rf.of(this._iid).handlers.map((function(e){return e.onChannelChanged(h)}))),s.dispatch(new hu({channels:[this],source:e.GroupChannelEventSource.EVENT_CHANNEL_READ}));case 9:case"end":return t.stop()}}),n,this)})))}},{key:"markAsDelivered",value:function(){return b(this,void 0,void 0,t().mark((function e(){var n,r,a,s;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n=ds.of(this._iid),r=n.sdkState,a=n.requestQueue,s=new ff({channelUrl:this.url,userId:r.userId}),e.next=4,a.send(s);case 4:case"end":return e.stop()}}),e,this)})))}},{key:"startTyping",value:function(){return b(this,void 0,void 0,t().mark((function e(){var n,r,a,s,i;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:n=ds.of(this._iid),r=n.requestQueue,a=n.typingIndicatorThrottle,(s=(new Date).getTime())-this._typingStarted>=a&&(this._typingStarted=s,this._typingEnded=0,i=new gf({channelUrl:this.url,time:this._typingStarted}),r.send(i));case 3:case"end":return e.stop()}}),e,this)})))}},{key:"endTyping",value:function(){return b(this,void 0,void 0,t().mark((function e(){var n,r,a,s,i;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:n=ds.of(this._iid),r=n.requestQueue,a=n.typingIndicatorThrottle,(s=(new Date).getTime())-this._typingEnded>=a&&(this._typingStarted=0,this._typingEnded=s,i=new kf({channelUrl:this.url,time:this._typingStarted}),r.send(i));case 3:case"end":return e.stop()}}),e,this)})))}},{key:"createScheduledUserMessage",value:function(e){e=Object.assign(Object.assign({},Vo),e),Ya(function(e){return Mo(e)&&L("number",e.scheduledAt,!0)}(e)).throw(A.invalidParameters);var t=new wi;return this._createScheduledUserMessage(e,t),t}},{key:"updateScheduledUserMessage",value:function(e,n){return b(this,void 0,void 0,t().mark((function r(){var a,s,i,o,u,c,l;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return a=Object.assign(Object.assign({},Sp),n),Ya(Ip(a)).throw(A.invalidParameters),s=ds.of(this._iid),i=s.requestQueue,o=new Ap(Object.assign({reqId:this._generateRequestId(),scheduledMessageId:e,channelType:this.channelType,channelUrl:this.url},a)),t.next=6,i.send(o);case 6:return u=t.sent,c=u.as(Fh),l=c.message,t.abrupt("return",l);case 9:case"end":return t.stop()}}),r,this)})))}},{key:"createScheduledFileMessage",value:function(e){var n=this;e=Object.assign(Object.assign({},Bo),e),Ya(function(e){return To(e)&&L("number",e.scheduledAt)&&(q(e.file)||L("string",e.fileUrl))&&L("string",e.fileName,!0)&&L("string",e.mimeType,!0)&&L("number",e.fileSize,!0)&&(null===e.thumbnailSizes||void 0===e.thumbnailSizes||e.thumbnailSizes.every((function(e){return L("object",e)&&e.maxWidth>0&&e.maxHeight>0})))}(e)).throw(A.invalidParameters);var r=Date.now(),a=this._generateRequestId(),s=new wi;return ka(2).then((function(){var i=n._createPendingScheduledFileMessage(e,a,r);wa((function(){return b(n,void 0,void 0,t().mark((function e(){return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",s._trigger(null,i));case 1:case"end":return e.stop()}}),e)})))}))})),q(e.file)?this._uploadFileAndUpdateParams(e).then((function(){return n._createScheduledFileMessage(e,s,a,r)})):this._createScheduledFileMessage(e,s,a,r),s}},{key:"updateScheduledFileMessage",value:function(e,n){return b(this,void 0,void 0,t().mark((function r(){var a,s,i,o,u,c,l;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(a=Object.assign(Object.assign({},Cp),n),Ya(Tp(a)).throw(A.invalidParameters),!q(a.file)){t.next=5;break}return t.next=5,this._uploadFileAndUpdateParams(a);case 5:return s=new Np(Object.assign({reqId:this._generateRequestId(),scheduledMessageId:e,channelType:this.channelType,channelUrl:this.url},a)),i=ds.of(this._iid),o=i.requestQueue,t.next=9,o.send(s);case 9:return u=t.sent,c=u.as(Mp),l=c.message,t.abrupt("return",l);case 12:case"end":return t.stop()}}),r,this)})))}},{key:"cancelScheduledMessage",value:function(e){return b(this,void 0,void 0,t().mark((function n(){var r,a,s;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return r=new Op({scheduledMessageId:e,channelType:this.channelType,channelUrl:this.url}),a=ds.of(this._iid),s=a.requestQueue,t.next=4,s.send(r);case 4:return t.abrupt("return");case 5:case"end":return t.stop()}}),n,this)})))}},{key:"sendScheduledMessageNow",value:function(e){return b(this,void 0,void 0,t().mark((function n(){var r,a,s;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return r=new Up({scheduledMessageId:e,channelType:this.channelType,channelUrl:this.url}),a=ds.of(this._iid),s=a.requestQueue,t.next=4,s.send(r);case 4:return t.abrupt("return");case 5:case"end":return t.stop()}}),n,this)})))}},{key:"getMyPushTriggerOption",value:function(){return b(this,void 0,void 0,t().mark((function e(){var n,r,a,s,i,o,u;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n=ds.of(this._iid),r=n.sdkState,a=n.requestQueue,s=new Dp({userId:r.userId,channelUrl:this.url}),e.next=4,a.send(s);case 4:return i=e.sent,o=i.as(Pp),u=o.pushTriggerOption,this.myPushTriggerOption=u,e.abrupt("return",u);case 8:case"end":return e.stop()}}),e,this)})))}},{key:"setMyPushTriggerOption",value:function(n){return b(this,void 0,void 0,t().mark((function r(){var a,s,i,o,u,c,l,h;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return Ya(D(e.PushTriggerOption,n)).throw(A.invalidParameters),a=ds.of(this._iid),s=a.dispatcher,i=a.sdkState,o=a.requestQueue,u=new Rp({userId:i.userId,channelUrl:this.url,pushTriggerOption:n}),t.next=5,o.send(u);case 5:return c=t.sent,l=c.as(Lp),h=l.pushTriggerOption,this.myPushTriggerOption=h,s.dispatch(new hu({channels:[this],source:e.GroupChannelEventSource.EVENT_CHANNEL_UPDATED})),t.abrupt("return",h);case 10:case"end":return t.stop()}}),r,this)})))}},{key:"setMyCountPreference",value:function(n){return b(this,void 0,void 0,t().mark((function r(){var a,s,i,o,u,c,l,h;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return Ya(D(e.CountPreference,n)).throw(A.invalidParameters),a=ds.of(this._iid),s=a.dispatcher,i=a.sdkState,o=a.requestQueue,u=new bp({channelUrl:this.url,userId:i.userId,countPreference:n}),t.next=5,o.send(u);case 5:return c=t.sent,l=c.as(Ep),h=l.countPreference,this.myCountPreference=h,this._updateUnreadCount(this.unreadMessageCount,this.unreadMentionCount),s.dispatch(new hu({channels:[this],source:e.GroupChannelEventSource.EVENT_CHANNEL_UPDATED})),t.abrupt("return",h);case 11:case"end":return t.stop()}}),r,this)})))}},{key:"resetMyHistory",value:function(){return b(this,void 0,void 0,t().mark((function n(){var r,a,s,i,o,u,c;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return r=ds.of(this._iid),a=r.dispatcher,s=r.requestQueue,i=new wp({channelUrl:this.url}),t.next=4,s.send(i);case 4:return o=t.sent,u=o.as(xp),c=u.messageOffsetTimestamp,this.messageOffsetTimestamp=c,a.dispatch(new hu({channels:[this],source:e.GroupChannelEventSource.EVENT_CHANNEL_RESET_HISTORY})),t.abrupt("return",this);case 9:case"end":return t.stop()}}),n,this)})))}},{key:"pinMessage",value:function(e){return b(this,void 0,void 0,t().mark((function n(){var r,a,s;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return Ya(L("number",e)&&e>0).throw(A.invalidParameters),r=ds.of(this._iid),a=r.requestQueue,s=new Fp({channelType:this.channelType,channelUrl:this.url,messageId:e}),t.next=5,a.send(s);case 5:case"end":return t.stop()}}),n,this)})))}},{key:"unpinMessage",value:function(e){return b(this,void 0,void 0,t().mark((function n(){var r,a,s;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return Ya(L("number",e)&&e>0).throw(A.invalidParameters),r=ds.of(this._iid),a=r.requestQueue,s=new Gp({channelType:this.channelType,channelUrl:this.url,messageId:e}),t.next=5,a.send(s);case 5:case"end":return t.stop()}}),n,this)})))}},{key:"_uploadFileAndUpdateParams",value:function(e){return b(this,void 0,void 0,t().mark((function n(){var r,a,s,i,o,u,c,l,h,d,f,p;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(!q(e.file)){t.next=11;break}return r=ds.of(this._iid),a=r.requestQueue,s=new ps({file:e.file,channelUrl:this.url,thumbnailSizes:e.thumbnailSizes,requestId:this._generateRequestId()}),t.next=5,a.send(s);case 5:i=t.sent,o=i.as(vs),u=o.url,c=o.fileSize,l=void 0===c?e.fileSize:c,h=o.thumbnailSizes,d=void 0===h?e.thumbnailSizes:h,f=o.requireAuth,p=void 0!==f&&f,e.fileUrl=u,e.fileSize=l,e.thumbnailSizes=d,e.requireAuth=p;case 11:case"end":return t.stop()}}),n,this)})))}}],[{key:"payloadify",value:function(e){return e?ue(Object.assign(Object.assign({},p(o(u),"payloadify",this).call(this,e)),{is_access_code_required:e.isAccessCodeRequired,is_distinct:e.isDistinct,is_super:e.isSuper,is_broadcast:e.isBroadcast,is_exclusive:e.isExclusive,is_public:e.isPublic,is_discoverable:e.isDiscoverable,is_muted:e.myMutedState,is_push_enabled:e.isPushEnabled,unread_message_count:e.unreadMessageCount,unread_mention_count:e.unreadMentionCount,push_trigger_option:e.myPushTriggerOption,count_preference:e.myCountPreference,hidden_state:e.hiddenState,member_count:e.memberCount,joined_member_count:e.joinedMemberCount,member_state:e.myMemberState,my_role:e.myRole,user_last_read:e.myLastRead,ts_message_offset:e.messageOffsetTimestamp,message_survival_seconds:e.messageSurvivalSeconds,read_receipt:e.cachedUnreadMemberState,delivery_receipt:e.cachedUndeliveredMemberState,members:e.members.map((function(e){return hd.payloadify(e)})),last_message:zs(e.lastMessage),inviter:e.inviter?Ja.payloadify(e.inviter):null,invited_at:e.invitedAt,joined_ts:e.joinedAt,pinned_message_ids:e.pinnedMessageIds,latest_pinned_message:zs(e.lastPinnedMessage)})):null}}]),u}(ed),Qp={},Kp=function(){function n(a){var s=this,i=a._iid,o=a.limit,u=void 0===o?100:o;r(this,n),this._sync=null,this._connectionEventContext=null,this.ref=0,this._metadata=null,this._iid=i,this._limit=u;var c,l=ds.of(this._iid),h=l.sdkState,d=l.dispatcher,f=l.logger;this._metadataKey=(c=h.userId,"sendbird:".concat(c,"@groupchannel/sync.meta"));var p=function(e){return"sendbird:".concat(e,"@groupchannel/sync")}(h.userId);this._sync=new Lf(p,(function(){return b(s,void 0,void 0,t().mark((function n(){var r,a,s,i,o,u;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return r={hasNext:!0,nextToken:""},t.next=3,this.loadMetadata();case 3:if(f.debug("channel background sync from",this._metadata.token),this._metadata.completed){t.next=31;break}return t.prev=5,s=Rf.of(this._iid),t.next=9,s.getMyGroupChannels(this._metadata.token,{includeEmpty:!0,order:e.GroupChannelListOrder.CHRONOLOGICAL},this._limit,e.GroupChannelEventSource.SYNC_CHANNEL_BACKGROUND);case 9:return i=t.sent,o=i.channels,u=i.token,r.hasNext=o.length>=this._limit&&!!u,r.nextToken=u,this._metadata.token=u,(a=this._metadata.range).extends.apply(a,_(o.map((function(e){return e.createdAt})))),this._metadata.completed=!r.hasNext,f.debug("channel background sync progress",r),t.next=20,this.saveMetadata();case 20:t.next=29;break;case 22:if(t.prev=22,t.t0=t.catch(5),f.debug("channel background sync error",t.t0),!(t.t0 instanceof A&&t.t0.isInvalidTokenError)){t.next=28;break}return t.next=28,this.clearMetaData();case 28:throw t.t0;case 29:t.next=33;break;case 31:r.hasNext=!1,r.nextToken="";case 33:return t.abrupt("return",r);case 34:case"end":return t.stop()}}),n,this,[[5,22]])})))})),this._connectionEventContext=d.on((function(e){if(e instanceof ha)if(e.stateType===aa.CONNECTED)s.resume();else s.pause()}))}return s(n,[{key:"range",get:function(){var e;return null===(e=this._metadata)||void 0===e?void 0:e.range}},{key:"completed",get:function(){var e;return!!(null===(e=this._metadata)||void 0===e?void 0:e.completed)}},{key:"loadMetadata",value:function(){return b(this,void 0,void 0,t().mark((function e(){var n,r,a;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(this._metadata){e.next=6;break}return n=ds.of(this._iid),r=n.cacheContext,e.next=4,r.preference.get(this._metadataKey);case 4:a=e.sent,this._metadata={token:a?a.token:"",range:new Af(a?a.range:{top:Number.MAX_SAFE_INTEGER,bottom:0}),completed:!!a&&a.completed};case 6:return e.abrupt("return",this._metadata);case 7:case"end":return e.stop()}}),e,this)})))}},{key:"saveMetadata",value:function(){return b(this,void 0,void 0,t().mark((function e(){var n,r;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!this._metadata){e.next=5;break}return n=ds.of(this._iid),r=n.cacheContext,e.next=4,r.preference.set(this._metadataKey,this._metadata);case 4:return e.abrupt("return",!0);case 5:return e.abrupt("return",!1);case 6:case"end":return e.stop()}}),e,this)})))}},{key:"clearMetaData",value:function(){return b(this,void 0,void 0,t().mark((function e(){var n,r;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n=ds.of(this._iid),r=n.cacheContext,e.next=3,r.preference.remove(this._metadataKey);case 3:this._metadata=null;case 4:case"end":return e.stop()}}),e,this)})))}},{key:"resume",value:function(){var e,t,n=ds.of(this._iid),r=n.logger;n.connectionManager.isConnected&&(r.debug("channel background sync resume()"),this._sync.start(null!==(t=null===(e=this._metadata)||void 0===e?void 0:e.token)&&void 0!==t?t:""))}},{key:"pause",value:function(){ds.of(this._iid).logger.debug("channel background sync stop()"),this._sync.stop()}},{key:"close",value:function(){this.ref--,this.ref<=0&&(this.ref=0,this.pause(),this._connectionEventContext.close(),delete Qp[this._iid])}}],[{key:"of",value:function(e){return Qp[e]||(Qp[e]=new n({_iid:e})),Qp[e].ref++,Qp[e]}},{key:"clear",value:function(e){Qp[e]&&(Qp[e].close(),delete Qp[e])}}]),n}(),Wp={},Yp=function(){function n(a){var s=this,i=a._iid;r(this,n),this._sync=null,this._connectionEventContext=null,this.ref=0,this._metadataKey=null,this._metadata=null,this._iid=i;var o,u=ds.of(this._iid),c=u.logger,l=u.sdkState,h=u.dispatcher;this._metadataKey=(o=l.userId,"sendbird:".concat(o,"@groupchannel/changelogs.meta"));var d=function(e){return"sendbird:".concat(e,"@groupchannel/changelogs")}(l.userId);this._sync=new Lf(d,(function(){return b(s,void 0,void 0,t().mark((function n(){var r,a,s,i,o;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return r={hasNext:!0,nextToken:0},t.next=3,this.loadMetadata();case 3:return c.debug("channel changelog sync from",this._metadata.token),t.prev=4,a=Rf.of(this._iid),t.next=8,a.getMyGroupChannelChangeLogs(this._metadata.token,{includeEmpty:!0},e.GroupChannelEventSource.SYNC_CHANNEL_CHANGELOGS);case 8:return s=t.sent,i=s.hasMore,o=s.token,r.hasNext=i,r.nextToken=o,this._metadata.token=o,c.debug("channel changelog sync progress",r),t.next=17,this.saveMetadata();case 17:t.next=26;break;case 19:if(t.prev=19,t.t0=t.catch(4),c.debug("channel changelog sync error",t.t0),!(t.t0 instanceof A&&t.t0.isInvalidTokenError)){t.next=25;break}return t.next=25,this.clearMetadata();case 25:throw t.t0;case 26:return t.abrupt("return",r);case 27:case"end":return t.stop()}}),n,this,[[4,19]])})))})),this._connectionEventContext=h.on((function(e){if(e instanceof ha)if(e.stateType===aa.CONNECTED)s.resume();else s.pause()}))}return s(n,[{key:"loadMetadata",value:function(){return b(this,void 0,void 0,t().mark((function e(){var n,r,a,s;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(this._metadata){e.next=6;break}return n=ds.of(this._iid),r=n.cacheContext,a=n.firstConnectedAt,e.next=4,r.preference.get(this._metadataKey);case 4:s=e.sent,this._metadata={token:s?s.token:a};case 6:return e.abrupt("return",this._metadata);case 7:case"end":return e.stop()}}),e,this)})))}},{key:"saveMetadata",value:function(){return b(this,void 0,void 0,t().mark((function e(){var n,r;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!this._metadata){e.next=5;break}return n=ds.of(this._iid),r=n.cacheContext,e.next=4,r.preference.set(this._metadataKey,this._metadata);case 4:return e.abrupt("return",!0);case 5:return e.abrupt("return",!1);case 6:case"end":return e.stop()}}),e,this)})))}},{key:"clearMetadata",value:function(){return b(this,void 0,void 0,t().mark((function e(){var n,r;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n=ds.of(this._iid),r=n.cacheContext,e.next=3,r.preference.remove(this._metadataKey);case 3:this._metadata=null;case 4:case"end":return e.stop()}}),e,this)})))}},{key:"resume",value:function(){ds.of(this._iid).connectionManager.isConnected&&this._sync.start(0)}},{key:"pause",value:function(){this._sync.stop()}},{key:"close",value:function(){this.ref--,this.ref<=0&&(this.ref=0,this.pause(),this._connectionEventContext.close(),delete Wp[this._iid])}}],[{key:"of",value:function(e){return Wp[e]||(Wp[e]=new n({_iid:e})),Wp[e].ref++,Wp[e]}},{key:"clear",value:function(e){Wp[e]&&(Wp[e].close(),delete Wp[e])}}]),n}(),Zp=function(){function n(a,s){var i=this,o=s.filter,u=s.order,c=s.limit;r(this,n),this.channels=[],this._backgroundSync=null,this._changelogSync=null,this._iid=a,this._key="gcc-".concat(re()),this._isDisposed=!1,this._isGetRemoteChannelsSucceeded=!0,this.filter=null!=o?o:new pd,this.order=null!=u?u:e.GroupChannelListOrder.LATEST_LAST_MESSAGE,this._hasMore=!0,this._token="",this._limit=null!=c?c:100;var l=ds.of(this._iid),h=l.sdkState,d=l.cacheContext,f=l.dispatcher;d.localCacheEnabled&&(this._backgroundSync=Kp.of(a),this._backgroundSync.resume()),this._changelogSync=Yp.of(a),this._changelogSync.resume(),Rf.of(this._iid).subscribeGroupChannelEvent(this._key,{onUpdate:function(e,t){if(lu(t)){var n=e.filter((function(e){return i.filter.match(e,h.userId)})),r=e.filter((function(e){return!i.filter.match(e,h.userId)})).map((function(e){return e.url}));n.length>0&&i._addChannelsToView(n,t),r.length>0&&i._removeChannelsFromView(r,t)}},onRemove:function(e,t){i._removeChannelsFromView(e,t)}}),ds.of(this._iid).statLogCollector.put(new as({type:Me.FEATURE_LOCALCACHE,data:{use_local_cache:d.localCacheEnabled,collection_interface:{group_channel:!0}}})),f.on((function(e){e instanceof ha&&(e.stateType===aa.CONNECTED?i._isGetRemoteChannelsSucceeded||b(i,void 0,void 0,t().mark((function e(){return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this._revokeLoadMore();case 2:case"end":return e.stop()}}),e,this)}))):e.stateType===aa.LOGOUT&&i.dispose())}))}return s(n,[{key:"hasMore",get:function(){return!this._isDisposed&&this._hasMore}},{key:"setGroupChannelCollectionHandler",value:function(e){this._handler=e}},{key:"_addChannelsToView",value:function(n,r){var a,s=this,i=arguments.length>2&&void 0!==arguments[2]&&arguments[2],o=[],u=[],c=[],l=y(n);try{for(l.s();!(a=l.n()).done;){var h=a.value,d=Wf(this.channels,h,this.order),f=d.place,p=d.oldPosition;if(-1===p)f===this.channels.length?!i&&this._hasMore||(o.push(h),this.channels.push(h)):(o.push(h),this.channels.splice(f,0,h));else switch(r){case e.GroupChannelEventSource.EVENT_CHANNEL_UPDATED:case e.GroupChannelEventSource.EVENT_MESSAGE_RECEIVED:case e.GroupChannelEventSource.SYNC_CHANNEL_CHANGELOGS:case e.GroupChannelEventSource.EVENT_MESSAGE_SENT:f!==p?this._hasMore&&f===this.channels.length?c.push(h):(this.channels.splice(p,1),this.channels.splice(p0){var v,_=y(c);try{for(_.s();!(v=_.n()).done;){var m=v.value,g=Kf(this.channels,m);-1!==g&&this.channels.splice(g,1)}}catch(e){_.e(e)}finally{_.f()}}lu(r)&&wa((function(){return b(s,void 0,void 0,t().mark((function e(){var n,a,s,i;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:i=new Df(r),o.length>0&&(null===(n=this._handler)||void 0===n?void 0:n.onChannelsAdded)&&this._handler.onChannelsAdded(i,o),u.length>0&&(null===(a=this._handler)||void 0===a?void 0:a.onChannelsUpdated)&&this._handler.onChannelsUpdated(i,u),c.length>0&&(null===(s=this._handler)||void 0===s?void 0:s.onChannelsDeleted)&&this._handler.onChannelsDeleted(i,c.map((function(e){return e.url})));case 4:case"end":return e.stop()}}),e,this)})))}))}},{key:"_removeChannelsFromView",value:function(e,n){var r,a=this,s=[],i=y(e);try{var o=function(){var e=r.value,t=a.channels.findIndex((function(t){return t.url===e}));t>=0&&(s.push(a.channels[t].url),a.channels.splice(t,1))};for(i.s();!(r=i.n()).done;)o()}catch(e){i.e(e)}finally{i.f()}return lu(n)&&s.length>0&&wa((function(){return b(a,void 0,void 0,t().mark((function e(){var r,a;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:a=new Df(n),(null===(r=this._handler)||void 0===r?void 0:r.onChannelsDeleted)&&this._handler.onChannelsDeleted(a,s);case 2:case"end":return e.stop()}}),e,this)})))})),s}},{key:"_getLocalChannels",value:function(){return b(this,void 0,void 0,t().mark((function e(){var n,r;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n=Rf.of(this._iid),r=this.channels.length>0?Qf(this.channels[this.channels.length-1],this.order):null,e.next=4,n.getChannelsFromCache(r,this.filter,this.order,this._limit,r?this.channels[this.channels.length-1].url:null);case 4:return e.abrupt("return",e.sent);case 5:case"end":return e.stop()}}),e,this)})))}},{key:"_getRemoteChannels",value:function(){return b(this,void 0,void 0,t().mark((function e(){var n,r,a,s;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n=Rf.of(this._iid),e.next=3,n.getMyGroupChannels(this._token,Object.assign(Object.assign({},this.filter),{order:this.order}),this._limit);case 3:return r=e.sent,a=r.channels,s=r.token,this._token=s,this._hasMore=!!s,e.abrupt("return",a);case 9:case"end":return e.stop()}}),e,this)})))}},{key:"_revokeLoadMore",value:function(){return b(this,void 0,void 0,t().mark((function n(){var r;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(!this._isDisposed){t.next=2;break}return t.abrupt("return");case 2:return t.prev=2,t.next=5,this._getRemoteChannels();case 5:r=t.sent,this._isGetRemoteChannelsSucceeded=!0,this._addChannelsToView(r,e.GroupChannelEventSource.REQUEST_CHANNEL,!0),t.next=13;break;case 10:t.prev=10,t.t0=t.catch(2),this._isGetRemoteChannelsSucceeded=!1;case 13:case"end":return t.stop()}}),n,this,[[2,10]])})))}},{key:"loadMore",value:function(){return b(this,void 0,void 0,t().mark((function n(){var r,a,s,i=this;return t().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:if(!this._isDisposed){n.next=2;break}throw new A({code:E.COLLECTION_DISPOSED,message:"Collection has been disposed."});case 2:if(!this._hasMore){n.next=23;break}if(r=ds.of(this._iid),a=r.cacheContext,s=[],!a.localCacheEnabled||!this._backgroundSync.completed){n.next=11;break}return n.next=8,xa((function(){return b(i,void 0,void 0,t().mark((function e(){return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this._getLocalChannels();case 2:s=e.sent;case 3:case"end":return e.stop()}}),e,this)})))}));case 8:this._hasMore=s.length>=this._limit,n.next=21;break;case 11:return n.prev=11,n.next=14,this._getRemoteChannels();case 14:s=n.sent,this._isGetRemoteChannelsSucceeded=!0,n.next=21;break;case 18:n.prev=18,n.t0=n.catch(11),this._isGetRemoteChannelsSucceeded=!1;case 21:return this._addChannelsToView(s,e.GroupChannelEventSource.REQUEST_CHANNEL,!0),n.abrupt("return",s);case 23:return n.abrupt("return",[]);case 24:case"end":return n.stop()}}),n,this,[[11,18]])})))}},{key:"dispose",value:function(){var e,t;this._isDisposed||(this._isDisposed=!0,this.channels.length>0&&this.channels.splice(0,this.channels.length),null===(e=this._backgroundSync)||void 0===e||e.close(),null===(t=this._changelogSync)||void 0===t||t.close(),Rf.of(this._iid).unsubscribeGroupChannelEvent(this._key))}}]),n}(),Jp=function(t){i(a,t);var n=f(a);function a(t){var s;r(this,a);var i=t.token,o=t.limit,u=t.order,c=t.includeEmpty,l=t.membershipFilter,h=t.channelNameContainsFilter,d=t.channelUrlsFilter,f=t.customTypesFilter,p=t.customTypeStartsWithFilter,v=t.superChannelFilter,_=t.metadataOrderKeyFilter,m=t.metadataKey,g=t.metadataValues,y=t.metadataValueStartsWith,k=t.includeFrozen,b=t.includeMetaData;return(s=n.call(this)).method=ce.GET,s.path=fe,s.params=ue({token:i,limit:o,order:u,show_member:!0,show_read_receipt:!0,show_delivery_receipt:!0,show_empty:c,public_mode:e.PublicChannelFilter.PUBLIC,public_membership_mode:l,name_contains:h,channel_urls:d,custom_types:f,custom_type_startswith:p,super_mode:v,metadata_order_key:_,metadata_key:m,metadata_values:g,metadata_value_startswith:y,show_frozen:k,show_metadata:b}),s}return s(a)}(Ae),Xp=function(e){i(n,e);var t=f(n);function n(e,a){var s;r(this,n),(s=t.call(this,e,a)).token=null,s.channels=[],s.ts=null;var i=a.next,o=a.channels,u=a.ts;return s.token=i,o&&o.length>0&&(s.channels=o.map((function(t){return t.ts=u,new Bp(e,t)}))),s.ts="number"==typeof u?u:null,s}return s(n)}(Oe);e.MembershipFilter=void 0,(Vp=e.MembershipFilter||(e.MembershipFilter={})).ALL="all",Vp.JOINED="joined";var $p,ev=function(n){i(u,n);var a=f(u);function u(t,n){var s,i,o,c,l,h,d,f,p,v,_,m,g,y,k;return r(this,u),(s=a.call(this,t,n)).includeEmpty=!1,s.includeFrozen=!0,s.includeMetaData=!0,s.channelUrlsFilter=null,s.customTypesFilter=null,s.customTypeStartsWithFilter=null,s.channelNameContainsFilter=null,s.membershipFilter=e.MembershipFilter.ALL,s.superChannelFilter=e.SuperChannelFilter.ALL,s.metadataKey=null,s.metadataValues=null,s.metadataOrderKeyFilter=null,s.metadataValueStartsWith=null,s.order=e.PublicGroupChannelListOrder.CHRONOLOGICAL,s.includeEmpty=null!==(i=n.includeEmpty)&&void 0!==i&&i,s.includeFrozen=null===(o=n.includeFrozen)||void 0===o||o,s.includeMetaData=null===(c=n.includeMetaData)||void 0===c||c,s.channelUrlsFilter=null!==(l=n.channelUrlsFilter)&&void 0!==l?l:null,s.customTypesFilter=null!==(h=n.customTypesFilter)&&void 0!==h?h:null,s.customTypeStartsWithFilter=null!==(d=n.customTypeStartsWithFilter)&&void 0!==d?d:null,s.channelNameContainsFilter=null!==(f=n.channelNameContainsFilter)&&void 0!==f?f:null,s.membershipFilter=null!==(p=n.membershipFilter)&&void 0!==p?p:e.MembershipFilter.ALL,s.superChannelFilter=null!==(v=n.superChannelFilter)&&void 0!==v?v:e.SuperChannelFilter.ALL,s.metadataKey=null!==(_=n.metadataKey)&&void 0!==_?_:null,s.metadataValues=null!==(m=n.metadataValues)&&void 0!==m?m:null,s.metadataOrderKeyFilter=null!==(g=n.metadataOrderKeyFilter)&&void 0!==g?g:null,s.metadataValueStartsWith=null!==(y=n.metadataValueStartsWith)&&void 0!==y?y:null,s.order=null!==(k=n.order)&&void 0!==k?k:e.PublicGroupChannelListOrder.CHRONOLOGICAL,s}return s(u,[{key:"_validate",value:function(){return p(o(u.prototype),"_validate",this).call(this)&&L("boolean",this.includeEmpty)&&L("boolean",this.includeFrozen)&&L("boolean",this.includeMetaData)&&L("string",this.channelNameContainsFilter,!0)&&F("string",this.channelUrlsFilter,!0)&&F("string",this.customTypesFilter,!0)&&L("string",this.customTypeStartsWithFilter,!0)&&D(e.MembershipFilter,this.membershipFilter)&&D(e.SuperChannelFilter,this.superChannelFilter)&&D(e.PublicGroupChannelListOrder,this.order)&&L("string",this.metadataOrderKeyFilter,!0)&&L("string",this.metadataKey,!0)&&F("string",this.metadataValues,!0)&&L("string",this.metadataValueStartsWith,!0)}},{key:"next",value:function(){return b(this,void 0,void 0,t().mark((function e(){var n,r,a,s,i,o,u,c;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!this._validate()){e.next=21;break}if(this._isLoading){e.next=18;break}if(n=[],!this._hasNext){e.next=15;break}return this._isLoading=!0,r=ds.of(this._iid),a=r.requestQueue,r.dispatcher,s=new Jp(Object.assign(Object.assign({},this),{token:this._token})),e.next=9,a.send(s);case 9:return i=e.sent,o=i.as(Xp),u=o.channels,c=o.token,this._token=c,this._hasNext=!!c,this._isLoading=!1,e.abrupt("return",u);case 15:return e.abrupt("return",n);case 18:throw A.queryInProgress;case 19:e.next=22;break;case 21:throw A.invalidParameters;case 22:case"end":return e.stop()}}),e,this)})))}}]),u}(Si),tv=s((function e(){r(this,e),this.onUserMuted=qe,this.onUserUnmuted=qe,this.onUserBanned=qe,this.onUserUnbanned=qe,this.onChannelChanged=qe,this.onChannelDeleted=qe,this.onChannelFrozen=qe,this.onChannelUnfrozen=qe,this.onOperatorUpdated=qe,this.onChannelMemberCountChanged=qe,this.onMetaDataCreated=qe,this.onMetaDataUpdated=qe,this.onMetaDataDeleted=qe,this.onMetaCounterCreated=qe,this.onMetaCounterUpdated=qe,this.onMetaCounterDeleted=qe,this.onMessageReceived=qe,this.onMessageUpdated=qe,this.onMessageDeleted=qe,this.onMentionReceived=qe,this.onReactionUpdated=qe,this.onThreadInfoUpdated=qe})),nv=function(e){i(n,e);var t=f(n);function n(){var e;return r(this,n),(e=t.apply(this,arguments)).onUserJoined=qe,e.onUserLeft=qe,e.onUserReceivedInvitation=qe,e.onUserDeclinedInvitation=qe,e.onChannelHidden=qe,e.onUnreadMemberStatusUpdated=qe,e.onUndeliveredMemberStatusUpdated=qe,e.onTypingStatusUpdated=qe,e.onPollUpdated=qe,e.onPollVoted=qe,e.onPollDeleted=qe,e.onPinnedMessageUpdated=qe,e}return s(n)}(tv),rv=function(e){i(n,e);var t=f(n);function n(){var e,a=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return r(this,n),e=t.call(this),Object.keys(a).forEach((function(t){e.hasOwnProperty(t)&&(e[t]=a[t])})),e}return s(n)}(nv),av=function(e){i(n,e);var t=f(n);function n(e){var a;r(this,n);var s=e.token,i=e.limit,o=e.order,u=e.reverse,c=e.channelUrl,l=e.messageTypeFilter,h=e.scheduledStatus;return(a=t.call(this)).method=ce.GET,a.path="".concat(Ee),a.params=ue({token:s,limit:i,reverse:u,channel_url:c,order:o,message_type:l,status:h}),a}return s(n)}(Ae),sv=function(e){i(n,e);var t=f(n);function n(e,a){var s;r(this,n),(s=t.call(this,e,a)).token=null,s.scheduledMessages=[];var i=a.next,o=a.scheduled_messages;return s.token=i,s.scheduledMessages=o.map((function(t){return Vs(e,t)})),s}return s(n)}(Oe),iv=function(n){i(u,n);var a=f(u);function u(t,n){var s,i,o,c,l,h;return r(this,u),(s=a.call(this,t,n)).channelUrl=null,s.order=null,s.reverse=!1,s.scheduledStatus=null,s.messageTypeFilter=e.MessageTypeFilter.ALL,s.channelUrl=null!==(i=n.channelUrl)&&void 0!==i?i:null,s.order=null!==(o=n.order)&&void 0!==o?o:null,s.reverse=null!==(c=n.reverse)&&void 0!==c&&c,s.scheduledStatus=null!==(l=n.scheduledStatus)&&void 0!==l?l:null,s.messageTypeFilter=null!==(h=n.messageTypeFilter)&&void 0!==h?h:e.MessageTypeFilter.ALL,s}return s(u,[{key:"_validate",value:function(){return p(o(u.prototype),"_validate",this).call(this)&&L("string",this.channelUrl,!0)&&(D(e.ScheduledMessageListOrder,this.order)||null===this.order)&&L("boolean",this.reverse)&&(F(e.ScheduledStatus,this.scheduledStatus)||null===this.scheduledStatus)&&D(e.MessageTypeFilter,this.messageTypeFilter)}},{key:"next",value:function(){return b(this,void 0,void 0,t().mark((function e(){var n,r,a,s,i,o,u;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!this._validate()){e.next=20;break}if(this._isLoading){e.next=17;break}if(!this._hasNext){e.next=14;break}return this._isLoading=!0,n=ds.of(this._iid),r=n.requestQueue,a=new av(Object.assign(Object.assign({},this),{token:this._token})),e.next=8,r.send(a);case 8:return s=e.sent,i=s.as(sv),o=i.scheduledMessages,u=i.token,this._token=u,this._hasNext=!!u,this._isLoading=!1,e.abrupt("return",o);case 14:return e.abrupt("return",[]);case 17:throw A.queryInProgress;case 18:e.next=21;break;case 20:throw A.invalidParameters;case 21:case"end":return e.stop()}}),e,this)})))}}]),u}(Si),ov=function(e){i(a,e);var n=f(a);function a(){var e;return r(this,a),(e=n.apply(this,arguments)).name="groupChannel",e}return s(a,[{key:"init",value:function(e,t){var n=t.sdkState,r=t.dispatcher,s=t.sessionManager,i=t.requestQueue,u=t.logger,c=t.onlineDetector,l=t.cacheContext;p(o(a.prototype),"init",this).call(this,e,{sdkState:n,dispatcher:r,sessionManager:s,requestQueue:i,logger:u,onlineDetector:c,cacheContext:l}),this._manager=new Rf(e,{sdkState:n,cacheContext:l,dispatcher:r,sessionManager:s,requestQueue:i,logger:u})}},{key:"createGroupChannelCollection",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return new Zp(this._iid,e)}},{key:"createMyGroupChannelListQuery",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return new Mf(this._iid,e)}},{key:"createPublicGroupChannelListQuery",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return new ev(this._iid,e)}},{key:"createScheduledMessageListQuery",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return new iv(this._iid,e)}},{key:"addGroupChannelHandler",value:function(e,t){Ya(L("string",e)&&t instanceof rv).throw(A.invalidParameters),this._manager.addHandler(e,t)}},{key:"removeGroupChannelHandler",value:function(e){Ya(L("string",e)).throw(A.invalidParameters),this._manager.removeHandler(e)}},{key:"removeAllGroupChannelHandlers",value:function(){this._manager.clearHandler()}},{key:"buildGroupChannelFromSerializedData",value:function(e){return this._manager.buildGroupChannelFromSerializedData(e)}},{key:"buildGroupChannelListQueryFromSerializedData",value:function(e){return this._manager.buildGroupChannelListQueryFromSerializedData(e)}},{key:"buildMemberFromSerializedData",value:function(e){return this._manager.buildMemberFromSerializedData(e)}},{key:"getChannel",value:function(e){return b(this,void 0,void 0,t().mark((function n(){return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return Ya(L("string",e)).throw(A.invalidParameters),t.abrupt("return",this._manager.getChannel(e));case 2:case"end":return t.stop()}}),n,this)})))}},{key:"getChannelWithoutCache",value:function(e){return b(this,void 0,void 0,t().mark((function n(){return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return Ya(L("string",e)).throw(A.invalidParameters),t.abrupt("return",this._manager.getChannelWithoutCache(e));case 2:case"end":return t.stop()}}),n,this)})))}},{key:"getMyGroupChannelChangeLogsByToken",value:function(e){var n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return b(this,void 0,void 0,t().mark((function r(){var a;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return a=Object.assign(Object.assign({},kd),n),Ya(L("string",e)&&bd(a)).throw(A.invalidParameters),t.next=4,this._manager.getMyGroupChannelChangeLogs(e,a);case 4:return t.abrupt("return",t.sent);case 5:case"end":return t.stop()}}),r,this)})))}},{key:"getMyGroupChannelChangeLogsByTimestamp",value:function(e){var n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return b(this,void 0,void 0,t().mark((function r(){var a;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return a=Object.assign(Object.assign({},kd),n),Ya(L("number",e)&&bd(a)).throw(A.invalidParameters),t.next=4,this._manager.getMyGroupChannelChangeLogs(e,a);case 4:return t.abrupt("return",t.sent);case 5:case"end":return t.stop()}}),r,this)})))}},{key:"getGroupChannelCount",value:function(e){return b(this,void 0,void 0,t().mark((function n(){var r;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return r=Object.assign(Object.assign({},Ed),e),Ya(wd(r)).throw(A.invalidParameters),t.abrupt("return",this._manager.getGroupChannelCount(r));case 3:case"end":return t.stop()}}),n,this)})))}},{key:"getUnreadItemCount",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return b(this,void 0,void 0,t().mark((function n(){return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,this._manager.getUnreadItemCount(e);case 2:return t.abrupt("return",t.sent);case 3:case"end":return t.stop()}}),n,this)})))}},{key:"getTotalUnreadChannelCount",value:function(){return b(this,void 0,void 0,t().mark((function e(){return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this._manager.getTotalUnreadChannelCount();case 2:return e.abrupt("return",e.sent);case 3:case"end":return e.stop()}}),e,this)})))}},{key:"getTotalUnreadMessageCount",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return b(this,void 0,void 0,t().mark((function n(){return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,this._manager.getTotalUnreadMessageCount(e);case 2:return t.abrupt("return",t.sent);case 3:case"end":return t.stop()}}),n,this)})))}},{key:"getTotalScheduledMessageCount",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return b(this,void 0,void 0,t().mark((function n(){return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,this._manager.getTotalScheduledMessageCount(e);case 2:return t.abrupt("return",t.sent);case 3:case"end":return t.stop()}}),n,this)})))}},{key:"getSubscribedTotalUnreadMessageCount",value:function(){return this._manager.getSubscribedTotalUnreadMessageCount()}},{key:"getSubscribedCustomTypeTotalUnreadMessageCount",value:function(){return this._manager.getSubscribedCustomTypeTotalUnreadMessageCount()}},{key:"getSubscribedCustomTypeUnreadMessageCount",value:function(e){return this._manager.getSubscribedCustomTypeUnreadMessageCount(e)}},{key:"createChannel",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return b(this,void 0,void 0,t().mark((function n(){var r;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return r=Object.assign(Object.assign({},gd),e),Ya(yd(r)).throw(A.invalidParameters),t.abrupt("return",this._manager.createChannel(r));case 3:case"end":return t.stop()}}),n,this)})))}},{key:"createDistinctChannelIfNotExist",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return b(this,void 0,void 0,t().mark((function n(){var r;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return r=Object.assign(Object.assign({},gd),e),Ya(yd(r)).throw(A.invalidParameters),r&&(r.isDistinct=!0),t.abrupt("return",this.createChannel(r));case 4:case"end":return t.stop()}}),n,this)})))}},{key:"createChannelWithUserIds",value:function(e){var n=arguments.length>1&&void 0!==arguments[1]&&arguments[1],r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:null,a=arguments.length>3&&void 0!==arguments[3]?arguments[3]:null,s=arguments.length>4&&void 0!==arguments[4]?arguments[4]:"",i=arguments.length>5&&void 0!==arguments[5]?arguments[5]:"";return b(this,void 0,void 0,t().mark((function o(){var u;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return u=Object.assign(Object.assign({},gd),{invitedUserIds:e,isDistinct:n,name:r,data:s,customType:i}),"string"==typeof a?u.coverUrl=a:u.coverImage=a,t.abrupt("return",this.createChannel(u));case 3:case"end":return t.stop()}}),o,this)})))}},{key:"markAsReadAll",value:function(){return b(this,void 0,void 0,t().mark((function e(){return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:this._manager.markAsReadAll();case 1:case"end":return e.stop()}}),e,this)})))}},{key:"markAsReadWithChannelUrls",value:function(e){return b(this,void 0,void 0,t().mark((function n(){return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:Ya(F("string",e)).throw(A.invalidParameters),this._manager.markAsReadWithChannelUrls(e);case 2:case"end":return t.stop()}}),n,this)})))}},{key:"markAsDelivered",value:function(e){return b(this,void 0,void 0,t().mark((function n(){var r;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return Ya(L("string",e)).throw(A.invalidParameters),t.next=3,this.getChannel(e);case 3:return r=t.sent,t.next=6,r.markAsDelivered();case 6:case"end":return t.stop()}}),n,this)})))}}]),a}(fs),uv=function(e){i(a,e);var n=f(a);function a(){var e;return r(this,a),(e=n.apply(this,arguments))._channels=new Map,e._enteredChannelUrls=[],e}return s(a,[{key:"enteredChannels",get:function(){var e=this;return this._enteredChannelUrls.map((function(t){return e._channels.get(t)})).filter((function(e){return null!==e}))}},{key:"isEnteredChannel",value:function(e){return this._enteredChannelUrls.includes(e)}},{key:"enter",value:function(e){this._enteredChannelUrls.indexOf(e)<0&&this._enteredChannelUrls.push(e)}},{key:"exit",value:function(e){var t=this._enteredChannelUrls.indexOf(e);t>=0&&this._enteredChannelUrls.splice(t,1)}},{key:"exitAll",value:function(){this._enteredChannelUrls=[]}},{key:"get",value:function(e){var n;return b(this,void 0,void 0,t().mark((function r(){return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.abrupt("return",null!==(n=this._channels.get(e))&&void 0!==n?n:null);case 1:case"end":return t.stop()}}),r,this)})))}},{key:"upsert",value:function(e){return b(this,void 0,void 0,t().mark((function n(){var r,a=this;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return r=[],e.forEach((function(e){if(a._channels.has(e.url)){var t=a._channels.get(e.url);Object.assign(t,e),r.push(t)}else a._channels.set(e.url,e),r.push(e)})),t.abrupt("return",r);case 3:case"end":return t.stop()}}),n)})))}},{key:"remove",value:function(e){return b(this,void 0,void 0,t().mark((function n(){return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:this._channels.delete(e),this.exit(e);case 2:case"end":return t.stop()}}),n,this)})))}},{key:"clear",value:function(){return b(this,void 0,void 0,t().mark((function e(){return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:this._channels.clear(),this._enteredChannelUrls=[];case 2:case"end":return e.stop()}}),e,this)})))}}]),a}(qa),cv={channelUrl:null,name:null,coverUrlOrImage:null,data:null,customType:null,operatorUserIds:null,isEphemeral:null},lv=function(e){return F("string",e.operatorUserIds,!0)&&(L("string",e.coverUrlOrImage)||q(e.coverUrlOrImage)||null===e.coverUrlOrImage)&&L("string",e.name,!0)&&L("string",e.data,!0)&&L("string",e.customType,!0)&&(L("string",e.channelUrl)&&/^\w+$/.test(e.channelUrl)||null===e.channelUrl)&&L("boolean",e.isEphemeral,!0)},hv=function(e){i(n,e);var t=f(n);function n(e){var a,s=e.channelUrl,i=e.isInternalCall;return r(this,n),(a=t.call(this)).method=ce.GET,a.path="".concat(i?_e:ve,"/").concat(encodeURIComponent(s)),a}return s(n)}(Ae),dv=function(e){i(n,e);var t=f(n);function n(e,a){var s;return r(this,n),(s=t.call(this,e,a)).channel=null,s.channel=new Iv(e,a),s}return s(n)}(Oe),fv=function(e){i(n,e);var t=f(n);function n(e){var a;r(this,n);var s=e.channelUrl,i=e.coverUrlOrImage,o=e.name,u=e.data,c=e.customType,l=e.operatorUserIds,h=e.isEphemeral;return(a=t.call(this)).method=ce.POST,a.path=ve,a.params=ue({channel_url:s,cover_url:L("string",i)?i:null,cover_file:q(i)?i:null,name:o,data:u,custom_type:c,operators:l,is_ephemeral:h}),a}return s(n)}(Ae),pv=function(e){i(n,e);var t=f(n);function n(e){var a=e.channelUrl;return r(this,n),t.call(this,{code:"ENTR",payload:{channel_url:a},ackRequired:!0})}return s(n)}(ia),vv=function(e){i(n,e);var t=f(n);function n(e,a,s){var i,o,u;return r(this,n),i=t.call(this,e,"SYEV",s),s.data&&(i.participantCount=null!==(o=s.data.participant_count)&&void 0!==o?o:0,i.user=new Ja(e,s.data),i.ts=null!==(u=s.data.edge_ts)&&void 0!==u?u:0),i}return s(n)}($d),_v=function(e){i(n,e);var t=f(n);function n(e){var a=e.channelUrl;return r(this,n),t.call(this,{code:"EXIT",payload:{channel_url:a},ackRequired:!0})}return s(n)}(ia),mv=function(e){i(n,e);var t=f(n);function n(e,a,s){var i,o,u;return r(this,n),i=t.call(this,e,"EXIT",s),s.data&&(i.participantCount=null!==(o=s.data.participant_count)&&void 0!==o?o:0,i.user=new Ja(e,s.data),i.ts=null!==(u=s.data.edge_ts)&&void 0!==u?u:0),i}return s(n)}($d),gv={},yv=function(){function n(e,t){var a=this,s=t.sdkState,i=t.dispatcher,o=t.requestQueue;return r(this,n),gv[e]||(this._iid=e,this._sdkState=s,this._requestQueue=o,this._dispatcher=i,this._openChannelCache=new uv(e),this._openChannelHandlers=new Map,this._dispatcher.on((function(e){if(e instanceof Ge)a._handleEvent(e);else if(e instanceof ha&&e.stateType===aa.CONNECTED){var t,n=y(a._openChannelCache.enteredChannels);try{for(n.s();!(t=n.n()).done;){t.value.enter()}}catch(e){n.e(e)}finally{n.f()}}})),gv[e]=this),gv[e]}return s(n,[{key:"buildOpenChannelFromSerializedData",value:function(e){var t=Wa(e);return new Iv(this._iid,Iv.payloadify(t))}},{key:"getChannelFromCache",value:function(e){return b(this,void 0,void 0,t().mark((function n(){return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,this._openChannelCache.get(e);case 2:return t.abrupt("return",t.sent);case 3:case"end":return t.stop()}}),n,this)})))}},{key:"upsertChannelsToCache",value:function(e){return b(this,void 0,void 0,t().mark((function n(){return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,this._openChannelCache.upsert(e);case 2:return t.abrupt("return",t.sent);case 3:case"end":return t.stop()}}),n,this)})))}},{key:"removeChannelsFromCache",value:function(e){return b(this,void 0,void 0,t().mark((function n(){var r,a,s;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:r=y(e),t.prev=1,r.s();case 3:if((a=r.n()).done){t.next=9;break}return s=a.value,t.next=7,this._openChannelCache.remove(s);case 7:t.next=3;break;case 9:t.next=14;break;case 11:t.prev=11,t.t0=t.catch(1),r.e(t.t0);case 14:return t.prev=14,r.f(),t.finish(14);case 17:case"end":return t.stop()}}),n,this,[[1,11,14,17]])})))}},{key:"setEnteredToCache",value:function(e){this._openChannelCache.enter(e.url)}},{key:"setExitedToCache",value:function(e){this._openChannelCache.exit(e.url)}},{key:"_handleEvent",value:function(n){return b(this,void 0,void 0,t().mark((function r(){var a,s,i,o,u,c,l,h,d,f,p,v,_,m,g,k,E,w,x,C,T,S,I,N,A,O,U,R,L,D,P,F,G,q,H,j,z,V,B,Q,K,W,Y,Z,J,X,$,ee,te,ne,re,ae,se,ie,oe,ue,ce,le,he,de,fe,pe,ve,_e,me,ge,ye,ke,be,Ee,we,xe,Ce,Te,Se,Ie,Ne,Me,Ae,Oe,Ue,Re,Le,De=this;return t().wrap((function(r){for(;;)switch(r.prev=r.next){case 0:r.prev=0,r.t0=n.code,r.next="MESG"===r.t0||"FILE"===r.t0||"ADMM"===r.t0||"BRDM"===r.t0?4:"MEDI"===r.t0||"FEDI"===r.t0||"AEDI"===r.t0?14:"DELM"===r.t0?24:"MRCT"===r.t0?31:"MTHD"===r.t0?38:"MCNT"===r.t0?45:"PEDI"===r.t0?73:"VOTE"===r.t0?81:"SYEV"===r.t0?89:166;break;case 4:if(a=null,"MESG"===n.code?a=n.as(xh):"FILE"===n.code?a=n.as(Ws):"ADMM"!==n.code&&"BRDM"!=n.code||(a=n.as(Cf)),!a){r.next=13;break}if(i=(s=a).message,o=s.isMentioned,i.channelType!==e.ChannelType.OPEN){r.next=13;break}return r.next=11,this.getChannel(i.channelUrl,!0);case 11:u=r.sent,wa((function(){return b(De,void 0,void 0,t().mark((function e(){var n,r,a;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:n=y(this._openChannelHandlers.values());try{for(n.s();!(r=n.n()).done;)a=r.value,this._openChannelCache.isEnteredChannel(u.url)&&(a.onMessageReceived(u,i),o&&a.onMentionReceived(u,i))}catch(e){n.e(e)}finally{n.f()}case 2:case"end":return e.stop()}}),e,this)})))}));case 13:return r.abrupt("break",166);case 14:if(c=null,"MEDI"===n.code?c=n.as(Th):"FEDI"===n.code?c=n.as(Ih):"AEDI"===n.code&&(c=n.as(Tf)),!c){r.next=23;break}if(h=(l=c).message,d=l.mentionCountChange,h.channelType!==e.ChannelType.OPEN){r.next=23;break}return r.next=21,this.getChannel(h.channelUrl,!0);case 21:f=r.sent,wa((function(){return b(De,void 0,void 0,t().mark((function e(){var n,r,a;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:n=y(this._openChannelHandlers.values());try{for(n.s();!(r=n.n()).done;)a=r.value,this._openChannelCache.isEnteredChannel(f.url)&&(a.onMessageUpdated(f,h),d>0&&a.onMentionReceived(f,h))}catch(e){n.e(e)}finally{n.f()}case 2:case"end":return e.stop()}}),e,this)})))}));case 23:return r.abrupt("break",166);case 24:if(p=n.as(Mh),v=p.channelUrl,_=p.channelType,m=p.messageId,_!==e.ChannelType.OPEN){r.next=30;break}return r.next=28,this.getChannel(v,!0);case 28:g=r.sent,wa((function(){return b(De,void 0,void 0,t().mark((function e(){var n,r,a;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:n=y(this._openChannelHandlers.values());try{for(n.s();!(r=n.n()).done;)a=r.value,this._openChannelCache.isEnteredChannel(g.url)&&a.onMessageDeleted(g,m)}catch(e){n.e(e)}finally{n.f()}case 2:case"end":return e.stop()}}),e,this)})))}));case 30:return r.abrupt("break",166);case 31:if(k=n.as(Sf),E=k.channelUrl,w=k.channelType,x=k.event,w!==e.ChannelType.OPEN){r.next=37;break}return r.next=35,this.getChannel(E,!0);case 35:C=r.sent,wa((function(){return b(De,void 0,void 0,t().mark((function e(){var n,r,a;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:n=y(this._openChannelHandlers.values());try{for(n.s();!(r=n.n()).done;)a=r.value,this._openChannelCache.isEnteredChannel(C.url)&&a.onReactionUpdated(C,x)}catch(e){n.e(e)}finally{n.f()}case 2:case"end":return e.stop()}}),e,this)})))}));case 37:return r.abrupt("break",166);case 38:if(T=n.as(If),(S=T.event).channelType!==e.ChannelType.OPEN){r.next=44;break}return r.next=42,this.getChannel(S.channelUrl,!0);case 42:I=r.sent,wa((function(){return b(De,void 0,void 0,t().mark((function e(){var n,r,a;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:n=y(this._openChannelHandlers.values());try{for(n.s();!(r=n.n()).done;)a=r.value,this._openChannelCache.isEnteredChannel(I.url)&&a.onThreadInfoUpdated(I,S)}catch(e){n.e(e)}finally{n.f()}case 2:case"end":return e.stop()}}),e,this)})))}));case 44:return r.abrupt("break",166);case 45:N=n.as(wf),A=N.openChannelMemberCounts,O=[],U=y(A),r.prev=48,U.s();case 50:if((R=U.n()).done){r.next=59;break}return L=R.value,D=L.channelUrl,P=L.participantCount,F=L.updatedAt,r.next=55,this.getChannelFromCache(D);case 55:(G=r.sent)&&G._updateParticipantCount(P,F)&&O.push(G);case 57:r.next=50;break;case 59:r.next=64;break;case 61:r.prev=61,r.t1=r.catch(48),U.e(r.t1);case 64:return r.prev=64,U.f(),r.finish(64);case 67:if(!(O.length>0)){r.next=72;break}return r.next=70,this.upsertChannelsToCache(O);case 70:q=r.sent,wa((function(){return b(De,void 0,void 0,t().mark((function e(){var n,r;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:n=y(this._openChannelHandlers.values());try{for(n.s();!(r=n.n()).done;)r.value.onChannelMemberCountChanged(q)}catch(e){n.e(e)}finally{n.f()}case 2:case"end":return e.stop()}}),e,this)})))}));case 72:return r.abrupt("break",166);case 73:if(H=n.as(Nf),j=H.event,z=H.status,V=H.channelUrl,B=H.channelType,!V||B!==e.ChannelType.OPEN){r.next=80;break}return r.next=77,this.getChannel(V,!0);case 77:Q=r.sent,this._dispatcher.dispatch(new hi({event:j,source:e.MessageEventSource.EVENT_POLL_UPDATED})),wa(z===Ls?function(){return b(De,void 0,void 0,t().mark((function e(){var n,r;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:n=y(this._openChannelHandlers.values());try{for(n.s();!(r=n.n()).done;)r.value.onPollDeleted(Q,j.pollId)}catch(e){n.e(e)}finally{n.f()}case 2:case"end":return e.stop()}}),e,this)})))}:function(){return b(De,void 0,void 0,t().mark((function e(){var n,r;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:n=y(this._openChannelHandlers.values());try{for(n.s();!(r=n.n()).done;)r.value.onPollUpdated(Q,j)}catch(e){n.e(e)}finally{n.f()}case 2:case"end":return e.stop()}}),e,this)})))});case 80:return r.abrupt("break",166);case 81:if(K=n.as($h),W=K.event,Y=K.channelUrl,Z=K.channelType,!Y||Z!==e.ChannelType.OPEN){r.next=88;break}return r.next=85,this.getChannel(Y,!0);case 85:J=r.sent,this._dispatcher.dispatch(new di({event:W,source:e.MessageEventSource.EVENT_POLL_VOTED})),wa((function(){return b(De,void 0,void 0,t().mark((function e(){var n,r;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:n=y(this._openChannelHandlers.values());try{for(n.s();!(r=n.n()).done;)r.value.onPollVoted(J,W)}catch(e){n.e(e)}finally{n.f()}case 2:case"end":return e.stop()}}),e,this)})))}));case 88:return r.abrupt("break",166);case 89:if(X=n.as($d),!($=X.event).isOpenChannelEvent){r.next=165;break}r.t2=$.category,r.next=r.t2===fd.CHANNEL_ENTER?94:r.t2===fd.CHANNEL_EXIT?101:r.t2===fd.CHANNEL_OPERATOR_UPDATE?108:r.t2===fd.USER_CHANNEL_MUTE||r.t2===fd.USER_CHANNEL_UNMUTE?116:r.t2===fd.USER_CHANNEL_BAN||r.t2===fd.USER_CHANNEL_UNBAN?123:r.t2===fd.CHANNEL_FREEZE||r.t2===fd.CHANNEL_UNFREEZE?130:r.t2===fd.CHANNEL_DELETED?138:r.t2===fd.CHANNEL_PROP_CHANGED?145:r.t2===fd.CHANNEL_META_DATA_CHANGED?150:r.t2===fd.CHANNEL_META_COUNTERS_CHANGED?159:165;break;case 94:return r.next=96,this.getChannel($.channelUrl,!0);case 96:return ee=r.sent,te=n.as(vv),ne=te.participantCount,re=te.user,ae=ee._updateParticipantCount(ne,$.ts),wa((function(){return b(De,void 0,void 0,t().mark((function e(){return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:this._openChannelHandlers.forEach((function(e){e.onUserEntered(ee,re),ae&&e.onChannelParticipantCountChanged(ee)}));case 1:case"end":return e.stop()}}),e,this)})))})),r.abrupt("break",165);case 101:return r.next=103,this.getChannel($.channelUrl,!0);case 103:return se=r.sent,ie=n.as(mv),oe=ie.participantCount,ue=ie.user,ce=se._updateParticipantCount(oe,$.ts),wa((function(){return b(De,void 0,void 0,t().mark((function e(){return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:this._openChannelHandlers.forEach((function(e){e.onUserExited(se,ue),ce&&e.onChannelParticipantCountChanged(se)}));case 1:case"end":return e.stop()}}),e,this)})))})),r.abrupt("break",165);case 108:return r.next=110,this.getChannel($.channelUrl,!0);case 110:return le=r.sent,he=n.as(Ef),de=he.operators,le.operators=de,this.upsertChannelsToCache([le]),wa((function(){return b(De,void 0,void 0,t().mark((function e(){return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:this._openChannelHandlers.forEach((function(e){e.onOperatorUpdated(le,de)}));case 1:case"end":return e.stop()}}),e,this)})))})),r.abrupt("break",165);case 116:return r.next=118,this.getChannel($.channelUrl,!0);case 118:return fe=r.sent,pe=$.category===fd.USER_CHANNEL_MUTE,ve=n.as(pe?hh:fh),_e=ve.user,wa((function(){return b(De,void 0,void 0,t().mark((function e(){return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:this._openChannelHandlers.forEach((function(e){pe?e.onUserMuted(fe,_e):e.onUserUnmuted(fe,_e)}));case 1:case"end":return e.stop()}}),e,this)})))})),r.abrupt("break",165);case 123:return r.next=125,this.getChannel($.channelUrl,!0);case 125:return me=r.sent,ge=$.category===fd.USER_CHANNEL_BAN,ye=n.as(ge?vh:mh),ke=ye.user,wa((function(){return b(De,void 0,void 0,t().mark((function e(){return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:this._openChannelHandlers.forEach((function(e){ge?e.onUserBanned(me,ke):e.onUserUnbanned(me,ke)}));case 1:case"end":return e.stop()}}),e,this)})))})),r.abrupt("break",165);case 130:return r.next=132,this.getChannel($.channelUrl,!0);case 132:return be=r.sent,Ee=n.as(yh),we=Ee.freeze,be.isFrozen=we,this.upsertChannelsToCache([be]),wa((function(){return b(De,void 0,void 0,t().mark((function e(){return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:this._openChannelHandlers.forEach((function(e){we?e.onChannelFrozen(be):e.onChannelUnfrozen(be)}));case 1:case"end":return e.stop()}}),e,this)})))})),r.abrupt("break",165);case 138:return r.next=140,this.getChannel($.channelUrl,!0);case 140:return xe=r.sent,r.next=143,this.removeChannelsFromCache([xe.url]);case 143:return wa((function(){return b(De,void 0,void 0,t().mark((function e(){return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:this._openChannelHandlers.forEach((function(e){e.onChannelDeleted(xe.url,xe.channelType)}));case 1:case"end":return e.stop()}}),e,this)})))})),r.abrupt("break",165);case 145:return r.next=147,this.getChannelWithoutCache($.channelUrl,!0);case 147:return Ce=r.sent,wa((function(){return b(De,void 0,void 0,t().mark((function e(){return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:this._openChannelHandlers.forEach((function(e){e.onChannelChanged(Ce)}));case 1:case"end":return e.stop()}}),e,this)})))})),r.abrupt("break",165);case 150:return r.next=152,this.getChannel($.channelUrl,!0);case 152:return Te=r.sent,Se=n.as(Zl),Ie=Se.created,Ne=Se.updated,Me=Se.deleted,Ie&&Te._upsertCachedMetaData(Ie,$.ts),Ne&&Te._upsertCachedMetaData(Ne,$.ts),Me&&Te._removeFromCachedMetaData(Me,$.ts),wa((function(){return b(De,void 0,void 0,t().mark((function e(){return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:this._openChannelHandlers.forEach((function(e){Ie&&e.onMetaDataCreated(Te,Ie),Ne&&e.onMetaDataUpdated(Te,Ne),Me&&e.onMetaDataDeleted(Te,Me)}));case 1:case"end":return e.stop()}}),e,this)})))})),r.abrupt("break",165);case 159:return r.next=161,this.getChannel($.channelUrl,!0);case 161:return Ae=r.sent,Oe=n.as(oh),Ue=Oe.created,Re=Oe.updated,Le=Oe.deleted,wa((function(){return b(De,void 0,void 0,t().mark((function e(){return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:this._openChannelHandlers.forEach((function(e){Ue&&e.onMetaCounterCreated(Ae,Ue),Re&&e.onMetaCounterUpdated(Ae,Re),Le&&e.onMetaCounterDeleted(Ae,Le)}));case 1:case"end":return e.stop()}}),e,this)})))})),r.abrupt("break",165);case 165:return r.abrupt("break",166);case 166:r.next=172;break;case 168:if(r.prev=168,r.t3=r.catch(0),!M(r.t3)){r.next=172;break}throw r.t3;case 172:case"end":return r.stop()}}),r,this,[[0,168],[48,61,64,67]])})))}},{key:"addHandler",value:function(e,t){this._openChannelHandlers.set(e,t)}},{key:"removeHandler",value:function(e){this._openChannelHandlers.delete(e)}},{key:"clearHandler",value:function(){this._openChannelHandlers.clear()}},{key:"getChannel",value:function(e){return b(this,void 0,void 0,t().mark((function n(){var r;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return Ya(L("string",e)).throw(A.invalidParameters),t.prev=1,t.next=4,this.getChannelFromCache(e);case 4:if(!(r=t.sent)){t.next=7;break}return t.abrupt("return",r);case 7:t.next=11;break;case 9:t.prev=9,t.t0=t.catch(1);case 11:return t.next=13,this.getChannelWithoutCache(e);case 13:return t.abrupt("return",t.sent);case 14:case"end":return t.stop()}}),n,this,[[1,9]])})))}},{key:"getChannelWithoutCache",value:function(e){var n=arguments.length>1&&void 0!==arguments[1]&&arguments[1];return b(this,void 0,void 0,t().mark((function r(){var a,s,i,o;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return Ya(L("string",e)).throw(A.invalidParameters),a=new hv({channelUrl:e,isInternalCall:n}),t.next=4,this._requestQueue.send(a);case 4:return s=t.sent,i=s.as(dv),o=i.channel,t.next=8,this.upsertChannelsToCache([o]);case 8:return t.abrupt("return",t.sent[0]);case 9:case"end":return t.stop()}}),r,this)})))}},{key:"createChannel",value:function(e){return b(this,void 0,void 0,t().mark((function n(){var r,a,s,i,o;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return r=Object.assign(Object.assign({},cv),e),Ya(lv(r)).throw(A.invalidParameters),a=new fv(r),t.next=5,this._requestQueue.send(a);case 5:return s=t.sent,i=s.as(dv),o=i.channel,this.upsertChannelsToCache([o]),t.abrupt("return",o);case 9:case"end":return t.stop()}}),n,this)})))}}],[{key:"of",value:function(e){return gv[e]}}]),n}(),kv={name:null,coverUrlOrImage:null,data:null,customType:null,operatorUserIds:null},bv=function(e){return F("string",e.operatorUserIds,!0)&&(L("string",e.coverUrlOrImage)||q(e.coverUrlOrImage)||null===e.coverUrlOrImage)&&L("string",e.name,!0)&&L("string",e.data,!0)&&L("string",e.customType,!0)},Ev=function(e){i(n,e);var t=f(n);function n(e){var a;r(this,n);var s=e.channelUrl,i=e.token,o=e.limit;return(a=t.call(this)).method=ce.GET,a.path="".concat(ve,"/").concat(encodeURIComponent(s),"/participants"),a.params={token:i,limit:o},a}return s(n)}(Ae),wv=function(e){i(n,e);var t=f(n);function n(e,a){var s;r(this,n),(s=t.call(this,e,a)).token=null,s.participants=[];var i=a.next,o=a.participants;return s.token=i,s.participants=o.map((function(t){return new wl(e,t)})),s}return s(n)}(Oe),xv=function(n){i(u,n);var a=f(u);function u(t,n,s){return r(this,u),a.call(this,t,n,e.ChannelType.OPEN,s)}return s(u,[{key:"_validate",value:function(){return p(o(u.prototype),"_validate",this).call(this)}},{key:"next",value:function(){return b(this,void 0,void 0,t().mark((function e(){var n,r,a,s,i,o,u;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!this._validate()){e.next=20;break}if(this._isLoading){e.next=17;break}if(!this._hasNext){e.next=14;break}return this._isLoading=!0,n=ds.of(this._iid),r=n.requestQueue,a=new Ev(Object.assign(Object.assign({},this),{token:this._token})),e.next=8,r.send(a);case 8:return s=e.sent,i=s.as(wv),o=i.participants,u=i.token,this._token=u,this._hasNext=!!u,this._isLoading=!1,e.abrupt("return",o);case 14:return e.abrupt("return",[]);case 17:throw A.queryInProgress;case 18:e.next=21;break;case 20:throw A.invalidParameters;case 21:case"end":return e.stop()}}),e,this)})))}}]),u}(Ri),Cv=function(e){i(n,e);var t=f(n);function n(e){var a;r(this,n);var s=e.channelUrl,i=e.coverUrlOrImage,o=e.name,u=e.data,c=e.customType,l=e.operatorUserIds;return(a=t.call(this)).method=ce.PUT,a.path="".concat(ve,"/").concat(encodeURIComponent(s)),a.params=ue({cover_url:L("string",i)?i:null,cover_file:q(i)?i:null,name:o,data:u,custom_type:c,operators:l}),a}return s(n)}(Ae),Tv=function(e){i(n,e);var t=f(n);function n(e,a){var s;return r(this,n),(s=t.call(this,e,a)).channel=new Iv(e,a),s}return s(n)}(Oe),Sv=function(e){i(n,e);var t=f(n);function n(e){var a;r(this,n);var s=e.channelUrl;return(a=t.call(this)).method=ce.DELETE,a.path="".concat(ve,"/").concat(encodeURIComponent(s)),a}return s(n)}(Ae),Iv=function(n){i(u,n);var a=f(u);function u(t,n){var s,i;return r(this,u),(s=a.call(this,t,n))._lastParticipantCountUpdated=0,s.participantCount=0,s.operators=[],s.channelType=e.ChannelType.OPEN,s.participantCount=null!==(i=n.participant_count)&&void 0!==i?i:0,s.operators=Array.isArray(n.operators)?n.operators.map((function(e){return new Ja(t,e)})):[],s}return s(u,[{key:"serialize",value:function(){return Ka(this)}},{key:"isOperator",value:function(e){return e instanceof Ja?this.isOperator(e.userId):this.operators.some((function(t){return t.userId===e}))}},{key:"_updateParticipantCount",value:function(e,t){return t>this._lastParticipantCountUpdated&&(this.participantCount=e,this._lastParticipantCountUpdated=t,!0)}},{key:"createParticipantListQuery",value:function(e){return new xv(this._iid,this.url,e)}},{key:"refresh",value:function(){return b(this,void 0,void 0,t().mark((function e(){var n;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n=yv.of(this._iid),e.next=3,n.getChannelWithoutCache(this.url);case 3:return e.abrupt("return",e.sent);case 4:case"end":return e.stop()}}),e,this)})))}},{key:"enter",value:function(){return b(this,void 0,void 0,t().mark((function e(){var n,r,a,s,i,o,u;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n=ds.of(this._iid),r=n.requestQueue,a=new pv({channelUrl:this.url}),e.next=4,r.send(a);case 4:s=e.sent,i=s.as(vv),o=i.participantCount,u=i.ts,this._updateParticipantCount(o,u),yv.of(this._iid).setEnteredToCache(this);case 9:case"end":return e.stop()}}),e,this)})))}},{key:"exit",value:function(){return b(this,void 0,void 0,t().mark((function e(){var n,r,a,s,i,o,u;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n=ds.of(this._iid),r=n.requestQueue,a=new _v({channelUrl:this.url}),e.next=4,r.send(a);case 4:s=e.sent,i=s.as(mv),o=i.participantCount,u=i.ts,this._updateParticipantCount(o,u),yv.of(this._iid).setExitedToCache(this),Ei.of(this._iid).fileMessageQueue.cancel(this);case 11:case"end":return e.stop()}}),e,this)})))}},{key:"updateChannel",value:function(e){return b(this,void 0,void 0,t().mark((function n(){var r,a,s,i,o,u,c,l;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return r=Object.assign(Object.assign({},kv),e),Ya(bv(r)).throw(A.invalidParameters),a=ds.of(this._iid),s=a.requestQueue,i=new Cv(Object.assign({channelUrl:this.url},r)),t.next=6,s.send(i);case 6:return o=t.sent,u=o.as(Tv),c=u.channel,this._update(c),l=yv.of(this._iid),t.next=12,l.upsertChannelsToCache([c]);case 12:return t.abrupt("return",this);case 13:case"end":return t.stop()}}),n,this)})))}},{key:"updateChannelWithOperatorUserIds",value:function(e,n,r,a,s){return b(this,void 0,void 0,t().mark((function i(){var o;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return o=Object.assign(Object.assign({},kv),{name:e,coverUrlOrImage:n,data:r,operatorUserIds:a,customType:s}),t.abrupt("return",this.updateChannel(o));case 2:case"end":return t.stop()}}),i,this)})))}},{key:"delete",value:function(){return b(this,void 0,void 0,t().mark((function e(){var n,r,a,s;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n=ds.of(this._iid),r=n.requestQueue,a=new Sv({channelUrl:this.url}),e.next=4,r.send(a);case 4:return s=yv.of(this._iid),e.next=7,s.removeChannelsFromCache([this.url]);case 7:case"end":return e.stop()}}),e,this)})))}},{key:"sendUserMessage",value:function(e){return Ya(!e.isPinnedMessage).throw(A.notSupportedError),p(o(u.prototype),"sendUserMessage",this).call(this,e)}},{key:"sendFileMessage",value:function(e){return Ya(!e.isPinnedMessage).throw(A.notSupportedError),p(o(u.prototype),"sendFileMessage",this).call(this,e)}}],[{key:"payloadify",value:function(e){return e?ue(Object.assign(Object.assign({},ed.payloadify(e)),{participant_count:e.participantCount,operators:e.operators.map((function(e){return Ja.payloadify(e)}))})):null}}]),u}(ed),Nv=function(e){i(n,e);var t=f(n);function n(){var e;return r(this,n),(e=t.apply(this,arguments)).onUserEntered=qe,e.onUserExited=qe,e.onChannelParticipantCountChanged=qe,e.onPollUpdated=qe,e.onPollVoted=qe,e.onPollDeleted=qe,e}return s(n)}(tv),Mv=function(e){i(n,e);var t=f(n);function n(){var e,a=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return r(this,n),e=t.call(this),Object.keys(a).forEach((function(t){e.hasOwnProperty(t)&&(e[t]=a[t])})),e}return s(n)}(Nv),Av=function(e){i(n,e);var t=f(n);function n(e){var a;r(this,n);var s=e.token,i=e.limit,o=e.nameKeyword,u=e.urlKeyword,c=e.customTypes,l=e.includeFrozen,h=e.includeMetaData;return(a=t.call(this)).method=ce.GET,a.path=ve,a.params=ue({token:s,limit:i,name_contains:o,url_contains:u,custom_types:c,show_frozen:l,show_metadata:h}),a}return s(n)}(Ae),Ov=function(e){i(n,e);var t=f(n);function n(e,a){var s;r(this,n),(s=t.call(this,e,a)).token=null,s.channels=[],s.ts=null;var i=a.next,o=a.channels,u=a.ts;return s.token=i,o&&o.length>0&&(s.channels=o.map((function(t){return new Iv(e,t)}))),s.ts="number"==typeof u?u:null,s}return s(n)}(Oe),Uv=function(e){i(a,e);var n=f(a);function a(e,t){var s,i,o,u,c,l;return r(this,a),(s=n.call(this,e,t)).includeFrozen=!0,s.includeMetaData=!0,s.nameKeyword=null,s.urlKeyword=null,s.customTypes=null,s.includeFrozen=null===(i=t.includeFrozen)||void 0===i||i,s.includeMetaData=null===(o=t.includeMetaData)||void 0===o||o,s.nameKeyword=null!==(u=t.nameKeyword)&&void 0!==u?u:null,s.urlKeyword=null!==(c=t.urlKeyword)&&void 0!==c?c:null,s.customTypes=null!==(l=t.customTypes)&&void 0!==l?l:null,s}return s(a,[{key:"_validate",value:function(){return p(o(a.prototype),"_validate",this).call(this)&&L("boolean",this.includeFrozen)&&L("boolean",this.includeMetaData)&&L("string",this.nameKeyword,!0)&&L("string",this.urlKeyword,!0)&&F("string",this.customTypes,!0)}},{key:"next",value:function(){return b(this,void 0,void 0,t().mark((function e(){var n,r,a,s,i,o,u,c;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!this._validate()){e.next=23;break}if(this._isLoading){e.next=20;break}if(!this._hasNext){e.next=17;break}return this._isLoading=!0,n=ds.of(this._iid),r=n.requestQueue,a=new Av(Object.assign(Object.assign({},this),{token:this._token})),e.next=8,r.send(a);case 8:return s=e.sent,i=s.as(Ov),o=i.channels,u=i.token,this._token=u,this._hasNext=!!u,c=yv.of(this._iid),e.next=15,c.upsertChannelsToCache(o);case 15:return this._isLoading=!1,e.abrupt("return",o);case 17:return e.abrupt("return",[]);case 20:throw A.queryInProgress;case 21:e.next=24;break;case 23:throw A.invalidParameters;case 24:case"end":return e.stop()}}),e,this)})))}}]),a}(Si),Rv=function(e){i(a,e);var n=f(a);function a(){var e;return r(this,a),(e=n.apply(this,arguments)).name="openChannel",e}return s(a,[{key:"init",value:function(e,t){var n=t.sdkState,r=t.dispatcher,s=t.sessionManager,i=t.requestQueue,u=t.logger,c=t.onlineDetector,l=t.cacheContext;p(o(a.prototype),"init",this).call(this,e,{sdkState:n,dispatcher:r,sessionManager:s,requestQueue:i,logger:u,onlineDetector:c,cacheContext:l}),this._manager=new yv(e,{sdkState:n,dispatcher:r,requestQueue:i})}},{key:"createOpenChannelListQuery",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return new Uv(this._iid,e)}},{key:"addOpenChannelHandler",value:function(e,t){this._manager.addHandler(e,t)}},{key:"removeOpenChannelHandler",value:function(e){this._manager.removeHandler(e)}},{key:"removeAllOpenChannelHandlers",value:function(){this._manager.clearHandler()}},{key:"buildOpenChannelFromSerializedData",value:function(e){return this._manager.buildOpenChannelFromSerializedData(e)}},{key:"getChannel",value:function(e){return b(this,void 0,void 0,t().mark((function n(){return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.abrupt("return",this._manager.getChannel(e));case 1:case"end":return t.stop()}}),n,this)})))}},{key:"getChannelWithoutCache",value:function(e){return b(this,void 0,void 0,t().mark((function n(){return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.abrupt("return",this._manager.getChannelWithoutCache(e));case 1:case"end":return t.stop()}}),n,this)})))}},{key:"createChannel",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return b(this,void 0,void 0,t().mark((function n(){return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.abrupt("return",this._manager.createChannel(e));case 1:case"end":return t.stop()}}),n,this)})))}},{key:"createChannelWithOperatorUserIds",value:function(e,n,r,a,s){return b(this,void 0,void 0,t().mark((function i(){var o;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return(o=Object.assign({},cv)).name=e,o.coverUrlOrImage=n,o.data=r,o.operatorUserIds=a,o.customType=s,t.abrupt("return",this._manager.createChannel(o));case 7:case"end":return t.stop()}}),i,this)})))}}]),a}(fs);$p=function(){function e(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function t(e,t){for(var n=0;n-1};function qv(e){if("string"!=typeof e&&(e=String(e)),/[^a-z0-9\-#$%&'*+.^_`|~!]/i.test(e)||""===e)throw new TypeError('Invalid character in header field name: "'+e+'"');return e.toLowerCase()}function Hv(e){return"string"!=typeof e&&(e=String(e)),e}function jv(e){var t={next:function(){var t=e.shift();return{done:void 0===t,value:t}}};return Pv.iterable&&(t[Symbol.iterator]=function(){return t}),t}function zv(e){this.map={},e instanceof zv?e.forEach((function(e,t){this.append(t,e)}),this):Array.isArray(e)?e.forEach((function(e){this.append(e[0],e[1])}),this):e&&Object.getOwnPropertyNames(e).forEach((function(t){this.append(t,e[t])}),this)}function Vv(e){if(e.bodyUsed)return Promise.reject(new TypeError("Already read"));e.bodyUsed=!0}function Bv(e){return new Promise((function(t,n){e.onload=function(){t(e.result)},e.onerror=function(){n(e.error)}}))}function Qv(e){var t=new FileReader,n=Bv(t);return t.readAsArrayBuffer(e),n}function Kv(e){if(e.slice)return e.slice(0);var t=new Uint8Array(e.byteLength);return t.set(new Uint8Array(e)),t.buffer}function Wv(){return this.bodyUsed=!1,this._initBody=function(e){var t;this.bodyUsed=this.bodyUsed,this._bodyInit=e,e?"string"==typeof e?this._bodyText=e:Pv.blob&&Blob.prototype.isPrototypeOf(e)?this._bodyBlob=e:Pv.formData&&FormData.prototype.isPrototypeOf(e)?this._bodyFormData=e:Pv.searchParams&&URLSearchParams.prototype.isPrototypeOf(e)?this._bodyText=e.toString():Pv.arrayBuffer&&Pv.blob&&((t=e)&&DataView.prototype.isPrototypeOf(t))?(this._bodyArrayBuffer=Kv(e.buffer),this._bodyInit=new Blob([this._bodyArrayBuffer])):Pv.arrayBuffer&&(ArrayBuffer.prototype.isPrototypeOf(e)||Gv(e))?this._bodyArrayBuffer=Kv(e):this._bodyText=e=Object.prototype.toString.call(e):this._bodyText="",this.headers.get("content-type")||("string"==typeof e?this.headers.set("content-type","text/plain;charset=UTF-8"):this._bodyBlob&&this._bodyBlob.type?this.headers.set("content-type",this._bodyBlob.type):Pv.searchParams&&URLSearchParams.prototype.isPrototypeOf(e)&&this.headers.set("content-type","application/x-www-form-urlencoded;charset=UTF-8"))},Pv.blob&&(this.blob=function(){var e=Vv(this);if(e)return e;if(this._bodyBlob)return Promise.resolve(this._bodyBlob);if(this._bodyArrayBuffer)return Promise.resolve(new Blob([this._bodyArrayBuffer]));if(this._bodyFormData)throw new Error("could not read FormData body as blob");return Promise.resolve(new Blob([this._bodyText]))},this.arrayBuffer=function(){if(this._bodyArrayBuffer){var e=Vv(this);return e||(ArrayBuffer.isView(this._bodyArrayBuffer)?Promise.resolve(this._bodyArrayBuffer.buffer.slice(this._bodyArrayBuffer.byteOffset,this._bodyArrayBuffer.byteOffset+this._bodyArrayBuffer.byteLength)):Promise.resolve(this._bodyArrayBuffer))}return this.blob().then(Qv)}),this.text=function(){var e,t,n,r=Vv(this);if(r)return r;if(this._bodyBlob)return e=this._bodyBlob,t=new FileReader,n=Bv(t),t.readAsText(e),n;if(this._bodyArrayBuffer)return Promise.resolve(function(e){for(var t=new Uint8Array(e),n=new Array(t.length),r=0;r-1?r:n),this.mode=t.mode||this.mode||null,this.signal=t.signal||this.signal,this.referrer=null,("GET"===this.method||"HEAD"===this.method)&&a)throw new TypeError("Body not allowed for GET or HEAD requests");if(this._initBody(a),!("GET"!==this.method&&"HEAD"!==this.method||"no-store"!==t.cache&&"no-cache"!==t.cache)){var s=/([?&])_=[^&]*/;if(s.test(this.url))this.url=this.url.replace(s,"$1_="+(new Date).getTime());else{this.url+=(/\?/.test(this.url)?"&":"?")+"_="+(new Date).getTime()}}}function Jv(e){var t=new FormData;return e.trim().split("&").forEach((function(e){if(e){var n=e.split("="),r=n.shift().replace(/\+/g," "),a=n.join("=").replace(/\+/g," ");t.append(decodeURIComponent(r),decodeURIComponent(a))}})),t}function Xv(e,t){if(!(this instanceof Xv))throw new TypeError('Please use the "new" operator, this DOM object constructor cannot be called as a function.');t||(t={}),this.type="default",this.status=void 0===t.status?200:t.status,this.ok=this.status>=200&&this.status<300,this.statusText=void 0===t.statusText?"":""+t.statusText,this.headers=new zv(t.headers),this.url=t.url||"",this._initBody(e)}Zv.prototype.clone=function(){return new Zv(this,{body:this._bodyInit})},Wv.call(Zv.prototype),Wv.call(Xv.prototype),Xv.prototype.clone=function(){return new Xv(this._bodyInit,{status:this.status,statusText:this.statusText,headers:new zv(this.headers),url:this.url})},Xv.error=function(){var e=new Xv(null,{status:0,statusText:""});return e.type="error",e};var $v=[301,302,303,307,308];Xv.redirect=function(e,t){if(-1===$v.indexOf(t))throw new RangeError("Invalid status code");return new Xv(null,{status:t,headers:{location:e}})};var e_=Dv.DOMException;try{new e_}catch(an){(e_=function(e,t){this.message=e,this.name=t;var n=Error(e);this.stack=n.stack}).prototype=Object.create(Error.prototype),e_.prototype.constructor=e_}function t_(e,t){return new Promise((function(r,a){var s=new Zv(e,t);if(s.signal&&s.signal.aborted)return a(new e_("Aborted","AbortError"));var i=new XMLHttpRequest;function o(){i.abort()}i.onload=function(){var e,t,n={status:i.status,statusText:i.statusText,headers:(e=i.getAllResponseHeaders()||"",t=new zv,e.replace(/\r?\n[\t ]+/g," ").split("\r").map((function(e){return 0===e.indexOf("\n")?e.substr(1,e.length):e})).forEach((function(e){var n=e.split(":"),r=n.shift().trim();if(r){var a=n.join(":").trim();t.append(r,a)}})),t)};n.url="responseURL"in i?i.responseURL:n.headers.get("X-Request-URL");var a="response"in i?i.response:i.responseText;setTimeout((function(){r(new Xv(a,n))}),0)},i.onerror=function(){setTimeout((function(){a(new TypeError("Network request failed"))}),0)},i.ontimeout=function(){setTimeout((function(){a(new TypeError("Network request failed"))}),0)},i.onabort=function(){setTimeout((function(){a(new e_("Aborted","AbortError"))}),0)},i.open(s.method,function(e){try{return""===e&&Dv.location.href?Dv.location.href:e}catch(t){return e}}(s.url),!0),"include"===s.credentials?i.withCredentials=!0:"omit"===s.credentials&&(i.withCredentials=!1),"responseType"in i&&(Pv.blob?i.responseType="blob":Pv.arrayBuffer&&s.headers.get("Content-Type")&&-1!==s.headers.get("Content-Type").indexOf("application/octet-stream")&&(i.responseType="arraybuffer")),!t||"object"!==n(t.headers)||t.headers instanceof zv?s.headers.forEach((function(e,t){i.setRequestHeader(t,e)})):Object.getOwnPropertyNames(t.headers).forEach((function(e){i.setRequestHeader(e,Hv(t.headers[e]))})),s.signal&&(s.signal.addEventListener("abort",o),i.onreadystatechange=function(){4===i.readyState&&s.signal.removeEventListener("abort",o)}),i.send(void 0===s._bodyInit?null:s._bodyInit)}))}t_.polyfill=!0,Dv.fetch||(Dv.fetch=t_,Dv.Headers=zv,Dv.Request=Zv,Dv.Response=Xv);var n_=Object.freeze({__proto__:null});return e.AdminMessage=Us,e.AppleCriticalAlertOptions=xs,e.ApplicationUserListQuery=mc,e.BannedUserListQuery=Fl,e.BaseChannel=ed,e.BaseMessage=Is,e.BlockedUserListQuery=kc,e.CachedChannelInfo=ee,e.ConnectionHandler=vo,e.Emoji=ac,e.EmojiCategory=sc,e.EmojiContainer=ic,e.FileMessage=Bs,e.FriendListQuery=wc,e.GroupChannel=Bp,e.GroupChannelCollection=Zp,e.GroupChannelEventContext=Df,e.GroupChannelFilter=pd,e.GroupChannelHandler=rv,e.GroupChannelListQuery=Mf,e.GroupChannelModule=ov,e.LocalCacheConfig=te,e.Member=hd,e.MemberListQuery=pp,e.MemoryStore=cl,e.MessageCollection=ap,e.MessageCollectionInitHandler=rp,e.MessageEventContext=Pf,e.MessageFilter=Eo,e.MessageMetaArray=bs,e.MessageModule=Gi,e.MessageRequestHandler=wi,e.MessageSearchQuery=Ui,e.MultipleFilesMessage=js,e.MultipleFilesMessageRequestHandler=Fi,e.MutedUserListQuery=Ll,e.OGImage=Es,e.OGMetaData=ws,e.OpenChannel=Iv,e.OpenChannelHandler=Mv,e.OpenChannelListQuery=Uv,e.OpenChannelModule=Rv,e.OperatorListQuery=Ol,e.Participant=wl,e.ParticipantListQuery=xv,e.PinnedMessage=qp,e.PinnedMessageListQuery=zp,e.Plugin=Rs,e.PreviousMessageListQuery=Li,e.PublicGroupChannelListQuery=ev,e.Reaction=ks,e.ReactionEvent=ys,e.ReadStatus=dd,e.RestrictedUser=El,e.RestrictionInfo=bl,e.ScheduledMessageListQuery=iv,e.SendbirdChat=nd,e.SendbirdChatOptions=H,e.SendbirdError=A,e.Sender=Cs,e.SessionHandler=po,e.ThreadInfo=_s,e.ThreadInfoUpdateEvent=xi,e.Thumbnail=Ms,e.UIKitConfigInfo=Pa,e.UploadedFileInfo=Hs,e.User=Ja,e.UserEventHandler=_o,e.UserMessage=qs,Object.defineProperty(e,"__esModule",{value:!0}),e}({}); +var Sendbird=function(e){"use strict";function t(){t=function(){return e};var e={},n=Object.prototype,r=n.hasOwnProperty,a=Object.defineProperty||function(e,t,n){e[t]=n.value},s="function"==typeof Symbol?Symbol:{},i=s.iterator||"@@iterator",o=s.asyncIterator||"@@asyncIterator",u=s.toStringTag||"@@toStringTag";function c(e,t,n){return Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}),e[t]}try{c({},"")}catch(e){c=function(e,t,n){return e[t]=n}}function l(e,t,n,r){var s=t&&t.prototype instanceof f?t:f,i=Object.create(s.prototype),o=new T(r||[]);return a(i,"_invoke",{value:E(e,n,o)}),i}function h(e,t,n){try{return{type:"normal",arg:e.call(t,n)}}catch(e){return{type:"throw",arg:e}}}e.wrap=l;var d={};function f(){}function p(){}function v(){}var _={};c(_,i,(function(){return this}));var m=Object.getPrototypeOf,g=m&&m(m(S([])));g&&g!==n&&r.call(g,i)&&(_=g);var y=v.prototype=f.prototype=Object.create(_);function k(e){["next","throw","return"].forEach((function(t){c(e,t,(function(e){return this._invoke(t,e)}))}))}function b(e,t){function n(a,s,i,o){var u=h(e[a],e,s);if("throw"!==u.type){var c=u.arg,l=c.value;return l&&"object"==typeof l&&r.call(l,"__await")?t.resolve(l.__await).then((function(e){n("next",e,i,o)}),(function(e){n("throw",e,i,o)})):t.resolve(l).then((function(e){c.value=e,i(c)}),(function(e){return n("throw",e,i,o)}))}o(u.arg)}var s;a(this,"_invoke",{value:function(e,r){function a(){return new t((function(t,a){n(e,r,t,a)}))}return s=s?s.then(a,a):a()}})}function E(e,t,n){var r="suspendedStart";return function(a,s){if("executing"===r)throw new Error("Generator is already running");if("completed"===r){if("throw"===a)throw s;return I()}for(n.method=a,n.arg=s;;){var i=n.delegate;if(i){var o=w(i,n);if(o){if(o===d)continue;return o}}if("next"===n.method)n.sent=n._sent=n.arg;else if("throw"===n.method){if("suspendedStart"===r)throw r="completed",n.arg;n.dispatchException(n.arg)}else"return"===n.method&&n.abrupt("return",n.arg);r="executing";var u=h(e,t,n);if("normal"===u.type){if(r=n.done?"completed":"suspendedYield",u.arg===d)continue;return{value:u.arg,done:n.done}}"throw"===u.type&&(r="completed",n.method="throw",n.arg=u.arg)}}}function w(e,t){var n=t.method,r=e.iterator[n];if(void 0===r)return t.delegate=null,"throw"===n&&e.iterator.return&&(t.method="return",t.arg=void 0,w(e,t),"throw"===t.method)||"return"!==n&&(t.method="throw",t.arg=new TypeError("The iterator does not provide a '"+n+"' method")),d;var a=h(r,e.iterator,t.arg);if("throw"===a.type)return t.method="throw",t.arg=a.arg,t.delegate=null,d;var s=a.arg;return s?s.done?(t[e.resultName]=s.value,t.next=e.nextLoc,"return"!==t.method&&(t.method="next",t.arg=void 0),t.delegate=null,d):s:(t.method="throw",t.arg=new TypeError("iterator result is not an object"),t.delegate=null,d)}function C(e){var t={tryLoc:e[0]};1 in e&&(t.catchLoc=e[1]),2 in e&&(t.finallyLoc=e[2],t.afterLoc=e[3]),this.tryEntries.push(t)}function x(e){var t=e.completion||{};t.type="normal",delete t.arg,e.completion=t}function T(e){this.tryEntries=[{tryLoc:"root"}],e.forEach(C,this),this.reset(!0)}function S(e){if(e){var t=e[i];if(t)return t.call(e);if("function"==typeof e.next)return e;if(!isNaN(e.length)){var n=-1,a=function t(){for(;++n=0;--a){var s=this.tryEntries[a],i=s.completion;if("root"===s.tryLoc)return n("end");if(s.tryLoc<=this.prev){var o=r.call(s,"catchLoc"),u=r.call(s,"finallyLoc");if(o&&u){if(this.prev=0;--n){var a=this.tryEntries[n];if(a.tryLoc<=this.prev&&r.call(a,"finallyLoc")&&this.prev=0;--t){var n=this.tryEntries[t];if(n.finallyLoc===e)return this.complete(n.completion,n.afterLoc),x(n),d}},catch:function(e){for(var t=this.tryEntries.length-1;t>=0;--t){var n=this.tryEntries[t];if(n.tryLoc===e){var r=n.completion;if("throw"===r.type){var a=r.arg;x(n)}return a}}throw new Error("illegal catch attempt")},delegateYield:function(e,t,n){return this.delegate={iterator:S(e),resultName:t,nextLoc:n},"next"===this.method&&(this.arg=void 0),d}},e}function n(e){return n="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},n(e)}function r(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function a(e,t){for(var n=0;ne.length)&&(t=e.length);for(var n=0,r=new Array(t);n=e.length?{done:!0}:{done:!1,value:e[r++]}},e:function(e){throw e},f:a}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var s,i=!0,o=!1;return{s:function(){n=n.call(e)},n:function(){var e=n.next();return i=e.done,e},e:function(e){o=!0,s=e},f:function(){try{i||null==n.return||n.return()}finally{if(o)throw s}}}}function k(e){var t=function(e,t){if("object"!=typeof e||null===e)return e;var n=e[Symbol.toPrimitive];if(void 0!==n){var r=n.call(e,t||"default");if("object"!=typeof r)return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(e,"string");return"symbol"==typeof t?t:String(t)}function b(e,t,n,r){return new(n||(n=Promise))((function(a,s){function i(e){try{u(r.next(e))}catch(e){s(e)}}function o(e){try{u(r.throw(e))}catch(e){s(e)}}function u(e){var t;e.done?a(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(i,o)}u((r=r.apply(e,t||[])).next())}))}var E,w="4.9.3",C=function(){function e(){r(this,e)}return s(e,null,[{key:"OS_VERSION",get:function(){return"undefined"!=typeof navigator&&navigator.userAgent?navigator.userAgent.replace(/,/g,"."):"noAgent"}},{key:"SDK_VERSION",get:function(){return w}},{key:"SDK_MAJOR_VERSION",get:function(){return e.SDK_VERSION.split(".")[0]}},{key:"DEFAULT_MAX_UNREAD_COUNT_OF_SUPER_GROUP_CHANNEL",get:function(){return 100}},{key:"INTERNAL_CALL",get:function(){return"ic"}}]),e}();!function(e){e[e.STAT_LOG_NOT_ALLOWED=400108]="STAT_LOG_NOT_ALLOWED",e[e.NON_AUTHORIZED=400108]="NON_AUTHORIZED",e[e.INVALID_TOKEN=400111]="INVALID_TOKEN",e[e.NOT_FOUND_IN_DATABASE=400201]="NOT_FOUND_IN_DATABASE",e[e.SESSION_TOKEN_EXPIRED=400302]="SESSION_TOKEN_EXPIRED",e[e.SESSION_KEY_EXPIRED=400309]="SESSION_KEY_EXPIRED",e[e.SESSION_REVOKED=400310]="SESSION_REVOKED",e[e.STAT_UPLOAD_NOT_ALLOWED=403200]="STAT_UPLOAD_NOT_ALLOWED",e[e.INTERNAL_SERVER_ERROR=500901]="INTERNAL_SERVER_ERROR",e[e.RATE_LIMIT_EXCEEDED=500910]="RATE_LIMIT_EXCEEDED",e[e.UNKNOWN_SERVER_ERROR=900200]="UNKNOWN_SERVER_ERROR",e[e.DEBUG_MODE_REQUIRED=7e5]="DEBUG_MODE_REQUIRED",e[e.LOST_INSTANCE=700100]="LOST_INSTANCE",e[e.CONNECTION_RENEW=700102]="CONNECTION_RENEW",e[e.INVALID_CONNECTION_STATE_TRANSITION=700200]="INVALID_CONNECTION_STATE_TRANSITION",e[e.INVALID_COMMAND=700700]="INVALID_COMMAND",e[e.UNKNOWN_ERROR=77e4]="UNKNOWN_ERROR",e[e.INVALID_INITIALIZATION=800100]="INVALID_INITIALIZATION",e[e.CONNECTION_REQUIRED=800101]="CONNECTION_REQUIRED",e[e.CONNECTION_CANCELED=800102]="CONNECTION_CANCELED",e[e.INVALID_PARAMETER=800110]="INVALID_PARAMETER",e[e.NOT_SUPPORTED_ERROR=800111]="NOT_SUPPORTED_ERROR",e[e.NETWORK_ERROR=800120]="NETWORK_ERROR",e[e.NETWORK_ROUTING_ERROR=800121]="NETWORK_ROUTING_ERROR",e[e.MALFORMED_DATA=800130]="MALFORMED_DATA",e[e.MALFORMED_ERROR_DATA=800140]="MALFORMED_ERROR_DATA",e[e.WRONG_CHANNEL_TYPE=800150]="WRONG_CHANNEL_TYPE",e[e.MARK_AS_READ_RATE_LIMIT_EXCEEDED=800160]="MARK_AS_READ_RATE_LIMIT_EXCEEDED",e[e.QUERY_IN_PROGRESS=800170]="QUERY_IN_PROGRESS",e[e.ACK_TIMEOUT=800180]="ACK_TIMEOUT",e[e.LOGIN_TIMEOUT=800190]="LOGIN_TIMEOUT",e[e.WEBSOCKET_CONNECTION_CLOSED=800200]="WEBSOCKET_CONNECTION_CLOSED",e[e.WEBSOCKET_CONNECTION_FAILED=800210]="WEBSOCKET_CONNECTION_FAILED",e[e.REQUEST_FAILED=800220]="REQUEST_FAILED",e[e.FILE_UPLOAD_CANCEL_FAILED=800230]="FILE_UPLOAD_CANCEL_FAILED",e[e.REQUEST_CANCELED=800240]="REQUEST_CANCELED",e[e.REQUEST_DUPLICATED=800250]="REQUEST_DUPLICATED",e[e.FILE_SIZE_LIMIT_EXCEEDED=800260]="FILE_SIZE_LIMIT_EXCEEDED",e[e.SESSION_TOKEN_REQUEST_FAILED=800500]="SESSION_TOKEN_REQUEST_FAILED",e[e.SESSION_TOKEN_REFRESHED=800501]="SESSION_TOKEN_REFRESHED",e[e.SESSION_TOKEN_REFRESH_FAILED=800502]="SESSION_TOKEN_REFRESH_FAILED",e[e.COLLECTION_DISPOSED=800600]="COLLECTION_DISPOSED",e[e.DATABASE_ERROR=800700]="DATABASE_ERROR"}(E||(E={}));var x,T,S,I,N,M=function(e){return!(e instanceof A&&!e.shouldThrowOutside)},A=function(e){i(n,e);var t=f(n);function n(e){var a,s=e.code,i=void 0===s?0:s,o=e.message,u=void 0===o?"":o;return r(this,n),(a=t.call(this,u)).shouldThrowOutside=!1,a.name="SendbirdError",a.code=i,Object.setPrototypeOf(d(a),n.prototype),a}return s(n,[{key:"isInvalidTokenError",get:function(){return this.code===E.INVALID_TOKEN}},{key:"isSessionTokenExpiredError",get:function(){return this.code===E.SESSION_TOKEN_EXPIRED}},{key:"isSessionKeyExpiredError",get:function(){return this.code===E.SESSION_KEY_EXPIRED}},{key:"isSessionRevokedError",get:function(){return this.code===E.SESSION_REVOKED}},{key:"throwOutside",value:function(){throw this.shouldThrowOutside=!0,this}}],[{key:"debugModeRequired",get:function(){return new n({code:E.DEBUG_MODE_REQUIRED,message:"Cannot run this operation in production mode."})}},{key:"lostInstance",get:function(){return new n({code:E.LOST_INSTANCE,message:"Instance ID is missing. It should belong to an instance."})}},{key:"invalidCommand",get:function(){return new n({code:E.INVALID_COMMAND,message:"Cannot send invalid command."})}},{key:"unknown",get:function(){return new n({code:E.UNKNOWN_ERROR,message:"Unknown error occurred."})}},{key:"connectionRenew",get:function(){return new n({code:E.CONNECTION_RENEW,message:"Connection restarts."})}},{key:"invalidConnectionStateTransition",get:function(){return new n({code:E.INVALID_CONNECTION_STATE_TRANSITION,message:"Invalid connection state transition."})}},{key:"connectionRequired",get:function(){return new n({code:E.CONNECTION_REQUIRED,message:"Connection is required."})}},{key:"connectionCanceled",get:function(){return new n({code:E.CONNECTION_CANCELED,message:"Connection is canceled."})}},{key:"invalidParameters",get:function(){return new n({code:E.INVALID_PARAMETER,message:"Invalid parameters."})}},{key:"notSupportedError",get:function(){return new n({code:E.NOT_SUPPORTED_ERROR,message:"Given parameters are not supported."})}},{key:"networkError",get:function(){return new n({code:E.NETWORK_ERROR,message:"There was a network error."})}},{key:"markAsReadAllRateLimitExceeded",get:function(){return new n({code:E.MARK_AS_READ_RATE_LIMIT_EXCEEDED,message:"markAsRead rate limit exceeded."})}},{key:"queryInProgress",get:function(){return new n({code:E.QUERY_IN_PROGRESS,message:"Query in progress."})}},{key:"noAckTimeout",get:function(){return new n({code:E.ACK_TIMEOUT,message:"Command received no ack."})}},{key:"loginTimeout",get:function(){return new n({code:E.LOGIN_TIMEOUT,message:"Connection timeout."})}},{key:"connectionClosed",get:function(){return new n({code:E.WEBSOCKET_CONNECTION_CLOSED,message:"Connection is closed. Please reconnect."})}},{key:"requestFailed",get:function(){return new n({code:E.REQUEST_FAILED,message:"Request failed."})}},{key:"fileUploadCanceled",get:function(){return new n({code:E.FILE_UPLOAD_CANCEL_FAILED,message:"File upload has been canceled."})}},{key:"requestCanceled",get:function(){return new n({code:E.REQUEST_CANCELED,message:"Request has been canceled."})}},{key:"sessionTokenRefreshFailed",get:function(){return new n({code:E.SESSION_TOKEN_REFRESH_FAILED,message:"Failed to refresh the session key."})}},{key:"sessionTokenRequestFailed",get:function(){return new n({code:E.SESSION_TOKEN_REQUEST_FAILED,message:"Failed to get the session token."})}},{key:"databaseError",get:function(){return new n({code:E.DATABASE_ERROR,message:"Database error."})}},{key:"fileSizeLimitExceededError",get:function(){return new n({code:E.FILE_SIZE_LIMIT_EXCEEDED,message:"File size exceeds the file size limit."})}}]),n}(h(Error)),O=[E.CONNECTION_REQUIRED,E.NETWORK_ERROR,E.ACK_TIMEOUT,E.WEBSOCKET_CONNECTION_CLOSED,E.WEBSOCKET_CONNECTION_FAILED,E.FILE_UPLOAD_CANCEL_FAILED,E.REQUEST_CANCELED,E.INTERNAL_SERVER_ERROR,E.RATE_LIMIT_EXCEEDED,E.UNKNOWN_SERVER_ERROR],U=[E.WEBSOCKET_CONNECTION_CLOSED,E.WEBSOCKET_CONNECTION_FAILED,E.CONNECTION_REQUIRED],R=function(e,t){if(e!==t){var n=Object.assign({},e),r=Object.assign({},t);return(!n.hasOwnProperty("messageId")||!r.hasOwnProperty("messageId")||n.messageId===r.messageId)&&((!n.hasOwnProperty("reqId")||!r.hasOwnProperty("reqId")||n.reqId===r.reqId)&&(n.hasOwnProperty("messageId")&&delete n.messageId,n.hasOwnProperty("reqId")&&delete n.reqId,r.hasOwnProperty("messageId")&&delete r.messageId,r.hasOwnProperty("reqId")&&delete r.reqId,JSON.stringify(n)===JSON.stringify(r)))}return!0},L=function(e,t){return!(!(arguments.length>2&&void 0!==arguments[2]&&arguments[2])||null!=t)||("string"!=typeof e?"object"===n(e)?D(e,t):P(e,t):n(t)===e)},D=function(e,t){return!(!(arguments.length>2&&void 0!==arguments[2]&&arguments[2])||null!=t)||Object.values(e).includes(t)},P=function(e,t){return t instanceof e},F=function(e,t){return!(!(arguments.length>2&&void 0!==arguments[2]&&arguments[2])||null!=t)||Array.isArray(t)&&t.every((function(t){return L(e,t)}))},G=function(e){return e>0&&U.indexOf(e)>=0},q=function(e){if(arguments.length>1&&void 0!==arguments[1]&&arguments[1]&&null==e)return!0;var t="object"===n(e)&&null!==e&&e.hasOwnProperty("name")&&"string"==typeof e.name&&e.hasOwnProperty("uri")&&"string"==typeof e.uri&&e.hasOwnProperty("type")&&"string"==typeof e.type;if(!t){if("undefined"!=typeof Blob)return e instanceof Blob;if("undefined"!=typeof File)return e instanceof File}return t},H=function(){function e(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},n=t.useMemberInfoInMessage,a=void 0===n||n,s=t.typingIndicatorInvalidateTime,i=void 0===s?1e4:s,o=t.typingIndicatorThrottle,u=void 0===o?1e3:o,c=t.websocketResponseTimeout,l=void 0===c?1e4:c,h=t.websocketPayloadDecompression,d=void 0===h||h,f=t.sessionTokenRefreshTimeout,p=void 0===f?60:f;r(this,e),this._useMemberInfoInMessage=!0,this._typingIndicatorInvalidateTime=1e4,this._typingIndicatorThrottle=1e3,this._websocketResponseTimeout=1e4,this._sessionTokenRefreshTimeout=60,this._useMemberInfoInMessage=a,this._typingIndicatorInvalidateTime=i,this._typingIndicatorThrottle=u,this._websocketResponseTimeout=l,this._sessionTokenRefreshTimeout=p,this.websocketPayloadDecompression=d}return s(e,[{key:"useMemberInfoInMessage",get:function(){return this._useMemberInfoInMessage},set:function(e){L("boolean",e)&&(this._useMemberInfoInMessage=e)}},{key:"typingIndicatorInvalidateTime",get:function(){return this._typingIndicatorInvalidateTime},set:function(e){L("number",e)&&(this._typingIndicatorInvalidateTime=e)}},{key:"typingIndicatorThrottle",get:function(){return this._typingIndicatorThrottle},set:function(e){L("number",e)&&e>=1e3&&e<=9e3&&(this._typingIndicatorThrottle=e)}},{key:"websocketResponseTimeout",get:function(){return this._websocketResponseTimeout},set:function(e){L("number",e)&&e>=5e3&&e<=3e4&&(this._websocketResponseTimeout=e)}},{key:"sessionTokenRefreshTimeout",get:function(){return this._sessionTokenRefreshTimeout},set:function(e){L("number",e)&&(e<60?e=60:e>1800&&(e=1800),this._sessionTokenRefreshTimeout=e)}}]),e}(),j={encrypt:function(e){return e},decrypt:function(e){return e}},z=function(){function e(t){var n=t.store;r(this,e),this._preference=new Map,this._store=n}return s(e,[{key:"_savePreferenceKeys",value:function(){return b(this,void 0,void 0,t().mark((function e(){return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this._store.set({key:this._keysAddress,value:_(this._preference.keys())});case 2:case"end":return e.stop()}}),e,this)})))}},{key:"init",value:function(e){var n,r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:1;return b(this,void 0,void 0,t().mark((function a(){var s,i,o,u,c,l,h;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return this._version=r,this._keysAddress=e,s="".concat(e,".metadata.version"),t.next=5,this._store.get(s);case 5:return i=t.sent,t.next=8,this._store.get(e);case 8:if(t.t1=n=t.sent,t.t0=null!==t.t1,!t.t0){t.next=12;break}t.t0=void 0!==n;case 12:if(!t.t0){t.next=16;break}t.t2=n,t.next=17;break;case 16:t.t2=[];case 17:if(o=t.t2,i&&!(i.version0&&void 0!==arguments[0]?arguments[0]:{},n=t.maxSize,a=void 0===n?256:n,s=t.clearOrder,i=void 0===s?N.MESSAGE_COLLECTION_ACCESSED_AT:s,o=t.customClearOrderComparator;r(this,e),this._clearOrderComparatorUseMessageCollectionAccessedAt=function(e,t){return e.channel.messageCollectionLastAccessedAt===t.channel.messageCollectionLastAccessedAt?e.channel.lastMessage&&!t.channel.lastMessage?1:!e.channel.lastMessage&&t.channel.lastMessage?-1:e.channel.lastMessage||t.channel.lastMessage?e.channel.lastMessage.createdAt-t.channel.lastMessage.createdAt:0:e.channel.messageCollectionLastAccessedAt>t.channel.messageCollectionLastAccessedAt?1:-1},this._maxSize=Math.max(a,64),o?(this._clearOrder=i,this._customClearOrderComparator=o):this._clearOrder=N.MESSAGE_COLLECTION_ACCESSED_AT}return s(e,[{key:"maxSize",get:function(){return this._maxSize}},{key:"clearOrder",get:function(){return this._clearOrder}},{key:"clearOrderComparator",get:function(){var e;return this._clearOrder===N.MESSAGE_COLLECTION_ACCESSED_AT?this._clearOrderComparatorUseMessageCollectionAccessedAt:null!==(e=this._customClearOrderComparator)&&void 0!==e?e:this._clearOrderComparatorUseMessageCollectionAccessedAt}}]),e}(),ne=function(){function e(){r(this,e)}return s(e,[{key:"hasSession",get:function(){return!!this.sessionKey}},{key:"clear",value:function(){this.authToken=void 0,this.sessionKey=void 0}}]),e}(),re=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)}))},ae=function(){function e(t){var n=t.container;r(this,e),this._container={},this._container=n,this.key=re()}return s(e,[{key:"_register",value:function(e,t,n){var r;return e in this._container||(this._container[e]=new Map),null===(r=this._container[e])||void 0===r||r.set(this.key,{occurence:t,handler:n}),this}},{key:"on",value:function(e,t){return this._register(e,-1,t)}},{key:"once",value:function(e,t){return this._register(e,1,t)}},{key:"close",value:function(){var e;for(var t in this._container)null===(e=this._container[t])||void 0===e||e.delete(this.key)}}]),e}(),se=function(){function e(){r(this,e),this._container={}}return s(e,[{key:"on",value:function(e,t){return new ae({container:this._container}).on(e,t)}},{key:"once",value:function(e,t){return new ae({container:this._container}).once(e,t)}},{key:"dispatch",value:function(e,t){var n=this._container[e];if(n){var r,a=[],s=y(n.keys());try{for(s.s();!(r=s.n()).done;){var i=r.value,o=n.get(i);o.handler(t),o.occurence>0&&(o.occurence--,0===o.occurence&&a.push(i))}}catch(e){s.e(e)}finally{s.f()}a.forEach((function(e){return n.delete(e)}))}}}]),e}(),ie=function(){function e(){r(this,e),this._dispatcher=new se}return s(e,[{key:"on",value:function(e){return this._dispatcher.on("event",e)}},{key:"once",value:function(e){return this._dispatcher.once("event",e)}},{key:"dispatch",value:function(e){this._dispatcher.dispatch("event",e)}}]),e}(),oe=s((function e(){r(this,e)})),ue=function(e){var t={};return e&&Object.keys(e).forEach((function(n){void 0===e[n]||Number.isNaN(e[n])||null===e[n]||(t[n]=e[n])})),t},ce=function e(t){if(null!=t){if("object"===n(t)){if(Array.isArray(t)){var r=_(t);for(var a in r)r[a]=e(r[a]);return r}for(var s in t)null===t[s]&&delete t[s];return t}return t}};e.ChannelType=void 0,(B=e.ChannelType||(e.ChannelType={})).BASE="base",B.GROUP="group",B.OPEN="open",e.Role=void 0,(Q=e.Role||(e.Role={})).OPERATOR="operator",Q.NONE="none",e.MessageType=void 0,(K=e.MessageType||(e.MessageType={})).BASE="base",K.USER="user",K.FILE="file",K.ADMIN="admin",e.MessageTypeFilter=void 0,(W=e.MessageTypeFilter||(e.MessageTypeFilter={})).ALL="",W.USER="MESG",W.FILE="FILE",W.ADMIN="ADMM",function(e){e.USER="MESG",e.FILE="FILE",e.ADMIN="ADMM"}(Y||(Y={})),e.MentionType=void 0,(Z=e.MentionType||(e.MentionType={})).USERS="users",Z.CHANNEL="channel",e.ReplyType=void 0,(J=e.ReplyType||(e.ReplyType={})).ALL="all",J.NONE="none",J.ONLY_REPLY_TO_CHANNEL="only_reply_to_channel",e.PushNotificationDeliveryOption=void 0,(X=e.PushNotificationDeliveryOption||(e.PushNotificationDeliveryOption={})).DEFAULT="default",X.SUPPRESS="suppress",e.SendingStatus=void 0,($=e.SendingStatus||(e.SendingStatus={})).PENDING="pending",$.SCHEDULED="scheduled",$.SUCCEEDED="succeeded",$.FAILED="failed",$.CANCELED="canceled";var le,he="v3",de="/".concat(he,"/users"),fe="/".concat(he,"/storage/file"),pe="/".concat(he,"/group_channels"),ve="/".concat(he,"/sdk/group_channels"),_e="/".concat(he,"/open_channels"),me="/".concat(he,"/sdk/open_channels"),ge="/".concat(he,"/search"),ye="/".concat(he,"/report"),ke="/".concat(he,"/emojis"),be="/".concat(he,"/emoji_categories"),Ee="/".concat(he,"/polls"),we="/".concat(he,"/scheduled_messages"),Ce="/".concat(he,"/sdk/ui_kit/configuration"),xe="/".concat(he,"/sdk/statistics"),Te=function(t){switch(t){case e.ChannelType.GROUP:return pe;case e.ChannelType.OPEN:return _e;default:return null}},Se=function(t){switch(t){case e.ChannelType.GROUP:return"".concat(ye,"/group_channels");case e.ChannelType.OPEN:return"".concat(ye,"/open_channels");default:return null}},Ie=function(t,n,r){switch(t){case e.MentionType.CHANNEL:return!0;case e.MentionType.USERS:if(n){var a,s=y(n);try{for(s.s();!(a=s.n()).done;){if(a.value===r)return!0}}catch(e){s.e(e)}finally{s.f()}}}return!1},Ne=function(e,t,n){var r,a,s,i,o=Ie(null!==(r=e.mentionType)&&void 0!==r?r:null,null!==(a=e.mentionedUserIds)&&void 0!==a?a:[],n),u=Ie(null!==(s=t.mentionType)&&void 0!==s?s:null,null!==(i=t.mentionedUserIds)&&void 0!==i?i:[],n);return!o&&u?1:o&&!u?-1:0},Me=function e(t,r,a){var s,i=r||new FormData;for(var o in t)if(Object.prototype.hasOwnProperty.call(t,o)){var u=t[o],c=a?"".concat(a,"[").concat(o,"]"):o;q(u)?i.append(c,u,null!==(s=u.name)&&void 0!==s?s:"filename"):"object"!==n(u)||null===u||Array.isArray(u)||u instanceof Blob?i.append(c,String(u)):i=e(u,i,c)}return i};!function(e){e.GET="GET",e.POST="POST",e.PUT="PUT",e.DELETE="DELETE"}(le||(le={}));var Ae,Oe=function(e){i(a,e);var t=f(a);function a(){var e;return r(this,a),(e=t.apply(this,arguments)).params={},e.requireAuth=!0,e.headers={},e.requestId=re(),e}return s(a,[{key:"encodeParams",value:function(e){var t=this;return null==e||""===e?encodeURIComponent(""):Array.isArray(e)?e.map((function(e){return t.encodeParams(e)})).join(","):"object"===n(e)?encodeURIComponent(JSON.stringify(e)):encodeURIComponent(String(e))}},{key:"query",get:function(){var e=this,t=ue(this.params);return"?".concat(Object.keys(t).map((function(n){return"".concat(encodeURIComponent(n),"=").concat(e.encodeParams(t[n]))})).join("&"))}},{key:"payload",get:function(){var e=ue(this.params);return Object.keys(e).some((function(t){return q(e[t])}))?Me(e):JSON.stringify(e)}}]),a}(oe),Ue=function(e){i(n,e);var t=f(n);function n(e,a){var s;return r(this,n),(s=t.call(this))._iid=e,s._payload=a,s}return s(n,[{key:"payload",get:function(){return Object.assign({},this._payload)}},{key:"as",value:function(e){return new e(this._iid,this.payload)}}]),n}(oe),Re=function(e){i(n,e);var t=f(n);function n(e){var a;return r(this,n),(a=t.call(this)).requestId=e,a}return s(n)}(oe),Le=function(e){i(n,e);var t=f(n);function n(e){var a,s=e.expires_in,i=e.reason,o=void 0===i?E.SESSION_KEY_EXPIRED:i;switch(r(this,n),(a=t.call(this)).expiresIn=null!=s?s:0,o){case E.SESSION_KEY_EXPIRED:case E.SESSION_TOKEN_EXPIRED:case E.SESSION_REVOKED:a.error=new A({code:o})}return a}return s(n,[{key:"invalidateSessionToken",get:function(){var e;return!!(null===(e=this.error)||void 0===e?void 0:e.isSessionTokenExpiredError)}}]),n}(oe),De=function(e){i(n,e);var t=f(n);function n(e){var a;return r(this,n),(a=t.call(this)).statLog=e,a}return s(n)}(oe);!function(e){e.FEATURE_LOCALCACHE="feature:local_cache",e.WEBSOCKET_CONNECT="ws:connect",e.API_RESULT="api:result"}(Ae||(Ae={}));var Pe=function(){function e(t){var n=t.type,a=t.data,s=t.ts,i=void 0===s?Date.now():s;r(this,e),this.type=n,this.createdAt=i,this.data=a}return s(e,null,[{key:"payloadify",value:function(e){return ue({stat_type:e.type,ts:e.createdAt,data:ue(e.data)})}}]),e}(),Fe=function(){return"undefined"==typeof document&&"undefined"!=typeof navigator&&"ReactNative"==navigator.product},Ge=function(){function e(t,n){var a=this,s=n.auth,i=n.sdkState,o=n.dispatcher,u=n.logger,c=n.useFetchCompat,l=void 0!==c&&c;r(this,e),this._abortControl=new Map,this._shouldImportFetchCompat=!1,this._iid=t,this._auth=s,this._sdkState=i,this._dispatcher=o,this._dispatcher.on((function(e){e instanceof Re&&a.cancel(e.requestId)})),this._logger=u,this._shouldImportFetchCompat=l}return s(e,[{key:"_userAgentWithExtension",get:function(){var e=this._sdkState.extensions,t=Fe()?"reactnative":"JS",n="//";if(e){var r=e.sb_syncmanager?"s".concat(e.sb_syncmanager):"",a=e.sb_uikit?"u".concat(e.sb_uikit):"",s=e["device-os-platform"]?"o".concat(e["device-os-platform"]):"";n="".concat(r,"/").concat(a,"/").concat(s)}return"".concat(t,"/c").concat(C.SDK_VERSION,"/").concat(n)}},{key:"_createHeader",value:function(e,t){var n=this._sdkState,r=n.appId,a=n.appVersion,s=Object.assign(Object.assign({},e.headers),{SendBird:"JS,".concat(C.OS_VERSION,",").concat(C.SDK_VERSION,",").concat(r).concat(a?",".concat(a):""),"SB-User-Agent":encodeURIComponent(this._userAgentWithExtension),"Request-Sent-Timestamp":Date.now().toString()});return t||(s["Content-Type"]="application/json; charset=utf-8"),e.requireAuth&&this._auth.hasSession&&(s["Session-Key"]=this._auth.sessionKey),this._auth&&this._auth.authToken&&(s["App-Id"]=r,s["Access-Token"]=this._auth.authToken),s}},{key:"_statLogApiResult",value:function(e,t,n){this._dispatcher.dispatch(new De(new Pe({type:Ae.API_RESULT,data:{endpoint:e.path,method:e.method,success:!n,latency:Date.now()-t,error_code:null==n?void 0:n.code,error_description:null==n?void 0:n.message}})))}},{key:"send",value:function(e){return b(this,void 0,void 0,t().mark((function n(){var r,a,s,i,o,u,c,l,h,d,f,p,v,_,m;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(r=e.path,a=e.method,s=![le.GET,le.DELETE].includes(a),i=this._sdkState.api,o="".concat(i.host).concat(r).concat(s?"":e.query),u=s?e.payload:null,c=this._createHeader(e,u instanceof FormData?u:void 0),l=new AbortController,h=l.signal,this._abortControl.set(e.requestId,l),d=Date.now(),t.prev=10,this._shouldImportFetchCompat&&(this._shouldImportFetchCompat=!1,("undefined"!=typeof globalThis&&globalThis||"undefined"!=typeof self&&self||"undefined"!=typeof global&&global||{fetch:null}).fetch=null),"undefined"!=typeof AbortController){t.next=15;break}return t.next=15,Promise.resolve().then((function(){return Pv}));case 15:if("function"==typeof fetch){t.next=18;break}return t.next=18,Promise.resolve().then((function(){return a_}));case 18:return t.next=20,fetch(o,{method:a,body:u,headers:c,signal:h});case 20:return f=t.sent,t.next=23,f.json();case 23:if(p=t.sent,!f.ok&&!f.redirected){t.next=30;break}return this._logger.debug("receive api response",e.requestId),this._statLogApiResult(e,d),t.abrupt("return",new Ue(this._iid,p));case 30:if(!p){t.next=37;break}throw((v=new A(p)).isSessionKeyExpiredError||v.isSessionTokenExpiredError)&&this._dispatcher.dispatch(new Le({reason:v.code})),this._statLogApiResult(e,d,v),v;case 37:throw _=A.requestFailed,this._statLogApiResult(e,d,_),_;case 40:t.next=57;break;case 42:if(t.prev=42,t.t0=t.catch(10),this._statLogApiResult(e,d,t.t0),!(t.t0 instanceof A)){t.next=50;break}throw this._logger.debug("fail api request",t.t0),t.t0;case 50:if("AbortError"!==t.t0.name){t.next=54;break}throw A.requestCanceled;case 54:throw m=A.networkError,this._logger.debug("fail api request",m),m;case 57:case"end":return t.stop()}}),n,this,[[10,42]])})))}},{key:"cancel",value:function(e){this._abortControl.has(e)&&(this._abortControl.get(e).abort(),this._abortControl.delete(e))}},{key:"cancelAll",value:function(){var e,t=y(this._abortControl.values());try{for(t.s();!(e=t.n()).done;){e.value.abort()}}catch(e){t.e(e)}finally{t.f()}this._abortControl.clear()}}]),e}(),qe=function(e){i(n,e);var t=f(n);function n(e,a,s){var i,o,u=arguments.length>3&&void 0!==arguments[3]?arguments[3]:"";return r(this,n),(i=t.call(this))._iid=e,i.code=a,i.payload=s,i.requestId=null!==(o=s.req_id)&&void 0!==o?o:u,i}return s(n,[{key:"convertToMessage",value:function(){return"".concat(this.code).concat(JSON.stringify(this.payload),"\n")}},{key:"as",value:function(e){return new e(this._iid,this.code,this.payload)}}],[{key:"createFromRawMessage",value:function(e,t){var r=t.substring(0,4),a={};try{a=JSON.parse(t.substring(4))}catch(e){r="NOOP"}finally{return new n(e,r,a)}}}]),n}(oe),He=function(){};function je(e){let t=e.length;for(;--t>=0;)e[t]=0}const ze=256,Ve=286,Be=30,Qe=15,Ke=new Uint8Array([0,0,0,0,0,0,0,0,1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4,5,5,5,5,0]),We=new Uint8Array([0,0,0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9,9,10,10,11,11,12,12,13,13]),Ye=new Uint8Array([0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,3,7]),Ze=new Uint8Array([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),Je=new Array(576);je(Je);const Xe=new Array(60);je(Xe);const $e=new Array(512);je($e);const et=new Array(256);je(et);const tt=new Array(29);je(tt);const nt=new Array(Be);function rt(e,t,n,r,a){this.static_tree=e,this.extra_bits=t,this.extra_base=n,this.elems=r,this.max_length=a,this.has_stree=e&&e.length}let at,st,it;function ot(e,t){this.dyn_tree=e,this.max_code=0,this.stat_desc=t}je(nt);const ut=e=>e<256?$e[e]:$e[256+(e>>>7)],ct=(e,t)=>{e.pending_buf[e.pending++]=255&t,e.pending_buf[e.pending++]=t>>>8&255},lt=(e,t,n)=>{e.bi_valid>16-n?(e.bi_buf|=t<>16-e.bi_valid,e.bi_valid+=n-16):(e.bi_buf|=t<{lt(e,n[2*t],n[2*t+1])},dt=(e,t)=>{let n=0;do{n|=1&e,e>>>=1,n<<=1}while(--t>0);return n>>>1},ft=(e,t,n)=>{const r=new Array(16);let a,s,i=0;for(a=1;a<=Qe;a++)i=i+n[a-1]<<1,r[a]=i;for(s=0;s<=t;s++){let t=e[2*s+1];0!==t&&(e[2*s]=dt(r[t]++,t))}},pt=e=>{let t;for(t=0;t{e.bi_valid>8?ct(e,e.bi_buf):e.bi_valid>0&&(e.pending_buf[e.pending++]=e.bi_buf),e.bi_buf=0,e.bi_valid=0},_t=(e,t,n,r)=>{const a=2*t,s=2*n;return e[a]{const r=e.heap[n];let a=n<<1;for(;a<=e.heap_len&&(a{let r,a,s,i,o=0;if(0!==e.sym_next)do{r=255&e.pending_buf[e.sym_buf+o++],r+=(255&e.pending_buf[e.sym_buf+o++])<<8,a=e.pending_buf[e.sym_buf+o++],0===r?ht(e,a,t):(s=et[a],ht(e,s+ze+1,t),i=Ke[s],0!==i&&(a-=tt[s],lt(e,a,i)),r--,s=ut(r),ht(e,s,n),i=We[s],0!==i&&(r-=nt[s],lt(e,r,i)))}while(o{const n=t.dyn_tree,r=t.stat_desc.static_tree,a=t.stat_desc.has_stree,s=t.stat_desc.elems;let i,o,u,c=-1;for(e.heap_len=0,e.heap_max=573,i=0;i>1;i>=1;i--)mt(e,n,i);u=s;do{i=e.heap[1],e.heap[1]=e.heap[e.heap_len--],mt(e,n,1),o=e.heap[1],e.heap[--e.heap_max]=i,e.heap[--e.heap_max]=o,n[2*u]=n[2*i]+n[2*o],e.depth[u]=(e.depth[i]>=e.depth[o]?e.depth[i]:e.depth[o])+1,n[2*i+1]=n[2*o+1]=u,e.heap[1]=u++,mt(e,n,1)}while(e.heap_len>=2);e.heap[--e.heap_max]=e.heap[1],((e,t)=>{const n=t.dyn_tree,r=t.max_code,a=t.stat_desc.static_tree,s=t.stat_desc.has_stree,i=t.stat_desc.extra_bits,o=t.stat_desc.extra_base,u=t.stat_desc.max_length;let c,l,h,d,f,p,v=0;for(d=0;d<=Qe;d++)e.bl_count[d]=0;for(n[2*e.heap[e.heap_max]+1]=0,c=e.heap_max+1;c<573;c++)l=e.heap[c],d=n[2*n[2*l+1]+1]+1,d>u&&(d=u,v++),n[2*l+1]=d,l>r||(e.bl_count[d]++,f=0,l>=o&&(f=i[l-o]),p=n[2*l],e.opt_len+=p*(d+f),s&&(e.static_len+=p*(a[2*l+1]+f)));if(0!==v){do{for(d=u-1;0===e.bl_count[d];)d--;e.bl_count[d]--,e.bl_count[d+1]+=2,e.bl_count[u]--,v-=2}while(v>0);for(d=u;0!==d;d--)for(l=e.bl_count[d];0!==l;)h=e.heap[--c],h>r||(n[2*h+1]!==d&&(e.opt_len+=(d-n[2*h+1])*n[2*h],n[2*h+1]=d),l--)}})(e,t),ft(n,c,e.bl_count)},kt=(e,t,n)=>{let r,a,s=-1,i=t[1],o=0,u=7,c=4;for(0===i&&(u=138,c=3),t[2*(n+1)+1]=65535,r=0;r<=n;r++)a=i,i=t[2*(r+1)+1],++o{let r,a,s=-1,i=t[1],o=0,u=7,c=4;for(0===i&&(u=138,c=3),r=0;r<=n;r++)if(a=i,i=t[2*(r+1)+1],!(++o{lt(e,0+(r?1:0),3),vt(e),ct(e,n),ct(e,~n),n&&e.pending_buf.set(e.window.subarray(t,t+n),e.pending),e.pending+=n};var Ct=(e,t,n,r)=>{let a,s,i=0;e.level>0?(2===e.strm.data_type&&(e.strm.data_type=(e=>{let t,n=4093624447;for(t=0;t<=31;t++,n>>>=1)if(1&n&&0!==e.dyn_ltree[2*t])return 0;if(0!==e.dyn_ltree[18]||0!==e.dyn_ltree[20]||0!==e.dyn_ltree[26])return 1;for(t=32;t{let t;for(kt(e,e.dyn_ltree,e.l_desc.max_code),kt(e,e.dyn_dtree,e.d_desc.max_code),yt(e,e.bl_desc),t=18;t>=3&&0===e.bl_tree[2*Ze[t]+1];t--);return e.opt_len+=3*(t+1)+5+5+4,t})(e),a=e.opt_len+3+7>>>3,s=e.static_len+3+7>>>3,s<=a&&(a=s)):a=s=n+5,n+4<=a&&-1!==t?wt(e,t,n,r):4===e.strategy||s===a?(lt(e,2+(r?1:0),3),gt(e,Je,Xe)):(lt(e,4+(r?1:0),3),((e,t,n,r)=>{let a;for(lt(e,t-257,5),lt(e,n-1,5),lt(e,r-4,4),a=0;a{Et||((()=>{let e,t,n,r,a;const s=new Array(16);for(n=0,r=0;r<28;r++)for(tt[r]=n,e=0;e<1<>=7;r(e.pending_buf[e.sym_buf+e.sym_next++]=t,e.pending_buf[e.sym_buf+e.sym_next++]=t>>8,e.pending_buf[e.sym_buf+e.sym_next++]=n,0===t?e.dyn_ltree[2*n]++:(e.matches++,t--,e.dyn_ltree[2*(et[n]+ze+1)]++,e.dyn_dtree[2*ut(t)]++),e.sym_next===e.sym_end),_tr_align:e=>{lt(e,2,3),ht(e,256,Je),(e=>{16===e.bi_valid?(ct(e,e.bi_buf),e.bi_buf=0,e.bi_valid=0):e.bi_valid>=8&&(e.pending_buf[e.pending++]=255&e.bi_buf,e.bi_buf>>=8,e.bi_valid-=8)})(e)}};var Tt=(e,t,n,r)=>{let a=65535&e|0,s=e>>>16&65535|0,i=0;for(;0!==n;){i=n>2e3?2e3:n,n-=i;do{a=a+t[r++]|0,s=s+a|0}while(--i);a%=65521,s%=65521}return a|s<<16|0};const St=new Uint32Array((()=>{let e,t=[];for(var n=0;n<256;n++){e=n;for(var r=0;r<8;r++)e=1&e?3988292384^e>>>1:e>>>1;t[n]=e}return t})());var It=(e,t,n,r)=>{const a=St,s=r+n;e^=-1;for(let n=r;n>>8^a[255&(e^t[n])];return-1^e},Nt={2:"need dictionary",1:"stream end",0:"","-1":"file error","-2":"stream error","-3":"data error","-4":"insufficient memory","-5":"buffer error","-6":"incompatible version"},Mt={Z_NO_FLUSH:0,Z_PARTIAL_FLUSH:1,Z_SYNC_FLUSH:2,Z_FULL_FLUSH:3,Z_FINISH:4,Z_BLOCK:5,Z_TREES:6,Z_OK:0,Z_STREAM_END:1,Z_NEED_DICT:2,Z_ERRNO:-1,Z_STREAM_ERROR:-2,Z_DATA_ERROR:-3,Z_MEM_ERROR:-4,Z_BUF_ERROR:-5,Z_NO_COMPRESSION:0,Z_BEST_SPEED:1,Z_BEST_COMPRESSION:9,Z_DEFAULT_COMPRESSION:-1,Z_FILTERED:1,Z_HUFFMAN_ONLY:2,Z_RLE:3,Z_FIXED:4,Z_DEFAULT_STRATEGY:0,Z_BINARY:0,Z_TEXT:1,Z_UNKNOWN:2,Z_DEFLATED:8};const{_tr_init:At,_tr_stored_block:Ot,_tr_flush_block:Ut,_tr_tally:Rt,_tr_align:Lt}=xt,{Z_NO_FLUSH:Dt,Z_PARTIAL_FLUSH:Pt,Z_FULL_FLUSH:Ft,Z_FINISH:Gt,Z_BLOCK:qt,Z_OK:Ht,Z_STREAM_END:jt,Z_STREAM_ERROR:zt,Z_DATA_ERROR:Vt,Z_BUF_ERROR:Bt,Z_DEFAULT_COMPRESSION:Qt,Z_FILTERED:Kt,Z_HUFFMAN_ONLY:Wt,Z_RLE:Yt,Z_FIXED:Zt,Z_DEFAULT_STRATEGY:Jt,Z_UNKNOWN:Xt,Z_DEFLATED:$t}=Mt,en=258,tn=262,nn=42,rn=113,an=666,sn=(e,t)=>(e.msg=Nt[t],t),on=e=>2*e-(e>4?9:0),un=e=>{let t=e.length;for(;--t>=0;)e[t]=0},cn=e=>{let t,n,r,a=e.w_size;t=e.hash_size,r=t;do{n=e.head[--r],e.head[r]=n>=a?n-a:0}while(--t);t=a,r=t;do{n=e.prev[--r],e.prev[r]=n>=a?n-a:0}while(--t)};let ln=(e,t,n)=>(t<{const t=e.state;let n=t.pending;n>e.avail_out&&(n=e.avail_out),0!==n&&(e.output.set(t.pending_buf.subarray(t.pending_out,t.pending_out+n),e.next_out),e.next_out+=n,t.pending_out+=n,e.total_out+=n,e.avail_out-=n,t.pending-=n,0===t.pending&&(t.pending_out=0))},dn=(e,t)=>{Ut(e,e.block_start>=0?e.block_start:-1,e.strstart-e.block_start,t),e.block_start=e.strstart,hn(e.strm)},fn=(e,t)=>{e.pending_buf[e.pending++]=t},pn=(e,t)=>{e.pending_buf[e.pending++]=t>>>8&255,e.pending_buf[e.pending++]=255&t},vn=(e,t,n,r)=>{let a=e.avail_in;return a>r&&(a=r),0===a?0:(e.avail_in-=a,t.set(e.input.subarray(e.next_in,e.next_in+a),n),1===e.state.wrap?e.adler=Tt(e.adler,t,a,n):2===e.state.wrap&&(e.adler=It(e.adler,t,a,n)),e.next_in+=a,e.total_in+=a,a)},_n=(e,t)=>{let n,r,a=e.max_chain_length,s=e.strstart,i=e.prev_length,o=e.nice_match;const u=e.strstart>e.w_size-tn?e.strstart-(e.w_size-tn):0,c=e.window,l=e.w_mask,h=e.prev,d=e.strstart+en;let f=c[s+i-1],p=c[s+i];e.prev_length>=e.good_match&&(a>>=2),o>e.lookahead&&(o=e.lookahead);do{if(n=t,c[n+i]===p&&c[n+i-1]===f&&c[n]===c[s]&&c[++n]===c[s+1]){s+=2,n++;do{}while(c[++s]===c[++n]&&c[++s]===c[++n]&&c[++s]===c[++n]&&c[++s]===c[++n]&&c[++s]===c[++n]&&c[++s]===c[++n]&&c[++s]===c[++n]&&c[++s]===c[++n]&&si){if(e.match_start=t,i=r,r>=o)break;f=c[s+i-1],p=c[s+i]}}}while((t=h[t&l])>u&&0!=--a);return i<=e.lookahead?i:e.lookahead},mn=e=>{const t=e.w_size;let n,r,a;do{if(r=e.window_size-e.lookahead-e.strstart,e.strstart>=t+(t-tn)&&(e.window.set(e.window.subarray(t,t+t-r),0),e.match_start-=t,e.strstart-=t,e.block_start-=t,e.insert>e.strstart&&(e.insert=e.strstart),cn(e),r+=t),0===e.strm.avail_in)break;if(n=vn(e.strm,e.window,e.strstart+e.lookahead,r),e.lookahead+=n,e.lookahead+e.insert>=3)for(a=e.strstart-e.insert,e.ins_h=e.window[a],e.ins_h=ln(e,e.ins_h,e.window[a+1]);e.insert&&(e.ins_h=ln(e,e.ins_h,e.window[a+3-1]),e.prev[a&e.w_mask]=e.head[e.ins_h],e.head[e.ins_h]=a,a++,e.insert--,!(e.lookahead+e.insert<3)););}while(e.lookahead{let n,r,a,s=e.pending_buf_size-5>e.w_size?e.w_size:e.pending_buf_size-5,i=0,o=e.strm.avail_in;do{if(n=65535,a=e.bi_valid+42>>3,e.strm.avail_outr+e.strm.avail_in&&(n=r+e.strm.avail_in),n>a&&(n=a),n>8,e.pending_buf[e.pending-2]=~n,e.pending_buf[e.pending-1]=~n>>8,hn(e.strm),r&&(r>n&&(r=n),e.strm.output.set(e.window.subarray(e.block_start,e.block_start+r),e.strm.next_out),e.strm.next_out+=r,e.strm.avail_out-=r,e.strm.total_out+=r,e.block_start+=r,n-=r),n&&(vn(e.strm,e.strm.output,e.strm.next_out,n),e.strm.next_out+=n,e.strm.avail_out-=n,e.strm.total_out+=n)}while(0===i);return o-=e.strm.avail_in,o&&(o>=e.w_size?(e.matches=2,e.window.set(e.strm.input.subarray(e.strm.next_in-e.w_size,e.strm.next_in),0),e.strstart=e.w_size,e.insert=e.strstart):(e.window_size-e.strstart<=o&&(e.strstart-=e.w_size,e.window.set(e.window.subarray(e.w_size,e.w_size+e.strstart),0),e.matches<2&&e.matches++,e.insert>e.strstart&&(e.insert=e.strstart)),e.window.set(e.strm.input.subarray(e.strm.next_in-o,e.strm.next_in),e.strstart),e.strstart+=o,e.insert+=o>e.w_size-e.insert?e.w_size-e.insert:o),e.block_start=e.strstart),e.high_watera&&e.block_start>=e.w_size&&(e.block_start-=e.w_size,e.strstart-=e.w_size,e.window.set(e.window.subarray(e.w_size,e.w_size+e.strstart),0),e.matches<2&&e.matches++,a+=e.w_size,e.insert>e.strstart&&(e.insert=e.strstart)),a>e.strm.avail_in&&(a=e.strm.avail_in),a&&(vn(e.strm,e.window,e.strstart,a),e.strstart+=a,e.insert+=a>e.w_size-e.insert?e.w_size-e.insert:a),e.high_water>3,a=e.pending_buf_size-a>65535?65535:e.pending_buf_size-a,s=a>e.w_size?e.w_size:a,r=e.strstart-e.block_start,(r>=s||(r||t===Gt)&&t!==Dt&&0===e.strm.avail_in&&r<=a)&&(n=r>a?a:r,i=t===Gt&&0===e.strm.avail_in&&n===r?1:0,Ot(e,e.block_start,n,i),e.block_start+=n,hn(e.strm)),i?3:1)},yn=(e,t)=>{let n,r;for(;;){if(e.lookahead=3&&(e.ins_h=ln(e,e.ins_h,e.window[e.strstart+3-1]),n=e.prev[e.strstart&e.w_mask]=e.head[e.ins_h],e.head[e.ins_h]=e.strstart),0!==n&&e.strstart-n<=e.w_size-tn&&(e.match_length=_n(e,n)),e.match_length>=3)if(r=Rt(e,e.strstart-e.match_start,e.match_length-3),e.lookahead-=e.match_length,e.match_length<=e.max_lazy_match&&e.lookahead>=3){e.match_length--;do{e.strstart++,e.ins_h=ln(e,e.ins_h,e.window[e.strstart+3-1]),n=e.prev[e.strstart&e.w_mask]=e.head[e.ins_h],e.head[e.ins_h]=e.strstart}while(0!=--e.match_length);e.strstart++}else e.strstart+=e.match_length,e.match_length=0,e.ins_h=e.window[e.strstart],e.ins_h=ln(e,e.ins_h,e.window[e.strstart+1]);else r=Rt(e,0,e.window[e.strstart]),e.lookahead--,e.strstart++;if(r&&(dn(e,!1),0===e.strm.avail_out))return 1}return e.insert=e.strstart<2?e.strstart:2,t===Gt?(dn(e,!0),0===e.strm.avail_out?3:4):e.sym_next&&(dn(e,!1),0===e.strm.avail_out)?1:2},kn=(e,t)=>{let n,r,a;for(;;){if(e.lookahead=3&&(e.ins_h=ln(e,e.ins_h,e.window[e.strstart+3-1]),n=e.prev[e.strstart&e.w_mask]=e.head[e.ins_h],e.head[e.ins_h]=e.strstart),e.prev_length=e.match_length,e.prev_match=e.match_start,e.match_length=2,0!==n&&e.prev_length4096)&&(e.match_length=2)),e.prev_length>=3&&e.match_length<=e.prev_length){a=e.strstart+e.lookahead-3,r=Rt(e,e.strstart-1-e.prev_match,e.prev_length-3),e.lookahead-=e.prev_length-1,e.prev_length-=2;do{++e.strstart<=a&&(e.ins_h=ln(e,e.ins_h,e.window[e.strstart+3-1]),n=e.prev[e.strstart&e.w_mask]=e.head[e.ins_h],e.head[e.ins_h]=e.strstart)}while(0!=--e.prev_length);if(e.match_available=0,e.match_length=2,e.strstart++,r&&(dn(e,!1),0===e.strm.avail_out))return 1}else if(e.match_available){if(r=Rt(e,0,e.window[e.strstart-1]),r&&dn(e,!1),e.strstart++,e.lookahead--,0===e.strm.avail_out)return 1}else e.match_available=1,e.strstart++,e.lookahead--}return e.match_available&&(r=Rt(e,0,e.window[e.strstart-1]),e.match_available=0),e.insert=e.strstart<2?e.strstart:2,t===Gt?(dn(e,!0),0===e.strm.avail_out?3:4):e.sym_next&&(dn(e,!1),0===e.strm.avail_out)?1:2};function bn(e,t,n,r,a){this.good_length=e,this.max_lazy=t,this.nice_length=n,this.max_chain=r,this.func=a}const En=[new bn(0,0,0,0,gn),new bn(4,4,8,4,yn),new bn(4,5,16,8,yn),new bn(4,6,32,32,yn),new bn(4,4,16,16,kn),new bn(8,16,32,32,kn),new bn(8,16,128,128,kn),new bn(8,32,128,256,kn),new bn(32,128,258,1024,kn),new bn(32,258,258,4096,kn)];function wn(){this.strm=null,this.status=0,this.pending_buf=null,this.pending_buf_size=0,this.pending_out=0,this.pending=0,this.wrap=0,this.gzhead=null,this.gzindex=0,this.method=$t,this.last_flush=-1,this.w_size=0,this.w_bits=0,this.w_mask=0,this.window=null,this.window_size=0,this.prev=null,this.head=null,this.ins_h=0,this.hash_size=0,this.hash_bits=0,this.hash_mask=0,this.hash_shift=0,this.block_start=0,this.match_length=0,this.prev_match=0,this.match_available=0,this.strstart=0,this.match_start=0,this.lookahead=0,this.prev_length=0,this.max_chain_length=0,this.max_lazy_match=0,this.level=0,this.strategy=0,this.good_match=0,this.nice_match=0,this.dyn_ltree=new Uint16Array(1146),this.dyn_dtree=new Uint16Array(122),this.bl_tree=new Uint16Array(78),un(this.dyn_ltree),un(this.dyn_dtree),un(this.bl_tree),this.l_desc=null,this.d_desc=null,this.bl_desc=null,this.bl_count=new Uint16Array(16),this.heap=new Uint16Array(573),un(this.heap),this.heap_len=0,this.heap_max=0,this.depth=new Uint16Array(573),un(this.depth),this.sym_buf=0,this.lit_bufsize=0,this.sym_next=0,this.sym_end=0,this.opt_len=0,this.static_len=0,this.matches=0,this.insert=0,this.bi_buf=0,this.bi_valid=0}const Cn=e=>{if(!e)return 1;const t=e.state;return!t||t.strm!==e||t.status!==nn&&57!==t.status&&69!==t.status&&73!==t.status&&91!==t.status&&103!==t.status&&t.status!==rn&&t.status!==an?1:0},xn=e=>{if(Cn(e))return sn(e,zt);e.total_in=e.total_out=0,e.data_type=Xt;const t=e.state;return t.pending=0,t.pending_out=0,t.wrap<0&&(t.wrap=-t.wrap),t.status=2===t.wrap?57:t.wrap?nn:rn,e.adler=2===t.wrap?0:1,t.last_flush=-2,At(t),Ht},Tn=e=>{const t=xn(e);var n;return t===Ht&&((n=e.state).window_size=2*n.w_size,un(n.head),n.max_lazy_match=En[n.level].max_lazy,n.good_match=En[n.level].good_length,n.nice_match=En[n.level].nice_length,n.max_chain_length=En[n.level].max_chain,n.strstart=0,n.block_start=0,n.lookahead=0,n.insert=0,n.match_length=n.prev_length=2,n.match_available=0,n.ins_h=0),t},Sn=(e,t,n,r,a,s)=>{if(!e)return zt;let i=1;if(t===Qt&&(t=6),r<0?(i=0,r=-r):r>15&&(i=2,r-=16),a<1||a>9||n!==$t||r<8||r>15||t<0||t>9||s<0||s>Zt||8===r&&1!==i)return sn(e,zt);8===r&&(r=9);const o=new wn;return e.state=o,o.strm=e,o.status=nn,o.wrap=i,o.gzhead=null,o.w_bits=r,o.w_size=1<Sn(e,t,$t,15,8,Jt),deflateInit2:Sn,deflateReset:Tn,deflateResetKeep:xn,deflateSetHeader:(e,t)=>Cn(e)||2!==e.state.wrap?zt:(e.state.gzhead=t,Ht),deflate:(e,t)=>{if(Cn(e)||t>qt||t<0)return e?sn(e,zt):zt;const n=e.state;if(!e.output||0!==e.avail_in&&!e.input||n.status===an&&t!==Gt)return sn(e,0===e.avail_out?Bt:zt);const r=n.last_flush;if(n.last_flush=t,0!==n.pending){if(hn(e),0===e.avail_out)return n.last_flush=-1,Ht}else if(0===e.avail_in&&on(t)<=on(r)&&t!==Gt)return sn(e,Bt);if(n.status===an&&0!==e.avail_in)return sn(e,Bt);if(n.status===nn&&0===n.wrap&&(n.status=rn),n.status===nn){let t=$t+(n.w_bits-8<<4)<<8,r=-1;if(r=n.strategy>=Wt||n.level<2?0:n.level<6?1:6===n.level?2:3,t|=r<<6,0!==n.strstart&&(t|=32),t+=31-t%31,pn(n,t),0!==n.strstart&&(pn(n,e.adler>>>16),pn(n,65535&e.adler)),e.adler=1,n.status=rn,hn(e),0!==n.pending)return n.last_flush=-1,Ht}if(57===n.status)if(e.adler=0,fn(n,31),fn(n,139),fn(n,8),n.gzhead)fn(n,(n.gzhead.text?1:0)+(n.gzhead.hcrc?2:0)+(n.gzhead.extra?4:0)+(n.gzhead.name?8:0)+(n.gzhead.comment?16:0)),fn(n,255&n.gzhead.time),fn(n,n.gzhead.time>>8&255),fn(n,n.gzhead.time>>16&255),fn(n,n.gzhead.time>>24&255),fn(n,9===n.level?2:n.strategy>=Wt||n.level<2?4:0),fn(n,255&n.gzhead.os),n.gzhead.extra&&n.gzhead.extra.length&&(fn(n,255&n.gzhead.extra.length),fn(n,n.gzhead.extra.length>>8&255)),n.gzhead.hcrc&&(e.adler=It(e.adler,n.pending_buf,n.pending,0)),n.gzindex=0,n.status=69;else if(fn(n,0),fn(n,0),fn(n,0),fn(n,0),fn(n,0),fn(n,9===n.level?2:n.strategy>=Wt||n.level<2?4:0),fn(n,3),n.status=rn,hn(e),0!==n.pending)return n.last_flush=-1,Ht;if(69===n.status){if(n.gzhead.extra){let t=n.pending,r=(65535&n.gzhead.extra.length)-n.gzindex;for(;n.pending+r>n.pending_buf_size;){let a=n.pending_buf_size-n.pending;if(n.pending_buf.set(n.gzhead.extra.subarray(n.gzindex,n.gzindex+a),n.pending),n.pending=n.pending_buf_size,n.gzhead.hcrc&&n.pending>t&&(e.adler=It(e.adler,n.pending_buf,n.pending-t,t)),n.gzindex+=a,hn(e),0!==n.pending)return n.last_flush=-1,Ht;t=0,r-=a}let a=new Uint8Array(n.gzhead.extra);n.pending_buf.set(a.subarray(n.gzindex,n.gzindex+r),n.pending),n.pending+=r,n.gzhead.hcrc&&n.pending>t&&(e.adler=It(e.adler,n.pending_buf,n.pending-t,t)),n.gzindex=0}n.status=73}if(73===n.status){if(n.gzhead.name){let t,r=n.pending;do{if(n.pending===n.pending_buf_size){if(n.gzhead.hcrc&&n.pending>r&&(e.adler=It(e.adler,n.pending_buf,n.pending-r,r)),hn(e),0!==n.pending)return n.last_flush=-1,Ht;r=0}t=n.gzindexr&&(e.adler=It(e.adler,n.pending_buf,n.pending-r,r)),n.gzindex=0}n.status=91}if(91===n.status){if(n.gzhead.comment){let t,r=n.pending;do{if(n.pending===n.pending_buf_size){if(n.gzhead.hcrc&&n.pending>r&&(e.adler=It(e.adler,n.pending_buf,n.pending-r,r)),hn(e),0!==n.pending)return n.last_flush=-1,Ht;r=0}t=n.gzindexr&&(e.adler=It(e.adler,n.pending_buf,n.pending-r,r))}n.status=103}if(103===n.status){if(n.gzhead.hcrc){if(n.pending+2>n.pending_buf_size&&(hn(e),0!==n.pending))return n.last_flush=-1,Ht;fn(n,255&e.adler),fn(n,e.adler>>8&255),e.adler=0}if(n.status=rn,hn(e),0!==n.pending)return n.last_flush=-1,Ht}if(0!==e.avail_in||0!==n.lookahead||t!==Dt&&n.status!==an){let r=0===n.level?gn(n,t):n.strategy===Wt?((e,t)=>{let n;for(;;){if(0===e.lookahead&&(mn(e),0===e.lookahead)){if(t===Dt)return 1;break}if(e.match_length=0,n=Rt(e,0,e.window[e.strstart]),e.lookahead--,e.strstart++,n&&(dn(e,!1),0===e.strm.avail_out))return 1}return e.insert=0,t===Gt?(dn(e,!0),0===e.strm.avail_out?3:4):e.sym_next&&(dn(e,!1),0===e.strm.avail_out)?1:2})(n,t):n.strategy===Yt?((e,t)=>{let n,r,a,s;const i=e.window;for(;;){if(e.lookahead<=en){if(mn(e),e.lookahead<=en&&t===Dt)return 1;if(0===e.lookahead)break}if(e.match_length=0,e.lookahead>=3&&e.strstart>0&&(a=e.strstart-1,r=i[a],r===i[++a]&&r===i[++a]&&r===i[++a])){s=e.strstart+en;do{}while(r===i[++a]&&r===i[++a]&&r===i[++a]&&r===i[++a]&&r===i[++a]&&r===i[++a]&&r===i[++a]&&r===i[++a]&&ae.lookahead&&(e.match_length=e.lookahead)}if(e.match_length>=3?(n=Rt(e,1,e.match_length-3),e.lookahead-=e.match_length,e.strstart+=e.match_length,e.match_length=0):(n=Rt(e,0,e.window[e.strstart]),e.lookahead--,e.strstart++),n&&(dn(e,!1),0===e.strm.avail_out))return 1}return e.insert=0,t===Gt?(dn(e,!0),0===e.strm.avail_out?3:4):e.sym_next&&(dn(e,!1),0===e.strm.avail_out)?1:2})(n,t):En[n.level].func(n,t);if(3!==r&&4!==r||(n.status=an),1===r||3===r)return 0===e.avail_out&&(n.last_flush=-1),Ht;if(2===r&&(t===Pt?Lt(n):t!==qt&&(Ot(n,0,0,!1),t===Ft&&(un(n.head),0===n.lookahead&&(n.strstart=0,n.block_start=0,n.insert=0))),hn(e),0===e.avail_out))return n.last_flush=-1,Ht}return t!==Gt?Ht:n.wrap<=0?jt:(2===n.wrap?(fn(n,255&e.adler),fn(n,e.adler>>8&255),fn(n,e.adler>>16&255),fn(n,e.adler>>24&255),fn(n,255&e.total_in),fn(n,e.total_in>>8&255),fn(n,e.total_in>>16&255),fn(n,e.total_in>>24&255)):(pn(n,e.adler>>>16),pn(n,65535&e.adler)),hn(e),n.wrap>0&&(n.wrap=-n.wrap),0!==n.pending?Ht:jt)},deflateEnd:e=>{if(Cn(e))return zt;const t=e.state.status;return e.state=null,t===rn?sn(e,Vt):Ht},deflateSetDictionary:(e,t)=>{let n=t.length;if(Cn(e))return zt;const r=e.state,a=r.wrap;if(2===a||1===a&&r.status!==nn||r.lookahead)return zt;if(1===a&&(e.adler=Tt(e.adler,t,n,0)),r.wrap=0,n>=r.w_size){0===a&&(un(r.head),r.strstart=0,r.block_start=0,r.insert=0);let e=new Uint8Array(r.w_size);e.set(t.subarray(n-r.w_size,n),0),t=e,n=r.w_size}const s=e.avail_in,i=e.next_in,o=e.input;for(e.avail_in=n,e.next_in=0,e.input=t,mn(r);r.lookahead>=3;){let e=r.strstart,t=r.lookahead-2;do{r.ins_h=ln(r,r.ins_h,r.window[e+3-1]),r.prev[e&r.w_mask]=r.head[r.ins_h],r.head[r.ins_h]=e,e++}while(--t);r.strstart=e,r.lookahead=2,mn(r)}return r.strstart+=r.lookahead,r.block_start=r.strstart,r.insert=r.lookahead,r.lookahead=0,r.match_length=r.prev_length=2,r.match_available=0,e.next_in=i,e.input=o,e.avail_in=s,r.wrap=a,Ht},deflateInfo:"pako deflate (from Nodeca project)"};const Nn=(e,t)=>Object.prototype.hasOwnProperty.call(e,t);var Mn={assign:function(e){const t=Array.prototype.slice.call(arguments,1);for(;t.length;){const n=t.shift();if(n){if("object"!=typeof n)throw new TypeError(n+"must be non-object");for(const t in n)Nn(n,t)&&(e[t]=n[t])}}return e},flattenChunks:e=>{let t=0;for(let n=0,r=e.length;n=252?6:e>=248?5:e>=240?4:e>=224?3:e>=192?2:1;On[254]=On[254]=1;var Un={string2buf:e=>{if("function"==typeof TextEncoder&&TextEncoder.prototype.encode)return(new TextEncoder).encode(e);let t,n,r,a,s,i=e.length,o=0;for(a=0;a>>6,t[s++]=128|63&n):n<65536?(t[s++]=224|n>>>12,t[s++]=128|n>>>6&63,t[s++]=128|63&n):(t[s++]=240|n>>>18,t[s++]=128|n>>>12&63,t[s++]=128|n>>>6&63,t[s++]=128|63&n);return t},buf2string:(e,t)=>{const n=t||e.length;if("function"==typeof TextDecoder&&TextDecoder.prototype.decode)return(new TextDecoder).decode(e.subarray(0,t));let r,a;const s=new Array(2*n);for(a=0,r=0;r4)s[a++]=65533,r+=i-1;else{for(t&=2===i?31:3===i?15:7;i>1&&r1?s[a++]=65533:t<65536?s[a++]=t:(t-=65536,s[a++]=55296|t>>10&1023,s[a++]=56320|1023&t)}}return((e,t)=>{if(t<65534&&e.subarray&&An)return String.fromCharCode.apply(null,e.length===t?e:e.subarray(0,t));let n="";for(let r=0;r{(t=t||e.length)>e.length&&(t=e.length);let n=t-1;for(;n>=0&&128==(192&e[n]);)n--;return n<0||0===n?t:n+On[e[n]]>t?n:t}};var Rn=function(){this.input=null,this.next_in=0,this.avail_in=0,this.total_in=0,this.output=null,this.next_out=0,this.avail_out=0,this.total_out=0,this.msg="",this.state=null,this.data_type=2,this.adler=0};const Ln=Object.prototype.toString,{Z_NO_FLUSH:Dn,Z_SYNC_FLUSH:Pn,Z_FULL_FLUSH:Fn,Z_FINISH:Gn,Z_OK:qn,Z_STREAM_END:Hn,Z_DEFAULT_COMPRESSION:jn,Z_DEFAULT_STRATEGY:zn,Z_DEFLATED:Vn}=Mt;function Bn(e){this.options=Mn.assign({level:jn,method:Vn,chunkSize:16384,windowBits:15,memLevel:8,strategy:zn},e||{});let t=this.options;t.raw&&t.windowBits>0?t.windowBits=-t.windowBits:t.gzip&&t.windowBits>0&&t.windowBits<16&&(t.windowBits+=16),this.err=0,this.msg="",this.ended=!1,this.chunks=[],this.strm=new Rn,this.strm.avail_out=0;let n=In.deflateInit2(this.strm,t.level,t.method,t.windowBits,t.memLevel,t.strategy);if(n!==qn)throw new Error(Nt[n]);if(t.header&&In.deflateSetHeader(this.strm,t.header),t.dictionary){let e;if(e="string"==typeof t.dictionary?Un.string2buf(t.dictionary):"[object ArrayBuffer]"===Ln.call(t.dictionary)?new Uint8Array(t.dictionary):t.dictionary,n=In.deflateSetDictionary(this.strm,e),n!==qn)throw new Error(Nt[n]);this._dict_set=!0}}function Qn(e,t){const n=new Bn(t);if(n.push(e,!0),n.err)throw n.msg||Nt[n.err];return n.result}Bn.prototype.push=function(e,t){const n=this.strm,r=this.options.chunkSize;let a,s;if(this.ended)return!1;for(s=t===~~t?t:!0===t?Gn:Dn,"string"==typeof e?n.input=Un.string2buf(e):"[object ArrayBuffer]"===Ln.call(e)?n.input=new Uint8Array(e):n.input=e,n.next_in=0,n.avail_in=n.input.length;;)if(0===n.avail_out&&(n.output=new Uint8Array(r),n.next_out=0,n.avail_out=r),(s===Pn||s===Fn)&&n.avail_out<=6)this.onData(n.output.subarray(0,n.next_out)),n.avail_out=0;else{if(a=In.deflate(n,s),a===Hn)return n.next_out>0&&this.onData(n.output.subarray(0,n.next_out)),a=In.deflateEnd(this.strm),this.onEnd(a),this.ended=!0,a===qn;if(0!==n.avail_out){if(s>0&&n.next_out>0)this.onData(n.output.subarray(0,n.next_out)),n.avail_out=0;else if(0===n.avail_in)break}else this.onData(n.output)}return!0},Bn.prototype.onData=function(e){this.chunks.push(e)},Bn.prototype.onEnd=function(e){e===qn&&(this.result=Mn.flattenChunks(this.chunks)),this.chunks=[],this.err=e,this.msg=this.strm.msg};var Kn={Deflate:Bn,deflate:Qn,deflateRaw:function(e,t){return(t=t||{}).raw=!0,Qn(e,t)},gzip:function(e,t){return(t=t||{}).gzip=!0,Qn(e,t)},constants:Mt};const Wn=16209;var Yn=function(e,t){let n,r,a,s,i,o,u,c,l,h,d,f,p,v,_,m,g,y,k,b,E,w,C,x;const T=e.state;n=e.next_in,C=e.input,r=n+(e.avail_in-5),a=e.next_out,x=e.output,s=a-(t-e.avail_out),i=a+(e.avail_out-257),o=T.dmax,u=T.wsize,c=T.whave,l=T.wnext,h=T.window,d=T.hold,f=T.bits,p=T.lencode,v=T.distcode,_=(1<>>24,d>>>=y,f-=y,y=g>>>16&255,0===y)x[a++]=65535&g;else{if(!(16&y)){if(0==(64&y)){g=p[(65535&g)+(d&(1<>>=y,f-=y),f<15&&(d+=C[n++]<>>24,d>>>=y,f-=y,y=g>>>16&255,!(16&y)){if(0==(64&y)){g=v[(65535&g)+(d&(1<o){e.msg="invalid distance too far back",T.mode=Wn;break e}if(d>>>=y,f-=y,y=a-s,b>y){if(y=b-y,y>c&&T.sane){e.msg="invalid distance too far back",T.mode=Wn;break e}if(E=0,w=h,0===l){if(E+=u-y,y2;)x[a++]=w[E++],x[a++]=w[E++],x[a++]=w[E++],k-=3;k&&(x[a++]=w[E++],k>1&&(x[a++]=w[E++]))}else{E=a-b;do{x[a++]=x[E++],x[a++]=x[E++],x[a++]=x[E++],k-=3}while(k>2);k&&(x[a++]=x[E++],k>1&&(x[a++]=x[E++]))}break}}break}}while(n>3,n-=k,f-=k<<3,d&=(1<{const u=o.bits;let c,l,h,d,f,p,v=0,_=0,m=0,g=0,y=0,k=0,b=0,E=0,w=0,C=0,x=null;const T=new Uint16Array(16),S=new Uint16Array(16);let I,N,M,A=null;for(v=0;v<=Zn;v++)T[v]=0;for(_=0;_=1&&0===T[g];g--);if(y>g&&(y=g),0===g)return a[s++]=20971520,a[s++]=20971520,o.bits=1,0;for(m=1;m0&&(0===e||1!==g))return-1;for(S[1]=0,v=1;v852||2===e&&w>592)return 1;for(;;){I=v-b,i[_]+1=p?(N=A[i[_]-p],M=x[i[_]-p]):(N=96,M=0),c=1<>b)+l]=I<<24|N<<16|M|0}while(0!==l);for(c=1<>=1;if(0!==c?(C&=c-1,C+=c):C=0,_++,0==--T[v]){if(v===g)break;v=t[n+i[_]]}if(v>y&&(C&d)!==h){for(0===b&&(b=y),f+=m,k=v-b,E=1<852||2===e&&w>592)return 1;h=C&d,a[h]=y<<24|k<<16|f-s|0}}return 0!==C&&(a[f+C]=v-b<<24|64<<16|0),o.bits=y,0};const{Z_FINISH:nr,Z_BLOCK:rr,Z_TREES:ar,Z_OK:sr,Z_STREAM_END:ir,Z_NEED_DICT:or,Z_STREAM_ERROR:ur,Z_DATA_ERROR:cr,Z_MEM_ERROR:lr,Z_BUF_ERROR:hr,Z_DEFLATED:dr}=Mt,fr=16180,pr=16190,vr=16191,_r=16192,mr=16194,gr=16199,yr=16200,kr=16206,br=16209,Er=e=>(e>>>24&255)+(e>>>8&65280)+((65280&e)<<8)+((255&e)<<24);function wr(){this.strm=null,this.mode=0,this.last=!1,this.wrap=0,this.havedict=!1,this.flags=0,this.dmax=0,this.check=0,this.total=0,this.head=null,this.wbits=0,this.wsize=0,this.whave=0,this.wnext=0,this.window=null,this.hold=0,this.bits=0,this.length=0,this.offset=0,this.extra=0,this.lencode=null,this.distcode=null,this.lenbits=0,this.distbits=0,this.ncode=0,this.nlen=0,this.ndist=0,this.have=0,this.next=null,this.lens=new Uint16Array(320),this.work=new Uint16Array(288),this.lendyn=null,this.distdyn=null,this.sane=0,this.back=0,this.was=0}const Cr=e=>{if(!e)return 1;const t=e.state;return!t||t.strm!==e||t.mode16211?1:0},xr=e=>{if(Cr(e))return ur;const t=e.state;return e.total_in=e.total_out=t.total=0,e.msg="",t.wrap&&(e.adler=1&t.wrap),t.mode=fr,t.last=0,t.havedict=0,t.flags=-1,t.dmax=32768,t.head=null,t.hold=0,t.bits=0,t.lencode=t.lendyn=new Int32Array(852),t.distcode=t.distdyn=new Int32Array(592),t.sane=1,t.back=-1,sr},Tr=e=>{if(Cr(e))return ur;const t=e.state;return t.wsize=0,t.whave=0,t.wnext=0,xr(e)},Sr=(e,t)=>{let n;if(Cr(e))return ur;const r=e.state;return t<0?(n=0,t=-t):(n=5+(t>>4),t<48&&(t&=15)),t&&(t<8||t>15)?ur:(null!==r.window&&r.wbits!==t&&(r.window=null),r.wrap=n,r.wbits=t,Tr(e))},Ir=(e,t)=>{if(!e)return ur;const n=new wr;e.state=n,n.strm=e,n.window=null,n.mode=fr;const r=Sr(e,t);return r!==sr&&(e.state=null),r};let Nr,Mr,Ar=!0;const Or=e=>{if(Ar){Nr=new Int32Array(512),Mr=new Int32Array(32);let t=0;for(;t<144;)e.lens[t++]=8;for(;t<256;)e.lens[t++]=9;for(;t<280;)e.lens[t++]=7;for(;t<288;)e.lens[t++]=8;for(tr(1,e.lens,0,288,Nr,0,e.work,{bits:9}),t=0;t<32;)e.lens[t++]=5;tr(2,e.lens,0,32,Mr,0,e.work,{bits:5}),Ar=!1}e.lencode=Nr,e.lenbits=9,e.distcode=Mr,e.distbits=5},Ur=(e,t,n,r)=>{let a;const s=e.state;return null===s.window&&(s.wsize=1<=s.wsize?(s.window.set(t.subarray(n-s.wsize,n),0),s.wnext=0,s.whave=s.wsize):(a=s.wsize-s.wnext,a>r&&(a=r),s.window.set(t.subarray(n-r,n-r+a),s.wnext),(r-=a)?(s.window.set(t.subarray(n-r,n),0),s.wnext=r,s.whave=s.wsize):(s.wnext+=a,s.wnext===s.wsize&&(s.wnext=0),s.whaveIr(e,15),inflateInit2:Ir,inflate:(e,t)=>{let n,r,a,s,i,o,u,c,l,h,d,f,p,v,_,m,g,y,k,b,E,w,C=0;const x=new Uint8Array(4);let T,S;const I=new Uint8Array([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]);if(Cr(e)||!e.output||!e.input&&0!==e.avail_in)return ur;n=e.state,n.mode===vr&&(n.mode=_r),i=e.next_out,a=e.output,u=e.avail_out,s=e.next_in,r=e.input,o=e.avail_in,c=n.hold,l=n.bits,h=o,d=u,w=sr;e:for(;;)switch(n.mode){case fr:if(0===n.wrap){n.mode=_r;break}for(;l<16;){if(0===o)break e;o--,c+=r[s++]<>>8&255,n.check=It(n.check,x,2,0),c=0,l=0,n.mode=16181;break}if(n.head&&(n.head.done=!1),!(1&n.wrap)||(((255&c)<<8)+(c>>8))%31){e.msg="incorrect header check",n.mode=br;break}if((15&c)!==dr){e.msg="unknown compression method",n.mode=br;break}if(c>>>=4,l-=4,E=8+(15&c),0===n.wbits&&(n.wbits=E),E>15||E>n.wbits){e.msg="invalid window size",n.mode=br;break}n.dmax=1<>8&1),512&n.flags&&4&n.wrap&&(x[0]=255&c,x[1]=c>>>8&255,n.check=It(n.check,x,2,0)),c=0,l=0,n.mode=16182;case 16182:for(;l<32;){if(0===o)break e;o--,c+=r[s++]<>>8&255,x[2]=c>>>16&255,x[3]=c>>>24&255,n.check=It(n.check,x,4,0)),c=0,l=0,n.mode=16183;case 16183:for(;l<16;){if(0===o)break e;o--,c+=r[s++]<>8),512&n.flags&&4&n.wrap&&(x[0]=255&c,x[1]=c>>>8&255,n.check=It(n.check,x,2,0)),c=0,l=0,n.mode=16184;case 16184:if(1024&n.flags){for(;l<16;){if(0===o)break e;o--,c+=r[s++]<>>8&255,n.check=It(n.check,x,2,0)),c=0,l=0}else n.head&&(n.head.extra=null);n.mode=16185;case 16185:if(1024&n.flags&&(f=n.length,f>o&&(f=o),f&&(n.head&&(E=n.head.extra_len-n.length,n.head.extra||(n.head.extra=new Uint8Array(n.head.extra_len)),n.head.extra.set(r.subarray(s,s+f),E)),512&n.flags&&4&n.wrap&&(n.check=It(n.check,r,f,s)),o-=f,s+=f,n.length-=f),n.length))break e;n.length=0,n.mode=16186;case 16186:if(2048&n.flags){if(0===o)break e;f=0;do{E=r[s+f++],n.head&&E&&n.length<65536&&(n.head.name+=String.fromCharCode(E))}while(E&&f>9&1,n.head.done=!0),e.adler=n.check=0,n.mode=vr;break;case 16189:for(;l<32;){if(0===o)break e;o--,c+=r[s++]<>>=7&l,l-=7&l,n.mode=kr;break}for(;l<3;){if(0===o)break e;o--,c+=r[s++]<>>=1,l-=1,3&c){case 0:n.mode=16193;break;case 1:if(Or(n),n.mode=gr,t===ar){c>>>=2,l-=2;break e}break;case 2:n.mode=16196;break;case 3:e.msg="invalid block type",n.mode=br}c>>>=2,l-=2;break;case 16193:for(c>>>=7&l,l-=7&l;l<32;){if(0===o)break e;o--,c+=r[s++]<>>16^65535)){e.msg="invalid stored block lengths",n.mode=br;break}if(n.length=65535&c,c=0,l=0,n.mode=mr,t===ar)break e;case mr:n.mode=16195;case 16195:if(f=n.length,f){if(f>o&&(f=o),f>u&&(f=u),0===f)break e;a.set(r.subarray(s,s+f),i),o-=f,s+=f,u-=f,i+=f,n.length-=f;break}n.mode=vr;break;case 16196:for(;l<14;){if(0===o)break e;o--,c+=r[s++]<>>=5,l-=5,n.ndist=1+(31&c),c>>>=5,l-=5,n.ncode=4+(15&c),c>>>=4,l-=4,n.nlen>286||n.ndist>30){e.msg="too many length or distance symbols",n.mode=br;break}n.have=0,n.mode=16197;case 16197:for(;n.have>>=3,l-=3}for(;n.have<19;)n.lens[I[n.have++]]=0;if(n.lencode=n.lendyn,n.lenbits=7,T={bits:n.lenbits},w=tr(0,n.lens,0,19,n.lencode,0,n.work,T),n.lenbits=T.bits,w){e.msg="invalid code lengths set",n.mode=br;break}n.have=0,n.mode=16198;case 16198:for(;n.have>>24,m=C>>>16&255,g=65535&C,!(_<=l);){if(0===o)break e;o--,c+=r[s++]<>>=_,l-=_,n.lens[n.have++]=g;else{if(16===g){for(S=_+2;l>>=_,l-=_,0===n.have){e.msg="invalid bit length repeat",n.mode=br;break}E=n.lens[n.have-1],f=3+(3&c),c>>>=2,l-=2}else if(17===g){for(S=_+3;l>>=_,l-=_,E=0,f=3+(7&c),c>>>=3,l-=3}else{for(S=_+7;l>>=_,l-=_,E=0,f=11+(127&c),c>>>=7,l-=7}if(n.have+f>n.nlen+n.ndist){e.msg="invalid bit length repeat",n.mode=br;break}for(;f--;)n.lens[n.have++]=E}}if(n.mode===br)break;if(0===n.lens[256]){e.msg="invalid code -- missing end-of-block",n.mode=br;break}if(n.lenbits=9,T={bits:n.lenbits},w=tr(1,n.lens,0,n.nlen,n.lencode,0,n.work,T),n.lenbits=T.bits,w){e.msg="invalid literal/lengths set",n.mode=br;break}if(n.distbits=6,n.distcode=n.distdyn,T={bits:n.distbits},w=tr(2,n.lens,n.nlen,n.ndist,n.distcode,0,n.work,T),n.distbits=T.bits,w){e.msg="invalid distances set",n.mode=br;break}if(n.mode=gr,t===ar)break e;case gr:n.mode=yr;case yr:if(o>=6&&u>=258){e.next_out=i,e.avail_out=u,e.next_in=s,e.avail_in=o,n.hold=c,n.bits=l,Yn(e,d),i=e.next_out,a=e.output,u=e.avail_out,s=e.next_in,r=e.input,o=e.avail_in,c=n.hold,l=n.bits,n.mode===vr&&(n.back=-1);break}for(n.back=0;C=n.lencode[c&(1<>>24,m=C>>>16&255,g=65535&C,!(_<=l);){if(0===o)break e;o--,c+=r[s++]<>y)],_=C>>>24,m=C>>>16&255,g=65535&C,!(y+_<=l);){if(0===o)break e;o--,c+=r[s++]<>>=y,l-=y,n.back+=y}if(c>>>=_,l-=_,n.back+=_,n.length=g,0===m){n.mode=16205;break}if(32&m){n.back=-1,n.mode=vr;break}if(64&m){e.msg="invalid literal/length code",n.mode=br;break}n.extra=15&m,n.mode=16201;case 16201:if(n.extra){for(S=n.extra;l>>=n.extra,l-=n.extra,n.back+=n.extra}n.was=n.length,n.mode=16202;case 16202:for(;C=n.distcode[c&(1<>>24,m=C>>>16&255,g=65535&C,!(_<=l);){if(0===o)break e;o--,c+=r[s++]<>y)],_=C>>>24,m=C>>>16&255,g=65535&C,!(y+_<=l);){if(0===o)break e;o--,c+=r[s++]<>>=y,l-=y,n.back+=y}if(c>>>=_,l-=_,n.back+=_,64&m){e.msg="invalid distance code",n.mode=br;break}n.offset=g,n.extra=15&m,n.mode=16203;case 16203:if(n.extra){for(S=n.extra;l>>=n.extra,l-=n.extra,n.back+=n.extra}if(n.offset>n.dmax){e.msg="invalid distance too far back",n.mode=br;break}n.mode=16204;case 16204:if(0===u)break e;if(f=d-u,n.offset>f){if(f=n.offset-f,f>n.whave&&n.sane){e.msg="invalid distance too far back",n.mode=br;break}f>n.wnext?(f-=n.wnext,p=n.wsize-f):p=n.wnext-f,f>n.length&&(f=n.length),v=n.window}else v=a,p=i-n.offset,f=n.length;f>u&&(f=u),u-=f,n.length-=f;do{a[i++]=v[p++]}while(--f);0===n.length&&(n.mode=yr);break;case 16205:if(0===u)break e;a[i++]=n.length,u--,n.mode=yr;break;case kr:if(n.wrap){for(;l<32;){if(0===o)break e;o--,c|=r[s++]<{if(Cr(e))return ur;let t=e.state;return t.window&&(t.window=null),e.state=null,sr},inflateGetHeader:(e,t)=>{if(Cr(e))return ur;const n=e.state;return 0==(2&n.wrap)?ur:(n.head=t,t.done=!1,sr)},inflateSetDictionary:(e,t)=>{const n=t.length;let r,a,s;return Cr(e)?ur:(r=e.state,0!==r.wrap&&r.mode!==pr?ur:r.mode===pr&&(a=1,a=Tt(a,t,n,0),a!==r.check)?cr:(s=Ur(e,t,n,n),s?(r.mode=16210,lr):(r.havedict=1,sr)))},inflateInfo:"pako inflate (from Nodeca project)"};var Lr=function(){this.text=0,this.time=0,this.xflags=0,this.os=0,this.extra=null,this.extra_len=0,this.name="",this.comment="",this.hcrc=0,this.done=!1};const Dr=Object.prototype.toString,{Z_NO_FLUSH:Pr,Z_FINISH:Fr,Z_OK:Gr,Z_STREAM_END:qr,Z_NEED_DICT:Hr,Z_STREAM_ERROR:jr,Z_DATA_ERROR:zr,Z_MEM_ERROR:Vr}=Mt;function Br(e){this.options=Mn.assign({chunkSize:65536,windowBits:15,to:""},e||{});const t=this.options;t.raw&&t.windowBits>=0&&t.windowBits<16&&(t.windowBits=-t.windowBits,0===t.windowBits&&(t.windowBits=-15)),!(t.windowBits>=0&&t.windowBits<16)||e&&e.windowBits||(t.windowBits+=32),t.windowBits>15&&t.windowBits<48&&0==(15&t.windowBits)&&(t.windowBits|=15),this.err=0,this.msg="",this.ended=!1,this.chunks=[],this.strm=new Rn,this.strm.avail_out=0;let n=Rr.inflateInit2(this.strm,t.windowBits);if(n!==Gr)throw new Error(Nt[n]);if(this.header=new Lr,Rr.inflateGetHeader(this.strm,this.header),t.dictionary&&("string"==typeof t.dictionary?t.dictionary=Un.string2buf(t.dictionary):"[object ArrayBuffer]"===Dr.call(t.dictionary)&&(t.dictionary=new Uint8Array(t.dictionary)),t.raw&&(n=Rr.inflateSetDictionary(this.strm,t.dictionary),n!==Gr)))throw new Error(Nt[n])}function Qr(e,t){const n=new Br(t);if(n.push(e),n.err)throw n.msg||Nt[n.err];return n.result}Br.prototype.push=function(e,t){const n=this.strm,r=this.options.chunkSize,a=this.options.dictionary;let s,i,o;if(this.ended)return!1;for(i=t===~~t?t:!0===t?Fr:Pr,"[object ArrayBuffer]"===Dr.call(e)?n.input=new Uint8Array(e):n.input=e,n.next_in=0,n.avail_in=n.input.length;;){for(0===n.avail_out&&(n.output=new Uint8Array(r),n.next_out=0,n.avail_out=r),s=Rr.inflate(n,i),s===Hr&&a&&(s=Rr.inflateSetDictionary(n,a),s===Gr?s=Rr.inflate(n,i):s===zr&&(s=Hr));n.avail_in>0&&s===qr&&n.state.wrap>0&&0!==e[n.next_in];)Rr.inflateReset(n),s=Rr.inflate(n,i);switch(s){case jr:case zr:case Hr:case Vr:return this.onEnd(s),this.ended=!0,!1}if(o=n.avail_out,n.next_out&&(0===n.avail_out||s===qr))if("string"===this.options.to){let e=Un.utf8border(n.output,n.next_out),t=n.next_out-e,a=Un.buf2string(n.output,e);n.next_out=t,n.avail_out=r-t,t&&n.output.set(n.output.subarray(e,e+t),0),this.onData(a)}else this.onData(n.output.length===n.next_out?n.output:n.output.subarray(0,n.next_out));if(s!==Gr||0!==o){if(s===qr)return s=Rr.inflateEnd(this.strm),this.onEnd(s),this.ended=!0,!0;if(0===n.avail_in)break}}return!0},Br.prototype.onData=function(e){this.chunks.push(e)},Br.prototype.onEnd=function(e){e===Gr&&("string"===this.options.to?this.result=this.chunks.join(""):this.result=Mn.flattenChunks(this.chunks)),this.chunks=[],this.err=e,this.msg=this.strm.msg};var Kr={Inflate:Br,inflate:Qr,inflateRaw:function(e,t){return(t=t||{}).raw=!0,Qr(e,t)},ungzip:Qr,constants:Mt};const{Deflate:Wr,deflate:Yr,deflateRaw:Zr,gzip:Jr}=Kn,{Inflate:Xr,inflate:$r,inflateRaw:ea,ungzip:ta}=Kr;var na,ra={Deflate:Wr,deflate:Yr,deflateRaw:Zr,gzip:Jr,Inflate:Xr,inflate:$r,inflateRaw:ea,ungzip:ta,constants:Mt},aa=function(e){return b(void 0,void 0,void 0,t().mark((function n(){var r;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return r=ra.ungzip(e),t.abrupt("return",String.fromCharCode.apply(null,r));case 2:case"end":return t.stop()}}),n)})))};e.ConnectionState=void 0,(na=e.ConnectionState||(e.ConnectionState={})).CONNECTING="CONNECTING",na.OPEN="OPEN",na.CLOSED="CLOSED";var sa,ia=function(n){i(o,n);var a=f(o);function o(e,t){var n,s=t.sdkState,i=t.dispatcher,u=t.logger;return r(this,o),(n=a.call(this)).lastActive=0,n._iid=e,n._sdkState=s,n._dispatcher=i,n._logger=u,n}return s(o,[{key:"isOpen",get:function(){return this.connectionState===e.ConnectionState.OPEN}},{key:"connectionState",get:function(){if(this._ws)switch(this._ws.readyState){case 0:return e.ConnectionState.CONNECTING;case 1:return e.ConnectionState.OPEN}return e.ConnectionState.CLOSED}},{key:"_handleMessage",value:function(e){var t=this;e.split("\n").forEach((function(e){if(e){var n=qe.createFromRawMessage(t._iid,e);if(t._logger.debug("receive websocket event",n),"LOGI"===n.code)t.dispatch("message",n);else if("PONG"===n.code)t.dispatch("pong");else if("EXPR"===n.code){if(n.payload){var r=new Le(n.payload);r.expiresIn>=0&&t._dispatcher.dispatch(r)}}else"NOOP"===n.code||t.dispatch("message",n)}}))}},{key:"connect",value:function(e){var n=this;this._ws=new WebSocket(e),this._ws.onopen=function(){n._logger.debug("websocket open"),n.dispatch("open")},this._ws.onmessage=function(e){return b(n,void 0,void 0,t().mark((function n(){var r,a,s=this;return t().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:(null===(r=this._sdkState.websocket)||void 0===r?void 0:r.compression)?e.data instanceof Blob?((a=new FileReader).readAsArrayBuffer(e.data),a.onloadend=function(){return b(s,void 0,void 0,t().mark((function e(){var n;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,aa(a.result);case 2:n=e.sent,this._handleMessage(n);case 4:case"end":return e.stop()}}),e,this)})))}):"string"==typeof e.data&&this._handleMessage(e.data):this._handleMessage(e.data);case 1:case"end":return n.stop()}}),n,this)})))},this._ws.onerror=function(){n._logger.debug("websocket error"),n.dispatch("error",A.networkError)},this._ws.onclose=function(){n._logger.debug("websocket close"),n.dispatch("close")},this.lastActive=Date.now()}},{key:"disconnect",value:function(){var t=this;return new Promise((function(n){t._logger.debug("websocket disconnect"),t._ws&&t.connectionState!==e.ConnectionState.CLOSED?(t._ws.onopen=He,t._ws.onmessage=He,t._ws.onerror=He,t._ws.onclose=function(){t.dispatch("close"),n()},t._ws.close(),t._ws=void 0):n()}))}},{key:"send",value:function(e){if(!this._ws)throw A.connectionClosed;"PING"!==e.code?this.dispatch("ping-refresh"):this._logger.debug("send ping",e),this._ws.send(e.convertToMessage())}},{key:"error",value:function(e){this._logger.debug("websocket error",e),this.dispatch("error",e)}}]),o}(se),oa=function(e){i(n,e);var t=f(n);function n(e){var a,s,i=e.code,o=e.ackRequired,u=e.payload,c=void 0===u?{}:u;return r(this,n),(a=t.call(this)).code=i,a.payload=c,a.requestId=null!==(s=a.payload.req_id)&&void 0!==s?s:re(),a.ackRequired=o,a.payload.req_id=a.requestId,a}return s(n,[{key:"convertToMessage",value:function(){return"".concat(this.code).concat(JSON.stringify(this.payload),"\n")}}]),n}(oe),ua=function(e){i(n,e);var t=f(n);function n(e){var a,s=e.all,i=e.custom_types,o=e.ts;return r(this,n),(a=t.call(this)).all=s,a.customTypes=i,a.ts=o,a}return s(n)}(oe),ca=s((function e(){var t=this;r(this,e),this.promise=new Promise((function(e,n){t.resolve=e,t.reject=n}))})),la=function(){function e(t,n){var a=this,s=n.auth,i=n.sdkState,o=n.dispatcher,u=n.logger,c=n.useFetchCompat,l=void 0!==c&&c;r(this,e),this._ackStateMap=new Map,this._sdkState=i,this._dispatcher=o,this._logger=u,this.apiClient=new Ge(t,{auth:s,sdkState:i,dispatcher:o,logger:u,useFetchCompat:l}),this.websocketClient=new ia(t,{sdkState:i,dispatcher:o,logger:u}),this.websocketClient.on("message",(function(e){if(e.payload.unread_cnt&&a._dispatcher.dispatch(new ua(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 A({code:e.payload.code,message:e.payload.message}))}}else a._dispatcher.dispatch(e)})).on("close",(function(){a._ackStateMap.forEach((function(e){e.reject(A.connectionClosed)})),a._ackStateMap.clear()}))}return s(e,[{key:"_sendApiRequest",value:function(e){return b(this,void 0,void 0,t().mark((function n(){return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,this.apiClient.send(e);case 2:return t.abrupt("return",t.sent);case 3:case"end":return t.stop()}}),n,this)})))}},{key:"_sendWebsocketRequest",value:function(e){return b(this,void 0,void 0,t().mark((function n(){var r,a,s,i=this;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(this._sdkState.websocket){t.next=2;break}throw A.connectionRequired;case 2:if(r=new ca,e.ackRequired){s=function(t,n){i._ackStateMap.has(e.requestId)&&(i._ackStateMap.delete(e.requestId),a&&(clearTimeout(a),a=null),t?(i._logger.debug("fail websocket request",t),r.reject(t)):(i._logger.debug("receive websocket ack",e.requestId),r.resolve(n)))};try{a=setTimeout((function(){return s(A.noAckTimeout)}),this._sdkState.websocket.responseTimeout),this._ackStateMap.set(e.requestId,{resolve:function(e){return s(void 0,e)},reject:function(e){return s(e)}}),this.websocketClient.send(e)}catch(e){s(e)}}else try{this.websocketClient.send(e),r.resolve()}catch(e){r.reject(e)}return t.abrupt("return",r.promise);case 5:case"end":return t.stop()}}),n,this)})))}},{key:"send",value:function(e){return b(this,void 0,void 0,t().mark((function n(){return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(!(e instanceof Oe)){t.next=6;break}return t.next=3,this._sendApiRequest(e);case 3:case 9:return t.abrupt("return",t.sent);case 6:if(!(e instanceof oa)){t.next=10;break}return t.next=9,this._sendWebsocketRequest(e);case 10:throw A.invalidParameters;case 11:case"end":return t.stop()}}),n,this)})))}},{key:"cancel",value:function(e){this.apiClient.cancel(e)}},{key:"cancelAll",value:function(){this.apiClient.cancelAll()}}]),e}();!function(e){e[e.NONE=0]="NONE",e[e.INITIALIZED=1]="INITIALIZED",e[e.CONNECTING=2]="CONNECTING",e[e.CONNECTED=3]="CONNECTED",e[e.RECONNECTING=4]="RECONNECTING",e[e.INTERNAL_DISCONNECTED=5]="INTERNAL_DISCONNECTED",e[e.EXTERNAL_DISCONNECTED=6]="EXTERNAL_DISCONNECTED",e[e.LOGOUT=7]="LOGOUT"}(sa||(sa={}));var ha,da=function(e){i(n,e);var t=f(n);function n(e){var a,s=e.stateType;return r(this,n),(a=t.call(this)).stateType=s,a}return s(n)}(oe),fa=function(){function e(n,a){var s=this,i=a.auth,o=a.sdkState,u=a.dispatcher,c=a.logger,l=a.useFetchCompat,h=void 0!==l&&l;r(this,e),this._currentConnectionStateType=sa.INITIALIZED,this._lazyCallQueue=[],this.commandRouter=new la(n,{auth:i,sdkState:o,dispatcher:u,logger:c,useFetchCompat:h}),this._auth=i,this._logger=c,this._dispatcher=u,this._dispatcher.on((function(e){if(e instanceof da){var n=e.stateType;switch(s._currentConnectionStateType=n,n){case sa.CONNECTED:var r=s._lazyCallQueue;s._lazyCallQueue=[],r.forEach((function(e){return b(s,void 0,void 0,t().mark((function n(){var r,a,s,i;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return r=e.command,a=e.deferred,s=e.timeout,clearTimeout(s),t.prev=2,t.next=5,this.send(r);case 5:i=t.sent,a.resolve(i),t.next=12;break;case 9:t.prev=9,t.t0=t.catch(2),a.reject(t.t0);case 12:case"end":return t.stop()}}),n,this,[[2,9]])})))}));break;case sa.INITIALIZED:case sa.INTERNAL_DISCONNECTED:case sa.EXTERNAL_DISCONNECTED:case sa.LOGOUT:var a=s._lazyCallQueue;s._lazyCallQueue=[],a.forEach((function(e){return b(s,void 0,void 0,t().mark((function n(){var r,a;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:r=e.deferred,a=e.timeout,clearTimeout(a),this._auth&&this._auth.hasSession?r.reject(A.connectionClosed):r.reject(A.connectionRequired);case 3:case"end":return t.stop()}}),n,this)})))}))}}}))}return s(e,[{key:"isReady",get:function(){return this._currentConnectionStateType===sa.CONNECTED}},{key:"isLazyCallActivated",get:function(){return this._currentConnectionStateType===sa.CONNECTING||this._currentConnectionStateType===sa.RECONNECTING}},{key:"send",value:function(e){return b(this,void 0,void 0,t().mark((function n(){var r,a,s,i=this;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(!(e instanceof oa)){t.next=19;break}if(!this.isReady){t.next=8;break}return this._logger.debug("send websocket request",e),t.next=5,this.commandRouter.send(e);case 5:case 24:return t.abrupt("return",t.sent);case 8:if(!this.isLazyCallActivated){t.next=15;break}return this._logger.debug("wait websocket request",e),r=new ca,this._lazyCallQueue.push({command:e,deferred:r,timeout:setTimeout((function(){return i.timeout(e.requestId)}),1e4)}),t.abrupt("return",r.promise);case 15:throw this._logger.debug("fail websocket request"),A.connectionRequired;case 17:case 37:t.next=40;break;case 19:if(!(e instanceof Oe)){t.next=39;break}if(!this._auth.hasSession){t.next=27;break}return this._logger.debug("send api request",e),t.next=24,this.commandRouter.send(e);case 27:if(!this.isLazyCallActivated){t.next=34;break}return this._logger.debug("wait api request",e),a=new ca,this._lazyCallQueue.push({command:e,deferred:a,timeout:setTimeout((function(){return i.timeout(e.requestId)}),1e4)}),t.abrupt("return",a.promise);case 34:throw s=A.connectionRequired,this._logger.debug("fail api request",s),s;case 39:throw A.invalidCommand;case 40:case"end":return t.stop()}}),n,this)})))}},{key:"forceSend",value:function(e){return b(this,void 0,void 0,t().mark((function n(){return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return this._logger.debug("send forced request",e),t.next=3,this.commandRouter.send(e);case 3:return t.abrupt("return",t.sent);case 4:case"end":return t.stop()}}),n,this)})))}},{key:"timeout",value:function(e){this._logger.debug("timeout request",e);var t=this._lazyCallQueue.findIndex((function(t){return t.command.requestId===e}));t>-1&&(this._lazyCallQueue[t].deferred.reject(A.connectionRequired),this._lazyCallQueue.splice(t,1))}},{key:"cancel",value:function(e){this._logger.debug("cancel api request",e),this.commandRouter.cancel(e)}},{key:"cancelAll",value:function(){this._logger.debug("cancel all api requests"),this.commandRouter.cancelAll()}}]),e}(),pa="sendbird@devicetokens",va=function(){function e(t){var n=t.type,a=t.token;r(this,e),this.type=n,this.token=a}return s(e,null,[{key:"payloadify",value:function(e){return ue(ce({type:e.type,token:e.token}))}}]),e}(),_a=function(e){i(n,e);var t=f(n);function n(e){var a,s=e.userId,i=e.authToken,o=e.expiringSession,u=void 0===o||o;return r(this,n),(a=t.call(this)).path="".concat(de,"/").concat(s,"/session_key"),a.method=le.POST,a.params={token:i,expiring_session:!!u},a.requireAuth=!1,a}return s(n)}(Oe),ma=function(e){i(n,e);var t=f(n);function n(e){var a=e.authToken,s=e.expiringSession,i=void 0===s||s,o=e.requestId,u=void 0===o?"":o;return r(this,n),t.call(this,{code:"LOGI",payload:{token:a,expiring_session:i?1:0,req_id:u},ackRequired:!0})}return s(n)}(oa),ga=function(e){i(n,e);var t=f(n);function n(e,a){var s;r(this,n),s=t.call(this,e,a);var i=a.key;return s.key=i,s}return s(n)}(Ue),ya=function(e){i(n,e);var t=f(n);function n(e,a,s){var i,o;return r(this,n),(i=t.call(this,e,"LOGI",s)).error=null,i.newKey=null,i.newKey=null!==(o=s.new_key)&&void 0!==o?o:null,i.error=s.error?new A(s.error):null,i}return s(n)}(qe),ka=function(e){i(n,e);var t=f(n);function n(){return r(this,n),t.apply(this,arguments)}return s(n)}(oe),ba=function(e){return b(void 0,void 0,void 0,t().mark((function n(){return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.abrupt("return",new Promise((function(t){return setTimeout(t,e)})));case 1:case"end":return t.stop()}}),n)})))},Ea=function(){function e(){r(this,e)}return s(e,[{key:"calcTimeout",value:function(){return 0}}]),e}(),wa=function(e,n){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:new Ea;return b(void 0,void 0,void 0,t().mark((function a(){var s,i,o,u,c;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:s=0,i=null,o=function(e){return i=null!=e?e:new Error("Halted")},u=function(){s=0};case 4:if(!(-1===n||s=0}},{key:"createRefreshWebsocketCommand",value:function(e,t){return new ma({authToken:e,expiringSession:!0,requestId:t})}},{key:"_refreshSessionKeyByWebSocket",value:function(e){return b(this,void 0,void 0,t().mark((function n(){var r,a,s,i,o;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return r=this.createRefreshWebsocketCommand(e),t.next=3,this._requestQueue.forceSend(r);case 3:if(a=t.sent,s=a.as(ya),i=s.newKey,!(o=s.error)){t.next=7;break}throw o;case 7:this.auth.sessionKey=null!=i?i:this.auth.sessionKey;case 8:case"end":return t.stop()}}),n,this)})))}},{key:"_refreshSessionKeyByApi",value:function(e){return b(this,void 0,void 0,t().mark((function n(){var r,a=this;return t().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return r=new _a({userId:this._sdkState.userId,authToken:e,expiringSession:!0}),n.next=3,wa((function(e){return b(a,void 0,void 0,t().mark((function n(){var a,s,i;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.prev=0,t.next=3,this._requestQueue.forceSend(r);case 3:a=t.sent,s=a.as(ga),i=s.key,this.auth.sessionKey=i,t.next=15;break;case 8:if(t.prev=8,t.t0=t.catch(0),!this._isSessionRelatedError(t.t0)){t.next=14;break}e(t.t0),t.next=15;break;case 14:throw t.t0;case 15:case"end":return t.stop()}}),n,this,[[0,8]])})))}),3);case 3:case"end":return n.stop()}}),n,this)})))}},{key:"_refreshSessionKey",value:function(e){var n=!(arguments.length>1&&void 0!==arguments[1])||arguments[1];return b(this,void 0,void 0,t().mark((function r(){var a,s;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(this._currentConnectionStateType!==sa.CONNECTED){t.next=26;break}return t.prev=1,t.next=4,this._refreshSessionKeyByWebSocket(e);case 4:return this.complete(),t.abrupt("return");case 8:if(t.prev=8,t.t0=t.catch(1),!this._isSessionRelatedError(t.t0)){t.next=26;break}if(!n){t.next=26;break}return t.next=14,this._receiveNewAuthToken();case 14:if(!(a=t.sent)){t.next=22;break}return this.auth.authToken=a,t.next=19,this._refreshSessionKey(this.auth.authToken,!1);case 19:this.complete(),t.next=25;break;case 22:return t.next=24,this.clear();case 24:this.close();case 25:return t.abrupt("return");case 26:return t.prev=26,t.next=29,this._refreshSessionKeyByApi(e);case 29:this.complete(),t.next=55;break;case 32:if(t.prev=32,t.t1=t.catch(26),!this._isSessionRelatedError(t.t1)){t.next=54;break}if(!n){t.next=51;break}return t.next=38,this._receiveNewAuthToken();case 38:if(!(s=t.sent)){t.next=46;break}return this.auth.authToken=s,t.next=43,this._refreshSessionKeyByApi(this.auth.authToken);case 43:this.complete(),t.next=49;break;case 46:return t.next=48,this.clear();case 48:this.close();case 49:t.next=52;break;case 51:throw t.t1;case 52:t.next=55;break;case 54:throw t.t1;case 55:case"end":return t.stop()}}),r,this,[[1,8],[26,32]])})))}},{key:"_receiveNewAuthToken",value:function(){var e=this,n=new ca;return Ca((function(){return b(e,void 0,void 0,t().mark((function e(){var r,a,s=this;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:this._isRefreshingAuthToken=!0,this.auth.clear(),r=null,a=function(){r&&(clearTimeout(r),r=null)},r=setTimeout((function(){s._isRefreshingAuthToken=!1,n.reject()}),1e3*this._sdkState.sessionTokenRefreshTimeout),this.handler.onSessionTokenRequired?this.handler.onSessionTokenRequired((function(e){a(),s._isRefreshingAuthToken&&(s._isRefreshingAuthToken=!1,s.dispatch("refresh-authtoken"),n.resolve(e))}),(function(e){a(),s._isRefreshingAuthToken=!1,n.reject(e)})):n.resolve(null);case 6:case"end":return e.stop()}}),e,this)})))})),n.promise}},{key:"_isSessionRelatedError",value:function(e){return e instanceof A&&(e.isSessionKeyExpiredError||e.isSessionTokenExpiredError||e.isSessionRevokedError)}},{key:"isSessionKeyRefreshing",get:function(){return this._isRefreshingSessionKey}},{key:"isRefreshingAuthToken",get:function(){return this._isRefreshingAuthToken}},{key:"login",value:function(e){var n;return b(this,void 0,void 0,t().mark((function r(){var a,s,i,o,u,c,l;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(a=e.key,s=e.ekey,i=e.userProfile,o=e.deviceTokenLastDeletedAt,u=void 0===o?0:o,this.auth.sessionKey=a,Ta.set(this,s),this._deviceTokenCacheEnabled=null===(n=null==i?void 0:i.appInfo)||void 0===n?void 0:n.deviceTokenCache,c=this._cacheContext.preference,!this._deviceTokenCacheEnabled){t.next=20;break}return t.next=8,c.get(pa);case 8:if((l=t.sent)&&!(l.lastDeletedAt=0&&this._deviceTokens.splice(n,1)}}},{key:"unsetDeviceTokens",value:function(e){this._deviceTokenCacheEnabled&&(this._deviceTokens=e?this._deviceTokens.filter((function(t){return t.type!==e})):[])}},{key:"setDeviceTokenDeletedAt",value:function(e){e>0&&(this._deviceTokenLastDeletedAt=e)}},{key:"saveDeviceToken",value:function(){return b(this,void 0,void 0,t().mark((function e(){var n;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!this._deviceTokenCacheEnabled){e.next=4;break}return n=this._cacheContext.preference,e.next=4,n.set(pa,{tokens:this._deviceTokens,lastDeletedAt:this._deviceTokenLastDeletedAt});case 4:case"end":return e.stop()}}),e,this)})))}},{key:"clear",value:function(){return b(this,void 0,void 0,t().mark((function e(){return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return this.currentUser=null,this.auth.clear(),this.close(),Ta.delete(this),this._deviceTokens=[],this._deviceTokenLastDeletedAt=0,e.next=8,this.saveDeviceToken();case 8:case"end":return e.stop()}}),e,this)})))}}]),a}(se),Ia=function(){function e(){r(this,e),this.type=sa.NONE,this.name="none"}return s(e,[{key:"run",value:function(e){return b(this,void 0,void 0,t().mark((function e(){return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:case"end":return e.stop()}}),e)})))}},{key:"onConnect",value:function(e,n){return b(this,void 0,void 0,t().mark((function e(){return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:case"end":return e.stop()}}),e)})))}},{key:"onReconnect",value:function(e,n){return n.resetReconnectCount,b(this,void 0,void 0,t().mark((function e(){return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:case"end":return e.stop()}}),e)})))}},{key:"onDisconnect",value:function(e,n){return n.error,n.autoReconnect,b(this,void 0,void 0,t().mark((function e(){return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:case"end":return e.stop()}}),e)})))}},{key:"onDisconnectWebSocket",value:function(e){return b(this,void 0,void 0,t().mark((function e(){return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:case"end":return e.stop()}}),e)})))}},{key:"onLogout",value:function(e){return b(this,void 0,void 0,t().mark((function e(){return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:case"end":return e.stop()}}),e)})))}}]),e}(),Na=function(e){i(a,e);var n=f(a);function a(){var e;return r(this,a),(e=n.apply(this,arguments)).type=sa.LOGOUT,e.name="logout",e}return s(a,[{key:"run",value:function(e){return b(this,void 0,void 0,t().mark((function n(){var r,a,s=this;return t().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return r=Date.now(),a=e.sdkState.userId,n.next=4,e.logout();case 4:return n.next=6,e.changeState(new La,r);case 6:Ca((function(){return b(s,void 0,void 0,t().mark((function n(){return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:e.connectionHandlers.forEach((function(e){e.onDisconnected&&e.onDisconnected(a)}));case 1:case"end":return t.stop()}}),n)})))}));case 7:case"end":return n.stop()}}),n)})))}}]),a}(Ia),Ma=function(e){i(a,e);var n=f(a);function a(){var e;return r(this,a),(e=n.call(this)).type=sa.EXTERNAL_DISCONNECTED,e.name="externaldisconnected",e}return s(a,[{key:"run",value:function(e){return b(this,void 0,void 0,t().mark((function n(){return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,e.disconnect();case 2:case"end":return t.stop()}}),n)})))}},{key:"onConnect",value:function(e,n){return b(this,void 0,void 0,t().mark((function r(){var a;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return a=Date.now(),t.next=3,e.disconnect();case 3:return t.next=5,e.changeState(new Ra({authToken:n}),a);case 5:case"end":return t.stop()}}),r)})))}},{key:"onReconnect",value:function(e){return b(this,void 0,void 0,t().mark((function n(){var r;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return r=Date.now(),t.next=3,e.changeState(new Oa,r);case 3:case"end":return t.stop()}}),n)})))}},{key:"onLogout",value:function(e){return b(this,void 0,void 0,t().mark((function n(){var r;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return r=Date.now(),t.next=3,e.changeState(new Na,r);case 3:case"end":return t.stop()}}),n)})))}}]),a}(Ia),Aa=function(e){i(a,e);var n=f(a);function a(e){var t,s=e.autoReconnect;return r(this,a),(t=n.call(this)).type=sa.INTERNAL_DISCONNECTED,t.name="internaldisconnected",t._autoReconnect=!1,t._autoReconnect=s,t}return s(a,[{key:"run",value:function(e){return b(this,void 0,void 0,t().mark((function n(){var r;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return r=Date.now(),t.next=3,e.disconnect();case 3:if(!this._autoReconnect){t.next=6;break}return t.next=6,e.changeState(new Oa,r);case 6:case"end":return t.stop()}}),n,this)})))}},{key:"onConnect",value:function(e,n){return b(this,void 0,void 0,t().mark((function r(){var a;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return a=Date.now(),t.next=3,e.disconnect();case 3:return t.next=5,e.changeState(new Ra({authToken:n}),a);case 5:case"end":return t.stop()}}),r)})))}},{key:"onReconnect",value:function(e){return b(this,void 0,void 0,t().mark((function n(){var r;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return r=Date.now(),t.next=3,e.changeState(new Oa,r);case 3:case"end":return t.stop()}}),n)})))}},{key:"onDisconnectWebSocket",value:function(e){return b(this,void 0,void 0,t().mark((function n(){var r;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return r=Date.now(),t.next=3,e.changeState(new Ma,r);case 3:case"end":return t.stop()}}),n)})))}},{key:"onLogout",value:function(e){return b(this,void 0,void 0,t().mark((function n(){var r;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return r=Date.now(),t.next=3,e.changeState(new Na,r);case 3:case"end":return t.stop()}}),n)})))}}]),a}(Ia),Oa=function(e){i(a,e);var n=f(a);function a(){var e;return r(this,a),(e=n.apply(this,arguments)).type=sa.RECONNECTING,e.name="reconnecting",e._callbacks=[],e}return s(a,[{key:"_halt",value:function(e){this._haltConnect&&(this._haltConnect(e),this._haltConnect=void 0)}},{key:"_flushCallbacks",value:function(e){this._haltConnect=void 0,this._resetConnect=void 0,this._callbacks.forEach((function(t){return t(e)}))}},{key:"run",value:function(e){return b(this,void 0,void 0,t().mark((function n(){var r,a,s,i,o,u=this;return t().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return r=Date.now(),a=new ca,this._callbacks.push((function(e){return e?a.reject(e):a.resolve()})),Ca((function(){return b(u,void 0,void 0,t().mark((function n(){return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:e.connectionHandlers.forEach((function(e){e.onReconnectStarted&&e.onReconnectStarted()}));case 1:case"end":return t.stop()}}),n)})))})),n.prev=4,s=e.sdkState.websocket,i=s.reconnectMaxRetry,o=s.reconnectRetryStrategy,n.next=8,wa((function(n,r){return b(u,void 0,void 0,t().mark((function a(){return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return this._haltConnect=n,this._resetConnect=r,t.prev=2,t.next=5,e.connect();case 5:t.next=17;break;case 7:if(t.prev=7,t.t0=t.catch(2),e.clearLoginTimer(),!(t.t0 instanceof A)){t.next=16;break}t.t1=t.t0.code,t.next=t.t1===E.CONNECTION_CANCELED?14:16;break;case 14:return n(t.t0),t.abrupt("return");case 16:throw t.t0;case 17:case"end":return t.stop()}}),a,this,[[2,7]])})))}),i,o);case 8:return n.next=10,e.changeState(new Ua,r);case 10:Ca((function(){return b(u,void 0,void 0,t().mark((function n(){return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:this._flushCallbacks(),e.connectionHandlers.forEach((function(e){e.onReconnectSucceeded&&e.onReconnectSucceeded()}));case 2:case"end":return t.stop()}}),n,this)})))})),n.next=24;break;case 13:if(n.prev=13,n.t0=n.catch(4),M(n.t0)){n.next=23;break}if(!(n.t0 instanceof A)){n.next=20;break}if(n.t0.code===E.CONNECTION_CANCELED){n.next=20;break}return n.next=20,e.changeState(new Aa({autoReconnect:!1}),r);case 20:Ca((function(){return b(u,void 0,void 0,t().mark((function r(){return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:this._flushCallbacks(n.t0),e.connectionHandlers.forEach((function(e){e.onReconnectFailed&&e.onReconnectFailed()}));case 2:case"end":return t.stop()}}),r,this)})))})),n.next=24;break;case 23:throw n.t0;case 24:return n.abrupt("return",a.promise);case 25:case"end":return n.stop()}}),n,this,[[4,13]])})))}},{key:"onConnect",value:function(e,n){return b(this,void 0,void 0,t().mark((function r(){var a;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return a=new ca,this._halt(A.connectionCanceled),e.cancelConnectForRetry(),this._callbacks.push((function(){var t=Date.now();e.changeState(new Ra({authToken:n}),t).then((function(){a.resolve()})).catch((function(e){a.reject(e)}))})),t.abrupt("return",a.promise);case 5:case"end":return t.stop()}}),r,this)})))}},{key:"onReconnect",value:function(e,n){var r=n.resetReconnectCount,a=void 0!==r&&r;return b(this,void 0,void 0,t().mark((function e(){var n;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n=new ca,this._resetConnect&&a&&this._resetConnect(),this._callbacks.push((function(e){return e?n.reject(e):n.resolve()})),e.abrupt("return",n.promise);case 4:case"end":return e.stop()}}),e,this)})))}},{key:"onDisconnect",value:function(e,n){n.error;var r=n.autoReconnect,a=void 0===r||r;return b(this,void 0,void 0,t().mark((function n(){var r;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return r=Date.now(),this._halt(A.connectionCanceled),t.next=4,e.changeState(new Aa({autoReconnect:a}),r);case 4:case"end":return t.stop()}}),n,this)})))}},{key:"onDisconnectWebSocket",value:function(e){return b(this,void 0,void 0,t().mark((function n(){var r;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return r=Date.now(),this._halt(A.connectionCanceled),t.next=4,e.changeState(new Ma,r);case 4:case"end":return t.stop()}}),n,this)})))}},{key:"onLogout",value:function(e){return b(this,void 0,void 0,t().mark((function n(){var r;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return r=Date.now(),this._halt(A.connectionCanceled),t.next=4,e.changeState(new Na,r);case 4:case"end":return t.stop()}}),n,this)})))}}]),a}(Ia),Ua=function(e){i(a,e);var n=f(a);function a(){var e;return r(this,a),(e=n.apply(this,arguments)).type=sa.CONNECTED,e.name="connected",e}return s(a,[{key:"onReconnect",value:function(e){return b(this,void 0,void 0,t().mark((function n(){var r;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return r=Date.now(),t.next=3,e.disconnect();case 3:return t.next=5,e.changeState(new Oa,r);case 5:case"end":return t.stop()}}),n)})))}},{key:"onDisconnect",value:function(e,n){var r=n.autoReconnect;return b(this,void 0,void 0,t().mark((function n(){var a;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return a=Date.now(),t.next=3,e.changeState(new Aa({autoReconnect:r}),a);case 3:case"end":return t.stop()}}),n)})))}},{key:"onDisconnectWebSocket",value:function(e){return b(this,void 0,void 0,t().mark((function n(){var r;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return r=Date.now(),t.next=3,e.changeState(new Ma,r);case 3:case"end":return t.stop()}}),n)})))}},{key:"onLogout",value:function(e){return b(this,void 0,void 0,t().mark((function n(){var r;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return r=Date.now(),t.next=3,e.changeState(new Na,r);case 3:case"end":return t.stop()}}),n)})))}}]),a}(Ia),Ra=function(e){i(a,e);var n=f(a);function a(e){var t,s=e.authToken;return r(this,a),(t=n.call(this)).type=sa.CONNECTING,t.name="connecting",t._authToken="",t._callbacks=[],t._authToken=s,t}return s(a,[{key:"_halt",value:function(e){this._haltConnect&&(this._haltConnect(e),this._haltConnect=void 0)}},{key:"_flushCallbacks",value:function(e){this._haltConnect=void 0,this._callbacks.forEach((function(t){return t(e)}))}},{key:"run",value:function(e){return b(this,void 0,void 0,t().mark((function n(){var r,a,s=this;return t().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return r=Date.now(),a=new ca,this._callbacks.push((function(e){return e?a.reject(e):a.resolve()})),n.prev=3,n.next=6,wa((function(n){return b(s,void 0,void 0,t().mark((function r(){return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return this._haltConnect=n,t.prev=1,t.next=4,e.connect(this._authToken);case 4:t.next=16;break;case 6:if(t.prev=6,t.t0=t.catch(1),e.clearLoginTimer(),!(t.t0 instanceof A)){t.next=15;break}t.t1=t.t0.code,t.next=t.t1===E.CONNECTION_CANCELED?13:15;break;case 13:return n(t.t0),t.abrupt("return");case 15:throw t.t0;case 16:case"end":return t.stop()}}),r,this,[[1,6]])})))}),e.sdkState.websocket.connectMaxRetry);case 6:return n.next=8,e.changeState(new Ua,r);case 8:Ca((function(){return b(s,void 0,void 0,t().mark((function n(){return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:this._flushCallbacks(),e.connectionHandlers.forEach((function(t){t.onConnected&&t.onConnected(e.sdkState.userId)}));case 2:case"end":return t.stop()}}),n,this)})))})),n.next=24;break;case 11:if(n.prev=11,n.t0=n.catch(3),M(n.t0)){n.next=23;break}return n.next=16,e.disconnect();case 16:if(!(n.t0 instanceof A)){n.next=20;break}if(n.t0.code===E.CONNECTION_CANCELED){n.next=20;break}return n.next=20,e.changeState(new La,r);case 20:Ca((function(){return b(s,void 0,void 0,t().mark((function e(){return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:this._flushCallbacks(n.t0);case 1:case"end":return e.stop()}}),e,this)})))})),n.next=24;break;case 23:throw n.t0;case 24:return n.abrupt("return",a.promise);case 25:case"end":return n.stop()}}),n,this,[[3,11]])})))}},{key:"onConnect",value:function(e){return b(this,void 0,void 0,t().mark((function e(){var n;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n=new ca,this._callbacks.push((function(e){return e?n.reject(e):n.resolve()})),e.abrupt("return",n.promise);case 3:case"end":return e.stop()}}),e,this)})))}},{key:"onDisconnect",value:function(e,n){var r=n.error,a=void 0===r?null:r,s=n.autoReconnect,i=void 0!==s&&s;return b(this,void 0,void 0,t().mark((function n(){var r;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(r=Date.now(),this._halt(null!=a?a:A.connectionCanceled),!e.hasSession){t.next=7;break}return t.next=5,e.changeState(new Aa({autoReconnect:i}),r);case 5:t.next=9;break;case 7:return t.next=9,e.changeState(new Na,r);case 9:case"end":return t.stop()}}),n,this)})))}},{key:"onDisconnectWebSocket",value:function(e){return b(this,void 0,void 0,t().mark((function n(){var r;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(r=Date.now(),this._halt(A.connectionCanceled),!e.hasSession){t.next=7;break}return t.next=5,e.changeState(new Ma,r);case 5:t.next=9;break;case 7:return t.next=9,e.changeState(new Na,r);case 9:case"end":return t.stop()}}),n,this)})))}},{key:"onLogout",value:function(e){return b(this,void 0,void 0,t().mark((function n(){var r;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return r=Date.now(),this._halt(A.connectionCanceled),t.next=4,e.changeState(new Na,r);case 4:case"end":return t.stop()}}),n,this)})))}}]),a}(Ia),La=function(e){i(a,e);var n=f(a);function a(){var e;return r(this,a),(e=n.apply(this,arguments)).type=sa.INITIALIZED,e.name="initialized",e}return s(a,[{key:"onConnect",value:function(e,n){return b(this,void 0,void 0,t().mark((function r(){var a;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return a=Date.now(),t.next=3,e.changeState(new Ra({authToken:n}),a);case 3:case"end":return t.stop()}}),r)})))}}]),a}(Ia),Da=function(e){i(n,e);var t=f(n);function n(){return r(this,n),t.call(this,{code:"PING",payload:{id:Date.now(),active:1},ackRequired:!1})}return s(n)}(oa),Pa=function(){function e(t){var n=t.pingDelegate,a=t.sdkState,s=t.logger;r(this,e),this.pingDelegate=n,this.sdkState=a,this._logger=s}return s(e,[{key:"isWaiting",get:function(){return!!this._pingTimeoutTimer}},{key:"ping",value:function(){var e,t=this;if(!this.sdkState.websocket)throw A.connectionRequired;var n=new Da;try{var r=null!==(e=this.sdkState.websocket.pongTimeout)&&void 0!==e?e:5e3;this._pingTimeoutTimer=setTimeout((function(){t._logger.debug("pinger.ping() timeout"),t.pingDelegate.error()}),r),this.pingDelegate.send(n),this._logger.debug("pinger.ping()")}catch(e){this._logger.debug("pinger.ping() error",e),this._pingTimeoutTimer&&(clearTimeout(this._pingTimeoutTimer),this._pingTimeoutTimer=void 0),this.pingDelegate.error()}return n}},{key:"pong",value:function(){this._logger.debug("pinger.pong()"),this._pingTimeoutTimer&&(clearTimeout(this._pingTimeoutTimer),this._pingTimeoutTimer=void 0)}},{key:"refreshTimer",value:function(){var e,t=this;if(!this.sdkState.websocket)throw A.connectionRequired;this._logger.debug("pinger.refreshTimer()");var n=null!==(e=this.sdkState.websocket.pingInterval)&&void 0!==e?e:15e3;this.stop(),this._pingTimer=setInterval((function(){t.ping()}),n)}},{key:"start",value:function(){this._logger.debug("pinger.start()"),this.refreshTimer(),this.ping()}},{key:"stop",value:function(){this._logger.debug("pinger.stop()"),this._pingTimer&&(clearInterval(this._pingTimer),this._pingTimer=void 0),this._pingTimeoutTimer&&(clearTimeout(this._pingTimeoutTimer),this._pingTimeoutTimer=void 0)}}]),e}(),Fa=function(){function e(t){var n;r(this,e),this.lastUpdatedAt=null!==(n=t.last_updated_at)&&void 0!==n?n:0}return s(e,null,[{key:"payloadify",value:function(e){return ue(ce({last_updated_at:e.lastUpdatedAt}))}}]),e}(),Ga=1048576,qa=function(){function e(){var t,n,a,s,i,o=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};r(this,e),this.emojiHash=o.emoji_hash||"",this.uploadSizeLimit=o.file_upload_size_limit?o.file_upload_size_limit*Ga:Number.MAX_SAFE_INTEGER,this.useReaction=!!o.use_reaction,this.applicationAttributes=null!==(t=o.application_attributes)&&void 0!==t?t:[],this.premiumFeatureList=null!==(n=o.premium_feature_list)&&void 0!==n?n:[],this.deviceTokenCache=this.applicationAttributes.includes("sdk_device_token_cache"),this.enabledChannelMemberShipHistory=this.applicationAttributes.includes("channel_membership_history"),this.multipleFilesMessageFileCountLimit=null!==(a=o.multiple_file_send_max_size)&&void 0!==a?a:5,this.allowSdkStatsUpload=null===(s=o.allow_sdk_log_ingestion)||void 0===s||s,this.uikitConfigInfo=new Fa(null!==(i=o.uikit_config)&&void 0!==i?i:{})}return s(e,null,[{key:"payloadify",value:function(e){return ue(ce({emoji_hash:e.emojiHash,file_upload_size_limit:e.uploadSizeLimit/Ga,application_attributes:e.applicationAttributes,premium_feature_list:e.premiumFeatureList,use_reaction:e.useReaction,allow_sdk_log_ingestion:e.allowSdkStatsUpload,uikit_config:e.uikitConfigInfo?Fa.payloadify(e.uikitConfigInfo):null}))}}]),e}(),Ha=function(){function e(t){r(this,e),this._iid="",this._iid=t}return s(e,null,[{key:"payloadify",value:function(e){return{}}}]),e}(),ja=function(e){i(n,e);var t=f(n);function n(e){var a,s=e.userId,i=e.metadata;return r(this,n),(a=t.call(this)).method=le.POST,a.path="".concat(de,"/").concat(s,"/metadata"),a.params={metadata:i},a}return s(n)}(Oe),za=function(e){i(n,e);var t=f(n);function n(e,a){var s;return r(this,n),(s=t.call(this,e,a)).metaData=a,s}return s(n)}(Ue),Va=function(e){i(n,e);var t=f(n);function n(e){var a,s=e.userId,i=e.metadata,o=e.upsert;return r(this,n),(a=t.call(this)).method=le.PUT,a.path="".concat(de,"/").concat(s,"/metadata"),a.params={metadata:i,upsert:o},a}return s(n)}(Oe),Ba=function(e){i(n,e);var t=f(n);function n(e,a){var s;return r(this,n),(s=t.call(this,e,a)).metadata=a,s}return s(n)}(Ue),Qa=function(e){i(n,e);var t=f(n);function n(e){var a,s=e.userId,i=e.metadataKey;return r(this,n),(a=t.call(this)).method=le.DELETE,a.path="".concat(de,"/").concat(s,"/metadata/").concat(i),a}return s(n)}(Oe),Ka=function(e){i(n,e);var t=f(n);function n(e){var a,s=e.userId;return r(this,n),(a=t.call(this)).method=le.DELETE,a.path="".concat(de,"/").concat(s,"/metadata"),a}return s(n)}(Oe),Wa=function(e,t){var n=JSON.parse(JSON.stringify(e));return n._iid&&delete n._iid,t&&t(n),n},Ya=function(e,t){var n=JSON.parse(JSON.stringify(e));return t&&t(n),n},Za=function(e){return{do:function(t){e||t()},throw:function(t){if(!e)throw t}}};e.UserOnlineState=void 0,(ha=e.UserOnlineState||(e.UserOnlineState={})).ONLINE="online",ha.OFFLINE="offline",ha.NON_AVAILABLE="nonavailable";var Ja,Xa=function(n){i(u,n);var a=f(u);function u(t,n){var s,i,o,c,l,h,d,f,p,v,m,g,y;return r(this,u),(s=a.call(this,t)).userId=null!==(o=null!==(i=n.guest_id)&&void 0!==i?i:n.user_id)&&void 0!==o?o:"",s.nickname=null!==(l=null!==(c=n.nickname)&&void 0!==c?c:n.name)&&void 0!==l?l:"",s.plainProfileUrl=null!==(d=null!==(h=n.profile_url)&&void 0!==h?h:n.image)&&void 0!==d?d:"",s.requireAuth=null!==(f=n.require_auth_for_profile_image)&&void 0!==f&&f,s.metaData=null!==(p=n.metadata)&&void 0!==p?p:{},s.connectionStatus=e.UserOnlineState.NON_AVAILABLE,D(e.UserOnlineState,n.is_online)?s.connectionStatus=n.is_online:L("boolean",n.is_online)&&(s.connectionStatus=n.is_online?e.UserOnlineState.ONLINE:e.UserOnlineState.OFFLINE),s.isActive=null===(v=n.is_active)||void 0===v||v,s.lastSeenAt=null!==(m=n.last_seen_at)&&void 0!==m?m:null,s.preferredLanguages=n.preferred_languages?_(n.preferred_languages):null,s.friendDiscoveryKey=null!==(g=n.friend_discovery_key)&&void 0!==g?g:null,s.friendName=null!==(y=n.friend_name)&&void 0!==y?y:null,s}return s(u,[{key:"profileUrl",get:function(){var e=fs.of(this._iid).sessionManager;return this.requireAuth?"".concat(this.plainProfileUrl,"?auth=").concat(e.ekey):this.plainProfileUrl}},{key:"serialize",value:function(){return Wa(this)}},{key:"_isValidMetaData",value:function(e){return!Array.isArray(e)&&Object.keys(e).length>0&&Object.keys(e).map((function(t){return e[t]})).every((function(e){return L("string",e)}))}},{key:"_applyMetaData",value:function(e){var t=this,n=arguments.length>1&&void 0!==arguments[1]&&arguments[1];Object.keys(e).forEach((function(r){n?delete t.metaData[r]:t.metaData[r]=e[r]}))}},{key:"createMetaData",value:function(e){return b(this,void 0,void 0,t().mark((function n(){var r,a,s,i,o,u,c;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return Za(this._isValidMetaData(e)).throw(A.invalidParameters),r=fs.of(this._iid),a=r.sdkState,s=r.requestQueue,i=new ja({userId:a.userId,metadata:e}),t.next=5,s.send(i);case 5:return o=t.sent,u=o.as(za),c=u.metaData,this._applyMetaData(c),t.abrupt("return",this.metaData);case 9:case"end":return t.stop()}}),n,this)})))}},{key:"updateMetaData",value:function(e){var n=arguments.length>1&&void 0!==arguments[1]&&arguments[1];return b(this,void 0,void 0,t().mark((function r(){var a,s,i,o,u,c,l;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return Za(this._isValidMetaData(e)).throw(A.invalidParameters),a=fs.of(this._iid),s=a.sdkState,i=a.requestQueue,o=new Va({userId:s.userId,metadata:e,upsert:n}),t.next=5,i.send(o);case 5:return u=t.sent,c=u.as(Ba),l=c.metadata,this._applyMetaData(l),t.abrupt("return",this.metaData);case 9:case"end":return t.stop()}}),r,this)})))}},{key:"deleteMetaData",value:function(e){return b(this,void 0,void 0,t().mark((function n(){var r,a,s,i;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return Za(L("string",e)).throw(A.invalidParameters),r=fs.of(this._iid),a=r.sdkState,s=r.requestQueue,i=new Qa({userId:a.userId,metadataKey:e}),t.next=5,s.send(i);case 5:return this._applyMetaData((n={},u=!0,(o=k(o=e))in n?Object.defineProperty(n,o,{value:u,enumerable:!0,configurable:!0,writable:!0}):n[o]=u,n),!0),t.abrupt("return",this.metaData);case 7:case"end":return t.stop()}var n,o,u}),n,this)})))}},{key:"deleteAllMetaData",value:function(){return b(this,void 0,void 0,t().mark((function e(){var n,r,a,s;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n=fs.of(this._iid),r=n.sdkState,a=n.requestQueue,s=new Ka({userId:r.userId}),e.next=4,a.send(s);case 4:this.metaData={};case 5:case"end":return e.stop()}}),e,this)})))}}],[{key:"payloadify",value:function(e){return ue(ce(Object.assign(Object.assign({},p(o(u),"payloadify",this).call(this,e)),{user_id:e.userId,nickname:e.nickname,profile_url:e.plainProfileUrl,require_auth_for_profile_image:e.requireAuth,metadata:e.metaData,is_online:e.connectionStatus,is_active:e.isActive,last_seen_at:e.lastSeenAt,preferred_languages:e.preferredLanguages,friend_discovery_key:e.friendDiscoveryKey,friend_name:e.friendName})))}}]),u}(Ha),$a=function(e){i(n,e);var t=f(n);function n(e){var a,s=e.userProfile;return r(this,n),(a=t.call(this)).userProfile=s,a}return s(n)}(oe),es=function(){function e(t,n){var a,s,i,o,u,c,l,h,d,f,p,v,_,m;r(this,e),this._iid=t,this.appInfo=new qa(n),this.user=new Xa(t,n),this.connectedAt=null!==(a=n.login_ts)&&void 0!==a?a:0,this.firstConnectedAt=0,this.pingInterval=null!==(s=n.ping_interval)&&void 0!==s?s:15e3,this.pongTimeout=null!==(i=n.pong_timeout)&&void 0!==i?i:5e3,this.reconnectInterval=null!==(u=null===(o=n.reconnect)||void 0===o?void 0:o.interval)&&void 0!==u?u:3e3,this.reconnectMaxInterval=null!==(l=null===(c=n.reconnect)||void 0===c?void 0:c.max_interval)&&void 0!==l?l:6e4,this.reconnectRetryCount=null!==(d=null===(h=n.reconnect)||void 0===h?void 0:h.retry_cnt)&&void 0!==d?d:5,this.reconnectIntervalMultiple=null!==(p=null===(f=n.reconnect)||void 0===f?void 0:f.mul)&&void 0!==p?p:2,this.maxUnreadCountOnSuperGroup=null!==(v=n.max_unread_cnt_on_super_group)&&void 0!==v?v:100,this.profileImageEncryption=!!n.profile_image_encryption,this.concurrentCallLimit=null!==(_=n.concurrent_call_limit)&&void 0!==_?_:5,this.backOffDelay=null!==(m=n.back_off_delay)&&void 0!==m?m:100}return s(e,[{key:"apply",value:function(){var e=this.reconnectInterval,t=this.reconnectMaxInterval,n=this.reconnectIntervalMultiple,r=fs.of(this._iid);r.sdkState.websocket&&(r.sdkState.websocket.pingInterval=1e3*this.pingInterval,r.sdkState.websocket.pongTimeout=1e3*this.pongTimeout,r.sdkState.websocket.reconnectMaxRetry=this.reconnectRetryCount,r.sdkState.websocket.reconnectRetryStrategy={calcTimeout:function(r){return r>0?1e3*Math.min(e*Math.pow(n,r-1),t):10}}),r.appInfo=this.appInfo,r.sessionManager.currentUser=this.user,r.connectedAt=this.connectedAt,this.firstConnectedAt||(r.firstConnectedAt=this.connectedAt),r.maxSuperGroupChannelUnreadCount=this.maxUnreadCountOnSuperGroup,r.concurrentCallLimit=this.concurrentCallLimit,r.backOffDelay=this.backOffDelay,r.dispatcher.dispatch(new $a({userProfile:this}))}}],[{key:"payloadify",value:function(e){return ue(ce(Object.assign(Object.assign(Object.assign({},Xa.payloadify(e.user)),qa.payloadify(e.appInfo)),{login_ts:e.connectedAt,ping_interval:e.pingInterval,pong_timeout:e.pongTimeout,reconnect:{interval:e.reconnectInterval,max_interval:e.reconnectMaxInterval,retry_cnt:e.reconnectRetryCount,mul:e.reconnectIntervalMultiple},max_unread_cnt_on_super_group:e.maxUnreadCountOnSuperGroup,profile_image_encryption:e.profileImageEncryption,concurrent_call_limit:e.concurrentCallLimit,back_off_delay:e.backOffDelay})))}}]),e}(),ts=function(e){i(a,e);var n=f(a);function a(e,t,s){var i,o,u,c;return r(this,a),(i=n.call(this,e,t,s)).error=null,i.userProfile=new es(e,s),i.deviceTokenLastDeletedAt=null!==(o=s.device_token_last_deleted_at)&&void 0!==o?o:0,i.key=null!==(u=s.key)&&void 0!==u?u:"",i.ekey=null!==(c=s.ekey)&&void 0!==c?c:"",i.error=s.error?new A(s):null,i}return s(a,[{key:"applyTo",value:function(e){return b(this,void 0,void 0,t().mark((function n(){var r,a;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(this.error){t.next=12;break}if(!(r=fs.of(e))){t.next=9;break}return a=r.sessionManager,t.next=6,a.login(this);case 6:this.userProfile.apply(),t.next=10;break;case 9:throw A.lostInstance;case 10:t.next=13;break;case 12:throw this.error;case 13:case"end":return t.stop()}}),n,this)})))}}],[{key:"asError",value:function(e){return new a("","LOGI",Object.assign({user_id:"",error:!0},e))}}]),a}(qe),ns=function(e){i(n,e);var t=f(n);function n(e){var a,s=e.request,i=void 0===s||s,o=e.features,u=void 0===o?{}:o,c=e.options,l=void 0===c?{}:c;return r(this,n),(a=t.call(this)).request=i,a.features=Object.assign({localCache:!0},u),a.options=Object.assign({ingestion:!0},l),a}return s(n)}(oe),rs=function(e){i(a,e);var n=f(a);function a(e,t){var s,i,o=t.sdkState,u=t.cacheContext,c=t.connectionHandlers,l=t.sessionManager,h=t.websocketClient,d=t.dispatcher,f=t.logger,p=t.entryState,v=void 0===p?new La:p;return r(this,a),(s=n.call(this))._stateUpdatedAt=0,s._connectingAt=0,s._connectionRequestQueue=[],s._iid=e,s.sdkState=o,s.cacheContext=u,s.connectionHandlers=c,s._sessionManager=l,s._websocketClient=h,s._dispatcher=d,s._logger=f,s._currentState=v,(null===(i=s.sdkState.websocket)||void 0===i?void 0:i.pingerDisabled)||(s._pinger=new Pa({pingDelegate:{send:function(e){return s._websocketClient.send(e)},error:function(e){return s._websocketClient.error(e)}},sdkState:s.sdkState,logger:f})),s._websocketClient.on("open",(function(){s._tryResolveConnectionRequest()})).on("message",(function(e){if("LOGI"===e.code)s.clearLoginTimer(),s._dispatcher.dispatch(e.as(ts))})).on("ping-refresh",(function(){var e;return null===(e=s._pinger)||void 0===e?void 0:e.refreshTimer()})).on("pong",(function(){var e;return null===(e=s._pinger)||void 0===e?void 0:e.pong()})).on("error",(function(){var e;return null===(e=s._pinger)||void 0===e?void 0:e.stop()})).on("close",(function(){s._logiProcessingTimer=setTimeout((function(){s._logiProcessingTimer=void 0,s._unresolvedLogi||s._rejectConnectionRequest(A.networkError)}),500)})),s._dispatcher.on((function(e){e instanceof ts&&(s._unresolvedLogi=e,s._tryResolveConnectionRequest())})),s}return s(a,[{key:"currentState",get:function(){return this._currentState}},{key:"hasSession",get:function(){return this._sessionManager.auth.hasSession}},{key:"changeState",value:function(e,n){return b(this,void 0,void 0,t().mark((function r(){return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(!(n>=this._stateUpdatedAt)){t.next=8;break}return this._currentState=e,this._stateUpdatedAt=n,this._dispatcher.dispatch(new da({stateType:e.type})),this._logger.debug("connection state changes to ".concat(e.name)),t.next=7,this._currentState.run(this);case 7:return t.abrupt("return",!0);case 8:return t.abrupt("return",!1);case 9:case"end":return t.stop()}}),r,this)})))}},{key:"_tryResolveConnectionRequest",value:function(){var e;return b(this,void 0,void 0,t().mark((function n(){var r,a;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(r=this._unresolvedLogi,!this._websocketClient.isOpen||!r){t.next=18;break}if(this._unresolvedLogi=void 0,r.error){t.next=15;break}return t.next=6,r.applyTo(this._iid);case 6:a=r.userProfile,this._enableStatLog({request:a.appInfo.applicationAttributes.includes("allow_sdk_request_log_publish"),features:{localCache:a.appInfo.applicationAttributes.includes("allow_sdk_feature_local_cache_log_publish")},options:{ingestion:a.appInfo.allowSdkStatsUpload}}),this._statLogConnection(),null===(e=this._pinger)||void 0===e||e.start(),this._connectionRequestQueue.forEach((function(e){return e.resolve()})),this._connectionRequestQueue=[],this.sdkState.appState="foreground",t.next=18;break;case 15:this._sessionManager.auth.authToken=void 0,(r.error.isSessionKeyExpiredError||r.error.isSessionTokenExpiredError)&&this._dispatcher.dispatch(new Le({reason:r.error.code})),this._rejectConnectionRequest(r.error);case 18:case"end":return t.stop()}}),n,this)})))}},{key:"_rejectConnectionRequest",value:function(e){var t;if(null===(t=this._pinger)||void 0===t||t.stop(),this.clearLoginTimer(),this._connectionRequestQueue.length>0){var n=this._connectionRequestQueue;this._connectionRequestQueue=[],n.forEach((function(t){return t.reject(e)})),this._statLogConnection(e)}}},{key:"_url",value:function(){var e,t,n,r=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"",a=this.sdkState,s=a.appId,i=a.appVersion,o=a.userId;a.extensions;var u=this.cacheContext.localCacheEnabled,c=this._sessionManager.auth,l=null===(e=this.sdkState.websocket)||void 0===e?void 0:e.compression,h=null!==(t=this.sdkState.extensions)&&void 0!==t?t:{},d=!!h.sb_uikit,f=h.sb_syncmanager?"s".concat(h.sb_syncmanager):"",p=h.sb_uikit?"u".concat(h.sb_uikit):"",v="JS/c".concat(C.SDK_VERSION,"/").concat(f,"/").concat(p);return"".concat(null===(n=this.sdkState.websocket)||void 0===n?void 0:n.host,"/?p=JS&pv=").concat(encodeURIComponent(C.OS_VERSION),"&sv=").concat(encodeURIComponent(C.SDK_VERSION),"&ai=").concat(s).concat(i?"&av=".concat(i):"").concat(c.hasSession?"&key=".concat(encodeURIComponent(c.sessionKey)):"&user_id=".concat(encodeURIComponent(o),"&access_token=").concat(encodeURIComponent(r)),"&pmce=").concat(l?1:0,"&active=1&device_token_types=").concat(encodeURIComponent(["gcm","huawei","apns"].join(",")),"&SB-User-Agent=").concat(v,"&Request-Sent-Timestamp=").concat(Date.now().toString(),"&include_extra_data=").concat(encodeURIComponent(String(["premium_feature_list","file_upload_size_limit","application_attributes","emoji_hash","multiple_file_send_max_size"]))).concat(this._sessionManager.handler?"&expiring_session=1":"","&use_local_cache=").concat(u?1:0,"&include_poll_details=1").concat(d?"&uikit_config=1":"")}},{key:"_enableStatLog",value:function(e){var t=e.request,n=e.features,r=e.options,a=void 0===r?{}:r;this._dispatcher.dispatch(new ns({request:t,features:n,options:a}))}},{key:"_statLogConnection",value:function(e){var t;this._dispatcher.dispatch(new De(new Pe({type:Ae.WEBSOCKET_CONNECT,data:{host_url:null===(t=this.sdkState.websocket)||void 0===t?void 0:t.host,success:!e,latency:Date.now()-this._connectingAt,error_code:null==e?void 0:e.code,error_description:null==e?void 0:e.message}})))}},{key:"connect",value:function(){var e,n=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"";return b(this,void 0,void 0,t().mark((function r(){var a,s,i=this;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return this._logiProcessingTimer&&(clearTimeout(this._logiProcessingTimer),this._logiProcessingTimer=void 0,this._rejectConnectionRequest(A.connectionCanceled)),a=this._url(n),s=new ca,this._connectionRequestQueue.push(s),1===this._connectionRequestQueue.length&&(this._connectingAt=Date.now(),this._loginTimer=setTimeout((function(){i._loginTimer=void 0,i._rejectConnectionRequest(A.loginTimeout)}),null===(e=this.sdkState.websocket)||void 0===e?void 0:e.responseTimeout),n&&(this._sessionManager.auth.authToken=n),this._websocketClient.connect(a)),t.abrupt("return",s.promise);case 6:case"end":return t.stop()}}),r,this)})))}},{key:"cancelConnectForRetry",value:function(){this._dispatcher.dispatch(ts.asError(A.connectionRenew))}},{key:"disconnect",value:function(){return b(this,void 0,void 0,t().mark((function e(){return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this._websocketClient.disconnect();case 2:case"end":return e.stop()}}),e,this)})))}},{key:"logout",value:function(){return b(this,void 0,void 0,t().mark((function e(){return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return this.sdkState.userId=void 0,this._unresolvedLogi=void 0,e.next=4,this._sessionManager.clear();case 4:return e.next=6,this.disconnect();case 6:case"end":return e.stop()}}),e,this)})))}},{key:"clearLoginTimer",value:function(){this._loginTimer&&(clearTimeout(this._loginTimer),this._loginTimer=void 0)}}]),a}(se),as=function(){function e(t,n){var a=n.sdkState,s=n.cacheContext,i=n.connectionHandlers,o=n.sessionManager,u=n.websocketClient,c=n.dispatcher,l=n.logger,h=n.disableWebSocketCloseEventHandling,d=void 0!==h&&h;r(this,e),this._disableWebSocketCloseEventHandling=!1,this._externalCalledWebSocketClose=!1,this._logger=l,this._disableWebSocketCloseEventHandling=d,this._context=new rs(t,{sdkState:a,cacheContext:s,connectionHandlers:i,sessionManager:o,websocketClient:u,dispatcher:c,logger:l}),this._sdkState=a,this._sessionManager=o,this._websocketClient=u}return s(e,[{key:"_registerEventDispatcher",value:function(){var e=this;this._disableWebSocketCloseEventHandling||(this._clearEventDispatcher(),this._sessionEventDispatcherContext=this._sessionManager.on("refresh-authtoken",(function(){e.isConnected||(e._logger.debug("try reconnect by session token refresh"),e.reconnect())})).on("refresh",(function(){e.isConnecting||e.isConnected||(e._logger.debug("try reconnect by session key refresh"),e.reconnect())})),this._websocketEventDispatcherContext=this._websocketClient.on("close",(function(){"foreground"!==e._sdkState.appState||e._externalCalledWebSocketClose||e._sessionManager.isRefreshingAuthToken||(e._logger.debug("try reconnect by websocket connection closed"),e.reconnect())})))}},{key:"_clearEventDispatcher",value:function(){this._sessionEventDispatcherContext&&(this._sessionEventDispatcherContext.close(),this._sessionEventDispatcherContext=void 0),this._websocketEventDispatcherContext&&(this._websocketEventDispatcherContext.close(),this._websocketEventDispatcherContext=void 0)}},{key:"isConnected",get:function(){return this._context.currentState.type===sa.CONNECTED}},{key:"isConnecting",get:function(){var e=this._context.currentState;return e.type===sa.CONNECTING||e.type===sa.RECONNECTING}},{key:"connect",value:function(e){return b(this,void 0,void 0,t().mark((function n(){var r;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return r=this._context.currentState,this._externalCalledWebSocketClose=!1,t.next=4,r.onConnect(this._context,e);case 4:this._registerEventDispatcher();case 5:case"end":return t.stop()}}),n,this)})))}},{key:"reconnect",value:function(){return b(this,void 0,void 0,t().mark((function e(){var n;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n=this._context.currentState,this._externalCalledWebSocketClose=!1,e.next=4,n.onReconnect(this._context,{});case 4:case"end":return e.stop()}}),e,this)})))}},{key:"resetAndReconnect",value:function(){return b(this,void 0,void 0,t().mark((function e(){var n;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n=this._context.currentState,this._externalCalledWebSocketClose=!1,e.next=4,n.onReconnect(this._context,{resetReconnectCount:!0});case 4:case"end":return e.stop()}}),e,this)})))}},{key:"background",value:function(){return b(this,void 0,void 0,t().mark((function e(){var n;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n=this._context.currentState,this._externalCalledWebSocketClose=!0,e.next=4,n.onDisconnect(this._context,{autoReconnect:!1});case 4:case"end":return e.stop()}}),e,this)})))}},{key:"disconnect",value:function(e){return b(this,void 0,void 0,t().mark((function n(){var r;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return r=this._context.currentState,t.next=3,r.onDisconnect(this._context,{error:e,autoReconnect:!0});case 3:case"end":return t.stop()}}),n,this)})))}},{key:"disconnectWebSocket",value:function(){return b(this,void 0,void 0,t().mark((function e(){var n;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n=this._context.currentState,this._externalCalledWebSocketClose=!0,e.next=4,n.onDisconnectWebSocket(this._context);case 4:case"end":return e.stop()}}),e,this)})))}},{key:"logout",value:function(){return b(this,void 0,void 0,t().mark((function e(){var n;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n=this._context.currentState,this._clearEventDispatcher(),e.next=4,n.onLogout(this._context);case 4:case"end":return e.stop()}}),e,this)})))}}]),e}(),ss=function(e){i(n,e);var t=f(n);function n(e){var a,s,i,o,u,c=e.type,l=e.data,h=e.ts,d=void 0===h?Date.now():h;return r(this,n),(a=t.call(this,{type:c,data:l,ts:d})).date=new Date(d),a.key="".concat((s=a.date,i=s.getFullYear(),o=String(s.getMonth()+1).padStart(2,"0"),u=String(s.getDate()).padStart(2,"0"),"".concat(i).concat(o).concat(u)),"_").concat(c),a}return s(n)}(Pe),is=function(e){i(n,e);var t=f(n);function n(e){var a,s=e.deviceId,i=e.statLogs;return r(this,n),(a=t.call(this)).method=le.POST,a.path="".concat(xe),a.params={device_id:s,log_entries:i.map((function(e){return Pe.payloadify(e)}))},a}return s(n)}(Oe),os=function e(t,r){if(null!==t&&null!==r){var a,s=Object.keys(t),i=Object.keys(r),o={},u=y(_(new Set([].concat(s,i))));try{for(u.s();!(a=u.n()).done;){var c=a.value,l=n(t[c]),h=n(r[c]);"undefined"===l?o[c]=r[c]:"undefined"===h?o[c]=t[c]:l!==h?o[c]=r[c]:"object"===l&&t[c]&&r[c]?o[c]=e(t[c],r[c]):o[c]=r[c]}}catch(e){u.e(e)}finally{u.f()}return o}return r};!function(e){e[e.PENDING=0]="PENDING",e[e.COLLECT_ONLY=1]="COLLECT_ONLY",e[e.ENABLED=2]="ENABLED",e[e.DISABLED=3]="DISABLED"}(Ja||(Ja={}));var us,cs=function(e){i(a,e);var n=f(a);function a(e){var t,s=e.cacheContext,i=e.requestQueue,o=e.dispatcher,u=e.baseLimit,c=void 0===u?100:u,l=e.maxLimit,h=void 0===l?1e3:l,d=e.minLimit,f=void 0===d?10:d;return r(this,a),(t=n.call(this)).queue=[],t.enabledState=Ja.PENDING,t.isFlushing=!1,t.generation=1,t.lastFlushedAt=0,t._collectRequestStat=!0,t._collectFeatureLocalCacheStat=!0,t.deviceId=re(),t.cacheContext=s,t.requestQueue=i,t.dispatcher=o,t.baseLimit=c,t.limit=c,t.maxLimit=h,t.minLimit=f,t}return s(a,[{key:"isEnabled",get:function(){return this.enabledState===Ja.ENABLED}},{key:"_arrangeStat",value:function(){var e=[];this._collectRequestStat&&e.push.apply(e,_(this.queue.filter((function(e){return e.type===Ae.API_RESULT||e.type===Ae.WEBSOCKET_CONNECT})))),this._collectFeatureLocalCacheStat&&e.push.apply(e,_(this.queue.filter((function(e){return e.type===Ae.FEATURE_LOCALCACHE})))),this.queue=e}},{key:"_save",value:function(){return b(this,void 0,void 0,t().mark((function e(){return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(this.enabledState!==Ja.ENABLED){e.next=4;break}return e.next=3,this.cacheContext.preference.set(this.key,{deviceId:this.deviceId,statLogs:this.queue.map((function(e){return Pe.payloadify(e)})),generation:this.generation++,lastFlushedAt:this.lastFlushedAt});case 3:this.dispatch("save",_(this.queue));case 4:case"end":return e.stop()}}),e,this)})))}},{key:"_flush",value:function(){return b(this,void 0,void 0,t().mark((function e(){var n,r,a,s;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!this.isEnabled){e.next=34;break}if(this.isFlushing){e.next=34;break}if(this.isFlushing=!0,e.prev=3,this._arrangeStat(),n=this.queue.filter((function(e){if(e instanceof ss){var t=new Date,n=[e.date.getFullYear(),t.getFullYear()],r=n[0],a=n[1];if(r0)){e.next=16;break}return s=new is({deviceId:this.deviceId,statLogs:a}),e.next=12,this.requestQueue.send(s);case 12:return this.dispatch("flush",a),this.queue=[].concat(_(n),_(r)).slice(a.length),e.next=16,this._save();case 16:this.limit=this.baseLimit,this.lastFlushedAt=Date.now(),e.next=31;break;case 20:if(e.prev=20,e.t0=e.catch(3),!(e.t0 instanceof A)){e.next=30;break}if(e.t0.code!==E.STAT_LOG_NOT_ALLOWED){e.next=29;break}return e.next=26,this.clear();case 26:this.enabledState=Ja.DISABLED,e.next=30;break;case 29:e.t0.code===E.STAT_UPLOAD_NOT_ALLOWED&&(this.enabledState=Ja.COLLECT_ONLY);case 30:this.limit=this.limit+20;case 31:return e.prev=31,this.isFlushing=!1,e.finish(31);case 34:case"end":return e.stop()}}),e,this,[[3,20,31,34]])})))}},{key:"init",value:function(e){return b(this,void 0,void 0,t().mark((function n(){var r,a,s=this;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return this.key=e,t.next=3,this.cacheContext.preference.get(this.key);case 3:if(!(r=t.sent)){t.next=15;break}if(this.deviceId=r.deviceId,this.queue=r.statLogs.map((function(e){return new Pe({type:e.stat_type,ts:e.ts,data:e.data})})),this.generation=r.generation,this.lastFlushedAt=r.lastFlushedAt,!(Date.now()-this.lastFlushedAt>=108e5&&this.queue.length>=this.minLimit)){t.next=15;break}return a=Math.min(Math.floor(18e4*Math.random()),100),t.next=13,ba(a);case 13:return t.next=15,this._flush();case 15:this.commandEventContext||(this.commandEventContext=this.dispatcher.on((function(e){if(e instanceof De){var t=e.statLog;s.put(t)}else if(e instanceof ns){var n=e.request,r=e.features,a=e.options;s._collectRequestStat=n,s._collectFeatureLocalCacheStat=null==r?void 0:r.localCache,s._arrangeStat(),s._collectRequestStat||s._collectFeatureLocalCacheStat?s.enabledState=a.ingestion?Ja.ENABLED:Ja.COLLECT_ONLY:s.enabledState=Ja.DISABLED,s.isEnabled?s.queue.length>=s.limit&&s._flush():s.clear()}})));case 16:case"end":return t.stop()}}),n,this)})))}},{key:"put",value:function(e){return b(this,void 0,void 0,t().mark((function n(){var r,a,s;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(this.enabledState===Ja.DISABLED){t.next=7;break}return e instanceof ss?this._collectFeatureLocalCacheStat&&(r=this.queue.filter((function(t){return t instanceof ss&&t.key===e.key})),a=v(r,1),(s=a[0])?s.data=os(s.data,e.data):this.queue.push(e)):this._collectRequestStat&&this.queue.push(e),t.next=4,this._save();case 4:if(!(this.queue.length>=this.limit)){t.next=7;break}return t.next=7,this._flush();case 7:case"end":return t.stop()}}),n,this)})))}},{key:"clear",value:function(){return b(this,void 0,void 0,t().mark((function e(){return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return this.queue=[],this.generation=1,e.next=4,this._save();case 4:case"end":return e.stop()}}),e,this)})))}},{key:"close",value:function(){this.commandEventContext&&(this.commandEventContext.close(),this.commandEventContext=void 0)}}]),a}(se);e.LogLevel=void 0,(us=e.LogLevel||(e.LogLevel={}))[us.NONE=0]="NONE",us[us.VERBOSE=1]="VERBOSE",us[us.DEBUG=2]="DEBUG",us[us.INFO=3]="INFO",us[us.WARN=4]="WARN",us[us.ERROR=5]="ERROR";var ls,hs=function(){function t(){r(this,t),this.level=e.LogLevel.WARN}return s(t,[{key:"verbose",value:function(){if(this.level<=e.LogLevel.VERBOSE){for(var t,n=arguments.length,r=new Array(n),a=0;a0&&L("number",i)&&(this.key=a,this.userIds=s,this.updatedAt=i);var o,u={},c=y(this.userIds);try{for(c.s();!(o=c.n()).done;){u[o.value]=this.updatedAt}}catch(e){c.e(e)}finally{c.f()}this._version=u}return s(t,[{key:"isEmpty",get:function(){return 0===this.userIds.length}},{key:"applyEvent",value:function(t){if(t.key===this.key&&this.updatedAt<=t.updatedAt){if(!this._version[t.userId]||this._version[t.userId]<=t.updatedAt){var n=this.userIds.indexOf(t.userId);switch(t.operation){case e.ReactionEventOperation.ADD:n<0&&this.userIds.push(t.userId);break;case e.ReactionEventOperation.DELETE:n>=0&&this.userIds.splice(n,1)}this._version[t.userId]=t.updatedAt}this.updatedAt=Math.max(this.updatedAt,t.updatedAt)}}}],[{key:"payloadify",value:function(e){return ue(ce({key:e.key,user_ids:e.userIds,updated_at:e.updatedAt}))}}]),t}(),Es=function(){function e(t){r(this,e),this.key=t.key,this.value=F("string",t.value)?_(t.value):[]}return s(e,null,[{key:"payloadify",value:function(e){var t;return ue(ce({key:e.key,value:null!==(t=e.value)&&void 0!==t?t:[]}))}}]),e}(),ws=function(){function e(t){r(this,e),this.secureUrl=null,this.type=null,this.width=0,this.height=0,this.alt=null,this.url=t.url,t.secure_url&&(this.secureUrl=t.secure_url),t.type&&(this.type=t.type),t.width&&(this.width=t.width),t.height&&(this.height=t.height),t.alt&&(this.alt=t.alt)}return s(e,null,[{key:"payloadify",value:function(e){var t,n;return ue(ce({url:e.url,secure_url:e.secureUrl,type:e.type,width:null!==(t=e.width)&&void 0!==t?t:0,height:null!==(n=e.height)&&void 0!==n?n:0,alt:e.alt}))}}]),e}(),Cs=function(){function e(t){r(this,e),this.title=null,this.url=null,this.description=null,this.defaultImage=null,t["og:title"]&&(this.title=t["og:title"]),t["og:url"]&&(this.url=t["og:url"]),t["og:description"]&&(this.description=t["og:description"]),t["og:image"]&&(this.defaultImage=new ws(t["og:image"]))}return s(e,null,[{key:"payloadify",value:function(e){return ue(ce({"og:title":e.title,"og:url":e.url,"og:description":e.description,"og:image":e.defaultImage?ws.payloadify(e.defaultImage):null}))}}]),e}(),xs=function(){function e(t){var n,a;r(this,e),this.volume=0,this.name=null!==(n=t.name)&&void 0!==n?n:"default",this.volume=null!==(a=t.volume)&&void 0!==a?a:1}return s(e,[{key:"serialize",value:function(){return{name:this.name,volume:this.volume}}}],[{key:"payloadify",value:function(e){return ue(ce({name:e.name,volume:e.volume}))}}]),e}(),Ts=function(t){i(a,t);var n=f(a);function a(t,s){var i,o;return r(this,a),(i=n.call(this,t,s)).isBlockedByMe=!1,i.role=D(e.Role,s.role)?s.role:e.Role.NONE,i.isBlockedByMe=null!==(o=s.is_blocked_by_me)&&void 0!==o&&o,i}return s(a,null,[{key:"payloadify",value:function(e){return ue(ce(Object.assign(Object.assign({},p(o(a),"payloadify",this).call(this,e)),{role:e.role,is_blocked_by_me:e.isBlockedByMe})))}}]),a}(Xa);e.ScheduledStatus=void 0,(gs=e.ScheduledStatus||(e.ScheduledStatus={})).PENDING="pending",gs.SENT="sent",gs.FAILED="failed",gs.CANCELED="canceled",function(e){e.PENDING="pending",e.IN_QUEUE="in_queue",e.SENT="sent",e.FAILED="failed",e.CANCELED="canceled",e.REMOVED="removed"}(ys||(ys={}));var Ss,Is=function(t){switch(t){case e.MessageType.BASE:return"";case e.MessageType.USER:return"MESG";case e.MessageType.FILE:return"FILE";case e.MessageType.ADMIN:return"ADMM"}},Ns=function(t){i(a,t);var n=f(a);function a(t,s){var i,o,u,c,l,h,d,f,p,v,_,m,g,y,k,b,E;r(this,a),(i=n.call(this,t)).channelType=e.ChannelType.BASE,i.parentMessage=null,i.silent=!1,i.isOperatorMessage=!1,i.messageType=e.MessageType.BASE,i.mentionType=null,i.threadInfo=null,i.reactions=[],i.metaArrays=[],i.appleCriticalAlertOptions=null,i.createdAt=0,i.updatedAt=0,i.scheduledInfo=null,i.extendedMessage={},i._isContinuousMessages=!1,i._scheduledStatus=null,i.messageId=null!==(u=null!==(o=s.msg_id)&&void 0!==o?o:s.message_id)&&void 0!==u?u:0,i.channelUrl=s.channel_url,i.channelType=D(e.ChannelType,s.channel_type)?s.channel_type:e.ChannelType.GROUP,s.channel&&(s.channel.channel_url&&(i.channelUrl=s.channel.channel_url),s.channel.channel_type&&(i.channelType=s.channel.channel_type)),i.parentMessageId=null!==(c="string"==typeof s.parent_message_id?parseInt(s.parent_message_id):s.parent_message_id)&&void 0!==c?c:0,i.data=null!==(l=s.data)&&void 0!==l?l:"",i.customType=null!==(h=s.custom_type)&&void 0!==h?h:"",i.mentionType=D(e.MentionType,s.mention_type)?s.mention_type:null,i.mentionedUsers=s.mentioned_users?s.mentioned_users.map((function(e){return new Xa(i._iid,e)})):null,i.mentionedUserIds=null!==(d=s.mentioned_user_ids)&&void 0!==d?d:null,i.mentionedUsers&&!i.mentionedUserIds&&(i.mentionedUserIds=i.mentionedUsers.map((function(e){return e.userId}))),i.mentionedMessageTemplate=null!==(f=s.mentioned_message_template)&&void 0!==f?f:"",i.threadInfo=s.thread_info?new ms(i._iid,s.thread_info):null,i.reactions=s.reactions?s.reactions.map((function(e){return new bs(e)})):[];var w=null!==(p=s.metaarray)&&void 0!==p?p:{},C=null!==(v=s.metaarray_key_order)&&void 0!==v?v:Object.keys(w).sort((function(e,t){return e.localeCompare(t)}));i.metaArrays=[];for(var x=0;x=t)return this.parentMessage=e,!0}return!1}}],[{key:"payloadify",value:function(e){var t,n,r,s;return ue(ce(Object.assign(Object.assign({},p(o(a),"payloadify",this).call(this,e)),{channel_url:e.channelUrl,channel_type:e.channelType,message_id:e.messageId,type:Is(e.messageType),parent_message_id:e.parentMessageId,data:e.data,custom_type:e.customType,mention_type:e.mentionType,mentioned_user_ids:e.mentionedUserIds,mentioned_users:null===(t=e.mentionedUsers)||void 0===t?void 0:t.map((function(e){return Xa.payloadify(e)})),mentioned_message_template:e.mentionedMessageTemplate,thread_info:e.threadInfo?ms.payloadify(e.threadInfo):null,reactions:e.reactions.map((function(e){return bs.payloadify(e)})),sorted_metaarray:null===(n=e.metaArrays)||void 0===n?void 0:n.map((function(e){return Es.payloadify(e)})),og_tag:e.ogMetaData?Cs.payloadify(e.ogMetaData):null,silent:e.silent,is_op_msg:e.isOperatorMessage,apple_critical_alert_options:e.appleCriticalAlertOptions?xs.payloadify(e.appleCriticalAlertOptions):null,created_at:e.createdAt,updated_at:e.updatedAt,scheduled_message_id:null===(r=e.scheduledInfo)||void 0===r?void 0:r.scheduledMessageId,scheduled_at:null===(s=e.scheduledInfo)||void 0===s?void 0:s.scheduledAt,scheduled_status:e._scheduledStatus,extended_message:e.extendedMessage})))}},{key:"_getParentMessageInfoPayload",value:function(e){return ue(ce({type:e.messageType,ts:e.createdAt,user:e.sender?Ts.payloadify(e.sender):null,message:e.message,file:{url:e.plainUrl,name:e.name,type:e.type,require_auth:e.requireAuth}}))}}]),a}(Ha),Ms=function(t){i(a,t);var n=f(a);function a(t,s){var i,o,u,c,l;if(r(this,a),(i=n.call(this,t,s)).reqId="",i.replyToChannel=!1,i.errorCode=0,i.sender=s.user?new Ts(i._iid,s.user):s.sender_id,i.reqId=null!==(u=null!==(o=s.req_id)&&void 0!==o?o:s.request_id)&&void 0!==u?u:"",i.replyToChannel=null!==(c=s.is_reply_to_channel)&&void 0!==c&&c,s.request_state&&D(e.SendingStatus,s.request_state)&&(i.sendingStatus=s.request_state),!i.sendingStatus)if(i.messageId>0)i.sendingStatus=e.SendingStatus.SUCCEEDED;else if(i.scheduledInfo)switch(s.scheduled_status&&(i._scheduledStatus=s.scheduled_status),s.scheduled_status){case ys.SENT:case ys.IN_QUEUE:i.sendingStatus=e.SendingStatus.SUCCEEDED;break;case ys.PENDING:i.sendingStatus=e.SendingStatus.SCHEDULED;break;case ys.FAILED:case ys.REMOVED:i.sendingStatus=e.SendingStatus.FAILED;break;case ys.CANCELED:i.sendingStatus=e.SendingStatus.CANCELED}else i.sendingStatus=e.SendingStatus.PENDING;return i.errorCode=null!==(l=s.error_code)&&void 0!==l?l:0,i}return s(a,[{key:"isResendable",get:function(){return this.sendingStatus===e.SendingStatus.FAILED&&((t=this.errorCode)>0&&O.indexOf(t)>=0);var t}},{key:"isIdentical",value:function(e){return this.messageId>0&&e.messageId>0?this.messageId===e.messageId:this.reqId===e.reqId}}],[{key:"payloadify",value:function(e){return ue(ce(Object.assign(Object.assign({},p(o(a),"payloadify",this).call(this,e)),{user:Ts.payloadify(e.sender),req_id:e.reqId,is_reply_to_channel:e.replyToChannel,request_state:e.sendingStatus,error_code:e.errorCode})))}}]),a}(Ns),As=function(){function e(t){var n,a;r(this,e),this.width=0,this.height=0,this.realWidth=0,this.realHeight=0,this.url=t.url,this.width=t.width,this.height=t.height,this.realWidth=null!==(n=t.real_width)&&void 0!==n?n:t.width,this.realHeight=null!==(a=t.real_height)&&void 0!==a?a:t.height}return s(e,[{key:"plainUrl",get:function(){return this.url.split("?auth=")[0]}}],[{key:"payloadify",value:function(e){return ue(ce({url:"",width:e.maxWidth,height:e.maxHeight,real_width:0,real_height:0}))}}]),e}(),Os={prevResultSize:0,nextResultSize:0,isInclusive:!1,reverse:!1,messageTypeFilter:e.MessageTypeFilter.ALL,customTypesFilter:void 0,senderUserIdsFilter:void 0,includeReactions:!1,includeMetaArray:!1,includeParentMessageInfo:!1},Us=function(t){return L("number",t.prevResultSize)&&L("number",t.nextResultSize)&&L("boolean",t.isInclusive)&&L("boolean",t.reverse)&&L("string",t.messageTypeFilter)&&D(e.MessageTypeFilter,t.messageTypeFilter)&&F("string",t.customTypesFilter,!0)&&F("string",t.senderUserIdsFilter,!0)&&L("boolean",t.includeMetaArray)&&L("boolean",t.includeReactions)&&L("boolean",t.includeParentMessageInfo)},Rs=function(n){i(u,n);var a=f(u);function u(t,n){var s,i,o,c,l;if(r(this,u),(s=a.call(this,t,n)).translations={},s.message=null!==(i=n.message)&&void 0!==i?i:"",s.messageType=e.MessageType.ADMIN,s.translations=null!==(o=n.translations)&&void 0!==o?o:{},n.parent_message_info){var h=n.parent_message_info;s.parentMessage=Bs(t,ue(ce(Object.assign(Object.assign({},h),{message_id:s.parentMessageId,channel_url:s.channelUrl,channel_type:s.channelType,file:h.file,url:null===(c=h.file)||void 0===c?void 0:c.url,require_auth:null===(l=h.file)||void 0===l?void 0:l.require_auth}))))}return s}return s(u,[{key:"getThreadedMessagesByTimestamp",value:function(e,n){return b(this,void 0,void 0,t().mark((function r(){var a,s;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return a=Object.assign(Object.assign({},Os),n),Za(this.messageId>0&&L("number",e)&&Us(a)).throw(A.invalidParameters),s=wi.of(this._iid),t.next=5,s.getThreadedMessagesByTimestamp(this,e,a);case 5:return t.abrupt("return",t.sent);case 6:case"end":return t.stop()}}),r,this)})))}}],[{key:"payloadify",value:function(e){return ue(ce(Object.assign(Object.assign({},p(o(u),"payloadify",this).call(this,e)),{message:e.message,translations:e.translations,parent_message_info:e.parentMessage?p(o(u),"_getParentMessageInfoPayload",this).call(this,e.parentMessage):null})))}}]),u}(Ns),Ls=function(){function e(t){var n,a;r(this,e),this.detail={},this.type=null!==(n=t.type)&&void 0!==n?n:"",this.vendor=null!==(a=t.vendor)&&void 0!==a?a:"",t.detail&&L("object",t.detail)&&!Array.isArray(t.detail)&&(this.detail=t.detail)}return s(e,null,[{key:"payloadify",value:function(e){return ue(ce({type:e.type,vendor:e.vendor,detail:e.detail}))}}]),e}();!function(e){e.OPEN="open",e.CLOSED="closed"}(Ss||(Ss={}));var Ds="removed",Ps=function(e){switch(e){case"open":return Ss.OPEN;case"closed":return Ss.CLOSED;default:return null}},Fs=function(e){return!e||!!e.text&&L("string",e.text)},Gs=function(e){i(n,e);var t=f(n);function n(e,a){var s,i,o,u,c,l,h,d;return r(this,n),(s=t.call(this,e)).pollId=0,s.id=0,s.text=null,s.voteCount=0,s.createdBy=null,s.createdAt=0,s.updatedAt=0,s._lastVotedAt=0,s.pollId=null!==(i=a.poll_id)&&void 0!==i?i:0,s.id=null!==(o=a.id)&&void 0!==o?o:0,s.text=null!==(u=a.text)&&void 0!==u?u:null,s.voteCount=null!==(c=a.vote_count)&&void 0!==c?c:0,s.createdBy=null!==(l=a.created_by)&&void 0!==l?l:null,s.createdAt=null!==(h=a.created_at)&&void 0!==h?h:0,s.updatedAt=null!==(d=a.updated_at)&&void 0!==d?d:0,s}return s(n,null,[{key:"payloadify",value:function(e){return ue(ce(Object.assign(Object.assign({},p(o(n),"payloadify",this).call(this,e)),{vote_count:e.voteCount,poll_id:e.pollId,text:e.text,created_at:e.createdAt,id:e.id,created_by:e.createdBy,updated_at:e.updatedAt})))}}]),n}(Ha),qs=function(e){i(n,e);var t=f(n);function n(e,a){var s,i,o,u,c,l,h,d,f,p,v,_,m,g;return r(this,n),(s=t.call(this,e)).id=0,s.title=null,s.createdAt=0,s.updatedAt=0,s.closeAt=-1,s.status=Ss.CLOSED,s.messageId=0,s.data=null,s.voterCount=-1,s.options=[],s.createdBy=null,s.allowUserSuggestion=!1,s.allowMultipleVotes=!1,s.votedPollOptionIds=[],s.id=null!==(i=a.id)&&void 0!==i?i:0,s.title=null!==(o=a.title)&&void 0!==o?o:null,s.createdAt=null!==(u=a.created_at)&&void 0!==u?u:0,s.updatedAt=null!==(c=a.updated_at)&&void 0!==c?c:0,s.closeAt=null!==(l=a.close_at)&&void 0!==l?l:-1,s.status=null!==(h=Ps(a.status))&&void 0!==h?h:Ss.CLOSED,s.messageId=null!==(d=a.message_id)&&void 0!==d?d:0,s.data=null!==(f=a.data)&&void 0!==f?f:null,s.voterCount=null!==(p=a.voter_count)&&void 0!==p?p:-1,s.options=a.options?a.options.map((function(e){return new Gs(s._iid,e)})):[],s.createdBy=null!==(v=a.created_by)&&void 0!==v?v:null,s.allowUserSuggestion=null!==(_=a.allow_user_suggestion)&&void 0!==_&&_,s.allowMultipleVotes=null!==(m=a.allow_multiple_votes)&&void 0!==m&&m,s.votedPollOptionIds=null!==(g=a.voted_option_ids)&&void 0!==g?g:[],s}return s(n,[{key:"_applyPollUpdatePayload",value:function(e){var t,n,r,a,s,i,o,u,c=this;this.title=null!==(t=e.title)&&void 0!==t?t:this.title,this.updatedAt=null!==(n=e.updated_at)&&void 0!==n?n:this.updatedAt,this.closeAt=null!==(r=e.close_at)&&void 0!==r?r:this.closeAt,this.status=null!==(a=Ps(e.status))&&void 0!==a?a:this.status,this.data=null!==(s=e.data)&&void 0!==s?s:this.data,this.voterCount=null!==(i=e.voter_count)&&void 0!==i?i:this.voterCount,e.options&&(this.options=e.options.map((function(e){return new Gs(c._iid,e)})),this.votedPollOptionIds=e.options.filter((function(e){return e.vote_count>0})).map((function(e){return e.id}))),this.allowUserSuggestion=null!==(o=e.allow_user_suggestion)&&void 0!==o?o:this.allowUserSuggestion,this.allowMultipleVotes=null!==(u=e.allow_multiple_votes)&&void 0!==u?u:this.allowMultipleVotes}},{key:"applyPollUpdateEvent",value:function(e){var t=e._payload.poll;return!(!t||this.id!==t.id||t.updated_at-1){var s=t[r];a>=s._lastVotedAt&&(s.voteCount=e.vote_count,s._lastVotedAt=a)}})),r.req_id&&r.voted_option_ids&&(this.votedPollOptionIds=r.voted_option_ids),!0}},{key:"serialize",value:function(){return Wa(this)}}],[{key:"payloadify",value:function(e){return ue(ce(Object.assign(Object.assign({},p(o(n),"payloadify",this).call(this,e)),{id:e.id,title:e.title,created_at:e.createdAt,updated_at:e.updatedAt,close_at:e.closeAt,status:e.status,message_id:e.messageId,data:e.data,voter_count:e.voterCount,options:e.options.map((function(e){return Gs.payloadify(e)})),created_by:e.createdBy,allow_user_suggestion:e.allowUserSuggestion,allow_multiple_votes:e.allowMultipleVotes,voted_option_ids:e.votedPollOptionIds})))}}]),n}(Ha),Hs=function(n){i(u,n);var a=f(u);function u(t,n){var s,i,o,c,l,h;if(r(this,u),(s=a.call(this,t,n)).message="",s.messageParams=null,s.translations={},s.translationTargetLanguages=[],s.messageSurvivalSeconds=-1,s.plugins=[],s._poll=null,s.message=n.message,s.messageType=e.MessageType.USER,s.translations=null!==(i=n.translations)&&void 0!==i?i:{},s.translationTargetLanguages=null!==(o=n.target_langs)&&void 0!==o?o:[],0===Object.keys(s.translations).length&&s.translationTargetLanguages.length>0){var d,f=y(s.translationTargetLanguages);try{for(f.s();!(d=f.n()).done;){var p=d.value;s.translations[p]=""}}catch(e){f.e(e)}finally{f.f()}}if(s.messageSurvivalSeconds=null!==(c=n.message_survival_seconds)&&void 0!==c?c:-1,s.plugins=n.plugins?n.plugins.map((function(e){return new Ls(e)})):[],s._poll=n.poll?new qs(s._iid,n.poll):null,n.parent_message_info){var v=n.parent_message_info;s.parentMessage=Bs(t,ue(ce(Object.assign(Object.assign({},v),{created_at:v.ts,message_id:s.parentMessageId,channel_url:s.channelUrl,channel_type:s.channelType,file:v.file,url:null===(l=v.file)||void 0===l?void 0:l.url,require_auth:null===(h=v.file)||void 0===h?void 0:h.require_auth}))))}return s}return s(u,[{key:"getThreadedMessagesByTimestamp",value:function(e,n){return b(this,void 0,void 0,t().mark((function r(){var a,s;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return a=Object.assign(Object.assign({},Os),n),Za(this.messageId>0&&L("number",e)&&Us(a)).throw(A.invalidParameters),s=wi.of(this._iid),t.next=5,s.getThreadedMessagesByTimestamp(this,e,a);case 5:return t.abrupt("return",t.sent);case 6:case"end":return t.stop()}}),r,this)})))}},{key:"applyPoll",value:function(e){return!(this._poll&&this._poll.id===e.id&&this._poll.updatedAt>e.updatedAt)&&(this._poll=e,!0)}},{key:"poll",get:function(){return this._poll}}],[{key:"payloadify",value:function(e){return ue(ce(Object.assign(Object.assign({},p(o(u),"payloadify",this).call(this,e)),{message:e.message,translations:e.translations,message_survival_seconds:e.messageSurvivalSeconds,plugins:e.plugins.map((function(e){return Ls.payloadify(e)})),poll:e._poll?qs.payloadify(e._poll):null,parent_message_info:e.parentMessage?p(o(u),"_getParentMessageInfoPayload",this).call(this,e.parentMessage):null})))}}]),u}(Ms),js=function(e){i(n,e);var t=f(n);function n(e,a){var s,i,o,u,c,l;r(this,n),(s=t.call(this,e)).plainUrl="",s.fileName=null,s.mimeType=null,s.fileSize=0,s.thumbnails=[],s._requireAuth=!1,s.plainUrl=null!==(i=a.url)&&void 0!==i?i:"",s.fileName=null!==(o=a.file_name)&&void 0!==o?o:null,s.mimeType=null!==(u=a.file_type)&&void 0!==u?u:null,s.fileSize=null!==(c=a.file_size)&&void 0!==c?c:0,s._requireAuth=null!==(l=a.require_auth)&&void 0!==l&&l;var h=fs.of(s._iid).sessionManager;return s.thumbnails=a.thumbnails?a.thumbnails.map((function(e){return new As(Object.assign(Object.assign({},e),{url:"".concat(e.url.split("?auth=")[0]).concat(s._requireAuth?"?auth=".concat(h.ekey):"")}))})):[],s}return s(n,[{key:"url",get:function(){var e=fs.of(this._iid).sessionManager;return this._requireAuth?"".concat(this.plainUrl,"?auth=").concat(e.ekey):this.plainUrl}}],[{key:"payloadify",value:function(e){var t;return ue(ce({url:e.plainUrl,file_name:e.fileName,file_type:e.mimeType,file_size:e.fileSize,thumbnails:null===(t=e.thumbnails)||void 0===t?void 0:t.map((function(e){return{url:e.url,width:e.width,height:e.height,real_width:e.realWidth,real_height:e.realHeight}})),require_auth:e._requireAuth}))}}]),n}(Ha),zs=function(n){i(u,n);var a=f(u);function u(t,n){var s,i,o,c,l,h;if(r(this,u),(s=a.call(this,t,n)).messageParams=null,s.fileInfoList=[],s.messageSurvivalSeconds=-1,s.messageType=e.MessageType.FILE,s.fileInfoList=null!==(o=null===(i=n.files)||void 0===i?void 0:i.map((function(e){return new js(t,e)})))&&void 0!==o?o:[],s.messageSurvivalSeconds=null!==(c=n.message_survival_seconds)&&void 0!==c?c:-1,n.parent_message_info){var d=n.parent_message_info;s.parentMessage=Bs(t,ue(ce(Object.assign(Object.assign({},d),{created_at:d.ts,message_id:s.parentMessageId,channel_url:s.channelUrl,channel_type:s.channelType,file:d.file,url:null===(l=d.file)||void 0===l?void 0:l.url,require_auth:null===(h=d.file)||void 0===h?void 0:h.require_auth}))))}return s}return s(u,[{key:"getThreadedMessagesByTimestamp",value:function(e,n){return b(this,void 0,void 0,t().mark((function r(){var a,s;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return a=Object.assign(Object.assign({},Os),n),Za(this.messageId>0&&L("number",e)&&Us(a)).throw(A.invalidParameters),s=wi.of(this._iid),t.next=5,s.getThreadedMessagesByTimestamp(this,e,a);case 5:return t.abrupt("return",t.sent);case 6:case"end":return t.stop()}}),r,this)})))}}],[{key:"payloadify",value:function(e){return ue(ce(Object.assign(Object.assign({},p(o(u),"payloadify",this).call(this,e)),{files:e.fileInfoList&&e.fileInfoList&&Array.isArray(e.fileInfoList)?e.fileInfoList.map((function(e){return js.payloadify(e)})):null,message_survival_seconds:e.messageSurvivalSeconds,parent_message_info:e.parentMessage?p(o(u),"_getParentMessageInfoPayload",this).call(this,e.parentMessage):null})))}},{key:"_isMultipleFilesMessagePayload",value:function(e){var t=e.files;return Array.isArray(t)&&t.length>=2}},{key:"_isMultipleFilesMessageSerializedData",value:function(e){var t=e.fileInfoList;return Array.isArray(t)}}]),u}(Ms),Vs=function(t){switch(t.messageType){case e.MessageType.USER:return Hs.payloadify(t);case e.MessageType.FILE:return t.fileInfoList?zs.payloadify(t):Qs.payloadify(t);case e.MessageType.ADMIN:return Rs.payloadify(t);default:throw A.unknown}},Bs=function(e,t){switch(t.type){case"MESG":return new Hs(e,t);case"FILE":return zs._isMultipleFilesMessagePayload(t)?new zs(e,t):new Qs(e,t);case"ADMM":case"BRDM":return new Rs(e,t)}throw A.unknown},Qs=function(n){i(u,n);var a=f(u);function u(t,n){var s,i,o,c,l,h,d,f,p,v,_,m,g,y,k;r(this,u),(s=a.call(this,t,n)).messageParams=null,s.plainUrl="",s.requireAuth=!1,s.thumbnails=[],s.messageSurvivalSeconds=-1,s.messageType=e.MessageType.FILE;var b=n.file;s.plainUrl=(null!==(o=null!==(i=null==b?void 0:b.url)&&void 0!==i?i:n.url)&&void 0!==o?o:"").split("?auth=")[0],s.name=null!==(l=null!==(c=null==b?void 0:b.name)&&void 0!==c?c:n.name)&&void 0!==l?l:"File",s.size=null!==(d=null!==(h=null==b?void 0:b.size)&&void 0!==h?h:n.size)&&void 0!==d?d:0,s.data=null!==(p=null!==(f=null==b?void 0:b.data)&&void 0!==f?f:n.custom)&&void 0!==p?p:"",s.type=b?null!==(v=b.type)&&void 0!==v?v:"":null!==(_=n.type)&&void 0!==_?_:"";var E=fs.of(s._iid).sessionManager;if(s.requireAuth=null!==(m=n.require_auth)&&void 0!==m&&m,s.thumbnails=n.thumbnails?n.thumbnails.map((function(e){return new As(Object.assign(Object.assign({},e),{url:"".concat(e.url.split("?auth=")[0]).concat(s.requireAuth?"?auth=".concat(E.ekey):"")}))})):[],s.messageSurvivalSeconds=null!==(g=n.message_survival_seconds)&&void 0!==g?g:-1,n.parent_message_info){var w=n.parent_message_info;s.parentMessage=Bs(t,ue(ce(Object.assign(Object.assign({},w),{created_at:w.ts,message_id:s.parentMessageId,channel_url:s.channelUrl,channel_type:s.channelType,file:w.file,url:null===(y=w.file)||void 0===y?void 0:y.url,require_auth:null===(k=w.file)||void 0===k?void 0:k.require_auth}))))}return s}return s(u,[{key:"url",get:function(){var e=fs.of(this._iid).sessionManager;return this.requireAuth?"".concat(this.plainUrl,"?auth=").concat(e.ekey):this.plainUrl}},{key:"getThreadedMessagesByTimestamp",value:function(e,n){return b(this,void 0,void 0,t().mark((function r(){var a,s;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return a=Object.assign(Object.assign({},Os),n),Za(this.messageId>0&&L("number",e)&&Us(a)).throw(A.invalidParameters),s=wi.of(this._iid),t.next=5,s.getThreadedMessagesByTimestamp(this,e,a);case 5:return t.abrupt("return",t.sent);case 6:case"end":return t.stop()}}),r,this)})))}}],[{key:"payloadify",value:function(e){var t;return ue(ce(Object.assign(Object.assign({},p(o(u),"payloadify",this).call(this,e)),{url:e.plainUrl,require_auth:e.requireAuth,file:{name:e.name,size:e.size,type:e.type,data:e.data},thumbnails:null===(t=e.thumbnails)||void 0===t?void 0:t.map((function(e){return{url:e.url,width:e.width,height:e.height,real_width:e.realWidth,real_height:e.realHeight}})),message_survival_seconds:e.messageSurvivalSeconds,parent_message_info:e.parentMessage?p(o(u),"_getParentMessageInfoPayload",this).call(this,e.parentMessage):null})))}}]),u}(Ms),Ks=function(t){i(a,t);var n=f(a);function a(t){var s,i,o;r(this,a);var u=[];return t.mentionType===e.MentionType.USERS&&(t.mentionedUserIds?u=t.mentionedUserIds:t.mentionedUsers&&(u=t.mentionedUsers.map((function(e){return e.userId})))),n.call(this,{code:"FILE",ackRequired:!0,payload:ue(ce({channel_url:t.channelUrl,files:t.files?Js(t.files):null,url:t.url,name:null!==(s=t.fileName)&&void 0!==s?s:"",type:null!==(i=t.mimeType)&&void 0!==i?i:"",size:null!==(o=t.fileSize)&&void 0!==o?o:0,custom:t.data,custom_type:t.customType,thumbnails:t.thumbnailSizes,require_auth:t.requireAuth,metaarray:t.metaArrays,mention_type:t.mentionType,mentioned_user_ids:u,push_option:t.pushNotificationDeliveryOption&&t.pushNotificationDeliveryOption!==e.PushNotificationDeliveryOption.DEFAULT?t.pushNotificationDeliveryOption:void 0,apple_critical_alert_options:t.appleCriticalAlertOptions?xs.payloadify(t.appleCriticalAlertOptions):null,silent:t.silent,reply_to_channel:t.isReplyToChannel,parent_message_id:t.parentMessageId?t.parentMessageId:null,req_id:t.reqId,pin_message:t.isPinnedMessage}))})}return s(a)}(oa),Ws=function(t){i(a,t);var n=f(a);function a(t){var s,i,o;r(this,a),s=n.call(this);var u=[];return t.mentionType===e.MentionType.USERS&&(t.mentionedUserIds?u=t.mentionedUserIds:t.mentionedUsers&&(u=t.mentionedUsers.map((function(e){return e.userId})))),s.method=le.POST,s.path="".concat(Te(t.channelType),"/").concat(encodeURIComponent(t.channelUrl),"/messages"),s.params=ue(ce({message_type:e.MessageType.FILE,user_id:t.userId,files:t.files?Js(t.files):null,url:t.fileUrl,mention_type:t.mentionType,mentioned_user_ids:u,file_name:t.fileName,file_size:t.fileSize,file_type:t.mimeType,data:t.data,custom_type:t.customType,thumbnails:null===(i=t.thumbnailSizes)||void 0===i?void 0:i.map((function(e){return As.payloadify(e)})),require_auth:t.requireAuth,sorted_metaarray:null===(o=t.metaArrays)||void 0===o?void 0:o.map((function(e){return Es.payloadify(e)})),push_option:t.pushNotificationDeliveryOption,parent_message_id:t.parentMessageId?t.parentMessageId:null,apple_critical_alert_options:t.appleCriticalAlertOptions?xs.payloadify(t.appleCriticalAlertOptions):null,reply_to_channel:t.isReplyToChannel,req_id:t.reqId,pin_message:t.isPinnedMessage})),s}return s(a)}(Oe),Ys=function(e){i(n,e);var t=f(n);function n(e,a,s){var i,o,u,c,l;r(this,n),(i=t.call(this,e,"FILE",s)).message=s.files&&s.files.length>=2?new zs(e,s):new Qs(e,s);var h=fs.of(e).sdkState;return i.isMentioned=Ie(i.message.mentionType,null!==(c=null!==(o=i.message.mentionedUserIds)&&void 0!==o?o:null===(u=i.message.mentionedUsers)||void 0===u?void 0:u.map((function(e){return e.userId})))&&void 0!==c?c:[],h.userId),i.forceUpdateLastMessage=null!==(l=s.force_update_last_message)&&void 0!==l&&l,i}return s(n)}(qe),Zs=function(e){i(n,e);var t=f(n);function n(e,a){var s,i,o,u,c;r(this,n),(s=t.call(this,e,a)).message=a.files&&a.files.length>=2?new zs(e,a):new Qs(e,a);var l=fs.of(e).sdkState;return s.isMentioned=Ie(s.message.mentionType,null!==(u=null!==(i=s.message.mentionedUserIds)&&void 0!==i?i:null===(o=s.message.mentionedUsers)||void 0===o?void 0:o.map((function(e){return e.userId})))&&void 0!==u?u:[],l.userId),s.forceUpdateLastMessage=null!==(c=a.force_update_last_message)&&void 0!==c&&c,s}return s(n)}(Ue);function Js(e){return e.map((function(e){var t,n;return ue(ce({url:e.fileUrl,file_name:e.fileName,file_type:e.mimeType,file_size:e.fileSize,thumbnails:null===(t=e.thumbnailSizes)||void 0===t?void 0:t.map((function(e){return As.payloadify(e)})),require_auth:null===(n=e._uploadedMetaData)||void 0===n?void 0:n.requireAuth}))}))}var Xs;!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"}(Xs||(Xs={}));var $s=function(){function e(t,n){var a=this,s=n.sdkState,i=n.dispatcher,o=n.requestQueue,u=n.onlineDetector,c=n.cacheContext;r(this,e),this._queueMap=new Map,this._iid=t,this._sdkState=s,this._requestQueue=o,this._cacheContext=c,this._dispatcher=i,this._dispatcher.on((function(e){e instanceof da&&(a._connectionState=e.stateType)})),this._onlineDetector=u}return s(e,[{key:"_shouldSendThroughWebSocket",get:function(){return this._connectionState===sa.CONNECTED||this._connectionState===sa.CONNECTING||this._connectionState===sa.RECONNECTING}},{key:"_sendFileMessage",value:function(e,n){return b(this,void 0,void 0,t().mark((function r(){var a,s,i,o,u,c,l,h,d;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(a=this._createSendFileMessageRequestParams(e,n),!this._shouldSendThroughWebSocket){t.next=10;break}return s=new Ks(a),t.next=5,this._requestQueue.send(s);case 5:return i=t.sent,o=i.as(Ys),u=o.message,t.abrupt("return",u);case 10:return c=new Ws(Object.assign(Object.assign({},a),{userId:this._sdkState.userId})),t.next=13,this._requestQueue.send(c);case 13:return l=t.sent,h=l.as(Zs),d=h.message,t.abrupt("return",d);case 16:case"end":return t.stop()}}),r,this)})))}},{key:"_createSendFileMessageRequestParams",value:function(e,t){var n=Object.assign(Object.assign({},t.params),{channelUrl:e.url,channelType:e.channelType,reqId:t.requestId,url:""});if(t.multipleFileUploadInfo){var r=t.params;n.files=r.fileInfoList}else{var a=t.params;n.url=a.fileUrl,n.requireAuth=a.requireAuth}return n}},{key:"_resolveMessageQueue",value:function(e){var n;return b(this,void 0,void 0,t().mark((function r(){var a,s,i,o,u,c,l,h,d;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(!(a=this._queueMap.get(e.url))){t.next=58;break}if(a.isResolving){t.next=57;break}a.isResolving=!0,s=[],i=!0,o=y(a.messageQueue),t.prev=7,o.s();case 9:if((u=o.n()).done){t.next=40;break}c=u.value,t.t0=c.state,t.next=t.t0===Xs.PENDING||t.t0===Xs.UPLOADING?14:t.t0===Xs.UPLOADED?17:t.t0===Xs.FAILED?35:38;break;case 14:return i=!1,s.push(c),t.abrupt("break",38);case 17:if(!i){t.next=33;break}return t.prev=18,c.state=Xs.SENDING,t.next=22,this._sendFileMessage(e,c);case 22:return l=t.sent,c.deferred.resolve(l),t.next=26,ba(100);case 26:t.next=31;break;case 28:t.prev=28,t.t1=t.catch(18),c.deferred.reject(t.t1);case 31:t.next=34;break;case 33:s.push(c);case 34:return t.abrupt("break",38);case 35:return h=null!==(n=c.error)&&void 0!==n?n:A.unknown,c.deferred.reject(h.code===E.REQUEST_CANCELED?A.fileUploadCanceled:h),t.abrupt("break",38);case 38:t.next=9;break;case 40:t.next=45;break;case 42:t.prev=42,t.t2=t.catch(7),o.e(t.t2);case 45:return t.prev=45,o.f(),t.finish(45);case 48:if(d=a.isResolveRequestPending,a.messageQueue=s,a.isResolving=!1,a.isResolveRequestPending=!1,!d){t.next=55;break}return t.next=55,this._resolveMessageQueue(e);case 55:t.next=58;break;case 57:a.isResolveRequestPending=!0;case 58:case"end":return t.stop()}}),r,this,[[7,42,45,48],[18,28]])})))}},{key:"_uploadNextPendingItem",value:function(e){var n;return b(this,void 0,void 0,t().mark((function r(){var a,s,i,o,u,c,l,h,d,f;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(!(a=this._queueMap.get(e.url))){t.next=30;break}if(!(s=a.messageQueue.find((function(e){return e.state===Xs.PENDING})))){t.next=30;break}if(!s.multipleFileUploadInfo){t.next=19;break}if(i=s.multipleFileUploadInfo,o=i.uploadIndex,u=i.uploadCount,c=i.requestHandler,l=s.params,h=l.fileInfoList[o],!q(h.file)||(null===(n=h._uploadedMetaData)||void 0===n?void 0:n.isUploaded)){t.next=13;break}return t.next=11,this._tryUploadNextItemAndUpdateItemState(e,a,s);case 11:t.next=14;break;case 13:s.state=o=0&&e.uploadQueue.splice(n,1)}},{key:"_uploadNextFileForSingleFileItemAndUpdateParams",value:function(e,n,r){var a,s,i;return b(this,void 0,void 0,t().mark((function o(){var u,c,l,h,d,f,p,v,_,m;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return u=new vs({file:r.file,channelUrl:e.url,thumbnailSizes:r.thumbnailSizes,requestId:n.requestId}),t.next=3,this._requestQueue.send(u);case 3:c=t.sent,l=c.as(_s),h=l.url,d=l.fileSize,f=void 0===d?r.fileSize:d,p=l.thumbnailSizes,v=void 0===p?r.thumbnailSizes:p,_=l.requireAuth,m=void 0!==_&&_,r.fileName=null!==(a=r.fileName)&&void 0!==a?a:r.file.name,r.mimeType=null!==(s=r.mimeType)&&void 0!==s?s:r.file.type,r.fileSize=null!==(i=r.fileSize)&&void 0!==i?i:r.file.size,r.fileUrl=h,r.fileSize=f,r.thumbnailSizes=v,r.requireAuth=m;case 12:case"end":return t.stop()}}),o,this)})))}},{key:"_uploadNextFileForMultipleFilesItemAndUpdateParams",value:function(e,n,r){var a,s,i;return b(this,void 0,void 0,t().mark((function o(){var u,c,l,h,d,f,p,v,_,m,g,y;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return u=n.multipleFileUploadInfo.uploadIndex,c=r.fileInfoList[u],l=new vs({file:c.file,channelUrl:e.url,thumbnailSizes:c.thumbnailSizes,requestId:n.requestId}),t.next=5,this._requestQueue.send(l);case 5:h=t.sent,d=h.as(_s),f=d.url,p=d.fileSize,v=void 0===p?c.fileSize:p,_=d.thumbnailSizes,m=void 0===_?c.thumbnailSizes:_,g=d.requireAuth,y=void 0!==g&&g,c.fileName=null!==(a=c.fileName)&&void 0!==a?a:c.file.name,c.mimeType=null!==(s=c.mimeType)&&void 0!==s?s:c.file.type,c.fileSize=null!==(i=c.fileSize)&&void 0!==i?i:c.file.size,c.file=void 0,c.fileUrl=f,c.fileSize=v,c.thumbnailSizes=m,c._uploadedMetaData=Object.assign(Object.assign({},c._uploadedMetaData),{requireAuth:y,isUploaded:!0});case 15:case"end":return t.stop()}}),o,this)})))}},{key:"request",value:function(e,n,r,a){return b(this,void 0,void 0,t().mark((function s(){var i,o,u,c,l;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return this._queueMap.has(e.url)||(i={messageQueue:[],uploadQueue:[],isResolving:!1,isResolveRequestPending:!1},this._queueMap.set(e.url,i)),o=this._queueMap.get(e.url),u=new ca,c={requestId:n,params:r,state:Xs.PENDING,deferred:u},ei(r)&&(l={uploadIndex:0,uploadCount:r.fileInfoList.length,requestHandler:a},c.multipleFileUploadInfo=l),o.messageQueue.push(c),this._uploadNextPendingItem(e),t.abrupt("return",u.promise);case 8:case"end":return t.stop()}}),s,this)})))}},{key:"cancel",value:function(e,t){var n=this._queueMap.get(e.url);if(n){var r,a=t?[n.messageQueue.find((function(e){return e.requestId===t}))]:_(n.messageQueue),s=y(a);try{for(s.s();!(r=s.n()).done;){var i=r.value;if(i)switch(i.state){case Xs.PENDING:i.state=Xs.FAILED,i.error=A.requestCanceled,this._resolveMessageQueue(e);break;case Xs.UPLOADING:this._requestQueue.cancel(i.requestId)}}}catch(e){s.e(e)}finally{s.f()}}}}]),e}();function ei(e){return"fileInfoList"in e}var ti,ni={prevResultSize:0,nextResultSize:0,isInclusive:!1,reverse:!1,messageTypeFilter:e.MessageTypeFilter.ALL,customTypesFilter:void 0,senderUserIdsFilter:void 0,replyType:e.ReplyType.NONE,includeReactions:!1,includeMetaArray:!1,includeParentMessageInfo:!1,includeThreadInfo:!1,showSubchannelMessagesOnly:!1},ri=function(t){return L("number",t.prevResultSize)&&L("number",t.nextResultSize)&&L("boolean",t.isInclusive)&&L("boolean",t.reverse)&&L("string",t.messageTypeFilter)&&D(e.MessageTypeFilter,t.messageTypeFilter)&&F("string",t.customTypesFilter,!0)&&F("string",t.senderUserIdsFilter,!0)&&D(e.ReplyType,t.replyType)&&L("boolean",t.includeMetaArray)&&L("boolean",t.includeReactions)&&L("boolean",t.includeParentMessageInfo)&&L("boolean",t.includeThreadInfo)&&L("boolean",t.showSubchannelMessagesOnly)},ai={replyType:e.ReplyType.NONE,includeReactions:!1,includeThreadInfo:!1,includeMetaArray:!1,includeParentMessageInfo:!1},si=function(t){return D(e.ReplyType,t.replyType)&&L("boolean",t.includeReactions)&&L("boolean",t.includeMetaArray)&&L("boolean",t.includeParentMessageInfo)&&L("boolean",t.includeThreadInfo)};e.MessageEventSource=void 0,(ti=e.MessageEventSource||(e.MessageEventSource={})).UNKNOWN="UNKNOWN",ti.EVENT_MESSAGE_SENT_SUCCESS="EVENT_MESSAGE_SENT_SUCCESS",ti.EVENT_MESSAGE_SENT_FAILED="EVENT_MESSAGE_SENT_FAILED",ti.EVENT_MESSAGE_SENT_PENDING="EVENT_MESSAGE_SENT_PENDING",ti.EVENT_MESSAGE_RECEIVED="EVENT_MESSAGE_RECEIVED",ti.EVENT_MESSAGE_UPDATED="EVENT_MESSAGE_UPDATED",ti.EVENT_MESSAGE_DELETED="EVENT_MESSAGE_DELETED",ti.EVENT_MESSAGE_READ="EVENT_MESSAGE_READ",ti.EVENT_MESSAGE_DELIVERED="EVENT_MESSAGE_DELIVERED",ti.EVENT_MESSAGE_REACTION_UPDATED="EVENT_MESSAGE_REACTION_UPDATED",ti.EVENT_MESSAGE_THREADINFO_UPDATED="EVENT_MESSAGE_THREADINFO_UPDATED",ti.EVENT_MESSAGE_OFFSET_UPDATED="EVENT_MESSAGE_OFFSET_UPDATED",ti.REQUEST_MESSAGE="REQUEST_MESSAGE",ti.EVENT_POLL_UPDATED="EVENT_POLL_UPDATED",ti.EVENT_POLL_VOTED="EVENT_POLL_VOTED",ti.SYNC_POLL_CHANGELOGS="SYNC_POLL_CHANGELOGS",ti.REQUEST_RESEND_MESSAGE="REQUEST_RESEND_MESSAGE",ti.REQUEST_THREADED_MESSAGE="REQUEST_THREADED_MESSAGE",ti.REQUEST_MESSAGE_CHANGELOGS="REQUEST_MESSAGE_CHANGELOGS",ti.SYNC_MESSAGE_FILL="SYNC_MESSAGE_FILL",ti.SYNC_MESSAGE_BACKGROUND="SYNC_MESSAGE_BACKGROUND",ti.SYNC_MESSAGE_CHANGELOGS="SYNC_MESSAGE_CHANGELOGS",ti.LOCAL_MESSAGE_PENDING_CREATED="LOCAL_MESSAGE_PENDING_CREATED",ti.LOCAL_MESSAGE_FAILED="LOCAL_MESSAGE_FAILED",ti.LOCAL_MESSAGE_CANCELED="LOCAL_MESSAGE_CANCELED",ti.LOCAL_MESSAGE_RESEND_STARTED="LOCAL_MESSAGE_RESEND_STARTED";var ii,oi=function(t){return t.startsWith("EVENT_")||t===e.MessageEventSource.SYNC_MESSAGE_FILL||t===e.MessageEventSource.SYNC_MESSAGE_CHANGELOGS||t===e.MessageEventSource.SYNC_POLL_CHANGELOGS},ui=function(e){i(n,e);var t=f(n);function n(e){var a,s=e.messages,i=e.source,o=e.isWebSocketEventComing,u=void 0!==o&&o;return r(this,n),(a=t.call(this)).messages=s,a.source=i,a.isWebSocketEventComing=u,a}return s(n)}(oe),ci=function(e){i(n,e);var t=f(n);function n(e){var a,s=e.messageIds,i=e.source,o=e.isWebSocketEventComing,u=void 0!==o&&o;return r(this,n),(a=t.call(this)).messageIds=s,a.source=i,a.isWebSocketEventComing=u,a}return s(n)}(oe),li=function(e){i(n,e);var t=f(n);function n(e){var a,s=e.reqId,i=e.source;return r(this,n),(a=t.call(this)).reqId=s,a.source=i,a}return s(n)}(oe),hi=function(e){i(n,e);var t=f(n);function n(e){var a,s=e.polls,i=e.source;return r(this,n),(a=t.call(this)).polls=s,a.source=i,a}return s(n)}(oe),di=function(e){i(n,e);var t=f(n);function n(e){var a,s=e.event,i=e.source;return r(this,n),(a=t.call(this)).event=s,a.source=i,a}return s(n)}(oe),fi=function(e){i(n,e);var t=f(n);function n(e){var a,s=e.event,i=e.source;return r(this,n),(a=t.call(this)).event=s,a.source=i,a}return s(n)}(oe),pi=function(e){i(n,e);var t=f(n);function n(e){var a,s=e.channelType,i=e.channelUrl,o=e.messageId,u=e.includeMetaArray,c=e.includeReactions,l=e.includeThreadInfo,h=e.includeParentMessageInfo;return r(this,n),(a=t.call(this)).method=le.GET,a.path="".concat(Te(s),"/").concat(encodeURIComponent(i),"/messages/").concat(encodeURIComponent(o)),a.params={is_sdk:!0,with_sorted_meta_array:u,include_reactions:c,include_thread_info:l,include_parent_message_info:h,include_poll_details:!0},a}return s(n)}(Oe),vi=function(e){i(n,e);var t=f(n);function n(e,a){var s;return r(this,n),(s=t.call(this,e,a)).message=a?Bs(e,Object.assign({},a)):null,s}return s(n)}(Ue),_i=function(e){i(n,e);var t=f(n);function n(e){var a,s=e.channelType,i=e.channelUrl,o=e.timestamp,u=e.token,c=e.prevResultSize,l=e.nextResultSize,h=e.isInclusive,d=e.reverse,f=e.messageTypeFilter,p=e.customTypesFilter,v=e.senderUserIdsFilter,_=e.replyType,m=e.includeMetaArray,g=e.includeReactions,y=e.parentMessageId,k=e.includeThreadInfo,b=e.includeParentMessageInfo,E=e.showSubchannelMessagesOnly,w=e.checkingContinuousMessages;return r(this,n),(a=t.call(this)).method=le.GET,a.path="".concat(Te(s),"/").concat(encodeURIComponent(i),"/messages"),a.params=ue(ce({is_sdk:!0,prev_limit:c,next_limit:l,include:h,reverse:d,message_ts:o,message_id:u,message_type:null!=f?f:null,custom_types:p,sender_ids:v,include_reply_type:_,with_sorted_meta_array:m,include_reactions:g,parent_message_id:y,include_thread_info:k,include_parent_message_info:b,show_subchannel_message_only:E,include_poll_details:!0,checking_continuous_messages:w})),a}return s(n)}(Oe),mi=function(e){i(n,e);var t=f(n);function n(e,a){var s;return r(this,n),(s=t.call(this,e,a)).messages=a.messages.map((function(t){return Bs(e,t)})),s}return s(n)}(Ue),gi=function(e){i(n,e);var t=f(n);function n(e){var a,s=e.channelType,i=e.channelUrl,o=e.timestamp,u=e.token,c=e.replyType,l=e.includeMetaArray,h=e.includeReactions,d=e.includeThreadInfo,f=e.includeParentMessageInfo;return r(this,n),(a=t.call(this)).method=le.GET,a.path="".concat(Te(s),"/").concat(encodeURIComponent(i),"/messages/changelogs"),a.params={change_ts:o,token:u,with_sorted_meta_array:l,include_reactions:h,include_thread_info:d,include_reply_type:c,include_parent_message_info:f,include_poll_details:!0},a}return s(n)}(Oe),yi=function(e){i(n,e);var t=f(n);function n(e,a){var s;return r(this,n),(s=t.call(this,e,a)).updatedMessages=a.updated.map((function(t){return Bs(e,t)})),s.deletedMessagesInfo=a.deleted.map((function(e){return{messageId:e.message_id,deletedAt:e.deleted_at}})),s.hasMore=a.has_more,s.nextToken=a.next,s}return s(n)}(Ue),ki=function(e){i(n,e);var t=f(n);function n(e){var a,s=e.channelUrl,i=e.scheduledMessageId;return r(this,n),(a=t.call(this)).method=le.GET,a.path="".concat(pe,"/").concat(encodeURIComponent(s),"/scheduled_messages/").concat(encodeURIComponent(i)),a.params={},a}return s(n)}(Oe),bi=function(e){i(n,e);var t=f(n);function n(e,a){var s;return r(this,n),(s=t.call(this,e,a)).message=a?Bs(e,Object.assign({},a)):null,s}return s(n)}(Ue),Ei={},wi=function(){function n(e,t){var a=t.sdkState,s=t.dispatcher,i=t.requestQueue,o=t.onlineDetector,u=t.cacheContext;r(this,n),this._iid=e,this._sdkState=a,this._requestQueue=i,this._dispatcher=s,this._cacheContext=u,this.fileMessageQueue=new $s(e,{sdkState:a,dispatcher:s,requestQueue:i,onlineDetector:o,cacheContext:u}),Ei[e]=this}return s(n,[{key:"buildMessageFromSerializedData",value:function(t){var n=Ya(t);switch(n.messageType){case e.MessageType.USER:return new Hs(this._iid,Hs.payloadify(n));case e.MessageType.FILE:return zs._isMultipleFilesMessageSerializedData(n)?new zs(this._iid,zs.payloadify(n)):new Qs(this._iid,Qs.payloadify(n));case e.MessageType.ADMIN:return new Rs(this._iid,Rs.payloadify(n))}throw A.invalidParameters}},{key:"buildUserMessageCreateParamsFromSerializedData",value:function(e,t){return ue(ce({data:t.data,customType:t.customType,mentionType:t.mentionType,mentionedUserIds:t.mentionedUserIds,mentionedUsers:t.mentionedUsers,mentionedMessageTemplate:t.mentionedMessageTemplate,metaArrays:t.metaArrays,parentMessageId:t.parentMessageId,isReplyToChannel:e.isReplyToChannel,pushNotificationDeliveryOption:e.pushNotificationDeliveryOption,appleCriticalAlertOptions:t.appleCriticalAlertOptions,reqId:t.reqId,message:t.message,translationTargetLanguages:Object.keys(t.translations),pollId:e.pollId}))}},{key:"buildFileMessageCreateParamsFromSerializedData",value:function(e,t){var n;return ue(ce({data:t.data,customType:t.customType,mentionType:t.mentionType,mentionedUserIds:t.mentionedUserIds,mentionedUsers:t.mentionedUsers,mentionedMessageTemplate:t.mentionedMessageTemplate,metaArrays:t.metaArrays,parentMessageId:t.parentMessageId,isReplyToChannel:e.isReplyToChannel,pushNotificationDeliveryOption:e.pushNotificationDeliveryOption,appleCriticalAlertOptions:t.appleCriticalAlertOptions,reqId:t.reqId,file:e.file,fileKey:e.fileKey,fileUrl:t.plainUrl,fileName:t.name,fileSize:t.size,mimeType:t.type,thumbnailSizes:null===(n=t.thumbnails)||void 0===n?void 0:n.map((function(e){return{maxWidth:e.width,maxHeight:e.height}})),fileType:e.fileType,requireAuth:t.requireAuth}))}},{key:"buildMultipleFilesMessageCreateParamsFromSerializedData",value:function(e,t){return ue({data:t.data,customType:t.customType,mentionType:t.mentionType,mentionedUserIds:t.mentionedUserIds,mentionedUsers:t.mentionedUsers,mentionedMessageTemplate:t.mentionedMessageTemplate,metaArrays:t.metaArrays,parentMessageId:t.parentMessageId,isReplyToChannel:e.isReplyToChannel,pushNotificationDeliveryOption:e.pushNotificationDeliveryOption,appleCriticalAlertOptions:t.appleCriticalAlertOptions,reqId:t.reqId,fileInfoList:e.fileInfoList})}},{key:"buildScheduledUserMessageCreateParamsFromSerializedData",value:function(e,t){return Object.assign(Object.assign({},this.buildUserMessageCreateParamsFromSerializedData(e,t)),{scheduledAt:e.scheduledAt})}},{key:"buildScheduledFileMessageCreateParamsFromSerializedData",value:function(e,t){return Object.assign(Object.assign({},this.buildFileMessageCreateParamsFromSerializedData(e,t)),{scheduledAt:e.scheduledAt})}},{key:"buildSenderFromSerializedData",value:function(e){var t=Ya(e);return new Ts(this._iid,Ts.payloadify(t))}},{key:"getMessage",value:function(e){return b(this,void 0,void 0,t().mark((function n(){var r,a,s,i;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return r=new pi(e),t.next=3,this._requestQueue.send(r);case 3:return a=t.sent,s=a.as(vi),i=s.message,t.abrupt("return",i);case 6:case"end":return t.stop()}}),n,this)})))}},{key:"getScheduledMessage",value:function(e){return b(this,void 0,void 0,t().mark((function n(){var r,a,s,i;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return r=new ki(e),t.next=3,this._requestQueue.send(r);case 3:return a=t.sent,s=a.as(bi),i=s.message,t.abrupt("return",i);case 6:case"end":return t.stop()}}),n,this)})))}},{key:"getMessagesByMessageId",value:function(n,r,a,s){var i=arguments.length>4&&void 0!==arguments[4]?arguments[4]:e.MessageEventSource.REQUEST_MESSAGE;return b(this,void 0,void 0,t().mark((function e(){var o,u,c,l;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return o=new _i(Object.assign(Object.assign({channelType:r,channelUrl:n,token:String(a)},ni),s)),e.next=3,this._requestQueue.send(o);case 3:return u=e.sent,c=u.as(mi),l=c.messages,this._dispatcher.dispatch(new ui({messages:l,source:i})),e.abrupt("return",l);case 7:case"end":return e.stop()}}),e,this)})))}},{key:"getMessagesByTimestamp",value:function(n,r,a,s){var i=arguments.length>4&&void 0!==arguments[4]?arguments[4]:e.MessageEventSource.REQUEST_MESSAGE;return b(this,void 0,void 0,t().mark((function e(){var o,u,c,l;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return o=new _i(Object.assign(Object.assign({channelType:r,channelUrl:n,timestamp:a},ni),s)),e.next=3,this._requestQueue.send(o);case 3:return u=e.sent,c=u.as(mi),l=c.messages,this._dispatcher.dispatch(new ui({messages:l,source:i})),e.abrupt("return",l);case 7:case"end":return e.stop()}}),e,this)})))}},{key:"_getMessagesByTimestampForCollection",value:function(n,r,a,s){var i=arguments.length>4&&void 0!==arguments[4]?arguments[4]:e.MessageEventSource.REQUEST_MESSAGE,o=arguments.length>5?arguments[5]:void 0;return b(this,void 0,void 0,t().mark((function e(){var u,c,l,h,d;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return u=new _i(Object.assign(Object.assign(Object.assign({channelType:r,channelUrl:n,timestamp:a},ni),s),{checkingContinuousMessages:o})),e.next=3,this._requestQueue.send(u);case 3:return c=e.sent,l=c.payload,h=c.as(mi),d=h.messages,this._dispatcher.dispatch(new ui({messages:d,source:i})),e.abrupt("return",{messages:d,isContinuousMessages:l});case 8:case"end":return e.stop()}}),e,this)})))}},{key:"getThreadedMessagesByTimestamp",value:function(n,r,a){var s=arguments.length>3&&void 0!==arguments[3]?arguments[3]:e.MessageEventSource.REQUEST_THREADED_MESSAGE;return b(this,void 0,void 0,t().mark((function i(){var o,u,c,l,h;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return o=new _i(Object.assign(Object.assign(Object.assign({channelUrl:n.channelUrl,channelType:n.channelType,timestamp:r},Os),a),{replyType:e.ReplyType.ALL,parentMessageId:n.messageId,includeThreadInfo:!0})),t.next=3,this._requestQueue.send(o);case 3:return u=t.sent,c=u.as(mi),l=c.messages,(h=l.slice(1)).forEach((function(e){e.parentMessage=n})),this._dispatcher.dispatch(new ui({messages:h,source:s})),t.abrupt("return",{parentMessage:l[0],threadedMessages:h});case 9:case"end":return t.stop()}}),i,this)})))}},{key:"getMessageChangelogs",value:function(n,r,a,s){var i=arguments.length>4&&void 0!==arguments[4]?arguments[4]:e.MessageEventSource.REQUEST_MESSAGE_CHANGELOGS;return b(this,void 0,void 0,t().mark((function e(){var o,u,c,l,h,d,f,p;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return o=new gi(ue(ce(Object.assign(Object.assign({channelType:r,channelUrl:n,timestamp:"number"==typeof a?a:null,token:"string"==typeof a?a:null},ai),s)))),e.next=3,this._requestQueue.send(o);case 3:return u=e.sent,c=u.as(yi),l=c.updatedMessages,h=c.deletedMessagesInfo,d=c.hasMore,f=c.nextToken,p=h.map((function(e){return e.messageId})),l.length>0&&this._dispatcher.dispatch(new ui({messages:l,source:i})),p.length>0&&this._dispatcher.dispatch(new ci({messageIds:p,source:i})),e.abrupt("return",{updatedMessages:l,deletedMessageIds:p,hasMore:d,token:f});case 9:case"end":return e.stop()}}),e,this)})))}}],[{key:"of",value:function(e){return Ei[e]}}]),n}(),Ci=function(){function t(){r(this,t),this._onPending=He,this._onFailed=He,this._onSucceeded=He}return s(t,[{key:"_trigger",value:function(t,n){switch(null==n?void 0:n.sendingStatus){case e.SendingStatus.PENDING:0===n.errorCode&&this._onPending(n);break;case e.SendingStatus.FAILED:case e.SendingStatus.CANCELED:this._onFailed(t,n.scheduledInfo?null:n);break;case e.SendingStatus.SCHEDULED:case e.SendingStatus.SUCCEEDED:this._onSucceeded(n)}}},{key:"onPending",value:function(e){return this._onPending=e,this}},{key:"onFailed",value:function(e){return this._onFailed=e,this}},{key:"onSucceeded",value:function(e){return this._onSucceeded=e,this}}]),t}(),xi=function(e){i(n,e);var t=f(n);function n(e,a){var s;r(this,n),(s=t.call(this,e)).targetMessageId=0;var i=a.thread_info,o=a.parent_message_id,u=a.channel_url,c=a.channel_type;return i&&L("object",i)&&L("number",o)&&L("string",u)&&L("string",c)&&(s.threadInfo=new ms(e,i),s.targetMessageId=o,s.channelUrl=u,s.channelType=c),s}return s(n)}(Ha),Ti={channelUrl:"",channelType:e.ChannelType.BASE,messageId:0,includeReactions:!1,includeMetaArray:!1,includeParentMessageInfo:!1,includeThreadInfo:!1},Si=function(t){return L("string",t.channelUrl)&&D(e.ChannelType,t.channelType)&&L("number",t.messageId)&&L("boolean",t.includeReactions,!0)&&L("boolean",t.includeMetaArray,!0)&&L("boolean",t.includeParentMessageInfo,!0)&&L("boolean",t.includeThreadInfo,!0)},Ii=function(){function e(t,n){var a;r(this,e),this.limit=20,this._isLoading=!1,this._hasNext=!0,this._token="",this._iid=t,this.limit=null!==(a=n.limit)&&void 0!==a?a:20}return s(e,[{key:"hasNext",get:function(){return this._hasNext}},{key:"isLoading",get:function(){return this._isLoading}},{key:"_validate",value:function(){return L("number",this.limit)&&this.limit>0}}]),e}(),Ni=function(e){i(n,e);var t=f(n);function n(e){var a,s=e.channelCustomType,i=e.keyword,o=e.limit,u=e.reverse,c=e.exactMatch,l=e.channelUrl,h=e.order,d=e.messageTimestampFrom,f=e.messageTimestampTo,p=e.advancedQuery,v=e.targetFields,_=e.nextToken;return r(this,n),(a=t.call(this)).method=le.GET,a.path="".concat(ge,"/messages"),a.params={custom_type:s,query:i,limit:o,reverse:u,exact_match:c,channel_url:l,message_ts_from:d,message_ts_to:f,sort_field:h,advanced_query:p,target_fields:v,after:_},a}return s(n)}(Oe),Mi=function(e){i(n,e);var t=f(n);function n(e,a){var s;return r(this,n),(s=t.call(this,e,a)).messages=a.results.map((function(t){return Bs(e,t)})),s.hasNext=a.has_next,s.nextToken=a.end_cursor,s.totalCount=a.total_count,s}return s(n)}(Ue);e.MessageSearchOrder=void 0,(ii=e.MessageSearchOrder||(e.MessageSearchOrder={})).SCORE="score",ii.TIMESTAMP="ts";var Ai,Oi,Ui,Ri=function(n){i(u,n);var a=f(u);function u(t,n){var s,i,o,c,l,h,d,f,p,v;return r(this,u),(s=a.call(this,t,n)).keyword="",s.reverse=!1,s.exactMatch=!1,s.channelUrl="",s.channelCustomType="",s.messageTimestampFrom=null,s.messageTimestampTo=null,s.order=e.MessageSearchOrder.SCORE,s.advancedQuery=!1,s.targetFields=null,s._nextToken="",s.totalCount=-1,s.keyword=n.keyword,s.reverse=null!==(i=n.reverse)&&void 0!==i&&i,s.exactMatch=null!==(o=n.exactMatch)&&void 0!==o&&o,s.channelUrl=null!==(c=n.channelUrl)&&void 0!==c?c:"",s.channelCustomType=null!==(l=n.channelCustomType)&&void 0!==l?l:"",s.messageTimestampFrom=null!==(h=n.messageTimestampFrom)&&void 0!==h?h:null,s.messageTimestampTo=null!==(d=n.messageTimestampTo)&&void 0!==d?d:null,s.order=null!==(f=n.order)&&void 0!==f?f:e.MessageSearchOrder.SCORE,s.advancedQuery=null!==(p=n.advancedQuery)&&void 0!==p&&p,s.targetFields=null!==(v=n.targetFields)&&void 0!==v?v:null,s}return s(u,[{key:"_validate",value:function(){return p(o(u.prototype),"_validate",this).call(this)&&L("string",this.keyword)&&this.keyword.length>0&&L("boolean",this.reverse)&&L("boolean",this.exactMatch)&&L("string",this.channelUrl)&&L("string",this.channelCustomType)&&(L("number",this.messageTimestampFrom)||null===this.messageTimestampFrom)&&(L("number",this.messageTimestampTo)||null===this.messageTimestampTo)&&D(e.MessageSearchOrder,this.order)&&L("boolean",this.advancedQuery)&&F("string",this.targetFields,!0)}},{key:"next",value:function(){return b(this,void 0,void 0,t().mark((function e(){var n,r,a,s,i,o,u,c,l;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!this._validate()){e.next=21;break}if(this._isLoading){e.next=18;break}if(!this._hasNext){e.next=15;break}return this._isLoading=!0,n=fs.of(this._iid),r=n.requestQueue,a=new Ni(ce(Object.assign(Object.assign({},this),{nextToken:this._nextToken?this._nextToken:null}))),e.next=8,r.send(a);case 8:return s=e.sent,i=s.as(Mi),o=i.messages,u=i.hasNext,c=i.nextToken,l=i.totalCount,this._nextToken=c,this._hasNext=u,this._isLoading=!1,this.totalCount=l,e.abrupt("return",o);case 15:return e.abrupt("return",[]);case 18:throw A.queryInProgress;case 19:e.next=22;break;case 21:throw A.invalidParameters;case 22:case"end":return e.stop()}}),e,this)})))}}]),u}(Ii),Li=function(t){i(a,t);var n=f(a);function a(e,t,s,i){var o;return r(this,a),(o=n.call(this,e,i)).channelUrl=t,o.channelType=s,o}return s(a,[{key:"_validate",value:function(){return p(o(a.prototype),"_validate",this).call(this)&&L("string",this.channelUrl)&&D(e.ChannelType,this.channelType)}}]),a}(Ii),Di=function(n){i(u,n);var a=f(u);function u(t,n,s,i){var o,c,l,h,d,f,p,v,_,m,g;return r(this,u),(o=a.call(this,t,n,s,i)).reverse=!1,o.messageTypeFilter=e.MessageTypeFilter.ALL,o.customTypesFilter=null,o.senderUserIdsFilter=null,o.replyType=e.ReplyType.NONE,o.includeMetaArray=!1,o.includeReactions=!1,o.includeParentMessageInfo=!1,o.includeThreadInfo=!1,o.showSubchannelMessagesOnly=!1,o._edge=Number.MAX_SAFE_INTEGER,o.reverse=null!==(c=i.reverse)&&void 0!==c&&c,o.messageTypeFilter=null!==(l=i.messageTypeFilter)&&void 0!==l?l:e.MessageTypeFilter.ALL,o.customTypesFilter=null!==(h=i.customTypesFilter)&&void 0!==h?h:null,o.senderUserIdsFilter=null!==(d=i.senderUserIdsFilter)&&void 0!==d?d:null,o.replyType=null!==(f=i.replyType)&&void 0!==f?f:e.ReplyType.NONE,o.includeMetaArray=null!==(p=i.includeMetaArray)&&void 0!==p&&p,o.includeReactions=null!==(v=i.includeReactions)&&void 0!==v&&v,o.includeParentMessageInfo=null!==(_=i.includeParentMessageInfo)&&void 0!==_&&_,o.includeThreadInfo=null!==(m=i.includeThreadInfo)&&void 0!==m&&m,o.showSubchannelMessagesOnly=null!==(g=i.showSubchannelMessagesOnly)&&void 0!==g&&g,o}return s(u,[{key:"_validate",value:function(){return p(o(u.prototype),"_validate",this).call(this)&&L("boolean",this.reverse)&&D(e.MessageTypeFilter,this.messageTypeFilter)&&D(e.ReplyType,this.replyType)&&F("string",this.customTypesFilter,!0)&&F("string",this.senderUserIdsFilter,!0)&&L("boolean",this.includeMetaArray)&&L("boolean",this.includeReactions)&&L("boolean",this.includeParentMessageInfo)&&L("boolean",this.includeThreadInfo)&&L("boolean",this.showSubchannelMessagesOnly)}},{key:"load",value:function(){return b(this,void 0,void 0,t().mark((function e(){var n,r;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!this._validate()){e.next=18;break}if(this._isLoading){e.next=15;break}if(!this._hasNext){e.next=12;break}return this._isLoading=!0,n=wi.of(this._iid),e.next=7,n.getMessagesByTimestamp(this.channelUrl,this.channelType,this._edge,ce({prevResultSize:this.limit,nextResultSize:0,isInclusive:!1,reverse:this.reverse,messageTypeFilter:this.messageTypeFilter,customTypesFilter:this.customTypesFilter,replyType:this.replyType,senderUserIdsFilter:this.senderUserIdsFilter,includeReactions:this.includeReactions,includeMetaArray:this.includeMetaArray,includeParentMessageInfo:this.includeParentMessageInfo,includeThreadInfo:this.includeThreadInfo,showSubchannelMessagesOnly:this.showSubchannelMessagesOnly}));case 7:return r=e.sent,this._edge=Math.min.apply(Math,[Number.MAX_SAFE_INTEGER].concat(_(r.map((function(e){return e.createdAt}))))),this._hasNext=r.length>=this.limit,this._isLoading=!1,e.abrupt("return",r);case 12:return e.abrupt("return",[]);case 15:throw A.queryInProgress;case 16:e.next=19;break;case 18:throw A.invalidParameters;case 19:case"end":return e.stop()}}),e,this)})))}}]),u}(Li),Pi={channelUrl:"",scheduledMessageId:0},Fi=function(e){return L("string",e.channelUrl)&&""!==e.channelUrl&&L("number",e.scheduledMessageId)&&e.scheduledMessageId>0},Gi=function(e){i(n,e);var t=f(n);function n(){var e;return r(this,n),(e=t.apply(this,arguments))._onFileUploaded=He,e}return s(n,[{key:"_triggerOnFileUploaded",value:function(e,t,n,r){this._onFileUploaded(e,t,n,r)}},{key:"onFileUploaded",value:function(e){return this._onFileUploaded=e,this}},{key:"onPending",value:function(e){return p(o(n.prototype),"onPending",this).call(this,e),this}},{key:"onFailed",value:function(e){return p(o(n.prototype),"onFailed",this).call(this,e),this}},{key:"onSucceeded",value:function(e){return p(o(n.prototype),"onSucceeded",this).call(this,e),this}}]),n}(Ci),qi=function(e){i(a,e);var n=f(a);function a(){var e;return r(this,a),(e=n.apply(this,arguments)).name="message",e}return s(a,[{key:"init",value:function(e,t){var n=t.sdkState,r=t.dispatcher,s=t.sessionManager,i=t.requestQueue,u=t.logger,c=t.onlineDetector,l=t.cacheContext;p(o(a.prototype),"init",this).call(this,e,{sdkState:n,dispatcher:r,sessionManager:s,requestQueue:i,logger:u,onlineDetector:c,cacheContext:l}),this._manager=new wi(e,{sdkState:n,dispatcher:r,requestQueue:i,onlineDetector:c,cacheContext:l})}},{key:"buildMessageFromSerializedData",value:function(e){return this._manager.buildMessageFromSerializedData(e)}},{key:"buildSenderFromSerializedData",value:function(e){return this._manager.buildSenderFromSerializedData(e)}},{key:"getMessage",value:function(e){return b(this,void 0,void 0,t().mark((function n(){var r;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return r=Object.assign(Object.assign({},Ti),e),Za(Si(r)).throw(A.invalidParameters),t.abrupt("return",this._manager.getMessage(r));case 3:case"end":return t.stop()}}),n,this)})))}},{key:"getScheduledMessage",value:function(e){return b(this,void 0,void 0,t().mark((function n(){var r;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return r=Object.assign(Object.assign({},Pi),e),Za(Fi(r)).throw(A.invalidParameters),t.abrupt("return",this._manager.getScheduledMessage(r));case 3:case"end":return t.stop()}}),n,this)})))}}]),a}(ps),Hi=function(e){i(n,e);var t=f(n);function n(e){var a,s=e.title,i=e.optionTexts,o=e.data,u=e.allowUserSuggestion,c=e.allowMultipleVotes,l=e.closeAt;return r(this,n),(a=t.call(this)).method=le.POST,a.path=Ee,a.params={title:s,options:i,data:o,allow_user_suggestion:u,allow_multiple_votes:c,close_at:l},a}return s(n)}(Oe),ji=function(e){i(n,e);var t=f(n);function n(e,a){var s;return r(this,n),(s=t.call(this,e,a)).poll=new qs(e,a),s}return s(n)}(Ue),zi=function(e){i(n,e);var t=f(n);function n(e){var a,s=e.channelUrl,i=e.channelType,o=e.pollId;return r(this,n),(a=t.call(this)).method=le.GET,a.path="".concat(Ee,"/").concat(encodeURIComponent(o)),a.params={channel_url:s,channel_type:i},a}return s(n)}(Oe),Vi=function(e){i(n,e);var t=f(n);function n(e,a){var s;return r(this,n),(s=t.call(this,e,a)).poll=new qs(e,a),s}return s(n)}(Ue),Bi=function(e){i(n,e);var t=f(n);function n(e){var a,s=e.channelUrl,i=e.channelType,o=e.pollId,u=e.pollOptionId;return r(this,n),(a=t.call(this)).method=le.GET,a.path="".concat(Ee,"/").concat(encodeURIComponent(o),"/options/").concat(encodeURIComponent(u)),a.params={channel_url:s,channel_type:i},a}return s(n)}(Oe),Qi=function(e){i(n,e);var t=f(n);function n(e,a){var s;return r(this,n),(s=t.call(this,e,a)).pollOption=new Gs(e,a),s}return s(n)}(Ue),Ki=function(e){i(n,e);var t=f(n);function n(e){var a,s=e.channelType,i=e.channelUrl,o=e.timestamp,u=e.token;return r(this,n),(a=t.call(this)).method=le.GET,a.path="".concat(Te(s),"/").concat(encodeURIComponent(i),"/polls/changelogs"),a.params=ue({change_ts:o,token:u}),a}return s(n)}(Oe),Wi=function(e){i(n,e);var t=f(n);function n(e,a){var s;return r(this,n),(s=t.call(this,e,a)).updatedPolls=a.updated.map((function(t){return function(e,t){return new qs(e,t)}(e,t)})),s.deletedPollIds=a.deleted.map((function(e){return e})),s.hasMore=a.has_more,s.nextToken=a.next,s}return s(n)}(Ue),Yi={title:"",optionTexts:[],data:void 0,allowUserSuggestion:void 0,allowMultipleVotes:void 0,closeAt:-1},Zi=function(e){return L("string",e.title)&&(t=e.optionTexts,F("string",t)&&t.every((function(e){return""!==e.trim()})))&&Fs(e.data)&&L("boolean",e.allowUserSuggestion,!0)&&L("boolean",e.allowMultipleVotes,!0)&&L("number",e.closeAt,!0);var t},Ji={channelUrl:"",channelType:e.ChannelType.BASE,pollId:0,pollOptionId:0},Xi=function(t){return L("string",t.channelUrl)&&""!==t.channelUrl&&D(e.ChannelType,t.channelType)&&L("number",t.pollId)&&t.pollId>0&&L("number",t.pollOptionId)&&t.pollOptionId>0},$i={channelUrl:"",channelType:e.ChannelType.BASE,pollId:0},eo=function(t){return L("string",t.channelUrl)&&""!==t.channelUrl&&D(e.ChannelType,t.channelType)&&L("number",t.pollId)},to={},no=function(){function n(e,t){var a=t.sdkState,s=t.dispatcher,i=t.sessionManager,o=t.requestQueue,u=t.logger;r(this,n),this._iid=e,this._sdkState=a,this._sessionManager=i,this._requestQueue=o,this._dispatcher=s,this._logger=u,to[e]=this}return s(n,[{key:"buildPollFromSerializedData",value:function(e){var t=Ya(e);return new qs(this._iid,qs.payloadify(t))}},{key:"get",value:function(e){return b(this,void 0,void 0,t().mark((function n(){var r,a,s,i;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return Za(eo(e)).throw(A.invalidParameters),r=new zi(Object.assign({},e)),t.next=4,this._requestQueue.send(r);case 4:return a=t.sent,s=a.as(Vi),i=s.poll,t.abrupt("return",i);case 7:case"end":return t.stop()}}),n,this)})))}},{key:"create",value:function(e){return b(this,void 0,void 0,t().mark((function n(){var r,a,s,i;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return Za(Zi(e)).throw(A.invalidParameters),r=new Hi(Object.assign({},e)),t.next=4,this._requestQueue.send(r);case 4:return a=t.sent,s=a.as(ji),i=s.poll,t.abrupt("return",i);case 7:case"end":return t.stop()}}),n,this)})))}},{key:"getOption",value:function(e){return b(this,void 0,void 0,t().mark((function n(){var r,a,s,i;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return Za(Xi(e)).throw(A.invalidParameters),r=new Bi(Object.assign({},e)),t.next=4,this._requestQueue.send(r);case 4:return a=t.sent,s=a.as(Qi),i=s.pollOption,t.abrupt("return",i);case 7:case"end":return t.stop()}}),n,this)})))}},{key:"getPollChangeLogs",value:function(n,r,a){var s=arguments.length>3&&void 0!==arguments[3]?arguments[3]:e.MessageEventSource.SYNC_POLL_CHANGELOGS;return b(this,void 0,void 0,t().mark((function e(){var i,o,u,c,l,h,d;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return i=new Ki(ce({channelType:r,channelUrl:n,timestamp:"number"==typeof a?a:null,token:"string"==typeof a?a:null})),e.next=3,this._requestQueue.send(i);case 3:return o=e.sent,u=o.as(Wi),c=u.updatedPolls,l=u.deletedPollIds,h=u.hasMore,d=u.nextToken,c.length>0&&this._dispatcher.dispatch(new hi({polls:c,source:s})),e.abrupt("return",{updatedPolls:c,deletedPollIds:l,hasMore:h,token:d});case 7:case"end":return e.stop()}}),e,this)})))}}],[{key:"of",value:function(e){return to[e]}}]),n}(),ro=s((function e(t,n){r(this,e),this.pollId=0,this.messageId=0,this.pollId=n.poll.id,this.messageId=n.poll.message_id,this._iid=t,this._payload=n})),ao=s((function e(t){r(this,e),this.pollId=0,this.messageId=0,this.pollId=t.poll_id,this.messageId=t.message_id,this._payload=t})),so=function(e){i(n,e);var t=f(n);function n(e){var a,s=e.channelUrl,i=e.channelType,o=e.token,u=e.limit;return r(this,n),(a=t.call(this)).method=le.GET,a.path=Ee,a.params={channel_url:s,channel_type:i,token:o,limit:u},a}return s(n)}(Oe),io=function(e){i(n,e);var t=f(n);function n(e,a){var s,i;return r(this,n),(s=t.call(this,e,a)).polls=(null!==(i=a.polls)&&void 0!==i?i:[]).map((function(t){return new qs(e,t)})),s.token=a.next,s}return s(n)}(Ue),oo=function(e){i(a,e);var n=f(a);function a(e,t){return r(this,a),n.call(this,e,t.channelUrl,t.channelType,t)}return s(a,[{key:"next",value:function(){return b(this,void 0,void 0,t().mark((function e(){var n,r,a,s,i,o,u;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!this._validate()){e.next=20;break}if(this._isLoading){e.next=17;break}if(!this._hasNext){e.next=14;break}return this._isLoading=!0,n=fs.of(this._iid),r=n.requestQueue,a=new so(Object.assign(Object.assign({},this),{token:this._token})),e.next=8,r.send(a);case 8:return s=e.sent,i=s.as(io),o=i.polls,u=i.token,this._token=u,this._hasNext=!!u,this._isLoading=!1,e.abrupt("return",o);case 14:return e.abrupt("return",[]);case 17:throw A.queryInProgress;case 18:e.next=21;break;case 20:throw A.invalidParameters;case 21:case"end":return e.stop()}}),e,this)})))}}]),a}(Li),uo=function(e){i(n,e);var t=f(n);function n(e){var a,s=e.channelUrl,i=e.channelType,o=e.pollId,u=e.pollOptionId,c=e.token,l=e.limit;return r(this,n),(a=t.call(this)).method=le.GET,a.path="".concat(Ee,"/").concat(encodeURIComponent(o),"/options/").concat(encodeURIComponent(u),"/voters"),a.params={channel_url:s,channel_type:i,token:c,limit:l},a}return s(n)}(Oe),co=function(e){i(n,e);var t=f(n);function n(e,a){var s,i;return r(this,n),(s=t.call(this,e,a)).voters=(null!==(i=a.voters)&&void 0!==i?i:[]).map((function(t){return new Xa(e,t)})),s.token=a.next,s}return s(n)}(Ue),lo=function(e){i(a,e);var n=f(a);function a(e,t){var s;return r(this,a),(s=n.call(this,e,t.channelUrl,t.channelType,t)).pollId=t.pollId,s.pollOptionId=t.pollOptionId,s}return s(a,[{key:"_validate",value:function(){return p(o(a.prototype),"_validate",this).call(this)&&L("number",this.pollId)&&L("number",this.pollOptionId)}},{key:"next",value:function(){return b(this,void 0,void 0,t().mark((function e(){var n,r,a,s,i,o,u;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!this._validate()){e.next=20;break}if(this._isLoading){e.next=17;break}if(!this._hasNext){e.next=14;break}return this._isLoading=!0,n=fs.of(this._iid),r=n.requestQueue,a=new uo(Object.assign(Object.assign({},this),{pollId:this.pollId,pollOptionId:this.pollOptionId,token:this._token})),e.next=8,r.send(a);case 8:return s=e.sent,i=s.as(co),o=i.voters,u=i.token,this._token=u,this._hasNext=!!u,this._isLoading=!1,e.abrupt("return",o);case 14:return e.abrupt("return",[]);case 17:throw A.queryInProgress;case 18:e.next=21;break;case 20:throw A.invalidParameters;case 21:case"end":return e.stop()}}),e,this)})))}}]),a}(Li),ho=function(e){i(a,e);var n=f(a);function a(){var e;return r(this,a),(e=n.apply(this,arguments)).name="poll",e}return s(a,[{key:"init",value:function(e,t){var n=t.sdkState,r=t.dispatcher,s=t.sessionManager,i=t.requestQueue,u=t.logger,c=t.onlineDetector,l=t.cacheContext;p(o(a.prototype),"init",this).call(this,e,{sdkState:n,dispatcher:r,sessionManager:s,requestQueue:i,logger:u,onlineDetector:c,cacheContext:l}),this._manager=new no(e,{sdkState:n,dispatcher:r,sessionManager:s,requestQueue:i,logger:u,onlineDetector:c,cacheContext:l})}},{key:"create",value:function(e){return b(this,void 0,void 0,t().mark((function n(){var r;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return r=Object.assign(Object.assign({},Yi),e),Za(Zi(r)).throw(A.invalidParameters),t.abrupt("return",this._manager.create(r));case 3:case"end":return t.stop()}}),n,this)})))}},{key:"get",value:function(e){return b(this,void 0,void 0,t().mark((function n(){var r;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return r=Object.assign(Object.assign({},$i),e),Za(eo(r)).throw(A.invalidParameters),t.abrupt("return",this._manager.get(r));case 3:case"end":return t.stop()}}),n,this)})))}},{key:"getOption",value:function(e){return b(this,void 0,void 0,t().mark((function n(){var r;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return r=Object.assign(Object.assign({},Ji),e),Za(Xi(r)).throw(A.invalidParameters),t.abrupt("return",this._manager.getOption(r));case 3:case"end":return t.stop()}}),n,this)})))}},{key:"buildPollFromSerializedData",value:function(e){return this._manager.buildPollFromSerializedData(e)}}]),a}(ps),fo={profileImage:void 0,profileUrl:void 0,nickname:void 0},po=function(e){return q(e.profileImage,!0)&&L("string",e.profileUrl,!0)&&L("string",e.nickname,!0)},vo=function(e){i(n,e);var t=f(n);function n(){var e,a=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return r(this,n),e=t.call(this),Object.keys(a).forEach((function(t){e.hasOwnProperty(t)&&(e[t]=a[t])})),e}return s(n)}(s((function e(){r(this,e),this.onSessionExpired=He,this.onSessionTokenRequired=function(e){return e(null)},this.onSessionError=He,this.onSessionRefreshed=He,this.onSessionClosed=He}))),_o=function(e){i(n,e);var t=f(n);function n(){var e,a=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return r(this,n),e=t.call(this),Object.keys(a).forEach((function(t){e.hasOwnProperty(t)&&(e[t]=a[t])})),e}return s(n)}(s((function e(){r(this,e),this.onConnected=He,this.onReconnectStarted=He,this.onReconnectSucceeded=He,this.onReconnectFailed=He,this.onDisconnected=He}))),mo=function(e){i(n,e);var t=f(n);function n(){var e,a=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return r(this,n),e=t.call(this),Object.keys(a).forEach((function(t){e.hasOwnProperty(t)&&(e[t]=a[t])})),e}return s(n)}(s((function e(){r(this,e),this.onFriendsDiscovered=He,this.onTotalUnreadMessageCountUpdated=He}))),go="GroupChannel",yo=100,ko="Message";e.GroupChannelListOrder=void 0,(Ai=e.GroupChannelListOrder||(e.GroupChannelListOrder={})).LATEST_LAST_MESSAGE="latest_last_message",Ai.CHRONOLOGICAL="chronological",Ai.CHANNEL_NAME_ALPHABETICAL="channel_name_alphabetical",Ai.METADATA_VALUE_ALPHABETICAL="metadata_value_alphabetical",e.PublicGroupChannelListOrder=void 0,(Oi=e.PublicGroupChannelListOrder||(e.PublicGroupChannelListOrder={})).CHRONOLOGICAL="chronological",Oi.CHANNEL_NAME_ALPHABETICAL="channel_name_alphabetical",Oi.METADATA_VALUE_ALPHABETICAL="metadata_value_alphabetical",e.ScheduledMessageListOrder=void 0,(Ui=e.ScheduledMessageListOrder||(e.ScheduledMessageListOrder={})).CREATED_AT="created_at",Ui.SCHEDULED_AT="scheduled_at";var bo,Eo=function(t){switch(t){case e.GroupChannelListOrder.LATEST_LAST_MESSAGE:return["-lastMessageUpdatedAt","-createdAt","syncIndex"];case e.GroupChannelListOrder.CHRONOLOGICAL:return["-createdAt","syncIndex"];case e.GroupChannelListOrder.CHANNEL_NAME_ALPHABETICAL:return["name"];default:return["-lastMessageUpdatedAt","-createdAt","syncIndex"]}},wo=function(){function t(){r(this,t),this.messageTypeFilter=e.MessageTypeFilter.ALL,this.customTypesFilter=null,this.senderUserIdsFilter=null,this.replyType=e.ReplyType.NONE}return s(t,[{key:"clone",value:function(){var e=new t,n=JSON.parse(JSON.stringify(this));return Object.keys(n).forEach((function(t){e[t]=n[t]})),e}},{key:"match",value:function(t){switch(this.messageTypeFilter){case e.MessageTypeFilter.USER:if(t.messageType!==e.MessageType.USER)return!1;break;case e.MessageTypeFilter.FILE:if(t.messageType!==e.MessageType.FILE)return!1;break;case e.MessageTypeFilter.ADMIN:if(t.messageType!==e.MessageType.ADMIN)return!1}if(this.customTypesFilter&&this.customTypesFilter.length>0&&!this.customTypesFilter.includes(t.customType))return!1;if(this.senderUserIdsFilter&&this.senderUserIdsFilter.length>0){if(!(t instanceof Ms))return!1;if(!this.senderUserIdsFilter.includes(t.sender.userId))return!1}switch(this.replyType){case e.ReplyType.NONE:if(t.parentMessageId>0)return!1;break;case e.ReplyType.ONLY_REPLY_TO_CHANNEL:if(t instanceof Ms&&t.parentMessageId>0&&!t.replyToChannel)return!1}return!0}}]),t}();!function(e){e.CHANNEL_LATEST="channel_latest",e.NEWEST_CHILD_MESSAGE="newest_child_message"}(bo||(bo={}));var Co,xo=function(e){switch(e){case bo.CHANNEL_LATEST:return["channelUrl","-createdAt","-messageId"];case bo.NEWEST_CHILD_MESSAGE:return["channelUrl","-parentMessageId","-createdAt","-messageId"]}},To={data:void 0,customType:void 0,mentionType:e.MentionType.USERS,mentionedUserIds:void 0,mentionedUsers:void 0,mentionedMessageTemplate:void 0,metaArrays:void 0,parentMessageId:void 0,isReplyToChannel:!1,pushNotificationDeliveryOption:void 0,appleCriticalAlertOptions:void 0,isPinnedMessage:!1},So=function(t){return L("string",t.data,!0)&&L("string",t.customType,!0)&&D(e.MentionType,t.mentionType)&&F("string",t.mentionedUserIds,!0)&&F(Xa,t.mentionedUsers,!0)&&L("string",t.mentionedMessageTemplate,!0)&&F(Es,t.metaArrays,!0)&&L("number",t.parentMessageId,!0)&&L("boolean",t.isReplyToChannel)&&D(e.PushNotificationDeliveryOption,t.pushNotificationDeliveryOption,!0)&&L(xs,t.appleCriticalAlertOptions,!0)&&L("boolean",t.isPinnedMessage,!0)},Io=function(e){return{isReplyToChannel:e.isReplyToChannel,pushNotificationDeliveryOption:e.pushNotificationDeliveryOption,pollId:e.pollId}},No=Object.assign(Object.assign({},To),{message:"",translationTargetLanguages:void 0,pollId:void 0}),Mo=function(e){var t;return ue(ce({data:e.data,customType:e.customType,mentionType:e.mentionType,mentionedUsers:e.mentionedUsers,mentionedUserIds:e.mentionedUserIds,mentionedMessageTemplate:e.mentionedMessageTemplate,metaArrays:e.metaArrays,pollId:null===(t=e.poll)||void 0===t?void 0:t.id,parentMessageId:e.parentMessageId,appleCriticalAlertOptions:e.appleCriticalAlertOptions,message:e.message,translationTargetLanguages:Object.keys(e.translations)}))},Ao=function(e){return So(e)&&L("string",e.message)&&F("string",e.translationTargetLanguages,!0)&&L("number",e.pollId,!0)};!function(e){e.FILE="file",e.BLOB="blob",e.BLOB_LIKE_OBJECT="blobLikeObject",e.URL="url"}(Co||(Co={}));var Oo,Uo,Ro=function(e){return"undefined"!=typeof window&&"Blob"in window&&"undefined"!=typeof Blob&&e instanceof Blob},Lo=function(e){return e===Co.BLOB||e===Co.FILE},Do=function(e){return{file:e.file,fileKey:e.fileKey,fileType:e.fileType,isReplyToChannel:e.isReplyToChannel,pushNotificationDeliveryOption:e.pushNotificationDeliveryOption}},Po=Object.assign(Object.assign({},To),{file:void 0,fileKey:void 0,fileUrl:void 0,fileName:void 0,fileType:void 0,fileSize:void 0,mimeType:void 0,thumbnailSizes:void 0,requireAuth:!1}),Fo=function(e,t){var n;return e.messageParams?(!e.url&&q(t)&&(e.messageParams.file=t),e.messageParams):ue(ce({data:e.data,customType:e.customType,mentionType:e.mentionType,mentionedUsers:e.mentionedUsers,mentionedUserIds:e.mentionedUserIds,metaArrays:e.metaArrays,parentMessageId:e.parentMessageId,appleCriticalAlertOptions:e.appleCriticalAlertOptions,file:t,fileUrl:e.url,fileName:e.name,fileSize:e.size,mimeType:e.type,thumbnailSizes:null===(n=e.thumbnails)||void 0===n?void 0:n.map((function(e){return{maxWidth:e.width,maxHeight:e.height}}))}))},Go=function(e){return So(e)&&(q(e.file)||L("string",e.fileUrl))&&L("string",e.fileName,!0)&&L("string",e.mimeType,!0)&&L("number",e.fileSize,!0)&&(null===e.thumbnailSizes||void 0===e.thumbnailSizes||Array.isArray(e.thumbnailSizes)&&e.thumbnailSizes.every((function(e){return L("object",e)&&e.maxWidth>0&&e.maxHeight>0})))},qo=function(){return"undefined"!=typeof document&&"undefined"!=typeof navigator&&"ReactNative"!==navigator.product},Ho=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"}(Oo||(Oo={})),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"}(Uo||(Uo={}));var jo,zo={},Vo=function(){function e(t){var n=this,a=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return r(this,e),this._state=Oo.PROCESSING,this._queue=[],this._activationQueue=[],zo[t]&&!a.forceCreate||(this.nodeId=Ho(),this.key=t,qo()&&(a.startAsInvisible?this.registerNode():"visible"===document.visibilityState?this.claimHost():this.registerNode(),document.addEventListener("visibilitychange",(function(){"visible"===document.visibilityState&&n.claimHost()})),window.addEventListener("message",(function(e){var t=e.data,r=t.nodeId,a=t.requestId,s=t.key,i=t.op,o=t.data;if(r!==n.nodeId&&s===n.key)switch(i){case Uo.NEWNODE:n._sendSync();break;case Uo.CLAIM_HOST:n._sendSync(),n._hostId=r;break;case Uo.SYNC_HOST:if(!n.isInSync){n._activationTimeout&&clearTimeout(n._activationTimeout);var u,c=o.currentItemRequestId,l=y(o.queue);try{var h=function(){var e=u.value,t=n._queue.findIndex((function(t){return t.requestId===e.requestId}));t<0&&n._requestLock({nodeId:e.nodeId,requestId:e.requestId,key:n.key,op:Uo.REQUEST_LOCK,ts:e.ts})};for(l.s();!(u=l.n()).done;)h()}catch(e){l.e(e)}finally{l.f()}n._currentItem=n._queue.find((function(e){return e.requestId===c})),n._completeSync()}break;case Uo.REMOVENODE:n._queue=n._queue.filter((function(e){return e.nodeId!==t.nodeId})),n._currentItem&&n._currentItem.nodeId===t.nodeId&&(n._currentItem=void 0,n._acquire(n._queue[0]));break;case Uo.REQUEST_LOCK:n._requestLock(t);break;case Uo.ACQUIRE_LOCK:var d=n._queue.find((function(e){return e.requestId===a}));n._acquire(d);break;case Uo.RELEASE_LOCK:n._release(a)}})),window.addEventListener("beforeunload",(function(){n._send(Uo.REMOVENODE)}))),zo[t]=this),zo[t]}return s(e,[{key:"locked",get:function(){return!!this._currentItem}},{key:"isHost",get:function(){return this._hostId===this.nodeId}},{key:"isInSync",get:function(){return this._state==Oo.DONE}},{key:"_send",value:function(e){var t,n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},r={nodeId:this.nodeId,requestId:null!==(t=null==n?void 0:n.requestId)&&void 0!==t?t:Ho(),key:this.key,op:e,data:n.data,ts:Date.now()};return qo()&&window.postMessage(r,"*"),r}},{key:"_acquire",value:function(e){e?(this._currentItem=e,this._currentItem.onAcquired&&this._currentItem.onAcquired(e.requestId)):this._currentItem=void 0}},{key:"_release",value:function(e){if(this._currentItem&&this._currentItem.requestId===e){var t=this._currentItem;this._currentItem=void 0,t.nodeId===this.nodeId&&this._send(Uo.RELEASE_LOCK,{requestId:t.requestId});var n=this._queue.findIndex((function(t){return t.requestId===e}));n>-1&&this._queue.splice(n,1),t.onReleased&&t.onReleased(e)}}},{key:"_requestLock",value:function(e){var t=this;return new Promise((function(n){var r={nodeId:e.nodeId,requestId:e.requestId,ts:e.ts,onAcquired:function(e){t.isHost&&t._send(Uo.ACQUIRE_LOCK,{requestId:e}),n()},onReleased:function(){t._acquire(t._queue[0])}},a=!1;for(var s in t._queue)if(t._queue[s].ts>r.ts){t._queue.splice(parseInt(s),0,r),a=!0;break}a||t._queue.push(r),t._currentItem||t._acquire(t._queue[0])}))}},{key:"_sendSync",value:function(){var e;this.isHost&&this._send(Uo.SYNC_HOST,{data:{currentItemRequestId:null===(e=this._currentItem)||void 0===e?void 0:e.requestId,queue:this._queue.map((function(e){return{nodeId:e.nodeId,requestId:e.requestId,ts:e.ts}}))}})}},{key:"_waitUntilSyncCompleted",value:function(){return b(this,void 0,void 0,t().mark((function e(){var n=this;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!this.isHost||this.isInSync){e.next=2;break}return e.abrupt("return",new Promise((function(e){n._activationQueue.push(e)})));case 2:case"end":return e.stop()}}),e,this)})))}},{key:"_waitSync",value:function(){var e=this;this.isInSync||(this._activationTimeout=setTimeout((function(){e._completeSync()}),8))}},{key:"_completeSync",value:function(){this.isInSync||(this._state=Oo.DONE,this._activationQueue.forEach((function(e){return e()})),this._activationQueue=[])}},{key:"registerNode",value:function(){this._send(Uo.NEWNODE),this._waitSync()}},{key:"claimHost",value:function(){this._hostId=this.nodeId,this._send(Uo.CLAIM_HOST),this._waitSync()}},{key:"lock",value:function(){return b(this,void 0,void 0,t().mark((function e(){var n;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this._waitUntilSyncCompleted();case 2:return n=this._send(Uo.REQUEST_LOCK),e.next=5,this._requestLock(n);case 5:case"end":return e.stop()}}),e,this)})))}},{key:"unlock",value:function(){var e;(null===(e=this._currentItem)||void 0===e?void 0:e.requestId)&&this._release(this._currentItem.requestId)}}]),e}(),Bo=Object.assign(Object.assign({},No),{scheduledAt:void 0}),Qo=Object.assign(Object.assign({},To),{scheduledAt:0,file:void 0,fileUrl:void 0,fileName:void 0,mimeType:void 0,fileSize:void 0,thumbnailSizes:void 0,requireAuth:!1}),Ko=Object.assign(Object.assign({},To),{fileInfoList:[]}),Wo=function(e){return(q(e.file)||L("string",e.fileUrl))&&L("string",e.fileName,!0)&&L("string",e.mimeType,!0)&&L("number",e.fileSize,!0)&&(void 0===e.thumbnailSizes||Array.isArray(e.thumbnailSizes)&&e.thumbnailSizes.every((function(e){return e.maxWidth>0&&e.maxHeight>0})))},Yo="UnsentMessage",Zo={},Jo=function(e){i(a,e);var n=f(a);function a(e,t){var s,i=t.sdkState,o=t.cacheContext;return r(this,a),(s=n.call(this,e))._sdkState=i,s._cacheContext=o,Zo[e]=d(s),s._mutex=new Vo("unsendmessagecache.lock"),s}return s(a,[{key:"collection",get:function(){var e=this._cacheContext.nestdb,t=null==e?void 0:e.collection(Yo);if(!t)throw A.databaseError;return t}},{key:"localCacheEnabled",get:function(){return this._cacheContext.localCacheEnabled&&!!this.collection}},{key:"_serialize",value:function(e){if(e.messageId>0)throw A.invalidParameters;var t,n=Object.assign({},e.serialize());return e instanceof Hs?(e.messageParams&&(n.messageParams=Io(e.messageParams)),e.scheduledInfo&&e.scheduledInfo.scheduledMessageParams&&(n.scheduledInfo.scheduledMessageParams=(t=e.scheduledInfo.scheduledMessageParams,Object.assign(Object.assign({},Io(t)),{scheduledAt:t.scheduledAt})))):e instanceof Qs?(e.messageParams&&(n.messageParams=Do(e.messageParams)),e.scheduledInfo&&e.scheduledInfo.scheduledMessageParams&&(n.scheduledInfo.scheduledMessageParams=function(e){return Object.assign(Object.assign({},Do(e)),{scheduledAt:e.scheduledAt})}(e.scheduledInfo.scheduledMessageParams))):e instanceof zs&&e.messageParams&&(n.messageParams=function(e){return ue({fileInfoList:e.fileInfoList,isReplyToChannel:e.isReplyToChannel,pushNotificationDeliveryOption:e.pushNotificationDeliveryOption})}(e.messageParams)),n}},{key:"_deserialize",value:function(e){return e=Object.assign(Object.assign({},e),{messageId:parseInt(e.messageId)}),wi.of(this._iid).buildMessageFromSerializedData(e)}},{key:"_deserializeWithMessageCreateParams",value:function(e){var n,r,a;return b(this,void 0,void 0,t().mark((function s(){var i,o,u,c,l,h,d,f=this;return t().wrap((function(s){for(;;)switch(s.prev=s.next){case 0:if(i=wi.of(this._iid),o=this._deserialize(e),!e.messageParams){s.next=32;break}if(!(o instanceof Hs)){s.next=8;break}u=e.messageParams,o.messageParams=i.buildUserMessageCreateParamsFromSerializedData(u,o),s.next=32;break;case 8:if(!(o instanceof Qs)){s.next=26;break}if(!(c=e.messageParams).fileKey||"string"!=typeof c.fileKey||!Lo(null!==(n=c.fileType)&&void 0!==n?n:"")){s.next=23;break}return s.next=13,this.collection.getBlob(c.fileKey);case 13:if(s.t1=r=s.sent,s.t0=null!==s.t1,!s.t0){s.next=17;break}s.t0=void 0!==r;case 17:if(!s.t0){s.next=21;break}s.t2=r,s.next=22;break;case 21:s.t2=void 0;case 22:c.file=s.t2;case 23:o.messageParams=i.buildFileMessageCreateParamsFromSerializedData(c,o),s.next=32;break;case 26:if(!(o instanceof zs)){s.next=32;break}if(!(l=e.messageParams)||!l.fileInfoList){s.next=32;break}return o.messageParams=i.buildMultipleFilesMessageCreateParamsFromSerializedData(l,o),s.next=32,Promise.all(o.messageParams.fileInfoList.map((function(e){return b(f,void 0,void 0,t().mark((function n(){var r,a,s,i;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if("string"!=typeof(null===(r=e._uploadedMetaData)||void 0===r?void 0:r.fileKey)||!Lo(null!==(s=null===(a=e._uploadedMetaData)||void 0===a?void 0:a.fileType)&&void 0!==s?s:"")){t.next=13;break}return t.next=3,this.collection.getBlob(e._uploadedMetaData.fileKey);case 3:if(t.t1=i=t.sent,t.t0=null!==t.t1,!t.t0){t.next=7;break}t.t0=void 0!==i;case 7:if(!t.t0){t.next=11;break}t.t2=i,t.next=12;break;case 11:t.t2=void 0;case 12:e.file=t.t2;case 13:case"end":return t.stop()}}),n,this)})))})));case 32:if(!(o.scheduledInfo&&e.scheduledInfo&&e.scheduledInfo.scheduledMessageParams)){s.next=54;break}if(!(o instanceof Hs)){s.next=38;break}h=e.scheduledInfo.scheduledMessageParams,o.scheduledInfo.scheduledMessageParams=i.buildScheduledUserMessageCreateParamsFromSerializedData(h,o),s.next=54;break;case 38:if(!(o instanceof Qs)){s.next=54;break}if(!(d=e.scheduledInfo.scheduledMessageParams).fileKey||"string"!=typeof d.fileKey||"string"!=typeof d.fileType||!Lo(d.fileType)){s.next=53;break}return s.next=43,this.collection.getBlob(d.fileKey);case 43:if(s.t4=a=s.sent,s.t3=null!==s.t4,!s.t3){s.next=47;break}s.t3=void 0!==a;case 47:if(!s.t3){s.next=51;break}s.t5=a,s.next=52;break;case 51:s.t5=void 0;case 52:d.file=s.t5;case 53:o.scheduledInfo.scheduledMessageParams=i.buildScheduledFileMessageCreateParamsFromSerializedData(d,o);case 54:return s.abrupt("return",o);case 55:case"end":return s.stop()}}),s,this)})))}},{key:"_getFileInfoBlobKey",value:function(e,t){return"".concat(e,".").concat(t)}},{key:"get",value:function(e){return b(this,void 0,void 0,t().mark((function n(){var r;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(!this.localCacheEnabled){t.next=6;break}return t.next=3,this.collection.getByKey("".concat(e));case 3:if(!(r=t.sent)){t.next=6;break}return t.abrupt("return",this._deserializeWithMessageCreateParams(r));case 6:return t.abrupt("return",void 0);case 7:case"end":return t.stop()}}),n,this)})))}},{key:"fetch",value:function(e){var n=e.channelUrl,r=e.filter,a=void 0===r?new wo:r,s=e.order,i=void 0===s?bo.CHANNEL_LATEST:s,o=e.sendingStatus,u=e.backward,c=void 0!==u&&u,l=e.parentMessageId;return b(this,void 0,void 0,t().mark((function e(){var r,s,u,h,d,f=this;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!this.localCacheEnabled){e.next=13;break}return r=xo(i),s={"/where":function(e){return!!(i!==bo.NEWEST_CHILD_MESSAGE||l&&0!==e.parentMessageId&&e.parentMessageId===l)&&a.match(f._deserialize(e))}},n&&(s.channelUrl=n),o&&(s.sendingStatus=o),u={where:s,index:r,backward:c},e.next=8,this.collection.query(u);case 8:return h=e.sent,e.next=11,h.fetch({});case 11:return d=e.sent,e.abrupt("return",Promise.all(d.map((function(e){return b(f,void 0,void 0,t().mark((function n(){return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,this._deserializeWithMessageCreateParams(e);case 2:return t.abrupt("return",t.sent);case 3:case"end":return t.stop()}}),n,this)})))}))));case 13:return e.abrupt("return",[]);case 14:case"end":return e.stop()}}),e,this)})))}},{key:"getAllChildMessages",value:function(e){var n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:new wo;return b(this,void 0,void 0,t().mark((function r(){return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,this.fetch({filter:n,order:bo.NEWEST_CHILD_MESSAGE,channelUrl:e.channelUrl,backward:!1,parentMessageId:e.messageId});case 2:return t.abrupt("return",t.sent);case 3:case"end":return t.stop()}}),r,this)})))}},{key:"upsert",value:function(e){return b(this,void 0,void 0,t().mark((function n(){var r=this;return t().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:if(!this.localCacheEnabled){n.next=3;break}return n.next=3,Promise.all(e.map((function(e){return b(r,void 0,void 0,t().mark((function n(){var r;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(!(e instanceof Qs||e instanceof zs)){t.next=7;break}return t.next=3,this._mutex.lock();case 3:return t.next=5,this.saveBlob(e);case 5:return t.next=7,this._mutex.unlock();case 7:return r=this._serialize(e),t.next=10,this.collection.upsertOne(r);case 10:case"end":return t.stop()}}),n,this)})))})));case 3:case"end":return n.stop()}}),n,this)})))}},{key:"upsertChildMessages",value:function(e){return b(this,void 0,void 0,t().mark((function n(){var r=this;return t().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:if(!this.localCacheEnabled){n.next=3;break}return n.next=3,Promise.all(e.map((function(e){return b(r,void 0,void 0,t().mark((function n(){var r;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(r=[],!(e.threadInfo&&e.threadInfo.replyCount>0)){t.next=5;break}return t.next=4,this.getAllChildMessages(e);case 4:r=t.sent;case 5:if(!(r.length>0)){t.next=9;break}return r.forEach((function(t){return t.applyParentMessage(e)})),t.next=9,this.upsert(r);case 9:case"end":return t.stop()}}),n,this)})))})));case 3:case"end":return n.stop()}}),n,this)})))}},{key:"remove",value:function(e){return b(this,void 0,void 0,t().mark((function n(){var r,a,s;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(!this.localCacheEnabled){t.next=18;break}r=y(e),t.prev=2,r.s();case 4:if((a=r.n()).done){t.next=10;break}return s=a.value,t.next=8,this.collection.remove(s);case 8:t.next=4;break;case 10:t.next=15;break;case 12:t.prev=12,t.t0=t.catch(2),r.e(t.t0);case 15:return t.prev=15,r.f(),t.finish(15);case 18:case"end":return t.stop()}}),n,this,[[2,12,15,18]])})))}},{key:"removeMessagesOfChannel",value:function(e){return b(this,void 0,void 0,t().mark((function n(){return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(!this.localCacheEnabled){t.next=3;break}return t.next=3,this.collection.removeIf({where:{channelUrl:e}});case 3:case"end":return t.stop()}}),n,this)})))}},{key:"clear",value:function(){return b(this,void 0,void 0,t().mark((function e(){return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!this.localCacheEnabled){e.next=3;break}return e.next=3,this.collection.clear();case 3:case"end":return e.stop()}}),e,this)})))}},{key:"saveBlob",value:function(e){return b(this,void 0,void 0,t().mark((function n(){var r,a,s,i,o,u=this;return t().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:if(!(e instanceof Qs)){n.next=19;break}if(!e.messageParams){n.next=9;break}if(!(r=e.messageParams).file||!Ro(r.file)){n.next=9;break}return n.next=6,this.collection.saveBlob(r.file,e.reqId);case 6:a=n.sent,r.fileKey=a,r.fileType=Co.BLOB;case 9:if(!e.scheduledInfo||!e.scheduledInfo.scheduledMessageParams){n.next=17;break}if(!(s=e.scheduledInfo.scheduledMessageParams).file||!Ro(s.file)){n.next=17;break}return n.next=14,this.collection.saveBlob(s.file,e.reqId);case 14:i=n.sent,s.fileKey=i,s.fileType=Co.BLOB;case 17:n.next=24;break;case 19:if(!(e instanceof zs)){n.next=24;break}if(!((o=e.messageParams)&&o.fileInfoList&&Array.isArray(o.fileInfoList))){n.next=24;break}return n.next=24,Promise.all(o.fileInfoList.map((function(n,r){return b(u,void 0,void 0,t().mark((function a(){var s;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(!n.file||!Ro(n.file)){t.next=7;break}return t.next=3,this.collection.saveBlob(n.file,this._getFileInfoBlobKey(e.reqId,r));case 3:s=t.sent,n._uploadedMetaData||(n._uploadedMetaData={}),n._uploadedMetaData.fileKey=s,n._uploadedMetaData.fileType=Co.BLOB;case 7:case"end":return t.stop()}}),a,this)})))})));case 24:case"end":return n.stop()}}),n,this)})))}}],[{key:"of",value:function(e){return Zo[e]}}]),a}(Ha),Xo=function(n,r){return function(a,s){if(1===a)n.clear().then((function(){r.clear().then((function(){(function(n){return b(void 0,void 0,void 0,t().mark((function r(){return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.abrupt("return",n.commitSchema([{collectionName:go,keyName:"url",index:[Eo(e.GroupChannelListOrder.LATEST_LAST_MESSAGE),Eo(e.GroupChannelListOrder.CHRONOLOGICAL),Eo(e.GroupChannelListOrder.CHANNEL_NAME_ALPHABETICAL)]},{collectionName:ko,keyName:"messageId",index:[xo(bo.CHANNEL_LATEST),xo(bo.NEWEST_CHILD_MESSAGE)]},{collectionName:Yo,keyName:"reqId",index:[xo(bo.CHANNEL_LATEST),xo(bo.NEWEST_CHILD_MESSAGE)]},{collectionName:"Poll",keyName:"pollId"}]));case 1:case"end":return t.stop()}}),r)})))})(n).then((function(){return s()})).catch((function(e){return s(e)}))})).catch((function(e){return s(e)}))})).catch((function(e){return s(e)}));else s()}},$o={},eu=function(e){i(a,e);var n=f(a);function a(e,t){var s,i=t.sdkState,o=t.cacheContext,u=t.unsentMessageCache;return r(this,a),(s=n.call(this,e))._sdkState=i,s._cacheContext=o,s._unsentMessageCache=u,$o[e]=d(s),s}return s(a,[{key:"collection",get:function(){var e=this._cacheContext.nestdb;return Za(!!e).throw(A.databaseError),e.collection(ko)}},{key:"localCacheEnabled",get:function(){return this._cacheContext.localCacheEnabled&&!!this.collection}},{key:"_serialize",value:function(e){return Object.assign(Object.assign({},e.serialize()),{messageId:"".concat(e.messageId)})}},{key:"_deserialize",value:function(e){return e=Object.assign(Object.assign({},e),{messageId:parseInt(e.messageId)}),wi.of(this._iid).buildMessageFromSerializedData(e)}},{key:"get",value:function(e){return b(this,void 0,void 0,t().mark((function n(){var r;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(!this.localCacheEnabled){t.next=6;break}return t.next=3,this.collection.getByKey("".concat(e));case 3:if(!(r=t.sent)){t.next=6;break}return t.abrupt("return",this._deserialize(r));case 6:return t.abrupt("return",void 0);case 7:case"end":return t.stop()}}),n,this)})))}},{key:"fetch",value:function(e){var n=e.channelUrl,r=e.token,a=e.limit,s=void 0===a?yo:a,i=e.filter,o=void 0===i?new wo:i,u=e.order,c=void 0===u?bo.CHANNEL_LATEST:u,l=e.backward,h=void 0!==l&&l,d=e.parentMessageId,f=e.isPollOnly,p=void 0!==f&&f;return b(this,void 0,void 0,t().mark((function e(){var a,i,u,l,f=this;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!this.localCacheEnabled){e.next=10;break}return a=xo(c),i={where:{channelUrl:n,"/where":function(e){if(r)switch(c){case bo.CHANNEL_LATEST:if(!h&&e.createdAt>r||h&&e.createdAt1&&void 0!==arguments[1]?arguments[1]:new wo;return b(this,void 0,void 0,t().mark((function r(){return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,this.fetch({channelUrl:e.channelUrl,token:Date.now(),limit:null,backward:!1,filter:n,order:bo.NEWEST_CHILD_MESSAGE,parentMessageId:e.messageId});case 2:return t.abrupt("return",t.sent);case 3:case"end":return t.stop()}}),r,this)})))}},{key:"upsert",value:function(e){return b(this,void 0,void 0,t().mark((function n(){var r,a=this;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(!this.localCacheEnabled){t.next=10;break}return t.next=3,this.saveBlobs(e);case 3:return r=e.map((function(e){return a._serialize(e)})),t.next=6,this.collection.upsertMany(r);case 6:return t.next=8,this.upsertChildMessages(e);case 8:return t.next=10,this._unsentMessageCache.upsertChildMessages(e);case 10:case"end":return t.stop()}}),n,this)})))}},{key:"upsertChildMessages",value:function(e){return b(this,void 0,void 0,t().mark((function n(){var r=this;return t().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:if(!this.localCacheEnabled){n.next=3;break}return n.next=3,Promise.all(e.map((function(e){return b(r,void 0,void 0,t().mark((function n(){var r,a;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(a=[],!((null===(r=e.threadInfo)||void 0===r?void 0:r.replyCount)&&e.threadInfo.replyCount>0)){t.next=5;break}return t.next=4,this.getAllChildMessages(e);case 4:a=t.sent;case 5:if(!(a.length>0)){t.next=9;break}return a.forEach((function(t){return t.applyParentMessage(e)})),t.next=9,this.upsert(a);case 9:case"end":return t.stop()}}),n,this)})))})));case 3:case"end":return n.stop()}}),n,this)})))}},{key:"remove",value:function(e){return b(this,void 0,void 0,t().mark((function n(){var r,a,s;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(!this.localCacheEnabled){t.next=18;break}r=y(e),t.prev=2,r.s();case 4:if((a=r.n()).done){t.next=10;break}return s=a.value,t.next=8,this.collection.remove("".concat(s));case 8:t.next=4;break;case 10:t.next=15;break;case 12:t.prev=12,t.t0=t.catch(2),r.e(t.t0);case 15:return t.prev=15,r.f(),t.finish(15);case 18:case"end":return t.stop()}}),n,this,[[2,12,15,18]])})))}},{key:"removeMessagesOfChannel",value:function(e){return b(this,void 0,void 0,t().mark((function n(){var r;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(!this.localCacheEnabled){t.next=12;break}return t.next=3,this.collection.removeIf({where:{channelUrl:e},index:xo(bo.CHANNEL_LATEST)});case 3:return r=this._cacheContext.preference,t.next=6,r.remove("sendbird:".concat(this._sdkState.userId,"@groupchannel/").concat(e,"/message/sync"));case 6:return t.next=8,r.remove("sendbird:".concat(this._sdkState.userId,"@groupchannel/").concat(e,"/message/sync.meta"));case 8:return t.next=10,r.remove("sendbird:".concat(this._sdkState.userId,"@groupchannel/").concat(e,"/message/changelogs"));case 10:return t.next=12,r.remove("sendbird:".concat(this._sdkState.userId,"@groupchannel/").concat(e,"/message/changelogs.meta"));case 12:case"end":return t.stop()}}),n,this)})))}},{key:"removeUnderOffset",value:function(e,n){return b(this,void 0,void 0,t().mark((function r(){return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(!this.localCacheEnabled){t.next=3;break}return t.next=3,this.collection.removeIf({where:{channelUrl:e,createdAt:{"<":n}},index:xo(bo.CHANNEL_LATEST)});case 3:case"end":return t.stop()}}),r,this)})))}},{key:"clear",value:function(){return b(this,void 0,void 0,t().mark((function e(){return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!this.localCacheEnabled){e.next=3;break}return e.next=3,this.collection.clear();case 3:case"end":return e.stop()}}),e,this)})))}},{key:"countBetween",value:function(e,n,r){return b(this,void 0,void 0,t().mark((function a(){var s,i,o=this;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(!this.localCacheEnabled){t.next=6;break}return s=xo(bo.CHANNEL_LATEST),i=this.collection.query({where:{channelUrl:e,"/where":function(e){var t=o._deserialize(e);return r.includes(t.createdAt)&&n.match(t)}},index:s}),t.next=5,i.count();case 5:return t.abrupt("return",t.sent);case 6:return t.abrupt("return",0);case 7:case"end":return t.stop()}}),a,this)})))}},{key:"saveBlobs",value:function(e){return b(this,void 0,void 0,t().mark((function n(){var r=this;return t().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return n.next=2,Promise.all(e.map((function(e){return b(r,void 0,void 0,t().mark((function n(){var r,a;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(!(e instanceof Qs&&e.messageParams)){t.next=7;break}if(!(r=e.messageParams).file||!Ro(r.file)){t.next=7;break}return t.next=5,this.collection.saveBlob(r.file,e.reqId);case 5:a=t.sent,r.fileKey=a;case 7:case"end":return t.stop()}}),n,this)})))})));case 2:case"end":return n.stop()}}),n)})))}},{key:"_getGroupChannelPreferenceSize",value:function(e){return b(this,void 0,void 0,t().mark((function n(){var r,a,s,i,o,u;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return r=0,a=this._cacheContext.preference,t.next=4,a.get("sendbird:".concat(this._sdkState.userId,"@groupchannel/").concat(e,"/message/sync"));case 4:return s=t.sent,t.next=7,a.get("sendbird:".concat(this._sdkState.userId,"@groupchannel/").concat(e,"/message/sync.meta"));case 7:return i=t.sent,t.next=10,a.get("sendbird:".concat(this._sdkState.userId,"@groupchannel/").concat(e,"/message/changelogs"));case 10:return o=t.sent,t.next=13,a.get("sendbird:".concat(this._sdkState.userId,"@groupchannel/").concat(e,"/message/changelogs.meta"));case 13:return u=t.sent,s&&(r+=JSON.stringify(s).length),i&&(r+=JSON.stringify(i).length),o&&(r+=JSON.stringify(o).length),u&&(r+=JSON.stringify(u).length),t.abrupt("return",r);case 19:case"end":return t.stop()}}),n,this)})))}}],[{key:"of",value:function(e){return $o[e]}}]),a}(Ha),tu=function(){return"undefined"!=typeof document?document.visibilityState:"visible"},nu=function(e){i(n,e);var t=f(n);function n(e){var a,s=e.getVisibilityState,i=void 0===s?tu:s,o=e.initialState,u=void 0===o?"visible":o,c=e.isEnabled,l=void 0===c||c,h=e.pauseCheckDelay,f=void 0===h?3e4:h;return r(this,n),(a=t.call(this))._pauseCheckDelay=3e4,a._currentState="visible",a._getVisibilityState=i,a._pauseCheckDelay=f,a._currentState=u,a._isEnabled=l,a._boundToggleState=a._toggleState.bind(d(a)),a}return s(n,[{key:"currentState",get:function(){return this._currentState}},{key:"isAvailable",get:function(){return"undefined"!=typeof window&&!!window.addEventListener&&!!window.removeEventListener}},{key:"_toggleState",value:function(){var e=this,t=this._getVisibilityState();"hidden"!==t?"hidden"===this._currentState&&(this._pauseDelayTimer&&(clearTimeout(this._pauseDelayTimer),this._pauseDelayTimer=void 0),this.dispatch("resume")):"hidden"!==this._currentState&&(this._pauseDelayTimer=setTimeout((function(){e._pauseDelayTimer=void 0,e.dispatch("pause")}),this._pauseCheckDelay)),this._currentState=t}},{key:"start",value:function(){this._isEnabled&&this.isAvailable&&(this._boundToggleState=this._toggleState.bind(this),window.addEventListener("visibilitychange",this._boundToggleState,{capture:!0}))}},{key:"stop",value:function(){this._isEnabled&&this.isAvailable&&this._boundToggleState&&window.removeEventListener("visibilitychange",this._boundToggleState,{capture:!0})}}]),n}(se),ru=function(){function e(t){var n=this,a=t.logger,s=t.connectionDelegate,i=void 0===s?null:s;r(this,e),this._onlineWorker=function(){var e;return null===(e=n.connectionDelegate)||void 0===e?void 0:e.reconnect()},this._offlineWorker=function(){var e;return null===(e=n.connectionDelegate)||void 0===e?void 0:e.disconnect()},this.unsubscribes=[],this._onlineListener=function(e){if(n.isAvailableOnWeb)return window.addEventListener("online",e),function(){return window.removeEventListener("online",e,!1)}},this._offlineListener=function(e){if(n.isAvailableOnWeb)return window.addEventListener("offline",e),function(){return window.removeEventListener("offline",e,!1)}},this.logger=a,i&&(this.connectionDelegate=i)}return s(e,[{key:"isAvailableOnWeb",get:function(){return"undefined"!=typeof window&&!!window.addEventListener&&"ononline"in window&&"onoffline"in window&&"undefined"!=typeof navigator&&void 0!==navigator.onLine}},{key:"setOnlineListener",value:function(e){Boolean(e)&&"function"==typeof e&&(this._onlineListener=e)}},{key:"setOfflineListener",value:function(e){Boolean(e)&&"function"==typeof e&&(this._offlineListener=e)}},{key:"start",value:function(){this.unsubscribes=[this._onlineListener(this._onlineWorker),this._offlineListener(this._offlineWorker)]}},{key:"stop",value:function(){var e=this;this.unsubscribes.forEach((function(t){try{null==t||t()}catch(t){e.logger.warn(t.message)}})),this.unsubscribes=[]}},{key:"isOnline",value:function(){return b(this,void 0,void 0,t().mark((function e(){return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!this.isAvailableOnWeb){e.next=4;break}return e.abrupt("return",navigator.onLine);case 4:return e.abrupt("return",new Promise((function(e){fetch("https://www.google.com",{method:le.GET,mode:"no-cors"}).then((function(){return e(!0)})).catch((function(){return e(!1)}))})));case 5:case"end":return e.stop()}}),e,this)})))}}]),e}(),au=function(e){i(n,e);var t=f(n);function n(e){var a,s=e.message;return r(this,n),(a=t.call(this)).message=s,a}return s(n)}(oe),su={},iu=function(){function n(e,t){var a=this,s=t.localCacheEnabled,i=t.dispatcher,o=t.sdkState,u=t.logger;r(this,n),this._iid=e,su[e]=this,this._localCacheEnabled=s,this._isProcessingAutoResend=!1,this._autoResendQueue=[],this._dispatcher=i,this._logger=u,this._sdkState=o,this._localCacheEnabled&&i.on((function(e){if(e instanceof da)switch(e.stateType){case sa.CONNECTED:a._isProcessingAutoResend||a.processAutoResendRegisteredPendingMessages().then((function(){return a._processNextAutoResend()}));break;case sa.INTERNAL_DISCONNECTED:case sa.EXTERNAL_DISCONNECTED:a._isProcessingAutoResend=!1}}))}return s(n,[{key:"processNonAutoResendRegisteredPendingMessages",value:function(){return b(this,void 0,void 0,t().mark((function n(){var r,a,s,i;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,this._fetchAllCachedPendingMessages();case 2:r=t.sent,a=y(r);try{for(a.s();!(s=a.n()).done;)0===(i=s.value).errorCode&&(this._logger.debug("cached pending message is not auto-resend registered. changing its sending status to failed: ",i.reqId),i.sendingStatus=e.SendingStatus.FAILED,i.errorCode=E.ACK_TIMEOUT,this._dispatcher.dispatch(new ui({messages:[i],source:e.MessageEventSource.LOCAL_MESSAGE_FAILED})))}catch(e){a.e(e)}finally{a.f()}case 5:case"end":return t.stop()}}),n,this)})))}},{key:"processAutoResendRegisteredPendingMessages",value:function(){return b(this,void 0,void 0,t().mark((function n(){var r,a,s,i,o,u;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,this._fetchAllCachedPendingMessages();case 2:r=t.sent,a=y(r);try{for(a.s();!(s=a.n()).done;)(i=s.value).errorCode&&G(i.errorCode)&&(o=(new Date).getTime(),u=i.createdAt+2592e5,o<=u?this._autoResendQueue.map((function(e){return e.reqId})).indexOf(i.reqId)<0&&this._autoResendQueue.push(i):(this._logger.debug("auto-resend registered pending messaged expired. expiration date: ",new Date(u).toLocaleString()),i.sendingStatus=e.SendingStatus.FAILED,this._dispatcher.dispatch(new ui({messages:[i],source:e.MessageEventSource.LOCAL_MESSAGE_FAILED}))))}catch(e){a.e(e)}finally{a.f()}case 5:case"end":return t.stop()}}),n,this)})))}},{key:"completeCurrentAndProcessNextAutoResend",value:function(t){if(this._localCacheEnabled&&(t.sendingStatus===e.SendingStatus.SUCCEEDED||t.sendingStatus===e.SendingStatus.FAILED&&!G(t.errorCode))){var n=this.indexOf(t);n>=0&&this._autoResendQueue.splice(n,1),0===n&&this._processNextAutoResend()}}},{key:"_fetchAllCachedPendingMessages",value:function(){return b(this,void 0,void 0,t().mark((function n(){var r;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(!(r=Jo.of(this._iid))){t.next=7;break}return t.next=4,r.fetch({sendingStatus:e.SendingStatus.PENDING,backward:!0});case 4:t.t0=t.sent,t.next=8;break;case 7:t.t0=[];case 8:return t.abrupt("return",t.t0);case 9:case"end":return t.stop()}}),n,this)})))}},{key:"indexOf",value:function(e){return this._autoResendQueue.length>0?this._autoResendQueue.map((function(e){return e.reqId})).indexOf(e.reqId):-1}},{key:"_isNotInQueue",value:function(e){return-1===this._autoResendQueue.map((function(e){return e.reqId})).indexOf(e.reqId)}},{key:"_processNextAutoResend",value:function(){return b(this,void 0,void 0,t().mark((function e(){var n;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(this._localCacheEnabled&&"foreground"===this._sdkState.appState)try{this._autoResendQueue.length>0?(this._isProcessingAutoResend||(this._logger.debug("auto-resend queue started."),this._isProcessingAutoResend=!0),n=this._autoResendQueue[0],this._dispatcher.dispatch(new au({message:n})),this._logger.debug("processing auto-resend for message request id: ",n.reqId)):(this._logger.debug("auto-resend queue finished."),this._isProcessingAutoResend=!1)}catch(e){this._logger.warn("process auto-resend error: ",e),this._isProcessingAutoResend=!1}case 1:case"end":return e.stop()}}),e,this)})))}}],[{key:"of",value:function(e){return su[e]}}]),n}();!function(e){e[e.USER_BLOCK=20001]="USER_BLOCK",e[e.USER_UNBLOCK=2e4]="USER_UNBLOCK",e[e.FRIEND_DISCOVERED=20900]="FRIEND_DISCOVERED"}(jo||(jo={}));var ou,uu=function(){function e(t){r(this,e),this.category=t.cat,this.data=t.data}return s(e,null,[{key:"getDataAsUserBlockEvent",value:function(e,t){var n=t.data,r=n.blocker,a=n.blockee;return{blocker:new Xa(e,r),blockee:new Xa(e,a)}}},{key:"getDataAsFriendDiscoveredEvent",value:function(e,t){var n=t.data.friend_discoveries;return{friendDiscoveries:Array.isArray(n)?n.map((function(t){return new Xa(e,t)})):[]}}}]),e}(),cu=function(e){i(n,e);var t=f(n);function n(e,a){var s,i=a.userId;return r(this,n),(s=t.call(this))._iid=e,s.userId=i,s}return s(n)}(oe);e.GroupChannelEventSource=void 0,(ou=e.GroupChannelEventSource||(e.GroupChannelEventSource={})).UNKNOWN="UNKNOWN",ou.EVENT_CHANNEL_CREATED="EVENT_CHANNEL_CREATED",ou.EVENT_CHANNEL_UPDATED="EVENT_CHANNEL_UPDATED",ou.EVENT_CHANNEL_DELETED="EVENT_CHANNEL_DELETED",ou.EVENT_CHANNEL_READ="EVENT_CHANNEL_READ",ou.EVENT_CHANNEL_DELIVERED="EVENT_CHANNEL_DELIVERED",ou.EVENT_CHANNEL_INVITED="EVENT_CHANNEL_INVITED",ou.EVENT_CHANNEL_JOINED="EVENT_CHANNEL_JOINED",ou.EVENT_CHANNEL_LEFT="EVENT_CHANNEL_LEFT",ou.EVENT_CHANNEL_ACCEPTED_INVITE="EVENT_CHANNEL_ACCEPTED_INVITE",ou.EVENT_CHANNEL_DECLINED_INVITE="EVENT_CHANNEL_DECLINED_INVITE",ou.EVENT_CHANNEL_OPERATOR_UPDATED="EVENT_CHANNEL_OPERATOR_UPDATED",ou.EVENT_CHANNEL_MUTED="EVENT_CHANNEL_MUTED",ou.EVENT_CHANNEL_UNMUTED="EVENT_CHANNEL_UNMUTED",ou.EVENT_CHANNEL_FROZEN="EVENT_CHANNEL_FROZEN",ou.EVENT_CHANNEL_UNFROZEN="EVENT_CHANNEL_UNFROZEN",ou.EVENT_CHANNEL_HIDDEN="EVENT_CHANNEL_HIDDEN",ou.EVENT_CHANNEL_UNHIDDEN="EVENT_CHANNEL_UNHIDDEN",ou.EVENT_CHANNEL_RESET_HISTORY="EVENT_CHANNEL_RESET_HISTORY",ou.EVENT_CHANNEL_TYPING_STATUS_UPDATE="EVENT_CHANNEL_TYPING_STATUS_UPDATE",ou.EVENT_CHANNEL_MEMBER_COUNT_UPDATED="EVENT_CHANNEL_MEMBER_COUNT_UPDATED",ou.EVENT_MESSAGE_SENT="EVENT_MESSAGE_SENT",ou.EVENT_MESSAGE_RECEIVED="EVENT_MESSAGE_RECEIVED",ou.EVENT_MESSAGE_UPDATED="EVENT_MESSAGE_UPDATED",ou.EVENT_PINNED_MESSAGE_UPDATED="EVENT_PINNED_MESSAGE_UPDATED",ou.REQUEST_CHANNEL="REQUEST_CHANNEL",ou.REQUEST_CHANNEL_CHANGELOGS="REQUEST_CHANNEL_CHANGELOGS",ou.REFRESH_CHANNEL="REFRESH_CHANNEL",ou.CHANNEL_LASTACCESSEDAT_UPDATED="CHANNEL_LASTACCESSEDAT_UPDATED",ou.SYNC_CHANNEL_BACKGROUND="SYNC_CHANNEL_BACKGROUND",ou.SYNC_CHANNEL_CHANGELOGS="SYNC_CHANNEL_CHANGELOGS";var lu,hu=function(t){return t.startsWith("EVENT_")||t===e.GroupChannelEventSource.SYNC_CHANNEL_CHANGELOGS||t===e.GroupChannelEventSource.REFRESH_CHANNEL},du=function(e){i(n,e);var t=f(n);function n(e){var a,s=e.channels,i=e.source,o=e.isWebSocketEventComing,u=void 0!==o&&o,c=e.data,l=void 0===c?null:c;return r(this,n),(a=t.call(this)).channels=s,a.source=i,a.isWebSocketEventComing=u,a.data=l,a}return s(n)}(oe),fu=function(e){i(n,e);var t=f(n);function n(e){var a,s=e.channelUrls,i=e.source,o=e.isWebSocketEventComing,u=void 0!==o&&o;return r(this,n),(a=t.call(this)).channelUrls=s,a.source=i,a.isWebSocketEventComing=u,a}return s(n)}(oe),pu=function(e){i(n,e);var t=f(n);function n(){return r(this,n),t.call(this)}return s(n)}(oe),vu=function(e){i(n,e);var t=f(n);function n(e,a,s){var i;return r(this,n),(i=t.call(this,e,"USEV",s)).event=new uu(s),i}return s(n)}(qe),_u=function(e){i(n,e);var t=f(n);function n(e){var a,s=e.userId,i=e.nickname,o=e.profileUrl,u=e.profileImage,c=e.preferredLanguages;return r(this,n),(a=t.call(this)).method=le.PUT,a.path="".concat(de,"/").concat(encodeURIComponent(s)),a.params=ue(ce({nickname:i,profile_url:o,profile_file:u,preferred_languages:c})),a}return s(n)}(Oe),mu=function(e){i(n,e);var t=f(n);function n(e,a){var s;return r(this,n),(s=t.call(this,e,a)).user=new Xa(e,Object.assign({},a)),s}return s(n)}(Ue),gu=function(e){i(n,e);var t=f(n);function n(e){var a,s=e.userId,i=e.token;return r(this,n),(a=t.call(this)).method=le.POST,a.path="".concat(de,"/").concat(encodeURIComponent(s),"/push/apns"),a.params={apns_device_token:i,always_push:!0},a}return s(n)}(Oe),yu=function(e){i(n,e);var t=f(n);function n(e){var a,s=e.userId,i=e.token;return r(this,n),(a=t.call(this)).method=le.POST,a.path="".concat(de,"/").concat(encodeURIComponent(s),"/push/gcm"),a.params={gcm_reg_token:i,always_push:!0},a}return s(n)}(Oe),ku=function(e){i(n,e);var t=f(n);function n(e){var a,s=e.userId,i=e.token;return r(this,n),(a=t.call(this)).method=le.DELETE,a.path="".concat(de,"/").concat(encodeURIComponent(s),"/push/apns/").concat(encodeURIComponent(i)),a}return s(n)}(Oe),bu=function(e){i(n,e);var t=f(n);function n(e){var a,s=e.userId,i=e.token;return r(this,n),(a=t.call(this)).method=le.DELETE,a.path="".concat(de,"/").concat(encodeURIComponent(s),"/push/gcm/").concat(encodeURIComponent(i)),a}return s(n)}(Oe),Eu=function(e){i(n,e);var t=f(n);function n(e){var a,s=e.userId;return r(this,n),(a=t.call(this)).method=le.DELETE,a.path="".concat(de,"/").concat(encodeURIComponent(s),"/push/apns"),a}return s(n)}(Oe),wu=function(e){i(n,e);var t=f(n);function n(e){var a,s=e.userId;return r(this,n),(a=t.call(this)).method=le.DELETE,a.path="".concat(de,"/").concat(encodeURIComponent(s),"/push/gcm"),a}return s(n)}(Oe),Cu=function(e){i(n,e);var t=f(n);function n(e){var a,s=e.userId,i=e.type,o=e.token,u=e.ts;return r(this,n),(a=t.call(this)).method=le.GET,a.path="".concat(de,"/").concat(encodeURIComponent(s),"/push/").concat(encodeURIComponent(i),"/device_tokens"),a.params={created_ts:u,token:o},a}return s(n)}(Oe),xu=function(t){i(a,t);var n=f(a);function a(t,s){var i;return r(this,a),(i=n.call(this,t,s)).pushTokens={type:s.type?e.PushTokenType[s.type.toLowerCase()]:e.PushTokenType.UNKNOWN,deviceTokens:s.device_tokens,hasMore:s.has_more,token:s.token},i}return s(a)}(Ue),Tu=function(e){i(n,e);var t=f(n);function n(e){var a,s=e.userId;return r(this,n),(a=t.call(this)).method=le.GET,a.path="".concat(de,"/").concat(encodeURIComponent(s),"/channel_invitation_preference"),a}return s(n)}(Oe),Su=function(e){i(n,e);var t=f(n);function n(e,a){var s;return r(this,n),(s=t.call(this,e,a)).autoAccept=a.auto_accept,s}return s(n)}(Ue),Iu=function(e){i(n,e);var t=f(n);function n(e){var a,s=e.userId,i=e.willAutoAccept;return r(this,n),(a=t.call(this)).method=le.PUT,a.path="".concat(de,"/").concat(encodeURIComponent(s),"/channel_invitation_preference"),a.params={auto_accept:i},a}return s(n)}(Oe),Nu=function(e){i(n,e);var t=f(n);function n(e,a){var s;return r(this,n),(s=t.call(this,e,a)).autoAccept=a.auto_accept,s}return s(n)}(Ue),Mu=function(e){i(n,e);var t=f(n);function n(e){var a,s=e.userId;return r(this,n),(a=t.call(this)).method=le.GET,a.path="".concat(de,"/").concat(encodeURIComponent(s),"/push_preference"),a}return s(n)}(Oe),Au=function(e){i(n,e);var t=f(n);function n(e,a){var s;return r(this,n),(s=t.call(this,e,a)).preference={doNotDisturbOn:a.do_not_disturb,startHour:a.start_hour,startMin:a.start_min,endHour:a.end_hour,endMin:a.end_min,timezone:a.timezone},s}return s(n)}(Ue),Ou=function(e){i(n,e);var t=f(n);function n(e){var a,s=e.userId,i=e.doNotDisturbOn,o=e.startHour,u=e.startMin,c=e.endHour,l=e.endMin,h=e.timezone;return r(this,n),(a=t.call(this)).method=le.PUT,a.path="".concat(de,"/").concat(encodeURIComponent(s),"/push_preference"),a.params={do_not_disturb:i,start_hour:o,start_min:u,end_hour:c,end_min:l,timezone:h},a}return s(n)}(Oe),Uu=function(e){i(n,e);var t=f(n);function n(e,a){var s;return r(this,n),(s=t.call(this,e,a)).preference={doNotDisturbOn:a.do_not_disturb,startHour:a.start_hour,startMin:a.start_min,endHour:a.end_hour,endMin:a.end_min,timezone:a.timezone},s}return s(n)}(Ue),Ru=function(e){i(n,e);var t=f(n);function n(e){var a,s=e.userId;return r(this,n),(a=t.call(this)).method=le.GET,a.path="".concat(de,"/").concat(encodeURIComponent(s),"/push_preference"),a}return s(n)}(Oe),Lu=function(e){i(n,e);var t=f(n);function n(e,a){var s;return r(this,n),(s=t.call(this,e,a)).snoozePeriod={isSnoozeOn:a.snooze_enabled},"number"==typeof a.snooze_start_ts&&(s.snoozePeriod.startTs=a.snooze_start_ts),"number"==typeof a.snooze_end_ts&&(s.snoozePeriod.endTs=a.snooze_end_ts),s}return s(n)}(Ue),Du=function(e){i(n,e);var t=f(n);function n(e){var a,s=e.userId,i=e.snoozeOn,o=e.startTs,u=e.endTs;return r(this,n),(a=t.call(this)).method=le.PUT,a.path="".concat(de,"/").concat(encodeURIComponent(s),"/push_preference"),a.params={snooze_enabled:i,snooze_start_ts:o,snooze_end_ts:u},a}return s(n)}(Oe),Pu=function(e){i(n,e);var t=f(n);function n(e,a){var s;return r(this,n),(s=t.call(this,e,a)).snoozePeriod={isSnoozeOn:a.snooze_enabled},"number"==typeof a.snooze_start_ts&&(s.snoozePeriod.startTs=a.snooze_start_ts),"number"==typeof a.snooze_end_ts&&(s.snoozePeriod.endTs=a.snooze_end_ts),s}return s(n)}(Ue),Fu=function(e){i(n,e);var t=f(n);function n(e){var a,s=e.userId,i=e.blockedUserId;return r(this,n),(a=t.call(this)).method=le.POST,a.path="".concat(de,"/").concat(encodeURIComponent(s),"/block"),a.params={target_id:i},a}return s(n)}(Oe),Gu=function(e){i(n,e);var t=f(n);function n(e){var a,s=e.userId,i=e.unblockedUserId;return r(this,n),(a=t.call(this)).method=le.DELETE,a.path="".concat(de,"/").concat(encodeURIComponent(s),"/block/").concat(encodeURIComponent(i)),a}return s(n)}(Oe),qu=function(e){i(n,e);var t=f(n);function n(e){var a,s=e.userId;return r(this,n),(a=t.call(this)).method=le.GET,a.path="".concat(de,"/").concat(encodeURIComponent(s),"/push_preference"),a}return s(n)}(Oe),Hu=function(e){i(n,e);var t=f(n);function n(e,a){var s;return r(this,n),(s=t.call(this,e,a)).pushTriggerOption=a.push_trigger_option,s}return s(n)}(Ue),ju=function(e){i(n,e);var t=f(n);function n(e){var a,s=e.userId,i=e.pushTriggerOption;return r(this,n),(a=t.call(this)).method=le.PUT,a.path="".concat(de,"/").concat(encodeURIComponent(s),"/push_preference"),a.params={push_trigger_option:i},a}return s(n)}(Oe),zu=function(e){i(n,e);var t=f(n);function n(e,a){var s;return r(this,n),(s=t.call(this,e,a)).pushTriggerOption=a.push_trigger_option,s}return s(n)}(Ue),Vu=function(e){i(n,e);var t=f(n);function n(e){var a,s=e.userId;return r(this,n),(a=t.call(this)).method=le.GET,a.path="".concat(de,"/").concat(encodeURIComponent(s),"/push/template"),a}return s(n)}(Oe),Bu=function(e){i(n,e);var t=f(n);function n(e,a){var s;return r(this,n),(s=t.call(this,e,a)).name=a.name,s}return s(n)}(Ue),Qu=function(e){i(n,e);var t=f(n);function n(e){var a,s=e.userId,i=e.templateName;return r(this,n),(a=t.call(this)).method=le.PUT,a.path="".concat(de,"/").concat(encodeURIComponent(s),"/push/template"),a.params={name:i},a}return s(n)}(Oe),Ku=function(e){i(n,e);var t=f(n);function n(e,a){var s;return r(this,n),(s=t.call(this,e,a)).name=a.name,s}return s(n)}(Ue),Wu=function(e){i(n,e);var t=f(n);function n(e){var a,s=e.userId,i=e.token;return r(this,n),(a=t.call(this)).method=le.GET,a.path="".concat(de,"/").concat(encodeURIComponent(s),"/friends/changelogs"),a.params={token:i},a}return s(n)}(Oe),Yu=function(e){i(n,e);var t=f(n);function n(e,a){var s;return r(this,n),(s=t.call(this,e,a)).changelogs={addedUsers:a.added.map((function(t){return new Xa(e,t)})),updatedUsers:a.updated.map((function(t){return new Xa(e,t)})),deletedUserIds:a.deleted,hasMore:a.has_more,token:a.next},s}return s(n)}(Ue),Zu=function(e){i(n,e);var t=f(n);function n(e){var a,s=e.userId,i=e.discoveries;return r(this,n),(a=t.call(this)).method=le.PUT,a.path="".concat(de,"/").concat(encodeURIComponent(s),"/friend_discoveries"),a.params={friend_discoveries:i.map((function(e){return{friend_discovery_key:e.friendDiscoveryKey,friend_name:e.friendName}}))},a}return s(n)}(Oe),Ju=function(e){i(n,e);var t=f(n);function n(e,a){var s;return r(this,n),(s=t.call(this,e,a)).friendDiscoveryRequestId=a.friend_discovery_request_id,s}return s(n)}(Ue),Xu=function(e){i(n,e);var t=f(n);function n(e){var a,s=e.userId,i=e.discoveryKeys;return r(this,n),(a=t.call(this)).method=le.DELETE,a.path="".concat(de,"/").concat(encodeURIComponent(s),"/friend_discoveries"),a.params={friend_discovery_keys:i},a}return s(n)}(Oe),$u=function(e){i(n,e);var t=f(n);function n(e){var a,s=e.userId,i=e.userIds;return r(this,n),(a=t.call(this)).method=le.POST,a.path="".concat(de,"/").concat(encodeURIComponent(s),"/friends"),a.params={user_ids:i},a}return s(n)}(Oe),ec=function(e){i(n,e);var t=f(n);function n(e,a){var s;return r(this,n),(s=t.call(this,e,a)).users=a.users.map((function(t){return new Xa(e,t)})),s}return s(n)}(Ue),tc=function(e){i(n,e);var t=f(n);function n(e){var a,s=e.userId,i=e.userIds;return r(this,n),(a=t.call(this)).method=le.DELETE,a.path="".concat(de,"/").concat(encodeURIComponent(s),"/friends"),a.params={user_ids:i},a}return s(n)}(Oe),nc=function(e){i(n,e);var t=f(n);function n(e){var a,s=e.userId;return r(this,n),(a=t.call(this)).method=le.GET,a.path="".concat(de,"/").concat(s,"/allow_friend_discovery"),a.params={},a}return s(n)}(Oe),rc=function(e){i(n,e);var t=f(n);function n(e,a){var s;return r(this,n),(s=t.call(this,e,a)).allowFriendDiscovery=a.allow_friend_discovery,s}return s(n)}(Ue),ac=function(e){i(n,e);var t=f(n);function n(e){var a,s=e.userId,i=e.allowFriendDiscovery;return r(this,n),(a=t.call(this)).method=le.PUT,a.path="".concat(de,"/").concat(s,"/allow_friend_discovery"),a.params={allow_friend_discovery:i},a}return s(n)}(Oe),sc=s((function e(t){r(this,e),this.key=t.key,this.url=t.url})),ic=s((function e(t){r(this,e),this.id=t.id,this.name=t.name,this.url=t.url,this.emojis=t.emojis?t.emojis.map((function(e){return new sc(e)})):[]})),oc=s((function e(t){r(this,e),this.emojiHash=t.emoji_hash||"",this.emojiCategories=t.emoji_categories?t.emoji_categories.map((function(e){return new ic(e)})):[]})),uc=function(e){i(n,e);var t=f(n);function n(){var e;return r(this,n),(e=t.call(this)).method=le.GET,e.path=be,e}return s(n)}(Oe),cc=function(e){i(n,e);var t=f(n);function n(e,a){var s;return r(this,n),(s=t.call(this,e,a)).emojiContainer=new oc(a),s}return s(n)}(Ue),lc=function(e){i(n,e);var t=f(n);function n(e){var a,s=e.categoryId;return r(this,n),(a=t.call(this)).method=le.GET,a.path="".concat(be,"/").concat(s),a}return s(n)}(Oe),hc=function(e){i(n,e);var t=f(n);function n(e,a){var s;return r(this,n),(s=t.call(this,e,a)).emojiCategory=new ic(a),s}return s(n)}(Ue),dc=function(e){i(n,e);var t=f(n);function n(e){var a,s=e.key;return r(this,n),(a=t.call(this)).method=le.GET,a.path="".concat(ke,"/").concat(s),a}return s(n)}(Oe),fc=function(e){i(n,e);var t=f(n);function n(e,a){var s;return r(this,n),(s=t.call(this,e,a)).emoji=new sc(a),s}return s(n)}(Ue),pc=function(e){i(n,e);var t=f(n);function n(){var e;return r(this,n),(e=t.call(this)).method=le.GET,e.path="".concat(Ce),e}return s(n)}(Oe),vc=function(e){i(n,e);var t=f(n);function n(e,a){var s,i;r(this,n);var o=null!=a?a:{};return(s=t.call(this,e,a)).uikitConfiguration={string:JSON.stringify(o),json:o},s.updatedAt=null!==(i=null==a?void 0:a.updated_at)&&void 0!==i?i:0,s}return s(n)}(Ue),_c=function(e){i(n,e);var t=f(n);function n(e){var a,s=e.limit,i=e.token,o=e.userIdsFilter,u=e.metaDataKeyFilter,c=e.metaDataValuesFilter,l=e.nicknameStartsWithFilter;return r(this,n),(a=t.call(this)).method=le.GET,a.path=de,a.params=ue({limit:s,token:i,user_ids:o,metadatakey:u,metadatavalues_in:c,nickname_startswith:l}),a}return s(n)}(Oe),mc=function(e){i(n,e);var t=f(n);function n(e,a){var s;return r(this,n),(s=t.call(this,e,a)).users=a.users.map((function(t){return new Xa(e,t)})),s.next=a.next,s}return s(n)}(Ue),gc=function(e){i(a,e);var n=f(a);function a(e,t){var s,i,o,u;return r(this,a),(s=n.call(this,e,t)).userIdsFilter=null,s.metaDataKeyFilter=null,s.metaDataValuesFilter=null,s.nicknameStartsWithFilter=null,s.userIdsFilter=null!==(i=t.userIdsFilter)&&void 0!==i?i:null,s.metaDataKeyFilter=null!==(o=t.metaDataKeyFilter)&&void 0!==o?o:null,s.metaDataValuesFilter=null!==(u=t.metaDataValuesFilter)&&void 0!==u?u:null,s.nicknameStartsWithFilter=t.nicknameStartsWithFilter||null,s}return s(a,[{key:"_validate",value:function(){return p(o(a.prototype),"_validate",this).call(this)&&F("string",this.userIdsFilter,!0)&&L("string",this.metaDataKeyFilter,!0)&&F("string",this.metaDataValuesFilter,!0)&&L("string",this.metaDataKeyFilter,!0)}},{key:"next",value:function(){return b(this,void 0,void 0,t().mark((function e(){var n,r,a,s,i,o,u;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!this._validate()){e.next=20;break}if(this._isLoading){e.next=17;break}if(!this._hasNext){e.next=14;break}return this._isLoading=!0,n=fs.of(this._iid),r=n.requestQueue,a=new _c(ce(Object.assign(Object.assign({},this),{token:this._token}))),e.next=8,r.send(a);case 8:return s=e.sent,i=s.as(mc),o=i.users,u=i.next,this._token=u,this._hasNext=!!u,this._isLoading=!1,e.abrupt("return",o);case 14:return e.abrupt("return",[]);case 17:throw A.queryInProgress;case 18:e.next=21;break;case 20:throw A.invalidParameters;case 21:case"end":return e.stop()}}),e,this)})))}}]),a}(Ii),yc=function(e){i(n,e);var t=f(n);function n(e){var a,s=e.userId,i=e.limit,o=e.token,u=e.userIdsFilter;return r(this,n),(a=t.call(this)).method=le.GET,a.path="".concat(de,"/").concat(s,"/block"),a.params=ue({limit:i,token:o,user_ids:u}),a}return s(n)}(Oe),kc=function(e){i(n,e);var t=f(n);function n(e,a){var s;return r(this,n),(s=t.call(this,e,a)).users=a.users.map((function(t){return new Xa(e,t)})),s.next=a.next,s}return s(n)}(Ue),bc=function(e){i(a,e);var n=f(a);function a(e,t){var s,i;return r(this,a),(s=n.call(this,e,t)).userIdsFilter=null,s.userIdsFilter=null!==(i=t.userIdsFilter)&&void 0!==i?i:null,s}return s(a,[{key:"_validate",value:function(){return p(o(a.prototype),"_validate",this).call(this)&&F("string",this.userIdsFilter,!0)}},{key:"next",value:function(){return b(this,void 0,void 0,t().mark((function e(){var n,r,a,s,i,o,u,c;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!this._validate()){e.next=20;break}if(this._isLoading){e.next=17;break}if(!this._hasNext){e.next=14;break}return this._isLoading=!0,n=fs.of(this._iid),r=n.sdkState,a=n.requestQueue,s=new yc(ce(Object.assign(Object.assign({},this),{userId:r.userId,token:this._token}))),e.next=8,a.send(s);case 8:return i=e.sent,o=i.as(kc),u=o.users,c=o.next,this._token=c,this._hasNext=!!c,this._isLoading=!1,e.abrupt("return",u);case 14:return e.abrupt("return",[]);case 17:throw A.queryInProgress;case 18:e.next=21;break;case 20:throw A.invalidParameters;case 21:case"end":return e.stop()}}),e,this)})))}}]),a}(Ii),Ec=function(e){i(n,e);var t=f(n);function n(e){var a,s=e.userId,i=e.limit,o=e.token;return r(this,n),(a=t.call(this)).method=le.GET,a.path="".concat(de,"/").concat(encodeURIComponent(s),"/friends"),a.params={limit:i,token:o},a}return s(n)}(Oe),wc=function(e){i(n,e);var t=f(n);function n(e,a){var s;return r(this,n),(s=t.call(this,e,a)).hasMore=a.has_more,s.users=a.users.map((function(t){return new Xa(e,t)})),s.next=a.next,s}return s(n)}(Ue),Cc=function(e){i(a,e);var n=f(a);function a(){return r(this,a),n.apply(this,arguments)}return s(a,[{key:"_validate",value:function(){return p(o(a.prototype),"_validate",this).call(this)}},{key:"next",value:function(){return b(this,void 0,void 0,t().mark((function e(){var n,r,a,s,i,o,u,c,l;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!this._validate()){e.next=20;break}if(this._isLoading){e.next=17;break}if(!this._hasNext){e.next=14;break}return this._isLoading=!0,n=fs.of(this._iid),r=n.sdkState,a=n.requestQueue,s=new Ec(Object.assign(Object.assign({},this),{userId:r.userId,token:this._token})),e.next=8,a.send(s);case 8:return i=e.sent,o=i.as(wc),u=o.users,c=o.hasMore,l=o.next,this._token=l,this._hasNext=c,this._isLoading=!1,e.abrupt("return",u);case 14:return e.abrupt("return",[]);case 17:throw A.queryInProgress;case 18:e.next=21;break;case 20:throw A.invalidParameters;case 21:case"end":return e.stop()}}),e,this)})))}}]),a}(Ii),xc={},Tc=function(){function e(t){var n=t.dbname,a=t.itemSizeLimit,s=void 0===a?1048576:a,i=t.cacheLimit,o=void 0===i?256:i,u=t.blockHashBase,c=void 0===u?2:u,l=t.blockHashMultiplier,h=void 0===l?10:l,d=t.blockHashConstant,f=void 0===d?11:d,p=t.transactionApplyDelay,v=void 0===p?200:p,_=t.disableLogger,m=void 0!==_&&_;return r(this,e),xc[n]||(this.itemSizeLimit=s,this.cacheLimit=o,this.blockHashBase=c,this.blockHashMultiplier=h,this.blockHashConstant=f,this.transactionApplyDelay=v,this.disableLogger=m,xc[n]=this),xc[n]}return s(e,null,[{key:"get",value:function(e){return xc[e]}}]),e}();!function(e){e[e.UNKNOWN_ERROR=6e7]="UNKNOWN_ERROR",e[e.STORE_NOT_DEFINED=61001e3]="STORE_NOT_DEFINED",e[e.STORE_NOT_AVAILABLE=61001001]="STORE_NOT_AVAILABLE",e[e.STORE_NOT_AVAILABLE_IN_PRIVATE_BROWSING=61001002]="STORE_NOT_AVAILABLE_IN_PRIVATE_BROWSING",e[e.STORE_IS_FULL=61001003]="STORE_IS_FULL",e[e.STORE_NOT_INITIALIZED=61001004]="STORE_NOT_INITIALIZED",e[e.STORE_INVALID_KEY_TYPE=61002e3]="STORE_INVALID_KEY_TYPE",e[e.STORE_BROKEN_INTEGRITY=61002001]="STORE_BROKEN_INTEGRITY",e[e.STORE_BROKEN_BLOB=61002002]="STORE_BROKEN_BLOB",e[e.STORE_ENCRYPTION_INVALID=61002003]="STORE_ENCRYPTION_INVALID",e[e.STORE_ITEM_SIZE_LIMIT_EXCEEDED=61017e3]="STORE_ITEM_SIZE_LIMIT_EXCEEDED",e[e.STORE_READ_FAILED=61017001]="STORE_READ_FAILED",e[e.STORE_WRITE_FAILED=61017002]="STORE_WRITE_FAILED",e[e.DATABASE_SCHEMA_NOT_ON_UPGRADE=62002e3]="DATABASE_SCHEMA_NOT_ON_UPGRADE",e[e.COLLECTION_NOT_READY=63001e3]="COLLECTION_NOT_READY",e[e.COLLECTION_KEY_NOT_MATCH=63002e3]="COLLECTION_KEY_NOT_MATCH",e[e.COLLECTION_QUERY_NOT_VALID=63002001]="COLLECTION_QUERY_NOT_VALID",e[e.COLLECTION_KEY_NOT_FOUND=63004e3]="COLLECTION_KEY_NOT_FOUND",e[e.COLLECTION_KEY_NOT_GIVEN=63004001]="COLLECTION_KEY_NOT_GIVEN",e[e.COLLECTION_INSERT_DUPLICATE=63009e3]="COLLECTION_INSERT_DUPLICATE",e[e.COLLECTION_WRITE_FAILED=63017e3]="COLLECTION_WRITE_FAILED",e[e.COLLECTION_ITEM_SIZE_LIMIT_EXCEEDED=63017001]="COLLECTION_ITEM_SIZE_LIMIT_EXCEEDED",e[e.INDEX_TABLE_IS_REQUIRED=65001e3]="INDEX_TABLE_IS_REQUIRED",e[e.INDEX_TYPE_NOT_MATCH=65002e3]="INDEX_TYPE_NOT_MATCH",e[e.COMPARE_TYPE_NOT_MATCH=69002001]="COMPARE_TYPE_NOT_MATCH",e[e.CIRCULAR_REFERENCE_FOUND=69002002]="CIRCULAR_REFERENCE_FOUND"}(lu||(lu={}));var Sc,Ic=function(e){i(n,e);var t=f(n);function n(e){var a,s=e.code,i=void 0===s?lu.UNKNOWN_ERROR:s,o=e.message,u=void 0===o?"Unknown error occurred.":o;return r(this,n),(a=t.call(this,u)).code=i,Object.setPrototypeOf(d(a),n.prototype),a}return s(n,null,[{key:"storeNotDefined",get:function(){return new n({code:lu.STORE_NOT_DEFINED,message:"Store is not defined. Specify the store on NestDB()"})}},{key:"storeNotAvailable",get:function(){return new n({code:lu.STORE_NOT_AVAILABLE,message:"Store is not available. Check your environment settings."})}},{key:"storeNotAvailableInPrivateBrowsing",get:function(){return new n({code:lu.STORE_NOT_AVAILABLE_IN_PRIVATE_BROWSING,message:"Store is not available because it is in private browsing."})}},{key:"storeIsFull",get:function(){return new n({code:lu.STORE_IS_FULL,message:"Store is full."})}},{key:"storeNotInitialized",get:function(){return new n({code:lu.STORE_NOT_INITIALIZED,message:"Store is not initialized."})}},{key:"storeKeyTypeIsInvalid",get:function(){return new n({code:lu.STORE_INVALID_KEY_TYPE,message:"Store key should be string type."})}},{key:"storeBrokenIntegrity",get:function(){return new n({code:lu.STORE_BROKEN_INTEGRITY,message:"Data should be in a store but it does not. Integrity is broken."})}},{key:"storeBrokenBlob",get:function(){return new n({code:lu.STORE_BROKEN_BLOB,message:"Data should be in a store but it does not. Blob data is broken."})}},{key:"storeEncryptionInvalid",get:function(){return new n({code:lu.STORE_ENCRYPTION_INVALID,message:"Encryption algorithm has changed. All the store should reset."})}},{key:"storeItemSizeExceeded",get:function(){return new n({code:lu.STORE_ITEM_SIZE_LIMIT_EXCEEDED,message:"The size of the item exceeds the limit that the store allows."})}},{key:"storeReadFailed",get:function(){return new n({code:lu.STORE_READ_FAILED,message:"Failed to read from store."})}},{key:"storeWriteFailed",get:function(){return new n({code:lu.STORE_WRITE_FAILED,message:"Failed to write to store."})}},{key:"databaseSchemaNotOnUpgrade",get:function(){return new n({code:lu.DATABASE_SCHEMA_NOT_ON_UPGRADE,message:"Committing schema is not allowed when upgrade is not running."})}},{key:"collectionNotReady",get:function(){return new n({code:lu.COLLECTION_NOT_READY,message:"Collection is not ready due to an error during initialization."})}},{key:"collectionKeyNotMatch",get:function(){return new n({code:lu.COLLECTION_KEY_NOT_MATCH,message:"keyName of collection could not change."})}},{key:"collectionQueryNotValid",get:function(){return new n({code:lu.COLLECTION_QUERY_NOT_VALID,message:"Query parameter is not a valid format."})}},{key:"collectionInsertDuplicate",get:function(){return new n({code:lu.COLLECTION_INSERT_DUPLICATE,message:"The key already exists."})}},{key:"collectionKeyNotFound",get:function(){return new n({code:lu.COLLECTION_KEY_NOT_FOUND,message:"The key is not found."})}},{key:"collectionKeyNotGiven",get:function(){return new n({code:lu.COLLECTION_KEY_NOT_GIVEN,message:"The item should contain [keyName] property."})}},{key:"collectionWriteFailed",get:function(){return new n({code:lu.COLLECTION_WRITE_FAILED,message:"Failed to write an item."})}},{key:"collectionItemSizeExceeded",get:function(){return new n({code:lu.COLLECTION_ITEM_SIZE_LIMIT_EXCEEDED,message:"The size of the item exceeds the limit that a collection allows."})}},{key:"indexTableIsRequired",get:function(){return new n({code:lu.INDEX_TABLE_IS_REQUIRED,message:"Index table is required."})}},{key:"indexTypesNotMatch",get:function(){return new n({code:lu.INDEX_TYPE_NOT_MATCH,message:"Indexed column should have primitive type."})}},{key:"compareTypesNotMatch",get:function(){return new n({code:lu.COMPARE_TYPE_NOT_MATCH,message:"Values to compare have different types."})}},{key:"circularReferenceFound",get:function(){return new n({code:lu.CIRCULAR_REFERENCE_FOUND,message:"Cannot handle circular referenced object."})}}]),n}(h(Error));!function(e){e.INIT="init",e.READY="ready",e.CLOSED="closed"}(Sc||(Sc={}));var Nc,Mc=function e(t){var r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:new WeakMap;if("object"===n(t)&&null!==t){if(r.has(t))throw Ic.circularReferenceFound;var a;if(r.set(t,!0),Array.isArray(t))a=t.map((function(t){return e(t,r)}));else if(t instanceof RegExp)a=t;else if(t instanceof Date)a=t;else for(var s in a={},t)a[s]=e(t[s],r);return r.delete(t),a}return t},Ac=function(e,t){if(null==t)return 1;if(null==e)return-1;if(n(e)!==n(t))throw Ic.compareTypesNotMatch;var r=0;switch(n(e)){case"boolean":case"number":r=e-t;break;case"string":r=e.localeCompare(t)}return r},Oc=function(e,t){for(var n=0,r=0;r>>0)%t},Uc=function(e){return new Promise((function(t){setTimeout((function(){return t()}),e)}))},Rc=function e(t,r){if(!r)return!1;if("function"!=typeof t){for(var a in t){if(["/and","&&"].includes(a)){if(t[a].some((function(t){return!e(t,r)})))return!1}else if(["/or","||"].includes(a)){if(t[a].every((function(t){return!e(t,r)})))return!1}else if("/where"===a){if(!(0,t[a])(r))return!1}else{var s=a;if("object"===n(t[s])){var i=t[s];for(var o in i)switch(o){case"/eq":case"=":if(r[s]!==i[o])return!1;break;case"/neq":case"!=":if(r[s]===i[o])return!1;break;case"/gt":case">":var u=r[s],c=i[o];if(!(Ac(u,c)>0))return!1;break;case"/gte":case">=":var l=r[s],h=i[o];if(!(Ac(l,h)>=0))return!1;break;case"/lt":case"<":var d=r[s],f=i[o];if(!(Ac(d,f)<0))return!1;break;case"/lte":case"<=":var p=r[s],v=i[o];if(!(Ac(p,v)<=0))return!1;break;case"/in":var _=r[s];if(!i[o].includes(_))return!1;break;case"/nin":var m=r[s];if(i[o].includes(m))return!1;break;case"/contain":var g=r[s],y=i[o];if(!g.includes(y))return!1;break;case"/regex":var k=r[s];if(!i[o].test(k))return!1;break;case"/where":var b=r[s];if(!(0,i[o])(b))return!1}}else if("function"==typeof t[s]){if(!t[s](r[s]))return!1}else if(t[s]!==r[s])return!1}}return!0}return t(r)},Lc=function(){},Dc=function(){return Promise.resolve()},Pc=function(e){return e},Fc=function(e,t){t()};!function(e){e[e.FORWARD=0]="FORWARD",e[e.BACKWARD=1]="BACKWARD"}(Nc||(Nc={}));var Gc,qc,Hc,jc=function(){function e(t){var n=t.initialPrevValue,a=void 0===n?null:n,s=t.initialNextValue,i=void 0===s?null:s,o=t.iterator,u=t.map,c=void 0===u?Pc:u,l=t.backward,h=void 0===l?Dc:l,d=t.forward,f=void 0===d?Dc:d,p=t.complete,v=void 0===p?Lc:p;r(this,e),this._prevValue=a,this._nextValue=i,this._error=null,this._map=c,this._backward=h,this._forward=f,this._iterator=o,this._complete=v}return s(e,[{key:"prevValue",get:function(){return this._map(this._prevValue)}},{key:"nextValue",get:function(){return this._map(this._nextValue)}},{key:"error",get:function(){return this._error}},{key:"hasPrevious",get:function(){return!!this._prevValue}},{key:"hasNext",get:function(){return!!this._nextValue}},{key:"prev",value:function(){return b(this,void 0,void 0,t().mark((function e(){var n;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!this.hasPrevious){e.next=20;break}return e.prev=1,n=this._prevValue,e.next=5,this._backward();case 5:if(e.t0=e.sent,e.t0){e.next=8;break}e.t0=null;case 8:this._prevValue=e.t0,this._nextValue=n,e.next=15;break;case 12:e.prev=12,e.t1=e.catch(1),this._error=e.t1;case 15:return e.next=17,this._iterator(this);case 17:return e.abrupt("return",e.sent);case 20:this._complete();case 21:case"end":return e.stop()}}),e,this,[[1,12]])})))}},{key:"next",value:function(){return b(this,void 0,void 0,t().mark((function e(){var n;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!this.hasNext){e.next=20;break}return e.prev=1,n=this._nextValue,e.next=5,this._forward();case 5:if(e.t0=e.sent,e.t0){e.next=8;break}e.t0=null;case 8:this._nextValue=e.t0,this._prevValue=n,e.next=15;break;case 12:e.prev=12,e.t1=e.catch(1),this._error=e.t1;case 15:return e.next=17,this._iterator(this);case 17:return e.abrupt("return",e.sent);case 20:this._complete();case 21:case"end":return e.stop()}}),e,this,[[1,12]])})))}},{key:"stop",value:function(){this._prevValue=null,this._nextValue=null,this._complete()}}]),e}(),zc=function(){function e(t){var n=t.condition,a=void 0===n?{}:n,s=t.backward,i=void 0!==s&&s,o=t.blockManager,u=t.indexer;r(this,e),this.condition=a,this.backward=i,this._blockManager=o,this._indexer=u}return s(e,[{key:"findOptimizedStartPosition",value:function(){var e=this,t=["=","/eq",">",">=","/gt","/gte"],r=["=","/eq","<","<=","/lt","/lte"];if(this.backward){var a=this._indexer.origin.length-1;if("function"!=typeof this.condition)for(var s in this._indexer.fields){var i=this._indexer.fields[s],o=1;if("-"===i[0]&&(i=i.slice(1),o=-1),this.condition[i])if("object"===n(this.condition[i])){var u=o>0?r:t;for(var c in this.condition[i])if(u.includes(c))for(var l=a;l>=0;l--)if(o*Ac(this._indexer.origin[l].columnValues[s],this.condition[i][c])<=0){a=l;break}}else for(var h=a;h>=0;h--)if(o*Ac(this._indexer.origin[h].columnValues[s],this.condition[i])<=0){a=h;break}}return Math.min(a+1,this._indexer.origin.length-1)}var d=0;if("function"!=typeof this.condition)for(var f=function(a){var s=e._indexer.fields[a],i=1;if("-"===s[0]&&(s=s.slice(1),i=-1),e.condition[s])if("object"===n(e.condition[s]))Object.keys(e.condition[s]).forEach((function(n){if((i>0?t:r).includes(n))for(var o=d;o=0){d=o;break}}));else for(var o=d;o=0){d=o;break}},p=0;p0&&void 0!==arguments[0]?arguments[0]:{};return b(this,void 0,void 0,t().mark((function n(){var r,a,s,i=this;return t().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:if(r=Math.max(e.offset||0,0),0!==(a="number"==typeof e.limit?e.limit:Number.MAX_SAFE_INTEGER)){n.next=6;break}return n.abrupt("return",[]);case 6:if(!(a<0)){n.next=8;break}throw Ic.collectionQueryNotValid;case 8:return n.prev=8,s=[],n.next=12,this._mutex.lock();case 12:return n.next=14,this._iterator.each((function(e){return b(i,void 0,void 0,t().mark((function n(){return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:e.error?e.stop():e.hasNext?0===r?(s.push(e.nextValue),03&&void 0!==arguments[3]?arguments[3]:0;return"".concat(Yc(e,t)).concat(n,".").concat(r)},Jc=function(){function e(t){var n=t.dbname,a=t.collectionName,s=t.store;r(this,e),this.dbname=n,this.collectionName=a,this.store=s}return s(e,[{key:"get",value:function(e){return b(this,void 0,void 0,t().mark((function n(){var r,a,s,i,o,u,c,l,h,d;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,this.store.get(e);case 2:if(!(r=t.sent)){t.next=19;break}if(a=r.data,s=r.type,"undefined"==typeof fetch){t.next=14;break}return t.next=8,fetch(a);case 8:return i=t.sent,t.next=11,i.blob();case 11:return t.abrupt("return",t.sent);case 14:for(512,o=[],u=atob(a.split(",")[1]),c=0;c1&&void 0!==arguments[1]?arguments[1]:"".concat(Date.now());return b(this,void 0,void 0,t().mark((function r(){var a,s,i,o,u=this;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,new Promise((function(t){var r=Zc(u.dbname,u.collectionName,n),a=new FileReader;a.onload=function(){t({blobId:r,data:a.result,type:e.type})},a.readAsDataURL(e)}));case 2:return a=t.sent,s=a.blobId,i=a.data,o=a.type,t.next=8,this.store.set({key:s,value:{data:i,type:o}});case 8:return t.abrupt("return",s);case 9:case"end":return t.stop()}}),r,this)})))}},{key:"remove",value:function(e){return b(this,void 0,void 0,t().mark((function n(){return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,this.store.remove(e);case 2:case"end":return t.stop()}}),n,this)})))}},{key:"clear",value:function(){return b(this,void 0,void 0,t().mark((function e(){var n,r,a=this;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n=Yc(this.dbname,this.collectionName),e.next=3,this.store.getAllKeys();case 3:return r=e.sent,e.next=6,Promise.all(r.filter((function(e){return e.startsWith(n)})).map((function(e){return b(a,void 0,void 0,t().mark((function n(){return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,this.store.remove(e);case 2:return t.abrupt("return",t.sent);case 3:case"end":return t.stop()}}),n,this)})))})));case 6:case"end":return e.stop()}}),e,this)})))}}]),e}();!function(e){e[e.COMMIT=0]="COMMIT",e[e.WRITE=1]="WRITE",e[e.ERROR=2]="ERROR"}(Gc||(Gc={})),function(e){e.PENDING="pending",e.PERSISTENT="persistent",e.VOLATILE="volatile"}(qc||(qc={})),function(e){e[e.NO_CACHE=0]="NO_CACHE",e[e.DEFAULT=1]="DEFAULT",e[e.PERSISTENT=2]="PERSISTENT"}(Hc||(Hc={}));var Xc,$c=[qc.PENDING,qc.VOLATILE],el={},tl=function(){function e(t){var n=t.dbname,a=t.limit,s=void 0===a?256:a;return r(this,e),el[n]||(this.dbname=n,this._items=[],this._limit=s,el[n]=this),el[n]}return s(e,[{key:"items",get:function(){return this._items}},{key:"find",value:function(e,n){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:Hc.DEFAULT;return b(this,void 0,void 0,t().mark((function a(){var s,i;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(s=this.get(n)){t.next=8;break}return t.next=4,e.get(n);case 4:(i=t.sent)&&(s={key:n,value:i,state:r===Hc.PERSISTENT?qc.PERSISTENT:qc.VOLATILE},this.put(s)),t.next=9;break;case 8:r===Hc.PERSISTENT&&(s.state=qc.PERSISTENT);case 9:return t.abrupt("return",s);case 10:case"end":return t.stop()}}),a,this)})))}},{key:"get",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:Hc.DEFAULT,n=this._items.map((function(e){return e.key})).indexOf(e);if(n>-1){var r=this._items[n];return t===Hc.PERSISTENT&&(r.state=qc.PERSISTENT),t!==Hc.NO_CACHE&&this.put(r),r}return null}},{key:"put",value:function(e){if(this._limit>0){var t=this._items.map((function(e){return e.key})).indexOf(e.key);if(t>-1)$c.includes(this._items[t].state)&&$c.includes(e.state)?(this._items.splice(t,1),this._items.push(e)):(this._items[t].state=e.state,this._items[t].value=e.value);else{this._items.push(e);var n=this._items.filter((function(e){return e.state===qc.VOLATILE})),r=n.length-this._limit;if(r>0){var a,s=[],i=y(this._items);try{for(i.s();!(a=i.n()).done;){var o=a.value;o.state===qc.VOLATILE&&r>0?r--:s.push(o)}}catch(e){i.e(e)}finally{i.f()}this._items=s}}}}},{key:"remove",value:function(e){var t=this._items.map((function(e){return e.key})).indexOf(e);t>-1&&this._items.splice(t,1)}},{key:"clearByCondition",value:function(e){this._items=this._items.filter((function(t){return!e(t)}))}},{key:"clear",value:function(){var e=arguments.length>0&&void 0!==arguments[0]&&arguments[0];this._items=e?[]:this._items.filter((function(e){return e.state!==qc.VOLATILE}))}}],[{key:"get",value:function(e){return el[e]}}]),e}(),nl=function(){function e(t){var n=t.dbname,a=t.collectionName,s=t.store;r(this,e),this._requests=[],this._onCommit=new Map,this._onWrite=new Map,this._onError=new Map,this.dbname=n,this.collectionName=a,this.metadataKey=function(e,t){return"".concat(Qc(e,t),"/trans.metadata")}(n,a),this.recordsetKey=function(e,t){return"".concat(Qc(e,t),"/trans.recordset")}(n,a),this._store=s}return s(e,[{key:"generation",get:function(){return this._metadata?this._metadata.generation:0}},{key:"requestCount",get:function(){return this._requests.length}},{key:"_getReducedRecordset",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[];return b(this,void 0,void 0,t().mark((function n(){var r;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,this._store.get(this.recordsetKey);case 2:if(t.t0=t.sent,t.t0){t.next=5;break}t.t0=[];case 5:return(r=t.t0).push.apply(r,_(e)),t.abrupt("return",this._reduceRecordSet(r));case 8:case"end":return t.stop()}}),n,this)})))}},{key:"_reduceRecordSet",value:function(e){for(var t=[],n={},r=e.length-1;r>=0;r--){for(var a=e[r],s=[],i=a.requests.length-1;i>=0;i--){var o=a.requests[i],u=o.data;n[u.key]||(s.unshift(o),n[u.key]=!0)}s.length>0&&(a.requests=s,t.unshift(a))}return t}},{key:"_applyRecord",value:function(e,n){return b(this,void 0,void 0,t().mark((function r(){var a,s,i,o,u,c,l,h;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return a=tl.get(this.dbname),s=n.generation,i=n.requests,o=null,t.prev=3,t.next=6,this._store.setMany(i.map((function(e){return Object.assign(Object.assign({},e.data),{generation:s})})));case 6:for(u=t.sent,c=0;c0)){e.next=20;break}for(r=[],a={},s=n.length-1;s>=0;s--)i=n[s],o=i.data,a[o.key]||(a[o.key]=!0,r.unshift(i));return u={generation:this.generation,requests:r},e.next=8,this._getReducedRecordset([u]);case 8:return c=e.sent,e.next=11,this._store.set({key:this.recordsetKey,value:c});case 11:return this._metadata.generation++,e.next=14,this._store.set({key:this.metadataKey,value:this._metadata});case 14:for(l=tl.get(this.dbname),h=0;h1&&void 0!==arguments[1]?arguments[1]:this.metadata.blockLevel;return t=this.dbname,n=this.collectionName,r=s,a="".concat(function(e,t,n){var r=n.base*Math.pow(n.multiplier,t)+n.constant;return(n.hashFunction||Oc)(e,r)}(e,s,{hashFunction:this.hashFunction,base:this.metadata.blockHashBase,multiplier:this.metadata.blockHashMultiplier,constant:this.metadata.blockHashConstant})),"".concat(Wc(t,n)).concat(r,".").concat(a)}},{key:"_findBlock",value:function(e){return b(this,void 0,void 0,t().mark((function n(){var r,a,s,i,o;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:r=tl.get(this.dbname),a=this.metadata.blockLevel;case 2:if(!(a>0)){t.next=15;break}return s=this.createBlockId(e,a),t.next=6,r.find(this._store,s);case 6:if(!(i=t.sent)){t.next=12;break}if(o=rl.createFromCacheItem(i),!(null==o?void 0:o.getItemByKey(e))){t.next=12;break}return t.abrupt("return",o);case 12:a--,t.next=2;break;case 15:return t.abrupt("return",null);case 16:case"end":return t.stop()}}),n,this)})))}},{key:"getFromBlock",value:function(e){return b(this,void 0,void 0,t().mark((function n(){var r;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,this._findBlock(e);case 2:return r=t.sent,t.abrupt("return",r?r.getItemByKey(e):null);case 4:case"end":return t.stop()}}),n,this)})))}},{key:"putToBlock",value:function(e,n){return b(this,void 0,void 0,t().mark((function r(){var a,s,i,o,u,c;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return a=Tc.get(this.dbname),s=this.createBlockId(e),i=Math.floor(this._store.itemSizeLimit/a.itemSizeLimit),o=tl.get(this.dbname),t.next=6,o.find(this._store,s);case 6:if(u=t.sent,!(null==(c=u?rl.createFromCacheItem(u):new rl({blockId:s,keyName:this.keyName,items:[],limit:i}))?void 0:c.add(n))){t.next=11;break}return this._transaction.requestWrite({key:c.blockId,value:c.serialize()}),t.abrupt("return",!0);case 11:return t.abrupt("return",!1);case 12:case"end":return t.stop()}}),r,this)})))}},{key:"removeFromBlock",value:function(e){return b(this,void 0,void 0,t().mark((function n(){var r;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,this._findBlock(e);case 2:if(!(r=t.sent)){t.next=7;break}if(!r.remove(e)){t.next=7;break}return this._transaction.requestWrite({key:r.blockId,value:r.serialize()}),t.abrupt("return",!0);case 7:return t.abrupt("return",!1);case 8:case"end":return t.stop()}}),n,this)})))}},{key:"clearAllBlocks",value:function(){return b(this,void 0,void 0,t().mark((function e(){var n,r,a;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n=Wc(this.dbname,this.collectionName),e.next=3,this._store.getAllKeys();case 3:return r=e.sent,a=r.filter((function(e){return e.startsWith(n)})),e.next=7,this._store.removeMany(a);case 7:return e.next=9,this._transaction.clear();case 9:tl.get(this.dbname).clearByCondition((function(e){return e.key.startsWith(n)}));case 11:case"end":return e.stop()}}),e,this)})))}}]),e}(),sl={},il=function(){function e(t){var n=this,a=t.dbname,s=t.collectionName,i=t.keyName,o=t.fields,u=t.transaction,c=t.store;r(this,e),this._origin=[],this._table=[];var l=function(e,t,n){return"".concat(Qc(e,t),"/index.").concat(n)}(a,s,o.join(">"));return sl[l]||(this.dbname=a,this.collectionName=s,this.keyName=i,this.fields=o,this.indexerKey=l,this._transaction=u,this._store=c,this._transaction.on(Gc.COMMIT,this.indexerKey,(function(){return n.commit()})),this._transaction.on(Gc.ERROR,this.indexerKey,(function(){return n.abort()}))),sl[l]}return s(e,[{key:"_addItem",value:function(e){var t=e[this.keyName],n=this.getColumnValues(e),r=v(this.indexOf(n),2),a=r[0];return r[1]?!this._table[a].keys.includes(t)&&(this._table[a].keys.push(t),!0):(this._table.splice(a,0,{columnValues:n,keys:[t]}),!0)}},{key:"_removeItem",value:function(e){var t=e[this.keyName],n=this.getColumnValues(e),r=v(this.indexOf(n),2),a=r[0];if(r[1]){var s=this._table[a].keys.indexOf(t);if(s>-1)return this._table[a].keys.splice(s,1),0===this._table[a].keys.length&&this._table.splice(a,1),!0}return!1}},{key:"origin",get:function(){return this._origin}},{key:"table",get:function(){return this._table}},{key:"getColumnValues",value:function(e){var t,r,a,s=[],i=y(this.fields);try{for(i.s();!(t=i.n()).done;){var o=t.value;if("-"===o[0]&&(o=o.slice(1)),r=e[o],a=void 0,a=n(r),null!==r&&"undefined"!==a&&"boolean"!==a&&"number"!==a&&"string"!==a)throw Ic.indexTypesNotMatch;s.push(e[o])}}catch(e){i.e(e)}finally{i.f()}return s}},{key:"diff",value:function(e,t){for(var n in this.fields){var r="-"===this.fields[n][0]?-1:1,a=Ac(e[n],t[n]);if(0!==a)return r*a}return 0}},{key:"indexOf",value:function(e){if(this._table.length>0){for(var t=0,n=this._table.length-1;t<=n;){var r=Math.floor((t+n)/2),a=this.diff(e,this._table[r].columnValues);if(a>0)t=r+1;else{if(!(a<0))return[r,!0];n=r-1}}return[t,!1]}return[0,!1]}},{key:"ensure",value:function(){return b(this,void 0,void 0,t().mark((function e(){var n,r,a,s,i,o,u,c,l,h,d,f;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n=tl.get(this.dbname),e.next=3,n.find(this._store,this.indexerKey,Hc.PERSISTENT);case 3:if(r=e.sent){e.next=33;break}return a=Wc(this.dbname,this.collectionName),e.next=8,this._store.getAllKeys();case 8:s=e.sent,i=y(s),e.prev=10,i.s();case 12:if((o=i.n()).done){e.next=22;break}if(!(u=o.value).startsWith(a)){e.next=20;break}return e.next=17,n.find(this._store,u,Hc.NO_CACHE);case 17:if(c=e.sent,l=rl.createFromCacheItem(c)){h=y(l.items);try{for(h.s();!(d=h.n()).done;)f=d.value,this._addItem(f)}catch(e){h.e(e)}finally{h.f()}}case 20:e.next=12;break;case 22:e.next=27;break;case 24:e.prev=24,e.t0=e.catch(10),i.e(e.t0);case 27:return e.prev=27,i.f(),e.finish(27);case 30:this._transaction.requestWrite({key:this.indexerKey,value:this._table},{persistent:!0}),e.next=35;break;case 33:this._origin=r.value,this._table=Mc(this._origin);case 35:sl[this.indexerKey]=this;case 36:case"end":return e.stop()}}),e,this,[[10,24,27,30]])})))}},{key:"drop",value:function(){return b(this,void 0,void 0,t().mark((function e(){return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return tl.get(this.dbname).remove(this.indexerKey),e.next=4,this._store.remove(this.indexerKey);case 4:delete sl[this.indexerKey];case 5:case"end":return e.stop()}}),e,this)})))}},{key:"addItem",value:function(e){return b(this,void 0,void 0,t().mark((function n(){return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:this._addItem(e)&&this._transaction.requestWrite({key:this.indexerKey,value:this._table},{persistent:!0});case 1:case"end":return t.stop()}}),n,this)})))}},{key:"removeItem",value:function(e){return b(this,void 0,void 0,t().mark((function n(){return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:this._removeItem(e)&&this._transaction.requestWrite({key:this.indexerKey,value:this._table},{persistent:!0});case 1:case"end":return t.stop()}}),n,this)})))}},{key:"clear",value:function(){return b(this,void 0,void 0,t().mark((function e(){return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:this._table=[],this._transaction.requestWrite({key:this.indexerKey,value:this._table},{persistent:!0});case 2:case"end":return e.stop()}}),e,this)})))}},{key:"commit",value:function(){this._origin=this._table,this._table=Mc(this._origin)}},{key:"abort",value:function(){this._table=Mc(this._origin)}}],[{key:"createKey",value:function(e){return e.join(">")}},{key:"parseKey",value:function(e){return e.split(">")}},{key:"clearIndexerMap",value:function(){for(var e in sl)delete sl[e]}}]),e}(),ol=function(){function e(t){var n=this,a=t.dbname,s=t.collectionName,i=t.keyName,o=t.keyHash,u=t.indexes,c=t.store;r(this,e),this._state=Sc.INIT,this._indexers=[],this.dbname=a,this.name=s,this.keyName=i,this.indexes=[[i]].concat(_(u.filter((function(e){return il.createKey(e)!==n.keyName})))),this._keyHash=o,this._store=c,this._mutex=new Vo(function(e,t){return"".concat(Qc(e,t),".lock")}(a,s)),this._blobContainer=new Jc({dbname:a,collectionName:s,store:c}),this._transaction=new nl({dbname:a,collectionName:s,store:c})}return s(e,[{key:"state",get:function(){return this._state}},{key:"isReady",get:function(){return this._state===Sc.READY}},{key:"init",value:function(){return b(this,void 0,void 0,t().mark((function n(){var r,a,s,i,o,u,c,l,h,d,f,p=this;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,this._mutex.lock();case 2:return t.prev=2,r=Tc.get(this.dbname),t.next=6,e.metadataOf(this.dbname,this.name,this._store);case 6:return a=t.sent,this._metadata=a||{keyName:this.keyName,blockLevel:1,blockHashBase:r.blockHashBase,blockHashMultiplier:r.blockHashMultiplier,blockHashConstant:r.blockHashConstant,indexes:this.indexes},t.next=10,this._transaction.init();case 10:this._blockManager=new al({dbname:this.dbname,collectionName:this.name,hashFunction:this._keyHash,metadata:this._metadata,transaction:this._transaction,store:this._store}),s=_(this.indexes),i=[],o=s.map((function(e){return il.createKey(e)})),u=a?a.indexes.map((function(e){return il.createKey(e)})):[],c=y(u);try{for(c.s();!(l=c.n()).done;)h=l.value,o.includes(h)||i.push(il.parseKey(h))}catch(e){c.e(e)}finally{c.f()}return(d=[]).push.apply(d,_(s.map((function(e){var t=new il({dbname:p.dbname,collectionName:p.name,keyName:p.keyName,fields:e,transaction:p._transaction,store:p._store});return p._indexers.push(t),t.ensure()})))),d.push.apply(d,_(i.map((function(e){return new il({dbname:p.dbname,collectionName:p.name,keyName:p.keyName,fields:e,transaction:p._transaction,store:p._store}).drop()})))),t.next=22,Promise.all(d);case 22:return t.next=24,this._transaction.commit();case 24:if(o.sort().join(",")===u.sort().join(",")){t.next=29;break}return f=Kc(this.dbname,this.name),this._metadata.indexes=s,t.next=29,this._store.set({key:f,value:this._metadata});case 29:this._state=Sc.READY,this._mutex.unlock(),t.next=37;break;case 33:throw t.prev=33,t.t0=t.catch(2),this._mutex.unlock(),t.t0;case 37:case"end":return t.stop()}}),n,this,[[2,33]])})))}},{key:"close",value:function(){this._state=Sc.CLOSED}},{key:"_hasPropertyOfKeyName",value:function(e){var t=e[this.keyName];return"string"==typeof t&&!!t}},{key:"_getIndexerBy",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:null;e||(e=[this.keyName]);var t,n=il.createKey(e),r=y(this._indexers);try{for(r.s();!(t=r.n()).done;){var a=t.value;if(n===il.createKey(a.fields))return a}}catch(e){r.e(e)}finally{r.f()}throw Ic.indexTableIsRequired}},{key:"_upgradeBlockLevel",value:function(){return b(this,void 0,void 0,t().mark((function e(){var n;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n=Kc(this.dbname,this.name),this._metadata.blockLevel++,e.next=4,this._store.set({key:n,value:this._metadata});case 4:case"end":return e.stop()}}),e,this)})))}},{key:"_requestInsert",value:function(e){return b(this,void 0,void 0,t().mark((function n(){var r,a,s,i;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return r=e[this.keyName],t.next=3,this._blockManager.getFromBlock(r);case 3:if(t.sent){t.next=32;break}return t.next=7,this._blockManager.putToBlock(r,e);case 7:if(t.sent){t.next=13;break}return t.next=11,this._upgradeBlockLevel();case 11:return t.next=13,this._blockManager.putToBlock(r,e);case 13:a=y(this._indexers),t.prev=14,a.s();case 16:if((s=a.n()).done){t.next=22;break}return i=s.value,t.next=20,i.addItem(e);case 20:t.next=16;break;case 22:t.next=27;break;case 24:t.prev=24,t.t0=t.catch(14),a.e(t.t0);case 27:return t.prev=27,a.f(),t.finish(27);case 30:t.next=33;break;case 32:throw Ic.collectionInsertDuplicate;case 33:case"end":return t.stop()}}),n,this,[[14,24,27,30]])})))}},{key:"_requestUpsert",value:function(e){return b(this,void 0,void 0,t().mark((function n(){var r,a,s,i,o,u,c,l;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return r=e[this.keyName],t.next=3,this._blockManager.getFromBlock(r);case 3:if(a=t.sent){t.next=32;break}return t.next=7,this._blockManager.putToBlock(r,e);case 7:if(t.sent){t.next=13;break}return t.next=11,this._upgradeBlockLevel();case 11:return t.next=13,this._blockManager.putToBlock(r,e);case 13:s=y(this._indexers),t.prev=14,s.s();case 16:if((i=s.n()).done){t.next=22;break}return o=i.value,t.next=20,o.addItem(e);case 20:t.next=16;break;case 22:t.next=27;break;case 24:t.prev=24,t.t0=t.catch(14),s.e(t.t0);case 27:return t.prev=27,s.f(),t.finish(27);case 30:t.next=54;break;case 32:return t.next=34,this._blockManager.putToBlock(r,e);case 34:u=y(this._indexers),t.prev=35,u.s();case 37:if((c=u.n()).done){t.next=46;break}if(0===(l=c.value).diff(l.getColumnValues(a),l.getColumnValues(e))){t.next=44;break}return t.next=42,l.removeItem(a);case 42:return t.next=44,l.addItem(e);case 44:t.next=37;break;case 46:t.next=51;break;case 48:t.prev=48,t.t1=t.catch(35),u.e(t.t1);case 51:return t.prev=51,u.f(),t.finish(51);case 54:case"end":return t.stop()}}),n,this,[[14,24,27,30],[35,48,51,54]])})))}},{key:"_requestUpdate",value:function(e){return b(this,void 0,void 0,t().mark((function n(){var r,a,s,i,o;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return r=e[this.keyName],t.next=3,this._blockManager.getFromBlock(r);case 3:if(!(a=t.sent)){t.next=27;break}return t.next=7,this._blockManager.putToBlock(r,e);case 7:s=y(this._indexers),t.prev=8,s.s();case 10:if((i=s.n()).done){t.next=19;break}if(0===(o=i.value).diff(o.getColumnValues(a),o.getColumnValues(e))){t.next=17;break}return t.next=15,o.removeItem(a);case 15:return t.next=17,o.addItem(e);case 17:t.next=10;break;case 19:t.next=24;break;case 21:t.prev=21,t.t0=t.catch(8),s.e(t.t0);case 24:return t.prev=24,s.f(),t.finish(24);case 27:case"end":return t.stop()}}),n,this,[[8,21,24,27]])})))}},{key:"_requestRemove",value:function(e){return b(this,void 0,void 0,t().mark((function n(){var r,a,s,i;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,this._blockManager.getFromBlock(e);case 2:if(!(r=t.sent)){t.next=23;break}return t.next=6,this._blockManager.removeFromBlock(e);case 6:a=y(this._indexers),t.prev=7,a.s();case 9:if((s=a.n()).done){t.next=15;break}return i=s.value,t.next=13,i.removeItem(r);case 13:t.next=9;break;case 15:t.next=20;break;case 17:t.prev=17,t.t0=t.catch(7),a.e(t.t0);case 20:return t.prev=20,a.f(),t.finish(20);case 23:case"end":return t.stop()}}),n,this,[[7,17,20,23]])})))}},{key:"_requestClear",value:function(){return b(this,void 0,void 0,t().mark((function e(){var n,r,a;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this._blockManager.clearAllBlocks();case 2:n=y(this._indexers),e.prev=3,n.s();case 5:if((r=n.n()).done){e.next=11;break}return a=r.value,e.next=9,a.clear();case 9:e.next=5;break;case 11:e.next=16;break;case 13:e.prev=13,e.t0=e.catch(3),n.e(e.t0);case 16:return e.prev=16,n.f(),e.finish(16);case 19:case"end":return e.stop()}}),e,this,[[3,13,16,19]])})))}},{key:"getByKey",value:function(e){return b(this,void 0,void 0,t().mark((function n(){var r;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(!this.isReady){t.next=17;break}return t.next=3,this._mutex.lock();case 3:return t.prev=3,t.next=6,this._blockManager.getFromBlock(e);case 6:return r=t.sent,this._mutex.unlock(),t.abrupt("return",Mc(r));case 11:throw t.prev=11,t.t0=t.catch(3),this._mutex.unlock(),t.t0;case 15:t.next=18;break;case 17:throw Ic.collectionNotReady;case 18:case"end":return t.stop()}}),n,this,[[3,11]])})))}},{key:"query",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};if(this.isReady)return new Vc({condition:e.where,mutex:this._mutex,blockManager:this._blockManager,indexer:this._getIndexerBy(e.index),backward:!!e.backward});throw Ic.collectionNotReady}},{key:"insertOne",value:function(e){return b(this,void 0,void 0,t().mark((function n(){return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(!this.isReady){t.next=22;break}return t.next=3,this._mutex.lock();case 3:if(t.prev=3,this._hasPropertyOfKeyName(e)){t.next=6;break}throw Ic.collectionKeyNotGiven;case 6:return t.next=8,this._requestInsert(Mc(e));case 8:return t.next=10,this._transaction.commit();case 10:return this._mutex.unlock(),t.abrupt("return",e);case 14:return t.prev=14,t.t0=t.catch(3),t.next=18,this._transaction.clear();case 18:throw this._mutex.unlock(),t.t0;case 20:t.next=23;break;case 22:throw Ic.collectionNotReady;case 23:case"end":return t.stop()}}),n,this,[[3,14]])})))}},{key:"insertMany",value:function(e){return b(this,void 0,void 0,t().mark((function n(){var r,a,s,i=this;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(!this.isReady){t.next=37;break}return t.next=3,this._mutex.lock();case 3:if(t.prev=3,!e.some((function(e){return!i._hasPropertyOfKeyName(e)}))){t.next=6;break}throw Ic.collectionKeyNotGiven;case 6:r=y(e),t.prev=7,r.s();case 9:if((a=r.n()).done){t.next=15;break}return s=a.value,t.next=13,this._requestInsert(Mc(s));case 13:t.next=9;break;case 15:t.next=20;break;case 17:t.prev=17,t.t0=t.catch(7),r.e(t.t0);case 20:return t.prev=20,r.f(),t.finish(20);case 23:return t.next=25,this._transaction.commit();case 25:return this._mutex.unlock(),t.abrupt("return",e);case 29:return t.prev=29,t.t1=t.catch(3),t.next=33,this._transaction.clear();case 33:throw this._mutex.unlock(),t.t1;case 35:t.next=38;break;case 37:throw Ic.collectionNotReady;case 38:case"end":return t.stop()}}),n,this,[[3,29],[7,17,20,23]])})))}},{key:"upsertOne",value:function(e){return b(this,void 0,void 0,t().mark((function n(){return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(!this.isReady){t.next=22;break}return t.next=3,this._mutex.lock();case 3:if(t.prev=3,this._hasPropertyOfKeyName(e)){t.next=6;break}throw Ic.collectionKeyNotGiven;case 6:return t.next=8,this._requestUpsert(Mc(e));case 8:return t.next=10,this._transaction.commit();case 10:return this._mutex.unlock(),t.abrupt("return",e);case 14:return t.prev=14,t.t0=t.catch(3),t.next=18,this._transaction.clear();case 18:throw this._mutex.unlock(),t.t0;case 20:t.next=23;break;case 22:throw Ic.collectionNotReady;case 23:case"end":return t.stop()}}),n,this,[[3,14]])})))}},{key:"upsertMany",value:function(e){return b(this,void 0,void 0,t().mark((function n(){var r,a,s,i=this;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(!this.isReady){t.next=37;break}return t.next=3,this._mutex.lock();case 3:if(t.prev=3,!e.some((function(e){return!i._hasPropertyOfKeyName(e)}))){t.next=6;break}throw Ic.collectionKeyNotGiven;case 6:r=y(e),t.prev=7,r.s();case 9:if((a=r.n()).done){t.next=15;break}return s=a.value,t.next=13,this._requestUpsert(Mc(s));case 13:t.next=9;break;case 15:t.next=20;break;case 17:t.prev=17,t.t0=t.catch(7),r.e(t.t0);case 20:return t.prev=20,r.f(),t.finish(20);case 23:return t.next=25,this._transaction.commit();case 25:return this._mutex.unlock(),t.abrupt("return",e);case 29:return t.prev=29,t.t1=t.catch(3),t.next=33,this._transaction.clear();case 33:throw this._mutex.unlock(),t.t1;case 35:t.next=38;break;case 37:throw Ic.collectionNotReady;case 38:case"end":return t.stop()}}),n,this,[[3,29],[7,17,20,23]])})))}},{key:"update",value:function(e){return b(this,void 0,void 0,t().mark((function n(){return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(!this.isReady){t.next=22;break}return t.next=3,this._mutex.lock();case 3:if(t.prev=3,this._hasPropertyOfKeyName(e)){t.next=6;break}throw Ic.collectionKeyNotGiven;case 6:return t.next=8,this._requestUpdate(Mc(e));case 8:return t.next=10,this._transaction.commit();case 10:return this._mutex.unlock(),t.abrupt("return",e);case 14:return t.prev=14,t.t0=t.catch(3),t.next=18,this._transaction.clear();case 18:throw this._mutex.unlock(),t.t0;case 20:t.next=23;break;case 22:throw Ic.collectionNotReady;case 23:case"end":return t.stop()}}),n,this,[[3,14]])})))}},{key:"updateIf",value:function(e,n){return b(this,void 0,void 0,t().mark((function r(){var a,s,i,o,u,c,l,h,d,f,p,v=this;return t().wrap((function(r){for(;;)switch(r.prev=r.next){case 0:if(!this.isReady){r.next=31;break}return r.next=3,this._mutex.lock();case 3:return r.prev=3,a=e.where,s=void 0===a?{}:a,i=e.index,o=void 0===i?null:i,u=e.backward,c=void 0!==u&&u,l=[],h=new zc({condition:s,blockManager:this._blockManager,backward:c,indexer:this._getIndexerBy(o)}),r.next=9,h.each((function(e){return b(v,void 0,void 0,t().mark((function r(){var a,i;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(e.error){t.next=4;break}if(e.hasNext){if(a=e.nextValue,Rc(s,a)&&n.set){if("function"!=typeof n.set)for(i in n.set)a[i]=n.set[i];else n.set(a);l.push(a)}e.next()}else e.stop();t.next=6;break;case 4:throw e.stop(),e.error;case 6:case"end":return t.stop()}}),r)})))}));case 9:d=0,f=l;case 10:if(!(d1&&void 0!==arguments[1]?arguments[1]:"";return"".concat(e).concat(t)}},{key:"_generateShardPostfixArray",value:function(){return _(Array(arguments.length>0&&void 0!==arguments[0]?arguments[0]:1).keys())}},{key:"_shardify",value:function(e){var t=this,n=e.key,r=e.value,a=JSON.stringify(this.encryption.encrypt(r)),s=Math.ceil(a.length/this.adjustedItemSizeLimit);return this._generateShardPostfixArray(s).map((function(e){var r={key:t._getRawKey(n,".".concat(e)),data:a.substring(e*t.adjustedItemSizeLimit,(e+1)*t.adjustedItemSizeLimit)};return 0===e&&(r.metadata={shards:s}),r}))}},{key:"adjustedItemSizeLimit",get:function(){return Math.max(this.itemSizeLimit-this.metadataBuffer,4)}},{key:"usage",value:function(){return b(this,void 0,void 0,t().mark((function e(){var n,r,a,s,i,o;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n=0,e.next=3,this._getAllRawKeys();case 3:r=e.sent,a=y(r),e.prev=5,a.s();case 7:if((s=a.n()).done){e.next=15;break}return i=s.value,e.next=11,this._getRaw(i);case 11:(o=e.sent)&&(n+=JSON.stringify(o).length);case 13:e.next=7;break;case 15:e.next=20;break;case 17:e.prev=17,e.t0=e.catch(5),a.e(e.t0);case 20:return e.prev=20,a.f(),e.finish(20);case 23:return e.abrupt("return",n);case 24:case"end":return e.stop()}}),e,this,[[5,17,20,23]])})))}},{key:"getAllKeys",value:function(){return b(this,void 0,void 0,t().mark((function e(){var n;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this._getAllRawKeys();case 2:return n=e.sent,e.abrupt("return",n.filter((function(e){return e.endsWith(".0")})).map((function(e){return e.replace(/\.0$/,"")})));case 4:case"end":return e.stop()}}),e,this)})))}},{key:"get",value:function(e){return b(this,void 0,void 0,t().mark((function n(){var r,a,s,i,o,u=this;return t().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return r=this._getRawKey(e,".0"),n.next=3,this._getRaw(r);case 3:if(!(a=n.sent)){n.next=21;break}if(n.prev=5,s=a.data,!((null==(i=a.metadata)?void 0:i.shards)&&i.shards>1)){n.next=13;break}return n.next=10,Promise.all(this._generateShardPostfixArray(null==i?void 0:i.shards).map((function(n){return b(u,void 0,void 0,t().mark((function r(){var a,i;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(!(n>0)){t.next=10;break}return a=this._getRawKey(e,".".concat(n)),t.next=4,this._getRaw(a);case 4:if(i=t.sent){t.next=7;break}throw Ic.storeBrokenIntegrity;case 7:return t.abrupt("return",i.data);case 10:return t.abrupt("return",s);case 11:case"end":return t.stop()}}),r,this)})))})));case 10:n.t0=n.sent,n.next=14;break;case 13:n.t0=[s];case 14:return o=n.t0,n.abrupt("return",this.encryption.decrypt(JSON.parse(o.join(""))));case 18:return n.prev=18,n.t1=n.catch(5),n.abrupt("return",null);case 21:return n.abrupt("return",null);case 22:case"end":return n.stop()}}),n,this,[[5,18]])})))}},{key:"set",value:function(e){return b(this,void 0,void 0,t().mark((function n(){var r;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return r=this._shardify(e),t.next=3,this._setRaw(r);case 3:return t.abrupt("return",Object.assign({},e.value));case 4:case"end":return t.stop()}}),n,this)})))}},{key:"setMany",value:function(e){return b(this,void 0,void 0,t().mark((function n(){var r,a=this;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return r=[],t.next=3,this._setRaw(r.concat.apply(r,_(e.map((function(e){return a._shardify(e)})))));case 3:return t.abrupt("return",e.map((function(e){return e.value})));case 4:case"end":return t.stop()}}),n,this)})))}},{key:"remove",value:function(e){return b(this,void 0,void 0,t().mark((function n(){var r,a,s,i=this;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return r=this._getRawKey(e,".0"),t.next=3,this._getRaw(r);case 3:if(!(a=t.sent)){t.next=9;break}return s=a.metadata,t.next=8,this._removeRaw(this._generateShardPostfixArray(null==s?void 0:s.shards).map((function(t){return i._getRawKey(e,".".concat(t))})));case 8:return t.abrupt("return",!0);case 9:return t.abrupt("return",!1);case 10:case"end":return t.stop()}}),n,this)})))}},{key:"removeMany",value:function(e){return b(this,void 0,void 0,t().mark((function n(){var r,a,s,i,o=this;return t().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:r=[],a=y(e),n.prev=2,i=t().mark((function e(){var n,a,i,u;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n=s.value,a=o._getRawKey(n,".0"),e.next=4,o._getRaw(a);case 4:(i=e.sent)&&(u=i.metadata,r.push.apply(r,_(o._generateShardPostfixArray(null==u?void 0:u.shards).map((function(e){return o._getRawKey(n,".".concat(e))})))));case 6:case"end":return e.stop()}}),e)})),a.s();case 5:if((s=a.n()).done){n.next=9;break}return n.delegateYield(i(),"t0",7);case 7:n.next=5;break;case 9:n.next=14;break;case 11:n.prev=11,n.t1=n.catch(2),a.e(n.t1);case 14:return n.prev=14,a.f(),n.finish(14);case 17:if(!(r.length>0)){n.next=20;break}return n.next=20,this._removeRaw(r);case 20:return n.abrupt("return",e);case 21:case"end":return n.stop()}}),n,this,[[2,11,14,17]])})))}}]),e}(),cl={},ll=function(e){i(a,e);var n=f(a);function a(){var e,t,s=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};r(this,a),e=n.call(this,Object.assign(Object.assign({},s),{itemSizeLimit:null!==(t=s.itemSizeLimit)&&void 0!==t?t:4194304}));var i=s.delay,o=void 0===i?1:i;return e.delay=o,e.observer={},e}return s(a,[{key:"rawData",get:function(){return cl[this.dbname]},set:function(e){cl[this.dbname]=e}},{key:"_getAllRawKeys",value:function(){return b(this,void 0,void 0,t().mark((function e(){return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!cl[this.dbname]){e.next=4;break}return e.abrupt("return",Object.keys(cl[this.dbname]));case 4:throw Ic.storeNotAvailable;case 5:case"end":return e.stop()}}),e,this)})))}},{key:"_getRaw",value:function(e){return b(this,void 0,void 0,t().mark((function n(){return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(!cl[this.dbname]){t.next=6;break}return t.next=3,Uc(this.delay);case 3:return t.abrupt("return",cl[this.dbname][e]?Object.assign({key:e},cl[this.dbname][e]):null);case 6:throw Ic.storeNotAvailable;case 7:case"end":return t.stop()}}),n,this)})))}},{key:"_setRaw",value:function(e){return b(this,void 0,void 0,t().mark((function n(){var r,a,s,i,o,u;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(!cl[this.dbname]){t.next=7;break}return t.next=3,Uc(this.delay);case 3:r=y(e);try{for(r.s();!(a=r.n()).done;)s=a.value,i=s.key,o=s.data,u=s.metadata,cl[this.dbname][i]=Object.freeze({data:o,metadata:u})}catch(e){r.e(e)}finally{r.f()}t.next=8;break;case 7:throw Ic.storeNotAvailable;case 8:case"end":return t.stop()}}),n,this)})))}},{key:"_removeRaw",value:function(e){return b(this,void 0,void 0,t().mark((function n(){var r,a,s;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(!cl[this.dbname]){t.next=7;break}return t.next=3,Uc(this.delay);case 3:r=y(e);try{for(r.s();!(a=r.n()).done;)s=a.value,cl[this.dbname][s]&&delete cl[this.dbname][s]}catch(e){r.e(e)}finally{r.f()}t.next=8;break;case 7:throw Ic.storeNotAvailable;case 8:case"end":return t.stop()}}),n,this)})))}},{key:"observe",value:function(e,t,n){var r=this;this.observer[e]||(this.observer[e]={}),t.forEach((function(t){return r.observer[e][t]=n}))}},{key:"checkAvailability",value:function(){return b(this,void 0,void 0,t().mark((function e(){return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:case"end":return e.stop()}}),e)})))}},{key:"init",value:function(e){return b(this,void 0,void 0,t().mark((function n(){return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:this.dbname=e,cl[this.dbname]={};case 2:case"end":return t.stop()}}),n,this)})))}},{key:"set",value:function(e){var n=this,r=Object.create(null,{set:{get:function(){return p(o(a.prototype),"set",n)}}});return b(this,void 0,void 0,t().mark((function n(){var a,s;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(!(a=this.observer[e.key])||"function"!=typeof a.set){t.next=5;break}if(!(s=a.set())){t.next=5;break}throw s;case 5:return t.abrupt("return",r.set.call(this,e));case 6:case"end":return t.stop()}}),n,this)})))}},{key:"setMany",value:function(e){var n=this,r=Object.create(null,{setMany:{get:function(){return p(o(a.prototype),"setMany",n)}}});return b(this,void 0,void 0,t().mark((function n(){var a,s,i,o,u;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:a=y(e),t.prev=1,a.s();case 3:if((s=a.n()).done){t.next=12;break}if(i=s.value,!(o=this.observer[i.key])||"function"!=typeof o.set){t.next=10;break}if(!(u=o.set())){t.next=10;break}throw u;case 10:t.next=3;break;case 12:t.next=17;break;case 14:t.prev=14,t.t0=t.catch(1),a.e(t.t0);case 17:return t.prev=17,a.f(),t.finish(17);case 20:return t.abrupt("return",r.setMany.call(this,e));case 21:case"end":return t.stop()}}),n,this,[[1,14,17,20]])})))}},{key:"clear",value:function(){return b(this,void 0,void 0,t().mark((function e(){return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,Uc(this.delay);case 2:cl[this.dbname]={};case 3:case"end":return e.stop()}}),e,this)})))}}]),a}(ul),hl="NestDBStore";!function(e){e[e.UNINITIALIZED=0]="UNINITIALIZED",e[e.OPENING=1]="OPENING",e[e.OPEN=2]="OPEN",e[e.CLOSED=3]="CLOSED"}(Xc||(Xc={}));var dl,fl=function(e){i(a,e);var n=f(a);function a(){var e,t,s=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return r(this,a),(e=n.call(this,Object.assign(Object.assign({},s),{itemSizeLimit:null!==(t=s.itemSizeLimit)&&void 0!==t?t:104857600})))._storeName=hl,e._state=Xc.UNINITIALIZED,e._openJobQueue=[],e._window="undefined"!=typeof window?window:void 0,e._indexedDb=e._window?e._window.indexedDB||e._window.mozIndexedDB||e._window.webkitIndexedDB||e._window.msIndexedDB:void 0,e}return s(a,[{key:"state",get:function(){return this._state}},{key:"_openDatabase",value:function(e){var t=this;return new Promise((function(n,r){if(t._indexedDb){t._state=Xc.OPENING;var a=t._indexedDb.open(e);a.addEventListener("upgradeneeded",(function(e){e.target.result.createObjectStore(hl,{keyPath:"key"})})),a.addEventListener("success",(function(r){t._state=Xc.OPEN,t._database=r.target.result,t._openJobQueue.forEach((function(e){return e()})),t._openJobQueue=[],t._database.onclose=function(){t._database=void 0,t._state=Xc.OPENING,setTimeout((function(){t._openDatabase(e)}),5)},n(t._database)})),a.addEventListener("error",(function(e){t._state=Xc.UNINITIALIZED,r(e.target.error)}))}else r(Ic.storeNotAvailable)}))}},{key:"_getObjectStore",value:function(e){return b(this,void 0,void 0,t().mark((function n(){var r=this;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(!this._database){t.next=4;break}return t.abrupt("return",this._database.transaction(this._storeName,e).objectStore(this._storeName));case 4:t.t0=this._state,t.next=t.t0===Xc.UNINITIALIZED||t.t0===Xc.OPEN?7:t.t0===Xc.OPENING||t.t0===Xc.CLOSED?8:9;break;case 7:throw Ic.storeNotInitialized;case 8:return t.abrupt("return",new Promise((function(t){r._openJobQueue.push((function(){return t(r._getObjectStore(e))}))})));case 9:return t.next=11,this._getObjectStore(e);case 11:return t.abrupt("return",t.sent);case 12:case"end":return t.stop()}}),n,this)})))}},{key:"_getAllRawKeys",value:function(){return b(this,void 0,void 0,t().mark((function e(){var n;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this._getObjectStore("readonly");case 2:return n=e.sent,e.next=5,new Promise((function(e,t){var r=n.getAllKeys();r.addEventListener("success",(function(t){e(t.target.result)})),r.addEventListener("error",(function(e){return t(e.target.error)}))}));case 5:return e.abrupt("return",e.sent);case 6:case"end":return e.stop()}}),e,this)})))}},{key:"_getRaw",value:function(e){return b(this,void 0,void 0,t().mark((function n(){var r;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,this._getObjectStore("readonly");case 2:return r=t.sent,t.next=5,new Promise((function(t,n){var a=r.get(e);a.addEventListener("success",(function(e){var n;t(null===(n=null==e?void 0:e.target)||void 0===n?void 0:n.result)})),a.addEventListener("error",(function(e){return n(e.target.error)}))}));case 5:return t.abrupt("return",t.sent);case 6:case"end":return t.stop()}}),n,this)})))}},{key:"_setRaw",value:function(e){return b(this,void 0,void 0,t().mark((function n(){var r;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,this._getObjectStore("readwrite");case 2:return r=t.sent,t.next=5,Promise.all(e.map((function(e){return new Promise((function(t,n){var a=r.put(e);a.addEventListener("success",(function(e){t(e.target.result)})),a.addEventListener("error",(function(){n("Failed to write.")}))}))})));case 5:case"end":return t.stop()}}),n,this)})))}},{key:"_removeRaw",value:function(e){return b(this,void 0,void 0,t().mark((function n(){var r;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,this._getObjectStore("readwrite");case 2:return r=t.sent,t.next=5,Promise.all(e.map((function(e){return new Promise((function(t,n){var a=r.delete(e);a.addEventListener("success",(function(){return t(e)})),a.addEventListener("error",(function(e){return n(e.target.error)}))}))})));case 5:case"end":return t.stop()}}),n,this)})))}},{key:"_triggerDatabaseClose",value:function(){this._database&&this._database.onclose&&this._database.onclose(new Event("dummy"))}},{key:"checkAvailability",value:function(){return b(this,void 0,void 0,t().mark((function e(){var n,r=this;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!((null==(n="undefined"!=typeof window?window:null)?void 0:n.indexedDB)||(null==n?void 0:n.mozIndexedDB)||(null==n?void 0:n.webkitIndexedDB)||(null==n?void 0:n.msIndexedDB))){e.next=16;break}if(this._indexedDb=n.indexedDB||n.mozIndexedDB||n.webkitIndexedDB||n.msIndexedDB,!this._window||!qo()){e.next=13;break}if(!(qo()&&navigator.userAgent&&navigator.userAgent.includes("Edge/"))){e.next=9;break}if(this._window.indexedDB||!n.PointerEvent&&!n.MSPointerEvent){e.next=7;break}throw Ic.storeNotAvailableInPrivateBrowsing;case 7:e.next=11;break;case 9:return e.next=11,new Promise((function(e,t){if(r._indexedDb)try{var n=r._indexedDb.open("_testMozilla");n.onerror=function(){return t(Ic.storeNotAvailableInPrivateBrowsing)},n.onsuccess=function(){return e()}}catch(e){t(Ic.storeNotAvailableInPrivateBrowsing)}else t(Ic.storeNotAvailable)}));case 11:e.next=14;break;case 13:case 16:throw Ic.storeNotAvailable;case 14:e.next=17;break;case 17:case"end":return e.stop()}}),e,this)})))}},{key:"init",value:function(e){return b(this,void 0,void 0,t().mark((function n(){return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return this.dbname=e,t.next=3,this.checkAvailability();case 3:return t.next=5,this._openDatabase(e);case 5:case"end":return t.stop()}}),n,this)})))}},{key:"clear",value:function(){return b(this,void 0,void 0,t().mark((function e(){var n;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this._getObjectStore("readwrite");case 2:return n=e.sent,e.next=5,new Promise((function(e,t){var r=n.clear();r.addEventListener("success",(function(){return e()})),r.addEventListener("error",(function(e){return t(e.target.error)}))}));case 5:return e.abrupt("return",e.sent);case 6:case"end":return e.stop()}}),e,this)})))}}]),a}(ul),pl=function(e){i(a,e);var n=f(a);function a(e){var t;r(this,a);var s=e.AsyncStorage,i=e.itemSizeLimit,o=void 0===i?6291456:i,u=function(e,t){var n={};for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&t.indexOf(r)<0&&(n[r]=e[r]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var a=0;for(r=Object.getOwnPropertySymbols(e);a0&&(s.mutedUsers=o.map((function(t){return new wl(e,t)}))),s}return s(n)}(Ue),Dl=function(e){i(a,e);var n=f(a);function a(e,t,s,i){return r(this,a),n.call(this,e,t,s,i)}return s(a,[{key:"next",value:function(){return b(this,void 0,void 0,t().mark((function e(){var n,r,a,s,i,o,u;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!this._validate()){e.next=20;break}if(this._isLoading){e.next=17;break}if(!this._hasNext){e.next=14;break}return this._isLoading=!0,n=fs.of(this._iid),r=n.requestQueue,a=new Rl(Object.assign(Object.assign({},this),{token:this._token})),e.next=8,r.send(a);case 8:return s=e.sent,i=s.as(Ll),o=i.mutedUsers,u=i.token,this._token=u,this._hasNext=!!u,this._isLoading=!1,e.abrupt("return",o);case 14:return e.abrupt("return",[]);case 17:throw A.queryInProgress;case 18:e.next=21;break;case 20:throw A.invalidParameters;case 21:case"end":return e.stop()}}),e,this)})))}}]),a}(Li),Pl=function(e){i(n,e);var t=f(n);function n(e){var a;r(this,n);var s=e.channelUrl,i=e.channelType,o=e.limit,u=e.token;return(a=t.call(this)).method=le.GET,a.path="".concat(Te(i),"/").concat(encodeURIComponent(s),"/ban"),a.params=ue({limit:o,token:u}),a}return s(n)}(Oe),Fl=function(e){i(n,e);var t=f(n);function n(e,a){var s;r(this,n),(s=t.call(this,e,a)).bannedUsers=[];var i=a.next,o=a.banned_list;return s.token=i,o&&o.length>0&&(s.bannedUsers=o.map((function(t){return new wl(e,t.user)}))),s}return s(n)}(Ue),Gl=function(e){i(a,e);var n=f(a);function a(e,t,s,i){return r(this,a),n.call(this,e,t,s,i)}return s(a,[{key:"_validate",value:function(){return p(o(a.prototype),"_validate",this).call(this)}},{key:"next",value:function(){return b(this,void 0,void 0,t().mark((function e(){var n,r,a,s,i,o,u;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!this._validate()){e.next=20;break}if(this._isLoading){e.next=17;break}if(!this._hasNext){e.next=14;break}return this._isLoading=!0,n=fs.of(this._iid),r=n.requestQueue,a=new Pl(Object.assign(Object.assign({},this),{token:this._token})),e.next=8,r.send(a);case 8:return s=e.sent,i=s.as(Fl),o=i.bannedUsers,u=i.token,this._token=u,this._hasNext=!!u,this._isLoading=!1,e.abrupt("return",o);case 14:return e.abrupt("return",[]);case 17:throw A.queryInProgress;case 18:e.next=21;break;case 20:throw A.invalidParameters;case 21:case"end":return e.stop()}}),e,this)})))}}]),a}(Li);e.ReportCategory=void 0,(bl=e.ReportCategory||(e.ReportCategory={})).SPAM="spam",bl.HARASSING="harassing",bl.SUSPICIOUS="suspicious",bl.INAPPROPRIATE="inappropriate";var ql,Hl,jl=function(e){i(n,e);var t=f(n);function n(e){var a;r(this,n);var s=e.channelUrl,i=e.channelType,o=e.operatorUserIds;return(a=t.call(this)).method=le.POST,a.path="".concat(Te(i),"/").concat(encodeURIComponent(s),"/operators"),a.params={operator_ids:o},a}return s(n)}(Oe),zl=function(e){i(n,e);var t=f(n);function n(e){var a;r(this,n);var s=e.channelUrl,i=e.channelType,o=e.operatorUserIds;return(a=t.call(this)).method=le.DELETE,a.path="".concat(Te(i),"/").concat(encodeURIComponent(s),"/operators"),a.params={operator_ids:o},a}return s(n)}(Oe),Vl=function(e){i(n,e);var t=f(n);function n(e){var a;r(this,n);var s=e.channelUrl,i=e.channelType,o=e.userId;return(a=t.call(this)).method=le.GET,a.path="".concat(Te(i),"/").concat(encodeURIComponent(s),"/mute/").concat(o),a}return s(n)}(Oe),Bl=function(e){i(n,e);var t=f(n);function n(e,a){var s;r(this,n),(s=t.call(this,e,a)).isMuted=!1,s.startAt=0,s.endAt=0;var i=a.is_muted,o=a.start_at,u=a.end_at,c=a.remaining_duration,l=a.description;return s.isMuted=i,s.startAt=o,s.endAt=u,s.remainingDuration=c,s.description=l,s}return s(n)}(Ue),Ql=function(e){i(n,e);var t=f(n);function n(e){var a;r(this,n);var s=e.channelUrl,i=e.channelType,o=e.keys;return(a=t.call(this)).method=le.GET,a.path="".concat(Te(i),"/").concat(encodeURIComponent(s),"/metadata"),a.params={keys:o,include_ts:!0},a}return s(n)}(Oe),Kl=function(e){i(n,e);var t=f(n);function n(e,a){var s;r(this,n),s=t.call(this,e,a);var i=a.metadata,o=a.ts;return s.metadata=i,s.ts=o,s}return s(n)}(Ue),Wl=function(e){i(n,e);var t=f(n);function n(e){var a;r(this,n);var s=e.channelUrl,i=e.channelType,o=e.metadata;return(a=t.call(this)).method=le.POST,a.path="".concat(Te(i),"/").concat(encodeURIComponent(s),"/metadata"),a.params={metadata:o,include_ts:!0},a}return s(n)}(Oe),Yl=function(e){i(n,e);var t=f(n);function n(e,a){var s,i,o;return r(this,n),(s=t.call(this,e,a)).metaData=null!==(i=a.metadata)&&void 0!==i?i:{},s.ts=null!==(o=a.ts)&&void 0!==o?o:null,s}return s(n)}(Ue),Zl=function(e){i(n,e);var t=f(n);function n(e){var a;r(this,n);var s=e.channelUrl,i=e.channelType,o=e.metadata,u=e.upsert;return(a=t.call(this)).method=le.PUT,a.path="".concat(Te(i),"/").concat(encodeURIComponent(s),"/metadata"),a.params={metadata:o,include_ts:!0,upsert:null!=u&&u},a}return s(n)}(Oe),Jl=function(e){i(n,e);var t=f(n);function n(e,a){var s;r(this,n),s=t.call(this,e,a);var i=a.metadata,o=a.ts;return s.metadata=i,s.ts=o,s}return s(n)}(Ue),Xl=function(e){i(n,e);var t=f(n);function n(e,a,s){var i;return r(this,n),i=t.call(this,e,"SYEV",s),s.data&&(i.created=s.data.created,i.updated=s.data.updated,i.deleted=s.data.deleted),i}return s(n)}(qe),$l=function(e){i(n,e);var t=f(n);function n(e){var a;r(this,n);var s=e.channelUrl,i=e.channelType,o=e.key;return(a=t.call(this)).method=le.DELETE,a.path="".concat(Te(i),"/").concat(encodeURIComponent(s),"/metadata/").concat(o),a.params={include_ts:!0},a}return s(n)}(Oe),eh=function(e){i(n,e);var t=f(n);function n(e,a){var s;r(this,n),s=t.call(this,e,a);var i=a.ts;return s.ts=i,s}return s(n)}(Ue),th=function(e){i(n,e);var t=f(n);function n(e){var a;r(this,n);var s=e.channelUrl,i=e.channelType;return(a=t.call(this)).method=le.DELETE,a.path="".concat(Te(i),"/").concat(encodeURIComponent(s),"/metadata"),a.params={include_ts:!0},a}return s(n)}(Oe),nh=function(e){i(n,e);var t=f(n);function n(e,a){var s;r(this,n),s=t.call(this,e,a);var i=a.ts;return s.ts=i,s}return s(n)}(Ue),rh=function(e){i(n,e);var t=f(n);function n(e){var a;r(this,n);var s=e.channelUrl,i=e.channelType,o=e.keys;return(a=t.call(this)).method=le.GET,a.path="".concat(Te(i),"/").concat(encodeURIComponent(s),"/metacounter"),a.params={keys:o},a}return s(n)}(Oe),ah=function(e){i(n,e);var t=f(n);function n(e,a){var s;return r(this,n),(s=t.call(this,e,a)).metaCounter=a,s}return s(n)}(Ue),sh=function(e){i(n,e);var t=f(n);function n(e){var a;r(this,n);var s=e.channelUrl,i=e.channelType,o=e.metaCounter;return(a=t.call(this)).method=le.POST,a.path="".concat(Te(i),"/").concat(encodeURIComponent(s),"/metacounter"),a.params={metacounter:o},a}return s(n)}(Oe),ih=function(e){i(n,e);var t=f(n);function n(e,a){var s;return r(this,n),(s=t.call(this,e,a)).metaCounter=a,s}return s(n)}(Ue),oh=function(e){i(n,e);var t=f(n);function n(e){var a;r(this,n);var s=e.channelUrl,i=e.channelType,o=e.metaCounter,u=e.upsert,c=void 0!==u&&u,l=e.mode,h=void 0===l?"set":l;return(a=t.call(this)).method=le.PUT,a.path="".concat(Te(i),"/").concat(encodeURIComponent(s),"/metacounter"),a.params={metacounter:o,upsert:c,mode:h},a}return s(n)}(Oe),uh=function(e){i(n,e);var t=f(n);function n(e,a){var s;return r(this,n),(s=t.call(this,e,a)).metaCounter=a,s}return s(n)}(Ue),ch=function(e){i(n,e);var t=f(n);function n(e,a,s){var i;return r(this,n),i=t.call(this,e,"SYEV",s),s.data&&(i.created=s.data.created,i.updated=s.data.updated,i.deleted=s.data.deleted),i}return s(n)}(qe),lh=function(e){i(n,e);var t=f(n);function n(e){var a;r(this,n);var s=e.channelUrl,i=e.channelType,o=e.key;return(a=t.call(this)).method=le.DELETE,a.path="".concat(Te(i),"/").concat(encodeURIComponent(s),"/metacounter/").concat(o),a.params={},a}return s(n)}(Oe),hh=function(e){i(n,e);var t=f(n);function n(e){var a;r(this,n);var s=e.channelUrl,i=e.channelType;return(a=t.call(this)).method=le.DELETE,a.path="".concat(Te(i),"/").concat(encodeURIComponent(s),"/metacounter"),a.params={},a}return s(n)}(Oe),dh=function(e){i(n,e);var t=f(n);function n(e){var a;r(this,n);var s=e.channelUrl,i=e.channelType,o=e.userId,u=e.seconds,c=e.description;return(a=t.call(this)).method=le.POST,a.path="".concat(Te(i),"/").concat(encodeURIComponent(s),"/mute"),a.params={user_id:o,seconds:u,description:c},a}return s(n)}(Oe),fh=function(e){i(n,e);var t=f(n);function n(e,a,s){var i;return r(this,n),(i=t.call(this,e,"SYEV",s)).user=new wl(e,s.data),i}return s(n)}(qe),ph=function(e){i(n,e);var t=f(n);function n(e){var a;r(this,n);var s=e.channelUrl,i=e.channelType,o=e.userId;return(a=t.call(this)).method=le.DELETE,a.path="".concat(Te(i),"/").concat(encodeURIComponent(s),"/mute/").concat(encodeURIComponent(o)),a}return s(n)}(Oe),vh=function(e){i(n,e);var t=f(n);function n(e,a,s){var i;return r(this,n),(i=t.call(this,e,"SYEV",s)).user=new wl(e,s.data),i}return s(n)}(qe),_h=function(e){i(n,e);var t=f(n);function n(e){var a;r(this,n);var s=e.channelUrl,i=e.channelType,o=e.userId,u=e.seconds,c=e.description;return(a=t.call(this)).method=le.POST,a.path="".concat(Te(i),"/").concat(encodeURIComponent(s),"/ban"),a.params=ue({user_id:o,seconds:u,description:c}),a}return s(n)}(Oe),mh=function(e){i(n,e);var t=f(n);function n(e,a,s){var i;return r(this,n),(i=t.call(this,e,"SYEV",s)).user=new wl(e,s.data),s.data.member_count&&(i.memberCount=s.data.member_count),s.data.joined_member_count&&(i.joinedMemberCount=s.data.joined_member_count),i}return s(n)}(qe),gh=function(e){i(n,e);var t=f(n);function n(e){var a;r(this,n);var s=e.channelUrl,i=e.channelType,o=e.userId;return(a=t.call(this)).method=le.DELETE,a.path="".concat(Te(i),"/").concat(encodeURIComponent(s),"/ban/").concat(encodeURIComponent(o)),a}return s(n)}(Oe),yh=function(e){i(n,e);var t=f(n);function n(e,a,s){var i;return r(this,n),(i=t.call(this,e,"SYEV",s)).user=new wl(e,s.data),i}return s(n)}(qe),kh=function(e){i(n,e);var t=f(n);function n(e){var a;r(this,n);var s=e.channelUrl,i=e.channelType,o=e.freezing;return(a=t.call(this)).method=le.PUT,a.path="".concat(Te(i),"/").concat(encodeURIComponent(s),"/freeze"),a.params={freeze:o},a}return s(n)}(Oe),bh=function(e){i(n,e);var t=f(n);function n(e,a,s){var i;return r(this,n),(i=t.call(this,e,"SYEV",s)).freeze=s.data.freeze,i}return s(n)}(qe),Eh=function(e){i(n,e);var t=f(n);function n(e){var a;r(this,n);var s=e.channelUrl,i=e.channelType,o=e.category,u=e.userId,c=e.description;return(a=t.call(this)).method=le.POST,a.path="".concat(Se(i),"/").concat(encodeURIComponent(s)),a.params={report_category:o,reporting_user_id:u,report_description:c},a}return s(n)}(Oe),wh=function(t){i(a,t);var n=f(a);function a(t){var s;r(this,a);var i=t.channelUrl,o=t.channelType,u=t.category,c=t.userId,l=t.offendingUserId,h=t.description;return(s=n.call(this)).method=le.POST,s.path="".concat(ye,"/users/").concat(l),s.params={channel_url:i,channel_type:o===e.ChannelType.OPEN?"open_channels":"group_channels",report_category:u,reporting_user_id:c,report_description:h},s}return s(a)}(Oe),Ch=function(e){i(n,e);var t=f(n);function n(e){var a;r(this,n);var s=e.channelUrl,i=e.channelType,o=e.category,u=e.userId,c=e.offendingUserId,l=e.messageId,h=e.description;return(a=t.call(this)).method=le.POST,a.path="".concat(Se(i),"/").concat(encodeURIComponent(s),"/messages/").concat(l),a.params={report_category:o,reporting_user_id:u,report_description:h,offending_user_id:c},a}return s(n)}(Oe),xh=function(t){i(a,t);var n=f(a);function a(t){r(this,a);var s=[];return t.mentionType===e.MentionType.USERS&&(t.mentionedUserIds?s=t.mentionedUserIds:t.mentionedUsers&&(s=t.mentionedUsers.map((function(e){return e.userId})))),n.call(this,{code:"MESG",ackRequired:!0,payload:ue(ce({channel_url:t.channelUrl,message:t.message,data:t.data,custom_type:t.customType,metaarray:t.metaArrays,mention_type:t.mentionType,mentioned_user_ids:s,mentioned_message_template:t.mentionedMessageTemplate,target_langs:t.translationTargetLanguages,push_option:t.pushNotificationDeliveryOption&&t.pushNotificationDeliveryOption!==e.PushNotificationDeliveryOption.DEFAULT?t.pushNotificationDeliveryOption:void 0,apple_critical_alert_options:t.appleCriticalAlertOptions,silent:t.silent,reply_to_channel:t.isReplyToChannel,parent_message_id:t.parentMessageId?t.parentMessageId:null,req_id:t.reqId,poll_id:t.pollId,pin_message:t.isPinnedMessage}))})}return s(a)}(oa),Th=function(e){i(n,e);var t=f(n);function n(e,a,s){var i,o,u,c,l;r(this,n),(i=t.call(this,e,"MESG",s)).message=new Hs(e,s);var h=fs.of(e).sdkState;return i.isMentioned=Ie(i.message.mentionType,null!==(c=null!==(o=i.message.mentionedUserIds)&&void 0!==o?o:null===(u=i.message.mentionedUsers)||void 0===u?void 0:u.map((function(e){return e.userId})))&&void 0!==c?c:[],h.userId),i.forceUpdateLastMessage=null!==(l=s.force_update_last_message)&&void 0!==l&&l,i}return s(n)}(qe),Sh=function(t){i(a,t);var n=f(a);function a(t){r(this,a);var s=null;return t.mentionType===e.MentionType.USERS&&(t.mentionedUserIds?s=t.mentionedUserIds:t.mentionedUsers&&(s=t.mentionedUsers.map((function(e){return e.userId})))),n.call(this,{code:"MEDI",ackRequired:!0,payload:ue(ce({channel_url:t.channelUrl,msg_id:t.messageId,message:t.message,data:t.data,custom_type:t.customType,metaarray:t.metaArrayParams,mention_type:t.mentionType,mentioned_user_ids:s,mentioned_message_template:t.mentionedMessageTemplate,apple_critical_alert_options:t.appleCriticalAlertOptions?xs.payloadify(t.appleCriticalAlertOptions):null,poll_id:t.pollId}))})}return s(a)}(oa),Ih=function(e){i(n,e);var t=f(n);function n(e,a,s){var i,o,u,c,l,h;r(this,n),(i=t.call(this,e,"MEDI",s)).message=new Hs(e,s);var d=fs.of(e).sdkState;return i.mentionCountChange=Ne({mentionType:null===(o=s.old_values)||void 0===o?void 0:o.mention_type,mentionedUserIds:null!==(c=null===(u=s.old_values)||void 0===u?void 0:u.mentioned_user_ids)&&void 0!==c?c:[]},ce({mentionType:i.message.mentionType,mentionedUserIds:null!==(l=i.message.mentionedUserIds)&&void 0!==l?l:null===(h=i.message.mentionedUsers)||void 0===h?void 0:h.map((function(e){return e.userId}))}),d.userId),i}return s(n)}(qe),Nh=function(t){i(a,t);var n=f(a);function a(t){r(this,a);var s=null;return t.mentionType===e.MentionType.USERS&&(t.mentionedUserIds?s=t.mentionedUserIds:t.mentionedUsers&&(s=t.mentionedUsers.map((function(e){return e.userId})))),n.call(this,{code:"FEDI",ackRequired:!0,payload:ue(ce({channel_url:t.channelUrl,msg_id:t.messageId,data:t.data,custom_type:t.customType,metaarray:t.metaArrayParams,mention_type:t.mentionType,mentioned_user_ids:s,apple_critical_alert_options:t.appleCriticalAlertOptions}))})}return s(a)}(oa),Mh=function(e){i(n,e);var t=f(n);function n(e,a,s){var i,o,u,c,l,h;r(this,n),(i=t.call(this,e,"FEDI",s)).message=new Qs(e,s);var d=fs.of(e).sdkState;return i.mentionCountChange=Ne({mentionType:null===(o=s.old_values)||void 0===o?void 0:o.mention_type,mentionedUserIds:null!==(c=null===(u=s.old_values)||void 0===u?void 0:u.mentioned_user_ids)&&void 0!==c?c:[]},ce({mentionType:i.message.mentionType,mentionedUserIds:null!==(l=i.message.mentionedUserIds)&&void 0!==l?l:null===(h=i.message.mentionedUsers)||void 0===h?void 0:h.map((function(e){return e.userId}))}),d.userId),i}return s(n)}(qe),Ah=function(e){i(n,e);var t=f(n);function n(e){var a;return r(this,n),(a=t.call(this)).method=le.DELETE,a.path="".concat(Te(e.channelType),"/").concat(e.channelUrl,"/messages/").concat(e.messageId),a}return s(n)}(Oe),Oh=function(e){i(n,e);var t=f(n);function n(e,a,s){var i;return r(this,n),(i=t.call(this,e,"DELM",s)).channelUrl=s.channel_url,i.channelType=s.channel_type,i.messageId=Number(s.msg_id),i}return s(n)}(qe),Uh=function(e){i(n,e);var t=f(n);function n(e){var a,s=e.channelType,i=e.channelUrl,o=e.messageId,u=e.reactionKey;return r(this,n),(a=t.call(this)).method=le.POST,a.path="".concat(Te(s),"/").concat(encodeURIComponent(i),"/messages/").concat(o,"/reactions"),a.params={reaction:u},a}return s(n)}(Oe),Rh=function(e){i(n,e);var t=f(n);function n(e,a){var s;return r(this,n),(s=t.call(this,e,a)).reactionEvent=new ks(a),s}return s(n)}(Ue),Lh=function(e){i(n,e);var t=f(n);function n(e){var a,s=e.channelType,i=e.channelUrl,o=e.messageId,u=e.reactionKey;return r(this,n),(a=t.call(this)).method=le.DELETE,a.path="".concat(Te(s),"/").concat(encodeURIComponent(i),"/messages/").concat(o,"/reactions"),a.params={reaction:u},a}return s(n)}(Oe),Dh=function(e){i(n,e);var t=f(n);function n(e,a){var s;return r(this,n),(s=t.call(this,e,a)).reactionEvent=new ks(Object.assign({},a)),s}return s(n)}(Ue),Ph=function(e){i(n,e);var t=f(n);function n(e){var a,s=e.channelType,i=e.channelUrl,o=e.messageId,u=e.translationTargetLanguages;return r(this,n),(a=t.call(this)).method=le.POST,a.path="".concat(Te(s),"/").concat(encodeURIComponent(i),"/messages/").concat(encodeURIComponent(o),"/translation"),a.params={target_langs:u},a}return s(n)}(Oe),Fh=function(e){i(n,e);var t=f(n);function n(e,a){var s;return r(this,n),(s=t.call(this,e,a)).message=new Hs(e,a),s}return s(n)}(Ue),Gh=function(t){i(a,t);var n=f(a);function a(t){var s,i;r(this,a),s=n.call(this);var o=[];t.mentionType===e.MentionType.USERS&&(t.mentionedUserIds?o=t.mentionedUserIds:t.mentionedUsers&&(o=t.mentionedUsers.map((function(e){return e.userId}))));var u=t.channelType,c=t.channelUrl;return s.method=le.POST,s.path="".concat(Te(u),"/").concat(encodeURIComponent(c),"/scheduled_messages"),s.params=ue(ce({req_id:t.reqId,scheduled_at:t.scheduledAt,message_type:Y.USER,message:t.message,custom_type:t.customType,data:t.data,mention_type:t.mentionType,mentioned_user_ids:o,sorted_metaarray:null===(i=t.metaArrays)||void 0===i?void 0:i.map((function(e){return Es.payloadify(e)})),apple_critical_alert_options:t.appleCriticalAlertOptions?xs.payloadify(t.appleCriticalAlertOptions):null,target_langs:t.translationTargetLanguages,push_option:t.pushNotificationDeliveryOption})),s}return s(a)}(Oe),qh=function(e){i(n,e);var t=f(n);function n(e,a){var s;return r(this,n),(s=t.call(this,e,a)).message=new Hs(e,a),s}return s(n)}(Ue),Hh=function(t){i(a,t);var n=f(a);function a(t){var s,i;r(this,a),s=n.call(this);var o=[];t.mentionType===e.MentionType.USERS&&(t.mentionedUserIds?o=t.mentionedUserIds:t.mentionedUsers&&(o=t.mentionedUsers.map((function(e){return e.userId}))));var u=t.channelType,c=t.channelUrl;return s.method=le.POST,s.path="".concat(Te(u),"/").concat(encodeURIComponent(c),"/scheduled_messages"),s.params=ce({req_id:t.reqId,scheduled_at:t.scheduledAt,message_type:Y.FILE,url:t.fileUrl,file_name:t.fileName,file_size:t.fileSize,file_type:t.mimeType,thumbnails:t.thumbnailSizes?t.thumbnailSizes.map((function(e){return As.payloadify(e)})):[],custom_type:t.customType,data:t.data,require_auth:t.requireAuth,mention_type:t.mentionType,mentioned_user_ids:o,sorted_metaarray:null===(i=t.metaArrays)||void 0===i?void 0:i.map((function(e){return Es.payloadify(e)})),apple_critical_alert_options:t.appleCriticalAlertOptions?xs.payloadify(t.appleCriticalAlertOptions):null,push_option:t.pushNotificationDeliveryOption}),s}return s(a)}(Oe),jh=function(e){i(n,e);var t=f(n);function n(e,a){var s;return r(this,n),(s=t.call(this,e,a)).message=new Qs(e,a),s}return s(n)}(Ue),zh=function(e){return L("string",e.title,!0)&&Fs(e.data)&&L("boolean",e.allowUserSuggestion,!0)&&L("boolean",e.allowMultipleVotes,!0)&&L("number",e.closeAt,!0)},Vh=function(e){i(n,e);var t=f(n);function n(e){var a,s=e.pollId,i=e.title,o=e.data,u=e.allowUserSuggestion,c=e.allowMultipleVotes,l=e.closeAt;return r(this,n),(a=t.call(this)).method=le.PUT,a.path="".concat(Ee,"/").concat(encodeURIComponent(s)),a.params={title:i,data:o,allow_user_suggestion:u,allow_multiple_votes:c,close_at:l},a}return s(n)}(Oe),Bh=function(e){i(n,e);var t=f(n);function n(e,a){var s;return r(this,n),(s=t.call(this,e,a)).poll=new qs(e,a),s}return s(n)}(Ue),Qh=function(e){i(n,e);var t=f(n);function n(e){var a,s=e.pollId;return r(this,n),(a=t.call(this)).method=le.DELETE,a.path="".concat(Ee,"/").concat(encodeURIComponent(s)),a}return s(n)}(Oe),Kh=function(e){i(n,e);var t=f(n);function n(e){var a,s=e.pollId;return r(this,n),(a=t.call(this)).method=le.PUT,a.path="".concat(Ee,"/").concat(encodeURIComponent(s),"/close"),a}return s(n)}(Oe),Wh=function(e){i(n,e);var t=f(n);function n(e,a){var s;return r(this,n),(s=t.call(this,e,a)).poll=new qs(e,a),s}return s(n)}(Ue),Yh=function(e){i(n,e);var t=f(n);function n(e){var a,s=e.channelUrl,i=e.channelType,o=e.pollId,u=e.optionText;return r(this,n),(a=t.call(this)).method=le.POST,a.path="".concat(Ee,"/").concat(encodeURIComponent(o),"/options"),a.params={channel_url:s,channel_type:i,text:u},a}return s(n)}(Oe),Zh=function(e){i(n,e);var t=f(n);function n(e,a){var s;return r(this,n),(s=t.call(this,e,a)).poll=new qs(e,a),s}return s(n)}(Ue),Jh=function(e){i(n,e);var t=f(n);function n(e){var a,s=e.pollId,i=e.pollOptionId,o=e.optionText;return r(this,n),(a=t.call(this)).method=le.PUT,a.path="".concat(Ee,"/").concat(encodeURIComponent(s),"/options/").concat(encodeURIComponent(i)),a.params={text:o},a}return s(n)}(Oe),Xh=function(e){i(n,e);var t=f(n);function n(e,a){var s;return r(this,n),(s=t.call(this,e,a)).poll=new qs(e,a),s}return s(n)}(Ue),$h=function(e){i(n,e);var t=f(n);function n(e){var a,s=e.pollId,i=e.pollOptionId;return r(this,n),(a=t.call(this)).method=le.DELETE,a.path="".concat(Ee,"/").concat(encodeURIComponent(s),"/options/").concat(encodeURIComponent(i)),a}return s(n)}(Oe),ed=function(t){i(a,t);var n=f(a);function a(t){var s=t.reqId,i=t.channelType,o=t.channelUrl,u=t.pollId,c=t.pollOptionIds;return r(this,a),n.call(this,{code:"VOTE",ackRequired:!0,payload:ue({req_id:s,channel_type:i===e.ChannelType.OPEN?"open_channels":"group_channels",channel_url:o,poll_id:u,option_ids:c})})}return s(a)}(oa),td=function(e){i(n,e);var t=f(n);function n(e,a,s){var i;return r(this,n),(i=t.call(this,e,"VOTE",s)).event=new ao(s),i.channelUrl=s.channel_url,i.channelType=s.channel_type,i}return s(n)}(qe),nd=function(n){i(u,n);var a=f(u);function u(t,n){var s,i,o,c,l;return r(this,u),(s=a.call(this,t)).channelType=e.ChannelType.BASE,s.name="",s.coverUrl="",s.customType="",s.data="",s.isFrozen=!1,s.isEphemeral=!1,s.creator=null,s.createdAt=0,s._messageCollectionLastAccessedAt=0,s.url=n.channel_url,s.name=null!==(i=n.name)&&void 0!==i?i:"",s.coverUrl=null!==(o=n.cover_url)&&void 0!==o?o:"",s.customType=null!==(c=n.custom_type)&&void 0!==c?c:"",s.data=null!==(l=n.data)&&void 0!==l?l:"",s.isFrozen=!!L("boolean",n.freeze)&&n.freeze,s.isEphemeral=!!L("boolean",n.is_ephemeral)&&n.is_ephemeral,s.creator=n.created_by?new Xa(s._iid,n.created_by):null,s.createdAt=1e3*n.created_at,n.metadata&&Object.keys(n.metadata).length>0&&n.ts&&(s._cachedMetaData=new Map,Object.keys(n.metadata).forEach((function(e){s._cachedMetaData.set(e,{value:n.metadata[e],isRemoved:!1,updatedAt:n.ts})}))),s}return s(u,[{key:"isGroupChannel",value:function(){return this.channelType===e.ChannelType.GROUP}},{key:"isOpenChannel",value:function(){return this.channelType===e.ChannelType.OPEN}},{key:"cachedMetaData",get:function(){var e={};return this._cachedMetaData?(this._cachedMetaData.forEach((function(t,n){t.isRemoved||(e[n]=t.value)})),e):e}},{key:"messageCollectionLastAccessedAt",get:function(){return this._messageCollectionLastAccessedAt}},{key:"_updateMessageCollectionLastAccessedAt",value:function(){this._messageCollectionLastAccessedAt=Date.now()}},{key:"_update",value:function(e){var t=ue(e);Object.assign(this,t)}},{key:"_upsertCachedMetaData",value:function(e,t){var n=this;Object.keys(e).forEach((function(r){n._cachedMetaData||(n._cachedMetaData=new Map);var a=n._cachedMetaData.get(r);(!a||a.updatedAt<=t)&&n._cachedMetaData.set(r,{value:e[r],isRemoved:!1,updatedAt:t})}))}},{key:"_removeFromCachedMetaData",value:function(e,t){var n=this;this._cachedMetaData&&e.forEach((function(e){var r=n._cachedMetaData.get(e);r&&r.updatedAt0&&void 0!==arguments[0]?arguments[0]:{};return new Ul(this._iid,this.url,this.channelType,e)}},{key:"createMutedUserListQuery",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return new Dl(this._iid,this.url,this.channelType,e)}},{key:"createBannedUserListQuery",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return new Gl(this._iid,this.url,this.channelType,e)}},{key:"createPreviousMessageListQuery",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return new Di(this._iid,this.url,this.channelType,e)}},{key:"addOperators",value:function(e){return b(this,void 0,void 0,t().mark((function n(){var r,a,s;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return Za(F("string",e)).throw(A.invalidParameters),r=fs.of(this._iid),a=r.requestQueue,s=new jl({channelUrl:this.url,channelType:this.channelType,operatorUserIds:e}),t.next=5,a.send(s);case 5:case"end":return t.stop()}}),n,this)})))}},{key:"removeOperators",value:function(e){return b(this,void 0,void 0,t().mark((function n(){var r,a,s;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return Za(F("string",e)).throw(A.invalidParameters),r=fs.of(this._iid),a=r.requestQueue,s=new zl({channelUrl:this.url,channelType:this.channelType,operatorUserIds:e}),t.next=5,a.send(s);case 5:case"end":return t.stop()}}),n,this)})))}},{key:"getMyMutedInfo",value:function(){return b(this,void 0,void 0,t().mark((function e(){var n,r,a,s,i,o,u,c,l,h,d;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n=fs.of(this._iid),r=n.sdkState,a=n.requestQueue,s=new Vl({channelUrl:this.url,channelType:this.channelType,userId:r.userId}),e.next=4,a.send(s);case 4:return i=e.sent,o=i.as(Bl),u=o.isMuted,c=o.startAt,l=o.endAt,h=o.remainingDuration,d=o.description,e.abrupt("return",{isMuted:u,startAt:c,endAt:l,remainingDuration:h,description:d});case 7:case"end":return e.stop()}}),e,this)})))}},{key:"getMetaData",value:function(e){return b(this,void 0,void 0,t().mark((function n(){var r,a,s,i,o,u,c;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return Za(F("string",e)).throw(A.invalidParameters),r=fs.of(this._iid),a=r.requestQueue,s=new Ql({channelUrl:this.url,channelType:this.channelType,keys:e}),t.next=5,a.send(s);case 5:return i=t.sent,o=i.as(Kl),u=o.metadata,c=o.ts,this._upsertCachedMetaData(u,c),t.abrupt("return",u);case 9:case"end":return t.stop()}}),n,this)})))}},{key:"getAllMetaData",value:function(){return b(this,void 0,void 0,t().mark((function e(){var n,r,a,s,i,o,u;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n=fs.of(this._iid),r=n.requestQueue,a=new Ql({channelUrl:this.url,channelType:this.channelType,keys:[]}),e.next=4,r.send(a);case 4:return s=e.sent,i=s.as(Kl),o=i.metadata,u=i.ts,this._upsertCachedMetaData(o,u),e.abrupt("return",o);case 8:case"end":return e.stop()}}),e,this)})))}},{key:"createMetaData",value:function(e){return b(this,void 0,void 0,t().mark((function n(){var r,a,s,i,o,u;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return r=fs.of(this._iid),a=r.requestQueue,s=new Wl({channelUrl:this.url,channelType:this.channelType,metadata:e}),t.next=4,a.send(s);case 4:return i=t.sent,o=i.as(Yl),u=o.metaData,this._upsertCachedMetaData(u,0),t.abrupt("return",u);case 8:case"end":return t.stop()}}),n,this)})))}},{key:"updateMetaData",value:function(e){var n=arguments.length>1&&void 0!==arguments[1]&&arguments[1];return b(this,void 0,void 0,t().mark((function r(){var a,s,i,o,u,c,l;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return a=fs.of(this._iid),s=a.requestQueue,i=new Zl({channelUrl:this.url,channelType:this.channelType,metadata:e,upsert:n}),t.next=4,s.send(i);case 4:return o=t.sent,u=o.as(Jl),c=u.metadata,l=u.ts,this._upsertCachedMetaData(c,l),t.abrupt("return",c);case 8:case"end":return t.stop()}}),r,this)})))}},{key:"deleteMetaData",value:function(e){return b(this,void 0,void 0,t().mark((function n(){var r,a,s,i,o,u;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return Za(L("string",e)).throw(A.invalidParameters),r=fs.of(this._iid),a=r.requestQueue,s=new $l({channelUrl:this.url,channelType:this.channelType,key:e}),t.next=5,a.send(s);case 5:i=t.sent,o=i.as(eh),u=o.ts,this._removeFromCachedMetaData([e],u);case 8:case"end":return t.stop()}}),n,this)})))}},{key:"deleteAllMetaData",value:function(){return b(this,void 0,void 0,t().mark((function e(){var n,r,a,s,i,o;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n=fs.of(this._iid),r=n.requestQueue,a=new th({channelUrl:this.url,channelType:this.channelType}),e.next=4,r.send(a);case 4:s=e.sent,i=s.as(nh),o=i.ts,this._removeFromCachedMetaData(_(this._cachedMetaData.keys()),o);case 7:case"end":return e.stop()}}),e,this)})))}},{key:"getMetaCounters",value:function(e){return b(this,void 0,void 0,t().mark((function n(){var r,a,s,i,o,u;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return Za(F("string",e)).throw(A.invalidParameters),r=fs.of(this._iid),a=r.requestQueue,s=new rh({channelUrl:this.url,channelType:this.channelType,keys:e}),t.next=5,a.send(s);case 5:return i=t.sent,o=i.as(ah),u=o.metaCounter,t.abrupt("return",u);case 8:case"end":return t.stop()}}),n,this)})))}},{key:"getAllMetaCounters",value:function(){return b(this,void 0,void 0,t().mark((function e(){var n,r,a,s,i,o;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n=fs.of(this._iid),r=n.requestQueue,a=new rh({channelUrl:this.url,channelType:this.channelType,keys:[]}),e.next=4,r.send(a);case 4:return s=e.sent,i=s.as(ah),o=i.metaCounter,e.abrupt("return",o);case 7:case"end":return e.stop()}}),e,this)})))}},{key:"createMetaCounters",value:function(e){return b(this,void 0,void 0,t().mark((function n(){var r,a,s,i,o,u;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return r=fs.of(this._iid),a=r.requestQueue,s=new sh({channelUrl:this.url,channelType:this.channelType,metaCounter:e}),t.next=4,a.send(s);case 4:return i=t.sent,o=i.as(ih),u=o.metaCounter,t.abrupt("return",u);case 7:case"end":return t.stop()}}),n,this)})))}},{key:"updateMetaCounters",value:function(e){var n=arguments.length>1&&void 0!==arguments[1]&&arguments[1];return b(this,void 0,void 0,t().mark((function r(){var a,s,i,o,u,c;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return a=fs.of(this._iid),s=a.requestQueue,i=new oh({channelUrl:this.url,channelType:this.channelType,metaCounter:e,upsert:n}),t.next=4,s.send(i);case 4:return o=t.sent,u=o.as(uh),c=u.metaCounter,t.abrupt("return",c);case 7:case"end":return t.stop()}}),r,this)})))}},{key:"increaseMetaCounters",value:function(e){return b(this,void 0,void 0,t().mark((function n(){var r,a,s,i,o,u;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return r=fs.of(this._iid),a=r.requestQueue,s=new oh({channelUrl:this.url,channelType:this.channelType,metaCounter:e,upsert:!1,mode:"increase"}),t.next=4,a.send(s);case 4:return i=t.sent,o=i.as(uh),u=o.metaCounter,t.abrupt("return",u);case 7:case"end":return t.stop()}}),n,this)})))}},{key:"decreaseMetaCounters",value:function(e){return b(this,void 0,void 0,t().mark((function n(){var r,a,s,i,o,u;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return r=fs.of(this._iid),a=r.requestQueue,s=new oh({channelUrl:this.url,channelType:this.channelType,metaCounter:e,upsert:!1,mode:"decrease"}),t.next=4,a.send(s);case 4:return i=t.sent,o=i.as(uh),u=o.metaCounter,t.abrupt("return",u);case 7:case"end":return t.stop()}}),n,this)})))}},{key:"deleteMetaCounter",value:function(e){return b(this,void 0,void 0,t().mark((function n(){var r,a,s;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return Za(L("string",e)).throw(A.invalidParameters),r=fs.of(this._iid),a=r.requestQueue,s=new lh({channelUrl:this.url,channelType:this.channelType,key:e}),t.next=5,a.send(s);case 5:case"end":return t.stop()}}),n,this)})))}},{key:"deleteAllMetaCounters",value:function(){return b(this,void 0,void 0,t().mark((function e(){var n,r,a;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n=fs.of(this._iid),r=n.requestQueue,a=new hh({channelUrl:this.url,channelType:this.channelType}),e.next=4,r.send(a);case 4:case"end":return e.stop()}}),e,this)})))}},{key:"muteUser",value:function(e,n,r){return b(this,void 0,void 0,t().mark((function a(){return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.abrupt("return",this.muteUserWithUserId(e.userId,n,r));case 1:case"end":return t.stop()}}),a,this)})))}},{key:"muteUserWithUserId",value:function(e,n,r){return b(this,void 0,void 0,t().mark((function a(){var s,i,o;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return Za(L("string",e)&&L("number",n,!0)&&L("string",r,!0)).throw(A.invalidParameters),s=fs.of(this._iid),i=s.requestQueue,o=new dh({channelUrl:this.url,channelType:this.channelType,userId:e,seconds:n,description:r}),t.next=5,i.send(o);case 5:case"end":return t.stop()}}),a,this)})))}},{key:"unmuteUser",value:function(e){return b(this,void 0,void 0,t().mark((function n(){return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.abrupt("return",this.unmuteUserWithUserId(e.userId));case 1:case"end":return t.stop()}}),n,this)})))}},{key:"unmuteUserWithUserId",value:function(e){return b(this,void 0,void 0,t().mark((function n(){var r,a,s;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return Za(L("string",e)).throw(A.invalidParameters),r=fs.of(this._iid),a=r.requestQueue,s=new ph({channelUrl:this.url,channelType:this.channelType,userId:e}),t.next=5,a.send(s);case 5:case"end":return t.stop()}}),n,this)})))}},{key:"banUser",value:function(e,n,r){return b(this,void 0,void 0,t().mark((function a(){return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.abrupt("return",this.banUserWithUserId(e.userId,n,r));case 1:case"end":return t.stop()}}),a,this)})))}},{key:"banUserWithUserId",value:function(e,n,r){return b(this,void 0,void 0,t().mark((function a(){var s,i,o;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return Za(L("string",e)&&L("number",n,!0)&&L("string",r,!0)).throw(A.invalidParameters),s=fs.of(this._iid),i=s.requestQueue,o=new _h({channelUrl:this.url,channelType:this.channelType,userId:e,seconds:n,description:r}),t.next=5,i.send(o);case 5:case"end":return t.stop()}}),a,this)})))}},{key:"unbanUser",value:function(e){return b(this,void 0,void 0,t().mark((function n(){return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.abrupt("return",this.unbanUserWithUserId(e.userId));case 1:case"end":return t.stop()}}),n,this)})))}},{key:"unbanUserWithUserId",value:function(e){return b(this,void 0,void 0,t().mark((function n(){var r,a,s;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return Za(L("string",e)).throw(A.invalidParameters),r=fs.of(this._iid),a=r.requestQueue,s=new gh({channelUrl:this.url,channelType:this.channelType,userId:e}),t.next=5,a.send(s);case 5:case"end":return t.stop()}}),n,this)})))}},{key:"freeze",value:function(){return b(this,void 0,void 0,t().mark((function e(){var n,r,a;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n=fs.of(this._iid),r=n.requestQueue,a=new kh({channelUrl:this.url,channelType:this.channelType,freezing:!0}),e.next=4,r.send(a);case 4:this.isFrozen=!0;case 5:case"end":return e.stop()}}),e,this)})))}},{key:"unfreeze",value:function(){return b(this,void 0,void 0,t().mark((function e(){var n,r,a;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n=fs.of(this._iid),r=n.requestQueue,a=new kh({channelUrl:this.url,channelType:this.channelType,freezing:!1}),e.next=4,r.send(a);case 4:this.isFrozen=!1;case 5:case"end":return e.stop()}}),e,this)})))}},{key:"getMessagesByMessageId",value:function(e,n){return b(this,void 0,void 0,t().mark((function r(){var a,s;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return a=Object.assign(Object.assign({},ni),n),Za(L("number",e)&&ri(a)).throw(A.invalidParameters),s=wi.of(this._iid),t.next=5,s.getMessagesByMessageId(this.url,this.channelType,e,a);case 5:return t.abrupt("return",t.sent);case 6:case"end":return t.stop()}}),r,this)})))}},{key:"getMessagesByTimestamp",value:function(e,n){return b(this,void 0,void 0,t().mark((function r(){var a,s;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return a=Object.assign(Object.assign({},ni),n),Za(L("number",e)&&ri(a)).throw(A.invalidParameters),s=wi.of(this._iid),t.next=5,s.getMessagesByTimestamp(this.url,this.channelType,e,a);case 5:return t.abrupt("return",t.sent);case 6:case"end":return t.stop()}}),r,this)})))}},{key:"getMessageChangeLogsSinceTimestamp",value:function(e){var n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return b(this,void 0,void 0,t().mark((function r(){var a,s;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return a=Object.assign(Object.assign({},ai),n),Za(L("number",e)&&si(a)).throw(A.invalidParameters),s=wi.of(this._iid),t.next=5,s.getMessageChangelogs(this.url,this.channelType,e,a);case 5:return t.abrupt("return",t.sent);case 6:case"end":return t.stop()}}),r,this)})))}},{key:"getMessageChangeLogsSinceToken",value:function(e){var n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return b(this,void 0,void 0,t().mark((function r(){var a,s;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return a=Object.assign(Object.assign({},ai),n),Za(L("string",e)&&si(a)).throw(A.invalidParameters),s=wi.of(this._iid),t.next=5,s.getMessageChangelogs(this.url,this.channelType,e,a);case 5:return t.abrupt("return",t.sent);case 6:case"end":return t.stop()}}),r,this)})))}},{key:"_createPendingSendableMessagePayload",value:function(t,n,r){var a,s=fs.of(this._iid).sessionManager;return ue(ce({channel_url:this.url,channel_type:this.channelType,msg_id:0,parent_message_id:t.parentMessageId,data:t.data,custom_type:t.customType,mention_type:t.mentionType,sorted_metaarray:t.metaArrays?t.metaArrays.map((function(e){return Es.payloadify(e)})):null,apple_critical_alert_options:t.appleCriticalAlertOptions?xs.payloadify(t.appleCriticalAlertOptions):null,created_at:r,user:s.currentUser?Ts.payloadify(s.currentUser):null,req_id:n,request_state:e.SendingStatus.PENDING,mentioned_user_ids:t.mentionedUserIds,mentioned_users:null===(a=t.mentionedUsers)||void 0===a?void 0:a.map((function(e){return Xa.payloadify(e)}))}))}},{key:"_createPendingUserMessage",value:function(t,n,r){var a={};if(t.translationTargetLanguages){var s,i=y(t.translationTargetLanguages);try{for(i.s();!(s=i.n()).done;){a[s.value]=""}}catch(e){i.e(e)}finally{i.f()}}var o=ue(Object.assign(Object.assign({},this._createPendingSendableMessagePayload(t,n,r)),{type:e.MessageType.USER,message:t.message,translations:a})),u=new Hs(this._iid,o);return u.messageParams=t,u}},{key:"_createPendingScheduledUserMessage",value:function(e,t,n){var r=this._createPendingUserMessage(e,t,n);return r.scheduledInfo={scheduledMessageId:0,scheduledAt:e.scheduledAt,scheduledMessageParams:e},r}},{key:"_createPendingFileMessage",value:function(t,n,r){var a,s,i,o,u,c,l=ue(Object.assign(Object.assign({},this._createPendingSendableMessagePayload(t,n,r)),{type:e.MessageType.FILE,url:t.fileUrl,file:{name:null!==(a=t.fileName)&&void 0!==a?a:null===(s=t.file)||void 0===s?void 0:s.name,size:null!==(i=t.fileSize)&&void 0!==i?i:null===(o=t.file)||void 0===o?void 0:o.size,type:null!==(u=t.mimeType)&&void 0!==u?u:null===(c=t.file)||void 0===c?void 0:c.type,data:t.data},thumbnails:t.thumbnailSizes?t.thumbnailSizes.map((function(e){return{url:"",width:e.maxWidth,height:e.maxHeight}})):[]})),h=new Qs(this._iid,l);return h.messageParams=t,h}},{key:"_createPendingMultipleFilesMessage",value:function(t,n,r){var a=ue(Object.assign(Object.assign({},this._createPendingSendableMessagePayload(t,n,r)),{type:e.MessageType.FILE})),s=new zs(this._iid,a);return s.messageParams=t,s}},{key:"_createPendingScheduledFileMessage",value:function(e,t,n){var r=this._createPendingFileMessage(e,t,n);return r.scheduledInfo={scheduledMessageId:0,scheduledAt:e.scheduledAt,scheduledMessageParams:e},r}},{key:"_markMessageAsFailed",value:function(t,n){var r=arguments.length>2&&void 0!==arguments[2]&&arguments[2];t.errorCode=n.code,n.code===E.REQUEST_CANCELED?t.sendingStatus=e.SendingStatus.CANCELED:r||(t.sendingStatus=e.SendingStatus.FAILED)}},{key:"sendUserMessage",value:function(e){var t=Object.assign(Object.assign({},No),e);return Za(Ao(t)).throw(A.invalidParameters),this._sendUserMessage(t)}},{key:"_sendUserMessage",value:function(n,r){var a=this,s=fs.of(this._iid),i=s.dispatcher,o=s.requestQueue;s.sessionManager;var u=null!=r?r:this._generateRequestId(),c=Date.now(),l=new Ci;return ba(2).then((function(){var r=new xh(Object.assign(Object.assign({},n),{channelUrl:a.url,channelType:a.channelType,reqId:u}));o.send(r).then((function(n){var r=n.as(Th).message;i.dispatch(new ui({messages:[r],source:e.MessageEventSource.EVENT_MESSAGE_SENT_SUCCESS})),Ca((function(){return b(a,void 0,void 0,t().mark((function e(){return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",l._trigger(null,r));case 1:case"end":return e.stop()}}),e)})))}))})).catch((function(r){if(M(r))throw r;var s=a._createPendingUserMessage(n,u,c),o=fs.of(a._iid).cacheContext.localCacheEnabled&&G(r.code);a._markMessageAsFailed(s,r,o),i.dispatch(new ui({messages:[s],source:s.sendingStatus===e.SendingStatus.PENDING?e.MessageEventSource.REQUEST_RESEND_MESSAGE:e.MessageEventSource.EVENT_MESSAGE_SENT_FAILED})),Ca((function(){return b(a,void 0,void 0,t().mark((function e(){return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",l._trigger(r,s));case 1:case"end":return e.stop()}}),e)})))}))}));var s=a._createPendingUserMessage(n,u,c);i.dispatch(new ui({messages:[s],source:e.MessageEventSource.EVENT_MESSAGE_SENT_PENDING})),Ca((function(){return b(a,void 0,void 0,t().mark((function e(){return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",l._trigger(null,s));case 1:case"end":return e.stop()}}),e)})))}))})),l}},{key:"_autoResendUserMessage",value:function(e){return Za(e instanceof Hs&&!!e.messageParams).throw(A.invalidParameters),this._sendUserMessage(e.messageParams,e.reqId)}},{key:"resendUserMessage",value:function(e){var n;return b(this,void 0,void 0,t().mark((function r(){var a,s;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return Za(e instanceof Hs&&!e.scheduledInfo).throw(A.invalidParameters),a=new ca,s=null!==(n=e.messageParams)&&void 0!==n?n:Mo(e),this._sendUserMessage(s,e.reqId).onFailed((function(e){return a.reject(e)})).onSucceeded((function(e){return a.resolve(e)})),t.abrupt("return",a.promise);case 5:case"end":return t.stop()}}),r,this)})))}},{key:"updateUserMessage",value:function(e,n){return b(this,void 0,void 0,t().mark((function r(){var a,s,i,o,u,c,l;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return a=Object.assign(Object.assign({},Sl),n),Za(L("number",e)&&Il(a)).throw(A.invalidParameters),s=fs.of(this._iid),i=s.requestQueue,o=new Sh(Object.assign({channelType:this.channelType,channelUrl:this.url,messageId:e},a)),t.next=6,i.send(o);case 6:return u=t.sent,c=u.as(Ih),l=c.message,t.abrupt("return",l);case 9:case"end":return t.stop()}}),r,this)})))}},{key:"copyUserMessage",value:function(n,r){var a,s,i;return b(this,void 0,void 0,t().mark((function o(){var c,l;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return Za(n instanceof u&&r instanceof Hs&&r.sendingStatus===e.SendingStatus.SUCCEEDED&&this.url===r.channelUrl&&!r.scheduledInfo).throw(A.invalidParameters),Za(!r.poll).throw(A.notSupportedError),c=new ca,l=null!==(a=r.messageParams)&&void 0!==a?a:ce(Object.assign(Object.assign({},r),{mentionType:r.mentionType,mentionedUserIds:null!==(s=r.mentionedUserIds)&&void 0!==s?s:null===(i=r.mentionedUsers)||void 0===i?void 0:i.map((function(e){return e.userId})),translationTargetLanguages:Object.keys(r.translations),pushNotificationDeliveryOption:e.PushNotificationDeliveryOption.DEFAULT,parentMessageId:null,isReplyToChannel:!1,isPinnedMessage:!1})),n._sendUserMessage(l).onSucceeded((function(e){c.resolve(e)})).onFailed((function(e){return c.reject(e)})),t.abrupt("return",c.promise);case 6:case"end":return t.stop()}}),o,this)})))}},{key:"translateUserMessage",value:function(e,n){return b(this,void 0,void 0,t().mark((function r(){var a,s,i,o,u,c;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return Za(e instanceof Hs&&e.messageId>0&&F("string",n)).throw(A.invalidParameters),a=fs.of(this._iid),s=a.requestQueue,i=new Ph({channelType:this.channelType,channelUrl:this.url,messageId:e.messageId,translationTargetLanguages:n}),t.next=5,s.send(i);case 5:return o=t.sent,u=o.as(Fh),c=u.message,t.abrupt("return",c);case 8:case"end":return t.stop()}}),r,this)})))}},{key:"_createScheduledUserMessage",value:function(e,n){var r=this,a=fs.of(this._iid).requestQueue,s=Date.now(),i=this._generateRequestId();ba(2).then((function(){var a=r._createPendingScheduledUserMessage(e,i,s);Ca((function(){return b(r,void 0,void 0,t().mark((function e(){return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",n._trigger(null,a));case 1:case"end":return e.stop()}}),e)})))}))}));var o=new Gh(Object.assign({reqId:i,channelType:this.channelType,channelUrl:this.url},e));a.send(o).then((function(e){var a=e.as(qh).message;Ca((function(){return b(r,void 0,void 0,t().mark((function e(){return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",n._trigger(null,a));case 1:case"end":return e.stop()}}),e)})))}))})).catch((function(a){if(M(a))throw a;ba(2).then((function(){var o=r._createPendingScheduledUserMessage(e,i,s);r._markMessageAsFailed(o,a),Ca((function(){return b(r,void 0,void 0,t().mark((function e(){return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",n._trigger(a,o));case 1:case"end":return e.stop()}}),e)})))}))}))}))}},{key:"sendFileMessage",value:function(e){var t=Object.assign(Object.assign({},Po),e);return Za(Go(t)).throw(A.invalidParameters),this._sendFileMessage(t)}},{key:"sendMultipleFilesMessage",value:function(e){var t,n=Object.assign(Object.assign({},Ko),e),r=fs.of(this._iid);Za(function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:5;return So(e)&&Array.isArray(e.fileInfoList)&&e.fileInfoList.length>=2&&e.fileInfoList.length<=t&&e.fileInfoList.every((function(e){return Wo(e)}))}(n,null===(t=r.appInfo)||void 0===t?void 0:t.multipleFilesMessageFileCountLimit)).throw(A.invalidParameters);var a=!!e.fileInfoList.find((function(e){var t=r.appInfo.uploadSizeLimit;return e.file instanceof Blob&&e.file.size>t||e.fileSize>t}));return Za(!a).throw(A.fileSizeLimitExceededError),this._sendMultipleFilesMessage(n)}},{key:"_sendFileMessage",value:function(n,r){var a=this,s=fs.of(this._iid),i=s.dispatcher;s.sessionManager;var o=wi.of(this._iid).fileMessageQueue,u=null!=r?r:this._generateRequestId(),c=Date.now(),l=new Ci;return ba(2).then((function(){var r=a._createPendingFileMessage(n,u,c);i.dispatch(new ui({messages:[r],source:e.MessageEventSource.EVENT_MESSAGE_SENT_PENDING})),Ca((function(){return b(a,void 0,void 0,t().mark((function e(){return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",l._trigger(null,r));case 1:case"end":return e.stop()}}),e)})))})),o.request(a,u,n).then((function(n){i.dispatch(new ui({messages:[n],source:e.MessageEventSource.EVENT_MESSAGE_SENT_SUCCESS})),Ca((function(){return b(a,void 0,void 0,t().mark((function e(){return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",l._trigger(null,n));case 1:case"end":return e.stop()}}),e)})))}))})).catch((function(r){if(M(r))throw r;var s=a._createPendingFileMessage(n,u,c),o=fs.of(a._iid).cacheContext.localCacheEnabled&&G(r.code);a._markMessageAsFailed(s,r,o),i.dispatch(new ui({messages:[s],source:s.sendingStatus===e.SendingStatus.PENDING?e.MessageEventSource.REQUEST_RESEND_MESSAGE:e.MessageEventSource.EVENT_MESSAGE_SENT_FAILED})),Ca((function(){return b(a,void 0,void 0,t().mark((function e(){return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",l._trigger(r,s));case 1:case"end":return e.stop()}}),e)})))}))}))})),l}},{key:"_autoResendFileMessage",value:function(e){Za(e instanceof Qs&&!!e.messageParams).throw(A.invalidParameters);var t=fs.of(this._iid).logger;return t.debug("autoResendFileMessage pending",e),this._sendFileMessage(e.messageParams,e.reqId).onFailed((function(e){t.debug("autoResendFileMessage failed",e)})).onSucceeded((function(e){t.debug("autoResendFileMessage success",e)}))}},{key:"_sendMultipleFilesMessage",value:function(n,r){var a=this,s=fs.of(this._iid),i=s.dispatcher;s.sessionManager;var o=wi.of(this._iid).fileMessageQueue,u=null!=r?r:this._generateRequestId(),c=Date.now(),l=new Gi;return ba(2).then((function(){var r=a._createPendingMultipleFilesMessage(n,u,c);i.dispatch(new ui({messages:[r],source:e.MessageEventSource.EVENT_MESSAGE_SENT_PENDING})),Ca((function(){return b(a,void 0,void 0,t().mark((function e(){return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",l._trigger(null,r));case 1:case"end":return e.stop()}}),e)})))})),o.request(a,u,n,l).then((function(n){i.dispatch(new ui({messages:[n],source:e.MessageEventSource.EVENT_MESSAGE_SENT_SUCCESS})),Ca((function(){return b(a,void 0,void 0,t().mark((function e(){return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",l._trigger(null,n));case 1:case"end":return e.stop()}}),e)})))}))})).catch((function(r){if(M(r))throw r;var s=a._createPendingMultipleFilesMessage(n,u,c);a._markMessageAsFailed(s,r),i.dispatch(new ui({messages:[s],source:e.MessageEventSource.EVENT_MESSAGE_SENT_FAILED})),Ca((function(){return b(a,void 0,void 0,t().mark((function e(){return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",l._trigger(r,s));case 1:case"end":return e.stop()}}),e)})))}))}))})),l}},{key:"_createScheduledFileMessage",value:function(e,n,r,a){var s=this,i=fs.of(this._iid).requestQueue,o=new Hh(Object.assign(Object.assign({reqId:r,channelType:this.channelType,channelUrl:this.url},e),{fileUrl:e.fileUrl,requireAuth:e.requireAuth}));i.send(o).then((function(e){var r=e.as(jh).message;Ca((function(){return b(s,void 0,void 0,t().mark((function e(){return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",n._trigger(null,r));case 1:case"end":return e.stop()}}),e)})))}))})).catch((function(i){if(M(i))throw i;ba(2).then((function(){var o=s._createPendingScheduledFileMessage(e,r,a);s._markMessageAsFailed(o,i),Ca((function(){return b(s,void 0,void 0,t().mark((function e(){return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",n._trigger(i,o));case 1:case"end":return e.stop()}}),e)})))}))}))}))}},{key:"sendFileMessages",value:function(e){Za(e.every((function(e){return Go(Object.assign(Object.assign({},Po),e))}))).throw(A.invalidParameters);var t,n=new Ci,r=y(e);try{for(r.s();!(t=r.n()).done;){var a=t.value;this.sendFileMessage(a).onPending((function(e){return n._trigger(null,e)})).onFailed((function(e,t){return n._trigger(e,t)})).onSucceeded((function(e){return n._trigger(null,e)}))}}catch(e){r.e(e)}finally{r.f()}return n}},{key:"resendFileMessage",value:function(e,n){var r;return b(this,void 0,void 0,t().mark((function a(){var s,i,o;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return s=Boolean(e.url)||q(n)||q(null===(r=e.messageParams)||void 0===r?void 0:r.file),Za(e instanceof Qs&&s&&!e.scheduledInfo).throw(A.invalidParameters),i=new ca,o=Fo(e,n),this._sendFileMessage(o,e.reqId).onFailed((function(e){return i.reject(e)})).onSucceeded((function(e){return i.resolve(e)})),t.abrupt("return",i.promise);case 6:case"end":return t.stop()}}),a,this)})))}},{key:"updateFileMessage",value:function(e,n){return b(this,void 0,void 0,t().mark((function r(){var a,s,i,o,u,c,l;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return a=Object.assign(Object.assign({},Nl),n),Za(L("number",e)&&Ml(a)).throw(A.invalidParameters),s=fs.of(this._iid),i=s.requestQueue,o=new Nh(Object.assign({channelType:this.channelType,channelUrl:this.url,messageId:e},a)),t.next=6,i.send(o);case 6:return u=t.sent,c=u.as(Mh),l=c.message,t.abrupt("return",l);case 9:case"end":return t.stop()}}),r,this)})))}},{key:"cancelUploadingFileMessage",value:function(e){return b(this,void 0,void 0,t().mark((function n(){var r;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return Za(L("string",e)).throw(A.invalidParameters),r=wi.of(this._iid),r.fileMessageQueue.cancel(this,e),t.abrupt("return",!0);case 4:case"end":return t.stop()}}),n,this)})))}},{key:"copyFileMessage",value:function(n,r){var a,s,i;return b(this,void 0,void 0,t().mark((function o(){var c,l;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return Za(n instanceof u&&r instanceof Qs&&r.sendingStatus===e.SendingStatus.SUCCEEDED&&this.url===r.channelUrl&&!r.scheduledInfo).throw(A.invalidParameters),c=new ca,l=ce(Object.assign(Object.assign({},r),{fileUrl:r.url,fileName:r.name,fileSize:r.size,mimeType:r.type,mentionType:r.mentionType,mentionedUserIds:null!==(a=r.mentionedUserIds)&&void 0!==a?a:null===(s=r.mentionedUsers)||void 0===s?void 0:s.map((function(e){return e.userId})),pushNotificationDeliveryOption:e.PushNotificationDeliveryOption.DEFAULT,parentMessageId:null,isReplyToChannel:!1,thumbnailSizes:null===(i=r.thumbnails)||void 0===i?void 0:i.map((function(e){return{maxWidth:e.width,maxHeight:e.height}})),requireAuth:r.requireAuth,isPinnedMessage:!1})),n._sendFileMessage(l).onSucceeded((function(e){return c.resolve(e)})).onFailed((function(e){return c.reject(e)})),t.abrupt("return",c.promise);case 5:case"end":return t.stop()}}),o,this)})))}},{key:"deleteMessage",value:function(e){return b(this,void 0,void 0,t().mark((function n(){var r,a,s;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(Za(e instanceof Ns).throw(A.invalidParameters),!(e.messageId>0)){t.next=6;break}return r=fs.of(this._iid),a=r.requestQueue,s=new Ah({channelType:this.channelType,channelUrl:this.url,messageId:e.messageId}),t.next=6,a.send(s);case 6:case"end":return t.stop()}}),n,this)})))}},{key:"addReaction",value:function(e,n){return b(this,void 0,void 0,t().mark((function r(){var a,s,i,o,u,c;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return Za(e instanceof Ns&&e.messageId>0&&L("string",n)).throw(A.invalidParameters),a=fs.of(this._iid),s=a.requestQueue,i=new Uh({channelType:this.channelType,channelUrl:this.url,messageId:e.messageId,reactionKey:n}),t.next=5,s.send(i);case 5:return o=t.sent,u=o.as(Rh),c=u.reactionEvent,t.abrupt("return",c);case 8:case"end":return t.stop()}}),r,this)})))}},{key:"deleteReaction",value:function(e,n){return b(this,void 0,void 0,t().mark((function r(){var a,s,i,o,u,c;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return Za(e instanceof Ns&&e.messageId>0&&L("string",n)).throw(A.invalidParameters),a=fs.of(this._iid),s=a.requestQueue,i=new Lh({channelType:this.channelType,channelUrl:this.url,messageId:e.messageId,reactionKey:n}),t.next=5,s.send(i);case 5:return o=t.sent,u=o.as(Dh),c=u.reactionEvent,t.abrupt("return",c);case 8:case"end":return t.stop()}}),r,this)})))}},{key:"_updateUserMessageMetaArray",value:function(n,r,a,s){return b(this,void 0,void 0,t().mark((function i(){var o,u,c,l,h,d,f;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return o=fs.of(this._iid),u=o.dispatcher,c=o.requestQueue,l=new Sh({channelType:this.channelType,channelUrl:this.url,messageId:n,metaArrayParams:{array:r,mode:a,upsert:s}}),t.next=4,c.send(l);case 4:return h=t.sent,d=h.as(Ih),f=d.message,u.dispatch(new ui({messages:[f],source:e.MessageEventSource.EVENT_MESSAGE_UPDATED})),t.abrupt("return",f);case 8:case"end":return t.stop()}}),i,this)})))}},{key:"_updateFileMessageMetaArray",value:function(n,r,a,s){return b(this,void 0,void 0,t().mark((function i(){var o,u,c,l,h,d,f;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return o=fs.of(this._iid),u=o.dispatcher,c=o.requestQueue,l=new Nh({channelType:this.channelType,channelUrl:this.url,messageId:n,metaArrayParams:{array:r,mode:a,upsert:s}}),t.next=4,c.send(l);case 4:return h=t.sent,d=h.as(Mh),f=d.message,u.dispatch(new ui({messages:[f],source:e.MessageEventSource.EVENT_MESSAGE_UPDATED})),t.abrupt("return",f);case 8:case"end":return t.stop()}}),i,this)})))}},{key:"createMessageMetaArrayKeys",value:function(e,n){return b(this,void 0,void 0,t().mark((function r(){var a;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(Za(e instanceof Ns&&e.messageId>0&&F("string",n)).throw(A.invalidParameters),a=n.map((function(e){return new Es({key:e})})),!(e instanceof Qs)){t.next=6;break}return t.abrupt("return",this._updateFileMessageMetaArray(e.messageId,a,"add",!0));case 6:return t.abrupt("return",this._updateUserMessageMetaArray(e.messageId,a,"add",!0));case 7:case"end":return t.stop()}}),r,this)})))}},{key:"deleteMessageMetaArrayKeys",value:function(e,n){return b(this,void 0,void 0,t().mark((function r(){var a;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(Za(e instanceof Ns&&e.messageId>0&&F("string",n)).throw(A.invalidParameters),a=n.map((function(e){return new Es({key:e})})),!(e instanceof Qs)){t.next=6;break}return t.abrupt("return",this._updateFileMessageMetaArray(e.messageId,a,"remove",!0));case 6:return t.abrupt("return",this._updateUserMessageMetaArray(e.messageId,a,"remove",!0));case 7:case"end":return t.stop()}}),r,this)})))}},{key:"addMessageMetaArrayValues",value:function(e,n){return b(this,void 0,void 0,t().mark((function r(){return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(Za(e instanceof Ns&&e.messageId>0&&n.every((function(e){return e instanceof Es}))).throw(A.invalidParameters),!(e instanceof Qs)){t.next=5;break}return t.abrupt("return",this._updateFileMessageMetaArray(e.messageId,n,"add",!0));case 5:return t.abrupt("return",this._updateUserMessageMetaArray(e.messageId,n,"add",!0));case 6:case"end":return t.stop()}}),r,this)})))}},{key:"removeMessageMetaArrayValues",value:function(e,n){return b(this,void 0,void 0,t().mark((function r(){return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(Za(e instanceof Ns&&e.messageId>0&&n.every((function(e){return e instanceof Es}))).throw(A.invalidParameters),!(e instanceof Qs)){t.next=5;break}return t.abrupt("return",this._updateFileMessageMetaArray(e.messageId,n,"remove",!0));case 5:return t.abrupt("return",this._updateUserMessageMetaArray(e.messageId,n,"remove",!0));case 6:case"end":return t.stop()}}),r,this)})))}},{key:"report",value:function(n,r){return b(this,void 0,void 0,t().mark((function a(){var s,i,o,u;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return Za(D(e.ReportCategory,n)&&L("string",r)).throw(A.invalidParameters),s=fs.of(this._iid),i=s.sdkState,o=s.requestQueue,u=new Eh({channelUrl:this.url,channelType:this.channelType,userId:i.userId,category:n,description:r}),t.next=5,o.send(u);case 5:case"end":return t.stop()}}),a,this)})))}},{key:"reportUser",value:function(n,r,a){return b(this,void 0,void 0,t().mark((function s(){var i,o,u,c;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return Za(n instanceof Xa&&D(e.ReportCategory,r)&&L("string",a)).throw(A.invalidParameters),i=fs.of(this._iid),o=i.sdkState,u=i.requestQueue,c=new wh({channelUrl:this.url,channelType:this.channelType,userId:o.userId,offendingUserId:n.userId,category:r,description:a}),t.next=5,u.send(c);case 5:case"end":return t.stop()}}),s,this)})))}},{key:"reportMessage",value:function(n,r,a){return b(this,void 0,void 0,t().mark((function s(){var i,o,u,c;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return Za(n instanceof Ms&&D(e.ReportCategory,r)&&L("string",a)).throw(A.invalidParameters),i=fs.of(this._iid),o=i.sdkState,u=i.requestQueue,c=new Ch({channelUrl:this.url,channelType:this.channelType,userId:o.userId,offendingUserId:n.sender.userId,messageId:n.messageId,category:r,description:a}),t.next=5,u.send(c);case 5:case"end":return t.stop()}}),s,this)})))}},{key:"updatePoll",value:function(e,n){return b(this,void 0,void 0,t().mark((function r(){var a,s,i,o,u,c;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return Za(L("number",e)&&zh(n)).throw(A.invalidParameters),a=fs.of(this._iid),s=a.requestQueue,i=new Vh(Object.assign({pollId:e},n)),t.next=5,s.send(i);case 5:return o=t.sent,u=o.as(Bh),c=u.poll,t.abrupt("return",c);case 8:case"end":return t.stop()}}),r,this)})))}},{key:"deletePoll",value:function(e){return b(this,void 0,void 0,t().mark((function n(){var r,a,s,i;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return r=L("number",e),Za(r).throw(A.invalidParameters),a=fs.of(this._iid),s=a.requestQueue,i=new Qh({pollId:e}),t.next=6,s.send(i);case 6:case"end":return t.stop()}}),n,this)})))}},{key:"closePoll",value:function(e){return b(this,void 0,void 0,t().mark((function n(){var r,a,s,i,o,u,c;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return r=L("number",e),Za(r).throw(A.invalidParameters),a=fs.of(this._iid),s=a.requestQueue,i=new Kh({pollId:e}),t.next=6,s.send(i);case 6:return o=t.sent,u=o.as(Wh),c=u.poll,t.abrupt("return",c);case 9:case"end":return t.stop()}}),n,this)})))}},{key:"addPollOption",value:function(e,n){return b(this,void 0,void 0,t().mark((function r(){var a,s,i,o,u,c,l;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return a=L("number",e)&&L("string",n)&&""!==n.trim(),Za(a).throw(A.invalidParameters),s=fs.of(this._iid),i=s.requestQueue,o=new Yh({channelUrl:this.url,channelType:this.channelType,pollId:e,optionText:n}),t.next=6,i.send(o);case 6:return u=t.sent,c=u.as(Zh),l=c.poll,t.abrupt("return",l);case 9:case"end":return t.stop()}}),r,this)})))}},{key:"updatePollOption",value:function(e,n,r){return b(this,void 0,void 0,t().mark((function a(){var s,i,o,u,c,l,h;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return s=L("number",e)&&L("number",n)&&L("string",r)&&""!==r.trim(),Za(s).throw(A.invalidParameters),i=fs.of(this._iid),o=i.requestQueue,u=new Jh({pollId:e,pollOptionId:n,optionText:r}),t.next=6,o.send(u);case 6:return c=t.sent,l=c.as(Xh),h=l.poll,t.abrupt("return",h);case 9:case"end":return t.stop()}}),a,this)})))}},{key:"deletePollOption",value:function(e,n){return b(this,void 0,void 0,t().mark((function r(){var a,s,i,o;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return a=L("number",e)&&L("number",n),Za(a).throw(A.invalidParameters),s=fs.of(this._iid),i=s.requestQueue,o=new $h({pollId:e,pollOptionId:n}),t.next=6,i.send(o);case 6:case"end":return t.stop()}}),r,this)})))}},{key:"votePoll",value:function(n,r){return b(this,void 0,void 0,t().mark((function a(){var s,i,o,u,c,l,h,d;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return s=L("number",n)&&F("number",r),Za(s).throw(A.invalidParameters),i=fs.of(this._iid),o=i.requestQueue,u=i.dispatcher,c=new ed({reqId:this._generateRequestId(),channelUrl:this.url,channelType:this.channelType,pollId:n,pollOptionIds:r}),t.next=6,o.send(c);case 6:return l=t.sent,h=l.as(td),d=h.event,u.dispatch(new fi({event:d,source:e.MessageEventSource.EVENT_POLL_VOTED})),t.abrupt("return",d);case 10:case"end":return t.stop()}}),a,this)})))}},{key:"getPollChangeLogsSinceTimestamp",value:function(e){return b(this,void 0,void 0,t().mark((function n(){var r;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return Za(L("number",e)).throw(A.invalidParameters),r=no.of(this._iid),t.next=4,r.getPollChangeLogs(this.url,this.channelType,e);case 4:return t.abrupt("return",t.sent);case 5:case"end":return t.stop()}}),n,this)})))}},{key:"getPollChangeLogsSinceToken",value:function(e){return b(this,void 0,void 0,t().mark((function n(){var r;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return Za(L("string",e,!0)),r=no.of(this._iid),t.next=4,r.getPollChangeLogs(this.url,this.channelType,e);case 4:return t.abrupt("return",t.sent);case 5:case"end":return t.stop()}}),n,this)})))}},{key:"createPollListQuery",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:10;return new oo(this._iid,{channelUrl:this.url,channelType:this.channelType,limit:e})}},{key:"createPollVoterListQuery",value:function(e,t){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:20;return new lo(this._iid,{channelUrl:this.url,channelType:this.channelType,pollId:e,pollOptionId:t,limit:n})}}],[{key:"payloadify",value:function(e){return ue(ce(Object.assign(Object.assign({},p(o(u),"payloadify",this).call(this,e)),{channel_url:e.url,name:e.name,cover_url:e.coverUrl,custom_type:e.customType,data:e.data,freeze:e.isFrozen,is_ephemeral:e.isEphemeral,created_by:e.creator?Xa.payloadify(e.creator):null,created_at:e.createdAt/1e3})))}}]),u}(Ha),rd=function(){function n(e,a,s){var i=this;r(this,n),this._storeInitialized=!1,this._iid=e,this.options=a;var o=fs.of(e),u=o.sdkState,c=o.cacheContext,l=o.dispatcher,h=o.sessionManager,d=o.requestQueue,f=o.logger,p=o.userEventHandlers,v=o.appStateToggleEnabled;this._onlineDetector=new ru({logger:f,connectionDelegate:{reconnect:function(){var t=fs.of(e),n=t.sdkState,r=t.connectionManager,a=t.sessionManager;a.auth.hasSession?"foreground"===n.appState&&r.resetAndReconnect():r.connect(a.auth.authToken)},disconnect:function(){fs.of(e).connectionManager.disconnect()}}});var _=new iu(e,{localCacheEnabled:c.localCacheEnabled,dispatcher:l,sdkState:u,logger:f});s.forEach((function(t){t.init(e,{sdkState:u,cacheContext:c,dispatcher:l,sessionManager:h,requestQueue:d,logger:f,onlineDetector:i._onlineDetector}),i[t.name]=t})),this._appStateChangeDetector=new nu({isEnabled:v}),this._appStateChangeDetector.on("resume",(function(){f.debug("the page resumes from freeze"),i.setForegroundState()})).on("pause",(function(){f.debug("the page freezes"),i.setBackgroundState()})),l.on((function(n){if(n instanceof da){if(n.stateType===sa.CONNECTED)_.processNonAutoResendRegisteredPendingMessages()}else if(n instanceof qe){if("USEV"===n.code){var r=n.as(vu).event;if(r.category===jo.FRIEND_DISCOVERED){var a=uu.getDataAsFriendDiscoveredEvent(e,r).friendDiscoveries;Ca((function(){return b(i,void 0,void 0,t().mark((function e(){return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",p.forEach((function(e){e.onFriendsDiscovered&&e.onFriendsDiscovered(a)})));case 1:case"end":return e.stop()}}),e)})))}))}}}else if(n instanceof ua){var s=fs.of(i._iid).subscribedUnreadMessageCount,o=!1,l=n.ts;if("number"==typeof l&&l>s.ts){if(s.all!==n.all&&(o=!0),s.all=n.all>=0?n.all:0,n.customTypes)for(var h in n.customTypes)s.customTypes[h]!==n.customTypes[h]&&(o=!0),s.customTypes[h]=n.customTypes[h];o=o&&s.ts>0,s.ts=l}o&&Ca((function(){return b(i,void 0,void 0,t().mark((function e(){return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",p.forEach((function(e){e.onTotalUnreadMessageCountUpdated&&e.onTotalUnreadMessageCountUpdated(s.all,s.customTypes)})));case 1:case"end":return e.stop()}}),e)})))}))}else n instanceof $a?c.preference.set(i._getUserProfileCacheKey(u.userId),es.payloadify(n.userProfile)):n instanceof Le&&n.error&&n.error.isSessionRevokedError&&(f.debug("session revoked."),i.disconnect())}))}return s(n,[{key:"appId",get:function(){return fs.of(this._iid).sdkState.appId}},{key:"appInfo",get:function(){var e=fs.of(this._iid).appInfo;return null!=e?e:null}},{key:"appVersion",get:function(){var e;return null!==(e=fs.of(this._iid).sdkState.appVersion)&&void 0!==e?e:""}},{key:"debugMode",get:function(){return!!fs.of(this._iid).debugMode}},{key:"logLevel",get:function(){return fs.of(this._iid).logger.level},set:function(e){fs.of(this._iid).logger.level=e}},{key:"isCacheEnabled",get:function(){return fs.of(this._iid).cacheContext.localCacheEnabled}},{key:"localCacheConfig",get:function(){var e=fs.of(this._iid).cacheContext;return e.localCacheEnabled?e.localCacheConfig:null}},{key:"ekey",get:function(){return fs.of(this._iid).sessionManager.ekey}},{key:"currentUser",get:function(){var e;return null!==(e=fs.of(this._iid).sessionManager.currentUser)&&void 0!==e?e:null}},{key:"connectionState",get:function(){var t=fs.of(this._iid).connectionManager;return t.isConnected?e.ConnectionState.OPEN:t.isConnecting?e.ConnectionState.CONNECTING:e.ConnectionState.CLOSED}},{key:"lastConnectedAt",get:function(){var e=fs.of(this._iid),t=e.connectedAt;return e.connectionManager.isConnected?t:0}},{key:"fcmPushToken",get:function(){var e;return null!==(e=this._fcmPushToken)&&void 0!==e?e:null}},{key:"apnsPushToken",get:function(){var e;return null!==(e=this._apnsPushToken)&&void 0!==e?e:null}},{key:"_getCurrentPreferenceVersion",value:function(){return 1}},{key:"_getPreferenceCacheKey",value:function(e){return"sendbird@".concat(this.appId,"/").concat(e,".pref")}},{key:"_getUserProfileCacheKey",value:function(e){return"sendbird@".concat(this.appId,"/").concat(e,".profile")}},{key:"getMemoryStoreForDebugging",value:function(){var e=fs.of(this._iid),t=e.debugMode,n=e.cacheContext;if(t)return n.store instanceof ll?n.store:null;throw A.debugModeRequired}},{key:"addExtension",value:function(e,t){var n=fs.of(this._iid).sdkState;["sb_uikit","sb_syncmanager","device-os-platform"].indexOf(e)>-1&&n.extensions&&(n.extensions[e]=t)}},{key:"setOnlineListener",value:function(e){this._onlineDetector.setOnlineListener(e)}},{key:"setOfflineListener",value:function(e){this._onlineDetector.setOfflineListener(e)}},{key:"_safeInitializeStore",value:function(e){return b(this,void 0,void 0,t().mark((function n(){var r,a;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return r=fs.of(this._iid),a=r.cacheContext,t.prev=1,t.next=4,a.store.init(e);case 4:this._storeInitialized=!0,t.next=12;break;case 7:return t.prev=7,t.t0=t.catch(1),a.replaceStore(new ll),t.next=12,this._safeInitializeStore(e);case 12:case"end":return t.stop()}}),n,this,[[1,7]])})))}},{key:"initializeCache",value:function(e){return b(this,void 0,void 0,t().mark((function n(){var r,a,s,i,o,u,c,l;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(r=fs.of(this._iid),a=r.sdkState,s=r.cacheContext,i=r.connectionManager,o=r.dispatcher,u=r.logger,a.userId&&a.userId===e){t.next=30;break}return t.next=4,i.logout();case 4:if(c="sendbird@".concat(a.appId,"/").concat(e,".db"),!s.localCacheEnabled){t.next=27;break}if(t.prev=6,s.nestdb&&s.nestdb.state!==dl.CLOSED&&s.nestdb.name===c){t.next=15;break}return(l=s.nestdb=new kl({name:"sendbird@".concat(a.appId,"/").concat(e,".db"),version:2,store:s.store})).on("upgrade",Xo(l,s.store)),l.on("storeReplaced",(function(e){s.replaceStore(e),s.localCacheEnabled=!1,l.on("upgrade",Xo(l,s.store))})),t.next=13,l.open();case 13:this._storeInitialized=!0,o.dispatch(new cu(this._iid,{userId:e}));case 15:a.userId=e,t.next=25;break;case 18:return t.prev=18,t.t0=t.catch(6),u.warn("Nest DB Open Failed. ",t.t0),t.next=23,this._safeInitializeStore(c);case 23:throw a.userId=e,A.databaseError;case 25:t.next=30;break;case 27:return t.next=29,this._safeInitializeStore(c);case 29:a.userId=e;case 30:case"end":return t.stop()}}),n,this,[[6,18]])})))}},{key:"getCacheDataSize",value:function(){return b(this,void 0,void 0,t().mark((function e(){var n,r;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(n=fs.of(this._iid),!(r=n.cacheContext).localCacheEnabled||!r.nestdb){e.next=5;break}return e.next=4,r.nestdb.estimateUsage();case 4:return e.abrupt("return",e.sent);case 5:return e.abrupt("return",0);case 6:case"end":return e.stop()}}),e,this)})))}},{key:"clearCachedData",value:function(){return b(this,void 0,void 0,t().mark((function e(){var n,r;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(n=fs.of(this._iid),!(r=n.cacheContext).localCacheEnabled){e.next=5;break}if(!r.nestdb){e.next=5;break}return e.next=5,r.nestdb.clear();case 5:if(!this._storeInitialized){e.next=8;break}return e.next=8,r.preference.clear();case 8:case"end":return e.stop()}}),e,this)})))}},{key:"clearCachedMessages",value:function(e){return b(this,void 0,void 0,t().mark((function n(){var r,a,s=this;return t().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:if(Za(F("string",e)).throw(A.invalidParameters),r=eu.of(this._iid),a=Jo.of(this._iid),!r||!a){n.next=6;break}return n.next=6,Promise.all(e.map((function(e){return b(s,void 0,void 0,t().mark((function n(){return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,r.removeMessagesOfChannel(e);case 2:return t.next=4,a.removeMessagesOfChannel(e);case 4:case"end":return t.stop()}}),n)})))})));case 6:case"end":return n.stop()}}),n,this)})))}},{key:"connect",value:function(e,n){return b(this,void 0,void 0,t().mark((function r(){var a,s,i,o,u,c,l,h,d;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return Za(L("string",e)&&L("string",n,!0)).throw(A.invalidParameters),a=fs.of(this._iid),s=a.sdkState,i=a.cacheContext,o=a.connectionManager,u=a.statLogCollector,t.prev=2,t.next=5,this.initializeCache(e);case 5:c=fs.of(this._iid),c.dispatcher.dispatch(new pu),t.next=14;break;case 9:t.prev=9,t.t0=t.catch(2),l=fs.of(this._iid),h=l.logger,i.localCacheEnabled=!1,h.warn("Cache initialization failed - cache is not available.");case 14:return t.next=16,i.preference.init(this._getPreferenceCacheKey(e),this._getCurrentPreferenceVersion());case 16:return t.next=18,i.preference.get(this._getUserProfileCacheKey(e));case 18:return(d=t.sent)&&new es(this._iid,d).apply(),t.next=22,u.init("sendbird@".concat(s.appId,"/").concat(e,".statlog"));case 22:return t.prev=22,t.next=25,o.connect(n);case 25:return t.prev=25,this._onlineDetector.start(),this._appStateChangeDetector.start(),t.finish(25);case 29:return t.abrupt("return",this.currentUser);case 30:case"end":return t.stop()}}),r,this,[[2,9],[22,,25,29]])})))}},{key:"reconnect",value:function(){var e=fs.of(this._iid),t=e.connectionManager,n=e.sdkState,r=e.sessionManager.auth.hasSession;return r&&(this._appStateChangeDetector.start(),this._onlineDetector.start(),t.resetAndReconnect().then((function(){n.appState="foreground"})).catch((function(){}))),r}},{key:"disconnect",value:function(){return b(this,void 0,void 0,t().mark((function e(){var n,r,a;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n=fs.of(this._iid),r=n.connectionManager,a=n.requestQueue,this._appStateChangeDetector.stop(),this._onlineDetector.stop(),a.cancelAll(),e.next=6,r.logout();case 6:return e.next=8,this.clearCachedData();case 8:case"end":return e.stop()}}),e,this)})))}},{key:"disconnectWebSocket",value:function(){return b(this,void 0,void 0,t().mark((function e(){var n,r,a;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n=fs.of(this._iid),r=n.connectionManager,a=n.requestQueue,this._appStateChangeDetector.stop(),this._onlineDetector.stop(),a.cancelAll(),e.next=6,r.disconnectWebSocket();case 6:case"end":return e.stop()}}),e,this)})))}},{key:"setBackgroundState",value:function(){var e=fs.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())}},{key:"setForegroundState",value:function(){var e=fs.of(this._iid),t=e.connectionManager,n=e.sdkState,r=e.logger;"background"===n.appState&&(n.appState="foreground",r.debug("going foreground state"),t.resetAndReconnect())}},{key:"setSessionHandler",value:function(e){Za(e instanceof vo).throw(A.invalidParameters),fs.of(this._iid).sessionManager.handler=e}},{key:"addUserEventHandler",value:function(e,t){Za(L("string",e)&&t instanceof mo).throw(A.invalidParameters),fs.of(this._iid).userEventHandlers.set(e,t)}},{key:"removeUserEventHandler",value:function(e){fs.of(this._iid).userEventHandlers.delete(e)}},{key:"removeAllUserEventHandler",value:function(){fs.of(this._iid).userEventHandlers.clear()}},{key:"addConnectionHandler",value:function(e,t){Za(L("string",e)&&t instanceof _o).throw(A.invalidParameters),fs.of(this._iid).connectionHandlers.set(e,t)}},{key:"removeConnectionHandler",value:function(e){fs.of(this._iid).connectionHandlers.delete(e)}},{key:"removeAllConnectionHandler",value:function(){fs.of(this._iid).connectionHandlers.clear()}},{key:"createApplicationUserListQuery",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return new gc(this._iid,e)}},{key:"createBlockedUserListQuery",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return new bc(this._iid,e)}},{key:"createFriendListQuery",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return new Cc(this._iid,e)}},{key:"createMessageSearchQuery",value:function(e){return new Ri(this._iid,e)}},{key:"createPollListQuery",value:function(e){return new oo(this._iid,Object.assign({},e))}},{key:"createPollVoterListQuery",value:function(e){return new lo(this._iid,Object.assign({},e))}},{key:"buildUserFromSerializedData",value:function(e){var t=Ya(e);return new Xa(this._iid,Xa.payloadify(t))}},{key:"updateCurrentUserInfo",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return b(this,void 0,void 0,t().mark((function n(){var r,a,s,i,o,u,c,l;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(r=Object.assign(Object.assign({},fo),e),Za(po(r)).throw(A.invalidParameters),!this.currentUser){t.next=13;break}return a=fs.of(this._iid),s=a.sdkState,i=a.requestQueue,o=new _u(Object.assign({userId:s.userId},r)),t.next=7,i.send(o);case 7:return u=t.sent,c=u.as(mu),l=c.user,this.currentUser&&(r.nickname&&(this.currentUser.nickname=l.nickname),(r.profileUrl||r.profileImage)&&(this.currentUser.plainProfileUrl=l.profileUrl)),t.abrupt("return",l);case 13:throw A.connectionRequired;case 14:case"end":return t.stop()}}),n,this)})))}},{key:"updateCurrentUserInfoWithPreferredLanguages",value:function(e){return b(this,void 0,void 0,t().mark((function n(){var r,a,s,i,o,u,c;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(Za(F("string",e)).throw(A.invalidParameters),!this.currentUser){t.next=12;break}return r=fs.of(this._iid),a=r.sdkState,s=r.requestQueue,i=new _u({userId:a.userId,preferredLanguages:e}),t.next=6,s.send(i);case 6:return o=t.sent,u=o.as(mu),c=u.user,this.currentUser&&(this.currentUser.preferredLanguages=c.preferredLanguages),t.abrupt("return",c);case 12:throw A.connectionRequired;case 13:case"end":return t.stop()}}),n,this)})))}},{key:"registerFCMPushTokenForCurrentUser",value:function(n){return b(this,void 0,void 0,t().mark((function r(){var a,s,i,o,u,c=this;return t().wrap((function(r){for(;;)switch(r.prev=r.next){case 0:if(Za(L("string",n)).throw(A.invalidParameters),!this.currentUser){r.next=20;break}if(r.prev=2,a=fs.of(this._iid),s=a.sessionManager,i=a.sdkState,o=a.requestQueue,!s.hasDeviceToken(e.PushTokenType.FCM,n)){r.next=6;break}return r.abrupt("return",e.PushTokenRegistrationState.SUCCESS);case 6:return u=new yu({userId:i.userId,token:n}),r.next=9,o.send(u);case 9:return r.next=11,xa((function(){return b(c,void 0,void 0,t().mark((function r(){return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return s.setDeviceToken(e.PushTokenType.FCM,n),t.next=3,s.saveDeviceToken();case 3:case"end":return t.stop()}}),r)})))}));case 11:return this._fcmPushToken="",r.abrupt("return",e.PushTokenRegistrationState.SUCCESS);case 15:return r.prev=15,r.t0=r.catch(2),r.abrupt("return",e.PushTokenRegistrationState.ERROR);case 18:r.next=22;break;case 20:return this._fcmPushToken=n,r.abrupt("return",e.PushTokenRegistrationState.PENDING);case 22:case"end":return r.stop()}}),r,this,[[2,15]])})))}},{key:"unregisterFCMPushTokenForCurrentUser",value:function(n){return b(this,void 0,void 0,t().mark((function r(){var a,s,i,o,u,c,l,h=this;return t().wrap((function(r){for(;;)switch(r.prev=r.next){case 0:if(Za(L("string",n)).throw(A.invalidParameters),!this.currentUser){r.next=20;break}return r.prev=2,a=fs.of(this._iid),s=a.sessionManager,i=a.sdkState,o=a.requestQueue,u=new bu({userId:i.userId,token:n}),r.next=7,o.send(u);case 7:return c=r.sent,l=c.lastDeletedAt,r.next=11,xa((function(){return b(h,void 0,void 0,t().mark((function r(){return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return s.unsetDeviceToken(e.PushTokenType.FCM,n),s.setDeviceTokenDeletedAt(l),t.next=4,s.saveDeviceToken();case 4:case"end":return t.stop()}}),r)})))}));case 11:return this._fcmPushToken="",r.abrupt("return",e.PushTokenRegistrationState.SUCCESS);case 15:return r.prev=15,r.t0=r.catch(2),r.abrupt("return",e.PushTokenRegistrationState.ERROR);case 18:r.next=22;break;case 20:return this._fcmPushToken=n,r.abrupt("return",e.PushTokenRegistrationState.PENDING);case 22:case"end":return r.stop()}}),r,this,[[2,15]])})))}},{key:"unregisterFCMPushTokenAllForCurrentUser",value:function(){return b(this,void 0,void 0,t().mark((function n(){var r,a,s,i,o,u,c,l=this;return t().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:if(!this.currentUser){n.next=9;break}return r=fs.of(this._iid),a=r.sessionManager,s=r.sdkState,i=r.requestQueue,o=new wu({userId:s.userId}),n.next=5,i.send(o);case 5:return u=n.sent,c=u.lastDeletedAt,n.next=9,xa((function(){return b(l,void 0,void 0,t().mark((function n(){return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return a.unsetDeviceTokens(e.PushTokenType.FCM),a.setDeviceTokenDeletedAt(c),t.next=4,a.saveDeviceToken();case 4:case"end":return t.stop()}}),n)})))}));case 9:case"end":return n.stop()}}),n,this)})))}},{key:"registerAPNSPushTokenForCurrentUser",value:function(n){return b(this,void 0,void 0,t().mark((function r(){var a,s,i,o,u,c=this;return t().wrap((function(r){for(;;)switch(r.prev=r.next){case 0:if(Za(L("string",n)).throw(A.invalidParameters),!this.currentUser){r.next=20;break}if(r.prev=2,a=fs.of(this._iid),s=a.sessionManager,i=a.sdkState,o=a.requestQueue,!s.hasDeviceToken(e.PushTokenType.APNS,n)){r.next=6;break}return r.abrupt("return",e.PushTokenRegistrationState.SUCCESS);case 6:return u=new gu({userId:i.userId,token:n}),r.next=9,o.send(u);case 9:return r.next=11,xa((function(){return b(c,void 0,void 0,t().mark((function r(){return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return s.setDeviceToken(e.PushTokenType.APNS,n),t.next=3,s.saveDeviceToken();case 3:case"end":return t.stop()}}),r)})))}));case 11:return this._apnsPushToken="",r.abrupt("return",e.PushTokenRegistrationState.SUCCESS);case 15:return r.prev=15,r.t0=r.catch(2),r.abrupt("return",e.PushTokenRegistrationState.ERROR);case 18:r.next=22;break;case 20:return this._apnsPushToken=n,r.abrupt("return",e.PushTokenRegistrationState.PENDING);case 22:case"end":return r.stop()}}),r,this,[[2,15]])})))}},{key:"unregisterAPNSPushTokenForCurrentUser",value:function(n){return b(this,void 0,void 0,t().mark((function r(){var a,s,i,o,u,c,l,h=this;return t().wrap((function(r){for(;;)switch(r.prev=r.next){case 0:if(Za(L("string",n)).throw(A.invalidParameters),!this.currentUser){r.next=20;break}return r.prev=2,a=fs.of(this._iid),s=a.sessionManager,i=a.sdkState,o=a.requestQueue,u=new ku({userId:i.userId,token:n}),r.next=7,o.send(u);case 7:return c=r.sent,l=c.lastDeletedAt,r.next=11,xa((function(){return b(h,void 0,void 0,t().mark((function r(){return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return s.unsetDeviceToken(e.PushTokenType.APNS,n),s.setDeviceTokenDeletedAt(l),t.next=4,s.saveDeviceToken();case 4:case"end":return t.stop()}}),r)})))}));case 11:return this._apnsPushToken="",r.abrupt("return",e.PushTokenRegistrationState.SUCCESS);case 15:return r.prev=15,r.t0=r.catch(2),r.abrupt("return",e.PushTokenRegistrationState.ERROR);case 18:r.next=22;break;case 20:return this._apnsPushToken=n,r.abrupt("return",e.PushTokenRegistrationState.PENDING);case 22:case"end":return r.stop()}}),r,this,[[2,15]])})))}},{key:"unregisterAPNSPushTokenAllForCurrentUser",value:function(){return b(this,void 0,void 0,t().mark((function n(){var r,a,s,i,o,u,c,l=this;return t().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:if(!this.currentUser){n.next=9;break}return r=fs.of(this._iid),a=r.sessionManager,s=r.sdkState,i=r.requestQueue,o=new Eu({userId:s.userId}),n.next=5,i.send(o);case 5:return u=n.sent,c=u.lastDeletedAt,n.next=9,xa((function(){return b(l,void 0,void 0,t().mark((function n(){return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return a.unsetDeviceTokens(e.PushTokenType.APNS),a.setDeviceTokenDeletedAt(c),t.next=4,a.saveDeviceToken();case 4:case"end":return t.stop()}}),n)})))}));case 9:case"end":return n.stop()}}),n,this)})))}},{key:"getChannelInvitationPreference",value:function(){return b(this,void 0,void 0,t().mark((function e(){var n,r,a,s,i,o,u;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n=fs.of(this._iid),r=n.sdkState,a=n.requestQueue,s=new Tu({userId:r.userId}),e.next=4,a.send(s);case 4:return i=e.sent,o=i.as(Su),u=o.autoAccept,e.abrupt("return",{autoAccept:u});case 7:case"end":return e.stop()}}),e,this)})))}},{key:"setChannelInvitationPreference",value:function(e){return b(this,void 0,void 0,t().mark((function n(){var r,a,s,i,o,u,c;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return Za(L("boolean",e)).throw(A.invalidParameters),r=fs.of(this._iid),a=r.sdkState,s=r.requestQueue,i=new Iu({userId:a.userId,willAutoAccept:e}),t.next=5,s.send(i);case 5:return o=t.sent,u=o.as(Nu),c=u.autoAccept,t.abrupt("return",{autoAccept:c});case 8:case"end":return t.stop()}}),n,this)})))}},{key:"getDoNotDisturb",value:function(){return b(this,void 0,void 0,t().mark((function e(){var n,r,a,s,i,o,u;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n=fs.of(this._iid),r=n.sdkState,a=n.requestQueue,s=new Mu({userId:r.userId}),e.next=4,a.send(s);case 4:return i=e.sent,o=i.as(Au),u=o.preference,e.abrupt("return",u);case 7:case"end":return e.stop()}}),e,this)})))}},{key:"setDoNotDisturb",value:function(e){var n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:0,a=arguments.length>3&&void 0!==arguments[3]?arguments[3]:0,s=arguments.length>4&&void 0!==arguments[4]?arguments[4]:0,i=arguments.length>5&&void 0!==arguments[5]?arguments[5]:"";return b(this,void 0,void 0,t().mark((function o(){var u,c,l,h,d,f,p;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return Za(L("boolean",e)&&L("number",n)&&L("number",r)&&L("number",a)&&L("number",s)&&L("string",i)).throw(A.invalidParameters),u=fs.of(this._iid),c=u.sdkState,l=u.requestQueue,h=new Ou({userId:c.userId,doNotDisturbOn:e,startHour:n,startMin:r,endHour:a,endMin:s,timezone:i}),t.next=5,l.send(h);case 5:return d=t.sent,f=d.as(Uu),p=f.preference,t.abrupt("return",p);case 8:case"end":return t.stop()}}),o,this)})))}},{key:"getSnoozePeriod",value:function(){return b(this,void 0,void 0,t().mark((function e(){var n,r,a,s,i,o,u;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n=fs.of(this._iid),r=n.sdkState,a=n.requestQueue,s=new Ru({userId:r.userId}),e.next=4,a.send(s);case 4:return i=e.sent,o=i.as(Lu),u=o.snoozePeriod,e.abrupt("return",u);case 7:case"end":return e.stop()}}),e,this)})))}},{key:"setSnoozePeriod",value:function(e){var n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:0;return b(this,void 0,void 0,t().mark((function a(){var s,i,o,u,c,l,h;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return Za(L("boolean",e)&&L("number",n)&&L("number",r)).throw(A.invalidParameters),s=fs.of(this._iid),i=s.sdkState,o=s.requestQueue,u=new Du({userId:i.userId,snoozeOn:e,startTs:n,endTs:r}),t.next=5,o.send(u);case 5:return c=t.sent,l=c.as(Pu),h=l.snoozePeriod,t.abrupt("return",h);case 8:case"end":return t.stop()}}),a,this)})))}},{key:"getMyPushTokensByToken",value:function(n,r){return b(this,void 0,void 0,t().mark((function a(){var s,i,o,u,c,l,h,d,f,p,v;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return Za(L("string",n)&&D(e.PushTokenType,r)).throw(A.invalidParameters),s=fs.of(this._iid),i=s.sdkState,o=s.requestQueue,u=s.sessionManager,c=new Cu({userId:i.userId,type:r,token:n}),t.next=5,o.send(c);case 5:l=t.sent,h=l.as(xu),d=h.pushTokens,f=y(d.deviceTokens);try{for(f.s();!(p=f.n()).done;)v=p.value,u.setDeviceToken(d.type,v)}catch(e){f.e(e)}finally{f.f()}return t.next=11,u.saveDeviceToken();case 11:return t.abrupt("return",d);case 12:case"end":return t.stop()}}),a,this)})))}},{key:"getPushTriggerOption",value:function(){return b(this,void 0,void 0,t().mark((function e(){var n,r,a,s,i;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n=fs.of(this._iid),r=n.sdkState,a=n.requestQueue,s=new qu({userId:r.userId}),e.next=4,a.send(s);case 4:return i=e.sent,e.abrupt("return",i.as(Hu).pushTriggerOption);case 6:case"end":return e.stop()}}),e,this)})))}},{key:"setPushTriggerOption",value:function(n){return b(this,void 0,void 0,t().mark((function r(){var a,s,i,o,u;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return Za(D(e.PushTriggerOption,n)).throw(A.invalidParameters),a=fs.of(this._iid),s=a.sdkState,i=a.requestQueue,o=new ju({userId:s.userId,pushTriggerOption:n}),t.next=5,i.send(o);case 5:return u=t.sent,t.abrupt("return",u.as(zu).pushTriggerOption);case 7:case"end":return t.stop()}}),r,this)})))}},{key:"getPushTemplate",value:function(){return b(this,void 0,void 0,t().mark((function e(){var n,r,a,s,i;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n=fs.of(this._iid),r=n.sdkState,a=n.requestQueue,s=new Vu({userId:r.userId}),e.next=4,a.send(s);case 4:return i=e.sent,e.abrupt("return",i.as(Bu).name);case 6:case"end":return e.stop()}}),e,this)})))}},{key:"setPushTemplate",value:function(n){return b(this,void 0,void 0,t().mark((function r(){var a,s,i,o,u;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return Za(D(e.PushTemplate,n)).throw(A.invalidParameters),a=fs.of(this._iid),s=a.sdkState,i=a.requestQueue,o=new Qu({userId:s.userId,templateName:n}),t.next=5,i.send(o);case 5:return u=t.sent,t.abrupt("return",u.as(Ku).name);case 7:case"end":return t.stop()}}),r,this)})))}},{key:"blockUser",value:function(e){return b(this,void 0,void 0,t().mark((function n(){var r,a,s,i;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return Za(e instanceof Xa||L("string",e)).throw(A.invalidParameters),r=fs.of(this._iid),a=r.sdkState,s=r.requestQueue,i=new Fu({userId:a.userId,blockedUserId:e instanceof Xa?e.userId:e}),t.next=5,s.send(i);case 5:case"end":return t.stop()}}),n,this)})))}},{key:"blockUserWithUserId",value:function(e){return b(this,void 0,void 0,t().mark((function n(){return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.abrupt("return",this.blockUser(e));case 1:case"end":return t.stop()}}),n,this)})))}},{key:"unblockUser",value:function(e){return b(this,void 0,void 0,t().mark((function n(){var r,a,s,i;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return Za(e instanceof Xa||L("string",e)).throw(A.invalidParameters),r=fs.of(this._iid),a=r.sdkState,s=r.requestQueue,i=new Gu({userId:a.userId,unblockedUserId:e instanceof Xa?e.userId:e}),t.next=5,s.send(i);case 5:case"end":return t.stop()}}),n,this)})))}},{key:"unblockUserWithUserId",value:function(e){return b(this,void 0,void 0,t().mark((function n(){return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.abrupt("return",this.unblockUser(e));case 1:case"end":return t.stop()}}),n,this)})))}},{key:"getFriendChangeLogsByToken",value:function(e){return b(this,void 0,void 0,t().mark((function n(){var r,a,s,i,o,u,c;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return Za(L("string",e)).throw(A.invalidParameters),r=fs.of(this._iid),a=r.sdkState,s=r.requestQueue,i=new Wu({userId:a.userId,token:e}),t.next=5,s.send(i);case 5:return o=t.sent,u=o.as(Yu),c=u.changelogs,t.abrupt("return",c);case 8:case"end":return t.stop()}}),n,this)})))}},{key:"getAllowFriendDiscovery",value:function(){return b(this,void 0,void 0,t().mark((function e(){var n,r,a,s,i,o,u;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n=fs.of(this._iid),r=n.sdkState,a=n.requestQueue,s=new nc({userId:r.userId}),e.next=4,a.send(s);case 4:return i=e.sent,o=i.as(rc),u=o.allowFriendDiscovery,e.abrupt("return",u);case 7:case"end":return e.stop()}}),e,this)})))}},{key:"setAllowFriendDiscovery",value:function(e){return b(this,void 0,void 0,t().mark((function n(){var r,a,s,i;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return Za(L("boolean",e)).throw(A.invalidParameters),r=fs.of(this._iid),a=r.sdkState,s=r.requestQueue,i=new ac({userId:a.userId,allowFriendDiscovery:e}),t.next=5,s.send(i);case 5:return t.abrupt("return",e);case 6:case"end":return t.stop()}}),n,this)})))}},{key:"uploadFriendDiscoveries",value:function(e){return b(this,void 0,void 0,t().mark((function n(){var r,a,s,i,o,u,c;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return r=fs.of(this._iid),a=r.sdkState,s=r.requestQueue,i=new Zu({userId:a.userId,discoveries:e}),t.next=4,s.send(i);case 4:return o=t.sent,u=o.as(Ju),c=u.friendDiscoveryRequestId,t.abrupt("return",c);case 7:case"end":return t.stop()}}),n,this)})))}},{key:"deleteFriendDiscovery",value:function(e){return b(this,void 0,void 0,t().mark((function n(){return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.abrupt("return",this.deleteFriendDiscoveries([e]));case 1:case"end":return t.stop()}}),n,this)})))}},{key:"deleteFriendDiscoveries",value:function(e){return b(this,void 0,void 0,t().mark((function n(){var r,a,s,i;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return Za(F("string",e)).throw(A.invalidParameters),r=fs.of(this._iid),a=r.sdkState,s=r.requestQueue,i=new Xu({userId:a.userId,discoveryKeys:e}),t.next=5,s.send(i);case 5:case"end":return t.stop()}}),n,this)})))}},{key:"addFriends",value:function(e){return b(this,void 0,void 0,t().mark((function n(){var r,a,s,i,o,u,c;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return Za(F("string",e)).throw(A.invalidParameters),r=fs.of(this._iid),a=r.sdkState,s=r.requestQueue,i=new $u({userId:a.userId,userIds:e}),t.next=5,s.send(i);case 5:return o=t.sent,u=o.as(ec),c=u.users,t.abrupt("return",c);case 8:case"end":return t.stop()}}),n,this)})))}},{key:"deleteFriend",value:function(e){return b(this,void 0,void 0,t().mark((function n(){return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.abrupt("return",this.deleteFriends([e]));case 1:case"end":return t.stop()}}),n,this)})))}},{key:"deleteFriends",value:function(e){return b(this,void 0,void 0,t().mark((function n(){var r,a,s,i;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return Za(F("string",e)).throw(A.invalidParameters),r=fs.of(this._iid),a=r.sdkState,s=r.requestQueue,i=new tc({userId:a.userId,userIds:e}),t.next=5,s.send(i);case 5:case"end":return t.stop()}}),n,this)})))}},{key:"getAllEmoji",value:function(){return b(this,void 0,void 0,t().mark((function e(){var n,r,a,s,i,o;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n=fs.of(this._iid),r=n.requestQueue,a=new uc,e.next=4,r.send(a);case 4:return s=e.sent,i=s.as(cc),o=i.emojiContainer,e.abrupt("return",o);case 7:case"end":return e.stop()}}),e,this)})))}},{key:"getEmojiCategory",value:function(e){return b(this,void 0,void 0,t().mark((function n(){var r,a,s,i,o,u;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return r=fs.of(this._iid),a=r.requestQueue,s=new lc({categoryId:e}),t.next=4,a.send(s);case 4:return i=t.sent,o=i.as(hc),u=o.emojiCategory,t.abrupt("return",u);case 7:case"end":return t.stop()}}),n,this)})))}},{key:"getEmoji",value:function(e){return b(this,void 0,void 0,t().mark((function n(){var r,a,s,i,o,u;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return r=fs.of(this._iid),a=r.requestQueue,s=new dc({key:e}),t.next=4,a.send(s);case 4:return i=t.sent,o=i.as(fc),u=o.emoji,t.abrupt("return",u);case 7:case"end":return t.stop()}}),n,this)})))}},{key:"getUIKitConfiguration",value:function(){return b(this,void 0,void 0,t().mark((function e(){var n,r,a,s,i,o;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n=fs.of(this._iid),Za(n.hasExtension("sb_uikit")).throw(A.notSupportedError),r=n.requestQueue,a=new pc,e.next=6,r.send(a);case 6:return s=e.sent,i=s.as(vc),o=i.uikitConfiguration,e.abrupt("return",o);case 9:case"end":return e.stop()}}),e,this)})))}}],[{key:"init",value:function(e){var t=e.appId,r=e.appVersion,a=e.modules,s=void 0===a?[]:a,i=e.options,o=void 0===i?new H:i,u=e.debugMode,c=void 0!==u&&u,l=e.customApiHost,h=e.customWebSocketHost,d=e.newInstance,f=void 0!==d&&d,p=e.logLevel,v=e.localCacheEnabled,m=void 0!==v&&v,g=e.localCacheConfig,y=void 0===g?new te:g,k=e.localCacheEncryption,b=e.useAsyncStorageStore,E=void 0===b?null:b,w=e.appStateToggleEnabled,C=void 0===w||w;if(!ql||f){var x="su-".concat(re()),T=null!=k?k:{encrypt:function(e){return e},decrypt:function(e){return e}},S=new ll({encryption:T});c||(S=Fe()?E?new pl({AsyncStorage:E,encryption:T}):new ll({encryption:T}):new fl({encryption:T})),new fs(x,{appId:t,appVersion:r,options:o,apiHost:null!=l?l:"https://api-".concat(t,".sendbird.com"),websocketHost:null!=h?h:"wss://ws-".concat(t,".sendbird.com"),store:S,encryption:T,logLevel:p,localCacheEnabled:m,localCacheConfig:y,debugMode:c,appStateToggleEnabled:C});var I=[new qi,new ho],N=new n(x,o,[].concat(_(s),I));return ql||(ql=N),N}return ql}},{key:"instance",get:function(){return ql}},{key:"version",get:function(){return w}}]),n}();e.MemberState=void 0,(Hl=e.MemberState||(e.MemberState={})).NONE="none",Hl.JOINED="joined",Hl.INVITED="invited",Hl.LEFT="left";var ad,sd,id,od,ud,cd,ld,hd,dd=function(t){i(a,t);var n=f(a);function a(t,s){var i;return r(this,a),(i=n.call(this,t,s)).state=null,i.role=null,i.isMuted=!1,i.isBlockedByMe=!1,i.isBlockingMe=!1,i.state=D(e.MemberState,s.state)?s.state:null,i.role=D(e.Role,s.role)?s.role:null,"boolean"==typeof s.is_muted&&(i.isMuted=s.is_muted),"boolean"==typeof s.is_blocked_by_me&&(i.isBlockedByMe=s.is_blocked_by_me),"boolean"==typeof s.is_blocking_me&&(i.isBlockingMe=s.is_blocking_me),i}return s(a,null,[{key:"payloadify",value:function(e){return ue(ce(Object.assign(Object.assign({},p(o(a),"payloadify",this).call(this,e)),{state:e.state,role:e.role,is_muted:e.isMuted,is_blocked_by_me:e.isBlockedByMe,is_blocking_me:e.isBlockingMe})))}}]),a}(wl),fd=function(t){i(a,t);var n=f(a);function a(t,s){var i,o,u;return r(this,a),(i=n.call(this,t)).channelUrl=null!==(o=s.channel_url)&&void 0!==o?o:"",i.channelType=null!==(u=s.channel_type)&&void 0!==u?u:e.ChannelType.GROUP,i.reader=new Xa(i._iid,s.user),i.readAt=s.ts,i}return s(a)}(Ha);e.PublicChannelFilter=void 0,(ad=e.PublicChannelFilter||(e.PublicChannelFilter={})).ALL="all",ad.PUBLIC="public",ad.PRIVATE="private",e.MyMemberStateFilter=void 0,(sd=e.MyMemberStateFilter||(e.MyMemberStateFilter={})).ALL="all",sd.JOINED="joined_only",sd.INVITED="invited_only",sd.INVITED_BY_FRIEND="invited_by_friend",sd.INVITED_BY_NON_FRIEND="invited_by_non_friend",e.SuperChannelFilter=void 0,(id=e.SuperChannelFilter||(e.SuperChannelFilter={})).ALL="all",id.SUPER="super",id.NON_SUPER="nonsuper",id.BROADCAST_ONLY="broadcast_only",id.EXCLUSIVE_ONLY="exclusive_only",e.UnreadChannelFilter=void 0,(od=e.UnreadChannelFilter||(e.UnreadChannelFilter={})).ALL="all",od.UNREAD_MESSAGE="unread_message",e.HiddenChannelFilter=void 0,(ud=e.HiddenChannelFilter||(e.HiddenChannelFilter={})).ALL="all",ud.UNHIDDEN="unhidden_only",ud.HIDDEN="hidden_only",ud.HIDDEN_ALLOW_AUTO_UNHIDE="hidden_allow_auto_unhide",ud.HIDDEN_PREVENT_AUTO_UNHIDE="hidden_prevent_auto_unhide",e.OperatorFilter=void 0,(cd=e.OperatorFilter||(e.OperatorFilter={})).ALL="all",cd.OPERATOR="operator",cd.NONOPERATOR="nonoperator",e.QueryType=void 0,(ld=e.QueryType||(e.QueryType={})).AND="AND",ld.OR="OR",e.GroupChannelSearchField=void 0,(hd=e.GroupChannelSearchField||(e.GroupChannelSearchField={})).MEMBER_NICKNAME="member_nickname",hd.CHANNEL_NAME="channel_name";var pd,vd=function(){function t(){r(this,t),this._searchFilter=null,this._userIdsFilter=null,this.includeEmpty=!1,this.nicknameContainsFilter=null,this.nicknameStartsWithFilter=null,this.nicknameExactMatchFilter=null,this.channelNameContainsFilter="",this.myMemberStateFilter=e.MyMemberStateFilter.ALL,this.customTypesFilter=null,this.channelUrlsFilter=null,this.superChannelFilter=e.SuperChannelFilter.ALL,this.publicChannelFilter=e.PublicChannelFilter.ALL,this.customTypeStartsWithFilter=null,this.unreadChannelFilter=e.UnreadChannelFilter.ALL,this.hiddenChannelFilter=e.HiddenChannelFilter.UNHIDDEN,this.includeFrozen=!0}return s(t,[{key:"_isFriend",value:function(e){return!(!e||!e.friendDiscoveryKey&&!e.friendName)}},{key:"searchFilter",get:function(){return this._searchFilter}},{key:"setSearchFilter",value:function(e,t){Array.isArray(e)&&0!==e.length&&"string"==typeof t&&t&&(this._searchFilter={query:t,fields:e})}},{key:"userIdsFilter",get:function(){return this._userIdsFilter}},{key:"setUserIdsFilter",value:function(t,n){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:e.QueryType.AND;this._userIdsFilter={userIds:t,includeMode:n,queryType:r}}},{key:"clone",value:function(){var e,n=new t;this.searchFilter&&n.setSearchFilter(this.searchFilter.fields,null!==(e=this.searchFilter.query)&&void 0!==e?e:void 0),this.userIdsFilter&&n.setUserIdsFilter(this.userIdsFilter.userIds,this.userIdsFilter.includeMode,this.userIdsFilter.queryType);var r=JSON.parse(JSON.stringify(this));return Object.keys(r).forEach((function(e){n[e]=r[e]})),n}},{key:"match",value:function(t,n){if(this._searchFilter){var r=this._searchFilter,a=r.query,s=r.fields;if(a&&s&&s.length>0&&!s.some((function(n){switch(n){case e.GroupChannelSearchField.CHANNEL_NAME:return t.name.toLowerCase().includes(a.toLowerCase());case e.GroupChannelSearchField.MEMBER_NICKNAME:return t.members.some((function(e){return e.nickname.toLowerCase().includes(a.toLowerCase())}));default:return!0}})))return!1}if(this._userIdsFilter){var i=this._userIdsFilter,o=i.userIds,u=i.includeMode,c=i.queryType,l=t.members.map((function(e){return e.userId}));if(u){if(o.length>0)switch(c){case e.QueryType.AND:if(o.some((function(e){return!l.includes(e)})))return!1;break;case e.QueryType.OR:if(o.every((function(e){return!l.includes(e)})))return!1}}else{if(o.includes(n)||o.push(n),t.members.length>o.length)return!1;if(!function(e,t){if(e===t)return!0;if(null==e||null==t)return!1;if(e.length!==t.length)return!1;for(var n=_(e).sort(),r=_(t).sort(),a=0;a0&&!this.customTypesFilter.includes(t.customType))return!1;if(this.customTypeStartsWithFilter&&!new RegExp("^".concat(this.customTypeStartsWithFilter)).test(t.customType))return!1;if(this.channelNameContainsFilter&&!t.name.toLowerCase().includes(this.channelNameContainsFilter.toLowerCase()))return!1;if(this.nicknameContainsFilter){var h=this.nicknameContainsFilter.toLowerCase();if(!t.members.some((function(e){return e.userId!==n&&e.nickname.toLowerCase().includes(h)})))return!1}if(this.nicknameStartsWithFilter){var d=this.nicknameStartsWithFilter.toLowerCase();if(!t.members.some((function(e){return e.userId!==n&&e.nickname.toLowerCase().startsWith(d)})))return!1}if(this.nicknameExactMatchFilter){var f=this.nicknameExactMatchFilter.toLowerCase();if(!t.members.some((function(e){return e.userId!==n&&e.nickname.toLowerCase()!=f})))return!1}if(this.channelUrlsFilter&&this.channelUrlsFilter.length>0&&!this.channelUrlsFilter.includes(t.url))return!1;if(this.myMemberStateFilter)switch(this.myMemberStateFilter){case e.MyMemberStateFilter.JOINED:if("joined"!==t.myMemberState)return!1;break;case e.MyMemberStateFilter.INVITED:if("invited"!==t.myMemberState)return!1;break;case e.MyMemberStateFilter.INVITED_BY_FRIEND:if("invited"!==t.myMemberState||!this._isFriend(t.inviter))return!1;break;case e.MyMemberStateFilter.INVITED_BY_NON_FRIEND:if("invited"!==t.myMemberState||this._isFriend(t.inviter))return!1}if(this.hiddenChannelFilter)switch(this.hiddenChannelFilter){case e.HiddenChannelFilter.UNHIDDEN:if(t.isHidden||"unhidden"!==t.hiddenState)return!1;break;case e.HiddenChannelFilter.HIDDEN:if(!t.isHidden)return!1;break;case e.HiddenChannelFilter.HIDDEN_ALLOW_AUTO_UNHIDE:if(!t.isHidden||"hidden_allow_auto_unhide"!==t.hiddenState)return!1;break;case e.HiddenChannelFilter.HIDDEN_PREVENT_AUTO_UNHIDE:if(!t.isHidden||"hidden_prevent_auto_unhide"!==t.hiddenState)return!1}if(this.unreadChannelFilter&&this.unreadChannelFilter===e.UnreadChannelFilter.UNREAD_MESSAGE)if(0===t.unreadMessageCount)return!1;if(this.publicChannelFilter)switch(this.publicChannelFilter){case e.PublicChannelFilter.PUBLIC:if(!t.isPublic)return!1;break;case e.PublicChannelFilter.PRIVATE:if(t.isPublic)return!1}if(this.superChannelFilter)switch(this.superChannelFilter){case e.SuperChannelFilter.SUPER:if(!t.isSuper)return!1;break;case e.SuperChannelFilter.NON_SUPER:if(t.isSuper)return!1}return!0}}]),t}(),_d=function(n){i(o,n);var a=f(o);function o(e,t){var n,s=t.sdkState,i=t.cacheContext;return r(this,o),(n=a.call(this,e))._channels=new Map,n._sdkState=s,n._cacheContext=i,n}return s(o,[{key:"collection",get:function(){var e=this._cacheContext.nestdb;return Za(!!e).throw(A.databaseError),e.collection(go)}},{key:"localCacheEnabled",get:function(){return this._cacheContext.localCacheEnabled&&!!this.collection}},{key:"_serialize",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0;return Object.assign(Object.assign({},e.serialize()),{lastMessageUpdatedAt:e.lastMessage?e.lastMessage.createdAt:0,syncIndex:t})}},{key:"_deserialize",value:function(e){return Ff.of(this._iid).buildGroupChannelFromSerializedData(e)}},{key:"channels",get:function(){return _(this._channels.values())}},{key:"isCachedInMemory",value:function(e){return this._channels.has(e)}},{key:"filterOffsetChanged",value:function(e){var t=this;return e.filter((function(e){if(t._channels.has(e.url))return t._channels.get(e.url).messageOffsetTimestamp0)return!1;if(d&&d===t.url)return!1;break;case e.GroupChannelListOrder.CHRONOLOGICAL:if(!o&&t.createdAt>r||o&&t.createdAtr||o&&t.lastMessageUpdatedAt0)){t.next=76;break}return t.next=76,this.upsert(s);case 76:case"end":return t.stop()}}),a,this,[[3,30,33,36],[8,20,23,26],[40,67,70,73],[45,57,60,63]])})))}},{key:"block",value:function(e,n){return b(this,void 0,void 0,t().mark((function r(){return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,this._setBlockStateOfAllChannels(e,n,!0);case 2:case"end":return t.stop()}}),r,this)})))}},{key:"unblock",value:function(e,n){return b(this,void 0,void 0,t().mark((function r(){return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,this._setBlockStateOfAllChannels(e,n,!1);case 2:case"end":return t.stop()}}),r,this)})))}},{key:"markAsRead",value:function(e){var n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:_(this._channels.keys());return b(this,void 0,void 0,t().mark((function r(){var a,s,i,o,u;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:a=[],s=y(n),t.prev=2,s.s();case 4:if((i=s.n()).done){t.next=12;break}return o=i.value,t.next=8,this.get(o);case 8:(null==(u=t.sent)?void 0:u._updateUnreadMemberState(this._sdkState.userId,e))&&(u._updateUnreadCount(0,0),a.push(u));case 10:t.next=4;break;case 12:t.next=17;break;case 14:t.prev=14,t.t0=t.catch(2),s.e(t.t0);case 17:return t.prev=17,s.f(),t.finish(17);case 20:if(!(a.length>0)){t.next=23;break}return t.next=23,this.upsert(a);case 23:case"end":return t.stop()}}),r,this,[[2,14,17,20]])})))}}]),o}(Ha);!function(e){e[e.NONE=0]="NONE",e[e.CHANNEL_ENTER=10102]="CHANNEL_ENTER",e[e.CHANNEL_EXIT=10103]="CHANNEL_EXIT",e[e.USER_CHANNEL_MUTE=10201]="USER_CHANNEL_MUTE",e[e.USER_CHANNEL_UNMUTE=10200]="USER_CHANNEL_UNMUTE",e[e.USER_CHANNEL_BAN=10601]="USER_CHANNEL_BAN",e[e.USER_CHANNEL_UNBAN=10600]="USER_CHANNEL_UNBAN",e[e.CHANNEL_FREEZE=10701]="CHANNEL_FREEZE",e[e.CHANNEL_UNFREEZE=10700]="CHANNEL_UNFREEZE",e[e.TYPING_START=10900]="TYPING_START",e[e.TYPING_END=10901]="TYPING_END",e[e.CHANNEL_JOIN=1e4]="CHANNEL_JOIN",e[e.CHANNEL_LEAVE=10001]="CHANNEL_LEAVE",e[e.CHANNEL_OPERATOR_UPDATE=10002]="CHANNEL_OPERATOR_UPDATE",e[e.CHANNEL_INVITE=10020]="CHANNEL_INVITE",e[e.CHANNEL_ACCEPT_INVITE=10021]="CHANNEL_ACCEPT_INVITE",e[e.CHANNEL_DECLINE_INVITE=10022]="CHANNEL_DECLINE_INVITE",e[e.CHANNEL_PROP_CHANGED=11e3]="CHANNEL_PROP_CHANGED",e[e.CHANNEL_DELETED=12e3]="CHANNEL_DELETED",e[e.CHANNEL_META_DATA_CHANGED=11100]="CHANNEL_META_DATA_CHANGED",e[e.CHANNEL_META_COUNTERS_CHANGED=11200]="CHANNEL_META_COUNTERS_CHANGED",e[e.CHANNEL_HIDE=13e3]="CHANNEL_HIDE",e[e.CHANNEL_UNHIDE=13001]="CHANNEL_UNHIDE",e[e.PINNED_MESSAGE_CHANGED=11300]="PINNED_MESSAGE_CHANGED"}(pd||(pd={}));var md,gd=function(){function t(e){var n;r(this,t),this.channelUrl=e.channel_url,this.channelType=e.channel_type,this.category=e.cat,this.data=null!==(n=e.data)&&void 0!==n?n:{},this.ts=e.ts}return s(t,[{key:"isGroupChannelEvent",get:function(){return this.channelType===e.ChannelType.GROUP}},{key:"isOpenChannelEvent",get:function(){return this.channelType===e.ChannelType.OPEN}}]),t}(),yd={invitedUserIds:void 0,channelUrl:void 0,coverUrl:void 0,coverImage:void 0,isDistinct:void 0,isSuper:void 0,isBroadcast:void 0,isExclusive:void 0,isPublic:void 0,isDiscoverable:void 0,isStrict:void 0,isEphemeral:void 0,accessCode:void 0,name:void 0,data:void 0,customType:void 0,operatorUserIds:void 0,messageSurvivalSeconds:void 0},kd=function(e){return F("string",e.invitedUserIds,!0)&&L("string",e.channelUrl,!0)&&L("string",e.coverUrl,!0)&&(q(e.coverImage)||L("string",e.coverImage,!0))&&L("boolean",e.isDistinct,!0)&&L("boolean",e.isSuper,!0)&&L("boolean",e.isBroadcast,!0)&&L("boolean",e.isExclusive,!0)&&L("boolean",e.isPublic,!0)&&L("boolean",e.isStrict,!0)&&L("boolean",e.isDiscoverable,!0)&&L("boolean",e.isEphemeral,!0)&&L("string",e.accessCode,!0)&&L("string",e.name,!0)&&L("string",e.data,!0)&&L("string",e.customType,!0)&&F("string",e.operatorUserIds,!0)&&L("number",e.messageSurvivalSeconds,!0)},bd={customTypes:void 0,includeEmpty:!1,includeFrozen:!0},Ed=function(e){return F("string",e.customTypes,!0)&&L("boolean",e.includeEmpty)&&L("boolean",e.includeFrozen)},wd={myMemberStateFilter:e.MyMemberStateFilter.ALL},Cd=function(t){return D(e.MyMemberStateFilter,t.myMemberStateFilter)};e.UnreadItemKey=void 0,(md=e.UnreadItemKey||(e.UnreadItemKey={})).GROUP_CHANNEL_UNREAD_MENTION_COUNT="group_channel_unread_mention_count",md.NONSUPER_UNREAD_MENTION_COUNT="non_super_group_channel_unread_mention_count",md.SUPER_UNREAD_MENTION_COUNT="super_group_channel_unread_mention_count",md.GROUP_CHANNEL_UNREAD_MESSAGE_COUNT="group_channel_unread_message_count",md.NONSUPER_UNREAD_MESSAGE_COUNT="non_super_group_channel_unread_message_count",md.SUPER_UNREAD_MESSAGE_COUNT="super_group_channel_unread_message_count",md.GROUP_CHANNEL_INVITATION_COUNT="group_channel_invitation_count",md.NONSUPER_INVITATION_COUNT="non_super_group_channel_invitation_count",md.SUPER_INVITATION_COUNT="super_group_channel_invitation_count";var xd,Td={keys:[]},Sd=function(t){return F(e.UnreadItemKey,t.keys)},Id={channelCustomTypesFilter:void 0,superChannelFilter:e.SuperChannelFilter.ALL},Nd=function(t){return F("string",t.channelCustomTypesFilter,!0)&&D(e.SuperChannelFilter,t.superChannelFilter)},Md={channelUrl:void 0,scheduledStatus:void 0,messageTypeFilter:e.MessageTypeFilter.ALL},Ad=function(t){return L("string",t.channelUrl,!0)&&F(e.ScheduledStatus,t.scheduledStatus,!0)&&D(e.MessageTypeFilter,t.messageTypeFilter)},Od=function(){function e(n){var a=this,s=n.groupChannelCache,i=n.messageCache,o=n.unsentMessageCache,u=n.dispatcher;r(this,e),this._observers=new Map,u.on((function(e){return b(a,void 0,void 0,t().mark((function n(){var r,a,u,c,l,h,d,f,p,v,_,m,g,k=this;return t().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:if(!(e instanceof du)){n.next=27;break}r=e.channels,a=e.source,u=e.isWebSocketEventComing,c=e.data,l=r.filter((function(e){return e instanceof Kp})),h=s.filterOffsetChanged(l),d=y(h),n.prev=5,d.s();case 7:if((f=d.n()).done){n.next=13;break}return p=f.value,n.next=11,i.removeUnderOffset(p.url,p.messageOffsetTimestamp);case 11:n.next=7;break;case 13:n.next=18;break;case 15:n.prev=15,n.t0=n.catch(5),d.e(n.t0);case 18:return n.prev=18,d.f(),n.finish(18);case 21:return n.next=23,s.upsert(l);case 23:v=n.sent,u||this._broadcastUpdateEvent(v,a,c),n.next=39;break;case 27:if(!(e instanceof fu)){n.next=36;break}return _=e.channelUrls,m=e.source,g=e.isWebSocketEventComing,n.next=31,s.remove(_);case 31:return n.next=33,xa((function(){return b(k,void 0,void 0,t().mark((function e(){var n,r,a;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:n=y(_),e.prev=1,n.s();case 3:if((r=n.n()).done){e.next=11;break}return a=r.value,e.next=7,i.removeMessagesOfChannel(a);case 7:return e.next=9,o.removeMessagesOfChannel(a);case 9:e.next=3;break;case 11:e.next=16;break;case 13:e.prev=13,e.t0=e.catch(1),n.e(e.t0);case 16:return e.prev=16,n.f(),e.finish(16);case 19:case"end":return e.stop()}}),e,null,[[1,13,16,19]])})))}));case 33:g||this._broadcastRemoveEvent(_,m),n.next=39;break;case 36:if(!(e instanceof cu)){n.next=39;break}return n.next=39,s.fetch({token:Number.MAX_SAFE_INTEGER,limit:Number.MAX_SAFE_INTEGER});case 39:case"end":return n.stop()}}),n,this,[[5,15,18,21]])})))}))}return s(e,[{key:"_broadcastUpdateEvent",value:function(e,t,n){var r,a=y(this._observers.values());try{for(a.s();!(r=a.n()).done;){var s=r.value;s.onUpdate&&s.onUpdate(e,t,n)}}catch(e){a.e(e)}finally{a.f()}}},{key:"_broadcastRemoveEvent",value:function(e,t){var n,r=y(this._observers.values());try{for(r.s();!(n=r.n()).done;){var a=n.value;a.onRemove&&a.onRemove(e,t)}}catch(e){r.e(e)}finally{r.f()}}},{key:"subscribe",value:function(e,t){this._observers.set(e,t)}},{key:"unsubscribe",value:function(e){this._observers.delete(e)}},{key:"unsubscribeAll",value:function(){this._observers.clear()}}]),e}(),Ud=function(){function e(n){var a=this,s=n.cacheContext,i=n.messageCache,o=n.unsentMessageCache,u=n.dispatcher,c=n.logger;r(this,e),this._observers=new Map,this._cacheContext=s,this._logger=c,u.on((function(e){return b(a,void 0,void 0,t().mark((function n(){var r,a,s,u,c,l,h,d,f,p,v,_,m,g,y,k,E,w,C,x,T=this;return t().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:if(!(e instanceof ui)){n.next=14;break}if(r=e.messages,a=e.source,s=e.isWebSocketEventComing,u=r.filter((function(e){return e.messageId>0})),c=r.filter((function(e){return 0===e.messageId})),!(u.length>0)){n.next=8;break}return n.next=7,xa((function(){return b(T,void 0,void 0,t().mark((function e(){return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,i.upsert(u);case 2:return e.next=4,o.remove(u.map((function(e){return e instanceof Ms?e.reqId:null})).filter((function(e){return null!==e})));case 4:case"end":return e.stop()}}),e)})))}));case 7:s||this._broadcastUpdateEvent(u,a);case 8:if(!(c.length>0)){n.next=12;break}return n.next=11,xa((function(){return b(T,void 0,void 0,t().mark((function e(){return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,o.upsert(c);case 2:case"end":return e.stop()}}),e)})))}));case 11:s||this._broadcastUpdateEvent(c,a);case 12:n.next=61;break;case 14:if(!(e instanceof ci)){n.next=21;break}return l=e.messageIds,h=e.source,d=e.isWebSocketEventComing,n.next=18,xa((function(){return b(T,void 0,void 0,t().mark((function e(){return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,i.remove(l);case 2:case"end":return e.stop()}}),e)})))}));case 18:d||this._broadcastRemoveEvent(l,h),n.next=61;break;case 21:if(!(e instanceof li)){n.next=28;break}return f=e.reqId,p=e.source,n.next=25,xa((function(){return b(T,void 0,void 0,t().mark((function e(){return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,o.remove([f]);case 2:case"end":return e.stop()}}),e)})))}));case 25:this._broadcastRemoveUnsentEvent(f,p),n.next=61;break;case 28:if(!(e instanceof hi)){n.next=41;break}if(v=e.polls,_=e.source,!this._cacheContext.localCacheEnabled){n.next=38;break}return m=v.map((function(e){return e.messageId})),n.next=34,Promise.all(m.map((function(e){return i.get(e)})));case 34:return g=n.sent.filter((function(e){return e})),g.length>0&&v.forEach((function(e){var t=g.find((function(t){return t.messageId===e.messageId}));t&&t.applyPoll(e)})),n.next=38,xa((function(){return b(T,void 0,void 0,t().mark((function e(){return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,i.upsert(g);case 2:return e.abrupt("return",e.sent);case 3:case"end":return e.stop()}}),e)})))}));case 38:this._broadcastPollChangeLogEvent(v,_),n.next=61;break;case 41:if(!(e instanceof di)){n.next=52;break}return y=e.event,k=e.source,n.next=45,i.get(y.messageId);case 45:if(!((E=n.sent)&&E.isUserMessage()&&E.poll&&E.poll.applyPollUpdateEvent(y))){n.next=49;break}return n.next=49,xa((function(){return b(T,void 0,void 0,t().mark((function e(){return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,i.upsert([E]);case 2:return e.abrupt("return",e.sent);case 3:case"end":return e.stop()}}),e)})))}));case 49:this._broadcastPollUpdateEvent(y,k),n.next=61;break;case 52:if(!(e instanceof fi)){n.next=61;break}return w=e.event,C=e.source,n.next=56,i.get(w.messageId);case 56:if(!((x=n.sent)&&x.isUserMessage()&&x.poll&&x.poll.applyPollVoteEvent(w))){n.next=60;break}return n.next=60,xa((function(){return b(T,void 0,void 0,t().mark((function e(){return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,i.upsert([x]);case 2:return e.abrupt("return",e.sent);case 3:case"end":return e.stop()}}),e)})))}));case 60:this._broadcastPollVoteEvent(w,C);case 61:case"end":return n.stop()}}),n,this)})))}))}return s(e,[{key:"_broadcastUpdateEvent",value:function(e,t){var n,r=y(this._observers.values());try{for(r.s();!(n=r.n()).done;){var a=n.value;a.onUpdate&&a.onUpdate(e,t)}}catch(e){r.e(e)}finally{r.f()}}},{key:"_broadcastPollChangeLogEvent",value:function(e,t){var n,r=y(this._observers.values());try{for(r.s();!(n=r.n()).done;){var a=n.value;a.onPollChangeLogUpdate&&a.onPollChangeLogUpdate(e,t)}}catch(e){r.e(e)}finally{r.f()}}},{key:"_broadcastPollUpdateEvent",value:function(e,t){var n,r=y(this._observers.values());try{for(r.s();!(n=r.n()).done;){var a=n.value;a.onPollUpdate&&a.onPollUpdate(e,t)}}catch(e){r.e(e)}finally{r.f()}}},{key:"_broadcastPollVoteEvent",value:function(e,t){var n,r=y(this._observers.values());try{for(r.s();!(n=r.n()).done;){var a=n.value;a.onPollVote&&a.onPollVote(e,t)}}catch(e){r.e(e)}finally{r.f()}}},{key:"_broadcastRemoveEvent",value:function(e,t){var n,r=y(this._observers.values());try{for(r.s();!(n=r.n()).done;){var a=n.value;a.onRemove&&a.onRemove(e,t)}}catch(e){r.e(e)}finally{r.f()}}},{key:"_broadcastRemoveUnsentEvent",value:function(e,t){var n,r=y(this._observers.values());try{for(r.s();!(n=r.n()).done;){var a=n.value;a.onRemoveUnsent&&a.onRemoveUnsent(e,t)}}catch(e){r.e(e)}finally{r.f()}}},{key:"subscribe",value:function(e,t){this._observers.set(e,t)}},{key:"unsubscribe",value:function(e){this._observers.delete(e)}},{key:"unsubscribeAll",value:function(){this._observers.clear()}}]),e}(),Rd=function(e){i(n,e);var t=f(n);function n(e){var a,s=e.userId,i=e.ts,o=e.token,u=e.filter;r(this,n),a=t.call(this);var c=Object.assign(Object.assign({},bd),u),l=c.customTypes,h=c.includeEmpty,d=c.includeFrozen;return a.method=le.GET,a.path="".concat(de,"/").concat(encodeURIComponent(s),"/my_group_channels/changelogs"),a.params=ue(ce({show_delivery_receipt:!0,show_member:!0,show_read_receipt:!0,change_ts:i||null,token:o,custom_types:l,show_empty:h,show_frozen:d})),a}return s(n)}(Oe),Ld=function(e){i(n,e);var t=f(n);function n(e,a){var s;return r(this,n),(s=t.call(this,e,a)).updatedChannels=a.updated.map((function(t){return new Kp(e,t)})),s.deletedChannelUrls=a.deleted,s.hasMore=a.has_more,s.token=a.next,s}return s(n)}(Ue),Dd=function(e){i(n,e);var t=f(n);function n(e){var a,s=e.channelUrl,i=e.isInternalCall;return r(this,n),(a=t.call(this)).method=le.GET,a.path="".concat(i?ve:pe,"/").concat(encodeURIComponent(s)),a.params={show_member:!0,show_read_receipt:!0,show_delivery_receipt:!0},a}return s(n)}(Oe),Pd=function(e){i(n,e);var t=f(n);function n(e,a){var s;return r(this,n),(s=t.call(this,e,a)).channel=new Kp(e,a),s}return s(n)}(Ue),Fd={includeEmpty:!1,includeFrozen:!0,includeMetaData:!0,channelUrlsFilter:void 0,customTypesFilter:void 0,customTypeStartsWithFilter:void 0,nicknameContainsFilter:void 0,nicknameStartsWithFilter:void 0,nicknameExactMatchFilter:void 0,channelNameContainsFilter:void 0,myMemberStateFilter:e.MyMemberStateFilter.ALL,unreadChannelFilter:e.UnreadChannelFilter.ALL,superChannelFilter:e.SuperChannelFilter.ALL,publicChannelFilter:e.PublicChannelFilter.ALL,hiddenChannelFilter:e.HiddenChannelFilter.ALL,userIdsFilter:{userIds:[],includeMode:!0,queryType:e.QueryType.AND},searchFilter:{query:void 0,fields:[]},metadataKey:void 0,metadataValues:void 0,metadataOrderKeyFilter:void 0,metadataValueStartsWith:void 0,order:e.GroupChannelListOrder.LATEST_LAST_MESSAGE},Gd=function(e){i(n,e);var t=f(n);function n(e){var a;r(this,n);var s=e.userId,i=e.token,o=e.limit,u=e.order,c=e.includeEmpty,l=e.myMemberStateFilter,h=e.superChannelFilter,d=e.publicChannelFilter,f=e.unreadChannelFilter,p=e.nicknameContainsFilter,v=e.nicknameStartsWithFilter,_=e.nicknameExactMatchFilter,m=e.channelNameContainsFilter,g=e.channelUrlsFilter,y=e.customTypesFilter,k=e.customTypeStartsWithFilter,b=e.hiddenChannelFilter,E=e.metadataOrderKeyFilter,w=e.metadataKey,C=e.metadataValues,x=e.metadataValueStartsWith,T=e.includeFrozen,S=e.includeMetaData,I=e.searchFilter,N=e.userIdsFilter;return(a=t.call(this)).method=le.GET,a.path="".concat(de,"/").concat(encodeURIComponent(s),"/my_group_channels"),a.params=ue({token:i,limit:o,order:null!=u?u:Fd.order,show_member:!0,show_read_receipt:!0,show_delivery_receipt:!0,show_empty:null!=c?c:Fd.includeEmpty,member_state_filter:null!=l?l:Fd.myMemberStateFilter,super_mode:null!=h?h:Fd.superChannelFilter,public_mode:null!=d?d:Fd.publicChannelFilter,unread_filter:null!=f?f:Fd.unreadChannelFilter,members_nickname_contains:p,members_nickname_startswith:v,members_nickname:_,name_contains:m,channel_urls:g,custom_types:y,custom_type_startswith:k,hidden_mode:b,metadata_order_key:E,metadata_key:w,metadata_values:C,metadata_value_startswith:x,show_frozen:T,show_metadata:S}),I&&I.query&&I.fields&&(a.params.search_query=I.query,a.params.search_fields=I.fields),N&&N.userIds&&N.userIds.length>0&&(N.includeMode?(a.params.members_include_in=N.userIds,a.params.query_type=N.queryType.toUpperCase()):a.params.members_exactly_in=N.userIds),a}return s(n)}(Oe),qd=function(e){i(n,e);var t=f(n);function n(e,a){var s;r(this,n),(s=t.call(this,e,a)).channels=[];var i=a.next,o=a.channels,u=a.ts;return s.token=i,o&&o.length>0&&(s.channels=o.map((function(t){return t.ts=u,new Kp(e,t)}))),s.ts=null!=u?u:0,s}return s(n)}(Ue),Hd=function(t){i(a,t);var n=f(a);function a(t){var s,i=t.userId,o=t.filter;r(this,a),s=n.call(this);var u=o.myMemberStateFilter;return s.method=le.GET,s.path="".concat(de,"/").concat(encodeURIComponent(i),"/group_channel_count"),s.params={state:null!=u?u:e.MyMemberStateFilter.ALL},s}return s(a)}(Oe),jd=function(e){i(n,e);var t=f(n);function n(e,a){var s;return r(this,n),(s=t.call(this,e,a)).groupChannelCount=a.group_channel_count,s}return s(n)}(Ue),zd=function(e){i(n,e);var t=f(n);function n(e){var a,s=e.userId,i=e.filter;r(this,n),a=t.call(this);var o=i.keys;return a.method=le.GET,a.path="".concat(de,"/").concat(encodeURIComponent(s),"/unread_item_count"),a.params=ue({item_keys:o}),a}return s(n)}(Oe),Vd=function(t){i(a,t);var n=f(a);function a(t,s){var i;return r(this,a),i=n.call(this,t,s),"number"==typeof s[e.UnreadItemKey.GROUP_CHANNEL_UNREAD_MENTION_COUNT]&&(i.groupChannelUnreadMentionCount=s[e.UnreadItemKey.GROUP_CHANNEL_UNREAD_MENTION_COUNT]),"number"==typeof s[e.UnreadItemKey.GROUP_CHANNEL_UNREAD_MESSAGE_COUNT]&&(i.groupChannelUnreadMessageCount=s[e.UnreadItemKey.GROUP_CHANNEL_UNREAD_MESSAGE_COUNT]),"number"==typeof s[e.UnreadItemKey.GROUP_CHANNEL_INVITATION_COUNT]&&(i.groupChannelInvitationCount=s[e.UnreadItemKey.GROUP_CHANNEL_INVITATION_COUNT]),"number"==typeof s[e.UnreadItemKey.SUPER_UNREAD_MENTION_COUNT]&&(i.superGroupChannelUnreadMentionCount=s[e.UnreadItemKey.SUPER_UNREAD_MENTION_COUNT]),"number"==typeof s[e.UnreadItemKey.SUPER_UNREAD_MESSAGE_COUNT]&&(i.superGroupChannelUnreadMessageCount=s[e.UnreadItemKey.SUPER_UNREAD_MESSAGE_COUNT]),"number"==typeof s[e.UnreadItemKey.SUPER_INVITATION_COUNT]&&(i.superGroupChannelInvitationCount=s[e.UnreadItemKey.SUPER_INVITATION_COUNT]),"number"==typeof s[e.UnreadItemKey.NONSUPER_UNREAD_MENTION_COUNT]&&(i.nonSuperGroupChannelUnreadMentionCount=s[e.UnreadItemKey.NONSUPER_UNREAD_MENTION_COUNT]),"number"==typeof s[e.UnreadItemKey.NONSUPER_UNREAD_MESSAGE_COUNT]&&(i.nonSuperGroupChannelUnreadMessageCount=s[e.UnreadItemKey.NONSUPER_UNREAD_MESSAGE_COUNT]),"number"==typeof s[e.UnreadItemKey.NONSUPER_INVITATION_COUNT]&&(i.nonSuperGroupChannelInvitationCount=s[e.UnreadItemKey.NONSUPER_INVITATION_COUNT]),i}return s(a)}(Ue),Bd=function(e){i(n,e);var t=f(n);function n(e){var a,s=e.userId;return r(this,n),(a=t.call(this)).method=le.GET,a.path="".concat(de,"/").concat(encodeURIComponent(s),"/unread_channel_count"),a}return s(n)}(Oe),Qd=function(e){i(n,e);var t=f(n);function n(e,a){var s;return r(this,n),(s=t.call(this,e,a)).unreadCount=a.unread_count,s}return s(n)}(Ue),Kd=function(t){i(a,t);var n=f(a);function a(t){var s,i=t.userId,o=t.filter;r(this,a),s=n.call(this);var u=o.channelCustomTypesFilter,c=o.superChannelFilter;return s.method=le.GET,s.path="".concat(de,"/").concat(encodeURIComponent(i),"/unread_message_count"),s.params={super_mode:null!=c?c:e.SuperChannelFilter.ALL,custom_types:u},s}return s(a)}(Oe),Wd=function(e){i(n,e);var t=f(n);function n(e,a){var s;return r(this,n),(s=t.call(this,e,a)).unreadCount=a.unread_count,s}return s(n)}(Ue),Yd=function(e){i(n,e);var t=f(n);function n(e){var a,s=e.channelUrl,i=e.scheduledStatus,o=e.messageTypeFilter;return r(this,n),(a=t.call(this)).method=le.GET,a.path="".concat(we,"/count"),a.params={channel_url:s,status:Jd(i)},o&&(a.params.message_type=o),a}return s(n)}(Oe),Zd=function(e){i(n,e);var t=f(n);function n(e,a){var s;return r(this,n),(s=t.call(this,e,a)).count=a.count,s}return s(n)}(Ue),Jd=function(t){if(!t)return[];var n=[];return t.forEach((function(t){switch(t){case e.ScheduledStatus.PENDING:n.push(ys.PENDING);break;case e.ScheduledStatus.SENT:n.push(ys.IN_QUEUE),n.push(ys.SENT);break;case e.ScheduledStatus.CANCELED:n.push(ys.CANCELED);break;case e.ScheduledStatus.FAILED:n.push(ys.FAILED)}})),n},Xd=function(e){i(n,e);var t=f(n);function n(e){var a;r(this,n);var s=e.userId,i=e.channelUrl,o=e.coverUrl,u=e.coverImage,c=e.isDistinct,l=e.isSuper,h=e.isBroadcast,d=e.isPublic,f=e.isExclusive,p=e.isDiscoverable,v=e.isStrict,m=e.isEphemeral,g=e.accessCode,y=e.name,k=e.data,b=e.customType,E=e.messageSurvivalSeconds,w=e.invitedUserIds,C=e.operatorUserIds;return(a=t.call(this)).method=le.POST,a.path=pe,a.params=ue({user_ids:[s].concat(_(null!=w?w:[])).filter((function(e,t,n){return t===n.indexOf(e)})),channel_url:i,cover_url:o,cover_file:u,is_distinct:c,is_super:l,is_broadcast:h,is_exclusive:f,is_public:d,is_discoverable:p,strict:v,is_ephemeral:m,access_code:g,name:y,data:k,custom_type:b,operator_ids:C,message_survival_seconds:E}),a}return s(n)}(Oe),$d=function(e){i(n,e);var t=f(n);function n(e,a){var s,i;return r(this,n),(s=t.call(this,e,a)).channel=new Kp(e,a),s.isCreated=null===(i=a.is_created)||void 0===i||i,s}return s(n)}(Ue),ef=function(e){i(n,e);var t=f(n);function n(e){var a,s=e.userId,i=e.channelUrls;return r(this,n),(a=t.call(this)).method=le.PUT,a.path="".concat(de,"/").concat(encodeURIComponent(s),"/mark_as_read_all"),a.params={channel_urls:i},a}return s(n)}(Oe),tf=function(e){i(n,e);var t=f(n);function n(e,a,s){var i;return r(this,n),(i=t.call(this,e,"SYEV",s)).event=new gd(s),i}return s(n)}(qe),nf=function(e){i(n,e);var t=f(n);function n(e){var a;r(this,n);var s=e.channelUrl,i=e.userId,o=e.accessCode;return(a=t.call(this)).method=le.PUT,a.path="".concat(pe,"/").concat(encodeURIComponent(s),"/join"),a.params={user_id:i,access_code:o},a}return s(n)}(Oe),rf=function(e){i(n,e);var t=f(n);function n(e,a){var s;return r(this,n),(s=t.call(this,e,a)).channel=new Kp(e,a),s}return s(n)}(Ue),af=function(e){i(n,e);var t=f(n);function n(e,a,s){var i;r(this,n),i=t.call(this,e,a,s);var o=s.data,u=o.member_count,c=void 0===u?0:u,l=o.joined_member_count,h=void 0===l?0:l,d=o.users,f=void 0===d?null:d;return i.memberCount=c,i.joinedMemberCount=h,i.members=Array.isArray(f)?f.map((function(t){return new dd(e,t)})):[new dd(e,s.data)],i}return s(n)}(tf),sf=function(e){i(n,e);var t=f(n);function n(e){var a;r(this,n);var s=e.channelUrl,i=e.userId,o=e.shouldRemoveOperatorStatus;return(a=t.call(this)).method=le.PUT,a.path="".concat(pe,"/").concat(encodeURIComponent(s),"/leave"),a.params={user_id:i,should_remove_operator_status:o},a}return s(n)}(Oe),of=function(e){i(n,e);var t=f(n);function n(e,a,s){var i;r(this,n),i=t.call(this,e,a,s);var o=s.data,u=o.member_count,c=void 0===u?0:u,l=o.joined_member_count,h=void 0===l?0:l;return i.memberCount=c,i.joinedMemberCount=h,i.member=new dd(i._iid,s.data),i}return s(n)}(tf),uf=function(e){i(n,e);var t=f(n);function n(e){var a;r(this,n);var s=e.channelUrl,i=e.userIds;return(a=t.call(this)).method=le.POST,a.path="".concat(pe,"/").concat(encodeURIComponent(s),"/invite"),a.params={user_ids:i},a}return s(n)}(Oe),cf=function(e){i(n,e);var t=f(n);function n(e,a){var s;return r(this,n),(s=t.call(this,e,a)).channel=new Kp(e,a),s}return s(n)}(Ue),lf=function(e){i(n,e);var t=f(n);function n(e,a,s){var i;r(this,n),i=t.call(this,e,a,s);var o=s.data,u=o.member_count,c=void 0===u?0:u,l=o.joined_member_count,h=void 0===l?0:l,d=o.inviter,f=o.invitees,p=void 0===f?[]:f;return i.memberCount=c,i.joinedMemberCount=h,i.inviter=new Xa(e,d),i.invitees=p.map((function(t){return new dd(e,t)})),i}return s(n)}(tf),hf=function(e){i(n,e);var t=f(n);function n(e){var a;r(this,n);var s=e.channelUrl,i=e.userId;return(a=t.call(this)).method=le.PUT,a.path="".concat(pe,"/").concat(encodeURIComponent(s),"/decline"),a.params={user_id:i},a}return s(n)}(Oe),df=function(e){i(n,e);var t=f(n);function n(e,a,s){var i;r(this,n),i=t.call(this,e,a,s);var o=s.data,u=o.member_count,c=o.joined_member_count,l=o.inviter,h=o.invitee;return i.memberCount=null!=u?u:0,i.joinedMemberCount=null!=c?c:0,i.inviter=new Xa(e,l),i.invitee=new dd(e,h),i}return s(n)}(tf),ff=function(e){i(n,e);var t=f(n);function n(e){var a=e.channelUrl;return r(this,n),t.call(this,{code:"READ",ackRequired:!0,payload:{channel_url:a}})}return s(n)}(oa),pf=function(e){i(n,e);var t=f(n);function n(e,a,s){var i;return r(this,n),(i=t.call(this,e,"READ",s)).readStatus=new fd(e,s),i}return s(n)}(qe),vf=function(e){i(n,e);var t=f(n);function n(e){var a,s=e.channelUrl,i=e.userId;return r(this,n),a=t.call(this),(a=t.call(this)).method=le.PUT,a.path="".concat(pe,"/").concat(encodeURIComponent(s),"/messages/mark_as_delivered"),a.params=ue({userId:i}),a}return s(n)}(Oe),_f=function(e){i(n,e);var t=f(n);function n(e,a,s){var i;return r(this,n),(i=t.call(this,e,"DLVR",s)).channelUrl=s.channel_url,i.deliveredStateUpdate=s.updated,i}return s(n)}(qe),mf={hidePreviousMessages:!1,allowAutoUnhide:!0},gf=function(e){return L("boolean",e.hidePreviousMessages,!0)&&L("boolean",e.allowAutoUnhide,!0)},yf=function(e){i(n,e);var t=f(n);function n(e){var a;r(this,n);var s=e.channelUrl,i=e.userId,o=e.hidePreviousMessages,u=e.allowAutoUnhide;return(a=t.call(this)).method=le.PUT,a.path="".concat(pe,"/").concat(encodeURIComponent(s),"/hide"),a.params={user_id:i,hide_previous_messages:null!=o?o:mf.hidePreviousMessages,allow_auto_unhide:null!=u?u:mf.allowAutoUnhide},a}return s(n)}(Oe),kf=function(e){i(n,e);var t=f(n);function n(e,a){var s;r(this,n),s=t.call(this,e,a);var i=a.ts_message_offset;return s.messageOffsetTimestamp=i,s}return s(n)}(Ue),bf=function(e){i(n,e);var t=f(n);function n(e,a,s){var i,o,u,c;return r(this,n),(i=t.call(this,e,"SYEV",s)).allowAutoUnhide=null,i.hidePreviousMessages=null,i.messageOffsetTimestamp=null,s.data&&(i.allowAutoUnhide=null!==(o=s.data.allow_auto_unhide)&&void 0!==o?o:null,i.hidePreviousMessages=null!==(u=s.data.hide_previous_messages)&&void 0!==u?u:null),i.messageOffsetTimestamp=null!==(c=s.ts_message_offset)&&void 0!==c?c:null,i}return s(n)}(qe),Ef=function(e){i(n,e);var t=f(n);function n(e){var a=e.channelUrl,s=e.time;return r(this,n),t.call(this,{code:"TPST",ackRequired:!1,payload:{channel_url:a,time:s}})}return s(n)}(oa),wf=function(e){i(n,e);var t=f(n);function n(e,a,s){var i;return r(this,n),(i=t.call(this,e,"SYEV",s)).user=new Xa(e,s.data),i}return s(n)}(qe),Cf=function(e){i(n,e);var t=f(n);function n(e){var a=e.channelUrl,s=e.time;return r(this,n),t.call(this,{code:"TPEN",ackRequired:!1,payload:{channel_url:a,time:s}})}return s(n)}(oa),xf=function(e){i(n,e);var t=f(n);function n(e,a,s){var i;return r(this,n),(i=t.call(this,e,"SYEV",s)).user=new Xa(e,s.data),i}return s(n)}(qe),Tf=function(e){i(n,e);var t=f(n);function n(e,a,s){var i;r(this,n),i=t.call(this,e,a,s);var o=s.data.operators,u=void 0===o?[]:o;return i.operators=u.map((function(e){return new Xa(i._iid,e)})),i}return s(n)}(tf),Sf=function(e){i(n,e);var t=f(n);function n(e,a,s){var i;return r(this,n),(i=t.call(this,e,"MCNT",s)).groupChannelMemberCounts=s.group_channels.map((function(e){return{channelUrl:e.channel_url,memberCount:e.member_count,joinedMemberCount:e.joined_member_count,updatedAt:e.ts}})),i.openChannelMemberCounts=s.open_channels.map((function(e){return{channelUrl:e.channel_url,participantCount:e.participant_count,updatedAt:e.ts}})),i}return s(n)}(qe),If=function(e){i(n,e);var t=f(n);function n(e){var a=e.channelUrl,s=e.messageId;return r(this,n),t.call(this,{code:"MACK",ackRequired:!1,payload:{channel_url:a,msg_id:s}})}return s(n)}(oa),Nf=function(e){i(n,e);var t=f(n);function n(e,a,s){var i,o,u,c,l;r(this,n),(i=t.call(this,e,"ADMM",s)).message=new Rs(e,s);var h=fs.of(e).sdkState;return i.isMentioned=Ie(i.message.mentionType,null!==(c=null!==(o=i.message.mentionedUserIds)&&void 0!==o?o:null===(u=i.message.mentionedUsers)||void 0===u?void 0:u.map((function(e){return e.userId})))&&void 0!==c?c:[],h.userId),i.forceUpdateLastMessage=null!==(l=s.force_update_last_message)&&void 0!==l&&l,i}return s(n)}(qe),Mf=function(e){i(n,e);var t=f(n);function n(e,a,s){var i,o,u,c,l,h;r(this,n),(i=t.call(this,e,"AEDI",s)).message=new Rs(e,s);var d=fs.of(e).sdkState;return i.mentionCountChange=Ne({mentionType:null===(o=s.old_values)||void 0===o?void 0:o.mention_type,mentionedUserIds:null!==(c=null===(u=s.old_values)||void 0===u?void 0:u.mentioned_user_ids)&&void 0!==c?c:[]},ce({mentionType:i.message.mentionType,mentionedUserIds:null!==(l=i.message.mentionedUserIds)&&void 0!==l?l:null===(h=i.message.mentionedUsers)||void 0===h?void 0:h.map((function(e){return e.userId}))}),d.userId),i}return s(n)}(qe),Af=function(e){i(n,e);var t=f(n);function n(e,a,s){var i;return r(this,n),(i=t.call(this,e,"MRCT",s)).channelUrl=s.channel_url,i.channelType=s.channel_type,i.event=new ks(s),i}return s(n)}(qe),Of=function(e){i(n,e);var t=f(n);function n(e,a,s){var i;return r(this,n),(i=t.call(this,e,"MTHD",s)).event=new xi(e,s),i}return s(n)}(qe),Uf=function(e){i(n,e);var t=f(n);function n(e,a,s){var i;return r(this,n),(i=t.call(this,e,"PEDI",s)).event=new ro(e,s),i.status=Ps(s.poll.status)||s.poll.status,i.channelUrl=s.channel_url,i.channelType=s.channel_type,i}return s(n)}(qe),Rf=function(n){i(u,n);var a=f(u);function u(t,n){var s,i,o,c,l,h,d,f,p,v,_,m,g,y,k,b,E,w,C,x,T,S,I;return r(this,u),(s=a.call(this,t,n)).includeEmpty=!1,s.includeFrozen=!0,s.includeMetaData=!0,s.channelUrlsFilter=null,s.customTypesFilter=null,s.customTypeStartsWithFilter=null,s.nicknameContainsFilter=null,s.nicknameStartsWithFilter=null,s.nicknameExactMatchFilter=null,s.channelNameContainsFilter="",s.myMemberStateFilter=e.MyMemberStateFilter.ALL,s.unreadChannelFilter=e.UnreadChannelFilter.ALL,s.superChannelFilter=e.SuperChannelFilter.ALL,s.publicChannelFilter=e.PublicChannelFilter.ALL,s.hiddenChannelFilter=e.HiddenChannelFilter.UNHIDDEN,s.searchFilter={fields:[],query:null},s.userIdsFilter={userIds:[],includeMode:!0,queryType:e.QueryType.AND},s.metadataKey=null,s.metadataValues=null,s.metadataOrderKeyFilter=null,s.metadataValueStartsWith=null,s.order=e.GroupChannelListOrder.LATEST_LAST_MESSAGE,s.includeEmpty=null!==(i=n.includeEmpty)&&void 0!==i&&i,s.includeFrozen=null===(o=n.includeFrozen)||void 0===o||o,s.includeMetaData=null===(c=n.includeMetaData)||void 0===c||c,s.channelUrlsFilter=null!==(l=n.channelUrlsFilter)&&void 0!==l?l:null,s.customTypesFilter=null!==(h=n.customTypesFilter)&&void 0!==h?h:null,s.customTypeStartsWithFilter=null!==(d=n.customTypeStartsWithFilter)&&void 0!==d?d:"",s.nicknameContainsFilter=null!==(f=n.nicknameContainsFilter)&&void 0!==f?f:null,s.nicknameStartsWithFilter=null!==(p=n.nicknameStartsWithFilter)&&void 0!==p?p:null,s.nicknameExactMatchFilter=null!==(v=n.nicknameExactMatchFilter)&&void 0!==v?v:null,s.channelNameContainsFilter=null!==(_=n.channelNameContainsFilter)&&void 0!==_?_:"",s.myMemberStateFilter=null!==(m=n.myMemberStateFilter)&&void 0!==m?m:e.MyMemberStateFilter.ALL,s.unreadChannelFilter=null!==(g=n.unreadChannelFilter)&&void 0!==g?g:e.UnreadChannelFilter.ALL,s.superChannelFilter=null!==(y=n.superChannelFilter)&&void 0!==y?y:e.SuperChannelFilter.ALL,s.publicChannelFilter=null!==(k=n.publicChannelFilter)&&void 0!==k?k:e.PublicChannelFilter.ALL,s.hiddenChannelFilter=null!==(b=n.hiddenChannelFilter)&&void 0!==b?b:e.HiddenChannelFilter.UNHIDDEN,s.searchFilter=null!==(E=n.searchFilter)&&void 0!==E?E:{fields:[],query:null},s.userIdsFilter=null!==(w=n.userIdsFilter)&&void 0!==w?w:{userIds:[],includeMode:!0,queryType:e.QueryType.AND},s.metadataKey=null!==(C=n.metadataKey)&&void 0!==C?C:null,s.metadataValues=null!==(x=n.metadataValues)&&void 0!==x?x:null,s.metadataOrderKeyFilter=null!==(T=n.metadataOrderKeyFilter)&&void 0!==T?T:null,s.metadataValueStartsWith=null!==(S=n.metadataValueStartsWith)&&void 0!==S?S:null,s.order=null!==(I=n.order)&&void 0!==I?I:e.GroupChannelListOrder.LATEST_LAST_MESSAGE,s}return s(u,[{key:"_validate",value:function(){return p(o(u.prototype),"_validate",this).call(this)&&L("boolean",this.includeEmpty)&&L("boolean",this.includeFrozen)&&L("boolean",this.includeMetaData)&&L("string",this.channelNameContainsFilter)&&F("string",this.channelUrlsFilter,!0)&&F("string",this.customTypesFilter,!0)&&L("string",this.customTypeStartsWithFilter)&&L("string",this.nicknameContainsFilter,!0)&&L("string",this.nicknameStartsWithFilter,!0)&&L("string",this.nicknameExactMatchFilter,!0)&&D(e.MyMemberStateFilter,this.myMemberStateFilter)&&D(e.SuperChannelFilter,this.superChannelFilter)&&D(e.PublicChannelFilter,this.publicChannelFilter)&&D(e.UnreadChannelFilter,this.unreadChannelFilter)&&D(e.HiddenChannelFilter,this.hiddenChannelFilter)&&F(e.GroupChannelSearchField,this.searchFilter.fields)&&L("string",this.searchFilter.query,!0)&&F("string",this.userIdsFilter.userIds)&&L("boolean",this.userIdsFilter.includeMode)&&D(e.QueryType,this.userIdsFilter.queryType)&&D(e.GroupChannelListOrder,this.order)&&L("string",this.metadataOrderKeyFilter,!0)&&L("string",this.metadataKey,!0)&&F("string",this.metadataValues,!0)&&L("string",this.metadataValueStartsWith,!0)}},{key:"serialize",value:function(){return Wa(this)}},{key:"next",value:function(){return b(this,void 0,void 0,t().mark((function e(){var n,r,a,s;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!this._validate()){e.next=20;break}if(this._isLoading){e.next=17;break}if(!this._hasNext){e.next=14;break}return this._isLoading=!0,n=Ff.of(this._iid),e.next=7,n.getMyGroupChannels(this._token,ce(Object.assign({},this)),this.limit);case 7:return r=e.sent,a=r.channels,s=r.token,this._token=s,this._hasNext=!!s,this._isLoading=!1,e.abrupt("return",a);case 14:return e.abrupt("return",[]);case 17:throw A.queryInProgress;case 18:e.next=21;break;case 20:throw A.invalidParameters;case 21:case"end":return e.stop()}}),e,this)})))}}]),u}(Ii),Lf=function(){function e(t){var n=t.top,a=void 0===n?Number.MAX_SAFE_INTEGER:n,s=t.bottom,i=void 0===s?0:s;r(this,e),this.top=a,this.bottom=i}return s(e,[{key:"includes",value:function(){for(var e=this,t=arguments.length,n=new Array(t),r=0;r0||H.unreadMentionCount>0)&&(H._updateUnreadCount(0,0),this._dispatcher.dispatch(new du({channels:[H],source:e.GroupChannelEventSource.EVENT_CHANNEL_READ})),Ca((function(){return b(dn,void 0,void 0,t().mark((function e(){var n,r,a;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:n=y(this._groupChannelHandlers.values());try{for(n.s();!(r=n.n()).done;)(a=r.value).onChannelChanged&&a.onChannelChanged(H)}catch(e){n.e(e)}finally{n.f()}case 2:case"end":return e.stop()}}),e,this)})))}))):0!==H.unreadMessageCount&&0!==H.unreadMentionCount||(this._dispatcher.dispatch(new du({channels:[H],source:e.GroupChannelEventSource.EVENT_CHANNEL_READ})),Ca((function(){return b(dn,void 0,void 0,t().mark((function e(){var n,r,a;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:n=y(this._groupChannelHandlers.values());try{for(n.s();!(r=n.n()).done;)(a=r.value).onChannelChanged&&a.onChannelChanged(H)}catch(e){n.e(e)}finally{n.f()}case 2:case"end":return e.stop()}}),e,this)})))}))):(this._dispatcher.dispatch(new du({channels:[H],source:e.GroupChannelEventSource.EVENT_CHANNEL_READ})),Ca((function(){return b(dn,void 0,void 0,t().mark((function e(){var n,r,a;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:n=y(this._groupChannelHandlers.values());try{for(n.s();!(r=n.n()).done;)(a=r.value).onUnreadMemberStatusUpdated&&a.onUnreadMemberStatusUpdated(H)}catch(e){n.e(e)}finally{n.f()}case 2:case"end":return e.stop()}}),e,this)})))})));case 80:return a.abrupt("break",335);case 81:return j=n.as(_f),z=j.channelUrl,V=j.deliveredStateUpdate,B=void 0===V?{}:V,Q=this._groupChannelCache.isCachedInMemory(z),a.next=85,this.getChannel(z,!0);case 85:if(K=a.sent,Q)for(W in B)K._updateUndeliveredMemberState(W,B[W]);return Object.keys(B).some((function(e){return e!==dn._sdkState.userId}))&&(this._dispatcher.dispatch(new du({channels:[K],source:e.GroupChannelEventSource.EVENT_CHANNEL_DELIVERED})),Ca((function(){return b(dn,void 0,void 0,t().mark((function e(){var n,r,a;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:n=y(this._groupChannelHandlers.values());try{for(n.s();!(r=n.n()).done;)(a=r.value).onUndeliveredMemberStatusUpdated&&a.onUndeliveredMemberStatusUpdated(K)}catch(e){n.e(e)}finally{n.f()}case 2:case"end":return e.stop()}}),e,this)})))}))),a.abrupt("break",335);case 89:if(Y=n.as(Af),Z=Y.channelUrl,J=Y.channelType,X=Y.event,J!==e.ChannelType.GROUP){a.next=99;break}return a.next=93,this.getChannel(Z,!0);case 93:return $=a.sent,a.next=96,this.getMessageFromCache(X.messageId);case 96:(ee=a.sent)&&(ee.applyReactionEvent(X),this._dispatcher.dispatch(new ui({messages:[ee],source:e.MessageEventSource.EVENT_MESSAGE_REACTION_UPDATED}))),Ca((function(){return b(dn,void 0,void 0,t().mark((function e(){var n,r,a;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:n=y(this._groupChannelHandlers.values());try{for(n.s();!(r=n.n()).done;)(a=r.value).onReactionUpdated&&a.onReactionUpdated($,X)}catch(e){n.e(e)}finally{n.f()}case 2:case"end":return e.stop()}}),e,this)})))}));case 99:return a.abrupt("break",335);case 100:if(te=n.as(Of),(ne=te.event).channelType!==e.ChannelType.GROUP){a.next=110;break}return a.next=104,this.getChannel(ne.channelUrl,!0);case 104:return re=a.sent,a.next=107,this.getMessageFromCache(ne.targetMessageId);case 107:(ae=a.sent)&&(ae.applyThreadInfoUpdateEvent(ne),this._dispatcher.dispatch(new ui({messages:[ae],source:e.MessageEventSource.EVENT_MESSAGE_THREADINFO_UPDATED}))),Ca((function(){return b(dn,void 0,void 0,t().mark((function e(){var n,r,a;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:n=y(this._groupChannelHandlers.values());try{for(n.s();!(r=n.n()).done;)(a=r.value).onThreadInfoUpdated&&a.onThreadInfoUpdated(re,ne)}catch(e){n.e(e)}finally{n.f()}case 2:case"end":return e.stop()}}),e,this)})))}));case 110:return a.abrupt("break",335);case 111:se=n.as(Sf),ie=se.groupChannelMemberCounts,oe=[],ue=y(ie),a.prev=114,ue.s();case 116:if((ce=ue.n()).done){a.next=125;break}return le=ce.value,he=le.channelUrl,de=le.memberCount,fe=le.joinedMemberCount,pe=le.updatedAt,a.next=121,this.getChannelFromCache(he);case 121:(ve=a.sent)&&ve._setLatestMemberCount(de,fe,pe)&&oe.push(ve);case 123:a.next=116;break;case 125:a.next=130;break;case 127:a.prev=127,a.t2=a.catch(114),ue.e(a.t2);case 130:return a.prev=130,ue.f(),a.finish(130);case 133:return oe.length>0&&(this._dispatcher.dispatch(new du({channels:oe,source:e.GroupChannelEventSource.EVENT_CHANNEL_MEMBER_COUNT_UPDATED})),Ca((function(){return b(dn,void 0,void 0,t().mark((function e(){var n,r,a;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:n=y(this._groupChannelHandlers.values());try{for(n.s();!(r=n.n()).done;)(a=r.value).onChannelMemberCountChanged&&a.onChannelMemberCountChanged(oe)}catch(e){n.e(e)}finally{n.f()}case 2:case"end":return e.stop()}}),e,this)})))}))),a.abrupt("break",335);case 135:if(_e=n.as(Uf),me=_e.event,ge=_e.status,ye=_e.channelUrl,ke=_e.channelType,!ye||ke!==e.ChannelType.GROUP){a.next=142;break}return a.next=139,this.getChannel(ye,!0);case 139:be=a.sent,this._dispatcher.dispatch(new di({event:me,source:e.MessageEventSource.EVENT_POLL_UPDATED})),Ca(ge===Ds?function(){return b(dn,void 0,void 0,t().mark((function e(){var n,r,a;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:n=y(this._groupChannelHandlers.values());try{for(n.s();!(r=n.n()).done;)(a=r.value).onPollDeleted&&a.onPollDeleted(be,me.pollId)}catch(e){n.e(e)}finally{n.f()}case 2:case"end":return e.stop()}}),e,this)})))}:function(){return b(dn,void 0,void 0,t().mark((function e(){var n,r,a;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:n=y(this._groupChannelHandlers.values());try{for(n.s();!(r=n.n()).done;)(a=r.value).onPollUpdated&&a.onPollUpdated(be,me)}catch(e){n.e(e)}finally{n.f()}case 2:case"end":return e.stop()}}),e,this)})))});case 142:return a.abrupt("break",335);case 143:if(Ee=n.as(td),we=Ee.event,Ce=Ee.channelUrl,xe=Ee.channelType,!Ce||xe!==e.ChannelType.GROUP){a.next=150;break}return a.next=147,this.getChannel(Ce,!0);case 147:Te=a.sent,this._dispatcher.dispatch(new fi({event:we,source:e.MessageEventSource.EVENT_POLL_VOTED})),Ca((function(){return b(dn,void 0,void 0,t().mark((function e(){var n,r,a;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:n=y(this._groupChannelHandlers.values());try{for(n.s();!(r=n.n()).done;)(a=r.value).onPollVoted&&a.onPollVoted(Te,we)}catch(e){n.e(e)}finally{n.f()}case 2:case"end":return e.stop()}}),e,this)})))}));case 150:return a.abrupt("break",335);case 151:if(Se=n.as(tf),!(Ie=Se.event).isGroupChannelEvent){a.next=323;break}a.t3=Ie.category,a.next=a.t3===pd.CHANNEL_JOIN?156:a.t3===pd.CHANNEL_LEAVE?165:a.t3===pd.CHANNEL_OPERATOR_UPDATE?181:a.t3===pd.CHANNEL_INVITE?192:a.t3===pd.CHANNEL_DECLINE_INVITE?202:a.t3===pd.TYPING_START||a.t3===pd.TYPING_END?210:a.t3===pd.USER_CHANNEL_MUTE||a.t3===pd.USER_CHANNEL_UNMUTE?219:a.t3===pd.USER_CHANNEL_BAN?246:a.t3===pd.USER_CHANNEL_UNBAN?259:a.t3===pd.CHANNEL_FREEZE||a.t3===pd.CHANNEL_UNFREEZE?265:a.t3===pd.CHANNEL_HIDE?273:a.t3===pd.CHANNEL_UNHIDE?283:a.t3===pd.CHANNEL_DELETED?290:a.t3===pd.CHANNEL_PROP_CHANGED?296:a.t3===pd.CHANNEL_META_DATA_CHANGED?302:a.t3===pd.CHANNEL_META_COUNTERS_CHANGED?311:a.t3===pd.PINNED_MESSAGE_CHANGED?317:323;break;case 156:return a.next=158,this.getChannel(Ie.channelUrl,!0);case 158:return Ne=a.sent,Me=n.as(af),Ae=Me.memberCount,Oe=Me.joinedMemberCount,Ue=Me.members,Re=!1,Ue.forEach((function(t){Ne.isExclusive||Ne.isSuper||Ne.isBroadcast?Re=Re||Ne._setLatestMemberCount(Ae,Oe,Ie.ts):(t.state=e.MemberState.JOINED,Ne.addMember(t,Ie.ts),dn._updateJoinedMemberCount(Ne)),t.userId===dn._sdkState.userId&&(Ne.myMemberState=e.MemberState.JOINED)})),this._dispatcher.dispatch(new du({channels:[Ne],source:e.GroupChannelEventSource.EVENT_CHANNEL_JOINED})),Ca((function(){return b(dn,void 0,void 0,t().mark((function e(){return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:this._groupChannelHandlers.forEach((function(e){var t,n=y(Ue);try{for(n.s();!(t=n.n()).done;){var r=t.value;e.onUserJoined&&e.onUserJoined(Ne,r)}}catch(e){n.e(e)}finally{n.f()}Ne.isBroadcast&&Re&&e.onChannelMemberCountChanged&&e.onChannelMemberCountChanged([Ne])}));case 1:case"end":return e.stop()}}),e,this)})))})),a.abrupt("break",323);case 165:if(!(Le=this._leftChannels.get(Ie.channelUrl))){a.next=170;break}a.t4=Le.channel,a.next=173;break;case 170:return a.next=172,this.getChannel(Ie.channelUrl,!0);case 172:a.t4=a.sent;case 173:return De=a.t4,Pe=n.as(of),Fe=Pe.memberCount,Ge=Pe.joinedMemberCount,qe=Pe.member,He=!1,je=fs.of(this._iid),ze=je.appInfo,De.isExclusive||De.isSuper||De.isBroadcast?He=De._setLatestMemberCount(Fe,Ge,Ie.ts):((null==ze?void 0:ze.enabledChannelMemberShipHistory)?((Ve=De.members.find((function(e){return e.userId===Ve.userId})))&&(Ve.state=e.MemberState.LEFT),De.memberCount=Fe):De.removeMember(qe),this._updateJoinedMemberCount(De)),qe.userId===this._sdkState.userId?(De.myMemberState=e.MemberState.NONE,De.invitedAt=0,De.joinedAt=0,De._updateUnreadCount(0,0),De.isPublic?this._dispatcher.dispatch(new du({channels:[De],source:e.GroupChannelEventSource.EVENT_CHANNEL_LEFT})):(this._markAsLeave(De),this._dispatcher.dispatch(new fu({channelUrls:[De.url],source:e.GroupChannelEventSource.EVENT_CHANNEL_LEFT})))):this._dispatcher.dispatch(new du({channels:[De],source:e.GroupChannelEventSource.EVENT_CHANNEL_LEFT})),Ca((function(){return b(dn,void 0,void 0,t().mark((function e(){return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:this._groupChannelHandlers.forEach((function(e){e.onUserLeft&&e.onUserLeft(De,qe),De.isBroadcast&&He&&e.onChannelMemberCountChanged&&e.onChannelMemberCountChanged([De])}));case 1:case"end":return e.stop()}}),e,this)})))})),a.abrupt("break",323);case 181:return a.next=183,this.getChannel(Ie.channelUrl,!0);case 183:Be=a.sent,Qe=n.as(Tf),Ke=Qe.operators,We=Ke.map((function(e){return e.userId})),Ye=y(Be.members);try{for(Ye.s();!(Ze=Ye.n()).done;)(Je=Ze.value).role=We.includes(Je.userId)?e.Role.OPERATOR:e.Role.NONE}catch(e){Ye.e(e)}finally{Ye.f()}return Be.myRole=We.includes(this._sdkState.userId)?e.Role.OPERATOR:e.Role.NONE,this._dispatcher.dispatch(new du({channels:[Be],source:e.GroupChannelEventSource.EVENT_CHANNEL_OPERATOR_UPDATED})),Ca((function(){return b(dn,void 0,void 0,t().mark((function e(){return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:this._groupChannelHandlers.forEach((function(e){e.onOperatorUpdated&&e.onOperatorUpdated(Be,Ke)}));case 1:case"end":return e.stop()}}),e,this)})))})),a.abrupt("break",323);case 192:return a.next=194,this.getChannel(Ie.channelUrl,!0);case 194:Xe=a.sent,$e=n.as(lf),et=$e.memberCount,tt=$e.joinedMemberCount,nt=$e.inviter,(rt=$e.invitees).forEach((function(t){return t.state=e.MemberState.INVITED})),at=y(rt);try{for(at.s();!(st=at.n()).done;)it=st.value,Xe.isExclusive||Xe.isSuper||Xe.isBroadcast?Xe._setLatestMemberCount(et,tt,Ie.ts):Xe.addMember(it,Ie.ts),this._sdkState.userId===it.userId&&(Xe.hiddenState=e.HiddenState.UNHIDDEN,Xe.myMemberState!==e.MemberState.JOINED&&(Xe.myMemberState=e.MemberState.INVITED),Xe.invitedAt=Ie.ts)}catch(e){at.e(e)}finally{at.f()}return this._dispatcher.dispatch(new du({channels:[Xe],source:e.GroupChannelEventSource.EVENT_CHANNEL_INVITED})),Ca((function(){return b(dn,void 0,void 0,t().mark((function e(){return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:this._groupChannelHandlers.forEach((function(e){e.onUserReceivedInvitation&&e.onUserReceivedInvitation(Xe,nt,rt)}));case 1:case"end":return e.stop()}}),e,this)})))})),a.abrupt("break",323);case 202:return a.next=204,this.getChannel(Ie.channelUrl,!0);case 204:return ot=a.sent,ut=n.as(df),ct=ut.memberCount,lt=ut.joinedMemberCount,ht=ut.inviter,dt=ut.invitee,ot.isExclusive||ot.isSuper||ot.isBroadcast?ot._setLatestMemberCount(ct,lt,Ie.ts):ot.removeMember(dt),this._sdkState.userId===dt.userId?(ot.invitedAt=0,ot.myMemberState=e.MemberState.NONE,ot.isPublic?this._dispatcher.dispatch(new du({channels:[ot],source:e.GroupChannelEventSource.EVENT_CHANNEL_DECLINED_INVITE})):this._dispatcher.dispatch(new fu({channelUrls:[ot.url],source:e.GroupChannelEventSource.EVENT_CHANNEL_DECLINED_INVITE}))):this._dispatcher.dispatch(new du({channels:[ot],source:e.GroupChannelEventSource.EVENT_CHANNEL_DECLINED_INVITE})),Ca((function(){return b(dn,void 0,void 0,t().mark((function e(){return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:this._groupChannelHandlers.forEach((function(e){e.onUserDeclinedInvitation&&e.onUserDeclinedInvitation(ot,ht,dt)}));case 1:case"end":return e.stop()}}),e,this)})))})),a.abrupt("break",323);case 210:return a.next=212,this.getChannel(Ie.channelUrl,!0);case 212:return ft=a.sent,pt=Ie.category===pd.TYPING_START,vt=n.as(pt?wf:xf),_t=vt.user,ft._updateTypingStatus(_t,pt?Ie.ts:0),this._dispatcher.dispatch(new du({channels:[ft],source:e.GroupChannelEventSource.EVENT_CHANNEL_TYPING_STATUS_UPDATE})),Ca((function(){return b(dn,void 0,void 0,t().mark((function e(){return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:this._groupChannelHandlers.forEach((function(e){e.onTypingStatusUpdated&&e.onTypingStatusUpdated(ft)}));case 1:case"end":return e.stop()}}),e,this)})))})),a.abrupt("break",323);case 219:return a.next=221,this.getChannel(Ie.channelUrl,!0);case 221:mt=a.sent,gt=Ie.category===pd.USER_CHANNEL_MUTE,yt=n.as(gt?fh:vh),(kt=yt.user).userId===this._sdkState.userId&&(mt.myMutedState=gt?e.MutedState.MUTED:e.MutedState.UNMUTED,mt._myMutedRemainingTime=kt.restrictionInfo.remainingDuration),bt=y(mt.members),a.prev=226,bt.s();case 228:if((Et=bt.n()).done){a.next=235;break}if((wt=Et.value).userId!==kt.userId){a.next=233;break}return wt.isMuted=gt,a.abrupt("break",235);case 233:a.next=228;break;case 235:a.next=240;break;case 237:a.prev=237,a.t5=a.catch(226),bt.e(a.t5);case 240:return a.prev=240,bt.f(),a.finish(240);case 243:return this._dispatcher.dispatch(new du({channels:[mt],source:gt?e.GroupChannelEventSource.EVENT_CHANNEL_MUTED:e.GroupChannelEventSource.EVENT_CHANNEL_UNMUTED,data:kt.userId})),Ca((function(){return b(dn,void 0,void 0,t().mark((function e(){return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:this._groupChannelHandlers.forEach((function(e){gt?e.onUserMuted&&e.onUserMuted(mt,kt):e.onUserUnmuted&&e.onUserUnmuted(mt,kt)}));case 1:case"end":return e.stop()}}),e,this)})))})),a.abrupt("break",323);case 246:if(!(Ct=this._leftChannels.get(Ie.channelUrl))){a.next=251;break}a.t6=Ct.channel,a.next=254;break;case 251:return a.next=253,this.getChannel(Ie.channelUrl,!0);case 253:a.t6=a.sent;case 254:return xt=a.t6,this._markAsLeave(xt),Tt=n.as(mh),St=Tt.user,Ca((function(){return b(dn,void 0,void 0,t().mark((function e(){return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:this._groupChannelHandlers.forEach((function(e){e.onUserBanned&&e.onUserBanned(xt,St)}));case 1:case"end":return e.stop()}}),e,this)})))})),a.abrupt("break",323);case 259:return a.next=261,this.getChannel(Ie.channelUrl,!0);case 261:return It=a.sent,Nt=n.as(yh),Mt=Nt.user,Ca((function(){return b(dn,void 0,void 0,t().mark((function e(){return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:this._groupChannelHandlers.forEach((function(e){e.onUserUnbanned&&e.onUserUnbanned(It,Mt)}));case 1:case"end":return e.stop()}}),e,this)})))})),a.abrupt("break",323);case 265:return a.next=267,this.getChannel(Ie.channelUrl,!0);case 267:return At=a.sent,Ot=n.as(bh),Ut=Ot.freeze,At.isFrozen=Ut,this._dispatcher.dispatch(new du({channels:[At],source:Ut?e.GroupChannelEventSource.EVENT_CHANNEL_FROZEN:e.GroupChannelEventSource.EVENT_CHANNEL_UNFROZEN})),Ca((function(){return b(dn,void 0,void 0,t().mark((function e(){return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:this._groupChannelHandlers.forEach((function(e){Ut?e.onChannelFrozen&&e.onChannelFrozen(At):e.onChannelUnfrozen&&e.onChannelUnfrozen(At)}));case 1:case"end":return e.stop()}}),e,this)})))})),a.abrupt("break",323);case 273:return a.next=275,this.getChannel(Ie.channelUrl,!0);case 275:return Rt=a.sent,Lt=n.as(bf),Dt=Lt.allowAutoUnhide,Pt=Lt.hidePreviousMessages,Ft=Lt.messageOffsetTimestamp,null!==Dt&&(Rt.hiddenState=Dt?e.HiddenState.HIDDEN_ALLOW_AUTO_UNHIDE:e.HiddenState.HIDDEN_PREVENT_AUTO_UNHIDE),null!==Pt&&Pt&&Rt._updateUnreadCount(0,0),null!==Ft&&(Rt.messageOffsetTimestamp=Ft),this._dispatcher.dispatch(new du({channels:[Rt],source:e.GroupChannelEventSource.EVENT_CHANNEL_HIDDEN})),Ca((function(){return b(dn,void 0,void 0,t().mark((function e(){return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:this._groupChannelHandlers.forEach((function(e){e.onChannelHidden&&e.onChannelHidden(Rt)}));case 1:case"end":return e.stop()}}),e,this)})))})),a.abrupt("break",323);case 283:return a.next=285,this.getChannel(Ie.channelUrl,!0);case 285:return(Gt=a.sent).hiddenState=e.HiddenState.UNHIDDEN,this._dispatcher.dispatch(new du({channels:[Gt],source:e.GroupChannelEventSource.EVENT_CHANNEL_UNHIDDEN})),Ca((function(){return b(dn,void 0,void 0,t().mark((function e(){return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:this._groupChannelHandlers.forEach((function(e){e.onChannelChanged&&e.onChannelChanged(Gt)}));case 1:case"end":return e.stop()}}),e,this)})))})),a.abrupt("break",323);case 290:return a.next=292,this.getChannel(Ie.channelUrl,!0);case 292:return qt=a.sent,this._dispatcher.dispatch(new fu({channelUrls:[Ie.channelUrl],source:e.GroupChannelEventSource.EVENT_CHANNEL_DELETED})),Ca((function(){return b(dn,void 0,void 0,t().mark((function e(){return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:this._groupChannelHandlers.forEach((function(e){e.onChannelDeleted&&e.onChannelDeleted(qt.url,qt.channelType)}));case 1:case"end":return e.stop()}}),e,this)})))})),a.abrupt("break",323);case 296:return a.next=298,this.getChannelWithoutCache(Ie.channelUrl,!0);case 298:return Ht=a.sent,this._dispatcher.dispatch(new du({channels:[Ht],source:e.GroupChannelEventSource.EVENT_CHANNEL_UPDATED})),Ca((function(){return b(dn,void 0,void 0,t().mark((function e(){return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:this._groupChannelHandlers.forEach((function(e){e.onChannelChanged&&e.onChannelChanged(Ht)}));case 1:case"end":return e.stop()}}),e,this)})))})),a.abrupt("break",323);case 302:return a.next=304,this.getChannel(Ie.channelUrl,!0);case 304:return jt=a.sent,zt=n.as(Xl),Vt=zt.created,Bt=zt.updated,Qt=zt.deleted,Vt&&jt._upsertCachedMetaData(Vt,Ie.ts),Bt&&jt._upsertCachedMetaData(Bt,Ie.ts),Qt&&jt._removeFromCachedMetaData(Qt,Ie.ts),Ca((function(){return b(dn,void 0,void 0,t().mark((function e(){return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:this._groupChannelHandlers.forEach((function(e){Vt&&e.onMetaDataCreated&&e.onMetaDataCreated(jt,Vt),Bt&&e.onMetaDataUpdated&&e.onMetaDataUpdated(jt,Bt),Qt&&e.onMetaDataDeleted&&e.onMetaDataDeleted(jt,Qt)}));case 1:case"end":return e.stop()}}),e,this)})))})),a.abrupt("break",323);case 311:return a.next=313,this.getChannel(Ie.channelUrl,!0);case 313:return Kt=a.sent,Wt=n.as(ch),Yt=Wt.created,Zt=Wt.updated,Jt=Wt.deleted,Ca((function(){return b(dn,void 0,void 0,t().mark((function e(){return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:this._groupChannelHandlers.forEach((function(e){Yt&&e.onMetaCounterCreated&&e.onMetaCounterCreated(Kt,Yt),Zt&&e.onMetaCounterUpdated&&e.onMetaCounterUpdated(Kt,Zt),Jt&&e.onMetaCounterDeleted&&e.onMetaCounterDeleted(Kt,Jt)}));case 1:case"end":return e.stop()}}),e,this)})))})),a.abrupt("break",323);case 317:return a.next=319,this.getChannel(Ie.channelUrl,!0);case 319:return Xt=a.sent,$t=n.as(Df),en=$t.pinnedMessageIds,tn=$t.latestPinnedMessage,(nn=$t.ts)>Xt._pinnedMessagesUpdatedAt&&(Xt.pinnedMessageIds=en,Xt.lastPinnedMessage=tn,Xt._pinnedMessagesUpdatedAt=nn,this._dispatcher.dispatch(new du({channels:[Xt],source:e.GroupChannelEventSource.EVENT_PINNED_MESSAGE_UPDATED})),Ca((function(){return b(dn,void 0,void 0,t().mark((function e(){var n,r,a;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:n=y(this._groupChannelHandlers.values());try{for(n.s();!(r=n.n()).done;)(a=r.value).onChannelChanged&&a.onChannelChanged(Xt)}catch(e){n.e(e)}finally{n.f()}case 2:case"end":return e.stop()}}),e,this)})))})),Ca((function(){return b(dn,void 0,void 0,t().mark((function e(){return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:this._groupChannelHandlers.forEach((function(e){e.onPinnedMessageUpdated&&e.onPinnedMessageUpdated(Xt)}));case 1:case"end":return e.stop()}}),e,this)})))}))),a.abrupt("break",323);case 323:return a.abrupt("break",335);case 324:rn=n.as(vu),an=rn.event,a.t7=an.category,a.next=a.t7===jo.USER_BLOCK?328:a.t7===jo.USER_UNBLOCK?331:334;break;case 328:return sn=uu.getDataAsUserBlockEvent(this._iid,an),on=sn.blocker,un=sn.blockee,this._groupChannelCache.block(on.userId,un.userId),a.abrupt("break",334);case 331:return cn=uu.getDataAsUserBlockEvent(this._iid,an),ln=cn.blocker,hn=cn.blockee,this._groupChannelCache.unblock(ln.userId,hn.userId),a.abrupt("break",334);case 334:return a.abrupt("break",335);case 335:a.next=341;break;case 337:if(a.prev=337,a.t8=a.catch(0),!M(a.t8)){a.next=341;break}throw a.t8;case 341:case"end":return a.stop()}}),a,this,[[0,337],[19,30,33,36],[114,127,130,133],[226,237,240,243]])})))}},{key:"_markAsLeave",value:function(e){var t,n=this,r=null!==(t=this._leftChannels.get(e.url))&&void 0!==t?t:{channel:e,ref:0};r.ref++,this._leftChannels.set(e.url,r),setTimeout((function(){r.ref--,0===r.ref&&n._leftChannels.delete(e.url)}),1e4)}},{key:"addHandler",value:function(e,t){this._groupChannelHandlers.set(e,t)}},{key:"removeHandler",value:function(e){this._groupChannelHandlers.delete(e)}},{key:"clearHandler",value:function(){this._groupChannelHandlers.clear()}},{key:"subscribeGroupChannelEvent",value:function(e,t){this._groupChannelBroadcast.subscribe(e,t)}},{key:"unsubscribeGroupChannelEvent",value:function(e){this._groupChannelBroadcast.unsubscribe(e)}},{key:"subscribeMessageEvent",value:function(e,t){this._messageBroadcast.subscribe(e,t)}},{key:"unsubscribeMessageEvent",value:function(e){this._messageBroadcast.unsubscribe(e)}},{key:"_updateJoinedMemberCount",value:function(t){t.joinedMemberCount=t.members.filter((function(t){return t.state===e.MemberState.JOINED})).length}},{key:"getChannel",value:function(e){var n=arguments.length>1&&void 0!==arguments[1]&&arguments[1];return b(this,void 0,void 0,t().mark((function r(){var a;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return Za(L("string",e)).throw(A.invalidParameters),t.prev=1,t.next=4,this.getChannelFromCache(e);case 4:if(!(a=t.sent)){t.next=7;break}return t.abrupt("return",a);case 7:t.next=11;break;case 9:t.prev=9,t.t0=t.catch(1);case 11:return t.next=13,this.getChannelWithoutCache(e,n);case 13:return t.abrupt("return",t.sent);case 14:case"end":return t.stop()}}),r,this,[[1,9]])})))}},{key:"getChannelWithoutCache",value:function(n){var r=arguments.length>1&&void 0!==arguments[1]&&arguments[1];return b(this,void 0,void 0,t().mark((function a(){var s,i,o,u,c,l;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return Za(L("string",n)).throw(A.invalidParameters),s=new Dd({channelUrl:n,isInternalCall:r}),t.next=4,this._requestQueue.send(s);case 4:i=t.sent,o=i.as(Pd),u=o.channel,c=u.unreadMessageCount,l=u.unreadMentionCount,t.t0=u.myCountPreference,t.next=t.t0===e.CountPreference.UNREAD_MESSAGE_COUNT_ONLY?10:t.t0===e.CountPreference.UNREAD_MENTION_COUNT_ONLY?12:t.t0===e.CountPreference.OFF?14:17;break;case 10:return l=0,t.abrupt("break",17);case 12:return c=0,t.abrupt("break",17);case 14:return c=0,l=0,t.abrupt("break",17);case 17:return u._updateUnreadCount(c,l),t.next=20,this.upsertChannelsToCache([u]);case 20:return t.abrupt("return",t.sent[0]);case 21:case"end":return t.stop()}}),a,this)})))}},{key:"refreshChannel",value:function(n){var r=!(arguments.length>1&&void 0!==arguments[1])||arguments[1],a=arguments.length>2&&void 0!==arguments[2]?arguments[2]:e.GroupChannelEventSource.REFRESH_CHANNEL;return b(this,void 0,void 0,t().mark((function s(){var i,o,u,c,l;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.prev=0,i=new Dd({channelUrl:n,isInternalCall:r}),t.next=4,this._requestQueue.send(i);case 4:if(o=t.sent,u=o.as(Pd),(c=u.channel).myMemberState!==e.MemberState.NONE){t.next=10;break}this._dispatcher.dispatch(new fu({channelUrls:[c.url],source:a})),t.next=14;break;case 10:return t.next=12,this.upsertChannelsToCache([c]);case 12:l=t.sent,this._dispatcher.dispatch(new du({channels:l,source:a}));case 14:t.next=19;break;case 16:t.prev=16,t.t0=t.catch(0),t.t0.code!==E.NON_AUTHORIZED&&t.t0.code!==E.NOT_FOUND_IN_DATABASE||this._dispatcher.dispatch(new fu({channelUrls:[n],source:a}));case 19:case"end":return t.stop()}}),s,this,[[0,16]])})))}},{key:"getMyGroupChannels",value:function(n,r,a){var s=arguments.length>3&&void 0!==arguments[3]?arguments[3]:e.GroupChannelEventSource.REQUEST_CHANNEL;return b(this,void 0,void 0,t().mark((function e(){var i,o,u,c,l;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return i=new Gd(Object.assign(Object.assign({},r),{userId:this._sdkState.userId,token:n,limit:a})),e.next=3,this._requestQueue.send(i);case 3:return o=e.sent,u=o.as(qd),c=u.channels,l=u.token,this._dispatcher.dispatch(new du({channels:c,source:s})),e.abrupt("return",{channels:c,token:l});case 7:case"end":return e.stop()}}),e,this)})))}},{key:"getMessageFromCache",value:function(e){var n;return b(this,void 0,void 0,t().mark((function r(){return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,this._messageCache.get(e);case 2:if(t.t1=n=t.sent,t.t0=null!==t.t1,!t.t0){t.next=6;break}t.t0=void 0!==n;case 6:if(!t.t0){t.next=10;break}t.t2=n,t.next=11;break;case 10:t.t2=null;case 11:return t.abrupt("return",t.t2);case 12:case"end":return t.stop()}}),r,this)})))}},{key:"getMessagesFromCache",value:function(e,n,r,a){var s=arguments.length>4&&void 0!==arguments[4]?arguments[4]:yo;return b(this,void 0,void 0,t().mark((function i(){return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,this._messageCache.fetch({channelUrl:e,token:n,limit:s,filter:a,backward:"next"===r});case 2:return t.abrupt("return",t.sent);case 3:case"end":return t.stop()}}),i,this)})))}},{key:"getPollMessagesFromCache",value:function(e,n,r){var a=arguments.length>3&&void 0!==arguments[3]?arguments[3]:yo;return b(this,void 0,void 0,t().mark((function s(){return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,this._messageCache.fetch({channelUrl:e,token:n,limit:a,filter:r,backward:!1,isPollOnly:!0});case 2:return t.abrupt("return",t.sent);case 3:case"end":return t.stop()}}),s,this)})))}},{key:"getUnsentMessagesFromCache",value:function(e,n){return b(this,void 0,void 0,t().mark((function r(){return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,this._unsentMessageCache.fetch({channelUrl:e,filter:n});case 2:return t.abrupt("return",t.sent);case 3:case"end":return t.stop()}}),r,this)})))}},{key:"removeFailedMessageFromCache",value:function(e){return b(this,void 0,void 0,t().mark((function n(){return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,this._unsentMessageCache.remove([e]);case 2:case"end":return t.stop()}}),n,this)})))}},{key:"getCachedMessageCountBetween",value:function(e,n,r,a){return b(this,void 0,void 0,t().mark((function s(){return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,this._messageCache.countBetween(e,n,new Lf({top:r,bottom:a}));case 2:return t.abrupt("return",t.sent);case 3:case"end":return t.stop()}}),s,this)})))}},{key:"getMyGroupChannelChangeLogs",value:function(n,r){var a=arguments.length>2&&void 0!==arguments[2]?arguments[2]:e.GroupChannelEventSource.REQUEST_CHANNEL_CHANGELOGS;return b(this,void 0,void 0,t().mark((function e(){var s,i,o,u,c,l,h;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return s=Object.assign(Object.assign({},bd),r),Za((L("string",n)||L("number",n))&&Ed(s)).throw(A.invalidParameters),i=new Rd(ce({userId:this._sdkState.userId,ts:"number"==typeof n?n:null,token:"string"==typeof n?n:null,filter:s})),e.next=5,this._requestQueue.send(i);case 5:return o=e.sent,u=o.as(Ld),c=u.updatedChannels,l=u.deletedChannelUrls,h=u.hasMore,c.length>0&&this._dispatcher.dispatch(new du({channels:c,source:a})),l.length>0&&this._dispatcher.dispatch(new fu({channelUrls:l,source:a})),e.abrupt("return",{updatedChannels:c,deletedChannelUrls:l,hasMore:h,token:u.token});case 11:case"end":return e.stop()}}),e,this)})))}},{key:"getGroupChannelCount",value:function(e){return b(this,void 0,void 0,t().mark((function n(){var r,a,s,i,o;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return r=Object.assign(Object.assign({},wd),e),Za(Cd(r)).throw(A.invalidParameters),a=new Hd({userId:this._sdkState.userId,filter:r}),t.next=5,this._requestQueue.send(a);case 5:return s=t.sent,i=s.as(jd),o=i.groupChannelCount,t.abrupt("return",o);case 8:case"end":return t.stop()}}),n,this)})))}},{key:"getUnreadItemCount",value:function(e){return b(this,void 0,void 0,t().mark((function n(){var r,a,s,i,o,u,c,l,h,d,f,p,v,_,m,g;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return r=Object.assign(Object.assign({},Td),e),Za(Sd(r)).throw(A.invalidParameters),a=fs.of(this._iid),s=a.sdkState,i=a.requestQueue,o=new zd({userId:s.userId,filter:r}),t.next=6,i.send(o);case 6:return u=t.sent,c=u.as(Vd),l=c.groupChannelUnreadMentionCount,h=c.groupChannelUnreadMessageCount,d=c.groupChannelInvitationCount,f=c.superGroupChannelUnreadMentionCount,p=c.superGroupChannelUnreadMessageCount,v=c.superGroupChannelInvitationCount,_=c.nonSuperGroupChannelUnreadMentionCount,m=c.nonSuperGroupChannelUnreadMessageCount,g=c.nonSuperGroupChannelInvitationCount,t.abrupt("return",ue({groupChannelUnreadMentionCount:l,groupChannelUnreadMessageCount:h,groupChannelInvitationCount:d,superGroupChannelUnreadMentionCount:f,superGroupChannelUnreadMessageCount:p,superGroupChannelInvitationCount:v,nonSuperGroupChannelUnreadMentionCount:_,nonSuperGroupChannelUnreadMessageCount:m,nonSuperGroupChannelInvitationCount:g}));case 9:case"end":return t.stop()}}),n,this)})))}},{key:"getTotalUnreadChannelCount",value:function(){return b(this,void 0,void 0,t().mark((function e(){var n,r,a,s,i,o,u;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n=fs.of(this._iid),r=n.sdkState,a=n.requestQueue,s=new Bd({userId:r.userId}),e.next=4,a.send(s);case 4:return i=e.sent,o=i.as(Qd),u=o.unreadCount,e.abrupt("return",u);case 7:case"end":return e.stop()}}),e,this)})))}},{key:"getTotalUnreadMessageCount",value:function(e){return b(this,void 0,void 0,t().mark((function n(){var r,a,s,i,o,u,c,l;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return r=Object.assign(Object.assign({},Id),e),Za(Nd(r)).throw(A.invalidParameters),a=fs.of(this._iid),s=a.sdkState,i=a.requestQueue,o=new Kd({userId:s.userId,filter:r}),t.next=6,i.send(o);case 6:return u=t.sent,c=u.as(Wd),l=c.unreadCount,t.abrupt("return",l);case 9:case"end":return t.stop()}}),n,this)})))}},{key:"getTotalScheduledMessageCount",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return b(this,void 0,void 0,t().mark((function n(){var r,a,s,i,o,u,c;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return r=Object.assign(Object.assign({},Md),e),Za(Ad(r)).throw(A.invalidParameters),a=fs.of(this._iid),s=a.requestQueue,i=new Yd(r),t.next=6,s.send(i);case 6:return o=t.sent,u=o.as(Zd),c=u.count,t.abrupt("return",c);case 9:case"end":return t.stop()}}),n,this)})))}},{key:"getSubscribedTotalUnreadMessageCount",value:function(){var e=fs.of(this._iid).subscribedUnreadMessageCount;return e.all>=0?e.all:0}},{key:"getSubscribedCustomTypeTotalUnreadMessageCount",value:function(){var e=0,t=fs.of(this._iid).subscribedUnreadMessageCount;for(var n in t.customTypes)e+=t.customTypes[n];return e}},{key:"getSubscribedCustomTypeUnreadMessageCount",value:function(e){var t;return null!==(t=fs.of(this._iid).subscribedUnreadMessageCount.customTypes[e])&&void 0!==t?t:0}},{key:"createChannel",value:function(e){return b(this,void 0,void 0,t().mark((function n(){var r,a,s,i,o;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return r=Object.assign(Object.assign({},yd),e),Za(kd(r)).throw(A.invalidParameters),r.isPublic||(r.accessCode=void 0),a=new Xd(Object.assign({userId:this._sdkState.userId},r)),t.next=6,this._requestQueue.send(a);case 6:return s=t.sent,i=s.as($d),o=i.channel,t.next=10,this.upsertChannelsToCache([o]);case 10:return t.abrupt("return",o);case 11:case"end":return t.stop()}}),n,this)})))}},{key:"markAsReadAll",value:function(){return b(this,void 0,void 0,t().mark((function e(){var n,r,a,s,i,o;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n=Date.now(),Za(n-this._markAsReadAllLastSentAt>=1e3).throw(A.markAsReadAllRateLimitExceeded),this._markAsReadAllLastSentAt=n,r=new ef({userId:this._sdkState.userId}),e.next=6,this._requestQueue.send(r);case 6:a=this._groupChannelCache.channels,s=y(a);try{for(s.s();!(i=s.n()).done;)(o=i.value)._updateUnreadMemberState(this._sdkState.userId,n),o._updateUnreadCount(0,0)}catch(e){s.e(e)}finally{s.f()}if(!(a.length>0)){e.next=12;break}return e.next=12,this.upsertChannelsToCache(a);case 12:case"end":return e.stop()}}),e,this)})))}},{key:"markAsReadWithChannelUrls",value:function(e){return b(this,void 0,void 0,t().mark((function n(){var r,a,s,i,o,u,c;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return r=Date.now(),Za(F("string",e)&&r-this._markAsReadAllLastSentAt>=1e3).throw(A.markAsReadAllRateLimitExceeded),this._markAsReadAllLastSentAt=r,a=new ef({userId:this._sdkState.userId,channelUrls:e}),t.next=6,this._requestQueue.send(a);case 6:s=this._groupChannelCache.channels,i=[],o=y(s);try{for(o.s();!(u=o.n()).done;)c=u.value,e.includes(c.url)&&(c._updateUnreadMemberState(this._sdkState.userId,r),c._updateUnreadCount(0,0),i.push(c))}catch(e){o.e(e)}finally{o.f()}if(!(i.length>0)){t.next=13;break}return t.next=13,this.upsertChannelsToCache(i);case 13:case"end":return t.stop()}}),n,this)})))}},{key:"markAsDelivered",value:function(e){return b(this,void 0,void 0,t().mark((function n(){var r;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,this.getChannel(e);case 2:return r=t.sent,t.next=5,r.markAsDelivered();case 5:case"end":return t.stop()}}),n,this)})))}}],[{key:"of",value:function(e){return Pf[e]}},{key:"clear",value:function(e){Pf[e]&&delete Pf[e]}}]),n}();!function(e){e[e.IDLE=0]="IDLE",e[e.RUNNING=1]="RUNNING",e[e.END=2]="END"}(xd||(xd={}));var Gf=function(e){i(a,e);var n=f(a);function a(e,t){var s;return r(this,a),(s=n.call(this))._state=xd.IDLE,s._retryCount=0,s._retryLimit=3,s.priority=0,s._worker=t,s}return s(a,[{key:"isIdle",get:function(){return this._state===xd.IDLE}},{key:"isRunning",get:function(){return this._state===xd.RUNNING}},{key:"isDone",get:function(){return this._state===xd.END}},{key:"retryCount",get:function(){return this._retryCount}},{key:"retryLimit",get:function(){return this._retryLimit}},{key:"_run",value:function(e){return b(this,void 0,void 0,t().mark((function n(){var r;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(!this.isRunning){t.next=14;break}return t.prev=1,t.next=4,this._worker(e);case 4:r=t.sent,this._retryCount=0,this.dispatch("progress",r),r.hasNext?this._run(r.nextToken):this.end(),t.next=14;break;case 10:t.prev=10,t.t0=t.catch(1),this.dispatch("error",t.t0),this._retryCount0&&(f=h.map((function(e){return e.createdAt})),(null===(u=this._metadata)||void 0===u?void 0:(d=u.range).intersect.apply(d,_(f)))?this.extendRange(h):this._metadata={range:new Lf({top:Math.min.apply(Math,_(f)),bottom:Math.max.apply(Math,_(f))}),previousComplete:!1}),c.hasNext=h.length>=this._limit&&this._prevSyncLoopCount<1,this._metadata&&(c.nextToken=this._metadata.range.top,this._metadata.previousComplete=h.length0&&(d=l.map((function(e){return e.createdAt})),(null===(o=this._metadata)||void 0===o?void 0:(h=o.range).intersect.apply(h,_(d)))?this.extendRange(l):this._metadata={range:new Lf({top:Math.min.apply(Math,_(d)),bottom:Math.max.apply(Math,_(d))}),previousComplete:!1}),u.hasNext=l.length>=this._limit&&this._nextSyncLoopCount<1,this._metadata&&(u.nextToken=this._metadata.range.bottom),v.debug("message background next sync progress",u),t.next=16,this.saveMetadata();case 16:t.next=22;break;case 18:throw t.prev=18,t.t0=t.catch(5),v.debug("message background next sync error",t.t0),t.t0;case 22:return t.abrupt("return",u);case 23:case"end":return t.stop()}}),r,this,[[5,18]])})))})),this._connectionEventContext=p.on((function(e){if(e instanceof da)if(e.stateType===sa.CONNECTED)s.resume();else s.pause()}))}return s(n,[{key:"range",get:function(){var e,t;return null!==(t=null===(e=this._metadata)||void 0===e?void 0:e.range)&&void 0!==t?t:new Lf({})}},{key:"previousComplete",get:function(){var e;return!!(null===(e=this._metadata)||void 0===e?void 0:e.previousComplete)}},{key:"isWrappingMessages",value:function(e){var t,n;return null===(n=this.range)||void 0===n?void 0:(t=n).includes.apply(t,_(e.map((function(e){return e.createdAt}))))}},{key:"extendRange",value:function(e){var t;this._metadata&&(t=this._metadata.range).extends.apply(t,_(e.map((function(e){return e.createdAt}))))}},{key:"loadMetadata",value:function(e){return b(this,void 0,void 0,t().mark((function n(){var r,a,s;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(this._metadata){t.next=6;break}return r=fs.of(this._iid),a=r.cacheContext,t.next=4,a.preference.get(this._metadataKey);case 4:(s=t.sent)?s.range.bottom0&&void 0!==arguments[0]?arguments[0]:Date.now(),s=fs.of(this._iid),i=s.logger;s.connectionManager.isConnected&&(i.debug("message background sync resume()"),this._prevSyncLoopCount=this._nextSyncLoopCount=0,this._metadata&&this._metadata.previousComplete||this._prevSync.start(null!==(t=null===(e=this._metadata)||void 0===e?void 0:e.range.top)&&void 0!==t?t:a),this._nextSync.start(null!==(r=null===(n=this._metadata)||void 0===n?void 0:n.range.bottom)&&void 0!==r?r:a))}},{key:"pause",value:function(){fs.of(this._iid).logger.debug("message background sync stop()"),this._prevSync.stop(),this._nextSync.stop()}},{key:"close",value:function(){this.ref--,this.ref<=0&&(this.ref=0,this.pause(),this._connectionEventContext.close(),delete jf[this._iid][this._channel.url])}}],[{key:"of",value:function(e,t){return jf[e]||(jf[e]={}),jf[e][t.url]||(jf[e][t.url]=new n({_iid:e,channel:t})),jf[e][t.url].ref++,jf[e][t.url]}},{key:"clear",value:function(e,t){jf[e]&&jf[e][t]&&(jf[e][t].close(),delete jf[e])}}]),n}(),Vf={},Bf=function(){function n(a){var s=this,i=a._iid,o=a.channel;r(this,n),this.ref=0,this._iid=i,this._channel=o;var u,c,l=fs.of(this._iid),h=l.logger,d=l.sdkState,f=l.dispatcher;this._metadataKey=(u=d.userId,c=o.url,"sendbird:".concat(u,"@groupchannel/").concat(c,"/message/changelogs.meta"));var p=function(e,t){return"sendbird:".concat(e,"@groupchannel/").concat(t,"/message/changelogs")}(d.userId,this._channel.url);this._sync=new Gf(p,(function(){return b(s,void 0,void 0,t().mark((function n(){var r,a,s,i,o,u,c,l;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return a={hasNext:!0,nextToken:0},t.next=3,this.loadMetadata();case 3:return h.debug("message changelog sync from",null===(r=this._metadata)||void 0===r?void 0:r.token),t.prev=4,s=wi.of(this._iid),t.next=8,s.getMessageChangelogs(this._channel.url,this._channel.channelType,this._metadata.token,{replyType:e.ReplyType.ALL,includeReactions:!0,includeThreadInfo:!0,includeMetaArray:!0,includeParentMessageInfo:!0},e.MessageEventSource.SYNC_MESSAGE_CHANGELOGS);case 8:return i=t.sent,o=i.updatedMessages,u=i.deletedMessageIds,c=i.hasMore,l=i.token,a.hasNext=c,a.nextToken=l,(o.length>0||u.length>0)&&this._metadata&&(this._metadata.token=l),h.debug("message changelog sync progress",a),t.next=19,this.saveMetadata();case 19:t.next=28;break;case 21:if(t.prev=21,t.t0=t.catch(4),h.debug("message changelog sync error",t.t0),!(t.t0 instanceof A&&t.t0.isInvalidTokenError)){t.next=27;break}return t.next=27,this.clearMetadata();case 27:throw t.t0;case 28:return t.abrupt("return",a);case 29:case"end":return t.stop()}}),n,this,[[4,21]])})))})),this._connectionEventContext=f.on((function(e){if(e instanceof da)if(e.stateType===sa.CONNECTED)s.resume();else s.pause()}))}return s(n,[{key:"loadMetadata",value:function(){return b(this,void 0,void 0,t().mark((function e(){var n,r,a,s;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(this._metadata){e.next=6;break}return n=fs.of(this._iid),r=n.cacheContext,a=n.firstConnectedAt,e.next=4,r.preference.get(this._metadataKey);case 4:s=e.sent,this._metadata={token:s?s.token:a};case 6:return e.abrupt("return",this._metadata);case 7:case"end":return e.stop()}}),e,this)})))}},{key:"saveMetadata",value:function(){return b(this,void 0,void 0,t().mark((function e(){var n,r;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!this._metadata){e.next=5;break}return n=fs.of(this._iid),r=n.cacheContext,e.next=4,r.preference.set(this._metadataKey,this._metadata);case 4:return e.abrupt("return",!0);case 5:return e.abrupt("return",!1);case 6:case"end":return e.stop()}}),e,this)})))}},{key:"clearMetadata",value:function(){return b(this,void 0,void 0,t().mark((function e(){var n,r;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n=fs.of(this._iid),r=n.cacheContext,e.next=3,r.preference.remove(this._metadataKey);case 3:this._metadata=void 0;case 4:case"end":return e.stop()}}),e,this)})))}},{key:"resume",value:function(){var e=fs.of(this._iid),t=e.logger;e.connectionManager.isConnected&&(t.debug("message changelog sync resume()"),this._sync.start(0))}},{key:"pause",value:function(){var e=fs.of(this._iid),t=e.logger;e.connectionManager.isConnected&&(t.debug("message changelog sync pause()"),this._sync.stop())}},{key:"close",value:function(){this.ref--,this.ref<=0&&(this.ref=0,this.pause(),this._connectionEventContext.close(),delete Vf[this._iid][this._channel.url])}}],[{key:"of",value:function(e,t){return Vf[e]||(Vf[e]={}),Vf[e][t.url]||(Vf[e][t.url]=new n({_iid:e,channel:t})),Vf[e][t.url].ref++,Vf[e][t.url]}},{key:"clear",value:function(e,t){Vf[e]&&Vf[e][t]&&(Vf[e][t].close(),delete Vf[e])}}]),n}(),Qf={},Kf=function(){function e(n){var a=this,s=n._iid,i=n.channel,o=n.hasPollMessage;r(this,e),this.ref=0,this._iid=s,this._channel=i;var u,c,l=fs.of(this._iid),h=l.logger,d=l.sdkState,f=l.dispatcher;this._metadataKey=(u=d.userId,c=i.url,"sendbird:".concat(u,"@groupchannel/").concat(c,"/poll/changelogs.meta"));var p=function(e,t){return"sendbird:".concat(e,"@groupchannel/").concat(t,"/poll/changelogs")}(d.userId,this._channel.url);this._sync=new Gf(p,(function(){return b(a,void 0,void 0,t().mark((function e(){var n,r,a,s,i,u,c,l,d;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return r={hasNext:!0,nextToken:0},e.next=3,this.loadMetadata();case 3:if(h.debug("poll changelog sync from",null===(n=this._metadata)||void 0===n?void 0:n.token),e.t0=!this._metadata||!this._metadata.token,!e.t0){e.next=9;break}return e.next=8,o();case 8:e.t0=!e.sent;case 9:if(!e.t0){e.next=12;break}return a={hasNext:!1,nextToken:0},e.abrupt("return",a);case 12:return this._metadata||(s=fs.of(this._iid),i=s.firstConnectedAt,this._metadata={token:i}),e.prev=13,u=no.of(this._iid),e.next=17,u.getPollChangeLogs(this._channel.url,this._channel.channelType,this._metadata.token);case 17:return c=e.sent,l=c.hasMore,d=c.token,r.hasNext=l,r.nextToken=d,this._metadata.token=d,h.debug("poll changelog sync progress",r),e.next=26,this.saveMetadata();case 26:e.next=35;break;case 28:if(e.prev=28,e.t1=e.catch(13),h.debug("poll changelog sync error",e.t1),!(e.t1 instanceof A&&e.t1.isInvalidTokenError)){e.next=34;break}return e.next=34,this.clearMetadata();case 34:throw e.t1;case 35:return e.abrupt("return",r);case 36:case"end":return e.stop()}}),e,this,[[13,28]])})))})),this._connectionEventContext=f.on((function(e){if(e instanceof da)if(e.stateType===sa.CONNECTED)a.resume();else a.pause()}))}return s(e,[{key:"loadMetadata",value:function(){return b(this,void 0,void 0,t().mark((function e(){var n,r,a;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(this._metadata){e.next=6;break}return n=fs.of(this._iid),r=n.cacheContext,e.next=4,r.preference.get(this._metadataKey);case 4:a=e.sent,this._metadata=a?{token:a.token}:void 0;case 6:case"end":return e.stop()}}),e,this)})))}},{key:"saveMetadata",value:function(){return b(this,void 0,void 0,t().mark((function e(){var n,r;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!this._metadata){e.next=4;break}return n=fs.of(this._iid),r=n.cacheContext,e.next=4,r.preference.set(this._metadataKey,this._metadata);case 4:case"end":return e.stop()}}),e,this)})))}},{key:"clearMetadata",value:function(){return b(this,void 0,void 0,t().mark((function e(){var n,r;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n=fs.of(this._iid),r=n.cacheContext,e.next=3,r.preference.remove(this._metadataKey);case 3:this._metadata=void 0;case 4:case"end":return e.stop()}}),e,this)})))}},{key:"resume",value:function(){fs.of(this._iid).logger.debug("poll changelog sync resume()"),this._sync.start(0)}},{key:"pause",value:function(){fs.of(this._iid).logger.debug("poll changelog sync pause()"),this._sync.stop()}},{key:"close",value:function(){this.ref--,this.ref<=0&&(this.ref=0,this.pause(),this._connectionEventContext.close(),delete Qf[this._iid][this._channel.url])}}],[{key:"of",value:function(t,n,r){return Qf[t]||(Qf[t]={}),Qf[t][n.url]||(Qf[t][n.url]=new e({_iid:t,channel:n,hasPollMessage:r})),Qf[t][n.url].ref++,Qf[t][n.url]}}]),e}(),Wf=function(e){i(n,e);var t=f(n);function n(e){var a,s,i,o,u,c,l;return r(this,n),(a=t.call(this)).method=le.GET,a.path="".concat(Te(e.channelType),"/").concat(e.channelUrl,"/messages_gap"),a.params=ue({prev_start_ts:e.prevStart,prev_end_ts:e.prevEnd,prev_cache_count:e.prevCount,next_start_ts:e.nextStart,next_end_ts:e.nextEnd,next_cache_count:e.nextCount,huge_gap_threshold:null!==(s=e.threshold)&&void 0!==s?s:null,reverse:!0,custom_types:null!==(i=e.customTypes)&&void 0!==i?i:["*"],message_type:null!==(o=e.messageType)&&void 0!==o?o:null,include_reactions:null===(u=e.includeReactions)||void 0===u||u,with_sorted_meta_array:null===(c=e.includeMetaArray)||void 0===c||c,show_subchannel_messages_only:null!==(l=e.showSubchannelMessagesOnly)&&void 0!==l&&l,include_poll_details:!0,checking_continuous_messages:e.checkingContinuousMessages}),a}return s(n)}(Oe),Yf=function(e){i(n,e);var t=f(n);function n(e,a){var s,i,o,u,c,l,h;return r(this,n),(s=t.call(this,e,a)).isHugeGap=a.is_huge_gap,s.prevMessages=(null!==(i=a.prev_messages)&&void 0!==i?i:[]).map((function(t){return Bs(e,t)})),s.prevHasMore=null!==(o=a.prev_hasmore)&&void 0!==o&&o,s.isContinuousPrevMessages=null!==(u=a.is_continuous_prev_messages)&&void 0!==u&&u,s.nextMessages=(null!==(c=a.next_messages)&&void 0!==c?c:[]).map((function(t){return Bs(e,t)})),s.nextHasmore=null!==(l=a.next_hasmore)&&void 0!==l&&l,s.isContinuousNextMessages=null!==(h=a.is_continuous_next_messages)&&void 0!==h&&h,s}return s(n)}(Ue),Zf=function(t,n){var r,a,s,i;switch(n){case e.GroupChannelListOrder.LATEST_LAST_MESSAGE:return null!==(a=null===(r=t.lastMessage)||void 0===r?void 0:r.createdAt)&&void 0!==a?a:t.createdAt;case e.GroupChannelListOrder.CHRONOLOGICAL:return t.createdAt;case e.GroupChannelListOrder.CHANNEL_NAME_ALPHABETICAL:return t.name;default:return null!==(i=null===(s=t.lastMessage)||void 0===s?void 0:s.createdAt)&&void 0!==i?i:t.createdAt}},Jf=function(e,t){return e.findIndex((function(e){return e.isIdentical(t)}))},Xf=function(e,t,n){if(e.length>0){for(var r=Jf(e,t),a=0,s=e.length-1,i=Math.floor((a+s)/2);a0)s=i,i=Math.floor((a+s)/2);else{if(!(o<0))return{place:i,oldPosition:r};a=i+1,i=Math.floor((a+s)/2)}}return{place:$f(e[i],t,n)>=0?i:i+1,oldPosition:r}}return{place:e.length,oldPosition:-1}},$f=function(t,n,r){switch(r){case e.GroupChannelListOrder.LATEST_LAST_MESSAGE:return t.lastMessage&&n.lastMessage?n.lastMessage.createdAt-t.lastMessage.createdAt:t.lastMessage?-1:n.lastMessage?1:n.createdAt-t.createdAt;case e.GroupChannelListOrder.CHRONOLOGICAL:return n.createdAt-t.createdAt;case e.GroupChannelListOrder.CHANNEL_NAME_ALPHABETICAL:var a=t.name.localeCompare(n.name);return 0===a?t.createdAt-n.createdAt:a;default:return 0}},ep=function(e,t){return t instanceof Ms?e.findIndex((function(e){return e instanceof Ms&&t.isIdentical(e)})):e.findIndex((function(e){return e.isIdentical(t)}))},tp=function(e,t){return e.findIndex((function(e){return e.messageId===t}))},np=function(e,t){if(e.length>0){for(var n=0,r=e.length-1,a=Math.floor((n+r)/2);n0)r=a,a=Math.floor((n+r)/2);else{if(!(s<0))return a;n=a+1,a=Math.floor((n+r)/2)}}return e[a].createdAt>t.createdAt?a:a+1}return e.length},rp=6e5;e.MessageCollectionInitPolicy=void 0,(e.MessageCollectionInitPolicy||(e.MessageCollectionInitPolicy={})).CACHE_AND_REPLACE_BY_API="cache_and_replace_by_api";var ap,sp,ip,op=function(){function e(){r(this,e)}return s(e,[{key:"_invokeResponse",value:function(e,n,r){var a=this;Ca((function(){return b(a,void 0,void 0,t().mark((function a(){return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:t.t0=e,t.next="local"===t.t0?3:"remote"===t.t0?5:7;break;case 3:return this._onCacheResult(n,r),t.abrupt("break",7);case 5:return this._onApiResult(n,r),t.abrupt("break",7);case 7:case"end":return t.stop()}}),a,this)})))}))}},{key:"onCacheResult",value:function(e){return this._onCacheResult=e,this}},{key:"onApiResult",value:function(e){return this._onApiResult=e,this}}]),e}(),up=function(){function n(a,s){var i=this,o=s.channel,u=s.filter,c=s.startingPoint,l=s.limit;r(this,n),this._messages=[],this._unsentMessages=[],this._iid=a,this._key="mc-".concat(re()),this.filter=null!=u?u:new wo,this._channel=o,this._syncRange=new Lf({}),this._hasPrevious=!0,this._hasNext=!0,this._startingPoint="number"==typeof c?c:Date.now()+rp,this._limit=l||yo;var h=Ff.of(this._iid);h.subscribeGroupChannelEvent(this._key,{onUpdate:function(n,r,a){var s=Jf(n,i._channel);if(s>=0){switch(i._channel=n[s],r){case e.GroupChannelEventSource.EVENT_CHANNEL_UPDATED:var o=!1;for(var u in i._messages){if(i._messages[u].createdAt>=i._channel.messageOffsetTimestamp){o=!0;var c=parseInt(u);if(c>0){var l=i._messages.splice(0,c);i._removeMessagesFromView(l.map((function(e){return e.messageId})),e.MessageEventSource.EVENT_MESSAGE_OFFSET_UPDATED)}break}}!o&&i._messages.length>0&&i._removeMessagesFromView(i._messages.map((function(e){return e.messageId})),e.MessageEventSource.EVENT_MESSAGE_OFFSET_UPDATED);break;case e.GroupChannelEventSource.EVENT_CHANNEL_UNMUTED:var h=a;fs.of(i._iid).sdkState.userId===h&&i._clearCheckMyMutedTimer();break;case e.GroupChannelEventSource.EVENT_CHANNEL_MUTED:var d=a;fs.of(i._iid).sdkState.userId===d&&-1!==i.channel._myMutedRemainingTime&&i._startCheckMyMutedTimer(i.channel._myMutedRemainingTime);break;case e.GroupChannelEventSource.EVENT_CHANNEL_LEFT:i.channel.isPublic&&i._clearCheckMyMutedTimer()}Ca((function(){return b(i,void 0,void 0,t().mark((function e(){var n,a;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:a=new qf(r),hu(r)&&(null===(n=this._handler)||void 0===n?void 0:n.onChannelUpdated)&&this._handler.onChannelUpdated(a,this.channel);case 2:case"end":return e.stop()}}),e,this)})))}))}},onRemove:function(e,n){e.indexOf(i.channel.url)>=0&&(i._clearCheckMyMutedTimer(),Ca((function(){return b(i,void 0,void 0,t().mark((function e(){var r,a;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:a=new qf(n),(null===(r=this._handler)||void 0===r?void 0:r.onChannelDeleted)&&this._handler.onChannelDeleted(a,this.channel.url);case 2:case"end":return e.stop()}}),e,this)})))})))}}),h.subscribeMessageEvent(this._key,{onUpdate:function(t,n){var r,a=[],s=[],o=y(t);try{for(o.s();!(r=o.n()).done;){var u=r.value;u.channelUrl===i._channel.url&&(i.filter.match(u)?a.push(u):s.push(u.messageId))}}catch(e){o.e(e)}finally{o.f()}if(oi(n)){if(a.length>0)switch(n){case e.MessageEventSource.EVENT_MESSAGE_SENT_FAILED:case e.MessageEventSource.EVENT_MESSAGE_SENT_SUCCESS:case e.MessageEventSource.EVENT_MESSAGE_UPDATED:case e.MessageEventSource.EVENT_MESSAGE_THREADINFO_UPDATED:case e.MessageEventSource.EVENT_MESSAGE_REACTION_UPDATED:case e.MessageEventSource.SYNC_MESSAGE_CHANGELOGS:i._updateMessagesToView(a,n);break;case e.MessageEventSource.EVENT_MESSAGE_SENT_PENDING:i._addMessagesToView(a,n);break;case e.MessageEventSource.EVENT_MESSAGE_RECEIVED:i.hasNext||i._addMessagesToView(a,n);break;case e.MessageEventSource.SYNC_MESSAGE_FILL:i._addMessagesToView(a,n)}s.length>0&&i._removeMessagesFromView(s,n)}},onRemove:function(e,t){i._removeMessagesFromView(e,t)},onRemoveUnsent:function(e,t){i._removeUnsentMessageFromView(e,t)},onPollChangeLogUpdate:function(e,t){i._updatePollsToView(e,t)},onPollUpdate:function(e,t){i._applyPollUpdateEventToView(e,t)},onPollVote:function(e,t){i._applyPollVoteEventToView(e,t)}});var d=fs.of(this._iid),f=d.cacheContext,p=d.dispatcher,v=d.logger;this._channel._updateMessageCollectionLastAccessedAt(),p.dispatch(new du({channels:[this._channel],source:e.GroupChannelEventSource.CHANNEL_LASTACCESSEDAT_UPDATED})),!this._channel.isSuper&&f.localCacheEnabled&&(this._backgroundSync=zf.of(this._iid,this._channel),this._backgroundSync.resume(this._startingPoint)),this._changelogSync=Bf.of(this._iid,this._channel),this._changelogSync.resume(),this._pollChangelogSync=Kf.of(this._iid,this._channel,this._hasPollMessage.bind(this)),this._pollChangelogSync.resume(),this._prevFill=new Gf(this._key,(function(n){return b(i,void 0,void 0,t().mark((function r(){var a,s,i,o,u;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,this._getRemoteMessages(n,{prevLimit:this._limit,source:e.MessageEventSource.SYNC_MESSAGE_FILL,checkingContinuousMessages:f.localCacheEnabled});case 2:if(s=t.sent,i=s.messages,o=s.isContinuousMessages,!(i.length>0)){t.next=10;break}return u=Math.min.apply(Math,_(i.map((function(e){return e.createdAt})))),this._syncRange.extends(u),o&&(null===(a=this._backgroundSync)||void 0===a||a.range.extends(u)),t.abrupt("return",{hasNext:i.length>=this._limit&&this.viewTop0)){t.next=10;break}return u=Math.max.apply(Math,_(i.map((function(e){return e.createdAt})))),this._syncRange.extends(u),o&&(null===(a=this._backgroundSync)||void 0===a||a.range.extends(u)),t.abrupt("return",{hasNext:!(i.length>=this._limit&&this._hasNext)||this.viewBottom>u,nextToken:this._syncRange.bottom});case 10:return t.abrupt("return",{hasNext:!1,nextToken:0});case 11:case"end":return t.stop()}}),r,this)})))})),this._connectionEventContext=p.on((function(n){if(n instanceof da)switch(n.stateType){case sa.CONNECTED:i._refreshChannel(e.GroupChannelEventSource.SYNC_CHANNEL_CHANGELOGS),xa((function(){return b(i,void 0,void 0,t().mark((function e(){var n;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this.channel.getMyMutedInfo();case 2:(n=e.sent).isMuted&&-1!==n.remainingDuration&&this._startCheckMyMutedTimer(n.remainingDuration);case 4:case"end":return e.stop()}}),e,this)})))})),v.debug("check huge gap"),i._checkHugeGap();break;case sa.LOGOUT:i.dispose();break;default:i._clearCheckMyMutedTimer(),i._prevFill.stop(),i._nextFill.stop()}})),fs.of(this._iid).statLogCollector.put(new ss({type:Ae.FEATURE_LOCALCACHE,data:{use_local_cache:f.localCacheEnabled,collection_interface:{message:!0}}}))}return s(n,[{key:"channel",get:function(){return this._channel}},{key:"succeededMessages",get:function(){return _(this._messages)}},{key:"failedMessages",get:function(){return this._unsentMessages.filter((function(t){return t.sendingStatus===e.SendingStatus.FAILED}))}},{key:"pendingMessages",get:function(){return this._unsentMessages.filter((function(t){return t.sendingStatus===e.SendingStatus.PENDING}))}},{key:"hasPrevious",get:function(){return this._hasPrevious}},{key:"hasNext",get:function(){return this._hasNext}},{key:"viewTop",get:function(){return Math.min.apply(Math,_(this._messages.map((function(e){return e.createdAt}))).concat([Number.MAX_SAFE_INTEGER]))}},{key:"viewBottom",get:function(){return Math.max.apply(Math,_(this._messages.map((function(e){return e.createdAt}))).concat([0]))}},{key:"setMessageCollectionHandler",value:function(e){this._handler=e}},{key:"_filterUnderOffsetMessage",value:function(e){return e}},{key:"_addMessagesToView",value:function(n,r){var a,s=this,i=this._filterUnderOffsetMessage(n),o=[],u=[],c=y(i);try{for(c.s();!(a=c.n()).done;){var l=a.value;if(r===e.MessageEventSource.SYNC_MESSAGE_FILL){if(l.messageId>0){if(ep(this._messages,l)<0){ep(this._unsentMessages,l)<0&&o.push(l);var h=np(this._messages,l);this._messages.splice(h,0,l)}}else if(l instanceof Ms){ep(this._unsentMessages,l)<0&&ep(this._messages,l)<0&&(this._unsentMessages.push(l),o.push(l))}}else if(l.messageId>0){var d=ep(this._messages,l);if(d<0){var f=ep(this._unsentMessages,l);f<0?o.push(l):(this._unsentMessages.splice(f,1),u.push(l));var p=np(this._messages,l);this._messages.splice(p,0,l)}else u.push(l),this._messages[d]=l;if(l.updatedAt>0){var v=this._updateChildMessagesInView(l);u.push.apply(u,_(v))}}else if(l instanceof Ms){var m=ep(this._unsentMessages,l);m<0?ep(this._messages,l)<0&&(this._unsentMessages.push(l),o.push(l)):(u.push(l),this._unsentMessages[m]=l)}}}catch(e){c.e(e)}finally{c.f()}oi(r)&&Ca((function(){return b(s,void 0,void 0,t().mark((function e(){var n,a,s;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:s=new Hf(r),o.length>0&&(null===(n=this._handler)||void 0===n||n.onMessagesAdded(s,this.channel,o)),u.length>0&&(null===(a=this._handler)||void 0===a||a.onMessagesUpdated(s,this.channel,u));case 3:case"end":return e.stop()}}),e,this)})))}))}},{key:"_updateChildMessagesInView",value:function(e){var t=[];return this._messages.forEach((function(n){n.applyParentMessage(e)&&t.push(n)})),t}},{key:"_updatePollsToView",value:function(e,n){var r,a=this,s=[],i=y(e);try{for(i.s();!(r=i.n()).done;){var o=r.value,u=tp(this._messages,o.messageId);if(u>=0){var c=this._messages[u];c&&c.applyPoll(o),s.push(c)}}}catch(e){i.e(e)}finally{i.f()}return s.length>0&&oi(n)&&Ca((function(){return b(a,void 0,void 0,t().mark((function e(){var r,a;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:a=new Hf(n),s.length>0&&(null===(r=this._handler)||void 0===r||r.onMessagesUpdated(a,this.channel,s));case 2:case"end":return e.stop()}}),e,this)})))})),s}},{key:"_applyPollUpdateEventToView",value:function(e,n){var r=this,a=tp(this._messages,e.messageId);if(a>=0){var s=this._messages[a];s&&s.isUserMessage()&&s.poll&&s.poll.applyPollUpdateEvent(e)&&oi(n)&&Ca((function(){return b(r,void 0,void 0,t().mark((function e(){var r,a;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:a=new Hf(n),null===(r=this._handler)||void 0===r||r.onMessagesUpdated(a,this.channel,[s]);case 2:case"end":return e.stop()}}),e,this)})))}))}}},{key:"_applyPollVoteEventToView",value:function(e,n){var r=this,a=tp(this._messages,e.messageId);if(a>=0){var s=this._messages[a];s&&s.isUserMessage()&&s.poll&&s.poll.applyPollVoteEvent(e)&&oi(n)&&Ca((function(){return b(r,void 0,void 0,t().mark((function e(){var r,a;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:a=new Hf(n),null===(r=this._handler)||void 0===r||r.onMessagesUpdated(a,this.channel,[s]);case 2:case"end":return e.stop()}}),e,this)})))}))}}},{key:"_updateMessagesToView",value:function(e,n){var r,a=this,s=[],i=[],o=y(e);try{for(o.s();!(r=o.n()).done;){var u=r.value;if(u.messageId>0){var c=ep(this._messages,u);if(c>=0)s.push(u),this._messages[c]=u;else{var l=ep(this._unsentMessages,u);if(l>=0){var h=this._unsentMessages.splice(l,1);if(this.hasNext&&h.length>0)i.push(h[0]);else{s.push(u);var d=np(this._messages,u);this._messages.splice(d,0,u)}}}}else if(u instanceof Ms){var f=ep(this._unsentMessages,u);f>=0&&(s.push(u),this._unsentMessages[f]=u)}}}catch(e){o.e(e)}finally{o.f()}return oi(n)&&Ca((function(){return b(a,void 0,void 0,t().mark((function e(){var r,a,o;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:o=new Hf(n),s.length>0?null===(r=this._handler)||void 0===r||r.onMessagesUpdated(o,this.channel,s):i.length>0&&(null===(a=this._handler)||void 0===a||a.onMessagesDeleted(o,this.channel,[],i));case 2:case"end":return e.stop()}}),e,this)})))})),s}},{key:"_removeMessagesFromView",value:function(e,n){var r,a=this,s=[],i=[],o=y(e);try{var u=function(){var e=r.value,t=a._messages.findIndex((function(t){return t.messageId===e}));if(t>=0){var n=a._messages[t];s.push(n.messageId),i.push(n),a._messages.splice(t,1)}};for(o.s();!(r=o.n()).done;)u()}catch(e){o.e(e)}finally{o.f()}return oi(n)&&i.length>0&&Ca((function(){return b(a,void 0,void 0,t().mark((function e(){var r,a;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:a=new Hf(n),null===(r=this._handler)||void 0===r||r.onMessagesDeleted(a,this.channel,s,i);case 2:case"end":return e.stop()}}),e,this)})))})),s}},{key:"_removeUnsentMessageFromView",value:function(e,t){var n=this._unsentMessages.findIndex((function(t){return t.reqId===e}));n>=0&&this._unsentMessages.splice(n,1)}},{key:"_getLocalMessages",value:function(e,n){var r=n.prevLimit,a=void 0===r?0:r,s=n.nextLimit,i=void 0===s?0:s;return b(this,void 0,void 0,t().mark((function n(){var r,s,o,u,c;return t().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:if(r=Ff.of(this._iid),!(a>0)){n.next=7;break}return n.next=4,r.getMessagesFromCache(this._channel.url,e,"prev",this.filter,a);case 4:n.t0=n.sent,n.next=8;break;case 7:n.t0=[];case 8:if(s=n.t0,!(i>0)){n.next=15;break}return n.next=12,r.getMessagesFromCache(this._channel.url,e,"next",this.filter,i);case 12:n.t1=n.sent,n.next=16;break;case 15:n.t1=[];case 16:if(o=n.t1,!(s.length>0&&o.length>0)){n.next=27;break}u=s.map((function(e){return e.messageId})),n.t2=t().keys(o);case 20:if((n.t3=n.t2()).done){n.next=27;break}if(c=n.t3.value,!u.includes(o[c].messageId)){n.next=25;break}return o.splice(parseInt(c),1),n.abrupt("break",27);case 25:n.next=20;break;case 27:return n.abrupt("return",[].concat(_(s),_(o)).sort((function(e,t){return t.createdAt-e.createdAt})));case 28:case"end":return n.stop()}}),n,this)})))}},{key:"_getRemoteMessages",value:function(n,r){var a=r.prevLimit,s=void 0===a?0:a,i=r.nextLimit,o=void 0===i?0:i,u=r.source,c=void 0===u?e.MessageEventSource.REQUEST_MESSAGE:u,l=r.reverse,h=void 0!==l&&l,d=r.checkingContinuousMessages,f=void 0!==d&&d;return b(this,void 0,void 0,t().mark((function e(){var r;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(r=wi.of(this._iid),!(s>0||o>0)){e.next=7;break}return e.next=4,r._getMessagesByTimestampForCollection(this._channel.url,this._channel.channelType,n,ce(Object.assign(Object.assign({},this.filter),{isInclusive:!0,reverse:h,prevResultSize:s,nextResultSize:o,includeMetaArray:!0,includeReactions:!0,includeThreadInfo:!0,includeParentMessageInfo:!0})),c,f);case 4:e.t0=e.sent,e.next=8;break;case 7:e.t0={messages:[],isContinuousMessages:!1};case 8:return e.abrupt("return",e.t0);case 9:case"end":return e.stop()}}),e,this)})))}},{key:"_checkHugeGap",value:function(){var n;return b(this,void 0,void 0,t().mark((function r(){var a,s,i,o,u,c,l,h,d,f,p,v,m,g,y,k,w,C,x,T,S=this;return t().wrap((function(r){for(;;)switch(r.prev=r.next){case 0:if(!(this._messages.length>0)){r.next=16;break}return a=this._syncRange.top,s=this.viewTop,i=this._syncRange.bottom,o=this.hasNext?this.viewBottom:Number.MAX_SAFE_INTEGER,u=Ff.of(this._iid),r.next=8,u.getCachedMessageCountBetween(this._channel.url,this.filter,s,a);case 8:return c=r.sent,r.next=11,u.getCachedMessageCountBetween(this._channel.url,this.filter,i,o);case 11:return l=r.sent,r.next=14,wa((function(){return b(S,void 0,void 0,t().mark((function n(){var r,u,h,d,f,p,v,m,g,y,k,E,w,C,x,T,S,I,N,M,A,O=this;return t().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return u=fs.of(this._iid),h=u.dispatcher,d=u.requestQueue,f=u.cacheContext,p=new Wf(Object.assign({channelUrl:this._channel.url,channelType:this._channel.channelType,prevStart:s,prevEnd:a,prevCount:c,nextStart:i,nextEnd:o,nextCount:l,checkingContinuousMessages:f.localCacheEnabled},this.filter)),n.next=4,d.send(p);case 4:v=n.sent,m=v.as(Yf),g=m.isHugeGap,y=m.prevMessages,k=void 0===y?[]:y,E=m.prevHasMore,w=m.isContinuousPrevMessages,C=m.nextMessages,x=void 0===C?[]:C,T=m.nextHasmore,S=m.isContinuousNextMessages,g?Ca((function(){return b(O,void 0,void 0,t().mark((function e(){var n;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:null===(n=this._handler)||void 0===n||n.onHugeGapDetected();case 1:case"end":return e.stop()}}),e,this)})))})):(this._hasPrevious=E,this._hasNext=T,I=this.viewTop,N=this.viewBottom,M=Math.min.apply(Math,[Number.MAX_SAFE_INTEGER,I].concat(_(k.map((function(e){return e.createdAt}))))),A=Math.max.apply(Math,[0,N].concat(_(x.map((function(e){return e.createdAt}))))),h.dispatch(new ui({messages:k,source:e.MessageEventSource.SYNC_MESSAGE_FILL})),h.dispatch(new ui({messages:x,source:e.MessageEventSource.SYNC_MESSAGE_FILL})),this._syncRange.extends(M,A),(w||S)&&(null===(r=this._backgroundSync)||void 0===r||r.range.extends(M,A)),IA&&this._nextFill.start(A));case 7:case"end":return n.stop()}}),n,this)})))}),1);case 14:r.next=31;break;case 16:return h=fs.of(this._iid),d=h.cacheContext,f=Math.floor(this._limit/2),p=Date.now(),r.prev=19,r.next=22,this._getRemoteMessages(p,{prevLimit:f,nextLimit:f,source:e.MessageEventSource.SYNC_MESSAGE_FILL,checkingContinuousMessages:d.localCacheEnabled});case 22:if(v=r.sent,m=v.messages,g=v.isContinuousMessages,m.length>0){for(k=m.map((function(e){return e.createdAt})),w=0,C=0,x=0;x=p&&C++;this._hasPrevious=w>=f,this._hasNext=C>=f,(y=this._syncRange).extends.apply(y,_(k)),g&&(null===(n=this._backgroundSync)||void 0===n||n.range.extends(this._syncRange.top,this._syncRange.bottom)),this._addMessagesToView(m,e.MessageEventSource.SYNC_MESSAGE_FILL)}else this._hasPrevious=!1,this._hasNext=!1;r.next=31;break;case 28:r.prev=28,r.t0=r.catch(19),r.t0 instanceof A&&r.t0.code===E.NOT_FOUND_IN_DATABASE&&(this._hasPrevious=!1,this._hasNext=!1);case 31:case"end":return r.stop()}}),r,this,[[19,28]])})))}},{key:"_loadUnsentMessages",value:function(){return b(this,void 0,void 0,t().mark((function e(){var n;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n=Ff.of(this._iid),e.next=3,n.getUnsentMessagesFromCache(this._channel.url,this.filter);case 3:this._unsentMessages=e.sent;case 4:case"end":return e.stop()}}),e,this)})))}},{key:"_hasPollMessage",value:function(){return b(this,void 0,void 0,t().mark((function e(){var n;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n=Ff.of(this._iid),e.next=3,n.getPollMessagesFromCache(this._channel.url,Date.now()+rp,this.filter,1);case 3:if(!(e.sent.length>0)){e.next=6;break}return e.abrupt("return",!0);case 6:return e.abrupt("return",!1);case 7:case"end":return e.stop()}}),e,this)})))}},{key:"_refreshChannel",value:function(e){Ff.of(this._iid).refreshChannel(this.channel.url,!0,e)}},{key:"_startCheckMyMutedTimer",value:function(n){var r=this;this._clearCheckMyMutedTimer(),this._checkMyMutedStateTimer=setTimeout((function(){return b(r,void 0,void 0,t().mark((function n(){var r,a,s,i;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return this._checkMyMutedStateTimer=void 0,a=!0,t.prev=2,t.next=5,this._channel.getMyMutedInfo();case 5:s=t.sent,a=!s.isMuted,t.next=12;break;case 9:t.prev=9,t.t0=t.catch(2),a=!0;case 12:return t.prev=12,a&&(this.channel.myMutedState=e.MutedState.UNMUTED,i=new qf(e.GroupChannelEventSource.EVENT_CHANNEL_UNMUTED),null===(r=this._handler)||void 0===r||r.onChannelUpdated(i,this.channel)),t.finish(12);case 15:case"end":return t.stop()}}),n,this,[[2,9,12,15]])})))}),n+1e3)}},{key:"_clearCheckMyMutedTimer",value:function(){this._checkMyMutedStateTimer&&(clearTimeout(this._checkMyMutedStateTimer),this._checkMyMutedStateTimer=void 0)}},{key:"initialize",value:function(n){var r=this,a=new op;this._messages=[],this._unsentMessages=[],this._syncRange=new Lf({}),this._hasNext=!0,this._hasPrevious=!0,this._refreshChannel(e.GroupChannelEventSource.REFRESH_CHANNEL),xa((function(){return b(r,void 0,void 0,t().mark((function e(){var n;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this.channel.getMyMutedInfo();case 2:(n=e.sent).isMuted&&-1!==n.remainingDuration&&this._startCheckMyMutedTimer(n.remainingDuration);case 4:case"end":return e.stop()}}),e,this)})))}));var s=Math.floor(this._limit/2);if(n===e.MessageCollectionInitPolicy.CACHE_AND_REPLACE_BY_API)this._getLocalMessages(this._startingPoint,{prevLimit:s,nextLimit:s}).then((function(n){return b(r,void 0,void 0,t().mark((function r(){var s;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return s=this._filterUnderOffsetMessage(n),this._addMessagesToView(s,e.MessageEventSource.REQUEST_MESSAGE),t.next=4,this._loadUnsentMessages();case 4:a._invokeResponse("local",null,s);case 5:case"end":return t.stop()}}),r,this)})))})).catch((function(e){if(M(e))throw e;a._invokeResponse("local",e,null)})).finally((function(){var t=fs.of(r._iid).cacheContext;r._getRemoteMessages(r._startingPoint,{prevLimit:s,nextLimit:s,reverse:!0,checkingContinuousMessages:t.localCacheEnabled}).then((function(t){var n,i=t.messages,o=t.isContinuousMessages;r._messages=[];var u=r._filterUnderOffsetMessage(i);if(u.length>0){for(var c,l=u.map((function(e){return e.createdAt})),h=0,d=0,f=0;f=r._startingPoint&&d++}r._hasPrevious=h>=s,r._hasNext=d>=s,(c=r._syncRange).extends.apply(c,_(u.map((function(e){return e.createdAt})))),o&&(null===(n=r._backgroundSync)||void 0===n||n.range.extends(r._syncRange.top,r._syncRange.bottom)),r._addMessagesToView(u,e.MessageEventSource.REQUEST_MESSAGE)}else r._hasPrevious=!1,r._hasNext=!1;a._invokeResponse("remote",null,u)})).catch((function(e){if(M(e))throw e;a._invokeResponse("remote",e,null)}))}));var i=fs.of(this._iid),o=i.cacheContext;return i.statLogCollector.put(new ss({type:Ae.FEATURE_LOCALCACHE,data:{use_local_cache:o.localCacheEnabled,collection_interface:{message_init_policy:n}}})),a}},{key:"loadPrevious",value:function(){return b(this,void 0,void 0,t().mark((function n(){var r,a,s,i=this;return t().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:if(!this._hasPrevious){n.next=14;break}return r=this.viewTop,a=[],n.next=5,xa((function(){return b(i,void 0,void 0,t().mark((function e(){return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.t0=this,e.next=3,this._getLocalMessages(r,{prevLimit:this._limit});case 3:e.t1=e.sent,a=e.t0._filterUnderOffsetMessage.call(e.t0,e.t1);case 5:case"end":return e.stop()}}),e,this)})))}));case 5:if(0!==a.length&&this._backgroundSync&&this._backgroundSync.isWrappingMessages(a)){n.next=11;break}return n.next=8,xa((function(){return b(i,void 0,void 0,t().mark((function e(){var n,s,i,o,u,c;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return i=fs.of(this._iid),o=i.cacheContext,e.next=3,this._getRemoteMessages(r,{prevLimit:this._limit,checkingContinuousMessages:o.localCacheEnabled});case 3:u=e.sent,a=this._filterUnderOffsetMessage(u.messages),this._hasPrevious=a.length>=this._limit,a.length>0&&((c=this._syncRange).extends.apply(c,_(a.map((function(e){return e.createdAt})))),(null===(n=this._backgroundSync)||void 0===n?void 0:n.range.overlap(this._syncRange))&&u.isContinuousMessages&&(null===(s=this._backgroundSync)||void 0===s||s.range.extends(this._syncRange.top)));case 7:case"end":return e.stop()}}),e,this)})))}));case 8:this._addMessagesToView(a,e.MessageEventSource.REQUEST_MESSAGE),n.next=13;break;case 11:this._hasPrevious=a.length>=this._limit,a.length>0&&((s=this._syncRange).extends.apply(s,_(a.map((function(e){return e.createdAt})))),this._addMessagesToView(a,e.MessageEventSource.REQUEST_MESSAGE));case 13:return n.abrupt("return",a);case 14:return n.abrupt("return",[]);case 15:case"end":return n.stop()}}),n,this)})))}},{key:"loadNext",value:function(){var n;return b(this,void 0,void 0,t().mark((function r(){var a,s,i,o=this;return t().wrap((function(r){for(;;)switch(r.prev=r.next){case 0:if(this._hasNext){r.next=2;break}return r.abrupt("return",[]);case 2:return a=this.viewBottom,s=[],r.next=6,xa((function(){return b(o,void 0,void 0,t().mark((function e(){return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.t0=this,e.next=3,this._getLocalMessages(a,{nextLimit:this._limit});case 3:e.t1=e.sent,s=e.t0._filterUnderOffsetMessage.call(e.t0,e.t1);case 5:case"end":return e.stop()}}),e,this)})))}));case 6:if(0!==s.length&&(null===(n=this._backgroundSync)||void 0===n?void 0:n.isWrappingMessages(s))){r.next=12;break}return r.next=9,xa((function(){return b(o,void 0,void 0,t().mark((function e(){var n,r,i,o,u,c;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return i=fs.of(this._iid),o=i.cacheContext,e.next=3,this._getRemoteMessages(a,{nextLimit:this._limit,checkingContinuousMessages:o.localCacheEnabled});case 3:u=e.sent,s=this._filterUnderOffsetMessage(u.messages),this._hasNext=s.length>=this._limit,s.length>0&&((c=this._syncRange).extends.apply(c,_(s.map((function(e){return e.createdAt})))),(null===(n=this._backgroundSync)||void 0===n?void 0:n.range.overlap(this._syncRange))&&u.isContinuousMessages&&(null===(r=this._backgroundSync)||void 0===r||r.range.extends(this._syncRange.bottom)));case 7:case"end":return e.stop()}}),e,this)})))}));case 9:this._addMessagesToView(s,e.MessageEventSource.REQUEST_MESSAGE),r.next=14;break;case 12:this._hasNext=s.length>=this._limit,s.length>0&&((i=this._syncRange).extends.apply(i,_(s.map((function(e){return e.createdAt})))),this._addMessagesToView(s,e.MessageEventSource.REQUEST_MESSAGE));case 14:return r.abrupt("return",s);case 15:case"end":return r.stop()}}),r,this)})))}},{key:"removeFailedMessage",value:function(e){return b(this,void 0,void 0,t().mark((function n(){var r,a;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return r=Ff.of(this._iid),t.next=3,r.removeFailedMessageFromCache(e);case 3:(a=this._unsentMessages.findIndex((function(t){return t.reqId===e})))>-1&&this._unsentMessages.splice(a,1);case 5:case"end":return t.stop()}}),n,this)})))}},{key:"dispose",value:function(){var t,n,r,a=fs.of(this._iid),s=a.cacheContext,i=a.dispatcher;this._clearCheckMyMutedTimer(),this._channel._updateMessageCollectionLastAccessedAt(),i.dispatch(new du({channels:[this._channel],source:e.GroupChannelEventSource.CHANNEL_LASTACCESSEDAT_UPDATED})),s.localCacheEnabled&&(this._prevFill.stop(),this._nextFill.stop()),null===(t=this._backgroundSync)||void 0===t||t.close(),null===(n=this._changelogSync)||void 0===n||n.close(),null===(r=this._pollChangelogSync)||void 0===r||r.close();var o=Ff.of(this._iid);o.unsubscribeGroupChannelEvent(this._key),o.unsubscribeMessageEvent(this._key),this._connectionEventContext&&this._connectionEventContext.close()}}]),n}(),cp={coverUrl:void 0,coverImage:void 0,isDistinct:void 0,isPublic:void 0,isDiscoverable:void 0,accessCode:void 0,name:void 0,data:void 0,customType:void 0,operatorUserIds:void 0,messageSurvivalSeconds:void 0},lp=function(e){return L("string",e.coverUrl,!0)&&(q(e.coverImage)||L("string",e.coverImage,!0))&&L("boolean",e.isDistinct,!0)&&L("boolean",e.isPublic,!0)&&L("boolean",e.isDiscoverable,!0)&&L("string",e.accessCode,!0)&&L("string",e.name,!0)&&L("string",e.data,!0)&&L("string",e.customType,!0)&&F("string",e.operatorUserIds,!0)&&L("number",e.messageSurvivalSeconds,!0)},hp=function(e){i(n,e);var t=f(n);function n(e){var a;r(this,n);var s=e.channelUrl,i=e.token,o=e.limit,u=e.order,c=e.mutedMemberFilter,l=e.memberStateFilter,h=e.nicknameStartsWithFilter,d=e.operatorFilter;return(a=t.call(this)).method=le.GET,a.path="".concat(pe,"/").concat(encodeURIComponent(s),"/members"),a.params={token:i,limit:o,order:u,muted_member_filter:c,member_state_filter:l,nickname_startswith:h,operator_filter:d,show_member_is_muted:!0,show_read_receipt:!0,show_delivery_receipt:!0},a}return s(n)}(Oe),dp=function(e){i(n,e);var t=f(n);function n(e,a){var s;r(this,n),(s=t.call(this,e,a)).members=[];var i=a.next,o=a.members;return s.token=i,o&&o.length>0&&(s.members=o.map((function(t){return new dd(e,t)}))),s}return s(n)}(Ue);e.MutedMemberFilter=void 0,(ap=e.MutedMemberFilter||(e.MutedMemberFilter={})).ALL="all",ap.MUTED="muted",ap.UNMUTED="unmuted",e.MemberListOrder=void 0,(sp=e.MemberListOrder||(e.MemberListOrder={})).MEMBER_NICKNAME_ALPHABETICAL="member_nickname_alphabetical",sp.OPERATOR_THEN_MEMBER_ALPHABETICAL="operator_then_member_alphabetical",e.MemberStateFilter=void 0,(ip=e.MemberStateFilter||(e.MemberStateFilter={})).ALL="all",ip.JOINED="joined_only",ip.INVITED="invited_only",ip.INVITED_BY_FRIEND="invited_by_friend",ip.INVITED_BY_NON_FRIEND="invited_by_non_friend";var fp,pp,vp,_p=function(n){i(u,n);var a=f(u);function u(t,n,s){var i,o,c,l,h;return r(this,u),(i=a.call(this,t,n,e.ChannelType.GROUP,s)).mutedMemberFilter=e.MutedMemberFilter.ALL,i.memberStateFilter=e.MemberStateFilter.ALL,i.nicknameStartsWithFilter=null,i.operatorFilter=e.OperatorFilter.ALL,i.order=e.MemberListOrder.MEMBER_NICKNAME_ALPHABETICAL,i.mutedMemberFilter=null!==(o=s.mutedMemberFilter)&&void 0!==o?o:e.MutedMemberFilter.ALL,i.memberStateFilter=null!==(c=s.memberStateFilter)&&void 0!==c?c:e.MemberStateFilter.ALL,i.nicknameStartsWithFilter=null!==(l=s.nicknameStartsWithFilter)&&void 0!==l?l:null,i.order=null!==(h=s.order)&&void 0!==h?h:e.MemberListOrder.MEMBER_NICKNAME_ALPHABETICAL,i}return s(u,[{key:"_validate",value:function(){return p(o(u.prototype),"_validate",this).call(this)&&D(e.MutedMemberFilter,this.mutedMemberFilter)&&D(e.MemberStateFilter,this.memberStateFilter)&&(L("string",this.nicknameStartsWithFilter)||null===this.nicknameStartsWithFilter)&&D(e.OperatorFilter,this.operatorFilter)&&D(e.MemberListOrder,this.order)}},{key:"next",value:function(){return b(this,void 0,void 0,t().mark((function e(){var n,r,a,s,i,o,u;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!this._validate()){e.next=20;break}if(this._isLoading){e.next=17;break}if(!this._hasNext){e.next=14;break}return this._isLoading=!0,n=fs.of(this._iid),r=n.requestQueue,a=new hp(ce(Object.assign(Object.assign({},this),{token:this._token}))),e.next=8,r.send(a);case 8:return s=e.sent,i=s.as(dp),o=i.members,u=i.token,this._token=u,this._hasNext=!!u,this._isLoading=!1,e.abrupt("return",o);case 14:return e.abrupt("return",[]);case 17:throw A.queryInProgress;case 18:e.next=21;break;case 20:throw A.invalidParameters;case 21:case"end":return e.stop()}}),e,this)})))}}]),u}(Li),mp=function(e){i(n,e);var t=f(n);function n(e){var a;r(this,n);var s=e.channelUrl,i=e.userId,o=e.accessCode;return(a=t.call(this)).method=le.PUT,a.path="".concat(pe,"/").concat(encodeURIComponent(s),"/accept"),a.params={user_id:i,access_code:o},a}return s(n)}(Oe),gp=function(t){i(a,t);var n=f(a);function a(t,s){var i;return r(this,a),(i=n.call(this,t,s)).channel=new Kp(t,s),i.channel.myMemberState=e.MemberState.JOINED,i}return s(a)}(Ue),yp=function(e){i(n,e);var t=f(n);function n(e){var a;r(this,n);var s=e.channelUrl,i=e.isDistinct,o=e.isPublic,u=e.isDiscoverable,c=e.coverUrl,l=e.coverImage,h=e.accessCode,d=e.name,f=e.data,p=e.customType,v=e.operatorUserIds,_=e.messageSurvivalSeconds;return(a=t.call(this)).method=le.PUT,a.path="".concat(pe,"/").concat(encodeURIComponent(s)),a.params=ue({is_distinct:i,is_public:o,is_discoverable:u,name:d,data:f,custom_type:p,cover_url:c,cover_file:l,access_code:h,operator_ids:v,message_survival_seconds:_}),a}return s(n)}(Oe),kp=function(e){i(n,e);var t=f(n);function n(e,a){var s;return r(this,n),(s=t.call(this,e,a)).channel=new Kp(e,a),s}return s(n)}(Ue),bp=function(e){i(n,e);var t=f(n);function n(e){var a;r(this,n);var s=e.channelUrl;return(a=t.call(this)).method=le.DELETE,a.path="".concat(pe,"/").concat(encodeURIComponent(s)),a}return s(n)}(Oe),Ep=function(e){i(n,e);var t=f(n);function n(e){var a;r(this,n);var s=e.channelUrl;return(a=t.call(this)).method=le.DELETE,a.path="".concat(pe,"/").concat(encodeURIComponent(s),"/hide"),a}return s(n)}(Oe),wp=function(e){i(n,e);var t=f(n);function n(e){var a,s=e.userId,i=e.channelUrl,o=e.countPreference;return r(this,n),(a=t.call(this)).method=le.PUT,a.path="".concat(de,"/").concat(encodeURIComponent(s),"/count_preference/").concat(encodeURIComponent(i)),a.params={count_preference:o},a}return s(n)}(Oe),Cp=function(e){i(n,e);var t=f(n);function n(e,a){var s;return r(this,n),(s=t.call(this,e,a)).countPreference=a.count_preference,s}return s(n)}(Ue),xp=function(e){i(n,e);var t=f(n);function n(e){var a;r(this,n);var s=e.channelUrl;return(a=t.call(this)).method=le.PUT,a.path="".concat(pe,"/").concat(encodeURIComponent(s),"/reset_user_history"),a}return s(n)}(Oe),Tp=function(e){i(n,e);var t=f(n);function n(e,a){var s;r(this,n),s=t.call(this,e,a);var i=a.ts_message_offset;return s.messageOffsetTimestamp=i,s}return s(n)}(Ue),Sp=Object.assign(Object.assign({},xl),{scheduledAt:void 0,file:void 0,fileUrl:void 0,fileName:void 0,mimeType:void 0,fileSize:void 0,thumbnailSizes:void 0,requireAuth:!1}),Ip=function(e){return Tl(e)&&L("number",e.scheduledAt,!0)&&(q(e.file)||L("string",e.fileUrl))&&L("string",e.fileName,!0)&&L("string",e.mimeType,!0)&&L("number",e.fileSize,!0)&&(null===e.thumbnailSizes||void 0===e.thumbnailSizes||e.thumbnailSizes.every((function(e){return L("object",e)&&e.maxWidth>0&&e.maxHeight>0})))},Np=Object.assign(Object.assign({},Sl),{scheduledAt:void 0}),Mp=function(e){return Il(e)&&L("number",e.scheduledAt,!0)},Ap=function(t){i(a,t);var n=f(a);function a(t){var s,i;r(this,a),s=n.call(this);var o=[];t.mentionType===e.MentionType.USERS&&(t.mentionedUserIds?o=t.mentionedUserIds:t.mentionedUsers&&(o=t.mentionedUsers.map((function(e){return e.userId}))));var u=t.channelType,c=t.channelUrl,l=t.scheduledMessageId;return s.method=le.PUT,s.path="".concat(Te(u),"/").concat(encodeURIComponent(c),"/scheduled_messages/").concat(encodeURIComponent(l)),s.params=ue(ce({req_id:t.reqId,scheduled_at:t.scheduledAt,message_type:Y.FILE,url:t.fileUrl,file_name:t.fileName,file_size:t.fileSize,file_type:t.mimeType,thumbnails:t.thumbnailSizes?t.thumbnailSizes.map((function(e){return As.payloadify(e)})):[],custom_type:t.customType,data:t.data,require_auth:t.requireAuth,mention_type:t.mentionType,mentioned_user_ids:o,sorted_metaarray:null===(i=t.metaArrays)||void 0===i?void 0:i.map((function(e){return Es.payloadify(e)})),apple_critical_alert_options:t.appleCriticalAlertOptions?xs.payloadify(t.appleCriticalAlertOptions):null,push_option:t.pushNotificationDeliveryOption})),s}return s(a)}(Oe),Op=function(e){i(n,e);var t=f(n);function n(e,a){var s;return r(this,n),(s=t.call(this,e,a)).message=new Qs(e,a),s}return s(n)}(Ue),Up=function(t){i(a,t);var n=f(a);function a(t){var s,i;r(this,a),s=n.call(this);var o=[];t.mentionType===e.MentionType.USERS&&(t.mentionedUserIds?o=t.mentionedUserIds:t.mentionedUsers&&(o=t.mentionedUsers.map((function(e){return e.userId}))));var u=t.channelType,c=t.channelUrl,l=t.scheduledMessageId;return s.method=le.PUT,s.path="".concat(Te(u),"/").concat(encodeURIComponent(c),"/scheduled_messages/").concat(encodeURIComponent(l)),s.params=ue(ce({req_id:t.reqId,scheduled_at:t.scheduledAt,message_type:Y.USER,message:t.message,custom_type:t.customType,data:t.data,mention_type:t.mentionType,mentioned_user_ids:o,sorted_metaarray:null===(i=t.metaArrays)||void 0===i?void 0:i.map((function(e){return Es.payloadify(e)})),apple_critical_alert_options:t.appleCriticalAlertOptions?xs.payloadify(t.appleCriticalAlertOptions):null,target_langs:t.translationTargetLanguages,push_option:t.pushNotificationDeliveryOption})),s}return s(a)}(Oe),Rp=function(e){i(n,e);var t=f(n);function n(e){var a;r(this,n),a=t.call(this);var s=e.channelType,i=e.channelUrl,o=e.scheduledMessageId;return a.method=le.DELETE,a.path="".concat(Te(s),"/").concat(encodeURIComponent(i),"/scheduled_messages/").concat(encodeURIComponent(o)),a}return s(n)}(Oe),Lp=function(e){i(n,e);var t=f(n);function n(e){var a;r(this,n),a=t.call(this);var s=e.channelType,i=e.channelUrl,o=e.scheduledMessageId;return a.method=le.POST,a.path="".concat(Te(s),"/").concat(encodeURIComponent(i),"/scheduled_messages/").concat(encodeURIComponent(o),"/send_now"),a}return s(n)}(Oe),Dp=function(e){i(n,e);var t=f(n);function n(e){var a,s=e.userId,i=e.channelUrl,o=e.pushTriggerOption;return r(this,n),(a=t.call(this)).method=le.PUT,a.path="".concat(de,"/").concat(encodeURIComponent(s),"/push_preference/").concat(encodeURIComponent(i)),a.params={push_trigger_option:o},a}return s(n)}(Oe),Pp=function(e){i(n,e);var t=f(n);function n(e,a){var s;return r(this,n),(s=t.call(this,e,a)).pushTriggerOption=a.push_trigger_option,s.enabled=a.enable,s}return s(n)}(Ue),Fp=function(e){i(n,e);var t=f(n);function n(e){var a,s=e.userId,i=e.channelUrl;return r(this,n),(a=t.call(this)).method=le.GET,a.path="".concat(de,"/").concat(encodeURIComponent(s),"/push_preference/").concat(encodeURIComponent(i)),a}return s(n)}(Oe),Gp=function(e){i(n,e);var t=f(n);function n(e,a){var s;return r(this,n),(s=t.call(this,e,a)).pushTriggerOption=a.push_trigger_option,s.enabled=a.enable,s}return s(n)}(Ue),qp=function(e){i(n,e);var t=f(n);function n(e){var a,s=e.channelType,i=e.channelUrl,o=e.messageId;return r(this,n),(a=t.call(this)).method=le.POST,a.path="".concat(Te(s),"/").concat(encodeURIComponent(i),"/messages/").concat(o,"/pin"),a}return s(n)}(Oe),Hp=function(e){i(n,e);var t=f(n);function n(e){var a,s=e.channelType,i=e.channelUrl,o=e.messageId;return r(this,n),(a=t.call(this)).method=le.DELETE,a.path="".concat(Te(s),"/").concat(encodeURIComponent(i),"/messages/").concat(o,"/pin"),a}return s(n)}(Oe),jp=function(e){i(n,e);var t=f(n);function n(e,a){var s;return r(this,n),(s=t.call(this,e)).message=Bs(e,a.message),s}return s(n)}(Ha),zp=function(e){i(n,e);var t=f(n);function n(e){var a;r(this,n);var s=e.channelType,i=e.channelUrl,o=e.limit,u=e.token,c=e.includeReactions,l=e.includeMetaArray,h=e.includeParentMessageInfo,d=e.includeThreadInfo,f=e.includePollDetails;return(a=t.call(this)).method=le.GET,a.path="".concat(Te(s),"/").concat(encodeURIComponent(i),"/pinned_messages"),a.params=ue({limit:o,token:u,include_reactions:c,with_sorted_meta_array:l,include_thread_info:d,include_parent_message_info:h,include_poll_details:f}),a}return s(n)}(Oe),Vp=function(e){i(n,e);var t=f(n);function n(e,a){var s;r(this,n),s=t.call(this,e,a);var i=a.pinned_messages,o=a.has_more,u=a.next;return s.pinnedMessages=i.map((function(t){return new jp(e,t)})),s.hasMore=o,s.token=u,s}return s(n)}(Ue),Bp=function(e){i(a,e);var n=f(a);function a(e,t,s,i){var o;return r(this,a),(o=n.call(this,e,t,s,i)).includeMetaArray=i.includeMetaArray,o.includeReactions=i.includeReactions,o.includeParentMessageInfo=i.includeParentMessageInfo,o.includeThreadInfo=i.includeThreadInfo,o.includePollDetails=i.includePollDetails,o}return s(a,[{key:"_validate",value:function(){return p(o(a.prototype),"_validate",this).call(this)&&L("boolean",this.includeMetaArray,!0)&&L("boolean",this.includeReactions,!0)&&L("boolean",this.includeParentMessageInfo,!0)&&L("boolean",this.includeThreadInfo,!0)&&L("boolean",this.includePollDetails,!0)}},{key:"next",value:function(){return b(this,void 0,void 0,t().mark((function e(){var n,r,a,s,i,o,u,c;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!this._validate()){e.next=20;break}if(this._isLoading){e.next=17;break}if(!this._hasNext){e.next=14;break}return this._isLoading=!0,n=fs.of(this._iid),r=n.requestQueue,a=new zp(Object.assign(Object.assign({},this),{token:this._token})),e.next=8,r.send(a);case 8:return s=e.sent,i=s.as(Vp),o=i.pinnedMessages,u=i.hasMore,c=i.token,this._token=c,this._hasNext=!!u,this._isLoading=!1,e.abrupt("return",o);case 14:return e.abrupt("return",[]);case 17:throw A.queryInProgress;case 18:e.next=21;break;case 20:throw A.invalidParameters;case 21:case"end":return e.stop()}}),e,this)})))}}]),a}(Li);e.CountPreference=void 0,(fp=e.CountPreference||(e.CountPreference={})).ALL="all",fp.UNREAD_MESSAGE_COUNT_ONLY="unread_message_count_only",fp.UNREAD_MENTION_COUNT_ONLY="unread_mention_count_only",fp.OFF="off",e.MutedState=void 0,(pp=e.MutedState||(e.MutedState={})).MUTED="muted",pp.UNMUTED="unmuted",e.HiddenState=void 0,(vp=e.HiddenState||(e.HiddenState={})).UNHIDDEN="unhidden",vp.HIDDEN_ALLOW_AUTO_UNHIDE="hidden_allow_auto_unhide",vp.HIDDEN_PREVENT_AUTO_UNHIDE="hidden_prevent_auto_unhide";var Qp,Kp=function(n){i(u,n);var a=f(u);function u(t,n){var s,i,o,c,l,h,d,f,p,v,m,g,y,k,b,E,w,C,x,T;(r(this,u),(s=a.call(this,t,n))._unreadMemberStateMap=new Map,s._undeliveredMemberStateMap=new Map,s._typingStatus=new Map,s._lastMemberCountUpdated=0,s._typingStarted=0,s._typingEnded=0,s.isDistinct=!1,s.isSuper=!1,s.isBroadcast=!1,s.isExclusive=!1,s.isPublic=!1,s.isDiscoverable=!0,s.isAccessCodeRequired=!1,s.isPushEnabled=!1,s.unreadMessageCount=0,s.unreadMentionCount=0,s.members=[],s.memberCount=0,s.joinedMemberCount=0,s.hiddenState=e.HiddenState.UNHIDDEN,s.lastMessage=null,s.messageOffsetTimestamp=0,s.messageSurvivalSeconds=-1,s.myMemberState=e.MemberState.NONE,s.myRole=e.Role.NONE,s.myMutedState=e.MutedState.UNMUTED,s.myLastRead=0,s.myCountPreference=e.CountPreference.ALL,s.myPushTriggerOption=e.PushTriggerOption.DEFAULT,s.inviter=null,s.invitedAt=0,s.joinedAt=0,s.pinnedMessageIds=[],s.lastPinnedMessage=null,s._pinnedMessagesUpdatedAt=0,s._myMutedRemainingTime=-1,s.channelType=e.ChannelType.GROUP,s.isDistinct=null!==(i=n.is_distinct)&&void 0!==i&&i,s.isSuper=null!==(o=n.is_super)&&void 0!==o&&o,s.isBroadcast=null!==(c=n.is_broadcast)&&void 0!==c&&c,s.isExclusive=null!==(l=n.is_exclusive)&&void 0!==l&&l,s.isPublic=null!==(h=n.is_public)&&void 0!==h&&h,s.isDiscoverable=null!==(d=n.is_discoverable)&&void 0!==d?d:s.isPublic,s.isAccessCodeRequired=null!==(f=n.is_access_code_required)&&void 0!==f&&f,s.isPushEnabled=null!==(p=n.is_push_enabled)&&void 0!==p&&p,Array.isArray(n.members))&&(T=s.members).push.apply(T,_(n.members.map((function(e){return new dd(s._iid,e)}))));return s.memberCount=null!==(v=n.member_count)&&void 0!==v?v:0,s.joinedMemberCount=null!==(m=n.joined_member_count)&&void 0!==m?m:0,s.hiddenState=D(e.HiddenState,n.hidden_state)?n.hidden_state:e.HiddenState.UNHIDDEN,s.messageOffsetTimestamp=null!==(g=n.ts_message_offset)&&void 0!==g?g:0,s.messageSurvivalSeconds=null!==(y=n.message_survival_seconds)&&void 0!==y?y:-1,s.lastMessage=n.last_message?Bs(s._iid,Object.assign({channel_type:s.channelType},n.last_message)):null,n.read_receipt&&Object.keys(n.read_receipt).forEach((function(e){L("number",n.read_receipt[e])&&s._updateUnreadMemberState(e,n.read_receipt[e])})),n.delivery_receipt&&Object.keys(n.delivery_receipt).forEach((function(e){L("number",n.delivery_receipt[e])&&s._updateUndeliveredMemberState(e,n.delivery_receipt[e])})),s.myMemberState=D(e.MemberState,n.member_state)?n.member_state:e.MemberState.NONE,s.myRole=D(e.Role,n.my_role)?n.my_role:e.Role.NONE,D(e.MutedState,n.is_muted)?s.myMutedState=n.is_muted:L("boolean",n.is_muted)?s.myMutedState=n.is_muted?e.MutedState.MUTED:e.MutedState.UNMUTED:s.myMutedState=e.MutedState.UNMUTED,s.myCountPreference=D(e.CountPreference,n.count_preference)?n.count_preference:e.CountPreference.ALL,s.myPushTriggerOption=D(e.PushTriggerOption,n.push_trigger_option)?n.push_trigger_option:e.PushTriggerOption.ALL,s.myLastRead=null!==(k=n.user_last_read)&&void 0!==k?k:0,s.inviter=n.inviter?new Xa(s._iid,n.inviter):null,s.invitedAt=null!==(b=n.invited_at)&&void 0!==b?b:0,s.joinedAt=null!==(E=n.joined_ts)&&void 0!==E?E:0,s._updateUnreadCount(null!==(w=n.unread_message_count)&&void 0!==w?w:0,null!==(C=n.unread_mention_count)&&void 0!==C?C:0),s.pinnedMessageIds=null!==(x=n.pinned_message_ids)&&void 0!==x?x:[],s.lastPinnedMessage=n.latest_pinned_message?Bs(s._iid,Object.assign({channel_type:s.channelType},n.latest_pinned_message)):null,s}return s(u,[{key:"isHidden",get:function(){return this.hiddenState!==e.HiddenState.UNHIDDEN}},{key:"isTyping",get:function(){return this._typingStatus.size>0}},{key:"cachedUnreadMemberState",get:function(){var e,t={},n=y(this._unreadMemberStateMap);try{for(n.s();!(e=n.n()).done;){var r=v(e.value,2),a=r[0],s=r[1];t[a]=s}}catch(e){n.e(e)}finally{n.f()}return t}},{key:"cachedUndeliveredMemberState",get:function(){var e,t={},n=y(this._undeliveredMemberStateMap);try{for(n.s();!(e=n.n()).done;){var r=v(e.value,2),a=r[0],s=r[1];t[a]=s}}catch(e){n.e(e)}finally{n.f()}return t}},{key:"_shouldUpdateLastMessageWith",value:function(e){return!(e instanceof Ms&&e.parentMessageId>0&&!e.replyToChannel)&&(!this.lastMessage||this.lastMessage.createdAt=0)if(this.myCountPreference===e.CountPreference.ALL||this.myCountPreference===e.CountPreference.UNREAD_MESSAGE_COUNT_ONLY)if(this.isExclusive||this.isSuper||this.isBroadcast){var r=fs.of(this._iid).maxSuperGroupChannelUnreadCount;this.unreadMessageCount=r&&t>=r?r:t}else this.unreadMessageCount=t;else this.unreadMessageCount=0;else this.unreadMessageCount=0;"number"==typeof n&&n>=0&&(this.myCountPreference===e.CountPreference.ALL||this.myCountPreference===e.CountPreference.UNREAD_MENTION_COUNT_ONLY)?this.unreadMentionCount=n:this.unreadMentionCount=0}},{key:"_updateUnreadMemberState",value:function(e,t){var n=this._unreadMemberStateMap.get(e);return(!n||n1&&void 0!==arguments[1]?arguments[1]:(new Date).getTime();t>0?this._typingStatus.set(e.userId,{user:e,ts:t}):this._typingStatus.delete(e.userId)}},{key:"_clearTypingStatus",value:function(){this._typingStatus.clear(),this._typingStarted=0,this._typingEnded=0}},{key:"_setLatestMemberCount",value:function(e,t,n){var r=!1;return n>=this._lastMemberCountUpdated&&(this._lastMemberCountUpdated=n,r=e!==this.memberCount||t!==this.joinedMemberCount,this.memberCount=e,this.joinedMemberCount=t),r}},{key:"isReadMessage",value:function(e){var t=fs.of(this._iid).sdkState,n=this._unreadMemberStateMap.get(t.userId);return!!n&&n>=e.createdAt}},{key:"serialize",value:function(){var e=this;return Wa(this,(function(t){t.cachedUnreadMemberState=e.cachedUnreadMemberState,t.cachedUndeliveredMemberState=e.cachedUndeliveredMemberState}))}},{key:"createMessageCollection",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return new up(this._iid,Object.assign({channel:this},e))}},{key:"createMemberListQuery",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return new _p(this._iid,this.url,e)}},{key:"createPinnedMessageListQuery",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return new Bp(this._iid,this.url,this.channelType,e)}},{key:"addMember",value:function(t){var n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0;if(!this.isExclusive&&!this.isSuper&&!this.isBroadcast){var r=this.members.findIndex((function(e){return e.userId===t.userId}));if(r>-1){var a=this.members[r];a.state===e.MemberState.JOINED&&(t.state=a.state),this.members.splice(r,1),this.memberCount--}this.members.push(t),this.memberCount++,this._updateUnreadMemberState(t.userId,n),this._updateUndeliveredMemberState(t.userId,n)}}},{key:"removeMember",value:function(e){if(!this.isExclusive&&!this.isSuper&&!this.isBroadcast){var t=e instanceof dd?e.userId:e,n=this.members.findIndex((function(e){return e.userId===t}));if(n>-1)return this.members.splice(n,1),this.memberCount--,!0}return!1}},{key:"getUnreadMemberCount",value:function(t){if(t instanceof Ms&&!this.isExclusive&&!this.isSuper&&!this.isBroadcast){var n,r=fs.of(this._iid).sdkState,a=t.createdAt,s=0,i=y(this.members);try{for(i.s();!(n=i.n()).done;){var o=n.value;if(r.userId!==o.userId&&o.state===e.MemberState.JOINED&&t.sender.userId!==o.userId)(this.cachedUnreadMemberState[o.userId]||0)1&&void 0!==arguments[1]&&arguments[1],r=fs.of(this._iid).sdkState;if(!r.userId||this.isExclusive||this.isSuper||this.isBroadcast)return[];var a=e instanceof Ms?e.sender:null,s=[];return this.members.forEach((function(i){if(n||i.userId!==r.userId&&i.userId!==(null==a?void 0:a.userId)){var o=t._unreadMemberStateMap.get(i.userId);o&&o>=e.createdAt&&s.push(i)}})),s}},{key:"getUnreadMembers",value:function(e){var t=this,n=arguments.length>1&&void 0!==arguments[1]&&arguments[1],r=fs.of(this._iid).sdkState;if(!r.userId||this.isExclusive||this.isSuper||this.isBroadcast)return[];var a=e instanceof Ms?e.sender:null,s=[];return this.members.forEach((function(i){if(n||i.userId!==r.userId&&i.userId!==(null==a?void 0:a.userId)){var o=t._unreadMemberStateMap.get(i.userId);o&&o0&&void 0!==arguments[0]&&arguments[0],n=fs.of(this._iid).sdkState;if(!n.userId||this.isExclusive||this.isSuper||this.isBroadcast)return null;var r={};return this.members.forEach((function(a){if(t||a.userId!==n.userId){var s=e._unreadMemberStateMap.get(a.userId);r[a.userId]=new fd(e._iid,{channel_url:e.url,channel_type:e.channelType,user:dd.payloadify(a),ts:null!=s?s:0})}})),r}},{key:"getTypingUsers",value:function(){var e=[];return this._typingStatus.forEach((function(t){var n=t.user;e.push(n)})),e}},{key:"invalidateTypingStatus",value:function(){var e=this,t=fs.of(this._iid).typingIndicatorInvalidateTime,n=Date.now(),r=!1;return this._typingStatus.forEach((function(a,s){var i=a.ts;n-i>=t&&(e._typingStatus.delete(s),r=!0)})),r}},{key:"refresh",value:function(){return b(this,void 0,void 0,t().mark((function n(){var r,a,s,i,o,u,c;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return r=fs.of(this._iid),a=r.requestQueue,s=r.dispatcher,i=new Dd({channelUrl:this.url}),t.next=4,a.send(i);case 4:return o=t.sent,u=o.as(Pd),c=u.channel,this._update(c),s.dispatch(new du({channels:[c],source:e.GroupChannelEventSource.REQUEST_CHANNEL})),t.abrupt("return",this);case 9:case"end":return t.stop()}}),n,this)})))}},{key:"freeze",value:function(){var n=this,r=Object.create(null,{freeze:{get:function(){return p(o(u.prototype),"freeze",n)}}});return b(this,void 0,void 0,t().mark((function n(){var a;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,r.freeze.call(this);case 2:a=fs.of(this._iid),a.dispatcher.dispatch(new du({channels:[this],source:e.GroupChannelEventSource.EVENT_CHANNEL_FROZEN,isWebSocketEventComing:!0}));case 4:case"end":return t.stop()}}),n,this)})))}},{key:"unfreeze",value:function(){var n=this,r=Object.create(null,{unfreeze:{get:function(){return p(o(u.prototype),"unfreeze",n)}}});return b(this,void 0,void 0,t().mark((function n(){var a;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,r.unfreeze.call(this);case 2:a=fs.of(this._iid),a.dispatcher.dispatch(new du({channels:[this],source:e.GroupChannelEventSource.EVENT_CHANNEL_UNFROZEN,isWebSocketEventComing:!0}));case 4:case"end":return t.stop()}}),n,this)})))}},{key:"updateChannel",value:function(n){return b(this,void 0,void 0,t().mark((function r(){var a,s,i,o,u,c,l,h;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return a=Object.assign(Object.assign({},cp),n),Za(lp(a)).throw(A.invalidParameters),s=fs.of(this._iid),i=s.dispatcher,o=s.requestQueue,u=new yp(Object.assign({channelUrl:this.url},a)),t.next=6,o.send(u);case 6:return c=t.sent,l=c.as(kp),h=l.channel,this._update(h),i.dispatch(new du({channels:[h],source:e.GroupChannelEventSource.EVENT_CHANNEL_UPDATED,isWebSocketEventComing:!0})),t.abrupt("return",this);case 11:case"end":return t.stop()}}),r,this)})))}},{key:"invite",value:function(e){return b(this,void 0,void 0,t().mark((function n(){return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return Za(e.every((function(e){return e instanceof Xa}))).throw(A.invalidParameters),t.abrupt("return",this.inviteWithUserIds(e.map((function(e){return e.userId}))));case 2:case"end":return t.stop()}}),n,this)})))}},{key:"inviteWithUserIds",value:function(n){return b(this,void 0,void 0,t().mark((function r(){var a,s,i,o,u,c,l;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return Za(F("string",n)).throw(A.invalidParameters),a=fs.of(this._iid),s=a.dispatcher,i=a.requestQueue,o=new uf({channelUrl:this.url,userIds:n}),t.next=5,i.send(o);case 5:return u=t.sent,c=u.as(cf),l=c.channel,this._update(l),s.dispatch(new du({channels:[l],source:e.GroupChannelEventSource.EVENT_CHANNEL_INVITED,isWebSocketEventComing:!0})),t.abrupt("return",this);case 10:case"end":return t.stop()}}),r,this)})))}},{key:"join",value:function(n){return b(this,void 0,void 0,t().mark((function r(){var a,s,i,o,u,c,l,h;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return Za(L("string",n,!0)).throw(A.invalidParameters),a=fs.of(this._iid),s=a.dispatcher,i=a.sdkState,o=a.requestQueue,u=new nf({channelUrl:this.url,userId:i.userId,accessCode:n}),t.next=5,o.send(u);case 5:return c=t.sent,l=c.as(rf),(h=l.channel).myMemberState=this.myMemberState=e.MemberState.JOINED,this._update(h),s.dispatch(new du({channels:[h],source:e.GroupChannelEventSource.EVENT_CHANNEL_JOINED,isWebSocketEventComing:!0})),t.abrupt("return",this);case 11:case"end":return t.stop()}}),r,this)})))}},{key:"leave",value:function(){var n=arguments.length>0&&void 0!==arguments[0]&&arguments[0];return b(this,void 0,void 0,t().mark((function r(){var a,s,i,o;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return a=fs.of(this._iid),s=a.sdkState,i=a.requestQueue,o=new sf({channelUrl:this.url,userId:s.userId,shouldRemoveOperatorStatus:n}),t.next=4,i.send(o);case 4:this.myMemberState=e.MemberState.NONE;case 5:case"end":return t.stop()}}),r,this)})))}},{key:"acceptInvitation",value:function(n){return b(this,void 0,void 0,t().mark((function r(){var a,s,i,o,u,c,l,h;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return Za(L("string",n,!0)).throw(A.invalidParameters),a=fs.of(this._iid),s=a.dispatcher,i=a.sdkState,o=a.requestQueue,u=new mp({channelUrl:this.url,userId:i.userId,accessCode:n}),t.next=5,o.send(u);case 5:return c=t.sent,l=c.as(gp),(h=l.channel).myMemberState=this.myMemberState=e.MemberState.JOINED,this._update(h),s.dispatch(new du({channels:[h],source:e.GroupChannelEventSource.EVENT_CHANNEL_ACCEPTED_INVITE,isWebSocketEventComing:!0})),t.abrupt("return",this);case 11:case"end":return t.stop()}}),r,this)})))}},{key:"declineInvitation",value:function(){return b(this,void 0,void 0,t().mark((function n(){var r,a,s,i;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return r=fs.of(this._iid),a=r.sdkState,s=r.requestQueue,i=new hf({channelUrl:this.url,userId:a.userId}),t.next=4,s.send(i);case 4:return this.myMemberState=e.MemberState.NONE,t.abrupt("return",this);case 6:case"end":return t.stop()}}),n,this)})))}},{key:"sendUserMessage",value:function(t){var n=this,r=new Ci,a=fs.of(this._iid).dispatcher,s=iu.of(this._iid);return p(o(u.prototype),"sendUserMessage",this).call(this,t).onPending((function(e){s.completeCurrentAndProcessNextAutoResend(e),r._trigger(null,e)})).onFailed((function(e,t){t&&s.completeCurrentAndProcessNextAutoResend(t),r._trigger(e,t)})).onSucceeded((function(t){n.hiddenState===e.HiddenState.HIDDEN_ALLOW_AUTO_UNHIDE&&(n.hiddenState=e.HiddenState.UNHIDDEN),s.completeCurrentAndProcessNextAutoResend(t),n._shouldUpdateLastMessageWith(t)&&(n.lastMessage=t),Ff.of(n._iid).handlers.map((function(e){e.onChannelChanged&&e.onChannelChanged(n)})),a.dispatch(new du({channels:[n],source:e.GroupChannelEventSource.EVENT_MESSAGE_SENT})),r._trigger(null,t)})),r}},{key:"updateUserMessage",value:function(n,r){var a=this,s=Object.create(null,{updateUserMessage:{get:function(){return p(o(u.prototype),"updateUserMessage",a)}}});return b(this,void 0,void 0,t().mark((function a(){var i,o,u,c,l,h=this;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return i=fs.of(this._iid),o=i.dispatcher,t.next=3,s.updateUserMessage.call(this,n,r);case 3:return u=t.sent,c=!1,!u.silent&&this._shouldUpdateLastMessageWith(u)&&(this.lastMessage=u,c=!0),l=!1,this.lastPinnedMessage&&this.lastPinnedMessage.messageId===u.messageId&&(this.lastPinnedMessage=u,c=!0,l=!0),c&&(Ff.of(this._iid).handlers.map((function(e){e.onChannelChanged&&e.onChannelChanged(h)})),o.dispatch(new du({channels:[this],source:l?e.GroupChannelEventSource.EVENT_PINNED_MESSAGE_UPDATED:e.GroupChannelEventSource.EVENT_MESSAGE_UPDATED}))),l&&Ff.of(this._iid).handlers.map((function(e){e.onPinnedMessageUpdated&&e.onPinnedMessageUpdated(h)})),o.dispatch(new ui({messages:[u],source:e.MessageEventSource.EVENT_MESSAGE_UPDATED})),t.abrupt("return",u);case 12:case"end":return t.stop()}}),a,this)})))}},{key:"_autoResendUserMessage",value:function(t){var n=this,r=new Ci,a=fs.of(this._iid).dispatcher,s=iu.of(this._iid);return p(o(u.prototype),"_autoResendUserMessage",this).call(this,t).onPending((function(e){s.completeCurrentAndProcessNextAutoResend(e),r._trigger(null,e)})).onFailed((function(e,t){s.completeCurrentAndProcessNextAutoResend(t),r._trigger(e,t)})).onSucceeded((function(t){var i=Ff.of(n._iid);s.completeCurrentAndProcessNextAutoResend(t),n._shouldUpdateLastMessageWith(t)&&(n.lastMessage=t),i.handlers.map((function(e){e.onChannelChanged&&e.onChannelChanged(n)})),a.dispatch(new du({channels:[n],source:e.GroupChannelEventSource.EVENT_MESSAGE_SENT})),r._trigger(null,t)})),r}},{key:"sendFileMessage",value:function(t){var n=this,r=new Ci,a=fs.of(this._iid).dispatcher,s=iu.of(this._iid);return p(o(u.prototype),"sendFileMessage",this).call(this,t).onPending((function(e){s.completeCurrentAndProcessNextAutoResend(e),r._trigger(null,e)})).onFailed((function(e,t){t&&s.completeCurrentAndProcessNextAutoResend(t),r._trigger(e,t)})).onSucceeded((function(t){var i=Ff.of(n._iid);s.completeCurrentAndProcessNextAutoResend(t),n._shouldUpdateLastMessageWith(t)&&(n.lastMessage=t),i.handlers.map((function(e){e.onChannelChanged&&e.onChannelChanged(n)})),a.dispatch(new du({channels:[n],source:e.GroupChannelEventSource.EVENT_MESSAGE_SENT})),r._trigger(null,t)})),r}},{key:"sendMultipleFilesMessage",value:function(t){var n=this,r=new Gi,a=fs.of(this._iid).dispatcher;return p(o(u.prototype),"sendMultipleFilesMessage",this).call(this,t).onPending((function(e){r._trigger(null,e)})).onFailed((function(e,t){r._trigger(e,t)})).onSucceeded((function(t){var s=Ff.of(n._iid);n._shouldUpdateLastMessageWith(t)&&(n.lastMessage=t),s.handlers.map((function(e){e.onChannelChanged&&e.onChannelChanged(n)})),a.dispatch(new du({channels:[n],source:e.GroupChannelEventSource.EVENT_MESSAGE_SENT})),r._trigger(null,t)})).onFileUploaded((function(e,t,n,a){r._triggerOnFileUploaded(e,t,n,a)})),r}},{key:"updateFileMessage",value:function(n,r){var a=this,s=Object.create(null,{updateFileMessage:{get:function(){return p(o(u.prototype),"updateFileMessage",a)}}});return b(this,void 0,void 0,t().mark((function a(){var i,o,u,c,l,h=this;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return i=fs.of(this._iid),o=i.dispatcher,t.next=3,s.updateFileMessage.call(this,n,r);case 3:return u=t.sent,c=!1,!u.silent&&this._shouldUpdateLastMessageWith(u)&&(this.lastMessage=u,c=!0),l=!1,this.lastPinnedMessage&&this.lastPinnedMessage.messageId===u.messageId&&(this.lastPinnedMessage=u,c=!0,l=!0),c&&(Ff.of(this._iid).handlers.map((function(e){e.onChannelChanged&&e.onChannelChanged(h)})),o.dispatch(new du({channels:[this],source:l?e.GroupChannelEventSource.EVENT_PINNED_MESSAGE_UPDATED:e.GroupChannelEventSource.EVENT_MESSAGE_UPDATED}))),l&&Ff.of(this._iid).handlers.map((function(e){e.onPinnedMessageUpdated&&e.onPinnedMessageUpdated(h)})),o.dispatch(new ui({messages:[u],source:e.MessageEventSource.EVENT_MESSAGE_UPDATED})),t.abrupt("return",u);case 12:case"end":return t.stop()}}),a,this)})))}},{key:"_autoResendFileMessage",value:function(t){var n=this,r=new Ci,a=fs.of(this._iid).dispatcher,s=iu.of(this._iid);return p(o(u.prototype),"_autoResendFileMessage",this).call(this,t).onPending((function(e){s.completeCurrentAndProcessNextAutoResend(e),r._trigger(null,e)})).onFailed((function(e,t){s.completeCurrentAndProcessNextAutoResend(t),r._trigger(e,t)})).onSucceeded((function(t){var i=Ff.of(n._iid);s.completeCurrentAndProcessNextAutoResend(t),n._shouldUpdateLastMessageWith(t)&&(n.lastMessage=t),i.handlers.map((function(e){e.onChannelChanged&&e.onChannelChanged(n)})),a.dispatch(new du({channels:[n],source:e.GroupChannelEventSource.EVENT_MESSAGE_SENT})),r._trigger(null,t)})),r}},{key:"deleteMessage",value:function(n){var r=this,a=Object.create(null,{deleteMessage:{get:function(){return p(o(u.prototype),"deleteMessage",r)}}});return b(this,void 0,void 0,t().mark((function r(){var s;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,a.deleteMessage.call(this,n);case 2:0===n.messageId&&n instanceof Ms&&(s=fs.of(this._iid),s.dispatcher.dispatch(new li({reqId:n.reqId,source:e.MessageEventSource.EVENT_MESSAGE_DELETED})));case 3:case"end":return t.stop()}}),r,this)})))}},{key:"hide",value:function(n){return b(this,void 0,void 0,t().mark((function r(){var a,s,i,o,u,c,l,h,d;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return a=Object.assign(Object.assign({},mf),n),Za(gf(a)).throw(A.invalidParameters),s=fs.of(this._iid),i=s.dispatcher,o=s.sdkState,u=s.requestQueue,c=new yf(Object.assign({channelUrl:this.url,userId:o.userId},a)),t.next=6,u.send(c);case 6:return l=t.sent,h=l.as(kf),d=h.messageOffsetTimestamp,this.hiddenState=a.allowAutoUnhide?e.HiddenState.HIDDEN_ALLOW_AUTO_UNHIDE:e.HiddenState.HIDDEN_PREVENT_AUTO_UNHIDE,a.hidePreviousMessages&&this._updateUnreadCount(0,0),d&&(this.messageOffsetTimestamp=d),i.dispatch(new du({channels:[this],source:e.GroupChannelEventSource.EVENT_CHANNEL_HIDDEN,isWebSocketEventComing:!0})),t.abrupt("return",this);case 13:case"end":return t.stop()}}),r,this)})))}},{key:"unhide",value:function(){return b(this,void 0,void 0,t().mark((function n(){var r,a,s,i;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return r=fs.of(this._iid),a=r.dispatcher,s=r.requestQueue,i=new Ep({channelUrl:this.url}),t.next=4,s.send(i);case 4:return this.hiddenState=e.HiddenState.UNHIDDEN,a.dispatch(new du({channels:[this],source:e.GroupChannelEventSource.EVENT_CHANNEL_UNHIDDEN,isWebSocketEventComing:!0})),t.abrupt("return",this);case 7:case"end":return t.stop()}}),n,this)})))}},{key:"delete",value:function(){return b(this,void 0,void 0,t().mark((function e(){var n,r,a;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n=fs.of(this._iid),r=n.requestQueue,a=new bp({channelUrl:this.url}),e.next=4,r.send(a);case 4:case"end":return e.stop()}}),e,this)})))}},{key:"markAsRead",value:function(){return b(this,void 0,void 0,t().mark((function n(){var r,a,s,i,o,u,c,l,h=this;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return r=fs.of(this._iid),a=r.sdkState,s=r.dispatcher,i=r.requestQueue,o=new ff({channelUrl:this.url}),t.next=4,i.send(o);case 4:u=t.sent,c=u.as(pf),l=c.readStatus,this._updateUnreadMemberState(a.userId,l.readAt),(this.unreadMessageCount>0||this.unreadMentionCount>0)&&(this._updateUnreadCount(0,0),Ff.of(this._iid).handlers.map((function(e){e.onChannelChanged&&e.onChannelChanged(h)}))),s.dispatch(new du({channels:[this],source:e.GroupChannelEventSource.EVENT_CHANNEL_READ}));case 9:case"end":return t.stop()}}),n,this)})))}},{key:"markAsDelivered",value:function(){return b(this,void 0,void 0,t().mark((function e(){var n,r,a,s;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n=fs.of(this._iid),r=n.sdkState,a=n.requestQueue,s=new vf({channelUrl:this.url,userId:r.userId}),e.next=4,a.send(s);case 4:case"end":return e.stop()}}),e,this)})))}},{key:"startTyping",value:function(){return b(this,void 0,void 0,t().mark((function e(){var n,r,a,s,i;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:n=fs.of(this._iid),r=n.requestQueue,a=n.typingIndicatorThrottle,(s=(new Date).getTime())-this._typingStarted>=a&&(this._typingStarted=s,this._typingEnded=0,i=new Ef({channelUrl:this.url,time:this._typingStarted}),r.send(i));case 3:case"end":return e.stop()}}),e,this)})))}},{key:"endTyping",value:function(){return b(this,void 0,void 0,t().mark((function e(){var n,r,a,s,i;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:n=fs.of(this._iid),r=n.requestQueue,a=n.typingIndicatorThrottle,(s=(new Date).getTime())-this._typingEnded>=a&&(this._typingStarted=0,this._typingEnded=s,i=new Cf({channelUrl:this.url,time:this._typingStarted}),r.send(i));case 3:case"end":return e.stop()}}),e,this)})))}},{key:"createScheduledUserMessage",value:function(e){e=Object.assign(Object.assign({},Bo),e),Za(function(e){return Ao(e)&&L("number",e.scheduledAt,!0)}(e)).throw(A.invalidParameters);var t=new Ci;return this._createScheduledUserMessage(e,t),t}},{key:"updateScheduledUserMessage",value:function(e,n){return b(this,void 0,void 0,t().mark((function r(){var a,s,i,o,u,c,l;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return a=Object.assign(Object.assign({},Np),n),Za(Mp(a)).throw(A.invalidParameters),s=fs.of(this._iid),i=s.requestQueue,o=new Up(Object.assign({reqId:this._generateRequestId(),scheduledMessageId:e,channelType:this.channelType,channelUrl:this.url},a)),t.next=6,i.send(o);case 6:return u=t.sent,c=u.as(qh),l=c.message,t.abrupt("return",l);case 9:case"end":return t.stop()}}),r,this)})))}},{key:"createScheduledFileMessage",value:function(e){var n=this;e=Object.assign(Object.assign({},Qo),e),Za(function(e){return So(e)&&L("number",e.scheduledAt)&&(q(e.file)||L("string",e.fileUrl))&&L("string",e.fileName,!0)&&L("string",e.mimeType,!0)&&L("number",e.fileSize,!0)&&(null===e.thumbnailSizes||void 0===e.thumbnailSizes||e.thumbnailSizes.every((function(e){return L("object",e)&&e.maxWidth>0&&e.maxHeight>0})))}(e)).throw(A.invalidParameters);var r=Date.now(),a=this._generateRequestId(),s=new Ci;return ba(2).then((function(){var i=n._createPendingScheduledFileMessage(e,a,r);Ca((function(){return b(n,void 0,void 0,t().mark((function e(){return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",s._trigger(null,i));case 1:case"end":return e.stop()}}),e)})))}))})),q(e.file)?this._uploadFileAndUpdateParams(e).then((function(){return n._createScheduledFileMessage(e,s,a,r)})):this._createScheduledFileMessage(e,s,a,r),s}},{key:"updateScheduledFileMessage",value:function(e,n){return b(this,void 0,void 0,t().mark((function r(){var a,s,i,o,u,c,l;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(a=Object.assign(Object.assign({},Sp),n),Za(Ip(a)).throw(A.invalidParameters),!q(a.file)){t.next=5;break}return t.next=5,this._uploadFileAndUpdateParams(a);case 5:return s=new Ap(Object.assign({reqId:this._generateRequestId(),scheduledMessageId:e,channelType:this.channelType,channelUrl:this.url},a)),i=fs.of(this._iid),o=i.requestQueue,t.next=9,o.send(s);case 9:return u=t.sent,c=u.as(Op),l=c.message,t.abrupt("return",l);case 12:case"end":return t.stop()}}),r,this)})))}},{key:"cancelScheduledMessage",value:function(e){return b(this,void 0,void 0,t().mark((function n(){var r,a,s;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return r=new Rp({scheduledMessageId:e,channelType:this.channelType,channelUrl:this.url}),a=fs.of(this._iid),s=a.requestQueue,t.next=4,s.send(r);case 4:return t.abrupt("return");case 5:case"end":return t.stop()}}),n,this)})))}},{key:"sendScheduledMessageNow",value:function(e){return b(this,void 0,void 0,t().mark((function n(){var r,a,s;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return r=new Lp({scheduledMessageId:e,channelType:this.channelType,channelUrl:this.url}),a=fs.of(this._iid),s=a.requestQueue,t.next=4,s.send(r);case 4:return t.abrupt("return");case 5:case"end":return t.stop()}}),n,this)})))}},{key:"getMyPushTriggerOption",value:function(){return b(this,void 0,void 0,t().mark((function e(){var n,r,a,s,i,o,u;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n=fs.of(this._iid),r=n.sdkState,a=n.requestQueue,s=new Fp({userId:r.userId,channelUrl:this.url}),e.next=4,a.send(s);case 4:return i=e.sent,o=i.as(Gp),u=o.pushTriggerOption,this.myPushTriggerOption=u,e.abrupt("return",u);case 8:case"end":return e.stop()}}),e,this)})))}},{key:"setMyPushTriggerOption",value:function(n){return b(this,void 0,void 0,t().mark((function r(){var a,s,i,o,u,c,l,h;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return Za(D(e.PushTriggerOption,n)).throw(A.invalidParameters),a=fs.of(this._iid),s=a.dispatcher,i=a.sdkState,o=a.requestQueue,u=new Dp({userId:i.userId,channelUrl:this.url,pushTriggerOption:n}),t.next=5,o.send(u);case 5:return c=t.sent,l=c.as(Pp),h=l.pushTriggerOption,this.myPushTriggerOption=h,s.dispatch(new du({channels:[this],source:e.GroupChannelEventSource.EVENT_CHANNEL_UPDATED,isWebSocketEventComing:!0})),t.abrupt("return",h);case 10:case"end":return t.stop()}}),r,this)})))}},{key:"setMyCountPreference",value:function(n){return b(this,void 0,void 0,t().mark((function r(){var a,s,i,o,u,c,l,h;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return Za(D(e.CountPreference,n)).throw(A.invalidParameters),a=fs.of(this._iid),s=a.dispatcher,i=a.sdkState,o=a.requestQueue,u=new wp({channelUrl:this.url,userId:i.userId,countPreference:n}),t.next=5,o.send(u);case 5:return c=t.sent,l=c.as(Cp),h=l.countPreference,this.myCountPreference=h,this._updateUnreadCount(this.unreadMessageCount,this.unreadMentionCount),s.dispatch(new du({channels:[this],source:e.GroupChannelEventSource.EVENT_CHANNEL_UPDATED,isWebSocketEventComing:!0})),t.abrupt("return",h);case 11:case"end":return t.stop()}}),r,this)})))}},{key:"resetMyHistory",value:function(){return b(this,void 0,void 0,t().mark((function n(){var r,a,s,i,o,u,c;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return r=fs.of(this._iid),a=r.dispatcher,s=r.requestQueue,i=new xp({channelUrl:this.url}),t.next=4,s.send(i);case 4:return o=t.sent,u=o.as(Tp),c=u.messageOffsetTimestamp,this.messageOffsetTimestamp=c,a.dispatch(new du({channels:[this],source:e.GroupChannelEventSource.EVENT_CHANNEL_RESET_HISTORY,isWebSocketEventComing:!0})),t.abrupt("return",this);case 9:case"end":return t.stop()}}),n,this)})))}},{key:"pinMessage",value:function(e){return b(this,void 0,void 0,t().mark((function n(){var r,a,s;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return Za(L("number",e)&&e>0).throw(A.invalidParameters),r=fs.of(this._iid),a=r.requestQueue,s=new qp({channelType:this.channelType,channelUrl:this.url,messageId:e}),t.next=5,a.send(s);case 5:case"end":return t.stop()}}),n,this)})))}},{key:"unpinMessage",value:function(e){return b(this,void 0,void 0,t().mark((function n(){var r,a,s;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return Za(L("number",e)&&e>0).throw(A.invalidParameters),r=fs.of(this._iid),a=r.requestQueue,s=new Hp({channelType:this.channelType,channelUrl:this.url,messageId:e}),t.next=5,a.send(s);case 5:case"end":return t.stop()}}),n,this)})))}},{key:"_uploadFileAndUpdateParams",value:function(e){return b(this,void 0,void 0,t().mark((function n(){var r,a,s,i,o,u,c,l,h,d,f,p;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(!q(e.file)){t.next=11;break}return r=fs.of(this._iid),a=r.requestQueue,s=new vs({file:e.file,channelUrl:this.url,thumbnailSizes:e.thumbnailSizes,requestId:this._generateRequestId()}),t.next=5,a.send(s);case 5:i=t.sent,o=i.as(_s),u=o.url,c=o.fileSize,l=void 0===c?e.fileSize:c,h=o.thumbnailSizes,d=void 0===h?e.thumbnailSizes:h,f=o.requireAuth,p=void 0!==f&&f,e.fileUrl=u,e.fileSize=l,e.thumbnailSizes=d,e.requireAuth=p;case 11:case"end":return t.stop()}}),n,this)})))}}],[{key:"payloadify",value:function(e){return ue(ce(Object.assign(Object.assign({},p(o(u),"payloadify",this).call(this,e)),{is_access_code_required:e.isAccessCodeRequired,is_distinct:e.isDistinct,is_super:e.isSuper,is_broadcast:e.isBroadcast,is_exclusive:e.isExclusive,is_public:e.isPublic,is_discoverable:e.isDiscoverable,is_muted:e.myMutedState,is_push_enabled:e.isPushEnabled,unread_message_count:e.unreadMessageCount,unread_mention_count:e.unreadMentionCount,push_trigger_option:e.myPushTriggerOption,count_preference:e.myCountPreference,hidden_state:e.hiddenState,member_count:e.memberCount,joined_member_count:e.joinedMemberCount,member_state:e.myMemberState,my_role:e.myRole,user_last_read:e.myLastRead,ts_message_offset:e.messageOffsetTimestamp,message_survival_seconds:e.messageSurvivalSeconds,read_receipt:e.cachedUnreadMemberState,delivery_receipt:e.cachedUndeliveredMemberState,members:e.members.map((function(e){return dd.payloadify(e)})),last_message:e.lastMessage?Vs(e.lastMessage):null,inviter:e.inviter?Xa.payloadify(e.inviter):null,invited_at:e.invitedAt,joined_ts:e.joinedAt,pinned_message_ids:e.pinnedMessageIds,latest_pinned_message:e.lastPinnedMessage?Vs(e.lastPinnedMessage):null})))}}]),u}(nd),Wp={},Yp=function(){function n(a){var s=this,i=a._iid,o=a.limit,u=void 0===o?100:o;r(this,n),this.ref=0,this._iid=i,this._limit=u;var c,l=fs.of(this._iid),h=l.sdkState,d=l.dispatcher,f=l.logger;this._metadataKey=(c=h.userId,"sendbird:".concat(c,"@groupchannel/sync.meta"));var p=function(e){return"sendbird:".concat(e,"@groupchannel/sync")}(h.userId);this._sync=new Gf(p,(function(){return b(s,void 0,void 0,t().mark((function n(){var r,a,s,i,o,u,c,l,h,d;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return o={hasNext:!0,nextToken:""},t.next=3,this.loadMetadata();case 3:if(f.debug("channel background sync from",null===(r=this._metadata)||void 0===r?void 0:r.token),null===(a=this._metadata)||void 0===a?void 0:a.completed){t.next=29;break}return t.prev=5,u=Ff.of(this._iid),t.next=9,u.getMyGroupChannels(null!==(i=null===(s=this._metadata)||void 0===s?void 0:s.token)&&void 0!==i?i:"",{includeEmpty:!0,order:e.GroupChannelListOrder.CHRONOLOGICAL},this._limit,e.GroupChannelEventSource.SYNC_CHANNEL_BACKGROUND);case 9:return c=t.sent,l=c.channels,h=c.token,o.hasNext=l.length>=this._limit&&!!h,o.nextToken=h,this._metadata&&(this._metadata.token=h,(d=this._metadata.range).extends.apply(d,_(l.map((function(e){return e.createdAt})))),this._metadata.completed=!o.hasNext),f.debug("channel background sync progress",o),t.next=18,this.saveMetadata();case 18:t.next=27;break;case 20:if(t.prev=20,t.t0=t.catch(5),f.debug("channel background sync error",t.t0),!(t.t0 instanceof A&&t.t0.isInvalidTokenError)){t.next=26;break}return t.next=26,this.clearMetaData();case 26:throw t.t0;case 27:t.next=31;break;case 29:o.hasNext=!1,o.nextToken="";case 31:return t.abrupt("return",o);case 32:case"end":return t.stop()}}),n,this,[[5,20]])})))})),this._connectionEventContext=d.on((function(e){if(e instanceof da)if(e.stateType===sa.CONNECTED)s.resume();else s.pause()}))}return s(n,[{key:"range",get:function(){var e,t;return null!==(t=null===(e=this._metadata)||void 0===e?void 0:e.range)&&void 0!==t?t:new Lf({})}},{key:"completed",get:function(){var e;return!!(null===(e=this._metadata)||void 0===e?void 0:e.completed)}},{key:"loadMetadata",value:function(){return b(this,void 0,void 0,t().mark((function e(){var n,r,a;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(this._metadata){e.next=6;break}return n=fs.of(this._iid),r=n.cacheContext,e.next=4,r.preference.get(this._metadataKey);case 4:a=e.sent,this._metadata={token:a?a.token:"",range:new Lf(a?a.range:{top:Number.MAX_SAFE_INTEGER,bottom:0}),completed:!!a&&a.completed};case 6:return e.abrupt("return",this._metadata);case 7:case"end":return e.stop()}}),e,this)})))}},{key:"saveMetadata",value:function(){return b(this,void 0,void 0,t().mark((function e(){var n,r;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!this._metadata){e.next=5;break}return n=fs.of(this._iid),r=n.cacheContext,e.next=4,r.preference.set(this._metadataKey,this._metadata);case 4:return e.abrupt("return",!0);case 5:return e.abrupt("return",!1);case 6:case"end":return e.stop()}}),e,this)})))}},{key:"clearMetaData",value:function(){return b(this,void 0,void 0,t().mark((function e(){var n,r;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n=fs.of(this._iid),r=n.cacheContext,e.next=3,r.preference.remove(this._metadataKey);case 3:this._metadata=void 0;case 4:case"end":return e.stop()}}),e,this)})))}},{key:"resume",value:function(){var e,t,n=fs.of(this._iid),r=n.logger;n.connectionManager.isConnected&&(r.debug("channel background sync resume()"),this._sync.start(null!==(t=null===(e=this._metadata)||void 0===e?void 0:e.token)&&void 0!==t?t:""))}},{key:"pause",value:function(){fs.of(this._iid).logger.debug("channel background sync stop()"),this._sync.stop()}},{key:"close",value:function(){this.ref--,this.ref<=0&&(this.ref=0,this.pause(),this._connectionEventContext.close(),delete Wp[this._iid])}}],[{key:"of",value:function(e){return Wp[e]||(Wp[e]=new n({_iid:e})),Wp[e].ref++,Wp[e]}},{key:"clear",value:function(e){Wp[e]&&(Wp[e].close(),delete Wp[e])}}]),n}(),Zp={},Jp=function(){function n(a){var s=this,i=a._iid;r(this,n),this.ref=0,this._iid=i;var o,u=fs.of(this._iid),c=u.logger,l=u.sdkState,h=u.dispatcher;this._metadataKey=(o=l.userId,"sendbird:".concat(o,"@groupchannel/changelogs.meta"));var d=function(e){return"sendbird:".concat(e,"@groupchannel/changelogs")}(l.userId);this._sync=new Gf(d,(function(){return b(s,void 0,void 0,t().mark((function n(){var r,a,s,i,o,u,l,h;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return i={hasNext:!0,nextToken:0},t.next=3,this.loadMetadata();case 3:return c.debug("channel changelog sync from",null===(r=this._metadata)||void 0===r?void 0:r.token),t.prev=4,o=Ff.of(this._iid),t.next=8,o.getMyGroupChannelChangeLogs(null!==(s=null===(a=this._metadata)||void 0===a?void 0:a.token)&&void 0!==s?s:"",{includeEmpty:!0},e.GroupChannelEventSource.SYNC_CHANNEL_CHANGELOGS);case 8:return u=t.sent,l=u.hasMore,h=u.token,i.hasNext=l,i.nextToken=h,this._metadata&&(this._metadata.token=h),c.debug("channel changelog sync progress",i),t.next=17,this.saveMetadata();case 17:t.next=26;break;case 19:if(t.prev=19,t.t0=t.catch(4),c.debug("channel changelog sync error",t.t0),!(t.t0 instanceof A&&t.t0.isInvalidTokenError)){t.next=25;break}return t.next=25,this.clearMetadata();case 25:throw t.t0;case 26:return t.abrupt("return",i);case 27:case"end":return t.stop()}}),n,this,[[4,19]])})))})),this._connectionEventContext=h.on((function(e){if(e instanceof da)if(e.stateType===sa.CONNECTED)s.resume();else s.pause()}))}return s(n,[{key:"loadMetadata",value:function(){return b(this,void 0,void 0,t().mark((function e(){var n,r,a,s;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(this._metadata){e.next=6;break}return n=fs.of(this._iid),r=n.cacheContext,a=n.firstConnectedAt,e.next=4,r.preference.get(this._metadataKey);case 4:s=e.sent,this._metadata={token:s?s.token:a};case 6:return e.abrupt("return",this._metadata);case 7:case"end":return e.stop()}}),e,this)})))}},{key:"saveMetadata",value:function(){return b(this,void 0,void 0,t().mark((function e(){var n,r;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!this._metadata){e.next=5;break}return n=fs.of(this._iid),r=n.cacheContext,e.next=4,r.preference.set(this._metadataKey,this._metadata);case 4:return e.abrupt("return",!0);case 5:return e.abrupt("return",!1);case 6:case"end":return e.stop()}}),e,this)})))}},{key:"clearMetadata",value:function(){return b(this,void 0,void 0,t().mark((function e(){var n,r;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n=fs.of(this._iid),r=n.cacheContext,e.next=3,r.preference.remove(this._metadataKey);case 3:this._metadata=void 0;case 4:case"end":return e.stop()}}),e,this)})))}},{key:"resume",value:function(){fs.of(this._iid).connectionManager.isConnected&&this._sync.start(0)}},{key:"pause",value:function(){this._sync.stop()}},{key:"close",value:function(){this.ref--,this.ref<=0&&(this.ref=0,this.pause(),this._connectionEventContext.close(),delete Zp[this._iid])}}],[{key:"of",value:function(e){return Zp[e]||(Zp[e]=new n({_iid:e})),Zp[e].ref++,Zp[e]}},{key:"clear",value:function(e){Zp[e]&&(Zp[e].close(),delete Zp[e])}}]),n}(),Xp=function(){function n(a,s){var i=this,o=s.filter,u=s.order,c=s.limit;r(this,n),this.channels=[],this._iid=a,this._key="gcc-".concat(re()),this._isDisposed=!1,this._isGetRemoteChannelsSucceeded=!0,this.filter=null!=o?o:new vd,this.order=null!=u?u:e.GroupChannelListOrder.LATEST_LAST_MESSAGE,this._hasMore=!0,this._token="",this._limit=null!=c?c:100;var l=fs.of(this._iid),h=l.sdkState,d=l.cacheContext,f=l.dispatcher;d.localCacheEnabled&&(this._backgroundSync=Yp.of(a),this._backgroundSync.resume()),this._changelogSync=Jp.of(a),this._changelogSync.resume(),Ff.of(this._iid).subscribeGroupChannelEvent(this._key,{onUpdate:function(e,t){if(hu(t)){var n=e.filter((function(e){return i.filter.match(e,h.userId)})),r=e.filter((function(e){return!i.filter.match(e,h.userId)})).map((function(e){return e.url}));n.length>0&&i._addChannelsToView(n,t),r.length>0&&i._removeChannelsFromView(r,t)}},onRemove:function(e,t){i._removeChannelsFromView(e,t)}}),fs.of(this._iid).statLogCollector.put(new ss({type:Ae.FEATURE_LOCALCACHE,data:{use_local_cache:d.localCacheEnabled,collection_interface:{group_channel:!0}}})),f.on((function(e){e instanceof da&&(e.stateType===sa.CONNECTED?i._isGetRemoteChannelsSucceeded||b(i,void 0,void 0,t().mark((function e(){return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this._revokeLoadMore();case 2:case"end":return e.stop()}}),e,this)}))):e.stateType===sa.LOGOUT&&i.dispose())}))}return s(n,[{key:"hasMore",get:function(){return!this._isDisposed&&this._hasMore}},{key:"setGroupChannelCollectionHandler",value:function(e){this._handler=e}},{key:"_addChannelsToView",value:function(n,r){var a,s=this,i=arguments.length>2&&void 0!==arguments[2]&&arguments[2],o=[],u=[],c=[],l=y(n);try{for(l.s();!(a=l.n()).done;){var h=a.value,d=Jf(this.channels,h);d>=0&&this.channels.splice(d,1);var f=Xf(this.channels,h,this.order).place;if(d<0)f===this.channels.length?!i&&this._hasMore||(o.push(h),this.channels.push(h)):(o.push(h),this.channels.splice(f,0,h));else switch(r){case e.GroupChannelEventSource.EVENT_CHANNEL_UPDATED:case e.GroupChannelEventSource.EVENT_MESSAGE_RECEIVED:case e.GroupChannelEventSource.SYNC_CHANNEL_CHANGELOGS:case e.GroupChannelEventSource.EVENT_MESSAGE_SENT:f!==d&&this._hasMore&&f===this.channels.length?c.push(h):(this.channels.splice(f,0,h),u.push(h));break;default:this.channels.splice(f,0,h),u.push(h)}}}catch(e){l.e(e)}finally{l.f()}if(c.length>0){var p,v=y(c);try{for(v.s();!(p=v.n()).done;){var _=p.value,m=Jf(this.channels,_);-1!==m&&this.channels.splice(m,1)}}catch(e){v.e(e)}finally{v.f()}}hu(r)&&Ca((function(){return b(s,void 0,void 0,t().mark((function e(){var n,a,s,i;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:i=new qf(r),o.length>0&&(null===(n=this._handler)||void 0===n?void 0:n.onChannelsAdded)&&this._handler.onChannelsAdded(i,o),u.length>0&&(null===(a=this._handler)||void 0===a?void 0:a.onChannelsUpdated)&&this._handler.onChannelsUpdated(i,u),c.length>0&&(null===(s=this._handler)||void 0===s?void 0:s.onChannelsDeleted)&&this._handler.onChannelsDeleted(i,c.map((function(e){return e.url})));case 4:case"end":return e.stop()}}),e,this)})))}))}},{key:"_removeChannelsFromView",value:function(e,n){var r,a=this,s=[],i=y(e);try{var o=function(){var e=r.value,t=a.channels.findIndex((function(t){return t.url===e}));t>=0&&(s.push(a.channels[t].url),a.channels.splice(t,1))};for(i.s();!(r=i.n()).done;)o()}catch(e){i.e(e)}finally{i.f()}return hu(n)&&s.length>0&&Ca((function(){return b(a,void 0,void 0,t().mark((function e(){var r,a;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:a=new qf(n),(null===(r=this._handler)||void 0===r?void 0:r.onChannelsDeleted)&&this._handler.onChannelsDeleted(a,s);case 2:case"end":return e.stop()}}),e,this)})))})),s}},{key:"_getLocalChannels",value:function(){return b(this,void 0,void 0,t().mark((function e(){var n,r;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n=Ff.of(this._iid),r=this.channels.length>0?Zf(this.channels[this.channels.length-1],this.order):null,e.next=4,n.getChannelsFromCache(r,this.filter,this.order,this._limit,r?this.channels[this.channels.length-1].url:void 0);case 4:return e.abrupt("return",e.sent);case 5:case"end":return e.stop()}}),e,this)})))}},{key:"_getRemoteChannels",value:function(){return b(this,void 0,void 0,t().mark((function e(){var n,r,a,s;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n=Ff.of(this._iid),e.next=3,n.getMyGroupChannels(this._token,ce(Object.assign(Object.assign({},this.filter),{order:this.order})),this._limit);case 3:return r=e.sent,a=r.channels,s=r.token,this._token=s,this._hasMore=!!s,e.abrupt("return",a);case 9:case"end":return e.stop()}}),e,this)})))}},{key:"_revokeLoadMore",value:function(){return b(this,void 0,void 0,t().mark((function n(){var r;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(!this._isDisposed){t.next=2;break}return t.abrupt("return");case 2:return t.prev=2,t.next=5,this._getRemoteChannels();case 5:r=t.sent,this._isGetRemoteChannelsSucceeded=!0,this._addChannelsToView(r,e.GroupChannelEventSource.REQUEST_CHANNEL,!0),t.next=13;break;case 10:t.prev=10,t.t0=t.catch(2),this._isGetRemoteChannelsSucceeded=!1;case 13:case"end":return t.stop()}}),n,this,[[2,10]])})))}},{key:"loadMore",value:function(){return b(this,void 0,void 0,t().mark((function n(){var r,a,s,i=this;return t().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:if(!this._isDisposed){n.next=2;break}throw new A({code:E.COLLECTION_DISPOSED,message:"Collection has been disposed."});case 2:if(!this._hasMore){n.next=23;break}if(r=fs.of(this._iid),a=r.cacheContext,s=[],!a.localCacheEnabled||!this._backgroundSync.completed){n.next=11;break}return n.next=8,xa((function(){return b(i,void 0,void 0,t().mark((function e(){return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this._getLocalChannels();case 2:s=e.sent;case 3:case"end":return e.stop()}}),e,this)})))}));case 8:this._hasMore=s.length>=this._limit,n.next=21;break;case 11:return n.prev=11,n.next=14,this._getRemoteChannels();case 14:s=n.sent,this._isGetRemoteChannelsSucceeded=!0,n.next=21;break;case 18:n.prev=18,n.t0=n.catch(11),this._isGetRemoteChannelsSucceeded=!1;case 21:return this._addChannelsToView(s,e.GroupChannelEventSource.REQUEST_CHANNEL,!0),n.abrupt("return",s);case 23:return n.abrupt("return",[]);case 24:case"end":return n.stop()}}),n,this,[[11,18]])})))}},{key:"dispose",value:function(){var e,t;this._isDisposed||(this._isDisposed=!0,this.channels.length>0&&this.channels.splice(0,this.channels.length),null===(e=this._backgroundSync)||void 0===e||e.close(),null===(t=this._changelogSync)||void 0===t||t.close(),Ff.of(this._iid).unsubscribeGroupChannelEvent(this._key))}}]),n}(),$p=function(t){i(a,t);var n=f(a);function a(t){var s;r(this,a);var i=t.token,o=t.limit,u=t.order,c=t.includeEmpty,l=t.membershipFilter,h=t.channelNameContainsFilter,d=t.channelUrlsFilter,f=t.customTypesFilter,p=t.customTypeStartsWithFilter,v=t.superChannelFilter,_=t.metadataOrderKeyFilter,m=t.metadataKey,g=t.metadataValues,y=t.metadataValueStartsWith,k=t.includeFrozen,b=t.includeMetaData;return(s=n.call(this)).method=le.GET,s.path=pe,s.params=ue(ce({token:i,limit:o,order:u,show_member:!0,show_read_receipt:!0,show_delivery_receipt:!0,show_empty:c,public_mode:e.PublicChannelFilter.PUBLIC,public_membership_mode:l,name_contains:h,channel_urls:d,custom_types:f,custom_type_startswith:p,super_mode:v,metadata_order_key:_,metadata_key:m,metadata_values:g,metadata_value_startswith:y,show_frozen:k,show_metadata:b})),s}return s(a)}(Oe),ev=function(e){i(n,e);var t=f(n);function n(e,a){var s;r(this,n),(s=t.call(this,e,a)).channels=[];var i=a.next,o=a.channels,u=a.ts;return s.token=i,o&&o.length>0&&(s.channels=o.map((function(t){return t.ts=u,new Kp(e,t)}))),s.ts="number"==typeof u?u:0,s}return s(n)}(Ue);e.MembershipFilter=void 0,(Qp=e.MembershipFilter||(e.MembershipFilter={})).ALL="all",Qp.JOINED="joined";var tv,nv=function(n){i(u,n);var a=f(u);function u(t,n){var s,i,o,c,l,h,d,f,p,v,_,m,g,y,k;return r(this,u),(s=a.call(this,t,n)).includeEmpty=!1,s.includeFrozen=!0,s.includeMetaData=!0,s.channelUrlsFilter=null,s.customTypesFilter=null,s.customTypeStartsWithFilter=null,s.channelNameContainsFilter=null,s.membershipFilter=e.MembershipFilter.ALL,s.superChannelFilter=e.SuperChannelFilter.ALL,s.metadataKey=null,s.metadataValues=null,s.metadataOrderKeyFilter=null,s.metadataValueStartsWith=null,s.order=e.PublicGroupChannelListOrder.CHRONOLOGICAL,s.includeEmpty=null!==(i=n.includeEmpty)&&void 0!==i&&i,s.includeFrozen=null===(o=n.includeFrozen)||void 0===o||o,s.includeMetaData=null===(c=n.includeMetaData)||void 0===c||c,s.channelUrlsFilter=null!==(l=n.channelUrlsFilter)&&void 0!==l?l:null,s.customTypesFilter=null!==(h=n.customTypesFilter)&&void 0!==h?h:null,s.customTypeStartsWithFilter=null!==(d=n.customTypeStartsWithFilter)&&void 0!==d?d:null,s.channelNameContainsFilter=null!==(f=n.channelNameContainsFilter)&&void 0!==f?f:null,s.membershipFilter=null!==(p=n.membershipFilter)&&void 0!==p?p:e.MembershipFilter.ALL,s.superChannelFilter=null!==(v=n.superChannelFilter)&&void 0!==v?v:e.SuperChannelFilter.ALL,s.metadataKey=null!==(_=n.metadataKey)&&void 0!==_?_:null,s.metadataValues=null!==(m=n.metadataValues)&&void 0!==m?m:null,s.metadataOrderKeyFilter=null!==(g=n.metadataOrderKeyFilter)&&void 0!==g?g:null,s.metadataValueStartsWith=null!==(y=n.metadataValueStartsWith)&&void 0!==y?y:null,s.order=null!==(k=n.order)&&void 0!==k?k:e.PublicGroupChannelListOrder.CHRONOLOGICAL,s}return s(u,[{key:"_validate",value:function(){return p(o(u.prototype),"_validate",this).call(this)&&L("boolean",this.includeEmpty)&&L("boolean",this.includeFrozen)&&L("boolean",this.includeMetaData)&&L("string",this.channelNameContainsFilter,!0)&&F("string",this.channelUrlsFilter,!0)&&F("string",this.customTypesFilter,!0)&&L("string",this.customTypeStartsWithFilter,!0)&&D(e.MembershipFilter,this.membershipFilter)&&D(e.SuperChannelFilter,this.superChannelFilter)&&D(e.PublicGroupChannelListOrder,this.order)&&L("string",this.metadataOrderKeyFilter,!0)&&L("string",this.metadataKey,!0)&&F("string",this.metadataValues,!0)&&L("string",this.metadataValueStartsWith,!0)}},{key:"next",value:function(){return b(this,void 0,void 0,t().mark((function e(){var n,r,a,s,i,o,u,c;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!this._validate()){e.next=21;break}if(this._isLoading){e.next=18;break}if(n=[],!this._hasNext){e.next=15;break}return this._isLoading=!0,r=fs.of(this._iid),a=r.requestQueue,r.dispatcher,s=new $p(ce(Object.assign(Object.assign({},this),{token:this._token}))),e.next=9,a.send(s);case 9:return i=e.sent,o=i.as(ev),u=o.channels,c=o.token,this._token=c,this._hasNext=!!c,this._isLoading=!1,e.abrupt("return",u);case 15:return e.abrupt("return",n);case 18:throw A.queryInProgress;case 19:e.next=22;break;case 21:throw A.invalidParameters;case 22:case"end":return e.stop()}}),e,this)})))}}]),u}(Ii),rv=s((function e(){r(this,e),this.onUserMuted=He,this.onUserUnmuted=He,this.onUserBanned=He,this.onUserUnbanned=He,this.onChannelChanged=He,this.onChannelDeleted=He,this.onChannelFrozen=He,this.onChannelUnfrozen=He,this.onOperatorUpdated=He,this.onChannelMemberCountChanged=He,this.onMetaDataCreated=He,this.onMetaDataUpdated=He,this.onMetaDataDeleted=He,this.onMetaCounterCreated=He,this.onMetaCounterUpdated=He,this.onMetaCounterDeleted=He,this.onMessageReceived=He,this.onMessageUpdated=He,this.onMessageDeleted=He,this.onMentionReceived=He,this.onReactionUpdated=He,this.onThreadInfoUpdated=He})),av=function(e){i(n,e);var t=f(n);function n(){var e;return r(this,n),(e=t.apply(this,arguments)).onUserJoined=He,e.onUserLeft=He,e.onUserReceivedInvitation=He,e.onUserDeclinedInvitation=He,e.onChannelHidden=He,e.onUnreadMemberStatusUpdated=He,e.onUndeliveredMemberStatusUpdated=He,e.onTypingStatusUpdated=He,e.onPollUpdated=He,e.onPollVoted=He,e.onPollDeleted=He,e.onPinnedMessageUpdated=He,e}return s(n)}(rv),sv=function(e){i(n,e);var t=f(n);function n(){var e,a=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return r(this,n),e=t.call(this),Object.keys(a).forEach((function(t){e.hasOwnProperty(t)&&(e[t]=a[t])})),e}return s(n)}(av),iv=function(e){i(n,e);var t=f(n);function n(e){var a;r(this,n);var s=e.token,i=e.limit,o=e.order,u=e.reverse,c=e.channelUrl,l=e.messageTypeFilter,h=e.scheduledStatus;return(a=t.call(this)).method=le.GET,a.path="".concat(we),a.params=ue(ce({token:s,limit:i,reverse:u,channel_url:c,order:o,message_type:l,status:h})),a}return s(n)}(Oe),ov=function(e){i(n,e);var t=f(n);function n(e,a){var s;r(this,n),(s=t.call(this,e,a)).scheduledMessages=[];var i=a.next,o=a.scheduled_messages;return s.token=i,s.scheduledMessages=o.map((function(t){return Bs(e,t)})),s}return s(n)}(Ue),uv=function(n){i(u,n);var a=f(u);function u(t,n){var s,i,o,c,l,h;return r(this,u),(s=a.call(this,t,n)).channelUrl=null,s.order=null,s.reverse=!1,s.scheduledStatus=null,s.messageTypeFilter=e.MessageTypeFilter.ALL,s.channelUrl=null!==(i=n.channelUrl)&&void 0!==i?i:null,s.order=null!==(o=n.order)&&void 0!==o?o:null,s.reverse=null!==(c=n.reverse)&&void 0!==c&&c,s.scheduledStatus=null!==(l=n.scheduledStatus)&&void 0!==l?l:null,s.messageTypeFilter=null!==(h=n.messageTypeFilter)&&void 0!==h?h:e.MessageTypeFilter.ALL,s}return s(u,[{key:"_validate",value:function(){return p(o(u.prototype),"_validate",this).call(this)&&L("string",this.channelUrl,!0)&&(D(e.ScheduledMessageListOrder,this.order)||null===this.order)&&L("boolean",this.reverse)&&(F(e.ScheduledStatus,this.scheduledStatus)||null===this.scheduledStatus)&&D(e.MessageTypeFilter,this.messageTypeFilter)}},{key:"next",value:function(){return b(this,void 0,void 0,t().mark((function e(){var n,r,a,s,i,o,u;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!this._validate()){e.next=20;break}if(this._isLoading){e.next=17;break}if(!this._hasNext){e.next=14;break}return this._isLoading=!0,n=fs.of(this._iid),r=n.requestQueue,a=new iv(ce(Object.assign(Object.assign({},this),{token:this._token}))),e.next=8,r.send(a);case 8:return s=e.sent,i=s.as(ov),o=i.scheduledMessages,u=i.token,this._token=u,this._hasNext=!!u,this._isLoading=!1,e.abrupt("return",o);case 14:return e.abrupt("return",[]);case 17:throw A.queryInProgress;case 18:e.next=21;break;case 20:throw A.invalidParameters;case 21:case"end":return e.stop()}}),e,this)})))}}]),u}(Ii),cv=function(e){i(a,e);var n=f(a);function a(){var e;return r(this,a),(e=n.apply(this,arguments)).name="groupChannel",e}return s(a,[{key:"init",value:function(e,t){var n=t.sdkState,r=t.dispatcher,s=t.sessionManager,i=t.requestQueue,u=t.logger,c=t.onlineDetector,l=t.cacheContext;p(o(a.prototype),"init",this).call(this,e,{sdkState:n,dispatcher:r,sessionManager:s,requestQueue:i,logger:u,onlineDetector:c,cacheContext:l}),this._manager=new Ff(e,{sdkState:n,cacheContext:l,dispatcher:r,sessionManager:s,requestQueue:i,logger:u})}},{key:"createGroupChannelCollection",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return new Xp(this._iid,e)}},{key:"createMyGroupChannelListQuery",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return new Rf(this._iid,e)}},{key:"createPublicGroupChannelListQuery",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return new nv(this._iid,e)}},{key:"createScheduledMessageListQuery",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return new uv(this._iid,e)}},{key:"addGroupChannelHandler",value:function(e,t){Za(L("string",e)&&t instanceof sv).throw(A.invalidParameters),this._manager.addHandler(e,t)}},{key:"removeGroupChannelHandler",value:function(e){Za(L("string",e)).throw(A.invalidParameters),this._manager.removeHandler(e)}},{key:"removeAllGroupChannelHandlers",value:function(){this._manager.clearHandler()}},{key:"buildGroupChannelFromSerializedData",value:function(e){return this._manager.buildGroupChannelFromSerializedData(e)}},{key:"buildGroupChannelListQueryFromSerializedData",value:function(e){return this._manager.buildGroupChannelListQueryFromSerializedData(e)}},{key:"buildMemberFromSerializedData",value:function(e){return this._manager.buildMemberFromSerializedData(e)}},{key:"getChannel",value:function(e){return b(this,void 0,void 0,t().mark((function n(){return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return Za(L("string",e)).throw(A.invalidParameters),t.abrupt("return",this._manager.getChannel(e));case 2:case"end":return t.stop()}}),n,this)})))}},{key:"getChannelWithoutCache",value:function(e){return b(this,void 0,void 0,t().mark((function n(){return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return Za(L("string",e)).throw(A.invalidParameters),t.abrupt("return",this._manager.getChannelWithoutCache(e));case 2:case"end":return t.stop()}}),n,this)})))}},{key:"getMyGroupChannelChangeLogsByToken",value:function(e){var n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return b(this,void 0,void 0,t().mark((function r(){var a;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return a=Object.assign(Object.assign({},bd),n),Za(L("string",e)&&Ed(a)).throw(A.invalidParameters),t.next=4,this._manager.getMyGroupChannelChangeLogs(e,a);case 4:return t.abrupt("return",t.sent);case 5:case"end":return t.stop()}}),r,this)})))}},{key:"getMyGroupChannelChangeLogsByTimestamp",value:function(e){var n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return b(this,void 0,void 0,t().mark((function r(){var a;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return a=Object.assign(Object.assign({},bd),n),Za(L("number",e)&&Ed(a)).throw(A.invalidParameters),t.next=4,this._manager.getMyGroupChannelChangeLogs(e,a);case 4:return t.abrupt("return",t.sent);case 5:case"end":return t.stop()}}),r,this)})))}},{key:"getGroupChannelCount",value:function(e){return b(this,void 0,void 0,t().mark((function n(){var r;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return r=Object.assign(Object.assign({},wd),e),Za(Cd(r)).throw(A.invalidParameters),t.abrupt("return",this._manager.getGroupChannelCount(r));case 3:case"end":return t.stop()}}),n,this)})))}},{key:"getUnreadItemCount",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return b(this,void 0,void 0,t().mark((function n(){return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,this._manager.getUnreadItemCount(e);case 2:return t.abrupt("return",t.sent);case 3:case"end":return t.stop()}}),n,this)})))}},{key:"getTotalUnreadChannelCount",value:function(){return b(this,void 0,void 0,t().mark((function e(){return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this._manager.getTotalUnreadChannelCount();case 2:return e.abrupt("return",e.sent);case 3:case"end":return e.stop()}}),e,this)})))}},{key:"getTotalUnreadMessageCount",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return b(this,void 0,void 0,t().mark((function n(){return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,this._manager.getTotalUnreadMessageCount(e);case 2:return t.abrupt("return",t.sent);case 3:case"end":return t.stop()}}),n,this)})))}},{key:"getTotalScheduledMessageCount",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return b(this,void 0,void 0,t().mark((function n(){return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,this._manager.getTotalScheduledMessageCount(e);case 2:return t.abrupt("return",t.sent);case 3:case"end":return t.stop()}}),n,this)})))}},{key:"getSubscribedTotalUnreadMessageCount",value:function(){return this._manager.getSubscribedTotalUnreadMessageCount()}},{key:"getSubscribedCustomTypeTotalUnreadMessageCount",value:function(){return this._manager.getSubscribedCustomTypeTotalUnreadMessageCount()}},{key:"getSubscribedCustomTypeUnreadMessageCount",value:function(e){return this._manager.getSubscribedCustomTypeUnreadMessageCount(e)}},{key:"createChannel",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return b(this,void 0,void 0,t().mark((function n(){var r;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return r=Object.assign(Object.assign({},yd),e),Za(kd(r)).throw(A.invalidParameters),t.abrupt("return",this._manager.createChannel(r));case 3:case"end":return t.stop()}}),n,this)})))}},{key:"createDistinctChannelIfNotExist",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return b(this,void 0,void 0,t().mark((function n(){var r;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return r=Object.assign(Object.assign({},yd),e),Za(kd(r)).throw(A.invalidParameters),r&&(r.isDistinct=!0),t.abrupt("return",this.createChannel(r));case 4:case"end":return t.stop()}}),n,this)})))}},{key:"createChannelWithUserIds",value:function(e){var n=arguments.length>1&&void 0!==arguments[1]&&arguments[1],r=arguments.length>2?arguments[2]:void 0,a=arguments.length>3?arguments[3]:void 0,s=arguments.length>4&&void 0!==arguments[4]?arguments[4]:"",i=arguments.length>5&&void 0!==arguments[5]?arguments[5]:"";return b(this,void 0,void 0,t().mark((function o(){var u;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return u=Object.assign(Object.assign({},yd),{invitedUserIds:e,isDistinct:n,name:r,data:s,customType:i}),"string"==typeof a?u.coverUrl=a:u.coverImage=a,t.abrupt("return",this.createChannel(u));case 3:case"end":return t.stop()}}),o,this)})))}},{key:"markAsReadAll",value:function(){return b(this,void 0,void 0,t().mark((function e(){return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:this._manager.markAsReadAll();case 1:case"end":return e.stop()}}),e,this)})))}},{key:"markAsReadWithChannelUrls",value:function(e){return b(this,void 0,void 0,t().mark((function n(){return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:Za(F("string",e)).throw(A.invalidParameters),this._manager.markAsReadWithChannelUrls(e);case 2:case"end":return t.stop()}}),n,this)})))}},{key:"markAsDelivered",value:function(e){return b(this,void 0,void 0,t().mark((function n(){var r;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return Za(L("string",e)).throw(A.invalidParameters),t.next=3,this.getChannel(e);case 3:return r=t.sent,t.next=6,r.markAsDelivered();case 6:case"end":return t.stop()}}),n,this)})))}}]),a}(ps),lv=function(e){i(a,e);var n=f(a);function a(){var e;return r(this,a),(e=n.apply(this,arguments))._channels=new Map,e._enteredChannelUrls=[],e}return s(a,[{key:"enteredChannels",get:function(){var e=this;return this._enteredChannelUrls.map((function(t){return e._channels.get(t)})).filter((function(e){return!!e}))}},{key:"isEnteredChannel",value:function(e){return this._enteredChannelUrls.includes(e)}},{key:"enter",value:function(e){this._enteredChannelUrls.indexOf(e)<0&&this._enteredChannelUrls.push(e)}},{key:"exit",value:function(e){var t=this._enteredChannelUrls.indexOf(e);t>=0&&this._enteredChannelUrls.splice(t,1)}},{key:"exitAll",value:function(){this._enteredChannelUrls=[]}},{key:"get",value:function(e){return b(this,void 0,void 0,t().mark((function n(){return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.abrupt("return",this._channels.get(e));case 1:case"end":return t.stop()}}),n,this)})))}},{key:"upsert",value:function(e){return b(this,void 0,void 0,t().mark((function n(){var r,a=this;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return r=[],e.forEach((function(e){if(a._channels.has(e.url)){var t=a._channels.get(e.url);Object.assign(t,e),r.push(t)}else a._channels.set(e.url,e),r.push(e)})),t.abrupt("return",r);case 3:case"end":return t.stop()}}),n)})))}},{key:"remove",value:function(e){return b(this,void 0,void 0,t().mark((function n(){return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:this._channels.delete(e),this.exit(e);case 2:case"end":return t.stop()}}),n,this)})))}},{key:"clear",value:function(){return b(this,void 0,void 0,t().mark((function e(){return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:this._channels.clear(),this._enteredChannelUrls=[];case 2:case"end":return e.stop()}}),e,this)})))}}]),a}(Ha),hv={channelUrl:void 0,name:void 0,coverUrlOrImage:void 0,data:void 0,customType:void 0,operatorUserIds:void 0,isEphemeral:void 0},dv=function(e){return F("string",e.operatorUserIds,!0)&&(L("string",e.coverUrlOrImage,!0)||q(e.coverUrlOrImage,!0))&&L("string",e.name,!0)&&L("string",e.data,!0)&&L("string",e.customType,!0)&&(L("string",e.channelUrl)&&/^\w+$/.test(e.channelUrl)||null===e.channelUrl||void 0===e.channelUrl)&&L("boolean",e.isEphemeral,!0)},fv=function(e){i(n,e);var t=f(n);function n(e){var a,s=e.channelUrl,i=e.isInternalCall;return r(this,n),(a=t.call(this)).method=le.GET,a.path="".concat(i?me:_e,"/").concat(encodeURIComponent(s)),a}return s(n)}(Oe),pv=function(e){i(n,e);var t=f(n);function n(e,a){var s;return r(this,n),(s=t.call(this,e,a)).channel=new Mv(e,a),s}return s(n)}(Ue),vv=function(e){i(n,e);var t=f(n);function n(e){var a;r(this,n);var s=e.channelUrl,i=e.coverUrlOrImage,o=e.name,u=e.data,c=e.customType,l=e.operatorUserIds,h=e.isEphemeral;return(a=t.call(this)).method=le.POST,a.path=_e,a.params=ue(ce({channel_url:s,cover_url:L("string",i)?i:null,cover_file:q(i)?i:null,name:o,data:u,custom_type:c,operators:l,is_ephemeral:h})),a}return s(n)}(Oe),_v=function(e){i(n,e);var t=f(n);function n(e){var a=e.channelUrl;return r(this,n),t.call(this,{code:"ENTR",payload:{channel_url:a},ackRequired:!0})}return s(n)}(oa),mv=function(e){i(n,e);var t=f(n);function n(e,a,s){var i,o,u;return r(this,n),i=t.call(this,e,"SYEV",s),s.data&&(i.participantCount=null!==(o=s.data.participant_count)&&void 0!==o?o:0,i.user=new Xa(e,s.data),i.ts=null!==(u=s.data.edge_ts)&&void 0!==u?u:0),i}return s(n)}(tf),gv=function(e){i(n,e);var t=f(n);function n(e){var a=e.channelUrl;return r(this,n),t.call(this,{code:"EXIT",payload:{channel_url:a},ackRequired:!0})}return s(n)}(oa),yv=function(e){i(n,e);var t=f(n);function n(e,a,s){var i,o,u;return r(this,n),i=t.call(this,e,"EXIT",s),s.data&&(i.participantCount=null!==(o=s.data.participant_count)&&void 0!==o?o:0,i.user=new Xa(e,s.data),i.ts=null!==(u=s.data.edge_ts)&&void 0!==u?u:0),i}return s(n)}(tf),kv={},bv=function(){function n(e,t){var a=this,s=t.sdkState,i=t.dispatcher,o=t.requestQueue;return r(this,n),kv[e]||(this._iid=e,this._sdkState=s,this._requestQueue=o,this._dispatcher=i,this._openChannelCache=new lv(e),this._openChannelHandlers=new Map,this._dispatcher.on((function(e){if(e instanceof qe)a._handleEvent(e);else if(e instanceof da&&e.stateType===sa.CONNECTED){var t,n=y(a._openChannelCache.enteredChannels);try{for(n.s();!(t=n.n()).done;){t.value.enter()}}catch(e){n.e(e)}finally{n.f()}}})),kv[e]=this),kv[e]}return s(n,[{key:"buildOpenChannelFromSerializedData",value:function(e){var t=Ya(e);return new Mv(this._iid,Mv.payloadify(t))}},{key:"getChannelFromCache",value:function(e){var n;return b(this,void 0,void 0,t().mark((function r(){return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,this._openChannelCache.get(e);case 2:if(t.t1=n=t.sent,t.t0=null!==t.t1,!t.t0){t.next=6;break}t.t0=void 0!==n;case 6:if(!t.t0){t.next=10;break}t.t2=n,t.next=11;break;case 10:t.t2=null;case 11:return t.abrupt("return",t.t2);case 12:case"end":return t.stop()}}),r,this)})))}},{key:"upsertChannelsToCache",value:function(e){return b(this,void 0,void 0,t().mark((function n(){return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,this._openChannelCache.upsert(e);case 2:return t.abrupt("return",t.sent);case 3:case"end":return t.stop()}}),n,this)})))}},{key:"removeChannelsFromCache",value:function(e){return b(this,void 0,void 0,t().mark((function n(){var r,a,s;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:r=y(e),t.prev=1,r.s();case 3:if((a=r.n()).done){t.next=9;break}return s=a.value,t.next=7,this._openChannelCache.remove(s);case 7:t.next=3;break;case 9:t.next=14;break;case 11:t.prev=11,t.t0=t.catch(1),r.e(t.t0);case 14:return t.prev=14,r.f(),t.finish(14);case 17:case"end":return t.stop()}}),n,this,[[1,11,14,17]])})))}},{key:"setEnteredToCache",value:function(e){this._openChannelCache.enter(e.url)}},{key:"setExitedToCache",value:function(e){this._openChannelCache.exit(e.url)}},{key:"_handleEvent",value:function(n){return b(this,void 0,void 0,t().mark((function r(){var a,s,i,o,u,c,l,h,d,f,p,v,_,m,g,k,E,w,C,x,T,S,I,N,A,O,U,R,L,D,P,F,G,q,H,j,z,V,B,Q,K,W,Y,Z,J,X,$,ee,te,ne,re,ae,se,ie,oe,ue,ce,le,he,de,fe,pe,ve,_e,me,ge,ye,ke,be,Ee,we,Ce,xe,Te,Se,Ie,Ne,Me,Ae,Oe,Ue,Re,Le,De=this;return t().wrap((function(r){for(;;)switch(r.prev=r.next){case 0:r.prev=0,r.t0=n.code,r.next="MESG"===r.t0||"FILE"===r.t0||"ADMM"===r.t0||"BRDM"===r.t0?4:"MEDI"===r.t0||"FEDI"===r.t0||"AEDI"===r.t0?14:"DELM"===r.t0?24:"MRCT"===r.t0?31:"MTHD"===r.t0?38:"MCNT"===r.t0?45:"PEDI"===r.t0?73:"VOTE"===r.t0?81:"SYEV"===r.t0?89:166;break;case 4:if(a=null,"MESG"===n.code?a=n.as(Th):"FILE"===n.code?a=n.as(Ys):"ADMM"!==n.code&&"BRDM"!=n.code||(a=n.as(Nf)),!a){r.next=13;break}if(i=(s=a).message,o=s.isMentioned,i.channelType!==e.ChannelType.OPEN){r.next=13;break}return r.next=11,this.getChannel(i.channelUrl,!0);case 11:u=r.sent,Ca((function(){return b(De,void 0,void 0,t().mark((function e(){var n,r,a;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:n=y(this._openChannelHandlers.values());try{for(n.s();!(r=n.n()).done;)a=r.value,this._openChannelCache.isEnteredChannel(u.url)&&(a.onMessageReceived&&a.onMessageReceived(u,i),o&&a.onMentionReceived&&a.onMentionReceived(u,i))}catch(e){n.e(e)}finally{n.f()}case 2:case"end":return e.stop()}}),e,this)})))}));case 13:return r.abrupt("break",166);case 14:if(c=null,"MEDI"===n.code?c=n.as(Ih):"FEDI"===n.code?c=n.as(Mh):"AEDI"===n.code&&(c=n.as(Mf)),!c){r.next=23;break}if(h=(l=c).message,d=l.mentionCountChange,h.channelType!==e.ChannelType.OPEN){r.next=23;break}return r.next=21,this.getChannel(h.channelUrl,!0);case 21:f=r.sent,Ca((function(){return b(De,void 0,void 0,t().mark((function e(){var n,r,a;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:n=y(this._openChannelHandlers.values());try{for(n.s();!(r=n.n()).done;)a=r.value,this._openChannelCache.isEnteredChannel(f.url)&&(a.onMessageUpdated&&a.onMessageUpdated(f,h),d>0&&a.onMentionReceived&&a.onMentionReceived(f,h))}catch(e){n.e(e)}finally{n.f()}case 2:case"end":return e.stop()}}),e,this)})))}));case 23:return r.abrupt("break",166);case 24:if(p=n.as(Oh),v=p.channelUrl,_=p.channelType,m=p.messageId,_!==e.ChannelType.OPEN){r.next=30;break}return r.next=28,this.getChannel(v,!0);case 28:g=r.sent,Ca((function(){return b(De,void 0,void 0,t().mark((function e(){var n,r,a;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:n=y(this._openChannelHandlers.values());try{for(n.s();!(r=n.n()).done;)a=r.value,this._openChannelCache.isEnteredChannel(g.url)&&a.onMessageDeleted&&a.onMessageDeleted(g,m)}catch(e){n.e(e)}finally{n.f()}case 2:case"end":return e.stop()}}),e,this)})))}));case 30:return r.abrupt("break",166);case 31:if(k=n.as(Af),E=k.channelUrl,w=k.channelType,C=k.event,w!==e.ChannelType.OPEN){r.next=37;break}return r.next=35,this.getChannel(E,!0);case 35:x=r.sent,Ca((function(){return b(De,void 0,void 0,t().mark((function e(){var n,r,a;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:n=y(this._openChannelHandlers.values());try{for(n.s();!(r=n.n()).done;)a=r.value,this._openChannelCache.isEnteredChannel(x.url)&&a.onReactionUpdated&&a.onReactionUpdated(x,C)}catch(e){n.e(e)}finally{n.f()}case 2:case"end":return e.stop()}}),e,this)})))}));case 37:return r.abrupt("break",166);case 38:if(T=n.as(Of),(S=T.event).channelType!==e.ChannelType.OPEN){r.next=44;break}return r.next=42,this.getChannel(S.channelUrl,!0);case 42:I=r.sent,Ca((function(){return b(De,void 0,void 0,t().mark((function e(){var n,r,a;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:n=y(this._openChannelHandlers.values());try{for(n.s();!(r=n.n()).done;)a=r.value,this._openChannelCache.isEnteredChannel(I.url)&&a.onThreadInfoUpdated&&a.onThreadInfoUpdated(I,S)}catch(e){n.e(e)}finally{n.f()}case 2:case"end":return e.stop()}}),e,this)})))}));case 44:return r.abrupt("break",166);case 45:N=n.as(Sf),A=N.openChannelMemberCounts,O=[],U=y(A),r.prev=48,U.s();case 50:if((R=U.n()).done){r.next=59;break}return L=R.value,D=L.channelUrl,P=L.participantCount,F=L.updatedAt,r.next=55,this.getChannelFromCache(D);case 55:(G=r.sent)&&G._updateParticipantCount(P,F)&&O.push(G);case 57:r.next=50;break;case 59:r.next=64;break;case 61:r.prev=61,r.t1=r.catch(48),U.e(r.t1);case 64:return r.prev=64,U.f(),r.finish(64);case 67:if(!(O.length>0)){r.next=72;break}return r.next=70,this.upsertChannelsToCache(O);case 70:q=r.sent,Ca((function(){return b(De,void 0,void 0,t().mark((function e(){var n,r,a;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:n=y(this._openChannelHandlers.values());try{for(n.s();!(r=n.n()).done;)(a=r.value).onChannelMemberCountChanged&&a.onChannelMemberCountChanged(q)}catch(e){n.e(e)}finally{n.f()}case 2:case"end":return e.stop()}}),e,this)})))}));case 72:return r.abrupt("break",166);case 73:if(H=n.as(Uf),j=H.event,z=H.status,V=H.channelUrl,B=H.channelType,!V||B!==e.ChannelType.OPEN){r.next=80;break}return r.next=77,this.getChannel(V,!0);case 77:Q=r.sent,this._dispatcher.dispatch(new di({event:j,source:e.MessageEventSource.EVENT_POLL_UPDATED})),Ca(z===Ds?function(){return b(De,void 0,void 0,t().mark((function e(){var n,r,a;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:n=y(this._openChannelHandlers.values());try{for(n.s();!(r=n.n()).done;)(a=r.value).onPollDeleted&&a.onPollDeleted(Q,j.pollId)}catch(e){n.e(e)}finally{n.f()}case 2:case"end":return e.stop()}}),e,this)})))}:function(){return b(De,void 0,void 0,t().mark((function e(){var n,r,a;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:n=y(this._openChannelHandlers.values());try{for(n.s();!(r=n.n()).done;)(a=r.value).onPollUpdated&&a.onPollUpdated(Q,j)}catch(e){n.e(e)}finally{n.f()}case 2:case"end":return e.stop()}}),e,this)})))});case 80:return r.abrupt("break",166);case 81:if(K=n.as(td),W=K.event,Y=K.channelUrl,Z=K.channelType,!Y||Z!==e.ChannelType.OPEN){r.next=88;break}return r.next=85,this.getChannel(Y,!0);case 85:J=r.sent,this._dispatcher.dispatch(new fi({event:W,source:e.MessageEventSource.EVENT_POLL_VOTED})),Ca((function(){return b(De,void 0,void 0,t().mark((function e(){var n,r,a;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:n=y(this._openChannelHandlers.values());try{for(n.s();!(r=n.n()).done;)(a=r.value).onPollVoted&&a.onPollVoted(J,W)}catch(e){n.e(e)}finally{n.f()}case 2:case"end":return e.stop()}}),e,this)})))}));case 88:return r.abrupt("break",166);case 89:if(X=n.as(tf),!($=X.event).isOpenChannelEvent){r.next=165;break}r.t2=$.category,r.next=r.t2===pd.CHANNEL_ENTER?94:r.t2===pd.CHANNEL_EXIT?101:r.t2===pd.CHANNEL_OPERATOR_UPDATE?108:r.t2===pd.USER_CHANNEL_MUTE||r.t2===pd.USER_CHANNEL_UNMUTE?116:r.t2===pd.USER_CHANNEL_BAN||r.t2===pd.USER_CHANNEL_UNBAN?123:r.t2===pd.CHANNEL_FREEZE||r.t2===pd.CHANNEL_UNFREEZE?130:r.t2===pd.CHANNEL_DELETED?138:r.t2===pd.CHANNEL_PROP_CHANGED?145:r.t2===pd.CHANNEL_META_DATA_CHANGED?150:r.t2===pd.CHANNEL_META_COUNTERS_CHANGED?159:165;break;case 94:return r.next=96,this.getChannel($.channelUrl,!0);case 96:return ee=r.sent,te=n.as(mv),ne=te.participantCount,re=te.user,ae=ee._updateParticipantCount(ne,$.ts),Ca((function(){return b(De,void 0,void 0,t().mark((function e(){return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:this._openChannelHandlers.forEach((function(e){e.onUserEntered&&e.onUserEntered(ee,re),ae&&e.onChannelParticipantCountChanged&&e.onChannelParticipantCountChanged(ee)}));case 1:case"end":return e.stop()}}),e,this)})))})),r.abrupt("break",165);case 101:return r.next=103,this.getChannel($.channelUrl,!0);case 103:return se=r.sent,ie=n.as(yv),oe=ie.participantCount,ue=ie.user,ce=se._updateParticipantCount(oe,$.ts),Ca((function(){return b(De,void 0,void 0,t().mark((function e(){return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:this._openChannelHandlers.forEach((function(e){e.onUserExited&&e.onUserExited(se,ue),ce&&e.onChannelParticipantCountChanged&&e.onChannelParticipantCountChanged(se)}));case 1:case"end":return e.stop()}}),e,this)})))})),r.abrupt("break",165);case 108:return r.next=110,this.getChannel($.channelUrl,!0);case 110:return le=r.sent,he=n.as(Tf),de=he.operators,le.operators=de,this.upsertChannelsToCache([le]),Ca((function(){return b(De,void 0,void 0,t().mark((function e(){return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:this._openChannelHandlers.forEach((function(e){e.onOperatorUpdated&&e.onOperatorUpdated(le,de)}));case 1:case"end":return e.stop()}}),e,this)})))})),r.abrupt("break",165);case 116:return r.next=118,this.getChannel($.channelUrl,!0);case 118:return fe=r.sent,pe=$.category===pd.USER_CHANNEL_MUTE,ve=n.as(pe?fh:vh),_e=ve.user,Ca((function(){return b(De,void 0,void 0,t().mark((function e(){return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:this._openChannelHandlers.forEach((function(e){pe?e.onUserMuted&&e.onUserMuted(fe,_e):e.onUserUnmuted&&e.onUserUnmuted(fe,_e)}));case 1:case"end":return e.stop()}}),e,this)})))})),r.abrupt("break",165);case 123:return r.next=125,this.getChannel($.channelUrl,!0);case 125:return me=r.sent,ge=$.category===pd.USER_CHANNEL_BAN,ye=n.as(ge?mh:yh),ke=ye.user,Ca((function(){return b(De,void 0,void 0,t().mark((function e(){return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:this._openChannelHandlers.forEach((function(e){ge?e.onUserBanned&&e.onUserBanned(me,ke):e.onUserUnbanned&&e.onUserUnbanned(me,ke)}));case 1:case"end":return e.stop()}}),e,this)})))})),r.abrupt("break",165);case 130:return r.next=132,this.getChannel($.channelUrl,!0);case 132:return be=r.sent,Ee=n.as(bh),we=Ee.freeze,be.isFrozen=we,this.upsertChannelsToCache([be]),Ca((function(){return b(De,void 0,void 0,t().mark((function e(){return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:this._openChannelHandlers.forEach((function(e){we?e.onChannelFrozen&&e.onChannelFrozen(be):e.onChannelUnfrozen&&e.onChannelUnfrozen(be)}));case 1:case"end":return e.stop()}}),e,this)})))})),r.abrupt("break",165);case 138:return r.next=140,this.getChannel($.channelUrl,!0);case 140:return Ce=r.sent,r.next=143,this.removeChannelsFromCache([Ce.url]);case 143:return Ca((function(){return b(De,void 0,void 0,t().mark((function e(){return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:this._openChannelHandlers.forEach((function(e){e.onChannelDeleted&&e.onChannelDeleted(Ce.url,Ce.channelType)}));case 1:case"end":return e.stop()}}),e,this)})))})),r.abrupt("break",165);case 145:return r.next=147,this.getChannelWithoutCache($.channelUrl,!0);case 147:return xe=r.sent,Ca((function(){return b(De,void 0,void 0,t().mark((function e(){return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:this._openChannelHandlers.forEach((function(e){e.onChannelChanged&&e.onChannelChanged(xe)}));case 1:case"end":return e.stop()}}),e,this)})))})),r.abrupt("break",165);case 150:return r.next=152,this.getChannel($.channelUrl,!0);case 152:return Te=r.sent,Se=n.as(Xl),Ie=Se.created,Ne=Se.updated,Me=Se.deleted,Ie&&Te._upsertCachedMetaData(Ie,$.ts),Ne&&Te._upsertCachedMetaData(Ne,$.ts),Me&&Te._removeFromCachedMetaData(Me,$.ts),Ca((function(){return b(De,void 0,void 0,t().mark((function e(){return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:this._openChannelHandlers.forEach((function(e){Ie&&e.onMetaDataCreated&&e.onMetaDataCreated(Te,Ie),Ne&&e.onMetaDataUpdated&&e.onMetaDataUpdated(Te,Ne),Me&&e.onMetaDataDeleted&&e.onMetaDataDeleted(Te,Me)}));case 1:case"end":return e.stop()}}),e,this)})))})),r.abrupt("break",165);case 159:return r.next=161,this.getChannel($.channelUrl,!0);case 161:return Ae=r.sent,Oe=n.as(ch),Ue=Oe.created,Re=Oe.updated,Le=Oe.deleted,Ca((function(){return b(De,void 0,void 0,t().mark((function e(){return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:this._openChannelHandlers.forEach((function(e){Ue&&e.onMetaCounterCreated&&e.onMetaCounterCreated(Ae,Ue),Re&&e.onMetaCounterUpdated&&e.onMetaCounterUpdated(Ae,Re),Le&&e.onMetaCounterDeleted&&e.onMetaCounterDeleted(Ae,Le)}));case 1:case"end":return e.stop()}}),e,this)})))})),r.abrupt("break",165);case 165:return r.abrupt("break",166);case 166:r.next=172;break;case 168:if(r.prev=168,r.t3=r.catch(0),!M(r.t3)){r.next=172;break}throw r.t3;case 172:case"end":return r.stop()}}),r,this,[[0,168],[48,61,64,67]])})))}},{key:"addHandler",value:function(e,t){this._openChannelHandlers.set(e,t)}},{key:"removeHandler",value:function(e){this._openChannelHandlers.delete(e)}},{key:"clearHandler",value:function(){this._openChannelHandlers.clear()}},{key:"getChannel",value:function(e){return b(this,void 0,void 0,t().mark((function n(){var r;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return Za(L("string",e)).throw(A.invalidParameters),t.prev=1,t.next=4,this.getChannelFromCache(e);case 4:if(!(r=t.sent)){t.next=7;break}return t.abrupt("return",r);case 7:t.next=11;break;case 9:t.prev=9,t.t0=t.catch(1);case 11:return t.next=13,this.getChannelWithoutCache(e);case 13:return t.abrupt("return",t.sent);case 14:case"end":return t.stop()}}),n,this,[[1,9]])})))}},{key:"getChannelWithoutCache",value:function(e){var n=arguments.length>1&&void 0!==arguments[1]&&arguments[1];return b(this,void 0,void 0,t().mark((function r(){var a,s,i,o;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return Za(L("string",e)).throw(A.invalidParameters),a=new fv({channelUrl:e,isInternalCall:n}),t.next=4,this._requestQueue.send(a);case 4:return s=t.sent,i=s.as(pv),o=i.channel,t.next=8,this.upsertChannelsToCache([o]);case 8:return t.abrupt("return",t.sent[0]);case 9:case"end":return t.stop()}}),r,this)})))}},{key:"createChannel",value:function(e){return b(this,void 0,void 0,t().mark((function n(){var r,a,s,i,o;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return r=Object.assign(Object.assign({},hv),e),Za(dv(r)).throw(A.invalidParameters),a=new vv(r),t.next=5,this._requestQueue.send(a);case 5:return s=t.sent,i=s.as(pv),o=i.channel,this.upsertChannelsToCache([o]),t.abrupt("return",o);case 9:case"end":return t.stop()}}),n,this)})))}}],[{key:"of",value:function(e){return kv[e]}}]),n}(),Ev={name:void 0,coverUrlOrImage:void 0,data:void 0,customType:void 0,operatorUserIds:void 0},wv=function(e){return F("string",e.operatorUserIds,!0)&&(L("string",e.coverUrlOrImage)||q(e.coverUrlOrImage)||null===e.coverUrlOrImage)&&L("string",e.name,!0)&&L("string",e.data,!0)&&L("string",e.customType,!0)},Cv=function(e){i(n,e);var t=f(n);function n(e){var a;r(this,n);var s=e.channelUrl,i=e.token,o=e.limit;return(a=t.call(this)).method=le.GET,a.path="".concat(_e,"/").concat(encodeURIComponent(s),"/participants"),a.params={token:i,limit:o},a}return s(n)}(Oe),xv=function(e){i(n,e);var t=f(n);function n(e,a){var s;r(this,n),(s=t.call(this,e,a)).participants=[];var i=a.next,o=a.participants;return s.token=i,s.participants=o.map((function(t){return new Cl(e,t)})),s}return s(n)}(Ue),Tv=function(n){i(u,n);var a=f(u);function u(t,n,s){return r(this,u),a.call(this,t,n,e.ChannelType.OPEN,s)}return s(u,[{key:"_validate",value:function(){return p(o(u.prototype),"_validate",this).call(this)}},{key:"next",value:function(){return b(this,void 0,void 0,t().mark((function e(){var n,r,a,s,i,o,u;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!this._validate()){e.next=20;break}if(this._isLoading){e.next=17;break}if(!this._hasNext){e.next=14;break}return this._isLoading=!0,n=fs.of(this._iid),r=n.requestQueue,a=new Cv(Object.assign(Object.assign({},this),{token:this._token})),e.next=8,r.send(a);case 8:return s=e.sent,i=s.as(xv),o=i.participants,u=i.token,this._token=u,this._hasNext=!!u,this._isLoading=!1,e.abrupt("return",o);case 14:return e.abrupt("return",[]);case 17:throw A.queryInProgress;case 18:e.next=21;break;case 20:throw A.invalidParameters;case 21:case"end":return e.stop()}}),e,this)})))}}]),u}(Li),Sv=function(e){i(n,e);var t=f(n);function n(e){var a;r(this,n);var s=e.channelUrl,i=e.coverUrlOrImage,o=e.name,u=e.data,c=e.customType,l=e.operatorUserIds;return(a=t.call(this)).method=le.PUT,a.path="".concat(_e,"/").concat(encodeURIComponent(s)),a.params=ue(ce({cover_url:L("string",i)?i:null,cover_file:q(i)?i:null,name:o,data:u,custom_type:c,operators:l})),a}return s(n)}(Oe),Iv=function(e){i(n,e);var t=f(n);function n(e,a){var s;return r(this,n),(s=t.call(this,e,a)).channel=new Mv(e,a),s}return s(n)}(Ue),Nv=function(e){i(n,e);var t=f(n);function n(e){var a;r(this,n);var s=e.channelUrl;return(a=t.call(this)).method=le.DELETE,a.path="".concat(_e,"/").concat(encodeURIComponent(s)),a}return s(n)}(Oe),Mv=function(n){i(u,n);var a=f(u);function u(t,n){var s,i;return r(this,u),(s=a.call(this,t,n))._lastParticipantCountUpdated=0,s.participantCount=0,s.operators=[],s.channelType=e.ChannelType.OPEN,s.participantCount=null!==(i=n.participant_count)&&void 0!==i?i:0,s.operators=Array.isArray(n.operators)?n.operators.map((function(e){return new Xa(t,e)})):[],s}return s(u,[{key:"serialize",value:function(){return Wa(this)}},{key:"isOperator",value:function(e){return e instanceof Xa?this.isOperator(e.userId):this.operators.some((function(t){return t.userId===e}))}},{key:"_updateParticipantCount",value:function(e,t){return t>this._lastParticipantCountUpdated&&(this.participantCount=e,this._lastParticipantCountUpdated=t,!0)}},{key:"createParticipantListQuery",value:function(e){return new Tv(this._iid,this.url,e)}},{key:"refresh",value:function(){return b(this,void 0,void 0,t().mark((function e(){var n;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n=bv.of(this._iid),e.next=3,n.getChannelWithoutCache(this.url);case 3:return e.abrupt("return",e.sent);case 4:case"end":return e.stop()}}),e,this)})))}},{key:"enter",value:function(){return b(this,void 0,void 0,t().mark((function e(){var n,r,a,s,i,o,u;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n=fs.of(this._iid),r=n.requestQueue,a=new _v({channelUrl:this.url}),e.next=4,r.send(a);case 4:s=e.sent,i=s.as(mv),o=i.participantCount,u=i.ts,this._updateParticipantCount(o,u),bv.of(this._iid).setEnteredToCache(this);case 9:case"end":return e.stop()}}),e,this)})))}},{key:"exit",value:function(){return b(this,void 0,void 0,t().mark((function e(){var n,r,a,s,i,o,u;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n=fs.of(this._iid),r=n.requestQueue,a=new gv({channelUrl:this.url}),e.next=4,r.send(a);case 4:s=e.sent,i=s.as(yv),o=i.participantCount,u=i.ts,this._updateParticipantCount(o,u),bv.of(this._iid).setExitedToCache(this),wi.of(this._iid).fileMessageQueue.cancel(this);case 11:case"end":return e.stop()}}),e,this)})))}},{key:"updateChannel",value:function(e){return b(this,void 0,void 0,t().mark((function n(){var r,a,s,i,o,u,c,l;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return r=Object.assign(Object.assign({},Ev),e),Za(wv(r)).throw(A.invalidParameters),a=fs.of(this._iid),s=a.requestQueue,i=new Sv(Object.assign({channelUrl:this.url},r)),t.next=6,s.send(i);case 6:return o=t.sent,u=o.as(Iv),c=u.channel,this._update(c),l=bv.of(this._iid),t.next=12,l.upsertChannelsToCache([c]);case 12:return t.abrupt("return",this);case 13:case"end":return t.stop()}}),n,this)})))}},{key:"updateChannelWithOperatorUserIds",value:function(e,n,r,a,s){return b(this,void 0,void 0,t().mark((function i(){var o;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return o=Object.assign(Object.assign({},Ev),{name:e,coverUrlOrImage:n,data:r,operatorUserIds:a,customType:s}),t.abrupt("return",this.updateChannel(o));case 2:case"end":return t.stop()}}),i,this)})))}},{key:"delete",value:function(){return b(this,void 0,void 0,t().mark((function e(){var n,r,a,s;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n=fs.of(this._iid),r=n.requestQueue,a=new Nv({channelUrl:this.url}),e.next=4,r.send(a);case 4:return s=bv.of(this._iid),e.next=7,s.removeChannelsFromCache([this.url]);case 7:case"end":return e.stop()}}),e,this)})))}},{key:"sendUserMessage",value:function(e){return Za(!e.isPinnedMessage).throw(A.notSupportedError),p(o(u.prototype),"sendUserMessage",this).call(this,e)}},{key:"sendFileMessage",value:function(e){return Za(!e.isPinnedMessage).throw(A.notSupportedError),p(o(u.prototype),"sendFileMessage",this).call(this,e)}}],[{key:"payloadify",value:function(e){return ue(ce(Object.assign(Object.assign({},nd.payloadify(e)),{participant_count:e.participantCount,operators:e.operators.map((function(e){return Xa.payloadify(e)}))})))}}]),u}(nd),Av=function(e){i(n,e);var t=f(n);function n(){var e;return r(this,n),(e=t.apply(this,arguments)).onUserEntered=He,e.onUserExited=He,e.onChannelParticipantCountChanged=He,e.onPollUpdated=He,e.onPollVoted=He,e.onPollDeleted=He,e}return s(n)}(rv),Ov=function(e){i(n,e);var t=f(n);function n(){var e,a=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return r(this,n),e=t.call(this),Object.keys(a).forEach((function(t){e.hasOwnProperty(t)&&(e[t]=a[t])})),e}return s(n)}(Av),Uv=function(e){i(n,e);var t=f(n);function n(e){var a;r(this,n);var s=e.token,i=e.limit,o=e.nameKeyword,u=e.urlKeyword,c=e.customTypes,l=e.includeFrozen,h=e.includeMetaData;return(a=t.call(this)).method=le.GET,a.path=_e,a.params=ue({token:s,limit:i,name_contains:o,url_contains:u,custom_types:c,show_frozen:l,show_metadata:h}),a}return s(n)}(Oe),Rv=function(e){i(n,e);var t=f(n);function n(e,a){var s;r(this,n),(s=t.call(this,e,a)).channels=[];var i=a.next,o=a.channels,u=a.ts;return s.token=i,o&&o.length>0&&(s.channels=o.map((function(t){return new Mv(e,t)}))),s.ts="number"==typeof u?u:null,s}return s(n)}(Ue),Lv=function(e){i(a,e);var n=f(a);function a(e,t){var s,i,o,u,c,l;return r(this,a),(s=n.call(this,e,t)).includeFrozen=!0,s.includeMetaData=!0,s.nameKeyword=null,s.urlKeyword=null,s.customTypes=null,s.includeFrozen=null===(i=t.includeFrozen)||void 0===i||i,s.includeMetaData=null===(o=t.includeMetaData)||void 0===o||o,s.nameKeyword=null!==(u=t.nameKeyword)&&void 0!==u?u:null,s.urlKeyword=null!==(c=t.urlKeyword)&&void 0!==c?c:null,s.customTypes=null!==(l=t.customTypes)&&void 0!==l?l:null,s}return s(a,[{key:"_validate",value:function(){return p(o(a.prototype),"_validate",this).call(this)&&L("boolean",this.includeFrozen)&&L("boolean",this.includeMetaData)&&L("string",this.nameKeyword,!0)&&L("string",this.urlKeyword,!0)&&F("string",this.customTypes,!0)}},{key:"next",value:function(){return b(this,void 0,void 0,t().mark((function e(){var n,r,a,s,i,o,u,c;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!this._validate()){e.next=23;break}if(this._isLoading){e.next=20;break}if(!this._hasNext){e.next=17;break}return this._isLoading=!0,n=fs.of(this._iid),r=n.requestQueue,a=new Uv(ce(Object.assign(Object.assign({},this),{token:this._token}))),e.next=8,r.send(a);case 8:return s=e.sent,i=s.as(Rv),o=i.channels,u=i.token,this._token=u,this._hasNext=!!u,c=bv.of(this._iid),e.next=15,c.upsertChannelsToCache(o);case 15:return this._isLoading=!1,e.abrupt("return",o);case 17:return e.abrupt("return",[]);case 20:throw A.queryInProgress;case 21:e.next=24;break;case 23:throw A.invalidParameters;case 24:case"end":return e.stop()}}),e,this)})))}}]),a}(Ii),Dv=function(e){i(a,e);var n=f(a);function a(){var e;return r(this,a),(e=n.apply(this,arguments)).name="openChannel",e}return s(a,[{key:"init",value:function(e,t){var n=t.sdkState,r=t.dispatcher,s=t.sessionManager,i=t.requestQueue,u=t.logger,c=t.onlineDetector,l=t.cacheContext;p(o(a.prototype),"init",this).call(this,e,{sdkState:n,dispatcher:r,sessionManager:s,requestQueue:i,logger:u,onlineDetector:c,cacheContext:l}),this._manager=new bv(e,{sdkState:n,dispatcher:r,requestQueue:i})}},{key:"createOpenChannelListQuery",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return new Lv(this._iid,e)}},{key:"addOpenChannelHandler",value:function(e,t){this._manager.addHandler(e,t)}},{key:"removeOpenChannelHandler",value:function(e){this._manager.removeHandler(e)}},{key:"removeAllOpenChannelHandlers",value:function(){this._manager.clearHandler()}},{key:"buildOpenChannelFromSerializedData",value:function(e){return this._manager.buildOpenChannelFromSerializedData(e)}},{key:"getChannel",value:function(e){return b(this,void 0,void 0,t().mark((function n(){return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.abrupt("return",this._manager.getChannel(e));case 1:case"end":return t.stop()}}),n,this)})))}},{key:"getChannelWithoutCache",value:function(e){return b(this,void 0,void 0,t().mark((function n(){return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.abrupt("return",this._manager.getChannelWithoutCache(e));case 1:case"end":return t.stop()}}),n,this)})))}},{key:"createChannel",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return b(this,void 0,void 0,t().mark((function n(){return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.abrupt("return",this._manager.createChannel(e));case 1:case"end":return t.stop()}}),n,this)})))}},{key:"createChannelWithOperatorUserIds",value:function(e,n,r,a,s){return b(this,void 0,void 0,t().mark((function i(){var o;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return(o=Object.assign({},hv)).name=e,o.coverUrlOrImage=n,o.data=r,o.operatorUserIds=a,o.customType=s,t.abrupt("return",this._manager.createChannel(o));case 7:case"end":return t.stop()}}),i,this)})))}}]),a}(ps);tv=function(){function e(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function t(e,t){for(var n=0;n-1};function jv(e){if("string"!=typeof e&&(e=String(e)),/[^a-z0-9\-#$%&'*+.^_`|~!]/i.test(e)||""===e)throw new TypeError('Invalid character in header field name: "'+e+'"');return e.toLowerCase()}function zv(e){return"string"!=typeof e&&(e=String(e)),e}function Vv(e){var t={next:function(){var t=e.shift();return{done:void 0===t,value:t}}};return Gv.iterable&&(t[Symbol.iterator]=function(){return t}),t}function Bv(e){this.map={},e instanceof Bv?e.forEach((function(e,t){this.append(t,e)}),this):Array.isArray(e)?e.forEach((function(e){this.append(e[0],e[1])}),this):e&&Object.getOwnPropertyNames(e).forEach((function(t){this.append(t,e[t])}),this)}function Qv(e){if(e.bodyUsed)return Promise.reject(new TypeError("Already read"));e.bodyUsed=!0}function Kv(e){return new Promise((function(t,n){e.onload=function(){t(e.result)},e.onerror=function(){n(e.error)}}))}function Wv(e){var t=new FileReader,n=Kv(t);return t.readAsArrayBuffer(e),n}function Yv(e){if(e.slice)return e.slice(0);var t=new Uint8Array(e.byteLength);return t.set(new Uint8Array(e)),t.buffer}function Zv(){return this.bodyUsed=!1,this._initBody=function(e){var t;this.bodyUsed=this.bodyUsed,this._bodyInit=e,e?"string"==typeof e?this._bodyText=e:Gv.blob&&Blob.prototype.isPrototypeOf(e)?this._bodyBlob=e:Gv.formData&&FormData.prototype.isPrototypeOf(e)?this._bodyFormData=e:Gv.searchParams&&URLSearchParams.prototype.isPrototypeOf(e)?this._bodyText=e.toString():Gv.arrayBuffer&&Gv.blob&&((t=e)&&DataView.prototype.isPrototypeOf(t))?(this._bodyArrayBuffer=Yv(e.buffer),this._bodyInit=new Blob([this._bodyArrayBuffer])):Gv.arrayBuffer&&(ArrayBuffer.prototype.isPrototypeOf(e)||Hv(e))?this._bodyArrayBuffer=Yv(e):this._bodyText=e=Object.prototype.toString.call(e):this._bodyText="",this.headers.get("content-type")||("string"==typeof e?this.headers.set("content-type","text/plain;charset=UTF-8"):this._bodyBlob&&this._bodyBlob.type?this.headers.set("content-type",this._bodyBlob.type):Gv.searchParams&&URLSearchParams.prototype.isPrototypeOf(e)&&this.headers.set("content-type","application/x-www-form-urlencoded;charset=UTF-8"))},Gv.blob&&(this.blob=function(){var e=Qv(this);if(e)return e;if(this._bodyBlob)return Promise.resolve(this._bodyBlob);if(this._bodyArrayBuffer)return Promise.resolve(new Blob([this._bodyArrayBuffer]));if(this._bodyFormData)throw new Error("could not read FormData body as blob");return Promise.resolve(new Blob([this._bodyText]))},this.arrayBuffer=function(){if(this._bodyArrayBuffer){var e=Qv(this);return e||(ArrayBuffer.isView(this._bodyArrayBuffer)?Promise.resolve(this._bodyArrayBuffer.buffer.slice(this._bodyArrayBuffer.byteOffset,this._bodyArrayBuffer.byteOffset+this._bodyArrayBuffer.byteLength)):Promise.resolve(this._bodyArrayBuffer))}return this.blob().then(Wv)}),this.text=function(){var e,t,n,r=Qv(this);if(r)return r;if(this._bodyBlob)return e=this._bodyBlob,t=new FileReader,n=Kv(t),t.readAsText(e),n;if(this._bodyArrayBuffer)return Promise.resolve(function(e){for(var t=new Uint8Array(e),n=new Array(t.length),r=0;r-1?r:n),this.mode=t.mode||this.mode||null,this.signal=t.signal||this.signal,this.referrer=null,("GET"===this.method||"HEAD"===this.method)&&a)throw new TypeError("Body not allowed for GET or HEAD requests");if(this._initBody(a),!("GET"!==this.method&&"HEAD"!==this.method||"no-store"!==t.cache&&"no-cache"!==t.cache)){var s=/([?&])_=[^&]*/;if(s.test(this.url))this.url=this.url.replace(s,"$1_="+(new Date).getTime());else{this.url+=(/\?/.test(this.url)?"&":"?")+"_="+(new Date).getTime()}}}function $v(e){var t=new FormData;return e.trim().split("&").forEach((function(e){if(e){var n=e.split("="),r=n.shift().replace(/\+/g," "),a=n.join("=").replace(/\+/g," ");t.append(decodeURIComponent(r),decodeURIComponent(a))}})),t}function e_(e,t){if(!(this instanceof e_))throw new TypeError('Please use the "new" operator, this DOM object constructor cannot be called as a function.');t||(t={}),this.type="default",this.status=void 0===t.status?200:t.status,this.ok=this.status>=200&&this.status<300,this.statusText=void 0===t.statusText?"":""+t.statusText,this.headers=new Bv(t.headers),this.url=t.url||"",this._initBody(e)}Xv.prototype.clone=function(){return new Xv(this,{body:this._bodyInit})},Zv.call(Xv.prototype),Zv.call(e_.prototype),e_.prototype.clone=function(){return new e_(this._bodyInit,{status:this.status,statusText:this.statusText,headers:new Bv(this.headers),url:this.url})},e_.error=function(){var e=new e_(null,{status:0,statusText:""});return e.type="error",e};var t_=[301,302,303,307,308];e_.redirect=function(e,t){if(-1===t_.indexOf(t))throw new RangeError("Invalid status code");return new e_(null,{status:t,headers:{location:e}})};var n_=Fv.DOMException;try{new n_}catch(sn){(n_=function(e,t){this.message=e,this.name=t;var n=Error(e);this.stack=n.stack}).prototype=Object.create(Error.prototype),n_.prototype.constructor=n_}function r_(e,t){return new Promise((function(r,a){var s=new Xv(e,t);if(s.signal&&s.signal.aborted)return a(new n_("Aborted","AbortError"));var i=new XMLHttpRequest;function o(){i.abort()}i.onload=function(){var e,t,n={status:i.status,statusText:i.statusText,headers:(e=i.getAllResponseHeaders()||"",t=new Bv,e.replace(/\r?\n[\t ]+/g," ").split("\r").map((function(e){return 0===e.indexOf("\n")?e.substr(1,e.length):e})).forEach((function(e){var n=e.split(":"),r=n.shift().trim();if(r){var a=n.join(":").trim();t.append(r,a)}})),t)};n.url="responseURL"in i?i.responseURL:n.headers.get("X-Request-URL");var a="response"in i?i.response:i.responseText;setTimeout((function(){r(new e_(a,n))}),0)},i.onerror=function(){setTimeout((function(){a(new TypeError("Network request failed"))}),0)},i.ontimeout=function(){setTimeout((function(){a(new TypeError("Network request failed"))}),0)},i.onabort=function(){setTimeout((function(){a(new n_("Aborted","AbortError"))}),0)},i.open(s.method,function(e){try{return""===e&&Fv.location.href?Fv.location.href:e}catch(t){return e}}(s.url),!0),"include"===s.credentials?i.withCredentials=!0:"omit"===s.credentials&&(i.withCredentials=!1),"responseType"in i&&(Gv.blob?i.responseType="blob":Gv.arrayBuffer&&s.headers.get("Content-Type")&&-1!==s.headers.get("Content-Type").indexOf("application/octet-stream")&&(i.responseType="arraybuffer")),!t||"object"!==n(t.headers)||t.headers instanceof Bv?s.headers.forEach((function(e,t){i.setRequestHeader(t,e)})):Object.getOwnPropertyNames(t.headers).forEach((function(e){i.setRequestHeader(e,zv(t.headers[e]))})),s.signal&&(s.signal.addEventListener("abort",o),i.onreadystatechange=function(){4===i.readyState&&s.signal.removeEventListener("abort",o)}),i.send(void 0===s._bodyInit?null:s._bodyInit)}))}r_.polyfill=!0,Fv.fetch||(Fv.fetch=r_,Fv.Headers=Bv,Fv.Request=Xv,Fv.Response=e_);var a_=Object.freeze({__proto__:null});return e.AdminMessage=Rs,e.AppleCriticalAlertOptions=xs,e.ApplicationUserListQuery=gc,e.BannedUserListQuery=Gl,e.BaseChannel=nd,e.BaseMessage=Ns,e.BlockedUserListQuery=bc,e.CachedChannelInfo=ee,e.ConnectionHandler=_o,e.Emoji=sc,e.EmojiCategory=ic,e.EmojiContainer=oc,e.FileMessage=Qs,e.FriendListQuery=Cc,e.GroupChannel=Kp,e.GroupChannelCollection=Xp,e.GroupChannelEventContext=qf,e.GroupChannelFilter=vd,e.GroupChannelHandler=sv,e.GroupChannelListQuery=Rf,e.GroupChannelModule=cv,e.LocalCacheConfig=te,e.Member=dd,e.MemberListQuery=_p,e.MemoryStore=ll,e.MessageCollection=up,e.MessageCollectionInitHandler=op,e.MessageEventContext=Hf,e.MessageFilter=wo,e.MessageMetaArray=Es,e.MessageModule=qi,e.MessageRequestHandler=Ci,e.MessageSearchQuery=Ri,e.MultipleFilesMessage=zs,e.MultipleFilesMessageRequestHandler=Gi,e.MutedUserListQuery=Dl,e.OGImage=ws,e.OGMetaData=Cs,e.OpenChannel=Mv,e.OpenChannelHandler=Ov,e.OpenChannelListQuery=Lv,e.OpenChannelModule=Dv,e.OperatorListQuery=Ul,e.Participant=Cl,e.ParticipantListQuery=Tv,e.PinnedMessage=jp,e.PinnedMessageListQuery=Bp,e.Plugin=Ls,e.PreviousMessageListQuery=Di,e.PublicGroupChannelListQuery=nv,e.Reaction=bs,e.ReactionEvent=ks,e.ReadStatus=fd,e.RestrictedUser=wl,e.RestrictionInfo=El,e.ScheduledMessageListQuery=uv,e.SendbirdChat=rd,e.SendbirdChatOptions=H,e.SendbirdError=A,e.Sender=Ts,e.SessionHandler=vo,e.ThreadInfo=ms,e.ThreadInfoUpdateEvent=xi,e.Thumbnail=As,e.UIKitConfigInfo=Fa,e.UploadedFileInfo=js,e.User=Xa,e.UserEventHandler=mo,e.UserMessage=Hs,Object.defineProperty(e,"__esModule",{value:!0}),e}({});