diff --git a/CHANGELOG.md b/CHANGELOG.md index 21ea757..8f4deeb 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,9 @@ # Changelog +## v4.1.3 (Nov 16, 2022) +- Improved stability + ## v4.1.2 (Nov 15, 2022) - Fixed a bug where Poll changelog being called when it's not enabled - Fixed the wrong `MessageCollection` event being triggered diff --git a/__bundle-0bd37fbb.js b/__bundle-0bd37fbb.js deleted file mode 100644 index d38fb9f..0000000 --- a/__bundle-0bd37fbb.js +++ /dev/null @@ -1 +0,0 @@ -import{_ as e,A as t,a as n,b as r,P as i,c as s,d as o,g as a,e as u,i as c,v as l,f as h,h as d,C as f,j as p,k as v,M as _,u as m,S as y,l as g,m as b,n as I,V as E,U as w,o as k,q as N,r as S,s as T,t as O,w as C,R as A,x as L,F as x,y as P,I as R,z as D,E as M,B as U,D as q,G as F,H as B,J as K,K as j,L as H,W as z,N as V,O as Q,Q as G,T as W,X as Y,Y as J,Z as X,$ as Z,a0 as $,a1 as ee,a2 as te,a3 as ne,a4 as re,a5 as ie,a6 as se,a7 as oe,a8 as ae,a9 as ue,aa as ce,ab as le,ac as he}from"./__bundle-0a632c33.js";import{U as de,s as fe,v as pe,B as ve,a as _e,b as me,i as ye,F as ge,c as be}from"./__bundle-c7363281.js";var Ie,Ee,we,ke;!function(e){e.SUCCESS="success",e.PENDING="pending",e.ERROR="error"}(Ie||(Ie={})),function(e){e.DEFAULT="default",e.ALL="all",e.MENTION_ONLY="mention_only",e.OFF="off"}(Ee||(Ee={})),function(e){e.FCM="gcm",e.APNS="apns",e.UNKNOWN="unknown"}(we||(we={})),function(e){e.ALTERNATIVE="alternative",e.DEFAULT="default"}(ke||(ke={}));var Ne,Se,Te,Oe=function(r){function i(e){var i=e.title,s=e.optionTexts,o=e.data,a=e.isAnonymous,u=e.allowUserSuggestion,c=e.allowMultipleVotes,l=e.closeAt,h=r.call(this)||this;return h.method=t.POST,h.path=n,h.params={title:i,options:s,data:o,is_anonymous:a,allow_user_suggestion:u,allow_multiple_votes:c,close_at:l},h}return e(i,r),i}(r),Ce=function(t){function n(e,n){var r=t.call(this,e,n)||this;return r.poll=new i(e,n),r}return e(n,t),n}(s),Ae=function(r){function i(e){var i=e.channelUrl,s=e.channelType,o=e.pollId,a=r.call(this)||this;return a.method=t.GET,a.path="".concat(n,"/").concat(encodeURIComponent(o)),a.params={channel_url:i,channel_type:s},a}return e(i,r),i}(r),Le=function(t){function n(e,n){var r=t.call(this,e,n)||this;return r.poll=new i(e,n),r}return e(n,t),n}(s),xe=function(r){function i(e){var i=e.channelUrl,s=e.channelType,o=e.pollId,a=e.pollOptionId,u=r.call(this)||this;return u.method=t.GET,u.path="".concat(n,"/").concat(encodeURIComponent(o),"/options/").concat(encodeURIComponent(a)),u.params={channel_url:i,channel_type:s},u}return e(i,r),i}(r),Pe=function(t){function n(e,n){var r=t.call(this,e,n)||this;return r.pollOption=new o(e,n),r}return e(n,t),n}(s),Re=function(n){function r(e){var r=e.channelType,i=e.channelUrl,s=e.timestamp,o=e.token,c=n.call(this)||this;return c.method=t.GET,c.path="".concat(a(r),"/").concat(encodeURIComponent(i),"/polls/changelogs"),c.params=u({change_ts:s,token:o}),c}return e(r,n),r}(r),De=function(t){function n(e,n){var r=t.call(this,e,n)||this;return r.updatedPolls=n.updated.map((function(t){return function(e,t){return t?new i(e,t):null}(e,t)})),r.deletedPollIds=n.deleted.map((function(e){return e})),r.hasMore=n.has_more,r.nextToken=n.next,r}return e(n,t),n}(s),Me={title:null,optionTexts:null,data:null,isAnonymous:null,allowUserSuggestion:null,allowMultipleVotes:null,closeAt:-1},Ue=function(e){return c("string",e.title)&&l(e.optionTexts)&&h(e.data)&&c("boolean",e.isAnonymous,!0)&&c("boolean",e.allowUserSuggestion,!0)&&c("boolean",e.allowMultipleVotes,!0)&&c("number",e.closeAt,!0)},qe={channelUrl:null,channelType:null,pollId:null,pollOptionId:null},Fe=function(e){return c("string",e.channelUrl)&&d(f,e.channelType)&&c("number",e.pollId)&&c("number",e.pollOptionId)},Be={channelUrl:null,channelType:null,pollId:null},Ke=function(e){return c("string",e.channelUrl)&&""!==e.channelUrl&&d(f,e.channelType)&&c("number",e.pollId)},je={},He=function(){function e(e,t){var n=t.sdkState,r=t.dispatcher,i=t.sessionManager,s=t.requestQueue,o=t.logger;this._iid=e,this._sdkState=n,this._sessionManager=i,this._requestQueue=s,this._dispatcher=r,this._logger=o,je[e]=this}return e.of=function(e){return je[e]},e.prototype.get=function(e){return p(this,void 0,void 0,(function(){var t,n;return v(this,(function(r){switch(r.label){case 0:return m(Ke(e)).throw(y.invalidParameters),t=new Ae(g({},e)),[4,this._requestQueue.send(t)];case 1:return n=r.sent(),[2,n.as(Le).poll]}}))}))},e.prototype.create=function(e){return p(this,void 0,void 0,(function(){var t,n,r;return v(this,(function(i){switch(i.label){case 0:return m(Ue(e)).throw(y.invalidParameters),t=e.data,n=new Oe(g(g({},e),{data:t})),[4,this._requestQueue.send(n)];case 1:return r=i.sent(),[2,r.as(Ce).poll]}}))}))},e.prototype.getOption=function(e){return p(this,void 0,void 0,(function(){var t,n;return v(this,(function(r){switch(r.label){case 0:return m(Fe(e)).throw(y.invalidParameters),t=new xe(g({},e)),[4,this._requestQueue.send(t)];case 1:return n=r.sent(),[2,n.as(Pe).pollOption]}}))}))},e.prototype.getPollChangeLogs=function(e,t,n,r){return void 0===r&&(r=_.SYNC_POLL_CHANGELOGS),p(this,void 0,void 0,(function(){var i,s,o,a,c,l,h;return v(this,(function(d){switch(d.label){case 0:return i=new Re(u({channelType:t,channelUrl:e,timestamp:"number"==typeof n?n:null,token:"string"==typeof n?n:null})),[4,this._requestQueue.send(i)];case 1:return s=d.sent(),o=s.as(De),a=o.updatedPolls,c=o.deletedPollIds,l=o.hasMore,h=o.nextToken,a.length>0&&this._dispatcher.dispatch(new b({polls:a,source:r})),[2,{updatedPolls:a,deletedPollIds:c,hasMore:l,token:h}]}}))}))},e}(),ze=function(e,t){this.pollId=0,this.messageId=0,this.pollId=t.poll.id,this.messageId=t.poll.message_id,this._iid=e,this._payload=t},Ve=function(e){this.pollId=0,this.messageId=0,this.pollId=e.poll_id,this.messageId=e.message_id,this._payload=e},Qe=function(r){function i(e){var i=e.channelUrl,s=e.channelType,o=e.token,a=e.limit,u=r.call(this)||this;return u.method=t.GET,u.path=n,u.params={channel_url:i,channel_type:s,token:o,limit:a},u}return e(i,r),i}(r),Ge=function(t){function n(e,n){var r,s=this;return(s=t.call(this,e,n)||this).polls=(null!==(r=n.polls)&&void 0!==r?r:[]).map((function(t){return new i(e,t)})),s.token=n.next,s}return e(n,t),n}(s),We=function(t){function n(e,n){return t.call(this,e,n.channelUrl,n.channelType,n)||this}return e(n,t),n.prototype.next=function(){return p(this,void 0,void 0,(function(){var e,t,n,r,i,s;return v(this,(function(o){switch(o.label){case 0:return this._validate()?this._isLoading?[3,3]:this._hasNext?(this._isLoading=!0,e=E.of(this._iid).requestQueue,t=new Qe(g(g({},this),{token:this._token})),[4,e.send(t)]):[3,2]:[3,5];case 1:return n=o.sent(),r=n.as(Ge),i=r.polls,s=r.token,this._token=s,this._hasNext=!!s,this._isLoading=!1,[2,i];case 2:return[2,[]];case 3:throw y.queryInProgress;case 4:return[3,6];case 5:throw y.invalidParameters;case 6:return[2]}}))}))},n}(I),Ye=function(r){function i(e){var i=e.channelUrl,s=e.channelType,o=e.pollId,a=e.pollOptionId,u=e.token,c=e.limit,l=r.call(this)||this;return l.method=t.GET,l.path="".concat(n,"/").concat(encodeURIComponent(o),"/options/").concat(encodeURIComponent(a),"/voters"),l.params={channel_url:i,channel_type:s,token:u,limit:c},l}return e(i,r),i}(r),Je=function(t){function n(e,n){var r,i=this;return(i=t.call(this,e,n)||this).voters=(null!==(r=n.voters)&&void 0!==r?r:[]).map((function(t){return new w(e,t)})),i.token=n.next,i}return e(n,t),n}(s),Xe=function(t){function n(e,n){var r=t.call(this,e,n.channelUrl,n.channelType,n)||this;return r.pollId=n.pollId,r.pollOptionId=n.pollOptionId,r}return e(n,t),n.prototype._validate=function(){return t.prototype._validate.call(this)&&c("number",this.pollId)&&c("number",this.pollOptionId)},n.prototype.next=function(){return p(this,void 0,void 0,(function(){var e,t,n,r,i,s;return v(this,(function(o){switch(o.label){case 0:return this._validate()?this._isLoading?[3,3]:this._hasNext?(this._isLoading=!0,e=E.of(this._iid).requestQueue,t=new Ye(g(g({},this),{pollId:this.pollId,pollOptionId:this.pollOptionId,token:this._token})),[4,e.send(t)]):[3,2]:[3,5];case 1:return n=o.sent(),r=n.as(Je),i=r.voters,s=r.token,this._token=s,this._hasNext=!!s,this._isLoading=!1,[2,i];case 2:return[2,[]];case 3:throw y.queryInProgress;case 4:return[3,6];case 5:throw y.invalidParameters;case 6:return[2]}}))}))},n}(I),Ze=function(t){function n(){var e=null!==t&&t.apply(this,arguments)||this;return e.name="poll",e}return e(n,t),n.prototype.init=function(e,n){var r=n.sdkState,i=n.dispatcher,s=n.sessionManager,o=n.requestQueue,a=n.logger,u=n.onlineDetector,c=n.cacheContext;t.prototype.init.call(this,e,{sdkState:r,dispatcher:i,sessionManager:s,requestQueue:o,logger:a,onlineDetector:u,cacheContext:c}),this._manager=new He(e,{sdkState:r,dispatcher:i,sessionManager:s,requestQueue:o,logger:a,onlineDetector:u,cacheContext:c})},n.prototype.create=function(e){return p(this,void 0,void 0,(function(){var t;return v(this,(function(n){return t=g(g({},Me),e),m(Ue(t)).throw(y.invalidParameters),[2,this._manager.create(t)]}))}))},n.prototype.get=function(e){return p(this,void 0,void 0,(function(){var t;return v(this,(function(n){return t=g(g({},Be),e),m(Ke(t)).throw(y.invalidParameters),[2,this._manager.get(t)]}))}))},n.prototype.getOption=function(e){return p(this,void 0,void 0,(function(){var t;return v(this,(function(n){return t=g(g({},qe),e),m(Fe(t)).throw(y.invalidParameters),[2,this._manager.getOption(t)]}))}))},n}(k),$e={profileImage:null,profileUrl:null,nickname:null},et=function(t){function n(e){void 0===e&&(e={});var n=t.call(this)||this;return Object.keys(e).forEach((function(t){n.hasOwnProperty(t)&&(n[t]=e[t])})),n}return e(n,t),n}((function(){this.onSessionExpired=S,this.onSessionTokenRequired=function(e){return e(null)},this.onSessionError=S,this.onSessionRefreshed=S,this.onSessionClosed=S})),tt=function(t){function n(e){void 0===e&&(e={});var n=t.call(this)||this;return Object.keys(e).forEach((function(t){n.hasOwnProperty(t)&&(n[t]=e[t])})),n}return e(n,t),n}((function(){this.onConnected=S,this.onReconnectStarted=S,this.onReconnectSucceeded=S,this.onReconnectFailed=S,this.onDisconnected=S})),nt=function(t){function n(e){void 0===e&&(e={});var n=t.call(this)||this;return Object.keys(e).forEach((function(t){n.hasOwnProperty(t)&&(n[t]=e[t])})),n}return e(n,t),n}((function(){this.onFriendsDiscovered=S,this.onTotalUnreadMessageCountUpdated=S})),rt=100,it="GroupChannel",st=100,ot=10,at=20;!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"}(Ne||(Ne={})),function(e){e.CHRONOLOGICAL="chronological",e.CHANNEL_NAME_ALPHABETICAL="channel_name_alphabetical",e.METADATA_VALUE_ALPHABETICAL="metadata_value_alphabetical"}(Se||(Se={})),function(e){e.CREATED_AT="created_at",e.SCHEDULED_AT="scheduled_at"}(Te||(Te={}));var ut,ct=function(e){switch(e){case Ne.LATEST_LAST_MESSAGE:return["-lastMessageUpdatedAt","-createdAt","syncIndex"];case Ne.CHRONOLOGICAL:return["-createdAt","syncIndex"];case Ne.CHANNEL_NAME_ALPHABETICAL:return["name"]}},lt=function(){function e(){this.messageTypeFilter=T.ALL,this.customTypesFilter=null,this.senderUserIdsFilter=null,this.replyType=A.NONE}return e.prototype.clone=function(){var t=new e,n=JSON.parse(JSON.stringify(this));return Object.keys(n).forEach((function(e){t[e]=n[e]})),t},e.prototype.match=function(e){switch(this.messageTypeFilter){case T.USER:if(e.messageType!==O.USER)return!1;break;case T.FILE:if(e.messageType!==O.FILE)return!1;break;case T.ADMIN:if(e.messageType!==O.ADMIN)return!1}if(this.customTypesFilter&&this.customTypesFilter.length>0&&!this.customTypesFilter.includes(e.customType))return!1;if(this.senderUserIdsFilter&&this.senderUserIdsFilter.length>0){if(!(e instanceof C))return!1;if(!this.senderUserIdsFilter.includes(e.sender.userId))return!1}switch(this.replyType){case A.NONE:if(e.parentMessageId>0)return!1;break;case A.ONLY_REPLY_TO_CHANNEL:if(e instanceof C&&e.parentMessageId>0&&!e.replyToChannel)return!1}return!0},e}();!function(e){e.CHANNEL_LATEST="channel_latest",e.NEWEST_CHILD_MESSAGE="newest_child_message"}(ut||(ut={}));var ht,dt=function(e){switch(e){case ut.CHANNEL_LATEST:return["channelUrl","-createdAt","-messageId"];case ut.NEWEST_CHILD_MESSAGE:return["channelUrl","-parentMessageId","-createdAt","-messageId"]}},ft=g(g({},de),{scheduledAt:null}),pt=function(e){return pe(e)&&c("number",e.scheduledAt,!0)},vt=g(g({},ve),{scheduledAt:null,file:null,fileUrl:null,fileName:null,mimeType:null,fileSize:null,thumbnailSizes:null,requireAuth:!1}),_t=function(e){return me(e)&&c("number",e.scheduledAt)&&(N(e.file)||c("string",e.fileUrl))&&c("string",e.fileName,!0)&&c("string",e.mimeType,!0)&&c("number",e.fileSize,!0)&&(null===e.thumbnailSizes||e.thumbnailSizes.every((function(e){return c("object",e)&&e.maxWidth>0&&e.maxHeight>0})))},mt={},yt=function(t){function n(e,n){var r=n.sdkState,i=n.cacheContext,s=t.call(this,e)||this;return s._sdkState=r,s._cacheContext=i,mt[e]=s,s}return e(n,t),n.of=function(e){return mt[e]},Object.defineProperty(n.prototype,"collection",{get:function(){var e=this._cacheContext.nestdb;return e&&e.collection("UnsentMessage")},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"localCacheEnabled",{get:function(){return this._cacheContext.localCacheEnabled&&!!this.collection},enumerable:!1,configurable:!0}),n.prototype._serialize=function(e){if(e.messageId>0)throw y.invalidParameters;var t,n=g({},e.serialize());return e instanceof L?(e.messageParams&&(n.messageParams=fe(e.messageParams)),e.scheduledInfo&&e.scheduledInfo.scheduledMessageParams&&(n.scheduledInfo.scheduledMessageParams=(t=e.scheduledInfo.scheduledMessageParams,g(g({},fe(t)),{scheduledAt:t.scheduledAt})))):e instanceof x&&(e.messageParams&&(n.messageParams=_e(e.messageParams)),e.scheduledInfo&&e.scheduledInfo.scheduledMessageParams&&(n.scheduledInfo.scheduledMessageParams=function(e){return g(g({},_e(e)),{scheduledAt:e.scheduledAt})}(e.scheduledInfo.scheduledMessageParams))),n},n.prototype._deserialize=function(e){return e?(e=g(g({},e),{messageId:parseInt(e.messageId)}),P.of(this._iid).buildMessageFromSerializedData(e)):null},n.prototype._deserializeWithMessageCreateParams=function(e){return p(this,void 0,void 0,(function(){var t,n,r,i,s,o;return v(this,(function(a){switch(a.label){case 0:return t=P.of(this._iid),n=this._deserialize(e),e.messageParams?n instanceof L?(r=e.messageParams,n.messageParams=t.buildUserMessageCreateParamsFromSerializedData(r,n),[3,4]):[3,1]:[3,4];case 1:return n instanceof x?(r=e.messageParams).fileKey&&"string"==typeof r.fileKey&&ye(r.fileType)?(i=r,[4,this.collection.getBlob(r.fileKey)]):[3,3]:[3,4];case 2:i.file=a.sent(),a.label=3;case 3:n.messageParams=t.buildFileMessageCreateParamsFromSerializedData(r,n),a.label=4;case 4:return n.scheduledInfo&&e.scheduledInfo&&e.scheduledInfo.scheduledMessageParams?n instanceof L?(s=e.scheduledInfo.scheduledMessageParams,n.scheduledInfo.scheduledMessageParams=t.buildScheduledUserMessageCreateParamsFromSerializedData(s,n),[3,8]):[3,5]:[3,8];case 5:return n instanceof x?(s=e.scheduledInfo.scheduledMessageParams).fileKey&&"string"==typeof s.fileKey&&ye(s.fileType)?(o=s,[4,this.collection.getBlob(s.fileKey)]):[3,7]:[3,8];case 6:o.file=a.sent(),a.label=7;case 7:n.scheduledInfo.scheduledMessageParams=t.buildScheduledFileMessageCreateParamsFromSerializedData(s,n),a.label=8;case 8:return[2,n]}}))}))},n.prototype.get=function(e){return p(this,void 0,void 0,(function(){var t;return v(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]}}))}))},n.prototype.fetch=function(e){var t=e.channelUrl,n=void 0===t?null:t,r=e.filter,i=void 0===r?new lt:r,s=e.order,o=void 0===s?ut.CHANNEL_LATEST:s,a=e.sendingStatus,u=void 0===a?null:a,c=e.backward,l=void 0!==c&&c,h=e.parentMessageId,d=void 0===h?null:h;return p(this,void 0,void 0,(function(){var e,t,r,s,a=this;return v(this,(function(c){switch(c.label){case 0:return this.localCacheEnabled?(e=dt(o),t={"/where":function(e){return!!(o!==ut.NEWEST_CHILD_MESSAGE||d&&0!==e.parentMessageId&&e.parentMessageId===d)&&i.match(a._deserialize(e))}},n&&(t.channelUrl=n),u&&(t.sendingStatus=u),r={where:t,index:e,backward:l},[4,this.collection.query(r)]):[3,3];case 1:return[4,c.sent().fetch({})];case 2:return s=c.sent(),[2,Promise.all(s.map((function(e){return p(a,void 0,void 0,(function(){return v(this,(function(t){switch(t.label){case 0:return[4,this._deserializeWithMessageCreateParams(e)];case 1:return[2,t.sent()]}}))}))})))];case 3:return[2,[]]}}))}))},n.prototype.getAllChildMessages=function(e,t){return void 0===t&&(t=new lt),p(this,void 0,void 0,(function(){return v(this,(function(n){switch(n.label){case 0:return[4,this.fetch({filter:t,order:ut.NEWEST_CHILD_MESSAGE,channelUrl:e.channelUrl,backward:!1,parentMessageId:e.messageId})];case 1:return[2,n.sent()]}}))}))},n.prototype.upsert=function(e){return p(this,void 0,void 0,(function(){var t,n=this;return v(this,(function(r){switch(r.label){case 0:return this.localCacheEnabled?[4,this.saveBlobs(e)]:[3,3];case 1:return r.sent(),t=e.map((function(e){return n._serialize(e)})),[4,this.collection.upsertMany(t)];case 2:r.sent(),r.label=3;case 3:return[2]}}))}))},n.prototype.upsertChildMessages=function(e){return p(this,void 0,void 0,(function(){var t=this;return v(this,(function(n){switch(n.label){case 0:return this.localCacheEnabled?[4,Promise.all(e.map((function(e){return p(t,void 0,void 0,(function(){var t,n;return v(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]}}))}))},n.prototype.remove=function(e){return p(this,void 0,void 0,(function(){var t,n,r,i,s,o;return v(this,(function(a){switch(a.label){case 0:if(!this.localCacheEnabled)return[3,8];a.label=1;case 1:a.trys.push([1,6,7,8]),t=D(e),n=t.next(),a.label=2;case 2:return n.done?[3,5]:(r=n.value,[4,this.collection.remove(r)]);case 3:a.sent(),a.label=4;case 4:return n=t.next(),[3,2];case 5:return[3,8];case 6:return i=a.sent(),s={error:i},[3,8];case 7:try{n&&!n.done&&(o=t.return)&&o.call(t)}finally{if(s)throw s.error}return[7];case 8:return[2]}}))}))},n.prototype.removeMessagesOfChannel=function(e){return p(this,void 0,void 0,(function(){return v(this,(function(t){switch(t.label){case 0:return this.localCacheEnabled?[4,this.collection.removeIf({where:{channelUrl:e}})]:[3,2];case 1:t.sent(),t.label=2;case 2:return[2]}}))}))},n.prototype.clear=function(){return p(this,void 0,void 0,(function(){return v(this,(function(e){switch(e.label){case 0:return this.localCacheEnabled?[4,this.collection.clear()]:[3,2];case 1:e.sent(),e.label=2;case 2:return[2]}}))}))},n.prototype.saveBlobs=function(e){return p(this,void 0,void 0,(function(){var t=this;return v(this,(function(n){switch(n.label){case 0:return[4,Promise.all(e.map((function(e){return p(t,void 0,void 0,(function(){var t,n,r;return v(this,(function(i){switch(i.label){case 0:return e instanceof x?e.messageParams&&(t=e.messageParams).file&&be(t.file)?[4,this.collection.saveBlob(t.file,e.reqId)]:[3,2]:[3,4];case 1:r=i.sent(),t.fileKey=r,t.fileType=ge.BLOB,i.label=2;case 2:return e.scheduledInfo&&e.scheduledInfo.scheduledMessageParams&&((n=e.scheduledInfo.scheduledMessageParams).file&&be(n.file))?[4,this.collection.saveBlob(n.file,e.reqId)]:[3,4];case 3:r=i.sent(),n.fileKey=r,n.fileType=ge.BLOB,i.label=4;case 4:return[2]}}))}))})))];case 1:return n.sent(),[2]}}))}))},n}(R),gt={},bt=function(t){function n(e,n){var r=n.sdkState,i=n.cacheContext,s=n.unsentMessageCache,o=t.call(this,e)||this;return o._sdkState=r,o._cacheContext=i,o._unsentMessageCache=s,gt[e]=o,o}return e(n,t),n.of=function(e){return gt[e]},Object.defineProperty(n.prototype,"collection",{get:function(){var e=this._cacheContext.nestdb;return e?e.collection("Message"):null},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"localCacheEnabled",{get:function(){return this._cacheContext.localCacheEnabled&&!!this.collection},enumerable:!1,configurable:!0}),n.prototype._serialize=function(e){return g(g({},e.serialize()),{messageId:"".concat(e.messageId)})},n.prototype._deserialize=function(e){return e=g(g({},e),{messageId:parseInt(e.messageId)}),P.of(this._iid).buildMessageFromSerializedData(e)},n.prototype.get=function(e){return p(this,void 0,void 0,(function(){var t;return v(this,(function(n){switch(n.label){case 0:return this.localCacheEnabled?[4,this.collection.getByKey("".concat(e))]:[3,2];case 1:if(t=n.sent())return[2,this._deserialize(t)];n.label=2;case 2:return[2,null]}}))}))},n.prototype.fetch=function(e){var t=e.channelUrl,n=e.token,r=e.limit,i=void 0===r?100:r,s=e.filter,o=void 0===s?new lt:s,a=e.order,u=void 0===a?ut.CHANNEL_LATEST:a,c=e.backward,l=void 0!==c&&c,h=e.parentMessageId,d=void 0===h?null:h;return p(this,void 0,void 0,(function(){var e,r,s,a=this;return v(this,(function(c){switch(c.label){case 0:return this.localCacheEnabled?(e=dt(u),r={where:{channelUrl:t,"/where":function(e){if(n)switch(u){case ut.CHANNEL_LATEST:if(!l&&e.createdAt>n||l&&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]}}))}))},n.prototype.remove=function(e){return p(this,void 0,void 0,(function(){var t,n,r,i,s,o;return v(this,(function(a){switch(a.label){case 0:if(!this.localCacheEnabled)return[3,8];a.label=1;case 1:a.trys.push([1,6,7,8]),t=D(e),n=t.next(),a.label=2;case 2:return n.done?[3,5]:(r=n.value,[4,this.collection.remove("".concat(r))]);case 3:a.sent(),a.label=4;case 4:return n=t.next(),[3,2];case 5:return[3,8];case 6:return i=a.sent(),s={error:i},[3,8];case 7:try{n&&!n.done&&(o=t.return)&&o.call(t)}finally{if(s)throw s.error}return[7];case 8:return[2]}}))}))},n.prototype.removeMessagesOfChannel=function(e){return p(this,void 0,void 0,(function(){var t;return v(this,(function(n){switch(n.label){case 0:return this.localCacheEnabled?[4,this.collection.removeIf({where:{channelUrl:e},index:dt(ut.CHANNEL_LATEST)})]:[3,6];case 1:return n.sent(),[4,(t=this._cacheContext.preference).remove("sendbird:".concat(this._sdkState.userId,"@groupchannel/").concat(e,"/message/sync"))];case 2:return n.sent(),[4,t.remove("sendbird:".concat(this._sdkState.userId,"@groupchannel/").concat(e,"/message/sync.meta"))];case 3:return n.sent(),[4,t.remove("sendbird:".concat(this._sdkState.userId,"@groupchannel/").concat(e,"/message/changelogs"))];case 4:return n.sent(),[4,t.remove("sendbird:".concat(this._sdkState.userId,"@groupchannel/").concat(e,"/message/changelogs.meta"))];case 5:n.sent(),n.label=6;case 6:return[2]}}))}))},n.prototype.removeUnderOffset=function(e,t){return p(this,void 0,void 0,(function(){return v(this,(function(n){switch(n.label){case 0:return this.localCacheEnabled?[4,this.collection.removeIf({where:{channelUrl:e,createdAt:{"<":t}},index:dt(ut.CHANNEL_LATEST)})]:[3,2];case 1:n.sent(),n.label=2;case 2:return[2]}}))}))},n.prototype.clear=function(){return p(this,void 0,void 0,(function(){return v(this,(function(e){switch(e.label){case 0:return this.localCacheEnabled?[4,this.collection.clear()]:[3,2];case 1:e.sent(),e.label=2;case 2:return[2]}}))}))},n.prototype.countBetween=function(e,t,n){return p(this,void 0,void 0,(function(){var r,i=this;return v(this,(function(s){switch(s.label){case 0:return this.localCacheEnabled?(r=dt(ut.CHANNEL_LATEST),[4,this.collection.query({where:{channelUrl:e,"/where":function(e){var r=i._deserialize(e);return n.includes(r.createdAt)&&t.match(r)}},index:r}).count()]):[3,2];case 1:return[2,s.sent()];case 2:return[2,0]}}))}))},n.prototype.saveBlobs=function(e){return p(this,void 0,void 0,(function(){var t=this;return v(this,(function(n){switch(n.label){case 0:return[4,Promise.all(e.map((function(e){return p(t,void 0,void 0,(function(){var t,n;return v(this,(function(r){switch(r.label){case 0:return e instanceof x&&e.messageParams&&((t=e.messageParams).file&&be(t.file))?[4,this.collection.saveBlob(t.file,e.reqId)]:[3,2];case 1:n=r.sent(),t.fileKey=n,r.label=2;case 2:return[2]}}))}))})))];case 1:return n.sent(),[2]}}))}))},n}(R),It=function(t){function n(){var e=t.call(this)||this;return e._pauseDelayTimer=null,e._currentState="visible",e._toggleState=e._toggleState.bind(e),e}return e(n,t),Object.defineProperty(n.prototype,"isAvailable",{get:function(){return"undefined"!=typeof window&&!!window.addEventListener&&!!window.removeEventListener},enumerable:!1,configurable:!0}),n.prototype._toggleState=function(){var e=this;"hidden"!==document.visibilityState?"hidden"===this._currentState&&(this._pauseDelayTimer&&(clearTimeout(this._pauseDelayTimer),this._pauseDelayTimer=null),this.dispatch("resume")):"hidden"!==this._currentState&&(this._pauseDelayTimer=setTimeout((function(){e._pauseDelayTimer=null,e.dispatch("pause")}),3e4)),this._currentState=document.visibilityState},n.prototype.start=function(){this.isAvailable&&window.addEventListener("visibilitychange",this._toggleState,{capture:!0})},n.prototype.stop=function(){this.isAvailable&&window.removeEventListener("visibilitychange",this._toggleState,{capture:!0})},n}(M),Et=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 p(this,void 0,void 0,(function(){return v(this,(function(e){return this.isAvailableOnWeb?[2,navigator.onLine]:[2,new Promise((function(e){fetch("https://www.google.com",{method:t.GET,mode:"no-cors"}).then((function(){return e(!0)})).catch((function(){return e(!1)}))}))]}))}))},e}(),wt=function(t){function n(e){var n=e.message,r=t.call(this)||this;return r.message=n,r}return e(n,t),n}(U),kt={},Nt=function(){function e(e,t){var n=t.localCacheEnabled,r=t.dispatcher,i=t.sdkState,s=t.logger,o=this;kt[e]=this,this._iid=e,kt[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 B)switch(e.stateType){case K.CONNECTED:o._isProcessingAutoResend||o.processAutoResendRegisteredPendingMessages().then((function(){return o._processNextAutoResend()}));break;case K.DISCONNECTED:o._isProcessingAutoResend=!1}}))}return e.of=function(e){return kt[e]},e.prototype.processNonAutoResendRegisteredPendingMessages=function(){return p(this,void 0,void 0,(function(){var e,t,n,r,i,s;return v(this,(function(o){switch(o.label){case 0:return[4,this._fetchAllCachedPendingMessages()];case 1:e=o.sent();try{for(t=D(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=q.FAILED,r.errorCode=j.ACK_TIMEOUT,this._dispatcher.dispatch(new H({messages:[r],source:_.LOCAL_MESSAGE_FAILED})))}catch(e){i={error:e}}finally{try{n&&!n.done&&(s=t.return)&&s.call(t)}finally{if(i)throw i.error}}return[2]}}))}))},e.prototype.processAutoResendRegisteredPendingMessages=function(){return p(this,void 0,void 0,(function(){var e,t,n,r,i,s,o,a;return v(this,(function(u){switch(u.label){case 0:return[4,this._fetchAllCachedPendingMessages()];case 1:e=u.sent();try{for(t=D(e),n=t.next();!n.done;n=t.next())(r=n.value).errorCode&&F(r.errorCode)&&(i=(new Date).getTime(),s=r.createdAt+2592e5,i<=s?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(s).toLocaleString()),r.sendingStatus=q.FAILED,this._dispatcher.dispatch(new H({messages:[r],source:_.LOCAL_MESSAGE_FAILED}))))}catch(e){o={error:e}}finally{try{n&&!n.done&&(a=t.return)&&a.call(t)}finally{if(o)throw o.error}}return[2]}}))}))},e.prototype.completeCurrentAndProcessNextAutoResend=function(e){if(this._localCacheEnabled&&(e.sendingStatus===q.SUCCEEDED||e.sendingStatus===q.FAILED&&!F(e.errorCode))){var t=this.indexOf(e);t>=0&&this._autoResendQueue.splice(t,1),0===t&&this._processNextAutoResend()}},e.prototype._fetchAllCachedPendingMessages=function(){return p(this,void 0,void 0,(function(){var e,t;return v(this,(function(n){switch(n.label){case 0:return(e=yt.of(this._iid))?[4,e.fetch({sendingStatus:q.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 p(this,void 0,void 0,(function(){var e;return v(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 wt({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"}(ht||(ht={}));var St=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 w(e,r),blockee:new w(e,i)}},e.getDataAsFriendDiscoveredEvent=function(e,t){var n=t.data.friend_discoveries;return{friendDiscoveries:Array.isArray(n)?n.map((function(t){return new w(e,t)})):[]}},e}(),Tt=function(t){function n(e,n){var r=n.userId,i=t.call(this)||this;return i._iid=e,i.userId=r,i}return e(n,t),n}(U),Ot=function(t){function n(e,n,r){var i=t.call(this,e,"USEV",r)||this;return i.event=new St(r),i}return e(n,t),n}(z),Ct=function(n){function r(e){var r=e.userId,i=e.nickname,s=void 0===i?null:i,o=e.profileUrl,a=void 0===o?null:o,c=e.profileImage,l=void 0===c?null:c,h=e.preferredLanguages,d=void 0===h?null:h,f=n.call(this)||this;return f.method=t.PUT,f.path="".concat(V,"/").concat(encodeURIComponent(r)),f.params=u({nickname:s,profile_url:a,profile_file:l,preferred_languages:d}),f}return e(r,n),r}(r),At=function(t){function n(e,n){var r=t.call(this,e,n)||this;return r.user=null,r.user=new w(e,g({},n)),r}return e(n,t),n}(s),Lt=function(n){function r(e){var r=e.userId,i=e.token,s=n.call(this)||this;return s.method=t.POST,s.path="".concat(V,"/").concat(encodeURIComponent(r),"/push/apns"),s.params={apns_device_token:i,always_push:!0},s}return e(r,n),r}(r);!function(t){function n(e,n){var r=t.call(this,e,n)||this;return r.token=n.token,r.type=n.type?we[n.type.toLowerCase()]:we.UNKNOWN,r.user=new w(e,n.user),r}e(n,t)}(s);var xt=function(n){function r(e){var r=e.userId,i=e.token,s=n.call(this)||this;return s.method=t.POST,s.path="".concat(V,"/").concat(encodeURIComponent(r),"/push/gcm"),s.params={gcm_reg_token:i,always_push:!0},s}return e(r,n),r}(r);!function(t){function n(e,n){var r=t.call(this,e,n)||this;return r.token=n.token,r.type=n.type?we[n.type.toLowerCase()]:we.UNKNOWN,r.user=new w(e,n.user),r}e(n,t)}(s);var Pt=function(n){function r(e){var r=e.userId,i=e.token,s=n.call(this)||this;return s.method=t.DELETE,s.path="".concat(V,"/").concat(encodeURIComponent(r),"/push/apns/").concat(encodeURIComponent(i)),s}return e(r,n),r}(r);!function(t){function n(e,n){var r=t.call(this,e,n)||this;return r.token=n.token,r.user=new w(e,n.user),r}e(n,t)}(s);var Rt=function(n){function r(e){var r=e.userId,i=e.token,s=n.call(this)||this;return s.method=t.DELETE,s.path="".concat(V,"/").concat(encodeURIComponent(r),"/push/gcm/").concat(encodeURIComponent(i)),s}return e(r,n),r}(r);!function(t){function n(e,n){var r=t.call(this,e,n)||this;return r.token=n.token,r.user=new w(e,n.user),r}e(n,t)}(s);var Dt=function(n){function r(e){var r=e.userId,i=n.call(this)||this;return i.method=t.DELETE,i.path="".concat(V,"/").concat(encodeURIComponent(r),"/push/apns"),i}return e(r,n),r}(r);!function(t){function n(e,n){var r=t.call(this,e,n)||this;return r.type=n.type?we[n.type.toLowerCase()]:we.UNKNOWN,r.user=new w(e,n.user),r}e(n,t)}(s);var Mt=function(n){function r(e){var r=e.userId,i=n.call(this)||this;return i.method=t.DELETE,i.path="".concat(V,"/").concat(encodeURIComponent(r),"/push/gcm"),i}return e(r,n),r}(r);!function(t){function n(e,n){var r=t.call(this,e,n)||this;return r.type=n.type?we[n.type.toLowerCase()]:we.UNKNOWN,r.user=new w(e,n.user),r}e(n,t)}(s);var Ut=function(n){function r(e){var r=e.userId,i=e.type,s=e.token,o=e.ts,a=n.call(this)||this;return a.method=t.GET,a.path="".concat(V,"/").concat(encodeURIComponent(r),"/push/").concat(encodeURIComponent(i),"/device_tokens"),a.params={created_ts:o,token:s},a}return e(r,n),r}(r),qt=function(t){function n(e,n){var r=t.call(this,e,n)||this;return r.pushTokens={type:n.type?we[n.type.toLowerCase()]:we.UNKNOWN,deviceTokens:n.device_tokens,hasMore:n.has_more,token:n.token},r}return e(n,t),n}(s),Ft=function(n){function r(e){var r=e.userId,i=n.call(this)||this;return i.method=t.GET,i.path="".concat(V,"/").concat(encodeURIComponent(r),"/channel_invitation_preference"),i}return e(r,n),r}(r),Bt=function(t){function n(e,n){var r=t.call(this,e,n)||this;return r.autoAccept=n.auto_accept,r}return e(n,t),n}(s),Kt=function(n){function r(e){var r=e.userId,i=e.willAutoAccept,s=n.call(this)||this;return s.method=t.PUT,s.path="".concat(V,"/").concat(encodeURIComponent(r),"/channel_invitation_preference"),s.params={auto_accept:i},s}return e(r,n),r}(r),jt=function(t){function n(e,n){var r=t.call(this,e,n)||this;return r.autoAccept=n.auto_accept,r}return e(n,t),n}(s),Ht=function(n){function r(e){var r=e.userId,i=n.call(this)||this;return i.method=t.GET,i.path="".concat(V,"/").concat(encodeURIComponent(r),"/push_preference"),i}return e(r,n),r}(r),zt=function(t){function n(e,n){var r=t.call(this,e,n)||this;return r.preference={doNotDisturbOn:n.do_not_disturb,startHour:n.start_hour,startMin:n.start_min,endHour:n.end_hour,endMin:n.end_min,timezone:n.timezone},r}return e(n,t),n}(s),Vt=function(n){function r(e){var r=e.userId,i=e.doNotDisturbOn,s=e.startHour,o=e.startMin,a=e.endHour,u=e.endMin,c=e.timezone,l=n.call(this)||this;return l.method=t.PUT,l.path="".concat(V,"/").concat(encodeURIComponent(r),"/push_preference"),l.params={do_not_disturb:i,start_hour:s,start_min:o,end_hour:a,end_min:u,timezone:c},l}return e(r,n),r}(r),Qt=function(t){function n(e,n){var r=t.call(this,e,n)||this;return r.preference={doNotDisturbOn:n.do_not_disturb,startHour:n.start_hour,startMin:n.start_min,endHour:n.end_hour,endMin:n.end_min,timezone:n.timezone},r}return e(n,t),n}(s),Gt=function(n){function r(e){var r=e.userId,i=n.call(this)||this;return i.method=t.GET,i.path="".concat(V,"/").concat(encodeURIComponent(r),"/push_preference"),i}return e(r,n),r}(r),Wt=function(t){function n(e,n){var r=t.call(this,e,n)||this;return r.snoozePeriod={isSnoozeOn:n.snooze_enabled},"number"==typeof n.snooze_start_ts&&(r.snoozePeriod.startTs=n.snooze_start_ts),"number"==typeof n.snooze_end_ts&&(r.snoozePeriod.endTs=n.snooze_end_ts),r}return e(n,t),n}(s),Yt=function(n){function r(e){var r=e.userId,i=e.snoozeOn,s=e.startTs,o=e.endTs,a=n.call(this)||this;return a.method=t.PUT,a.path="".concat(V,"/").concat(encodeURIComponent(r),"/push_preference"),a.params={snooze_enabled:i,snooze_start_ts:s,snooze_end_ts:o},a}return e(r,n),r}(r),Jt=function(t){function n(e,n){var r=t.call(this,e,n)||this;return r.snoozePeriod={isSnoozeOn:n.snooze_enabled},"number"==typeof n.snooze_start_ts&&(r.snoozePeriod.startTs=n.snooze_start_ts),"number"==typeof n.snooze_end_ts&&(r.snoozePeriod.endTs=n.snooze_end_ts),r}return e(n,t),n}(s),Xt=function(n){function r(e){var r=e.userId,i=e.blockedUserId,s=n.call(this)||this;return s.method=t.POST,s.path="".concat(V,"/").concat(encodeURIComponent(r),"/block"),s.params={target_id:i},s}return e(r,n),r}(r);!function(t){function n(e,n){var r=t.call(this,e,n)||this;return r.user=new w(e,n),r}e(n,t)}(s);var Zt=function(n){function r(e){var r=e.userId,i=e.unblockedUserId,s=n.call(this)||this;return s.method=t.DELETE,s.path="".concat(V,"/").concat(encodeURIComponent(r),"/block/").concat(encodeURIComponent(i)),s}return e(r,n),r}(r);!function(t){function n(){return null!==t&&t.apply(this,arguments)||this}e(n,t)}(s);var $t=function(n){function r(e){var r=e.userId,i=n.call(this)||this;return i.method=t.GET,i.path="".concat(V,"/").concat(encodeURIComponent(r),"/push_preference"),i}return e(r,n),r}(r),en=function(t){function n(e,n){var r=t.call(this,e,n)||this;return r.pushTriggerOption=n.push_trigger_option,r}return e(n,t),n}(s),tn=function(n){function r(e){var r=e.userId,i=e.pushTriggerOption,s=n.call(this)||this;return s.method=t.PUT,s.path="".concat(V,"/").concat(encodeURIComponent(r),"/push_preference"),s.params={push_trigger_option:i},s}return e(r,n),r}(r),nn=function(t){function n(e,n){var r=t.call(this,e,n)||this;return r.pushTriggerOption=n.push_trigger_option,r}return e(n,t),n}(s),rn=function(n){function r(e){var r=e.userId,i=n.call(this)||this;return i.method=t.GET,i.path="".concat(V,"/").concat(encodeURIComponent(r),"/push/template"),i}return e(r,n),r}(r),sn=function(t){function n(e,n){var r=t.call(this,e,n)||this;return r.name=n.name,r}return e(n,t),n}(s),on=function(n){function r(e){var r=e.userId,i=e.templateName,s=n.call(this)||this;return s.method=t.PUT,s.path="".concat(V,"/").concat(encodeURIComponent(r),"/push/template"),s.params={name:i},s}return e(r,n),r}(r),an=function(t){function n(e,n){var r=t.call(this,e,n)||this;return r.name=n.name,r}return e(n,t),n}(s),un=function(n){function r(e){var r=e.userId,i=e.token,s=n.call(this)||this;return s.method=t.GET,s.path="".concat(V,"/").concat(encodeURIComponent(r),"/friends/changelogs"),s.params={token:i},s}return e(r,n),r}(r),cn=function(t){function n(e,n){var r=t.call(this,e,n)||this;return r.changelogs={addedUsers:n.added.map((function(t){return new w(e,t)})),updatedUsers:n.updated.map((function(t){return new w(e,t)})),deletedUserIds:n.deleted,hasMore:n.has_more,token:n.next},r}return e(n,t),n}(s),ln=function(n){function r(e){var r=e.userId,i=e.discoveries,s=n.call(this)||this;return s.method=t.PUT,s.path="".concat(V,"/").concat(encodeURIComponent(r),"/friend_discoveries"),s.params={friend_discoveries:i.map((function(e){return{friend_discovery_key:e.friendDiscoveryKey,friend_name:e.friendName}}))},s}return e(r,n),r}(r),hn=function(t){function n(e,n){var r=t.call(this,e,n)||this;return r.friendDiscoveryRequestId=n.friend_discovery_request_id,r}return e(n,t),n}(s),dn=function(n){function r(e){var r=e.userId,i=e.discoveryKeys,s=n.call(this)||this;return s.method=t.DELETE,s.path="".concat(V,"/").concat(encodeURIComponent(r),"/friend_discoveries"),s.params={friend_discovery_keys:i},s}return e(r,n),r}(r);!function(t){function n(){return null!==t&&t.apply(this,arguments)||this}e(n,t)}(s);var fn=function(n){function r(e){var r=e.userId,i=e.userIds,s=n.call(this)||this;return s.method=t.POST,s.path="".concat(V,"/").concat(encodeURIComponent(r),"/friends"),s.params={user_ids:i},s}return e(r,n),r}(r),pn=function(t){function n(e,n){var r=t.call(this,e,n)||this;return r.users=n.users.map((function(t){return new w(e,t)})),r}return e(n,t),n}(s),vn=function(n){function r(e){var r=e.userId,i=e.userIds,s=n.call(this)||this;return s.method=t.DELETE,s.path="".concat(V,"/").concat(encodeURIComponent(r),"/friends"),s.params={user_ids:i},s}return e(r,n),r}(r);!function(t){function n(){return null!==t&&t.apply(this,arguments)||this}e(n,t)}(s);var _n=function(n){function r(e){var r=e.userId,i=n.call(this)||this;return i.method=t.GET,i.path="".concat(V,"/").concat(r,"/allow_friend_discovery"),i.params={},i}return e(r,n),r}(r),mn=function(t){function n(e,n){var r=t.call(this,e,n)||this;return r.allowFriendDiscovery=n.allow_friend_discovery,r}return e(n,t),n}(s),yn=function(n){function r(e){var r=e.userId,i=e.allowFriendDiscovery,s=n.call(this)||this;return s.method=t.PUT,s.path="".concat(V,"/").concat(r,"/allow_friend_discovery"),s.params={allow_friend_discovery:i},s}return e(r,n),r}(r);!function(t){function n(){return null!==t&&t.apply(this,arguments)||this}e(n,t)}(s);var gn,bn=function(e){this.key=null,this.url=null,this.key=e.key,this.url=e.url},In=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 bn(e)})):[]},En=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 In(e)})):[]},wn=function(n){function r(){var e=n.call(this)||this;return e.method=t.GET,e.path=Q,e}return e(r,n),r}(r),kn=function(t){function n(e,n){var r=t.call(this,e,n)||this;return r.emojiContainer=new En(n),r}return e(n,t),n}(s),Nn=function(n){function r(e){var r=e.categoryId,i=n.call(this)||this;return i.method=t.GET,i.path="".concat(Q,"/").concat(r),i}return e(r,n),r}(r),Sn=function(t){function n(e,n){var r=t.call(this,e,n)||this;return r.emojiCategory=new In(n),r}return e(n,t),n}(s),Tn=function(n){function r(e){var r=e.key,i=n.call(this)||this;return i.method=t.GET,i.path="".concat(G,"/").concat(r),i}return e(r,n),r}(r),On=function(t){function n(e,n){var r=t.call(this,e,n)||this;return r.emoji=new bn(n),r}return e(n,t),n}(s),Cn=function(n){function r(e){var r=e.limit,i=e.token,s=e.userIdsFilter,o=e.metaDataKeyFilter,a=e.metaDataValuesFilter,c=e.nicknameStartsWithFilter,l=n.call(this)||this;return l.method=t.GET,l.path=V,l.params=u({limit:r,token:i,user_ids:s,metadatakey:o,metadatavalues_in:a,nickname_startswith:c}),l}return e(r,n),r}(r),An=function(t){function n(e,n){var r=t.call(this,e,n)||this;return r.users=n.users.map((function(t){return new w(e,t)})),r.next=n.next,r}return e(n,t),n}(s),Ln=function(t){function n(e,n){var r,i,s,o=this;return(o=t.call(this,e,n)||this).userIdsFilter=null,o.metaDataKeyFilter=null,o.metaDataValuesFilter=null,o.nicknameStartsWithFilter=null,o.userIdsFilter=null!==(r=n.userIdsFilter)&&void 0!==r?r:null,o.metaDataKeyFilter=null!==(i=n.metaDataKeyFilter)&&void 0!==i?i:null,o.metaDataValuesFilter=null!==(s=n.metaDataValuesFilter)&&void 0!==s?s:null,o.nicknameStartsWithFilter=n.nicknameStartsWithFilter||null,o}return e(n,t),n.prototype._validate=function(){return t.prototype._validate.call(this)&&W("string",this.userIdsFilter,!0)&&c("string",this.metaDataKeyFilter,!0)&&W("string",this.metaDataValuesFilter,!0)&&c("string",this.metaDataKeyFilter,!0)},n.prototype.next=function(){return p(this,void 0,void 0,(function(){var e,t,n,r,i,s;return v(this,(function(o){switch(o.label){case 0:return this._validate()?this._isLoading?[3,3]:this._hasNext?(this._isLoading=!0,e=E.of(this._iid).requestQueue,t=new Cn(g(g({},this),{token:this._token})),[4,e.send(t)]):[3,2]:[3,5];case 1:return n=o.sent(),r=n.as(An),i=r.users,s=r.next,this._token=s,this._hasNext=!!s,this._isLoading=!1,[2,i];case 2:return[2,[]];case 3:throw y.queryInProgress;case 4:return[3,6];case 5:throw y.invalidParameters;case 6:return[2]}}))}))},n}(Y),xn=function(n){function r(e){var r=e.userId,i=e.limit,s=e.token,o=e.userIdsFilter,a=n.call(this)||this;return a.method=t.GET,a.path="".concat(V,"/").concat(r,"/block"),a.params=u({limit:i,token:s,user_ids:o}),a}return e(r,n),r}(r),Pn=function(t){function n(e,n){var r=t.call(this,e,n)||this;return r.users=n.users.map((function(t){return new w(e,t)})),r.next=n.next,r}return e(n,t),n}(s),Rn=function(t){function n(e,n){var r,i=this;return(i=t.call(this,e,n)||this).userIdsFilter=null,i.userIdsFilter=null!==(r=n.userIdsFilter)&&void 0!==r?r:null,i}return e(n,t),n.prototype._validate=function(){return t.prototype._validate.call(this)&&W("string",this.userIdsFilter,!0)},n.prototype.next=function(){return p(this,void 0,void 0,(function(){var e,t,n,r,i,s,o,a;return v(this,(function(u){switch(u.label){case 0:return this._validate()?this._isLoading?[3,3]:this._hasNext?(this._isLoading=!0,e=E.of(this._iid),t=e.sdkState,n=e.requestQueue,r=new xn(g(g({},this),{userId:t.userId,token:this._token})),[4,n.send(r)]):[3,2]:[3,5];case 1:return i=u.sent(),s=i.as(Pn),o=s.users,a=s.next,this._token=a,this._hasNext=!!a,this._isLoading=!1,[2,o];case 2:return[2,[]];case 3:throw y.queryInProgress;case 4:return[3,6];case 5:throw y.invalidParameters;case 6:return[2]}}))}))},n}(Y),Dn=function(n){function r(e){var r=e.userId,i=e.limit,s=e.token,o=n.call(this)||this;return o.method=t.GET,o.path="".concat(V,"/").concat(encodeURIComponent(r),"/friends"),o.params={limit:i,token:s},o}return e(r,n),r}(r),Mn=function(t){function n(e,n){var r=t.call(this,e,n)||this;return r.hasMore=n.has_more,r.users=n.users.map((function(t){return new w(e,t)})),r.next=n.next,r}return e(n,t),n}(s),Un=function(t){function n(){return null!==t&&t.apply(this,arguments)||this}return e(n,t),n.prototype._validate=function(){return t.prototype._validate.call(this)},n.prototype.next=function(){return p(this,void 0,void 0,(function(){var e,t,n,r,i,s,o,a,u;return v(this,(function(c){switch(c.label){case 0:return this._validate()?this._isLoading?[3,3]:this._hasNext?(this._isLoading=!0,e=E.of(this._iid),t=e.sdkState,n=e.requestQueue,r=new Dn(g(g({},this),{userId:t.userId,token:this._token})),[4,n.send(r)]):[3,2]:[3,5];case 1:return i=c.sent(),s=i.as(Mn),o=s.users,a=s.hasMore,u=s.next,this._token=u,this._hasNext=a,this._isLoading=!1,[2,o];case 2:return[2,[]];case 3:throw y.queryInProgress;case 4:return[3,6];case 5:throw y.invalidParameters;case 6:return[2]}}))}))},n}(Y),qn={},Fn=function(){function e(e){var t=e.dbname,n=e.itemSizeLimit,r=void 0===n?1048576:n,i=e.cacheLimit,s=void 0===i?256:i,o=e.blockHashBase,a=void 0===o?2:o,u=e.blockHashMultiplier,c=void 0===u?10:u,l=e.blockHashConstant,h=void 0===l?11:l,d=e.transactionApplyDelay,f=void 0===d?200:d,p=e.disableLogger,v=void 0!==p&&p;return qn[t]||(this.itemSizeLimit=r,this.cacheLimit=s,this.blockHashBase=a,this.blockHashMultiplier=c,this.blockHashConstant=h,this.transactionApplyDelay=f,this.disableLogger=v,qn[t]=this),qn[t]}return e.get=function(e){return qn[e]},e}();!function(e){e[e.UNKNOWN_ERROR=6e7]="UNKNOWN_ERROR",e[e.STORE_NOT_DEFINED=61001e3]="STORE_NOT_DEFINED",e[e.STORE_NOT_AVAILABLE=61001001]="STORE_NOT_AVAILABLE",e[e.STORE_NOT_AVAILABLE_IN_PRIVATE_BROWSING=61001002]="STORE_NOT_AVAILABLE_IN_PRIVATE_BROWSING",e[e.STORE_IS_FULL=61001003]="STORE_IS_FULL",e[e.STORE_INVALID_KEY_TYPE=61002e3]="STORE_INVALID_KEY_TYPE",e[e.STORE_BROKEN_INTEGRITY=61002001]="STORE_BROKEN_INTEGRITY",e[e.STORE_BROKEN_BLOB=61002002]="STORE_BROKEN_BLOB",e[e.STORE_ENCRYPTION_INVALID=61002003]="STORE_ENCRYPTION_INVALID",e[e.STORE_ITEM_SIZE_LIMIT_EXCEEDED=61017e3]="STORE_ITEM_SIZE_LIMIT_EXCEEDED",e[e.STORE_READ_FAILED=61017001]="STORE_READ_FAILED",e[e.STORE_WRITE_FAILED=61017002]="STORE_WRITE_FAILED",e[e.DATABASE_SCHEMA_NOT_ON_UPGRADE=62002e3]="DATABASE_SCHEMA_NOT_ON_UPGRADE",e[e.COLLECTION_NOT_READY=63001e3]="COLLECTION_NOT_READY",e[e.COLLECTION_KEY_NOT_MATCH=63002e3]="COLLECTION_KEY_NOT_MATCH",e[e.COLLECTION_QUERY_NOT_VALID=63002001]="COLLECTION_QUERY_NOT_VALID",e[e.COLLECTION_KEY_NOT_FOUND=63004e3]="COLLECTION_KEY_NOT_FOUND",e[e.COLLECTION_KEY_NOT_GIVEN=63004001]="COLLECTION_KEY_NOT_GIVEN",e[e.COLLECTION_INSERT_DUPLICATE=63009e3]="COLLECTION_INSERT_DUPLICATE",e[e.COLLECTION_WRITE_FAILED=63017e3]="COLLECTION_WRITE_FAILED",e[e.COLLECTION_ITEM_SIZE_LIMIT_EXCEEDED=63017001]="COLLECTION_ITEM_SIZE_LIMIT_EXCEEDED",e[e.INDEX_TABLE_IS_REQUIRED=65001e3]="INDEX_TABLE_IS_REQUIRED",e[e.INDEX_TYPE_NOT_MATCH=65002e3]="INDEX_TYPE_NOT_MATCH",e[e.COMPARE_TYPE_NOT_MATCH=69002001]="COMPARE_TYPE_NOT_MATCH",e[e.CIRCULAR_REFERENCE_FOUND=69002002]="CIRCULAR_REFERENCE_FOUND"}(gn||(gn={}));var Bn,Kn=function(t){function n(e){var r=e.code,i=void 0===r?gn.UNKNOWN_ERROR:r,s=e.message,o=void 0===s?"Unknown error occurred.":s,a=t.call(this,o)||this;return a.code=i,Object.setPrototypeOf(a,n.prototype),a}return e(n,t),Object.defineProperty(n,"storeNotDefined",{get:function(){return new n({code:gn.STORE_NOT_DEFINED,message:"Store is not defined. Specify the store on NestDB()"})},enumerable:!1,configurable:!0}),Object.defineProperty(n,"storeNotAvailable",{get:function(){return new n({code:gn.STORE_NOT_AVAILABLE,message:"Store is not available. Check your environment settings."})},enumerable:!1,configurable:!0}),Object.defineProperty(n,"storeNotAvailableInPrivateBrowsing",{get:function(){return new n({code:gn.STORE_NOT_AVAILABLE_IN_PRIVATE_BROWSING,message:"Store is not available because it is in private browsing."})},enumerable:!1,configurable:!0}),Object.defineProperty(n,"storeIsFull",{get:function(){return new n({code:gn.STORE_IS_FULL,message:"Store is full."})},enumerable:!1,configurable:!0}),Object.defineProperty(n,"storeKeyTypeIsInvalid",{get:function(){return new n({code:gn.STORE_INVALID_KEY_TYPE,message:"Store key should be string type."})},enumerable:!1,configurable:!0}),Object.defineProperty(n,"storeBrokenIntegrity",{get:function(){return new n({code:gn.STORE_BROKEN_INTEGRITY,message:"Data should be in a store but it does not. Integrity is broken."})},enumerable:!1,configurable:!0}),Object.defineProperty(n,"storeBrokenBlob",{get:function(){return new n({code:gn.STORE_BROKEN_BLOB,message:"Data should be in a store but it does not. Blob data is broken."})},enumerable:!1,configurable:!0}),Object.defineProperty(n,"storeEncryptionInvalid",{get:function(){return new n({code:gn.STORE_ENCRYPTION_INVALID,message:"Encryption algorithm has changed. All the store should reset."})},enumerable:!1,configurable:!0}),Object.defineProperty(n,"storeItemSizeExceeded",{get:function(){return new n({code:gn.STORE_ITEM_SIZE_LIMIT_EXCEEDED,message:"The size of the item exceeds the limit that the store allows."})},enumerable:!1,configurable:!0}),Object.defineProperty(n,"storeReadFailed",{get:function(){return new n({code:gn.STORE_READ_FAILED,message:"Failed to read from store."})},enumerable:!1,configurable:!0}),Object.defineProperty(n,"storeWriteFailed",{get:function(){return new n({code:gn.STORE_WRITE_FAILED,message:"Failed to write to store."})},enumerable:!1,configurable:!0}),Object.defineProperty(n,"databaseSchemaNotOnUpgrade",{get:function(){return new n({code:gn.DATABASE_SCHEMA_NOT_ON_UPGRADE,message:"Committing schema is not allowed when upgrade is not running."})},enumerable:!1,configurable:!0}),Object.defineProperty(n,"collectionNotReady",{get:function(){return new n({code:gn.COLLECTION_NOT_READY,message:"Collection is not ready due to an error during initialization."})},enumerable:!1,configurable:!0}),Object.defineProperty(n,"collectionKeyNotMatch",{get:function(){return new n({code:gn.COLLECTION_KEY_NOT_MATCH,message:"keyName of collection could not change."})},enumerable:!1,configurable:!0}),Object.defineProperty(n,"collectionQueryNotValid",{get:function(){return new n({code:gn.COLLECTION_QUERY_NOT_VALID,message:"Query parameter is not a valid format."})},enumerable:!1,configurable:!0}),Object.defineProperty(n,"collectionInsertDuplicate",{get:function(){return new n({code:gn.COLLECTION_INSERT_DUPLICATE,message:"The key already exists."})},enumerable:!1,configurable:!0}),Object.defineProperty(n,"collectionKeyNotFound",{get:function(){return new n({code:gn.COLLECTION_KEY_NOT_FOUND,message:"The key is not found."})},enumerable:!1,configurable:!0}),Object.defineProperty(n,"collectionKeyNotGiven",{get:function(){return new n({code:gn.COLLECTION_KEY_NOT_GIVEN,message:"The item should contain [keyName] property."})},enumerable:!1,configurable:!0}),Object.defineProperty(n,"collectionWriteFailed",{get:function(){return new n({code:gn.COLLECTION_WRITE_FAILED,message:"Failed to write an item."})},enumerable:!1,configurable:!0}),Object.defineProperty(n,"collectionItemSizeExceeded",{get:function(){return new n({code:gn.COLLECTION_ITEM_SIZE_LIMIT_EXCEEDED,message:"The size of the item exceeds the limit that a collection allows."})},enumerable:!1,configurable:!0}),Object.defineProperty(n,"indexTableIsRequired",{get:function(){return new n({code:gn.INDEX_TABLE_IS_REQUIRED,message:"Index table is required."})},enumerable:!1,configurable:!0}),Object.defineProperty(n,"indexTypesNotMatch",{get:function(){return new n({code:gn.INDEX_TYPE_NOT_MATCH,message:"Indexed column should have primitive type."})},enumerable:!1,configurable:!0}),Object.defineProperty(n,"compareTypesNotMatch",{get:function(){return new n({code:gn.COMPARE_TYPE_NOT_MATCH,message:"Values to compare have different types."})},enumerable:!1,configurable:!0}),Object.defineProperty(n,"circularReferenceFound",{get:function(){return new n({code:gn.CIRCULAR_REFERENCE_FOUND,message:"Cannot handle circular referenced object."})},enumerable:!1,configurable:!0}),n}(Error);!function(e){e.INIT="init",e.READY="ready",e.CLOSED="closed"}(Bn||(Bn={}));var jn,Hn=function(e,t){if(void 0===t&&(t=new WeakMap),"object"==typeof e&&null!==e){if(t.has(e))throw Kn.circularReferenceFound;t.set(e,!0);var n=null;if(Array.isArray(e))n=e.map((function(e){return Hn(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]=Hn(e[r],t);return t.delete(e),n}return e},zn=function(e,t){if(null==t)return 1;if(null==e)return-1;if(typeof e!=typeof t)throw Kn.compareTypesNotMatch;var n=0;switch(typeof e){case"boolean":case"number":n=e-t;break;case"string":n=e.localeCompare(t)}return n},Vn=function(e,t){for(var n=0,r=0;r>>0)%t},Qn=function(e){return new Promise((function(t){setTimeout((function(){return t()}),e)}))},Gn=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!Gn(e,t)})))return!1}else if(["/or","||"].includes(n)){if(e[n].every((function(e){return!Gn(e,t)})))return!1}else if("/where"===n){if(!(0,e[n])(t))return!1}else{var r=n;if("object"==typeof e[r]){var i=e[r];for(var s in i)switch(s){case"/eq":case"=":if((o=t[r])!==(a=i[s]))return!1;break;case"/neq":case"!=":if((o=t[r])===(a=i[s]))return!1;break;case"/gt":case">":var o=t[r],a=i[s];if(!(zn(o,a)>0))return!1;break;case"/gte":case">=":o=t[r],a=i[s];if(!(zn(o,a)>=0))return!1;break;case"/lt":case"<":o=t[r],a=i[s];if(!(zn(o,a)<0))return!1;break;case"/lte":case"<=":o=t[r],a=i[s];if(!(zn(o,a)<=0))return!1;break;case"/in":o=t[r];if(!(a=i[s]).includes(o))return!1;break;case"/nin":o=t[r];if((a=i[s]).includes(o))return!1;break;case"/contain":o=t[r],a=i[s];if(!o.includes(a))return!1;break;case"/regex":o=t[r];if(!(a=i[s]).test(o))return!1;break;case"/where":o=t[r];if(!(0,i[s])(o))return!1}}else if("function"==typeof e[r]){if(!e[r](t[r]))return!1}else if(e[r]!==t[r])return!1}}return!0}return e(t)},Wn=function(){},Yn=function(){return Promise.resolve()},Jn=function(e){return e},Xn=function(e,t){t(null)};!function(e){e[e.FORWARD=0]="FORWARD",e[e.BACKWARD=1]="BACKWARD"}(jn||(jn={}));var Zn,$n,er,tr=function(){function e(e){var t=e.initialPrevValue,n=void 0===t?null:t,r=e.initialNextValue,i=void 0===r?null:r,s=e.iterator,o=e.map,a=void 0===o?Jn:o,u=e.backward,c=void 0===u?Yn:u,l=e.forward,h=void 0===l?Yn:l,d=e.complete,f=void 0===d?Wn:d;this._prevValue=n,this._nextValue=i,this._error=null,this._map=a,this._backward=c,this._forward=h,this._iterator=s,this._complete=f}return Object.defineProperty(e.prototype,"prevValue",{get:function(){return this._map(this._prevValue)},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"nextValue",{get:function(){return this._map(this._nextValue)},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"error",{get:function(){return this._error},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"hasPrevious",{get:function(){return!!this._prevValue},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"hasNext",{get:function(){return!!this._nextValue},enumerable:!1,configurable:!0}),e.prototype.prev=function(){return p(this,void 0,void 0,(function(){var e,t,n;return v(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 p(this,void 0,void 0,(function(){var e,t,n;return v(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}(),nr=function(){function e(e){var t=e.condition,n=void 0===t?{}:t,r=e.backward,i=void 0!==r&&r,s=e.blockManager,o=e.indexer;this.condition=n,this.backward=i,this._blockManager=s,this._indexer=o}return e.prototype.findOptimizedStartPosition=function(){var e=this,t=["=","/eq",">",">=","/gt","/gte"],n=["=","/eq","<","<=","/lt","/lte"];if(this.backward){var r=this._indexer.origin.length-1;if("function"!=typeof this.condition)for(var i in this._indexer.fields){var s=this._indexer.fields[i],o=1;if("-"===s[0]&&(s=s.slice(1),o=-1),this.condition[s])if("object"==typeof this.condition[s]){var a=o>0?n:t;for(var u in this.condition[s])if(a.includes(u))for(var c=r;c>=0;c--)if(o*zn(this._indexer.origin[c].columnValues[i],this.condition[s][u])<=0){r=c;break}}else for(c=r;c>=0;c--)if(o*zn(this._indexer.origin[c].columnValues[i],this.condition[s])<=0){r=c;break}}return Math.min(r+1,this._indexer.origin.length-1)}var l=0;if("function"!=typeof this.condition)for(var h=function(r){var i=d._indexer.fields[r],s=1;if("-"===i[0]&&(i=i.slice(1),s=-1),d.condition[i])if("object"==typeof d.condition[i])Object.keys(d.condition[i]).forEach((function(o){if((s>0?t:n).includes(o))for(var a=l;a=0){l=a;break}}));else for(var o=l;o=0){l=o;break}},d=this,i=0;i0){for(var r=Math.ceil(e.data.length/n),i="".concat(r,".").concat(e.type,".").concat(t),s=[],o=0;o0))return[3,6];o=0,c.label=1;case 1:return o0))return[3,2];for(s=0;s-1){var r=this._items[n];return t===er.PERSISTENT&&(r.state=$n.PERSISTENT),t!==er.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)hr.includes(this._items[r].state)&&hr.includes(e.state)?(this._items.splice(r,1),this._items.push(e)):(this._items[r].state=e.state,this._items[r].generation=e.generation,this._items[r].value=e.value);else{this._items.push(e);var i=this._items.filter((function(e){return e.state===$n.VOLATILE})),s=i.length-this._limit;if(s>0){var o=[];try{for(var a=D(this._items),u=a.next();!u.done;u=a.next()){var c=u.value;c.state===$n.VOLATILE&&s>0?s--:o.push(c)}}catch(e){t={error:e}}finally{try{u&&!u.done&&(n=a.return)&&n.call(a)}finally{if(t)throw t.error}}this._items=o}}}},e.prototype.remove=function(e){var t=this._items.map((function(e){return e.key})).indexOf(e);t>-1&&this._items.splice(t,1)},e.prototype.clearByCondition=function(e){this._items=this._items.filter((function(t){return!e(t)}))},e.prototype.clear=function(e){void 0===e&&(e=!1),this._items=e?[]:this._items.filter((function(e){return e.state!==$n.VOLATILE}))},e}(),pr=function(){function e(e){var t=e.dbname,n=e.collectionName,r=e.store;this._metadata=null,this._requests=[],this._onCommit=new Map,this._onWrite=new Map,this._onError=new Map,this.dbname=t,this.collectionName=n,this.metadataKey=function(e,t){return"".concat(sr(e,t),"/trans.metadata")}(t,n),this.recordsetKey=function(e,t){return"".concat(sr(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=[]),p(this,void 0,void 0,(function(){var t;return v(this,(function(n){switch(n.label){case 0:return[4,this._store.get(this.recordsetKey)];case 1:return(t=n.sent()||[]).push.apply(t,X([],J(e),!1)),[2,this._reduceRecordSet(t)]}}))}))},e.prototype._reduceRecordSet=function(e){for(var t=[],n={},r=e.length-1;r>=0;r--){for(var i=e[r],s=[],o=i.requests.length-1;o>=0;o--){var a=i.requests[o],u=a.data;n[u.key]||(s.unshift(a),n[u.key]=!0)}s.length>0&&(i.requests=s,t.unshift(i))}return t},e.prototype._applyRecord=function(e,t){return p(this,void 0,void 0,(function(){var n,r,i,s,o,a,u,c,l;return v(this,(function(h){switch(h.label){case 0:n=fr.get(this.dbname),r=t.generation,i=t.requests,s=null,h.label=1;case 1:return h.trys.push([1,3,,4]),[4,this._store.setMany(i.map((function(e){return g(g({},e.data),{generation:r})})))];case 2:for(o=h.sent(),a=0;a0))return[3,4];for(t=[],n={},a=e.length-1;a>=0;a--)r=e[a],c=r.data,n[c.key]||(n[c.key]=!0,t.unshift(r));return i={generation:this.generation,requests:t},[4,this._getReducedRecordset([i])];case 1:return s=f.sent(),[4,this._store.set({key:this.recordsetKey,value:s,generation:this.generation})];case 2:return f.sent(),this._metadata.generation++,[4,this._store.set({key:this.metadataKey,value:this._metadata,generation:1})];case 3:for(f.sent(),o=fr.get(this.dbname),a=0;a0?(r=this.createBlockId(e,n),[4,t.find(this._store,r)]):[3,4];case 2:if((i=o.sent())&&(s=vr.createFromCacheItem(i),s.getItemByKey(e)))return[2,s];o.label=3;case 3:return n--,[3,1];case 4:return[2,null]}}))}))},e.prototype.getFromBlock=function(e){return p(this,void 0,void 0,(function(){var t;return v(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 p(this,void 0,void 0,(function(){var n,r,i,s,o;return v(this,(function(a){switch(a.label){case 0:return n=Fn.get(this.dbname),r=this.createBlockId(e),i=Math.floor(this._store.itemSizeLimit/n.itemSizeLimit),[4,fr.get(this.dbname).find(this._store,r)];case 1:return s=a.sent(),(o=s?vr.createFromCacheItem(s):new vr({blockId:r,keyName:this.keyName,items:[],limit:i})).add(t)?(this._transaction.requestWrite({key:o.blockId,value:o.serialize()}),[2,!0]):[2,!1]}}))}))},e.prototype.removeFromBlock=function(e){return p(this,void 0,void 0,(function(){var t;return v(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 p(this,void 0,void 0,(function(){var e,t,n,r,i,s,o,a,u;return v(this,(function(c){switch(c.label){case 0:return e=ar(this.dbname,this.collectionName),[4,this._store.getAllKeys()];case 1:return t=c.sent(),n=t.filter((function(t){return t.startsWith(e)})),[4,this._store.removeMany(n)];case 2:c.sent(),r=fr.get(this.dbname);try{for(i=D(n),s=i.next();!s.done;s=i.next())o=s.value,r.remove(o)}catch(e){a={error:e}}finally{try{s&&!s.done&&(u=i.return)&&u.call(i)}finally{if(a)throw a.error}}return[2]}}))}))},e}(),mr=function(){function e(e){var t=e.dbname,n=e.collectionName,r=e.keyName,i=e.fields,s=e.transaction,o=e.store,a=this;this._origin=[],this._table=[],this.dbname=t,this.collectionName=n,this.keyName=r,this.fields=i,this.indexerKey=function(e,t,n){return"".concat(sr(e,t),"/index.").concat(n)}(this.dbname,this.collectionName,this.fields.join(">")),this._transaction=s,this._store=o,this._transaction.on(Zn.COMMIT,this.indexerKey,(function(){return a.commit()})),this._transaction.on(Zn.ERROR,this.indexerKey,(function(){return a.abort()}))}return e.createKey=function(e){return e.join(">")},e.parseKey=function(e){return e.split(">")},e.prototype._addItem=function(e){var t=e[this.keyName],n=this.getColumnValues(e),r=J(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=J(this.indexOf(n),2),i=r[0];if(r[1]){var s=this._table[i].keys.indexOf(t);if(s>-1)return this._table[i].keys.splice(s,1),0===this._table[i].keys.length&&this._table.splice(i,1),!0}return!1},Object.defineProperty(e.prototype,"origin",{get:function(){return this._origin},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"table",{get:function(){return this._table},enumerable:!1,configurable:!0}),e.prototype.getColumnValues=function(e){var t,n,r,i,s=[];try{for(var o=D(this.fields),a=o.next();!a.done;a=o.next()){var u=a.value;if("-"===u[0]&&(u=u.slice(1)),r=e[u],i=void 0,i=typeof r,null!==r&&"undefined"!==i&&"boolean"!==i&&"number"!==i&&"string"!==i)throw Kn.indexTypesNotMatch;s.push(e[u])}}catch(e){t={error:e}}finally{try{a&&!a.done&&(n=o.return)&&n.call(o)}finally{if(t)throw t.error}}return s},e.prototype.diff=function(e,t){for(var n in this.fields){var r="-"===this.fields[n][0]?-1:1,i=zn(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 p(this,void 0,void 0,(function(){var e,t,n,r,i,s,o,a,u,c,l,h,d,f,p,_,m;return v(this,(function(v){switch(v.label){case 0:return[4,(e=fr.get(this.dbname)).find(this._store,this.indexerKey,er.PERSISTENT)];case 1:return(t=v.sent())?[3,11]:(n=ar(this.dbname,this.collectionName),[4,this._store.getAllKeys()]);case 2:r=v.sent(),v.label=3;case 3:v.trys.push([3,8,9,10]),i=D(r),s=i.next(),v.label=4;case 4:return s.done?[3,7]:(o=s.value).startsWith(n)?[4,e.find(this._store,o,er.NO_CACHE)]:[3,6];case 5:a=v.sent(),u=vr.createFromCacheItem(a);try{for(_=void 0,c=D(u.items),l=c.next();!l.done;l=c.next())h=l.value,this._addItem(h)}catch(e){_={error:e}}finally{try{l&&!l.done&&(m=c.return)&&m.call(c)}finally{if(_)throw _.error}}v.label=6;case 6:return s=i.next(),[3,4];case 7:return[3,10];case 8:return d=v.sent(),f={error:d},[3,10];case 9:try{s&&!s.done&&(p=i.return)&&p.call(i)}finally{if(f)throw f.error}return[7];case 10:return this._transaction.requestWrite({key:this.indexerKey,value:this._table},{persistent:!0}),[3,12];case 11:this._origin=t.value,this._table=Hn(this._origin),v.label=12;case 12:return[2]}}))}))},e.prototype.drop=function(){return p(this,void 0,void 0,(function(){return v(this,(function(e){switch(e.label){case 0:return fr.get(this.dbname).remove(this.indexerKey),[4,this._store.remove(this.indexerKey)];case 1:return e.sent(),[2]}}))}))},e.prototype.addItem=function(e){return p(this,void 0,void 0,(function(){return v(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 p(this,void 0,void 0,(function(){return v(this,(function(t){return this._removeItem(e)&&this._transaction.requestWrite({key:this.indexerKey,value:this._table},{persistent:!0}),[2]}))}))},e.prototype.clear=function(){return p(this,void 0,void 0,(function(){return v(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=Hn(this._origin)},e.prototype.abort=function(){this._table=Hn(this._origin)},e}(),yr="undefined"!=typeof document&&"undefined"!=typeof navigator;yr&&navigator.userAgent&&navigator.userAgent.includes("Chrome/")&&navigator.userAgent.includes("Chromium/");var gr=yr&&navigator.userAgent&&navigator.userAgent.includes("Firefox/")&&!navigator.userAgent.includes("Seamonkey/");yr&&navigator.userAgent&&navigator.userAgent.includes("Safari/")&&!navigator.userAgent.includes("Chrome/")&&navigator.userAgent.includes("Chromium/"),yr&&navigator.userAgent&&(navigator.userAgent.includes("OPR/")||navigator.userAgent.includes("Opera/")),yr&&navigator.userAgent&&navigator.userAgent.includes("Trident/7.0");var br,Ir,Er=yr&&navigator.userAgent&&navigator.userAgent.includes("Edge/"),wr=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"}(br||(br={})),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"}(Ir||(Ir={}));var kr,Nr={},Sr=function(){function e(e,t){void 0===t&&(t={});var n=this;return this._state=br.PROCESSING,this._hostId=null,this._queue=[],this._currentItem=null,this._activationTimeout=null,this._activationQueue=[],Nr[e]&&!t.forceCreate||(this.nodeId=wr(),this.key=e,yr&&(t.startAsInvisible?this.registerNode():"visible"===document.visibilityState?this.claimHost():this.registerNode(),document.addEventListener("visibilitychange",(function(){"visible"===document.visibilityState&&n.claimHost()})),window.addEventListener("message",(function(e){var t,r,i=e.data,s=i.nodeId,o=i.requestId,a=i.key,u=i.op,c=i.data;if(s!==n.nodeId&&a===n.key)switch(u){case Ir.NEWNODE:n._sendSync();break;case Ir.CLAIM_HOST:n._sendSync(),n._hostId=s;break;case Ir.SYNC_HOST:if(!n.isInSync){n._activationTimeout&&clearTimeout(n._activationTimeout);var l=c,h=l.currentItemRequestId,d=l.queue,f=function(e){var t=n._queue.findIndex((function(t){return t.requestId===e.requestId}));t<0&&n._requestLock({nodeId:e.nodeId,requestId:e.requestId,key:n.key,op:Ir.REQUEST_LOCK,ts:e.ts})};try{for(var p=D(d),v=p.next();!v.done;v=p.next()){f(v.value)}}catch(e){t={error:e}}finally{try{v&&!v.done&&(r=p.return)&&r.call(p)}finally{if(t)throw t.error}}n._currentItem=n._queue.find((function(e){return e.requestId===h})),n._completeSync()}break;case Ir.REMOVENODE:n._queue=n._queue.filter((function(e){return e.nodeId!==i.nodeId})),n._currentItem&&n._currentItem.nodeId===i.nodeId&&(n._currentItem=null,n._acquire(n._queue[0]));break;case Ir.REQUEST_LOCK:n._requestLock(i);break;case Ir.ACQUIRE_LOCK:var _=n._queue.find((function(e){return e.requestId===o}));n._acquire(_);break;case Ir.RELEASE_LOCK:n._release(o)}})),window.addEventListener("beforeunload",(function(){n._send(Ir.REMOVENODE)}))),Nr[e]=this),Nr[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==br.DONE},enumerable:!1,configurable:!0}),e.prototype._send=function(e,t){var n,r;void 0===t&&(t={});var i={nodeId:this.nodeId,requestId:null!==(n=null==t?void 0:t.requestId)&&void 0!==n?n:wr(),key:this.key,op:e,data:null!==(r=t.data)&&void 0!==r?r:null,ts:Date.now()};return yr&&window.postMessage(i,"*"),i},e.prototype._acquire=function(e){void 0===e&&(e=null),e?(this._currentItem=e,this._currentItem.onAcquired(e.requestId)):this._currentItem=null},e.prototype._release=function(e){if(this._currentItem&&this._currentItem.requestId===e){var t=this._currentItem;this._currentItem=null,t.nodeId===this.nodeId&&this._send(Ir.RELEASE_LOCK,{requestId:t.requestId});var n=this._queue.findIndex((function(t){return t.requestId===e}));n>-1&&this._queue.splice(n,1),t.onReleased(e)}},e.prototype._requestLock=function(e){var t=this;return new Promise((function(n){var r={nodeId:e.nodeId,requestId:e.requestId,ts:e.ts,onAcquired:function(e){t.isHost&&t._send(Ir.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(Ir.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 p(this,void 0,void 0,(function(){var e=this;return v(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=br.DONE,this._activationQueue.forEach((function(e){return e()})),this._activationQueue=[])},e.prototype.registerNode=function(){this._send(Ir.NEWNODE),this._waitSync()},e.prototype.claimHost=function(){this._hostId=this.nodeId,this._send(Ir.CLAIM_HOST),this._waitSync()},e.prototype.lock=function(){return p(this,void 0,void 0,(function(){var e;return v(this,(function(t){switch(t.label){case 0:return[4,this._waitUntilSyncCompleted()];case 1:return t.sent(),e=this._send(Ir.REQUEST_LOCK),[4,this._requestLock(e)];case 2:return t.sent(),[2]}}))}))},e.prototype.unlock=function(){var e;this._release(null===(e=this._currentItem)||void 0===e?void 0:e.requestId)},e}(),Tr=function(){function e(e){var t=e.dbname,n=e.collectionName,r=e.keyName,i=e.keyHash,s=e.indexes,o=e.store,a=this;this._state=Bn.INIT,this._metadata=null,this._indexers=[],this.dbname=t,this.name=n,this.keyName=r,this.indexes=X([[r]],J(s.filter((function(e){return mr.createKey(e)!==a.keyName}))),!1),this._keyHash=i,this._store=o,this._mutex=new Sr(function(e,t){return"".concat(sr(e,t),".lock")}(t,n)),this._blobContainer=new lr({dbname:t,collectionName:n,store:o}),this._transaction=new pr({dbname:t,collectionName:n,store:o})}return e.metadataOf=function(e,t,n){return p(this,void 0,void 0,(function(){var r;return v(this,(function(i){switch(i.label){case 0:return r=or(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===Bn.READY},enumerable:!1,configurable:!0}),e.prototype.init=function(){return p(this,void 0,void 0,(function(){var t,n,r,i,s,o,a,u,c,l,h,d,f,p,_=this;return v(this,(function(v){switch(v.label){case 0:return[4,this._mutex.lock()];case 1:v.sent(),v.label=2;case 2:return v.trys.push([2,9,,10]),t=Fn.get(this.dbname),[4,e.metadataOf(this.dbname,this.name,this._store)];case 3:return n=v.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:v.sent(),this._blockManager=new _r({dbname:this.dbname,collectionName:this.name,hashFunction:this._keyHash,metadata:this._metadata,transaction:this._transaction,store:this._store}),r=X([],J(this.indexes),!1),i=[],s=r.map((function(e){return mr.createKey(e)})),o=n?n.indexes.map((function(e){return mr.createKey(e)})):[];try{for(a=D(o),u=a.next();!u.done;u=a.next())c=u.value,s.includes(c)||i.push(mr.parseKey(c))}catch(e){f={error:e}}finally{try{u&&!u.done&&(p=a.return)&&p.call(a)}finally{if(f)throw f.error}}return(l=[]).push.apply(l,X([],J(r.map((function(e){var t=new mr({dbname:_.dbname,collectionName:_.name,keyName:_.keyName,fields:e,transaction:_._transaction,store:_._store});return _._indexers.push(t),t.ensure()}))),!1)),l.push.apply(l,X([],J(i.map((function(e){return new mr({dbname:_.dbname,collectionName:_.name,keyName:_.keyName,fields:e,transaction:_._transaction,store:_._store}).drop()}))),!1)),[4,Promise.all(l)];case 5:return v.sent(),[4,this._transaction.commit()];case 6:return v.sent(),s.sort().join(",")===o.sort().join(",")?[3,8]:(h=or(this.dbname,this.name),this._metadata.indexes=r,[4,this._store.set({key:h,value:this._metadata,generation:1})]);case 7:v.sent(),v.label=8;case 8:return this._state=Bn.READY,this._mutex.unlock(),[3,10];case 9:throw d=v.sent(),this._mutex.unlock(),d;case 10:return[2]}}))}))},e.prototype.close=function(){this._state=Bn.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=mr.createKey(e);try{for(var i=D(this._indexers),s=i.next();!s.done;s=i.next()){var o=s.value;if(r===mr.createKey(o.fields))return o}}catch(e){t={error:e}}finally{try{s&&!s.done&&(n=i.return)&&n.call(i)}finally{if(t)throw t.error}}return null},e.prototype._upgradeBlockLevel=function(){return p(this,void 0,void 0,(function(){var e;return v(this,(function(t){switch(t.label){case 0:return e=or(this.dbname,this.name),this._metadata.blockLevel++,[4,this._store.set({key:e,value:this._metadata,generation:1})];case 1:return t.sent(),[2]}}))}))},e.prototype._requestInsert=function(e){return p(this,void 0,void 0,(function(){var t,n,r,i,s,o;return v(this,(function(a){switch(a.label){case 0:return t=e[this.keyName],[4,this._blockManager.getFromBlock(t)];case 1:return a.sent()?[3,13]:[4,this._blockManager.putToBlock(t,e)];case 2:return a.sent()?[3,5]:[4,this._upgradeBlockLevel()];case 3:return a.sent(),[4,this._blockManager.putToBlock(t,e)];case 4:a.sent(),a.label=5;case 5:a.trys.push([5,10,11,12]),n=D(this._indexers),r=n.next(),a.label=6;case 6:return r.done?[3,9]:[4,r.value.addItem(e)];case 7:a.sent(),a.label=8;case 8:return r=n.next(),[3,6];case 9:return[3,12];case 10:return i=a.sent(),s={error:i},[3,12];case 11:try{r&&!r.done&&(o=n.return)&&o.call(n)}finally{if(s)throw s.error}return[7];case 12:return[3,14];case 13:throw Kn.collectionInsertDuplicate;case 14:return[2]}}))}))},e.prototype._requestUpsert=function(e){return p(this,void 0,void 0,(function(){var t,n,r,i,s,o,a,u,c,l,h,d,f;return v(this,(function(p){switch(p.label){case 0:return t=e[this.keyName],[4,this._blockManager.getFromBlock(t)];case 1:return(n=p.sent())?[3,13]:[4,this._blockManager.putToBlock(t,e)];case 2:return p.sent()?[3,5]:[4,this._upgradeBlockLevel()];case 3:return p.sent(),[4,this._blockManager.putToBlock(t,e)];case 4:p.sent(),p.label=5;case 5:p.trys.push([5,10,11,12]),r=D(this._indexers),i=r.next(),p.label=6;case 6:return i.done?[3,9]:[4,(u=i.value).addItem(e)];case 7:p.sent(),p.label=8;case 8:return i=r.next(),[3,6];case 9:return[3,12];case 10:return s=p.sent(),l={error:s},[3,12];case 11:try{i&&!i.done&&(h=r.return)&&h.call(r)}finally{if(l)throw l.error}return[7];case 12:return[3,23];case 13:return[4,this._blockManager.putToBlock(t,e)];case 14:p.sent(),p.label=15;case 15:p.trys.push([15,21,22,23]),o=D(this._indexers),a=o.next(),p.label=16;case 16:return a.done?[3,20]:0===(u=a.value).diff(u.getColumnValues(n),u.getColumnValues(e))?[3,19]:[4,u.removeItem(n)];case 17:return p.sent(),[4,u.addItem(e)];case 18:p.sent(),p.label=19;case 19:return a=o.next(),[3,16];case 20:return[3,23];case 21:return c=p.sent(),d={error:c},[3,23];case 22:try{a&&!a.done&&(f=o.return)&&f.call(o)}finally{if(d)throw d.error}return[7];case 23:return[2]}}))}))},e.prototype._requestUpdate=function(e){return p(this,void 0,void 0,(function(){var t,n,r,i,s,o,a,u;return v(this,(function(c){switch(c.label){case 0:return t=e[this.keyName],[4,this._blockManager.getFromBlock(t)];case 1:return(n=c.sent())?[4,this._blockManager.putToBlock(t,e)]:[3,11];case 2:c.sent(),c.label=3;case 3:c.trys.push([3,9,10,11]),r=D(this._indexers),i=r.next(),c.label=4;case 4:return i.done?[3,8]:0===(s=i.value).diff(s.getColumnValues(n),s.getColumnValues(e))?[3,7]:[4,s.removeItem(n)];case 5:return c.sent(),[4,s.addItem(e)];case 6:c.sent(),c.label=7;case 7:return i=r.next(),[3,4];case 8:return[3,11];case 9:return o=c.sent(),a={error:o},[3,11];case 10:try{i&&!i.done&&(u=r.return)&&u.call(r)}finally{if(a)throw a.error}return[7];case 11:return[2]}}))}))},e.prototype._requestRemove=function(e){return p(this,void 0,void 0,(function(){var t,n,r,i,s,o;return v(this,(function(a){switch(a.label){case 0:return[4,this._blockManager.getFromBlock(e)];case 1:return(t=a.sent())?[4,this._blockManager.removeFromBlock(e)]:[3,10];case 2:a.sent(),a.label=3;case 3:a.trys.push([3,8,9,10]),n=D(this._indexers),r=n.next(),a.label=4;case 4:return r.done?[3,7]:[4,r.value.removeItem(t)];case 5:a.sent(),a.label=6;case 6:return r=n.next(),[3,4];case 7:return[3,10];case 8:return i=a.sent(),s={error:i},[3,10];case 9:try{r&&!r.done&&(o=n.return)&&o.call(n)}finally{if(s)throw s.error}return[7];case 10:return[2]}}))}))},e.prototype._requestClear=function(){return p(this,void 0,void 0,(function(){var e,t,n,r,i;return v(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=D(this._indexers),t=e.next(),s.label=3;case 3:return t.done?[3,6]:[4,t.value.clear()];case 4:s.sent(),s.label=5;case 5:return t=e.next(),[3,3];case 6:return[3,9];case 7:return n=s.sent(),r={error:n},[3,9];case 8:try{t&&!t.done&&(i=e.return)&&i.call(e)}finally{if(r)throw r.error}return[7];case 9:return[2]}}))}))},e.prototype.getByKey=function(e){return p(this,void 0,void 0,(function(){var t,n;return v(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,Hn(t)];case 4:throw n=r.sent(),this._mutex.unlock(),n;case 5:return[3,7];case 6:throw Kn.collectionNotReady;case 7:return[2]}}))}))},e.prototype.query=function(e){return void 0===e&&(e={}),this.isReady?new rr({condition:e.where,mutex:this._mutex,blockManager:this._blockManager,indexer:this._getIndexerBy(e.index),backward:!!e.backward}):null},e.prototype.insertOne=function(e){return p(this,void 0,void 0,(function(){var t;return v(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 Kn.collectionKeyNotGiven;return[4,this._requestInsert(Hn(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 Kn.collectionNotReady;case 9:return[2]}}))}))},e.prototype.insertMany=function(e){return p(this,void 0,void 0,(function(){var t,n,r,i,s,o,a,u=this;return v(this,(function(c){switch(c.label){case 0:return this.isReady?[4,this._mutex.lock()]:[3,15];case 1:c.sent(),c.label=2;case 2:if(c.trys.push([2,12,,14]),e.some((function(e){return!u._hasPropertyOfKeyName(e)})))throw Kn.collectionKeyNotGiven;c.label=3;case 3:c.trys.push([3,8,9,10]),t=D(e),n=t.next(),c.label=4;case 4:return n.done?[3,7]:(r=n.value,[4,this._requestInsert(Hn(r))]);case 5:c.sent(),c.label=6;case 6:return n=t.next(),[3,4];case 7:return[3,10];case 8:return i=c.sent(),o={error:i},[3,10];case 9:try{n&&!n.done&&(a=t.return)&&a.call(t)}finally{if(o)throw o.error}return[7];case 10:return[4,this._transaction.commit()];case 11:return c.sent(),this._mutex.unlock(),[2,e];case 12:return s=c.sent(),[4,this._transaction.clear()];case 13:throw c.sent(),this._mutex.unlock(),s;case 14:return[3,16];case 15:throw Kn.collectionNotReady;case 16:return[2]}}))}))},e.prototype.upsertOne=function(e){return p(this,void 0,void 0,(function(){var t;return v(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 Kn.collectionKeyNotGiven;return[4,this._requestUpsert(Hn(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 Kn.collectionNotReady;case 9:return[2]}}))}))},e.prototype.upsertMany=function(e){return p(this,void 0,void 0,(function(){var t,n,r,i,s,o,a,u=this;return v(this,(function(c){switch(c.label){case 0:return this.isReady?[4,this._mutex.lock()]:[3,15];case 1:c.sent(),c.label=2;case 2:if(c.trys.push([2,12,,14]),e.some((function(e){return!u._hasPropertyOfKeyName(e)})))throw Kn.collectionKeyNotGiven;c.label=3;case 3:c.trys.push([3,8,9,10]),t=D(e),n=t.next(),c.label=4;case 4:return n.done?[3,7]:(r=n.value,[4,this._requestUpsert(Hn(r))]);case 5:c.sent(),c.label=6;case 6:return n=t.next(),[3,4];case 7:return[3,10];case 8:return i=c.sent(),o={error:i},[3,10];case 9:try{n&&!n.done&&(a=t.return)&&a.call(t)}finally{if(o)throw o.error}return[7];case 10:return[4,this._transaction.commit()];case 11:return c.sent(),this._mutex.unlock(),[2,e];case 12:return s=c.sent(),[4,this._transaction.clear()];case 13:throw c.sent(),this._mutex.unlock(),s;case 14:return[3,16];case 15:throw Kn.collectionNotReady;case 16:return[2]}}))}))},e.prototype.update=function(e){return p(this,void 0,void 0,(function(){var t;return v(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 Kn.collectionKeyNotGiven;return[4,this._requestUpdate(Hn(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 Kn.collectionNotReady;case 9:return[2]}}))}))},e.prototype.updateIf=function(e,t){return p(this,void 0,void 0,(function(){var n,r,i,s,o,a,u,c,l,h,d,f,_,m,y=this;return v(this,(function(g){switch(g.label){case 0:return this.isReady?[4,this._mutex.lock()]:[3,16];case 1:g.sent(),g.label=2;case 2:return g.trys.push([2,13,,15]),n=e.where,r=void 0===n?{}:n,i=e.index,s=void 0===i?null:i,o=e.backward,a=void 0!==o&&o,u=[],[4,new nr({condition:r,blockManager:this._blockManager,backward:a,indexer:this._getIndexerBy(s)}).each((function(e){return p(y,void 0,void 0,(function(){var n,i;return v(this,(function(s){if(e.error)throw e.stop(),e.error;if(e.hasNext){if(n=e.nextValue,Gn(r,n)&&t.set){if("function"!=typeof t.set)for(i in t.set)n[i]=t.set[i];else t.set(n);u.push(n)}e.next()}else e.stop();return[2]}))}))}))];case 3:g.sent(),g.label=4;case 4:g.trys.push([4,9,10,11]),c=D(u),l=c.next(),g.label=5;case 5:return l.done?[3,8]:(h=l.value,[4,this._requestUpdate(Hn(h))]);case 6:g.sent(),g.label=7;case 7:return l=c.next(),[3,5];case 8:return[3,11];case 9:return d=g.sent(),_={error:d},[3,11];case 10:try{l&&!l.done&&(m=c.return)&&m.call(c)}finally{if(_)throw _.error}return[7];case 11:return[4,this._transaction.commit()];case 12:return g.sent(),this._mutex.unlock(),[2,u];case 13:return f=g.sent(),[4,this._transaction.clear()];case 14:throw g.sent(),this._mutex.unlock(),f;case 15:return[3,17];case 16:throw this._transaction.clear(),Kn.collectionNotReady;case 17:return[2]}}))}))},e.prototype.remove=function(e){return p(this,void 0,void 0,(function(){var t;return v(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 Kn.collectionNotReady;case 9:return[2]}}))}))},e.prototype.removeIf=function(e){return p(this,void 0,void 0,(function(){var t,n,r,i,s,o,a,u,c,l,h,d,f,_,m=this;return v(this,(function(y){switch(y.label){case 0:return this.isReady?[4,this._mutex.lock()]:[3,15];case 1:y.sent(),y.label=2;case 2:return y.trys.push([2,13,,14]),t=e.where,n=void 0===t?{}:t,r=e.index,i=void 0===r?null:r,s=e.backward,o=void 0!==s&&s,a=[],[4,new nr({condition:n,blockManager:this._blockManager,backward:o,indexer:this._getIndexerBy(i)}).each((function(e){return p(m,void 0,void 0,(function(){var t,r;return v(this,(function(i){if(e.error)throw e.stop(),e.error;return e.hasNext?(t=e.nextValue,Gn(n,t)&&(r=t[this.keyName],a.push(r)),e.next()):e.stop(),[2]}))}))}))];case 3:y.sent(),y.label=4;case 4:y.trys.push([4,9,10,11]),u=D(a),c=u.next(),y.label=5;case 5:return c.done?[3,8]:(l=c.value,[4,this._requestRemove(l)]);case 6:y.sent(),y.label=7;case 7:return c=u.next(),[3,5];case 8:return[3,11];case 9:return h=y.sent(),f={error:h},[3,11];case 10:try{c&&!c.done&&(_=u.return)&&_.call(u)}finally{if(f)throw f.error}return[7];case 11:return[4,this._transaction.commit()];case 12:return y.sent(),this._mutex.unlock(),[2,a];case 13:throw d=y.sent(),this._mutex.unlock(),d;case 14:return[3,16];case 15:throw this._transaction.clear(),Kn.collectionNotReady;case 16:return[2]}}))}))},e.prototype.clear=function(){return p(this,void 0,void 0,(function(){var e;return v(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 Kn.collectionNotReady;case 9:return[2]}}))}))},e.prototype.getBlob=function(e){return p(this,void 0,void 0,(function(){return v(this,(function(t){switch(t.label){case 0:return[4,this._blobContainer.get(e)];case 1:return[2,t.sent()]}}))}))},e.prototype.saveBlob=function(e,t){return void 0===t&&(t=null),p(this,void 0,void 0,(function(){return v(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 p(this,void 0,void 0,(function(){return v(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 p(this,void 0,void 0,(function(){return v(this,(function(e){switch(e.label){case 0:return[4,this._blobContainer.clear()];case 1:return e.sent(),[2]}}))}))},e}(),Or={},Cr=function(){function e(e){void 0===e&&(e={});var t=e.itemSizeLimit,n=void 0===t?4194304:t,r=e.delay,i=void 0===r?1:r,s=e.encryption,o=void 0===s?Z:s;this._encryption=o,this.itemSizeLimit=n,this.delay=i,this.observer={}}return Object.defineProperty(e.prototype,"rawData",{get:function(){return Or[this.dbname]},set:function(e){Or[this.dbname]=e},enumerable:!1,configurable:!0}),e.prototype.observe=function(e,t,n){var r=this;this.observer[e]={},t.forEach((function(t){return r.observer[e][t]=n}))},e.prototype.init=function(e){return p(this,void 0,void 0,(function(){var t;return v(this,(function(n){switch(n.label){case 0:this.dbname=e,Or[this.dbname]={},n.label=1;case 1:return n.trys.push([1,,3,5]),[4,this.get($.key)];case 2:if((t=n.sent())&&JSON.stringify(t)!==JSON.stringify($.value))throw Kn.storeEncryptionInvalid;return[3,5];case 3:return[4,this.set($)];case 4:return n.sent(),[7];case 5:return[2]}}))}))},e.prototype.getAllKeys=function(){return p(this,void 0,void 0,(function(){return v(this,(function(e){return[2,Object.keys(Or[this.dbname]).filter((function(e){return e!==$.key}))]}))}))},e.prototype.get=function(e){return p(this,void 0,void 0,(function(){var t;return v(this,(function(n){switch(n.label){case 0:return[4,this.getRaw(e)];case 1:return[2,(t=n.sent())?this._encryption.decrypt(t):null]}}))}))},e.prototype.getRaw=function(e){return p(this,void 0,void 0,(function(){var t,n;return v(this,(function(r){switch(r.label){case 0:return[4,Qn(this.delay)];case 1:if(r.sent(),t=this.observer[e],n=t&&t.get?t.get(e):null)throw n;return[2,Or[this.dbname][e]]}}))}))},e.prototype.set=function(e){return p(this,void 0,void 0,(function(){var t,n,r,i,s,o;return v(this,(function(a){switch(a.label){case 0:return[4,Qn(this.delay)];case 1:if(a.sent(),t=e.key,n=e.value,r=this.observer[t],i=r&&r.set?r.set(t):null)throw i;if(s=this._encryption.encrypt(n),o=JSON.stringify(s),t===$.key||o.lengtha.ts){if(a.all!==t.all&&(u=!0),a.all=t.all>=0?t.all:0,t.customTypes)for(var l in t.customTypes)a.customTypes[l]!==t.customTypes[l]&&(u=!0),a.customTypes[l]=t.customTypes[l];u=u&&a.ts>0,a.ts=c}u&&ue((function(){return p(r,void 0,void 0,(function(){return v(this,(function(e){return[2,h.forEach((function(e){e.onTotalUnreadMessageCountUpdated(a.all,a.customTypes)}))]}))}))}))}else t instanceof le&&o.localCacheEnabled&&o.preference.set(r._getUserProfileCacheKey(s.userId),he.payloadify(t.userProfile))}))}return e.init=function(t){var n=t.appId,r=t.appVersion,i=void 0===r?null:r,s=t.modules,o=void 0===s?[]:s,a=t.options,u=void 0===a?new ee:a,c=t.debugMode,l=void 0!==c&&c,h=t.customApiHost,d=t.customWebSocketHost,f=t.newInstance,p=void 0!==f&&f,v=t.logLevel,_=t.localCacheEnabled,m=void 0!==_&&_,y=t.localCacheEncryption,g=t.useAsyncStorageStore,b=void 0===g?null:g;if(!Dr||p){var I="su-".concat(te()),w=null!=y?y:{encrypt:function(e){return e},decrypt:function(e){return e}},k=new Cr({encryption:w});l||(k=b?new Lr({AsyncStorage:b,encryption:w}):new Ar({encryption:w})),new E(I,{appId:n,appVersion:i,options:u,apiHost:null!=h?h:"https://api-".concat(n,".sendbird.com"),websocketHost:null!=d?d:"wss://ws-".concat(n,".sendbird.com"),store:k,encryption:w,logLevel:v,localCacheEnabled:m,debugMode:l});var N=[new ne,new Ze],S=new e(I,u,X(X([],J(o),!1),J(N),!1));return Dr||(Dr=S),S}return Dr},Object.defineProperty(e,"instance",{get:function(){return Dr},enumerable:!1,configurable:!0}),Object.defineProperty(e,"version",{get:function(){return re},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"appId",{get:function(){return E.of(this._iid).sdkState.appId},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"appInfo",{get:function(){return E.of(this._iid).appInfo},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"appVersion",{get:function(){var e;return null!==(e=E.of(this._iid).sdkState.appVersion)&&void 0!==e?e:""},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"debugMode",{get:function(){return E.of(this._iid).debugMode},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"logLevel",{get:function(){return E.of(this._iid).logger.level},set:function(e){E.of(this._iid).logger.level=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"isCacheEnabled",{get:function(){return E.of(this._iid).cacheContext.localCacheEnabled},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"ekey",{get:function(){return ie(this._iid)},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"currentUser",{get:function(){var e;return null!==(e=E.of(this._iid).sessionManager.currentUser)&&void 0!==e?e:null},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"connectionState",{get:function(){var e=E.of(this._iid).connectionManager;return e.isConnected?se.OPEN:e.isConnecting?se.CONNECTING:se.CLOSED},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"lastConnectedAt",{get:function(){var e=E.of(this._iid),t=e.connectedAt;return e.connectionManager.isConnected?t:0},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"fcmPushToken",{get:function(){return this._fcmPushToken},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"apnsPushToken",{get:function(){return this._apnsPushToken},enumerable:!1,configurable:!0}),e.prototype._getPreferenceCacheKey=function(e){return"sendbird@".concat(this.appId,"/").concat(e,".pref")},e.prototype._getUserProfileCacheKey=function(e){return"sendbird@".concat(this.appId,"/").concat(e,".profile")},e.prototype.getMemoryStoreForDebugging=function(){var e=E.of(this._iid),t=e.debugMode,n=e.cacheContext;if(t)return n.store instanceof Cr?n.store:null;throw y.debugModeRequired},e.prototype.addExtension=function(e,t){var n=E.of(this._iid).sdkState;["sb_uikit","sb_syncmanager","device-os-platform"].indexOf(e)>-1&&(n.extensions[e]=t)},e.prototype.setOnlineListener=function(e){this._onlineDetector.setOnlineListener(e)},e.prototype.setOfflineListener=function(e){this._onlineDetector.setOfflineListener(e)},e.prototype.initializeCache=function(e){return p(this,void 0,void 0,(function(){var t,n,r,i,s,o,a,u;return v(this,(function(c){switch(c.label){case 0:return t=E.of(this._iid),n=t.sdkState,r=t.cacheContext,i=t.connectionManager,s=t.dispatcher,n.userId&&n.userId===e?[3,6]:[4,i.logout()];case 1:return c.sent(),n.userId=e,r.localCacheEnabled?(o="sendbird@".concat(n.appId,"/").concat(e,".db"),r.nestdb&&r.nestdb.state!==kr.CLOSED&&r.nestdb.name===o?[3,3]:((a=r.nestdb=new Rr({name:"sendbird@".concat(n.appId,"/").concat(e,".db"),version:1,store:r.store})).on("upgrade",function(e){return function(t,n){0===t?e.commitSchema([{collectionName:"GroupChannel",keyName:"url",index:[ct(Ne.LATEST_LAST_MESSAGE),ct(Ne.CHRONOLOGICAL),ct(Ne.CHANNEL_NAME_ALPHABETICAL)]},{collectionName:"Message",keyName:"messageId",index:[dt(ut.CHANNEL_LATEST),dt(ut.NEWEST_CHILD_MESSAGE)]},{collectionName:"UnsentMessage",keyName:"reqId",index:[dt(ut.CHANNEL_LATEST),dt(ut.NEWEST_CHILD_MESSAGE)]},{collectionName:"Poll",keyName:"pollId"}]).then((function(){return n()})).catch((function(e){return n(e)})):n()}}(a)),[4,a.open()])):[3,6];case 2:c.sent(),s.dispatch(new Tt(this._iid,{userId:e})),c.label=3;case 3:return[4,r.preference.init(this._getPreferenceCacheKey(e))];case 4:return c.sent(),[4,r.preference.get(this._getUserProfileCacheKey(e))];case 5:(u=c.sent())&&new he(this._iid,u).apply(),c.label=6;case 6:return[2]}}))}))},e.prototype.clearCachedData=function(){return p(this,void 0,void 0,(function(){var e;return v(this,(function(t){switch(t.label){case 0:return(e=E.of(this._iid).cacheContext).localCacheEnabled?(e.nestdb&&e.nestdb.clear(),[4,e.preference.clear()]):[3,2];case 1:t.sent(),t.label=2;case 2:return[2]}}))}))},e.prototype.clearCachedMessages=function(e){return p(this,void 0,void 0,(function(){var t,n,r=this;return v(this,(function(i){switch(i.label){case 0:return m(W("string",e)).throw(y.invalidParameters),t=bt.of(this._iid),n=yt.of(this._iid),t&&n?[4,Promise.all(e.map((function(e){return p(r,void 0,void 0,(function(){return v(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]}}))}))},e.prototype.connect=function(e,t){return void 0===t&&(t=null),p(this,void 0,void 0,(function(){var n,r,i,s,o,a,u;return v(this,(function(l){switch(l.label){case 0:m(c("string",e)&&c("string",t,!0)).throw(y.invalidParameters),n=E.of(this._iid),r=n.sdkState,i=n.cacheContext,s=n.connectionManager,o=n.statLogCollector,l.label=1;case 1:return l.trys.push([1,3,,4]),[4,this.initializeCache(e)];case 2:return l.sent(),[3,4];case 3:return l.sent(),a=E.of(this._iid).logger,i.localCacheEnabled=!1,a.warn("Cache initialization failed - cache is not available."),[3,4];case 4:return[4,o.init("sendbird@".concat(r.appId,"/").concat(e,".statlog"))];case 5:return l.sent(),[4,s.connect(t)];case 6:return l.sent(),this._appStateChangeDetector.start(),r.appState="foreground",[4,null==(u=Nt.of(this._iid))?void 0:u.processNonAutoResendRegisteredPendingMessages()];case 7:return l.sent(),this._onlineDetector.start(),[2,this.currentUser]}}))}))},e.prototype.reconnect=function(){var e=E.of(this._iid),t=e.connectionManager,n=e.sdkState,r=e.sessionManager.auth.hasSession;return r&&t.resetAndReconnect().then((function(){n.appState="foreground"})).catch((function(){})),r},e.prototype.disconnect=function(){return p(this,void 0,void 0,(function(){var e,t,n,r;return v(this,(function(i){switch(i.label){case 0:return e=E.of(this._iid),t=e.connectionManager,n=e.cacheContext,r=e.requestQueue,this._appStateChangeDetector.stop(),this._onlineDetector.stop(),r.cancelAll(),[4,t.logout()];case 1:return i.sent(),n.localCacheEnabled?[4,this.clearCachedData()]:[3,3];case 2:i.sent(),i.label=3;case 3:return[2]}}))}))},e.prototype.setBackgroundState=function(){var e=E.of(this._iid),t=e.connectionManager,n=e.sdkState,r=e.logger;"foreground"===n.appState&&(n.appState="background",r.debug("going background state"),t.background())},e.prototype.setForegroundState=function(){var e=E.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())},e.prototype.setSessionHandler=function(e){m(e instanceof et).throw(y.invalidParameters),E.of(this._iid).sessionManager.handler=e},e.prototype.addUserEventHandler=function(e,t){m(c("string",e)&&t instanceof nt).throw(y.invalidParameters),E.of(this._iid).userEventHandlers.set(e,t)},e.prototype.removeUserEventHandler=function(e){E.of(this._iid).userEventHandlers.delete(e)},e.prototype.removeAllUserEventHandler=function(){E.of(this._iid).userEventHandlers.clear()},e.prototype.addConnectionHandler=function(e,t){m(c("string",e)&&t instanceof tt).throw(y.invalidParameters),E.of(this._iid).connectionHandlers.set(e,t)},e.prototype.removeConnectionHandler=function(e){E.of(this._iid).connectionHandlers.delete(e)},e.prototype.removeAllConnectionHandler=function(){E.of(this._iid).connectionHandlers.clear()},e.prototype.createApplicationUserListQuery=function(e){return void 0===e&&(e={}),new Ln(this._iid,e)},e.prototype.createBlockedUserListQuery=function(e){return void 0===e&&(e={}),new Rn(this._iid,e)},e.prototype.createFriendListQuery=function(e){return void 0===e&&(e={}),new Un(this._iid,e)},e.prototype.createMessageSearchQuery=function(e){return new oe(this._iid,e)},e.prototype.createPollListQuery=function(e){return new We(this._iid,g({},e))},e.prototype.createPollVoterListQuery=function(e){return new Xe(this._iid,g({},e))},e.prototype.buildUserFromSerializedData=function(e){var t=ae(e);return new w(this._iid,w.payloadify(t))},e.prototype.updateCurrentUserInfo=function(e){return void 0===e&&(e={}),p(this,void 0,void 0,(function(){var t,n,r,i,s,o,a;return v(this,(function(u){switch(u.label){case 0:return t=g(g({},$e),e),m(function(e){return N(e.profileImage,!0)&&c("string",e.profileUrl,!0)&&c("string",e.nickname,!0)}(t)).throw(y.invalidParameters),this.currentUser?(n=E.of(this._iid),r=n.sdkState,i=n.requestQueue,s=new Ct(g({userId:r.userId},t)),[4,i.send(s)]):[3,2];case 1:return o=u.sent(),a=o.as(At).user,this.currentUser&&(t.nickname&&(this.currentUser.nickname=a.nickname),(t.profileUrl||t.profileImage)&&(this.currentUser.plainProfileUrl=a.profileUrl)),[2,a];case 2:throw y.connectionRequired}}))}))},e.prototype.updateCurrentUserInfoWithPreferredLanguages=function(e){return p(this,void 0,void 0,(function(){var t,n,r,i,s,o;return v(this,(function(a){switch(a.label){case 0:return m(W("string",e)).throw(y.invalidParameters),this.currentUser?(t=E.of(this._iid),n=t.sdkState,r=t.requestQueue,i=new Ct({userId:n.userId,preferredLanguages:e}),[4,r.send(i)]):[3,2];case 1:return s=a.sent(),o=s.as(At).user,this.currentUser&&(this.currentUser.preferredLanguages=o.preferredLanguages),[2,o];case 2:throw y.connectionRequired}}))}))},e.prototype.registerFCMPushTokenForCurrentUser=function(e){return p(this,void 0,void 0,(function(){var t,n,r,i;return v(this,(function(s){switch(s.label){case 0:if(m(c("string",e)).throw(y.invalidParameters),!this.currentUser)return[3,5];s.label=1;case 1:return s.trys.push([1,3,,4]),t=E.of(this._iid),n=t.sdkState,r=t.requestQueue,i=new xt({userId:n.userId,token:e}),[4,r.send(i)];case 2:return s.sent(),this._fcmPushToken="",[2,Ie.SUCCESS];case 3:return s.sent(),[2,Ie.ERROR];case 4:return[3,6];case 5:return this._fcmPushToken=e,[2,Ie.PENDING];case 6:return[2]}}))}))},e.prototype.unregisterFCMPushTokenForCurrentUser=function(e){return p(this,void 0,void 0,(function(){var t,n,r,i;return v(this,(function(s){switch(s.label){case 0:if(m(c("string",e)).throw(y.invalidParameters),!this.currentUser)return[3,5];s.label=1;case 1:return s.trys.push([1,3,,4]),t=E.of(this._iid),n=t.sdkState,r=t.requestQueue,i=new Rt({userId:n.userId,token:e}),[4,r.send(i)];case 2:return s.sent(),this._fcmPushToken="",[2,Ie.SUCCESS];case 3:return s.sent(),[2,Ie.ERROR];case 4:return[3,6];case 5:return this._fcmPushToken=e,[2,Ie.PENDING];case 6:return[2]}}))}))},e.prototype.unregisterFCMPushTokenAllForCurrentUser=function(){return p(this,void 0,void 0,(function(){var e,t,n,r;return v(this,(function(i){switch(i.label){case 0:return this.currentUser?(e=E.of(this._iid),t=e.sdkState,n=e.requestQueue,r=new Mt({userId:t.userId}),[4,n.send(r)]):[3,2];case 1:i.sent(),i.label=2;case 2:return[2]}}))}))},e.prototype.registerAPNSPushTokenForCurrentUser=function(e){return p(this,void 0,void 0,(function(){var t,n,r,i;return v(this,(function(s){switch(s.label){case 0:if(m(c("string",e)).throw(y.invalidParameters),!this.currentUser)return[3,5];s.label=1;case 1:return s.trys.push([1,3,,4]),t=E.of(this._iid),n=t.sdkState,r=t.requestQueue,i=new Lt({userId:n.userId,token:e}),[4,r.send(i)];case 2:return s.sent(),this._fcmPushToken="",[2,Ie.SUCCESS];case 3:return s.sent(),[2,Ie.ERROR];case 4:return[3,6];case 5:return this._fcmPushToken=e,[2,Ie.PENDING];case 6:return[2]}}))}))},e.prototype.unregisterAPNSPushTokenForCurrentUser=function(e){return p(this,void 0,void 0,(function(){var t,n,r,i;return v(this,(function(s){switch(s.label){case 0:if(m(c("string",e)).throw(y.invalidParameters),!this.currentUser)return[3,5];s.label=1;case 1:return s.trys.push([1,3,,4]),t=E.of(this._iid),n=t.sdkState,r=t.requestQueue,i=new Pt({userId:n.userId,token:e}),[4,r.send(i)];case 2:return s.sent(),this._fcmPushToken="",[2,Ie.SUCCESS];case 3:return s.sent(),[2,Ie.ERROR];case 4:return[3,6];case 5:return this._fcmPushToken=e,[2,Ie.PENDING];case 6:return[2]}}))}))},e.prototype.unregisterAPNSPushTokenAllForCurrentUser=function(){return p(this,void 0,void 0,(function(){var e,t,n,r;return v(this,(function(i){switch(i.label){case 0:return this.currentUser?(e=E.of(this._iid),t=e.sdkState,n=e.requestQueue,r=new Dt({userId:t.userId}),[4,n.send(r)]):[3,2];case 1:i.sent(),i.label=2;case 2:return[2]}}))}))},e.prototype.getChannelInvitationPreference=function(){return p(this,void 0,void 0,(function(){var e,t,n,r,i;return v(this,(function(s){switch(s.label){case 0:return e=E.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,{autoAccept:i.as(Bt).autoAccept}]}}))}))},e.prototype.setChannelInvitationPreference=function(e){return p(this,void 0,void 0,(function(){var t,n,r,i,s;return v(this,(function(o){switch(o.label){case 0:return m(c("boolean",e)).throw(y.invalidParameters),t=E.of(this._iid),n=t.sdkState,r=t.requestQueue,i=new Kt({userId:n.userId,willAutoAccept:e}),[4,r.send(i)];case 1:return s=o.sent(),[2,{autoAccept:s.as(jt).autoAccept}]}}))}))},e.prototype.getDoNotDisturb=function(){return p(this,void 0,void 0,(function(){var e,t,n,r,i;return v(this,(function(s){switch(s.label){case 0:return e=E.of(this._iid),t=e.sdkState,n=e.requestQueue,r=new Ht({userId:t.userId}),[4,n.send(r)];case 1:return i=s.sent(),[2,i.as(zt).preference]}}))}))},e.prototype.setDoNotDisturb=function(e,t,n,r,i,s){return void 0===t&&(t=0),void 0===n&&(n=0),void 0===r&&(r=0),void 0===i&&(i=0),void 0===s&&(s=""),p(this,void 0,void 0,(function(){var o,a,u,l,h;return v(this,(function(d){switch(d.label){case 0:return m(c("boolean",e)&&c("number",t)&&c("number",n)&&c("number",r)&&c("number",i)&&c("string",s)).throw(y.invalidParameters),o=E.of(this._iid),a=o.sdkState,u=o.requestQueue,l=new Vt({userId:a.userId,doNotDisturbOn:e,startHour:t,startMin:n,endHour:r,endMin:i,timezone:s}),[4,u.send(l)];case 1:return h=d.sent(),[2,h.as(Qt).preference]}}))}))},e.prototype.getSnoozePeriod=function(){return p(this,void 0,void 0,(function(){var e,t,n,r,i;return v(this,(function(s){switch(s.label){case 0:return e=E.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(Wt).snoozePeriod]}}))}))},e.prototype.setSnoozePeriod=function(e,t,n){return void 0===t&&(t=0),void 0===n&&(n=0),p(this,void 0,void 0,(function(){var r,i,s,o,a;return v(this,(function(u){switch(u.label){case 0:return m(c("boolean",e)&&c("number",t)&&c("number",n)).throw(y.invalidParameters),r=E.of(this._iid),i=r.sdkState,s=r.requestQueue,o=new Yt({userId:i.userId,snoozeOn:e,startTs:t,endTs:n}),[4,s.send(o)];case 1:return a=u.sent(),[2,a.as(Jt).snoozePeriod]}}))}))},e.prototype.getMyPushTokensByToken=function(e,t){return p(this,void 0,void 0,(function(){var n,r,i,s,o;return v(this,(function(a){switch(a.label){case 0:return m(c("string",e)&&d(we,t)).throw(y.invalidParameters),n=E.of(this._iid),r=n.sdkState,i=n.requestQueue,s=new Ut({userId:r.userId,type:t,token:e}),[4,i.send(s)];case 1:return o=a.sent(),[2,o.as(qt).pushTokens]}}))}))},e.prototype.getPushTriggerOption=function(){return p(this,void 0,void 0,(function(){var e,t,n,r;return v(this,(function(i){switch(i.label){case 0:return e=E.of(this._iid),t=e.sdkState,n=e.requestQueue,r=new $t({userId:t.userId}),[4,n.send(r)];case 1:return[2,i.sent().as(en).pushTriggerOption]}}))}))},e.prototype.setPushTriggerOption=function(e){return p(this,void 0,void 0,(function(){var t,n,r,i;return v(this,(function(s){switch(s.label){case 0:return m(d(Ee,e)).throw(y.invalidParameters),t=E.of(this._iid),n=t.sdkState,r=t.requestQueue,i=new tn({userId:n.userId,pushTriggerOption:e}),[4,r.send(i)];case 1:return[2,s.sent().as(nn).pushTriggerOption]}}))}))},e.prototype.getPushTemplate=function(){return p(this,void 0,void 0,(function(){var e,t,n,r;return v(this,(function(i){switch(i.label){case 0:return e=E.of(this._iid),t=e.sdkState,n=e.requestQueue,r=new rn({userId:t.userId}),[4,n.send(r)];case 1:return[2,i.sent().as(sn).name]}}))}))},e.prototype.setPushTemplate=function(e){return p(this,void 0,void 0,(function(){var t,n,r,i;return v(this,(function(s){switch(s.label){case 0:return m(d(ke,e)).throw(y.invalidParameters),t=E.of(this._iid),n=t.sdkState,r=t.requestQueue,i=new on({userId:n.userId,templateName:e}),[4,r.send(i)];case 1:return[2,s.sent().as(an).name]}}))}))},e.prototype.blockUser=function(e){return p(this,void 0,void 0,(function(){var t,n,r,i;return v(this,(function(s){switch(s.label){case 0:return m(e instanceof w||c("string",e)).throw(y.invalidParameters),t=E.of(this._iid),n=t.sdkState,r=t.requestQueue,i=new Xt({userId:n.userId,blockedUserId:e instanceof w?e.userId:e}),[4,r.send(i)];case 1:return s.sent(),[2]}}))}))},e.prototype.blockUserWithUserId=function(e){return p(this,void 0,void 0,(function(){return v(this,(function(t){return[2,this.blockUser(e)]}))}))},e.prototype.unblockUser=function(e){return p(this,void 0,void 0,(function(){var t,n,r,i;return v(this,(function(s){switch(s.label){case 0:return m(e instanceof w||c("string",e)).throw(y.invalidParameters),t=E.of(this._iid),n=t.sdkState,r=t.requestQueue,i=new Zt({userId:n.userId,unblockedUserId:e instanceof w?e.userId:e}),[4,r.send(i)];case 1:return s.sent(),[2]}}))}))},e.prototype.unblockUserWithUserId=function(e){return p(this,void 0,void 0,(function(){return v(this,(function(t){return[2,this.unblockUser(e)]}))}))},e.prototype.getFriendChangeLogsByToken=function(e){return p(this,void 0,void 0,(function(){var t,n,r,i,s;return v(this,(function(o){switch(o.label){case 0:return m(c("string",e)).throw(y.invalidParameters),t=E.of(this._iid),n=t.sdkState,r=t.requestQueue,i=new un({userId:n.userId,token:e}),[4,r.send(i)];case 1:return s=o.sent(),[2,s.as(cn).changelogs]}}))}))},e.prototype.getAllowFriendDiscovery=function(){return p(this,void 0,void 0,(function(){var e,t,n,r,i;return v(this,(function(s){switch(s.label){case 0:return e=E.of(this._iid),t=e.sdkState,n=e.requestQueue,r=new _n({userId:t.userId}),[4,n.send(r)];case 1:return i=s.sent(),[2,i.as(mn).allowFriendDiscovery]}}))}))},e.prototype.setAllowFriendDiscovery=function(e){return p(this,void 0,void 0,(function(){var t,n,r,i;return v(this,(function(s){switch(s.label){case 0:return m(c("boolean",e)).throw(y.invalidParameters),t=E.of(this._iid),n=t.sdkState,r=t.requestQueue,i=new yn({userId:n.userId,allowFriendDiscovery:e}),[4,r.send(i)];case 1:return s.sent(),[2,e]}}))}))},e.prototype.uploadFriendDiscoveries=function(e){return p(this,void 0,void 0,(function(){var t,n,r,i,s;return v(this,(function(o){switch(o.label){case 0:return t=E.of(this._iid),n=t.sdkState,r=t.requestQueue,i=new ln({userId:n.userId,discoveries:e}),[4,r.send(i)];case 1:return s=o.sent(),[2,s.as(hn).friendDiscoveryRequestId]}}))}))},e.prototype.deleteFriendDiscovery=function(e){return p(this,void 0,void 0,(function(){return v(this,(function(t){return[2,this.deleteFriendDiscoveries([e])]}))}))},e.prototype.deleteFriendDiscoveries=function(e){return p(this,void 0,void 0,(function(){var t,n,r,i;return v(this,(function(s){switch(s.label){case 0:return m(W("string",e)).throw(y.invalidParameters),t=E.of(this._iid),n=t.sdkState,r=t.requestQueue,i=new dn({userId:n.userId,discoveryKeys:e}),[4,r.send(i)];case 1:return s.sent(),[2]}}))}))},e.prototype.addFriends=function(e){return p(this,void 0,void 0,(function(){var t,n,r,i,s;return v(this,(function(o){switch(o.label){case 0:return m(W("string",e)).throw(y.invalidParameters),t=E.of(this._iid),n=t.sdkState,r=t.requestQueue,i=new fn({userId:n.userId,userIds:e}),[4,r.send(i)];case 1:return s=o.sent(),[2,s.as(pn).users]}}))}))},e.prototype.deleteFriend=function(e){return p(this,void 0,void 0,(function(){return v(this,(function(t){return[2,this.deleteFriends([e])]}))}))},e.prototype.deleteFriends=function(e){return p(this,void 0,void 0,(function(){var t,n,r,i;return v(this,(function(s){switch(s.label){case 0:return m(W("string",e)).throw(y.invalidParameters),t=E.of(this._iid),n=t.sdkState,r=t.requestQueue,i=new vn({userId:n.userId,userIds:e}),[4,r.send(i)];case 1:return s.sent(),[2]}}))}))},e.prototype.getAllEmoji=function(){return p(this,void 0,void 0,(function(){var e,t,n;return v(this,(function(r){switch(r.label){case 0:return e=E.of(this._iid).requestQueue,t=new wn,[4,e.send(t)];case 1:return n=r.sent(),[2,n.as(kn).emojiContainer]}}))}))},e.prototype.getEmojiCategory=function(e){return p(this,void 0,void 0,(function(){var t,n,r;return v(this,(function(i){switch(i.label){case 0:return t=E.of(this._iid).requestQueue,n=new Nn({categoryId:e}),[4,t.send(n)];case 1:return r=i.sent(),[2,r.as(Sn).emojiCategory]}}))}))},e.prototype.getEmoji=function(e){return p(this,void 0,void 0,(function(){var t,n,r;return v(this,(function(i){switch(i.label){case 0:return t=E.of(this._iid).requestQueue,n=new Tn({key:e}),[4,t.send(n)];case 1:return r=i.sent(),[2,r.as(On).emoji]}}))}))},e}();export{wt as A,Rn as B,tt as C,rt as D,bn as E,Un as F,Ne as G,ke as H,Ie as I,we as J,et as K,nt as L,bt as M,it as N,ze as P,ft as S,yt as U,Tt as a,Ve as b,Ot as c,ht as d,St as e,st as f,ct as g,He as h,lt as i,Nt as j,vt as k,_t as l,We as m,Xe as n,Ee as o,ot as p,at as q,Se as r,Te as s,Ze as t,Mr as u,pt as v,Ln as w,In as x,En as y,Cr as z}; diff --git a/__bundle-0a632c33.js b/__bundle-1abffbb6.js similarity index 70% rename from __bundle-0a632c33.js rename to __bundle-1abffbb6.js index c6638ef..10db9c4 100644 --- a/__bundle-0a632c33.js +++ b/__bundle-1abffbb6.js @@ -1 +1 @@ -var e=function(t,n){return e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n])},e(t,n)};function t(t,n){if("function"!=typeof n&&null!==n)throw new TypeError("Class extends value "+String(n)+" is not a constructor or null");function r(){this.constructor=t}e(t,n),t.prototype=null===n?Object.create(n):(r.prototype=n.prototype,new r)}var n=function(){return n=Object.assign||function(e){for(var t,n=1,r=arguments.length;n0&&i[i.length-1])||6!==s[0]&&2!==s[0])){o=0;continue}if(3===s[0]&&(!i||s[1]>i[0]&&s[1]=e.length&&(e=void 0),{value:e&&e[r++],done:!e}}};throw new TypeError(t?"Object is not iterable.":"Symbol.iterator is not defined.")}function o(e,t){var n="function"==typeof Symbol&&e[Symbol.iterator];if(!n)return e;var r,i,s=n.call(e),o=[];try{for(;(void 0===t||t-- >0)&&!(r=s.next()).done;)o.push(r.value)}catch(e){i={error:e}}finally{try{r&&!r.done&&(n=s.return)&&n.call(s)}finally{if(i)throw i.error}}return o}function a(e,t,n){if(n||2===arguments.length)for(var r,i=0,s=t.length;i0&&_.indexOf(e)>=0},S=function(e,t){if(void 0===t&&(t=!1),t&&null===e)return!0;var n=y("object",e)&&null!==e&&e.hasOwnProperty("name")&&"string"==typeof e.name&&e.hasOwnProperty("uri")&&"string"==typeof e.uri&&e.hasOwnProperty("type")&&"string"==typeof e.type;if(!n){if("undefined"!=typeof Blob)return e instanceof Blob;if("undefined"!=typeof File)return e instanceof File}return n},T=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=a([],o(e),!1).sort(),r=a([],o(t),!1).sort(),i=0;i=1e3&&e<=9e3&&(this._typingIndicatorThrottle=e)},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"websocketResponseTimeout",{get:function(){return this._websocketResponseTimeout},set:function(e){y("number",e)&&e>=5e3&&e<=3e4&&(this._websocketResponseTimeout=e)},enumerable:!1,configurable:!0}),e}(),N={key:"__ev",value:{k:"__ev",v:"scs"},generation:1},A={encrypt:function(e){return e},decrypt:function(e){return e}},C=function(){function e(e){var t=e.store;this._preference=new Map,this._store=t}return e.prototype._savePreferenceKeys=function(){return r(this,void 0,void 0,(function(){return i(this,(function(e){switch(e.label){case 0:return[4,this._store.set({key:this._keysAddress,value:a([],o(this._preference.keys()),!1),generation:1})];case 1:return e.sent(),[2]}}))}))},e.prototype.init=function(e){var t;return r(this,void 0,void 0,(function(){var n,r,o,a,u,c,l,d;return i(this,(function(i){switch(i.label){case 0:return this._keysAddress=e,[4,this._store.get(e)];case 1:n=null!==(t=i.sent())&&void 0!==t?t:[],i.label=2;case 2:i.trys.push([2,7,8,9]),r=s(n),o=r.next(),i.label=3;case 3:return o.done?[3,6]:(a=o.value,[4,this._store.get(a)]);case 4:(u=i.sent())&&this._preference.set(a,u),i.label=5;case 5:return o=r.next(),[3,3];case 6:return[3,9];case 7:return c=i.sent(),l={error:c},[3,9];case 8:try{o&&!o.done&&(d=r.return)&&d.call(r)}finally{if(l)throw l.error}return[7];case 9:return[2]}}))}))},e.prototype.get=function(e){var t;return r(this,void 0,void 0,(function(){return i(this,(function(n){return[2,null!==(t=this._preference.get(e))&&void 0!==t?t:null]}))}))},e.prototype.set=function(e,t){return r(this,void 0,void 0,(function(){var n;return i(this,(function(r){switch(r.label){case 0:return n=!this._preference.has(e),[4,this._store.set({key:e,value:t,generation:1})];case 1:return r.sent(),this._preference.set(e,t),n?[4,this._savePreferenceKeys()]:[3,3];case 2:r.sent(),r.label=3;case 3:return[2]}}))}))},e.prototype.remove=function(e){return r(this,void 0,void 0,(function(){return i(this,(function(t){switch(t.label){case 0:return[4,this._store.remove(e)];case 1:return t.sent(),this._preference.delete(e),[4,this._savePreferenceKeys()];case 2:return t.sent(),[2]}}))}))},e.prototype.clear=function(){return r(this,void 0,void 0,(function(){return i(this,(function(e){switch(e.label){case 0:return[4,this._store.removeMany(a([],o(this._preference.keys()),!1))];case 1:return e.sent(),this._preference.clear(),[4,this._savePreferenceKeys()];case 2:return e.sent(),[2]}}))}))},e}(),O=function(e){var t=e.encryption,n=void 0===t?null:t,r=e.store,i=void 0===r?null:r,s=e.localCacheEnabled,o=void 0===s||s;this.nestdb=null,this.store=i,this.preference=new C({store:i}),this.encryption=null!=n?n:A,this.localCacheEnabled=o},w=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}(),R=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)}))},D=function(){function e(e){var t=e.container;this._container={},this._container=t,this.key=R()}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}(),M=function(){function e(){this._container={}}return e.prototype.on=function(e,t){return new D({container:this._container}).on(e,t)},e.prototype.once=function(e,t){return new D({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()),u=a.next();!u.done;u=a.next()){var c=u.value,l=i.get(c);l.handler(t),l.occurence>0&&(l.occurence--,0===l.occurence&&o.push(c))}}catch(e){n={error:e}}finally{try{u&&!u.done&&(r=a.return)&&r.call(a)}finally{if(n)throw n.error}}o.forEach((function(e){return i.delete(e)}))}},e}(),k=function(){function e(){this._dispatcher=new M}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}(),L=function(){},U=function(e){var t={};return e&&Object.keys(e).forEach((function(n){void 0!==e[n]&&NaN!==e[n]&&null!==e[n]&&(t[n]=e[n])})),t};!function(e){e.GET="GET",e.POST="POST",e.PUT="PUT",e.DELETE="DELETE"}(d||(d={}));var P,q=function(e){function n(){var t=null!==e&&e.apply(this,arguments)||this;return t.params={},t.requireAuth=!0,t.headers={},t.requestId=R(),t}return t(n,e),n.prototype.stringifyParams=function(e){return"object"!=typeof e||Array.isArray(e)?String(e):e?JSON.stringify(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=U(this.params);return"?".concat(Object.keys(t).map((function(n){return"".concat(encodeURIComponent(n),"=").concat(e.encodeParams(t[n]))})).join("&"))},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"payload",{get:function(){var e=this,t=U(this.params);if(Object.keys(t).some((function(e){return S(t[e])}))){var n=new FormData;return Object.keys(t).forEach((function(r){var i,s=t[r];if(S(s)){var o=s;n.append(r,o,null!==(i=o.name)&&void 0!==i?i:"filename")}else n.append(r,e.stringifyParams(s))})),n}return JSON.stringify(t)},enumerable:!1,configurable:!0}),n}(L),x=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}(L),F=function(e){function n(t){var n=e.call(this)||this;return n.requestId=t,n}return t(n,e),n}(L),G=function(e){function n(){return null!==e&&e.apply(this,arguments)||this}return t(n,e),n}(L),Q=function(e){function n(t){var n=e.call(this)||this;return n.statLog=t,n}return t(n,e),n}(L);!function(e){e.WEBSOCKET_CONNECT="ws:connect",e.API_RESULT="api:result"}(P||(P={}));var j,K=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 U({stat_type:e.type,ts:e.createdAt,data:U(e.data)})},e}(),V=function(){return"undefined"==typeof document&&"undefined"!=typeof navigator&&"ReactNative"==navigator.product},z=function(){function e(e,t){var n=t.auth,r=t.sdkState,i=t.dispatcher,s=t.logger,o=this;this._abortControl=new Map,this._iid=e,this._auth=n,this._sdkState=r,this._dispatcher=i,this._dispatcher.on((function(e){e instanceof F&&o.cancel(e.requestId)})),this._logger=s}return Object.defineProperty(e.prototype,"_userAgentWithExtension",{get:function(){var e=this._sdkState.extensions,t=V()?"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(l.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,s=r.appVersion,o=n(n({},e.headers),{SendBird:"JS,".concat(l.OS_VERSION,",").concat(l.SDK_VERSION,",").concat(i).concat(s?",".concat(s):""),"SB-User-Agent":encodeURIComponent(this._userAgentWithExtension),"Request-Sent-Timestamp":Date.now().toString()});return t||(o["Content-Type"]="application/json; charset=utf-8"),e.requireAuth&&this._auth.hasSession&&(o["Session-Key"]=this._auth.sessionKey),this._auth&&this._auth.authToken&&(o["App-Id"]=i,o["Access-Token"]=this._auth.authToken),o},e.prototype._statLogApiResult=function(e,t,n){this._dispatcher.dispatch(new Q(new K({type:P.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 r(this,void 0,void 0,(function(){var t,n,r,s,o,a,u,c,l,h,f,_,g,y,m;return i(this,(function(i){switch(i.label){case 0:t=e.path,n=e.method,r=![d.GET,d.DELETE].includes(n),s=this._sdkState.api,o="".concat(s.host).concat(t).concat(r?"":e.query),a=r?e.payload:null,u=this._createHeader(e,a instanceof FormData?a:null),c=new AbortController,l=c.signal,this._abortControl.set(e.requestId,c),h=Date.now(),i.label=1;case 1:return i.trys.push([1,4,,5]),[4,fetch(o,{method:n,body:a,headers:u,signal:l})];case 2:return[4,(f=i.sent()).json()];case 3:if(_=i.sent(),f.ok||f.redirected)return this._logger.debug("receive api response",e.requestId),this._statLogApiResult(e,h,null),[2,new x(this._iid,_)];throw _?(g=new p(_),!e.requireAuth&&g.isSessionKeyExpiredError&&this._dispatcher.dispatch(new G),this._statLogApiResult(e,h,g),g):(g=p.requestFailed,this._statLogApiResult(e,h,g),g);case 4:throw y=i.sent(),this._statLogApiResult(e,h,y),y instanceof p?(this._logger.debug("fail api request",y),y):"AbortError"===y.name?p.requestCanceled:(m=p.networkError,this._logger.debug("fail api request",m),m);case 5:return[2]}}))}))},e.prototype.cancel=function(e){this._abortControl.has(e)&&(this._abortControl.get(e).abort(),this._abortControl.delete(e))},e.prototype.cancelAll=function(){var e,t;try{for(var n=s(this._abortControl.values()),r=n.next();!r.done;r=n.next()){r.value.abort()}}catch(t){e={error:t}}finally{try{r&&!r.done&&(t=n.return)&&t.call(n)}finally{if(e)throw e.error}}this._abortControl.clear()},e}(),B=function(e){function n(t,n,r,i){void 0===i&&(i="");var s,o=this;return(o=e.call(this)||this)._iid=t,o.code=n,o.payload=r,o.requestId=r?null!==(s=r.req_id)&&void 0!==s?s: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}(L),H=function(e){function n(t){var n,r=t.code,i=t.ackRequired,s=t.payload,o=void 0===s?null:s,a=this;return(a=e.call(this)||this).code=r,a.payload=o,a.requestId=null!==(n=a.payload.req_id)&&void 0!==n?n:R(),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}(L),W=function(e){function n(){return e.call(this,{code:"PING",payload:{id:Date.now(),active:1},ackRequired:!1})||this}return t(n,e),n}(H),Y=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 W;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}(),X=function(){};!function(e){e.CONNECTING="CONNECTING",e.OPEN="OPEN",e.CLOSED="CLOSED"}(j||(j={}));var J,Z=function(e){function n(t,n){var r=n.sdkState,i=n.dispatcher,s=n.logger,o=e.call(this)||this;return o._pinger=null,o.lastActive=0,o._iid=t,o._sdkState=r,o._dispatcher=i,o._logger=s,o._sdkState.websocket.pingerDisabled||(o._pinger=new Y({pingDelegate:{send:function(e){return o.send(e)},error:function(e){return o.error(e)}},sdkState:o._sdkState,logger:s})),o}return t(n,e),Object.defineProperty(n.prototype,"connectionState",{get:function(){if(this._ws)switch(this._ws.readyState){case 0:return j.CONNECTING;case 1:return j.OPEN}return j.CLOSED},enumerable:!1,configurable:!0}),n.prototype.connect=function(e){var t=this;this._ws=new WebSocket(e),this._ws.onopen=function(){t._logger.debug("websocket open"),t.dispatch("open")},this._ws.onmessage=function(e){e.data.split("\n").forEach((function(e){if(e&&y("string",e)){var n=B.createFromRawMessage(t._iid,e);t._logger.debug("receive websocket event",n),"LOGI"===n.code?(n.payload&&!n.payload.error&&t._pinger&&t._pinger.start(),t.dispatch("message",n)):"PONG"===n.code?t._pinger&&t._pinger.pong():"EXPR"===n.code?n.payload&&n.payload.expires_in>=0&&t._dispatcher.dispatch(new G):"NOOP"===n.code||t.dispatch("message",n)}}))},this._ws.onerror=function(){t._logger.debug("websocket error"),t._pinger&&t._pinger.stop(),t.dispatch("error",p.networkError)},this._ws.onclose=function(){t._logger.debug("websocket close"),t._pinger&&t._pinger.stop(),t.dispatch("close")},this.lastActive=Date.now()},n.prototype.disconnect=function(){var e=this;this._logger.debug("websocket disconnect"),this._pinger&&this._pinger.stop(),this._ws&&(this._ws.onopen=X,this._ws.onmessage=X,this._ws.onerror=X,this._ws.onclose=function(){e.dispatch("close")},this._ws.close(),this._ws=null)},n.prototype.send=function(e){if(!this._ws)throw p.connectionClosed;"PING"!==e.code?this._pinger&&this._pinger.refreshTimer():this._logger.debug("send ping",e),this._ws.send(e.convertToMessage())},n.prototype.error=function(e){this._logger.debug("websocket error",e),this._pinger&&this._pinger.stop(),this.dispatch("error",e)},n}(M),$=function(e){function n(t){var n=t.all,r=t.custom_types,i=t.ts,s=e.call(this)||this;return s.all=n,s.customTypes=r,s.ts=i,s}return t(n,e),n}(L),ee=function(){var e=this;this.promise=new Promise((function(t,n){e.resolve=t,e.reject=n}))},te=function(){function e(e,t){var n=t.auth,r=t.sdkState,i=t.dispatcher,s=t.logger,o=this;this._ackStateMap=new Map,this._sdkState=r,this._dispatcher=i,this._logger=s,this.apiClient=new z(e,{auth:n,sdkState:r,dispatcher:i,logger:s}),this.websocketClient=new Z(e,{sdkState:r,dispatcher:i,logger:s}),this.websocketClient.on("message",(function(e){if(e.payload.unread_cnt&&o._dispatcher.dispatch(new $(e.payload.unread_cnt)),e.requestId){if(o._ackStateMap.has(e.requestId)){var t=o._ackStateMap.get(e.requestId);"EROR"!==e.code?t.resolve(e):t.reject(new p({code:e.payload.code,message:e.payload.message}))}}else o._dispatcher.dispatch(e)})).on("close",(function(){o._ackStateMap.forEach((function(e){e.reject(p.connectionClosed)})),o._ackStateMap.clear()}))}return e.prototype._sendApiRequest=function(e){return r(this,void 0,void 0,(function(){return i(this,(function(t){switch(t.label){case 0:return[4,this.apiClient.send(e)];case 1:return[2,t.sent()]}}))}))},e.prototype._sendWebsocketRequest=function(e){return r(this,void 0,void 0,(function(){var t,n,r,s=this;return i(this,(function(i){if(t=new ee,e.ackRequired){n=null,r=function(r,i){void 0===r&&(r=null),void 0===i&&(i=null),s._ackStateMap.has(e.requestId)&&(s._ackStateMap.delete(e.requestId),n&&(clearTimeout(n),n=null),r?(s._logger.debug("fail websocket request",r),t.reject(r)):(s._logger.debug("receive websocket ack",e.requestId),t.resolve(i)))};try{n=setTimeout((function(){return r(p.noAckTimeout)}),this._sdkState.websocket.responseTimeout),this._ackStateMap.set(e.requestId,{resolve:function(e){return r(null,e)},reject:function(e){return r(e)}}),this.websocketClient.send(e)}catch(e){r(e)}}else try{this.websocketClient.send(e),t.resolve(null)}catch(e){t.reject(e)}return[2,t.promise]}))}))},e.prototype.send=function(e){return r(this,void 0,void 0,(function(){return i(this,(function(t){switch(t.label){case 0:return e instanceof q?[4,this._sendApiRequest(e)]:[3,2];case 1:case 3:return[2,t.sent()];case 2:return e instanceof H?[4,this._sendWebsocketRequest(e)]:[3,4];case 4:throw p.invalidParameters}}))}))},e.prototype.cancel=function(e){this.apiClient.cancel(e)},e.prototype.cancelAll=function(){this.apiClient.cancelAll()},e}();!function(e){e[e.NONE=0]="NONE",e[e.INITIALIZED=1]="INITIALIZED",e[e.CONNECTING=2]="CONNECTING",e[e.CONNECTED=3]="CONNECTED",e[e.RECONNECTING=4]="RECONNECTING",e[e.DISCONNECTED=5]="DISCONNECTED",e[e.LOGOUT=6]="LOGOUT"}(J||(J={}));var ne,re,ie,se,oe,ae,ue,ce,le,de=function(e){function n(t){var n=t.stateType,r=e.call(this)||this;return r.stateType=n,r}return t(n,e),n}(L),he=function(){function e(e,t){var n=t.auth,s=t.sdkState,o=t.dispatcher,a=t.logger,u=this;this._currentConnectionStateType=J.INITIALIZED,this._lazyCallQueue=[],this.commandRouter=new te(e,{auth:n,sdkState:s,dispatcher:o,logger:a}),this._auth=n,this._logger=a,this._dispatcher=o,this._dispatcher.on((function(e){if(e instanceof de){var t=e.stateType;switch(u._currentConnectionStateType=t,t){case J.CONNECTED:var n=u._lazyCallQueue;u._lazyCallQueue=[],n.forEach((function(e){return r(u,void 0,void 0,(function(){var t,n,r,s,o;return i(this,(function(i){switch(i.label){case 0:t=e.command,n=e.deferred,r=e.timeout,clearTimeout(r),i.label=1;case 1:return i.trys.push([1,3,,4]),[4,this.send(t)];case 2:return s=i.sent(),n.resolve(s),[3,4];case 3:return o=i.sent(),n.reject(o),[3,4];case 4:return[2]}}))}))}));break;case J.INITIALIZED:case J.DISCONNECTED:case J.LOGOUT:n=u._lazyCallQueue;u._lazyCallQueue=[],n.forEach((function(e){return r(u,void 0,void 0,(function(){var t,n;return i(this,(function(r){return t=e.deferred,n=e.timeout,clearTimeout(n),this._auth&&this._auth.hasSession?t.reject(p.connectionClosed):t.reject(p.connectionRequired),[2]}))}))}))}}}))}return Object.defineProperty(e.prototype,"isReady",{get:function(){return this._currentConnectionStateType===J.CONNECTED},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"isLazyCallActivated",{get:function(){return this._currentConnectionStateType===J.CONNECTING||this._currentConnectionStateType===J.RECONNECTING},enumerable:!1,configurable:!0}),e.prototype.send=function(e){return r(this,void 0,void 0,(function(){var t,n,r=this;return i(this,(function(i){switch(i.label){case 0:return e instanceof H?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 ee,this._lazyCallQueue.push({command:e,deferred:t,timeout:setTimeout((function(){return r.timeout(e.requestId)}),1e4)}),[2,t.promise];throw this._logger.debug("fail websocket request"),p.connectionRequired;case 3:return[3,7];case 4:return e instanceof q?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 ee,this._lazyCallQueue.push({command:e,deferred:t,timeout:setTimeout((function(){return r.timeout(e.requestId)}),1e4)}),[2,t.promise];throw n=p.connectionRequired,this._logger.debug("fail api request",n),n;case 7:return[2]}}))}))},e.prototype.forceSend=function(e){return r(this,void 0,void 0,(function(){return i(this,(function(t){switch(t.label){case 0:return this._logger.debug("send 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(p.connectionRequired),this._lazyCallQueue.splice(t,1))},e.prototype.cancel=function(e){this._logger.debug("cancel api request",e),this.commandRouter.cancel(e)},e.prototype.cancelAll=function(){this._logger.debug("cancel all api requests"),this.commandRouter.cancelAll()},e}(),pe="/".concat("v3","/users"),fe="/".concat("v3","/storage/file"),_e="/".concat("v3","/group_channels"),ge="/".concat("v3","/sdk/group_channels"),ye="/".concat("v3","/open_channels"),me="/".concat("v3","/sdk/open_channels"),ve="/".concat("v3","/search"),Ee="/".concat("v3","/report"),Ie="/".concat("v3","/emojis"),Se="/".concat("v3","/emoji_categories"),Te="/".concat("v3","/polls"),be="/".concat("v3","/scheduled_messages"),Ne="/".concat("v3","/sdk/statistics"),Ae=function(e){function n(t){var n=t.userId,r=t.authToken,i=t.expiringSession,s=void 0===i||i,o=e.call(this)||this;return o.path="".concat(pe,"/").concat(n,"/session_key"),o.method=d.POST,o.params={token:r,expiring_session:!!s},o.requireAuth=!1,o}return t(n,e),n}(q),Ce=function(e){function n(t){var n=t.authToken,r=t.expiringSession,i=void 0===r||r;return e.call(this,{code:"LOGI",payload:{token:n,expiring_session:i?1:0},ackRequired:!0})||this}return t(n,e),n}(H),Oe=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}(x),we=function(e){function n(t,n,r){var i=e.call(this,t,"LOGI",r)||this;return i.error=null,i.newKey=r.new_key,i.error=r.error?new p(r.error):null,i}return t(n,e),n}(B),Re=function(e){function n(){return null!==e&&e.apply(this,arguments)||this}return t(n,e),n}(L),De=function(e){return r(void 0,void 0,void 0,(function(){return i(this,(function(t){return[2,new Promise((function(t){return setTimeout(t,e)}))]}))}))},Me=function(){function e(){}return e.prototype.calcTimeout=function(){return 0},e}(),ke=function(e,t,n){return void 0===n&&(n=new Me),r(void 0,void 0,void 0,(function(){var r,s,o,a,u,c;return i(this,(function(i){switch(i.label){case 0:r=0,s=null,o=function(e){return void 0===e&&(e=null),s=null!=e?e:new Error("Halted")},a=function(){r=0},i.label=1;case 1:if(!(-1===t||r0?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 dt({userProfile:this}))},e}(),pt=function(e){function r(t,n,r){var i,s=this;return(s=e.call(this,t,n,r)||this).error=null,s.userProfile=new ht(t,r),s.key=r.key,s.ekey=null!==(i=r.ekey)&&void 0!==i?i:"",s.error=r.error?new p(r):null,s}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){if(this.error)throw this.error;var t=Tt.of(e);if(!t)throw p.lostInstance;t.sessionManager.auth.sessionKey=this.key,ze(e,this.ekey),this.userProfile.apply()},r}(B),ft=function(e){function n(t){var n=e.call(this)||this;return n.enabled=t,n}return t(n,e),n}(L),_t=function(e){function n(t,n){var r=n.sdkState,i=n.cacheContext,s=n.connectionHandlers,o=n.sessionManager,a=n.websocketClient,u=n.dispatcher,c=n.logger,l=n.entryState,d=void 0===l?new Ke:l,h=e.call(this)||this;return h._currentState=null,h._loginTimer=null,h._connectingAt=0,h._connectionRequestQueue=[],h._iid=t,h.sdkState=r,h.cacheContext=i,h.connectionHandlers=s,h._sessionManager=o,h._websocketClient=a,h._dispatcher=u,h._logger=c,h._currentState=d,h._websocketClient.on("message",(function(e){if("LOGI"===e.code){h._loginTimer&&(clearTimeout(h._loginTimer),h._loginTimer=null);var t=e.as(pt);if(t.error)(t.error.isSessionKeyExpiredError||t.error.isSessionTokenExpiredError)&&h._dispatcher.dispatch(new G),h._connectionRequestQueue.forEach((function(e){return e.reject(t.error)})),h._statLogConnection(t.error);else{t.applyTo(h._iid),h._connectionRequestQueue.forEach((function(e){return e.resolve()}));var n=t.userProfile;h._enableStatLog(n.appInfo.applicationAttributes.includes("allow_sdk_request_log_publish")),h._statLogConnection(null)}h._connectionRequestQueue=[]}})).on("close",(function(){h._connectionRequestQueue.length>0&&(h._connectionRequestQueue.forEach((function(e){return e.reject(p.networkError)})),h._connectionRequestQueue=[],h._statLogConnection(p.networkError))})),h}return t(n,e),Object.defineProperty(n.prototype,"currentState",{get:function(){return this._currentState},enumerable:!1,configurable:!0}),n.prototype.changeState=function(e){return r(this,void 0,void 0,(function(){return i(this,(function(t){switch(t.label){case 0:return this._currentState=e,this._dispatcher.dispatch(new de({stateType:e.type})),this._logger.debug("connection state changes to ".concat(e.name)),[4,this._currentState.run(this)];case 1:return t.sent(),[2]}}))}))},n.prototype._url=function(e){void 0===e&&(e="");var t=this.sdkState,n=t.appId,r=t.appVersion,i=t.userId,s=t.extensions,o=this.cacheContext.localCacheEnabled,a=this._sessionManager.auth,u=s.sb_syncmanager?"s".concat(s.sb_syncmanager):"",c=s.sb_uikit?"u".concat(s.sb_uikit):"",d="JS/c".concat(l.SDK_VERSION,"/").concat(u,"/").concat(c);return"".concat(this.sdkState.websocket.host,"/?p=JS&pv=").concat(encodeURIComponent(l.OS_VERSION),"&sv=").concat(encodeURIComponent(l.SDK_VERSION),"&ai=").concat(n).concat(r?"&av=".concat(r):"").concat(a.hasSession?"&key=".concat(encodeURIComponent(a.sessionKey)):"&user_id=".concat(encodeURIComponent(i),"&access_token=").concat(encodeURIComponent(e)),"&active=1&SB-User-Agent=").concat(d,"&Request-Sent-Timestamp=").concat(Date.now().toString(),"&include_extra_data=").concat(encodeURIComponent(String(["premium_feature_list","file_upload_size_limit","application_attributes","emoji_hash"]))).concat(this._sessionManager.handler?"&expiring_session=1":"","&use_local_cache=").concat(o?1:0,"&include_poll_details=1")},n.prototype._enableStatLog=function(e){this._dispatcher.dispatch(new ft(e))},n.prototype._statLogConnection=function(e){this._dispatcher.dispatch(new Q(new K({type:P.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=""),r(this,void 0,void 0,(function(){var t,n,r=this;return i(this,(function(i){return t=this._url(e),n=new ee,this._connectionRequestQueue.push(n),1===this._connectionRequestQueue.length&&(this._connectingAt=Date.now(),this._loginTimer=setTimeout((function(){r._loginTimer=null,r._dispatcher.dispatch(pt.asError(p.loginTimeout))}),this.sdkState.websocket.responseTimeout),this._websocketClient.connect(t)),[2,n.promise]}))}))},n.prototype.cancelConnectForRetry=function(){this._dispatcher.dispatch(pt.asError(p.connectionRenew))},n.prototype.disconnect=function(){this._websocketClient.disconnect()},n.prototype.logout=function(){this.sdkState.userId=null,this._sessionManager.currentUser=null,this._sessionManager.auth.clear(),this.disconnect()},n}(M),gt=function(){function e(e,t){var n=t.sdkState,r=t.cacheContext,i=t.connectionHandlers,s=t.sessionManager,o=t.websocketClient,a=t.dispatcher,u=t.logger,c=t.disableAutoReconnect,l=void 0!==c&&c,d=this;this._context=null,this._logger=u,this._context=new _t(e,{sdkState:n,cacheContext:r,connectionHandlers:i,sessionManager:s,websocketClient:o,dispatcher:a,logger:u}),l||(s.on("refresh-authtoken",(function(){d.isConnected||(d._logger.debug("try reconnect by session token refresh"),d.reconnect())})).on("refresh",(function(){d.isConnecting||d.isConnected||(d._logger.debug("try reconnect by session key refresh"),d.reconnect())})),o.on("close",(function(){"foreground"===n.appState&&setTimeout((function(){s.isRefreshingAuthToken||(d._logger.debug("try reconnect by websocket connection closed"),d.reconnect())}),100)})))}return Object.defineProperty(e.prototype,"isConnected",{get:function(){return this._context.currentState.type===J.CONNECTED},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"isConnecting",{get:function(){var e=this._context.currentState;return e.type===J.CONNECTING||e.type===J.RECONNECTING},enumerable:!1,configurable:!0}),e.prototype.connect=function(e){return r(this,void 0,void 0,(function(){return i(this,(function(t){switch(t.label){case 0:return[4,this._context.currentState.onConnect(this._context,e)];case 1:return t.sent(),[2]}}))}))},e.prototype.reconnect=function(){return r(this,void 0,void 0,(function(){return i(this,(function(e){switch(e.label){case 0:return[4,this._context.currentState.onReconnect(this._context,{})];case 1:return e.sent(),[2]}}))}))},e.prototype.resetAndReconnect=function(){return r(this,void 0,void 0,(function(){return i(this,(function(e){switch(e.label){case 0:return[4,this._context.currentState.onReconnect(this._context,{resetReconnectCount:!0})];case 1:return e.sent(),[2]}}))}))},e.prototype.background=function(){return r(this,void 0,void 0,(function(){return i(this,(function(e){switch(e.label){case 0:return[4,this._context.currentState.onDisconnect(this._context,{autoReconnect:!1})];case 1:return e.sent(),[2]}}))}))},e.prototype.disconnect=function(e){return void 0===e&&(e=null),r(this,void 0,void 0,(function(){return i(this,(function(t){switch(t.label){case 0:return[4,this._context.currentState.onDisconnect(this._context,{error:e,autoReconnect:!0})];case 1:return t.sent(),[2]}}))}))},e.prototype.logout=function(){return r(this,void 0,void 0,(function(){return i(this,(function(e){switch(e.label){case 0:return[4,this._context.currentState.onLogout(this._context)];case 1:return e.sent(),[2]}}))}))},e}(),yt=function(e){function n(t){var n=t.deviceId,r=t.statLogs,i=e.call(this)||this;return i.method=d.POST,i.path="".concat(Ne),i.params={device_id:n,log_entries:r.map((function(e){return K.payloadify(e)}))},i}return t(n,e),n}(q);!function(e){e[e.PENDING=0]="PENDING",e[e.ENABLED=1]="ENABLED",e[e.DISABLED=2]="DISABLED"}(ct||(ct={}));var mt,vt=function(){function e(e){var t=e.cacheContext,n=e.requestQueue,r=e.dispatcher,i=e.baseLimit,s=void 0===i?100:i,o=e.maxLimit,a=void 0===o?1e3:o,u=e.minLimit,c=void 0===u?10:u;this.queue=[],this.enabledstate=ct.PENDING,this.isFlushing=!1,this.generation=1,this.lastFlushedAt=0,this.deviceId=R(),this.cacheContext=t,this.requestQueue=n,this.dispatcher=r,this.baseLimit=s,this.limit=s,this.maxLimit=a,this.minLimit=c}return Object.defineProperty(e.prototype,"isEnabled",{get:function(){return this.enabledstate===ct.ENABLED},enumerable:!1,configurable:!0}),e.prototype._save=function(){return r(this,void 0,void 0,(function(){return i(this,(function(e){switch(e.label){case 0:return this.cacheContext.localCacheEnabled?[4,this.cacheContext.preference.set(this.key,{deviceId:this.deviceId,statLogs:this.queue.map((function(e){return K.payloadify(e)})),generation:this.generation++,lastFlushedAt:this.lastFlushedAt})]:[3,2];case 1:e.sent(),e.label=2;case 2:return[2]}}))}))},e.prototype._flush=function(){return r(this,void 0,void 0,(function(){var e,t;return i(this,(function(n){switch(n.label){case 0:if(!this.isEnabled)return[3,7];if(this.isFlushing)return[3,7];this.isFlushing=!0,n.label=1;case 1:return n.trys.push([1,5,6,7]),(e=this.queue.slice(0,Math.min(this.limit,this.maxLimit))).length>0?(t=new yt({deviceId:this.deviceId,statLogs:e}),[4,this.requestQueue.send(t)]):[3,4];case 2:return n.sent(),this.queue=this.queue.slice(e.length),[4,this._save()];case 3:n.sent(),n.label=4;case 4:return this.limit=this.baseLimit,this.lastFlushedAt=Date.now(),[3,7];case 5:return n.sent(),this.limit=this.limit+20,[3,7];case 6:return this.isFlushing=!1,[7];case 7:return[2]}}))}))},e.prototype.init=function(e){return r(this,void 0,void 0,(function(){var t,n,r=this;return i(this,(function(i){switch(i.label){case 0:return this.key=e,this.cacheContext.localCacheEnabled?[4,this.cacheContext.preference.get(this.key)]:[3,4];case 1:return(t=i.sent())?(this.deviceId=t.deviceId,this.queue=t.statLogs.map((function(e){return new K({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,De(n)]):[3,4]):[3,4];case 2:return i.sent(),[4,this._flush()];case 3:i.sent(),i.label=4;case 4:return this.dispatcher.on((function(e){if(e instanceof Q){var t=e.statLog;r.put(t)}else e instanceof ft&&(r.enabledstate=e.enabled?ct.ENABLED:ct.DISABLED,r.isEnabled?r.queue.length>=r.limit&&r._flush():r.clear())})),[2]}}))}))},e.prototype.put=function(e){return r(this,void 0,void 0,(function(){return i(this,(function(t){switch(t.label){case 0:return this.enabledstate===ct.DISABLED?[3,3]:(this.queue.push(e),[4,this._save()]);case 1:return t.sent(),this.queue.length>=this.limit?[4,this._flush()]:[3,3];case 2:t.sent(),t.label=3;case 3:return[2]}}))}))},e.prototype.clear=function(){return r(this,void 0,void 0,(function(){return i(this,(function(e){switch(e.label){case 0:return this.queue=[],this.generation=1,[4,this._save()];case 1:return e.sent(),[2]}}))}))},e}();!function(e){e[e.NONE=0]="NONE",e[e.VERBOSE=1]="VERBOSE",e[e.DEBUG=2]="DEBUG",e[e.INFO=3]="INFO",e[e.WARN=4]="WARN",e[e.ERROR=5]="ERROR"}(mt||(mt={}));var Et,It=function(){function e(){this.level=mt.WARN}return e.prototype.verbose=function(){for(var e=[],t=0;t0&&y("number",c)&&(this.key=i,this.userIds=u,this.updatedAt=c);var l={};try{for(var d=s(this.userIds),h=d.next();!h.done;h=d.next()){l[h.value]=this.updatedAt}}catch(e){t={error:e}}finally{try{h&&!h.done&&(n=d.return)&&n.call(d)}finally{if(t)throw t.error}}this._version=l}return Object.defineProperty(e.prototype,"isEmpty",{get:function(){return 0===this.userIds.length},enumerable:!1,configurable:!0}),e.payloadify=function(e){return e?U({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 Et.ADD:t<0&&this.userIds.push(e.userId);break;case Et.DELETE:t>=0&&this.userIds.splice(t,1)}this._version[e.userId]=e.updatedAt}this.updatedAt=Math.max(this.updatedAt,e.updatedAt)}},e}(),Mt=function(){function e(e){this.key=e.key,this.value=E("string",e.value)?a([],o(e.value),!1):[]}return e.payloadify=function(e){var t;return e?U({key:e.key,value:null!==(t=e.value)&&void 0!==t?t:[]}):null},e}(),kt=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?U({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}(),Lt=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 kt(e["og:image"]))}return e.payloadify=function(e){return e?U({"og:title":e.title,"og:url":e.url,"og:description":e.description,"og:image":e.defaultImage?kt.payloadify(e.defaultImage):null}):null},e}(),Ut=function(){function e(e){var t,n;this.name=null,this.volume=0,this.name=null!==(t=e.name)&&void 0!==t?t:"default",this.volume=null!==(n=e.volume)&&void 0!==n?n:1}return e.payloadify=function(e){return e?U({name:e.name,volume:e.volume}):null},e}();!function(e){e.PENDING="pending",e.SENT="sent",e.FAILED="failed",e.CANCELED="canceled"}(Ot||(Ot={})),function(e){e.PENDING="pending",e.IN_QUEUE="in_queue",e.SENT="sent",e.FAILED="failed",e.CANCELED="canceled",e.REMOVED="removed"}(wt||(wt={}));var Pt,qt=function(e){switch(e){case ie.BASE:return"";case ie.USER:return"MESG";case ie.FILE:return"FILE";case ie.ADMIN:return"ADMM"}},xt=function(e){function r(t,n){var r,i,s,o,a,u,c,l,d,h,p,f,_,g=this;(g=e.call(this,t)||this).channelUrl=null,g.channelType=ne.BASE,g.messageId=0,g.parentMessageId=null,g.parentMessage=null,g.silent=!1,g.isOperatorMessage=!1,g.messageType=ie.BASE,g.data=null,g.customType=null,g.mentionType=null,g.mentionedUsers=[],g.mentionedUserIds=[],g.mentionedMessageTemplate=null,g.threadInfo=null,g.reactions=[],g.metaArrays=[],g.ogMetaData=null,g.appleCriticalAlertOptions=null,g.createdAt=0,g.updatedAt=0,g.scheduledInfo=null,g._scheduledStatus=null,g.messageId=null!==(i=null!==(r=n.msg_id)&&void 0!==r?r:n.message_id)&&void 0!==i?i:0,g.channelUrl=n.channel_url,g.channelType=m(ne,n.channel_type)?n.channel_type:ne.GROUP,n.channel&&(n.channel.channel_url&&(g.channelUrl=n.channel.channel_url),n.channel.channel_type&&(g.channelType=n.channel.channel_type)),g.parentMessageId=null!==(s="string"==typeof n.parent_message_id?parseInt(n.parent_message_id):n.parent_message_id)&&void 0!==s?s:0,g.data=null!==(o=n.data)&&void 0!==o?o:"",g.customType=null!==(a=n.custom_type)&&void 0!==a?a:"",g.mentionType=m(ae,n.mention_type)?n.mention_type:null;var y=n.mentioned_users;g.mentionedUsers=y?y.map((function(e){return new lt(g._iid,e)})):null;var v=n.mentioned_user_ids;g.mentionedUserIds=null!=v?v:null,g.mentionedMessageTemplate=null!==(u=n.mentioned_message_template)&&void 0!==u?u:"",g.threadInfo=n.thread_info?new Ct(g._iid,n.thread_info):null,g.reactions=n.reactions?n.reactions.map((function(e){return new Dt(e)})):[];for(var E=null!==(c=n.metaarray)&&void 0!==c?c:{},I=null!==(l=n.metaarray_key_order)&&void 0!==l?l:Object.keys(E).sort((function(e,t){return e.localeCompare(t)})),S=0;S=t)return this.parentMessage=e,!0}return!1},r}(He),Ft=function(e){function r(t,n){var r=e.call(this,t,n)||this;return r.role=null,r.isBlockedByMe=!1,r.role=m(re,n.role)?n.role:re.NONE,n.hasOwnProperty("is_blocked_by_me")&&(r.isBlockedByMe=n.is_blocked_by_me),r}return t(r,e),r.payloadify=function(t){return t?U(n(n({},e.payloadify.call(this,t)),{role:t.role,is_blocked_by_me:t.isBlockedByMe})):null},r}(lt),Gt=function(e){function r(t,n){var r,i,s,o,a=this;if((a=e.call(this,t,n)||this).sender=null,a.reqId="",a.replyToChannel=!1,a.sendingStatus=null,a.errorCode=0,a.sender=n.user?new Ft(a._iid,n.user):n.sender_id,a.reqId=null!==(i=null!==(r=n.req_id)&&void 0!==r?r:n.request_id)&&void 0!==i?i:"",a.replyToChannel=null!==(s=n.is_reply_to_channel)&&void 0!==s&&s,n.request_state&&m(le,n.request_state)&&(a.sendingStatus=n.request_state),!a.sendingStatus)if(a.messageId>0)a.sendingStatus=le.SUCCEEDED;else if(a.scheduledInfo)switch(a._scheduledStatus=n.scheduled_status,n.scheduled_status){case wt.SENT:case wt.IN_QUEUE:a.sendingStatus=le.SUCCEEDED;break;case wt.PENDING:a.sendingStatus=le.SCHEDULED;break;case wt.FAILED:case wt.REMOVED:a.sendingStatus=le.FAILED;break;case wt.CANCELED:a.sendingStatus=le.CANCELED}else a.sendingStatus=le.PENDING;return a.errorCode=null!==(o=n.error_code)&&void 0!==o?o:0,a}return t(r,e),r.payloadify=function(t){return t?U(n(n({},e.payloadify.call(this,t)),{user:Ft.payloadify(t.sender),req_id:t.reqId,is_reply_to_channel:t.replyToChannel,request_state:t.sendingStatus,error_code:t.errorCode})):null},Object.defineProperty(r.prototype,"isResendable",{get:function(){return this.sendingStatus===le.FAILED&&((e=this.errorCode)>0&&f.indexOf(e)>=0);var e},enumerable:!1,configurable:!0}),r.prototype.isIdentical=function(e){return this.messageId>0&&e.messageId>0?this.messageId===e.messageId:this.reqId===e.reqId},r}(xt),Qt=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?U({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}(),jt={prevResultSize:0,nextResultSize:0,isInclusive:!1,reverse:!1,messageTypeFilter:se.ALL,customTypesFilter:null,senderUserIdsFilter:null,includeReactions:!1,includeMetaArray:!1,includeParentMessageInfo:!1},Kt=function(e){return y("number",e.prevResultSize)&&y("number",e.nextResultSize)&&y("boolean",e.isInclusive)&&y("boolean",e.reverse)&&y("string",e.messageTypeFilter)&&m(se,e.messageTypeFilter)&&E("string",e.customTypesFilter,!0)&&E("string",e.senderUserIdsFilter,!0)&&y("boolean",e.includeMetaArray)&&y("boolean",e.includeReactions)&&y("boolean",e.includeParentMessageInfo)},Vt=function(e){function s(t,r){var i,s,o,a,u=this;if((u=e.call(this,t,r)||this).message=null,u.translations={},u.message=null!==(i=r.message)&&void 0!==i?i:"",u.messageType=ie.ADMIN,u.translations=null!==(s=r.translations)&&void 0!==s?s:{},r.parent_message_info){var c=r.parent_message_info,l=n(n({},c),{message_id:u.parentMessageId,channel_url:u.channelUrl,channel_type:u.channelType,file:c.file,url:null===(o=c.file)||void 0===o?void 0:o.url,require_auth:null===(a=c.file)||void 0===a?void 0:a.require_auth});u.parentMessage=tn(t,l)}return u}return t(s,e),s.payloadify=function(t){return t?U(n(n({},e.payloadify.call(this,t)),{message:t.message,translations:t.translations,parent_message_info:en(t.parentMessage)})):null},s.prototype.getThreadedMessagesByTimestamp=function(e,t){return r(this,void 0,void 0,(function(){var r;return i(this,(function(i){switch(i.label){case 0:return r=n(n({},jt),t),ut(this.messageId>0&&y("number",e)&&Kt(r)).throw(p.invalidParameters),[4,Dn.of(this._iid).getThreadedMessagesByTimestamp(this,e,r)];case 1:return[2,i.sent()]}}))}))},s}(xt),zt=function(){function e(e){var t,n;this.type=null,this.vendor=null,this.detail={},this.type=null!==(t=e.type)&&void 0!==t?t:"",this.vendor=null!==(n=e.vendor)&&void 0!==n?n:"",e.hasOwnProperty("detail")&&y("object",e.detail)&&!Array.isArray(e.detail)&&(this.detail=e.detail)}return e.payloadify=function(e){return e?U({type:e.type,vendor:e.vendor,detail:e.detail}):null},e}();!function(e){e.OPEN="open",e.CLOSED="closed"}(Pt||(Pt={}));var Bt,Ht="removed",Wt=function(e){switch(e){case Pt.OPEN:return Pt.OPEN;case Pt.CLOSED:return Pt.CLOSED}},Yt=function(e){return!e||e.text&&y("string",e.text)},Xt=function(e){return E("string",e)&&e.every((function(e){return""!==e.trim()}))},Jt=function(e){function r(t,n){var r,i,s,o,a,u,c,l=this;return(l=e.call(this,t)||this).pollId=0,l.id=0,l.text=null,l.voteCount=0,l.createdBy=null,l.createdAt=0,l.updatedAt=0,l._lastVotedAt=0,l.pollId=null!==(r=n.poll_id)&&void 0!==r?r:0,l.id=null!==(i=n.id)&&void 0!==i?i:0,l.text=null!==(s=n.text)&&void 0!==s?s:null,l.voteCount=null!==(o=n.vote_count)&&void 0!==o?o:0,l.createdBy=null!==(a=n.created_by)&&void 0!==a?a:null,l.createdAt=null!==(u=n.created_at)&&void 0!==u?u:0,l.updatedAt=null!==(c=n.updated_at)&&void 0!==c?c:0,l}return t(r,e),r.payloadify=function(t){return t?U(n(n({},e.payloadify.call(this,t)),{vote_count:t.voteCount,poll_id:t.pollId,text:t.text,created_at:t.createdAt,id:t.id,created_by:t.createdBy,updated_at:t.updatedAt})):null},r}(He),Zt=function(e){function r(t,n){var r,i,s,o,a,u,c,l,d,h,p,f,_,g,y=this;return(y=e.call(this,t)||this).id=0,y.title=null,y.createdAt=0,y.updatedAt=0,y.closeAt=-1,y.status=Pt.CLOSED,y.messageId=0,y.data=null,y.voterCount=-1,y.options=[],y.createdBy=null,y.isAnonymous=!1,y.allowUserSuggestion=!1,y.allowMultipleVotes=!1,y.votedPollOptionIds=[],y.id=null!==(r=n.id)&&void 0!==r?r:0,y.title=null!==(i=n.title)&&void 0!==i?i:null,y.createdAt=null!==(s=n.created_at)&&void 0!==s?s:0,y.updatedAt=null!==(o=n.updated_at)&&void 0!==o?o:0,y.closeAt=null!==(a=n.close_at)&&void 0!==a?a:-1,y.status=null!==(u=Wt(n.status))&&void 0!==u?u:Pt.CLOSED,y.messageId=null!==(c=n.message_id)&&void 0!==c?c:0,y.data=null!==(l=n.data)&&void 0!==l?l:null,y.voterCount=null!==(d=n.voter_count)&&void 0!==d?d:-1,y.options=n.options?n.options.map((function(e){return new Jt(y._iid,e)})):[],y.createdBy=null!==(h=n.created_by)&&void 0!==h?h:null,y.isAnonymous=null!==(p=n.is_anonymous)&&void 0!==p&&p,y.allowUserSuggestion=null!==(f=n.allow_user_suggestion)&&void 0!==f&&f,y.allowMultipleVotes=null!==(_=n.allow_multiple_votes)&&void 0!==_&&_,y.votedPollOptionIds=null!==(g=n.voted_option_ids)&&void 0!==g?g:[],y}return t(r,e),r.prototype._applyPollUpdatePayload=function(e){var t,n,r,i,s,o,a,u,c,l=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!==(i=Wt(e.status))&&void 0!==i?i:this.status,this.data=null!==(s=e.data)&&void 0!==s?s:this.data,this.voterCount=null!==(o=e.voter_count)&&void 0!==o?o:this.voterCount,this.options=e.options?e.options.map((function(e){return new Jt(l._iid,e)})):this.options,this.isAnonymous=null!==(a=e.is_anonymous)&&void 0!==a?a:this.isAnonymous,this.allowUserSuggestion=null!==(u=e.allow_user_suggestion)&&void 0!==u?u:this.allowUserSuggestion,this.allowMultipleVotes=null!==(c=e.allow_multiple_votes)&&void 0!==c?c:this.allowMultipleVotes},r.payloadify=function(t){return t?U(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 Jt.payloadify(e)})),created_by:t.createdBy,is_anonymous:t.isAnonymous,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 s=t[r];i>s._lastVotedAt&&(s.voteCount=e.vote_count,s._lastVotedAt=i)}})),r.req_id&&r.voted_option_ids&&(this.votedPollOptionIds=r.voted_option_ids),!0},r}(He),$t=function(e){function o(t,r){var i,o,a,u,c,l,d,h=this;if((h=e.call(this,t,r)||this).message="",h.messageParams=null,h.translations={},h.translationTargetLanguages=[],h.messageSurvivalSeconds=-1,h.plugins=[],h._poll=null,h.message=r.message,h.messageType=ie.USER,h.translations=null!==(a=r.translations)&&void 0!==a?a:{},h.translationTargetLanguages=null!==(u=r.target_langs)&&void 0!==u?u:[],0===Object.keys(h.translations).length&&h.translationTargetLanguages.length>0)try{for(var p=s(h.translationTargetLanguages),f=p.next();!f.done;f=p.next()){var _=f.value;h.translations[_]=""}}catch(e){i={error:e}}finally{try{f&&!f.done&&(o=p.return)&&o.call(p)}finally{if(i)throw i.error}}if(h.messageSurvivalSeconds=null!==(c=r.message_survival_seconds)&&void 0!==c?c:-1,h.plugins=r.plugins?r.plugins.map((function(e){return new zt(e)})):[],h._poll=r.poll?new Zt(h._iid,r.poll):null,r.parent_message_info){var g=r.parent_message_info,y=n(n({},g),{created_at:g.ts,message_id:h.parentMessageId,channel_url:h.channelUrl,channel_type:h.channelType,file:g.file,url:null===(l=g.file)||void 0===l?void 0:l.url,require_auth:null===(d=g.file)||void 0===d?void 0:d.require_auth});h.parentMessage=tn(t,U(y))}return h}return t(o,e),o.payloadify=function(t){return t?U(n(n({},e.payloadify.call(this,t)),{message:t.message,translations:t.translations,message_survival_seconds:t.messageSurvivalSeconds,plugins:t.plugins.map((function(e){return zt.payloadify(e)})),poll:Zt.payloadify(t._poll),parent_message_info:en(t.parentMessage)})):null},o.prototype.getThreadedMessagesByTimestamp=function(e,t){return r(this,void 0,void 0,(function(){var r;return i(this,(function(i){switch(i.label){case 0:return r=n(n({},jt),t),ut(this.messageId>0&&y("number",e)&&Kt(r)).throw(p.invalidParameters),[4,Dn.of(this._iid).getThreadedMessagesByTimestamp(this,e,r)];case 1:return[2,i.sent()]}}))}))},o.prototype.applyPoll=function(e){return!(this._poll&&this._poll.id===e.id&&this._poll.updatedAt>e.updatedAt)&&(this._poll=e,!0)},Object.defineProperty(o.prototype,"poll",{get:function(){return this._poll},enumerable:!1,configurable:!0}),o}(Gt),en=function(e){if(e)switch(e.messageType){case ie.USER:return $t.payloadify(e);case ie.FILE:return nn.payloadify(e);case ie.ADMIN:return Vt.payloadify(e)}return null},tn=function(e,t){switch(t.type){case"MESG":return new $t(e,t);case"FILE":return new nn(e,t);case"ADMM":case"BRDM":return new Vt(e,t)}return null},nn=function(e){function s(t,r){var i,s,o,a,u,c,l,d,h,p,f,_,g,y,m,v=this;(v=e.call(this,t,r)||this).messageParams=null,v.plainUrl="",v.requireAuth=!1,v.name=null,v.size=0,v.type=null,v.thumbnails=[],v.messageSurvivalSeconds=-1,v.messageType=ie.FILE;var E=null!==(i=r.file)&&void 0!==i?i:null;if(v.plainUrl=(null!==(o=null!==(s=null==E?void 0:E.url)&&void 0!==s?s:r.url)&&void 0!==o?o:"").split("?auth=")[0],v.name=null!==(u=null!==(a=null==E?void 0:E.name)&&void 0!==a?a:r.name)&&void 0!==u?u:"File",v.size=null!==(l=null!==(c=null==E?void 0:E.size)&&void 0!==c?c:r.size)&&void 0!==l?l:0,v.data=null!==(h=null!==(d=null==E?void 0:E.data)&&void 0!==d?d:r.custom)&&void 0!==h?h:"",v.type=E?null!==(p=E.type)&&void 0!==p?p:"":null!==(f=r.type)&&void 0!==f?f:"",v.requireAuth=null!==(_=r.require_auth)&&void 0!==_&&_,v.thumbnails=r.thumbnails?r.thumbnails.map((function(e){return new Qt(n(n({},e),{url:"".concat(e.url.split("?auth=")[0]).concat(v.requireAuth?"?auth=".concat(ze(v._iid)):"")}))})):[],v.messageSurvivalSeconds=null!==(g=r.message_survival_seconds)&&void 0!==g?g:-1,r.parent_message_info){var I=r.parent_message_info,S=n(n({},I),{message_id:v.parentMessageId,channel_url:v.channelUrl,channel_type:v.channelType,file:I.file,url:null===(y=I.file)||void 0===y?void 0:y.url,require_auth:null===(m=I.file)||void 0===m?void 0:m.require_auth});v.parentMessage=tn(t,S)}return v}return t(s,e),s.payloadify=function(t){return t?U(n(n({},e.payloadify.call(this,t)),{url:t.plainUrl,require_auth:t.requireAuth,file:{name:t.name,size:t.size,type:t.type,data:t.data},thumbnails:t.thumbnails.map((function(e){return{url:e.url,width:e.width,height:e.height,real_width:e.realWidth,real_height:e.realHeight}})),message_survival_seconds:t.messageSurvivalSeconds,parent_message_info:en(t.parentMessage)})):null},Object.defineProperty(s.prototype,"url",{get:function(){return this.requireAuth?"".concat(this.plainUrl,"?auth=").concat(ze(this._iid)):this.plainUrl},enumerable:!1,configurable:!0}),s.prototype.getThreadedMessagesByTimestamp=function(e,t){return r(this,void 0,void 0,(function(){var r;return i(this,(function(i){switch(i.label){case 0:return r=n(n({},jt),t),ut(this.messageId>0&&y("number",e)&&Kt(r)).throw(p.invalidParameters),[4,Dn.of(this._iid).getThreadedMessagesByTimestamp(this,e,r)];case 1:return[2,i.sent()]}}))}))},s}(Gt),rn=function(e){function n(t){var n,r,i,s=[];return t.mentionType===ae.USERS&&(t.mentionedUserIds?s=t.mentionedUserIds:t.mentionedUsers&&(s=t.mentionedUsers.map((function(e){return e.userId})))),e.call(this,{code:"FILE",ackRequired:!0,payload:U({channel_url:t.channelUrl,url:t.url,name:null!==(n=t.fileName)&&void 0!==n?n:"",type:null!==(r=t.mimeType)&&void 0!==r?r:"",size:null!==(i=t.fileSize)&&void 0!==i?i:0,custom:t.data,custom_type:t.customType,thumbnails:t.thumbnailSizes,require_auth:t.requireAuth,metaarray:t.metaArrays,mention_type:t.mentionType,mentioned_user_ids:s,push_option:t.pushNotificationDeliveryOption&&t.pushNotificationDeliveryOption!==ce.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})})||this}return t(n,e),n}(H),sn=function(e){function n(t){var n,r=this;r=e.call(this)||this;var i=[];return t.mentionType===ae.USERS&&(t.mentionedUserIds?i=t.mentionedUserIds:t.mentionedUsers&&(i=t.mentionedUsers.map((function(e){return e.userId})))),r.method=d.POST,r.path="".concat(Ye(t.channelType),"/").concat(encodeURIComponent(t.channelUrl),"/messages"),r.params=U({message_type:ie.FILE,user_id:t.userId,url:t.fileUrl,mention_type:t.mentionType,mentioned_user_ids:i,file_name:t.fileName,file_size:t.fileSize,file_type:t.mimeType,data:t.data,custom_type:t.customType,thumbnails:t.thumbnailSizes.map((function(e){return Qt.payloadify(e)})),require_auth:t.requireAuth,sorted_metaarray:null===(n=t.metaArrays)||void 0===n?void 0:n.map((function(e){return Mt.payloadify(e)})),push_option:t.pushNotificationDeliveryOption,parent_message_id:t.parentMessageId>0?t.parentMessageId:null,apple_critical_alert_options:Ut.payloadify(t.appleCriticalAlertOptions),reply_to_channel:t.isReplyToChannel,req_id:t.reqId}),r}return t(n,e),n}(q),on=function(e){function n(t,n,r){var i,s,o,a=this;(a=e.call(this,t,"FILE",r)||this).message=new nn(t,r);var u=Tt.of(t).sdkState;return a.isMentioned=Je(a.message.mentionType,null!==(i=a.message.mentionedUserIds)&&void 0!==i?i:null===(s=a.message.mentionedUsers)||void 0===s?void 0:s.map((function(e){return e.userId})),u.userId),a.forceUpdateLastMessage=null!==(o=r.force_update_last_message)&&void 0!==o&&o,a}return t(n,e),n}(B),an=function(e){function n(t,n){var r,i,s=this;(s=e.call(this,t,n)||this).message=new nn(t,n);var o=Tt.of(t).sdkState;return s.isMentioned=Je(s.message.mentionType,null!==(r=s.message.mentionedUserIds)&&void 0!==r?r:s.message.mentionedUsers.map((function(e){return e.userId})),o.userId),s.forceUpdateLastMessage=null!==(i=n.force_update_last_message)&&void 0!==i&&i,s}return t(n,e),n}(x);!function(e){e[e.PENDING=0]="PENDING",e[e.UPLOADING=1]="UPLOADING",e[e.UPLOADED=2]="UPLOADED",e[e.SENDING=3]="SENDING",e[e.FAILED=4]="FAILED"}(Bt||(Bt={}));var un,cn=function(){function e(e,t){var n=t.sdkState,r=t.dispatcher,i=t.requestQueue,s=t.onlineDetector,o=t.cacheContext,a=this;this._queueMap=new Map,this._connectionState=null,this._onlineDetector=null,this._iid=e,this._sdkState=n,this._requestQueue=i,this._cacheContext=o,this._dispatcher=r,this._dispatcher.on((function(e){e instanceof de&&(a._connectionState=e.stateType)})),this._onlineDetector=s}return Object.defineProperty(e.prototype,"_shouldSendThroughWebSocket",{get:function(){return this._connectionState===J.CONNECTED||this._connectionState===J.CONNECTING||this._connectionState===J.RECONNECTING},enumerable:!1,configurable:!0}),e.prototype._sendFileMessage=function(e,t){return r(this,void 0,void 0,(function(){var r,s;return i(this,(function(i){switch(i.label){case 0:return this._shouldSendThroughWebSocket?(r=new rn(n(n({channelUrl:e.url,channelType:e.channelType,url:t.params.fileUrl,requireAuth:t.requireAuth},t.params),{reqId:t.requestId})),[4,this._requestQueue.send(r)]):[3,2];case 1:return s=i.sent(),[2,s.as(on).message];case 2:return r=new sn(n(n({channelUrl:e.url,channelType:e.channelType,url:t.params.fileUrl,userId:this._sdkState.userId,requireAuth:t.requireAuth},t.params),{reqId:t.requestId})),[4,this._requestQueue.send(r)];case 3:return s=i.sent(),[2,s.as(an).message]}}))}))},e.prototype._resolveMessageQueue=function(e){return r(this,void 0,void 0,(function(){var t,n,r,o,a,c,l,d,h,f,_,g;return i(this,(function(i){switch(i.label){case 0:if(!(t=this._queueMap.get(e.url)))return[3,21];if(t.isResolving)return[3,20];t.isResolving=!0,n=[],r=!0,i.label=1;case 1:i.trys.push([1,15,16,17]),o=s(t.messageQueue),a=o.next(),i.label=2;case 2:if(a.done)return[3,14];switch(c=a.value,c.state){case Bt.PENDING:case Bt.UPLOADING:return[3,3];case Bt.UPLOADED:return[3,4];case Bt.FAILED:return[3,12]}return[3,13];case 3:return r=!1,n.push(c),[3,13];case 4:if(!r)return[3,10];i.label=5;case 5:return i.trys.push([5,8,,9]),c.state=Bt.SENDING,[4,this._sendFileMessage(e,c)];case 6:return l=i.sent(),c.deferred.resolve(l),[4,De(100)];case 7:return i.sent(),[3,9];case 8:return d=i.sent(),c.deferred.reject(d),[3,9];case 9:return[3,11];case 10:n.push(c),i.label=11;case 11:return[3,13];case 12:return c.deferred.reject(c.error.code===u.REQUEST_CANCELED?p.fileUploadCanceled:c.error),[3,13];case 13:return a=o.next(),[3,2];case 14:return[3,17];case 15:return h=i.sent(),_={error:h},[3,17];case 16:try{a&&!a.done&&(g=o.return)&&g.call(o)}finally{if(_)throw _.error}return[7];case 17:return f=t.isResolveRequestPending,t.messageQueue=n,t.isResolving=!1,t.isResolveRequestPending=!1,f?[4,this._resolveMessageQueue(e)]:[3,19];case 18:i.sent(),i.label=19;case 19:return[3,21];case 20:t.isResolveRequestPending=!0,i.label=21;case 21:return[2]}}))}))},e.prototype._uploadNextPendingItem=function(e){return r(this,void 0,void 0,(function(){var t,n,r,s,o,a,c,l,d,h,f,_,g,y;return i(this,(function(i){switch(i.label){case 0:return t=this._queueMap.get(e.url),(n=t.messageQueue.find((function(e){return e.state===Bt.PENDING})))?S(n.params.file)?t.uploadQueue.length<6?(n.state=Bt.UPLOADING,t.uploadQueue.push(n),[4,this._onlineDetector.isOnline()]):[3,10]:[3,11]:[3,13];case 1:if(!i.sent())return[3,8];i.label=2;case 2:return i.trys.push([2,4,5,7]),r=new Nt({file:n.params.file,channelUrl:e.url,thumbnailSizes:n.params.thumbnailSizes,requestId:n.requestId}),[4,this._requestQueue.send(r)];case 3:return s=i.sent(),o=s.as(At),a=o.url,c=o.fileSize,l=void 0===c?n.params.fileSize:c,d=o.thumbnailSizes,h=void 0===d?n.params.thumbnailSizes:d,f=o.requireAuth,_=void 0!==f&&f,n.params.fileUrl=a,n.params.fileSize=l,n.params.thumbnailSizes=h,n.params.requireAuth=_,n.requireAuth=_,n.state=Bt.UPLOADED,[3,7];case 4:return(g=i.sent()).code===u.REQUEST_FAILED?n.error=new p({code:u.NETWORK_ERROR,message:"Failed to upload a file."}):n.error=g,n.state=Bt.FAILED,[3,7];case 5:return(y=t.uploadQueue.findIndex((function(e){return e.requestId===n.requestId})))>=0&&(t.uploadQueue.splice(y,1),this._uploadNextPendingItem(e)),[4,this._resolveMessageQueue(e)];case 6:return i.sent(),[7];case 7:return[3,10];case 8:return n.state=Bt.FAILED,n.error=p.connectionRequired,(y=t.uploadQueue.findIndex((function(e){return e.requestId===n.requestId})))>=0&&(t.uploadQueue.splice(y,1),this._uploadNextPendingItem(e)),[4,this._resolveMessageQueue(e)];case 9:i.sent(),i.label=10;case 10:return[3,13];case 11:return n.params.thumbnailSizes=[],n.state=Bt.UPLOADED,[4,this._resolveMessageQueue(e)];case 12:i.sent(),i.label=13;case 13:return[2]}}))}))},e.prototype.request=function(e,t,n){var s,o,a;return r(this,void 0,void 0,(function(){var r;return i(this,(function(i){return r=new ee,S(n.file)&&(n.fileName=null!==(s=n.fileName)&&void 0!==s?s:n.file.name,n.mimeType=null!==(o=n.mimeType)&&void 0!==o?o:n.file.type,n.fileSize=null!==(a=n.fileSize)&&void 0!==a?a:n.file.size),this._queueMap.has(e.url)||this._queueMap.set(e.url,{messageQueue:[],uploadQueue:[],isResolving:!1,isResolveRequestPending:!1}),this._queueMap.get(e.url).messageQueue.push({requestId:t,params:n,state:Bt.PENDING,deferred:r,requireAuth:n.requireAuth}),this._uploadNextPendingItem(e),[2,r.promise]}))}))},e.prototype.cancel=function(e,t){var n,r;void 0===t&&(t=null);var i=this._queueMap.get(e.url);if(i){var u=t?[i.messageQueue.find((function(e){return e.requestId===t}))]:a([],o(i.messageQueue),!1);try{for(var c=s(u),l=c.next();!l.done;l=c.next()){var d=l.value;if(d)switch(d.state){case Bt.PENDING:d.state=Bt.FAILED,d.error=p.requestCanceled,this._resolveMessageQueue(e);break;case Bt.UPLOADING:this._requestQueue.cancel(d.requestId)}}}catch(e){n={error:e}}finally{try{l&&!l.done&&(r=c.return)&&r.call(c)}finally{if(n)throw n.error}}}},e}(),ln={prevResultSize:0,nextResultSize:0,isInclusive:!1,reverse:!1,messageTypeFilter:se.ALL,customTypesFilter:null,senderUserIdsFilter:null,replyType:ue.NONE,includeReactions:!1,includeMetaArray:!1,includeParentMessageInfo:!1,includeThreadInfo:!1,showSubchannelMessagesOnly:!1},dn=function(e){return y("number",e.prevResultSize)&&y("number",e.nextResultSize)&&y("boolean",e.isInclusive)&&y("boolean",e.reverse)&&y("string",e.messageTypeFilter)&&m(se,e.messageTypeFilter)&&E("string",e.customTypesFilter,!0)&&E("string",e.senderUserIdsFilter,!0)&&m(ue,e.replyType)&&y("boolean",e.includeMetaArray)&&y("boolean",e.includeReactions)&&y("boolean",e.includeParentMessageInfo)&&y("boolean",e.includeThreadInfo)&&y("boolean",e.showSubchannelMessagesOnly)},hn={replyType:ue.NONE,includeReactions:!1,includeThreadInfo:!1,includeMetaArray:!1,includeParentMessageInfo:!1},pn=function(e){return m(ue,e.replyType)&&y("boolean",e.includeReactions)&&y("boolean",e.includeMetaArray)&&y("boolean",e.includeParentMessageInfo)&&y("boolean",e.includeThreadInfo)};!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"}(un||(un={}));var fn,_n=function(e){return e.startsWith("EVENT_")||e===un.SYNC_MESSAGE_FILL||e===un.SYNC_MESSAGE_CHANGELOGS||e===un.SYNC_POLL_CHANGELOGS},gn=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}(L),yn=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}(L),mn=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}(L),vn=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}(L),En=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}(L),In=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}(L),Sn=function(e){function n(t){var n=t.channelType,r=t.channelUrl,i=t.messageId,s=t.includeMetaArray,o=t.includeReactions,a=t.includeThreadInfo,u=t.includeParentMessageInfo,c=e.call(this)||this;return c.method=d.GET,c.path="".concat(Ye(n),"/").concat(encodeURIComponent(r),"/messages/").concat(encodeURIComponent(i)),c.params={is_sdk:!0,with_sorted_meta_array:s,include_reactions:o,include_thread_info:a,include_parent_message_info:u,include_poll_details:!0},c}return t(n,e),n}(q),Tn=function(e){function r(t,r){var i=e.call(this,t,r)||this;return i.message=r?tn(t,n({},r)):null,i}return t(r,e),r}(x),bn=function(e){function n(t){var n=t.channelType,r=t.channelUrl,i=t.timestamp,s=void 0===i?null:i,o=t.token,a=void 0===o?null:o,u=t.prevResultSize,c=t.nextResultSize,l=t.isInclusive,h=t.reverse,p=t.messageTypeFilter,f=t.customTypesFilter,_=t.senderUserIdsFilter,g=t.replyType,y=t.includeMetaArray,m=t.includeReactions,v=t.parentMessageId,E=t.includeThreadInfo,I=t.includeParentMessageInfo,S=t.showSubchannelMessagesOnly,T=e.call(this)||this;return T.method=d.GET,T.path="".concat(Ye(n),"/").concat(encodeURIComponent(r),"/messages"),T.params=U({is_sdk:!0,prev_limit:u,next_limit:c,include:l,reverse:h,message_ts:s,message_id:a,message_type:null!=p?p:null,custom_types:f,sender_ids:_,include_reply_type:g,with_sorted_meta_array:y,include_reactions:m,parent_message_id:v,include_thread_info:E,include_parent_message_info:I,show_subchannel_message_only:S,include_poll_details:!0}),T}return t(n,e),n}(q),Nn=function(e){function n(t,n){var r=e.call(this,t,n)||this;return r.messages=n.messages.map((function(e){return tn(t,e)})),r}return t(n,e),n}(x),An=function(e){function n(t){var n=t.channelType,r=t.channelUrl,i=t.timestamp,s=t.token,o=t.replyType,a=t.includeMetaArray,u=t.includeReactions,c=t.includeThreadInfo,l=t.includeParentMessageInfo,h=e.call(this)||this;return h.method=d.GET,h.path="".concat(Ye(n),"/").concat(encodeURIComponent(r),"/messages/changelogs"),h.params={change_ts:i,token:s,with_sorted_meta_array:a,include_reactions:u,include_thread_info:c,include_reply_type:o,include_parent_message_info:l,include_poll_details:!0},h}return t(n,e),n}(q),Cn=function(e){function n(t,n){var r=e.call(this,t,n)||this;return r.updatedMessages=n.updated.map((function(e){return tn(t,e)})),r.deletedMessagesInfo=n.deleted.map((function(e){return{messageId:e.message_id,deletedAt:e.deleted_at}})),r.hasMore=n.has_more,r.nextToken=n.next,r}return t(n,e),n}(x),On=function(e){function n(t){var n=t.channelUrl,r=t.scheduledMessageId,i=e.call(this)||this;return i.method=d.GET,i.path="".concat(_e,"/").concat(encodeURIComponent(n),"/scheduled_messages/").concat(encodeURIComponent(r)),i.params={},i}return t(n,e),n}(q),wn=function(e){function r(t,r){var i=e.call(this,t,r)||this;return i.message=r?tn(t,n({},r)):null,i}return t(r,e),r}(x),Rn={},Dn=function(){function e(e,t){var n=t.sdkState,r=t.dispatcher,i=t.requestQueue,s=t.onlineDetector,o=t.cacheContext;this._iid=e,this._sdkState=n,this._requestQueue=i,this._dispatcher=r,this._onlineDetector=s,this._cacheContext=o,this.fileMessageQueue=new cn(e,{sdkState:n,dispatcher:r,requestQueue:i,onlineDetector:s,cacheContext:o}),Rn[e]=this}return e.of=function(e){return Rn[e]},e.prototype.buildMessageFromSerializedData=function(e){var t=at(e);switch(t.messageType){case ie.USER:return new $t(this._iid,$t.payloadify(t));case ie.FILE:return new nn(this._iid,nn.payloadify(t));case ie.ADMIN:return new Vt(this._iid,Vt.payloadify(t))}return null},e.prototype.buildUserMessageCreateParamsFromSerializedData=function(e,t){return U({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){return U({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.url,fileName:t.name,fileSize:t.size,mimeType:t.type,thumbnailSizes:t.thumbnails.map((function(e){return{maxWidth:e.width,maxHeight:e.height}})),fileType:e.fileType,requireAuth:t.requireAuth})},e.prototype.buildScheduledUserMessageCreateParamsFromSerializedData=function(e,t){return n(n({},this.buildUserMessageCreateParamsFromSerializedData(e,t)),{scheduledAt:e.scheduledAt})},e.prototype.buildScheduledFileMessageCreateParamsFromSerializedData=function(e,t){return n(n({},this.buildFileMessageCreateParamsFromSerializedData(e,t)),{scheduledAt:e.scheduledAt})},e.prototype.buildSenderFromSerializedData=function(e){var t=at(e);return new Ft(this._iid,Ft.payloadify(t))},e.prototype.getMessage=function(e){return r(this,void 0,void 0,(function(){var t,n;return i(this,(function(r){switch(r.label){case 0:return t=new Sn(e),[4,this._requestQueue.send(t)];case 1:return n=r.sent(),[2,n.as(Tn).message]}}))}))},e.prototype.getScheduledMessage=function(e){return r(this,void 0,void 0,(function(){var t,n;return i(this,(function(r){switch(r.label){case 0:return t=new On(e),[4,this._requestQueue.send(t)];case 1:return n=r.sent(),[2,n.as(wn).message]}}))}))},e.prototype.getMessagesByMessageId=function(e,t,s,o,a){return void 0===a&&(a=un.REQUEST_MESSAGE),r(this,void 0,void 0,(function(){var r,u,c;return i(this,(function(i){switch(i.label){case 0:return r=new bn(n(n({channelType:t,channelUrl:e,token:String(s)},ln),o)),[4,this._requestQueue.send(r)];case 1:return u=i.sent(),c=u.as(Nn).messages,this._dispatcher.dispatch(new gn({messages:c,source:a})),[2,c]}}))}))},e.prototype.getMessagesByTimestamp=function(e,t,s,o,a){return void 0===a&&(a=un.REQUEST_MESSAGE),r(this,void 0,void 0,(function(){var r,u,c;return i(this,(function(i){switch(i.label){case 0:return r=new bn(n(n({channelType:t,channelUrl:e,timestamp:s},ln),o)),[4,this._requestQueue.send(r)];case 1:return u=i.sent(),c=u.as(Nn).messages,this._dispatcher.dispatch(new gn({messages:c,source:a})),[2,c]}}))}))},e.prototype.getThreadedMessagesByTimestamp=function(e,t,s,o){return void 0===o&&(o=un.REQUEST_THREADED_MESSAGE),r(this,void 0,void 0,(function(){var r,a,u,c;return i(this,(function(i){switch(i.label){case 0:return r=new bn(n(n(n({channelUrl:e.channelUrl,channelType:e.channelType,timestamp:t},jt),s),{replyType:ue.ALL,parentMessageId:e.messageId,includeThreadInfo:!0})),[4,this._requestQueue.send(r)];case 1:return a=i.sent(),u=a.as(Nn).messages,(c=u.slice(1)).forEach((function(t){t.parentMessage=e})),this._dispatcher.dispatch(new gn({messages:c,source:o})),[2,{parentMessage:u[0],threadedMessages:c}]}}))}))},e.prototype.getMessageChangelogs=function(e,t,s,o,a){return void 0===a&&(a=un.REQUEST_MESSAGE_CHANGELOGS),r(this,void 0,void 0,(function(){var r,u,c,l,d,h,p,f;return i(this,(function(i){switch(i.label){case 0:return r=new An(U(n(n({channelType:t,channelUrl:e,timestamp:"number"==typeof s?s:null,token:"string"==typeof s?s:null},hn),o))),[4,this._requestQueue.send(r)];case 1:return u=i.sent(),c=u.as(Cn),l=c.updatedMessages,d=c.deletedMessagesInfo,h=c.hasMore,p=c.nextToken,f=d.map((function(e){return e.messageId})),l.length>0&&this._dispatcher.dispatch(new gn({messages:l,source:a})),f.length>0&&this._dispatcher.dispatch(new yn({messageIds:f,source:a})),[2,{updatedMessages:l,deletedMessageIds:f,hasMore:h,token:p}]}}))}))},e}(),Mn=function(){function e(){this._onPending=X,this._onFailed=X,this._onSucceeded=X}return e.prototype._trigger=function(e,t){switch(t.sendingStatus){case le.PENDING:this._onPending(t);break;case le.FAILED:case le.CANCELED:this._onFailed(e,t.scheduledInfo?null:t);break;case le.SCHEDULED:case le.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}(),kn=function(e){function n(t,n){var r=e.call(this,t)||this;r.threadInfo=null,r.targetMessageId=0,r.channelUrl=null,r.channelType=null;var i=n.thread_info,s=n.root_message_id,o=n.channel_url,a=n.channel_type;return i&&y("object",i)&&y("number",s)&&y("string",o)&&y("string",a)&&(r.threadInfo=new Ct(t,i),r.targetMessageId=s,r.channelUrl=o,r.channelType=a),r}return t(n,e),n}(He),Ln={channelUrl:null,channelType:null,messageId:0,includeReactions:!1,includeMetaArray:!1,includeParentMessageInfo:!1,includeThreadInfo:!1},Un=function(){function e(e,t){var n;this._iid=null,this.limit=20,this._isLoading=!1,this._hasNext=!0,this._token="",this._iid=e,this.limit=null!==(n=t.limit)&&void 0!==n?n:20}return Object.defineProperty(e.prototype,"hasNext",{get:function(){return this._hasNext},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"isLoading",{get:function(){return this._isLoading},enumerable:!1,configurable:!0}),e.prototype._validate=function(){return y("number",this.limit)&&this.limit>0},e}(),Pn=function(e){function n(t){var n=t.channelCustomType,r=t.keyword,i=t.limit,s=t.reverse,o=t.exactMatch,a=t.channelUrl,u=t.order,c=t.messageTimestampFrom,l=t.messageTimestampTo,h=t.advancedQuery,p=t.targetFields,f=t.nextToken,_=e.call(this)||this;return _.method=d.GET,_.path="".concat(ve,"/messages"),_.params={custom_type:n,query:r,limit:i,reverse:s,exact_match:o,channel_url:a,message_ts_from:c,message_ts_to:l,sort_field:u,advanced_query:h,target_fields:p,after:f},_}return t(n,e),n}(q),qn=function(e){function n(t,n){var r=e.call(this,t,n)||this;return r.messages=n.results.map((function(e){return tn(t,e)})),r.hasNext=n.has_next,r.nextToken=n.end_cursor,r.totalCount=n.total_count,r}return t(n,e),n}(x);!function(e){e.SCORE="score",e.TIMESTAMP="ts"}(fn||(fn={}));var xn=function(e){function s(t,n){var r,i,s,o,a,u,c,l,d,h=this;return(h=e.call(this,t,n)||this).keyword="",h.reverse=!1,h.exactMatch=!1,h.channelUrl="",h.channelCustomType="",h.messageTimestampFrom=null,h.messageTimestampTo=null,h.order=fn.SCORE,h.advancedQuery=!1,h.targetFields=null,h._nextToken="",h.totalCount=-1,h.keyword=n.keyword,h.reverse=null!==(r=n.reverse)&&void 0!==r&&r,h.exactMatch=null!==(i=n.exactMatch)&&void 0!==i&&i,h.channelUrl=null!==(s=n.channelUrl)&&void 0!==s?s:"",h.channelCustomType=null!==(o=n.channelCustomType)&&void 0!==o?o:"",h.messageTimestampFrom=null!==(a=n.messageTimestampFrom)&&void 0!==a?a:null,h.messageTimestampTo=null!==(u=n.messageTimestampTo)&&void 0!==u?u:null,h.order=null!==(c=n.order)&&void 0!==c?c:fn.SCORE,h.advancedQuery=null!==(l=n.advancedQuery)&&void 0!==l&&l,h.targetFields=null!==(d=n.targetFields)&&void 0!==d?d:null,h}return t(s,e),s.prototype._validate=function(){return e.prototype._validate.call(this)&&y("string",this.keyword)&&this.keyword.length>0&&y("boolean",this.reverse)&&y("boolean",this.exactMatch)&&y("string",this.channelUrl)&&y("string",this.channelCustomType)&&(y("number",this.messageTimestampFrom)||null===this.messageTimestampFrom)&&(y("number",this.messageTimestampTo)||null===this.messageTimestampTo)&&m(fn,this.order)&&y("boolean",this.advancedQuery)&&E("string",this.targetFields,!0)},s.prototype.next=function(){return r(this,void 0,void 0,(function(){var e,t,r,s,o,a,u,c;return i(this,(function(i){switch(i.label){case 0:return this._validate()?this._isLoading?[3,3]:this._hasNext?(this._isLoading=!0,e=Tt.of(this._iid).requestQueue,t=new Pn(n(n({},this),{nextToken:this._nextToken?this._nextToken:null})),[4,e.send(t)]):[3,2]:[3,5];case 1:return r=i.sent(),s=r.as(qn),o=s.messages,a=s.hasNext,u=s.nextToken,c=s.totalCount,this._nextToken=u,this._hasNext=a,this._isLoading=!1,this.totalCount=c,[2,o];case 2:return[2,[]];case 3:throw p.queryInProgress;case 4:return[3,6];case 5:throw p.invalidParameters;case 6:return[2]}}))}))},s}(Un),Fn=function(e){function n(t,n,r,i){var s=e.call(this,t,i)||this;return s.channelUrl=n,s.channelType=r,s}return t(n,e),n.prototype._validate=function(){return e.prototype._validate.call(this)&&y("string",this.channelUrl)&&m(ne,this.channelType)},n}(Un),Gn=function(e){function n(t,n,r,i){var s,o,a,u,c,l,d,h,p,f,_=this;return(_=e.call(this,t,n,r,i)||this).reverse=!1,_.messageTypeFilter=se.ALL,_.customTypesFilter=null,_.senderUserIdsFilter=null,_.replyType=ue.NONE,_.includeMetaArray=!1,_.includeReactions=!1,_.includeParentMessageInfo=!1,_.includeThreadInfo=!1,_.showSubchannelMessagesOnly=!1,_._edge=Number.MAX_SAFE_INTEGER,_.reverse=null!==(s=i.reverse)&&void 0!==s&&s,_.messageTypeFilter=null!==(o=i.messageTypeFilter)&&void 0!==o?o:se.ALL,_.customTypesFilter=null!==(a=i.customTypesFilter)&&void 0!==a?a:null,_.senderUserIdsFilter=null!==(u=i.senderUserIdsFilter)&&void 0!==u?u:null,_.replyType=null!==(c=i.replyType)&&void 0!==c?c:ue.NONE,_.includeMetaArray=null!==(l=i.includeMetaArray)&&void 0!==l&&l,_.includeReactions=null!==(d=i.includeReactions)&&void 0!==d&&d,_.includeParentMessageInfo=null!==(h=i.includeParentMessageInfo)&&void 0!==h&&h,_.includeThreadInfo=null!==(p=i.includeThreadInfo)&&void 0!==p&&p,_.showSubchannelMessagesOnly=null!==(f=i.showSubchannelMessagesOnly)&&void 0!==f&&f,_}return t(n,e),n.prototype._validate=function(){return e.prototype._validate.call(this)&&y("boolean",this.reverse)&&m(se,this.messageTypeFilter)&&m(ue,this.replyType)&&E("string",this.customTypesFilter,!0)&&E("string",this.senderUserIdsFilter,!0)&&y("boolean",this.includeMetaArray)&&y("boolean",this.includeReactions)&&y("boolean",this.includeParentMessageInfo)&&y("boolean",this.includeThreadInfo)&&y("boolean",this.showSubchannelMessagesOnly)},n.prototype.load=function(){return r(this,void 0,void 0,(function(){var e;return i(this,(function(t){switch(t.label){case 0:return this._validate()?this._isLoading?[3,3]:this._hasNext?(this._isLoading=!0,[4,Dn.of(this._iid).getMessagesByTimestamp(this.channelUrl,this.channelType,this._edge,{prevResultSize:this.limit,nextResultSize:0,isInclusive:!1,reverse:this.reverse,messageTypeFilter:this.messageTypeFilter,customTypesFilter:this.customTypesFilter,replyType:this.replyType,senderUserIdsFilter:this.senderUserIdsFilter,includeReactions:this.includeReactions,includeMetaArray:this.includeMetaArray,includeParentMessageInfo:this.includeParentMessageInfo,includeThreadInfo:this.includeThreadInfo,showSubchannelMessagesOnly:this.showSubchannelMessagesOnly})]):[3,2]:[3,5];case 1:return e=t.sent(),this._edge=Math.min.apply(Math,a([Number.MAX_SAFE_INTEGER],o(e.map((function(e){return e.createdAt}))),!1)),this._hasNext=e.length>=this.limit,this._isLoading=!1,[2,e];case 2:return[2,[]];case 3:throw p.queryInProgress;case 4:return[3,6];case 5:throw p.invalidParameters;case 6:return[2]}}))}))},n}(Fn),Qn={channelUrl:null,scheduledMessageId:0},jn=function(e){function s(){var t=null!==e&&e.apply(this,arguments)||this;return t.name="message",t}return t(s,e),s.prototype.init=function(t,n){var r=n.sdkState,i=n.dispatcher,s=n.sessionManager,o=n.requestQueue,a=n.logger,u=n.onlineDetector,c=n.cacheContext;e.prototype.init.call(this,t,{sdkState:r,dispatcher:i,sessionManager:s,requestQueue:o,logger:a,onlineDetector:u,cacheContext:c}),this._manager=new Dn(t,{sdkState:r,dispatcher:i,requestQueue:o,onlineDetector:u,cacheContext:c})},s.prototype.buildMessageFromSerializedData=function(e){return this._manager.buildMessageFromSerializedData(e)},s.prototype.buildSenderFromSerializedData=function(e){return this._manager.buildSenderFromSerializedData(e)},s.prototype.getMessage=function(e){return r(this,void 0,void 0,(function(){var t;return i(this,(function(r){return t=n(n({},Ln),e),ut(function(e){return y("string",e.channelUrl)&&y("string",e.channelType)&&m(ne,e.channelType)&&y("number",e.messageId)&&y("boolean",e.includeMetaArray)&&y("boolean",e.includeParentMessageInfo)&&y("boolean",e.includeThreadInfo)}(t)).throw(p.invalidParameters),[2,this._manager.getMessage(t)]}))}))},s.prototype.getScheduledMessage=function(e){return r(this,void 0,void 0,(function(){var t;return i(this,(function(r){return t=n(n({},Qn),e),ut(function(e){return y("string",e.channelUrl)&&y("number",e.scheduledMessageId)}(t)).throw(p.invalidParameters),[2,this._manager.getScheduledMessage(t)]}))}))},s}(bt);export{A as $,d as A,L as B,ne as C,le as D,M as E,nn as F,I as G,de as H,He as I,J,u as K,gn as L,un as M,pe as N,Se as O,Zt as P,Ie as Q,ue as R,p as S,E as T,lt as U,Tt as V,B as W,Un as X,o as Y,a as Z,t as _,Te as a,At as a$,N as a0,b as a1,R as a2,jn as a3,c as a4,ze as a5,j as a6,xn as a7,at as a8,Le as a9,$e as aA,ln as aB,dn as aC,hn as aD,pn as aE,ee as aF,xt as aG,T as aH,Ot as aI,Ue as aJ,In as aK,En as aL,mn as aM,yn as aN,ge as aO,_e as aP,be as aQ,wt as aR,Wt as aS,ot as aT,on as aU,Ht as aV,V as aW,tn as aX,_n as aY,ke as aZ,en as a_,$ as aa,dt as ab,ht as ac,mt as ad,zt as ae,re as af,st as ag,ae as ah,Mt as ai,ce as aj,Ut as ak,Xe as al,Ee as am,H as an,Je as ao,Ze as ap,Rt as aq,oe as ar,Qt as as,g as at,Gn as au,Ft as av,De as aw,h as ax,Mn as ay,et as az,q as b,Nt as b0,Vt as b1,kn as b2,me as b3,ye as b4,fn as b5,kt as b6,Lt as b7,Dt as b8,Et as b9,Ct as ba,x as c,Jt as d,U as e,Yt as f,Ye as g,m as h,y as i,r as j,i as k,n as l,vn as m,Fn as n,bt as o,Pt as p,S as q,X as r,se as s,ie as t,ut as u,Xt as v,Gt as w,$t as x,Dn as y,s as z}; +var e=function(t,n){return e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n])},e(t,n)};function t(t,n){if("function"!=typeof n&&null!==n)throw new TypeError("Class extends value "+String(n)+" is not a constructor or null");function r(){this.constructor=t}e(t,n),t.prototype=null===n?Object.create(n):(r.prototype=n.prototype,new r)}var n=function(){return n=Object.assign||function(e){for(var t,n=1,r=arguments.length;n0&&i[i.length-1])||6!==s[0]&&2!==s[0])){o=0;continue}if(3===s[0]&&(!i||s[1]>i[0]&&s[1]=e.length&&(e=void 0),{value:e&&e[r++],done:!e}}};throw new TypeError(t?"Object is not iterable.":"Symbol.iterator is not defined.")}function o(e,t){var n="function"==typeof Symbol&&e[Symbol.iterator];if(!n)return e;var r,i,s=n.call(e),o=[];try{for(;(void 0===t||t-- >0)&&!(r=s.next()).done;)o.push(r.value)}catch(e){i={error:e}}finally{try{r&&!r.done&&(n=s.return)&&n.call(s)}finally{if(i)throw i.error}}return o}function a(e,t,n){if(n||2===arguments.length)for(var r,i=0,s=t.length;i0&&_.indexOf(e)>=0},S=function(e,t){if(void 0===t&&(t=!1),t&&null===e)return!0;var n=y("object",e)&&null!==e&&e.hasOwnProperty("name")&&"string"==typeof e.name&&e.hasOwnProperty("uri")&&"string"==typeof e.uri&&e.hasOwnProperty("type")&&"string"==typeof e.type;if(!n){if("undefined"!=typeof Blob)return e instanceof Blob;if("undefined"!=typeof File)return e instanceof File}return n},T=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=a([],o(e),!1).sort(),r=a([],o(t),!1).sort(),i=0;i=1e3&&e<=9e3&&(this._typingIndicatorThrottle=e)},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"websocketResponseTimeout",{get:function(){return this._websocketResponseTimeout},set:function(e){y("number",e)&&e>=5e3&&e<=3e4&&(this._websocketResponseTimeout=e)},enumerable:!1,configurable:!0}),e}(),N={key:"__ev",value:{k:"__ev",v:"scs"},generation:1},A={encrypt:function(e){return e},decrypt:function(e){return e}},C=function(){function e(e){var t=e.store;this._preference=new Map,this._store=t}return e.prototype._savePreferenceKeys=function(){return r(this,void 0,void 0,(function(){return i(this,(function(e){switch(e.label){case 0:return[4,this._store.set({key:this._keysAddress,value:a([],o(this._preference.keys()),!1),generation:1})];case 1:return e.sent(),[2]}}))}))},e.prototype.init=function(e){var t;return r(this,void 0,void 0,(function(){var n,r,o,a,u,c,l,d;return i(this,(function(i){switch(i.label){case 0:return this._keysAddress=e,[4,this._store.get(e)];case 1:n=null!==(t=i.sent())&&void 0!==t?t:[],i.label=2;case 2:i.trys.push([2,7,8,9]),r=s(n),o=r.next(),i.label=3;case 3:return o.done?[3,6]:(a=o.value,[4,this._store.get(a)]);case 4:(u=i.sent())&&this._preference.set(a,u),i.label=5;case 5:return o=r.next(),[3,3];case 6:return[3,9];case 7:return c=i.sent(),l={error:c},[3,9];case 8:try{o&&!o.done&&(d=r.return)&&d.call(r)}finally{if(l)throw l.error}return[7];case 9:return[2]}}))}))},e.prototype.get=function(e){var t;return r(this,void 0,void 0,(function(){return i(this,(function(n){return[2,null!==(t=this._preference.get(e))&&void 0!==t?t:null]}))}))},e.prototype.set=function(e,t){return r(this,void 0,void 0,(function(){var n;return i(this,(function(r){switch(r.label){case 0:return n=!this._preference.has(e),[4,this._store.set({key:e,value:t,generation:1})];case 1:return r.sent(),this._preference.set(e,t),n?[4,this._savePreferenceKeys()]:[3,3];case 2:r.sent(),r.label=3;case 3:return[2]}}))}))},e.prototype.remove=function(e){return r(this,void 0,void 0,(function(){return i(this,(function(t){switch(t.label){case 0:return[4,this._store.remove(e)];case 1:return t.sent(),this._preference.delete(e),[4,this._savePreferenceKeys()];case 2:return t.sent(),[2]}}))}))},e.prototype.clear=function(){return r(this,void 0,void 0,(function(){return i(this,(function(e){switch(e.label){case 0:return[4,this._store.removeMany(a([],o(this._preference.keys()),!1))];case 1:return e.sent(),this._preference.clear(),[4,this._savePreferenceKeys()];case 2:return e.sent(),[2]}}))}))},e}(),O=function(e){var t=e.encryption,n=void 0===t?null:t,r=e.store,i=void 0===r?null:r,s=e.localCacheEnabled,o=void 0===s||s;this.nestdb=null,this.store=i,this.preference=new C({store:i}),this.encryption=null!=n?n:A,this.localCacheEnabled=o},w=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}(),R=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)}))},D=function(){function e(e){var t=e.container;this._container={},this._container=t,this.key=R()}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}(),M=function(){function e(){this._container={}}return e.prototype.on=function(e,t){return new D({container:this._container}).on(e,t)},e.prototype.once=function(e,t){return new D({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()),u=a.next();!u.done;u=a.next()){var c=u.value,l=i.get(c);l.handler(t),l.occurence>0&&(l.occurence--,0===l.occurence&&o.push(c))}}catch(e){n={error:e}}finally{try{u&&!u.done&&(r=a.return)&&r.call(a)}finally{if(n)throw n.error}}o.forEach((function(e){return i.delete(e)}))}},e}(),k=function(){function e(){this._dispatcher=new M}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}(),L=function(){},U=function(e){var t={};return e&&Object.keys(e).forEach((function(n){void 0!==e[n]&&NaN!==e[n]&&null!==e[n]&&(t[n]=e[n])})),t};!function(e){e.GET="GET",e.POST="POST",e.PUT="PUT",e.DELETE="DELETE"}(d||(d={}));var P,q=function(e){function n(){var t=null!==e&&e.apply(this,arguments)||this;return t.params={},t.requireAuth=!0,t.headers={},t.requestId=R(),t}return t(n,e),n.prototype.stringifyParams=function(e){return"object"!=typeof e||Array.isArray(e)?String(e):e?JSON.stringify(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=U(this.params);return"?".concat(Object.keys(t).map((function(n){return"".concat(encodeURIComponent(n),"=").concat(e.encodeParams(t[n]))})).join("&"))},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"payload",{get:function(){var e=this,t=U(this.params);if(Object.keys(t).some((function(e){return S(t[e])}))){var n=new FormData;return Object.keys(t).forEach((function(r){var i,s=t[r];if(S(s)){var o=s;n.append(r,o,null!==(i=o.name)&&void 0!==i?i:"filename")}else n.append(r,e.stringifyParams(s))})),n}return JSON.stringify(t)},enumerable:!1,configurable:!0}),n}(L),x=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}(L),F=function(e){function n(t){var n=e.call(this)||this;return n.requestId=t,n}return t(n,e),n}(L),G=function(e){function n(){return null!==e&&e.apply(this,arguments)||this}return t(n,e),n}(L),Q=function(e){function n(t){var n=e.call(this)||this;return n.statLog=t,n}return t(n,e),n}(L);!function(e){e.WEBSOCKET_CONNECT="ws:connect",e.API_RESULT="api:result"}(P||(P={}));var j,K=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 U({stat_type:e.type,ts:e.createdAt,data:U(e.data)})},e}(),V=function(){return"undefined"==typeof document&&"undefined"!=typeof navigator&&"ReactNative"==navigator.product},z=function(){function e(e,t){var n=t.auth,r=t.sdkState,i=t.dispatcher,s=t.logger,o=this;this._abortControl=new Map,this._iid=e,this._auth=n,this._sdkState=r,this._dispatcher=i,this._dispatcher.on((function(e){e instanceof F&&o.cancel(e.requestId)})),this._logger=s}return Object.defineProperty(e.prototype,"_userAgentWithExtension",{get:function(){var e=this._sdkState.extensions,t=V()?"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(l.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,s=r.appVersion,o=n(n({},e.headers),{SendBird:"JS,".concat(l.OS_VERSION,",").concat(l.SDK_VERSION,",").concat(i).concat(s?",".concat(s):""),"SB-User-Agent":encodeURIComponent(this._userAgentWithExtension),"Request-Sent-Timestamp":Date.now().toString()});return t||(o["Content-Type"]="application/json; charset=utf-8"),e.requireAuth&&this._auth.hasSession&&(o["Session-Key"]=this._auth.sessionKey),this._auth&&this._auth.authToken&&(o["App-Id"]=i,o["Access-Token"]=this._auth.authToken),o},e.prototype._statLogApiResult=function(e,t,n){this._dispatcher.dispatch(new Q(new K({type:P.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 r(this,void 0,void 0,(function(){var t,n,r,s,o,a,u,c,l,h,f,_,g,y,m;return i(this,(function(i){switch(i.label){case 0:t=e.path,n=e.method,r=![d.GET,d.DELETE].includes(n),s=this._sdkState.api,o="".concat(s.host).concat(t).concat(r?"":e.query),a=r?e.payload:null,u=this._createHeader(e,a instanceof FormData?a:null),c=new AbortController,l=c.signal,this._abortControl.set(e.requestId,c),h=Date.now(),i.label=1;case 1:return i.trys.push([1,4,,5]),[4,fetch(o,{method:n,body:a,headers:u,signal:l})];case 2:return[4,(f=i.sent()).json()];case 3:if(_=i.sent(),f.ok||f.redirected)return this._logger.debug("receive api response",e.requestId),this._statLogApiResult(e,h,null),[2,new x(this._iid,_)];throw _?(g=new p(_),!e.requireAuth&&g.isSessionKeyExpiredError&&this._dispatcher.dispatch(new G),this._statLogApiResult(e,h,g),g):(g=p.requestFailed,this._statLogApiResult(e,h,g),g);case 4:throw y=i.sent(),this._statLogApiResult(e,h,y),y instanceof p?(this._logger.debug("fail api request",y),y):"AbortError"===y.name?p.requestCanceled:(m=p.networkError,this._logger.debug("fail api request",m),m);case 5:return[2]}}))}))},e.prototype.cancel=function(e){this._abortControl.has(e)&&(this._abortControl.get(e).abort(),this._abortControl.delete(e))},e.prototype.cancelAll=function(){var e,t;try{for(var n=s(this._abortControl.values()),r=n.next();!r.done;r=n.next()){r.value.abort()}}catch(t){e={error:t}}finally{try{r&&!r.done&&(t=n.return)&&t.call(n)}finally{if(e)throw e.error}}this._abortControl.clear()},e}(),B=function(e){function n(t,n,r,i){void 0===i&&(i="");var s,o=this;return(o=e.call(this)||this)._iid=t,o.code=n,o.payload=r,o.requestId=r?null!==(s=r.req_id)&&void 0!==s?s: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}(L),H=function(e){function n(t){var n,r=t.code,i=t.ackRequired,s=t.payload,o=void 0===s?null:s,a=this;return(a=e.call(this)||this).code=r,a.payload=o,a.requestId=null!==(n=a.payload.req_id)&&void 0!==n?n:R(),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}(L),W=function(e){function n(){return e.call(this,{code:"PING",payload:{id:Date.now(),active:1},ackRequired:!1})||this}return t(n,e),n}(H),Y=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 W;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}(),X=function(){};!function(e){e.CONNECTING="CONNECTING",e.OPEN="OPEN",e.CLOSED="CLOSED"}(j||(j={}));var J,Z=function(e){function n(t,n){var r=n.sdkState,i=n.dispatcher,s=n.logger,o=e.call(this)||this;return o._pinger=null,o.lastActive=0,o._iid=t,o._sdkState=r,o._dispatcher=i,o._logger=s,o._sdkState.websocket.pingerDisabled||(o._pinger=new Y({pingDelegate:{send:function(e){return o.send(e)},error:function(e){return o.error(e)}},sdkState:o._sdkState,logger:s})),o}return t(n,e),Object.defineProperty(n.prototype,"connectionState",{get:function(){if(this._ws)switch(this._ws.readyState){case 0:return j.CONNECTING;case 1:return j.OPEN}return j.CLOSED},enumerable:!1,configurable:!0}),n.prototype.connect=function(e){var t=this;this._ws=new WebSocket(e),this._ws.onopen=function(){t._logger.debug("websocket open"),t.dispatch("open")},this._ws.onmessage=function(e){e.data.split("\n").forEach((function(e){if(e&&y("string",e)){var n=B.createFromRawMessage(t._iid,e);t._logger.debug("receive websocket event",n),"LOGI"===n.code?(n.payload&&!n.payload.error&&t._pinger&&t._pinger.start(),t.dispatch("message",n)):"PONG"===n.code?t._pinger&&t._pinger.pong():"EXPR"===n.code?n.payload&&n.payload.expires_in>=0&&t._dispatcher.dispatch(new G):"NOOP"===n.code||t.dispatch("message",n)}}))},this._ws.onerror=function(){t._logger.debug("websocket error"),t._pinger&&t._pinger.stop(),t.dispatch("error",p.networkError)},this._ws.onclose=function(){t._logger.debug("websocket close"),t._pinger&&t._pinger.stop(),t.dispatch("close")},this.lastActive=Date.now()},n.prototype.disconnect=function(){var e=this;this._logger.debug("websocket disconnect"),this._pinger&&this._pinger.stop(),this._ws&&(this._ws.onopen=X,this._ws.onmessage=X,this._ws.onerror=X,this._ws.onclose=function(){e.dispatch("close")},this._ws.close(),this._ws=null)},n.prototype.send=function(e){if(!this._ws)throw p.connectionClosed;"PING"!==e.code?this._pinger&&this._pinger.refreshTimer():this._logger.debug("send ping",e),this._ws.send(e.convertToMessage())},n.prototype.error=function(e){this._logger.debug("websocket error",e),this._pinger&&this._pinger.stop(),this.dispatch("error",e)},n}(M),$=function(e){function n(t){var n=t.all,r=t.custom_types,i=t.ts,s=e.call(this)||this;return s.all=n,s.customTypes=r,s.ts=i,s}return t(n,e),n}(L),ee=function(){var e=this;this.promise=new Promise((function(t,n){e.resolve=t,e.reject=n}))},te=function(){function e(e,t){var n=t.auth,r=t.sdkState,i=t.dispatcher,s=t.logger,o=this;this._ackStateMap=new Map,this._sdkState=r,this._dispatcher=i,this._logger=s,this.apiClient=new z(e,{auth:n,sdkState:r,dispatcher:i,logger:s}),this.websocketClient=new Z(e,{sdkState:r,dispatcher:i,logger:s}),this.websocketClient.on("message",(function(e){if(e.payload.unread_cnt&&o._dispatcher.dispatch(new $(e.payload.unread_cnt)),e.requestId){if(o._ackStateMap.has(e.requestId)){var t=o._ackStateMap.get(e.requestId);"EROR"!==e.code?t.resolve(e):t.reject(new p({code:e.payload.code,message:e.payload.message}))}}else o._dispatcher.dispatch(e)})).on("close",(function(){o._ackStateMap.forEach((function(e){e.reject(p.connectionClosed)})),o._ackStateMap.clear()}))}return e.prototype._sendApiRequest=function(e){return r(this,void 0,void 0,(function(){return i(this,(function(t){switch(t.label){case 0:return[4,this.apiClient.send(e)];case 1:return[2,t.sent()]}}))}))},e.prototype._sendWebsocketRequest=function(e){return r(this,void 0,void 0,(function(){var t,n,r,s=this;return i(this,(function(i){if(t=new ee,e.ackRequired){n=null,r=function(r,i){void 0===r&&(r=null),void 0===i&&(i=null),s._ackStateMap.has(e.requestId)&&(s._ackStateMap.delete(e.requestId),n&&(clearTimeout(n),n=null),r?(s._logger.debug("fail websocket request",r),t.reject(r)):(s._logger.debug("receive websocket ack",e.requestId),t.resolve(i)))};try{n=setTimeout((function(){return r(p.noAckTimeout)}),this._sdkState.websocket.responseTimeout),this._ackStateMap.set(e.requestId,{resolve:function(e){return r(null,e)},reject:function(e){return r(e)}}),this.websocketClient.send(e)}catch(e){r(e)}}else try{this.websocketClient.send(e),t.resolve(null)}catch(e){t.reject(e)}return[2,t.promise]}))}))},e.prototype.send=function(e){return r(this,void 0,void 0,(function(){return i(this,(function(t){switch(t.label){case 0:return e instanceof q?[4,this._sendApiRequest(e)]:[3,2];case 1:case 3:return[2,t.sent()];case 2:return e instanceof H?[4,this._sendWebsocketRequest(e)]:[3,4];case 4:throw p.invalidParameters}}))}))},e.prototype.cancel=function(e){this.apiClient.cancel(e)},e.prototype.cancelAll=function(){this.apiClient.cancelAll()},e}();!function(e){e[e.NONE=0]="NONE",e[e.INITIALIZED=1]="INITIALIZED",e[e.CONNECTING=2]="CONNECTING",e[e.CONNECTED=3]="CONNECTED",e[e.RECONNECTING=4]="RECONNECTING",e[e.DISCONNECTED=5]="DISCONNECTED",e[e.LOGOUT=6]="LOGOUT"}(J||(J={}));var ne,re,ie,se,oe,ae,ue,ce,le,de=function(e){function n(t){var n=t.stateType,r=e.call(this)||this;return r.stateType=n,r}return t(n,e),n}(L),he=function(){function e(e,t){var n=t.auth,s=t.sdkState,o=t.dispatcher,a=t.logger,u=this;this._currentConnectionStateType=J.INITIALIZED,this._lazyCallQueue=[],this.commandRouter=new te(e,{auth:n,sdkState:s,dispatcher:o,logger:a}),this._auth=n,this._logger=a,this._dispatcher=o,this._dispatcher.on((function(e){if(e instanceof de){var t=e.stateType;switch(u._currentConnectionStateType=t,t){case J.CONNECTED:var n=u._lazyCallQueue;u._lazyCallQueue=[],n.forEach((function(e){return r(u,void 0,void 0,(function(){var t,n,r,s,o;return i(this,(function(i){switch(i.label){case 0:t=e.command,n=e.deferred,r=e.timeout,clearTimeout(r),i.label=1;case 1:return i.trys.push([1,3,,4]),[4,this.send(t)];case 2:return s=i.sent(),n.resolve(s),[3,4];case 3:return o=i.sent(),n.reject(o),[3,4];case 4:return[2]}}))}))}));break;case J.INITIALIZED:case J.DISCONNECTED:case J.LOGOUT:n=u._lazyCallQueue;u._lazyCallQueue=[],n.forEach((function(e){return r(u,void 0,void 0,(function(){var t,n;return i(this,(function(r){return t=e.deferred,n=e.timeout,clearTimeout(n),this._auth&&this._auth.hasSession?t.reject(p.connectionClosed):t.reject(p.connectionRequired),[2]}))}))}))}}}))}return Object.defineProperty(e.prototype,"isReady",{get:function(){return this._currentConnectionStateType===J.CONNECTED},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"isLazyCallActivated",{get:function(){return this._currentConnectionStateType===J.CONNECTING||this._currentConnectionStateType===J.RECONNECTING},enumerable:!1,configurable:!0}),e.prototype.send=function(e){return r(this,void 0,void 0,(function(){var t,n,r=this;return i(this,(function(i){switch(i.label){case 0:return e instanceof H?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 ee,this._lazyCallQueue.push({command:e,deferred:t,timeout:setTimeout((function(){return r.timeout(e.requestId)}),1e4)}),[2,t.promise];throw this._logger.debug("fail websocket request"),p.connectionRequired;case 3:return[3,7];case 4:return e instanceof q?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 ee,this._lazyCallQueue.push({command:e,deferred:t,timeout:setTimeout((function(){return r.timeout(e.requestId)}),1e4)}),[2,t.promise];throw n=p.connectionRequired,this._logger.debug("fail api request",n),n;case 7:return[2]}}))}))},e.prototype.forceSend=function(e){return r(this,void 0,void 0,(function(){return i(this,(function(t){switch(t.label){case 0:return this._logger.debug("send 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(p.connectionRequired),this._lazyCallQueue.splice(t,1))},e.prototype.cancel=function(e){this._logger.debug("cancel api request",e),this.commandRouter.cancel(e)},e.prototype.cancelAll=function(){this._logger.debug("cancel all api requests"),this.commandRouter.cancelAll()},e}(),pe="/".concat("v3","/users"),fe="/".concat("v3","/storage/file"),_e="/".concat("v3","/group_channels"),ge="/".concat("v3","/sdk/group_channels"),ye="/".concat("v3","/open_channels"),me="/".concat("v3","/sdk/open_channels"),ve="/".concat("v3","/search"),Ee="/".concat("v3","/report"),Ie="/".concat("v3","/emojis"),Se="/".concat("v3","/emoji_categories"),Te="/".concat("v3","/polls"),be="/".concat("v3","/scheduled_messages"),Ne="/".concat("v3","/sdk/statistics"),Ae=function(e){function n(t){var n=t.userId,r=t.authToken,i=t.expiringSession,s=void 0===i||i,o=e.call(this)||this;return o.path="".concat(pe,"/").concat(n,"/session_key"),o.method=d.POST,o.params={token:r,expiring_session:!!s},o.requireAuth=!1,o}return t(n,e),n}(q),Ce=function(e){function n(t){var n=t.authToken,r=t.expiringSession,i=void 0===r||r;return e.call(this,{code:"LOGI",payload:{token:n,expiring_session:i?1:0},ackRequired:!0})||this}return t(n,e),n}(H),Oe=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}(x),we=function(e){function n(t,n,r){var i=e.call(this,t,"LOGI",r)||this;return i.error=null,i.newKey=r.new_key,i.error=r.error?new p(r.error):null,i}return t(n,e),n}(B),Re=function(e){function n(){return null!==e&&e.apply(this,arguments)||this}return t(n,e),n}(L),De=function(e){return r(void 0,void 0,void 0,(function(){return i(this,(function(t){return[2,new Promise((function(t){return setTimeout(t,e)}))]}))}))},Me=function(){function e(){}return e.prototype.calcTimeout=function(){return 0},e}(),ke=function(e,t,n){return void 0===n&&(n=new Me),r(void 0,void 0,void 0,(function(){var r,s,o,a,u,c;return i(this,(function(i){switch(i.label){case 0:r=0,s=null,o=function(e){return void 0===e&&(e=null),s=null!=e?e:new Error("Halted")},a=function(){r=0},i.label=1;case 1:if(!(-1===t||r0?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 dt({userProfile:this}))},e}(),pt=function(e){function r(t,n,r){var i,s=this;return(s=e.call(this,t,n,r)||this).error=null,s.userProfile=new ht(t,r),s.key=r.key,s.ekey=null!==(i=r.ekey)&&void 0!==i?i:"",s.error=r.error?new p(r):null,s}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){if(this.error)throw this.error;var t=Tt.of(e);if(!t)throw p.lostInstance;t.sessionManager.auth.sessionKey=this.key,ze(e,this.ekey),this.userProfile.apply()},r}(B),ft=function(e){function n(t){var n=e.call(this)||this;return n.enabled=t,n}return t(n,e),n}(L),_t=function(e){function n(t,n){var r=n.sdkState,i=n.cacheContext,s=n.connectionHandlers,o=n.sessionManager,a=n.websocketClient,u=n.dispatcher,c=n.logger,l=n.entryState,d=void 0===l?new Ke:l,h=e.call(this)||this;return h._currentState=null,h._loginTimer=null,h._connectingAt=0,h._connectionRequestQueue=[],h._iid=t,h.sdkState=r,h.cacheContext=i,h.connectionHandlers=s,h._sessionManager=o,h._websocketClient=a,h._dispatcher=u,h._logger=c,h._currentState=d,h._websocketClient.on("message",(function(e){if("LOGI"===e.code){h._loginTimer&&(clearTimeout(h._loginTimer),h._loginTimer=null);var t=e.as(pt);if(t.error)(t.error.isSessionKeyExpiredError||t.error.isSessionTokenExpiredError)&&h._dispatcher.dispatch(new G),h._connectionRequestQueue.forEach((function(e){return e.reject(t.error)})),h._statLogConnection(t.error);else{t.applyTo(h._iid),h._connectionRequestQueue.forEach((function(e){return e.resolve()}));var n=t.userProfile;h._enableStatLog(n.appInfo.applicationAttributes.includes("allow_sdk_request_log_publish")),h._statLogConnection(null)}h._connectionRequestQueue=[]}})).on("close",(function(){h._connectionRequestQueue.length>0&&(h._connectionRequestQueue.forEach((function(e){return e.reject(p.networkError)})),h._connectionRequestQueue=[],h._statLogConnection(p.networkError))})),h}return t(n,e),Object.defineProperty(n.prototype,"currentState",{get:function(){return this._currentState},enumerable:!1,configurable:!0}),n.prototype.changeState=function(e){return r(this,void 0,void 0,(function(){return i(this,(function(t){switch(t.label){case 0:return this._currentState=e,this._dispatcher.dispatch(new de({stateType:e.type})),this._logger.debug("connection state changes to ".concat(e.name)),[4,this._currentState.run(this)];case 1:return t.sent(),[2]}}))}))},n.prototype._url=function(e){void 0===e&&(e="");var t=this.sdkState,n=t.appId,r=t.appVersion,i=t.userId,s=t.extensions,o=this.cacheContext.localCacheEnabled,a=this._sessionManager.auth,u=s.sb_syncmanager?"s".concat(s.sb_syncmanager):"",c=s.sb_uikit?"u".concat(s.sb_uikit):"",d="JS/c".concat(l.SDK_VERSION,"/").concat(u,"/").concat(c);return"".concat(this.sdkState.websocket.host,"/?p=JS&pv=").concat(encodeURIComponent(l.OS_VERSION),"&sv=").concat(encodeURIComponent(l.SDK_VERSION),"&ai=").concat(n).concat(r?"&av=".concat(r):"").concat(a.hasSession?"&key=".concat(encodeURIComponent(a.sessionKey)):"&user_id=".concat(encodeURIComponent(i),"&access_token=").concat(encodeURIComponent(e)),"&active=1&SB-User-Agent=").concat(d,"&Request-Sent-Timestamp=").concat(Date.now().toString(),"&include_extra_data=").concat(encodeURIComponent(String(["premium_feature_list","file_upload_size_limit","application_attributes","emoji_hash"]))).concat(this._sessionManager.handler?"&expiring_session=1":"","&use_local_cache=").concat(o?1:0,"&include_poll_details=1")},n.prototype._enableStatLog=function(e){this._dispatcher.dispatch(new ft(e))},n.prototype._statLogConnection=function(e){this._dispatcher.dispatch(new Q(new K({type:P.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=""),r(this,void 0,void 0,(function(){var t,n,r=this;return i(this,(function(i){return t=this._url(e),n=new ee,this._connectionRequestQueue.push(n),1===this._connectionRequestQueue.length&&(this._connectingAt=Date.now(),this._loginTimer=setTimeout((function(){r._loginTimer=null,r._dispatcher.dispatch(pt.asError(p.loginTimeout))}),this.sdkState.websocket.responseTimeout),this._websocketClient.connect(t)),[2,n.promise]}))}))},n.prototype.cancelConnectForRetry=function(){this._dispatcher.dispatch(pt.asError(p.connectionRenew))},n.prototype.disconnect=function(){this._websocketClient.disconnect()},n.prototype.logout=function(){this.sdkState.userId=null,this._sessionManager.currentUser=null,this._sessionManager.auth.clear(),this.disconnect()},n}(M),gt=function(){function e(e,t){var n=t.sdkState,r=t.cacheContext,i=t.connectionHandlers,s=t.sessionManager,o=t.websocketClient,a=t.dispatcher,u=t.logger,c=t.disableAutoReconnect,l=void 0!==c&&c,d=this;this._context=null,this._logger=u,this._context=new _t(e,{sdkState:n,cacheContext:r,connectionHandlers:i,sessionManager:s,websocketClient:o,dispatcher:a,logger:u}),l||(s.on("refresh-authtoken",(function(){d.isConnected||(d._logger.debug("try reconnect by session token refresh"),d.reconnect())})).on("refresh",(function(){d.isConnecting||d.isConnected||(d._logger.debug("try reconnect by session key refresh"),d.reconnect())})),o.on("close",(function(){"foreground"===n.appState&&setTimeout((function(){s.isRefreshingAuthToken||(d._logger.debug("try reconnect by websocket connection closed"),d.reconnect())}),100)})))}return Object.defineProperty(e.prototype,"isConnected",{get:function(){return this._context.currentState.type===J.CONNECTED},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"isConnecting",{get:function(){var e=this._context.currentState;return e.type===J.CONNECTING||e.type===J.RECONNECTING},enumerable:!1,configurable:!0}),e.prototype.connect=function(e){return r(this,void 0,void 0,(function(){return i(this,(function(t){switch(t.label){case 0:return[4,this._context.currentState.onConnect(this._context,e)];case 1:return t.sent(),[2]}}))}))},e.prototype.reconnect=function(){return r(this,void 0,void 0,(function(){return i(this,(function(e){switch(e.label){case 0:return[4,this._context.currentState.onReconnect(this._context,{})];case 1:return e.sent(),[2]}}))}))},e.prototype.resetAndReconnect=function(){return r(this,void 0,void 0,(function(){return i(this,(function(e){switch(e.label){case 0:return[4,this._context.currentState.onReconnect(this._context,{resetReconnectCount:!0})];case 1:return e.sent(),[2]}}))}))},e.prototype.background=function(){return r(this,void 0,void 0,(function(){return i(this,(function(e){switch(e.label){case 0:return[4,this._context.currentState.onDisconnect(this._context,{autoReconnect:!1})];case 1:return e.sent(),[2]}}))}))},e.prototype.disconnect=function(e){return void 0===e&&(e=null),r(this,void 0,void 0,(function(){return i(this,(function(t){switch(t.label){case 0:return[4,this._context.currentState.onDisconnect(this._context,{error:e,autoReconnect:!0})];case 1:return t.sent(),[2]}}))}))},e.prototype.logout=function(){return r(this,void 0,void 0,(function(){return i(this,(function(e){switch(e.label){case 0:return[4,this._context.currentState.onLogout(this._context)];case 1:return e.sent(),[2]}}))}))},e}(),yt=function(e){function n(t){var n=t.deviceId,r=t.statLogs,i=e.call(this)||this;return i.method=d.POST,i.path="".concat(Ne),i.params={device_id:n,log_entries:r.map((function(e){return K.payloadify(e)}))},i}return t(n,e),n}(q);!function(e){e[e.PENDING=0]="PENDING",e[e.ENABLED=1]="ENABLED",e[e.DISABLED=2]="DISABLED"}(ct||(ct={}));var mt,vt=function(){function e(e){var t=e.cacheContext,n=e.requestQueue,r=e.dispatcher,i=e.baseLimit,s=void 0===i?100:i,o=e.maxLimit,a=void 0===o?1e3:o,u=e.minLimit,c=void 0===u?10:u;this.queue=[],this.enabledstate=ct.PENDING,this.isFlushing=!1,this.generation=1,this.lastFlushedAt=0,this.deviceId=R(),this.cacheContext=t,this.requestQueue=n,this.dispatcher=r,this.baseLimit=s,this.limit=s,this.maxLimit=a,this.minLimit=c}return Object.defineProperty(e.prototype,"isEnabled",{get:function(){return this.enabledstate===ct.ENABLED},enumerable:!1,configurable:!0}),e.prototype._save=function(){return r(this,void 0,void 0,(function(){return i(this,(function(e){switch(e.label){case 0:return this.cacheContext.localCacheEnabled?[4,this.cacheContext.preference.set(this.key,{deviceId:this.deviceId,statLogs:this.queue.map((function(e){return K.payloadify(e)})),generation:this.generation++,lastFlushedAt:this.lastFlushedAt})]:[3,2];case 1:e.sent(),e.label=2;case 2:return[2]}}))}))},e.prototype._flush=function(){return r(this,void 0,void 0,(function(){var e,t;return i(this,(function(n){switch(n.label){case 0:if(!this.isEnabled)return[3,7];if(this.isFlushing)return[3,7];this.isFlushing=!0,n.label=1;case 1:return n.trys.push([1,5,6,7]),(e=this.queue.slice(0,Math.min(this.limit,this.maxLimit))).length>0?(t=new yt({deviceId:this.deviceId,statLogs:e}),[4,this.requestQueue.send(t)]):[3,4];case 2:return n.sent(),this.queue=this.queue.slice(e.length),[4,this._save()];case 3:n.sent(),n.label=4;case 4:return this.limit=this.baseLimit,this.lastFlushedAt=Date.now(),[3,7];case 5:return n.sent(),this.limit=this.limit+20,[3,7];case 6:return this.isFlushing=!1,[7];case 7:return[2]}}))}))},e.prototype.init=function(e){return r(this,void 0,void 0,(function(){var t,n,r=this;return i(this,(function(i){switch(i.label){case 0:return this.key=e,this.cacheContext.localCacheEnabled?[4,this.cacheContext.preference.get(this.key)]:[3,4];case 1:return(t=i.sent())?(this.deviceId=t.deviceId,this.queue=t.statLogs.map((function(e){return new K({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,De(n)]):[3,4]):[3,4];case 2:return i.sent(),[4,this._flush()];case 3:i.sent(),i.label=4;case 4:return this.dispatcher.on((function(e){if(e instanceof Q){var t=e.statLog;r.put(t)}else e instanceof ft&&(r.enabledstate=e.enabled?ct.ENABLED:ct.DISABLED,r.isEnabled?r.queue.length>=r.limit&&r._flush():r.clear())})),[2]}}))}))},e.prototype.put=function(e){return r(this,void 0,void 0,(function(){return i(this,(function(t){switch(t.label){case 0:return this.enabledstate===ct.DISABLED?[3,3]:(this.queue.push(e),[4,this._save()]);case 1:return t.sent(),this.queue.length>=this.limit?[4,this._flush()]:[3,3];case 2:t.sent(),t.label=3;case 3:return[2]}}))}))},e.prototype.clear=function(){return r(this,void 0,void 0,(function(){return i(this,(function(e){switch(e.label){case 0:return this.queue=[],this.generation=1,[4,this._save()];case 1:return e.sent(),[2]}}))}))},e}();!function(e){e[e.NONE=0]="NONE",e[e.VERBOSE=1]="VERBOSE",e[e.DEBUG=2]="DEBUG",e[e.INFO=3]="INFO",e[e.WARN=4]="WARN",e[e.ERROR=5]="ERROR"}(mt||(mt={}));var Et,It=function(){function e(){this.level=mt.WARN}return e.prototype.verbose=function(){for(var e=[],t=0;t0&&y("number",c)&&(this.key=i,this.userIds=u,this.updatedAt=c);var l={};try{for(var d=s(this.userIds),h=d.next();!h.done;h=d.next()){l[h.value]=this.updatedAt}}catch(e){t={error:e}}finally{try{h&&!h.done&&(n=d.return)&&n.call(d)}finally{if(t)throw t.error}}this._version=l}return Object.defineProperty(e.prototype,"isEmpty",{get:function(){return 0===this.userIds.length},enumerable:!1,configurable:!0}),e.payloadify=function(e){return e?U({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 Et.ADD:t<0&&this.userIds.push(e.userId);break;case Et.DELETE:t>=0&&this.userIds.splice(t,1)}this._version[e.userId]=e.updatedAt}this.updatedAt=Math.max(this.updatedAt,e.updatedAt)}},e}(),Mt=function(){function e(e){this.key=e.key,this.value=E("string",e.value)?a([],o(e.value),!1):[]}return e.payloadify=function(e){var t;return e?U({key:e.key,value:null!==(t=e.value)&&void 0!==t?t:[]}):null},e}(),kt=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?U({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}(),Lt=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 kt(e["og:image"]))}return e.payloadify=function(e){return e?U({"og:title":e.title,"og:url":e.url,"og:description":e.description,"og:image":e.defaultImage?kt.payloadify(e.defaultImage):null}):null},e}(),Ut=function(){function e(e){var t,n;this.name=null,this.volume=0,this.name=null!==(t=e.name)&&void 0!==t?t:"default",this.volume=null!==(n=e.volume)&&void 0!==n?n:1}return e.payloadify=function(e){return e?U({name:e.name,volume:e.volume}):null},e}();!function(e){e.PENDING="pending",e.SENT="sent",e.FAILED="failed",e.CANCELED="canceled"}(Ot||(Ot={})),function(e){e.PENDING="pending",e.IN_QUEUE="in_queue",e.SENT="sent",e.FAILED="failed",e.CANCELED="canceled",e.REMOVED="removed"}(wt||(wt={}));var Pt,qt=function(e){switch(e){case ie.BASE:return"";case ie.USER:return"MESG";case ie.FILE:return"FILE";case ie.ADMIN:return"ADMM"}},xt=function(e){function r(t,n){var r,i,s,o,a,u,c,l,d,h,p,f,_,g=this;(g=e.call(this,t)||this).channelUrl=null,g.channelType=ne.BASE,g.messageId=0,g.parentMessageId=null,g.parentMessage=null,g.silent=!1,g.isOperatorMessage=!1,g.messageType=ie.BASE,g.data=null,g.customType=null,g.mentionType=null,g.mentionedUsers=[],g.mentionedUserIds=[],g.mentionedMessageTemplate=null,g.threadInfo=null,g.reactions=[],g.metaArrays=[],g.ogMetaData=null,g.appleCriticalAlertOptions=null,g.createdAt=0,g.updatedAt=0,g.scheduledInfo=null,g._scheduledStatus=null,g.messageId=null!==(i=null!==(r=n.msg_id)&&void 0!==r?r:n.message_id)&&void 0!==i?i:0,g.channelUrl=n.channel_url,g.channelType=m(ne,n.channel_type)?n.channel_type:ne.GROUP,n.channel&&(n.channel.channel_url&&(g.channelUrl=n.channel.channel_url),n.channel.channel_type&&(g.channelType=n.channel.channel_type)),g.parentMessageId=null!==(s="string"==typeof n.parent_message_id?parseInt(n.parent_message_id):n.parent_message_id)&&void 0!==s?s:0,g.data=null!==(o=n.data)&&void 0!==o?o:"",g.customType=null!==(a=n.custom_type)&&void 0!==a?a:"",g.mentionType=m(ae,n.mention_type)?n.mention_type:null;var y=n.mentioned_users;g.mentionedUsers=y?y.map((function(e){return new lt(g._iid,e)})):null;var v=n.mentioned_user_ids;g.mentionedUserIds=null!=v?v:null,g.mentionedMessageTemplate=null!==(u=n.mentioned_message_template)&&void 0!==u?u:"",g.threadInfo=n.thread_info?new Ct(g._iid,n.thread_info):null,g.reactions=n.reactions?n.reactions.map((function(e){return new Dt(e)})):[];for(var E=null!==(c=n.metaarray)&&void 0!==c?c:{},I=null!==(l=n.metaarray_key_order)&&void 0!==l?l:Object.keys(E).sort((function(e,t){return e.localeCompare(t)})),S=0;S=t)return this.parentMessage=e,!0}return!1},r}(He),Ft=function(e){function r(t,n){var r=e.call(this,t,n)||this;return r.role=null,r.isBlockedByMe=!1,r.role=m(re,n.role)?n.role:re.NONE,n.hasOwnProperty("is_blocked_by_me")&&(r.isBlockedByMe=n.is_blocked_by_me),r}return t(r,e),r.payloadify=function(t){return t?U(n(n({},e.payloadify.call(this,t)),{role:t.role,is_blocked_by_me:t.isBlockedByMe})):null},r}(lt),Gt=function(e){function r(t,n){var r,i,s,o,a=this;if((a=e.call(this,t,n)||this).sender=null,a.reqId="",a.replyToChannel=!1,a.sendingStatus=null,a.errorCode=0,a.sender=n.user?new Ft(a._iid,n.user):n.sender_id,a.reqId=null!==(i=null!==(r=n.req_id)&&void 0!==r?r:n.request_id)&&void 0!==i?i:"",a.replyToChannel=null!==(s=n.is_reply_to_channel)&&void 0!==s&&s,n.request_state&&m(le,n.request_state)&&(a.sendingStatus=n.request_state),!a.sendingStatus)if(a.messageId>0)a.sendingStatus=le.SUCCEEDED;else if(a.scheduledInfo)switch(a._scheduledStatus=n.scheduled_status,n.scheduled_status){case wt.SENT:case wt.IN_QUEUE:a.sendingStatus=le.SUCCEEDED;break;case wt.PENDING:a.sendingStatus=le.SCHEDULED;break;case wt.FAILED:case wt.REMOVED:a.sendingStatus=le.FAILED;break;case wt.CANCELED:a.sendingStatus=le.CANCELED}else a.sendingStatus=le.PENDING;return a.errorCode=null!==(o=n.error_code)&&void 0!==o?o:0,a}return t(r,e),r.payloadify=function(t){return t?U(n(n({},e.payloadify.call(this,t)),{user:Ft.payloadify(t.sender),req_id:t.reqId,is_reply_to_channel:t.replyToChannel,request_state:t.sendingStatus,error_code:t.errorCode})):null},Object.defineProperty(r.prototype,"isResendable",{get:function(){return this.sendingStatus===le.FAILED&&((e=this.errorCode)>0&&f.indexOf(e)>=0);var e},enumerable:!1,configurable:!0}),r.prototype.isIdentical=function(e){return this.messageId>0&&e.messageId>0?this.messageId===e.messageId:this.reqId===e.reqId},r}(xt),Qt=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?U({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}(),jt={prevResultSize:0,nextResultSize:0,isInclusive:!1,reverse:!1,messageTypeFilter:se.ALL,customTypesFilter:null,senderUserIdsFilter:null,includeReactions:!1,includeMetaArray:!1,includeParentMessageInfo:!1},Kt=function(e){return y("number",e.prevResultSize)&&y("number",e.nextResultSize)&&y("boolean",e.isInclusive)&&y("boolean",e.reverse)&&y("string",e.messageTypeFilter)&&m(se,e.messageTypeFilter)&&E("string",e.customTypesFilter,!0)&&E("string",e.senderUserIdsFilter,!0)&&y("boolean",e.includeMetaArray)&&y("boolean",e.includeReactions)&&y("boolean",e.includeParentMessageInfo)},Vt=function(e){function s(t,r){var i,s,o,a,u=this;if((u=e.call(this,t,r)||this).message=null,u.translations={},u.message=null!==(i=r.message)&&void 0!==i?i:"",u.messageType=ie.ADMIN,u.translations=null!==(s=r.translations)&&void 0!==s?s:{},r.parent_message_info){var c=r.parent_message_info,l=n(n({},c),{message_id:u.parentMessageId,channel_url:u.channelUrl,channel_type:u.channelType,file:c.file,url:null===(o=c.file)||void 0===o?void 0:o.url,require_auth:null===(a=c.file)||void 0===a?void 0:a.require_auth});u.parentMessage=tn(t,l)}return u}return t(s,e),s.payloadify=function(t){return t?U(n(n({},e.payloadify.call(this,t)),{message:t.message,translations:t.translations,parent_message_info:en(t.parentMessage)})):null},s.prototype.getThreadedMessagesByTimestamp=function(e,t){return r(this,void 0,void 0,(function(){var r;return i(this,(function(i){switch(i.label){case 0:return r=n(n({},jt),t),ut(this.messageId>0&&y("number",e)&&Kt(r)).throw(p.invalidParameters),[4,Dn.of(this._iid).getThreadedMessagesByTimestamp(this,e,r)];case 1:return[2,i.sent()]}}))}))},s}(xt),zt=function(){function e(e){var t,n;this.type=null,this.vendor=null,this.detail={},this.type=null!==(t=e.type)&&void 0!==t?t:"",this.vendor=null!==(n=e.vendor)&&void 0!==n?n:"",e.hasOwnProperty("detail")&&y("object",e.detail)&&!Array.isArray(e.detail)&&(this.detail=e.detail)}return e.payloadify=function(e){return e?U({type:e.type,vendor:e.vendor,detail:e.detail}):null},e}();!function(e){e.OPEN="open",e.CLOSED="closed"}(Pt||(Pt={}));var Bt,Ht="removed",Wt=function(e){switch(e){case Pt.OPEN:return Pt.OPEN;case Pt.CLOSED:return Pt.CLOSED}},Yt=function(e){return!e||e.text&&y("string",e.text)},Xt=function(e){return E("string",e)&&e.every((function(e){return""!==e.trim()}))},Jt=function(e){function r(t,n){var r,i,s,o,a,u,c,l=this;return(l=e.call(this,t)||this).pollId=0,l.id=0,l.text=null,l.voteCount=0,l.createdBy=null,l.createdAt=0,l.updatedAt=0,l._lastVotedAt=0,l.pollId=null!==(r=n.poll_id)&&void 0!==r?r:0,l.id=null!==(i=n.id)&&void 0!==i?i:0,l.text=null!==(s=n.text)&&void 0!==s?s:null,l.voteCount=null!==(o=n.vote_count)&&void 0!==o?o:0,l.createdBy=null!==(a=n.created_by)&&void 0!==a?a:null,l.createdAt=null!==(u=n.created_at)&&void 0!==u?u:0,l.updatedAt=null!==(c=n.updated_at)&&void 0!==c?c:0,l}return t(r,e),r.payloadify=function(t){return t?U(n(n({},e.payloadify.call(this,t)),{vote_count:t.voteCount,poll_id:t.pollId,text:t.text,created_at:t.createdAt,id:t.id,created_by:t.createdBy,updated_at:t.updatedAt})):null},r}(He),Zt=function(e){function r(t,n){var r,i,s,o,a,u,c,l,d,h,p,f,_,g=this;return(g=e.call(this,t)||this).id=0,g.title=null,g.createdAt=0,g.updatedAt=0,g.closeAt=-1,g.status=Pt.CLOSED,g.messageId=0,g.data=null,g.voterCount=-1,g.options=[],g.createdBy=null,g.allowUserSuggestion=!1,g.allowMultipleVotes=!1,g.votedPollOptionIds=[],g.id=null!==(r=n.id)&&void 0!==r?r:0,g.title=null!==(i=n.title)&&void 0!==i?i:null,g.createdAt=null!==(s=n.created_at)&&void 0!==s?s:0,g.updatedAt=null!==(o=n.updated_at)&&void 0!==o?o:0,g.closeAt=null!==(a=n.close_at)&&void 0!==a?a:-1,g.status=null!==(u=Wt(n.status))&&void 0!==u?u:Pt.CLOSED,g.messageId=null!==(c=n.message_id)&&void 0!==c?c:0,g.data=null!==(l=n.data)&&void 0!==l?l:null,g.voterCount=null!==(d=n.voter_count)&&void 0!==d?d:-1,g.options=n.options?n.options.map((function(e){return new Jt(g._iid,e)})):[],g.createdBy=null!==(h=n.created_by)&&void 0!==h?h:null,g.allowUserSuggestion=null!==(p=n.allow_user_suggestion)&&void 0!==p&&p,g.allowMultipleVotes=null!==(f=n.allow_multiple_votes)&&void 0!==f&&f,g.votedPollOptionIds=null!==(_=n.voted_option_ids)&&void 0!==_?_:[],g}return t(r,e),r.prototype._applyPollUpdatePayload=function(e){var t,n,r,i,s,o,a,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!==(i=Wt(e.status))&&void 0!==i?i:this.status,this.data=null!==(s=e.data)&&void 0!==s?s:this.data,this.voterCount=null!==(o=e.voter_count)&&void 0!==o?o:this.voterCount,this.options=e.options?e.options.map((function(e){return new Jt(c._iid,e)})):this.options,this.allowUserSuggestion=null!==(a=e.allow_user_suggestion)&&void 0!==a?a:this.allowUserSuggestion,this.allowMultipleVotes=null!==(u=e.allow_multiple_votes)&&void 0!==u?u:this.allowMultipleVotes},r.payloadify=function(t){return t?U(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 Jt.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 s=t[r];i>s._lastVotedAt&&(s.voteCount=e.vote_count,s._lastVotedAt=i)}})),r.req_id&&r.voted_option_ids&&(this.votedPollOptionIds=r.voted_option_ids),!0},r}(He),$t=function(e){function o(t,r){var i,o,a,u,c,l,d,h=this;if((h=e.call(this,t,r)||this).message="",h.messageParams=null,h.translations={},h.translationTargetLanguages=[],h.messageSurvivalSeconds=-1,h.plugins=[],h._poll=null,h.message=r.message,h.messageType=ie.USER,h.translations=null!==(a=r.translations)&&void 0!==a?a:{},h.translationTargetLanguages=null!==(u=r.target_langs)&&void 0!==u?u:[],0===Object.keys(h.translations).length&&h.translationTargetLanguages.length>0)try{for(var p=s(h.translationTargetLanguages),f=p.next();!f.done;f=p.next()){var _=f.value;h.translations[_]=""}}catch(e){i={error:e}}finally{try{f&&!f.done&&(o=p.return)&&o.call(p)}finally{if(i)throw i.error}}if(h.messageSurvivalSeconds=null!==(c=r.message_survival_seconds)&&void 0!==c?c:-1,h.plugins=r.plugins?r.plugins.map((function(e){return new zt(e)})):[],h._poll=r.poll?new Zt(h._iid,r.poll):null,r.parent_message_info){var g=r.parent_message_info,y=n(n({},g),{created_at:g.ts,message_id:h.parentMessageId,channel_url:h.channelUrl,channel_type:h.channelType,file:g.file,url:null===(l=g.file)||void 0===l?void 0:l.url,require_auth:null===(d=g.file)||void 0===d?void 0:d.require_auth});h.parentMessage=tn(t,U(y))}return h}return t(o,e),o.payloadify=function(t){return t?U(n(n({},e.payloadify.call(this,t)),{message:t.message,translations:t.translations,message_survival_seconds:t.messageSurvivalSeconds,plugins:t.plugins.map((function(e){return zt.payloadify(e)})),poll:Zt.payloadify(t._poll),parent_message_info:en(t.parentMessage)})):null},o.prototype.getThreadedMessagesByTimestamp=function(e,t){return r(this,void 0,void 0,(function(){var r;return i(this,(function(i){switch(i.label){case 0:return r=n(n({},jt),t),ut(this.messageId>0&&y("number",e)&&Kt(r)).throw(p.invalidParameters),[4,Dn.of(this._iid).getThreadedMessagesByTimestamp(this,e,r)];case 1:return[2,i.sent()]}}))}))},o.prototype.applyPoll=function(e){return!(this._poll&&this._poll.id===e.id&&this._poll.updatedAt>e.updatedAt)&&(this._poll=e,!0)},Object.defineProperty(o.prototype,"poll",{get:function(){return this._poll},enumerable:!1,configurable:!0}),o}(Gt),en=function(e){if(e)switch(e.messageType){case ie.USER:return $t.payloadify(e);case ie.FILE:return nn.payloadify(e);case ie.ADMIN:return Vt.payloadify(e)}return null},tn=function(e,t){switch(t.type){case"MESG":return new $t(e,t);case"FILE":return new nn(e,t);case"ADMM":case"BRDM":return new Vt(e,t)}return null},nn=function(e){function s(t,r){var i,s,o,a,u,c,l,d,h,p,f,_,g,y,m,v=this;(v=e.call(this,t,r)||this).messageParams=null,v.plainUrl="",v.requireAuth=!1,v.name=null,v.size=0,v.type=null,v.thumbnails=[],v.messageSurvivalSeconds=-1,v.messageType=ie.FILE;var E=null!==(i=r.file)&&void 0!==i?i:null;if(v.plainUrl=(null!==(o=null!==(s=null==E?void 0:E.url)&&void 0!==s?s:r.url)&&void 0!==o?o:"").split("?auth=")[0],v.name=null!==(u=null!==(a=null==E?void 0:E.name)&&void 0!==a?a:r.name)&&void 0!==u?u:"File",v.size=null!==(l=null!==(c=null==E?void 0:E.size)&&void 0!==c?c:r.size)&&void 0!==l?l:0,v.data=null!==(h=null!==(d=null==E?void 0:E.data)&&void 0!==d?d:r.custom)&&void 0!==h?h:"",v.type=E?null!==(p=E.type)&&void 0!==p?p:"":null!==(f=r.type)&&void 0!==f?f:"",v.requireAuth=null!==(_=r.require_auth)&&void 0!==_&&_,v.thumbnails=r.thumbnails?r.thumbnails.map((function(e){return new Qt(n(n({},e),{url:"".concat(e.url.split("?auth=")[0]).concat(v.requireAuth?"?auth=".concat(ze(v._iid)):"")}))})):[],v.messageSurvivalSeconds=null!==(g=r.message_survival_seconds)&&void 0!==g?g:-1,r.parent_message_info){var I=r.parent_message_info,S=n(n({},I),{message_id:v.parentMessageId,channel_url:v.channelUrl,channel_type:v.channelType,file:I.file,url:null===(y=I.file)||void 0===y?void 0:y.url,require_auth:null===(m=I.file)||void 0===m?void 0:m.require_auth});v.parentMessage=tn(t,S)}return v}return t(s,e),s.payloadify=function(t){return t?U(n(n({},e.payloadify.call(this,t)),{url:t.plainUrl,require_auth:t.requireAuth,file:{name:t.name,size:t.size,type:t.type,data:t.data},thumbnails:t.thumbnails.map((function(e){return{url:e.url,width:e.width,height:e.height,real_width:e.realWidth,real_height:e.realHeight}})),message_survival_seconds:t.messageSurvivalSeconds,parent_message_info:en(t.parentMessage)})):null},Object.defineProperty(s.prototype,"url",{get:function(){return this.requireAuth?"".concat(this.plainUrl,"?auth=").concat(ze(this._iid)):this.plainUrl},enumerable:!1,configurable:!0}),s.prototype.getThreadedMessagesByTimestamp=function(e,t){return r(this,void 0,void 0,(function(){var r;return i(this,(function(i){switch(i.label){case 0:return r=n(n({},jt),t),ut(this.messageId>0&&y("number",e)&&Kt(r)).throw(p.invalidParameters),[4,Dn.of(this._iid).getThreadedMessagesByTimestamp(this,e,r)];case 1:return[2,i.sent()]}}))}))},s}(Gt),rn=function(e){function n(t){var n,r,i,s=[];return t.mentionType===ae.USERS&&(t.mentionedUserIds?s=t.mentionedUserIds:t.mentionedUsers&&(s=t.mentionedUsers.map((function(e){return e.userId})))),e.call(this,{code:"FILE",ackRequired:!0,payload:U({channel_url:t.channelUrl,url:t.url,name:null!==(n=t.fileName)&&void 0!==n?n:"",type:null!==(r=t.mimeType)&&void 0!==r?r:"",size:null!==(i=t.fileSize)&&void 0!==i?i:0,custom:t.data,custom_type:t.customType,thumbnails:t.thumbnailSizes,require_auth:t.requireAuth,metaarray:t.metaArrays,mention_type:t.mentionType,mentioned_user_ids:s,push_option:t.pushNotificationDeliveryOption&&t.pushNotificationDeliveryOption!==ce.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})})||this}return t(n,e),n}(H),sn=function(e){function n(t){var n,r=this;r=e.call(this)||this;var i=[];return t.mentionType===ae.USERS&&(t.mentionedUserIds?i=t.mentionedUserIds:t.mentionedUsers&&(i=t.mentionedUsers.map((function(e){return e.userId})))),r.method=d.POST,r.path="".concat(Ye(t.channelType),"/").concat(encodeURIComponent(t.channelUrl),"/messages"),r.params=U({message_type:ie.FILE,user_id:t.userId,url:t.fileUrl,mention_type:t.mentionType,mentioned_user_ids:i,file_name:t.fileName,file_size:t.fileSize,file_type:t.mimeType,data:t.data,custom_type:t.customType,thumbnails:t.thumbnailSizes.map((function(e){return Qt.payloadify(e)})),require_auth:t.requireAuth,sorted_metaarray:null===(n=t.metaArrays)||void 0===n?void 0:n.map((function(e){return Mt.payloadify(e)})),push_option:t.pushNotificationDeliveryOption,parent_message_id:t.parentMessageId>0?t.parentMessageId:null,apple_critical_alert_options:Ut.payloadify(t.appleCriticalAlertOptions),reply_to_channel:t.isReplyToChannel,req_id:t.reqId}),r}return t(n,e),n}(q),on=function(e){function n(t,n,r){var i,s,o,a=this;(a=e.call(this,t,"FILE",r)||this).message=new nn(t,r);var u=Tt.of(t).sdkState;return a.isMentioned=Je(a.message.mentionType,null!==(i=a.message.mentionedUserIds)&&void 0!==i?i:null===(s=a.message.mentionedUsers)||void 0===s?void 0:s.map((function(e){return e.userId})),u.userId),a.forceUpdateLastMessage=null!==(o=r.force_update_last_message)&&void 0!==o&&o,a}return t(n,e),n}(B),an=function(e){function n(t,n){var r,i,s=this;(s=e.call(this,t,n)||this).message=new nn(t,n);var o=Tt.of(t).sdkState;return s.isMentioned=Je(s.message.mentionType,null!==(r=s.message.mentionedUserIds)&&void 0!==r?r:s.message.mentionedUsers.map((function(e){return e.userId})),o.userId),s.forceUpdateLastMessage=null!==(i=n.force_update_last_message)&&void 0!==i&&i,s}return t(n,e),n}(x);!function(e){e[e.PENDING=0]="PENDING",e[e.UPLOADING=1]="UPLOADING",e[e.UPLOADED=2]="UPLOADED",e[e.SENDING=3]="SENDING",e[e.FAILED=4]="FAILED"}(Bt||(Bt={}));var un,cn=function(){function e(e,t){var n=t.sdkState,r=t.dispatcher,i=t.requestQueue,s=t.onlineDetector,o=t.cacheContext,a=this;this._queueMap=new Map,this._connectionState=null,this._onlineDetector=null,this._iid=e,this._sdkState=n,this._requestQueue=i,this._cacheContext=o,this._dispatcher=r,this._dispatcher.on((function(e){e instanceof de&&(a._connectionState=e.stateType)})),this._onlineDetector=s}return Object.defineProperty(e.prototype,"_shouldSendThroughWebSocket",{get:function(){return this._connectionState===J.CONNECTED||this._connectionState===J.CONNECTING||this._connectionState===J.RECONNECTING},enumerable:!1,configurable:!0}),e.prototype._sendFileMessage=function(e,t){return r(this,void 0,void 0,(function(){var r,s;return i(this,(function(i){switch(i.label){case 0:return this._shouldSendThroughWebSocket?(r=new rn(n(n({channelUrl:e.url,channelType:e.channelType,url:t.params.fileUrl,requireAuth:t.requireAuth},t.params),{reqId:t.requestId})),[4,this._requestQueue.send(r)]):[3,2];case 1:return s=i.sent(),[2,s.as(on).message];case 2:return r=new sn(n(n({channelUrl:e.url,channelType:e.channelType,url:t.params.fileUrl,userId:this._sdkState.userId,requireAuth:t.requireAuth},t.params),{reqId:t.requestId})),[4,this._requestQueue.send(r)];case 3:return s=i.sent(),[2,s.as(an).message]}}))}))},e.prototype._resolveMessageQueue=function(e){return r(this,void 0,void 0,(function(){var t,n,r,o,a,c,l,d,h,f,_,g;return i(this,(function(i){switch(i.label){case 0:if(!(t=this._queueMap.get(e.url)))return[3,21];if(t.isResolving)return[3,20];t.isResolving=!0,n=[],r=!0,i.label=1;case 1:i.trys.push([1,15,16,17]),o=s(t.messageQueue),a=o.next(),i.label=2;case 2:if(a.done)return[3,14];switch(c=a.value,c.state){case Bt.PENDING:case Bt.UPLOADING:return[3,3];case Bt.UPLOADED:return[3,4];case Bt.FAILED:return[3,12]}return[3,13];case 3:return r=!1,n.push(c),[3,13];case 4:if(!r)return[3,10];i.label=5;case 5:return i.trys.push([5,8,,9]),c.state=Bt.SENDING,[4,this._sendFileMessage(e,c)];case 6:return l=i.sent(),c.deferred.resolve(l),[4,De(100)];case 7:return i.sent(),[3,9];case 8:return d=i.sent(),c.deferred.reject(d),[3,9];case 9:return[3,11];case 10:n.push(c),i.label=11;case 11:return[3,13];case 12:return c.deferred.reject(c.error.code===u.REQUEST_CANCELED?p.fileUploadCanceled:c.error),[3,13];case 13:return a=o.next(),[3,2];case 14:return[3,17];case 15:return h=i.sent(),_={error:h},[3,17];case 16:try{a&&!a.done&&(g=o.return)&&g.call(o)}finally{if(_)throw _.error}return[7];case 17:return f=t.isResolveRequestPending,t.messageQueue=n,t.isResolving=!1,t.isResolveRequestPending=!1,f?[4,this._resolveMessageQueue(e)]:[3,19];case 18:i.sent(),i.label=19;case 19:return[3,21];case 20:t.isResolveRequestPending=!0,i.label=21;case 21:return[2]}}))}))},e.prototype._uploadNextPendingItem=function(e){return r(this,void 0,void 0,(function(){var t,n,r,s,o,a,c,l,d,h,f,_,g,y;return i(this,(function(i){switch(i.label){case 0:return t=this._queueMap.get(e.url),(n=t.messageQueue.find((function(e){return e.state===Bt.PENDING})))?S(n.params.file)?t.uploadQueue.length<6?(n.state=Bt.UPLOADING,t.uploadQueue.push(n),[4,this._onlineDetector.isOnline()]):[3,10]:[3,11]:[3,13];case 1:if(!i.sent())return[3,8];i.label=2;case 2:return i.trys.push([2,4,5,7]),r=new Nt({file:n.params.file,channelUrl:e.url,thumbnailSizes:n.params.thumbnailSizes,requestId:n.requestId}),[4,this._requestQueue.send(r)];case 3:return s=i.sent(),o=s.as(At),a=o.url,c=o.fileSize,l=void 0===c?n.params.fileSize:c,d=o.thumbnailSizes,h=void 0===d?n.params.thumbnailSizes:d,f=o.requireAuth,_=void 0!==f&&f,n.params.fileUrl=a,n.params.fileSize=l,n.params.thumbnailSizes=h,n.params.requireAuth=_,n.requireAuth=_,n.state=Bt.UPLOADED,[3,7];case 4:return(g=i.sent()).code===u.REQUEST_FAILED?n.error=new p({code:u.NETWORK_ERROR,message:"Failed to upload a file."}):n.error=g,n.state=Bt.FAILED,[3,7];case 5:return(y=t.uploadQueue.findIndex((function(e){return e.requestId===n.requestId})))>=0&&(t.uploadQueue.splice(y,1),this._uploadNextPendingItem(e)),[4,this._resolveMessageQueue(e)];case 6:return i.sent(),[7];case 7:return[3,10];case 8:return n.state=Bt.FAILED,n.error=p.connectionRequired,(y=t.uploadQueue.findIndex((function(e){return e.requestId===n.requestId})))>=0&&(t.uploadQueue.splice(y,1),this._uploadNextPendingItem(e)),[4,this._resolveMessageQueue(e)];case 9:i.sent(),i.label=10;case 10:return[3,13];case 11:return n.params.thumbnailSizes=[],n.state=Bt.UPLOADED,[4,this._resolveMessageQueue(e)];case 12:i.sent(),i.label=13;case 13:return[2]}}))}))},e.prototype.request=function(e,t,n){var s,o,a;return r(this,void 0,void 0,(function(){var r;return i(this,(function(i){return r=new ee,S(n.file)&&(n.fileName=null!==(s=n.fileName)&&void 0!==s?s:n.file.name,n.mimeType=null!==(o=n.mimeType)&&void 0!==o?o:n.file.type,n.fileSize=null!==(a=n.fileSize)&&void 0!==a?a:n.file.size),this._queueMap.has(e.url)||this._queueMap.set(e.url,{messageQueue:[],uploadQueue:[],isResolving:!1,isResolveRequestPending:!1}),this._queueMap.get(e.url).messageQueue.push({requestId:t,params:n,state:Bt.PENDING,deferred:r,requireAuth:n.requireAuth}),this._uploadNextPendingItem(e),[2,r.promise]}))}))},e.prototype.cancel=function(e,t){var n,r;void 0===t&&(t=null);var i=this._queueMap.get(e.url);if(i){var u=t?[i.messageQueue.find((function(e){return e.requestId===t}))]:a([],o(i.messageQueue),!1);try{for(var c=s(u),l=c.next();!l.done;l=c.next()){var d=l.value;if(d)switch(d.state){case Bt.PENDING:d.state=Bt.FAILED,d.error=p.requestCanceled,this._resolveMessageQueue(e);break;case Bt.UPLOADING:this._requestQueue.cancel(d.requestId)}}}catch(e){n={error:e}}finally{try{l&&!l.done&&(r=c.return)&&r.call(c)}finally{if(n)throw n.error}}}},e}(),ln={prevResultSize:0,nextResultSize:0,isInclusive:!1,reverse:!1,messageTypeFilter:se.ALL,customTypesFilter:null,senderUserIdsFilter:null,replyType:ue.NONE,includeReactions:!1,includeMetaArray:!1,includeParentMessageInfo:!1,includeThreadInfo:!1,showSubchannelMessagesOnly:!1},dn=function(e){return y("number",e.prevResultSize)&&y("number",e.nextResultSize)&&y("boolean",e.isInclusive)&&y("boolean",e.reverse)&&y("string",e.messageTypeFilter)&&m(se,e.messageTypeFilter)&&E("string",e.customTypesFilter,!0)&&E("string",e.senderUserIdsFilter,!0)&&m(ue,e.replyType)&&y("boolean",e.includeMetaArray)&&y("boolean",e.includeReactions)&&y("boolean",e.includeParentMessageInfo)&&y("boolean",e.includeThreadInfo)&&y("boolean",e.showSubchannelMessagesOnly)},hn={replyType:ue.NONE,includeReactions:!1,includeThreadInfo:!1,includeMetaArray:!1,includeParentMessageInfo:!1},pn=function(e){return m(ue,e.replyType)&&y("boolean",e.includeReactions)&&y("boolean",e.includeMetaArray)&&y("boolean",e.includeParentMessageInfo)&&y("boolean",e.includeThreadInfo)};!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"}(un||(un={}));var fn,_n=function(e){return e.startsWith("EVENT_")||e===un.SYNC_MESSAGE_FILL||e===un.SYNC_MESSAGE_CHANGELOGS||e===un.SYNC_POLL_CHANGELOGS},gn=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}(L),yn=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}(L),mn=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}(L),vn=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}(L),En=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}(L),In=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}(L),Sn=function(e){function n(t){var n=t.channelType,r=t.channelUrl,i=t.messageId,s=t.includeMetaArray,o=t.includeReactions,a=t.includeThreadInfo,u=t.includeParentMessageInfo,c=e.call(this)||this;return c.method=d.GET,c.path="".concat(Ye(n),"/").concat(encodeURIComponent(r),"/messages/").concat(encodeURIComponent(i)),c.params={is_sdk:!0,with_sorted_meta_array:s,include_reactions:o,include_thread_info:a,include_parent_message_info:u,include_poll_details:!0},c}return t(n,e),n}(q),Tn=function(e){function r(t,r){var i=e.call(this,t,r)||this;return i.message=r?tn(t,n({},r)):null,i}return t(r,e),r}(x),bn=function(e){function n(t){var n=t.channelType,r=t.channelUrl,i=t.timestamp,s=void 0===i?null:i,o=t.token,a=void 0===o?null:o,u=t.prevResultSize,c=t.nextResultSize,l=t.isInclusive,h=t.reverse,p=t.messageTypeFilter,f=t.customTypesFilter,_=t.senderUserIdsFilter,g=t.replyType,y=t.includeMetaArray,m=t.includeReactions,v=t.parentMessageId,E=t.includeThreadInfo,I=t.includeParentMessageInfo,S=t.showSubchannelMessagesOnly,T=e.call(this)||this;return T.method=d.GET,T.path="".concat(Ye(n),"/").concat(encodeURIComponent(r),"/messages"),T.params=U({is_sdk:!0,prev_limit:u,next_limit:c,include:l,reverse:h,message_ts:s,message_id:a,message_type:null!=p?p:null,custom_types:f,sender_ids:_,include_reply_type:g,with_sorted_meta_array:y,include_reactions:m,parent_message_id:v,include_thread_info:E,include_parent_message_info:I,show_subchannel_message_only:S,include_poll_details:!0}),T}return t(n,e),n}(q),Nn=function(e){function n(t,n){var r=e.call(this,t,n)||this;return r.messages=n.messages.map((function(e){return tn(t,e)})),r}return t(n,e),n}(x),An=function(e){function n(t){var n=t.channelType,r=t.channelUrl,i=t.timestamp,s=t.token,o=t.replyType,a=t.includeMetaArray,u=t.includeReactions,c=t.includeThreadInfo,l=t.includeParentMessageInfo,h=e.call(this)||this;return h.method=d.GET,h.path="".concat(Ye(n),"/").concat(encodeURIComponent(r),"/messages/changelogs"),h.params={change_ts:i,token:s,with_sorted_meta_array:a,include_reactions:u,include_thread_info:c,include_reply_type:o,include_parent_message_info:l,include_poll_details:!0},h}return t(n,e),n}(q),Cn=function(e){function n(t,n){var r=e.call(this,t,n)||this;return r.updatedMessages=n.updated.map((function(e){return tn(t,e)})),r.deletedMessagesInfo=n.deleted.map((function(e){return{messageId:e.message_id,deletedAt:e.deleted_at}})),r.hasMore=n.has_more,r.nextToken=n.next,r}return t(n,e),n}(x),On=function(e){function n(t){var n=t.channelUrl,r=t.scheduledMessageId,i=e.call(this)||this;return i.method=d.GET,i.path="".concat(_e,"/").concat(encodeURIComponent(n),"/scheduled_messages/").concat(encodeURIComponent(r)),i.params={},i}return t(n,e),n}(q),wn=function(e){function r(t,r){var i=e.call(this,t,r)||this;return i.message=r?tn(t,n({},r)):null,i}return t(r,e),r}(x),Rn={},Dn=function(){function e(e,t){var n=t.sdkState,r=t.dispatcher,i=t.requestQueue,s=t.onlineDetector,o=t.cacheContext;this._iid=e,this._sdkState=n,this._requestQueue=i,this._dispatcher=r,this._onlineDetector=s,this._cacheContext=o,this.fileMessageQueue=new cn(e,{sdkState:n,dispatcher:r,requestQueue:i,onlineDetector:s,cacheContext:o}),Rn[e]=this}return e.of=function(e){return Rn[e]},e.prototype.buildMessageFromSerializedData=function(e){var t=at(e);switch(t.messageType){case ie.USER:return new $t(this._iid,$t.payloadify(t));case ie.FILE:return new nn(this._iid,nn.payloadify(t));case ie.ADMIN:return new Vt(this._iid,Vt.payloadify(t))}return null},e.prototype.buildUserMessageCreateParamsFromSerializedData=function(e,t){return U({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){return U({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.url,fileName:t.name,fileSize:t.size,mimeType:t.type,thumbnailSizes:t.thumbnails.map((function(e){return{maxWidth:e.width,maxHeight:e.height}})),fileType:e.fileType,requireAuth:t.requireAuth})},e.prototype.buildScheduledUserMessageCreateParamsFromSerializedData=function(e,t){return n(n({},this.buildUserMessageCreateParamsFromSerializedData(e,t)),{scheduledAt:e.scheduledAt})},e.prototype.buildScheduledFileMessageCreateParamsFromSerializedData=function(e,t){return n(n({},this.buildFileMessageCreateParamsFromSerializedData(e,t)),{scheduledAt:e.scheduledAt})},e.prototype.buildSenderFromSerializedData=function(e){var t=at(e);return new Ft(this._iid,Ft.payloadify(t))},e.prototype.getMessage=function(e){return r(this,void 0,void 0,(function(){var t,n;return i(this,(function(r){switch(r.label){case 0:return t=new Sn(e),[4,this._requestQueue.send(t)];case 1:return n=r.sent(),[2,n.as(Tn).message]}}))}))},e.prototype.getScheduledMessage=function(e){return r(this,void 0,void 0,(function(){var t,n;return i(this,(function(r){switch(r.label){case 0:return t=new On(e),[4,this._requestQueue.send(t)];case 1:return n=r.sent(),[2,n.as(wn).message]}}))}))},e.prototype.getMessagesByMessageId=function(e,t,s,o,a){return void 0===a&&(a=un.REQUEST_MESSAGE),r(this,void 0,void 0,(function(){var r,u,c;return i(this,(function(i){switch(i.label){case 0:return r=new bn(n(n({channelType:t,channelUrl:e,token:String(s)},ln),o)),[4,this._requestQueue.send(r)];case 1:return u=i.sent(),c=u.as(Nn).messages,this._dispatcher.dispatch(new gn({messages:c,source:a})),[2,c]}}))}))},e.prototype.getMessagesByTimestamp=function(e,t,s,o,a){return void 0===a&&(a=un.REQUEST_MESSAGE),r(this,void 0,void 0,(function(){var r,u,c;return i(this,(function(i){switch(i.label){case 0:return r=new bn(n(n({channelType:t,channelUrl:e,timestamp:s},ln),o)),[4,this._requestQueue.send(r)];case 1:return u=i.sent(),c=u.as(Nn).messages,this._dispatcher.dispatch(new gn({messages:c,source:a})),[2,c]}}))}))},e.prototype.getThreadedMessagesByTimestamp=function(e,t,s,o){return void 0===o&&(o=un.REQUEST_THREADED_MESSAGE),r(this,void 0,void 0,(function(){var r,a,u,c;return i(this,(function(i){switch(i.label){case 0:return r=new bn(n(n(n({channelUrl:e.channelUrl,channelType:e.channelType,timestamp:t},jt),s),{replyType:ue.ALL,parentMessageId:e.messageId,includeThreadInfo:!0})),[4,this._requestQueue.send(r)];case 1:return a=i.sent(),u=a.as(Nn).messages,(c=u.slice(1)).forEach((function(t){t.parentMessage=e})),this._dispatcher.dispatch(new gn({messages:c,source:o})),[2,{parentMessage:u[0],threadedMessages:c}]}}))}))},e.prototype.getMessageChangelogs=function(e,t,s,o,a){return void 0===a&&(a=un.REQUEST_MESSAGE_CHANGELOGS),r(this,void 0,void 0,(function(){var r,u,c,l,d,h,p,f;return i(this,(function(i){switch(i.label){case 0:return r=new An(U(n(n({channelType:t,channelUrl:e,timestamp:"number"==typeof s?s:null,token:"string"==typeof s?s:null},hn),o))),[4,this._requestQueue.send(r)];case 1:return u=i.sent(),c=u.as(Cn),l=c.updatedMessages,d=c.deletedMessagesInfo,h=c.hasMore,p=c.nextToken,f=d.map((function(e){return e.messageId})),l.length>0&&this._dispatcher.dispatch(new gn({messages:l,source:a})),f.length>0&&this._dispatcher.dispatch(new yn({messageIds:f,source:a})),[2,{updatedMessages:l,deletedMessageIds:f,hasMore:h,token:p}]}}))}))},e}(),Mn=function(){function e(){this._onPending=X,this._onFailed=X,this._onSucceeded=X}return e.prototype._trigger=function(e,t){switch(t.sendingStatus){case le.PENDING:this._onPending(t);break;case le.FAILED:case le.CANCELED:this._onFailed(e,t.scheduledInfo?null:t);break;case le.SCHEDULED:case le.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}(),kn=function(e){function n(t,n){var r=e.call(this,t)||this;r.threadInfo=null,r.targetMessageId=0,r.channelUrl=null,r.channelType=null;var i=n.thread_info,s=n.root_message_id,o=n.channel_url,a=n.channel_type;return i&&y("object",i)&&y("number",s)&&y("string",o)&&y("string",a)&&(r.threadInfo=new Ct(t,i),r.targetMessageId=s,r.channelUrl=o,r.channelType=a),r}return t(n,e),n}(He),Ln={channelUrl:null,channelType:null,messageId:0,includeReactions:!1,includeMetaArray:!1,includeParentMessageInfo:!1,includeThreadInfo:!1},Un=function(){function e(e,t){var n;this._iid=null,this.limit=20,this._isLoading=!1,this._hasNext=!0,this._token="",this._iid=e,this.limit=null!==(n=t.limit)&&void 0!==n?n:20}return Object.defineProperty(e.prototype,"hasNext",{get:function(){return this._hasNext},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"isLoading",{get:function(){return this._isLoading},enumerable:!1,configurable:!0}),e.prototype._validate=function(){return y("number",this.limit)&&this.limit>0},e}(),Pn=function(e){function n(t){var n=t.channelCustomType,r=t.keyword,i=t.limit,s=t.reverse,o=t.exactMatch,a=t.channelUrl,u=t.order,c=t.messageTimestampFrom,l=t.messageTimestampTo,h=t.advancedQuery,p=t.targetFields,f=t.nextToken,_=e.call(this)||this;return _.method=d.GET,_.path="".concat(ve,"/messages"),_.params={custom_type:n,query:r,limit:i,reverse:s,exact_match:o,channel_url:a,message_ts_from:c,message_ts_to:l,sort_field:u,advanced_query:h,target_fields:p,after:f},_}return t(n,e),n}(q),qn=function(e){function n(t,n){var r=e.call(this,t,n)||this;return r.messages=n.results.map((function(e){return tn(t,e)})),r.hasNext=n.has_next,r.nextToken=n.end_cursor,r.totalCount=n.total_count,r}return t(n,e),n}(x);!function(e){e.SCORE="score",e.TIMESTAMP="ts"}(fn||(fn={}));var xn=function(e){function s(t,n){var r,i,s,o,a,u,c,l,d,h=this;return(h=e.call(this,t,n)||this).keyword="",h.reverse=!1,h.exactMatch=!1,h.channelUrl="",h.channelCustomType="",h.messageTimestampFrom=null,h.messageTimestampTo=null,h.order=fn.SCORE,h.advancedQuery=!1,h.targetFields=null,h._nextToken="",h.totalCount=-1,h.keyword=n.keyword,h.reverse=null!==(r=n.reverse)&&void 0!==r&&r,h.exactMatch=null!==(i=n.exactMatch)&&void 0!==i&&i,h.channelUrl=null!==(s=n.channelUrl)&&void 0!==s?s:"",h.channelCustomType=null!==(o=n.channelCustomType)&&void 0!==o?o:"",h.messageTimestampFrom=null!==(a=n.messageTimestampFrom)&&void 0!==a?a:null,h.messageTimestampTo=null!==(u=n.messageTimestampTo)&&void 0!==u?u:null,h.order=null!==(c=n.order)&&void 0!==c?c:fn.SCORE,h.advancedQuery=null!==(l=n.advancedQuery)&&void 0!==l&&l,h.targetFields=null!==(d=n.targetFields)&&void 0!==d?d:null,h}return t(s,e),s.prototype._validate=function(){return e.prototype._validate.call(this)&&y("string",this.keyword)&&this.keyword.length>0&&y("boolean",this.reverse)&&y("boolean",this.exactMatch)&&y("string",this.channelUrl)&&y("string",this.channelCustomType)&&(y("number",this.messageTimestampFrom)||null===this.messageTimestampFrom)&&(y("number",this.messageTimestampTo)||null===this.messageTimestampTo)&&m(fn,this.order)&&y("boolean",this.advancedQuery)&&E("string",this.targetFields,!0)},s.prototype.next=function(){return r(this,void 0,void 0,(function(){var e,t,r,s,o,a,u,c;return i(this,(function(i){switch(i.label){case 0:return this._validate()?this._isLoading?[3,3]:this._hasNext?(this._isLoading=!0,e=Tt.of(this._iid).requestQueue,t=new Pn(n(n({},this),{nextToken:this._nextToken?this._nextToken:null})),[4,e.send(t)]):[3,2]:[3,5];case 1:return r=i.sent(),s=r.as(qn),o=s.messages,a=s.hasNext,u=s.nextToken,c=s.totalCount,this._nextToken=u,this._hasNext=a,this._isLoading=!1,this.totalCount=c,[2,o];case 2:return[2,[]];case 3:throw p.queryInProgress;case 4:return[3,6];case 5:throw p.invalidParameters;case 6:return[2]}}))}))},s}(Un),Fn=function(e){function n(t,n,r,i){var s=e.call(this,t,i)||this;return s.channelUrl=n,s.channelType=r,s}return t(n,e),n.prototype._validate=function(){return e.prototype._validate.call(this)&&y("string",this.channelUrl)&&m(ne,this.channelType)},n}(Un),Gn=function(e){function n(t,n,r,i){var s,o,a,u,c,l,d,h,p,f,_=this;return(_=e.call(this,t,n,r,i)||this).reverse=!1,_.messageTypeFilter=se.ALL,_.customTypesFilter=null,_.senderUserIdsFilter=null,_.replyType=ue.NONE,_.includeMetaArray=!1,_.includeReactions=!1,_.includeParentMessageInfo=!1,_.includeThreadInfo=!1,_.showSubchannelMessagesOnly=!1,_._edge=Number.MAX_SAFE_INTEGER,_.reverse=null!==(s=i.reverse)&&void 0!==s&&s,_.messageTypeFilter=null!==(o=i.messageTypeFilter)&&void 0!==o?o:se.ALL,_.customTypesFilter=null!==(a=i.customTypesFilter)&&void 0!==a?a:null,_.senderUserIdsFilter=null!==(u=i.senderUserIdsFilter)&&void 0!==u?u:null,_.replyType=null!==(c=i.replyType)&&void 0!==c?c:ue.NONE,_.includeMetaArray=null!==(l=i.includeMetaArray)&&void 0!==l&&l,_.includeReactions=null!==(d=i.includeReactions)&&void 0!==d&&d,_.includeParentMessageInfo=null!==(h=i.includeParentMessageInfo)&&void 0!==h&&h,_.includeThreadInfo=null!==(p=i.includeThreadInfo)&&void 0!==p&&p,_.showSubchannelMessagesOnly=null!==(f=i.showSubchannelMessagesOnly)&&void 0!==f&&f,_}return t(n,e),n.prototype._validate=function(){return e.prototype._validate.call(this)&&y("boolean",this.reverse)&&m(se,this.messageTypeFilter)&&m(ue,this.replyType)&&E("string",this.customTypesFilter,!0)&&E("string",this.senderUserIdsFilter,!0)&&y("boolean",this.includeMetaArray)&&y("boolean",this.includeReactions)&&y("boolean",this.includeParentMessageInfo)&&y("boolean",this.includeThreadInfo)&&y("boolean",this.showSubchannelMessagesOnly)},n.prototype.load=function(){return r(this,void 0,void 0,(function(){var e;return i(this,(function(t){switch(t.label){case 0:return this._validate()?this._isLoading?[3,3]:this._hasNext?(this._isLoading=!0,[4,Dn.of(this._iid).getMessagesByTimestamp(this.channelUrl,this.channelType,this._edge,{prevResultSize:this.limit,nextResultSize:0,isInclusive:!1,reverse:this.reverse,messageTypeFilter:this.messageTypeFilter,customTypesFilter:this.customTypesFilter,replyType:this.replyType,senderUserIdsFilter:this.senderUserIdsFilter,includeReactions:this.includeReactions,includeMetaArray:this.includeMetaArray,includeParentMessageInfo:this.includeParentMessageInfo,includeThreadInfo:this.includeThreadInfo,showSubchannelMessagesOnly:this.showSubchannelMessagesOnly})]):[3,2]:[3,5];case 1:return e=t.sent(),this._edge=Math.min.apply(Math,a([Number.MAX_SAFE_INTEGER],o(e.map((function(e){return e.createdAt}))),!1)),this._hasNext=e.length>=this.limit,this._isLoading=!1,[2,e];case 2:return[2,[]];case 3:throw p.queryInProgress;case 4:return[3,6];case 5:throw p.invalidParameters;case 6:return[2]}}))}))},n}(Fn),Qn={channelUrl:null,scheduledMessageId:0},jn=function(e){function s(){var t=null!==e&&e.apply(this,arguments)||this;return t.name="message",t}return t(s,e),s.prototype.init=function(t,n){var r=n.sdkState,i=n.dispatcher,s=n.sessionManager,o=n.requestQueue,a=n.logger,u=n.onlineDetector,c=n.cacheContext;e.prototype.init.call(this,t,{sdkState:r,dispatcher:i,sessionManager:s,requestQueue:o,logger:a,onlineDetector:u,cacheContext:c}),this._manager=new Dn(t,{sdkState:r,dispatcher:i,requestQueue:o,onlineDetector:u,cacheContext:c})},s.prototype.buildMessageFromSerializedData=function(e){return this._manager.buildMessageFromSerializedData(e)},s.prototype.buildSenderFromSerializedData=function(e){return this._manager.buildSenderFromSerializedData(e)},s.prototype.getMessage=function(e){return r(this,void 0,void 0,(function(){var t;return i(this,(function(r){return t=n(n({},Ln),e),ut(function(e){return y("string",e.channelUrl)&&y("string",e.channelType)&&m(ne,e.channelType)&&y("number",e.messageId)&&y("boolean",e.includeMetaArray)&&y("boolean",e.includeParentMessageInfo)&&y("boolean",e.includeThreadInfo)}(t)).throw(p.invalidParameters),[2,this._manager.getMessage(t)]}))}))},s.prototype.getScheduledMessage=function(e){return r(this,void 0,void 0,(function(){var t;return i(this,(function(r){return t=n(n({},Qn),e),ut(function(e){return y("string",e.channelUrl)&&y("number",e.scheduledMessageId)}(t)).throw(p.invalidParameters),[2,this._manager.getScheduledMessage(t)]}))}))},s}(bt);export{A as $,d as A,L as B,ne as C,le as D,M as E,nn as F,I as G,de as H,He as I,J,u as K,gn as L,un as M,pe as N,Se as O,Zt as P,Ie as Q,ue as R,p as S,E as T,lt as U,Tt as V,B as W,Un as X,o as Y,a as Z,t as _,Te as a,At as a$,N as a0,b as a1,R as a2,jn as a3,c as a4,ze as a5,j as a6,xn as a7,at as a8,Le as a9,$e as aA,ln as aB,dn as aC,hn as aD,pn as aE,ee as aF,xt as aG,T as aH,Ot as aI,Ue as aJ,In as aK,En as aL,mn as aM,yn as aN,ge as aO,_e as aP,be as aQ,wt as aR,Wt as aS,ot as aT,on as aU,Ht as aV,V as aW,tn as aX,_n as aY,ke as aZ,en as a_,$ as aa,dt as ab,ht as ac,mt as ad,zt as ae,re as af,st as ag,ae as ah,Mt as ai,ce as aj,Ut as ak,Xe as al,Ee as am,H as an,Je as ao,Ze as ap,Rt as aq,oe as ar,Qt as as,g as at,Gn as au,Ft as av,De as aw,h as ax,Mn as ay,et as az,q as b,Nt as b0,Vt as b1,kn as b2,me as b3,ye as b4,fn as b5,kt as b6,Lt as b7,Dt as b8,Et as b9,Ct as ba,x as c,Jt as d,U as e,Yt as f,Ye as g,m as h,y as i,r as j,i as k,n as l,vn as m,Fn as n,bt as o,Pt as p,S as q,X as r,se as s,ie as t,ut as u,Xt as v,Gt as w,$t as x,Dn as y,s as z}; diff --git a/__bundle-c7363281.js b/__bundle-329965e1.js similarity index 99% rename from __bundle-c7363281.js rename to __bundle-329965e1.js index 4510fe7..046a931 100644 --- a/__bundle-c7363281.js +++ b/__bundle-329965e1.js @@ -1 +1 @@ -import{ah as e,i as t,h as n,T as r,U as i,ai as a,aj as s,ak as o,l as u,e as c,q as l,_ as d,A as h,g as p,b as f,c as m,j as v,n as y,k as g,S as _,V as T,W as U,al as I,am as w,C as M,an as E,x as S,ao as b,ap as C,F as P,aq as A,ar as D,as as q,a2 as R,at as k,au as N,av as O,D as F,z as L,t as Q,K as z,u as x,aw as G,L as B,M as j,a9 as V,ax as W,G as K,y as Y,I as H,ay as J,az as Z,aA as X,Z as $,Y as ee,aB as te,aC as ne,aD as re,aE as ie,aF as ae,w as se,aG as oe}from"./__bundle-0a632c33.js";var ue,ce={data:null,customType:null,mentionType:e.USERS,mentionedUserIds:null,mentionedUsers:null,mentionedMessageTemplate:null,metaArrays:null,parentMessageId:null,isReplyToChannel:!1,pushNotificationDeliveryOption:null,appleCriticalAlertOptions:null},le=function(u){return t("string",u.data,!0)&&t("string",u.customType,!0)&&n(e,u.mentionType)&&r("string",u.mentionedUserIds,!0)&&r(i,u.mentionedUsers,!0)&&t("string",u.mentionedMessageTemplate,!0)&&r(a,u.metaArrays,!0)&&t("number",u.parentMessageId,!0)&&t("boolean",u.isReplyToChannel)&&n(s,u.pushNotificationDeliveryOption,!0)&&t(o,u.appleCriticalAlertOptions,!0)},de=function(e){return e?{isReplyToChannel:e.isReplyToChannel,pushNotificationDeliveryOption:e.pushNotificationDeliveryOption,pollId:e.pollId}:null},he=u(u({},ce),{message:null,translationTargetLanguages:null,pollId:null}),pe=function(e){return le(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"}(ue||(ue={}));var fe,me=function(e){return"undefined"!=typeof window&&"Blob"in window&&"undefined"!=typeof Blob&&e instanceof Blob},ve=function(e){return e===ue.BLOB||e===ue.FILE},ye=function(e){return e?{file:e.file,fileKey:e.fileKey,fileType:e.fileType,isReplyToChannel:e.isReplyToChannel,pushNotificationDeliveryOption:e.pushNotificationDeliveryOption}:null},ge=u(u({},ce),{file:null,fileKey:null,fileUrl:null,fileName:null,fileType:null,fileSize:null,mimeType:null,thumbnailSizes:null,requireAuth:!1}),_e=function(e){return le(e)&&(l(e.file)||t("string",e.fileUrl))&&t("string",e.fileName,!0)&&t("string",e.mimeType,!0)&&t("number",e.fileSize,!0)&&(null===e.thumbnailSizes||Array.isArray(e.thumbnailSizes)&&e.thumbnailSizes.every((function(e){return t("object",e)&&e.maxWidth>0&&e.maxHeight>0})))};!function(e){e.MUTED="muted",e.BANNED="banned"}(fe||(fe={}));var Te,Ue=function(){function e(e){var t,r,i;this.restrictionType=null,this.description=null,this.endAt=-1,n(fe,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}return e.payloadify=function(e){return e?c({restriction_type:e.restrictionType,description:e.description,end_at:e.endAt}):null},e}(),Ie=function(e){function t(t,n){var r=e.call(this,t,n)||this;return r.restrictionInfo=null,r.restrictionInfo=new Ue(n),r}return d(t,e),t.payloadify=function(t){return t?c(u(u({},e.payloadify.call(this,t)),Ue.payloadify(t.restrictionInfo))):null},t}(i),we={data:null,customType:null,mentionType:e.USERS,mentionedUserIds:null,mentionedUsers:null,mentionedMessageTemplate:null,metaArrays:null,pushNotificationDeliveryOption:null,appleCriticalAlertOptions:null},Me=function(u){return t("string",u.data,!0)&&t("string",u.customType,!0)&&n(e,u.mentionType)&&r("string",u.mentionedUserIds,!0)&&r(i,u.mentionedUsers,!0)&&t("string",u.mentionedMessageTemplate,!0)&&r(a,u.metaArrays,!0)&&n(s,u.pushNotificationDeliveryOption,!0)&&t(o,u.appleCriticalAlertOptions,!0)},Ee=u(u({},we),{message:null,translationTargetLanguages:null,pollId:null}),Se=function(e){return Me(e)&&t("string",e.message,!0)&&r("string",e.translationTargetLanguages,!0)&&t("number",e.pollId,!0)},be=u({},we),Ce=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),Pe=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),Ae=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,s;return g(this,(function(o){switch(o.label){case 0:return this._validate()?this._isLoading?[3,3]:(e=[],this._hasNext?(this._isLoading=!0,t=T.of(this._iid).requestQueue,n=new Ce(u(u({},this),{channelUrl:this.channelUrl,token:this._token})),[4,t.send(n)]):[3,2]):[3,5];case 1:return r=o.sent(),i=r.as(Pe),a=i.operators,s=i.token,this._token=s,this._hasNext=!!s,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),De=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),qe=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 Ie(t,e)}))),r}return d(t,e),t}(m),Re=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(s){switch(s.label){case 0:return this._validate()?this._isLoading?[3,3]:this._hasNext?(this._isLoading=!0,e=T.of(this._iid).requestQueue,t=new De(u(u({},this),{token:this._token})),[4,e.send(t)]):[3,2]:[3,5];case 1:return n=s.sent(),r=n.as(qe),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),ke=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=c({limit:a,token:s}),n}return d(t,e),t}(f),Ne=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 Ie(t,e.user)}))),r}return d(t,e),t}(m),Oe=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(s){switch(s.label){case 0:return this._validate()?this._isLoading?[3,3]:this._hasNext?(this._isLoading=!0,e=T.of(this._iid).requestQueue,t=new ke(u(u({},this),{token:this._token})),[4,e.send(t)]):[3,2]:[3,5];case 1:return n=s.sent(),r=n.as(Ne),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"}(Te||(Te={}));var Fe=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 Le=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 Qe=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),ze=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 d(t,e),t}(m),xe=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),Ge=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 d(t,e),t}(m),Be=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),je=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 d(t,e),t}(m),Ve=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 d(t,e),t}(U),We=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),Ke=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 d(t,e),t}(m),Ye=function(e){function t(t){var n=this,r=t.channelUrl,i=t.channelType;return(n=e.call(this)||this).method=h.PUT,n.path="".concat(p(i),"/").concat(encodeURIComponent(r),"/metadata"),n.params={include_ts:!0},n}return d(t,e),t}(f),He=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 d(t,e),t}(m),Je=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),Ze=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),Xe=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),$e=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){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),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),nt=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 d(t,e),t}(U),rt=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=null,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 it=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=null,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.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 st=function(e){function t(t,n,r){var i=e.call(this,t,"SYEV",r)||this;return i.user=new Ie(t,r.data),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),"/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 ut=function(e){function t(t,n,r){var i=e.call(this,t,"SYEV",r)||this;return i.user=new Ie(t,r.data),i}return d(t,e),t}(U),ct=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),"/ban"),n.params=c({user_id:a,seconds:s,description:o}),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.memberCount=null,i.joinedMemberCount=null,i.user=new Ie(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),dt=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 ht=function(e){function t(t,n,r){var i=e.call(this,t,"SYEV",r)||this;return i.user=new Ie(t,r.data),i}return d(t,e),t}(U),pt=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),mt=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),vt=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),yt=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),gt=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:c({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!==s.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})})||this}return d(n,t),n}(E),_t=function(e){function t(t,n,r){var i,a,s,o=this;(o=e.call(this,t,"MESG",r)||this).message=new S(t,r);var u=T.of(t).sdkState;return o.isMentioned=b(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 d(t,e),t}(U),Tt=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:"MEDI",ackRequired:!0,payload:c({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,poll_id:n.pollId})})||this}return d(n,t),n}(E),Ut=function(e){function t(t,n,r){var i,a,s,o,u,c,l=this;(l=e.call(this,t,"MEDI",r)||this).message=new S(t,r);var d=T.of(t).sdkState;return l.mentionCountChange=C({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:l.message.mentionType,mentionedUserIds:null!==(u=l.message.mentionedUserIds)&&void 0!==u?u:null===(c=l.message.mentionedUsers)||void 0===c?void 0:c.map((function(e){return e.userId}))},d.userId),l}return d(t,e),t}(U),It=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:"FEDI",ackRequired:!0,payload:c({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,u,c,l=this;(l=e.call(this,t,"FEDI",r)||this).message=new P(t,r);var d=T.of(t).sdkState;return l.mentionCountChange=C({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:l.message.mentionType,mentionedUserIds:null!==(u=l.message.mentionedUserIds)&&void 0!==u?u:null===(c=l.message.mentionedUsers)||void 0===c?void 0:c.map((function(e){return e.userId}))},d.userId),l}return d(t,e),t}(U),Mt=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 Et=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),St=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),bt=function(e){function t(t,n){var r=e.call(this,t,n)||this;return r.reactionEvent=new A(n),r}return d(t,e),t}(m),Ct=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),Pt=function(e){function t(t,n){var r=e.call(this,t,n)||this;return r.reactionEvent=new A(u({},n)),r}return d(t,e),t}(m),At=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),Dt=function(e){function t(t,n){var r=e.call(this,t,n)||this;return r.message=new S(t,n),r}return d(t,e),t}(m),qt=function(t){function n(n){var r,i=this;i=t.call(this)||this;var s=[];n.mentionType===e.USERS&&(n.mentionedUserIds?s=n.mentionedUserIds:n.mentionedUsers&&(s=n.mentionedUsers.map((function(e){return e.userId}))));var u=n.channelType,c=n.channelUrl;return i.method=h.POST,i.path="".concat(p(u),"/").concat(encodeURIComponent(c),"/scheduled_messages"),i.params={req_id:n.reqId,scheduled_at:n.scheduledAt,message_type:D.USER,message:n.message,custom_type:n.customType,data:n.data,mention_type:n.mentionType,mentioned_user_ids:s,sorted_metaarray:null===(r=n.metaArrays)||void 0===r?void 0:r.map((function(e){return a.payloadify(e)})),apple_critical_alert_options:o.payloadify(n.appleCriticalAlertOptions),target_langs:n.translationTargetLanguages,push_option:n.pushNotificationDeliveryOption},i}return d(n,t),n}(f),Rt=function(e){function t(t,n){var r=e.call(this,t,n)||this;return r.message=new S(t,n),r}return d(t,e),t}(m),kt=function(t){function n(n){var r,i=this;i=t.call(this)||this;var s=[];n.mentionType===e.USERS&&(n.mentionedUserIds?s=n.mentionedUserIds:n.mentionedUsers&&(s=n.mentionedUsers.map((function(e){return e.userId}))));var u=n.channelType,c=n.channelUrl;return i.method=h.POST,i.path="".concat(p(u),"/").concat(encodeURIComponent(c),"/scheduled_messages"),i.params={req_id:n.reqId,scheduled_at:n.scheduledAt,message_type:D.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 q.payloadify(e)})):[],custom_type:n.customType,data:n.data,require_auth:n.requireAuth,mention_type:n.mentionType,mentioned_user_ids:s,sorted_metaarray:null===(r=n.metaArrays)||void 0===r?void 0:r.map((function(e){return a.payloadify(e)})),apple_critical_alert_options:o.payloadify(n.appleCriticalAlertOptions),push_option:n.pushNotificationDeliveryOption},i}return d(n,t),n}(f),Nt=function(e){function t(t,n){var r=e.call(this,t,n)||this;return r.message=new P(t,n),r}return d(t,e),t}(m),Ot=2,Ft=function(e){function h(n,r){var a,s,o,u,c=this;return(c=e.call(this,n)||this).url="",c.channelType=M.BASE,c.name="",c.coverUrl="",c.customType="",c.data="",c.isFrozen=!1,c.isEphemeral=!1,c.creator=null,c.createdAt=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,c._cachedMetaData=new Map,r.metadata&&r.ts&&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 c(u(u({},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}))},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.forEach((function(t,n){t.isRemoved||(e[n]=t.value)})),e},enumerable:!1,configurable:!0}),h.prototype._upsertCachedMetaData=function(e,t){var n=this;Object.keys(e).forEach((function(r){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;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 At({channelType:this.channelType,channelUrl:this.url,messageId:e.messageId,translationTargetLanguages:t}),[4,n.send(i)];case 1:return a=s.sent(),[2,a.as(Dt).message]}}))}))},h.prototype._createScheduledUserMessage=function(e,t){var n=this,r=T.of(this._iid).requestQueue,i=Date.now(),a=this._generateRequestId();G(2).then((function(){var r=n._createPendingScheduledUserMessage(e,a,i);V((function(){return v(n,void 0,void 0,(function(){return g(this,(function(e){return[2,t._trigger(null,r)]}))}))}))}));var s=new qt(u({reqId:a,channelType:this.channelType,channelUrl:this.url},e));r.send(s).then((function(e){var r=e.as(Rt).message;V((function(){return v(n,void 0,void 0,(function(){return g(this,(function(e){return[2,t._trigger(null,r)]}))}))}))})).catch((function(r){if(W(r))throw r;G(2).then((function(){var s=n._createPendingScheduledUserMessage(e,a,i);n._markMessageAsFailed(s,r),V((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=u(u({},ge),e);return x(_e(t)).throw(_.invalidParameters),this._sendFileMessage(t)},h.prototype._sendFileMessage=function(e,t){var n=this;void 0===t&&(t=null);var r=T.of(this._iid).dispatcher,i=Y.of(this._iid).fileMessageQueue,a=t,s=Date.now(),o=new J;return a||(a=this._generateRequestId(),G(2).then((function(){var t=n._createPendingFileMessage(e,a,s);r.dispatch(new B({messages:[t],source:j.EVENT_MESSAGE_SENT_PENDING})),V((function(){return v(n,void 0,void 0,(function(){return g(this,(function(e){return[2,o._trigger(null,t)]}))}))}))}))),i.request(this,a,e).then((function(e){r.dispatch(new B({messages:[e],source:j.EVENT_MESSAGE_SENT_SUCCESS})),V((function(){return v(n,void 0,void 0,(function(){return g(this,(function(t){return[2,o._trigger(null,e)]}))}))}))})).catch((function(t){if(W(t))throw t;G(2).then((function(){var i=n._createPendingFileMessage(e,a,s),u=T.of(n._iid).cacheContext.localCacheEnabled&&K(t.code);n._markMessageAsFailed(i,t,u),r.dispatch(new B({messages:[i],source:i.sendingStatus===F.PENDING?j.REQUEST_RESEND_MESSAGE:j.EVENT_MESSAGE_SENT_FAILED})),V((function(){return v(n,void 0,void 0,(function(){return g(this,(function(e){return[2,o._trigger(t,i)]}))}))}))}))})),o},h.prototype._autoResendFileMessage=function(e){x(e instanceof P).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._createScheduledFileMessage=function(e,t,n,r){var i=this,a=T.of(this._iid).requestQueue,s=new kt(u(u({reqId:n,channelType:this.channelType,channelUrl:this.url},e),{fileUrl:e.fileUrl,requireAuth:e.requireAuth}));a.send(s).then((function(e){var n=e.as(Nt).message;V((function(){return v(i,void 0,void 0,(function(){return g(this,(function(e){return[2,t._trigger(null,n)]}))}))}))})).catch((function(a){if(W(a))throw a;G(2).then((function(){var s=i._createPendingScheduledFileMessage(e,n,r);i._markMessageAsFailed(s,a),V((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;x(e.every((function(e){return _e(u(u({},ge),e))}))).throw(_.invalidParameters);var r=new J;try{for(var i=L(e),a=i.next();!a.done;a=i.next()){var s=a.value;this.sendFileMessage(s).onPending((function(e){return r._trigger(null,e)})).onFailed((function(e,t){return r._trigger(e,t)})).onSucceeded((function(e){return r._trigger(null,e)}))}}catch(e){t={error:e}}finally{try{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)||l(t)||l(null===(n=e.messageParams)||void 0===n?void 0:n.file),x(e instanceof P&&r&&!e.scheduledInfo).throw(_.invalidParameters),i=new ae,a=function(e,t){var n;return void 0===t&&(t=null),e.messageParams?(!e.url&&l(t)&&(e.messageParams.file=t),e.messageParams):c({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:e.thumbnails.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,s;return g(this,(function(o){switch(o.label){case 0:return r=u(u({},be),n),x(t("number",e)&&function(e){return Me(e)}(r)).throw(_.invalidParameters),i=T.of(this._iid).requestQueue,a=new It(u({channelType:this.channelType,channelUrl:this.url,messageId:e},r)),[4,i.send(a)];case 1:return s=o.sent(),[2,s.as(wt).message]}}))}))},h.prototype.cancelUploadingFileMessage=function(e){return v(this,void 0,void 0,(function(){return g(this,(function(n){return x(t("string",e)).throw(_.invalidParameters),Y.of(this._iid).fileMessageQueue.cancel(this,e),[2,!0]}))}))},h.prototype.copyFileMessage=function(e,t){var n,r;return v(this,void 0,void 0,(function(){var i,a;return g(this,(function(o){return x(e instanceof h&&t instanceof P&&t.sendingStatus===F.SUCCEEDED&&e.url===t.channelUrl&&!t.scheduledInfo).throw(_.invalidParameters),i=new ae,a=u(u({},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:s.DEFAULT,parentMessageId:null,isReplyToChannel:!1,thumbnailSizes:t.thumbnails.map((function(e){return{maxWidth:e.width,maxHeight:e.height}})),requireAuth:t.requireAuth}),e._sendFileMessage(a).onSucceeded((function(e){return i.resolve(e)})).onFailed((function(e){return i.reject(e)})),[2,i.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 x(e instanceof se).throw(_.invalidParameters),e.messageId>0?(t=T.of(this._iid).requestQueue,n=new Mt({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 x(e instanceof oe&&e.messageId>0&&t("string",n)).throw(_.invalidParameters),r=T.of(this._iid).requestQueue,i=new St({channelType:this.channelType,channelUrl:this.url,messageId:e.messageId,reactionKey:n}),[4,r.send(i)];case 1:return a=s.sent(),[2,a.as(bt).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 x(e instanceof oe&&e.messageId>0&&t("string",n)).throw(_.invalidParameters),r=T.of(this._iid).requestQueue,i=new Ct({channelType:this.channelType,channelUrl:this.url,messageId:e.messageId,reactionKey:n}),[4,r.send(i)];case 1:return a=s.sent(),[2,a.as(Pt).reactionEvent]}}))}))},h.prototype._updateMessageMetaArray=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 Tt({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(Ut).message,a.dispatch(new B({messages:[c],source:j.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 x(e instanceof se&&e.messageId>0&&r("string",t)).throw(_.invalidParameters),n=t.map((function(e){return new a({key:e})})),[2,this._updateMessageMetaArray(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 x(e instanceof se&&e.messageId>0&&r("string",t)).throw(_.invalidParameters),n=t.map((function(e){return new a({key:e})})),[2,this._updateMessageMetaArray(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 x(e instanceof se&&e.messageId>0&&t.every((function(e){return e instanceof a}))).throw(_.invalidParameters),[2,this._updateMessageMetaArray(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 x(e instanceof se&&e.messageId>0&&t.every((function(e){return e instanceof a}))).throw(_.invalidParameters),[2,this._updateMessageMetaArray(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 x(n(Te,e)&&t("string",r)).throw(_.invalidParameters),i=T.of(this._iid),a=i.sdkState,s=i.requestQueue,o=new mt({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 x(e instanceof i&&n(Te,r)&&t("string",a)).throw(_.invalidParameters),s=T.of(this._iid),o=s.sdkState,u=s.requestQueue,c=new vt({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 x(e instanceof se&&n(Te,r)&&t("string",i)).throw(_.invalidParameters),a=T.of(this._iid),s=a.sdkState,o=a.requestQueue,u=new yt({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}(H);export{ce as B,Rt as C,Et as D,ue as F,Re as M,Ae as O,Ot as P,Te as R,he as U,ye as a,le as b,me as c,Oe as d,Ft as e,Ie as f,Ue as g,fe as h,ve as i,nt as j,Ve as k,ft as l,ht as m,lt as n,st as o,ut as p,Ut as q,wt as r,de as s,_t as t,we as u,pe as v,Me as w,Ee as x,Se as y}; +import{ah as e,i as t,h as n,T as r,U as i,ai as a,aj as s,ak as o,l as u,e as c,q as l,_ as d,A as h,g as p,b as f,c as m,j as v,n as y,k as g,S as _,V as T,W as U,al as I,am as w,C as M,an as E,x as S,ao as b,ap as C,F as P,aq as A,ar as D,as as q,a2 as R,at as k,au as N,av as O,D as F,z as L,t as Q,K as z,u as x,aw as G,L as B,M as j,a9 as V,ax as W,G as K,y as Y,I as H,ay as J,az as Z,aA as X,Z as $,Y as ee,aB as te,aC as ne,aD as re,aE as ie,aF as ae,w as se,aG as oe}from"./__bundle-1abffbb6.js";var ue,ce={data:null,customType:null,mentionType:e.USERS,mentionedUserIds:null,mentionedUsers:null,mentionedMessageTemplate:null,metaArrays:null,parentMessageId:null,isReplyToChannel:!1,pushNotificationDeliveryOption:null,appleCriticalAlertOptions:null},le=function(u){return t("string",u.data,!0)&&t("string",u.customType,!0)&&n(e,u.mentionType)&&r("string",u.mentionedUserIds,!0)&&r(i,u.mentionedUsers,!0)&&t("string",u.mentionedMessageTemplate,!0)&&r(a,u.metaArrays,!0)&&t("number",u.parentMessageId,!0)&&t("boolean",u.isReplyToChannel)&&n(s,u.pushNotificationDeliveryOption,!0)&&t(o,u.appleCriticalAlertOptions,!0)},de=function(e){return e?{isReplyToChannel:e.isReplyToChannel,pushNotificationDeliveryOption:e.pushNotificationDeliveryOption,pollId:e.pollId}:null},he=u(u({},ce),{message:null,translationTargetLanguages:null,pollId:null}),pe=function(e){return le(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"}(ue||(ue={}));var fe,me=function(e){return"undefined"!=typeof window&&"Blob"in window&&"undefined"!=typeof Blob&&e instanceof Blob},ve=function(e){return e===ue.BLOB||e===ue.FILE},ye=function(e){return e?{file:e.file,fileKey:e.fileKey,fileType:e.fileType,isReplyToChannel:e.isReplyToChannel,pushNotificationDeliveryOption:e.pushNotificationDeliveryOption}:null},ge=u(u({},ce),{file:null,fileKey:null,fileUrl:null,fileName:null,fileType:null,fileSize:null,mimeType:null,thumbnailSizes:null,requireAuth:!1}),_e=function(e){return le(e)&&(l(e.file)||t("string",e.fileUrl))&&t("string",e.fileName,!0)&&t("string",e.mimeType,!0)&&t("number",e.fileSize,!0)&&(null===e.thumbnailSizes||Array.isArray(e.thumbnailSizes)&&e.thumbnailSizes.every((function(e){return t("object",e)&&e.maxWidth>0&&e.maxHeight>0})))};!function(e){e.MUTED="muted",e.BANNED="banned"}(fe||(fe={}));var Te,Ue=function(){function e(e){var t,r,i;this.restrictionType=null,this.description=null,this.endAt=-1,n(fe,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}return e.payloadify=function(e){return e?c({restriction_type:e.restrictionType,description:e.description,end_at:e.endAt}):null},e}(),Ie=function(e){function t(t,n){var r=e.call(this,t,n)||this;return r.restrictionInfo=null,r.restrictionInfo=new Ue(n),r}return d(t,e),t.payloadify=function(t){return t?c(u(u({},e.payloadify.call(this,t)),Ue.payloadify(t.restrictionInfo))):null},t}(i),we={data:null,customType:null,mentionType:e.USERS,mentionedUserIds:null,mentionedUsers:null,mentionedMessageTemplate:null,metaArrays:null,pushNotificationDeliveryOption:null,appleCriticalAlertOptions:null},Me=function(u){return t("string",u.data,!0)&&t("string",u.customType,!0)&&n(e,u.mentionType)&&r("string",u.mentionedUserIds,!0)&&r(i,u.mentionedUsers,!0)&&t("string",u.mentionedMessageTemplate,!0)&&r(a,u.metaArrays,!0)&&n(s,u.pushNotificationDeliveryOption,!0)&&t(o,u.appleCriticalAlertOptions,!0)},Ee=u(u({},we),{message:null,translationTargetLanguages:null,pollId:null}),Se=function(e){return Me(e)&&t("string",e.message,!0)&&r("string",e.translationTargetLanguages,!0)&&t("number",e.pollId,!0)},be=u({},we),Ce=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),Pe=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),Ae=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,s;return g(this,(function(o){switch(o.label){case 0:return this._validate()?this._isLoading?[3,3]:(e=[],this._hasNext?(this._isLoading=!0,t=T.of(this._iid).requestQueue,n=new Ce(u(u({},this),{channelUrl:this.channelUrl,token:this._token})),[4,t.send(n)]):[3,2]):[3,5];case 1:return r=o.sent(),i=r.as(Pe),a=i.operators,s=i.token,this._token=s,this._hasNext=!!s,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),De=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),qe=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 Ie(t,e)}))),r}return d(t,e),t}(m),Re=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(s){switch(s.label){case 0:return this._validate()?this._isLoading?[3,3]:this._hasNext?(this._isLoading=!0,e=T.of(this._iid).requestQueue,t=new De(u(u({},this),{token:this._token})),[4,e.send(t)]):[3,2]:[3,5];case 1:return n=s.sent(),r=n.as(qe),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),ke=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=c({limit:a,token:s}),n}return d(t,e),t}(f),Ne=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 Ie(t,e.user)}))),r}return d(t,e),t}(m),Oe=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(s){switch(s.label){case 0:return this._validate()?this._isLoading?[3,3]:this._hasNext?(this._isLoading=!0,e=T.of(this._iid).requestQueue,t=new ke(u(u({},this),{token:this._token})),[4,e.send(t)]):[3,2]:[3,5];case 1:return n=s.sent(),r=n.as(Ne),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"}(Te||(Te={}));var Fe=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 Le=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 Qe=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),ze=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 d(t,e),t}(m),xe=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),Ge=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 d(t,e),t}(m),Be=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),je=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 d(t,e),t}(m),Ve=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 d(t,e),t}(U),We=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),Ke=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 d(t,e),t}(m),Ye=function(e){function t(t){var n=this,r=t.channelUrl,i=t.channelType;return(n=e.call(this)||this).method=h.PUT,n.path="".concat(p(i),"/").concat(encodeURIComponent(r),"/metadata"),n.params={include_ts:!0},n}return d(t,e),t}(f),He=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 d(t,e),t}(m),Je=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),Ze=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),Xe=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),$e=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){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),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),nt=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 d(t,e),t}(U),rt=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=null,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 it=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=null,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.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 st=function(e){function t(t,n,r){var i=e.call(this,t,"SYEV",r)||this;return i.user=new Ie(t,r.data),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),"/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 ut=function(e){function t(t,n,r){var i=e.call(this,t,"SYEV",r)||this;return i.user=new Ie(t,r.data),i}return d(t,e),t}(U),ct=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),"/ban"),n.params=c({user_id:a,seconds:s,description:o}),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.memberCount=null,i.joinedMemberCount=null,i.user=new Ie(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),dt=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 ht=function(e){function t(t,n,r){var i=e.call(this,t,"SYEV",r)||this;return i.user=new Ie(t,r.data),i}return d(t,e),t}(U),pt=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),mt=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),vt=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),yt=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),gt=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:c({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!==s.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})})||this}return d(n,t),n}(E),_t=function(e){function t(t,n,r){var i,a,s,o=this;(o=e.call(this,t,"MESG",r)||this).message=new S(t,r);var u=T.of(t).sdkState;return o.isMentioned=b(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 d(t,e),t}(U),Tt=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:"MEDI",ackRequired:!0,payload:c({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,poll_id:n.pollId})})||this}return d(n,t),n}(E),Ut=function(e){function t(t,n,r){var i,a,s,o,u,c,l=this;(l=e.call(this,t,"MEDI",r)||this).message=new S(t,r);var d=T.of(t).sdkState;return l.mentionCountChange=C({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:l.message.mentionType,mentionedUserIds:null!==(u=l.message.mentionedUserIds)&&void 0!==u?u:null===(c=l.message.mentionedUsers)||void 0===c?void 0:c.map((function(e){return e.userId}))},d.userId),l}return d(t,e),t}(U),It=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:"FEDI",ackRequired:!0,payload:c({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,u,c,l=this;(l=e.call(this,t,"FEDI",r)||this).message=new P(t,r);var d=T.of(t).sdkState;return l.mentionCountChange=C({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:l.message.mentionType,mentionedUserIds:null!==(u=l.message.mentionedUserIds)&&void 0!==u?u:null===(c=l.message.mentionedUsers)||void 0===c?void 0:c.map((function(e){return e.userId}))},d.userId),l}return d(t,e),t}(U),Mt=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 Et=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),St=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),bt=function(e){function t(t,n){var r=e.call(this,t,n)||this;return r.reactionEvent=new A(n),r}return d(t,e),t}(m),Ct=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),Pt=function(e){function t(t,n){var r=e.call(this,t,n)||this;return r.reactionEvent=new A(u({},n)),r}return d(t,e),t}(m),At=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),Dt=function(e){function t(t,n){var r=e.call(this,t,n)||this;return r.message=new S(t,n),r}return d(t,e),t}(m),qt=function(t){function n(n){var r,i=this;i=t.call(this)||this;var s=[];n.mentionType===e.USERS&&(n.mentionedUserIds?s=n.mentionedUserIds:n.mentionedUsers&&(s=n.mentionedUsers.map((function(e){return e.userId}))));var u=n.channelType,c=n.channelUrl;return i.method=h.POST,i.path="".concat(p(u),"/").concat(encodeURIComponent(c),"/scheduled_messages"),i.params={req_id:n.reqId,scheduled_at:n.scheduledAt,message_type:D.USER,message:n.message,custom_type:n.customType,data:n.data,mention_type:n.mentionType,mentioned_user_ids:s,sorted_metaarray:null===(r=n.metaArrays)||void 0===r?void 0:r.map((function(e){return a.payloadify(e)})),apple_critical_alert_options:o.payloadify(n.appleCriticalAlertOptions),target_langs:n.translationTargetLanguages,push_option:n.pushNotificationDeliveryOption},i}return d(n,t),n}(f),Rt=function(e){function t(t,n){var r=e.call(this,t,n)||this;return r.message=new S(t,n),r}return d(t,e),t}(m),kt=function(t){function n(n){var r,i=this;i=t.call(this)||this;var s=[];n.mentionType===e.USERS&&(n.mentionedUserIds?s=n.mentionedUserIds:n.mentionedUsers&&(s=n.mentionedUsers.map((function(e){return e.userId}))));var u=n.channelType,c=n.channelUrl;return i.method=h.POST,i.path="".concat(p(u),"/").concat(encodeURIComponent(c),"/scheduled_messages"),i.params={req_id:n.reqId,scheduled_at:n.scheduledAt,message_type:D.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 q.payloadify(e)})):[],custom_type:n.customType,data:n.data,require_auth:n.requireAuth,mention_type:n.mentionType,mentioned_user_ids:s,sorted_metaarray:null===(r=n.metaArrays)||void 0===r?void 0:r.map((function(e){return a.payloadify(e)})),apple_critical_alert_options:o.payloadify(n.appleCriticalAlertOptions),push_option:n.pushNotificationDeliveryOption},i}return d(n,t),n}(f),Nt=function(e){function t(t,n){var r=e.call(this,t,n)||this;return r.message=new P(t,n),r}return d(t,e),t}(m),Ot=2,Ft=function(e){function h(n,r){var a,s,o,u,c=this;return(c=e.call(this,n)||this).url="",c.channelType=M.BASE,c.name="",c.coverUrl="",c.customType="",c.data="",c.isFrozen=!1,c.isEphemeral=!1,c.creator=null,c.createdAt=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,c._cachedMetaData=new Map,r.metadata&&r.ts&&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 c(u(u({},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}))},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.forEach((function(t,n){t.isRemoved||(e[n]=t.value)})),e},enumerable:!1,configurable:!0}),h.prototype._upsertCachedMetaData=function(e,t){var n=this;Object.keys(e).forEach((function(r){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;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 At({channelType:this.channelType,channelUrl:this.url,messageId:e.messageId,translationTargetLanguages:t}),[4,n.send(i)];case 1:return a=s.sent(),[2,a.as(Dt).message]}}))}))},h.prototype._createScheduledUserMessage=function(e,t){var n=this,r=T.of(this._iid).requestQueue,i=Date.now(),a=this._generateRequestId();G(2).then((function(){var r=n._createPendingScheduledUserMessage(e,a,i);V((function(){return v(n,void 0,void 0,(function(){return g(this,(function(e){return[2,t._trigger(null,r)]}))}))}))}));var s=new qt(u({reqId:a,channelType:this.channelType,channelUrl:this.url},e));r.send(s).then((function(e){var r=e.as(Rt).message;V((function(){return v(n,void 0,void 0,(function(){return g(this,(function(e){return[2,t._trigger(null,r)]}))}))}))})).catch((function(r){if(W(r))throw r;G(2).then((function(){var s=n._createPendingScheduledUserMessage(e,a,i);n._markMessageAsFailed(s,r),V((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=u(u({},ge),e);return x(_e(t)).throw(_.invalidParameters),this._sendFileMessage(t)},h.prototype._sendFileMessage=function(e,t){var n=this;void 0===t&&(t=null);var r=T.of(this._iid).dispatcher,i=Y.of(this._iid).fileMessageQueue,a=t,s=Date.now(),o=new J;return a||(a=this._generateRequestId(),G(2).then((function(){var t=n._createPendingFileMessage(e,a,s);r.dispatch(new B({messages:[t],source:j.EVENT_MESSAGE_SENT_PENDING})),V((function(){return v(n,void 0,void 0,(function(){return g(this,(function(e){return[2,o._trigger(null,t)]}))}))}))}))),i.request(this,a,e).then((function(e){r.dispatch(new B({messages:[e],source:j.EVENT_MESSAGE_SENT_SUCCESS})),V((function(){return v(n,void 0,void 0,(function(){return g(this,(function(t){return[2,o._trigger(null,e)]}))}))}))})).catch((function(t){if(W(t))throw t;G(2).then((function(){var i=n._createPendingFileMessage(e,a,s),u=T.of(n._iid).cacheContext.localCacheEnabled&&K(t.code);n._markMessageAsFailed(i,t,u),r.dispatch(new B({messages:[i],source:i.sendingStatus===F.PENDING?j.REQUEST_RESEND_MESSAGE:j.EVENT_MESSAGE_SENT_FAILED})),V((function(){return v(n,void 0,void 0,(function(){return g(this,(function(e){return[2,o._trigger(t,i)]}))}))}))}))})),o},h.prototype._autoResendFileMessage=function(e){x(e instanceof P).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._createScheduledFileMessage=function(e,t,n,r){var i=this,a=T.of(this._iid).requestQueue,s=new kt(u(u({reqId:n,channelType:this.channelType,channelUrl:this.url},e),{fileUrl:e.fileUrl,requireAuth:e.requireAuth}));a.send(s).then((function(e){var n=e.as(Nt).message;V((function(){return v(i,void 0,void 0,(function(){return g(this,(function(e){return[2,t._trigger(null,n)]}))}))}))})).catch((function(a){if(W(a))throw a;G(2).then((function(){var s=i._createPendingScheduledFileMessage(e,n,r);i._markMessageAsFailed(s,a),V((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;x(e.every((function(e){return _e(u(u({},ge),e))}))).throw(_.invalidParameters);var r=new J;try{for(var i=L(e),a=i.next();!a.done;a=i.next()){var s=a.value;this.sendFileMessage(s).onPending((function(e){return r._trigger(null,e)})).onFailed((function(e,t){return r._trigger(e,t)})).onSucceeded((function(e){return r._trigger(null,e)}))}}catch(e){t={error:e}}finally{try{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)||l(t)||l(null===(n=e.messageParams)||void 0===n?void 0:n.file),x(e instanceof P&&r&&!e.scheduledInfo).throw(_.invalidParameters),i=new ae,a=function(e,t){var n;return void 0===t&&(t=null),e.messageParams?(!e.url&&l(t)&&(e.messageParams.file=t),e.messageParams):c({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:e.thumbnails.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,s;return g(this,(function(o){switch(o.label){case 0:return r=u(u({},be),n),x(t("number",e)&&function(e){return Me(e)}(r)).throw(_.invalidParameters),i=T.of(this._iid).requestQueue,a=new It(u({channelType:this.channelType,channelUrl:this.url,messageId:e},r)),[4,i.send(a)];case 1:return s=o.sent(),[2,s.as(wt).message]}}))}))},h.prototype.cancelUploadingFileMessage=function(e){return v(this,void 0,void 0,(function(){return g(this,(function(n){return x(t("string",e)).throw(_.invalidParameters),Y.of(this._iid).fileMessageQueue.cancel(this,e),[2,!0]}))}))},h.prototype.copyFileMessage=function(e,t){var n,r;return v(this,void 0,void 0,(function(){var i,a;return g(this,(function(o){return x(e instanceof h&&t instanceof P&&t.sendingStatus===F.SUCCEEDED&&e.url===t.channelUrl&&!t.scheduledInfo).throw(_.invalidParameters),i=new ae,a=u(u({},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:s.DEFAULT,parentMessageId:null,isReplyToChannel:!1,thumbnailSizes:t.thumbnails.map((function(e){return{maxWidth:e.width,maxHeight:e.height}})),requireAuth:t.requireAuth}),e._sendFileMessage(a).onSucceeded((function(e){return i.resolve(e)})).onFailed((function(e){return i.reject(e)})),[2,i.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 x(e instanceof se).throw(_.invalidParameters),e.messageId>0?(t=T.of(this._iid).requestQueue,n=new Mt({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 x(e instanceof oe&&e.messageId>0&&t("string",n)).throw(_.invalidParameters),r=T.of(this._iid).requestQueue,i=new St({channelType:this.channelType,channelUrl:this.url,messageId:e.messageId,reactionKey:n}),[4,r.send(i)];case 1:return a=s.sent(),[2,a.as(bt).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 x(e instanceof oe&&e.messageId>0&&t("string",n)).throw(_.invalidParameters),r=T.of(this._iid).requestQueue,i=new Ct({channelType:this.channelType,channelUrl:this.url,messageId:e.messageId,reactionKey:n}),[4,r.send(i)];case 1:return a=s.sent(),[2,a.as(Pt).reactionEvent]}}))}))},h.prototype._updateMessageMetaArray=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 Tt({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(Ut).message,a.dispatch(new B({messages:[c],source:j.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 x(e instanceof se&&e.messageId>0&&r("string",t)).throw(_.invalidParameters),n=t.map((function(e){return new a({key:e})})),[2,this._updateMessageMetaArray(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 x(e instanceof se&&e.messageId>0&&r("string",t)).throw(_.invalidParameters),n=t.map((function(e){return new a({key:e})})),[2,this._updateMessageMetaArray(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 x(e instanceof se&&e.messageId>0&&t.every((function(e){return e instanceof a}))).throw(_.invalidParameters),[2,this._updateMessageMetaArray(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 x(e instanceof se&&e.messageId>0&&t.every((function(e){return e instanceof a}))).throw(_.invalidParameters),[2,this._updateMessageMetaArray(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 x(n(Te,e)&&t("string",r)).throw(_.invalidParameters),i=T.of(this._iid),a=i.sdkState,s=i.requestQueue,o=new mt({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 x(e instanceof i&&n(Te,r)&&t("string",a)).throw(_.invalidParameters),s=T.of(this._iid),o=s.sdkState,u=s.requestQueue,c=new vt({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 x(e instanceof se&&n(Te,r)&&t("string",i)).throw(_.invalidParameters),a=T.of(this._iid),s=a.sdkState,o=a.requestQueue,u=new yt({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}(H);export{ce as B,Rt as C,Et as D,ue as F,Re as M,Ae as O,Ot as P,Te as R,he as U,ye as a,le as b,me as c,Oe as d,Ft as e,Ie as f,Ue as g,fe as h,ve as i,nt as j,Ve as k,ft as l,ht as m,lt as n,st as o,ut as p,Ut as q,wt as r,de as s,_t as t,we as u,pe as v,Me as w,Ee as x,Se as y}; diff --git a/__bundle-3b6b9d30.js b/__bundle-3b6b9d30.js new file mode 100644 index 0000000..4c187fb --- /dev/null +++ b/__bundle-3b6b9d30.js @@ -0,0 +1 @@ +import{_ as e,A as t,a as n,b as r,P as i,c as s,d as o,g as a,e as u,i as c,v as l,f as h,h as d,C as f,j as p,k as v,M as _,u as m,S as y,l as g,m as b,n as I,V as E,U as w,o as k,q as N,r as S,s as T,t as O,w as C,R as A,x as L,F as x,y as P,I as R,z as D,E as M,B as U,D as q,G as F,H as B,J as K,K as j,L as H,W as z,N as V,O as Q,Q as G,T as W,X as Y,Y as J,Z as X,$ as Z,a0 as $,a1 as ee,a2 as te,a3 as ne,a4 as re,a5 as ie,a6 as se,a7 as oe,a8 as ae,a9 as ue,aa as ce,ab as le,ac as he}from"./__bundle-1abffbb6.js";import{U as de,s as fe,v as pe,B as ve,a as _e,b as me,i as ye,F as ge,c as be}from"./__bundle-329965e1.js";var Ie,Ee,we,ke;!function(e){e.SUCCESS="success",e.PENDING="pending",e.ERROR="error"}(Ie||(Ie={})),function(e){e.DEFAULT="default",e.ALL="all",e.MENTION_ONLY="mention_only",e.OFF="off"}(Ee||(Ee={})),function(e){e.FCM="gcm",e.APNS="apns",e.UNKNOWN="unknown"}(we||(we={})),function(e){e.ALTERNATIVE="alternative",e.DEFAULT="default"}(ke||(ke={}));var Ne,Se,Te,Oe=function(r){function i(e){var i=e.title,s=e.optionTexts,o=e.data,a=e.allowUserSuggestion,u=e.allowMultipleVotes,c=e.closeAt,l=r.call(this)||this;return l.method=t.POST,l.path=n,l.params={title:i,options:s,data:o,allow_user_suggestion:a,allow_multiple_votes:u,close_at:c},l}return e(i,r),i}(r),Ce=function(t){function n(e,n){var r=t.call(this,e,n)||this;return r.poll=new i(e,n),r}return e(n,t),n}(s),Ae=function(r){function i(e){var i=e.channelUrl,s=e.channelType,o=e.pollId,a=r.call(this)||this;return a.method=t.GET,a.path="".concat(n,"/").concat(encodeURIComponent(o)),a.params={channel_url:i,channel_type:s},a}return e(i,r),i}(r),Le=function(t){function n(e,n){var r=t.call(this,e,n)||this;return r.poll=new i(e,n),r}return e(n,t),n}(s),xe=function(r){function i(e){var i=e.channelUrl,s=e.channelType,o=e.pollId,a=e.pollOptionId,u=r.call(this)||this;return u.method=t.GET,u.path="".concat(n,"/").concat(encodeURIComponent(o),"/options/").concat(encodeURIComponent(a)),u.params={channel_url:i,channel_type:s},u}return e(i,r),i}(r),Pe=function(t){function n(e,n){var r=t.call(this,e,n)||this;return r.pollOption=new o(e,n),r}return e(n,t),n}(s),Re=function(n){function r(e){var r=e.channelType,i=e.channelUrl,s=e.timestamp,o=e.token,c=n.call(this)||this;return c.method=t.GET,c.path="".concat(a(r),"/").concat(encodeURIComponent(i),"/polls/changelogs"),c.params=u({change_ts:s,token:o}),c}return e(r,n),r}(r),De=function(t){function n(e,n){var r=t.call(this,e,n)||this;return r.updatedPolls=n.updated.map((function(t){return function(e,t){return t?new i(e,t):null}(e,t)})),r.deletedPollIds=n.deleted.map((function(e){return e})),r.hasMore=n.has_more,r.nextToken=n.next,r}return e(n,t),n}(s),Me={title:null,optionTexts:null,data:null,allowUserSuggestion:null,allowMultipleVotes:null,closeAt:-1},Ue=function(e){return c("string",e.title)&&l(e.optionTexts)&&h(e.data)&&c("boolean",e.allowUserSuggestion,!0)&&c("boolean",e.allowMultipleVotes,!0)&&c("number",e.closeAt,!0)},qe={channelUrl:null,channelType:null,pollId:null,pollOptionId:null},Fe=function(e){return c("string",e.channelUrl)&&d(f,e.channelType)&&c("number",e.pollId)&&c("number",e.pollOptionId)},Be={channelUrl:null,channelType:null,pollId:null},Ke=function(e){return c("string",e.channelUrl)&&""!==e.channelUrl&&d(f,e.channelType)&&c("number",e.pollId)},je={},He=function(){function e(e,t){var n=t.sdkState,r=t.dispatcher,i=t.sessionManager,s=t.requestQueue,o=t.logger;this._iid=e,this._sdkState=n,this._sessionManager=i,this._requestQueue=s,this._dispatcher=r,this._logger=o,je[e]=this}return e.of=function(e){return je[e]},e.prototype.get=function(e){return p(this,void 0,void 0,(function(){var t,n;return v(this,(function(r){switch(r.label){case 0:return m(Ke(e)).throw(y.invalidParameters),t=new Ae(g({},e)),[4,this._requestQueue.send(t)];case 1:return n=r.sent(),[2,n.as(Le).poll]}}))}))},e.prototype.create=function(e){return p(this,void 0,void 0,(function(){var t,n,r;return v(this,(function(i){switch(i.label){case 0:return m(Ue(e)).throw(y.invalidParameters),t=e.data,n=new Oe(g(g({},e),{data:t})),[4,this._requestQueue.send(n)];case 1:return r=i.sent(),[2,r.as(Ce).poll]}}))}))},e.prototype.getOption=function(e){return p(this,void 0,void 0,(function(){var t,n;return v(this,(function(r){switch(r.label){case 0:return m(Fe(e)).throw(y.invalidParameters),t=new xe(g({},e)),[4,this._requestQueue.send(t)];case 1:return n=r.sent(),[2,n.as(Pe).pollOption]}}))}))},e.prototype.getPollChangeLogs=function(e,t,n,r){return void 0===r&&(r=_.SYNC_POLL_CHANGELOGS),p(this,void 0,void 0,(function(){var i,s,o,a,c,l,h;return v(this,(function(d){switch(d.label){case 0:return i=new Re(u({channelType:t,channelUrl:e,timestamp:"number"==typeof n?n:null,token:"string"==typeof n?n:null})),[4,this._requestQueue.send(i)];case 1:return s=d.sent(),o=s.as(De),a=o.updatedPolls,c=o.deletedPollIds,l=o.hasMore,h=o.nextToken,a.length>0&&this._dispatcher.dispatch(new b({polls:a,source:r})),[2,{updatedPolls:a,deletedPollIds:c,hasMore:l,token:h}]}}))}))},e}(),ze=function(e,t){this.pollId=0,this.messageId=0,this.pollId=t.poll.id,this.messageId=t.poll.message_id,this._iid=e,this._payload=t},Ve=function(e){this.pollId=0,this.messageId=0,this.pollId=e.poll_id,this.messageId=e.message_id,this._payload=e},Qe=function(r){function i(e){var i=e.channelUrl,s=e.channelType,o=e.token,a=e.limit,u=r.call(this)||this;return u.method=t.GET,u.path=n,u.params={channel_url:i,channel_type:s,token:o,limit:a},u}return e(i,r),i}(r),Ge=function(t){function n(e,n){var r,s=this;return(s=t.call(this,e,n)||this).polls=(null!==(r=n.polls)&&void 0!==r?r:[]).map((function(t){return new i(e,t)})),s.token=n.next,s}return e(n,t),n}(s),We=function(t){function n(e,n){return t.call(this,e,n.channelUrl,n.channelType,n)||this}return e(n,t),n.prototype.next=function(){return p(this,void 0,void 0,(function(){var e,t,n,r,i,s;return v(this,(function(o){switch(o.label){case 0:return this._validate()?this._isLoading?[3,3]:this._hasNext?(this._isLoading=!0,e=E.of(this._iid).requestQueue,t=new Qe(g(g({},this),{token:this._token})),[4,e.send(t)]):[3,2]:[3,5];case 1:return n=o.sent(),r=n.as(Ge),i=r.polls,s=r.token,this._token=s,this._hasNext=!!s,this._isLoading=!1,[2,i];case 2:return[2,[]];case 3:throw y.queryInProgress;case 4:return[3,6];case 5:throw y.invalidParameters;case 6:return[2]}}))}))},n}(I),Ye=function(r){function i(e){var i=e.channelUrl,s=e.channelType,o=e.pollId,a=e.pollOptionId,u=e.token,c=e.limit,l=r.call(this)||this;return l.method=t.GET,l.path="".concat(n,"/").concat(encodeURIComponent(o),"/options/").concat(encodeURIComponent(a),"/voters"),l.params={channel_url:i,channel_type:s,token:u,limit:c},l}return e(i,r),i}(r),Je=function(t){function n(e,n){var r,i=this;return(i=t.call(this,e,n)||this).voters=(null!==(r=n.voters)&&void 0!==r?r:[]).map((function(t){return new w(e,t)})),i.token=n.next,i}return e(n,t),n}(s),Xe=function(t){function n(e,n){var r=t.call(this,e,n.channelUrl,n.channelType,n)||this;return r.pollId=n.pollId,r.pollOptionId=n.pollOptionId,r}return e(n,t),n.prototype._validate=function(){return t.prototype._validate.call(this)&&c("number",this.pollId)&&c("number",this.pollOptionId)},n.prototype.next=function(){return p(this,void 0,void 0,(function(){var e,t,n,r,i,s;return v(this,(function(o){switch(o.label){case 0:return this._validate()?this._isLoading?[3,3]:this._hasNext?(this._isLoading=!0,e=E.of(this._iid).requestQueue,t=new Ye(g(g({},this),{pollId:this.pollId,pollOptionId:this.pollOptionId,token:this._token})),[4,e.send(t)]):[3,2]:[3,5];case 1:return n=o.sent(),r=n.as(Je),i=r.voters,s=r.token,this._token=s,this._hasNext=!!s,this._isLoading=!1,[2,i];case 2:return[2,[]];case 3:throw y.queryInProgress;case 4:return[3,6];case 5:throw y.invalidParameters;case 6:return[2]}}))}))},n}(I),Ze=function(t){function n(){var e=null!==t&&t.apply(this,arguments)||this;return e.name="poll",e}return e(n,t),n.prototype.init=function(e,n){var r=n.sdkState,i=n.dispatcher,s=n.sessionManager,o=n.requestQueue,a=n.logger,u=n.onlineDetector,c=n.cacheContext;t.prototype.init.call(this,e,{sdkState:r,dispatcher:i,sessionManager:s,requestQueue:o,logger:a,onlineDetector:u,cacheContext:c}),this._manager=new He(e,{sdkState:r,dispatcher:i,sessionManager:s,requestQueue:o,logger:a,onlineDetector:u,cacheContext:c})},n.prototype.create=function(e){return p(this,void 0,void 0,(function(){var t;return v(this,(function(n){return t=g(g({},Me),e),m(Ue(t)).throw(y.invalidParameters),[2,this._manager.create(t)]}))}))},n.prototype.get=function(e){return p(this,void 0,void 0,(function(){var t;return v(this,(function(n){return t=g(g({},Be),e),m(Ke(t)).throw(y.invalidParameters),[2,this._manager.get(t)]}))}))},n.prototype.getOption=function(e){return p(this,void 0,void 0,(function(){var t;return v(this,(function(n){return t=g(g({},qe),e),m(Fe(t)).throw(y.invalidParameters),[2,this._manager.getOption(t)]}))}))},n}(k),$e={profileImage:null,profileUrl:null,nickname:null},et=function(t){function n(e){void 0===e&&(e={});var n=t.call(this)||this;return Object.keys(e).forEach((function(t){n.hasOwnProperty(t)&&(n[t]=e[t])})),n}return e(n,t),n}((function(){this.onSessionExpired=S,this.onSessionTokenRequired=function(e){return e(null)},this.onSessionError=S,this.onSessionRefreshed=S,this.onSessionClosed=S})),tt=function(t){function n(e){void 0===e&&(e={});var n=t.call(this)||this;return Object.keys(e).forEach((function(t){n.hasOwnProperty(t)&&(n[t]=e[t])})),n}return e(n,t),n}((function(){this.onConnected=S,this.onReconnectStarted=S,this.onReconnectSucceeded=S,this.onReconnectFailed=S,this.onDisconnected=S})),nt=function(t){function n(e){void 0===e&&(e={});var n=t.call(this)||this;return Object.keys(e).forEach((function(t){n.hasOwnProperty(t)&&(n[t]=e[t])})),n}return e(n,t),n}((function(){this.onFriendsDiscovered=S,this.onTotalUnreadMessageCountUpdated=S})),rt=100,it="GroupChannel",st=100,ot=10,at=20;!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"}(Ne||(Ne={})),function(e){e.CHRONOLOGICAL="chronological",e.CHANNEL_NAME_ALPHABETICAL="channel_name_alphabetical",e.METADATA_VALUE_ALPHABETICAL="metadata_value_alphabetical"}(Se||(Se={})),function(e){e.CREATED_AT="created_at",e.SCHEDULED_AT="scheduled_at"}(Te||(Te={}));var ut,ct=function(e){switch(e){case Ne.LATEST_LAST_MESSAGE:return["-lastMessageUpdatedAt","-createdAt","syncIndex"];case Ne.CHRONOLOGICAL:return["-createdAt","syncIndex"];case Ne.CHANNEL_NAME_ALPHABETICAL:return["name"]}},lt=function(){function e(){this.messageTypeFilter=T.ALL,this.customTypesFilter=null,this.senderUserIdsFilter=null,this.replyType=A.NONE}return e.prototype.clone=function(){var t=new e,n=JSON.parse(JSON.stringify(this));return Object.keys(n).forEach((function(e){t[e]=n[e]})),t},e.prototype.match=function(e){switch(this.messageTypeFilter){case T.USER:if(e.messageType!==O.USER)return!1;break;case T.FILE:if(e.messageType!==O.FILE)return!1;break;case T.ADMIN:if(e.messageType!==O.ADMIN)return!1}if(this.customTypesFilter&&this.customTypesFilter.length>0&&!this.customTypesFilter.includes(e.customType))return!1;if(this.senderUserIdsFilter&&this.senderUserIdsFilter.length>0){if(!(e instanceof C))return!1;if(!this.senderUserIdsFilter.includes(e.sender.userId))return!1}switch(this.replyType){case A.NONE:if(e.parentMessageId>0)return!1;break;case A.ONLY_REPLY_TO_CHANNEL:if(e instanceof C&&e.parentMessageId>0&&!e.replyToChannel)return!1}return!0},e}();!function(e){e.CHANNEL_LATEST="channel_latest",e.NEWEST_CHILD_MESSAGE="newest_child_message"}(ut||(ut={}));var ht,dt=function(e){switch(e){case ut.CHANNEL_LATEST:return["channelUrl","-createdAt","-messageId"];case ut.NEWEST_CHILD_MESSAGE:return["channelUrl","-parentMessageId","-createdAt","-messageId"]}},ft=g(g({},de),{scheduledAt:null}),pt=function(e){return pe(e)&&c("number",e.scheduledAt,!0)},vt=g(g({},ve),{scheduledAt:null,file:null,fileUrl:null,fileName:null,mimeType:null,fileSize:null,thumbnailSizes:null,requireAuth:!1}),_t=function(e){return me(e)&&c("number",e.scheduledAt)&&(N(e.file)||c("string",e.fileUrl))&&c("string",e.fileName,!0)&&c("string",e.mimeType,!0)&&c("number",e.fileSize,!0)&&(null===e.thumbnailSizes||e.thumbnailSizes.every((function(e){return c("object",e)&&e.maxWidth>0&&e.maxHeight>0})))},mt={},yt=function(t){function n(e,n){var r=n.sdkState,i=n.cacheContext,s=t.call(this,e)||this;return s._sdkState=r,s._cacheContext=i,mt[e]=s,s}return e(n,t),n.of=function(e){return mt[e]},Object.defineProperty(n.prototype,"collection",{get:function(){var e=this._cacheContext.nestdb;return e&&e.collection("UnsentMessage")},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"localCacheEnabled",{get:function(){return this._cacheContext.localCacheEnabled&&!!this.collection},enumerable:!1,configurable:!0}),n.prototype._serialize=function(e){if(e.messageId>0)throw y.invalidParameters;var t,n=g({},e.serialize());return e instanceof L?(e.messageParams&&(n.messageParams=fe(e.messageParams)),e.scheduledInfo&&e.scheduledInfo.scheduledMessageParams&&(n.scheduledInfo.scheduledMessageParams=(t=e.scheduledInfo.scheduledMessageParams,g(g({},fe(t)),{scheduledAt:t.scheduledAt})))):e instanceof x&&(e.messageParams&&(n.messageParams=_e(e.messageParams)),e.scheduledInfo&&e.scheduledInfo.scheduledMessageParams&&(n.scheduledInfo.scheduledMessageParams=function(e){return g(g({},_e(e)),{scheduledAt:e.scheduledAt})}(e.scheduledInfo.scheduledMessageParams))),n},n.prototype._deserialize=function(e){return e?(e=g(g({},e),{messageId:parseInt(e.messageId)}),P.of(this._iid).buildMessageFromSerializedData(e)):null},n.prototype._deserializeWithMessageCreateParams=function(e){return p(this,void 0,void 0,(function(){var t,n,r,i,s,o;return v(this,(function(a){switch(a.label){case 0:return t=P.of(this._iid),n=this._deserialize(e),e.messageParams?n instanceof L?(r=e.messageParams,n.messageParams=t.buildUserMessageCreateParamsFromSerializedData(r,n),[3,4]):[3,1]:[3,4];case 1:return n instanceof x?(r=e.messageParams).fileKey&&"string"==typeof r.fileKey&&ye(r.fileType)?(i=r,[4,this.collection.getBlob(r.fileKey)]):[3,3]:[3,4];case 2:i.file=a.sent(),a.label=3;case 3:n.messageParams=t.buildFileMessageCreateParamsFromSerializedData(r,n),a.label=4;case 4:return n.scheduledInfo&&e.scheduledInfo&&e.scheduledInfo.scheduledMessageParams?n instanceof L?(s=e.scheduledInfo.scheduledMessageParams,n.scheduledInfo.scheduledMessageParams=t.buildScheduledUserMessageCreateParamsFromSerializedData(s,n),[3,8]):[3,5]:[3,8];case 5:return n instanceof x?(s=e.scheduledInfo.scheduledMessageParams).fileKey&&"string"==typeof s.fileKey&&ye(s.fileType)?(o=s,[4,this.collection.getBlob(s.fileKey)]):[3,7]:[3,8];case 6:o.file=a.sent(),a.label=7;case 7:n.scheduledInfo.scheduledMessageParams=t.buildScheduledFileMessageCreateParamsFromSerializedData(s,n),a.label=8;case 8:return[2,n]}}))}))},n.prototype.get=function(e){return p(this,void 0,void 0,(function(){var t;return v(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]}}))}))},n.prototype.fetch=function(e){var t=e.channelUrl,n=void 0===t?null:t,r=e.filter,i=void 0===r?new lt:r,s=e.order,o=void 0===s?ut.CHANNEL_LATEST:s,a=e.sendingStatus,u=void 0===a?null:a,c=e.backward,l=void 0!==c&&c,h=e.parentMessageId,d=void 0===h?null:h;return p(this,void 0,void 0,(function(){var e,t,r,s,a=this;return v(this,(function(c){switch(c.label){case 0:return this.localCacheEnabled?(e=dt(o),t={"/where":function(e){return!!(o!==ut.NEWEST_CHILD_MESSAGE||d&&0!==e.parentMessageId&&e.parentMessageId===d)&&i.match(a._deserialize(e))}},n&&(t.channelUrl=n),u&&(t.sendingStatus=u),r={where:t,index:e,backward:l},[4,this.collection.query(r)]):[3,3];case 1:return[4,c.sent().fetch({})];case 2:return s=c.sent(),[2,Promise.all(s.map((function(e){return p(a,void 0,void 0,(function(){return v(this,(function(t){switch(t.label){case 0:return[4,this._deserializeWithMessageCreateParams(e)];case 1:return[2,t.sent()]}}))}))})))];case 3:return[2,[]]}}))}))},n.prototype.getAllChildMessages=function(e,t){return void 0===t&&(t=new lt),p(this,void 0,void 0,(function(){return v(this,(function(n){switch(n.label){case 0:return[4,this.fetch({filter:t,order:ut.NEWEST_CHILD_MESSAGE,channelUrl:e.channelUrl,backward:!1,parentMessageId:e.messageId})];case 1:return[2,n.sent()]}}))}))},n.prototype.upsert=function(e){return p(this,void 0,void 0,(function(){var t,n=this;return v(this,(function(r){switch(r.label){case 0:return this.localCacheEnabled?[4,this.saveBlobs(e)]:[3,3];case 1:return r.sent(),t=e.map((function(e){return n._serialize(e)})),[4,this.collection.upsertMany(t)];case 2:r.sent(),r.label=3;case 3:return[2]}}))}))},n.prototype.upsertChildMessages=function(e){return p(this,void 0,void 0,(function(){var t=this;return v(this,(function(n){switch(n.label){case 0:return this.localCacheEnabled?[4,Promise.all(e.map((function(e){return p(t,void 0,void 0,(function(){var t,n;return v(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]}}))}))},n.prototype.remove=function(e){return p(this,void 0,void 0,(function(){var t,n,r,i,s,o;return v(this,(function(a){switch(a.label){case 0:if(!this.localCacheEnabled)return[3,8];a.label=1;case 1:a.trys.push([1,6,7,8]),t=D(e),n=t.next(),a.label=2;case 2:return n.done?[3,5]:(r=n.value,[4,this.collection.remove(r)]);case 3:a.sent(),a.label=4;case 4:return n=t.next(),[3,2];case 5:return[3,8];case 6:return i=a.sent(),s={error:i},[3,8];case 7:try{n&&!n.done&&(o=t.return)&&o.call(t)}finally{if(s)throw s.error}return[7];case 8:return[2]}}))}))},n.prototype.removeMessagesOfChannel=function(e){return p(this,void 0,void 0,(function(){return v(this,(function(t){switch(t.label){case 0:return this.localCacheEnabled?[4,this.collection.removeIf({where:{channelUrl:e}})]:[3,2];case 1:t.sent(),t.label=2;case 2:return[2]}}))}))},n.prototype.clear=function(){return p(this,void 0,void 0,(function(){return v(this,(function(e){switch(e.label){case 0:return this.localCacheEnabled?[4,this.collection.clear()]:[3,2];case 1:e.sent(),e.label=2;case 2:return[2]}}))}))},n.prototype.saveBlobs=function(e){return p(this,void 0,void 0,(function(){var t=this;return v(this,(function(n){switch(n.label){case 0:return[4,Promise.all(e.map((function(e){return p(t,void 0,void 0,(function(){var t,n,r;return v(this,(function(i){switch(i.label){case 0:return e instanceof x?e.messageParams&&(t=e.messageParams).file&&be(t.file)?[4,this.collection.saveBlob(t.file,e.reqId)]:[3,2]:[3,4];case 1:r=i.sent(),t.fileKey=r,t.fileType=ge.BLOB,i.label=2;case 2:return e.scheduledInfo&&e.scheduledInfo.scheduledMessageParams&&((n=e.scheduledInfo.scheduledMessageParams).file&&be(n.file))?[4,this.collection.saveBlob(n.file,e.reqId)]:[3,4];case 3:r=i.sent(),n.fileKey=r,n.fileType=ge.BLOB,i.label=4;case 4:return[2]}}))}))})))];case 1:return n.sent(),[2]}}))}))},n}(R),gt={},bt=function(t){function n(e,n){var r=n.sdkState,i=n.cacheContext,s=n.unsentMessageCache,o=t.call(this,e)||this;return o._sdkState=r,o._cacheContext=i,o._unsentMessageCache=s,gt[e]=o,o}return e(n,t),n.of=function(e){return gt[e]},Object.defineProperty(n.prototype,"collection",{get:function(){var e=this._cacheContext.nestdb;return e?e.collection("Message"):null},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"localCacheEnabled",{get:function(){return this._cacheContext.localCacheEnabled&&!!this.collection},enumerable:!1,configurable:!0}),n.prototype._serialize=function(e){return g(g({},e.serialize()),{messageId:"".concat(e.messageId)})},n.prototype._deserialize=function(e){return e=g(g({},e),{messageId:parseInt(e.messageId)}),P.of(this._iid).buildMessageFromSerializedData(e)},n.prototype.get=function(e){return p(this,void 0,void 0,(function(){var t;return v(this,(function(n){switch(n.label){case 0:return this.localCacheEnabled?[4,this.collection.getByKey("".concat(e))]:[3,2];case 1:if(t=n.sent())return[2,this._deserialize(t)];n.label=2;case 2:return[2,null]}}))}))},n.prototype.fetch=function(e){var t=e.channelUrl,n=e.token,r=e.limit,i=void 0===r?100:r,s=e.filter,o=void 0===s?new lt:s,a=e.order,u=void 0===a?ut.CHANNEL_LATEST:a,c=e.backward,l=void 0!==c&&c,h=e.parentMessageId,d=void 0===h?null:h,f=e.isPollOnly,_=void 0!==f&&f;return p(this,void 0,void 0,(function(){var e,r,s,a=this;return v(this,(function(c){switch(c.label){case 0:return this.localCacheEnabled?(e=dt(u),r={where:{channelUrl:t,"/where":function(e){if(n)switch(u){case ut.CHANNEL_LATEST:if(!l&&e.createdAt>n||l&&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]}}))}))},n.prototype.remove=function(e){return p(this,void 0,void 0,(function(){var t,n,r,i,s,o;return v(this,(function(a){switch(a.label){case 0:if(!this.localCacheEnabled)return[3,8];a.label=1;case 1:a.trys.push([1,6,7,8]),t=D(e),n=t.next(),a.label=2;case 2:return n.done?[3,5]:(r=n.value,[4,this.collection.remove("".concat(r))]);case 3:a.sent(),a.label=4;case 4:return n=t.next(),[3,2];case 5:return[3,8];case 6:return i=a.sent(),s={error:i},[3,8];case 7:try{n&&!n.done&&(o=t.return)&&o.call(t)}finally{if(s)throw s.error}return[7];case 8:return[2]}}))}))},n.prototype.removeMessagesOfChannel=function(e){return p(this,void 0,void 0,(function(){var t;return v(this,(function(n){switch(n.label){case 0:return this.localCacheEnabled?[4,this.collection.removeIf({where:{channelUrl:e},index:dt(ut.CHANNEL_LATEST)})]:[3,6];case 1:return n.sent(),[4,(t=this._cacheContext.preference).remove("sendbird:".concat(this._sdkState.userId,"@groupchannel/").concat(e,"/message/sync"))];case 2:return n.sent(),[4,t.remove("sendbird:".concat(this._sdkState.userId,"@groupchannel/").concat(e,"/message/sync.meta"))];case 3:return n.sent(),[4,t.remove("sendbird:".concat(this._sdkState.userId,"@groupchannel/").concat(e,"/message/changelogs"))];case 4:return n.sent(),[4,t.remove("sendbird:".concat(this._sdkState.userId,"@groupchannel/").concat(e,"/message/changelogs.meta"))];case 5:n.sent(),n.label=6;case 6:return[2]}}))}))},n.prototype.removeUnderOffset=function(e,t){return p(this,void 0,void 0,(function(){return v(this,(function(n){switch(n.label){case 0:return this.localCacheEnabled?[4,this.collection.removeIf({where:{channelUrl:e,createdAt:{"<":t}},index:dt(ut.CHANNEL_LATEST)})]:[3,2];case 1:n.sent(),n.label=2;case 2:return[2]}}))}))},n.prototype.clear=function(){return p(this,void 0,void 0,(function(){return v(this,(function(e){switch(e.label){case 0:return this.localCacheEnabled?[4,this.collection.clear()]:[3,2];case 1:e.sent(),e.label=2;case 2:return[2]}}))}))},n.prototype.countBetween=function(e,t,n){return p(this,void 0,void 0,(function(){var r,i=this;return v(this,(function(s){switch(s.label){case 0:return this.localCacheEnabled?(r=dt(ut.CHANNEL_LATEST),[4,this.collection.query({where:{channelUrl:e,"/where":function(e){var r=i._deserialize(e);return n.includes(r.createdAt)&&t.match(r)}},index:r}).count()]):[3,2];case 1:return[2,s.sent()];case 2:return[2,0]}}))}))},n.prototype.saveBlobs=function(e){return p(this,void 0,void 0,(function(){var t=this;return v(this,(function(n){switch(n.label){case 0:return[4,Promise.all(e.map((function(e){return p(t,void 0,void 0,(function(){var t,n;return v(this,(function(r){switch(r.label){case 0:return e instanceof x&&e.messageParams&&((t=e.messageParams).file&&be(t.file))?[4,this.collection.saveBlob(t.file,e.reqId)]:[3,2];case 1:n=r.sent(),t.fileKey=n,r.label=2;case 2:return[2]}}))}))})))];case 1:return n.sent(),[2]}}))}))},n}(R),It=function(t){function n(){var e=t.call(this)||this;return e._pauseDelayTimer=null,e._currentState="visible",e._toggleState=e._toggleState.bind(e),e}return e(n,t),Object.defineProperty(n.prototype,"isAvailable",{get:function(){return"undefined"!=typeof window&&!!window.addEventListener&&!!window.removeEventListener},enumerable:!1,configurable:!0}),n.prototype._toggleState=function(){var e=this;"hidden"!==document.visibilityState?"hidden"===this._currentState&&(this._pauseDelayTimer&&(clearTimeout(this._pauseDelayTimer),this._pauseDelayTimer=null),this.dispatch("resume")):"hidden"!==this._currentState&&(this._pauseDelayTimer=setTimeout((function(){e._pauseDelayTimer=null,e.dispatch("pause")}),3e4)),this._currentState=document.visibilityState},n.prototype.start=function(){this.isAvailable&&window.addEventListener("visibilitychange",this._toggleState,{capture:!0})},n.prototype.stop=function(){this.isAvailable&&window.removeEventListener("visibilitychange",this._toggleState,{capture:!0})},n}(M),Et=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 p(this,void 0,void 0,(function(){return v(this,(function(e){return this.isAvailableOnWeb?[2,navigator.onLine]:[2,new Promise((function(e){fetch("https://www.google.com",{method:t.GET,mode:"no-cors"}).then((function(){return e(!0)})).catch((function(){return e(!1)}))}))]}))}))},e}(),wt=function(t){function n(e){var n=e.message,r=t.call(this)||this;return r.message=n,r}return e(n,t),n}(U),kt={},Nt=function(){function e(e,t){var n=t.localCacheEnabled,r=t.dispatcher,i=t.sdkState,s=t.logger,o=this;kt[e]=this,this._iid=e,kt[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 B)switch(e.stateType){case K.CONNECTED:o._isProcessingAutoResend||o.processAutoResendRegisteredPendingMessages().then((function(){return o._processNextAutoResend()}));break;case K.DISCONNECTED:o._isProcessingAutoResend=!1}}))}return e.of=function(e){return kt[e]},e.prototype.processNonAutoResendRegisteredPendingMessages=function(){return p(this,void 0,void 0,(function(){var e,t,n,r,i,s;return v(this,(function(o){switch(o.label){case 0:return[4,this._fetchAllCachedPendingMessages()];case 1:e=o.sent();try{for(t=D(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=q.FAILED,r.errorCode=j.ACK_TIMEOUT,this._dispatcher.dispatch(new H({messages:[r],source:_.LOCAL_MESSAGE_FAILED})))}catch(e){i={error:e}}finally{try{n&&!n.done&&(s=t.return)&&s.call(t)}finally{if(i)throw i.error}}return[2]}}))}))},e.prototype.processAutoResendRegisteredPendingMessages=function(){return p(this,void 0,void 0,(function(){var e,t,n,r,i,s,o,a;return v(this,(function(u){switch(u.label){case 0:return[4,this._fetchAllCachedPendingMessages()];case 1:e=u.sent();try{for(t=D(e),n=t.next();!n.done;n=t.next())(r=n.value).errorCode&&F(r.errorCode)&&(i=(new Date).getTime(),s=r.createdAt+2592e5,i<=s?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(s).toLocaleString()),r.sendingStatus=q.FAILED,this._dispatcher.dispatch(new H({messages:[r],source:_.LOCAL_MESSAGE_FAILED}))))}catch(e){o={error:e}}finally{try{n&&!n.done&&(a=t.return)&&a.call(t)}finally{if(o)throw o.error}}return[2]}}))}))},e.prototype.completeCurrentAndProcessNextAutoResend=function(e){if(this._localCacheEnabled&&(e.sendingStatus===q.SUCCEEDED||e.sendingStatus===q.FAILED&&!F(e.errorCode))){var t=this.indexOf(e);t>=0&&this._autoResendQueue.splice(t,1),0===t&&this._processNextAutoResend()}},e.prototype._fetchAllCachedPendingMessages=function(){return p(this,void 0,void 0,(function(){var e,t;return v(this,(function(n){switch(n.label){case 0:return(e=yt.of(this._iid))?[4,e.fetch({sendingStatus:q.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 p(this,void 0,void 0,(function(){var e;return v(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 wt({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"}(ht||(ht={}));var St=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 w(e,r),blockee:new w(e,i)}},e.getDataAsFriendDiscoveredEvent=function(e,t){var n=t.data.friend_discoveries;return{friendDiscoveries:Array.isArray(n)?n.map((function(t){return new w(e,t)})):[]}},e}(),Tt=function(t){function n(e,n){var r=n.userId,i=t.call(this)||this;return i._iid=e,i.userId=r,i}return e(n,t),n}(U),Ot=function(t){function n(e,n,r){var i=t.call(this,e,"USEV",r)||this;return i.event=new St(r),i}return e(n,t),n}(z),Ct=function(n){function r(e){var r=e.userId,i=e.nickname,s=void 0===i?null:i,o=e.profileUrl,a=void 0===o?null:o,c=e.profileImage,l=void 0===c?null:c,h=e.preferredLanguages,d=void 0===h?null:h,f=n.call(this)||this;return f.method=t.PUT,f.path="".concat(V,"/").concat(encodeURIComponent(r)),f.params=u({nickname:s,profile_url:a,profile_file:l,preferred_languages:d}),f}return e(r,n),r}(r),At=function(t){function n(e,n){var r=t.call(this,e,n)||this;return r.user=null,r.user=new w(e,g({},n)),r}return e(n,t),n}(s),Lt=function(n){function r(e){var r=e.userId,i=e.token,s=n.call(this)||this;return s.method=t.POST,s.path="".concat(V,"/").concat(encodeURIComponent(r),"/push/apns"),s.params={apns_device_token:i,always_push:!0},s}return e(r,n),r}(r);!function(t){function n(e,n){var r=t.call(this,e,n)||this;return r.token=n.token,r.type=n.type?we[n.type.toLowerCase()]:we.UNKNOWN,r.user=new w(e,n.user),r}e(n,t)}(s);var xt=function(n){function r(e){var r=e.userId,i=e.token,s=n.call(this)||this;return s.method=t.POST,s.path="".concat(V,"/").concat(encodeURIComponent(r),"/push/gcm"),s.params={gcm_reg_token:i,always_push:!0},s}return e(r,n),r}(r);!function(t){function n(e,n){var r=t.call(this,e,n)||this;return r.token=n.token,r.type=n.type?we[n.type.toLowerCase()]:we.UNKNOWN,r.user=new w(e,n.user),r}e(n,t)}(s);var Pt=function(n){function r(e){var r=e.userId,i=e.token,s=n.call(this)||this;return s.method=t.DELETE,s.path="".concat(V,"/").concat(encodeURIComponent(r),"/push/apns/").concat(encodeURIComponent(i)),s}return e(r,n),r}(r);!function(t){function n(e,n){var r=t.call(this,e,n)||this;return r.token=n.token,r.user=new w(e,n.user),r}e(n,t)}(s);var Rt=function(n){function r(e){var r=e.userId,i=e.token,s=n.call(this)||this;return s.method=t.DELETE,s.path="".concat(V,"/").concat(encodeURIComponent(r),"/push/gcm/").concat(encodeURIComponent(i)),s}return e(r,n),r}(r);!function(t){function n(e,n){var r=t.call(this,e,n)||this;return r.token=n.token,r.user=new w(e,n.user),r}e(n,t)}(s);var Dt=function(n){function r(e){var r=e.userId,i=n.call(this)||this;return i.method=t.DELETE,i.path="".concat(V,"/").concat(encodeURIComponent(r),"/push/apns"),i}return e(r,n),r}(r);!function(t){function n(e,n){var r=t.call(this,e,n)||this;return r.type=n.type?we[n.type.toLowerCase()]:we.UNKNOWN,r.user=new w(e,n.user),r}e(n,t)}(s);var Mt=function(n){function r(e){var r=e.userId,i=n.call(this)||this;return i.method=t.DELETE,i.path="".concat(V,"/").concat(encodeURIComponent(r),"/push/gcm"),i}return e(r,n),r}(r);!function(t){function n(e,n){var r=t.call(this,e,n)||this;return r.type=n.type?we[n.type.toLowerCase()]:we.UNKNOWN,r.user=new w(e,n.user),r}e(n,t)}(s);var Ut=function(n){function r(e){var r=e.userId,i=e.type,s=e.token,o=e.ts,a=n.call(this)||this;return a.method=t.GET,a.path="".concat(V,"/").concat(encodeURIComponent(r),"/push/").concat(encodeURIComponent(i),"/device_tokens"),a.params={created_ts:o,token:s},a}return e(r,n),r}(r),qt=function(t){function n(e,n){var r=t.call(this,e,n)||this;return r.pushTokens={type:n.type?we[n.type.toLowerCase()]:we.UNKNOWN,deviceTokens:n.device_tokens,hasMore:n.has_more,token:n.token},r}return e(n,t),n}(s),Ft=function(n){function r(e){var r=e.userId,i=n.call(this)||this;return i.method=t.GET,i.path="".concat(V,"/").concat(encodeURIComponent(r),"/channel_invitation_preference"),i}return e(r,n),r}(r),Bt=function(t){function n(e,n){var r=t.call(this,e,n)||this;return r.autoAccept=n.auto_accept,r}return e(n,t),n}(s),Kt=function(n){function r(e){var r=e.userId,i=e.willAutoAccept,s=n.call(this)||this;return s.method=t.PUT,s.path="".concat(V,"/").concat(encodeURIComponent(r),"/channel_invitation_preference"),s.params={auto_accept:i},s}return e(r,n),r}(r),jt=function(t){function n(e,n){var r=t.call(this,e,n)||this;return r.autoAccept=n.auto_accept,r}return e(n,t),n}(s),Ht=function(n){function r(e){var r=e.userId,i=n.call(this)||this;return i.method=t.GET,i.path="".concat(V,"/").concat(encodeURIComponent(r),"/push_preference"),i}return e(r,n),r}(r),zt=function(t){function n(e,n){var r=t.call(this,e,n)||this;return r.preference={doNotDisturbOn:n.do_not_disturb,startHour:n.start_hour,startMin:n.start_min,endHour:n.end_hour,endMin:n.end_min,timezone:n.timezone},r}return e(n,t),n}(s),Vt=function(n){function r(e){var r=e.userId,i=e.doNotDisturbOn,s=e.startHour,o=e.startMin,a=e.endHour,u=e.endMin,c=e.timezone,l=n.call(this)||this;return l.method=t.PUT,l.path="".concat(V,"/").concat(encodeURIComponent(r),"/push_preference"),l.params={do_not_disturb:i,start_hour:s,start_min:o,end_hour:a,end_min:u,timezone:c},l}return e(r,n),r}(r),Qt=function(t){function n(e,n){var r=t.call(this,e,n)||this;return r.preference={doNotDisturbOn:n.do_not_disturb,startHour:n.start_hour,startMin:n.start_min,endHour:n.end_hour,endMin:n.end_min,timezone:n.timezone},r}return e(n,t),n}(s),Gt=function(n){function r(e){var r=e.userId,i=n.call(this)||this;return i.method=t.GET,i.path="".concat(V,"/").concat(encodeURIComponent(r),"/push_preference"),i}return e(r,n),r}(r),Wt=function(t){function n(e,n){var r=t.call(this,e,n)||this;return r.snoozePeriod={isSnoozeOn:n.snooze_enabled},"number"==typeof n.snooze_start_ts&&(r.snoozePeriod.startTs=n.snooze_start_ts),"number"==typeof n.snooze_end_ts&&(r.snoozePeriod.endTs=n.snooze_end_ts),r}return e(n,t),n}(s),Yt=function(n){function r(e){var r=e.userId,i=e.snoozeOn,s=e.startTs,o=e.endTs,a=n.call(this)||this;return a.method=t.PUT,a.path="".concat(V,"/").concat(encodeURIComponent(r),"/push_preference"),a.params={snooze_enabled:i,snooze_start_ts:s,snooze_end_ts:o},a}return e(r,n),r}(r),Jt=function(t){function n(e,n){var r=t.call(this,e,n)||this;return r.snoozePeriod={isSnoozeOn:n.snooze_enabled},"number"==typeof n.snooze_start_ts&&(r.snoozePeriod.startTs=n.snooze_start_ts),"number"==typeof n.snooze_end_ts&&(r.snoozePeriod.endTs=n.snooze_end_ts),r}return e(n,t),n}(s),Xt=function(n){function r(e){var r=e.userId,i=e.blockedUserId,s=n.call(this)||this;return s.method=t.POST,s.path="".concat(V,"/").concat(encodeURIComponent(r),"/block"),s.params={target_id:i},s}return e(r,n),r}(r);!function(t){function n(e,n){var r=t.call(this,e,n)||this;return r.user=new w(e,n),r}e(n,t)}(s);var Zt=function(n){function r(e){var r=e.userId,i=e.unblockedUserId,s=n.call(this)||this;return s.method=t.DELETE,s.path="".concat(V,"/").concat(encodeURIComponent(r),"/block/").concat(encodeURIComponent(i)),s}return e(r,n),r}(r);!function(t){function n(){return null!==t&&t.apply(this,arguments)||this}e(n,t)}(s);var $t=function(n){function r(e){var r=e.userId,i=n.call(this)||this;return i.method=t.GET,i.path="".concat(V,"/").concat(encodeURIComponent(r),"/push_preference"),i}return e(r,n),r}(r),en=function(t){function n(e,n){var r=t.call(this,e,n)||this;return r.pushTriggerOption=n.push_trigger_option,r}return e(n,t),n}(s),tn=function(n){function r(e){var r=e.userId,i=e.pushTriggerOption,s=n.call(this)||this;return s.method=t.PUT,s.path="".concat(V,"/").concat(encodeURIComponent(r),"/push_preference"),s.params={push_trigger_option:i},s}return e(r,n),r}(r),nn=function(t){function n(e,n){var r=t.call(this,e,n)||this;return r.pushTriggerOption=n.push_trigger_option,r}return e(n,t),n}(s),rn=function(n){function r(e){var r=e.userId,i=n.call(this)||this;return i.method=t.GET,i.path="".concat(V,"/").concat(encodeURIComponent(r),"/push/template"),i}return e(r,n),r}(r),sn=function(t){function n(e,n){var r=t.call(this,e,n)||this;return r.name=n.name,r}return e(n,t),n}(s),on=function(n){function r(e){var r=e.userId,i=e.templateName,s=n.call(this)||this;return s.method=t.PUT,s.path="".concat(V,"/").concat(encodeURIComponent(r),"/push/template"),s.params={name:i},s}return e(r,n),r}(r),an=function(t){function n(e,n){var r=t.call(this,e,n)||this;return r.name=n.name,r}return e(n,t),n}(s),un=function(n){function r(e){var r=e.userId,i=e.token,s=n.call(this)||this;return s.method=t.GET,s.path="".concat(V,"/").concat(encodeURIComponent(r),"/friends/changelogs"),s.params={token:i},s}return e(r,n),r}(r),cn=function(t){function n(e,n){var r=t.call(this,e,n)||this;return r.changelogs={addedUsers:n.added.map((function(t){return new w(e,t)})),updatedUsers:n.updated.map((function(t){return new w(e,t)})),deletedUserIds:n.deleted,hasMore:n.has_more,token:n.next},r}return e(n,t),n}(s),ln=function(n){function r(e){var r=e.userId,i=e.discoveries,s=n.call(this)||this;return s.method=t.PUT,s.path="".concat(V,"/").concat(encodeURIComponent(r),"/friend_discoveries"),s.params={friend_discoveries:i.map((function(e){return{friend_discovery_key:e.friendDiscoveryKey,friend_name:e.friendName}}))},s}return e(r,n),r}(r),hn=function(t){function n(e,n){var r=t.call(this,e,n)||this;return r.friendDiscoveryRequestId=n.friend_discovery_request_id,r}return e(n,t),n}(s),dn=function(n){function r(e){var r=e.userId,i=e.discoveryKeys,s=n.call(this)||this;return s.method=t.DELETE,s.path="".concat(V,"/").concat(encodeURIComponent(r),"/friend_discoveries"),s.params={friend_discovery_keys:i},s}return e(r,n),r}(r);!function(t){function n(){return null!==t&&t.apply(this,arguments)||this}e(n,t)}(s);var fn=function(n){function r(e){var r=e.userId,i=e.userIds,s=n.call(this)||this;return s.method=t.POST,s.path="".concat(V,"/").concat(encodeURIComponent(r),"/friends"),s.params={user_ids:i},s}return e(r,n),r}(r),pn=function(t){function n(e,n){var r=t.call(this,e,n)||this;return r.users=n.users.map((function(t){return new w(e,t)})),r}return e(n,t),n}(s),vn=function(n){function r(e){var r=e.userId,i=e.userIds,s=n.call(this)||this;return s.method=t.DELETE,s.path="".concat(V,"/").concat(encodeURIComponent(r),"/friends"),s.params={user_ids:i},s}return e(r,n),r}(r);!function(t){function n(){return null!==t&&t.apply(this,arguments)||this}e(n,t)}(s);var _n=function(n){function r(e){var r=e.userId,i=n.call(this)||this;return i.method=t.GET,i.path="".concat(V,"/").concat(r,"/allow_friend_discovery"),i.params={},i}return e(r,n),r}(r),mn=function(t){function n(e,n){var r=t.call(this,e,n)||this;return r.allowFriendDiscovery=n.allow_friend_discovery,r}return e(n,t),n}(s),yn=function(n){function r(e){var r=e.userId,i=e.allowFriendDiscovery,s=n.call(this)||this;return s.method=t.PUT,s.path="".concat(V,"/").concat(r,"/allow_friend_discovery"),s.params={allow_friend_discovery:i},s}return e(r,n),r}(r);!function(t){function n(){return null!==t&&t.apply(this,arguments)||this}e(n,t)}(s);var gn,bn=function(e){this.key=null,this.url=null,this.key=e.key,this.url=e.url},In=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 bn(e)})):[]},En=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 In(e)})):[]},wn=function(n){function r(){var e=n.call(this)||this;return e.method=t.GET,e.path=Q,e}return e(r,n),r}(r),kn=function(t){function n(e,n){var r=t.call(this,e,n)||this;return r.emojiContainer=new En(n),r}return e(n,t),n}(s),Nn=function(n){function r(e){var r=e.categoryId,i=n.call(this)||this;return i.method=t.GET,i.path="".concat(Q,"/").concat(r),i}return e(r,n),r}(r),Sn=function(t){function n(e,n){var r=t.call(this,e,n)||this;return r.emojiCategory=new In(n),r}return e(n,t),n}(s),Tn=function(n){function r(e){var r=e.key,i=n.call(this)||this;return i.method=t.GET,i.path="".concat(G,"/").concat(r),i}return e(r,n),r}(r),On=function(t){function n(e,n){var r=t.call(this,e,n)||this;return r.emoji=new bn(n),r}return e(n,t),n}(s),Cn=function(n){function r(e){var r=e.limit,i=e.token,s=e.userIdsFilter,o=e.metaDataKeyFilter,a=e.metaDataValuesFilter,c=e.nicknameStartsWithFilter,l=n.call(this)||this;return l.method=t.GET,l.path=V,l.params=u({limit:r,token:i,user_ids:s,metadatakey:o,metadatavalues_in:a,nickname_startswith:c}),l}return e(r,n),r}(r),An=function(t){function n(e,n){var r=t.call(this,e,n)||this;return r.users=n.users.map((function(t){return new w(e,t)})),r.next=n.next,r}return e(n,t),n}(s),Ln=function(t){function n(e,n){var r,i,s,o=this;return(o=t.call(this,e,n)||this).userIdsFilter=null,o.metaDataKeyFilter=null,o.metaDataValuesFilter=null,o.nicknameStartsWithFilter=null,o.userIdsFilter=null!==(r=n.userIdsFilter)&&void 0!==r?r:null,o.metaDataKeyFilter=null!==(i=n.metaDataKeyFilter)&&void 0!==i?i:null,o.metaDataValuesFilter=null!==(s=n.metaDataValuesFilter)&&void 0!==s?s:null,o.nicknameStartsWithFilter=n.nicknameStartsWithFilter||null,o}return e(n,t),n.prototype._validate=function(){return t.prototype._validate.call(this)&&W("string",this.userIdsFilter,!0)&&c("string",this.metaDataKeyFilter,!0)&&W("string",this.metaDataValuesFilter,!0)&&c("string",this.metaDataKeyFilter,!0)},n.prototype.next=function(){return p(this,void 0,void 0,(function(){var e,t,n,r,i,s;return v(this,(function(o){switch(o.label){case 0:return this._validate()?this._isLoading?[3,3]:this._hasNext?(this._isLoading=!0,e=E.of(this._iid).requestQueue,t=new Cn(g(g({},this),{token:this._token})),[4,e.send(t)]):[3,2]:[3,5];case 1:return n=o.sent(),r=n.as(An),i=r.users,s=r.next,this._token=s,this._hasNext=!!s,this._isLoading=!1,[2,i];case 2:return[2,[]];case 3:throw y.queryInProgress;case 4:return[3,6];case 5:throw y.invalidParameters;case 6:return[2]}}))}))},n}(Y),xn=function(n){function r(e){var r=e.userId,i=e.limit,s=e.token,o=e.userIdsFilter,a=n.call(this)||this;return a.method=t.GET,a.path="".concat(V,"/").concat(r,"/block"),a.params=u({limit:i,token:s,user_ids:o}),a}return e(r,n),r}(r),Pn=function(t){function n(e,n){var r=t.call(this,e,n)||this;return r.users=n.users.map((function(t){return new w(e,t)})),r.next=n.next,r}return e(n,t),n}(s),Rn=function(t){function n(e,n){var r,i=this;return(i=t.call(this,e,n)||this).userIdsFilter=null,i.userIdsFilter=null!==(r=n.userIdsFilter)&&void 0!==r?r:null,i}return e(n,t),n.prototype._validate=function(){return t.prototype._validate.call(this)&&W("string",this.userIdsFilter,!0)},n.prototype.next=function(){return p(this,void 0,void 0,(function(){var e,t,n,r,i,s,o,a;return v(this,(function(u){switch(u.label){case 0:return this._validate()?this._isLoading?[3,3]:this._hasNext?(this._isLoading=!0,e=E.of(this._iid),t=e.sdkState,n=e.requestQueue,r=new xn(g(g({},this),{userId:t.userId,token:this._token})),[4,n.send(r)]):[3,2]:[3,5];case 1:return i=u.sent(),s=i.as(Pn),o=s.users,a=s.next,this._token=a,this._hasNext=!!a,this._isLoading=!1,[2,o];case 2:return[2,[]];case 3:throw y.queryInProgress;case 4:return[3,6];case 5:throw y.invalidParameters;case 6:return[2]}}))}))},n}(Y),Dn=function(n){function r(e){var r=e.userId,i=e.limit,s=e.token,o=n.call(this)||this;return o.method=t.GET,o.path="".concat(V,"/").concat(encodeURIComponent(r),"/friends"),o.params={limit:i,token:s},o}return e(r,n),r}(r),Mn=function(t){function n(e,n){var r=t.call(this,e,n)||this;return r.hasMore=n.has_more,r.users=n.users.map((function(t){return new w(e,t)})),r.next=n.next,r}return e(n,t),n}(s),Un=function(t){function n(){return null!==t&&t.apply(this,arguments)||this}return e(n,t),n.prototype._validate=function(){return t.prototype._validate.call(this)},n.prototype.next=function(){return p(this,void 0,void 0,(function(){var e,t,n,r,i,s,o,a,u;return v(this,(function(c){switch(c.label){case 0:return this._validate()?this._isLoading?[3,3]:this._hasNext?(this._isLoading=!0,e=E.of(this._iid),t=e.sdkState,n=e.requestQueue,r=new Dn(g(g({},this),{userId:t.userId,token:this._token})),[4,n.send(r)]):[3,2]:[3,5];case 1:return i=c.sent(),s=i.as(Mn),o=s.users,a=s.hasMore,u=s.next,this._token=u,this._hasNext=a,this._isLoading=!1,[2,o];case 2:return[2,[]];case 3:throw y.queryInProgress;case 4:return[3,6];case 5:throw y.invalidParameters;case 6:return[2]}}))}))},n}(Y),qn={},Fn=function(){function e(e){var t=e.dbname,n=e.itemSizeLimit,r=void 0===n?1048576:n,i=e.cacheLimit,s=void 0===i?256:i,o=e.blockHashBase,a=void 0===o?2:o,u=e.blockHashMultiplier,c=void 0===u?10:u,l=e.blockHashConstant,h=void 0===l?11:l,d=e.transactionApplyDelay,f=void 0===d?200:d,p=e.disableLogger,v=void 0!==p&&p;return qn[t]||(this.itemSizeLimit=r,this.cacheLimit=s,this.blockHashBase=a,this.blockHashMultiplier=c,this.blockHashConstant=h,this.transactionApplyDelay=f,this.disableLogger=v,qn[t]=this),qn[t]}return e.get=function(e){return qn[e]},e}();!function(e){e[e.UNKNOWN_ERROR=6e7]="UNKNOWN_ERROR",e[e.STORE_NOT_DEFINED=61001e3]="STORE_NOT_DEFINED",e[e.STORE_NOT_AVAILABLE=61001001]="STORE_NOT_AVAILABLE",e[e.STORE_NOT_AVAILABLE_IN_PRIVATE_BROWSING=61001002]="STORE_NOT_AVAILABLE_IN_PRIVATE_BROWSING",e[e.STORE_IS_FULL=61001003]="STORE_IS_FULL",e[e.STORE_INVALID_KEY_TYPE=61002e3]="STORE_INVALID_KEY_TYPE",e[e.STORE_BROKEN_INTEGRITY=61002001]="STORE_BROKEN_INTEGRITY",e[e.STORE_BROKEN_BLOB=61002002]="STORE_BROKEN_BLOB",e[e.STORE_ENCRYPTION_INVALID=61002003]="STORE_ENCRYPTION_INVALID",e[e.STORE_ITEM_SIZE_LIMIT_EXCEEDED=61017e3]="STORE_ITEM_SIZE_LIMIT_EXCEEDED",e[e.STORE_READ_FAILED=61017001]="STORE_READ_FAILED",e[e.STORE_WRITE_FAILED=61017002]="STORE_WRITE_FAILED",e[e.DATABASE_SCHEMA_NOT_ON_UPGRADE=62002e3]="DATABASE_SCHEMA_NOT_ON_UPGRADE",e[e.COLLECTION_NOT_READY=63001e3]="COLLECTION_NOT_READY",e[e.COLLECTION_KEY_NOT_MATCH=63002e3]="COLLECTION_KEY_NOT_MATCH",e[e.COLLECTION_QUERY_NOT_VALID=63002001]="COLLECTION_QUERY_NOT_VALID",e[e.COLLECTION_KEY_NOT_FOUND=63004e3]="COLLECTION_KEY_NOT_FOUND",e[e.COLLECTION_KEY_NOT_GIVEN=63004001]="COLLECTION_KEY_NOT_GIVEN",e[e.COLLECTION_INSERT_DUPLICATE=63009e3]="COLLECTION_INSERT_DUPLICATE",e[e.COLLECTION_WRITE_FAILED=63017e3]="COLLECTION_WRITE_FAILED",e[e.COLLECTION_ITEM_SIZE_LIMIT_EXCEEDED=63017001]="COLLECTION_ITEM_SIZE_LIMIT_EXCEEDED",e[e.INDEX_TABLE_IS_REQUIRED=65001e3]="INDEX_TABLE_IS_REQUIRED",e[e.INDEX_TYPE_NOT_MATCH=65002e3]="INDEX_TYPE_NOT_MATCH",e[e.COMPARE_TYPE_NOT_MATCH=69002001]="COMPARE_TYPE_NOT_MATCH",e[e.CIRCULAR_REFERENCE_FOUND=69002002]="CIRCULAR_REFERENCE_FOUND"}(gn||(gn={}));var Bn,Kn=function(t){function n(e){var r=e.code,i=void 0===r?gn.UNKNOWN_ERROR:r,s=e.message,o=void 0===s?"Unknown error occurred.":s,a=t.call(this,o)||this;return a.code=i,Object.setPrototypeOf(a,n.prototype),a}return e(n,t),Object.defineProperty(n,"storeNotDefined",{get:function(){return new n({code:gn.STORE_NOT_DEFINED,message:"Store is not defined. Specify the store on NestDB()"})},enumerable:!1,configurable:!0}),Object.defineProperty(n,"storeNotAvailable",{get:function(){return new n({code:gn.STORE_NOT_AVAILABLE,message:"Store is not available. Check your environment settings."})},enumerable:!1,configurable:!0}),Object.defineProperty(n,"storeNotAvailableInPrivateBrowsing",{get:function(){return new n({code:gn.STORE_NOT_AVAILABLE_IN_PRIVATE_BROWSING,message:"Store is not available because it is in private browsing."})},enumerable:!1,configurable:!0}),Object.defineProperty(n,"storeIsFull",{get:function(){return new n({code:gn.STORE_IS_FULL,message:"Store is full."})},enumerable:!1,configurable:!0}),Object.defineProperty(n,"storeKeyTypeIsInvalid",{get:function(){return new n({code:gn.STORE_INVALID_KEY_TYPE,message:"Store key should be string type."})},enumerable:!1,configurable:!0}),Object.defineProperty(n,"storeBrokenIntegrity",{get:function(){return new n({code:gn.STORE_BROKEN_INTEGRITY,message:"Data should be in a store but it does not. Integrity is broken."})},enumerable:!1,configurable:!0}),Object.defineProperty(n,"storeBrokenBlob",{get:function(){return new n({code:gn.STORE_BROKEN_BLOB,message:"Data should be in a store but it does not. Blob data is broken."})},enumerable:!1,configurable:!0}),Object.defineProperty(n,"storeEncryptionInvalid",{get:function(){return new n({code:gn.STORE_ENCRYPTION_INVALID,message:"Encryption algorithm has changed. All the store should reset."})},enumerable:!1,configurable:!0}),Object.defineProperty(n,"storeItemSizeExceeded",{get:function(){return new n({code:gn.STORE_ITEM_SIZE_LIMIT_EXCEEDED,message:"The size of the item exceeds the limit that the store allows."})},enumerable:!1,configurable:!0}),Object.defineProperty(n,"storeReadFailed",{get:function(){return new n({code:gn.STORE_READ_FAILED,message:"Failed to read from store."})},enumerable:!1,configurable:!0}),Object.defineProperty(n,"storeWriteFailed",{get:function(){return new n({code:gn.STORE_WRITE_FAILED,message:"Failed to write to store."})},enumerable:!1,configurable:!0}),Object.defineProperty(n,"databaseSchemaNotOnUpgrade",{get:function(){return new n({code:gn.DATABASE_SCHEMA_NOT_ON_UPGRADE,message:"Committing schema is not allowed when upgrade is not running."})},enumerable:!1,configurable:!0}),Object.defineProperty(n,"collectionNotReady",{get:function(){return new n({code:gn.COLLECTION_NOT_READY,message:"Collection is not ready due to an error during initialization."})},enumerable:!1,configurable:!0}),Object.defineProperty(n,"collectionKeyNotMatch",{get:function(){return new n({code:gn.COLLECTION_KEY_NOT_MATCH,message:"keyName of collection could not change."})},enumerable:!1,configurable:!0}),Object.defineProperty(n,"collectionQueryNotValid",{get:function(){return new n({code:gn.COLLECTION_QUERY_NOT_VALID,message:"Query parameter is not a valid format."})},enumerable:!1,configurable:!0}),Object.defineProperty(n,"collectionInsertDuplicate",{get:function(){return new n({code:gn.COLLECTION_INSERT_DUPLICATE,message:"The key already exists."})},enumerable:!1,configurable:!0}),Object.defineProperty(n,"collectionKeyNotFound",{get:function(){return new n({code:gn.COLLECTION_KEY_NOT_FOUND,message:"The key is not found."})},enumerable:!1,configurable:!0}),Object.defineProperty(n,"collectionKeyNotGiven",{get:function(){return new n({code:gn.COLLECTION_KEY_NOT_GIVEN,message:"The item should contain [keyName] property."})},enumerable:!1,configurable:!0}),Object.defineProperty(n,"collectionWriteFailed",{get:function(){return new n({code:gn.COLLECTION_WRITE_FAILED,message:"Failed to write an item."})},enumerable:!1,configurable:!0}),Object.defineProperty(n,"collectionItemSizeExceeded",{get:function(){return new n({code:gn.COLLECTION_ITEM_SIZE_LIMIT_EXCEEDED,message:"The size of the item exceeds the limit that a collection allows."})},enumerable:!1,configurable:!0}),Object.defineProperty(n,"indexTableIsRequired",{get:function(){return new n({code:gn.INDEX_TABLE_IS_REQUIRED,message:"Index table is required."})},enumerable:!1,configurable:!0}),Object.defineProperty(n,"indexTypesNotMatch",{get:function(){return new n({code:gn.INDEX_TYPE_NOT_MATCH,message:"Indexed column should have primitive type."})},enumerable:!1,configurable:!0}),Object.defineProperty(n,"compareTypesNotMatch",{get:function(){return new n({code:gn.COMPARE_TYPE_NOT_MATCH,message:"Values to compare have different types."})},enumerable:!1,configurable:!0}),Object.defineProperty(n,"circularReferenceFound",{get:function(){return new n({code:gn.CIRCULAR_REFERENCE_FOUND,message:"Cannot handle circular referenced object."})},enumerable:!1,configurable:!0}),n}(Error);!function(e){e.INIT="init",e.READY="ready",e.CLOSED="closed"}(Bn||(Bn={}));var jn,Hn=function(e,t){if(void 0===t&&(t=new WeakMap),"object"==typeof e&&null!==e){if(t.has(e))throw Kn.circularReferenceFound;t.set(e,!0);var n=null;if(Array.isArray(e))n=e.map((function(e){return Hn(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]=Hn(e[r],t);return t.delete(e),n}return e},zn=function(e,t){if(null==t)return 1;if(null==e)return-1;if(typeof e!=typeof t)throw Kn.compareTypesNotMatch;var n=0;switch(typeof e){case"boolean":case"number":n=e-t;break;case"string":n=e.localeCompare(t)}return n},Vn=function(e,t){for(var n=0,r=0;r>>0)%t},Qn=function(e){return new Promise((function(t){setTimeout((function(){return t()}),e)}))},Gn=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!Gn(e,t)})))return!1}else if(["/or","||"].includes(n)){if(e[n].every((function(e){return!Gn(e,t)})))return!1}else if("/where"===n){if(!(0,e[n])(t))return!1}else{var r=n;if("object"==typeof e[r]){var i=e[r];for(var s in i)switch(s){case"/eq":case"=":if((o=t[r])!==(a=i[s]))return!1;break;case"/neq":case"!=":if((o=t[r])===(a=i[s]))return!1;break;case"/gt":case">":var o=t[r],a=i[s];if(!(zn(o,a)>0))return!1;break;case"/gte":case">=":o=t[r],a=i[s];if(!(zn(o,a)>=0))return!1;break;case"/lt":case"<":o=t[r],a=i[s];if(!(zn(o,a)<0))return!1;break;case"/lte":case"<=":o=t[r],a=i[s];if(!(zn(o,a)<=0))return!1;break;case"/in":o=t[r];if(!(a=i[s]).includes(o))return!1;break;case"/nin":o=t[r];if((a=i[s]).includes(o))return!1;break;case"/contain":o=t[r],a=i[s];if(!o.includes(a))return!1;break;case"/regex":o=t[r];if(!(a=i[s]).test(o))return!1;break;case"/where":o=t[r];if(!(0,i[s])(o))return!1}}else if("function"==typeof e[r]){if(!e[r](t[r]))return!1}else if(e[r]!==t[r])return!1}}return!0}return e(t)},Wn=function(){},Yn=function(){return Promise.resolve()},Jn=function(e){return e},Xn=function(e,t){t(null)};!function(e){e[e.FORWARD=0]="FORWARD",e[e.BACKWARD=1]="BACKWARD"}(jn||(jn={}));var Zn,$n,er,tr=function(){function e(e){var t=e.initialPrevValue,n=void 0===t?null:t,r=e.initialNextValue,i=void 0===r?null:r,s=e.iterator,o=e.map,a=void 0===o?Jn:o,u=e.backward,c=void 0===u?Yn:u,l=e.forward,h=void 0===l?Yn:l,d=e.complete,f=void 0===d?Wn:d;this._prevValue=n,this._nextValue=i,this._error=null,this._map=a,this._backward=c,this._forward=h,this._iterator=s,this._complete=f}return Object.defineProperty(e.prototype,"prevValue",{get:function(){return this._map(this._prevValue)},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"nextValue",{get:function(){return this._map(this._nextValue)},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"error",{get:function(){return this._error},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"hasPrevious",{get:function(){return!!this._prevValue},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"hasNext",{get:function(){return!!this._nextValue},enumerable:!1,configurable:!0}),e.prototype.prev=function(){return p(this,void 0,void 0,(function(){var e,t,n;return v(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 p(this,void 0,void 0,(function(){var e,t,n;return v(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}(),nr=function(){function e(e){var t=e.condition,n=void 0===t?{}:t,r=e.backward,i=void 0!==r&&r,s=e.blockManager,o=e.indexer;this.condition=n,this.backward=i,this._blockManager=s,this._indexer=o}return e.prototype.findOptimizedStartPosition=function(){var e=this,t=["=","/eq",">",">=","/gt","/gte"],n=["=","/eq","<","<=","/lt","/lte"];if(this.backward){var r=this._indexer.origin.length-1;if("function"!=typeof this.condition)for(var i in this._indexer.fields){var s=this._indexer.fields[i],o=1;if("-"===s[0]&&(s=s.slice(1),o=-1),this.condition[s])if("object"==typeof this.condition[s]){var a=o>0?n:t;for(var u in this.condition[s])if(a.includes(u))for(var c=r;c>=0;c--)if(o*zn(this._indexer.origin[c].columnValues[i],this.condition[s][u])<=0){r=c;break}}else for(c=r;c>=0;c--)if(o*zn(this._indexer.origin[c].columnValues[i],this.condition[s])<=0){r=c;break}}return Math.min(r+1,this._indexer.origin.length-1)}var l=0;if("function"!=typeof this.condition)for(var h=function(r){var i=d._indexer.fields[r],s=1;if("-"===i[0]&&(i=i.slice(1),s=-1),d.condition[i])if("object"==typeof d.condition[i])Object.keys(d.condition[i]).forEach((function(o){if((s>0?t:n).includes(o))for(var a=l;a=0){l=a;break}}));else for(var o=l;o=0){l=o;break}},d=this,i=0;i0){for(var r=Math.ceil(e.data.length/n),i="".concat(r,".").concat(e.type,".").concat(t),s=[],o=0;o0))return[3,6];o=0,c.label=1;case 1:return o0))return[3,2];for(s=0;s-1){var r=this._items[n];return t===er.PERSISTENT&&(r.state=$n.PERSISTENT),t!==er.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)hr.includes(this._items[r].state)&&hr.includes(e.state)?(this._items.splice(r,1),this._items.push(e)):(this._items[r].state=e.state,this._items[r].generation=e.generation,this._items[r].value=e.value);else{this._items.push(e);var i=this._items.filter((function(e){return e.state===$n.VOLATILE})),s=i.length-this._limit;if(s>0){var o=[];try{for(var a=D(this._items),u=a.next();!u.done;u=a.next()){var c=u.value;c.state===$n.VOLATILE&&s>0?s--:o.push(c)}}catch(e){t={error:e}}finally{try{u&&!u.done&&(n=a.return)&&n.call(a)}finally{if(t)throw t.error}}this._items=o}}}},e.prototype.remove=function(e){var t=this._items.map((function(e){return e.key})).indexOf(e);t>-1&&this._items.splice(t,1)},e.prototype.clearByCondition=function(e){this._items=this._items.filter((function(t){return!e(t)}))},e.prototype.clear=function(e){void 0===e&&(e=!1),this._items=e?[]:this._items.filter((function(e){return e.state!==$n.VOLATILE}))},e}(),pr=function(){function e(e){var t=e.dbname,n=e.collectionName,r=e.store;this._metadata=null,this._requests=[],this._onCommit=new Map,this._onWrite=new Map,this._onError=new Map,this.dbname=t,this.collectionName=n,this.metadataKey=function(e,t){return"".concat(sr(e,t),"/trans.metadata")}(t,n),this.recordsetKey=function(e,t){return"".concat(sr(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=[]),p(this,void 0,void 0,(function(){var t;return v(this,(function(n){switch(n.label){case 0:return[4,this._store.get(this.recordsetKey)];case 1:return(t=n.sent()||[]).push.apply(t,X([],J(e),!1)),[2,this._reduceRecordSet(t)]}}))}))},e.prototype._reduceRecordSet=function(e){for(var t=[],n={},r=e.length-1;r>=0;r--){for(var i=e[r],s=[],o=i.requests.length-1;o>=0;o--){var a=i.requests[o],u=a.data;n[u.key]||(s.unshift(a),n[u.key]=!0)}s.length>0&&(i.requests=s,t.unshift(i))}return t},e.prototype._applyRecord=function(e,t){return p(this,void 0,void 0,(function(){var n,r,i,s,o,a,u,c,l;return v(this,(function(h){switch(h.label){case 0:n=fr.get(this.dbname),r=t.generation,i=t.requests,s=null,h.label=1;case 1:return h.trys.push([1,3,,4]),[4,this._store.setMany(i.map((function(e){return g(g({},e.data),{generation:r})})))];case 2:for(o=h.sent(),a=0;a0))return[3,4];for(t=[],n={},a=e.length-1;a>=0;a--)r=e[a],c=r.data,n[c.key]||(n[c.key]=!0,t.unshift(r));return i={generation:this.generation,requests:t},[4,this._getReducedRecordset([i])];case 1:return s=f.sent(),[4,this._store.set({key:this.recordsetKey,value:s,generation:this.generation})];case 2:return f.sent(),this._metadata.generation++,[4,this._store.set({key:this.metadataKey,value:this._metadata,generation:1})];case 3:for(f.sent(),o=fr.get(this.dbname),a=0;a0?(r=this.createBlockId(e,n),[4,t.find(this._store,r)]):[3,4];case 2:if((i=o.sent())&&(s=vr.createFromCacheItem(i),s.getItemByKey(e)))return[2,s];o.label=3;case 3:return n--,[3,1];case 4:return[2,null]}}))}))},e.prototype.getFromBlock=function(e){return p(this,void 0,void 0,(function(){var t;return v(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 p(this,void 0,void 0,(function(){var n,r,i,s,o;return v(this,(function(a){switch(a.label){case 0:return n=Fn.get(this.dbname),r=this.createBlockId(e),i=Math.floor(this._store.itemSizeLimit/n.itemSizeLimit),[4,fr.get(this.dbname).find(this._store,r)];case 1:return s=a.sent(),(o=s?vr.createFromCacheItem(s):new vr({blockId:r,keyName:this.keyName,items:[],limit:i})).add(t)?(this._transaction.requestWrite({key:o.blockId,value:o.serialize()}),[2,!0]):[2,!1]}}))}))},e.prototype.removeFromBlock=function(e){return p(this,void 0,void 0,(function(){var t;return v(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 p(this,void 0,void 0,(function(){var e,t,n,r,i,s,o,a,u;return v(this,(function(c){switch(c.label){case 0:return e=ar(this.dbname,this.collectionName),[4,this._store.getAllKeys()];case 1:return t=c.sent(),n=t.filter((function(t){return t.startsWith(e)})),[4,this._store.removeMany(n)];case 2:c.sent(),r=fr.get(this.dbname);try{for(i=D(n),s=i.next();!s.done;s=i.next())o=s.value,r.remove(o)}catch(e){a={error:e}}finally{try{s&&!s.done&&(u=i.return)&&u.call(i)}finally{if(a)throw a.error}}return[2]}}))}))},e}(),mr=function(){function e(e){var t=e.dbname,n=e.collectionName,r=e.keyName,i=e.fields,s=e.transaction,o=e.store,a=this;this._origin=[],this._table=[],this.dbname=t,this.collectionName=n,this.keyName=r,this.fields=i,this.indexerKey=function(e,t,n){return"".concat(sr(e,t),"/index.").concat(n)}(this.dbname,this.collectionName,this.fields.join(">")),this._transaction=s,this._store=o,this._transaction.on(Zn.COMMIT,this.indexerKey,(function(){return a.commit()})),this._transaction.on(Zn.ERROR,this.indexerKey,(function(){return a.abort()}))}return e.createKey=function(e){return e.join(">")},e.parseKey=function(e){return e.split(">")},e.prototype._addItem=function(e){var t=e[this.keyName],n=this.getColumnValues(e),r=J(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=J(this.indexOf(n),2),i=r[0];if(r[1]){var s=this._table[i].keys.indexOf(t);if(s>-1)return this._table[i].keys.splice(s,1),0===this._table[i].keys.length&&this._table.splice(i,1),!0}return!1},Object.defineProperty(e.prototype,"origin",{get:function(){return this._origin},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"table",{get:function(){return this._table},enumerable:!1,configurable:!0}),e.prototype.getColumnValues=function(e){var t,n,r,i,s=[];try{for(var o=D(this.fields),a=o.next();!a.done;a=o.next()){var u=a.value;if("-"===u[0]&&(u=u.slice(1)),r=e[u],i=void 0,i=typeof r,null!==r&&"undefined"!==i&&"boolean"!==i&&"number"!==i&&"string"!==i)throw Kn.indexTypesNotMatch;s.push(e[u])}}catch(e){t={error:e}}finally{try{a&&!a.done&&(n=o.return)&&n.call(o)}finally{if(t)throw t.error}}return s},e.prototype.diff=function(e,t){for(var n in this.fields){var r="-"===this.fields[n][0]?-1:1,i=zn(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 p(this,void 0,void 0,(function(){var e,t,n,r,i,s,o,a,u,c,l,h,d,f,p,_,m;return v(this,(function(v){switch(v.label){case 0:return[4,(e=fr.get(this.dbname)).find(this._store,this.indexerKey,er.PERSISTENT)];case 1:return(t=v.sent())?[3,11]:(n=ar(this.dbname,this.collectionName),[4,this._store.getAllKeys()]);case 2:r=v.sent(),v.label=3;case 3:v.trys.push([3,8,9,10]),i=D(r),s=i.next(),v.label=4;case 4:return s.done?[3,7]:(o=s.value).startsWith(n)?[4,e.find(this._store,o,er.NO_CACHE)]:[3,6];case 5:a=v.sent(),u=vr.createFromCacheItem(a);try{for(_=void 0,c=D(u.items),l=c.next();!l.done;l=c.next())h=l.value,this._addItem(h)}catch(e){_={error:e}}finally{try{l&&!l.done&&(m=c.return)&&m.call(c)}finally{if(_)throw _.error}}v.label=6;case 6:return s=i.next(),[3,4];case 7:return[3,10];case 8:return d=v.sent(),f={error:d},[3,10];case 9:try{s&&!s.done&&(p=i.return)&&p.call(i)}finally{if(f)throw f.error}return[7];case 10:return this._transaction.requestWrite({key:this.indexerKey,value:this._table},{persistent:!0}),[3,12];case 11:this._origin=t.value,this._table=Hn(this._origin),v.label=12;case 12:return[2]}}))}))},e.prototype.drop=function(){return p(this,void 0,void 0,(function(){return v(this,(function(e){switch(e.label){case 0:return fr.get(this.dbname).remove(this.indexerKey),[4,this._store.remove(this.indexerKey)];case 1:return e.sent(),[2]}}))}))},e.prototype.addItem=function(e){return p(this,void 0,void 0,(function(){return v(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 p(this,void 0,void 0,(function(){return v(this,(function(t){return this._removeItem(e)&&this._transaction.requestWrite({key:this.indexerKey,value:this._table},{persistent:!0}),[2]}))}))},e.prototype.clear=function(){return p(this,void 0,void 0,(function(){return v(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=Hn(this._origin)},e.prototype.abort=function(){this._table=Hn(this._origin)},e}(),yr="undefined"!=typeof document&&"undefined"!=typeof navigator;yr&&navigator.userAgent&&navigator.userAgent.includes("Chrome/")&&navigator.userAgent.includes("Chromium/");var gr=yr&&navigator.userAgent&&navigator.userAgent.includes("Firefox/")&&!navigator.userAgent.includes("Seamonkey/");yr&&navigator.userAgent&&navigator.userAgent.includes("Safari/")&&!navigator.userAgent.includes("Chrome/")&&navigator.userAgent.includes("Chromium/"),yr&&navigator.userAgent&&(navigator.userAgent.includes("OPR/")||navigator.userAgent.includes("Opera/")),yr&&navigator.userAgent&&navigator.userAgent.includes("Trident/7.0");var br,Ir,Er=yr&&navigator.userAgent&&navigator.userAgent.includes("Edge/"),wr=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"}(br||(br={})),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"}(Ir||(Ir={}));var kr,Nr={},Sr=function(){function e(e,t){void 0===t&&(t={});var n=this;return this._state=br.PROCESSING,this._hostId=null,this._queue=[],this._currentItem=null,this._activationTimeout=null,this._activationQueue=[],Nr[e]&&!t.forceCreate||(this.nodeId=wr(),this.key=e,yr&&(t.startAsInvisible?this.registerNode():"visible"===document.visibilityState?this.claimHost():this.registerNode(),document.addEventListener("visibilitychange",(function(){"visible"===document.visibilityState&&n.claimHost()})),window.addEventListener("message",(function(e){var t,r,i=e.data,s=i.nodeId,o=i.requestId,a=i.key,u=i.op,c=i.data;if(s!==n.nodeId&&a===n.key)switch(u){case Ir.NEWNODE:n._sendSync();break;case Ir.CLAIM_HOST:n._sendSync(),n._hostId=s;break;case Ir.SYNC_HOST:if(!n.isInSync){n._activationTimeout&&clearTimeout(n._activationTimeout);var l=c,h=l.currentItemRequestId,d=l.queue,f=function(e){var t=n._queue.findIndex((function(t){return t.requestId===e.requestId}));t<0&&n._requestLock({nodeId:e.nodeId,requestId:e.requestId,key:n.key,op:Ir.REQUEST_LOCK,ts:e.ts})};try{for(var p=D(d),v=p.next();!v.done;v=p.next()){f(v.value)}}catch(e){t={error:e}}finally{try{v&&!v.done&&(r=p.return)&&r.call(p)}finally{if(t)throw t.error}}n._currentItem=n._queue.find((function(e){return e.requestId===h})),n._completeSync()}break;case Ir.REMOVENODE:n._queue=n._queue.filter((function(e){return e.nodeId!==i.nodeId})),n._currentItem&&n._currentItem.nodeId===i.nodeId&&(n._currentItem=null,n._acquire(n._queue[0]));break;case Ir.REQUEST_LOCK:n._requestLock(i);break;case Ir.ACQUIRE_LOCK:var _=n._queue.find((function(e){return e.requestId===o}));n._acquire(_);break;case Ir.RELEASE_LOCK:n._release(o)}})),window.addEventListener("beforeunload",(function(){n._send(Ir.REMOVENODE)}))),Nr[e]=this),Nr[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==br.DONE},enumerable:!1,configurable:!0}),e.prototype._send=function(e,t){var n,r;void 0===t&&(t={});var i={nodeId:this.nodeId,requestId:null!==(n=null==t?void 0:t.requestId)&&void 0!==n?n:wr(),key:this.key,op:e,data:null!==(r=t.data)&&void 0!==r?r:null,ts:Date.now()};return yr&&window.postMessage(i,"*"),i},e.prototype._acquire=function(e){void 0===e&&(e=null),e?(this._currentItem=e,this._currentItem.onAcquired(e.requestId)):this._currentItem=null},e.prototype._release=function(e){if(this._currentItem&&this._currentItem.requestId===e){var t=this._currentItem;this._currentItem=null,t.nodeId===this.nodeId&&this._send(Ir.RELEASE_LOCK,{requestId:t.requestId});var n=this._queue.findIndex((function(t){return t.requestId===e}));n>-1&&this._queue.splice(n,1),t.onReleased(e)}},e.prototype._requestLock=function(e){var t=this;return new Promise((function(n){var r={nodeId:e.nodeId,requestId:e.requestId,ts:e.ts,onAcquired:function(e){t.isHost&&t._send(Ir.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(Ir.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 p(this,void 0,void 0,(function(){var e=this;return v(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=br.DONE,this._activationQueue.forEach((function(e){return e()})),this._activationQueue=[])},e.prototype.registerNode=function(){this._send(Ir.NEWNODE),this._waitSync()},e.prototype.claimHost=function(){this._hostId=this.nodeId,this._send(Ir.CLAIM_HOST),this._waitSync()},e.prototype.lock=function(){return p(this,void 0,void 0,(function(){var e;return v(this,(function(t){switch(t.label){case 0:return[4,this._waitUntilSyncCompleted()];case 1:return t.sent(),e=this._send(Ir.REQUEST_LOCK),[4,this._requestLock(e)];case 2:return t.sent(),[2]}}))}))},e.prototype.unlock=function(){var e;this._release(null===(e=this._currentItem)||void 0===e?void 0:e.requestId)},e}(),Tr=function(){function e(e){var t=e.dbname,n=e.collectionName,r=e.keyName,i=e.keyHash,s=e.indexes,o=e.store,a=this;this._state=Bn.INIT,this._metadata=null,this._indexers=[],this.dbname=t,this.name=n,this.keyName=r,this.indexes=X([[r]],J(s.filter((function(e){return mr.createKey(e)!==a.keyName}))),!1),this._keyHash=i,this._store=o,this._mutex=new Sr(function(e,t){return"".concat(sr(e,t),".lock")}(t,n)),this._blobContainer=new lr({dbname:t,collectionName:n,store:o}),this._transaction=new pr({dbname:t,collectionName:n,store:o})}return e.metadataOf=function(e,t,n){return p(this,void 0,void 0,(function(){var r;return v(this,(function(i){switch(i.label){case 0:return r=or(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===Bn.READY},enumerable:!1,configurable:!0}),e.prototype.init=function(){return p(this,void 0,void 0,(function(){var t,n,r,i,s,o,a,u,c,l,h,d,f,p,_=this;return v(this,(function(v){switch(v.label){case 0:return[4,this._mutex.lock()];case 1:v.sent(),v.label=2;case 2:return v.trys.push([2,9,,10]),t=Fn.get(this.dbname),[4,e.metadataOf(this.dbname,this.name,this._store)];case 3:return n=v.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:v.sent(),this._blockManager=new _r({dbname:this.dbname,collectionName:this.name,hashFunction:this._keyHash,metadata:this._metadata,transaction:this._transaction,store:this._store}),r=X([],J(this.indexes),!1),i=[],s=r.map((function(e){return mr.createKey(e)})),o=n?n.indexes.map((function(e){return mr.createKey(e)})):[];try{for(a=D(o),u=a.next();!u.done;u=a.next())c=u.value,s.includes(c)||i.push(mr.parseKey(c))}catch(e){f={error:e}}finally{try{u&&!u.done&&(p=a.return)&&p.call(a)}finally{if(f)throw f.error}}return(l=[]).push.apply(l,X([],J(r.map((function(e){var t=new mr({dbname:_.dbname,collectionName:_.name,keyName:_.keyName,fields:e,transaction:_._transaction,store:_._store});return _._indexers.push(t),t.ensure()}))),!1)),l.push.apply(l,X([],J(i.map((function(e){return new mr({dbname:_.dbname,collectionName:_.name,keyName:_.keyName,fields:e,transaction:_._transaction,store:_._store}).drop()}))),!1)),[4,Promise.all(l)];case 5:return v.sent(),[4,this._transaction.commit()];case 6:return v.sent(),s.sort().join(",")===o.sort().join(",")?[3,8]:(h=or(this.dbname,this.name),this._metadata.indexes=r,[4,this._store.set({key:h,value:this._metadata,generation:1})]);case 7:v.sent(),v.label=8;case 8:return this._state=Bn.READY,this._mutex.unlock(),[3,10];case 9:throw d=v.sent(),this._mutex.unlock(),d;case 10:return[2]}}))}))},e.prototype.close=function(){this._state=Bn.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=mr.createKey(e);try{for(var i=D(this._indexers),s=i.next();!s.done;s=i.next()){var o=s.value;if(r===mr.createKey(o.fields))return o}}catch(e){t={error:e}}finally{try{s&&!s.done&&(n=i.return)&&n.call(i)}finally{if(t)throw t.error}}return null},e.prototype._upgradeBlockLevel=function(){return p(this,void 0,void 0,(function(){var e;return v(this,(function(t){switch(t.label){case 0:return e=or(this.dbname,this.name),this._metadata.blockLevel++,[4,this._store.set({key:e,value:this._metadata,generation:1})];case 1:return t.sent(),[2]}}))}))},e.prototype._requestInsert=function(e){return p(this,void 0,void 0,(function(){var t,n,r,i,s,o;return v(this,(function(a){switch(a.label){case 0:return t=e[this.keyName],[4,this._blockManager.getFromBlock(t)];case 1:return a.sent()?[3,13]:[4,this._blockManager.putToBlock(t,e)];case 2:return a.sent()?[3,5]:[4,this._upgradeBlockLevel()];case 3:return a.sent(),[4,this._blockManager.putToBlock(t,e)];case 4:a.sent(),a.label=5;case 5:a.trys.push([5,10,11,12]),n=D(this._indexers),r=n.next(),a.label=6;case 6:return r.done?[3,9]:[4,r.value.addItem(e)];case 7:a.sent(),a.label=8;case 8:return r=n.next(),[3,6];case 9:return[3,12];case 10:return i=a.sent(),s={error:i},[3,12];case 11:try{r&&!r.done&&(o=n.return)&&o.call(n)}finally{if(s)throw s.error}return[7];case 12:return[3,14];case 13:throw Kn.collectionInsertDuplicate;case 14:return[2]}}))}))},e.prototype._requestUpsert=function(e){return p(this,void 0,void 0,(function(){var t,n,r,i,s,o,a,u,c,l,h,d,f;return v(this,(function(p){switch(p.label){case 0:return t=e[this.keyName],[4,this._blockManager.getFromBlock(t)];case 1:return(n=p.sent())?[3,13]:[4,this._blockManager.putToBlock(t,e)];case 2:return p.sent()?[3,5]:[4,this._upgradeBlockLevel()];case 3:return p.sent(),[4,this._blockManager.putToBlock(t,e)];case 4:p.sent(),p.label=5;case 5:p.trys.push([5,10,11,12]),r=D(this._indexers),i=r.next(),p.label=6;case 6:return i.done?[3,9]:[4,(u=i.value).addItem(e)];case 7:p.sent(),p.label=8;case 8:return i=r.next(),[3,6];case 9:return[3,12];case 10:return s=p.sent(),l={error:s},[3,12];case 11:try{i&&!i.done&&(h=r.return)&&h.call(r)}finally{if(l)throw l.error}return[7];case 12:return[3,23];case 13:return[4,this._blockManager.putToBlock(t,e)];case 14:p.sent(),p.label=15;case 15:p.trys.push([15,21,22,23]),o=D(this._indexers),a=o.next(),p.label=16;case 16:return a.done?[3,20]:0===(u=a.value).diff(u.getColumnValues(n),u.getColumnValues(e))?[3,19]:[4,u.removeItem(n)];case 17:return p.sent(),[4,u.addItem(e)];case 18:p.sent(),p.label=19;case 19:return a=o.next(),[3,16];case 20:return[3,23];case 21:return c=p.sent(),d={error:c},[3,23];case 22:try{a&&!a.done&&(f=o.return)&&f.call(o)}finally{if(d)throw d.error}return[7];case 23:return[2]}}))}))},e.prototype._requestUpdate=function(e){return p(this,void 0,void 0,(function(){var t,n,r,i,s,o,a,u;return v(this,(function(c){switch(c.label){case 0:return t=e[this.keyName],[4,this._blockManager.getFromBlock(t)];case 1:return(n=c.sent())?[4,this._blockManager.putToBlock(t,e)]:[3,11];case 2:c.sent(),c.label=3;case 3:c.trys.push([3,9,10,11]),r=D(this._indexers),i=r.next(),c.label=4;case 4:return i.done?[3,8]:0===(s=i.value).diff(s.getColumnValues(n),s.getColumnValues(e))?[3,7]:[4,s.removeItem(n)];case 5:return c.sent(),[4,s.addItem(e)];case 6:c.sent(),c.label=7;case 7:return i=r.next(),[3,4];case 8:return[3,11];case 9:return o=c.sent(),a={error:o},[3,11];case 10:try{i&&!i.done&&(u=r.return)&&u.call(r)}finally{if(a)throw a.error}return[7];case 11:return[2]}}))}))},e.prototype._requestRemove=function(e){return p(this,void 0,void 0,(function(){var t,n,r,i,s,o;return v(this,(function(a){switch(a.label){case 0:return[4,this._blockManager.getFromBlock(e)];case 1:return(t=a.sent())?[4,this._blockManager.removeFromBlock(e)]:[3,10];case 2:a.sent(),a.label=3;case 3:a.trys.push([3,8,9,10]),n=D(this._indexers),r=n.next(),a.label=4;case 4:return r.done?[3,7]:[4,r.value.removeItem(t)];case 5:a.sent(),a.label=6;case 6:return r=n.next(),[3,4];case 7:return[3,10];case 8:return i=a.sent(),s={error:i},[3,10];case 9:try{r&&!r.done&&(o=n.return)&&o.call(n)}finally{if(s)throw s.error}return[7];case 10:return[2]}}))}))},e.prototype._requestClear=function(){return p(this,void 0,void 0,(function(){var e,t,n,r,i;return v(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=D(this._indexers),t=e.next(),s.label=3;case 3:return t.done?[3,6]:[4,t.value.clear()];case 4:s.sent(),s.label=5;case 5:return t=e.next(),[3,3];case 6:return[3,9];case 7:return n=s.sent(),r={error:n},[3,9];case 8:try{t&&!t.done&&(i=e.return)&&i.call(e)}finally{if(r)throw r.error}return[7];case 9:return[2]}}))}))},e.prototype.getByKey=function(e){return p(this,void 0,void 0,(function(){var t,n;return v(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,Hn(t)];case 4:throw n=r.sent(),this._mutex.unlock(),n;case 5:return[3,7];case 6:throw Kn.collectionNotReady;case 7:return[2]}}))}))},e.prototype.query=function(e){return void 0===e&&(e={}),this.isReady?new rr({condition:e.where,mutex:this._mutex,blockManager:this._blockManager,indexer:this._getIndexerBy(e.index),backward:!!e.backward}):null},e.prototype.insertOne=function(e){return p(this,void 0,void 0,(function(){var t;return v(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 Kn.collectionKeyNotGiven;return[4,this._requestInsert(Hn(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 Kn.collectionNotReady;case 9:return[2]}}))}))},e.prototype.insertMany=function(e){return p(this,void 0,void 0,(function(){var t,n,r,i,s,o,a,u=this;return v(this,(function(c){switch(c.label){case 0:return this.isReady?[4,this._mutex.lock()]:[3,15];case 1:c.sent(),c.label=2;case 2:if(c.trys.push([2,12,,14]),e.some((function(e){return!u._hasPropertyOfKeyName(e)})))throw Kn.collectionKeyNotGiven;c.label=3;case 3:c.trys.push([3,8,9,10]),t=D(e),n=t.next(),c.label=4;case 4:return n.done?[3,7]:(r=n.value,[4,this._requestInsert(Hn(r))]);case 5:c.sent(),c.label=6;case 6:return n=t.next(),[3,4];case 7:return[3,10];case 8:return i=c.sent(),o={error:i},[3,10];case 9:try{n&&!n.done&&(a=t.return)&&a.call(t)}finally{if(o)throw o.error}return[7];case 10:return[4,this._transaction.commit()];case 11:return c.sent(),this._mutex.unlock(),[2,e];case 12:return s=c.sent(),[4,this._transaction.clear()];case 13:throw c.sent(),this._mutex.unlock(),s;case 14:return[3,16];case 15:throw Kn.collectionNotReady;case 16:return[2]}}))}))},e.prototype.upsertOne=function(e){return p(this,void 0,void 0,(function(){var t;return v(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 Kn.collectionKeyNotGiven;return[4,this._requestUpsert(Hn(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 Kn.collectionNotReady;case 9:return[2]}}))}))},e.prototype.upsertMany=function(e){return p(this,void 0,void 0,(function(){var t,n,r,i,s,o,a,u=this;return v(this,(function(c){switch(c.label){case 0:return this.isReady?[4,this._mutex.lock()]:[3,15];case 1:c.sent(),c.label=2;case 2:if(c.trys.push([2,12,,14]),e.some((function(e){return!u._hasPropertyOfKeyName(e)})))throw Kn.collectionKeyNotGiven;c.label=3;case 3:c.trys.push([3,8,9,10]),t=D(e),n=t.next(),c.label=4;case 4:return n.done?[3,7]:(r=n.value,[4,this._requestUpsert(Hn(r))]);case 5:c.sent(),c.label=6;case 6:return n=t.next(),[3,4];case 7:return[3,10];case 8:return i=c.sent(),o={error:i},[3,10];case 9:try{n&&!n.done&&(a=t.return)&&a.call(t)}finally{if(o)throw o.error}return[7];case 10:return[4,this._transaction.commit()];case 11:return c.sent(),this._mutex.unlock(),[2,e];case 12:return s=c.sent(),[4,this._transaction.clear()];case 13:throw c.sent(),this._mutex.unlock(),s;case 14:return[3,16];case 15:throw Kn.collectionNotReady;case 16:return[2]}}))}))},e.prototype.update=function(e){return p(this,void 0,void 0,(function(){var t;return v(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 Kn.collectionKeyNotGiven;return[4,this._requestUpdate(Hn(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 Kn.collectionNotReady;case 9:return[2]}}))}))},e.prototype.updateIf=function(e,t){return p(this,void 0,void 0,(function(){var n,r,i,s,o,a,u,c,l,h,d,f,_,m,y=this;return v(this,(function(g){switch(g.label){case 0:return this.isReady?[4,this._mutex.lock()]:[3,16];case 1:g.sent(),g.label=2;case 2:return g.trys.push([2,13,,15]),n=e.where,r=void 0===n?{}:n,i=e.index,s=void 0===i?null:i,o=e.backward,a=void 0!==o&&o,u=[],[4,new nr({condition:r,blockManager:this._blockManager,backward:a,indexer:this._getIndexerBy(s)}).each((function(e){return p(y,void 0,void 0,(function(){var n,i;return v(this,(function(s){if(e.error)throw e.stop(),e.error;if(e.hasNext){if(n=e.nextValue,Gn(r,n)&&t.set){if("function"!=typeof t.set)for(i in t.set)n[i]=t.set[i];else t.set(n);u.push(n)}e.next()}else e.stop();return[2]}))}))}))];case 3:g.sent(),g.label=4;case 4:g.trys.push([4,9,10,11]),c=D(u),l=c.next(),g.label=5;case 5:return l.done?[3,8]:(h=l.value,[4,this._requestUpdate(Hn(h))]);case 6:g.sent(),g.label=7;case 7:return l=c.next(),[3,5];case 8:return[3,11];case 9:return d=g.sent(),_={error:d},[3,11];case 10:try{l&&!l.done&&(m=c.return)&&m.call(c)}finally{if(_)throw _.error}return[7];case 11:return[4,this._transaction.commit()];case 12:return g.sent(),this._mutex.unlock(),[2,u];case 13:return f=g.sent(),[4,this._transaction.clear()];case 14:throw g.sent(),this._mutex.unlock(),f;case 15:return[3,17];case 16:throw this._transaction.clear(),Kn.collectionNotReady;case 17:return[2]}}))}))},e.prototype.remove=function(e){return p(this,void 0,void 0,(function(){var t;return v(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 Kn.collectionNotReady;case 9:return[2]}}))}))},e.prototype.removeIf=function(e){return p(this,void 0,void 0,(function(){var t,n,r,i,s,o,a,u,c,l,h,d,f,_,m=this;return v(this,(function(y){switch(y.label){case 0:return this.isReady?[4,this._mutex.lock()]:[3,15];case 1:y.sent(),y.label=2;case 2:return y.trys.push([2,13,,14]),t=e.where,n=void 0===t?{}:t,r=e.index,i=void 0===r?null:r,s=e.backward,o=void 0!==s&&s,a=[],[4,new nr({condition:n,blockManager:this._blockManager,backward:o,indexer:this._getIndexerBy(i)}).each((function(e){return p(m,void 0,void 0,(function(){var t,r;return v(this,(function(i){if(e.error)throw e.stop(),e.error;return e.hasNext?(t=e.nextValue,Gn(n,t)&&(r=t[this.keyName],a.push(r)),e.next()):e.stop(),[2]}))}))}))];case 3:y.sent(),y.label=4;case 4:y.trys.push([4,9,10,11]),u=D(a),c=u.next(),y.label=5;case 5:return c.done?[3,8]:(l=c.value,[4,this._requestRemove(l)]);case 6:y.sent(),y.label=7;case 7:return c=u.next(),[3,5];case 8:return[3,11];case 9:return h=y.sent(),f={error:h},[3,11];case 10:try{c&&!c.done&&(_=u.return)&&_.call(u)}finally{if(f)throw f.error}return[7];case 11:return[4,this._transaction.commit()];case 12:return y.sent(),this._mutex.unlock(),[2,a];case 13:throw d=y.sent(),this._mutex.unlock(),d;case 14:return[3,16];case 15:throw this._transaction.clear(),Kn.collectionNotReady;case 16:return[2]}}))}))},e.prototype.clear=function(){return p(this,void 0,void 0,(function(){var e;return v(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 Kn.collectionNotReady;case 9:return[2]}}))}))},e.prototype.getBlob=function(e){return p(this,void 0,void 0,(function(){return v(this,(function(t){switch(t.label){case 0:return[4,this._blobContainer.get(e)];case 1:return[2,t.sent()]}}))}))},e.prototype.saveBlob=function(e,t){return void 0===t&&(t=null),p(this,void 0,void 0,(function(){return v(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 p(this,void 0,void 0,(function(){return v(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 p(this,void 0,void 0,(function(){return v(this,(function(e){switch(e.label){case 0:return[4,this._blobContainer.clear()];case 1:return e.sent(),[2]}}))}))},e}(),Or={},Cr=function(){function e(e){void 0===e&&(e={});var t=e.itemSizeLimit,n=void 0===t?4194304:t,r=e.delay,i=void 0===r?1:r,s=e.encryption,o=void 0===s?Z:s;this._encryption=o,this.itemSizeLimit=n,this.delay=i,this.observer={}}return Object.defineProperty(e.prototype,"rawData",{get:function(){return Or[this.dbname]},set:function(e){Or[this.dbname]=e},enumerable:!1,configurable:!0}),e.prototype.observe=function(e,t,n){var r=this;this.observer[e]={},t.forEach((function(t){return r.observer[e][t]=n}))},e.prototype.init=function(e){return p(this,void 0,void 0,(function(){var t;return v(this,(function(n){switch(n.label){case 0:this.dbname=e,Or[this.dbname]={},n.label=1;case 1:return n.trys.push([1,,3,5]),[4,this.get($.key)];case 2:if((t=n.sent())&&JSON.stringify(t)!==JSON.stringify($.value))throw Kn.storeEncryptionInvalid;return[3,5];case 3:return[4,this.set($)];case 4:return n.sent(),[7];case 5:return[2]}}))}))},e.prototype.getAllKeys=function(){return p(this,void 0,void 0,(function(){return v(this,(function(e){return[2,Object.keys(Or[this.dbname]).filter((function(e){return e!==$.key}))]}))}))},e.prototype.get=function(e){return p(this,void 0,void 0,(function(){var t;return v(this,(function(n){switch(n.label){case 0:return[4,this.getRaw(e)];case 1:return[2,(t=n.sent())?this._encryption.decrypt(t):null]}}))}))},e.prototype.getRaw=function(e){return p(this,void 0,void 0,(function(){var t,n;return v(this,(function(r){switch(r.label){case 0:return[4,Qn(this.delay)];case 1:if(r.sent(),t=this.observer[e],n=t&&t.get?t.get(e):null)throw n;return[2,Or[this.dbname][e]]}}))}))},e.prototype.set=function(e){return p(this,void 0,void 0,(function(){var t,n,r,i,s,o;return v(this,(function(a){switch(a.label){case 0:return[4,Qn(this.delay)];case 1:if(a.sent(),t=e.key,n=e.value,r=this.observer[t],i=r&&r.set?r.set(t):null)throw i;if(s=this._encryption.encrypt(n),o=JSON.stringify(s),t===$.key||o.lengtha.ts){if(a.all!==t.all&&(u=!0),a.all=t.all>=0?t.all:0,t.customTypes)for(var l in t.customTypes)a.customTypes[l]!==t.customTypes[l]&&(u=!0),a.customTypes[l]=t.customTypes[l];u=u&&a.ts>0,a.ts=c}u&&ue((function(){return p(r,void 0,void 0,(function(){return v(this,(function(e){return[2,h.forEach((function(e){e.onTotalUnreadMessageCountUpdated(a.all,a.customTypes)}))]}))}))}))}else t instanceof le&&o.localCacheEnabled&&o.preference.set(r._getUserProfileCacheKey(s.userId),he.payloadify(t.userProfile))}))}return e.init=function(t){var n=t.appId,r=t.appVersion,i=void 0===r?null:r,s=t.modules,o=void 0===s?[]:s,a=t.options,u=void 0===a?new ee:a,c=t.debugMode,l=void 0!==c&&c,h=t.customApiHost,d=t.customWebSocketHost,f=t.newInstance,p=void 0!==f&&f,v=t.logLevel,_=t.localCacheEnabled,m=void 0!==_&&_,y=t.localCacheEncryption,g=t.useAsyncStorageStore,b=void 0===g?null:g;if(!Dr||p){var I="su-".concat(te()),w=null!=y?y:{encrypt:function(e){return e},decrypt:function(e){return e}},k=new Cr({encryption:w});l||(k=b?new Lr({AsyncStorage:b,encryption:w}):new Ar({encryption:w})),new E(I,{appId:n,appVersion:i,options:u,apiHost:null!=h?h:"https://api-".concat(n,".sendbird.com"),websocketHost:null!=d?d:"wss://ws-".concat(n,".sendbird.com"),store:k,encryption:w,logLevel:v,localCacheEnabled:m,debugMode:l});var N=[new ne,new Ze],S=new e(I,u,X(X([],J(o),!1),J(N),!1));return Dr||(Dr=S),S}return Dr},Object.defineProperty(e,"instance",{get:function(){return Dr},enumerable:!1,configurable:!0}),Object.defineProperty(e,"version",{get:function(){return re},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"appId",{get:function(){return E.of(this._iid).sdkState.appId},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"appInfo",{get:function(){return E.of(this._iid).appInfo},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"appVersion",{get:function(){var e;return null!==(e=E.of(this._iid).sdkState.appVersion)&&void 0!==e?e:""},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"debugMode",{get:function(){return E.of(this._iid).debugMode},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"logLevel",{get:function(){return E.of(this._iid).logger.level},set:function(e){E.of(this._iid).logger.level=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"isCacheEnabled",{get:function(){return E.of(this._iid).cacheContext.localCacheEnabled},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"ekey",{get:function(){return ie(this._iid)},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"currentUser",{get:function(){var e;return null!==(e=E.of(this._iid).sessionManager.currentUser)&&void 0!==e?e:null},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"connectionState",{get:function(){var e=E.of(this._iid).connectionManager;return e.isConnected?se.OPEN:e.isConnecting?se.CONNECTING:se.CLOSED},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"lastConnectedAt",{get:function(){var e=E.of(this._iid),t=e.connectedAt;return e.connectionManager.isConnected?t:0},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"fcmPushToken",{get:function(){return this._fcmPushToken},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"apnsPushToken",{get:function(){return this._apnsPushToken},enumerable:!1,configurable:!0}),e.prototype._getPreferenceCacheKey=function(e){return"sendbird@".concat(this.appId,"/").concat(e,".pref")},e.prototype._getUserProfileCacheKey=function(e){return"sendbird@".concat(this.appId,"/").concat(e,".profile")},e.prototype.getMemoryStoreForDebugging=function(){var e=E.of(this._iid),t=e.debugMode,n=e.cacheContext;if(t)return n.store instanceof Cr?n.store:null;throw y.debugModeRequired},e.prototype.addExtension=function(e,t){var n=E.of(this._iid).sdkState;["sb_uikit","sb_syncmanager","device-os-platform"].indexOf(e)>-1&&(n.extensions[e]=t)},e.prototype.setOnlineListener=function(e){this._onlineDetector.setOnlineListener(e)},e.prototype.setOfflineListener=function(e){this._onlineDetector.setOfflineListener(e)},e.prototype.initializeCache=function(e){return p(this,void 0,void 0,(function(){var t,n,r,i,s,o,a,u;return v(this,(function(c){switch(c.label){case 0:return t=E.of(this._iid),n=t.sdkState,r=t.cacheContext,i=t.connectionManager,s=t.dispatcher,n.userId&&n.userId===e?[3,6]:[4,i.logout()];case 1:return c.sent(),n.userId=e,r.localCacheEnabled?(o="sendbird@".concat(n.appId,"/").concat(e,".db"),r.nestdb&&r.nestdb.state!==kr.CLOSED&&r.nestdb.name===o?[3,3]:((a=r.nestdb=new Rr({name:"sendbird@".concat(n.appId,"/").concat(e,".db"),version:1,store:r.store})).on("upgrade",function(e){return function(t,n){0===t?e.commitSchema([{collectionName:"GroupChannel",keyName:"url",index:[ct(Ne.LATEST_LAST_MESSAGE),ct(Ne.CHRONOLOGICAL),ct(Ne.CHANNEL_NAME_ALPHABETICAL)]},{collectionName:"Message",keyName:"messageId",index:[dt(ut.CHANNEL_LATEST),dt(ut.NEWEST_CHILD_MESSAGE)]},{collectionName:"UnsentMessage",keyName:"reqId",index:[dt(ut.CHANNEL_LATEST),dt(ut.NEWEST_CHILD_MESSAGE)]},{collectionName:"Poll",keyName:"pollId"}]).then((function(){return n()})).catch((function(e){return n(e)})):n()}}(a)),[4,a.open()])):[3,6];case 2:c.sent(),s.dispatch(new Tt(this._iid,{userId:e})),c.label=3;case 3:return[4,r.preference.init(this._getPreferenceCacheKey(e))];case 4:return c.sent(),[4,r.preference.get(this._getUserProfileCacheKey(e))];case 5:(u=c.sent())&&new he(this._iid,u).apply(),c.label=6;case 6:return[2]}}))}))},e.prototype.clearCachedData=function(){return p(this,void 0,void 0,(function(){var e;return v(this,(function(t){switch(t.label){case 0:return(e=E.of(this._iid).cacheContext).localCacheEnabled?(e.nestdb&&e.nestdb.clear(),[4,e.preference.clear()]):[3,2];case 1:t.sent(),t.label=2;case 2:return[2]}}))}))},e.prototype.clearCachedMessages=function(e){return p(this,void 0,void 0,(function(){var t,n,r=this;return v(this,(function(i){switch(i.label){case 0:return m(W("string",e)).throw(y.invalidParameters),t=bt.of(this._iid),n=yt.of(this._iid),t&&n?[4,Promise.all(e.map((function(e){return p(r,void 0,void 0,(function(){return v(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]}}))}))},e.prototype.connect=function(e,t){return void 0===t&&(t=null),p(this,void 0,void 0,(function(){var n,r,i,s,o,a,u;return v(this,(function(l){switch(l.label){case 0:m(c("string",e)&&c("string",t,!0)).throw(y.invalidParameters),n=E.of(this._iid),r=n.sdkState,i=n.cacheContext,s=n.connectionManager,o=n.statLogCollector,l.label=1;case 1:return l.trys.push([1,3,,4]),[4,this.initializeCache(e)];case 2:return l.sent(),[3,4];case 3:return l.sent(),a=E.of(this._iid).logger,i.localCacheEnabled=!1,a.warn("Cache initialization failed - cache is not available."),[3,4];case 4:return[4,o.init("sendbird@".concat(r.appId,"/").concat(e,".statlog"))];case 5:return l.sent(),[4,s.connect(t)];case 6:return l.sent(),this._appStateChangeDetector.start(),r.appState="foreground",[4,null==(u=Nt.of(this._iid))?void 0:u.processNonAutoResendRegisteredPendingMessages()];case 7:return l.sent(),this._onlineDetector.start(),[2,this.currentUser]}}))}))},e.prototype.reconnect=function(){var e=E.of(this._iid),t=e.connectionManager,n=e.sdkState,r=e.sessionManager.auth.hasSession;return r&&t.resetAndReconnect().then((function(){n.appState="foreground"})).catch((function(){})),r},e.prototype.disconnect=function(){return p(this,void 0,void 0,(function(){var e,t,n,r;return v(this,(function(i){switch(i.label){case 0:return e=E.of(this._iid),t=e.connectionManager,n=e.cacheContext,r=e.requestQueue,this._appStateChangeDetector.stop(),this._onlineDetector.stop(),r.cancelAll(),[4,t.logout()];case 1:return i.sent(),n.localCacheEnabled?[4,this.clearCachedData()]:[3,3];case 2:i.sent(),i.label=3;case 3:return[2]}}))}))},e.prototype.setBackgroundState=function(){var e=E.of(this._iid),t=e.connectionManager,n=e.sdkState,r=e.logger;"foreground"===n.appState&&(n.appState="background",r.debug("going background state"),t.background())},e.prototype.setForegroundState=function(){var e=E.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())},e.prototype.setSessionHandler=function(e){m(e instanceof et).throw(y.invalidParameters),E.of(this._iid).sessionManager.handler=e},e.prototype.addUserEventHandler=function(e,t){m(c("string",e)&&t instanceof nt).throw(y.invalidParameters),E.of(this._iid).userEventHandlers.set(e,t)},e.prototype.removeUserEventHandler=function(e){E.of(this._iid).userEventHandlers.delete(e)},e.prototype.removeAllUserEventHandler=function(){E.of(this._iid).userEventHandlers.clear()},e.prototype.addConnectionHandler=function(e,t){m(c("string",e)&&t instanceof tt).throw(y.invalidParameters),E.of(this._iid).connectionHandlers.set(e,t)},e.prototype.removeConnectionHandler=function(e){E.of(this._iid).connectionHandlers.delete(e)},e.prototype.removeAllConnectionHandler=function(){E.of(this._iid).connectionHandlers.clear()},e.prototype.createApplicationUserListQuery=function(e){return void 0===e&&(e={}),new Ln(this._iid,e)},e.prototype.createBlockedUserListQuery=function(e){return void 0===e&&(e={}),new Rn(this._iid,e)},e.prototype.createFriendListQuery=function(e){return void 0===e&&(e={}),new Un(this._iid,e)},e.prototype.createMessageSearchQuery=function(e){return new oe(this._iid,e)},e.prototype.createPollListQuery=function(e){return new We(this._iid,g({},e))},e.prototype.createPollVoterListQuery=function(e){return new Xe(this._iid,g({},e))},e.prototype.buildUserFromSerializedData=function(e){var t=ae(e);return new w(this._iid,w.payloadify(t))},e.prototype.updateCurrentUserInfo=function(e){return void 0===e&&(e={}),p(this,void 0,void 0,(function(){var t,n,r,i,s,o,a;return v(this,(function(u){switch(u.label){case 0:return t=g(g({},$e),e),m(function(e){return N(e.profileImage,!0)&&c("string",e.profileUrl,!0)&&c("string",e.nickname,!0)}(t)).throw(y.invalidParameters),this.currentUser?(n=E.of(this._iid),r=n.sdkState,i=n.requestQueue,s=new Ct(g({userId:r.userId},t)),[4,i.send(s)]):[3,2];case 1:return o=u.sent(),a=o.as(At).user,this.currentUser&&(t.nickname&&(this.currentUser.nickname=a.nickname),(t.profileUrl||t.profileImage)&&(this.currentUser.plainProfileUrl=a.profileUrl)),[2,a];case 2:throw y.connectionRequired}}))}))},e.prototype.updateCurrentUserInfoWithPreferredLanguages=function(e){return p(this,void 0,void 0,(function(){var t,n,r,i,s,o;return v(this,(function(a){switch(a.label){case 0:return m(W("string",e)).throw(y.invalidParameters),this.currentUser?(t=E.of(this._iid),n=t.sdkState,r=t.requestQueue,i=new Ct({userId:n.userId,preferredLanguages:e}),[4,r.send(i)]):[3,2];case 1:return s=a.sent(),o=s.as(At).user,this.currentUser&&(this.currentUser.preferredLanguages=o.preferredLanguages),[2,o];case 2:throw y.connectionRequired}}))}))},e.prototype.registerFCMPushTokenForCurrentUser=function(e){return p(this,void 0,void 0,(function(){var t,n,r,i;return v(this,(function(s){switch(s.label){case 0:if(m(c("string",e)).throw(y.invalidParameters),!this.currentUser)return[3,5];s.label=1;case 1:return s.trys.push([1,3,,4]),t=E.of(this._iid),n=t.sdkState,r=t.requestQueue,i=new xt({userId:n.userId,token:e}),[4,r.send(i)];case 2:return s.sent(),this._fcmPushToken="",[2,Ie.SUCCESS];case 3:return s.sent(),[2,Ie.ERROR];case 4:return[3,6];case 5:return this._fcmPushToken=e,[2,Ie.PENDING];case 6:return[2]}}))}))},e.prototype.unregisterFCMPushTokenForCurrentUser=function(e){return p(this,void 0,void 0,(function(){var t,n,r,i;return v(this,(function(s){switch(s.label){case 0:if(m(c("string",e)).throw(y.invalidParameters),!this.currentUser)return[3,5];s.label=1;case 1:return s.trys.push([1,3,,4]),t=E.of(this._iid),n=t.sdkState,r=t.requestQueue,i=new Rt({userId:n.userId,token:e}),[4,r.send(i)];case 2:return s.sent(),this._fcmPushToken="",[2,Ie.SUCCESS];case 3:return s.sent(),[2,Ie.ERROR];case 4:return[3,6];case 5:return this._fcmPushToken=e,[2,Ie.PENDING];case 6:return[2]}}))}))},e.prototype.unregisterFCMPushTokenAllForCurrentUser=function(){return p(this,void 0,void 0,(function(){var e,t,n,r;return v(this,(function(i){switch(i.label){case 0:return this.currentUser?(e=E.of(this._iid),t=e.sdkState,n=e.requestQueue,r=new Mt({userId:t.userId}),[4,n.send(r)]):[3,2];case 1:i.sent(),i.label=2;case 2:return[2]}}))}))},e.prototype.registerAPNSPushTokenForCurrentUser=function(e){return p(this,void 0,void 0,(function(){var t,n,r,i;return v(this,(function(s){switch(s.label){case 0:if(m(c("string",e)).throw(y.invalidParameters),!this.currentUser)return[3,5];s.label=1;case 1:return s.trys.push([1,3,,4]),t=E.of(this._iid),n=t.sdkState,r=t.requestQueue,i=new Lt({userId:n.userId,token:e}),[4,r.send(i)];case 2:return s.sent(),this._fcmPushToken="",[2,Ie.SUCCESS];case 3:return s.sent(),[2,Ie.ERROR];case 4:return[3,6];case 5:return this._fcmPushToken=e,[2,Ie.PENDING];case 6:return[2]}}))}))},e.prototype.unregisterAPNSPushTokenForCurrentUser=function(e){return p(this,void 0,void 0,(function(){var t,n,r,i;return v(this,(function(s){switch(s.label){case 0:if(m(c("string",e)).throw(y.invalidParameters),!this.currentUser)return[3,5];s.label=1;case 1:return s.trys.push([1,3,,4]),t=E.of(this._iid),n=t.sdkState,r=t.requestQueue,i=new Pt({userId:n.userId,token:e}),[4,r.send(i)];case 2:return s.sent(),this._fcmPushToken="",[2,Ie.SUCCESS];case 3:return s.sent(),[2,Ie.ERROR];case 4:return[3,6];case 5:return this._fcmPushToken=e,[2,Ie.PENDING];case 6:return[2]}}))}))},e.prototype.unregisterAPNSPushTokenAllForCurrentUser=function(){return p(this,void 0,void 0,(function(){var e,t,n,r;return v(this,(function(i){switch(i.label){case 0:return this.currentUser?(e=E.of(this._iid),t=e.sdkState,n=e.requestQueue,r=new Dt({userId:t.userId}),[4,n.send(r)]):[3,2];case 1:i.sent(),i.label=2;case 2:return[2]}}))}))},e.prototype.getChannelInvitationPreference=function(){return p(this,void 0,void 0,(function(){var e,t,n,r,i;return v(this,(function(s){switch(s.label){case 0:return e=E.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,{autoAccept:i.as(Bt).autoAccept}]}}))}))},e.prototype.setChannelInvitationPreference=function(e){return p(this,void 0,void 0,(function(){var t,n,r,i,s;return v(this,(function(o){switch(o.label){case 0:return m(c("boolean",e)).throw(y.invalidParameters),t=E.of(this._iid),n=t.sdkState,r=t.requestQueue,i=new Kt({userId:n.userId,willAutoAccept:e}),[4,r.send(i)];case 1:return s=o.sent(),[2,{autoAccept:s.as(jt).autoAccept}]}}))}))},e.prototype.getDoNotDisturb=function(){return p(this,void 0,void 0,(function(){var e,t,n,r,i;return v(this,(function(s){switch(s.label){case 0:return e=E.of(this._iid),t=e.sdkState,n=e.requestQueue,r=new Ht({userId:t.userId}),[4,n.send(r)];case 1:return i=s.sent(),[2,i.as(zt).preference]}}))}))},e.prototype.setDoNotDisturb=function(e,t,n,r,i,s){return void 0===t&&(t=0),void 0===n&&(n=0),void 0===r&&(r=0),void 0===i&&(i=0),void 0===s&&(s=""),p(this,void 0,void 0,(function(){var o,a,u,l,h;return v(this,(function(d){switch(d.label){case 0:return m(c("boolean",e)&&c("number",t)&&c("number",n)&&c("number",r)&&c("number",i)&&c("string",s)).throw(y.invalidParameters),o=E.of(this._iid),a=o.sdkState,u=o.requestQueue,l=new Vt({userId:a.userId,doNotDisturbOn:e,startHour:t,startMin:n,endHour:r,endMin:i,timezone:s}),[4,u.send(l)];case 1:return h=d.sent(),[2,h.as(Qt).preference]}}))}))},e.prototype.getSnoozePeriod=function(){return p(this,void 0,void 0,(function(){var e,t,n,r,i;return v(this,(function(s){switch(s.label){case 0:return e=E.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(Wt).snoozePeriod]}}))}))},e.prototype.setSnoozePeriod=function(e,t,n){return void 0===t&&(t=0),void 0===n&&(n=0),p(this,void 0,void 0,(function(){var r,i,s,o,a;return v(this,(function(u){switch(u.label){case 0:return m(c("boolean",e)&&c("number",t)&&c("number",n)).throw(y.invalidParameters),r=E.of(this._iid),i=r.sdkState,s=r.requestQueue,o=new Yt({userId:i.userId,snoozeOn:e,startTs:t,endTs:n}),[4,s.send(o)];case 1:return a=u.sent(),[2,a.as(Jt).snoozePeriod]}}))}))},e.prototype.getMyPushTokensByToken=function(e,t){return p(this,void 0,void 0,(function(){var n,r,i,s,o;return v(this,(function(a){switch(a.label){case 0:return m(c("string",e)&&d(we,t)).throw(y.invalidParameters),n=E.of(this._iid),r=n.sdkState,i=n.requestQueue,s=new Ut({userId:r.userId,type:t,token:e}),[4,i.send(s)];case 1:return o=a.sent(),[2,o.as(qt).pushTokens]}}))}))},e.prototype.getPushTriggerOption=function(){return p(this,void 0,void 0,(function(){var e,t,n,r;return v(this,(function(i){switch(i.label){case 0:return e=E.of(this._iid),t=e.sdkState,n=e.requestQueue,r=new $t({userId:t.userId}),[4,n.send(r)];case 1:return[2,i.sent().as(en).pushTriggerOption]}}))}))},e.prototype.setPushTriggerOption=function(e){return p(this,void 0,void 0,(function(){var t,n,r,i;return v(this,(function(s){switch(s.label){case 0:return m(d(Ee,e)).throw(y.invalidParameters),t=E.of(this._iid),n=t.sdkState,r=t.requestQueue,i=new tn({userId:n.userId,pushTriggerOption:e}),[4,r.send(i)];case 1:return[2,s.sent().as(nn).pushTriggerOption]}}))}))},e.prototype.getPushTemplate=function(){return p(this,void 0,void 0,(function(){var e,t,n,r;return v(this,(function(i){switch(i.label){case 0:return e=E.of(this._iid),t=e.sdkState,n=e.requestQueue,r=new rn({userId:t.userId}),[4,n.send(r)];case 1:return[2,i.sent().as(sn).name]}}))}))},e.prototype.setPushTemplate=function(e){return p(this,void 0,void 0,(function(){var t,n,r,i;return v(this,(function(s){switch(s.label){case 0:return m(d(ke,e)).throw(y.invalidParameters),t=E.of(this._iid),n=t.sdkState,r=t.requestQueue,i=new on({userId:n.userId,templateName:e}),[4,r.send(i)];case 1:return[2,s.sent().as(an).name]}}))}))},e.prototype.blockUser=function(e){return p(this,void 0,void 0,(function(){var t,n,r,i;return v(this,(function(s){switch(s.label){case 0:return m(e instanceof w||c("string",e)).throw(y.invalidParameters),t=E.of(this._iid),n=t.sdkState,r=t.requestQueue,i=new Xt({userId:n.userId,blockedUserId:e instanceof w?e.userId:e}),[4,r.send(i)];case 1:return s.sent(),[2]}}))}))},e.prototype.blockUserWithUserId=function(e){return p(this,void 0,void 0,(function(){return v(this,(function(t){return[2,this.blockUser(e)]}))}))},e.prototype.unblockUser=function(e){return p(this,void 0,void 0,(function(){var t,n,r,i;return v(this,(function(s){switch(s.label){case 0:return m(e instanceof w||c("string",e)).throw(y.invalidParameters),t=E.of(this._iid),n=t.sdkState,r=t.requestQueue,i=new Zt({userId:n.userId,unblockedUserId:e instanceof w?e.userId:e}),[4,r.send(i)];case 1:return s.sent(),[2]}}))}))},e.prototype.unblockUserWithUserId=function(e){return p(this,void 0,void 0,(function(){return v(this,(function(t){return[2,this.unblockUser(e)]}))}))},e.prototype.getFriendChangeLogsByToken=function(e){return p(this,void 0,void 0,(function(){var t,n,r,i,s;return v(this,(function(o){switch(o.label){case 0:return m(c("string",e)).throw(y.invalidParameters),t=E.of(this._iid),n=t.sdkState,r=t.requestQueue,i=new un({userId:n.userId,token:e}),[4,r.send(i)];case 1:return s=o.sent(),[2,s.as(cn).changelogs]}}))}))},e.prototype.getAllowFriendDiscovery=function(){return p(this,void 0,void 0,(function(){var e,t,n,r,i;return v(this,(function(s){switch(s.label){case 0:return e=E.of(this._iid),t=e.sdkState,n=e.requestQueue,r=new _n({userId:t.userId}),[4,n.send(r)];case 1:return i=s.sent(),[2,i.as(mn).allowFriendDiscovery]}}))}))},e.prototype.setAllowFriendDiscovery=function(e){return p(this,void 0,void 0,(function(){var t,n,r,i;return v(this,(function(s){switch(s.label){case 0:return m(c("boolean",e)).throw(y.invalidParameters),t=E.of(this._iid),n=t.sdkState,r=t.requestQueue,i=new yn({userId:n.userId,allowFriendDiscovery:e}),[4,r.send(i)];case 1:return s.sent(),[2,e]}}))}))},e.prototype.uploadFriendDiscoveries=function(e){return p(this,void 0,void 0,(function(){var t,n,r,i,s;return v(this,(function(o){switch(o.label){case 0:return t=E.of(this._iid),n=t.sdkState,r=t.requestQueue,i=new ln({userId:n.userId,discoveries:e}),[4,r.send(i)];case 1:return s=o.sent(),[2,s.as(hn).friendDiscoveryRequestId]}}))}))},e.prototype.deleteFriendDiscovery=function(e){return p(this,void 0,void 0,(function(){return v(this,(function(t){return[2,this.deleteFriendDiscoveries([e])]}))}))},e.prototype.deleteFriendDiscoveries=function(e){return p(this,void 0,void 0,(function(){var t,n,r,i;return v(this,(function(s){switch(s.label){case 0:return m(W("string",e)).throw(y.invalidParameters),t=E.of(this._iid),n=t.sdkState,r=t.requestQueue,i=new dn({userId:n.userId,discoveryKeys:e}),[4,r.send(i)];case 1:return s.sent(),[2]}}))}))},e.prototype.addFriends=function(e){return p(this,void 0,void 0,(function(){var t,n,r,i,s;return v(this,(function(o){switch(o.label){case 0:return m(W("string",e)).throw(y.invalidParameters),t=E.of(this._iid),n=t.sdkState,r=t.requestQueue,i=new fn({userId:n.userId,userIds:e}),[4,r.send(i)];case 1:return s=o.sent(),[2,s.as(pn).users]}}))}))},e.prototype.deleteFriend=function(e){return p(this,void 0,void 0,(function(){return v(this,(function(t){return[2,this.deleteFriends([e])]}))}))},e.prototype.deleteFriends=function(e){return p(this,void 0,void 0,(function(){var t,n,r,i;return v(this,(function(s){switch(s.label){case 0:return m(W("string",e)).throw(y.invalidParameters),t=E.of(this._iid),n=t.sdkState,r=t.requestQueue,i=new vn({userId:n.userId,userIds:e}),[4,r.send(i)];case 1:return s.sent(),[2]}}))}))},e.prototype.getAllEmoji=function(){return p(this,void 0,void 0,(function(){var e,t,n;return v(this,(function(r){switch(r.label){case 0:return e=E.of(this._iid).requestQueue,t=new wn,[4,e.send(t)];case 1:return n=r.sent(),[2,n.as(kn).emojiContainer]}}))}))},e.prototype.getEmojiCategory=function(e){return p(this,void 0,void 0,(function(){var t,n,r;return v(this,(function(i){switch(i.label){case 0:return t=E.of(this._iid).requestQueue,n=new Nn({categoryId:e}),[4,t.send(n)];case 1:return r=i.sent(),[2,r.as(Sn).emojiCategory]}}))}))},e.prototype.getEmoji=function(e){return p(this,void 0,void 0,(function(){var t,n,r;return v(this,(function(i){switch(i.label){case 0:return t=E.of(this._iid).requestQueue,n=new Tn({key:e}),[4,t.send(n)];case 1:return r=i.sent(),[2,r.as(On).emoji]}}))}))},e}();export{wt as A,Rn as B,tt as C,rt as D,bn as E,Un as F,Ne as G,ke as H,Ie as I,we as J,et as K,nt as L,bt as M,it as N,ze as P,ft as S,yt as U,Tt as a,Ve as b,Ot as c,ht as d,St as e,st as f,ct as g,He as h,lt as i,Nt as j,vt as k,_t as l,We as m,Xe as n,Ee as o,ot as p,at as q,Se as r,Te as s,Ze as t,Mr as u,pt as v,Ln as w,In as x,En as y,Cr as z}; diff --git a/__bundle-466be550.js b/__bundle-cd7e480a.js similarity index 98% rename from __bundle-466be550.js rename to __bundle-cd7e480a.js index fd42b49..9028f57 100644 --- a/__bundle-466be550.js +++ b/__bundle-cd7e480a.js @@ -1 +1 @@ -import{C as e,_ as n,W as t,U as a,b1 as s,V as o,ao as N,ap as r,aq as E,b2 as i,r as u}from"./__bundle-0a632c33.js";var _;!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"}(_||(_={}));var C=function(){function n(e){this.channelUrl=e.channel_url,this.channelType=e.channel_type,this.category=e.cat,this.data=e.data,this.ts=e.ts}return Object.defineProperty(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}(),l=function(e){function t(n,t,a){var s=e.call(this,n,"SYEV",a)||this;return s.event=new C(a),s}return n(t,e),t}(t),d=function(e){function t(n,t,s){var o=e.call(this,n,t,s)||this,N=s.data.operators,r=void 0===N?[]:N;return o.operators=r.map((function(e){return new a(o._iid,e)})),o}return n(t,e),t}(l),h=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),A=function(e){function t(n,t,a){var r,E,i,u=this;(u=e.call(this,n,"ADMM",a)||this).message=new s(n,a);var _=o.of(n).sdkState;return u.isMentioned=N(u.message.mentionType,null!==(r=u.message.mentionedUserIds)&&void 0!==r?r:null===(E=u.message.mentionedUsers)||void 0===E?void 0:E.map((function(e){return e.userId})),_.userId),u.forceUpdateLastMessage=null!==(i=a.force_update_last_message)&&void 0!==i&&i,u}return n(t,e),t}(t),c=function(e){function t(n,t,a){var N,E,i,u,_,C,l=this;(l=e.call(this,n,"AEDI",a)||this).message=new s(n,a);var d=o.of(n).sdkState;return l.mentionCountChange=r({mentionType:null!==(E=null===(N=a.old_values)||void 0===N?void 0:N.mention_type)&&void 0!==E?E:null,mentionedUserIds:null!==(u=null===(i=a.old_values)||void 0===i?void 0:i.mentioned_user_ids)&&void 0!==u?u:[]},{mentionType:l.message.mentionType,mentionedUserIds:null!==(_=l.message.mentionedUserIds)&&void 0!==_?_:null===(C=l.message.mentionedUsers)||void 0===C?void 0:C.map((function(e){return e.userId}))},d.userId),l}return n(t,e),t}(t),H=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 E(a),s}return n(t,e),t}(t),T=function(e){function t(n,t,a){var s=e.call(this,n,"MTHD",a)||this;return s.event=new i(n,a),s}return n(t,e),t}(t),U=function(){this.onUserMuted=u,this.onUserUnmuted=u,this.onUserBanned=u,this.onUserUnbanned=u,this.onChannelChanged=u,this.onChannelDeleted=u,this.onChannelFrozen=u,this.onChannelUnfrozen=u,this.onOperatorUpdated=u,this.onChannelMemberCountChanged=u,this.onMetaDataCreated=u,this.onMetaDataUpdated=u,this.onMetaDataDeleted=u,this.onMetaCounterCreated=u,this.onMetaCounterUpdated=u,this.onMetaCounterDeleted=u,this.onMessageReceived=u,this.onMessageUpdated=u,this.onMessageDeleted=u,this.onMentionReceived=u,this.onReactionUpdated=u,this.onThreadInfoUpdated=u};export{A,U as B,l as C,h as M,d as O,H as R,T,c as U,_ as a}; +import{C as e,_ as n,W as t,U as a,b1 as s,V as o,ao as N,ap as r,aq as E,b2 as i,r as u}from"./__bundle-1abffbb6.js";var _;!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"}(_||(_={}));var C=function(){function n(e){this.channelUrl=e.channel_url,this.channelType=e.channel_type,this.category=e.cat,this.data=e.data,this.ts=e.ts}return Object.defineProperty(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}(),l=function(e){function t(n,t,a){var s=e.call(this,n,"SYEV",a)||this;return s.event=new C(a),s}return n(t,e),t}(t),d=function(e){function t(n,t,s){var o=e.call(this,n,t,s)||this,N=s.data.operators,r=void 0===N?[]:N;return o.operators=r.map((function(e){return new a(o._iid,e)})),o}return n(t,e),t}(l),h=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),A=function(e){function t(n,t,a){var r,E,i,u=this;(u=e.call(this,n,"ADMM",a)||this).message=new s(n,a);var _=o.of(n).sdkState;return u.isMentioned=N(u.message.mentionType,null!==(r=u.message.mentionedUserIds)&&void 0!==r?r:null===(E=u.message.mentionedUsers)||void 0===E?void 0:E.map((function(e){return e.userId})),_.userId),u.forceUpdateLastMessage=null!==(i=a.force_update_last_message)&&void 0!==i&&i,u}return n(t,e),t}(t),c=function(e){function t(n,t,a){var N,E,i,u,_,C,l=this;(l=e.call(this,n,"AEDI",a)||this).message=new s(n,a);var d=o.of(n).sdkState;return l.mentionCountChange=r({mentionType:null!==(E=null===(N=a.old_values)||void 0===N?void 0:N.mention_type)&&void 0!==E?E:null,mentionedUserIds:null!==(u=null===(i=a.old_values)||void 0===i?void 0:i.mentioned_user_ids)&&void 0!==u?u:[]},{mentionType:l.message.mentionType,mentionedUserIds:null!==(_=l.message.mentionedUserIds)&&void 0!==_?_:null===(C=l.message.mentionedUsers)||void 0===C?void 0:C.map((function(e){return e.userId}))},d.userId),l}return n(t,e),t}(t),H=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 E(a),s}return n(t,e),t}(t),T=function(e){function t(n,t,a){var s=e.call(this,n,"MTHD",a)||this;return s.event=new i(n,a),s}return n(t,e),t}(t),U=function(){this.onUserMuted=u,this.onUserUnmuted=u,this.onUserBanned=u,this.onUserUnbanned=u,this.onChannelChanged=u,this.onChannelDeleted=u,this.onChannelFrozen=u,this.onChannelUnfrozen=u,this.onOperatorUpdated=u,this.onChannelMemberCountChanged=u,this.onMetaDataCreated=u,this.onMetaDataUpdated=u,this.onMetaDataDeleted=u,this.onMetaCounterCreated=u,this.onMetaCounterUpdated=u,this.onMetaCounterDeleted=u,this.onMessageReceived=u,this.onMessageUpdated=u,this.onMessageDeleted=u,this.onMentionReceived=u,this.onReactionUpdated=u,this.onThreadInfoUpdated=u};export{A,U as B,l as C,h as M,d as O,H as R,T,c as U,_ as a}; diff --git a/groupChannel.js b/groupChannel.js index db5da06..a84e6b3 100644 --- a/groupChannel.js +++ b/groupChannel.js @@ -1 +1 @@ -import{_ as e,e as t,l as n,h as a,af as o,C as u,U as l,I as c,aH as h,Z as d,Y as f,j as p,k as _,z as m,T as v,i as g,q as y,s as E,aI as C,B as N,aJ as b,aK as T,aL as S,m as U,aM as A,aN as I,L as w,w as L,A as D,N as R,b as O,c as P,aO as k,aP as F,aQ as x,aR as H,an as V,W as q,aS as K,aT as B,X as j,S as Q,a8 as z,V as W,x as Y,F as J,ax as X,a9 as Z,M as $,aU as ee,u as te,D as ne,aV as re,aW as se,a2 as ie,aw as ae,E as oe,H as ue,J as le,y as ce,R as he,g as de,aX as fe,aY as pe,aZ as _e,n as me,ah as ve,ar as ge,as as ye,ai as Ee,ak as Ce,f as Ne,a as be,P as Me,a_ as Te,ay as Se,a$ as Ue,b0 as Ae,r as Ie,o as we}from"./__bundle-0a632c33.js";export{M as MessageEventSource,aI as ScheduledStatus}from"./__bundle-0a632c33.js";import{N as Le,G as De,g as Re,D as Oe,a as Pe,P as ke,b as Fe,U as xe,M as He,A as Ve,c as Ge,d as qe,e as Ke,f as Be,h as je,i as Qe,j as ze,S as We,v as Ye,k as Je,l as Xe,m as Ze,n as $e,o as et,p as tt,q as nt,r as rt,s as st}from"./__bundle-0bd37fbb.js";export{G as GroupChannelListOrder,i as MessageFilter,r as PublicGroupChannelListOrder,s as ScheduledMessageListOrder}from"./__bundle-0bd37fbb.js";import{f as it,j as at,k as ot,l as ut,m as lt,n as ct,o as ht,p as dt,D as ft,q as pt,r as _t,t as mt,u as vt,w as gt,x as yt,y as Et,e as Ct,C as Nt,P as bt}from"./__bundle-c7363281.js";import{C as Mt,a as Tt,O as St,M as Ut,T as At,R as It,U as wt,A as Lt,B as Dt}from"./__bundle-466be550.js";var Rt;!function(e){e.NONE="none",e.JOINED="joined",e.INVITED="invited",e.LEFT="left"}(Rt||(Rt={}));var Ot,Pt,kt,Ft,xt,Ht,Vt,Gt,qt=function(r){function s(e,t){var n=r.call(this,e,t)||this;return n.state=null,n.role=null,n.isMuted=!1,n.isBlockedByMe=!1,n.isBlockingMe=!1,n.state=a(Rt,t.state)?t.state:null,n.role=a(o,t.role)?t.role:null,t.hasOwnProperty("is_muted")&&(n.isMuted=t.is_muted),t.hasOwnProperty("is_blocked_by_me")&&(n.isBlockedByMe=t.is_blocked_by_me),t.hasOwnProperty("is_blocking_me")&&(n.isBlockingMe=t.is_blocking_me),n}return e(s,r),s.payloadify=function(e){return e?t(n(n({},r.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},s}(it),Kt=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 l(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"}(Ot||(Ot={})),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"}(Pt||(Pt={})),function(e){e.ALL="all",e.SUPER="super",e.NON_SUPER="nonsuper",e.BROADCAST_ONLY="broadcast_only",e.EXCLUSIVE_ONLY="exclusive_only"}(kt||(kt={})),function(e){e.ALL="all",e.UNREAD_MESSAGE="unread_message"}(Ft||(Ft={})),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"}(xt||(xt={})),function(e){e.ALL="all",e.OPERATOR="operator",e.NONOPERATOR="nonoperator"}(Ht||(Ht={})),function(e){e.AND="AND",e.OR="OR"}(Vt||(Vt={})),function(e){e.MEMBER_NICKNAME="member_nickname",e.CHANNEL_NAME="channel_name"}(Gt||(Gt={}));var Bt,jt=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=Pt.ALL,this.customTypesFilter=null,this.channelUrlsFilter=null,this.superChannelFilter=kt.ALL,this.publicChannelFilter=Ot.ALL,this.customTypeStartsWithFilter=null,this.unreadChannelFilter=Ft.ALL,this.hiddenChannelFilter=xt.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=Vt.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 Gt.CHANNEL_NAME:return e.name.toLowerCase().includes(r.toLowerCase());case Gt.MEMBER_NICKNAME:return e.members.some((function(e){return e.nickname.toLowerCase().includes(r.toLowerCase())}));default:return!0}})))return!1}if(this._userIdsFilter){var i=this._userIdsFilter,a=i.userIds,o=i.includeMode,u=i.queryType,l=e.members.map((function(e){return e.userId}));if(o){if(a.length>0)switch(u){case Vt.AND:if(a.some((function(e){return!l.includes(e)})))return!1;break;case Vt.OR:if(a.every((function(e){return!l.includes(e)})))return!1}}else{if(a.includes(t)||a.push(t),e.members.length>a.length)return!1;if(!h(a,l))return!1}}if(!this.includeEmpty&&!e.lastMessage)return!1;if(!this.includeFrozen&&e.isFrozen)return!1;if(this.customTypesFilter&&this.customTypesFilter.length>0&&!this.customTypesFilter.includes(e.customType))return!1;if(this.customTypeStartsWithFilter&&!new RegExp("^".concat(this.customTypeStartsWithFilter)).test(e.customType))return!1;if(this.channelNameContainsFilter&&!e.name.toLowerCase().includes(this.channelNameContainsFilter.toLowerCase()))return!1;if(this.nicknameContainsFilter){var c=this.nicknameContainsFilter.toLowerCase();if(e.members.every((function(e){return!e.nickname.toLowerCase().includes(c)})))return!1}if(this.nicknameStartsWithFilter){var d=this.nicknameStartsWithFilter.toLowerCase();if(e.members.every((function(e){return!e.nickname.toLowerCase().startsWith(d)})))return!1}if(this.nicknameExactMatchFilter){var f=this.nicknameExactMatchFilter.toLowerCase();if(e.members.every((function(e){return e.nickname.toLowerCase()!=f})))return!1}if(this.channelUrlsFilter&&this.channelUrlsFilter.length>0&&!this.channelUrlsFilter.includes(e.url))return!1;if(this.myMemberStateFilter)switch(this.myMemberStateFilter){case Pt.JOINED:if("joined"!==e.myMemberState)return!1;break;case Pt.INVITED:if("invited"!==e.myMemberState)return!1;break;case Pt.INVITED_BY_FRIEND:if("invited"!==e.myMemberState||!this._isFriend(e.inviter))return!1;break;case Pt.INVITED_BY_NON_FRIEND:if("invited"!==e.myMemberState||this._isFriend(e.inviter))return!1}if(this.hiddenChannelFilter)switch(this.hiddenChannelFilter){case xt.UNHIDDEN:if(e.isHidden||"unhidden"!==e.hiddenState)return!1;break;case xt.HIDDEN:if(!e.isHidden)return!1;break;case xt.HIDDEN_ALLOW_AUTO_UNHIDE:if(!e.isHidden||"hidden_allow_auto_unhide"!==e.hiddenState)return!1;break;case xt.HIDDEN_PREVENT_AUTO_UNHIDE:if(!e.isHidden||"hidden_prevent_auto_unhide"!==e.hiddenState)return!1}if(this.unreadChannelFilter&&this.unreadChannelFilter===Ft.UNREAD_MESSAGE)if(0===e.unreadMessageCount)return!1;if(this.publicChannelFilter)switch(this.publicChannelFilter){case Ot.PUBLIC:if(!e.isPublic)return!1;break;case Ot.PRIVATE:if(e.isPublic)return!1}if(this.superChannelFilter)switch(this.superChannelFilter){case kt.SUPER:if(!e.isSuper)return!1;break;case kt.NON_SUPER:if(e.isSuper)return!1}return!0},e}(),Qt=function(t){function r(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(r,t),Object.defineProperty(r.prototype,"collection",{get:function(){var e=this._cacheContext.nestdb;return e?e.collection(Le):null},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"localCacheEnabled",{get:function(){return this._cacheContext.localCacheEnabled&&!!this.collection},enumerable:!1,configurable:!0}),r.prototype._serialize=function(e,t){return void 0===t&&(t=0),n(n({},e.serialize()),{lastMessageUpdatedAt:e.lastMessage?e.lastMessage.createdAt:0,syncIndex:t})},r.prototype._deserialize=function(e){return sr.of(this._iid).buildGroupChannelFromSerializedData(e)},Object.defineProperty(r.prototype,"channels",{get:function(){return d([],f(this._channels.values()),!1)},enumerable:!1,configurable:!0}),r.prototype.isCachedInMemory=function(e){return this._channels.has(e)},r.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;break;case De.CHRONOLOGICAL:if(!i&&e.createdAt>t||i&&e.createdAtt||i&&e.lastMessageUpdatedAt0?[4,this.upsert(r)]:[3,2];case 1:_.sent(),_.label=2;case 2:return[2]}}))}))},r.prototype.block=function(e,t){return p(this,void 0,void 0,(function(){return _(this,(function(n){switch(n.label){case 0:return[4,this._setBlockStateOfAllChannels(e,t,!0)];case 1:return n.sent(),[2]}}))}))},r.prototype.unblock=function(e,t){return p(this,void 0,void 0,(function(){return _(this,(function(n){switch(n.label){case 0:return[4,this._setBlockStateOfAllChannels(e,t,!1)];case 1:return n.sent(),[2]}}))}))},r.prototype.markAsRead=function(e,t){return void 0===t&&(t=d([],f(this._channels.keys()),!1)),p(this,void 0,void 0,(function(){var n,r,s,i,a,o,u,l;return _(this,(function(c){switch(c.label){case 0:n=[],c.label=1;case 1:c.trys.push([1,6,7,8]),r=m(t),s=r.next(),c.label=2;case 2:return s.done?[3,5]:(i=s.value,[4,this.get(i)]);case 3:(a=c.sent())._updateUnreadMemberState(this._sdkState.userId,e)&&(a._updateUnreadCount(0,0),n.push(a)),c.label=4;case 4:return s=r.next(),[3,2];case 5:return[3,8];case 6:return o=c.sent(),u={error:o},[3,8];case 7:try{s&&!s.done&&(l=r.return)&&l.call(r)}finally{if(u)throw u.error}return[7];case 8:return n.length>0?[4,this.upsert(n)]:[3,10];case 9:c.sent(),c.label=10;case 10:return[2]}}))}))},r}(c),zt={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},Wt=function(e){return v("string",e.invitedUserIds,!0)&&g("string",e.channelUrl,!0)&&g("string",e.coverUrl,!0)&&(y(e.coverImage)||g("string",e.coverImage)||null===e.coverImage)&&g("boolean",e.isDistinct,!0)&&g("boolean",e.isSuper,!0)&&g("boolean",e.isBroadcast,!0)&&g("boolean",e.isExclusive,!0)&&g("boolean",e.isPublic,!0)&&g("boolean",e.isStrict,!0)&&g("boolean",e.isDiscoverable,!0)&&g("boolean",e.isEphemeral,!0)&&g("string",e.accessCode,!0)&&g("string",e.name,!0)&&g("string",e.data,!0)&&g("string",e.customType,!0)&&v("string",e.operatorUserIds,!0)&&g("number",e.messageSurvivalSeconds,!0)},Yt={customTypes:null,includeEmpty:!1,includeFrozen:!0},Jt=function(e){return v("string",e.customTypes,!0)&&g("boolean",e.includeEmpty)&&g("boolean",e.includeFrozen)},Xt={myMemberStateFilter:Pt.ALL},Zt=function(e){return a(Pt,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"}(Bt||(Bt={}));var $t,en={keys:[]},tn={channelCustomTypesFilter:null,superChannelFilter:kt.ALL},nn={channelUrl:null,scheduledStatus:null,messageTypeFilter:E.ALL};!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.REQUEST_CHANNEL="REQUEST_CHANNEL",e.REQUEST_CHANNEL_CHANGELOGS="REQUEST_CHANNEL_CHANGELOGS",e.SYNC_CHANNEL_BACKGROUND="SYNC_CHANNEL_BACKGROUND",e.SYNC_CHANNEL_CHANGELOGS="SYNC_CHANNEL_CHANGELOGS"}($t||($t={}));var rn=function(e){return e.startsWith("EVENT_")||e===$t.SYNC_CHANNEL_BACKGROUND||e===$t.SYNC_CHANNEL_CHANGELOGS},sn=function(t){function n(e){var n=e.channels,r=e.source,s=t.call(this)||this;return s.channels=n,s.source=r,s}return e(n,t),n}(N),an=function(t){function n(e){var n=e.channelUrls,r=e.source,s=t.call(this)||this;return s.channelUrls=n,s.source=r,s}return e(n,t),n}(N),on=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 p(i,void 0,void 0,(function(){var s,i,a,o,u,l,c,h,d,f,v=this;return _(this,(function(g){switch(g.label){case 0:if(!(e instanceof sn))return[3,2];s=e.channels,h=e.source,i=s.filter((function(e){return e instanceof ys})),a=t.filterOffsetChanged(i);try{for(o=m(a),u=o.next();!u.done;u=o.next())l=u.value,n.removeUnderOffset(l.url,l.messageOffsetTimestamp)}catch(e){d={error:e}}finally{try{u&&!u.done&&(f=o.return)&&f.call(o)}finally{if(d)throw d.error}}return[4,t.upsert(i)];case 1:return g.sent(),this._broadcastUpdateEvent(i,h),[3,7];case 2:return e instanceof an?(c=e.channelUrls,h=e.source,[4,t.remove(c)]):[3,5];case 3:return g.sent(),[4,b((function(){return p(v,void 0,void 0,(function(){var e,t,s,i,a,o;return _(this,(function(u){switch(u.label){case 0:u.trys.push([0,6,7,8]),e=m(c),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 4:return g.sent(),this._broadcastRemoveEvent(c,h),[3,7];case 5:return e instanceof Pe?[4,t.fetch({token:Number.MAX_SAFE_INTEGER,limit:Number.MAX_SAFE_INTEGER})]:[3,7];case 6:g.sent(),g.label=7;case 7:return[2]}}))}))}))}return e.prototype._broadcastUpdateEvent=function(e,t){var n,r;try{for(var s=m(this._observers.values()),i=s.next();!i.done;i=s.next()){i.value.onUpdate(e,t)}}catch(e){n={error:e}}finally{try{i&&!i.done&&(r=s.return)&&r.call(s)}finally{if(n)throw n.error}}},e.prototype._broadcastRemoveEvent=function(e,t){var n,r;try{for(var s=m(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}(),un=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 p(a,void 0,void 0,(function(){var t,s,i,a,o,u,l,c,h,d,f,m,v,g=this;return _(this,(function(y){switch(y.label){case 0:return e instanceof w?(t=e.messages,m=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 p(g,void 0,void 0,(function(){return _(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 L?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,m),y.label=2;case 2:return i.length>0?[4,b((function(){return p(g,void 0,void 0,(function(){return _(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,m),y.label=4;case 4:return[3,21];case 5:return e instanceof I?(a=e.messageIds,m=e.source,[4,b((function(){return p(g,void 0,void 0,(function(){return _(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,m),[3,21];case 7:return e instanceof A?(o=e.reqId,m=e.source,[4,b((function(){return p(g,void 0,void 0,(function(){return _(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,m),[3,21];case 9:return e instanceof U?(u=e.polls,m=e.source,this._cacheContext.localCacheEnabled?(l=u.map((function(e){return e.messageId})),[4,Promise.all(l.map((function(e){return n.get(e)})))]):[3,12]):[3,13];case 10:return(c=y.sent().filter((function(e){return e}))).length>0&&u.forEach((function(e){var t=c.find((function(t){return t.messageId===e.messageId}));t&&t.applyPoll(e)})),[4,b((function(){return p(g,void 0,void 0,(function(){return _(this,(function(e){switch(e.label){case 0:return[4,n.upsert(c)];case 1:return[2,e.sent()]}}))}))}))];case 11:y.sent(),y.label=12;case 12:return this._broadcastPollChangeLogEvent(u,m),[3,21];case 13:return e instanceof S?(h=e.event,m=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 p(g,void 0,void 0,(function(){return _(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,m),[3,21];case 17:return e instanceof T?(f=e.event,m=e.source,[4,n.get(f.messageId)]):[3,21];case 18:return(v=y.sent())&&v.isUserMessage()&&v.poll&&v.poll.applyPollVoteEvent(f)?[4,b((function(){return p(g,void 0,void 0,(function(){return _(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(f,m),y.label=21;case 21:return[2]}}))}))}))}return e.prototype._broadcastUpdateEvent=function(e,t){var n,r;try{for(var s=m(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=m(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=m(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=m(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=m(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=m(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}(),ln=function(r){function s(e){var s=e.userId,i=e.ts,a=e.token,o=e.filter,u=r.call(this)||this,l=n(n({},Yt),o),c=l.customTypes,h=l.includeEmpty,d=l.includeFrozen;return u.method=D.GET,u.path="".concat(R,"/").concat(encodeURIComponent(s),"/my_group_channels/changelogs"),u.params=t({show_delivery_receipt:!0,show_member:!0,show_read_receipt:!0,change_ts:i>0?i:null,token:a,custom_types:c,show_empty:h,show_frozen:d}),u}return e(s,r),s}(O),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 ys(e,t)})),r.deletedChannelUrls=n.deleted,r.hasMore=n.has_more,r.token=n.next,r}return e(n,t),n}(P),hn=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?k:F,"/").concat(encodeURIComponent(n)),s.params={show_member:!0,show_read_receipt:!0,show_delivery_receipt:!0},s}return e(n,t),n}(O),dn=function(t){function n(e,n){var r=t.call(this,e,n)||this;return r.channel=null,r.channel=new ys(e,n),r}return e(n,t),n}(P),fn=function(n){function r(e){var r=this,s=e.userId,i=e.token,a=e.limit,o=e.order,u=e.includeEmpty,l=e.myMemberStateFilter,c=e.superChannelFilter,h=e.publicChannelFilter,d=e.unreadChannelFilter,f=e.nicknameContainsFilter,p=e.nicknameStartsWithFilter,_=e.nicknameExactMatchFilter,m=e.channelNameContainsFilter,v=e.channelUrlsFilter,g=e.customTypesFilter,y=e.customTypeStartsWithFilter,E=e.hiddenChannelFilter,C=e.metadataOrderKeyFilter,N=e.metadataKey,b=e.metadataValues,M=e.metadataValueStartsWith,T=e.includeFrozen,S=e.includeMetaData,U=e.searchFilter,A=e.userIdsFilter;return(r=n.call(this)||this).method=D.GET,r.path="".concat(R,"/").concat(encodeURIComponent(s),"/my_group_channels"),r.params=t({token:i,limit:a,order:o,show_member:!0,show_read_receipt:!0,show_delivery_receipt:!0,show_empty:u,member_state_filter:l,super_mode:c,public_mode:h,unread_filter:d,members_nickname_contains:f,members_nickname_startswith:p,members_nickname:_,name_contains:m,channel_urls:v,custom_types:g,custom_type_startswith:y,hidden_mode:E,metadata_order_key:C,metadata_key:N,metadata_values:b,metadata_value_startswith:M,show_frozen:T,show_metadata:S}),U&&U.query&&U.fields&&(r.params.search_query=U.query,r.params.search_fields=U.fields),A&&A.userIds&&A.userIds.length>0&&(A.includeMode?(r.params.members_include_in=A.userIds,r.params.query_type=A.queryType.toUpperCase()):r.params.members_exactly_in=A.userIds),r}return e(r,n),r}(O),pn=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 ys(e,t)}))),r.ts=null!=a?a:null,r}return e(n,t),n}(P),_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(R,"/").concat(encodeURIComponent(n),"/group_channel_count"),s.params={state:null!=i?i:Pt.ALL},s}return e(n,t),n}(O),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}(P),vn=function(t){function n(e){var n=e.userId,r=e.filter,s=t.call(this)||this,i=r.keys;return s.method=D.GET,s.path="".concat(R,"/").concat(encodeURIComponent(n),"/unread_item_count"),s.params={item_keys:i},s}return e(n,t),n}(O),gn=function(t){function n(e,n){var r=t.call(this,e,n)||this;return"number"==typeof n[Bt.GROUP_CHANNEL_UNREAD_MENTION_COUNT]&&(r.groupChannelUnreadMentionCount=n[Bt.GROUP_CHANNEL_UNREAD_MENTION_COUNT]),"number"==typeof n[Bt.GROUP_CHANNEL_UNREAD_MESSAGE_COUNT]&&(r.groupChannelUnreadMessageCount=n[Bt.GROUP_CHANNEL_UNREAD_MESSAGE_COUNT]),"number"==typeof n[Bt.GROUP_CHANNEL_INVITATION_COUNT]&&(r.groupChannelInvitationCount=n[Bt.GROUP_CHANNEL_INVITATION_COUNT]),"number"==typeof n[Bt.SUPER_UNREAD_MENTION_COUNT]&&(r.superGroupChannelUnreadMentionCount=n[Bt.SUPER_UNREAD_MENTION_COUNT]),"number"==typeof n[Bt.SUPER_UNREAD_MESSAGE_COUNT]&&(r.superGroupChannelUnreadMessageCount=n[Bt.SUPER_UNREAD_MESSAGE_COUNT]),"number"==typeof n[Bt.SUPER_INVITATION_COUNT]&&(r.superGroupChannelInvitationCount=n[Bt.SUPER_INVITATION_COUNT]),"number"==typeof n[Bt.NONSUPER_UNREAD_MENTION_COUNT]&&(r.nonSuperGroupChannelUnreadMentionCount=n[Bt.NONSUPER_UNREAD_MENTION_COUNT]),"number"==typeof n[Bt.NONSUPER_UNREAD_MESSAGE_COUNT]&&(r.nonSuperGroupChannelUnreadMessageCount=n[Bt.NONSUPER_UNREAD_MESSAGE_COUNT]),"number"==typeof n[Bt.NONSUPER_INVITATION_COUNT]&&(r.nonSuperGroupChannelInvitationCount=n[Bt.NONSUPER_INVITATION_COUNT]),r}return e(n,t),n}(P),yn=function(t){function n(e){var n=e.userId,r=t.call(this)||this;return r.method=D.GET,r.path="".concat(R,"/").concat(encodeURIComponent(n),"/unread_channel_count"),r}return e(n,t),n}(O),En=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}(P),Cn=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(R,"/").concat(encodeURIComponent(n),"/unread_message_count"),s.params={super_mode:null!=a?a:kt.ALL,custom_types:i},s}return e(n,t),n}(O),Nn=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}(P),bn=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(x,"/count"),i.params={channel_url:n,status:Tn(r)},s&&(i.params.message_type=s),i}return e(n,t),n}(O),Mn=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}(P),Tn=function(e){if(e){var t=[];return e.forEach((function(e){switch(e){case C.PENDING:t.push(H.PENDING);break;case C.SENT:t.push(H.IN_QUEUE),t.push(H.SENT);break;case C.CANCELED:t.push(H.CANCELED);break;case C.FAILED:t.push(H.FAILED)}})),t}},Sn=function(n){function r(e){var r=this,s=e.userId,i=e.channelUrl,a=e.coverUrl,o=e.coverImage,u=e.isDistinct,l=e.isSuper,c=e.isBroadcast,h=e.isPublic,p=e.isExclusive,_=e.isDiscoverable,m=e.isStrict,v=e.isEphemeral,g=e.accessCode,y=e.name,E=e.data,C=e.customType,N=e.messageSurvivalSeconds,b=e.invitedUserIds,M=e.operatorUserIds;return(r=n.call(this)||this).method=D.POST,r.path=F,r.params=t({user_ids:d([s],f(null!=b?b:[]),!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:l,is_broadcast:c,is_exclusive:p,is_public:h,is_discoverable:_,strict:m,is_ephemeral:v,access_code:g,name:y,data:E,custom_type:C,operator_ids:M,message_survival_seconds:N}),r}return e(r,n),r}(O),Un=function(t){function n(e,n){var r=t.call(this,e,n)||this;return r.channel=new ys(e,n),r.isCreated=n.is_created,r}return e(n,t),n}(P),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(R,"/").concat(encodeURIComponent(n),"/mark_as_read_all"),s.params={channel_urls:r},s}return e(n,t),n}(O);!function(t){function n(){return null!==t&&t.apply(this,arguments)||this}e(n,t)}(P);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(F,"/").concat(encodeURIComponent(r),"/join"),n.params={user_id:s,access_code:i},n}return e(n,t),n}(O),wn=function(t){function n(e,n){var r=t.call(this,e,n)||this;return r.channel=new ys(e,n),r}return e(n,t),n}(P),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?null:a,u=i.joined_member_count,l=void 0===u?null:u,c=i.users,h=void 0===c?null:c;return s.memberCount=o,s.joinedMemberCount=l,s.members=Array.isArray(h)?h.map((function(t){return new qt(e,t)})):[new qt(e,r.data)],s}return e(n,t),n}(Mt),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(F,"/").concat(encodeURIComponent(r),"/leave"),n.params={user_id:s,should_remove_operator_status:i},n}return e(n,t),n}(O);!function(t){function n(e,n){return t.call(this,e,n)||this}e(n,t)}(P);var Rn=function(t){function n(e,n,r){var s=t.call(this,e,n,r)||this,i=r.data,a=i.member_count,o=void 0===a?null:a,u=i.joined_member_count,l=void 0===u?null:u;return s.memberCount=o,s.joinedMemberCount=l,s.member=new qt(s._iid,r.data),s}return e(n,t),n}(Mt),On=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(F,"/").concat(encodeURIComponent(r),"/invite"),n.params={user_ids:s},n}return e(n,t),n}(O),Pn=function(t){function n(e,n){var r=t.call(this,e,n)||this;return r.channel=new ys(e,n),r}return e(n,t),n}(P),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?null:a,u=i.joined_member_count,c=void 0===u?null:u,h=i.inviter,d=void 0===h?null:h,f=i.invitees,p=void 0===f?[]:f;return s.memberCount=o,s.joinedMemberCount=c,s.inviter=d?new l(e,d):null,s.invitees=p.map((function(t){return new qt(e,t)})),s}return e(n,t),n}(Mt),Fn=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(F,"/").concat(encodeURIComponent(r),"/decline"),n.params={user_id:s},n}return e(n,t),n}(O),xn=function(t){function n(e,n){var r=t.call(this,e,n)||this;return r.channel=new ys(e,n),r.channel.myMemberState=Rt.NONE,r}return e(n,t),n}(P),Hn=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,h=i.inviter,d=void 0===h?null:h,f=i.invitee,p=void 0===f?null:f;return s.memberCount=o,s.joinedMemberCount=c,s.inviter=d?new l(e,d):null,s.invitee=p?new qt(e,p):null,s}return e(n,t),n}(Mt),Vn=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 Kt(e,r),s}return e(n,t),n}(q),qn=function(n){function r(e){var r=e.channelUrl,s=e.userId,i=n.call(this)||this;return(i=n.call(this)||this).method=D.PUT,i.path="".concat(F,"/").concat(encodeURIComponent(r),"/messages/mark_as_delivered"),i.params=t({userId:s}),i}return e(r,n),r}(O);!function(t){function n(){return null!==t&&t.apply(this,arguments)||this}e(n,t)}(P);var Kn,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),jn=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(F,"/").concat(encodeURIComponent(r),"/hide"),n.params={user_id:s,hide_previous_messages:i,allow_auto_unhide:a},n}return e(n,t),n}(O),Qn=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}(P),zn=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}(q),Wn=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 l(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 l(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,r){var s=t.call(this,e,"PEDI",r)||this;return s.event=null,s.status=null,s.channelUrl=null,s.channelType=null,s.event=new ke(e,r),s.status=K(r.poll.status)||r.poll.status,s.channelUrl=r.channel_url,s.channelType=r.channel_type,s}return e(n,t),n}(q),er=function(t){function n(e,n,r){var s=t.call(this,e,"VOTE",r)||this;return s.event=null,s.channelUrl=null,s.channelType=null,s.event=new Fe(r),s.channelUrl=r.channel_url,s.channelType=r.channel_type,s}return e(n,t),n}(q),tr=function(t){function n(e,n){var r,s,i,a,o,u,l,c,h,d,f,p,_,m,v,g,y,E,C,N,b,M,T=this;return(T=t.call(this,e,n)||this).includeEmpty=!1,T.includeFrozen=!0,T.includeMetaData=!0,T.channelUrlsFilter=null,T.customTypesFilter=null,T.customTypeStartsWithFilter=null,T.nicknameContainsFilter=null,T.nicknameStartsWithFilter=null,T.nicknameExactMatchFilter=null,T.channelNameContainsFilter="",T.myMemberStateFilter=Pt.ALL,T.unreadChannelFilter=Ft.ALL,T.superChannelFilter=kt.ALL,T.publicChannelFilter=Ot.ALL,T.hiddenChannelFilter=xt.UNHIDDEN,T.searchFilter={fields:[],query:null},T.userIdsFilter={userIds:[],includeMode:!0,queryType:Vt.AND},T.metadataKey=null,T.metadataValues=null,T.metadataOrderKeyFilter=null,T.metadataValueStartsWith=null,T.order=De.LATEST_LAST_MESSAGE,T.includeEmpty=null!==(r=n.includeEmpty)&&void 0!==r&&r,T.includeFrozen=null===(s=n.includeFrozen)||void 0===s||s,T.includeMetaData=null===(i=n.includeMetaData)||void 0===i||i,T.channelUrlsFilter=null!==(a=n.channelUrlsFilter)&&void 0!==a?a:null,T.customTypesFilter=null!==(o=n.customTypesFilter)&&void 0!==o?o:null,T.customTypeStartsWithFilter=null!==(u=n.customTypeStartsWithFilter)&&void 0!==u?u:"",T.nicknameContainsFilter=null!==(l=n.nicknameContainsFilter)&&void 0!==l?l:null,T.nicknameStartsWithFilter=null!==(c=n.nicknameStartsWithFilter)&&void 0!==c?c:null,T.nicknameExactMatchFilter=null!==(h=n.nicknameExactMatchFilter)&&void 0!==h?h:null,T.channelNameContainsFilter=null!==(d=n.channelNameContainsFilter)&&void 0!==d?d:"",T.myMemberStateFilter=null!==(f=n.myMemberStateFilter)&&void 0!==f?f:Pt.ALL,T.unreadChannelFilter=null!==(p=n.unreadChannelFilter)&&void 0!==p?p:Ft.ALL,T.superChannelFilter=null!==(_=n.superChannelFilter)&&void 0!==_?_:kt.ALL,T.publicChannelFilter=null!==(m=n.publicChannelFilter)&&void 0!==m?m:Ot.ALL,T.hiddenChannelFilter=null!==(v=n.hiddenChannelFilter)&&void 0!==v?v:xt.UNHIDDEN,T.searchFilter=null!==(g=n.searchFilter)&&void 0!==g?g:{fields:[],query:null},T.userIdsFilter=null!==(y=n.userIdsFilter)&&void 0!==y?y:{userIds:[],includeMode:!0,queryType:Vt.AND},T.metadataKey=null!==(E=n.metadataKey)&&void 0!==E?E:null,T.metadataValues=null!==(C=n.metadataValues)&&void 0!==C?C:null,T.metadataOrderKeyFilter=null!==(N=n.metadataOrderKeyFilter)&&void 0!==N?N:null,T.metadataValueStartsWith=null!==(b=n.metadataValueStartsWith)&&void 0!==b?b:null,T.order=null!==(M=n.order)&&void 0!==M?M:De.LATEST_LAST_MESSAGE,T}return e(n,t),n.prototype._validate=function(){return t.prototype._validate.call(this)&&g("boolean",this.includeEmpty)&&g("boolean",this.includeFrozen)&&g("boolean",this.includeMetaData)&&g("string",this.channelNameContainsFilter)&&v("string",this.channelUrlsFilter,!0)&&v("string",this.customTypesFilter,!0)&&g("string",this.customTypeStartsWithFilter)&&g("string",this.nicknameContainsFilter,!0)&&g("string",this.nicknameStartsWithFilter,!0)&&g("string",this.nicknameExactMatchFilter,!0)&&a(Pt,this.myMemberStateFilter)&&a(kt,this.superChannelFilter)&&a(Ot,this.publicChannelFilter)&&a(Ft,this.unreadChannelFilter)&&a(xt,this.hiddenChannelFilter)&&v(Gt,this.searchFilter.fields)&&g("string",this.searchFilter.query,!0)&&v("string",this.userIdsFilter.userIds)&&g("boolean",this.userIdsFilter.includeMode)&&a(Vt,this.userIdsFilter.queryType)&&a(De,this.order)&&g("string",this.metadataOrderKeyFilter,!0)&&g("string",this.metadataKey,!0)&&v("string",this.metadataValues,!0)&&g("string",this.metadataValueStartsWith,!0)},n.prototype.serialize=function(){return B(this)},n.prototype.next=function(){return p(this,void 0,void 0,(function(){var e,t,n;return _(this,(function(r){switch(r.label){case 0:return this._validate()?this._isLoading?[3,3]:this._hasNext?(this._isLoading=!0,[4,sr.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}(j),nr=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||U.unreadMentionCount>0)&&(U._updateUnreadCount(0,0),this._dispatcher.dispatch(new sn({channels:[U],source:$t.EVENT_CHANNEL_READ})),Z((function(){return p(fn,void 0,void 0,(function(){var e,t,n,r;return _(this,(function(s){try{for(e=m(this._groupChannelHandlers.values()),t=e.next();!t.done;t=e.next())t.value.onChannelChanged(U)}catch(e){n={error:e}}finally{try{t&&!t.done&&(r=e.return)&&r.call(e)}finally{if(n)throw n.error}}return[2]}))}))}))):0!==U.unreadMessageCount&&0!==U.unreadMentionCount||(this._dispatcher.dispatch(new sn({channels:[U],source:$t.EVENT_CHANNEL_READ})),Z((function(){return p(fn,void 0,void 0,(function(){var e,t,n,r;return _(this,(function(s){try{for(e=m(this._groupChannelHandlers.values()),t=e.next();!t.done;t=e.next())t.value.onChannelChanged(U)}catch(e){n={error:e}}finally{try{t&&!t.done&&(r=e.return)&&r.call(e)}finally{if(n)throw n.error}}return[2]}))}))}))):(this._dispatcher.dispatch(new sn({channels:[U],source:$t.EVENT_CHANNEL_READ})),Z((function(){return p(fn,void 0,void 0,(function(){var e,t,n,r;return _(this,(function(s){try{for(e=m(this._groupChannelHandlers.values()),t=e.next();!t.done;t=e.next())t.value.onUnreadMemberStatusUpdated(U)}catch(e){n={error:e}}finally{try{t&&!t.done&&(r=e.return)&&r.call(e)}finally{if(n)throw n.error}}return[2]}))}))}))),pn.label=12;case 12:return[3,75];case 13:return A=e.as(Bn),le=A.channelUrl,D=A.deliveredStateUpdate,R=void 0===D?{}:D,O=this._groupChannelCache.isCachedInMemory(le),[4,this.getChannel(le,!0)];case 14:if(P=pn.sent(),O)for(k in R)P._updateUndeliveredMemberState(k,R[k]);return this._dispatcher.dispatch(new sn({channels:[P],source:$t.EVENT_CHANNEL_DELIVERED})),Object.keys(R).some((function(e){return e!==fn._sdkState.userId}))&&Z((function(){return p(fn,void 0,void 0,(function(){var e,t,n,r;return _(this,(function(s){try{for(e=m(this._groupChannelHandlers.values()),t=e.next();!t.done;t=e.next())t.value.onUndeliveredMemberStatusUpdated(P)}catch(e){n={error:e}}finally{try{t&&!t.done&&(r=e.return)&&r.call(e)}finally{if(n)throw n.error}}return[2]}))}))})),[3,75];case 15:return F=e.as(It),le=F.channelUrl,ce=F.channelType,x=F.event,ce!==u.GROUP?[3,18]:[4,this.getChannel(le,!0)];case 16:return H=pn.sent(),[4,this.getMessageFromCache(x.messageId)];case 17:(q=pn.sent())&&(q.applyReactionEvent(x),this._dispatcher.dispatch(new w({messages:[q],source:$.EVENT_MESSAGE_REACTION_UPDATED}))),Z((function(){return p(fn,void 0,void 0,(function(){var e,t,n,r;return _(this,(function(s){try{for(e=m(this._groupChannelHandlers.values()),t=e.next();!t.done;t=e.next())t.value.onReactionUpdated(H,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]}))}))})),pn.label=18;case 18:return[3,75];case 19:return(V=e.as(At).event).channelType!==u.GROUP?[3,22]:[4,this.getChannel(V.channelUrl,!0)];case 20:return G=pn.sent(),[4,this.getMessageFromCache(V.targetMessageId)];case 21:(q=pn.sent())&&(q.applyThreadInfoUpdateEvent(V),this._dispatcher.dispatch(new w({messages:[q],source:$.EVENT_MESSAGE_THREADINFO_UPDATED}))),Z((function(){return p(fn,void 0,void 0,(function(){var e,t,n,r;return _(this,(function(s){try{for(e=m(this._groupChannelHandlers.values()),t=e.next();!t.done;t=e.next())t.value.onThreadInfoUpdated(G,V)}catch(e){n={error:e}}finally{try{t&&!t.done&&(r=e.return)&&r.call(e)}finally{if(n)throw n.error}}return[2]}))}))})),pn.label=22;case 22:return[3,75];case 23:K=e.as(Ut).groupChannelMemberCounts,B=[],pn.label=24;case 24:pn.trys.push([24,29,30,31]),j=m(K),Q=j.next(),pn.label=25;case 25:return Q.done?[3,28]:(z=Q.value,le=z.channelUrl,He=z.memberCount,Ve=z.joinedMemberCount,Y=z.updatedAt,[4,this.getChannelFromCache(le)]);case 26:(J=pn.sent())&&J._setLatestMemberCount(He,Ve,Y)&&B.push(J),pn.label=27;case 27:return Q=j.next(),[3,25];case 28:return[3,31];case 29:return te=pn.sent(),nn={error:te},[3,31];case 30:try{Q&&!Q.done&&(rn=j.return)&&rn.call(j)}finally{if(nn)throw nn.error}return[7];case 31:return B.length>0&&(this._dispatcher.dispatch(new sn({channels:B,source:$t.EVENT_CHANNEL_MEMBER_COUNT_UPDATED})),Z((function(){return p(fn,void 0,void 0,(function(){var e,t,n,r;return _(this,(function(s){try{for(e=m(this._groupChannelHandlers.values()),t=e.next();!t.done;t=e.next())t.value.onChannelMemberCountChanged(B)}catch(e){n={error:e}}finally{try{t&&!t.done&&(r=e.return)&&r.call(e)}finally{if(n)throw n.error}}return[2]}))}))}))),[3,75];case 32:return ne=e.as($n),se=ne.event,ie=ne.status,le=ne.channelUrl,ce=ne.channelType,le&&ce?[4,this.getChannel(le,!0)]:[3,75];case 33:return ae=pn.sent(),this._dispatcher.dispatch(new S({event:se,source:$.EVENT_POLL_UPDATED})),Z(ie===re?function(){return p(fn,void 0,void 0,(function(){var e,t,n,r;return _(this,(function(s){try{for(e=m(this._groupChannelHandlers.values()),t=e.next();!t.done;t=e.next())t.value.onPollDeleted(ae,se.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 p(fn,void 0,void 0,(function(){var e,t,n,r;return _(this,(function(s){try{for(e=m(this._groupChannelHandlers.values()),t=e.next();!t.done;t=e.next())t.value.onPollUpdated(ae,se)}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,75];case 34:return oe=e.as(er),ue=oe.event,le=oe.channelUrl,ce=oe.channelType,le&&ce?[4,this.getChannel(le,!0)]:[3,75];case 35:return he=pn.sent(),this._dispatcher.dispatch(new T({event:ue,source:$.EVENT_POLL_VOTED})),Z((function(){return p(fn,void 0,void 0,(function(){var e,t,n,r;return _(this,(function(s){try{for(e=m(this._groupChannelHandlers.values()),t=e.next();!t.done;t=e.next())t.value.onPollVoted(he,ue)}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,75];case 36:if(!(de=e.as(Mt).event).isGroupChannelEvent)return[3,73];switch(de.category){case Tt.CHANNEL_JOIN:return[3,37];case Tt.CHANNEL_LEAVE:return[3,39];case Tt.CHANNEL_OPERATOR_UPDATE:return[3,43];case Tt.CHANNEL_INVITE:return[3,45];case Tt.CHANNEL_DECLINE_INVITE:return[3,47];case Tt.TYPING_START:case Tt.TYPING_END:return[3,49];case Tt.USER_CHANNEL_MUTE:case Tt.USER_CHANNEL_UNMUTE:return[3,51];case Tt.USER_CHANNEL_BAN:return[3,53];case Tt.USER_CHANNEL_UNBAN:return[3,57];case Tt.CHANNEL_FREEZE:case Tt.CHANNEL_UNFREEZE:return[3,59];case Tt.CHANNEL_HIDE:return[3,61];case Tt.CHANNEL_UNHIDE:return[3,63];case Tt.CHANNEL_DELETED:return[3,65];case Tt.CHANNEL_PROP_CHANGED:return[3,67];case Tt.CHANNEL_META_DATA_CHANGED:return[3,69];case Tt.CHANNEL_META_COUNTERS_CHANGED:return[3,71]}return[3,73];case 37:return[4,this.getChannel(de.channelUrl,!0)];case 38:return fe=pn.sent(),pe=e.as(Ln),_e=pe.memberCount,me=pe.joinedMemberCount,ve=pe.members,ge=!1,ve.forEach((function(e){fe.isExclusive||fe.isSuper||fe.isBroadcast?ge=ge||fe._setLatestMemberCount(_e,me,de.ts):(e.state=Rt.JOINED,fe.addMember(e,de.ts),fn._updateJoinedMemberCount(fe)),e.userId===fn._sdkState.userId&&(fe.myMemberState=Rt.JOINED)})),this._dispatcher.dispatch(new sn({channels:[fe],source:$t.EVENT_CHANNEL_JOINED})),Z((function(){return p(fn,void 0,void 0,(function(){return _(this,(function(e){return this._groupChannelHandlers.forEach((function(e){var t,n;try{for(var r=m(ve),s=r.next();!s.done;s=r.next()){var i=s.value;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&&ge&&e.onChannelMemberCountChanged([fe])})),[2]}))}))})),[3,73];case 39:return(tt=this._leftChannels.get(de.channelUrl))?(Ee=tt.channel,[3,42]):[3,40];case 40:return[4,this.getChannel(de.channelUrl,!0)];case 41:Ee=pn.sent(),pn.label=42;case 42:return ye=Ee,Ce=e.as(Rn),He=Ce.memberCount,Ve=Ce.joinedMemberCount,Ne=Ce.member,be=!1,Me=W.of(this._iid).appInfo,ye.isExclusive||ye.isSuper||ye.isBroadcast?be=ye._setLatestMemberCount(He,Ve,de.ts):(Me.enabledChannelMemberShipHistory?(ye.members.find((function(e){return e.userId===Ne.userId})).state=Rt.LEFT,ye.memberCount=He):ye.removeMember(Ne),this._updateJoinedMemberCount(ye)),Ne.userId===this._sdkState.userId?(ye.myMemberState=Rt.NONE,ye.invitedAt=0,ye.joinedAt=0,ye._updateUnreadCount(0,0),ye.isPublic?this._dispatcher.dispatch(new sn({channels:[ye],source:$t.EVENT_CHANNEL_LEFT})):(this._markAsLeave(ye),this._dispatcher.dispatch(new an({channelUrls:[ye.url],source:$t.EVENT_CHANNEL_LEFT})))):this._dispatcher.dispatch(new sn({channels:[ye],source:$t.EVENT_CHANNEL_LEFT})),Z((function(){return p(fn,void 0,void 0,(function(){return _(this,(function(e){return this._groupChannelHandlers.forEach((function(e){e.onUserLeft(ye,Ne),ye.isBroadcast&&be&&e.onChannelMemberCountChanged([ye])})),[2]}))}))})),[3,73];case 43:return[4,this.getChannel(de.channelUrl,!0)];case 44:Te=pn.sent(),Se=e.as(St).operators,Ue=Se.map((function(e){return e.userId}));try{for(Ae=m(Te.members),Ie=Ae.next();!Ie.done;Ie=Ae.next())(et=Ie.value).role=Ue.includes(et.userId)?o.OPERATOR:o.NONE}catch(e){on={error:e}}finally{try{Ie&&!Ie.done&&(un=Ae.return)&&un.call(Ae)}finally{if(on)throw on.error}}return Te.myRole=Ue.includes(this._sdkState.userId)?o.OPERATOR:o.NONE,this._dispatcher.dispatch(new sn({channels:[Te],source:$t.EVENT_CHANNEL_OPERATOR_UPDATED})),Z((function(){return p(fn,void 0,void 0,(function(){return _(this,(function(e){return this._groupChannelHandlers.forEach((function(e){e.onOperatorUpdated(Te,Se)})),[2]}))}))})),[3,73];case 45:return[4,this.getChannel(de.channelUrl,!0)];case 46:we=pn.sent(),Le=e.as(kn),He=Le.memberCount,Ve=Le.joinedMemberCount,De=Le.inviter,(Re=Le.invitees).forEach((function(e){return e.state=Rt.INVITED}));try{for(Oe=m(Re),Pe=Oe.next();!Pe.done;Pe=Oe.next())ke=Pe.value,we.isExclusive||we.isSuper||we.isBroadcast?we._setLatestMemberCount(He,Ve,de.ts):we.addMember(ke,de.ts),this._sdkState.userId===ke.userId&&(we.hiddenState=ms.UNHIDDEN,we.myMemberState!==Rt.JOINED&&(we.myMemberState=Rt.INVITED),we.invitedAt=de.ts)}catch(e){ln={error:e}}finally{try{Pe&&!Pe.done&&(cn=Oe.return)&&cn.call(Oe)}finally{if(ln)throw ln.error}}return this._dispatcher.dispatch(new sn({channels:[we],source:$t.EVENT_CHANNEL_INVITED})),Z((function(){return p(fn,void 0,void 0,(function(){return _(this,(function(e){return this._groupChannelHandlers.forEach((function(e){e.onUserReceivedInvitation(we,De,Re)})),[2]}))}))})),[3,73];case 47:return[4,this.getChannel(de.channelUrl,!0)];case 48:return Fe=pn.sent(),xe=e.as(Hn),He=xe.memberCount,Ve=xe.joinedMemberCount,Be=xe.inviter,je=xe.invitee,Fe.isExclusive||Fe.isSuper||Fe.isBroadcast?Fe._setLatestMemberCount(He,Ve,de.ts):Fe.removeMember(je),this._sdkState.userId===je.userId?(Fe.invitedAt=0,Fe.myMemberState=Rt.NONE,Fe.isPublic?this._dispatcher.dispatch(new sn({channels:[Fe],source:$t.EVENT_CHANNEL_DECLINED_INVITE})):this._dispatcher.dispatch(new an({channelUrls:[Fe.url],source:$t.EVENT_CHANNEL_DECLINED_INVITE}))):this._dispatcher.dispatch(new sn({channels:[Fe],source:$t.EVENT_CHANNEL_DECLINED_INVITE})),Z((function(){return p(fn,void 0,void 0,(function(){return _(this,(function(e){return this._groupChannelHandlers.forEach((function(e){e.onUserDeclinedInvitation(Fe,Be,je)})),[2]}))}))})),[3,73];case 49:return[4,this.getChannel(de.channelUrl,!0)];case 50:return Qe=pn.sent(),ze=de.category===Tt.TYPING_START,We=e.as(ze?Yn:Xn).user,Qe._updateTypingStatus(We,ze?de.ts:0),this._dispatcher.dispatch(new sn({channels:[Qe],source:$t.EVENT_CHANNEL_TYPING_STATUS_UPDATE})),Z((function(){return p(fn,void 0,void 0,(function(){return _(this,(function(e){return this._groupChannelHandlers.forEach((function(e){e.onTypingStatusUpdated(Qe)})),[2]}))}))})),[3,73];case 51:return[4,this.getChannel(de.channelUrl,!0)];case 52:Ye=pn.sent(),Je=de.category===Tt.USER_CHANNEL_MUTE,(Xe=e.as(Je?ht:dt).user).userId===this._sdkState.userId&&(Ye.myMutedState=Je?_s.MUTED:_s.UNMUTED);try{for(Ze=m(Ye.members),$e=Ze.next();!$e.done;$e=Ze.next())if((et=$e.value).userId===Xe.userId){et.isMuted=Je;break}}catch(e){hn={error:e}}finally{try{$e&&!$e.done&&(dn=Ze.return)&&dn.call(Ze)}finally{if(hn)throw hn.error}}return this._dispatcher.dispatch(new sn({channels:[Ye],source:Je?$t.EVENT_CHANNEL_MUTED:$t.EVENT_CHANNEL_UNMUTED})),Z((function(){return p(fn,void 0,void 0,(function(){return _(this,(function(e){return this._groupChannelHandlers.forEach((function(e){Je?e.onUserMuted(Ye,Xe):e.onUserUnmuted(Ye,Xe)})),[2]}))}))})),[3,73];case 53:return(tt=this._leftChannels.get(de.channelUrl))?(rt=tt.channel,[3,56]):[3,54];case 54:return[4,this.getChannel(de.channelUrl,!0)];case 55:rt=pn.sent(),pn.label=56;case 56:return nt=rt,this._markAsLeave(nt),st=e.as(ct).user,Z((function(){return p(fn,void 0,void 0,(function(){return _(this,(function(e){return this._groupChannelHandlers.forEach((function(e){e.onUserBanned(nt,st)})),[2]}))}))})),[3,73];case 57:return[4,this.getChannel(de.channelUrl,!0)];case 58:return it=pn.sent(),vt=e.as(lt).user,Z((function(){return p(fn,void 0,void 0,(function(){return _(this,(function(e){return this._groupChannelHandlers.forEach((function(e){e.onUserUnbanned(it,vt)})),[2]}))}))})),[3,73];case 59:return[4,this.getChannel(de.channelUrl,!0)];case 60:return gt=pn.sent(),yt=e.as(ut).freeze,gt.isFrozen=yt,this._dispatcher.dispatch(new sn({channels:[gt],source:yt?$t.EVENT_CHANNEL_FROZEN:$t.EVENT_CHANNEL_UNFROZEN})),Z((function(){return p(fn,void 0,void 0,(function(){return _(this,(function(e){return this._groupChannelHandlers.forEach((function(e){yt?e.onChannelFrozen(gt):e.onChannelUnfrozen(gt)})),[2]}))}))})),[3,73];case 61:return[4,this.getChannel(de.channelUrl,!0)];case 62:return Et=pn.sent(),Ct=e.as(zn),Nt=Ct.allowAutoUnhide,bt=Ct.hidePreviousMessages,Dt=Ct.messageOffsetTimestamp,null!==Nt&&(Et.hiddenState=Nt?ms.HIDDEN_ALLOW_AUTO_UNHIDE:ms.HIDDEN_PREVENT_AUTO_UNHIDE),null!==bt&&bt&&Et._updateUnreadCount(0,0),null!==Dt&&(Et.messageOffsetTimestamp=Dt),this._dispatcher.dispatch(new sn({channels:[Et],source:$t.EVENT_CHANNEL_HIDDEN})),Z((function(){return p(fn,void 0,void 0,(function(){return _(this,(function(e){return this._groupChannelHandlers.forEach((function(e){e.onChannelHidden(Et)})),[2]}))}))})),[3,73];case 63:return[4,this.getChannel(de.channelUrl,!0)];case 64:return(Ot=pn.sent()).hiddenState=ms.UNHIDDEN,this._dispatcher.dispatch(new sn({channels:[Ot],source:$t.EVENT_CHANNEL_UNHIDDEN})),Z((function(){return p(fn,void 0,void 0,(function(){return _(this,(function(e){return this._groupChannelHandlers.forEach((function(e){e.onChannelChanged(Ot)})),[2]}))}))})),[3,73];case 65:return[4,this.getChannel(de.channelUrl,!0)];case 66:return Pt=pn.sent(),this._dispatcher.dispatch(new an({channelUrls:[de.channelUrl],source:$t.EVENT_CHANNEL_DELETED})),Z((function(){return p(fn,void 0,void 0,(function(){return _(this,(function(e){return this._groupChannelHandlers.forEach((function(e){e.onChannelDeleted(Pt.url,Pt.channelType)})),[2]}))}))})),[3,73];case 67:return[4,this.getChannelWithoutCache(de.channelUrl,!0)];case 68:return kt=pn.sent(),this._dispatcher.dispatch(new sn({channels:[kt],source:$t.EVENT_CHANNEL_UPDATED})),Z((function(){return p(fn,void 0,void 0,(function(){return _(this,(function(e){return this._groupChannelHandlers.forEach((function(e){e.onChannelChanged(kt)})),[2]}))}))})),[3,73];case 69:return[4,this.getChannel(de.channelUrl,!0)];case 70:return Ft=pn.sent(),xt=e.as(ot),Ht=xt.created,Vt=xt.updated,Gt=xt.deleted,Ht&&Ft._upsertCachedMetaData(Ht,de.ts),Vt&&Ft._upsertCachedMetaData(Vt,de.ts),Gt&&Ft._removeFromCachedMetaData(Gt,de.ts),Z((function(){return p(fn,void 0,void 0,(function(){return _(this,(function(e){return this._groupChannelHandlers.forEach((function(e){Ht&&e.onMetaDataCreated(Ft,Ht),Vt&&e.onMetaDataUpdated(Ft,Vt),Gt&&e.onMetaDataDeleted(Ft,Gt)})),[2]}))}))})),[3,73];case 71:return[4,this.getChannel(de.channelUrl,!0)];case 72:return qt=pn.sent(),Kt=e.as(at),Bt=Kt.created,jt=Kt.updated,Qt=Kt.deleted,Z((function(){return p(fn,void 0,void 0,(function(){return _(this,(function(e){return this._groupChannelHandlers.forEach((function(e){Bt&&e.onMetaCounterCreated(qt,Bt),jt&&e.onMetaCounterUpdated(qt,jt),Qt&&e.onMetaCounterDeleted(qt,Qt)})),[2]}))}))})),[3,73];case 73:return[3,75];case 74:switch((zt=e.as(Ge).event).category){case qe.USER_BLOCK:Wt=Ke.getDataAsUserBlockEvent(this._iid,zt),Jt=Wt.blocker,Xt=Wt.blockee,this._groupChannelCache.block(Jt.userId,Xt.userId);break;case qe.USER_UNBLOCK:Yt=Ke.getDataAsUserBlockEvent(this._iid,zt),Jt=Yt.blocker,Xt=Yt.blockee,this._groupChannelCache.unblock(Jt.userId,Xt.userId)}return[3,75];case 75:return[3,77];case 76:if(Zt=pn.sent(),X(Zt))throw Zt;return[3,77];case 77: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===Rt.JOINED})).length},e.prototype.getChannel=function(e,t){return void 0===t&&(t=!1),p(this,void 0,void 0,(function(){var n;return _(this,(function(r){switch(r.label){case 0:te(g("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),p(this,void 0,void 0,(function(){var n,r,s,i,a;return _(this,(function(o){switch(o.label){case 0:return te(g("string",e)).throw(Q.invalidParameters),n=new hn({channelUrl:e,isInternalCall:t}),[4,this._requestQueue.send(n)];case 1:switch(r=o.sent(),s=r.as(dn).channel,i=s.unreadMessageCount,a=s.unreadMentionCount,s.myCountPreference){case ps.UNREAD_MESSAGE_COUNT_ONLY:a=0;break;case ps.UNREAD_MENTION_COUNT_ONLY:i=0;break;case ps.OFF:i=0,a=0}return s._updateUnreadCount(i,a),[4,this._groupChannelCache.upsert([s])];case 2:return o.sent(),[2,s]}}))}))},e.prototype.getMyGroupChannels=function(e,t,r,s){return void 0===s&&(s=$t.REQUEST_CHANNEL),p(this,void 0,void 0,(function(){var i,a,o,u,l;return _(this,(function(c){switch(c.label){case 0:return i=new fn(n(n({},t),{userId:this._sdkState.userId,token:e,limit:r})),[4,this._requestQueue.send(i)];case 1:return a=c.sent(),o=a.as(pn),u=o.channels,l=o.token,this._dispatcher.dispatch(new sn({channels:u,source:s})),[2,{channels:u,token:l}]}}))}))},e.prototype.getMessageFromCache=function(e){return p(this,void 0,void 0,(function(){return _(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=Be),p(this,void 0,void 0,(function(){return _(this,(function(i){switch(i.label){case 0:return[4,this._messageCache.fetch({channelUrl:e,token:t,limit:s,filter:r,backward:"next"===n})];case 1:return[2,i.sent()]}}))}))},e.prototype.getAllFailedMessagesFromCache=function(e,t){return p(this,void 0,void 0,(function(){return _(this,(function(n){switch(n.label){case 0:return[4,this._unsentMessageCache.fetch({channelUrl:e,filter:t,sendingStatus:ne.FAILED})];case 1:return[2,n.sent()]}}))}))},e.prototype.removeFailedMessageFromCache=function(e){return p(this,void 0,void 0,(function(){return _(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 p(this,void 0,void 0,(function(){return _(this,(function(s){switch(s.label){case 0:return[4,this._messageCache.countBetween(e,t,new nr({top:n,bottom:r}))];case 1:return[2,s.sent()]}}))}))},e.prototype.getMyGroupChannelChangeLogs=function(e,r,s){return void 0===s&&(s=$t.REQUEST_CHANNEL_CHANGELOGS),p(this,void 0,void 0,(function(){var i,a,o,u,l,c;return _(this,(function(h){switch(h.label){case 0:return i=n(n({},Yt),r),te((g("string",e)||g("number",e))&&Jt(i)).throw(Q.invalidParameters),a=new ln(t({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=h.sent(),u=o.as(cn),l=u.updatedChannels,c=u.deletedChannelUrls,l.length>0&&this._dispatcher.dispatch(new sn({channels:l,source:s})),c.length>0&&this._dispatcher.dispatch(new an({channelUrls:c,source:s})),[2,u]}}))}))},e.prototype.getGroupChannelCount=function(e){return p(this,void 0,void 0,(function(){var t,r,s;return _(this,(function(i){switch(i.label){case 0:return t=n(n({},Xt),e),te(Zt(t)).throw(Q.invalidParameters),r=new _n({userId:this._sdkState.userId,filter:t}),[4,this._requestQueue.send(r)];case 1:return s=i.sent(),[2,s.as(mn).groupChannelCount]}}))}))},e.prototype.getUnreadItemCount=function(e){return p(this,void 0,void 0,(function(){var t,r,s,i,a;return _(this,(function(o){switch(o.label){case 0:return t=n(n({},en),e),te(function(e){return v(Bt,e.keys)}(t)).throw(Q.invalidParameters),r=W.of(this._iid),s=r.sdkState,i=r.requestQueue,a=new vn({userId:s.userId,filter:t}),[4,i.send(a)];case 1:return[2,o.sent().as(gn)]}}))}))},e.prototype.getTotalUnreadChannelCount=function(){return p(this,void 0,void 0,(function(){var e,t,n,r,s;return _(this,(function(i){switch(i.label){case 0:return e=W.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(En).unreadCount]}}))}))},e.prototype.getTotalUnreadMessageCount=function(e){return p(this,void 0,void 0,(function(){var t,r,s,i,o,u;return _(this,(function(l){switch(l.label){case 0:return t=n(n({},tn),e),te(function(e){return v("string",e.channelCustomTypesFilter,!0)&&a(kt,e.superChannelFilter)}(t)).throw(Q.invalidParameters),r=W.of(this._iid),s=r.sdkState,i=r.requestQueue,o=new Cn({userId:s.userId,filter:t}),[4,i.send(o)];case 1:return u=l.sent(),[2,u.as(Nn).unreadCount]}}))}))},e.prototype.getTotalScheduledMessageCount=function(e){return void 0===e&&(e={}),p(this,void 0,void 0,(function(){var t,r,s,i;return _(this,(function(o){switch(o.label){case 0:return t=n(n({},nn),e),te(function(e){return g("string",e.channelUrl,!0)&&v(C,e.scheduledStatus,!0)&&a(E,e.messageTypeFilter)}(t)).throw(Q.invalidParameters),r=W.of(this._iid).requestQueue,s=new bn(t),[4,r.send(s)];case 1:return i=o.sent(),[2,i.as(Mn).count]}}))}))},e.prototype.getSubscribedTotalUnreadMessageCount=function(){var e=W.of(this._iid).subscribedUnreadMessageCount;return e.all>=0?e.all:0},e.prototype.getSubscribedCustomTypeTotalUnreadMessageCount=function(){var e=0,t=W.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=W.of(this._iid).subscribedUnreadMessageCount.customTypes[e])&&void 0!==t?t:0},e.prototype.createChannel=function(e){return p(this,void 0,void 0,(function(){var t,r,s,i;return _(this,(function(a){switch(a.label){case 0:return t=n(n({},zt),e),te(Wt(t)).throw(Q.invalidParameters),t.isPublic||(t.accessCode=null),r=new Sn(n({userId:this._sdkState.userId},t)),[4,this._requestQueue.send(r)];case 1:return s=a.sent(),i=s.as(Un).channel,[4,this._groupChannelCache.upsert([i])];case 2:return a.sent(),[2,i]}}))}))},e.prototype.markAsReadAll=function(){return p(this,void 0,void 0,(function(){var e,t,n,r,s,i,a,o;return _(this,(function(u){switch(u.label){case 0:return e=Date.now(),te(e-this._markAsReadAllLastSentAt>=1e3).throw(Q.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=m(n),s=r.next();!s.done;s=r.next())(i=s.value)._updateUnreadMemberState(this._sdkState.userId,e),i._updateUnreadCount(0,0)}catch(e){a={error:e}}finally{try{s&&!s.done&&(o=r.return)&&o.call(r)}finally{if(a)throw a.error}}return n.length>0?[4,this._groupChannelCache.upsert(n)]:[3,3];case 2:u.sent(),u.label=3;case 3:return[2]}}))}))},e.prototype.markAsReadWithChannelUrls=function(e){return p(this,void 0,void 0,(function(){var t,n,r,s,i,a,o,u,l;return _(this,(function(c){switch(c.label){case 0:return t=Date.now(),te(v("string",e)&&t-this._markAsReadAllLastSentAt>=1e3).throw(Q.markAsReadAllRateLimitExceeded),this._markAsReadAllLastSentAt=t,n=new An({userId:this._sdkState.userId,channelUrls:e}),[4,this._requestQueue.send(n)];case 1:c.sent(),r=this._groupChannelCache.channels,s=[];try{for(i=m(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&&(l=i.return)&&l.call(i)}finally{if(u)throw u.error}}return s.length>0?[4,this._groupChannelCache.upsert(s)]:[3,3];case 2:c.sent(),c.label=3;case 3:return[2]}}))}))},e.prototype.markAsDelivered=function(e){return p(this,void 0,void 0,(function(){return _(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}(),ir=new Map,ar=new Map,or=new Map,ur=function(){function e(t){var n=t.key,r=t.concurrentCallLimit,s=void 0===r?2:r,i=t.backOffDelay,a=void 0===i?0:i,o=this;this._holdersKey=e.createSemaphoreHoldersKey(n),this._resolversKey=e.createSemaphoreResolversKey(n),this._chainProcessStateKey=e.createChainProcessStateKey(n),this._numLocks=s,this._backOffDelay=a,this._localAcquiredKeys=[],this._localResolversData=[],se()?(ir[this._holdersKey]||(ir[this._holdersKey]=[]),ar[this._resolversKey]||(ar[this._resolversKey]=[])):(window.addEventListener("storage",(function(e){return p(o,void 0,void 0,(function(){var t,n;return _(this,(function(r){if(this._localResolversData.length>0&&this.numLocksAvailable>0&&!this._isProcessChainAcquireRunning()&&this._hasHighestPriorityResolver())switch(e.key){case this._holdersKey:if(t=JSON.parse(e.oldValue),n=JSON.parse(e.newValue),!t||!n||n.length>=t.length)return[2];this._processChainResolve();break;case this._chainProcessStateKey:if(JSON.parse(e.newValue))return[2];this._processChainResolve();break;default:return[2]}return[2]}))}))})),window.addEventListener("beforeunload",(function(){var e=o._getLocalResolversData(),t=o._localResolversData.map((function(e){return e.key})),n=e.filter((function(e){return t.indexOf(e.key)<0}));window.localStorage.setItem(o._resolversKey,JSON.stringify(n)),o._localAcquiredKeys.forEach((function(e){return o.release(e)}))})))}return e.createSemaphoreHoldersKey=function(e){return"collection@semaphore_holders_for:"+e},e.createSemaphoreResolversKey=function(e){return"collection@semaphore_resolvers_for:"+e},e.createChainProcessStateKey=function(e){return"collection@semaphore_chain_process_state_for:"+e},Object.defineProperty(e.prototype,"numLocks",{get:function(){return this._numLocks},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"backOffDelay",{get:function(){return this._backOffDelay},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"numLocksAvailable",{get:function(){if(se())return this.numLocks-ir[this._holdersKey].length;var e=this._getLocalHoldersData();return this.numLocks-e.length},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"waitCount",{get:function(){return se()?ar[this._resolversKey].length:this._getLocalResolversData().length},enumerable:!1,configurable:!0}),e.prototype._hasHighestPriorityResolver=function(){var e=this._getLocalResolversData();return e.length>0&&this._localResolversData.map((function(e){return e.key})).indexOf(e[0].key)>=0},e.prototype._isProcessChainAcquireRunning=function(){if(se())return or[this._chainProcessStateKey];var e=window.localStorage[this._chainProcessStateKey];return void 0!==e&&JSON.parse(e)},e.prototype._setProcessChainAcquireRunning=function(e){se()?or[this._chainProcessStateKey]=e:e?window.localStorage.setItem(this._chainProcessStateKey,JSON.stringify(e)):window.localStorage.removeItem(this._chainProcessStateKey)},e.prototype._processChainResolve=function(){return p(this,void 0,void 0,(function(){var e;return _(this,(function(t){switch(t.label){case 0:return this.waitCount>0&&this.numLocksAvailable>0&&!this._isProcessChainAcquireRunning()?(this._setProcessChainAcquireRunning(!0),this._tryResolve()?[4,ae(this._backOffDelay)]:[3,2]):[3,3];case 1:t.sent(),t.label=2;case 2:this._setProcessChainAcquireRunning(!1),se()?this._processChainResolve():(e=new StorageEvent("storage",{key:this._chainProcessStateKey,oldValue:JSON.stringify(!0),newValue:JSON.stringify(!1)}),dispatchEvent(e)),t.label=3;case 3:return[2]}}))}))},e.prototype.acquire=function(e){return void 0===e&&(e=0),p(this,void 0,void 0,(function(){var t,n=this;return _(this,(function(r){return se()?[2,new Promise((function(t){for(var r={key:ie(),resolver:function(e){return t(e)},priority:e},s=ar[n._resolversKey],i=-1,a=0;as[a].priority){i=a;break}i>=0?ar[n._resolversKey].splice(i,0,r):ar[n._resolversKey].push(r),n._processChainResolve()}))]:(t=this._getLocalResolversData(),[2,new Promise((function(r){for(var s=ie(),i={key:s,priority:e},a={key:s,resolver:function(e){return r(e)},priority:e},o=-1,u=0;ut[u].priority){o=u;break}o>=0?(t.splice(o,0,i),n._localResolversData.splice(o,0,a)):(t.push(i),n._localResolversData.push(a)),window.localStorage.setItem(n._resolversKey,JSON.stringify(t)),n._processChainResolve()}))])}))}))},e.prototype.release=function(e){if(se()){if((t=ir[this._holdersKey].indexOf(e))>=0)return ir[this._holdersKey].splice(t,1),this._processChainResolve(),!0}else if(window.localStorage[this._holdersKey]){var t,n=JSON.parse(window.localStorage[this._holdersKey]),r=d([],f(n),!1);if((t=n.indexOf(e))>=0){n.splice(t,1),window.localStorage.setItem(this._holdersKey,JSON.stringify(n)),this._localAcquiredKeys.splice(this._localAcquiredKeys.indexOf(e),1);var s=new StorageEvent("storage",{key:this._holdersKey,oldValue:JSON.stringify(r),newValue:JSON.stringify(n)});return dispatchEvent(s),!0}}return!1},e.prototype._tryResolve=function(){if(se()){if(ir[this._holdersKey].length=100,t.nextToken=this._metadata.range.top,this._metadata.previousComplete=!t.hasNext,u.debug("message background prev sync progress",t),[4,this.saveMetadata()];case 4:return o.sent(),[3,8];case 5:return r=o.sent(),u.debug("message background prev sync error",r),r instanceof Q&&r.isInvalidTokenError?[4,this.clearMetadata()]:[3,7];case 6:o.sent(),o.label=7;case 7:throw r;case 8:return[3,10];case 9:t.hasNext=!1,o.label=10;case 10:return[2,t]}}))}))})),this._nextSync=new cr(l,(function(e){return p(r,void 0,void 0,(function(){var t,n,r,s,i,a;return _(this,(function(o){switch(o.label){case 0:return t={hasNext:!0,nextToken:0},[4,this.loadMetadata()];case 1:o.sent(),u.debug("message background next sync from",null===(s=this._metadata)||void 0===s?void 0:s.range.bottom),o.label=2;case 2:return o.trys.push([2,5,,6]),[4,ce.of(this._iid).getMessagesByTimestamp(this._channel.url,this._channel.channelType,null!==(a=null===(i=this._metadata.range)||void 0===i?void 0:i.bottom)&&void 0!==a?a:e,{prevResultSize:0,nextResultSize:100,replyType:he.ALL,includeReactions:!0,includeMetaArray:!0,includeParentMessageInfo:!0,includeThreadInfo:!0},$.SYNC_MESSAGE_BACKGROUND)];case 3:return n=o.sent(),this.extendRange(n),t.hasNext=n.length>=100,t.nextToken=this._metadata.range.bottom,u.debug("message background next sync progress",t),[4,this.saveMetadata()];case 4:return o.sent(),[3,6];case 5:throw r=o.sent(),u.debug("message background next sync error",r),r;case 6:return[2,t]}}))}))}))}return e.of=function(t,n){if(fr[t]||(fr[t]={}),!fr[t][n.url]){var r=fr[t][n.url]=new e({_iid:t,channel:n});W.of(t).dispatcher.on((function(e){if(e instanceof ue)if(e.stateType===le.CONNECTED)r.resume();else r.pause()}))}return fr[t][n.url]},Object.defineProperty(e.prototype,"range",{get:function(){var e;return null===(e=this._metadata)||void 0===e?void 0:e.range},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"previousComplete",{get:function(){var e;return!!(null===(e=this._metadata)||void 0===e?void 0:e.previousComplete)},enumerable:!1,configurable:!0}),e.prototype.isWrappingMessages=function(e){var t;return null===(t=this.range)||void 0===t?void 0:t.includes.apply(t,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(){return p(this,void 0,void 0,(function(){var e;return _(this,(function(t){switch(t.label){case 0:return this._metadata?[3,2]:[4,W.of(this._iid).cacheContext.preference.get(this._metadataKey)];case 1:e=t.sent(),this._metadata={range:new nr(e?e.range:{top:Number.MAX_SAFE_INTEGER,bottom:Number.MAX_SAFE_INTEGER}),previousComplete:!!e&&e.previousComplete},t.label=2;case 2:return[2]}}))}))},e.prototype.saveMetadata=function(){return p(this,void 0,void 0,(function(){return _(this,(function(e){switch(e.label){case 0:return this._metadata?[4,W.of(this._iid).cacheContext.preference.set(this._metadataKey,this._metadata)]:[3,2];case 1:e.sent(),e.label=2;case 2:return[2]}}))}))},e.prototype.clearMetadata=function(){return p(this,void 0,void 0,(function(){return _(this,(function(e){switch(e.label){case 0:return[4,W.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,r;W.of(this._iid).logger.debug("message background sync resume()"),this._metadata&&this._metadata.previousComplete||this._prevSync.start(null!==(t=null===(e=this._metadata)||void 0===e?void 0:e.range.top)&&void 0!==t?t:Date.now()),this._nextSync.start(null!==(r=null===(n=this._metadata)||void 0===n?void 0:n.range.bottom)&&void 0!==r?r:Date.now())},e.prototype.pause=function(){W.of(this._iid).logger.debug("message background sync stop()"),this._prevSync.stop(),this._nextSync.stop()},e}(),_r={},mr=function(){function e(e){var t=e._iid,n=e.channel,r=this;this._sync=null,this._metadata=null,this._iid=t,this._channel=n;var s,i,a=W.of(this._iid),o=a.logger,u=a.sdkState;this._metadataKey=(s=u.userId,i=n.url,"sendbird:".concat(s,"@groupchannel/").concat(i,"/message/changelogs.meta"));var l=function(e,t){return"sendbird:".concat(e,"@groupchannel/").concat(t,"/message/changelogs")}(u.userId,this._channel.url);this._sync=new cr(l,(function(){return p(r,void 0,void 0,(function(){var e,t,n,r,s,i;return _(this,(function(a){switch(a.label){case 0:return e={hasNext:!0,nextToken:0},[4,this.loadMetadata()];case 1:a.sent(),o.debug("message changelog sync from",null===(i=this._metadata)||void 0===i?void 0:i.token),a.label=2;case 2:return a.trys.push([2,5,,8]),[4,ce.of(this._iid).getMessageChangelogs(this._channel.url,this._channel.channelType,this._metadata.token,{replyType:he.ALL,includeReactions:!0,includeThreadInfo:!0,includeMetaArray:!0,includeParentMessageInfo:!0},$.SYNC_MESSAGE_CHANGELOGS)];case 3:return t=a.sent(),n=t.hasMore,r=t.token,e.hasNext=n,e.nextToken=r,this._metadata.token=r,o.debug("message changelog sync progress",e),[4,this.saveMetadata()];case 4:return a.sent(),[3,8];case 5:return s=a.sent(),o.debug("message 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]}}))}))}))}return e.of=function(t,n){if(_r[t]||(_r[t]={}),!_r[t][n.url]){var r=_r[t][n.url]=new e({_iid:t,channel:n});W.of(t).dispatcher.on((function(e){if(e instanceof ue)if(e.stateType===le.CONNECTED)r.resume();else r.pause()}))}return _r[t][n.url]},e.prototype.loadMetadata=function(){return p(this,void 0,void 0,(function(){var e,t,n,r;return _(this,(function(s){switch(s.label){case 0:return this._metadata?[3,2]:(e=W.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/1e3},s.label=2;case 2:return[2]}}))}))},e.prototype.saveMetadata=function(){return p(this,void 0,void 0,(function(){return _(this,(function(e){switch(e.label){case 0:return this._metadata?[4,W.of(this._iid).cacheContext.preference.set(this._metadataKey,this._metadata)]:[3,2];case 1:e.sent(),e.label=2;case 2:return[2]}}))}))},e.prototype.clearMetadata=function(){return p(this,void 0,void 0,(function(){return _(this,(function(e){switch(e.label){case 0:return[4,W.of(this._iid).cacheContext.preference.remove(this._metadataKey)];case 1:return e.sent(),this._metadata=null,[2]}}))}))},e.prototype.resume=function(){W.of(this._iid).logger.debug("message changelog sync resume()"),this._sync.start(0)},e.prototype.pause=function(){W.of(this._iid).logger.debug("message changelog sync pause()"),this._sync.stop()},e}(),vr=function(n){function r(e){var r,s,i,a,o,u,l=this;return(l=n.call(this)||this).method=D.GET,l.path="".concat(de(e.channelType),"/").concat(e.channelUrl,"/messages_gap"),l.params=t({prev_start_ts:e.prevStart,prev_end_ts:e.prevEnd,prev_cache_count:e.prevCount,next_start_ts:e.nextStart,next_end_ts:e.nextEnd,next_cache_count:e.nextCount,huge_gap_threshold:null!==(r=e.threshold)&&void 0!==r?r:null,reverse:!0,custom_types:null!==(s=e.customTypes)&&void 0!==s?s:["*"],message_type:null!==(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}),l}return e(r,n),r}(O),gr=function(t){function n(e,n){var r,s,i,a,o=this;return(o=t.call(this,e,n)||this).isHugeGap=n.is_huge_gap,o.prevMessages=(null!==(r=n.prev_messages)&&void 0!==r?r:[]).map((function(t){return fe(e,t)})),o.prevHasMore=null!==(s=n.prev_hasmore)&&void 0!==s&&s,o.nextMessages=(null!==(i=n.next_messages)&&void 0!==i?i:[]).map((function(t){return fe(e,t)})),o.nextHasmore=null!==(a=n.next_hasmore)&&void 0!==a&&a,o}return e(n,t),n}(P),yr=function(e,t){return e.findIndex((function(e){return e.isIdentical(t)}))},Er=function(e,t,n){if(e.length>0){var r=yr(e,t);if(r<0){for(var s=0,i=e.length-1,a=Math.floor((s+i)/2);s0)i=a,a=Math.floor((s+i)/2);else{if(!(o<0))return{place:a,contains:e[a].isIdentical(t)};s=a+1,a=Math.floor((s+i)/2)}}return{place:Cr(e[a],t,n)>0?a:a+1,contains:!1}}return{place:r,contains:!0}}return{place:e.length,contains:!1}},Cr=function(e,t,n){switch(n){case De.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 De.CHRONOLOGICAL:return t.createdAt-e.createdAt;case De.CHANNEL_NAME_ALPHABETICAL:return e.name.localeCompare(t.name)}},Nr=function(e,t){if(t instanceof L)return e.findIndex((function(e){return e instanceof L&&t.isIdentical(e)}));e.findIndex((function(e){return e.isIdentical(t)}))},br=function(e,t){return e.findIndex((function(e){return e.messageId===t}))},Mr=function(e,t){if(e.length>0){for(var n=0,r=e.length-1,s=Math.floor((n+r)/2);n0)r=s,s=Math.floor((n+r)/2);else{if(!(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},Tr={},Sr=function(){function e(e){var t=e._iid,n=e.channel,r=this;this._sync=null,this._metadata=null,this._iid=t,this._channel=n;var s,i,a=W.of(this._iid),o=a.logger,u=a.sdkState;this._metadataKey=(s=u.userId,i=n.url,"sendbird:".concat(s,"@groupchannel/").concat(i,"/poll/changelogs.meta"));var l=function(e,t){return"sendbird:".concat(e,"@groupchannel/").concat(t,"/poll/changelogs")}(u.userId,this._channel.url);this._sync=new cr(l,(function(){return p(r,void 0,void 0,(function(){var e,t,n,r,s,i;return _(this,(function(a){switch(a.label){case 0:return e={hasNext:!0,nextToken:0},[4,this.loadMetadata()];case 1:a.sent(),o.debug("poll changelog sync from",null===(i=this._metadata)||void 0===i?void 0:i.token),a.label=2;case 2:return a.trys.push([2,5,,8]),[4,je.of(this._iid).getPollChangeLogs(this._channel.url,this._channel.channelType,this._metadata.token)];case 3:return t=a.sent(),n=t.hasMore,r=t.token,e.hasNext=n,e.nextToken=r,this._metadata.token=r,o.debug("poll changelog sync progress",e),[4,this.saveMetadata()];case 4:return a.sent(),[3,8];case 5:return s=a.sent(),o.debug("poll 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]}}))}))}))}return e.of=function(t,n){if(Tr[t]||(Tr[t]={}),!Tr[t][n.url]){var r=Tr[t][n.url]=new e({_iid:t,channel:n});W.of(t).dispatcher.on((function(e){if(e instanceof ue)if(e.stateType===le.CONNECTED)r.resume();else r.pause()}))}return Tr[t][n.url]},e.prototype.loadMetadata=function(){return p(this,void 0,void 0,(function(){var e,t,n,r;return _(this,(function(s){switch(s.label){case 0:return this._metadata?[3,2]:(e=W.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/1e3},s.label=2;case 2:return[2]}}))}))},e.prototype.saveMetadata=function(){return p(this,void 0,void 0,(function(){return _(this,(function(e){switch(e.label){case 0:return this._metadata?[4,W.of(this._iid).cacheContext.preference.set(this._metadataKey,this._metadata)]:[3,2];case 1:e.sent(),e.label=2;case 2:return[2]}}))}))},e.prototype.clearMetadata=function(){return p(this,void 0,void 0,(function(){return _(this,(function(e){switch(e.label){case 0:return[4,W.of(this._iid).cacheContext.preference.remove(this._metadataKey)];case 1:return e.sent(),this._metadata=null,[2]}}))}))},e.prototype.resume=function(){W.of(this._iid).logger.debug("poll changelog sync resume()"),this._sync.start(0)},e.prototype.pause=function(){W.of(this._iid).logger.debug("poll changelog sync pause()"),this._sync.stop()},e}();!function(e){e.CACHE_AND_REPLACE_BY_API="cache_and_replace_by_api"}(lr||(lr={}));var Ur,Ar,Ir,wr=function(){function e(){}return e.prototype._invokeResponse=function(e,t,n){var r=this;Z((function(){return p(r,void 0,void 0,(function(){return _(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}(),Lr=function(){function e(e,t){var n=t.channel,r=t.filter,s=t.startingPoint,i=t.limit,a=this;this._channel=null,this._messages=[],this._unsentMessages=[],this._readReceiptMap=new Map,this._deliveryReceiptMap=new Map,this._iid=e,this._key="mc-".concat(ie()),this.filter=null!=r?r:new Qe,this._channel=n,this._syncRange=new nr({}),this._hasPrevious=!0,this._hasNext=!0,this._startingPoint=s||Date.now()+6e5,this._limit=i||Be;var o=sr.of(this._iid);o.subscribeGroupChannelEvent(this._key,{onUpdate:function(e,t){var n,r,s,i,o=yr(e,a._channel);if(o>=0)switch(Z((function(){return p(a,void 0,void 0,(function(){var n;return _(this,(function(r){return n=new hr(t),this._channel=e[o],this._handler.onChannelUpdated(n,this.channel),[2]}))}))})),t){case $t.EVENT_CHANNEL_UPDATED:var u=!1;for(var l in a._messages){if((g=a._messages[l]).createdAt>=a._channel.messageOffsetTimestamp){u=!0;var c=parseInt(l);if(c>0){var h=a._messages.splice(0,c);a._removeMessagesFromView(h.map((function(e){return e.messageId})),$.EVENT_MESSAGE_OFFSET_UPDATED)}break}}!u&&a._messages.length>0&&a._removeMessagesFromView(a._messages.map((function(e){return e.messageId})),$.EVENT_MESSAGE_OFFSET_UPDATED);break;case $t.EVENT_CHANNEL_READ:var d=[];try{for(var f=m(a._messages),v=f.next();!v.done;v=f.next()){var g=v.value;if((C=a._readReceiptMap.get(g.messageId))>0)C!==a._channel.getUnreadMemberCount(g)&&d.push(g)}}catch(e){n={error:e}}finally{try{v&&!v.done&&(r=f.return)&&r.call(f)}finally{if(n)throw n.error}}d.length>0&&a._updateMessagesToView(d,$.EVENT_MESSAGE_READ);break;case $t.EVENT_CHANNEL_DELIVERED:d=[];try{for(var y=m(a._messages),E=y.next();!E.done;E=y.next()){var C;g=E.value;if((C=a._deliveryReceiptMap.get(g.messageId))>0)C!==a._channel.getUndeliveredMemberCount(g)&&d.push(g)}}catch(e){s={error:e}}finally{try{E&&!E.done&&(i=y.return)&&i.call(y)}finally{if(s)throw s.error}}d.length>0&&a._updateMessagesToView(d,$.EVENT_MESSAGE_READ)}},onRemove:function(e,t){e.indexOf(a.channel.url)>=0&&Z((function(){return p(a,void 0,void 0,(function(){var e;return _(this,(function(n){return e=new hr(t),this._handler.onChannelDeleted(e,this.channel.url),[2]}))}))}))}}),o.subscribeMessageEvent(this._key,{onUpdate:function(e,t){var n,r,s=[],i=[];try{for(var o=m(e),u=o.next();!u.done;u=o.next()){var l=u.value;l.channelUrl===a._channel.url&&(a.filter.match(l)?s.push(l):i.push(l.messageId))}}catch(e){n={error:e}}finally{try{u&&!u.done&&(r=o.return)&&r.call(o)}finally{if(n)throw n.error}}if(pe(t)){if(s.length>0)switch(t){case $.EVENT_MESSAGE_SENT_FAILED:case $.EVENT_MESSAGE_SENT_SUCCESS:case $.EVENT_MESSAGE_UPDATED:case $.EVENT_MESSAGE_THREADINFO_UPDATED:case $.EVENT_MESSAGE_REACTION_UPDATED:case $.SYNC_MESSAGE_CHANGELOGS:a._updateMessagesToView(s,t);break;case $.EVENT_MESSAGE_SENT_PENDING:case $.EVENT_MESSAGE_RECEIVED:case $.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=W.of(this._iid).cacheContext;!this._channel.isSuper&&u.localCacheEnabled&&pr.of(this._iid,this._channel).resume(),mr.of(this._iid,this._channel).resume(),Sr.of(this._iid,this._channel).resume(),this._prevFill=new cr(this._key,(function(e){return p(a,void 0,void 0,(function(){var t,n;return _(this,(function(r){switch(r.label){case 0:return[4,this._getRemoteMessages(e,{prevLimit:this._limit,source:$.SYNC_MESSAGE_FILL})];case 1:return(t=r.sent()).length>0?(n=Math.min.apply(Math,d([],f(t.map((function(e){return e.createdAt}))),!1)),this._syncRange.extends(n),[2,{hasNext:t.length>=this._limit&&this.viewTop0?(n=Math.max.apply(Math,d([],f(t.map((function(e){return e.createdAt}))),!1)),this._syncRange.extends(n),[2,{hasNext:!(t.length>=this._limit&&this._hasNext)||this.viewBottom>n,nextToken:this._syncRange.bottom}]):[2,{hasNext:!1,nextToken:0}]}}))}))}));var l=W.of(this._iid),c=l.dispatcher,h=l.logger;c.on((function(e){if(e instanceof ue)if(e.stateType===le.CONNECTED)h.debug("check huge gap"),a._checkHugeGap();else a._prevFill.stop(),a._nextFill.stop()}))}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===ne.FAILED}))},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"pendingMessages",{get:function(){return this._unsentMessages.filter((function(e){return e.sendingStatus===ne.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){var t=this;return e.filter((function(e){return e.createdAt>=t._channel.messageOffsetTimestamp}))},e.prototype._addMessagesToView=function(e,t){var n,r,s=this,i=this._filterUnderOffsetMessage(e),a=[],o=[];try{for(var u=m(i),l=u.next();!l.done;l=u.next()){var c=l.value;if(t===$.SYNC_MESSAGE_FILL){if(c.messageId>0){if((y=Nr(this._messages,c))<0){Nr(this._unsentMessages,c)<0&&a.push(c);var h=Mr(this._messages,c);this._messages.splice(h,0,c)}this._readReceiptMap.set(c.messageId,this._channel.getUnreadMemberCount(c)),this._deliveryReceiptMap.set(c.messageId,this._channel.getUndeliveredMemberCount(c))}else if(c instanceof L){(y=Nr(this._unsentMessages,c))<0&&Nr(this._messages,c)<0&&(this._unsentMessages.push(c),a.push(c))}}else if(c.messageId>0){if((y=Nr(this._messages,c))<0){var v=Nr(this._unsentMessages,c);v<0?a.push(c):(this._unsentMessages.splice(v,1),o.push(c));h=Mr(this._messages,c);this._messages.splice(h,0,c)}else o.push(c),this._messages[y]=c;if(this._readReceiptMap.set(c.messageId,this._channel.getUnreadMemberCount(c)),this._deliveryReceiptMap.set(c.messageId,this._channel.getUndeliveredMemberCount(c)),c.updatedAt>0){var g=this._updateChildMessagesInView(c);o.push.apply(o,d([],f(g),!1))}}else if(c instanceof L){var y;(y=Nr(this._unsentMessages,c))<0?Nr(this._messages,c)<0&&(this._unsentMessages.push(c),a.push(c)):(o.push(c),this._unsentMessages[y]=c)}}}catch(e){n={error:e}}finally{try{l&&!l.done&&(r=u.return)&&r.call(u)}finally{if(n)throw n.error}}pe(t)&&Z((function(){return p(s,void 0,void 0,(function(){var e;return _(this,(function(n){return e=new dr(t),a.length>0&&this._handler.onMessagesAdded(e,this.channel,a),o.length>0&&this._handler.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=m(e),o=a.next();!o.done;o=a.next()){var u=o.value,l=br(this._messages,u.messageId);if(l>=0){var c=this._messages[l];c&&c.applyPoll(u),i.push(c)}}}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&&pe(t)&&Z((function(){return p(s,void 0,void 0,(function(){var e;return _(this,(function(n){return e=new dr(t),i.length>0&&this._handler.onMessagesUpdated(e,this.channel,i),[2]}))}))})),i},e.prototype._applyPollUpdateEventToView=function(e,t){var n=this,r=br(this._messages,e.messageId);if(r>=0){var s=this._messages[r];s&&s.isUserMessage()&&s.poll&&s.poll.applyPollUpdateEvent(e)&&pe(t)&&Z((function(){return p(n,void 0,void 0,(function(){var e;return _(this,(function(n){return e=new dr(t),this._handler.onMessagesUpdated(e,this.channel,[s]),[2]}))}))}))}},e.prototype._applyPollVoteEventToView=function(e,t){var n=this,r=br(this._messages,e.messageId);if(r>=0){var s=this._messages[r];s&&s.isUserMessage()&&s.poll&&s.poll.applyPollVoteEvent(e)&&pe(t)&&Z((function(){return p(n,void 0,void 0,(function(){var e;return _(this,(function(n){return e=new dr(t),this._handler.onMessagesUpdated(e,this.channel,[s]),[2]}))}))}))}},e.prototype._updateMessagesToView=function(e,t){var n,r,s=this,i=[];try{for(var a=m(e),o=a.next();!o.done;o=a.next()){var u,l=o.value;if(l.messageId>0)if((u=Nr(this._messages,l))>=0)i.push(l),this._messages[u]=l;else{var c=Nr(this._unsentMessages,l);if(c>=0){i.push(l),this._unsentMessages.splice(c,1);var h=Mr(this._messages,l);this._messages.splice(h,0,l)}}else if(l instanceof L)(u=Nr(this._unsentMessages,l))>=0&&(i.push(l),this._unsentMessages[u]=l)}}catch(e){n={error:e}}finally{try{o&&!o.done&&(r=a.return)&&r.call(a)}finally{if(n)throw n.error}}return pe(t)&&Z((function(){return p(s,void 0,void 0,(function(){var e;return _(this,(function(n){return e=new dr(t),i.length>0&&this._handler.onMessagesUpdated(e,this.channel,i),[2]}))}))})),i},e.prototype._removeMessagesFromView=function(e,t){var n,r,s=this,i=[],a=function(e){var t=o._messages.findIndex((function(t){return t.messageId===e}));t>=0&&(i.push(o._messages[t].messageId),o._messages.splice(t,1))},o=this;try{for(var u=m(e),l=u.next();!l.done;l=u.next()){a(l.value)}}catch(e){n={error:e}}finally{try{l&&!l.done&&(r=u.return)&&r.call(u)}finally{if(n)throw n.error}}return pe(t)&&i.length>0&&Z((function(){return p(s,void 0,void 0,(function(){var e;return _(this,(function(n){return e=new dr(t),i.length>0&&this._handler.onMessagesDeleted(e,this.channel,i),[2]}))}))})),i},e.prototype._removeUnsentMessageFromView=function(e,t){var n=this._unsentMessages.findIndex((function(t){return t.reqId===e}));n>=0&&this._unsentMessages.splice(n,1)},e.prototype._getLocalMessages=function(e,t){var n=t.prevLimit,r=void 0===n?0:n,s=t.nextLimit,i=void 0===s?0:s;return p(this,void 0,void 0,(function(){var t,n,s,a,o,u,l;return _(this,(function(c){switch(c.label){case 0:return t=sr.of(this._iid),r>0?[4,t.getMessagesFromCache(this._channel.url,e,"prev",this.filter,this._limit)]:[3,2];case 1:return s=c.sent(),[3,3];case 2:s=[],c.label=3;case 3:return n=s,i>0?[4,t.getMessagesFromCache(this._channel.url,e,"next",this.filter,this._limit)]:[3,5];case 4:return o=c.sent(),[3,6];case 5:o=[],c.label=6;case 6:if(a=o,n.length>0&&a.length)for(l in u=n.map((function(e){return e.messageId})),a)if(u.includes(a[l].messageId)){a.splice(parseInt(l),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 r=t.prevLimit,s=void 0===r?0:r,i=t.nextLimit,a=void 0===i?0:i,o=t.source,u=void 0===o?$.REQUEST_MESSAGE:o,l=t.reverse,c=void 0!==l&&l;return p(this,void 0,void 0,(function(){var t,r;return _(this,(function(i){switch(i.label){case 0:return t=ce.of(this._iid),s>0||a>0?[4,t.getMessagesByTimestamp(this._channel.url,this._channel.channelType,e,n(n({},this.filter),{reverse:c,prevResultSize:s,nextResultSize:a,includeMetaArray:!0,includeReactions:!0,includeThreadInfo:!0}),u)]:[3,2];case 1:return r=i.sent(),[3,3];case 2:r=[],i.label=3;case 3:return[2,r]}}))}))},e.prototype._checkHugeGap=function(){return p(this,void 0,void 0,(function(){var e,t,r,s,i,a,o,u,l,c,h=this;return _(this,(function(m){switch(m.label){case 0:return this._messages.length>0?(e=this.viewTop,t=this._syncRange.top,r=this._syncRange.bottom,s=this.hasNext?this.viewBottom:Number.MAX_SAFE_INTEGER,[4,(i=sr.of(this._iid)).getCachedMessageCountBetween(this._channel.url,this.filter,e,t)]):[3,4];case 1:return a=m.sent(),[4,i.getCachedMessageCountBetween(this._channel.url,this.filter,r,s)];case 2:return o=m.sent(),[4,_e((function(){return p(h,void 0,void 0,(function(){var i,u,l,c,h,m,v,g,y,E,C,N,b,M,T,S,U,A=this;return _(this,(function(I){switch(I.label){case 0:return i=W.of(this._iid),u=i.dispatcher,l=i.requestQueue,c=new vr(n({channelUrl:this._channel.url,channelType:this._channel.channelType,prevStart:e,prevEnd:t,prevCount:a,nextStart:r,nextEnd:s,nextCount:o},this.filter)),[4,l.send(c)];case 1:return h=I.sent(),m=h.as(gr),v=m.isHugeGap,g=m.prevMessages,y=void 0===g?[]:g,E=m.prevHasMore,C=m.nextMessages,N=void 0===C?[]:C,b=m.nextHasmore,v?Z((function(){return p(A,void 0,void 0,(function(){return _(this,(function(e){return this._handler.onHugeGapDetected(),[2]}))}))})):(this._hasPrevious=E,this._hasNext=b,M=this.viewTop,T=this.viewBottom,S=Math.min.apply(Math,d([Number.MAX_SAFE_INTEGER],f(y.map((function(e){return e.createdAt}))),!1)),U=Math.max.apply(Math,d([0],f(N.map((function(e){return e.createdAt}))),!1)),u.dispatch(new w({messages:y,source:$.SYNC_MESSAGE_FILL})),u.dispatch(new w({messages:N,source:$.SYNC_MESSAGE_FILL})),this._syncRange.extends(S,U),MU&&this._nextFill.start(U)),[2]}}))}))}),1)];case 3:return m.sent(),[3,6];case 4:return u=Math.floor(this._limit/2),[4,this._getRemoteMessages(Date.now(),{prevLimit:u,nextLimit:u,source:$.SYNC_MESSAGE_FILL})];case 5:(l=m.sent()).length>0&&((c=this._syncRange).extends.apply(c,d([],f(l.map((function(e){return e.createdAt}))),!1)),l.length0&&((s=t._syncRange).extends.apply(s,d([],f(i.map((function(e){return e.createdAt}))),!1)),t._addMessagesToView(i,$.REQUEST_MESSAGE)),n._invokeResponse("remote",null,i)})).catch((function(e){if(X(e))throw e;n._invokeResponse("remote",e,null)}))}));return n},e.prototype.loadPrevious=function(){return p(this,void 0,void 0,(function(){var e,t,n,r,s=this;return _(this,(function(i){switch(i.label){case 0:return this._hasPrevious?(e=this.viewTop,t=[],[4,b((function(){return p(s,void 0,void 0,(function(){var n;return _(this,(function(r){switch(r.label){case 0:return n=this._filterUnderOffsetMessage,[4,this._getLocalMessages(e,{prevLimit:this._limit})];case 1:return t=n.apply(this,[r.sent()]),[2]}}))}))}))]):[3,5];case 1:return i.sent(),n=pr.of(this._iid,this._channel),0!==t.length&&n.isWrappingMessages(t)?[3,3]:[4,b((function(){return p(s,void 0,void 0,(function(){var r,s;return _(this,(function(i){switch(i.label){case 0:return r=this._filterUnderOffsetMessage,[4,this._getRemoteMessages(e,{prevLimit:this._limit})];case 1:return t=r.apply(this,[i.sent()]),this._hasPrevious=t.length>=this._limit,t.length>0&&((s=this._syncRange).extends.apply(s,d([],f(t.map((function(e){return e.createdAt}))),!1)),n.range.overlap(this._syncRange)&&n.range.extends(this._syncRange.top)),[2]}}))}))}))];case 2:return i.sent(),this._addMessagesToView(t,$.REQUEST_MESSAGE),[3,4];case 3:this._hasPrevious=t.length>=this._limit,t.length>0&&((r=this._syncRange).extends.apply(r,d([],f(t.map((function(e){return e.createdAt}))),!1)),this._addMessagesToView(t,$.REQUEST_MESSAGE)),i.label=4;case 4:return[2,t];case 5:return[2,[]]}}))}))},e.prototype.loadNext=function(){return p(this,void 0,void 0,(function(){var e,t,n,r,s=this;return _(this,(function(i){switch(i.label){case 0:return e=this.viewBottom,t=[],[4,b((function(){return p(s,void 0,void 0,(function(){var n;return _(this,(function(r){switch(r.label){case 0:return n=this._filterUnderOffsetMessage,[4,this._getLocalMessages(e,{nextLimit:this._limit})];case 1:return t=n.apply(this,[r.sent()]),[2]}}))}))}))];case 1:return i.sent(),n=pr.of(this._iid,this._channel),0!==t.length&&n.isWrappingMessages(t)?[3,3]:[4,b((function(){return p(s,void 0,void 0,(function(){var r,s;return _(this,(function(i){switch(i.label){case 0:return r=this._filterUnderOffsetMessage,[4,this._getRemoteMessages(e,{nextLimit:this._limit})];case 1:return t=r.apply(this,[i.sent()]),this._hasNext=t.length>=this._limit,t.length>0&&((s=this._syncRange).extends.apply(s,d([],f(t.map((function(e){return e.createdAt}))),!1)),n.range.overlap(this._syncRange)&&n.range.extends(this._syncRange.bottom)),[2]}}))}))}))];case 2:return i.sent(),this._addMessagesToView(t,$.REQUEST_MESSAGE),[3,4];case 3:this._hasNext=t.length>=this._limit,t.length>0&&((r=this._syncRange).extends.apply(r,d([],f(t.map((function(e){return e.createdAt}))),!1)),this._addMessagesToView(t,$.REQUEST_MESSAGE)),i.label=4;case 4:return[2,t]}}))}))},e.prototype.removeFailedMessage=function(e){return p(this,void 0,void 0,(function(){var t;return _(this,(function(n){switch(n.label){case 0:return[4,sr.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(){W.of(this._iid).cacheContext.localCacheEnabled&&(this._prevFill.stop(),this._nextFill.stop(),pr.of(this._iid,this._channel).pause()),mr.of(this._iid,this._channel).pause(),Sr.of(this._iid,this._channel).pause();var e=sr.of(this._iid);e.unsubscribeGroupChannelEvent(this._key),e.unsubscribeMessageEvent(this._key)},e}(),Dr={coverUrl:null,coverImage:null,isDistinct:null,isPublic:null,isDiscoverable:null,accessCode:null,name:null,data:null,customType:null,operatorUserIds:null,messageSurvivalSeconds:null},Rr={hidePreviousMessages:!1,allowAutoUnhide:!0},Or=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,l=e.nicknameStartsWithFilter,c=e.operatorFilter;return(n=t.call(this)||this).method=D.GET,n.path="".concat(F,"/").concat(encodeURIComponent(r),"/members"),n.params={token:s,limit:i,order:a,muted_member_filter:o,member_state_filter:u,nickname_startswith:l,operator_filter:c,show_member_is_muted:!0,show_read_receipt:!0,show_delivery_receipt:!0},n}return e(n,t),n}(O),Pr=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 qt(e,t)}))),r}return e(n,t),n}(P);!function(e){e.ALL="all",e.MUTED="muted",e.UNMUTED="unmuted"}(Ur||(Ur={})),function(e){e.MEMBER_NICKNAME_ALPHABETICAL="member_nickname_alphabetical",e.OPERATOR_THEN_MEMBER_ALPHABETICAL="operator_then_member_alphabetical"}(Ar||(Ar={})),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"}(Ir||(Ir={}));var kr=function(t){function r(e,n,r){var s,i,a,o,l=this;return(l=t.call(this,e,n,u.GROUP,r)||this).mutedMemberFilter=Ur.ALL,l.memberStateFilter=Ir.ALL,l.nicknameStartsWithFilter=null,l.operatorFilter=Ht.ALL,l.order=Ar.MEMBER_NICKNAME_ALPHABETICAL,l.mutedMemberFilter=null!==(s=r.mutedMemberFilter)&&void 0!==s?s:Ur.ALL,l.memberStateFilter=null!==(i=r.memberStateFilter)&&void 0!==i?i:Ir.ALL,l.nicknameStartsWithFilter=null!==(a=r.nicknameStartsWithFilter)&&void 0!==a?a:null,l.order=null!==(o=r.order)&&void 0!==o?o:Ar.MEMBER_NICKNAME_ALPHABETICAL,l}return e(r,t),r.prototype._validate=function(){return t.prototype._validate.call(this)&&a(Ur,this.mutedMemberFilter)&&a(Ir,this.memberStateFilter)&&(g("string",this.nicknameStartsWithFilter)||null===this.nicknameStartsWithFilter)&&a(Ht,this.operatorFilter)&&a(Ar,this.order)},r.prototype.next=function(){return p(this,void 0,void 0,(function(){var e,t,r,s,i,a;return _(this,(function(o){switch(o.label){case 0:return this._validate()?this._isLoading?[3,3]:this._hasNext?(this._isLoading=!0,e=W.of(this._iid).requestQueue,t=new Or(n(n({},this),{token:this._token})),[4,e.send(t)]):[3,2]:[3,5];case 1:return r=o.sent(),s=r.as(Pr),i=s.members,a=s.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]}}))}))},r}(me),Fr=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(F,"/").concat(encodeURIComponent(r),"/accept"),n.params={user_id:s,access_code:i},n}return e(n,t),n}(O),xr=function(t){function n(e,n){var r=t.call(this,e,n)||this;return r.channel=new ys(e,n),r.channel.myMemberState=Rt.JOINED,r}return e(n,t),n}(P),Hr=function(n){function r(e){var r=this,s=e.channelUrl,i=e.isDistinct,a=e.isPublic,o=e.isDiscoverable,u=e.coverUrl,l=e.coverImage,c=e.accessCode,h=e.name,d=e.data,f=e.customType,p=e.operatorUserIds,_=e.messageSurvivalSeconds;return(r=n.call(this)||this).method=D.PUT,r.path="".concat(F,"/").concat(encodeURIComponent(s)),r.params=t({is_distinct:i,is_public:a,is_discoverable:o,name:h,data:d,custom_type:f,cover_url:u,cover_file:l,access_code:c,operator_ids:p,message_survival_seconds:_}),r}return e(r,n),r}(O),Vr=function(t){function n(e,n){var r=t.call(this,e,n)||this;return r.channel=new ys(e,n),r}return e(n,t),n}(P),Gr=function(t){function n(e){var n=this,r=e.channelUrl;return(n=t.call(this)||this).method=D.DELETE,n.path="".concat(F,"/").concat(encodeURIComponent(r)),n}return e(n,t),n}(O);!function(t){function n(e,n){return t.call(this,e,n)||this}e(n,t)}(P);var qr=function(t){function n(e){var n=this,r=e.channelUrl;return(n=t.call(this)||this).method=D.DELETE,n.path="".concat(F,"/").concat(encodeURIComponent(r),"/hide"),n}return e(n,t),n}(O);!function(t){function n(){return null!==t&&t.apply(this,arguments)||this}e(n,t)}(P);var Kr=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(R,"/").concat(encodeURIComponent(n),"/count_preference/").concat(encodeURIComponent(r)),i.params={count_preference:s},i}return e(n,t),n}(O),Br=function(t){function n(e,n){var r=t.call(this,e,n)||this;return r.countPreference=ps[n.count_preference],r}return e(n,t),n}(P),jr=function(t){function n(e){var n=this,r=e.channelUrl;return(n=t.call(this)||this).method=D.PUT,n.path="".concat(F,"/").concat(encodeURIComponent(r),"/reset_user_history"),n}return e(n,t),n}(O),Qr=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}(P),zr=n(n({},vt),{scheduledAt:null,file:null,fileUrl:null,fileName:null,mimeType:null,fileSize:null,thumbnailSizes:null,requireAuth:!1}),Wr=n(n({},yt),{scheduledAt:null}),Yr=function(t){function n(e){var n,r=this;r=t.call(this)||this;var s=[];e.mentionType===ve.USERS&&(e.mentionedUserIds?s=e.mentionedUserIds:e.mentionedUsers&&(s=e.mentionedUsers.map((function(e){return e.userId}))));var i=e.channelType,a=e.channelUrl,o=e.scheduledMessageId;return r.method=D.PUT,r.path="".concat(de(i),"/").concat(encodeURIComponent(a),"/scheduled_messages/").concat(encodeURIComponent(o)),r.params={req_id:e.reqId,scheduled_at:e.scheduledAt,message_type:ge.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 ye.payloadify(e)})):[],custom_type:e.customType,data:e.data,require_auth:e.requireAuth,mention_type:e.mentionType,mentioned_user_ids:s,sorted_metaarray:null===(n=e.metaArrays)||void 0===n?void 0:n.map((function(e){return Ee.payloadify(e)})),apple_critical_alert_options:Ce.payloadify(e.appleCriticalAlertOptions),push_option:e.pushNotificationDeliveryOption},r}return e(n,t),n}(O),Jr=function(t){function n(e,n){var r=t.call(this,e,n)||this;return r.message=new J(e,n),r}return e(n,t),n}(P),Xr=function(t){function n(e){var n,r=this;r=t.call(this)||this;var s=[];e.mentionType===ve.USERS&&(e.mentionedUserIds?s=e.mentionedUserIds:e.mentionedUsers&&(s=e.mentionedUsers.map((function(e){return e.userId}))));var i=e.channelType,a=e.channelUrl,o=e.scheduledMessageId;return r.method=D.PUT,r.path="".concat(de(i),"/").concat(encodeURIComponent(a),"/scheduled_messages/").concat(encodeURIComponent(o)),r.params={req_id:e.reqId,scheduled_at:e.scheduledAt,message_type:ge.USER,message:e.message,custom_type:e.customType,data:e.data,mention_type:e.mentionType,mentioned_user_ids:s,sorted_metaarray:null===(n=e.metaArrays)||void 0===n?void 0:n.map((function(e){return Ee.payloadify(e)})),apple_critical_alert_options:Ce.payloadify(e.appleCriticalAlertOptions),target_langs:e.translationTargetLanguages,push_option:e.pushNotificationDeliveryOption},r}return e(n,t),n}(O);!function(t){function n(e,n){var r=t.call(this,e,n)||this;return r.message=new Y(e,n),r}e(n,t)}(P);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=D.DELETE,n.path="".concat(de(r),"/").concat(encodeURIComponent(s),"/scheduled_messages/").concat(encodeURIComponent(i)),n}return e(n,t),n}(O),$r=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(de(r),"/").concat(encodeURIComponent(s),"/scheduled_messages/").concat(encodeURIComponent(i),"/send_now"),n}return e(n,t),n}(O),es=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(R,"/").concat(encodeURIComponent(n),"/push_preference/").concat(encodeURIComponent(r)),i.params={push_trigger_option:s},i}return e(n,t),n}(O),ts=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}(P),ns=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(R,"/").concat(encodeURIComponent(n),"/push_preference/").concat(encodeURIComponent(r)),s}return e(n,t),n}(O),rs=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}(P),ss=function(t){function n(e){var n=e.pollId,r=e.title,s=e.data,i=e.isAnonymous,a=e.allowUserSuggestion,o=e.allowMultipleVotes,u=e.closeAt,l=t.call(this)||this;return l.method=D.PUT,l.path="".concat(be,"/").concat(encodeURIComponent(n)),l.params={title:r,data:s,is_anonymous:i,allow_user_suggestion:a,allow_multiple_votes:o,close_at:u},l}return e(n,t),n}(O),is=function(t){function n(e,n){var r=t.call(this,e,n)||this;return r.poll=new Me(e,n),r}return e(n,t),n}(P),as=function(t){function n(e){var n=e.pollId,r=t.call(this)||this;return r.method=D.DELETE,r.path="".concat(be,"/").concat(encodeURIComponent(n)),r}return e(n,t),n}(O);!function(t){function n(){return null!==t&&t.apply(this,arguments)||this}e(n,t)}(P);var os=function(t){function n(e){var n=e.pollId,r=t.call(this)||this;return r.method=D.PUT,r.path="".concat(be,"/").concat(encodeURIComponent(n),"/close"),r}return e(n,t),n}(O),us=function(t){function n(e,n){var r=t.call(this,e,n)||this;return r.poll=new Me(e,n),r}return e(n,t),n}(P),ls=function(t){function n(e){var n=e.channelUrl,r=e.channelType,s=e.pollId,i=e.optionText,a=t.call(this)||this;return a.method=D.POST,a.path="".concat(be,"/").concat(encodeURIComponent(s),"/options"),a.params={channel_url:n,channel_type:r,text:i},a}return e(n,t),n}(O),cs=function(t){function n(e,n){var r=t.call(this,e,n)||this;return r.poll=new Me(e,n),r}return e(n,t),n}(P),hs=function(t){function n(e){var n=e.pollId,r=e.pollOptionId,s=e.optionText,i=t.call(this)||this;return i.method=D.PUT,i.path="".concat(be,"/").concat(encodeURIComponent(n),"/options/").concat(encodeURIComponent(r)),i.params={text:s},i}return e(n,t),n}(O),ds=function(t){function n(e,n){var r=t.call(this,e,n)||this;return r.poll=new Me(e,n),r}return e(n,t),n}(P),fs=function(t){function n(e){var n=e.pollId,r=e.pollOptionId,s=t.call(this)||this;return s.method=D.DELETE,s.path="".concat(be,"/").concat(encodeURIComponent(n),"/options/").concat(encodeURIComponent(r)),s}return e(n,t),n}(O);!function(t){function n(){return null!==t&&t.apply(this,arguments)||this}e(n,t)}(P);var ps,_s,ms,vs=function(n){function r(e){var r=e.reqId,s=e.channelType,i=e.channelUrl,a=e.pollId,o=e.pollOptionIds;return n.call(this,{code:"VOTE",ackRequired:!0,payload:t({req_id:r,channel_type:s===u.OPEN?"open_channels":"group_channels",channel_url:i,poll_id:a,option_ids:o})})||this}return e(r,n),r}(V);!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"}(ps||(ps={})),function(e){e.MUTED="muted",e.UNMUTED="unmuted"}(_s||(_s={})),function(e){e.UNHIDDEN="unhidden",e.HIDDEN_ALLOW_AUTO_UNHIDE="hidden_allow_auto_unhide",e.HIDDEN_PREVENT_AUTO_UNHIDE="hidden_prevent_auto_unhide"}(ms||(ms={}));var gs,ys=function(r){function s(e,t){var s,i,c,h,p,_,m,v,y,E,C,N,b,M,T,S,U,A,I=this;return(I=r.call(this,e,t)||this)._unreadMemberStateMap=new Map,I._undeliveredMemberStateMap=new Map,I._typingStatus=new Map,I._lastMemberCountUpdated=0,I._typingStarted=0,I._typingEnded=0,I.isDistinct=!1,I.isSuper=!1,I.isBroadcast=!1,I.isExclusive=!1,I.isPublic=!1,I.isDiscoverable=!0,I.isAccessCodeRequired=!1,I.isPushEnabled=!1,I.unreadMessageCount=0,I.unreadMentionCount=0,I.members=[],I.memberCount=0,I.joinedMemberCount=0,I.hiddenState=ms.UNHIDDEN,I.lastMessage=null,I.messageOffsetTimestamp=0,I.messageSurvivalSeconds=-1,I.myMemberState=Rt.NONE,I.myRole=o.NONE,I.myMutedState=_s.UNMUTED,I.myLastRead=0,I.myCountPreference=ps.ALL,I.myPushTriggerOption=et.DEFAULT,I.inviter=null,I.invitedAt=0,I.joinedAt=0,I.channelType=u.GROUP,I.isDistinct=null!==(i=t.is_distinct)&&void 0!==i&&i,I.isSuper=null!==(c=t.is_super)&&void 0!==c&&c,I.isBroadcast=null!==(h=t.is_broadcast)&&void 0!==h&&h,I.isExclusive=null!==(p=t.is_exclusive)&&void 0!==p&&p,I.isPublic=null!==(_=t.is_public)&&void 0!==_&&_,I.isDiscoverable=null!==(m=t.is_discoverable)&&void 0!==m?m:I.isPublic,I.isAccessCodeRequired=null!==(v=t.is_access_code_required)&&void 0!==v&&v,I.isPushEnabled=null!==(y=t.is_push_enabled)&&void 0!==y&&y,Array.isArray(t.members)&&(s=I.members).push.apply(s,d([],f(t.members.map((function(e){return new qt(I._iid,e)}))),!1)),I.memberCount=null!==(E=t.member_count)&&void 0!==E?E:0,I.joinedMemberCount=null!==(C=t.joined_member_count)&&void 0!==C?C:0,I.hiddenState=a(ms,t.hidden_state)?t.hidden_state:ms.UNHIDDEN,I.messageOffsetTimestamp=null!==(N=t.ts_message_offset)&&void 0!==N?N:0,I.messageSurvivalSeconds=null!==(b=t.message_survival_seconds)&&void 0!==b?b:-1,I.lastMessage=t.last_message?fe(I._iid,n({channel_type:I.channelType},t.last_message)):null,t.read_receipt&&Object.keys(t.read_receipt).forEach((function(e){g("number",t.read_receipt[e])&&I._updateUnreadMemberState(e,t.read_receipt[e])})),t.delivery_receipt&&Object.keys(t.delivery_receipt).forEach((function(e){g("number",t.delivery_receipt[e])&&I._updateUndeliveredMemberState(e,t.delivery_receipt[e])})),I.myMemberState=a(Rt,t.member_state)?t.member_state:Rt.NONE,I.myRole=a(o,t.my_role)?t.my_role:o.NONE,a(_s,t.is_muted)?I.myMutedState=t.is_muted:g("boolean",t.is_muted)?I.myMutedState=t.is_muted?_s.MUTED:_s.UNMUTED:I.myMutedState=_s.UNMUTED,I.myCountPreference=a(ps,t.count_preference)?t.count_preference:ps.ALL,I.myPushTriggerOption=a(et,t.push_trigger_option)?t.push_trigger_option:et.ALL,I.myLastRead=null!==(M=t.user_last_read)&&void 0!==M?M:0,I.inviter=t.inviter?new l(I._iid,t.inviter):null,I.invitedAt=null!==(T=t.invited_at)&&void 0!==T?T:0,I.joinedAt=null!==(S=t.joined_ts)&&void 0!==S?S:0,I._updateUnreadCount(null!==(U=t.unread_message_count)&&void 0!==U?U:0,null!==(A=t.unread_mention_count)&&void 0!==A?A:0),I}return e(s,r),Object.defineProperty(s.prototype,"isHidden",{get:function(){return this.hiddenState!==ms.UNHIDDEN},enumerable:!1,configurable:!0}),Object.defineProperty(s.prototype,"isTyping",{get:function(){return Object.keys(this._typingStatus).length>0},enumerable:!1,configurable:!0}),Object.defineProperty(s.prototype,"cachedUnreadMemberState",{get:function(){var e,t,n={};try{for(var r=m(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(s.prototype,"cachedUndeliveredMemberState",{get:function(){var e,t,n={};try{for(var r=m(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}),s.payloadify=function(e){return e?t(n(n({},r.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 qt.payloadify(e)})),last_message:Te(e.lastMessage),inviter:e.inviter?l.payloadify(e.inviter):null,invited_at:e.invitedAt,joined_ts:e.joinedAt})):null},s.prototype._shouldUpdateLastMessageWith=function(e){return!(e instanceof L&&e.parentMessageId>0&&!e.replyToChannel)&&(!this.lastMessage||this.lastMessage.createdAt=0)if(this.myCountPreference===ps.ALL||this.myCountPreference===ps.UNREAD_MESSAGE_COUNT_ONLY)if(this.isExclusive||this.isSuper||this.isBroadcast){var n=W.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===ps.ALL||this.myCountPreference===ps.UNREAD_MENTION_COUNT_ONLY)?this.unreadMentionCount=t:this.unreadMentionCount=0},s.prototype._updateUnreadMemberState=function(e,t){var n=this._unreadMemberStateMap.get(e);return(!n||n0?this._typingStatus[e.userId]={user:e,ts:t}:delete this._typingStatus[e.userId]},s.prototype._invalidateTypingStatus=function(){var e=(new Date).getTime(),t=!1;for(var n in this._typingStatus){e-this._typingStatus[n].ts>=1e4&&(delete this._typingStatus[n],t=!0)}return t},s.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},s.prototype.isReadMessage=function(e){var t=W.of(this._iid).sdkState,n=this._unreadMemberStateMap.get(t.userId);return n&&n>=e.createdAt},s.prototype.serialize=function(){var e=this;return B(this,(function(t){t.cachedUnreadMemberState=e.cachedUnreadMemberState,t.cachedUndeliveredMemberState=e.cachedUndeliveredMemberState}))},s.prototype.createMessageCollection=function(e){return void 0===e&&(e={}),new Lr(this._iid,n({channel:this},e))},s.prototype.createMemberListQuery=function(e){return void 0===e&&(e={}),new kr(this._iid,this.url,e)},s.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===Rt.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)}},s.prototype.removeMember=function(e){if(!this.isExclusive&&!this.isSuper&&!this.isBroadcast){var t=this.members.findIndex((function(t){return t.userId===e.userId}));if(t>-1)return this.members.splice(t,1),this.memberCount--,!0}return!1},s.prototype.getUnreadMemberCount=function(e){var t,n;if(e instanceof L&&!this.isExclusive&&!this.isSuper&&!this.isBroadcast){var r=W.of(this._iid).sdkState,s=e.createdAt,i=0;try{for(var a=m(this.members),o=a.next();!o.done;o=a.next()){var u=o.value;if(r.userId!==u.userId&&u.state===Rt.JOINED&&e.sender.userId!==u.userId)(this.cachedUnreadMemberState[u.userId]||0)=e.createdAt&&s.push(i))})),s},s.prototype.getUnreadMembers=function(e,t){var n=this;void 0===t&&(t=!1);var r=W.of(this._iid).sdkState;if(!r.userId||this.isExclusive||this.isSuper||this.isBroadcast)return[];var s=[];return this.members.forEach((function(i){(t||i.userId!==r.userId&&i.userId!==e.sender.userId)&&(n._unreadMemberStateMap.get(i.userId)=e&&(delete this._typingStatus[r],n=!0)}return n},s.prototype.refresh=function(){return p(this,void 0,void 0,(function(){var e,t,n,r,s,i;return _(this,(function(a){switch(a.label){case 0:return e=W.of(this._iid),t=e.requestQueue,n=e.dispatcher,r=new hn({channelUrl:this.url}),[4,t.send(r)];case 1:return s=a.sent(),i=s.as(dn).channel,n.dispatch(new sn({channels:[i],source:$t.REQUEST_CHANNEL})),[2,i]}}))}))},s.prototype.freeze=function(){return p(this,void 0,void 0,(function(){return _(this,(function(e){switch(e.label){case 0:return[4,r.prototype.freeze.call(this)];case 1:return e.sent(),W.of(this._iid).dispatcher.dispatch(new sn({channels:[this],source:$t.EVENT_CHANNEL_HIDDEN})),[2]}}))}))},s.prototype.unfreeze=function(){return p(this,void 0,void 0,(function(){return _(this,(function(e){switch(e.label){case 0:return[4,r.prototype.unfreeze.call(this)];case 1:return e.sent(),W.of(this._iid).dispatcher.dispatch(new sn({channels:[this],source:$t.EVENT_CHANNEL_UNHIDDEN})),[2]}}))}))},s.prototype.updateChannel=function(e){return p(this,void 0,void 0,(function(){var t,r,s,i,a,o,u;return _(this,(function(l){switch(l.label){case 0:return t=n(n({},Dr),e),te(function(e){return g("string",e.coverUrl,!0)&&(y(e.coverImage)||g("string",e.coverImage)||null===e.coverImage)&&g("boolean",e.isDistinct,!0)&&g("boolean",e.isPublic,!0)&&g("boolean",e.isDiscoverable,!0)&&g("string",e.accessCode,!0)&&g("string",e.name,!0)&&g("string",e.data,!0)&&g("string",e.customType,!0)&&v("string",e.operatorUserIds,!0)&&g("number",e.messageSurvivalSeconds,!0)}(t)).throw(Q.invalidParameters),r=W.of(this._iid),s=r.dispatcher,i=r.requestQueue,a=new Hr(n({channelUrl:this.url},t)),[4,i.send(a)];case 1:return o=l.sent(),u=o.as(Vr).channel,s.dispatch(new sn({channels:[u],source:$t.EVENT_CHANNEL_UPDATED})),[2,u]}}))}))},s.prototype.invite=function(e){return p(this,void 0,void 0,(function(){return _(this,(function(t){return te(e.every((function(e){return e instanceof l}))).throw(Q.invalidParameters),[2,this.inviteWithUserIds(e.map((function(e){return e.userId})))]}))}))},s.prototype.inviteWithUserIds=function(e){return p(this,void 0,void 0,(function(){var t,n,r,s,i,a;return _(this,(function(o){switch(o.label){case 0:return te(v("string",e)).throw(Q.invalidParameters),t=W.of(this._iid),n=t.dispatcher,r=t.requestQueue,s=new On({channelUrl:this.url,userIds:e}),[4,r.send(s)];case 1:return i=o.sent(),a=i.as(Pn).channel,n.dispatch(new sn({channels:[a],source:$t.EVENT_CHANNEL_INVITED})),[2,a]}}))}))},s.prototype.join=function(e){return void 0===e&&(e=null),p(this,void 0,void 0,(function(){var t,n,r,s,i,a,o;return _(this,(function(u){switch(u.label){case 0:return te(g("string",e)||null===e).throw(Q.invalidParameters),t=W.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=Rt.JOINED,n.dispatch(new sn({channels:[o],source:$t.EVENT_CHANNEL_JOINED})),[2,this]}}))}))},s.prototype.leave=function(e){return void 0===e&&(e=!1),p(this,void 0,void 0,(function(){var t,n,r,s;return _(this,(function(i){switch(i.label){case 0:return t=W.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(),[2]}}))}))},s.prototype.acceptInvitation=function(e){return void 0===e&&(e=null),p(this,void 0,void 0,(function(){var t,n,r,s,i,a,o;return _(this,(function(u){switch(u.label){case 0:return te(g("string",e)||null===e).throw(Q.invalidParameters),t=W.of(this._iid),n=t.dispatcher,r=t.sdkState,s=t.requestQueue,i=new Fr({channelUrl:this.url,userId:r.userId,accessCode:e}),[4,s.send(i)];case 1:return a=u.sent(),(o=a.as(xr).channel).myMemberState=Rt.JOINED,n.dispatch(new sn({channels:[o],source:$t.EVENT_CHANNEL_ACCEPTED_INVITE})),[2,o]}}))}))},s.prototype.declineInvitation=function(){return p(this,void 0,void 0,(function(){var e,t,n,r,s,i;return _(this,(function(a){switch(a.label){case 0:return e=W.of(this._iid),t=e.sdkState,n=e.requestQueue,r=new Fn({channelUrl:this.url,userId:t.userId}),[4,n.send(r)];case 1:return s=a.sent(),(i=s.as(xn).channel).myMemberState=Rt.NONE,[2,i]}}))}))},s.prototype.sendUserMessage=function(e){var t=this,n=new Se,s=W.of(this._iid).dispatcher,i=ze.of(this._iid);return r.prototype.sendUserMessage.call(this,e).onPending((function(e){i.completeCurrentAndProcessNextAutoResend(e),n._trigger(null,e)})).onFailed((function(e,t){t&&i.completeCurrentAndProcessNextAutoResend(t),n._trigger(e,t)})).onSucceeded((function(e){var r=sr.of(t._iid);i.completeCurrentAndProcessNextAutoResend(e),t._shouldUpdateLastMessageWith(e)&&(t.lastMessage=e),r.handlers.map((function(e){return e.onChannelChanged(t)})),s.dispatch(new sn({channels:[t],source:$t.EVENT_MESSAGE_SENT})),n._trigger(null,e)})),n},s.prototype.updateUserMessage=function(e,t){return p(this,void 0,void 0,(function(){var n,s,i,a=this;return _(this,(function(o){switch(o.label){case 0:return n=W.of(this._iid).dispatcher,[4,r.prototype.updateUserMessage.call(this,e,t)];case 1:return s=o.sent(),i=!1,!s.silent&&this._shouldUpdateLastMessageWith(s)&&(this.lastMessage=s,i=!0),i&&(sr.of(this._iid).handlers.map((function(e){return e.onChannelChanged(a)})),n.dispatch(new sn({channels:[this],source:$t.EVENT_CHANNEL_UPDATED}))),n.dispatch(new w({messages:[s],source:$.EVENT_MESSAGE_UPDATED})),[2,s]}}))}))},s.prototype._autoResendUserMessage=function(e){var t=this,n=new Se,s=W.of(this._iid).dispatcher,i=ze.of(this._iid);return r.prototype._autoResendUserMessage.call(this,e).onPending((function(e){i.completeCurrentAndProcessNextAutoResend(e),n._trigger(null,e)})).onFailed((function(e,t){i.completeCurrentAndProcessNextAutoResend(t),n._trigger(e,t)})).onSucceeded((function(e){var r=sr.of(t._iid);i.completeCurrentAndProcessNextAutoResend(e),t._shouldUpdateLastMessageWith(e)&&(t.lastMessage=e),r.handlers.map((function(e){return e.onChannelChanged(t)})),s.dispatch(new sn({channels:[t],source:$t.EVENT_MESSAGE_SENT})),n._trigger(null,e)})),n},s.prototype.sendFileMessage=function(e){var t=this,n=new Se,s=W.of(this._iid).dispatcher,i=ze.of(this._iid);return r.prototype.sendFileMessage.call(this,e).onPending((function(e){i.completeCurrentAndProcessNextAutoResend(e),n._trigger(null,e)})).onFailed((function(e,t){t&&i.completeCurrentAndProcessNextAutoResend(t),n._trigger(e,t)})).onSucceeded((function(e){var r=sr.of(t._iid);i.completeCurrentAndProcessNextAutoResend(e),t._shouldUpdateLastMessageWith(e)&&(t.lastMessage=e),r.handlers.map((function(e){return e.onChannelChanged(t)})),s.dispatch(new sn({channels:[t],source:$t.EVENT_MESSAGE_SENT})),n._trigger(null,e)})),n},s.prototype.updateFileMessage=function(e,t){return p(this,void 0,void 0,(function(){var n,s,i,a=this;return _(this,(function(o){switch(o.label){case 0:return n=W.of(this._iid).dispatcher,[4,r.prototype.updateFileMessage.call(this,e,t)];case 1:return s=o.sent(),i=!1,!s.silent&&this._shouldUpdateLastMessageWith(s)&&(this.lastMessage=s,i=!0),i&&(sr.of(this._iid).handlers.map((function(e){return e.onChannelChanged(a)})),n.dispatch(new sn({channels:[this],source:$t.EVENT_CHANNEL_UPDATED}))),n.dispatch(new w({messages:[s],source:$.EVENT_MESSAGE_UPDATED})),[2,s]}}))}))},s.prototype._autoResendFileMessage=function(e){var t=this,n=new Se,s=W.of(this._iid).dispatcher,i=ze.of(this._iid);return r.prototype._autoResendFileMessage.call(this,e).onPending((function(e){i.completeCurrentAndProcessNextAutoResend(e),n._trigger(null,e)})).onFailed((function(e,t){i.completeCurrentAndProcessNextAutoResend(t),n._trigger(e,t)})).onSucceeded((function(e){var r=sr.of(t._iid);i.completeCurrentAndProcessNextAutoResend(e),t._shouldUpdateLastMessageWith(e)&&(t.lastMessage=e),r.handlers.map((function(e){return e.onChannelChanged(t)})),s.dispatch(new sn({channels:[t],source:$t.EVENT_MESSAGE_SENT})),n._trigger(null,e)})),n},s.prototype.deleteMessage=function(e){return p(this,void 0,void 0,(function(){return _(this,(function(t){switch(t.label){case 0:return[4,r.prototype.deleteMessage.call(this,e)];case 1:return t.sent(),0===e.messageId&&W.of(this._iid).dispatcher.dispatch(new A({reqId:e.reqId,source:$.EVENT_MESSAGE_DELETED})),[2]}}))}))},s.prototype.hide=function(e){return p(this,void 0,void 0,(function(){var t,r,s,i,a,o,u,l;return _(this,(function(c){switch(c.label){case 0:return t=n(n({},Rr),e),te(function(e){return g("boolean",e.hidePreviousMessages)&&g("boolean",e.allowAutoUnhide)}(t)).throw(Q.invalidParameters),r=W.of(this._iid),s=r.dispatcher,i=r.sdkState,a=r.requestQueue,o=new jn(n({channelUrl:this.url,userId:i.userId},t)),[4,a.send(o)];case 1:return u=c.sent(),l=u.as(Qn).messageOffsetTimestamp,this.hiddenState=t.allowAutoUnhide?ms.HIDDEN_ALLOW_AUTO_UNHIDE:ms.HIDDEN_PREVENT_AUTO_UNHIDE,t.hidePreviousMessages&&this._updateUnreadCount(0,0),l&&(this.messageOffsetTimestamp=l),s.dispatch(new sn({channels:[this],source:$t.EVENT_CHANNEL_HIDDEN})),[2,this]}}))}))},s.prototype.unhide=function(){return p(this,void 0,void 0,(function(){var e,t,n,r;return _(this,(function(s){switch(s.label){case 0:return e=W.of(this._iid),t=e.dispatcher,n=e.requestQueue,r=new qr({channelUrl:this.url}),[4,n.send(r)];case 1:return s.sent(),this.hiddenState=ms.UNHIDDEN,t.dispatch(new sn({channels:[this],source:$t.EVENT_CHANNEL_UNHIDDEN})),[2,this]}}))}))},s.prototype.delete=function(){return p(this,void 0,void 0,(function(){var e,t;return _(this,(function(n){switch(n.label){case 0:return e=W.of(this._iid).requestQueue,t=new Gr({channelUrl:this.url}),[4,e.send(t)];case 1:return n.sent(),[2]}}))}))},s.prototype.markAsRead=function(){return p(this,void 0,void 0,(function(){var e,t,n,r,s,i,a,o=this;return _(this,(function(u){switch(u.label){case 0:return e=W.of(this._iid),t=e.sdkState,n=e.dispatcher,r=e.requestQueue,s=new Vn({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),sr.of(this._iid).handlers.map((function(e){return e.onChannelChanged(o)}))),n.dispatch(new sn({channels:[this],source:$t.EVENT_CHANNEL_READ})),[2]}}))}))},s.prototype.markAsDelivered=function(){return p(this,void 0,void 0,(function(){var e,t,n,r;return _(this,(function(s){switch(s.label){case 0:return e=W.of(this._iid),t=e.sdkState,n=e.requestQueue,r=new qn({channelUrl:this.url,userId:t.userId}),[4,n.send(r)];case 1:return s.sent(),[2]}}))}))},s.prototype.startTyping=function(){return p(this,void 0,void 0,(function(){var e,t,n,r,s;return _(this,(function(i){return e=W.of(this._iid),t=e.requestQueue,n=e.typingIndicatorThrottle,(r=(new Date).getTime())-this._typingStarted>=n&&(this._typingStarted=r,this._typingEnded=0,s=new Wn({channelUrl:this.url,time:this._typingStarted}),t.send(s)),[2]}))}))},s.prototype.endTyping=function(){return p(this,void 0,void 0,(function(){var e,t,n,r,s;return _(this,(function(i){return e=W.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]}))}))},s.prototype.createScheduledUserMessage=function(e){e=n(n({},We),e),te(Ye(e)).throw(Q.invalidParameters);var t=new Se;return this._createScheduledUserMessage(e,t),t},s.prototype.updateScheduledUserMessage=function(e,t){return p(this,void 0,void 0,(function(){var r,s,i,a;return _(this,(function(o){switch(o.label){case 0:return r=n(n({},Wr),t),te(function(e){return Et(e)&&g("number",e.scheduledAt,!0)}(r)).throw(Q.invalidParameters),s=W.of(this._iid).requestQueue,i=new Xr(n({reqId:this._generateRequestId(),scheduledMessageId:e,channelType:this.channelType,channelUrl:this.url},r)),[4,s.send(i)];case 1:return a=o.sent(),[2,a.as(Nt).message]}}))}))},s.prototype.createScheduledFileMessage=function(e){var t=this;e=n(n({},Je),e),te(Xe(e)).throw(Q.invalidParameters);var r=Date.now(),s=this._generateRequestId(),i=new Se;return ae(bt).then((function(){var n=t._createPendingScheduledFileMessage(e,s,r);Z((function(){return p(t,void 0,void 0,(function(){return _(this,(function(e){return[2,i._trigger(null,n)]}))}))}))})),y(e.file)?this._uploadFileAndUpdateParams(e).then((function(){return t._createScheduledFileMessage(e,i,s,r)})):this._createScheduledFileMessage(e,i,s,r),i},s.prototype.updateScheduledFileMessage=function(e,t){return p(this,void 0,void 0,(function(){var r,s,i;return _(this,(function(a){switch(a.label){case 0:return r=n(n({},zr),t),te(function(e){return gt(e)&&g("number",e.scheduledAt,!0)&&(y(e.file)||g("string",e.fileUrl))&&g("string",e.fileName,!0)&&g("string",e.mimeType,!0)&&g("number",e.fileSize,!0)&&(null===e.thumbnailSizes||e.thumbnailSizes.every((function(e){return g("object",e)&&e.maxWidth>0&&e.maxHeight>0})))}(r)).throw(Q.invalidParameters),y(r.file)?[4,this._uploadFileAndUpdateParams(r)]:[3,2];case 1:a.sent(),a.label=2;case 2:return s=new Yr(n({reqId:this._generateRequestId(),scheduledMessageId:e,channelType:this.channelType,channelUrl:this.url},r)),[4,W.of(this._iid).requestQueue.send(s)];case 3:return i=a.sent(),[2,i.as(Jr).message]}}))}))},s.prototype.cancelScheduledMessage=function(e){return p(this,void 0,void 0,(function(){var t;return _(this,(function(n){switch(n.label){case 0:return t=new Zr({scheduledMessageId:e,channelType:this.channelType,channelUrl:this.url}),[4,W.of(this._iid).requestQueue.send(t)];case 1:return n.sent(),[2]}}))}))},s.prototype.sendScheduledMessageNow=function(e){return p(this,void 0,void 0,(function(){var t;return _(this,(function(n){switch(n.label){case 0:return t=new $r({scheduledMessageId:e,channelType:this.channelType,channelUrl:this.url}),[4,W.of(this._iid).requestQueue.send(t)];case 1:return n.sent(),[2]}}))}))},s.prototype.getMyPushTriggerOption=function(){return p(this,void 0,void 0,(function(){var e,t,n,r,s,i;return _(this,(function(a){switch(a.label){case 0:return e=W.of(this._iid),t=e.sdkState,n=e.requestQueue,r=new ns({userId:t.userId,channelUrl:this.url}),[4,n.send(r)];case 1:return s=a.sent(),i=s.as(rs).pushTriggerOption,this.myPushTriggerOption=i,[2,i]}}))}))},s.prototype.setMyPushTriggerOption=function(e){return p(this,void 0,void 0,(function(){var t,n,r,s,i,o;return _(this,(function(u){switch(u.label){case 0:return te(a(et,e)).throw(Q.invalidParameters),t=W.of(this._iid),n=t.sdkState,r=t.requestQueue,s=new es({userId:n.userId,channelUrl:this.url,pushTriggerOption:e}),[4,r.send(s)];case 1:return i=u.sent(),o=i.as(ts).pushTriggerOption,this.myPushTriggerOption=o,[2,o]}}))}))},s.prototype.setMyCountPreference=function(e){return p(this,void 0,void 0,(function(){var t,n,r,s,i,o,u;return _(this,(function(l){switch(l.label){case 0:return te(a(ps,e)).throw(Q.invalidParameters),t=W.of(this._iid),n=t.dispatcher,r=t.sdkState,s=t.requestQueue,i=new Kr({channelUrl:this.url,userId:r.userId,countPreference:e}),[4,s.send(i)];case 1:return o=l.sent(),u=o.as(Br).countPreference,this.myCountPreference=u,this._updateUnreadCount(this.unreadMessageCount,this.unreadMentionCount),n.dispatch(new sn({channels:[this],source:$t.EVENT_CHANNEL_CREATED})),[2,u]}}))}))},s.prototype.resetMyHistory=function(){return p(this,void 0,void 0,(function(){var e,t,n,r,s,i;return _(this,(function(a){switch(a.label){case 0:return e=W.of(this._iid),t=e.dispatcher,n=e.requestQueue,r=new jr({channelUrl:this.url}),[4,n.send(r)];case 1:return s=a.sent(),i=s.as(Qr).messageOffsetTimestamp,this.messageOffsetTimestamp=i,t.dispatch(new sn({channels:[this],source:$t.EVENT_CHANNEL_RESET_HISTORY})),[2,this]}}))}))},s.prototype.updatePoll=function(e,t){return p(this,void 0,void 0,(function(){var r,s,i;return _(this,(function(a){switch(a.label){case 0:return te(g("number",e)&&function(e){return g("string",e.title,!0)&&Ne(e.data)&&g("boolean",e.isAnonymous,!0)&&g("boolean",e.allowUserSuggestion,!0)&&g("boolean",e.allowMultipleVotes,!0)&&g("number",e.closeAt,!0)}(t)).throw(Q.invalidParameters),r=W.of(this._iid).requestQueue,s=new ss(n({pollId:e},t)),[4,r.send(s)];case 1:return i=a.sent(),[2,i.as(is).poll]}}))}))},s.prototype.deletePoll=function(e){return p(this,void 0,void 0,(function(){var t,n,r;return _(this,(function(s){switch(s.label){case 0:return t=g("number",e),te(t).throw(Q.invalidParameters),n=W.of(this._iid).requestQueue,r=new as({pollId:e}),[4,n.send(r)];case 1:return s.sent(),[2]}}))}))},s.prototype.closePoll=function(e){return p(this,void 0,void 0,(function(){var t,n,r,s;return _(this,(function(i){switch(i.label){case 0:return t=g("number",e),te(t).throw(Q.invalidParameters),n=W.of(this._iid).requestQueue,r=new os({pollId:e}),[4,n.send(r)];case 1:return s=i.sent(),[2,s.as(us).poll]}}))}))},s.prototype.addPollOption=function(e,t){return p(this,void 0,void 0,(function(){var n,r,s,i;return _(this,(function(a){switch(a.label){case 0:return n=g("number",e)&&g("string",t)&&""!==t.trim(),te(n).throw(Q.invalidParameters),r=W.of(this._iid).requestQueue,s=new ls({channelUrl:this.url,channelType:this.channelType,pollId:e,optionText:t}),[4,r.send(s)];case 1:return i=a.sent(),[2,i.as(cs).poll]}}))}))},s.prototype.updatePollOption=function(e,t,n){return p(this,void 0,void 0,(function(){var r,s,i,a;return _(this,(function(o){switch(o.label){case 0:return r=g("number",e)&&g("number",t)&&g("string",n)&&""!==n.trim(),te(r).throw(Q.invalidParameters),s=W.of(this._iid).requestQueue,i=new hs({pollId:e,pollOptionId:t,optionText:n}),[4,s.send(i)];case 1:return a=o.sent(),[2,a.as(ds).poll]}}))}))},s.prototype.deletePollOption=function(e,t){return p(this,void 0,void 0,(function(){var n,r,s;return _(this,(function(i){switch(i.label){case 0:return n=g("number",e)&&g("number",t),te(n).throw(Q.invalidParameters),r=W.of(this._iid).requestQueue,s=new fs({pollId:e,pollOptionId:t}),[4,r.send(s)];case 1:return i.sent(),[2]}}))}))},s.prototype.votePoll=function(e,t){return p(this,void 0,void 0,(function(){var n,r,s,i,a,o,u;return _(this,(function(l){switch(l.label){case 0:return n=g("number",e)&&v("number",t),te(n).throw(Q.invalidParameters),r=W.of(this._iid),s=r.requestQueue,i=r.dispatcher,a=new vs({reqId:this._generateRequestId(),channelUrl:this.url,channelType:this.channelType,pollId:e,pollOptionIds:t}),[4,s.send(a)];case 1:return o=l.sent(),u=o.as(er).event,i.dispatch(new T({event:u,source:$.EVENT_POLL_VOTED})),[2,u]}}))}))},s.prototype.getPollChangeLogsSinceTimestamp=function(e){return p(this,void 0,void 0,(function(){return _(this,(function(t){switch(t.label){case 0:return te(g("number",e)).throw(Q.invalidParameters),[4,je.of(this._iid).getPollChangeLogs(this.url,this.channelType,e)];case 1:return[2,t.sent()]}}))}))},s.prototype.getPollChangeLogsSinceToken=function(e){return p(this,void 0,void 0,(function(){return _(this,(function(t){switch(t.label){case 0:return te(g("string",e,!0)),[4,je.of(this._iid).getPollChangeLogs(this.url,this.channelType,e)];case 1:return[2,t.sent()]}}))}))},s.prototype.createPollListQuery=function(e){return void 0===e&&(e=tt),new Ze(this._iid,{channelUrl:this.url,channelType:this.channelType,limit:e})},s.prototype.createPollVoterListQuery=function(e,t,n){return void 0===n&&(n=nt),new $e(this._iid,{channelUrl:this.url,channelType:this.channelType,pollId:e,pollOptionId:t,limit:n})},s.prototype._uploadFileAndUpdateParams=function(e){return p(this,void 0,void 0,(function(){var t,n,r,s,i,a,o,u,l,c,h;return _(this,(function(d){switch(d.label){case 0:return y(e.file)?(t=W.of(this._iid).requestQueue,n=new Ae({file:e.file,channelUrl:this.url,thumbnailSizes:e.thumbnailSizes,requestId:this._generateRequestId()}),[4,t.send(n)]):[3,2];case 1:r=d.sent(),s=r.as(Ue),i=s.url,a=s.fileSize,o=void 0===a?e.fileSize:a,u=s.thumbnailSizes,l=void 0===u?e.thumbnailSizes:u,c=s.requireAuth,h=void 0!==c&&c,e.fileUrl=i,e.fileSize=o,e.thumbnailSizes=l,e.requireAuth=h,d.label=2;case 2:return[2]}}))}))},s}(Ct),Es={},Cs=function(){function e(e){var t=e._iid,n=this;this._sync=null,this._metadata=null,this._iid=t;var r,s=W.of(this._iid),i=s.sdkState,a=s.logger;this._metadataKey=(r=i.userId,"sendbird:".concat(r,"@groupchannel/sync.meta"));var o=function(e){return"sendbird:".concat(e,"@groupchannel/sync")}(i.userId);this._sync=new cr(o,(function(){return p(n,void 0,void 0,(function(){var e,t,n,r,s,i;return _(this,(function(o){switch(o.label){case 0:return e={hasNext:!0,nextToken:""},[4,this.loadMetadata()];case 1:if(o.sent(),a.debug("channel background sync from",this._metadata.token),this._metadata.completed)return[3,9];o.label=2;case 2:return o.trys.push([2,5,,8]),[4,sr.of(this._iid).getMyGroupChannels(this._metadata.token,{includeEmpty:!0,order:De.CHRONOLOGICAL},100,$t.SYNC_CHANNEL_BACKGROUND)];case 3:return t=o.sent(),n=t.channels,r=t.token,e.hasNext=n.length>=100&&!!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,a.debug("channel background sync progress",e),[4,this.saveMetadata()];case 4:return o.sent(),[3,8];case 5:return s=o.sent(),a.debug("channel background sync error",s),s instanceof Q&&s.isInvalidTokenError?[4,this.clearMetaData()]:[3,7];case 6:o.sent(),o.label=7;case 7:throw s;case 8:return[3,10];case 9:e.hasNext=!1,e.nextToken="",o.label=10;case 10:return[2,e]}}))}))}))}return e.of=function(t){if(!Es[t]){var n=Es[t]=new e({_iid:t});W.of(t).dispatcher.on((function(e){if(e instanceof ue)if(e.stateType===le.CONNECTED)n.resume();else n.pause()}))}return Es[t]},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 p(this,void 0,void 0,(function(){var e;return _(this,(function(t){switch(t.label){case 0:return this._metadata?[3,2]:[4,W.of(this._iid).cacheContext.preference.get(this._metadataKey)];case 1:e=t.sent(),this._metadata={token:e?e.token:"",range:new nr(e?e.range:{top:Number.MAX_SAFE_INTEGER,bottom:0}),completed:!!e&&e.completed},t.label=2;case 2:return[2]}}))}))},e.prototype.saveMetadata=function(){return p(this,void 0,void 0,(function(){return _(this,(function(e){switch(e.label){case 0:return this._metadata?[4,W.of(this._iid).cacheContext.preference.set(this._metadataKey,this._metadata)]:[3,2];case 1:e.sent(),e.label=2;case 2:return[2]}}))}))},e.prototype.clearMetaData=function(){return p(this,void 0,void 0,(function(){return _(this,(function(e){switch(e.label){case 0:return[4,W.of(this._iid).cacheContext.preference.remove(this._metadataKey)];case 1:return e.sent(),this._metadata=null,[2]}}))}))},e.prototype.resume=function(){var e,t;W.of(this._iid).logger.debug("channel background sync resume()"),this._sync.start(null!==(t=null===(e=this._metadata)||void 0===e?void 0:e.token)&&void 0!==t?t:"")},e.prototype.pause=function(){W.of(this._iid).logger.debug("channel background sync stop()"),this._sync.stop()},e}(),Ns={},bs=function(){function e(e){var t=e._iid,n=this;this._sync=null,this._metadataKey=null,this._metadata=null,this._iid=t;var r,s=W.of(this._iid),i=s.logger,a=s.sdkState;this._metadataKey=(r=a.userId,"sendbird:".concat(r,"@groupchannel/changelogs.meta"));var o=function(e){return"sendbird:".concat(e,"@groupchannel/changelogs")}(a.userId);this._sync=new cr(o,(function(){return p(n,void 0,void 0,(function(){var e,t,n,r,s;return _(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,sr.of(this._iid).getMyGroupChannelChangeLogs(this._metadata.token,{},$t.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]}}))}))}))}return e.of=function(t){if(!Ns[t]){var n=Ns[t]=new e({_iid:t});W.of(t).dispatcher.on((function(e){if(e instanceof ue)if(e.stateType===le.CONNECTED)n.resume();else n.pause()}))}return Ns[t]},e.prototype.loadMetadata=function(){return p(this,void 0,void 0,(function(){var e,t,n,r;return _(this,(function(s){switch(s.label){case 0:return this._metadata?[3,2]:(e=W.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/1e3},s.label=2;case 2:return[2]}}))}))},e.prototype.saveMetadata=function(){return p(this,void 0,void 0,(function(){return _(this,(function(e){switch(e.label){case 0:return this._metadata?[4,W.of(this._iid).cacheContext.preference.set(this._metadataKey,this._metadata)]:[3,2];case 1:e.sent(),e.label=2;case 2:return[2]}}))}))},e.prototype.clearMetadata=function(){return p(this,void 0,void 0,(function(){return _(this,(function(e){switch(e.label){case 0:return[4,W.of(this._iid).cacheContext.preference.remove(this._metadataKey)];case 1:return e.sent(),this._metadata=null,[2]}}))}))},e.prototype.resume=function(){this._sync.start(0)},e.prototype.pause=function(){this._sync.stop()},e}(),Ms=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(ie()),this.filter=null!=n?n:new jt,this.order=null!=r?r:De.LATEST_LAST_MESSAGE,this._hasMore=!0,this._token="",this._limit=null!=s?s:Oe;var a=W.of(this._iid),o=a.sdkState;a.cacheContext.localCacheEnabled&&Cs.of(e).resume(),bs.of(e).resume(),sr.of(this._iid).subscribeGroupChannelEvent(this._key,{onUpdate:function(e,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)}})}return Object.defineProperty(e.prototype,"hasMore",{get:function(){return 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=this;void 0===n&&(n=!1);var a=[],o=[];try{for(var u=m(e),l=u.next();!l.done;l=u.next()){var c=l.value,h=Er(this.channels,c,this.order),d=h.place;if(h.contains)switch(o.push(c),t){case $t.EVENT_CHANNEL_UPDATED:case $t.EVENT_MESSAGE_RECEIVED:this.channels.splice(d,1);var f=Er(this.channels,c,this.order).place;this.channels.splice(f,0,c);break;default:this.channels[d]=c}else if(d===this.channels.length){var v=Cs.of(this._iid);(n||v.completed)&&(a.push(c),this.channels.push(c))}else a.push(c),this.channels.splice(d,0,c)}}catch(e){r={error:e}}finally{try{l&&!l.done&&(s=u.return)&&s.call(u)}finally{if(r)throw r.error}}rn(t)&&Z((function(){return p(i,void 0,void 0,(function(){var e;return _(this,(function(n){return e=new hr(t),a.length>0&&this._handler.onChannelsAdded(e,a),o.length>0&&this._handler.onChannelsUpdated(e,o),[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=m(e),l=u.next();!l.done;l=u.next()){a(l.value)}}catch(e){n={error:e}}finally{try{l&&!l.done&&(r=u.return)&&r.call(u)}finally{if(n)throw n.error}}return rn(t)&&i.length>0&&Z((function(){return p(s,void 0,void 0,(function(){var e;return _(this,(function(n){return e=new hr(t),this._handler.onChannelsDeleted(e,i),[2]}))}))})),i},e.prototype._getLocalChannels=function(){return p(this,void 0,void 0,(function(){return _(this,(function(e){switch(e.label){case 0:return[4,sr.of(this._iid).getChannelsFromCache(this._token,this.filter,this.order)];case 1:return[2,e.sent()]}}))}))},e.prototype._getRemoteChannels=function(){return p(this,void 0,void 0,(function(){var e,t,r;return _(this,(function(s){switch(s.label){case 0:return[4,sr.of(this._iid).getMyGroupChannels(this._token,n(n({},this.filter),{order:this.order}),this._limit)];case 1:return e=s.sent(),t=e.channels,r=e.token,this._token=r,this._hasMore=!!r,[2,t]}}))}))},e.prototype.loadMore=function(){return p(this,void 0,void 0,(function(){var e,t=this;return _(this,(function(n){switch(n.label){case 0:return this._hasMore?(e=[],[4,b((function(){return p(t,void 0,void 0,(function(){return _(this,(function(t){switch(t.label){case 0:return[4,this._getLocalChannels()];case 1:return e=t.sent(),[2]}}))}))}))]):[3,3];case 1:return n.sent(),[4,b((function(){return p(t,void 0,void 0,(function(){return _(this,(function(t){switch(t.label){case 0:return[4,this._getRemoteChannels()];case 1:return e=t.sent(),[2]}}))}))}))];case 2:return n.sent(),this._addChannelsToView(e,$t.REQUEST_CHANNEL,!0),[2,e];case 3:return[2,[]]}}))}))},e.prototype.dispose=function(){W.of(this._iid).cacheContext.localCacheEnabled&&Cs.of(this._iid).pause(),bs.of(this._iid).pause(),sr.of(this._iid).unsubscribeGroupChannelEvent(this._key)},e}(),Ts=function(n){function r(e){var r=this,s=e.token,i=e.limit,a=e.order,o=e.includeEmpty,u=e.membershipFilter,l=e.channelNameContainsFilter,c=e.channelUrlsFilter,h=e.customTypesFilter,d=e.customTypeStartsWithFilter,f=e.superChannelFilter,p=e.metadataOrderKeyFilter,_=e.metadataKey,m=e.metadataValues,v=e.metadataValueStartsWith,g=e.includeFrozen,y=e.includeMetaData;return(r=n.call(this)||this).method=D.GET,r.path=F,r.params=t({token:s,limit:i,order:a,show_member:!0,show_read_receipt:!0,show_delivery_receipt:!0,show_empty:o,public_mode:Ot.PUBLIC,public_membership_mode:u,name_contains:l,channel_urls:c,custom_types:h,custom_type_startswith:d,super_mode:f,metadata_order_key:p,metadata_key:_,metadata_values:m,metadata_value_startswith:v,show_frozen:g,show_metadata:y}),r}return e(r,n),r}(O),Ss=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 ys(e,t)}))),r.ts="number"==typeof a?a:null,r}return e(n,t),n}(P);!function(e){e.ALL="all",e.JOINED="joined"}(gs||(gs={}));var Us=function(t){function r(e,n){var r,s,i,a,o,u,l,c,h,d,f,p,_,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=gs.ALL,v.superChannelFilter=kt.ALL,v.metadataKey=null,v.metadataValues=null,v.metadataOrderKeyFilter=null,v.metadataValueStartsWith=null,v.order=rt.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!==(l=n.channelNameContainsFilter)&&void 0!==l?l:null,v.membershipFilter=null!==(c=n.membershipFilter)&&void 0!==c?c:gs.ALL,v.superChannelFilter=null!==(h=n.superChannelFilter)&&void 0!==h?h:kt.ALL,v.metadataKey=null!==(d=n.metadataKey)&&void 0!==d?d:null,v.metadataValues=null!==(f=n.metadataValues)&&void 0!==f?f:null,v.metadataOrderKeyFilter=null!==(p=n.metadataOrderKeyFilter)&&void 0!==p?p:null,v.metadataValueStartsWith=null!==(_=n.metadataValueStartsWith)&&void 0!==_?_:null,v.order=null!==(m=n.order)&&void 0!==m?m:rt.CHRONOLOGICAL,v}return e(r,t),r.prototype._validate=function(){return t.prototype._validate.call(this)&&g("boolean",this.includeEmpty)&&g("boolean",this.includeFrozen)&&g("boolean",this.includeMetaData)&&g("string",this.channelNameContainsFilter,!0)&&v("string",this.channelUrlsFilter,!0)&&v("string",this.customTypesFilter,!0)&&g("string",this.customTypeStartsWithFilter,!0)&&a(gs,this.membershipFilter)&&a(kt,this.superChannelFilter)&&a(rt,this.order)&&g("string",this.metadataOrderKeyFilter,!0)&&g("string",this.metadataKey,!0)&&v("string",this.metadataValues,!0)&&g("string",this.metadataValueStartsWith,!0)},r.prototype.next=function(){return p(this,void 0,void 0,(function(){var e,t,r,s,i,a,o,u,l;return _(this,(function(c){switch(c.label){case 0:return this._validate()?this._isLoading?[3,3]:(e=[],this._hasNext?(this._isLoading=!0,t=W.of(this._iid),r=t.requestQueue,s=t.dispatcher,i=new Ts(n(n({},this),{token:this._token})),[4,r.send(i)]):[3,2]):[3,5];case 1:return a=c.sent(),o=a.as(Ss),u=o.channels,l=o.token,this._token=l,this._hasNext=!!l,s.dispatch(new sn({channels:u,source:$t.REQUEST_CHANNEL})),this._isLoading=!1,[2,u];case 2:return[2,e];case 3:throw Q.queryInProgress;case 4:return[3,6];case 5:throw Q.invalidParameters;case 6:return[2]}}))}))},r}(j),As=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=Ie,e.onUserLeft=Ie,e.onUserReceivedInvitation=Ie,e.onUserDeclinedInvitation=Ie,e.onChannelHidden=Ie,e.onUnreadMemberStatusUpdated=Ie,e.onUndeliveredMemberStatusUpdated=Ie,e.onTypingStatusUpdated=Ie,e.onPollUpdated=Ie,e.onPollVoted=Ie,e.onPollDeleted=Ie,e}return e(n,t),n}(Dt)),Is=function(n){function r(e){var r=this,s=e.token,i=e.limit,a=e.order,o=e.reverse,u=e.channelUrl,l=e.messageTypeFilter,c=e.scheduledStatus;return(r=n.call(this)||this).method=D.GET,r.path="".concat(x),r.params=t({limit:i,reverse:o,channel_url:u,order:a,status:c}),s&&(r.params.token=s),l&&(r.params.message_type=l),r}return e(r,n),r}(O),ws=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 fe(e,t)})),r}return e(n,t),n}(P),Ls=function(t){function r(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(r,t),r.prototype._validate=function(){return t.prototype._validate.call(this)&&g("string",this.channelUrl,!0)&&(a(st,this.order)||null===this.order)&&g("boolean",this.reverse)&&(v(C,this.scheduledStatus)||null===this.scheduledStatus)&&a(E,this.messageTypeFilter)},r.prototype.next=function(){return p(this,void 0,void 0,(function(){var e,t,r,s,i,a;return _(this,(function(o){switch(o.label){case 0:return this._validate()?this._isLoading?[3,3]:this._hasNext?(this._isLoading=!0,e=W.of(this._iid).requestQueue,t=new Is(n(n({},this),{token:this._token})),[4,e.send(t)]):[3,2]:[3,5];case 1:return r=o.sent(),s=r.as(ws),i=s.scheduledMessages,a=s.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]}}))}))},r}(j),Ds=function(t){function r(){var e=null!==t&&t.apply(this,arguments)||this;return e.name="groupChannel",e}return e(r,t),r.prototype.init=function(e,n){var r=n.sdkState,s=n.dispatcher,i=n.sessionManager,a=n.requestQueue,o=n.logger,u=n.onlineDetector,l=n.cacheContext;t.prototype.init.call(this,e,{sdkState:r,dispatcher:s,sessionManager:i,requestQueue:a,logger:o,onlineDetector:u,cacheContext:l}),this._manager=new sr(e,{sdkState:r,cacheContext:l,dispatcher:s,sessionManager:i,requestQueue:a,logger:o})},r.prototype.createGroupChannelCollection=function(e){return void 0===e&&(e={}),new Ms(this._iid,e)},r.prototype.createMyGroupChannelListQuery=function(e){return void 0===e&&(e={}),new tr(this._iid,e)},r.prototype.createPublicGroupChannelListQuery=function(e){return void 0===e&&(e={}),new Us(this._iid,e)},r.prototype.createScheduledMessageListQuery=function(e){return void 0===e&&(e={}),new Ls(this._iid,e)},r.prototype.addGroupChannelHandler=function(e,t){te(g("string",e)&&t instanceof As).throw(Q.invalidParameters),this._manager.addHandler(e,t)},r.prototype.removeGroupChannelHandler=function(e){te(g("string",e)).throw(Q.invalidParameters),this._manager.removeHandler(e)},r.prototype.removeAllGroupChannelHandlers=function(){this._manager.clearHandler()},r.prototype.buildGroupChannelFromSerializedData=function(e){return this._manager.buildGroupChannelFromSerializedData(e)},r.prototype.buildGroupChannelListQueryFromSerializedData=function(e){return this._manager.buildGroupChannelListQueryFromSerializedData(e)},r.prototype.buildMemberFromSerializedData=function(e){return this._manager.buildMemberFromSerializedData(e)},r.prototype.getChannel=function(e){return p(this,void 0,void 0,(function(){return _(this,(function(t){return te(g("string",e)).throw(Q.invalidParameters),[2,this._manager.getChannel(e)]}))}))},r.prototype.getChannelWithoutCache=function(e){return p(this,void 0,void 0,(function(){return _(this,(function(t){return te(g("string",e)).throw(Q.invalidParameters),[2,this._manager.getChannelWithoutCache(e)]}))}))},r.prototype.getMyGroupChannelChangeLogsByToken=function(e,t){return p(this,void 0,void 0,(function(){var r;return _(this,(function(s){switch(s.label){case 0:return r=n(n({},Yt),t),te(g("string",e)&&Jt(r)).throw(Q.invalidParameters),[4,this._manager.getMyGroupChannelChangeLogs(e,r)];case 1:return[2,s.sent()]}}))}))},r.prototype.getMyGroupChannelChangeLogsByTimestamp=function(e,t){return p(this,void 0,void 0,(function(){var r;return _(this,(function(s){switch(s.label){case 0:return r=n(n({},Yt),t),te(g("number",e)&&Jt(r)).throw(Q.invalidParameters),[4,this._manager.getMyGroupChannelChangeLogs(e,r)];case 1:return[2,s.sent()]}}))}))},r.prototype.getGroupChannelCount=function(e){return p(this,void 0,void 0,(function(){var t;return _(this,(function(r){return t=n(n({},Xt),e),te(Zt(t)).throw(Q.invalidParameters),[2,this._manager.getGroupChannelCount(t)]}))}))},r.prototype.getUnreadItemCount=function(e){return void 0===e&&(e={}),p(this,void 0,void 0,(function(){return _(this,(function(t){switch(t.label){case 0:return[4,this._manager.getUnreadItemCount(e)];case 1:return[2,t.sent()]}}))}))},r.prototype.getTotalUnreadChannelCount=function(){return p(this,void 0,void 0,(function(){return _(this,(function(e){switch(e.label){case 0:return[4,this._manager.getTotalUnreadChannelCount()];case 1:return[2,e.sent()]}}))}))},r.prototype.getTotalUnreadMessageCount=function(e){return void 0===e&&(e={}),p(this,void 0,void 0,(function(){return _(this,(function(t){switch(t.label){case 0:return[4,this._manager.getTotalUnreadMessageCount(e)];case 1:return[2,t.sent()]}}))}))},r.prototype.getTotalScheduledMessageCount=function(e){return void 0===e&&(e={}),p(this,void 0,void 0,(function(){return _(this,(function(t){switch(t.label){case 0:return[4,this._manager.getTotalScheduledMessageCount(e)];case 1:return[2,t.sent()]}}))}))},r.prototype.getSubscribedTotalUnreadMessageCount=function(){return this._manager.getSubscribedTotalUnreadMessageCount()},r.prototype.getSubscribedCustomTypeTotalUnreadMessageCount=function(){return this._manager.getSubscribedCustomTypeTotalUnreadMessageCount()},r.prototype.getSubscribedCustomTypeUnreadMessageCount=function(e){return this._manager.getSubscribedCustomTypeUnreadMessageCount(e)},r.prototype.createChannel=function(e){return void 0===e&&(e={}),p(this,void 0,void 0,(function(){var t;return _(this,(function(r){return t=n(n({},zt),e),te(Wt(t)).throw(Q.invalidParameters),[2,this._manager.createChannel(t)]}))}))},r.prototype.createDistinctChannelIfNotExist=function(e){return void 0===e&&(e={}),p(this,void 0,void 0,(function(){var t;return _(this,(function(r){return t=n(n({},zt),e),te(Wt(t)).throw(Q.invalidParameters),t&&(t.isDistinct=!0),[2,this.createChannel(t)]}))}))},r.prototype.createChannelWithUserIds=function(e,t,r,s,i,a){return void 0===t&&(t=!1),void 0===r&&(r=null),void 0===s&&(s=null),void 0===i&&(i=""),void 0===a&&(a=""),p(this,void 0,void 0,(function(){var o;return _(this,(function(u){return o=n(n({},zt),{invitedUserIds:e,isDistinct:t,name:r,data:i,customType:a}),"string"==typeof s?o.coverUrl=s:o.coverImage=s,[2,this.createChannel(o)]}))}))},r.prototype.markAsReadAll=function(){return p(this,void 0,void 0,(function(){return _(this,(function(e){return this._manager.markAsReadAll(),[2]}))}))},r.prototype.markAsReadWithChannelUrls=function(e){return p(this,void 0,void 0,(function(){return _(this,(function(t){return te(v("string",e)).throw(Q.invalidParameters),this._manager.markAsReadWithChannelUrls(e),[2]}))}))},r.prototype.markAsDelivered=function(e){return p(this,void 0,void 0,(function(){return _(this,(function(t){switch(t.label){case 0:return te(g("string",e)).throw(Q.invalidParameters),[4,this.getChannel(e)];case 1:return[4,t.sent().markAsDelivered()];case 2:return t.sent(),[2]}}))}))},r}(we);export{ps as CountPreference,ys as GroupChannel,Ms as GroupChannelCollection,hr as GroupChannelEventContext,$t as GroupChannelEventSource,jt as GroupChannelFilter,As as GroupChannelHandler,tr as GroupChannelListQuery,Ds as GroupChannelModule,Gt as GroupChannelSearchField,xt as HiddenChannelFilter,ms as HiddenState,qt as Member,Ar as MemberListOrder,kr as MemberListQuery,Rt as MemberState,Ir as MemberStateFilter,gs as MembershipFilter,Lr as MessageCollection,wr as MessageCollectionInitHandler,lr as MessageCollectionInitPolicy,dr as MessageEventContext,Ur as MutedMemberFilter,_s as MutedState,Pt as MyMemberStateFilter,Ht as OperatorFilter,Ot as PublicChannelFilter,Us as PublicGroupChannelListQuery,Vt as QueryType,Kt as ReadStatus,Ls as ScheduledMessageListQuery,kt as SuperChannelFilter,Ft as UnreadChannelFilter,Bt as UnreadItemKey}; +import{_ as e,e as t,l as n,h as a,af as o,C as u,U as l,I as c,aH as h,Z as d,Y as f,j as p,k as _,z as m,T as v,i as g,q as y,s as E,aI as C,B as N,aJ as b,aK as T,aL as S,m as U,aM as A,aN as I,L as w,w as L,A as D,N as R,b as P,c as O,aO as k,aP as F,aQ as x,aR as H,an as V,W as q,aS as K,aT as B,X as j,S as Q,a8 as z,V as W,x as Y,F as J,ax as X,a9 as Z,M as $,aU as ee,u as te,D as ne,aV as re,aW as se,a2 as ie,aw as ae,E as oe,H as ue,J as le,y as ce,R as he,g as de,aX as fe,aY as pe,aZ as _e,n as me,ah as ve,ar as ge,as as ye,ai as Ee,ak as Ce,f as Ne,a as be,P as Me,a_ as Te,ay as Se,a$ as Ue,b0 as Ae,r as Ie,o as we}from"./__bundle-1abffbb6.js";export{M as MessageEventSource,aI as ScheduledStatus}from"./__bundle-1abffbb6.js";import{N as Le,G as De,g as Re,D as Pe,a as Oe,P as ke,b as Fe,U as xe,M as He,A as Ve,c as Ge,d as qe,e as Ke,f as Be,h as je,i as Qe,j as ze,S as We,v as Ye,k as Je,l as Xe,m as Ze,n as $e,o as et,p as tt,q as nt,r as rt,s as st}from"./__bundle-3b6b9d30.js";export{G as GroupChannelListOrder,i as MessageFilter,r as PublicGroupChannelListOrder,s as ScheduledMessageListOrder}from"./__bundle-3b6b9d30.js";import{f as it,j as at,k as ot,l as ut,m as lt,n as ct,o as ht,p as dt,D as ft,q as pt,r as _t,t as mt,u as vt,w as gt,x as yt,y as Et,e as Ct,C as Nt,P as bt}from"./__bundle-329965e1.js";import{C as Mt,a as Tt,O as St,M as Ut,T as At,R as It,U as wt,A as Lt,B as Dt}from"./__bundle-cd7e480a.js";var Rt;!function(e){e.NONE="none",e.JOINED="joined",e.INVITED="invited",e.LEFT="left"}(Rt||(Rt={}));var Pt,Ot,kt,Ft,xt,Ht,Vt,Gt,qt=function(r){function s(e,t){var n=r.call(this,e,t)||this;return n.state=null,n.role=null,n.isMuted=!1,n.isBlockedByMe=!1,n.isBlockingMe=!1,n.state=a(Rt,t.state)?t.state:null,n.role=a(o,t.role)?t.role:null,t.hasOwnProperty("is_muted")&&(n.isMuted=t.is_muted),t.hasOwnProperty("is_blocked_by_me")&&(n.isBlockedByMe=t.is_blocked_by_me),t.hasOwnProperty("is_blocking_me")&&(n.isBlockingMe=t.is_blocking_me),n}return e(s,r),s.payloadify=function(e){return e?t(n(n({},r.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},s}(it),Kt=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 l(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"}(Pt||(Pt={})),function(e){e.ALL="all",e.JOINED="joined_only",e.INVITED="invited_only",e.INVITED_BY_FRIEND="invited_by_friend",e.INVITED_BY_NON_FRIEND="invited_by_non_friend"}(Ot||(Ot={})),function(e){e.ALL="all",e.SUPER="super",e.NON_SUPER="nonsuper",e.BROADCAST_ONLY="broadcast_only",e.EXCLUSIVE_ONLY="exclusive_only"}(kt||(kt={})),function(e){e.ALL="all",e.UNREAD_MESSAGE="unread_message"}(Ft||(Ft={})),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"}(xt||(xt={})),function(e){e.ALL="all",e.OPERATOR="operator",e.NONOPERATOR="nonoperator"}(Ht||(Ht={})),function(e){e.AND="AND",e.OR="OR"}(Vt||(Vt={})),function(e){e.MEMBER_NICKNAME="member_nickname",e.CHANNEL_NAME="channel_name"}(Gt||(Gt={}));var Bt,jt=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=kt.ALL,this.publicChannelFilter=Pt.ALL,this.customTypeStartsWithFilter=null,this.unreadChannelFilter=Ft.ALL,this.hiddenChannelFilter=xt.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=Vt.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 Gt.CHANNEL_NAME:return e.name.toLowerCase().includes(r.toLowerCase());case Gt.MEMBER_NICKNAME:return e.members.some((function(e){return e.nickname.toLowerCase().includes(r.toLowerCase())}));default:return!0}})))return!1}if(this._userIdsFilter){var i=this._userIdsFilter,a=i.userIds,o=i.includeMode,u=i.queryType,l=e.members.map((function(e){return e.userId}));if(o){if(a.length>0)switch(u){case Vt.AND:if(a.some((function(e){return!l.includes(e)})))return!1;break;case Vt.OR:if(a.every((function(e){return!l.includes(e)})))return!1}}else{if(a.includes(t)||a.push(t),e.members.length>a.length)return!1;if(!h(a,l))return!1}}if(!this.includeEmpty&&!e.lastMessage)return!1;if(!this.includeFrozen&&e.isFrozen)return!1;if(this.customTypesFilter&&this.customTypesFilter.length>0&&!this.customTypesFilter.includes(e.customType))return!1;if(this.customTypeStartsWithFilter&&!new RegExp("^".concat(this.customTypeStartsWithFilter)).test(e.customType))return!1;if(this.channelNameContainsFilter&&!e.name.toLowerCase().includes(this.channelNameContainsFilter.toLowerCase()))return!1;if(this.nicknameContainsFilter){var c=this.nicknameContainsFilter.toLowerCase();if(e.members.every((function(e){return!e.nickname.toLowerCase().includes(c)})))return!1}if(this.nicknameStartsWithFilter){var d=this.nicknameStartsWithFilter.toLowerCase();if(e.members.every((function(e){return!e.nickname.toLowerCase().startsWith(d)})))return!1}if(this.nicknameExactMatchFilter){var f=this.nicknameExactMatchFilter.toLowerCase();if(e.members.every((function(e){return e.nickname.toLowerCase()!=f})))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 xt.UNHIDDEN:if(e.isHidden||"unhidden"!==e.hiddenState)return!1;break;case xt.HIDDEN:if(!e.isHidden)return!1;break;case xt.HIDDEN_ALLOW_AUTO_UNHIDE:if(!e.isHidden||"hidden_allow_auto_unhide"!==e.hiddenState)return!1;break;case xt.HIDDEN_PREVENT_AUTO_UNHIDE:if(!e.isHidden||"hidden_prevent_auto_unhide"!==e.hiddenState)return!1}if(this.unreadChannelFilter&&this.unreadChannelFilter===Ft.UNREAD_MESSAGE)if(0===e.unreadMessageCount)return!1;if(this.publicChannelFilter)switch(this.publicChannelFilter){case Pt.PUBLIC:if(!e.isPublic)return!1;break;case Pt.PRIVATE:if(e.isPublic)return!1}if(this.superChannelFilter)switch(this.superChannelFilter){case kt.SUPER:if(!e.isSuper)return!1;break;case kt.NON_SUPER:if(e.isSuper)return!1}return!0},e}(),Qt=function(t){function r(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(r,t),Object.defineProperty(r.prototype,"collection",{get:function(){var e=this._cacheContext.nestdb;return e?e.collection(Le):null},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"localCacheEnabled",{get:function(){return this._cacheContext.localCacheEnabled&&!!this.collection},enumerable:!1,configurable:!0}),r.prototype._serialize=function(e,t){return void 0===t&&(t=0),n(n({},e.serialize()),{lastMessageUpdatedAt:e.lastMessage?e.lastMessage.createdAt:0,syncIndex:t})},r.prototype._deserialize=function(e){return sr.of(this._iid).buildGroupChannelFromSerializedData(e)},Object.defineProperty(r.prototype,"channels",{get:function(){return d([],f(this._channels.values()),!1)},enumerable:!1,configurable:!0}),r.prototype.isCachedInMemory=function(e){return this._channels.has(e)},r.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;break;case De.CHRONOLOGICAL:if(!i&&e.createdAt>t||i&&e.createdAtt||i&&e.lastMessageUpdatedAt0?[4,this.upsert(r)]:[3,2];case 1:_.sent(),_.label=2;case 2:return[2]}}))}))},r.prototype.block=function(e,t){return p(this,void 0,void 0,(function(){return _(this,(function(n){switch(n.label){case 0:return[4,this._setBlockStateOfAllChannels(e,t,!0)];case 1:return n.sent(),[2]}}))}))},r.prototype.unblock=function(e,t){return p(this,void 0,void 0,(function(){return _(this,(function(n){switch(n.label){case 0:return[4,this._setBlockStateOfAllChannels(e,t,!1)];case 1:return n.sent(),[2]}}))}))},r.prototype.markAsRead=function(e,t){return void 0===t&&(t=d([],f(this._channels.keys()),!1)),p(this,void 0,void 0,(function(){var n,r,s,i,a,o,u,l;return _(this,(function(c){switch(c.label){case 0:n=[],c.label=1;case 1:c.trys.push([1,6,7,8]),r=m(t),s=r.next(),c.label=2;case 2:return s.done?[3,5]:(i=s.value,[4,this.get(i)]);case 3:(a=c.sent())._updateUnreadMemberState(this._sdkState.userId,e)&&(a._updateUnreadCount(0,0),n.push(a)),c.label=4;case 4:return s=r.next(),[3,2];case 5:return[3,8];case 6:return o=c.sent(),u={error:o},[3,8];case 7:try{s&&!s.done&&(l=r.return)&&l.call(r)}finally{if(u)throw u.error}return[7];case 8:return n.length>0?[4,this.upsert(n)]:[3,10];case 9:c.sent(),c.label=10;case 10:return[2]}}))}))},r}(c),zt={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},Wt=function(e){return v("string",e.invitedUserIds,!0)&&g("string",e.channelUrl,!0)&&g("string",e.coverUrl,!0)&&(y(e.coverImage)||g("string",e.coverImage)||null===e.coverImage)&&g("boolean",e.isDistinct,!0)&&g("boolean",e.isSuper,!0)&&g("boolean",e.isBroadcast,!0)&&g("boolean",e.isExclusive,!0)&&g("boolean",e.isPublic,!0)&&g("boolean",e.isStrict,!0)&&g("boolean",e.isDiscoverable,!0)&&g("boolean",e.isEphemeral,!0)&&g("string",e.accessCode,!0)&&g("string",e.name,!0)&&g("string",e.data,!0)&&g("string",e.customType,!0)&&v("string",e.operatorUserIds,!0)&&g("number",e.messageSurvivalSeconds,!0)},Yt={customTypes:null,includeEmpty:!1,includeFrozen:!0},Jt=function(e){return v("string",e.customTypes,!0)&&g("boolean",e.includeEmpty)&&g("boolean",e.includeFrozen)},Xt={myMemberStateFilter:Ot.ALL},Zt=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"}(Bt||(Bt={}));var $t,en={keys:[]},tn={channelCustomTypesFilter:null,superChannelFilter:kt.ALL},nn={channelUrl:null,scheduledStatus:null,messageTypeFilter:E.ALL};!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.REQUEST_CHANNEL="REQUEST_CHANNEL",e.REQUEST_CHANNEL_CHANGELOGS="REQUEST_CHANNEL_CHANGELOGS",e.SYNC_CHANNEL_BACKGROUND="SYNC_CHANNEL_BACKGROUND",e.SYNC_CHANNEL_CHANGELOGS="SYNC_CHANNEL_CHANGELOGS"}($t||($t={}));var rn=function(e){return e.startsWith("EVENT_")||e===$t.SYNC_CHANNEL_BACKGROUND||e===$t.SYNC_CHANNEL_CHANGELOGS},sn=function(t){function n(e){var n=e.channels,r=e.source,s=t.call(this)||this;return s.channels=n,s.source=r,s}return e(n,t),n}(N),an=function(t){function n(e){var n=e.channelUrls,r=e.source,s=t.call(this)||this;return s.channelUrls=n,s.source=r,s}return e(n,t),n}(N),on=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 p(i,void 0,void 0,(function(){var s,i,a,o,u,l,c,h,d,f,v=this;return _(this,(function(g){switch(g.label){case 0:if(!(e instanceof sn))return[3,2];s=e.channels,h=e.source,i=s.filter((function(e){return e instanceof ys})),a=t.filterOffsetChanged(i);try{for(o=m(a),u=o.next();!u.done;u=o.next())l=u.value,n.removeUnderOffset(l.url,l.messageOffsetTimestamp)}catch(e){d={error:e}}finally{try{u&&!u.done&&(f=o.return)&&f.call(o)}finally{if(d)throw d.error}}return[4,t.upsert(i)];case 1:return g.sent(),this._broadcastUpdateEvent(i,h),[3,7];case 2:return e instanceof an?(c=e.channelUrls,h=e.source,[4,t.remove(c)]):[3,5];case 3:return g.sent(),[4,b((function(){return p(v,void 0,void 0,(function(){var e,t,s,i,a,o;return _(this,(function(u){switch(u.label){case 0:u.trys.push([0,6,7,8]),e=m(c),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 4:return g.sent(),this._broadcastRemoveEvent(c,h),[3,7];case 5:return e instanceof Oe?[4,t.fetch({token:Number.MAX_SAFE_INTEGER,limit:Number.MAX_SAFE_INTEGER})]:[3,7];case 6:g.sent(),g.label=7;case 7:return[2]}}))}))}))}return e.prototype._broadcastUpdateEvent=function(e,t){var n,r;try{for(var s=m(this._observers.values()),i=s.next();!i.done;i=s.next()){i.value.onUpdate(e,t)}}catch(e){n={error:e}}finally{try{i&&!i.done&&(r=s.return)&&r.call(s)}finally{if(n)throw n.error}}},e.prototype._broadcastRemoveEvent=function(e,t){var n,r;try{for(var s=m(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}(),un=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 p(a,void 0,void 0,(function(){var t,s,i,a,o,u,l,c,h,d,f,m,v,g=this;return _(this,(function(y){switch(y.label){case 0:return e instanceof w?(t=e.messages,m=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 p(g,void 0,void 0,(function(){return _(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 L?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,m),y.label=2;case 2:return i.length>0?[4,b((function(){return p(g,void 0,void 0,(function(){return _(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,m),y.label=4;case 4:return[3,21];case 5:return e instanceof I?(a=e.messageIds,m=e.source,[4,b((function(){return p(g,void 0,void 0,(function(){return _(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,m),[3,21];case 7:return e instanceof A?(o=e.reqId,m=e.source,[4,b((function(){return p(g,void 0,void 0,(function(){return _(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,m),[3,21];case 9:return e instanceof U?(u=e.polls,m=e.source,this._cacheContext.localCacheEnabled?(l=u.map((function(e){return e.messageId})),[4,Promise.all(l.map((function(e){return n.get(e)})))]):[3,12]):[3,13];case 10:return(c=y.sent().filter((function(e){return e}))).length>0&&u.forEach((function(e){var t=c.find((function(t){return t.messageId===e.messageId}));t&&t.applyPoll(e)})),[4,b((function(){return p(g,void 0,void 0,(function(){return _(this,(function(e){switch(e.label){case 0:return[4,n.upsert(c)];case 1:return[2,e.sent()]}}))}))}))];case 11:y.sent(),y.label=12;case 12:return this._broadcastPollChangeLogEvent(u,m),[3,21];case 13:return e instanceof S?(h=e.event,m=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 p(g,void 0,void 0,(function(){return _(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,m),[3,21];case 17:return e instanceof T?(f=e.event,m=e.source,[4,n.get(f.messageId)]):[3,21];case 18:return(v=y.sent())&&v.isUserMessage()&&v.poll&&v.poll.applyPollVoteEvent(f)?[4,b((function(){return p(g,void 0,void 0,(function(){return _(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(f,m),y.label=21;case 21:return[2]}}))}))}))}return e.prototype._broadcastUpdateEvent=function(e,t){var n,r;try{for(var s=m(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=m(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=m(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=m(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=m(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=m(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}(),ln=function(r){function s(e){var s=e.userId,i=e.ts,a=e.token,o=e.filter,u=r.call(this)||this,l=n(n({},Yt),o),c=l.customTypes,h=l.includeEmpty,d=l.includeFrozen;return u.method=D.GET,u.path="".concat(R,"/").concat(encodeURIComponent(s),"/my_group_channels/changelogs"),u.params=t({show_delivery_receipt:!0,show_member:!0,show_read_receipt:!0,change_ts:i>0?i:null,token:a,custom_types:c,show_empty:h,show_frozen:d}),u}return e(s,r),s}(P),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 ys(e,t)})),r.deletedChannelUrls=n.deleted,r.hasMore=n.has_more,r.token=n.next,r}return e(n,t),n}(O),hn=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?k:F,"/").concat(encodeURIComponent(n)),s.params={show_member:!0,show_read_receipt:!0,show_delivery_receipt:!0},s}return e(n,t),n}(P),dn=function(t){function n(e,n){var r=t.call(this,e,n)||this;return r.channel=null,r.channel=new ys(e,n),r}return e(n,t),n}(O),fn=function(n){function r(e){var r=this,s=e.userId,i=e.token,a=e.limit,o=e.order,u=e.includeEmpty,l=e.myMemberStateFilter,c=e.superChannelFilter,h=e.publicChannelFilter,d=e.unreadChannelFilter,f=e.nicknameContainsFilter,p=e.nicknameStartsWithFilter,_=e.nicknameExactMatchFilter,m=e.channelNameContainsFilter,v=e.channelUrlsFilter,g=e.customTypesFilter,y=e.customTypeStartsWithFilter,E=e.hiddenChannelFilter,C=e.metadataOrderKeyFilter,N=e.metadataKey,b=e.metadataValues,M=e.metadataValueStartsWith,T=e.includeFrozen,S=e.includeMetaData,U=e.searchFilter,A=e.userIdsFilter;return(r=n.call(this)||this).method=D.GET,r.path="".concat(R,"/").concat(encodeURIComponent(s),"/my_group_channels"),r.params=t({token:i,limit:a,order:o,show_member:!0,show_read_receipt:!0,show_delivery_receipt:!0,show_empty:u,member_state_filter:l,super_mode:c,public_mode:h,unread_filter:d,members_nickname_contains:f,members_nickname_startswith:p,members_nickname:_,name_contains:m,channel_urls:v,custom_types:g,custom_type_startswith:y,hidden_mode:E,metadata_order_key:C,metadata_key:N,metadata_values:b,metadata_value_startswith:M,show_frozen:T,show_metadata:S}),U&&U.query&&U.fields&&(r.params.search_query=U.query,r.params.search_fields=U.fields),A&&A.userIds&&A.userIds.length>0&&(A.includeMode?(r.params.members_include_in=A.userIds,r.params.query_type=A.queryType.toUpperCase()):r.params.members_exactly_in=A.userIds),r}return e(r,n),r}(P),pn=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 ys(e,t)}))),r.ts=null!=a?a:null,r}return e(n,t),n}(O),_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(R,"/").concat(encodeURIComponent(n),"/group_channel_count"),s.params={state:null!=i?i:Ot.ALL},s}return e(n,t),n}(P),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}(O),vn=function(t){function n(e){var n=e.userId,r=e.filter,s=t.call(this)||this,i=r.keys;return s.method=D.GET,s.path="".concat(R,"/").concat(encodeURIComponent(n),"/unread_item_count"),s.params={item_keys:i},s}return e(n,t),n}(P),gn=function(t){function n(e,n){var r=t.call(this,e,n)||this;return"number"==typeof n[Bt.GROUP_CHANNEL_UNREAD_MENTION_COUNT]&&(r.groupChannelUnreadMentionCount=n[Bt.GROUP_CHANNEL_UNREAD_MENTION_COUNT]),"number"==typeof n[Bt.GROUP_CHANNEL_UNREAD_MESSAGE_COUNT]&&(r.groupChannelUnreadMessageCount=n[Bt.GROUP_CHANNEL_UNREAD_MESSAGE_COUNT]),"number"==typeof n[Bt.GROUP_CHANNEL_INVITATION_COUNT]&&(r.groupChannelInvitationCount=n[Bt.GROUP_CHANNEL_INVITATION_COUNT]),"number"==typeof n[Bt.SUPER_UNREAD_MENTION_COUNT]&&(r.superGroupChannelUnreadMentionCount=n[Bt.SUPER_UNREAD_MENTION_COUNT]),"number"==typeof n[Bt.SUPER_UNREAD_MESSAGE_COUNT]&&(r.superGroupChannelUnreadMessageCount=n[Bt.SUPER_UNREAD_MESSAGE_COUNT]),"number"==typeof n[Bt.SUPER_INVITATION_COUNT]&&(r.superGroupChannelInvitationCount=n[Bt.SUPER_INVITATION_COUNT]),"number"==typeof n[Bt.NONSUPER_UNREAD_MENTION_COUNT]&&(r.nonSuperGroupChannelUnreadMentionCount=n[Bt.NONSUPER_UNREAD_MENTION_COUNT]),"number"==typeof n[Bt.NONSUPER_UNREAD_MESSAGE_COUNT]&&(r.nonSuperGroupChannelUnreadMessageCount=n[Bt.NONSUPER_UNREAD_MESSAGE_COUNT]),"number"==typeof n[Bt.NONSUPER_INVITATION_COUNT]&&(r.nonSuperGroupChannelInvitationCount=n[Bt.NONSUPER_INVITATION_COUNT]),r}return e(n,t),n}(O),yn=function(t){function n(e){var n=e.userId,r=t.call(this)||this;return r.method=D.GET,r.path="".concat(R,"/").concat(encodeURIComponent(n),"/unread_channel_count"),r}return e(n,t),n}(P),En=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}(O),Cn=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(R,"/").concat(encodeURIComponent(n),"/unread_message_count"),s.params={super_mode:null!=a?a:kt.ALL,custom_types:i},s}return e(n,t),n}(P),Nn=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}(O),bn=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(x,"/count"),i.params={channel_url:n,status:Tn(r)},s&&(i.params.message_type=s),i}return e(n,t),n}(P),Mn=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}(O),Tn=function(e){if(e){var t=[];return e.forEach((function(e){switch(e){case C.PENDING:t.push(H.PENDING);break;case C.SENT:t.push(H.IN_QUEUE),t.push(H.SENT);break;case C.CANCELED:t.push(H.CANCELED);break;case C.FAILED:t.push(H.FAILED)}})),t}},Sn=function(n){function r(e){var r=this,s=e.userId,i=e.channelUrl,a=e.coverUrl,o=e.coverImage,u=e.isDistinct,l=e.isSuper,c=e.isBroadcast,h=e.isPublic,p=e.isExclusive,_=e.isDiscoverable,m=e.isStrict,v=e.isEphemeral,g=e.accessCode,y=e.name,E=e.data,C=e.customType,N=e.messageSurvivalSeconds,b=e.invitedUserIds,M=e.operatorUserIds;return(r=n.call(this)||this).method=D.POST,r.path=F,r.params=t({user_ids:d([s],f(null!=b?b:[]),!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:l,is_broadcast:c,is_exclusive:p,is_public:h,is_discoverable:_,strict:m,is_ephemeral:v,access_code:g,name:y,data:E,custom_type:C,operator_ids:M,message_survival_seconds:N}),r}return e(r,n),r}(P),Un=function(t){function n(e,n){var r=t.call(this,e,n)||this;return r.channel=new ys(e,n),r.isCreated=n.is_created,r}return e(n,t),n}(O),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(R,"/").concat(encodeURIComponent(n),"/mark_as_read_all"),s.params={channel_urls:r},s}return e(n,t),n}(P);!function(t){function n(){return null!==t&&t.apply(this,arguments)||this}e(n,t)}(O);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(F,"/").concat(encodeURIComponent(r),"/join"),n.params={user_id:s,access_code:i},n}return e(n,t),n}(P),wn=function(t){function n(e,n){var r=t.call(this,e,n)||this;return r.channel=new ys(e,n),r}return e(n,t),n}(O),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?null:a,u=i.joined_member_count,l=void 0===u?null:u,c=i.users,h=void 0===c?null:c;return s.memberCount=o,s.joinedMemberCount=l,s.members=Array.isArray(h)?h.map((function(t){return new qt(e,t)})):[new qt(e,r.data)],s}return e(n,t),n}(Mt),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(F,"/").concat(encodeURIComponent(r),"/leave"),n.params={user_id:s,should_remove_operator_status:i},n}return e(n,t),n}(P);!function(t){function n(e,n){return t.call(this,e,n)||this}e(n,t)}(O);var Rn=function(t){function n(e,n,r){var s=t.call(this,e,n,r)||this,i=r.data,a=i.member_count,o=void 0===a?null:a,u=i.joined_member_count,l=void 0===u?null:u;return s.memberCount=o,s.joinedMemberCount=l,s.member=new qt(s._iid,r.data),s}return e(n,t),n}(Mt),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(F,"/").concat(encodeURIComponent(r),"/invite"),n.params={user_ids:s},n}return e(n,t),n}(P),On=function(t){function n(e,n){var r=t.call(this,e,n)||this;return r.channel=new ys(e,n),r}return e(n,t),n}(O),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?null:a,u=i.joined_member_count,c=void 0===u?null:u,h=i.inviter,d=void 0===h?null:h,f=i.invitees,p=void 0===f?[]:f;return s.memberCount=o,s.joinedMemberCount=c,s.inviter=d?new l(e,d):null,s.invitees=p.map((function(t){return new qt(e,t)})),s}return e(n,t),n}(Mt),Fn=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(F,"/").concat(encodeURIComponent(r),"/decline"),n.params={user_id:s},n}return e(n,t),n}(P),xn=function(t){function n(e,n){var r=t.call(this,e,n)||this;return r.channel=new ys(e,n),r.channel.myMemberState=Rt.NONE,r}return e(n,t),n}(O),Hn=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,h=i.inviter,d=void 0===h?null:h,f=i.invitee,p=void 0===f?null:f;return s.memberCount=o,s.joinedMemberCount=c,s.inviter=d?new l(e,d):null,s.invitee=p?new qt(e,p):null,s}return e(n,t),n}(Mt),Vn=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 Kt(e,r),s}return e(n,t),n}(q),qn=function(n){function r(e){var r=e.channelUrl,s=e.userId,i=n.call(this)||this;return(i=n.call(this)||this).method=D.PUT,i.path="".concat(F,"/").concat(encodeURIComponent(r),"/messages/mark_as_delivered"),i.params=t({userId:s}),i}return e(r,n),r}(P);!function(t){function n(){return null!==t&&t.apply(this,arguments)||this}e(n,t)}(O);var Kn,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),jn=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(F,"/").concat(encodeURIComponent(r),"/hide"),n.params={user_id:s,hide_previous_messages:i,allow_auto_unhide:a},n}return e(n,t),n}(P),Qn=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}(O),zn=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}(q),Wn=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 l(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 l(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,r){var s=t.call(this,e,"PEDI",r)||this;return s.event=null,s.status=null,s.channelUrl=null,s.channelType=null,s.event=new ke(e,r),s.status=K(r.poll.status)||r.poll.status,s.channelUrl=r.channel_url,s.channelType=r.channel_type,s}return e(n,t),n}(q),er=function(t){function n(e,n,r){var s=t.call(this,e,"VOTE",r)||this;return s.event=null,s.channelUrl=null,s.channelType=null,s.event=new Fe(r),s.channelUrl=r.channel_url,s.channelType=r.channel_type,s}return e(n,t),n}(q),tr=function(t){function n(e,n){var r,s,i,a,o,u,l,c,h,d,f,p,_,m,v,g,y,E,C,N,b,M,T=this;return(T=t.call(this,e,n)||this).includeEmpty=!1,T.includeFrozen=!0,T.includeMetaData=!0,T.channelUrlsFilter=null,T.customTypesFilter=null,T.customTypeStartsWithFilter=null,T.nicknameContainsFilter=null,T.nicknameStartsWithFilter=null,T.nicknameExactMatchFilter=null,T.channelNameContainsFilter="",T.myMemberStateFilter=Ot.ALL,T.unreadChannelFilter=Ft.ALL,T.superChannelFilter=kt.ALL,T.publicChannelFilter=Pt.ALL,T.hiddenChannelFilter=xt.UNHIDDEN,T.searchFilter={fields:[],query:null},T.userIdsFilter={userIds:[],includeMode:!0,queryType:Vt.AND},T.metadataKey=null,T.metadataValues=null,T.metadataOrderKeyFilter=null,T.metadataValueStartsWith=null,T.order=De.LATEST_LAST_MESSAGE,T.includeEmpty=null!==(r=n.includeEmpty)&&void 0!==r&&r,T.includeFrozen=null===(s=n.includeFrozen)||void 0===s||s,T.includeMetaData=null===(i=n.includeMetaData)||void 0===i||i,T.channelUrlsFilter=null!==(a=n.channelUrlsFilter)&&void 0!==a?a:null,T.customTypesFilter=null!==(o=n.customTypesFilter)&&void 0!==o?o:null,T.customTypeStartsWithFilter=null!==(u=n.customTypeStartsWithFilter)&&void 0!==u?u:"",T.nicknameContainsFilter=null!==(l=n.nicknameContainsFilter)&&void 0!==l?l:null,T.nicknameStartsWithFilter=null!==(c=n.nicknameStartsWithFilter)&&void 0!==c?c:null,T.nicknameExactMatchFilter=null!==(h=n.nicknameExactMatchFilter)&&void 0!==h?h:null,T.channelNameContainsFilter=null!==(d=n.channelNameContainsFilter)&&void 0!==d?d:"",T.myMemberStateFilter=null!==(f=n.myMemberStateFilter)&&void 0!==f?f:Ot.ALL,T.unreadChannelFilter=null!==(p=n.unreadChannelFilter)&&void 0!==p?p:Ft.ALL,T.superChannelFilter=null!==(_=n.superChannelFilter)&&void 0!==_?_:kt.ALL,T.publicChannelFilter=null!==(m=n.publicChannelFilter)&&void 0!==m?m:Pt.ALL,T.hiddenChannelFilter=null!==(v=n.hiddenChannelFilter)&&void 0!==v?v:xt.UNHIDDEN,T.searchFilter=null!==(g=n.searchFilter)&&void 0!==g?g:{fields:[],query:null},T.userIdsFilter=null!==(y=n.userIdsFilter)&&void 0!==y?y:{userIds:[],includeMode:!0,queryType:Vt.AND},T.metadataKey=null!==(E=n.metadataKey)&&void 0!==E?E:null,T.metadataValues=null!==(C=n.metadataValues)&&void 0!==C?C:null,T.metadataOrderKeyFilter=null!==(N=n.metadataOrderKeyFilter)&&void 0!==N?N:null,T.metadataValueStartsWith=null!==(b=n.metadataValueStartsWith)&&void 0!==b?b:null,T.order=null!==(M=n.order)&&void 0!==M?M:De.LATEST_LAST_MESSAGE,T}return e(n,t),n.prototype._validate=function(){return t.prototype._validate.call(this)&&g("boolean",this.includeEmpty)&&g("boolean",this.includeFrozen)&&g("boolean",this.includeMetaData)&&g("string",this.channelNameContainsFilter)&&v("string",this.channelUrlsFilter,!0)&&v("string",this.customTypesFilter,!0)&&g("string",this.customTypeStartsWithFilter)&&g("string",this.nicknameContainsFilter,!0)&&g("string",this.nicknameStartsWithFilter,!0)&&g("string",this.nicknameExactMatchFilter,!0)&&a(Ot,this.myMemberStateFilter)&&a(kt,this.superChannelFilter)&&a(Pt,this.publicChannelFilter)&&a(Ft,this.unreadChannelFilter)&&a(xt,this.hiddenChannelFilter)&&v(Gt,this.searchFilter.fields)&&g("string",this.searchFilter.query,!0)&&v("string",this.userIdsFilter.userIds)&&g("boolean",this.userIdsFilter.includeMode)&&a(Vt,this.userIdsFilter.queryType)&&a(De,this.order)&&g("string",this.metadataOrderKeyFilter,!0)&&g("string",this.metadataKey,!0)&&v("string",this.metadataValues,!0)&&g("string",this.metadataValueStartsWith,!0)},n.prototype.serialize=function(){return B(this)},n.prototype.next=function(){return p(this,void 0,void 0,(function(){var e,t,n;return _(this,(function(r){switch(r.label){case 0:return this._validate()?this._isLoading?[3,3]:this._hasNext?(this._isLoading=!0,[4,sr.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}(j),nr=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||U.unreadMentionCount>0)&&(U._updateUnreadCount(0,0),this._dispatcher.dispatch(new sn({channels:[U],source:$t.EVENT_CHANNEL_READ})),Z((function(){return p(fn,void 0,void 0,(function(){var e,t,n,r;return _(this,(function(s){try{for(e=m(this._groupChannelHandlers.values()),t=e.next();!t.done;t=e.next())t.value.onChannelChanged(U)}catch(e){n={error:e}}finally{try{t&&!t.done&&(r=e.return)&&r.call(e)}finally{if(n)throw n.error}}return[2]}))}))}))):0!==U.unreadMessageCount&&0!==U.unreadMentionCount||(this._dispatcher.dispatch(new sn({channels:[U],source:$t.EVENT_CHANNEL_READ})),Z((function(){return p(fn,void 0,void 0,(function(){var e,t,n,r;return _(this,(function(s){try{for(e=m(this._groupChannelHandlers.values()),t=e.next();!t.done;t=e.next())t.value.onChannelChanged(U)}catch(e){n={error:e}}finally{try{t&&!t.done&&(r=e.return)&&r.call(e)}finally{if(n)throw n.error}}return[2]}))}))}))):(this._dispatcher.dispatch(new sn({channels:[U],source:$t.EVENT_CHANNEL_READ})),Z((function(){return p(fn,void 0,void 0,(function(){var e,t,n,r;return _(this,(function(s){try{for(e=m(this._groupChannelHandlers.values()),t=e.next();!t.done;t=e.next())t.value.onUnreadMemberStatusUpdated(U)}catch(e){n={error:e}}finally{try{t&&!t.done&&(r=e.return)&&r.call(e)}finally{if(n)throw n.error}}return[2]}))}))}))),pn.label=12;case 12:return[3,75];case 13:return A=e.as(Bn),le=A.channelUrl,D=A.deliveredStateUpdate,R=void 0===D?{}:D,P=this._groupChannelCache.isCachedInMemory(le),[4,this.getChannel(le,!0)];case 14:if(O=pn.sent(),P)for(k in R)O._updateUndeliveredMemberState(k,R[k]);return this._dispatcher.dispatch(new sn({channels:[O],source:$t.EVENT_CHANNEL_DELIVERED})),Object.keys(R).some((function(e){return e!==fn._sdkState.userId}))&&Z((function(){return p(fn,void 0,void 0,(function(){var e,t,n,r;return _(this,(function(s){try{for(e=m(this._groupChannelHandlers.values()),t=e.next();!t.done;t=e.next())t.value.onUndeliveredMemberStatusUpdated(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]}))}))})),[3,75];case 15:return F=e.as(It),le=F.channelUrl,ce=F.channelType,x=F.event,ce!==u.GROUP?[3,18]:[4,this.getChannel(le,!0)];case 16:return H=pn.sent(),[4,this.getMessageFromCache(x.messageId)];case 17:(q=pn.sent())&&(q.applyReactionEvent(x),this._dispatcher.dispatch(new w({messages:[q],source:$.EVENT_MESSAGE_REACTION_UPDATED}))),Z((function(){return p(fn,void 0,void 0,(function(){var e,t,n,r;return _(this,(function(s){try{for(e=m(this._groupChannelHandlers.values()),t=e.next();!t.done;t=e.next())t.value.onReactionUpdated(H,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]}))}))})),pn.label=18;case 18:return[3,75];case 19:return(V=e.as(At).event).channelType!==u.GROUP?[3,22]:[4,this.getChannel(V.channelUrl,!0)];case 20:return G=pn.sent(),[4,this.getMessageFromCache(V.targetMessageId)];case 21:(q=pn.sent())&&(q.applyThreadInfoUpdateEvent(V),this._dispatcher.dispatch(new w({messages:[q],source:$.EVENT_MESSAGE_THREADINFO_UPDATED}))),Z((function(){return p(fn,void 0,void 0,(function(){var e,t,n,r;return _(this,(function(s){try{for(e=m(this._groupChannelHandlers.values()),t=e.next();!t.done;t=e.next())t.value.onThreadInfoUpdated(G,V)}catch(e){n={error:e}}finally{try{t&&!t.done&&(r=e.return)&&r.call(e)}finally{if(n)throw n.error}}return[2]}))}))})),pn.label=22;case 22:return[3,75];case 23:K=e.as(Ut).groupChannelMemberCounts,B=[],pn.label=24;case 24:pn.trys.push([24,29,30,31]),j=m(K),Q=j.next(),pn.label=25;case 25:return Q.done?[3,28]:(z=Q.value,le=z.channelUrl,He=z.memberCount,Ve=z.joinedMemberCount,Y=z.updatedAt,[4,this.getChannelFromCache(le)]);case 26:(J=pn.sent())&&J._setLatestMemberCount(He,Ve,Y)&&B.push(J),pn.label=27;case 27:return Q=j.next(),[3,25];case 28:return[3,31];case 29:return te=pn.sent(),nn={error:te},[3,31];case 30:try{Q&&!Q.done&&(rn=j.return)&&rn.call(j)}finally{if(nn)throw nn.error}return[7];case 31:return B.length>0&&(this._dispatcher.dispatch(new sn({channels:B,source:$t.EVENT_CHANNEL_MEMBER_COUNT_UPDATED})),Z((function(){return p(fn,void 0,void 0,(function(){var e,t,n,r;return _(this,(function(s){try{for(e=m(this._groupChannelHandlers.values()),t=e.next();!t.done;t=e.next())t.value.onChannelMemberCountChanged(B)}catch(e){n={error:e}}finally{try{t&&!t.done&&(r=e.return)&&r.call(e)}finally{if(n)throw n.error}}return[2]}))}))}))),[3,75];case 32:return ne=e.as($n),se=ne.event,ie=ne.status,le=ne.channelUrl,ce=ne.channelType,le&&ce?[4,this.getChannel(le,!0)]:[3,75];case 33:return ae=pn.sent(),this._dispatcher.dispatch(new S({event:se,source:$.EVENT_POLL_UPDATED})),Z(ie===re?function(){return p(fn,void 0,void 0,(function(){var e,t,n,r;return _(this,(function(s){try{for(e=m(this._groupChannelHandlers.values()),t=e.next();!t.done;t=e.next())t.value.onPollDeleted(ae,se.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 p(fn,void 0,void 0,(function(){var e,t,n,r;return _(this,(function(s){try{for(e=m(this._groupChannelHandlers.values()),t=e.next();!t.done;t=e.next())t.value.onPollUpdated(ae,se)}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,75];case 34:return oe=e.as(er),ue=oe.event,le=oe.channelUrl,ce=oe.channelType,le&&ce?[4,this.getChannel(le,!0)]:[3,75];case 35:return he=pn.sent(),this._dispatcher.dispatch(new T({event:ue,source:$.EVENT_POLL_VOTED})),Z((function(){return p(fn,void 0,void 0,(function(){var e,t,n,r;return _(this,(function(s){try{for(e=m(this._groupChannelHandlers.values()),t=e.next();!t.done;t=e.next())t.value.onPollVoted(he,ue)}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,75];case 36:if(!(de=e.as(Mt).event).isGroupChannelEvent)return[3,73];switch(de.category){case Tt.CHANNEL_JOIN:return[3,37];case Tt.CHANNEL_LEAVE:return[3,39];case Tt.CHANNEL_OPERATOR_UPDATE:return[3,43];case Tt.CHANNEL_INVITE:return[3,45];case Tt.CHANNEL_DECLINE_INVITE:return[3,47];case Tt.TYPING_START:case Tt.TYPING_END:return[3,49];case Tt.USER_CHANNEL_MUTE:case Tt.USER_CHANNEL_UNMUTE:return[3,51];case Tt.USER_CHANNEL_BAN:return[3,53];case Tt.USER_CHANNEL_UNBAN:return[3,57];case Tt.CHANNEL_FREEZE:case Tt.CHANNEL_UNFREEZE:return[3,59];case Tt.CHANNEL_HIDE:return[3,61];case Tt.CHANNEL_UNHIDE:return[3,63];case Tt.CHANNEL_DELETED:return[3,65];case Tt.CHANNEL_PROP_CHANGED:return[3,67];case Tt.CHANNEL_META_DATA_CHANGED:return[3,69];case Tt.CHANNEL_META_COUNTERS_CHANGED:return[3,71]}return[3,73];case 37:return[4,this.getChannel(de.channelUrl,!0)];case 38:return fe=pn.sent(),pe=e.as(Ln),_e=pe.memberCount,me=pe.joinedMemberCount,ve=pe.members,ge=!1,ve.forEach((function(e){fe.isExclusive||fe.isSuper||fe.isBroadcast?ge=ge||fe._setLatestMemberCount(_e,me,de.ts):(e.state=Rt.JOINED,fe.addMember(e,de.ts),fn._updateJoinedMemberCount(fe)),e.userId===fn._sdkState.userId&&(fe.myMemberState=Rt.JOINED)})),this._dispatcher.dispatch(new sn({channels:[fe],source:$t.EVENT_CHANNEL_JOINED})),Z((function(){return p(fn,void 0,void 0,(function(){return _(this,(function(e){return this._groupChannelHandlers.forEach((function(e){var t,n;try{for(var r=m(ve),s=r.next();!s.done;s=r.next()){var i=s.value;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&&ge&&e.onChannelMemberCountChanged([fe])})),[2]}))}))})),[3,73];case 39:return(tt=this._leftChannels.get(de.channelUrl))?(Ee=tt.channel,[3,42]):[3,40];case 40:return[4,this.getChannel(de.channelUrl,!0)];case 41:Ee=pn.sent(),pn.label=42;case 42:return ye=Ee,Ce=e.as(Rn),He=Ce.memberCount,Ve=Ce.joinedMemberCount,Ne=Ce.member,be=!1,Me=W.of(this._iid).appInfo,ye.isExclusive||ye.isSuper||ye.isBroadcast?be=ye._setLatestMemberCount(He,Ve,de.ts):(Me.enabledChannelMemberShipHistory?(ye.members.find((function(e){return e.userId===Ne.userId})).state=Rt.LEFT,ye.memberCount=He):ye.removeMember(Ne),this._updateJoinedMemberCount(ye)),Ne.userId===this._sdkState.userId?(ye.myMemberState=Rt.NONE,ye.invitedAt=0,ye.joinedAt=0,ye._updateUnreadCount(0,0),ye.isPublic?this._dispatcher.dispatch(new sn({channels:[ye],source:$t.EVENT_CHANNEL_LEFT})):(this._markAsLeave(ye),this._dispatcher.dispatch(new an({channelUrls:[ye.url],source:$t.EVENT_CHANNEL_LEFT})))):this._dispatcher.dispatch(new sn({channels:[ye],source:$t.EVENT_CHANNEL_LEFT})),Z((function(){return p(fn,void 0,void 0,(function(){return _(this,(function(e){return this._groupChannelHandlers.forEach((function(e){e.onUserLeft(ye,Ne),ye.isBroadcast&&be&&e.onChannelMemberCountChanged([ye])})),[2]}))}))})),[3,73];case 43:return[4,this.getChannel(de.channelUrl,!0)];case 44:Te=pn.sent(),Se=e.as(St).operators,Ue=Se.map((function(e){return e.userId}));try{for(Ae=m(Te.members),Ie=Ae.next();!Ie.done;Ie=Ae.next())(et=Ie.value).role=Ue.includes(et.userId)?o.OPERATOR:o.NONE}catch(e){on={error:e}}finally{try{Ie&&!Ie.done&&(un=Ae.return)&&un.call(Ae)}finally{if(on)throw on.error}}return Te.myRole=Ue.includes(this._sdkState.userId)?o.OPERATOR:o.NONE,this._dispatcher.dispatch(new sn({channels:[Te],source:$t.EVENT_CHANNEL_OPERATOR_UPDATED})),Z((function(){return p(fn,void 0,void 0,(function(){return _(this,(function(e){return this._groupChannelHandlers.forEach((function(e){e.onOperatorUpdated(Te,Se)})),[2]}))}))})),[3,73];case 45:return[4,this.getChannel(de.channelUrl,!0)];case 46:we=pn.sent(),Le=e.as(kn),He=Le.memberCount,Ve=Le.joinedMemberCount,De=Le.inviter,(Re=Le.invitees).forEach((function(e){return e.state=Rt.INVITED}));try{for(Pe=m(Re),Oe=Pe.next();!Oe.done;Oe=Pe.next())ke=Oe.value,we.isExclusive||we.isSuper||we.isBroadcast?we._setLatestMemberCount(He,Ve,de.ts):we.addMember(ke,de.ts),this._sdkState.userId===ke.userId&&(we.hiddenState=ms.UNHIDDEN,we.myMemberState!==Rt.JOINED&&(we.myMemberState=Rt.INVITED),we.invitedAt=de.ts)}catch(e){ln={error:e}}finally{try{Oe&&!Oe.done&&(cn=Pe.return)&&cn.call(Pe)}finally{if(ln)throw ln.error}}return this._dispatcher.dispatch(new sn({channels:[we],source:$t.EVENT_CHANNEL_INVITED})),Z((function(){return p(fn,void 0,void 0,(function(){return _(this,(function(e){return this._groupChannelHandlers.forEach((function(e){e.onUserReceivedInvitation(we,De,Re)})),[2]}))}))})),[3,73];case 47:return[4,this.getChannel(de.channelUrl,!0)];case 48:return Fe=pn.sent(),xe=e.as(Hn),He=xe.memberCount,Ve=xe.joinedMemberCount,Be=xe.inviter,je=xe.invitee,Fe.isExclusive||Fe.isSuper||Fe.isBroadcast?Fe._setLatestMemberCount(He,Ve,de.ts):Fe.removeMember(je),this._sdkState.userId===je.userId?(Fe.invitedAt=0,Fe.myMemberState=Rt.NONE,Fe.isPublic?this._dispatcher.dispatch(new sn({channels:[Fe],source:$t.EVENT_CHANNEL_DECLINED_INVITE})):this._dispatcher.dispatch(new an({channelUrls:[Fe.url],source:$t.EVENT_CHANNEL_DECLINED_INVITE}))):this._dispatcher.dispatch(new sn({channels:[Fe],source:$t.EVENT_CHANNEL_DECLINED_INVITE})),Z((function(){return p(fn,void 0,void 0,(function(){return _(this,(function(e){return this._groupChannelHandlers.forEach((function(e){e.onUserDeclinedInvitation(Fe,Be,je)})),[2]}))}))})),[3,73];case 49:return[4,this.getChannel(de.channelUrl,!0)];case 50:return Qe=pn.sent(),ze=de.category===Tt.TYPING_START,We=e.as(ze?Yn:Xn).user,Qe._updateTypingStatus(We,ze?de.ts:0),this._dispatcher.dispatch(new sn({channels:[Qe],source:$t.EVENT_CHANNEL_TYPING_STATUS_UPDATE})),Z((function(){return p(fn,void 0,void 0,(function(){return _(this,(function(e){return this._groupChannelHandlers.forEach((function(e){e.onTypingStatusUpdated(Qe)})),[2]}))}))})),[3,73];case 51:return[4,this.getChannel(de.channelUrl,!0)];case 52:Ye=pn.sent(),Je=de.category===Tt.USER_CHANNEL_MUTE,(Xe=e.as(Je?ht:dt).user).userId===this._sdkState.userId&&(Ye.myMutedState=Je?_s.MUTED:_s.UNMUTED);try{for(Ze=m(Ye.members),$e=Ze.next();!$e.done;$e=Ze.next())if((et=$e.value).userId===Xe.userId){et.isMuted=Je;break}}catch(e){hn={error:e}}finally{try{$e&&!$e.done&&(dn=Ze.return)&&dn.call(Ze)}finally{if(hn)throw hn.error}}return this._dispatcher.dispatch(new sn({channels:[Ye],source:Je?$t.EVENT_CHANNEL_MUTED:$t.EVENT_CHANNEL_UNMUTED})),Z((function(){return p(fn,void 0,void 0,(function(){return _(this,(function(e){return this._groupChannelHandlers.forEach((function(e){Je?e.onUserMuted(Ye,Xe):e.onUserUnmuted(Ye,Xe)})),[2]}))}))})),[3,73];case 53:return(tt=this._leftChannels.get(de.channelUrl))?(rt=tt.channel,[3,56]):[3,54];case 54:return[4,this.getChannel(de.channelUrl,!0)];case 55:rt=pn.sent(),pn.label=56;case 56:return nt=rt,this._markAsLeave(nt),st=e.as(ct).user,Z((function(){return p(fn,void 0,void 0,(function(){return _(this,(function(e){return this._groupChannelHandlers.forEach((function(e){e.onUserBanned(nt,st)})),[2]}))}))})),[3,73];case 57:return[4,this.getChannel(de.channelUrl,!0)];case 58:return it=pn.sent(),vt=e.as(lt).user,Z((function(){return p(fn,void 0,void 0,(function(){return _(this,(function(e){return this._groupChannelHandlers.forEach((function(e){e.onUserUnbanned(it,vt)})),[2]}))}))})),[3,73];case 59:return[4,this.getChannel(de.channelUrl,!0)];case 60:return gt=pn.sent(),yt=e.as(ut).freeze,gt.isFrozen=yt,this._dispatcher.dispatch(new sn({channels:[gt],source:yt?$t.EVENT_CHANNEL_FROZEN:$t.EVENT_CHANNEL_UNFROZEN})),Z((function(){return p(fn,void 0,void 0,(function(){return _(this,(function(e){return this._groupChannelHandlers.forEach((function(e){yt?e.onChannelFrozen(gt):e.onChannelUnfrozen(gt)})),[2]}))}))})),[3,73];case 61:return[4,this.getChannel(de.channelUrl,!0)];case 62:return Et=pn.sent(),Ct=e.as(zn),Nt=Ct.allowAutoUnhide,bt=Ct.hidePreviousMessages,Dt=Ct.messageOffsetTimestamp,null!==Nt&&(Et.hiddenState=Nt?ms.HIDDEN_ALLOW_AUTO_UNHIDE:ms.HIDDEN_PREVENT_AUTO_UNHIDE),null!==bt&&bt&&Et._updateUnreadCount(0,0),null!==Dt&&(Et.messageOffsetTimestamp=Dt),this._dispatcher.dispatch(new sn({channels:[Et],source:$t.EVENT_CHANNEL_HIDDEN})),Z((function(){return p(fn,void 0,void 0,(function(){return _(this,(function(e){return this._groupChannelHandlers.forEach((function(e){e.onChannelHidden(Et)})),[2]}))}))})),[3,73];case 63:return[4,this.getChannel(de.channelUrl,!0)];case 64:return(Pt=pn.sent()).hiddenState=ms.UNHIDDEN,this._dispatcher.dispatch(new sn({channels:[Pt],source:$t.EVENT_CHANNEL_UNHIDDEN})),Z((function(){return p(fn,void 0,void 0,(function(){return _(this,(function(e){return this._groupChannelHandlers.forEach((function(e){e.onChannelChanged(Pt)})),[2]}))}))})),[3,73];case 65:return[4,this.getChannel(de.channelUrl,!0)];case 66:return Ot=pn.sent(),this._dispatcher.dispatch(new an({channelUrls:[de.channelUrl],source:$t.EVENT_CHANNEL_DELETED})),Z((function(){return p(fn,void 0,void 0,(function(){return _(this,(function(e){return this._groupChannelHandlers.forEach((function(e){e.onChannelDeleted(Ot.url,Ot.channelType)})),[2]}))}))})),[3,73];case 67:return[4,this.getChannelWithoutCache(de.channelUrl,!0)];case 68:return kt=pn.sent(),this._dispatcher.dispatch(new sn({channels:[kt],source:$t.EVENT_CHANNEL_UPDATED})),Z((function(){return p(fn,void 0,void 0,(function(){return _(this,(function(e){return this._groupChannelHandlers.forEach((function(e){e.onChannelChanged(kt)})),[2]}))}))})),[3,73];case 69:return[4,this.getChannel(de.channelUrl,!0)];case 70:return Ft=pn.sent(),xt=e.as(ot),Ht=xt.created,Vt=xt.updated,Gt=xt.deleted,Ht&&Ft._upsertCachedMetaData(Ht,de.ts),Vt&&Ft._upsertCachedMetaData(Vt,de.ts),Gt&&Ft._removeFromCachedMetaData(Gt,de.ts),Z((function(){return p(fn,void 0,void 0,(function(){return _(this,(function(e){return this._groupChannelHandlers.forEach((function(e){Ht&&e.onMetaDataCreated(Ft,Ht),Vt&&e.onMetaDataUpdated(Ft,Vt),Gt&&e.onMetaDataDeleted(Ft,Gt)})),[2]}))}))})),[3,73];case 71:return[4,this.getChannel(de.channelUrl,!0)];case 72:return qt=pn.sent(),Kt=e.as(at),Bt=Kt.created,jt=Kt.updated,Qt=Kt.deleted,Z((function(){return p(fn,void 0,void 0,(function(){return _(this,(function(e){return this._groupChannelHandlers.forEach((function(e){Bt&&e.onMetaCounterCreated(qt,Bt),jt&&e.onMetaCounterUpdated(qt,jt),Qt&&e.onMetaCounterDeleted(qt,Qt)})),[2]}))}))})),[3,73];case 73:return[3,75];case 74:switch((zt=e.as(Ge).event).category){case qe.USER_BLOCK:Wt=Ke.getDataAsUserBlockEvent(this._iid,zt),Jt=Wt.blocker,Xt=Wt.blockee,this._groupChannelCache.block(Jt.userId,Xt.userId);break;case qe.USER_UNBLOCK:Yt=Ke.getDataAsUserBlockEvent(this._iid,zt),Jt=Yt.blocker,Xt=Yt.blockee,this._groupChannelCache.unblock(Jt.userId,Xt.userId)}return[3,75];case 75:return[3,77];case 76:if(Zt=pn.sent(),X(Zt))throw Zt;return[3,77];case 77: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===Rt.JOINED})).length},e.prototype.getChannel=function(e,t){return void 0===t&&(t=!1),p(this,void 0,void 0,(function(){var n;return _(this,(function(r){switch(r.label){case 0:te(g("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),p(this,void 0,void 0,(function(){var n,r,s,i,a;return _(this,(function(o){switch(o.label){case 0:return te(g("string",e)).throw(Q.invalidParameters),n=new hn({channelUrl:e,isInternalCall:t}),[4,this._requestQueue.send(n)];case 1:switch(r=o.sent(),s=r.as(dn).channel,i=s.unreadMessageCount,a=s.unreadMentionCount,s.myCountPreference){case ps.UNREAD_MESSAGE_COUNT_ONLY:a=0;break;case ps.UNREAD_MENTION_COUNT_ONLY:i=0;break;case ps.OFF:i=0,a=0}return s._updateUnreadCount(i,a),[4,this._groupChannelCache.upsert([s])];case 2:return o.sent(),[2,s]}}))}))},e.prototype.getMyGroupChannels=function(e,t,r,s){return void 0===s&&(s=$t.REQUEST_CHANNEL),p(this,void 0,void 0,(function(){var i,a,o,u,l;return _(this,(function(c){switch(c.label){case 0:return i=new fn(n(n({},t),{userId:this._sdkState.userId,token:e,limit:r})),[4,this._requestQueue.send(i)];case 1:return a=c.sent(),o=a.as(pn),u=o.channels,l=o.token,this._dispatcher.dispatch(new sn({channels:u,source:s})),[2,{channels:u,token:l}]}}))}))},e.prototype.getMessageFromCache=function(e){return p(this,void 0,void 0,(function(){return _(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=Be),p(this,void 0,void 0,(function(){return _(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=Be),p(this,void 0,void 0,(function(){return _(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.getAllFailedMessagesFromCache=function(e,t){return p(this,void 0,void 0,(function(){return _(this,(function(n){switch(n.label){case 0:return[4,this._unsentMessageCache.fetch({channelUrl:e,filter:t,sendingStatus:ne.FAILED})];case 1:return[2,n.sent()]}}))}))},e.prototype.removeFailedMessageFromCache=function(e){return p(this,void 0,void 0,(function(){return _(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 p(this,void 0,void 0,(function(){return _(this,(function(s){switch(s.label){case 0:return[4,this._messageCache.countBetween(e,t,new nr({top:n,bottom:r}))];case 1:return[2,s.sent()]}}))}))},e.prototype.getMyGroupChannelChangeLogs=function(e,r,s){return void 0===s&&(s=$t.REQUEST_CHANNEL_CHANGELOGS),p(this,void 0,void 0,(function(){var i,a,o,u,l,c;return _(this,(function(h){switch(h.label){case 0:return i=n(n({},Yt),r),te((g("string",e)||g("number",e))&&Jt(i)).throw(Q.invalidParameters),a=new ln(t({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=h.sent(),u=o.as(cn),l=u.updatedChannels,c=u.deletedChannelUrls,l.length>0&&this._dispatcher.dispatch(new sn({channels:l,source:s})),c.length>0&&this._dispatcher.dispatch(new an({channelUrls:c,source:s})),[2,u]}}))}))},e.prototype.getGroupChannelCount=function(e){return p(this,void 0,void 0,(function(){var t,r,s;return _(this,(function(i){switch(i.label){case 0:return t=n(n({},Xt),e),te(Zt(t)).throw(Q.invalidParameters),r=new _n({userId:this._sdkState.userId,filter:t}),[4,this._requestQueue.send(r)];case 1:return s=i.sent(),[2,s.as(mn).groupChannelCount]}}))}))},e.prototype.getUnreadItemCount=function(e){return p(this,void 0,void 0,(function(){var t,r,s,i,a;return _(this,(function(o){switch(o.label){case 0:return t=n(n({},en),e),te(function(e){return v(Bt,e.keys)}(t)).throw(Q.invalidParameters),r=W.of(this._iid),s=r.sdkState,i=r.requestQueue,a=new vn({userId:s.userId,filter:t}),[4,i.send(a)];case 1:return[2,o.sent().as(gn)]}}))}))},e.prototype.getTotalUnreadChannelCount=function(){return p(this,void 0,void 0,(function(){var e,t,n,r,s;return _(this,(function(i){switch(i.label){case 0:return e=W.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(En).unreadCount]}}))}))},e.prototype.getTotalUnreadMessageCount=function(e){return p(this,void 0,void 0,(function(){var t,r,s,i,o,u;return _(this,(function(l){switch(l.label){case 0:return t=n(n({},tn),e),te(function(e){return v("string",e.channelCustomTypesFilter,!0)&&a(kt,e.superChannelFilter)}(t)).throw(Q.invalidParameters),r=W.of(this._iid),s=r.sdkState,i=r.requestQueue,o=new Cn({userId:s.userId,filter:t}),[4,i.send(o)];case 1:return u=l.sent(),[2,u.as(Nn).unreadCount]}}))}))},e.prototype.getTotalScheduledMessageCount=function(e){return void 0===e&&(e={}),p(this,void 0,void 0,(function(){var t,r,s,i;return _(this,(function(o){switch(o.label){case 0:return t=n(n({},nn),e),te(function(e){return g("string",e.channelUrl,!0)&&v(C,e.scheduledStatus,!0)&&a(E,e.messageTypeFilter)}(t)).throw(Q.invalidParameters),r=W.of(this._iid).requestQueue,s=new bn(t),[4,r.send(s)];case 1:return i=o.sent(),[2,i.as(Mn).count]}}))}))},e.prototype.getSubscribedTotalUnreadMessageCount=function(){var e=W.of(this._iid).subscribedUnreadMessageCount;return e.all>=0?e.all:0},e.prototype.getSubscribedCustomTypeTotalUnreadMessageCount=function(){var e=0,t=W.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=W.of(this._iid).subscribedUnreadMessageCount.customTypes[e])&&void 0!==t?t:0},e.prototype.createChannel=function(e){return p(this,void 0,void 0,(function(){var t,r,s,i;return _(this,(function(a){switch(a.label){case 0:return t=n(n({},zt),e),te(Wt(t)).throw(Q.invalidParameters),t.isPublic||(t.accessCode=null),r=new Sn(n({userId:this._sdkState.userId},t)),[4,this._requestQueue.send(r)];case 1:return s=a.sent(),i=s.as(Un).channel,[4,this._groupChannelCache.upsert([i])];case 2:return a.sent(),[2,i]}}))}))},e.prototype.markAsReadAll=function(){return p(this,void 0,void 0,(function(){var e,t,n,r,s,i,a,o;return _(this,(function(u){switch(u.label){case 0:return e=Date.now(),te(e-this._markAsReadAllLastSentAt>=1e3).throw(Q.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=m(n),s=r.next();!s.done;s=r.next())(i=s.value)._updateUnreadMemberState(this._sdkState.userId,e),i._updateUnreadCount(0,0)}catch(e){a={error:e}}finally{try{s&&!s.done&&(o=r.return)&&o.call(r)}finally{if(a)throw a.error}}return n.length>0?[4,this._groupChannelCache.upsert(n)]:[3,3];case 2:u.sent(),u.label=3;case 3:return[2]}}))}))},e.prototype.markAsReadWithChannelUrls=function(e){return p(this,void 0,void 0,(function(){var t,n,r,s,i,a,o,u,l;return _(this,(function(c){switch(c.label){case 0:return t=Date.now(),te(v("string",e)&&t-this._markAsReadAllLastSentAt>=1e3).throw(Q.markAsReadAllRateLimitExceeded),this._markAsReadAllLastSentAt=t,n=new An({userId:this._sdkState.userId,channelUrls:e}),[4,this._requestQueue.send(n)];case 1:c.sent(),r=this._groupChannelCache.channels,s=[];try{for(i=m(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&&(l=i.return)&&l.call(i)}finally{if(u)throw u.error}}return s.length>0?[4,this._groupChannelCache.upsert(s)]:[3,3];case 2:c.sent(),c.label=3;case 3:return[2]}}))}))},e.prototype.markAsDelivered=function(e){return p(this,void 0,void 0,(function(){return _(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}(),ir=new Map,ar=new Map,or=new Map,ur=function(){function e(t){var n=t.key,r=t.concurrentCallLimit,s=void 0===r?2:r,i=t.backOffDelay,a=void 0===i?0:i,o=this;this._holdersKey=e.createSemaphoreHoldersKey(n),this._resolversKey=e.createSemaphoreResolversKey(n),this._chainProcessStateKey=e.createChainProcessStateKey(n),this._numLocks=s,this._backOffDelay=a,this._localAcquiredKeys=[],this._localResolversData=[],se()?(ir[this._holdersKey]||(ir[this._holdersKey]=[]),ar[this._resolversKey]||(ar[this._resolversKey]=[])):(window.addEventListener("storage",(function(e){return p(o,void 0,void 0,(function(){var t,n;return _(this,(function(r){if(this._localResolversData.length>0&&this.numLocksAvailable>0&&!this._isProcessChainAcquireRunning()&&this._hasHighestPriorityResolver())switch(e.key){case this._holdersKey:if(t=JSON.parse(e.oldValue),n=JSON.parse(e.newValue),!t||!n||n.length>=t.length)return[2];this._processChainResolve();break;case this._chainProcessStateKey:if(JSON.parse(e.newValue))return[2];this._processChainResolve();break;default:return[2]}return[2]}))}))})),window.addEventListener("beforeunload",(function(){var e=o._getLocalResolversData(),t=o._localResolversData.map((function(e){return e.key})),n=e.filter((function(e){return t.indexOf(e.key)<0}));window.localStorage.setItem(o._resolversKey,JSON.stringify(n)),o._localAcquiredKeys.forEach((function(e){return o.release(e)}))})))}return e.createSemaphoreHoldersKey=function(e){return"collection@semaphore_holders_for:"+e},e.createSemaphoreResolversKey=function(e){return"collection@semaphore_resolvers_for:"+e},e.createChainProcessStateKey=function(e){return"collection@semaphore_chain_process_state_for:"+e},Object.defineProperty(e.prototype,"numLocks",{get:function(){return this._numLocks},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"backOffDelay",{get:function(){return this._backOffDelay},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"numLocksAvailable",{get:function(){if(se())return this.numLocks-ir[this._holdersKey].length;var e=this._getLocalHoldersData();return this.numLocks-e.length},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"waitCount",{get:function(){return se()?ar[this._resolversKey].length:this._getLocalResolversData().length},enumerable:!1,configurable:!0}),e.prototype._hasHighestPriorityResolver=function(){var e=this._getLocalResolversData();return e.length>0&&this._localResolversData.map((function(e){return e.key})).indexOf(e[0].key)>=0},e.prototype._isProcessChainAcquireRunning=function(){if(se())return or[this._chainProcessStateKey];var e=window.localStorage[this._chainProcessStateKey];return void 0!==e&&JSON.parse(e)},e.prototype._setProcessChainAcquireRunning=function(e){se()?or[this._chainProcessStateKey]=e:e?window.localStorage.setItem(this._chainProcessStateKey,JSON.stringify(e)):window.localStorage.removeItem(this._chainProcessStateKey)},e.prototype._processChainResolve=function(){return p(this,void 0,void 0,(function(){var e;return _(this,(function(t){switch(t.label){case 0:return this.waitCount>0&&this.numLocksAvailable>0&&!this._isProcessChainAcquireRunning()?(this._setProcessChainAcquireRunning(!0),this._tryResolve()?[4,ae(this._backOffDelay)]:[3,2]):[3,3];case 1:t.sent(),t.label=2;case 2:this._setProcessChainAcquireRunning(!1),se()?this._processChainResolve():(e=new StorageEvent("storage",{key:this._chainProcessStateKey,oldValue:JSON.stringify(!0),newValue:JSON.stringify(!1)}),dispatchEvent(e)),t.label=3;case 3:return[2]}}))}))},e.prototype.acquire=function(e){return void 0===e&&(e=0),p(this,void 0,void 0,(function(){var t,n=this;return _(this,(function(r){return se()?[2,new Promise((function(t){for(var r={key:ie(),resolver:function(e){return t(e)},priority:e},s=ar[n._resolversKey],i=-1,a=0;as[a].priority){i=a;break}i>=0?ar[n._resolversKey].splice(i,0,r):ar[n._resolversKey].push(r),n._processChainResolve()}))]:(t=this._getLocalResolversData(),[2,new Promise((function(r){for(var s=ie(),i={key:s,priority:e},a={key:s,resolver:function(e){return r(e)},priority:e},o=-1,u=0;ut[u].priority){o=u;break}o>=0?(t.splice(o,0,i),n._localResolversData.splice(o,0,a)):(t.push(i),n._localResolversData.push(a)),window.localStorage.setItem(n._resolversKey,JSON.stringify(t)),n._processChainResolve()}))])}))}))},e.prototype.release=function(e){if(se()){if((t=ir[this._holdersKey].indexOf(e))>=0)return ir[this._holdersKey].splice(t,1),this._processChainResolve(),!0}else if(window.localStorage[this._holdersKey]){var t,n=JSON.parse(window.localStorage[this._holdersKey]),r=d([],f(n),!1);if((t=n.indexOf(e))>=0){n.splice(t,1),window.localStorage.setItem(this._holdersKey,JSON.stringify(n)),this._localAcquiredKeys.splice(this._localAcquiredKeys.indexOf(e),1);var s=new StorageEvent("storage",{key:this._holdersKey,oldValue:JSON.stringify(r),newValue:JSON.stringify(n)});return dispatchEvent(s),!0}}return!1},e.prototype._tryResolve=function(){if(se()){if(ir[this._holdersKey].length=100,t.nextToken=this._metadata.range.top,this._metadata.previousComplete=!t.hasNext,u.debug("message background prev sync progress",t),[4,this.saveMetadata()];case 4:return o.sent(),[3,8];case 5:return r=o.sent(),u.debug("message background prev sync error",r),r instanceof Q&&r.isInvalidTokenError?[4,this.clearMetadata()]:[3,7];case 6:o.sent(),o.label=7;case 7:throw r;case 8:return[3,10];case 9:t.hasNext=!1,o.label=10;case 10:return[2,t]}}))}))})),this._nextSync=new cr(l,(function(e){return p(r,void 0,void 0,(function(){var t,n,r,s,i,a;return _(this,(function(o){switch(o.label){case 0:return t={hasNext:!0,nextToken:0},[4,this.loadMetadata()];case 1:o.sent(),u.debug("message background next sync from",null===(s=this._metadata)||void 0===s?void 0:s.range.bottom),o.label=2;case 2:return o.trys.push([2,5,,6]),[4,ce.of(this._iid).getMessagesByTimestamp(this._channel.url,this._channel.channelType,null!==(a=null===(i=this._metadata.range)||void 0===i?void 0:i.bottom)&&void 0!==a?a:e,{prevResultSize:0,nextResultSize:100,replyType:he.ALL,includeReactions:!0,includeMetaArray:!0,includeParentMessageInfo:!0,includeThreadInfo:!0},$.SYNC_MESSAGE_BACKGROUND)];case 3:return n=o.sent(),this.extendRange(n),t.hasNext=n.length>=100,t.nextToken=this._metadata.range.bottom,u.debug("message background next sync progress",t),[4,this.saveMetadata()];case 4:return o.sent(),[3,6];case 5:throw r=o.sent(),u.debug("message background next sync error",r),r;case 6:return[2,t]}}))}))}))}return e.of=function(t,n){if(fr[t]||(fr[t]={}),!fr[t][n.url]){var r=fr[t][n.url]=new e({_iid:t,channel:n});W.of(t).dispatcher.on((function(e){if(e instanceof ue)if(e.stateType===le.CONNECTED)r.resume();else r.pause()}))}return fr[t][n.url]},Object.defineProperty(e.prototype,"range",{get:function(){var e;return null===(e=this._metadata)||void 0===e?void 0:e.range},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"previousComplete",{get:function(){var e;return!!(null===(e=this._metadata)||void 0===e?void 0:e.previousComplete)},enumerable:!1,configurable:!0}),e.prototype.isWrappingMessages=function(e){var t;return null===(t=this.range)||void 0===t?void 0:t.includes.apply(t,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(){return p(this,void 0,void 0,(function(){var e;return _(this,(function(t){switch(t.label){case 0:return this._metadata?[3,2]:[4,W.of(this._iid).cacheContext.preference.get(this._metadataKey)];case 1:e=t.sent(),this._metadata={range:new nr(e?e.range:{top:Number.MAX_SAFE_INTEGER,bottom:Number.MAX_SAFE_INTEGER}),previousComplete:!!e&&e.previousComplete},t.label=2;case 2:return[2]}}))}))},e.prototype.saveMetadata=function(){return p(this,void 0,void 0,(function(){return _(this,(function(e){switch(e.label){case 0:return this._metadata?[4,W.of(this._iid).cacheContext.preference.set(this._metadataKey,this._metadata)]:[3,2];case 1:e.sent(),e.label=2;case 2:return[2]}}))}))},e.prototype.clearMetadata=function(){return p(this,void 0,void 0,(function(){return _(this,(function(e){switch(e.label){case 0:return[4,W.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,r;W.of(this._iid).logger.debug("message background sync resume()"),this._metadata&&this._metadata.previousComplete||this._prevSync.start(null!==(t=null===(e=this._metadata)||void 0===e?void 0:e.range.top)&&void 0!==t?t:Date.now()),this._nextSync.start(null!==(r=null===(n=this._metadata)||void 0===n?void 0:n.range.bottom)&&void 0!==r?r:Date.now())},e.prototype.pause=function(){W.of(this._iid).logger.debug("message background sync stop()"),this._prevSync.stop(),this._nextSync.stop()},e}(),_r={},mr=function(){function e(e){var t=e._iid,n=e.channel,r=this;this._sync=null,this._metadata=null,this._iid=t,this._channel=n;var s,i,a=W.of(this._iid),o=a.logger,u=a.sdkState;this._metadataKey=(s=u.userId,i=n.url,"sendbird:".concat(s,"@groupchannel/").concat(i,"/message/changelogs.meta"));var l=function(e,t){return"sendbird:".concat(e,"@groupchannel/").concat(t,"/message/changelogs")}(u.userId,this._channel.url);this._sync=new cr(l,(function(){return p(r,void 0,void 0,(function(){var e,t,n,r,s,i;return _(this,(function(a){switch(a.label){case 0:return e={hasNext:!0,nextToken:0},[4,this.loadMetadata()];case 1:a.sent(),o.debug("message changelog sync from",null===(i=this._metadata)||void 0===i?void 0:i.token),a.label=2;case 2:return a.trys.push([2,5,,8]),[4,ce.of(this._iid).getMessageChangelogs(this._channel.url,this._channel.channelType,this._metadata.token,{replyType:he.ALL,includeReactions:!0,includeThreadInfo:!0,includeMetaArray:!0,includeParentMessageInfo:!0},$.SYNC_MESSAGE_CHANGELOGS)];case 3:return t=a.sent(),n=t.hasMore,r=t.token,e.hasNext=n,e.nextToken=r,this._metadata.token=r,o.debug("message changelog sync progress",e),[4,this.saveMetadata()];case 4:return a.sent(),[3,8];case 5:return s=a.sent(),o.debug("message 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]}}))}))}))}return e.of=function(t,n){if(_r[t]||(_r[t]={}),!_r[t][n.url]){var r=_r[t][n.url]=new e({_iid:t,channel:n});W.of(t).dispatcher.on((function(e){if(e instanceof ue)if(e.stateType===le.CONNECTED)r.resume();else r.pause()}))}return _r[t][n.url]},e.prototype.loadMetadata=function(){return p(this,void 0,void 0,(function(){var e,t,n,r;return _(this,(function(s){switch(s.label){case 0:return this._metadata?[3,2]:(e=W.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/1e3},s.label=2;case 2:return[2]}}))}))},e.prototype.saveMetadata=function(){return p(this,void 0,void 0,(function(){return _(this,(function(e){switch(e.label){case 0:return this._metadata?[4,W.of(this._iid).cacheContext.preference.set(this._metadataKey,this._metadata)]:[3,2];case 1:e.sent(),e.label=2;case 2:return[2]}}))}))},e.prototype.clearMetadata=function(){return p(this,void 0,void 0,(function(){return _(this,(function(e){switch(e.label){case 0:return[4,W.of(this._iid).cacheContext.preference.remove(this._metadataKey)];case 1:return e.sent(),this._metadata=null,[2]}}))}))},e.prototype.resume=function(){W.of(this._iid).logger.debug("message changelog sync resume()"),this._sync.start(0)},e.prototype.pause=function(){W.of(this._iid).logger.debug("message changelog sync pause()"),this._sync.stop()},e}(),vr=function(n){function r(e){var r,s,i,a,o,u,l=this;return(l=n.call(this)||this).method=D.GET,l.path="".concat(de(e.channelType),"/").concat(e.channelUrl,"/messages_gap"),l.params=t({prev_start_ts:e.prevStart,prev_end_ts:e.prevEnd,prev_cache_count:e.prevCount,next_start_ts:e.nextStart,next_end_ts:e.nextEnd,next_cache_count:e.nextCount,huge_gap_threshold:null!==(r=e.threshold)&&void 0!==r?r:null,reverse:!0,custom_types:null!==(s=e.customTypes)&&void 0!==s?s:["*"],message_type:null!==(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}),l}return e(r,n),r}(P),gr=function(t){function n(e,n){var r,s,i,a,o=this;return(o=t.call(this,e,n)||this).isHugeGap=n.is_huge_gap,o.prevMessages=(null!==(r=n.prev_messages)&&void 0!==r?r:[]).map((function(t){return fe(e,t)})),o.prevHasMore=null!==(s=n.prev_hasmore)&&void 0!==s&&s,o.nextMessages=(null!==(i=n.next_messages)&&void 0!==i?i:[]).map((function(t){return fe(e,t)})),o.nextHasmore=null!==(a=n.next_hasmore)&&void 0!==a&&a,o}return e(n,t),n}(O),yr=function(e,t){return e.findIndex((function(e){return e.isIdentical(t)}))},Er=function(e,t,n){if(e.length>0){var r=yr(e,t);if(r<0){for(var s=0,i=e.length-1,a=Math.floor((s+i)/2);s0)i=a,a=Math.floor((s+i)/2);else{if(!(o<0))return{place:a,contains:e[a].isIdentical(t)};s=a+1,a=Math.floor((s+i)/2)}}return{place:Cr(e[a],t,n)>0?a:a+1,contains:!1}}return{place:r,contains:!0}}return{place:e.length,contains:!1}},Cr=function(e,t,n){switch(n){case De.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 De.CHRONOLOGICAL:return t.createdAt-e.createdAt;case De.CHANNEL_NAME_ALPHABETICAL:return e.name.localeCompare(t.name)}},Nr=function(e,t){return t instanceof L?e.findIndex((function(e){return e instanceof L&&t.isIdentical(e)})):e.findIndex((function(e){return e.isIdentical(t)}))},br=function(e,t){return e.findIndex((function(e){return e.messageId===t}))},Mr=function(e,t){if(e.length>0){for(var n=0,r=e.length-1,s=Math.floor((n+r)/2);n0)r=s,s=Math.floor((n+r)/2);else{if(!(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},Tr={},Sr=function(){function e(e){var t=e._iid,n=e.channel,r=e.hasPollMessage,s=this;this._sync=null,this._metadata=null,this._iid=t,this._channel=n;var i,a,o=W.of(this._iid),u=o.logger,l=o.sdkState;this._metadataKey=(i=l.userId,a=n.url,"sendbird:".concat(i,"@groupchannel/").concat(a,"/poll/changelogs.meta"));var c=function(e,t){return"sendbird:".concat(e,"@groupchannel/").concat(t,"/poll/changelogs")}(l.userId,this._channel.url);this._sync=new cr(c,(function(){return p(s,void 0,void 0,(function(){var e,t,n,s,i,a,o;return _(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===(o=this._metadata)||void 0===o?void 0:o.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}];l.label=4;case 4:return l.trys.push([4,7,,10]),[4,je.of(this._iid).getPollChangeLogs(this._channel.url,this._channel.channelType,this._metadata.token)];case 5:return n=l.sent(),s=n.hasMore,i=n.token,e.hasNext=s,e.nextToken=i,this._metadata.token=i,u.debug("poll changelog sync progress",e),[4,this.saveMetadata()];case 6:return l.sent(),[3,10];case 7:return a=l.sent(),u.debug("poll changelog sync error",a),a instanceof Q&&a.isInvalidTokenError?[4,this.clearMetadata()]:[3,9];case 8:l.sent(),l.label=9;case 9:throw a;case 10:return[2,e]}}))}))}))}return e.of=function(t,n,r){if(Tr[t]||(Tr[t]={}),!Tr[t][n.url]){var s=Tr[t][n.url]=new e({_iid:t,channel:n,hasPollMessage:r});W.of(t).dispatcher.on((function(e){if(e instanceof ue)if(e.stateType===le.CONNECTED)s.resume();else s.pause()}))}return Tr[t][n.url]},e.prototype.loadMetadata=function(){return p(this,void 0,void 0,(function(){var e,t,n,r;return _(this,(function(s){switch(s.label){case 0:return this._metadata?[3,2]:(e=W.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/1e3},s.label=2;case 2:return[2]}}))}))},e.prototype.saveMetadata=function(){return p(this,void 0,void 0,(function(){return _(this,(function(e){switch(e.label){case 0:return this._metadata?[4,W.of(this._iid).cacheContext.preference.set(this._metadataKey,this._metadata)]:[3,2];case 1:e.sent(),e.label=2;case 2:return[2]}}))}))},e.prototype.clearMetadata=function(){return p(this,void 0,void 0,(function(){return _(this,(function(e){switch(e.label){case 0:return[4,W.of(this._iid).cacheContext.preference.remove(this._metadataKey)];case 1:return e.sent(),this._metadata=null,[2]}}))}))},e.prototype.resume=function(){W.of(this._iid).logger.debug("poll changelog sync resume()"),this._sync.start(0)},e.prototype.pause=function(){W.of(this._iid).logger.debug("poll changelog sync pause()"),this._sync.stop()},e}();!function(e){e.CACHE_AND_REPLACE_BY_API="cache_and_replace_by_api"}(lr||(lr={}));var Ur,Ar,Ir,wr=function(){function e(){}return e.prototype._invokeResponse=function(e,t,n){var r=this;Z((function(){return p(r,void 0,void 0,(function(){return _(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}(),Lr=function(){function e(e,t){var n=t.channel,r=t.filter,s=t.startingPoint,i=t.limit,a=this;this._channel=null,this._messages=[],this._unsentMessages=[],this._readReceiptMap=new Map,this._deliveryReceiptMap=new Map,this._iid=e,this._key="mc-".concat(ie()),this.filter=null!=r?r:new Qe,this._channel=n,this._syncRange=new nr({}),this._hasPrevious=!0,this._hasNext=!0,this._startingPoint=s||Date.now()+6e5,this._limit=i||Be;var o=sr.of(this._iid);o.subscribeGroupChannelEvent(this._key,{onUpdate:function(e,t){var n,r,s,i,o=yr(e,a._channel);if(o>=0)switch(Z((function(){return p(a,void 0,void 0,(function(){var n;return _(this,(function(r){return n=new hr(t),this._channel=e[o],this._handler.onChannelUpdated(n,this.channel),[2]}))}))})),t){case $t.EVENT_CHANNEL_UPDATED:var u=!1;for(var l in a._messages){if((g=a._messages[l]).createdAt>=a._channel.messageOffsetTimestamp){u=!0;var c=parseInt(l);if(c>0){var h=a._messages.splice(0,c);a._removeMessagesFromView(h.map((function(e){return e.messageId})),$.EVENT_MESSAGE_OFFSET_UPDATED)}break}}!u&&a._messages.length>0&&a._removeMessagesFromView(a._messages.map((function(e){return e.messageId})),$.EVENT_MESSAGE_OFFSET_UPDATED);break;case $t.EVENT_CHANNEL_READ:var d=[];try{for(var f=m(a._messages),v=f.next();!v.done;v=f.next()){var g=v.value;if((C=a._readReceiptMap.get(g.messageId))>0)C!==a._channel.getUnreadMemberCount(g)&&d.push(g)}}catch(e){n={error:e}}finally{try{v&&!v.done&&(r=f.return)&&r.call(f)}finally{if(n)throw n.error}}d.length>0&&a._updateMessagesToView(d,$.EVENT_MESSAGE_READ);break;case $t.EVENT_CHANNEL_DELIVERED:d=[];try{for(var y=m(a._messages),E=y.next();!E.done;E=y.next()){var C;g=E.value;if((C=a._deliveryReceiptMap.get(g.messageId))>0)C!==a._channel.getUndeliveredMemberCount(g)&&d.push(g)}}catch(e){s={error:e}}finally{try{E&&!E.done&&(i=y.return)&&i.call(y)}finally{if(s)throw s.error}}d.length>0&&a._updateMessagesToView(d,$.EVENT_MESSAGE_READ)}},onRemove:function(e,t){e.indexOf(a.channel.url)>=0&&Z((function(){return p(a,void 0,void 0,(function(){var e;return _(this,(function(n){return e=new hr(t),this._handler.onChannelDeleted(e,this.channel.url),[2]}))}))}))}}),o.subscribeMessageEvent(this._key,{onUpdate:function(e,t){var n,r,s=[],i=[];try{for(var o=m(e),u=o.next();!u.done;u=o.next()){var l=u.value;l.channelUrl===a._channel.url&&(a.filter.match(l)?s.push(l):i.push(l.messageId))}}catch(e){n={error:e}}finally{try{u&&!u.done&&(r=o.return)&&r.call(o)}finally{if(n)throw n.error}}if(pe(t)){if(s.length>0)switch(t){case $.EVENT_MESSAGE_SENT_FAILED:case $.EVENT_MESSAGE_SENT_SUCCESS:case $.EVENT_MESSAGE_UPDATED:case $.EVENT_MESSAGE_THREADINFO_UPDATED:case $.EVENT_MESSAGE_REACTION_UPDATED:case $.SYNC_MESSAGE_CHANGELOGS:a._updateMessagesToView(s,t);break;case $.EVENT_MESSAGE_SENT_PENDING:case $.EVENT_MESSAGE_RECEIVED:case $.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=W.of(this._iid).cacheContext;!this._channel.isSuper&&u.localCacheEnabled&&pr.of(this._iid,this._channel).resume(),mr.of(this._iid,this._channel).resume(),Sr.of(this._iid,this._channel,this._hasPollMessage.bind(this)).resume(),this._prevFill=new cr(this._key,(function(e){return p(a,void 0,void 0,(function(){var t,n;return _(this,(function(r){switch(r.label){case 0:return[4,this._getRemoteMessages(e,{prevLimit:this._limit,source:$.SYNC_MESSAGE_FILL})];case 1:return(t=r.sent()).length>0?(n=Math.min.apply(Math,d([],f(t.map((function(e){return e.createdAt}))),!1)),this._syncRange.extends(n),[2,{hasNext:t.length>=this._limit&&this.viewTop0?(n=Math.max.apply(Math,d([],f(t.map((function(e){return e.createdAt}))),!1)),this._syncRange.extends(n),[2,{hasNext:!(t.length>=this._limit&&this._hasNext)||this.viewBottom>n,nextToken:this._syncRange.bottom}]):[2,{hasNext:!1,nextToken:0}]}}))}))}));var l=W.of(this._iid),c=l.dispatcher,h=l.logger;c.on((function(e){if(e instanceof ue)if(e.stateType===le.CONNECTED)h.debug("check huge gap"),a._checkHugeGap();else a._prevFill.stop(),a._nextFill.stop()}))}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===ne.FAILED}))},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"pendingMessages",{get:function(){return this._unsentMessages.filter((function(e){return e.sendingStatus===ne.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=m(i),l=u.next();!l.done;l=u.next()){var c=l.value;if(t===$.SYNC_MESSAGE_FILL){if(c.messageId>0){if((y=Nr(this._messages,c))<0){Nr(this._unsentMessages,c)<0&&a.push(c);var h=Mr(this._messages,c);this._messages.splice(h,0,c)}this._readReceiptMap.set(c.messageId,this._channel.getUnreadMemberCount(c)),this._deliveryReceiptMap.set(c.messageId,this._channel.getUndeliveredMemberCount(c))}else if(c instanceof L){(y=Nr(this._unsentMessages,c))<0&&Nr(this._messages,c)<0&&(this._unsentMessages.push(c),a.push(c))}}else if(c.messageId>0){if((y=Nr(this._messages,c))<0){var v=Nr(this._unsentMessages,c);v<0?a.push(c):(this._unsentMessages.splice(v,1),o.push(c));h=Mr(this._messages,c);this._messages.splice(h,0,c)}else o.push(c),this._messages[y]=c;if(this._readReceiptMap.set(c.messageId,this._channel.getUnreadMemberCount(c)),this._deliveryReceiptMap.set(c.messageId,this._channel.getUndeliveredMemberCount(c)),c.updatedAt>0){var g=this._updateChildMessagesInView(c);o.push.apply(o,d([],f(g),!1))}}else if(c instanceof L){var y;(y=Nr(this._unsentMessages,c))<0?Nr(this._messages,c)<0&&(this._unsentMessages.push(c),a.push(c)):(o.push(c),this._unsentMessages[y]=c)}}}catch(e){n={error:e}}finally{try{l&&!l.done&&(r=u.return)&&r.call(u)}finally{if(n)throw n.error}}pe(t)&&Z((function(){return p(s,void 0,void 0,(function(){var e;return _(this,(function(n){return e=new dr(t),a.length>0&&this._handler.onMessagesAdded(e,this.channel,a),o.length>0&&this._handler.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=m(e),o=a.next();!o.done;o=a.next()){var u=o.value,l=br(this._messages,u.messageId);if(l>=0){var c=this._messages[l];c&&c.applyPoll(u),i.push(c)}}}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&&pe(t)&&Z((function(){return p(s,void 0,void 0,(function(){var e;return _(this,(function(n){return e=new dr(t),i.length>0&&this._handler.onMessagesUpdated(e,this.channel,i),[2]}))}))})),i},e.prototype._applyPollUpdateEventToView=function(e,t){var n=this,r=br(this._messages,e.messageId);if(r>=0){var s=this._messages[r];s&&s.isUserMessage()&&s.poll&&s.poll.applyPollUpdateEvent(e)&&pe(t)&&Z((function(){return p(n,void 0,void 0,(function(){var e;return _(this,(function(n){return e=new dr(t),this._handler.onMessagesUpdated(e,this.channel,[s]),[2]}))}))}))}},e.prototype._applyPollVoteEventToView=function(e,t){var n=this,r=br(this._messages,e.messageId);if(r>=0){var s=this._messages[r];s&&s.isUserMessage()&&s.poll&&s.poll.applyPollVoteEvent(e)&&pe(t)&&Z((function(){return p(n,void 0,void 0,(function(){var e;return _(this,(function(n){return e=new dr(t),this._handler.onMessagesUpdated(e,this.channel,[s]),[2]}))}))}))}},e.prototype._updateMessagesToView=function(e,t){var n,r,s=this,i=[];try{for(var a=m(e),o=a.next();!o.done;o=a.next()){var u,l=o.value;if(l.messageId>0)if((u=Nr(this._messages,l))>=0)i.push(l),this._messages[u]=l;else{var c=Nr(this._unsentMessages,l);if(c>=0){i.push(l),this._unsentMessages.splice(c,1);var h=Mr(this._messages,l);this._messages.splice(h,0,l)}}else if(l instanceof L)(u=Nr(this._unsentMessages,l))>=0&&(i.push(l),this._unsentMessages[u]=l)}}catch(e){n={error:e}}finally{try{o&&!o.done&&(r=a.return)&&r.call(a)}finally{if(n)throw n.error}}return pe(t)&&Z((function(){return p(s,void 0,void 0,(function(){var e;return _(this,(function(n){return e=new dr(t),i.length>0&&this._handler.onMessagesUpdated(e,this.channel,i),[2]}))}))})),i},e.prototype._removeMessagesFromView=function(e,t){var n,r,s=this,i=[],a=function(e){var t=o._messages.findIndex((function(t){return t.messageId===e}));t>=0&&(i.push(o._messages[t].messageId),o._messages.splice(t,1))},o=this;try{for(var u=m(e),l=u.next();!l.done;l=u.next()){a(l.value)}}catch(e){n={error:e}}finally{try{l&&!l.done&&(r=u.return)&&r.call(u)}finally{if(n)throw n.error}}return pe(t)&&i.length>0&&Z((function(){return p(s,void 0,void 0,(function(){var e;return _(this,(function(n){return e=new dr(t),i.length>0&&this._handler.onMessagesDeleted(e,this.channel,i),[2]}))}))})),i},e.prototype._removeUnsentMessageFromView=function(e,t){var n=this._unsentMessages.findIndex((function(t){return t.reqId===e}));n>=0&&this._unsentMessages.splice(n,1)},e.prototype._getLocalMessages=function(e,t){var n=t.prevLimit,r=void 0===n?0:n,s=t.nextLimit,i=void 0===s?0:s;return p(this,void 0,void 0,(function(){var t,n,s,a,o,u,l;return _(this,(function(c){switch(c.label){case 0:return t=sr.of(this._iid),r>0?[4,t.getMessagesFromCache(this._channel.url,e,"prev",this.filter,this._limit)]:[3,2];case 1:return s=c.sent(),[3,3];case 2:s=[],c.label=3;case 3:return n=s,i>0?[4,t.getMessagesFromCache(this._channel.url,e,"next",this.filter,this._limit)]:[3,5];case 4:return o=c.sent(),[3,6];case 5:o=[],c.label=6;case 6:if(a=o,n.length>0&&a.length)for(l in u=n.map((function(e){return e.messageId})),a)if(u.includes(a[l].messageId)){a.splice(parseInt(l),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 r=t.prevLimit,s=void 0===r?0:r,i=t.nextLimit,a=void 0===i?0:i,o=t.source,u=void 0===o?$.REQUEST_MESSAGE:o,l=t.reverse,c=void 0!==l&&l;return p(this,void 0,void 0,(function(){var t,r;return _(this,(function(i){switch(i.label){case 0:return t=ce.of(this._iid),s>0||a>0?[4,t.getMessagesByTimestamp(this._channel.url,this._channel.channelType,e,n(n({},this.filter),{reverse:c,prevResultSize:s,nextResultSize:a,includeMetaArray:!0,includeReactions:!0,includeThreadInfo:!0}),u)]:[3,2];case 1:return r=i.sent(),[3,3];case 2:r=[],i.label=3;case 3:return[2,r]}}))}))},e.prototype._checkHugeGap=function(){return p(this,void 0,void 0,(function(){var e,t,r,s,i,a,o,u,l,c,h=this;return _(this,(function(m){switch(m.label){case 0:return this._messages.length>0?(e=this.viewTop,t=this._syncRange.top,r=this._syncRange.bottom,s=this.hasNext?this.viewBottom:Number.MAX_SAFE_INTEGER,[4,(i=sr.of(this._iid)).getCachedMessageCountBetween(this._channel.url,this.filter,e,t)]):[3,4];case 1:return a=m.sent(),[4,i.getCachedMessageCountBetween(this._channel.url,this.filter,r,s)];case 2:return o=m.sent(),[4,_e((function(){return p(h,void 0,void 0,(function(){var i,u,l,c,h,m,v,g,y,E,C,N,b,M,T,S,U,A=this;return _(this,(function(I){switch(I.label){case 0:return i=W.of(this._iid),u=i.dispatcher,l=i.requestQueue,c=new vr(n({channelUrl:this._channel.url,channelType:this._channel.channelType,prevStart:e,prevEnd:t,prevCount:a,nextStart:r,nextEnd:s,nextCount:o},this.filter)),[4,l.send(c)];case 1:return h=I.sent(),m=h.as(gr),v=m.isHugeGap,g=m.prevMessages,y=void 0===g?[]:g,E=m.prevHasMore,C=m.nextMessages,N=void 0===C?[]:C,b=m.nextHasmore,v?Z((function(){return p(A,void 0,void 0,(function(){return _(this,(function(e){return this._handler.onHugeGapDetected(),[2]}))}))})):(this._hasPrevious=E,this._hasNext=b,M=this.viewTop,T=this.viewBottom,S=Math.min.apply(Math,d([Number.MAX_SAFE_INTEGER],f(y.map((function(e){return e.createdAt}))),!1)),U=Math.max.apply(Math,d([0],f(N.map((function(e){return e.createdAt}))),!1)),u.dispatch(new w({messages:y,source:$.SYNC_MESSAGE_FILL})),u.dispatch(new w({messages:N,source:$.SYNC_MESSAGE_FILL})),this._syncRange.extends(S,U),MU&&this._nextFill.start(U)),[2]}}))}))}),1)];case 3:return m.sent(),[3,6];case 4:return u=Math.floor(this._limit/2),[4,this._getRemoteMessages(Date.now(),{prevLimit:u,nextLimit:u,source:$.SYNC_MESSAGE_FILL})];case 5:(l=m.sent()).length>0&&((c=this._syncRange).extends.apply(c,d([],f(l.map((function(e){return e.createdAt}))),!1)),l.length0?[2,!0]:[2,!1]}}))}))},e.prototype.initialize=function(e){var t=this,n=new wr;this._messages=[],this._unsentMessages=[],this._syncRange=new nr({}),this._hasNext=!0,this._hasPrevious=!0;var r=Math.floor(this._limit/2);if(e===lr.CACHE_AND_REPLACE_BY_API)this._getLocalMessages(this._startingPoint,{prevLimit:r,nextLimit:r}).then((function(e){var r=t._filterUnderOffsetMessage(e);t._addMessagesToView(r,$.REQUEST_MESSAGE),n._invokeResponse("local",null,r)})).catch((function(e){if(X(e))throw e;n._invokeResponse("local",e,null)})).finally((function(){t._loadAllFailedMessages(),t._getRemoteMessages(t._startingPoint,{prevLimit:r,nextLimit:r,reverse:!0}).then((function(e){var s;t._messages=[];var i=t._filterUnderOffsetMessage(e);i.length0&&((s=t._syncRange).extends.apply(s,d([],f(i.map((function(e){return e.createdAt}))),!1)),t._addMessagesToView(i,$.REQUEST_MESSAGE)),n._invokeResponse("remote",null,i)})).catch((function(e){if(X(e))throw e;n._invokeResponse("remote",e,null)}))}));return n},e.prototype.loadPrevious=function(){return p(this,void 0,void 0,(function(){var e,t,n,r,s=this;return _(this,(function(i){switch(i.label){case 0:return this._hasPrevious?(e=this.viewTop,t=[],[4,b((function(){return p(s,void 0,void 0,(function(){var n;return _(this,(function(r){switch(r.label){case 0:return n=this._filterUnderOffsetMessage,[4,this._getLocalMessages(e,{prevLimit:this._limit})];case 1:return t=n.apply(this,[r.sent()]),[2]}}))}))}))]):[3,5];case 1:return i.sent(),n=pr.of(this._iid,this._channel),0!==t.length&&n.isWrappingMessages(t)?[3,3]:[4,b((function(){return p(s,void 0,void 0,(function(){var r,s;return _(this,(function(i){switch(i.label){case 0:return r=this._filterUnderOffsetMessage,[4,this._getRemoteMessages(e,{prevLimit:this._limit})];case 1:return t=r.apply(this,[i.sent()]),this._hasPrevious=t.length>=this._limit,t.length>0&&((s=this._syncRange).extends.apply(s,d([],f(t.map((function(e){return e.createdAt}))),!1)),n.range.overlap(this._syncRange)&&n.range.extends(this._syncRange.top)),[2]}}))}))}))];case 2:return i.sent(),this._addMessagesToView(t,$.REQUEST_MESSAGE),[3,4];case 3:this._hasPrevious=t.length>=this._limit,t.length>0&&((r=this._syncRange).extends.apply(r,d([],f(t.map((function(e){return e.createdAt}))),!1)),this._addMessagesToView(t,$.REQUEST_MESSAGE)),i.label=4;case 4:return[2,t];case 5:return[2,[]]}}))}))},e.prototype.loadNext=function(){return p(this,void 0,void 0,(function(){var e,t,n,r,s=this;return _(this,(function(i){switch(i.label){case 0:return e=this.viewBottom,t=[],[4,b((function(){return p(s,void 0,void 0,(function(){var n;return _(this,(function(r){switch(r.label){case 0:return n=this._filterUnderOffsetMessage,[4,this._getLocalMessages(e,{nextLimit:this._limit})];case 1:return t=n.apply(this,[r.sent()]),[2]}}))}))}))];case 1:return i.sent(),n=pr.of(this._iid,this._channel),0!==t.length&&n.isWrappingMessages(t)?[3,3]:[4,b((function(){return p(s,void 0,void 0,(function(){var r,s;return _(this,(function(i){switch(i.label){case 0:return r=this._filterUnderOffsetMessage,[4,this._getRemoteMessages(e,{nextLimit:this._limit})];case 1:return t=r.apply(this,[i.sent()]),this._hasNext=t.length>=this._limit,t.length>0&&((s=this._syncRange).extends.apply(s,d([],f(t.map((function(e){return e.createdAt}))),!1)),n.range.overlap(this._syncRange)&&n.range.extends(this._syncRange.bottom)),[2]}}))}))}))];case 2:return i.sent(),this._addMessagesToView(t,$.REQUEST_MESSAGE),[3,4];case 3:this._hasNext=t.length>=this._limit,t.length>0&&((r=this._syncRange).extends.apply(r,d([],f(t.map((function(e){return e.createdAt}))),!1)),this._addMessagesToView(t,$.REQUEST_MESSAGE)),i.label=4;case 4:return[2,t]}}))}))},e.prototype.removeFailedMessage=function(e){return p(this,void 0,void 0,(function(){var t;return _(this,(function(n){switch(n.label){case 0:return[4,sr.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(){W.of(this._iid).cacheContext.localCacheEnabled&&(this._prevFill.stop(),this._nextFill.stop(),pr.of(this._iid,this._channel).pause()),mr.of(this._iid,this._channel).pause(),Sr.of(this._iid,this._channel,this._hasPollMessage.bind(this)).pause();var e=sr.of(this._iid);e.unsubscribeGroupChannelEvent(this._key),e.unsubscribeMessageEvent(this._key)},e}(),Dr={coverUrl:null,coverImage:null,isDistinct:null,isPublic:null,isDiscoverable:null,accessCode:null,name:null,data:null,customType:null,operatorUserIds:null,messageSurvivalSeconds:null},Rr={hidePreviousMessages:!1,allowAutoUnhide:!0},Pr=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,l=e.nicknameStartsWithFilter,c=e.operatorFilter;return(n=t.call(this)||this).method=D.GET,n.path="".concat(F,"/").concat(encodeURIComponent(r),"/members"),n.params={token:s,limit:i,order:a,muted_member_filter:o,member_state_filter:u,nickname_startswith:l,operator_filter:c,show_member_is_muted:!0,show_read_receipt:!0,show_delivery_receipt:!0},n}return e(n,t),n}(P),Or=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 qt(e,t)}))),r}return e(n,t),n}(O);!function(e){e.ALL="all",e.MUTED="muted",e.UNMUTED="unmuted"}(Ur||(Ur={})),function(e){e.MEMBER_NICKNAME_ALPHABETICAL="member_nickname_alphabetical",e.OPERATOR_THEN_MEMBER_ALPHABETICAL="operator_then_member_alphabetical"}(Ar||(Ar={})),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"}(Ir||(Ir={}));var kr=function(t){function r(e,n,r){var s,i,a,o,l=this;return(l=t.call(this,e,n,u.GROUP,r)||this).mutedMemberFilter=Ur.ALL,l.memberStateFilter=Ir.ALL,l.nicknameStartsWithFilter=null,l.operatorFilter=Ht.ALL,l.order=Ar.MEMBER_NICKNAME_ALPHABETICAL,l.mutedMemberFilter=null!==(s=r.mutedMemberFilter)&&void 0!==s?s:Ur.ALL,l.memberStateFilter=null!==(i=r.memberStateFilter)&&void 0!==i?i:Ir.ALL,l.nicknameStartsWithFilter=null!==(a=r.nicknameStartsWithFilter)&&void 0!==a?a:null,l.order=null!==(o=r.order)&&void 0!==o?o:Ar.MEMBER_NICKNAME_ALPHABETICAL,l}return e(r,t),r.prototype._validate=function(){return t.prototype._validate.call(this)&&a(Ur,this.mutedMemberFilter)&&a(Ir,this.memberStateFilter)&&(g("string",this.nicknameStartsWithFilter)||null===this.nicknameStartsWithFilter)&&a(Ht,this.operatorFilter)&&a(Ar,this.order)},r.prototype.next=function(){return p(this,void 0,void 0,(function(){var e,t,r,s,i,a;return _(this,(function(o){switch(o.label){case 0:return this._validate()?this._isLoading?[3,3]:this._hasNext?(this._isLoading=!0,e=W.of(this._iid).requestQueue,t=new Pr(n(n({},this),{token:this._token})),[4,e.send(t)]):[3,2]:[3,5];case 1:return r=o.sent(),s=r.as(Or),i=s.members,a=s.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]}}))}))},r}(me),Fr=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(F,"/").concat(encodeURIComponent(r),"/accept"),n.params={user_id:s,access_code:i},n}return e(n,t),n}(P),xr=function(t){function n(e,n){var r=t.call(this,e,n)||this;return r.channel=new ys(e,n),r.channel.myMemberState=Rt.JOINED,r}return e(n,t),n}(O),Hr=function(n){function r(e){var r=this,s=e.channelUrl,i=e.isDistinct,a=e.isPublic,o=e.isDiscoverable,u=e.coverUrl,l=e.coverImage,c=e.accessCode,h=e.name,d=e.data,f=e.customType,p=e.operatorUserIds,_=e.messageSurvivalSeconds;return(r=n.call(this)||this).method=D.PUT,r.path="".concat(F,"/").concat(encodeURIComponent(s)),r.params=t({is_distinct:i,is_public:a,is_discoverable:o,name:h,data:d,custom_type:f,cover_url:u,cover_file:l,access_code:c,operator_ids:p,message_survival_seconds:_}),r}return e(r,n),r}(P),Vr=function(t){function n(e,n){var r=t.call(this,e,n)||this;return r.channel=new ys(e,n),r}return e(n,t),n}(O),Gr=function(t){function n(e){var n=this,r=e.channelUrl;return(n=t.call(this)||this).method=D.DELETE,n.path="".concat(F,"/").concat(encodeURIComponent(r)),n}return e(n,t),n}(P);!function(t){function n(e,n){return t.call(this,e,n)||this}e(n,t)}(O);var qr=function(t){function n(e){var n=this,r=e.channelUrl;return(n=t.call(this)||this).method=D.DELETE,n.path="".concat(F,"/").concat(encodeURIComponent(r),"/hide"),n}return e(n,t),n}(P);!function(t){function n(){return null!==t&&t.apply(this,arguments)||this}e(n,t)}(O);var Kr=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(R,"/").concat(encodeURIComponent(n),"/count_preference/").concat(encodeURIComponent(r)),i.params={count_preference:s},i}return e(n,t),n}(P),Br=function(t){function n(e,n){var r=t.call(this,e,n)||this;return r.countPreference=ps[n.count_preference],r}return e(n,t),n}(O),jr=function(t){function n(e){var n=this,r=e.channelUrl;return(n=t.call(this)||this).method=D.PUT,n.path="".concat(F,"/").concat(encodeURIComponent(r),"/reset_user_history"),n}return e(n,t),n}(P),Qr=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}(O),zr=n(n({},vt),{scheduledAt:null,file:null,fileUrl:null,fileName:null,mimeType:null,fileSize:null,thumbnailSizes:null,requireAuth:!1}),Wr=n(n({},yt),{scheduledAt:null}),Yr=function(t){function n(e){var n,r=this;r=t.call(this)||this;var s=[];e.mentionType===ve.USERS&&(e.mentionedUserIds?s=e.mentionedUserIds:e.mentionedUsers&&(s=e.mentionedUsers.map((function(e){return e.userId}))));var i=e.channelType,a=e.channelUrl,o=e.scheduledMessageId;return r.method=D.PUT,r.path="".concat(de(i),"/").concat(encodeURIComponent(a),"/scheduled_messages/").concat(encodeURIComponent(o)),r.params={req_id:e.reqId,scheduled_at:e.scheduledAt,message_type:ge.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 ye.payloadify(e)})):[],custom_type:e.customType,data:e.data,require_auth:e.requireAuth,mention_type:e.mentionType,mentioned_user_ids:s,sorted_metaarray:null===(n=e.metaArrays)||void 0===n?void 0:n.map((function(e){return Ee.payloadify(e)})),apple_critical_alert_options:Ce.payloadify(e.appleCriticalAlertOptions),push_option:e.pushNotificationDeliveryOption},r}return e(n,t),n}(P),Jr=function(t){function n(e,n){var r=t.call(this,e,n)||this;return r.message=new J(e,n),r}return e(n,t),n}(O),Xr=function(t){function n(e){var n,r=this;r=t.call(this)||this;var s=[];e.mentionType===ve.USERS&&(e.mentionedUserIds?s=e.mentionedUserIds:e.mentionedUsers&&(s=e.mentionedUsers.map((function(e){return e.userId}))));var i=e.channelType,a=e.channelUrl,o=e.scheduledMessageId;return r.method=D.PUT,r.path="".concat(de(i),"/").concat(encodeURIComponent(a),"/scheduled_messages/").concat(encodeURIComponent(o)),r.params={req_id:e.reqId,scheduled_at:e.scheduledAt,message_type:ge.USER,message:e.message,custom_type:e.customType,data:e.data,mention_type:e.mentionType,mentioned_user_ids:s,sorted_metaarray:null===(n=e.metaArrays)||void 0===n?void 0:n.map((function(e){return Ee.payloadify(e)})),apple_critical_alert_options:Ce.payloadify(e.appleCriticalAlertOptions),target_langs:e.translationTargetLanguages,push_option:e.pushNotificationDeliveryOption},r}return e(n,t),n}(P);!function(t){function n(e,n){var r=t.call(this,e,n)||this;return r.message=new Y(e,n),r}e(n,t)}(O);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=D.DELETE,n.path="".concat(de(r),"/").concat(encodeURIComponent(s),"/scheduled_messages/").concat(encodeURIComponent(i)),n}return e(n,t),n}(P),$r=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(de(r),"/").concat(encodeURIComponent(s),"/scheduled_messages/").concat(encodeURIComponent(i),"/send_now"),n}return e(n,t),n}(P),es=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(R,"/").concat(encodeURIComponent(n),"/push_preference/").concat(encodeURIComponent(r)),i.params={push_trigger_option:s},i}return e(n,t),n}(P),ts=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}(O),ns=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(R,"/").concat(encodeURIComponent(n),"/push_preference/").concat(encodeURIComponent(r)),s}return e(n,t),n}(P),rs=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}(O),ss=function(t){function n(e){var n=e.pollId,r=e.title,s=e.data,i=e.allowUserSuggestion,a=e.allowMultipleVotes,o=e.closeAt,u=t.call(this)||this;return u.method=D.PUT,u.path="".concat(be,"/").concat(encodeURIComponent(n)),u.params={title:r,data:s,allow_user_suggestion:i,allow_multiple_votes:a,close_at:o},u}return e(n,t),n}(P),is=function(t){function n(e,n){var r=t.call(this,e,n)||this;return r.poll=new Me(e,n),r}return e(n,t),n}(O),as=function(t){function n(e){var n=e.pollId,r=t.call(this)||this;return r.method=D.DELETE,r.path="".concat(be,"/").concat(encodeURIComponent(n)),r}return e(n,t),n}(P);!function(t){function n(){return null!==t&&t.apply(this,arguments)||this}e(n,t)}(O);var os=function(t){function n(e){var n=e.pollId,r=t.call(this)||this;return r.method=D.PUT,r.path="".concat(be,"/").concat(encodeURIComponent(n),"/close"),r}return e(n,t),n}(P),us=function(t){function n(e,n){var r=t.call(this,e,n)||this;return r.poll=new Me(e,n),r}return e(n,t),n}(O),ls=function(t){function n(e){var n=e.channelUrl,r=e.channelType,s=e.pollId,i=e.optionText,a=t.call(this)||this;return a.method=D.POST,a.path="".concat(be,"/").concat(encodeURIComponent(s),"/options"),a.params={channel_url:n,channel_type:r,text:i},a}return e(n,t),n}(P),cs=function(t){function n(e,n){var r=t.call(this,e,n)||this;return r.poll=new Me(e,n),r}return e(n,t),n}(O),hs=function(t){function n(e){var n=e.pollId,r=e.pollOptionId,s=e.optionText,i=t.call(this)||this;return i.method=D.PUT,i.path="".concat(be,"/").concat(encodeURIComponent(n),"/options/").concat(encodeURIComponent(r)),i.params={text:s},i}return e(n,t),n}(P),ds=function(t){function n(e,n){var r=t.call(this,e,n)||this;return r.poll=new Me(e,n),r}return e(n,t),n}(O),fs=function(t){function n(e){var n=e.pollId,r=e.pollOptionId,s=t.call(this)||this;return s.method=D.DELETE,s.path="".concat(be,"/").concat(encodeURIComponent(n),"/options/").concat(encodeURIComponent(r)),s}return e(n,t),n}(P);!function(t){function n(){return null!==t&&t.apply(this,arguments)||this}e(n,t)}(O);var ps,_s,ms,vs=function(n){function r(e){var r=e.reqId,s=e.channelType,i=e.channelUrl,a=e.pollId,o=e.pollOptionIds;return n.call(this,{code:"VOTE",ackRequired:!0,payload:t({req_id:r,channel_type:s===u.OPEN?"open_channels":"group_channels",channel_url:i,poll_id:a,option_ids:o})})||this}return e(r,n),r}(V);!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"}(ps||(ps={})),function(e){e.MUTED="muted",e.UNMUTED="unmuted"}(_s||(_s={})),function(e){e.UNHIDDEN="unhidden",e.HIDDEN_ALLOW_AUTO_UNHIDE="hidden_allow_auto_unhide",e.HIDDEN_PREVENT_AUTO_UNHIDE="hidden_prevent_auto_unhide"}(ms||(ms={}));var gs,ys=function(r){function s(e,t){var s,i,c,h,p,_,m,v,y,E,C,N,b,M,T,S,U,A,I=this;return(I=r.call(this,e,t)||this)._unreadMemberStateMap=new Map,I._undeliveredMemberStateMap=new Map,I._typingStatus=new Map,I._lastMemberCountUpdated=0,I._typingStarted=0,I._typingEnded=0,I.isDistinct=!1,I.isSuper=!1,I.isBroadcast=!1,I.isExclusive=!1,I.isPublic=!1,I.isDiscoverable=!0,I.isAccessCodeRequired=!1,I.isPushEnabled=!1,I.unreadMessageCount=0,I.unreadMentionCount=0,I.members=[],I.memberCount=0,I.joinedMemberCount=0,I.hiddenState=ms.UNHIDDEN,I.lastMessage=null,I.messageOffsetTimestamp=0,I.messageSurvivalSeconds=-1,I.myMemberState=Rt.NONE,I.myRole=o.NONE,I.myMutedState=_s.UNMUTED,I.myLastRead=0,I.myCountPreference=ps.ALL,I.myPushTriggerOption=et.DEFAULT,I.inviter=null,I.invitedAt=0,I.joinedAt=0,I.channelType=u.GROUP,I.isDistinct=null!==(i=t.is_distinct)&&void 0!==i&&i,I.isSuper=null!==(c=t.is_super)&&void 0!==c&&c,I.isBroadcast=null!==(h=t.is_broadcast)&&void 0!==h&&h,I.isExclusive=null!==(p=t.is_exclusive)&&void 0!==p&&p,I.isPublic=null!==(_=t.is_public)&&void 0!==_&&_,I.isDiscoverable=null!==(m=t.is_discoverable)&&void 0!==m?m:I.isPublic,I.isAccessCodeRequired=null!==(v=t.is_access_code_required)&&void 0!==v&&v,I.isPushEnabled=null!==(y=t.is_push_enabled)&&void 0!==y&&y,Array.isArray(t.members)&&(s=I.members).push.apply(s,d([],f(t.members.map((function(e){return new qt(I._iid,e)}))),!1)),I.memberCount=null!==(E=t.member_count)&&void 0!==E?E:0,I.joinedMemberCount=null!==(C=t.joined_member_count)&&void 0!==C?C:0,I.hiddenState=a(ms,t.hidden_state)?t.hidden_state:ms.UNHIDDEN,I.messageOffsetTimestamp=null!==(N=t.ts_message_offset)&&void 0!==N?N:0,I.messageSurvivalSeconds=null!==(b=t.message_survival_seconds)&&void 0!==b?b:-1,I.lastMessage=t.last_message?fe(I._iid,n({channel_type:I.channelType},t.last_message)):null,t.read_receipt&&Object.keys(t.read_receipt).forEach((function(e){g("number",t.read_receipt[e])&&I._updateUnreadMemberState(e,t.read_receipt[e])})),t.delivery_receipt&&Object.keys(t.delivery_receipt).forEach((function(e){g("number",t.delivery_receipt[e])&&I._updateUndeliveredMemberState(e,t.delivery_receipt[e])})),I.myMemberState=a(Rt,t.member_state)?t.member_state:Rt.NONE,I.myRole=a(o,t.my_role)?t.my_role:o.NONE,a(_s,t.is_muted)?I.myMutedState=t.is_muted:g("boolean",t.is_muted)?I.myMutedState=t.is_muted?_s.MUTED:_s.UNMUTED:I.myMutedState=_s.UNMUTED,I.myCountPreference=a(ps,t.count_preference)?t.count_preference:ps.ALL,I.myPushTriggerOption=a(et,t.push_trigger_option)?t.push_trigger_option:et.ALL,I.myLastRead=null!==(M=t.user_last_read)&&void 0!==M?M:0,I.inviter=t.inviter?new l(I._iid,t.inviter):null,I.invitedAt=null!==(T=t.invited_at)&&void 0!==T?T:0,I.joinedAt=null!==(S=t.joined_ts)&&void 0!==S?S:0,I._updateUnreadCount(null!==(U=t.unread_message_count)&&void 0!==U?U:0,null!==(A=t.unread_mention_count)&&void 0!==A?A:0),I}return e(s,r),Object.defineProperty(s.prototype,"isHidden",{get:function(){return this.hiddenState!==ms.UNHIDDEN},enumerable:!1,configurable:!0}),Object.defineProperty(s.prototype,"isTyping",{get:function(){return Object.keys(this._typingStatus).length>0},enumerable:!1,configurable:!0}),Object.defineProperty(s.prototype,"cachedUnreadMemberState",{get:function(){var e,t,n={};try{for(var r=m(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(s.prototype,"cachedUndeliveredMemberState",{get:function(){var e,t,n={};try{for(var r=m(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}),s.payloadify=function(e){return e?t(n(n({},r.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 qt.payloadify(e)})),last_message:Te(e.lastMessage),inviter:e.inviter?l.payloadify(e.inviter):null,invited_at:e.invitedAt,joined_ts:e.joinedAt})):null},s.prototype._shouldUpdateLastMessageWith=function(e){return!(e instanceof L&&e.parentMessageId>0&&!e.replyToChannel)&&(!this.lastMessage||this.lastMessage.createdAt=0)if(this.myCountPreference===ps.ALL||this.myCountPreference===ps.UNREAD_MESSAGE_COUNT_ONLY)if(this.isExclusive||this.isSuper||this.isBroadcast){var n=W.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===ps.ALL||this.myCountPreference===ps.UNREAD_MENTION_COUNT_ONLY)?this.unreadMentionCount=t:this.unreadMentionCount=0},s.prototype._updateUnreadMemberState=function(e,t){var n=this._unreadMemberStateMap.get(e);return(!n||n0?this._typingStatus[e.userId]={user:e,ts:t}:delete this._typingStatus[e.userId]},s.prototype._invalidateTypingStatus=function(){var e=(new Date).getTime(),t=!1;for(var n in this._typingStatus){e-this._typingStatus[n].ts>=1e4&&(delete this._typingStatus[n],t=!0)}return t},s.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},s.prototype.isReadMessage=function(e){var t=W.of(this._iid).sdkState,n=this._unreadMemberStateMap.get(t.userId);return n&&n>=e.createdAt},s.prototype.serialize=function(){var e=this;return B(this,(function(t){t.cachedUnreadMemberState=e.cachedUnreadMemberState,t.cachedUndeliveredMemberState=e.cachedUndeliveredMemberState}))},s.prototype.createMessageCollection=function(e){return void 0===e&&(e={}),new Lr(this._iid,n({channel:this},e))},s.prototype.createMemberListQuery=function(e){return void 0===e&&(e={}),new kr(this._iid,this.url,e)},s.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===Rt.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)}},s.prototype.removeMember=function(e){if(!this.isExclusive&&!this.isSuper&&!this.isBroadcast){var t=this.members.findIndex((function(t){return t.userId===e.userId}));if(t>-1)return this.members.splice(t,1),this.memberCount--,!0}return!1},s.prototype.getUnreadMemberCount=function(e){var t,n;if(e instanceof L&&!this.isExclusive&&!this.isSuper&&!this.isBroadcast){var r=W.of(this._iid).sdkState,s=e.createdAt,i=0;try{for(var a=m(this.members),o=a.next();!o.done;o=a.next()){var u=o.value;if(r.userId!==u.userId&&u.state===Rt.JOINED&&e.sender.userId!==u.userId)(this.cachedUnreadMemberState[u.userId]||0)=e.createdAt&&s.push(i))})),s},s.prototype.getUnreadMembers=function(e,t){var n=this;void 0===t&&(t=!1);var r=W.of(this._iid).sdkState;if(!r.userId||this.isExclusive||this.isSuper||this.isBroadcast)return[];var s=[];return this.members.forEach((function(i){(t||i.userId!==r.userId&&i.userId!==e.sender.userId)&&(n._unreadMemberStateMap.get(i.userId)=e&&(delete this._typingStatus[r],n=!0)}return n},s.prototype.refresh=function(){return p(this,void 0,void 0,(function(){var e,t,n,r,s,i;return _(this,(function(a){switch(a.label){case 0:return e=W.of(this._iid),t=e.requestQueue,n=e.dispatcher,r=new hn({channelUrl:this.url}),[4,t.send(r)];case 1:return s=a.sent(),i=s.as(dn).channel,n.dispatch(new sn({channels:[i],source:$t.REQUEST_CHANNEL})),[2,i]}}))}))},s.prototype.freeze=function(){return p(this,void 0,void 0,(function(){return _(this,(function(e){switch(e.label){case 0:return[4,r.prototype.freeze.call(this)];case 1:return e.sent(),W.of(this._iid).dispatcher.dispatch(new sn({channels:[this],source:$t.EVENT_CHANNEL_HIDDEN})),[2]}}))}))},s.prototype.unfreeze=function(){return p(this,void 0,void 0,(function(){return _(this,(function(e){switch(e.label){case 0:return[4,r.prototype.unfreeze.call(this)];case 1:return e.sent(),W.of(this._iid).dispatcher.dispatch(new sn({channels:[this],source:$t.EVENT_CHANNEL_UNHIDDEN})),[2]}}))}))},s.prototype.updateChannel=function(e){return p(this,void 0,void 0,(function(){var t,r,s,i,a,o,u;return _(this,(function(l){switch(l.label){case 0:return t=n(n({},Dr),e),te(function(e){return g("string",e.coverUrl,!0)&&(y(e.coverImage)||g("string",e.coverImage)||null===e.coverImage)&&g("boolean",e.isDistinct,!0)&&g("boolean",e.isPublic,!0)&&g("boolean",e.isDiscoverable,!0)&&g("string",e.accessCode,!0)&&g("string",e.name,!0)&&g("string",e.data,!0)&&g("string",e.customType,!0)&&v("string",e.operatorUserIds,!0)&&g("number",e.messageSurvivalSeconds,!0)}(t)).throw(Q.invalidParameters),r=W.of(this._iid),s=r.dispatcher,i=r.requestQueue,a=new Hr(n({channelUrl:this.url},t)),[4,i.send(a)];case 1:return o=l.sent(),u=o.as(Vr).channel,s.dispatch(new sn({channels:[u],source:$t.EVENT_CHANNEL_UPDATED})),[2,u]}}))}))},s.prototype.invite=function(e){return p(this,void 0,void 0,(function(){return _(this,(function(t){return te(e.every((function(e){return e instanceof l}))).throw(Q.invalidParameters),[2,this.inviteWithUserIds(e.map((function(e){return e.userId})))]}))}))},s.prototype.inviteWithUserIds=function(e){return p(this,void 0,void 0,(function(){var t,n,r,s,i,a;return _(this,(function(o){switch(o.label){case 0:return te(v("string",e)).throw(Q.invalidParameters),t=W.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(On).channel,n.dispatch(new sn({channels:[a],source:$t.EVENT_CHANNEL_INVITED})),[2,a]}}))}))},s.prototype.join=function(e){return void 0===e&&(e=null),p(this,void 0,void 0,(function(){var t,n,r,s,i,a,o;return _(this,(function(u){switch(u.label){case 0:return te(g("string",e)||null===e).throw(Q.invalidParameters),t=W.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=Rt.JOINED,n.dispatch(new sn({channels:[o],source:$t.EVENT_CHANNEL_JOINED})),[2,this]}}))}))},s.prototype.leave=function(e){return void 0===e&&(e=!1),p(this,void 0,void 0,(function(){var t,n,r,s;return _(this,(function(i){switch(i.label){case 0:return t=W.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(),[2]}}))}))},s.prototype.acceptInvitation=function(e){return void 0===e&&(e=null),p(this,void 0,void 0,(function(){var t,n,r,s,i,a,o;return _(this,(function(u){switch(u.label){case 0:return te(g("string",e)||null===e).throw(Q.invalidParameters),t=W.of(this._iid),n=t.dispatcher,r=t.sdkState,s=t.requestQueue,i=new Fr({channelUrl:this.url,userId:r.userId,accessCode:e}),[4,s.send(i)];case 1:return a=u.sent(),(o=a.as(xr).channel).myMemberState=Rt.JOINED,n.dispatch(new sn({channels:[o],source:$t.EVENT_CHANNEL_ACCEPTED_INVITE})),[2,o]}}))}))},s.prototype.declineInvitation=function(){return p(this,void 0,void 0,(function(){var e,t,n,r,s,i;return _(this,(function(a){switch(a.label){case 0:return e=W.of(this._iid),t=e.sdkState,n=e.requestQueue,r=new Fn({channelUrl:this.url,userId:t.userId}),[4,n.send(r)];case 1:return s=a.sent(),(i=s.as(xn).channel).myMemberState=Rt.NONE,[2,i]}}))}))},s.prototype.sendUserMessage=function(e){var t=this,n=new Se,s=W.of(this._iid).dispatcher,i=ze.of(this._iid);return r.prototype.sendUserMessage.call(this,e).onPending((function(e){i.completeCurrentAndProcessNextAutoResend(e),n._trigger(null,e)})).onFailed((function(e,t){t&&i.completeCurrentAndProcessNextAutoResend(t),n._trigger(e,t)})).onSucceeded((function(e){var r=sr.of(t._iid);i.completeCurrentAndProcessNextAutoResend(e),t._shouldUpdateLastMessageWith(e)&&(t.lastMessage=e),r.handlers.map((function(e){return e.onChannelChanged(t)})),s.dispatch(new sn({channels:[t],source:$t.EVENT_MESSAGE_SENT})),n._trigger(null,e)})),n},s.prototype.updateUserMessage=function(e,t){return p(this,void 0,void 0,(function(){var n,s,i,a=this;return _(this,(function(o){switch(o.label){case 0:return n=W.of(this._iid).dispatcher,[4,r.prototype.updateUserMessage.call(this,e,t)];case 1:return s=o.sent(),i=!1,!s.silent&&this._shouldUpdateLastMessageWith(s)&&(this.lastMessage=s,i=!0),i&&(sr.of(this._iid).handlers.map((function(e){return e.onChannelChanged(a)})),n.dispatch(new sn({channels:[this],source:$t.EVENT_CHANNEL_UPDATED}))),n.dispatch(new w({messages:[s],source:$.EVENT_MESSAGE_UPDATED})),[2,s]}}))}))},s.prototype._autoResendUserMessage=function(e){var t=this,n=new Se,s=W.of(this._iid).dispatcher,i=ze.of(this._iid);return r.prototype._autoResendUserMessage.call(this,e).onPending((function(e){i.completeCurrentAndProcessNextAutoResend(e),n._trigger(null,e)})).onFailed((function(e,t){i.completeCurrentAndProcessNextAutoResend(t),n._trigger(e,t)})).onSucceeded((function(e){var r=sr.of(t._iid);i.completeCurrentAndProcessNextAutoResend(e),t._shouldUpdateLastMessageWith(e)&&(t.lastMessage=e),r.handlers.map((function(e){return e.onChannelChanged(t)})),s.dispatch(new sn({channels:[t],source:$t.EVENT_MESSAGE_SENT})),n._trigger(null,e)})),n},s.prototype.sendFileMessage=function(e){var t=this,n=new Se,s=W.of(this._iid).dispatcher,i=ze.of(this._iid);return r.prototype.sendFileMessage.call(this,e).onPending((function(e){i.completeCurrentAndProcessNextAutoResend(e),n._trigger(null,e)})).onFailed((function(e,t){t&&i.completeCurrentAndProcessNextAutoResend(t),n._trigger(e,t)})).onSucceeded((function(e){var r=sr.of(t._iid);i.completeCurrentAndProcessNextAutoResend(e),t._shouldUpdateLastMessageWith(e)&&(t.lastMessage=e),r.handlers.map((function(e){return e.onChannelChanged(t)})),s.dispatch(new sn({channels:[t],source:$t.EVENT_MESSAGE_SENT})),n._trigger(null,e)})),n},s.prototype.updateFileMessage=function(e,t){return p(this,void 0,void 0,(function(){var n,s,i,a=this;return _(this,(function(o){switch(o.label){case 0:return n=W.of(this._iid).dispatcher,[4,r.prototype.updateFileMessage.call(this,e,t)];case 1:return s=o.sent(),i=!1,!s.silent&&this._shouldUpdateLastMessageWith(s)&&(this.lastMessage=s,i=!0),i&&(sr.of(this._iid).handlers.map((function(e){return e.onChannelChanged(a)})),n.dispatch(new sn({channels:[this],source:$t.EVENT_CHANNEL_UPDATED}))),n.dispatch(new w({messages:[s],source:$.EVENT_MESSAGE_UPDATED})),[2,s]}}))}))},s.prototype._autoResendFileMessage=function(e){var t=this,n=new Se,s=W.of(this._iid).dispatcher,i=ze.of(this._iid);return r.prototype._autoResendFileMessage.call(this,e).onPending((function(e){i.completeCurrentAndProcessNextAutoResend(e),n._trigger(null,e)})).onFailed((function(e,t){i.completeCurrentAndProcessNextAutoResend(t),n._trigger(e,t)})).onSucceeded((function(e){var r=sr.of(t._iid);i.completeCurrentAndProcessNextAutoResend(e),t._shouldUpdateLastMessageWith(e)&&(t.lastMessage=e),r.handlers.map((function(e){return e.onChannelChanged(t)})),s.dispatch(new sn({channels:[t],source:$t.EVENT_MESSAGE_SENT})),n._trigger(null,e)})),n},s.prototype.deleteMessage=function(e){return p(this,void 0,void 0,(function(){return _(this,(function(t){switch(t.label){case 0:return[4,r.prototype.deleteMessage.call(this,e)];case 1:return t.sent(),0===e.messageId&&W.of(this._iid).dispatcher.dispatch(new A({reqId:e.reqId,source:$.EVENT_MESSAGE_DELETED})),[2]}}))}))},s.prototype.hide=function(e){return p(this,void 0,void 0,(function(){var t,r,s,i,a,o,u,l;return _(this,(function(c){switch(c.label){case 0:return t=n(n({},Rr),e),te(function(e){return g("boolean",e.hidePreviousMessages)&&g("boolean",e.allowAutoUnhide)}(t)).throw(Q.invalidParameters),r=W.of(this._iid),s=r.dispatcher,i=r.sdkState,a=r.requestQueue,o=new jn(n({channelUrl:this.url,userId:i.userId},t)),[4,a.send(o)];case 1:return u=c.sent(),l=u.as(Qn).messageOffsetTimestamp,this.hiddenState=t.allowAutoUnhide?ms.HIDDEN_ALLOW_AUTO_UNHIDE:ms.HIDDEN_PREVENT_AUTO_UNHIDE,t.hidePreviousMessages&&this._updateUnreadCount(0,0),l&&(this.messageOffsetTimestamp=l),s.dispatch(new sn({channels:[this],source:$t.EVENT_CHANNEL_HIDDEN})),[2,this]}}))}))},s.prototype.unhide=function(){return p(this,void 0,void 0,(function(){var e,t,n,r;return _(this,(function(s){switch(s.label){case 0:return e=W.of(this._iid),t=e.dispatcher,n=e.requestQueue,r=new qr({channelUrl:this.url}),[4,n.send(r)];case 1:return s.sent(),this.hiddenState=ms.UNHIDDEN,t.dispatch(new sn({channels:[this],source:$t.EVENT_CHANNEL_UNHIDDEN})),[2,this]}}))}))},s.prototype.delete=function(){return p(this,void 0,void 0,(function(){var e,t;return _(this,(function(n){switch(n.label){case 0:return e=W.of(this._iid).requestQueue,t=new Gr({channelUrl:this.url}),[4,e.send(t)];case 1:return n.sent(),[2]}}))}))},s.prototype.markAsRead=function(){return p(this,void 0,void 0,(function(){var e,t,n,r,s,i,a,o=this;return _(this,(function(u){switch(u.label){case 0:return e=W.of(this._iid),t=e.sdkState,n=e.dispatcher,r=e.requestQueue,s=new Vn({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),sr.of(this._iid).handlers.map((function(e){return e.onChannelChanged(o)}))),n.dispatch(new sn({channels:[this],source:$t.EVENT_CHANNEL_READ})),[2]}}))}))},s.prototype.markAsDelivered=function(){return p(this,void 0,void 0,(function(){var e,t,n,r;return _(this,(function(s){switch(s.label){case 0:return e=W.of(this._iid),t=e.sdkState,n=e.requestQueue,r=new qn({channelUrl:this.url,userId:t.userId}),[4,n.send(r)];case 1:return s.sent(),[2]}}))}))},s.prototype.startTyping=function(){return p(this,void 0,void 0,(function(){var e,t,n,r,s;return _(this,(function(i){return e=W.of(this._iid),t=e.requestQueue,n=e.typingIndicatorThrottle,(r=(new Date).getTime())-this._typingStarted>=n&&(this._typingStarted=r,this._typingEnded=0,s=new Wn({channelUrl:this.url,time:this._typingStarted}),t.send(s)),[2]}))}))},s.prototype.endTyping=function(){return p(this,void 0,void 0,(function(){var e,t,n,r,s;return _(this,(function(i){return e=W.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]}))}))},s.prototype.createScheduledUserMessage=function(e){e=n(n({},We),e),te(Ye(e)).throw(Q.invalidParameters);var t=new Se;return this._createScheduledUserMessage(e,t),t},s.prototype.updateScheduledUserMessage=function(e,t){return p(this,void 0,void 0,(function(){var r,s,i,a;return _(this,(function(o){switch(o.label){case 0:return r=n(n({},Wr),t),te(function(e){return Et(e)&&g("number",e.scheduledAt,!0)}(r)).throw(Q.invalidParameters),s=W.of(this._iid).requestQueue,i=new Xr(n({reqId:this._generateRequestId(),scheduledMessageId:e,channelType:this.channelType,channelUrl:this.url},r)),[4,s.send(i)];case 1:return a=o.sent(),[2,a.as(Nt).message]}}))}))},s.prototype.createScheduledFileMessage=function(e){var t=this;e=n(n({},Je),e),te(Xe(e)).throw(Q.invalidParameters);var r=Date.now(),s=this._generateRequestId(),i=new Se;return ae(bt).then((function(){var n=t._createPendingScheduledFileMessage(e,s,r);Z((function(){return p(t,void 0,void 0,(function(){return _(this,(function(e){return[2,i._trigger(null,n)]}))}))}))})),y(e.file)?this._uploadFileAndUpdateParams(e).then((function(){return t._createScheduledFileMessage(e,i,s,r)})):this._createScheduledFileMessage(e,i,s,r),i},s.prototype.updateScheduledFileMessage=function(e,t){return p(this,void 0,void 0,(function(){var r,s,i;return _(this,(function(a){switch(a.label){case 0:return r=n(n({},zr),t),te(function(e){return gt(e)&&g("number",e.scheduledAt,!0)&&(y(e.file)||g("string",e.fileUrl))&&g("string",e.fileName,!0)&&g("string",e.mimeType,!0)&&g("number",e.fileSize,!0)&&(null===e.thumbnailSizes||e.thumbnailSizes.every((function(e){return g("object",e)&&e.maxWidth>0&&e.maxHeight>0})))}(r)).throw(Q.invalidParameters),y(r.file)?[4,this._uploadFileAndUpdateParams(r)]:[3,2];case 1:a.sent(),a.label=2;case 2:return s=new Yr(n({reqId:this._generateRequestId(),scheduledMessageId:e,channelType:this.channelType,channelUrl:this.url},r)),[4,W.of(this._iid).requestQueue.send(s)];case 3:return i=a.sent(),[2,i.as(Jr).message]}}))}))},s.prototype.cancelScheduledMessage=function(e){return p(this,void 0,void 0,(function(){var t;return _(this,(function(n){switch(n.label){case 0:return t=new Zr({scheduledMessageId:e,channelType:this.channelType,channelUrl:this.url}),[4,W.of(this._iid).requestQueue.send(t)];case 1:return n.sent(),[2]}}))}))},s.prototype.sendScheduledMessageNow=function(e){return p(this,void 0,void 0,(function(){var t;return _(this,(function(n){switch(n.label){case 0:return t=new $r({scheduledMessageId:e,channelType:this.channelType,channelUrl:this.url}),[4,W.of(this._iid).requestQueue.send(t)];case 1:return n.sent(),[2]}}))}))},s.prototype.getMyPushTriggerOption=function(){return p(this,void 0,void 0,(function(){var e,t,n,r,s,i;return _(this,(function(a){switch(a.label){case 0:return e=W.of(this._iid),t=e.sdkState,n=e.requestQueue,r=new ns({userId:t.userId,channelUrl:this.url}),[4,n.send(r)];case 1:return s=a.sent(),i=s.as(rs).pushTriggerOption,this.myPushTriggerOption=i,[2,i]}}))}))},s.prototype.setMyPushTriggerOption=function(e){return p(this,void 0,void 0,(function(){var t,n,r,s,i,o;return _(this,(function(u){switch(u.label){case 0:return te(a(et,e)).throw(Q.invalidParameters),t=W.of(this._iid),n=t.sdkState,r=t.requestQueue,s=new es({userId:n.userId,channelUrl:this.url,pushTriggerOption:e}),[4,r.send(s)];case 1:return i=u.sent(),o=i.as(ts).pushTriggerOption,this.myPushTriggerOption=o,[2,o]}}))}))},s.prototype.setMyCountPreference=function(e){return p(this,void 0,void 0,(function(){var t,n,r,s,i,o,u;return _(this,(function(l){switch(l.label){case 0:return te(a(ps,e)).throw(Q.invalidParameters),t=W.of(this._iid),n=t.dispatcher,r=t.sdkState,s=t.requestQueue,i=new Kr({channelUrl:this.url,userId:r.userId,countPreference:e}),[4,s.send(i)];case 1:return o=l.sent(),u=o.as(Br).countPreference,this.myCountPreference=u,this._updateUnreadCount(this.unreadMessageCount,this.unreadMentionCount),n.dispatch(new sn({channels:[this],source:$t.EVENT_CHANNEL_CREATED})),[2,u]}}))}))},s.prototype.resetMyHistory=function(){return p(this,void 0,void 0,(function(){var e,t,n,r,s,i;return _(this,(function(a){switch(a.label){case 0:return e=W.of(this._iid),t=e.dispatcher,n=e.requestQueue,r=new jr({channelUrl:this.url}),[4,n.send(r)];case 1:return s=a.sent(),i=s.as(Qr).messageOffsetTimestamp,this.messageOffsetTimestamp=i,t.dispatch(new sn({channels:[this],source:$t.EVENT_CHANNEL_RESET_HISTORY})),[2,this]}}))}))},s.prototype.updatePoll=function(e,t){return p(this,void 0,void 0,(function(){var r,s,i;return _(this,(function(a){switch(a.label){case 0:return te(g("number",e)&&function(e){return g("string",e.title,!0)&&Ne(e.data)&&g("boolean",e.allowUserSuggestion,!0)&&g("boolean",e.allowMultipleVotes,!0)&&g("number",e.closeAt,!0)}(t)).throw(Q.invalidParameters),r=W.of(this._iid).requestQueue,s=new ss(n({pollId:e},t)),[4,r.send(s)];case 1:return i=a.sent(),[2,i.as(is).poll]}}))}))},s.prototype.deletePoll=function(e){return p(this,void 0,void 0,(function(){var t,n,r;return _(this,(function(s){switch(s.label){case 0:return t=g("number",e),te(t).throw(Q.invalidParameters),n=W.of(this._iid).requestQueue,r=new as({pollId:e}),[4,n.send(r)];case 1:return s.sent(),[2]}}))}))},s.prototype.closePoll=function(e){return p(this,void 0,void 0,(function(){var t,n,r,s;return _(this,(function(i){switch(i.label){case 0:return t=g("number",e),te(t).throw(Q.invalidParameters),n=W.of(this._iid).requestQueue,r=new os({pollId:e}),[4,n.send(r)];case 1:return s=i.sent(),[2,s.as(us).poll]}}))}))},s.prototype.addPollOption=function(e,t){return p(this,void 0,void 0,(function(){var n,r,s,i;return _(this,(function(a){switch(a.label){case 0:return n=g("number",e)&&g("string",t)&&""!==t.trim(),te(n).throw(Q.invalidParameters),r=W.of(this._iid).requestQueue,s=new ls({channelUrl:this.url,channelType:this.channelType,pollId:e,optionText:t}),[4,r.send(s)];case 1:return i=a.sent(),[2,i.as(cs).poll]}}))}))},s.prototype.updatePollOption=function(e,t,n){return p(this,void 0,void 0,(function(){var r,s,i,a;return _(this,(function(o){switch(o.label){case 0:return r=g("number",e)&&g("number",t)&&g("string",n)&&""!==n.trim(),te(r).throw(Q.invalidParameters),s=W.of(this._iid).requestQueue,i=new hs({pollId:e,pollOptionId:t,optionText:n}),[4,s.send(i)];case 1:return a=o.sent(),[2,a.as(ds).poll]}}))}))},s.prototype.deletePollOption=function(e,t){return p(this,void 0,void 0,(function(){var n,r,s;return _(this,(function(i){switch(i.label){case 0:return n=g("number",e)&&g("number",t),te(n).throw(Q.invalidParameters),r=W.of(this._iid).requestQueue,s=new fs({pollId:e,pollOptionId:t}),[4,r.send(s)];case 1:return i.sent(),[2]}}))}))},s.prototype.votePoll=function(e,t){return p(this,void 0,void 0,(function(){var n,r,s,i,a,o,u;return _(this,(function(l){switch(l.label){case 0:return n=g("number",e)&&v("number",t),te(n).throw(Q.invalidParameters),r=W.of(this._iid),s=r.requestQueue,i=r.dispatcher,a=new vs({reqId:this._generateRequestId(),channelUrl:this.url,channelType:this.channelType,pollId:e,pollOptionIds:t}),[4,s.send(a)];case 1:return o=l.sent(),u=o.as(er).event,i.dispatch(new T({event:u,source:$.EVENT_POLL_VOTED})),[2,u]}}))}))},s.prototype.getPollChangeLogsSinceTimestamp=function(e){return p(this,void 0,void 0,(function(){return _(this,(function(t){switch(t.label){case 0:return te(g("number",e)).throw(Q.invalidParameters),[4,je.of(this._iid).getPollChangeLogs(this.url,this.channelType,e)];case 1:return[2,t.sent()]}}))}))},s.prototype.getPollChangeLogsSinceToken=function(e){return p(this,void 0,void 0,(function(){return _(this,(function(t){switch(t.label){case 0:return te(g("string",e,!0)),[4,je.of(this._iid).getPollChangeLogs(this.url,this.channelType,e)];case 1:return[2,t.sent()]}}))}))},s.prototype.createPollListQuery=function(e){return void 0===e&&(e=tt),new Ze(this._iid,{channelUrl:this.url,channelType:this.channelType,limit:e})},s.prototype.createPollVoterListQuery=function(e,t,n){return void 0===n&&(n=nt),new $e(this._iid,{channelUrl:this.url,channelType:this.channelType,pollId:e,pollOptionId:t,limit:n})},s.prototype._uploadFileAndUpdateParams=function(e){return p(this,void 0,void 0,(function(){var t,n,r,s,i,a,o,u,l,c,h;return _(this,(function(d){switch(d.label){case 0:return y(e.file)?(t=W.of(this._iid).requestQueue,n=new Ae({file:e.file,channelUrl:this.url,thumbnailSizes:e.thumbnailSizes,requestId:this._generateRequestId()}),[4,t.send(n)]):[3,2];case 1:r=d.sent(),s=r.as(Ue),i=s.url,a=s.fileSize,o=void 0===a?e.fileSize:a,u=s.thumbnailSizes,l=void 0===u?e.thumbnailSizes:u,c=s.requireAuth,h=void 0!==c&&c,e.fileUrl=i,e.fileSize=o,e.thumbnailSizes=l,e.requireAuth=h,d.label=2;case 2:return[2]}}))}))},s}(Ct),Es={},Cs=function(){function e(e){var t=e._iid,n=this;this._sync=null,this._metadata=null,this._iid=t;var r,s=W.of(this._iid),i=s.sdkState,a=s.logger;this._metadataKey=(r=i.userId,"sendbird:".concat(r,"@groupchannel/sync.meta"));var o=function(e){return"sendbird:".concat(e,"@groupchannel/sync")}(i.userId);this._sync=new cr(o,(function(){return p(n,void 0,void 0,(function(){var e,t,n,r,s,i;return _(this,(function(o){switch(o.label){case 0:return e={hasNext:!0,nextToken:""},[4,this.loadMetadata()];case 1:if(o.sent(),a.debug("channel background sync from",this._metadata.token),this._metadata.completed)return[3,9];o.label=2;case 2:return o.trys.push([2,5,,8]),[4,sr.of(this._iid).getMyGroupChannels(this._metadata.token,{includeEmpty:!0,order:De.CHRONOLOGICAL},100,$t.SYNC_CHANNEL_BACKGROUND)];case 3:return t=o.sent(),n=t.channels,r=t.token,e.hasNext=n.length>=100&&!!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,a.debug("channel background sync progress",e),[4,this.saveMetadata()];case 4:return o.sent(),[3,8];case 5:return s=o.sent(),a.debug("channel background sync error",s),s instanceof Q&&s.isInvalidTokenError?[4,this.clearMetaData()]:[3,7];case 6:o.sent(),o.label=7;case 7:throw s;case 8:return[3,10];case 9:e.hasNext=!1,e.nextToken="",o.label=10;case 10:return[2,e]}}))}))}))}return e.of=function(t){if(!Es[t]){var n=Es[t]=new e({_iid:t});W.of(t).dispatcher.on((function(e){if(e instanceof ue)if(e.stateType===le.CONNECTED)n.resume();else n.pause()}))}return Es[t]},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 p(this,void 0,void 0,(function(){var e;return _(this,(function(t){switch(t.label){case 0:return this._metadata?[3,2]:[4,W.of(this._iid).cacheContext.preference.get(this._metadataKey)];case 1:e=t.sent(),this._metadata={token:e?e.token:"",range:new nr(e?e.range:{top:Number.MAX_SAFE_INTEGER,bottom:0}),completed:!!e&&e.completed},t.label=2;case 2:return[2]}}))}))},e.prototype.saveMetadata=function(){return p(this,void 0,void 0,(function(){return _(this,(function(e){switch(e.label){case 0:return this._metadata?[4,W.of(this._iid).cacheContext.preference.set(this._metadataKey,this._metadata)]:[3,2];case 1:e.sent(),e.label=2;case 2:return[2]}}))}))},e.prototype.clearMetaData=function(){return p(this,void 0,void 0,(function(){return _(this,(function(e){switch(e.label){case 0:return[4,W.of(this._iid).cacheContext.preference.remove(this._metadataKey)];case 1:return e.sent(),this._metadata=null,[2]}}))}))},e.prototype.resume=function(){var e,t;W.of(this._iid).logger.debug("channel background sync resume()"),this._sync.start(null!==(t=null===(e=this._metadata)||void 0===e?void 0:e.token)&&void 0!==t?t:"")},e.prototype.pause=function(){W.of(this._iid).logger.debug("channel background sync stop()"),this._sync.stop()},e}(),Ns={},bs=function(){function e(e){var t=e._iid,n=this;this._sync=null,this._metadataKey=null,this._metadata=null,this._iid=t;var r,s=W.of(this._iid),i=s.logger,a=s.sdkState;this._metadataKey=(r=a.userId,"sendbird:".concat(r,"@groupchannel/changelogs.meta"));var o=function(e){return"sendbird:".concat(e,"@groupchannel/changelogs")}(a.userId);this._sync=new cr(o,(function(){return p(n,void 0,void 0,(function(){var e,t,n,r,s;return _(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,sr.of(this._iid).getMyGroupChannelChangeLogs(this._metadata.token,{},$t.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]}}))}))}))}return e.of=function(t){if(!Ns[t]){var n=Ns[t]=new e({_iid:t});W.of(t).dispatcher.on((function(e){if(e instanceof ue)if(e.stateType===le.CONNECTED)n.resume();else n.pause()}))}return Ns[t]},e.prototype.loadMetadata=function(){return p(this,void 0,void 0,(function(){var e,t,n,r;return _(this,(function(s){switch(s.label){case 0:return this._metadata?[3,2]:(e=W.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/1e3},s.label=2;case 2:return[2]}}))}))},e.prototype.saveMetadata=function(){return p(this,void 0,void 0,(function(){return _(this,(function(e){switch(e.label){case 0:return this._metadata?[4,W.of(this._iid).cacheContext.preference.set(this._metadataKey,this._metadata)]:[3,2];case 1:e.sent(),e.label=2;case 2:return[2]}}))}))},e.prototype.clearMetadata=function(){return p(this,void 0,void 0,(function(){return _(this,(function(e){switch(e.label){case 0:return[4,W.of(this._iid).cacheContext.preference.remove(this._metadataKey)];case 1:return e.sent(),this._metadata=null,[2]}}))}))},e.prototype.resume=function(){this._sync.start(0)},e.prototype.pause=function(){this._sync.stop()},e}(),Ms=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(ie()),this.filter=null!=n?n:new jt,this.order=null!=r?r:De.LATEST_LAST_MESSAGE,this._hasMore=!0,this._token="",this._limit=null!=s?s:Pe;var a=W.of(this._iid),o=a.sdkState;a.cacheContext.localCacheEnabled&&Cs.of(e).resume(),bs.of(e).resume(),sr.of(this._iid).subscribeGroupChannelEvent(this._key,{onUpdate:function(e,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)}})}return Object.defineProperty(e.prototype,"hasMore",{get:function(){return 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=this;void 0===n&&(n=!1);var a=[],o=[];try{for(var u=m(e),l=u.next();!l.done;l=u.next()){var c=l.value,h=Er(this.channels,c,this.order),d=h.place;if(h.contains)switch(o.push(c),t){case $t.EVENT_CHANNEL_UPDATED:case $t.EVENT_MESSAGE_RECEIVED:this.channels.splice(d,1);var f=Er(this.channels,c,this.order).place;this.channels.splice(f,0,c);break;default:this.channels[d]=c}else if(d===this.channels.length){var v=Cs.of(this._iid);(n||v.completed)&&(a.push(c),this.channels.push(c))}else a.push(c),this.channels.splice(d,0,c)}}catch(e){r={error:e}}finally{try{l&&!l.done&&(s=u.return)&&s.call(u)}finally{if(r)throw r.error}}rn(t)&&Z((function(){return p(i,void 0,void 0,(function(){var e;return _(this,(function(n){return e=new hr(t),a.length>0&&this._handler.onChannelsAdded(e,a),o.length>0&&this._handler.onChannelsUpdated(e,o),[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=m(e),l=u.next();!l.done;l=u.next()){a(l.value)}}catch(e){n={error:e}}finally{try{l&&!l.done&&(r=u.return)&&r.call(u)}finally{if(n)throw n.error}}return rn(t)&&i.length>0&&Z((function(){return p(s,void 0,void 0,(function(){var e;return _(this,(function(n){return e=new hr(t),this._handler.onChannelsDeleted(e,i),[2]}))}))})),i},e.prototype._getLocalChannels=function(){return p(this,void 0,void 0,(function(){return _(this,(function(e){switch(e.label){case 0:return[4,sr.of(this._iid).getChannelsFromCache(this._token,this.filter,this.order)];case 1:return[2,e.sent()]}}))}))},e.prototype._getRemoteChannels=function(){return p(this,void 0,void 0,(function(){var e,t,r;return _(this,(function(s){switch(s.label){case 0:return[4,sr.of(this._iid).getMyGroupChannels(this._token,n(n({},this.filter),{order:this.order}),this._limit)];case 1:return e=s.sent(),t=e.channels,r=e.token,this._token=r,this._hasMore=!!r,[2,t]}}))}))},e.prototype.loadMore=function(){return p(this,void 0,void 0,(function(){var e,t=this;return _(this,(function(n){switch(n.label){case 0:return this._hasMore?(e=[],[4,b((function(){return p(t,void 0,void 0,(function(){return _(this,(function(t){switch(t.label){case 0:return[4,this._getLocalChannels()];case 1:return e=t.sent(),[2]}}))}))}))]):[3,3];case 1:return n.sent(),[4,b((function(){return p(t,void 0,void 0,(function(){return _(this,(function(t){switch(t.label){case 0:return[4,this._getRemoteChannels()];case 1:return e=t.sent(),[2]}}))}))}))];case 2:return n.sent(),this._addChannelsToView(e,$t.REQUEST_CHANNEL,!0),[2,e];case 3:return[2,[]]}}))}))},e.prototype.dispose=function(){W.of(this._iid).cacheContext.localCacheEnabled&&Cs.of(this._iid).pause(),bs.of(this._iid).pause(),sr.of(this._iid).unsubscribeGroupChannelEvent(this._key)},e}(),Ts=function(n){function r(e){var r=this,s=e.token,i=e.limit,a=e.order,o=e.includeEmpty,u=e.membershipFilter,l=e.channelNameContainsFilter,c=e.channelUrlsFilter,h=e.customTypesFilter,d=e.customTypeStartsWithFilter,f=e.superChannelFilter,p=e.metadataOrderKeyFilter,_=e.metadataKey,m=e.metadataValues,v=e.metadataValueStartsWith,g=e.includeFrozen,y=e.includeMetaData;return(r=n.call(this)||this).method=D.GET,r.path=F,r.params=t({token:s,limit:i,order:a,show_member:!0,show_read_receipt:!0,show_delivery_receipt:!0,show_empty:o,public_mode:Pt.PUBLIC,public_membership_mode:u,name_contains:l,channel_urls:c,custom_types:h,custom_type_startswith:d,super_mode:f,metadata_order_key:p,metadata_key:_,metadata_values:m,metadata_value_startswith:v,show_frozen:g,show_metadata:y}),r}return e(r,n),r}(P),Ss=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 ys(e,t)}))),r.ts="number"==typeof a?a:null,r}return e(n,t),n}(O);!function(e){e.ALL="all",e.JOINED="joined"}(gs||(gs={}));var Us=function(t){function r(e,n){var r,s,i,a,o,u,l,c,h,d,f,p,_,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=gs.ALL,v.superChannelFilter=kt.ALL,v.metadataKey=null,v.metadataValues=null,v.metadataOrderKeyFilter=null,v.metadataValueStartsWith=null,v.order=rt.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!==(l=n.channelNameContainsFilter)&&void 0!==l?l:null,v.membershipFilter=null!==(c=n.membershipFilter)&&void 0!==c?c:gs.ALL,v.superChannelFilter=null!==(h=n.superChannelFilter)&&void 0!==h?h:kt.ALL,v.metadataKey=null!==(d=n.metadataKey)&&void 0!==d?d:null,v.metadataValues=null!==(f=n.metadataValues)&&void 0!==f?f:null,v.metadataOrderKeyFilter=null!==(p=n.metadataOrderKeyFilter)&&void 0!==p?p:null,v.metadataValueStartsWith=null!==(_=n.metadataValueStartsWith)&&void 0!==_?_:null,v.order=null!==(m=n.order)&&void 0!==m?m:rt.CHRONOLOGICAL,v}return e(r,t),r.prototype._validate=function(){return t.prototype._validate.call(this)&&g("boolean",this.includeEmpty)&&g("boolean",this.includeFrozen)&&g("boolean",this.includeMetaData)&&g("string",this.channelNameContainsFilter,!0)&&v("string",this.channelUrlsFilter,!0)&&v("string",this.customTypesFilter,!0)&&g("string",this.customTypeStartsWithFilter,!0)&&a(gs,this.membershipFilter)&&a(kt,this.superChannelFilter)&&a(rt,this.order)&&g("string",this.metadataOrderKeyFilter,!0)&&g("string",this.metadataKey,!0)&&v("string",this.metadataValues,!0)&&g("string",this.metadataValueStartsWith,!0)},r.prototype.next=function(){return p(this,void 0,void 0,(function(){var e,t,r,s,i,a,o,u,l;return _(this,(function(c){switch(c.label){case 0:return this._validate()?this._isLoading?[3,3]:(e=[],this._hasNext?(this._isLoading=!0,t=W.of(this._iid),r=t.requestQueue,s=t.dispatcher,i=new Ts(n(n({},this),{token:this._token})),[4,r.send(i)]):[3,2]):[3,5];case 1:return a=c.sent(),o=a.as(Ss),u=o.channels,l=o.token,this._token=l,this._hasNext=!!l,s.dispatch(new sn({channels:u,source:$t.REQUEST_CHANNEL})),this._isLoading=!1,[2,u];case 2:return[2,e];case 3:throw Q.queryInProgress;case 4:return[3,6];case 5:throw Q.invalidParameters;case 6:return[2]}}))}))},r}(j),As=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=Ie,e.onUserLeft=Ie,e.onUserReceivedInvitation=Ie,e.onUserDeclinedInvitation=Ie,e.onChannelHidden=Ie,e.onUnreadMemberStatusUpdated=Ie,e.onUndeliveredMemberStatusUpdated=Ie,e.onTypingStatusUpdated=Ie,e.onPollUpdated=Ie,e.onPollVoted=Ie,e.onPollDeleted=Ie,e}return e(n,t),n}(Dt)),Is=function(n){function r(e){var r=this,s=e.token,i=e.limit,a=e.order,o=e.reverse,u=e.channelUrl,l=e.messageTypeFilter,c=e.scheduledStatus;return(r=n.call(this)||this).method=D.GET,r.path="".concat(x),r.params=t({limit:i,reverse:o,channel_url:u,order:a,status:c}),s&&(r.params.token=s),l&&(r.params.message_type=l),r}return e(r,n),r}(P),ws=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 fe(e,t)})),r}return e(n,t),n}(O),Ls=function(t){function r(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(r,t),r.prototype._validate=function(){return t.prototype._validate.call(this)&&g("string",this.channelUrl,!0)&&(a(st,this.order)||null===this.order)&&g("boolean",this.reverse)&&(v(C,this.scheduledStatus)||null===this.scheduledStatus)&&a(E,this.messageTypeFilter)},r.prototype.next=function(){return p(this,void 0,void 0,(function(){var e,t,r,s,i,a;return _(this,(function(o){switch(o.label){case 0:return this._validate()?this._isLoading?[3,3]:this._hasNext?(this._isLoading=!0,e=W.of(this._iid).requestQueue,t=new Is(n(n({},this),{token:this._token})),[4,e.send(t)]):[3,2]:[3,5];case 1:return r=o.sent(),s=r.as(ws),i=s.scheduledMessages,a=s.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]}}))}))},r}(j),Ds=function(t){function r(){var e=null!==t&&t.apply(this,arguments)||this;return e.name="groupChannel",e}return e(r,t),r.prototype.init=function(e,n){var r=n.sdkState,s=n.dispatcher,i=n.sessionManager,a=n.requestQueue,o=n.logger,u=n.onlineDetector,l=n.cacheContext;t.prototype.init.call(this,e,{sdkState:r,dispatcher:s,sessionManager:i,requestQueue:a,logger:o,onlineDetector:u,cacheContext:l}),this._manager=new sr(e,{sdkState:r,cacheContext:l,dispatcher:s,sessionManager:i,requestQueue:a,logger:o})},r.prototype.createGroupChannelCollection=function(e){return void 0===e&&(e={}),new Ms(this._iid,e)},r.prototype.createMyGroupChannelListQuery=function(e){return void 0===e&&(e={}),new tr(this._iid,e)},r.prototype.createPublicGroupChannelListQuery=function(e){return void 0===e&&(e={}),new Us(this._iid,e)},r.prototype.createScheduledMessageListQuery=function(e){return void 0===e&&(e={}),new Ls(this._iid,e)},r.prototype.addGroupChannelHandler=function(e,t){te(g("string",e)&&t instanceof As).throw(Q.invalidParameters),this._manager.addHandler(e,t)},r.prototype.removeGroupChannelHandler=function(e){te(g("string",e)).throw(Q.invalidParameters),this._manager.removeHandler(e)},r.prototype.removeAllGroupChannelHandlers=function(){this._manager.clearHandler()},r.prototype.buildGroupChannelFromSerializedData=function(e){return this._manager.buildGroupChannelFromSerializedData(e)},r.prototype.buildGroupChannelListQueryFromSerializedData=function(e){return this._manager.buildGroupChannelListQueryFromSerializedData(e)},r.prototype.buildMemberFromSerializedData=function(e){return this._manager.buildMemberFromSerializedData(e)},r.prototype.getChannel=function(e){return p(this,void 0,void 0,(function(){return _(this,(function(t){return te(g("string",e)).throw(Q.invalidParameters),[2,this._manager.getChannel(e)]}))}))},r.prototype.getChannelWithoutCache=function(e){return p(this,void 0,void 0,(function(){return _(this,(function(t){return te(g("string",e)).throw(Q.invalidParameters),[2,this._manager.getChannelWithoutCache(e)]}))}))},r.prototype.getMyGroupChannelChangeLogsByToken=function(e,t){return p(this,void 0,void 0,(function(){var r;return _(this,(function(s){switch(s.label){case 0:return r=n(n({},Yt),t),te(g("string",e)&&Jt(r)).throw(Q.invalidParameters),[4,this._manager.getMyGroupChannelChangeLogs(e,r)];case 1:return[2,s.sent()]}}))}))},r.prototype.getMyGroupChannelChangeLogsByTimestamp=function(e,t){return p(this,void 0,void 0,(function(){var r;return _(this,(function(s){switch(s.label){case 0:return r=n(n({},Yt),t),te(g("number",e)&&Jt(r)).throw(Q.invalidParameters),[4,this._manager.getMyGroupChannelChangeLogs(e,r)];case 1:return[2,s.sent()]}}))}))},r.prototype.getGroupChannelCount=function(e){return p(this,void 0,void 0,(function(){var t;return _(this,(function(r){return t=n(n({},Xt),e),te(Zt(t)).throw(Q.invalidParameters),[2,this._manager.getGroupChannelCount(t)]}))}))},r.prototype.getUnreadItemCount=function(e){return void 0===e&&(e={}),p(this,void 0,void 0,(function(){return _(this,(function(t){switch(t.label){case 0:return[4,this._manager.getUnreadItemCount(e)];case 1:return[2,t.sent()]}}))}))},r.prototype.getTotalUnreadChannelCount=function(){return p(this,void 0,void 0,(function(){return _(this,(function(e){switch(e.label){case 0:return[4,this._manager.getTotalUnreadChannelCount()];case 1:return[2,e.sent()]}}))}))},r.prototype.getTotalUnreadMessageCount=function(e){return void 0===e&&(e={}),p(this,void 0,void 0,(function(){return _(this,(function(t){switch(t.label){case 0:return[4,this._manager.getTotalUnreadMessageCount(e)];case 1:return[2,t.sent()]}}))}))},r.prototype.getTotalScheduledMessageCount=function(e){return void 0===e&&(e={}),p(this,void 0,void 0,(function(){return _(this,(function(t){switch(t.label){case 0:return[4,this._manager.getTotalScheduledMessageCount(e)];case 1:return[2,t.sent()]}}))}))},r.prototype.getSubscribedTotalUnreadMessageCount=function(){return this._manager.getSubscribedTotalUnreadMessageCount()},r.prototype.getSubscribedCustomTypeTotalUnreadMessageCount=function(){return this._manager.getSubscribedCustomTypeTotalUnreadMessageCount()},r.prototype.getSubscribedCustomTypeUnreadMessageCount=function(e){return this._manager.getSubscribedCustomTypeUnreadMessageCount(e)},r.prototype.createChannel=function(e){return void 0===e&&(e={}),p(this,void 0,void 0,(function(){var t;return _(this,(function(r){return t=n(n({},zt),e),te(Wt(t)).throw(Q.invalidParameters),[2,this._manager.createChannel(t)]}))}))},r.prototype.createDistinctChannelIfNotExist=function(e){return void 0===e&&(e={}),p(this,void 0,void 0,(function(){var t;return _(this,(function(r){return t=n(n({},zt),e),te(Wt(t)).throw(Q.invalidParameters),t&&(t.isDistinct=!0),[2,this.createChannel(t)]}))}))},r.prototype.createChannelWithUserIds=function(e,t,r,s,i,a){return void 0===t&&(t=!1),void 0===r&&(r=null),void 0===s&&(s=null),void 0===i&&(i=""),void 0===a&&(a=""),p(this,void 0,void 0,(function(){var o;return _(this,(function(u){return o=n(n({},zt),{invitedUserIds:e,isDistinct:t,name:r,data:i,customType:a}),"string"==typeof s?o.coverUrl=s:o.coverImage=s,[2,this.createChannel(o)]}))}))},r.prototype.markAsReadAll=function(){return p(this,void 0,void 0,(function(){return _(this,(function(e){return this._manager.markAsReadAll(),[2]}))}))},r.prototype.markAsReadWithChannelUrls=function(e){return p(this,void 0,void 0,(function(){return _(this,(function(t){return te(v("string",e)).throw(Q.invalidParameters),this._manager.markAsReadWithChannelUrls(e),[2]}))}))},r.prototype.markAsDelivered=function(e){return p(this,void 0,void 0,(function(){return _(this,(function(t){switch(t.label){case 0:return te(g("string",e)).throw(Q.invalidParameters),[4,this.getChannel(e)];case 1:return[4,t.sent().markAsDelivered()];case 2:return t.sent(),[2]}}))}))},r}(we);export{ps as CountPreference,ys as GroupChannel,Ms as GroupChannelCollection,hr as GroupChannelEventContext,$t as GroupChannelEventSource,jt as GroupChannelFilter,As as GroupChannelHandler,tr as GroupChannelListQuery,Ds as GroupChannelModule,Gt as GroupChannelSearchField,xt as HiddenChannelFilter,ms as HiddenState,qt as Member,Ar as MemberListOrder,kr as MemberListQuery,Rt as MemberState,Ir as MemberStateFilter,gs as MembershipFilter,Lr as MessageCollection,wr as MessageCollectionInitHandler,lr as MessageCollectionInitPolicy,dr as MessageEventContext,Ur as MutedMemberFilter,_s as MutedState,Ot as MyMemberStateFilter,Ht as OperatorFilter,Pt as PublicChannelFilter,Us as PublicGroupChannelListQuery,Vt as QueryType,Kt as ReadStatus,Ls as ScheduledMessageListQuery,kt as SuperChannelFilter,Ft as UnreadChannelFilter,Bt as UnreadItemKey}; diff --git a/lib/__definition.d.ts b/lib/__definition.d.ts index 448cdad..f6239eb 100644 --- a/lib/__definition.d.ts +++ b/lib/__definition.d.ts @@ -620,6 +620,8 @@ export declare class MessageCollection { get pendingMessages(): SendableMessage[]; get hasPrevious(): boolean; get hasNext(): boolean; + private get viewTop(); + private get viewBottom(); setMessageCollectionHandler(handler: MessageCollectionEventHandler): void; initialize(policy: MessageCollectionInitPolicy): MessageCollectionInitHandler; loadPrevious(): Promise; @@ -924,7 +926,6 @@ export declare class Poll { voterCount: number; options: PollOption[]; createdBy?: string; - isAnonymous: boolean; allowUserSuggestion: boolean; allowMultipleVotes: boolean; votedPollOptionIds: number[]; @@ -943,7 +944,6 @@ export declare interface PollCreateParams { title: string; optionTexts: string[]; data?: PollData; - isAnonymous?: boolean; allowUserSuggestion?: boolean; allowMultipleVotes?: boolean; closeAt?: number; @@ -1002,7 +1002,6 @@ export declare class PollUpdateEvent { export declare interface PollUpdateParams { title?: string; data?: PollData; - isAnonymous?: boolean; allowUserSuggestion?: boolean; allowMultipleVotes?: boolean; closeAt?: number; diff --git a/message.js b/message.js index 4f59cf5..f5eea87 100644 --- a/message.js +++ b/message.js @@ -1 +1 @@ -export{b1 as AdminMessage,ak as AppleCriticalAlertOptions,aG as BaseMessage,F as FileMessage,ah as MentionType,ai as MessageMetaArray,a3 as MessageModule,ay as MessageRequestHandler,b5 as MessageSearchOrder,a7 as MessageSearchQuery,t as MessageType,s as MessageTypeFilter,b6 as OGImage,b7 as OGMetaData,au as PreviousMessageListQuery,aj as PushNotificationDeliveryOption,b8 as Reaction,aq as ReactionEvent,b9 as ReactionEventOperation,R as ReplyType,av as Sender,D as SendingStatus,ba as ThreadInfo,b2 as ThreadInfoUpdateEvent,as as Thumbnail,x as UserMessage}from"./__bundle-0a632c33.js"; +export{b1 as AdminMessage,ak as AppleCriticalAlertOptions,aG as BaseMessage,F as FileMessage,ah as MentionType,ai as MessageMetaArray,a3 as MessageModule,ay as MessageRequestHandler,b5 as MessageSearchOrder,a7 as MessageSearchQuery,t as MessageType,s as MessageTypeFilter,b6 as OGImage,b7 as OGMetaData,au as PreviousMessageListQuery,aj as PushNotificationDeliveryOption,b8 as Reaction,aq as ReactionEvent,b9 as ReactionEventOperation,R as ReplyType,av as Sender,D as SendingStatus,ba as ThreadInfo,b2 as ThreadInfoUpdateEvent,as as Thumbnail,x as UserMessage}from"./__bundle-1abffbb6.js"; diff --git a/openChannel.js b/openChannel.js index 8cee7ab..0c074fa 100644 --- a/openChannel.js +++ b/openChannel.js @@ -1 +1 @@ -import{_ as n,j as e,k as t,I as r,T as a,i,q as s,A as o,b3 as u,b4 as c,b as l,c as h,e as d,an as p,U as f,W as C,H as v,J as _,z as y,a8 as m,ax as g,a9 as U,C as E,aU as w,u as T,S as N,l as H,n as b,V as M,aT as I,y as O,r as D,X as x,o as A}from"./__bundle-0a632c33.js";import{j as P,k as L,l as R,n as k,m as F,o as S,p as q,D as Q,q as z,r as K,t as W,e as j}from"./__bundle-c7363281.js";import{a as G,O as B,C as X,M as V,T as Z,R as J,U as Y,A as $,B as nn}from"./__bundle-466be550.js";var en=function(r){function a(){var n=null!==r&&r.apply(this,arguments)||this;return n._channels=new Map,n._enteredChannelUrls=[],n}return n(a,r),Object.defineProperty(a.prototype,"enteredChannels",{get:function(){var n=this;return this._enteredChannelUrls.map((function(e){return n._channels.get(e)})).filter((function(n){return null!==n}))},enumerable:!1,configurable:!0}),a.prototype.isEnteredChannel=function(n){return this._enteredChannelUrls.includes(n)},a.prototype.enter=function(n){this._enteredChannelUrls.indexOf(n)<0&&this._enteredChannelUrls.push(n)},a.prototype.exit=function(n){var e=this._enteredChannelUrls.indexOf(n);e>=0&&this._enteredChannelUrls.splice(e,1)},a.prototype.exitAll=function(){this._enteredChannelUrls=[]},a.prototype.get=function(n){var r;return e(this,void 0,void 0,(function(){return t(this,(function(e){return[2,null!==(r=this._channels.get(n))&&void 0!==r?r:null]}))}))},a.prototype.upsert=function(n){return e(this,void 0,void 0,(function(){var e=this;return t(this,(function(t){return n.forEach((function(n){if(e._channels.has(n.url)){var t=e._channels.get(n.url);Object.assign(t,n)}else e._channels.set(n.url,n)})),[2]}))}))},a.prototype.remove=function(n){return e(this,void 0,void 0,(function(){return t(this,(function(e){return this._channels.delete(n),this.exit(n),[2]}))}))},a.prototype.clear=function(){return e(this,void 0,void 0,(function(){return t(this,(function(n){return this._channels.clear(),this._enteredChannelUrls=[],[2]}))}))},a}(r),tn={channelUrl:null,name:null,coverUrlOrImage:null,data:null,customType:null,operatorUserIds:null},rn=function(e){function t(n){var t=n.channelUrl,r=n.isInternalCall,a=e.call(this)||this;return a.method=o.GET,a.path="".concat(r?u:c,"/").concat(encodeURIComponent(t)),a}return n(t,e),t}(l),an=function(e){function t(n,t){var r=e.call(this,n,t)||this;return r.channel=null,r.channel=new gn(n,t),r}return n(t,e),t}(h),sn=function(e){function t(n){var t=this,r=n.channelUrl,a=n.coverUrlOrImage,u=n.name,l=n.data,h=n.customType,p=n.operatorUserIds;return(t=e.call(this)||this).method=o.POST,t.path=c,t.params=d({channel_url:r,cover_url:i("string",a)?a:null,cover_file:s(a)?a:null,name:u,data:l,custom_type:h,operators:p}),t}return n(t,e),t}(l);!function(e){function t(n,t){var r=e.call(this,n,t)||this;return r.channel=new gn(n,t),r}n(t,e)}(h);var on=function(e){function t(n){var t=n.channelUrl;return e.call(this,{code:"ENTR",payload:{channel_url:t},ackRequired:!0})||this}return n(t,e),t}(p),un=function(e){function t(n,t,r){var a,i,s=this;return s=e.call(this,n,"ENTR",r)||this,r.data&&(s.participantCount=null!==(a=r.data.participant_count)&&void 0!==a?a:0,s.user=new f(n,r.data),s.ts=null!==(i=r.data.edge_ts)&&void 0!==i?i:0),s}return n(t,e),t}(C),cn=function(e){function t(n){var t=n.channelUrl;return e.call(this,{code:"EXIT",payload:{channel_url:t},ackRequired:!0})||this}return n(t,e),t}(p),ln=function(e){function t(n,t,r){var a,i,s=this;return s=e.call(this,n,"EXIT",r)||this,r.data&&(s.participantCount=null!==(a=r.data.participant_count)&&void 0!==a?a:0,s.user=new f(n,r.data),s.ts=null!==(i=r.data.edge_ts)&&void 0!==i?i:0),s}return n(t,e),t}(C),hn={},dn=function(){function n(n,e){var t=e.sdkState,r=e.dispatcher,a=e.requestQueue,i=this;this._sdkState=t,this._requestQueue=a,this._dispatcher=r,this._openChannelCache=new en(n),this._openChannelHandlers=new Map,this._dispatcher.on((function(n){var e,t;if(n instanceof C)i._handleEvent(n);else if(n instanceof v&&n.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(n){e={error:n}}finally{try{s&&!s.done&&(t=a.return)&&t.call(a)}finally{if(e)throw e.error}}}})),hn[n]=this}return n.of=function(n){return hn[n]},n.prototype.buildOpenChannelFromSerializedData=function(n){var e=m(n);return new gn(e._iid,gn.payloadify(e))},n.prototype.getChannelFromCache=function(n){return e(this,void 0,void 0,(function(){return t(this,(function(e){switch(e.label){case 0:return[4,this._openChannelCache.get(n)];case 1:return[2,e.sent()]}}))}))},n.prototype.upsertChannelsToCache=function(n){return e(this,void 0,void 0,(function(){return t(this,(function(e){switch(e.label){case 0:return[4,this._openChannelCache.upsert(n)];case 1:return e.sent(),[2]}}))}))},n.prototype.removeChannelsFromCache=function(n){return e(this,void 0,void 0,(function(){var e,r,a,i,s,o;return t(this,(function(t){switch(t.label){case 0:t.trys.push([0,5,6,7]),e=y(n),r=e.next(),t.label=1;case 1:return r.done?[3,4]:(a=r.value,[4,this._openChannelCache.remove(a)]);case 2:t.sent(),t.label=3;case 3:return r=e.next(),[3,1];case 4:return[3,7];case 5:return i=t.sent(),s={error:i},[3,7];case 6:try{r&&!r.done&&(o=e.return)&&o.call(e)}finally{if(s)throw s.error}return[7];case 7:return[2]}}))}))},n.prototype.setEnteredToCache=function(n){this._openChannelCache.enter(n.url)},n.prototype.setExitedToCache=function(n){this._openChannelCache.exit(n.url)},n.prototype._handleEvent=function(n){return e(this,void 0,void 0,(function(){var r,a,i,s,o,u,c,l,h,d,p,f,C,v,_,m,T,N,H,b,M,I,O,D,x,A,j,nn,en,tn,rn,an,sn,on,cn,hn,dn,pn,fn,Cn,vn,_n,yn,mn,gn,Un,En,wn,Tn,Nn,Hn,bn,Mn,In,On,Dn,xn,An,Pn,Ln=this;return t(this,(function(Rn){switch(Rn.label){case 0:switch(Rn.trys.push([0,51,,52]),n.code){case"MESG":case"FILE":case"ADMM":case"BRDM":return[3,1];case"MEDI":case"FEDI":case"AEDI":return[3,4];case"DELM":return[3,7];case"MRCT":return[3,10];case"MTHD":return[3,13];case"MCNT":return[3,16];case"SYEV":return[3,27]}return[3,50];case 1:return s=null,"MESG"===n.code?s=n.as(W):"FILE"===n.code?s=n.as(w):"ADMM"!==n.code&&"BRDM"!=n.code||(s=n.as($)),s?(r=s.message,a=s.isMentioned,r.channelType!==E.OPEN?[3,3]:[4,this.getChannel(r.channelUrl,!0)]):[3,3];case 2:i=Rn.sent(),U((function(){return e(Ln,void 0,void 0,(function(){var n,e,s,o,u;return t(this,(function(t){try{for(n=y(this._openChannelHandlers.values()),e=n.next();!e.done;e=n.next())s=e.value,this._openChannelCache.isEnteredChannel(i.url)&&s.onMessageReceived(i,r),a&&s.onMentionReceived(i,r)}catch(n){o={error:n}}finally{try{e&&!e.done&&(u=n.return)&&u.call(n)}finally{if(o)throw o.error}}return[2]}))}))})),Rn.label=3;case 3:return[3,50];case 4:return s=null,"MEDI"===n.code?s=n.as(z):"FEDI"===n.code?s=n.as(K):"AEDI"===n.code&&(s=n.as(Y)),s?(o=s.message).channelType!==E.OPEN?[3,6]:[4,this.getChannel(o.channelUrl,!0)]:[3,6];case 5:u=Rn.sent(),U((function(){return e(Ln,void 0,void 0,(function(){var n,e,r,a,i;return t(this,(function(t){try{for(n=y(this._openChannelHandlers.values()),e=n.next();!e.done;e=n.next())r=e.value,this._openChannelCache.isEnteredChannel(u.url)&&r.onMessageUpdated(u,o)}catch(n){a={error:n}}finally{try{e&&!e.done&&(i=n.return)&&i.call(n)}finally{if(a)throw a.error}}return[2]}))}))})),Rn.label=6;case 6:return[3,50];case 7:return c=n.as(Q),M=c.channelUrl,p=c.channelType,l=c.messageId,p!==E.OPEN?[3,9]:[4,this.getChannel(M,!0)];case 8:h=Rn.sent(),U((function(){return e(Ln,void 0,void 0,(function(){var n,e,r,a,i;return t(this,(function(t){try{for(n=y(this._openChannelHandlers.values()),e=n.next();!e.done;e=n.next())r=e.value,this._openChannelCache.isEnteredChannel(h.url)&&r.onMessageDeleted(h,l)}catch(n){a={error:n}}finally{try{e&&!e.done&&(i=n.return)&&i.call(n)}finally{if(a)throw a.error}}return[2]}))}))})),Rn.label=9;case 9:return[3,50];case 10:return d=n.as(J),M=d.channelUrl,p=d.channelType,f=d.event,p!==E.OPEN?[3,12]:[4,this.getChannel(M,!0)];case 11:C=Rn.sent(),U((function(){return e(Ln,void 0,void 0,(function(){var n,e,r,a;return t(this,(function(t){try{for(n=y(this._openChannelHandlers.values()),e=n.next();!e.done;e=n.next())e.value.onReactionUpdated(C,f)}catch(n){r={error:n}}finally{try{e&&!e.done&&(a=n.return)&&a.call(n)}finally{if(r)throw r.error}}return[2]}))}))})),Rn.label=12;case 12:return[3,50];case 13:return(v=n.as(Z).event).channelType!==E.OPEN?[3,15]:[4,this.getChannel(v.channelUrl,!0)];case 14:_=Rn.sent(),U((function(){return e(Ln,void 0,void 0,(function(){var n,e,r,a;return t(this,(function(t){try{for(n=y(this._openChannelHandlers.values()),e=n.next();!e.done;e=n.next())e.value.onThreadInfoUpdated(_,v)}catch(n){r={error:n}}finally{try{e&&!e.done&&(a=n.return)&&a.call(n)}finally{if(r)throw r.error}}return[2]}))}))})),Rn.label=15;case 15:return[3,50];case 16:m=n.as(V).openChannelMemberCounts,T=[],Rn.label=17;case 17:Rn.trys.push([17,22,23,24]),N=y(m),H=N.next(),Rn.label=18;case 18:return H.done?[3,21]:(b=H.value,M=b.channelUrl,an=b.participantCount,I=b.updatedAt,[4,this.getChannelFromCache(M)]);case 19:(O=Rn.sent())&&O._updateParticipantCount(an,I)&&T.push(O),Rn.label=20;case 20:return H=N.next(),[3,18];case 21:return[3,24];case 22:return D=Rn.sent(),An={error:D},[3,24];case 23:try{H&&!H.done&&(Pn=N.return)&&Pn.call(N)}finally{if(An)throw An.error}return[7];case 24:return T.length>0?[4,this.upsertChannelsToCache(T)]:[3,26];case 25:Rn.sent(),U((function(){return e(Ln,void 0,void 0,(function(){var n,e,r,a;return t(this,(function(t){try{for(n=y(this._openChannelHandlers.values()),e=n.next();!e.done;e=n.next())e.value.onChannelMemberCountChanged(T)}catch(n){r={error:n}}finally{try{e&&!e.done&&(a=n.return)&&a.call(n)}finally{if(r)throw r.error}}return[2]}))}))})),Rn.label=26;case 26:return[3,50];case 27:if(!(x=n.as(X).event).isOpenChannelEvent)return[3,49];switch(x.category){case G.CHANNEL_ENTER:return[3,28];case G.CHANNEL_EXIT:return[3,30];case G.CHANNEL_OPERATOR_UPDATE:return[3,32];case G.USER_CHANNEL_MUTE:case G.USER_CHANNEL_UNMUTE:return[3,34];case G.USER_CHANNEL_BAN:case G.USER_CHANNEL_UNBAN:return[3,36];case G.CHANNEL_FREEZE:case G.CHANNEL_UNFREEZE:return[3,38];case G.CHANNEL_DELETED:return[3,40];case G.CHANNEL_PROP_CHANGED:return[3,43];case G.CHANNEL_META_DATA_CHANGED:return[3,45];case G.CHANNEL_META_COUNTERS_CHANGED:return[3,47]}return[3,49];case 28:return[4,this.getChannel(x.channelUrl,!0)];case 29:return A=Rn.sent(),j=n.as(un),an=j.participantCount,nn=j.user,en=A._updateParticipantCount(an,x.ts),U((function(){return e(Ln,void 0,void 0,(function(){return t(this,(function(n){return this._openChannelHandlers.forEach((function(n){n.onUserEntered(A,nn),en&&n.onChannelParticipantCountChanged(A)})),[2]}))}))})),[3,49];case 30:return[4,this.getChannel(x.channelUrl,!0)];case 31:return tn=Rn.sent(),rn=n.as(ln),an=rn.participantCount,sn=rn.user,on=tn._updateParticipantCount(an,x.ts),U((function(){return e(Ln,void 0,void 0,(function(){return t(this,(function(n){return this._openChannelHandlers.forEach((function(n){n.onUserExited(tn,sn),on&&n.onChannelParticipantCountChanged(tn)})),[2]}))}))})),[3,49];case 32:return[4,this.getChannel(x.channelUrl,!0)];case 33:return cn=Rn.sent(),hn=n.as(B).operators,cn.operators=hn,this.upsertChannelsToCache([cn]),U((function(){return e(Ln,void 0,void 0,(function(){return t(this,(function(n){return this._openChannelHandlers.forEach((function(n){n.onOperatorUpdated(cn,hn)})),[2]}))}))})),[3,49];case 34:return[4,this.getChannel(x.channelUrl,!0)];case 35:return dn=Rn.sent(),pn=x.category===G.USER_CHANNEL_MUTE,fn=n.as(pn?S:q).user,U((function(){return e(Ln,void 0,void 0,(function(){return t(this,(function(n){return this._openChannelHandlers.forEach((function(n){pn?n.onUserMuted(dn,fn):n.onUserUnmuted(dn,fn)})),[2]}))}))})),[3,49];case 36:return[4,this.getChannel(x.channelUrl,!0)];case 37:return Cn=Rn.sent(),vn=x.category===G.USER_CHANNEL_BAN,_n=n.as(vn?k:F).user,U((function(){return e(Ln,void 0,void 0,(function(){return t(this,(function(n){return this._openChannelHandlers.forEach((function(n){vn?n.onUserBanned(Cn,_n):n.onUserUnbanned(Cn,_n)})),[2]}))}))})),[3,49];case 38:return[4,this.getChannel(x.channelUrl,!0)];case 39:return yn=Rn.sent(),mn=n.as(R).freeze,yn.isFrozen=mn,this.upsertChannelsToCache([yn]),U((function(){return e(Ln,void 0,void 0,(function(){return t(this,(function(n){return this._openChannelHandlers.forEach((function(n){mn?n.onChannelFrozen(yn):n.onChannelUnfrozen(yn)})),[2]}))}))})),[3,49];case 40:return[4,this.getChannel(x.channelUrl,!0)];case 41:return gn=Rn.sent(),[4,this.removeChannelsFromCache([gn.url])];case 42:return Rn.sent(),U((function(){return e(Ln,void 0,void 0,(function(){return t(this,(function(n){return this._openChannelHandlers.forEach((function(n){n.onChannelDeleted(gn.url,gn.channelType)})),[2]}))}))})),[3,49];case 43:return[4,this.getChannelWithoutCache(x.channelUrl,!0)];case 44:return Un=Rn.sent(),U((function(){return e(Ln,void 0,void 0,(function(){return t(this,(function(n){return this._openChannelHandlers.forEach((function(n){n.onChannelChanged(Un)})),[2]}))}))})),[3,49];case 45:return[4,this.getChannel(x.channelUrl,!0)];case 46:return En=Rn.sent(),wn=n.as(L),Tn=wn.created,Nn=wn.updated,Hn=wn.deleted,Tn&&En._upsertCachedMetaData(Tn,x.ts),Nn&&En._upsertCachedMetaData(Nn,x.ts),Hn&&En._removeFromCachedMetaData(Hn,x.ts),U((function(){return e(Ln,void 0,void 0,(function(){return t(this,(function(n){return this._openChannelHandlers.forEach((function(n){Tn&&n.onMetaDataCreated(En,Tn),Nn&&n.onMetaDataUpdated(En,Nn),Hn&&n.onMetaDataDeleted(En,Hn)})),[2]}))}))})),[3,49];case 47:return[4,this.getChannel(x.channelUrl,!0)];case 48:return bn=Rn.sent(),Mn=n.as(P),In=Mn.created,On=Mn.updated,Dn=Mn.deleted,U((function(){return e(Ln,void 0,void 0,(function(){return t(this,(function(n){return this._openChannelHandlers.forEach((function(n){In&&n.onMetaCounterCreated(bn,In),On&&n.onMetaCounterUpdated(bn,On),Dn&&n.onMetaCounterDeleted(bn,Dn)})),[2]}))}))})),[3,49];case 49:return[3,50];case 50:return[3,52];case 51:if(xn=Rn.sent(),g(xn))throw xn;return[3,52];case 52:return[2]}}))}))},n.prototype.addHandler=function(n,e){this._openChannelHandlers.set(n,e)},n.prototype.removeHandler=function(n){this._openChannelHandlers.delete(n)},n.prototype.clearHandler=function(){this._openChannelHandlers.clear()},n.prototype.getChannel=function(n,r){return e(this,void 0,void 0,(function(){var e;return t(this,(function(t){switch(t.label){case 0:T(i("string",n)).throw(N.invalidParameters),t.label=1;case 1:return t.trys.push([1,3,,4]),[4,this.getChannelFromCache(n)];case 2:return(e=t.sent())?[2,e]:[3,4];case 3:return t.sent(),[3,4];case 4:return[4,this.getChannelWithoutCache(n)];case 5:return[2,t.sent()]}}))}))},n.prototype.getChannelWithoutCache=function(n,r){return void 0===r&&(r=!1),e(this,void 0,void 0,(function(){var e,a,s;return t(this,(function(t){switch(t.label){case 0:return T(i("string",n)).throw(N.invalidParameters),e=new rn({channelUrl:n,isInternalCall:r}),[4,this._requestQueue.send(e)];case 1:return a=t.sent(),s=a.as(an).channel,[4,this.upsertChannelsToCache([s])];case 2:return t.sent(),[2,s]}}))}))},n.prototype.createChannel=function(n){return e(this,void 0,void 0,(function(){var e,r,o,u;return t(this,(function(t){switch(t.label){case 0:return e=H(H({},tn),n),T(function(n){return a("string",n.operatorUserIds,!0)&&(i("string",n.coverUrlOrImage)||s(n.coverUrlOrImage)||null===n.coverUrlOrImage)&&i("string",n.name,!0)&&i("string",n.data,!0)&&i("string",n.customType,!0)&&(i("string",n.channelUrl)&&/^\w+$/.test(n.channelUrl)||null===n.channelUrl)}(e)).throw(N.invalidParameters),r=new sn(e),[4,this._requestQueue.send(r)];case 1:return o=t.sent(),u=o.as(an).channel,this.upsertChannelsToCache([u]),[2,u]}}))}))},n}(),pn={name:null,coverUrlOrImage:null,data:null,customType:null,operatorUserIds:null},fn=function(e){function t(n){var t=this,r=n.channelUrl,a=n.token,i=n.limit;return(t=e.call(this)||this).method=o.GET,t.path="".concat(c,"/").concat(encodeURIComponent(r),"/participants"),t.params={token:a,limit:i},t}return n(t,e),t}(l),Cn=function(e){function t(n,t){var r=e.call(this,n,t)||this;r.token=null,r.participants=[];var a=t.next,i=t.participants;return r.token=a,r.participants=i.map((function(e){return new f(n,e)})),r}return n(t,e),t}(h),vn=function(r){function a(n,e,t){return r.call(this,n,e,E.OPEN,t)||this}return n(a,r),a.prototype._validate=function(){return r.prototype._validate.call(this)},a.prototype.next=function(){return e(this,void 0,void 0,(function(){var n,e,r,a,i,s;return t(this,(function(t){switch(t.label){case 0:return this._validate()?this._isLoading?[3,3]:this._hasNext?(this._isLoading=!0,n=M.of(this._iid).requestQueue,e=new fn(H(H({},this),{token:this._token})),[4,n.send(e)]):[3,2]:[3,5];case 1:return r=t.sent(),a=r.as(Cn),i=a.participants,s=a.token,this._token=s,this._hasNext=!!s,this._isLoading=!1,[2,i];case 2:return[2,[]];case 3:throw N.queryInProgress;case 4:return[3,6];case 5:throw N.invalidParameters;case 6:return[2]}}))}))},a}(b),_n=function(e){function t(n){var t=this,r=n.channelUrl,a=n.coverUrlOrImage,u=n.name,l=n.data,h=n.customType,p=n.operatorUserIds;return(t=e.call(this)||this).method=o.PUT,t.path="".concat(c,"/").concat(encodeURIComponent(r)),t.params=d({cover_url:i("string",a)?a:null,cover_file:s(a)?a:null,name:u,data:l,custom_type:h,operators:p}),t}return n(t,e),t}(l),yn=function(e){function t(n,t){var r=e.call(this,n,t)||this;return r.channel=new gn(n,t),r}return n(t,e),t}(h),mn=function(e){function t(n){var t=this,r=n.channelUrl;return(t=e.call(this)||this).method=o.DELETE,t.path="".concat(c,"/").concat(encodeURIComponent(r)),t}return n(t,e),t}(l);!function(e){function t(n,t){return e.call(this,n,t)||this}n(t,e)}(h);var gn=function(r){function o(n,e){var t,a=this;return(a=r.call(this,n,e)||this)._lastParticipantCountUpdated=0,a.participantCount=0,a.operators=[],a.channelType=E.OPEN,a.participantCount=null!==(t=e.participant_count)&&void 0!==t?t:0,a.operators=Array.isArray(e.operators)?e.operators.map((function(e){return new f(n,e)})):[],a}return n(o,r),o.payloadify=function(n){return n?d(H(H({},j.payloadify(n)),{participant_count:n.participantCount,operators:n.operators.map((function(n){return f.payloadify(n)}))})):null},o.prototype.serialize=function(){return I(this)},o.prototype.isOperator=function(n){return n instanceof f?this.isOperator(n.userId):this.operators.some((function(e){return e.userId===n}))},o.prototype._updateParticipantCount=function(n,e){return e>this._lastParticipantCountUpdated&&(this.participantCount=n,this._lastParticipantCountUpdated=e,!0)},o.prototype.createParticipantListQuery=function(n){return new vn(this._iid,this.url,n)},o.prototype.refresh=function(){return e(this,void 0,void 0,(function(){return t(this,(function(n){switch(n.label){case 0:return[4,dn.of(this._iid).getChannelWithoutCache(this.url)];case 1:return[2,n.sent()]}}))}))},o.prototype.enter=function(){return e(this,void 0,void 0,(function(){var n,e,r,a,i,s;return t(this,(function(t){switch(t.label){case 0:return n=M.of(this._iid).requestQueue,e=new on({channelUrl:this.url}),[4,n.send(e)];case 1:return r=t.sent(),a=r.as(un),i=a.participantCount,s=a.ts,this._updateParticipantCount(i,s),dn.of(this._iid).setEnteredToCache(this),[2]}}))}))},o.prototype.exit=function(){return e(this,void 0,void 0,(function(){var n,e,r,a,i,s;return t(this,(function(t){switch(t.label){case 0:return n=M.of(this._iid).requestQueue,e=new cn({channelUrl:this.url}),[4,n.send(e)];case 1:return r=t.sent(),a=r.as(ln),i=a.participantCount,s=a.ts,this._updateParticipantCount(i,s),dn.of(this._iid).setExitedToCache(this),O.of(this._iid).fileMessageQueue.cancel(this),[2]}}))}))},o.prototype.updateChannel=function(n){return e(this,void 0,void 0,(function(){var e,r,o,u,c;return t(this,(function(t){switch(t.label){case 0:return e=H(H({},pn),n),T(function(n){return a("string",n.operatorUserIds,!0)&&(i("string",n.coverUrlOrImage)||s(n.coverUrlOrImage)||null===n.coverUrlOrImage)&&i("string",n.name,!0)&&i("string",n.data,!0)&&i("string",n.customType,!0)}(e)).throw(N.invalidParameters),r=M.of(this._iid).requestQueue,o=new _n(H({channelUrl:this.url},e)),[4,r.send(o)];case 1:return u=t.sent(),c=u.as(yn).channel,[4,dn.of(this._iid).upsertChannelsToCache([c])];case 2:return t.sent(),[2,c]}}))}))},o.prototype.updateChannelWithOperatorUserIds=function(n,r,a,i,s){return e(this,void 0,void 0,(function(){var e;return t(this,(function(t){return e=H(H({},pn),{name:n,coverUrlOrImage:r,data:a,operatorUserIds:i,customType:s}),[2,this.updateChannel(e)]}))}))},o.prototype.delete=function(){return e(this,void 0,void 0,(function(){var n,e;return t(this,(function(t){switch(t.label){case 0:return n=M.of(this._iid).requestQueue,e=new mn({channelUrl:this.url}),[4,n.send(e)];case 1:return t.sent(),[4,dn.of(this._iid).removeChannelsFromCache([this.url])];case 2:return t.sent(),[2]}}))}))},o}(j),Un=function(e){function t(n){void 0===n&&(n={});var t=e.call(this)||this;return Object.keys(n).forEach((function(e){t.hasOwnProperty(e)&&(t[e]=n[e])})),t}return n(t,e),t}(function(e){function t(){var n=null!==e&&e.apply(this,arguments)||this;return n.onUserEntered=D,n.onUserExited=D,n.onChannelParticipantCountChanged=D,n}return n(t,e),t}(nn)),En=function(e){function t(n){var t=this,r=n.token,a=n.limit,i=n.nameKeyword,s=n.urlKeyword,u=n.customTypes,l=n.includeFrozen,h=n.includeMetaData;return(t=e.call(this)||this).method=o.GET,t.path=c,t.params=d({token:r,limit:a,name_contains:i,url_contains:s,custom_types:u,show_frozen:l,show_metadata:h}),t}return n(t,e),t}(l),wn=function(e){function t(n,t){var r=e.call(this,n,t)||this;r.token=null,r.channels=[],r.ts=null;var a=t.next,i=t.channels,s=t.ts;return r.token=a,i&&i.length>0&&(r.channels=i.map((function(e){return new gn(n,e)}))),r.ts="number"==typeof s?s:null,r}return n(t,e),t}(h),Tn=function(r){function s(n,e){var t,a,i,s,o,u=this;return(u=r.call(this,n,e)||this).includeFrozen=!0,u.includeMetaData=!0,u.nameKeyword=null,u.urlKeyword=null,u.customTypes=null,u.includeFrozen=null===(t=e.includeFrozen)||void 0===t||t,u.includeMetaData=null===(a=e.includeMetaData)||void 0===a||a,u.nameKeyword=null!==(i=e.nameKeyword)&&void 0!==i?i:null,u.urlKeyword=null!==(s=e.urlKeyword)&&void 0!==s?s:null,u.customTypes=null!==(o=e.customTypes)&&void 0!==o?o:null,u}return n(s,r),s.prototype._validate=function(){return r.prototype._validate.call(this)&&i("boolean",this.includeFrozen)&&i("boolean",this.includeMetaData)&&i("string",this.nameKeyword,!0)&&i("string",this.urlKeyword,!0)&&a("string",this.customTypes,!0)},s.prototype.next=function(){return e(this,void 0,void 0,(function(){var n,e,r,a,i,s;return t(this,(function(t){switch(t.label){case 0:return this._validate()?this._isLoading?[3,4]:this._hasNext?(this._isLoading=!0,n=M.of(this._iid).requestQueue,e=new En(H(H({},this),{token:this._token})),[4,n.send(e)]):[3,3]:[3,6];case 1:return r=t.sent(),a=r.as(wn),i=a.channels,s=a.token,this._token=s,this._hasNext=!!s,[4,dn.of(this._iid).upsertChannelsToCache(i)];case 2:return t.sent(),this._isLoading=!1,[2,i];case 3:return[2,[]];case 4:throw N.queryInProgress;case 5:return[3,7];case 6:throw N.invalidParameters;case 7:return[2]}}))}))},s}(x),Nn=function(r){function a(){var n=null!==r&&r.apply(this,arguments)||this;return n.name="openChannel",n}return n(a,r),a.prototype.init=function(n,e){var t=e.sdkState,a=e.dispatcher,i=e.sessionManager,s=e.requestQueue,o=e.logger,u=e.onlineDetector,c=e.cacheContext;r.prototype.init.call(this,n,{sdkState:t,dispatcher:a,sessionManager:i,requestQueue:s,logger:o,onlineDetector:u,cacheContext:c}),this._manager=new dn(n,{sdkState:t,dispatcher:a,requestQueue:s})},a.prototype.createOpenChannelListQuery=function(n){return void 0===n&&(n={}),new Tn(this._iid,n)},a.prototype.addOpenChannelHandler=function(n,e){this._manager.addHandler(n,e)},a.prototype.removeOpenChannelHandler=function(n){this._manager.removeHandler(n)},a.prototype.removeAllOpenChannelHandlers=function(){this._manager.clearHandler()},a.prototype.buildOpenChannelFromSerializedData=function(n){return this._manager.buildOpenChannelFromSerializedData(n)},a.prototype.getChannel=function(n){return e(this,void 0,void 0,(function(){return t(this,(function(e){return[2,this._manager.getChannel(n)]}))}))},a.prototype.getChannelWithoutCache=function(n){return e(this,void 0,void 0,(function(){return t(this,(function(e){return[2,this._manager.getChannelWithoutCache(n)]}))}))},a.prototype.createChannel=function(n){return void 0===n&&(n={}),e(this,void 0,void 0,(function(){return t(this,(function(e){return[2,this._manager.createChannel(n)]}))}))},a.prototype.createChannelWithOperatorUserIds=function(n,r,a,i,s){return e(this,void 0,void 0,(function(){var e;return t(this,(function(t){return(e=H({},tn)).name=n,e.coverUrlOrImage=r,e.data=a,e.operatorUserIds=i,e.customType=s,[2,this._manager.createChannel(e)]}))}))},a}(A);export{gn as OpenChannel,Un as OpenChannelHandler,Tn as OpenChannelListQuery,Nn as OpenChannelModule,vn as ParticipantListQuery}; +import{_ as n,j as e,k as t,I as r,T as a,i,q as s,A as o,b3 as u,b4 as c,b as l,c as h,e as d,an as p,U as f,W as C,H as v,J as _,z as y,a8 as m,ax as g,a9 as U,C as E,aU as w,u as T,S as N,l as b,n as H,V as M,aT as I,y as O,r as D,X as x,o as A}from"./__bundle-1abffbb6.js";import{j as P,k as L,l as R,n as k,m as F,o as S,p as q,D as Q,q as z,r as K,t as W,e as j}from"./__bundle-329965e1.js";import{a as G,O as B,C as X,M as V,T as Z,R as J,U as Y,A as $,B as nn}from"./__bundle-cd7e480a.js";var en=function(r){function a(){var n=null!==r&&r.apply(this,arguments)||this;return n._channels=new Map,n._enteredChannelUrls=[],n}return n(a,r),Object.defineProperty(a.prototype,"enteredChannels",{get:function(){var n=this;return this._enteredChannelUrls.map((function(e){return n._channels.get(e)})).filter((function(n){return null!==n}))},enumerable:!1,configurable:!0}),a.prototype.isEnteredChannel=function(n){return this._enteredChannelUrls.includes(n)},a.prototype.enter=function(n){this._enteredChannelUrls.indexOf(n)<0&&this._enteredChannelUrls.push(n)},a.prototype.exit=function(n){var e=this._enteredChannelUrls.indexOf(n);e>=0&&this._enteredChannelUrls.splice(e,1)},a.prototype.exitAll=function(){this._enteredChannelUrls=[]},a.prototype.get=function(n){var r;return e(this,void 0,void 0,(function(){return t(this,(function(e){return[2,null!==(r=this._channels.get(n))&&void 0!==r?r:null]}))}))},a.prototype.upsert=function(n){return e(this,void 0,void 0,(function(){var e=this;return t(this,(function(t){return n.forEach((function(n){if(e._channels.has(n.url)){var t=e._channels.get(n.url);Object.assign(t,n)}else e._channels.set(n.url,n)})),[2]}))}))},a.prototype.remove=function(n){return e(this,void 0,void 0,(function(){return t(this,(function(e){return this._channels.delete(n),this.exit(n),[2]}))}))},a.prototype.clear=function(){return e(this,void 0,void 0,(function(){return t(this,(function(n){return this._channels.clear(),this._enteredChannelUrls=[],[2]}))}))},a}(r),tn={channelUrl:null,name:null,coverUrlOrImage:null,data:null,customType:null,operatorUserIds:null},rn=function(e){function t(n){var t=n.channelUrl,r=n.isInternalCall,a=e.call(this)||this;return a.method=o.GET,a.path="".concat(r?u:c,"/").concat(encodeURIComponent(t)),a}return n(t,e),t}(l),an=function(e){function t(n,t){var r=e.call(this,n,t)||this;return r.channel=null,r.channel=new gn(n,t),r}return n(t,e),t}(h),sn=function(e){function t(n){var t=this,r=n.channelUrl,a=n.coverUrlOrImage,u=n.name,l=n.data,h=n.customType,p=n.operatorUserIds;return(t=e.call(this)||this).method=o.POST,t.path=c,t.params=d({channel_url:r,cover_url:i("string",a)?a:null,cover_file:s(a)?a:null,name:u,data:l,custom_type:h,operators:p}),t}return n(t,e),t}(l);!function(e){function t(n,t){var r=e.call(this,n,t)||this;return r.channel=new gn(n,t),r}n(t,e)}(h);var on=function(e){function t(n){var t=n.channelUrl;return e.call(this,{code:"ENTR",payload:{channel_url:t},ackRequired:!0})||this}return n(t,e),t}(p),un=function(e){function t(n,t,r){var a,i,s=this;return s=e.call(this,n,"ENTR",r)||this,r.data&&(s.participantCount=null!==(a=r.data.participant_count)&&void 0!==a?a:0,s.user=new f(n,r.data),s.ts=null!==(i=r.data.edge_ts)&&void 0!==i?i:0),s}return n(t,e),t}(C),cn=function(e){function t(n){var t=n.channelUrl;return e.call(this,{code:"EXIT",payload:{channel_url:t},ackRequired:!0})||this}return n(t,e),t}(p),ln=function(e){function t(n,t,r){var a,i,s=this;return s=e.call(this,n,"EXIT",r)||this,r.data&&(s.participantCount=null!==(a=r.data.participant_count)&&void 0!==a?a:0,s.user=new f(n,r.data),s.ts=null!==(i=r.data.edge_ts)&&void 0!==i?i:0),s}return n(t,e),t}(C),hn={},dn=function(){function n(n,e){var t=e.sdkState,r=e.dispatcher,a=e.requestQueue,i=this;this._sdkState=t,this._requestQueue=a,this._dispatcher=r,this._openChannelCache=new en(n),this._openChannelHandlers=new Map,this._dispatcher.on((function(n){var e,t;if(n instanceof C)i._handleEvent(n);else if(n instanceof v&&n.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(n){e={error:n}}finally{try{s&&!s.done&&(t=a.return)&&t.call(a)}finally{if(e)throw e.error}}}})),hn[n]=this}return n.of=function(n){return hn[n]},n.prototype.buildOpenChannelFromSerializedData=function(n){var e=m(n);return new gn(e._iid,gn.payloadify(e))},n.prototype.getChannelFromCache=function(n){return e(this,void 0,void 0,(function(){return t(this,(function(e){switch(e.label){case 0:return[4,this._openChannelCache.get(n)];case 1:return[2,e.sent()]}}))}))},n.prototype.upsertChannelsToCache=function(n){return e(this,void 0,void 0,(function(){return t(this,(function(e){switch(e.label){case 0:return[4,this._openChannelCache.upsert(n)];case 1:return e.sent(),[2]}}))}))},n.prototype.removeChannelsFromCache=function(n){return e(this,void 0,void 0,(function(){var e,r,a,i,s,o;return t(this,(function(t){switch(t.label){case 0:t.trys.push([0,5,6,7]),e=y(n),r=e.next(),t.label=1;case 1:return r.done?[3,4]:(a=r.value,[4,this._openChannelCache.remove(a)]);case 2:t.sent(),t.label=3;case 3:return r=e.next(),[3,1];case 4:return[3,7];case 5:return i=t.sent(),s={error:i},[3,7];case 6:try{r&&!r.done&&(o=e.return)&&o.call(e)}finally{if(s)throw s.error}return[7];case 7:return[2]}}))}))},n.prototype.setEnteredToCache=function(n){this._openChannelCache.enter(n.url)},n.prototype.setExitedToCache=function(n){this._openChannelCache.exit(n.url)},n.prototype._handleEvent=function(n){return e(this,void 0,void 0,(function(){var r,a,i,s,o,u,c,l,h,d,p,f,C,v,_,m,T,N,b,H,M,I,O,D,x,A,j,nn,en,tn,rn,an,sn,on,cn,hn,dn,pn,fn,Cn,vn,_n,yn,mn,gn,Un,En,wn,Tn,Nn,bn,Hn,Mn,In,On,Dn,xn,An,Pn,Ln=this;return t(this,(function(Rn){switch(Rn.label){case 0:switch(Rn.trys.push([0,51,,52]),n.code){case"MESG":case"FILE":case"ADMM":case"BRDM":return[3,1];case"MEDI":case"FEDI":case"AEDI":return[3,4];case"DELM":return[3,7];case"MRCT":return[3,10];case"MTHD":return[3,13];case"MCNT":return[3,16];case"SYEV":return[3,27]}return[3,50];case 1:return s=null,"MESG"===n.code?s=n.as(W):"FILE"===n.code?s=n.as(w):"ADMM"!==n.code&&"BRDM"!=n.code||(s=n.as($)),s?(r=s.message,a=s.isMentioned,r.channelType!==E.OPEN?[3,3]:[4,this.getChannel(r.channelUrl,!0)]):[3,3];case 2:i=Rn.sent(),U((function(){return e(Ln,void 0,void 0,(function(){var n,e,s,o,u;return t(this,(function(t){try{for(n=y(this._openChannelHandlers.values()),e=n.next();!e.done;e=n.next())s=e.value,this._openChannelCache.isEnteredChannel(i.url)&&s.onMessageReceived(i,r),a&&s.onMentionReceived(i,r)}catch(n){o={error:n}}finally{try{e&&!e.done&&(u=n.return)&&u.call(n)}finally{if(o)throw o.error}}return[2]}))}))})),Rn.label=3;case 3:return[3,50];case 4:return s=null,"MEDI"===n.code?s=n.as(z):"FEDI"===n.code?s=n.as(K):"AEDI"===n.code&&(s=n.as(Y)),s?(o=s.message).channelType!==E.OPEN?[3,6]:[4,this.getChannel(o.channelUrl,!0)]:[3,6];case 5:u=Rn.sent(),U((function(){return e(Ln,void 0,void 0,(function(){var n,e,r,a,i;return t(this,(function(t){try{for(n=y(this._openChannelHandlers.values()),e=n.next();!e.done;e=n.next())r=e.value,this._openChannelCache.isEnteredChannel(u.url)&&r.onMessageUpdated(u,o)}catch(n){a={error:n}}finally{try{e&&!e.done&&(i=n.return)&&i.call(n)}finally{if(a)throw a.error}}return[2]}))}))})),Rn.label=6;case 6:return[3,50];case 7:return c=n.as(Q),M=c.channelUrl,p=c.channelType,l=c.messageId,p!==E.OPEN?[3,9]:[4,this.getChannel(M,!0)];case 8:h=Rn.sent(),U((function(){return e(Ln,void 0,void 0,(function(){var n,e,r,a,i;return t(this,(function(t){try{for(n=y(this._openChannelHandlers.values()),e=n.next();!e.done;e=n.next())r=e.value,this._openChannelCache.isEnteredChannel(h.url)&&r.onMessageDeleted(h,l)}catch(n){a={error:n}}finally{try{e&&!e.done&&(i=n.return)&&i.call(n)}finally{if(a)throw a.error}}return[2]}))}))})),Rn.label=9;case 9:return[3,50];case 10:return d=n.as(J),M=d.channelUrl,p=d.channelType,f=d.event,p!==E.OPEN?[3,12]:[4,this.getChannel(M,!0)];case 11:C=Rn.sent(),U((function(){return e(Ln,void 0,void 0,(function(){var n,e,r,a;return t(this,(function(t){try{for(n=y(this._openChannelHandlers.values()),e=n.next();!e.done;e=n.next())e.value.onReactionUpdated(C,f)}catch(n){r={error:n}}finally{try{e&&!e.done&&(a=n.return)&&a.call(n)}finally{if(r)throw r.error}}return[2]}))}))})),Rn.label=12;case 12:return[3,50];case 13:return(v=n.as(Z).event).channelType!==E.OPEN?[3,15]:[4,this.getChannel(v.channelUrl,!0)];case 14:_=Rn.sent(),U((function(){return e(Ln,void 0,void 0,(function(){var n,e,r,a;return t(this,(function(t){try{for(n=y(this._openChannelHandlers.values()),e=n.next();!e.done;e=n.next())e.value.onThreadInfoUpdated(_,v)}catch(n){r={error:n}}finally{try{e&&!e.done&&(a=n.return)&&a.call(n)}finally{if(r)throw r.error}}return[2]}))}))})),Rn.label=15;case 15:return[3,50];case 16:m=n.as(V).openChannelMemberCounts,T=[],Rn.label=17;case 17:Rn.trys.push([17,22,23,24]),N=y(m),b=N.next(),Rn.label=18;case 18:return b.done?[3,21]:(H=b.value,M=H.channelUrl,an=H.participantCount,I=H.updatedAt,[4,this.getChannelFromCache(M)]);case 19:(O=Rn.sent())&&O._updateParticipantCount(an,I)&&T.push(O),Rn.label=20;case 20:return b=N.next(),[3,18];case 21:return[3,24];case 22:return D=Rn.sent(),An={error:D},[3,24];case 23:try{b&&!b.done&&(Pn=N.return)&&Pn.call(N)}finally{if(An)throw An.error}return[7];case 24:return T.length>0?[4,this.upsertChannelsToCache(T)]:[3,26];case 25:Rn.sent(),U((function(){return e(Ln,void 0,void 0,(function(){var n,e,r,a;return t(this,(function(t){try{for(n=y(this._openChannelHandlers.values()),e=n.next();!e.done;e=n.next())e.value.onChannelMemberCountChanged(T)}catch(n){r={error:n}}finally{try{e&&!e.done&&(a=n.return)&&a.call(n)}finally{if(r)throw r.error}}return[2]}))}))})),Rn.label=26;case 26:return[3,50];case 27:if(!(x=n.as(X).event).isOpenChannelEvent)return[3,49];switch(x.category){case G.CHANNEL_ENTER:return[3,28];case G.CHANNEL_EXIT:return[3,30];case G.CHANNEL_OPERATOR_UPDATE:return[3,32];case G.USER_CHANNEL_MUTE:case G.USER_CHANNEL_UNMUTE:return[3,34];case G.USER_CHANNEL_BAN:case G.USER_CHANNEL_UNBAN:return[3,36];case G.CHANNEL_FREEZE:case G.CHANNEL_UNFREEZE:return[3,38];case G.CHANNEL_DELETED:return[3,40];case G.CHANNEL_PROP_CHANGED:return[3,43];case G.CHANNEL_META_DATA_CHANGED:return[3,45];case G.CHANNEL_META_COUNTERS_CHANGED:return[3,47]}return[3,49];case 28:return[4,this.getChannel(x.channelUrl,!0)];case 29:return A=Rn.sent(),j=n.as(un),an=j.participantCount,nn=j.user,en=A._updateParticipantCount(an,x.ts),U((function(){return e(Ln,void 0,void 0,(function(){return t(this,(function(n){return this._openChannelHandlers.forEach((function(n){n.onUserEntered(A,nn),en&&n.onChannelParticipantCountChanged(A)})),[2]}))}))})),[3,49];case 30:return[4,this.getChannel(x.channelUrl,!0)];case 31:return tn=Rn.sent(),rn=n.as(ln),an=rn.participantCount,sn=rn.user,on=tn._updateParticipantCount(an,x.ts),U((function(){return e(Ln,void 0,void 0,(function(){return t(this,(function(n){return this._openChannelHandlers.forEach((function(n){n.onUserExited(tn,sn),on&&n.onChannelParticipantCountChanged(tn)})),[2]}))}))})),[3,49];case 32:return[4,this.getChannel(x.channelUrl,!0)];case 33:return cn=Rn.sent(),hn=n.as(B).operators,cn.operators=hn,this.upsertChannelsToCache([cn]),U((function(){return e(Ln,void 0,void 0,(function(){return t(this,(function(n){return this._openChannelHandlers.forEach((function(n){n.onOperatorUpdated(cn,hn)})),[2]}))}))})),[3,49];case 34:return[4,this.getChannel(x.channelUrl,!0)];case 35:return dn=Rn.sent(),pn=x.category===G.USER_CHANNEL_MUTE,fn=n.as(pn?S:q).user,U((function(){return e(Ln,void 0,void 0,(function(){return t(this,(function(n){return this._openChannelHandlers.forEach((function(n){pn?n.onUserMuted(dn,fn):n.onUserUnmuted(dn,fn)})),[2]}))}))})),[3,49];case 36:return[4,this.getChannel(x.channelUrl,!0)];case 37:return Cn=Rn.sent(),vn=x.category===G.USER_CHANNEL_BAN,_n=n.as(vn?k:F).user,U((function(){return e(Ln,void 0,void 0,(function(){return t(this,(function(n){return this._openChannelHandlers.forEach((function(n){vn?n.onUserBanned(Cn,_n):n.onUserUnbanned(Cn,_n)})),[2]}))}))})),[3,49];case 38:return[4,this.getChannel(x.channelUrl,!0)];case 39:return yn=Rn.sent(),mn=n.as(R).freeze,yn.isFrozen=mn,this.upsertChannelsToCache([yn]),U((function(){return e(Ln,void 0,void 0,(function(){return t(this,(function(n){return this._openChannelHandlers.forEach((function(n){mn?n.onChannelFrozen(yn):n.onChannelUnfrozen(yn)})),[2]}))}))})),[3,49];case 40:return[4,this.getChannel(x.channelUrl,!0)];case 41:return gn=Rn.sent(),[4,this.removeChannelsFromCache([gn.url])];case 42:return Rn.sent(),U((function(){return e(Ln,void 0,void 0,(function(){return t(this,(function(n){return this._openChannelHandlers.forEach((function(n){n.onChannelDeleted(gn.url,gn.channelType)})),[2]}))}))})),[3,49];case 43:return[4,this.getChannelWithoutCache(x.channelUrl,!0)];case 44:return Un=Rn.sent(),U((function(){return e(Ln,void 0,void 0,(function(){return t(this,(function(n){return this._openChannelHandlers.forEach((function(n){n.onChannelChanged(Un)})),[2]}))}))})),[3,49];case 45:return[4,this.getChannel(x.channelUrl,!0)];case 46:return En=Rn.sent(),wn=n.as(L),Tn=wn.created,Nn=wn.updated,bn=wn.deleted,Tn&&En._upsertCachedMetaData(Tn,x.ts),Nn&&En._upsertCachedMetaData(Nn,x.ts),bn&&En._removeFromCachedMetaData(bn,x.ts),U((function(){return e(Ln,void 0,void 0,(function(){return t(this,(function(n){return this._openChannelHandlers.forEach((function(n){Tn&&n.onMetaDataCreated(En,Tn),Nn&&n.onMetaDataUpdated(En,Nn),bn&&n.onMetaDataDeleted(En,bn)})),[2]}))}))})),[3,49];case 47:return[4,this.getChannel(x.channelUrl,!0)];case 48:return Hn=Rn.sent(),Mn=n.as(P),In=Mn.created,On=Mn.updated,Dn=Mn.deleted,U((function(){return e(Ln,void 0,void 0,(function(){return t(this,(function(n){return this._openChannelHandlers.forEach((function(n){In&&n.onMetaCounterCreated(Hn,In),On&&n.onMetaCounterUpdated(Hn,On),Dn&&n.onMetaCounterDeleted(Hn,Dn)})),[2]}))}))})),[3,49];case 49:return[3,50];case 50:return[3,52];case 51:if(xn=Rn.sent(),g(xn))throw xn;return[3,52];case 52:return[2]}}))}))},n.prototype.addHandler=function(n,e){this._openChannelHandlers.set(n,e)},n.prototype.removeHandler=function(n){this._openChannelHandlers.delete(n)},n.prototype.clearHandler=function(){this._openChannelHandlers.clear()},n.prototype.getChannel=function(n,r){return e(this,void 0,void 0,(function(){var e;return t(this,(function(t){switch(t.label){case 0:T(i("string",n)).throw(N.invalidParameters),t.label=1;case 1:return t.trys.push([1,3,,4]),[4,this.getChannelFromCache(n)];case 2:return(e=t.sent())?[2,e]:[3,4];case 3:return t.sent(),[3,4];case 4:return[4,this.getChannelWithoutCache(n)];case 5:return[2,t.sent()]}}))}))},n.prototype.getChannelWithoutCache=function(n,r){return void 0===r&&(r=!1),e(this,void 0,void 0,(function(){var e,a,s;return t(this,(function(t){switch(t.label){case 0:return T(i("string",n)).throw(N.invalidParameters),e=new rn({channelUrl:n,isInternalCall:r}),[4,this._requestQueue.send(e)];case 1:return a=t.sent(),s=a.as(an).channel,[4,this.upsertChannelsToCache([s])];case 2:return t.sent(),[2,s]}}))}))},n.prototype.createChannel=function(n){return e(this,void 0,void 0,(function(){var e,r,o,u;return t(this,(function(t){switch(t.label){case 0:return e=b(b({},tn),n),T(function(n){return a("string",n.operatorUserIds,!0)&&(i("string",n.coverUrlOrImage)||s(n.coverUrlOrImage)||null===n.coverUrlOrImage)&&i("string",n.name,!0)&&i("string",n.data,!0)&&i("string",n.customType,!0)&&(i("string",n.channelUrl)&&/^\w+$/.test(n.channelUrl)||null===n.channelUrl)}(e)).throw(N.invalidParameters),r=new sn(e),[4,this._requestQueue.send(r)];case 1:return o=t.sent(),u=o.as(an).channel,this.upsertChannelsToCache([u]),[2,u]}}))}))},n}(),pn={name:null,coverUrlOrImage:null,data:null,customType:null,operatorUserIds:null},fn=function(e){function t(n){var t=this,r=n.channelUrl,a=n.token,i=n.limit;return(t=e.call(this)||this).method=o.GET,t.path="".concat(c,"/").concat(encodeURIComponent(r),"/participants"),t.params={token:a,limit:i},t}return n(t,e),t}(l),Cn=function(e){function t(n,t){var r=e.call(this,n,t)||this;r.token=null,r.participants=[];var a=t.next,i=t.participants;return r.token=a,r.participants=i.map((function(e){return new f(n,e)})),r}return n(t,e),t}(h),vn=function(r){function a(n,e,t){return r.call(this,n,e,E.OPEN,t)||this}return n(a,r),a.prototype._validate=function(){return r.prototype._validate.call(this)},a.prototype.next=function(){return e(this,void 0,void 0,(function(){var n,e,r,a,i,s;return t(this,(function(t){switch(t.label){case 0:return this._validate()?this._isLoading?[3,3]:this._hasNext?(this._isLoading=!0,n=M.of(this._iid).requestQueue,e=new fn(b(b({},this),{token:this._token})),[4,n.send(e)]):[3,2]:[3,5];case 1:return r=t.sent(),a=r.as(Cn),i=a.participants,s=a.token,this._token=s,this._hasNext=!!s,this._isLoading=!1,[2,i];case 2:return[2,[]];case 3:throw N.queryInProgress;case 4:return[3,6];case 5:throw N.invalidParameters;case 6:return[2]}}))}))},a}(H),_n=function(e){function t(n){var t=this,r=n.channelUrl,a=n.coverUrlOrImage,u=n.name,l=n.data,h=n.customType,p=n.operatorUserIds;return(t=e.call(this)||this).method=o.PUT,t.path="".concat(c,"/").concat(encodeURIComponent(r)),t.params=d({cover_url:i("string",a)?a:null,cover_file:s(a)?a:null,name:u,data:l,custom_type:h,operators:p}),t}return n(t,e),t}(l),yn=function(e){function t(n,t){var r=e.call(this,n,t)||this;return r.channel=new gn(n,t),r}return n(t,e),t}(h),mn=function(e){function t(n){var t=this,r=n.channelUrl;return(t=e.call(this)||this).method=o.DELETE,t.path="".concat(c,"/").concat(encodeURIComponent(r)),t}return n(t,e),t}(l);!function(e){function t(n,t){return e.call(this,n,t)||this}n(t,e)}(h);var gn=function(r){function o(n,e){var t,a=this;return(a=r.call(this,n,e)||this)._lastParticipantCountUpdated=0,a.participantCount=0,a.operators=[],a.channelType=E.OPEN,a.participantCount=null!==(t=e.participant_count)&&void 0!==t?t:0,a.operators=Array.isArray(e.operators)?e.operators.map((function(e){return new f(n,e)})):[],a}return n(o,r),o.payloadify=function(n){return n?d(b(b({},j.payloadify(n)),{participant_count:n.participantCount,operators:n.operators.map((function(n){return f.payloadify(n)}))})):null},o.prototype.serialize=function(){return I(this)},o.prototype.isOperator=function(n){return n instanceof f?this.isOperator(n.userId):this.operators.some((function(e){return e.userId===n}))},o.prototype._updateParticipantCount=function(n,e){return e>this._lastParticipantCountUpdated&&(this.participantCount=n,this._lastParticipantCountUpdated=e,!0)},o.prototype.createParticipantListQuery=function(n){return new vn(this._iid,this.url,n)},o.prototype.refresh=function(){return e(this,void 0,void 0,(function(){return t(this,(function(n){switch(n.label){case 0:return[4,dn.of(this._iid).getChannelWithoutCache(this.url)];case 1:return[2,n.sent()]}}))}))},o.prototype.enter=function(){return e(this,void 0,void 0,(function(){var n,e,r,a,i,s;return t(this,(function(t){switch(t.label){case 0:return n=M.of(this._iid).requestQueue,e=new on({channelUrl:this.url}),[4,n.send(e)];case 1:return r=t.sent(),a=r.as(un),i=a.participantCount,s=a.ts,this._updateParticipantCount(i,s),dn.of(this._iid).setEnteredToCache(this),[2]}}))}))},o.prototype.exit=function(){return e(this,void 0,void 0,(function(){var n,e,r,a,i,s;return t(this,(function(t){switch(t.label){case 0:return n=M.of(this._iid).requestQueue,e=new cn({channelUrl:this.url}),[4,n.send(e)];case 1:return r=t.sent(),a=r.as(ln),i=a.participantCount,s=a.ts,this._updateParticipantCount(i,s),dn.of(this._iid).setExitedToCache(this),O.of(this._iid).fileMessageQueue.cancel(this),[2]}}))}))},o.prototype.updateChannel=function(n){return e(this,void 0,void 0,(function(){var e,r,o,u,c;return t(this,(function(t){switch(t.label){case 0:return e=b(b({},pn),n),T(function(n){return a("string",n.operatorUserIds,!0)&&(i("string",n.coverUrlOrImage)||s(n.coverUrlOrImage)||null===n.coverUrlOrImage)&&i("string",n.name,!0)&&i("string",n.data,!0)&&i("string",n.customType,!0)}(e)).throw(N.invalidParameters),r=M.of(this._iid).requestQueue,o=new _n(b({channelUrl:this.url},e)),[4,r.send(o)];case 1:return u=t.sent(),c=u.as(yn).channel,[4,dn.of(this._iid).upsertChannelsToCache([c])];case 2:return t.sent(),[2,c]}}))}))},o.prototype.updateChannelWithOperatorUserIds=function(n,r,a,i,s){return e(this,void 0,void 0,(function(){var e;return t(this,(function(t){return e=b(b({},pn),{name:n,coverUrlOrImage:r,data:a,operatorUserIds:i,customType:s}),[2,this.updateChannel(e)]}))}))},o.prototype.delete=function(){return e(this,void 0,void 0,(function(){var n,e;return t(this,(function(t){switch(t.label){case 0:return n=M.of(this._iid).requestQueue,e=new mn({channelUrl:this.url}),[4,n.send(e)];case 1:return t.sent(),[4,dn.of(this._iid).removeChannelsFromCache([this.url])];case 2:return t.sent(),[2]}}))}))},o}(j),Un=function(e){function t(n){void 0===n&&(n={});var t=e.call(this)||this;return Object.keys(n).forEach((function(e){t.hasOwnProperty(e)&&(t[e]=n[e])})),t}return n(t,e),t}(function(e){function t(){var n=null!==e&&e.apply(this,arguments)||this;return n.onUserEntered=D,n.onUserExited=D,n.onChannelParticipantCountChanged=D,n}return n(t,e),t}(nn)),En=function(e){function t(n){var t=this,r=n.token,a=n.limit,i=n.nameKeyword,s=n.urlKeyword,u=n.customTypes,l=n.includeFrozen,h=n.includeMetaData;return(t=e.call(this)||this).method=o.GET,t.path=c,t.params=d({token:r,limit:a,name_contains:i,url_contains:s,custom_types:u,show_frozen:l,show_metadata:h}),t}return n(t,e),t}(l),wn=function(e){function t(n,t){var r=e.call(this,n,t)||this;r.token=null,r.channels=[],r.ts=null;var a=t.next,i=t.channels,s=t.ts;return r.token=a,i&&i.length>0&&(r.channels=i.map((function(e){return new gn(n,e)}))),r.ts="number"==typeof s?s:null,r}return n(t,e),t}(h),Tn=function(r){function s(n,e){var t,a,i,s,o,u=this;return(u=r.call(this,n,e)||this).includeFrozen=!0,u.includeMetaData=!0,u.nameKeyword=null,u.urlKeyword=null,u.customTypes=null,u.includeFrozen=null===(t=e.includeFrozen)||void 0===t||t,u.includeMetaData=null===(a=e.includeMetaData)||void 0===a||a,u.nameKeyword=null!==(i=e.nameKeyword)&&void 0!==i?i:null,u.urlKeyword=null!==(s=e.urlKeyword)&&void 0!==s?s:null,u.customTypes=null!==(o=e.customTypes)&&void 0!==o?o:null,u}return n(s,r),s.prototype._validate=function(){return r.prototype._validate.call(this)&&i("boolean",this.includeFrozen)&&i("boolean",this.includeMetaData)&&i("string",this.nameKeyword,!0)&&i("string",this.urlKeyword,!0)&&a("string",this.customTypes,!0)},s.prototype.next=function(){return e(this,void 0,void 0,(function(){var n,e,r,a,i,s;return t(this,(function(t){switch(t.label){case 0:return this._validate()?this._isLoading?[3,4]:this._hasNext?(this._isLoading=!0,n=M.of(this._iid).requestQueue,e=new En(b(b({},this),{token:this._token})),[4,n.send(e)]):[3,3]:[3,6];case 1:return r=t.sent(),a=r.as(wn),i=a.channels,s=a.token,this._token=s,this._hasNext=!!s,[4,dn.of(this._iid).upsertChannelsToCache(i)];case 2:return t.sent(),this._isLoading=!1,[2,i];case 3:return[2,[]];case 4:throw N.queryInProgress;case 5:return[3,7];case 6:throw N.invalidParameters;case 7:return[2]}}))}))},s}(x),Nn=function(r){function a(){var n=null!==r&&r.apply(this,arguments)||this;return n.name="openChannel",n}return n(a,r),a.prototype.init=function(n,e){var t=e.sdkState,a=e.dispatcher,i=e.sessionManager,s=e.requestQueue,o=e.logger,u=e.onlineDetector,c=e.cacheContext;r.prototype.init.call(this,n,{sdkState:t,dispatcher:a,sessionManager:i,requestQueue:s,logger:o,onlineDetector:u,cacheContext:c}),this._manager=new dn(n,{sdkState:t,dispatcher:a,requestQueue:s})},a.prototype.createOpenChannelListQuery=function(n){return void 0===n&&(n={}),new Tn(this._iid,n)},a.prototype.addOpenChannelHandler=function(n,e){this._manager.addHandler(n,e)},a.prototype.removeOpenChannelHandler=function(n){this._manager.removeHandler(n)},a.prototype.removeAllOpenChannelHandlers=function(){this._manager.clearHandler()},a.prototype.buildOpenChannelFromSerializedData=function(n){return this._manager.buildOpenChannelFromSerializedData(n)},a.prototype.getChannel=function(n){return e(this,void 0,void 0,(function(){return t(this,(function(e){return[2,this._manager.getChannel(n)]}))}))},a.prototype.getChannelWithoutCache=function(n){return e(this,void 0,void 0,(function(){return t(this,(function(e){return[2,this._manager.getChannelWithoutCache(n)]}))}))},a.prototype.createChannel=function(n){return void 0===n&&(n={}),e(this,void 0,void 0,(function(){return t(this,(function(e){return[2,this._manager.createChannel(n)]}))}))},a.prototype.createChannelWithOperatorUserIds=function(n,r,a,i,s){return e(this,void 0,void 0,(function(){var e;return t(this,(function(t){return(e=b({},tn)).name=n,e.coverUrlOrImage=r,e.data=a,e.operatorUserIds=i,e.customType=s,[2,this._manager.createChannel(e)]}))}))},a}(A);export{gn as OpenChannel,Un as OpenChannelHandler,Tn as OpenChannelListQuery,Nn as OpenChannelModule,vn as ParticipantListQuery}; diff --git a/package.json b/package.json index 28c2044..cb1bcf7 100644 --- a/package.json +++ b/package.json @@ -1,5 +1,5 @@ { - "version": "4.1.2", + "version": "4.1.3", "description": "Sendbird SDK for JavaScript", "name": "@sendbird/chat", "author": "Sendbird ", diff --git a/poll.js b/poll.js index 8c40932..521ec53 100644 --- a/poll.js +++ b/poll.js @@ -1 +1 @@ -export{P as Poll,d as PollOption,p as PollStatus}from"./__bundle-0a632c33.js";export{m as PollListQuery,t as PollModule,P as PollUpdateEvent,b as PollVoteEvent,n as PollVoterListQuery}from"./__bundle-0bd37fbb.js";import"./__bundle-c7363281.js"; +export{P as Poll,d as PollOption,p as PollStatus}from"./__bundle-1abffbb6.js";export{m as PollListQuery,t as PollModule,P as PollUpdateEvent,b as PollVoteEvent,n as PollVoterListQuery}from"./__bundle-3b6b9d30.js";import"./__bundle-329965e1.js"; diff --git a/sendbird.js b/sendbird.js index 43acea1..a0c0356 100644 --- a/sendbird.js +++ b/sendbird.js @@ -1 +1 @@ -export{C as ChannelType,a6 as ConnectionState,ad as LogLevel,ae as Plugin,af as Role,a1 as SendbirdChatOptions,S as SendbirdError,U as User,ag as UserOnlineState}from"./__bundle-0a632c33.js";export{w as ApplicationUserListQuery,B as BlockedUserListQuery,C as ConnectionHandler,E as Emoji,x as EmojiCategory,y as EmojiContainer,F as FriendListQuery,z as MemoryStore,H as PushTemplate,I as PushTokenRegistrationState,J as PushTokenType,o as PushTriggerOption,K as SessionHandler,L as UserEventHandler,u as default}from"./__bundle-0bd37fbb.js";export{d as BannedUserListQuery,e as BaseChannel,M as MutedUserListQuery,O as OperatorListQuery,R as ReportCategory,f as RestrictedUser,g as RestrictionInfo,h as RestrictionType}from"./__bundle-c7363281.js"; +export{C as ChannelType,a6 as ConnectionState,ad as LogLevel,ae as Plugin,af as Role,a1 as SendbirdChatOptions,S as SendbirdError,U as User,ag as UserOnlineState}from"./__bundle-1abffbb6.js";export{w as ApplicationUserListQuery,B as BlockedUserListQuery,C as ConnectionHandler,E as Emoji,x as EmojiCategory,y as EmojiContainer,F as FriendListQuery,z as MemoryStore,H as PushTemplate,I as PushTokenRegistrationState,J as PushTokenType,o as PushTriggerOption,K as SessionHandler,L as UserEventHandler,u as default}from"./__bundle-3b6b9d30.js";export{d as BannedUserListQuery,e as BaseChannel,M as MutedUserListQuery,O as OperatorListQuery,R as ReportCategory,f as RestrictedUser,g as RestrictionInfo,h as RestrictionType}from"./__bundle-329965e1.js"; diff --git a/sendbird.min.js b/sendbird.min.js index 1c5366c..936168c 100644 --- a/sendbird.min.js +++ b/sendbird.min.js @@ -1 +1 @@ -var Sendbird=function(e){"use strict";var t=function(e,n){return t=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])},t(e,n)};function n(e,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=e}t(e,n),e.prototype=null===n?Object.create(n):(r.prototype=n.prototype,new r)}var r=function(){return r=Object.assign||function(e){for(var t,n=1,r=arguments.length;n0&&i[i.length-1])||6!==s[0]&&2!==s[0])){a=0;continue}if(3===s[0]&&(!i||s[1]>i[0]&&s[1]=e.length&&(e=void 0),{value:e&&e[r++],done:!e}}};throw new TypeError(t?"Object is not iterable.":"Symbol.iterator is not defined.")}function o(e,t){var n="function"==typeof Symbol&&e[Symbol.iterator];if(!n)return e;var r,i,s=n.call(e),a=[];try{for(;(void 0===t||t-- >0)&&!(r=s.next()).done;)a.push(r.value)}catch(e){i={error:e}}finally{try{r&&!r.done&&(n=s.return)&&n.call(s)}finally{if(i)throw i.error}}return a}function u(e,t,n){if(n||2===arguments.length)for(var r,i=0,s=t.length;i0&&v.indexOf(e)>=0},T=function(e,t){if(void 0===t&&(t=!1),t&&null===e)return!0;var n=g("object",e)&&null!==e&&e.hasOwnProperty("name")&&"string"==typeof e.name&&e.hasOwnProperty("uri")&&"string"==typeof e.uri&&e.hasOwnProperty("type")&&"string"==typeof e.type;if(!n){if("undefined"!=typeof Blob)return e instanceof Blob;if("undefined"!=typeof File)return e instanceof File}return n},I=function(){function e(e){var t=void 0===e?{}:e,n=t.useMemberInfoInMessage,r=void 0===n||n,i=t.typingIndicatorInvalidateTime,s=void 0===i?1e4:i,a=t.typingIndicatorThrottle,o=void 0===a?1e3:a,u=t.websocketResponseTimeout,c=void 0===u?1e4:u;this._useMemberInfoInMessage=!0,this._typingIndicatorInvalidateTime=1e4,this._typingIndicatorThrottle=1e3,this._websocketResponseTimeout=1e4,this._useMemberInfoInMessage=r,this._typingIndicatorInvalidateTime=s,this._typingIndicatorThrottle=o,this._websocketResponseTimeout=c}return Object.defineProperty(e.prototype,"useMemberInfoInMessage",{get:function(){return this._useMemberInfoInMessage},set:function(e){g("boolean",e)&&(this._useMemberInfoInMessage=e)},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"typingIndicatorInvalidateTime",{get:function(){return this._typingIndicatorInvalidateTime},set:function(e){g("number",e)&&(this._typingIndicatorInvalidateTime=e)},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"typingIndicatorThrottle",{get:function(){return this._typingIndicatorThrottle},set:function(e){g("number",e)&&e>=1e3&&e<=9e3&&(this._typingIndicatorThrottle=e)},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"websocketResponseTimeout",{get:function(){return this._websocketResponseTimeout},set:function(e){g("number",e)&&e>=5e3&&e<=3e4&&(this._websocketResponseTimeout=e)},enumerable:!1,configurable:!0}),e}(),S={key:"__ev",value:{k:"__ev",v:"scs"},generation:1},N={encrypt:function(e){return e},decrypt:function(e){return e}},w=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 s(this,(function(e){switch(e.label){case 0:return[4,this._store.set({key:this._keysAddress,value:u([],o(this._preference.keys()),!1),generation:1})];case 1:return e.sent(),[2]}}))}))},e.prototype.init=function(e){var t;return i(this,void 0,void 0,(function(){var n,r,i,o,u,c,l,h;return s(this,(function(s){switch(s.label){case 0:return this._keysAddress=e,[4,this._store.get(e)];case 1:n=null!==(t=s.sent())&&void 0!==t?t:[],s.label=2;case 2:s.trys.push([2,7,8,9]),r=a(n),i=r.next(),s.label=3;case 3:return i.done?[3,6]:(o=i.value,[4,this._store.get(o)]);case 4:(u=s.sent())&&this._preference.set(o,u),s.label=5;case 5:return i=r.next(),[3,3];case 6:return[3,9];case 7:return c=s.sent(),l={error:c},[3,9];case 8:try{i&&!i.done&&(h=r.return)&&h.call(r)}finally{if(l)throw l.error}return[7];case 9:return[2]}}))}))},e.prototype.get=function(e){var t;return i(this,void 0,void 0,(function(){return s(this,(function(n){return[2,null!==(t=this._preference.get(e))&&void 0!==t?t:null]}))}))},e.prototype.set=function(e,t){return i(this,void 0,void 0,(function(){var n;return s(this,(function(r){switch(r.label){case 0:return n=!this._preference.has(e),[4,this._store.set({key:e,value:t,generation:1})];case 1:return r.sent(),this._preference.set(e,t),n?[4,this._savePreferenceKeys()]:[3,3];case 2:r.sent(),r.label=3;case 3:return[2]}}))}))},e.prototype.remove=function(e){return i(this,void 0,void 0,(function(){return s(this,(function(t){switch(t.label){case 0:return[4,this._store.remove(e)];case 1:return t.sent(),this._preference.delete(e),[4,this._savePreferenceKeys()];case 2:return t.sent(),[2]}}))}))},e.prototype.clear=function(){return i(this,void 0,void 0,(function(){return s(this,(function(e){switch(e.label){case 0:return[4,this._store.removeMany(u([],o(this._preference.keys()),!1))];case 1:return e.sent(),this._preference.clear(),[4,this._savePreferenceKeys()];case 2:return e.sent(),[2]}}))}))},e}(),M=function(e){var t=e.encryption,n=void 0===t?null:t,r=e.store,i=void 0===r?null:r,s=e.localCacheEnabled,a=void 0===s||s;this.nestdb=null,this.store=i,this.preference=new w({store:i}),this.encryption=null!=n?n:N,this.localCacheEnabled=a},A=function(){function e(){this.sessionKey=null,this.authToken=null}return Object.defineProperty(e.prototype,"hasSession",{get:function(){return!!this.sessionKey},enumerable:!1,configurable:!0}),e.prototype.clear=function(){this.authToken=null,this.sessionKey=null},e}(),U=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)}))},O=function(){function e(e){var t=e.container;this._container={},this._container=t,this.key=U()}return e.prototype._register=function(e,t,n){return e in this._container||(this._container[e]=new Map),this._container[e].set(this.key,{occurence:t,handler:n}),this},e.prototype.on=function(e,t){return this._register(e,-1,t)},e.prototype.once=function(e,t){return this._register(e,1,t)},e.prototype.close=function(){for(var e in this._container)this._container[e].delete(this.key)},e}(),R=function(){function e(){this._container={}}return e.prototype.on=function(e,t){return new O({container:this._container}).on(e,t)},e.prototype.once=function(e,t){return new O({container:this._container}).once(e,t)},e.prototype.dispatch=function(e,t){var n,r,i=this._container[e];if(i){var s=[];try{for(var o=a(i.keys()),u=o.next();!u.done;u=o.next()){var c=u.value,l=i.get(c);l.handler(t),l.occurence>0&&(l.occurence--,0===l.occurence&&s.push(c))}}catch(e){n={error:e}}finally{try{u&&!u.done&&(r=o.return)&&r.call(o)}finally{if(n)throw n.error}}s.forEach((function(e){return i.delete(e)}))}},e}(),L=function(){function e(){this._dispatcher=new R}return e.prototype.on=function(e){return this._dispatcher.on("event",e)},e.prototype.once=function(e){return this._dispatcher.once("event",e)},e.prototype.dispatch=function(e){this._dispatcher.dispatch("event",e)},e}(),k=function(){},D=function(e){var t={};return e&&Object.keys(e).forEach((function(n){void 0!==e[n]&&NaN!==e[n]&&null!==e[n]&&(t[n]=e[n])})),t};!function(e){e.GET="GET",e.POST="POST",e.PUT="PUT",e.DELETE="DELETE"}(d||(d={}));var P,x=function(e){function t(){var t=null!==e&&e.apply(this,arguments)||this;return t.params={},t.requireAuth=!0,t.headers={},t.requestId=U(),t}return n(t,e),t.prototype.stringifyParams=function(e){return"object"!=typeof e||Array.isArray(e)?String(e):e?JSON.stringify(e):""},t.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(t.prototype,"query",{get:function(){var e=this,t=D(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(t.prototype,"payload",{get:function(){var e=this,t=D(this.params);if(Object.keys(t).some((function(e){return T(t[e])}))){var n=new FormData;return Object.keys(t).forEach((function(r){var i,s=t[r];if(T(s)){var a=s;n.append(r,a,null!==(i=a.name)&&void 0!==i?i:"filename")}else n.append(r,e.stringifyParams(s))})),n}return JSON.stringify(t)},enumerable:!1,configurable:!0}),t}(k),F=function(e){function t(t,n){var r=e.call(this)||this;return r._iid=t,r._payload=n,r}return n(t,e),Object.defineProperty(t.prototype,"payload",{get:function(){return r({},this._payload)},enumerable:!1,configurable:!0}),t.prototype.as=function(e){return new e(this._iid,this.payload)},t}(k),q=function(e){function t(t){var n=e.call(this)||this;return n.requestId=t,n}return n(t,e),t}(k),G=function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return n(t,e),t}(k),H=function(e){function t(t){var n=e.call(this)||this;return n.statLog=t,n}return n(t,e),t}(k);!function(e){e.WEBSOCKET_CONNECT="ws:connect",e.API_RESULT="api:result"}(P||(P={}));var V,K=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 D({stat_type:e.type,ts:e.createdAt,data:D(e.data)})},e}(),Q=function(){return"undefined"==typeof document&&"undefined"!=typeof navigator&&"ReactNative"==navigator.product},B=function(){function e(e,t){var n=t.auth,r=t.sdkState,i=t.dispatcher,s=t.logger,a=this;this._abortControl=new Map,this._iid=e,this._auth=n,this._sdkState=r,this._dispatcher=i,this._dispatcher.on((function(e){e instanceof q&&a.cancel(e.requestId)})),this._logger=s}return Object.defineProperty(e.prototype,"_userAgentWithExtension",{get:function(){var e=this._sdkState.extensions,t=Q()?"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 n=this._sdkState,i=n.appId,s=n.appVersion,a=r(r({},e.headers),{SendBird:"JS,".concat(h.OS_VERSION,",").concat(h.SDK_VERSION,",").concat(i).concat(s?",".concat(s):""),"SB-User-Agent":encodeURIComponent(this._userAgentWithExtension),"Request-Sent-Timestamp":Date.now().toString()});return t||(a["Content-Type"]="application/json; charset=utf-8"),e.requireAuth&&this._auth.hasSession&&(a["Session-Key"]=this._auth.sessionKey),this._auth&&this._auth.authToken&&(a["App-Id"]=i,a["Access-Token"]=this._auth.authToken),a},e.prototype._statLogApiResult=function(e,t,n){this._dispatcher.dispatch(new H(new K({type:P.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,a,o,u,c,l,h,p,_,v,m,g;return s(this,(function(s){switch(s.label){case 0:t=e.path,n=e.method,r=![d.GET,d.DELETE].includes(n),i=this._sdkState.api,a="".concat(i.host).concat(t).concat(r?"":e.query),o=r?e.payload:null,u=this._createHeader(e,o instanceof FormData?o:null),c=new AbortController,l=c.signal,this._abortControl.set(e.requestId,c),h=Date.now(),s.label=1;case 1:return s.trys.push([1,4,,5]),[4,fetch(a,{method:n,body:o,headers:u,signal:l})];case 2:return[4,(p=s.sent()).json()];case 3:if(_=s.sent(),p.ok||p.redirected)return this._logger.debug("receive api response",e.requestId),this._statLogApiResult(e,h,null),[2,new F(this._iid,_)];throw _?(v=new f(_),!e.requireAuth&&v.isSessionKeyExpiredError&&this._dispatcher.dispatch(new G),this._statLogApiResult(e,h,v),v):(v=f.requestFailed,this._statLogApiResult(e,h,v),v);case 4:throw m=s.sent(),this._statLogApiResult(e,h,m),m instanceof f?(this._logger.debug("fail api request",m),m):"AbortError"===m.name?f.requestCanceled:(g=f.networkError,this._logger.debug("fail api request",g),g);case 5:return[2]}}))}))},e.prototype.cancel=function(e){this._abortControl.has(e)&&(this._abortControl.get(e).abort(),this._abortControl.delete(e))},e.prototype.cancelAll=function(){var e,t;try{for(var n=a(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}(),j=function(e){function t(t,n,r,i){void 0===i&&(i="");var s,a=this;return(a=e.call(this)||this)._iid=t,a.code=n,a.payload=r,a.requestId=r?null!==(s=r.req_id)&&void 0!==s?s:i:"",a}return n(t,e),t.createFromRawMessage=function(e,n){var r=n.substring(0,4),i=null;try{i=JSON.parse(n.substring(4))}catch(e){r="NOOP"}finally{return new t(e,r,i)}},t.prototype.convertToMessage=function(){return"".concat(this.code).concat(JSON.stringify(this.payload),"\n")},t.prototype.as=function(e){return new e(this._iid,this.code,this.payload)},t}(k),z=function(e){function t(t){var n,r=t.code,i=t.ackRequired,s=t.payload,a=void 0===s?null:s,o=this;return(o=e.call(this)||this).code=r,o.payload=a,o.requestId=null!==(n=o.payload.req_id)&&void 0!==n?n:U(),o.ackRequired=i,o.payload.req_id=o.requestId,o}return n(t,e),t.prototype.convertToMessage=function(){return"".concat(this.code).concat(JSON.stringify(this.payload),"\n")},t}(k),W=function(e){function t(){return e.call(this,{code:"PING",payload:{id:Date.now(),active:1},ackRequired:!1})||this}return n(t,e),t}(z),Y=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 W;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}(),J=function(){};e.ConnectionState=void 0,(V=e.ConnectionState||(e.ConnectionState={})).CONNECTING="CONNECTING",V.OPEN="OPEN",V.CLOSED="CLOSED";var X,Z=function(t){function r(e,n){var r=n.sdkState,i=n.dispatcher,s=n.logger,a=t.call(this)||this;return a._pinger=null,a.lastActive=0,a._iid=e,a._sdkState=r,a._dispatcher=i,a._logger=s,a._sdkState.websocket.pingerDisabled||(a._pinger=new Y({pingDelegate:{send:function(e){return a.send(e)},error:function(e){return a.error(e)}},sdkState:a._sdkState,logger:s})),a}return n(r,t),Object.defineProperty(r.prototype,"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},enumerable:!1,configurable:!0}),r.prototype.connect=function(e){var t=this;this._ws=new WebSocket(e),this._ws.onopen=function(){t._logger.debug("websocket open"),t.dispatch("open")},this._ws.onmessage=function(e){e.data.split("\n").forEach((function(e){if(e&&g("string",e)){var n=j.createFromRawMessage(t._iid,e);t._logger.debug("receive websocket event",n),"LOGI"===n.code?(n.payload&&!n.payload.error&&t._pinger&&t._pinger.start(),t.dispatch("message",n)):"PONG"===n.code?t._pinger&&t._pinger.pong():"EXPR"===n.code?n.payload&&n.payload.expires_in>=0&&t._dispatcher.dispatch(new G):"NOOP"===n.code||t.dispatch("message",n)}}))},this._ws.onerror=function(){t._logger.debug("websocket error"),t._pinger&&t._pinger.stop(),t.dispatch("error",f.networkError)},this._ws.onclose=function(){t._logger.debug("websocket close"),t._pinger&&t._pinger.stop(),t.dispatch("close")},this.lastActive=Date.now()},r.prototype.disconnect=function(){var e=this;this._logger.debug("websocket disconnect"),this._pinger&&this._pinger.stop(),this._ws&&(this._ws.onopen=J,this._ws.onmessage=J,this._ws.onerror=J,this._ws.onclose=function(){e.dispatch("close")},this._ws.close(),this._ws=null)},r.prototype.send=function(e){if(!this._ws)throw f.connectionClosed;"PING"!==e.code?this._pinger&&this._pinger.refreshTimer():this._logger.debug("send ping",e),this._ws.send(e.convertToMessage())},r.prototype.error=function(e){this._logger.debug("websocket error",e),this._pinger&&this._pinger.stop(),this.dispatch("error",e)},r}(R),$=function(e){function t(t){var n=t.all,r=t.custom_types,i=t.ts,s=e.call(this)||this;return s.all=n,s.customTypes=r,s.ts=i,s}return n(t,e),t}(k),ee=function(){var e=this;this.promise=new Promise((function(t,n){e.resolve=t,e.reject=n}))},te=function(){function e(e,t){var n=t.auth,r=t.sdkState,i=t.dispatcher,s=t.logger,a=this;this._ackStateMap=new Map,this._sdkState=r,this._dispatcher=i,this._logger=s,this.apiClient=new B(e,{auth:n,sdkState:r,dispatcher:i,logger:s}),this.websocketClient=new Z(e,{sdkState:r,dispatcher:i,logger:s}),this.websocketClient.on("message",(function(e){if(e.payload.unread_cnt&&a._dispatcher.dispatch(new $(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 f({code:e.payload.code,message:e.payload.message}))}}else a._dispatcher.dispatch(e)})).on("close",(function(){a._ackStateMap.forEach((function(e){e.reject(f.connectionClosed)})),a._ackStateMap.clear()}))}return e.prototype._sendApiRequest=function(e){return i(this,void 0,void 0,(function(){return s(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 s(this,(function(s){if(t=new ee,e.ackRequired){n=null,r=function(r,s){void 0===r&&(r=null),void 0===s&&(s=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(s)))};try{n=setTimeout((function(){return r(f.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 s(this,(function(t){switch(t.label){case 0:return e instanceof x?[4,this._sendApiRequest(e)]:[3,2];case 1:case 3:return[2,t.sent()];case 2:return e instanceof z?[4,this._sendWebsocketRequest(e)]:[3,4];case 4:throw f.invalidParameters}}))}))},e.prototype.cancel=function(e){this.apiClient.cancel(e)},e.prototype.cancelAll=function(){this.apiClient.cancelAll()},e}();!function(e){e[e.NONE=0]="NONE",e[e.INITIALIZED=1]="INITIALIZED",e[e.CONNECTING=2]="CONNECTING",e[e.CONNECTED=3]="CONNECTED",e[e.RECONNECTING=4]="RECONNECTING",e[e.DISCONNECTED=5]="DISCONNECTED",e[e.LOGOUT=6]="LOGOUT"}(X||(X={}));var ne,re,ie,se,ae,oe,ue,ce,le,he=function(e){function t(t){var n=t.stateType,r=e.call(this)||this;return r.stateType=n,r}return n(t,e),t}(k),de=function(){function e(e,t){var n=t.auth,r=t.sdkState,a=t.dispatcher,o=t.logger,u=this;this._currentConnectionStateType=X.INITIALIZED,this._lazyCallQueue=[],this.commandRouter=new te(e,{auth:n,sdkState:r,dispatcher:a,logger:o}),this._auth=n,this._logger=o,this._dispatcher=a,this._dispatcher.on((function(e){if(e instanceof he){var t=e.stateType;switch(u._currentConnectionStateType=t,t){case X.CONNECTED:var n=u._lazyCallQueue;u._lazyCallQueue=[],n.forEach((function(e){return i(u,void 0,void 0,(function(){var t,n,r,i,a;return s(this,(function(s){switch(s.label){case 0:t=e.command,n=e.deferred,r=e.timeout,clearTimeout(r),s.label=1;case 1:return s.trys.push([1,3,,4]),[4,this.send(t)];case 2:return i=s.sent(),n.resolve(i),[3,4];case 3:return a=s.sent(),n.reject(a),[3,4];case 4:return[2]}}))}))}));break;case X.INITIALIZED:case X.DISCONNECTED:case X.LOGOUT:n=u._lazyCallQueue;u._lazyCallQueue=[],n.forEach((function(e){return i(u,void 0,void 0,(function(){var t,n;return s(this,(function(r){return t=e.deferred,n=e.timeout,clearTimeout(n),this._auth&&this._auth.hasSession?t.reject(f.connectionClosed):t.reject(f.connectionRequired),[2]}))}))}))}}}))}return Object.defineProperty(e.prototype,"isReady",{get:function(){return this._currentConnectionStateType===X.CONNECTED},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"isLazyCallActivated",{get:function(){return this._currentConnectionStateType===X.CONNECTING||this._currentConnectionStateType===X.RECONNECTING},enumerable:!1,configurable:!0}),e.prototype.send=function(e){return i(this,void 0,void 0,(function(){var t,n,r=this;return s(this,(function(i){switch(i.label){case 0:return e instanceof z?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 ee,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"),f.connectionRequired;case 3:return[3,7];case 4:return e instanceof x?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 ee,this._lazyCallQueue.push({command:e,deferred:t,timeout:setTimeout((function(){return r.timeout(e.requestId)}),1e4)}),[2,t.promise];throw n=f.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 s(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(f.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}(),pe="v3",fe="/".concat(pe,"/users"),_e="/".concat(pe,"/storage/file"),ve="/".concat(pe,"/group_channels"),me="/".concat(pe,"/sdk/group_channels"),ge="/".concat(pe,"/open_channels"),ye="/".concat(pe,"/sdk/open_channels"),Ee="/".concat(pe,"/search"),be="/".concat(pe,"/report"),Ce="/".concat(pe,"/emojis"),Te="/".concat(pe,"/emoji_categories"),Ie="/".concat(pe,"/polls"),Se="/".concat(pe,"/scheduled_messages"),Ne="/".concat(pe,"/sdk/statistics"),we=function(e){function t(t){var n=t.userId,r=t.authToken,i=t.expiringSession,s=void 0===i||i,a=e.call(this)||this;return a.path="".concat(fe,"/").concat(n,"/session_key"),a.method=d.POST,a.params={token:r,expiring_session:!!s},a.requireAuth=!1,a}return n(t,e),t}(x),Me=function(e){function t(t){var n=t.authToken,r=t.expiringSession,i=void 0===r||r;return e.call(this,{code:"LOGI",payload:{token:n,expiring_session:i?1:0},ackRequired:!0})||this}return n(t,e),t}(z),Ae=function(e){function t(t,n){var r=e.call(this,t,n)||this,i=n.key;return r.key=i,r}return n(t,e),t}(F),Ue=function(e){function t(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 f(r.error):null,i}return n(t,e),t}(j),Oe=function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return n(t,e),t}(k),Re=function(e){return i(void 0,void 0,void 0,(function(){return s(this,(function(t){return[2,new Promise((function(t){return setTimeout(t,e)}))]}))}))},Le=function(){function e(){}return e.prototype.calcTimeout=function(){return 0},e}(),ke=function(e,t,n){return void 0===n&&(n=new Le),i(void 0,void 0,void 0,(function(){var r,i,a,o,u,c;return s(this,(function(s){switch(s.label){case 0:r=0,i=null,a=function(e){return void 0===e&&(e=null),i=null!=e?e:new Error("Halted")},o=function(){r=0},s.label=1;case 1:if(!(-1===t||r0?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 dt({userProfile:this}))},e}(),ft=function(e){function t(t,n,r){var i,s=this;return(s=e.call(this,t,n,r)||this).error=null,s.userProfile=new pt(t,r),s.key=r.key,s.ekey=null!==(i=r.ekey)&&void 0!==i?i:"",s.error=r.error?new f(r):null,s}return n(t,e),t.asError=function(e){return new t(null,"LOGI",r({user_id:null,error:!0},e))},t.prototype.applyTo=function(e){if(this.error)throw this.error;var t=wt.of(e);if(!t)throw f.lostInstance;t.sessionManager.auth.sessionKey=this.key,je(e,this.ekey),this.userProfile.apply()},t}(j),_t=function(e){function t(t){var n=e.call(this)||this;return n.enabled=t,n}return n(t,e),t}(k),vt=function(e){function t(t,n){var r=n.sdkState,i=n.cacheContext,s=n.connectionHandlers,a=n.sessionManager,o=n.websocketClient,u=n.dispatcher,c=n.logger,l=n.entryState,h=void 0===l?new Qe:l,d=e.call(this)||this;return d._currentState=null,d._loginTimer=null,d._connectingAt=0,d._connectionRequestQueue=[],d._iid=t,d.sdkState=r,d.cacheContext=i,d.connectionHandlers=s,d._sessionManager=a,d._websocketClient=o,d._dispatcher=u,d._logger=c,d._currentState=h,d._websocketClient.on("message",(function(e){if("LOGI"===e.code){d._loginTimer&&(clearTimeout(d._loginTimer),d._loginTimer=null);var t=e.as(ft);if(t.error)(t.error.isSessionKeyExpiredError||t.error.isSessionTokenExpiredError)&&d._dispatcher.dispatch(new G),d._connectionRequestQueue.forEach((function(e){return e.reject(t.error)})),d._statLogConnection(t.error);else{t.applyTo(d._iid),d._connectionRequestQueue.forEach((function(e){return e.resolve()}));var n=t.userProfile;d._enableStatLog(n.appInfo.applicationAttributes.includes("allow_sdk_request_log_publish")),d._statLogConnection(null)}d._connectionRequestQueue=[]}})).on("close",(function(){d._connectionRequestQueue.length>0&&(d._connectionRequestQueue.forEach((function(e){return e.reject(f.networkError)})),d._connectionRequestQueue=[],d._statLogConnection(f.networkError))})),d}return n(t,e),Object.defineProperty(t.prototype,"currentState",{get:function(){return this._currentState},enumerable:!1,configurable:!0}),t.prototype.changeState=function(e){return i(this,void 0,void 0,(function(){return s(this,(function(t){switch(t.label){case 0:return this._currentState=e,this._dispatcher.dispatch(new he({stateType:e.type})),this._logger.debug("connection state changes to ".concat(e.name)),[4,this._currentState.run(this)];case 1:return t.sent(),[2]}}))}))},t.prototype._url=function(e){void 0===e&&(e="");var t=this.sdkState,n=t.appId,r=t.appVersion,i=t.userId,s=t.extensions,a=this.cacheContext.localCacheEnabled,o=this._sessionManager.auth,u=s.sb_syncmanager?"s".concat(s.sb_syncmanager):"",c=s.sb_uikit?"u".concat(s.sb_uikit):"",l="JS/c".concat(h.SDK_VERSION,"/").concat(u,"/").concat(c);return"".concat(this.sdkState.websocket.host,"/?p=JS&pv=").concat(encodeURIComponent(h.OS_VERSION),"&sv=").concat(encodeURIComponent(h.SDK_VERSION),"&ai=").concat(n).concat(r?"&av=".concat(r):"").concat(o.hasSession?"&key=".concat(encodeURIComponent(o.sessionKey)):"&user_id=".concat(encodeURIComponent(i),"&access_token=").concat(encodeURIComponent(e)),"&active=1&SB-User-Agent=").concat(l,"&Request-Sent-Timestamp=").concat(Date.now().toString(),"&include_extra_data=").concat(encodeURIComponent(String(["premium_feature_list","file_upload_size_limit","application_attributes","emoji_hash"]))).concat(this._sessionManager.handler?"&expiring_session=1":"","&use_local_cache=").concat(a?1:0,"&include_poll_details=1")},t.prototype._enableStatLog=function(e){this._dispatcher.dispatch(new _t(e))},t.prototype._statLogConnection=function(e){this._dispatcher.dispatch(new H(new K({type:P.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}})))},t.prototype.connect=function(e){return void 0===e&&(e=""),i(this,void 0,void 0,(function(){var t,n,r=this;return s(this,(function(i){return t=this._url(e),n=new ee,this._connectionRequestQueue.push(n),1===this._connectionRequestQueue.length&&(this._connectingAt=Date.now(),this._loginTimer=setTimeout((function(){r._loginTimer=null,r._dispatcher.dispatch(ft.asError(f.loginTimeout))}),this.sdkState.websocket.responseTimeout),this._websocketClient.connect(t)),[2,n.promise]}))}))},t.prototype.cancelConnectForRetry=function(){this._dispatcher.dispatch(ft.asError(f.connectionRenew))},t.prototype.disconnect=function(){this._websocketClient.disconnect()},t.prototype.logout=function(){this.sdkState.userId=null,this._sessionManager.currentUser=null,this._sessionManager.auth.clear(),this.disconnect()},t}(R),mt=function(){function e(e,t){var n=t.sdkState,r=t.cacheContext,i=t.connectionHandlers,s=t.sessionManager,a=t.websocketClient,o=t.dispatcher,u=t.logger,c=t.disableAutoReconnect,l=void 0!==c&&c,h=this;this._context=null,this._logger=u,this._context=new vt(e,{sdkState:n,cacheContext:r,connectionHandlers:i,sessionManager:s,websocketClient:a,dispatcher:o,logger:u}),l||(s.on("refresh-authtoken",(function(){h.isConnected||(h._logger.debug("try reconnect by session token refresh"),h.reconnect())})).on("refresh",(function(){h.isConnecting||h.isConnected||(h._logger.debug("try reconnect by session key refresh"),h.reconnect())})),a.on("close",(function(){"foreground"===n.appState&&setTimeout((function(){s.isRefreshingAuthToken||(h._logger.debug("try reconnect by websocket connection closed"),h.reconnect())}),100)})))}return Object.defineProperty(e.prototype,"isConnected",{get:function(){return this._context.currentState.type===X.CONNECTED},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"isConnecting",{get:function(){var e=this._context.currentState;return e.type===X.CONNECTING||e.type===X.RECONNECTING},enumerable:!1,configurable:!0}),e.prototype.connect=function(e){return i(this,void 0,void 0,(function(){return s(this,(function(t){switch(t.label){case 0:return[4,this._context.currentState.onConnect(this._context,e)];case 1:return t.sent(),[2]}}))}))},e.prototype.reconnect=function(){return i(this,void 0,void 0,(function(){return s(this,(function(e){switch(e.label){case 0:return[4,this._context.currentState.onReconnect(this._context,{})];case 1:return e.sent(),[2]}}))}))},e.prototype.resetAndReconnect=function(){return i(this,void 0,void 0,(function(){return s(this,(function(e){switch(e.label){case 0:return[4,this._context.currentState.onReconnect(this._context,{resetReconnectCount:!0})];case 1:return e.sent(),[2]}}))}))},e.prototype.background=function(){return i(this,void 0,void 0,(function(){return s(this,(function(e){switch(e.label){case 0:return[4,this._context.currentState.onDisconnect(this._context,{autoReconnect:!1})];case 1:return e.sent(),[2]}}))}))},e.prototype.disconnect=function(e){return void 0===e&&(e=null),i(this,void 0,void 0,(function(){return s(this,(function(t){switch(t.label){case 0:return[4,this._context.currentState.onDisconnect(this._context,{error:e,autoReconnect:!0})];case 1:return t.sent(),[2]}}))}))},e.prototype.logout=function(){return i(this,void 0,void 0,(function(){return s(this,(function(e){switch(e.label){case 0:return[4,this._context.currentState.onLogout(this._context)];case 1:return e.sent(),[2]}}))}))},e}(),gt=function(e){function t(t){var n=t.deviceId,r=t.statLogs,i=e.call(this)||this;return i.method=d.POST,i.path="".concat(Ne),i.params={device_id:n,log_entries:r.map((function(e){return K.payloadify(e)}))},i}return n(t,e),t}(x);!function(e){e[e.PENDING=0]="PENDING",e[e.ENABLED=1]="ENABLED",e[e.DISABLED=2]="DISABLED"}(lt||(lt={}));var yt,Et=function(){function e(e){var t=e.cacheContext,n=e.requestQueue,r=e.dispatcher,i=e.baseLimit,s=void 0===i?100:i,a=e.maxLimit,o=void 0===a?1e3:a,u=e.minLimit,c=void 0===u?10:u;this.queue=[],this.enabledstate=lt.PENDING,this.isFlushing=!1,this.generation=1,this.lastFlushedAt=0,this.deviceId=U(),this.cacheContext=t,this.requestQueue=n,this.dispatcher=r,this.baseLimit=s,this.limit=s,this.maxLimit=o,this.minLimit=c}return Object.defineProperty(e.prototype,"isEnabled",{get:function(){return this.enabledstate===lt.ENABLED},enumerable:!1,configurable:!0}),e.prototype._save=function(){return i(this,void 0,void 0,(function(){return s(this,(function(e){switch(e.label){case 0:return this.cacheContext.localCacheEnabled?[4,this.cacheContext.preference.set(this.key,{deviceId:this.deviceId,statLogs:this.queue.map((function(e){return K.payloadify(e)})),generation:this.generation++,lastFlushedAt:this.lastFlushedAt})]:[3,2];case 1:e.sent(),e.label=2;case 2:return[2]}}))}))},e.prototype._flush=function(){return i(this,void 0,void 0,(function(){var e,t;return s(this,(function(n){switch(n.label){case 0:if(!this.isEnabled)return[3,7];if(this.isFlushing)return[3,7];this.isFlushing=!0,n.label=1;case 1:return n.trys.push([1,5,6,7]),(e=this.queue.slice(0,Math.min(this.limit,this.maxLimit))).length>0?(t=new gt({deviceId:this.deviceId,statLogs:e}),[4,this.requestQueue.send(t)]):[3,4];case 2:return n.sent(),this.queue=this.queue.slice(e.length),[4,this._save()];case 3:n.sent(),n.label=4;case 4:return this.limit=this.baseLimit,this.lastFlushedAt=Date.now(),[3,7];case 5:return n.sent(),this.limit=this.limit+20,[3,7];case 6:return this.isFlushing=!1,[7];case 7:return[2]}}))}))},e.prototype.init=function(e){return i(this,void 0,void 0,(function(){var t,n,r=this;return s(this,(function(i){switch(i.label){case 0:return this.key=e,this.cacheContext.localCacheEnabled?[4,this.cacheContext.preference.get(this.key)]:[3,4];case 1:return(t=i.sent())?(this.deviceId=t.deviceId,this.queue=t.statLogs.map((function(e){return new K({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,Re(n)]):[3,4]):[3,4];case 2:return i.sent(),[4,this._flush()];case 3:i.sent(),i.label=4;case 4:return this.dispatcher.on((function(e){if(e instanceof H){var t=e.statLog;r.put(t)}else e instanceof _t&&(r.enabledstate=e.enabled?lt.ENABLED:lt.DISABLED,r.isEnabled?r.queue.length>=r.limit&&r._flush():r.clear())})),[2]}}))}))},e.prototype.put=function(e){return i(this,void 0,void 0,(function(){return s(this,(function(t){switch(t.label){case 0:return this.enabledstate===lt.DISABLED?[3,3]:(this.queue.push(e),[4,this._save()]);case 1:return t.sent(),this.queue.length>=this.limit?[4,this._flush()]:[3,3];case 2:t.sent(),t.label=3;case 3:return[2]}}))}))},e.prototype.clear=function(){return i(this,void 0,void 0,(function(){return s(this,(function(e){switch(e.label){case 0:return this.queue=[],this.generation=1,[4,this._save()];case 1:return e.sent(),[2]}}))}))},e}();e.LogLevel=void 0,(yt=e.LogLevel||(e.LogLevel={}))[yt.NONE=0]="NONE",yt[yt.VERBOSE=1]="VERBOSE",yt[yt.DEBUG=2]="DEBUG",yt[yt.INFO=3]="INFO",yt[yt.WARN=4]="WARN",yt[yt.ERROR=5]="ERROR";var bt,Ct,Tt,It,St=function(){function t(){this.level=e.LogLevel.WARN}return t.prototype.verbose=function(){for(var t=[],n=0;n0&&g("number",c)&&(this.key=i,this.userIds=s,this.updatedAt=c);var l={};try{for(var h=a(this.userIds),d=h.next();!d.done;d=h.next()){l[d.value]=this.updatedAt}}catch(e){t={error:e}}finally{try{d&&!d.done&&(n=h.return)&&n.call(h)}finally{if(t)throw t.error}}this._version=l}return Object.defineProperty(t.prototype,"isEmpty",{get:function(){return 0===this.userIds.length},enumerable:!1,configurable:!0}),t.payloadify=function(e){return e?D({key:e.key,user_ids:e.userIds,updated_at:e.updatedAt}):null},t.prototype.applyEvent=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)}},t}(),xt=function(){function e(e){this.key=e.key,this.value=b("string",e.value)?u([],o(e.value),!1):[]}return e.payloadify=function(e){var t;return e?D({key:e.key,value:null!==(t=e.value)&&void 0!==t?t:[]}):null},e}(),Ft=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?D({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}(),qt=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 Ft(e["og:image"]))}return e.payloadify=function(e){return e?D({"og:title":e.title,"og:url":e.url,"og:description":e.description,"og:image":e.defaultImage?Ft.payloadify(e.defaultImage):null}):null},e}(),Gt=function(){function e(e){var t,n;this.name=null,this.volume=0,this.name=null!==(t=e.name)&&void 0!==t?t:"default",this.volume=null!==(n=e.volume)&&void 0!==n?n:1}return e.payloadify=function(e){return e?D({name:e.name,volume:e.volume}):null},e}();e.ScheduledStatus=void 0,(Lt=e.ScheduledStatus||(e.ScheduledStatus={})).PENDING="pending",Lt.SENT="sent",Lt.FAILED="failed",Lt.CANCELED="canceled",function(e){e.PENDING="pending",e.IN_QUEUE="in_queue",e.SENT="sent",e.FAILED="failed",e.CANCELED="canceled",e.REMOVED="removed"}(kt||(kt={}));var Ht,Vt=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"}},Kt=function(t){function i(n,r){var i,s,a,o,u,c,l,h,d,p,f,_,v,m=this;(m=t.call(this,n)||this).channelUrl=null,m.channelType=e.ChannelType.BASE,m.messageId=0,m.parentMessageId=null,m.parentMessage=null,m.silent=!1,m.isOperatorMessage=!1,m.messageType=e.MessageType.BASE,m.data=null,m.customType=null,m.mentionType=null,m.mentionedUsers=[],m.mentionedUserIds=[],m.mentionedMessageTemplate=null,m.threadInfo=null,m.reactions=[],m.metaArrays=[],m.ogMetaData=null,m.appleCriticalAlertOptions=null,m.createdAt=0,m.updatedAt=0,m.scheduledInfo=null,m._scheduledStatus=null,m.messageId=null!==(s=null!==(i=r.msg_id)&&void 0!==i?i:r.message_id)&&void 0!==s?s:0,m.channelUrl=r.channel_url,m.channelType=y(e.ChannelType,r.channel_type)?r.channel_type:e.ChannelType.GROUP,r.channel&&(r.channel.channel_url&&(m.channelUrl=r.channel.channel_url),r.channel.channel_type&&(m.channelType=r.channel.channel_type)),m.parentMessageId=null!==(a="string"==typeof r.parent_message_id?parseInt(r.parent_message_id):r.parent_message_id)&&void 0!==a?a:0,m.data=null!==(o=r.data)&&void 0!==o?o:"",m.customType=null!==(u=r.custom_type)&&void 0!==u?u:"",m.mentionType=y(e.MentionType,r.mention_type)?r.mention_type:null;var g=r.mentioned_users;m.mentionedUsers=g?g.map((function(e){return new ht(m._iid,e)})):null;var E=r.mentioned_user_ids;m.mentionedUserIds=null!=E?E:null,m.mentionedMessageTemplate=null!==(c=r.mentioned_message_template)&&void 0!==c?c:"",m.threadInfo=r.thread_info?new Rt(m._iid,r.thread_info):null,m.reactions=r.reactions?r.reactions.map((function(e){return new Pt(e)})):[];for(var b=null!==(l=r.metaarray)&&void 0!==l?l:{},C=null!==(h=r.metaarray_key_order)&&void 0!==h?h:Object.keys(b).sort((function(e,t){return e.localeCompare(t)})),T=0;T=t)return this.parentMessage=e,!0}return!1},i}(We),Qt=function(t){function i(n,r){var i=t.call(this,n,r)||this;return i.role=null,i.isBlockedByMe=!1,i.role=y(e.Role,r.role)?r.role:e.Role.NONE,r.hasOwnProperty("is_blocked_by_me")&&(i.isBlockedByMe=r.is_blocked_by_me),i}return n(i,t),i.payloadify=function(e){return e?D(r(r({},t.payloadify.call(this,e)),{role:e.role,is_blocked_by_me:e.isBlockedByMe})):null},i}(ht),Bt=function(t){function i(n,r){var i,s,a,o,u=this;if((u=t.call(this,n,r)||this).sender=null,u.reqId="",u.replyToChannel=!1,u.sendingStatus=null,u.errorCode=0,u.sender=r.user?new Qt(u._iid,r.user):r.sender_id,u.reqId=null!==(s=null!==(i=r.req_id)&&void 0!==i?i:r.request_id)&&void 0!==s?s:"",u.replyToChannel=null!==(a=r.is_reply_to_channel)&&void 0!==a&&a,r.request_state&&y(e.SendingStatus,r.request_state)&&(u.sendingStatus=r.request_state),!u.sendingStatus)if(u.messageId>0)u.sendingStatus=e.SendingStatus.SUCCEEDED;else if(u.scheduledInfo)switch(u._scheduledStatus=r.scheduled_status,r.scheduled_status){case kt.SENT:case kt.IN_QUEUE:u.sendingStatus=e.SendingStatus.SUCCEEDED;break;case kt.PENDING:u.sendingStatus=e.SendingStatus.SCHEDULED;break;case kt.FAILED:case kt.REMOVED:u.sendingStatus=e.SendingStatus.FAILED;break;case kt.CANCELED:u.sendingStatus=e.SendingStatus.CANCELED}else u.sendingStatus=e.SendingStatus.PENDING;return u.errorCode=null!==(o=r.error_code)&&void 0!==o?o:0,u}return n(i,t),i.payloadify=function(e){return e?D(r(r({},t.payloadify.call(this,e)),{user:Qt.payloadify(e.sender),req_id:e.reqId,is_reply_to_channel:e.replyToChannel,request_state:e.sendingStatus,error_code:e.errorCode})):null},Object.defineProperty(i.prototype,"isResendable",{get:function(){return this.sendingStatus===e.SendingStatus.FAILED&&((t=this.errorCode)>0&&_.indexOf(t)>=0);var t},enumerable:!1,configurable:!0}),i.prototype.isIdentical=function(e){return this.messageId>0&&e.messageId>0?this.messageId===e.messageId:this.reqId===e.reqId},i}(Kt),jt=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?D({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}(),zt={prevResultSize:0,nextResultSize:0,isInclusive:!1,reverse:!1,messageTypeFilter:e.MessageTypeFilter.ALL,customTypesFilter:null,senderUserIdsFilter:null,includeReactions:!1,includeMetaArray:!1,includeParentMessageInfo:!1},Wt=function(t){return g("number",t.prevResultSize)&&g("number",t.nextResultSize)&&g("boolean",t.isInclusive)&&g("boolean",t.reverse)&&g("string",t.messageTypeFilter)&&y(e.MessageTypeFilter,t.messageTypeFilter)&&b("string",t.customTypesFilter,!0)&&b("string",t.senderUserIdsFilter,!0)&&g("boolean",t.includeMetaArray)&&g("boolean",t.includeReactions)&&g("boolean",t.includeParentMessageInfo)},Yt=function(t){function a(n,i){var s,a,o,u,c=this;if((c=t.call(this,n,i)||this).message=null,c.translations={},c.message=null!==(s=i.message)&&void 0!==s?s:"",c.messageType=e.MessageType.ADMIN,c.translations=null!==(a=i.translations)&&void 0!==a?a:{},i.parent_message_info){var l=i.parent_message_info,h=r(r({},l),{message_id:c.parentMessageId,channel_url:c.channelUrl,channel_type:c.channelType,file:l.file,url:null===(o=l.file)||void 0===o?void 0:o.url,require_auth:null===(u=l.file)||void 0===u?void 0:u.require_auth});c.parentMessage=sn(n,h)}return c}return n(a,t),a.payloadify=function(e){return e?D(r(r({},t.payloadify.call(this,e)),{message:e.message,translations:e.translations,parent_message_info:rn(e.parentMessage)})):null},a.prototype.getThreadedMessagesByTimestamp=function(e,t){return i(this,void 0,void 0,(function(){var n;return s(this,(function(i){switch(i.label){case 0:return n=r(r({},zt),t),ct(this.messageId>0&&g("number",e)&&Wt(n)).throw(f.invalidParameters),[4,kn.of(this._iid).getThreadedMessagesByTimestamp(this,e,n)];case 1:return[2,i.sent()]}}))}))},a}(Kt),Jt=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")&&g("object",e.detail)&&!Array.isArray(e.detail)&&(this.detail=e.detail)}return e.payloadify=function(e){return e?D({type:e.type,vendor:e.vendor,detail:e.detail}):null},e}();!function(e){e.OPEN="open",e.CLOSED="closed"}(Ht||(Ht={}));var Xt,Zt=function(e){switch(e){case Ht.OPEN:return Ht.OPEN;case Ht.CLOSED:return Ht.CLOSED}},$t=function(e){return!e||e.text&&g("string",e.text)},en=function(e){function t(t,n){var r,i,s,a,o,u,c,l=this;return(l=e.call(this,t)||this).pollId=0,l.id=0,l.text=null,l.voteCount=0,l.createdBy=null,l.createdAt=0,l.updatedAt=0,l._lastVotedAt=0,l.pollId=null!==(r=n.poll_id)&&void 0!==r?r:0,l.id=null!==(i=n.id)&&void 0!==i?i:0,l.text=null!==(s=n.text)&&void 0!==s?s:null,l.voteCount=null!==(a=n.vote_count)&&void 0!==a?a:0,l.createdBy=null!==(o=n.created_by)&&void 0!==o?o:null,l.createdAt=null!==(u=n.created_at)&&void 0!==u?u:0,l.updatedAt=null!==(c=n.updated_at)&&void 0!==c?c:0,l}return n(t,e),t.payloadify=function(t){return t?D(r(r({},e.payloadify.call(this,t)),{vote_count:t.voteCount,poll_id:t.pollId,text:t.text,created_at:t.createdAt,id:t.id,created_by:t.createdBy,updated_at:t.updatedAt})):null},t}(We),tn=function(e){function t(t,n){var r,i,s,a,o,u,c,l,h,d,p,f,_,v,m=this;return(m=e.call(this,t)||this).id=0,m.title=null,m.createdAt=0,m.updatedAt=0,m.closeAt=-1,m.status=Ht.CLOSED,m.messageId=0,m.data=null,m.voterCount=-1,m.options=[],m.createdBy=null,m.isAnonymous=!1,m.allowUserSuggestion=!1,m.allowMultipleVotes=!1,m.votedPollOptionIds=[],m.id=null!==(r=n.id)&&void 0!==r?r:0,m.title=null!==(i=n.title)&&void 0!==i?i:null,m.createdAt=null!==(s=n.created_at)&&void 0!==s?s:0,m.updatedAt=null!==(a=n.updated_at)&&void 0!==a?a:0,m.closeAt=null!==(o=n.close_at)&&void 0!==o?o:-1,m.status=null!==(u=Zt(n.status))&&void 0!==u?u:Ht.CLOSED,m.messageId=null!==(c=n.message_id)&&void 0!==c?c:0,m.data=null!==(l=n.data)&&void 0!==l?l:null,m.voterCount=null!==(h=n.voter_count)&&void 0!==h?h:-1,m.options=n.options?n.options.map((function(e){return new en(m._iid,e)})):[],m.createdBy=null!==(d=n.created_by)&&void 0!==d?d:null,m.isAnonymous=null!==(p=n.is_anonymous)&&void 0!==p&&p,m.allowUserSuggestion=null!==(f=n.allow_user_suggestion)&&void 0!==f&&f,m.allowMultipleVotes=null!==(_=n.allow_multiple_votes)&&void 0!==_&&_,m.votedPollOptionIds=null!==(v=n.voted_option_ids)&&void 0!==v?v:[],m}return n(t,e),t.prototype._applyPollUpdatePayload=function(e){var t,n,r,i,s,a,o,u,c,l=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!==(i=Zt(e.status))&&void 0!==i?i:this.status,this.data=null!==(s=e.data)&&void 0!==s?s:this.data,this.voterCount=null!==(a=e.voter_count)&&void 0!==a?a:this.voterCount,this.options=e.options?e.options.map((function(e){return new en(l._iid,e)})):this.options,this.isAnonymous=null!==(o=e.is_anonymous)&&void 0!==o?o:this.isAnonymous,this.allowUserSuggestion=null!==(u=e.allow_user_suggestion)&&void 0!==u?u:this.allowUserSuggestion,this.allowMultipleVotes=null!==(c=e.allow_multiple_votes)&&void 0!==c?c:this.allowMultipleVotes},t.payloadify=function(t){return t?D(r(r({},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 en.payloadify(e)})),created_by:t.createdBy,is_anonymous:t.isAnonymous,allow_user_suggestion:t.allowUserSuggestion,allow_multiple_votes:t.allowMultipleVotes,voted_option_ids:t.votedPollOptionIds})):null},t.prototype.applyPollUpdateEvent=function(e){var t=e._payload.poll;return!(!t||this.id!==t.id||t.updated_at-1){var s=t[r];i>s._lastVotedAt&&(s.voteCount=e.vote_count,s._lastVotedAt=i)}})),r.req_id&&r.voted_option_ids&&(this.votedPollOptionIds=r.voted_option_ids),!0},t}(We),nn=function(t){function o(n,i){var s,o,u,c,l,h,d,p=this;if((p=t.call(this,n,i)||this).message="",p.messageParams=null,p.translations={},p.translationTargetLanguages=[],p.messageSurvivalSeconds=-1,p.plugins=[],p._poll=null,p.message=i.message,p.messageType=e.MessageType.USER,p.translations=null!==(u=i.translations)&&void 0!==u?u:{},p.translationTargetLanguages=null!==(c=i.target_langs)&&void 0!==c?c:[],0===Object.keys(p.translations).length&&p.translationTargetLanguages.length>0)try{for(var f=a(p.translationTargetLanguages),_=f.next();!_.done;_=f.next()){var v=_.value;p.translations[v]=""}}catch(e){s={error:e}}finally{try{_&&!_.done&&(o=f.return)&&o.call(f)}finally{if(s)throw s.error}}if(p.messageSurvivalSeconds=null!==(l=i.message_survival_seconds)&&void 0!==l?l:-1,p.plugins=i.plugins?i.plugins.map((function(e){return new Jt(e)})):[],p._poll=i.poll?new tn(p._iid,i.poll):null,i.parent_message_info){var m=i.parent_message_info,g=r(r({},m),{created_at:m.ts,message_id:p.parentMessageId,channel_url:p.channelUrl,channel_type:p.channelType,file:m.file,url:null===(h=m.file)||void 0===h?void 0:h.url,require_auth:null===(d=m.file)||void 0===d?void 0:d.require_auth});p.parentMessage=sn(n,D(g))}return p}return n(o,t),o.payloadify=function(e){return e?D(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 Jt.payloadify(e)})),poll:tn.payloadify(e._poll),parent_message_info:rn(e.parentMessage)})):null},o.prototype.getThreadedMessagesByTimestamp=function(e,t){return i(this,void 0,void 0,(function(){var n;return s(this,(function(i){switch(i.label){case 0:return n=r(r({},zt),t),ct(this.messageId>0&&g("number",e)&&Wt(n)).throw(f.invalidParameters),[4,kn.of(this._iid).getThreadedMessagesByTimestamp(this,e,n)];case 1:return[2,i.sent()]}}))}))},o.prototype.applyPoll=function(e){return!(this._poll&&this._poll.id===e.id&&this._poll.updatedAt>e.updatedAt)&&(this._poll=e,!0)},Object.defineProperty(o.prototype,"poll",{get:function(){return this._poll},enumerable:!1,configurable:!0}),o}(Bt),rn=function(t){if(t)switch(t.messageType){case e.MessageType.USER:return nn.payloadify(t);case e.MessageType.FILE:return an.payloadify(t);case e.MessageType.ADMIN:return Yt.payloadify(t)}return null},sn=function(e,t){switch(t.type){case"MESG":return new nn(e,t);case"FILE":return new an(e,t);case"ADMM":case"BRDM":return new Yt(e,t)}return null},an=function(t){function a(n,i){var s,a,o,u,c,l,h,d,p,f,_,v,m,g,y,E=this;(E=t.call(this,n,i)||this).messageParams=null,E.plainUrl="",E.requireAuth=!1,E.name=null,E.size=0,E.type=null,E.thumbnails=[],E.messageSurvivalSeconds=-1,E.messageType=e.MessageType.FILE;var b=null!==(s=i.file)&&void 0!==s?s:null;if(E.plainUrl=(null!==(o=null!==(a=null==b?void 0:b.url)&&void 0!==a?a:i.url)&&void 0!==o?o:"").split("?auth=")[0],E.name=null!==(c=null!==(u=null==b?void 0:b.name)&&void 0!==u?u:i.name)&&void 0!==c?c:"File",E.size=null!==(h=null!==(l=null==b?void 0:b.size)&&void 0!==l?l:i.size)&&void 0!==h?h:0,E.data=null!==(p=null!==(d=null==b?void 0:b.data)&&void 0!==d?d:i.custom)&&void 0!==p?p:"",E.type=b?null!==(f=b.type)&&void 0!==f?f:"":null!==(_=i.type)&&void 0!==_?_:"",E.requireAuth=null!==(v=i.require_auth)&&void 0!==v&&v,E.thumbnails=i.thumbnails?i.thumbnails.map((function(e){return new jt(r(r({},e),{url:"".concat(e.url.split("?auth=")[0]).concat(E.requireAuth?"?auth=".concat(je(E._iid)):"")}))})):[],E.messageSurvivalSeconds=null!==(m=i.message_survival_seconds)&&void 0!==m?m:-1,i.parent_message_info){var C=i.parent_message_info,T=r(r({},C),{message_id:E.parentMessageId,channel_url:E.channelUrl,channel_type:E.channelType,file:C.file,url:null===(g=C.file)||void 0===g?void 0:g.url,require_auth:null===(y=C.file)||void 0===y?void 0:y.require_auth});E.parentMessage=sn(n,T)}return E}return n(a,t),a.payloadify=function(e){return e?D(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:e.thumbnails.map((function(e){return{url:e.url,width:e.width,height:e.height,real_width:e.realWidth,real_height:e.realHeight}})),message_survival_seconds:e.messageSurvivalSeconds,parent_message_info:rn(e.parentMessage)})):null},Object.defineProperty(a.prototype,"url",{get:function(){return this.requireAuth?"".concat(this.plainUrl,"?auth=").concat(je(this._iid)):this.plainUrl},enumerable:!1,configurable:!0}),a.prototype.getThreadedMessagesByTimestamp=function(e,t){return i(this,void 0,void 0,(function(){var n;return s(this,(function(i){switch(i.label){case 0:return n=r(r({},zt),t),ct(this.messageId>0&&g("number",e)&&Wt(n)).throw(f.invalidParameters),[4,kn.of(this._iid).getThreadedMessagesByTimestamp(this,e,n)];case 1:return[2,i.sent()]}}))}))},a}(Bt),on=function(t){function r(n){var r,i,s,a=[];return n.mentionType===e.MentionType.USERS&&(n.mentionedUserIds?a=n.mentionedUserIds:n.mentionedUsers&&(a=n.mentionedUsers.map((function(e){return e.userId})))),t.call(this,{code:"FILE",ackRequired:!0,payload:D({channel_url:n.channelUrl,url:n.url,name:null!==(r=n.fileName)&&void 0!==r?r:"",type:null!==(i=n.mimeType)&&void 0!==i?i:"",size:null!==(s=n.fileSize)&&void 0!==s?s:0,custom:n.data,custom_type:n.customType,thumbnails:n.thumbnailSizes,require_auth:n.requireAuth,metaarray:n.metaArrays,mention_type:n.mentionType,mentioned_user_ids:a,push_option:n.pushNotificationDeliveryOption&&n.pushNotificationDeliveryOption!==e.PushNotificationDeliveryOption.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})})||this}return n(r,t),r}(z),un=function(t){function r(n){var r,i=this;i=t.call(this)||this;var s=[];return n.mentionType===e.MentionType.USERS&&(n.mentionedUserIds?s=n.mentionedUserIds:n.mentionedUsers&&(s=n.mentionedUsers.map((function(e){return e.userId})))),i.method=d.POST,i.path="".concat(Je(n.channelType),"/").concat(encodeURIComponent(n.channelUrl),"/messages"),i.params=D({message_type:e.MessageType.FILE,user_id:n.userId,url:n.fileUrl,mention_type:n.mentionType,mentioned_user_ids:s,file_name:n.fileName,file_size:n.fileSize,file_type:n.mimeType,data:n.data,custom_type:n.customType,thumbnails:n.thumbnailSizes.map((function(e){return jt.payloadify(e)})),require_auth:n.requireAuth,sorted_metaarray:null===(r=n.metaArrays)||void 0===r?void 0:r.map((function(e){return xt.payloadify(e)})),push_option:n.pushNotificationDeliveryOption,parent_message_id:n.parentMessageId>0?n.parentMessageId:null,apple_critical_alert_options:Gt.payloadify(n.appleCriticalAlertOptions),reply_to_channel:n.isReplyToChannel,req_id:n.reqId}),i}return n(r,t),r}(x),cn=function(e){function t(t,n,r){var i,s,a,o=this;(o=e.call(this,t,"FILE",r)||this).message=new an(t,r);var u=wt.of(t).sdkState;return o.isMentioned=Ze(o.message.mentionType,null!==(i=o.message.mentionedUserIds)&&void 0!==i?i:null===(s=o.message.mentionedUsers)||void 0===s?void 0:s.map((function(e){return e.userId})),u.userId),o.forceUpdateLastMessage=null!==(a=r.force_update_last_message)&&void 0!==a&&a,o}return n(t,e),t}(j),ln=function(e){function t(t,n){var r,i,s=this;(s=e.call(this,t,n)||this).message=new an(t,n);var a=wt.of(t).sdkState;return s.isMentioned=Ze(s.message.mentionType,null!==(r=s.message.mentionedUserIds)&&void 0!==r?r:s.message.mentionedUsers.map((function(e){return e.userId})),a.userId),s.forceUpdateLastMessage=null!==(i=n.force_update_last_message)&&void 0!==i&&i,s}return n(t,e),t}(F);!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"}(Xt||(Xt={}));var hn,dn=function(){function e(e,t){var n=t.sdkState,r=t.dispatcher,i=t.requestQueue,s=t.onlineDetector,a=t.cacheContext,o=this;this._queueMap=new Map,this._connectionState=null,this._onlineDetector=null,this._iid=e,this._sdkState=n,this._requestQueue=i,this._cacheContext=a,this._dispatcher=r,this._dispatcher.on((function(e){e instanceof he&&(o._connectionState=e.stateType)})),this._onlineDetector=s}return Object.defineProperty(e.prototype,"_shouldSendThroughWebSocket",{get:function(){return this._connectionState===X.CONNECTED||this._connectionState===X.CONNECTING||this._connectionState===X.RECONNECTING},enumerable:!1,configurable:!0}),e.prototype._sendFileMessage=function(e,t){return i(this,void 0,void 0,(function(){var n,i;return s(this,(function(s){switch(s.label){case 0:return this._shouldSendThroughWebSocket?(n=new on(r(r({channelUrl:e.url,channelType:e.channelType,url:t.params.fileUrl,requireAuth:t.requireAuth},t.params),{reqId:t.requestId})),[4,this._requestQueue.send(n)]):[3,2];case 1:return i=s.sent(),[2,i.as(cn).message];case 2:return n=new un(r(r({channelUrl:e.url,channelType:e.channelType,url:t.params.fileUrl,userId:this._sdkState.userId,requireAuth:t.requireAuth},t.params),{reqId:t.requestId})),[4,this._requestQueue.send(n)];case 3:return i=s.sent(),[2,i.as(ln).message]}}))}))},e.prototype._resolveMessageQueue=function(e){return i(this,void 0,void 0,(function(){var t,n,r,i,o,u,l,h,d,p,_,v;return s(this,(function(s){switch(s.label){case 0:if(!(t=this._queueMap.get(e.url)))return[3,21];if(t.isResolving)return[3,20];t.isResolving=!0,n=[],r=!0,s.label=1;case 1:s.trys.push([1,15,16,17]),i=a(t.messageQueue),o=i.next(),s.label=2;case 2:if(o.done)return[3,14];switch(u=o.value,u.state){case Xt.PENDING:case Xt.UPLOADING:return[3,3];case Xt.UPLOADED:return[3,4];case Xt.FAILED:return[3,12]}return[3,13];case 3:return r=!1,n.push(u),[3,13];case 4:if(!r)return[3,10];s.label=5;case 5:return s.trys.push([5,8,,9]),u.state=Xt.SENDING,[4,this._sendFileMessage(e,u)];case 6:return l=s.sent(),u.deferred.resolve(l),[4,Re(100)];case 7:return s.sent(),[3,9];case 8:return h=s.sent(),u.deferred.reject(h),[3,9];case 9:return[3,11];case 10:n.push(u),s.label=11;case 11:return[3,13];case 12:return u.deferred.reject(u.error.code===c.REQUEST_CANCELED?f.fileUploadCanceled:u.error),[3,13];case 13:return o=i.next(),[3,2];case 14:return[3,17];case 15:return d=s.sent(),_={error:d},[3,17];case 16:try{o&&!o.done&&(v=i.return)&&v.call(i)}finally{if(_)throw _.error}return[7];case 17:return p=t.isResolveRequestPending,t.messageQueue=n,t.isResolving=!1,t.isResolveRequestPending=!1,p?[4,this._resolveMessageQueue(e)]:[3,19];case 18:s.sent(),s.label=19;case 19:return[3,21];case 20:t.isResolveRequestPending=!0,s.label=21;case 21:return[2]}}))}))},e.prototype._uploadNextPendingItem=function(e){return i(this,void 0,void 0,(function(){var t,n,r,i,a,o,u,l,h,d,p,_,v,m;return s(this,(function(s){switch(s.label){case 0:return t=this._queueMap.get(e.url),(n=t.messageQueue.find((function(e){return e.state===Xt.PENDING})))?T(n.params.file)?t.uploadQueue.length<6?(n.state=Xt.UPLOADING,t.uploadQueue.push(n),[4,this._onlineDetector.isOnline()]):[3,10]:[3,11]:[3,13];case 1:if(!s.sent())return[3,8];s.label=2;case 2:return s.trys.push([2,4,5,7]),r=new Ut({file:n.params.file,channelUrl:e.url,thumbnailSizes:n.params.thumbnailSizes,requestId:n.requestId}),[4,this._requestQueue.send(r)];case 3:return i=s.sent(),a=i.as(Ot),o=a.url,u=a.fileSize,l=void 0===u?n.params.fileSize:u,h=a.thumbnailSizes,d=void 0===h?n.params.thumbnailSizes:h,p=a.requireAuth,_=void 0!==p&&p,n.params.fileUrl=o,n.params.fileSize=l,n.params.thumbnailSizes=d,n.params.requireAuth=_,n.requireAuth=_,n.state=Xt.UPLOADED,[3,7];case 4:return(v=s.sent()).code===c.REQUEST_FAILED?n.error=new f({code:c.NETWORK_ERROR,message:"Failed to upload a file."}):n.error=v,n.state=Xt.FAILED,[3,7];case 5:return(m=t.uploadQueue.findIndex((function(e){return e.requestId===n.requestId})))>=0&&(t.uploadQueue.splice(m,1),this._uploadNextPendingItem(e)),[4,this._resolveMessageQueue(e)];case 6:return s.sent(),[7];case 7:return[3,10];case 8:return n.state=Xt.FAILED,n.error=f.connectionRequired,(m=t.uploadQueue.findIndex((function(e){return e.requestId===n.requestId})))>=0&&(t.uploadQueue.splice(m,1),this._uploadNextPendingItem(e)),[4,this._resolveMessageQueue(e)];case 9:s.sent(),s.label=10;case 10:return[3,13];case 11:return n.params.thumbnailSizes=[],n.state=Xt.UPLOADED,[4,this._resolveMessageQueue(e)];case 12:s.sent(),s.label=13;case 13:return[2]}}))}))},e.prototype.request=function(e,t,n){var r,a,o;return i(this,void 0,void 0,(function(){var i;return s(this,(function(s){return i=new ee,T(n.file)&&(n.fileName=null!==(r=n.fileName)&&void 0!==r?r:n.file.name,n.mimeType=null!==(a=n.mimeType)&&void 0!==a?a:n.file.type,n.fileSize=null!==(o=n.fileSize)&&void 0!==o?o:n.file.size),this._queueMap.has(e.url)||this._queueMap.set(e.url,{messageQueue:[],uploadQueue:[],isResolving:!1,isResolveRequestPending:!1}),this._queueMap.get(e.url).messageQueue.push({requestId:t,params:n,state:Xt.PENDING,deferred:i,requireAuth:n.requireAuth}),this._uploadNextPendingItem(e),[2,i.promise]}))}))},e.prototype.cancel=function(e,t){var n,r;void 0===t&&(t=null);var i=this._queueMap.get(e.url);if(i){var s=t?[i.messageQueue.find((function(e){return e.requestId===t}))]:u([],o(i.messageQueue),!1);try{for(var c=a(s),l=c.next();!l.done;l=c.next()){var h=l.value;if(h)switch(h.state){case Xt.PENDING:h.state=Xt.FAILED,h.error=f.requestCanceled,this._resolveMessageQueue(e);break;case Xt.UPLOADING:this._requestQueue.cancel(h.requestId)}}}catch(e){n={error:e}}finally{try{l&&!l.done&&(r=c.return)&&r.call(c)}finally{if(n)throw n.error}}}},e}(),pn={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},fn=function(t){return g("number",t.prevResultSize)&&g("number",t.nextResultSize)&&g("boolean",t.isInclusive)&&g("boolean",t.reverse)&&g("string",t.messageTypeFilter)&&y(e.MessageTypeFilter,t.messageTypeFilter)&&b("string",t.customTypesFilter,!0)&&b("string",t.senderUserIdsFilter,!0)&&y(e.ReplyType,t.replyType)&&g("boolean",t.includeMetaArray)&&g("boolean",t.includeReactions)&&g("boolean",t.includeParentMessageInfo)&&g("boolean",t.includeThreadInfo)&&g("boolean",t.showSubchannelMessagesOnly)},_n={replyType:e.ReplyType.NONE,includeReactions:!1,includeThreadInfo:!1,includeMetaArray:!1,includeParentMessageInfo:!1},vn=function(t){return y(e.ReplyType,t.replyType)&&g("boolean",t.includeReactions)&&g("boolean",t.includeMetaArray)&&g("boolean",t.includeParentMessageInfo)&&g("boolean",t.includeThreadInfo)};e.MessageEventSource=void 0,(hn=e.MessageEventSource||(e.MessageEventSource={})).UNKNOWN="UNKNOWN",hn.EVENT_MESSAGE_SENT_SUCCESS="EVENT_MESSAGE_SENT_SUCCESS",hn.EVENT_MESSAGE_SENT_FAILED="EVENT_MESSAGE_SENT_FAILED",hn.EVENT_MESSAGE_SENT_PENDING="EVENT_MESSAGE_SENT_PENDING",hn.EVENT_MESSAGE_RECEIVED="EVENT_MESSAGE_RECEIVED",hn.EVENT_MESSAGE_UPDATED="EVENT_MESSAGE_UPDATED",hn.EVENT_MESSAGE_DELETED="EVENT_MESSAGE_DELETED",hn.EVENT_MESSAGE_READ="EVENT_MESSAGE_READ",hn.EVENT_MESSAGE_DELIVERED="EVENT_MESSAGE_DELIVERED",hn.EVENT_MESSAGE_REACTION_UPDATED="EVENT_MESSAGE_REACTION_UPDATED",hn.EVENT_MESSAGE_THREADINFO_UPDATED="EVENT_MESSAGE_THREADINFO_UPDATED",hn.EVENT_MESSAGE_OFFSET_UPDATED="EVENT_MESSAGE_OFFSET_UPDATED",hn.REQUEST_MESSAGE="REQUEST_MESSAGE",hn.EVENT_POLL_UPDATED="EVENT_POLL_UPDATED",hn.EVENT_POLL_VOTED="EVENT_POLL_VOTED",hn.SYNC_POLL_CHANGELOGS="SYNC_POLL_CHANGELOGS",hn.REQUEST_RESEND_MESSAGE="REQUEST_RESEND_MESSAGE",hn.REQUEST_THREADED_MESSAGE="REQUEST_THREADED_MESSAGE",hn.REQUEST_MESSAGE_CHANGELOGS="REQUEST_MESSAGE_CHANGELOGS",hn.SYNC_MESSAGE_FILL="SYNC_MESSAGE_FILL",hn.SYNC_MESSAGE_BACKGROUND="SYNC_MESSAGE_BACKGROUND",hn.SYNC_MESSAGE_CHANGELOGS="SYNC_MESSAGE_CHANGELOGS",hn.LOCAL_MESSAGE_PENDING_CREATED="LOCAL_MESSAGE_PENDING_CREATED",hn.LOCAL_MESSAGE_FAILED="LOCAL_MESSAGE_FAILED",hn.LOCAL_MESSAGE_CANCELED="LOCAL_MESSAGE_CANCELED",hn.LOCAL_MESSAGE_RESEND_STARTED="LOCAL_MESSAGE_RESEND_STARTED";var mn,gn=function(t){return t.startsWith("EVENT_")||t===e.MessageEventSource.SYNC_MESSAGE_FILL||t===e.MessageEventSource.SYNC_MESSAGE_CHANGELOGS||t===e.MessageEventSource.SYNC_POLL_CHANGELOGS},yn=function(e){function t(t){var n=t.messages,r=t.source,i=e.call(this)||this;return i.messages=n,i.source=r,i}return n(t,e),t}(k),En=function(e){function t(t){var n=t.messageIds,r=t.source,i=e.call(this)||this;return i.messageIds=n,i.source=r,i}return n(t,e),t}(k),bn=function(e){function t(t){var n=t.reqId,r=t.source,i=e.call(this)||this;return i.reqId=n,i.source=r,i}return n(t,e),t}(k),Cn=function(e){function t(t){var n=t.polls,r=t.source,i=e.call(this)||this;return i.polls=n,i.source=r,i}return n(t,e),t}(k),Tn=function(e){function t(t){var n=t.event,r=t.source,i=e.call(this)||this;return i.event=n,i.source=r,i}return n(t,e),t}(k),In=function(e){function t(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 n(t,e),t}(k),Sn=function(e){function t(t){var n=t.channelType,r=t.channelUrl,i=t.messageId,s=t.includeMetaArray,a=t.includeReactions,o=t.includeThreadInfo,u=t.includeParentMessageInfo,c=e.call(this)||this;return c.method=d.GET,c.path="".concat(Je(n),"/").concat(encodeURIComponent(r),"/messages/").concat(encodeURIComponent(i)),c.params={is_sdk:!0,with_sorted_meta_array:s,include_reactions:a,include_thread_info:o,include_parent_message_info:u,include_poll_details:!0},c}return n(t,e),t}(x),Nn=function(e){function t(t,n){var i=e.call(this,t,n)||this;return i.message=n?sn(t,r({},n)):null,i}return n(t,e),t}(F),wn=function(e){function t(t){var n=t.channelType,r=t.channelUrl,i=t.timestamp,s=void 0===i?null:i,a=t.token,o=void 0===a?null:a,u=t.prevResultSize,c=t.nextResultSize,l=t.isInclusive,h=t.reverse,p=t.messageTypeFilter,f=t.customTypesFilter,_=t.senderUserIdsFilter,v=t.replyType,m=t.includeMetaArray,g=t.includeReactions,y=t.parentMessageId,E=t.includeThreadInfo,b=t.includeParentMessageInfo,C=t.showSubchannelMessagesOnly,T=e.call(this)||this;return T.method=d.GET,T.path="".concat(Je(n),"/").concat(encodeURIComponent(r),"/messages"),T.params=D({is_sdk:!0,prev_limit:u,next_limit:c,include:l,reverse:h,message_ts:s,message_id:o,message_type:null!=p?p:null,custom_types:f,sender_ids:_,include_reply_type:v,with_sorted_meta_array:m,include_reactions:g,parent_message_id:y,include_thread_info:E,include_parent_message_info:b,show_subchannel_message_only:C,include_poll_details:!0}),T}return n(t,e),t}(x),Mn=function(e){function t(t,n){var r=e.call(this,t,n)||this;return r.messages=n.messages.map((function(e){return sn(t,e)})),r}return n(t,e),t}(F),An=function(e){function t(t){var n=t.channelType,r=t.channelUrl,i=t.timestamp,s=t.token,a=t.replyType,o=t.includeMetaArray,u=t.includeReactions,c=t.includeThreadInfo,l=t.includeParentMessageInfo,h=e.call(this)||this;return h.method=d.GET,h.path="".concat(Je(n),"/").concat(encodeURIComponent(r),"/messages/changelogs"),h.params={change_ts:i,token:s,with_sorted_meta_array:o,include_reactions:u,include_thread_info:c,include_reply_type:a,include_parent_message_info:l,include_poll_details:!0},h}return n(t,e),t}(x),Un=function(e){function t(t,n){var r=e.call(this,t,n)||this;return r.updatedMessages=n.updated.map((function(e){return sn(t,e)})),r.deletedMessagesInfo=n.deleted.map((function(e){return{messageId:e.message_id,deletedAt:e.deleted_at}})),r.hasMore=n.has_more,r.nextToken=n.next,r}return n(t,e),t}(F),On=function(e){function t(t){var n=t.channelUrl,r=t.scheduledMessageId,i=e.call(this)||this;return i.method=d.GET,i.path="".concat(ve,"/").concat(encodeURIComponent(n),"/scheduled_messages/").concat(encodeURIComponent(r)),i.params={},i}return n(t,e),t}(x),Rn=function(e){function t(t,n){var i=e.call(this,t,n)||this;return i.message=n?sn(t,r({},n)):null,i}return n(t,e),t}(F),Ln={},kn=function(){function t(e,t){var n=t.sdkState,r=t.dispatcher,i=t.requestQueue,s=t.onlineDetector,a=t.cacheContext;this._iid=e,this._sdkState=n,this._requestQueue=i,this._dispatcher=r,this._onlineDetector=s,this._cacheContext=a,this.fileMessageQueue=new dn(e,{sdkState:n,dispatcher:r,requestQueue:i,onlineDetector:s,cacheContext:a}),Ln[e]=this}return t.of=function(e){return Ln[e]},t.prototype.buildMessageFromSerializedData=function(t){var n=ut(t);switch(n.messageType){case e.MessageType.USER:return new nn(this._iid,nn.payloadify(n));case e.MessageType.FILE:return new an(this._iid,an.payloadify(n));case e.MessageType.ADMIN:return new Yt(this._iid,Yt.payloadify(n))}return null},t.prototype.buildUserMessageCreateParamsFromSerializedData=function(e,t){return D({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})},t.prototype.buildFileMessageCreateParamsFromSerializedData=function(e,t){return D({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.url,fileName:t.name,fileSize:t.size,mimeType:t.type,thumbnailSizes:t.thumbnails.map((function(e){return{maxWidth:e.width,maxHeight:e.height}})),fileType:e.fileType,requireAuth:t.requireAuth})},t.prototype.buildScheduledUserMessageCreateParamsFromSerializedData=function(e,t){return r(r({},this.buildUserMessageCreateParamsFromSerializedData(e,t)),{scheduledAt:e.scheduledAt})},t.prototype.buildScheduledFileMessageCreateParamsFromSerializedData=function(e,t){return r(r({},this.buildFileMessageCreateParamsFromSerializedData(e,t)),{scheduledAt:e.scheduledAt})},t.prototype.buildSenderFromSerializedData=function(e){var t=ut(e);return new Qt(this._iid,Qt.payloadify(t))},t.prototype.getMessage=function(e){return i(this,void 0,void 0,(function(){var t,n;return s(this,(function(r){switch(r.label){case 0:return t=new Sn(e),[4,this._requestQueue.send(t)];case 1:return n=r.sent(),[2,n.as(Nn).message]}}))}))},t.prototype.getScheduledMessage=function(e){return i(this,void 0,void 0,(function(){var t,n;return s(this,(function(r){switch(r.label){case 0:return t=new On(e),[4,this._requestQueue.send(t)];case 1:return n=r.sent(),[2,n.as(Rn).message]}}))}))},t.prototype.getMessagesByMessageId=function(t,n,a,o,u){return void 0===u&&(u=e.MessageEventSource.REQUEST_MESSAGE),i(this,void 0,void 0,(function(){var e,i,c;return s(this,(function(s){switch(s.label){case 0:return e=new wn(r(r({channelType:n,channelUrl:t,token:String(a)},pn),o)),[4,this._requestQueue.send(e)];case 1:return i=s.sent(),c=i.as(Mn).messages,this._dispatcher.dispatch(new yn({messages:c,source:u})),[2,c]}}))}))},t.prototype.getMessagesByTimestamp=function(t,n,a,o,u){return void 0===u&&(u=e.MessageEventSource.REQUEST_MESSAGE),i(this,void 0,void 0,(function(){var e,i,c;return s(this,(function(s){switch(s.label){case 0:return e=new wn(r(r({channelType:n,channelUrl:t,timestamp:a},pn),o)),[4,this._requestQueue.send(e)];case 1:return i=s.sent(),c=i.as(Mn).messages,this._dispatcher.dispatch(new yn({messages:c,source:u})),[2,c]}}))}))},t.prototype.getThreadedMessagesByTimestamp=function(t,n,a,o){return void 0===o&&(o=e.MessageEventSource.REQUEST_THREADED_MESSAGE),i(this,void 0,void 0,(function(){var i,u,c,l;return s(this,(function(s){switch(s.label){case 0:return i=new wn(r(r(r({channelUrl:t.channelUrl,channelType:t.channelType,timestamp:n},zt),a),{replyType:e.ReplyType.ALL,parentMessageId:t.messageId,includeThreadInfo:!0})),[4,this._requestQueue.send(i)];case 1:return u=s.sent(),c=u.as(Mn).messages,(l=c.slice(1)).forEach((function(e){e.parentMessage=t})),this._dispatcher.dispatch(new yn({messages:l,source:o})),[2,{parentMessage:c[0],threadedMessages:l}]}}))}))},t.prototype.getMessageChangelogs=function(t,n,a,o,u){return void 0===u&&(u=e.MessageEventSource.REQUEST_MESSAGE_CHANGELOGS),i(this,void 0,void 0,(function(){var e,i,c,l,h,d,p,f;return s(this,(function(s){switch(s.label){case 0:return e=new An(D(r(r({channelType:n,channelUrl:t,timestamp:"number"==typeof a?a:null,token:"string"==typeof a?a:null},_n),o))),[4,this._requestQueue.send(e)];case 1:return i=s.sent(),c=i.as(Un),l=c.updatedMessages,h=c.deletedMessagesInfo,d=c.hasMore,p=c.nextToken,f=h.map((function(e){return e.messageId})),l.length>0&&this._dispatcher.dispatch(new yn({messages:l,source:u})),f.length>0&&this._dispatcher.dispatch(new En({messageIds:f,source:u})),[2,{updatedMessages:l,deletedMessageIds:f,hasMore:d,token:p}]}}))}))},t}(),Dn=function(){function t(){this._onPending=J,this._onFailed=J,this._onSucceeded=J}return t.prototype._trigger=function(t,n){switch(n.sendingStatus){case e.SendingStatus.PENDING: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)}},t.prototype.onPending=function(e){return this._onPending=e,this},t.prototype.onFailed=function(e){return this._onFailed=e,this},t.prototype.onSucceeded=function(e){return this._onSucceeded=e,this},t}(),Pn=function(e){function t(t,n){var r=e.call(this,t)||this;r.threadInfo=null,r.targetMessageId=0,r.channelUrl=null,r.channelType=null;var i=n.thread_info,s=n.root_message_id,a=n.channel_url,o=n.channel_type;return i&&g("object",i)&&g("number",s)&&g("string",a)&&g("string",o)&&(r.threadInfo=new Rt(t,i),r.targetMessageId=s,r.channelUrl=a,r.channelType=o),r}return n(t,e),t}(We),xn={channelUrl:null,channelType:null,messageId:0,includeReactions:!1,includeMetaArray:!1,includeParentMessageInfo:!1,includeThreadInfo:!1},Fn=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 g("number",this.limit)&&this.limit>0},e}(),qn=function(e){function t(t){var n=t.channelCustomType,r=t.keyword,i=t.limit,s=t.reverse,a=t.exactMatch,o=t.channelUrl,u=t.order,c=t.messageTimestampFrom,l=t.messageTimestampTo,h=t.advancedQuery,p=t.targetFields,f=t.nextToken,_=e.call(this)||this;return _.method=d.GET,_.path="".concat(Ee,"/messages"),_.params={custom_type:n,query:r,limit:i,reverse:s,exact_match:a,channel_url:o,message_ts_from:c,message_ts_to:l,sort_field:u,advanced_query:h,target_fields:p,after:f},_}return n(t,e),t}(x),Gn=function(e){function t(t,n){var r=e.call(this,t,n)||this;return r.messages=n.results.map((function(e){return sn(t,e)})),r.hasNext=n.has_next,r.nextToken=n.end_cursor,r.totalCount=n.total_count,r}return n(t,e),t}(F);e.MessageSearchOrder=void 0,(mn=e.MessageSearchOrder||(e.MessageSearchOrder={})).SCORE="score",mn.TIMESTAMP="ts";var Hn,Vn,Kn,Qn=function(t){function a(n,r){var i,s,a,o,u,c,l,h,d,p=this;return(p=t.call(this,n,r)||this).keyword="",p.reverse=!1,p.exactMatch=!1,p.channelUrl="",p.channelCustomType="",p.messageTimestampFrom=null,p.messageTimestampTo=null,p.order=e.MessageSearchOrder.SCORE,p.advancedQuery=!1,p.targetFields=null,p._nextToken="",p.totalCount=-1,p.keyword=r.keyword,p.reverse=null!==(i=r.reverse)&&void 0!==i&&i,p.exactMatch=null!==(s=r.exactMatch)&&void 0!==s&&s,p.channelUrl=null!==(a=r.channelUrl)&&void 0!==a?a:"",p.channelCustomType=null!==(o=r.channelCustomType)&&void 0!==o?o:"",p.messageTimestampFrom=null!==(u=r.messageTimestampFrom)&&void 0!==u?u:null,p.messageTimestampTo=null!==(c=r.messageTimestampTo)&&void 0!==c?c:null,p.order=null!==(l=r.order)&&void 0!==l?l:e.MessageSearchOrder.SCORE,p.advancedQuery=null!==(h=r.advancedQuery)&&void 0!==h&&h,p.targetFields=null!==(d=r.targetFields)&&void 0!==d?d:null,p}return n(a,t),a.prototype._validate=function(){return t.prototype._validate.call(this)&&g("string",this.keyword)&&this.keyword.length>0&&g("boolean",this.reverse)&&g("boolean",this.exactMatch)&&g("string",this.channelUrl)&&g("string",this.channelCustomType)&&(g("number",this.messageTimestampFrom)||null===this.messageTimestampFrom)&&(g("number",this.messageTimestampTo)||null===this.messageTimestampTo)&&y(e.MessageSearchOrder,this.order)&&g("boolean",this.advancedQuery)&&b("string",this.targetFields,!0)},a.prototype.next=function(){return i(this,void 0,void 0,(function(){var e,t,n,i,a,o,u,c;return s(this,(function(s){switch(s.label){case 0:return this._validate()?this._isLoading?[3,3]:this._hasNext?(this._isLoading=!0,e=wt.of(this._iid).requestQueue,t=new qn(r(r({},this),{nextToken:this._nextToken?this._nextToken:null})),[4,e.send(t)]):[3,2]:[3,5];case 1:return n=s.sent(),i=n.as(Gn),a=i.messages,o=i.hasNext,u=i.nextToken,c=i.totalCount,this._nextToken=u,this._hasNext=o,this._isLoading=!1,this.totalCount=c,[2,a];case 2:return[2,[]];case 3:throw f.queryInProgress;case 4:return[3,6];case 5:throw f.invalidParameters;case 6:return[2]}}))}))},a}(Fn),Bn=function(t){function r(e,n,r,i){var s=t.call(this,e,i)||this;return s.channelUrl=n,s.channelType=r,s}return n(r,t),r.prototype._validate=function(){return t.prototype._validate.call(this)&&g("string",this.channelUrl)&&y(e.ChannelType,this.channelType)},r}(Fn),jn=function(t){function r(n,r,i,s){var a,o,u,c,l,h,d,p,f,_,v=this;return(v=t.call(this,n,r,i,s)||this).reverse=!1,v.messageTypeFilter=e.MessageTypeFilter.ALL,v.customTypesFilter=null,v.senderUserIdsFilter=null,v.replyType=e.ReplyType.NONE,v.includeMetaArray=!1,v.includeReactions=!1,v.includeParentMessageInfo=!1,v.includeThreadInfo=!1,v.showSubchannelMessagesOnly=!1,v._edge=Number.MAX_SAFE_INTEGER,v.reverse=null!==(a=s.reverse)&&void 0!==a&&a,v.messageTypeFilter=null!==(o=s.messageTypeFilter)&&void 0!==o?o:e.MessageTypeFilter.ALL,v.customTypesFilter=null!==(u=s.customTypesFilter)&&void 0!==u?u:null,v.senderUserIdsFilter=null!==(c=s.senderUserIdsFilter)&&void 0!==c?c:null,v.replyType=null!==(l=s.replyType)&&void 0!==l?l:e.ReplyType.NONE,v.includeMetaArray=null!==(h=s.includeMetaArray)&&void 0!==h&&h,v.includeReactions=null!==(d=s.includeReactions)&&void 0!==d&&d,v.includeParentMessageInfo=null!==(p=s.includeParentMessageInfo)&&void 0!==p&&p,v.includeThreadInfo=null!==(f=s.includeThreadInfo)&&void 0!==f&&f,v.showSubchannelMessagesOnly=null!==(_=s.showSubchannelMessagesOnly)&&void 0!==_&&_,v}return n(r,t),r.prototype._validate=function(){return t.prototype._validate.call(this)&&g("boolean",this.reverse)&&y(e.MessageTypeFilter,this.messageTypeFilter)&&y(e.ReplyType,this.replyType)&&b("string",this.customTypesFilter,!0)&&b("string",this.senderUserIdsFilter,!0)&&g("boolean",this.includeMetaArray)&&g("boolean",this.includeReactions)&&g("boolean",this.includeParentMessageInfo)&&g("boolean",this.includeThreadInfo)&&g("boolean",this.showSubchannelMessagesOnly)},r.prototype.load=function(){return i(this,void 0,void 0,(function(){var e;return s(this,(function(t){switch(t.label){case 0:return this._validate()?this._isLoading?[3,3]:this._hasNext?(this._isLoading=!0,[4,kn.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,u([Number.MAX_SAFE_INTEGER],o(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 f.queryInProgress;case 4:return[3,6];case 5:throw f.invalidParameters;case 6:return[2]}}))}))},r}(Bn),zn={channelUrl:null,scheduledMessageId:0},Wn=function(t){function a(){var e=null!==t&&t.apply(this,arguments)||this;return e.name="message",e}return n(a,t),a.prototype.init=function(e,n){var r=n.sdkState,i=n.dispatcher,s=n.sessionManager,a=n.requestQueue,o=n.logger,u=n.onlineDetector,c=n.cacheContext;t.prototype.init.call(this,e,{sdkState:r,dispatcher:i,sessionManager:s,requestQueue:a,logger:o,onlineDetector:u,cacheContext:c}),this._manager=new kn(e,{sdkState:r,dispatcher:i,requestQueue:a,onlineDetector:u,cacheContext:c})},a.prototype.buildMessageFromSerializedData=function(e){return this._manager.buildMessageFromSerializedData(e)},a.prototype.buildSenderFromSerializedData=function(e){return this._manager.buildSenderFromSerializedData(e)},a.prototype.getMessage=function(t){return i(this,void 0,void 0,(function(){var n;return s(this,(function(i){return n=r(r({},xn),t),ct(function(t){return g("string",t.channelUrl)&&g("string",t.channelType)&&y(e.ChannelType,t.channelType)&&g("number",t.messageId)&&g("boolean",t.includeMetaArray)&&g("boolean",t.includeParentMessageInfo)&&g("boolean",t.includeThreadInfo)}(n)).throw(f.invalidParameters),[2,this._manager.getMessage(n)]}))}))},a.prototype.getScheduledMessage=function(e){return i(this,void 0,void 0,(function(){var t;return s(this,(function(n){return t=r(r({},zn),e),ct(function(e){return g("string",e.channelUrl)&&g("number",e.scheduledMessageId)}(t)).throw(f.invalidParameters),[2,this._manager.getScheduledMessage(t)]}))}))},a}(At),Yn=function(e){function t(t){var n=t.title,r=t.optionTexts,i=t.data,s=t.isAnonymous,a=t.allowUserSuggestion,o=t.allowMultipleVotes,u=t.closeAt,c=e.call(this)||this;return c.method=d.POST,c.path=Ie,c.params={title:n,options:r,data:i,is_anonymous:s,allow_user_suggestion:a,allow_multiple_votes:o,close_at:u},c}return n(t,e),t}(x),Jn=function(e){function t(t,n){var r=e.call(this,t,n)||this;return r.poll=new tn(t,n),r}return n(t,e),t}(F),Xn=function(e){function t(t){var n=t.channelUrl,r=t.channelType,i=t.pollId,s=e.call(this)||this;return s.method=d.GET,s.path="".concat(Ie,"/").concat(encodeURIComponent(i)),s.params={channel_url:n,channel_type:r},s}return n(t,e),t}(x),Zn=function(e){function t(t,n){var r=e.call(this,t,n)||this;return r.poll=new tn(t,n),r}return n(t,e),t}(F),$n=function(e){function t(t){var n=t.channelUrl,r=t.channelType,i=t.pollId,s=t.pollOptionId,a=e.call(this)||this;return a.method=d.GET,a.path="".concat(Ie,"/").concat(encodeURIComponent(i),"/options/").concat(encodeURIComponent(s)),a.params={channel_url:n,channel_type:r},a}return n(t,e),t}(x),er=function(e){function t(t,n){var r=e.call(this,t,n)||this;return r.pollOption=new en(t,n),r}return n(t,e),t}(F),tr=function(e){function t(t){var n=t.channelType,r=t.channelUrl,i=t.timestamp,s=t.token,a=e.call(this)||this;return a.method=d.GET,a.path="".concat(Je(n),"/").concat(encodeURIComponent(r),"/polls/changelogs"),a.params=D({change_ts:i,token:s}),a}return n(t,e),t}(x),nr=function(e){function t(t,n){var r=e.call(this,t,n)||this;return r.updatedPolls=n.updated.map((function(e){return function(e,t){return t?new tn(e,t):null}(t,e)})),r.deletedPollIds=n.deleted.map((function(e){return e})),r.hasMore=n.has_more,r.nextToken=n.next,r}return n(t,e),t}(F),rr={title:null,optionTexts:null,data:null,isAnonymous:null,allowUserSuggestion:null,allowMultipleVotes:null,closeAt:-1},ir=function(e){return g("string",e.title)&&(t=e.optionTexts,b("string",t)&&t.every((function(e){return""!==e.trim()})))&&$t(e.data)&&g("boolean",e.isAnonymous,!0)&&g("boolean",e.allowUserSuggestion,!0)&&g("boolean",e.allowMultipleVotes,!0)&&g("number",e.closeAt,!0);var t},sr={channelUrl:null,channelType:null,pollId:null,pollOptionId:null},ar=function(t){return g("string",t.channelUrl)&&y(e.ChannelType,t.channelType)&&g("number",t.pollId)&&g("number",t.pollOptionId)},or={channelUrl:null,channelType:null,pollId:null},ur=function(t){return g("string",t.channelUrl)&&""!==t.channelUrl&&y(e.ChannelType,t.channelType)&&g("number",t.pollId)},cr={},lr=function(){function t(e,t){var n=t.sdkState,r=t.dispatcher,i=t.sessionManager,s=t.requestQueue,a=t.logger;this._iid=e,this._sdkState=n,this._sessionManager=i,this._requestQueue=s,this._dispatcher=r,this._logger=a,cr[e]=this}return t.of=function(e){return cr[e]},t.prototype.get=function(e){return i(this,void 0,void 0,(function(){var t,n;return s(this,(function(i){switch(i.label){case 0:return ct(ur(e)).throw(f.invalidParameters),t=new Xn(r({},e)),[4,this._requestQueue.send(t)];case 1:return n=i.sent(),[2,n.as(Zn).poll]}}))}))},t.prototype.create=function(e){return i(this,void 0,void 0,(function(){var t,n,i;return s(this,(function(s){switch(s.label){case 0:return ct(ir(e)).throw(f.invalidParameters),t=e.data,n=new Yn(r(r({},e),{data:t})),[4,this._requestQueue.send(n)];case 1:return i=s.sent(),[2,i.as(Jn).poll]}}))}))},t.prototype.getOption=function(e){return i(this,void 0,void 0,(function(){var t,n;return s(this,(function(i){switch(i.label){case 0:return ct(ar(e)).throw(f.invalidParameters),t=new $n(r({},e)),[4,this._requestQueue.send(t)];case 1:return n=i.sent(),[2,n.as(er).pollOption]}}))}))},t.prototype.getPollChangeLogs=function(t,n,r,a){return void 0===a&&(a=e.MessageEventSource.SYNC_POLL_CHANGELOGS),i(this,void 0,void 0,(function(){var e,i,o,u,c,l,h;return s(this,(function(s){switch(s.label){case 0:return e=new tr(D({channelType:n,channelUrl:t,timestamp:"number"==typeof r?r:null,token:"string"==typeof r?r:null})),[4,this._requestQueue.send(e)];case 1:return i=s.sent(),o=i.as(nr),u=o.updatedPolls,c=o.deletedPollIds,l=o.hasMore,h=o.nextToken,u.length>0&&this._dispatcher.dispatch(new Cn({polls:u,source:a})),[2,{updatedPolls:u,deletedPollIds:c,hasMore:l,token:h}]}}))}))},t}(),hr=function(e,t){this.pollId=0,this.messageId=0,this.pollId=t.poll.id,this.messageId=t.poll.message_id,this._iid=e,this._payload=t},dr=function(e){this.pollId=0,this.messageId=0,this.pollId=e.poll_id,this.messageId=e.message_id,this._payload=e},pr=function(e){function t(t){var n=t.channelUrl,r=t.channelType,i=t.token,s=t.limit,a=e.call(this)||this;return a.method=d.GET,a.path=Ie,a.params={channel_url:n,channel_type:r,token:i,limit:s},a}return n(t,e),t}(x),fr=function(e){function t(t,n){var r,i=this;return(i=e.call(this,t,n)||this).polls=(null!==(r=n.polls)&&void 0!==r?r:[]).map((function(e){return new tn(t,e)})),i.token=n.next,i}return n(t,e),t}(F),_r=function(e){function t(t,n){return e.call(this,t,n.channelUrl,n.channelType,n)||this}return n(t,e),t.prototype.next=function(){return i(this,void 0,void 0,(function(){var e,t,n,i,a,o;return s(this,(function(s){switch(s.label){case 0:return this._validate()?this._isLoading?[3,3]:this._hasNext?(this._isLoading=!0,e=wt.of(this._iid).requestQueue,t=new pr(r(r({},this),{token:this._token})),[4,e.send(t)]):[3,2]:[3,5];case 1:return n=s.sent(),i=n.as(fr),a=i.polls,o=i.token,this._token=o,this._hasNext=!!o,this._isLoading=!1,[2,a];case 2:return[2,[]];case 3:throw f.queryInProgress;case 4:return[3,6];case 5:throw f.invalidParameters;case 6:return[2]}}))}))},t}(Bn),vr=function(e){function t(t){var n=t.channelUrl,r=t.channelType,i=t.pollId,s=t.pollOptionId,a=t.token,o=t.limit,u=e.call(this)||this;return u.method=d.GET,u.path="".concat(Ie,"/").concat(encodeURIComponent(i),"/options/").concat(encodeURIComponent(s),"/voters"),u.params={channel_url:n,channel_type:r,token:a,limit:o},u}return n(t,e),t}(x),mr=function(e){function t(t,n){var r,i=this;return(i=e.call(this,t,n)||this).voters=(null!==(r=n.voters)&&void 0!==r?r:[]).map((function(e){return new ht(t,e)})),i.token=n.next,i}return n(t,e),t}(F),gr=function(e){function t(t,n){var r=e.call(this,t,n.channelUrl,n.channelType,n)||this;return r.pollId=n.pollId,r.pollOptionId=n.pollOptionId,r}return n(t,e),t.prototype._validate=function(){return e.prototype._validate.call(this)&&g("number",this.pollId)&&g("number",this.pollOptionId)},t.prototype.next=function(){return i(this,void 0,void 0,(function(){var e,t,n,i,a,o;return s(this,(function(s){switch(s.label){case 0:return this._validate()?this._isLoading?[3,3]:this._hasNext?(this._isLoading=!0,e=wt.of(this._iid).requestQueue,t=new vr(r(r({},this),{pollId:this.pollId,pollOptionId:this.pollOptionId,token:this._token})),[4,e.send(t)]):[3,2]:[3,5];case 1:return n=s.sent(),i=n.as(mr),a=i.voters,o=i.token,this._token=o,this._hasNext=!!o,this._isLoading=!1,[2,a];case 2:return[2,[]];case 3:throw f.queryInProgress;case 4:return[3,6];case 5:throw f.invalidParameters;case 6:return[2]}}))}))},t}(Bn),yr=function(e){function t(){var t=null!==e&&e.apply(this,arguments)||this;return t.name="poll",t}return n(t,e),t.prototype.init=function(t,n){var r=n.sdkState,i=n.dispatcher,s=n.sessionManager,a=n.requestQueue,o=n.logger,u=n.onlineDetector,c=n.cacheContext;e.prototype.init.call(this,t,{sdkState:r,dispatcher:i,sessionManager:s,requestQueue:a,logger:o,onlineDetector:u,cacheContext:c}),this._manager=new lr(t,{sdkState:r,dispatcher:i,sessionManager:s,requestQueue:a,logger:o,onlineDetector:u,cacheContext:c})},t.prototype.create=function(e){return i(this,void 0,void 0,(function(){var t;return s(this,(function(n){return t=r(r({},rr),e),ct(ir(t)).throw(f.invalidParameters),[2,this._manager.create(t)]}))}))},t.prototype.get=function(e){return i(this,void 0,void 0,(function(){var t;return s(this,(function(n){return t=r(r({},or),e),ct(ur(t)).throw(f.invalidParameters),[2,this._manager.get(t)]}))}))},t.prototype.getOption=function(e){return i(this,void 0,void 0,(function(){var t;return s(this,(function(n){return t=r(r({},sr),e),ct(ar(t)).throw(f.invalidParameters),[2,this._manager.getOption(t)]}))}))},t}(At),Er={profileImage:null,profileUrl:null,nickname:null},br=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=J,this.onSessionTokenRequired=function(e){return e(null)},this.onSessionError=J,this.onSessionRefreshed=J,this.onSessionClosed=J})),Cr=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=J,this.onReconnectStarted=J,this.onReconnectSucceeded=J,this.onReconnectFailed=J,this.onDisconnected=J})),Tr=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=J,this.onTotalUnreadMessageCountUpdated=J})),Ir="GroupChannel",Sr="Message";e.GroupChannelListOrder=void 0,(Hn=e.GroupChannelListOrder||(e.GroupChannelListOrder={})).LATEST_LAST_MESSAGE="latest_last_message",Hn.CHRONOLOGICAL="chronological",Hn.CHANNEL_NAME_ALPHABETICAL="channel_name_alphabetical",Hn.METADATA_VALUE_ALPHABETICAL="metadata_value_alphabetical",e.PublicGroupChannelListOrder=void 0,(Vn=e.PublicGroupChannelListOrder||(e.PublicGroupChannelListOrder={})).CHRONOLOGICAL="chronological",Vn.CHANNEL_NAME_ALPHABETICAL="channel_name_alphabetical",Vn.METADATA_VALUE_ALPHABETICAL="metadata_value_alphabetical",e.ScheduledMessageListOrder=void 0,(Kn=e.ScheduledMessageListOrder||(e.ScheduledMessageListOrder={})).CREATED_AT="created_at",Kn.SCHEDULED_AT="scheduled_at";var Nr,wr=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"]}},Mr=function(){function t(){this.messageTypeFilter=e.MessageTypeFilter.ALL,this.customTypesFilter=null,this.senderUserIdsFilter=null,this.replyType=e.ReplyType.NONE}return t.prototype.clone=function(){var e=new t,n=JSON.parse(JSON.stringify(this));return Object.keys(n).forEach((function(t){e[t]=n[t]})),e},t.prototype.match=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 Bt))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 Bt&&t.parentMessageId>0&&!t.replyToChannel)return!1}return!0},t}();!function(e){e.CHANNEL_LATEST="channel_latest",e.NEWEST_CHILD_MESSAGE="newest_child_message"}(Nr||(Nr={}));var Ar,Ur=function(e){switch(e){case Nr.CHANNEL_LATEST:return["channelUrl","-createdAt","-messageId"];case Nr.NEWEST_CHILD_MESSAGE:return["channelUrl","-parentMessageId","-createdAt","-messageId"]}},Or={data:null,customType:null,mentionType:e.MentionType.USERS,mentionedUserIds:null,mentionedUsers:null,mentionedMessageTemplate:null,metaArrays:null,parentMessageId:null,isReplyToChannel:!1,pushNotificationDeliveryOption:null,appleCriticalAlertOptions:null},Rr=function(t){return g("string",t.data,!0)&&g("string",t.customType,!0)&&y(e.MentionType,t.mentionType)&&b("string",t.mentionedUserIds,!0)&&b(ht,t.mentionedUsers,!0)&&g("string",t.mentionedMessageTemplate,!0)&&b(xt,t.metaArrays,!0)&&g("number",t.parentMessageId,!0)&&g("boolean",t.isReplyToChannel)&&y(e.PushNotificationDeliveryOption,t.pushNotificationDeliveryOption,!0)&&g(Gt,t.appleCriticalAlertOptions,!0)},Lr=function(e){return e?{isReplyToChannel:e.isReplyToChannel,pushNotificationDeliveryOption:e.pushNotificationDeliveryOption,pollId:e.pollId}:null},kr=r(r({},Or),{message:null,translationTargetLanguages:null,pollId:null}),Dr=function(e){return Rr(e)&&g("string",e.message)&&b("string",e.translationTargetLanguages,!0)&&g("number",e.pollId,!0)};!function(e){e.FILE="file",e.BLOB="blob",e.BLOB_LIKE_OBJECT="blobLikeObject",e.URL="url"}(Ar||(Ar={}));var Pr,xr=function(e){return"undefined"!=typeof window&&"Blob"in window&&"undefined"!=typeof Blob&&e instanceof Blob},Fr=function(e){return e===Ar.BLOB||e===Ar.FILE},qr=function(e){return e?{file:e.file,fileKey:e.fileKey,fileType:e.fileType,isReplyToChannel:e.isReplyToChannel,pushNotificationDeliveryOption:e.pushNotificationDeliveryOption}:null},Gr=r(r({},Or),{file:null,fileKey:null,fileUrl:null,fileName:null,fileType:null,fileSize:null,mimeType:null,thumbnailSizes:null,requireAuth:!1}),Hr=function(e){return Rr(e)&&(T(e.file)||g("string",e.fileUrl))&&g("string",e.fileName,!0)&&g("string",e.mimeType,!0)&&g("number",e.fileSize,!0)&&(null===e.thumbnailSizes||Array.isArray(e.thumbnailSizes)&&e.thumbnailSizes.every((function(e){return g("object",e)&&e.maxWidth>0&&e.maxHeight>0})))},Vr=r(r({},kr),{scheduledAt:null}),Kr=r(r({},Or),{scheduledAt:null,file:null,fileUrl:null,fileName:null,mimeType:null,fileSize:null,thumbnailSizes:null,requireAuth:!1}),Qr="UnsentMessage",Br={},jr=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,Br[t]=s,s}return n(t,e),t.of=function(e){return Br[e]},Object.defineProperty(t.prototype,"collection",{get:function(){var e=this._cacheContext.nestdb;return e&&e.collection(Qr)},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 f.invalidParameters;var t,n=r({},e.serialize());return e instanceof nn?(e.messageParams&&(n.messageParams=Lr(e.messageParams)),e.scheduledInfo&&e.scheduledInfo.scheduledMessageParams&&(n.scheduledInfo.scheduledMessageParams=(t=e.scheduledInfo.scheduledMessageParams,r(r({},Lr(t)),{scheduledAt:t.scheduledAt})))):e instanceof an&&(e.messageParams&&(n.messageParams=qr(e.messageParams)),e.scheduledInfo&&e.scheduledInfo.scheduledMessageParams&&(n.scheduledInfo.scheduledMessageParams=function(e){return r(r({},qr(e)),{scheduledAt:e.scheduledAt})}(e.scheduledInfo.scheduledMessageParams))),n},t.prototype._deserialize=function(e){return e?(e=r(r({},e),{messageId:parseInt(e.messageId)}),kn.of(this._iid).buildMessageFromSerializedData(e)):null},t.prototype._deserializeWithMessageCreateParams=function(e){return i(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=kn.of(this._iid),n=this._deserialize(e),e.messageParams?n instanceof nn?(r=e.messageParams,n.messageParams=t.buildUserMessageCreateParamsFromSerializedData(r,n),[3,4]):[3,1]:[3,4];case 1:return n instanceof an?(r=e.messageParams).fileKey&&"string"==typeof r.fileKey&&Fr(r.fileType)?(i=r,[4,this.collection.getBlob(r.fileKey)]):[3,3]:[3,4];case 2:i.file=s.sent(),s.label=3;case 3:n.messageParams=t.buildFileMessageCreateParamsFromSerializedData(r,n),s.label=4;case 4:return n.scheduledInfo&&e.scheduledInfo&&e.scheduledInfo.scheduledMessageParams?n instanceof nn?(a=e.scheduledInfo.scheduledMessageParams,n.scheduledInfo.scheduledMessageParams=t.buildScheduledUserMessageCreateParamsFromSerializedData(a,n),[3,8]):[3,5]:[3,8];case 5:return n instanceof an?(a=e.scheduledInfo.scheduledMessageParams).fileKey&&"string"==typeof a.fileKey&&Fr(a.fileType)?(o=a,[4,this.collection.getBlob(a.fileKey)]):[3,7]:[3,8];case 6:o.file=s.sent(),s.label=7;case 7:n.scheduledInfo.scheduledMessageParams=t.buildScheduledFileMessageCreateParamsFromSerializedData(a,n),s.label=8;case 8:return[2,n]}}))}))},t.prototype.get=function(e){return i(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,r=e.filter,a=void 0===r?new Mr:r,o=e.order,u=void 0===o?Nr.CHANNEL_LATEST:o,c=e.sendingStatus,l=void 0===c?null:c,h=e.backward,d=void 0!==h&&h,p=e.parentMessageId,f=void 0===p?null:p;return i(this,void 0,void 0,(function(){var e,t,r,o,c=this;return s(this,(function(h){switch(h.label){case 0:return this.localCacheEnabled?(e=Ur(u),t={"/where":function(e){return!!(u!==Nr.NEWEST_CHILD_MESSAGE||f&&0!==e.parentMessageId&&e.parentMessageId===f)&&a.match(c._deserialize(e))}},n&&(t.channelUrl=n),l&&(t.sendingStatus=l),r={where:t,index:e,backward:d},[4,this.collection.query(r)]):[3,3];case 1:return[4,h.sent().fetch({})];case 2:return o=h.sent(),[2,Promise.all(o.map((function(e){return i(c,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 Mr),i(this,void 0,void 0,(function(){return s(this,(function(n){switch(n.label){case 0:return[4,this.fetch({filter:t,order:Nr.NEWEST_CHILD_MESSAGE,channelUrl:e.channelUrl,backward:!1,parentMessageId:e.messageId})];case 1:return[2,n.sent()]}}))}))},t.prototype.upsert=function(e){return i(this,void 0,void 0,(function(){var t,n=this;return s(this,(function(r){switch(r.label){case 0:return this.localCacheEnabled?[4,this.saveBlobs(e)]:[3,3];case 1:return r.sent(),t=e.map((function(e){return n._serialize(e)})),[4,this.collection.upsertMany(t)];case 2:r.sent(),r.label=3;case 3:return[2]}}))}))},t.prototype.upsertChildMessages=function(e){return i(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 i(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 i(this,void 0,void 0,(function(){var t,n,r,i,o,u;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=a(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 i=s.sent(),o={error:i},[3,8];case 7:try{n&&!n.done&&(u=t.return)&&u.call(t)}finally{if(o)throw o.error}return[7];case 8:return[2]}}))}))},t.prototype.removeMessagesOfChannel=function(e){return i(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 i(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.saveBlobs=function(e){return i(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 i(t,void 0,void 0,(function(){var t,n,r;return s(this,(function(i){switch(i.label){case 0:return e instanceof an?e.messageParams&&(t=e.messageParams).file&&xr(t.file)?[4,this.collection.saveBlob(t.file,e.reqId)]:[3,2]:[3,4];case 1:r=i.sent(),t.fileKey=r,t.fileType=Ar.BLOB,i.label=2;case 2:return e.scheduledInfo&&e.scheduledInfo.scheduledMessageParams&&((n=e.scheduledInfo.scheduledMessageParams).file&&xr(n.file))?[4,this.collection.saveBlob(n.file,e.reqId)]:[3,4];case 3:r=i.sent(),n.fileKey=r,n.fileType=Ar.BLOB,i.label=4;case 4:return[2]}}))}))})))];case 1:return n.sent(),[2]}}))}))},t}(We),zr={},Wr=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,zr[t]=a,a}return n(t,e),t.of=function(e){return zr[e]},Object.defineProperty(t.prototype,"collection",{get:function(){var e=this._cacheContext.nestdb;return e?e.collection(Sr):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 r(r({},e.serialize()),{messageId:"".concat(e.messageId)})},t.prototype._deserialize=function(e){return e=r(r({},e),{messageId:parseInt(e.messageId)}),kn.of(this._iid).buildMessageFromSerializedData(e)},t.prototype.get=function(e){return i(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,r=e.limit,a=void 0===r?100:r,o=e.filter,u=void 0===o?new Mr:o,c=e.order,l=void 0===c?Nr.CHANNEL_LATEST:c,h=e.backward,d=void 0!==h&&h,p=e.parentMessageId,f=void 0===p?null:p;return i(this,void 0,void 0,(function(){var e,r,o,c=this;return s(this,(function(h){switch(h.label){case 0:return this.localCacheEnabled?(e=Ur(l),r={where:{channelUrl:t,"/where":function(e){if(n)switch(l){case Nr.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 i(this,void 0,void 0,(function(){var t,n,r,i,o,u;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=a(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 i=s.sent(),o={error:i},[3,8];case 7:try{n&&!n.done&&(u=t.return)&&u.call(t)}finally{if(o)throw o.error}return[7];case 8:return[2]}}))}))},t.prototype.removeMessagesOfChannel=function(e){return i(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:Ur(Nr.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 i(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:Ur(Nr.CHANNEL_LATEST)})]:[3,2];case 1:n.sent(),n.label=2;case 2:return[2]}}))}))},t.prototype.clear=function(){return i(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 i(this,void 0,void 0,(function(){var r,i=this;return s(this,(function(s){switch(s.label){case 0:return this.localCacheEnabled?(r=Ur(Nr.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 i(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 i(t,void 0,void 0,(function(){var t,n;return s(this,(function(r){switch(r.label){case 0:return e instanceof an&&e.messageParams&&((t=e.messageParams).file&&xr(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}(We),Yr=function(e){function t(){var t=e.call(this)||this;return t._pauseDelayTimer=null,t._currentState="visible",t._toggleState=t._toggleState.bind(t),t}return n(t,e),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;"hidden"!==document.visibilityState?"hidden"===this._currentState&&(this._pauseDelayTimer&&(clearTimeout(this._pauseDelayTimer),this._pauseDelayTimer=null),this.dispatch("resume")):"hidden"!==this._currentState&&(this._pauseDelayTimer=setTimeout((function(){e._pauseDelayTimer=null,e.dispatch("pause")}),3e4)),this._currentState=document.visibilityState},t.prototype.start=function(){this.isAvailable&&window.addEventListener("visibilitychange",this._toggleState,{capture:!0})},t.prototype.stop=function(){this.isAvailable&&window.removeEventListener("visibilitychange",this._toggleState,{capture:!0})},t}(R),Jr=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 i(this,void 0,void 0,(function(){return s(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}(),Xr=function(e){function t(t){var n=t.message,r=e.call(this)||this;return r.message=n,r}return n(t,e),t}(k),Zr={},$r=function(){function t(e,t){var n=t.localCacheEnabled,r=t.dispatcher,i=t.sdkState,s=t.logger,a=this;Zr[e]=this,this._iid=e,Zr[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 he)switch(e.stateType){case X.CONNECTED:a._isProcessingAutoResend||a.processAutoResendRegisteredPendingMessages().then((function(){return a._processNextAutoResend()}));break;case X.DISCONNECTED:a._isProcessingAutoResend=!1}}))}return t.of=function(e){return Zr[e]},t.prototype.processNonAutoResendRegisteredPendingMessages=function(){return i(this,void 0,void 0,(function(){var t,n,r,i,o,u;return s(this,(function(s){switch(s.label){case 0:return[4,this._fetchAllCachedPendingMessages()];case 1:t=s.sent();try{for(n=a(t),r=n.next();!r.done;r=n.next())0===(i=r.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=c.ACK_TIMEOUT,this._dispatcher.dispatch(new yn({messages:[i],source:e.MessageEventSource.LOCAL_MESSAGE_FAILED})))}catch(e){o={error:e}}finally{try{r&&!r.done&&(u=n.return)&&u.call(n)}finally{if(o)throw o.error}}return[2]}}))}))},t.prototype.processAutoResendRegisteredPendingMessages=function(){return i(this,void 0,void 0,(function(){var t,n,r,i,o,u,c,l;return s(this,(function(s){switch(s.label){case 0:return[4,this._fetchAllCachedPendingMessages()];case 1:t=s.sent();try{for(n=a(t),r=n.next();!r.done;r=n.next())(i=r.value).errorCode&&C(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 yn({messages:[i],source:e.MessageEventSource.LOCAL_MESSAGE_FAILED}))))}catch(e){c={error:e}}finally{try{r&&!r.done&&(l=n.return)&&l.call(n)}finally{if(c)throw c.error}}return[2]}}))}))},t.prototype.completeCurrentAndProcessNextAutoResend=function(t){if(this._localCacheEnabled&&(t.sendingStatus===e.SendingStatus.SUCCEEDED||t.sendingStatus===e.SendingStatus.FAILED&&!C(t.errorCode))){var n=this.indexOf(t);n>=0&&this._autoResendQueue.splice(n,1),0===n&&this._processNextAutoResend()}},t.prototype._fetchAllCachedPendingMessages=function(){return i(this,void 0,void 0,(function(){var t,n;return s(this,(function(r){switch(r.label){case 0:return(t=jr.of(this._iid))?[4,t.fetch({sendingStatus:e.SendingStatus.PENDING,backward:!0})]:[3,2];case 1:return n=r.sent(),[3,3];case 2:n=[],r.label=3;case 3:return[2,n]}}))}))},t.prototype.indexOf=function(e){return this._autoResendQueue.length>0?this._autoResendQueue.map((function(e){return e.reqId})).indexOf(e.reqId):-1},t.prototype._isNotInQueue=function(e){return-1===this._autoResendQueue.map((function(e){return e.reqId})).indexOf(e.reqId)},t.prototype._processNextAutoResend=function(){return i(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 Xr({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]}))}))},t}();!function(e){e[e.USER_BLOCK=20001]="USER_BLOCK",e[e.USER_UNBLOCK=2e4]="USER_UNBLOCK",e[e.FRIEND_DISCOVERED=20900]="FRIEND_DISCOVERED"}(Pr||(Pr={}));var ei=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 ht(e,r),blockee:new ht(e,i)}},e.getDataAsFriendDiscoveredEvent=function(e,t){var n=t.data.friend_discoveries;return{friendDiscoveries:Array.isArray(n)?n.map((function(t){return new ht(e,t)})):[]}},e}(),ti=function(e){function t(t,n){var r=n.userId,i=e.call(this)||this;return i._iid=t,i.userId=r,i}return n(t,e),t}(k),ni=function(e){function t(t,n,r){var i=e.call(this,t,"USEV",r)||this;return i.event=new ei(r),i}return n(t,e),t}(j),ri=function(e){function t(t){var n=t.userId,r=t.nickname,i=void 0===r?null:r,s=t.profileUrl,a=void 0===s?null:s,o=t.profileImage,u=void 0===o?null:o,c=t.preferredLanguages,l=void 0===c?null:c,h=e.call(this)||this;return h.method=d.PUT,h.path="".concat(fe,"/").concat(encodeURIComponent(n)),h.params=D({nickname:i,profile_url:a,profile_file:u,preferred_languages:l}),h}return n(t,e),t}(x),ii=function(e){function t(t,n){var i=e.call(this,t,n)||this;return i.user=null,i.user=new ht(t,r({},n)),i}return n(t,e),t}(F),si=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(fe,"/").concat(encodeURIComponent(n),"/push/apns"),i.params={apns_device_token:r,always_push:!0},i}return n(t,e),t}(x);!function(t){function r(n,r){var i=t.call(this,n,r)||this;return i.token=r.token,i.type=r.type?e.PushTokenType[r.type.toLowerCase()]:e.PushTokenType.UNKNOWN,i.user=new ht(n,r.user),i}n(r,t)}(F);var ai=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(fe,"/").concat(encodeURIComponent(n),"/push/gcm"),i.params={gcm_reg_token:r,always_push:!0},i}return n(t,e),t}(x);!function(t){function r(n,r){var i=t.call(this,n,r)||this;return i.token=r.token,i.type=r.type?e.PushTokenType[r.type.toLowerCase()]:e.PushTokenType.UNKNOWN,i.user=new ht(n,r.user),i}n(r,t)}(F);var oi=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(fe,"/").concat(encodeURIComponent(n),"/push/apns/").concat(encodeURIComponent(r)),i}return n(t,e),t}(x);!function(e){function t(t,n){var r=e.call(this,t,n)||this;return r.token=n.token,r.user=new ht(t,n.user),r}n(t,e)}(F);var ui=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(fe,"/").concat(encodeURIComponent(n),"/push/gcm/").concat(encodeURIComponent(r)),i}return n(t,e),t}(x);!function(e){function t(t,n){var r=e.call(this,t,n)||this;return r.token=n.token,r.user=new ht(t,n.user),r}n(t,e)}(F);var ci=function(e){function t(t){var n=t.userId,r=e.call(this)||this;return r.method=d.DELETE,r.path="".concat(fe,"/").concat(encodeURIComponent(n),"/push/apns"),r}return n(t,e),t}(x);!function(t){function r(n,r){var i=t.call(this,n,r)||this;return i.type=r.type?e.PushTokenType[r.type.toLowerCase()]:e.PushTokenType.UNKNOWN,i.user=new ht(n,r.user),i}n(r,t)}(F);var li=function(e){function t(t){var n=t.userId,r=e.call(this)||this;return r.method=d.DELETE,r.path="".concat(fe,"/").concat(encodeURIComponent(n),"/push/gcm"),r}return n(t,e),t}(x);!function(t){function r(n,r){var i=t.call(this,n,r)||this;return i.type=r.type?e.PushTokenType[r.type.toLowerCase()]:e.PushTokenType.UNKNOWN,i.user=new ht(n,r.user),i}n(r,t)}(F);var hi=function(e){function t(t){var n=t.userId,r=t.type,i=t.token,s=t.ts,a=e.call(this)||this;return a.method=d.GET,a.path="".concat(fe,"/").concat(encodeURIComponent(n),"/push/").concat(encodeURIComponent(r),"/device_tokens"),a.params={created_ts:s,token:i},a}return n(t,e),t}(x),di=function(t){function r(n,r){var i=t.call(this,n,r)||this;return i.pushTokens={type:r.type?e.PushTokenType[r.type.toLowerCase()]:e.PushTokenType.UNKNOWN,deviceTokens:r.device_tokens,hasMore:r.has_more,token:r.token},i}return n(r,t),r}(F),pi=function(e){function t(t){var n=t.userId,r=e.call(this)||this;return r.method=d.GET,r.path="".concat(fe,"/").concat(encodeURIComponent(n),"/channel_invitation_preference"),r}return n(t,e),t}(x),fi=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}(F),_i=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(fe,"/").concat(encodeURIComponent(n),"/channel_invitation_preference"),i.params={auto_accept:r},i}return n(t,e),t}(x),vi=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}(F),mi=function(e){function t(t){var n=t.userId,r=e.call(this)||this;return r.method=d.GET,r.path="".concat(fe,"/").concat(encodeURIComponent(n),"/push_preference"),r}return n(t,e),t}(x),gi=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}(F),yi=function(e){function t(t){var n=t.userId,r=t.doNotDisturbOn,i=t.startHour,s=t.startMin,a=t.endHour,o=t.endMin,u=t.timezone,c=e.call(this)||this;return c.method=d.PUT,c.path="".concat(fe,"/").concat(encodeURIComponent(n),"/push_preference"),c.params={do_not_disturb:r,start_hour:i,start_min:s,end_hour:a,end_min:o,timezone:u},c}return n(t,e),t}(x),Ei=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}(F),bi=function(e){function t(t){var n=t.userId,r=e.call(this)||this;return r.method=d.GET,r.path="".concat(fe,"/").concat(encodeURIComponent(n),"/push_preference"),r}return n(t,e),t}(x),Ci=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}(F),Ti=function(e){function t(t){var n=t.userId,r=t.snoozeOn,i=t.startTs,s=t.endTs,a=e.call(this)||this;return a.method=d.PUT,a.path="".concat(fe,"/").concat(encodeURIComponent(n),"/push_preference"),a.params={snooze_enabled:r,snooze_start_ts:i,snooze_end_ts:s},a}return n(t,e),t}(x),Ii=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}(F),Si=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(fe,"/").concat(encodeURIComponent(n),"/block"),i.params={target_id:r},i}return n(t,e),t}(x);!function(e){function t(t,n){var r=e.call(this,t,n)||this;return r.user=new ht(t,n),r}n(t,e)}(F);var Ni=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(fe,"/").concat(encodeURIComponent(n),"/block/").concat(encodeURIComponent(r)),i}return n(t,e),t}(x);!function(e){function t(){return null!==e&&e.apply(this,arguments)||this}n(t,e)}(F);var wi=function(e){function t(t){var n=t.userId,r=e.call(this)||this;return r.method=d.GET,r.path="".concat(fe,"/").concat(encodeURIComponent(n),"/push_preference"),r}return n(t,e),t}(x),Mi=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}(F),Ai=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(fe,"/").concat(encodeURIComponent(n),"/push_preference"),i.params={push_trigger_option:r},i}return n(t,e),t}(x),Ui=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}(F),Oi=function(e){function t(t){var n=t.userId,r=e.call(this)||this;return r.method=d.GET,r.path="".concat(fe,"/").concat(encodeURIComponent(n),"/push/template"),r}return n(t,e),t}(x),Ri=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}(F),Li=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(fe,"/").concat(encodeURIComponent(n),"/push/template"),i.params={name:r},i}return n(t,e),t}(x),ki=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}(F),Di=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(fe,"/").concat(encodeURIComponent(n),"/friends/changelogs"),i.params={token:r},i}return n(t,e),t}(x),Pi=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 ht(t,e)})),updatedUsers:n.updated.map((function(e){return new ht(t,e)})),deletedUserIds:n.deleted,hasMore:n.has_more,token:n.next},r}return n(t,e),t}(F),xi=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(fe,"/").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}(x),Fi=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}(F),qi=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(fe,"/").concat(encodeURIComponent(n),"/friend_discoveries"),i.params={friend_discovery_keys:r},i}return n(t,e),t}(x);!function(e){function t(){return null!==e&&e.apply(this,arguments)||this}n(t,e)}(F);var Gi=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(fe,"/").concat(encodeURIComponent(n),"/friends"),i.params={user_ids:r},i}return n(t,e),t}(x),Hi=function(e){function t(t,n){var r=e.call(this,t,n)||this;return r.users=n.users.map((function(e){return new ht(t,e)})),r}return n(t,e),t}(F),Vi=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(fe,"/").concat(encodeURIComponent(n),"/friends"),i.params={user_ids:r},i}return n(t,e),t}(x);!function(e){function t(){return null!==e&&e.apply(this,arguments)||this}n(t,e)}(F);var Ki=function(e){function t(t){var n=t.userId,r=e.call(this)||this;return r.method=d.GET,r.path="".concat(fe,"/").concat(n,"/allow_friend_discovery"),r.params={},r}return n(t,e),t}(x),Qi=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}(F),Bi=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(fe,"/").concat(n,"/allow_friend_discovery"),i.params={allow_friend_discovery:r},i}return n(t,e),t}(x);!function(e){function t(){return null!==e&&e.apply(this,arguments)||this}n(t,e)}(F);var ji,zi=function(e){this.key=null,this.url=null,this.key=e.key,this.url=e.url},Wi=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 zi(e)})):[]},Yi=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 Wi(e)})):[]},Ji=function(e){function t(){var t=e.call(this)||this;return t.method=d.GET,t.path=Te,t}return n(t,e),t}(x),Xi=function(e){function t(t,n){var r=e.call(this,t,n)||this;return r.emojiContainer=new Yi(n),r}return n(t,e),t}(F),Zi=function(e){function t(t){var n=t.categoryId,r=e.call(this)||this;return r.method=d.GET,r.path="".concat(Te,"/").concat(n),r}return n(t,e),t}(x),$i=function(e){function t(t,n){var r=e.call(this,t,n)||this;return r.emojiCategory=new Wi(n),r}return n(t,e),t}(F),es=function(e){function t(t){var n=t.key,r=e.call(this)||this;return r.method=d.GET,r.path="".concat(Ce,"/").concat(n),r}return n(t,e),t}(x),ts=function(e){function t(t,n){var r=e.call(this,t,n)||this;return r.emoji=new zi(n),r}return n(t,e),t}(F),ns=function(e){function t(t){var n=t.limit,r=t.token,i=t.userIdsFilter,s=t.metaDataKeyFilter,a=t.metaDataValuesFilter,o=t.nicknameStartsWithFilter,u=e.call(this)||this;return u.method=d.GET,u.path=fe,u.params=D({limit:n,token:r,user_ids:i,metadatakey:s,metadatavalues_in:a,nickname_startswith:o}),u}return n(t,e),t}(x),rs=function(e){function t(t,n){var r=e.call(this,t,n)||this;return r.users=n.users.map((function(e){return new ht(t,e)})),r.next=n.next,r}return n(t,e),t}(F),is=function(e){function t(t,n){var r,i,s,a=this;return(a=e.call(this,t,n)||this).userIdsFilter=null,a.metaDataKeyFilter=null,a.metaDataValuesFilter=null,a.nicknameStartsWithFilter=null,a.userIdsFilter=null!==(r=n.userIdsFilter)&&void 0!==r?r:null,a.metaDataKeyFilter=null!==(i=n.metaDataKeyFilter)&&void 0!==i?i:null,a.metaDataValuesFilter=null!==(s=n.metaDataValuesFilter)&&void 0!==s?s:null,a.nicknameStartsWithFilter=n.nicknameStartsWithFilter||null,a}return n(t,e),t.prototype._validate=function(){return e.prototype._validate.call(this)&&b("string",this.userIdsFilter,!0)&&g("string",this.metaDataKeyFilter,!0)&&b("string",this.metaDataValuesFilter,!0)&&g("string",this.metaDataKeyFilter,!0)},t.prototype.next=function(){return i(this,void 0,void 0,(function(){var e,t,n,i,a,o;return s(this,(function(s){switch(s.label){case 0:return this._validate()?this._isLoading?[3,3]:this._hasNext?(this._isLoading=!0,e=wt.of(this._iid).requestQueue,t=new ns(r(r({},this),{token:this._token})),[4,e.send(t)]):[3,2]:[3,5];case 1:return n=s.sent(),i=n.as(rs),a=i.users,o=i.next,this._token=o,this._hasNext=!!o,this._isLoading=!1,[2,a];case 2:return[2,[]];case 3:throw f.queryInProgress;case 4:return[3,6];case 5:throw f.invalidParameters;case 6:return[2]}}))}))},t}(Fn),ss=function(e){function t(t){var n=t.userId,r=t.limit,i=t.token,s=t.userIdsFilter,a=e.call(this)||this;return a.method=d.GET,a.path="".concat(fe,"/").concat(n,"/block"),a.params=D({limit:r,token:i,user_ids:s}),a}return n(t,e),t}(x),as=function(e){function t(t,n){var r=e.call(this,t,n)||this;return r.users=n.users.map((function(e){return new ht(t,e)})),r.next=n.next,r}return n(t,e),t}(F),os=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)&&b("string",this.userIdsFilter,!0)},t.prototype.next=function(){return i(this,void 0,void 0,(function(){var e,t,n,i,a,o,u,c;return s(this,(function(s){switch(s.label){case 0:return this._validate()?this._isLoading?[3,3]:this._hasNext?(this._isLoading=!0,e=wt.of(this._iid),t=e.sdkState,n=e.requestQueue,i=new ss(r(r({},this),{userId:t.userId,token:this._token})),[4,n.send(i)]):[3,2]:[3,5];case 1:return a=s.sent(),o=a.as(as),u=o.users,c=o.next,this._token=c,this._hasNext=!!c,this._isLoading=!1,[2,u];case 2:return[2,[]];case 3:throw f.queryInProgress;case 4:return[3,6];case 5:throw f.invalidParameters;case 6:return[2]}}))}))},t}(Fn),us=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(fe,"/").concat(encodeURIComponent(n),"/friends"),s.params={limit:r,token:i},s}return n(t,e),t}(x),cs=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 ht(t,e)})),r.next=n.next,r}return n(t,e),t}(F),ls=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 i(this,void 0,void 0,(function(){var e,t,n,i,a,o,u,c,l;return s(this,(function(s){switch(s.label){case 0:return this._validate()?this._isLoading?[3,3]:this._hasNext?(this._isLoading=!0,e=wt.of(this._iid),t=e.sdkState,n=e.requestQueue,i=new us(r(r({},this),{userId:t.userId,token:this._token})),[4,n.send(i)]):[3,2]:[3,5];case 1:return a=s.sent(),o=a.as(cs),u=o.users,c=o.hasMore,l=o.next,this._token=l,this._hasNext=c,this._isLoading=!1,[2,u];case 2:return[2,[]];case 3:throw f.queryInProgress;case 4:return[3,6];case 5:throw f.invalidParameters;case 6:return[2]}}))}))},t}(Fn),hs={},ds=function(){function e(e){var t=e.dbname,n=e.itemSizeLimit,r=void 0===n?1048576:n,i=e.cacheLimit,s=void 0===i?256:i,a=e.blockHashBase,o=void 0===a?2:a,u=e.blockHashMultiplier,c=void 0===u?10:u,l=e.blockHashConstant,h=void 0===l?11:l,d=e.transactionApplyDelay,p=void 0===d?200:d,f=e.disableLogger,_=void 0!==f&&f;return hs[t]||(this.itemSizeLimit=r,this.cacheLimit=s,this.blockHashBase=o,this.blockHashMultiplier=c,this.blockHashConstant=h,this.transactionApplyDelay=p,this.disableLogger=_,hs[t]=this),hs[t]}return e.get=function(e){return hs[e]},e}();!function(e){e[e.UNKNOWN_ERROR=6e7]="UNKNOWN_ERROR",e[e.STORE_NOT_DEFINED=61001e3]="STORE_NOT_DEFINED",e[e.STORE_NOT_AVAILABLE=61001001]="STORE_NOT_AVAILABLE",e[e.STORE_NOT_AVAILABLE_IN_PRIVATE_BROWSING=61001002]="STORE_NOT_AVAILABLE_IN_PRIVATE_BROWSING",e[e.STORE_IS_FULL=61001003]="STORE_IS_FULL",e[e.STORE_INVALID_KEY_TYPE=61002e3]="STORE_INVALID_KEY_TYPE",e[e.STORE_BROKEN_INTEGRITY=61002001]="STORE_BROKEN_INTEGRITY",e[e.STORE_BROKEN_BLOB=61002002]="STORE_BROKEN_BLOB",e[e.STORE_ENCRYPTION_INVALID=61002003]="STORE_ENCRYPTION_INVALID",e[e.STORE_ITEM_SIZE_LIMIT_EXCEEDED=61017e3]="STORE_ITEM_SIZE_LIMIT_EXCEEDED",e[e.STORE_READ_FAILED=61017001]="STORE_READ_FAILED",e[e.STORE_WRITE_FAILED=61017002]="STORE_WRITE_FAILED",e[e.DATABASE_SCHEMA_NOT_ON_UPGRADE=62002e3]="DATABASE_SCHEMA_NOT_ON_UPGRADE",e[e.COLLECTION_NOT_READY=63001e3]="COLLECTION_NOT_READY",e[e.COLLECTION_KEY_NOT_MATCH=63002e3]="COLLECTION_KEY_NOT_MATCH",e[e.COLLECTION_QUERY_NOT_VALID=63002001]="COLLECTION_QUERY_NOT_VALID",e[e.COLLECTION_KEY_NOT_FOUND=63004e3]="COLLECTION_KEY_NOT_FOUND",e[e.COLLECTION_KEY_NOT_GIVEN=63004001]="COLLECTION_KEY_NOT_GIVEN",e[e.COLLECTION_INSERT_DUPLICATE=63009e3]="COLLECTION_INSERT_DUPLICATE",e[e.COLLECTION_WRITE_FAILED=63017e3]="COLLECTION_WRITE_FAILED",e[e.COLLECTION_ITEM_SIZE_LIMIT_EXCEEDED=63017001]="COLLECTION_ITEM_SIZE_LIMIT_EXCEEDED",e[e.INDEX_TABLE_IS_REQUIRED=65001e3]="INDEX_TABLE_IS_REQUIRED",e[e.INDEX_TYPE_NOT_MATCH=65002e3]="INDEX_TYPE_NOT_MATCH",e[e.COMPARE_TYPE_NOT_MATCH=69002001]="COMPARE_TYPE_NOT_MATCH",e[e.CIRCULAR_REFERENCE_FOUND=69002002]="CIRCULAR_REFERENCE_FOUND"}(ji||(ji={}));var ps,fs=function(e){function t(n){var r=n.code,i=void 0===r?ji.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 n(t,e),Object.defineProperty(t,"storeNotDefined",{get:function(){return new t({code:ji.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:ji.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:ji.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:ji.STORE_IS_FULL,message:"Store is full."})},enumerable:!1,configurable:!0}),Object.defineProperty(t,"storeKeyTypeIsInvalid",{get:function(){return new t({code:ji.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:ji.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:ji.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:ji.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:ji.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:ji.STORE_READ_FAILED,message:"Failed to read from store."})},enumerable:!1,configurable:!0}),Object.defineProperty(t,"storeWriteFailed",{get:function(){return new t({code:ji.STORE_WRITE_FAILED,message:"Failed to write to store."})},enumerable:!1,configurable:!0}),Object.defineProperty(t,"databaseSchemaNotOnUpgrade",{get:function(){return new t({code:ji.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:ji.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:ji.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:ji.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:ji.COLLECTION_INSERT_DUPLICATE,message:"The key already exists."})},enumerable:!1,configurable:!0}),Object.defineProperty(t,"collectionKeyNotFound",{get:function(){return new t({code:ji.COLLECTION_KEY_NOT_FOUND,message:"The key is not found."})},enumerable:!1,configurable:!0}),Object.defineProperty(t,"collectionKeyNotGiven",{get:function(){return new t({code:ji.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:ji.COLLECTION_WRITE_FAILED,message:"Failed to write an item."})},enumerable:!1,configurable:!0}),Object.defineProperty(t,"collectionItemSizeExceeded",{get:function(){return new t({code:ji.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:ji.INDEX_TABLE_IS_REQUIRED,message:"Index table is required."})},enumerable:!1,configurable:!0}),Object.defineProperty(t,"indexTypesNotMatch",{get:function(){return new t({code:ji.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:ji.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:ji.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"}(ps||(ps={}));var _s,vs=function(e,t){if(void 0===t&&(t=new WeakMap),"object"==typeof e&&null!==e){if(t.has(e))throw fs.circularReferenceFound;t.set(e,!0);var n=null;if(Array.isArray(e))n=e.map((function(e){return vs(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]=vs(e[r],t);return t.delete(e),n}return e},ms=function(e,t){if(null==t)return 1;if(null==e)return-1;if(typeof e!=typeof t)throw fs.compareTypesNotMatch;var n=0;switch(typeof e){case"boolean":case"number":n=e-t;break;case"string":n=e.localeCompare(t)}return n},gs=function(e,t){for(var n=0,r=0;r>>0)%t},ys=function(e){return new Promise((function(t){setTimeout((function(){return t()}),e)}))},Es=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!Es(e,t)})))return!1}else if(["/or","||"].includes(n)){if(e[n].every((function(e){return!Es(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(!(ms(a,o)>0))return!1;break;case"/gte":case">=":a=t[r],o=i[s];if(!(ms(a,o)>=0))return!1;break;case"/lt":case"<":a=t[r],o=i[s];if(!(ms(a,o)<0))return!1;break;case"/lte":case"<=":a=t[r],o=i[s];if(!(ms(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)},bs=function(){},Cs=function(){return Promise.resolve()},Ts=function(e){return e},Is=function(e,t){t(null)};!function(e){e[e.FORWARD=0]="FORWARD",e[e.BACKWARD=1]="BACKWARD"}(_s||(_s={}));var Ss,Ns,ws,Ms=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?Ts:a,u=e.backward,c=void 0===u?Cs:u,l=e.forward,h=void 0===l?Cs:l,d=e.complete,p=void 0===d?bs:d;this._prevValue=n,this._nextValue=i,this._error=null,this._map=o,this._backward=c,this._forward=h,this._iterator=s,this._complete=p}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 i(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 i(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}(),As=function(){function e(e){var t=e.condition,n=void 0===t?{}:t,r=e.backward,i=void 0!==r&&r,s=e.blockManager,a=e.indexer;this.condition=n,this.backward=i,this._blockManager=s,this._indexer=a}return e.prototype.findOptimizedStartPosition=function(){var e=this,t=["=","/eq",">",">=","/gt","/gte"],n=["=","/eq","<","<=","/lt","/lte"];if(this.backward){var r=this._indexer.origin.length-1;if("function"!=typeof this.condition)for(var i in this._indexer.fields){var s=this._indexer.fields[i],a=1;if("-"===s[0]&&(s=s.slice(1),a=-1),this.condition[s])if("object"==typeof this.condition[s]){var o=a>0?n:t;for(var u in this.condition[s])if(o.includes(u))for(var c=r;c>=0;c--)if(a*ms(this._indexer.origin[c].columnValues[i],this.condition[s][u])<=0){r=c;break}}else for(c=r;c>=0;c--)if(a*ms(this._indexer.origin[c].columnValues[i],this.condition[s])<=0){r=c;break}}return Math.min(r+1,this._indexer.origin.length-1)}var l=0;if("function"!=typeof this.condition)for(var h=function(r){var i=d._indexer.fields[r],s=1;if("-"===i[0]&&(i=i.slice(1),s=-1),d.condition[i])if("object"==typeof d.condition[i])Object.keys(d.condition[i]).forEach((function(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;i0){for(var r=Math.ceil(e.data.length/n),i="".concat(r,".").concat(e.type,".").concat(t),s=[],a=0;a0))return[3,6];u=0,s.label=1;case 1:return u0))return[3,2];for(a=0;a-1){var r=this._items[n];return t===ws.PERSISTENT&&(r.state=Ns.PERSISTENT),t!==ws.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)Fs.includes(this._items[r].state)&&Fs.includes(e.state)?(this._items.splice(r,1),this._items.push(e)):(this._items[r].state=e.state,this._items[r].generation=e.generation,this._items[r].value=e.value);else{this._items.push(e);var i=this._items.filter((function(e){return e.state===Ns.VOLATILE})),s=i.length-this._limit;if(s>0){var o=[];try{for(var u=a(this._items),c=u.next();!c.done;c=u.next()){var l=c.value;l.state===Ns.VOLATILE&&s>0?s--:o.push(l)}}catch(e){t={error:e}}finally{try{c&&!c.done&&(n=u.return)&&n.call(u)}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!==Ns.VOLATILE}))},e}(),Hs=function(){function e(e){var t=e.dbname,n=e.collectionName,r=e.store;this._metadata=null,this._requests=[],this._onCommit=new Map,this._onWrite=new Map,this._onError=new Map,this.dbname=t,this.collectionName=n,this.metadataKey=function(e,t){return"".concat(Rs(e,t),"/trans.metadata")}(t,n),this.recordsetKey=function(e,t){return"".concat(Rs(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=[]),i(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,u([],o(e),!1)),[2,this._reduceRecordSet(t)]}}))}))},e.prototype._reduceRecordSet=function(e){for(var t=[],n={},r=e.length-1;r>=0;r--){for(var i=e[r],s=[],a=i.requests.length-1;a>=0;a--){var o=i.requests[a],u=o.data;n[u.key]||(s.unshift(o),n[u.key]=!0)}s.length>0&&(i.requests=s,t.unshift(i))}return t},e.prototype._applyRecord=function(e,t){return i(this,void 0,void 0,(function(){var n,i,a,o,u,c,l,h,d;return s(this,(function(s){switch(s.label){case 0:n=Gs.get(this.dbname),i=t.generation,a=t.requests,o=null,s.label=1;case 1:return s.trys.push([1,3,,4]),[4,this._store.setMany(a.map((function(e){return r(r({},e.data),{generation:i})})))];case 2:for(u=s.sent(),c=0;c0))return[3,4];for(t=[],n={},c=e.length-1;c>=0;c--)i=e[c],h=i.data,n[h.key]||(n[h.key]=!0,t.unshift(i));return a={generation:this.generation,requests:t},[4,this._getReducedRecordset([a])];case 1:return o=s.sent(),[4,this._store.set({key:this.recordsetKey,value:o,generation:this.generation})];case 2:return s.sent(),this._metadata.generation++,[4,this._store.set({key:this.metadataKey,value:this._metadata,generation:1})];case 3:for(s.sent(),u=Gs.get(this.dbname),c=0;c0?(r=this.createBlockId(e,n),[4,t.find(this._store,r)]):[3,4];case 2:if((i=s.sent())&&(a=Vs.createFromCacheItem(i),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 i(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 i(this,void 0,void 0,(function(){var n,r,i,a,o;return s(this,(function(s){switch(s.label){case 0:return n=ds.get(this.dbname),r=this.createBlockId(e),i=Math.floor(this._store.itemSizeLimit/n.itemSizeLimit),[4,Gs.get(this.dbname).find(this._store,r)];case 1:return a=s.sent(),(o=a?Vs.createFromCacheItem(a):new Vs({blockId:r,keyName:this.keyName,items:[],limit:i})).add(t)?(this._transaction.requestWrite({key:o.blockId,value:o.serialize()}),[2,!0]):[2,!1]}}))}))},e.prototype.removeFromBlock=function(e){return i(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 i(this,void 0,void 0,(function(){var e,t,n,r,i,o,u,c,l;return s(this,(function(s){switch(s.label){case 0:return e=ks(this.dbname,this.collectionName),[4,this._store.getAllKeys()];case 1:return t=s.sent(),n=t.filter((function(t){return t.startsWith(e)})),[4,this._store.removeMany(n)];case 2:s.sent(),r=Gs.get(this.dbname);try{for(i=a(n),o=i.next();!o.done;o=i.next())u=o.value,r.remove(u)}catch(e){c={error:e}}finally{try{o&&!o.done&&(l=i.return)&&l.call(i)}finally{if(c)throw c.error}}return[2]}}))}))},e}(),Qs=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=[],this.dbname=t,this.collectionName=n,this.keyName=r,this.fields=i,this.indexerKey=function(e,t,n){return"".concat(Rs(e,t),"/index.").concat(n)}(this.dbname,this.collectionName,this.fields.join(">")),this._transaction=s,this._store=a,this._transaction.on(Ss.COMMIT,this.indexerKey,(function(){return o.commit()})),this._transaction.on(Ss.ERROR,this.indexerKey,(function(){return o.abort()}))}return e.createKey=function(e){return e.join(">")},e.parseKey=function(e){return e.split(">")},e.prototype._addItem=function(e){var t=e[this.keyName],n=this.getColumnValues(e),r=o(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=o(this.indexOf(n),2),i=r[0];if(r[1]){var s=this._table[i].keys.indexOf(t);if(s>-1)return this._table[i].keys.splice(s,1),0===this._table[i].keys.length&&this._table.splice(i,1),!0}return!1},Object.defineProperty(e.prototype,"origin",{get:function(){return this._origin},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"table",{get:function(){return this._table},enumerable:!1,configurable:!0}),e.prototype.getColumnValues=function(e){var t,n,r,i,s=[];try{for(var o=a(this.fields),u=o.next();!u.done;u=o.next()){var c=u.value;if("-"===c[0]&&(c=c.slice(1)),r=e[c],i=void 0,i=typeof r,null!==r&&"undefined"!==i&&"boolean"!==i&&"number"!==i&&"string"!==i)throw fs.indexTypesNotMatch;s.push(e[c])}}catch(e){t={error:e}}finally{try{u&&!u.done&&(n=o.return)&&n.call(o)}finally{if(t)throw t.error}}return s},e.prototype.diff=function(e,t){for(var n in this.fields){var r="-"===this.fields[n][0]?-1:1,i=ms(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 i(this,void 0,void 0,(function(){var e,t,n,r,i,o,u,c,l,h,d,p,f,_,v,m,g;return s(this,(function(s){switch(s.label){case 0:return[4,(e=Gs.get(this.dbname)).find(this._store,this.indexerKey,ws.PERSISTENT)];case 1:return(t=s.sent())?[3,11]:(n=ks(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]),i=a(r),o=i.next(),s.label=4;case 4:return o.done?[3,7]:(u=o.value).startsWith(n)?[4,e.find(this._store,u,ws.NO_CACHE)]:[3,6];case 5:c=s.sent(),l=Vs.createFromCacheItem(c);try{for(m=void 0,h=a(l.items),d=h.next();!d.done;d=h.next())p=d.value,this._addItem(p)}catch(e){m={error:e}}finally{try{d&&!d.done&&(g=h.return)&&g.call(h)}finally{if(m)throw m.error}}s.label=6;case 6:return o=i.next(),[3,4];case 7:return[3,10];case 8:return f=s.sent(),_={error:f},[3,10];case 9:try{o&&!o.done&&(v=i.return)&&v.call(i)}finally{if(_)throw _.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=vs(this._origin),s.label=12;case 12:return[2]}}))}))},e.prototype.drop=function(){return i(this,void 0,void 0,(function(){return s(this,(function(e){switch(e.label){case 0:return Gs.get(this.dbname).remove(this.indexerKey),[4,this._store.remove(this.indexerKey)];case 1:return e.sent(),[2]}}))}))},e.prototype.addItem=function(e){return i(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 i(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 i(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=vs(this._origin)},e.prototype.abort=function(){this._table=vs(this._origin)},e}(),Bs="undefined"!=typeof document&&"undefined"!=typeof navigator;Bs&&navigator.userAgent&&navigator.userAgent.includes("Chrome/")&&navigator.userAgent.includes("Chromium/");var js=Bs&&navigator.userAgent&&navigator.userAgent.includes("Firefox/")&&!navigator.userAgent.includes("Seamonkey/");Bs&&navigator.userAgent&&navigator.userAgent.includes("Safari/")&&!navigator.userAgent.includes("Chrome/")&&navigator.userAgent.includes("Chromium/"),Bs&&navigator.userAgent&&(navigator.userAgent.includes("OPR/")||navigator.userAgent.includes("Opera/")),Bs&&navigator.userAgent&&navigator.userAgent.includes("Trident/7.0");var zs,Ws,Ys=Bs&&navigator.userAgent&&navigator.userAgent.includes("Edge/"),Js=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"}(zs||(zs={})),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"}(Ws||(Ws={}));var Xs,Zs={},$s=function(){function e(e,t){void 0===t&&(t={});var n=this;return this._state=zs.PROCESSING,this._hostId=null,this._queue=[],this._currentItem=null,this._activationTimeout=null,this._activationQueue=[],Zs[e]&&!t.forceCreate||(this.nodeId=Js(),this.key=e,Bs&&(t.startAsInvisible?this.registerNode():"visible"===document.visibilityState?this.claimHost():this.registerNode(),document.addEventListener("visibilitychange",(function(){"visible"===document.visibilityState&&n.claimHost()})),window.addEventListener("message",(function(e){var t,r,i=e.data,s=i.nodeId,o=i.requestId,u=i.key,c=i.op,l=i.data;if(s!==n.nodeId&&u===n.key)switch(c){case Ws.NEWNODE:n._sendSync();break;case Ws.CLAIM_HOST:n._sendSync(),n._hostId=s;break;case Ws.SYNC_HOST:if(!n.isInSync){n._activationTimeout&&clearTimeout(n._activationTimeout);var h=l,d=h.currentItemRequestId,p=h.queue,f=function(e){var t=n._queue.findIndex((function(t){return t.requestId===e.requestId}));t<0&&n._requestLock({nodeId:e.nodeId,requestId:e.requestId,key:n.key,op:Ws.REQUEST_LOCK,ts:e.ts})};try{for(var _=a(p),v=_.next();!v.done;v=_.next()){f(v.value)}}catch(e){t={error:e}}finally{try{v&&!v.done&&(r=_.return)&&r.call(_)}finally{if(t)throw t.error}}n._currentItem=n._queue.find((function(e){return e.requestId===d})),n._completeSync()}break;case Ws.REMOVENODE:n._queue=n._queue.filter((function(e){return e.nodeId!==i.nodeId})),n._currentItem&&n._currentItem.nodeId===i.nodeId&&(n._currentItem=null,n._acquire(n._queue[0]));break;case Ws.REQUEST_LOCK:n._requestLock(i);break;case Ws.ACQUIRE_LOCK:var m=n._queue.find((function(e){return e.requestId===o}));n._acquire(m);break;case Ws.RELEASE_LOCK:n._release(o)}})),window.addEventListener("beforeunload",(function(){n._send(Ws.REMOVENODE)}))),Zs[e]=this),Zs[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==zs.DONE},enumerable:!1,configurable:!0}),e.prototype._send=function(e,t){var n,r;void 0===t&&(t={});var i={nodeId:this.nodeId,requestId:null!==(n=null==t?void 0:t.requestId)&&void 0!==n?n:Js(),key:this.key,op:e,data:null!==(r=t.data)&&void 0!==r?r:null,ts:Date.now()};return Bs&&window.postMessage(i,"*"),i},e.prototype._acquire=function(e){void 0===e&&(e=null),e?(this._currentItem=e,this._currentItem.onAcquired(e.requestId)):this._currentItem=null},e.prototype._release=function(e){if(this._currentItem&&this._currentItem.requestId===e){var t=this._currentItem;this._currentItem=null,t.nodeId===this.nodeId&&this._send(Ws.RELEASE_LOCK,{requestId:t.requestId});var n=this._queue.findIndex((function(t){return t.requestId===e}));n>-1&&this._queue.splice(n,1),t.onReleased(e)}},e.prototype._requestLock=function(e){var t=this;return new Promise((function(n){var r={nodeId:e.nodeId,requestId:e.requestId,ts:e.ts,onAcquired:function(e){t.isHost&&t._send(Ws.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(Ws.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 i(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=zs.DONE,this._activationQueue.forEach((function(e){return e()})),this._activationQueue=[])},e.prototype.registerNode=function(){this._send(Ws.NEWNODE),this._waitSync()},e.prototype.claimHost=function(){this._hostId=this.nodeId,this._send(Ws.CLAIM_HOST),this._waitSync()},e.prototype.lock=function(){return i(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(Ws.REQUEST_LOCK),[4,this._requestLock(e)];case 2:return t.sent(),[2]}}))}))},e.prototype.unlock=function(){var e;this._release(null===(e=this._currentItem)||void 0===e?void 0:e.requestId)},e}(),ea=function(){function e(e){var t=e.dbname,n=e.collectionName,r=e.keyName,i=e.keyHash,s=e.indexes,a=e.store,c=this;this._state=ps.INIT,this._metadata=null,this._indexers=[],this.dbname=t,this.name=n,this.keyName=r,this.indexes=u([[r]],o(s.filter((function(e){return Qs.createKey(e)!==c.keyName}))),!1),this._keyHash=i,this._store=a,this._mutex=new $s(function(e,t){return"".concat(Rs(e,t),".lock")}(t,n)),this._blobContainer=new xs({dbname:t,collectionName:n,store:a}),this._transaction=new Hs({dbname:t,collectionName:n,store:a})}return e.metadataOf=function(e,t,n){return i(this,void 0,void 0,(function(){var r;return s(this,(function(i){switch(i.label){case 0:return r=Ls(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===ps.READY},enumerable:!1,configurable:!0}),e.prototype.init=function(){return i(this,void 0,void 0,(function(){var t,n,r,i,c,l,h,d,p,f,_,v,m,g,y=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=ds.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 Ks({dbname:this.dbname,collectionName:this.name,hashFunction:this._keyHash,metadata:this._metadata,transaction:this._transaction,store:this._store}),r=u([],o(this.indexes),!1),i=[],c=r.map((function(e){return Qs.createKey(e)})),l=n?n.indexes.map((function(e){return Qs.createKey(e)})):[];try{for(h=a(l),d=h.next();!d.done;d=h.next())p=d.value,c.includes(p)||i.push(Qs.parseKey(p))}catch(e){m={error:e}}finally{try{d&&!d.done&&(g=h.return)&&g.call(h)}finally{if(m)throw m.error}}return(f=[]).push.apply(f,u([],o(r.map((function(e){var t=new Qs({dbname:y.dbname,collectionName:y.name,keyName:y.keyName,fields:e,transaction:y._transaction,store:y._store});return y._indexers.push(t),t.ensure()}))),!1)),f.push.apply(f,u([],o(i.map((function(e){return new Qs({dbname:y.dbname,collectionName:y.name,keyName:y.keyName,fields:e,transaction:y._transaction,store:y._store}).drop()}))),!1)),[4,Promise.all(f)];case 5:return s.sent(),[4,this._transaction.commit()];case 6:return s.sent(),c.sort().join(",")===l.sort().join(",")?[3,8]:(_=Ls(this.dbname,this.name),this._metadata.indexes=r,[4,this._store.set({key:_,value:this._metadata,generation:1})]);case 7:s.sent(),s.label=8;case 8:return this._state=ps.READY,this._mutex.unlock(),[3,10];case 9:throw v=s.sent(),this._mutex.unlock(),v;case 10:return[2]}}))}))},e.prototype.close=function(){this._state=ps.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=Qs.createKey(e);try{for(var i=a(this._indexers),s=i.next();!s.done;s=i.next()){var o=s.value;if(r===Qs.createKey(o.fields))return o}}catch(e){t={error:e}}finally{try{s&&!s.done&&(n=i.return)&&n.call(i)}finally{if(t)throw t.error}}return null},e.prototype._upgradeBlockLevel=function(){return i(this,void 0,void 0,(function(){var e;return s(this,(function(t){switch(t.label){case 0:return e=Ls(this.dbname,this.name),this._metadata.blockLevel++,[4,this._store.set({key:e,value:this._metadata,generation:1})];case 1:return t.sent(),[2]}}))}))},e.prototype._requestInsert=function(e){return i(this,void 0,void 0,(function(){var t,n,r,i,o,u;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=a(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 i=s.sent(),o={error:i},[3,12];case 11:try{r&&!r.done&&(u=n.return)&&u.call(n)}finally{if(o)throw o.error}return[7];case 12:return[3,14];case 13:throw fs.collectionInsertDuplicate;case 14:return[2]}}))}))},e.prototype._requestUpsert=function(e){return i(this,void 0,void 0,(function(){var t,n,r,i,o,u,c,l,h,d,p,f,_;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=a(this._indexers),i=r.next(),s.label=6;case 6:return i.done?[3,9]:[4,(l=i.value).addItem(e)];case 7:s.sent(),s.label=8;case 8:return i=r.next(),[3,6];case 9:return[3,12];case 10:return o=s.sent(),d={error:o},[3,12];case 11:try{i&&!i.done&&(p=r.return)&&p.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]),u=a(this._indexers),c=u.next(),s.label=16;case 16:return c.done?[3,20]:0===(l=c.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 c=u.next(),[3,16];case 20:return[3,23];case 21:return h=s.sent(),f={error:h},[3,23];case 22:try{c&&!c.done&&(_=u.return)&&_.call(u)}finally{if(f)throw f.error}return[7];case 23:return[2]}}))}))},e.prototype._requestUpdate=function(e){return i(this,void 0,void 0,(function(){var t,n,r,i,o,u,c,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=a(this._indexers),i=r.next(),s.label=4;case 4:return i.done?[3,8]:0===(o=i.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 i=r.next(),[3,4];case 8:return[3,11];case 9:return u=s.sent(),c={error:u},[3,11];case 10:try{i&&!i.done&&(l=r.return)&&l.call(r)}finally{if(c)throw c.error}return[7];case 11:return[2]}}))}))},e.prototype._requestRemove=function(e){return i(this,void 0,void 0,(function(){var t,n,r,i,o,u;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=a(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 i=s.sent(),o={error:i},[3,10];case 9:try{r&&!r.done&&(u=n.return)&&u.call(n)}finally{if(o)throw o.error}return[7];case 10:return[2]}}))}))},e.prototype._requestClear=function(){return i(this,void 0,void 0,(function(){var e,t,n,r,i;return s(this,(function(s){switch(s.label){case 0:return[4,this._blockManager.clearAllBlocks()];case 1:s.sent(),s.label=2;case 2:s.trys.push([2,7,8,9]),e=a(this._indexers),t=e.next(),s.label=3;case 3:return t.done?[3,6]:[4,t.value.clear()];case 4:s.sent(),s.label=5;case 5:return t=e.next(),[3,3];case 6:return[3,9];case 7:return n=s.sent(),r={error:n},[3,9];case 8:try{t&&!t.done&&(i=e.return)&&i.call(e)}finally{if(r)throw r.error}return[7];case 9:return[2]}}))}))},e.prototype.getByKey=function(e){return i(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,vs(t)];case 4:throw n=r.sent(),this._mutex.unlock(),n;case 5:return[3,7];case 6:throw fs.collectionNotReady;case 7:return[2]}}))}))},e.prototype.query=function(e){return void 0===e&&(e={}),this.isReady?new Us({condition:e.where,mutex:this._mutex,blockManager:this._blockManager,indexer:this._getIndexerBy(e.index),backward:!!e.backward}):null},e.prototype.insertOne=function(e){return i(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 fs.collectionKeyNotGiven;return[4,this._requestInsert(vs(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 fs.collectionNotReady;case 9:return[2]}}))}))},e.prototype.insertMany=function(e){return i(this,void 0,void 0,(function(){var t,n,r,i,o,u,c,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 fs.collectionKeyNotGiven;s.label=3;case 3:s.trys.push([3,8,9,10]),t=a(e),n=t.next(),s.label=4;case 4:return n.done?[3,7]:(r=n.value,[4,this._requestInsert(vs(r))]);case 5:s.sent(),s.label=6;case 6:return n=t.next(),[3,4];case 7:return[3,10];case 8:return i=s.sent(),u={error:i},[3,10];case 9:try{n&&!n.done&&(c=t.return)&&c.call(t)}finally{if(u)throw u.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 fs.collectionNotReady;case 16:return[2]}}))}))},e.prototype.upsertOne=function(e){return i(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 fs.collectionKeyNotGiven;return[4,this._requestUpsert(vs(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 fs.collectionNotReady;case 9:return[2]}}))}))},e.prototype.upsertMany=function(e){return i(this,void 0,void 0,(function(){var t,n,r,i,o,u,c,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 fs.collectionKeyNotGiven;s.label=3;case 3:s.trys.push([3,8,9,10]),t=a(e),n=t.next(),s.label=4;case 4:return n.done?[3,7]:(r=n.value,[4,this._requestUpsert(vs(r))]);case 5:s.sent(),s.label=6;case 6:return n=t.next(),[3,4];case 7:return[3,10];case 8:return i=s.sent(),u={error:i},[3,10];case 9:try{n&&!n.done&&(c=t.return)&&c.call(t)}finally{if(u)throw u.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 fs.collectionNotReady;case 16:return[2]}}))}))},e.prototype.update=function(e){return i(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 fs.collectionKeyNotGiven;return[4,this._requestUpdate(vs(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 fs.collectionNotReady;case 9:return[2]}}))}))},e.prototype.updateIf=function(e,t){return i(this,void 0,void 0,(function(){var n,r,o,u,c,l,h,d,p,f,_,v,m,g,y=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,r=void 0===n?{}:n,o=e.index,u=void 0===o?null:o,c=e.backward,l=void 0!==c&&c,h=[],[4,new As({condition:r,blockManager:this._blockManager,backward:l,indexer:this._getIndexerBy(u)}).each((function(e){return i(y,void 0,void 0,(function(){var n,i;return s(this,(function(s){if(e.error)throw e.stop(),e.error;if(e.hasNext){if(n=e.nextValue,Es(r,n)&&t.set){if("function"!=typeof t.set)for(i in t.set)n[i]=t.set[i];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=a(h),p=d.next(),E.label=5;case 5:return p.done?[3,8]:(f=p.value,[4,this._requestUpdate(vs(f))]);case 6:E.sent(),E.label=7;case 7:return p=d.next(),[3,5];case 8:return[3,11];case 9:return _=E.sent(),m={error:_},[3,11];case 10:try{p&&!p.done&&(g=d.return)&&g.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 v=E.sent(),[4,this._transaction.clear()];case 14:throw E.sent(),this._mutex.unlock(),v;case 15:return[3,17];case 16:throw this._transaction.clear(),fs.collectionNotReady;case 17:return[2]}}))}))},e.prototype.remove=function(e){return i(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 fs.collectionNotReady;case 9:return[2]}}))}))},e.prototype.removeIf=function(e){return i(this,void 0,void 0,(function(){var t,n,r,o,u,c,l,h,d,p,f,_,v,m,g=this;return s(this,(function(y){switch(y.label){case 0:return this.isReady?[4,this._mutex.lock()]:[3,15];case 1:y.sent(),y.label=2;case 2:return y.trys.push([2,13,,14]),t=e.where,n=void 0===t?{}:t,r=e.index,o=void 0===r?null:r,u=e.backward,c=void 0!==u&&u,l=[],[4,new As({condition:n,blockManager:this._blockManager,backward:c,indexer:this._getIndexerBy(o)}).each((function(e){return i(g,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,Es(n,t)&&(r=t[this.keyName],l.push(r)),e.next()):e.stop(),[2]}))}))}))];case 3:y.sent(),y.label=4;case 4:y.trys.push([4,9,10,11]),h=a(l),d=h.next(),y.label=5;case 5:return d.done?[3,8]:(p=d.value,[4,this._requestRemove(p)]);case 6:y.sent(),y.label=7;case 7:return d=h.next(),[3,5];case 8:return[3,11];case 9:return f=y.sent(),v={error:f},[3,11];case 10:try{d&&!d.done&&(m=h.return)&&m.call(h)}finally{if(v)throw v.error}return[7];case 11:return[4,this._transaction.commit()];case 12:return y.sent(),this._mutex.unlock(),[2,l];case 13:throw _=y.sent(),this._mutex.unlock(),_;case 14:return[3,16];case 15:throw this._transaction.clear(),fs.collectionNotReady;case 16:return[2]}}))}))},e.prototype.clear=function(){return i(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 fs.collectionNotReady;case 9:return[2]}}))}))},e.prototype.getBlob=function(e){return i(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 void 0===t&&(t=null),i(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 i(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 i(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}(),ta={},na=function(){function e(e){void 0===e&&(e={});var t=e.itemSizeLimit,n=void 0===t?4194304:t,r=e.delay,i=void 0===r?1:r,s=e.encryption,a=void 0===s?N:s;this._encryption=a,this.itemSizeLimit=n,this.delay=i,this.observer={}}return Object.defineProperty(e.prototype,"rawData",{get:function(){return ta[this.dbname]},set:function(e){ta[this.dbname]=e},enumerable:!1,configurable:!0}),e.prototype.observe=function(e,t,n){var r=this;this.observer[e]={},t.forEach((function(t){return r.observer[e][t]=n}))},e.prototype.init=function(e){return i(this,void 0,void 0,(function(){var t;return s(this,(function(n){switch(n.label){case 0:this.dbname=e,ta[this.dbname]={},n.label=1;case 1:return n.trys.push([1,,3,5]),[4,this.get(S.key)];case 2:if((t=n.sent())&&JSON.stringify(t)!==JSON.stringify(S.value))throw fs.storeEncryptionInvalid;return[3,5];case 3:return[4,this.set(S)];case 4:return n.sent(),[7];case 5:return[2]}}))}))},e.prototype.getAllKeys=function(){return i(this,void 0,void 0,(function(){return s(this,(function(e){return[2,Object.keys(ta[this.dbname]).filter((function(e){return e!==S.key}))]}))}))},e.prototype.get=function(e){return i(this,void 0,void 0,(function(){var t;return s(this,(function(n){switch(n.label){case 0:return[4,this.getRaw(e)];case 1:return[2,(t=n.sent())?this._encryption.decrypt(t):null]}}))}))},e.prototype.getRaw=function(e){return i(this,void 0,void 0,(function(){var t,n;return s(this,(function(r){switch(r.label){case 0:return[4,ys(this.delay)];case 1:if(r.sent(),t=this.observer[e],n=t&&t.get?t.get(e):null)throw n;return[2,ta[this.dbname][e]]}}))}))},e.prototype.set=function(e){return i(this,void 0,void 0,(function(){var t,n,r,i,a,o;return s(this,(function(s){switch(s.label){case 0:return[4,ys(this.delay)];case 1:if(s.sent(),t=e.key,n=e.value,r=this.observer[t],i=r&&r.set?r.set(t):null)throw i;if(a=this._encryption.encrypt(n),o=JSON.stringify(a),t===S.key||o.length0&&(r.mutedUsers=s.map((function(e){return new pa(t,e)}))),r}return n(t,e),t}(F),Ia=function(e){function t(t,n,r,i){return e.call(this,t,n,r,i)||this}return n(t,e),t.prototype.next=function(){return i(this,void 0,void 0,(function(){var e,t,n,i,a,o;return s(this,(function(s){switch(s.label){case 0:return this._validate()?this._isLoading?[3,3]:this._hasNext?(this._isLoading=!0,e=wt.of(this._iid).requestQueue,t=new Ca(r(r({},this),{token:this._token})),[4,e.send(t)]):[3,2]:[3,5];case 1:return n=s.sent(),i=n.as(Ta),a=i.mutedUsers,o=i.token,this._token=o,this._hasNext=!!o,this._isLoading=!1,[2,a];case 2:return[2,[]];case 3:throw f.queryInProgress;case 4:return[3,6];case 5:throw f.invalidParameters;case 6:return[2]}}))}))},t}(Bn),Sa=function(e){function t(t){var n=this,r=t.channelUrl,i=t.channelType,s=t.limit,a=t.token;return(n=e.call(this)||this).method=d.GET,n.path="".concat(Je(i),"/").concat(encodeURIComponent(r),"/ban"),n.params=D({limit:s,token:a}),n}return n(t,e),t}(x),Na=function(e){function t(t,n){var r=e.call(this,t,n)||this;r.token=null,r.bannedUsers=[];var i=n.next,s=n.banned_list;return r.token=i,s&&s.length>0&&(r.bannedUsers=s.map((function(e){return new pa(t,e.user)}))),r}return n(t,e),t}(F),wa=function(e){function t(t,n,r,i){return e.call(this,t,n,r,i)||this}return n(t,e),t.prototype._validate=function(){return e.prototype._validate.call(this)},t.prototype.next=function(){return i(this,void 0,void 0,(function(){var e,t,n,i,a,o;return s(this,(function(s){switch(s.label){case 0:return this._validate()?this._isLoading?[3,3]:this._hasNext?(this._isLoading=!0,e=wt.of(this._iid).requestQueue,t=new Sa(r(r({},this),{token:this._token})),[4,e.send(t)]):[3,2]:[3,5];case 1:return n=s.sent(),i=n.as(Na),a=i.bannedUsers,o=i.token,this._token=o,this._hasNext=!!o,this._isLoading=!1,[2,a];case 2:return[2,[]];case 3:throw f.queryInProgress;case 4:return[3,6];case 5:throw f.invalidParameters;case 6:return[2]}}))}))},t}(Bn);e.ReportCategory=void 0,(ha=e.ReportCategory||(e.ReportCategory={})).SPAM="spam",ha.HARASSING="harassing",ha.SUSPICIOUS="suspicious",ha.INAPPROPRIATE="inappropriate";var Ma=function(e){function t(t){var n=this,r=t.channelUrl,i=t.channelType,s=t.operatorUserIds;return(n=e.call(this)||this).method=d.POST,n.path="".concat(Je(i),"/").concat(encodeURIComponent(r),"/operators"),n.params={operator_ids:s},n}return n(t,e),t}(x);!function(e){function t(){return null!==e&&e.apply(this,arguments)||this}n(t,e)}(F);var Aa=function(e){function t(t){var n=this,r=t.channelUrl,i=t.channelType,s=t.operatorUserIds;return(n=e.call(this)||this).method=d.DELETE,n.path="".concat(Je(i),"/").concat(encodeURIComponent(r),"/operators"),n.params={operator_ids:s},n}return n(t,e),t}(x);!function(e){function t(t,n){return e.call(this,t,n)||this}n(t,e)}(F);var Ua=function(e){function t(t){var n=this,r=t.channelUrl,i=t.channelType,s=t.userId;return(n=e.call(this)||this).method=d.GET,n.path="".concat(Je(i),"/").concat(encodeURIComponent(r),"/mute/").concat(s),n}return n(t,e),t}(x),Oa=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,s=n.start_at,a=n.end_at,o=n.remaining_duration,u=n.description;return r.isMuted=i,r.startAt=s,r.endAt=a,r.remainingDuration=o,r.description=u,r}return n(t,e),t}(F),Ra=function(e){function t(t){var n=this,r=t.channelUrl,i=t.channelType,s=t.keys;return(n=e.call(this)||this).method=d.GET,n.path="".concat(Je(i),"/").concat(encodeURIComponent(r),"/metadata"),n.params={keys:s,include_ts:!0},n}return n(t,e),t}(x),La=function(e){function t(t,n){var r=e.call(this,t,n)||this;r.ts=null;var i=n.metadata,s=n.ts;return r.metadata=i,r.ts=null!=s?s:null,r}return n(t,e),t}(F),ka=function(e){function t(t){var n=this,r=t.channelUrl,i=t.channelType,s=t.metadata,a=t.upsert;return(n=e.call(this)||this).method=d.PUT,n.path="".concat(Je(i),"/").concat(encodeURIComponent(r),"/metadata"),n.params={metadata:s,include_ts:!0,upsert:null!=a&&a},n}return n(t,e),t}(x),Da=function(e){function t(t,n){var r=e.call(this,t,n)||this;r.ts=null;var i=n.metadata,s=n.ts;return r.metadata=i,r.ts=null!=s?s:null,r}return n(t,e),t}(F),Pa=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 n(t,e),t}(j),xa=function(e){function t(t){var n=this,r=t.channelUrl,i=t.channelType,s=t.key;return(n=e.call(this)||this).method=d.DELETE,n.path="".concat(Je(i),"/").concat(encodeURIComponent(r),"/metadata/").concat(s),n.params={include_ts:!0},n}return n(t,e),t}(x),Fa=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 n(t,e),t}(F),qa=function(e){function t(t){var n=this,r=t.channelUrl,i=t.channelType;return(n=e.call(this)||this).method=d.PUT,n.path="".concat(Je(i),"/").concat(encodeURIComponent(r),"/metadata"),n.params={include_ts:!0},n}return n(t,e),t}(x),Ga=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 n(t,e),t}(F),Ha=function(e){function t(t){var n=this,r=t.channelUrl,i=t.channelType,s=t.keys;return(n=e.call(this)||this).method=d.GET,n.path="".concat(Je(i),"/").concat(encodeURIComponent(r),"/metacounter"),n.params={keys:s},n}return n(t,e),t}(x),Va=function(e){function t(t,n){var r=e.call(this,t,n)||this;return r.metaCounter=n,r}return n(t,e),t}(F),Ka=function(e){function t(t){var n=this,r=t.channelUrl,i=t.channelType,s=t.metaCounter;return(n=e.call(this)||this).method=d.POST,n.path="".concat(Je(i),"/").concat(encodeURIComponent(r),"/metacounter"),n.params={metacounter:s},n}return n(t,e),t}(x),Qa=function(e){function t(t,n){var r=e.call(this,t,n)||this;return r.metaCounter=n,r}return n(t,e),t}(F),Ba=function(e){function t(t){var n=this,r=t.channelUrl,i=t.channelType,s=t.metaCounter,a=t.upsert,o=void 0!==a&&a,u=t.mode,c=void 0===u?"set":u;return(n=e.call(this)||this).method=d.PUT,n.path="".concat(Je(i),"/").concat(encodeURIComponent(r),"/metacounter"),n.params={metacounter:s,upsert:o,mode:c},n}return n(t,e),t}(x),ja=function(e){function t(t,n){var r=e.call(this,t,n)||this;return r.metaCounter=n,r}return n(t,e),t}(F),za=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 n(t,e),t}(j),Wa=function(e){function t(t){var n=this,r=t.channelUrl,i=t.channelType,s=t.key;return(n=e.call(this)||this).method=d.DELETE,n.path="".concat(Je(i),"/").concat(encodeURIComponent(r),"/metacounter/").concat(s),n.params=null,n}return n(t,e),t}(x);!function(e){function t(t,n){return e.call(this,t,n)||this}n(t,e)}(F);var Ya=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(Je(i),"/").concat(encodeURIComponent(r),"/metacounter"),n.params=null,n}return n(t,e),t}(x);!function(e){function t(){return null!==e&&e.apply(this,arguments)||this}n(t,e)}(F);var Ja=function(e){function t(t){var n=this,r=t.channelUrl,i=t.channelType,s=t.userId,a=t.seconds,o=t.description;return(n=e.call(this)||this).method=d.POST,n.path="".concat(Je(i),"/").concat(encodeURIComponent(r),"/mute"),n.params={user_id:s,seconds:a,description:o},n}return n(t,e),t}(x);!function(e){function t(t,n){return e.call(this,t,n)||this}n(t,e)}(F);var Xa=function(e){function t(t,n,r){var i=e.call(this,t,"SYEV",r)||this;return i.user=new pa(t,r.data),i}return n(t,e),t}(j),Za=function(e){function t(t){var n=this,r=t.channelUrl,i=t.channelType,s=t.userId;return(n=e.call(this)||this).method=d.DELETE,n.path="".concat(Je(i),"/").concat(encodeURIComponent(r),"/mute/").concat(encodeURIComponent(s)),n}return n(t,e),t}(x);!function(e){function t(){return null!==e&&e.apply(this,arguments)||this}n(t,e)}(F);var $a=function(e){function t(t,n,r){var i=e.call(this,t,"SYEV",r)||this;return i.user=new pa(t,r.data),i}return n(t,e),t}(j),eo=function(e){function t(t){var n=this,r=t.channelUrl,i=t.channelType,s=t.userId,a=t.seconds,o=t.description;return(n=e.call(this)||this).method=d.POST,n.path="".concat(Je(i),"/").concat(encodeURIComponent(r),"/ban"),n.params=D({user_id:s,seconds:a,description:o}),n}return n(t,e),t}(x);!function(e){function t(){return null!==e&&e.apply(this,arguments)||this}n(t,e)}(F);var to=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 pa(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 n(t,e),t}(j),no=function(e){function t(t){var n=this,r=t.channelUrl,i=t.channelType,s=t.userId;return(n=e.call(this)||this).method=d.DELETE,n.path="".concat(Je(i),"/").concat(encodeURIComponent(r),"/ban/").concat(encodeURIComponent(s)),n}return n(t,e),t}(x);!function(e){function t(){return null!==e&&e.apply(this,arguments)||this}n(t,e)}(F);var ro=function(e){function t(t,n,r){var i=e.call(this,t,"SYEV",r)||this;return i.user=new pa(t,r.data),i}return n(t,e),t}(j),io=function(e){function t(t){var n=this,r=t.channelUrl,i=t.channelType,s=t.freezing;return(n=e.call(this)||this).method=d.PUT,n.path="".concat(Je(i),"/").concat(encodeURIComponent(r),"/freeze"),n.params={freeze:s},n}return n(t,e),t}(x);!function(e){function t(){return null!==e&&e.apply(this,arguments)||this}n(t,e)}(F);var so=function(e){function t(t,n,r){var i=e.call(this,t,"SYEV",r)||this;return i.freeze=r.data.freeze,i}return n(t,e),t}(j),ao=function(e){function t(t){var n=this,r=t.channelUrl,i=t.channelType,s=t.category,a=t.userId,o=t.description;return(n=e.call(this)||this).method=d.POST,n.path="".concat(Xe(i),"/").concat(encodeURIComponent(r)),n.params={report_category:s,reporting_user_id:a,report_description:o},n}return n(t,e),t}(x),oo=function(t){function r(n){var r=this,i=n.channelUrl,s=n.channelType,a=n.category,o=n.userId,u=n.offendingUserId,c=n.description;return(r=t.call(this)||this).method=d.POST,r.path="".concat(be,"/users/").concat(u),r.params={channel_url:i,channel_type:s===e.ChannelType.OPEN?"open_channels":"group_channels",report_category:a,reporting_user_id:o,report_description:c},r}return n(r,t),r}(x),uo=function(e){function t(t){var n=this,r=t.channelUrl,i=t.channelType,s=t.category,a=t.userId,o=t.offendingUserId,u=t.messageId,c=t.description;return(n=e.call(this)||this).method=d.POST,n.path="".concat(Xe(i),"/").concat(encodeURIComponent(r),"/messages/").concat(u),n.params={report_category:s,reporting_user_id:a,report_description:c,offending_user_id:o},n}return n(t,e),t}(x),co=function(t){function r(n){var r=[];return n.mentionType===e.MentionType.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:D({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!==e.PushNotificationDeliveryOption.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})})||this}return n(r,t),r}(z),lo=function(e){function t(t,n,r){var i,s,a,o=this;(o=e.call(this,t,"MESG",r)||this).message=new nn(t,r);var u=wt.of(t).sdkState;return o.isMentioned=Ze(o.message.mentionType,null!==(i=o.message.mentionedUserIds)&&void 0!==i?i:null===(s=o.message.mentionedUsers)||void 0===s?void 0:s.map((function(e){return e.userId})),u.userId),o.forceUpdateLastMessage=null!==(a=r.force_update_last_message)&&void 0!==a&&a,o}return n(t,e),t}(j),ho=function(t){function r(n){var r=[];return n.mentionType===e.MentionType.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:D({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,poll_id:n.pollId})})||this}return n(r,t),r}(z),po=function(e){function t(t,n,r){var i,s,a,o,u,c,l=this;(l=e.call(this,t,"MEDI",r)||this).message=new nn(t,r);var h=wt.of(t).sdkState;return l.mentionCountChange=$e({mentionType:null!==(s=null===(i=r.old_values)||void 0===i?void 0:i.mention_type)&&void 0!==s?s:null,mentionedUserIds:null!==(o=null===(a=r.old_values)||void 0===a?void 0:a.mentioned_user_ids)&&void 0!==o?o:[]},{mentionType:l.message.mentionType,mentionedUserIds:null!==(u=l.message.mentionedUserIds)&&void 0!==u?u:null===(c=l.message.mentionedUsers)||void 0===c?void 0:c.map((function(e){return e.userId}))},h.userId),l}return n(t,e),t}(j),fo=function(t){function r(n){var r=[];return n.mentionType===e.MentionType.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:D({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 n(r,t),r}(z),_o=function(e){function t(t,n,r){var i,s,a,o,u,c,l=this;(l=e.call(this,t,"FEDI",r)||this).message=new an(t,r);var h=wt.of(t).sdkState;return l.mentionCountChange=$e({mentionType:null!==(s=null===(i=r.old_values)||void 0===i?void 0:i.mention_type)&&void 0!==s?s:null,mentionedUserIds:null!==(o=null===(a=r.old_values)||void 0===a?void 0:a.mentioned_user_ids)&&void 0!==o?o:[]},{mentionType:l.message.mentionType,mentionedUserIds:null!==(u=l.message.mentionedUserIds)&&void 0!==u?u:null===(c=l.message.mentionedUsers)||void 0===c?void 0:c.map((function(e){return e.userId}))},h.userId),l}return n(t,e),t}(j),vo=function(e){function t(t){var n=e.call(this)||this;return n.method=d.DELETE,n.path="".concat(Je(t.channelType),"/").concat(t.channelUrl,"/messages/").concat(t.messageId),n}return n(t,e),t}(x);!function(e){function t(){return null!==e&&e.apply(this,arguments)||this}n(t,e)}(F);var mo,go=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 n(t,e),t}(j),yo=function(e){function t(t){var n=t.channelType,r=t.channelUrl,i=t.messageId,s=t.reactionKey,a=e.call(this)||this;return a.method=d.POST,a.path="".concat(Je(n),"/").concat(encodeURIComponent(r),"/messages/").concat(i,"/reactions"),a.params={reaction:s},a}return n(t,e),t}(x),Eo=function(e){function t(t,n){var r=e.call(this,t,n)||this;return r.reactionEvent=new Dt(n),r}return n(t,e),t}(F),bo=function(e){function t(t){var n=t.channelType,r=t.channelUrl,i=t.messageId,s=t.reactionKey,a=e.call(this)||this;return a.method=d.DELETE,a.path="".concat(Je(n),"/").concat(encodeURIComponent(r),"/messages/").concat(i,"/reactions"),a.params={reaction:s},a}return n(t,e),t}(x),Co=function(e){function t(t,n){var i=e.call(this,t,n)||this;return i.reactionEvent=new Dt(r({},n)),i}return n(t,e),t}(F),To=function(e){function t(t){var n=t.channelType,r=t.channelUrl,i=t.messageId,s=t.translationTargetLanguages,a=e.call(this)||this;return a.method=d.POST,a.path="".concat(Je(n),"/").concat(encodeURIComponent(r),"/messages/").concat(encodeURIComponent(i),"/translation"),a.params={target_langs:s},a}return n(t,e),t}(x),Io=function(e){function t(t,n){var r=e.call(this,t,n)||this;return r.message=new nn(t,n),r}return n(t,e),t}(F),So=function(t){function r(n){var r,i=this;i=t.call(this)||this;var s=[];n.mentionType===e.MentionType.USERS&&(n.mentionedUserIds?s=n.mentionedUserIds:n.mentionedUsers&&(s=n.mentionedUsers.map((function(e){return e.userId}))));var a=n.channelType,o=n.channelUrl;return i.method=d.POST,i.path="".concat(Je(a),"/").concat(encodeURIComponent(o),"/scheduled_messages"),i.params={req_id:n.reqId,scheduled_at:n.scheduledAt,message_type:ae.USER,message:n.message,custom_type:n.customType,data:n.data,mention_type:n.mentionType,mentioned_user_ids:s,sorted_metaarray:null===(r=n.metaArrays)||void 0===r?void 0:r.map((function(e){return xt.payloadify(e)})),apple_critical_alert_options:Gt.payloadify(n.appleCriticalAlertOptions),target_langs:n.translationTargetLanguages,push_option:n.pushNotificationDeliveryOption},i}return n(r,t),r}(x),No=function(e){function t(t,n){var r=e.call(this,t,n)||this;return r.message=new nn(t,n),r}return n(t,e),t}(F),wo=function(t){function r(n){var r,i=this;i=t.call(this)||this;var s=[];n.mentionType===e.MentionType.USERS&&(n.mentionedUserIds?s=n.mentionedUserIds:n.mentionedUsers&&(s=n.mentionedUsers.map((function(e){return e.userId}))));var a=n.channelType,o=n.channelUrl;return i.method=d.POST,i.path="".concat(Je(a),"/").concat(encodeURIComponent(o),"/scheduled_messages"),i.params={req_id:n.reqId,scheduled_at:n.scheduledAt,message_type:ae.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 jt.payloadify(e)})):[],custom_type:n.customType,data:n.data,require_auth:n.requireAuth,mention_type:n.mentionType,mentioned_user_ids:s,sorted_metaarray:null===(r=n.metaArrays)||void 0===r?void 0:r.map((function(e){return xt.payloadify(e)})),apple_critical_alert_options:Gt.payloadify(n.appleCriticalAlertOptions),push_option:n.pushNotificationDeliveryOption},i}return n(r,t),r}(x),Mo=function(e){function t(t,n){var r=e.call(this,t,n)||this;return r.message=new an(t,n),r}return n(t,e),t}(F),Ao=function(t){function l(n,r){var i,s,a,o,u=this;return(u=t.call(this,n)||this).url="",u.channelType=e.ChannelType.BASE,u.name="",u.coverUrl="",u.customType="",u.data="",u.isFrozen=!1,u.isEphemeral=!1,u.creator=null,u.createdAt=0,u.url=r.channel_url,u.name=null!==(i=r.name)&&void 0!==i?i:"",u.coverUrl=null!==(s=r.cover_url)&&void 0!==s?s:"",u.customType=null!==(a=r.custom_type)&&void 0!==a?a:"",u.data=null!==(o=r.data)&&void 0!==o?o:"",u.isFrozen=!!g("boolean",r.freeze)&&r.freeze,u.isEphemeral=!!g("boolean",r.is_ephemeral)&&r.is_ephemeral,u.creator=r.created_by?new ht(u._iid,r.created_by):null,u.createdAt=1e3*r.created_at,u._cachedMetaData=new Map,r.metadata&&r.ts&&Object.keys(r.metadata).forEach((function(e){u._cachedMetaData.set(e,{value:r.metadata[e],isRemoved:!1,updatedAt:r.ts})})),u}return n(l,t),l.payloadify=function(e){return D(r(r({},t.payloadify.call(this,e)),{channel_url:e.url,name:e.name,cover_url:e.coverUrl,custom_type:e.customType,data:e.data,freeze:e.isFrozen,is_ephemeral:e.isEphemeral,created_by:ht.payloadify(e.creator),created_at:e.createdAt/1e3}))},l.prototype.isGroupChannel=function(){return this.channelType===e.ChannelType.GROUP},l.prototype.isOpenChannel=function(){return this.channelType===e.ChannelType.OPEN},Object.defineProperty(l.prototype,"cachedMetaData",{get:function(){var e={};return this._cachedMetaData.forEach((function(t,n){t.isRemoved||(e[n]=t.value)})),e},enumerable:!1,configurable:!0}),l.prototype._upsertCachedMetaData=function(e,t){var n=this;Object.keys(e).forEach((function(r){var i=n._cachedMetaData.get(r);(!i||i.updatedAt<=t)&&n._cachedMetaData.set(r,{value:e[r],isRemoved:!1,updatedAt:t})}))},l.prototype._removeFromCachedMetaData=function(e,t){var n=this;e.forEach((function(e){var r=n._cachedMetaData.get(e);r&&r.updatedAt0&&b("string",t)).throw(f.invalidParameters),n=wt.of(this._iid).requestQueue,r=new To({channelType:this.channelType,channelUrl:this.url,messageId:e.messageId,translationTargetLanguages:t}),[4,n.send(r)];case 1:return i=s.sent(),[2,i.as(Io).message]}}))}))},l.prototype._createScheduledUserMessage=function(e,t){var n=this,a=wt.of(this._iid).requestQueue,o=Date.now(),u=this._generateRequestId();Re(2).then((function(){var r=n._createPendingScheduledUserMessage(e,u,o);De((function(){return i(n,void 0,void 0,(function(){return s(this,(function(e){return[2,t._trigger(null,r)]}))}))}))}));var c=new So(r({reqId:u,channelType:this.channelType,channelUrl:this.url},e));a.send(c).then((function(e){var r=e.as(No).message;De((function(){return i(n,void 0,void 0,(function(){return s(this,(function(e){return[2,t._trigger(null,r)]}))}))}))})).catch((function(r){if(p(r))throw r;Re(2).then((function(){var a=n._createPendingScheduledUserMessage(e,u,o);n._markMessageAsFailed(a,r),De((function(){return i(n,void 0,void 0,(function(){return s(this,(function(e){return[2,t._trigger(r,a)]}))}))}))}))}))},l.prototype.sendFileMessage=function(e){var t=r(r({},Gr),e);return ct(Hr(t)).throw(f.invalidParameters),this._sendFileMessage(t)},l.prototype._sendFileMessage=function(t,n){var r=this;void 0===n&&(n=null);var a=wt.of(this._iid).dispatcher,o=kn.of(this._iid).fileMessageQueue,u=n,c=Date.now(),l=new Dn;return u||(u=this._generateRequestId(),Re(2).then((function(){var n=r._createPendingFileMessage(t,u,c);a.dispatch(new yn({messages:[n],source:e.MessageEventSource.EVENT_MESSAGE_SENT_PENDING})),De((function(){return i(r,void 0,void 0,(function(){return s(this,(function(e){return[2,l._trigger(null,n)]}))}))}))}))),o.request(this,u,t).then((function(t){a.dispatch(new yn({messages:[t],source:e.MessageEventSource.EVENT_MESSAGE_SENT_SUCCESS})),De((function(){return i(r,void 0,void 0,(function(){return s(this,(function(e){return[2,l._trigger(null,t)]}))}))}))})).catch((function(n){if(p(n))throw n;Re(2).then((function(){var o=r._createPendingFileMessage(t,u,c),h=wt.of(r._iid).cacheContext.localCacheEnabled&&C(n.code);r._markMessageAsFailed(o,n,h),a.dispatch(new yn({messages:[o],source:o.sendingStatus===e.SendingStatus.PENDING?e.MessageEventSource.REQUEST_RESEND_MESSAGE:e.MessageEventSource.EVENT_MESSAGE_SENT_FAILED})),De((function(){return i(r,void 0,void 0,(function(){return s(this,(function(e){return[2,l._trigger(n,o)]}))}))}))}))})),l},l.prototype._autoResendFileMessage=function(e){ct(e instanceof an).throw(f.invalidParameters);var t=wt.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)}))},l.prototype._createScheduledFileMessage=function(e,t,n,a){var o=this,u=wt.of(this._iid).requestQueue,c=new wo(r(r({reqId:n,channelType:this.channelType,channelUrl:this.url},e),{fileUrl:e.fileUrl,requireAuth:e.requireAuth}));u.send(c).then((function(e){var n=e.as(Mo).message;De((function(){return i(o,void 0,void 0,(function(){return s(this,(function(e){return[2,t._trigger(null,n)]}))}))}))})).catch((function(r){if(p(r))throw r;Re(2).then((function(){var u=o._createPendingScheduledFileMessage(e,n,a);o._markMessageAsFailed(u,r),De((function(){return i(o,void 0,void 0,(function(){return s(this,(function(e){return[2,t._trigger(r,u)]}))}))}))}))}))},l.prototype.sendFileMessages=function(e){var t,n;ct(e.every((function(e){return Hr(r(r({},Gr),e))}))).throw(f.invalidParameters);var i=new Dn;try{for(var s=a(e),o=s.next();!o.done;o=s.next()){var u=o.value;this.sendFileMessage(u).onPending((function(e){return i._trigger(null,e)})).onFailed((function(e,t){return i._trigger(e,t)})).onSucceeded((function(e){return i._trigger(null,e)}))}}catch(e){t={error:e}}finally{try{o&&!o.done&&(n=s.return)&&n.call(s)}finally{if(t)throw t.error}}return i},l.prototype.resendFileMessage=function(e,t){var n;return i(this,void 0,void 0,(function(){var r,i,a;return s(this,(function(s){return r=Boolean(e.url)||T(t)||T(null===(n=e.messageParams)||void 0===n?void 0:n.file),ct(e instanceof an&&r&&!e.scheduledInfo).throw(f.invalidParameters),i=new ee,a=function(e,t){var n;return void 0===t&&(t=null),e.messageParams?(!e.url&&T(t)&&(e.messageParams.file=t),e.messageParams):D({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:e.thumbnails.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]}))}))},l.prototype.updateFileMessage=function(e,t){return i(this,void 0,void 0,(function(){var n,i,a,o;return s(this,(function(s){switch(s.label){case 0:return n=r(r({},ga),t),ct(g("number",e)&&function(e){return _a(e)}(n)).throw(f.invalidParameters),i=wt.of(this._iid).requestQueue,a=new fo(r({channelType:this.channelType,channelUrl:this.url,messageId:e},n)),[4,i.send(a)];case 1:return o=s.sent(),[2,o.as(_o).message]}}))}))},l.prototype.cancelUploadingFileMessage=function(e){return i(this,void 0,void 0,(function(){return s(this,(function(t){return ct(g("string",e)).throw(f.invalidParameters),kn.of(this._iid).fileMessageQueue.cancel(this,e),[2,!0]}))}))},l.prototype.copyFileMessage=function(t,n){var a,o;return i(this,void 0,void 0,(function(){var i,u;return s(this,(function(s){return ct(t instanceof l&&n instanceof an&&n.sendingStatus===e.SendingStatus.SUCCEEDED&&t.url===n.channelUrl&&!n.scheduledInfo).throw(f.invalidParameters),i=new ee,u=r(r({},n),{fileUrl:n.url,fileName:n.name,fileSize:n.size,mimeType:n.type,mentionType:n.mentionType,mentionedUserIds:null!==(a=n.mentionedUserIds)&&void 0!==a?a:null===(o=n.mentionedUsers)||void 0===o?void 0:o.map((function(e){return e.userId})),pushNotificationDeliveryOption:e.PushNotificationDeliveryOption.DEFAULT,parentMessageId:null,isReplyToChannel:!1,thumbnailSizes:n.thumbnails.map((function(e){return{maxWidth:e.width,maxHeight:e.height}})),requireAuth:n.requireAuth}),t._sendFileMessage(u).onSucceeded((function(e){return i.resolve(e)})).onFailed((function(e){return i.reject(e)})),[2,i.promise]}))}))},l.prototype.deleteMessage=function(e){return i(this,void 0,void 0,(function(){var t,n;return s(this,(function(r){switch(r.label){case 0:return ct(e instanceof Bt).throw(f.invalidParameters),e.messageId>0?(t=wt.of(this._iid).requestQueue,n=new vo({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]}}))}))},l.prototype.addReaction=function(e,t){return i(this,void 0,void 0,(function(){var n,r,i;return s(this,(function(s){switch(s.label){case 0:return ct(e instanceof Kt&&e.messageId>0&&g("string",t)).throw(f.invalidParameters),n=wt.of(this._iid).requestQueue,r=new yo({channelType:this.channelType,channelUrl:this.url,messageId:e.messageId,reactionKey:t}),[4,n.send(r)];case 1:return i=s.sent(),[2,i.as(Eo).reactionEvent]}}))}))},l.prototype.deleteReaction=function(e,t){return i(this,void 0,void 0,(function(){var n,r,i;return s(this,(function(s){switch(s.label){case 0:return ct(e instanceof Kt&&e.messageId>0&&g("string",t)).throw(f.invalidParameters),n=wt.of(this._iid).requestQueue,r=new bo({channelType:this.channelType,channelUrl:this.url,messageId:e.messageId,reactionKey:t}),[4,n.send(r)];case 1:return i=s.sent(),[2,i.as(Co).reactionEvent]}}))}))},l.prototype._updateMessageMetaArray=function(t,n,r,a){return i(this,void 0,void 0,(function(){var i,o,u,c,l,h;return s(this,(function(s){switch(s.label){case 0:return i=wt.of(this._iid),o=i.dispatcher,u=i.requestQueue,c=new ho({channelType:this.channelType,channelUrl:this.url,messageId:t,metaArrayParams:{array:n,mode:r,upsert:a}}),[4,u.send(c)];case 1:return l=s.sent(),h=l.as(po).message,o.dispatch(new yn({messages:[h],source:e.MessageEventSource.EVENT_MESSAGE_UPDATED})),[2,h]}}))}))},l.prototype.createMessageMetaArrayKeys=function(e,t){return i(this,void 0,void 0,(function(){var n;return s(this,(function(r){return ct(e instanceof Bt&&e.messageId>0&&b("string",t)).throw(f.invalidParameters),n=t.map((function(e){return new xt({key:e})})),[2,this._updateMessageMetaArray(e.messageId,n,"add",!0)]}))}))},l.prototype.deleteMessageMetaArrayKeys=function(e,t){return i(this,void 0,void 0,(function(){var n;return s(this,(function(r){return ct(e instanceof Bt&&e.messageId>0&&b("string",t)).throw(f.invalidParameters),n=t.map((function(e){return new xt({key:e})})),[2,this._updateMessageMetaArray(e.messageId,n,"remove",!0)]}))}))},l.prototype.addMessageMetaArrayValues=function(e,t){return i(this,void 0,void 0,(function(){return s(this,(function(n){return ct(e instanceof Bt&&e.messageId>0&&t.every((function(e){return e instanceof xt}))).throw(f.invalidParameters),[2,this._updateMessageMetaArray(e.messageId,t,"add",!0)]}))}))},l.prototype.removeMessageMetaArrayValues=function(e,t){return i(this,void 0,void 0,(function(){return s(this,(function(n){return ct(e instanceof Bt&&e.messageId>0&&t.every((function(e){return e instanceof xt}))).throw(f.invalidParameters),[2,this._updateMessageMetaArray(e.messageId,t,"remove",!0)]}))}))},l.prototype.report=function(t,n){return i(this,void 0,void 0,(function(){var r,i,a,o;return s(this,(function(s){switch(s.label){case 0:return ct(y(e.ReportCategory,t)&&g("string",n)).throw(f.invalidParameters),r=wt.of(this._iid),i=r.sdkState,a=r.requestQueue,o=new ao({channelUrl:this.url,channelType:this.channelType,userId:i.userId,category:t,description:n}),[4,a.send(o)];case 1:return s.sent(),[2]}}))}))},l.prototype.reportUser=function(t,n,r){return i(this,void 0,void 0,(function(){var i,a,o,u;return s(this,(function(s){switch(s.label){case 0:return ct(t instanceof ht&&y(e.ReportCategory,n)&&g("string",r)).throw(f.invalidParameters),i=wt.of(this._iid),a=i.sdkState,o=i.requestQueue,u=new oo({channelUrl:this.url,channelType:this.channelType,userId:a.userId,offendingUserId:t.userId,category:n,description:r}),[4,o.send(u)];case 1:return s.sent(),[2]}}))}))},l.prototype.reportMessage=function(t,n,r){return i(this,void 0,void 0,(function(){var i,a,o,u;return s(this,(function(s){switch(s.label){case 0:return ct(t instanceof Bt&&y(e.ReportCategory,n)&&g("string",r)).throw(f.invalidParameters),i=wt.of(this._iid),a=i.sdkState,o=i.requestQueue,u=new uo({channelUrl:this.url,channelType:this.channelType,userId:a.userId,offendingUserId:t.sender.userId,messageId:t.messageId,category:n,description:r}),[4,o.send(u)];case 1:return s.sent(),[2]}}))}))},l}(We),Uo=null,Oo=function(){function t(e,t,n){var r=this;this._fcmPushToken=null,this._apnsPushToken=null,this._iid=e,this.options=t;var a=wt.of(e),o=a.sdkState,u=a.cacheContext,c=a.dispatcher,l=a.sessionManager,h=a.requestQueue,d=a.logger,p=a.userEventHandlers;this._onlineDetector=new Jr({logger:d,connectionDelegate:{reconnect:function(){var t=wt.of(e),n=t.sdkState,r=t.connectionManager;"foreground"===n.appState&&r.resetAndReconnect()},disconnect:function(){wt.of(e).connectionManager.disconnect()}}}),new $r(e,{localCacheEnabled:u.localCacheEnabled,dispatcher:c,sdkState:o,logger:d}),n.forEach((function(t){t.init(e,{sdkState:o,cacheContext:u,dispatcher:c,sessionManager:l,requestQueue:h,logger:d,onlineDetector:r._onlineDetector}),r[t.name]=t})),this._appStateChangeDetector=new Yr,this._appStateChangeDetector.on("resume",(function(){d.debug("the page resumes from freeze"),r.setForegroundState()})).on("pause",(function(){d.debug("the page freezes"),r.setBackgroundState()})),c.on((function(t){if(t instanceof j){if("USEV"===t.code){var n=t.as(ni).event;if(n.category===Pr.FRIEND_DISCOVERED){var a=ei.getDataAsFriendDiscoveredEvent(e,n).friendDiscoveries;De((function(){return i(r,void 0,void 0,(function(){return s(this,(function(e){return[2,p.forEach((function(e){e.onFriendsDiscovered(a)}))]}))}))}))}}}else if(t instanceof $){var c=wt.of(r._iid).subscribedUnreadMessageCount,l=!1,h=t.ts;if("number"==typeof h&&h>c.ts){if(c.all!==t.all&&(l=!0),c.all=t.all>=0?t.all:0,t.customTypes)for(var d in t.customTypes)c.customTypes[d]!==t.customTypes[d]&&(l=!0),c.customTypes[d]=t.customTypes[d];l=l&&c.ts>0,c.ts=h}l&&De((function(){return i(r,void 0,void 0,(function(){return s(this,(function(e){return[2,p.forEach((function(e){e.onTotalUnreadMessageCountUpdated(c.all,c.customTypes)}))]}))}))}))}else t instanceof dt&&u.localCacheEnabled&&u.preference.set(r._getUserProfileCacheKey(o.userId),pt.payloadify(t.userProfile))}))}return t.init=function(e){var n=e.appId,r=e.appVersion,i=void 0===r?null:r,s=e.modules,a=void 0===s?[]:s,c=e.options,l=void 0===c?new I:c,h=e.debugMode,d=void 0!==h&&h,p=e.customApiHost,f=e.customWebSocketHost,_=e.newInstance,v=void 0!==_&&_,m=e.logLevel,g=e.localCacheEnabled,y=void 0!==g&&g,E=e.localCacheEncryption,b=e.useAsyncStorageStore,C=void 0===b?null:b;if(!Uo||v){var T="su-".concat(U()),S=null!=E?E:{encrypt:function(e){return e},decrypt:function(e){return e}},N=new na({encryption:S});d||(N=C?new sa({AsyncStorage:C,encryption:S}):new ia({encryption:S})),new wt(T,{appId:n,appVersion:i,options:l,apiHost:null!=p?p:"https://api-".concat(n,".sendbird.com"),websocketHost:null!=f?f:"wss://ws-".concat(n,".sendbird.com"),store:N,encryption:S,logLevel:m,localCacheEnabled:y,debugMode:d});var w=[new Wn,new yr],M=new t(T,l,u(u([],o(a),!1),o(w),!1));return Uo||(Uo=M),M}return Uo},Object.defineProperty(t,"instance",{get:function(){return Uo},enumerable:!1,configurable:!0}),Object.defineProperty(t,"version",{get:function(){return l},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"appId",{get:function(){return wt.of(this._iid).sdkState.appId},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"appInfo",{get:function(){return wt.of(this._iid).appInfo},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"appVersion",{get:function(){var e;return null!==(e=wt.of(this._iid).sdkState.appVersion)&&void 0!==e?e:""},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"debugMode",{get:function(){return wt.of(this._iid).debugMode},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"logLevel",{get:function(){return wt.of(this._iid).logger.level},set:function(e){wt.of(this._iid).logger.level=e},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"isCacheEnabled",{get:function(){return wt.of(this._iid).cacheContext.localCacheEnabled},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"ekey",{get:function(){return je(this._iid)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"currentUser",{get:function(){var e;return null!==(e=wt.of(this._iid).sessionManager.currentUser)&&void 0!==e?e:null},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"connectionState",{get:function(){var t=wt.of(this._iid).connectionManager;return t.isConnected?e.ConnectionState.OPEN:t.isConnecting?e.ConnectionState.CONNECTING:e.ConnectionState.CLOSED},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"lastConnectedAt",{get:function(){var e=wt.of(this._iid),t=e.connectedAt;return e.connectionManager.isConnected?t:0},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"fcmPushToken",{get:function(){return this._fcmPushToken},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"apnsPushToken",{get:function(){return this._apnsPushToken},enumerable:!1,configurable:!0}),t.prototype._getPreferenceCacheKey=function(e){return"sendbird@".concat(this.appId,"/").concat(e,".pref")},t.prototype._getUserProfileCacheKey=function(e){return"sendbird@".concat(this.appId,"/").concat(e,".profile")},t.prototype.getMemoryStoreForDebugging=function(){var e=wt.of(this._iid),t=e.debugMode,n=e.cacheContext;if(t)return n.store instanceof na?n.store:null;throw f.debugModeRequired},t.prototype.addExtension=function(e,t){var n=wt.of(this._iid).sdkState;["sb_uikit","sb_syncmanager","device-os-platform"].indexOf(e)>-1&&(n.extensions[e]=t)},t.prototype.setOnlineListener=function(e){this._onlineDetector.setOnlineListener(e)},t.prototype.setOfflineListener=function(e){this._onlineDetector.setOfflineListener(e)},t.prototype.initializeCache=function(t){return i(this,void 0,void 0,(function(){var n,r,i,a,o,u,c,l;return s(this,(function(s){switch(s.label){case 0:return n=wt.of(this._iid),r=n.sdkState,i=n.cacheContext,a=n.connectionManager,o=n.dispatcher,r.userId&&r.userId===t?[3,6]:[4,a.logout()];case 1:return s.sent(),r.userId=t,i.localCacheEnabled?(u="sendbird@".concat(r.appId,"/").concat(t,".db"),i.nestdb&&i.nestdb.state!==Xs.CLOSED&&i.nestdb.name===u?[3,3]:((c=i.nestdb=new la({name:"sendbird@".concat(r.appId,"/").concat(t,".db"),version:1,store:i.store})).on("upgrade",function(t){return function(n,r){0===n?t.commitSchema([{collectionName:Ir,keyName:"url",index:[wr(e.GroupChannelListOrder.LATEST_LAST_MESSAGE),wr(e.GroupChannelListOrder.CHRONOLOGICAL),wr(e.GroupChannelListOrder.CHANNEL_NAME_ALPHABETICAL)]},{collectionName:Sr,keyName:"messageId",index:[Ur(Nr.CHANNEL_LATEST),Ur(Nr.NEWEST_CHILD_MESSAGE)]},{collectionName:Qr,keyName:"reqId",index:[Ur(Nr.CHANNEL_LATEST),Ur(Nr.NEWEST_CHILD_MESSAGE)]},{collectionName:"Poll",keyName:"pollId"}]).then((function(){return r()})).catch((function(e){return r(e)})):r()}}(c)),[4,c.open()])):[3,6];case 2:s.sent(),o.dispatch(new ti(this._iid,{userId:t})),s.label=3;case 3:return[4,i.preference.init(this._getPreferenceCacheKey(t))];case 4:return s.sent(),[4,i.preference.get(this._getUserProfileCacheKey(t))];case 5:(l=s.sent())&&new pt(this._iid,l).apply(),s.label=6;case 6:return[2]}}))}))},t.prototype.clearCachedData=function(){return i(this,void 0,void 0,(function(){var e;return s(this,(function(t){switch(t.label){case 0:return(e=wt.of(this._iid).cacheContext).localCacheEnabled?(e.nestdb&&e.nestdb.clear(),[4,e.preference.clear()]):[3,2];case 1:t.sent(),t.label=2;case 2:return[2]}}))}))},t.prototype.clearCachedMessages=function(e){return i(this,void 0,void 0,(function(){var t,n,r=this;return s(this,(function(a){switch(a.label){case 0:return ct(b("string",e)).throw(f.invalidParameters),t=Wr.of(this._iid),n=jr.of(this._iid),t&&n?[4,Promise.all(e.map((function(e){return i(r,void 0,void 0,(function(){return s(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:a.sent(),a.label=2;case 2:return[2]}}))}))},t.prototype.connect=function(e,t){return void 0===t&&(t=null),i(this,void 0,void 0,(function(){var n,r,i,a,o,u,c;return s(this,(function(s){switch(s.label){case 0:ct(g("string",e)&&g("string",t,!0)).throw(f.invalidParameters),n=wt.of(this._iid),r=n.sdkState,i=n.cacheContext,a=n.connectionManager,o=n.statLogCollector,s.label=1;case 1:return s.trys.push([1,3,,4]),[4,this.initializeCache(e)];case 2:return s.sent(),[3,4];case 3:return s.sent(),u=wt.of(this._iid).logger,i.localCacheEnabled=!1,u.warn("Cache initialization failed - cache is not available."),[3,4];case 4:return[4,o.init("sendbird@".concat(r.appId,"/").concat(e,".statlog"))];case 5:return s.sent(),[4,a.connect(t)];case 6:return s.sent(),this._appStateChangeDetector.start(),r.appState="foreground",[4,null==(c=$r.of(this._iid))?void 0:c.processNonAutoResendRegisteredPendingMessages()];case 7:return s.sent(),this._onlineDetector.start(),[2,this.currentUser]}}))}))},t.prototype.reconnect=function(){var e=wt.of(this._iid),t=e.connectionManager,n=e.sdkState,r=e.sessionManager.auth.hasSession;return r&&t.resetAndReconnect().then((function(){n.appState="foreground"})).catch((function(){})),r},t.prototype.disconnect=function(){return i(this,void 0,void 0,(function(){var e,t,n,r;return s(this,(function(i){switch(i.label){case 0:return e=wt.of(this._iid),t=e.connectionManager,n=e.cacheContext,r=e.requestQueue,this._appStateChangeDetector.stop(),this._onlineDetector.stop(),r.cancelAll(),[4,t.logout()];case 1:return i.sent(),n.localCacheEnabled?[4,this.clearCachedData()]:[3,3];case 2:i.sent(),i.label=3;case 3:return[2]}}))}))},t.prototype.setBackgroundState=function(){var e=wt.of(this._iid),t=e.connectionManager,n=e.sdkState,r=e.logger;"foreground"===n.appState&&(n.appState="background",r.debug("going background state"),t.background())},t.prototype.setForegroundState=function(){var e=wt.of(this._iid),t=e.connectionManager,n=e.sdkState,r=e.logger;"background"===n.appState&&(n.appState="foreground",r.debug("going foreground state"),t.resetAndReconnect())},t.prototype.setSessionHandler=function(e){ct(e instanceof br).throw(f.invalidParameters),wt.of(this._iid).sessionManager.handler=e},t.prototype.addUserEventHandler=function(e,t){ct(g("string",e)&&t instanceof Tr).throw(f.invalidParameters),wt.of(this._iid).userEventHandlers.set(e,t)},t.prototype.removeUserEventHandler=function(e){wt.of(this._iid).userEventHandlers.delete(e)},t.prototype.removeAllUserEventHandler=function(){wt.of(this._iid).userEventHandlers.clear()},t.prototype.addConnectionHandler=function(e,t){ct(g("string",e)&&t instanceof Cr).throw(f.invalidParameters),wt.of(this._iid).connectionHandlers.set(e,t)},t.prototype.removeConnectionHandler=function(e){wt.of(this._iid).connectionHandlers.delete(e)},t.prototype.removeAllConnectionHandler=function(){wt.of(this._iid).connectionHandlers.clear()},t.prototype.createApplicationUserListQuery=function(e){return void 0===e&&(e={}),new is(this._iid,e)},t.prototype.createBlockedUserListQuery=function(e){return void 0===e&&(e={}),new os(this._iid,e)},t.prototype.createFriendListQuery=function(e){return void 0===e&&(e={}),new ls(this._iid,e)},t.prototype.createMessageSearchQuery=function(e){return new Qn(this._iid,e)},t.prototype.createPollListQuery=function(e){return new _r(this._iid,r({},e))},t.prototype.createPollVoterListQuery=function(e){return new gr(this._iid,r({},e))},t.prototype.buildUserFromSerializedData=function(e){var t=ut(e);return new ht(this._iid,ht.payloadify(t))},t.prototype.updateCurrentUserInfo=function(e){return void 0===e&&(e={}),i(this,void 0,void 0,(function(){var t,n,i,a,o,u,c;return s(this,(function(s){switch(s.label){case 0:return t=r(r({},Er),e),ct(function(e){return T(e.profileImage,!0)&&g("string",e.profileUrl,!0)&&g("string",e.nickname,!0)}(t)).throw(f.invalidParameters),this.currentUser?(n=wt.of(this._iid),i=n.sdkState,a=n.requestQueue,o=new ri(r({userId:i.userId},t)),[4,a.send(o)]):[3,2];case 1:return u=s.sent(),c=u.as(ii).user,this.currentUser&&(t.nickname&&(this.currentUser.nickname=c.nickname),(t.profileUrl||t.profileImage)&&(this.currentUser.plainProfileUrl=c.profileUrl)),[2,c];case 2:throw f.connectionRequired}}))}))},t.prototype.updateCurrentUserInfoWithPreferredLanguages=function(e){return i(this,void 0,void 0,(function(){var t,n,r,i,a,o;return s(this,(function(s){switch(s.label){case 0:return ct(b("string",e)).throw(f.invalidParameters),this.currentUser?(t=wt.of(this._iid),n=t.sdkState,r=t.requestQueue,i=new ri({userId:n.userId,preferredLanguages:e}),[4,r.send(i)]):[3,2];case 1:return a=s.sent(),o=a.as(ii).user,this.currentUser&&(this.currentUser.preferredLanguages=o.preferredLanguages),[2,o];case 2:throw f.connectionRequired}}))}))},t.prototype.registerFCMPushTokenForCurrentUser=function(t){return i(this,void 0,void 0,(function(){var n,r,i,a;return s(this,(function(s){switch(s.label){case 0:if(ct(g("string",t)).throw(f.invalidParameters),!this.currentUser)return[3,5];s.label=1;case 1:return s.trys.push([1,3,,4]),n=wt.of(this._iid),r=n.sdkState,i=n.requestQueue,a=new ai({userId:r.userId,token:t}),[4,i.send(a)];case 2:return s.sent(),this._fcmPushToken="",[2,e.PushTokenRegistrationState.SUCCESS];case 3:return s.sent(),[2,e.PushTokenRegistrationState.ERROR];case 4:return[3,6];case 5:return this._fcmPushToken=t,[2,e.PushTokenRegistrationState.PENDING];case 6:return[2]}}))}))},t.prototype.unregisterFCMPushTokenForCurrentUser=function(t){return i(this,void 0,void 0,(function(){var n,r,i,a;return s(this,(function(s){switch(s.label){case 0:if(ct(g("string",t)).throw(f.invalidParameters),!this.currentUser)return[3,5];s.label=1;case 1:return s.trys.push([1,3,,4]),n=wt.of(this._iid),r=n.sdkState,i=n.requestQueue,a=new ui({userId:r.userId,token:t}),[4,i.send(a)];case 2:return s.sent(),this._fcmPushToken="",[2,e.PushTokenRegistrationState.SUCCESS];case 3:return s.sent(),[2,e.PushTokenRegistrationState.ERROR];case 4:return[3,6];case 5:return this._fcmPushToken=t,[2,e.PushTokenRegistrationState.PENDING];case 6:return[2]}}))}))},t.prototype.unregisterFCMPushTokenAllForCurrentUser=function(){return i(this,void 0,void 0,(function(){var e,t,n,r;return s(this,(function(i){switch(i.label){case 0:return this.currentUser?(e=wt.of(this._iid),t=e.sdkState,n=e.requestQueue,r=new li({userId:t.userId}),[4,n.send(r)]):[3,2];case 1:i.sent(),i.label=2;case 2:return[2]}}))}))},t.prototype.registerAPNSPushTokenForCurrentUser=function(t){return i(this,void 0,void 0,(function(){var n,r,i,a;return s(this,(function(s){switch(s.label){case 0:if(ct(g("string",t)).throw(f.invalidParameters),!this.currentUser)return[3,5];s.label=1;case 1:return s.trys.push([1,3,,4]),n=wt.of(this._iid),r=n.sdkState,i=n.requestQueue,a=new si({userId:r.userId,token:t}),[4,i.send(a)];case 2:return s.sent(),this._fcmPushToken="",[2,e.PushTokenRegistrationState.SUCCESS];case 3:return s.sent(),[2,e.PushTokenRegistrationState.ERROR];case 4:return[3,6];case 5:return this._fcmPushToken=t,[2,e.PushTokenRegistrationState.PENDING];case 6:return[2]}}))}))},t.prototype.unregisterAPNSPushTokenForCurrentUser=function(t){return i(this,void 0,void 0,(function(){var n,r,i,a;return s(this,(function(s){switch(s.label){case 0:if(ct(g("string",t)).throw(f.invalidParameters),!this.currentUser)return[3,5];s.label=1;case 1:return s.trys.push([1,3,,4]),n=wt.of(this._iid),r=n.sdkState,i=n.requestQueue,a=new oi({userId:r.userId,token:t}),[4,i.send(a)];case 2:return s.sent(),this._fcmPushToken="",[2,e.PushTokenRegistrationState.SUCCESS];case 3:return s.sent(),[2,e.PushTokenRegistrationState.ERROR];case 4:return[3,6];case 5:return this._fcmPushToken=t,[2,e.PushTokenRegistrationState.PENDING];case 6:return[2]}}))}))},t.prototype.unregisterAPNSPushTokenAllForCurrentUser=function(){return i(this,void 0,void 0,(function(){var e,t,n,r;return s(this,(function(i){switch(i.label){case 0:return this.currentUser?(e=wt.of(this._iid),t=e.sdkState,n=e.requestQueue,r=new ci({userId:t.userId}),[4,n.send(r)]):[3,2];case 1:i.sent(),i.label=2;case 2:return[2]}}))}))},t.prototype.getChannelInvitationPreference=function(){return i(this,void 0,void 0,(function(){var e,t,n,r,i;return s(this,(function(s){switch(s.label){case 0:return e=wt.of(this._iid),t=e.sdkState,n=e.requestQueue,r=new pi({userId:t.userId}),[4,n.send(r)];case 1:return i=s.sent(),[2,{autoAccept:i.as(fi).autoAccept}]}}))}))},t.prototype.setChannelInvitationPreference=function(e){return i(this,void 0,void 0,(function(){var t,n,r,i,a;return s(this,(function(s){switch(s.label){case 0:return ct(g("boolean",e)).throw(f.invalidParameters),t=wt.of(this._iid),n=t.sdkState,r=t.requestQueue,i=new _i({userId:n.userId,willAutoAccept:e}),[4,r.send(i)];case 1:return a=s.sent(),[2,{autoAccept:a.as(vi).autoAccept}]}}))}))},t.prototype.getDoNotDisturb=function(){return i(this,void 0,void 0,(function(){var e,t,n,r,i;return s(this,(function(s){switch(s.label){case 0:return e=wt.of(this._iid),t=e.sdkState,n=e.requestQueue,r=new mi({userId:t.userId}),[4,n.send(r)];case 1:return i=s.sent(),[2,i.as(gi).preference]}}))}))},t.prototype.setDoNotDisturb=function(e,t,n,r,a,o){return void 0===t&&(t=0),void 0===n&&(n=0),void 0===r&&(r=0),void 0===a&&(a=0),void 0===o&&(o=""),i(this,void 0,void 0,(function(){var i,u,c,l,h;return s(this,(function(s){switch(s.label){case 0:return ct(g("boolean",e)&&g("number",t)&&g("number",n)&&g("number",r)&&g("number",a)&&g("string",o)).throw(f.invalidParameters),i=wt.of(this._iid),u=i.sdkState,c=i.requestQueue,l=new yi({userId:u.userId,doNotDisturbOn:e,startHour:t,startMin:n,endHour:r,endMin:a,timezone:o}),[4,c.send(l)];case 1:return h=s.sent(),[2,h.as(Ei).preference]}}))}))},t.prototype.getSnoozePeriod=function(){return i(this,void 0,void 0,(function(){var e,t,n,r,i;return s(this,(function(s){switch(s.label){case 0:return e=wt.of(this._iid),t=e.sdkState,n=e.requestQueue,r=new bi({userId:t.userId}),[4,n.send(r)];case 1:return i=s.sent(),[2,i.as(Ci).snoozePeriod]}}))}))},t.prototype.setSnoozePeriod=function(e,t,n){return void 0===t&&(t=0),void 0===n&&(n=0),i(this,void 0,void 0,(function(){var r,i,a,o,u;return s(this,(function(s){switch(s.label){case 0:return ct(g("boolean",e)&&g("number",t)&&g("number",n)).throw(f.invalidParameters),r=wt.of(this._iid),i=r.sdkState,a=r.requestQueue,o=new Ti({userId:i.userId,snoozeOn:e,startTs:t,endTs:n}),[4,a.send(o)];case 1:return u=s.sent(),[2,u.as(Ii).snoozePeriod]}}))}))},t.prototype.getMyPushTokensByToken=function(t,n){return i(this,void 0,void 0,(function(){var r,i,a,o,u;return s(this,(function(s){switch(s.label){case 0:return ct(g("string",t)&&y(e.PushTokenType,n)).throw(f.invalidParameters),r=wt.of(this._iid),i=r.sdkState,a=r.requestQueue,o=new hi({userId:i.userId,type:n,token:t}),[4,a.send(o)];case 1:return u=s.sent(),[2,u.as(di).pushTokens]}}))}))},t.prototype.getPushTriggerOption=function(){return i(this,void 0,void 0,(function(){var e,t,n,r;return s(this,(function(i){switch(i.label){case 0:return e=wt.of(this._iid),t=e.sdkState,n=e.requestQueue,r=new wi({userId:t.userId}),[4,n.send(r)];case 1:return[2,i.sent().as(Mi).pushTriggerOption]}}))}))},t.prototype.setPushTriggerOption=function(t){return i(this,void 0,void 0,(function(){var n,r,i,a;return s(this,(function(s){switch(s.label){case 0:return ct(y(e.PushTriggerOption,t)).throw(f.invalidParameters),n=wt.of(this._iid),r=n.sdkState,i=n.requestQueue,a=new Ai({userId:r.userId,pushTriggerOption:t}),[4,i.send(a)];case 1:return[2,s.sent().as(Ui).pushTriggerOption]}}))}))},t.prototype.getPushTemplate=function(){return i(this,void 0,void 0,(function(){var e,t,n,r;return s(this,(function(i){switch(i.label){case 0:return e=wt.of(this._iid),t=e.sdkState,n=e.requestQueue,r=new Oi({userId:t.userId}),[4,n.send(r)];case 1:return[2,i.sent().as(Ri).name]}}))}))},t.prototype.setPushTemplate=function(t){return i(this,void 0,void 0,(function(){var n,r,i,a;return s(this,(function(s){switch(s.label){case 0:return ct(y(e.PushTemplate,t)).throw(f.invalidParameters),n=wt.of(this._iid),r=n.sdkState,i=n.requestQueue,a=new Li({userId:r.userId,templateName:t}),[4,i.send(a)];case 1:return[2,s.sent().as(ki).name]}}))}))},t.prototype.blockUser=function(e){return i(this,void 0,void 0,(function(){var t,n,r,i;return s(this,(function(s){switch(s.label){case 0:return ct(e instanceof ht||g("string",e)).throw(f.invalidParameters),t=wt.of(this._iid),n=t.sdkState,r=t.requestQueue,i=new Si({userId:n.userId,blockedUserId:e instanceof ht?e.userId:e}),[4,r.send(i)];case 1:return s.sent(),[2]}}))}))},t.prototype.blockUserWithUserId=function(e){return i(this,void 0,void 0,(function(){return s(this,(function(t){return[2,this.blockUser(e)]}))}))},t.prototype.unblockUser=function(e){return i(this,void 0,void 0,(function(){var t,n,r,i;return s(this,(function(s){switch(s.label){case 0:return ct(e instanceof ht||g("string",e)).throw(f.invalidParameters),t=wt.of(this._iid),n=t.sdkState,r=t.requestQueue,i=new Ni({userId:n.userId,unblockedUserId:e instanceof ht?e.userId:e}),[4,r.send(i)];case 1:return s.sent(),[2]}}))}))},t.prototype.unblockUserWithUserId=function(e){return i(this,void 0,void 0,(function(){return s(this,(function(t){return[2,this.unblockUser(e)]}))}))},t.prototype.getFriendChangeLogsByToken=function(e){return i(this,void 0,void 0,(function(){var t,n,r,i,a;return s(this,(function(s){switch(s.label){case 0:return ct(g("string",e)).throw(f.invalidParameters),t=wt.of(this._iid),n=t.sdkState,r=t.requestQueue,i=new Di({userId:n.userId,token:e}),[4,r.send(i)];case 1:return a=s.sent(),[2,a.as(Pi).changelogs]}}))}))},t.prototype.getAllowFriendDiscovery=function(){return i(this,void 0,void 0,(function(){var e,t,n,r,i;return s(this,(function(s){switch(s.label){case 0:return e=wt.of(this._iid),t=e.sdkState,n=e.requestQueue,r=new Ki({userId:t.userId}),[4,n.send(r)];case 1:return i=s.sent(),[2,i.as(Qi).allowFriendDiscovery]}}))}))},t.prototype.setAllowFriendDiscovery=function(e){return i(this,void 0,void 0,(function(){var t,n,r,i;return s(this,(function(s){switch(s.label){case 0:return ct(g("boolean",e)).throw(f.invalidParameters),t=wt.of(this._iid),n=t.sdkState,r=t.requestQueue,i=new Bi({userId:n.userId,allowFriendDiscovery:e}),[4,r.send(i)];case 1:return s.sent(),[2,e]}}))}))},t.prototype.uploadFriendDiscoveries=function(e){return i(this,void 0,void 0,(function(){var t,n,r,i,a;return s(this,(function(s){switch(s.label){case 0:return t=wt.of(this._iid),n=t.sdkState,r=t.requestQueue,i=new xi({userId:n.userId,discoveries:e}),[4,r.send(i)];case 1:return a=s.sent(),[2,a.as(Fi).friendDiscoveryRequestId]}}))}))},t.prototype.deleteFriendDiscovery=function(e){return i(this,void 0,void 0,(function(){return s(this,(function(t){return[2,this.deleteFriendDiscoveries([e])]}))}))},t.prototype.deleteFriendDiscoveries=function(e){return i(this,void 0,void 0,(function(){var t,n,r,i;return s(this,(function(s){switch(s.label){case 0:return ct(b("string",e)).throw(f.invalidParameters),t=wt.of(this._iid),n=t.sdkState,r=t.requestQueue,i=new qi({userId:n.userId,discoveryKeys:e}),[4,r.send(i)];case 1:return s.sent(),[2]}}))}))},t.prototype.addFriends=function(e){return i(this,void 0,void 0,(function(){var t,n,r,i,a;return s(this,(function(s){switch(s.label){case 0:return ct(b("string",e)).throw(f.invalidParameters),t=wt.of(this._iid),n=t.sdkState,r=t.requestQueue,i=new Gi({userId:n.userId,userIds:e}),[4,r.send(i)];case 1:return a=s.sent(),[2,a.as(Hi).users]}}))}))},t.prototype.deleteFriend=function(e){return i(this,void 0,void 0,(function(){return s(this,(function(t){return[2,this.deleteFriends([e])]}))}))},t.prototype.deleteFriends=function(e){return i(this,void 0,void 0,(function(){var t,n,r,i;return s(this,(function(s){switch(s.label){case 0:return ct(b("string",e)).throw(f.invalidParameters),t=wt.of(this._iid),n=t.sdkState,r=t.requestQueue,i=new Vi({userId:n.userId,userIds:e}),[4,r.send(i)];case 1:return s.sent(),[2]}}))}))},t.prototype.getAllEmoji=function(){return i(this,void 0,void 0,(function(){var e,t,n;return s(this,(function(r){switch(r.label){case 0:return e=wt.of(this._iid).requestQueue,t=new Ji,[4,e.send(t)];case 1:return n=r.sent(),[2,n.as(Xi).emojiContainer]}}))}))},t.prototype.getEmojiCategory=function(e){return i(this,void 0,void 0,(function(){var t,n,r;return s(this,(function(i){switch(i.label){case 0:return t=wt.of(this._iid).requestQueue,n=new Zi({categoryId:e}),[4,t.send(n)];case 1:return r=i.sent(),[2,r.as($i).emojiCategory]}}))}))},t.prototype.getEmoji=function(e){return i(this,void 0,void 0,(function(){var t,n,r;return s(this,(function(i){switch(i.label){case 0:return t=wt.of(this._iid).requestQueue,n=new es({key:e}),[4,t.send(n)];case 1:return r=i.sent(),[2,r.as(ts).emoji]}}))}))},t}();e.MemberState=void 0,(mo=e.MemberState||(e.MemberState={})).NONE="none",mo.JOINED="joined",mo.INVITED="invited",mo.LEFT="left";var Ro,Lo,ko,Do,Po,xo,Fo,qo,Go=function(t){function i(n,r){var i=t.call(this,n,r)||this;return i.state=null,i.role=null,i.isMuted=!1,i.isBlockedByMe=!1,i.isBlockingMe=!1,i.state=y(e.MemberState,r.state)?r.state:null,i.role=y(e.Role,r.role)?r.role:null,r.hasOwnProperty("is_muted")&&(i.isMuted=r.is_muted),r.hasOwnProperty("is_blocked_by_me")&&(i.isBlockedByMe=r.is_blocked_by_me),r.hasOwnProperty("is_blocking_me")&&(i.isBlockingMe=r.is_blocking_me),i}return n(i,t),i.payloadify=function(e){return e?D(r(r({},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},i}(pa),Ho=function(t){function r(n,r){var i,s,a=this;return(a=t.call(this,n)||this).channelUrl=null!==(i=r.channel_url)&&void 0!==i?i:"",a.channelType=null!==(s=r.channel_type)&&void 0!==s?s:e.ChannelType.GROUP,a.reader=new ht(a._iid,r.user),a.readAt=r.ts,a}return n(r,t),r}(We);e.PublicChannelFilter=void 0,(Ro=e.PublicChannelFilter||(e.PublicChannelFilter={})).ALL="all",Ro.PUBLIC="public",Ro.PRIVATE="private",e.MyMemberStateFilter=void 0,(Lo=e.MyMemberStateFilter||(e.MyMemberStateFilter={})).ALL="all",Lo.JOINED="joined_only",Lo.INVITED="invited_only",Lo.INVITED_BY_FRIEND="invited_by_friend",Lo.INVITED_BY_NON_FRIEND="invited_by_non_friend",e.SuperChannelFilter=void 0,(ko=e.SuperChannelFilter||(e.SuperChannelFilter={})).ALL="all",ko.SUPER="super",ko.NON_SUPER="nonsuper",ko.BROADCAST_ONLY="broadcast_only",ko.EXCLUSIVE_ONLY="exclusive_only",e.UnreadChannelFilter=void 0,(Do=e.UnreadChannelFilter||(e.UnreadChannelFilter={})).ALL="all",Do.UNREAD_MESSAGE="unread_message",e.HiddenChannelFilter=void 0,(Po=e.HiddenChannelFilter||(e.HiddenChannelFilter={})).ALL="all",Po.UNHIDDEN="unhidden_only",Po.HIDDEN="hidden_only",Po.HIDDEN_ALLOW_AUTO_UNHIDE="hidden_allow_auto_unhide",Po.HIDDEN_PREVENT_AUTO_UNHIDE="hidden_prevent_auto_unhide",e.OperatorFilter=void 0,(xo=e.OperatorFilter||(e.OperatorFilter={})).ALL="all",xo.OPERATOR="operator",xo.NONOPERATOR="nonoperator",e.QueryType=void 0,(Fo=e.QueryType||(e.QueryType={})).AND="AND",Fo.OR="OR",e.GroupChannelSearchField=void 0,(qo=e.GroupChannelSearchField||(e.GroupChannelSearchField={})).MEMBER_NICKNAME="member_nickname",qo.CHANNEL_NAME="channel_name";var Vo,Ko=function(){function 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 t.prototype._isFriend=function(e){return!!e.friendDiscoveryKey||!!e.friendName},Object.defineProperty(t.prototype,"searchFilter",{get:function(){return this._searchFilter},enumerable:!1,configurable:!0}),t.prototype.setSearchFilter=function(e,t){Array.isArray(e)&&0!==e.length&&"string"==typeof t&&t&&(this._searchFilter={query:t,fields:e})},Object.defineProperty(t.prototype,"userIdsFilter",{get:function(){return this._userIdsFilter},enumerable:!1,configurable:!0}),t.prototype.setUserIdsFilter=function(t,n,r){void 0===r&&(r=e.QueryType.AND),this._userIdsFilter={userIds:t,includeMode:n,queryType:r}},t.prototype.clone=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},t.prototype.match=function(t,n){if(this._searchFilter){var r=this._searchFilter,i=r.query,s=r.fields;if(i&&s&&s.length>0&&!s.some((function(n){switch(n){case e.GroupChannelSearchField.CHANNEL_NAME:return t.name.toLowerCase().includes(i.toLowerCase());case e.GroupChannelSearchField.MEMBER_NICKNAME:return t.members.some((function(e){return e.nickname.toLowerCase().includes(i.toLowerCase())}));default:return!0}})))return!1}if(this._userIdsFilter){var a=this._userIdsFilter,c=a.userIds,l=a.includeMode,h=a.queryType,d=t.members.map((function(e){return e.userId}));if(l){if(c.length>0)switch(h){case e.QueryType.AND:if(c.some((function(e){return!d.includes(e)})))return!1;break;case e.QueryType.OR:if(c.every((function(e){return!d.includes(e)})))return!1}}else{if(c.includes(n)||c.push(n),t.members.length>c.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=u([],o(e),!1).sort(),r=u([],o(t),!1).sort(),i=0;i0&&!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 p=this.nicknameContainsFilter.toLowerCase();if(t.members.every((function(e){return!e.nickname.toLowerCase().includes(p)})))return!1}if(this.nicknameStartsWithFilter){var f=this.nicknameStartsWithFilter.toLowerCase();if(t.members.every((function(e){return!e.nickname.toLowerCase().startsWith(f)})))return!1}if(this.nicknameExactMatchFilter){var _=this.nicknameExactMatchFilter.toLowerCase();if(t.members.every((function(e){return e.nickname.toLowerCase()!=_})))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}(),Qo=function(t){function c(e,n){var r=n.sdkState,i=n.cacheContext,s=t.call(this,e)||this;return s._channels=new Map,s._sdkState=r,s._cacheContext=i,s}return n(c,t),Object.defineProperty(c.prototype,"collection",{get:function(){var e=this._cacheContext.nestdb;return e?e.collection(Ir):null},enumerable:!1,configurable:!0}),Object.defineProperty(c.prototype,"localCacheEnabled",{get:function(){return this._cacheContext.localCacheEnabled&&!!this.collection},enumerable:!1,configurable:!0}),c.prototype._serialize=function(e,t){return void 0===t&&(t=0),r(r({},e.serialize()),{lastMessageUpdatedAt:e.lastMessage?e.lastMessage.createdAt:0,syncIndex:t})},c.prototype._deserialize=function(e){return lc.of(this._iid).buildGroupChannelFromSerializedData(e)},Object.defineProperty(c.prototype,"channels",{get:function(){return u([],o(this._channels.values()),!1)},enumerable:!1,configurable:!0}),c.prototype.isCachedInMemory=function(e){return this._channels.has(e)},c.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;break;case e.GroupChannelListOrder.CHRONOLOGICAL:if(!u&&t.createdAt>n||u&&t.createdAtn||u&&t.lastMessageUpdatedAt0?[4,this.upsert(r)]:[3,2];case 1:s.sent(),s.label=2;case 2:return[2]}}))}))},c.prototype.block=function(e,t){return i(this,void 0,void 0,(function(){return s(this,(function(n){switch(n.label){case 0:return[4,this._setBlockStateOfAllChannels(e,t,!0)];case 1:return n.sent(),[2]}}))}))},c.prototype.unblock=function(e,t){return i(this,void 0,void 0,(function(){return s(this,(function(n){switch(n.label){case 0:return[4,this._setBlockStateOfAllChannels(e,t,!1)];case 1:return n.sent(),[2]}}))}))},c.prototype.markAsRead=function(e,t){return void 0===t&&(t=u([],o(this._channels.keys()),!1)),i(this,void 0,void 0,(function(){var n,r,i,o,u,c,l,h;return s(this,(function(s){switch(s.label){case 0:n=[],s.label=1;case 1:s.trys.push([1,6,7,8]),r=a(t),i=r.next(),s.label=2;case 2:return i.done?[3,5]:(o=i.value,[4,this.get(o)]);case 3:(u=s.sent())._updateUnreadMemberState(this._sdkState.userId,e)&&(u._updateUnreadCount(0,0),n.push(u)),s.label=4;case 4:return i=r.next(),[3,2];case 5:return[3,8];case 6:return c=s.sent(),l={error:c},[3,8];case 7:try{i&&!i.done&&(h=r.return)&&h.call(r)}finally{if(l)throw l.error}return[7];case 8:return n.length>0?[4,this.upsert(n)]:[3,10];case 9:s.sent(),s.label=10;case 10:return[2]}}))}))},c}(We);!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"}(Vo||(Vo={}));var Bo,jo=function(){function t(e){this.channelUrl=e.channel_url,this.channelType=e.channel_type,this.category=e.cat,this.data=e.data,this.ts=e.ts}return Object.defineProperty(t.prototype,"isGroupChannelEvent",{get:function(){return this.channelType===e.ChannelType.GROUP},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"isOpenChannelEvent",{get:function(){return this.channelType===e.ChannelType.OPEN},enumerable:!1,configurable:!0}),t}(),zo={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},Wo=function(e){return b("string",e.invitedUserIds,!0)&&g("string",e.channelUrl,!0)&&g("string",e.coverUrl,!0)&&(T(e.coverImage)||g("string",e.coverImage)||null===e.coverImage)&&g("boolean",e.isDistinct,!0)&&g("boolean",e.isSuper,!0)&&g("boolean",e.isBroadcast,!0)&&g("boolean",e.isExclusive,!0)&&g("boolean",e.isPublic,!0)&&g("boolean",e.isStrict,!0)&&g("boolean",e.isDiscoverable,!0)&&g("boolean",e.isEphemeral,!0)&&g("string",e.accessCode,!0)&&g("string",e.name,!0)&&g("string",e.data,!0)&&g("string",e.customType,!0)&&b("string",e.operatorUserIds,!0)&&g("number",e.messageSurvivalSeconds,!0)},Yo={customTypes:null,includeEmpty:!1,includeFrozen:!0},Jo=function(e){return b("string",e.customTypes,!0)&&g("boolean",e.includeEmpty)&&g("boolean",e.includeFrozen)},Xo={myMemberStateFilter:e.MyMemberStateFilter.ALL},Zo=function(t){return y(e.MyMemberStateFilter,t.myMemberStateFilter)};e.UnreadItemKey=void 0,(Bo=e.UnreadItemKey||(e.UnreadItemKey={})).GROUP_CHANNEL_UNREAD_MENTION_COUNT="group_channel_unread_mention_count",Bo.NONSUPER_UNREAD_MENTION_COUNT="non_super_group_channel_unread_mention_count",Bo.SUPER_UNREAD_MENTION_COUNT="super_group_channel_unread_mention_count",Bo.GROUP_CHANNEL_UNREAD_MESSAGE_COUNT="group_channel_unread_message_count",Bo.NONSUPER_UNREAD_MESSAGE_COUNT="non_super_group_channel_unread_message_count",Bo.SUPER_UNREAD_MESSAGE_COUNT="super_group_channel_unread_message_count",Bo.GROUP_CHANNEL_INVITATION_COUNT="group_channel_invitation_count",Bo.NONSUPER_INVITATION_COUNT="non_super_group_channel_invitation_count",Bo.SUPER_INVITATION_COUNT="super_group_channel_invitation_count";var $o,eu={keys:[]},tu={channelCustomTypesFilter:null,superChannelFilter:e.SuperChannelFilter.ALL},nu={channelUrl:null,scheduledStatus:null,messageTypeFilter:e.MessageTypeFilter.ALL};e.GroupChannelEventSource=void 0,($o=e.GroupChannelEventSource||(e.GroupChannelEventSource={})).UNKNOWN="UNKNOWN",$o.EVENT_CHANNEL_CREATED="EVENT_CHANNEL_CREATED",$o.EVENT_CHANNEL_UPDATED="EVENT_CHANNEL_UPDATED",$o.EVENT_CHANNEL_DELETED="EVENT_CHANNEL_DELETED",$o.EVENT_CHANNEL_READ="EVENT_CHANNEL_READ",$o.EVENT_CHANNEL_DELIVERED="EVENT_CHANNEL_DELIVERED",$o.EVENT_CHANNEL_INVITED="EVENT_CHANNEL_INVITED",$o.EVENT_CHANNEL_JOINED="EVENT_CHANNEL_JOINED",$o.EVENT_CHANNEL_LEFT="EVENT_CHANNEL_LEFT",$o.EVENT_CHANNEL_ACCEPTED_INVITE="EVENT_CHANNEL_ACCEPTED_INVITE",$o.EVENT_CHANNEL_DECLINED_INVITE="EVENT_CHANNEL_DECLINED_INVITE",$o.EVENT_CHANNEL_OPERATOR_UPDATED="EVENT_CHANNEL_OPERATOR_UPDATED",$o.EVENT_CHANNEL_MUTED="EVENT_CHANNEL_MUTED",$o.EVENT_CHANNEL_UNMUTED="EVENT_CHANNEL_UNMUTED",$o.EVENT_CHANNEL_FROZEN="EVENT_CHANNEL_FROZEN",$o.EVENT_CHANNEL_UNFROZEN="EVENT_CHANNEL_UNFROZEN",$o.EVENT_CHANNEL_HIDDEN="EVENT_CHANNEL_HIDDEN",$o.EVENT_CHANNEL_UNHIDDEN="EVENT_CHANNEL_UNHIDDEN",$o.EVENT_CHANNEL_RESET_HISTORY="EVENT_CHANNEL_RESET_HISTORY",$o.EVENT_CHANNEL_TYPING_STATUS_UPDATE="EVENT_CHANNEL_TYPING_STATUS_UPDATE",$o.EVENT_CHANNEL_MEMBER_COUNT_UPDATED="EVENT_CHANNEL_MEMBER_COUNT_UPDATED",$o.EVENT_MESSAGE_SENT="EVENT_MESSAGE_SENT",$o.EVENT_MESSAGE_RECEIVED="EVENT_MESSAGE_RECEIVED",$o.EVENT_MESSAGE_UPDATED="EVENT_MESSAGE_UPDATED",$o.REQUEST_CHANNEL="REQUEST_CHANNEL",$o.REQUEST_CHANNEL_CHANGELOGS="REQUEST_CHANNEL_CHANGELOGS",$o.SYNC_CHANNEL_BACKGROUND="SYNC_CHANNEL_BACKGROUND",$o.SYNC_CHANNEL_CHANGELOGS="SYNC_CHANNEL_CHANGELOGS";var ru=function(t){return t.startsWith("EVENT_")||t===e.GroupChannelEventSource.SYNC_CHANNEL_BACKGROUND||t===e.GroupChannelEventSource.SYNC_CHANNEL_CHANGELOGS},iu=function(e){function t(t){var n=t.channels,r=t.source,i=e.call(this)||this;return i.channels=n,i.source=r,i}return n(t,e),t}(k),su=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 n(t,e),t}(k),au=function(){function e(e){var t=e.groupChannelCache,n=e.messageCache,r=e.unsentMessageCache,o=e.dispatcher,u=this;this._observers=new Map,o.on((function(e){return i(u,void 0,void 0,(function(){var o,u,c,l,h,d,p,f,_,v,m=this;return s(this,(function(g){switch(g.label){case 0:if(!(e instanceof iu))return[3,2];o=e.channels,f=e.source,u=o.filter((function(e){return e instanceof Sl})),c=t.filterOffsetChanged(u);try{for(l=a(c),h=l.next();!h.done;h=l.next())d=h.value,n.removeUnderOffset(d.url,d.messageOffsetTimestamp)}catch(e){_={error:e}}finally{try{h&&!h.done&&(v=l.return)&&v.call(l)}finally{if(_)throw _.error}}return[4,t.upsert(u)];case 1:return g.sent(),this._broadcastUpdateEvent(u,f),[3,7];case 2:return e instanceof su?(p=e.channelUrls,f=e.source,[4,t.remove(p)]):[3,5];case 3:return g.sent(),[4,Pe((function(){return i(m,void 0,void 0,(function(){var e,t,i,o,u,c;return s(this,(function(s){switch(s.label){case 0:s.trys.push([0,6,7,8]),e=a(p),t=e.next(),s.label=1;case 1:return t.done?[3,5]:(i=t.value,[4,n.removeMessagesOfChannel(i)]);case 2:return s.sent(),[4,r.removeMessagesOfChannel(i)];case 3:s.sent(),s.label=4;case 4:return t=e.next(),[3,1];case 5:return[3,8];case 6:return o=s.sent(),u={error:o},[3,8];case 7:try{t&&!t.done&&(c=e.return)&&c.call(e)}finally{if(u)throw u.error}return[7];case 8:return[2]}}))}))}))];case 4:return g.sent(),this._broadcastRemoveEvent(p,f),[3,7];case 5:return e instanceof ti?[4,t.fetch({token:Number.MAX_SAFE_INTEGER,limit:Number.MAX_SAFE_INTEGER})]:[3,7];case 6:g.sent(),g.label=7;case 7:return[2]}}))}))}))}return e.prototype._broadcastUpdateEvent=function(e,t){var n,r;try{for(var i=a(this._observers.values()),s=i.next();!s.done;s=i.next()){s.value.onUpdate(e,t)}}catch(e){n={error:e}}finally{try{s&&!s.done&&(r=i.return)&&r.call(i)}finally{if(n)throw n.error}}},e.prototype._broadcastRemoveEvent=function(e,t){var n,r;try{for(var i=a(this._observers.values()),s=i.next();!s.done;s=i.next()){s.value.onRemove(e,t)}}catch(e){n={error:e}}finally{try{s&&!s.done&&(r=i.return)&&r.call(i)}finally{if(n)throw n.error}}},e.prototype.subscribe=function(e,t){this._observers.set(e,t)},e.prototype.unsubscribe=function(e){this._observers.delete(e)},e}(),ou=function(){function e(e){var t=e.cacheContext,n=e.messageCache,r=e.unsentMessageCache,a=e.dispatcher,o=e.logger,u=this;this._cacheContext=null,this._observers=new Map,this._logger=null,this._cacheContext=t,this._logger=o,a.on((function(e){return i(u,void 0,void 0,(function(){var t,a,o,u,c,l,h,d,p,f,_,v,m,g=this;return s(this,(function(y){switch(y.label){case 0:return e instanceof yn?(t=e.messages,v=e.source,a=t.filter((function(e){return e.messageId>0})),o=t.filter((function(e){return 0===e.messageId})),a.length>0?[4,Pe((function(){return i(g,void 0,void 0,(function(){return s(this,(function(e){switch(e.label){case 0:return[4,n.upsert(a)];case 1:return e.sent(),[4,r.remove(a.map((function(e){return e instanceof Bt?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(a,v),y.label=2;case 2:return o.length>0?[4,Pe((function(){return i(g,void 0,void 0,(function(){return s(this,(function(e){switch(e.label){case 0:return[4,r.upsert(o)];case 1:return e.sent(),[2]}}))}))}))]:[3,4];case 3:y.sent(),this._broadcastUpdateEvent(o,v),y.label=4;case 4:return[3,21];case 5:return e instanceof En?(u=e.messageIds,v=e.source,[4,Pe((function(){return i(g,void 0,void 0,(function(){return s(this,(function(e){switch(e.label){case 0:return[4,n.remove(u)];case 1:return e.sent(),[2]}}))}))}))]):[3,7];case 6:return y.sent(),this._broadcastRemoveEvent(u,v),[3,21];case 7:return e instanceof bn?(c=e.reqId,v=e.source,[4,Pe((function(){return i(g,void 0,void 0,(function(){return s(this,(function(e){switch(e.label){case 0:return[4,r.remove([c])];case 1:return e.sent(),[2]}}))}))}))]):[3,9];case 8:return y.sent(),this._broadcastRemoveUnsentEvent(c,v),[3,21];case 9:return e instanceof Cn?(l=e.polls,v=e.source,this._cacheContext.localCacheEnabled?(h=l.map((function(e){return e.messageId})),[4,Promise.all(h.map((function(e){return n.get(e)})))]):[3,12]):[3,13];case 10:return(d=y.sent().filter((function(e){return e}))).length>0&&l.forEach((function(e){var t=d.find((function(t){return t.messageId===e.messageId}));t&&t.applyPoll(e)})),[4,Pe((function(){return i(g,void 0,void 0,(function(){return s(this,(function(e){switch(e.label){case 0:return[4,n.upsert(d)];case 1:return[2,e.sent()]}}))}))}))];case 11:y.sent(),y.label=12;case 12:return this._broadcastPollChangeLogEvent(l,v),[3,21];case 13:return e instanceof Tn?(p=e.event,v=e.source,[4,n.get(p.messageId)]):[3,17];case 14:return(f=y.sent())&&f.isUserMessage()&&f.poll&&f.poll.applyPollUpdateEvent(p)?[4,Pe((function(){return i(g,void 0,void 0,(function(){return s(this,(function(e){switch(e.label){case 0:return[4,n.upsert([f])];case 1:return[2,e.sent()]}}))}))}))]:[3,16];case 15:y.sent(),y.label=16;case 16:return this._broadcastPollUpdateEvent(p,v),[3,21];case 17:return e instanceof In?(_=e.event,v=e.source,[4,n.get(_.messageId)]):[3,21];case 18:return(m=y.sent())&&m.isUserMessage()&&m.poll&&m.poll.applyPollVoteEvent(_)?[4,Pe((function(){return i(g,void 0,void 0,(function(){return s(this,(function(e){switch(e.label){case 0:return[4,n.upsert([m])];case 1:return[2,e.sent()]}}))}))}))]:[3,20];case 19:y.sent(),y.label=20;case 20:this._broadcastPollVoteEvent(_,v),y.label=21;case 21:return[2]}}))}))}))}return e.prototype._broadcastUpdateEvent=function(e,t){var n,r;try{for(var i=a(this._observers.values()),s=i.next();!s.done;s=i.next()){s.value.onUpdate(e,t)}}catch(e){n={error:e}}finally{try{s&&!s.done&&(r=i.return)&&r.call(i)}finally{if(n)throw n.error}}},e.prototype._broadcastPollChangeLogEvent=function(e,t){var n,r;try{for(var i=a(this._observers.values()),s=i.next();!s.done;s=i.next()){s.value.onPollChangeLogUpdate(e,t)}}catch(e){n={error:e}}finally{try{s&&!s.done&&(r=i.return)&&r.call(i)}finally{if(n)throw n.error}}},e.prototype._broadcastPollUpdateEvent=function(e,t){var n,r;try{for(var i=a(this._observers.values()),s=i.next();!s.done;s=i.next()){s.value.onPollUpdate(e,t)}}catch(e){n={error:e}}finally{try{s&&!s.done&&(r=i.return)&&r.call(i)}finally{if(n)throw n.error}}},e.prototype._broadcastPollVoteEvent=function(e,t){var n,r;try{for(var i=a(this._observers.values()),s=i.next();!s.done;s=i.next()){s.value.onPollVote(e,t)}}catch(e){n={error:e}}finally{try{s&&!s.done&&(r=i.return)&&r.call(i)}finally{if(n)throw n.error}}},e.prototype._broadcastRemoveEvent=function(e,t){var n,r;try{for(var i=a(this._observers.values()),s=i.next();!s.done;s=i.next()){s.value.onRemove(e,t)}}catch(e){n={error:e}}finally{try{s&&!s.done&&(r=i.return)&&r.call(i)}finally{if(n)throw n.error}}},e.prototype._broadcastRemoveUnsentEvent=function(e,t){var n,r;try{for(var i=a(this._observers.values()),s=i.next();!s.done;s=i.next()){s.value.onRemoveUnsent(e,t)}}catch(e){n={error:e}}finally{try{s&&!s.done&&(r=i.return)&&r.call(i)}finally{if(n)throw n.error}}},e.prototype.subscribe=function(e,t){this._observers.set(e,t)},e.prototype.unsubscribe=function(e){this._observers.delete(e)},e}(),uu=function(e){function t(t){var n=t.userId,i=t.ts,s=t.token,a=t.filter,o=e.call(this)||this,u=r(r({},Yo),a),c=u.customTypes,l=u.includeEmpty,h=u.includeFrozen;return o.method=d.GET,o.path="".concat(fe,"/").concat(encodeURIComponent(n),"/my_group_channels/changelogs"),o.params=D({show_delivery_receipt:!0,show_member:!0,show_read_receipt:!0,change_ts:i>0?i:null,token:s,custom_types:c,show_empty:l,show_frozen:h}),o}return n(t,e),t}(x),cu=function(e){function t(t,n){var r=e.call(this,t,n)||this;return r.updatedChannels=n.updated.map((function(e){return new Sl(t,e)})),r.deletedChannelUrls=n.deleted,r.hasMore=n.has_more,r.token=n.next,r}return n(t,e),t}(F),lu=function(e){function t(t){var n=t.channelUrl,r=t.isInternalCall,i=e.call(this)||this;return i.method=d.GET,i.path="".concat(r?me:ve,"/").concat(encodeURIComponent(n)),i.params={show_member:!0,show_read_receipt:!0,show_delivery_receipt:!0},i}return n(t,e),t}(x),hu=function(e){function t(t,n){var r=e.call(this,t,n)||this;return r.channel=null,r.channel=new Sl(t,n),r}return n(t,e),t}(F),du=function(e){function t(t){var n=this,r=t.userId,i=t.token,s=t.limit,a=t.order,o=t.includeEmpty,u=t.myMemberStateFilter,c=t.superChannelFilter,l=t.publicChannelFilter,h=t.unreadChannelFilter,p=t.nicknameContainsFilter,f=t.nicknameStartsWithFilter,_=t.nicknameExactMatchFilter,v=t.channelNameContainsFilter,m=t.channelUrlsFilter,g=t.customTypesFilter,y=t.customTypeStartsWithFilter,E=t.hiddenChannelFilter,b=t.metadataOrderKeyFilter,C=t.metadataKey,T=t.metadataValues,I=t.metadataValueStartsWith,S=t.includeFrozen,N=t.includeMetaData,w=t.searchFilter,M=t.userIdsFilter;return(n=e.call(this)||this).method=d.GET,n.path="".concat(fe,"/").concat(encodeURIComponent(r),"/my_group_channels"),n.params=D({token:i,limit:s,order:a,show_member:!0,show_read_receipt:!0,show_delivery_receipt:!0,show_empty:o,member_state_filter:u,super_mode:c,public_mode:l,unread_filter:h,members_nickname_contains:p,members_nickname_startswith:f,members_nickname:_,name_contains:v,channel_urls:m,custom_types:g,custom_type_startswith:y,hidden_mode:E,metadata_order_key:b,metadata_key:C,metadata_values:T,metadata_value_startswith:I,show_frozen:S,show_metadata:N}),w&&w.query&&w.fields&&(n.params.search_query=w.query,n.params.search_fields=w.fields),M&&M.userIds&&M.userIds.length>0&&(M.includeMode?(n.params.members_include_in=M.userIds,n.params.query_type=M.queryType.toUpperCase()):n.params.members_exactly_in=M.userIds),n}return n(t,e),t}(x),pu=function(e){function t(t,n){var r=e.call(this,t,n)||this;r.token=null,r.channels=[],r.ts=null;var i=n.next,s=n.channels,a=n.ts;return r.token=i,s&&s.length>0&&(r.channels=s.map((function(e){return e.ts=a,new Sl(t,e)}))),r.ts=null!=a?a:null,r}return n(t,e),t}(F),fu=function(t){function r(n){var r=n.userId,i=n.filter,s=t.call(this)||this,a=i.myMemberStateFilter;return s.method=d.GET,s.path="".concat(fe,"/").concat(encodeURIComponent(r),"/group_channel_count"),s.params={state:null!=a?a:e.MyMemberStateFilter.ALL},s}return n(r,t),r}(x),_u=function(e){function t(t,n){var r=e.call(this,t,n)||this;return r.groupChannelCount=n.group_channel_count,r}return n(t,e),t}(F),vu=function(e){function t(t){var n=t.userId,r=t.filter,i=e.call(this)||this,s=r.keys;return i.method=d.GET,i.path="".concat(fe,"/").concat(encodeURIComponent(n),"/unread_item_count"),i.params={item_keys:s},i}return n(t,e),t}(x),mu=function(t){function r(n,r){var i=t.call(this,n,r)||this;return"number"==typeof r[e.UnreadItemKey.GROUP_CHANNEL_UNREAD_MENTION_COUNT]&&(i.groupChannelUnreadMentionCount=r[e.UnreadItemKey.GROUP_CHANNEL_UNREAD_MENTION_COUNT]),"number"==typeof r[e.UnreadItemKey.GROUP_CHANNEL_UNREAD_MESSAGE_COUNT]&&(i.groupChannelUnreadMessageCount=r[e.UnreadItemKey.GROUP_CHANNEL_UNREAD_MESSAGE_COUNT]),"number"==typeof r[e.UnreadItemKey.GROUP_CHANNEL_INVITATION_COUNT]&&(i.groupChannelInvitationCount=r[e.UnreadItemKey.GROUP_CHANNEL_INVITATION_COUNT]),"number"==typeof r[e.UnreadItemKey.SUPER_UNREAD_MENTION_COUNT]&&(i.superGroupChannelUnreadMentionCount=r[e.UnreadItemKey.SUPER_UNREAD_MENTION_COUNT]),"number"==typeof r[e.UnreadItemKey.SUPER_UNREAD_MESSAGE_COUNT]&&(i.superGroupChannelUnreadMessageCount=r[e.UnreadItemKey.SUPER_UNREAD_MESSAGE_COUNT]),"number"==typeof r[e.UnreadItemKey.SUPER_INVITATION_COUNT]&&(i.superGroupChannelInvitationCount=r[e.UnreadItemKey.SUPER_INVITATION_COUNT]),"number"==typeof r[e.UnreadItemKey.NONSUPER_UNREAD_MENTION_COUNT]&&(i.nonSuperGroupChannelUnreadMentionCount=r[e.UnreadItemKey.NONSUPER_UNREAD_MENTION_COUNT]),"number"==typeof r[e.UnreadItemKey.NONSUPER_UNREAD_MESSAGE_COUNT]&&(i.nonSuperGroupChannelUnreadMessageCount=r[e.UnreadItemKey.NONSUPER_UNREAD_MESSAGE_COUNT]),"number"==typeof r[e.UnreadItemKey.NONSUPER_INVITATION_COUNT]&&(i.nonSuperGroupChannelInvitationCount=r[e.UnreadItemKey.NONSUPER_INVITATION_COUNT]),i}return n(r,t),r}(F),gu=function(e){function t(t){var n=t.userId,r=e.call(this)||this;return r.method=d.GET,r.path="".concat(fe,"/").concat(encodeURIComponent(n),"/unread_channel_count"),r}return n(t,e),t}(x),yu=function(e){function t(t,n){var r=e.call(this,t,n)||this;return r.unreadCount=n.unread_count,r}return n(t,e),t}(F),Eu=function(t){function r(n){var r=n.userId,i=n.filter,s=t.call(this)||this,a=i.channelCustomTypesFilter,o=i.superChannelFilter;return s.method=d.GET,s.path="".concat(fe,"/").concat(encodeURIComponent(r),"/unread_message_count"),s.params={super_mode:null!=o?o:e.SuperChannelFilter.ALL,custom_types:a},s}return n(r,t),r}(x),bu=function(e){function t(t,n){var r=e.call(this,t,n)||this;return r.unreadCount=n.unread_count,r}return n(t,e),t}(F),Cu=function(e){function t(t){var n=t.channelUrl,r=t.scheduledStatus,i=t.messageTypeFilter,s=e.call(this)||this;return s.method=d.GET,s.path="".concat(Se,"/count"),s.params={channel_url:n,status:Iu(r)},i&&(s.params.message_type=i),s}return n(t,e),t}(x),Tu=function(e){function t(t,n){var r=e.call(this,t,n)||this;return r.count=n.count,r}return n(t,e),t}(F),Iu=function(t){if(t){var n=[];return t.forEach((function(t){switch(t){case e.ScheduledStatus.PENDING:n.push(kt.PENDING);break;case e.ScheduledStatus.SENT:n.push(kt.IN_QUEUE),n.push(kt.SENT);break;case e.ScheduledStatus.CANCELED:n.push(kt.CANCELED);break;case e.ScheduledStatus.FAILED:n.push(kt.FAILED)}})),n}},Su=function(e){function t(t){var n=this,r=t.userId,i=t.channelUrl,s=t.coverUrl,a=t.coverImage,c=t.isDistinct,l=t.isSuper,h=t.isBroadcast,p=t.isPublic,f=t.isExclusive,_=t.isDiscoverable,v=t.isStrict,m=t.isEphemeral,g=t.accessCode,y=t.name,E=t.data,b=t.customType,C=t.messageSurvivalSeconds,T=t.invitedUserIds,I=t.operatorUserIds;return(n=e.call(this)||this).method=d.POST,n.path=ve,n.params=D({user_ids:u([r],o(null!=T?T:[]),!1).filter((function(e,t,n){return t===n.indexOf(e)})),channel_url:i,cover_url:s,cover_file:a,is_distinct:c,is_super:l,is_broadcast:h,is_exclusive:f,is_public:p,is_discoverable:_,strict:v,is_ephemeral:m,access_code:g,name:y,data:E,custom_type:b,operator_ids:I,message_survival_seconds:C}),n}return n(t,e),t}(x),Nu=function(e){function t(t,n){var r=e.call(this,t,n)||this;return r.channel=new Sl(t,n),r.isCreated=n.is_created,r}return n(t,e),t}(F),wu=function(e){function t(t){var n=t.userId,r=t.channelUrls,i=e.call(this)||this;return i.method=d.PUT,i.path="".concat(fe,"/").concat(encodeURIComponent(n),"/mark_as_read_all"),i.params={channel_urls:r},i}return n(t,e),t}(x);!function(e){function t(){return null!==e&&e.apply(this,arguments)||this}n(t,e)}(F);var Mu=function(e){function t(t,n,r){var i=e.call(this,t,"SYEV",r)||this;return i.event=new jo(r),i}return n(t,e),t}(j),Au=function(e){function t(t){var n=this,r=t.channelUrl,i=t.userId,s=t.accessCode;return(n=e.call(this)||this).method=d.PUT,n.path="".concat(ve,"/").concat(encodeURIComponent(r),"/join"),n.params={user_id:i,access_code:s},n}return n(t,e),t}(x),Uu=function(e){function t(t,n){var r=e.call(this,t,n)||this;return r.channel=new Sl(t,n),r}return n(t,e),t}(F),Ou=function(e){function t(t,n,r){var i=e.call(this,t,n,r)||this,s=r.data,a=s.member_count,o=void 0===a?null:a,u=s.joined_member_count,c=void 0===u?null:u,l=s.users,h=void 0===l?null:l;return i.memberCount=o,i.joinedMemberCount=c,i.members=Array.isArray(h)?h.map((function(e){return new Go(t,e)})):[new Go(t,r.data)],i}return n(t,e),t}(Mu),Ru=function(e){function t(t){var n=this,r=t.channelUrl,i=t.userId,s=t.shouldRemoveOperatorStatus;return(n=e.call(this)||this).method=d.PUT,n.path="".concat(ve,"/").concat(encodeURIComponent(r),"/leave"),n.params={user_id:i,should_remove_operator_status:s},n}return n(t,e),t}(x);!function(e){function t(t,n){return e.call(this,t,n)||this}n(t,e)}(F);var Lu=function(e){function t(t,n,r){var i=e.call(this,t,n,r)||this,s=r.data,a=s.member_count,o=void 0===a?null:a,u=s.joined_member_count,c=void 0===u?null:u;return i.memberCount=o,i.joinedMemberCount=c,i.member=new Go(i._iid,r.data),i}return n(t,e),t}(Mu),ku=function(e){function t(t){var n=this,r=t.channelUrl,i=t.userIds;return(n=e.call(this)||this).method=d.POST,n.path="".concat(ve,"/").concat(encodeURIComponent(r),"/invite"),n.params={user_ids:i},n}return n(t,e),t}(x),Du=function(e){function t(t,n){var r=e.call(this,t,n)||this;return r.channel=new Sl(t,n),r}return n(t,e),t}(F),Pu=function(e){function t(t,n,r){var i=e.call(this,t,n,r)||this,s=r.data,a=s.member_count,o=void 0===a?null:a,u=s.joined_member_count,c=void 0===u?null:u,l=s.inviter,h=void 0===l?null:l,d=s.invitees,p=void 0===d?[]:d;return i.memberCount=o,i.joinedMemberCount=c,i.inviter=h?new ht(t,h):null,i.invitees=p.map((function(e){return new Go(t,e)})),i}return n(t,e),t}(Mu),xu=function(e){function t(t){var n=this,r=t.channelUrl,i=t.userId;return(n=e.call(this)||this).method=d.PUT,n.path="".concat(ve,"/").concat(encodeURIComponent(r),"/decline"),n.params={user_id:i},n}return n(t,e),t}(x),Fu=function(t){function r(n,r){var i=t.call(this,n,r)||this;return i.channel=new Sl(n,r),i.channel.myMemberState=e.MemberState.NONE,i}return n(r,t),r}(F),qu=function(e){function t(t,n,r){var i=e.call(this,t,n,r)||this,s=r.data,a=s.member_count,o=void 0===a?null:a,u=s.joined_member_count,c=void 0===u?null:u,l=s.inviter,h=void 0===l?null:l,d=s.invitee,p=void 0===d?null:d;return i.memberCount=o,i.joinedMemberCount=c,i.inviter=h?new ht(t,h):null,i.invitee=p?new Go(t,p):null,i}return n(t,e),t}(Mu),Gu=function(e){function t(t){var n=t.channelUrl;return e.call(this,{code:"READ",ackRequired:!0,payload:{channel_url:n}})||this}return n(t,e),t}(z),Hu=function(e){function t(t,n,r){var i=e.call(this,t,"READ",r)||this;return i.readStatus=new Ho(t,r),i}return n(t,e),t}(j),Vu=function(e){function t(t){var n=t.channelUrl,r=t.userId,i=e.call(this)||this;return(i=e.call(this)||this).method=d.PUT,i.path="".concat(ve,"/").concat(encodeURIComponent(n),"/messages/mark_as_delivered"),i.params=D({userId:r}),i}return n(t,e),t}(x);!function(e){function t(){return null!==e&&e.apply(this,arguments)||this}n(t,e)}(F);var Ku,Qu=function(e){function t(t,n,r){var i=e.call(this,t,"DLVR",r)||this;return i.channelUrl=r.channel_url,i.deliveredStateUpdate=r.updated,i}return n(t,e),t}(j),Bu=function(e){function t(t){var n=this,r=t.channelUrl,i=t.userId,s=t.hidePreviousMessages,a=t.allowAutoUnhide;return(n=e.call(this)||this).method=d.PUT,n.path="".concat(ve,"/").concat(encodeURIComponent(r),"/hide"),n.params={user_id:i,hide_previous_messages:s,allow_auto_unhide:a},n}return n(t,e),t}(x),ju=function(e){function t(t,n){var r=e.call(this,t,n)||this;r.messageOffsetTimestamp=null;var i=n.ts_message_offset;return r.messageOffsetTimestamp=null!=i?i:null,r}return n(t,e),t}(F),zu=function(e){function t(t,n,r){var i=e.call(this,t,"SYEV",r)||this;return i.allowAutoUnhide=null,i.hidePreviousMessages=null,i.messageOffsetTimestamp=null,r.data&&(i.allowAutoUnhide=r.data.allow_auto_unhide,i.hidePreviousMessages=r.data.hide_previous_messages),i.messageOffsetTimestamp=r.ts_message_offset,i}return n(t,e),t}(j),Wu=function(e){function t(t){var n=t.channelUrl,r=t.time;return e.call(this,{code:"TPST",ackRequired:!1,payload:{channel_url:n,time:r}})||this}return n(t,e),t}(z),Yu=function(e){function t(t,n,r){var i=e.call(this,t,"SYEV",r)||this;return i.user=new ht(t,r.data),i}return n(t,e),t}(j),Ju=function(e){function t(t){var n=t.channelUrl,r=t.time;return e.call(this,{code:"TPEN",ackRequired:!1,payload:{channel_url:n,time:r}})||this}return n(t,e),t}(z),Xu=function(e){function t(t,n,r){var i=e.call(this,t,"SYEV",r)||this;return i.user=new ht(t,r.data),i}return n(t,e),t}(j),Zu=function(e){function t(t,n,r){var i=e.call(this,t,n,r)||this,s=r.data.operators,a=void 0===s?[]:s;return i.operators=a.map((function(e){return new ht(i._iid,e)})),i}return n(t,e),t}(Mu),$u=function(e){function t(t,n,r){var i=e.call(this,t,"MCNT",r)||this;return i.groupChannelMemberCounts=r.group_channels.map((function(e){return{channelUrl:e.channel_url,memberCount:e.member_count,joinedMemberCount:e.joined_member_count,updatedAt:e.ts}})),i.openChannelMemberCounts=r.open_channels.map((function(e){return{channelUrl:e.channel_url,participantCount:e.participant_count,updatedAt:e.ts}})),i}return n(t,e),t}(j),ec=function(e){function t(t){var n=t.channelUrl,r=t.messageId;return e.call(this,{code:"MACK",ackRequired:!1,payload:{channel_url:n,msg_id:r}})||this}return n(t,e),t}(z),tc=function(e){function t(t,n,r){var i,s,a,o=this;(o=e.call(this,t,"ADMM",r)||this).message=new Yt(t,r);var u=wt.of(t).sdkState;return o.isMentioned=Ze(o.message.mentionType,null!==(i=o.message.mentionedUserIds)&&void 0!==i?i:null===(s=o.message.mentionedUsers)||void 0===s?void 0:s.map((function(e){return e.userId})),u.userId),o.forceUpdateLastMessage=null!==(a=r.force_update_last_message)&&void 0!==a&&a,o}return n(t,e),t}(j),nc=function(e){function t(t,n,r){var i,s,a,o,u,c,l=this;(l=e.call(this,t,"AEDI",r)||this).message=new Yt(t,r);var h=wt.of(t).sdkState;return l.mentionCountChange=$e({mentionType:null!==(s=null===(i=r.old_values)||void 0===i?void 0:i.mention_type)&&void 0!==s?s:null,mentionedUserIds:null!==(o=null===(a=r.old_values)||void 0===a?void 0:a.mentioned_user_ids)&&void 0!==o?o:[]},{mentionType:l.message.mentionType,mentionedUserIds:null!==(u=l.message.mentionedUserIds)&&void 0!==u?u:null===(c=l.message.mentionedUsers)||void 0===c?void 0:c.map((function(e){return e.userId}))},h.userId),l}return n(t,e),t}(j),rc=function(e){function t(t,n,r){var i=e.call(this,t,"MRCT",r)||this;return i.channelUrl=r.channel_url,i.channelType=r.channel_type,i.event=new Dt(r),i}return n(t,e),t}(j),ic=function(e){function t(t,n,r){var i=e.call(this,t,"MTHD",r)||this;return i.event=new Pn(t,r),i}return n(t,e),t}(j),sc=function(e){function t(t,n,r){var i=e.call(this,t,"PEDI",r)||this;return i.event=null,i.status=null,i.channelUrl=null,i.channelType=null,i.event=new hr(t,r),i.status=Zt(r.poll.status)||r.poll.status,i.channelUrl=r.channel_url,i.channelType=r.channel_type,i}return n(t,e),t}(j),ac=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 dr(r),i.channelUrl=r.channel_url,i.channelType=r.channel_type,i}return n(t,e),t}(j),oc=function(t){function r(n,r){var i,s,a,o,u,c,l,h,d,p,f,_,v,m,g,y,E,b,C,T,I,S,N=this;return(N=t.call(this,n,r)||this).includeEmpty=!1,N.includeFrozen=!0,N.includeMetaData=!0,N.channelUrlsFilter=null,N.customTypesFilter=null,N.customTypeStartsWithFilter=null,N.nicknameContainsFilter=null,N.nicknameStartsWithFilter=null,N.nicknameExactMatchFilter=null,N.channelNameContainsFilter="",N.myMemberStateFilter=e.MyMemberStateFilter.ALL,N.unreadChannelFilter=e.UnreadChannelFilter.ALL,N.superChannelFilter=e.SuperChannelFilter.ALL,N.publicChannelFilter=e.PublicChannelFilter.ALL,N.hiddenChannelFilter=e.HiddenChannelFilter.UNHIDDEN,N.searchFilter={fields:[],query:null},N.userIdsFilter={userIds:[],includeMode:!0,queryType:e.QueryType.AND},N.metadataKey=null,N.metadataValues=null,N.metadataOrderKeyFilter=null,N.metadataValueStartsWith=null,N.order=e.GroupChannelListOrder.LATEST_LAST_MESSAGE,N.includeEmpty=null!==(i=r.includeEmpty)&&void 0!==i&&i,N.includeFrozen=null===(s=r.includeFrozen)||void 0===s||s,N.includeMetaData=null===(a=r.includeMetaData)||void 0===a||a,N.channelUrlsFilter=null!==(o=r.channelUrlsFilter)&&void 0!==o?o:null,N.customTypesFilter=null!==(u=r.customTypesFilter)&&void 0!==u?u:null,N.customTypeStartsWithFilter=null!==(c=r.customTypeStartsWithFilter)&&void 0!==c?c:"",N.nicknameContainsFilter=null!==(l=r.nicknameContainsFilter)&&void 0!==l?l:null,N.nicknameStartsWithFilter=null!==(h=r.nicknameStartsWithFilter)&&void 0!==h?h:null,N.nicknameExactMatchFilter=null!==(d=r.nicknameExactMatchFilter)&&void 0!==d?d:null,N.channelNameContainsFilter=null!==(p=r.channelNameContainsFilter)&&void 0!==p?p:"",N.myMemberStateFilter=null!==(f=r.myMemberStateFilter)&&void 0!==f?f:e.MyMemberStateFilter.ALL,N.unreadChannelFilter=null!==(_=r.unreadChannelFilter)&&void 0!==_?_:e.UnreadChannelFilter.ALL,N.superChannelFilter=null!==(v=r.superChannelFilter)&&void 0!==v?v:e.SuperChannelFilter.ALL,N.publicChannelFilter=null!==(m=r.publicChannelFilter)&&void 0!==m?m:e.PublicChannelFilter.ALL,N.hiddenChannelFilter=null!==(g=r.hiddenChannelFilter)&&void 0!==g?g:e.HiddenChannelFilter.UNHIDDEN,N.searchFilter=null!==(y=r.searchFilter)&&void 0!==y?y:{fields:[],query:null},N.userIdsFilter=null!==(E=r.userIdsFilter)&&void 0!==E?E:{userIds:[],includeMode:!0,queryType:e.QueryType.AND},N.metadataKey=null!==(b=r.metadataKey)&&void 0!==b?b:null,N.metadataValues=null!==(C=r.metadataValues)&&void 0!==C?C:null,N.metadataOrderKeyFilter=null!==(T=r.metadataOrderKeyFilter)&&void 0!==T?T:null,N.metadataValueStartsWith=null!==(I=r.metadataValueStartsWith)&&void 0!==I?I:null,N.order=null!==(S=r.order)&&void 0!==S?S:e.GroupChannelListOrder.LATEST_LAST_MESSAGE,N}return n(r,t),r.prototype._validate=function(){return t.prototype._validate.call(this)&&g("boolean",this.includeEmpty)&&g("boolean",this.includeFrozen)&&g("boolean",this.includeMetaData)&&g("string",this.channelNameContainsFilter)&&b("string",this.channelUrlsFilter,!0)&&b("string",this.customTypesFilter,!0)&&g("string",this.customTypeStartsWithFilter)&&g("string",this.nicknameContainsFilter,!0)&&g("string",this.nicknameStartsWithFilter,!0)&&g("string",this.nicknameExactMatchFilter,!0)&&y(e.MyMemberStateFilter,this.myMemberStateFilter)&&y(e.SuperChannelFilter,this.superChannelFilter)&&y(e.PublicChannelFilter,this.publicChannelFilter)&&y(e.UnreadChannelFilter,this.unreadChannelFilter)&&y(e.HiddenChannelFilter,this.hiddenChannelFilter)&&b(e.GroupChannelSearchField,this.searchFilter.fields)&&g("string",this.searchFilter.query,!0)&&b("string",this.userIdsFilter.userIds)&&g("boolean",this.userIdsFilter.includeMode)&&y(e.QueryType,this.userIdsFilter.queryType)&&y(e.GroupChannelListOrder,this.order)&&g("string",this.metadataOrderKeyFilter,!0)&&g("string",this.metadataKey,!0)&&b("string",this.metadataValues,!0)&&g("string",this.metadataValueStartsWith,!0)},r.prototype.serialize=function(){return ot(this)},r.prototype.next=function(){return i(this,void 0,void 0,(function(){var e,t,n;return s(this,(function(r){switch(r.label){case 0:return this._validate()?this._isLoading?[3,3]:this._hasNext?(this._isLoading=!0,[4,lc.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 f.queryInProgress;case 4:return[3,6];case 5:throw f.invalidParameters;case 6:return[2]}}))}))},r}(Fn),uc=function(){function e(e){var t=e.top,n=void 0===t?Number.MAX_SAFE_INTEGER:t,r=e.bottom,i=void 0===r?0:r;this.top=n,this.bottom=i}return e.prototype.includes=function(){for(var e=this,t=[],n=0;n0||I.unreadMentionCount>0)&&(I._updateUnreadCount(0,0),this._dispatcher.dispatch(new iu({channels:[I],source:e.GroupChannelEventSource.EVENT_CHANNEL_READ})),De((function(){return i(Ot,void 0,void 0,(function(){var e,t,n,r;return s(this,(function(i){try{for(e=a(this._groupChannelHandlers.values()),t=e.next();!t.done;t=e.next())t.value.onChannelChanged(I)}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!==I.unreadMessageCount&&0!==I.unreadMentionCount||(this._dispatcher.dispatch(new iu({channels:[I],source:e.GroupChannelEventSource.EVENT_CHANNEL_READ})),De((function(){return i(Ot,void 0,void 0,(function(){var e,t,n,r;return s(this,(function(i){try{for(e=a(this._groupChannelHandlers.values()),t=e.next();!t.done;t=e.next())t.value.onChannelChanged(I)}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 iu({channels:[I],source:e.GroupChannelEventSource.EVENT_CHANNEL_READ})),De((function(){return i(Ot,void 0,void 0,(function(){var e,t,n,r;return s(this,(function(i){try{for(e=a(this._groupChannelHandlers.values()),t=e.next();!t.done;t=e.next())t.value.onUnreadMemberStatusUpdated(I)}catch(e){n={error:e}}finally{try{t&&!t.done&&(r=e.return)&&r.call(e)}finally{if(n)throw n.error}}return[2]}))}))}))),Rt.label=12;case 12:return[3,75];case 13:return S=t.as(Qu),X=S.channelUrl,N=S.deliveredStateUpdate,w=void 0===N?{}:N,M=this._groupChannelCache.isCachedInMemory(X),[4,this.getChannel(X,!0)];case 14:if(A=Rt.sent(),M)for(U in w)A._updateUndeliveredMemberState(U,w[U]);return this._dispatcher.dispatch(new iu({channels:[A],source:e.GroupChannelEventSource.EVENT_CHANNEL_DELIVERED})),Object.keys(w).some((function(e){return e!==Ot._sdkState.userId}))&&De((function(){return i(Ot,void 0,void 0,(function(){var e,t,n,r;return s(this,(function(i){try{for(e=a(this._groupChannelHandlers.values()),t=e.next();!t.done;t=e.next())t.value.onUndeliveredMemberStatusUpdated(A)}catch(e){n={error:e}}finally{try{t&&!t.done&&(r=e.return)&&r.call(e)}finally{if(n)throw n.error}}return[2]}))}))})),[3,75];case 15:return O=t.as(rc),X=O.channelUrl,Z=O.channelType,R=O.event,Z!==e.ChannelType.GROUP?[3,18]:[4,this.getChannel(X,!0)];case 16:return L=Rt.sent(),[4,this.getMessageFromCache(R.messageId)];case 17:(P=Rt.sent())&&(P.applyReactionEvent(R),this._dispatcher.dispatch(new yn({messages:[P],source:e.MessageEventSource.EVENT_MESSAGE_REACTION_UPDATED}))),De((function(){return i(Ot,void 0,void 0,(function(){var e,t,n,r;return s(this,(function(i){try{for(e=a(this._groupChannelHandlers.values()),t=e.next();!t.done;t=e.next())t.value.onReactionUpdated(L,R)}catch(e){n={error:e}}finally{try{t&&!t.done&&(r=e.return)&&r.call(e)}finally{if(n)throw n.error}}return[2]}))}))})),Rt.label=18;case 18:return[3,75];case 19:return(k=t.as(ic).event).channelType!==e.ChannelType.GROUP?[3,22]:[4,this.getChannel(k.channelUrl,!0)];case 20:return D=Rt.sent(),[4,this.getMessageFromCache(k.targetMessageId)];case 21:(P=Rt.sent())&&(P.applyThreadInfoUpdateEvent(k),this._dispatcher.dispatch(new yn({messages:[P],source:e.MessageEventSource.EVENT_MESSAGE_THREADINFO_UPDATED}))),De((function(){return i(Ot,void 0,void 0,(function(){var e,t,n,r;return s(this,(function(i){try{for(e=a(this._groupChannelHandlers.values()),t=e.next();!t.done;t=e.next())t.value.onThreadInfoUpdated(D,k)}catch(e){n={error:e}}finally{try{t&&!t.done&&(r=e.return)&&r.call(e)}finally{if(n)throw n.error}}return[2]}))}))})),Rt.label=22;case 22:return[3,75];case 23:x=t.as($u).groupChannelMemberCounts,F=[],Rt.label=24;case 24:Rt.trys.push([24,29,30,31]),q=a(x),G=q.next(),Rt.label=25;case 25:return G.done?[3,28]:(H=G.value,X=H.channelUrl,we=H.memberCount,Me=H.joinedMemberCount,V=H.updatedAt,[4,this.getChannelFromCache(X)]);case 26:(K=Rt.sent())&&K._setLatestMemberCount(we,Me,V)&&F.push(K),Rt.label=27;case 27:return G=q.next(),[3,25];case 28:return[3,31];case 29:return Q=Rt.sent(),Ct={error:Q},[3,31];case 30:try{G&&!G.done&&(Tt=q.return)&&Tt.call(q)}finally{if(Ct)throw Ct.error}return[7];case 31:return F.length>0&&(this._dispatcher.dispatch(new iu({channels:F,source:e.GroupChannelEventSource.EVENT_CHANNEL_MEMBER_COUNT_UPDATED})),De((function(){return i(Ot,void 0,void 0,(function(){var e,t,n,r;return s(this,(function(i){try{for(e=a(this._groupChannelHandlers.values()),t=e.next();!t.done;t=e.next())t.value.onChannelMemberCountChanged(F)}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,75];case 32:return B=t.as(sc),j=B.event,z=B.status,X=B.channelUrl,Z=B.channelType,X&&Z?[4,this.getChannel(X,!0)]:[3,75];case 33:return W=Rt.sent(),this._dispatcher.dispatch(new Tn({event:j,source:e.MessageEventSource.EVENT_POLL_UPDATED})),De("removed"===z?function(){return i(Ot,void 0,void 0,(function(){var e,t,n,r;return s(this,(function(i){try{for(e=a(this._groupChannelHandlers.values()),t=e.next();!t.done;t=e.next())t.value.onPollDeleted(W,j.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 i(Ot,void 0,void 0,(function(){var e,t,n,r;return s(this,(function(i){try{for(e=a(this._groupChannelHandlers.values()),t=e.next();!t.done;t=e.next())t.value.onPollUpdated(W,j)}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,75];case 34:return Y=t.as(ac),J=Y.event,X=Y.channelUrl,Z=Y.channelType,X&&Z?[4,this.getChannel(X,!0)]:[3,75];case 35:return $=Rt.sent(),this._dispatcher.dispatch(new In({event:J,source:e.MessageEventSource.EVENT_POLL_VOTED})),De((function(){return i(Ot,void 0,void 0,(function(){var e,t,n,r;return s(this,(function(i){try{for(e=a(this._groupChannelHandlers.values()),t=e.next();!t.done;t=e.next())t.value.onPollVoted($,J)}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,75];case 36:if(!(ee=t.as(Mu).event).isGroupChannelEvent)return[3,73];switch(ee.category){case Vo.CHANNEL_JOIN:return[3,37];case Vo.CHANNEL_LEAVE:return[3,39];case Vo.CHANNEL_OPERATOR_UPDATE:return[3,43];case Vo.CHANNEL_INVITE:return[3,45];case Vo.CHANNEL_DECLINE_INVITE:return[3,47];case Vo.TYPING_START:case Vo.TYPING_END:return[3,49];case Vo.USER_CHANNEL_MUTE:case Vo.USER_CHANNEL_UNMUTE:return[3,51];case Vo.USER_CHANNEL_BAN:return[3,53];case Vo.USER_CHANNEL_UNBAN:return[3,57];case Vo.CHANNEL_FREEZE:case Vo.CHANNEL_UNFREEZE:return[3,59];case Vo.CHANNEL_HIDE:return[3,61];case Vo.CHANNEL_UNHIDE:return[3,63];case Vo.CHANNEL_DELETED:return[3,65];case Vo.CHANNEL_PROP_CHANGED:return[3,67];case Vo.CHANNEL_META_DATA_CHANGED:return[3,69];case Vo.CHANNEL_META_COUNTERS_CHANGED:return[3,71]}return[3,73];case 37:return[4,this.getChannel(ee.channelUrl,!0)];case 38:return te=Rt.sent(),ne=t.as(Ou),re=ne.memberCount,ie=ne.joinedMemberCount,se=ne.members,ae=!1,se.forEach((function(t){te.isExclusive||te.isSuper||te.isBroadcast?ae=ae||te._setLatestMemberCount(re,ie,ee.ts):(t.state=e.MemberState.JOINED,te.addMember(t,ee.ts),Ot._updateJoinedMemberCount(te)),t.userId===Ot._sdkState.userId&&(te.myMemberState=e.MemberState.JOINED)})),this._dispatcher.dispatch(new iu({channels:[te],source:e.GroupChannelEventSource.EVENT_CHANNEL_JOINED})),De((function(){return i(Ot,void 0,void 0,(function(){return s(this,(function(e){return this._groupChannelHandlers.forEach((function(e){var t,n;try{for(var r=a(se),i=r.next();!i.done;i=r.next()){var s=i.value;e.onUserJoined(te,s)}}catch(e){t={error:e}}finally{try{i&&!i.done&&(n=r.return)&&n.call(r)}finally{if(t)throw t.error}}te.isBroadcast&&ae&&e.onChannelMemberCountChanged([te])})),[2]}))}))})),[3,73];case 39:return(Ve=this._leftChannels.get(ee.channelUrl))?(ue=Ve.channel,[3,42]):[3,40];case 40:return[4,this.getChannel(ee.channelUrl,!0)];case 41:ue=Rt.sent(),Rt.label=42;case 42:return oe=ue,ce=t.as(Lu),we=ce.memberCount,Me=ce.joinedMemberCount,le=ce.member,he=!1,de=wt.of(this._iid).appInfo,oe.isExclusive||oe.isSuper||oe.isBroadcast?he=oe._setLatestMemberCount(we,Me,ee.ts):(de.enabledChannelMemberShipHistory?(oe.members.find((function(e){return e.userId===le.userId})).state=e.MemberState.LEFT,oe.memberCount=we):oe.removeMember(le),this._updateJoinedMemberCount(oe)),le.userId===this._sdkState.userId?(oe.myMemberState=e.MemberState.NONE,oe.invitedAt=0,oe.joinedAt=0,oe._updateUnreadCount(0,0),oe.isPublic?this._dispatcher.dispatch(new iu({channels:[oe],source:e.GroupChannelEventSource.EVENT_CHANNEL_LEFT})):(this._markAsLeave(oe),this._dispatcher.dispatch(new su({channelUrls:[oe.url],source:e.GroupChannelEventSource.EVENT_CHANNEL_LEFT})))):this._dispatcher.dispatch(new iu({channels:[oe],source:e.GroupChannelEventSource.EVENT_CHANNEL_LEFT})),De((function(){return i(Ot,void 0,void 0,(function(){return s(this,(function(e){return this._groupChannelHandlers.forEach((function(e){e.onUserLeft(oe,le),oe.isBroadcast&&he&&e.onChannelMemberCountChanged([oe])})),[2]}))}))})),[3,73];case 43:return[4,this.getChannel(ee.channelUrl,!0)];case 44:pe=Rt.sent(),fe=t.as(Zu).operators,_e=fe.map((function(e){return e.userId}));try{for(ve=a(pe.members),me=ve.next();!me.done;me=ve.next())(He=me.value).role=_e.includes(He.userId)?e.Role.OPERATOR:e.Role.NONE}catch(e){It={error:e}}finally{try{me&&!me.done&&(St=ve.return)&&St.call(ve)}finally{if(It)throw It.error}}return pe.myRole=_e.includes(this._sdkState.userId)?e.Role.OPERATOR:e.Role.NONE,this._dispatcher.dispatch(new iu({channels:[pe],source:e.GroupChannelEventSource.EVENT_CHANNEL_OPERATOR_UPDATED})),De((function(){return i(Ot,void 0,void 0,(function(){return s(this,(function(e){return this._groupChannelHandlers.forEach((function(e){e.onOperatorUpdated(pe,fe)})),[2]}))}))})),[3,73];case 45:return[4,this.getChannel(ee.channelUrl,!0)];case 46:ge=Rt.sent(),ye=t.as(Pu),we=ye.memberCount,Me=ye.joinedMemberCount,Ee=ye.inviter,(be=ye.invitees).forEach((function(t){return t.state=e.MemberState.INVITED}));try{for(Ce=a(be),Te=Ce.next();!Te.done;Te=Ce.next())Ie=Te.value,ge.isExclusive||ge.isSuper||ge.isBroadcast?ge._setLatestMemberCount(we,Me,ee.ts):ge.addMember(Ie,ee.ts),this._sdkState.userId===Ie.userId&&(ge.hiddenState=e.HiddenState.UNHIDDEN,ge.myMemberState!==e.MemberState.JOINED&&(ge.myMemberState=e.MemberState.INVITED),ge.invitedAt=ee.ts)}catch(e){Nt={error:e}}finally{try{Te&&!Te.done&&(Mt=Ce.return)&&Mt.call(Ce)}finally{if(Nt)throw Nt.error}}return this._dispatcher.dispatch(new iu({channels:[ge],source:e.GroupChannelEventSource.EVENT_CHANNEL_INVITED})),De((function(){return i(Ot,void 0,void 0,(function(){return s(this,(function(e){return this._groupChannelHandlers.forEach((function(e){e.onUserReceivedInvitation(ge,Ee,be)})),[2]}))}))})),[3,73];case 47:return[4,this.getChannel(ee.channelUrl,!0)];case 48:return Se=Rt.sent(),Ne=t.as(qu),we=Ne.memberCount,Me=Ne.joinedMemberCount,Ae=Ne.inviter,Ue=Ne.invitee,Se.isExclusive||Se.isSuper||Se.isBroadcast?Se._setLatestMemberCount(we,Me,ee.ts):Se.removeMember(Ue),this._sdkState.userId===Ue.userId?(Se.invitedAt=0,Se.myMemberState=e.MemberState.NONE,Se.isPublic?this._dispatcher.dispatch(new iu({channels:[Se],source:e.GroupChannelEventSource.EVENT_CHANNEL_DECLINED_INVITE})):this._dispatcher.dispatch(new su({channelUrls:[Se.url],source:e.GroupChannelEventSource.EVENT_CHANNEL_DECLINED_INVITE}))):this._dispatcher.dispatch(new iu({channels:[Se],source:e.GroupChannelEventSource.EVENT_CHANNEL_DECLINED_INVITE})),De((function(){return i(Ot,void 0,void 0,(function(){return s(this,(function(e){return this._groupChannelHandlers.forEach((function(e){e.onUserDeclinedInvitation(Se,Ae,Ue)})),[2]}))}))})),[3,73];case 49:return[4,this.getChannel(ee.channelUrl,!0)];case 50:return Oe=Rt.sent(),Re=ee.category===Vo.TYPING_START,Le=t.as(Re?Yu:Xu).user,Oe._updateTypingStatus(Le,Re?ee.ts:0),this._dispatcher.dispatch(new iu({channels:[Oe],source:e.GroupChannelEventSource.EVENT_CHANNEL_TYPING_STATUS_UPDATE})),De((function(){return i(Ot,void 0,void 0,(function(){return s(this,(function(e){return this._groupChannelHandlers.forEach((function(e){e.onTypingStatusUpdated(Oe)})),[2]}))}))})),[3,73];case 51:return[4,this.getChannel(ee.channelUrl,!0)];case 52:ke=Rt.sent(),xe=ee.category===Vo.USER_CHANNEL_MUTE,(Fe=t.as(xe?Xa:$a).user).userId===this._sdkState.userId&&(ke.myMutedState=xe?e.MutedState.MUTED:e.MutedState.UNMUTED);try{for(qe=a(ke.members),Ge=qe.next();!Ge.done;Ge=qe.next())if((He=Ge.value).userId===Fe.userId){He.isMuted=xe;break}}catch(e){At={error:e}}finally{try{Ge&&!Ge.done&&(Ut=qe.return)&&Ut.call(qe)}finally{if(At)throw At.error}}return this._dispatcher.dispatch(new iu({channels:[ke],source:xe?e.GroupChannelEventSource.EVENT_CHANNEL_MUTED:e.GroupChannelEventSource.EVENT_CHANNEL_UNMUTED})),De((function(){return i(Ot,void 0,void 0,(function(){return s(this,(function(e){return this._groupChannelHandlers.forEach((function(e){xe?e.onUserMuted(ke,Fe):e.onUserUnmuted(ke,Fe)})),[2]}))}))})),[3,73];case 53:return(Ve=this._leftChannels.get(ee.channelUrl))?(Qe=Ve.channel,[3,56]):[3,54];case 54:return[4,this.getChannel(ee.channelUrl,!0)];case 55:Qe=Rt.sent(),Rt.label=56;case 56:return Ke=Qe,this._markAsLeave(Ke),Be=t.as(to).user,De((function(){return i(Ot,void 0,void 0,(function(){return s(this,(function(e){return this._groupChannelHandlers.forEach((function(e){e.onUserBanned(Ke,Be)})),[2]}))}))})),[3,73];case 57:return[4,this.getChannel(ee.channelUrl,!0)];case 58:return je=Rt.sent(),ze=t.as(ro).user,De((function(){return i(Ot,void 0,void 0,(function(){return s(this,(function(e){return this._groupChannelHandlers.forEach((function(e){e.onUserUnbanned(je,ze)})),[2]}))}))})),[3,73];case 59:return[4,this.getChannel(ee.channelUrl,!0)];case 60:return We=Rt.sent(),Ye=t.as(so).freeze,We.isFrozen=Ye,this._dispatcher.dispatch(new iu({channels:[We],source:Ye?e.GroupChannelEventSource.EVENT_CHANNEL_FROZEN:e.GroupChannelEventSource.EVENT_CHANNEL_UNFROZEN})),De((function(){return i(Ot,void 0,void 0,(function(){return s(this,(function(e){return this._groupChannelHandlers.forEach((function(e){Ye?e.onChannelFrozen(We):e.onChannelUnfrozen(We)})),[2]}))}))})),[3,73];case 61:return[4,this.getChannel(ee.channelUrl,!0)];case 62:return Je=Rt.sent(),Xe=t.as(zu),Ze=Xe.allowAutoUnhide,$e=Xe.hidePreviousMessages,et=Xe.messageOffsetTimestamp,null!==Ze&&(Je.hiddenState=Ze?e.HiddenState.HIDDEN_ALLOW_AUTO_UNHIDE:e.HiddenState.HIDDEN_PREVENT_AUTO_UNHIDE),null!==$e&&$e&&Je._updateUnreadCount(0,0),null!==et&&(Je.messageOffsetTimestamp=et),this._dispatcher.dispatch(new iu({channels:[Je],source:e.GroupChannelEventSource.EVENT_CHANNEL_HIDDEN})),De((function(){return i(Ot,void 0,void 0,(function(){return s(this,(function(e){return this._groupChannelHandlers.forEach((function(e){e.onChannelHidden(Je)})),[2]}))}))})),[3,73];case 63:return[4,this.getChannel(ee.channelUrl,!0)];case 64:return(tt=Rt.sent()).hiddenState=e.HiddenState.UNHIDDEN,this._dispatcher.dispatch(new iu({channels:[tt],source:e.GroupChannelEventSource.EVENT_CHANNEL_UNHIDDEN})),De((function(){return i(Ot,void 0,void 0,(function(){return s(this,(function(e){return this._groupChannelHandlers.forEach((function(e){e.onChannelChanged(tt)})),[2]}))}))})),[3,73];case 65:return[4,this.getChannel(ee.channelUrl,!0)];case 66:return nt=Rt.sent(),this._dispatcher.dispatch(new su({channelUrls:[ee.channelUrl],source:e.GroupChannelEventSource.EVENT_CHANNEL_DELETED})),De((function(){return i(Ot,void 0,void 0,(function(){return s(this,(function(e){return this._groupChannelHandlers.forEach((function(e){e.onChannelDeleted(nt.url,nt.channelType)})),[2]}))}))})),[3,73];case 67:return[4,this.getChannelWithoutCache(ee.channelUrl,!0)];case 68:return rt=Rt.sent(),this._dispatcher.dispatch(new iu({channels:[rt],source:e.GroupChannelEventSource.EVENT_CHANNEL_UPDATED})),De((function(){return i(Ot,void 0,void 0,(function(){return s(this,(function(e){return this._groupChannelHandlers.forEach((function(e){e.onChannelChanged(rt)})),[2]}))}))})),[3,73];case 69:return[4,this.getChannel(ee.channelUrl,!0)];case 70:return it=Rt.sent(),st=t.as(Pa),at=st.created,ot=st.updated,ut=st.deleted,at&&it._upsertCachedMetaData(at,ee.ts),ot&&it._upsertCachedMetaData(ot,ee.ts),ut&&it._removeFromCachedMetaData(ut,ee.ts),De((function(){return i(Ot,void 0,void 0,(function(){return s(this,(function(e){return this._groupChannelHandlers.forEach((function(e){at&&e.onMetaDataCreated(it,at),ot&&e.onMetaDataUpdated(it,ot),ut&&e.onMetaDataDeleted(it,ut)})),[2]}))}))})),[3,73];case 71:return[4,this.getChannel(ee.channelUrl,!0)];case 72:return ct=Rt.sent(),lt=t.as(za),ht=lt.created,dt=lt.updated,pt=lt.deleted,De((function(){return i(Ot,void 0,void 0,(function(){return s(this,(function(e){return this._groupChannelHandlers.forEach((function(e){ht&&e.onMetaCounterCreated(ct,ht),dt&&e.onMetaCounterUpdated(ct,dt),pt&&e.onMetaCounterDeleted(ct,pt)})),[2]}))}))})),[3,73];case 73:return[3,75];case 74:switch((ft=t.as(ni).event).category){case Pr.USER_BLOCK:_t=ei.getDataAsUserBlockEvent(this._iid,ft),mt=_t.blocker,gt=_t.blockee,this._groupChannelCache.block(mt.userId,gt.userId);break;case Pr.USER_UNBLOCK:vt=ei.getDataAsUserBlockEvent(this._iid,ft),mt=vt.blocker,gt=vt.blockee,this._groupChannelCache.unblock(mt.userId,gt.userId)}return[3,75];case 75:return[3,77];case 76:if(yt=Rt.sent(),p(yt))throw yt;return[3,77];case 77:return[2]}}))}))},t.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)},t.prototype.addHandler=function(e,t){this._groupChannelHandlers.set(e,t)},t.prototype.removeHandler=function(e){this._groupChannelHandlers.delete(e)},t.prototype.clearHandler=function(){this._groupChannelHandlers.clear()},t.prototype.subscribeGroupChannelEvent=function(e,t){this._groupChannelBroadcast.subscribe(e,t)},t.prototype.unsubscribeGroupChannelEvent=function(e){this._groupChannelBroadcast.unsubscribe(e)},t.prototype.subscribeMessageEvent=function(e,t){this._messageBroadcast.subscribe(e,t)},t.prototype.unsubscribeMessageEvent=function(e){this._messageBroadcast.unsubscribe(e)},t.prototype._updateJoinedMemberCount=function(t){t.joinedMemberCount=t.members.filter((function(t){return t.state===e.MemberState.JOINED})).length},t.prototype.getChannel=function(e,t){return void 0===t&&(t=!1),i(this,void 0,void 0,(function(){var n;return s(this,(function(r){switch(r.label){case 0:ct(g("string",e)).throw(f.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()]}}))}))},t.prototype.getChannelWithoutCache=function(t,n){return void 0===n&&(n=!1),i(this,void 0,void 0,(function(){var r,i,a,o,u;return s(this,(function(s){switch(s.label){case 0:return ct(g("string",t)).throw(f.invalidParameters),r=new lu({channelUrl:t,isInternalCall:n}),[4,this._requestQueue.send(r)];case 1:switch(i=s.sent(),a=i.as(hu).channel,o=a.unreadMessageCount,u=a.unreadMentionCount,a.myCountPreference){case e.CountPreference.UNREAD_MESSAGE_COUNT_ONLY:u=0;break;case e.CountPreference.UNREAD_MENTION_COUNT_ONLY:o=0;break;case e.CountPreference.OFF:o=0,u=0}return a._updateUnreadCount(o,u),[4,this._groupChannelCache.upsert([a])];case 2:return s.sent(),[2,a]}}))}))},t.prototype.getMyGroupChannels=function(t,n,a,o){return void 0===o&&(o=e.GroupChannelEventSource.REQUEST_CHANNEL),i(this,void 0,void 0,(function(){var e,i,u,c,l;return s(this,(function(s){switch(s.label){case 0:return e=new du(r(r({},n),{userId:this._sdkState.userId,token:t,limit:a})),[4,this._requestQueue.send(e)];case 1:return i=s.sent(),u=i.as(pu),c=u.channels,l=u.token,this._dispatcher.dispatch(new iu({channels:c,source:o})),[2,{channels:c,token:l}]}}))}))},t.prototype.getMessageFromCache=function(e){return i(this,void 0,void 0,(function(){return s(this,(function(t){switch(t.label){case 0:return[4,this._messageCache.get(e)];case 1:return[2,t.sent()]}}))}))},t.prototype.getMessagesFromCache=function(e,t,n,r,a){return void 0===a&&(a=100),i(this,void 0,void 0,(function(){return s(this,(function(i){switch(i.label){case 0:return[4,this._messageCache.fetch({channelUrl:e,token:t,limit:a,filter:r,backward:"next"===n})];case 1:return[2,i.sent()]}}))}))},t.prototype.getAllFailedMessagesFromCache=function(t,n){return i(this,void 0,void 0,(function(){return s(this,(function(r){switch(r.label){case 0:return[4,this._unsentMessageCache.fetch({channelUrl:t,filter:n,sendingStatus:e.SendingStatus.FAILED})];case 1:return[2,r.sent()]}}))}))},t.prototype.removeFailedMessageFromCache=function(e){return i(this,void 0,void 0,(function(){return s(this,(function(t){switch(t.label){case 0:return[4,this._unsentMessageCache.remove([e])];case 1:return t.sent(),[2]}}))}))},t.prototype.getCachedMessageCountBetween=function(e,t,n,r){return i(this,void 0,void 0,(function(){return s(this,(function(i){switch(i.label){case 0:return[4,this._messageCache.countBetween(e,t,new uc({top:n,bottom:r}))];case 1:return[2,i.sent()]}}))}))},t.prototype.getMyGroupChannelChangeLogs=function(t,n,a){return void 0===a&&(a=e.GroupChannelEventSource.REQUEST_CHANNEL_CHANGELOGS),i(this,void 0,void 0,(function(){var e,i,o,u,c,l;return s(this,(function(s){switch(s.label){case 0:return e=r(r({},Yo),n),ct((g("string",t)||g("number",t))&&Jo(e)).throw(f.invalidParameters),i=new uu(D({userId:this._sdkState.userId,ts:"number"==typeof t?t:null,token:"string"==typeof t?t:null,filter:e})),[4,this._requestQueue.send(i)];case 1:return o=s.sent(),u=o.as(cu),c=u.updatedChannels,l=u.deletedChannelUrls,c.length>0&&this._dispatcher.dispatch(new iu({channels:c,source:a})),l.length>0&&this._dispatcher.dispatch(new su({channelUrls:l,source:a})),[2,u]}}))}))},t.prototype.getGroupChannelCount=function(e){return i(this,void 0,void 0,(function(){var t,n,i;return s(this,(function(s){switch(s.label){case 0:return t=r(r({},Xo),e),ct(Zo(t)).throw(f.invalidParameters),n=new fu({userId:this._sdkState.userId,filter:t}),[4,this._requestQueue.send(n)];case 1:return i=s.sent(),[2,i.as(_u).groupChannelCount]}}))}))},t.prototype.getUnreadItemCount=function(t){return i(this,void 0,void 0,(function(){var n,i,a,o,u;return s(this,(function(s){switch(s.label){case 0:return n=r(r({},eu),t),ct(function(t){return b(e.UnreadItemKey,t.keys)}(n)).throw(f.invalidParameters),i=wt.of(this._iid),a=i.sdkState,o=i.requestQueue,u=new vu({userId:a.userId,filter:n}),[4,o.send(u)];case 1:return[2,s.sent().as(mu)]}}))}))},t.prototype.getTotalUnreadChannelCount=function(){return i(this,void 0,void 0,(function(){var e,t,n,r,i;return s(this,(function(s){switch(s.label){case 0:return e=wt.of(this._iid),t=e.sdkState,n=e.requestQueue,r=new gu({userId:t.userId}),[4,n.send(r)];case 1:return i=s.sent(),[2,i.as(yu).unreadCount]}}))}))},t.prototype.getTotalUnreadMessageCount=function(t){return i(this,void 0,void 0,(function(){var n,i,a,o,u,c;return s(this,(function(s){switch(s.label){case 0:return n=r(r({},tu),t),ct(function(t){return b("string",t.channelCustomTypesFilter,!0)&&y(e.SuperChannelFilter,t.superChannelFilter)}(n)).throw(f.invalidParameters),i=wt.of(this._iid),a=i.sdkState,o=i.requestQueue,u=new Eu({userId:a.userId,filter:n}),[4,o.send(u)];case 1:return c=s.sent(),[2,c.as(bu).unreadCount]}}))}))},t.prototype.getTotalScheduledMessageCount=function(t){return void 0===t&&(t={}),i(this,void 0,void 0,(function(){var n,i,a,o;return s(this,(function(s){switch(s.label){case 0:return n=r(r({},nu),t),ct(function(t){return g("string",t.channelUrl,!0)&&b(e.ScheduledStatus,t.scheduledStatus,!0)&&y(e.MessageTypeFilter,t.messageTypeFilter)}(n)).throw(f.invalidParameters),i=wt.of(this._iid).requestQueue,a=new Cu(n),[4,i.send(a)];case 1:return o=s.sent(),[2,o.as(Tu).count]}}))}))},t.prototype.getSubscribedTotalUnreadMessageCount=function(){var e=wt.of(this._iid).subscribedUnreadMessageCount;return e.all>=0?e.all:0},t.prototype.getSubscribedCustomTypeTotalUnreadMessageCount=function(){var e=0,t=wt.of(this._iid).subscribedUnreadMessageCount;for(var n in t.customTypes)e+=t.customTypes[n];return e},t.prototype.getSubscribedCustomTypeUnreadMessageCount=function(e){var t;return null!==(t=wt.of(this._iid).subscribedUnreadMessageCount.customTypes[e])&&void 0!==t?t:0},t.prototype.createChannel=function(e){return i(this,void 0,void 0,(function(){var t,n,i,a;return s(this,(function(s){switch(s.label){case 0:return t=r(r({},zo),e),ct(Wo(t)).throw(f.invalidParameters),t.isPublic||(t.accessCode=null),n=new Su(r({userId:this._sdkState.userId},t)),[4,this._requestQueue.send(n)];case 1:return i=s.sent(),a=i.as(Nu).channel,[4,this._groupChannelCache.upsert([a])];case 2:return s.sent(),[2,a]}}))}))},t.prototype.markAsReadAll=function(){return i(this,void 0,void 0,(function(){var e,t,n,r,i,o,u,c;return s(this,(function(s){switch(s.label){case 0:return e=Date.now(),ct(e-this._markAsReadAllLastSentAt>=1e3).throw(f.markAsReadAllRateLimitExceeded),this._markAsReadAllLastSentAt=e,t=new wu({userId:this._sdkState.userId}),[4,this._requestQueue.send(t)];case 1:s.sent(),n=this._groupChannelCache.channels;try{for(r=a(n),i=r.next();!i.done;i=r.next())(o=i.value)._updateUnreadMemberState(this._sdkState.userId,e),o._updateUnreadCount(0,0)}catch(e){u={error:e}}finally{try{i&&!i.done&&(c=r.return)&&c.call(r)}finally{if(u)throw u.error}}return n.length>0?[4,this._groupChannelCache.upsert(n)]:[3,3];case 2:s.sent(),s.label=3;case 3:return[2]}}))}))},t.prototype.markAsReadWithChannelUrls=function(e){return i(this,void 0,void 0,(function(){var t,n,r,i,o,u,c,l,h;return s(this,(function(s){switch(s.label){case 0:return t=Date.now(),ct(b("string",e)&&t-this._markAsReadAllLastSentAt>=1e3).throw(f.markAsReadAllRateLimitExceeded),this._markAsReadAllLastSentAt=t,n=new wu({userId:this._sdkState.userId,channelUrls:e}),[4,this._requestQueue.send(n)];case 1:s.sent(),r=this._groupChannelCache.channels,i=[];try{for(o=a(r),u=o.next();!u.done;u=o.next())c=u.value,e.includes(c.url)&&(c._updateUnreadMemberState(this._sdkState.userId,t),c._updateUnreadCount(0,0),i.push(c))}catch(e){l={error:e}}finally{try{u&&!u.done&&(h=o.return)&&h.call(o)}finally{if(l)throw l.error}}return i.length>0?[4,this._groupChannelCache.upsert(i)]:[3,3];case 2:s.sent(),s.label=3;case 3:return[2]}}))}))},t.prototype.markAsDelivered=function(e){return i(this,void 0,void 0,(function(){return s(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]}}))}))},t}(),hc=new Map,dc=new Map,pc=new Map,fc=function(){function e(t){var n=t.key,r=t.concurrentCallLimit,a=void 0===r?2:r,o=t.backOffDelay,u=void 0===o?0:o,c=this;this._holdersKey=e.createSemaphoreHoldersKey(n),this._resolversKey=e.createSemaphoreResolversKey(n),this._chainProcessStateKey=e.createChainProcessStateKey(n),this._numLocks=a,this._backOffDelay=u,this._localAcquiredKeys=[],this._localResolversData=[],Q()?(hc[this._holdersKey]||(hc[this._holdersKey]=[]),dc[this._resolversKey]||(dc[this._resolversKey]=[])):(window.addEventListener("storage",(function(e){return i(c,void 0,void 0,(function(){var t,n;return s(this,(function(r){if(this._localResolversData.length>0&&this.numLocksAvailable>0&&!this._isProcessChainAcquireRunning()&&this._hasHighestPriorityResolver())switch(e.key){case this._holdersKey:if(t=JSON.parse(e.oldValue),n=JSON.parse(e.newValue),!t||!n||n.length>=t.length)return[2];this._processChainResolve();break;case this._chainProcessStateKey:if(JSON.parse(e.newValue))return[2];this._processChainResolve();break;default:return[2]}return[2]}))}))})),window.addEventListener("beforeunload",(function(){var e=c._getLocalResolversData(),t=c._localResolversData.map((function(e){return e.key})),n=e.filter((function(e){return t.indexOf(e.key)<0}));window.localStorage.setItem(c._resolversKey,JSON.stringify(n)),c._localAcquiredKeys.forEach((function(e){return c.release(e)}))})))}return e.createSemaphoreHoldersKey=function(e){return"collection@semaphore_holders_for:"+e},e.createSemaphoreResolversKey=function(e){return"collection@semaphore_resolvers_for:"+e},e.createChainProcessStateKey=function(e){return"collection@semaphore_chain_process_state_for:"+e},Object.defineProperty(e.prototype,"numLocks",{get:function(){return this._numLocks},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"backOffDelay",{get:function(){return this._backOffDelay},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"numLocksAvailable",{get:function(){if(Q())return this.numLocks-hc[this._holdersKey].length;var e=this._getLocalHoldersData();return this.numLocks-e.length},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"waitCount",{get:function(){return Q()?dc[this._resolversKey].length:this._getLocalResolversData().length},enumerable:!1,configurable:!0}),e.prototype._hasHighestPriorityResolver=function(){var e=this._getLocalResolversData();return e.length>0&&this._localResolversData.map((function(e){return e.key})).indexOf(e[0].key)>=0},e.prototype._isProcessChainAcquireRunning=function(){if(Q())return pc[this._chainProcessStateKey];var e=window.localStorage[this._chainProcessStateKey];return void 0!==e&&JSON.parse(e)},e.prototype._setProcessChainAcquireRunning=function(e){Q()?pc[this._chainProcessStateKey]=e:e?window.localStorage.setItem(this._chainProcessStateKey,JSON.stringify(e)):window.localStorage.removeItem(this._chainProcessStateKey)},e.prototype._processChainResolve=function(){return i(this,void 0,void 0,(function(){var e;return s(this,(function(t){switch(t.label){case 0:return this.waitCount>0&&this.numLocksAvailable>0&&!this._isProcessChainAcquireRunning()?(this._setProcessChainAcquireRunning(!0),this._tryResolve()?[4,Re(this._backOffDelay)]:[3,2]):[3,3];case 1:t.sent(),t.label=2;case 2:this._setProcessChainAcquireRunning(!1),Q()?this._processChainResolve():(e=new StorageEvent("storage",{key:this._chainProcessStateKey,oldValue:JSON.stringify(!0),newValue:JSON.stringify(!1)}),dispatchEvent(e)),t.label=3;case 3:return[2]}}))}))},e.prototype.acquire=function(e){return void 0===e&&(e=0),i(this,void 0,void 0,(function(){var t,n=this;return s(this,(function(r){return Q()?[2,new Promise((function(t){for(var r={key:U(),resolver:function(e){return t(e)},priority:e},i=dc[n._resolversKey],s=-1,a=0;ai[a].priority){s=a;break}s>=0?dc[n._resolversKey].splice(s,0,r):dc[n._resolversKey].push(r),n._processChainResolve()}))]:(t=this._getLocalResolversData(),[2,new Promise((function(r){for(var i=U(),s={key:i,priority:e},a={key:i,resolver:function(e){return r(e)},priority:e},o=-1,u=0;ut[u].priority){o=u;break}o>=0?(t.splice(o,0,s),n._localResolversData.splice(o,0,a)):(t.push(s),n._localResolversData.push(a)),window.localStorage.setItem(n._resolversKey,JSON.stringify(t)),n._processChainResolve()}))])}))}))},e.prototype.release=function(e){if(Q()){if((t=hc[this._holdersKey].indexOf(e))>=0)return hc[this._holdersKey].splice(t,1),this._processChainResolve(),!0}else if(window.localStorage[this._holdersKey]){var t,n=JSON.parse(window.localStorage[this._holdersKey]),r=u([],o(n),!1);if((t=n.indexOf(e))>=0){n.splice(t,1),window.localStorage.setItem(this._holdersKey,JSON.stringify(n)),this._localAcquiredKeys.splice(this._localAcquiredKeys.indexOf(e),1);var i=new StorageEvent("storage",{key:this._holdersKey,oldValue:JSON.stringify(r),newValue:JSON.stringify(n)});return dispatchEvent(i),!0}}return!1},e.prototype._tryResolve=function(){if(Q()){if(hc[this._holdersKey].length=yc,n.nextToken=this._metadata.range.top,this._metadata.previousComplete=!n.hasNext,h.debug("message background prev sync progress",n),[4,this.saveMetadata()];case 4:return s.sent(),[3,8];case 5:return i=s.sent(),h.debug("message background prev sync error",i),i instanceof f&&i.isInvalidTokenError?[4,this.clearMetadata()]:[3,7];case 6:s.sent(),s.label=7;case 7:throw i;case 8:return[3,10];case 9:n.hasNext=!1,s.label=10;case 10:return[2,n]}}))}))})),this._nextSync=new _c(d,(function(t){return i(a,void 0,void 0,(function(){var n,r,i,a,o,u;return s(this,(function(s){switch(s.label){case 0:return n={hasNext:!0,nextToken:0},[4,this.loadMetadata()];case 1:s.sent(),h.debug("message background next sync from",null===(a=this._metadata)||void 0===a?void 0:a.range.bottom),s.label=2;case 2:return s.trys.push([2,5,,6]),[4,kn.of(this._iid).getMessagesByTimestamp(this._channel.url,this._channel.channelType,null!==(u=null===(o=this._metadata.range)||void 0===o?void 0:o.bottom)&&void 0!==u?u:t,{prevResultSize:0,nextResultSize:yc,replyType:e.ReplyType.ALL,includeReactions:!0,includeMetaArray:!0,includeParentMessageInfo:!0,includeThreadInfo:!0},e.MessageEventSource.SYNC_MESSAGE_BACKGROUND)];case 3:return r=s.sent(),this.extendRange(r),n.hasNext=r.length>=yc,n.nextToken=this._metadata.range.bottom,h.debug("message background next sync progress",n),[4,this.saveMetadata()];case 4:return s.sent(),[3,6];case 5:throw i=s.sent(),h.debug("message background next sync error",i),i;case 6:return[2,n]}}))}))}))}return t.of=function(e,n){if(gc[e]||(gc[e]={}),!gc[e][n.url]){var r=gc[e][n.url]=new t({_iid:e,channel:n});wt.of(e).dispatcher.on((function(e){if(e instanceof he)if(e.stateType===X.CONNECTED)r.resume();else r.pause()}))}return gc[e][n.url]},Object.defineProperty(t.prototype,"range",{get:function(){var e;return null===(e=this._metadata)||void 0===e?void 0:e.range},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"previousComplete",{get:function(){var e;return!!(null===(e=this._metadata)||void 0===e?void 0:e.previousComplete)},enumerable:!1,configurable:!0}),t.prototype.isWrappingMessages=function(e){var t;return null===(t=this.range)||void 0===t?void 0:t.includes.apply(t,u([],o(e.map((function(e){return e.createdAt}))),!1))},t.prototype.extendRange=function(e){var t;this._metadata&&(t=this._metadata.range).extends.apply(t,u([],o(e.map((function(e){return e.createdAt}))),!1))},t.prototype.loadMetadata=function(){return i(this,void 0,void 0,(function(){var e;return s(this,(function(t){switch(t.label){case 0:return this._metadata?[3,2]:[4,wt.of(this._iid).cacheContext.preference.get(this._metadataKey)];case 1:e=t.sent(),this._metadata={range:new uc(e?e.range:{top:Number.MAX_SAFE_INTEGER,bottom:Number.MAX_SAFE_INTEGER}),previousComplete:!!e&&e.previousComplete},t.label=2;case 2:return[2]}}))}))},t.prototype.saveMetadata=function(){return i(this,void 0,void 0,(function(){return s(this,(function(e){switch(e.label){case 0:return this._metadata?[4,wt.of(this._iid).cacheContext.preference.set(this._metadataKey,this._metadata)]:[3,2];case 1:e.sent(),e.label=2;case 2:return[2]}}))}))},t.prototype.clearMetadata=function(){return i(this,void 0,void 0,(function(){return s(this,(function(e){switch(e.label){case 0:return[4,wt.of(this._iid).cacheContext.preference.remove(this._metadataKey)];case 1:return e.sent(),this._metadata=null,[2]}}))}))},t.prototype.resume=function(){var e,t,n,r;wt.of(this._iid).logger.debug("message background sync resume()"),this._metadata&&this._metadata.previousComplete||this._prevSync.start(null!==(t=null===(e=this._metadata)||void 0===e?void 0:e.range.top)&&void 0!==t?t:Date.now()),this._nextSync.start(null!==(r=null===(n=this._metadata)||void 0===n?void 0:n.range.bottom)&&void 0!==r?r:Date.now())},t.prototype.pause=function(){wt.of(this._iid).logger.debug("message background sync stop()"),this._prevSync.stop(),this._nextSync.stop()},t}(),bc={},Cc=function(){function t(t){var n=t._iid,r=t.channel,a=this;this._sync=null,this._metadata=null,this._iid=n,this._channel=r;var o,u,c=wt.of(this._iid),l=c.logger,h=c.sdkState;this._metadataKey=(o=h.userId,u=r.url,"sendbird:".concat(o,"@groupchannel/").concat(u,"/message/changelogs.meta"));var d=function(e,t){return"sendbird:".concat(e,"@groupchannel/").concat(t,"/message/changelogs")}(h.userId,this._channel.url);this._sync=new _c(d,(function(){return i(a,void 0,void 0,(function(){var t,n,r,i,a,o;return s(this,(function(s){switch(s.label){case 0:return t={hasNext:!0,nextToken:0},[4,this.loadMetadata()];case 1:s.sent(),l.debug("message changelog sync from",null===(o=this._metadata)||void 0===o?void 0:o.token),s.label=2;case 2:return s.trys.push([2,5,,8]),[4,kn.of(this._iid).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 3:return n=s.sent(),r=n.hasMore,i=n.token,t.hasNext=r,t.nextToken=i,this._metadata.token=i,l.debug("message changelog sync progress",t),[4,this.saveMetadata()];case 4:return s.sent(),[3,8];case 5:return a=s.sent(),l.debug("message changelog sync error",a),a instanceof f&&a.isInvalidTokenError?[4,this.clearMetadata()]:[3,7];case 6:s.sent(),s.label=7;case 7:throw a;case 8:return[2,t]}}))}))}))}return t.of=function(e,n){if(bc[e]||(bc[e]={}),!bc[e][n.url]){var r=bc[e][n.url]=new t({_iid:e,channel:n});wt.of(e).dispatcher.on((function(e){if(e instanceof he)if(e.stateType===X.CONNECTED)r.resume();else r.pause()}))}return bc[e][n.url]},t.prototype.loadMetadata=function(){return i(this,void 0,void 0,(function(){var e,t,n,r;return s(this,(function(i){switch(i.label){case 0:return this._metadata?[3,2]:(e=wt.of(this._iid),t=e.cacheContext,n=e.firstConnectedAt,[4,t.preference.get(this._metadataKey)]);case 1:r=i.sent(),this._metadata={token:r?r.token:n/1e3},i.label=2;case 2:return[2]}}))}))},t.prototype.saveMetadata=function(){return i(this,void 0,void 0,(function(){return s(this,(function(e){switch(e.label){case 0:return this._metadata?[4,wt.of(this._iid).cacheContext.preference.set(this._metadataKey,this._metadata)]:[3,2];case 1:e.sent(),e.label=2;case 2:return[2]}}))}))},t.prototype.clearMetadata=function(){return i(this,void 0,void 0,(function(){return s(this,(function(e){switch(e.label){case 0:return[4,wt.of(this._iid).cacheContext.preference.remove(this._metadataKey)];case 1:return e.sent(),this._metadata=null,[2]}}))}))},t.prototype.resume=function(){wt.of(this._iid).logger.debug("message changelog sync resume()"),this._sync.start(0)},t.prototype.pause=function(){wt.of(this._iid).logger.debug("message changelog sync pause()"),this._sync.stop()},t}(),Tc=function(e){function t(t){var n,r,i,s,a,o,u=this;return(u=e.call(this)||this).method=d.GET,u.path="".concat(Je(t.channelType),"/").concat(t.channelUrl,"/messages_gap"),u.params=D({prev_start_ts:t.prevStart,prev_end_ts:t.prevEnd,prev_cache_count:t.prevCount,next_start_ts:t.nextStart,next_end_ts:t.nextEnd,next_cache_count:t.nextCount,huge_gap_threshold:null!==(n=t.threshold)&&void 0!==n?n:null,reverse:!0,custom_types:null!==(r=t.customTypes)&&void 0!==r?r:["*"],message_type:null!==(i=t.messageType)&&void 0!==i?i:null,include_reactions:null===(s=t.includeReactions)||void 0===s||s,with_sorted_meta_array:null===(a=t.includeMetaArray)||void 0===a||a,show_subchannel_messages_only:null!==(o=t.showSubchannelMessagesOnly)&&void 0!==o&&o,include_poll_details:!0}),u}return n(t,e),t}(x),Ic=function(e){function t(t,n){var r,i,s,a,o=this;return(o=e.call(this,t,n)||this).isHugeGap=n.is_huge_gap,o.prevMessages=(null!==(r=n.prev_messages)&&void 0!==r?r:[]).map((function(e){return sn(t,e)})),o.prevHasMore=null!==(i=n.prev_hasmore)&&void 0!==i&&i,o.nextMessages=(null!==(s=n.next_messages)&&void 0!==s?s:[]).map((function(e){return sn(t,e)})),o.nextHasmore=null!==(a=n.next_hasmore)&&void 0!==a&&a,o}return n(t,e),t}(F),Sc=function(e,t){return e.findIndex((function(e){return e.isIdentical(t)}))},Nc=function(e,t,n){if(e.length>0){var r=Sc(e,t);if(r<0){for(var i=0,s=e.length-1,a=Math.floor((i+s)/2);i0)s=a,a=Math.floor((i+s)/2);else{if(!(o<0))return{place:a,contains:e[a].isIdentical(t)};i=a+1,a=Math.floor((i+s)/2)}}return{place:wc(e[a],t,n)>0?a:a+1,contains:!1}}return{place:r,contains:!0}}return{place:e.length,contains:!1}},wc=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:return t.name.localeCompare(n.name)}},Mc=function(e,t){if(t instanceof Bt)return e.findIndex((function(e){return e instanceof Bt&&t.isIdentical(e)}));e.findIndex((function(e){return e.isIdentical(t)}))},Ac=function(e,t){return e.findIndex((function(e){return e.messageId===t}))},Uc=function(e,t){if(e.length>0){for(var n=0,r=e.length-1,i=Math.floor((n+r)/2);n0)r=i,i=Math.floor((n+r)/2);else{if(!(s<0))return i;n=i+1,i=Math.floor((n+r)/2)}}return e[i].createdAt>t.createdAt?i:i+1}return e.length},Oc={},Rc=function(){function e(e){var t=e._iid,n=e.channel,r=this;this._sync=null,this._metadata=null,this._iid=t,this._channel=n;var a,o,u=wt.of(this._iid),c=u.logger,l=u.sdkState;this._metadataKey=(a=l.userId,o=n.url,"sendbird:".concat(a,"@groupchannel/").concat(o,"/poll/changelogs.meta"));var h=function(e,t){return"sendbird:".concat(e,"@groupchannel/").concat(t,"/poll/changelogs")}(l.userId,this._channel.url);this._sync=new _c(h,(function(){return i(r,void 0,void 0,(function(){var e,t,n,r,i,a;return s(this,(function(s){switch(s.label){case 0:return e={hasNext:!0,nextToken:0},[4,this.loadMetadata()];case 1:s.sent(),c.debug("poll changelog sync from",null===(a=this._metadata)||void 0===a?void 0:a.token),s.label=2;case 2:return s.trys.push([2,5,,8]),[4,lr.of(this._iid).getPollChangeLogs(this._channel.url,this._channel.channelType,this._metadata.token)];case 3:return t=s.sent(),n=t.hasMore,r=t.token,e.hasNext=n,e.nextToken=r,this._metadata.token=r,c.debug("poll changelog sync progress",e),[4,this.saveMetadata()];case 4:return s.sent(),[3,8];case 5:return i=s.sent(),c.debug("poll changelog sync error",i),i instanceof f&&i.isInvalidTokenError?[4,this.clearMetadata()]:[3,7];case 6:s.sent(),s.label=7;case 7:throw i;case 8:return[2,e]}}))}))}))}return e.of=function(t,n){if(Oc[t]||(Oc[t]={}),!Oc[t][n.url]){var r=Oc[t][n.url]=new e({_iid:t,channel:n});wt.of(t).dispatcher.on((function(e){if(e instanceof he)if(e.stateType===X.CONNECTED)r.resume();else r.pause()}))}return Oc[t][n.url]},e.prototype.loadMetadata=function(){return i(this,void 0,void 0,(function(){var e,t,n,r;return s(this,(function(i){switch(i.label){case 0:return this._metadata?[3,2]:(e=wt.of(this._iid),t=e.cacheContext,n=e.firstConnectedAt,[4,t.preference.get(this._metadataKey)]);case 1:r=i.sent(),this._metadata={token:r?r.token:n/1e3},i.label=2;case 2:return[2]}}))}))},e.prototype.saveMetadata=function(){return i(this,void 0,void 0,(function(){return s(this,(function(e){switch(e.label){case 0:return this._metadata?[4,wt.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 i(this,void 0,void 0,(function(){return s(this,(function(e){switch(e.label){case 0:return[4,wt.of(this._iid).cacheContext.preference.remove(this._metadataKey)];case 1:return e.sent(),this._metadata=null,[2]}}))}))},e.prototype.resume=function(){wt.of(this._iid).logger.debug("poll changelog sync resume()"),this._sync.start(0)},e.prototype.pause=function(){wt.of(this._iid).logger.debug("poll changelog sync pause()"),this._sync.stop()},e}();e.MessageCollectionInitPolicy=void 0,(e.MessageCollectionInitPolicy||(e.MessageCollectionInitPolicy={})).CACHE_AND_REPLACE_BY_API="cache_and_replace_by_api";var Lc,kc,Dc,Pc=function(){function e(){}return e.prototype._invokeResponse=function(e,t,n){var r=this;De((function(){return i(r,void 0,void 0,(function(){return s(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}(),xc=function(){function t(t,n){var r=n.channel,c=n.filter,l=n.startingPoint,h=n.limit,d=this;this._channel=null,this._messages=[],this._unsentMessages=[],this._readReceiptMap=new Map,this._deliveryReceiptMap=new Map,this._iid=t,this._key="mc-".concat(U()),this.filter=null!=c?c:new Mr,this._channel=r,this._syncRange=new uc({}),this._hasPrevious=!0,this._hasNext=!0,this._startingPoint=l||Date.now()+6e5,this._limit=h||100;var p=lc.of(this._iid);p.subscribeGroupChannelEvent(this._key,{onUpdate:function(t,n){var r,o,u,c,l=Sc(t,d._channel);if(l>=0)switch(De((function(){return i(d,void 0,void 0,(function(){var e;return s(this,(function(r){return e=new vc(n),this._channel=t[l],this._handler.onChannelUpdated(e,this.channel),[2]}))}))})),n){case e.GroupChannelEventSource.EVENT_CHANNEL_UPDATED:var h=!1;for(var p in d._messages){if((y=d._messages[p]).createdAt>=d._channel.messageOffsetTimestamp){h=!0;var f=parseInt(p);if(f>0){var _=d._messages.splice(0,f);d._removeMessagesFromView(_.map((function(e){return e.messageId})),e.MessageEventSource.EVENT_MESSAGE_OFFSET_UPDATED)}break}}!h&&d._messages.length>0&&d._removeMessagesFromView(d._messages.map((function(e){return e.messageId})),e.MessageEventSource.EVENT_MESSAGE_OFFSET_UPDATED);break;case e.GroupChannelEventSource.EVENT_CHANNEL_READ:var v=[];try{for(var m=a(d._messages),g=m.next();!g.done;g=m.next()){var y=g.value;if((C=d._readReceiptMap.get(y.messageId))>0)C!==d._channel.getUnreadMemberCount(y)&&v.push(y)}}catch(e){r={error:e}}finally{try{g&&!g.done&&(o=m.return)&&o.call(m)}finally{if(r)throw r.error}}v.length>0&&d._updateMessagesToView(v,e.MessageEventSource.EVENT_MESSAGE_READ);break;case e.GroupChannelEventSource.EVENT_CHANNEL_DELIVERED:v=[];try{for(var E=a(d._messages),b=E.next();!b.done;b=E.next()){var C;y=b.value;if((C=d._deliveryReceiptMap.get(y.messageId))>0)C!==d._channel.getUndeliveredMemberCount(y)&&v.push(y)}}catch(e){u={error:e}}finally{try{b&&!b.done&&(c=E.return)&&c.call(E)}finally{if(u)throw u.error}}v.length>0&&d._updateMessagesToView(v,e.MessageEventSource.EVENT_MESSAGE_READ)}},onRemove:function(e,t){e.indexOf(d.channel.url)>=0&&De((function(){return i(d,void 0,void 0,(function(){var e;return s(this,(function(n){return e=new vc(t),this._handler.onChannelDeleted(e,this.channel.url),[2]}))}))}))}}),p.subscribeMessageEvent(this._key,{onUpdate:function(t,n){var r,i,s=[],o=[];try{for(var u=a(t),c=u.next();!c.done;c=u.next()){var l=c.value;l.channelUrl===d._channel.url&&(d.filter.match(l)?s.push(l):o.push(l.messageId))}}catch(e){r={error:e}}finally{try{c&&!c.done&&(i=u.return)&&i.call(u)}finally{if(r)throw r.error}}if(gn(n)){if(s.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:d._updateMessagesToView(s,n);break;case e.MessageEventSource.EVENT_MESSAGE_SENT_PENDING:case e.MessageEventSource.EVENT_MESSAGE_RECEIVED:case e.MessageEventSource.SYNC_MESSAGE_FILL:d._addMessagesToView(s,n)}o.length>0&&d._removeMessagesFromView(o,n)}},onRemove:function(e,t){d._removeMessagesFromView(e,t)},onRemoveUnsent:function(e,t){d._removeUnsentMessageFromView(e,t)},onPollChangeLogUpdate:function(e,t){d._updatePollsToView(e,t)},onPollUpdate:function(e,t){d._applyPollUpdateEventToView(e,t)},onPollVote:function(e,t){d._applyPollVoteEventToView(e,t)}});var f=wt.of(this._iid).cacheContext;!this._channel.isSuper&&f.localCacheEnabled&&Ec.of(this._iid,this._channel).resume(),Cc.of(this._iid,this._channel).resume(),Rc.of(this._iid,this._channel).resume(),this._prevFill=new _c(this._key,(function(t){return i(d,void 0,void 0,(function(){var n,r;return s(this,(function(i){switch(i.label){case 0:return[4,this._getRemoteMessages(t,{prevLimit:this._limit,source:e.MessageEventSource.SYNC_MESSAGE_FILL})];case 1:return(n=i.sent()).length>0?(r=Math.min.apply(Math,u([],o(n.map((function(e){return e.createdAt}))),!1)),this._syncRange.extends(r),[2,{hasNext:n.length>=this._limit&&this.viewTop0?(r=Math.max.apply(Math,u([],o(n.map((function(e){return e.createdAt}))),!1)),this._syncRange.extends(r),[2,{hasNext:!(n.length>=this._limit&&this._hasNext)||this.viewBottom>r,nextToken:this._syncRange.bottom}]):[2,{hasNext:!1,nextToken:0}]}}))}))}));var _=wt.of(this._iid),v=_.dispatcher,m=_.logger;v.on((function(e){if(e instanceof he)if(e.stateType===X.CONNECTED)m.debug("check huge gap"),d._checkHugeGap();else d._prevFill.stop(),d._nextFill.stop()}))}return Object.defineProperty(t.prototype,"channel",{get:function(){return this._channel},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"succeededMessages",{get:function(){return u([],o(this._messages),!1)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"failedMessages",{get:function(){return this._unsentMessages.filter((function(t){return t.sendingStatus===e.SendingStatus.FAILED}))},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"pendingMessages",{get:function(){return this._unsentMessages.filter((function(t){return t.sendingStatus===e.SendingStatus.PENDING}))},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"hasPrevious",{get:function(){return this._hasPrevious},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"hasNext",{get:function(){return this._hasNext},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"viewTop",{get:function(){return Math.min.apply(Math,u(u([],o(this._messages.map((function(e){return e.createdAt}))),!1),[Number.MAX_SAFE_INTEGER],!1))},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"viewBottom",{get:function(){return Math.max.apply(Math,u(u([],o(this._messages.map((function(e){return e.createdAt}))),!1),[0],!1))},enumerable:!1,configurable:!0}),t.prototype.setMessageCollectionHandler=function(e){this._handler=e},t.prototype._filterUnderOffsetMessage=function(e){var t=this;return e.filter((function(e){return e.createdAt>=t._channel.messageOffsetTimestamp}))},t.prototype._addMessagesToView=function(t,n){var r,c,l=this,h=this._filterUnderOffsetMessage(t),d=[],p=[];try{for(var f=a(h),_=f.next();!_.done;_=f.next()){var v=_.value;if(n===e.MessageEventSource.SYNC_MESSAGE_FILL){if(v.messageId>0){if((E=Mc(this._messages,v))<0){Mc(this._unsentMessages,v)<0&&d.push(v);var m=Uc(this._messages,v);this._messages.splice(m,0,v)}this._readReceiptMap.set(v.messageId,this._channel.getUnreadMemberCount(v)),this._deliveryReceiptMap.set(v.messageId,this._channel.getUndeliveredMemberCount(v))}else if(v instanceof Bt){(E=Mc(this._unsentMessages,v))<0&&Mc(this._messages,v)<0&&(this._unsentMessages.push(v),d.push(v))}}else if(v.messageId>0){if((E=Mc(this._messages,v))<0){var g=Mc(this._unsentMessages,v);g<0?d.push(v):(this._unsentMessages.splice(g,1),p.push(v));m=Uc(this._messages,v);this._messages.splice(m,0,v)}else p.push(v),this._messages[E]=v;if(this._readReceiptMap.set(v.messageId,this._channel.getUnreadMemberCount(v)),this._deliveryReceiptMap.set(v.messageId,this._channel.getUndeliveredMemberCount(v)),v.updatedAt>0){var y=this._updateChildMessagesInView(v);p.push.apply(p,u([],o(y),!1))}}else if(v instanceof Bt){var E;(E=Mc(this._unsentMessages,v))<0?Mc(this._messages,v)<0&&(this._unsentMessages.push(v),d.push(v)):(p.push(v),this._unsentMessages[E]=v)}}}catch(e){r={error:e}}finally{try{_&&!_.done&&(c=f.return)&&c.call(f)}finally{if(r)throw r.error}}gn(n)&&De((function(){return i(l,void 0,void 0,(function(){var e;return s(this,(function(t){return e=new mc(n),d.length>0&&this._handler.onMessagesAdded(e,this.channel,d),p.length>0&&this._handler.onMessagesUpdated(e,this.channel,p),[2]}))}))}))},t.prototype._updateChildMessagesInView=function(e){var t=[];return this._messages.forEach((function(n){n.applyParentMessage(e)&&t.push(n)})),t},t.prototype._updatePollsToView=function(e,t){var n,r,o=this,u=[];try{for(var c=a(e),l=c.next();!l.done;l=c.next()){var h=l.value,d=Ac(this._messages,h.messageId);if(d>=0){var p=this._messages[d];p&&p.applyPoll(h),u.push(p)}}}catch(e){n={error:e}}finally{try{l&&!l.done&&(r=c.return)&&r.call(c)}finally{if(n)throw n.error}}return u.length>0&&gn(t)&&De((function(){return i(o,void 0,void 0,(function(){var e;return s(this,(function(n){return e=new mc(t),u.length>0&&this._handler.onMessagesUpdated(e,this.channel,u),[2]}))}))})),u},t.prototype._applyPollUpdateEventToView=function(e,t){var n=this,r=Ac(this._messages,e.messageId);if(r>=0){var a=this._messages[r];a&&a.isUserMessage()&&a.poll&&a.poll.applyPollUpdateEvent(e)&&gn(t)&&De((function(){return i(n,void 0,void 0,(function(){var e;return s(this,(function(n){return e=new mc(t),this._handler.onMessagesUpdated(e,this.channel,[a]),[2]}))}))}))}},t.prototype._applyPollVoteEventToView=function(e,t){var n=this,r=Ac(this._messages,e.messageId);if(r>=0){var a=this._messages[r];a&&a.isUserMessage()&&a.poll&&a.poll.applyPollVoteEvent(e)&&gn(t)&&De((function(){return i(n,void 0,void 0,(function(){var e;return s(this,(function(n){return e=new mc(t),this._handler.onMessagesUpdated(e,this.channel,[a]),[2]}))}))}))}},t.prototype._updateMessagesToView=function(e,t){var n,r,o=this,u=[];try{for(var c=a(e),l=c.next();!l.done;l=c.next()){var h,d=l.value;if(d.messageId>0)if((h=Mc(this._messages,d))>=0)u.push(d),this._messages[h]=d;else{var p=Mc(this._unsentMessages,d);if(p>=0){u.push(d),this._unsentMessages.splice(p,1);var f=Uc(this._messages,d);this._messages.splice(f,0,d)}}else if(d instanceof Bt)(h=Mc(this._unsentMessages,d))>=0&&(u.push(d),this._unsentMessages[h]=d)}}catch(e){n={error:e}}finally{try{l&&!l.done&&(r=c.return)&&r.call(c)}finally{if(n)throw n.error}}return gn(t)&&De((function(){return i(o,void 0,void 0,(function(){var e;return s(this,(function(n){return e=new mc(t),u.length>0&&this._handler.onMessagesUpdated(e,this.channel,u),[2]}))}))})),u},t.prototype._removeMessagesFromView=function(e,t){var n,r,o=this,u=[],c=function(e){var t=l._messages.findIndex((function(t){return t.messageId===e}));t>=0&&(u.push(l._messages[t].messageId),l._messages.splice(t,1))},l=this;try{for(var h=a(e),d=h.next();!d.done;d=h.next()){c(d.value)}}catch(e){n={error:e}}finally{try{d&&!d.done&&(r=h.return)&&r.call(h)}finally{if(n)throw n.error}}return gn(t)&&u.length>0&&De((function(){return i(o,void 0,void 0,(function(){var e;return s(this,(function(n){return e=new mc(t),u.length>0&&this._handler.onMessagesDeleted(e,this.channel,u),[2]}))}))})),u},t.prototype._removeUnsentMessageFromView=function(e,t){var n=this._unsentMessages.findIndex((function(t){return t.reqId===e}));n>=0&&this._unsentMessages.splice(n,1)},t.prototype._getLocalMessages=function(e,t){var n=t.prevLimit,r=void 0===n?0:n,a=t.nextLimit,c=void 0===a?0:a;return i(this,void 0,void 0,(function(){var t,n,i,a,l,h,d;return s(this,(function(s){switch(s.label){case 0:return t=lc.of(this._iid),r>0?[4,t.getMessagesFromCache(this._channel.url,e,"prev",this.filter,this._limit)]:[3,2];case 1:return i=s.sent(),[3,3];case 2:i=[],s.label=3;case 3:return n=i,c>0?[4,t.getMessagesFromCache(this._channel.url,e,"next",this.filter,this._limit)]:[3,5];case 4:return l=s.sent(),[3,6];case 5:l=[],s.label=6;case 6:if(a=l,n.length>0&&a.length)for(d in h=n.map((function(e){return e.messageId})),a)if(h.includes(a[d].messageId)){a.splice(parseInt(d),1);break}return[2,u(u([],o(n),!1),o(a),!1).sort((function(e,t){return t.createdAt-e.createdAt}))]}}))}))},t.prototype._getRemoteMessages=function(t,n){var a=n.prevLimit,o=void 0===a?0:a,u=n.nextLimit,c=void 0===u?0:u,l=n.source,h=void 0===l?e.MessageEventSource.REQUEST_MESSAGE:l,d=n.reverse,p=void 0!==d&&d;return i(this,void 0,void 0,(function(){var e,n;return s(this,(function(i){switch(i.label){case 0:return e=kn.of(this._iid),o>0||c>0?[4,e.getMessagesByTimestamp(this._channel.url,this._channel.channelType,t,r(r({},this.filter),{reverse:p,prevResultSize:o,nextResultSize:c,includeMetaArray:!0,includeReactions:!0,includeThreadInfo:!0}),h)]:[3,2];case 1:return n=i.sent(),[3,3];case 2:n=[],i.label=3;case 3:return[2,n]}}))}))},t.prototype._checkHugeGap=function(){return i(this,void 0,void 0,(function(){var t,n,a,c,l,h,d,p,f,_,v=this;return s(this,(function(m){switch(m.label){case 0:return this._messages.length>0?(t=this.viewTop,n=this._syncRange.top,a=this._syncRange.bottom,c=this.hasNext?this.viewBottom:Number.MAX_SAFE_INTEGER,[4,(l=lc.of(this._iid)).getCachedMessageCountBetween(this._channel.url,this.filter,t,n)]):[3,4];case 1:return h=m.sent(),[4,l.getCachedMessageCountBetween(this._channel.url,this.filter,a,c)];case 2:return d=m.sent(),[4,ke((function(){return i(v,void 0,void 0,(function(){var l,p,f,_,v,m,g,y,E,b,C,T,I,S,N,w,M,A=this;return s(this,(function(U){switch(U.label){case 0:return l=wt.of(this._iid),p=l.dispatcher,f=l.requestQueue,_=new Tc(r({channelUrl:this._channel.url,channelType:this._channel.channelType,prevStart:t,prevEnd:n,prevCount:h,nextStart:a,nextEnd:c,nextCount:d},this.filter)),[4,f.send(_)];case 1:return v=U.sent(),m=v.as(Ic),g=m.isHugeGap,y=m.prevMessages,E=void 0===y?[]:y,b=m.prevHasMore,C=m.nextMessages,T=void 0===C?[]:C,I=m.nextHasmore,g?De((function(){return i(A,void 0,void 0,(function(){return s(this,(function(e){return this._handler.onHugeGapDetected(),[2]}))}))})):(this._hasPrevious=b,this._hasNext=I,S=this.viewTop,N=this.viewBottom,w=Math.min.apply(Math,u([Number.MAX_SAFE_INTEGER],o(E.map((function(e){return e.createdAt}))),!1)),M=Math.max.apply(Math,u([0],o(T.map((function(e){return e.createdAt}))),!1)),p.dispatch(new yn({messages:E,source:e.MessageEventSource.SYNC_MESSAGE_FILL})),p.dispatch(new yn({messages:T,source:e.MessageEventSource.SYNC_MESSAGE_FILL})),this._syncRange.extends(w,M),SM&&this._nextFill.start(M)),[2]}}))}))}),1)];case 3:return m.sent(),[3,6];case 4:return p=Math.floor(this._limit/2),[4,this._getRemoteMessages(Date.now(),{prevLimit:p,nextLimit:p,source:e.MessageEventSource.SYNC_MESSAGE_FILL})];case 5:(f=m.sent()).length>0&&((_=this._syncRange).extends.apply(_,u([],o(f.map((function(e){return e.createdAt}))),!1)),f.length0&&((s=n._syncRange).extends.apply(s,u([],o(a.map((function(e){return e.createdAt}))),!1)),n._addMessagesToView(a,e.MessageEventSource.REQUEST_MESSAGE)),r._invokeResponse("remote",null,a)})).catch((function(e){if(p(e))throw e;r._invokeResponse("remote",e,null)}))}));return r},t.prototype.loadPrevious=function(){return i(this,void 0,void 0,(function(){var t,n,r,a,c=this;return s(this,(function(l){switch(l.label){case 0:return this._hasPrevious?(t=this.viewTop,n=[],[4,Pe((function(){return i(c,void 0,void 0,(function(){var e;return s(this,(function(r){switch(r.label){case 0:return e=this._filterUnderOffsetMessage,[4,this._getLocalMessages(t,{prevLimit:this._limit})];case 1:return n=e.apply(this,[r.sent()]),[2]}}))}))}))]):[3,5];case 1:return l.sent(),r=Ec.of(this._iid,this._channel),0!==n.length&&r.isWrappingMessages(n)?[3,3]:[4,Pe((function(){return i(c,void 0,void 0,(function(){var e,i;return s(this,(function(s){switch(s.label){case 0:return e=this._filterUnderOffsetMessage,[4,this._getRemoteMessages(t,{prevLimit:this._limit})];case 1:return n=e.apply(this,[s.sent()]),this._hasPrevious=n.length>=this._limit,n.length>0&&((i=this._syncRange).extends.apply(i,u([],o(n.map((function(e){return e.createdAt}))),!1)),r.range.overlap(this._syncRange)&&r.range.extends(this._syncRange.top)),[2]}}))}))}))];case 2:return l.sent(),this._addMessagesToView(n,e.MessageEventSource.REQUEST_MESSAGE),[3,4];case 3:this._hasPrevious=n.length>=this._limit,n.length>0&&((a=this._syncRange).extends.apply(a,u([],o(n.map((function(e){return e.createdAt}))),!1)),this._addMessagesToView(n,e.MessageEventSource.REQUEST_MESSAGE)),l.label=4;case 4:return[2,n];case 5:return[2,[]]}}))}))},t.prototype.loadNext=function(){return i(this,void 0,void 0,(function(){var t,n,r,a,c=this;return s(this,(function(l){switch(l.label){case 0:return t=this.viewBottom,n=[],[4,Pe((function(){return i(c,void 0,void 0,(function(){var e;return s(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]}}))}))}))];case 1:return l.sent(),r=Ec.of(this._iid,this._channel),0!==n.length&&r.isWrappingMessages(n)?[3,3]:[4,Pe((function(){return i(c,void 0,void 0,(function(){var e,i;return s(this,(function(s){switch(s.label){case 0:return e=this._filterUnderOffsetMessage,[4,this._getRemoteMessages(t,{nextLimit:this._limit})];case 1:return n=e.apply(this,[s.sent()]),this._hasNext=n.length>=this._limit,n.length>0&&((i=this._syncRange).extends.apply(i,u([],o(n.map((function(e){return e.createdAt}))),!1)),r.range.overlap(this._syncRange)&&r.range.extends(this._syncRange.bottom)),[2]}}))}))}))];case 2:return l.sent(),this._addMessagesToView(n,e.MessageEventSource.REQUEST_MESSAGE),[3,4];case 3:this._hasNext=n.length>=this._limit,n.length>0&&((a=this._syncRange).extends.apply(a,u([],o(n.map((function(e){return e.createdAt}))),!1)),this._addMessagesToView(n,e.MessageEventSource.REQUEST_MESSAGE)),l.label=4;case 4:return[2,n]}}))}))},t.prototype.removeFailedMessage=function(e){return i(this,void 0,void 0,(function(){var t;return s(this,(function(n){switch(n.label){case 0:return[4,lc.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]}}))}))},t.prototype.dispose=function(){wt.of(this._iid).cacheContext.localCacheEnabled&&(this._prevFill.stop(),this._nextFill.stop(),Ec.of(this._iid,this._channel).pause()),Cc.of(this._iid,this._channel).pause(),Rc.of(this._iid,this._channel).pause();var e=lc.of(this._iid);e.unsubscribeGroupChannelEvent(this._key),e.unsubscribeMessageEvent(this._key)},t}(),Fc={coverUrl:null,coverImage:null,isDistinct:null,isPublic:null,isDiscoverable:null,accessCode:null,name:null,data:null,customType:null,operatorUserIds:null,messageSurvivalSeconds:null},qc={hidePreviousMessages:!1,allowAutoUnhide:!0},Gc=function(e){function t(t){var n=this,r=t.channelUrl,i=t.token,s=t.limit,a=t.order,o=t.mutedMemberFilter,u=t.memberStateFilter,c=t.nicknameStartsWithFilter,l=t.operatorFilter;return(n=e.call(this)||this).method=d.GET,n.path="".concat(ve,"/").concat(encodeURIComponent(r),"/members"),n.params={token:i,limit:s,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 n(t,e),t}(x),Hc=function(e){function t(t,n){var r=e.call(this,t,n)||this;r.token=null,r.members=[];var i=n.next,s=n.members;return r.token=i,s&&s.length>0&&(r.members=s.map((function(e){return new Go(t,e)}))),r}return n(t,e),t}(F);e.MutedMemberFilter=void 0,(Lc=e.MutedMemberFilter||(e.MutedMemberFilter={})).ALL="all",Lc.MUTED="muted",Lc.UNMUTED="unmuted",e.MemberListOrder=void 0,(kc=e.MemberListOrder||(e.MemberListOrder={})).MEMBER_NICKNAME_ALPHABETICAL="member_nickname_alphabetical",kc.OPERATOR_THEN_MEMBER_ALPHABETICAL="operator_then_member_alphabetical",e.MemberStateFilter=void 0,(Dc=e.MemberStateFilter||(e.MemberStateFilter={})).ALL="all",Dc.JOINED="joined_only",Dc.INVITED="invited_only",Dc.INVITED_BY_FRIEND="invited_by_friend",Dc.INVITED_BY_NON_FRIEND="invited_by_non_friend";var Vc=function(t){function a(n,r,i){var s,a,o,u,c=this;return(c=t.call(this,n,r,e.ChannelType.GROUP,i)||this).mutedMemberFilter=e.MutedMemberFilter.ALL,c.memberStateFilter=e.MemberStateFilter.ALL,c.nicknameStartsWithFilter=null,c.operatorFilter=e.OperatorFilter.ALL,c.order=e.MemberListOrder.MEMBER_NICKNAME_ALPHABETICAL,c.mutedMemberFilter=null!==(s=i.mutedMemberFilter)&&void 0!==s?s:e.MutedMemberFilter.ALL,c.memberStateFilter=null!==(a=i.memberStateFilter)&&void 0!==a?a:e.MemberStateFilter.ALL,c.nicknameStartsWithFilter=null!==(o=i.nicknameStartsWithFilter)&&void 0!==o?o:null,c.order=null!==(u=i.order)&&void 0!==u?u:e.MemberListOrder.MEMBER_NICKNAME_ALPHABETICAL,c}return n(a,t),a.prototype._validate=function(){return t.prototype._validate.call(this)&&y(e.MutedMemberFilter,this.mutedMemberFilter)&&y(e.MemberStateFilter,this.memberStateFilter)&&(g("string",this.nicknameStartsWithFilter)||null===this.nicknameStartsWithFilter)&&y(e.OperatorFilter,this.operatorFilter)&&y(e.MemberListOrder,this.order)},a.prototype.next=function(){return i(this,void 0,void 0,(function(){var e,t,n,i,a,o;return s(this,(function(s){switch(s.label){case 0:return this._validate()?this._isLoading?[3,3]:this._hasNext?(this._isLoading=!0,e=wt.of(this._iid).requestQueue,t=new Gc(r(r({},this),{token:this._token})),[4,e.send(t)]):[3,2]:[3,5];case 1:return n=s.sent(),i=n.as(Hc),a=i.members,o=i.token,this._token=o,this._hasNext=!!o,this._isLoading=!1,[2,a];case 2:return[2,[]];case 3:throw f.queryInProgress;case 4:return[3,6];case 5:throw f.invalidParameters;case 6:return[2]}}))}))},a}(Bn),Kc=function(e){function t(t){var n=this,r=t.channelUrl,i=t.userId,s=t.accessCode;return(n=e.call(this)||this).method=d.PUT,n.path="".concat(ve,"/").concat(encodeURIComponent(r),"/accept"),n.params={user_id:i,access_code:s},n}return n(t,e),t}(x),Qc=function(t){function r(n,r){var i=t.call(this,n,r)||this;return i.channel=new Sl(n,r),i.channel.myMemberState=e.MemberState.JOINED,i}return n(r,t),r}(F),Bc=function(e){function t(t){var n=this,r=t.channelUrl,i=t.isDistinct,s=t.isPublic,a=t.isDiscoverable,o=t.coverUrl,u=t.coverImage,c=t.accessCode,l=t.name,h=t.data,p=t.customType,f=t.operatorUserIds,_=t.messageSurvivalSeconds;return(n=e.call(this)||this).method=d.PUT,n.path="".concat(ve,"/").concat(encodeURIComponent(r)),n.params=D({is_distinct:i,is_public:s,is_discoverable:a,name:l,data:h,custom_type:p,cover_url:o,cover_file:u,access_code:c,operator_ids:f,message_survival_seconds:_}),n}return n(t,e),t}(x),jc=function(e){function t(t,n){var r=e.call(this,t,n)||this;return r.channel=new Sl(t,n),r}return n(t,e),t}(F),zc=function(e){function t(t){var n=this,r=t.channelUrl;return(n=e.call(this)||this).method=d.DELETE,n.path="".concat(ve,"/").concat(encodeURIComponent(r)),n}return n(t,e),t}(x);!function(e){function t(t,n){return e.call(this,t,n)||this}n(t,e)}(F);var Wc=function(e){function t(t){var n=this,r=t.channelUrl;return(n=e.call(this)||this).method=d.DELETE,n.path="".concat(ve,"/").concat(encodeURIComponent(r),"/hide"),n}return n(t,e),t}(x);!function(e){function t(){return null!==e&&e.apply(this,arguments)||this}n(t,e)}(F);var Yc=function(e){function t(t){var n=t.userId,r=t.channelUrl,i=t.countPreference,s=e.call(this)||this;return s.method=d.PUT,s.path="".concat(fe,"/").concat(encodeURIComponent(n),"/count_preference/").concat(encodeURIComponent(r)),s.params={count_preference:i},s}return n(t,e),t}(x),Jc=function(t){function r(n,r){var i=t.call(this,n,r)||this;return i.countPreference=e.CountPreference[r.count_preference],i}return n(r,t),r}(F),Xc=function(e){function t(t){var n=this,r=t.channelUrl;return(n=e.call(this)||this).method=d.PUT,n.path="".concat(ve,"/").concat(encodeURIComponent(r),"/reset_user_history"),n}return n(t,e),t}(x),Zc=function(e){function t(t,n){var r=e.call(this,t,n)||this;r.messageOffsetTimestamp=null;var i=n.ts_message_offset;return r.messageOffsetTimestamp=null!=i?i:null,r}return n(t,e),t}(F),$c=r(r({},fa),{scheduledAt:null,file:null,fileUrl:null,fileName:null,mimeType:null,fileSize:null,thumbnailSizes:null,requireAuth:!1}),el=r(r({},va),{scheduledAt:null}),tl=function(t){function r(n){var r,i=this;i=t.call(this)||this;var s=[];n.mentionType===e.MentionType.USERS&&(n.mentionedUserIds?s=n.mentionedUserIds:n.mentionedUsers&&(s=n.mentionedUsers.map((function(e){return e.userId}))));var a=n.channelType,o=n.channelUrl,u=n.scheduledMessageId;return i.method=d.PUT,i.path="".concat(Je(a),"/").concat(encodeURIComponent(o),"/scheduled_messages/").concat(encodeURIComponent(u)),i.params={req_id:n.reqId,scheduled_at:n.scheduledAt,message_type:ae.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 jt.payloadify(e)})):[],custom_type:n.customType,data:n.data,require_auth:n.requireAuth,mention_type:n.mentionType,mentioned_user_ids:s,sorted_metaarray:null===(r=n.metaArrays)||void 0===r?void 0:r.map((function(e){return xt.payloadify(e)})),apple_critical_alert_options:Gt.payloadify(n.appleCriticalAlertOptions),push_option:n.pushNotificationDeliveryOption},i}return n(r,t),r}(x),nl=function(e){function t(t,n){var r=e.call(this,t,n)||this;return r.message=new an(t,n),r}return n(t,e),t}(F),rl=function(t){function r(n){var r,i=this;i=t.call(this)||this;var s=[];n.mentionType===e.MentionType.USERS&&(n.mentionedUserIds?s=n.mentionedUserIds:n.mentionedUsers&&(s=n.mentionedUsers.map((function(e){return e.userId}))));var a=n.channelType,o=n.channelUrl,u=n.scheduledMessageId;return i.method=d.PUT,i.path="".concat(Je(a),"/").concat(encodeURIComponent(o),"/scheduled_messages/").concat(encodeURIComponent(u)),i.params={req_id:n.reqId,scheduled_at:n.scheduledAt,message_type:ae.USER,message:n.message,custom_type:n.customType,data:n.data,mention_type:n.mentionType,mentioned_user_ids:s,sorted_metaarray:null===(r=n.metaArrays)||void 0===r?void 0:r.map((function(e){return xt.payloadify(e)})),apple_critical_alert_options:Gt.payloadify(n.appleCriticalAlertOptions),target_langs:n.translationTargetLanguages,push_option:n.pushNotificationDeliveryOption},i}return n(r,t),r}(x);!function(e){function t(t,n){var r=e.call(this,t,n)||this;return r.message=new nn(t,n),r}n(t,e)}(F);var il=function(e){function t(t){var n=e.call(this)||this,r=t.channelType,i=t.channelUrl,s=t.scheduledMessageId;return n.method=d.DELETE,n.path="".concat(Je(r),"/").concat(encodeURIComponent(i),"/scheduled_messages/").concat(encodeURIComponent(s)),n}return n(t,e),t}(x),sl=function(e){function t(t){var n=e.call(this)||this,r=t.channelType,i=t.channelUrl,s=t.scheduledMessageId;return n.method=d.POST,n.path="".concat(Je(r),"/").concat(encodeURIComponent(i),"/scheduled_messages/").concat(encodeURIComponent(s),"/send_now"),n}return n(t,e),t}(x),al=function(e){function t(t){var n=t.userId,r=t.channelUrl,i=t.pushTriggerOption,s=e.call(this)||this;return s.method=d.PUT,s.path="".concat(fe,"/").concat(encodeURIComponent(n),"/push_preference/").concat(encodeURIComponent(r)),s.params={push_trigger_option:i},s}return n(t,e),t}(x),ol=function(e){function t(t,n){var r=e.call(this,t,n)||this;return r.pushTriggerOption=n.push_trigger_option,r.enabled=n.enable,r}return n(t,e),t}(F),ul=function(e){function t(t){var n=t.userId,r=t.channelUrl,i=e.call(this)||this;return i.method=d.GET,i.path="".concat(fe,"/").concat(encodeURIComponent(n),"/push_preference/").concat(encodeURIComponent(r)),i}return n(t,e),t}(x),cl=function(e){function t(t,n){var r=e.call(this,t,n)||this;return r.pushTriggerOption=n.push_trigger_option,r.enabled=n.enable,r}return n(t,e),t}(F),ll=function(e){function t(t){var n=t.pollId,r=t.title,i=t.data,s=t.isAnonymous,a=t.allowUserSuggestion,o=t.allowMultipleVotes,u=t.closeAt,c=e.call(this)||this;return c.method=d.PUT,c.path="".concat(Ie,"/").concat(encodeURIComponent(n)),c.params={title:r,data:i,is_anonymous:s,allow_user_suggestion:a,allow_multiple_votes:o,close_at:u},c}return n(t,e),t}(x),hl=function(e){function t(t,n){var r=e.call(this,t,n)||this;return r.poll=new tn(t,n),r}return n(t,e),t}(F),dl=function(e){function t(t){var n=t.pollId,r=e.call(this)||this;return r.method=d.DELETE,r.path="".concat(Ie,"/").concat(encodeURIComponent(n)),r}return n(t,e),t}(x);!function(e){function t(){return null!==e&&e.apply(this,arguments)||this}n(t,e)}(F);var pl=function(e){function t(t){var n=t.pollId,r=e.call(this)||this;return r.method=d.PUT,r.path="".concat(Ie,"/").concat(encodeURIComponent(n),"/close"),r}return n(t,e),t}(x),fl=function(e){function t(t,n){var r=e.call(this,t,n)||this;return r.poll=new tn(t,n),r}return n(t,e),t}(F),_l=function(e){function t(t){var n=t.channelUrl,r=t.channelType,i=t.pollId,s=t.optionText,a=e.call(this)||this;return a.method=d.POST,a.path="".concat(Ie,"/").concat(encodeURIComponent(i),"/options"),a.params={channel_url:n,channel_type:r,text:s},a}return n(t,e),t}(x),vl=function(e){function t(t,n){var r=e.call(this,t,n)||this;return r.poll=new tn(t,n),r}return n(t,e),t}(F),ml=function(e){function t(t){var n=t.pollId,r=t.pollOptionId,i=t.optionText,s=e.call(this)||this;return s.method=d.PUT,s.path="".concat(Ie,"/").concat(encodeURIComponent(n),"/options/").concat(encodeURIComponent(r)),s.params={text:i},s}return n(t,e),t}(x),gl=function(e){function t(t,n){var r=e.call(this,t,n)||this;return r.poll=new tn(t,n),r}return n(t,e),t}(F),yl=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(Ie,"/").concat(encodeURIComponent(n),"/options/").concat(encodeURIComponent(r)),i}return n(t,e),t}(x);!function(e){function t(){return null!==e&&e.apply(this,arguments)||this}n(t,e)}(F);var El,bl,Cl,Tl=function(t){function r(n){var r=n.reqId,i=n.channelType,s=n.channelUrl,a=n.pollId,o=n.pollOptionIds;return t.call(this,{code:"VOTE",ackRequired:!0,payload:D({req_id:r,channel_type:i===e.ChannelType.OPEN?"open_channels":"group_channels",channel_url:s,poll_id:a,option_ids:o})})||this}return n(r,t),r}(z);e.CountPreference=void 0,(El=e.CountPreference||(e.CountPreference={})).ALL="all",El.UNREAD_MESSAGE_COUNT_ONLY="unread_message_count_only",El.UNREAD_MENTION_COUNT_ONLY="unread_mention_count_only",El.OFF="off",e.MutedState=void 0,(bl=e.MutedState||(e.MutedState={})).MUTED="muted",bl.UNMUTED="unmuted",e.HiddenState=void 0,(Cl=e.HiddenState||(e.HiddenState={})).UNHIDDEN="unhidden",Cl.HIDDEN_ALLOW_AUTO_UNHIDE="hidden_allow_auto_unhide",Cl.HIDDEN_PREVENT_AUTO_UNHIDE="hidden_prevent_auto_unhide";var Il,Sl=function(t){function c(n,i){var s,a,c,l,h,d,p,f,_,v,m,E,b,C,T,I,S,N,w=this;return(w=t.call(this,n,i)||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=e.HiddenState.UNHIDDEN,w.lastMessage=null,w.messageOffsetTimestamp=0,w.messageSurvivalSeconds=-1,w.myMemberState=e.MemberState.NONE,w.myRole=e.Role.NONE,w.myMutedState=e.MutedState.UNMUTED,w.myLastRead=0,w.myCountPreference=e.CountPreference.ALL,w.myPushTriggerOption=e.PushTriggerOption.DEFAULT,w.inviter=null,w.invitedAt=0,w.joinedAt=0,w.channelType=e.ChannelType.GROUP,w.isDistinct=null!==(a=i.is_distinct)&&void 0!==a&&a,w.isSuper=null!==(c=i.is_super)&&void 0!==c&&c,w.isBroadcast=null!==(l=i.is_broadcast)&&void 0!==l&&l,w.isExclusive=null!==(h=i.is_exclusive)&&void 0!==h&&h,w.isPublic=null!==(d=i.is_public)&&void 0!==d&&d,w.isDiscoverable=null!==(p=i.is_discoverable)&&void 0!==p?p:w.isPublic,w.isAccessCodeRequired=null!==(f=i.is_access_code_required)&&void 0!==f&&f,w.isPushEnabled=null!==(_=i.is_push_enabled)&&void 0!==_&&_,Array.isArray(i.members)&&(s=w.members).push.apply(s,u([],o(i.members.map((function(e){return new Go(w._iid,e)}))),!1)),w.memberCount=null!==(v=i.member_count)&&void 0!==v?v:0,w.joinedMemberCount=null!==(m=i.joined_member_count)&&void 0!==m?m:0,w.hiddenState=y(e.HiddenState,i.hidden_state)?i.hidden_state:e.HiddenState.UNHIDDEN,w.messageOffsetTimestamp=null!==(E=i.ts_message_offset)&&void 0!==E?E:0,w.messageSurvivalSeconds=null!==(b=i.message_survival_seconds)&&void 0!==b?b:-1,w.lastMessage=i.last_message?sn(w._iid,r({channel_type:w.channelType},i.last_message)):null,i.read_receipt&&Object.keys(i.read_receipt).forEach((function(e){g("number",i.read_receipt[e])&&w._updateUnreadMemberState(e,i.read_receipt[e])})),i.delivery_receipt&&Object.keys(i.delivery_receipt).forEach((function(e){g("number",i.delivery_receipt[e])&&w._updateUndeliveredMemberState(e,i.delivery_receipt[e])})),w.myMemberState=y(e.MemberState,i.member_state)?i.member_state:e.MemberState.NONE,w.myRole=y(e.Role,i.my_role)?i.my_role:e.Role.NONE,y(e.MutedState,i.is_muted)?w.myMutedState=i.is_muted:g("boolean",i.is_muted)?w.myMutedState=i.is_muted?e.MutedState.MUTED:e.MutedState.UNMUTED:w.myMutedState=e.MutedState.UNMUTED,w.myCountPreference=y(e.CountPreference,i.count_preference)?i.count_preference:e.CountPreference.ALL,w.myPushTriggerOption=y(e.PushTriggerOption,i.push_trigger_option)?i.push_trigger_option:e.PushTriggerOption.ALL,w.myLastRead=null!==(C=i.user_last_read)&&void 0!==C?C:0,w.inviter=i.inviter?new ht(w._iid,i.inviter):null,w.invitedAt=null!==(T=i.invited_at)&&void 0!==T?T:0,w.joinedAt=null!==(I=i.joined_ts)&&void 0!==I?I:0,w._updateUnreadCount(null!==(S=i.unread_message_count)&&void 0!==S?S:0,null!==(N=i.unread_mention_count)&&void 0!==N?N:0),w}return n(c,t),Object.defineProperty(c.prototype,"isHidden",{get:function(){return this.hiddenState!==e.HiddenState.UNHIDDEN},enumerable:!1,configurable:!0}),Object.defineProperty(c.prototype,"isTyping",{get:function(){return Object.keys(this._typingStatus).length>0},enumerable:!1,configurable:!0}),Object.defineProperty(c.prototype,"cachedUnreadMemberState",{get:function(){var e,t,n={};try{for(var r=a(this._unreadMemberStateMap),i=r.next();!i.done;i=r.next()){var s=o(i.value,2),u=s[0],c=s[1];n[u]=c}}catch(t){e={error:t}}finally{try{i&&!i.done&&(t=r.return)&&t.call(r)}finally{if(e)throw e.error}}return n},enumerable:!1,configurable:!0}),Object.defineProperty(c.prototype,"cachedUndeliveredMemberState",{get:function(){var e,t,n={};try{for(var r=a(this._undeliveredMemberStateMap),i=r.next();!i.done;i=r.next()){var s=o(i.value,2),u=s[0],c=s[1];n[u]=c}}catch(t){e={error:t}}finally{try{i&&!i.done&&(t=r.return)&&t.call(r)}finally{if(e)throw e.error}}return n},enumerable:!1,configurable:!0}),c.payloadify=function(e){return e?D(r(r({},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 Go.payloadify(e)})),last_message:rn(e.lastMessage),inviter:e.inviter?ht.payloadify(e.inviter):null,invited_at:e.invitedAt,joined_ts:e.joinedAt})):null},c.prototype._shouldUpdateLastMessageWith=function(e){return!(e instanceof Bt&&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=wt.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},c.prototype._updateUnreadMemberState=function(e,t){var n=this._unreadMemberStateMap.get(e);return(!n||n0?this._typingStatus[e.userId]={user:e,ts:t}:delete this._typingStatus[e.userId]},c.prototype._invalidateTypingStatus=function(){var e=(new Date).getTime(),t=!1;for(var n in this._typingStatus){e-this._typingStatus[n].ts>=1e4&&(delete this._typingStatus[n],t=!0)}return t},c.prototype._setLatestMemberCount=function(e,t,n){var r=!1;return n>=this._lastMemberCountUpdated&&(this._lastMemberCountUpdated=n,r=e!==this.memberCount||t!==this.joinedMemberCount,this.memberCount=e,this.joinedMemberCount=t),r},c.prototype.isReadMessage=function(e){var t=wt.of(this._iid).sdkState,n=this._unreadMemberStateMap.get(t.userId);return n&&n>=e.createdAt},c.prototype.serialize=function(){var e=this;return ot(this,(function(t){t.cachedUnreadMemberState=e.cachedUnreadMemberState,t.cachedUndeliveredMemberState=e.cachedUndeliveredMemberState}))},c.prototype.createMessageCollection=function(e){return void 0===e&&(e={}),new xc(this._iid,r({channel:this},e))},c.prototype.createMemberListQuery=function(e){return void 0===e&&(e={}),new Vc(this._iid,this.url,e)},c.prototype.addMember=function(t,n){if(void 0===n&&(n=0),!this.isExclusive&&!this.isSuper&&!this.isBroadcast){var r=this.members.findIndex((function(e){return e.userId===t.userId}));if(r>-1){var i=this.members[r];i.state===e.MemberState.JOINED&&(t.state=i.state),this.members.splice(r,1),this.memberCount--}this.members.push(t),this.memberCount++,this._updateUnreadMemberState(t.userId,n),this._updateUndeliveredMemberState(t.userId,n)}},c.prototype.removeMember=function(e){if(!this.isExclusive&&!this.isSuper&&!this.isBroadcast){var t=this.members.findIndex((function(t){return t.userId===e.userId}));if(t>-1)return this.members.splice(t,1),this.memberCount--,!0}return!1},c.prototype.getUnreadMemberCount=function(t){var n,r;if(t instanceof Bt&&!this.isExclusive&&!this.isSuper&&!this.isBroadcast){var i=wt.of(this._iid).sdkState,s=t.createdAt,o=0;try{for(var u=a(this.members),c=u.next();!c.done;c=u.next()){var l=c.value;if(i.userId!==l.userId&&l.state===e.MemberState.JOINED&&t.sender.userId!==l.userId)(this.cachedUnreadMemberState[l.userId]||0)=e.createdAt&&i.push(s))})),i},c.prototype.getUnreadMembers=function(e,t){var n=this;void 0===t&&(t=!1);var r=wt.of(this._iid).sdkState;if(!r.userId||this.isExclusive||this.isSuper||this.isBroadcast)return[];var i=[];return this.members.forEach((function(s){(t||s.userId!==r.userId&&s.userId!==e.sender.userId)&&(n._unreadMemberStateMap.get(s.userId)=e&&(delete this._typingStatus[r],n=!0)}return n},c.prototype.refresh=function(){return i(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=wt.of(this._iid),n=t.requestQueue,r=t.dispatcher,i=new lu({channelUrl:this.url}),[4,n.send(i)];case 1:return a=s.sent(),o=a.as(hu).channel,r.dispatch(new iu({channels:[o],source:e.GroupChannelEventSource.REQUEST_CHANNEL})),[2,o]}}))}))},c.prototype.freeze=function(){return i(this,void 0,void 0,(function(){return s(this,(function(n){switch(n.label){case 0:return[4,t.prototype.freeze.call(this)];case 1:return n.sent(),wt.of(this._iid).dispatcher.dispatch(new iu({channels:[this],source:e.GroupChannelEventSource.EVENT_CHANNEL_HIDDEN})),[2]}}))}))},c.prototype.unfreeze=function(){return i(this,void 0,void 0,(function(){return s(this,(function(n){switch(n.label){case 0:return[4,t.prototype.unfreeze.call(this)];case 1:return n.sent(),wt.of(this._iid).dispatcher.dispatch(new iu({channels:[this],source:e.GroupChannelEventSource.EVENT_CHANNEL_UNHIDDEN})),[2]}}))}))},c.prototype.updateChannel=function(t){return i(this,void 0,void 0,(function(){var n,i,a,o,u,c,l;return s(this,(function(s){switch(s.label){case 0:return n=r(r({},Fc),t),ct(function(e){return g("string",e.coverUrl,!0)&&(T(e.coverImage)||g("string",e.coverImage)||null===e.coverImage)&&g("boolean",e.isDistinct,!0)&&g("boolean",e.isPublic,!0)&&g("boolean",e.isDiscoverable,!0)&&g("string",e.accessCode,!0)&&g("string",e.name,!0)&&g("string",e.data,!0)&&g("string",e.customType,!0)&&b("string",e.operatorUserIds,!0)&&g("number",e.messageSurvivalSeconds,!0)}(n)).throw(f.invalidParameters),i=wt.of(this._iid),a=i.dispatcher,o=i.requestQueue,u=new Bc(r({channelUrl:this.url},n)),[4,o.send(u)];case 1:return c=s.sent(),l=c.as(jc).channel,a.dispatch(new iu({channels:[l],source:e.GroupChannelEventSource.EVENT_CHANNEL_UPDATED})),[2,l]}}))}))},c.prototype.invite=function(e){return i(this,void 0,void 0,(function(){return s(this,(function(t){return ct(e.every((function(e){return e instanceof ht}))).throw(f.invalidParameters),[2,this.inviteWithUserIds(e.map((function(e){return e.userId})))]}))}))},c.prototype.inviteWithUserIds=function(t){return i(this,void 0,void 0,(function(){var n,r,i,a,o,u;return s(this,(function(s){switch(s.label){case 0:return ct(b("string",t)).throw(f.invalidParameters),n=wt.of(this._iid),r=n.dispatcher,i=n.requestQueue,a=new ku({channelUrl:this.url,userIds:t}),[4,i.send(a)];case 1:return o=s.sent(),u=o.as(Du).channel,r.dispatch(new iu({channels:[u],source:e.GroupChannelEventSource.EVENT_CHANNEL_INVITED})),[2,u]}}))}))},c.prototype.join=function(t){return void 0===t&&(t=null),i(this,void 0,void 0,(function(){var n,r,i,a,o,u,c;return s(this,(function(s){switch(s.label){case 0:return ct(g("string",t)||null===t).throw(f.invalidParameters),n=wt.of(this._iid),r=n.dispatcher,i=n.sdkState,a=n.requestQueue,o=new Au({channelUrl:this.url,userId:i.userId,accessCode:t}),[4,a.send(o)];case 1:return u=s.sent(),(c=u.as(Uu).channel).myMemberState=e.MemberState.JOINED,r.dispatch(new iu({channels:[c],source:e.GroupChannelEventSource.EVENT_CHANNEL_JOINED})),[2,this]}}))}))},c.prototype.leave=function(e){return void 0===e&&(e=!1),i(this,void 0,void 0,(function(){var t,n,r,i;return s(this,(function(s){switch(s.label){case 0:return t=wt.of(this._iid),n=t.sdkState,r=t.requestQueue,i=new Ru({channelUrl:this.url,userId:n.userId,shouldRemoveOperatorStatus:e}),[4,r.send(i)];case 1:return s.sent(),[2]}}))}))},c.prototype.acceptInvitation=function(t){return void 0===t&&(t=null),i(this,void 0,void 0,(function(){var n,r,i,a,o,u,c;return s(this,(function(s){switch(s.label){case 0:return ct(g("string",t)||null===t).throw(f.invalidParameters),n=wt.of(this._iid),r=n.dispatcher,i=n.sdkState,a=n.requestQueue,o=new Kc({channelUrl:this.url,userId:i.userId,accessCode:t}),[4,a.send(o)];case 1:return u=s.sent(),(c=u.as(Qc).channel).myMemberState=e.MemberState.JOINED,r.dispatch(new iu({channels:[c],source:e.GroupChannelEventSource.EVENT_CHANNEL_ACCEPTED_INVITE})),[2,c]}}))}))},c.prototype.declineInvitation=function(){return i(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=wt.of(this._iid),n=t.sdkState,r=t.requestQueue,i=new xu({channelUrl:this.url,userId:n.userId}),[4,r.send(i)];case 1:return a=s.sent(),(o=a.as(Fu).channel).myMemberState=e.MemberState.NONE,[2,o]}}))}))},c.prototype.sendUserMessage=function(n){var r=this,i=new Dn,s=wt.of(this._iid).dispatcher,a=$r.of(this._iid);return t.prototype.sendUserMessage.call(this,n).onPending((function(e){a.completeCurrentAndProcessNextAutoResend(e),i._trigger(null,e)})).onFailed((function(e,t){t&&a.completeCurrentAndProcessNextAutoResend(t),i._trigger(e,t)})).onSucceeded((function(t){var n=lc.of(r._iid);a.completeCurrentAndProcessNextAutoResend(t),r._shouldUpdateLastMessageWith(t)&&(r.lastMessage=t),n.handlers.map((function(e){return e.onChannelChanged(r)})),s.dispatch(new iu({channels:[r],source:e.GroupChannelEventSource.EVENT_MESSAGE_SENT})),i._trigger(null,t)})),i},c.prototype.updateUserMessage=function(n,r){return i(this,void 0,void 0,(function(){var i,a,o,u=this;return s(this,(function(s){switch(s.label){case 0:return i=wt.of(this._iid).dispatcher,[4,t.prototype.updateUserMessage.call(this,n,r)];case 1:return a=s.sent(),o=!1,!a.silent&&this._shouldUpdateLastMessageWith(a)&&(this.lastMessage=a,o=!0),o&&(lc.of(this._iid).handlers.map((function(e){return e.onChannelChanged(u)})),i.dispatch(new iu({channels:[this],source:e.GroupChannelEventSource.EVENT_CHANNEL_UPDATED}))),i.dispatch(new yn({messages:[a],source:e.MessageEventSource.EVENT_MESSAGE_UPDATED})),[2,a]}}))}))},c.prototype._autoResendUserMessage=function(n){var r=this,i=new Dn,s=wt.of(this._iid).dispatcher,a=$r.of(this._iid);return t.prototype._autoResendUserMessage.call(this,n).onPending((function(e){a.completeCurrentAndProcessNextAutoResend(e),i._trigger(null,e)})).onFailed((function(e,t){a.completeCurrentAndProcessNextAutoResend(t),i._trigger(e,t)})).onSucceeded((function(t){var n=lc.of(r._iid);a.completeCurrentAndProcessNextAutoResend(t),r._shouldUpdateLastMessageWith(t)&&(r.lastMessage=t),n.handlers.map((function(e){return e.onChannelChanged(r)})),s.dispatch(new iu({channels:[r],source:e.GroupChannelEventSource.EVENT_MESSAGE_SENT})),i._trigger(null,t)})),i},c.prototype.sendFileMessage=function(n){var r=this,i=new Dn,s=wt.of(this._iid).dispatcher,a=$r.of(this._iid);return t.prototype.sendFileMessage.call(this,n).onPending((function(e){a.completeCurrentAndProcessNextAutoResend(e),i._trigger(null,e)})).onFailed((function(e,t){t&&a.completeCurrentAndProcessNextAutoResend(t),i._trigger(e,t)})).onSucceeded((function(t){var n=lc.of(r._iid);a.completeCurrentAndProcessNextAutoResend(t),r._shouldUpdateLastMessageWith(t)&&(r.lastMessage=t),n.handlers.map((function(e){return e.onChannelChanged(r)})),s.dispatch(new iu({channels:[r],source:e.GroupChannelEventSource.EVENT_MESSAGE_SENT})),i._trigger(null,t)})),i},c.prototype.updateFileMessage=function(n,r){return i(this,void 0,void 0,(function(){var i,a,o,u=this;return s(this,(function(s){switch(s.label){case 0:return i=wt.of(this._iid).dispatcher,[4,t.prototype.updateFileMessage.call(this,n,r)];case 1:return a=s.sent(),o=!1,!a.silent&&this._shouldUpdateLastMessageWith(a)&&(this.lastMessage=a,o=!0),o&&(lc.of(this._iid).handlers.map((function(e){return e.onChannelChanged(u)})),i.dispatch(new iu({channels:[this],source:e.GroupChannelEventSource.EVENT_CHANNEL_UPDATED}))),i.dispatch(new yn({messages:[a],source:e.MessageEventSource.EVENT_MESSAGE_UPDATED})),[2,a]}}))}))},c.prototype._autoResendFileMessage=function(n){var r=this,i=new Dn,s=wt.of(this._iid).dispatcher,a=$r.of(this._iid);return t.prototype._autoResendFileMessage.call(this,n).onPending((function(e){a.completeCurrentAndProcessNextAutoResend(e),i._trigger(null,e)})).onFailed((function(e,t){a.completeCurrentAndProcessNextAutoResend(t),i._trigger(e,t)})).onSucceeded((function(t){var n=lc.of(r._iid);a.completeCurrentAndProcessNextAutoResend(t),r._shouldUpdateLastMessageWith(t)&&(r.lastMessage=t),n.handlers.map((function(e){return e.onChannelChanged(r)})),s.dispatch(new iu({channels:[r],source:e.GroupChannelEventSource.EVENT_MESSAGE_SENT})),i._trigger(null,t)})),i},c.prototype.deleteMessage=function(n){return i(this,void 0,void 0,(function(){return s(this,(function(r){switch(r.label){case 0:return[4,t.prototype.deleteMessage.call(this,n)];case 1:return r.sent(),0===n.messageId&&wt.of(this._iid).dispatcher.dispatch(new bn({reqId:n.reqId,source:e.MessageEventSource.EVENT_MESSAGE_DELETED})),[2]}}))}))},c.prototype.hide=function(t){return i(this,void 0,void 0,(function(){var n,i,a,o,u,c,l,h;return s(this,(function(s){switch(s.label){case 0:return n=r(r({},qc),t),ct(function(e){return g("boolean",e.hidePreviousMessages)&&g("boolean",e.allowAutoUnhide)}(n)).throw(f.invalidParameters),i=wt.of(this._iid),a=i.dispatcher,o=i.sdkState,u=i.requestQueue,c=new Bu(r({channelUrl:this.url,userId:o.userId},n)),[4,u.send(c)];case 1:return l=s.sent(),h=l.as(ju).messageOffsetTimestamp,this.hiddenState=n.allowAutoUnhide?e.HiddenState.HIDDEN_ALLOW_AUTO_UNHIDE:e.HiddenState.HIDDEN_PREVENT_AUTO_UNHIDE,n.hidePreviousMessages&&this._updateUnreadCount(0,0),h&&(this.messageOffsetTimestamp=h),a.dispatch(new iu({channels:[this],source:e.GroupChannelEventSource.EVENT_CHANNEL_HIDDEN})),[2,this]}}))}))},c.prototype.unhide=function(){return i(this,void 0,void 0,(function(){var t,n,r,i;return s(this,(function(s){switch(s.label){case 0:return t=wt.of(this._iid),n=t.dispatcher,r=t.requestQueue,i=new Wc({channelUrl:this.url}),[4,r.send(i)];case 1:return s.sent(),this.hiddenState=e.HiddenState.UNHIDDEN,n.dispatch(new iu({channels:[this],source:e.GroupChannelEventSource.EVENT_CHANNEL_UNHIDDEN})),[2,this]}}))}))},c.prototype.delete=function(){return i(this,void 0,void 0,(function(){var e,t;return s(this,(function(n){switch(n.label){case 0:return e=wt.of(this._iid).requestQueue,t=new zc({channelUrl:this.url}),[4,e.send(t)];case 1:return n.sent(),[2]}}))}))},c.prototype.markAsRead=function(){return i(this,void 0,void 0,(function(){var t,n,r,i,a,o,u,c=this;return s(this,(function(s){switch(s.label){case 0:return t=wt.of(this._iid),n=t.sdkState,r=t.dispatcher,i=t.requestQueue,a=new Gu({channelUrl:this.url}),[4,i.send(a)];case 1:return o=s.sent(),u=o.as(Hu).readStatus,this._updateUnreadMemberState(n.userId,u.readAt),(this.unreadMessageCount>0||this.unreadMentionCount>0)&&(this._updateUnreadCount(0,0),lc.of(this._iid).handlers.map((function(e){return e.onChannelChanged(c)}))),r.dispatch(new iu({channels:[this],source:e.GroupChannelEventSource.EVENT_CHANNEL_READ})),[2]}}))}))},c.prototype.markAsDelivered=function(){return i(this,void 0,void 0,(function(){var e,t,n,r;return s(this,(function(i){switch(i.label){case 0:return e=wt.of(this._iid),t=e.sdkState,n=e.requestQueue,r=new Vu({channelUrl:this.url,userId:t.userId}),[4,n.send(r)];case 1:return i.sent(),[2]}}))}))},c.prototype.startTyping=function(){return i(this,void 0,void 0,(function(){var e,t,n,r,i;return s(this,(function(s){return e=wt.of(this._iid),t=e.requestQueue,n=e.typingIndicatorThrottle,(r=(new Date).getTime())-this._typingStarted>=n&&(this._typingStarted=r,this._typingEnded=0,i=new Wu({channelUrl:this.url,time:this._typingStarted}),t.send(i)),[2]}))}))},c.prototype.endTyping=function(){return i(this,void 0,void 0,(function(){var e,t,n,r,i;return s(this,(function(s){return e=wt.of(this._iid),t=e.requestQueue,n=e.typingIndicatorThrottle,(r=(new Date).getTime())-this._typingEnded>=n&&(this._typingStarted=0,this._typingEnded=r,i=new Ju({channelUrl:this.url,time:this._typingStarted}),t.send(i)),[2]}))}))},c.prototype.createScheduledUserMessage=function(e){e=r(r({},Vr),e),ct(function(e){return Dr(e)&&g("number",e.scheduledAt,!0)}(e)).throw(f.invalidParameters);var t=new Dn;return this._createScheduledUserMessage(e,t),t},c.prototype.updateScheduledUserMessage=function(e,t){return i(this,void 0,void 0,(function(){var n,i,a,o;return s(this,(function(s){switch(s.label){case 0:return n=r(r({},el),t),ct(function(e){return ma(e)&&g("number",e.scheduledAt,!0)}(n)).throw(f.invalidParameters),i=wt.of(this._iid).requestQueue,a=new rl(r({reqId:this._generateRequestId(),scheduledMessageId:e,channelType:this.channelType,channelUrl:this.url},n)),[4,i.send(a)];case 1:return o=s.sent(),[2,o.as(No).message]}}))}))},c.prototype.createScheduledFileMessage=function(e){var t=this;e=r(r({},Kr),e),ct(function(e){return Rr(e)&&g("number",e.scheduledAt)&&(T(e.file)||g("string",e.fileUrl))&&g("string",e.fileName,!0)&&g("string",e.mimeType,!0)&&g("number",e.fileSize,!0)&&(null===e.thumbnailSizes||e.thumbnailSizes.every((function(e){return g("object",e)&&e.maxWidth>0&&e.maxHeight>0})))}(e)).throw(f.invalidParameters);var n=Date.now(),a=this._generateRequestId(),o=new Dn;return Re(2).then((function(){var r=t._createPendingScheduledFileMessage(e,a,n);De((function(){return i(t,void 0,void 0,(function(){return s(this,(function(e){return[2,o._trigger(null,r)]}))}))}))})),T(e.file)?this._uploadFileAndUpdateParams(e).then((function(){return t._createScheduledFileMessage(e,o,a,n)})):this._createScheduledFileMessage(e,o,a,n),o},c.prototype.updateScheduledFileMessage=function(e,t){return i(this,void 0,void 0,(function(){var n,i,a;return s(this,(function(s){switch(s.label){case 0:return n=r(r({},$c),t),ct(function(e){return _a(e)&&g("number",e.scheduledAt,!0)&&(T(e.file)||g("string",e.fileUrl))&&g("string",e.fileName,!0)&&g("string",e.mimeType,!0)&&g("number",e.fileSize,!0)&&(null===e.thumbnailSizes||e.thumbnailSizes.every((function(e){return g("object",e)&&e.maxWidth>0&&e.maxHeight>0})))}(n)).throw(f.invalidParameters),T(n.file)?[4,this._uploadFileAndUpdateParams(n)]:[3,2];case 1:s.sent(),s.label=2;case 2:return i=new tl(r({reqId:this._generateRequestId(),scheduledMessageId:e,channelType:this.channelType,channelUrl:this.url},n)),[4,wt.of(this._iid).requestQueue.send(i)];case 3:return a=s.sent(),[2,a.as(nl).message]}}))}))},c.prototype.cancelScheduledMessage=function(e){return i(this,void 0,void 0,(function(){var t;return s(this,(function(n){switch(n.label){case 0:return t=new il({scheduledMessageId:e,channelType:this.channelType,channelUrl:this.url}),[4,wt.of(this._iid).requestQueue.send(t)];case 1:return n.sent(),[2]}}))}))},c.prototype.sendScheduledMessageNow=function(e){return i(this,void 0,void 0,(function(){var t;return s(this,(function(n){switch(n.label){case 0:return t=new sl({scheduledMessageId:e,channelType:this.channelType,channelUrl:this.url}),[4,wt.of(this._iid).requestQueue.send(t)];case 1:return n.sent(),[2]}}))}))},c.prototype.getMyPushTriggerOption=function(){return i(this,void 0,void 0,(function(){var e,t,n,r,i,a;return s(this,(function(s){switch(s.label){case 0:return e=wt.of(this._iid),t=e.sdkState,n=e.requestQueue,r=new ul({userId:t.userId,channelUrl:this.url}),[4,n.send(r)];case 1:return i=s.sent(),a=i.as(cl).pushTriggerOption,this.myPushTriggerOption=a,[2,a]}}))}))},c.prototype.setMyPushTriggerOption=function(t){return i(this,void 0,void 0,(function(){var n,r,i,a,o,u;return s(this,(function(s){switch(s.label){case 0:return ct(y(e.PushTriggerOption,t)).throw(f.invalidParameters),n=wt.of(this._iid),r=n.sdkState,i=n.requestQueue,a=new al({userId:r.userId,channelUrl:this.url,pushTriggerOption:t}),[4,i.send(a)];case 1:return o=s.sent(),u=o.as(ol).pushTriggerOption,this.myPushTriggerOption=u,[2,u]}}))}))},c.prototype.setMyCountPreference=function(t){return i(this,void 0,void 0,(function(){var n,r,i,a,o,u,c;return s(this,(function(s){switch(s.label){case 0:return ct(y(e.CountPreference,t)).throw(f.invalidParameters),n=wt.of(this._iid),r=n.dispatcher,i=n.sdkState,a=n.requestQueue,o=new Yc({channelUrl:this.url,userId:i.userId,countPreference:t}),[4,a.send(o)];case 1:return u=s.sent(),c=u.as(Jc).countPreference,this.myCountPreference=c,this._updateUnreadCount(this.unreadMessageCount,this.unreadMentionCount),r.dispatch(new iu({channels:[this],source:e.GroupChannelEventSource.EVENT_CHANNEL_CREATED})),[2,c]}}))}))},c.prototype.resetMyHistory=function(){return i(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=wt.of(this._iid),n=t.dispatcher,r=t.requestQueue,i=new Xc({channelUrl:this.url}),[4,r.send(i)];case 1:return a=s.sent(),o=a.as(Zc).messageOffsetTimestamp,this.messageOffsetTimestamp=o,n.dispatch(new iu({channels:[this],source:e.GroupChannelEventSource.EVENT_CHANNEL_RESET_HISTORY})),[2,this]}}))}))},c.prototype.updatePoll=function(e,t){return i(this,void 0,void 0,(function(){var n,i,a;return s(this,(function(s){switch(s.label){case 0:return ct(g("number",e)&&function(e){return g("string",e.title,!0)&&$t(e.data)&&g("boolean",e.isAnonymous,!0)&&g("boolean",e.allowUserSuggestion,!0)&&g("boolean",e.allowMultipleVotes,!0)&&g("number",e.closeAt,!0)}(t)).throw(f.invalidParameters),n=wt.of(this._iid).requestQueue,i=new ll(r({pollId:e},t)),[4,n.send(i)];case 1:return a=s.sent(),[2,a.as(hl).poll]}}))}))},c.prototype.deletePoll=function(e){return i(this,void 0,void 0,(function(){var t,n,r;return s(this,(function(i){switch(i.label){case 0:return t=g("number",e),ct(t).throw(f.invalidParameters),n=wt.of(this._iid).requestQueue,r=new dl({pollId:e}),[4,n.send(r)];case 1:return i.sent(),[2]}}))}))},c.prototype.closePoll=function(e){return i(this,void 0,void 0,(function(){var t,n,r,i;return s(this,(function(s){switch(s.label){case 0:return t=g("number",e),ct(t).throw(f.invalidParameters),n=wt.of(this._iid).requestQueue,r=new pl({pollId:e}),[4,n.send(r)];case 1:return i=s.sent(),[2,i.as(fl).poll]}}))}))},c.prototype.addPollOption=function(e,t){return i(this,void 0,void 0,(function(){var n,r,i,a;return s(this,(function(s){switch(s.label){case 0:return n=g("number",e)&&g("string",t)&&""!==t.trim(),ct(n).throw(f.invalidParameters),r=wt.of(this._iid).requestQueue,i=new _l({channelUrl:this.url,channelType:this.channelType,pollId:e,optionText:t}),[4,r.send(i)];case 1:return a=s.sent(),[2,a.as(vl).poll]}}))}))},c.prototype.updatePollOption=function(e,t,n){return i(this,void 0,void 0,(function(){var r,i,a,o;return s(this,(function(s){switch(s.label){case 0:return r=g("number",e)&&g("number",t)&&g("string",n)&&""!==n.trim(),ct(r).throw(f.invalidParameters),i=wt.of(this._iid).requestQueue,a=new ml({pollId:e,pollOptionId:t,optionText:n}),[4,i.send(a)];case 1:return o=s.sent(),[2,o.as(gl).poll]}}))}))},c.prototype.deletePollOption=function(e,t){return i(this,void 0,void 0,(function(){var n,r,i;return s(this,(function(s){switch(s.label){case 0:return n=g("number",e)&&g("number",t),ct(n).throw(f.invalidParameters),r=wt.of(this._iid).requestQueue,i=new yl({pollId:e,pollOptionId:t}),[4,r.send(i)];case 1:return s.sent(),[2]}}))}))},c.prototype.votePoll=function(t,n){return i(this,void 0,void 0,(function(){var r,i,a,o,u,c,l;return s(this,(function(s){switch(s.label){case 0:return r=g("number",t)&&b("number",n),ct(r).throw(f.invalidParameters),i=wt.of(this._iid),a=i.requestQueue,o=i.dispatcher,u=new Tl({reqId:this._generateRequestId(),channelUrl:this.url,channelType:this.channelType,pollId:t,pollOptionIds:n}),[4,a.send(u)];case 1:return c=s.sent(),l=c.as(ac).event,o.dispatch(new In({event:l,source:e.MessageEventSource.EVENT_POLL_VOTED})),[2,l]}}))}))},c.prototype.getPollChangeLogsSinceTimestamp=function(e){return i(this,void 0,void 0,(function(){return s(this,(function(t){switch(t.label){case 0:return ct(g("number",e)).throw(f.invalidParameters),[4,lr.of(this._iid).getPollChangeLogs(this.url,this.channelType,e)];case 1:return[2,t.sent()]}}))}))},c.prototype.getPollChangeLogsSinceToken=function(e){return i(this,void 0,void 0,(function(){return s(this,(function(t){switch(t.label){case 0:return ct(g("string",e,!0)),[4,lr.of(this._iid).getPollChangeLogs(this.url,this.channelType,e)];case 1:return[2,t.sent()]}}))}))},c.prototype.createPollListQuery=function(e){return void 0===e&&(e=10),new _r(this._iid,{channelUrl:this.url,channelType:this.channelType,limit:e})},c.prototype.createPollVoterListQuery=function(e,t,n){return void 0===n&&(n=20),new gr(this._iid,{channelUrl:this.url,channelType:this.channelType,pollId:e,pollOptionId:t,limit:n})},c.prototype._uploadFileAndUpdateParams=function(e){return i(this,void 0,void 0,(function(){var t,n,r,i,a,o,u,c,l,h,d;return s(this,(function(s){switch(s.label){case 0:return T(e.file)?(t=wt.of(this._iid).requestQueue,n=new Ut({file:e.file,channelUrl:this.url,thumbnailSizes:e.thumbnailSizes,requestId:this._generateRequestId()}),[4,t.send(n)]):[3,2];case 1:r=s.sent(),i=r.as(Ot),a=i.url,o=i.fileSize,u=void 0===o?e.fileSize:o,c=i.thumbnailSizes,l=void 0===c?e.thumbnailSizes:c,h=i.requireAuth,d=void 0!==h&&h,e.fileUrl=a,e.fileSize=u,e.thumbnailSizes=l,e.requireAuth=d,s.label=2;case 2:return[2]}}))}))},c}(Ao),Nl={},wl=function(){function t(t){var n=t._iid,r=this;this._sync=null,this._metadata=null,this._iid=n;var a,c=wt.of(this._iid),l=c.sdkState,h=c.logger;this._metadataKey=(a=l.userId,"sendbird:".concat(a,"@groupchannel/sync.meta"));var d=function(e){return"sendbird:".concat(e,"@groupchannel/sync")}(l.userId);this._sync=new _c(d,(function(){return i(r,void 0,void 0,(function(){var t,n,r,i,a,c;return s(this,(function(s){switch(s.label){case 0:return t={hasNext:!0,nextToken:""},[4,this.loadMetadata()];case 1:if(s.sent(),h.debug("channel background sync from",this._metadata.token),this._metadata.completed)return[3,9];s.label=2;case 2:return s.trys.push([2,5,,8]),[4,lc.of(this._iid).getMyGroupChannels(this._metadata.token,{includeEmpty:!0,order:e.GroupChannelListOrder.CHRONOLOGICAL},100,e.GroupChannelEventSource.SYNC_CHANNEL_BACKGROUND)];case 3:return n=s.sent(),r=n.channels,i=n.token,t.hasNext=r.length>=100&&!!i,t.nextToken=i,this._metadata.token=i,(c=this._metadata.range).extends.apply(c,u([],o(r.map((function(e){return e.createdAt}))),!1)),this._metadata.completed=!t.hasNext,h.debug("channel background sync progress",t),[4,this.saveMetadata()];case 4:return s.sent(),[3,8];case 5:return a=s.sent(),h.debug("channel background sync error",a),a instanceof f&&a.isInvalidTokenError?[4,this.clearMetaData()]:[3,7];case 6:s.sent(),s.label=7;case 7:throw a;case 8:return[3,10];case 9:t.hasNext=!1,t.nextToken="",s.label=10;case 10:return[2,t]}}))}))}))}return t.of=function(e){if(!Nl[e]){var n=Nl[e]=new t({_iid:e});wt.of(e).dispatcher.on((function(e){if(e instanceof he)if(e.stateType===X.CONNECTED)n.resume();else n.pause()}))}return Nl[e]},Object.defineProperty(t.prototype,"range",{get:function(){var e;return null===(e=this._metadata)||void 0===e?void 0:e.range},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"completed",{get:function(){var e;return!!(null===(e=this._metadata)||void 0===e?void 0:e.completed)},enumerable:!1,configurable:!0}),t.prototype.loadMetadata=function(){return i(this,void 0,void 0,(function(){var e;return s(this,(function(t){switch(t.label){case 0:return this._metadata?[3,2]:[4,wt.of(this._iid).cacheContext.preference.get(this._metadataKey)];case 1:e=t.sent(),this._metadata={token:e?e.token:"",range:new uc(e?e.range:{top:Number.MAX_SAFE_INTEGER,bottom:0}),completed:!!e&&e.completed},t.label=2;case 2:return[2]}}))}))},t.prototype.saveMetadata=function(){return i(this,void 0,void 0,(function(){return s(this,(function(e){switch(e.label){case 0:return this._metadata?[4,wt.of(this._iid).cacheContext.preference.set(this._metadataKey,this._metadata)]:[3,2];case 1:e.sent(),e.label=2;case 2:return[2]}}))}))},t.prototype.clearMetaData=function(){return i(this,void 0,void 0,(function(){return s(this,(function(e){switch(e.label){case 0:return[4,wt.of(this._iid).cacheContext.preference.remove(this._metadataKey)];case 1:return e.sent(),this._metadata=null,[2]}}))}))},t.prototype.resume=function(){var e,t;wt.of(this._iid).logger.debug("channel background sync resume()"),this._sync.start(null!==(t=null===(e=this._metadata)||void 0===e?void 0:e.token)&&void 0!==t?t:"")},t.prototype.pause=function(){wt.of(this._iid).logger.debug("channel background sync stop()"),this._sync.stop()},t}(),Ml={},Al=function(){function t(t){var n=t._iid,r=this;this._sync=null,this._metadataKey=null,this._metadata=null,this._iid=n;var a,o=wt.of(this._iid),u=o.logger,c=o.sdkState;this._metadataKey=(a=c.userId,"sendbird:".concat(a,"@groupchannel/changelogs.meta"));var l=function(e){return"sendbird:".concat(e,"@groupchannel/changelogs")}(c.userId);this._sync=new _c(l,(function(){return i(r,void 0,void 0,(function(){var t,n,r,i,a;return s(this,(function(s){switch(s.label){case 0:return t={hasNext:!0,nextToken:0},[4,this.loadMetadata()];case 1:s.sent(),u.debug("channel changelog sync from",this._metadata.token),s.label=2;case 2:return s.trys.push([2,5,,8]),[4,lc.of(this._iid).getMyGroupChannelChangeLogs(this._metadata.token,{},e.GroupChannelEventSource.SYNC_CHANNEL_CHANGELOGS)];case 3:return n=s.sent(),r=n.hasMore,i=n.token,t.hasNext=r,t.nextToken=i,this._metadata.token=i,u.debug("channel changelog sync progress",t),[4,this.saveMetadata()];case 4:return s.sent(),[3,8];case 5:return a=s.sent(),u.debug("channel changelog sync error",a),a instanceof f&&a.isInvalidTokenError?[4,this.clearMetadata()]:[3,7];case 6:s.sent(),s.label=7;case 7:throw a;case 8:return[2,t]}}))}))}))}return t.of=function(e){if(!Ml[e]){var n=Ml[e]=new t({_iid:e});wt.of(e).dispatcher.on((function(e){if(e instanceof he)if(e.stateType===X.CONNECTED)n.resume();else n.pause()}))}return Ml[e]},t.prototype.loadMetadata=function(){return i(this,void 0,void 0,(function(){var e,t,n,r;return s(this,(function(i){switch(i.label){case 0:return this._metadata?[3,2]:(e=wt.of(this._iid),t=e.cacheContext,n=e.firstConnectedAt,[4,t.preference.get(this._metadataKey)]);case 1:r=i.sent(),this._metadata={token:r?r.token:n/1e3},i.label=2;case 2:return[2]}}))}))},t.prototype.saveMetadata=function(){return i(this,void 0,void 0,(function(){return s(this,(function(e){switch(e.label){case 0:return this._metadata?[4,wt.of(this._iid).cacheContext.preference.set(this._metadataKey,this._metadata)]:[3,2];case 1:e.sent(),e.label=2;case 2:return[2]}}))}))},t.prototype.clearMetadata=function(){return i(this,void 0,void 0,(function(){return s(this,(function(e){switch(e.label){case 0:return[4,wt.of(this._iid).cacheContext.preference.remove(this._metadataKey)];case 1:return e.sent(),this._metadata=null,[2]}}))}))},t.prototype.resume=function(){this._sync.start(0)},t.prototype.pause=function(){this._sync.stop()},t}(),Ul=function(){function t(t,n){var r=n.filter,i=n.order,s=n.limit,a=this;this.channels=[],this._iid=t,this._key="gcc-".concat(U()),this.filter=null!=r?r:new Ko,this.order=null!=i?i:e.GroupChannelListOrder.LATEST_LAST_MESSAGE,this._hasMore=!0,this._token="",this._limit=null!=s?s:100;var o=wt.of(this._iid),u=o.sdkState;o.cacheContext.localCacheEnabled&&wl.of(t).resume(),Al.of(t).resume(),lc.of(this._iid).subscribeGroupChannelEvent(this._key,{onUpdate:function(e,t){var n=e.filter((function(e){return a.filter.match(e,u.userId)})),r=e.filter((function(e){return!a.filter.match(e,u.userId)})).map((function(e){return e.url}));n.length>0&&a._addChannelsToView(n,t),r.length>0&&a._removeChannelsFromView(r,t)},onRemove:function(e,t){a._removeChannelsFromView(e,t)}})}return Object.defineProperty(t.prototype,"hasMore",{get:function(){return this._hasMore},enumerable:!1,configurable:!0}),t.prototype.setGroupChannelCollectionHandler=function(e){this._handler=e},t.prototype._addChannelsToView=function(t,n,r){var o,u,c=this;void 0===r&&(r=!1);var l=[],h=[];try{for(var d=a(t),p=d.next();!p.done;p=d.next()){var f=p.value,_=Nc(this.channels,f,this.order),v=_.place;if(_.contains)switch(h.push(f),n){case e.GroupChannelEventSource.EVENT_CHANNEL_UPDATED:case e.GroupChannelEventSource.EVENT_MESSAGE_RECEIVED:this.channels.splice(v,1);var m=Nc(this.channels,f,this.order).place;this.channels.splice(m,0,f);break;default:this.channels[v]=f}else if(v===this.channels.length){var g=wl.of(this._iid);(r||g.completed)&&(l.push(f),this.channels.push(f))}else l.push(f),this.channels.splice(v,0,f)}}catch(e){o={error:e}}finally{try{p&&!p.done&&(u=d.return)&&u.call(d)}finally{if(o)throw o.error}}ru(n)&&De((function(){return i(c,void 0,void 0,(function(){var e;return s(this,(function(t){return e=new vc(n),l.length>0&&this._handler.onChannelsAdded(e,l),h.length>0&&this._handler.onChannelsUpdated(e,h),[2]}))}))}))},t.prototype._removeChannelsFromView=function(e,t){var n,r,o=this,u=[],c=function(e){var t=l.channels.findIndex((function(t){return t.url===e}));t>=0&&(u.push(l.channels[t].url),l.channels.splice(t,1))},l=this;try{for(var h=a(e),d=h.next();!d.done;d=h.next()){c(d.value)}}catch(e){n={error:e}}finally{try{d&&!d.done&&(r=h.return)&&r.call(h)}finally{if(n)throw n.error}}return ru(t)&&u.length>0&&De((function(){return i(o,void 0,void 0,(function(){var e;return s(this,(function(n){return e=new vc(t),this._handler.onChannelsDeleted(e,u),[2]}))}))})),u},t.prototype._getLocalChannels=function(){return i(this,void 0,void 0,(function(){return s(this,(function(e){switch(e.label){case 0:return[4,lc.of(this._iid).getChannelsFromCache(this._token,this.filter,this.order)];case 1:return[2,e.sent()]}}))}))},t.prototype._getRemoteChannels=function(){return i(this,void 0,void 0,(function(){var e,t,n;return s(this,(function(i){switch(i.label){case 0:return[4,lc.of(this._iid).getMyGroupChannels(this._token,r(r({},this.filter),{order:this.order}),this._limit)];case 1:return e=i.sent(),t=e.channels,n=e.token,this._token=n,this._hasMore=!!n,[2,t]}}))}))},t.prototype.loadMore=function(){return i(this,void 0,void 0,(function(){var t,n=this;return s(this,(function(r){switch(r.label){case 0:return this._hasMore?(t=[],[4,Pe((function(){return i(n,void 0,void 0,(function(){return s(this,(function(e){switch(e.label){case 0:return[4,this._getLocalChannels()];case 1:return t=e.sent(),[2]}}))}))}))]):[3,3];case 1:return r.sent(),[4,Pe((function(){return i(n,void 0,void 0,(function(){return s(this,(function(e){switch(e.label){case 0:return[4,this._getRemoteChannels()];case 1:return t=e.sent(),[2]}}))}))}))];case 2:return r.sent(),this._addChannelsToView(t,e.GroupChannelEventSource.REQUEST_CHANNEL,!0),[2,t];case 3:return[2,[]]}}))}))},t.prototype.dispose=function(){wt.of(this._iid).cacheContext.localCacheEnabled&&wl.of(this._iid).pause(),Al.of(this._iid).pause(),lc.of(this._iid).unsubscribeGroupChannelEvent(this._key)},t}(),Ol=function(t){function r(n){var r=this,i=n.token,s=n.limit,a=n.order,o=n.includeEmpty,u=n.membershipFilter,c=n.channelNameContainsFilter,l=n.channelUrlsFilter,h=n.customTypesFilter,p=n.customTypeStartsWithFilter,f=n.superChannelFilter,_=n.metadataOrderKeyFilter,v=n.metadataKey,m=n.metadataValues,g=n.metadataValueStartsWith,y=n.includeFrozen,E=n.includeMetaData;return(r=t.call(this)||this).method=d.GET,r.path=ve,r.params=D({token:i,limit:s,order:a,show_member:!0,show_read_receipt:!0,show_delivery_receipt:!0,show_empty:o,public_mode:e.PublicChannelFilter.PUBLIC,public_membership_mode:u,name_contains:c,channel_urls:l,custom_types:h,custom_type_startswith:p,super_mode:f,metadata_order_key:_,metadata_key:v,metadata_values:m,metadata_value_startswith:g,show_frozen:y,show_metadata:E}),r}return n(r,t),r}(x),Rl=function(e){function t(t,n){var r=e.call(this,t,n)||this;r.token=null,r.channels=[],r.ts=null;var i=n.next,s=n.channels,a=n.ts;return r.token=i,s&&s.length>0&&(r.channels=s.map((function(e){return e.ts=a,new Sl(t,e)}))),r.ts="number"==typeof a?a:null,r}return n(t,e),t}(F);e.MembershipFilter=void 0,(Il=e.MembershipFilter||(e.MembershipFilter={})).ALL="all",Il.JOINED="joined";var Ll=function(t){function a(n,r){var i,s,a,o,u,c,l,h,d,p,f,_,v,m,g=this;return(g=t.call(this,n,r)||this).includeEmpty=!1,g.includeFrozen=!0,g.includeMetaData=!0,g.channelUrlsFilter=null,g.customTypesFilter=null,g.customTypeStartsWithFilter=null,g.channelNameContainsFilter=null,g.membershipFilter=e.MembershipFilter.ALL,g.superChannelFilter=e.SuperChannelFilter.ALL,g.metadataKey=null,g.metadataValues=null,g.metadataOrderKeyFilter=null,g.metadataValueStartsWith=null,g.order=e.PublicGroupChannelListOrder.CHRONOLOGICAL,g.includeEmpty=null!==(i=r.includeEmpty)&&void 0!==i&&i,g.includeFrozen=null===(s=r.includeFrozen)||void 0===s||s,g.includeMetaData=null===(a=r.includeMetaData)||void 0===a||a,g.channelUrlsFilter=null!==(o=r.channelUrlsFilter)&&void 0!==o?o:null,g.customTypesFilter=null!==(u=r.customTypesFilter)&&void 0!==u?u:null,g.customTypeStartsWithFilter=null!==(c=r.customTypeStartsWithFilter)&&void 0!==c?c:null,g.channelNameContainsFilter=null!==(l=r.channelNameContainsFilter)&&void 0!==l?l:null,g.membershipFilter=null!==(h=r.membershipFilter)&&void 0!==h?h:e.MembershipFilter.ALL,g.superChannelFilter=null!==(d=r.superChannelFilter)&&void 0!==d?d:e.SuperChannelFilter.ALL,g.metadataKey=null!==(p=r.metadataKey)&&void 0!==p?p:null,g.metadataValues=null!==(f=r.metadataValues)&&void 0!==f?f:null,g.metadataOrderKeyFilter=null!==(_=r.metadataOrderKeyFilter)&&void 0!==_?_:null,g.metadataValueStartsWith=null!==(v=r.metadataValueStartsWith)&&void 0!==v?v:null,g.order=null!==(m=r.order)&&void 0!==m?m:e.PublicGroupChannelListOrder.CHRONOLOGICAL,g}return n(a,t),a.prototype._validate=function(){return t.prototype._validate.call(this)&&g("boolean",this.includeEmpty)&&g("boolean",this.includeFrozen)&&g("boolean",this.includeMetaData)&&g("string",this.channelNameContainsFilter,!0)&&b("string",this.channelUrlsFilter,!0)&&b("string",this.customTypesFilter,!0)&&g("string",this.customTypeStartsWithFilter,!0)&&y(e.MembershipFilter,this.membershipFilter)&&y(e.SuperChannelFilter,this.superChannelFilter)&&y(e.PublicGroupChannelListOrder,this.order)&&g("string",this.metadataOrderKeyFilter,!0)&&g("string",this.metadataKey,!0)&&b("string",this.metadataValues,!0)&&g("string",this.metadataValueStartsWith,!0)},a.prototype.next=function(){return i(this,void 0,void 0,(function(){var t,n,i,a,o,u,c,l,h;return s(this,(function(s){switch(s.label){case 0:return this._validate()?this._isLoading?[3,3]:(t=[],this._hasNext?(this._isLoading=!0,n=wt.of(this._iid),i=n.requestQueue,a=n.dispatcher,o=new Ol(r(r({},this),{token:this._token})),[4,i.send(o)]):[3,2]):[3,5];case 1:return u=s.sent(),c=u.as(Rl),l=c.channels,h=c.token,this._token=h,this._hasNext=!!h,a.dispatch(new iu({channels:l,source:e.GroupChannelEventSource.REQUEST_CHANNEL})),this._isLoading=!1,[2,l];case 2:return[2,t];case 3:throw f.queryInProgress;case 4:return[3,6];case 5:throw f.invalidParameters;case 6:return[2]}}))}))},a}(Fn),kl=function(){this.onUserMuted=J,this.onUserUnmuted=J,this.onUserBanned=J,this.onUserUnbanned=J,this.onChannelChanged=J,this.onChannelDeleted=J,this.onChannelFrozen=J,this.onChannelUnfrozen=J,this.onOperatorUpdated=J,this.onChannelMemberCountChanged=J,this.onMetaDataCreated=J,this.onMetaDataUpdated=J,this.onMetaDataDeleted=J,this.onMetaCounterCreated=J,this.onMetaCounterUpdated=J,this.onMetaCounterDeleted=J,this.onMessageReceived=J,this.onMessageUpdated=J,this.onMessageDeleted=J,this.onMentionReceived=J,this.onReactionUpdated=J,this.onThreadInfoUpdated=J},Dl=function(e){function t(){var t=null!==e&&e.apply(this,arguments)||this;return t.onUserJoined=J,t.onUserLeft=J,t.onUserReceivedInvitation=J,t.onUserDeclinedInvitation=J,t.onChannelHidden=J,t.onUnreadMemberStatusUpdated=J,t.onUndeliveredMemberStatusUpdated=J,t.onTypingStatusUpdated=J,t.onPollUpdated=J,t.onPollVoted=J,t.onPollDeleted=J,t}return n(t,e),t}(kl),Pl=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}(Dl),xl=function(e){function t(t){var n=this,r=t.token,i=t.limit,s=t.order,a=t.reverse,o=t.channelUrl,u=t.messageTypeFilter,c=t.scheduledStatus;return(n=e.call(this)||this).method=d.GET,n.path="".concat(Se),n.params=D({limit:i,reverse:a,channel_url:o,order:s,status:c}),r&&(n.params.token=r),u&&(n.params.message_type=u),n}return n(t,e),t}(x),Fl=function(e){function t(t,n){var r=e.call(this,t,n)||this;r.token=null,r.scheduledMessages=[];var i=n.next,s=n.scheduled_messages;return r.token=i,r.scheduledMessages=s.map((function(e){return sn(t,e)})),r}return n(t,e),t}(F),ql=function(t){function a(n,r){var i,s,a,o,u,c=this;return(c=t.call(this,n,r)||this).channelUrl=null,c.order=null,c.reverse=!1,c.scheduledStatus=null,c.messageTypeFilter=e.MessageTypeFilter.ALL,c.channelUrl=null!==(i=r.channelUrl)&&void 0!==i?i:null,c.order=null!==(s=r.order)&&void 0!==s?s:null,c.reverse=null!==(a=r.reverse)&&void 0!==a&&a,c.scheduledStatus=null!==(o=r.scheduledStatus)&&void 0!==o?o:null,c.messageTypeFilter=null!==(u=r.messageTypeFilter)&&void 0!==u?u:e.MessageTypeFilter.ALL,c}return n(a,t),a.prototype._validate=function(){return t.prototype._validate.call(this)&&g("string",this.channelUrl,!0)&&(y(e.ScheduledMessageListOrder,this.order)||null===this.order)&&g("boolean",this.reverse)&&(b(e.ScheduledStatus,this.scheduledStatus)||null===this.scheduledStatus)&&y(e.MessageTypeFilter,this.messageTypeFilter)},a.prototype.next=function(){return i(this,void 0,void 0,(function(){var e,t,n,i,a,o;return s(this,(function(s){switch(s.label){case 0:return this._validate()?this._isLoading?[3,3]:this._hasNext?(this._isLoading=!0,e=wt.of(this._iid).requestQueue,t=new xl(r(r({},this),{token:this._token})),[4,e.send(t)]):[3,2]:[3,5];case 1:return n=s.sent(),i=n.as(Fl),a=i.scheduledMessages,o=i.token,this._token=o,this._hasNext=!!o,this._isLoading=!1,[2,a];case 2:return[2,[]];case 3:throw f.queryInProgress;case 4:return[3,6];case 5:throw f.invalidParameters;case 6:return[2]}}))}))},a}(Fn),Gl=function(e){function t(){var t=null!==e&&e.apply(this,arguments)||this;return t.name="groupChannel",t}return n(t,e),t.prototype.init=function(t,n){var r=n.sdkState,i=n.dispatcher,s=n.sessionManager,a=n.requestQueue,o=n.logger,u=n.onlineDetector,c=n.cacheContext;e.prototype.init.call(this,t,{sdkState:r,dispatcher:i,sessionManager:s,requestQueue:a,logger:o,onlineDetector:u,cacheContext:c}),this._manager=new lc(t,{sdkState:r,cacheContext:c,dispatcher:i,sessionManager:s,requestQueue:a,logger:o})},t.prototype.createGroupChannelCollection=function(e){return void 0===e&&(e={}),new Ul(this._iid,e)},t.prototype.createMyGroupChannelListQuery=function(e){return void 0===e&&(e={}),new oc(this._iid,e)},t.prototype.createPublicGroupChannelListQuery=function(e){return void 0===e&&(e={}),new Ll(this._iid,e)},t.prototype.createScheduledMessageListQuery=function(e){return void 0===e&&(e={}),new ql(this._iid,e)},t.prototype.addGroupChannelHandler=function(e,t){ct(g("string",e)&&t instanceof Pl).throw(f.invalidParameters),this._manager.addHandler(e,t)},t.prototype.removeGroupChannelHandler=function(e){ct(g("string",e)).throw(f.invalidParameters),this._manager.removeHandler(e)},t.prototype.removeAllGroupChannelHandlers=function(){this._manager.clearHandler()},t.prototype.buildGroupChannelFromSerializedData=function(e){return this._manager.buildGroupChannelFromSerializedData(e)},t.prototype.buildGroupChannelListQueryFromSerializedData=function(e){return this._manager.buildGroupChannelListQueryFromSerializedData(e)},t.prototype.buildMemberFromSerializedData=function(e){return this._manager.buildMemberFromSerializedData(e)},t.prototype.getChannel=function(e){return i(this,void 0,void 0,(function(){return s(this,(function(t){return ct(g("string",e)).throw(f.invalidParameters),[2,this._manager.getChannel(e)]}))}))},t.prototype.getChannelWithoutCache=function(e){return i(this,void 0,void 0,(function(){return s(this,(function(t){return ct(g("string",e)).throw(f.invalidParameters),[2,this._manager.getChannelWithoutCache(e)]}))}))},t.prototype.getMyGroupChannelChangeLogsByToken=function(e,t){return i(this,void 0,void 0,(function(){var n;return s(this,(function(i){switch(i.label){case 0:return n=r(r({},Yo),t),ct(g("string",e)&&Jo(n)).throw(f.invalidParameters),[4,this._manager.getMyGroupChannelChangeLogs(e,n)];case 1:return[2,i.sent()]}}))}))},t.prototype.getMyGroupChannelChangeLogsByTimestamp=function(e,t){return i(this,void 0,void 0,(function(){var n;return s(this,(function(i){switch(i.label){case 0:return n=r(r({},Yo),t),ct(g("number",e)&&Jo(n)).throw(f.invalidParameters),[4,this._manager.getMyGroupChannelChangeLogs(e,n)];case 1:return[2,i.sent()]}}))}))},t.prototype.getGroupChannelCount=function(e){return i(this,void 0,void 0,(function(){var t;return s(this,(function(n){return t=r(r({},Xo),e),ct(Zo(t)).throw(f.invalidParameters),[2,this._manager.getGroupChannelCount(t)]}))}))},t.prototype.getUnreadItemCount=function(e){return void 0===e&&(e={}),i(this,void 0,void 0,(function(){return s(this,(function(t){switch(t.label){case 0:return[4,this._manager.getUnreadItemCount(e)];case 1:return[2,t.sent()]}}))}))},t.prototype.getTotalUnreadChannelCount=function(){return i(this,void 0,void 0,(function(){return s(this,(function(e){switch(e.label){case 0:return[4,this._manager.getTotalUnreadChannelCount()];case 1:return[2,e.sent()]}}))}))},t.prototype.getTotalUnreadMessageCount=function(e){return void 0===e&&(e={}),i(this,void 0,void 0,(function(){return s(this,(function(t){switch(t.label){case 0:return[4,this._manager.getTotalUnreadMessageCount(e)];case 1:return[2,t.sent()]}}))}))},t.prototype.getTotalScheduledMessageCount=function(e){return void 0===e&&(e={}),i(this,void 0,void 0,(function(){return s(this,(function(t){switch(t.label){case 0:return[4,this._manager.getTotalScheduledMessageCount(e)];case 1:return[2,t.sent()]}}))}))},t.prototype.getSubscribedTotalUnreadMessageCount=function(){return this._manager.getSubscribedTotalUnreadMessageCount()},t.prototype.getSubscribedCustomTypeTotalUnreadMessageCount=function(){return this._manager.getSubscribedCustomTypeTotalUnreadMessageCount()},t.prototype.getSubscribedCustomTypeUnreadMessageCount=function(e){return this._manager.getSubscribedCustomTypeUnreadMessageCount(e)},t.prototype.createChannel=function(e){return void 0===e&&(e={}),i(this,void 0,void 0,(function(){var t;return s(this,(function(n){return t=r(r({},zo),e),ct(Wo(t)).throw(f.invalidParameters),[2,this._manager.createChannel(t)]}))}))},t.prototype.createDistinctChannelIfNotExist=function(e){return void 0===e&&(e={}),i(this,void 0,void 0,(function(){var t;return s(this,(function(n){return t=r(r({},zo),e),ct(Wo(t)).throw(f.invalidParameters),t&&(t.isDistinct=!0),[2,this.createChannel(t)]}))}))},t.prototype.createChannelWithUserIds=function(e,t,n,a,o,u){return void 0===t&&(t=!1),void 0===n&&(n=null),void 0===a&&(a=null),void 0===o&&(o=""),void 0===u&&(u=""),i(this,void 0,void 0,(function(){var i;return s(this,(function(s){return i=r(r({},zo),{invitedUserIds:e,isDistinct:t,name:n,data:o,customType:u}),"string"==typeof a?i.coverUrl=a:i.coverImage=a,[2,this.createChannel(i)]}))}))},t.prototype.markAsReadAll=function(){return i(this,void 0,void 0,(function(){return s(this,(function(e){return this._manager.markAsReadAll(),[2]}))}))},t.prototype.markAsReadWithChannelUrls=function(e){return i(this,void 0,void 0,(function(){return s(this,(function(t){return ct(b("string",e)).throw(f.invalidParameters),this._manager.markAsReadWithChannelUrls(e),[2]}))}))},t.prototype.markAsDelivered=function(e){return i(this,void 0,void 0,(function(){return s(this,(function(t){switch(t.label){case 0:return ct(g("string",e)).throw(f.invalidParameters),[4,this.getChannel(e)];case 1:return[4,t.sent().markAsDelivered()];case 2:return t.sent(),[2]}}))}))},t}(At),Hl=function(e){function t(){var t=null!==e&&e.apply(this,arguments)||this;return t._channels=new Map,t._enteredChannelUrls=[],t}return n(t,e),Object.defineProperty(t.prototype,"enteredChannels",{get:function(){var e=this;return this._enteredChannelUrls.map((function(t){return e._channels.get(t)})).filter((function(e){return null!==e}))},enumerable:!1,configurable:!0}),t.prototype.isEnteredChannel=function(e){return this._enteredChannelUrls.includes(e)},t.prototype.enter=function(e){this._enteredChannelUrls.indexOf(e)<0&&this._enteredChannelUrls.push(e)},t.prototype.exit=function(e){var t=this._enteredChannelUrls.indexOf(e);t>=0&&this._enteredChannelUrls.splice(t,1)},t.prototype.exitAll=function(){this._enteredChannelUrls=[]},t.prototype.get=function(e){var t;return i(this,void 0,void 0,(function(){return s(this,(function(n){return[2,null!==(t=this._channels.get(e))&&void 0!==t?t:null]}))}))},t.prototype.upsert=function(e){return i(this,void 0,void 0,(function(){var t=this;return s(this,(function(n){return e.forEach((function(e){if(t._channels.has(e.url)){var n=t._channels.get(e.url);Object.assign(n,e)}else t._channels.set(e.url,e)})),[2]}))}))},t.prototype.remove=function(e){return i(this,void 0,void 0,(function(){return s(this,(function(t){return this._channels.delete(e),this.exit(e),[2]}))}))},t.prototype.clear=function(){return i(this,void 0,void 0,(function(){return s(this,(function(e){return this._channels.clear(),this._enteredChannelUrls=[],[2]}))}))},t}(We),Vl={channelUrl:null,name:null,coverUrlOrImage:null,data:null,customType:null,operatorUserIds:null},Kl=function(e){function t(t){var n=t.channelUrl,r=t.isInternalCall,i=e.call(this)||this;return i.method=d.GET,i.path="".concat(r?ye:ge,"/").concat(encodeURIComponent(n)),i}return n(t,e),t}(x),Ql=function(e){function t(t,n){var r=e.call(this,t,n)||this;return r.channel=null,r.channel=new sh(t,n),r}return n(t,e),t}(F),Bl=function(e){function t(t){var n=this,r=t.channelUrl,i=t.coverUrlOrImage,s=t.name,a=t.data,o=t.customType,u=t.operatorUserIds;return(n=e.call(this)||this).method=d.POST,n.path=ge,n.params=D({channel_url:r,cover_url:g("string",i)?i:null,cover_file:T(i)?i:null,name:s,data:a,custom_type:o,operators:u}),n}return n(t,e),t}(x);!function(e){function t(t,n){var r=e.call(this,t,n)||this;return r.channel=new sh(t,n),r}n(t,e)}(F);var jl=function(e){function t(t){var n=t.channelUrl;return e.call(this,{code:"ENTR",payload:{channel_url:n},ackRequired:!0})||this}return n(t,e),t}(z),zl=function(e){function t(t,n,r){var i,s,a=this;return a=e.call(this,t,"ENTR",r)||this,r.data&&(a.participantCount=null!==(i=r.data.participant_count)&&void 0!==i?i:0,a.user=new ht(t,r.data),a.ts=null!==(s=r.data.edge_ts)&&void 0!==s?s:0),a}return n(t,e),t}(j),Wl=function(e){function t(t){var n=t.channelUrl;return e.call(this,{code:"EXIT",payload:{channel_url:n},ackRequired:!0})||this}return n(t,e),t}(z),Yl=function(e){function t(t,n,r){var i,s,a=this;return a=e.call(this,t,"EXIT",r)||this,r.data&&(a.participantCount=null!==(i=r.data.participant_count)&&void 0!==i?i:0,a.user=new ht(t,r.data),a.ts=null!==(s=r.data.edge_ts)&&void 0!==s?s:0),a}return n(t,e),t}(j),Jl={},Xl=function(){function t(e,t){var n=t.sdkState,r=t.dispatcher,i=t.requestQueue,s=this;this._sdkState=n,this._requestQueue=i,this._dispatcher=r,this._openChannelCache=new Hl(e),this._openChannelHandlers=new Map,this._dispatcher.on((function(e){var t,n;if(e instanceof j)s._handleEvent(e);else if(e instanceof he&&e.stateType===X.CONNECTED){var r=s._openChannelCache.enteredChannels;try{for(var i=a(r),o=i.next();!o.done;o=i.next()){o.value.enter()}}catch(e){t={error:e}}finally{try{o&&!o.done&&(n=i.return)&&n.call(i)}finally{if(t)throw t.error}}}})),Jl[e]=this}return t.of=function(e){return Jl[e]},t.prototype.buildOpenChannelFromSerializedData=function(e){var t=ut(e);return new sh(t._iid,sh.payloadify(t))},t.prototype.getChannelFromCache=function(e){return i(this,void 0,void 0,(function(){return s(this,(function(t){switch(t.label){case 0:return[4,this._openChannelCache.get(e)];case 1:return[2,t.sent()]}}))}))},t.prototype.upsertChannelsToCache=function(e){return i(this,void 0,void 0,(function(){return s(this,(function(t){switch(t.label){case 0:return[4,this._openChannelCache.upsert(e)];case 1:return t.sent(),[2]}}))}))},t.prototype.removeChannelsFromCache=function(e){return i(this,void 0,void 0,(function(){var t,n,r,i,o,u;return s(this,(function(s){switch(s.label){case 0:s.trys.push([0,5,6,7]),t=a(e),n=t.next(),s.label=1;case 1:return n.done?[3,4]:(r=n.value,[4,this._openChannelCache.remove(r)]);case 2:s.sent(),s.label=3;case 3:return n=t.next(),[3,1];case 4:return[3,7];case 5:return i=s.sent(),o={error:i},[3,7];case 6:try{n&&!n.done&&(u=t.return)&&u.call(t)}finally{if(o)throw o.error}return[7];case 7:return[2]}}))}))},t.prototype.setEnteredToCache=function(e){this._openChannelCache.enter(e.url)},t.prototype.setExitedToCache=function(e){this._openChannelCache.exit(e.url)},t.prototype._handleEvent=function(t){return i(this,void 0,void 0,(function(){var n,r,o,u,c,l,h,d,f,_,v,m,g,y,E,b,C,T,I,S,N,w,M,A,U,O,R,L,k,D,P,x,F,q,G,H,V,K,Q,B,j,z,W,Y,J,X,Z,$,ee,te,ne,re,ie,se,ae,oe,ue,ce,le,he=this;return s(this,(function(de){switch(de.label){case 0:switch(de.trys.push([0,51,,52]),t.code){case"MESG":case"FILE":case"ADMM":case"BRDM":return[3,1];case"MEDI":case"FEDI":case"AEDI":return[3,4];case"DELM":return[3,7];case"MRCT":return[3,10];case"MTHD":return[3,13];case"MCNT":return[3,16];case"SYEV":return[3,27]}return[3,50];case 1:return u=null,"MESG"===t.code?u=t.as(lo):"FILE"===t.code?u=t.as(cn):"ADMM"!==t.code&&"BRDM"!=t.code||(u=t.as(tc)),u?(n=u.message,r=u.isMentioned,n.channelType!==e.ChannelType.OPEN?[3,3]:[4,this.getChannel(n.channelUrl,!0)]):[3,3];case 2:o=de.sent(),De((function(){return i(he,void 0,void 0,(function(){var e,t,i,u,c;return s(this,(function(s){try{for(e=a(this._openChannelHandlers.values()),t=e.next();!t.done;t=e.next())i=t.value,this._openChannelCache.isEnteredChannel(o.url)&&i.onMessageReceived(o,n),r&&i.onMentionReceived(o,n)}catch(e){u={error:e}}finally{try{t&&!t.done&&(c=e.return)&&c.call(e)}finally{if(u)throw u.error}}return[2]}))}))})),de.label=3;case 3:return[3,50];case 4:return u=null,"MEDI"===t.code?u=t.as(po):"FEDI"===t.code?u=t.as(_o):"AEDI"===t.code&&(u=t.as(nc)),u?(c=u.message).channelType!==e.ChannelType.OPEN?[3,6]:[4,this.getChannel(c.channelUrl,!0)]:[3,6];case 5:l=de.sent(),De((function(){return i(he,void 0,void 0,(function(){var e,t,n,r,i;return s(this,(function(s){try{for(e=a(this._openChannelHandlers.values()),t=e.next();!t.done;t=e.next())n=t.value,this._openChannelCache.isEnteredChannel(l.url)&&n.onMessageUpdated(l,c)}catch(e){r={error:e}}finally{try{t&&!t.done&&(i=e.return)&&i.call(e)}finally{if(r)throw r.error}}return[2]}))}))})),de.label=6;case 6:return[3,50];case 7:return h=t.as(go),N=h.channelUrl,v=h.channelType,d=h.messageId,v!==e.ChannelType.OPEN?[3,9]:[4,this.getChannel(N,!0)];case 8:f=de.sent(),De((function(){return i(he,void 0,void 0,(function(){var e,t,n,r,i;return s(this,(function(s){try{for(e=a(this._openChannelHandlers.values()),t=e.next();!t.done;t=e.next())n=t.value,this._openChannelCache.isEnteredChannel(f.url)&&n.onMessageDeleted(f,d)}catch(e){r={error:e}}finally{try{t&&!t.done&&(i=e.return)&&i.call(e)}finally{if(r)throw r.error}}return[2]}))}))})),de.label=9;case 9:return[3,50];case 10:return _=t.as(rc),N=_.channelUrl,v=_.channelType,m=_.event,v!==e.ChannelType.OPEN?[3,12]:[4,this.getChannel(N,!0)];case 11:g=de.sent(),De((function(){return i(he,void 0,void 0,(function(){var e,t,n,r;return s(this,(function(i){try{for(e=a(this._openChannelHandlers.values()),t=e.next();!t.done;t=e.next())t.value.onReactionUpdated(g,m)}catch(e){n={error:e}}finally{try{t&&!t.done&&(r=e.return)&&r.call(e)}finally{if(n)throw n.error}}return[2]}))}))})),de.label=12;case 12:return[3,50];case 13:return(y=t.as(ic).event).channelType!==e.ChannelType.OPEN?[3,15]:[4,this.getChannel(y.channelUrl,!0)];case 14:E=de.sent(),De((function(){return i(he,void 0,void 0,(function(){var e,t,n,r;return s(this,(function(i){try{for(e=a(this._openChannelHandlers.values()),t=e.next();!t.done;t=e.next())t.value.onThreadInfoUpdated(E,y)}catch(e){n={error:e}}finally{try{t&&!t.done&&(r=e.return)&&r.call(e)}finally{if(n)throw n.error}}return[2]}))}))})),de.label=15;case 15:return[3,50];case 16:b=t.as($u).openChannelMemberCounts,C=[],de.label=17;case 17:de.trys.push([17,22,23,24]),T=a(b),I=T.next(),de.label=18;case 18:return I.done?[3,21]:(S=I.value,N=S.channelUrl,x=S.participantCount,w=S.updatedAt,[4,this.getChannelFromCache(N)]);case 19:(M=de.sent())&&M._updateParticipantCount(x,w)&&C.push(M),de.label=20;case 20:return I=T.next(),[3,18];case 21:return[3,24];case 22:return A=de.sent(),ce={error:A},[3,24];case 23:try{I&&!I.done&&(le=T.return)&&le.call(T)}finally{if(ce)throw ce.error}return[7];case 24:return C.length>0?[4,this.upsertChannelsToCache(C)]:[3,26];case 25:de.sent(),De((function(){return i(he,void 0,void 0,(function(){var e,t,n,r;return s(this,(function(i){try{for(e=a(this._openChannelHandlers.values()),t=e.next();!t.done;t=e.next())t.value.onChannelMemberCountChanged(C)}catch(e){n={error:e}}finally{try{t&&!t.done&&(r=e.return)&&r.call(e)}finally{if(n)throw n.error}}return[2]}))}))})),de.label=26;case 26:return[3,50];case 27:if(!(U=t.as(Mu).event).isOpenChannelEvent)return[3,49];switch(U.category){case Vo.CHANNEL_ENTER:return[3,28];case Vo.CHANNEL_EXIT:return[3,30];case Vo.CHANNEL_OPERATOR_UPDATE:return[3,32];case Vo.USER_CHANNEL_MUTE:case Vo.USER_CHANNEL_UNMUTE:return[3,34];case Vo.USER_CHANNEL_BAN:case Vo.USER_CHANNEL_UNBAN:return[3,36];case Vo.CHANNEL_FREEZE:case Vo.CHANNEL_UNFREEZE:return[3,38];case Vo.CHANNEL_DELETED:return[3,40];case Vo.CHANNEL_PROP_CHANGED:return[3,43];case Vo.CHANNEL_META_DATA_CHANGED:return[3,45];case Vo.CHANNEL_META_COUNTERS_CHANGED:return[3,47]}return[3,49];case 28:return[4,this.getChannel(U.channelUrl,!0)];case 29:return O=de.sent(),R=t.as(zl),x=R.participantCount,L=R.user,k=O._updateParticipantCount(x,U.ts),De((function(){return i(he,void 0,void 0,(function(){return s(this,(function(e){return this._openChannelHandlers.forEach((function(e){e.onUserEntered(O,L),k&&e.onChannelParticipantCountChanged(O)})),[2]}))}))})),[3,49];case 30:return[4,this.getChannel(U.channelUrl,!0)];case 31:return D=de.sent(),P=t.as(Yl),x=P.participantCount,F=P.user,q=D._updateParticipantCount(x,U.ts),De((function(){return i(he,void 0,void 0,(function(){return s(this,(function(e){return this._openChannelHandlers.forEach((function(e){e.onUserExited(D,F),q&&e.onChannelParticipantCountChanged(D)})),[2]}))}))})),[3,49];case 32:return[4,this.getChannel(U.channelUrl,!0)];case 33:return G=de.sent(),H=t.as(Zu).operators,G.operators=H,this.upsertChannelsToCache([G]),De((function(){return i(he,void 0,void 0,(function(){return s(this,(function(e){return this._openChannelHandlers.forEach((function(e){e.onOperatorUpdated(G,H)})),[2]}))}))})),[3,49];case 34:return[4,this.getChannel(U.channelUrl,!0)];case 35:return V=de.sent(),K=U.category===Vo.USER_CHANNEL_MUTE,Q=t.as(K?Xa:$a).user,De((function(){return i(he,void 0,void 0,(function(){return s(this,(function(e){return this._openChannelHandlers.forEach((function(e){K?e.onUserMuted(V,Q):e.onUserUnmuted(V,Q)})),[2]}))}))})),[3,49];case 36:return[4,this.getChannel(U.channelUrl,!0)];case 37:return B=de.sent(),j=U.category===Vo.USER_CHANNEL_BAN,z=t.as(j?to:ro).user,De((function(){return i(he,void 0,void 0,(function(){return s(this,(function(e){return this._openChannelHandlers.forEach((function(e){j?e.onUserBanned(B,z):e.onUserUnbanned(B,z)})),[2]}))}))})),[3,49];case 38:return[4,this.getChannel(U.channelUrl,!0)];case 39:return W=de.sent(),Y=t.as(so).freeze,W.isFrozen=Y,this.upsertChannelsToCache([W]),De((function(){return i(he,void 0,void 0,(function(){return s(this,(function(e){return this._openChannelHandlers.forEach((function(e){Y?e.onChannelFrozen(W):e.onChannelUnfrozen(W)})),[2]}))}))})),[3,49];case 40:return[4,this.getChannel(U.channelUrl,!0)];case 41:return J=de.sent(),[4,this.removeChannelsFromCache([J.url])];case 42:return de.sent(),De((function(){return i(he,void 0,void 0,(function(){return s(this,(function(e){return this._openChannelHandlers.forEach((function(e){e.onChannelDeleted(J.url,J.channelType)})),[2]}))}))})),[3,49];case 43:return[4,this.getChannelWithoutCache(U.channelUrl,!0)];case 44:return X=de.sent(),De((function(){return i(he,void 0,void 0,(function(){return s(this,(function(e){return this._openChannelHandlers.forEach((function(e){e.onChannelChanged(X)})),[2]}))}))})),[3,49];case 45:return[4,this.getChannel(U.channelUrl,!0)];case 46:return Z=de.sent(),$=t.as(Pa),ee=$.created,te=$.updated,ne=$.deleted,ee&&Z._upsertCachedMetaData(ee,U.ts),te&&Z._upsertCachedMetaData(te,U.ts),ne&&Z._removeFromCachedMetaData(ne,U.ts),De((function(){return i(he,void 0,void 0,(function(){return s(this,(function(e){return this._openChannelHandlers.forEach((function(e){ee&&e.onMetaDataCreated(Z,ee),te&&e.onMetaDataUpdated(Z,te),ne&&e.onMetaDataDeleted(Z,ne)})),[2]}))}))})),[3,49];case 47:return[4,this.getChannel(U.channelUrl,!0)];case 48:return re=de.sent(),ie=t.as(za),se=ie.created,ae=ie.updated,oe=ie.deleted,De((function(){return i(he,void 0,void 0,(function(){return s(this,(function(e){return this._openChannelHandlers.forEach((function(e){se&&e.onMetaCounterCreated(re,se),ae&&e.onMetaCounterUpdated(re,ae),oe&&e.onMetaCounterDeleted(re,oe)})),[2]}))}))})),[3,49];case 49:return[3,50];case 50:return[3,52];case 51:if(ue=de.sent(),p(ue))throw ue;return[3,52];case 52:return[2]}}))}))},t.prototype.addHandler=function(e,t){this._openChannelHandlers.set(e,t)},t.prototype.removeHandler=function(e){this._openChannelHandlers.delete(e)},t.prototype.clearHandler=function(){this._openChannelHandlers.clear()},t.prototype.getChannel=function(e,t){return i(this,void 0,void 0,(function(){var t;return s(this,(function(n){switch(n.label){case 0:ct(g("string",e)).throw(f.invalidParameters),n.label=1;case 1:return n.trys.push([1,3,,4]),[4,this.getChannelFromCache(e)];case 2:return(t=n.sent())?[2,t]:[3,4];case 3:return n.sent(),[3,4];case 4:return[4,this.getChannelWithoutCache(e)];case 5:return[2,n.sent()]}}))}))},t.prototype.getChannelWithoutCache=function(e,t){return void 0===t&&(t=!1),i(this,void 0,void 0,(function(){var n,r,i;return s(this,(function(s){switch(s.label){case 0:return ct(g("string",e)).throw(f.invalidParameters),n=new Kl({channelUrl:e,isInternalCall:t}),[4,this._requestQueue.send(n)];case 1:return r=s.sent(),i=r.as(Ql).channel,[4,this.upsertChannelsToCache([i])];case 2:return s.sent(),[2,i]}}))}))},t.prototype.createChannel=function(e){return i(this,void 0,void 0,(function(){var t,n,i,a;return s(this,(function(s){switch(s.label){case 0:return t=r(r({},Vl),e),ct(function(e){return b("string",e.operatorUserIds,!0)&&(g("string",e.coverUrlOrImage)||T(e.coverUrlOrImage)||null===e.coverUrlOrImage)&&g("string",e.name,!0)&&g("string",e.data,!0)&&g("string",e.customType,!0)&&(g("string",e.channelUrl)&&/^\w+$/.test(e.channelUrl)||null===e.channelUrl)}(t)).throw(f.invalidParameters),n=new Bl(t),[4,this._requestQueue.send(n)];case 1:return i=s.sent(),a=i.as(Ql).channel,this.upsertChannelsToCache([a]),[2,a]}}))}))},t}(),Zl={name:null,coverUrlOrImage:null,data:null,customType:null,operatorUserIds:null},$l=function(e){function t(t){var n=this,r=t.channelUrl,i=t.token,s=t.limit;return(n=e.call(this)||this).method=d.GET,n.path="".concat(ge,"/").concat(encodeURIComponent(r),"/participants"),n.params={token:i,limit:s},n}return n(t,e),t}(x),eh=function(e){function t(t,n){var r=e.call(this,t,n)||this;r.token=null,r.participants=[];var i=n.next,s=n.participants;return r.token=i,r.participants=s.map((function(e){return new ht(t,e)})),r}return n(t,e),t}(F),th=function(t){function a(n,r,i){return t.call(this,n,r,e.ChannelType.OPEN,i)||this}return n(a,t),a.prototype._validate=function(){return t.prototype._validate.call(this)},a.prototype.next=function(){return i(this,void 0,void 0,(function(){var e,t,n,i,a,o;return s(this,(function(s){switch(s.label){case 0:return this._validate()?this._isLoading?[3,3]:this._hasNext?(this._isLoading=!0,e=wt.of(this._iid).requestQueue,t=new $l(r(r({},this),{token:this._token})),[4,e.send(t)]):[3,2]:[3,5];case 1:return n=s.sent(),i=n.as(eh),a=i.participants,o=i.token,this._token=o,this._hasNext=!!o,this._isLoading=!1,[2,a];case 2:return[2,[]];case 3:throw f.queryInProgress;case 4:return[3,6];case 5:throw f.invalidParameters;case 6:return[2]}}))}))},a}(Bn),nh=function(e){function t(t){var n=this,r=t.channelUrl,i=t.coverUrlOrImage,s=t.name,a=t.data,o=t.customType,u=t.operatorUserIds;return(n=e.call(this)||this).method=d.PUT,n.path="".concat(ge,"/").concat(encodeURIComponent(r)),n.params=D({cover_url:g("string",i)?i:null,cover_file:T(i)?i:null,name:s,data:a,custom_type:o,operators:u}),n}return n(t,e),t}(x),rh=function(e){function t(t,n){var r=e.call(this,t,n)||this;return r.channel=new sh(t,n),r}return n(t,e),t}(F),ih=function(e){function t(t){var n=this,r=t.channelUrl;return(n=e.call(this)||this).method=d.DELETE,n.path="".concat(ge,"/").concat(encodeURIComponent(r)),n}return n(t,e),t}(x);!function(e){function t(t,n){return e.call(this,t,n)||this}n(t,e)}(F);var sh=function(t){function a(n,r){var i,s=this;return(s=t.call(this,n,r)||this)._lastParticipantCountUpdated=0,s.participantCount=0,s.operators=[],s.channelType=e.ChannelType.OPEN,s.participantCount=null!==(i=r.participant_count)&&void 0!==i?i:0,s.operators=Array.isArray(r.operators)?r.operators.map((function(e){return new ht(n,e)})):[],s}return n(a,t),a.payloadify=function(e){return e?D(r(r({},Ao.payloadify(e)),{participant_count:e.participantCount,operators:e.operators.map((function(e){return ht.payloadify(e)}))})):null},a.prototype.serialize=function(){return ot(this)},a.prototype.isOperator=function(e){return e instanceof ht?this.isOperator(e.userId):this.operators.some((function(t){return t.userId===e}))},a.prototype._updateParticipantCount=function(e,t){return t>this._lastParticipantCountUpdated&&(this.participantCount=e,this._lastParticipantCountUpdated=t,!0)},a.prototype.createParticipantListQuery=function(e){return new th(this._iid,this.url,e)},a.prototype.refresh=function(){return i(this,void 0,void 0,(function(){return s(this,(function(e){switch(e.label){case 0:return[4,Xl.of(this._iid).getChannelWithoutCache(this.url)];case 1:return[2,e.sent()]}}))}))},a.prototype.enter=function(){return i(this,void 0,void 0,(function(){var e,t,n,r,i,a;return s(this,(function(s){switch(s.label){case 0:return e=wt.of(this._iid).requestQueue,t=new jl({channelUrl:this.url}),[4,e.send(t)];case 1:return n=s.sent(),r=n.as(zl),i=r.participantCount,a=r.ts,this._updateParticipantCount(i,a),Xl.of(this._iid).setEnteredToCache(this),[2]}}))}))},a.prototype.exit=function(){return i(this,void 0,void 0,(function(){var e,t,n,r,i,a;return s(this,(function(s){switch(s.label){case 0:return e=wt.of(this._iid).requestQueue,t=new Wl({channelUrl:this.url}),[4,e.send(t)];case 1:return n=s.sent(),r=n.as(Yl),i=r.participantCount,a=r.ts,this._updateParticipantCount(i,a),Xl.of(this._iid).setExitedToCache(this),kn.of(this._iid).fileMessageQueue.cancel(this),[2]}}))}))},a.prototype.updateChannel=function(e){return i(this,void 0,void 0,(function(){var t,n,i,a,o;return s(this,(function(s){switch(s.label){case 0:return t=r(r({},Zl),e),ct(function(e){return b("string",e.operatorUserIds,!0)&&(g("string",e.coverUrlOrImage)||T(e.coverUrlOrImage)||null===e.coverUrlOrImage)&&g("string",e.name,!0)&&g("string",e.data,!0)&&g("string",e.customType,!0)}(t)).throw(f.invalidParameters),n=wt.of(this._iid).requestQueue,i=new nh(r({channelUrl:this.url},t)),[4,n.send(i)];case 1:return a=s.sent(),o=a.as(rh).channel,[4,Xl.of(this._iid).upsertChannelsToCache([o])];case 2:return s.sent(),[2,o]}}))}))},a.prototype.updateChannelWithOperatorUserIds=function(e,t,n,a,o){return i(this,void 0,void 0,(function(){var i;return s(this,(function(s){return i=r(r({},Zl),{name:e,coverUrlOrImage:t,data:n,operatorUserIds:a,customType:o}),[2,this.updateChannel(i)]}))}))},a.prototype.delete=function(){return i(this,void 0,void 0,(function(){var e,t;return s(this,(function(n){switch(n.label){case 0:return e=wt.of(this._iid).requestQueue,t=new ih({channelUrl:this.url}),[4,e.send(t)];case 1:return n.sent(),[4,Xl.of(this._iid).removeChannelsFromCache([this.url])];case 2:return n.sent(),[2]}}))}))},a}(Ao),ah=function(e){function t(){var t=null!==e&&e.apply(this,arguments)||this;return t.onUserEntered=J,t.onUserExited=J,t.onChannelParticipantCountChanged=J,t}return n(t,e),t}(kl),oh=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}(ah),uh=function(e){function t(t){var n=this,r=t.token,i=t.limit,s=t.nameKeyword,a=t.urlKeyword,o=t.customTypes,u=t.includeFrozen,c=t.includeMetaData;return(n=e.call(this)||this).method=d.GET,n.path=ge,n.params=D({token:r,limit:i,name_contains:s,url_contains:a,custom_types:o,show_frozen:u,show_metadata:c}),n}return n(t,e),t}(x),ch=function(e){function t(t,n){var r=e.call(this,t,n)||this;r.token=null,r.channels=[],r.ts=null;var i=n.next,s=n.channels,a=n.ts;return r.token=i,s&&s.length>0&&(r.channels=s.map((function(e){return new sh(t,e)}))),r.ts="number"==typeof a?a:null,r}return n(t,e),t}(F),lh=function(e){function t(t,n){var r,i,s,a,o,u=this;return(u=e.call(this,t,n)||this).includeFrozen=!0,u.includeMetaData=!0,u.nameKeyword=null,u.urlKeyword=null,u.customTypes=null,u.includeFrozen=null===(r=n.includeFrozen)||void 0===r||r,u.includeMetaData=null===(i=n.includeMetaData)||void 0===i||i,u.nameKeyword=null!==(s=n.nameKeyword)&&void 0!==s?s:null,u.urlKeyword=null!==(a=n.urlKeyword)&&void 0!==a?a:null,u.customTypes=null!==(o=n.customTypes)&&void 0!==o?o:null,u}return n(t,e),t.prototype._validate=function(){return e.prototype._validate.call(this)&&g("boolean",this.includeFrozen)&&g("boolean",this.includeMetaData)&&g("string",this.nameKeyword,!0)&&g("string",this.urlKeyword,!0)&&b("string",this.customTypes,!0)},t.prototype.next=function(){return i(this,void 0,void 0,(function(){var e,t,n,i,a,o;return s(this,(function(s){switch(s.label){case 0:return this._validate()?this._isLoading?[3,4]:this._hasNext?(this._isLoading=!0,e=wt.of(this._iid).requestQueue,t=new uh(r(r({},this),{token:this._token})),[4,e.send(t)]):[3,3]:[3,6];case 1:return n=s.sent(),i=n.as(ch),a=i.channels,o=i.token,this._token=o,this._hasNext=!!o,[4,Xl.of(this._iid).upsertChannelsToCache(a)];case 2:return s.sent(),this._isLoading=!1,[2,a];case 3:return[2,[]];case 4:throw f.queryInProgress;case 5:return[3,7];case 6:throw f.invalidParameters;case 7:return[2]}}))}))},t}(Fn),hh=function(e){function t(){var t=null!==e&&e.apply(this,arguments)||this;return t.name="openChannel",t}return n(t,e),t.prototype.init=function(t,n){var r=n.sdkState,i=n.dispatcher,s=n.sessionManager,a=n.requestQueue,o=n.logger,u=n.onlineDetector,c=n.cacheContext;e.prototype.init.call(this,t,{sdkState:r,dispatcher:i,sessionManager:s,requestQueue:a,logger:o,onlineDetector:u,cacheContext:c}),this._manager=new Xl(t,{sdkState:r,dispatcher:i,requestQueue:a})},t.prototype.createOpenChannelListQuery=function(e){return void 0===e&&(e={}),new lh(this._iid,e)},t.prototype.addOpenChannelHandler=function(e,t){this._manager.addHandler(e,t)},t.prototype.removeOpenChannelHandler=function(e){this._manager.removeHandler(e)},t.prototype.removeAllOpenChannelHandlers=function(){this._manager.clearHandler()},t.prototype.buildOpenChannelFromSerializedData=function(e){return this._manager.buildOpenChannelFromSerializedData(e)},t.prototype.getChannel=function(e){return i(this,void 0,void 0,(function(){return s(this,(function(t){return[2,this._manager.getChannel(e)]}))}))},t.prototype.getChannelWithoutCache=function(e){return i(this,void 0,void 0,(function(){return s(this,(function(t){return[2,this._manager.getChannelWithoutCache(e)]}))}))},t.prototype.createChannel=function(e){return void 0===e&&(e={}),i(this,void 0,void 0,(function(){return s(this,(function(t){return[2,this._manager.createChannel(e)]}))}))},t.prototype.createChannelWithOperatorUserIds=function(e,t,n,a,o){return i(this,void 0,void 0,(function(){var i;return s(this,(function(s){return(i=r({},Vl)).name=e,i.coverUrlOrImage=t,i.data=n,i.operatorUserIds=a,i.customType=o,[2,this._manager.createChannel(i)]}))}))},t}(At);return e.AdminMessage=Yt,e.AppleCriticalAlertOptions=Gt,e.ApplicationUserListQuery=is,e.BannedUserListQuery=wa,e.BaseChannel=Ao,e.BaseMessage=Kt,e.BlockedUserListQuery=os,e.ConnectionHandler=Cr,e.Emoji=zi,e.EmojiCategory=Wi,e.EmojiContainer=Yi,e.FileMessage=an,e.FriendListQuery=ls,e.GroupChannel=Sl,e.GroupChannelCollection=Ul,e.GroupChannelEventContext=vc,e.GroupChannelFilter=Ko,e.GroupChannelHandler=Pl,e.GroupChannelListQuery=oc,e.GroupChannelModule=Gl,e.Member=Go,e.MemberListQuery=Vc,e.MemoryStore=na,e.MessageCollection=xc,e.MessageCollectionInitHandler=Pc,e.MessageEventContext=mc,e.MessageFilter=Mr,e.MessageMetaArray=xt,e.MessageModule=Wn,e.MessageRequestHandler=Dn,e.MessageSearchQuery=Qn,e.MutedUserListQuery=Ia,e.OGImage=Ft,e.OGMetaData=qt,e.OpenChannel=sh,e.OpenChannelHandler=oh,e.OpenChannelListQuery=lh,e.OpenChannelModule=hh,e.OperatorListQuery=ba,e.ParticipantListQuery=th,e.Plugin=Jt,e.PreviousMessageListQuery=jn,e.PublicGroupChannelListQuery=Ll,e.Reaction=Pt,e.ReactionEvent=Dt,e.ReadStatus=Ho,e.RestrictedUser=pa,e.RestrictionInfo=da,e.ScheduledMessageListQuery=ql,e.SendbirdChat=Oo,e.SendbirdChatOptions=I,e.SendbirdError=f,e.Sender=Qt,e.SessionHandler=br,e.ThreadInfo=Rt,e.ThreadInfoUpdateEvent=Pn,e.Thumbnail=jt,e.User=ht,e.UserEventHandler=Tr,e.UserMessage=nn,Object.defineProperty(e,"__esModule",{value:!0}),e}({}); +var Sendbird=function(e){"use strict";var t=function(e,n){return t=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])},t(e,n)};function n(e,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=e}t(e,n),e.prototype=null===n?Object.create(n):(r.prototype=n.prototype,new r)}var r=function(){return r=Object.assign||function(e){for(var t,n=1,r=arguments.length;n0&&i[i.length-1])||6!==s[0]&&2!==s[0])){a=0;continue}if(3===s[0]&&(!i||s[1]>i[0]&&s[1]=e.length&&(e=void 0),{value:e&&e[r++],done:!e}}};throw new TypeError(t?"Object is not iterable.":"Symbol.iterator is not defined.")}function o(e,t){var n="function"==typeof Symbol&&e[Symbol.iterator];if(!n)return e;var r,i,s=n.call(e),a=[];try{for(;(void 0===t||t-- >0)&&!(r=s.next()).done;)a.push(r.value)}catch(e){i={error:e}}finally{try{r&&!r.done&&(n=s.return)&&n.call(s)}finally{if(i)throw i.error}}return a}function u(e,t,n){if(n||2===arguments.length)for(var r,i=0,s=t.length;i0&&v.indexOf(e)>=0},T=function(e,t){if(void 0===t&&(t=!1),t&&null===e)return!0;var n=g("object",e)&&null!==e&&e.hasOwnProperty("name")&&"string"==typeof e.name&&e.hasOwnProperty("uri")&&"string"==typeof e.uri&&e.hasOwnProperty("type")&&"string"==typeof e.type;if(!n){if("undefined"!=typeof Blob)return e instanceof Blob;if("undefined"!=typeof File)return e instanceof File}return n},I=function(){function e(e){var t=void 0===e?{}:e,n=t.useMemberInfoInMessage,r=void 0===n||n,i=t.typingIndicatorInvalidateTime,s=void 0===i?1e4:i,a=t.typingIndicatorThrottle,o=void 0===a?1e3:a,u=t.websocketResponseTimeout,c=void 0===u?1e4:u;this._useMemberInfoInMessage=!0,this._typingIndicatorInvalidateTime=1e4,this._typingIndicatorThrottle=1e3,this._websocketResponseTimeout=1e4,this._useMemberInfoInMessage=r,this._typingIndicatorInvalidateTime=s,this._typingIndicatorThrottle=o,this._websocketResponseTimeout=c}return Object.defineProperty(e.prototype,"useMemberInfoInMessage",{get:function(){return this._useMemberInfoInMessage},set:function(e){g("boolean",e)&&(this._useMemberInfoInMessage=e)},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"typingIndicatorInvalidateTime",{get:function(){return this._typingIndicatorInvalidateTime},set:function(e){g("number",e)&&(this._typingIndicatorInvalidateTime=e)},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"typingIndicatorThrottle",{get:function(){return this._typingIndicatorThrottle},set:function(e){g("number",e)&&e>=1e3&&e<=9e3&&(this._typingIndicatorThrottle=e)},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"websocketResponseTimeout",{get:function(){return this._websocketResponseTimeout},set:function(e){g("number",e)&&e>=5e3&&e<=3e4&&(this._websocketResponseTimeout=e)},enumerable:!1,configurable:!0}),e}(),S={key:"__ev",value:{k:"__ev",v:"scs"},generation:1},N={encrypt:function(e){return e},decrypt:function(e){return e}},w=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 s(this,(function(e){switch(e.label){case 0:return[4,this._store.set({key:this._keysAddress,value:u([],o(this._preference.keys()),!1),generation:1})];case 1:return e.sent(),[2]}}))}))},e.prototype.init=function(e){var t;return i(this,void 0,void 0,(function(){var n,r,i,o,u,c,l,h;return s(this,(function(s){switch(s.label){case 0:return this._keysAddress=e,[4,this._store.get(e)];case 1:n=null!==(t=s.sent())&&void 0!==t?t:[],s.label=2;case 2:s.trys.push([2,7,8,9]),r=a(n),i=r.next(),s.label=3;case 3:return i.done?[3,6]:(o=i.value,[4,this._store.get(o)]);case 4:(u=s.sent())&&this._preference.set(o,u),s.label=5;case 5:return i=r.next(),[3,3];case 6:return[3,9];case 7:return c=s.sent(),l={error:c},[3,9];case 8:try{i&&!i.done&&(h=r.return)&&h.call(r)}finally{if(l)throw l.error}return[7];case 9:return[2]}}))}))},e.prototype.get=function(e){var t;return i(this,void 0,void 0,(function(){return s(this,(function(n){return[2,null!==(t=this._preference.get(e))&&void 0!==t?t:null]}))}))},e.prototype.set=function(e,t){return i(this,void 0,void 0,(function(){var n;return s(this,(function(r){switch(r.label){case 0:return n=!this._preference.has(e),[4,this._store.set({key:e,value:t,generation:1})];case 1:return r.sent(),this._preference.set(e,t),n?[4,this._savePreferenceKeys()]:[3,3];case 2:r.sent(),r.label=3;case 3:return[2]}}))}))},e.prototype.remove=function(e){return i(this,void 0,void 0,(function(){return s(this,(function(t){switch(t.label){case 0:return[4,this._store.remove(e)];case 1:return t.sent(),this._preference.delete(e),[4,this._savePreferenceKeys()];case 2:return t.sent(),[2]}}))}))},e.prototype.clear=function(){return i(this,void 0,void 0,(function(){return s(this,(function(e){switch(e.label){case 0:return[4,this._store.removeMany(u([],o(this._preference.keys()),!1))];case 1:return e.sent(),this._preference.clear(),[4,this._savePreferenceKeys()];case 2:return e.sent(),[2]}}))}))},e}(),M=function(e){var t=e.encryption,n=void 0===t?null:t,r=e.store,i=void 0===r?null:r,s=e.localCacheEnabled,a=void 0===s||s;this.nestdb=null,this.store=i,this.preference=new w({store:i}),this.encryption=null!=n?n:N,this.localCacheEnabled=a},A=function(){function e(){this.sessionKey=null,this.authToken=null}return Object.defineProperty(e.prototype,"hasSession",{get:function(){return!!this.sessionKey},enumerable:!1,configurable:!0}),e.prototype.clear=function(){this.authToken=null,this.sessionKey=null},e}(),U=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)}))},O=function(){function e(e){var t=e.container;this._container={},this._container=t,this.key=U()}return e.prototype._register=function(e,t,n){return e in this._container||(this._container[e]=new Map),this._container[e].set(this.key,{occurence:t,handler:n}),this},e.prototype.on=function(e,t){return this._register(e,-1,t)},e.prototype.once=function(e,t){return this._register(e,1,t)},e.prototype.close=function(){for(var e in this._container)this._container[e].delete(this.key)},e}(),R=function(){function e(){this._container={}}return e.prototype.on=function(e,t){return new O({container:this._container}).on(e,t)},e.prototype.once=function(e,t){return new O({container:this._container}).once(e,t)},e.prototype.dispatch=function(e,t){var n,r,i=this._container[e];if(i){var s=[];try{for(var o=a(i.keys()),u=o.next();!u.done;u=o.next()){var c=u.value,l=i.get(c);l.handler(t),l.occurence>0&&(l.occurence--,0===l.occurence&&s.push(c))}}catch(e){n={error:e}}finally{try{u&&!u.done&&(r=o.return)&&r.call(o)}finally{if(n)throw n.error}}s.forEach((function(e){return i.delete(e)}))}},e}(),L=function(){function e(){this._dispatcher=new R}return e.prototype.on=function(e){return this._dispatcher.on("event",e)},e.prototype.once=function(e){return this._dispatcher.once("event",e)},e.prototype.dispatch=function(e){this._dispatcher.dispatch("event",e)},e}(),k=function(){},D=function(e){var t={};return e&&Object.keys(e).forEach((function(n){void 0!==e[n]&&NaN!==e[n]&&null!==e[n]&&(t[n]=e[n])})),t};!function(e){e.GET="GET",e.POST="POST",e.PUT="PUT",e.DELETE="DELETE"}(d||(d={}));var P,x=function(e){function t(){var t=null!==e&&e.apply(this,arguments)||this;return t.params={},t.requireAuth=!0,t.headers={},t.requestId=U(),t}return n(t,e),t.prototype.stringifyParams=function(e){return"object"!=typeof e||Array.isArray(e)?String(e):e?JSON.stringify(e):""},t.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(t.prototype,"query",{get:function(){var e=this,t=D(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(t.prototype,"payload",{get:function(){var e=this,t=D(this.params);if(Object.keys(t).some((function(e){return T(t[e])}))){var n=new FormData;return Object.keys(t).forEach((function(r){var i,s=t[r];if(T(s)){var a=s;n.append(r,a,null!==(i=a.name)&&void 0!==i?i:"filename")}else n.append(r,e.stringifyParams(s))})),n}return JSON.stringify(t)},enumerable:!1,configurable:!0}),t}(k),F=function(e){function t(t,n){var r=e.call(this)||this;return r._iid=t,r._payload=n,r}return n(t,e),Object.defineProperty(t.prototype,"payload",{get:function(){return r({},this._payload)},enumerable:!1,configurable:!0}),t.prototype.as=function(e){return new e(this._iid,this.payload)},t}(k),q=function(e){function t(t){var n=e.call(this)||this;return n.requestId=t,n}return n(t,e),t}(k),G=function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return n(t,e),t}(k),H=function(e){function t(t){var n=e.call(this)||this;return n.statLog=t,n}return n(t,e),t}(k);!function(e){e.WEBSOCKET_CONNECT="ws:connect",e.API_RESULT="api:result"}(P||(P={}));var V,K=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 D({stat_type:e.type,ts:e.createdAt,data:D(e.data)})},e}(),Q=function(){return"undefined"==typeof document&&"undefined"!=typeof navigator&&"ReactNative"==navigator.product},B=function(){function e(e,t){var n=t.auth,r=t.sdkState,i=t.dispatcher,s=t.logger,a=this;this._abortControl=new Map,this._iid=e,this._auth=n,this._sdkState=r,this._dispatcher=i,this._dispatcher.on((function(e){e instanceof q&&a.cancel(e.requestId)})),this._logger=s}return Object.defineProperty(e.prototype,"_userAgentWithExtension",{get:function(){var e=this._sdkState.extensions,t=Q()?"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 n=this._sdkState,i=n.appId,s=n.appVersion,a=r(r({},e.headers),{SendBird:"JS,".concat(h.OS_VERSION,",").concat(h.SDK_VERSION,",").concat(i).concat(s?",".concat(s):""),"SB-User-Agent":encodeURIComponent(this._userAgentWithExtension),"Request-Sent-Timestamp":Date.now().toString()});return t||(a["Content-Type"]="application/json; charset=utf-8"),e.requireAuth&&this._auth.hasSession&&(a["Session-Key"]=this._auth.sessionKey),this._auth&&this._auth.authToken&&(a["App-Id"]=i,a["Access-Token"]=this._auth.authToken),a},e.prototype._statLogApiResult=function(e,t,n){this._dispatcher.dispatch(new H(new K({type:P.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,a,o,u,c,l,h,p,_,v,m,g;return s(this,(function(s){switch(s.label){case 0:t=e.path,n=e.method,r=![d.GET,d.DELETE].includes(n),i=this._sdkState.api,a="".concat(i.host).concat(t).concat(r?"":e.query),o=r?e.payload:null,u=this._createHeader(e,o instanceof FormData?o:null),c=new AbortController,l=c.signal,this._abortControl.set(e.requestId,c),h=Date.now(),s.label=1;case 1:return s.trys.push([1,4,,5]),[4,fetch(a,{method:n,body:o,headers:u,signal:l})];case 2:return[4,(p=s.sent()).json()];case 3:if(_=s.sent(),p.ok||p.redirected)return this._logger.debug("receive api response",e.requestId),this._statLogApiResult(e,h,null),[2,new F(this._iid,_)];throw _?(v=new f(_),!e.requireAuth&&v.isSessionKeyExpiredError&&this._dispatcher.dispatch(new G),this._statLogApiResult(e,h,v),v):(v=f.requestFailed,this._statLogApiResult(e,h,v),v);case 4:throw m=s.sent(),this._statLogApiResult(e,h,m),m instanceof f?(this._logger.debug("fail api request",m),m):"AbortError"===m.name?f.requestCanceled:(g=f.networkError,this._logger.debug("fail api request",g),g);case 5:return[2]}}))}))},e.prototype.cancel=function(e){this._abortControl.has(e)&&(this._abortControl.get(e).abort(),this._abortControl.delete(e))},e.prototype.cancelAll=function(){var e,t;try{for(var n=a(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}(),j=function(e){function t(t,n,r,i){void 0===i&&(i="");var s,a=this;return(a=e.call(this)||this)._iid=t,a.code=n,a.payload=r,a.requestId=r?null!==(s=r.req_id)&&void 0!==s?s:i:"",a}return n(t,e),t.createFromRawMessage=function(e,n){var r=n.substring(0,4),i=null;try{i=JSON.parse(n.substring(4))}catch(e){r="NOOP"}finally{return new t(e,r,i)}},t.prototype.convertToMessage=function(){return"".concat(this.code).concat(JSON.stringify(this.payload),"\n")},t.prototype.as=function(e){return new e(this._iid,this.code,this.payload)},t}(k),z=function(e){function t(t){var n,r=t.code,i=t.ackRequired,s=t.payload,a=void 0===s?null:s,o=this;return(o=e.call(this)||this).code=r,o.payload=a,o.requestId=null!==(n=o.payload.req_id)&&void 0!==n?n:U(),o.ackRequired=i,o.payload.req_id=o.requestId,o}return n(t,e),t.prototype.convertToMessage=function(){return"".concat(this.code).concat(JSON.stringify(this.payload),"\n")},t}(k),W=function(e){function t(){return e.call(this,{code:"PING",payload:{id:Date.now(),active:1},ackRequired:!1})||this}return n(t,e),t}(z),Y=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 W;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}(),J=function(){};e.ConnectionState=void 0,(V=e.ConnectionState||(e.ConnectionState={})).CONNECTING="CONNECTING",V.OPEN="OPEN",V.CLOSED="CLOSED";var X,Z=function(t){function r(e,n){var r=n.sdkState,i=n.dispatcher,s=n.logger,a=t.call(this)||this;return a._pinger=null,a.lastActive=0,a._iid=e,a._sdkState=r,a._dispatcher=i,a._logger=s,a._sdkState.websocket.pingerDisabled||(a._pinger=new Y({pingDelegate:{send:function(e){return a.send(e)},error:function(e){return a.error(e)}},sdkState:a._sdkState,logger:s})),a}return n(r,t),Object.defineProperty(r.prototype,"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},enumerable:!1,configurable:!0}),r.prototype.connect=function(e){var t=this;this._ws=new WebSocket(e),this._ws.onopen=function(){t._logger.debug("websocket open"),t.dispatch("open")},this._ws.onmessage=function(e){e.data.split("\n").forEach((function(e){if(e&&g("string",e)){var n=j.createFromRawMessage(t._iid,e);t._logger.debug("receive websocket event",n),"LOGI"===n.code?(n.payload&&!n.payload.error&&t._pinger&&t._pinger.start(),t.dispatch("message",n)):"PONG"===n.code?t._pinger&&t._pinger.pong():"EXPR"===n.code?n.payload&&n.payload.expires_in>=0&&t._dispatcher.dispatch(new G):"NOOP"===n.code||t.dispatch("message",n)}}))},this._ws.onerror=function(){t._logger.debug("websocket error"),t._pinger&&t._pinger.stop(),t.dispatch("error",f.networkError)},this._ws.onclose=function(){t._logger.debug("websocket close"),t._pinger&&t._pinger.stop(),t.dispatch("close")},this.lastActive=Date.now()},r.prototype.disconnect=function(){var e=this;this._logger.debug("websocket disconnect"),this._pinger&&this._pinger.stop(),this._ws&&(this._ws.onopen=J,this._ws.onmessage=J,this._ws.onerror=J,this._ws.onclose=function(){e.dispatch("close")},this._ws.close(),this._ws=null)},r.prototype.send=function(e){if(!this._ws)throw f.connectionClosed;"PING"!==e.code?this._pinger&&this._pinger.refreshTimer():this._logger.debug("send ping",e),this._ws.send(e.convertToMessage())},r.prototype.error=function(e){this._logger.debug("websocket error",e),this._pinger&&this._pinger.stop(),this.dispatch("error",e)},r}(R),$=function(e){function t(t){var n=t.all,r=t.custom_types,i=t.ts,s=e.call(this)||this;return s.all=n,s.customTypes=r,s.ts=i,s}return n(t,e),t}(k),ee=function(){var e=this;this.promise=new Promise((function(t,n){e.resolve=t,e.reject=n}))},te=function(){function e(e,t){var n=t.auth,r=t.sdkState,i=t.dispatcher,s=t.logger,a=this;this._ackStateMap=new Map,this._sdkState=r,this._dispatcher=i,this._logger=s,this.apiClient=new B(e,{auth:n,sdkState:r,dispatcher:i,logger:s}),this.websocketClient=new Z(e,{sdkState:r,dispatcher:i,logger:s}),this.websocketClient.on("message",(function(e){if(e.payload.unread_cnt&&a._dispatcher.dispatch(new $(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 f({code:e.payload.code,message:e.payload.message}))}}else a._dispatcher.dispatch(e)})).on("close",(function(){a._ackStateMap.forEach((function(e){e.reject(f.connectionClosed)})),a._ackStateMap.clear()}))}return e.prototype._sendApiRequest=function(e){return i(this,void 0,void 0,(function(){return s(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 s(this,(function(s){if(t=new ee,e.ackRequired){n=null,r=function(r,s){void 0===r&&(r=null),void 0===s&&(s=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(s)))};try{n=setTimeout((function(){return r(f.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 s(this,(function(t){switch(t.label){case 0:return e instanceof x?[4,this._sendApiRequest(e)]:[3,2];case 1:case 3:return[2,t.sent()];case 2:return e instanceof z?[4,this._sendWebsocketRequest(e)]:[3,4];case 4:throw f.invalidParameters}}))}))},e.prototype.cancel=function(e){this.apiClient.cancel(e)},e.prototype.cancelAll=function(){this.apiClient.cancelAll()},e}();!function(e){e[e.NONE=0]="NONE",e[e.INITIALIZED=1]="INITIALIZED",e[e.CONNECTING=2]="CONNECTING",e[e.CONNECTED=3]="CONNECTED",e[e.RECONNECTING=4]="RECONNECTING",e[e.DISCONNECTED=5]="DISCONNECTED",e[e.LOGOUT=6]="LOGOUT"}(X||(X={}));var ne,re,ie,se,ae,oe,ue,ce,le,he=function(e){function t(t){var n=t.stateType,r=e.call(this)||this;return r.stateType=n,r}return n(t,e),t}(k),de=function(){function e(e,t){var n=t.auth,r=t.sdkState,a=t.dispatcher,o=t.logger,u=this;this._currentConnectionStateType=X.INITIALIZED,this._lazyCallQueue=[],this.commandRouter=new te(e,{auth:n,sdkState:r,dispatcher:a,logger:o}),this._auth=n,this._logger=o,this._dispatcher=a,this._dispatcher.on((function(e){if(e instanceof he){var t=e.stateType;switch(u._currentConnectionStateType=t,t){case X.CONNECTED:var n=u._lazyCallQueue;u._lazyCallQueue=[],n.forEach((function(e){return i(u,void 0,void 0,(function(){var t,n,r,i,a;return s(this,(function(s){switch(s.label){case 0:t=e.command,n=e.deferred,r=e.timeout,clearTimeout(r),s.label=1;case 1:return s.trys.push([1,3,,4]),[4,this.send(t)];case 2:return i=s.sent(),n.resolve(i),[3,4];case 3:return a=s.sent(),n.reject(a),[3,4];case 4:return[2]}}))}))}));break;case X.INITIALIZED:case X.DISCONNECTED:case X.LOGOUT:n=u._lazyCallQueue;u._lazyCallQueue=[],n.forEach((function(e){return i(u,void 0,void 0,(function(){var t,n;return s(this,(function(r){return t=e.deferred,n=e.timeout,clearTimeout(n),this._auth&&this._auth.hasSession?t.reject(f.connectionClosed):t.reject(f.connectionRequired),[2]}))}))}))}}}))}return Object.defineProperty(e.prototype,"isReady",{get:function(){return this._currentConnectionStateType===X.CONNECTED},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"isLazyCallActivated",{get:function(){return this._currentConnectionStateType===X.CONNECTING||this._currentConnectionStateType===X.RECONNECTING},enumerable:!1,configurable:!0}),e.prototype.send=function(e){return i(this,void 0,void 0,(function(){var t,n,r=this;return s(this,(function(i){switch(i.label){case 0:return e instanceof z?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 ee,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"),f.connectionRequired;case 3:return[3,7];case 4:return e instanceof x?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 ee,this._lazyCallQueue.push({command:e,deferred:t,timeout:setTimeout((function(){return r.timeout(e.requestId)}),1e4)}),[2,t.promise];throw n=f.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 s(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(f.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}(),pe="v3",fe="/".concat(pe,"/users"),_e="/".concat(pe,"/storage/file"),ve="/".concat(pe,"/group_channels"),me="/".concat(pe,"/sdk/group_channels"),ge="/".concat(pe,"/open_channels"),ye="/".concat(pe,"/sdk/open_channels"),Ee="/".concat(pe,"/search"),be="/".concat(pe,"/report"),Ce="/".concat(pe,"/emojis"),Te="/".concat(pe,"/emoji_categories"),Ie="/".concat(pe,"/polls"),Se="/".concat(pe,"/scheduled_messages"),Ne="/".concat(pe,"/sdk/statistics"),we=function(e){function t(t){var n=t.userId,r=t.authToken,i=t.expiringSession,s=void 0===i||i,a=e.call(this)||this;return a.path="".concat(fe,"/").concat(n,"/session_key"),a.method=d.POST,a.params={token:r,expiring_session:!!s},a.requireAuth=!1,a}return n(t,e),t}(x),Me=function(e){function t(t){var n=t.authToken,r=t.expiringSession,i=void 0===r||r;return e.call(this,{code:"LOGI",payload:{token:n,expiring_session:i?1:0},ackRequired:!0})||this}return n(t,e),t}(z),Ae=function(e){function t(t,n){var r=e.call(this,t,n)||this,i=n.key;return r.key=i,r}return n(t,e),t}(F),Ue=function(e){function t(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 f(r.error):null,i}return n(t,e),t}(j),Oe=function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return n(t,e),t}(k),Re=function(e){return i(void 0,void 0,void 0,(function(){return s(this,(function(t){return[2,new Promise((function(t){return setTimeout(t,e)}))]}))}))},Le=function(){function e(){}return e.prototype.calcTimeout=function(){return 0},e}(),ke=function(e,t,n){return void 0===n&&(n=new Le),i(void 0,void 0,void 0,(function(){var r,i,a,o,u,c;return s(this,(function(s){switch(s.label){case 0:r=0,i=null,a=function(e){return void 0===e&&(e=null),i=null!=e?e:new Error("Halted")},o=function(){r=0},s.label=1;case 1:if(!(-1===t||r0?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 dt({userProfile:this}))},e}(),ft=function(e){function t(t,n,r){var i,s=this;return(s=e.call(this,t,n,r)||this).error=null,s.userProfile=new pt(t,r),s.key=r.key,s.ekey=null!==(i=r.ekey)&&void 0!==i?i:"",s.error=r.error?new f(r):null,s}return n(t,e),t.asError=function(e){return new t(null,"LOGI",r({user_id:null,error:!0},e))},t.prototype.applyTo=function(e){if(this.error)throw this.error;var t=wt.of(e);if(!t)throw f.lostInstance;t.sessionManager.auth.sessionKey=this.key,je(e,this.ekey),this.userProfile.apply()},t}(j),_t=function(e){function t(t){var n=e.call(this)||this;return n.enabled=t,n}return n(t,e),t}(k),vt=function(e){function t(t,n){var r=n.sdkState,i=n.cacheContext,s=n.connectionHandlers,a=n.sessionManager,o=n.websocketClient,u=n.dispatcher,c=n.logger,l=n.entryState,h=void 0===l?new Qe:l,d=e.call(this)||this;return d._currentState=null,d._loginTimer=null,d._connectingAt=0,d._connectionRequestQueue=[],d._iid=t,d.sdkState=r,d.cacheContext=i,d.connectionHandlers=s,d._sessionManager=a,d._websocketClient=o,d._dispatcher=u,d._logger=c,d._currentState=h,d._websocketClient.on("message",(function(e){if("LOGI"===e.code){d._loginTimer&&(clearTimeout(d._loginTimer),d._loginTimer=null);var t=e.as(ft);if(t.error)(t.error.isSessionKeyExpiredError||t.error.isSessionTokenExpiredError)&&d._dispatcher.dispatch(new G),d._connectionRequestQueue.forEach((function(e){return e.reject(t.error)})),d._statLogConnection(t.error);else{t.applyTo(d._iid),d._connectionRequestQueue.forEach((function(e){return e.resolve()}));var n=t.userProfile;d._enableStatLog(n.appInfo.applicationAttributes.includes("allow_sdk_request_log_publish")),d._statLogConnection(null)}d._connectionRequestQueue=[]}})).on("close",(function(){d._connectionRequestQueue.length>0&&(d._connectionRequestQueue.forEach((function(e){return e.reject(f.networkError)})),d._connectionRequestQueue=[],d._statLogConnection(f.networkError))})),d}return n(t,e),Object.defineProperty(t.prototype,"currentState",{get:function(){return this._currentState},enumerable:!1,configurable:!0}),t.prototype.changeState=function(e){return i(this,void 0,void 0,(function(){return s(this,(function(t){switch(t.label){case 0:return this._currentState=e,this._dispatcher.dispatch(new he({stateType:e.type})),this._logger.debug("connection state changes to ".concat(e.name)),[4,this._currentState.run(this)];case 1:return t.sent(),[2]}}))}))},t.prototype._url=function(e){void 0===e&&(e="");var t=this.sdkState,n=t.appId,r=t.appVersion,i=t.userId,s=t.extensions,a=this.cacheContext.localCacheEnabled,o=this._sessionManager.auth,u=s.sb_syncmanager?"s".concat(s.sb_syncmanager):"",c=s.sb_uikit?"u".concat(s.sb_uikit):"",l="JS/c".concat(h.SDK_VERSION,"/").concat(u,"/").concat(c);return"".concat(this.sdkState.websocket.host,"/?p=JS&pv=").concat(encodeURIComponent(h.OS_VERSION),"&sv=").concat(encodeURIComponent(h.SDK_VERSION),"&ai=").concat(n).concat(r?"&av=".concat(r):"").concat(o.hasSession?"&key=".concat(encodeURIComponent(o.sessionKey)):"&user_id=".concat(encodeURIComponent(i),"&access_token=").concat(encodeURIComponent(e)),"&active=1&SB-User-Agent=").concat(l,"&Request-Sent-Timestamp=").concat(Date.now().toString(),"&include_extra_data=").concat(encodeURIComponent(String(["premium_feature_list","file_upload_size_limit","application_attributes","emoji_hash"]))).concat(this._sessionManager.handler?"&expiring_session=1":"","&use_local_cache=").concat(a?1:0,"&include_poll_details=1")},t.prototype._enableStatLog=function(e){this._dispatcher.dispatch(new _t(e))},t.prototype._statLogConnection=function(e){this._dispatcher.dispatch(new H(new K({type:P.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}})))},t.prototype.connect=function(e){return void 0===e&&(e=""),i(this,void 0,void 0,(function(){var t,n,r=this;return s(this,(function(i){return t=this._url(e),n=new ee,this._connectionRequestQueue.push(n),1===this._connectionRequestQueue.length&&(this._connectingAt=Date.now(),this._loginTimer=setTimeout((function(){r._loginTimer=null,r._dispatcher.dispatch(ft.asError(f.loginTimeout))}),this.sdkState.websocket.responseTimeout),this._websocketClient.connect(t)),[2,n.promise]}))}))},t.prototype.cancelConnectForRetry=function(){this._dispatcher.dispatch(ft.asError(f.connectionRenew))},t.prototype.disconnect=function(){this._websocketClient.disconnect()},t.prototype.logout=function(){this.sdkState.userId=null,this._sessionManager.currentUser=null,this._sessionManager.auth.clear(),this.disconnect()},t}(R),mt=function(){function e(e,t){var n=t.sdkState,r=t.cacheContext,i=t.connectionHandlers,s=t.sessionManager,a=t.websocketClient,o=t.dispatcher,u=t.logger,c=t.disableAutoReconnect,l=void 0!==c&&c,h=this;this._context=null,this._logger=u,this._context=new vt(e,{sdkState:n,cacheContext:r,connectionHandlers:i,sessionManager:s,websocketClient:a,dispatcher:o,logger:u}),l||(s.on("refresh-authtoken",(function(){h.isConnected||(h._logger.debug("try reconnect by session token refresh"),h.reconnect())})).on("refresh",(function(){h.isConnecting||h.isConnected||(h._logger.debug("try reconnect by session key refresh"),h.reconnect())})),a.on("close",(function(){"foreground"===n.appState&&setTimeout((function(){s.isRefreshingAuthToken||(h._logger.debug("try reconnect by websocket connection closed"),h.reconnect())}),100)})))}return Object.defineProperty(e.prototype,"isConnected",{get:function(){return this._context.currentState.type===X.CONNECTED},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"isConnecting",{get:function(){var e=this._context.currentState;return e.type===X.CONNECTING||e.type===X.RECONNECTING},enumerable:!1,configurable:!0}),e.prototype.connect=function(e){return i(this,void 0,void 0,(function(){return s(this,(function(t){switch(t.label){case 0:return[4,this._context.currentState.onConnect(this._context,e)];case 1:return t.sent(),[2]}}))}))},e.prototype.reconnect=function(){return i(this,void 0,void 0,(function(){return s(this,(function(e){switch(e.label){case 0:return[4,this._context.currentState.onReconnect(this._context,{})];case 1:return e.sent(),[2]}}))}))},e.prototype.resetAndReconnect=function(){return i(this,void 0,void 0,(function(){return s(this,(function(e){switch(e.label){case 0:return[4,this._context.currentState.onReconnect(this._context,{resetReconnectCount:!0})];case 1:return e.sent(),[2]}}))}))},e.prototype.background=function(){return i(this,void 0,void 0,(function(){return s(this,(function(e){switch(e.label){case 0:return[4,this._context.currentState.onDisconnect(this._context,{autoReconnect:!1})];case 1:return e.sent(),[2]}}))}))},e.prototype.disconnect=function(e){return void 0===e&&(e=null),i(this,void 0,void 0,(function(){return s(this,(function(t){switch(t.label){case 0:return[4,this._context.currentState.onDisconnect(this._context,{error:e,autoReconnect:!0})];case 1:return t.sent(),[2]}}))}))},e.prototype.logout=function(){return i(this,void 0,void 0,(function(){return s(this,(function(e){switch(e.label){case 0:return[4,this._context.currentState.onLogout(this._context)];case 1:return e.sent(),[2]}}))}))},e}(),gt=function(e){function t(t){var n=t.deviceId,r=t.statLogs,i=e.call(this)||this;return i.method=d.POST,i.path="".concat(Ne),i.params={device_id:n,log_entries:r.map((function(e){return K.payloadify(e)}))},i}return n(t,e),t}(x);!function(e){e[e.PENDING=0]="PENDING",e[e.ENABLED=1]="ENABLED",e[e.DISABLED=2]="DISABLED"}(lt||(lt={}));var yt,Et=function(){function e(e){var t=e.cacheContext,n=e.requestQueue,r=e.dispatcher,i=e.baseLimit,s=void 0===i?100:i,a=e.maxLimit,o=void 0===a?1e3:a,u=e.minLimit,c=void 0===u?10:u;this.queue=[],this.enabledstate=lt.PENDING,this.isFlushing=!1,this.generation=1,this.lastFlushedAt=0,this.deviceId=U(),this.cacheContext=t,this.requestQueue=n,this.dispatcher=r,this.baseLimit=s,this.limit=s,this.maxLimit=o,this.minLimit=c}return Object.defineProperty(e.prototype,"isEnabled",{get:function(){return this.enabledstate===lt.ENABLED},enumerable:!1,configurable:!0}),e.prototype._save=function(){return i(this,void 0,void 0,(function(){return s(this,(function(e){switch(e.label){case 0:return this.cacheContext.localCacheEnabled?[4,this.cacheContext.preference.set(this.key,{deviceId:this.deviceId,statLogs:this.queue.map((function(e){return K.payloadify(e)})),generation:this.generation++,lastFlushedAt:this.lastFlushedAt})]:[3,2];case 1:e.sent(),e.label=2;case 2:return[2]}}))}))},e.prototype._flush=function(){return i(this,void 0,void 0,(function(){var e,t;return s(this,(function(n){switch(n.label){case 0:if(!this.isEnabled)return[3,7];if(this.isFlushing)return[3,7];this.isFlushing=!0,n.label=1;case 1:return n.trys.push([1,5,6,7]),(e=this.queue.slice(0,Math.min(this.limit,this.maxLimit))).length>0?(t=new gt({deviceId:this.deviceId,statLogs:e}),[4,this.requestQueue.send(t)]):[3,4];case 2:return n.sent(),this.queue=this.queue.slice(e.length),[4,this._save()];case 3:n.sent(),n.label=4;case 4:return this.limit=this.baseLimit,this.lastFlushedAt=Date.now(),[3,7];case 5:return n.sent(),this.limit=this.limit+20,[3,7];case 6:return this.isFlushing=!1,[7];case 7:return[2]}}))}))},e.prototype.init=function(e){return i(this,void 0,void 0,(function(){var t,n,r=this;return s(this,(function(i){switch(i.label){case 0:return this.key=e,this.cacheContext.localCacheEnabled?[4,this.cacheContext.preference.get(this.key)]:[3,4];case 1:return(t=i.sent())?(this.deviceId=t.deviceId,this.queue=t.statLogs.map((function(e){return new K({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,Re(n)]):[3,4]):[3,4];case 2:return i.sent(),[4,this._flush()];case 3:i.sent(),i.label=4;case 4:return this.dispatcher.on((function(e){if(e instanceof H){var t=e.statLog;r.put(t)}else e instanceof _t&&(r.enabledstate=e.enabled?lt.ENABLED:lt.DISABLED,r.isEnabled?r.queue.length>=r.limit&&r._flush():r.clear())})),[2]}}))}))},e.prototype.put=function(e){return i(this,void 0,void 0,(function(){return s(this,(function(t){switch(t.label){case 0:return this.enabledstate===lt.DISABLED?[3,3]:(this.queue.push(e),[4,this._save()]);case 1:return t.sent(),this.queue.length>=this.limit?[4,this._flush()]:[3,3];case 2:t.sent(),t.label=3;case 3:return[2]}}))}))},e.prototype.clear=function(){return i(this,void 0,void 0,(function(){return s(this,(function(e){switch(e.label){case 0:return this.queue=[],this.generation=1,[4,this._save()];case 1:return e.sent(),[2]}}))}))},e}();e.LogLevel=void 0,(yt=e.LogLevel||(e.LogLevel={}))[yt.NONE=0]="NONE",yt[yt.VERBOSE=1]="VERBOSE",yt[yt.DEBUG=2]="DEBUG",yt[yt.INFO=3]="INFO",yt[yt.WARN=4]="WARN",yt[yt.ERROR=5]="ERROR";var bt,Ct,Tt,It,St=function(){function t(){this.level=e.LogLevel.WARN}return t.prototype.verbose=function(){for(var t=[],n=0;n0&&g("number",c)&&(this.key=i,this.userIds=s,this.updatedAt=c);var l={};try{for(var h=a(this.userIds),d=h.next();!d.done;d=h.next()){l[d.value]=this.updatedAt}}catch(e){t={error:e}}finally{try{d&&!d.done&&(n=h.return)&&n.call(h)}finally{if(t)throw t.error}}this._version=l}return Object.defineProperty(t.prototype,"isEmpty",{get:function(){return 0===this.userIds.length},enumerable:!1,configurable:!0}),t.payloadify=function(e){return e?D({key:e.key,user_ids:e.userIds,updated_at:e.updatedAt}):null},t.prototype.applyEvent=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)}},t}(),xt=function(){function e(e){this.key=e.key,this.value=b("string",e.value)?u([],o(e.value),!1):[]}return e.payloadify=function(e){var t;return e?D({key:e.key,value:null!==(t=e.value)&&void 0!==t?t:[]}):null},e}(),Ft=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?D({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}(),qt=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 Ft(e["og:image"]))}return e.payloadify=function(e){return e?D({"og:title":e.title,"og:url":e.url,"og:description":e.description,"og:image":e.defaultImage?Ft.payloadify(e.defaultImage):null}):null},e}(),Gt=function(){function e(e){var t,n;this.name=null,this.volume=0,this.name=null!==(t=e.name)&&void 0!==t?t:"default",this.volume=null!==(n=e.volume)&&void 0!==n?n:1}return e.payloadify=function(e){return e?D({name:e.name,volume:e.volume}):null},e}();e.ScheduledStatus=void 0,(Lt=e.ScheduledStatus||(e.ScheduledStatus={})).PENDING="pending",Lt.SENT="sent",Lt.FAILED="failed",Lt.CANCELED="canceled",function(e){e.PENDING="pending",e.IN_QUEUE="in_queue",e.SENT="sent",e.FAILED="failed",e.CANCELED="canceled",e.REMOVED="removed"}(kt||(kt={}));var Ht,Vt=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"}},Kt=function(t){function i(n,r){var i,s,a,o,u,c,l,h,d,p,f,_,v,m=this;(m=t.call(this,n)||this).channelUrl=null,m.channelType=e.ChannelType.BASE,m.messageId=0,m.parentMessageId=null,m.parentMessage=null,m.silent=!1,m.isOperatorMessage=!1,m.messageType=e.MessageType.BASE,m.data=null,m.customType=null,m.mentionType=null,m.mentionedUsers=[],m.mentionedUserIds=[],m.mentionedMessageTemplate=null,m.threadInfo=null,m.reactions=[],m.metaArrays=[],m.ogMetaData=null,m.appleCriticalAlertOptions=null,m.createdAt=0,m.updatedAt=0,m.scheduledInfo=null,m._scheduledStatus=null,m.messageId=null!==(s=null!==(i=r.msg_id)&&void 0!==i?i:r.message_id)&&void 0!==s?s:0,m.channelUrl=r.channel_url,m.channelType=y(e.ChannelType,r.channel_type)?r.channel_type:e.ChannelType.GROUP,r.channel&&(r.channel.channel_url&&(m.channelUrl=r.channel.channel_url),r.channel.channel_type&&(m.channelType=r.channel.channel_type)),m.parentMessageId=null!==(a="string"==typeof r.parent_message_id?parseInt(r.parent_message_id):r.parent_message_id)&&void 0!==a?a:0,m.data=null!==(o=r.data)&&void 0!==o?o:"",m.customType=null!==(u=r.custom_type)&&void 0!==u?u:"",m.mentionType=y(e.MentionType,r.mention_type)?r.mention_type:null;var g=r.mentioned_users;m.mentionedUsers=g?g.map((function(e){return new ht(m._iid,e)})):null;var E=r.mentioned_user_ids;m.mentionedUserIds=null!=E?E:null,m.mentionedMessageTemplate=null!==(c=r.mentioned_message_template)&&void 0!==c?c:"",m.threadInfo=r.thread_info?new Rt(m._iid,r.thread_info):null,m.reactions=r.reactions?r.reactions.map((function(e){return new Pt(e)})):[];for(var b=null!==(l=r.metaarray)&&void 0!==l?l:{},C=null!==(h=r.metaarray_key_order)&&void 0!==h?h:Object.keys(b).sort((function(e,t){return e.localeCompare(t)})),T=0;T=t)return this.parentMessage=e,!0}return!1},i}(We),Qt=function(t){function i(n,r){var i=t.call(this,n,r)||this;return i.role=null,i.isBlockedByMe=!1,i.role=y(e.Role,r.role)?r.role:e.Role.NONE,r.hasOwnProperty("is_blocked_by_me")&&(i.isBlockedByMe=r.is_blocked_by_me),i}return n(i,t),i.payloadify=function(e){return e?D(r(r({},t.payloadify.call(this,e)),{role:e.role,is_blocked_by_me:e.isBlockedByMe})):null},i}(ht),Bt=function(t){function i(n,r){var i,s,a,o,u=this;if((u=t.call(this,n,r)||this).sender=null,u.reqId="",u.replyToChannel=!1,u.sendingStatus=null,u.errorCode=0,u.sender=r.user?new Qt(u._iid,r.user):r.sender_id,u.reqId=null!==(s=null!==(i=r.req_id)&&void 0!==i?i:r.request_id)&&void 0!==s?s:"",u.replyToChannel=null!==(a=r.is_reply_to_channel)&&void 0!==a&&a,r.request_state&&y(e.SendingStatus,r.request_state)&&(u.sendingStatus=r.request_state),!u.sendingStatus)if(u.messageId>0)u.sendingStatus=e.SendingStatus.SUCCEEDED;else if(u.scheduledInfo)switch(u._scheduledStatus=r.scheduled_status,r.scheduled_status){case kt.SENT:case kt.IN_QUEUE:u.sendingStatus=e.SendingStatus.SUCCEEDED;break;case kt.PENDING:u.sendingStatus=e.SendingStatus.SCHEDULED;break;case kt.FAILED:case kt.REMOVED:u.sendingStatus=e.SendingStatus.FAILED;break;case kt.CANCELED:u.sendingStatus=e.SendingStatus.CANCELED}else u.sendingStatus=e.SendingStatus.PENDING;return u.errorCode=null!==(o=r.error_code)&&void 0!==o?o:0,u}return n(i,t),i.payloadify=function(e){return e?D(r(r({},t.payloadify.call(this,e)),{user:Qt.payloadify(e.sender),req_id:e.reqId,is_reply_to_channel:e.replyToChannel,request_state:e.sendingStatus,error_code:e.errorCode})):null},Object.defineProperty(i.prototype,"isResendable",{get:function(){return this.sendingStatus===e.SendingStatus.FAILED&&((t=this.errorCode)>0&&_.indexOf(t)>=0);var t},enumerable:!1,configurable:!0}),i.prototype.isIdentical=function(e){return this.messageId>0&&e.messageId>0?this.messageId===e.messageId:this.reqId===e.reqId},i}(Kt),jt=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?D({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}(),zt={prevResultSize:0,nextResultSize:0,isInclusive:!1,reverse:!1,messageTypeFilter:e.MessageTypeFilter.ALL,customTypesFilter:null,senderUserIdsFilter:null,includeReactions:!1,includeMetaArray:!1,includeParentMessageInfo:!1},Wt=function(t){return g("number",t.prevResultSize)&&g("number",t.nextResultSize)&&g("boolean",t.isInclusive)&&g("boolean",t.reverse)&&g("string",t.messageTypeFilter)&&y(e.MessageTypeFilter,t.messageTypeFilter)&&b("string",t.customTypesFilter,!0)&&b("string",t.senderUserIdsFilter,!0)&&g("boolean",t.includeMetaArray)&&g("boolean",t.includeReactions)&&g("boolean",t.includeParentMessageInfo)},Yt=function(t){function a(n,i){var s,a,o,u,c=this;if((c=t.call(this,n,i)||this).message=null,c.translations={},c.message=null!==(s=i.message)&&void 0!==s?s:"",c.messageType=e.MessageType.ADMIN,c.translations=null!==(a=i.translations)&&void 0!==a?a:{},i.parent_message_info){var l=i.parent_message_info,h=r(r({},l),{message_id:c.parentMessageId,channel_url:c.channelUrl,channel_type:c.channelType,file:l.file,url:null===(o=l.file)||void 0===o?void 0:o.url,require_auth:null===(u=l.file)||void 0===u?void 0:u.require_auth});c.parentMessage=sn(n,h)}return c}return n(a,t),a.payloadify=function(e){return e?D(r(r({},t.payloadify.call(this,e)),{message:e.message,translations:e.translations,parent_message_info:rn(e.parentMessage)})):null},a.prototype.getThreadedMessagesByTimestamp=function(e,t){return i(this,void 0,void 0,(function(){var n;return s(this,(function(i){switch(i.label){case 0:return n=r(r({},zt),t),ct(this.messageId>0&&g("number",e)&&Wt(n)).throw(f.invalidParameters),[4,kn.of(this._iid).getThreadedMessagesByTimestamp(this,e,n)];case 1:return[2,i.sent()]}}))}))},a}(Kt),Jt=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")&&g("object",e.detail)&&!Array.isArray(e.detail)&&(this.detail=e.detail)}return e.payloadify=function(e){return e?D({type:e.type,vendor:e.vendor,detail:e.detail}):null},e}();!function(e){e.OPEN="open",e.CLOSED="closed"}(Ht||(Ht={}));var Xt,Zt=function(e){switch(e){case Ht.OPEN:return Ht.OPEN;case Ht.CLOSED:return Ht.CLOSED}},$t=function(e){return!e||e.text&&g("string",e.text)},en=function(e){function t(t,n){var r,i,s,a,o,u,c,l=this;return(l=e.call(this,t)||this).pollId=0,l.id=0,l.text=null,l.voteCount=0,l.createdBy=null,l.createdAt=0,l.updatedAt=0,l._lastVotedAt=0,l.pollId=null!==(r=n.poll_id)&&void 0!==r?r:0,l.id=null!==(i=n.id)&&void 0!==i?i:0,l.text=null!==(s=n.text)&&void 0!==s?s:null,l.voteCount=null!==(a=n.vote_count)&&void 0!==a?a:0,l.createdBy=null!==(o=n.created_by)&&void 0!==o?o:null,l.createdAt=null!==(u=n.created_at)&&void 0!==u?u:0,l.updatedAt=null!==(c=n.updated_at)&&void 0!==c?c:0,l}return n(t,e),t.payloadify=function(t){return t?D(r(r({},e.payloadify.call(this,t)),{vote_count:t.voteCount,poll_id:t.pollId,text:t.text,created_at:t.createdAt,id:t.id,created_by:t.createdBy,updated_at:t.updatedAt})):null},t}(We),tn=function(e){function t(t,n){var r,i,s,a,o,u,c,l,h,d,p,f,_,v=this;return(v=e.call(this,t)||this).id=0,v.title=null,v.createdAt=0,v.updatedAt=0,v.closeAt=-1,v.status=Ht.CLOSED,v.messageId=0,v.data=null,v.voterCount=-1,v.options=[],v.createdBy=null,v.allowUserSuggestion=!1,v.allowMultipleVotes=!1,v.votedPollOptionIds=[],v.id=null!==(r=n.id)&&void 0!==r?r:0,v.title=null!==(i=n.title)&&void 0!==i?i:null,v.createdAt=null!==(s=n.created_at)&&void 0!==s?s:0,v.updatedAt=null!==(a=n.updated_at)&&void 0!==a?a:0,v.closeAt=null!==(o=n.close_at)&&void 0!==o?o:-1,v.status=null!==(u=Zt(n.status))&&void 0!==u?u:Ht.CLOSED,v.messageId=null!==(c=n.message_id)&&void 0!==c?c:0,v.data=null!==(l=n.data)&&void 0!==l?l:null,v.voterCount=null!==(h=n.voter_count)&&void 0!==h?h:-1,v.options=n.options?n.options.map((function(e){return new en(v._iid,e)})):[],v.createdBy=null!==(d=n.created_by)&&void 0!==d?d:null,v.allowUserSuggestion=null!==(p=n.allow_user_suggestion)&&void 0!==p&&p,v.allowMultipleVotes=null!==(f=n.allow_multiple_votes)&&void 0!==f&&f,v.votedPollOptionIds=null!==(_=n.voted_option_ids)&&void 0!==_?_:[],v}return n(t,e),t.prototype._applyPollUpdatePayload=function(e){var t,n,r,i,s,a,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!==(i=Zt(e.status))&&void 0!==i?i:this.status,this.data=null!==(s=e.data)&&void 0!==s?s:this.data,this.voterCount=null!==(a=e.voter_count)&&void 0!==a?a:this.voterCount,this.options=e.options?e.options.map((function(e){return new en(c._iid,e)})):this.options,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},t.payloadify=function(t){return t?D(r(r({},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 en.payloadify(e)})),created_by:t.createdBy,allow_user_suggestion:t.allowUserSuggestion,allow_multiple_votes:t.allowMultipleVotes,voted_option_ids:t.votedPollOptionIds})):null},t.prototype.applyPollUpdateEvent=function(e){var t=e._payload.poll;return!(!t||this.id!==t.id||t.updated_at-1){var s=t[r];i>s._lastVotedAt&&(s.voteCount=e.vote_count,s._lastVotedAt=i)}})),r.req_id&&r.voted_option_ids&&(this.votedPollOptionIds=r.voted_option_ids),!0},t}(We),nn=function(t){function o(n,i){var s,o,u,c,l,h,d,p=this;if((p=t.call(this,n,i)||this).message="",p.messageParams=null,p.translations={},p.translationTargetLanguages=[],p.messageSurvivalSeconds=-1,p.plugins=[],p._poll=null,p.message=i.message,p.messageType=e.MessageType.USER,p.translations=null!==(u=i.translations)&&void 0!==u?u:{},p.translationTargetLanguages=null!==(c=i.target_langs)&&void 0!==c?c:[],0===Object.keys(p.translations).length&&p.translationTargetLanguages.length>0)try{for(var f=a(p.translationTargetLanguages),_=f.next();!_.done;_=f.next()){var v=_.value;p.translations[v]=""}}catch(e){s={error:e}}finally{try{_&&!_.done&&(o=f.return)&&o.call(f)}finally{if(s)throw s.error}}if(p.messageSurvivalSeconds=null!==(l=i.message_survival_seconds)&&void 0!==l?l:-1,p.plugins=i.plugins?i.plugins.map((function(e){return new Jt(e)})):[],p._poll=i.poll?new tn(p._iid,i.poll):null,i.parent_message_info){var m=i.parent_message_info,g=r(r({},m),{created_at:m.ts,message_id:p.parentMessageId,channel_url:p.channelUrl,channel_type:p.channelType,file:m.file,url:null===(h=m.file)||void 0===h?void 0:h.url,require_auth:null===(d=m.file)||void 0===d?void 0:d.require_auth});p.parentMessage=sn(n,D(g))}return p}return n(o,t),o.payloadify=function(e){return e?D(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 Jt.payloadify(e)})),poll:tn.payloadify(e._poll),parent_message_info:rn(e.parentMessage)})):null},o.prototype.getThreadedMessagesByTimestamp=function(e,t){return i(this,void 0,void 0,(function(){var n;return s(this,(function(i){switch(i.label){case 0:return n=r(r({},zt),t),ct(this.messageId>0&&g("number",e)&&Wt(n)).throw(f.invalidParameters),[4,kn.of(this._iid).getThreadedMessagesByTimestamp(this,e,n)];case 1:return[2,i.sent()]}}))}))},o.prototype.applyPoll=function(e){return!(this._poll&&this._poll.id===e.id&&this._poll.updatedAt>e.updatedAt)&&(this._poll=e,!0)},Object.defineProperty(o.prototype,"poll",{get:function(){return this._poll},enumerable:!1,configurable:!0}),o}(Bt),rn=function(t){if(t)switch(t.messageType){case e.MessageType.USER:return nn.payloadify(t);case e.MessageType.FILE:return an.payloadify(t);case e.MessageType.ADMIN:return Yt.payloadify(t)}return null},sn=function(e,t){switch(t.type){case"MESG":return new nn(e,t);case"FILE":return new an(e,t);case"ADMM":case"BRDM":return new Yt(e,t)}return null},an=function(t){function a(n,i){var s,a,o,u,c,l,h,d,p,f,_,v,m,g,y,E=this;(E=t.call(this,n,i)||this).messageParams=null,E.plainUrl="",E.requireAuth=!1,E.name=null,E.size=0,E.type=null,E.thumbnails=[],E.messageSurvivalSeconds=-1,E.messageType=e.MessageType.FILE;var b=null!==(s=i.file)&&void 0!==s?s:null;if(E.plainUrl=(null!==(o=null!==(a=null==b?void 0:b.url)&&void 0!==a?a:i.url)&&void 0!==o?o:"").split("?auth=")[0],E.name=null!==(c=null!==(u=null==b?void 0:b.name)&&void 0!==u?u:i.name)&&void 0!==c?c:"File",E.size=null!==(h=null!==(l=null==b?void 0:b.size)&&void 0!==l?l:i.size)&&void 0!==h?h:0,E.data=null!==(p=null!==(d=null==b?void 0:b.data)&&void 0!==d?d:i.custom)&&void 0!==p?p:"",E.type=b?null!==(f=b.type)&&void 0!==f?f:"":null!==(_=i.type)&&void 0!==_?_:"",E.requireAuth=null!==(v=i.require_auth)&&void 0!==v&&v,E.thumbnails=i.thumbnails?i.thumbnails.map((function(e){return new jt(r(r({},e),{url:"".concat(e.url.split("?auth=")[0]).concat(E.requireAuth?"?auth=".concat(je(E._iid)):"")}))})):[],E.messageSurvivalSeconds=null!==(m=i.message_survival_seconds)&&void 0!==m?m:-1,i.parent_message_info){var C=i.parent_message_info,T=r(r({},C),{message_id:E.parentMessageId,channel_url:E.channelUrl,channel_type:E.channelType,file:C.file,url:null===(g=C.file)||void 0===g?void 0:g.url,require_auth:null===(y=C.file)||void 0===y?void 0:y.require_auth});E.parentMessage=sn(n,T)}return E}return n(a,t),a.payloadify=function(e){return e?D(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:e.thumbnails.map((function(e){return{url:e.url,width:e.width,height:e.height,real_width:e.realWidth,real_height:e.realHeight}})),message_survival_seconds:e.messageSurvivalSeconds,parent_message_info:rn(e.parentMessage)})):null},Object.defineProperty(a.prototype,"url",{get:function(){return this.requireAuth?"".concat(this.plainUrl,"?auth=").concat(je(this._iid)):this.plainUrl},enumerable:!1,configurable:!0}),a.prototype.getThreadedMessagesByTimestamp=function(e,t){return i(this,void 0,void 0,(function(){var n;return s(this,(function(i){switch(i.label){case 0:return n=r(r({},zt),t),ct(this.messageId>0&&g("number",e)&&Wt(n)).throw(f.invalidParameters),[4,kn.of(this._iid).getThreadedMessagesByTimestamp(this,e,n)];case 1:return[2,i.sent()]}}))}))},a}(Bt),on=function(t){function r(n){var r,i,s,a=[];return n.mentionType===e.MentionType.USERS&&(n.mentionedUserIds?a=n.mentionedUserIds:n.mentionedUsers&&(a=n.mentionedUsers.map((function(e){return e.userId})))),t.call(this,{code:"FILE",ackRequired:!0,payload:D({channel_url:n.channelUrl,url:n.url,name:null!==(r=n.fileName)&&void 0!==r?r:"",type:null!==(i=n.mimeType)&&void 0!==i?i:"",size:null!==(s=n.fileSize)&&void 0!==s?s:0,custom:n.data,custom_type:n.customType,thumbnails:n.thumbnailSizes,require_auth:n.requireAuth,metaarray:n.metaArrays,mention_type:n.mentionType,mentioned_user_ids:a,push_option:n.pushNotificationDeliveryOption&&n.pushNotificationDeliveryOption!==e.PushNotificationDeliveryOption.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})})||this}return n(r,t),r}(z),un=function(t){function r(n){var r,i=this;i=t.call(this)||this;var s=[];return n.mentionType===e.MentionType.USERS&&(n.mentionedUserIds?s=n.mentionedUserIds:n.mentionedUsers&&(s=n.mentionedUsers.map((function(e){return e.userId})))),i.method=d.POST,i.path="".concat(Je(n.channelType),"/").concat(encodeURIComponent(n.channelUrl),"/messages"),i.params=D({message_type:e.MessageType.FILE,user_id:n.userId,url:n.fileUrl,mention_type:n.mentionType,mentioned_user_ids:s,file_name:n.fileName,file_size:n.fileSize,file_type:n.mimeType,data:n.data,custom_type:n.customType,thumbnails:n.thumbnailSizes.map((function(e){return jt.payloadify(e)})),require_auth:n.requireAuth,sorted_metaarray:null===(r=n.metaArrays)||void 0===r?void 0:r.map((function(e){return xt.payloadify(e)})),push_option:n.pushNotificationDeliveryOption,parent_message_id:n.parentMessageId>0?n.parentMessageId:null,apple_critical_alert_options:Gt.payloadify(n.appleCriticalAlertOptions),reply_to_channel:n.isReplyToChannel,req_id:n.reqId}),i}return n(r,t),r}(x),cn=function(e){function t(t,n,r){var i,s,a,o=this;(o=e.call(this,t,"FILE",r)||this).message=new an(t,r);var u=wt.of(t).sdkState;return o.isMentioned=Ze(o.message.mentionType,null!==(i=o.message.mentionedUserIds)&&void 0!==i?i:null===(s=o.message.mentionedUsers)||void 0===s?void 0:s.map((function(e){return e.userId})),u.userId),o.forceUpdateLastMessage=null!==(a=r.force_update_last_message)&&void 0!==a&&a,o}return n(t,e),t}(j),ln=function(e){function t(t,n){var r,i,s=this;(s=e.call(this,t,n)||this).message=new an(t,n);var a=wt.of(t).sdkState;return s.isMentioned=Ze(s.message.mentionType,null!==(r=s.message.mentionedUserIds)&&void 0!==r?r:s.message.mentionedUsers.map((function(e){return e.userId})),a.userId),s.forceUpdateLastMessage=null!==(i=n.force_update_last_message)&&void 0!==i&&i,s}return n(t,e),t}(F);!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"}(Xt||(Xt={}));var hn,dn=function(){function e(e,t){var n=t.sdkState,r=t.dispatcher,i=t.requestQueue,s=t.onlineDetector,a=t.cacheContext,o=this;this._queueMap=new Map,this._connectionState=null,this._onlineDetector=null,this._iid=e,this._sdkState=n,this._requestQueue=i,this._cacheContext=a,this._dispatcher=r,this._dispatcher.on((function(e){e instanceof he&&(o._connectionState=e.stateType)})),this._onlineDetector=s}return Object.defineProperty(e.prototype,"_shouldSendThroughWebSocket",{get:function(){return this._connectionState===X.CONNECTED||this._connectionState===X.CONNECTING||this._connectionState===X.RECONNECTING},enumerable:!1,configurable:!0}),e.prototype._sendFileMessage=function(e,t){return i(this,void 0,void 0,(function(){var n,i;return s(this,(function(s){switch(s.label){case 0:return this._shouldSendThroughWebSocket?(n=new on(r(r({channelUrl:e.url,channelType:e.channelType,url:t.params.fileUrl,requireAuth:t.requireAuth},t.params),{reqId:t.requestId})),[4,this._requestQueue.send(n)]):[3,2];case 1:return i=s.sent(),[2,i.as(cn).message];case 2:return n=new un(r(r({channelUrl:e.url,channelType:e.channelType,url:t.params.fileUrl,userId:this._sdkState.userId,requireAuth:t.requireAuth},t.params),{reqId:t.requestId})),[4,this._requestQueue.send(n)];case 3:return i=s.sent(),[2,i.as(ln).message]}}))}))},e.prototype._resolveMessageQueue=function(e){return i(this,void 0,void 0,(function(){var t,n,r,i,o,u,l,h,d,p,_,v;return s(this,(function(s){switch(s.label){case 0:if(!(t=this._queueMap.get(e.url)))return[3,21];if(t.isResolving)return[3,20];t.isResolving=!0,n=[],r=!0,s.label=1;case 1:s.trys.push([1,15,16,17]),i=a(t.messageQueue),o=i.next(),s.label=2;case 2:if(o.done)return[3,14];switch(u=o.value,u.state){case Xt.PENDING:case Xt.UPLOADING:return[3,3];case Xt.UPLOADED:return[3,4];case Xt.FAILED:return[3,12]}return[3,13];case 3:return r=!1,n.push(u),[3,13];case 4:if(!r)return[3,10];s.label=5;case 5:return s.trys.push([5,8,,9]),u.state=Xt.SENDING,[4,this._sendFileMessage(e,u)];case 6:return l=s.sent(),u.deferred.resolve(l),[4,Re(100)];case 7:return s.sent(),[3,9];case 8:return h=s.sent(),u.deferred.reject(h),[3,9];case 9:return[3,11];case 10:n.push(u),s.label=11;case 11:return[3,13];case 12:return u.deferred.reject(u.error.code===c.REQUEST_CANCELED?f.fileUploadCanceled:u.error),[3,13];case 13:return o=i.next(),[3,2];case 14:return[3,17];case 15:return d=s.sent(),_={error:d},[3,17];case 16:try{o&&!o.done&&(v=i.return)&&v.call(i)}finally{if(_)throw _.error}return[7];case 17:return p=t.isResolveRequestPending,t.messageQueue=n,t.isResolving=!1,t.isResolveRequestPending=!1,p?[4,this._resolveMessageQueue(e)]:[3,19];case 18:s.sent(),s.label=19;case 19:return[3,21];case 20:t.isResolveRequestPending=!0,s.label=21;case 21:return[2]}}))}))},e.prototype._uploadNextPendingItem=function(e){return i(this,void 0,void 0,(function(){var t,n,r,i,a,o,u,l,h,d,p,_,v,m;return s(this,(function(s){switch(s.label){case 0:return t=this._queueMap.get(e.url),(n=t.messageQueue.find((function(e){return e.state===Xt.PENDING})))?T(n.params.file)?t.uploadQueue.length<6?(n.state=Xt.UPLOADING,t.uploadQueue.push(n),[4,this._onlineDetector.isOnline()]):[3,10]:[3,11]:[3,13];case 1:if(!s.sent())return[3,8];s.label=2;case 2:return s.trys.push([2,4,5,7]),r=new Ut({file:n.params.file,channelUrl:e.url,thumbnailSizes:n.params.thumbnailSizes,requestId:n.requestId}),[4,this._requestQueue.send(r)];case 3:return i=s.sent(),a=i.as(Ot),o=a.url,u=a.fileSize,l=void 0===u?n.params.fileSize:u,h=a.thumbnailSizes,d=void 0===h?n.params.thumbnailSizes:h,p=a.requireAuth,_=void 0!==p&&p,n.params.fileUrl=o,n.params.fileSize=l,n.params.thumbnailSizes=d,n.params.requireAuth=_,n.requireAuth=_,n.state=Xt.UPLOADED,[3,7];case 4:return(v=s.sent()).code===c.REQUEST_FAILED?n.error=new f({code:c.NETWORK_ERROR,message:"Failed to upload a file."}):n.error=v,n.state=Xt.FAILED,[3,7];case 5:return(m=t.uploadQueue.findIndex((function(e){return e.requestId===n.requestId})))>=0&&(t.uploadQueue.splice(m,1),this._uploadNextPendingItem(e)),[4,this._resolveMessageQueue(e)];case 6:return s.sent(),[7];case 7:return[3,10];case 8:return n.state=Xt.FAILED,n.error=f.connectionRequired,(m=t.uploadQueue.findIndex((function(e){return e.requestId===n.requestId})))>=0&&(t.uploadQueue.splice(m,1),this._uploadNextPendingItem(e)),[4,this._resolveMessageQueue(e)];case 9:s.sent(),s.label=10;case 10:return[3,13];case 11:return n.params.thumbnailSizes=[],n.state=Xt.UPLOADED,[4,this._resolveMessageQueue(e)];case 12:s.sent(),s.label=13;case 13:return[2]}}))}))},e.prototype.request=function(e,t,n){var r,a,o;return i(this,void 0,void 0,(function(){var i;return s(this,(function(s){return i=new ee,T(n.file)&&(n.fileName=null!==(r=n.fileName)&&void 0!==r?r:n.file.name,n.mimeType=null!==(a=n.mimeType)&&void 0!==a?a:n.file.type,n.fileSize=null!==(o=n.fileSize)&&void 0!==o?o:n.file.size),this._queueMap.has(e.url)||this._queueMap.set(e.url,{messageQueue:[],uploadQueue:[],isResolving:!1,isResolveRequestPending:!1}),this._queueMap.get(e.url).messageQueue.push({requestId:t,params:n,state:Xt.PENDING,deferred:i,requireAuth:n.requireAuth}),this._uploadNextPendingItem(e),[2,i.promise]}))}))},e.prototype.cancel=function(e,t){var n,r;void 0===t&&(t=null);var i=this._queueMap.get(e.url);if(i){var s=t?[i.messageQueue.find((function(e){return e.requestId===t}))]:u([],o(i.messageQueue),!1);try{for(var c=a(s),l=c.next();!l.done;l=c.next()){var h=l.value;if(h)switch(h.state){case Xt.PENDING:h.state=Xt.FAILED,h.error=f.requestCanceled,this._resolveMessageQueue(e);break;case Xt.UPLOADING:this._requestQueue.cancel(h.requestId)}}}catch(e){n={error:e}}finally{try{l&&!l.done&&(r=c.return)&&r.call(c)}finally{if(n)throw n.error}}}},e}(),pn={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},fn=function(t){return g("number",t.prevResultSize)&&g("number",t.nextResultSize)&&g("boolean",t.isInclusive)&&g("boolean",t.reverse)&&g("string",t.messageTypeFilter)&&y(e.MessageTypeFilter,t.messageTypeFilter)&&b("string",t.customTypesFilter,!0)&&b("string",t.senderUserIdsFilter,!0)&&y(e.ReplyType,t.replyType)&&g("boolean",t.includeMetaArray)&&g("boolean",t.includeReactions)&&g("boolean",t.includeParentMessageInfo)&&g("boolean",t.includeThreadInfo)&&g("boolean",t.showSubchannelMessagesOnly)},_n={replyType:e.ReplyType.NONE,includeReactions:!1,includeThreadInfo:!1,includeMetaArray:!1,includeParentMessageInfo:!1},vn=function(t){return y(e.ReplyType,t.replyType)&&g("boolean",t.includeReactions)&&g("boolean",t.includeMetaArray)&&g("boolean",t.includeParentMessageInfo)&&g("boolean",t.includeThreadInfo)};e.MessageEventSource=void 0,(hn=e.MessageEventSource||(e.MessageEventSource={})).UNKNOWN="UNKNOWN",hn.EVENT_MESSAGE_SENT_SUCCESS="EVENT_MESSAGE_SENT_SUCCESS",hn.EVENT_MESSAGE_SENT_FAILED="EVENT_MESSAGE_SENT_FAILED",hn.EVENT_MESSAGE_SENT_PENDING="EVENT_MESSAGE_SENT_PENDING",hn.EVENT_MESSAGE_RECEIVED="EVENT_MESSAGE_RECEIVED",hn.EVENT_MESSAGE_UPDATED="EVENT_MESSAGE_UPDATED",hn.EVENT_MESSAGE_DELETED="EVENT_MESSAGE_DELETED",hn.EVENT_MESSAGE_READ="EVENT_MESSAGE_READ",hn.EVENT_MESSAGE_DELIVERED="EVENT_MESSAGE_DELIVERED",hn.EVENT_MESSAGE_REACTION_UPDATED="EVENT_MESSAGE_REACTION_UPDATED",hn.EVENT_MESSAGE_THREADINFO_UPDATED="EVENT_MESSAGE_THREADINFO_UPDATED",hn.EVENT_MESSAGE_OFFSET_UPDATED="EVENT_MESSAGE_OFFSET_UPDATED",hn.REQUEST_MESSAGE="REQUEST_MESSAGE",hn.EVENT_POLL_UPDATED="EVENT_POLL_UPDATED",hn.EVENT_POLL_VOTED="EVENT_POLL_VOTED",hn.SYNC_POLL_CHANGELOGS="SYNC_POLL_CHANGELOGS",hn.REQUEST_RESEND_MESSAGE="REQUEST_RESEND_MESSAGE",hn.REQUEST_THREADED_MESSAGE="REQUEST_THREADED_MESSAGE",hn.REQUEST_MESSAGE_CHANGELOGS="REQUEST_MESSAGE_CHANGELOGS",hn.SYNC_MESSAGE_FILL="SYNC_MESSAGE_FILL",hn.SYNC_MESSAGE_BACKGROUND="SYNC_MESSAGE_BACKGROUND",hn.SYNC_MESSAGE_CHANGELOGS="SYNC_MESSAGE_CHANGELOGS",hn.LOCAL_MESSAGE_PENDING_CREATED="LOCAL_MESSAGE_PENDING_CREATED",hn.LOCAL_MESSAGE_FAILED="LOCAL_MESSAGE_FAILED",hn.LOCAL_MESSAGE_CANCELED="LOCAL_MESSAGE_CANCELED",hn.LOCAL_MESSAGE_RESEND_STARTED="LOCAL_MESSAGE_RESEND_STARTED";var mn,gn=function(t){return t.startsWith("EVENT_")||t===e.MessageEventSource.SYNC_MESSAGE_FILL||t===e.MessageEventSource.SYNC_MESSAGE_CHANGELOGS||t===e.MessageEventSource.SYNC_POLL_CHANGELOGS},yn=function(e){function t(t){var n=t.messages,r=t.source,i=e.call(this)||this;return i.messages=n,i.source=r,i}return n(t,e),t}(k),En=function(e){function t(t){var n=t.messageIds,r=t.source,i=e.call(this)||this;return i.messageIds=n,i.source=r,i}return n(t,e),t}(k),bn=function(e){function t(t){var n=t.reqId,r=t.source,i=e.call(this)||this;return i.reqId=n,i.source=r,i}return n(t,e),t}(k),Cn=function(e){function t(t){var n=t.polls,r=t.source,i=e.call(this)||this;return i.polls=n,i.source=r,i}return n(t,e),t}(k),Tn=function(e){function t(t){var n=t.event,r=t.source,i=e.call(this)||this;return i.event=n,i.source=r,i}return n(t,e),t}(k),In=function(e){function t(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 n(t,e),t}(k),Sn=function(e){function t(t){var n=t.channelType,r=t.channelUrl,i=t.messageId,s=t.includeMetaArray,a=t.includeReactions,o=t.includeThreadInfo,u=t.includeParentMessageInfo,c=e.call(this)||this;return c.method=d.GET,c.path="".concat(Je(n),"/").concat(encodeURIComponent(r),"/messages/").concat(encodeURIComponent(i)),c.params={is_sdk:!0,with_sorted_meta_array:s,include_reactions:a,include_thread_info:o,include_parent_message_info:u,include_poll_details:!0},c}return n(t,e),t}(x),Nn=function(e){function t(t,n){var i=e.call(this,t,n)||this;return i.message=n?sn(t,r({},n)):null,i}return n(t,e),t}(F),wn=function(e){function t(t){var n=t.channelType,r=t.channelUrl,i=t.timestamp,s=void 0===i?null:i,a=t.token,o=void 0===a?null:a,u=t.prevResultSize,c=t.nextResultSize,l=t.isInclusive,h=t.reverse,p=t.messageTypeFilter,f=t.customTypesFilter,_=t.senderUserIdsFilter,v=t.replyType,m=t.includeMetaArray,g=t.includeReactions,y=t.parentMessageId,E=t.includeThreadInfo,b=t.includeParentMessageInfo,C=t.showSubchannelMessagesOnly,T=e.call(this)||this;return T.method=d.GET,T.path="".concat(Je(n),"/").concat(encodeURIComponent(r),"/messages"),T.params=D({is_sdk:!0,prev_limit:u,next_limit:c,include:l,reverse:h,message_ts:s,message_id:o,message_type:null!=p?p:null,custom_types:f,sender_ids:_,include_reply_type:v,with_sorted_meta_array:m,include_reactions:g,parent_message_id:y,include_thread_info:E,include_parent_message_info:b,show_subchannel_message_only:C,include_poll_details:!0}),T}return n(t,e),t}(x),Mn=function(e){function t(t,n){var r=e.call(this,t,n)||this;return r.messages=n.messages.map((function(e){return sn(t,e)})),r}return n(t,e),t}(F),An=function(e){function t(t){var n=t.channelType,r=t.channelUrl,i=t.timestamp,s=t.token,a=t.replyType,o=t.includeMetaArray,u=t.includeReactions,c=t.includeThreadInfo,l=t.includeParentMessageInfo,h=e.call(this)||this;return h.method=d.GET,h.path="".concat(Je(n),"/").concat(encodeURIComponent(r),"/messages/changelogs"),h.params={change_ts:i,token:s,with_sorted_meta_array:o,include_reactions:u,include_thread_info:c,include_reply_type:a,include_parent_message_info:l,include_poll_details:!0},h}return n(t,e),t}(x),Un=function(e){function t(t,n){var r=e.call(this,t,n)||this;return r.updatedMessages=n.updated.map((function(e){return sn(t,e)})),r.deletedMessagesInfo=n.deleted.map((function(e){return{messageId:e.message_id,deletedAt:e.deleted_at}})),r.hasMore=n.has_more,r.nextToken=n.next,r}return n(t,e),t}(F),On=function(e){function t(t){var n=t.channelUrl,r=t.scheduledMessageId,i=e.call(this)||this;return i.method=d.GET,i.path="".concat(ve,"/").concat(encodeURIComponent(n),"/scheduled_messages/").concat(encodeURIComponent(r)),i.params={},i}return n(t,e),t}(x),Rn=function(e){function t(t,n){var i=e.call(this,t,n)||this;return i.message=n?sn(t,r({},n)):null,i}return n(t,e),t}(F),Ln={},kn=function(){function t(e,t){var n=t.sdkState,r=t.dispatcher,i=t.requestQueue,s=t.onlineDetector,a=t.cacheContext;this._iid=e,this._sdkState=n,this._requestQueue=i,this._dispatcher=r,this._onlineDetector=s,this._cacheContext=a,this.fileMessageQueue=new dn(e,{sdkState:n,dispatcher:r,requestQueue:i,onlineDetector:s,cacheContext:a}),Ln[e]=this}return t.of=function(e){return Ln[e]},t.prototype.buildMessageFromSerializedData=function(t){var n=ut(t);switch(n.messageType){case e.MessageType.USER:return new nn(this._iid,nn.payloadify(n));case e.MessageType.FILE:return new an(this._iid,an.payloadify(n));case e.MessageType.ADMIN:return new Yt(this._iid,Yt.payloadify(n))}return null},t.prototype.buildUserMessageCreateParamsFromSerializedData=function(e,t){return D({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})},t.prototype.buildFileMessageCreateParamsFromSerializedData=function(e,t){return D({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.url,fileName:t.name,fileSize:t.size,mimeType:t.type,thumbnailSizes:t.thumbnails.map((function(e){return{maxWidth:e.width,maxHeight:e.height}})),fileType:e.fileType,requireAuth:t.requireAuth})},t.prototype.buildScheduledUserMessageCreateParamsFromSerializedData=function(e,t){return r(r({},this.buildUserMessageCreateParamsFromSerializedData(e,t)),{scheduledAt:e.scheduledAt})},t.prototype.buildScheduledFileMessageCreateParamsFromSerializedData=function(e,t){return r(r({},this.buildFileMessageCreateParamsFromSerializedData(e,t)),{scheduledAt:e.scheduledAt})},t.prototype.buildSenderFromSerializedData=function(e){var t=ut(e);return new Qt(this._iid,Qt.payloadify(t))},t.prototype.getMessage=function(e){return i(this,void 0,void 0,(function(){var t,n;return s(this,(function(r){switch(r.label){case 0:return t=new Sn(e),[4,this._requestQueue.send(t)];case 1:return n=r.sent(),[2,n.as(Nn).message]}}))}))},t.prototype.getScheduledMessage=function(e){return i(this,void 0,void 0,(function(){var t,n;return s(this,(function(r){switch(r.label){case 0:return t=new On(e),[4,this._requestQueue.send(t)];case 1:return n=r.sent(),[2,n.as(Rn).message]}}))}))},t.prototype.getMessagesByMessageId=function(t,n,a,o,u){return void 0===u&&(u=e.MessageEventSource.REQUEST_MESSAGE),i(this,void 0,void 0,(function(){var e,i,c;return s(this,(function(s){switch(s.label){case 0:return e=new wn(r(r({channelType:n,channelUrl:t,token:String(a)},pn),o)),[4,this._requestQueue.send(e)];case 1:return i=s.sent(),c=i.as(Mn).messages,this._dispatcher.dispatch(new yn({messages:c,source:u})),[2,c]}}))}))},t.prototype.getMessagesByTimestamp=function(t,n,a,o,u){return void 0===u&&(u=e.MessageEventSource.REQUEST_MESSAGE),i(this,void 0,void 0,(function(){var e,i,c;return s(this,(function(s){switch(s.label){case 0:return e=new wn(r(r({channelType:n,channelUrl:t,timestamp:a},pn),o)),[4,this._requestQueue.send(e)];case 1:return i=s.sent(),c=i.as(Mn).messages,this._dispatcher.dispatch(new yn({messages:c,source:u})),[2,c]}}))}))},t.prototype.getThreadedMessagesByTimestamp=function(t,n,a,o){return void 0===o&&(o=e.MessageEventSource.REQUEST_THREADED_MESSAGE),i(this,void 0,void 0,(function(){var i,u,c,l;return s(this,(function(s){switch(s.label){case 0:return i=new wn(r(r(r({channelUrl:t.channelUrl,channelType:t.channelType,timestamp:n},zt),a),{replyType:e.ReplyType.ALL,parentMessageId:t.messageId,includeThreadInfo:!0})),[4,this._requestQueue.send(i)];case 1:return u=s.sent(),c=u.as(Mn).messages,(l=c.slice(1)).forEach((function(e){e.parentMessage=t})),this._dispatcher.dispatch(new yn({messages:l,source:o})),[2,{parentMessage:c[0],threadedMessages:l}]}}))}))},t.prototype.getMessageChangelogs=function(t,n,a,o,u){return void 0===u&&(u=e.MessageEventSource.REQUEST_MESSAGE_CHANGELOGS),i(this,void 0,void 0,(function(){var e,i,c,l,h,d,p,f;return s(this,(function(s){switch(s.label){case 0:return e=new An(D(r(r({channelType:n,channelUrl:t,timestamp:"number"==typeof a?a:null,token:"string"==typeof a?a:null},_n),o))),[4,this._requestQueue.send(e)];case 1:return i=s.sent(),c=i.as(Un),l=c.updatedMessages,h=c.deletedMessagesInfo,d=c.hasMore,p=c.nextToken,f=h.map((function(e){return e.messageId})),l.length>0&&this._dispatcher.dispatch(new yn({messages:l,source:u})),f.length>0&&this._dispatcher.dispatch(new En({messageIds:f,source:u})),[2,{updatedMessages:l,deletedMessageIds:f,hasMore:d,token:p}]}}))}))},t}(),Dn=function(){function t(){this._onPending=J,this._onFailed=J,this._onSucceeded=J}return t.prototype._trigger=function(t,n){switch(n.sendingStatus){case e.SendingStatus.PENDING: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)}},t.prototype.onPending=function(e){return this._onPending=e,this},t.prototype.onFailed=function(e){return this._onFailed=e,this},t.prototype.onSucceeded=function(e){return this._onSucceeded=e,this},t}(),Pn=function(e){function t(t,n){var r=e.call(this,t)||this;r.threadInfo=null,r.targetMessageId=0,r.channelUrl=null,r.channelType=null;var i=n.thread_info,s=n.root_message_id,a=n.channel_url,o=n.channel_type;return i&&g("object",i)&&g("number",s)&&g("string",a)&&g("string",o)&&(r.threadInfo=new Rt(t,i),r.targetMessageId=s,r.channelUrl=a,r.channelType=o),r}return n(t,e),t}(We),xn={channelUrl:null,channelType:null,messageId:0,includeReactions:!1,includeMetaArray:!1,includeParentMessageInfo:!1,includeThreadInfo:!1},Fn=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 g("number",this.limit)&&this.limit>0},e}(),qn=function(e){function t(t){var n=t.channelCustomType,r=t.keyword,i=t.limit,s=t.reverse,a=t.exactMatch,o=t.channelUrl,u=t.order,c=t.messageTimestampFrom,l=t.messageTimestampTo,h=t.advancedQuery,p=t.targetFields,f=t.nextToken,_=e.call(this)||this;return _.method=d.GET,_.path="".concat(Ee,"/messages"),_.params={custom_type:n,query:r,limit:i,reverse:s,exact_match:a,channel_url:o,message_ts_from:c,message_ts_to:l,sort_field:u,advanced_query:h,target_fields:p,after:f},_}return n(t,e),t}(x),Gn=function(e){function t(t,n){var r=e.call(this,t,n)||this;return r.messages=n.results.map((function(e){return sn(t,e)})),r.hasNext=n.has_next,r.nextToken=n.end_cursor,r.totalCount=n.total_count,r}return n(t,e),t}(F);e.MessageSearchOrder=void 0,(mn=e.MessageSearchOrder||(e.MessageSearchOrder={})).SCORE="score",mn.TIMESTAMP="ts";var Hn,Vn,Kn,Qn=function(t){function a(n,r){var i,s,a,o,u,c,l,h,d,p=this;return(p=t.call(this,n,r)||this).keyword="",p.reverse=!1,p.exactMatch=!1,p.channelUrl="",p.channelCustomType="",p.messageTimestampFrom=null,p.messageTimestampTo=null,p.order=e.MessageSearchOrder.SCORE,p.advancedQuery=!1,p.targetFields=null,p._nextToken="",p.totalCount=-1,p.keyword=r.keyword,p.reverse=null!==(i=r.reverse)&&void 0!==i&&i,p.exactMatch=null!==(s=r.exactMatch)&&void 0!==s&&s,p.channelUrl=null!==(a=r.channelUrl)&&void 0!==a?a:"",p.channelCustomType=null!==(o=r.channelCustomType)&&void 0!==o?o:"",p.messageTimestampFrom=null!==(u=r.messageTimestampFrom)&&void 0!==u?u:null,p.messageTimestampTo=null!==(c=r.messageTimestampTo)&&void 0!==c?c:null,p.order=null!==(l=r.order)&&void 0!==l?l:e.MessageSearchOrder.SCORE,p.advancedQuery=null!==(h=r.advancedQuery)&&void 0!==h&&h,p.targetFields=null!==(d=r.targetFields)&&void 0!==d?d:null,p}return n(a,t),a.prototype._validate=function(){return t.prototype._validate.call(this)&&g("string",this.keyword)&&this.keyword.length>0&&g("boolean",this.reverse)&&g("boolean",this.exactMatch)&&g("string",this.channelUrl)&&g("string",this.channelCustomType)&&(g("number",this.messageTimestampFrom)||null===this.messageTimestampFrom)&&(g("number",this.messageTimestampTo)||null===this.messageTimestampTo)&&y(e.MessageSearchOrder,this.order)&&g("boolean",this.advancedQuery)&&b("string",this.targetFields,!0)},a.prototype.next=function(){return i(this,void 0,void 0,(function(){var e,t,n,i,a,o,u,c;return s(this,(function(s){switch(s.label){case 0:return this._validate()?this._isLoading?[3,3]:this._hasNext?(this._isLoading=!0,e=wt.of(this._iid).requestQueue,t=new qn(r(r({},this),{nextToken:this._nextToken?this._nextToken:null})),[4,e.send(t)]):[3,2]:[3,5];case 1:return n=s.sent(),i=n.as(Gn),a=i.messages,o=i.hasNext,u=i.nextToken,c=i.totalCount,this._nextToken=u,this._hasNext=o,this._isLoading=!1,this.totalCount=c,[2,a];case 2:return[2,[]];case 3:throw f.queryInProgress;case 4:return[3,6];case 5:throw f.invalidParameters;case 6:return[2]}}))}))},a}(Fn),Bn=function(t){function r(e,n,r,i){var s=t.call(this,e,i)||this;return s.channelUrl=n,s.channelType=r,s}return n(r,t),r.prototype._validate=function(){return t.prototype._validate.call(this)&&g("string",this.channelUrl)&&y(e.ChannelType,this.channelType)},r}(Fn),jn=function(t){function r(n,r,i,s){var a,o,u,c,l,h,d,p,f,_,v=this;return(v=t.call(this,n,r,i,s)||this).reverse=!1,v.messageTypeFilter=e.MessageTypeFilter.ALL,v.customTypesFilter=null,v.senderUserIdsFilter=null,v.replyType=e.ReplyType.NONE,v.includeMetaArray=!1,v.includeReactions=!1,v.includeParentMessageInfo=!1,v.includeThreadInfo=!1,v.showSubchannelMessagesOnly=!1,v._edge=Number.MAX_SAFE_INTEGER,v.reverse=null!==(a=s.reverse)&&void 0!==a&&a,v.messageTypeFilter=null!==(o=s.messageTypeFilter)&&void 0!==o?o:e.MessageTypeFilter.ALL,v.customTypesFilter=null!==(u=s.customTypesFilter)&&void 0!==u?u:null,v.senderUserIdsFilter=null!==(c=s.senderUserIdsFilter)&&void 0!==c?c:null,v.replyType=null!==(l=s.replyType)&&void 0!==l?l:e.ReplyType.NONE,v.includeMetaArray=null!==(h=s.includeMetaArray)&&void 0!==h&&h,v.includeReactions=null!==(d=s.includeReactions)&&void 0!==d&&d,v.includeParentMessageInfo=null!==(p=s.includeParentMessageInfo)&&void 0!==p&&p,v.includeThreadInfo=null!==(f=s.includeThreadInfo)&&void 0!==f&&f,v.showSubchannelMessagesOnly=null!==(_=s.showSubchannelMessagesOnly)&&void 0!==_&&_,v}return n(r,t),r.prototype._validate=function(){return t.prototype._validate.call(this)&&g("boolean",this.reverse)&&y(e.MessageTypeFilter,this.messageTypeFilter)&&y(e.ReplyType,this.replyType)&&b("string",this.customTypesFilter,!0)&&b("string",this.senderUserIdsFilter,!0)&&g("boolean",this.includeMetaArray)&&g("boolean",this.includeReactions)&&g("boolean",this.includeParentMessageInfo)&&g("boolean",this.includeThreadInfo)&&g("boolean",this.showSubchannelMessagesOnly)},r.prototype.load=function(){return i(this,void 0,void 0,(function(){var e;return s(this,(function(t){switch(t.label){case 0:return this._validate()?this._isLoading?[3,3]:this._hasNext?(this._isLoading=!0,[4,kn.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,u([Number.MAX_SAFE_INTEGER],o(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 f.queryInProgress;case 4:return[3,6];case 5:throw f.invalidParameters;case 6:return[2]}}))}))},r}(Bn),zn={channelUrl:null,scheduledMessageId:0},Wn=function(t){function a(){var e=null!==t&&t.apply(this,arguments)||this;return e.name="message",e}return n(a,t),a.prototype.init=function(e,n){var r=n.sdkState,i=n.dispatcher,s=n.sessionManager,a=n.requestQueue,o=n.logger,u=n.onlineDetector,c=n.cacheContext;t.prototype.init.call(this,e,{sdkState:r,dispatcher:i,sessionManager:s,requestQueue:a,logger:o,onlineDetector:u,cacheContext:c}),this._manager=new kn(e,{sdkState:r,dispatcher:i,requestQueue:a,onlineDetector:u,cacheContext:c})},a.prototype.buildMessageFromSerializedData=function(e){return this._manager.buildMessageFromSerializedData(e)},a.prototype.buildSenderFromSerializedData=function(e){return this._manager.buildSenderFromSerializedData(e)},a.prototype.getMessage=function(t){return i(this,void 0,void 0,(function(){var n;return s(this,(function(i){return n=r(r({},xn),t),ct(function(t){return g("string",t.channelUrl)&&g("string",t.channelType)&&y(e.ChannelType,t.channelType)&&g("number",t.messageId)&&g("boolean",t.includeMetaArray)&&g("boolean",t.includeParentMessageInfo)&&g("boolean",t.includeThreadInfo)}(n)).throw(f.invalidParameters),[2,this._manager.getMessage(n)]}))}))},a.prototype.getScheduledMessage=function(e){return i(this,void 0,void 0,(function(){var t;return s(this,(function(n){return t=r(r({},zn),e),ct(function(e){return g("string",e.channelUrl)&&g("number",e.scheduledMessageId)}(t)).throw(f.invalidParameters),[2,this._manager.getScheduledMessage(t)]}))}))},a}(At),Yn=function(e){function t(t){var n=t.title,r=t.optionTexts,i=t.data,s=t.allowUserSuggestion,a=t.allowMultipleVotes,o=t.closeAt,u=e.call(this)||this;return u.method=d.POST,u.path=Ie,u.params={title:n,options:r,data:i,allow_user_suggestion:s,allow_multiple_votes:a,close_at:o},u}return n(t,e),t}(x),Jn=function(e){function t(t,n){var r=e.call(this,t,n)||this;return r.poll=new tn(t,n),r}return n(t,e),t}(F),Xn=function(e){function t(t){var n=t.channelUrl,r=t.channelType,i=t.pollId,s=e.call(this)||this;return s.method=d.GET,s.path="".concat(Ie,"/").concat(encodeURIComponent(i)),s.params={channel_url:n,channel_type:r},s}return n(t,e),t}(x),Zn=function(e){function t(t,n){var r=e.call(this,t,n)||this;return r.poll=new tn(t,n),r}return n(t,e),t}(F),$n=function(e){function t(t){var n=t.channelUrl,r=t.channelType,i=t.pollId,s=t.pollOptionId,a=e.call(this)||this;return a.method=d.GET,a.path="".concat(Ie,"/").concat(encodeURIComponent(i),"/options/").concat(encodeURIComponent(s)),a.params={channel_url:n,channel_type:r},a}return n(t,e),t}(x),er=function(e){function t(t,n){var r=e.call(this,t,n)||this;return r.pollOption=new en(t,n),r}return n(t,e),t}(F),tr=function(e){function t(t){var n=t.channelType,r=t.channelUrl,i=t.timestamp,s=t.token,a=e.call(this)||this;return a.method=d.GET,a.path="".concat(Je(n),"/").concat(encodeURIComponent(r),"/polls/changelogs"),a.params=D({change_ts:i,token:s}),a}return n(t,e),t}(x),nr=function(e){function t(t,n){var r=e.call(this,t,n)||this;return r.updatedPolls=n.updated.map((function(e){return function(e,t){return t?new tn(e,t):null}(t,e)})),r.deletedPollIds=n.deleted.map((function(e){return e})),r.hasMore=n.has_more,r.nextToken=n.next,r}return n(t,e),t}(F),rr={title:null,optionTexts:null,data:null,allowUserSuggestion:null,allowMultipleVotes:null,closeAt:-1},ir=function(e){return g("string",e.title)&&(t=e.optionTexts,b("string",t)&&t.every((function(e){return""!==e.trim()})))&&$t(e.data)&&g("boolean",e.allowUserSuggestion,!0)&&g("boolean",e.allowMultipleVotes,!0)&&g("number",e.closeAt,!0);var t},sr={channelUrl:null,channelType:null,pollId:null,pollOptionId:null},ar=function(t){return g("string",t.channelUrl)&&y(e.ChannelType,t.channelType)&&g("number",t.pollId)&&g("number",t.pollOptionId)},or={channelUrl:null,channelType:null,pollId:null},ur=function(t){return g("string",t.channelUrl)&&""!==t.channelUrl&&y(e.ChannelType,t.channelType)&&g("number",t.pollId)},cr={},lr=function(){function t(e,t){var n=t.sdkState,r=t.dispatcher,i=t.sessionManager,s=t.requestQueue,a=t.logger;this._iid=e,this._sdkState=n,this._sessionManager=i,this._requestQueue=s,this._dispatcher=r,this._logger=a,cr[e]=this}return t.of=function(e){return cr[e]},t.prototype.get=function(e){return i(this,void 0,void 0,(function(){var t,n;return s(this,(function(i){switch(i.label){case 0:return ct(ur(e)).throw(f.invalidParameters),t=new Xn(r({},e)),[4,this._requestQueue.send(t)];case 1:return n=i.sent(),[2,n.as(Zn).poll]}}))}))},t.prototype.create=function(e){return i(this,void 0,void 0,(function(){var t,n,i;return s(this,(function(s){switch(s.label){case 0:return ct(ir(e)).throw(f.invalidParameters),t=e.data,n=new Yn(r(r({},e),{data:t})),[4,this._requestQueue.send(n)];case 1:return i=s.sent(),[2,i.as(Jn).poll]}}))}))},t.prototype.getOption=function(e){return i(this,void 0,void 0,(function(){var t,n;return s(this,(function(i){switch(i.label){case 0:return ct(ar(e)).throw(f.invalidParameters),t=new $n(r({},e)),[4,this._requestQueue.send(t)];case 1:return n=i.sent(),[2,n.as(er).pollOption]}}))}))},t.prototype.getPollChangeLogs=function(t,n,r,a){return void 0===a&&(a=e.MessageEventSource.SYNC_POLL_CHANGELOGS),i(this,void 0,void 0,(function(){var e,i,o,u,c,l,h;return s(this,(function(s){switch(s.label){case 0:return e=new tr(D({channelType:n,channelUrl:t,timestamp:"number"==typeof r?r:null,token:"string"==typeof r?r:null})),[4,this._requestQueue.send(e)];case 1:return i=s.sent(),o=i.as(nr),u=o.updatedPolls,c=o.deletedPollIds,l=o.hasMore,h=o.nextToken,u.length>0&&this._dispatcher.dispatch(new Cn({polls:u,source:a})),[2,{updatedPolls:u,deletedPollIds:c,hasMore:l,token:h}]}}))}))},t}(),hr=function(e,t){this.pollId=0,this.messageId=0,this.pollId=t.poll.id,this.messageId=t.poll.message_id,this._iid=e,this._payload=t},dr=function(e){this.pollId=0,this.messageId=0,this.pollId=e.poll_id,this.messageId=e.message_id,this._payload=e},pr=function(e){function t(t){var n=t.channelUrl,r=t.channelType,i=t.token,s=t.limit,a=e.call(this)||this;return a.method=d.GET,a.path=Ie,a.params={channel_url:n,channel_type:r,token:i,limit:s},a}return n(t,e),t}(x),fr=function(e){function t(t,n){var r,i=this;return(i=e.call(this,t,n)||this).polls=(null!==(r=n.polls)&&void 0!==r?r:[]).map((function(e){return new tn(t,e)})),i.token=n.next,i}return n(t,e),t}(F),_r=function(e){function t(t,n){return e.call(this,t,n.channelUrl,n.channelType,n)||this}return n(t,e),t.prototype.next=function(){return i(this,void 0,void 0,(function(){var e,t,n,i,a,o;return s(this,(function(s){switch(s.label){case 0:return this._validate()?this._isLoading?[3,3]:this._hasNext?(this._isLoading=!0,e=wt.of(this._iid).requestQueue,t=new pr(r(r({},this),{token:this._token})),[4,e.send(t)]):[3,2]:[3,5];case 1:return n=s.sent(),i=n.as(fr),a=i.polls,o=i.token,this._token=o,this._hasNext=!!o,this._isLoading=!1,[2,a];case 2:return[2,[]];case 3:throw f.queryInProgress;case 4:return[3,6];case 5:throw f.invalidParameters;case 6:return[2]}}))}))},t}(Bn),vr=function(e){function t(t){var n=t.channelUrl,r=t.channelType,i=t.pollId,s=t.pollOptionId,a=t.token,o=t.limit,u=e.call(this)||this;return u.method=d.GET,u.path="".concat(Ie,"/").concat(encodeURIComponent(i),"/options/").concat(encodeURIComponent(s),"/voters"),u.params={channel_url:n,channel_type:r,token:a,limit:o},u}return n(t,e),t}(x),mr=function(e){function t(t,n){var r,i=this;return(i=e.call(this,t,n)||this).voters=(null!==(r=n.voters)&&void 0!==r?r:[]).map((function(e){return new ht(t,e)})),i.token=n.next,i}return n(t,e),t}(F),gr=function(e){function t(t,n){var r=e.call(this,t,n.channelUrl,n.channelType,n)||this;return r.pollId=n.pollId,r.pollOptionId=n.pollOptionId,r}return n(t,e),t.prototype._validate=function(){return e.prototype._validate.call(this)&&g("number",this.pollId)&&g("number",this.pollOptionId)},t.prototype.next=function(){return i(this,void 0,void 0,(function(){var e,t,n,i,a,o;return s(this,(function(s){switch(s.label){case 0:return this._validate()?this._isLoading?[3,3]:this._hasNext?(this._isLoading=!0,e=wt.of(this._iid).requestQueue,t=new vr(r(r({},this),{pollId:this.pollId,pollOptionId:this.pollOptionId,token:this._token})),[4,e.send(t)]):[3,2]:[3,5];case 1:return n=s.sent(),i=n.as(mr),a=i.voters,o=i.token,this._token=o,this._hasNext=!!o,this._isLoading=!1,[2,a];case 2:return[2,[]];case 3:throw f.queryInProgress;case 4:return[3,6];case 5:throw f.invalidParameters;case 6:return[2]}}))}))},t}(Bn),yr=function(e){function t(){var t=null!==e&&e.apply(this,arguments)||this;return t.name="poll",t}return n(t,e),t.prototype.init=function(t,n){var r=n.sdkState,i=n.dispatcher,s=n.sessionManager,a=n.requestQueue,o=n.logger,u=n.onlineDetector,c=n.cacheContext;e.prototype.init.call(this,t,{sdkState:r,dispatcher:i,sessionManager:s,requestQueue:a,logger:o,onlineDetector:u,cacheContext:c}),this._manager=new lr(t,{sdkState:r,dispatcher:i,sessionManager:s,requestQueue:a,logger:o,onlineDetector:u,cacheContext:c})},t.prototype.create=function(e){return i(this,void 0,void 0,(function(){var t;return s(this,(function(n){return t=r(r({},rr),e),ct(ir(t)).throw(f.invalidParameters),[2,this._manager.create(t)]}))}))},t.prototype.get=function(e){return i(this,void 0,void 0,(function(){var t;return s(this,(function(n){return t=r(r({},or),e),ct(ur(t)).throw(f.invalidParameters),[2,this._manager.get(t)]}))}))},t.prototype.getOption=function(e){return i(this,void 0,void 0,(function(){var t;return s(this,(function(n){return t=r(r({},sr),e),ct(ar(t)).throw(f.invalidParameters),[2,this._manager.getOption(t)]}))}))},t}(At),Er={profileImage:null,profileUrl:null,nickname:null},br=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=J,this.onSessionTokenRequired=function(e){return e(null)},this.onSessionError=J,this.onSessionRefreshed=J,this.onSessionClosed=J})),Cr=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=J,this.onReconnectStarted=J,this.onReconnectSucceeded=J,this.onReconnectFailed=J,this.onDisconnected=J})),Tr=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=J,this.onTotalUnreadMessageCountUpdated=J})),Ir="GroupChannel",Sr=100,Nr="Message";e.GroupChannelListOrder=void 0,(Hn=e.GroupChannelListOrder||(e.GroupChannelListOrder={})).LATEST_LAST_MESSAGE="latest_last_message",Hn.CHRONOLOGICAL="chronological",Hn.CHANNEL_NAME_ALPHABETICAL="channel_name_alphabetical",Hn.METADATA_VALUE_ALPHABETICAL="metadata_value_alphabetical",e.PublicGroupChannelListOrder=void 0,(Vn=e.PublicGroupChannelListOrder||(e.PublicGroupChannelListOrder={})).CHRONOLOGICAL="chronological",Vn.CHANNEL_NAME_ALPHABETICAL="channel_name_alphabetical",Vn.METADATA_VALUE_ALPHABETICAL="metadata_value_alphabetical",e.ScheduledMessageListOrder=void 0,(Kn=e.ScheduledMessageListOrder||(e.ScheduledMessageListOrder={})).CREATED_AT="created_at",Kn.SCHEDULED_AT="scheduled_at";var wr,Mr=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"]}},Ar=function(){function t(){this.messageTypeFilter=e.MessageTypeFilter.ALL,this.customTypesFilter=null,this.senderUserIdsFilter=null,this.replyType=e.ReplyType.NONE}return t.prototype.clone=function(){var e=new t,n=JSON.parse(JSON.stringify(this));return Object.keys(n).forEach((function(t){e[t]=n[t]})),e},t.prototype.match=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 Bt))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 Bt&&t.parentMessageId>0&&!t.replyToChannel)return!1}return!0},t}();!function(e){e.CHANNEL_LATEST="channel_latest",e.NEWEST_CHILD_MESSAGE="newest_child_message"}(wr||(wr={}));var Ur,Or=function(e){switch(e){case wr.CHANNEL_LATEST:return["channelUrl","-createdAt","-messageId"];case wr.NEWEST_CHILD_MESSAGE:return["channelUrl","-parentMessageId","-createdAt","-messageId"]}},Rr={data:null,customType:null,mentionType:e.MentionType.USERS,mentionedUserIds:null,mentionedUsers:null,mentionedMessageTemplate:null,metaArrays:null,parentMessageId:null,isReplyToChannel:!1,pushNotificationDeliveryOption:null,appleCriticalAlertOptions:null},Lr=function(t){return g("string",t.data,!0)&&g("string",t.customType,!0)&&y(e.MentionType,t.mentionType)&&b("string",t.mentionedUserIds,!0)&&b(ht,t.mentionedUsers,!0)&&g("string",t.mentionedMessageTemplate,!0)&&b(xt,t.metaArrays,!0)&&g("number",t.parentMessageId,!0)&&g("boolean",t.isReplyToChannel)&&y(e.PushNotificationDeliveryOption,t.pushNotificationDeliveryOption,!0)&&g(Gt,t.appleCriticalAlertOptions,!0)},kr=function(e){return e?{isReplyToChannel:e.isReplyToChannel,pushNotificationDeliveryOption:e.pushNotificationDeliveryOption,pollId:e.pollId}:null},Dr=r(r({},Rr),{message:null,translationTargetLanguages:null,pollId:null}),Pr=function(e){return Lr(e)&&g("string",e.message)&&b("string",e.translationTargetLanguages,!0)&&g("number",e.pollId,!0)};!function(e){e.FILE="file",e.BLOB="blob",e.BLOB_LIKE_OBJECT="blobLikeObject",e.URL="url"}(Ur||(Ur={}));var xr,Fr=function(e){return"undefined"!=typeof window&&"Blob"in window&&"undefined"!=typeof Blob&&e instanceof Blob},qr=function(e){return e===Ur.BLOB||e===Ur.FILE},Gr=function(e){return e?{file:e.file,fileKey:e.fileKey,fileType:e.fileType,isReplyToChannel:e.isReplyToChannel,pushNotificationDeliveryOption:e.pushNotificationDeliveryOption}:null},Hr=r(r({},Rr),{file:null,fileKey:null,fileUrl:null,fileName:null,fileType:null,fileSize:null,mimeType:null,thumbnailSizes:null,requireAuth:!1}),Vr=function(e){return Lr(e)&&(T(e.file)||g("string",e.fileUrl))&&g("string",e.fileName,!0)&&g("string",e.mimeType,!0)&&g("number",e.fileSize,!0)&&(null===e.thumbnailSizes||Array.isArray(e.thumbnailSizes)&&e.thumbnailSizes.every((function(e){return g("object",e)&&e.maxWidth>0&&e.maxHeight>0})))},Kr=r(r({},Dr),{scheduledAt:null}),Qr=r(r({},Rr),{scheduledAt:null,file:null,fileUrl:null,fileName:null,mimeType:null,fileSize:null,thumbnailSizes:null,requireAuth:!1}),Br="UnsentMessage",jr={},zr=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,jr[t]=s,s}return n(t,e),t.of=function(e){return jr[e]},Object.defineProperty(t.prototype,"collection",{get:function(){var e=this._cacheContext.nestdb;return e&&e.collection(Br)},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 f.invalidParameters;var t,n=r({},e.serialize());return e instanceof nn?(e.messageParams&&(n.messageParams=kr(e.messageParams)),e.scheduledInfo&&e.scheduledInfo.scheduledMessageParams&&(n.scheduledInfo.scheduledMessageParams=(t=e.scheduledInfo.scheduledMessageParams,r(r({},kr(t)),{scheduledAt:t.scheduledAt})))):e instanceof an&&(e.messageParams&&(n.messageParams=Gr(e.messageParams)),e.scheduledInfo&&e.scheduledInfo.scheduledMessageParams&&(n.scheduledInfo.scheduledMessageParams=function(e){return r(r({},Gr(e)),{scheduledAt:e.scheduledAt})}(e.scheduledInfo.scheduledMessageParams))),n},t.prototype._deserialize=function(e){return e?(e=r(r({},e),{messageId:parseInt(e.messageId)}),kn.of(this._iid).buildMessageFromSerializedData(e)):null},t.prototype._deserializeWithMessageCreateParams=function(e){return i(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=kn.of(this._iid),n=this._deserialize(e),e.messageParams?n instanceof nn?(r=e.messageParams,n.messageParams=t.buildUserMessageCreateParamsFromSerializedData(r,n),[3,4]):[3,1]:[3,4];case 1:return n instanceof an?(r=e.messageParams).fileKey&&"string"==typeof r.fileKey&&qr(r.fileType)?(i=r,[4,this.collection.getBlob(r.fileKey)]):[3,3]:[3,4];case 2:i.file=s.sent(),s.label=3;case 3:n.messageParams=t.buildFileMessageCreateParamsFromSerializedData(r,n),s.label=4;case 4:return n.scheduledInfo&&e.scheduledInfo&&e.scheduledInfo.scheduledMessageParams?n instanceof nn?(a=e.scheduledInfo.scheduledMessageParams,n.scheduledInfo.scheduledMessageParams=t.buildScheduledUserMessageCreateParamsFromSerializedData(a,n),[3,8]):[3,5]:[3,8];case 5:return n instanceof an?(a=e.scheduledInfo.scheduledMessageParams).fileKey&&"string"==typeof a.fileKey&&qr(a.fileType)?(o=a,[4,this.collection.getBlob(a.fileKey)]):[3,7]:[3,8];case 6:o.file=s.sent(),s.label=7;case 7:n.scheduledInfo.scheduledMessageParams=t.buildScheduledFileMessageCreateParamsFromSerializedData(a,n),s.label=8;case 8:return[2,n]}}))}))},t.prototype.get=function(e){return i(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,r=e.filter,a=void 0===r?new Ar:r,o=e.order,u=void 0===o?wr.CHANNEL_LATEST:o,c=e.sendingStatus,l=void 0===c?null:c,h=e.backward,d=void 0!==h&&h,p=e.parentMessageId,f=void 0===p?null:p;return i(this,void 0,void 0,(function(){var e,t,r,o,c=this;return s(this,(function(h){switch(h.label){case 0:return this.localCacheEnabled?(e=Or(u),t={"/where":function(e){return!!(u!==wr.NEWEST_CHILD_MESSAGE||f&&0!==e.parentMessageId&&e.parentMessageId===f)&&a.match(c._deserialize(e))}},n&&(t.channelUrl=n),l&&(t.sendingStatus=l),r={where:t,index:e,backward:d},[4,this.collection.query(r)]):[3,3];case 1:return[4,h.sent().fetch({})];case 2:return o=h.sent(),[2,Promise.all(o.map((function(e){return i(c,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 Ar),i(this,void 0,void 0,(function(){return s(this,(function(n){switch(n.label){case 0:return[4,this.fetch({filter:t,order:wr.NEWEST_CHILD_MESSAGE,channelUrl:e.channelUrl,backward:!1,parentMessageId:e.messageId})];case 1:return[2,n.sent()]}}))}))},t.prototype.upsert=function(e){return i(this,void 0,void 0,(function(){var t,n=this;return s(this,(function(r){switch(r.label){case 0:return this.localCacheEnabled?[4,this.saveBlobs(e)]:[3,3];case 1:return r.sent(),t=e.map((function(e){return n._serialize(e)})),[4,this.collection.upsertMany(t)];case 2:r.sent(),r.label=3;case 3:return[2]}}))}))},t.prototype.upsertChildMessages=function(e){return i(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 i(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 i(this,void 0,void 0,(function(){var t,n,r,i,o,u;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=a(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 i=s.sent(),o={error:i},[3,8];case 7:try{n&&!n.done&&(u=t.return)&&u.call(t)}finally{if(o)throw o.error}return[7];case 8:return[2]}}))}))},t.prototype.removeMessagesOfChannel=function(e){return i(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 i(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.saveBlobs=function(e){return i(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 i(t,void 0,void 0,(function(){var t,n,r;return s(this,(function(i){switch(i.label){case 0:return e instanceof an?e.messageParams&&(t=e.messageParams).file&&Fr(t.file)?[4,this.collection.saveBlob(t.file,e.reqId)]:[3,2]:[3,4];case 1:r=i.sent(),t.fileKey=r,t.fileType=Ur.BLOB,i.label=2;case 2:return e.scheduledInfo&&e.scheduledInfo.scheduledMessageParams&&((n=e.scheduledInfo.scheduledMessageParams).file&&Fr(n.file))?[4,this.collection.saveBlob(n.file,e.reqId)]:[3,4];case 3:r=i.sent(),n.fileKey=r,n.fileType=Ur.BLOB,i.label=4;case 4:return[2]}}))}))})))];case 1:return n.sent(),[2]}}))}))},t}(We),Wr={},Yr=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,Wr[t]=a,a}return n(t,e),t.of=function(e){return Wr[e]},Object.defineProperty(t.prototype,"collection",{get:function(){var e=this._cacheContext.nestdb;return e?e.collection(Nr):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 r(r({},e.serialize()),{messageId:"".concat(e.messageId)})},t.prototype._deserialize=function(e){return e=r(r({},e),{messageId:parseInt(e.messageId)}),kn.of(this._iid).buildMessageFromSerializedData(e)},t.prototype.get=function(e){return i(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,r=e.limit,a=void 0===r?Sr:r,o=e.filter,u=void 0===o?new Ar:o,c=e.order,l=void 0===c?wr.CHANNEL_LATEST:c,h=e.backward,d=void 0!==h&&h,p=e.parentMessageId,f=void 0===p?null:p,_=e.isPollOnly,v=void 0!==_&&_;return i(this,void 0,void 0,(function(){var e,r,o,c=this;return s(this,(function(h){switch(h.label){case 0:return this.localCacheEnabled?(e=Or(l),r={where:{channelUrl:t,"/where":function(e){if(n)switch(l){case wr.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 i(this,void 0,void 0,(function(){var t,n,r,i,o,u;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=a(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 i=s.sent(),o={error:i},[3,8];case 7:try{n&&!n.done&&(u=t.return)&&u.call(t)}finally{if(o)throw o.error}return[7];case 8:return[2]}}))}))},t.prototype.removeMessagesOfChannel=function(e){return i(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:Or(wr.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 i(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:Or(wr.CHANNEL_LATEST)})]:[3,2];case 1:n.sent(),n.label=2;case 2:return[2]}}))}))},t.prototype.clear=function(){return i(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 i(this,void 0,void 0,(function(){var r,i=this;return s(this,(function(s){switch(s.label){case 0:return this.localCacheEnabled?(r=Or(wr.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 i(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 i(t,void 0,void 0,(function(){var t,n;return s(this,(function(r){switch(r.label){case 0:return e instanceof an&&e.messageParams&&((t=e.messageParams).file&&Fr(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}(We),Jr=function(e){function t(){var t=e.call(this)||this;return t._pauseDelayTimer=null,t._currentState="visible",t._toggleState=t._toggleState.bind(t),t}return n(t,e),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;"hidden"!==document.visibilityState?"hidden"===this._currentState&&(this._pauseDelayTimer&&(clearTimeout(this._pauseDelayTimer),this._pauseDelayTimer=null),this.dispatch("resume")):"hidden"!==this._currentState&&(this._pauseDelayTimer=setTimeout((function(){e._pauseDelayTimer=null,e.dispatch("pause")}),3e4)),this._currentState=document.visibilityState},t.prototype.start=function(){this.isAvailable&&window.addEventListener("visibilitychange",this._toggleState,{capture:!0})},t.prototype.stop=function(){this.isAvailable&&window.removeEventListener("visibilitychange",this._toggleState,{capture:!0})},t}(R),Xr=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 i(this,void 0,void 0,(function(){return s(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}(),Zr=function(e){function t(t){var n=t.message,r=e.call(this)||this;return r.message=n,r}return n(t,e),t}(k),$r={},ei=function(){function t(e,t){var n=t.localCacheEnabled,r=t.dispatcher,i=t.sdkState,s=t.logger,a=this;$r[e]=this,this._iid=e,$r[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 he)switch(e.stateType){case X.CONNECTED:a._isProcessingAutoResend||a.processAutoResendRegisteredPendingMessages().then((function(){return a._processNextAutoResend()}));break;case X.DISCONNECTED:a._isProcessingAutoResend=!1}}))}return t.of=function(e){return $r[e]},t.prototype.processNonAutoResendRegisteredPendingMessages=function(){return i(this,void 0,void 0,(function(){var t,n,r,i,o,u;return s(this,(function(s){switch(s.label){case 0:return[4,this._fetchAllCachedPendingMessages()];case 1:t=s.sent();try{for(n=a(t),r=n.next();!r.done;r=n.next())0===(i=r.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=c.ACK_TIMEOUT,this._dispatcher.dispatch(new yn({messages:[i],source:e.MessageEventSource.LOCAL_MESSAGE_FAILED})))}catch(e){o={error:e}}finally{try{r&&!r.done&&(u=n.return)&&u.call(n)}finally{if(o)throw o.error}}return[2]}}))}))},t.prototype.processAutoResendRegisteredPendingMessages=function(){return i(this,void 0,void 0,(function(){var t,n,r,i,o,u,c,l;return s(this,(function(s){switch(s.label){case 0:return[4,this._fetchAllCachedPendingMessages()];case 1:t=s.sent();try{for(n=a(t),r=n.next();!r.done;r=n.next())(i=r.value).errorCode&&C(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 yn({messages:[i],source:e.MessageEventSource.LOCAL_MESSAGE_FAILED}))))}catch(e){c={error:e}}finally{try{r&&!r.done&&(l=n.return)&&l.call(n)}finally{if(c)throw c.error}}return[2]}}))}))},t.prototype.completeCurrentAndProcessNextAutoResend=function(t){if(this._localCacheEnabled&&(t.sendingStatus===e.SendingStatus.SUCCEEDED||t.sendingStatus===e.SendingStatus.FAILED&&!C(t.errorCode))){var n=this.indexOf(t);n>=0&&this._autoResendQueue.splice(n,1),0===n&&this._processNextAutoResend()}},t.prototype._fetchAllCachedPendingMessages=function(){return i(this,void 0,void 0,(function(){var t,n;return s(this,(function(r){switch(r.label){case 0:return(t=zr.of(this._iid))?[4,t.fetch({sendingStatus:e.SendingStatus.PENDING,backward:!0})]:[3,2];case 1:return n=r.sent(),[3,3];case 2:n=[],r.label=3;case 3:return[2,n]}}))}))},t.prototype.indexOf=function(e){return this._autoResendQueue.length>0?this._autoResendQueue.map((function(e){return e.reqId})).indexOf(e.reqId):-1},t.prototype._isNotInQueue=function(e){return-1===this._autoResendQueue.map((function(e){return e.reqId})).indexOf(e.reqId)},t.prototype._processNextAutoResend=function(){return i(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 Zr({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]}))}))},t}();!function(e){e[e.USER_BLOCK=20001]="USER_BLOCK",e[e.USER_UNBLOCK=2e4]="USER_UNBLOCK",e[e.FRIEND_DISCOVERED=20900]="FRIEND_DISCOVERED"}(xr||(xr={}));var ti=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 ht(e,r),blockee:new ht(e,i)}},e.getDataAsFriendDiscoveredEvent=function(e,t){var n=t.data.friend_discoveries;return{friendDiscoveries:Array.isArray(n)?n.map((function(t){return new ht(e,t)})):[]}},e}(),ni=function(e){function t(t,n){var r=n.userId,i=e.call(this)||this;return i._iid=t,i.userId=r,i}return n(t,e),t}(k),ri=function(e){function t(t,n,r){var i=e.call(this,t,"USEV",r)||this;return i.event=new ti(r),i}return n(t,e),t}(j),ii=function(e){function t(t){var n=t.userId,r=t.nickname,i=void 0===r?null:r,s=t.profileUrl,a=void 0===s?null:s,o=t.profileImage,u=void 0===o?null:o,c=t.preferredLanguages,l=void 0===c?null:c,h=e.call(this)||this;return h.method=d.PUT,h.path="".concat(fe,"/").concat(encodeURIComponent(n)),h.params=D({nickname:i,profile_url:a,profile_file:u,preferred_languages:l}),h}return n(t,e),t}(x),si=function(e){function t(t,n){var i=e.call(this,t,n)||this;return i.user=null,i.user=new ht(t,r({},n)),i}return n(t,e),t}(F),ai=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(fe,"/").concat(encodeURIComponent(n),"/push/apns"),i.params={apns_device_token:r,always_push:!0},i}return n(t,e),t}(x);!function(t){function r(n,r){var i=t.call(this,n,r)||this;return i.token=r.token,i.type=r.type?e.PushTokenType[r.type.toLowerCase()]:e.PushTokenType.UNKNOWN,i.user=new ht(n,r.user),i}n(r,t)}(F);var oi=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(fe,"/").concat(encodeURIComponent(n),"/push/gcm"),i.params={gcm_reg_token:r,always_push:!0},i}return n(t,e),t}(x);!function(t){function r(n,r){var i=t.call(this,n,r)||this;return i.token=r.token,i.type=r.type?e.PushTokenType[r.type.toLowerCase()]:e.PushTokenType.UNKNOWN,i.user=new ht(n,r.user),i}n(r,t)}(F);var ui=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(fe,"/").concat(encodeURIComponent(n),"/push/apns/").concat(encodeURIComponent(r)),i}return n(t,e),t}(x);!function(e){function t(t,n){var r=e.call(this,t,n)||this;return r.token=n.token,r.user=new ht(t,n.user),r}n(t,e)}(F);var ci=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(fe,"/").concat(encodeURIComponent(n),"/push/gcm/").concat(encodeURIComponent(r)),i}return n(t,e),t}(x);!function(e){function t(t,n){var r=e.call(this,t,n)||this;return r.token=n.token,r.user=new ht(t,n.user),r}n(t,e)}(F);var li=function(e){function t(t){var n=t.userId,r=e.call(this)||this;return r.method=d.DELETE,r.path="".concat(fe,"/").concat(encodeURIComponent(n),"/push/apns"),r}return n(t,e),t}(x);!function(t){function r(n,r){var i=t.call(this,n,r)||this;return i.type=r.type?e.PushTokenType[r.type.toLowerCase()]:e.PushTokenType.UNKNOWN,i.user=new ht(n,r.user),i}n(r,t)}(F);var hi=function(e){function t(t){var n=t.userId,r=e.call(this)||this;return r.method=d.DELETE,r.path="".concat(fe,"/").concat(encodeURIComponent(n),"/push/gcm"),r}return n(t,e),t}(x);!function(t){function r(n,r){var i=t.call(this,n,r)||this;return i.type=r.type?e.PushTokenType[r.type.toLowerCase()]:e.PushTokenType.UNKNOWN,i.user=new ht(n,r.user),i}n(r,t)}(F);var di=function(e){function t(t){var n=t.userId,r=t.type,i=t.token,s=t.ts,a=e.call(this)||this;return a.method=d.GET,a.path="".concat(fe,"/").concat(encodeURIComponent(n),"/push/").concat(encodeURIComponent(r),"/device_tokens"),a.params={created_ts:s,token:i},a}return n(t,e),t}(x),pi=function(t){function r(n,r){var i=t.call(this,n,r)||this;return i.pushTokens={type:r.type?e.PushTokenType[r.type.toLowerCase()]:e.PushTokenType.UNKNOWN,deviceTokens:r.device_tokens,hasMore:r.has_more,token:r.token},i}return n(r,t),r}(F),fi=function(e){function t(t){var n=t.userId,r=e.call(this)||this;return r.method=d.GET,r.path="".concat(fe,"/").concat(encodeURIComponent(n),"/channel_invitation_preference"),r}return n(t,e),t}(x),_i=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}(F),vi=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(fe,"/").concat(encodeURIComponent(n),"/channel_invitation_preference"),i.params={auto_accept:r},i}return n(t,e),t}(x),mi=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}(F),gi=function(e){function t(t){var n=t.userId,r=e.call(this)||this;return r.method=d.GET,r.path="".concat(fe,"/").concat(encodeURIComponent(n),"/push_preference"),r}return n(t,e),t}(x),yi=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}(F),Ei=function(e){function t(t){var n=t.userId,r=t.doNotDisturbOn,i=t.startHour,s=t.startMin,a=t.endHour,o=t.endMin,u=t.timezone,c=e.call(this)||this;return c.method=d.PUT,c.path="".concat(fe,"/").concat(encodeURIComponent(n),"/push_preference"),c.params={do_not_disturb:r,start_hour:i,start_min:s,end_hour:a,end_min:o,timezone:u},c}return n(t,e),t}(x),bi=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}(F),Ci=function(e){function t(t){var n=t.userId,r=e.call(this)||this;return r.method=d.GET,r.path="".concat(fe,"/").concat(encodeURIComponent(n),"/push_preference"),r}return n(t,e),t}(x),Ti=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}(F),Ii=function(e){function t(t){var n=t.userId,r=t.snoozeOn,i=t.startTs,s=t.endTs,a=e.call(this)||this;return a.method=d.PUT,a.path="".concat(fe,"/").concat(encodeURIComponent(n),"/push_preference"),a.params={snooze_enabled:r,snooze_start_ts:i,snooze_end_ts:s},a}return n(t,e),t}(x),Si=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}(F),Ni=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(fe,"/").concat(encodeURIComponent(n),"/block"),i.params={target_id:r},i}return n(t,e),t}(x);!function(e){function t(t,n){var r=e.call(this,t,n)||this;return r.user=new ht(t,n),r}n(t,e)}(F);var wi=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(fe,"/").concat(encodeURIComponent(n),"/block/").concat(encodeURIComponent(r)),i}return n(t,e),t}(x);!function(e){function t(){return null!==e&&e.apply(this,arguments)||this}n(t,e)}(F);var Mi=function(e){function t(t){var n=t.userId,r=e.call(this)||this;return r.method=d.GET,r.path="".concat(fe,"/").concat(encodeURIComponent(n),"/push_preference"),r}return n(t,e),t}(x),Ai=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}(F),Ui=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(fe,"/").concat(encodeURIComponent(n),"/push_preference"),i.params={push_trigger_option:r},i}return n(t,e),t}(x),Oi=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}(F),Ri=function(e){function t(t){var n=t.userId,r=e.call(this)||this;return r.method=d.GET,r.path="".concat(fe,"/").concat(encodeURIComponent(n),"/push/template"),r}return n(t,e),t}(x),Li=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}(F),ki=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(fe,"/").concat(encodeURIComponent(n),"/push/template"),i.params={name:r},i}return n(t,e),t}(x),Di=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}(F),Pi=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(fe,"/").concat(encodeURIComponent(n),"/friends/changelogs"),i.params={token:r},i}return n(t,e),t}(x),xi=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 ht(t,e)})),updatedUsers:n.updated.map((function(e){return new ht(t,e)})),deletedUserIds:n.deleted,hasMore:n.has_more,token:n.next},r}return n(t,e),t}(F),Fi=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(fe,"/").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}(x),qi=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}(F),Gi=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(fe,"/").concat(encodeURIComponent(n),"/friend_discoveries"),i.params={friend_discovery_keys:r},i}return n(t,e),t}(x);!function(e){function t(){return null!==e&&e.apply(this,arguments)||this}n(t,e)}(F);var Hi=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(fe,"/").concat(encodeURIComponent(n),"/friends"),i.params={user_ids:r},i}return n(t,e),t}(x),Vi=function(e){function t(t,n){var r=e.call(this,t,n)||this;return r.users=n.users.map((function(e){return new ht(t,e)})),r}return n(t,e),t}(F),Ki=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(fe,"/").concat(encodeURIComponent(n),"/friends"),i.params={user_ids:r},i}return n(t,e),t}(x);!function(e){function t(){return null!==e&&e.apply(this,arguments)||this}n(t,e)}(F);var Qi=function(e){function t(t){var n=t.userId,r=e.call(this)||this;return r.method=d.GET,r.path="".concat(fe,"/").concat(n,"/allow_friend_discovery"),r.params={},r}return n(t,e),t}(x),Bi=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}(F),ji=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(fe,"/").concat(n,"/allow_friend_discovery"),i.params={allow_friend_discovery:r},i}return n(t,e),t}(x);!function(e){function t(){return null!==e&&e.apply(this,arguments)||this}n(t,e)}(F);var zi,Wi=function(e){this.key=null,this.url=null,this.key=e.key,this.url=e.url},Yi=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 Wi(e)})):[]},Ji=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 Yi(e)})):[]},Xi=function(e){function t(){var t=e.call(this)||this;return t.method=d.GET,t.path=Te,t}return n(t,e),t}(x),Zi=function(e){function t(t,n){var r=e.call(this,t,n)||this;return r.emojiContainer=new Ji(n),r}return n(t,e),t}(F),$i=function(e){function t(t){var n=t.categoryId,r=e.call(this)||this;return r.method=d.GET,r.path="".concat(Te,"/").concat(n),r}return n(t,e),t}(x),es=function(e){function t(t,n){var r=e.call(this,t,n)||this;return r.emojiCategory=new Yi(n),r}return n(t,e),t}(F),ts=function(e){function t(t){var n=t.key,r=e.call(this)||this;return r.method=d.GET,r.path="".concat(Ce,"/").concat(n),r}return n(t,e),t}(x),ns=function(e){function t(t,n){var r=e.call(this,t,n)||this;return r.emoji=new Wi(n),r}return n(t,e),t}(F),rs=function(e){function t(t){var n=t.limit,r=t.token,i=t.userIdsFilter,s=t.metaDataKeyFilter,a=t.metaDataValuesFilter,o=t.nicknameStartsWithFilter,u=e.call(this)||this;return u.method=d.GET,u.path=fe,u.params=D({limit:n,token:r,user_ids:i,metadatakey:s,metadatavalues_in:a,nickname_startswith:o}),u}return n(t,e),t}(x),is=function(e){function t(t,n){var r=e.call(this,t,n)||this;return r.users=n.users.map((function(e){return new ht(t,e)})),r.next=n.next,r}return n(t,e),t}(F),ss=function(e){function t(t,n){var r,i,s,a=this;return(a=e.call(this,t,n)||this).userIdsFilter=null,a.metaDataKeyFilter=null,a.metaDataValuesFilter=null,a.nicknameStartsWithFilter=null,a.userIdsFilter=null!==(r=n.userIdsFilter)&&void 0!==r?r:null,a.metaDataKeyFilter=null!==(i=n.metaDataKeyFilter)&&void 0!==i?i:null,a.metaDataValuesFilter=null!==(s=n.metaDataValuesFilter)&&void 0!==s?s:null,a.nicknameStartsWithFilter=n.nicknameStartsWithFilter||null,a}return n(t,e),t.prototype._validate=function(){return e.prototype._validate.call(this)&&b("string",this.userIdsFilter,!0)&&g("string",this.metaDataKeyFilter,!0)&&b("string",this.metaDataValuesFilter,!0)&&g("string",this.metaDataKeyFilter,!0)},t.prototype.next=function(){return i(this,void 0,void 0,(function(){var e,t,n,i,a,o;return s(this,(function(s){switch(s.label){case 0:return this._validate()?this._isLoading?[3,3]:this._hasNext?(this._isLoading=!0,e=wt.of(this._iid).requestQueue,t=new rs(r(r({},this),{token:this._token})),[4,e.send(t)]):[3,2]:[3,5];case 1:return n=s.sent(),i=n.as(is),a=i.users,o=i.next,this._token=o,this._hasNext=!!o,this._isLoading=!1,[2,a];case 2:return[2,[]];case 3:throw f.queryInProgress;case 4:return[3,6];case 5:throw f.invalidParameters;case 6:return[2]}}))}))},t}(Fn),as=function(e){function t(t){var n=t.userId,r=t.limit,i=t.token,s=t.userIdsFilter,a=e.call(this)||this;return a.method=d.GET,a.path="".concat(fe,"/").concat(n,"/block"),a.params=D({limit:r,token:i,user_ids:s}),a}return n(t,e),t}(x),os=function(e){function t(t,n){var r=e.call(this,t,n)||this;return r.users=n.users.map((function(e){return new ht(t,e)})),r.next=n.next,r}return n(t,e),t}(F),us=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)&&b("string",this.userIdsFilter,!0)},t.prototype.next=function(){return i(this,void 0,void 0,(function(){var e,t,n,i,a,o,u,c;return s(this,(function(s){switch(s.label){case 0:return this._validate()?this._isLoading?[3,3]:this._hasNext?(this._isLoading=!0,e=wt.of(this._iid),t=e.sdkState,n=e.requestQueue,i=new as(r(r({},this),{userId:t.userId,token:this._token})),[4,n.send(i)]):[3,2]:[3,5];case 1:return a=s.sent(),o=a.as(os),u=o.users,c=o.next,this._token=c,this._hasNext=!!c,this._isLoading=!1,[2,u];case 2:return[2,[]];case 3:throw f.queryInProgress;case 4:return[3,6];case 5:throw f.invalidParameters;case 6:return[2]}}))}))},t}(Fn),cs=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(fe,"/").concat(encodeURIComponent(n),"/friends"),s.params={limit:r,token:i},s}return n(t,e),t}(x),ls=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 ht(t,e)})),r.next=n.next,r}return n(t,e),t}(F),hs=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 i(this,void 0,void 0,(function(){var e,t,n,i,a,o,u,c,l;return s(this,(function(s){switch(s.label){case 0:return this._validate()?this._isLoading?[3,3]:this._hasNext?(this._isLoading=!0,e=wt.of(this._iid),t=e.sdkState,n=e.requestQueue,i=new cs(r(r({},this),{userId:t.userId,token:this._token})),[4,n.send(i)]):[3,2]:[3,5];case 1:return a=s.sent(),o=a.as(ls),u=o.users,c=o.hasMore,l=o.next,this._token=l,this._hasNext=c,this._isLoading=!1,[2,u];case 2:return[2,[]];case 3:throw f.queryInProgress;case 4:return[3,6];case 5:throw f.invalidParameters;case 6:return[2]}}))}))},t}(Fn),ds={},ps=function(){function e(e){var t=e.dbname,n=e.itemSizeLimit,r=void 0===n?1048576:n,i=e.cacheLimit,s=void 0===i?256:i,a=e.blockHashBase,o=void 0===a?2:a,u=e.blockHashMultiplier,c=void 0===u?10:u,l=e.blockHashConstant,h=void 0===l?11:l,d=e.transactionApplyDelay,p=void 0===d?200:d,f=e.disableLogger,_=void 0!==f&&f;return ds[t]||(this.itemSizeLimit=r,this.cacheLimit=s,this.blockHashBase=o,this.blockHashMultiplier=c,this.blockHashConstant=h,this.transactionApplyDelay=p,this.disableLogger=_,ds[t]=this),ds[t]}return e.get=function(e){return ds[e]},e}();!function(e){e[e.UNKNOWN_ERROR=6e7]="UNKNOWN_ERROR",e[e.STORE_NOT_DEFINED=61001e3]="STORE_NOT_DEFINED",e[e.STORE_NOT_AVAILABLE=61001001]="STORE_NOT_AVAILABLE",e[e.STORE_NOT_AVAILABLE_IN_PRIVATE_BROWSING=61001002]="STORE_NOT_AVAILABLE_IN_PRIVATE_BROWSING",e[e.STORE_IS_FULL=61001003]="STORE_IS_FULL",e[e.STORE_INVALID_KEY_TYPE=61002e3]="STORE_INVALID_KEY_TYPE",e[e.STORE_BROKEN_INTEGRITY=61002001]="STORE_BROKEN_INTEGRITY",e[e.STORE_BROKEN_BLOB=61002002]="STORE_BROKEN_BLOB",e[e.STORE_ENCRYPTION_INVALID=61002003]="STORE_ENCRYPTION_INVALID",e[e.STORE_ITEM_SIZE_LIMIT_EXCEEDED=61017e3]="STORE_ITEM_SIZE_LIMIT_EXCEEDED",e[e.STORE_READ_FAILED=61017001]="STORE_READ_FAILED",e[e.STORE_WRITE_FAILED=61017002]="STORE_WRITE_FAILED",e[e.DATABASE_SCHEMA_NOT_ON_UPGRADE=62002e3]="DATABASE_SCHEMA_NOT_ON_UPGRADE",e[e.COLLECTION_NOT_READY=63001e3]="COLLECTION_NOT_READY",e[e.COLLECTION_KEY_NOT_MATCH=63002e3]="COLLECTION_KEY_NOT_MATCH",e[e.COLLECTION_QUERY_NOT_VALID=63002001]="COLLECTION_QUERY_NOT_VALID",e[e.COLLECTION_KEY_NOT_FOUND=63004e3]="COLLECTION_KEY_NOT_FOUND",e[e.COLLECTION_KEY_NOT_GIVEN=63004001]="COLLECTION_KEY_NOT_GIVEN",e[e.COLLECTION_INSERT_DUPLICATE=63009e3]="COLLECTION_INSERT_DUPLICATE",e[e.COLLECTION_WRITE_FAILED=63017e3]="COLLECTION_WRITE_FAILED",e[e.COLLECTION_ITEM_SIZE_LIMIT_EXCEEDED=63017001]="COLLECTION_ITEM_SIZE_LIMIT_EXCEEDED",e[e.INDEX_TABLE_IS_REQUIRED=65001e3]="INDEX_TABLE_IS_REQUIRED",e[e.INDEX_TYPE_NOT_MATCH=65002e3]="INDEX_TYPE_NOT_MATCH",e[e.COMPARE_TYPE_NOT_MATCH=69002001]="COMPARE_TYPE_NOT_MATCH",e[e.CIRCULAR_REFERENCE_FOUND=69002002]="CIRCULAR_REFERENCE_FOUND"}(zi||(zi={}));var fs,_s=function(e){function t(n){var r=n.code,i=void 0===r?zi.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 n(t,e),Object.defineProperty(t,"storeNotDefined",{get:function(){return new t({code:zi.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:zi.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:zi.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:zi.STORE_IS_FULL,message:"Store is full."})},enumerable:!1,configurable:!0}),Object.defineProperty(t,"storeKeyTypeIsInvalid",{get:function(){return new t({code:zi.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:zi.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:zi.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:zi.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:zi.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:zi.STORE_READ_FAILED,message:"Failed to read from store."})},enumerable:!1,configurable:!0}),Object.defineProperty(t,"storeWriteFailed",{get:function(){return new t({code:zi.STORE_WRITE_FAILED,message:"Failed to write to store."})},enumerable:!1,configurable:!0}),Object.defineProperty(t,"databaseSchemaNotOnUpgrade",{get:function(){return new t({code:zi.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:zi.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:zi.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:zi.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:zi.COLLECTION_INSERT_DUPLICATE,message:"The key already exists."})},enumerable:!1,configurable:!0}),Object.defineProperty(t,"collectionKeyNotFound",{get:function(){return new t({code:zi.COLLECTION_KEY_NOT_FOUND,message:"The key is not found."})},enumerable:!1,configurable:!0}),Object.defineProperty(t,"collectionKeyNotGiven",{get:function(){return new t({code:zi.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:zi.COLLECTION_WRITE_FAILED,message:"Failed to write an item."})},enumerable:!1,configurable:!0}),Object.defineProperty(t,"collectionItemSizeExceeded",{get:function(){return new t({code:zi.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:zi.INDEX_TABLE_IS_REQUIRED,message:"Index table is required."})},enumerable:!1,configurable:!0}),Object.defineProperty(t,"indexTypesNotMatch",{get:function(){return new t({code:zi.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:zi.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:zi.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"}(fs||(fs={}));var vs,ms=function(e,t){if(void 0===t&&(t=new WeakMap),"object"==typeof e&&null!==e){if(t.has(e))throw _s.circularReferenceFound;t.set(e,!0);var n=null;if(Array.isArray(e))n=e.map((function(e){return ms(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]=ms(e[r],t);return t.delete(e),n}return e},gs=function(e,t){if(null==t)return 1;if(null==e)return-1;if(typeof e!=typeof t)throw _s.compareTypesNotMatch;var n=0;switch(typeof e){case"boolean":case"number":n=e-t;break;case"string":n=e.localeCompare(t)}return n},ys=function(e,t){for(var n=0,r=0;r>>0)%t},Es=function(e){return new Promise((function(t){setTimeout((function(){return t()}),e)}))},bs=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!bs(e,t)})))return!1}else if(["/or","||"].includes(n)){if(e[n].every((function(e){return!bs(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(!(gs(a,o)>0))return!1;break;case"/gte":case">=":a=t[r],o=i[s];if(!(gs(a,o)>=0))return!1;break;case"/lt":case"<":a=t[r],o=i[s];if(!(gs(a,o)<0))return!1;break;case"/lte":case"<=":a=t[r],o=i[s];if(!(gs(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)},Cs=function(){},Ts=function(){return Promise.resolve()},Is=function(e){return e},Ss=function(e,t){t(null)};!function(e){e[e.FORWARD=0]="FORWARD",e[e.BACKWARD=1]="BACKWARD"}(vs||(vs={}));var Ns,ws,Ms,As=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?Is:a,u=e.backward,c=void 0===u?Ts:u,l=e.forward,h=void 0===l?Ts:l,d=e.complete,p=void 0===d?Cs:d;this._prevValue=n,this._nextValue=i,this._error=null,this._map=o,this._backward=c,this._forward=h,this._iterator=s,this._complete=p}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 i(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 i(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}(),Us=function(){function e(e){var t=e.condition,n=void 0===t?{}:t,r=e.backward,i=void 0!==r&&r,s=e.blockManager,a=e.indexer;this.condition=n,this.backward=i,this._blockManager=s,this._indexer=a}return e.prototype.findOptimizedStartPosition=function(){var e=this,t=["=","/eq",">",">=","/gt","/gte"],n=["=","/eq","<","<=","/lt","/lte"];if(this.backward){var r=this._indexer.origin.length-1;if("function"!=typeof this.condition)for(var i in this._indexer.fields){var s=this._indexer.fields[i],a=1;if("-"===s[0]&&(s=s.slice(1),a=-1),this.condition[s])if("object"==typeof this.condition[s]){var o=a>0?n:t;for(var u in this.condition[s])if(o.includes(u))for(var c=r;c>=0;c--)if(a*gs(this._indexer.origin[c].columnValues[i],this.condition[s][u])<=0){r=c;break}}else for(c=r;c>=0;c--)if(a*gs(this._indexer.origin[c].columnValues[i],this.condition[s])<=0){r=c;break}}return Math.min(r+1,this._indexer.origin.length-1)}var l=0;if("function"!=typeof this.condition)for(var h=function(r){var i=d._indexer.fields[r],s=1;if("-"===i[0]&&(i=i.slice(1),s=-1),d.condition[i])if("object"==typeof d.condition[i])Object.keys(d.condition[i]).forEach((function(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;i0){for(var r=Math.ceil(e.data.length/n),i="".concat(r,".").concat(e.type,".").concat(t),s=[],a=0;a0))return[3,6];u=0,s.label=1;case 1:return u0))return[3,2];for(a=0;a-1){var r=this._items[n];return t===Ms.PERSISTENT&&(r.state=ws.PERSISTENT),t!==Ms.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)qs.includes(this._items[r].state)&&qs.includes(e.state)?(this._items.splice(r,1),this._items.push(e)):(this._items[r].state=e.state,this._items[r].generation=e.generation,this._items[r].value=e.value);else{this._items.push(e);var i=this._items.filter((function(e){return e.state===ws.VOLATILE})),s=i.length-this._limit;if(s>0){var o=[];try{for(var u=a(this._items),c=u.next();!c.done;c=u.next()){var l=c.value;l.state===ws.VOLATILE&&s>0?s--:o.push(l)}}catch(e){t={error:e}}finally{try{c&&!c.done&&(n=u.return)&&n.call(u)}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!==ws.VOLATILE}))},e}(),Vs=function(){function e(e){var t=e.dbname,n=e.collectionName,r=e.store;this._metadata=null,this._requests=[],this._onCommit=new Map,this._onWrite=new Map,this._onError=new Map,this.dbname=t,this.collectionName=n,this.metadataKey=function(e,t){return"".concat(Ls(e,t),"/trans.metadata")}(t,n),this.recordsetKey=function(e,t){return"".concat(Ls(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=[]),i(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,u([],o(e),!1)),[2,this._reduceRecordSet(t)]}}))}))},e.prototype._reduceRecordSet=function(e){for(var t=[],n={},r=e.length-1;r>=0;r--){for(var i=e[r],s=[],a=i.requests.length-1;a>=0;a--){var o=i.requests[a],u=o.data;n[u.key]||(s.unshift(o),n[u.key]=!0)}s.length>0&&(i.requests=s,t.unshift(i))}return t},e.prototype._applyRecord=function(e,t){return i(this,void 0,void 0,(function(){var n,i,a,o,u,c,l,h,d;return s(this,(function(s){switch(s.label){case 0:n=Hs.get(this.dbname),i=t.generation,a=t.requests,o=null,s.label=1;case 1:return s.trys.push([1,3,,4]),[4,this._store.setMany(a.map((function(e){return r(r({},e.data),{generation:i})})))];case 2:for(u=s.sent(),c=0;c0))return[3,4];for(t=[],n={},c=e.length-1;c>=0;c--)i=e[c],h=i.data,n[h.key]||(n[h.key]=!0,t.unshift(i));return a={generation:this.generation,requests:t},[4,this._getReducedRecordset([a])];case 1:return o=s.sent(),[4,this._store.set({key:this.recordsetKey,value:o,generation:this.generation})];case 2:return s.sent(),this._metadata.generation++,[4,this._store.set({key:this.metadataKey,value:this._metadata,generation:1})];case 3:for(s.sent(),u=Hs.get(this.dbname),c=0;c0?(r=this.createBlockId(e,n),[4,t.find(this._store,r)]):[3,4];case 2:if((i=s.sent())&&(a=Ks.createFromCacheItem(i),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 i(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 i(this,void 0,void 0,(function(){var n,r,i,a,o;return s(this,(function(s){switch(s.label){case 0:return n=ps.get(this.dbname),r=this.createBlockId(e),i=Math.floor(this._store.itemSizeLimit/n.itemSizeLimit),[4,Hs.get(this.dbname).find(this._store,r)];case 1:return a=s.sent(),(o=a?Ks.createFromCacheItem(a):new Ks({blockId:r,keyName:this.keyName,items:[],limit:i})).add(t)?(this._transaction.requestWrite({key:o.blockId,value:o.serialize()}),[2,!0]):[2,!1]}}))}))},e.prototype.removeFromBlock=function(e){return i(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 i(this,void 0,void 0,(function(){var e,t,n,r,i,o,u,c,l;return s(this,(function(s){switch(s.label){case 0:return e=Ds(this.dbname,this.collectionName),[4,this._store.getAllKeys()];case 1:return t=s.sent(),n=t.filter((function(t){return t.startsWith(e)})),[4,this._store.removeMany(n)];case 2:s.sent(),r=Hs.get(this.dbname);try{for(i=a(n),o=i.next();!o.done;o=i.next())u=o.value,r.remove(u)}catch(e){c={error:e}}finally{try{o&&!o.done&&(l=i.return)&&l.call(i)}finally{if(c)throw c.error}}return[2]}}))}))},e}(),Bs=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=[],this.dbname=t,this.collectionName=n,this.keyName=r,this.fields=i,this.indexerKey=function(e,t,n){return"".concat(Ls(e,t),"/index.").concat(n)}(this.dbname,this.collectionName,this.fields.join(">")),this._transaction=s,this._store=a,this._transaction.on(Ns.COMMIT,this.indexerKey,(function(){return o.commit()})),this._transaction.on(Ns.ERROR,this.indexerKey,(function(){return o.abort()}))}return e.createKey=function(e){return e.join(">")},e.parseKey=function(e){return e.split(">")},e.prototype._addItem=function(e){var t=e[this.keyName],n=this.getColumnValues(e),r=o(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=o(this.indexOf(n),2),i=r[0];if(r[1]){var s=this._table[i].keys.indexOf(t);if(s>-1)return this._table[i].keys.splice(s,1),0===this._table[i].keys.length&&this._table.splice(i,1),!0}return!1},Object.defineProperty(e.prototype,"origin",{get:function(){return this._origin},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"table",{get:function(){return this._table},enumerable:!1,configurable:!0}),e.prototype.getColumnValues=function(e){var t,n,r,i,s=[];try{for(var o=a(this.fields),u=o.next();!u.done;u=o.next()){var c=u.value;if("-"===c[0]&&(c=c.slice(1)),r=e[c],i=void 0,i=typeof r,null!==r&&"undefined"!==i&&"boolean"!==i&&"number"!==i&&"string"!==i)throw _s.indexTypesNotMatch;s.push(e[c])}}catch(e){t={error:e}}finally{try{u&&!u.done&&(n=o.return)&&n.call(o)}finally{if(t)throw t.error}}return s},e.prototype.diff=function(e,t){for(var n in this.fields){var r="-"===this.fields[n][0]?-1:1,i=gs(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 i(this,void 0,void 0,(function(){var e,t,n,r,i,o,u,c,l,h,d,p,f,_,v,m,g;return s(this,(function(s){switch(s.label){case 0:return[4,(e=Hs.get(this.dbname)).find(this._store,this.indexerKey,Ms.PERSISTENT)];case 1:return(t=s.sent())?[3,11]:(n=Ds(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]),i=a(r),o=i.next(),s.label=4;case 4:return o.done?[3,7]:(u=o.value).startsWith(n)?[4,e.find(this._store,u,Ms.NO_CACHE)]:[3,6];case 5:c=s.sent(),l=Ks.createFromCacheItem(c);try{for(m=void 0,h=a(l.items),d=h.next();!d.done;d=h.next())p=d.value,this._addItem(p)}catch(e){m={error:e}}finally{try{d&&!d.done&&(g=h.return)&&g.call(h)}finally{if(m)throw m.error}}s.label=6;case 6:return o=i.next(),[3,4];case 7:return[3,10];case 8:return f=s.sent(),_={error:f},[3,10];case 9:try{o&&!o.done&&(v=i.return)&&v.call(i)}finally{if(_)throw _.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=ms(this._origin),s.label=12;case 12:return[2]}}))}))},e.prototype.drop=function(){return i(this,void 0,void 0,(function(){return s(this,(function(e){switch(e.label){case 0:return Hs.get(this.dbname).remove(this.indexerKey),[4,this._store.remove(this.indexerKey)];case 1:return e.sent(),[2]}}))}))},e.prototype.addItem=function(e){return i(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 i(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 i(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=ms(this._origin)},e.prototype.abort=function(){this._table=ms(this._origin)},e}(),js="undefined"!=typeof document&&"undefined"!=typeof navigator;js&&navigator.userAgent&&navigator.userAgent.includes("Chrome/")&&navigator.userAgent.includes("Chromium/");var zs=js&&navigator.userAgent&&navigator.userAgent.includes("Firefox/")&&!navigator.userAgent.includes("Seamonkey/");js&&navigator.userAgent&&navigator.userAgent.includes("Safari/")&&!navigator.userAgent.includes("Chrome/")&&navigator.userAgent.includes("Chromium/"),js&&navigator.userAgent&&(navigator.userAgent.includes("OPR/")||navigator.userAgent.includes("Opera/")),js&&navigator.userAgent&&navigator.userAgent.includes("Trident/7.0");var Ws,Ys,Js=js&&navigator.userAgent&&navigator.userAgent.includes("Edge/"),Xs=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"}(Ws||(Ws={})),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"}(Ys||(Ys={}));var Zs,$s={},ea=function(){function e(e,t){void 0===t&&(t={});var n=this;return this._state=Ws.PROCESSING,this._hostId=null,this._queue=[],this._currentItem=null,this._activationTimeout=null,this._activationQueue=[],$s[e]&&!t.forceCreate||(this.nodeId=Xs(),this.key=e,js&&(t.startAsInvisible?this.registerNode():"visible"===document.visibilityState?this.claimHost():this.registerNode(),document.addEventListener("visibilitychange",(function(){"visible"===document.visibilityState&&n.claimHost()})),window.addEventListener("message",(function(e){var t,r,i=e.data,s=i.nodeId,o=i.requestId,u=i.key,c=i.op,l=i.data;if(s!==n.nodeId&&u===n.key)switch(c){case Ys.NEWNODE:n._sendSync();break;case Ys.CLAIM_HOST:n._sendSync(),n._hostId=s;break;case Ys.SYNC_HOST:if(!n.isInSync){n._activationTimeout&&clearTimeout(n._activationTimeout);var h=l,d=h.currentItemRequestId,p=h.queue,f=function(e){var t=n._queue.findIndex((function(t){return t.requestId===e.requestId}));t<0&&n._requestLock({nodeId:e.nodeId,requestId:e.requestId,key:n.key,op:Ys.REQUEST_LOCK,ts:e.ts})};try{for(var _=a(p),v=_.next();!v.done;v=_.next()){f(v.value)}}catch(e){t={error:e}}finally{try{v&&!v.done&&(r=_.return)&&r.call(_)}finally{if(t)throw t.error}}n._currentItem=n._queue.find((function(e){return e.requestId===d})),n._completeSync()}break;case Ys.REMOVENODE:n._queue=n._queue.filter((function(e){return e.nodeId!==i.nodeId})),n._currentItem&&n._currentItem.nodeId===i.nodeId&&(n._currentItem=null,n._acquire(n._queue[0]));break;case Ys.REQUEST_LOCK:n._requestLock(i);break;case Ys.ACQUIRE_LOCK:var m=n._queue.find((function(e){return e.requestId===o}));n._acquire(m);break;case Ys.RELEASE_LOCK:n._release(o)}})),window.addEventListener("beforeunload",(function(){n._send(Ys.REMOVENODE)}))),$s[e]=this),$s[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==Ws.DONE},enumerable:!1,configurable:!0}),e.prototype._send=function(e,t){var n,r;void 0===t&&(t={});var i={nodeId:this.nodeId,requestId:null!==(n=null==t?void 0:t.requestId)&&void 0!==n?n:Xs(),key:this.key,op:e,data:null!==(r=t.data)&&void 0!==r?r:null,ts:Date.now()};return js&&window.postMessage(i,"*"),i},e.prototype._acquire=function(e){void 0===e&&(e=null),e?(this._currentItem=e,this._currentItem.onAcquired(e.requestId)):this._currentItem=null},e.prototype._release=function(e){if(this._currentItem&&this._currentItem.requestId===e){var t=this._currentItem;this._currentItem=null,t.nodeId===this.nodeId&&this._send(Ys.RELEASE_LOCK,{requestId:t.requestId});var n=this._queue.findIndex((function(t){return t.requestId===e}));n>-1&&this._queue.splice(n,1),t.onReleased(e)}},e.prototype._requestLock=function(e){var t=this;return new Promise((function(n){var r={nodeId:e.nodeId,requestId:e.requestId,ts:e.ts,onAcquired:function(e){t.isHost&&t._send(Ys.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(Ys.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 i(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=Ws.DONE,this._activationQueue.forEach((function(e){return e()})),this._activationQueue=[])},e.prototype.registerNode=function(){this._send(Ys.NEWNODE),this._waitSync()},e.prototype.claimHost=function(){this._hostId=this.nodeId,this._send(Ys.CLAIM_HOST),this._waitSync()},e.prototype.lock=function(){return i(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(Ys.REQUEST_LOCK),[4,this._requestLock(e)];case 2:return t.sent(),[2]}}))}))},e.prototype.unlock=function(){var e;this._release(null===(e=this._currentItem)||void 0===e?void 0:e.requestId)},e}(),ta=function(){function e(e){var t=e.dbname,n=e.collectionName,r=e.keyName,i=e.keyHash,s=e.indexes,a=e.store,c=this;this._state=fs.INIT,this._metadata=null,this._indexers=[],this.dbname=t,this.name=n,this.keyName=r,this.indexes=u([[r]],o(s.filter((function(e){return Bs.createKey(e)!==c.keyName}))),!1),this._keyHash=i,this._store=a,this._mutex=new ea(function(e,t){return"".concat(Ls(e,t),".lock")}(t,n)),this._blobContainer=new Fs({dbname:t,collectionName:n,store:a}),this._transaction=new Vs({dbname:t,collectionName:n,store:a})}return e.metadataOf=function(e,t,n){return i(this,void 0,void 0,(function(){var r;return s(this,(function(i){switch(i.label){case 0:return r=ks(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===fs.READY},enumerable:!1,configurable:!0}),e.prototype.init=function(){return i(this,void 0,void 0,(function(){var t,n,r,i,c,l,h,d,p,f,_,v,m,g,y=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=ps.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 Qs({dbname:this.dbname,collectionName:this.name,hashFunction:this._keyHash,metadata:this._metadata,transaction:this._transaction,store:this._store}),r=u([],o(this.indexes),!1),i=[],c=r.map((function(e){return Bs.createKey(e)})),l=n?n.indexes.map((function(e){return Bs.createKey(e)})):[];try{for(h=a(l),d=h.next();!d.done;d=h.next())p=d.value,c.includes(p)||i.push(Bs.parseKey(p))}catch(e){m={error:e}}finally{try{d&&!d.done&&(g=h.return)&&g.call(h)}finally{if(m)throw m.error}}return(f=[]).push.apply(f,u([],o(r.map((function(e){var t=new Bs({dbname:y.dbname,collectionName:y.name,keyName:y.keyName,fields:e,transaction:y._transaction,store:y._store});return y._indexers.push(t),t.ensure()}))),!1)),f.push.apply(f,u([],o(i.map((function(e){return new Bs({dbname:y.dbname,collectionName:y.name,keyName:y.keyName,fields:e,transaction:y._transaction,store:y._store}).drop()}))),!1)),[4,Promise.all(f)];case 5:return s.sent(),[4,this._transaction.commit()];case 6:return s.sent(),c.sort().join(",")===l.sort().join(",")?[3,8]:(_=ks(this.dbname,this.name),this._metadata.indexes=r,[4,this._store.set({key:_,value:this._metadata,generation:1})]);case 7:s.sent(),s.label=8;case 8:return this._state=fs.READY,this._mutex.unlock(),[3,10];case 9:throw v=s.sent(),this._mutex.unlock(),v;case 10:return[2]}}))}))},e.prototype.close=function(){this._state=fs.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=Bs.createKey(e);try{for(var i=a(this._indexers),s=i.next();!s.done;s=i.next()){var o=s.value;if(r===Bs.createKey(o.fields))return o}}catch(e){t={error:e}}finally{try{s&&!s.done&&(n=i.return)&&n.call(i)}finally{if(t)throw t.error}}return null},e.prototype._upgradeBlockLevel=function(){return i(this,void 0,void 0,(function(){var e;return s(this,(function(t){switch(t.label){case 0:return e=ks(this.dbname,this.name),this._metadata.blockLevel++,[4,this._store.set({key:e,value:this._metadata,generation:1})];case 1:return t.sent(),[2]}}))}))},e.prototype._requestInsert=function(e){return i(this,void 0,void 0,(function(){var t,n,r,i,o,u;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=a(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 i=s.sent(),o={error:i},[3,12];case 11:try{r&&!r.done&&(u=n.return)&&u.call(n)}finally{if(o)throw o.error}return[7];case 12:return[3,14];case 13:throw _s.collectionInsertDuplicate;case 14:return[2]}}))}))},e.prototype._requestUpsert=function(e){return i(this,void 0,void 0,(function(){var t,n,r,i,o,u,c,l,h,d,p,f,_;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=a(this._indexers),i=r.next(),s.label=6;case 6:return i.done?[3,9]:[4,(l=i.value).addItem(e)];case 7:s.sent(),s.label=8;case 8:return i=r.next(),[3,6];case 9:return[3,12];case 10:return o=s.sent(),d={error:o},[3,12];case 11:try{i&&!i.done&&(p=r.return)&&p.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]),u=a(this._indexers),c=u.next(),s.label=16;case 16:return c.done?[3,20]:0===(l=c.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 c=u.next(),[3,16];case 20:return[3,23];case 21:return h=s.sent(),f={error:h},[3,23];case 22:try{c&&!c.done&&(_=u.return)&&_.call(u)}finally{if(f)throw f.error}return[7];case 23:return[2]}}))}))},e.prototype._requestUpdate=function(e){return i(this,void 0,void 0,(function(){var t,n,r,i,o,u,c,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=a(this._indexers),i=r.next(),s.label=4;case 4:return i.done?[3,8]:0===(o=i.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 i=r.next(),[3,4];case 8:return[3,11];case 9:return u=s.sent(),c={error:u},[3,11];case 10:try{i&&!i.done&&(l=r.return)&&l.call(r)}finally{if(c)throw c.error}return[7];case 11:return[2]}}))}))},e.prototype._requestRemove=function(e){return i(this,void 0,void 0,(function(){var t,n,r,i,o,u;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=a(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 i=s.sent(),o={error:i},[3,10];case 9:try{r&&!r.done&&(u=n.return)&&u.call(n)}finally{if(o)throw o.error}return[7];case 10:return[2]}}))}))},e.prototype._requestClear=function(){return i(this,void 0,void 0,(function(){var e,t,n,r,i;return s(this,(function(s){switch(s.label){case 0:return[4,this._blockManager.clearAllBlocks()];case 1:s.sent(),s.label=2;case 2:s.trys.push([2,7,8,9]),e=a(this._indexers),t=e.next(),s.label=3;case 3:return t.done?[3,6]:[4,t.value.clear()];case 4:s.sent(),s.label=5;case 5:return t=e.next(),[3,3];case 6:return[3,9];case 7:return n=s.sent(),r={error:n},[3,9];case 8:try{t&&!t.done&&(i=e.return)&&i.call(e)}finally{if(r)throw r.error}return[7];case 9:return[2]}}))}))},e.prototype.getByKey=function(e){return i(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,ms(t)];case 4:throw n=r.sent(),this._mutex.unlock(),n;case 5:return[3,7];case 6:throw _s.collectionNotReady;case 7:return[2]}}))}))},e.prototype.query=function(e){return void 0===e&&(e={}),this.isReady?new Os({condition:e.where,mutex:this._mutex,blockManager:this._blockManager,indexer:this._getIndexerBy(e.index),backward:!!e.backward}):null},e.prototype.insertOne=function(e){return i(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 _s.collectionKeyNotGiven;return[4,this._requestInsert(ms(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 _s.collectionNotReady;case 9:return[2]}}))}))},e.prototype.insertMany=function(e){return i(this,void 0,void 0,(function(){var t,n,r,i,o,u,c,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 _s.collectionKeyNotGiven;s.label=3;case 3:s.trys.push([3,8,9,10]),t=a(e),n=t.next(),s.label=4;case 4:return n.done?[3,7]:(r=n.value,[4,this._requestInsert(ms(r))]);case 5:s.sent(),s.label=6;case 6:return n=t.next(),[3,4];case 7:return[3,10];case 8:return i=s.sent(),u={error:i},[3,10];case 9:try{n&&!n.done&&(c=t.return)&&c.call(t)}finally{if(u)throw u.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 _s.collectionNotReady;case 16:return[2]}}))}))},e.prototype.upsertOne=function(e){return i(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 _s.collectionKeyNotGiven;return[4,this._requestUpsert(ms(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 _s.collectionNotReady;case 9:return[2]}}))}))},e.prototype.upsertMany=function(e){return i(this,void 0,void 0,(function(){var t,n,r,i,o,u,c,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 _s.collectionKeyNotGiven;s.label=3;case 3:s.trys.push([3,8,9,10]),t=a(e),n=t.next(),s.label=4;case 4:return n.done?[3,7]:(r=n.value,[4,this._requestUpsert(ms(r))]);case 5:s.sent(),s.label=6;case 6:return n=t.next(),[3,4];case 7:return[3,10];case 8:return i=s.sent(),u={error:i},[3,10];case 9:try{n&&!n.done&&(c=t.return)&&c.call(t)}finally{if(u)throw u.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 _s.collectionNotReady;case 16:return[2]}}))}))},e.prototype.update=function(e){return i(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 _s.collectionKeyNotGiven;return[4,this._requestUpdate(ms(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 _s.collectionNotReady;case 9:return[2]}}))}))},e.prototype.updateIf=function(e,t){return i(this,void 0,void 0,(function(){var n,r,o,u,c,l,h,d,p,f,_,v,m,g,y=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,r=void 0===n?{}:n,o=e.index,u=void 0===o?null:o,c=e.backward,l=void 0!==c&&c,h=[],[4,new Us({condition:r,blockManager:this._blockManager,backward:l,indexer:this._getIndexerBy(u)}).each((function(e){return i(y,void 0,void 0,(function(){var n,i;return s(this,(function(s){if(e.error)throw e.stop(),e.error;if(e.hasNext){if(n=e.nextValue,bs(r,n)&&t.set){if("function"!=typeof t.set)for(i in t.set)n[i]=t.set[i];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=a(h),p=d.next(),E.label=5;case 5:return p.done?[3,8]:(f=p.value,[4,this._requestUpdate(ms(f))]);case 6:E.sent(),E.label=7;case 7:return p=d.next(),[3,5];case 8:return[3,11];case 9:return _=E.sent(),m={error:_},[3,11];case 10:try{p&&!p.done&&(g=d.return)&&g.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 v=E.sent(),[4,this._transaction.clear()];case 14:throw E.sent(),this._mutex.unlock(),v;case 15:return[3,17];case 16:throw this._transaction.clear(),_s.collectionNotReady;case 17:return[2]}}))}))},e.prototype.remove=function(e){return i(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 _s.collectionNotReady;case 9:return[2]}}))}))},e.prototype.removeIf=function(e){return i(this,void 0,void 0,(function(){var t,n,r,o,u,c,l,h,d,p,f,_,v,m,g=this;return s(this,(function(y){switch(y.label){case 0:return this.isReady?[4,this._mutex.lock()]:[3,15];case 1:y.sent(),y.label=2;case 2:return y.trys.push([2,13,,14]),t=e.where,n=void 0===t?{}:t,r=e.index,o=void 0===r?null:r,u=e.backward,c=void 0!==u&&u,l=[],[4,new Us({condition:n,blockManager:this._blockManager,backward:c,indexer:this._getIndexerBy(o)}).each((function(e){return i(g,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,bs(n,t)&&(r=t[this.keyName],l.push(r)),e.next()):e.stop(),[2]}))}))}))];case 3:y.sent(),y.label=4;case 4:y.trys.push([4,9,10,11]),h=a(l),d=h.next(),y.label=5;case 5:return d.done?[3,8]:(p=d.value,[4,this._requestRemove(p)]);case 6:y.sent(),y.label=7;case 7:return d=h.next(),[3,5];case 8:return[3,11];case 9:return f=y.sent(),v={error:f},[3,11];case 10:try{d&&!d.done&&(m=h.return)&&m.call(h)}finally{if(v)throw v.error}return[7];case 11:return[4,this._transaction.commit()];case 12:return y.sent(),this._mutex.unlock(),[2,l];case 13:throw _=y.sent(),this._mutex.unlock(),_;case 14:return[3,16];case 15:throw this._transaction.clear(),_s.collectionNotReady;case 16:return[2]}}))}))},e.prototype.clear=function(){return i(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 _s.collectionNotReady;case 9:return[2]}}))}))},e.prototype.getBlob=function(e){return i(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 void 0===t&&(t=null),i(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 i(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 i(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}(),na={},ra=function(){function e(e){void 0===e&&(e={});var t=e.itemSizeLimit,n=void 0===t?4194304:t,r=e.delay,i=void 0===r?1:r,s=e.encryption,a=void 0===s?N:s;this._encryption=a,this.itemSizeLimit=n,this.delay=i,this.observer={}}return Object.defineProperty(e.prototype,"rawData",{get:function(){return na[this.dbname]},set:function(e){na[this.dbname]=e},enumerable:!1,configurable:!0}),e.prototype.observe=function(e,t,n){var r=this;this.observer[e]={},t.forEach((function(t){return r.observer[e][t]=n}))},e.prototype.init=function(e){return i(this,void 0,void 0,(function(){var t;return s(this,(function(n){switch(n.label){case 0:this.dbname=e,na[this.dbname]={},n.label=1;case 1:return n.trys.push([1,,3,5]),[4,this.get(S.key)];case 2:if((t=n.sent())&&JSON.stringify(t)!==JSON.stringify(S.value))throw _s.storeEncryptionInvalid;return[3,5];case 3:return[4,this.set(S)];case 4:return n.sent(),[7];case 5:return[2]}}))}))},e.prototype.getAllKeys=function(){return i(this,void 0,void 0,(function(){return s(this,(function(e){return[2,Object.keys(na[this.dbname]).filter((function(e){return e!==S.key}))]}))}))},e.prototype.get=function(e){return i(this,void 0,void 0,(function(){var t;return s(this,(function(n){switch(n.label){case 0:return[4,this.getRaw(e)];case 1:return[2,(t=n.sent())?this._encryption.decrypt(t):null]}}))}))},e.prototype.getRaw=function(e){return i(this,void 0,void 0,(function(){var t,n;return s(this,(function(r){switch(r.label){case 0:return[4,Es(this.delay)];case 1:if(r.sent(),t=this.observer[e],n=t&&t.get?t.get(e):null)throw n;return[2,na[this.dbname][e]]}}))}))},e.prototype.set=function(e){return i(this,void 0,void 0,(function(){var t,n,r,i,a,o;return s(this,(function(s){switch(s.label){case 0:return[4,Es(this.delay)];case 1:if(s.sent(),t=e.key,n=e.value,r=this.observer[t],i=r&&r.set?r.set(t):null)throw i;if(a=this._encryption.encrypt(n),o=JSON.stringify(a),t===S.key||o.length0&&(r.mutedUsers=s.map((function(e){return new fa(t,e)}))),r}return n(t,e),t}(F),Sa=function(e){function t(t,n,r,i){return e.call(this,t,n,r,i)||this}return n(t,e),t.prototype.next=function(){return i(this,void 0,void 0,(function(){var e,t,n,i,a,o;return s(this,(function(s){switch(s.label){case 0:return this._validate()?this._isLoading?[3,3]:this._hasNext?(this._isLoading=!0,e=wt.of(this._iid).requestQueue,t=new Ta(r(r({},this),{token:this._token})),[4,e.send(t)]):[3,2]:[3,5];case 1:return n=s.sent(),i=n.as(Ia),a=i.mutedUsers,o=i.token,this._token=o,this._hasNext=!!o,this._isLoading=!1,[2,a];case 2:return[2,[]];case 3:throw f.queryInProgress;case 4:return[3,6];case 5:throw f.invalidParameters;case 6:return[2]}}))}))},t}(Bn),Na=function(e){function t(t){var n=this,r=t.channelUrl,i=t.channelType,s=t.limit,a=t.token;return(n=e.call(this)||this).method=d.GET,n.path="".concat(Je(i),"/").concat(encodeURIComponent(r),"/ban"),n.params=D({limit:s,token:a}),n}return n(t,e),t}(x),wa=function(e){function t(t,n){var r=e.call(this,t,n)||this;r.token=null,r.bannedUsers=[];var i=n.next,s=n.banned_list;return r.token=i,s&&s.length>0&&(r.bannedUsers=s.map((function(e){return new fa(t,e.user)}))),r}return n(t,e),t}(F),Ma=function(e){function t(t,n,r,i){return e.call(this,t,n,r,i)||this}return n(t,e),t.prototype._validate=function(){return e.prototype._validate.call(this)},t.prototype.next=function(){return i(this,void 0,void 0,(function(){var e,t,n,i,a,o;return s(this,(function(s){switch(s.label){case 0:return this._validate()?this._isLoading?[3,3]:this._hasNext?(this._isLoading=!0,e=wt.of(this._iid).requestQueue,t=new Na(r(r({},this),{token:this._token})),[4,e.send(t)]):[3,2]:[3,5];case 1:return n=s.sent(),i=n.as(wa),a=i.bannedUsers,o=i.token,this._token=o,this._hasNext=!!o,this._isLoading=!1,[2,a];case 2:return[2,[]];case 3:throw f.queryInProgress;case 4:return[3,6];case 5:throw f.invalidParameters;case 6:return[2]}}))}))},t}(Bn);e.ReportCategory=void 0,(da=e.ReportCategory||(e.ReportCategory={})).SPAM="spam",da.HARASSING="harassing",da.SUSPICIOUS="suspicious",da.INAPPROPRIATE="inappropriate";var Aa=function(e){function t(t){var n=this,r=t.channelUrl,i=t.channelType,s=t.operatorUserIds;return(n=e.call(this)||this).method=d.POST,n.path="".concat(Je(i),"/").concat(encodeURIComponent(r),"/operators"),n.params={operator_ids:s},n}return n(t,e),t}(x);!function(e){function t(){return null!==e&&e.apply(this,arguments)||this}n(t,e)}(F);var Ua=function(e){function t(t){var n=this,r=t.channelUrl,i=t.channelType,s=t.operatorUserIds;return(n=e.call(this)||this).method=d.DELETE,n.path="".concat(Je(i),"/").concat(encodeURIComponent(r),"/operators"),n.params={operator_ids:s},n}return n(t,e),t}(x);!function(e){function t(t,n){return e.call(this,t,n)||this}n(t,e)}(F);var Oa=function(e){function t(t){var n=this,r=t.channelUrl,i=t.channelType,s=t.userId;return(n=e.call(this)||this).method=d.GET,n.path="".concat(Je(i),"/").concat(encodeURIComponent(r),"/mute/").concat(s),n}return n(t,e),t}(x),Ra=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,s=n.start_at,a=n.end_at,o=n.remaining_duration,u=n.description;return r.isMuted=i,r.startAt=s,r.endAt=a,r.remainingDuration=o,r.description=u,r}return n(t,e),t}(F),La=function(e){function t(t){var n=this,r=t.channelUrl,i=t.channelType,s=t.keys;return(n=e.call(this)||this).method=d.GET,n.path="".concat(Je(i),"/").concat(encodeURIComponent(r),"/metadata"),n.params={keys:s,include_ts:!0},n}return n(t,e),t}(x),ka=function(e){function t(t,n){var r=e.call(this,t,n)||this;r.ts=null;var i=n.metadata,s=n.ts;return r.metadata=i,r.ts=null!=s?s:null,r}return n(t,e),t}(F),Da=function(e){function t(t){var n=this,r=t.channelUrl,i=t.channelType,s=t.metadata,a=t.upsert;return(n=e.call(this)||this).method=d.PUT,n.path="".concat(Je(i),"/").concat(encodeURIComponent(r),"/metadata"),n.params={metadata:s,include_ts:!0,upsert:null!=a&&a},n}return n(t,e),t}(x),Pa=function(e){function t(t,n){var r=e.call(this,t,n)||this;r.ts=null;var i=n.metadata,s=n.ts;return r.metadata=i,r.ts=null!=s?s:null,r}return n(t,e),t}(F),xa=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 n(t,e),t}(j),Fa=function(e){function t(t){var n=this,r=t.channelUrl,i=t.channelType,s=t.key;return(n=e.call(this)||this).method=d.DELETE,n.path="".concat(Je(i),"/").concat(encodeURIComponent(r),"/metadata/").concat(s),n.params={include_ts:!0},n}return n(t,e),t}(x),qa=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 n(t,e),t}(F),Ga=function(e){function t(t){var n=this,r=t.channelUrl,i=t.channelType;return(n=e.call(this)||this).method=d.PUT,n.path="".concat(Je(i),"/").concat(encodeURIComponent(r),"/metadata"),n.params={include_ts:!0},n}return n(t,e),t}(x),Ha=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 n(t,e),t}(F),Va=function(e){function t(t){var n=this,r=t.channelUrl,i=t.channelType,s=t.keys;return(n=e.call(this)||this).method=d.GET,n.path="".concat(Je(i),"/").concat(encodeURIComponent(r),"/metacounter"),n.params={keys:s},n}return n(t,e),t}(x),Ka=function(e){function t(t,n){var r=e.call(this,t,n)||this;return r.metaCounter=n,r}return n(t,e),t}(F),Qa=function(e){function t(t){var n=this,r=t.channelUrl,i=t.channelType,s=t.metaCounter;return(n=e.call(this)||this).method=d.POST,n.path="".concat(Je(i),"/").concat(encodeURIComponent(r),"/metacounter"),n.params={metacounter:s},n}return n(t,e),t}(x),Ba=function(e){function t(t,n){var r=e.call(this,t,n)||this;return r.metaCounter=n,r}return n(t,e),t}(F),ja=function(e){function t(t){var n=this,r=t.channelUrl,i=t.channelType,s=t.metaCounter,a=t.upsert,o=void 0!==a&&a,u=t.mode,c=void 0===u?"set":u;return(n=e.call(this)||this).method=d.PUT,n.path="".concat(Je(i),"/").concat(encodeURIComponent(r),"/metacounter"),n.params={metacounter:s,upsert:o,mode:c},n}return n(t,e),t}(x),za=function(e){function t(t,n){var r=e.call(this,t,n)||this;return r.metaCounter=n,r}return n(t,e),t}(F),Wa=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 n(t,e),t}(j),Ya=function(e){function t(t){var n=this,r=t.channelUrl,i=t.channelType,s=t.key;return(n=e.call(this)||this).method=d.DELETE,n.path="".concat(Je(i),"/").concat(encodeURIComponent(r),"/metacounter/").concat(s),n.params=null,n}return n(t,e),t}(x);!function(e){function t(t,n){return e.call(this,t,n)||this}n(t,e)}(F);var Ja=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(Je(i),"/").concat(encodeURIComponent(r),"/metacounter"),n.params=null,n}return n(t,e),t}(x);!function(e){function t(){return null!==e&&e.apply(this,arguments)||this}n(t,e)}(F);var Xa=function(e){function t(t){var n=this,r=t.channelUrl,i=t.channelType,s=t.userId,a=t.seconds,o=t.description;return(n=e.call(this)||this).method=d.POST,n.path="".concat(Je(i),"/").concat(encodeURIComponent(r),"/mute"),n.params={user_id:s,seconds:a,description:o},n}return n(t,e),t}(x);!function(e){function t(t,n){return e.call(this,t,n)||this}n(t,e)}(F);var Za=function(e){function t(t,n,r){var i=e.call(this,t,"SYEV",r)||this;return i.user=new fa(t,r.data),i}return n(t,e),t}(j),$a=function(e){function t(t){var n=this,r=t.channelUrl,i=t.channelType,s=t.userId;return(n=e.call(this)||this).method=d.DELETE,n.path="".concat(Je(i),"/").concat(encodeURIComponent(r),"/mute/").concat(encodeURIComponent(s)),n}return n(t,e),t}(x);!function(e){function t(){return null!==e&&e.apply(this,arguments)||this}n(t,e)}(F);var eo=function(e){function t(t,n,r){var i=e.call(this,t,"SYEV",r)||this;return i.user=new fa(t,r.data),i}return n(t,e),t}(j),to=function(e){function t(t){var n=this,r=t.channelUrl,i=t.channelType,s=t.userId,a=t.seconds,o=t.description;return(n=e.call(this)||this).method=d.POST,n.path="".concat(Je(i),"/").concat(encodeURIComponent(r),"/ban"),n.params=D({user_id:s,seconds:a,description:o}),n}return n(t,e),t}(x);!function(e){function t(){return null!==e&&e.apply(this,arguments)||this}n(t,e)}(F);var no=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 fa(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 n(t,e),t}(j),ro=function(e){function t(t){var n=this,r=t.channelUrl,i=t.channelType,s=t.userId;return(n=e.call(this)||this).method=d.DELETE,n.path="".concat(Je(i),"/").concat(encodeURIComponent(r),"/ban/").concat(encodeURIComponent(s)),n}return n(t,e),t}(x);!function(e){function t(){return null!==e&&e.apply(this,arguments)||this}n(t,e)}(F);var io=function(e){function t(t,n,r){var i=e.call(this,t,"SYEV",r)||this;return i.user=new fa(t,r.data),i}return n(t,e),t}(j),so=function(e){function t(t){var n=this,r=t.channelUrl,i=t.channelType,s=t.freezing;return(n=e.call(this)||this).method=d.PUT,n.path="".concat(Je(i),"/").concat(encodeURIComponent(r),"/freeze"),n.params={freeze:s},n}return n(t,e),t}(x);!function(e){function t(){return null!==e&&e.apply(this,arguments)||this}n(t,e)}(F);var ao=function(e){function t(t,n,r){var i=e.call(this,t,"SYEV",r)||this;return i.freeze=r.data.freeze,i}return n(t,e),t}(j),oo=function(e){function t(t){var n=this,r=t.channelUrl,i=t.channelType,s=t.category,a=t.userId,o=t.description;return(n=e.call(this)||this).method=d.POST,n.path="".concat(Xe(i),"/").concat(encodeURIComponent(r)),n.params={report_category:s,reporting_user_id:a,report_description:o},n}return n(t,e),t}(x),uo=function(t){function r(n){var r=this,i=n.channelUrl,s=n.channelType,a=n.category,o=n.userId,u=n.offendingUserId,c=n.description;return(r=t.call(this)||this).method=d.POST,r.path="".concat(be,"/users/").concat(u),r.params={channel_url:i,channel_type:s===e.ChannelType.OPEN?"open_channels":"group_channels",report_category:a,reporting_user_id:o,report_description:c},r}return n(r,t),r}(x),co=function(e){function t(t){var n=this,r=t.channelUrl,i=t.channelType,s=t.category,a=t.userId,o=t.offendingUserId,u=t.messageId,c=t.description;return(n=e.call(this)||this).method=d.POST,n.path="".concat(Xe(i),"/").concat(encodeURIComponent(r),"/messages/").concat(u),n.params={report_category:s,reporting_user_id:a,report_description:c,offending_user_id:o},n}return n(t,e),t}(x),lo=function(t){function r(n){var r=[];return n.mentionType===e.MentionType.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:D({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!==e.PushNotificationDeliveryOption.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})})||this}return n(r,t),r}(z),ho=function(e){function t(t,n,r){var i,s,a,o=this;(o=e.call(this,t,"MESG",r)||this).message=new nn(t,r);var u=wt.of(t).sdkState;return o.isMentioned=Ze(o.message.mentionType,null!==(i=o.message.mentionedUserIds)&&void 0!==i?i:null===(s=o.message.mentionedUsers)||void 0===s?void 0:s.map((function(e){return e.userId})),u.userId),o.forceUpdateLastMessage=null!==(a=r.force_update_last_message)&&void 0!==a&&a,o}return n(t,e),t}(j),po=function(t){function r(n){var r=[];return n.mentionType===e.MentionType.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:D({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,poll_id:n.pollId})})||this}return n(r,t),r}(z),fo=function(e){function t(t,n,r){var i,s,a,o,u,c,l=this;(l=e.call(this,t,"MEDI",r)||this).message=new nn(t,r);var h=wt.of(t).sdkState;return l.mentionCountChange=$e({mentionType:null!==(s=null===(i=r.old_values)||void 0===i?void 0:i.mention_type)&&void 0!==s?s:null,mentionedUserIds:null!==(o=null===(a=r.old_values)||void 0===a?void 0:a.mentioned_user_ids)&&void 0!==o?o:[]},{mentionType:l.message.mentionType,mentionedUserIds:null!==(u=l.message.mentionedUserIds)&&void 0!==u?u:null===(c=l.message.mentionedUsers)||void 0===c?void 0:c.map((function(e){return e.userId}))},h.userId),l}return n(t,e),t}(j),_o=function(t){function r(n){var r=[];return n.mentionType===e.MentionType.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:D({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 n(r,t),r}(z),vo=function(e){function t(t,n,r){var i,s,a,o,u,c,l=this;(l=e.call(this,t,"FEDI",r)||this).message=new an(t,r);var h=wt.of(t).sdkState;return l.mentionCountChange=$e({mentionType:null!==(s=null===(i=r.old_values)||void 0===i?void 0:i.mention_type)&&void 0!==s?s:null,mentionedUserIds:null!==(o=null===(a=r.old_values)||void 0===a?void 0:a.mentioned_user_ids)&&void 0!==o?o:[]},{mentionType:l.message.mentionType,mentionedUserIds:null!==(u=l.message.mentionedUserIds)&&void 0!==u?u:null===(c=l.message.mentionedUsers)||void 0===c?void 0:c.map((function(e){return e.userId}))},h.userId),l}return n(t,e),t}(j),mo=function(e){function t(t){var n=e.call(this)||this;return n.method=d.DELETE,n.path="".concat(Je(t.channelType),"/").concat(t.channelUrl,"/messages/").concat(t.messageId),n}return n(t,e),t}(x);!function(e){function t(){return null!==e&&e.apply(this,arguments)||this}n(t,e)}(F);var go,yo=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 n(t,e),t}(j),Eo=function(e){function t(t){var n=t.channelType,r=t.channelUrl,i=t.messageId,s=t.reactionKey,a=e.call(this)||this;return a.method=d.POST,a.path="".concat(Je(n),"/").concat(encodeURIComponent(r),"/messages/").concat(i,"/reactions"),a.params={reaction:s},a}return n(t,e),t}(x),bo=function(e){function t(t,n){var r=e.call(this,t,n)||this;return r.reactionEvent=new Dt(n),r}return n(t,e),t}(F),Co=function(e){function t(t){var n=t.channelType,r=t.channelUrl,i=t.messageId,s=t.reactionKey,a=e.call(this)||this;return a.method=d.DELETE,a.path="".concat(Je(n),"/").concat(encodeURIComponent(r),"/messages/").concat(i,"/reactions"),a.params={reaction:s},a}return n(t,e),t}(x),To=function(e){function t(t,n){var i=e.call(this,t,n)||this;return i.reactionEvent=new Dt(r({},n)),i}return n(t,e),t}(F),Io=function(e){function t(t){var n=t.channelType,r=t.channelUrl,i=t.messageId,s=t.translationTargetLanguages,a=e.call(this)||this;return a.method=d.POST,a.path="".concat(Je(n),"/").concat(encodeURIComponent(r),"/messages/").concat(encodeURIComponent(i),"/translation"),a.params={target_langs:s},a}return n(t,e),t}(x),So=function(e){function t(t,n){var r=e.call(this,t,n)||this;return r.message=new nn(t,n),r}return n(t,e),t}(F),No=function(t){function r(n){var r,i=this;i=t.call(this)||this;var s=[];n.mentionType===e.MentionType.USERS&&(n.mentionedUserIds?s=n.mentionedUserIds:n.mentionedUsers&&(s=n.mentionedUsers.map((function(e){return e.userId}))));var a=n.channelType,o=n.channelUrl;return i.method=d.POST,i.path="".concat(Je(a),"/").concat(encodeURIComponent(o),"/scheduled_messages"),i.params={req_id:n.reqId,scheduled_at:n.scheduledAt,message_type:ae.USER,message:n.message,custom_type:n.customType,data:n.data,mention_type:n.mentionType,mentioned_user_ids:s,sorted_metaarray:null===(r=n.metaArrays)||void 0===r?void 0:r.map((function(e){return xt.payloadify(e)})),apple_critical_alert_options:Gt.payloadify(n.appleCriticalAlertOptions),target_langs:n.translationTargetLanguages,push_option:n.pushNotificationDeliveryOption},i}return n(r,t),r}(x),wo=function(e){function t(t,n){var r=e.call(this,t,n)||this;return r.message=new nn(t,n),r}return n(t,e),t}(F),Mo=function(t){function r(n){var r,i=this;i=t.call(this)||this;var s=[];n.mentionType===e.MentionType.USERS&&(n.mentionedUserIds?s=n.mentionedUserIds:n.mentionedUsers&&(s=n.mentionedUsers.map((function(e){return e.userId}))));var a=n.channelType,o=n.channelUrl;return i.method=d.POST,i.path="".concat(Je(a),"/").concat(encodeURIComponent(o),"/scheduled_messages"),i.params={req_id:n.reqId,scheduled_at:n.scheduledAt,message_type:ae.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 jt.payloadify(e)})):[],custom_type:n.customType,data:n.data,require_auth:n.requireAuth,mention_type:n.mentionType,mentioned_user_ids:s,sorted_metaarray:null===(r=n.metaArrays)||void 0===r?void 0:r.map((function(e){return xt.payloadify(e)})),apple_critical_alert_options:Gt.payloadify(n.appleCriticalAlertOptions),push_option:n.pushNotificationDeliveryOption},i}return n(r,t),r}(x),Ao=function(e){function t(t,n){var r=e.call(this,t,n)||this;return r.message=new an(t,n),r}return n(t,e),t}(F),Uo=function(t){function l(n,r){var i,s,a,o,u=this;return(u=t.call(this,n)||this).url="",u.channelType=e.ChannelType.BASE,u.name="",u.coverUrl="",u.customType="",u.data="",u.isFrozen=!1,u.isEphemeral=!1,u.creator=null,u.createdAt=0,u.url=r.channel_url,u.name=null!==(i=r.name)&&void 0!==i?i:"",u.coverUrl=null!==(s=r.cover_url)&&void 0!==s?s:"",u.customType=null!==(a=r.custom_type)&&void 0!==a?a:"",u.data=null!==(o=r.data)&&void 0!==o?o:"",u.isFrozen=!!g("boolean",r.freeze)&&r.freeze,u.isEphemeral=!!g("boolean",r.is_ephemeral)&&r.is_ephemeral,u.creator=r.created_by?new ht(u._iid,r.created_by):null,u.createdAt=1e3*r.created_at,u._cachedMetaData=new Map,r.metadata&&r.ts&&Object.keys(r.metadata).forEach((function(e){u._cachedMetaData.set(e,{value:r.metadata[e],isRemoved:!1,updatedAt:r.ts})})),u}return n(l,t),l.payloadify=function(e){return D(r(r({},t.payloadify.call(this,e)),{channel_url:e.url,name:e.name,cover_url:e.coverUrl,custom_type:e.customType,data:e.data,freeze:e.isFrozen,is_ephemeral:e.isEphemeral,created_by:ht.payloadify(e.creator),created_at:e.createdAt/1e3}))},l.prototype.isGroupChannel=function(){return this.channelType===e.ChannelType.GROUP},l.prototype.isOpenChannel=function(){return this.channelType===e.ChannelType.OPEN},Object.defineProperty(l.prototype,"cachedMetaData",{get:function(){var e={};return this._cachedMetaData.forEach((function(t,n){t.isRemoved||(e[n]=t.value)})),e},enumerable:!1,configurable:!0}),l.prototype._upsertCachedMetaData=function(e,t){var n=this;Object.keys(e).forEach((function(r){var i=n._cachedMetaData.get(r);(!i||i.updatedAt<=t)&&n._cachedMetaData.set(r,{value:e[r],isRemoved:!1,updatedAt:t})}))},l.prototype._removeFromCachedMetaData=function(e,t){var n=this;e.forEach((function(e){var r=n._cachedMetaData.get(e);r&&r.updatedAt0&&b("string",t)).throw(f.invalidParameters),n=wt.of(this._iid).requestQueue,r=new Io({channelType:this.channelType,channelUrl:this.url,messageId:e.messageId,translationTargetLanguages:t}),[4,n.send(r)];case 1:return i=s.sent(),[2,i.as(So).message]}}))}))},l.prototype._createScheduledUserMessage=function(e,t){var n=this,a=wt.of(this._iid).requestQueue,o=Date.now(),u=this._generateRequestId();Re(2).then((function(){var r=n._createPendingScheduledUserMessage(e,u,o);De((function(){return i(n,void 0,void 0,(function(){return s(this,(function(e){return[2,t._trigger(null,r)]}))}))}))}));var c=new No(r({reqId:u,channelType:this.channelType,channelUrl:this.url},e));a.send(c).then((function(e){var r=e.as(wo).message;De((function(){return i(n,void 0,void 0,(function(){return s(this,(function(e){return[2,t._trigger(null,r)]}))}))}))})).catch((function(r){if(p(r))throw r;Re(2).then((function(){var a=n._createPendingScheduledUserMessage(e,u,o);n._markMessageAsFailed(a,r),De((function(){return i(n,void 0,void 0,(function(){return s(this,(function(e){return[2,t._trigger(r,a)]}))}))}))}))}))},l.prototype.sendFileMessage=function(e){var t=r(r({},Hr),e);return ct(Vr(t)).throw(f.invalidParameters),this._sendFileMessage(t)},l.prototype._sendFileMessage=function(t,n){var r=this;void 0===n&&(n=null);var a=wt.of(this._iid).dispatcher,o=kn.of(this._iid).fileMessageQueue,u=n,c=Date.now(),l=new Dn;return u||(u=this._generateRequestId(),Re(2).then((function(){var n=r._createPendingFileMessage(t,u,c);a.dispatch(new yn({messages:[n],source:e.MessageEventSource.EVENT_MESSAGE_SENT_PENDING})),De((function(){return i(r,void 0,void 0,(function(){return s(this,(function(e){return[2,l._trigger(null,n)]}))}))}))}))),o.request(this,u,t).then((function(t){a.dispatch(new yn({messages:[t],source:e.MessageEventSource.EVENT_MESSAGE_SENT_SUCCESS})),De((function(){return i(r,void 0,void 0,(function(){return s(this,(function(e){return[2,l._trigger(null,t)]}))}))}))})).catch((function(n){if(p(n))throw n;Re(2).then((function(){var o=r._createPendingFileMessage(t,u,c),h=wt.of(r._iid).cacheContext.localCacheEnabled&&C(n.code);r._markMessageAsFailed(o,n,h),a.dispatch(new yn({messages:[o],source:o.sendingStatus===e.SendingStatus.PENDING?e.MessageEventSource.REQUEST_RESEND_MESSAGE:e.MessageEventSource.EVENT_MESSAGE_SENT_FAILED})),De((function(){return i(r,void 0,void 0,(function(){return s(this,(function(e){return[2,l._trigger(n,o)]}))}))}))}))})),l},l.prototype._autoResendFileMessage=function(e){ct(e instanceof an).throw(f.invalidParameters);var t=wt.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)}))},l.prototype._createScheduledFileMessage=function(e,t,n,a){var o=this,u=wt.of(this._iid).requestQueue,c=new Mo(r(r({reqId:n,channelType:this.channelType,channelUrl:this.url},e),{fileUrl:e.fileUrl,requireAuth:e.requireAuth}));u.send(c).then((function(e){var n=e.as(Ao).message;De((function(){return i(o,void 0,void 0,(function(){return s(this,(function(e){return[2,t._trigger(null,n)]}))}))}))})).catch((function(r){if(p(r))throw r;Re(2).then((function(){var u=o._createPendingScheduledFileMessage(e,n,a);o._markMessageAsFailed(u,r),De((function(){return i(o,void 0,void 0,(function(){return s(this,(function(e){return[2,t._trigger(r,u)]}))}))}))}))}))},l.prototype.sendFileMessages=function(e){var t,n;ct(e.every((function(e){return Vr(r(r({},Hr),e))}))).throw(f.invalidParameters);var i=new Dn;try{for(var s=a(e),o=s.next();!o.done;o=s.next()){var u=o.value;this.sendFileMessage(u).onPending((function(e){return i._trigger(null,e)})).onFailed((function(e,t){return i._trigger(e,t)})).onSucceeded((function(e){return i._trigger(null,e)}))}}catch(e){t={error:e}}finally{try{o&&!o.done&&(n=s.return)&&n.call(s)}finally{if(t)throw t.error}}return i},l.prototype.resendFileMessage=function(e,t){var n;return i(this,void 0,void 0,(function(){var r,i,a;return s(this,(function(s){return r=Boolean(e.url)||T(t)||T(null===(n=e.messageParams)||void 0===n?void 0:n.file),ct(e instanceof an&&r&&!e.scheduledInfo).throw(f.invalidParameters),i=new ee,a=function(e,t){var n;return void 0===t&&(t=null),e.messageParams?(!e.url&&T(t)&&(e.messageParams.file=t),e.messageParams):D({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:e.thumbnails.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]}))}))},l.prototype.updateFileMessage=function(e,t){return i(this,void 0,void 0,(function(){var n,i,a,o;return s(this,(function(s){switch(s.label){case 0:return n=r(r({},ya),t),ct(g("number",e)&&function(e){return va(e)}(n)).throw(f.invalidParameters),i=wt.of(this._iid).requestQueue,a=new _o(r({channelType:this.channelType,channelUrl:this.url,messageId:e},n)),[4,i.send(a)];case 1:return o=s.sent(),[2,o.as(vo).message]}}))}))},l.prototype.cancelUploadingFileMessage=function(e){return i(this,void 0,void 0,(function(){return s(this,(function(t){return ct(g("string",e)).throw(f.invalidParameters),kn.of(this._iid).fileMessageQueue.cancel(this,e),[2,!0]}))}))},l.prototype.copyFileMessage=function(t,n){var a,o;return i(this,void 0,void 0,(function(){var i,u;return s(this,(function(s){return ct(t instanceof l&&n instanceof an&&n.sendingStatus===e.SendingStatus.SUCCEEDED&&t.url===n.channelUrl&&!n.scheduledInfo).throw(f.invalidParameters),i=new ee,u=r(r({},n),{fileUrl:n.url,fileName:n.name,fileSize:n.size,mimeType:n.type,mentionType:n.mentionType,mentionedUserIds:null!==(a=n.mentionedUserIds)&&void 0!==a?a:null===(o=n.mentionedUsers)||void 0===o?void 0:o.map((function(e){return e.userId})),pushNotificationDeliveryOption:e.PushNotificationDeliveryOption.DEFAULT,parentMessageId:null,isReplyToChannel:!1,thumbnailSizes:n.thumbnails.map((function(e){return{maxWidth:e.width,maxHeight:e.height}})),requireAuth:n.requireAuth}),t._sendFileMessage(u).onSucceeded((function(e){return i.resolve(e)})).onFailed((function(e){return i.reject(e)})),[2,i.promise]}))}))},l.prototype.deleteMessage=function(e){return i(this,void 0,void 0,(function(){var t,n;return s(this,(function(r){switch(r.label){case 0:return ct(e instanceof Bt).throw(f.invalidParameters),e.messageId>0?(t=wt.of(this._iid).requestQueue,n=new mo({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]}}))}))},l.prototype.addReaction=function(e,t){return i(this,void 0,void 0,(function(){var n,r,i;return s(this,(function(s){switch(s.label){case 0:return ct(e instanceof Kt&&e.messageId>0&&g("string",t)).throw(f.invalidParameters),n=wt.of(this._iid).requestQueue,r=new Eo({channelType:this.channelType,channelUrl:this.url,messageId:e.messageId,reactionKey:t}),[4,n.send(r)];case 1:return i=s.sent(),[2,i.as(bo).reactionEvent]}}))}))},l.prototype.deleteReaction=function(e,t){return i(this,void 0,void 0,(function(){var n,r,i;return s(this,(function(s){switch(s.label){case 0:return ct(e instanceof Kt&&e.messageId>0&&g("string",t)).throw(f.invalidParameters),n=wt.of(this._iid).requestQueue,r=new Co({channelType:this.channelType,channelUrl:this.url,messageId:e.messageId,reactionKey:t}),[4,n.send(r)];case 1:return i=s.sent(),[2,i.as(To).reactionEvent]}}))}))},l.prototype._updateMessageMetaArray=function(t,n,r,a){return i(this,void 0,void 0,(function(){var i,o,u,c,l,h;return s(this,(function(s){switch(s.label){case 0:return i=wt.of(this._iid),o=i.dispatcher,u=i.requestQueue,c=new po({channelType:this.channelType,channelUrl:this.url,messageId:t,metaArrayParams:{array:n,mode:r,upsert:a}}),[4,u.send(c)];case 1:return l=s.sent(),h=l.as(fo).message,o.dispatch(new yn({messages:[h],source:e.MessageEventSource.EVENT_MESSAGE_UPDATED})),[2,h]}}))}))},l.prototype.createMessageMetaArrayKeys=function(e,t){return i(this,void 0,void 0,(function(){var n;return s(this,(function(r){return ct(e instanceof Bt&&e.messageId>0&&b("string",t)).throw(f.invalidParameters),n=t.map((function(e){return new xt({key:e})})),[2,this._updateMessageMetaArray(e.messageId,n,"add",!0)]}))}))},l.prototype.deleteMessageMetaArrayKeys=function(e,t){return i(this,void 0,void 0,(function(){var n;return s(this,(function(r){return ct(e instanceof Bt&&e.messageId>0&&b("string",t)).throw(f.invalidParameters),n=t.map((function(e){return new xt({key:e})})),[2,this._updateMessageMetaArray(e.messageId,n,"remove",!0)]}))}))},l.prototype.addMessageMetaArrayValues=function(e,t){return i(this,void 0,void 0,(function(){return s(this,(function(n){return ct(e instanceof Bt&&e.messageId>0&&t.every((function(e){return e instanceof xt}))).throw(f.invalidParameters),[2,this._updateMessageMetaArray(e.messageId,t,"add",!0)]}))}))},l.prototype.removeMessageMetaArrayValues=function(e,t){return i(this,void 0,void 0,(function(){return s(this,(function(n){return ct(e instanceof Bt&&e.messageId>0&&t.every((function(e){return e instanceof xt}))).throw(f.invalidParameters),[2,this._updateMessageMetaArray(e.messageId,t,"remove",!0)]}))}))},l.prototype.report=function(t,n){return i(this,void 0,void 0,(function(){var r,i,a,o;return s(this,(function(s){switch(s.label){case 0:return ct(y(e.ReportCategory,t)&&g("string",n)).throw(f.invalidParameters),r=wt.of(this._iid),i=r.sdkState,a=r.requestQueue,o=new oo({channelUrl:this.url,channelType:this.channelType,userId:i.userId,category:t,description:n}),[4,a.send(o)];case 1:return s.sent(),[2]}}))}))},l.prototype.reportUser=function(t,n,r){return i(this,void 0,void 0,(function(){var i,a,o,u;return s(this,(function(s){switch(s.label){case 0:return ct(t instanceof ht&&y(e.ReportCategory,n)&&g("string",r)).throw(f.invalidParameters),i=wt.of(this._iid),a=i.sdkState,o=i.requestQueue,u=new uo({channelUrl:this.url,channelType:this.channelType,userId:a.userId,offendingUserId:t.userId,category:n,description:r}),[4,o.send(u)];case 1:return s.sent(),[2]}}))}))},l.prototype.reportMessage=function(t,n,r){return i(this,void 0,void 0,(function(){var i,a,o,u;return s(this,(function(s){switch(s.label){case 0:return ct(t instanceof Bt&&y(e.ReportCategory,n)&&g("string",r)).throw(f.invalidParameters),i=wt.of(this._iid),a=i.sdkState,o=i.requestQueue,u=new co({channelUrl:this.url,channelType:this.channelType,userId:a.userId,offendingUserId:t.sender.userId,messageId:t.messageId,category:n,description:r}),[4,o.send(u)];case 1:return s.sent(),[2]}}))}))},l}(We),Oo=null,Ro=function(){function t(e,t,n){var r=this;this._fcmPushToken=null,this._apnsPushToken=null,this._iid=e,this.options=t;var a=wt.of(e),o=a.sdkState,u=a.cacheContext,c=a.dispatcher,l=a.sessionManager,h=a.requestQueue,d=a.logger,p=a.userEventHandlers;this._onlineDetector=new Xr({logger:d,connectionDelegate:{reconnect:function(){var t=wt.of(e),n=t.sdkState,r=t.connectionManager;"foreground"===n.appState&&r.resetAndReconnect()},disconnect:function(){wt.of(e).connectionManager.disconnect()}}}),new ei(e,{localCacheEnabled:u.localCacheEnabled,dispatcher:c,sdkState:o,logger:d}),n.forEach((function(t){t.init(e,{sdkState:o,cacheContext:u,dispatcher:c,sessionManager:l,requestQueue:h,logger:d,onlineDetector:r._onlineDetector}),r[t.name]=t})),this._appStateChangeDetector=new Jr,this._appStateChangeDetector.on("resume",(function(){d.debug("the page resumes from freeze"),r.setForegroundState()})).on("pause",(function(){d.debug("the page freezes"),r.setBackgroundState()})),c.on((function(t){if(t instanceof j){if("USEV"===t.code){var n=t.as(ri).event;if(n.category===xr.FRIEND_DISCOVERED){var a=ti.getDataAsFriendDiscoveredEvent(e,n).friendDiscoveries;De((function(){return i(r,void 0,void 0,(function(){return s(this,(function(e){return[2,p.forEach((function(e){e.onFriendsDiscovered(a)}))]}))}))}))}}}else if(t instanceof $){var c=wt.of(r._iid).subscribedUnreadMessageCount,l=!1,h=t.ts;if("number"==typeof h&&h>c.ts){if(c.all!==t.all&&(l=!0),c.all=t.all>=0?t.all:0,t.customTypes)for(var d in t.customTypes)c.customTypes[d]!==t.customTypes[d]&&(l=!0),c.customTypes[d]=t.customTypes[d];l=l&&c.ts>0,c.ts=h}l&&De((function(){return i(r,void 0,void 0,(function(){return s(this,(function(e){return[2,p.forEach((function(e){e.onTotalUnreadMessageCountUpdated(c.all,c.customTypes)}))]}))}))}))}else t instanceof dt&&u.localCacheEnabled&&u.preference.set(r._getUserProfileCacheKey(o.userId),pt.payloadify(t.userProfile))}))}return t.init=function(e){var n=e.appId,r=e.appVersion,i=void 0===r?null:r,s=e.modules,a=void 0===s?[]:s,c=e.options,l=void 0===c?new I:c,h=e.debugMode,d=void 0!==h&&h,p=e.customApiHost,f=e.customWebSocketHost,_=e.newInstance,v=void 0!==_&&_,m=e.logLevel,g=e.localCacheEnabled,y=void 0!==g&&g,E=e.localCacheEncryption,b=e.useAsyncStorageStore,C=void 0===b?null:b;if(!Oo||v){var T="su-".concat(U()),S=null!=E?E:{encrypt:function(e){return e},decrypt:function(e){return e}},N=new ra({encryption:S});d||(N=C?new aa({AsyncStorage:C,encryption:S}):new sa({encryption:S})),new wt(T,{appId:n,appVersion:i,options:l,apiHost:null!=p?p:"https://api-".concat(n,".sendbird.com"),websocketHost:null!=f?f:"wss://ws-".concat(n,".sendbird.com"),store:N,encryption:S,logLevel:m,localCacheEnabled:y,debugMode:d});var w=[new Wn,new yr],M=new t(T,l,u(u([],o(a),!1),o(w),!1));return Oo||(Oo=M),M}return Oo},Object.defineProperty(t,"instance",{get:function(){return Oo},enumerable:!1,configurable:!0}),Object.defineProperty(t,"version",{get:function(){return l},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"appId",{get:function(){return wt.of(this._iid).sdkState.appId},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"appInfo",{get:function(){return wt.of(this._iid).appInfo},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"appVersion",{get:function(){var e;return null!==(e=wt.of(this._iid).sdkState.appVersion)&&void 0!==e?e:""},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"debugMode",{get:function(){return wt.of(this._iid).debugMode},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"logLevel",{get:function(){return wt.of(this._iid).logger.level},set:function(e){wt.of(this._iid).logger.level=e},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"isCacheEnabled",{get:function(){return wt.of(this._iid).cacheContext.localCacheEnabled},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"ekey",{get:function(){return je(this._iid)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"currentUser",{get:function(){var e;return null!==(e=wt.of(this._iid).sessionManager.currentUser)&&void 0!==e?e:null},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"connectionState",{get:function(){var t=wt.of(this._iid).connectionManager;return t.isConnected?e.ConnectionState.OPEN:t.isConnecting?e.ConnectionState.CONNECTING:e.ConnectionState.CLOSED},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"lastConnectedAt",{get:function(){var e=wt.of(this._iid),t=e.connectedAt;return e.connectionManager.isConnected?t:0},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"fcmPushToken",{get:function(){return this._fcmPushToken},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"apnsPushToken",{get:function(){return this._apnsPushToken},enumerable:!1,configurable:!0}),t.prototype._getPreferenceCacheKey=function(e){return"sendbird@".concat(this.appId,"/").concat(e,".pref")},t.prototype._getUserProfileCacheKey=function(e){return"sendbird@".concat(this.appId,"/").concat(e,".profile")},t.prototype.getMemoryStoreForDebugging=function(){var e=wt.of(this._iid),t=e.debugMode,n=e.cacheContext;if(t)return n.store instanceof ra?n.store:null;throw f.debugModeRequired},t.prototype.addExtension=function(e,t){var n=wt.of(this._iid).sdkState;["sb_uikit","sb_syncmanager","device-os-platform"].indexOf(e)>-1&&(n.extensions[e]=t)},t.prototype.setOnlineListener=function(e){this._onlineDetector.setOnlineListener(e)},t.prototype.setOfflineListener=function(e){this._onlineDetector.setOfflineListener(e)},t.prototype.initializeCache=function(t){return i(this,void 0,void 0,(function(){var n,r,i,a,o,u,c,l;return s(this,(function(s){switch(s.label){case 0:return n=wt.of(this._iid),r=n.sdkState,i=n.cacheContext,a=n.connectionManager,o=n.dispatcher,r.userId&&r.userId===t?[3,6]:[4,a.logout()];case 1:return s.sent(),r.userId=t,i.localCacheEnabled?(u="sendbird@".concat(r.appId,"/").concat(t,".db"),i.nestdb&&i.nestdb.state!==Zs.CLOSED&&i.nestdb.name===u?[3,3]:((c=i.nestdb=new ha({name:"sendbird@".concat(r.appId,"/").concat(t,".db"),version:1,store:i.store})).on("upgrade",function(t){return function(n,r){0===n?t.commitSchema([{collectionName:Ir,keyName:"url",index:[Mr(e.GroupChannelListOrder.LATEST_LAST_MESSAGE),Mr(e.GroupChannelListOrder.CHRONOLOGICAL),Mr(e.GroupChannelListOrder.CHANNEL_NAME_ALPHABETICAL)]},{collectionName:Nr,keyName:"messageId",index:[Or(wr.CHANNEL_LATEST),Or(wr.NEWEST_CHILD_MESSAGE)]},{collectionName:Br,keyName:"reqId",index:[Or(wr.CHANNEL_LATEST),Or(wr.NEWEST_CHILD_MESSAGE)]},{collectionName:"Poll",keyName:"pollId"}]).then((function(){return r()})).catch((function(e){return r(e)})):r()}}(c)),[4,c.open()])):[3,6];case 2:s.sent(),o.dispatch(new ni(this._iid,{userId:t})),s.label=3;case 3:return[4,i.preference.init(this._getPreferenceCacheKey(t))];case 4:return s.sent(),[4,i.preference.get(this._getUserProfileCacheKey(t))];case 5:(l=s.sent())&&new pt(this._iid,l).apply(),s.label=6;case 6:return[2]}}))}))},t.prototype.clearCachedData=function(){return i(this,void 0,void 0,(function(){var e;return s(this,(function(t){switch(t.label){case 0:return(e=wt.of(this._iid).cacheContext).localCacheEnabled?(e.nestdb&&e.nestdb.clear(),[4,e.preference.clear()]):[3,2];case 1:t.sent(),t.label=2;case 2:return[2]}}))}))},t.prototype.clearCachedMessages=function(e){return i(this,void 0,void 0,(function(){var t,n,r=this;return s(this,(function(a){switch(a.label){case 0:return ct(b("string",e)).throw(f.invalidParameters),t=Yr.of(this._iid),n=zr.of(this._iid),t&&n?[4,Promise.all(e.map((function(e){return i(r,void 0,void 0,(function(){return s(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:a.sent(),a.label=2;case 2:return[2]}}))}))},t.prototype.connect=function(e,t){return void 0===t&&(t=null),i(this,void 0,void 0,(function(){var n,r,i,a,o,u,c;return s(this,(function(s){switch(s.label){case 0:ct(g("string",e)&&g("string",t,!0)).throw(f.invalidParameters),n=wt.of(this._iid),r=n.sdkState,i=n.cacheContext,a=n.connectionManager,o=n.statLogCollector,s.label=1;case 1:return s.trys.push([1,3,,4]),[4,this.initializeCache(e)];case 2:return s.sent(),[3,4];case 3:return s.sent(),u=wt.of(this._iid).logger,i.localCacheEnabled=!1,u.warn("Cache initialization failed - cache is not available."),[3,4];case 4:return[4,o.init("sendbird@".concat(r.appId,"/").concat(e,".statlog"))];case 5:return s.sent(),[4,a.connect(t)];case 6:return s.sent(),this._appStateChangeDetector.start(),r.appState="foreground",[4,null==(c=ei.of(this._iid))?void 0:c.processNonAutoResendRegisteredPendingMessages()];case 7:return s.sent(),this._onlineDetector.start(),[2,this.currentUser]}}))}))},t.prototype.reconnect=function(){var e=wt.of(this._iid),t=e.connectionManager,n=e.sdkState,r=e.sessionManager.auth.hasSession;return r&&t.resetAndReconnect().then((function(){n.appState="foreground"})).catch((function(){})),r},t.prototype.disconnect=function(){return i(this,void 0,void 0,(function(){var e,t,n,r;return s(this,(function(i){switch(i.label){case 0:return e=wt.of(this._iid),t=e.connectionManager,n=e.cacheContext,r=e.requestQueue,this._appStateChangeDetector.stop(),this._onlineDetector.stop(),r.cancelAll(),[4,t.logout()];case 1:return i.sent(),n.localCacheEnabled?[4,this.clearCachedData()]:[3,3];case 2:i.sent(),i.label=3;case 3:return[2]}}))}))},t.prototype.setBackgroundState=function(){var e=wt.of(this._iid),t=e.connectionManager,n=e.sdkState,r=e.logger;"foreground"===n.appState&&(n.appState="background",r.debug("going background state"),t.background())},t.prototype.setForegroundState=function(){var e=wt.of(this._iid),t=e.connectionManager,n=e.sdkState,r=e.logger;"background"===n.appState&&(n.appState="foreground",r.debug("going foreground state"),t.resetAndReconnect())},t.prototype.setSessionHandler=function(e){ct(e instanceof br).throw(f.invalidParameters),wt.of(this._iid).sessionManager.handler=e},t.prototype.addUserEventHandler=function(e,t){ct(g("string",e)&&t instanceof Tr).throw(f.invalidParameters),wt.of(this._iid).userEventHandlers.set(e,t)},t.prototype.removeUserEventHandler=function(e){wt.of(this._iid).userEventHandlers.delete(e)},t.prototype.removeAllUserEventHandler=function(){wt.of(this._iid).userEventHandlers.clear()},t.prototype.addConnectionHandler=function(e,t){ct(g("string",e)&&t instanceof Cr).throw(f.invalidParameters),wt.of(this._iid).connectionHandlers.set(e,t)},t.prototype.removeConnectionHandler=function(e){wt.of(this._iid).connectionHandlers.delete(e)},t.prototype.removeAllConnectionHandler=function(){wt.of(this._iid).connectionHandlers.clear()},t.prototype.createApplicationUserListQuery=function(e){return void 0===e&&(e={}),new ss(this._iid,e)},t.prototype.createBlockedUserListQuery=function(e){return void 0===e&&(e={}),new us(this._iid,e)},t.prototype.createFriendListQuery=function(e){return void 0===e&&(e={}),new hs(this._iid,e)},t.prototype.createMessageSearchQuery=function(e){return new Qn(this._iid,e)},t.prototype.createPollListQuery=function(e){return new _r(this._iid,r({},e))},t.prototype.createPollVoterListQuery=function(e){return new gr(this._iid,r({},e))},t.prototype.buildUserFromSerializedData=function(e){var t=ut(e);return new ht(this._iid,ht.payloadify(t))},t.prototype.updateCurrentUserInfo=function(e){return void 0===e&&(e={}),i(this,void 0,void 0,(function(){var t,n,i,a,o,u,c;return s(this,(function(s){switch(s.label){case 0:return t=r(r({},Er),e),ct(function(e){return T(e.profileImage,!0)&&g("string",e.profileUrl,!0)&&g("string",e.nickname,!0)}(t)).throw(f.invalidParameters),this.currentUser?(n=wt.of(this._iid),i=n.sdkState,a=n.requestQueue,o=new ii(r({userId:i.userId},t)),[4,a.send(o)]):[3,2];case 1:return u=s.sent(),c=u.as(si).user,this.currentUser&&(t.nickname&&(this.currentUser.nickname=c.nickname),(t.profileUrl||t.profileImage)&&(this.currentUser.plainProfileUrl=c.profileUrl)),[2,c];case 2:throw f.connectionRequired}}))}))},t.prototype.updateCurrentUserInfoWithPreferredLanguages=function(e){return i(this,void 0,void 0,(function(){var t,n,r,i,a,o;return s(this,(function(s){switch(s.label){case 0:return ct(b("string",e)).throw(f.invalidParameters),this.currentUser?(t=wt.of(this._iid),n=t.sdkState,r=t.requestQueue,i=new ii({userId:n.userId,preferredLanguages:e}),[4,r.send(i)]):[3,2];case 1:return a=s.sent(),o=a.as(si).user,this.currentUser&&(this.currentUser.preferredLanguages=o.preferredLanguages),[2,o];case 2:throw f.connectionRequired}}))}))},t.prototype.registerFCMPushTokenForCurrentUser=function(t){return i(this,void 0,void 0,(function(){var n,r,i,a;return s(this,(function(s){switch(s.label){case 0:if(ct(g("string",t)).throw(f.invalidParameters),!this.currentUser)return[3,5];s.label=1;case 1:return s.trys.push([1,3,,4]),n=wt.of(this._iid),r=n.sdkState,i=n.requestQueue,a=new oi({userId:r.userId,token:t}),[4,i.send(a)];case 2:return s.sent(),this._fcmPushToken="",[2,e.PushTokenRegistrationState.SUCCESS];case 3:return s.sent(),[2,e.PushTokenRegistrationState.ERROR];case 4:return[3,6];case 5:return this._fcmPushToken=t,[2,e.PushTokenRegistrationState.PENDING];case 6:return[2]}}))}))},t.prototype.unregisterFCMPushTokenForCurrentUser=function(t){return i(this,void 0,void 0,(function(){var n,r,i,a;return s(this,(function(s){switch(s.label){case 0:if(ct(g("string",t)).throw(f.invalidParameters),!this.currentUser)return[3,5];s.label=1;case 1:return s.trys.push([1,3,,4]),n=wt.of(this._iid),r=n.sdkState,i=n.requestQueue,a=new ci({userId:r.userId,token:t}),[4,i.send(a)];case 2:return s.sent(),this._fcmPushToken="",[2,e.PushTokenRegistrationState.SUCCESS];case 3:return s.sent(),[2,e.PushTokenRegistrationState.ERROR];case 4:return[3,6];case 5:return this._fcmPushToken=t,[2,e.PushTokenRegistrationState.PENDING];case 6:return[2]}}))}))},t.prototype.unregisterFCMPushTokenAllForCurrentUser=function(){return i(this,void 0,void 0,(function(){var e,t,n,r;return s(this,(function(i){switch(i.label){case 0:return this.currentUser?(e=wt.of(this._iid),t=e.sdkState,n=e.requestQueue,r=new hi({userId:t.userId}),[4,n.send(r)]):[3,2];case 1:i.sent(),i.label=2;case 2:return[2]}}))}))},t.prototype.registerAPNSPushTokenForCurrentUser=function(t){return i(this,void 0,void 0,(function(){var n,r,i,a;return s(this,(function(s){switch(s.label){case 0:if(ct(g("string",t)).throw(f.invalidParameters),!this.currentUser)return[3,5];s.label=1;case 1:return s.trys.push([1,3,,4]),n=wt.of(this._iid),r=n.sdkState,i=n.requestQueue,a=new ai({userId:r.userId,token:t}),[4,i.send(a)];case 2:return s.sent(),this._fcmPushToken="",[2,e.PushTokenRegistrationState.SUCCESS];case 3:return s.sent(),[2,e.PushTokenRegistrationState.ERROR];case 4:return[3,6];case 5:return this._fcmPushToken=t,[2,e.PushTokenRegistrationState.PENDING];case 6:return[2]}}))}))},t.prototype.unregisterAPNSPushTokenForCurrentUser=function(t){return i(this,void 0,void 0,(function(){var n,r,i,a;return s(this,(function(s){switch(s.label){case 0:if(ct(g("string",t)).throw(f.invalidParameters),!this.currentUser)return[3,5];s.label=1;case 1:return s.trys.push([1,3,,4]),n=wt.of(this._iid),r=n.sdkState,i=n.requestQueue,a=new ui({userId:r.userId,token:t}),[4,i.send(a)];case 2:return s.sent(),this._fcmPushToken="",[2,e.PushTokenRegistrationState.SUCCESS];case 3:return s.sent(),[2,e.PushTokenRegistrationState.ERROR];case 4:return[3,6];case 5:return this._fcmPushToken=t,[2,e.PushTokenRegistrationState.PENDING];case 6:return[2]}}))}))},t.prototype.unregisterAPNSPushTokenAllForCurrentUser=function(){return i(this,void 0,void 0,(function(){var e,t,n,r;return s(this,(function(i){switch(i.label){case 0:return this.currentUser?(e=wt.of(this._iid),t=e.sdkState,n=e.requestQueue,r=new li({userId:t.userId}),[4,n.send(r)]):[3,2];case 1:i.sent(),i.label=2;case 2:return[2]}}))}))},t.prototype.getChannelInvitationPreference=function(){return i(this,void 0,void 0,(function(){var e,t,n,r,i;return s(this,(function(s){switch(s.label){case 0:return e=wt.of(this._iid),t=e.sdkState,n=e.requestQueue,r=new fi({userId:t.userId}),[4,n.send(r)];case 1:return i=s.sent(),[2,{autoAccept:i.as(_i).autoAccept}]}}))}))},t.prototype.setChannelInvitationPreference=function(e){return i(this,void 0,void 0,(function(){var t,n,r,i,a;return s(this,(function(s){switch(s.label){case 0:return ct(g("boolean",e)).throw(f.invalidParameters),t=wt.of(this._iid),n=t.sdkState,r=t.requestQueue,i=new vi({userId:n.userId,willAutoAccept:e}),[4,r.send(i)];case 1:return a=s.sent(),[2,{autoAccept:a.as(mi).autoAccept}]}}))}))},t.prototype.getDoNotDisturb=function(){return i(this,void 0,void 0,(function(){var e,t,n,r,i;return s(this,(function(s){switch(s.label){case 0:return e=wt.of(this._iid),t=e.sdkState,n=e.requestQueue,r=new gi({userId:t.userId}),[4,n.send(r)];case 1:return i=s.sent(),[2,i.as(yi).preference]}}))}))},t.prototype.setDoNotDisturb=function(e,t,n,r,a,o){return void 0===t&&(t=0),void 0===n&&(n=0),void 0===r&&(r=0),void 0===a&&(a=0),void 0===o&&(o=""),i(this,void 0,void 0,(function(){var i,u,c,l,h;return s(this,(function(s){switch(s.label){case 0:return ct(g("boolean",e)&&g("number",t)&&g("number",n)&&g("number",r)&&g("number",a)&&g("string",o)).throw(f.invalidParameters),i=wt.of(this._iid),u=i.sdkState,c=i.requestQueue,l=new Ei({userId:u.userId,doNotDisturbOn:e,startHour:t,startMin:n,endHour:r,endMin:a,timezone:o}),[4,c.send(l)];case 1:return h=s.sent(),[2,h.as(bi).preference]}}))}))},t.prototype.getSnoozePeriod=function(){return i(this,void 0,void 0,(function(){var e,t,n,r,i;return s(this,(function(s){switch(s.label){case 0:return e=wt.of(this._iid),t=e.sdkState,n=e.requestQueue,r=new Ci({userId:t.userId}),[4,n.send(r)];case 1:return i=s.sent(),[2,i.as(Ti).snoozePeriod]}}))}))},t.prototype.setSnoozePeriod=function(e,t,n){return void 0===t&&(t=0),void 0===n&&(n=0),i(this,void 0,void 0,(function(){var r,i,a,o,u;return s(this,(function(s){switch(s.label){case 0:return ct(g("boolean",e)&&g("number",t)&&g("number",n)).throw(f.invalidParameters),r=wt.of(this._iid),i=r.sdkState,a=r.requestQueue,o=new Ii({userId:i.userId,snoozeOn:e,startTs:t,endTs:n}),[4,a.send(o)];case 1:return u=s.sent(),[2,u.as(Si).snoozePeriod]}}))}))},t.prototype.getMyPushTokensByToken=function(t,n){return i(this,void 0,void 0,(function(){var r,i,a,o,u;return s(this,(function(s){switch(s.label){case 0:return ct(g("string",t)&&y(e.PushTokenType,n)).throw(f.invalidParameters),r=wt.of(this._iid),i=r.sdkState,a=r.requestQueue,o=new di({userId:i.userId,type:n,token:t}),[4,a.send(o)];case 1:return u=s.sent(),[2,u.as(pi).pushTokens]}}))}))},t.prototype.getPushTriggerOption=function(){return i(this,void 0,void 0,(function(){var e,t,n,r;return s(this,(function(i){switch(i.label){case 0:return e=wt.of(this._iid),t=e.sdkState,n=e.requestQueue,r=new Mi({userId:t.userId}),[4,n.send(r)];case 1:return[2,i.sent().as(Ai).pushTriggerOption]}}))}))},t.prototype.setPushTriggerOption=function(t){return i(this,void 0,void 0,(function(){var n,r,i,a;return s(this,(function(s){switch(s.label){case 0:return ct(y(e.PushTriggerOption,t)).throw(f.invalidParameters),n=wt.of(this._iid),r=n.sdkState,i=n.requestQueue,a=new Ui({userId:r.userId,pushTriggerOption:t}),[4,i.send(a)];case 1:return[2,s.sent().as(Oi).pushTriggerOption]}}))}))},t.prototype.getPushTemplate=function(){return i(this,void 0,void 0,(function(){var e,t,n,r;return s(this,(function(i){switch(i.label){case 0:return e=wt.of(this._iid),t=e.sdkState,n=e.requestQueue,r=new Ri({userId:t.userId}),[4,n.send(r)];case 1:return[2,i.sent().as(Li).name]}}))}))},t.prototype.setPushTemplate=function(t){return i(this,void 0,void 0,(function(){var n,r,i,a;return s(this,(function(s){switch(s.label){case 0:return ct(y(e.PushTemplate,t)).throw(f.invalidParameters),n=wt.of(this._iid),r=n.sdkState,i=n.requestQueue,a=new ki({userId:r.userId,templateName:t}),[4,i.send(a)];case 1:return[2,s.sent().as(Di).name]}}))}))},t.prototype.blockUser=function(e){return i(this,void 0,void 0,(function(){var t,n,r,i;return s(this,(function(s){switch(s.label){case 0:return ct(e instanceof ht||g("string",e)).throw(f.invalidParameters),t=wt.of(this._iid),n=t.sdkState,r=t.requestQueue,i=new Ni({userId:n.userId,blockedUserId:e instanceof ht?e.userId:e}),[4,r.send(i)];case 1:return s.sent(),[2]}}))}))},t.prototype.blockUserWithUserId=function(e){return i(this,void 0,void 0,(function(){return s(this,(function(t){return[2,this.blockUser(e)]}))}))},t.prototype.unblockUser=function(e){return i(this,void 0,void 0,(function(){var t,n,r,i;return s(this,(function(s){switch(s.label){case 0:return ct(e instanceof ht||g("string",e)).throw(f.invalidParameters),t=wt.of(this._iid),n=t.sdkState,r=t.requestQueue,i=new wi({userId:n.userId,unblockedUserId:e instanceof ht?e.userId:e}),[4,r.send(i)];case 1:return s.sent(),[2]}}))}))},t.prototype.unblockUserWithUserId=function(e){return i(this,void 0,void 0,(function(){return s(this,(function(t){return[2,this.unblockUser(e)]}))}))},t.prototype.getFriendChangeLogsByToken=function(e){return i(this,void 0,void 0,(function(){var t,n,r,i,a;return s(this,(function(s){switch(s.label){case 0:return ct(g("string",e)).throw(f.invalidParameters),t=wt.of(this._iid),n=t.sdkState,r=t.requestQueue,i=new Pi({userId:n.userId,token:e}),[4,r.send(i)];case 1:return a=s.sent(),[2,a.as(xi).changelogs]}}))}))},t.prototype.getAllowFriendDiscovery=function(){return i(this,void 0,void 0,(function(){var e,t,n,r,i;return s(this,(function(s){switch(s.label){case 0:return e=wt.of(this._iid),t=e.sdkState,n=e.requestQueue,r=new Qi({userId:t.userId}),[4,n.send(r)];case 1:return i=s.sent(),[2,i.as(Bi).allowFriendDiscovery]}}))}))},t.prototype.setAllowFriendDiscovery=function(e){return i(this,void 0,void 0,(function(){var t,n,r,i;return s(this,(function(s){switch(s.label){case 0:return ct(g("boolean",e)).throw(f.invalidParameters),t=wt.of(this._iid),n=t.sdkState,r=t.requestQueue,i=new ji({userId:n.userId,allowFriendDiscovery:e}),[4,r.send(i)];case 1:return s.sent(),[2,e]}}))}))},t.prototype.uploadFriendDiscoveries=function(e){return i(this,void 0,void 0,(function(){var t,n,r,i,a;return s(this,(function(s){switch(s.label){case 0:return t=wt.of(this._iid),n=t.sdkState,r=t.requestQueue,i=new Fi({userId:n.userId,discoveries:e}),[4,r.send(i)];case 1:return a=s.sent(),[2,a.as(qi).friendDiscoveryRequestId]}}))}))},t.prototype.deleteFriendDiscovery=function(e){return i(this,void 0,void 0,(function(){return s(this,(function(t){return[2,this.deleteFriendDiscoveries([e])]}))}))},t.prototype.deleteFriendDiscoveries=function(e){return i(this,void 0,void 0,(function(){var t,n,r,i;return s(this,(function(s){switch(s.label){case 0:return ct(b("string",e)).throw(f.invalidParameters),t=wt.of(this._iid),n=t.sdkState,r=t.requestQueue,i=new Gi({userId:n.userId,discoveryKeys:e}),[4,r.send(i)];case 1:return s.sent(),[2]}}))}))},t.prototype.addFriends=function(e){return i(this,void 0,void 0,(function(){var t,n,r,i,a;return s(this,(function(s){switch(s.label){case 0:return ct(b("string",e)).throw(f.invalidParameters),t=wt.of(this._iid),n=t.sdkState,r=t.requestQueue,i=new Hi({userId:n.userId,userIds:e}),[4,r.send(i)];case 1:return a=s.sent(),[2,a.as(Vi).users]}}))}))},t.prototype.deleteFriend=function(e){return i(this,void 0,void 0,(function(){return s(this,(function(t){return[2,this.deleteFriends([e])]}))}))},t.prototype.deleteFriends=function(e){return i(this,void 0,void 0,(function(){var t,n,r,i;return s(this,(function(s){switch(s.label){case 0:return ct(b("string",e)).throw(f.invalidParameters),t=wt.of(this._iid),n=t.sdkState,r=t.requestQueue,i=new Ki({userId:n.userId,userIds:e}),[4,r.send(i)];case 1:return s.sent(),[2]}}))}))},t.prototype.getAllEmoji=function(){return i(this,void 0,void 0,(function(){var e,t,n;return s(this,(function(r){switch(r.label){case 0:return e=wt.of(this._iid).requestQueue,t=new Xi,[4,e.send(t)];case 1:return n=r.sent(),[2,n.as(Zi).emojiContainer]}}))}))},t.prototype.getEmojiCategory=function(e){return i(this,void 0,void 0,(function(){var t,n,r;return s(this,(function(i){switch(i.label){case 0:return t=wt.of(this._iid).requestQueue,n=new $i({categoryId:e}),[4,t.send(n)];case 1:return r=i.sent(),[2,r.as(es).emojiCategory]}}))}))},t.prototype.getEmoji=function(e){return i(this,void 0,void 0,(function(){var t,n,r;return s(this,(function(i){switch(i.label){case 0:return t=wt.of(this._iid).requestQueue,n=new ts({key:e}),[4,t.send(n)];case 1:return r=i.sent(),[2,r.as(ns).emoji]}}))}))},t}();e.MemberState=void 0,(go=e.MemberState||(e.MemberState={})).NONE="none",go.JOINED="joined",go.INVITED="invited",go.LEFT="left";var Lo,ko,Do,Po,xo,Fo,qo,Go,Ho=function(t){function i(n,r){var i=t.call(this,n,r)||this;return i.state=null,i.role=null,i.isMuted=!1,i.isBlockedByMe=!1,i.isBlockingMe=!1,i.state=y(e.MemberState,r.state)?r.state:null,i.role=y(e.Role,r.role)?r.role:null,r.hasOwnProperty("is_muted")&&(i.isMuted=r.is_muted),r.hasOwnProperty("is_blocked_by_me")&&(i.isBlockedByMe=r.is_blocked_by_me),r.hasOwnProperty("is_blocking_me")&&(i.isBlockingMe=r.is_blocking_me),i}return n(i,t),i.payloadify=function(e){return e?D(r(r({},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},i}(fa),Vo=function(t){function r(n,r){var i,s,a=this;return(a=t.call(this,n)||this).channelUrl=null!==(i=r.channel_url)&&void 0!==i?i:"",a.channelType=null!==(s=r.channel_type)&&void 0!==s?s:e.ChannelType.GROUP,a.reader=new ht(a._iid,r.user),a.readAt=r.ts,a}return n(r,t),r}(We);e.PublicChannelFilter=void 0,(Lo=e.PublicChannelFilter||(e.PublicChannelFilter={})).ALL="all",Lo.PUBLIC="public",Lo.PRIVATE="private",e.MyMemberStateFilter=void 0,(ko=e.MyMemberStateFilter||(e.MyMemberStateFilter={})).ALL="all",ko.JOINED="joined_only",ko.INVITED="invited_only",ko.INVITED_BY_FRIEND="invited_by_friend",ko.INVITED_BY_NON_FRIEND="invited_by_non_friend",e.SuperChannelFilter=void 0,(Do=e.SuperChannelFilter||(e.SuperChannelFilter={})).ALL="all",Do.SUPER="super",Do.NON_SUPER="nonsuper",Do.BROADCAST_ONLY="broadcast_only",Do.EXCLUSIVE_ONLY="exclusive_only",e.UnreadChannelFilter=void 0,(Po=e.UnreadChannelFilter||(e.UnreadChannelFilter={})).ALL="all",Po.UNREAD_MESSAGE="unread_message",e.HiddenChannelFilter=void 0,(xo=e.HiddenChannelFilter||(e.HiddenChannelFilter={})).ALL="all",xo.UNHIDDEN="unhidden_only",xo.HIDDEN="hidden_only",xo.HIDDEN_ALLOW_AUTO_UNHIDE="hidden_allow_auto_unhide",xo.HIDDEN_PREVENT_AUTO_UNHIDE="hidden_prevent_auto_unhide",e.OperatorFilter=void 0,(Fo=e.OperatorFilter||(e.OperatorFilter={})).ALL="all",Fo.OPERATOR="operator",Fo.NONOPERATOR="nonoperator",e.QueryType=void 0,(qo=e.QueryType||(e.QueryType={})).AND="AND",qo.OR="OR",e.GroupChannelSearchField=void 0,(Go=e.GroupChannelSearchField||(e.GroupChannelSearchField={})).MEMBER_NICKNAME="member_nickname",Go.CHANNEL_NAME="channel_name";var Ko,Qo=function(){function 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 t.prototype._isFriend=function(e){return!!e.friendDiscoveryKey||!!e.friendName},Object.defineProperty(t.prototype,"searchFilter",{get:function(){return this._searchFilter},enumerable:!1,configurable:!0}),t.prototype.setSearchFilter=function(e,t){Array.isArray(e)&&0!==e.length&&"string"==typeof t&&t&&(this._searchFilter={query:t,fields:e})},Object.defineProperty(t.prototype,"userIdsFilter",{get:function(){return this._userIdsFilter},enumerable:!1,configurable:!0}),t.prototype.setUserIdsFilter=function(t,n,r){void 0===r&&(r=e.QueryType.AND),this._userIdsFilter={userIds:t,includeMode:n,queryType:r}},t.prototype.clone=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},t.prototype.match=function(t,n){if(this._searchFilter){var r=this._searchFilter,i=r.query,s=r.fields;if(i&&s&&s.length>0&&!s.some((function(n){switch(n){case e.GroupChannelSearchField.CHANNEL_NAME:return t.name.toLowerCase().includes(i.toLowerCase());case e.GroupChannelSearchField.MEMBER_NICKNAME:return t.members.some((function(e){return e.nickname.toLowerCase().includes(i.toLowerCase())}));default:return!0}})))return!1}if(this._userIdsFilter){var a=this._userIdsFilter,c=a.userIds,l=a.includeMode,h=a.queryType,d=t.members.map((function(e){return e.userId}));if(l){if(c.length>0)switch(h){case e.QueryType.AND:if(c.some((function(e){return!d.includes(e)})))return!1;break;case e.QueryType.OR:if(c.every((function(e){return!d.includes(e)})))return!1}}else{if(c.includes(n)||c.push(n),t.members.length>c.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=u([],o(e),!1).sort(),r=u([],o(t),!1).sort(),i=0;i0&&!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 p=this.nicknameContainsFilter.toLowerCase();if(t.members.every((function(e){return!e.nickname.toLowerCase().includes(p)})))return!1}if(this.nicknameStartsWithFilter){var f=this.nicknameStartsWithFilter.toLowerCase();if(t.members.every((function(e){return!e.nickname.toLowerCase().startsWith(f)})))return!1}if(this.nicknameExactMatchFilter){var _=this.nicknameExactMatchFilter.toLowerCase();if(t.members.every((function(e){return e.nickname.toLowerCase()!=_})))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}(),Bo=function(t){function c(e,n){var r=n.sdkState,i=n.cacheContext,s=t.call(this,e)||this;return s._channels=new Map,s._sdkState=r,s._cacheContext=i,s}return n(c,t),Object.defineProperty(c.prototype,"collection",{get:function(){var e=this._cacheContext.nestdb;return e?e.collection(Ir):null},enumerable:!1,configurable:!0}),Object.defineProperty(c.prototype,"localCacheEnabled",{get:function(){return this._cacheContext.localCacheEnabled&&!!this.collection},enumerable:!1,configurable:!0}),c.prototype._serialize=function(e,t){return void 0===t&&(t=0),r(r({},e.serialize()),{lastMessageUpdatedAt:e.lastMessage?e.lastMessage.createdAt:0,syncIndex:t})},c.prototype._deserialize=function(e){return hc.of(this._iid).buildGroupChannelFromSerializedData(e)},Object.defineProperty(c.prototype,"channels",{get:function(){return u([],o(this._channels.values()),!1)},enumerable:!1,configurable:!0}),c.prototype.isCachedInMemory=function(e){return this._channels.has(e)},c.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;break;case e.GroupChannelListOrder.CHRONOLOGICAL:if(!u&&t.createdAt>n||u&&t.createdAtn||u&&t.lastMessageUpdatedAt0?[4,this.upsert(r)]:[3,2];case 1:s.sent(),s.label=2;case 2:return[2]}}))}))},c.prototype.block=function(e,t){return i(this,void 0,void 0,(function(){return s(this,(function(n){switch(n.label){case 0:return[4,this._setBlockStateOfAllChannels(e,t,!0)];case 1:return n.sent(),[2]}}))}))},c.prototype.unblock=function(e,t){return i(this,void 0,void 0,(function(){return s(this,(function(n){switch(n.label){case 0:return[4,this._setBlockStateOfAllChannels(e,t,!1)];case 1:return n.sent(),[2]}}))}))},c.prototype.markAsRead=function(e,t){return void 0===t&&(t=u([],o(this._channels.keys()),!1)),i(this,void 0,void 0,(function(){var n,r,i,o,u,c,l,h;return s(this,(function(s){switch(s.label){case 0:n=[],s.label=1;case 1:s.trys.push([1,6,7,8]),r=a(t),i=r.next(),s.label=2;case 2:return i.done?[3,5]:(o=i.value,[4,this.get(o)]);case 3:(u=s.sent())._updateUnreadMemberState(this._sdkState.userId,e)&&(u._updateUnreadCount(0,0),n.push(u)),s.label=4;case 4:return i=r.next(),[3,2];case 5:return[3,8];case 6:return c=s.sent(),l={error:c},[3,8];case 7:try{i&&!i.done&&(h=r.return)&&h.call(r)}finally{if(l)throw l.error}return[7];case 8:return n.length>0?[4,this.upsert(n)]:[3,10];case 9:s.sent(),s.label=10;case 10:return[2]}}))}))},c}(We);!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"}(Ko||(Ko={}));var jo,zo=function(){function t(e){this.channelUrl=e.channel_url,this.channelType=e.channel_type,this.category=e.cat,this.data=e.data,this.ts=e.ts}return Object.defineProperty(t.prototype,"isGroupChannelEvent",{get:function(){return this.channelType===e.ChannelType.GROUP},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"isOpenChannelEvent",{get:function(){return this.channelType===e.ChannelType.OPEN},enumerable:!1,configurable:!0}),t}(),Wo={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},Yo=function(e){return b("string",e.invitedUserIds,!0)&&g("string",e.channelUrl,!0)&&g("string",e.coverUrl,!0)&&(T(e.coverImage)||g("string",e.coverImage)||null===e.coverImage)&&g("boolean",e.isDistinct,!0)&&g("boolean",e.isSuper,!0)&&g("boolean",e.isBroadcast,!0)&&g("boolean",e.isExclusive,!0)&&g("boolean",e.isPublic,!0)&&g("boolean",e.isStrict,!0)&&g("boolean",e.isDiscoverable,!0)&&g("boolean",e.isEphemeral,!0)&&g("string",e.accessCode,!0)&&g("string",e.name,!0)&&g("string",e.data,!0)&&g("string",e.customType,!0)&&b("string",e.operatorUserIds,!0)&&g("number",e.messageSurvivalSeconds,!0)},Jo={customTypes:null,includeEmpty:!1,includeFrozen:!0},Xo=function(e){return b("string",e.customTypes,!0)&&g("boolean",e.includeEmpty)&&g("boolean",e.includeFrozen)},Zo={myMemberStateFilter:e.MyMemberStateFilter.ALL},$o=function(t){return y(e.MyMemberStateFilter,t.myMemberStateFilter)};e.UnreadItemKey=void 0,(jo=e.UnreadItemKey||(e.UnreadItemKey={})).GROUP_CHANNEL_UNREAD_MENTION_COUNT="group_channel_unread_mention_count",jo.NONSUPER_UNREAD_MENTION_COUNT="non_super_group_channel_unread_mention_count",jo.SUPER_UNREAD_MENTION_COUNT="super_group_channel_unread_mention_count",jo.GROUP_CHANNEL_UNREAD_MESSAGE_COUNT="group_channel_unread_message_count",jo.NONSUPER_UNREAD_MESSAGE_COUNT="non_super_group_channel_unread_message_count",jo.SUPER_UNREAD_MESSAGE_COUNT="super_group_channel_unread_message_count",jo.GROUP_CHANNEL_INVITATION_COUNT="group_channel_invitation_count",jo.NONSUPER_INVITATION_COUNT="non_super_group_channel_invitation_count",jo.SUPER_INVITATION_COUNT="super_group_channel_invitation_count";var eu,tu={keys:[]},nu={channelCustomTypesFilter:null,superChannelFilter:e.SuperChannelFilter.ALL},ru={channelUrl:null,scheduledStatus:null,messageTypeFilter:e.MessageTypeFilter.ALL};e.GroupChannelEventSource=void 0,(eu=e.GroupChannelEventSource||(e.GroupChannelEventSource={})).UNKNOWN="UNKNOWN",eu.EVENT_CHANNEL_CREATED="EVENT_CHANNEL_CREATED",eu.EVENT_CHANNEL_UPDATED="EVENT_CHANNEL_UPDATED",eu.EVENT_CHANNEL_DELETED="EVENT_CHANNEL_DELETED",eu.EVENT_CHANNEL_READ="EVENT_CHANNEL_READ",eu.EVENT_CHANNEL_DELIVERED="EVENT_CHANNEL_DELIVERED",eu.EVENT_CHANNEL_INVITED="EVENT_CHANNEL_INVITED",eu.EVENT_CHANNEL_JOINED="EVENT_CHANNEL_JOINED",eu.EVENT_CHANNEL_LEFT="EVENT_CHANNEL_LEFT",eu.EVENT_CHANNEL_ACCEPTED_INVITE="EVENT_CHANNEL_ACCEPTED_INVITE",eu.EVENT_CHANNEL_DECLINED_INVITE="EVENT_CHANNEL_DECLINED_INVITE",eu.EVENT_CHANNEL_OPERATOR_UPDATED="EVENT_CHANNEL_OPERATOR_UPDATED",eu.EVENT_CHANNEL_MUTED="EVENT_CHANNEL_MUTED",eu.EVENT_CHANNEL_UNMUTED="EVENT_CHANNEL_UNMUTED",eu.EVENT_CHANNEL_FROZEN="EVENT_CHANNEL_FROZEN",eu.EVENT_CHANNEL_UNFROZEN="EVENT_CHANNEL_UNFROZEN",eu.EVENT_CHANNEL_HIDDEN="EVENT_CHANNEL_HIDDEN",eu.EVENT_CHANNEL_UNHIDDEN="EVENT_CHANNEL_UNHIDDEN",eu.EVENT_CHANNEL_RESET_HISTORY="EVENT_CHANNEL_RESET_HISTORY",eu.EVENT_CHANNEL_TYPING_STATUS_UPDATE="EVENT_CHANNEL_TYPING_STATUS_UPDATE",eu.EVENT_CHANNEL_MEMBER_COUNT_UPDATED="EVENT_CHANNEL_MEMBER_COUNT_UPDATED",eu.EVENT_MESSAGE_SENT="EVENT_MESSAGE_SENT",eu.EVENT_MESSAGE_RECEIVED="EVENT_MESSAGE_RECEIVED",eu.EVENT_MESSAGE_UPDATED="EVENT_MESSAGE_UPDATED",eu.REQUEST_CHANNEL="REQUEST_CHANNEL",eu.REQUEST_CHANNEL_CHANGELOGS="REQUEST_CHANNEL_CHANGELOGS",eu.SYNC_CHANNEL_BACKGROUND="SYNC_CHANNEL_BACKGROUND",eu.SYNC_CHANNEL_CHANGELOGS="SYNC_CHANNEL_CHANGELOGS";var iu=function(t){return t.startsWith("EVENT_")||t===e.GroupChannelEventSource.SYNC_CHANNEL_BACKGROUND||t===e.GroupChannelEventSource.SYNC_CHANNEL_CHANGELOGS},su=function(e){function t(t){var n=t.channels,r=t.source,i=e.call(this)||this;return i.channels=n,i.source=r,i}return n(t,e),t}(k),au=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 n(t,e),t}(k),ou=function(){function e(e){var t=e.groupChannelCache,n=e.messageCache,r=e.unsentMessageCache,o=e.dispatcher,u=this;this._observers=new Map,o.on((function(e){return i(u,void 0,void 0,(function(){var o,u,c,l,h,d,p,f,_,v,m=this;return s(this,(function(g){switch(g.label){case 0:if(!(e instanceof su))return[3,2];o=e.channels,f=e.source,u=o.filter((function(e){return e instanceof wl})),c=t.filterOffsetChanged(u);try{for(l=a(c),h=l.next();!h.done;h=l.next())d=h.value,n.removeUnderOffset(d.url,d.messageOffsetTimestamp)}catch(e){_={error:e}}finally{try{h&&!h.done&&(v=l.return)&&v.call(l)}finally{if(_)throw _.error}}return[4,t.upsert(u)];case 1:return g.sent(),this._broadcastUpdateEvent(u,f),[3,7];case 2:return e instanceof au?(p=e.channelUrls,f=e.source,[4,t.remove(p)]):[3,5];case 3:return g.sent(),[4,Pe((function(){return i(m,void 0,void 0,(function(){var e,t,i,o,u,c;return s(this,(function(s){switch(s.label){case 0:s.trys.push([0,6,7,8]),e=a(p),t=e.next(),s.label=1;case 1:return t.done?[3,5]:(i=t.value,[4,n.removeMessagesOfChannel(i)]);case 2:return s.sent(),[4,r.removeMessagesOfChannel(i)];case 3:s.sent(),s.label=4;case 4:return t=e.next(),[3,1];case 5:return[3,8];case 6:return o=s.sent(),u={error:o},[3,8];case 7:try{t&&!t.done&&(c=e.return)&&c.call(e)}finally{if(u)throw u.error}return[7];case 8:return[2]}}))}))}))];case 4:return g.sent(),this._broadcastRemoveEvent(p,f),[3,7];case 5:return e instanceof ni?[4,t.fetch({token:Number.MAX_SAFE_INTEGER,limit:Number.MAX_SAFE_INTEGER})]:[3,7];case 6:g.sent(),g.label=7;case 7:return[2]}}))}))}))}return e.prototype._broadcastUpdateEvent=function(e,t){var n,r;try{for(var i=a(this._observers.values()),s=i.next();!s.done;s=i.next()){s.value.onUpdate(e,t)}}catch(e){n={error:e}}finally{try{s&&!s.done&&(r=i.return)&&r.call(i)}finally{if(n)throw n.error}}},e.prototype._broadcastRemoveEvent=function(e,t){var n,r;try{for(var i=a(this._observers.values()),s=i.next();!s.done;s=i.next()){s.value.onRemove(e,t)}}catch(e){n={error:e}}finally{try{s&&!s.done&&(r=i.return)&&r.call(i)}finally{if(n)throw n.error}}},e.prototype.subscribe=function(e,t){this._observers.set(e,t)},e.prototype.unsubscribe=function(e){this._observers.delete(e)},e}(),uu=function(){function e(e){var t=e.cacheContext,n=e.messageCache,r=e.unsentMessageCache,a=e.dispatcher,o=e.logger,u=this;this._cacheContext=null,this._observers=new Map,this._logger=null,this._cacheContext=t,this._logger=o,a.on((function(e){return i(u,void 0,void 0,(function(){var t,a,o,u,c,l,h,d,p,f,_,v,m,g=this;return s(this,(function(y){switch(y.label){case 0:return e instanceof yn?(t=e.messages,v=e.source,a=t.filter((function(e){return e.messageId>0})),o=t.filter((function(e){return 0===e.messageId})),a.length>0?[4,Pe((function(){return i(g,void 0,void 0,(function(){return s(this,(function(e){switch(e.label){case 0:return[4,n.upsert(a)];case 1:return e.sent(),[4,r.remove(a.map((function(e){return e instanceof Bt?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(a,v),y.label=2;case 2:return o.length>0?[4,Pe((function(){return i(g,void 0,void 0,(function(){return s(this,(function(e){switch(e.label){case 0:return[4,r.upsert(o)];case 1:return e.sent(),[2]}}))}))}))]:[3,4];case 3:y.sent(),this._broadcastUpdateEvent(o,v),y.label=4;case 4:return[3,21];case 5:return e instanceof En?(u=e.messageIds,v=e.source,[4,Pe((function(){return i(g,void 0,void 0,(function(){return s(this,(function(e){switch(e.label){case 0:return[4,n.remove(u)];case 1:return e.sent(),[2]}}))}))}))]):[3,7];case 6:return y.sent(),this._broadcastRemoveEvent(u,v),[3,21];case 7:return e instanceof bn?(c=e.reqId,v=e.source,[4,Pe((function(){return i(g,void 0,void 0,(function(){return s(this,(function(e){switch(e.label){case 0:return[4,r.remove([c])];case 1:return e.sent(),[2]}}))}))}))]):[3,9];case 8:return y.sent(),this._broadcastRemoveUnsentEvent(c,v),[3,21];case 9:return e instanceof Cn?(l=e.polls,v=e.source,this._cacheContext.localCacheEnabled?(h=l.map((function(e){return e.messageId})),[4,Promise.all(h.map((function(e){return n.get(e)})))]):[3,12]):[3,13];case 10:return(d=y.sent().filter((function(e){return e}))).length>0&&l.forEach((function(e){var t=d.find((function(t){return t.messageId===e.messageId}));t&&t.applyPoll(e)})),[4,Pe((function(){return i(g,void 0,void 0,(function(){return s(this,(function(e){switch(e.label){case 0:return[4,n.upsert(d)];case 1:return[2,e.sent()]}}))}))}))];case 11:y.sent(),y.label=12;case 12:return this._broadcastPollChangeLogEvent(l,v),[3,21];case 13:return e instanceof Tn?(p=e.event,v=e.source,[4,n.get(p.messageId)]):[3,17];case 14:return(f=y.sent())&&f.isUserMessage()&&f.poll&&f.poll.applyPollUpdateEvent(p)?[4,Pe((function(){return i(g,void 0,void 0,(function(){return s(this,(function(e){switch(e.label){case 0:return[4,n.upsert([f])];case 1:return[2,e.sent()]}}))}))}))]:[3,16];case 15:y.sent(),y.label=16;case 16:return this._broadcastPollUpdateEvent(p,v),[3,21];case 17:return e instanceof In?(_=e.event,v=e.source,[4,n.get(_.messageId)]):[3,21];case 18:return(m=y.sent())&&m.isUserMessage()&&m.poll&&m.poll.applyPollVoteEvent(_)?[4,Pe((function(){return i(g,void 0,void 0,(function(){return s(this,(function(e){switch(e.label){case 0:return[4,n.upsert([m])];case 1:return[2,e.sent()]}}))}))}))]:[3,20];case 19:y.sent(),y.label=20;case 20:this._broadcastPollVoteEvent(_,v),y.label=21;case 21:return[2]}}))}))}))}return e.prototype._broadcastUpdateEvent=function(e,t){var n,r;try{for(var i=a(this._observers.values()),s=i.next();!s.done;s=i.next()){s.value.onUpdate(e,t)}}catch(e){n={error:e}}finally{try{s&&!s.done&&(r=i.return)&&r.call(i)}finally{if(n)throw n.error}}},e.prototype._broadcastPollChangeLogEvent=function(e,t){var n,r;try{for(var i=a(this._observers.values()),s=i.next();!s.done;s=i.next()){s.value.onPollChangeLogUpdate(e,t)}}catch(e){n={error:e}}finally{try{s&&!s.done&&(r=i.return)&&r.call(i)}finally{if(n)throw n.error}}},e.prototype._broadcastPollUpdateEvent=function(e,t){var n,r;try{for(var i=a(this._observers.values()),s=i.next();!s.done;s=i.next()){s.value.onPollUpdate(e,t)}}catch(e){n={error:e}}finally{try{s&&!s.done&&(r=i.return)&&r.call(i)}finally{if(n)throw n.error}}},e.prototype._broadcastPollVoteEvent=function(e,t){var n,r;try{for(var i=a(this._observers.values()),s=i.next();!s.done;s=i.next()){s.value.onPollVote(e,t)}}catch(e){n={error:e}}finally{try{s&&!s.done&&(r=i.return)&&r.call(i)}finally{if(n)throw n.error}}},e.prototype._broadcastRemoveEvent=function(e,t){var n,r;try{for(var i=a(this._observers.values()),s=i.next();!s.done;s=i.next()){s.value.onRemove(e,t)}}catch(e){n={error:e}}finally{try{s&&!s.done&&(r=i.return)&&r.call(i)}finally{if(n)throw n.error}}},e.prototype._broadcastRemoveUnsentEvent=function(e,t){var n,r;try{for(var i=a(this._observers.values()),s=i.next();!s.done;s=i.next()){s.value.onRemoveUnsent(e,t)}}catch(e){n={error:e}}finally{try{s&&!s.done&&(r=i.return)&&r.call(i)}finally{if(n)throw n.error}}},e.prototype.subscribe=function(e,t){this._observers.set(e,t)},e.prototype.unsubscribe=function(e){this._observers.delete(e)},e}(),cu=function(e){function t(t){var n=t.userId,i=t.ts,s=t.token,a=t.filter,o=e.call(this)||this,u=r(r({},Jo),a),c=u.customTypes,l=u.includeEmpty,h=u.includeFrozen;return o.method=d.GET,o.path="".concat(fe,"/").concat(encodeURIComponent(n),"/my_group_channels/changelogs"),o.params=D({show_delivery_receipt:!0,show_member:!0,show_read_receipt:!0,change_ts:i>0?i:null,token:s,custom_types:c,show_empty:l,show_frozen:h}),o}return n(t,e),t}(x),lu=function(e){function t(t,n){var r=e.call(this,t,n)||this;return r.updatedChannels=n.updated.map((function(e){return new wl(t,e)})),r.deletedChannelUrls=n.deleted,r.hasMore=n.has_more,r.token=n.next,r}return n(t,e),t}(F),hu=function(e){function t(t){var n=t.channelUrl,r=t.isInternalCall,i=e.call(this)||this;return i.method=d.GET,i.path="".concat(r?me:ve,"/").concat(encodeURIComponent(n)),i.params={show_member:!0,show_read_receipt:!0,show_delivery_receipt:!0},i}return n(t,e),t}(x),du=function(e){function t(t,n){var r=e.call(this,t,n)||this;return r.channel=null,r.channel=new wl(t,n),r}return n(t,e),t}(F),pu=function(e){function t(t){var n=this,r=t.userId,i=t.token,s=t.limit,a=t.order,o=t.includeEmpty,u=t.myMemberStateFilter,c=t.superChannelFilter,l=t.publicChannelFilter,h=t.unreadChannelFilter,p=t.nicknameContainsFilter,f=t.nicknameStartsWithFilter,_=t.nicknameExactMatchFilter,v=t.channelNameContainsFilter,m=t.channelUrlsFilter,g=t.customTypesFilter,y=t.customTypeStartsWithFilter,E=t.hiddenChannelFilter,b=t.metadataOrderKeyFilter,C=t.metadataKey,T=t.metadataValues,I=t.metadataValueStartsWith,S=t.includeFrozen,N=t.includeMetaData,w=t.searchFilter,M=t.userIdsFilter;return(n=e.call(this)||this).method=d.GET,n.path="".concat(fe,"/").concat(encodeURIComponent(r),"/my_group_channels"),n.params=D({token:i,limit:s,order:a,show_member:!0,show_read_receipt:!0,show_delivery_receipt:!0,show_empty:o,member_state_filter:u,super_mode:c,public_mode:l,unread_filter:h,members_nickname_contains:p,members_nickname_startswith:f,members_nickname:_,name_contains:v,channel_urls:m,custom_types:g,custom_type_startswith:y,hidden_mode:E,metadata_order_key:b,metadata_key:C,metadata_values:T,metadata_value_startswith:I,show_frozen:S,show_metadata:N}),w&&w.query&&w.fields&&(n.params.search_query=w.query,n.params.search_fields=w.fields),M&&M.userIds&&M.userIds.length>0&&(M.includeMode?(n.params.members_include_in=M.userIds,n.params.query_type=M.queryType.toUpperCase()):n.params.members_exactly_in=M.userIds),n}return n(t,e),t}(x),fu=function(e){function t(t,n){var r=e.call(this,t,n)||this;r.token=null,r.channels=[],r.ts=null;var i=n.next,s=n.channels,a=n.ts;return r.token=i,s&&s.length>0&&(r.channels=s.map((function(e){return e.ts=a,new wl(t,e)}))),r.ts=null!=a?a:null,r}return n(t,e),t}(F),_u=function(t){function r(n){var r=n.userId,i=n.filter,s=t.call(this)||this,a=i.myMemberStateFilter;return s.method=d.GET,s.path="".concat(fe,"/").concat(encodeURIComponent(r),"/group_channel_count"),s.params={state:null!=a?a:e.MyMemberStateFilter.ALL},s}return n(r,t),r}(x),vu=function(e){function t(t,n){var r=e.call(this,t,n)||this;return r.groupChannelCount=n.group_channel_count,r}return n(t,e),t}(F),mu=function(e){function t(t){var n=t.userId,r=t.filter,i=e.call(this)||this,s=r.keys;return i.method=d.GET,i.path="".concat(fe,"/").concat(encodeURIComponent(n),"/unread_item_count"),i.params={item_keys:s},i}return n(t,e),t}(x),gu=function(t){function r(n,r){var i=t.call(this,n,r)||this;return"number"==typeof r[e.UnreadItemKey.GROUP_CHANNEL_UNREAD_MENTION_COUNT]&&(i.groupChannelUnreadMentionCount=r[e.UnreadItemKey.GROUP_CHANNEL_UNREAD_MENTION_COUNT]),"number"==typeof r[e.UnreadItemKey.GROUP_CHANNEL_UNREAD_MESSAGE_COUNT]&&(i.groupChannelUnreadMessageCount=r[e.UnreadItemKey.GROUP_CHANNEL_UNREAD_MESSAGE_COUNT]),"number"==typeof r[e.UnreadItemKey.GROUP_CHANNEL_INVITATION_COUNT]&&(i.groupChannelInvitationCount=r[e.UnreadItemKey.GROUP_CHANNEL_INVITATION_COUNT]),"number"==typeof r[e.UnreadItemKey.SUPER_UNREAD_MENTION_COUNT]&&(i.superGroupChannelUnreadMentionCount=r[e.UnreadItemKey.SUPER_UNREAD_MENTION_COUNT]),"number"==typeof r[e.UnreadItemKey.SUPER_UNREAD_MESSAGE_COUNT]&&(i.superGroupChannelUnreadMessageCount=r[e.UnreadItemKey.SUPER_UNREAD_MESSAGE_COUNT]),"number"==typeof r[e.UnreadItemKey.SUPER_INVITATION_COUNT]&&(i.superGroupChannelInvitationCount=r[e.UnreadItemKey.SUPER_INVITATION_COUNT]),"number"==typeof r[e.UnreadItemKey.NONSUPER_UNREAD_MENTION_COUNT]&&(i.nonSuperGroupChannelUnreadMentionCount=r[e.UnreadItemKey.NONSUPER_UNREAD_MENTION_COUNT]),"number"==typeof r[e.UnreadItemKey.NONSUPER_UNREAD_MESSAGE_COUNT]&&(i.nonSuperGroupChannelUnreadMessageCount=r[e.UnreadItemKey.NONSUPER_UNREAD_MESSAGE_COUNT]),"number"==typeof r[e.UnreadItemKey.NONSUPER_INVITATION_COUNT]&&(i.nonSuperGroupChannelInvitationCount=r[e.UnreadItemKey.NONSUPER_INVITATION_COUNT]),i}return n(r,t),r}(F),yu=function(e){function t(t){var n=t.userId,r=e.call(this)||this;return r.method=d.GET,r.path="".concat(fe,"/").concat(encodeURIComponent(n),"/unread_channel_count"),r}return n(t,e),t}(x),Eu=function(e){function t(t,n){var r=e.call(this,t,n)||this;return r.unreadCount=n.unread_count,r}return n(t,e),t}(F),bu=function(t){function r(n){var r=n.userId,i=n.filter,s=t.call(this)||this,a=i.channelCustomTypesFilter,o=i.superChannelFilter;return s.method=d.GET,s.path="".concat(fe,"/").concat(encodeURIComponent(r),"/unread_message_count"),s.params={super_mode:null!=o?o:e.SuperChannelFilter.ALL,custom_types:a},s}return n(r,t),r}(x),Cu=function(e){function t(t,n){var r=e.call(this,t,n)||this;return r.unreadCount=n.unread_count,r}return n(t,e),t}(F),Tu=function(e){function t(t){var n=t.channelUrl,r=t.scheduledStatus,i=t.messageTypeFilter,s=e.call(this)||this;return s.method=d.GET,s.path="".concat(Se,"/count"),s.params={channel_url:n,status:Su(r)},i&&(s.params.message_type=i),s}return n(t,e),t}(x),Iu=function(e){function t(t,n){var r=e.call(this,t,n)||this;return r.count=n.count,r}return n(t,e),t}(F),Su=function(t){if(t){var n=[];return t.forEach((function(t){switch(t){case e.ScheduledStatus.PENDING:n.push(kt.PENDING);break;case e.ScheduledStatus.SENT:n.push(kt.IN_QUEUE),n.push(kt.SENT);break;case e.ScheduledStatus.CANCELED:n.push(kt.CANCELED);break;case e.ScheduledStatus.FAILED:n.push(kt.FAILED)}})),n}},Nu=function(e){function t(t){var n=this,r=t.userId,i=t.channelUrl,s=t.coverUrl,a=t.coverImage,c=t.isDistinct,l=t.isSuper,h=t.isBroadcast,p=t.isPublic,f=t.isExclusive,_=t.isDiscoverable,v=t.isStrict,m=t.isEphemeral,g=t.accessCode,y=t.name,E=t.data,b=t.customType,C=t.messageSurvivalSeconds,T=t.invitedUserIds,I=t.operatorUserIds;return(n=e.call(this)||this).method=d.POST,n.path=ve,n.params=D({user_ids:u([r],o(null!=T?T:[]),!1).filter((function(e,t,n){return t===n.indexOf(e)})),channel_url:i,cover_url:s,cover_file:a,is_distinct:c,is_super:l,is_broadcast:h,is_exclusive:f,is_public:p,is_discoverable:_,strict:v,is_ephemeral:m,access_code:g,name:y,data:E,custom_type:b,operator_ids:I,message_survival_seconds:C}),n}return n(t,e),t}(x),wu=function(e){function t(t,n){var r=e.call(this,t,n)||this;return r.channel=new wl(t,n),r.isCreated=n.is_created,r}return n(t,e),t}(F),Mu=function(e){function t(t){var n=t.userId,r=t.channelUrls,i=e.call(this)||this;return i.method=d.PUT,i.path="".concat(fe,"/").concat(encodeURIComponent(n),"/mark_as_read_all"),i.params={channel_urls:r},i}return n(t,e),t}(x);!function(e){function t(){return null!==e&&e.apply(this,arguments)||this}n(t,e)}(F);var Au=function(e){function t(t,n,r){var i=e.call(this,t,"SYEV",r)||this;return i.event=new zo(r),i}return n(t,e),t}(j),Uu=function(e){function t(t){var n=this,r=t.channelUrl,i=t.userId,s=t.accessCode;return(n=e.call(this)||this).method=d.PUT,n.path="".concat(ve,"/").concat(encodeURIComponent(r),"/join"),n.params={user_id:i,access_code:s},n}return n(t,e),t}(x),Ou=function(e){function t(t,n){var r=e.call(this,t,n)||this;return r.channel=new wl(t,n),r}return n(t,e),t}(F),Ru=function(e){function t(t,n,r){var i=e.call(this,t,n,r)||this,s=r.data,a=s.member_count,o=void 0===a?null:a,u=s.joined_member_count,c=void 0===u?null:u,l=s.users,h=void 0===l?null:l;return i.memberCount=o,i.joinedMemberCount=c,i.members=Array.isArray(h)?h.map((function(e){return new Ho(t,e)})):[new Ho(t,r.data)],i}return n(t,e),t}(Au),Lu=function(e){function t(t){var n=this,r=t.channelUrl,i=t.userId,s=t.shouldRemoveOperatorStatus;return(n=e.call(this)||this).method=d.PUT,n.path="".concat(ve,"/").concat(encodeURIComponent(r),"/leave"),n.params={user_id:i,should_remove_operator_status:s},n}return n(t,e),t}(x);!function(e){function t(t,n){return e.call(this,t,n)||this}n(t,e)}(F);var ku=function(e){function t(t,n,r){var i=e.call(this,t,n,r)||this,s=r.data,a=s.member_count,o=void 0===a?null:a,u=s.joined_member_count,c=void 0===u?null:u;return i.memberCount=o,i.joinedMemberCount=c,i.member=new Ho(i._iid,r.data),i}return n(t,e),t}(Au),Du=function(e){function t(t){var n=this,r=t.channelUrl,i=t.userIds;return(n=e.call(this)||this).method=d.POST,n.path="".concat(ve,"/").concat(encodeURIComponent(r),"/invite"),n.params={user_ids:i},n}return n(t,e),t}(x),Pu=function(e){function t(t,n){var r=e.call(this,t,n)||this;return r.channel=new wl(t,n),r}return n(t,e),t}(F),xu=function(e){function t(t,n,r){var i=e.call(this,t,n,r)||this,s=r.data,a=s.member_count,o=void 0===a?null:a,u=s.joined_member_count,c=void 0===u?null:u,l=s.inviter,h=void 0===l?null:l,d=s.invitees,p=void 0===d?[]:d;return i.memberCount=o,i.joinedMemberCount=c,i.inviter=h?new ht(t,h):null,i.invitees=p.map((function(e){return new Ho(t,e)})),i}return n(t,e),t}(Au),Fu=function(e){function t(t){var n=this,r=t.channelUrl,i=t.userId;return(n=e.call(this)||this).method=d.PUT,n.path="".concat(ve,"/").concat(encodeURIComponent(r),"/decline"),n.params={user_id:i},n}return n(t,e),t}(x),qu=function(t){function r(n,r){var i=t.call(this,n,r)||this;return i.channel=new wl(n,r),i.channel.myMemberState=e.MemberState.NONE,i}return n(r,t),r}(F),Gu=function(e){function t(t,n,r){var i=e.call(this,t,n,r)||this,s=r.data,a=s.member_count,o=void 0===a?null:a,u=s.joined_member_count,c=void 0===u?null:u,l=s.inviter,h=void 0===l?null:l,d=s.invitee,p=void 0===d?null:d;return i.memberCount=o,i.joinedMemberCount=c,i.inviter=h?new ht(t,h):null,i.invitee=p?new Ho(t,p):null,i}return n(t,e),t}(Au),Hu=function(e){function t(t){var n=t.channelUrl;return e.call(this,{code:"READ",ackRequired:!0,payload:{channel_url:n}})||this}return n(t,e),t}(z),Vu=function(e){function t(t,n,r){var i=e.call(this,t,"READ",r)||this;return i.readStatus=new Vo(t,r),i}return n(t,e),t}(j),Ku=function(e){function t(t){var n=t.channelUrl,r=t.userId,i=e.call(this)||this;return(i=e.call(this)||this).method=d.PUT,i.path="".concat(ve,"/").concat(encodeURIComponent(n),"/messages/mark_as_delivered"),i.params=D({userId:r}),i}return n(t,e),t}(x);!function(e){function t(){return null!==e&&e.apply(this,arguments)||this}n(t,e)}(F);var Qu,Bu=function(e){function t(t,n,r){var i=e.call(this,t,"DLVR",r)||this;return i.channelUrl=r.channel_url,i.deliveredStateUpdate=r.updated,i}return n(t,e),t}(j),ju=function(e){function t(t){var n=this,r=t.channelUrl,i=t.userId,s=t.hidePreviousMessages,a=t.allowAutoUnhide;return(n=e.call(this)||this).method=d.PUT,n.path="".concat(ve,"/").concat(encodeURIComponent(r),"/hide"),n.params={user_id:i,hide_previous_messages:s,allow_auto_unhide:a},n}return n(t,e),t}(x),zu=function(e){function t(t,n){var r=e.call(this,t,n)||this;r.messageOffsetTimestamp=null;var i=n.ts_message_offset;return r.messageOffsetTimestamp=null!=i?i:null,r}return n(t,e),t}(F),Wu=function(e){function t(t,n,r){var i=e.call(this,t,"SYEV",r)||this;return i.allowAutoUnhide=null,i.hidePreviousMessages=null,i.messageOffsetTimestamp=null,r.data&&(i.allowAutoUnhide=r.data.allow_auto_unhide,i.hidePreviousMessages=r.data.hide_previous_messages),i.messageOffsetTimestamp=r.ts_message_offset,i}return n(t,e),t}(j),Yu=function(e){function t(t){var n=t.channelUrl,r=t.time;return e.call(this,{code:"TPST",ackRequired:!1,payload:{channel_url:n,time:r}})||this}return n(t,e),t}(z),Ju=function(e){function t(t,n,r){var i=e.call(this,t,"SYEV",r)||this;return i.user=new ht(t,r.data),i}return n(t,e),t}(j),Xu=function(e){function t(t){var n=t.channelUrl,r=t.time;return e.call(this,{code:"TPEN",ackRequired:!1,payload:{channel_url:n,time:r}})||this}return n(t,e),t}(z),Zu=function(e){function t(t,n,r){var i=e.call(this,t,"SYEV",r)||this;return i.user=new ht(t,r.data),i}return n(t,e),t}(j),$u=function(e){function t(t,n,r){var i=e.call(this,t,n,r)||this,s=r.data.operators,a=void 0===s?[]:s;return i.operators=a.map((function(e){return new ht(i._iid,e)})),i}return n(t,e),t}(Au),ec=function(e){function t(t,n,r){var i=e.call(this,t,"MCNT",r)||this;return i.groupChannelMemberCounts=r.group_channels.map((function(e){return{channelUrl:e.channel_url,memberCount:e.member_count,joinedMemberCount:e.joined_member_count,updatedAt:e.ts}})),i.openChannelMemberCounts=r.open_channels.map((function(e){return{channelUrl:e.channel_url,participantCount:e.participant_count,updatedAt:e.ts}})),i}return n(t,e),t}(j),tc=function(e){function t(t){var n=t.channelUrl,r=t.messageId;return e.call(this,{code:"MACK",ackRequired:!1,payload:{channel_url:n,msg_id:r}})||this}return n(t,e),t}(z),nc=function(e){function t(t,n,r){var i,s,a,o=this;(o=e.call(this,t,"ADMM",r)||this).message=new Yt(t,r);var u=wt.of(t).sdkState;return o.isMentioned=Ze(o.message.mentionType,null!==(i=o.message.mentionedUserIds)&&void 0!==i?i:null===(s=o.message.mentionedUsers)||void 0===s?void 0:s.map((function(e){return e.userId})),u.userId),o.forceUpdateLastMessage=null!==(a=r.force_update_last_message)&&void 0!==a&&a,o}return n(t,e),t}(j),rc=function(e){function t(t,n,r){var i,s,a,o,u,c,l=this;(l=e.call(this,t,"AEDI",r)||this).message=new Yt(t,r);var h=wt.of(t).sdkState;return l.mentionCountChange=$e({mentionType:null!==(s=null===(i=r.old_values)||void 0===i?void 0:i.mention_type)&&void 0!==s?s:null,mentionedUserIds:null!==(o=null===(a=r.old_values)||void 0===a?void 0:a.mentioned_user_ids)&&void 0!==o?o:[]},{mentionType:l.message.mentionType,mentionedUserIds:null!==(u=l.message.mentionedUserIds)&&void 0!==u?u:null===(c=l.message.mentionedUsers)||void 0===c?void 0:c.map((function(e){return e.userId}))},h.userId),l}return n(t,e),t}(j),ic=function(e){function t(t,n,r){var i=e.call(this,t,"MRCT",r)||this;return i.channelUrl=r.channel_url,i.channelType=r.channel_type,i.event=new Dt(r),i}return n(t,e),t}(j),sc=function(e){function t(t,n,r){var i=e.call(this,t,"MTHD",r)||this;return i.event=new Pn(t,r),i}return n(t,e),t}(j),ac=function(e){function t(t,n,r){var i=e.call(this,t,"PEDI",r)||this;return i.event=null,i.status=null,i.channelUrl=null,i.channelType=null,i.event=new hr(t,r),i.status=Zt(r.poll.status)||r.poll.status,i.channelUrl=r.channel_url,i.channelType=r.channel_type,i}return n(t,e),t}(j),oc=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 dr(r),i.channelUrl=r.channel_url,i.channelType=r.channel_type,i}return n(t,e),t}(j),uc=function(t){function r(n,r){var i,s,a,o,u,c,l,h,d,p,f,_,v,m,g,y,E,b,C,T,I,S,N=this;return(N=t.call(this,n,r)||this).includeEmpty=!1,N.includeFrozen=!0,N.includeMetaData=!0,N.channelUrlsFilter=null,N.customTypesFilter=null,N.customTypeStartsWithFilter=null,N.nicknameContainsFilter=null,N.nicknameStartsWithFilter=null,N.nicknameExactMatchFilter=null,N.channelNameContainsFilter="",N.myMemberStateFilter=e.MyMemberStateFilter.ALL,N.unreadChannelFilter=e.UnreadChannelFilter.ALL,N.superChannelFilter=e.SuperChannelFilter.ALL,N.publicChannelFilter=e.PublicChannelFilter.ALL,N.hiddenChannelFilter=e.HiddenChannelFilter.UNHIDDEN,N.searchFilter={fields:[],query:null},N.userIdsFilter={userIds:[],includeMode:!0,queryType:e.QueryType.AND},N.metadataKey=null,N.metadataValues=null,N.metadataOrderKeyFilter=null,N.metadataValueStartsWith=null,N.order=e.GroupChannelListOrder.LATEST_LAST_MESSAGE,N.includeEmpty=null!==(i=r.includeEmpty)&&void 0!==i&&i,N.includeFrozen=null===(s=r.includeFrozen)||void 0===s||s,N.includeMetaData=null===(a=r.includeMetaData)||void 0===a||a,N.channelUrlsFilter=null!==(o=r.channelUrlsFilter)&&void 0!==o?o:null,N.customTypesFilter=null!==(u=r.customTypesFilter)&&void 0!==u?u:null,N.customTypeStartsWithFilter=null!==(c=r.customTypeStartsWithFilter)&&void 0!==c?c:"",N.nicknameContainsFilter=null!==(l=r.nicknameContainsFilter)&&void 0!==l?l:null,N.nicknameStartsWithFilter=null!==(h=r.nicknameStartsWithFilter)&&void 0!==h?h:null,N.nicknameExactMatchFilter=null!==(d=r.nicknameExactMatchFilter)&&void 0!==d?d:null,N.channelNameContainsFilter=null!==(p=r.channelNameContainsFilter)&&void 0!==p?p:"",N.myMemberStateFilter=null!==(f=r.myMemberStateFilter)&&void 0!==f?f:e.MyMemberStateFilter.ALL,N.unreadChannelFilter=null!==(_=r.unreadChannelFilter)&&void 0!==_?_:e.UnreadChannelFilter.ALL,N.superChannelFilter=null!==(v=r.superChannelFilter)&&void 0!==v?v:e.SuperChannelFilter.ALL,N.publicChannelFilter=null!==(m=r.publicChannelFilter)&&void 0!==m?m:e.PublicChannelFilter.ALL,N.hiddenChannelFilter=null!==(g=r.hiddenChannelFilter)&&void 0!==g?g:e.HiddenChannelFilter.UNHIDDEN,N.searchFilter=null!==(y=r.searchFilter)&&void 0!==y?y:{fields:[],query:null},N.userIdsFilter=null!==(E=r.userIdsFilter)&&void 0!==E?E:{userIds:[],includeMode:!0,queryType:e.QueryType.AND},N.metadataKey=null!==(b=r.metadataKey)&&void 0!==b?b:null,N.metadataValues=null!==(C=r.metadataValues)&&void 0!==C?C:null,N.metadataOrderKeyFilter=null!==(T=r.metadataOrderKeyFilter)&&void 0!==T?T:null,N.metadataValueStartsWith=null!==(I=r.metadataValueStartsWith)&&void 0!==I?I:null,N.order=null!==(S=r.order)&&void 0!==S?S:e.GroupChannelListOrder.LATEST_LAST_MESSAGE,N}return n(r,t),r.prototype._validate=function(){return t.prototype._validate.call(this)&&g("boolean",this.includeEmpty)&&g("boolean",this.includeFrozen)&&g("boolean",this.includeMetaData)&&g("string",this.channelNameContainsFilter)&&b("string",this.channelUrlsFilter,!0)&&b("string",this.customTypesFilter,!0)&&g("string",this.customTypeStartsWithFilter)&&g("string",this.nicknameContainsFilter,!0)&&g("string",this.nicknameStartsWithFilter,!0)&&g("string",this.nicknameExactMatchFilter,!0)&&y(e.MyMemberStateFilter,this.myMemberStateFilter)&&y(e.SuperChannelFilter,this.superChannelFilter)&&y(e.PublicChannelFilter,this.publicChannelFilter)&&y(e.UnreadChannelFilter,this.unreadChannelFilter)&&y(e.HiddenChannelFilter,this.hiddenChannelFilter)&&b(e.GroupChannelSearchField,this.searchFilter.fields)&&g("string",this.searchFilter.query,!0)&&b("string",this.userIdsFilter.userIds)&&g("boolean",this.userIdsFilter.includeMode)&&y(e.QueryType,this.userIdsFilter.queryType)&&y(e.GroupChannelListOrder,this.order)&&g("string",this.metadataOrderKeyFilter,!0)&&g("string",this.metadataKey,!0)&&b("string",this.metadataValues,!0)&&g("string",this.metadataValueStartsWith,!0)},r.prototype.serialize=function(){return ot(this)},r.prototype.next=function(){return i(this,void 0,void 0,(function(){var e,t,n;return s(this,(function(r){switch(r.label){case 0:return this._validate()?this._isLoading?[3,3]:this._hasNext?(this._isLoading=!0,[4,hc.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 f.queryInProgress;case 4:return[3,6];case 5:throw f.invalidParameters;case 6:return[2]}}))}))},r}(Fn),cc=function(){function e(e){var t=e.top,n=void 0===t?Number.MAX_SAFE_INTEGER:t,r=e.bottom,i=void 0===r?0:r;this.top=n,this.bottom=i}return e.prototype.includes=function(){for(var e=this,t=[],n=0;n0||I.unreadMentionCount>0)&&(I._updateUnreadCount(0,0),this._dispatcher.dispatch(new su({channels:[I],source:e.GroupChannelEventSource.EVENT_CHANNEL_READ})),De((function(){return i(Ot,void 0,void 0,(function(){var e,t,n,r;return s(this,(function(i){try{for(e=a(this._groupChannelHandlers.values()),t=e.next();!t.done;t=e.next())t.value.onChannelChanged(I)}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!==I.unreadMessageCount&&0!==I.unreadMentionCount||(this._dispatcher.dispatch(new su({channels:[I],source:e.GroupChannelEventSource.EVENT_CHANNEL_READ})),De((function(){return i(Ot,void 0,void 0,(function(){var e,t,n,r;return s(this,(function(i){try{for(e=a(this._groupChannelHandlers.values()),t=e.next();!t.done;t=e.next())t.value.onChannelChanged(I)}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 su({channels:[I],source:e.GroupChannelEventSource.EVENT_CHANNEL_READ})),De((function(){return i(Ot,void 0,void 0,(function(){var e,t,n,r;return s(this,(function(i){try{for(e=a(this._groupChannelHandlers.values()),t=e.next();!t.done;t=e.next())t.value.onUnreadMemberStatusUpdated(I)}catch(e){n={error:e}}finally{try{t&&!t.done&&(r=e.return)&&r.call(e)}finally{if(n)throw n.error}}return[2]}))}))}))),Rt.label=12;case 12:return[3,75];case 13:return S=t.as(Bu),X=S.channelUrl,N=S.deliveredStateUpdate,w=void 0===N?{}:N,M=this._groupChannelCache.isCachedInMemory(X),[4,this.getChannel(X,!0)];case 14:if(A=Rt.sent(),M)for(U in w)A._updateUndeliveredMemberState(U,w[U]);return this._dispatcher.dispatch(new su({channels:[A],source:e.GroupChannelEventSource.EVENT_CHANNEL_DELIVERED})),Object.keys(w).some((function(e){return e!==Ot._sdkState.userId}))&&De((function(){return i(Ot,void 0,void 0,(function(){var e,t,n,r;return s(this,(function(i){try{for(e=a(this._groupChannelHandlers.values()),t=e.next();!t.done;t=e.next())t.value.onUndeliveredMemberStatusUpdated(A)}catch(e){n={error:e}}finally{try{t&&!t.done&&(r=e.return)&&r.call(e)}finally{if(n)throw n.error}}return[2]}))}))})),[3,75];case 15:return O=t.as(ic),X=O.channelUrl,Z=O.channelType,R=O.event,Z!==e.ChannelType.GROUP?[3,18]:[4,this.getChannel(X,!0)];case 16:return L=Rt.sent(),[4,this.getMessageFromCache(R.messageId)];case 17:(P=Rt.sent())&&(P.applyReactionEvent(R),this._dispatcher.dispatch(new yn({messages:[P],source:e.MessageEventSource.EVENT_MESSAGE_REACTION_UPDATED}))),De((function(){return i(Ot,void 0,void 0,(function(){var e,t,n,r;return s(this,(function(i){try{for(e=a(this._groupChannelHandlers.values()),t=e.next();!t.done;t=e.next())t.value.onReactionUpdated(L,R)}catch(e){n={error:e}}finally{try{t&&!t.done&&(r=e.return)&&r.call(e)}finally{if(n)throw n.error}}return[2]}))}))})),Rt.label=18;case 18:return[3,75];case 19:return(k=t.as(sc).event).channelType!==e.ChannelType.GROUP?[3,22]:[4,this.getChannel(k.channelUrl,!0)];case 20:return D=Rt.sent(),[4,this.getMessageFromCache(k.targetMessageId)];case 21:(P=Rt.sent())&&(P.applyThreadInfoUpdateEvent(k),this._dispatcher.dispatch(new yn({messages:[P],source:e.MessageEventSource.EVENT_MESSAGE_THREADINFO_UPDATED}))),De((function(){return i(Ot,void 0,void 0,(function(){var e,t,n,r;return s(this,(function(i){try{for(e=a(this._groupChannelHandlers.values()),t=e.next();!t.done;t=e.next())t.value.onThreadInfoUpdated(D,k)}catch(e){n={error:e}}finally{try{t&&!t.done&&(r=e.return)&&r.call(e)}finally{if(n)throw n.error}}return[2]}))}))})),Rt.label=22;case 22:return[3,75];case 23:x=t.as(ec).groupChannelMemberCounts,F=[],Rt.label=24;case 24:Rt.trys.push([24,29,30,31]),q=a(x),G=q.next(),Rt.label=25;case 25:return G.done?[3,28]:(H=G.value,X=H.channelUrl,we=H.memberCount,Me=H.joinedMemberCount,V=H.updatedAt,[4,this.getChannelFromCache(X)]);case 26:(K=Rt.sent())&&K._setLatestMemberCount(we,Me,V)&&F.push(K),Rt.label=27;case 27:return G=q.next(),[3,25];case 28:return[3,31];case 29:return Q=Rt.sent(),Ct={error:Q},[3,31];case 30:try{G&&!G.done&&(Tt=q.return)&&Tt.call(q)}finally{if(Ct)throw Ct.error}return[7];case 31:return F.length>0&&(this._dispatcher.dispatch(new su({channels:F,source:e.GroupChannelEventSource.EVENT_CHANNEL_MEMBER_COUNT_UPDATED})),De((function(){return i(Ot,void 0,void 0,(function(){var e,t,n,r;return s(this,(function(i){try{for(e=a(this._groupChannelHandlers.values()),t=e.next();!t.done;t=e.next())t.value.onChannelMemberCountChanged(F)}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,75];case 32:return B=t.as(ac),j=B.event,z=B.status,X=B.channelUrl,Z=B.channelType,X&&Z?[4,this.getChannel(X,!0)]:[3,75];case 33:return W=Rt.sent(),this._dispatcher.dispatch(new Tn({event:j,source:e.MessageEventSource.EVENT_POLL_UPDATED})),De("removed"===z?function(){return i(Ot,void 0,void 0,(function(){var e,t,n,r;return s(this,(function(i){try{for(e=a(this._groupChannelHandlers.values()),t=e.next();!t.done;t=e.next())t.value.onPollDeleted(W,j.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 i(Ot,void 0,void 0,(function(){var e,t,n,r;return s(this,(function(i){try{for(e=a(this._groupChannelHandlers.values()),t=e.next();!t.done;t=e.next())t.value.onPollUpdated(W,j)}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,75];case 34:return Y=t.as(oc),J=Y.event,X=Y.channelUrl,Z=Y.channelType,X&&Z?[4,this.getChannel(X,!0)]:[3,75];case 35:return $=Rt.sent(),this._dispatcher.dispatch(new In({event:J,source:e.MessageEventSource.EVENT_POLL_VOTED})),De((function(){return i(Ot,void 0,void 0,(function(){var e,t,n,r;return s(this,(function(i){try{for(e=a(this._groupChannelHandlers.values()),t=e.next();!t.done;t=e.next())t.value.onPollVoted($,J)}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,75];case 36:if(!(ee=t.as(Au).event).isGroupChannelEvent)return[3,73];switch(ee.category){case Ko.CHANNEL_JOIN:return[3,37];case Ko.CHANNEL_LEAVE:return[3,39];case Ko.CHANNEL_OPERATOR_UPDATE:return[3,43];case Ko.CHANNEL_INVITE:return[3,45];case Ko.CHANNEL_DECLINE_INVITE:return[3,47];case Ko.TYPING_START:case Ko.TYPING_END:return[3,49];case Ko.USER_CHANNEL_MUTE:case Ko.USER_CHANNEL_UNMUTE:return[3,51];case Ko.USER_CHANNEL_BAN:return[3,53];case Ko.USER_CHANNEL_UNBAN:return[3,57];case Ko.CHANNEL_FREEZE:case Ko.CHANNEL_UNFREEZE:return[3,59];case Ko.CHANNEL_HIDE:return[3,61];case Ko.CHANNEL_UNHIDE:return[3,63];case Ko.CHANNEL_DELETED:return[3,65];case Ko.CHANNEL_PROP_CHANGED:return[3,67];case Ko.CHANNEL_META_DATA_CHANGED:return[3,69];case Ko.CHANNEL_META_COUNTERS_CHANGED:return[3,71]}return[3,73];case 37:return[4,this.getChannel(ee.channelUrl,!0)];case 38:return te=Rt.sent(),ne=t.as(Ru),re=ne.memberCount,ie=ne.joinedMemberCount,se=ne.members,ae=!1,se.forEach((function(t){te.isExclusive||te.isSuper||te.isBroadcast?ae=ae||te._setLatestMemberCount(re,ie,ee.ts):(t.state=e.MemberState.JOINED,te.addMember(t,ee.ts),Ot._updateJoinedMemberCount(te)),t.userId===Ot._sdkState.userId&&(te.myMemberState=e.MemberState.JOINED)})),this._dispatcher.dispatch(new su({channels:[te],source:e.GroupChannelEventSource.EVENT_CHANNEL_JOINED})),De((function(){return i(Ot,void 0,void 0,(function(){return s(this,(function(e){return this._groupChannelHandlers.forEach((function(e){var t,n;try{for(var r=a(se),i=r.next();!i.done;i=r.next()){var s=i.value;e.onUserJoined(te,s)}}catch(e){t={error:e}}finally{try{i&&!i.done&&(n=r.return)&&n.call(r)}finally{if(t)throw t.error}}te.isBroadcast&&ae&&e.onChannelMemberCountChanged([te])})),[2]}))}))})),[3,73];case 39:return(Ve=this._leftChannels.get(ee.channelUrl))?(ue=Ve.channel,[3,42]):[3,40];case 40:return[4,this.getChannel(ee.channelUrl,!0)];case 41:ue=Rt.sent(),Rt.label=42;case 42:return oe=ue,ce=t.as(ku),we=ce.memberCount,Me=ce.joinedMemberCount,le=ce.member,he=!1,de=wt.of(this._iid).appInfo,oe.isExclusive||oe.isSuper||oe.isBroadcast?he=oe._setLatestMemberCount(we,Me,ee.ts):(de.enabledChannelMemberShipHistory?(oe.members.find((function(e){return e.userId===le.userId})).state=e.MemberState.LEFT,oe.memberCount=we):oe.removeMember(le),this._updateJoinedMemberCount(oe)),le.userId===this._sdkState.userId?(oe.myMemberState=e.MemberState.NONE,oe.invitedAt=0,oe.joinedAt=0,oe._updateUnreadCount(0,0),oe.isPublic?this._dispatcher.dispatch(new su({channels:[oe],source:e.GroupChannelEventSource.EVENT_CHANNEL_LEFT})):(this._markAsLeave(oe),this._dispatcher.dispatch(new au({channelUrls:[oe.url],source:e.GroupChannelEventSource.EVENT_CHANNEL_LEFT})))):this._dispatcher.dispatch(new su({channels:[oe],source:e.GroupChannelEventSource.EVENT_CHANNEL_LEFT})),De((function(){return i(Ot,void 0,void 0,(function(){return s(this,(function(e){return this._groupChannelHandlers.forEach((function(e){e.onUserLeft(oe,le),oe.isBroadcast&&he&&e.onChannelMemberCountChanged([oe])})),[2]}))}))})),[3,73];case 43:return[4,this.getChannel(ee.channelUrl,!0)];case 44:pe=Rt.sent(),fe=t.as($u).operators,_e=fe.map((function(e){return e.userId}));try{for(ve=a(pe.members),me=ve.next();!me.done;me=ve.next())(He=me.value).role=_e.includes(He.userId)?e.Role.OPERATOR:e.Role.NONE}catch(e){It={error:e}}finally{try{me&&!me.done&&(St=ve.return)&&St.call(ve)}finally{if(It)throw It.error}}return pe.myRole=_e.includes(this._sdkState.userId)?e.Role.OPERATOR:e.Role.NONE,this._dispatcher.dispatch(new su({channels:[pe],source:e.GroupChannelEventSource.EVENT_CHANNEL_OPERATOR_UPDATED})),De((function(){return i(Ot,void 0,void 0,(function(){return s(this,(function(e){return this._groupChannelHandlers.forEach((function(e){e.onOperatorUpdated(pe,fe)})),[2]}))}))})),[3,73];case 45:return[4,this.getChannel(ee.channelUrl,!0)];case 46:ge=Rt.sent(),ye=t.as(xu),we=ye.memberCount,Me=ye.joinedMemberCount,Ee=ye.inviter,(be=ye.invitees).forEach((function(t){return t.state=e.MemberState.INVITED}));try{for(Ce=a(be),Te=Ce.next();!Te.done;Te=Ce.next())Ie=Te.value,ge.isExclusive||ge.isSuper||ge.isBroadcast?ge._setLatestMemberCount(we,Me,ee.ts):ge.addMember(Ie,ee.ts),this._sdkState.userId===Ie.userId&&(ge.hiddenState=e.HiddenState.UNHIDDEN,ge.myMemberState!==e.MemberState.JOINED&&(ge.myMemberState=e.MemberState.INVITED),ge.invitedAt=ee.ts)}catch(e){Nt={error:e}}finally{try{Te&&!Te.done&&(Mt=Ce.return)&&Mt.call(Ce)}finally{if(Nt)throw Nt.error}}return this._dispatcher.dispatch(new su({channels:[ge],source:e.GroupChannelEventSource.EVENT_CHANNEL_INVITED})),De((function(){return i(Ot,void 0,void 0,(function(){return s(this,(function(e){return this._groupChannelHandlers.forEach((function(e){e.onUserReceivedInvitation(ge,Ee,be)})),[2]}))}))})),[3,73];case 47:return[4,this.getChannel(ee.channelUrl,!0)];case 48:return Se=Rt.sent(),Ne=t.as(Gu),we=Ne.memberCount,Me=Ne.joinedMemberCount,Ae=Ne.inviter,Ue=Ne.invitee,Se.isExclusive||Se.isSuper||Se.isBroadcast?Se._setLatestMemberCount(we,Me,ee.ts):Se.removeMember(Ue),this._sdkState.userId===Ue.userId?(Se.invitedAt=0,Se.myMemberState=e.MemberState.NONE,Se.isPublic?this._dispatcher.dispatch(new su({channels:[Se],source:e.GroupChannelEventSource.EVENT_CHANNEL_DECLINED_INVITE})):this._dispatcher.dispatch(new au({channelUrls:[Se.url],source:e.GroupChannelEventSource.EVENT_CHANNEL_DECLINED_INVITE}))):this._dispatcher.dispatch(new su({channels:[Se],source:e.GroupChannelEventSource.EVENT_CHANNEL_DECLINED_INVITE})),De((function(){return i(Ot,void 0,void 0,(function(){return s(this,(function(e){return this._groupChannelHandlers.forEach((function(e){e.onUserDeclinedInvitation(Se,Ae,Ue)})),[2]}))}))})),[3,73];case 49:return[4,this.getChannel(ee.channelUrl,!0)];case 50:return Oe=Rt.sent(),Re=ee.category===Ko.TYPING_START,Le=t.as(Re?Ju:Zu).user,Oe._updateTypingStatus(Le,Re?ee.ts:0),this._dispatcher.dispatch(new su({channels:[Oe],source:e.GroupChannelEventSource.EVENT_CHANNEL_TYPING_STATUS_UPDATE})),De((function(){return i(Ot,void 0,void 0,(function(){return s(this,(function(e){return this._groupChannelHandlers.forEach((function(e){e.onTypingStatusUpdated(Oe)})),[2]}))}))})),[3,73];case 51:return[4,this.getChannel(ee.channelUrl,!0)];case 52:ke=Rt.sent(),xe=ee.category===Ko.USER_CHANNEL_MUTE,(Fe=t.as(xe?Za:eo).user).userId===this._sdkState.userId&&(ke.myMutedState=xe?e.MutedState.MUTED:e.MutedState.UNMUTED);try{for(qe=a(ke.members),Ge=qe.next();!Ge.done;Ge=qe.next())if((He=Ge.value).userId===Fe.userId){He.isMuted=xe;break}}catch(e){At={error:e}}finally{try{Ge&&!Ge.done&&(Ut=qe.return)&&Ut.call(qe)}finally{if(At)throw At.error}}return this._dispatcher.dispatch(new su({channels:[ke],source:xe?e.GroupChannelEventSource.EVENT_CHANNEL_MUTED:e.GroupChannelEventSource.EVENT_CHANNEL_UNMUTED})),De((function(){return i(Ot,void 0,void 0,(function(){return s(this,(function(e){return this._groupChannelHandlers.forEach((function(e){xe?e.onUserMuted(ke,Fe):e.onUserUnmuted(ke,Fe)})),[2]}))}))})),[3,73];case 53:return(Ve=this._leftChannels.get(ee.channelUrl))?(Qe=Ve.channel,[3,56]):[3,54];case 54:return[4,this.getChannel(ee.channelUrl,!0)];case 55:Qe=Rt.sent(),Rt.label=56;case 56:return Ke=Qe,this._markAsLeave(Ke),Be=t.as(no).user,De((function(){return i(Ot,void 0,void 0,(function(){return s(this,(function(e){return this._groupChannelHandlers.forEach((function(e){e.onUserBanned(Ke,Be)})),[2]}))}))})),[3,73];case 57:return[4,this.getChannel(ee.channelUrl,!0)];case 58:return je=Rt.sent(),ze=t.as(io).user,De((function(){return i(Ot,void 0,void 0,(function(){return s(this,(function(e){return this._groupChannelHandlers.forEach((function(e){e.onUserUnbanned(je,ze)})),[2]}))}))})),[3,73];case 59:return[4,this.getChannel(ee.channelUrl,!0)];case 60:return We=Rt.sent(),Ye=t.as(ao).freeze,We.isFrozen=Ye,this._dispatcher.dispatch(new su({channels:[We],source:Ye?e.GroupChannelEventSource.EVENT_CHANNEL_FROZEN:e.GroupChannelEventSource.EVENT_CHANNEL_UNFROZEN})),De((function(){return i(Ot,void 0,void 0,(function(){return s(this,(function(e){return this._groupChannelHandlers.forEach((function(e){Ye?e.onChannelFrozen(We):e.onChannelUnfrozen(We)})),[2]}))}))})),[3,73];case 61:return[4,this.getChannel(ee.channelUrl,!0)];case 62:return Je=Rt.sent(),Xe=t.as(Wu),Ze=Xe.allowAutoUnhide,$e=Xe.hidePreviousMessages,et=Xe.messageOffsetTimestamp,null!==Ze&&(Je.hiddenState=Ze?e.HiddenState.HIDDEN_ALLOW_AUTO_UNHIDE:e.HiddenState.HIDDEN_PREVENT_AUTO_UNHIDE),null!==$e&&$e&&Je._updateUnreadCount(0,0),null!==et&&(Je.messageOffsetTimestamp=et),this._dispatcher.dispatch(new su({channels:[Je],source:e.GroupChannelEventSource.EVENT_CHANNEL_HIDDEN})),De((function(){return i(Ot,void 0,void 0,(function(){return s(this,(function(e){return this._groupChannelHandlers.forEach((function(e){e.onChannelHidden(Je)})),[2]}))}))})),[3,73];case 63:return[4,this.getChannel(ee.channelUrl,!0)];case 64:return(tt=Rt.sent()).hiddenState=e.HiddenState.UNHIDDEN,this._dispatcher.dispatch(new su({channels:[tt],source:e.GroupChannelEventSource.EVENT_CHANNEL_UNHIDDEN})),De((function(){return i(Ot,void 0,void 0,(function(){return s(this,(function(e){return this._groupChannelHandlers.forEach((function(e){e.onChannelChanged(tt)})),[2]}))}))})),[3,73];case 65:return[4,this.getChannel(ee.channelUrl,!0)];case 66:return nt=Rt.sent(),this._dispatcher.dispatch(new au({channelUrls:[ee.channelUrl],source:e.GroupChannelEventSource.EVENT_CHANNEL_DELETED})),De((function(){return i(Ot,void 0,void 0,(function(){return s(this,(function(e){return this._groupChannelHandlers.forEach((function(e){e.onChannelDeleted(nt.url,nt.channelType)})),[2]}))}))})),[3,73];case 67:return[4,this.getChannelWithoutCache(ee.channelUrl,!0)];case 68:return rt=Rt.sent(),this._dispatcher.dispatch(new su({channels:[rt],source:e.GroupChannelEventSource.EVENT_CHANNEL_UPDATED})),De((function(){return i(Ot,void 0,void 0,(function(){return s(this,(function(e){return this._groupChannelHandlers.forEach((function(e){e.onChannelChanged(rt)})),[2]}))}))})),[3,73];case 69:return[4,this.getChannel(ee.channelUrl,!0)];case 70:return it=Rt.sent(),st=t.as(xa),at=st.created,ot=st.updated,ut=st.deleted,at&&it._upsertCachedMetaData(at,ee.ts),ot&&it._upsertCachedMetaData(ot,ee.ts),ut&&it._removeFromCachedMetaData(ut,ee.ts),De((function(){return i(Ot,void 0,void 0,(function(){return s(this,(function(e){return this._groupChannelHandlers.forEach((function(e){at&&e.onMetaDataCreated(it,at),ot&&e.onMetaDataUpdated(it,ot),ut&&e.onMetaDataDeleted(it,ut)})),[2]}))}))})),[3,73];case 71:return[4,this.getChannel(ee.channelUrl,!0)];case 72:return ct=Rt.sent(),lt=t.as(Wa),ht=lt.created,dt=lt.updated,pt=lt.deleted,De((function(){return i(Ot,void 0,void 0,(function(){return s(this,(function(e){return this._groupChannelHandlers.forEach((function(e){ht&&e.onMetaCounterCreated(ct,ht),dt&&e.onMetaCounterUpdated(ct,dt),pt&&e.onMetaCounterDeleted(ct,pt)})),[2]}))}))})),[3,73];case 73:return[3,75];case 74:switch((ft=t.as(ri).event).category){case xr.USER_BLOCK:_t=ti.getDataAsUserBlockEvent(this._iid,ft),mt=_t.blocker,gt=_t.blockee,this._groupChannelCache.block(mt.userId,gt.userId);break;case xr.USER_UNBLOCK:vt=ti.getDataAsUserBlockEvent(this._iid,ft),mt=vt.blocker,gt=vt.blockee,this._groupChannelCache.unblock(mt.userId,gt.userId)}return[3,75];case 75:return[3,77];case 76:if(yt=Rt.sent(),p(yt))throw yt;return[3,77];case 77:return[2]}}))}))},t.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)},t.prototype.addHandler=function(e,t){this._groupChannelHandlers.set(e,t)},t.prototype.removeHandler=function(e){this._groupChannelHandlers.delete(e)},t.prototype.clearHandler=function(){this._groupChannelHandlers.clear()},t.prototype.subscribeGroupChannelEvent=function(e,t){this._groupChannelBroadcast.subscribe(e,t)},t.prototype.unsubscribeGroupChannelEvent=function(e){this._groupChannelBroadcast.unsubscribe(e)},t.prototype.subscribeMessageEvent=function(e,t){this._messageBroadcast.subscribe(e,t)},t.prototype.unsubscribeMessageEvent=function(e){this._messageBroadcast.unsubscribe(e)},t.prototype._updateJoinedMemberCount=function(t){t.joinedMemberCount=t.members.filter((function(t){return t.state===e.MemberState.JOINED})).length},t.prototype.getChannel=function(e,t){return void 0===t&&(t=!1),i(this,void 0,void 0,(function(){var n;return s(this,(function(r){switch(r.label){case 0:ct(g("string",e)).throw(f.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()]}}))}))},t.prototype.getChannelWithoutCache=function(t,n){return void 0===n&&(n=!1),i(this,void 0,void 0,(function(){var r,i,a,o,u;return s(this,(function(s){switch(s.label){case 0:return ct(g("string",t)).throw(f.invalidParameters),r=new hu({channelUrl:t,isInternalCall:n}),[4,this._requestQueue.send(r)];case 1:switch(i=s.sent(),a=i.as(du).channel,o=a.unreadMessageCount,u=a.unreadMentionCount,a.myCountPreference){case e.CountPreference.UNREAD_MESSAGE_COUNT_ONLY:u=0;break;case e.CountPreference.UNREAD_MENTION_COUNT_ONLY:o=0;break;case e.CountPreference.OFF:o=0,u=0}return a._updateUnreadCount(o,u),[4,this._groupChannelCache.upsert([a])];case 2:return s.sent(),[2,a]}}))}))},t.prototype.getMyGroupChannels=function(t,n,a,o){return void 0===o&&(o=e.GroupChannelEventSource.REQUEST_CHANNEL),i(this,void 0,void 0,(function(){var e,i,u,c,l;return s(this,(function(s){switch(s.label){case 0:return e=new pu(r(r({},n),{userId:this._sdkState.userId,token:t,limit:a})),[4,this._requestQueue.send(e)];case 1:return i=s.sent(),u=i.as(fu),c=u.channels,l=u.token,this._dispatcher.dispatch(new su({channels:c,source:o})),[2,{channels:c,token:l}]}}))}))},t.prototype.getMessageFromCache=function(e){return i(this,void 0,void 0,(function(){return s(this,(function(t){switch(t.label){case 0:return[4,this._messageCache.get(e)];case 1:return[2,t.sent()]}}))}))},t.prototype.getMessagesFromCache=function(e,t,n,r,a){return void 0===a&&(a=Sr),i(this,void 0,void 0,(function(){return s(this,(function(i){switch(i.label){case 0:return[4,this._messageCache.fetch({channelUrl:e,token:t,limit:a,filter:r,backward:"next"===n})];case 1:return[2,i.sent()]}}))}))},t.prototype.getPollMessagesFromCache=function(e,t,n,r){return void 0===r&&(r=Sr),i(this,void 0,void 0,(function(){return s(this,(function(i){switch(i.label){case 0:return[4,this._messageCache.fetch({channelUrl:e,token:t,limit:r,filter:n,backward:!1,isPollOnly:!0})];case 1:return[2,i.sent()]}}))}))},t.prototype.getAllFailedMessagesFromCache=function(t,n){return i(this,void 0,void 0,(function(){return s(this,(function(r){switch(r.label){case 0:return[4,this._unsentMessageCache.fetch({channelUrl:t,filter:n,sendingStatus:e.SendingStatus.FAILED})];case 1:return[2,r.sent()]}}))}))},t.prototype.removeFailedMessageFromCache=function(e){return i(this,void 0,void 0,(function(){return s(this,(function(t){switch(t.label){case 0:return[4,this._unsentMessageCache.remove([e])];case 1:return t.sent(),[2]}}))}))},t.prototype.getCachedMessageCountBetween=function(e,t,n,r){return i(this,void 0,void 0,(function(){return s(this,(function(i){switch(i.label){case 0:return[4,this._messageCache.countBetween(e,t,new cc({top:n,bottom:r}))];case 1:return[2,i.sent()]}}))}))},t.prototype.getMyGroupChannelChangeLogs=function(t,n,a){return void 0===a&&(a=e.GroupChannelEventSource.REQUEST_CHANNEL_CHANGELOGS),i(this,void 0,void 0,(function(){var e,i,o,u,c,l;return s(this,(function(s){switch(s.label){case 0:return e=r(r({},Jo),n),ct((g("string",t)||g("number",t))&&Xo(e)).throw(f.invalidParameters),i=new cu(D({userId:this._sdkState.userId,ts:"number"==typeof t?t:null,token:"string"==typeof t?t:null,filter:e})),[4,this._requestQueue.send(i)];case 1:return o=s.sent(),u=o.as(lu),c=u.updatedChannels,l=u.deletedChannelUrls,c.length>0&&this._dispatcher.dispatch(new su({channels:c,source:a})),l.length>0&&this._dispatcher.dispatch(new au({channelUrls:l,source:a})),[2,u]}}))}))},t.prototype.getGroupChannelCount=function(e){return i(this,void 0,void 0,(function(){var t,n,i;return s(this,(function(s){switch(s.label){case 0:return t=r(r({},Zo),e),ct($o(t)).throw(f.invalidParameters),n=new _u({userId:this._sdkState.userId,filter:t}),[4,this._requestQueue.send(n)];case 1:return i=s.sent(),[2,i.as(vu).groupChannelCount]}}))}))},t.prototype.getUnreadItemCount=function(t){return i(this,void 0,void 0,(function(){var n,i,a,o,u;return s(this,(function(s){switch(s.label){case 0:return n=r(r({},tu),t),ct(function(t){return b(e.UnreadItemKey,t.keys)}(n)).throw(f.invalidParameters),i=wt.of(this._iid),a=i.sdkState,o=i.requestQueue,u=new mu({userId:a.userId,filter:n}),[4,o.send(u)];case 1:return[2,s.sent().as(gu)]}}))}))},t.prototype.getTotalUnreadChannelCount=function(){return i(this,void 0,void 0,(function(){var e,t,n,r,i;return s(this,(function(s){switch(s.label){case 0:return e=wt.of(this._iid),t=e.sdkState,n=e.requestQueue,r=new yu({userId:t.userId}),[4,n.send(r)];case 1:return i=s.sent(),[2,i.as(Eu).unreadCount]}}))}))},t.prototype.getTotalUnreadMessageCount=function(t){return i(this,void 0,void 0,(function(){var n,i,a,o,u,c;return s(this,(function(s){switch(s.label){case 0:return n=r(r({},nu),t),ct(function(t){return b("string",t.channelCustomTypesFilter,!0)&&y(e.SuperChannelFilter,t.superChannelFilter)}(n)).throw(f.invalidParameters),i=wt.of(this._iid),a=i.sdkState,o=i.requestQueue,u=new bu({userId:a.userId,filter:n}),[4,o.send(u)];case 1:return c=s.sent(),[2,c.as(Cu).unreadCount]}}))}))},t.prototype.getTotalScheduledMessageCount=function(t){return void 0===t&&(t={}),i(this,void 0,void 0,(function(){var n,i,a,o;return s(this,(function(s){switch(s.label){case 0:return n=r(r({},ru),t),ct(function(t){return g("string",t.channelUrl,!0)&&b(e.ScheduledStatus,t.scheduledStatus,!0)&&y(e.MessageTypeFilter,t.messageTypeFilter)}(n)).throw(f.invalidParameters),i=wt.of(this._iid).requestQueue,a=new Tu(n),[4,i.send(a)];case 1:return o=s.sent(),[2,o.as(Iu).count]}}))}))},t.prototype.getSubscribedTotalUnreadMessageCount=function(){var e=wt.of(this._iid).subscribedUnreadMessageCount;return e.all>=0?e.all:0},t.prototype.getSubscribedCustomTypeTotalUnreadMessageCount=function(){var e=0,t=wt.of(this._iid).subscribedUnreadMessageCount;for(var n in t.customTypes)e+=t.customTypes[n];return e},t.prototype.getSubscribedCustomTypeUnreadMessageCount=function(e){var t;return null!==(t=wt.of(this._iid).subscribedUnreadMessageCount.customTypes[e])&&void 0!==t?t:0},t.prototype.createChannel=function(e){return i(this,void 0,void 0,(function(){var t,n,i,a;return s(this,(function(s){switch(s.label){case 0:return t=r(r({},Wo),e),ct(Yo(t)).throw(f.invalidParameters),t.isPublic||(t.accessCode=null),n=new Nu(r({userId:this._sdkState.userId},t)),[4,this._requestQueue.send(n)];case 1:return i=s.sent(),a=i.as(wu).channel,[4,this._groupChannelCache.upsert([a])];case 2:return s.sent(),[2,a]}}))}))},t.prototype.markAsReadAll=function(){return i(this,void 0,void 0,(function(){var e,t,n,r,i,o,u,c;return s(this,(function(s){switch(s.label){case 0:return e=Date.now(),ct(e-this._markAsReadAllLastSentAt>=1e3).throw(f.markAsReadAllRateLimitExceeded),this._markAsReadAllLastSentAt=e,t=new Mu({userId:this._sdkState.userId}),[4,this._requestQueue.send(t)];case 1:s.sent(),n=this._groupChannelCache.channels;try{for(r=a(n),i=r.next();!i.done;i=r.next())(o=i.value)._updateUnreadMemberState(this._sdkState.userId,e),o._updateUnreadCount(0,0)}catch(e){u={error:e}}finally{try{i&&!i.done&&(c=r.return)&&c.call(r)}finally{if(u)throw u.error}}return n.length>0?[4,this._groupChannelCache.upsert(n)]:[3,3];case 2:s.sent(),s.label=3;case 3:return[2]}}))}))},t.prototype.markAsReadWithChannelUrls=function(e){return i(this,void 0,void 0,(function(){var t,n,r,i,o,u,c,l,h;return s(this,(function(s){switch(s.label){case 0:return t=Date.now(),ct(b("string",e)&&t-this._markAsReadAllLastSentAt>=1e3).throw(f.markAsReadAllRateLimitExceeded),this._markAsReadAllLastSentAt=t,n=new Mu({userId:this._sdkState.userId,channelUrls:e}),[4,this._requestQueue.send(n)];case 1:s.sent(),r=this._groupChannelCache.channels,i=[];try{for(o=a(r),u=o.next();!u.done;u=o.next())c=u.value,e.includes(c.url)&&(c._updateUnreadMemberState(this._sdkState.userId,t),c._updateUnreadCount(0,0),i.push(c))}catch(e){l={error:e}}finally{try{u&&!u.done&&(h=o.return)&&h.call(o)}finally{if(l)throw l.error}}return i.length>0?[4,this._groupChannelCache.upsert(i)]:[3,3];case 2:s.sent(),s.label=3;case 3:return[2]}}))}))},t.prototype.markAsDelivered=function(e){return i(this,void 0,void 0,(function(){return s(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]}}))}))},t}(),dc=new Map,pc=new Map,fc=new Map,_c=function(){function e(t){var n=t.key,r=t.concurrentCallLimit,a=void 0===r?2:r,o=t.backOffDelay,u=void 0===o?0:o,c=this;this._holdersKey=e.createSemaphoreHoldersKey(n),this._resolversKey=e.createSemaphoreResolversKey(n),this._chainProcessStateKey=e.createChainProcessStateKey(n),this._numLocks=a,this._backOffDelay=u,this._localAcquiredKeys=[],this._localResolversData=[],Q()?(dc[this._holdersKey]||(dc[this._holdersKey]=[]),pc[this._resolversKey]||(pc[this._resolversKey]=[])):(window.addEventListener("storage",(function(e){return i(c,void 0,void 0,(function(){var t,n;return s(this,(function(r){if(this._localResolversData.length>0&&this.numLocksAvailable>0&&!this._isProcessChainAcquireRunning()&&this._hasHighestPriorityResolver())switch(e.key){case this._holdersKey:if(t=JSON.parse(e.oldValue),n=JSON.parse(e.newValue),!t||!n||n.length>=t.length)return[2];this._processChainResolve();break;case this._chainProcessStateKey:if(JSON.parse(e.newValue))return[2];this._processChainResolve();break;default:return[2]}return[2]}))}))})),window.addEventListener("beforeunload",(function(){var e=c._getLocalResolversData(),t=c._localResolversData.map((function(e){return e.key})),n=e.filter((function(e){return t.indexOf(e.key)<0}));window.localStorage.setItem(c._resolversKey,JSON.stringify(n)),c._localAcquiredKeys.forEach((function(e){return c.release(e)}))})))}return e.createSemaphoreHoldersKey=function(e){return"collection@semaphore_holders_for:"+e},e.createSemaphoreResolversKey=function(e){return"collection@semaphore_resolvers_for:"+e},e.createChainProcessStateKey=function(e){return"collection@semaphore_chain_process_state_for:"+e},Object.defineProperty(e.prototype,"numLocks",{get:function(){return this._numLocks},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"backOffDelay",{get:function(){return this._backOffDelay},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"numLocksAvailable",{get:function(){if(Q())return this.numLocks-dc[this._holdersKey].length;var e=this._getLocalHoldersData();return this.numLocks-e.length},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"waitCount",{get:function(){return Q()?pc[this._resolversKey].length:this._getLocalResolversData().length},enumerable:!1,configurable:!0}),e.prototype._hasHighestPriorityResolver=function(){var e=this._getLocalResolversData();return e.length>0&&this._localResolversData.map((function(e){return e.key})).indexOf(e[0].key)>=0},e.prototype._isProcessChainAcquireRunning=function(){if(Q())return fc[this._chainProcessStateKey];var e=window.localStorage[this._chainProcessStateKey];return void 0!==e&&JSON.parse(e)},e.prototype._setProcessChainAcquireRunning=function(e){Q()?fc[this._chainProcessStateKey]=e:e?window.localStorage.setItem(this._chainProcessStateKey,JSON.stringify(e)):window.localStorage.removeItem(this._chainProcessStateKey)},e.prototype._processChainResolve=function(){return i(this,void 0,void 0,(function(){var e;return s(this,(function(t){switch(t.label){case 0:return this.waitCount>0&&this.numLocksAvailable>0&&!this._isProcessChainAcquireRunning()?(this._setProcessChainAcquireRunning(!0),this._tryResolve()?[4,Re(this._backOffDelay)]:[3,2]):[3,3];case 1:t.sent(),t.label=2;case 2:this._setProcessChainAcquireRunning(!1),Q()?this._processChainResolve():(e=new StorageEvent("storage",{key:this._chainProcessStateKey,oldValue:JSON.stringify(!0),newValue:JSON.stringify(!1)}),dispatchEvent(e)),t.label=3;case 3:return[2]}}))}))},e.prototype.acquire=function(e){return void 0===e&&(e=0),i(this,void 0,void 0,(function(){var t,n=this;return s(this,(function(r){return Q()?[2,new Promise((function(t){for(var r={key:U(),resolver:function(e){return t(e)},priority:e},i=pc[n._resolversKey],s=-1,a=0;ai[a].priority){s=a;break}s>=0?pc[n._resolversKey].splice(s,0,r):pc[n._resolversKey].push(r),n._processChainResolve()}))]:(t=this._getLocalResolversData(),[2,new Promise((function(r){for(var i=U(),s={key:i,priority:e},a={key:i,resolver:function(e){return r(e)},priority:e},o=-1,u=0;ut[u].priority){o=u;break}o>=0?(t.splice(o,0,s),n._localResolversData.splice(o,0,a)):(t.push(s),n._localResolversData.push(a)),window.localStorage.setItem(n._resolversKey,JSON.stringify(t)),n._processChainResolve()}))])}))}))},e.prototype.release=function(e){if(Q()){if((t=dc[this._holdersKey].indexOf(e))>=0)return dc[this._holdersKey].splice(t,1),this._processChainResolve(),!0}else if(window.localStorage[this._holdersKey]){var t,n=JSON.parse(window.localStorage[this._holdersKey]),r=u([],o(n),!1);if((t=n.indexOf(e))>=0){n.splice(t,1),window.localStorage.setItem(this._holdersKey,JSON.stringify(n)),this._localAcquiredKeys.splice(this._localAcquiredKeys.indexOf(e),1);var i=new StorageEvent("storage",{key:this._holdersKey,oldValue:JSON.stringify(r),newValue:JSON.stringify(n)});return dispatchEvent(i),!0}}return!1},e.prototype._tryResolve=function(){if(Q()){if(dc[this._holdersKey].length=Ec,n.nextToken=this._metadata.range.top,this._metadata.previousComplete=!n.hasNext,h.debug("message background prev sync progress",n),[4,this.saveMetadata()];case 4:return s.sent(),[3,8];case 5:return i=s.sent(),h.debug("message background prev sync error",i),i instanceof f&&i.isInvalidTokenError?[4,this.clearMetadata()]:[3,7];case 6:s.sent(),s.label=7;case 7:throw i;case 8:return[3,10];case 9:n.hasNext=!1,s.label=10;case 10:return[2,n]}}))}))})),this._nextSync=new vc(d,(function(t){return i(a,void 0,void 0,(function(){var n,r,i,a,o,u;return s(this,(function(s){switch(s.label){case 0:return n={hasNext:!0,nextToken:0},[4,this.loadMetadata()];case 1:s.sent(),h.debug("message background next sync from",null===(a=this._metadata)||void 0===a?void 0:a.range.bottom),s.label=2;case 2:return s.trys.push([2,5,,6]),[4,kn.of(this._iid).getMessagesByTimestamp(this._channel.url,this._channel.channelType,null!==(u=null===(o=this._metadata.range)||void 0===o?void 0:o.bottom)&&void 0!==u?u:t,{prevResultSize:0,nextResultSize:Ec,replyType:e.ReplyType.ALL,includeReactions:!0,includeMetaArray:!0,includeParentMessageInfo:!0,includeThreadInfo:!0},e.MessageEventSource.SYNC_MESSAGE_BACKGROUND)];case 3:return r=s.sent(),this.extendRange(r),n.hasNext=r.length>=Ec,n.nextToken=this._metadata.range.bottom,h.debug("message background next sync progress",n),[4,this.saveMetadata()];case 4:return s.sent(),[3,6];case 5:throw i=s.sent(),h.debug("message background next sync error",i),i;case 6:return[2,n]}}))}))}))}return t.of=function(e,n){if(yc[e]||(yc[e]={}),!yc[e][n.url]){var r=yc[e][n.url]=new t({_iid:e,channel:n});wt.of(e).dispatcher.on((function(e){if(e instanceof he)if(e.stateType===X.CONNECTED)r.resume();else r.pause()}))}return yc[e][n.url]},Object.defineProperty(t.prototype,"range",{get:function(){var e;return null===(e=this._metadata)||void 0===e?void 0:e.range},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"previousComplete",{get:function(){var e;return!!(null===(e=this._metadata)||void 0===e?void 0:e.previousComplete)},enumerable:!1,configurable:!0}),t.prototype.isWrappingMessages=function(e){var t;return null===(t=this.range)||void 0===t?void 0:t.includes.apply(t,u([],o(e.map((function(e){return e.createdAt}))),!1))},t.prototype.extendRange=function(e){var t;this._metadata&&(t=this._metadata.range).extends.apply(t,u([],o(e.map((function(e){return e.createdAt}))),!1))},t.prototype.loadMetadata=function(){return i(this,void 0,void 0,(function(){var e;return s(this,(function(t){switch(t.label){case 0:return this._metadata?[3,2]:[4,wt.of(this._iid).cacheContext.preference.get(this._metadataKey)];case 1:e=t.sent(),this._metadata={range:new cc(e?e.range:{top:Number.MAX_SAFE_INTEGER,bottom:Number.MAX_SAFE_INTEGER}),previousComplete:!!e&&e.previousComplete},t.label=2;case 2:return[2]}}))}))},t.prototype.saveMetadata=function(){return i(this,void 0,void 0,(function(){return s(this,(function(e){switch(e.label){case 0:return this._metadata?[4,wt.of(this._iid).cacheContext.preference.set(this._metadataKey,this._metadata)]:[3,2];case 1:e.sent(),e.label=2;case 2:return[2]}}))}))},t.prototype.clearMetadata=function(){return i(this,void 0,void 0,(function(){return s(this,(function(e){switch(e.label){case 0:return[4,wt.of(this._iid).cacheContext.preference.remove(this._metadataKey)];case 1:return e.sent(),this._metadata=null,[2]}}))}))},t.prototype.resume=function(){var e,t,n,r;wt.of(this._iid).logger.debug("message background sync resume()"),this._metadata&&this._metadata.previousComplete||this._prevSync.start(null!==(t=null===(e=this._metadata)||void 0===e?void 0:e.range.top)&&void 0!==t?t:Date.now()),this._nextSync.start(null!==(r=null===(n=this._metadata)||void 0===n?void 0:n.range.bottom)&&void 0!==r?r:Date.now())},t.prototype.pause=function(){wt.of(this._iid).logger.debug("message background sync stop()"),this._prevSync.stop(),this._nextSync.stop()},t}(),Cc={},Tc=function(){function t(t){var n=t._iid,r=t.channel,a=this;this._sync=null,this._metadata=null,this._iid=n,this._channel=r;var o,u,c=wt.of(this._iid),l=c.logger,h=c.sdkState;this._metadataKey=(o=h.userId,u=r.url,"sendbird:".concat(o,"@groupchannel/").concat(u,"/message/changelogs.meta"));var d=function(e,t){return"sendbird:".concat(e,"@groupchannel/").concat(t,"/message/changelogs")}(h.userId,this._channel.url);this._sync=new vc(d,(function(){return i(a,void 0,void 0,(function(){var t,n,r,i,a,o;return s(this,(function(s){switch(s.label){case 0:return t={hasNext:!0,nextToken:0},[4,this.loadMetadata()];case 1:s.sent(),l.debug("message changelog sync from",null===(o=this._metadata)||void 0===o?void 0:o.token),s.label=2;case 2:return s.trys.push([2,5,,8]),[4,kn.of(this._iid).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 3:return n=s.sent(),r=n.hasMore,i=n.token,t.hasNext=r,t.nextToken=i,this._metadata.token=i,l.debug("message changelog sync progress",t),[4,this.saveMetadata()];case 4:return s.sent(),[3,8];case 5:return a=s.sent(),l.debug("message changelog sync error",a),a instanceof f&&a.isInvalidTokenError?[4,this.clearMetadata()]:[3,7];case 6:s.sent(),s.label=7;case 7:throw a;case 8:return[2,t]}}))}))}))}return t.of=function(e,n){if(Cc[e]||(Cc[e]={}),!Cc[e][n.url]){var r=Cc[e][n.url]=new t({_iid:e,channel:n});wt.of(e).dispatcher.on((function(e){if(e instanceof he)if(e.stateType===X.CONNECTED)r.resume();else r.pause()}))}return Cc[e][n.url]},t.prototype.loadMetadata=function(){return i(this,void 0,void 0,(function(){var e,t,n,r;return s(this,(function(i){switch(i.label){case 0:return this._metadata?[3,2]:(e=wt.of(this._iid),t=e.cacheContext,n=e.firstConnectedAt,[4,t.preference.get(this._metadataKey)]);case 1:r=i.sent(),this._metadata={token:r?r.token:n/1e3},i.label=2;case 2:return[2]}}))}))},t.prototype.saveMetadata=function(){return i(this,void 0,void 0,(function(){return s(this,(function(e){switch(e.label){case 0:return this._metadata?[4,wt.of(this._iid).cacheContext.preference.set(this._metadataKey,this._metadata)]:[3,2];case 1:e.sent(),e.label=2;case 2:return[2]}}))}))},t.prototype.clearMetadata=function(){return i(this,void 0,void 0,(function(){return s(this,(function(e){switch(e.label){case 0:return[4,wt.of(this._iid).cacheContext.preference.remove(this._metadataKey)];case 1:return e.sent(),this._metadata=null,[2]}}))}))},t.prototype.resume=function(){wt.of(this._iid).logger.debug("message changelog sync resume()"),this._sync.start(0)},t.prototype.pause=function(){wt.of(this._iid).logger.debug("message changelog sync pause()"),this._sync.stop()},t}(),Ic=function(e){function t(t){var n,r,i,s,a,o,u=this;return(u=e.call(this)||this).method=d.GET,u.path="".concat(Je(t.channelType),"/").concat(t.channelUrl,"/messages_gap"),u.params=D({prev_start_ts:t.prevStart,prev_end_ts:t.prevEnd,prev_cache_count:t.prevCount,next_start_ts:t.nextStart,next_end_ts:t.nextEnd,next_cache_count:t.nextCount,huge_gap_threshold:null!==(n=t.threshold)&&void 0!==n?n:null,reverse:!0,custom_types:null!==(r=t.customTypes)&&void 0!==r?r:["*"],message_type:null!==(i=t.messageType)&&void 0!==i?i:null,include_reactions:null===(s=t.includeReactions)||void 0===s||s,with_sorted_meta_array:null===(a=t.includeMetaArray)||void 0===a||a,show_subchannel_messages_only:null!==(o=t.showSubchannelMessagesOnly)&&void 0!==o&&o,include_poll_details:!0}),u}return n(t,e),t}(x),Sc=function(e){function t(t,n){var r,i,s,a,o=this;return(o=e.call(this,t,n)||this).isHugeGap=n.is_huge_gap,o.prevMessages=(null!==(r=n.prev_messages)&&void 0!==r?r:[]).map((function(e){return sn(t,e)})),o.prevHasMore=null!==(i=n.prev_hasmore)&&void 0!==i&&i,o.nextMessages=(null!==(s=n.next_messages)&&void 0!==s?s:[]).map((function(e){return sn(t,e)})),o.nextHasmore=null!==(a=n.next_hasmore)&&void 0!==a&&a,o}return n(t,e),t}(F),Nc=function(e,t){return e.findIndex((function(e){return e.isIdentical(t)}))},wc=function(e,t,n){if(e.length>0){var r=Nc(e,t);if(r<0){for(var i=0,s=e.length-1,a=Math.floor((i+s)/2);i0)s=a,a=Math.floor((i+s)/2);else{if(!(o<0))return{place:a,contains:e[a].isIdentical(t)};i=a+1,a=Math.floor((i+s)/2)}}return{place:Mc(e[a],t,n)>0?a:a+1,contains:!1}}return{place:r,contains:!0}}return{place:e.length,contains:!1}},Mc=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:return t.name.localeCompare(n.name)}},Ac=function(e,t){return t instanceof Bt?e.findIndex((function(e){return e instanceof Bt&&t.isIdentical(e)})):e.findIndex((function(e){return e.isIdentical(t)}))},Uc=function(e,t){return e.findIndex((function(e){return e.messageId===t}))},Oc=function(e,t){if(e.length>0){for(var n=0,r=e.length-1,i=Math.floor((n+r)/2);n0)r=i,i=Math.floor((n+r)/2);else{if(!(s<0))return i;n=i+1,i=Math.floor((n+r)/2)}}return e[i].createdAt>t.createdAt?i:i+1}return e.length},Rc={},Lc=function(){function e(e){var t=e._iid,n=e.channel,r=e.hasPollMessage,a=this;this._sync=null,this._metadata=null,this._iid=t,this._channel=n;var o,u,c=wt.of(this._iid),l=c.logger,h=c.sdkState;this._metadataKey=(o=h.userId,u=n.url,"sendbird:".concat(o,"@groupchannel/").concat(u,"/poll/changelogs.meta"));var d=function(e,t){return"sendbird:".concat(e,"@groupchannel/").concat(t,"/poll/changelogs")}(h.userId,this._channel.url);this._sync=new vc(d,(function(){return i(a,void 0,void 0,(function(){var e,t,n,i,a,o,u;return s(this,(function(s){switch(s.label){case 0:return e={hasNext:!0,nextToken:0},[4,this.loadMetadata()];case 1:return s.sent(),l.debug("poll changelog sync from",null===(u=this._metadata)||void 0===u?void 0:u.token),(t=!this._metadata||!this._metadata.token)?[4,r()]:[3,3];case 2:t=!s.sent(),s.label=3;case 3:if(t)return[2,{hasNext:!1,nextToken:0}];s.label=4;case 4:return s.trys.push([4,7,,10]),[4,lr.of(this._iid).getPollChangeLogs(this._channel.url,this._channel.channelType,this._metadata.token)];case 5:return n=s.sent(),i=n.hasMore,a=n.token,e.hasNext=i,e.nextToken=a,this._metadata.token=a,l.debug("poll changelog sync progress",e),[4,this.saveMetadata()];case 6:return s.sent(),[3,10];case 7:return o=s.sent(),l.debug("poll changelog sync error",o),o instanceof f&&o.isInvalidTokenError?[4,this.clearMetadata()]:[3,9];case 8:s.sent(),s.label=9;case 9:throw o;case 10:return[2,e]}}))}))}))}return e.of=function(t,n,r){if(Rc[t]||(Rc[t]={}),!Rc[t][n.url]){var i=Rc[t][n.url]=new e({_iid:t,channel:n,hasPollMessage:r});wt.of(t).dispatcher.on((function(e){if(e instanceof he)if(e.stateType===X.CONNECTED)i.resume();else i.pause()}))}return Rc[t][n.url]},e.prototype.loadMetadata=function(){return i(this,void 0,void 0,(function(){var e,t,n,r;return s(this,(function(i){switch(i.label){case 0:return this._metadata?[3,2]:(e=wt.of(this._iid),t=e.cacheContext,n=e.firstConnectedAt,[4,t.preference.get(this._metadataKey)]);case 1:r=i.sent(),this._metadata={token:r?r.token:n/1e3},i.label=2;case 2:return[2]}}))}))},e.prototype.saveMetadata=function(){return i(this,void 0,void 0,(function(){return s(this,(function(e){switch(e.label){case 0:return this._metadata?[4,wt.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 i(this,void 0,void 0,(function(){return s(this,(function(e){switch(e.label){case 0:return[4,wt.of(this._iid).cacheContext.preference.remove(this._metadataKey)];case 1:return e.sent(),this._metadata=null,[2]}}))}))},e.prototype.resume=function(){wt.of(this._iid).logger.debug("poll changelog sync resume()"),this._sync.start(0)},e.prototype.pause=function(){wt.of(this._iid).logger.debug("poll changelog sync pause()"),this._sync.stop()},e}(),kc=6e5;e.MessageCollectionInitPolicy=void 0,(e.MessageCollectionInitPolicy||(e.MessageCollectionInitPolicy={})).CACHE_AND_REPLACE_BY_API="cache_and_replace_by_api";var Dc,Pc,xc,Fc=function(){function e(){}return e.prototype._invokeResponse=function(e,t,n){var r=this;De((function(){return i(r,void 0,void 0,(function(){return s(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}(),qc=function(){function t(t,n){var r=n.channel,c=n.filter,l=n.startingPoint,h=n.limit,d=this;this._channel=null,this._messages=[],this._unsentMessages=[],this._readReceiptMap=new Map,this._deliveryReceiptMap=new Map,this._iid=t,this._key="mc-".concat(U()),this.filter=null!=c?c:new Ar,this._channel=r,this._syncRange=new cc({}),this._hasPrevious=!0,this._hasNext=!0,this._startingPoint=l||Date.now()+kc,this._limit=h||Sr;var p=hc.of(this._iid);p.subscribeGroupChannelEvent(this._key,{onUpdate:function(t,n){var r,o,u,c,l=Nc(t,d._channel);if(l>=0)switch(De((function(){return i(d,void 0,void 0,(function(){var e;return s(this,(function(r){return e=new mc(n),this._channel=t[l],this._handler.onChannelUpdated(e,this.channel),[2]}))}))})),n){case e.GroupChannelEventSource.EVENT_CHANNEL_UPDATED:var h=!1;for(var p in d._messages){if((y=d._messages[p]).createdAt>=d._channel.messageOffsetTimestamp){h=!0;var f=parseInt(p);if(f>0){var _=d._messages.splice(0,f);d._removeMessagesFromView(_.map((function(e){return e.messageId})),e.MessageEventSource.EVENT_MESSAGE_OFFSET_UPDATED)}break}}!h&&d._messages.length>0&&d._removeMessagesFromView(d._messages.map((function(e){return e.messageId})),e.MessageEventSource.EVENT_MESSAGE_OFFSET_UPDATED);break;case e.GroupChannelEventSource.EVENT_CHANNEL_READ:var v=[];try{for(var m=a(d._messages),g=m.next();!g.done;g=m.next()){var y=g.value;if((C=d._readReceiptMap.get(y.messageId))>0)C!==d._channel.getUnreadMemberCount(y)&&v.push(y)}}catch(e){r={error:e}}finally{try{g&&!g.done&&(o=m.return)&&o.call(m)}finally{if(r)throw r.error}}v.length>0&&d._updateMessagesToView(v,e.MessageEventSource.EVENT_MESSAGE_READ);break;case e.GroupChannelEventSource.EVENT_CHANNEL_DELIVERED:v=[];try{for(var E=a(d._messages),b=E.next();!b.done;b=E.next()){var C;y=b.value;if((C=d._deliveryReceiptMap.get(y.messageId))>0)C!==d._channel.getUndeliveredMemberCount(y)&&v.push(y)}}catch(e){u={error:e}}finally{try{b&&!b.done&&(c=E.return)&&c.call(E)}finally{if(u)throw u.error}}v.length>0&&d._updateMessagesToView(v,e.MessageEventSource.EVENT_MESSAGE_READ)}},onRemove:function(e,t){e.indexOf(d.channel.url)>=0&&De((function(){return i(d,void 0,void 0,(function(){var e;return s(this,(function(n){return e=new mc(t),this._handler.onChannelDeleted(e,this.channel.url),[2]}))}))}))}}),p.subscribeMessageEvent(this._key,{onUpdate:function(t,n){var r,i,s=[],o=[];try{for(var u=a(t),c=u.next();!c.done;c=u.next()){var l=c.value;l.channelUrl===d._channel.url&&(d.filter.match(l)?s.push(l):o.push(l.messageId))}}catch(e){r={error:e}}finally{try{c&&!c.done&&(i=u.return)&&i.call(u)}finally{if(r)throw r.error}}if(gn(n)){if(s.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:d._updateMessagesToView(s,n);break;case e.MessageEventSource.EVENT_MESSAGE_SENT_PENDING:case e.MessageEventSource.EVENT_MESSAGE_RECEIVED:case e.MessageEventSource.SYNC_MESSAGE_FILL:d._addMessagesToView(s,n)}o.length>0&&d._removeMessagesFromView(o,n)}},onRemove:function(e,t){d._removeMessagesFromView(e,t)},onRemoveUnsent:function(e,t){d._removeUnsentMessageFromView(e,t)},onPollChangeLogUpdate:function(e,t){d._updatePollsToView(e,t)},onPollUpdate:function(e,t){d._applyPollUpdateEventToView(e,t)},onPollVote:function(e,t){d._applyPollVoteEventToView(e,t)}});var f=wt.of(this._iid).cacheContext;!this._channel.isSuper&&f.localCacheEnabled&&bc.of(this._iid,this._channel).resume(),Tc.of(this._iid,this._channel).resume(),Lc.of(this._iid,this._channel,this._hasPollMessage.bind(this)).resume(),this._prevFill=new vc(this._key,(function(t){return i(d,void 0,void 0,(function(){var n,r;return s(this,(function(i){switch(i.label){case 0:return[4,this._getRemoteMessages(t,{prevLimit:this._limit,source:e.MessageEventSource.SYNC_MESSAGE_FILL})];case 1:return(n=i.sent()).length>0?(r=Math.min.apply(Math,u([],o(n.map((function(e){return e.createdAt}))),!1)),this._syncRange.extends(r),[2,{hasNext:n.length>=this._limit&&this.viewTop0?(r=Math.max.apply(Math,u([],o(n.map((function(e){return e.createdAt}))),!1)),this._syncRange.extends(r),[2,{hasNext:!(n.length>=this._limit&&this._hasNext)||this.viewBottom>r,nextToken:this._syncRange.bottom}]):[2,{hasNext:!1,nextToken:0}]}}))}))}));var _=wt.of(this._iid),v=_.dispatcher,m=_.logger;v.on((function(e){if(e instanceof he)if(e.stateType===X.CONNECTED)m.debug("check huge gap"),d._checkHugeGap();else d._prevFill.stop(),d._nextFill.stop()}))}return Object.defineProperty(t.prototype,"channel",{get:function(){return this._channel},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"succeededMessages",{get:function(){return u([],o(this._messages),!1)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"failedMessages",{get:function(){return this._unsentMessages.filter((function(t){return t.sendingStatus===e.SendingStatus.FAILED}))},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"pendingMessages",{get:function(){return this._unsentMessages.filter((function(t){return t.sendingStatus===e.SendingStatus.PENDING}))},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"hasPrevious",{get:function(){return this._hasPrevious},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"hasNext",{get:function(){return this._hasNext},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"viewTop",{get:function(){return Math.min.apply(Math,u(u([],o(this._messages.map((function(e){return e.createdAt}))),!1),[Number.MAX_SAFE_INTEGER],!1))},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"viewBottom",{get:function(){return Math.max.apply(Math,u(u([],o(this._messages.map((function(e){return e.createdAt}))),!1),[0],!1))},enumerable:!1,configurable:!0}),t.prototype.setMessageCollectionHandler=function(e){this._handler=e},t.prototype._filterUnderOffsetMessage=function(e){return e},t.prototype._addMessagesToView=function(t,n){var r,c,l=this,h=this._filterUnderOffsetMessage(t),d=[],p=[];try{for(var f=a(h),_=f.next();!_.done;_=f.next()){var v=_.value;if(n===e.MessageEventSource.SYNC_MESSAGE_FILL){if(v.messageId>0){if((E=Ac(this._messages,v))<0){Ac(this._unsentMessages,v)<0&&d.push(v);var m=Oc(this._messages,v);this._messages.splice(m,0,v)}this._readReceiptMap.set(v.messageId,this._channel.getUnreadMemberCount(v)),this._deliveryReceiptMap.set(v.messageId,this._channel.getUndeliveredMemberCount(v))}else if(v instanceof Bt){(E=Ac(this._unsentMessages,v))<0&&Ac(this._messages,v)<0&&(this._unsentMessages.push(v),d.push(v))}}else if(v.messageId>0){if((E=Ac(this._messages,v))<0){var g=Ac(this._unsentMessages,v);g<0?d.push(v):(this._unsentMessages.splice(g,1),p.push(v));m=Oc(this._messages,v);this._messages.splice(m,0,v)}else p.push(v),this._messages[E]=v;if(this._readReceiptMap.set(v.messageId,this._channel.getUnreadMemberCount(v)),this._deliveryReceiptMap.set(v.messageId,this._channel.getUndeliveredMemberCount(v)),v.updatedAt>0){var y=this._updateChildMessagesInView(v);p.push.apply(p,u([],o(y),!1))}}else if(v instanceof Bt){var E;(E=Ac(this._unsentMessages,v))<0?Ac(this._messages,v)<0&&(this._unsentMessages.push(v),d.push(v)):(p.push(v),this._unsentMessages[E]=v)}}}catch(e){r={error:e}}finally{try{_&&!_.done&&(c=f.return)&&c.call(f)}finally{if(r)throw r.error}}gn(n)&&De((function(){return i(l,void 0,void 0,(function(){var e;return s(this,(function(t){return e=new gc(n),d.length>0&&this._handler.onMessagesAdded(e,this.channel,d),p.length>0&&this._handler.onMessagesUpdated(e,this.channel,p),[2]}))}))}))},t.prototype._updateChildMessagesInView=function(e){var t=[];return this._messages.forEach((function(n){n.applyParentMessage(e)&&t.push(n)})),t},t.prototype._updatePollsToView=function(e,t){var n,r,o=this,u=[];try{for(var c=a(e),l=c.next();!l.done;l=c.next()){var h=l.value,d=Uc(this._messages,h.messageId);if(d>=0){var p=this._messages[d];p&&p.applyPoll(h),u.push(p)}}}catch(e){n={error:e}}finally{try{l&&!l.done&&(r=c.return)&&r.call(c)}finally{if(n)throw n.error}}return u.length>0&&gn(t)&&De((function(){return i(o,void 0,void 0,(function(){var e;return s(this,(function(n){return e=new gc(t),u.length>0&&this._handler.onMessagesUpdated(e,this.channel,u),[2]}))}))})),u},t.prototype._applyPollUpdateEventToView=function(e,t){var n=this,r=Uc(this._messages,e.messageId);if(r>=0){var a=this._messages[r];a&&a.isUserMessage()&&a.poll&&a.poll.applyPollUpdateEvent(e)&&gn(t)&&De((function(){return i(n,void 0,void 0,(function(){var e;return s(this,(function(n){return e=new gc(t),this._handler.onMessagesUpdated(e,this.channel,[a]),[2]}))}))}))}},t.prototype._applyPollVoteEventToView=function(e,t){var n=this,r=Uc(this._messages,e.messageId);if(r>=0){var a=this._messages[r];a&&a.isUserMessage()&&a.poll&&a.poll.applyPollVoteEvent(e)&&gn(t)&&De((function(){return i(n,void 0,void 0,(function(){var e;return s(this,(function(n){return e=new gc(t),this._handler.onMessagesUpdated(e,this.channel,[a]),[2]}))}))}))}},t.prototype._updateMessagesToView=function(e,t){var n,r,o=this,u=[];try{for(var c=a(e),l=c.next();!l.done;l=c.next()){var h,d=l.value;if(d.messageId>0)if((h=Ac(this._messages,d))>=0)u.push(d),this._messages[h]=d;else{var p=Ac(this._unsentMessages,d);if(p>=0){u.push(d),this._unsentMessages.splice(p,1);var f=Oc(this._messages,d);this._messages.splice(f,0,d)}}else if(d instanceof Bt)(h=Ac(this._unsentMessages,d))>=0&&(u.push(d),this._unsentMessages[h]=d)}}catch(e){n={error:e}}finally{try{l&&!l.done&&(r=c.return)&&r.call(c)}finally{if(n)throw n.error}}return gn(t)&&De((function(){return i(o,void 0,void 0,(function(){var e;return s(this,(function(n){return e=new gc(t),u.length>0&&this._handler.onMessagesUpdated(e,this.channel,u),[2]}))}))})),u},t.prototype._removeMessagesFromView=function(e,t){var n,r,o=this,u=[],c=function(e){var t=l._messages.findIndex((function(t){return t.messageId===e}));t>=0&&(u.push(l._messages[t].messageId),l._messages.splice(t,1))},l=this;try{for(var h=a(e),d=h.next();!d.done;d=h.next()){c(d.value)}}catch(e){n={error:e}}finally{try{d&&!d.done&&(r=h.return)&&r.call(h)}finally{if(n)throw n.error}}return gn(t)&&u.length>0&&De((function(){return i(o,void 0,void 0,(function(){var e;return s(this,(function(n){return e=new gc(t),u.length>0&&this._handler.onMessagesDeleted(e,this.channel,u),[2]}))}))})),u},t.prototype._removeUnsentMessageFromView=function(e,t){var n=this._unsentMessages.findIndex((function(t){return t.reqId===e}));n>=0&&this._unsentMessages.splice(n,1)},t.prototype._getLocalMessages=function(e,t){var n=t.prevLimit,r=void 0===n?0:n,a=t.nextLimit,c=void 0===a?0:a;return i(this,void 0,void 0,(function(){var t,n,i,a,l,h,d;return s(this,(function(s){switch(s.label){case 0:return t=hc.of(this._iid),r>0?[4,t.getMessagesFromCache(this._channel.url,e,"prev",this.filter,this._limit)]:[3,2];case 1:return i=s.sent(),[3,3];case 2:i=[],s.label=3;case 3:return n=i,c>0?[4,t.getMessagesFromCache(this._channel.url,e,"next",this.filter,this._limit)]:[3,5];case 4:return l=s.sent(),[3,6];case 5:l=[],s.label=6;case 6:if(a=l,n.length>0&&a.length)for(d in h=n.map((function(e){return e.messageId})),a)if(h.includes(a[d].messageId)){a.splice(parseInt(d),1);break}return[2,u(u([],o(n),!1),o(a),!1).sort((function(e,t){return t.createdAt-e.createdAt}))]}}))}))},t.prototype._getRemoteMessages=function(t,n){var a=n.prevLimit,o=void 0===a?0:a,u=n.nextLimit,c=void 0===u?0:u,l=n.source,h=void 0===l?e.MessageEventSource.REQUEST_MESSAGE:l,d=n.reverse,p=void 0!==d&&d;return i(this,void 0,void 0,(function(){var e,n;return s(this,(function(i){switch(i.label){case 0:return e=kn.of(this._iid),o>0||c>0?[4,e.getMessagesByTimestamp(this._channel.url,this._channel.channelType,t,r(r({},this.filter),{reverse:p,prevResultSize:o,nextResultSize:c,includeMetaArray:!0,includeReactions:!0,includeThreadInfo:!0}),h)]:[3,2];case 1:return n=i.sent(),[3,3];case 2:n=[],i.label=3;case 3:return[2,n]}}))}))},t.prototype._checkHugeGap=function(){return i(this,void 0,void 0,(function(){var t,n,a,c,l,h,d,p,f,_,v=this;return s(this,(function(m){switch(m.label){case 0:return this._messages.length>0?(t=this.viewTop,n=this._syncRange.top,a=this._syncRange.bottom,c=this.hasNext?this.viewBottom:Number.MAX_SAFE_INTEGER,[4,(l=hc.of(this._iid)).getCachedMessageCountBetween(this._channel.url,this.filter,t,n)]):[3,4];case 1:return h=m.sent(),[4,l.getCachedMessageCountBetween(this._channel.url,this.filter,a,c)];case 2:return d=m.sent(),[4,ke((function(){return i(v,void 0,void 0,(function(){var l,p,f,_,v,m,g,y,E,b,C,T,I,S,N,w,M,A=this;return s(this,(function(U){switch(U.label){case 0:return l=wt.of(this._iid),p=l.dispatcher,f=l.requestQueue,_=new Ic(r({channelUrl:this._channel.url,channelType:this._channel.channelType,prevStart:t,prevEnd:n,prevCount:h,nextStart:a,nextEnd:c,nextCount:d},this.filter)),[4,f.send(_)];case 1:return v=U.sent(),m=v.as(Sc),g=m.isHugeGap,y=m.prevMessages,E=void 0===y?[]:y,b=m.prevHasMore,C=m.nextMessages,T=void 0===C?[]:C,I=m.nextHasmore,g?De((function(){return i(A,void 0,void 0,(function(){return s(this,(function(e){return this._handler.onHugeGapDetected(),[2]}))}))})):(this._hasPrevious=b,this._hasNext=I,S=this.viewTop,N=this.viewBottom,w=Math.min.apply(Math,u([Number.MAX_SAFE_INTEGER],o(E.map((function(e){return e.createdAt}))),!1)),M=Math.max.apply(Math,u([0],o(T.map((function(e){return e.createdAt}))),!1)),p.dispatch(new yn({messages:E,source:e.MessageEventSource.SYNC_MESSAGE_FILL})),p.dispatch(new yn({messages:T,source:e.MessageEventSource.SYNC_MESSAGE_FILL})),this._syncRange.extends(w,M),SM&&this._nextFill.start(M)),[2]}}))}))}),1)];case 3:return m.sent(),[3,6];case 4:return p=Math.floor(this._limit/2),[4,this._getRemoteMessages(Date.now(),{prevLimit:p,nextLimit:p,source:e.MessageEventSource.SYNC_MESSAGE_FILL})];case 5:(f=m.sent()).length>0&&((_=this._syncRange).extends.apply(_,u([],o(f.map((function(e){return e.createdAt}))),!1)),f.length0?[2,!0]:[2,!1]}}))}))},t.prototype.initialize=function(t){var n=this,r=new Fc;this._messages=[],this._unsentMessages=[],this._syncRange=new cc({}),this._hasNext=!0,this._hasPrevious=!0;var i=Math.floor(this._limit/2);if(t===e.MessageCollectionInitPolicy.CACHE_AND_REPLACE_BY_API)this._getLocalMessages(this._startingPoint,{prevLimit:i,nextLimit:i}).then((function(t){var i=n._filterUnderOffsetMessage(t);n._addMessagesToView(i,e.MessageEventSource.REQUEST_MESSAGE),r._invokeResponse("local",null,i)})).catch((function(e){if(p(e))throw e;r._invokeResponse("local",e,null)})).finally((function(){n._loadAllFailedMessages(),n._getRemoteMessages(n._startingPoint,{prevLimit:i,nextLimit:i,reverse:!0}).then((function(t){var s;n._messages=[];var a=n._filterUnderOffsetMessage(t);a.length0&&((s=n._syncRange).extends.apply(s,u([],o(a.map((function(e){return e.createdAt}))),!1)),n._addMessagesToView(a,e.MessageEventSource.REQUEST_MESSAGE)),r._invokeResponse("remote",null,a)})).catch((function(e){if(p(e))throw e;r._invokeResponse("remote",e,null)}))}));return r},t.prototype.loadPrevious=function(){return i(this,void 0,void 0,(function(){var t,n,r,a,c=this;return s(this,(function(l){switch(l.label){case 0:return this._hasPrevious?(t=this.viewTop,n=[],[4,Pe((function(){return i(c,void 0,void 0,(function(){var e;return s(this,(function(r){switch(r.label){case 0:return e=this._filterUnderOffsetMessage,[4,this._getLocalMessages(t,{prevLimit:this._limit})];case 1:return n=e.apply(this,[r.sent()]),[2]}}))}))}))]):[3,5];case 1:return l.sent(),r=bc.of(this._iid,this._channel),0!==n.length&&r.isWrappingMessages(n)?[3,3]:[4,Pe((function(){return i(c,void 0,void 0,(function(){var e,i;return s(this,(function(s){switch(s.label){case 0:return e=this._filterUnderOffsetMessage,[4,this._getRemoteMessages(t,{prevLimit:this._limit})];case 1:return n=e.apply(this,[s.sent()]),this._hasPrevious=n.length>=this._limit,n.length>0&&((i=this._syncRange).extends.apply(i,u([],o(n.map((function(e){return e.createdAt}))),!1)),r.range.overlap(this._syncRange)&&r.range.extends(this._syncRange.top)),[2]}}))}))}))];case 2:return l.sent(),this._addMessagesToView(n,e.MessageEventSource.REQUEST_MESSAGE),[3,4];case 3:this._hasPrevious=n.length>=this._limit,n.length>0&&((a=this._syncRange).extends.apply(a,u([],o(n.map((function(e){return e.createdAt}))),!1)),this._addMessagesToView(n,e.MessageEventSource.REQUEST_MESSAGE)),l.label=4;case 4:return[2,n];case 5:return[2,[]]}}))}))},t.prototype.loadNext=function(){return i(this,void 0,void 0,(function(){var t,n,r,a,c=this;return s(this,(function(l){switch(l.label){case 0:return t=this.viewBottom,n=[],[4,Pe((function(){return i(c,void 0,void 0,(function(){var e;return s(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]}}))}))}))];case 1:return l.sent(),r=bc.of(this._iid,this._channel),0!==n.length&&r.isWrappingMessages(n)?[3,3]:[4,Pe((function(){return i(c,void 0,void 0,(function(){var e,i;return s(this,(function(s){switch(s.label){case 0:return e=this._filterUnderOffsetMessage,[4,this._getRemoteMessages(t,{nextLimit:this._limit})];case 1:return n=e.apply(this,[s.sent()]),this._hasNext=n.length>=this._limit,n.length>0&&((i=this._syncRange).extends.apply(i,u([],o(n.map((function(e){return e.createdAt}))),!1)),r.range.overlap(this._syncRange)&&r.range.extends(this._syncRange.bottom)),[2]}}))}))}))];case 2:return l.sent(),this._addMessagesToView(n,e.MessageEventSource.REQUEST_MESSAGE),[3,4];case 3:this._hasNext=n.length>=this._limit,n.length>0&&((a=this._syncRange).extends.apply(a,u([],o(n.map((function(e){return e.createdAt}))),!1)),this._addMessagesToView(n,e.MessageEventSource.REQUEST_MESSAGE)),l.label=4;case 4:return[2,n]}}))}))},t.prototype.removeFailedMessage=function(e){return i(this,void 0,void 0,(function(){var t;return s(this,(function(n){switch(n.label){case 0:return[4,hc.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]}}))}))},t.prototype.dispose=function(){wt.of(this._iid).cacheContext.localCacheEnabled&&(this._prevFill.stop(),this._nextFill.stop(),bc.of(this._iid,this._channel).pause()),Tc.of(this._iid,this._channel).pause(),Lc.of(this._iid,this._channel,this._hasPollMessage.bind(this)).pause();var e=hc.of(this._iid);e.unsubscribeGroupChannelEvent(this._key),e.unsubscribeMessageEvent(this._key)},t}(),Gc={coverUrl:null,coverImage:null,isDistinct:null,isPublic:null,isDiscoverable:null,accessCode:null,name:null,data:null,customType:null,operatorUserIds:null,messageSurvivalSeconds:null},Hc={hidePreviousMessages:!1,allowAutoUnhide:!0},Vc=function(e){function t(t){var n=this,r=t.channelUrl,i=t.token,s=t.limit,a=t.order,o=t.mutedMemberFilter,u=t.memberStateFilter,c=t.nicknameStartsWithFilter,l=t.operatorFilter;return(n=e.call(this)||this).method=d.GET,n.path="".concat(ve,"/").concat(encodeURIComponent(r),"/members"),n.params={token:i,limit:s,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 n(t,e),t}(x),Kc=function(e){function t(t,n){var r=e.call(this,t,n)||this;r.token=null,r.members=[];var i=n.next,s=n.members;return r.token=i,s&&s.length>0&&(r.members=s.map((function(e){return new Ho(t,e)}))),r}return n(t,e),t}(F);e.MutedMemberFilter=void 0,(Dc=e.MutedMemberFilter||(e.MutedMemberFilter={})).ALL="all",Dc.MUTED="muted",Dc.UNMUTED="unmuted",e.MemberListOrder=void 0,(Pc=e.MemberListOrder||(e.MemberListOrder={})).MEMBER_NICKNAME_ALPHABETICAL="member_nickname_alphabetical",Pc.OPERATOR_THEN_MEMBER_ALPHABETICAL="operator_then_member_alphabetical",e.MemberStateFilter=void 0,(xc=e.MemberStateFilter||(e.MemberStateFilter={})).ALL="all",xc.JOINED="joined_only",xc.INVITED="invited_only",xc.INVITED_BY_FRIEND="invited_by_friend",xc.INVITED_BY_NON_FRIEND="invited_by_non_friend";var Qc=function(t){function a(n,r,i){var s,a,o,u,c=this;return(c=t.call(this,n,r,e.ChannelType.GROUP,i)||this).mutedMemberFilter=e.MutedMemberFilter.ALL,c.memberStateFilter=e.MemberStateFilter.ALL,c.nicknameStartsWithFilter=null,c.operatorFilter=e.OperatorFilter.ALL,c.order=e.MemberListOrder.MEMBER_NICKNAME_ALPHABETICAL,c.mutedMemberFilter=null!==(s=i.mutedMemberFilter)&&void 0!==s?s:e.MutedMemberFilter.ALL,c.memberStateFilter=null!==(a=i.memberStateFilter)&&void 0!==a?a:e.MemberStateFilter.ALL,c.nicknameStartsWithFilter=null!==(o=i.nicknameStartsWithFilter)&&void 0!==o?o:null,c.order=null!==(u=i.order)&&void 0!==u?u:e.MemberListOrder.MEMBER_NICKNAME_ALPHABETICAL,c}return n(a,t),a.prototype._validate=function(){return t.prototype._validate.call(this)&&y(e.MutedMemberFilter,this.mutedMemberFilter)&&y(e.MemberStateFilter,this.memberStateFilter)&&(g("string",this.nicknameStartsWithFilter)||null===this.nicknameStartsWithFilter)&&y(e.OperatorFilter,this.operatorFilter)&&y(e.MemberListOrder,this.order)},a.prototype.next=function(){return i(this,void 0,void 0,(function(){var e,t,n,i,a,o;return s(this,(function(s){switch(s.label){case 0:return this._validate()?this._isLoading?[3,3]:this._hasNext?(this._isLoading=!0,e=wt.of(this._iid).requestQueue,t=new Vc(r(r({},this),{token:this._token})),[4,e.send(t)]):[3,2]:[3,5];case 1:return n=s.sent(),i=n.as(Kc),a=i.members,o=i.token,this._token=o,this._hasNext=!!o,this._isLoading=!1,[2,a];case 2:return[2,[]];case 3:throw f.queryInProgress;case 4:return[3,6];case 5:throw f.invalidParameters;case 6:return[2]}}))}))},a}(Bn),Bc=function(e){function t(t){var n=this,r=t.channelUrl,i=t.userId,s=t.accessCode;return(n=e.call(this)||this).method=d.PUT,n.path="".concat(ve,"/").concat(encodeURIComponent(r),"/accept"),n.params={user_id:i,access_code:s},n}return n(t,e),t}(x),jc=function(t){function r(n,r){var i=t.call(this,n,r)||this;return i.channel=new wl(n,r),i.channel.myMemberState=e.MemberState.JOINED,i}return n(r,t),r}(F),zc=function(e){function t(t){var n=this,r=t.channelUrl,i=t.isDistinct,s=t.isPublic,a=t.isDiscoverable,o=t.coverUrl,u=t.coverImage,c=t.accessCode,l=t.name,h=t.data,p=t.customType,f=t.operatorUserIds,_=t.messageSurvivalSeconds;return(n=e.call(this)||this).method=d.PUT,n.path="".concat(ve,"/").concat(encodeURIComponent(r)),n.params=D({is_distinct:i,is_public:s,is_discoverable:a,name:l,data:h,custom_type:p,cover_url:o,cover_file:u,access_code:c,operator_ids:f,message_survival_seconds:_}),n}return n(t,e),t}(x),Wc=function(e){function t(t,n){var r=e.call(this,t,n)||this;return r.channel=new wl(t,n),r}return n(t,e),t}(F),Yc=function(e){function t(t){var n=this,r=t.channelUrl;return(n=e.call(this)||this).method=d.DELETE,n.path="".concat(ve,"/").concat(encodeURIComponent(r)),n}return n(t,e),t}(x);!function(e){function t(t,n){return e.call(this,t,n)||this}n(t,e)}(F);var Jc=function(e){function t(t){var n=this,r=t.channelUrl;return(n=e.call(this)||this).method=d.DELETE,n.path="".concat(ve,"/").concat(encodeURIComponent(r),"/hide"),n}return n(t,e),t}(x);!function(e){function t(){return null!==e&&e.apply(this,arguments)||this}n(t,e)}(F);var Xc=function(e){function t(t){var n=t.userId,r=t.channelUrl,i=t.countPreference,s=e.call(this)||this;return s.method=d.PUT,s.path="".concat(fe,"/").concat(encodeURIComponent(n),"/count_preference/").concat(encodeURIComponent(r)),s.params={count_preference:i},s}return n(t,e),t}(x),Zc=function(t){function r(n,r){var i=t.call(this,n,r)||this;return i.countPreference=e.CountPreference[r.count_preference],i}return n(r,t),r}(F),$c=function(e){function t(t){var n=this,r=t.channelUrl;return(n=e.call(this)||this).method=d.PUT,n.path="".concat(ve,"/").concat(encodeURIComponent(r),"/reset_user_history"),n}return n(t,e),t}(x),el=function(e){function t(t,n){var r=e.call(this,t,n)||this;r.messageOffsetTimestamp=null;var i=n.ts_message_offset;return r.messageOffsetTimestamp=null!=i?i:null,r}return n(t,e),t}(F),tl=r(r({},_a),{scheduledAt:null,file:null,fileUrl:null,fileName:null,mimeType:null,fileSize:null,thumbnailSizes:null,requireAuth:!1}),nl=r(r({},ma),{scheduledAt:null}),rl=function(t){function r(n){var r,i=this;i=t.call(this)||this;var s=[];n.mentionType===e.MentionType.USERS&&(n.mentionedUserIds?s=n.mentionedUserIds:n.mentionedUsers&&(s=n.mentionedUsers.map((function(e){return e.userId}))));var a=n.channelType,o=n.channelUrl,u=n.scheduledMessageId;return i.method=d.PUT,i.path="".concat(Je(a),"/").concat(encodeURIComponent(o),"/scheduled_messages/").concat(encodeURIComponent(u)),i.params={req_id:n.reqId,scheduled_at:n.scheduledAt,message_type:ae.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 jt.payloadify(e)})):[],custom_type:n.customType,data:n.data,require_auth:n.requireAuth,mention_type:n.mentionType,mentioned_user_ids:s,sorted_metaarray:null===(r=n.metaArrays)||void 0===r?void 0:r.map((function(e){return xt.payloadify(e)})),apple_critical_alert_options:Gt.payloadify(n.appleCriticalAlertOptions),push_option:n.pushNotificationDeliveryOption},i}return n(r,t),r}(x),il=function(e){function t(t,n){var r=e.call(this,t,n)||this;return r.message=new an(t,n),r}return n(t,e),t}(F),sl=function(t){function r(n){var r,i=this;i=t.call(this)||this;var s=[];n.mentionType===e.MentionType.USERS&&(n.mentionedUserIds?s=n.mentionedUserIds:n.mentionedUsers&&(s=n.mentionedUsers.map((function(e){return e.userId}))));var a=n.channelType,o=n.channelUrl,u=n.scheduledMessageId;return i.method=d.PUT,i.path="".concat(Je(a),"/").concat(encodeURIComponent(o),"/scheduled_messages/").concat(encodeURIComponent(u)),i.params={req_id:n.reqId,scheduled_at:n.scheduledAt,message_type:ae.USER,message:n.message,custom_type:n.customType,data:n.data,mention_type:n.mentionType,mentioned_user_ids:s,sorted_metaarray:null===(r=n.metaArrays)||void 0===r?void 0:r.map((function(e){return xt.payloadify(e)})),apple_critical_alert_options:Gt.payloadify(n.appleCriticalAlertOptions),target_langs:n.translationTargetLanguages,push_option:n.pushNotificationDeliveryOption},i}return n(r,t),r}(x);!function(e){function t(t,n){var r=e.call(this,t,n)||this;return r.message=new nn(t,n),r}n(t,e)}(F);var al=function(e){function t(t){var n=e.call(this)||this,r=t.channelType,i=t.channelUrl,s=t.scheduledMessageId;return n.method=d.DELETE,n.path="".concat(Je(r),"/").concat(encodeURIComponent(i),"/scheduled_messages/").concat(encodeURIComponent(s)),n}return n(t,e),t}(x),ol=function(e){function t(t){var n=e.call(this)||this,r=t.channelType,i=t.channelUrl,s=t.scheduledMessageId;return n.method=d.POST,n.path="".concat(Je(r),"/").concat(encodeURIComponent(i),"/scheduled_messages/").concat(encodeURIComponent(s),"/send_now"),n}return n(t,e),t}(x),ul=function(e){function t(t){var n=t.userId,r=t.channelUrl,i=t.pushTriggerOption,s=e.call(this)||this;return s.method=d.PUT,s.path="".concat(fe,"/").concat(encodeURIComponent(n),"/push_preference/").concat(encodeURIComponent(r)),s.params={push_trigger_option:i},s}return n(t,e),t}(x),cl=function(e){function t(t,n){var r=e.call(this,t,n)||this;return r.pushTriggerOption=n.push_trigger_option,r.enabled=n.enable,r}return n(t,e),t}(F),ll=function(e){function t(t){var n=t.userId,r=t.channelUrl,i=e.call(this)||this;return i.method=d.GET,i.path="".concat(fe,"/").concat(encodeURIComponent(n),"/push_preference/").concat(encodeURIComponent(r)),i}return n(t,e),t}(x),hl=function(e){function t(t,n){var r=e.call(this,t,n)||this;return r.pushTriggerOption=n.push_trigger_option,r.enabled=n.enable,r}return n(t,e),t}(F),dl=function(e){function t(t){var n=t.pollId,r=t.title,i=t.data,s=t.allowUserSuggestion,a=t.allowMultipleVotes,o=t.closeAt,u=e.call(this)||this;return u.method=d.PUT,u.path="".concat(Ie,"/").concat(encodeURIComponent(n)),u.params={title:r,data:i,allow_user_suggestion:s,allow_multiple_votes:a,close_at:o},u}return n(t,e),t}(x),pl=function(e){function t(t,n){var r=e.call(this,t,n)||this;return r.poll=new tn(t,n),r}return n(t,e),t}(F),fl=function(e){function t(t){var n=t.pollId,r=e.call(this)||this;return r.method=d.DELETE,r.path="".concat(Ie,"/").concat(encodeURIComponent(n)),r}return n(t,e),t}(x);!function(e){function t(){return null!==e&&e.apply(this,arguments)||this}n(t,e)}(F);var _l=function(e){function t(t){var n=t.pollId,r=e.call(this)||this;return r.method=d.PUT,r.path="".concat(Ie,"/").concat(encodeURIComponent(n),"/close"),r}return n(t,e),t}(x),vl=function(e){function t(t,n){var r=e.call(this,t,n)||this;return r.poll=new tn(t,n),r}return n(t,e),t}(F),ml=function(e){function t(t){var n=t.channelUrl,r=t.channelType,i=t.pollId,s=t.optionText,a=e.call(this)||this;return a.method=d.POST,a.path="".concat(Ie,"/").concat(encodeURIComponent(i),"/options"),a.params={channel_url:n,channel_type:r,text:s},a}return n(t,e),t}(x),gl=function(e){function t(t,n){var r=e.call(this,t,n)||this;return r.poll=new tn(t,n),r}return n(t,e),t}(F),yl=function(e){function t(t){var n=t.pollId,r=t.pollOptionId,i=t.optionText,s=e.call(this)||this;return s.method=d.PUT,s.path="".concat(Ie,"/").concat(encodeURIComponent(n),"/options/").concat(encodeURIComponent(r)),s.params={text:i},s}return n(t,e),t}(x),El=function(e){function t(t,n){var r=e.call(this,t,n)||this;return r.poll=new tn(t,n),r}return n(t,e),t}(F),bl=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(Ie,"/").concat(encodeURIComponent(n),"/options/").concat(encodeURIComponent(r)),i}return n(t,e),t}(x);!function(e){function t(){return null!==e&&e.apply(this,arguments)||this}n(t,e)}(F);var Cl,Tl,Il,Sl=function(t){function r(n){var r=n.reqId,i=n.channelType,s=n.channelUrl,a=n.pollId,o=n.pollOptionIds;return t.call(this,{code:"VOTE",ackRequired:!0,payload:D({req_id:r,channel_type:i===e.ChannelType.OPEN?"open_channels":"group_channels",channel_url:s,poll_id:a,option_ids:o})})||this}return n(r,t),r}(z);e.CountPreference=void 0,(Cl=e.CountPreference||(e.CountPreference={})).ALL="all",Cl.UNREAD_MESSAGE_COUNT_ONLY="unread_message_count_only",Cl.UNREAD_MENTION_COUNT_ONLY="unread_mention_count_only",Cl.OFF="off",e.MutedState=void 0,(Tl=e.MutedState||(e.MutedState={})).MUTED="muted",Tl.UNMUTED="unmuted",e.HiddenState=void 0,(Il=e.HiddenState||(e.HiddenState={})).UNHIDDEN="unhidden",Il.HIDDEN_ALLOW_AUTO_UNHIDE="hidden_allow_auto_unhide",Il.HIDDEN_PREVENT_AUTO_UNHIDE="hidden_prevent_auto_unhide";var Nl,wl=function(t){function c(n,i){var s,a,c,l,h,d,p,f,_,v,m,E,b,C,T,I,S,N,w=this;return(w=t.call(this,n,i)||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=e.HiddenState.UNHIDDEN,w.lastMessage=null,w.messageOffsetTimestamp=0,w.messageSurvivalSeconds=-1,w.myMemberState=e.MemberState.NONE,w.myRole=e.Role.NONE,w.myMutedState=e.MutedState.UNMUTED,w.myLastRead=0,w.myCountPreference=e.CountPreference.ALL,w.myPushTriggerOption=e.PushTriggerOption.DEFAULT,w.inviter=null,w.invitedAt=0,w.joinedAt=0,w.channelType=e.ChannelType.GROUP,w.isDistinct=null!==(a=i.is_distinct)&&void 0!==a&&a,w.isSuper=null!==(c=i.is_super)&&void 0!==c&&c,w.isBroadcast=null!==(l=i.is_broadcast)&&void 0!==l&&l,w.isExclusive=null!==(h=i.is_exclusive)&&void 0!==h&&h,w.isPublic=null!==(d=i.is_public)&&void 0!==d&&d,w.isDiscoverable=null!==(p=i.is_discoverable)&&void 0!==p?p:w.isPublic,w.isAccessCodeRequired=null!==(f=i.is_access_code_required)&&void 0!==f&&f,w.isPushEnabled=null!==(_=i.is_push_enabled)&&void 0!==_&&_,Array.isArray(i.members)&&(s=w.members).push.apply(s,u([],o(i.members.map((function(e){return new Ho(w._iid,e)}))),!1)),w.memberCount=null!==(v=i.member_count)&&void 0!==v?v:0,w.joinedMemberCount=null!==(m=i.joined_member_count)&&void 0!==m?m:0,w.hiddenState=y(e.HiddenState,i.hidden_state)?i.hidden_state:e.HiddenState.UNHIDDEN,w.messageOffsetTimestamp=null!==(E=i.ts_message_offset)&&void 0!==E?E:0,w.messageSurvivalSeconds=null!==(b=i.message_survival_seconds)&&void 0!==b?b:-1,w.lastMessage=i.last_message?sn(w._iid,r({channel_type:w.channelType},i.last_message)):null,i.read_receipt&&Object.keys(i.read_receipt).forEach((function(e){g("number",i.read_receipt[e])&&w._updateUnreadMemberState(e,i.read_receipt[e])})),i.delivery_receipt&&Object.keys(i.delivery_receipt).forEach((function(e){g("number",i.delivery_receipt[e])&&w._updateUndeliveredMemberState(e,i.delivery_receipt[e])})),w.myMemberState=y(e.MemberState,i.member_state)?i.member_state:e.MemberState.NONE,w.myRole=y(e.Role,i.my_role)?i.my_role:e.Role.NONE,y(e.MutedState,i.is_muted)?w.myMutedState=i.is_muted:g("boolean",i.is_muted)?w.myMutedState=i.is_muted?e.MutedState.MUTED:e.MutedState.UNMUTED:w.myMutedState=e.MutedState.UNMUTED,w.myCountPreference=y(e.CountPreference,i.count_preference)?i.count_preference:e.CountPreference.ALL,w.myPushTriggerOption=y(e.PushTriggerOption,i.push_trigger_option)?i.push_trigger_option:e.PushTriggerOption.ALL,w.myLastRead=null!==(C=i.user_last_read)&&void 0!==C?C:0,w.inviter=i.inviter?new ht(w._iid,i.inviter):null,w.invitedAt=null!==(T=i.invited_at)&&void 0!==T?T:0,w.joinedAt=null!==(I=i.joined_ts)&&void 0!==I?I:0,w._updateUnreadCount(null!==(S=i.unread_message_count)&&void 0!==S?S:0,null!==(N=i.unread_mention_count)&&void 0!==N?N:0),w}return n(c,t),Object.defineProperty(c.prototype,"isHidden",{get:function(){return this.hiddenState!==e.HiddenState.UNHIDDEN},enumerable:!1,configurable:!0}),Object.defineProperty(c.prototype,"isTyping",{get:function(){return Object.keys(this._typingStatus).length>0},enumerable:!1,configurable:!0}),Object.defineProperty(c.prototype,"cachedUnreadMemberState",{get:function(){var e,t,n={};try{for(var r=a(this._unreadMemberStateMap),i=r.next();!i.done;i=r.next()){var s=o(i.value,2),u=s[0],c=s[1];n[u]=c}}catch(t){e={error:t}}finally{try{i&&!i.done&&(t=r.return)&&t.call(r)}finally{if(e)throw e.error}}return n},enumerable:!1,configurable:!0}),Object.defineProperty(c.prototype,"cachedUndeliveredMemberState",{get:function(){var e,t,n={};try{for(var r=a(this._undeliveredMemberStateMap),i=r.next();!i.done;i=r.next()){var s=o(i.value,2),u=s[0],c=s[1];n[u]=c}}catch(t){e={error:t}}finally{try{i&&!i.done&&(t=r.return)&&t.call(r)}finally{if(e)throw e.error}}return n},enumerable:!1,configurable:!0}),c.payloadify=function(e){return e?D(r(r({},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 Ho.payloadify(e)})),last_message:rn(e.lastMessage),inviter:e.inviter?ht.payloadify(e.inviter):null,invited_at:e.invitedAt,joined_ts:e.joinedAt})):null},c.prototype._shouldUpdateLastMessageWith=function(e){return!(e instanceof Bt&&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=wt.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},c.prototype._updateUnreadMemberState=function(e,t){var n=this._unreadMemberStateMap.get(e);return(!n||n0?this._typingStatus[e.userId]={user:e,ts:t}:delete this._typingStatus[e.userId]},c.prototype._invalidateTypingStatus=function(){var e=(new Date).getTime(),t=!1;for(var n in this._typingStatus){e-this._typingStatus[n].ts>=1e4&&(delete this._typingStatus[n],t=!0)}return t},c.prototype._setLatestMemberCount=function(e,t,n){var r=!1;return n>=this._lastMemberCountUpdated&&(this._lastMemberCountUpdated=n,r=e!==this.memberCount||t!==this.joinedMemberCount,this.memberCount=e,this.joinedMemberCount=t),r},c.prototype.isReadMessage=function(e){var t=wt.of(this._iid).sdkState,n=this._unreadMemberStateMap.get(t.userId);return n&&n>=e.createdAt},c.prototype.serialize=function(){var e=this;return ot(this,(function(t){t.cachedUnreadMemberState=e.cachedUnreadMemberState,t.cachedUndeliveredMemberState=e.cachedUndeliveredMemberState}))},c.prototype.createMessageCollection=function(e){return void 0===e&&(e={}),new qc(this._iid,r({channel:this},e))},c.prototype.createMemberListQuery=function(e){return void 0===e&&(e={}),new Qc(this._iid,this.url,e)},c.prototype.addMember=function(t,n){if(void 0===n&&(n=0),!this.isExclusive&&!this.isSuper&&!this.isBroadcast){var r=this.members.findIndex((function(e){return e.userId===t.userId}));if(r>-1){var i=this.members[r];i.state===e.MemberState.JOINED&&(t.state=i.state),this.members.splice(r,1),this.memberCount--}this.members.push(t),this.memberCount++,this._updateUnreadMemberState(t.userId,n),this._updateUndeliveredMemberState(t.userId,n)}},c.prototype.removeMember=function(e){if(!this.isExclusive&&!this.isSuper&&!this.isBroadcast){var t=this.members.findIndex((function(t){return t.userId===e.userId}));if(t>-1)return this.members.splice(t,1),this.memberCount--,!0}return!1},c.prototype.getUnreadMemberCount=function(t){var n,r;if(t instanceof Bt&&!this.isExclusive&&!this.isSuper&&!this.isBroadcast){var i=wt.of(this._iid).sdkState,s=t.createdAt,o=0;try{for(var u=a(this.members),c=u.next();!c.done;c=u.next()){var l=c.value;if(i.userId!==l.userId&&l.state===e.MemberState.JOINED&&t.sender.userId!==l.userId)(this.cachedUnreadMemberState[l.userId]||0)=e.createdAt&&i.push(s))})),i},c.prototype.getUnreadMembers=function(e,t){var n=this;void 0===t&&(t=!1);var r=wt.of(this._iid).sdkState;if(!r.userId||this.isExclusive||this.isSuper||this.isBroadcast)return[];var i=[];return this.members.forEach((function(s){(t||s.userId!==r.userId&&s.userId!==e.sender.userId)&&(n._unreadMemberStateMap.get(s.userId)=e&&(delete this._typingStatus[r],n=!0)}return n},c.prototype.refresh=function(){return i(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=wt.of(this._iid),n=t.requestQueue,r=t.dispatcher,i=new hu({channelUrl:this.url}),[4,n.send(i)];case 1:return a=s.sent(),o=a.as(du).channel,r.dispatch(new su({channels:[o],source:e.GroupChannelEventSource.REQUEST_CHANNEL})),[2,o]}}))}))},c.prototype.freeze=function(){return i(this,void 0,void 0,(function(){return s(this,(function(n){switch(n.label){case 0:return[4,t.prototype.freeze.call(this)];case 1:return n.sent(),wt.of(this._iid).dispatcher.dispatch(new su({channels:[this],source:e.GroupChannelEventSource.EVENT_CHANNEL_HIDDEN})),[2]}}))}))},c.prototype.unfreeze=function(){return i(this,void 0,void 0,(function(){return s(this,(function(n){switch(n.label){case 0:return[4,t.prototype.unfreeze.call(this)];case 1:return n.sent(),wt.of(this._iid).dispatcher.dispatch(new su({channels:[this],source:e.GroupChannelEventSource.EVENT_CHANNEL_UNHIDDEN})),[2]}}))}))},c.prototype.updateChannel=function(t){return i(this,void 0,void 0,(function(){var n,i,a,o,u,c,l;return s(this,(function(s){switch(s.label){case 0:return n=r(r({},Gc),t),ct(function(e){return g("string",e.coverUrl,!0)&&(T(e.coverImage)||g("string",e.coverImage)||null===e.coverImage)&&g("boolean",e.isDistinct,!0)&&g("boolean",e.isPublic,!0)&&g("boolean",e.isDiscoverable,!0)&&g("string",e.accessCode,!0)&&g("string",e.name,!0)&&g("string",e.data,!0)&&g("string",e.customType,!0)&&b("string",e.operatorUserIds,!0)&&g("number",e.messageSurvivalSeconds,!0)}(n)).throw(f.invalidParameters),i=wt.of(this._iid),a=i.dispatcher,o=i.requestQueue,u=new zc(r({channelUrl:this.url},n)),[4,o.send(u)];case 1:return c=s.sent(),l=c.as(Wc).channel,a.dispatch(new su({channels:[l],source:e.GroupChannelEventSource.EVENT_CHANNEL_UPDATED})),[2,l]}}))}))},c.prototype.invite=function(e){return i(this,void 0,void 0,(function(){return s(this,(function(t){return ct(e.every((function(e){return e instanceof ht}))).throw(f.invalidParameters),[2,this.inviteWithUserIds(e.map((function(e){return e.userId})))]}))}))},c.prototype.inviteWithUserIds=function(t){return i(this,void 0,void 0,(function(){var n,r,i,a,o,u;return s(this,(function(s){switch(s.label){case 0:return ct(b("string",t)).throw(f.invalidParameters),n=wt.of(this._iid),r=n.dispatcher,i=n.requestQueue,a=new Du({channelUrl:this.url,userIds:t}),[4,i.send(a)];case 1:return o=s.sent(),u=o.as(Pu).channel,r.dispatch(new su({channels:[u],source:e.GroupChannelEventSource.EVENT_CHANNEL_INVITED})),[2,u]}}))}))},c.prototype.join=function(t){return void 0===t&&(t=null),i(this,void 0,void 0,(function(){var n,r,i,a,o,u,c;return s(this,(function(s){switch(s.label){case 0:return ct(g("string",t)||null===t).throw(f.invalidParameters),n=wt.of(this._iid),r=n.dispatcher,i=n.sdkState,a=n.requestQueue,o=new Uu({channelUrl:this.url,userId:i.userId,accessCode:t}),[4,a.send(o)];case 1:return u=s.sent(),(c=u.as(Ou).channel).myMemberState=e.MemberState.JOINED,r.dispatch(new su({channels:[c],source:e.GroupChannelEventSource.EVENT_CHANNEL_JOINED})),[2,this]}}))}))},c.prototype.leave=function(e){return void 0===e&&(e=!1),i(this,void 0,void 0,(function(){var t,n,r,i;return s(this,(function(s){switch(s.label){case 0:return t=wt.of(this._iid),n=t.sdkState,r=t.requestQueue,i=new Lu({channelUrl:this.url,userId:n.userId,shouldRemoveOperatorStatus:e}),[4,r.send(i)];case 1:return s.sent(),[2]}}))}))},c.prototype.acceptInvitation=function(t){return void 0===t&&(t=null),i(this,void 0,void 0,(function(){var n,r,i,a,o,u,c;return s(this,(function(s){switch(s.label){case 0:return ct(g("string",t)||null===t).throw(f.invalidParameters),n=wt.of(this._iid),r=n.dispatcher,i=n.sdkState,a=n.requestQueue,o=new Bc({channelUrl:this.url,userId:i.userId,accessCode:t}),[4,a.send(o)];case 1:return u=s.sent(),(c=u.as(jc).channel).myMemberState=e.MemberState.JOINED,r.dispatch(new su({channels:[c],source:e.GroupChannelEventSource.EVENT_CHANNEL_ACCEPTED_INVITE})),[2,c]}}))}))},c.prototype.declineInvitation=function(){return i(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=wt.of(this._iid),n=t.sdkState,r=t.requestQueue,i=new Fu({channelUrl:this.url,userId:n.userId}),[4,r.send(i)];case 1:return a=s.sent(),(o=a.as(qu).channel).myMemberState=e.MemberState.NONE,[2,o]}}))}))},c.prototype.sendUserMessage=function(n){var r=this,i=new Dn,s=wt.of(this._iid).dispatcher,a=ei.of(this._iid);return t.prototype.sendUserMessage.call(this,n).onPending((function(e){a.completeCurrentAndProcessNextAutoResend(e),i._trigger(null,e)})).onFailed((function(e,t){t&&a.completeCurrentAndProcessNextAutoResend(t),i._trigger(e,t)})).onSucceeded((function(t){var n=hc.of(r._iid);a.completeCurrentAndProcessNextAutoResend(t),r._shouldUpdateLastMessageWith(t)&&(r.lastMessage=t),n.handlers.map((function(e){return e.onChannelChanged(r)})),s.dispatch(new su({channels:[r],source:e.GroupChannelEventSource.EVENT_MESSAGE_SENT})),i._trigger(null,t)})),i},c.prototype.updateUserMessage=function(n,r){return i(this,void 0,void 0,(function(){var i,a,o,u=this;return s(this,(function(s){switch(s.label){case 0:return i=wt.of(this._iid).dispatcher,[4,t.prototype.updateUserMessage.call(this,n,r)];case 1:return a=s.sent(),o=!1,!a.silent&&this._shouldUpdateLastMessageWith(a)&&(this.lastMessage=a,o=!0),o&&(hc.of(this._iid).handlers.map((function(e){return e.onChannelChanged(u)})),i.dispatch(new su({channels:[this],source:e.GroupChannelEventSource.EVENT_CHANNEL_UPDATED}))),i.dispatch(new yn({messages:[a],source:e.MessageEventSource.EVENT_MESSAGE_UPDATED})),[2,a]}}))}))},c.prototype._autoResendUserMessage=function(n){var r=this,i=new Dn,s=wt.of(this._iid).dispatcher,a=ei.of(this._iid);return t.prototype._autoResendUserMessage.call(this,n).onPending((function(e){a.completeCurrentAndProcessNextAutoResend(e),i._trigger(null,e)})).onFailed((function(e,t){a.completeCurrentAndProcessNextAutoResend(t),i._trigger(e,t)})).onSucceeded((function(t){var n=hc.of(r._iid);a.completeCurrentAndProcessNextAutoResend(t),r._shouldUpdateLastMessageWith(t)&&(r.lastMessage=t),n.handlers.map((function(e){return e.onChannelChanged(r)})),s.dispatch(new su({channels:[r],source:e.GroupChannelEventSource.EVENT_MESSAGE_SENT})),i._trigger(null,t)})),i},c.prototype.sendFileMessage=function(n){var r=this,i=new Dn,s=wt.of(this._iid).dispatcher,a=ei.of(this._iid);return t.prototype.sendFileMessage.call(this,n).onPending((function(e){a.completeCurrentAndProcessNextAutoResend(e),i._trigger(null,e)})).onFailed((function(e,t){t&&a.completeCurrentAndProcessNextAutoResend(t),i._trigger(e,t)})).onSucceeded((function(t){var n=hc.of(r._iid);a.completeCurrentAndProcessNextAutoResend(t),r._shouldUpdateLastMessageWith(t)&&(r.lastMessage=t),n.handlers.map((function(e){return e.onChannelChanged(r)})),s.dispatch(new su({channels:[r],source:e.GroupChannelEventSource.EVENT_MESSAGE_SENT})),i._trigger(null,t)})),i},c.prototype.updateFileMessage=function(n,r){return i(this,void 0,void 0,(function(){var i,a,o,u=this;return s(this,(function(s){switch(s.label){case 0:return i=wt.of(this._iid).dispatcher,[4,t.prototype.updateFileMessage.call(this,n,r)];case 1:return a=s.sent(),o=!1,!a.silent&&this._shouldUpdateLastMessageWith(a)&&(this.lastMessage=a,o=!0),o&&(hc.of(this._iid).handlers.map((function(e){return e.onChannelChanged(u)})),i.dispatch(new su({channels:[this],source:e.GroupChannelEventSource.EVENT_CHANNEL_UPDATED}))),i.dispatch(new yn({messages:[a],source:e.MessageEventSource.EVENT_MESSAGE_UPDATED})),[2,a]}}))}))},c.prototype._autoResendFileMessage=function(n){var r=this,i=new Dn,s=wt.of(this._iid).dispatcher,a=ei.of(this._iid);return t.prototype._autoResendFileMessage.call(this,n).onPending((function(e){a.completeCurrentAndProcessNextAutoResend(e),i._trigger(null,e)})).onFailed((function(e,t){a.completeCurrentAndProcessNextAutoResend(t),i._trigger(e,t)})).onSucceeded((function(t){var n=hc.of(r._iid);a.completeCurrentAndProcessNextAutoResend(t),r._shouldUpdateLastMessageWith(t)&&(r.lastMessage=t),n.handlers.map((function(e){return e.onChannelChanged(r)})),s.dispatch(new su({channels:[r],source:e.GroupChannelEventSource.EVENT_MESSAGE_SENT})),i._trigger(null,t)})),i},c.prototype.deleteMessage=function(n){return i(this,void 0,void 0,(function(){return s(this,(function(r){switch(r.label){case 0:return[4,t.prototype.deleteMessage.call(this,n)];case 1:return r.sent(),0===n.messageId&&wt.of(this._iid).dispatcher.dispatch(new bn({reqId:n.reqId,source:e.MessageEventSource.EVENT_MESSAGE_DELETED})),[2]}}))}))},c.prototype.hide=function(t){return i(this,void 0,void 0,(function(){var n,i,a,o,u,c,l,h;return s(this,(function(s){switch(s.label){case 0:return n=r(r({},Hc),t),ct(function(e){return g("boolean",e.hidePreviousMessages)&&g("boolean",e.allowAutoUnhide)}(n)).throw(f.invalidParameters),i=wt.of(this._iid),a=i.dispatcher,o=i.sdkState,u=i.requestQueue,c=new ju(r({channelUrl:this.url,userId:o.userId},n)),[4,u.send(c)];case 1:return l=s.sent(),h=l.as(zu).messageOffsetTimestamp,this.hiddenState=n.allowAutoUnhide?e.HiddenState.HIDDEN_ALLOW_AUTO_UNHIDE:e.HiddenState.HIDDEN_PREVENT_AUTO_UNHIDE,n.hidePreviousMessages&&this._updateUnreadCount(0,0),h&&(this.messageOffsetTimestamp=h),a.dispatch(new su({channels:[this],source:e.GroupChannelEventSource.EVENT_CHANNEL_HIDDEN})),[2,this]}}))}))},c.prototype.unhide=function(){return i(this,void 0,void 0,(function(){var t,n,r,i;return s(this,(function(s){switch(s.label){case 0:return t=wt.of(this._iid),n=t.dispatcher,r=t.requestQueue,i=new Jc({channelUrl:this.url}),[4,r.send(i)];case 1:return s.sent(),this.hiddenState=e.HiddenState.UNHIDDEN,n.dispatch(new su({channels:[this],source:e.GroupChannelEventSource.EVENT_CHANNEL_UNHIDDEN})),[2,this]}}))}))},c.prototype.delete=function(){return i(this,void 0,void 0,(function(){var e,t;return s(this,(function(n){switch(n.label){case 0:return e=wt.of(this._iid).requestQueue,t=new Yc({channelUrl:this.url}),[4,e.send(t)];case 1:return n.sent(),[2]}}))}))},c.prototype.markAsRead=function(){return i(this,void 0,void 0,(function(){var t,n,r,i,a,o,u,c=this;return s(this,(function(s){switch(s.label){case 0:return t=wt.of(this._iid),n=t.sdkState,r=t.dispatcher,i=t.requestQueue,a=new Hu({channelUrl:this.url}),[4,i.send(a)];case 1:return o=s.sent(),u=o.as(Vu).readStatus,this._updateUnreadMemberState(n.userId,u.readAt),(this.unreadMessageCount>0||this.unreadMentionCount>0)&&(this._updateUnreadCount(0,0),hc.of(this._iid).handlers.map((function(e){return e.onChannelChanged(c)}))),r.dispatch(new su({channels:[this],source:e.GroupChannelEventSource.EVENT_CHANNEL_READ})),[2]}}))}))},c.prototype.markAsDelivered=function(){return i(this,void 0,void 0,(function(){var e,t,n,r;return s(this,(function(i){switch(i.label){case 0:return e=wt.of(this._iid),t=e.sdkState,n=e.requestQueue,r=new Ku({channelUrl:this.url,userId:t.userId}),[4,n.send(r)];case 1:return i.sent(),[2]}}))}))},c.prototype.startTyping=function(){return i(this,void 0,void 0,(function(){var e,t,n,r,i;return s(this,(function(s){return e=wt.of(this._iid),t=e.requestQueue,n=e.typingIndicatorThrottle,(r=(new Date).getTime())-this._typingStarted>=n&&(this._typingStarted=r,this._typingEnded=0,i=new Yu({channelUrl:this.url,time:this._typingStarted}),t.send(i)),[2]}))}))},c.prototype.endTyping=function(){return i(this,void 0,void 0,(function(){var e,t,n,r,i;return s(this,(function(s){return e=wt.of(this._iid),t=e.requestQueue,n=e.typingIndicatorThrottle,(r=(new Date).getTime())-this._typingEnded>=n&&(this._typingStarted=0,this._typingEnded=r,i=new Xu({channelUrl:this.url,time:this._typingStarted}),t.send(i)),[2]}))}))},c.prototype.createScheduledUserMessage=function(e){e=r(r({},Kr),e),ct(function(e){return Pr(e)&&g("number",e.scheduledAt,!0)}(e)).throw(f.invalidParameters);var t=new Dn;return this._createScheduledUserMessage(e,t),t},c.prototype.updateScheduledUserMessage=function(e,t){return i(this,void 0,void 0,(function(){var n,i,a,o;return s(this,(function(s){switch(s.label){case 0:return n=r(r({},nl),t),ct(function(e){return ga(e)&&g("number",e.scheduledAt,!0)}(n)).throw(f.invalidParameters),i=wt.of(this._iid).requestQueue,a=new sl(r({reqId:this._generateRequestId(),scheduledMessageId:e,channelType:this.channelType,channelUrl:this.url},n)),[4,i.send(a)];case 1:return o=s.sent(),[2,o.as(wo).message]}}))}))},c.prototype.createScheduledFileMessage=function(e){var t=this;e=r(r({},Qr),e),ct(function(e){return Lr(e)&&g("number",e.scheduledAt)&&(T(e.file)||g("string",e.fileUrl))&&g("string",e.fileName,!0)&&g("string",e.mimeType,!0)&&g("number",e.fileSize,!0)&&(null===e.thumbnailSizes||e.thumbnailSizes.every((function(e){return g("object",e)&&e.maxWidth>0&&e.maxHeight>0})))}(e)).throw(f.invalidParameters);var n=Date.now(),a=this._generateRequestId(),o=new Dn;return Re(2).then((function(){var r=t._createPendingScheduledFileMessage(e,a,n);De((function(){return i(t,void 0,void 0,(function(){return s(this,(function(e){return[2,o._trigger(null,r)]}))}))}))})),T(e.file)?this._uploadFileAndUpdateParams(e).then((function(){return t._createScheduledFileMessage(e,o,a,n)})):this._createScheduledFileMessage(e,o,a,n),o},c.prototype.updateScheduledFileMessage=function(e,t){return i(this,void 0,void 0,(function(){var n,i,a;return s(this,(function(s){switch(s.label){case 0:return n=r(r({},tl),t),ct(function(e){return va(e)&&g("number",e.scheduledAt,!0)&&(T(e.file)||g("string",e.fileUrl))&&g("string",e.fileName,!0)&&g("string",e.mimeType,!0)&&g("number",e.fileSize,!0)&&(null===e.thumbnailSizes||e.thumbnailSizes.every((function(e){return g("object",e)&&e.maxWidth>0&&e.maxHeight>0})))}(n)).throw(f.invalidParameters),T(n.file)?[4,this._uploadFileAndUpdateParams(n)]:[3,2];case 1:s.sent(),s.label=2;case 2:return i=new rl(r({reqId:this._generateRequestId(),scheduledMessageId:e,channelType:this.channelType,channelUrl:this.url},n)),[4,wt.of(this._iid).requestQueue.send(i)];case 3:return a=s.sent(),[2,a.as(il).message]}}))}))},c.prototype.cancelScheduledMessage=function(e){return i(this,void 0,void 0,(function(){var t;return s(this,(function(n){switch(n.label){case 0:return t=new al({scheduledMessageId:e,channelType:this.channelType,channelUrl:this.url}),[4,wt.of(this._iid).requestQueue.send(t)];case 1:return n.sent(),[2]}}))}))},c.prototype.sendScheduledMessageNow=function(e){return i(this,void 0,void 0,(function(){var t;return s(this,(function(n){switch(n.label){case 0:return t=new ol({scheduledMessageId:e,channelType:this.channelType,channelUrl:this.url}),[4,wt.of(this._iid).requestQueue.send(t)];case 1:return n.sent(),[2]}}))}))},c.prototype.getMyPushTriggerOption=function(){return i(this,void 0,void 0,(function(){var e,t,n,r,i,a;return s(this,(function(s){switch(s.label){case 0:return e=wt.of(this._iid),t=e.sdkState,n=e.requestQueue,r=new ll({userId:t.userId,channelUrl:this.url}),[4,n.send(r)];case 1:return i=s.sent(),a=i.as(hl).pushTriggerOption,this.myPushTriggerOption=a,[2,a]}}))}))},c.prototype.setMyPushTriggerOption=function(t){return i(this,void 0,void 0,(function(){var n,r,i,a,o,u;return s(this,(function(s){switch(s.label){case 0:return ct(y(e.PushTriggerOption,t)).throw(f.invalidParameters),n=wt.of(this._iid),r=n.sdkState,i=n.requestQueue,a=new ul({userId:r.userId,channelUrl:this.url,pushTriggerOption:t}),[4,i.send(a)];case 1:return o=s.sent(),u=o.as(cl).pushTriggerOption,this.myPushTriggerOption=u,[2,u]}}))}))},c.prototype.setMyCountPreference=function(t){return i(this,void 0,void 0,(function(){var n,r,i,a,o,u,c;return s(this,(function(s){switch(s.label){case 0:return ct(y(e.CountPreference,t)).throw(f.invalidParameters),n=wt.of(this._iid),r=n.dispatcher,i=n.sdkState,a=n.requestQueue,o=new Xc({channelUrl:this.url,userId:i.userId,countPreference:t}),[4,a.send(o)];case 1:return u=s.sent(),c=u.as(Zc).countPreference,this.myCountPreference=c,this._updateUnreadCount(this.unreadMessageCount,this.unreadMentionCount),r.dispatch(new su({channels:[this],source:e.GroupChannelEventSource.EVENT_CHANNEL_CREATED})),[2,c]}}))}))},c.prototype.resetMyHistory=function(){return i(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=wt.of(this._iid),n=t.dispatcher,r=t.requestQueue,i=new $c({channelUrl:this.url}),[4,r.send(i)];case 1:return a=s.sent(),o=a.as(el).messageOffsetTimestamp,this.messageOffsetTimestamp=o,n.dispatch(new su({channels:[this],source:e.GroupChannelEventSource.EVENT_CHANNEL_RESET_HISTORY})),[2,this]}}))}))},c.prototype.updatePoll=function(e,t){return i(this,void 0,void 0,(function(){var n,i,a;return s(this,(function(s){switch(s.label){case 0:return ct(g("number",e)&&function(e){return g("string",e.title,!0)&&$t(e.data)&&g("boolean",e.allowUserSuggestion,!0)&&g("boolean",e.allowMultipleVotes,!0)&&g("number",e.closeAt,!0)}(t)).throw(f.invalidParameters),n=wt.of(this._iid).requestQueue,i=new dl(r({pollId:e},t)),[4,n.send(i)];case 1:return a=s.sent(),[2,a.as(pl).poll]}}))}))},c.prototype.deletePoll=function(e){return i(this,void 0,void 0,(function(){var t,n,r;return s(this,(function(i){switch(i.label){case 0:return t=g("number",e),ct(t).throw(f.invalidParameters),n=wt.of(this._iid).requestQueue,r=new fl({pollId:e}),[4,n.send(r)];case 1:return i.sent(),[2]}}))}))},c.prototype.closePoll=function(e){return i(this,void 0,void 0,(function(){var t,n,r,i;return s(this,(function(s){switch(s.label){case 0:return t=g("number",e),ct(t).throw(f.invalidParameters),n=wt.of(this._iid).requestQueue,r=new _l({pollId:e}),[4,n.send(r)];case 1:return i=s.sent(),[2,i.as(vl).poll]}}))}))},c.prototype.addPollOption=function(e,t){return i(this,void 0,void 0,(function(){var n,r,i,a;return s(this,(function(s){switch(s.label){case 0:return n=g("number",e)&&g("string",t)&&""!==t.trim(),ct(n).throw(f.invalidParameters),r=wt.of(this._iid).requestQueue,i=new ml({channelUrl:this.url,channelType:this.channelType,pollId:e,optionText:t}),[4,r.send(i)];case 1:return a=s.sent(),[2,a.as(gl).poll]}}))}))},c.prototype.updatePollOption=function(e,t,n){return i(this,void 0,void 0,(function(){var r,i,a,o;return s(this,(function(s){switch(s.label){case 0:return r=g("number",e)&&g("number",t)&&g("string",n)&&""!==n.trim(),ct(r).throw(f.invalidParameters),i=wt.of(this._iid).requestQueue,a=new yl({pollId:e,pollOptionId:t,optionText:n}),[4,i.send(a)];case 1:return o=s.sent(),[2,o.as(El).poll]}}))}))},c.prototype.deletePollOption=function(e,t){return i(this,void 0,void 0,(function(){var n,r,i;return s(this,(function(s){switch(s.label){case 0:return n=g("number",e)&&g("number",t),ct(n).throw(f.invalidParameters),r=wt.of(this._iid).requestQueue,i=new bl({pollId:e,pollOptionId:t}),[4,r.send(i)];case 1:return s.sent(),[2]}}))}))},c.prototype.votePoll=function(t,n){return i(this,void 0,void 0,(function(){var r,i,a,o,u,c,l;return s(this,(function(s){switch(s.label){case 0:return r=g("number",t)&&b("number",n),ct(r).throw(f.invalidParameters),i=wt.of(this._iid),a=i.requestQueue,o=i.dispatcher,u=new Sl({reqId:this._generateRequestId(),channelUrl:this.url,channelType:this.channelType,pollId:t,pollOptionIds:n}),[4,a.send(u)];case 1:return c=s.sent(),l=c.as(oc).event,o.dispatch(new In({event:l,source:e.MessageEventSource.EVENT_POLL_VOTED})),[2,l]}}))}))},c.prototype.getPollChangeLogsSinceTimestamp=function(e){return i(this,void 0,void 0,(function(){return s(this,(function(t){switch(t.label){case 0:return ct(g("number",e)).throw(f.invalidParameters),[4,lr.of(this._iid).getPollChangeLogs(this.url,this.channelType,e)];case 1:return[2,t.sent()]}}))}))},c.prototype.getPollChangeLogsSinceToken=function(e){return i(this,void 0,void 0,(function(){return s(this,(function(t){switch(t.label){case 0:return ct(g("string",e,!0)),[4,lr.of(this._iid).getPollChangeLogs(this.url,this.channelType,e)];case 1:return[2,t.sent()]}}))}))},c.prototype.createPollListQuery=function(e){return void 0===e&&(e=10),new _r(this._iid,{channelUrl:this.url,channelType:this.channelType,limit:e})},c.prototype.createPollVoterListQuery=function(e,t,n){return void 0===n&&(n=20),new gr(this._iid,{channelUrl:this.url,channelType:this.channelType,pollId:e,pollOptionId:t,limit:n})},c.prototype._uploadFileAndUpdateParams=function(e){return i(this,void 0,void 0,(function(){var t,n,r,i,a,o,u,c,l,h,d;return s(this,(function(s){switch(s.label){case 0:return T(e.file)?(t=wt.of(this._iid).requestQueue,n=new Ut({file:e.file,channelUrl:this.url,thumbnailSizes:e.thumbnailSizes,requestId:this._generateRequestId()}),[4,t.send(n)]):[3,2];case 1:r=s.sent(),i=r.as(Ot),a=i.url,o=i.fileSize,u=void 0===o?e.fileSize:o,c=i.thumbnailSizes,l=void 0===c?e.thumbnailSizes:c,h=i.requireAuth,d=void 0!==h&&h,e.fileUrl=a,e.fileSize=u,e.thumbnailSizes=l,e.requireAuth=d,s.label=2;case 2:return[2]}}))}))},c}(Uo),Ml={},Al=function(){function t(t){var n=t._iid,r=this;this._sync=null,this._metadata=null,this._iid=n;var a,c=wt.of(this._iid),l=c.sdkState,h=c.logger;this._metadataKey=(a=l.userId,"sendbird:".concat(a,"@groupchannel/sync.meta"));var d=function(e){return"sendbird:".concat(e,"@groupchannel/sync")}(l.userId);this._sync=new vc(d,(function(){return i(r,void 0,void 0,(function(){var t,n,r,i,a,c;return s(this,(function(s){switch(s.label){case 0:return t={hasNext:!0,nextToken:""},[4,this.loadMetadata()];case 1:if(s.sent(),h.debug("channel background sync from",this._metadata.token),this._metadata.completed)return[3,9];s.label=2;case 2:return s.trys.push([2,5,,8]),[4,hc.of(this._iid).getMyGroupChannels(this._metadata.token,{includeEmpty:!0,order:e.GroupChannelListOrder.CHRONOLOGICAL},100,e.GroupChannelEventSource.SYNC_CHANNEL_BACKGROUND)];case 3:return n=s.sent(),r=n.channels,i=n.token,t.hasNext=r.length>=100&&!!i,t.nextToken=i,this._metadata.token=i,(c=this._metadata.range).extends.apply(c,u([],o(r.map((function(e){return e.createdAt}))),!1)),this._metadata.completed=!t.hasNext,h.debug("channel background sync progress",t),[4,this.saveMetadata()];case 4:return s.sent(),[3,8];case 5:return a=s.sent(),h.debug("channel background sync error",a),a instanceof f&&a.isInvalidTokenError?[4,this.clearMetaData()]:[3,7];case 6:s.sent(),s.label=7;case 7:throw a;case 8:return[3,10];case 9:t.hasNext=!1,t.nextToken="",s.label=10;case 10:return[2,t]}}))}))}))}return t.of=function(e){if(!Ml[e]){var n=Ml[e]=new t({_iid:e});wt.of(e).dispatcher.on((function(e){if(e instanceof he)if(e.stateType===X.CONNECTED)n.resume();else n.pause()}))}return Ml[e]},Object.defineProperty(t.prototype,"range",{get:function(){var e;return null===(e=this._metadata)||void 0===e?void 0:e.range},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"completed",{get:function(){var e;return!!(null===(e=this._metadata)||void 0===e?void 0:e.completed)},enumerable:!1,configurable:!0}),t.prototype.loadMetadata=function(){return i(this,void 0,void 0,(function(){var e;return s(this,(function(t){switch(t.label){case 0:return this._metadata?[3,2]:[4,wt.of(this._iid).cacheContext.preference.get(this._metadataKey)];case 1:e=t.sent(),this._metadata={token:e?e.token:"",range:new cc(e?e.range:{top:Number.MAX_SAFE_INTEGER,bottom:0}),completed:!!e&&e.completed},t.label=2;case 2:return[2]}}))}))},t.prototype.saveMetadata=function(){return i(this,void 0,void 0,(function(){return s(this,(function(e){switch(e.label){case 0:return this._metadata?[4,wt.of(this._iid).cacheContext.preference.set(this._metadataKey,this._metadata)]:[3,2];case 1:e.sent(),e.label=2;case 2:return[2]}}))}))},t.prototype.clearMetaData=function(){return i(this,void 0,void 0,(function(){return s(this,(function(e){switch(e.label){case 0:return[4,wt.of(this._iid).cacheContext.preference.remove(this._metadataKey)];case 1:return e.sent(),this._metadata=null,[2]}}))}))},t.prototype.resume=function(){var e,t;wt.of(this._iid).logger.debug("channel background sync resume()"),this._sync.start(null!==(t=null===(e=this._metadata)||void 0===e?void 0:e.token)&&void 0!==t?t:"")},t.prototype.pause=function(){wt.of(this._iid).logger.debug("channel background sync stop()"),this._sync.stop()},t}(),Ul={},Ol=function(){function t(t){var n=t._iid,r=this;this._sync=null,this._metadataKey=null,this._metadata=null,this._iid=n;var a,o=wt.of(this._iid),u=o.logger,c=o.sdkState;this._metadataKey=(a=c.userId,"sendbird:".concat(a,"@groupchannel/changelogs.meta"));var l=function(e){return"sendbird:".concat(e,"@groupchannel/changelogs")}(c.userId);this._sync=new vc(l,(function(){return i(r,void 0,void 0,(function(){var t,n,r,i,a;return s(this,(function(s){switch(s.label){case 0:return t={hasNext:!0,nextToken:0},[4,this.loadMetadata()];case 1:s.sent(),u.debug("channel changelog sync from",this._metadata.token),s.label=2;case 2:return s.trys.push([2,5,,8]),[4,hc.of(this._iid).getMyGroupChannelChangeLogs(this._metadata.token,{},e.GroupChannelEventSource.SYNC_CHANNEL_CHANGELOGS)];case 3:return n=s.sent(),r=n.hasMore,i=n.token,t.hasNext=r,t.nextToken=i,this._metadata.token=i,u.debug("channel changelog sync progress",t),[4,this.saveMetadata()];case 4:return s.sent(),[3,8];case 5:return a=s.sent(),u.debug("channel changelog sync error",a),a instanceof f&&a.isInvalidTokenError?[4,this.clearMetadata()]:[3,7];case 6:s.sent(),s.label=7;case 7:throw a;case 8:return[2,t]}}))}))}))}return t.of=function(e){if(!Ul[e]){var n=Ul[e]=new t({_iid:e});wt.of(e).dispatcher.on((function(e){if(e instanceof he)if(e.stateType===X.CONNECTED)n.resume();else n.pause()}))}return Ul[e]},t.prototype.loadMetadata=function(){return i(this,void 0,void 0,(function(){var e,t,n,r;return s(this,(function(i){switch(i.label){case 0:return this._metadata?[3,2]:(e=wt.of(this._iid),t=e.cacheContext,n=e.firstConnectedAt,[4,t.preference.get(this._metadataKey)]);case 1:r=i.sent(),this._metadata={token:r?r.token:n/1e3},i.label=2;case 2:return[2]}}))}))},t.prototype.saveMetadata=function(){return i(this,void 0,void 0,(function(){return s(this,(function(e){switch(e.label){case 0:return this._metadata?[4,wt.of(this._iid).cacheContext.preference.set(this._metadataKey,this._metadata)]:[3,2];case 1:e.sent(),e.label=2;case 2:return[2]}}))}))},t.prototype.clearMetadata=function(){return i(this,void 0,void 0,(function(){return s(this,(function(e){switch(e.label){case 0:return[4,wt.of(this._iid).cacheContext.preference.remove(this._metadataKey)];case 1:return e.sent(),this._metadata=null,[2]}}))}))},t.prototype.resume=function(){this._sync.start(0)},t.prototype.pause=function(){this._sync.stop()},t}(),Rl=function(){function t(t,n){var r=n.filter,i=n.order,s=n.limit,a=this;this.channels=[],this._iid=t,this._key="gcc-".concat(U()),this.filter=null!=r?r:new Qo,this.order=null!=i?i:e.GroupChannelListOrder.LATEST_LAST_MESSAGE,this._hasMore=!0,this._token="",this._limit=null!=s?s:100;var o=wt.of(this._iid),u=o.sdkState;o.cacheContext.localCacheEnabled&&Al.of(t).resume(),Ol.of(t).resume(),hc.of(this._iid).subscribeGroupChannelEvent(this._key,{onUpdate:function(e,t){var n=e.filter((function(e){return a.filter.match(e,u.userId)})),r=e.filter((function(e){return!a.filter.match(e,u.userId)})).map((function(e){return e.url}));n.length>0&&a._addChannelsToView(n,t),r.length>0&&a._removeChannelsFromView(r,t)},onRemove:function(e,t){a._removeChannelsFromView(e,t)}})}return Object.defineProperty(t.prototype,"hasMore",{get:function(){return this._hasMore},enumerable:!1,configurable:!0}),t.prototype.setGroupChannelCollectionHandler=function(e){this._handler=e},t.prototype._addChannelsToView=function(t,n,r){var o,u,c=this;void 0===r&&(r=!1);var l=[],h=[];try{for(var d=a(t),p=d.next();!p.done;p=d.next()){var f=p.value,_=wc(this.channels,f,this.order),v=_.place;if(_.contains)switch(h.push(f),n){case e.GroupChannelEventSource.EVENT_CHANNEL_UPDATED:case e.GroupChannelEventSource.EVENT_MESSAGE_RECEIVED:this.channels.splice(v,1);var m=wc(this.channels,f,this.order).place;this.channels.splice(m,0,f);break;default:this.channels[v]=f}else if(v===this.channels.length){var g=Al.of(this._iid);(r||g.completed)&&(l.push(f),this.channels.push(f))}else l.push(f),this.channels.splice(v,0,f)}}catch(e){o={error:e}}finally{try{p&&!p.done&&(u=d.return)&&u.call(d)}finally{if(o)throw o.error}}iu(n)&&De((function(){return i(c,void 0,void 0,(function(){var e;return s(this,(function(t){return e=new mc(n),l.length>0&&this._handler.onChannelsAdded(e,l),h.length>0&&this._handler.onChannelsUpdated(e,h),[2]}))}))}))},t.prototype._removeChannelsFromView=function(e,t){var n,r,o=this,u=[],c=function(e){var t=l.channels.findIndex((function(t){return t.url===e}));t>=0&&(u.push(l.channels[t].url),l.channels.splice(t,1))},l=this;try{for(var h=a(e),d=h.next();!d.done;d=h.next()){c(d.value)}}catch(e){n={error:e}}finally{try{d&&!d.done&&(r=h.return)&&r.call(h)}finally{if(n)throw n.error}}return iu(t)&&u.length>0&&De((function(){return i(o,void 0,void 0,(function(){var e;return s(this,(function(n){return e=new mc(t),this._handler.onChannelsDeleted(e,u),[2]}))}))})),u},t.prototype._getLocalChannels=function(){return i(this,void 0,void 0,(function(){return s(this,(function(e){switch(e.label){case 0:return[4,hc.of(this._iid).getChannelsFromCache(this._token,this.filter,this.order)];case 1:return[2,e.sent()]}}))}))},t.prototype._getRemoteChannels=function(){return i(this,void 0,void 0,(function(){var e,t,n;return s(this,(function(i){switch(i.label){case 0:return[4,hc.of(this._iid).getMyGroupChannels(this._token,r(r({},this.filter),{order:this.order}),this._limit)];case 1:return e=i.sent(),t=e.channels,n=e.token,this._token=n,this._hasMore=!!n,[2,t]}}))}))},t.prototype.loadMore=function(){return i(this,void 0,void 0,(function(){var t,n=this;return s(this,(function(r){switch(r.label){case 0:return this._hasMore?(t=[],[4,Pe((function(){return i(n,void 0,void 0,(function(){return s(this,(function(e){switch(e.label){case 0:return[4,this._getLocalChannels()];case 1:return t=e.sent(),[2]}}))}))}))]):[3,3];case 1:return r.sent(),[4,Pe((function(){return i(n,void 0,void 0,(function(){return s(this,(function(e){switch(e.label){case 0:return[4,this._getRemoteChannels()];case 1:return t=e.sent(),[2]}}))}))}))];case 2:return r.sent(),this._addChannelsToView(t,e.GroupChannelEventSource.REQUEST_CHANNEL,!0),[2,t];case 3:return[2,[]]}}))}))},t.prototype.dispose=function(){wt.of(this._iid).cacheContext.localCacheEnabled&&Al.of(this._iid).pause(),Ol.of(this._iid).pause(),hc.of(this._iid).unsubscribeGroupChannelEvent(this._key)},t}(),Ll=function(t){function r(n){var r=this,i=n.token,s=n.limit,a=n.order,o=n.includeEmpty,u=n.membershipFilter,c=n.channelNameContainsFilter,l=n.channelUrlsFilter,h=n.customTypesFilter,p=n.customTypeStartsWithFilter,f=n.superChannelFilter,_=n.metadataOrderKeyFilter,v=n.metadataKey,m=n.metadataValues,g=n.metadataValueStartsWith,y=n.includeFrozen,E=n.includeMetaData;return(r=t.call(this)||this).method=d.GET,r.path=ve,r.params=D({token:i,limit:s,order:a,show_member:!0,show_read_receipt:!0,show_delivery_receipt:!0,show_empty:o,public_mode:e.PublicChannelFilter.PUBLIC,public_membership_mode:u,name_contains:c,channel_urls:l,custom_types:h,custom_type_startswith:p,super_mode:f,metadata_order_key:_,metadata_key:v,metadata_values:m,metadata_value_startswith:g,show_frozen:y,show_metadata:E}),r}return n(r,t),r}(x),kl=function(e){function t(t,n){var r=e.call(this,t,n)||this;r.token=null,r.channels=[],r.ts=null;var i=n.next,s=n.channels,a=n.ts;return r.token=i,s&&s.length>0&&(r.channels=s.map((function(e){return e.ts=a,new wl(t,e)}))),r.ts="number"==typeof a?a:null,r}return n(t,e),t}(F);e.MembershipFilter=void 0,(Nl=e.MembershipFilter||(e.MembershipFilter={})).ALL="all",Nl.JOINED="joined";var Dl=function(t){function a(n,r){var i,s,a,o,u,c,l,h,d,p,f,_,v,m,g=this;return(g=t.call(this,n,r)||this).includeEmpty=!1,g.includeFrozen=!0,g.includeMetaData=!0,g.channelUrlsFilter=null,g.customTypesFilter=null,g.customTypeStartsWithFilter=null,g.channelNameContainsFilter=null,g.membershipFilter=e.MembershipFilter.ALL,g.superChannelFilter=e.SuperChannelFilter.ALL,g.metadataKey=null,g.metadataValues=null,g.metadataOrderKeyFilter=null,g.metadataValueStartsWith=null,g.order=e.PublicGroupChannelListOrder.CHRONOLOGICAL,g.includeEmpty=null!==(i=r.includeEmpty)&&void 0!==i&&i,g.includeFrozen=null===(s=r.includeFrozen)||void 0===s||s,g.includeMetaData=null===(a=r.includeMetaData)||void 0===a||a,g.channelUrlsFilter=null!==(o=r.channelUrlsFilter)&&void 0!==o?o:null,g.customTypesFilter=null!==(u=r.customTypesFilter)&&void 0!==u?u:null,g.customTypeStartsWithFilter=null!==(c=r.customTypeStartsWithFilter)&&void 0!==c?c:null,g.channelNameContainsFilter=null!==(l=r.channelNameContainsFilter)&&void 0!==l?l:null,g.membershipFilter=null!==(h=r.membershipFilter)&&void 0!==h?h:e.MembershipFilter.ALL,g.superChannelFilter=null!==(d=r.superChannelFilter)&&void 0!==d?d:e.SuperChannelFilter.ALL,g.metadataKey=null!==(p=r.metadataKey)&&void 0!==p?p:null,g.metadataValues=null!==(f=r.metadataValues)&&void 0!==f?f:null,g.metadataOrderKeyFilter=null!==(_=r.metadataOrderKeyFilter)&&void 0!==_?_:null,g.metadataValueStartsWith=null!==(v=r.metadataValueStartsWith)&&void 0!==v?v:null,g.order=null!==(m=r.order)&&void 0!==m?m:e.PublicGroupChannelListOrder.CHRONOLOGICAL,g}return n(a,t),a.prototype._validate=function(){return t.prototype._validate.call(this)&&g("boolean",this.includeEmpty)&&g("boolean",this.includeFrozen)&&g("boolean",this.includeMetaData)&&g("string",this.channelNameContainsFilter,!0)&&b("string",this.channelUrlsFilter,!0)&&b("string",this.customTypesFilter,!0)&&g("string",this.customTypeStartsWithFilter,!0)&&y(e.MembershipFilter,this.membershipFilter)&&y(e.SuperChannelFilter,this.superChannelFilter)&&y(e.PublicGroupChannelListOrder,this.order)&&g("string",this.metadataOrderKeyFilter,!0)&&g("string",this.metadataKey,!0)&&b("string",this.metadataValues,!0)&&g("string",this.metadataValueStartsWith,!0)},a.prototype.next=function(){return i(this,void 0,void 0,(function(){var t,n,i,a,o,u,c,l,h;return s(this,(function(s){switch(s.label){case 0:return this._validate()?this._isLoading?[3,3]:(t=[],this._hasNext?(this._isLoading=!0,n=wt.of(this._iid),i=n.requestQueue,a=n.dispatcher,o=new Ll(r(r({},this),{token:this._token})),[4,i.send(o)]):[3,2]):[3,5];case 1:return u=s.sent(),c=u.as(kl),l=c.channels,h=c.token,this._token=h,this._hasNext=!!h,a.dispatch(new su({channels:l,source:e.GroupChannelEventSource.REQUEST_CHANNEL})),this._isLoading=!1,[2,l];case 2:return[2,t];case 3:throw f.queryInProgress;case 4:return[3,6];case 5:throw f.invalidParameters;case 6:return[2]}}))}))},a}(Fn),Pl=function(){this.onUserMuted=J,this.onUserUnmuted=J,this.onUserBanned=J,this.onUserUnbanned=J,this.onChannelChanged=J,this.onChannelDeleted=J,this.onChannelFrozen=J,this.onChannelUnfrozen=J,this.onOperatorUpdated=J,this.onChannelMemberCountChanged=J,this.onMetaDataCreated=J,this.onMetaDataUpdated=J,this.onMetaDataDeleted=J,this.onMetaCounterCreated=J,this.onMetaCounterUpdated=J,this.onMetaCounterDeleted=J,this.onMessageReceived=J,this.onMessageUpdated=J,this.onMessageDeleted=J,this.onMentionReceived=J,this.onReactionUpdated=J,this.onThreadInfoUpdated=J},xl=function(e){function t(){var t=null!==e&&e.apply(this,arguments)||this;return t.onUserJoined=J,t.onUserLeft=J,t.onUserReceivedInvitation=J,t.onUserDeclinedInvitation=J,t.onChannelHidden=J,t.onUnreadMemberStatusUpdated=J,t.onUndeliveredMemberStatusUpdated=J,t.onTypingStatusUpdated=J,t.onPollUpdated=J,t.onPollVoted=J,t.onPollDeleted=J,t}return n(t,e),t}(Pl),Fl=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}(xl),ql=function(e){function t(t){var n=this,r=t.token,i=t.limit,s=t.order,a=t.reverse,o=t.channelUrl,u=t.messageTypeFilter,c=t.scheduledStatus;return(n=e.call(this)||this).method=d.GET,n.path="".concat(Se),n.params=D({limit:i,reverse:a,channel_url:o,order:s,status:c}),r&&(n.params.token=r),u&&(n.params.message_type=u),n}return n(t,e),t}(x),Gl=function(e){function t(t,n){var r=e.call(this,t,n)||this;r.token=null,r.scheduledMessages=[];var i=n.next,s=n.scheduled_messages;return r.token=i,r.scheduledMessages=s.map((function(e){return sn(t,e)})),r}return n(t,e),t}(F),Hl=function(t){function a(n,r){var i,s,a,o,u,c=this;return(c=t.call(this,n,r)||this).channelUrl=null,c.order=null,c.reverse=!1,c.scheduledStatus=null,c.messageTypeFilter=e.MessageTypeFilter.ALL,c.channelUrl=null!==(i=r.channelUrl)&&void 0!==i?i:null,c.order=null!==(s=r.order)&&void 0!==s?s:null,c.reverse=null!==(a=r.reverse)&&void 0!==a&&a,c.scheduledStatus=null!==(o=r.scheduledStatus)&&void 0!==o?o:null,c.messageTypeFilter=null!==(u=r.messageTypeFilter)&&void 0!==u?u:e.MessageTypeFilter.ALL,c}return n(a,t),a.prototype._validate=function(){return t.prototype._validate.call(this)&&g("string",this.channelUrl,!0)&&(y(e.ScheduledMessageListOrder,this.order)||null===this.order)&&g("boolean",this.reverse)&&(b(e.ScheduledStatus,this.scheduledStatus)||null===this.scheduledStatus)&&y(e.MessageTypeFilter,this.messageTypeFilter)},a.prototype.next=function(){return i(this,void 0,void 0,(function(){var e,t,n,i,a,o;return s(this,(function(s){switch(s.label){case 0:return this._validate()?this._isLoading?[3,3]:this._hasNext?(this._isLoading=!0,e=wt.of(this._iid).requestQueue,t=new ql(r(r({},this),{token:this._token})),[4,e.send(t)]):[3,2]:[3,5];case 1:return n=s.sent(),i=n.as(Gl),a=i.scheduledMessages,o=i.token,this._token=o,this._hasNext=!!o,this._isLoading=!1,[2,a];case 2:return[2,[]];case 3:throw f.queryInProgress;case 4:return[3,6];case 5:throw f.invalidParameters;case 6:return[2]}}))}))},a}(Fn),Vl=function(e){function t(){var t=null!==e&&e.apply(this,arguments)||this;return t.name="groupChannel",t}return n(t,e),t.prototype.init=function(t,n){var r=n.sdkState,i=n.dispatcher,s=n.sessionManager,a=n.requestQueue,o=n.logger,u=n.onlineDetector,c=n.cacheContext;e.prototype.init.call(this,t,{sdkState:r,dispatcher:i,sessionManager:s,requestQueue:a,logger:o,onlineDetector:u,cacheContext:c}),this._manager=new hc(t,{sdkState:r,cacheContext:c,dispatcher:i,sessionManager:s,requestQueue:a,logger:o})},t.prototype.createGroupChannelCollection=function(e){return void 0===e&&(e={}),new Rl(this._iid,e)},t.prototype.createMyGroupChannelListQuery=function(e){return void 0===e&&(e={}),new uc(this._iid,e)},t.prototype.createPublicGroupChannelListQuery=function(e){return void 0===e&&(e={}),new Dl(this._iid,e)},t.prototype.createScheduledMessageListQuery=function(e){return void 0===e&&(e={}),new Hl(this._iid,e)},t.prototype.addGroupChannelHandler=function(e,t){ct(g("string",e)&&t instanceof Fl).throw(f.invalidParameters),this._manager.addHandler(e,t)},t.prototype.removeGroupChannelHandler=function(e){ct(g("string",e)).throw(f.invalidParameters),this._manager.removeHandler(e)},t.prototype.removeAllGroupChannelHandlers=function(){this._manager.clearHandler()},t.prototype.buildGroupChannelFromSerializedData=function(e){return this._manager.buildGroupChannelFromSerializedData(e)},t.prototype.buildGroupChannelListQueryFromSerializedData=function(e){return this._manager.buildGroupChannelListQueryFromSerializedData(e)},t.prototype.buildMemberFromSerializedData=function(e){return this._manager.buildMemberFromSerializedData(e)},t.prototype.getChannel=function(e){return i(this,void 0,void 0,(function(){return s(this,(function(t){return ct(g("string",e)).throw(f.invalidParameters),[2,this._manager.getChannel(e)]}))}))},t.prototype.getChannelWithoutCache=function(e){return i(this,void 0,void 0,(function(){return s(this,(function(t){return ct(g("string",e)).throw(f.invalidParameters),[2,this._manager.getChannelWithoutCache(e)]}))}))},t.prototype.getMyGroupChannelChangeLogsByToken=function(e,t){return i(this,void 0,void 0,(function(){var n;return s(this,(function(i){switch(i.label){case 0:return n=r(r({},Jo),t),ct(g("string",e)&&Xo(n)).throw(f.invalidParameters),[4,this._manager.getMyGroupChannelChangeLogs(e,n)];case 1:return[2,i.sent()]}}))}))},t.prototype.getMyGroupChannelChangeLogsByTimestamp=function(e,t){return i(this,void 0,void 0,(function(){var n;return s(this,(function(i){switch(i.label){case 0:return n=r(r({},Jo),t),ct(g("number",e)&&Xo(n)).throw(f.invalidParameters),[4,this._manager.getMyGroupChannelChangeLogs(e,n)];case 1:return[2,i.sent()]}}))}))},t.prototype.getGroupChannelCount=function(e){return i(this,void 0,void 0,(function(){var t;return s(this,(function(n){return t=r(r({},Zo),e),ct($o(t)).throw(f.invalidParameters),[2,this._manager.getGroupChannelCount(t)]}))}))},t.prototype.getUnreadItemCount=function(e){return void 0===e&&(e={}),i(this,void 0,void 0,(function(){return s(this,(function(t){switch(t.label){case 0:return[4,this._manager.getUnreadItemCount(e)];case 1:return[2,t.sent()]}}))}))},t.prototype.getTotalUnreadChannelCount=function(){return i(this,void 0,void 0,(function(){return s(this,(function(e){switch(e.label){case 0:return[4,this._manager.getTotalUnreadChannelCount()];case 1:return[2,e.sent()]}}))}))},t.prototype.getTotalUnreadMessageCount=function(e){return void 0===e&&(e={}),i(this,void 0,void 0,(function(){return s(this,(function(t){switch(t.label){case 0:return[4,this._manager.getTotalUnreadMessageCount(e)];case 1:return[2,t.sent()]}}))}))},t.prototype.getTotalScheduledMessageCount=function(e){return void 0===e&&(e={}),i(this,void 0,void 0,(function(){return s(this,(function(t){switch(t.label){case 0:return[4,this._manager.getTotalScheduledMessageCount(e)];case 1:return[2,t.sent()]}}))}))},t.prototype.getSubscribedTotalUnreadMessageCount=function(){return this._manager.getSubscribedTotalUnreadMessageCount()},t.prototype.getSubscribedCustomTypeTotalUnreadMessageCount=function(){return this._manager.getSubscribedCustomTypeTotalUnreadMessageCount()},t.prototype.getSubscribedCustomTypeUnreadMessageCount=function(e){return this._manager.getSubscribedCustomTypeUnreadMessageCount(e)},t.prototype.createChannel=function(e){return void 0===e&&(e={}),i(this,void 0,void 0,(function(){var t;return s(this,(function(n){return t=r(r({},Wo),e),ct(Yo(t)).throw(f.invalidParameters),[2,this._manager.createChannel(t)]}))}))},t.prototype.createDistinctChannelIfNotExist=function(e){return void 0===e&&(e={}),i(this,void 0,void 0,(function(){var t;return s(this,(function(n){return t=r(r({},Wo),e),ct(Yo(t)).throw(f.invalidParameters),t&&(t.isDistinct=!0),[2,this.createChannel(t)]}))}))},t.prototype.createChannelWithUserIds=function(e,t,n,a,o,u){return void 0===t&&(t=!1),void 0===n&&(n=null),void 0===a&&(a=null),void 0===o&&(o=""),void 0===u&&(u=""),i(this,void 0,void 0,(function(){var i;return s(this,(function(s){return i=r(r({},Wo),{invitedUserIds:e,isDistinct:t,name:n,data:o,customType:u}),"string"==typeof a?i.coverUrl=a:i.coverImage=a,[2,this.createChannel(i)]}))}))},t.prototype.markAsReadAll=function(){return i(this,void 0,void 0,(function(){return s(this,(function(e){return this._manager.markAsReadAll(),[2]}))}))},t.prototype.markAsReadWithChannelUrls=function(e){return i(this,void 0,void 0,(function(){return s(this,(function(t){return ct(b("string",e)).throw(f.invalidParameters),this._manager.markAsReadWithChannelUrls(e),[2]}))}))},t.prototype.markAsDelivered=function(e){return i(this,void 0,void 0,(function(){return s(this,(function(t){switch(t.label){case 0:return ct(g("string",e)).throw(f.invalidParameters),[4,this.getChannel(e)];case 1:return[4,t.sent().markAsDelivered()];case 2:return t.sent(),[2]}}))}))},t}(At),Kl=function(e){function t(){var t=null!==e&&e.apply(this,arguments)||this;return t._channels=new Map,t._enteredChannelUrls=[],t}return n(t,e),Object.defineProperty(t.prototype,"enteredChannels",{get:function(){var e=this;return this._enteredChannelUrls.map((function(t){return e._channels.get(t)})).filter((function(e){return null!==e}))},enumerable:!1,configurable:!0}),t.prototype.isEnteredChannel=function(e){return this._enteredChannelUrls.includes(e)},t.prototype.enter=function(e){this._enteredChannelUrls.indexOf(e)<0&&this._enteredChannelUrls.push(e)},t.prototype.exit=function(e){var t=this._enteredChannelUrls.indexOf(e);t>=0&&this._enteredChannelUrls.splice(t,1)},t.prototype.exitAll=function(){this._enteredChannelUrls=[]},t.prototype.get=function(e){var t;return i(this,void 0,void 0,(function(){return s(this,(function(n){return[2,null!==(t=this._channels.get(e))&&void 0!==t?t:null]}))}))},t.prototype.upsert=function(e){return i(this,void 0,void 0,(function(){var t=this;return s(this,(function(n){return e.forEach((function(e){if(t._channels.has(e.url)){var n=t._channels.get(e.url);Object.assign(n,e)}else t._channels.set(e.url,e)})),[2]}))}))},t.prototype.remove=function(e){return i(this,void 0,void 0,(function(){return s(this,(function(t){return this._channels.delete(e),this.exit(e),[2]}))}))},t.prototype.clear=function(){return i(this,void 0,void 0,(function(){return s(this,(function(e){return this._channels.clear(),this._enteredChannelUrls=[],[2]}))}))},t}(We),Ql={channelUrl:null,name:null,coverUrlOrImage:null,data:null,customType:null,operatorUserIds:null},Bl=function(e){function t(t){var n=t.channelUrl,r=t.isInternalCall,i=e.call(this)||this;return i.method=d.GET,i.path="".concat(r?ye:ge,"/").concat(encodeURIComponent(n)),i}return n(t,e),t}(x),jl=function(e){function t(t,n){var r=e.call(this,t,n)||this;return r.channel=null,r.channel=new oh(t,n),r}return n(t,e),t}(F),zl=function(e){function t(t){var n=this,r=t.channelUrl,i=t.coverUrlOrImage,s=t.name,a=t.data,o=t.customType,u=t.operatorUserIds;return(n=e.call(this)||this).method=d.POST,n.path=ge,n.params=D({channel_url:r,cover_url:g("string",i)?i:null,cover_file:T(i)?i:null,name:s,data:a,custom_type:o,operators:u}),n}return n(t,e),t}(x);!function(e){function t(t,n){var r=e.call(this,t,n)||this;return r.channel=new oh(t,n),r}n(t,e)}(F);var Wl=function(e){function t(t){var n=t.channelUrl;return e.call(this,{code:"ENTR",payload:{channel_url:n},ackRequired:!0})||this}return n(t,e),t}(z),Yl=function(e){function t(t,n,r){var i,s,a=this;return a=e.call(this,t,"ENTR",r)||this,r.data&&(a.participantCount=null!==(i=r.data.participant_count)&&void 0!==i?i:0,a.user=new ht(t,r.data),a.ts=null!==(s=r.data.edge_ts)&&void 0!==s?s:0),a}return n(t,e),t}(j),Jl=function(e){function t(t){var n=t.channelUrl;return e.call(this,{code:"EXIT",payload:{channel_url:n},ackRequired:!0})||this}return n(t,e),t}(z),Xl=function(e){function t(t,n,r){var i,s,a=this;return a=e.call(this,t,"EXIT",r)||this,r.data&&(a.participantCount=null!==(i=r.data.participant_count)&&void 0!==i?i:0,a.user=new ht(t,r.data),a.ts=null!==(s=r.data.edge_ts)&&void 0!==s?s:0),a}return n(t,e),t}(j),Zl={},$l=function(){function t(e,t){var n=t.sdkState,r=t.dispatcher,i=t.requestQueue,s=this;this._sdkState=n,this._requestQueue=i,this._dispatcher=r,this._openChannelCache=new Kl(e),this._openChannelHandlers=new Map,this._dispatcher.on((function(e){var t,n;if(e instanceof j)s._handleEvent(e);else if(e instanceof he&&e.stateType===X.CONNECTED){var r=s._openChannelCache.enteredChannels;try{for(var i=a(r),o=i.next();!o.done;o=i.next()){o.value.enter()}}catch(e){t={error:e}}finally{try{o&&!o.done&&(n=i.return)&&n.call(i)}finally{if(t)throw t.error}}}})),Zl[e]=this}return t.of=function(e){return Zl[e]},t.prototype.buildOpenChannelFromSerializedData=function(e){var t=ut(e);return new oh(t._iid,oh.payloadify(t))},t.prototype.getChannelFromCache=function(e){return i(this,void 0,void 0,(function(){return s(this,(function(t){switch(t.label){case 0:return[4,this._openChannelCache.get(e)];case 1:return[2,t.sent()]}}))}))},t.prototype.upsertChannelsToCache=function(e){return i(this,void 0,void 0,(function(){return s(this,(function(t){switch(t.label){case 0:return[4,this._openChannelCache.upsert(e)];case 1:return t.sent(),[2]}}))}))},t.prototype.removeChannelsFromCache=function(e){return i(this,void 0,void 0,(function(){var t,n,r,i,o,u;return s(this,(function(s){switch(s.label){case 0:s.trys.push([0,5,6,7]),t=a(e),n=t.next(),s.label=1;case 1:return n.done?[3,4]:(r=n.value,[4,this._openChannelCache.remove(r)]);case 2:s.sent(),s.label=3;case 3:return n=t.next(),[3,1];case 4:return[3,7];case 5:return i=s.sent(),o={error:i},[3,7];case 6:try{n&&!n.done&&(u=t.return)&&u.call(t)}finally{if(o)throw o.error}return[7];case 7:return[2]}}))}))},t.prototype.setEnteredToCache=function(e){this._openChannelCache.enter(e.url)},t.prototype.setExitedToCache=function(e){this._openChannelCache.exit(e.url)},t.prototype._handleEvent=function(t){return i(this,void 0,void 0,(function(){var n,r,o,u,c,l,h,d,f,_,v,m,g,y,E,b,C,T,I,S,N,w,M,A,U,O,R,L,k,D,P,x,F,q,G,H,V,K,Q,B,j,z,W,Y,J,X,Z,$,ee,te,ne,re,ie,se,ae,oe,ue,ce,le,he=this;return s(this,(function(de){switch(de.label){case 0:switch(de.trys.push([0,51,,52]),t.code){case"MESG":case"FILE":case"ADMM":case"BRDM":return[3,1];case"MEDI":case"FEDI":case"AEDI":return[3,4];case"DELM":return[3,7];case"MRCT":return[3,10];case"MTHD":return[3,13];case"MCNT":return[3,16];case"SYEV":return[3,27]}return[3,50];case 1:return u=null,"MESG"===t.code?u=t.as(ho):"FILE"===t.code?u=t.as(cn):"ADMM"!==t.code&&"BRDM"!=t.code||(u=t.as(nc)),u?(n=u.message,r=u.isMentioned,n.channelType!==e.ChannelType.OPEN?[3,3]:[4,this.getChannel(n.channelUrl,!0)]):[3,3];case 2:o=de.sent(),De((function(){return i(he,void 0,void 0,(function(){var e,t,i,u,c;return s(this,(function(s){try{for(e=a(this._openChannelHandlers.values()),t=e.next();!t.done;t=e.next())i=t.value,this._openChannelCache.isEnteredChannel(o.url)&&i.onMessageReceived(o,n),r&&i.onMentionReceived(o,n)}catch(e){u={error:e}}finally{try{t&&!t.done&&(c=e.return)&&c.call(e)}finally{if(u)throw u.error}}return[2]}))}))})),de.label=3;case 3:return[3,50];case 4:return u=null,"MEDI"===t.code?u=t.as(fo):"FEDI"===t.code?u=t.as(vo):"AEDI"===t.code&&(u=t.as(rc)),u?(c=u.message).channelType!==e.ChannelType.OPEN?[3,6]:[4,this.getChannel(c.channelUrl,!0)]:[3,6];case 5:l=de.sent(),De((function(){return i(he,void 0,void 0,(function(){var e,t,n,r,i;return s(this,(function(s){try{for(e=a(this._openChannelHandlers.values()),t=e.next();!t.done;t=e.next())n=t.value,this._openChannelCache.isEnteredChannel(l.url)&&n.onMessageUpdated(l,c)}catch(e){r={error:e}}finally{try{t&&!t.done&&(i=e.return)&&i.call(e)}finally{if(r)throw r.error}}return[2]}))}))})),de.label=6;case 6:return[3,50];case 7:return h=t.as(yo),N=h.channelUrl,v=h.channelType,d=h.messageId,v!==e.ChannelType.OPEN?[3,9]:[4,this.getChannel(N,!0)];case 8:f=de.sent(),De((function(){return i(he,void 0,void 0,(function(){var e,t,n,r,i;return s(this,(function(s){try{for(e=a(this._openChannelHandlers.values()),t=e.next();!t.done;t=e.next())n=t.value,this._openChannelCache.isEnteredChannel(f.url)&&n.onMessageDeleted(f,d)}catch(e){r={error:e}}finally{try{t&&!t.done&&(i=e.return)&&i.call(e)}finally{if(r)throw r.error}}return[2]}))}))})),de.label=9;case 9:return[3,50];case 10:return _=t.as(ic),N=_.channelUrl,v=_.channelType,m=_.event,v!==e.ChannelType.OPEN?[3,12]:[4,this.getChannel(N,!0)];case 11:g=de.sent(),De((function(){return i(he,void 0,void 0,(function(){var e,t,n,r;return s(this,(function(i){try{for(e=a(this._openChannelHandlers.values()),t=e.next();!t.done;t=e.next())t.value.onReactionUpdated(g,m)}catch(e){n={error:e}}finally{try{t&&!t.done&&(r=e.return)&&r.call(e)}finally{if(n)throw n.error}}return[2]}))}))})),de.label=12;case 12:return[3,50];case 13:return(y=t.as(sc).event).channelType!==e.ChannelType.OPEN?[3,15]:[4,this.getChannel(y.channelUrl,!0)];case 14:E=de.sent(),De((function(){return i(he,void 0,void 0,(function(){var e,t,n,r;return s(this,(function(i){try{for(e=a(this._openChannelHandlers.values()),t=e.next();!t.done;t=e.next())t.value.onThreadInfoUpdated(E,y)}catch(e){n={error:e}}finally{try{t&&!t.done&&(r=e.return)&&r.call(e)}finally{if(n)throw n.error}}return[2]}))}))})),de.label=15;case 15:return[3,50];case 16:b=t.as(ec).openChannelMemberCounts,C=[],de.label=17;case 17:de.trys.push([17,22,23,24]),T=a(b),I=T.next(),de.label=18;case 18:return I.done?[3,21]:(S=I.value,N=S.channelUrl,x=S.participantCount,w=S.updatedAt,[4,this.getChannelFromCache(N)]);case 19:(M=de.sent())&&M._updateParticipantCount(x,w)&&C.push(M),de.label=20;case 20:return I=T.next(),[3,18];case 21:return[3,24];case 22:return A=de.sent(),ce={error:A},[3,24];case 23:try{I&&!I.done&&(le=T.return)&&le.call(T)}finally{if(ce)throw ce.error}return[7];case 24:return C.length>0?[4,this.upsertChannelsToCache(C)]:[3,26];case 25:de.sent(),De((function(){return i(he,void 0,void 0,(function(){var e,t,n,r;return s(this,(function(i){try{for(e=a(this._openChannelHandlers.values()),t=e.next();!t.done;t=e.next())t.value.onChannelMemberCountChanged(C)}catch(e){n={error:e}}finally{try{t&&!t.done&&(r=e.return)&&r.call(e)}finally{if(n)throw n.error}}return[2]}))}))})),de.label=26;case 26:return[3,50];case 27:if(!(U=t.as(Au).event).isOpenChannelEvent)return[3,49];switch(U.category){case Ko.CHANNEL_ENTER:return[3,28];case Ko.CHANNEL_EXIT:return[3,30];case Ko.CHANNEL_OPERATOR_UPDATE:return[3,32];case Ko.USER_CHANNEL_MUTE:case Ko.USER_CHANNEL_UNMUTE:return[3,34];case Ko.USER_CHANNEL_BAN:case Ko.USER_CHANNEL_UNBAN:return[3,36];case Ko.CHANNEL_FREEZE:case Ko.CHANNEL_UNFREEZE:return[3,38];case Ko.CHANNEL_DELETED:return[3,40];case Ko.CHANNEL_PROP_CHANGED:return[3,43];case Ko.CHANNEL_META_DATA_CHANGED:return[3,45];case Ko.CHANNEL_META_COUNTERS_CHANGED:return[3,47]}return[3,49];case 28:return[4,this.getChannel(U.channelUrl,!0)];case 29:return O=de.sent(),R=t.as(Yl),x=R.participantCount,L=R.user,k=O._updateParticipantCount(x,U.ts),De((function(){return i(he,void 0,void 0,(function(){return s(this,(function(e){return this._openChannelHandlers.forEach((function(e){e.onUserEntered(O,L),k&&e.onChannelParticipantCountChanged(O)})),[2]}))}))})),[3,49];case 30:return[4,this.getChannel(U.channelUrl,!0)];case 31:return D=de.sent(),P=t.as(Xl),x=P.participantCount,F=P.user,q=D._updateParticipantCount(x,U.ts),De((function(){return i(he,void 0,void 0,(function(){return s(this,(function(e){return this._openChannelHandlers.forEach((function(e){e.onUserExited(D,F),q&&e.onChannelParticipantCountChanged(D)})),[2]}))}))})),[3,49];case 32:return[4,this.getChannel(U.channelUrl,!0)];case 33:return G=de.sent(),H=t.as($u).operators,G.operators=H,this.upsertChannelsToCache([G]),De((function(){return i(he,void 0,void 0,(function(){return s(this,(function(e){return this._openChannelHandlers.forEach((function(e){e.onOperatorUpdated(G,H)})),[2]}))}))})),[3,49];case 34:return[4,this.getChannel(U.channelUrl,!0)];case 35:return V=de.sent(),K=U.category===Ko.USER_CHANNEL_MUTE,Q=t.as(K?Za:eo).user,De((function(){return i(he,void 0,void 0,(function(){return s(this,(function(e){return this._openChannelHandlers.forEach((function(e){K?e.onUserMuted(V,Q):e.onUserUnmuted(V,Q)})),[2]}))}))})),[3,49];case 36:return[4,this.getChannel(U.channelUrl,!0)];case 37:return B=de.sent(),j=U.category===Ko.USER_CHANNEL_BAN,z=t.as(j?no:io).user,De((function(){return i(he,void 0,void 0,(function(){return s(this,(function(e){return this._openChannelHandlers.forEach((function(e){j?e.onUserBanned(B,z):e.onUserUnbanned(B,z)})),[2]}))}))})),[3,49];case 38:return[4,this.getChannel(U.channelUrl,!0)];case 39:return W=de.sent(),Y=t.as(ao).freeze,W.isFrozen=Y,this.upsertChannelsToCache([W]),De((function(){return i(he,void 0,void 0,(function(){return s(this,(function(e){return this._openChannelHandlers.forEach((function(e){Y?e.onChannelFrozen(W):e.onChannelUnfrozen(W)})),[2]}))}))})),[3,49];case 40:return[4,this.getChannel(U.channelUrl,!0)];case 41:return J=de.sent(),[4,this.removeChannelsFromCache([J.url])];case 42:return de.sent(),De((function(){return i(he,void 0,void 0,(function(){return s(this,(function(e){return this._openChannelHandlers.forEach((function(e){e.onChannelDeleted(J.url,J.channelType)})),[2]}))}))})),[3,49];case 43:return[4,this.getChannelWithoutCache(U.channelUrl,!0)];case 44:return X=de.sent(),De((function(){return i(he,void 0,void 0,(function(){return s(this,(function(e){return this._openChannelHandlers.forEach((function(e){e.onChannelChanged(X)})),[2]}))}))})),[3,49];case 45:return[4,this.getChannel(U.channelUrl,!0)];case 46:return Z=de.sent(),$=t.as(xa),ee=$.created,te=$.updated,ne=$.deleted,ee&&Z._upsertCachedMetaData(ee,U.ts),te&&Z._upsertCachedMetaData(te,U.ts),ne&&Z._removeFromCachedMetaData(ne,U.ts),De((function(){return i(he,void 0,void 0,(function(){return s(this,(function(e){return this._openChannelHandlers.forEach((function(e){ee&&e.onMetaDataCreated(Z,ee),te&&e.onMetaDataUpdated(Z,te),ne&&e.onMetaDataDeleted(Z,ne)})),[2]}))}))})),[3,49];case 47:return[4,this.getChannel(U.channelUrl,!0)];case 48:return re=de.sent(),ie=t.as(Wa),se=ie.created,ae=ie.updated,oe=ie.deleted,De((function(){return i(he,void 0,void 0,(function(){return s(this,(function(e){return this._openChannelHandlers.forEach((function(e){se&&e.onMetaCounterCreated(re,se),ae&&e.onMetaCounterUpdated(re,ae),oe&&e.onMetaCounterDeleted(re,oe)})),[2]}))}))})),[3,49];case 49:return[3,50];case 50:return[3,52];case 51:if(ue=de.sent(),p(ue))throw ue;return[3,52];case 52:return[2]}}))}))},t.prototype.addHandler=function(e,t){this._openChannelHandlers.set(e,t)},t.prototype.removeHandler=function(e){this._openChannelHandlers.delete(e)},t.prototype.clearHandler=function(){this._openChannelHandlers.clear()},t.prototype.getChannel=function(e,t){return i(this,void 0,void 0,(function(){var t;return s(this,(function(n){switch(n.label){case 0:ct(g("string",e)).throw(f.invalidParameters),n.label=1;case 1:return n.trys.push([1,3,,4]),[4,this.getChannelFromCache(e)];case 2:return(t=n.sent())?[2,t]:[3,4];case 3:return n.sent(),[3,4];case 4:return[4,this.getChannelWithoutCache(e)];case 5:return[2,n.sent()]}}))}))},t.prototype.getChannelWithoutCache=function(e,t){return void 0===t&&(t=!1),i(this,void 0,void 0,(function(){var n,r,i;return s(this,(function(s){switch(s.label){case 0:return ct(g("string",e)).throw(f.invalidParameters),n=new Bl({channelUrl:e,isInternalCall:t}),[4,this._requestQueue.send(n)];case 1:return r=s.sent(),i=r.as(jl).channel,[4,this.upsertChannelsToCache([i])];case 2:return s.sent(),[2,i]}}))}))},t.prototype.createChannel=function(e){return i(this,void 0,void 0,(function(){var t,n,i,a;return s(this,(function(s){switch(s.label){case 0:return t=r(r({},Ql),e),ct(function(e){return b("string",e.operatorUserIds,!0)&&(g("string",e.coverUrlOrImage)||T(e.coverUrlOrImage)||null===e.coverUrlOrImage)&&g("string",e.name,!0)&&g("string",e.data,!0)&&g("string",e.customType,!0)&&(g("string",e.channelUrl)&&/^\w+$/.test(e.channelUrl)||null===e.channelUrl)}(t)).throw(f.invalidParameters),n=new zl(t),[4,this._requestQueue.send(n)];case 1:return i=s.sent(),a=i.as(jl).channel,this.upsertChannelsToCache([a]),[2,a]}}))}))},t}(),eh={name:null,coverUrlOrImage:null,data:null,customType:null,operatorUserIds:null},th=function(e){function t(t){var n=this,r=t.channelUrl,i=t.token,s=t.limit;return(n=e.call(this)||this).method=d.GET,n.path="".concat(ge,"/").concat(encodeURIComponent(r),"/participants"),n.params={token:i,limit:s},n}return n(t,e),t}(x),nh=function(e){function t(t,n){var r=e.call(this,t,n)||this;r.token=null,r.participants=[];var i=n.next,s=n.participants;return r.token=i,r.participants=s.map((function(e){return new ht(t,e)})),r}return n(t,e),t}(F),rh=function(t){function a(n,r,i){return t.call(this,n,r,e.ChannelType.OPEN,i)||this}return n(a,t),a.prototype._validate=function(){return t.prototype._validate.call(this)},a.prototype.next=function(){return i(this,void 0,void 0,(function(){var e,t,n,i,a,o;return s(this,(function(s){switch(s.label){case 0:return this._validate()?this._isLoading?[3,3]:this._hasNext?(this._isLoading=!0,e=wt.of(this._iid).requestQueue,t=new th(r(r({},this),{token:this._token})),[4,e.send(t)]):[3,2]:[3,5];case 1:return n=s.sent(),i=n.as(nh),a=i.participants,o=i.token,this._token=o,this._hasNext=!!o,this._isLoading=!1,[2,a];case 2:return[2,[]];case 3:throw f.queryInProgress;case 4:return[3,6];case 5:throw f.invalidParameters;case 6:return[2]}}))}))},a}(Bn),ih=function(e){function t(t){var n=this,r=t.channelUrl,i=t.coverUrlOrImage,s=t.name,a=t.data,o=t.customType,u=t.operatorUserIds;return(n=e.call(this)||this).method=d.PUT,n.path="".concat(ge,"/").concat(encodeURIComponent(r)),n.params=D({cover_url:g("string",i)?i:null,cover_file:T(i)?i:null,name:s,data:a,custom_type:o,operators:u}),n}return n(t,e),t}(x),sh=function(e){function t(t,n){var r=e.call(this,t,n)||this;return r.channel=new oh(t,n),r}return n(t,e),t}(F),ah=function(e){function t(t){var n=this,r=t.channelUrl;return(n=e.call(this)||this).method=d.DELETE,n.path="".concat(ge,"/").concat(encodeURIComponent(r)),n}return n(t,e),t}(x);!function(e){function t(t,n){return e.call(this,t,n)||this}n(t,e)}(F);var oh=function(t){function a(n,r){var i,s=this;return(s=t.call(this,n,r)||this)._lastParticipantCountUpdated=0,s.participantCount=0,s.operators=[],s.channelType=e.ChannelType.OPEN,s.participantCount=null!==(i=r.participant_count)&&void 0!==i?i:0,s.operators=Array.isArray(r.operators)?r.operators.map((function(e){return new ht(n,e)})):[],s}return n(a,t),a.payloadify=function(e){return e?D(r(r({},Uo.payloadify(e)),{participant_count:e.participantCount,operators:e.operators.map((function(e){return ht.payloadify(e)}))})):null},a.prototype.serialize=function(){return ot(this)},a.prototype.isOperator=function(e){return e instanceof ht?this.isOperator(e.userId):this.operators.some((function(t){return t.userId===e}))},a.prototype._updateParticipantCount=function(e,t){return t>this._lastParticipantCountUpdated&&(this.participantCount=e,this._lastParticipantCountUpdated=t,!0)},a.prototype.createParticipantListQuery=function(e){return new rh(this._iid,this.url,e)},a.prototype.refresh=function(){return i(this,void 0,void 0,(function(){return s(this,(function(e){switch(e.label){case 0:return[4,$l.of(this._iid).getChannelWithoutCache(this.url)];case 1:return[2,e.sent()]}}))}))},a.prototype.enter=function(){return i(this,void 0,void 0,(function(){var e,t,n,r,i,a;return s(this,(function(s){switch(s.label){case 0:return e=wt.of(this._iid).requestQueue,t=new Wl({channelUrl:this.url}),[4,e.send(t)];case 1:return n=s.sent(),r=n.as(Yl),i=r.participantCount,a=r.ts,this._updateParticipantCount(i,a),$l.of(this._iid).setEnteredToCache(this),[2]}}))}))},a.prototype.exit=function(){return i(this,void 0,void 0,(function(){var e,t,n,r,i,a;return s(this,(function(s){switch(s.label){case 0:return e=wt.of(this._iid).requestQueue,t=new Jl({channelUrl:this.url}),[4,e.send(t)];case 1:return n=s.sent(),r=n.as(Xl),i=r.participantCount,a=r.ts,this._updateParticipantCount(i,a),$l.of(this._iid).setExitedToCache(this),kn.of(this._iid).fileMessageQueue.cancel(this),[2]}}))}))},a.prototype.updateChannel=function(e){return i(this,void 0,void 0,(function(){var t,n,i,a,o;return s(this,(function(s){switch(s.label){case 0:return t=r(r({},eh),e),ct(function(e){return b("string",e.operatorUserIds,!0)&&(g("string",e.coverUrlOrImage)||T(e.coverUrlOrImage)||null===e.coverUrlOrImage)&&g("string",e.name,!0)&&g("string",e.data,!0)&&g("string",e.customType,!0)}(t)).throw(f.invalidParameters),n=wt.of(this._iid).requestQueue,i=new ih(r({channelUrl:this.url},t)),[4,n.send(i)];case 1:return a=s.sent(),o=a.as(sh).channel,[4,$l.of(this._iid).upsertChannelsToCache([o])];case 2:return s.sent(),[2,o]}}))}))},a.prototype.updateChannelWithOperatorUserIds=function(e,t,n,a,o){return i(this,void 0,void 0,(function(){var i;return s(this,(function(s){return i=r(r({},eh),{name:e,coverUrlOrImage:t,data:n,operatorUserIds:a,customType:o}),[2,this.updateChannel(i)]}))}))},a.prototype.delete=function(){return i(this,void 0,void 0,(function(){var e,t;return s(this,(function(n){switch(n.label){case 0:return e=wt.of(this._iid).requestQueue,t=new ah({channelUrl:this.url}),[4,e.send(t)];case 1:return n.sent(),[4,$l.of(this._iid).removeChannelsFromCache([this.url])];case 2:return n.sent(),[2]}}))}))},a}(Uo),uh=function(e){function t(){var t=null!==e&&e.apply(this,arguments)||this;return t.onUserEntered=J,t.onUserExited=J,t.onChannelParticipantCountChanged=J,t}return n(t,e),t}(Pl),ch=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}(uh),lh=function(e){function t(t){var n=this,r=t.token,i=t.limit,s=t.nameKeyword,a=t.urlKeyword,o=t.customTypes,u=t.includeFrozen,c=t.includeMetaData;return(n=e.call(this)||this).method=d.GET,n.path=ge,n.params=D({token:r,limit:i,name_contains:s,url_contains:a,custom_types:o,show_frozen:u,show_metadata:c}),n}return n(t,e),t}(x),hh=function(e){function t(t,n){var r=e.call(this,t,n)||this;r.token=null,r.channels=[],r.ts=null;var i=n.next,s=n.channels,a=n.ts;return r.token=i,s&&s.length>0&&(r.channels=s.map((function(e){return new oh(t,e)}))),r.ts="number"==typeof a?a:null,r}return n(t,e),t}(F),dh=function(e){function t(t,n){var r,i,s,a,o,u=this;return(u=e.call(this,t,n)||this).includeFrozen=!0,u.includeMetaData=!0,u.nameKeyword=null,u.urlKeyword=null,u.customTypes=null,u.includeFrozen=null===(r=n.includeFrozen)||void 0===r||r,u.includeMetaData=null===(i=n.includeMetaData)||void 0===i||i,u.nameKeyword=null!==(s=n.nameKeyword)&&void 0!==s?s:null,u.urlKeyword=null!==(a=n.urlKeyword)&&void 0!==a?a:null,u.customTypes=null!==(o=n.customTypes)&&void 0!==o?o:null,u}return n(t,e),t.prototype._validate=function(){return e.prototype._validate.call(this)&&g("boolean",this.includeFrozen)&&g("boolean",this.includeMetaData)&&g("string",this.nameKeyword,!0)&&g("string",this.urlKeyword,!0)&&b("string",this.customTypes,!0)},t.prototype.next=function(){return i(this,void 0,void 0,(function(){var e,t,n,i,a,o;return s(this,(function(s){switch(s.label){case 0:return this._validate()?this._isLoading?[3,4]:this._hasNext?(this._isLoading=!0,e=wt.of(this._iid).requestQueue,t=new lh(r(r({},this),{token:this._token})),[4,e.send(t)]):[3,3]:[3,6];case 1:return n=s.sent(),i=n.as(hh),a=i.channels,o=i.token,this._token=o,this._hasNext=!!o,[4,$l.of(this._iid).upsertChannelsToCache(a)];case 2:return s.sent(),this._isLoading=!1,[2,a];case 3:return[2,[]];case 4:throw f.queryInProgress;case 5:return[3,7];case 6:throw f.invalidParameters;case 7:return[2]}}))}))},t}(Fn),ph=function(e){function t(){var t=null!==e&&e.apply(this,arguments)||this;return t.name="openChannel",t}return n(t,e),t.prototype.init=function(t,n){var r=n.sdkState,i=n.dispatcher,s=n.sessionManager,a=n.requestQueue,o=n.logger,u=n.onlineDetector,c=n.cacheContext;e.prototype.init.call(this,t,{sdkState:r,dispatcher:i,sessionManager:s,requestQueue:a,logger:o,onlineDetector:u,cacheContext:c}),this._manager=new $l(t,{sdkState:r,dispatcher:i,requestQueue:a})},t.prototype.createOpenChannelListQuery=function(e){return void 0===e&&(e={}),new dh(this._iid,e)},t.prototype.addOpenChannelHandler=function(e,t){this._manager.addHandler(e,t)},t.prototype.removeOpenChannelHandler=function(e){this._manager.removeHandler(e)},t.prototype.removeAllOpenChannelHandlers=function(){this._manager.clearHandler()},t.prototype.buildOpenChannelFromSerializedData=function(e){return this._manager.buildOpenChannelFromSerializedData(e)},t.prototype.getChannel=function(e){return i(this,void 0,void 0,(function(){return s(this,(function(t){return[2,this._manager.getChannel(e)]}))}))},t.prototype.getChannelWithoutCache=function(e){return i(this,void 0,void 0,(function(){return s(this,(function(t){return[2,this._manager.getChannelWithoutCache(e)]}))}))},t.prototype.createChannel=function(e){return void 0===e&&(e={}),i(this,void 0,void 0,(function(){return s(this,(function(t){return[2,this._manager.createChannel(e)]}))}))},t.prototype.createChannelWithOperatorUserIds=function(e,t,n,a,o){return i(this,void 0,void 0,(function(){var i;return s(this,(function(s){return(i=r({},Ql)).name=e,i.coverUrlOrImage=t,i.data=n,i.operatorUserIds=a,i.customType=o,[2,this._manager.createChannel(i)]}))}))},t}(At);return e.AdminMessage=Yt,e.AppleCriticalAlertOptions=Gt,e.ApplicationUserListQuery=ss,e.BannedUserListQuery=Ma,e.BaseChannel=Uo,e.BaseMessage=Kt,e.BlockedUserListQuery=us,e.ConnectionHandler=Cr,e.Emoji=Wi,e.EmojiCategory=Yi,e.EmojiContainer=Ji,e.FileMessage=an,e.FriendListQuery=hs,e.GroupChannel=wl,e.GroupChannelCollection=Rl,e.GroupChannelEventContext=mc,e.GroupChannelFilter=Qo,e.GroupChannelHandler=Fl,e.GroupChannelListQuery=uc,e.GroupChannelModule=Vl,e.Member=Ho,e.MemberListQuery=Qc,e.MemoryStore=ra,e.MessageCollection=qc,e.MessageCollectionInitHandler=Fc,e.MessageEventContext=gc,e.MessageFilter=Ar,e.MessageMetaArray=xt,e.MessageModule=Wn,e.MessageRequestHandler=Dn,e.MessageSearchQuery=Qn,e.MutedUserListQuery=Sa,e.OGImage=Ft,e.OGMetaData=qt,e.OpenChannel=oh,e.OpenChannelHandler=ch,e.OpenChannelListQuery=dh,e.OpenChannelModule=ph,e.OperatorListQuery=Ca,e.ParticipantListQuery=rh,e.Plugin=Jt,e.PreviousMessageListQuery=jn,e.PublicGroupChannelListQuery=Dl,e.Reaction=Pt,e.ReactionEvent=Dt,e.ReadStatus=Vo,e.RestrictedUser=fa,e.RestrictionInfo=pa,e.ScheduledMessageListQuery=Hl,e.SendbirdChat=Ro,e.SendbirdChatOptions=I,e.SendbirdError=f,e.Sender=Qt,e.SessionHandler=br,e.ThreadInfo=Rt,e.ThreadInfoUpdateEvent=Pn,e.Thumbnail=jt,e.User=ht,e.UserEventHandler=Tr,e.UserMessage=nn,Object.defineProperty(e,"__esModule",{value:!0}),e}({});