From 9e89dd3331949d11d5dab640559b08474645d91b Mon Sep 17 00:00:00 2001 From: sendbird-sdk-deployment Date: Fri, 12 May 2023 06:46:13 +0000 Subject: [PATCH] Release - 4.8.2 --- CHANGELOG.md | 3 +++ __bundle-51a2cdbc.js => __bundle-12fe2d56.js | 2 +- __bundle-edc633d6.js => __bundle-3b517302.js | 2 +- __bundle-5ab69bcd.js => __bundle-5c4b7d2b.js | 2 +- __bundle-9e0eba5d.js => __bundle-9a0f0a93.js | 2 +- __bundle-7ac921c4.js => __bundle-da2eac9e.js | 2 +- __bundle-7e9a42ec.js => __bundle-e9aa026e.js | 2 +- __bundle-03ba89c3.js => __bundle-ea43c8a8.js | 2 +- groupChannel.js | 2 +- message.js | 2 +- openChannel.js | 2 +- package.json | 2 +- poll.js | 2 +- sendbird.js | 2 +- sendbird.min.js | 2 +- 15 files changed, 17 insertions(+), 14 deletions(-) rename __bundle-51a2cdbc.js => __bundle-12fe2d56.js (99%) rename __bundle-edc633d6.js => __bundle-3b517302.js (99%) rename __bundle-5ab69bcd.js => __bundle-5c4b7d2b.js (71%) rename __bundle-9e0eba5d.js => __bundle-9a0f0a93.js (99%) rename __bundle-7ac921c4.js => __bundle-da2eac9e.js (99%) rename __bundle-7e9a42ec.js => __bundle-e9aa026e.js (95%) rename __bundle-03ba89c3.js => __bundle-ea43c8a8.js (99%) diff --git a/CHANGELOG.md b/CHANGELOG.md index 5917b39..84f28ad 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,8 @@ # Changelog +## v4.8.2 (May 12, 2023) +### **Improvements** +- Fixed a bug that `PublicGroupChannelListQuery` overwrites the cache with missing properties\n ## v4.8.1 (May 04, 2023) ### **Improvements** - Improved stability diff --git a/__bundle-51a2cdbc.js b/__bundle-12fe2d56.js similarity index 99% rename from __bundle-51a2cdbc.js rename to __bundle-12fe2d56.js index ebea7b2..b9621e3 100644 --- a/__bundle-51a2cdbc.js +++ b/__bundle-12fe2d56.js @@ -1 +1 @@ -import{_ as e,A as t,T as n,e as s,f as a,h as i,g as r,U as l,X as u,l as o,a as d,I as c,p as h,q as p,H as m,Y as g,Z as y,$ as f,M as _,a0 as v,R as I,a1 as T,a2 as M,a3 as S,b,c as A,r as E,S as U,a4 as w,V as D,a5 as q,a6 as F,a7 as C,a8 as N,W as R,t as P,w as O,a9 as k,aa as L,i as x,ab as z,ac as Q,ad as G,s as B,ae as j,af as H,ag as W,n as K,ah as V,B as X,ai as Y,aj as Z}from"./__bundle-03ba89c3.js";var $,J=function(a){function i(e){var i=a.call(this)||this;if(i.method=t.POST,i.path="".concat(n),i.params=s({file:e.file,channel_url:e.channelUrl}),e.thumbnailSizes)for(var r=0;r0&&d("number",r)&&(this.key=a,this.userIds=i,this.updatedAt=r);var l={};try{for(var u=m(this.userIds),c=u.next();!c.done;c=u.next()){l[c.value]=this.updatedAt}}catch(e){t={error:e}}finally{try{c&&!c.done&&(n=u.return)&&n.call(u)}finally{if(t)throw t.error}}this._version=l}return Object.defineProperty(e.prototype,"isEmpty",{get:function(){return 0===this.userIds.length},enumerable:!1,configurable:!0}),e.payloadify=function(e){return e?s({key:e.key,user_ids:e.userIds,updated_at:e.updatedAt}):null},e.prototype.applyEvent=function(e){if(e.key===this.key&&this.updatedAt<=e.updatedAt){if(!this._version[e.userId]||this._version[e.userId]<=e.updatedAt){var t=this.userIds.indexOf(e.userId);switch(e.operation){case $.ADD:t<0&&this.userIds.push(e.userId);break;case $.DELETE:t>=0&&this.userIds.splice(t,1)}this._version[e.userId]=e.updatedAt}this.updatedAt=Math.max(this.updatedAt,e.updatedAt)}},e}(),re=function(){function e(e){this.key=e.key,this.value=o("string",e.value)?h([],p(e.value),!1):[]}return e.payloadify=function(e){var t;return e?s({key:e.key,value:null!==(t=e.value)&&void 0!==t?t:[]}):null},e}(),le=function(){function e(e){this.url=null,this.secureUrl=null,this.type=null,this.width=0,this.height=0,this.alt=null,this.url=e.url,e.hasOwnProperty("secure_url")&&(this.secureUrl=e.secure_url),e.hasOwnProperty("type")&&(this.type=e.type),e.hasOwnProperty("width")&&(this.width=e.width),e.hasOwnProperty("height")&&(this.height=e.height),e.hasOwnProperty("alt")&&(this.alt=e.alt)}return e.payloadify=function(e){var t,n;return e?s({url:e.url,secure_url:e.secureUrl,type:e.type,width:null!==(t=e.width)&&void 0!==t?t:0,height:null!==(n=e.height)&&void 0!==n?n:0,alt:e.alt}):null},e}(),ue=function(){function e(e){this.title=null,this.url=null,this.description=null,this.defaultImage=null,e.hasOwnProperty("og:title")&&(this.title=e["og:title"]),e.hasOwnProperty("og:url")&&(this.url=e["og:url"]),e.hasOwnProperty("og:description")&&(this.description=e["og:description"]),e.hasOwnProperty("og:image")&&(this.defaultImage=new le(e["og:image"]))}return e.payloadify=function(e){return e?s({"og:title":e.title,"og:url":e.url,"og:description":e.description,"og:image":e.defaultImage?le.payloadify(e.defaultImage):null}):null},e}(),oe=function(){function e(e){var t,n;this.name=null,this.volume=0,this.name=null!==(t=e.name)&&void 0!==t?t:"default",this.volume=null!==(n=e.volume)&&void 0!==n?n:1}return e.prototype.serialize=function(){return{name:this.name,volume:this.volume}},e.payloadify=function(e){return e?s({name:e.name,volume:e.volume}):null},e}();!function(e){e.PENDING="pending",e.SENT="sent",e.FAILED="failed",e.CANCELED="canceled"}(ne||(ne={})),function(e){e.PENDING="pending",e.IN_QUEUE="in_queue",e.SENT="sent",e.FAILED="failed",e.CANCELED="canceled",e.REMOVED="removed"}(se||(se={}));var de,ce=function(e){switch(e){case y.BASE:return"";case y.USER:return"MESG";case y.FILE:return"FILE";case y.ADMIN:return"ADMM"}},he=function(t){function n(e,n){var s,a,i,r,u,o,d,h,p,m,g,f,I,T,M,S=this;(S=t.call(this,e)||this).channelUrl=null,S.channelType=_.BASE,S.messageId=0,S.parentMessageId=null,S.parentMessage=null,S.silent=!1,S.isOperatorMessage=!1,S.messageType=y.BASE,S.data=null,S.customType=null,S.mentionType=null,S.mentionedUsers=[],S.mentionedUserIds=[],S.mentionedMessageTemplate=null,S.threadInfo=null,S.reactions=[],S.metaArrays=[],S.ogMetaData=null,S.appleCriticalAlertOptions=null,S.createdAt=0,S.updatedAt=0,S.scheduledInfo=null,S.extendedMessage={},S._isContinuousMessages=!1,S._scheduledStatus=null,S.messageId=null!==(a=null!==(s=n.msg_id)&&void 0!==s?s:n.message_id)&&void 0!==a?a:0,S.channelUrl=n.channel_url,S.channelType=c(_,n.channel_type)?n.channel_type:_.GROUP,n.channel&&(n.channel.channel_url&&(S.channelUrl=n.channel.channel_url),n.channel.channel_type&&(S.channelType=n.channel.channel_type)),S.parentMessageId=null!==(i="string"==typeof n.parent_message_id?parseInt(n.parent_message_id):n.parent_message_id)&&void 0!==i?i:0,S.data=null!==(r=n.data)&&void 0!==r?r:"",S.customType=null!==(u=n.custom_type)&&void 0!==u?u:"",S.mentionType=c(v,n.mention_type)?n.mention_type:null;var b=n.mentioned_users;S.mentionedUsers=b?b.map((function(e){return new l(S._iid,e)})):null;var A=n.mentioned_user_ids;S.mentionedUserIds=null!=A?A:null,S.mentionedUsers&&!S.mentionedUserIds&&(S.mentionedUserIds=S.mentionedUsers.map((function(e){return e.userId}))),S.mentionedMessageTemplate=null!==(o=n.mentioned_message_template)&&void 0!==o?o:"",S.threadInfo=n.thread_info?new te(S._iid,n.thread_info):null,S.reactions=n.reactions?n.reactions.map((function(e){return new ie(e)})):[];for(var E=null!==(d=n.metaarray)&&void 0!==d?d:{},U=null!==(h=n.metaarray_key_order)&&void 0!==h?h:Object.keys(E).sort((function(e,t){return e.localeCompare(t)})),w=0;w=t)return this.parentMessage=e,!0}return!1},n}(u),pe=function(t){function n(e,n){var s=t.call(this,e,n)||this;return s.role=null,s.isBlockedByMe=!1,s.role=c(I,n.role)?n.role:I.NONE,n.hasOwnProperty("is_blocked_by_me")&&(s.isBlockedByMe=n.is_blocked_by_me),s}return e(n,t),n.payloadify=function(e){return e?s(r(r({},t.payloadify.call(this,e)),{role:e.role,is_blocked_by_me:e.isBlockedByMe})):null},n}(l),me=function(t){function n(e,n){var s,a,i,r,l=this;if((l=t.call(this,e,n)||this).sender=null,l.reqId="",l.replyToChannel=!1,l.sendingStatus=null,l.errorCode=0,l.sender=n.user?new pe(l._iid,n.user):n.sender_id,l.reqId=null!==(a=null!==(s=n.req_id)&&void 0!==s?s:n.request_id)&&void 0!==a?a:"",l.replyToChannel=null!==(i=n.is_reply_to_channel)&&void 0!==i&&i,n.request_state&&c(T,n.request_state)&&(l.sendingStatus=n.request_state),!l.sendingStatus)if(l.messageId>0)l.sendingStatus=T.SUCCEEDED;else if(l.scheduledInfo)switch(l._scheduledStatus=n.scheduled_status,n.scheduled_status){case se.SENT:case se.IN_QUEUE:l.sendingStatus=T.SUCCEEDED;break;case se.PENDING:l.sendingStatus=T.SCHEDULED;break;case se.FAILED:case se.REMOVED:l.sendingStatus=T.FAILED;break;case se.CANCELED:l.sendingStatus=T.CANCELED}else l.sendingStatus=T.PENDING;return l.errorCode=null!==(r=n.error_code)&&void 0!==r?r:0,l}return e(n,t),n.payloadify=function(e){return e?s(r(r({},t.payloadify.call(this,e)),{user:pe.payloadify(e.sender),req_id:e.reqId,is_reply_to_channel:e.replyToChannel,request_state:e.sendingStatus,error_code:e.errorCode})):null},Object.defineProperty(n.prototype,"isResendable",{get:function(){return this.sendingStatus===T.FAILED&&M(this.errorCode)},enumerable:!1,configurable:!0}),n.prototype.isIdentical=function(e){return this.messageId>0&&e.messageId>0?this.messageId===e.messageId:this.reqId===e.reqId},n}(he),ge=function(){function e(e){var t,n;this.url=null,this.width=0,this.height=0,this.realWidth=0,this.realHeight=0,this.url=e.url,this.width=e.width,this.height=e.height,this.realWidth=null!==(t=e.real_width)&&void 0!==t?t:e.width,this.realHeight=null!==(n=e.real_height)&&void 0!==n?n:e.height}return e.payloadify=function(e){return e?s({url:"",width:e.maxWidth,height:e.maxHeight,real_width:0,real_height:0}):null},Object.defineProperty(e.prototype,"plainUrl",{get:function(){return this.url.split("?auth=")[0]},enumerable:!1,configurable:!0}),e}(),ye={prevResultSize:0,nextResultSize:0,isInclusive:!1,reverse:!1,messageTypeFilter:S.ALL,customTypesFilter:null,senderUserIdsFilter:null,includeReactions:!1,includeMetaArray:!1,includeParentMessageInfo:!1},fe=function(e){return d("number",e.prevResultSize)&&d("number",e.nextResultSize)&&d("boolean",e.isInclusive)&&d("boolean",e.reverse)&&d("string",e.messageTypeFilter)&&c(S,e.messageTypeFilter)&&o("string",e.customTypesFilter,!0)&&o("string",e.senderUserIdsFilter,!0)&&d("boolean",e.includeMetaArray)&&d("boolean",e.includeReactions)&&d("boolean",e.includeParentMessageInfo)},_e=function(t){function n(e,n){var s,a,i,l,u=this;if((u=t.call(this,e,n)||this).message=null,u.translations={},u.message=null!==(s=n.message)&&void 0!==s?s:"",u.messageType=y.ADMIN,u.translations=null!==(a=n.translations)&&void 0!==a?a:{},n.parent_message_info){var o=n.parent_message_info,d=r(r({},o),{message_id:u.parentMessageId,channel_url:u.channelUrl,channel_type:u.channelType,file:o.file,url:null===(i=o.file)||void 0===i?void 0:i.url,require_auth:null===(l=o.file)||void 0===l?void 0:l.require_auth});u.parentMessage=Me(e,d)}return u}return e(n,t),n.payloadify=function(e){return e?s(r(r({},t.payloadify.call(this,e)),{message:e.message,translations:e.translations,parent_message_info:Te(e.parentMessage)})):null},n.prototype.getThreadedMessagesByTimestamp=function(e,t){return b(this,void 0,void 0,(function(){var n;return A(this,(function(s){switch(s.label){case 0:return n=r(r({},ye),t),E(this.messageId>0&&d("number",e)&&fe(n)).throw(U.invalidParameters),[4,Be.of(this._iid).getThreadedMessagesByTimestamp(this,e,n)];case 1:return[2,s.sent()]}}))}))},n}(he),ve=function(){function e(e){var t,n;this.type=null,this.vendor=null,this.detail={},this.type=null!==(t=e.type)&&void 0!==t?t:"",this.vendor=null!==(n=e.vendor)&&void 0!==n?n:"",e.hasOwnProperty("detail")&&d("object",e.detail)&&!Array.isArray(e.detail)&&(this.detail=e.detail)}return e.payloadify=function(e){return e?s({type:e.type,vendor:e.vendor,detail:e.detail}):null},e}(),Ie=function(t){function n(e,n){var a,i,l,u,o,d,c,h=this;if((h=t.call(this,e,n)||this).message="",h.messageParams=null,h.translations={},h.translationTargetLanguages=[],h.messageSurvivalSeconds=-1,h.plugins=[],h._poll=null,h.message=n.message,h.messageType=y.USER,h.translations=null!==(l=n.translations)&&void 0!==l?l:{},h.translationTargetLanguages=null!==(u=n.target_langs)&&void 0!==u?u:[],0===Object.keys(h.translations).length&&h.translationTargetLanguages.length>0)try{for(var p=m(h.translationTargetLanguages),g=p.next();!g.done;g=p.next()){var f=g.value;h.translations[f]=""}}catch(e){a={error:e}}finally{try{g&&!g.done&&(i=p.return)&&i.call(p)}finally{if(a)throw a.error}}if(h.messageSurvivalSeconds=null!==(o=n.message_survival_seconds)&&void 0!==o?o:-1,h.plugins=n.plugins?n.plugins.map((function(e){return new ve(e)})):[],h._poll=n.poll?new w(h._iid,n.poll):null,n.parent_message_info){var _=n.parent_message_info,v=r(r({},_),{created_at:_.ts,message_id:h.parentMessageId,channel_url:h.channelUrl,channel_type:h.channelType,file:_.file,url:null===(d=_.file)||void 0===d?void 0:d.url,require_auth:null===(c=_.file)||void 0===c?void 0:c.require_auth});h.parentMessage=Me(e,s(v))}return h}return e(n,t),n.payloadify=function(e){return e?s(r(r({},t.payloadify.call(this,e)),{message:e.message,translations:e.translations,message_survival_seconds:e.messageSurvivalSeconds,plugins:e.plugins.map((function(e){return ve.payloadify(e)})),poll:w.payloadify(e._poll),parent_message_info:Te(e.parentMessage)})):null},n.prototype.getThreadedMessagesByTimestamp=function(e,t){return b(this,void 0,void 0,(function(){var n;return A(this,(function(s){switch(s.label){case 0:return n=r(r({},ye),t),E(this.messageId>0&&d("number",e)&&fe(n)).throw(U.invalidParameters),[4,Be.of(this._iid).getThreadedMessagesByTimestamp(this,e,n)];case 1:return[2,s.sent()]}}))}))},n.prototype.applyPoll=function(e){return!(this._poll&&this._poll.id===e.id&&this._poll.updatedAt>e.updatedAt)&&(this._poll=e,!0)},Object.defineProperty(n.prototype,"poll",{get:function(){return this._poll},enumerable:!1,configurable:!0}),n}(me),Te=function(e){if(e)switch(e.messageType){case y.USER:return Ie.payloadify(e);case y.FILE:return Se.payloadify(e);case y.ADMIN:return _e.payloadify(e)}return null},Me=function(e,t){switch(t.type){case"MESG":return new Ie(e,t);case"FILE":return new Se(e,t);case"ADMM":case"BRDM":return new _e(e,t)}return null},Se=function(t){function n(e,n){var s,a,i,l,u,o,d,c,h,p,m,g,f,_,v,I=this;(I=t.call(this,e,n)||this).messageParams=null,I.plainUrl="",I.requireAuth=!1,I.name=null,I.size=0,I.type=null,I.thumbnails=[],I.messageSurvivalSeconds=-1,I.messageType=y.FILE;var T=null!==(s=n.file)&&void 0!==s?s:null;I.plainUrl=(null!==(i=null!==(a=null==T?void 0:T.url)&&void 0!==a?a:n.url)&&void 0!==i?i:"").split("?auth=")[0],I.name=null!==(u=null!==(l=null==T?void 0:T.name)&&void 0!==l?l:n.name)&&void 0!==u?u:"File",I.size=null!==(d=null!==(o=null==T?void 0:T.size)&&void 0!==o?o:n.size)&&void 0!==d?d:0,I.data=null!==(h=null!==(c=null==T?void 0:T.data)&&void 0!==c?c:n.custom)&&void 0!==h?h:"",I.type=T?null!==(p=T.type)&&void 0!==p?p:"":null!==(m=n.type)&&void 0!==m?m:"";var M=D.of(I._iid).sessionManager;if(I.requireAuth=null!==(g=n.require_auth)&&void 0!==g&&g,I.thumbnails=n.thumbnails?n.thumbnails.map((function(e){return new ge(r(r({},e),{url:"".concat(e.url.split("?auth=")[0]).concat(I.requireAuth?"?auth=".concat(M.ekey):"")}))})):[],I.messageSurvivalSeconds=null!==(f=n.message_survival_seconds)&&void 0!==f?f:-1,n.parent_message_info){var S=n.parent_message_info,b=r(r({},S),{message_id:I.parentMessageId,channel_url:I.channelUrl,channel_type:I.channelType,file:S.file,url:null===(_=S.file)||void 0===_?void 0:_.url,require_auth:null===(v=S.file)||void 0===v?void 0:v.require_auth});I.parentMessage=Me(e,b)}return I}return e(n,t),n.payloadify=function(e){return e?s(r(r({},t.payloadify.call(this,e)),{url:e.plainUrl,require_auth:e.requireAuth,file:{name:e.name,size:e.size,type:e.type,data:e.data},thumbnails: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:Te(e.parentMessage)})):null},Object.defineProperty(n.prototype,"url",{get:function(){var e=D.of(this._iid).sessionManager;return this.requireAuth?"".concat(this.plainUrl,"?auth=").concat(e.ekey):this.plainUrl},enumerable:!1,configurable:!0}),n.prototype.getThreadedMessagesByTimestamp=function(e,t){return b(this,void 0,void 0,(function(){var n;return A(this,(function(s){switch(s.label){case 0:return n=r(r({},ye),t),E(this.messageId>0&&d("number",e)&&fe(n)).throw(U.invalidParameters),[4,Be.of(this._iid).getThreadedMessagesByTimestamp(this,e,n)];case 1:return[2,s.sent()]}}))}))},n}(me),be=function(t){function n(e){var n,a,i,r=[];return e.mentionType===v.USERS&&(e.mentionedUserIds?r=e.mentionedUserIds:e.mentionedUsers&&(r=e.mentionedUsers.map((function(e){return e.userId})))),t.call(this,{code:"FILE",ackRequired:!0,payload:s({channel_url:e.channelUrl,url:e.url,name:null!==(n=e.fileName)&&void 0!==n?n:"",type:null!==(a=e.mimeType)&&void 0!==a?a:"",size:null!==(i=e.fileSize)&&void 0!==i?i:0,custom:e.data,custom_type:e.customType,thumbnails:e.thumbnailSizes,require_auth:e.requireAuth,metaarray:e.metaArrays,mention_type:e.mentionType,mentioned_user_ids:r,push_option:e.pushNotificationDeliveryOption&&e.pushNotificationDeliveryOption!==q.DEFAULT?e.pushNotificationDeliveryOption:void 0,apple_critical_alert_options:e.appleCriticalAlertOptions,silent:e.silent,reply_to_channel:e.isReplyToChannel,parent_message_id:e.parentMessageId>0?e.parentMessageId:null,req_id:e.reqId,pin_message:e.isPinnedMessage})})||this}return e(n,t),n}(F),Ae=function(n){function a(e){var a,i=this;i=n.call(this)||this;var r=[];return e.mentionType===v.USERS&&(e.mentionedUserIds?r=e.mentionedUserIds:e.mentionedUsers&&(r=e.mentionedUsers.map((function(e){return e.userId})))),i.method=t.POST,i.path="".concat(C(e.channelType),"/").concat(encodeURIComponent(e.channelUrl),"/messages"),i.params=s({message_type:y.FILE,user_id:e.userId,url:e.fileUrl,mention_type:e.mentionType,mentioned_user_ids:r,file_name:e.fileName,file_size:e.fileSize,file_type:e.mimeType,data:e.data,custom_type:e.customType,thumbnails:e.thumbnailSizes.map((function(e){return ge.payloadify(e)})),require_auth:e.requireAuth,sorted_metaarray:null===(a=e.metaArrays)||void 0===a?void 0:a.map((function(e){return re.payloadify(e)})),push_option:e.pushNotificationDeliveryOption,parent_message_id:e.parentMessageId>0?e.parentMessageId:null,apple_critical_alert_options:oe.payloadify(e.appleCriticalAlertOptions),reply_to_channel:e.isReplyToChannel,req_id:e.reqId,pin_message:e.isPinnedMessage}),i}return e(a,n),a}(a),Ee=function(t){function n(e,n,s){var a,i,r,l=this;(l=t.call(this,e,"FILE",s)||this).message=new Se(e,s);var u=D.of(e).sdkState;return l.isMentioned=N(l.message.mentionType,null!==(a=l.message.mentionedUserIds)&&void 0!==a?a:null===(i=l.message.mentionedUsers)||void 0===i?void 0:i.map((function(e){return e.userId})),u.userId),l.forceUpdateLastMessage=null!==(r=s.force_update_last_message)&&void 0!==r&&r,l}return e(n,t),n}(R),Ue=function(t){function n(e,n){var s,a,i=this;(i=t.call(this,e,n)||this).message=new Se(e,n);var r=D.of(e).sdkState;return i.isMentioned=N(i.message.mentionType,null!==(s=i.message.mentionedUserIds)&&void 0!==s?s:i.message.mentionedUsers.map((function(e){return e.userId})),r.userId),i.forceUpdateLastMessage=null!==(a=n.force_update_last_message)&&void 0!==a&&a,i}return e(n,t),n}(i);!function(e){e[e.PENDING=0]="PENDING",e[e.UPLOADING=1]="UPLOADING",e[e.UPLOADED=2]="UPLOADED",e[e.SENDING=3]="SENDING",e[e.FAILED=4]="FAILED"}(de||(de={}));var we,De=function(){function e(e,t){var n=t.sdkState,s=t.dispatcher,a=t.requestQueue,i=t.onlineDetector,r=t.cacheContext,l=this;this._queueMap=new Map,this._connectionState=null,this._onlineDetector=null,this._iid=e,this._sdkState=n,this._requestQueue=a,this._cacheContext=r,this._dispatcher=s,this._dispatcher.on((function(e){e instanceof P&&(l._connectionState=e.stateType)})),this._onlineDetector=i}return Object.defineProperty(e.prototype,"_shouldSendThroughWebSocket",{get:function(){return this._connectionState===O.CONNECTED||this._connectionState===O.CONNECTING||this._connectionState===O.RECONNECTING},enumerable:!1,configurable:!0}),e.prototype._sendFileMessage=function(e,t){return b(this,void 0,void 0,(function(){var n,s;return A(this,(function(a){switch(a.label){case 0:return this._shouldSendThroughWebSocket?(n=new be(r(r({},t.params),{channelUrl:e.url,channelType:e.channelType,url:t.params.fileUrl,requireAuth:t.requireAuth,reqId:t.requestId})),[4,this._requestQueue.send(n)]):[3,2];case 1:return s=a.sent(),[2,s.as(Ee).message];case 2:return n=new Ae(r(r({},t.params),{channelUrl:e.url,channelType:e.channelType,url:t.params.fileUrl,userId:this._sdkState.userId,requireAuth:t.requireAuth,reqId:t.requestId})),[4,this._requestQueue.send(n)];case 3:return s=a.sent(),[2,s.as(Ue).message]}}))}))},e.prototype._resolveMessageQueue=function(e){return b(this,void 0,void 0,(function(){var t,n,s,a,i,r,l,u,o,d,c,h;return A(this,(function(p){switch(p.label){case 0:if(!(t=this._queueMap.get(e.url)))return[3,21];if(t.isResolving)return[3,20];t.isResolving=!0,n=[],s=!0,p.label=1;case 1:p.trys.push([1,15,16,17]),a=m(t.messageQueue),i=a.next(),p.label=2;case 2:if(i.done)return[3,14];switch(r=i.value,r.state){case de.PENDING:case de.UPLOADING:return[3,3];case de.UPLOADED:return[3,4];case de.FAILED:return[3,12]}return[3,13];case 3:return s=!1,n.push(r),[3,13];case 4:if(!s)return[3,10];p.label=5;case 5:return p.trys.push([5,8,,9]),r.state=de.SENDING,[4,this._sendFileMessage(e,r)];case 6:return l=p.sent(),r.deferred.resolve(l),[4,L(100)];case 7:return p.sent(),[3,9];case 8:return u=p.sent(),r.deferred.reject(u),[3,9];case 9:return[3,11];case 10:n.push(r),p.label=11;case 11:return[3,13];case 12:return r.deferred.reject(r.error.code===k.REQUEST_CANCELED?U.fileUploadCanceled:r.error),[3,13];case 13:return i=a.next(),[3,2];case 14:return[3,17];case 15:return o=p.sent(),c={error:o},[3,17];case 16:try{i&&!i.done&&(h=a.return)&&h.call(a)}finally{if(c)throw c.error}return[7];case 17:return d=t.isResolveRequestPending,t.messageQueue=n,t.isResolving=!1,t.isResolveRequestPending=!1,d?[4,this._resolveMessageQueue(e)]:[3,19];case 18:p.sent(),p.label=19;case 19:return[3,21];case 20:t.isResolveRequestPending=!0,p.label=21;case 21:return[2]}}))}))},e.prototype._uploadNextPendingItem=function(e){return b(this,void 0,void 0,(function(){var t,n,s,a,i,r,l,u,o,d,c,h,p,m;return A(this,(function(g){switch(g.label){case 0:return t=this._queueMap.get(e.url),(n=t.messageQueue.find((function(e){return e.state===de.PENDING})))?x(n.params.file)?t.uploadQueue.length<6?(n.state=de.UPLOADING,t.uploadQueue.push(n),[4,this._onlineDetector.isOnline()]):[3,10]:[3,11]:[3,13];case 1:if(!g.sent())return[3,8];g.label=2;case 2:return g.trys.push([2,4,5,7]),s=new J({file:n.params.file,channelUrl:e.url,thumbnailSizes:n.params.thumbnailSizes,requestId:n.requestId}),[4,this._requestQueue.send(s)];case 3:return a=g.sent(),i=a.as(ee),r=i.url,l=i.fileSize,u=void 0===l?n.params.fileSize:l,o=i.thumbnailSizes,d=void 0===o?n.params.thumbnailSizes:o,c=i.requireAuth,h=void 0!==c&&c,n.params.fileUrl=r,n.params.fileSize=u,n.params.thumbnailSizes=d,n.params.requireAuth=h,n.requireAuth=h,n.state=de.UPLOADED,[3,7];case 4:return(p=g.sent()).code===k.REQUEST_FAILED?n.error=new U({code:k.NETWORK_ERROR,message:"Failed to upload a file."}):n.error=p,n.state=de.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 g.sent(),[7];case 7:return[3,10];case 8:return n.state=de.FAILED,n.error=U.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:g.sent(),g.label=10;case 10:return[3,13];case 11:return n.params.thumbnailSizes=[],n.state=de.UPLOADED,[4,this._resolveMessageQueue(e)];case 12:g.sent(),g.label=13;case 13:return[2]}}))}))},e.prototype.request=function(e,t,n){var s,a,i;return b(this,void 0,void 0,(function(){var r;return A(this,(function(l){return r=new z,x(n.file)&&(n.fileName=null!==(s=n.fileName)&&void 0!==s?s:n.file.name,n.mimeType=null!==(a=n.mimeType)&&void 0!==a?a:n.file.type,n.fileSize=null!==(i=n.fileSize)&&void 0!==i?i: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:de.PENDING,deferred:r,requireAuth:n.requireAuth}),this._uploadNextPendingItem(e),[2,r.promise]}))}))},e.prototype.cancel=function(e,t){var n,s;void 0===t&&(t=null);var a=this._queueMap.get(e.url);if(a){var i=t?[a.messageQueue.find((function(e){return e.requestId===t}))]:h([],p(a.messageQueue),!1);try{for(var r=m(i),l=r.next();!l.done;l=r.next()){var u=l.value;if(u)switch(u.state){case de.PENDING:u.state=de.FAILED,u.error=U.requestCanceled,this._resolveMessageQueue(e);break;case de.UPLOADING:this._requestQueue.cancel(u.requestId)}}}catch(e){n={error:e}}finally{try{l&&!l.done&&(s=r.return)&&s.call(r)}finally{if(n)throw n.error}}}},e}(),qe={prevResultSize:0,nextResultSize:0,isInclusive:!1,reverse:!1,messageTypeFilter:S.ALL,customTypesFilter:null,senderUserIdsFilter:null,replyType:Q.NONE,includeReactions:!1,includeMetaArray:!1,includeParentMessageInfo:!1,includeThreadInfo:!1,showSubchannelMessagesOnly:!1},Fe=function(e){return d("number",e.prevResultSize)&&d("number",e.nextResultSize)&&d("boolean",e.isInclusive)&&d("boolean",e.reverse)&&d("string",e.messageTypeFilter)&&c(S,e.messageTypeFilter)&&o("string",e.customTypesFilter,!0)&&o("string",e.senderUserIdsFilter,!0)&&c(Q,e.replyType)&&d("boolean",e.includeMetaArray)&&d("boolean",e.includeReactions)&&d("boolean",e.includeParentMessageInfo)&&d("boolean",e.includeThreadInfo)&&d("boolean",e.showSubchannelMessagesOnly)},Ce={replyType:Q.NONE,includeReactions:!1,includeThreadInfo:!1,includeMetaArray:!1,includeParentMessageInfo:!1},Ne=function(e){return c(Q,e.replyType)&&d("boolean",e.includeReactions)&&d("boolean",e.includeMetaArray)&&d("boolean",e.includeParentMessageInfo)&&d("boolean",e.includeThreadInfo)},Re=function(n){function s(e){var s=e.channelType,a=e.channelUrl,i=e.messageId,r=e.includeMetaArray,l=e.includeReactions,u=e.includeThreadInfo,o=e.includeParentMessageInfo,d=n.call(this)||this;return d.method=t.GET,d.path="".concat(C(s),"/").concat(encodeURIComponent(a),"/messages/").concat(encodeURIComponent(i)),d.params={is_sdk:!0,with_sorted_meta_array:r,include_reactions:l,include_thread_info:u,include_parent_message_info:o,include_poll_details:!0},d}return e(s,n),s}(a),Pe=function(t){function n(e,n){var s=t.call(this,e,n)||this;return s.message=n?Me(e,r({},n)):null,s}return e(n,t),n}(i),Oe=function(n){function a(e){var a=e.channelType,i=e.channelUrl,r=e.timestamp,l=void 0===r?null:r,u=e.token,o=void 0===u?null:u,d=e.prevResultSize,c=e.nextResultSize,h=e.isInclusive,p=e.reverse,m=e.messageTypeFilter,g=e.customTypesFilter,y=e.senderUserIdsFilter,f=e.replyType,_=e.includeMetaArray,v=e.includeReactions,I=e.parentMessageId,T=e.includeThreadInfo,M=e.includeParentMessageInfo,S=e.showSubchannelMessagesOnly,b=e.checkingContinuousMessages,A=n.call(this)||this;return A.method=t.GET,A.path="".concat(C(a),"/").concat(encodeURIComponent(i),"/messages"),A.params=s({is_sdk:!0,prev_limit:d,next_limit:c,include:h,reverse:p,message_ts:l,message_id:o,message_type:null!=m?m:null,custom_types:g,sender_ids:y,include_reply_type:f,with_sorted_meta_array:_,include_reactions:v,parent_message_id:I,include_thread_info:T,include_parent_message_info:M,show_subchannel_message_only:S,include_poll_details:!0,checking_continuous_messages:b}),A}return e(a,n),a}(a),ke=function(t){function n(e,n){var s=t.call(this,e,n)||this;return s.messages=n.messages.map((function(t){return Me(e,t)})),s}return e(n,t),n}(i),Le=function(n){function s(e){var s=e.channelType,a=e.channelUrl,i=e.timestamp,r=e.token,l=e.replyType,u=e.includeMetaArray,o=e.includeReactions,d=e.includeThreadInfo,c=e.includeParentMessageInfo,h=n.call(this)||this;return h.method=t.GET,h.path="".concat(C(s),"/").concat(encodeURIComponent(a),"/messages/changelogs"),h.params={change_ts:i,token:r,with_sorted_meta_array:u,include_reactions:o,include_thread_info:d,include_reply_type:l,include_parent_message_info:c,include_poll_details:!0},h}return e(s,n),s}(a),xe=function(t){function n(e,n){var s=t.call(this,e,n)||this;return s.updatedMessages=n.updated.map((function(t){return Me(e,t)})),s.deletedMessagesInfo=n.deleted.map((function(e){return{messageId:e.message_id,deletedAt:e.deleted_at}})),s.hasMore=n.has_more,s.nextToken=n.next,s}return e(n,t),n}(i),ze=function(n){function s(e){var s=e.channelUrl,a=e.scheduledMessageId,i=n.call(this)||this;return i.method=t.GET,i.path="".concat(G,"/").concat(encodeURIComponent(s),"/scheduled_messages/").concat(encodeURIComponent(a)),i.params={},i}return e(s,n),s}(a),Qe=function(t){function n(e,n){var s=t.call(this,e,n)||this;return s.message=n?Me(e,r({},n)):null,s}return e(n,t),n}(i),Ge={},Be=function(){function e(e,t){var n=t.sdkState,s=t.dispatcher,a=t.requestQueue,i=t.onlineDetector,r=t.cacheContext;this._iid=e,this._sdkState=n,this._requestQueue=a,this._dispatcher=s,this._cacheContext=r,this.fileMessageQueue=new De(e,{sdkState:n,dispatcher:s,requestQueue:a,onlineDetector:i,cacheContext:r}),Ge[e]=this}return e.of=function(e){return Ge[e]},e.prototype.buildMessageFromSerializedData=function(e){var t=B(e);switch(t.messageType){case y.USER:return new Ie(this._iid,Ie.payloadify(t));case y.FILE:return new Se(this._iid,Se.payloadify(t));case y.ADMIN:return new _e(this._iid,_e.payloadify(t))}return null},e.prototype.buildUserMessageCreateParamsFromSerializedData=function(e,t){return s({data:t.data,customType:t.customType,mentionType:t.mentionType,mentionedUserIds:t.mentionedUserIds,mentionedUsers:t.mentionedUsers,mentionedMessageTemplate:t.mentionedMessageTemplate,metaArrays:t.metaArrays,parentMessageId:t.parentMessageId,isReplyToChannel:e.isReplyToChannel,pushNotificationDeliveryOption:e.pushNotificationDeliveryOption,appleCriticalAlertOptions:t.appleCriticalAlertOptions,reqId:t.reqId,message:t.message,translationTargetLanguages:Object.keys(t.translations),pollId:e.pollId})},e.prototype.buildFileMessageCreateParamsFromSerializedData=function(e,t){return s({data:t.data,customType:t.customType,mentionType:t.mentionType,mentionedUserIds:t.mentionedUserIds,mentionedUsers:t.mentionedUsers,mentionedMessageTemplate:t.mentionedMessageTemplate,metaArrays:t.metaArrays,parentMessageId:t.parentMessageId,isReplyToChannel:e.isReplyToChannel,pushNotificationDeliveryOption:e.pushNotificationDeliveryOption,appleCriticalAlertOptions:t.appleCriticalAlertOptions,reqId:t.reqId,file:e.file,fileKey:e.fileKey,fileUrl:t.plainUrl,fileName:t.name,fileSize:t.size,mimeType:t.type,thumbnailSizes: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 r(r({},this.buildUserMessageCreateParamsFromSerializedData(e,t)),{scheduledAt:e.scheduledAt})},e.prototype.buildScheduledFileMessageCreateParamsFromSerializedData=function(e,t){return r(r({},this.buildFileMessageCreateParamsFromSerializedData(e,t)),{scheduledAt:e.scheduledAt})},e.prototype.buildSenderFromSerializedData=function(e){var t=B(e);return new pe(this._iid,pe.payloadify(t))},e.prototype.getMessage=function(e){return b(this,void 0,void 0,(function(){var t,n;return A(this,(function(s){switch(s.label){case 0:return t=new Re(e),[4,this._requestQueue.send(t)];case 1:return n=s.sent(),[2,n.as(Pe).message]}}))}))},e.prototype.getScheduledMessage=function(e){return b(this,void 0,void 0,(function(){var t,n;return A(this,(function(s){switch(s.label){case 0:return t=new ze(e),[4,this._requestQueue.send(t)];case 1:return n=s.sent(),[2,n.as(Qe).message]}}))}))},e.prototype.getMessagesByMessageId=function(e,t,n,s,a){return void 0===a&&(a=j.REQUEST_MESSAGE),b(this,void 0,void 0,(function(){var i,l,u;return A(this,(function(o){switch(o.label){case 0:return i=new Oe(r(r({channelType:t,channelUrl:e,token:String(n)},qe),s)),[4,this._requestQueue.send(i)];case 1:return l=o.sent(),u=l.as(ke).messages,this._dispatcher.dispatch(new H({messages:u,source:a})),[2,u]}}))}))},e.prototype.getMessagesByTimestamp=function(e,t,n,s,a){return void 0===a&&(a=j.REQUEST_MESSAGE),b(this,void 0,void 0,(function(){var i,l,u;return A(this,(function(o){switch(o.label){case 0:return i=new Oe(r(r({channelType:t,channelUrl:e,timestamp:n},qe),s)),[4,this._requestQueue.send(i)];case 1:return l=o.sent(),u=l.as(ke).messages,this._dispatcher.dispatch(new H({messages:u,source:a})),[2,u]}}))}))},e.prototype._getMessagesByTimestampForCollection=function(e,t,n,s,a,i){return void 0===a&&(a=j.REQUEST_MESSAGE),b(this,void 0,void 0,(function(){var l,u,o,d;return A(this,(function(c){switch(c.label){case 0:return l=new Oe(r(r(r({channelType:t,channelUrl:e,timestamp:n},qe),s),{checkingContinuousMessages:i})),[4,this._requestQueue.send(l)];case 1:return u=c.sent(),o=u.payload,d=u.as(ke).messages,this._dispatcher.dispatch(new H({messages:d,source:a})),[2,{messages:d,isContinuousMessages:o}]}}))}))},e.prototype.getThreadedMessagesByTimestamp=function(e,t,n,s){return void 0===s&&(s=j.REQUEST_THREADED_MESSAGE),b(this,void 0,void 0,(function(){var a,i,l,u;return A(this,(function(o){switch(o.label){case 0:return a=new Oe(r(r(r({channelUrl:e.channelUrl,channelType:e.channelType,timestamp:t},ye),n),{replyType:Q.ALL,parentMessageId:e.messageId,includeThreadInfo:!0})),[4,this._requestQueue.send(a)];case 1:return i=o.sent(),l=i.as(ke).messages,(u=l.slice(1)).forEach((function(t){t.parentMessage=e})),this._dispatcher.dispatch(new H({messages:u,source:s})),[2,{parentMessage:l[0],threadedMessages:u}]}}))}))},e.prototype.getMessageChangelogs=function(e,t,n,a,i){return void 0===i&&(i=j.REQUEST_MESSAGE_CHANGELOGS),b(this,void 0,void 0,(function(){var l,u,o,d,c,h,p,m;return A(this,(function(g){switch(g.label){case 0:return l=new Le(s(r(r({channelType:t,channelUrl:e,timestamp:"number"==typeof n?n:null,token:"string"==typeof n?n:null},Ce),a))),[4,this._requestQueue.send(l)];case 1:return u=g.sent(),o=u.as(xe),d=o.updatedMessages,c=o.deletedMessagesInfo,h=o.hasMore,p=o.nextToken,m=c.map((function(e){return e.messageId})),d.length>0&&this._dispatcher.dispatch(new H({messages:d,source:i})),m.length>0&&this._dispatcher.dispatch(new W({messageIds:m,source:i})),[2,{updatedMessages:d,deletedMessageIds:m,hasMore:h,token:p}]}}))}))},e}(),je=function(){function e(){this._onPending=K,this._onFailed=K,this._onSucceeded=K}return e.prototype._trigger=function(e,t){switch(t.sendingStatus){case T.PENDING:0===t.errorCode&&this._onPending(t);break;case T.FAILED:case T.CANCELED:this._onFailed(e,t.scheduledInfo?null:t);break;case T.SCHEDULED:case T.SUCCEEDED:this._onSucceeded(t)}},e.prototype.onPending=function(e){return this._onPending=e,this},e.prototype.onFailed=function(e){return this._onFailed=e,this},e.prototype.onSucceeded=function(e){return this._onSucceeded=e,this},e}(),He=function(t){function n(e,n){var s=t.call(this,e)||this;s.threadInfo=null,s.targetMessageId=0,s.channelUrl=null,s.channelType=null;var a=n.thread_info,i=n.parent_message_id,r=n.channel_url,l=n.channel_type;return a&&d("object",a)&&d("number",i)&&d("string",r)&&d("string",l)&&(s.threadInfo=new te(e,a),s.targetMessageId=i,s.channelUrl=r,s.channelType=l),s}return e(n,t),n}(u),We={channelUrl:null,channelType:null,messageId:0,includeReactions:!1,includeMetaArray:!1,includeParentMessageInfo:!1,includeThreadInfo:!1},Ke=function(n){function s(e){var s=e.channelCustomType,a=e.keyword,i=e.limit,r=e.reverse,l=e.exactMatch,u=e.channelUrl,o=e.order,d=e.messageTimestampFrom,c=e.messageTimestampTo,h=e.advancedQuery,p=e.targetFields,m=e.nextToken,g=n.call(this)||this;return g.method=t.GET,g.path="".concat(V,"/messages"),g.params={custom_type:s,query:a,limit:i,reverse:r,exact_match:l,channel_url:u,message_ts_from:d,message_ts_to:c,sort_field:o,advanced_query:h,target_fields:p,after:m},g}return e(s,n),s}(a),Ve=function(t){function n(e,n){var s=t.call(this,e,n)||this;return s.messages=n.results.map((function(t){return Me(e,t)})),s.hasNext=n.has_next,s.nextToken=n.end_cursor,s.totalCount=n.total_count,s}return e(n,t),n}(i);!function(e){e.SCORE="score",e.TIMESTAMP="ts"}(we||(we={}));var Xe=function(t){function n(e,n){var s,a,i,r,l,u,o,d,c,h=this;return(h=t.call(this,e,n)||this).keyword="",h.reverse=!1,h.exactMatch=!1,h.channelUrl="",h.channelCustomType="",h.messageTimestampFrom=null,h.messageTimestampTo=null,h.order=we.SCORE,h.advancedQuery=!1,h.targetFields=null,h._nextToken="",h.totalCount=-1,h.keyword=n.keyword,h.reverse=null!==(s=n.reverse)&&void 0!==s&&s,h.exactMatch=null!==(a=n.exactMatch)&&void 0!==a&&a,h.channelUrl=null!==(i=n.channelUrl)&&void 0!==i?i:"",h.channelCustomType=null!==(r=n.channelCustomType)&&void 0!==r?r:"",h.messageTimestampFrom=null!==(l=n.messageTimestampFrom)&&void 0!==l?l:null,h.messageTimestampTo=null!==(u=n.messageTimestampTo)&&void 0!==u?u:null,h.order=null!==(o=n.order)&&void 0!==o?o:we.SCORE,h.advancedQuery=null!==(d=n.advancedQuery)&&void 0!==d&&d,h.targetFields=null!==(c=n.targetFields)&&void 0!==c?c:null,h}return e(n,t),n.prototype._validate=function(){return t.prototype._validate.call(this)&&d("string",this.keyword)&&this.keyword.length>0&&d("boolean",this.reverse)&&d("boolean",this.exactMatch)&&d("string",this.channelUrl)&&d("string",this.channelCustomType)&&(d("number",this.messageTimestampFrom)||null===this.messageTimestampFrom)&&(d("number",this.messageTimestampTo)||null===this.messageTimestampTo)&&c(we,this.order)&&d("boolean",this.advancedQuery)&&o("string",this.targetFields,!0)},n.prototype.next=function(){return b(this,void 0,void 0,(function(){var e,t,n,s,a,i,l,u;return A(this,(function(o){switch(o.label){case 0:return this._validate()?this._isLoading?[3,3]:this._hasNext?(this._isLoading=!0,e=D.of(this._iid).requestQueue,t=new Ke(r(r({},this),{nextToken:this._nextToken?this._nextToken:null})),[4,e.send(t)]):[3,2]:[3,5];case 1:return n=o.sent(),s=n.as(Ve),a=s.messages,i=s.hasNext,l=s.nextToken,u=s.totalCount,this._nextToken=l,this._hasNext=i,this._isLoading=!1,this.totalCount=u,[2,a];case 2:return[2,[]];case 3:throw U.queryInProgress;case 4:return[3,6];case 5:throw U.invalidParameters;case 6:return[2]}}))}))},n}(X),Ye=function(t){function n(e,n,s,a){var i,r,l,u,o,d,c,h,p,m,g=this;return(g=t.call(this,e,n,s,a)||this).reverse=!1,g.messageTypeFilter=S.ALL,g.customTypesFilter=null,g.senderUserIdsFilter=null,g.replyType=Q.NONE,g.includeMetaArray=!1,g.includeReactions=!1,g.includeParentMessageInfo=!1,g.includeThreadInfo=!1,g.showSubchannelMessagesOnly=!1,g._edge=Number.MAX_SAFE_INTEGER,g.reverse=null!==(i=a.reverse)&&void 0!==i&&i,g.messageTypeFilter=null!==(r=a.messageTypeFilter)&&void 0!==r?r:S.ALL,g.customTypesFilter=null!==(l=a.customTypesFilter)&&void 0!==l?l:null,g.senderUserIdsFilter=null!==(u=a.senderUserIdsFilter)&&void 0!==u?u:null,g.replyType=null!==(o=a.replyType)&&void 0!==o?o:Q.NONE,g.includeMetaArray=null!==(d=a.includeMetaArray)&&void 0!==d&&d,g.includeReactions=null!==(c=a.includeReactions)&&void 0!==c&&c,g.includeParentMessageInfo=null!==(h=a.includeParentMessageInfo)&&void 0!==h&&h,g.includeThreadInfo=null!==(p=a.includeThreadInfo)&&void 0!==p&&p,g.showSubchannelMessagesOnly=null!==(m=a.showSubchannelMessagesOnly)&&void 0!==m&&m,g}return e(n,t),n.prototype._validate=function(){return t.prototype._validate.call(this)&&d("boolean",this.reverse)&&c(S,this.messageTypeFilter)&&c(Q,this.replyType)&&o("string",this.customTypesFilter,!0)&&o("string",this.senderUserIdsFilter,!0)&&d("boolean",this.includeMetaArray)&&d("boolean",this.includeReactions)&&d("boolean",this.includeParentMessageInfo)&&d("boolean",this.includeThreadInfo)&&d("boolean",this.showSubchannelMessagesOnly)},n.prototype.load=function(){return b(this,void 0,void 0,(function(){var e;return A(this,(function(t){switch(t.label){case 0:return this._validate()?this._isLoading?[3,3]:this._hasNext?(this._isLoading=!0,[4,Be.of(this._iid).getMessagesByTimestamp(this.channelUrl,this.channelType,this._edge,{prevResultSize:this.limit,nextResultSize:0,isInclusive:!1,reverse:this.reverse,messageTypeFilter:this.messageTypeFilter,customTypesFilter:this.customTypesFilter,replyType:this.replyType,senderUserIdsFilter:this.senderUserIdsFilter,includeReactions:this.includeReactions,includeMetaArray:this.includeMetaArray,includeParentMessageInfo:this.includeParentMessageInfo,includeThreadInfo:this.includeThreadInfo,showSubchannelMessagesOnly:this.showSubchannelMessagesOnly})]):[3,2]:[3,5];case 1:return e=t.sent(),this._edge=Math.min.apply(Math,h([Number.MAX_SAFE_INTEGER],p(e.map((function(e){return e.createdAt}))),!1)),this._hasNext=e.length>=this.limit,this._isLoading=!1,[2,e];case 2:return[2,[]];case 3:throw U.queryInProgress;case 4:return[3,6];case 5:throw U.invalidParameters;case 6:return[2]}}))}))},n}(Y),Ze={channelUrl:null,scheduledMessageId:0},$e=function(t){function n(){var e=null!==t&&t.apply(this,arguments)||this;return e.name="message",e}return e(n,t),n.prototype.init=function(e,n){var s=n.sdkState,a=n.dispatcher,i=n.sessionManager,r=n.requestQueue,l=n.logger,u=n.onlineDetector,o=n.cacheContext;t.prototype.init.call(this,e,{sdkState:s,dispatcher:a,sessionManager:i,requestQueue:r,logger:l,onlineDetector:u,cacheContext:o}),this._manager=new Be(e,{sdkState:s,dispatcher:a,requestQueue:r,onlineDetector:u,cacheContext:o})},n.prototype.buildMessageFromSerializedData=function(e){return this._manager.buildMessageFromSerializedData(e)},n.prototype.buildSenderFromSerializedData=function(e){return this._manager.buildSenderFromSerializedData(e)},n.prototype.getMessage=function(e){return b(this,void 0,void 0,(function(){var t;return A(this,(function(n){return t=r(r({},We),e),E(function(e){return d("string",e.channelUrl)&&d("string",e.channelType)&&c(_,e.channelType)&&d("number",e.messageId)&&d("boolean",e.includeMetaArray)&&d("boolean",e.includeParentMessageInfo)&&d("boolean",e.includeThreadInfo)}(t)).throw(U.invalidParameters),[2,this._manager.getMessage(t)]}))}))},n.prototype.getScheduledMessage=function(e){return b(this,void 0,void 0,(function(){var t;return A(this,(function(n){return t=r(r({},Ze),e),E(function(e){return d("string",e.channelUrl)&&d("number",e.scheduledMessageId)}(t)).throw(U.invalidParameters),[2,this._manager.getScheduledMessage(t)]}))}))},n}(Z);export{oe as A,he as B,Se as F,se as I,$e as M,le as O,ve as P,ae as R,me as S,ge as T,Ie as U,Xe as a,Be as b,re as c,Ye as d,pe as e,je as f,qe as g,Ce as h,Ne as i,ne as j,Ee as k,Te as l,ee as m,J as n,_e as o,Me as p,He as q,we as r,ue as s,ie as t,$ as u,Fe as v,te as w}; +import{_ as e,A as t,T as n,e as s,f as a,h as i,g as r,U as l,X as u,l as o,a as d,I as c,p as h,q as p,H as m,Y as g,Z as y,$ as f,M as _,a0 as v,R as I,a1 as T,a2 as M,a3 as S,b,c as A,r as E,S as U,a4 as w,V as D,a5 as q,a6 as F,a7 as C,a8 as N,W as R,t as P,w as O,a9 as k,aa as L,i as x,ab as z,ac as Q,ad as G,s as B,ae as j,af as H,ag as W,n as K,ah as V,B as X,ai as Y,aj as Z}from"./__bundle-ea43c8a8.js";var $,J=function(a){function i(e){var i=a.call(this)||this;if(i.method=t.POST,i.path="".concat(n),i.params=s({file:e.file,channel_url:e.channelUrl}),e.thumbnailSizes)for(var r=0;r0&&d("number",r)&&(this.key=a,this.userIds=i,this.updatedAt=r);var l={};try{for(var u=m(this.userIds),c=u.next();!c.done;c=u.next()){l[c.value]=this.updatedAt}}catch(e){t={error:e}}finally{try{c&&!c.done&&(n=u.return)&&n.call(u)}finally{if(t)throw t.error}}this._version=l}return Object.defineProperty(e.prototype,"isEmpty",{get:function(){return 0===this.userIds.length},enumerable:!1,configurable:!0}),e.payloadify=function(e){return e?s({key:e.key,user_ids:e.userIds,updated_at:e.updatedAt}):null},e.prototype.applyEvent=function(e){if(e.key===this.key&&this.updatedAt<=e.updatedAt){if(!this._version[e.userId]||this._version[e.userId]<=e.updatedAt){var t=this.userIds.indexOf(e.userId);switch(e.operation){case $.ADD:t<0&&this.userIds.push(e.userId);break;case $.DELETE:t>=0&&this.userIds.splice(t,1)}this._version[e.userId]=e.updatedAt}this.updatedAt=Math.max(this.updatedAt,e.updatedAt)}},e}(),re=function(){function e(e){this.key=e.key,this.value=o("string",e.value)?h([],p(e.value),!1):[]}return e.payloadify=function(e){var t;return e?s({key:e.key,value:null!==(t=e.value)&&void 0!==t?t:[]}):null},e}(),le=function(){function e(e){this.url=null,this.secureUrl=null,this.type=null,this.width=0,this.height=0,this.alt=null,this.url=e.url,e.hasOwnProperty("secure_url")&&(this.secureUrl=e.secure_url),e.hasOwnProperty("type")&&(this.type=e.type),e.hasOwnProperty("width")&&(this.width=e.width),e.hasOwnProperty("height")&&(this.height=e.height),e.hasOwnProperty("alt")&&(this.alt=e.alt)}return e.payloadify=function(e){var t,n;return e?s({url:e.url,secure_url:e.secureUrl,type:e.type,width:null!==(t=e.width)&&void 0!==t?t:0,height:null!==(n=e.height)&&void 0!==n?n:0,alt:e.alt}):null},e}(),ue=function(){function e(e){this.title=null,this.url=null,this.description=null,this.defaultImage=null,e.hasOwnProperty("og:title")&&(this.title=e["og:title"]),e.hasOwnProperty("og:url")&&(this.url=e["og:url"]),e.hasOwnProperty("og:description")&&(this.description=e["og:description"]),e.hasOwnProperty("og:image")&&(this.defaultImage=new le(e["og:image"]))}return e.payloadify=function(e){return e?s({"og:title":e.title,"og:url":e.url,"og:description":e.description,"og:image":e.defaultImage?le.payloadify(e.defaultImage):null}):null},e}(),oe=function(){function e(e){var t,n;this.name=null,this.volume=0,this.name=null!==(t=e.name)&&void 0!==t?t:"default",this.volume=null!==(n=e.volume)&&void 0!==n?n:1}return e.prototype.serialize=function(){return{name:this.name,volume:this.volume}},e.payloadify=function(e){return e?s({name:e.name,volume:e.volume}):null},e}();!function(e){e.PENDING="pending",e.SENT="sent",e.FAILED="failed",e.CANCELED="canceled"}(ne||(ne={})),function(e){e.PENDING="pending",e.IN_QUEUE="in_queue",e.SENT="sent",e.FAILED="failed",e.CANCELED="canceled",e.REMOVED="removed"}(se||(se={}));var de,ce=function(e){switch(e){case y.BASE:return"";case y.USER:return"MESG";case y.FILE:return"FILE";case y.ADMIN:return"ADMM"}},he=function(t){function n(e,n){var s,a,i,r,u,o,d,h,p,m,g,f,I,T,M,S=this;(S=t.call(this,e)||this).channelUrl=null,S.channelType=_.BASE,S.messageId=0,S.parentMessageId=null,S.parentMessage=null,S.silent=!1,S.isOperatorMessage=!1,S.messageType=y.BASE,S.data=null,S.customType=null,S.mentionType=null,S.mentionedUsers=[],S.mentionedUserIds=[],S.mentionedMessageTemplate=null,S.threadInfo=null,S.reactions=[],S.metaArrays=[],S.ogMetaData=null,S.appleCriticalAlertOptions=null,S.createdAt=0,S.updatedAt=0,S.scheduledInfo=null,S.extendedMessage={},S._isContinuousMessages=!1,S._scheduledStatus=null,S.messageId=null!==(a=null!==(s=n.msg_id)&&void 0!==s?s:n.message_id)&&void 0!==a?a:0,S.channelUrl=n.channel_url,S.channelType=c(_,n.channel_type)?n.channel_type:_.GROUP,n.channel&&(n.channel.channel_url&&(S.channelUrl=n.channel.channel_url),n.channel.channel_type&&(S.channelType=n.channel.channel_type)),S.parentMessageId=null!==(i="string"==typeof n.parent_message_id?parseInt(n.parent_message_id):n.parent_message_id)&&void 0!==i?i:0,S.data=null!==(r=n.data)&&void 0!==r?r:"",S.customType=null!==(u=n.custom_type)&&void 0!==u?u:"",S.mentionType=c(v,n.mention_type)?n.mention_type:null;var b=n.mentioned_users;S.mentionedUsers=b?b.map((function(e){return new l(S._iid,e)})):null;var A=n.mentioned_user_ids;S.mentionedUserIds=null!=A?A:null,S.mentionedUsers&&!S.mentionedUserIds&&(S.mentionedUserIds=S.mentionedUsers.map((function(e){return e.userId}))),S.mentionedMessageTemplate=null!==(o=n.mentioned_message_template)&&void 0!==o?o:"",S.threadInfo=n.thread_info?new te(S._iid,n.thread_info):null,S.reactions=n.reactions?n.reactions.map((function(e){return new ie(e)})):[];for(var E=null!==(d=n.metaarray)&&void 0!==d?d:{},U=null!==(h=n.metaarray_key_order)&&void 0!==h?h:Object.keys(E).sort((function(e,t){return e.localeCompare(t)})),w=0;w=t)return this.parentMessage=e,!0}return!1},n}(u),pe=function(t){function n(e,n){var s=t.call(this,e,n)||this;return s.role=null,s.isBlockedByMe=!1,s.role=c(I,n.role)?n.role:I.NONE,n.hasOwnProperty("is_blocked_by_me")&&(s.isBlockedByMe=n.is_blocked_by_me),s}return e(n,t),n.payloadify=function(e){return e?s(r(r({},t.payloadify.call(this,e)),{role:e.role,is_blocked_by_me:e.isBlockedByMe})):null},n}(l),me=function(t){function n(e,n){var s,a,i,r,l=this;if((l=t.call(this,e,n)||this).sender=null,l.reqId="",l.replyToChannel=!1,l.sendingStatus=null,l.errorCode=0,l.sender=n.user?new pe(l._iid,n.user):n.sender_id,l.reqId=null!==(a=null!==(s=n.req_id)&&void 0!==s?s:n.request_id)&&void 0!==a?a:"",l.replyToChannel=null!==(i=n.is_reply_to_channel)&&void 0!==i&&i,n.request_state&&c(T,n.request_state)&&(l.sendingStatus=n.request_state),!l.sendingStatus)if(l.messageId>0)l.sendingStatus=T.SUCCEEDED;else if(l.scheduledInfo)switch(l._scheduledStatus=n.scheduled_status,n.scheduled_status){case se.SENT:case se.IN_QUEUE:l.sendingStatus=T.SUCCEEDED;break;case se.PENDING:l.sendingStatus=T.SCHEDULED;break;case se.FAILED:case se.REMOVED:l.sendingStatus=T.FAILED;break;case se.CANCELED:l.sendingStatus=T.CANCELED}else l.sendingStatus=T.PENDING;return l.errorCode=null!==(r=n.error_code)&&void 0!==r?r:0,l}return e(n,t),n.payloadify=function(e){return e?s(r(r({},t.payloadify.call(this,e)),{user:pe.payloadify(e.sender),req_id:e.reqId,is_reply_to_channel:e.replyToChannel,request_state:e.sendingStatus,error_code:e.errorCode})):null},Object.defineProperty(n.prototype,"isResendable",{get:function(){return this.sendingStatus===T.FAILED&&M(this.errorCode)},enumerable:!1,configurable:!0}),n.prototype.isIdentical=function(e){return this.messageId>0&&e.messageId>0?this.messageId===e.messageId:this.reqId===e.reqId},n}(he),ge=function(){function e(e){var t,n;this.url=null,this.width=0,this.height=0,this.realWidth=0,this.realHeight=0,this.url=e.url,this.width=e.width,this.height=e.height,this.realWidth=null!==(t=e.real_width)&&void 0!==t?t:e.width,this.realHeight=null!==(n=e.real_height)&&void 0!==n?n:e.height}return e.payloadify=function(e){return e?s({url:"",width:e.maxWidth,height:e.maxHeight,real_width:0,real_height:0}):null},Object.defineProperty(e.prototype,"plainUrl",{get:function(){return this.url.split("?auth=")[0]},enumerable:!1,configurable:!0}),e}(),ye={prevResultSize:0,nextResultSize:0,isInclusive:!1,reverse:!1,messageTypeFilter:S.ALL,customTypesFilter:null,senderUserIdsFilter:null,includeReactions:!1,includeMetaArray:!1,includeParentMessageInfo:!1},fe=function(e){return d("number",e.prevResultSize)&&d("number",e.nextResultSize)&&d("boolean",e.isInclusive)&&d("boolean",e.reverse)&&d("string",e.messageTypeFilter)&&c(S,e.messageTypeFilter)&&o("string",e.customTypesFilter,!0)&&o("string",e.senderUserIdsFilter,!0)&&d("boolean",e.includeMetaArray)&&d("boolean",e.includeReactions)&&d("boolean",e.includeParentMessageInfo)},_e=function(t){function n(e,n){var s,a,i,l,u=this;if((u=t.call(this,e,n)||this).message=null,u.translations={},u.message=null!==(s=n.message)&&void 0!==s?s:"",u.messageType=y.ADMIN,u.translations=null!==(a=n.translations)&&void 0!==a?a:{},n.parent_message_info){var o=n.parent_message_info,d=r(r({},o),{message_id:u.parentMessageId,channel_url:u.channelUrl,channel_type:u.channelType,file:o.file,url:null===(i=o.file)||void 0===i?void 0:i.url,require_auth:null===(l=o.file)||void 0===l?void 0:l.require_auth});u.parentMessage=Me(e,d)}return u}return e(n,t),n.payloadify=function(e){return e?s(r(r({},t.payloadify.call(this,e)),{message:e.message,translations:e.translations,parent_message_info:Te(e.parentMessage)})):null},n.prototype.getThreadedMessagesByTimestamp=function(e,t){return b(this,void 0,void 0,(function(){var n;return A(this,(function(s){switch(s.label){case 0:return n=r(r({},ye),t),E(this.messageId>0&&d("number",e)&&fe(n)).throw(U.invalidParameters),[4,Be.of(this._iid).getThreadedMessagesByTimestamp(this,e,n)];case 1:return[2,s.sent()]}}))}))},n}(he),ve=function(){function e(e){var t,n;this.type=null,this.vendor=null,this.detail={},this.type=null!==(t=e.type)&&void 0!==t?t:"",this.vendor=null!==(n=e.vendor)&&void 0!==n?n:"",e.hasOwnProperty("detail")&&d("object",e.detail)&&!Array.isArray(e.detail)&&(this.detail=e.detail)}return e.payloadify=function(e){return e?s({type:e.type,vendor:e.vendor,detail:e.detail}):null},e}(),Ie=function(t){function n(e,n){var a,i,l,u,o,d,c,h=this;if((h=t.call(this,e,n)||this).message="",h.messageParams=null,h.translations={},h.translationTargetLanguages=[],h.messageSurvivalSeconds=-1,h.plugins=[],h._poll=null,h.message=n.message,h.messageType=y.USER,h.translations=null!==(l=n.translations)&&void 0!==l?l:{},h.translationTargetLanguages=null!==(u=n.target_langs)&&void 0!==u?u:[],0===Object.keys(h.translations).length&&h.translationTargetLanguages.length>0)try{for(var p=m(h.translationTargetLanguages),g=p.next();!g.done;g=p.next()){var f=g.value;h.translations[f]=""}}catch(e){a={error:e}}finally{try{g&&!g.done&&(i=p.return)&&i.call(p)}finally{if(a)throw a.error}}if(h.messageSurvivalSeconds=null!==(o=n.message_survival_seconds)&&void 0!==o?o:-1,h.plugins=n.plugins?n.plugins.map((function(e){return new ve(e)})):[],h._poll=n.poll?new w(h._iid,n.poll):null,n.parent_message_info){var _=n.parent_message_info,v=r(r({},_),{created_at:_.ts,message_id:h.parentMessageId,channel_url:h.channelUrl,channel_type:h.channelType,file:_.file,url:null===(d=_.file)||void 0===d?void 0:d.url,require_auth:null===(c=_.file)||void 0===c?void 0:c.require_auth});h.parentMessage=Me(e,s(v))}return h}return e(n,t),n.payloadify=function(e){return e?s(r(r({},t.payloadify.call(this,e)),{message:e.message,translations:e.translations,message_survival_seconds:e.messageSurvivalSeconds,plugins:e.plugins.map((function(e){return ve.payloadify(e)})),poll:w.payloadify(e._poll),parent_message_info:Te(e.parentMessage)})):null},n.prototype.getThreadedMessagesByTimestamp=function(e,t){return b(this,void 0,void 0,(function(){var n;return A(this,(function(s){switch(s.label){case 0:return n=r(r({},ye),t),E(this.messageId>0&&d("number",e)&&fe(n)).throw(U.invalidParameters),[4,Be.of(this._iid).getThreadedMessagesByTimestamp(this,e,n)];case 1:return[2,s.sent()]}}))}))},n.prototype.applyPoll=function(e){return!(this._poll&&this._poll.id===e.id&&this._poll.updatedAt>e.updatedAt)&&(this._poll=e,!0)},Object.defineProperty(n.prototype,"poll",{get:function(){return this._poll},enumerable:!1,configurable:!0}),n}(me),Te=function(e){if(e)switch(e.messageType){case y.USER:return Ie.payloadify(e);case y.FILE:return Se.payloadify(e);case y.ADMIN:return _e.payloadify(e)}return null},Me=function(e,t){switch(t.type){case"MESG":return new Ie(e,t);case"FILE":return new Se(e,t);case"ADMM":case"BRDM":return new _e(e,t)}return null},Se=function(t){function n(e,n){var s,a,i,l,u,o,d,c,h,p,m,g,f,_,v,I=this;(I=t.call(this,e,n)||this).messageParams=null,I.plainUrl="",I.requireAuth=!1,I.name=null,I.size=0,I.type=null,I.thumbnails=[],I.messageSurvivalSeconds=-1,I.messageType=y.FILE;var T=null!==(s=n.file)&&void 0!==s?s:null;I.plainUrl=(null!==(i=null!==(a=null==T?void 0:T.url)&&void 0!==a?a:n.url)&&void 0!==i?i:"").split("?auth=")[0],I.name=null!==(u=null!==(l=null==T?void 0:T.name)&&void 0!==l?l:n.name)&&void 0!==u?u:"File",I.size=null!==(d=null!==(o=null==T?void 0:T.size)&&void 0!==o?o:n.size)&&void 0!==d?d:0,I.data=null!==(h=null!==(c=null==T?void 0:T.data)&&void 0!==c?c:n.custom)&&void 0!==h?h:"",I.type=T?null!==(p=T.type)&&void 0!==p?p:"":null!==(m=n.type)&&void 0!==m?m:"";var M=D.of(I._iid).sessionManager;if(I.requireAuth=null!==(g=n.require_auth)&&void 0!==g&&g,I.thumbnails=n.thumbnails?n.thumbnails.map((function(e){return new ge(r(r({},e),{url:"".concat(e.url.split("?auth=")[0]).concat(I.requireAuth?"?auth=".concat(M.ekey):"")}))})):[],I.messageSurvivalSeconds=null!==(f=n.message_survival_seconds)&&void 0!==f?f:-1,n.parent_message_info){var S=n.parent_message_info,b=r(r({},S),{message_id:I.parentMessageId,channel_url:I.channelUrl,channel_type:I.channelType,file:S.file,url:null===(_=S.file)||void 0===_?void 0:_.url,require_auth:null===(v=S.file)||void 0===v?void 0:v.require_auth});I.parentMessage=Me(e,b)}return I}return e(n,t),n.payloadify=function(e){return e?s(r(r({},t.payloadify.call(this,e)),{url:e.plainUrl,require_auth:e.requireAuth,file:{name:e.name,size:e.size,type:e.type,data:e.data},thumbnails: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:Te(e.parentMessage)})):null},Object.defineProperty(n.prototype,"url",{get:function(){var e=D.of(this._iid).sessionManager;return this.requireAuth?"".concat(this.plainUrl,"?auth=").concat(e.ekey):this.plainUrl},enumerable:!1,configurable:!0}),n.prototype.getThreadedMessagesByTimestamp=function(e,t){return b(this,void 0,void 0,(function(){var n;return A(this,(function(s){switch(s.label){case 0:return n=r(r({},ye),t),E(this.messageId>0&&d("number",e)&&fe(n)).throw(U.invalidParameters),[4,Be.of(this._iid).getThreadedMessagesByTimestamp(this,e,n)];case 1:return[2,s.sent()]}}))}))},n}(me),be=function(t){function n(e){var n,a,i,r=[];return e.mentionType===v.USERS&&(e.mentionedUserIds?r=e.mentionedUserIds:e.mentionedUsers&&(r=e.mentionedUsers.map((function(e){return e.userId})))),t.call(this,{code:"FILE",ackRequired:!0,payload:s({channel_url:e.channelUrl,url:e.url,name:null!==(n=e.fileName)&&void 0!==n?n:"",type:null!==(a=e.mimeType)&&void 0!==a?a:"",size:null!==(i=e.fileSize)&&void 0!==i?i:0,custom:e.data,custom_type:e.customType,thumbnails:e.thumbnailSizes,require_auth:e.requireAuth,metaarray:e.metaArrays,mention_type:e.mentionType,mentioned_user_ids:r,push_option:e.pushNotificationDeliveryOption&&e.pushNotificationDeliveryOption!==q.DEFAULT?e.pushNotificationDeliveryOption:void 0,apple_critical_alert_options:e.appleCriticalAlertOptions,silent:e.silent,reply_to_channel:e.isReplyToChannel,parent_message_id:e.parentMessageId>0?e.parentMessageId:null,req_id:e.reqId,pin_message:e.isPinnedMessage})})||this}return e(n,t),n}(F),Ae=function(n){function a(e){var a,i=this;i=n.call(this)||this;var r=[];return e.mentionType===v.USERS&&(e.mentionedUserIds?r=e.mentionedUserIds:e.mentionedUsers&&(r=e.mentionedUsers.map((function(e){return e.userId})))),i.method=t.POST,i.path="".concat(C(e.channelType),"/").concat(encodeURIComponent(e.channelUrl),"/messages"),i.params=s({message_type:y.FILE,user_id:e.userId,url:e.fileUrl,mention_type:e.mentionType,mentioned_user_ids:r,file_name:e.fileName,file_size:e.fileSize,file_type:e.mimeType,data:e.data,custom_type:e.customType,thumbnails:e.thumbnailSizes.map((function(e){return ge.payloadify(e)})),require_auth:e.requireAuth,sorted_metaarray:null===(a=e.metaArrays)||void 0===a?void 0:a.map((function(e){return re.payloadify(e)})),push_option:e.pushNotificationDeliveryOption,parent_message_id:e.parentMessageId>0?e.parentMessageId:null,apple_critical_alert_options:oe.payloadify(e.appleCriticalAlertOptions),reply_to_channel:e.isReplyToChannel,req_id:e.reqId,pin_message:e.isPinnedMessage}),i}return e(a,n),a}(a),Ee=function(t){function n(e,n,s){var a,i,r,l=this;(l=t.call(this,e,"FILE",s)||this).message=new Se(e,s);var u=D.of(e).sdkState;return l.isMentioned=N(l.message.mentionType,null!==(a=l.message.mentionedUserIds)&&void 0!==a?a:null===(i=l.message.mentionedUsers)||void 0===i?void 0:i.map((function(e){return e.userId})),u.userId),l.forceUpdateLastMessage=null!==(r=s.force_update_last_message)&&void 0!==r&&r,l}return e(n,t),n}(R),Ue=function(t){function n(e,n){var s,a,i=this;(i=t.call(this,e,n)||this).message=new Se(e,n);var r=D.of(e).sdkState;return i.isMentioned=N(i.message.mentionType,null!==(s=i.message.mentionedUserIds)&&void 0!==s?s:i.message.mentionedUsers.map((function(e){return e.userId})),r.userId),i.forceUpdateLastMessage=null!==(a=n.force_update_last_message)&&void 0!==a&&a,i}return e(n,t),n}(i);!function(e){e[e.PENDING=0]="PENDING",e[e.UPLOADING=1]="UPLOADING",e[e.UPLOADED=2]="UPLOADED",e[e.SENDING=3]="SENDING",e[e.FAILED=4]="FAILED"}(de||(de={}));var we,De=function(){function e(e,t){var n=t.sdkState,s=t.dispatcher,a=t.requestQueue,i=t.onlineDetector,r=t.cacheContext,l=this;this._queueMap=new Map,this._connectionState=null,this._onlineDetector=null,this._iid=e,this._sdkState=n,this._requestQueue=a,this._cacheContext=r,this._dispatcher=s,this._dispatcher.on((function(e){e instanceof P&&(l._connectionState=e.stateType)})),this._onlineDetector=i}return Object.defineProperty(e.prototype,"_shouldSendThroughWebSocket",{get:function(){return this._connectionState===O.CONNECTED||this._connectionState===O.CONNECTING||this._connectionState===O.RECONNECTING},enumerable:!1,configurable:!0}),e.prototype._sendFileMessage=function(e,t){return b(this,void 0,void 0,(function(){var n,s;return A(this,(function(a){switch(a.label){case 0:return this._shouldSendThroughWebSocket?(n=new be(r(r({},t.params),{channelUrl:e.url,channelType:e.channelType,url:t.params.fileUrl,requireAuth:t.requireAuth,reqId:t.requestId})),[4,this._requestQueue.send(n)]):[3,2];case 1:return s=a.sent(),[2,s.as(Ee).message];case 2:return n=new Ae(r(r({},t.params),{channelUrl:e.url,channelType:e.channelType,url:t.params.fileUrl,userId:this._sdkState.userId,requireAuth:t.requireAuth,reqId:t.requestId})),[4,this._requestQueue.send(n)];case 3:return s=a.sent(),[2,s.as(Ue).message]}}))}))},e.prototype._resolveMessageQueue=function(e){return b(this,void 0,void 0,(function(){var t,n,s,a,i,r,l,u,o,d,c,h;return A(this,(function(p){switch(p.label){case 0:if(!(t=this._queueMap.get(e.url)))return[3,21];if(t.isResolving)return[3,20];t.isResolving=!0,n=[],s=!0,p.label=1;case 1:p.trys.push([1,15,16,17]),a=m(t.messageQueue),i=a.next(),p.label=2;case 2:if(i.done)return[3,14];switch(r=i.value,r.state){case de.PENDING:case de.UPLOADING:return[3,3];case de.UPLOADED:return[3,4];case de.FAILED:return[3,12]}return[3,13];case 3:return s=!1,n.push(r),[3,13];case 4:if(!s)return[3,10];p.label=5;case 5:return p.trys.push([5,8,,9]),r.state=de.SENDING,[4,this._sendFileMessage(e,r)];case 6:return l=p.sent(),r.deferred.resolve(l),[4,L(100)];case 7:return p.sent(),[3,9];case 8:return u=p.sent(),r.deferred.reject(u),[3,9];case 9:return[3,11];case 10:n.push(r),p.label=11;case 11:return[3,13];case 12:return r.deferred.reject(r.error.code===k.REQUEST_CANCELED?U.fileUploadCanceled:r.error),[3,13];case 13:return i=a.next(),[3,2];case 14:return[3,17];case 15:return o=p.sent(),c={error:o},[3,17];case 16:try{i&&!i.done&&(h=a.return)&&h.call(a)}finally{if(c)throw c.error}return[7];case 17:return d=t.isResolveRequestPending,t.messageQueue=n,t.isResolving=!1,t.isResolveRequestPending=!1,d?[4,this._resolveMessageQueue(e)]:[3,19];case 18:p.sent(),p.label=19;case 19:return[3,21];case 20:t.isResolveRequestPending=!0,p.label=21;case 21:return[2]}}))}))},e.prototype._uploadNextPendingItem=function(e){return b(this,void 0,void 0,(function(){var t,n,s,a,i,r,l,u,o,d,c,h,p,m;return A(this,(function(g){switch(g.label){case 0:return t=this._queueMap.get(e.url),(n=t.messageQueue.find((function(e){return e.state===de.PENDING})))?x(n.params.file)?t.uploadQueue.length<6?(n.state=de.UPLOADING,t.uploadQueue.push(n),[4,this._onlineDetector.isOnline()]):[3,10]:[3,11]:[3,13];case 1:if(!g.sent())return[3,8];g.label=2;case 2:return g.trys.push([2,4,5,7]),s=new J({file:n.params.file,channelUrl:e.url,thumbnailSizes:n.params.thumbnailSizes,requestId:n.requestId}),[4,this._requestQueue.send(s)];case 3:return a=g.sent(),i=a.as(ee),r=i.url,l=i.fileSize,u=void 0===l?n.params.fileSize:l,o=i.thumbnailSizes,d=void 0===o?n.params.thumbnailSizes:o,c=i.requireAuth,h=void 0!==c&&c,n.params.fileUrl=r,n.params.fileSize=u,n.params.thumbnailSizes=d,n.params.requireAuth=h,n.requireAuth=h,n.state=de.UPLOADED,[3,7];case 4:return(p=g.sent()).code===k.REQUEST_FAILED?n.error=new U({code:k.NETWORK_ERROR,message:"Failed to upload a file."}):n.error=p,n.state=de.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 g.sent(),[7];case 7:return[3,10];case 8:return n.state=de.FAILED,n.error=U.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:g.sent(),g.label=10;case 10:return[3,13];case 11:return n.params.thumbnailSizes=[],n.state=de.UPLOADED,[4,this._resolveMessageQueue(e)];case 12:g.sent(),g.label=13;case 13:return[2]}}))}))},e.prototype.request=function(e,t,n){var s,a,i;return b(this,void 0,void 0,(function(){var r;return A(this,(function(l){return r=new z,x(n.file)&&(n.fileName=null!==(s=n.fileName)&&void 0!==s?s:n.file.name,n.mimeType=null!==(a=n.mimeType)&&void 0!==a?a:n.file.type,n.fileSize=null!==(i=n.fileSize)&&void 0!==i?i: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:de.PENDING,deferred:r,requireAuth:n.requireAuth}),this._uploadNextPendingItem(e),[2,r.promise]}))}))},e.prototype.cancel=function(e,t){var n,s;void 0===t&&(t=null);var a=this._queueMap.get(e.url);if(a){var i=t?[a.messageQueue.find((function(e){return e.requestId===t}))]:h([],p(a.messageQueue),!1);try{for(var r=m(i),l=r.next();!l.done;l=r.next()){var u=l.value;if(u)switch(u.state){case de.PENDING:u.state=de.FAILED,u.error=U.requestCanceled,this._resolveMessageQueue(e);break;case de.UPLOADING:this._requestQueue.cancel(u.requestId)}}}catch(e){n={error:e}}finally{try{l&&!l.done&&(s=r.return)&&s.call(r)}finally{if(n)throw n.error}}}},e}(),qe={prevResultSize:0,nextResultSize:0,isInclusive:!1,reverse:!1,messageTypeFilter:S.ALL,customTypesFilter:null,senderUserIdsFilter:null,replyType:Q.NONE,includeReactions:!1,includeMetaArray:!1,includeParentMessageInfo:!1,includeThreadInfo:!1,showSubchannelMessagesOnly:!1},Fe=function(e){return d("number",e.prevResultSize)&&d("number",e.nextResultSize)&&d("boolean",e.isInclusive)&&d("boolean",e.reverse)&&d("string",e.messageTypeFilter)&&c(S,e.messageTypeFilter)&&o("string",e.customTypesFilter,!0)&&o("string",e.senderUserIdsFilter,!0)&&c(Q,e.replyType)&&d("boolean",e.includeMetaArray)&&d("boolean",e.includeReactions)&&d("boolean",e.includeParentMessageInfo)&&d("boolean",e.includeThreadInfo)&&d("boolean",e.showSubchannelMessagesOnly)},Ce={replyType:Q.NONE,includeReactions:!1,includeThreadInfo:!1,includeMetaArray:!1,includeParentMessageInfo:!1},Ne=function(e){return c(Q,e.replyType)&&d("boolean",e.includeReactions)&&d("boolean",e.includeMetaArray)&&d("boolean",e.includeParentMessageInfo)&&d("boolean",e.includeThreadInfo)},Re=function(n){function s(e){var s=e.channelType,a=e.channelUrl,i=e.messageId,r=e.includeMetaArray,l=e.includeReactions,u=e.includeThreadInfo,o=e.includeParentMessageInfo,d=n.call(this)||this;return d.method=t.GET,d.path="".concat(C(s),"/").concat(encodeURIComponent(a),"/messages/").concat(encodeURIComponent(i)),d.params={is_sdk:!0,with_sorted_meta_array:r,include_reactions:l,include_thread_info:u,include_parent_message_info:o,include_poll_details:!0},d}return e(s,n),s}(a),Pe=function(t){function n(e,n){var s=t.call(this,e,n)||this;return s.message=n?Me(e,r({},n)):null,s}return e(n,t),n}(i),Oe=function(n){function a(e){var a=e.channelType,i=e.channelUrl,r=e.timestamp,l=void 0===r?null:r,u=e.token,o=void 0===u?null:u,d=e.prevResultSize,c=e.nextResultSize,h=e.isInclusive,p=e.reverse,m=e.messageTypeFilter,g=e.customTypesFilter,y=e.senderUserIdsFilter,f=e.replyType,_=e.includeMetaArray,v=e.includeReactions,I=e.parentMessageId,T=e.includeThreadInfo,M=e.includeParentMessageInfo,S=e.showSubchannelMessagesOnly,b=e.checkingContinuousMessages,A=n.call(this)||this;return A.method=t.GET,A.path="".concat(C(a),"/").concat(encodeURIComponent(i),"/messages"),A.params=s({is_sdk:!0,prev_limit:d,next_limit:c,include:h,reverse:p,message_ts:l,message_id:o,message_type:null!=m?m:null,custom_types:g,sender_ids:y,include_reply_type:f,with_sorted_meta_array:_,include_reactions:v,parent_message_id:I,include_thread_info:T,include_parent_message_info:M,show_subchannel_message_only:S,include_poll_details:!0,checking_continuous_messages:b}),A}return e(a,n),a}(a),ke=function(t){function n(e,n){var s=t.call(this,e,n)||this;return s.messages=n.messages.map((function(t){return Me(e,t)})),s}return e(n,t),n}(i),Le=function(n){function s(e){var s=e.channelType,a=e.channelUrl,i=e.timestamp,r=e.token,l=e.replyType,u=e.includeMetaArray,o=e.includeReactions,d=e.includeThreadInfo,c=e.includeParentMessageInfo,h=n.call(this)||this;return h.method=t.GET,h.path="".concat(C(s),"/").concat(encodeURIComponent(a),"/messages/changelogs"),h.params={change_ts:i,token:r,with_sorted_meta_array:u,include_reactions:o,include_thread_info:d,include_reply_type:l,include_parent_message_info:c,include_poll_details:!0},h}return e(s,n),s}(a),xe=function(t){function n(e,n){var s=t.call(this,e,n)||this;return s.updatedMessages=n.updated.map((function(t){return Me(e,t)})),s.deletedMessagesInfo=n.deleted.map((function(e){return{messageId:e.message_id,deletedAt:e.deleted_at}})),s.hasMore=n.has_more,s.nextToken=n.next,s}return e(n,t),n}(i),ze=function(n){function s(e){var s=e.channelUrl,a=e.scheduledMessageId,i=n.call(this)||this;return i.method=t.GET,i.path="".concat(G,"/").concat(encodeURIComponent(s),"/scheduled_messages/").concat(encodeURIComponent(a)),i.params={},i}return e(s,n),s}(a),Qe=function(t){function n(e,n){var s=t.call(this,e,n)||this;return s.message=n?Me(e,r({},n)):null,s}return e(n,t),n}(i),Ge={},Be=function(){function e(e,t){var n=t.sdkState,s=t.dispatcher,a=t.requestQueue,i=t.onlineDetector,r=t.cacheContext;this._iid=e,this._sdkState=n,this._requestQueue=a,this._dispatcher=s,this._cacheContext=r,this.fileMessageQueue=new De(e,{sdkState:n,dispatcher:s,requestQueue:a,onlineDetector:i,cacheContext:r}),Ge[e]=this}return e.of=function(e){return Ge[e]},e.prototype.buildMessageFromSerializedData=function(e){var t=B(e);switch(t.messageType){case y.USER:return new Ie(this._iid,Ie.payloadify(t));case y.FILE:return new Se(this._iid,Se.payloadify(t));case y.ADMIN:return new _e(this._iid,_e.payloadify(t))}return null},e.prototype.buildUserMessageCreateParamsFromSerializedData=function(e,t){return s({data:t.data,customType:t.customType,mentionType:t.mentionType,mentionedUserIds:t.mentionedUserIds,mentionedUsers:t.mentionedUsers,mentionedMessageTemplate:t.mentionedMessageTemplate,metaArrays:t.metaArrays,parentMessageId:t.parentMessageId,isReplyToChannel:e.isReplyToChannel,pushNotificationDeliveryOption:e.pushNotificationDeliveryOption,appleCriticalAlertOptions:t.appleCriticalAlertOptions,reqId:t.reqId,message:t.message,translationTargetLanguages:Object.keys(t.translations),pollId:e.pollId})},e.prototype.buildFileMessageCreateParamsFromSerializedData=function(e,t){return s({data:t.data,customType:t.customType,mentionType:t.mentionType,mentionedUserIds:t.mentionedUserIds,mentionedUsers:t.mentionedUsers,mentionedMessageTemplate:t.mentionedMessageTemplate,metaArrays:t.metaArrays,parentMessageId:t.parentMessageId,isReplyToChannel:e.isReplyToChannel,pushNotificationDeliveryOption:e.pushNotificationDeliveryOption,appleCriticalAlertOptions:t.appleCriticalAlertOptions,reqId:t.reqId,file:e.file,fileKey:e.fileKey,fileUrl:t.plainUrl,fileName:t.name,fileSize:t.size,mimeType:t.type,thumbnailSizes: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 r(r({},this.buildUserMessageCreateParamsFromSerializedData(e,t)),{scheduledAt:e.scheduledAt})},e.prototype.buildScheduledFileMessageCreateParamsFromSerializedData=function(e,t){return r(r({},this.buildFileMessageCreateParamsFromSerializedData(e,t)),{scheduledAt:e.scheduledAt})},e.prototype.buildSenderFromSerializedData=function(e){var t=B(e);return new pe(this._iid,pe.payloadify(t))},e.prototype.getMessage=function(e){return b(this,void 0,void 0,(function(){var t,n;return A(this,(function(s){switch(s.label){case 0:return t=new Re(e),[4,this._requestQueue.send(t)];case 1:return n=s.sent(),[2,n.as(Pe).message]}}))}))},e.prototype.getScheduledMessage=function(e){return b(this,void 0,void 0,(function(){var t,n;return A(this,(function(s){switch(s.label){case 0:return t=new ze(e),[4,this._requestQueue.send(t)];case 1:return n=s.sent(),[2,n.as(Qe).message]}}))}))},e.prototype.getMessagesByMessageId=function(e,t,n,s,a){return void 0===a&&(a=j.REQUEST_MESSAGE),b(this,void 0,void 0,(function(){var i,l,u;return A(this,(function(o){switch(o.label){case 0:return i=new Oe(r(r({channelType:t,channelUrl:e,token:String(n)},qe),s)),[4,this._requestQueue.send(i)];case 1:return l=o.sent(),u=l.as(ke).messages,this._dispatcher.dispatch(new H({messages:u,source:a})),[2,u]}}))}))},e.prototype.getMessagesByTimestamp=function(e,t,n,s,a){return void 0===a&&(a=j.REQUEST_MESSAGE),b(this,void 0,void 0,(function(){var i,l,u;return A(this,(function(o){switch(o.label){case 0:return i=new Oe(r(r({channelType:t,channelUrl:e,timestamp:n},qe),s)),[4,this._requestQueue.send(i)];case 1:return l=o.sent(),u=l.as(ke).messages,this._dispatcher.dispatch(new H({messages:u,source:a})),[2,u]}}))}))},e.prototype._getMessagesByTimestampForCollection=function(e,t,n,s,a,i){return void 0===a&&(a=j.REQUEST_MESSAGE),b(this,void 0,void 0,(function(){var l,u,o,d;return A(this,(function(c){switch(c.label){case 0:return l=new Oe(r(r(r({channelType:t,channelUrl:e,timestamp:n},qe),s),{checkingContinuousMessages:i})),[4,this._requestQueue.send(l)];case 1:return u=c.sent(),o=u.payload,d=u.as(ke).messages,this._dispatcher.dispatch(new H({messages:d,source:a})),[2,{messages:d,isContinuousMessages:o}]}}))}))},e.prototype.getThreadedMessagesByTimestamp=function(e,t,n,s){return void 0===s&&(s=j.REQUEST_THREADED_MESSAGE),b(this,void 0,void 0,(function(){var a,i,l,u;return A(this,(function(o){switch(o.label){case 0:return a=new Oe(r(r(r({channelUrl:e.channelUrl,channelType:e.channelType,timestamp:t},ye),n),{replyType:Q.ALL,parentMessageId:e.messageId,includeThreadInfo:!0})),[4,this._requestQueue.send(a)];case 1:return i=o.sent(),l=i.as(ke).messages,(u=l.slice(1)).forEach((function(t){t.parentMessage=e})),this._dispatcher.dispatch(new H({messages:u,source:s})),[2,{parentMessage:l[0],threadedMessages:u}]}}))}))},e.prototype.getMessageChangelogs=function(e,t,n,a,i){return void 0===i&&(i=j.REQUEST_MESSAGE_CHANGELOGS),b(this,void 0,void 0,(function(){var l,u,o,d,c,h,p,m;return A(this,(function(g){switch(g.label){case 0:return l=new Le(s(r(r({channelType:t,channelUrl:e,timestamp:"number"==typeof n?n:null,token:"string"==typeof n?n:null},Ce),a))),[4,this._requestQueue.send(l)];case 1:return u=g.sent(),o=u.as(xe),d=o.updatedMessages,c=o.deletedMessagesInfo,h=o.hasMore,p=o.nextToken,m=c.map((function(e){return e.messageId})),d.length>0&&this._dispatcher.dispatch(new H({messages:d,source:i})),m.length>0&&this._dispatcher.dispatch(new W({messageIds:m,source:i})),[2,{updatedMessages:d,deletedMessageIds:m,hasMore:h,token:p}]}}))}))},e}(),je=function(){function e(){this._onPending=K,this._onFailed=K,this._onSucceeded=K}return e.prototype._trigger=function(e,t){switch(t.sendingStatus){case T.PENDING:0===t.errorCode&&this._onPending(t);break;case T.FAILED:case T.CANCELED:this._onFailed(e,t.scheduledInfo?null:t);break;case T.SCHEDULED:case T.SUCCEEDED:this._onSucceeded(t)}},e.prototype.onPending=function(e){return this._onPending=e,this},e.prototype.onFailed=function(e){return this._onFailed=e,this},e.prototype.onSucceeded=function(e){return this._onSucceeded=e,this},e}(),He=function(t){function n(e,n){var s=t.call(this,e)||this;s.threadInfo=null,s.targetMessageId=0,s.channelUrl=null,s.channelType=null;var a=n.thread_info,i=n.parent_message_id,r=n.channel_url,l=n.channel_type;return a&&d("object",a)&&d("number",i)&&d("string",r)&&d("string",l)&&(s.threadInfo=new te(e,a),s.targetMessageId=i,s.channelUrl=r,s.channelType=l),s}return e(n,t),n}(u),We={channelUrl:null,channelType:null,messageId:0,includeReactions:!1,includeMetaArray:!1,includeParentMessageInfo:!1,includeThreadInfo:!1},Ke=function(n){function s(e){var s=e.channelCustomType,a=e.keyword,i=e.limit,r=e.reverse,l=e.exactMatch,u=e.channelUrl,o=e.order,d=e.messageTimestampFrom,c=e.messageTimestampTo,h=e.advancedQuery,p=e.targetFields,m=e.nextToken,g=n.call(this)||this;return g.method=t.GET,g.path="".concat(V,"/messages"),g.params={custom_type:s,query:a,limit:i,reverse:r,exact_match:l,channel_url:u,message_ts_from:d,message_ts_to:c,sort_field:o,advanced_query:h,target_fields:p,after:m},g}return e(s,n),s}(a),Ve=function(t){function n(e,n){var s=t.call(this,e,n)||this;return s.messages=n.results.map((function(t){return Me(e,t)})),s.hasNext=n.has_next,s.nextToken=n.end_cursor,s.totalCount=n.total_count,s}return e(n,t),n}(i);!function(e){e.SCORE="score",e.TIMESTAMP="ts"}(we||(we={}));var Xe=function(t){function n(e,n){var s,a,i,r,l,u,o,d,c,h=this;return(h=t.call(this,e,n)||this).keyword="",h.reverse=!1,h.exactMatch=!1,h.channelUrl="",h.channelCustomType="",h.messageTimestampFrom=null,h.messageTimestampTo=null,h.order=we.SCORE,h.advancedQuery=!1,h.targetFields=null,h._nextToken="",h.totalCount=-1,h.keyword=n.keyword,h.reverse=null!==(s=n.reverse)&&void 0!==s&&s,h.exactMatch=null!==(a=n.exactMatch)&&void 0!==a&&a,h.channelUrl=null!==(i=n.channelUrl)&&void 0!==i?i:"",h.channelCustomType=null!==(r=n.channelCustomType)&&void 0!==r?r:"",h.messageTimestampFrom=null!==(l=n.messageTimestampFrom)&&void 0!==l?l:null,h.messageTimestampTo=null!==(u=n.messageTimestampTo)&&void 0!==u?u:null,h.order=null!==(o=n.order)&&void 0!==o?o:we.SCORE,h.advancedQuery=null!==(d=n.advancedQuery)&&void 0!==d&&d,h.targetFields=null!==(c=n.targetFields)&&void 0!==c?c:null,h}return e(n,t),n.prototype._validate=function(){return t.prototype._validate.call(this)&&d("string",this.keyword)&&this.keyword.length>0&&d("boolean",this.reverse)&&d("boolean",this.exactMatch)&&d("string",this.channelUrl)&&d("string",this.channelCustomType)&&(d("number",this.messageTimestampFrom)||null===this.messageTimestampFrom)&&(d("number",this.messageTimestampTo)||null===this.messageTimestampTo)&&c(we,this.order)&&d("boolean",this.advancedQuery)&&o("string",this.targetFields,!0)},n.prototype.next=function(){return b(this,void 0,void 0,(function(){var e,t,n,s,a,i,l,u;return A(this,(function(o){switch(o.label){case 0:return this._validate()?this._isLoading?[3,3]:this._hasNext?(this._isLoading=!0,e=D.of(this._iid).requestQueue,t=new Ke(r(r({},this),{nextToken:this._nextToken?this._nextToken:null})),[4,e.send(t)]):[3,2]:[3,5];case 1:return n=o.sent(),s=n.as(Ve),a=s.messages,i=s.hasNext,l=s.nextToken,u=s.totalCount,this._nextToken=l,this._hasNext=i,this._isLoading=!1,this.totalCount=u,[2,a];case 2:return[2,[]];case 3:throw U.queryInProgress;case 4:return[3,6];case 5:throw U.invalidParameters;case 6:return[2]}}))}))},n}(X),Ye=function(t){function n(e,n,s,a){var i,r,l,u,o,d,c,h,p,m,g=this;return(g=t.call(this,e,n,s,a)||this).reverse=!1,g.messageTypeFilter=S.ALL,g.customTypesFilter=null,g.senderUserIdsFilter=null,g.replyType=Q.NONE,g.includeMetaArray=!1,g.includeReactions=!1,g.includeParentMessageInfo=!1,g.includeThreadInfo=!1,g.showSubchannelMessagesOnly=!1,g._edge=Number.MAX_SAFE_INTEGER,g.reverse=null!==(i=a.reverse)&&void 0!==i&&i,g.messageTypeFilter=null!==(r=a.messageTypeFilter)&&void 0!==r?r:S.ALL,g.customTypesFilter=null!==(l=a.customTypesFilter)&&void 0!==l?l:null,g.senderUserIdsFilter=null!==(u=a.senderUserIdsFilter)&&void 0!==u?u:null,g.replyType=null!==(o=a.replyType)&&void 0!==o?o:Q.NONE,g.includeMetaArray=null!==(d=a.includeMetaArray)&&void 0!==d&&d,g.includeReactions=null!==(c=a.includeReactions)&&void 0!==c&&c,g.includeParentMessageInfo=null!==(h=a.includeParentMessageInfo)&&void 0!==h&&h,g.includeThreadInfo=null!==(p=a.includeThreadInfo)&&void 0!==p&&p,g.showSubchannelMessagesOnly=null!==(m=a.showSubchannelMessagesOnly)&&void 0!==m&&m,g}return e(n,t),n.prototype._validate=function(){return t.prototype._validate.call(this)&&d("boolean",this.reverse)&&c(S,this.messageTypeFilter)&&c(Q,this.replyType)&&o("string",this.customTypesFilter,!0)&&o("string",this.senderUserIdsFilter,!0)&&d("boolean",this.includeMetaArray)&&d("boolean",this.includeReactions)&&d("boolean",this.includeParentMessageInfo)&&d("boolean",this.includeThreadInfo)&&d("boolean",this.showSubchannelMessagesOnly)},n.prototype.load=function(){return b(this,void 0,void 0,(function(){var e;return A(this,(function(t){switch(t.label){case 0:return this._validate()?this._isLoading?[3,3]:this._hasNext?(this._isLoading=!0,[4,Be.of(this._iid).getMessagesByTimestamp(this.channelUrl,this.channelType,this._edge,{prevResultSize:this.limit,nextResultSize:0,isInclusive:!1,reverse:this.reverse,messageTypeFilter:this.messageTypeFilter,customTypesFilter:this.customTypesFilter,replyType:this.replyType,senderUserIdsFilter:this.senderUserIdsFilter,includeReactions:this.includeReactions,includeMetaArray:this.includeMetaArray,includeParentMessageInfo:this.includeParentMessageInfo,includeThreadInfo:this.includeThreadInfo,showSubchannelMessagesOnly:this.showSubchannelMessagesOnly})]):[3,2]:[3,5];case 1:return e=t.sent(),this._edge=Math.min.apply(Math,h([Number.MAX_SAFE_INTEGER],p(e.map((function(e){return e.createdAt}))),!1)),this._hasNext=e.length>=this.limit,this._isLoading=!1,[2,e];case 2:return[2,[]];case 3:throw U.queryInProgress;case 4:return[3,6];case 5:throw U.invalidParameters;case 6:return[2]}}))}))},n}(Y),Ze={channelUrl:null,scheduledMessageId:0},$e=function(t){function n(){var e=null!==t&&t.apply(this,arguments)||this;return e.name="message",e}return e(n,t),n.prototype.init=function(e,n){var s=n.sdkState,a=n.dispatcher,i=n.sessionManager,r=n.requestQueue,l=n.logger,u=n.onlineDetector,o=n.cacheContext;t.prototype.init.call(this,e,{sdkState:s,dispatcher:a,sessionManager:i,requestQueue:r,logger:l,onlineDetector:u,cacheContext:o}),this._manager=new Be(e,{sdkState:s,dispatcher:a,requestQueue:r,onlineDetector:u,cacheContext:o})},n.prototype.buildMessageFromSerializedData=function(e){return this._manager.buildMessageFromSerializedData(e)},n.prototype.buildSenderFromSerializedData=function(e){return this._manager.buildSenderFromSerializedData(e)},n.prototype.getMessage=function(e){return b(this,void 0,void 0,(function(){var t;return A(this,(function(n){return t=r(r({},We),e),E(function(e){return d("string",e.channelUrl)&&d("string",e.channelType)&&c(_,e.channelType)&&d("number",e.messageId)&&d("boolean",e.includeMetaArray)&&d("boolean",e.includeParentMessageInfo)&&d("boolean",e.includeThreadInfo)}(t)).throw(U.invalidParameters),[2,this._manager.getMessage(t)]}))}))},n.prototype.getScheduledMessage=function(e){return b(this,void 0,void 0,(function(){var t;return A(this,(function(n){return t=r(r({},Ze),e),E(function(e){return d("string",e.channelUrl)&&d("number",e.scheduledMessageId)}(t)).throw(U.invalidParameters),[2,this._manager.getScheduledMessage(t)]}))}))},n}(Z);export{oe as A,he as B,Se as F,se as I,$e as M,le as O,ve as P,ae as R,me as S,ge as T,Ie as U,Xe as a,Be as b,re as c,Ye as d,pe as e,je as f,qe as g,Ce as h,Ne as i,ne as j,Ee as k,Te as l,ee as m,J as n,_e as o,Me as p,He as q,we as r,ue as s,ie as t,$ as u,Fe as v,te as w}; diff --git a/__bundle-edc633d6.js b/__bundle-3b517302.js similarity index 99% rename from __bundle-edc633d6.js rename to __bundle-3b517302.js index a3b51bd..b1c2489 100644 --- a/__bundle-edc633d6.js +++ b/__bundle-3b517302.js @@ -1 +1 @@ -import{a0 as e,a as t,I as n,l as r,U as i,a5 as a,g as s,e as o,i as u,_ as c,A as l,a7 as d,f as h,h as p,b as f,ai as m,c as v,S as y,V as g,W as _,au as T,av as U,M as I,a6 as w,a8 as M,aw as E,ax as b,as as P,aq as C,a4 as S,u as A,Y as D,a1 as q,H as R,Z as O,a9 as L,r as N,aa as k,af as F,ae as Q,x as z,ay as x,an as G,X as V,p as j,q as B,ab as W,az as K}from"./__bundle-03ba89c3.js";import{c as Y,A as H,U as J,F as X,R as Z,T as $,d as ee,e as te,b as ne,f as re,g as ie,v as ae,h as se,i as oe,B as ue,S as ce}from"./__bundle-51a2cdbc.js";import{i as le,P as de,a as he,b as pe}from"./__bundle-9e0eba5d.js";var fe,me=100,ve="GroupChannel",ye="url",ge=100,_e="Message",Te="messageId",Ue="Poll",Ie="pollId",we={data:null,customType:null,mentionType:e.USERS,mentionedUserIds:null,mentionedUsers:null,mentionedMessageTemplate:null,metaArrays:null,parentMessageId:null,isReplyToChannel:!1,pushNotificationDeliveryOption:null,appleCriticalAlertOptions:null,isPinnedMessage:!1},Me=function(s){return t("string",s.data,!0)&&t("string",s.customType,!0)&&n(e,s.mentionType)&&r("string",s.mentionedUserIds,!0)&&r(i,s.mentionedUsers,!0)&&t("string",s.mentionedMessageTemplate,!0)&&r(Y,s.metaArrays,!0)&&t("number",s.parentMessageId,!0)&&t("boolean",s.isReplyToChannel)&&n(a,s.pushNotificationDeliveryOption,!0)&&t(H,s.appleCriticalAlertOptions,!0)&&t("boolean",s.isPinnedMessage,!0)},Ee=function(e){return e?{isReplyToChannel:e.isReplyToChannel,pushNotificationDeliveryOption:e.pushNotificationDeliveryOption,pollId:e.pollId}:null},be=s(s({},we),{message:null,translationTargetLanguages:null,pollId:null}),Pe=function(e){return Me(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"}(fe||(fe={}));var Ce,Se=function(e){return"undefined"!=typeof window&&"Blob"in window&&"undefined"!=typeof Blob&&e instanceof Blob},Ae=function(e){return e===fe.BLOB||e===fe.FILE},De=function(e){return e?{file:e.file,fileKey:e.fileKey,fileType:e.fileType,isReplyToChannel:e.isReplyToChannel,pushNotificationDeliveryOption:e.pushNotificationDeliveryOption}:null},qe=s(s({},we),{file:null,fileKey:null,fileUrl:null,fileName:null,fileType:null,fileSize:null,mimeType:null,thumbnailSizes:null,requireAuth:!1}),Re=function(e){return Me(e)&&(u(e.file)||t("string",e.fileUrl))&&t("string",e.fileName,!0)&&t("string",e.mimeType,!0)&&t("number",e.fileSize,!0)&&(null===e.thumbnailSizes||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"}(Ce||(Ce={}));var Oe,Le=function(){function e(e){var t,r,i,a;this.restrictionType=null,this.description=null,this.endAt=-1,this.remainingDuration=-1,n(Ce,e.restriction_type)&&(this.restrictionType=e.restriction_type),this.description=null!==(t=e.description)&&void 0!==t?t:null,this.endAt=null!==(i=null!==(r=e.end_at)&&void 0!==r?r:e.muted_end_at)&&void 0!==i?i:-1,this.remainingDuration=null!==(a=e.remaining_duration)&&void 0!==a?a:-1}return e.payloadify=function(e){return e?o({restriction_type:e.restrictionType,description:e.description,end_at:e.endAt,remaining_duration:e.remainingDuration}):null},e}(),Ne=function(e){function t(t,n){var r=e.call(this,t,n)||this;return r.restrictionInfo=null,r.restrictionInfo=new Le(n),r}return c(t,e),t.payloadify=function(t){return t?o(s(s({},e.payloadify.call(this,t)),Le.payloadify(t.restrictionInfo))):null},t}(i),ke={data:null,customType:null,mentionType:e.USERS,mentionedUserIds:null,mentionedUsers:null,mentionedMessageTemplate:null,metaArrays:null,pushNotificationDeliveryOption:null,appleCriticalAlertOptions:null},Fe=function(s){return t("string",s.data,!0)&&t("string",s.customType,!0)&&n(e,s.mentionType)&&r("string",s.mentionedUserIds,!0)&&r(i,s.mentionedUsers,!0)&&t("string",s.mentionedMessageTemplate,!0)&&r(Y,s.metaArrays,!0)&&n(a,s.pushNotificationDeliveryOption,!0)&&t(H,s.appleCriticalAlertOptions,!0)},Qe=s(s({},ke),{message:null,translationTargetLanguages:null,pollId:null}),ze=function(e){return Fe(e)&&t("string",e.message,!0)&&r("string",e.translationTargetLanguages,!0)&&t("number",e.pollId,!0)},xe=s({},ke),Ge=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=l.GET,s.path="".concat(d(r),"/").concat(encodeURIComponent(n),"/operators"),s.params={token:i,limit:a},s}return c(t,e),t}(h),Ve=function(e){function t(t,n){var r=e.call(this,t,n)||this;return r.operators=n.operators.map((function(e){return new i(t,e)})),r.token=n.next,r}return c(t,e),t}(p),je=function(e){function t(t,n,r,i){return e.call(this,t,n,r,i)||this}return c(t,e),t.prototype._validate=function(){return e.prototype._validate.call(this)},t.prototype.next=function(){return f(this,void 0,void 0,(function(){var e,t,n,r,i,a,o;return v(this,(function(u){switch(u.label){case 0:return this._validate()?this._isLoading?[3,3]:(e=[],this._hasNext?(this._isLoading=!0,t=g.of(this._iid).requestQueue,n=new Ge(s(s({},this),{channelUrl:this.channelUrl,token:this._token})),[4,t.send(n)]):[3,2]):[3,5];case 1:return r=u.sent(),i=r.as(Ve),a=i.operators,o=i.token,this._token=o,this._hasNext=!!o,this._isLoading=!1,[2,a];case 2:return[2,e];case 3:throw y.queryInProgress;case 4:return[3,6];case 5:throw y.invalidParameters;case 6:return[2]}}))}))},t}(m),Be=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=l.GET,n.path="".concat(d(i),"/").concat(encodeURIComponent(r),"/mute"),n.params={limit:a,token:s},n}return c(t,e),t}(h),We=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 Ne(t,e)}))),r}return c(t,e),t}(p),Ke=function(e){function t(t,n,r,i){return e.call(this,t,n,r,i)||this}return c(t,e),t.prototype.next=function(){return f(this,void 0,void 0,(function(){var e,t,n,r,i,a;return v(this,(function(o){switch(o.label){case 0:return this._validate()?this._isLoading?[3,3]:this._hasNext?(this._isLoading=!0,e=g.of(this._iid).requestQueue,t=new Be(s(s({},this),{token:this._token})),[4,e.send(t)]):[3,2]:[3,5];case 1:return n=o.sent(),r=n.as(We),i=r.mutedUsers,a=r.token,this._token=a,this._hasNext=!!a,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]}}))}))},t}(m),Ye=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=l.GET,n.path="".concat(d(i),"/").concat(encodeURIComponent(r),"/ban"),n.params=o({limit:a,token:s}),n}return c(t,e),t}(h),He=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 Ne(t,e.user)}))),r}return c(t,e),t}(p),Je=function(e){function t(t,n,r,i){return e.call(this,t,n,r,i)||this}return c(t,e),t.prototype._validate=function(){return e.prototype._validate.call(this)},t.prototype.next=function(){return f(this,void 0,void 0,(function(){var e,t,n,r,i,a;return v(this,(function(o){switch(o.label){case 0:return this._validate()?this._isLoading?[3,3]:this._hasNext?(this._isLoading=!0,e=g.of(this._iid).requestQueue,t=new Ye(s(s({},this),{token:this._token})),[4,e.send(t)]):[3,2]:[3,5];case 1:return n=o.sent(),r=n.as(He),i=r.bannedUsers,a=r.token,this._token=a,this._hasNext=!!a,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]}}))}))},t}(m);!function(e){e.SPAM="spam",e.HARASSING="harassing",e.SUSPICIOUS="suspicious",e.INAPPROPRIATE="inappropriate"}(Oe||(Oe={}));var Xe=function(e){function t(t){var n=this,r=t.channelUrl,i=t.channelType,a=t.operatorUserIds;return(n=e.call(this)||this).method=l.POST,n.path="".concat(d(i),"/").concat(encodeURIComponent(r),"/operators"),n.params={operator_ids:a},n}return c(t,e),t}(h);!function(e){function t(){return null!==e&&e.apply(this,arguments)||this}c(t,e)}(p);var Ze=function(e){function t(t){var n=this,r=t.channelUrl,i=t.channelType,a=t.operatorUserIds;return(n=e.call(this)||this).method=l.DELETE,n.path="".concat(d(i),"/").concat(encodeURIComponent(r),"/operators"),n.params={operator_ids:a},n}return c(t,e),t}(h);!function(e){function t(t,n){return e.call(this,t,n)||this}c(t,e)}(p);var $e=function(e){function t(t){var n=this,r=t.channelUrl,i=t.channelType,a=t.userId;return(n=e.call(this)||this).method=l.GET,n.path="".concat(d(i),"/").concat(encodeURIComponent(r),"/mute/").concat(a),n}return c(t,e),t}(h),et=function(e){function t(t,n){var r=e.call(this,t,n)||this;r.isMuted=!1,r.startAt=null,r.endAt=null,r.remainingDuration=null,r.description=null;var i=n.is_muted,a=n.start_at,s=n.end_at,o=n.remaining_duration,u=n.description;return r.isMuted=i,r.startAt=a,r.endAt=s,r.remainingDuration=o,r.description=u,r}return c(t,e),t}(p),tt=function(e){function t(t){var n=this,r=t.channelUrl,i=t.channelType,a=t.keys;return(n=e.call(this)||this).method=l.GET,n.path="".concat(d(i),"/").concat(encodeURIComponent(r),"/metadata"),n.params={keys:a,include_ts:!0},n}return c(t,e),t}(h),nt=function(e){function t(t,n){var r=e.call(this,t,n)||this;r.ts=null;var i=n.metadata,a=n.ts;return r.metadata=i,r.ts=null!=a?a:null,r}return c(t,e),t}(p),rt=function(e){function t(t){var n=this,r=t.channelUrl,i=t.channelType,a=t.metadata;return(n=e.call(this)||this).method=l.POST,n.path="".concat(d(i),"/").concat(encodeURIComponent(r),"/metadata"),n.params={metadata:a,include_ts:!0},n}return c(t,e),t}(h),it=function(e){function t(t,n){var r,i,a=this;return(a=e.call(this,t,n)||this).metaData=null!==(r=n.metadata)&&void 0!==r?r:{},a.ts=null!==(i=n.ts)&&void 0!==i?i:null,a}return c(t,e),t}(p),at=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=l.PUT,n.path="".concat(d(i),"/").concat(encodeURIComponent(r),"/metadata"),n.params={metadata:a,include_ts:!0,upsert:null!=s&&s},n}return c(t,e),t}(h),st=function(e){function t(t,n){var r=e.call(this,t,n)||this;r.ts=null;var i=n.metadata,a=n.ts;return r.metadata=i,r.ts=null!=a?a:null,r}return c(t,e),t}(p),ot=function(e){function t(t,n,r){var i=e.call(this,t,"SYEV",r)||this;return i.created=null,i.updated=null,i.deleted=null,r.data&&(i.created=r.data.created,i.updated=r.data.updated,i.deleted=r.data.deleted),i}return c(t,e),t}(_),ut=function(e){function t(t){var n=this,r=t.channelUrl,i=t.channelType,a=t.key;return(n=e.call(this)||this).method=l.DELETE,n.path="".concat(d(i),"/").concat(encodeURIComponent(r),"/metadata/").concat(a),n.params={include_ts:!0},n}return c(t,e),t}(h),ct=function(e){function t(t,n){var r=e.call(this,t,n)||this;r.ts=null;var i=n.ts;return r.ts=null!=i?i:null,r}return c(t,e),t}(p),lt=function(e){function t(t){var n=this,r=t.channelUrl,i=t.channelType;return(n=e.call(this)||this).method=l.DELETE,n.path="".concat(d(i),"/").concat(encodeURIComponent(r),"/metadata"),n.params={include_ts:!0},n}return c(t,e),t}(h),dt=function(e){function t(t,n){var r=e.call(this,t,n)||this;r.ts=null;var i=n.ts;return r.ts=null!=i?i:null,r}return c(t,e),t}(p),ht=function(e){function t(t){var n=this,r=t.channelUrl,i=t.channelType,a=t.keys;return(n=e.call(this)||this).method=l.GET,n.path="".concat(d(i),"/").concat(encodeURIComponent(r),"/metacounter"),n.params={keys:a},n}return c(t,e),t}(h),pt=function(e){function t(t,n){var r=e.call(this,t,n)||this;return r.metaCounter=n,r}return c(t,e),t}(p),ft=function(e){function t(t){var n=this,r=t.channelUrl,i=t.channelType,a=t.metaCounter;return(n=e.call(this)||this).method=l.POST,n.path="".concat(d(i),"/").concat(encodeURIComponent(r),"/metacounter"),n.params={metacounter:a},n}return c(t,e),t}(h),mt=function(e){function t(t,n){var r=e.call(this,t,n)||this;return r.metaCounter=n,r}return c(t,e),t}(p),vt=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=l.PUT,n.path="".concat(d(i),"/").concat(encodeURIComponent(r),"/metacounter"),n.params={metacounter:a,upsert:o,mode:c},n}return c(t,e),t}(h),yt=function(e){function t(t,n){var r=e.call(this,t,n)||this;return r.metaCounter=n,r}return c(t,e),t}(p),gt=function(e){function t(t,n,r){var i=e.call(this,t,"SYEV",r)||this;return i.created=null,i.updated=null,i.deleted=null,r.data&&(i.created=r.data.created,i.updated=r.data.updated,i.deleted=r.data.deleted),i}return c(t,e),t}(_),_t=function(e){function t(t){var n=this,r=t.channelUrl,i=t.channelType,a=t.key;return(n=e.call(this)||this).method=l.DELETE,n.path="".concat(d(i),"/").concat(encodeURIComponent(r),"/metacounter/").concat(a),n.params=null,n}return c(t,e),t}(h);!function(e){function t(t,n){return e.call(this,t,n)||this}c(t,e)}(p);var Tt=function(e){function t(t){var n=this,r=t.channelUrl,i=t.channelType;return(n=e.call(this)||this).method=l.DELETE,n.path="".concat(d(i),"/").concat(encodeURIComponent(r),"/metacounter"),n.params=null,n}return c(t,e),t}(h);!function(e){function t(){return null!==e&&e.apply(this,arguments)||this}c(t,e)}(p);var Ut=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=l.POST,n.path="".concat(d(i),"/").concat(encodeURIComponent(r),"/mute"),n.params={user_id:a,seconds:s,description:o},n}return c(t,e),t}(h);!function(e){function t(t,n){return e.call(this,t,n)||this}c(t,e)}(p);var It=function(e){function t(t,n,r){var i=e.call(this,t,"SYEV",r)||this;return i.user=new Ne(t,r.data),i}return c(t,e),t}(_),wt=function(e){function t(t){var n=this,r=t.channelUrl,i=t.channelType,a=t.userId;return(n=e.call(this)||this).method=l.DELETE,n.path="".concat(d(i),"/").concat(encodeURIComponent(r),"/mute/").concat(encodeURIComponent(a)),n}return c(t,e),t}(h);!function(e){function t(){return null!==e&&e.apply(this,arguments)||this}c(t,e)}(p);var Mt=function(e){function t(t,n,r){var i=e.call(this,t,"SYEV",r)||this;return i.user=new Ne(t,r.data),i}return c(t,e),t}(_),Et=function(e){function t(t){var n=this,r=t.channelUrl,i=t.channelType,a=t.userId,s=t.seconds,u=t.description;return(n=e.call(this)||this).method=l.POST,n.path="".concat(d(i),"/").concat(encodeURIComponent(r),"/ban"),n.params=o({user_id:a,seconds:s,description:u}),n}return c(t,e),t}(h);!function(e){function t(){return null!==e&&e.apply(this,arguments)||this}c(t,e)}(p);var bt=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 Ne(t,r.data),r.data.member_count&&(i.memberCount=r.data.member_count),r.data.joined_member_count&&(i.joinedMemberCount=r.data.joined_member_count),i}return c(t,e),t}(_),Pt=function(e){function t(t){var n=this,r=t.channelUrl,i=t.channelType,a=t.userId;return(n=e.call(this)||this).method=l.DELETE,n.path="".concat(d(i),"/").concat(encodeURIComponent(r),"/ban/").concat(encodeURIComponent(a)),n}return c(t,e),t}(h);!function(e){function t(){return null!==e&&e.apply(this,arguments)||this}c(t,e)}(p);var Ct=function(e){function t(t,n,r){var i=e.call(this,t,"SYEV",r)||this;return i.user=new Ne(t,r.data),i}return c(t,e),t}(_),St=function(e){function t(t){var n=this,r=t.channelUrl,i=t.channelType,a=t.freezing;return(n=e.call(this)||this).method=l.PUT,n.path="".concat(d(i),"/").concat(encodeURIComponent(r),"/freeze"),n.params={freeze:a},n}return c(t,e),t}(h);!function(e){function t(){return null!==e&&e.apply(this,arguments)||this}c(t,e)}(p);var At=function(e){function t(t,n,r){var i=e.call(this,t,"SYEV",r)||this;return i.freeze=r.data.freeze,i}return c(t,e),t}(_),Dt=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=l.POST,n.path="".concat(T(i),"/").concat(encodeURIComponent(r)),n.params={report_category:a,reporting_user_id:s,report_description:o},n}return c(t,e),t}(h),qt=function(e){function t(t){var n=this,r=t.channelUrl,i=t.channelType,a=t.category,s=t.userId,o=t.offendingUserId,u=t.description;return(n=e.call(this)||this).method=l.POST,n.path="".concat(U,"/users/").concat(o),n.params={channel_url:r,channel_type:i===I.OPEN?"open_channels":"group_channels",report_category:a,reporting_user_id:s,report_description:u},n}return c(t,e),t}(h),Rt=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=l.POST,n.path="".concat(T(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 c(t,e),t}(h),Ot=function(t){function n(n){var r=[];return n.mentionType===e.USERS&&(n.mentionedUserIds?r=n.mentionedUserIds:n.mentionedUsers&&(r=n.mentionedUsers.map((function(e){return e.userId})))),t.call(this,{code:"MESG",ackRequired:!0,payload:o({channel_url:n.channelUrl,message:n.message,data:n.data,custom_type:n.customType,metaarray:n.metaArrays,mention_type:n.mentionType,mentioned_user_ids:r,mentioned_message_template:n.mentionedMessageTemplate,target_langs:n.translationTargetLanguages,push_option:n.pushNotificationDeliveryOption&&n.pushNotificationDeliveryOption!==a.DEFAULT?n.pushNotificationDeliveryOption:void 0,apple_critical_alert_options:n.appleCriticalAlertOptions,silent:n.silent,reply_to_channel:n.isReplyToChannel,parent_message_id:n.parentMessageId>0?n.parentMessageId:null,req_id:n.reqId,poll_id:n.pollId,pin_message:n.isPinnedMessage})})||this}return c(n,t),n}(w),Lt=function(e){function t(t,n,r){var i,a,s,o=this;(o=e.call(this,t,"MESG",r)||this).message=new J(t,r);var u=g.of(t).sdkState;return o.isMentioned=M(o.message.mentionType,null!==(i=o.message.mentionedUserIds)&&void 0!==i?i:null===(a=o.message.mentionedUsers)||void 0===a?void 0:a.map((function(e){return e.userId})),u.userId),o.forceUpdateLastMessage=null!==(s=r.force_update_last_message)&&void 0!==s&&s,o}return c(t,e),t}(_),Nt=function(t){function n(n){var r,i=null;return n.mentionType===e.USERS&&(n.mentionedUserIds?i=n.mentionedUserIds:n.mentionedUsers&&(i=n.mentionedUsers.map((function(e){return e.userId})))),t.call(this,{code:"MEDI",ackRequired:!0,payload:o({channel_url:n.channelUrl,msg_id:n.messageId,message:n.message,data:n.data,custom_type:n.customType,metaarray:n.metaArrayParams,mention_type:n.mentionType,mentioned_user_ids:i,mentioned_message_template:n.mentionedMessageTemplate,apple_critical_alert_options:null===(r=n.appleCriticalAlertOptions)||void 0===r?void 0:r.serialize(),poll_id:n.pollId})})||this}return c(n,t),n}(w),kt=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 J(t,r);var d=g.of(t).sdkState;return l.mentionCountChange=E({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 c(t,e),t}(_),Ft=function(t){function n(n){var r=null;return n.mentionType===e.USERS&&(n.mentionedUserIds?r=n.mentionedUserIds:n.mentionedUsers&&(r=n.mentionedUsers.map((function(e){return e.userId})))),t.call(this,{code:"FEDI",ackRequired:!0,payload:o({channel_url:n.channelUrl,msg_id:n.messageId,data:n.data,custom_type:n.customType,metaarray:n.metaArrayParams,mention_type:n.mentionType,mentioned_user_ids:r,apple_critical_alert_options:n.appleCriticalAlertOptions})})||this}return c(n,t),n}(w),Qt=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 X(t,r);var d=g.of(t).sdkState;return l.mentionCountChange=E({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 c(t,e),t}(_),zt=function(e){function t(t){var n=e.call(this)||this;return n.method=l.DELETE,n.path="".concat(d(t.channelType),"/").concat(t.channelUrl,"/messages/").concat(t.messageId),n}return c(t,e),t}(h);!function(e){function t(){return null!==e&&e.apply(this,arguments)||this}c(t,e)}(p);var xt=function(e){function t(t,n,r){var i=e.call(this,t,"DELM",r)||this;return i.channelUrl=r.channel_url,i.channelType=r.channel_type,i.messageId=Number(r.msg_id),i}return c(t,e),t}(_),Gt=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=l.POST,s.path="".concat(d(n),"/").concat(encodeURIComponent(r),"/messages/").concat(i,"/reactions"),s.params={reaction:a},s}return c(t,e),t}(h),Vt=function(e){function t(t,n){var r=e.call(this,t,n)||this;return r.reactionEvent=new Z(n),r}return c(t,e),t}(p),jt=function(e){function t(t){var n=t.channelType,r=t.channelUrl,i=t.messageId,a=t.reactionKey,s=e.call(this)||this;return s.method=l.DELETE,s.path="".concat(d(n),"/").concat(encodeURIComponent(r),"/messages/").concat(i,"/reactions"),s.params={reaction:a},s}return c(t,e),t}(h),Bt=function(e){function t(t,n){var r=e.call(this,t,n)||this;return r.reactionEvent=new Z(s({},n)),r}return c(t,e),t}(p),Wt=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=l.POST,s.path="".concat(d(n),"/").concat(encodeURIComponent(r),"/messages/").concat(encodeURIComponent(i),"/translation"),s.params={target_langs:a},s}return c(t,e),t}(h),Kt=function(e){function t(t,n){var r=e.call(this,t,n)||this;return r.message=new J(t,n),r}return c(t,e),t}(p),Yt=function(t){function n(n){var r,i=this;i=t.call(this)||this;var a=[];n.mentionType===e.USERS&&(n.mentionedUserIds?a=n.mentionedUserIds:n.mentionedUsers&&(a=n.mentionedUsers.map((function(e){return e.userId}))));var s=n.channelType,o=n.channelUrl;return i.method=l.POST,i.path="".concat(d(s),"/").concat(encodeURIComponent(o),"/scheduled_messages"),i.params={req_id:n.reqId,scheduled_at:n.scheduledAt,message_type:b.USER,message:n.message,custom_type:n.customType,data:n.data,mention_type:n.mentionType,mentioned_user_ids:a,sorted_metaarray:null===(r=n.metaArrays)||void 0===r?void 0:r.map((function(e){return Y.payloadify(e)})),apple_critical_alert_options:H.payloadify(n.appleCriticalAlertOptions),target_langs:n.translationTargetLanguages,push_option:n.pushNotificationDeliveryOption},i}return c(n,t),n}(h),Ht=function(e){function t(t,n){var r=e.call(this,t,n)||this;return r.message=new J(t,n),r}return c(t,e),t}(p),Jt=function(t){function n(n){var r,i=this;i=t.call(this)||this;var a=[];n.mentionType===e.USERS&&(n.mentionedUserIds?a=n.mentionedUserIds:n.mentionedUsers&&(a=n.mentionedUsers.map((function(e){return e.userId}))));var s=n.channelType,o=n.channelUrl;return i.method=l.POST,i.path="".concat(d(s),"/").concat(encodeURIComponent(o),"/scheduled_messages"),i.params={req_id:n.reqId,scheduled_at:n.scheduledAt,message_type:b.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 $.payloadify(e)})):[],custom_type:n.customType,data:n.data,require_auth:n.requireAuth,mention_type:n.mentionType,mentioned_user_ids:a,sorted_metaarray:null===(r=n.metaArrays)||void 0===r?void 0:r.map((function(e){return Y.payloadify(e)})),apple_critical_alert_options:H.payloadify(n.appleCriticalAlertOptions),push_option:n.pushNotificationDeliveryOption},i}return c(n,t),n}(h),Xt=function(e){function t(t,n){var r=e.call(this,t,n)||this;return r.message=new X(t,n),r}return c(t,e),t}(p),Zt=function(e){function t(t){var n=t.pollId,r=t.title,i=t.data,a=t.allowUserSuggestion,s=t.allowMultipleVotes,o=t.closeAt,u=e.call(this)||this;return u.method=l.PUT,u.path="".concat(C,"/").concat(encodeURIComponent(n)),u.params={title:r,data:i,allow_user_suggestion:a,allow_multiple_votes:s,close_at:o},u}return c(t,e),t}(h),$t=function(e){function t(t,n){var r=e.call(this,t,n)||this;return r.poll=new S(t,n),r}return c(t,e),t}(p),en=function(e){function t(t){var n=t.pollId,r=e.call(this)||this;return r.method=l.DELETE,r.path="".concat(C,"/").concat(encodeURIComponent(n)),r}return c(t,e),t}(h);!function(e){function t(){return null!==e&&e.apply(this,arguments)||this}c(t,e)}(p);var tn=function(e){function t(t){var n=t.pollId,r=e.call(this)||this;return r.method=l.PUT,r.path="".concat(C,"/").concat(encodeURIComponent(n),"/close"),r}return c(t,e),t}(h),nn=function(e){function t(t,n){var r=e.call(this,t,n)||this;return r.poll=new S(t,n),r}return c(t,e),t}(p),rn=function(e){function t(t){var n=t.channelUrl,r=t.channelType,i=t.pollId,a=t.optionText,s=e.call(this)||this;return s.method=l.POST,s.path="".concat(C,"/").concat(encodeURIComponent(i),"/options"),s.params={channel_url:n,channel_type:r,text:a},s}return c(t,e),t}(h),an=function(e){function t(t,n){var r=e.call(this,t,n)||this;return r.poll=new S(t,n),r}return c(t,e),t}(p),sn=function(e){function t(t){var n=t.pollId,r=t.pollOptionId,i=t.optionText,a=e.call(this)||this;return a.method=l.PUT,a.path="".concat(C,"/").concat(encodeURIComponent(n),"/options/").concat(encodeURIComponent(r)),a.params={text:i},a}return c(t,e),t}(h),on=function(e){function t(t,n){var r=e.call(this,t,n)||this;return r.poll=new S(t,n),r}return c(t,e),t}(p),un=function(e){function t(t){var n=t.pollId,r=t.pollOptionId,i=e.call(this)||this;return i.method=l.DELETE,i.path="".concat(C,"/").concat(encodeURIComponent(n),"/options/").concat(encodeURIComponent(r)),i}return c(t,e),t}(h);!function(e){function t(){return null!==e&&e.apply(this,arguments)||this}c(t,e)}(p);var cn=function(e){function t(t){var n=t.reqId,r=t.channelType,i=t.channelUrl,a=t.pollId,s=t.pollOptionIds;return e.call(this,{code:"VOTE",ackRequired:!0,payload:o({req_id:n,channel_type:r===I.OPEN?"open_channels":"group_channels",channel_url:i,poll_id:a,option_ids:s})})||this}return c(t,e),t}(w),ln=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 le(r),i.channelUrl=r.channel_url,i.channelType=r.channel_type,i}return c(t,e),t}(_),dn=2,hn=function(e){function l(n,r){var a,s,o,u,c=this;return(c=e.call(this,n)||this).url="",c.channelType=I.BASE,c.name="",c.coverUrl="",c.customType="",c.data="",c.isFrozen=!1,c.isEphemeral=!1,c.creator=null,c.createdAt=0,c._messageCollectionLastAccessedAt=0,c.url=r.channel_url,c.name=null!==(a=r.name)&&void 0!==a?a:"",c.coverUrl=null!==(s=r.cover_url)&&void 0!==s?s:"",c.customType=null!==(o=r.custom_type)&&void 0!==o?o:"",c.data=null!==(u=r.data)&&void 0!==u?u:"",c.isFrozen=!!t("boolean",r.freeze)&&r.freeze,c.isEphemeral=!!t("boolean",r.is_ephemeral)&&r.is_ephemeral,c.creator=r.created_by?new i(c._iid,r.created_by):null,c.createdAt=1e3*r.created_at,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 c(l,e),l.payloadify=function(t){return o(s(s({},e.payloadify.call(this,t)),{channel_url:t.url,name:t.name,cover_url:t.coverUrl,custom_type:t.customType,data:t.data,freeze:t.isFrozen,is_ephemeral:t.isEphemeral,created_by:i.payloadify(t.creator),created_at:t.createdAt/1e3}))},l.prototype.isGroupChannel=function(){return this.channelType===I.GROUP},l.prototype.isOpenChannel=function(){return this.channelType===I.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}),Object.defineProperty(l.prototype,"messageCollectionLastAccessedAt",{get:function(){return this._messageCollectionLastAccessedAt},enumerable:!1,configurable:!0}),l.prototype._updateMessageCollectionLastAccessedAt=function(){this._messageCollectionLastAccessedAt=Date.now()},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&&r("string",t)).throw(y.invalidParameters),n=g.of(this._iid).requestQueue,i=new Wt({channelType:this.channelType,channelUrl:this.url,messageId:e.messageId,translationTargetLanguages:t}),[4,n.send(i)];case 1:return a=s.sent(),[2,a.as(Kt).message]}}))}))},l.prototype._createScheduledUserMessage=function(e,t){var n=this,r=g.of(this._iid).requestQueue,i=Date.now(),a=this._generateRequestId();k(2).then((function(){var r=n._createPendingScheduledUserMessage(e,a,i);z((function(){return f(n,void 0,void 0,(function(){return v(this,(function(e){return[2,t._trigger(null,r)]}))}))}))}));var o=new Yt(s({reqId:a,channelType:this.channelType,channelUrl:this.url},e));r.send(o).then((function(e){var r=e.as(Ht).message;z((function(){return f(n,void 0,void 0,(function(){return v(this,(function(e){return[2,t._trigger(null,r)]}))}))}))})).catch((function(r){if(x(r))throw r;k(2).then((function(){var s=n._createPendingScheduledUserMessage(e,a,i);n._markMessageAsFailed(s,r),z((function(){return f(n,void 0,void 0,(function(){return v(this,(function(e){return[2,t._trigger(r,s)]}))}))}))}))}))},l.prototype.sendFileMessage=function(e){var t=s(s({},qe),e);return N(Re(t)).throw(y.invalidParameters),this._sendFileMessage(t)},l.prototype._sendFileMessage=function(e,t){var n=this;void 0===t&&(t=null);var r=g.of(this._iid).dispatcher,i=ne.of(this._iid).fileMessageQueue,a=t,s=Date.now(),o=new re;return a||(a=this._generateRequestId(),k(2).then((function(){var t=n._createPendingFileMessage(e,a,s);r.dispatch(new F({messages:[t],source:Q.EVENT_MESSAGE_SENT_PENDING})),z((function(){return f(n,void 0,void 0,(function(){return v(this,(function(e){return[2,o._trigger(null,t)]}))}))}))}))),i.request(this,a,e).then((function(e){r.dispatch(new F({messages:[e],source:Q.EVENT_MESSAGE_SENT_SUCCESS})),z((function(){return f(n,void 0,void 0,(function(){return v(this,(function(t){return[2,o._trigger(null,e)]}))}))}))})).catch((function(t){if(x(t))throw t;k(2).then((function(){var i=n._createPendingFileMessage(e,a,s),u=g.of(n._iid).cacheContext.localCacheEnabled&&G(t.code);n._markMessageAsFailed(i,t,u),r.dispatch(new F({messages:[i],source:i.sendingStatus===q.PENDING?Q.REQUEST_RESEND_MESSAGE:Q.EVENT_MESSAGE_SENT_FAILED})),z((function(){return f(n,void 0,void 0,(function(){return v(this,(function(e){return[2,o._trigger(t,i)]}))}))}))}))})),o},l.prototype._autoResendFileMessage=function(e){N(e instanceof X).throw(y.invalidParameters);var t=g.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,r){var i=this,a=g.of(this._iid).requestQueue,o=new Jt(s(s({reqId:n,channelType:this.channelType,channelUrl:this.url},e),{fileUrl:e.fileUrl,requireAuth:e.requireAuth}));a.send(o).then((function(e){var n=e.as(Xt).message;z((function(){return f(i,void 0,void 0,(function(){return v(this,(function(e){return[2,t._trigger(null,n)]}))}))}))})).catch((function(a){if(x(a))throw a;k(2).then((function(){var s=i._createPendingScheduledFileMessage(e,n,r);i._markMessageAsFailed(s,a),z((function(){return f(i,void 0,void 0,(function(){return v(this,(function(e){return[2,t._trigger(a,s)]}))}))}))}))}))},l.prototype.sendFileMessages=function(e){var t,n;N(e.every((function(e){return Re(s(s({},qe),e))}))).throw(y.invalidParameters);var r=new re;try{for(var i=R(e),a=i.next();!a.done;a=i.next()){var o=a.value;this.sendFileMessage(o).onPending((function(e){return r._trigger(null,e)})).onFailed((function(e,t){return r._trigger(e,t)})).onSucceeded((function(e){return r._trigger(null,e)}))}}catch(e){t={error:e}}finally{try{a&&!a.done&&(n=i.return)&&n.call(i)}finally{if(t)throw t.error}}return r},l.prototype.resendFileMessage=function(e,t){var n;return f(this,void 0,void 0,(function(){var r,i,a;return v(this,(function(s){return r=Boolean(e.url)||u(t)||u(null===(n=e.messageParams)||void 0===n?void 0:n.file),N(e instanceof X&&r&&!e.scheduledInfo).throw(y.invalidParameters),i=new W,a=function(e,t){var n;return void 0===t&&(t=null),e.messageParams?(!e.url&&u(t)&&(e.messageParams.file=t),e.messageParams):o({data:e.data,customType:e.customType,mentionType:e.mentionType,mentionedUsers:e.mentionedUsers,mentionedUserIds:e.mentionedUserIds,metaArrays:e.metaArrays,parentMessageId:e.parentMessageId,appleCriticalAlertOptions:e.appleCriticalAlertOptions,file:null!=t?t:null===(n=e.messageParams)||void 0===n?void 0:n.file,fileUrl:e.url,fileName:e.name,fileSize:e.size,mimeType:e.type,thumbnailSizes: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,n){return f(this,void 0,void 0,(function(){var r,i,a,o;return v(this,(function(u){switch(u.label){case 0:return r=s(s({},xe),n),N(t("number",e)&&function(e){return Fe(e)}(r)).throw(y.invalidParameters),i=g.of(this._iid).requestQueue,a=new Ft(s({channelType:this.channelType,channelUrl:this.url,messageId:e},r)),[4,i.send(a)];case 1:return o=u.sent(),[2,o.as(Qt).message]}}))}))},l.prototype.cancelUploadingFileMessage=function(e){return f(this,void 0,void 0,(function(){return v(this,(function(n){return N(t("string",e)).throw(y.invalidParameters),ne.of(this._iid).fileMessageQueue.cancel(this,e),[2,!0]}))}))},l.prototype.copyFileMessage=function(e,t){var n,r;return f(this,void 0,void 0,(function(){var i,o;return v(this,(function(u){return N(e instanceof l&&t instanceof X&&t.sendingStatus===q.SUCCEEDED&&this.url===t.channelUrl&&!t.scheduledInfo).throw(y.invalidParameters),i=new W,o=s(s({},t),{fileUrl:t.url,fileName:t.name,fileSize:t.size,mimeType:t.type,mentionType:t.mentionType,mentionedUserIds:null!==(n=t.mentionedUserIds)&&void 0!==n?n:null===(r=t.mentionedUsers)||void 0===r?void 0:r.map((function(e){return e.userId})),pushNotificationDeliveryOption:a.DEFAULT,parentMessageId:null,isReplyToChannel:!1,thumbnailSizes:t.thumbnails.map((function(e){return{maxWidth:e.width,maxHeight:e.height}})),requireAuth:t.requireAuth,isPinnedMessage:!1}),e._sendFileMessage(o).onSucceeded((function(e){return i.resolve(e)})).onFailed((function(e){return i.reject(e)})),[2,i.promise]}))}))},l.prototype.deleteMessage=function(e){return f(this,void 0,void 0,(function(){var t,n;return v(this,(function(r){switch(r.label){case 0:return N(e instanceof ue).throw(y.invalidParameters),e.messageId>0?(t=g.of(this._iid).requestQueue,n=new zt({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,n){return f(this,void 0,void 0,(function(){var r,i,a;return v(this,(function(s){switch(s.label){case 0:return N(e instanceof ue&&e.messageId>0&&t("string",n)).throw(y.invalidParameters),r=g.of(this._iid).requestQueue,i=new Gt({channelType:this.channelType,channelUrl:this.url,messageId:e.messageId,reactionKey:n}),[4,r.send(i)];case 1:return a=s.sent(),[2,a.as(Vt).reactionEvent]}}))}))},l.prototype.deleteReaction=function(e,n){return f(this,void 0,void 0,(function(){var r,i,a;return v(this,(function(s){switch(s.label){case 0:return N(e instanceof ue&&e.messageId>0&&t("string",n)).throw(y.invalidParameters),r=g.of(this._iid).requestQueue,i=new jt({channelType:this.channelType,channelUrl:this.url,messageId:e.messageId,reactionKey:n}),[4,r.send(i)];case 1:return a=s.sent(),[2,a.as(Bt).reactionEvent]}}))}))},l.prototype._updateUserMessageMetaArray=function(e,t,n,r){return f(this,void 0,void 0,(function(){var i,a,s,o,u,c;return v(this,(function(l){switch(l.label){case 0:return i=g.of(this._iid),a=i.dispatcher,s=i.requestQueue,o=new Nt({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(kt).message,a.dispatch(new F({messages:[c],source:Q.EVENT_MESSAGE_UPDATED})),[2,c]}}))}))},l.prototype._updateFileMessageMetaArray=function(e,t,n,r){return f(this,void 0,void 0,(function(){var i,a,s,o,u,c;return v(this,(function(l){switch(l.label){case 0:return i=g.of(this._iid),a=i.dispatcher,s=i.requestQueue,o=new Ft({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(Qt).message,a.dispatch(new F({messages:[c],source:Q.EVENT_MESSAGE_UPDATED})),[2,c]}}))}))},l.prototype.createMessageMetaArrayKeys=function(e,t){return f(this,void 0,void 0,(function(){var n;return v(this,(function(i){return N(e instanceof ue&&e.messageId>0&&r("string",t)).throw(y.invalidParameters),n=t.map((function(e){return new Y({key:e})})),e instanceof X?[2,this._updateFileMessageMetaArray(e.messageId,n,"add",!0)]:[2,this._updateUserMessageMetaArray(e.messageId,n,"add",!0)]}))}))},l.prototype.deleteMessageMetaArrayKeys=function(e,t){return f(this,void 0,void 0,(function(){var n;return v(this,(function(i){return N(e instanceof ue&&e.messageId>0&&r("string",t)).throw(y.invalidParameters),n=t.map((function(e){return new Y({key:e})})),e instanceof X?[2,this._updateFileMessageMetaArray(e.messageId,n,"remove",!0)]:[2,this._updateUserMessageMetaArray(e.messageId,n,"remove",!0)]}))}))},l.prototype.addMessageMetaArrayValues=function(e,t){return f(this,void 0,void 0,(function(){return v(this,(function(n){return N(e instanceof ue&&e.messageId>0&&t.every((function(e){return e instanceof Y}))).throw(y.invalidParameters),e instanceof X?[2,this._updateFileMessageMetaArray(e.messageId,t,"add",!0)]:[2,this._updateUserMessageMetaArray(e.messageId,t,"add",!0)]}))}))},l.prototype.removeMessageMetaArrayValues=function(e,t){return f(this,void 0,void 0,(function(){return v(this,(function(n){return N(e instanceof ue&&e.messageId>0&&t.every((function(e){return e instanceof Y}))).throw(y.invalidParameters),e instanceof X?[2,this._updateFileMessageMetaArray(e.messageId,t,"remove",!0)]:[2,this._updateUserMessageMetaArray(e.messageId,t,"remove",!0)]}))}))},l.prototype.report=function(e,r){return f(this,void 0,void 0,(function(){var i,a,s,o;return v(this,(function(u){switch(u.label){case 0:return N(n(Oe,e)&&t("string",r)).throw(y.invalidParameters),i=g.of(this._iid),a=i.sdkState,s=i.requestQueue,o=new Dt({channelUrl:this.url,channelType:this.channelType,userId:a.userId,category:e,description:r}),[4,s.send(o)];case 1:return u.sent(),[2]}}))}))},l.prototype.reportUser=function(e,r,a){return f(this,void 0,void 0,(function(){var s,o,u,c;return v(this,(function(l){switch(l.label){case 0:return N(e instanceof i&&n(Oe,r)&&t("string",a)).throw(y.invalidParameters),s=g.of(this._iid),o=s.sdkState,u=s.requestQueue,c=new qt({channelUrl:this.url,channelType:this.channelType,userId:o.userId,offendingUserId:e.userId,category:r,description:a}),[4,u.send(c)];case 1:return l.sent(),[2]}}))}))},l.prototype.reportMessage=function(e,r,i){return f(this,void 0,void 0,(function(){var a,s,o,u;return v(this,(function(c){switch(c.label){case 0:return N(e instanceof ce&&n(Oe,r)&&t("string",i)).throw(y.invalidParameters),a=g.of(this._iid),s=a.sdkState,o=a.requestQueue,u=new Rt({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]}}))}))},l.prototype.updatePoll=function(e,n){return f(this,void 0,void 0,(function(){var r,i,a;return v(this,(function(o){switch(o.label){case 0:return N(t("number",e)&&function(e){return t("string",e.title,!0)&&P(e.data)&&t("boolean",e.allowUserSuggestion,!0)&&t("boolean",e.allowMultipleVotes,!0)&&t("number",e.closeAt,!0)}(n)).throw(y.invalidParameters),r=g.of(this._iid).requestQueue,i=new Zt(s({pollId:e},n)),[4,r.send(i)];case 1:return a=o.sent(),[2,a.as($t).poll]}}))}))},l.prototype.deletePoll=function(e){return f(this,void 0,void 0,(function(){var n,r,i;return v(this,(function(a){switch(a.label){case 0:return n=t("number",e),N(n).throw(y.invalidParameters),r=g.of(this._iid).requestQueue,i=new en({pollId:e}),[4,r.send(i)];case 1:return a.sent(),[2]}}))}))},l.prototype.closePoll=function(e){return f(this,void 0,void 0,(function(){var n,r,i,a;return v(this,(function(s){switch(s.label){case 0:return n=t("number",e),N(n).throw(y.invalidParameters),r=g.of(this._iid).requestQueue,i=new tn({pollId:e}),[4,r.send(i)];case 1:return a=s.sent(),[2,a.as(nn).poll]}}))}))},l.prototype.addPollOption=function(e,n){return f(this,void 0,void 0,(function(){var r,i,a,s;return v(this,(function(o){switch(o.label){case 0:return r=t("number",e)&&t("string",n)&&""!==n.trim(),N(r).throw(y.invalidParameters),i=g.of(this._iid).requestQueue,a=new rn({channelUrl:this.url,channelType:this.channelType,pollId:e,optionText:n}),[4,i.send(a)];case 1:return s=o.sent(),[2,s.as(an).poll]}}))}))},l.prototype.updatePollOption=function(e,n,r){return f(this,void 0,void 0,(function(){var i,a,s,o;return v(this,(function(u){switch(u.label){case 0:return i=t("number",e)&&t("number",n)&&t("string",r)&&""!==r.trim(),N(i).throw(y.invalidParameters),a=g.of(this._iid).requestQueue,s=new sn({pollId:e,pollOptionId:n,optionText:r}),[4,a.send(s)];case 1:return o=u.sent(),[2,o.as(on).poll]}}))}))},l.prototype.deletePollOption=function(e,n){return f(this,void 0,void 0,(function(){var r,i,a;return v(this,(function(s){switch(s.label){case 0:return r=t("number",e)&&t("number",n),N(r).throw(y.invalidParameters),i=g.of(this._iid).requestQueue,a=new un({pollId:e,pollOptionId:n}),[4,i.send(a)];case 1:return s.sent(),[2]}}))}))},l.prototype.votePoll=function(e,n){return f(this,void 0,void 0,(function(){var i,a,s,o,u,c,l;return v(this,(function(d){switch(d.label){case 0:return i=t("number",e)&&r("number",n),N(i).throw(y.invalidParameters),a=g.of(this._iid),s=a.requestQueue,o=a.dispatcher,u=new cn({reqId:this._generateRequestId(),channelUrl:this.url,channelType:this.channelType,pollId:e,pollOptionIds:n}),[4,s.send(u)];case 1:return c=d.sent(),l=c.as(ln).event,o.dispatch(new K({event:l,source:Q.EVENT_POLL_VOTED})),[2,l]}}))}))},l.prototype.getPollChangeLogsSinceTimestamp=function(e){return f(this,void 0,void 0,(function(){return v(this,(function(n){switch(n.label){case 0:return N(t("number",e)).throw(y.invalidParameters),[4,pe.of(this._iid).getPollChangeLogs(this.url,this.channelType,e)];case 1:return[2,n.sent()]}}))}))},l.prototype.getPollChangeLogsSinceToken=function(e){return f(this,void 0,void 0,(function(){return v(this,(function(n){switch(n.label){case 0:return N(t("string",e,!0)),[4,pe.of(this._iid).getPollChangeLogs(this.url,this.channelType,e)];case 1:return[2,n.sent()]}}))}))},l.prototype.createPollListQuery=function(e){return void 0===e&&(e=10),new de(this._iid,{channelUrl:this.url,channelType:this.channelType,limit:e})},l.prototype.createPollVoterListQuery=function(e,t,n){return void 0===n&&(n=20),new he(this._iid,{channelUrl:this.url,channelType:this.channelType,pollId:e,pollOptionId:t,limit:n})},l}(V);export{Qt as A,Je as B,Lt as C,ge as D,ke as E,fe as F,Fe as G,Qe as H,ze as I,Ht as J,dn as K,Ke as M,ve as N,je as O,ln as P,Oe as R,be as U,ye as a,_e as b,Te as c,Ue as d,Ie as e,hn as f,Ne as g,Le as h,Ce as i,we as j,De as k,Me as l,Ae as m,Se as n,me as o,gt as p,ot as q,At as r,Ee as s,Ct as t,bt as u,Pe as v,It as w,Mt as x,xt as y,kt as z}; +import{a0 as e,a as t,I as n,l as r,U as i,a5 as a,g as s,e as o,i as u,_ as c,A as l,a7 as d,f as h,h as p,b as f,ai as m,c as v,S as y,V as g,W as _,au as T,av as U,M as I,a6 as w,a8 as M,aw as E,ax as b,as as P,aq as C,a4 as S,u as A,Y as D,a1 as q,H as R,Z as O,a9 as L,r as N,aa as k,af as F,ae as Q,x as z,ay as x,an as G,X as V,p as j,q as B,ab as W,az as K}from"./__bundle-ea43c8a8.js";import{c as Y,A as H,U as J,F as X,R as Z,T as $,d as ee,e as te,b as ne,f as re,g as ie,v as ae,h as se,i as oe,B as ue,S as ce}from"./__bundle-12fe2d56.js";import{i as le,P as de,a as he,b as pe}from"./__bundle-9a0f0a93.js";var fe,me=100,ve="GroupChannel",ye="url",ge=100,_e="Message",Te="messageId",Ue="Poll",Ie="pollId",we={data:null,customType:null,mentionType:e.USERS,mentionedUserIds:null,mentionedUsers:null,mentionedMessageTemplate:null,metaArrays:null,parentMessageId:null,isReplyToChannel:!1,pushNotificationDeliveryOption:null,appleCriticalAlertOptions:null,isPinnedMessage:!1},Me=function(s){return t("string",s.data,!0)&&t("string",s.customType,!0)&&n(e,s.mentionType)&&r("string",s.mentionedUserIds,!0)&&r(i,s.mentionedUsers,!0)&&t("string",s.mentionedMessageTemplate,!0)&&r(Y,s.metaArrays,!0)&&t("number",s.parentMessageId,!0)&&t("boolean",s.isReplyToChannel)&&n(a,s.pushNotificationDeliveryOption,!0)&&t(H,s.appleCriticalAlertOptions,!0)&&t("boolean",s.isPinnedMessage,!0)},Ee=function(e){return e?{isReplyToChannel:e.isReplyToChannel,pushNotificationDeliveryOption:e.pushNotificationDeliveryOption,pollId:e.pollId}:null},be=s(s({},we),{message:null,translationTargetLanguages:null,pollId:null}),Pe=function(e){return Me(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"}(fe||(fe={}));var Ce,Se=function(e){return"undefined"!=typeof window&&"Blob"in window&&"undefined"!=typeof Blob&&e instanceof Blob},Ae=function(e){return e===fe.BLOB||e===fe.FILE},De=function(e){return e?{file:e.file,fileKey:e.fileKey,fileType:e.fileType,isReplyToChannel:e.isReplyToChannel,pushNotificationDeliveryOption:e.pushNotificationDeliveryOption}:null},qe=s(s({},we),{file:null,fileKey:null,fileUrl:null,fileName:null,fileType:null,fileSize:null,mimeType:null,thumbnailSizes:null,requireAuth:!1}),Re=function(e){return Me(e)&&(u(e.file)||t("string",e.fileUrl))&&t("string",e.fileName,!0)&&t("string",e.mimeType,!0)&&t("number",e.fileSize,!0)&&(null===e.thumbnailSizes||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"}(Ce||(Ce={}));var Oe,Le=function(){function e(e){var t,r,i,a;this.restrictionType=null,this.description=null,this.endAt=-1,this.remainingDuration=-1,n(Ce,e.restriction_type)&&(this.restrictionType=e.restriction_type),this.description=null!==(t=e.description)&&void 0!==t?t:null,this.endAt=null!==(i=null!==(r=e.end_at)&&void 0!==r?r:e.muted_end_at)&&void 0!==i?i:-1,this.remainingDuration=null!==(a=e.remaining_duration)&&void 0!==a?a:-1}return e.payloadify=function(e){return e?o({restriction_type:e.restrictionType,description:e.description,end_at:e.endAt,remaining_duration:e.remainingDuration}):null},e}(),Ne=function(e){function t(t,n){var r=e.call(this,t,n)||this;return r.restrictionInfo=null,r.restrictionInfo=new Le(n),r}return c(t,e),t.payloadify=function(t){return t?o(s(s({},e.payloadify.call(this,t)),Le.payloadify(t.restrictionInfo))):null},t}(i),ke={data:null,customType:null,mentionType:e.USERS,mentionedUserIds:null,mentionedUsers:null,mentionedMessageTemplate:null,metaArrays:null,pushNotificationDeliveryOption:null,appleCriticalAlertOptions:null},Fe=function(s){return t("string",s.data,!0)&&t("string",s.customType,!0)&&n(e,s.mentionType)&&r("string",s.mentionedUserIds,!0)&&r(i,s.mentionedUsers,!0)&&t("string",s.mentionedMessageTemplate,!0)&&r(Y,s.metaArrays,!0)&&n(a,s.pushNotificationDeliveryOption,!0)&&t(H,s.appleCriticalAlertOptions,!0)},Qe=s(s({},ke),{message:null,translationTargetLanguages:null,pollId:null}),ze=function(e){return Fe(e)&&t("string",e.message,!0)&&r("string",e.translationTargetLanguages,!0)&&t("number",e.pollId,!0)},xe=s({},ke),Ge=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=l.GET,s.path="".concat(d(r),"/").concat(encodeURIComponent(n),"/operators"),s.params={token:i,limit:a},s}return c(t,e),t}(h),Ve=function(e){function t(t,n){var r=e.call(this,t,n)||this;return r.operators=n.operators.map((function(e){return new i(t,e)})),r.token=n.next,r}return c(t,e),t}(p),je=function(e){function t(t,n,r,i){return e.call(this,t,n,r,i)||this}return c(t,e),t.prototype._validate=function(){return e.prototype._validate.call(this)},t.prototype.next=function(){return f(this,void 0,void 0,(function(){var e,t,n,r,i,a,o;return v(this,(function(u){switch(u.label){case 0:return this._validate()?this._isLoading?[3,3]:(e=[],this._hasNext?(this._isLoading=!0,t=g.of(this._iid).requestQueue,n=new Ge(s(s({},this),{channelUrl:this.channelUrl,token:this._token})),[4,t.send(n)]):[3,2]):[3,5];case 1:return r=u.sent(),i=r.as(Ve),a=i.operators,o=i.token,this._token=o,this._hasNext=!!o,this._isLoading=!1,[2,a];case 2:return[2,e];case 3:throw y.queryInProgress;case 4:return[3,6];case 5:throw y.invalidParameters;case 6:return[2]}}))}))},t}(m),Be=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=l.GET,n.path="".concat(d(i),"/").concat(encodeURIComponent(r),"/mute"),n.params={limit:a,token:s},n}return c(t,e),t}(h),We=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 Ne(t,e)}))),r}return c(t,e),t}(p),Ke=function(e){function t(t,n,r,i){return e.call(this,t,n,r,i)||this}return c(t,e),t.prototype.next=function(){return f(this,void 0,void 0,(function(){var e,t,n,r,i,a;return v(this,(function(o){switch(o.label){case 0:return this._validate()?this._isLoading?[3,3]:this._hasNext?(this._isLoading=!0,e=g.of(this._iid).requestQueue,t=new Be(s(s({},this),{token:this._token})),[4,e.send(t)]):[3,2]:[3,5];case 1:return n=o.sent(),r=n.as(We),i=r.mutedUsers,a=r.token,this._token=a,this._hasNext=!!a,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]}}))}))},t}(m),Ye=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=l.GET,n.path="".concat(d(i),"/").concat(encodeURIComponent(r),"/ban"),n.params=o({limit:a,token:s}),n}return c(t,e),t}(h),He=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 Ne(t,e.user)}))),r}return c(t,e),t}(p),Je=function(e){function t(t,n,r,i){return e.call(this,t,n,r,i)||this}return c(t,e),t.prototype._validate=function(){return e.prototype._validate.call(this)},t.prototype.next=function(){return f(this,void 0,void 0,(function(){var e,t,n,r,i,a;return v(this,(function(o){switch(o.label){case 0:return this._validate()?this._isLoading?[3,3]:this._hasNext?(this._isLoading=!0,e=g.of(this._iid).requestQueue,t=new Ye(s(s({},this),{token:this._token})),[4,e.send(t)]):[3,2]:[3,5];case 1:return n=o.sent(),r=n.as(He),i=r.bannedUsers,a=r.token,this._token=a,this._hasNext=!!a,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]}}))}))},t}(m);!function(e){e.SPAM="spam",e.HARASSING="harassing",e.SUSPICIOUS="suspicious",e.INAPPROPRIATE="inappropriate"}(Oe||(Oe={}));var Xe=function(e){function t(t){var n=this,r=t.channelUrl,i=t.channelType,a=t.operatorUserIds;return(n=e.call(this)||this).method=l.POST,n.path="".concat(d(i),"/").concat(encodeURIComponent(r),"/operators"),n.params={operator_ids:a},n}return c(t,e),t}(h);!function(e){function t(){return null!==e&&e.apply(this,arguments)||this}c(t,e)}(p);var Ze=function(e){function t(t){var n=this,r=t.channelUrl,i=t.channelType,a=t.operatorUserIds;return(n=e.call(this)||this).method=l.DELETE,n.path="".concat(d(i),"/").concat(encodeURIComponent(r),"/operators"),n.params={operator_ids:a},n}return c(t,e),t}(h);!function(e){function t(t,n){return e.call(this,t,n)||this}c(t,e)}(p);var $e=function(e){function t(t){var n=this,r=t.channelUrl,i=t.channelType,a=t.userId;return(n=e.call(this)||this).method=l.GET,n.path="".concat(d(i),"/").concat(encodeURIComponent(r),"/mute/").concat(a),n}return c(t,e),t}(h),et=function(e){function t(t,n){var r=e.call(this,t,n)||this;r.isMuted=!1,r.startAt=null,r.endAt=null,r.remainingDuration=null,r.description=null;var i=n.is_muted,a=n.start_at,s=n.end_at,o=n.remaining_duration,u=n.description;return r.isMuted=i,r.startAt=a,r.endAt=s,r.remainingDuration=o,r.description=u,r}return c(t,e),t}(p),tt=function(e){function t(t){var n=this,r=t.channelUrl,i=t.channelType,a=t.keys;return(n=e.call(this)||this).method=l.GET,n.path="".concat(d(i),"/").concat(encodeURIComponent(r),"/metadata"),n.params={keys:a,include_ts:!0},n}return c(t,e),t}(h),nt=function(e){function t(t,n){var r=e.call(this,t,n)||this;r.ts=null;var i=n.metadata,a=n.ts;return r.metadata=i,r.ts=null!=a?a:null,r}return c(t,e),t}(p),rt=function(e){function t(t){var n=this,r=t.channelUrl,i=t.channelType,a=t.metadata;return(n=e.call(this)||this).method=l.POST,n.path="".concat(d(i),"/").concat(encodeURIComponent(r),"/metadata"),n.params={metadata:a,include_ts:!0},n}return c(t,e),t}(h),it=function(e){function t(t,n){var r,i,a=this;return(a=e.call(this,t,n)||this).metaData=null!==(r=n.metadata)&&void 0!==r?r:{},a.ts=null!==(i=n.ts)&&void 0!==i?i:null,a}return c(t,e),t}(p),at=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=l.PUT,n.path="".concat(d(i),"/").concat(encodeURIComponent(r),"/metadata"),n.params={metadata:a,include_ts:!0,upsert:null!=s&&s},n}return c(t,e),t}(h),st=function(e){function t(t,n){var r=e.call(this,t,n)||this;r.ts=null;var i=n.metadata,a=n.ts;return r.metadata=i,r.ts=null!=a?a:null,r}return c(t,e),t}(p),ot=function(e){function t(t,n,r){var i=e.call(this,t,"SYEV",r)||this;return i.created=null,i.updated=null,i.deleted=null,r.data&&(i.created=r.data.created,i.updated=r.data.updated,i.deleted=r.data.deleted),i}return c(t,e),t}(_),ut=function(e){function t(t){var n=this,r=t.channelUrl,i=t.channelType,a=t.key;return(n=e.call(this)||this).method=l.DELETE,n.path="".concat(d(i),"/").concat(encodeURIComponent(r),"/metadata/").concat(a),n.params={include_ts:!0},n}return c(t,e),t}(h),ct=function(e){function t(t,n){var r=e.call(this,t,n)||this;r.ts=null;var i=n.ts;return r.ts=null!=i?i:null,r}return c(t,e),t}(p),lt=function(e){function t(t){var n=this,r=t.channelUrl,i=t.channelType;return(n=e.call(this)||this).method=l.DELETE,n.path="".concat(d(i),"/").concat(encodeURIComponent(r),"/metadata"),n.params={include_ts:!0},n}return c(t,e),t}(h),dt=function(e){function t(t,n){var r=e.call(this,t,n)||this;r.ts=null;var i=n.ts;return r.ts=null!=i?i:null,r}return c(t,e),t}(p),ht=function(e){function t(t){var n=this,r=t.channelUrl,i=t.channelType,a=t.keys;return(n=e.call(this)||this).method=l.GET,n.path="".concat(d(i),"/").concat(encodeURIComponent(r),"/metacounter"),n.params={keys:a},n}return c(t,e),t}(h),pt=function(e){function t(t,n){var r=e.call(this,t,n)||this;return r.metaCounter=n,r}return c(t,e),t}(p),ft=function(e){function t(t){var n=this,r=t.channelUrl,i=t.channelType,a=t.metaCounter;return(n=e.call(this)||this).method=l.POST,n.path="".concat(d(i),"/").concat(encodeURIComponent(r),"/metacounter"),n.params={metacounter:a},n}return c(t,e),t}(h),mt=function(e){function t(t,n){var r=e.call(this,t,n)||this;return r.metaCounter=n,r}return c(t,e),t}(p),vt=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=l.PUT,n.path="".concat(d(i),"/").concat(encodeURIComponent(r),"/metacounter"),n.params={metacounter:a,upsert:o,mode:c},n}return c(t,e),t}(h),yt=function(e){function t(t,n){var r=e.call(this,t,n)||this;return r.metaCounter=n,r}return c(t,e),t}(p),gt=function(e){function t(t,n,r){var i=e.call(this,t,"SYEV",r)||this;return i.created=null,i.updated=null,i.deleted=null,r.data&&(i.created=r.data.created,i.updated=r.data.updated,i.deleted=r.data.deleted),i}return c(t,e),t}(_),_t=function(e){function t(t){var n=this,r=t.channelUrl,i=t.channelType,a=t.key;return(n=e.call(this)||this).method=l.DELETE,n.path="".concat(d(i),"/").concat(encodeURIComponent(r),"/metacounter/").concat(a),n.params=null,n}return c(t,e),t}(h);!function(e){function t(t,n){return e.call(this,t,n)||this}c(t,e)}(p);var Tt=function(e){function t(t){var n=this,r=t.channelUrl,i=t.channelType;return(n=e.call(this)||this).method=l.DELETE,n.path="".concat(d(i),"/").concat(encodeURIComponent(r),"/metacounter"),n.params=null,n}return c(t,e),t}(h);!function(e){function t(){return null!==e&&e.apply(this,arguments)||this}c(t,e)}(p);var Ut=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=l.POST,n.path="".concat(d(i),"/").concat(encodeURIComponent(r),"/mute"),n.params={user_id:a,seconds:s,description:o},n}return c(t,e),t}(h);!function(e){function t(t,n){return e.call(this,t,n)||this}c(t,e)}(p);var It=function(e){function t(t,n,r){var i=e.call(this,t,"SYEV",r)||this;return i.user=new Ne(t,r.data),i}return c(t,e),t}(_),wt=function(e){function t(t){var n=this,r=t.channelUrl,i=t.channelType,a=t.userId;return(n=e.call(this)||this).method=l.DELETE,n.path="".concat(d(i),"/").concat(encodeURIComponent(r),"/mute/").concat(encodeURIComponent(a)),n}return c(t,e),t}(h);!function(e){function t(){return null!==e&&e.apply(this,arguments)||this}c(t,e)}(p);var Mt=function(e){function t(t,n,r){var i=e.call(this,t,"SYEV",r)||this;return i.user=new Ne(t,r.data),i}return c(t,e),t}(_),Et=function(e){function t(t){var n=this,r=t.channelUrl,i=t.channelType,a=t.userId,s=t.seconds,u=t.description;return(n=e.call(this)||this).method=l.POST,n.path="".concat(d(i),"/").concat(encodeURIComponent(r),"/ban"),n.params=o({user_id:a,seconds:s,description:u}),n}return c(t,e),t}(h);!function(e){function t(){return null!==e&&e.apply(this,arguments)||this}c(t,e)}(p);var bt=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 Ne(t,r.data),r.data.member_count&&(i.memberCount=r.data.member_count),r.data.joined_member_count&&(i.joinedMemberCount=r.data.joined_member_count),i}return c(t,e),t}(_),Pt=function(e){function t(t){var n=this,r=t.channelUrl,i=t.channelType,a=t.userId;return(n=e.call(this)||this).method=l.DELETE,n.path="".concat(d(i),"/").concat(encodeURIComponent(r),"/ban/").concat(encodeURIComponent(a)),n}return c(t,e),t}(h);!function(e){function t(){return null!==e&&e.apply(this,arguments)||this}c(t,e)}(p);var Ct=function(e){function t(t,n,r){var i=e.call(this,t,"SYEV",r)||this;return i.user=new Ne(t,r.data),i}return c(t,e),t}(_),St=function(e){function t(t){var n=this,r=t.channelUrl,i=t.channelType,a=t.freezing;return(n=e.call(this)||this).method=l.PUT,n.path="".concat(d(i),"/").concat(encodeURIComponent(r),"/freeze"),n.params={freeze:a},n}return c(t,e),t}(h);!function(e){function t(){return null!==e&&e.apply(this,arguments)||this}c(t,e)}(p);var At=function(e){function t(t,n,r){var i=e.call(this,t,"SYEV",r)||this;return i.freeze=r.data.freeze,i}return c(t,e),t}(_),Dt=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=l.POST,n.path="".concat(T(i),"/").concat(encodeURIComponent(r)),n.params={report_category:a,reporting_user_id:s,report_description:o},n}return c(t,e),t}(h),qt=function(e){function t(t){var n=this,r=t.channelUrl,i=t.channelType,a=t.category,s=t.userId,o=t.offendingUserId,u=t.description;return(n=e.call(this)||this).method=l.POST,n.path="".concat(U,"/users/").concat(o),n.params={channel_url:r,channel_type:i===I.OPEN?"open_channels":"group_channels",report_category:a,reporting_user_id:s,report_description:u},n}return c(t,e),t}(h),Rt=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=l.POST,n.path="".concat(T(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 c(t,e),t}(h),Ot=function(t){function n(n){var r=[];return n.mentionType===e.USERS&&(n.mentionedUserIds?r=n.mentionedUserIds:n.mentionedUsers&&(r=n.mentionedUsers.map((function(e){return e.userId})))),t.call(this,{code:"MESG",ackRequired:!0,payload:o({channel_url:n.channelUrl,message:n.message,data:n.data,custom_type:n.customType,metaarray:n.metaArrays,mention_type:n.mentionType,mentioned_user_ids:r,mentioned_message_template:n.mentionedMessageTemplate,target_langs:n.translationTargetLanguages,push_option:n.pushNotificationDeliveryOption&&n.pushNotificationDeliveryOption!==a.DEFAULT?n.pushNotificationDeliveryOption:void 0,apple_critical_alert_options:n.appleCriticalAlertOptions,silent:n.silent,reply_to_channel:n.isReplyToChannel,parent_message_id:n.parentMessageId>0?n.parentMessageId:null,req_id:n.reqId,poll_id:n.pollId,pin_message:n.isPinnedMessage})})||this}return c(n,t),n}(w),Lt=function(e){function t(t,n,r){var i,a,s,o=this;(o=e.call(this,t,"MESG",r)||this).message=new J(t,r);var u=g.of(t).sdkState;return o.isMentioned=M(o.message.mentionType,null!==(i=o.message.mentionedUserIds)&&void 0!==i?i:null===(a=o.message.mentionedUsers)||void 0===a?void 0:a.map((function(e){return e.userId})),u.userId),o.forceUpdateLastMessage=null!==(s=r.force_update_last_message)&&void 0!==s&&s,o}return c(t,e),t}(_),Nt=function(t){function n(n){var r,i=null;return n.mentionType===e.USERS&&(n.mentionedUserIds?i=n.mentionedUserIds:n.mentionedUsers&&(i=n.mentionedUsers.map((function(e){return e.userId})))),t.call(this,{code:"MEDI",ackRequired:!0,payload:o({channel_url:n.channelUrl,msg_id:n.messageId,message:n.message,data:n.data,custom_type:n.customType,metaarray:n.metaArrayParams,mention_type:n.mentionType,mentioned_user_ids:i,mentioned_message_template:n.mentionedMessageTemplate,apple_critical_alert_options:null===(r=n.appleCriticalAlertOptions)||void 0===r?void 0:r.serialize(),poll_id:n.pollId})})||this}return c(n,t),n}(w),kt=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 J(t,r);var d=g.of(t).sdkState;return l.mentionCountChange=E({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 c(t,e),t}(_),Ft=function(t){function n(n){var r=null;return n.mentionType===e.USERS&&(n.mentionedUserIds?r=n.mentionedUserIds:n.mentionedUsers&&(r=n.mentionedUsers.map((function(e){return e.userId})))),t.call(this,{code:"FEDI",ackRequired:!0,payload:o({channel_url:n.channelUrl,msg_id:n.messageId,data:n.data,custom_type:n.customType,metaarray:n.metaArrayParams,mention_type:n.mentionType,mentioned_user_ids:r,apple_critical_alert_options:n.appleCriticalAlertOptions})})||this}return c(n,t),n}(w),Qt=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 X(t,r);var d=g.of(t).sdkState;return l.mentionCountChange=E({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 c(t,e),t}(_),zt=function(e){function t(t){var n=e.call(this)||this;return n.method=l.DELETE,n.path="".concat(d(t.channelType),"/").concat(t.channelUrl,"/messages/").concat(t.messageId),n}return c(t,e),t}(h);!function(e){function t(){return null!==e&&e.apply(this,arguments)||this}c(t,e)}(p);var xt=function(e){function t(t,n,r){var i=e.call(this,t,"DELM",r)||this;return i.channelUrl=r.channel_url,i.channelType=r.channel_type,i.messageId=Number(r.msg_id),i}return c(t,e),t}(_),Gt=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=l.POST,s.path="".concat(d(n),"/").concat(encodeURIComponent(r),"/messages/").concat(i,"/reactions"),s.params={reaction:a},s}return c(t,e),t}(h),Vt=function(e){function t(t,n){var r=e.call(this,t,n)||this;return r.reactionEvent=new Z(n),r}return c(t,e),t}(p),jt=function(e){function t(t){var n=t.channelType,r=t.channelUrl,i=t.messageId,a=t.reactionKey,s=e.call(this)||this;return s.method=l.DELETE,s.path="".concat(d(n),"/").concat(encodeURIComponent(r),"/messages/").concat(i,"/reactions"),s.params={reaction:a},s}return c(t,e),t}(h),Bt=function(e){function t(t,n){var r=e.call(this,t,n)||this;return r.reactionEvent=new Z(s({},n)),r}return c(t,e),t}(p),Wt=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=l.POST,s.path="".concat(d(n),"/").concat(encodeURIComponent(r),"/messages/").concat(encodeURIComponent(i),"/translation"),s.params={target_langs:a},s}return c(t,e),t}(h),Kt=function(e){function t(t,n){var r=e.call(this,t,n)||this;return r.message=new J(t,n),r}return c(t,e),t}(p),Yt=function(t){function n(n){var r,i=this;i=t.call(this)||this;var a=[];n.mentionType===e.USERS&&(n.mentionedUserIds?a=n.mentionedUserIds:n.mentionedUsers&&(a=n.mentionedUsers.map((function(e){return e.userId}))));var s=n.channelType,o=n.channelUrl;return i.method=l.POST,i.path="".concat(d(s),"/").concat(encodeURIComponent(o),"/scheduled_messages"),i.params={req_id:n.reqId,scheduled_at:n.scheduledAt,message_type:b.USER,message:n.message,custom_type:n.customType,data:n.data,mention_type:n.mentionType,mentioned_user_ids:a,sorted_metaarray:null===(r=n.metaArrays)||void 0===r?void 0:r.map((function(e){return Y.payloadify(e)})),apple_critical_alert_options:H.payloadify(n.appleCriticalAlertOptions),target_langs:n.translationTargetLanguages,push_option:n.pushNotificationDeliveryOption},i}return c(n,t),n}(h),Ht=function(e){function t(t,n){var r=e.call(this,t,n)||this;return r.message=new J(t,n),r}return c(t,e),t}(p),Jt=function(t){function n(n){var r,i=this;i=t.call(this)||this;var a=[];n.mentionType===e.USERS&&(n.mentionedUserIds?a=n.mentionedUserIds:n.mentionedUsers&&(a=n.mentionedUsers.map((function(e){return e.userId}))));var s=n.channelType,o=n.channelUrl;return i.method=l.POST,i.path="".concat(d(s),"/").concat(encodeURIComponent(o),"/scheduled_messages"),i.params={req_id:n.reqId,scheduled_at:n.scheduledAt,message_type:b.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 $.payloadify(e)})):[],custom_type:n.customType,data:n.data,require_auth:n.requireAuth,mention_type:n.mentionType,mentioned_user_ids:a,sorted_metaarray:null===(r=n.metaArrays)||void 0===r?void 0:r.map((function(e){return Y.payloadify(e)})),apple_critical_alert_options:H.payloadify(n.appleCriticalAlertOptions),push_option:n.pushNotificationDeliveryOption},i}return c(n,t),n}(h),Xt=function(e){function t(t,n){var r=e.call(this,t,n)||this;return r.message=new X(t,n),r}return c(t,e),t}(p),Zt=function(e){function t(t){var n=t.pollId,r=t.title,i=t.data,a=t.allowUserSuggestion,s=t.allowMultipleVotes,o=t.closeAt,u=e.call(this)||this;return u.method=l.PUT,u.path="".concat(C,"/").concat(encodeURIComponent(n)),u.params={title:r,data:i,allow_user_suggestion:a,allow_multiple_votes:s,close_at:o},u}return c(t,e),t}(h),$t=function(e){function t(t,n){var r=e.call(this,t,n)||this;return r.poll=new S(t,n),r}return c(t,e),t}(p),en=function(e){function t(t){var n=t.pollId,r=e.call(this)||this;return r.method=l.DELETE,r.path="".concat(C,"/").concat(encodeURIComponent(n)),r}return c(t,e),t}(h);!function(e){function t(){return null!==e&&e.apply(this,arguments)||this}c(t,e)}(p);var tn=function(e){function t(t){var n=t.pollId,r=e.call(this)||this;return r.method=l.PUT,r.path="".concat(C,"/").concat(encodeURIComponent(n),"/close"),r}return c(t,e),t}(h),nn=function(e){function t(t,n){var r=e.call(this,t,n)||this;return r.poll=new S(t,n),r}return c(t,e),t}(p),rn=function(e){function t(t){var n=t.channelUrl,r=t.channelType,i=t.pollId,a=t.optionText,s=e.call(this)||this;return s.method=l.POST,s.path="".concat(C,"/").concat(encodeURIComponent(i),"/options"),s.params={channel_url:n,channel_type:r,text:a},s}return c(t,e),t}(h),an=function(e){function t(t,n){var r=e.call(this,t,n)||this;return r.poll=new S(t,n),r}return c(t,e),t}(p),sn=function(e){function t(t){var n=t.pollId,r=t.pollOptionId,i=t.optionText,a=e.call(this)||this;return a.method=l.PUT,a.path="".concat(C,"/").concat(encodeURIComponent(n),"/options/").concat(encodeURIComponent(r)),a.params={text:i},a}return c(t,e),t}(h),on=function(e){function t(t,n){var r=e.call(this,t,n)||this;return r.poll=new S(t,n),r}return c(t,e),t}(p),un=function(e){function t(t){var n=t.pollId,r=t.pollOptionId,i=e.call(this)||this;return i.method=l.DELETE,i.path="".concat(C,"/").concat(encodeURIComponent(n),"/options/").concat(encodeURIComponent(r)),i}return c(t,e),t}(h);!function(e){function t(){return null!==e&&e.apply(this,arguments)||this}c(t,e)}(p);var cn=function(e){function t(t){var n=t.reqId,r=t.channelType,i=t.channelUrl,a=t.pollId,s=t.pollOptionIds;return e.call(this,{code:"VOTE",ackRequired:!0,payload:o({req_id:n,channel_type:r===I.OPEN?"open_channels":"group_channels",channel_url:i,poll_id:a,option_ids:s})})||this}return c(t,e),t}(w),ln=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 le(r),i.channelUrl=r.channel_url,i.channelType=r.channel_type,i}return c(t,e),t}(_),dn=2,hn=function(e){function l(n,r){var a,s,o,u,c=this;return(c=e.call(this,n)||this).url="",c.channelType=I.BASE,c.name="",c.coverUrl="",c.customType="",c.data="",c.isFrozen=!1,c.isEphemeral=!1,c.creator=null,c.createdAt=0,c._messageCollectionLastAccessedAt=0,c.url=r.channel_url,c.name=null!==(a=r.name)&&void 0!==a?a:"",c.coverUrl=null!==(s=r.cover_url)&&void 0!==s?s:"",c.customType=null!==(o=r.custom_type)&&void 0!==o?o:"",c.data=null!==(u=r.data)&&void 0!==u?u:"",c.isFrozen=!!t("boolean",r.freeze)&&r.freeze,c.isEphemeral=!!t("boolean",r.is_ephemeral)&&r.is_ephemeral,c.creator=r.created_by?new i(c._iid,r.created_by):null,c.createdAt=1e3*r.created_at,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 c(l,e),l.payloadify=function(t){return o(s(s({},e.payloadify.call(this,t)),{channel_url:t.url,name:t.name,cover_url:t.coverUrl,custom_type:t.customType,data:t.data,freeze:t.isFrozen,is_ephemeral:t.isEphemeral,created_by:i.payloadify(t.creator),created_at:t.createdAt/1e3}))},l.prototype.isGroupChannel=function(){return this.channelType===I.GROUP},l.prototype.isOpenChannel=function(){return this.channelType===I.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}),Object.defineProperty(l.prototype,"messageCollectionLastAccessedAt",{get:function(){return this._messageCollectionLastAccessedAt},enumerable:!1,configurable:!0}),l.prototype._updateMessageCollectionLastAccessedAt=function(){this._messageCollectionLastAccessedAt=Date.now()},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&&r("string",t)).throw(y.invalidParameters),n=g.of(this._iid).requestQueue,i=new Wt({channelType:this.channelType,channelUrl:this.url,messageId:e.messageId,translationTargetLanguages:t}),[4,n.send(i)];case 1:return a=s.sent(),[2,a.as(Kt).message]}}))}))},l.prototype._createScheduledUserMessage=function(e,t){var n=this,r=g.of(this._iid).requestQueue,i=Date.now(),a=this._generateRequestId();k(2).then((function(){var r=n._createPendingScheduledUserMessage(e,a,i);z((function(){return f(n,void 0,void 0,(function(){return v(this,(function(e){return[2,t._trigger(null,r)]}))}))}))}));var o=new Yt(s({reqId:a,channelType:this.channelType,channelUrl:this.url},e));r.send(o).then((function(e){var r=e.as(Ht).message;z((function(){return f(n,void 0,void 0,(function(){return v(this,(function(e){return[2,t._trigger(null,r)]}))}))}))})).catch((function(r){if(x(r))throw r;k(2).then((function(){var s=n._createPendingScheduledUserMessage(e,a,i);n._markMessageAsFailed(s,r),z((function(){return f(n,void 0,void 0,(function(){return v(this,(function(e){return[2,t._trigger(r,s)]}))}))}))}))}))},l.prototype.sendFileMessage=function(e){var t=s(s({},qe),e);return N(Re(t)).throw(y.invalidParameters),this._sendFileMessage(t)},l.prototype._sendFileMessage=function(e,t){var n=this;void 0===t&&(t=null);var r=g.of(this._iid).dispatcher,i=ne.of(this._iid).fileMessageQueue,a=t,s=Date.now(),o=new re;return a||(a=this._generateRequestId(),k(2).then((function(){var t=n._createPendingFileMessage(e,a,s);r.dispatch(new F({messages:[t],source:Q.EVENT_MESSAGE_SENT_PENDING})),z((function(){return f(n,void 0,void 0,(function(){return v(this,(function(e){return[2,o._trigger(null,t)]}))}))}))}))),i.request(this,a,e).then((function(e){r.dispatch(new F({messages:[e],source:Q.EVENT_MESSAGE_SENT_SUCCESS})),z((function(){return f(n,void 0,void 0,(function(){return v(this,(function(t){return[2,o._trigger(null,e)]}))}))}))})).catch((function(t){if(x(t))throw t;k(2).then((function(){var i=n._createPendingFileMessage(e,a,s),u=g.of(n._iid).cacheContext.localCacheEnabled&&G(t.code);n._markMessageAsFailed(i,t,u),r.dispatch(new F({messages:[i],source:i.sendingStatus===q.PENDING?Q.REQUEST_RESEND_MESSAGE:Q.EVENT_MESSAGE_SENT_FAILED})),z((function(){return f(n,void 0,void 0,(function(){return v(this,(function(e){return[2,o._trigger(t,i)]}))}))}))}))})),o},l.prototype._autoResendFileMessage=function(e){N(e instanceof X).throw(y.invalidParameters);var t=g.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,r){var i=this,a=g.of(this._iid).requestQueue,o=new Jt(s(s({reqId:n,channelType:this.channelType,channelUrl:this.url},e),{fileUrl:e.fileUrl,requireAuth:e.requireAuth}));a.send(o).then((function(e){var n=e.as(Xt).message;z((function(){return f(i,void 0,void 0,(function(){return v(this,(function(e){return[2,t._trigger(null,n)]}))}))}))})).catch((function(a){if(x(a))throw a;k(2).then((function(){var s=i._createPendingScheduledFileMessage(e,n,r);i._markMessageAsFailed(s,a),z((function(){return f(i,void 0,void 0,(function(){return v(this,(function(e){return[2,t._trigger(a,s)]}))}))}))}))}))},l.prototype.sendFileMessages=function(e){var t,n;N(e.every((function(e){return Re(s(s({},qe),e))}))).throw(y.invalidParameters);var r=new re;try{for(var i=R(e),a=i.next();!a.done;a=i.next()){var o=a.value;this.sendFileMessage(o).onPending((function(e){return r._trigger(null,e)})).onFailed((function(e,t){return r._trigger(e,t)})).onSucceeded((function(e){return r._trigger(null,e)}))}}catch(e){t={error:e}}finally{try{a&&!a.done&&(n=i.return)&&n.call(i)}finally{if(t)throw t.error}}return r},l.prototype.resendFileMessage=function(e,t){var n;return f(this,void 0,void 0,(function(){var r,i,a;return v(this,(function(s){return r=Boolean(e.url)||u(t)||u(null===(n=e.messageParams)||void 0===n?void 0:n.file),N(e instanceof X&&r&&!e.scheduledInfo).throw(y.invalidParameters),i=new W,a=function(e,t){var n;return void 0===t&&(t=null),e.messageParams?(!e.url&&u(t)&&(e.messageParams.file=t),e.messageParams):o({data:e.data,customType:e.customType,mentionType:e.mentionType,mentionedUsers:e.mentionedUsers,mentionedUserIds:e.mentionedUserIds,metaArrays:e.metaArrays,parentMessageId:e.parentMessageId,appleCriticalAlertOptions:e.appleCriticalAlertOptions,file:null!=t?t:null===(n=e.messageParams)||void 0===n?void 0:n.file,fileUrl:e.url,fileName:e.name,fileSize:e.size,mimeType:e.type,thumbnailSizes: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,n){return f(this,void 0,void 0,(function(){var r,i,a,o;return v(this,(function(u){switch(u.label){case 0:return r=s(s({},xe),n),N(t("number",e)&&function(e){return Fe(e)}(r)).throw(y.invalidParameters),i=g.of(this._iid).requestQueue,a=new Ft(s({channelType:this.channelType,channelUrl:this.url,messageId:e},r)),[4,i.send(a)];case 1:return o=u.sent(),[2,o.as(Qt).message]}}))}))},l.prototype.cancelUploadingFileMessage=function(e){return f(this,void 0,void 0,(function(){return v(this,(function(n){return N(t("string",e)).throw(y.invalidParameters),ne.of(this._iid).fileMessageQueue.cancel(this,e),[2,!0]}))}))},l.prototype.copyFileMessage=function(e,t){var n,r;return f(this,void 0,void 0,(function(){var i,o;return v(this,(function(u){return N(e instanceof l&&t instanceof X&&t.sendingStatus===q.SUCCEEDED&&this.url===t.channelUrl&&!t.scheduledInfo).throw(y.invalidParameters),i=new W,o=s(s({},t),{fileUrl:t.url,fileName:t.name,fileSize:t.size,mimeType:t.type,mentionType:t.mentionType,mentionedUserIds:null!==(n=t.mentionedUserIds)&&void 0!==n?n:null===(r=t.mentionedUsers)||void 0===r?void 0:r.map((function(e){return e.userId})),pushNotificationDeliveryOption:a.DEFAULT,parentMessageId:null,isReplyToChannel:!1,thumbnailSizes:t.thumbnails.map((function(e){return{maxWidth:e.width,maxHeight:e.height}})),requireAuth:t.requireAuth,isPinnedMessage:!1}),e._sendFileMessage(o).onSucceeded((function(e){return i.resolve(e)})).onFailed((function(e){return i.reject(e)})),[2,i.promise]}))}))},l.prototype.deleteMessage=function(e){return f(this,void 0,void 0,(function(){var t,n;return v(this,(function(r){switch(r.label){case 0:return N(e instanceof ue).throw(y.invalidParameters),e.messageId>0?(t=g.of(this._iid).requestQueue,n=new zt({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,n){return f(this,void 0,void 0,(function(){var r,i,a;return v(this,(function(s){switch(s.label){case 0:return N(e instanceof ue&&e.messageId>0&&t("string",n)).throw(y.invalidParameters),r=g.of(this._iid).requestQueue,i=new Gt({channelType:this.channelType,channelUrl:this.url,messageId:e.messageId,reactionKey:n}),[4,r.send(i)];case 1:return a=s.sent(),[2,a.as(Vt).reactionEvent]}}))}))},l.prototype.deleteReaction=function(e,n){return f(this,void 0,void 0,(function(){var r,i,a;return v(this,(function(s){switch(s.label){case 0:return N(e instanceof ue&&e.messageId>0&&t("string",n)).throw(y.invalidParameters),r=g.of(this._iid).requestQueue,i=new jt({channelType:this.channelType,channelUrl:this.url,messageId:e.messageId,reactionKey:n}),[4,r.send(i)];case 1:return a=s.sent(),[2,a.as(Bt).reactionEvent]}}))}))},l.prototype._updateUserMessageMetaArray=function(e,t,n,r){return f(this,void 0,void 0,(function(){var i,a,s,o,u,c;return v(this,(function(l){switch(l.label){case 0:return i=g.of(this._iid),a=i.dispatcher,s=i.requestQueue,o=new Nt({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(kt).message,a.dispatch(new F({messages:[c],source:Q.EVENT_MESSAGE_UPDATED})),[2,c]}}))}))},l.prototype._updateFileMessageMetaArray=function(e,t,n,r){return f(this,void 0,void 0,(function(){var i,a,s,o,u,c;return v(this,(function(l){switch(l.label){case 0:return i=g.of(this._iid),a=i.dispatcher,s=i.requestQueue,o=new Ft({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(Qt).message,a.dispatch(new F({messages:[c],source:Q.EVENT_MESSAGE_UPDATED})),[2,c]}}))}))},l.prototype.createMessageMetaArrayKeys=function(e,t){return f(this,void 0,void 0,(function(){var n;return v(this,(function(i){return N(e instanceof ue&&e.messageId>0&&r("string",t)).throw(y.invalidParameters),n=t.map((function(e){return new Y({key:e})})),e instanceof X?[2,this._updateFileMessageMetaArray(e.messageId,n,"add",!0)]:[2,this._updateUserMessageMetaArray(e.messageId,n,"add",!0)]}))}))},l.prototype.deleteMessageMetaArrayKeys=function(e,t){return f(this,void 0,void 0,(function(){var n;return v(this,(function(i){return N(e instanceof ue&&e.messageId>0&&r("string",t)).throw(y.invalidParameters),n=t.map((function(e){return new Y({key:e})})),e instanceof X?[2,this._updateFileMessageMetaArray(e.messageId,n,"remove",!0)]:[2,this._updateUserMessageMetaArray(e.messageId,n,"remove",!0)]}))}))},l.prototype.addMessageMetaArrayValues=function(e,t){return f(this,void 0,void 0,(function(){return v(this,(function(n){return N(e instanceof ue&&e.messageId>0&&t.every((function(e){return e instanceof Y}))).throw(y.invalidParameters),e instanceof X?[2,this._updateFileMessageMetaArray(e.messageId,t,"add",!0)]:[2,this._updateUserMessageMetaArray(e.messageId,t,"add",!0)]}))}))},l.prototype.removeMessageMetaArrayValues=function(e,t){return f(this,void 0,void 0,(function(){return v(this,(function(n){return N(e instanceof ue&&e.messageId>0&&t.every((function(e){return e instanceof Y}))).throw(y.invalidParameters),e instanceof X?[2,this._updateFileMessageMetaArray(e.messageId,t,"remove",!0)]:[2,this._updateUserMessageMetaArray(e.messageId,t,"remove",!0)]}))}))},l.prototype.report=function(e,r){return f(this,void 0,void 0,(function(){var i,a,s,o;return v(this,(function(u){switch(u.label){case 0:return N(n(Oe,e)&&t("string",r)).throw(y.invalidParameters),i=g.of(this._iid),a=i.sdkState,s=i.requestQueue,o=new Dt({channelUrl:this.url,channelType:this.channelType,userId:a.userId,category:e,description:r}),[4,s.send(o)];case 1:return u.sent(),[2]}}))}))},l.prototype.reportUser=function(e,r,a){return f(this,void 0,void 0,(function(){var s,o,u,c;return v(this,(function(l){switch(l.label){case 0:return N(e instanceof i&&n(Oe,r)&&t("string",a)).throw(y.invalidParameters),s=g.of(this._iid),o=s.sdkState,u=s.requestQueue,c=new qt({channelUrl:this.url,channelType:this.channelType,userId:o.userId,offendingUserId:e.userId,category:r,description:a}),[4,u.send(c)];case 1:return l.sent(),[2]}}))}))},l.prototype.reportMessage=function(e,r,i){return f(this,void 0,void 0,(function(){var a,s,o,u;return v(this,(function(c){switch(c.label){case 0:return N(e instanceof ce&&n(Oe,r)&&t("string",i)).throw(y.invalidParameters),a=g.of(this._iid),s=a.sdkState,o=a.requestQueue,u=new Rt({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]}}))}))},l.prototype.updatePoll=function(e,n){return f(this,void 0,void 0,(function(){var r,i,a;return v(this,(function(o){switch(o.label){case 0:return N(t("number",e)&&function(e){return t("string",e.title,!0)&&P(e.data)&&t("boolean",e.allowUserSuggestion,!0)&&t("boolean",e.allowMultipleVotes,!0)&&t("number",e.closeAt,!0)}(n)).throw(y.invalidParameters),r=g.of(this._iid).requestQueue,i=new Zt(s({pollId:e},n)),[4,r.send(i)];case 1:return a=o.sent(),[2,a.as($t).poll]}}))}))},l.prototype.deletePoll=function(e){return f(this,void 0,void 0,(function(){var n,r,i;return v(this,(function(a){switch(a.label){case 0:return n=t("number",e),N(n).throw(y.invalidParameters),r=g.of(this._iid).requestQueue,i=new en({pollId:e}),[4,r.send(i)];case 1:return a.sent(),[2]}}))}))},l.prototype.closePoll=function(e){return f(this,void 0,void 0,(function(){var n,r,i,a;return v(this,(function(s){switch(s.label){case 0:return n=t("number",e),N(n).throw(y.invalidParameters),r=g.of(this._iid).requestQueue,i=new tn({pollId:e}),[4,r.send(i)];case 1:return a=s.sent(),[2,a.as(nn).poll]}}))}))},l.prototype.addPollOption=function(e,n){return f(this,void 0,void 0,(function(){var r,i,a,s;return v(this,(function(o){switch(o.label){case 0:return r=t("number",e)&&t("string",n)&&""!==n.trim(),N(r).throw(y.invalidParameters),i=g.of(this._iid).requestQueue,a=new rn({channelUrl:this.url,channelType:this.channelType,pollId:e,optionText:n}),[4,i.send(a)];case 1:return s=o.sent(),[2,s.as(an).poll]}}))}))},l.prototype.updatePollOption=function(e,n,r){return f(this,void 0,void 0,(function(){var i,a,s,o;return v(this,(function(u){switch(u.label){case 0:return i=t("number",e)&&t("number",n)&&t("string",r)&&""!==r.trim(),N(i).throw(y.invalidParameters),a=g.of(this._iid).requestQueue,s=new sn({pollId:e,pollOptionId:n,optionText:r}),[4,a.send(s)];case 1:return o=u.sent(),[2,o.as(on).poll]}}))}))},l.prototype.deletePollOption=function(e,n){return f(this,void 0,void 0,(function(){var r,i,a;return v(this,(function(s){switch(s.label){case 0:return r=t("number",e)&&t("number",n),N(r).throw(y.invalidParameters),i=g.of(this._iid).requestQueue,a=new un({pollId:e,pollOptionId:n}),[4,i.send(a)];case 1:return s.sent(),[2]}}))}))},l.prototype.votePoll=function(e,n){return f(this,void 0,void 0,(function(){var i,a,s,o,u,c,l;return v(this,(function(d){switch(d.label){case 0:return i=t("number",e)&&r("number",n),N(i).throw(y.invalidParameters),a=g.of(this._iid),s=a.requestQueue,o=a.dispatcher,u=new cn({reqId:this._generateRequestId(),channelUrl:this.url,channelType:this.channelType,pollId:e,pollOptionIds:n}),[4,s.send(u)];case 1:return c=d.sent(),l=c.as(ln).event,o.dispatch(new K({event:l,source:Q.EVENT_POLL_VOTED})),[2,l]}}))}))},l.prototype.getPollChangeLogsSinceTimestamp=function(e){return f(this,void 0,void 0,(function(){return v(this,(function(n){switch(n.label){case 0:return N(t("number",e)).throw(y.invalidParameters),[4,pe.of(this._iid).getPollChangeLogs(this.url,this.channelType,e)];case 1:return[2,n.sent()]}}))}))},l.prototype.getPollChangeLogsSinceToken=function(e){return f(this,void 0,void 0,(function(){return v(this,(function(n){switch(n.label){case 0:return N(t("string",e,!0)),[4,pe.of(this._iid).getPollChangeLogs(this.url,this.channelType,e)];case 1:return[2,n.sent()]}}))}))},l.prototype.createPollListQuery=function(e){return void 0===e&&(e=10),new de(this._iid,{channelUrl:this.url,channelType:this.channelType,limit:e})},l.prototype.createPollVoterListQuery=function(e,t,n){return void 0===n&&(n=20),new he(this._iid,{channelUrl:this.url,channelType:this.channelType,pollId:e,pollOptionId:t,limit:n})},l}(V);export{Qt as A,Je as B,Lt as C,ge as D,ke as E,fe as F,Fe as G,Qe as H,ze as I,Ht as J,dn as K,Ke as M,ve as N,je as O,ln as P,Oe as R,be as U,ye as a,_e as b,Te as c,Ue as d,Ie as e,hn as f,Ne as g,Le as h,Ce as i,we as j,De as k,Me as l,Ae as m,Se as n,me as o,gt as p,ot as q,At as r,Ee as s,Ct as t,bt as u,Pe as v,It as w,Mt as x,xt as y,kt as z}; diff --git a/__bundle-5ab69bcd.js b/__bundle-5c4b7d2b.js similarity index 71% rename from __bundle-5ab69bcd.js rename to __bundle-5c4b7d2b.js index ed723e6..e4437c4 100644 --- a/__bundle-5ab69bcd.js +++ b/__bundle-5c4b7d2b.js @@ -1 +1 @@ -import{_ as t,U as i}from"./__bundle-03ba89c3.js";var s=function(i){function s(t,s){var r,u=this;return(u=i.call(this,t,s)||this).isMuted=!1,u.isMuted=null!==(r=s.is_muted)&&void 0!==r&&r,u}return t(s,i),s}(i);export{s as P}; +import{_ as t,U as i}from"./__bundle-ea43c8a8.js";var s=function(i){function s(t,s){var r,u=this;return(u=i.call(this,t,s)||this).isMuted=!1,u.isMuted=null!==(r=s.is_muted)&&void 0!==r&&r,u}return t(s,i),s}(i);export{s as P}; diff --git a/__bundle-9e0eba5d.js b/__bundle-9a0f0a93.js similarity index 99% rename from __bundle-9e0eba5d.js rename to __bundle-9a0f0a93.js index 0310352..9580934 100644 --- a/__bundle-9e0eba5d.js +++ b/__bundle-9a0f0a93.js @@ -1 +1 @@ -import{_ as t,A as n,aq as e,f as o,a4 as s,h as l,ak as a,a7 as i,e as r,a as u,ar as c,as as h,I as p,M as d,s as f,b as _,c as m,ae as v,r as g,S as I,g as w,at as y,ai as k,V as T,U}from"./__bundle-03ba89c3.js";var b=function(o){function s(t){var s=t.title,l=t.optionTexts,a=t.data,i=t.allowUserSuggestion,r=t.allowMultipleVotes,u=t.closeAt,c=o.call(this)||this;return c.method=n.POST,c.path=e,c.params={title:s,options:l,data:a,allow_user_suggestion:i,allow_multiple_votes:r,close_at:u},c}return t(s,o),s}(o),P=function(n){function e(t,e){var o=n.call(this,t,e)||this;return o.poll=new s(t,e),o}return t(e,n),e}(l),x=function(o){function s(t){var s=t.channelUrl,l=t.channelType,a=t.pollId,i=o.call(this)||this;return i.method=n.GET,i.path="".concat(e,"/").concat(encodeURIComponent(a)),i.params={channel_url:s,channel_type:l},i}return t(s,o),s}(o),O=function(n){function e(t,e){var o=n.call(this,t,e)||this;return o.poll=new s(t,e),o}return t(e,n),e}(l),q=function(o){function s(t){var s=t.channelUrl,l=t.channelType,a=t.pollId,i=t.pollOptionId,r=o.call(this)||this;return r.method=n.GET,r.path="".concat(e,"/").concat(encodeURIComponent(a),"/options/").concat(encodeURIComponent(i)),r.params={channel_url:s,channel_type:l},r}return t(s,o),s}(o),L=function(n){function e(t,e){var o=n.call(this,t,e)||this;return o.pollOption=new a(t,e),o}return t(e,n),e}(l),S=function(e){function o(t){var o=t.channelType,s=t.channelUrl,l=t.timestamp,a=t.token,u=e.call(this)||this;return u.method=n.GET,u.path="".concat(i(o),"/").concat(encodeURIComponent(s),"/polls/changelogs"),u.params=r({change_ts:l,token:a}),u}return t(o,e),o}(o),C=function(n){function e(t,e){var o=n.call(this,t,e)||this;return o.updatedPolls=e.updated.map((function(n){return function(t,n){return n?new s(t,n):null}(t,n)})),o.deletedPollIds=e.deleted.map((function(t){return t})),o.hasMore=e.has_more,o.nextToken=e.next,o}return t(e,n),e}(l),M={title:null,optionTexts:null,data:null,allowUserSuggestion:null,allowMultipleVotes:null,closeAt:-1},Q=function(t){return u("string",t.title)&&c(t.optionTexts)&&h(t.data)&&u("boolean",t.allowUserSuggestion,!0)&&u("boolean",t.allowMultipleVotes,!0)&&u("number",t.closeAt,!0)},G={channelUrl:null,channelType:null,pollId:null,pollOptionId:null},E=function(t){return u("string",t.channelUrl)&&p(d,t.channelType)&&u("number",t.pollId)&&u("number",t.pollOptionId)},N={channelUrl:null,channelType:null,pollId:null},R=function(t){return u("string",t.channelUrl)&&""!==t.channelUrl&&p(d,t.channelType)&&u("number",t.pollId)},A={},V=function(){function t(t,n){var e=n.sdkState,o=n.dispatcher,s=n.sessionManager,l=n.requestQueue,a=n.logger;this._iid=t,this._sdkState=e,this._sessionManager=s,this._requestQueue=l,this._dispatcher=o,this._logger=a,A[t]=this}return t.of=function(t){return A[t]},t.prototype.buildPollFromSerializedData=function(t){var n=f(t);return new s(this._iid,s.payloadify(n))},t.prototype.get=function(t){return _(this,void 0,void 0,(function(){var n,e;return m(this,(function(o){switch(o.label){case 0:return g(R(t)).throw(I.invalidParameters),n=new x(w({},t)),[4,this._requestQueue.send(n)];case 1:return e=o.sent(),[2,e.as(O).poll]}}))}))},t.prototype.create=function(t){return _(this,void 0,void 0,(function(){var n,e,o;return m(this,(function(s){switch(s.label){case 0:return g(Q(t)).throw(I.invalidParameters),n=t.data,e=new b(w(w({},t),{data:n})),[4,this._requestQueue.send(e)];case 1:return o=s.sent(),[2,o.as(P).poll]}}))}))},t.prototype.getOption=function(t){return _(this,void 0,void 0,(function(){var n,e;return m(this,(function(o){switch(o.label){case 0:return g(E(t)).throw(I.invalidParameters),n=new q(w({},t)),[4,this._requestQueue.send(n)];case 1:return e=o.sent(),[2,e.as(L).pollOption]}}))}))},t.prototype.getPollChangeLogs=function(t,n,e,o){return void 0===o&&(o=v.SYNC_POLL_CHANGELOGS),_(this,void 0,void 0,(function(){var s,l,a,i,u,c,h;return m(this,(function(p){switch(p.label){case 0:return s=new S(r({channelType:n,channelUrl:t,timestamp:"number"==typeof e?e:null,token:"string"==typeof e?e:null})),[4,this._requestQueue.send(s)];case 1:return l=p.sent(),a=l.as(C),i=a.updatedPolls,u=a.deletedPollIds,c=a.hasMore,h=a.nextToken,i.length>0&&this._dispatcher.dispatch(new y({polls:i,source:o})),[2,{updatedPolls:i,deletedPollIds:u,hasMore:c,token:h}]}}))}))},t}(),j=function(t,n){this.pollId=0,this.messageId=0,this.pollId=n.poll.id,this.messageId=n.poll.message_id,this._iid=t,this._payload=n},z=function(t){this.pollId=0,this.messageId=0,this.pollId=t.poll_id,this.messageId=t.message_id,this._payload=t},D=function(o){function s(t){var s=t.channelUrl,l=t.channelType,a=t.token,i=t.limit,r=o.call(this)||this;return r.method=n.GET,r.path=e,r.params={channel_url:s,channel_type:l,token:a,limit:i},r}return t(s,o),s}(o),F=function(n){function e(t,e){var o,l=this;return(l=n.call(this,t,e)||this).polls=(null!==(o=e.polls)&&void 0!==o?o:[]).map((function(n){return new s(t,n)})),l.token=e.next,l}return t(e,n),e}(l),H=function(n){function e(t,e){return n.call(this,t,e.channelUrl,e.channelType,e)||this}return t(e,n),e.prototype.next=function(){return _(this,void 0,void 0,(function(){var t,n,e,o,s,l;return m(this,(function(a){switch(a.label){case 0:return this._validate()?this._isLoading?[3,3]:this._hasNext?(this._isLoading=!0,t=T.of(this._iid).requestQueue,n=new D(w(w({},this),{token:this._token})),[4,t.send(n)]):[3,2]:[3,5];case 1:return e=a.sent(),o=e.as(F),s=o.polls,l=o.token,this._token=l,this._hasNext=!!l,this._isLoading=!1,[2,s];case 2:return[2,[]];case 3:throw I.queryInProgress;case 4:return[3,6];case 5:throw I.invalidParameters;case 6:return[2]}}))}))},e}(k),Y=function(o){function s(t){var s=t.channelUrl,l=t.channelType,a=t.pollId,i=t.pollOptionId,r=t.token,u=t.limit,c=o.call(this)||this;return c.method=n.GET,c.path="".concat(e,"/").concat(encodeURIComponent(a),"/options/").concat(encodeURIComponent(i),"/voters"),c.params={channel_url:s,channel_type:l,token:r,limit:u},c}return t(s,o),s}(o),B=function(n){function e(t,e){var o,s=this;return(s=n.call(this,t,e)||this).voters=(null!==(o=e.voters)&&void 0!==o?o:[]).map((function(n){return new U(t,n)})),s.token=e.next,s}return t(e,n),e}(l),J=function(n){function e(t,e){var o=n.call(this,t,e.channelUrl,e.channelType,e)||this;return o.pollId=e.pollId,o.pollOptionId=e.pollOptionId,o}return t(e,n),e.prototype._validate=function(){return n.prototype._validate.call(this)&&u("number",this.pollId)&&u("number",this.pollOptionId)},e.prototype.next=function(){return _(this,void 0,void 0,(function(){var t,n,e,o,s,l;return m(this,(function(a){switch(a.label){case 0:return this._validate()?this._isLoading?[3,3]:this._hasNext?(this._isLoading=!0,t=T.of(this._iid).requestQueue,n=new Y(w(w({},this),{pollId:this.pollId,pollOptionId:this.pollOptionId,token:this._token})),[4,t.send(n)]):[3,2]:[3,5];case 1:return e=a.sent(),o=e.as(B),s=o.voters,l=o.token,this._token=l,this._hasNext=!!l,this._isLoading=!1,[2,s];case 2:return[2,[]];case 3:throw I.queryInProgress;case 4:return[3,6];case 5:throw I.invalidParameters;case 6:return[2]}}))}))},e}(k);export{H as P,J as a,V as b,M as c,N as d,R as e,G as f,E as g,j as h,z as i,Q as v}; +import{_ as t,A as n,aq as e,f as o,a4 as s,h as l,ak as a,a7 as i,e as r,a as u,ar as c,as as h,I as p,M as d,s as f,b as _,c as m,ae as v,r as g,S as I,g as w,at as y,ai as k,V as T,U}from"./__bundle-ea43c8a8.js";var b=function(o){function s(t){var s=t.title,l=t.optionTexts,a=t.data,i=t.allowUserSuggestion,r=t.allowMultipleVotes,u=t.closeAt,c=o.call(this)||this;return c.method=n.POST,c.path=e,c.params={title:s,options:l,data:a,allow_user_suggestion:i,allow_multiple_votes:r,close_at:u},c}return t(s,o),s}(o),P=function(n){function e(t,e){var o=n.call(this,t,e)||this;return o.poll=new s(t,e),o}return t(e,n),e}(l),x=function(o){function s(t){var s=t.channelUrl,l=t.channelType,a=t.pollId,i=o.call(this)||this;return i.method=n.GET,i.path="".concat(e,"/").concat(encodeURIComponent(a)),i.params={channel_url:s,channel_type:l},i}return t(s,o),s}(o),O=function(n){function e(t,e){var o=n.call(this,t,e)||this;return o.poll=new s(t,e),o}return t(e,n),e}(l),q=function(o){function s(t){var s=t.channelUrl,l=t.channelType,a=t.pollId,i=t.pollOptionId,r=o.call(this)||this;return r.method=n.GET,r.path="".concat(e,"/").concat(encodeURIComponent(a),"/options/").concat(encodeURIComponent(i)),r.params={channel_url:s,channel_type:l},r}return t(s,o),s}(o),L=function(n){function e(t,e){var o=n.call(this,t,e)||this;return o.pollOption=new a(t,e),o}return t(e,n),e}(l),S=function(e){function o(t){var o=t.channelType,s=t.channelUrl,l=t.timestamp,a=t.token,u=e.call(this)||this;return u.method=n.GET,u.path="".concat(i(o),"/").concat(encodeURIComponent(s),"/polls/changelogs"),u.params=r({change_ts:l,token:a}),u}return t(o,e),o}(o),C=function(n){function e(t,e){var o=n.call(this,t,e)||this;return o.updatedPolls=e.updated.map((function(n){return function(t,n){return n?new s(t,n):null}(t,n)})),o.deletedPollIds=e.deleted.map((function(t){return t})),o.hasMore=e.has_more,o.nextToken=e.next,o}return t(e,n),e}(l),M={title:null,optionTexts:null,data:null,allowUserSuggestion:null,allowMultipleVotes:null,closeAt:-1},Q=function(t){return u("string",t.title)&&c(t.optionTexts)&&h(t.data)&&u("boolean",t.allowUserSuggestion,!0)&&u("boolean",t.allowMultipleVotes,!0)&&u("number",t.closeAt,!0)},G={channelUrl:null,channelType:null,pollId:null,pollOptionId:null},E=function(t){return u("string",t.channelUrl)&&p(d,t.channelType)&&u("number",t.pollId)&&u("number",t.pollOptionId)},N={channelUrl:null,channelType:null,pollId:null},R=function(t){return u("string",t.channelUrl)&&""!==t.channelUrl&&p(d,t.channelType)&&u("number",t.pollId)},A={},V=function(){function t(t,n){var e=n.sdkState,o=n.dispatcher,s=n.sessionManager,l=n.requestQueue,a=n.logger;this._iid=t,this._sdkState=e,this._sessionManager=s,this._requestQueue=l,this._dispatcher=o,this._logger=a,A[t]=this}return t.of=function(t){return A[t]},t.prototype.buildPollFromSerializedData=function(t){var n=f(t);return new s(this._iid,s.payloadify(n))},t.prototype.get=function(t){return _(this,void 0,void 0,(function(){var n,e;return m(this,(function(o){switch(o.label){case 0:return g(R(t)).throw(I.invalidParameters),n=new x(w({},t)),[4,this._requestQueue.send(n)];case 1:return e=o.sent(),[2,e.as(O).poll]}}))}))},t.prototype.create=function(t){return _(this,void 0,void 0,(function(){var n,e,o;return m(this,(function(s){switch(s.label){case 0:return g(Q(t)).throw(I.invalidParameters),n=t.data,e=new b(w(w({},t),{data:n})),[4,this._requestQueue.send(e)];case 1:return o=s.sent(),[2,o.as(P).poll]}}))}))},t.prototype.getOption=function(t){return _(this,void 0,void 0,(function(){var n,e;return m(this,(function(o){switch(o.label){case 0:return g(E(t)).throw(I.invalidParameters),n=new q(w({},t)),[4,this._requestQueue.send(n)];case 1:return e=o.sent(),[2,e.as(L).pollOption]}}))}))},t.prototype.getPollChangeLogs=function(t,n,e,o){return void 0===o&&(o=v.SYNC_POLL_CHANGELOGS),_(this,void 0,void 0,(function(){var s,l,a,i,u,c,h;return m(this,(function(p){switch(p.label){case 0:return s=new S(r({channelType:n,channelUrl:t,timestamp:"number"==typeof e?e:null,token:"string"==typeof e?e:null})),[4,this._requestQueue.send(s)];case 1:return l=p.sent(),a=l.as(C),i=a.updatedPolls,u=a.deletedPollIds,c=a.hasMore,h=a.nextToken,i.length>0&&this._dispatcher.dispatch(new y({polls:i,source:o})),[2,{updatedPolls:i,deletedPollIds:u,hasMore:c,token:h}]}}))}))},t}(),j=function(t,n){this.pollId=0,this.messageId=0,this.pollId=n.poll.id,this.messageId=n.poll.message_id,this._iid=t,this._payload=n},z=function(t){this.pollId=0,this.messageId=0,this.pollId=t.poll_id,this.messageId=t.message_id,this._payload=t},D=function(o){function s(t){var s=t.channelUrl,l=t.channelType,a=t.token,i=t.limit,r=o.call(this)||this;return r.method=n.GET,r.path=e,r.params={channel_url:s,channel_type:l,token:a,limit:i},r}return t(s,o),s}(o),F=function(n){function e(t,e){var o,l=this;return(l=n.call(this,t,e)||this).polls=(null!==(o=e.polls)&&void 0!==o?o:[]).map((function(n){return new s(t,n)})),l.token=e.next,l}return t(e,n),e}(l),H=function(n){function e(t,e){return n.call(this,t,e.channelUrl,e.channelType,e)||this}return t(e,n),e.prototype.next=function(){return _(this,void 0,void 0,(function(){var t,n,e,o,s,l;return m(this,(function(a){switch(a.label){case 0:return this._validate()?this._isLoading?[3,3]:this._hasNext?(this._isLoading=!0,t=T.of(this._iid).requestQueue,n=new D(w(w({},this),{token:this._token})),[4,t.send(n)]):[3,2]:[3,5];case 1:return e=a.sent(),o=e.as(F),s=o.polls,l=o.token,this._token=l,this._hasNext=!!l,this._isLoading=!1,[2,s];case 2:return[2,[]];case 3:throw I.queryInProgress;case 4:return[3,6];case 5:throw I.invalidParameters;case 6:return[2]}}))}))},e}(k),Y=function(o){function s(t){var s=t.channelUrl,l=t.channelType,a=t.pollId,i=t.pollOptionId,r=t.token,u=t.limit,c=o.call(this)||this;return c.method=n.GET,c.path="".concat(e,"/").concat(encodeURIComponent(a),"/options/").concat(encodeURIComponent(i),"/voters"),c.params={channel_url:s,channel_type:l,token:r,limit:u},c}return t(s,o),s}(o),B=function(n){function e(t,e){var o,s=this;return(s=n.call(this,t,e)||this).voters=(null!==(o=e.voters)&&void 0!==o?o:[]).map((function(n){return new U(t,n)})),s.token=e.next,s}return t(e,n),e}(l),J=function(n){function e(t,e){var o=n.call(this,t,e.channelUrl,e.channelType,e)||this;return o.pollId=e.pollId,o.pollOptionId=e.pollOptionId,o}return t(e,n),e.prototype._validate=function(){return n.prototype._validate.call(this)&&u("number",this.pollId)&&u("number",this.pollOptionId)},e.prototype.next=function(){return _(this,void 0,void 0,(function(){var t,n,e,o,s,l;return m(this,(function(a){switch(a.label){case 0:return this._validate()?this._isLoading?[3,3]:this._hasNext?(this._isLoading=!0,t=T.of(this._iid).requestQueue,n=new Y(w(w({},this),{pollId:this.pollId,pollOptionId:this.pollOptionId,token:this._token})),[4,t.send(n)]):[3,2]:[3,5];case 1:return e=a.sent(),o=e.as(B),s=o.voters,l=o.token,this._token=l,this._hasNext=!!l,this._isLoading=!1,[2,s];case 2:return[2,[]];case 3:throw I.queryInProgress;case 4:return[3,6];case 5:throw I.invalidParameters;case 6:return[2]}}))}))},e}(k);export{H as P,J as a,V as b,M as c,N as d,R as e,G as f,E as g,j as h,z as i,Q as v}; diff --git a/__bundle-7ac921c4.js b/__bundle-da2eac9e.js similarity index 99% rename from __bundle-7ac921c4.js rename to __bundle-da2eac9e.js index a6bcfde..adacde5 100644 --- a/__bundle-7ac921c4.js +++ b/__bundle-da2eac9e.js @@ -1 +1 @@ -import{a3 as e,Z as t,ac as n,b as r,H as i,c as s,g as o,a,i as c,_ as u,S as l,X as h,am as d,a1 as f,an as _,t as v,w as m,a9 as p,af as y,ae as E,U as b,W as g,p as N,q as I,ao as w,ap as A}from"./__bundle-03ba89c3.js";import{U as T,s as O,v as C,j as S,k,l as L,m as x,F as R,n as D,b as P,D as M}from"./__bundle-edc633d6.js";import{S as B,U as H,F as V,b as U}from"./__bundle-51a2cdbc.js";var K,q,F;!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"}(K||(K={})),function(e){e.CHRONOLOGICAL="chronological",e.CHANNEL_NAME_ALPHABETICAL="channel_name_alphabetical",e.METADATA_VALUE_ALPHABETICAL="metadata_value_alphabetical"}(q||(q={})),function(e){e.CREATED_AT="created_at",e.SCHEDULED_AT="scheduled_at"}(F||(F={}));var j,G=function(e){switch(e){case K.LATEST_LAST_MESSAGE:return["-lastMessageUpdatedAt","-createdAt","syncIndex"];case K.CHRONOLOGICAL:return["-createdAt","syncIndex"];case K.CHANNEL_NAME_ALPHABETICAL:return["name"]}},z=function(){function r(){this.messageTypeFilter=e.ALL,this.customTypesFilter=null,this.senderUserIdsFilter=null,this.replyType=n.NONE}return r.prototype.clone=function(){var e=new r,t=JSON.parse(JSON.stringify(this));return Object.keys(t).forEach((function(n){e[n]=t[n]})),e},r.prototype.match=function(r){switch(this.messageTypeFilter){case e.USER:if(r.messageType!==t.USER)return!1;break;case e.FILE:if(r.messageType!==t.FILE)return!1;break;case e.ADMIN:if(r.messageType!==t.ADMIN)return!1}if(this.customTypesFilter&&this.customTypesFilter.length>0&&!this.customTypesFilter.includes(r.customType))return!1;if(this.senderUserIdsFilter&&this.senderUserIdsFilter.length>0){if(!(r instanceof B))return!1;if(!this.senderUserIdsFilter.includes(r.sender.userId))return!1}switch(this.replyType){case n.NONE:if(r.parentMessageId>0)return!1;break;case n.ONLY_REPLY_TO_CHANNEL:if(r instanceof B&&r.parentMessageId>0&&!r.replyToChannel)return!1}return!0},r}();!function(e){e.CHANNEL_LATEST="channel_latest",e.NEWEST_CHILD_MESSAGE="newest_child_message"}(j||(j={}));var W=function(e){switch(e){case j.CHANNEL_LATEST:return["channelUrl","-createdAt","-messageId"];case j.NEWEST_CHILD_MESSAGE:return["channelUrl","-parentMessageId","-createdAt","-messageId"]}},Y="undefined"!=typeof document&&"undefined"!=typeof navigator;Y&&navigator.userAgent&&navigator.userAgent.includes("Chrome/")&&navigator.userAgent.includes("Chromium/");var Q=Y&&navigator.userAgent&&navigator.userAgent.includes("Firefox/")&&!navigator.userAgent.includes("Seamonkey/");Y&&navigator.userAgent&&navigator.userAgent.includes("Safari/")&&!navigator.userAgent.includes("Chrome/")&&navigator.userAgent.includes("Chromium/"),Y&&navigator.userAgent&&(navigator.userAgent.includes("OPR/")||navigator.userAgent.includes("Opera/")),Y&&navigator.userAgent&&navigator.userAgent.includes("Trident/7.0");var J,X,Z=Y&&navigator.userAgent&&navigator.userAgent.includes("Edge/"),$=function(){var e=(new Date).getTime();return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,(function(t){var n=(e+16*Math.random())%16|0;return e=Math.floor(e/16),("x"===t?n:3&n|8).toString(16)}))};!function(e){e[e.PROCESSING=0]="PROCESSING",e[e.DONE=1]="DONE"}(J||(J={})),function(e){e.NEWNODE="newnode",e.REMOVENODE="removenode",e.CLAIM_HOST="claimhost",e.SYNC_HOST="synchost",e.REQUEST_LOCK="requestlock",e.ACQUIRE_LOCK="acquirelock",e.RELEASE_LOCK="releaselock"}(X||(X={}));var ee,te={},ne=function(){function e(e,t){void 0===t&&(t={});var n=this;return this._state=J.PROCESSING,this._hostId=null,this._queue=[],this._currentItem=null,this._activationTimeout=null,this._activationQueue=[],te[e]&&!t.forceCreate||(this.nodeId=$(),this.key=e,Y&&(t.startAsInvisible?this.registerNode():"visible"===document.visibilityState?this.claimHost():this.registerNode(),document.addEventListener("visibilitychange",(function(){"visible"===document.visibilityState&&n.claimHost()})),window.addEventListener("message",(function(e){var t,r,s=e.data,o=s.nodeId,a=s.requestId,c=s.key,u=s.op,l=s.data;if(o!==n.nodeId&&c===n.key)switch(u){case X.NEWNODE:n._sendSync();break;case X.CLAIM_HOST:n._sendSync(),n._hostId=o;break;case X.SYNC_HOST:if(!n.isInSync){n._activationTimeout&&clearTimeout(n._activationTimeout);var h=l,d=h.currentItemRequestId,f=h.queue,_=function(e){var t=n._queue.findIndex((function(t){return t.requestId===e.requestId}));t<0&&n._requestLock({nodeId:e.nodeId,requestId:e.requestId,key:n.key,op:X.REQUEST_LOCK,ts:e.ts})};try{for(var v=i(f),m=v.next();!m.done;m=v.next()){_(m.value)}}catch(e){t={error:e}}finally{try{m&&!m.done&&(r=v.return)&&r.call(v)}finally{if(t)throw t.error}}n._currentItem=n._queue.find((function(e){return e.requestId===d})),n._completeSync()}break;case X.REMOVENODE:n._queue=n._queue.filter((function(e){return e.nodeId!==s.nodeId})),n._currentItem&&n._currentItem.nodeId===s.nodeId&&(n._currentItem=null,n._acquire(n._queue[0]));break;case X.REQUEST_LOCK:n._requestLock(s);break;case X.ACQUIRE_LOCK:var p=n._queue.find((function(e){return e.requestId===a}));n._acquire(p);break;case X.RELEASE_LOCK:n._release(a)}})),window.addEventListener("beforeunload",(function(){n._send(X.REMOVENODE)}))),te[e]=this),te[e]}return Object.defineProperty(e.prototype,"locked",{get:function(){return!!this._currentItem},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"isHost",{get:function(){return this._hostId===this.nodeId},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"isInSync",{get:function(){return this._state==J.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:$(),key:this.key,op:e,data:null!==(r=t.data)&&void 0!==r?r:null,ts:Date.now()};return Y&&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(X.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(X.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(X.SYNC_HOST,{data:{currentItemRequestId:null===(e=this._currentItem)||void 0===e?void 0:e.requestId,queue:this._queue.map((function(e){return{nodeId:e.nodeId,requestId:e.requestId,ts:e.ts}}))}})},e.prototype._waitUntilSyncCompleted=function(){return r(this,void 0,void 0,(function(){var e=this;return s(this,(function(t){return this.isHost&&!this.isInSync?[2,new Promise((function(t){e._activationQueue.push(t)}))]:[2]}))}))},e.prototype._waitSync=function(){var e=this;this.isInSync||(this._activationTimeout=setTimeout((function(){e._completeSync()}),8))},e.prototype._completeSync=function(){this.isInSync||(this._state=J.DONE,this._activationQueue.forEach((function(e){return e()})),this._activationQueue=[])},e.prototype.registerNode=function(){this._send(X.NEWNODE),this._waitSync()},e.prototype.claimHost=function(){this._hostId=this.nodeId,this._send(X.CLAIM_HOST),this._waitSync()},e.prototype.lock=function(){return r(this,void 0,void 0,(function(){var e;return s(this,(function(t){switch(t.label){case 0:return[4,this._waitUntilSyncCompleted()];case 1:return t.sent(),e=this._send(X.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}(),re=o(o({},T),{scheduledAt:null}),ie=function(e){return C(e)&&a("number",e.scheduledAt,!0)},se=o(o({},S),{scheduledAt:null,file:null,fileUrl:null,fileName:null,mimeType:null,fileSize:null,thumbnailSizes:null,requireAuth:!1}),oe=function(e){return L(e)&&a("number",e.scheduledAt)&&(c(e.file)||a("string",e.fileUrl))&&a("string",e.fileName,!0)&&a("string",e.mimeType,!0)&&a("number",e.fileSize,!0)&&(null===e.thumbnailSizes||e.thumbnailSizes.every((function(e){return a("object",e)&&e.maxWidth>0&&e.maxHeight>0})))},ae="UnsentMessage",ce="reqId",ue={},le=function(e){function t(t,n){var r=n.sdkState,i=n.cacheContext,s=e.call(this,t)||this;return s._sdkState=r,s._cacheContext=i,ue[t]=s,s._mutex=new ne("unsendmessagecache.lock"),s}return u(t,e),t.of=function(e){return ue[e]},Object.defineProperty(t.prototype,"collection",{get:function(){var e=this._cacheContext.nestdb;return e&&e.collection(ae)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"localCacheEnabled",{get:function(){return this._cacheContext.localCacheEnabled&&!!this.collection},enumerable:!1,configurable:!0}),t.prototype._serialize=function(e){if(e.messageId>0)throw l.invalidParameters;var t,n=o({},e.serialize());return e instanceof H?(e.messageParams&&(n.messageParams=O(e.messageParams)),e.scheduledInfo&&e.scheduledInfo.scheduledMessageParams&&(n.scheduledInfo.scheduledMessageParams=(t=e.scheduledInfo.scheduledMessageParams,o(o({},O(t)),{scheduledAt:t.scheduledAt})))):e instanceof V&&(e.messageParams&&(n.messageParams=k(e.messageParams)),e.scheduledInfo&&e.scheduledInfo.scheduledMessageParams&&(n.scheduledInfo.scheduledMessageParams=function(e){return o(o({},k(e)),{scheduledAt:e.scheduledAt})}(e.scheduledInfo.scheduledMessageParams))),n},t.prototype._deserialize=function(e){return e?(e=o(o({},e),{messageId:parseInt(e.messageId)}),U.of(this._iid).buildMessageFromSerializedData(e)):null},t.prototype._deserializeWithMessageCreateParams=function(e){return r(this,void 0,void 0,(function(){var t,n,r,i,o,a;return s(this,(function(s){switch(s.label){case 0:return t=U.of(this._iid),n=this._deserialize(e),e.messageParams?n instanceof H?(r=e.messageParams,n.messageParams=t.buildUserMessageCreateParamsFromSerializedData(r,n),[3,4]):[3,1]:[3,4];case 1:return n instanceof V?(r=e.messageParams).fileKey&&"string"==typeof r.fileKey&&x(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 H?(o=e.scheduledInfo.scheduledMessageParams,n.scheduledInfo.scheduledMessageParams=t.buildScheduledUserMessageCreateParamsFromSerializedData(o,n),[3,8]):[3,5]:[3,8];case 5:return n instanceof V?(o=e.scheduledInfo.scheduledMessageParams).fileKey&&"string"==typeof o.fileKey&&x(o.fileType)?(a=o,[4,this.collection.getBlob(o.fileKey)]):[3,7]:[3,8];case 6:a.file=s.sent(),s.label=7;case 7:n.scheduledInfo.scheduledMessageParams=t.buildScheduledFileMessageCreateParamsFromSerializedData(o,n),s.label=8;case 8:return[2,n]}}))}))},t.prototype.get=function(e){return r(this,void 0,void 0,(function(){var t;return s(this,(function(n){switch(n.label){case 0:return this.localCacheEnabled?[4,this.collection.getByKey("".concat(e))]:[3,2];case 1:if(t=n.sent())return[2,this._deserializeWithMessageCreateParams(t)];n.label=2;case 2:return[2,null]}}))}))},t.prototype.fetch=function(e){var t=e.channelUrl,n=void 0===t?null:t,i=e.filter,o=void 0===i?new z:i,a=e.order,c=void 0===a?j.CHANNEL_LATEST:a,u=e.sendingStatus,l=void 0===u?null:u,h=e.backward,d=void 0!==h&&h,f=e.parentMessageId,_=void 0===f?null:f;return r(this,void 0,void 0,(function(){var e,t,i,a,u=this;return s(this,(function(h){switch(h.label){case 0:return this.localCacheEnabled?(e=W(c),t={"/where":function(e){return!!(c!==j.NEWEST_CHILD_MESSAGE||_&&0!==e.parentMessageId&&e.parentMessageId===_)&&o.match(u._deserialize(e))}},n&&(t.channelUrl=n),l&&(t.sendingStatus=l),i={where:t,index:e,backward:d},[4,this.collection.query(i)]):[3,3];case 1:return[4,h.sent().fetch({})];case 2:return a=h.sent(),[2,Promise.all(a.map((function(e){return r(u,void 0,void 0,(function(){return s(this,(function(t){switch(t.label){case 0:return[4,this._deserializeWithMessageCreateParams(e)];case 1:return[2,t.sent()]}}))}))})))];case 3:return[2,[]]}}))}))},t.prototype.getAllChildMessages=function(e,t){return void 0===t&&(t=new z),r(this,void 0,void 0,(function(){return s(this,(function(n){switch(n.label){case 0:return[4,this.fetch({filter:t,order:j.NEWEST_CHILD_MESSAGE,channelUrl:e.channelUrl,backward:!1,parentMessageId:e.messageId})];case 1:return[2,n.sent()]}}))}))},t.prototype.upsert=function(e){return r(this,void 0,void 0,(function(){var t=this;return s(this,(function(n){switch(n.label){case 0:return this.localCacheEnabled?[4,Promise.all(e.map((function(e){return r(t,void 0,void 0,(function(){var t;return s(this,(function(n){switch(n.label){case 0:return e instanceof V?[4,this._mutex.lock()]:[3,4];case 1:return n.sent(),[4,this.saveBlob(e)];case 2:return n.sent(),[4,this._mutex.unlock()];case 3:n.sent(),n.label=4;case 4:return t=this._serialize(e),[4,this.collection.upsertOne(t)];case 5:return n.sent(),[2]}}))}))})))]:[3,2];case 1:n.sent(),n.label=2;case 2:return[2]}}))}))},t.prototype.upsertChildMessages=function(e){return r(this,void 0,void 0,(function(){var t=this;return s(this,(function(n){switch(n.label){case 0:return this.localCacheEnabled?[4,Promise.all(e.map((function(e){return r(t,void 0,void 0,(function(){var t,n;return s(this,(function(r){switch(r.label){case 0:return t=[],(null===(n=e.threadInfo)||void 0===n?void 0:n.replyCount)>0?[4,this.getAllChildMessages(e)]:[3,2];case 1:t=r.sent(),r.label=2;case 2:return t.length>0?(t.forEach((function(t){return t.applyParentMessage(e)})),[4,this.upsert(t)]):[3,4];case 3:r.sent(),r.label=4;case 4:return[2]}}))}))})))]:[3,2];case 1:n.sent(),n.label=2;case 2:return[2]}}))}))},t.prototype.remove=function(e){return r(this,void 0,void 0,(function(){var t,n,r,o,a,c;return s(this,(function(s){switch(s.label){case 0:if(!this.localCacheEnabled)return[3,8];s.label=1;case 1:s.trys.push([1,6,7,8]),t=i(e),n=t.next(),s.label=2;case 2:return n.done?[3,5]:(r=n.value,[4,this.collection.remove(r)]);case 3:s.sent(),s.label=4;case 4:return n=t.next(),[3,2];case 5:return[3,8];case 6:return o=s.sent(),a={error:o},[3,8];case 7:try{n&&!n.done&&(c=t.return)&&c.call(t)}finally{if(a)throw a.error}return[7];case 8:return[2]}}))}))},t.prototype.removeMessagesOfChannel=function(e){return r(this,void 0,void 0,(function(){return s(this,(function(t){switch(t.label){case 0:return this.localCacheEnabled?[4,this.collection.removeIf({where:{channelUrl:e}})]:[3,2];case 1:t.sent(),t.label=2;case 2:return[2]}}))}))},t.prototype.clear=function(){return r(this,void 0,void 0,(function(){return s(this,(function(e){switch(e.label){case 0:return this.localCacheEnabled?[4,this.collection.clear()]:[3,2];case 1:e.sent(),e.label=2;case 2:return[2]}}))}))},t.prototype.saveBlob=function(e){return r(this,void 0,void 0,(function(){var t,n,r;return s(this,(function(i){switch(i.label){case 0:return e instanceof V?e.messageParams&&(t=e.messageParams).file&&D(t.file)?[4,this.collection.saveBlob(t.file,e.reqId)]:[3,2]:[3,4];case 1:r=i.sent(),t.fileKey=r,t.fileType=R.BLOB,i.label=2;case 2:return e.scheduledInfo&&e.scheduledInfo.scheduledMessageParams&&((n=e.scheduledInfo.scheduledMessageParams).file&&D(n.file))?[4,this.collection.saveBlob(n.file,e.reqId)]:[3,4];case 3:r=i.sent(),n.fileKey=r,n.fileType=R.BLOB,i.label=4;case 4:return[2]}}))}))},t}(h),he={},de=function(e){function t(t,n){var r=n.sdkState,i=n.cacheContext,s=n.unsentMessageCache,o=e.call(this,t)||this;return o._sdkState=r,o._cacheContext=i,o._unsentMessageCache=s,he[t]=o,o}return u(t,e),t.of=function(e){return he[e]},Object.defineProperty(t.prototype,"collection",{get:function(){var e=this._cacheContext.nestdb;return e?e.collection(P):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 o(o({},e.serialize()),{messageId:"".concat(e.messageId)})},t.prototype._deserialize=function(e){return e=o(o({},e),{messageId:parseInt(e.messageId)}),U.of(this._iid).buildMessageFromSerializedData(e)},t.prototype.get=function(e){return r(this,void 0,void 0,(function(){var t;return s(this,(function(n){switch(n.label){case 0:return this.localCacheEnabled?[4,this.collection.getByKey("".concat(e))]:[3,2];case 1:if(t=n.sent())return[2,this._deserialize(t)];n.label=2;case 2:return[2,null]}}))}))},t.prototype.fetch=function(e){var t=e.channelUrl,n=e.token,i=e.limit,o=void 0===i?M:i,a=e.filter,c=void 0===a?new z:a,u=e.order,l=void 0===u?j.CHANNEL_LATEST:u,h=e.backward,d=void 0!==h&&h,f=e.parentMessageId,_=void 0===f?null:f,v=e.isPollOnly,m=void 0!==v&&v;return r(this,void 0,void 0,(function(){var e,i,a,u=this;return s(this,(function(h){switch(h.label){case 0:return this.localCacheEnabled?(e=W(l),i={where:{channelUrl:t,"/where":function(e){if(n)switch(l){case j.CHANNEL_LATEST:if(!d&&e.createdAt>n||d&&e.createdAt0?[4,this.getAllChildMessages(e)]:[3,2];case 1:t=r.sent(),r.label=2;case 2:return t.length>0?(t.forEach((function(t){return t.applyParentMessage(e)})),[4,this.upsert(t)]):[3,4];case 3:r.sent(),r.label=4;case 4:return[2]}}))}))})))]:[3,2];case 1:n.sent(),n.label=2;case 2:return[2]}}))}))},t.prototype.remove=function(e){return r(this,void 0,void 0,(function(){var t,n,r,o,a,c;return s(this,(function(s){switch(s.label){case 0:if(!this.localCacheEnabled)return[3,8];s.label=1;case 1:s.trys.push([1,6,7,8]),t=i(e),n=t.next(),s.label=2;case 2:return n.done?[3,5]:(r=n.value,[4,this.collection.remove("".concat(r))]);case 3:s.sent(),s.label=4;case 4:return n=t.next(),[3,2];case 5:return[3,8];case 6:return o=s.sent(),a={error:o},[3,8];case 7:try{n&&!n.done&&(c=t.return)&&c.call(t)}finally{if(a)throw a.error}return[7];case 8:return[2]}}))}))},t.prototype.removeMessagesOfChannel=function(e){return r(this,void 0,void 0,(function(){var t;return s(this,(function(n){switch(n.label){case 0:return this.localCacheEnabled?[4,this.collection.removeIf({where:{channelUrl:e},index:W(j.CHANNEL_LATEST)})]:[3,6];case 1:return n.sent(),[4,(t=this._cacheContext.preference).remove("sendbird:".concat(this._sdkState.userId,"@groupchannel/").concat(e,"/message/sync"))];case 2:return n.sent(),[4,t.remove("sendbird:".concat(this._sdkState.userId,"@groupchannel/").concat(e,"/message/sync.meta"))];case 3:return n.sent(),[4,t.remove("sendbird:".concat(this._sdkState.userId,"@groupchannel/").concat(e,"/message/changelogs"))];case 4:return n.sent(),[4,t.remove("sendbird:".concat(this._sdkState.userId,"@groupchannel/").concat(e,"/message/changelogs.meta"))];case 5:n.sent(),n.label=6;case 6:return[2]}}))}))},t.prototype.removeUnderOffset=function(e,t){return r(this,void 0,void 0,(function(){return s(this,(function(n){switch(n.label){case 0:return this.localCacheEnabled?[4,this.collection.removeIf({where:{channelUrl:e,createdAt:{"<":t}},index:W(j.CHANNEL_LATEST)})]:[3,2];case 1:n.sent(),n.label=2;case 2:return[2]}}))}))},t.prototype.clear=function(){return r(this,void 0,void 0,(function(){return s(this,(function(e){switch(e.label){case 0:return this.localCacheEnabled?[4,this.collection.clear()]:[3,2];case 1:e.sent(),e.label=2;case 2:return[2]}}))}))},t.prototype.countBetween=function(e,t,n){return r(this,void 0,void 0,(function(){var r,i=this;return s(this,(function(s){switch(s.label){case 0:return this.localCacheEnabled?(r=W(j.CHANNEL_LATEST),[4,this.collection.query({where:{channelUrl:e,"/where":function(e){var r=i._deserialize(e);return n.includes(r.createdAt)&&t.match(r)}},index:r}).count()]):[3,2];case 1:return[2,s.sent()];case 2:return[2,0]}}))}))},t.prototype.saveBlobs=function(e){return r(this,void 0,void 0,(function(){var t=this;return s(this,(function(n){switch(n.label){case 0:return[4,Promise.all(e.map((function(e){return r(t,void 0,void 0,(function(){var t,n;return s(this,(function(r){switch(r.label){case 0:return e instanceof V&&e.messageParams&&((t=e.messageParams).file&&D(t.file))?[4,this.collection.saveBlob(t.file,e.reqId)]:[3,2];case 1:n=r.sent(),t.fileKey=n,r.label=2;case 2:return[2]}}))}))})))];case 1:return n.sent(),[2]}}))}))},t.prototype._getGroupChannelPreferenceSize=function(e){return r(this,void 0,void 0,(function(){var t,n,r,i,o,a;return s(this,(function(s){switch(s.label){case 0:return t=0,[4,(n=this._cacheContext.preference).get("sendbird:".concat(this._sdkState.userId,"@groupchannel/").concat(e,"/message/sync"))];case 1:return r=s.sent(),[4,n.get("sendbird:".concat(this._sdkState.userId,"@groupchannel/").concat(e,"/message/sync.meta"))];case 2:return i=s.sent(),[4,n.get("sendbird:".concat(this._sdkState.userId,"@groupchannel/").concat(e,"/message/changelogs"))];case 3:return o=s.sent(),[4,n.get("sendbird:".concat(this._sdkState.userId,"@groupchannel/").concat(e,"/message/changelogs.meta"))];case 4:return a=s.sent(),r&&(t+=JSON.stringify(r).length),i&&(t+=JSON.stringify(i).length),o&&(t+=JSON.stringify(o).length),a&&(t+=JSON.stringify(a).length),[2,t]}}))}))},t}(h),fe=function(e){function t(t){var n=t.message,r=e.call(this)||this;return r.message=n,r}return u(t,e),t}(d),_e={},ve=function(){function e(e,t){var n=t.localCacheEnabled,r=t.dispatcher,i=t.sdkState,s=t.logger,o=this;this._iid=e,_e[e]=this,this._localCacheEnabled=n,this._isProcessingAutoResend=!1,this._autoResendQueue=[],this._dispatcher=r,this._logger=s,this._sdkState=i,this._localCacheEnabled&&r.on((function(e){if(e instanceof v)switch(e.stateType){case m.CONNECTED:o._isProcessingAutoResend||o.processAutoResendRegisteredPendingMessages().then((function(){return o._processNextAutoResend()}));break;case m.INTERNAL_DISCONNECTED:case m.EXTERNAL_DISCONNECTED:o._isProcessingAutoResend=!1}}))}return e.of=function(e){return _e[e]},e.prototype.processNonAutoResendRegisteredPendingMessages=function(){return r(this,void 0,void 0,(function(){var e,t,n,r,o,a;return s(this,(function(s){switch(s.label){case 0:return[4,this._fetchAllCachedPendingMessages()];case 1:e=s.sent();try{for(t=i(e),n=t.next();!n.done;n=t.next())0===(r=n.value).errorCode&&(this._logger.debug("cached pending message is not auto-resend registered. changing its sending status to failed: ",r.reqId),r.sendingStatus=f.FAILED,r.errorCode=p.ACK_TIMEOUT,this._dispatcher.dispatch(new y({messages:[r],source:E.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.processAutoResendRegisteredPendingMessages=function(){return r(this,void 0,void 0,(function(){var e,t,n,r,o,a,c,u;return s(this,(function(s){switch(s.label){case 0:return[4,this._fetchAllCachedPendingMessages()];case 1:e=s.sent();try{for(t=i(e),n=t.next();!n.done;n=t.next())(r=n.value).errorCode&&_(r.errorCode)&&(o=(new Date).getTime(),a=r.createdAt+2592e5,o<=a?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(a).toLocaleString()),r.sendingStatus=f.FAILED,this._dispatcher.dispatch(new y({messages:[r],source:E.LOCAL_MESSAGE_FAILED}))))}catch(e){c={error:e}}finally{try{n&&!n.done&&(u=t.return)&&u.call(t)}finally{if(c)throw c.error}}return[2]}}))}))},e.prototype.completeCurrentAndProcessNextAutoResend=function(e){if(this._localCacheEnabled&&(e.sendingStatus===f.SUCCEEDED||e.sendingStatus===f.FAILED&&!_(e.errorCode))){var t=this.indexOf(e);t>=0&&this._autoResendQueue.splice(t,1),0===t&&this._processNextAutoResend()}},e.prototype._fetchAllCachedPendingMessages=function(){return r(this,void 0,void 0,(function(){var e,t;return s(this,(function(n){switch(n.label){case 0:return(e=le.of(this._iid))?[4,e.fetch({sendingStatus:f.PENDING,backward:!0})]:[3,2];case 1:return t=n.sent(),[3,3];case 2:t=[],n.label=3;case 3:return[2,t]}}))}))},e.prototype.indexOf=function(e){return this._autoResendQueue.length>0?this._autoResendQueue.map((function(e){return e.reqId})).indexOf(e.reqId):-1},e.prototype._isNotInQueue=function(e){return-1===this._autoResendQueue.map((function(e){return e.reqId})).indexOf(e.reqId)},e.prototype._processNextAutoResend=function(){return r(this,void 0,void 0,(function(){var e;return s(this,(function(t){if(this._localCacheEnabled&&"foreground"===this._sdkState.appState)try{this._autoResendQueue.length>0?(this._isProcessingAutoResend||(this._logger.debug("auto-resend queue started."),this._isProcessingAutoResend=!0),e=this._autoResendQueue[0],this._dispatcher.dispatch(new fe({message:e})),this._logger.debug("processing auto-resend for message request id: ",e.reqId)):(this._logger.debug("auto-resend queue finished."),this._isProcessingAutoResend=!1)}catch(e){this._logger.warn("process auto-resend error: ",e),this._isProcessingAutoResend=!1}return[2]}))}))},e}();!function(e){e[e.USER_BLOCK=20001]="USER_BLOCK",e[e.USER_UNBLOCK=2e4]="USER_UNBLOCK",e[e.FRIEND_DISCOVERED=20900]="FRIEND_DISCOVERED"}(ee||(ee={}));var me,pe=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 b(e,r),blockee:new b(e,i)}},e.getDataAsFriendDiscoveredEvent=function(e,t){var n=t.data.friend_discoveries;return{friendDiscoveries:Array.isArray(n)?n.map((function(t){return new b(e,t)})):[]}},e}(),ye=function(e){function t(t,n){var r=n.userId,i=e.call(this)||this;return i._iid=t,i.userId=r,i}return u(t,e),t}(d);!function(e){e.UNKNOWN="UNKNOWN",e.EVENT_CHANNEL_CREATED="EVENT_CHANNEL_CREATED",e.EVENT_CHANNEL_UPDATED="EVENT_CHANNEL_UPDATED",e.EVENT_CHANNEL_DELETED="EVENT_CHANNEL_DELETED",e.EVENT_CHANNEL_READ="EVENT_CHANNEL_READ",e.EVENT_CHANNEL_DELIVERED="EVENT_CHANNEL_DELIVERED",e.EVENT_CHANNEL_INVITED="EVENT_CHANNEL_INVITED",e.EVENT_CHANNEL_JOINED="EVENT_CHANNEL_JOINED",e.EVENT_CHANNEL_LEFT="EVENT_CHANNEL_LEFT",e.EVENT_CHANNEL_ACCEPTED_INVITE="EVENT_CHANNEL_ACCEPTED_INVITE",e.EVENT_CHANNEL_DECLINED_INVITE="EVENT_CHANNEL_DECLINED_INVITE",e.EVENT_CHANNEL_OPERATOR_UPDATED="EVENT_CHANNEL_OPERATOR_UPDATED",e.EVENT_CHANNEL_MUTED="EVENT_CHANNEL_MUTED",e.EVENT_CHANNEL_UNMUTED="EVENT_CHANNEL_UNMUTED",e.EVENT_CHANNEL_FROZEN="EVENT_CHANNEL_FROZEN",e.EVENT_CHANNEL_UNFROZEN="EVENT_CHANNEL_UNFROZEN",e.EVENT_CHANNEL_HIDDEN="EVENT_CHANNEL_HIDDEN",e.EVENT_CHANNEL_UNHIDDEN="EVENT_CHANNEL_UNHIDDEN",e.EVENT_CHANNEL_RESET_HISTORY="EVENT_CHANNEL_RESET_HISTORY",e.EVENT_CHANNEL_TYPING_STATUS_UPDATE="EVENT_CHANNEL_TYPING_STATUS_UPDATE",e.EVENT_CHANNEL_MEMBER_COUNT_UPDATED="EVENT_CHANNEL_MEMBER_COUNT_UPDATED",e.EVENT_MESSAGE_SENT="EVENT_MESSAGE_SENT",e.EVENT_MESSAGE_RECEIVED="EVENT_MESSAGE_RECEIVED",e.EVENT_MESSAGE_UPDATED="EVENT_MESSAGE_UPDATED",e.EVENT_PINNED_MESSAGE_UPDATED="EVENT_PINNED_MESSAGE_UPDATED",e.REQUEST_CHANNEL="REQUEST_CHANNEL",e.REQUEST_CHANNEL_CHANGELOGS="REQUEST_CHANNEL_CHANGELOGS",e.REFRESH_CHANNEL="REFRESH_CHANNEL",e.CHANNEL_LASTACCESSEDAT_UPDATED="CHANNEL_LASTACCESSEDAT_UPDATED",e.SYNC_CHANNEL_BACKGROUND="SYNC_CHANNEL_BACKGROUND",e.SYNC_CHANNEL_CHANGELOGS="SYNC_CHANNEL_CHANGELOGS"}(me||(me={}));var Ee,be=function(e){return e.startsWith("EVENT_")||e===me.SYNC_CHANNEL_CHANGELOGS||e===me.REFRESH_CHANNEL},ge=function(e){function t(t){var n=t.channels,r=t.source,i=t.data,s=void 0===i?null:i,o=e.call(this)||this;return o.channels=n,o.source=r,o.data=s,o}return u(t,e),t}(d),Ne=function(e){function t(t){var n=t.channelUrls,r=t.source,i=e.call(this)||this;return i.channelUrls=n,i.source=r,i}return u(t,e),t}(d),Ie=function(e){function t(){return e.call(this)||this}return u(t,e),t}(d),we=function(e){function t(t,n,r){var i=e.call(this,t,"USEV",r)||this;return i.event=new pe(r),i}return u(t,e),t}(g),Ae={},Te=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,c=e.blockHashMultiplier,u=void 0===c?10:c,l=e.blockHashConstant,h=void 0===l?11:l,d=e.transactionApplyDelay,f=void 0===d?200:d,_=e.disableLogger,v=void 0!==_&&_;return Ae[t]||(this.itemSizeLimit=r,this.cacheLimit=s,this.blockHashBase=a,this.blockHashMultiplier=u,this.blockHashConstant=h,this.transactionApplyDelay=f,this.disableLogger=v,Ae[t]=this),Ae[t]}return e.get=function(e){return Ae[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"}(Ee||(Ee={}));var Oe,Ce=function(e){function t(n){var r=n.code,i=void 0===r?Ee.UNKNOWN_ERROR:r,s=n.message,o=void 0===s?"Unknown error occurred.":s,a=e.call(this,o)||this;return a.code=i,Object.setPrototypeOf(a,t.prototype),a}return u(t,e),Object.defineProperty(t,"storeNotDefined",{get:function(){return new t({code:Ee.STORE_NOT_DEFINED,message:"Store is not defined. Specify the store on NestDB()"})},enumerable:!1,configurable:!0}),Object.defineProperty(t,"storeNotAvailable",{get:function(){return new t({code:Ee.STORE_NOT_AVAILABLE,message:"Store is not available. Check your environment settings."})},enumerable:!1,configurable:!0}),Object.defineProperty(t,"storeNotAvailableInPrivateBrowsing",{get:function(){return new t({code:Ee.STORE_NOT_AVAILABLE_IN_PRIVATE_BROWSING,message:"Store is not available because it is in private browsing."})},enumerable:!1,configurable:!0}),Object.defineProperty(t,"storeIsFull",{get:function(){return new t({code:Ee.STORE_IS_FULL,message:"Store is full."})},enumerable:!1,configurable:!0}),Object.defineProperty(t,"storeKeyTypeIsInvalid",{get:function(){return new t({code:Ee.STORE_INVALID_KEY_TYPE,message:"Store key should be string type."})},enumerable:!1,configurable:!0}),Object.defineProperty(t,"storeBrokenIntegrity",{get:function(){return new t({code:Ee.STORE_BROKEN_INTEGRITY,message:"Data should be in a store but it does not. Integrity is broken."})},enumerable:!1,configurable:!0}),Object.defineProperty(t,"storeBrokenBlob",{get:function(){return new t({code:Ee.STORE_BROKEN_BLOB,message:"Data should be in a store but it does not. Blob data is broken."})},enumerable:!1,configurable:!0}),Object.defineProperty(t,"storeEncryptionInvalid",{get:function(){return new t({code:Ee.STORE_ENCRYPTION_INVALID,message:"Encryption algorithm has changed. All the store should reset."})},enumerable:!1,configurable:!0}),Object.defineProperty(t,"storeItemSizeExceeded",{get:function(){return new t({code:Ee.STORE_ITEM_SIZE_LIMIT_EXCEEDED,message:"The size of the item exceeds the limit that the store allows."})},enumerable:!1,configurable:!0}),Object.defineProperty(t,"storeReadFailed",{get:function(){return new t({code:Ee.STORE_READ_FAILED,message:"Failed to read from store."})},enumerable:!1,configurable:!0}),Object.defineProperty(t,"storeWriteFailed",{get:function(){return new t({code:Ee.STORE_WRITE_FAILED,message:"Failed to write to store."})},enumerable:!1,configurable:!0}),Object.defineProperty(t,"databaseSchemaNotOnUpgrade",{get:function(){return new t({code:Ee.DATABASE_SCHEMA_NOT_ON_UPGRADE,message:"Committing schema is not allowed when upgrade is not running."})},enumerable:!1,configurable:!0}),Object.defineProperty(t,"collectionNotReady",{get:function(){return new t({code:Ee.COLLECTION_NOT_READY,message:"Collection is not ready due to an error during initialization."})},enumerable:!1,configurable:!0}),Object.defineProperty(t,"collectionKeyNotMatch",{get:function(){return new t({code:Ee.COLLECTION_KEY_NOT_MATCH,message:"keyName of collection could not change."})},enumerable:!1,configurable:!0}),Object.defineProperty(t,"collectionQueryNotValid",{get:function(){return new t({code:Ee.COLLECTION_QUERY_NOT_VALID,message:"Query parameter is not a valid format."})},enumerable:!1,configurable:!0}),Object.defineProperty(t,"collectionInsertDuplicate",{get:function(){return new t({code:Ee.COLLECTION_INSERT_DUPLICATE,message:"The key already exists."})},enumerable:!1,configurable:!0}),Object.defineProperty(t,"collectionKeyNotFound",{get:function(){return new t({code:Ee.COLLECTION_KEY_NOT_FOUND,message:"The key is not found."})},enumerable:!1,configurable:!0}),Object.defineProperty(t,"collectionKeyNotGiven",{get:function(){return new t({code:Ee.COLLECTION_KEY_NOT_GIVEN,message:"The item should contain [keyName] property."})},enumerable:!1,configurable:!0}),Object.defineProperty(t,"collectionWriteFailed",{get:function(){return new t({code:Ee.COLLECTION_WRITE_FAILED,message:"Failed to write an item."})},enumerable:!1,configurable:!0}),Object.defineProperty(t,"collectionItemSizeExceeded",{get:function(){return new t({code:Ee.COLLECTION_ITEM_SIZE_LIMIT_EXCEEDED,message:"The size of the item exceeds the limit that a collection allows."})},enumerable:!1,configurable:!0}),Object.defineProperty(t,"indexTableIsRequired",{get:function(){return new t({code:Ee.INDEX_TABLE_IS_REQUIRED,message:"Index table is required."})},enumerable:!1,configurable:!0}),Object.defineProperty(t,"indexTypesNotMatch",{get:function(){return new t({code:Ee.INDEX_TYPE_NOT_MATCH,message:"Indexed column should have primitive type."})},enumerable:!1,configurable:!0}),Object.defineProperty(t,"compareTypesNotMatch",{get:function(){return new t({code:Ee.COMPARE_TYPE_NOT_MATCH,message:"Values to compare have different types."})},enumerable:!1,configurable:!0}),Object.defineProperty(t,"circularReferenceFound",{get:function(){return new t({code:Ee.CIRCULAR_REFERENCE_FOUND,message:"Cannot handle circular referenced object."})},enumerable:!1,configurable:!0}),t}(Error);!function(e){e.INIT="init",e.READY="ready",e.CLOSED="closed"}(Oe||(Oe={}));var Se,ke=function(e,t){if(void 0===t&&(t=new WeakMap),"object"==typeof e&&null!==e){if(t.has(e))throw Ce.circularReferenceFound;t.set(e,!0);var n=null;if(Array.isArray(e))n=e.map((function(e){return ke(e,t)}));else if(e instanceof RegExp)n=e;else if(e instanceof Date)n=e;else for(var r in n={},e)n[r]=ke(e[r],t);return t.delete(e),n}return e},Le=function(e,t){if(null==t)return 1;if(null==e)return-1;if(typeof e!=typeof t)throw Ce.compareTypesNotMatch;var n=0;switch(typeof e){case"boolean":case"number":n=e-t;break;case"string":n=e.localeCompare(t)}return n},xe=function(e,t){for(var n=0,r=0;r>>0)%t},Re=function(e){return new Promise((function(t){setTimeout((function(){return t()}),e)}))},De=function(e,t){if(!t)return!1;if("function"!=typeof e){for(var n in e){if(["/and","&&"].includes(n)){if(e[n].some((function(e){return!De(e,t)})))return!1}else if(["/or","||"].includes(n)){if(e[n].every((function(e){return!De(e,t)})))return!1}else if("/where"===n){if(!(0,e[n])(t))return!1}else{var r=n;if("object"==typeof e[r]){var i=e[r];for(var s in i)switch(s){case"/eq":case"=":if((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(!(Le(o,a)>0))return!1;break;case"/gte":case">=":o=t[r],a=i[s];if(!(Le(o,a)>=0))return!1;break;case"/lt":case"<":o=t[r],a=i[s];if(!(Le(o,a)<0))return!1;break;case"/lte":case"<=":o=t[r],a=i[s];if(!(Le(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)},Pe=function(){},Me=function(){return Promise.resolve()},Be=function(e){return e},He=function(e,t){t(null)};!function(e){e[e.FORWARD=0]="FORWARD",e[e.BACKWARD=1]="BACKWARD"}(Se||(Se={}));var Ve,Ue,Ke,qe=function(){function e(e){var t=e.initialPrevValue,n=void 0===t?null:t,r=e.initialNextValue,i=void 0===r?null:r,s=e.iterator,o=e.map,a=void 0===o?Be:o,c=e.backward,u=void 0===c?Me:c,l=e.forward,h=void 0===l?Me:l,d=e.complete,f=void 0===d?Pe:d;this._prevValue=n,this._nextValue=i,this._error=null,this._map=a,this._backward=u,this._forward=h,this._iterator=s,this._complete=f}return Object.defineProperty(e.prototype,"prevValue",{get:function(){return this._map(this._prevValue)},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"nextValue",{get:function(){return this._map(this._nextValue)},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"error",{get:function(){return this._error},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"hasPrevious",{get:function(){return!!this._prevValue},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"hasNext",{get:function(){return!!this._nextValue},enumerable:!1,configurable:!0}),e.prototype.prev=function(){return r(this,void 0,void 0,(function(){var e,t,n;return s(this,(function(r){switch(r.label){case 0:if(!this.hasPrevious)return[3,6];r.label=1;case 1:return r.trys.push([1,3,,4]),e=this._prevValue,t=this,[4,this._backward()];case 2:return t._prevValue=r.sent()||null,this._nextValue=e,[3,4];case 3:return n=r.sent(),this._error=n,[3,4];case 4:return[4,this._iterator(this)];case 5:return[2,r.sent()];case 6:this._complete(),r.label=7;case 7:return[2]}}))}))},e.prototype.next=function(){return r(this,void 0,void 0,(function(){var e,t,n;return s(this,(function(r){switch(r.label){case 0:if(!this.hasNext)return[3,6];r.label=1;case 1:return r.trys.push([1,3,,4]),e=this._nextValue,t=this,[4,this._forward()];case 2:return t._nextValue=r.sent()||null,this._prevValue=e,[3,4];case 3:return n=r.sent(),this._error=n,[3,4];case 4:return[4,this._iterator(this)];case 5:return[2,r.sent()];case 6:this._complete(),r.label=7;case 7:return[2]}}))}))},e.prototype.stop=function(){this._prevValue=null,this._nextValue=null,this._complete()},e}(),Fe=function(){function e(e){var t=e.condition,n=void 0===t?{}:t,r=e.backward,i=void 0!==r&&r,s=e.blockManager,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 c in this.condition[s])if(a.includes(c))for(var u=r;u>=0;u--)if(o*Le(this._indexer.origin[u].columnValues[i],this.condition[s][c])<=0){r=u;break}}else for(u=r;u>=0;u--)if(o*Le(this._indexer.origin[u].columnValues[i],this.condition[s])<=0){r=u;break}}return Math.min(r+1,this._indexer.origin.length-1)}var l=0;if("function"!=typeof this.condition)for(var h=function(r){var i=d._indexer.fields[r],s=1;if("-"===i[0]&&(i=i.slice(1),s=-1),d.condition[i])if("object"==typeof d.condition[i])Object.keys(d.condition[i]).forEach((function(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;i-1){var r=this._items[n];return t===Ke.PERSISTENT&&(r.state=Ue.PERSISTENT),t!==Ke.NO_CACHE&&this.put(r),r}return null},e.prototype.put=function(e){var t,n;if(this._limit>0){var r=this._items.map((function(e){return e.key})).indexOf(e.key);if(r>-1)Xe.includes(this._items[r].state)&&Xe.includes(e.state)?(this._items.splice(r,1),this._items.push(e)):(this._items[r].state=e.state,this._items[r].generation=e.generation,this._items[r].value=e.value);else{this._items.push(e);var s=this._items.filter((function(e){return e.state===Ue.VOLATILE})),o=s.length-this._limit;if(o>0){var a=[];try{for(var c=i(this._items),u=c.next();!u.done;u=c.next()){var l=u.value;l.state===Ue.VOLATILE&&o>0?o--:a.push(l)}}catch(e){t={error:e}}finally{try{u&&!u.done&&(n=c.return)&&n.call(c)}finally{if(t)throw t.error}}this._items=a}}}},e.prototype.remove=function(e){var t=this._items.map((function(e){return e.key})).indexOf(e);t>-1&&this._items.splice(t,1)},e.prototype.clearByCondition=function(e){this._items=this._items.filter((function(t){return!e(t)}))},e.prototype.clear=function(e){void 0===e&&(e=!1),this._items=e?[]:this._items.filter((function(e){return e.state!==Ue.VOLATILE}))},e}(),et=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(ze(e,t),"/trans.metadata")}(t,n),this.recordsetKey=function(e,t){return"".concat(ze(e,t),"/trans.recordset")}(t,n),this._store=r}return Object.defineProperty(e.prototype,"generation",{get:function(){return this._metadata?this._metadata.generation:0},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"requestCount",{get:function(){return this._requests.length},enumerable:!1,configurable:!0}),e.prototype._getReducedRecordset=function(e){return void 0===e&&(e=[]),r(this,void 0,void 0,(function(){var t;return s(this,(function(n){switch(n.label){case 0:return[4,this._store.get(this.recordsetKey)];case 1:return(t=n.sent()||[]).push.apply(t,N([],I(e),!1)),[2,this._reduceRecordSet(t)]}}))}))},e.prototype._reduceRecordSet=function(e){for(var t=[],n={},r=e.length-1;r>=0;r--){for(var i=e[r],s=[],o=i.requests.length-1;o>=0;o--){var a=i.requests[o],c=a.data;n[c.key]||(s.unshift(a),n[c.key]=!0)}s.length>0&&(i.requests=s,t.unshift(i))}return t},e.prototype._applyRecord=function(e,t){return r(this,void 0,void 0,(function(){var n,r,i,a,c,u,l,h,d;return s(this,(function(s){switch(s.label){case 0:n=$e.get(this.dbname),r=t.generation,i=t.requests,a=null,s.label=1;case 1:return s.trys.push([1,3,,4]),[4,this._store.setMany(i.map((function(e){return o(o({},e.data),{generation:r})})))];case 2:for(c=s.sent(),u=0;u0))return[3,4];for(t=[],n={},u=e.length-1;u>=0;u--)r=e[u],h=r.data,n[h.key]||(n[h.key]=!0,t.unshift(r));return i={generation:this.generation,requests:t},[4,this._getReducedRecordset([i])];case 1:return a=s.sent(),[4,this._store.set({key:this.recordsetKey,value:a,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(),c=$e.get(this.dbname),u=0;u0?(r=this.createBlockId(e,n),[4,t.find(this._store,r)]):[3,4];case 2:if((i=s.sent())&&(o=tt.createFromCacheItem(i),o.getItemByKey(e)))return[2,o];s.label=3;case 3:return n--,[3,1];case 4:return[2,null]}}))}))},e.prototype.getFromBlock=function(e){return r(this,void 0,void 0,(function(){var t;return s(this,(function(n){switch(n.label){case 0:return[4,this._findBlock(e)];case 1:return[2,(t=n.sent())?t.getItemByKey(e):null]}}))}))},e.prototype.putToBlock=function(e,t){return r(this,void 0,void 0,(function(){var n,r,i,o,a;return s(this,(function(s){switch(s.label){case 0:return n=Te.get(this.dbname),r=this.createBlockId(e),i=Math.floor(this._store.itemSizeLimit/n.itemSizeLimit),[4,$e.get(this.dbname).find(this._store,r)];case 1:return o=s.sent(),(a=o?tt.createFromCacheItem(o):new tt({blockId:r,keyName:this.keyName,items:[],limit:i})).add(t)?(this._transaction.requestWrite({key:a.blockId,value:a.serialize()}),[2,!0]):[2,!1]}}))}))},e.prototype.removeFromBlock=function(e){return r(this,void 0,void 0,(function(){var t;return s(this,(function(n){switch(n.label){case 0:return[4,this._findBlock(e)];case 1:return(t=n.sent())&&t.remove(e)?(this._transaction.requestWrite({key:t.blockId,value:t.serialize()}),[2,!0]):[2,!1]}}))}))},e.prototype.clearAllBlocks=function(){return r(this,void 0,void 0,(function(){var e,t,n;return s(this,(function(r){switch(r.label){case 0:return e=Ye(this.dbname,this.collectionName),[4,this._store.getAllKeys()];case 1:return t=r.sent(),n=t.filter((function(t){return t.startsWith(e)})),[4,this._store.removeMany(n)];case 2:return r.sent(),[4,this._transaction.clear()];case 3:return r.sent(),$e.get(this.dbname).clearByCondition((function(t){return t.key.startsWith(e)})),[2]}}))}))},e}(),rt={},it=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=[];var c=function(e,t,n){return"".concat(ze(e,t),"/index.").concat(n)}(t,n,i.join(">"));return rt[c]||(this.dbname=t,this.collectionName=n,this.keyName=r,this.fields=i,this.indexerKey=c,this._transaction=s,this._store=o,this._transaction.on(Ve.COMMIT,this.indexerKey,(function(){return a.commit()})),this._transaction.on(Ve.ERROR,this.indexerKey,(function(){return a.abort()}))),rt[c]}return e.createKey=function(e){return e.join(">")},e.parseKey=function(e){return e.split(">")},e.clearIndexerMap=function(){for(var e in rt)delete rt[e]},e.prototype._addItem=function(e){var t=e[this.keyName],n=this.getColumnValues(e),r=I(this.indexOf(n),2),i=r[0];return r[1]?!this._table[i].keys.includes(t)&&(this._table[i].keys.push(t),!0):(this._table.splice(i,0,{columnValues:n,keys:[t]}),!0)},e.prototype._removeItem=function(e){var t=e[this.keyName],n=this.getColumnValues(e),r=I(this.indexOf(n),2),i=r[0];if(r[1]){var s=this._table[i].keys.indexOf(t);if(s>-1)return this._table[i].keys.splice(s,1),0===this._table[i].keys.length&&this._table.splice(i,1),!0}return!1},Object.defineProperty(e.prototype,"origin",{get:function(){return this._origin},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"table",{get:function(){return this._table},enumerable:!1,configurable:!0}),e.prototype.getColumnValues=function(e){var t,n,r,s,o=[];try{for(var a=i(this.fields),c=a.next();!c.done;c=a.next()){var u=c.value;if("-"===u[0]&&(u=u.slice(1)),r=e[u],s=void 0,s=typeof r,null!==r&&"undefined"!==s&&"boolean"!==s&&"number"!==s&&"string"!==s)throw Ce.indexTypesNotMatch;o.push(e[u])}}catch(e){t={error:e}}finally{try{c&&!c.done&&(n=a.return)&&n.call(a)}finally{if(t)throw t.error}}return o},e.prototype.diff=function(e,t){for(var n in this.fields){var r="-"===this.fields[n][0]?-1:1,i=Le(e[n],t[n]);if(0!==i)return r*i}return 0},e.prototype.indexOf=function(e){if(this._table.length>0){for(var t=0,n=this._table.length-1;t<=n;){var r=Math.floor((t+n)/2),i=this.diff(e,this._table[r].columnValues);if(i>0)t=r+1;else{if(!(i<0))return[r,!0];n=r-1}}return[t,!1]}return[0,!1]},e.prototype.ensure=function(){return r(this,void 0,void 0,(function(){var e,t,n,r,o,a,c,u,l,h,d,f,_,v,m,p,y;return s(this,(function(s){switch(s.label){case 0:return[4,(e=$e.get(this.dbname)).find(this._store,this.indexerKey,Ke.PERSISTENT)];case 1:return(t=s.sent())?[3,11]:(n=Ye(this.dbname,this.collectionName),[4,this._store.getAllKeys()]);case 2:r=s.sent(),s.label=3;case 3:s.trys.push([3,8,9,10]),o=i(r),a=o.next(),s.label=4;case 4:return a.done?[3,7]:(c=a.value).startsWith(n)?[4,e.find(this._store,c,Ke.NO_CACHE)]:[3,6];case 5:u=s.sent(),l=tt.createFromCacheItem(u);try{for(p=void 0,h=i(l.items),d=h.next();!d.done;d=h.next())f=d.value,this._addItem(f)}catch(e){p={error:e}}finally{try{d&&!d.done&&(y=h.return)&&y.call(h)}finally{if(p)throw p.error}}s.label=6;case 6:return a=o.next(),[3,4];case 7:return[3,10];case 8:return _=s.sent(),v={error:_},[3,10];case 9:try{a&&!a.done&&(m=o.return)&&m.call(o)}finally{if(v)throw v.error}return[7];case 10:return this._transaction.requestWrite({key:this.indexerKey,value:this._table},{persistent:!0}),[3,12];case 11:this._origin=t.value,this._table=ke(this._origin),s.label=12;case 12:return rt[this.indexerKey]=this,[2]}}))}))},e.prototype.drop=function(){return r(this,void 0,void 0,(function(){return s(this,(function(e){switch(e.label){case 0:return $e.get(this.dbname).remove(this.indexerKey),[4,this._store.remove(this.indexerKey)];case 1:return e.sent(),delete rt[this.indexerKey],[2]}}))}))},e.prototype.addItem=function(e){return r(this,void 0,void 0,(function(){return s(this,(function(t){return this._addItem(e)&&this._transaction.requestWrite({key:this.indexerKey,value:this._table},{persistent:!0}),[2]}))}))},e.prototype.removeItem=function(e){return r(this,void 0,void 0,(function(){return s(this,(function(t){return this._removeItem(e)&&this._transaction.requestWrite({key:this.indexerKey,value:this._table},{persistent:!0}),[2]}))}))},e.prototype.clear=function(){return r(this,void 0,void 0,(function(){return s(this,(function(e){return this._table=[],this._transaction.requestWrite({key:this.indexerKey,value:this._table},{persistent:!0}),[2]}))}))},e.prototype.commit=function(){this._origin=this._table,this._table=ke(this._origin)},e.prototype.abort=function(){this._table=ke(this._origin)},e}(),st=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=Oe.INIT,this._metadata=null,this._indexers=[],this.dbname=t,this.name=n,this.keyName=r,this.indexes=N([[r]],I(s.filter((function(e){return it.createKey(e)!==a.keyName}))),!1),this._keyHash=i,this._store=o,this._mutex=new ne(function(e,t){return"".concat(ze(e,t),".lock")}(t,n)),this._blobContainer=new Je({dbname:t,collectionName:n,store:o}),this._transaction=new et({dbname:t,collectionName:n,store:o})}return e.metadataOf=function(e,t,n){return r(this,void 0,void 0,(function(){var r;return s(this,(function(i){switch(i.label){case 0:return r=We(e,t),[4,n.get(r)];case 1:return[2,i.sent()]}}))}))},Object.defineProperty(e.prototype,"state",{get:function(){return this._state},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"isReady",{get:function(){return this._state===Oe.READY},enumerable:!1,configurable:!0}),e.prototype.init=function(){return r(this,void 0,void 0,(function(){var t,n,r,o,a,c,u,l,h,d,f,_,v,m,p=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=Te.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 nt({dbname:this.dbname,collectionName:this.name,hashFunction:this._keyHash,metadata:this._metadata,transaction:this._transaction,store:this._store}),r=N([],I(this.indexes),!1),o=[],a=r.map((function(e){return it.createKey(e)})),c=n?n.indexes.map((function(e){return it.createKey(e)})):[];try{for(u=i(c),l=u.next();!l.done;l=u.next())h=l.value,a.includes(h)||o.push(it.parseKey(h))}catch(e){v={error:e}}finally{try{l&&!l.done&&(m=u.return)&&m.call(u)}finally{if(v)throw v.error}}return(d=[]).push.apply(d,N([],I(r.map((function(e){var t=new it({dbname:p.dbname,collectionName:p.name,keyName:p.keyName,fields:e,transaction:p._transaction,store:p._store});return p._indexers.push(t),t.ensure()}))),!1)),d.push.apply(d,N([],I(o.map((function(e){return new it({dbname:p.dbname,collectionName:p.name,keyName:p.keyName,fields:e,transaction:p._transaction,store:p._store}).drop()}))),!1)),[4,Promise.all(d)];case 5:return s.sent(),[4,this._transaction.commit()];case 6:return s.sent(),a.sort().join(",")===c.sort().join(",")?[3,8]:(f=We(this.dbname,this.name),this._metadata.indexes=r,[4,this._store.set({key:f,value:this._metadata,generation:1})]);case 7:s.sent(),s.label=8;case 8:return this._state=Oe.READY,this._mutex.unlock(),[3,10];case 9:throw _=s.sent(),this._mutex.unlock(),_;case 10:return[2]}}))}))},e.prototype.close=function(){this._state=Oe.CLOSED},e.prototype._hasPropertyOfKeyName=function(e){var t=e[this.keyName];return"string"==typeof t&&!!t},e.prototype._getIndexerBy=function(e){var t,n;void 0===e&&(e=null),e||(e=[this.keyName]);var r=it.createKey(e);try{for(var s=i(this._indexers),o=s.next();!o.done;o=s.next()){var a=o.value;if(r===it.createKey(a.fields))return a}}catch(e){t={error:e}}finally{try{o&&!o.done&&(n=s.return)&&n.call(s)}finally{if(t)throw t.error}}return null},e.prototype._upgradeBlockLevel=function(){return r(this,void 0,void 0,(function(){var e;return s(this,(function(t){switch(t.label){case 0:return e=We(this.dbname,this.name),this._metadata.blockLevel++,[4,this._store.set({key:e,value:this._metadata,generation:1})];case 1:return t.sent(),[2]}}))}))},e.prototype._requestInsert=function(e){return r(this,void 0,void 0,(function(){var t,n,r,o,a,c;return s(this,(function(s){switch(s.label){case 0:return t=e[this.keyName],[4,this._blockManager.getFromBlock(t)];case 1:return s.sent()?[3,13]:[4,this._blockManager.putToBlock(t,e)];case 2:return s.sent()?[3,5]:[4,this._upgradeBlockLevel()];case 3:return s.sent(),[4,this._blockManager.putToBlock(t,e)];case 4:s.sent(),s.label=5;case 5:s.trys.push([5,10,11,12]),n=i(this._indexers),r=n.next(),s.label=6;case 6:return r.done?[3,9]:[4,r.value.addItem(e)];case 7:s.sent(),s.label=8;case 8:return r=n.next(),[3,6];case 9:return[3,12];case 10:return o=s.sent(),a={error:o},[3,12];case 11:try{r&&!r.done&&(c=n.return)&&c.call(n)}finally{if(a)throw a.error}return[7];case 12:return[3,14];case 13:throw Ce.collectionInsertDuplicate;case 14:return[2]}}))}))},e.prototype._requestUpsert=function(e){return r(this,void 0,void 0,(function(){var t,n,r,o,a,c,u,l,h,d,f,_,v;return s(this,(function(s){switch(s.label){case 0:return t=e[this.keyName],[4,this._blockManager.getFromBlock(t)];case 1:return(n=s.sent())?[3,13]:[4,this._blockManager.putToBlock(t,e)];case 2:return s.sent()?[3,5]:[4,this._upgradeBlockLevel()];case 3:return s.sent(),[4,this._blockManager.putToBlock(t,e)];case 4:s.sent(),s.label=5;case 5:s.trys.push([5,10,11,12]),r=i(this._indexers),o=r.next(),s.label=6;case 6:return o.done?[3,9]:[4,(l=o.value).addItem(e)];case 7:s.sent(),s.label=8;case 8:return o=r.next(),[3,6];case 9:return[3,12];case 10:return a=s.sent(),d={error:a},[3,12];case 11:try{o&&!o.done&&(f=r.return)&&f.call(r)}finally{if(d)throw d.error}return[7];case 12:return[3,23];case 13:return[4,this._blockManager.putToBlock(t,e)];case 14:s.sent(),s.label=15;case 15:s.trys.push([15,21,22,23]),c=i(this._indexers),u=c.next(),s.label=16;case 16:return u.done?[3,20]:0===(l=u.value).diff(l.getColumnValues(n),l.getColumnValues(e))?[3,19]:[4,l.removeItem(n)];case 17:return s.sent(),[4,l.addItem(e)];case 18:s.sent(),s.label=19;case 19:return u=c.next(),[3,16];case 20:return[3,23];case 21:return h=s.sent(),_={error:h},[3,23];case 22:try{u&&!u.done&&(v=c.return)&&v.call(c)}finally{if(_)throw _.error}return[7];case 23:return[2]}}))}))},e.prototype._requestUpdate=function(e){return r(this,void 0,void 0,(function(){var t,n,r,o,a,c,u,l;return s(this,(function(s){switch(s.label){case 0:return t=e[this.keyName],[4,this._blockManager.getFromBlock(t)];case 1:return(n=s.sent())?[4,this._blockManager.putToBlock(t,e)]:[3,11];case 2:s.sent(),s.label=3;case 3:s.trys.push([3,9,10,11]),r=i(this._indexers),o=r.next(),s.label=4;case 4:return o.done?[3,8]:0===(a=o.value).diff(a.getColumnValues(n),a.getColumnValues(e))?[3,7]:[4,a.removeItem(n)];case 5:return s.sent(),[4,a.addItem(e)];case 6:s.sent(),s.label=7;case 7:return o=r.next(),[3,4];case 8:return[3,11];case 9:return c=s.sent(),u={error:c},[3,11];case 10:try{o&&!o.done&&(l=r.return)&&l.call(r)}finally{if(u)throw u.error}return[7];case 11:return[2]}}))}))},e.prototype._requestRemove=function(e){return r(this,void 0,void 0,(function(){var t,n,r,o,a,c;return s(this,(function(s){switch(s.label){case 0:return[4,this._blockManager.getFromBlock(e)];case 1:return(t=s.sent())?[4,this._blockManager.removeFromBlock(e)]:[3,10];case 2:s.sent(),s.label=3;case 3:s.trys.push([3,8,9,10]),n=i(this._indexers),r=n.next(),s.label=4;case 4:return r.done?[3,7]:[4,r.value.removeItem(t)];case 5:s.sent(),s.label=6;case 6:return r=n.next(),[3,4];case 7:return[3,10];case 8:return o=s.sent(),a={error:o},[3,10];case 9:try{r&&!r.done&&(c=n.return)&&c.call(n)}finally{if(a)throw a.error}return[7];case 10:return[2]}}))}))},e.prototype._requestClear=function(){return r(this,void 0,void 0,(function(){var e,t,n,r,o;return s(this,(function(s){switch(s.label){case 0:return[4,this._blockManager.clearAllBlocks()];case 1:s.sent(),s.label=2;case 2:s.trys.push([2,7,8,9]),e=i(this._indexers),t=e.next(),s.label=3;case 3:return t.done?[3,6]:[4,t.value.clear()];case 4:s.sent(),s.label=5;case 5:return t=e.next(),[3,3];case 6:return[3,9];case 7:return n=s.sent(),r={error:n},[3,9];case 8:try{t&&!t.done&&(o=e.return)&&o.call(e)}finally{if(r)throw r.error}return[7];case 9:return[2]}}))}))},e.prototype.getByKey=function(e){return r(this,void 0,void 0,(function(){var t,n;return s(this,(function(r){switch(r.label){case 0:return this.isReady?[4,this._mutex.lock()]:[3,6];case 1:r.sent(),r.label=2;case 2:return r.trys.push([2,4,,5]),[4,this._blockManager.getFromBlock(e)];case 3:return t=r.sent(),this._mutex.unlock(),[2,ke(t)];case 4:throw n=r.sent(),this._mutex.unlock(),n;case 5:return[3,7];case 6:throw Ce.collectionNotReady;case 7:return[2]}}))}))},e.prototype.query=function(e){return void 0===e&&(e={}),this.isReady?new je({condition:e.where,mutex:this._mutex,blockManager:this._blockManager,indexer:this._getIndexerBy(e.index),backward:!!e.backward}):null},e.prototype.insertOne=function(e){return r(this,void 0,void 0,(function(){var t;return s(this,(function(n){switch(n.label){case 0:return this.isReady?[4,this._mutex.lock()]:[3,8];case 1:n.sent(),n.label=2;case 2:if(n.trys.push([2,5,,7]),!this._hasPropertyOfKeyName(e))throw Ce.collectionKeyNotGiven;return[4,this._requestInsert(ke(e))];case 3:return n.sent(),[4,this._transaction.commit()];case 4:return n.sent(),this._mutex.unlock(),[2,e];case 5:return t=n.sent(),[4,this._transaction.clear()];case 6:throw n.sent(),this._mutex.unlock(),t;case 7:return[3,9];case 8:throw Ce.collectionNotReady;case 9:return[2]}}))}))},e.prototype.insertMany=function(e){return r(this,void 0,void 0,(function(){var t,n,r,o,a,c,u,l=this;return s(this,(function(s){switch(s.label){case 0:return this.isReady?[4,this._mutex.lock()]:[3,15];case 1:s.sent(),s.label=2;case 2:if(s.trys.push([2,12,,14]),e.some((function(e){return!l._hasPropertyOfKeyName(e)})))throw Ce.collectionKeyNotGiven;s.label=3;case 3:s.trys.push([3,8,9,10]),t=i(e),n=t.next(),s.label=4;case 4:return n.done?[3,7]:(r=n.value,[4,this._requestInsert(ke(r))]);case 5:s.sent(),s.label=6;case 6:return n=t.next(),[3,4];case 7:return[3,10];case 8:return o=s.sent(),c={error:o},[3,10];case 9:try{n&&!n.done&&(u=t.return)&&u.call(t)}finally{if(c)throw c.error}return[7];case 10:return[4,this._transaction.commit()];case 11:return s.sent(),this._mutex.unlock(),[2,e];case 12:return a=s.sent(),[4,this._transaction.clear()];case 13:throw s.sent(),this._mutex.unlock(),a;case 14:return[3,16];case 15:throw Ce.collectionNotReady;case 16:return[2]}}))}))},e.prototype.upsertOne=function(e){return r(this,void 0,void 0,(function(){var t;return s(this,(function(n){switch(n.label){case 0:return this.isReady?[4,this._mutex.lock()]:[3,8];case 1:n.sent(),n.label=2;case 2:if(n.trys.push([2,5,,7]),!this._hasPropertyOfKeyName(e))throw Ce.collectionKeyNotGiven;return[4,this._requestUpsert(ke(e))];case 3:return n.sent(),[4,this._transaction.commit()];case 4:return n.sent(),this._mutex.unlock(),[2,e];case 5:return t=n.sent(),[4,this._transaction.clear()];case 6:throw n.sent(),this._mutex.unlock(),t;case 7:return[3,9];case 8:throw Ce.collectionNotReady;case 9:return[2]}}))}))},e.prototype.upsertMany=function(e){return r(this,void 0,void 0,(function(){var t,n,r,o,a,c,u,l=this;return s(this,(function(s){switch(s.label){case 0:return this.isReady?[4,this._mutex.lock()]:[3,15];case 1:s.sent(),s.label=2;case 2:if(s.trys.push([2,12,,14]),e.some((function(e){return!l._hasPropertyOfKeyName(e)})))throw Ce.collectionKeyNotGiven;s.label=3;case 3:s.trys.push([3,8,9,10]),t=i(e),n=t.next(),s.label=4;case 4:return n.done?[3,7]:(r=n.value,[4,this._requestUpsert(ke(r))]);case 5:s.sent(),s.label=6;case 6:return n=t.next(),[3,4];case 7:return[3,10];case 8:return o=s.sent(),c={error:o},[3,10];case 9:try{n&&!n.done&&(u=t.return)&&u.call(t)}finally{if(c)throw c.error}return[7];case 10:return[4,this._transaction.commit()];case 11:return s.sent(),this._mutex.unlock(),[2,e];case 12:return a=s.sent(),[4,this._transaction.clear()];case 13:throw s.sent(),this._mutex.unlock(),a;case 14:return[3,16];case 15:throw Ce.collectionNotReady;case 16:return[2]}}))}))},e.prototype.update=function(e){return r(this,void 0,void 0,(function(){var t;return s(this,(function(n){switch(n.label){case 0:return this.isReady?[4,this._mutex.lock()]:[3,8];case 1:n.sent(),n.label=2;case 2:if(n.trys.push([2,5,,7]),!this._hasPropertyOfKeyName(e))throw Ce.collectionKeyNotGiven;return[4,this._requestUpdate(ke(e))];case 3:return n.sent(),[4,this._transaction.commit()];case 4:return n.sent(),this._mutex.unlock(),[2,e];case 5:return t=n.sent(),[4,this._transaction.clear()];case 6:throw n.sent(),this._mutex.unlock(),t;case 7:return[3,9];case 8:throw Ce.collectionNotReady;case 9:return[2]}}))}))},e.prototype.updateIf=function(e,t){return r(this,void 0,void 0,(function(){var n,o,a,c,u,l,h,d,f,_,v,m,p,y,E=this;return s(this,(function(b){switch(b.label){case 0:return this.isReady?[4,this._mutex.lock()]:[3,16];case 1:b.sent(),b.label=2;case 2:return b.trys.push([2,13,,15]),n=e.where,o=void 0===n?{}:n,a=e.index,c=void 0===a?null:a,u=e.backward,l=void 0!==u&&u,h=[],[4,new Fe({condition:o,blockManager:this._blockManager,backward:l,indexer:this._getIndexerBy(c)}).each((function(e){return r(E,void 0,void 0,(function(){var n,r;return s(this,(function(i){if(e.error)throw e.stop(),e.error;if(e.hasNext){if(n=e.nextValue,De(o,n)&&t.set){if("function"!=typeof t.set)for(r in t.set)n[r]=t.set[r];else t.set(n);h.push(n)}e.next()}else e.stop();return[2]}))}))}))];case 3:b.sent(),b.label=4;case 4:b.trys.push([4,9,10,11]),d=i(h),f=d.next(),b.label=5;case 5:return f.done?[3,8]:(_=f.value,[4,this._requestUpdate(ke(_))]);case 6:b.sent(),b.label=7;case 7:return f=d.next(),[3,5];case 8:return[3,11];case 9:return v=b.sent(),p={error:v},[3,11];case 10:try{f&&!f.done&&(y=d.return)&&y.call(d)}finally{if(p)throw p.error}return[7];case 11:return[4,this._transaction.commit()];case 12:return b.sent(),this._mutex.unlock(),[2,h];case 13:return m=b.sent(),[4,this._transaction.clear()];case 14:throw b.sent(),this._mutex.unlock(),m;case 15:return[3,17];case 16:throw this._transaction.clear(),Ce.collectionNotReady;case 17:return[2]}}))}))},e.prototype.remove=function(e){return r(this,void 0,void 0,(function(){var t;return s(this,(function(n){switch(n.label){case 0:return this.isReady?[4,this._mutex.lock()]:[3,8];case 1:n.sent(),n.label=2;case 2:return n.trys.push([2,5,,7]),[4,this._requestRemove(e)];case 3:return n.sent(),[4,this._transaction.commit()];case 4:return n.sent(),this._mutex.unlock(),[3,7];case 5:return t=n.sent(),[4,this._transaction.clear()];case 6:throw n.sent(),this._mutex.unlock(),t;case 7:return[3,9];case 8:throw Ce.collectionNotReady;case 9:return[2]}}))}))},e.prototype.removeIf=function(e){return r(this,void 0,void 0,(function(){var t,n,o,a,c,u,l,h,d,f,_,v,m,p,y=this;return s(this,(function(E){switch(E.label){case 0:return this.isReady?[4,this._mutex.lock()]:[3,15];case 1:E.sent(),E.label=2;case 2:return E.trys.push([2,13,,14]),t=e.where,n=void 0===t?{}:t,o=e.index,a=void 0===o?null:o,c=e.backward,u=void 0!==c&&c,l=[],[4,new Fe({condition:n,blockManager:this._blockManager,backward:u,indexer:this._getIndexerBy(a)}).each((function(e){return r(y,void 0,void 0,(function(){var t,r;return s(this,(function(i){if(e.error)throw e.stop(),e.error;return e.hasNext?(t=e.nextValue,De(n,t)&&(r=t[this.keyName],l.push(r)),e.next()):e.stop(),[2]}))}))}))];case 3:E.sent(),E.label=4;case 4:E.trys.push([4,9,10,11]),h=i(l),d=h.next(),E.label=5;case 5:return d.done?[3,8]:(f=d.value,[4,this._requestRemove(f)]);case 6:E.sent(),E.label=7;case 7:return d=h.next(),[3,5];case 8:return[3,11];case 9:return _=E.sent(),m={error:_},[3,11];case 10:try{d&&!d.done&&(p=h.return)&&p.call(h)}finally{if(m)throw m.error}return[7];case 11:return[4,this._transaction.commit()];case 12:return E.sent(),this._mutex.unlock(),[2,l];case 13:throw v=E.sent(),this._mutex.unlock(),v;case 14:return[3,16];case 15:throw this._transaction.clear(),Ce.collectionNotReady;case 16:return[2]}}))}))},e.prototype.clear=function(){return r(this,void 0,void 0,(function(){var e;return s(this,(function(t){switch(t.label){case 0:return this.isReady?[4,this._mutex.lock()]:[3,8];case 1:t.sent(),t.label=2;case 2:return t.trys.push([2,5,,7]),[4,this._requestClear()];case 3:return t.sent(),[4,this._transaction.commit()];case 4:return t.sent(),this._mutex.unlock(),[3,7];case 5:return e=t.sent(),[4,this._transaction.clear()];case 6:throw t.sent(),this._mutex.unlock(),e;case 7:return[3,9];case 8:throw Ce.collectionNotReady;case 9:return[2]}}))}))},e.prototype.getBlob=function(e){return r(this,void 0,void 0,(function(){return s(this,(function(t){switch(t.label){case 0:return[4,this._blobContainer.get(e)];case 1:return[2,t.sent()]}}))}))},e.prototype.saveBlob=function(e,t){return void 0===t&&(t=null),r(this,void 0,void 0,(function(){return s(this,(function(n){switch(n.label){case 0:return[4,this._blobContainer.save(e,t)];case 1:return[2,n.sent()]}}))}))},e.prototype.removeBlob=function(e){return r(this,void 0,void 0,(function(){return s(this,(function(t){switch(t.label){case 0:return[4,this._blobContainer.remove(e)];case 1:return t.sent(),[2]}}))}))},e.prototype.removeAllBlobs=function(){return r(this,void 0,void 0,(function(){return s(this,(function(e){switch(e.label){case 0:return[4,this._blobContainer.clear()];case 1:return e.sent(),[2]}}))}))},e}(),ot=function(){function e(e){var t,n,r;this.encryption=null!==(t=e.encryption)&&void 0!==t?t:w,this.itemSizeLimit=null!==(n=e.itemSizeLimit)&&void 0!==n?n:4194304,this.metadataBuffer=null!==(r=e.metadataBuffer)&&void 0!==r?r:256}return e.prototype._getRawKey=function(e,t){return void 0===t&&(t=""),"".concat(e).concat(t)},e.prototype._generateShardPostfixArray=function(e){return void 0===e&&(e=1),N([],I(Array(e).keys()),!1)},e.prototype._shardify=function(e){var t=this,n=e.key,r=e.value,i=JSON.stringify(this.encryption.encrypt(r)),s=Math.ceil(i.length/this.adjustedItemSizeLimit);return this._generateShardPostfixArray(s).map((function(e){var r={key:t._getRawKey(n,".".concat(e)),data:i.substring(e*t.adjustedItemSizeLimit,(e+1)*t.adjustedItemSizeLimit)};return 0===e&&(r.metadata={shards:s}),r}))},Object.defineProperty(e.prototype,"adjustedItemSizeLimit",{get:function(){return Math.max(this.itemSizeLimit-this.metadataBuffer,4)},enumerable:!1,configurable:!0}),e.prototype.usage=function(){return r(this,void 0,void 0,(function(){var e,t,n,r,o,a,c,u,l;return s(this,(function(s){switch(s.label){case 0:return e=0,[4,this._getAllRawKeys()];case 1:t=s.sent(),s.label=2;case 2:s.trys.push([2,7,8,9]),n=i(t),r=n.next(),s.label=3;case 3:return r.done?[3,6]:(o=r.value,[4,this._getRaw(o)]);case 4:(a=s.sent())&&(e+=JSON.stringify(a).length),s.label=5;case 5:return r=n.next(),[3,3];case 6:return[3,9];case 7:return c=s.sent(),u={error:c},[3,9];case 8:try{r&&!r.done&&(l=n.return)&&l.call(n)}finally{if(u)throw u.error}return[7];case 9:return[2,e]}}))}))},e.prototype.getAllKeys=function(){return r(this,void 0,void 0,(function(){return s(this,(function(e){switch(e.label){case 0:return[4,this._getAllRawKeys()];case 1:return[2,e.sent().filter((function(e){return e.endsWith(".0")})).map((function(e){return e.replace(/\.0$/,"")}))]}}))}))},e.prototype.get=function(e){return r(this,void 0,void 0,(function(){var t,n,i,o,a,c,u=this;return s(this,(function(l){switch(l.label){case 0:return t=this._getRawKey(e,".0"),[4,this._getRaw(t)];case 1:if(!(n=l.sent()))return[3,7];l.label=2;case 2:return l.trys.push([2,6,,7]),i=n.data,(null==(o=n.metadata)?void 0:o.shards)>1?[4,Promise.all(this._generateShardPostfixArray(null==o?void 0:o.shards).map((function(t){return r(u,void 0,void 0,(function(){var n,r;return s(this,(function(s){switch(s.label){case 0:return t>0?(n=this._getRawKey(e,".".concat(t)),[4,this._getRaw(n)]):[3,2];case 1:if(!(r=s.sent()))throw Ce.storeBrokenIntegrity;return[2,r.data];case 2:return[2,i]}}))}))})))]:[3,4];case 3:return c=l.sent(),[3,5];case 4:c=[i],l.label=5;case 5:return a=c,[2,this.encryption.decrypt(JSON.parse(a.join("")))];case 6:return l.sent(),[2,null];case 7:return[2,null]}}))}))},e.prototype.set=function(e){return r(this,void 0,void 0,(function(){var t;return s(this,(function(n){switch(n.label){case 0:return t=this._shardify(e),[4,this._setRaw(t)];case 1:return n.sent(),[2,o({},e.value)]}}))}))},e.prototype.setMany=function(e){return r(this,void 0,void 0,(function(){var t=this;return s(this,(function(n){switch(n.label){case 0:return[4,this._setRaw([].concat.apply([],N([],I(e.map((function(e){return t._shardify(e)}))),!1)))];case 1:return n.sent(),[2,e.map((function(e){return e.value}))]}}))}))},e.prototype.remove=function(e){return r(this,void 0,void 0,(function(){var t,n,r,i=this;return s(this,(function(s){switch(s.label){case 0:return t=this._getRawKey(e,".0"),[4,this._getRaw(t)];case 1:return(n=s.sent())?(r=n.metadata,[4,this._removeRaw(this._generateShardPostfixArray(null==r?void 0:r.shards).map((function(t){return i._getRawKey(e,".".concat(t))})))]):[3,3];case 2:return s.sent(),[2,!0];case 3:return[2,!1]}}))}))},e.prototype.removeMany=function(e){return r(this,void 0,void 0,(function(){var t,n,r,o,a,c,u,l,h,d=this;return s(this,(function(f){switch(f.label){case 0:t=[],n=function(e){var n,i,o;return s(this,(function(s){switch(s.label){case 0:return n=r._getRawKey(e,".0"),[4,r._getRaw(n)];case 1:return(i=s.sent())&&(o=i.metadata,t.push.apply(t,N([],I(r._generateShardPostfixArray(null==o?void 0:o.shards).map((function(t){return d._getRawKey(e,".".concat(t))}))),!1))),[2]}}))},r=this,f.label=1;case 1:f.trys.push([1,6,7,8]),o=i(e),a=o.next(),f.label=2;case 2:return a.done?[3,5]:(c=a.value,[5,n(c)]);case 3:f.sent(),f.label=4;case 4:return a=o.next(),[3,2];case 5:return[3,8];case 6:return u=f.sent(),l={error:u},[3,8];case 7:try{a&&!a.done&&(h=o.return)&&h.call(o)}finally{if(l)throw l.error}return[7];case 8:return t.length>0?[4,this._removeRaw(t)]:[3,10];case 9:f.sent(),f.label=10;case 10:return[2,e]}}))}))},e}(),at={},ct=function(e){function t(t){void 0===t&&(t={});var n,r=this;r=e.call(this,o(o({},t),{itemSizeLimit:null!==(n=t.itemSizeLimit)&&void 0!==n?n:4194304}))||this;var i=t.delay,s=void 0===i?1:i;return r.delay=s,r.observer={},r}return u(t,e),Object.defineProperty(t.prototype,"rawData",{get:function(){return at[this.dbname]},set:function(e){at[this.dbname]=e},enumerable:!1,configurable:!0}),t.prototype._getAllRawKeys=function(){return r(this,void 0,void 0,(function(){return s(this,(function(e){if(at[this.dbname])return[2,Object.keys(at[this.dbname])];throw Ce.storeNotAvailable}))}))},t.prototype._getRaw=function(e){return r(this,void 0,void 0,(function(){return s(this,(function(t){switch(t.label){case 0:return at[this.dbname]?[4,Re(this.delay)]:[3,2];case 1:return t.sent(),[2,at[this.dbname][e]?o({key:e},at[this.dbname][e]):null];case 2:throw Ce.storeNotAvailable}}))}))},t.prototype._setRaw=function(e){return r(this,void 0,void 0,(function(){var t,n,r,o,a,c,u,l;return s(this,(function(s){switch(s.label){case 0:return at[this.dbname]?[4,Re(this.delay)]:[3,2];case 1:s.sent();try{for(t=i(e),n=t.next();!n.done;n=t.next())r=n.value,o=r.key,a=r.data,c=r.metadata,at[this.dbname][o]=Object.freeze({data:a,metadata:c})}catch(e){u={error:e}}finally{try{n&&!n.done&&(l=t.return)&&l.call(t)}finally{if(u)throw u.error}}return[3,3];case 2:throw Ce.storeNotAvailable;case 3:return[2]}}))}))},t.prototype._removeRaw=function(e){return r(this,void 0,void 0,(function(){var t,n,r,o,a;return s(this,(function(s){switch(s.label){case 0:return at[this.dbname]?[4,Re(this.delay)]:[3,2];case 1:s.sent();try{for(t=i(e),n=t.next();!n.done;n=t.next())r=n.value,at[this.dbname][r]&&delete at[this.dbname][r]}catch(e){o={error:e}}finally{try{n&&!n.done&&(a=t.return)&&a.call(t)}finally{if(o)throw o.error}}return[3,3];case 2:throw Ce.storeNotAvailable;case 3:return[2]}}))}))},t.prototype.observe=function(e,t,n){var r=this;this.observer[e]||(this.observer[e]={}),t.forEach((function(t){return r.observer[e][t]=n}))},t.prototype.isAvailable=function(){return r(this,void 0,void 0,(function(){return s(this,(function(e){return[2,!0]}))}))},t.prototype.init=function(e){return r(this,void 0,void 0,(function(){return s(this,(function(t){return this.dbname=e,at[this.dbname]={},[2]}))}))},t.prototype.set=function(t){return r(this,void 0,void 0,(function(){var n;return s(this,(function(r){if(this.observer[t.key]&&"function"==typeof this.observer[t.key].set&&(n=this.observer[t.key].set()))throw n;return[2,e.prototype.set.call(this,t)]}))}))},t.prototype.setMany=function(t){return r(this,void 0,void 0,(function(){var n,r,o,a,c,u;return s(this,(function(s){try{for(n=i(t),r=n.next();!r.done;r=n.next())if(o=r.value,this.observer[o.key]&&"function"==typeof this.observer[o.key].set&&(a=this.observer[o.key].set()))throw a}catch(e){c={error:e}}finally{try{r&&!r.done&&(u=n.return)&&u.call(n)}finally{if(c)throw c.error}}return[2,e.prototype.setMany.call(this,t)]}))}))},t.prototype.clear=function(){return r(this,void 0,void 0,(function(){return s(this,(function(e){switch(e.label){case 0:return[4,Re(this.delay)];case 1:return e.sent(),at[this.dbname]={},[2]}}))}))},t}(ot),ut="NestDBStore",lt=function(e){function t(t){void 0===t&&(t={});var n,r=this;return(r=e.call(this,o(o({},t),{itemSizeLimit:null!==(n=t.itemSizeLimit)&&void 0!==n?n:104857600}))||this)._storeName=ut,r._window="undefined"!=typeof window?window:null,r._indexedDb=r._window?r._window.indexedDB||r._window.mozIndexedDB||r._window.webkitIndexedDB||r._window.msIndexedDB:null,r}return u(t,e),t.prototype._getObjectStore=function(e){return this._database.transaction(this._storeName,e).objectStore(this._storeName)},t.prototype._getAllRawKeys=function(){return r(this,void 0,void 0,(function(){var e=this;return s(this,(function(t){switch(t.label){case 0:return[4,new Promise((function(t,n){var r=e._getObjectStore("readonly").getAllKeys();r.addEventListener("success",(function(e){t(e.target.result)})),r.addEventListener("error",(function(e){return n(e.target.error)}))}))];case 1:return[2,t.sent()]}}))}))},t.prototype._getRaw=function(e){return r(this,void 0,void 0,(function(){var t=this;return s(this,(function(n){switch(n.label){case 0:return[4,new Promise((function(n,r){var i=t._getObjectStore("readonly").get(e);i.addEventListener("success",(function(e){var t;n(null===(t=null==e?void 0:e.target)||void 0===t?void 0:t.result)})),i.addEventListener("error",(function(e){return r(e.target.error)}))}))];case 1:return[2,n.sent()]}}))}))},t.prototype._setRaw=function(e){return r(this,void 0,void 0,(function(){var t;return s(this,(function(n){switch(n.label){case 0:return t=this._getObjectStore("readwrite"),[4,Promise.all(e.map((function(e){return new Promise((function(n,r){var i=t.put(e);i.addEventListener("success",(function(e){n(e.target.result)})),i.addEventListener("error",(function(){r("Failed to write.")}))}))})))];case 1:return n.sent(),[2]}}))}))},t.prototype._removeRaw=function(e){return r(this,void 0,void 0,(function(){var t;return s(this,(function(n){switch(n.label){case 0:return t=this._getObjectStore("readwrite"),[4,Promise.all(e.map((function(e){return new Promise((function(n,r){var i=t.delete(e);i.addEventListener("success",(function(){return n(e)})),i.addEventListener("error",(function(e){return r(e.target.error)}))}))})))];case 1:return n.sent(),[2]}}))}))},t.prototype.isAvailable=function(){return r(this,void 0,void 0,(function(){var e,t,n,r,i=this;return s(this,(function(s){switch(s.label){case 0:if(!((null==(e="undefined"!=typeof window?window:null)?void 0:e.indexedDB)||(null==e?void 0:e.mozIndexedDB)||(null==e?void 0:e.webkitIndexedDB)||(null==e?void 0:e.msIndexedDB)))return[3,4];s.label=1;case 1:return s.trys.push([1,3,,4]),this._indexedDb=e.indexedDB||e.mozIndexedDB||e.webkitIndexedDB||e.msIndexedDB,t="undefined"!=typeof document&&"undefined"!=typeof navigator,n=navigator.userAgent&&navigator.userAgent.includes("Firefox/")&&!navigator.userAgent.includes("Seamonkey/"),r=navigator.userAgent&&navigator.userAgent.includes("Edge/"),[4,new Promise((function(s,o){if(t)if(n){var a=i._indexedDb.open("_testMozilla");a.onerror=function(){return o("Private browsing mode.")},a.onsuccess=function(){return s()}}else r?(e.PointerEvent||e.MSPointerEvent)&&o("Private browsing mode."):s()}))];case 2:return s.sent(),[2,!0];case 3:return s.sent(),[2,!1];case 4:return[2,!1]}}))}))},t.prototype.init=function(e){return r(this,void 0,void 0,(function(){var t,n=this;return s(this,(function(r){switch(r.label){case 0:return this.dbname=e,[4,new Promise((function(e,t){if(n._window&&Y)if(Q){var r=n._indexedDb.open("_testMozilla");r.onerror=function(){return t(Ce.storeNotAvailableInPrivateBrowsing)},r.onsuccess=function(){return e()}}else Z?n._window.indexedDB||!n._window.PointerEvent&&!n._window.MSPointerEvent||t(Ce.storeNotAvailableInPrivateBrowsing):e();else t(Ce.storeNotAvailable)}))];case 1:return r.sent(),t=this,[4,new Promise((function(t,r){var i=n._indexedDb.open(e);i.addEventListener("upgradeneeded",(function(e){e.target.result.createObjectStore(ut,{keyPath:"key"})})),i.addEventListener("success",(function(e){return t(e.target.result)})),i.addEventListener("error",(function(e){return r(e.target.error)}))}))];case 2:return t._database=r.sent(),[2]}}))}))},t.prototype.clear=function(){return r(this,void 0,void 0,(function(){var e=this;return s(this,(function(t){switch(t.label){case 0:return[4,new Promise((function(t,n){var r=e._getObjectStore("readwrite").clear();r.addEventListener("success",(function(){return t()})),r.addEventListener("error",(function(e){return n(e.target.error)}))}))];case 1:return[2,t.sent()]}}))}))},t}(ot),ht=function(e){function t(t){var n=this,r=t.AsyncStorage,i=t.itemSizeLimit,s=void 0===i?6291456:i,a=A(t,["AsyncStorage","itemSizeLimit"]);return(n=e.call(this,o(o({},a),{itemSizeLimit:s}))||this)._asyncStorage=r,n}return u(t,e),t.prototype._isBelonging=function(e){return e.startsWith("".concat(this.dbname,"/"))},t.prototype._getActualKey=function(e){return"".concat(this.dbname,"/").concat(e)},t.prototype._getAllRawKeys=function(){return r(this,void 0,void 0,(function(){var e,t=this;return s(this,(function(n){switch(n.label){case 0:return[4,this._asyncStorage.getAllKeys()];case 1:return e=n.sent(),[2,e.filter((function(e){return t._isBelonging(e)})).map((function(e){return e.substring("".concat(t.dbname,"/").length)}))]}}))}))},t.prototype._getRaw=function(e){return r(this,void 0,void 0,(function(){var t;return s(this,(function(n){switch(n.label){case 0:return[4,this._asyncStorage.getItem(this._getActualKey(e))];case 1:return[2,(t=n.sent())?JSON.parse(t):null]}}))}))},t.prototype._setRaw=function(e){return r(this,void 0,void 0,(function(){var t,n,r,o,a,c,u;return s(this,(function(s){switch(s.label){case 0:t=[];try{for(n=i(e),r=n.next();!r.done;r=n.next())o=r.value,a=o.key,o.data.length<=this.adjustedItemSizeLimit&&t.push([this._getActualKey(a),JSON.stringify(o)])}catch(e){c={error:e}}finally{try{r&&!r.done&&(u=n.return)&&u.call(n)}finally{if(c)throw c.error}}return[4,this._asyncStorage.multiSet(t)];case 1:return s.sent(),[2]}}))}))},t.prototype._removeRaw=function(e){return r(this,void 0,void 0,(function(){var t=this;return s(this,(function(n){switch(n.label){case 0:return[4,this._asyncStorage.multiRemove(e.map((function(e){return t._getActualKey(e)})))];case 1:return n.sent(),[2]}}))}))},t.prototype.isAvailable=function(){return r(this,void 0,void 0,(function(){return s(this,(function(e){return[2,!!this._asyncStorage]}))}))},t.prototype.init=function(e){return r(this,void 0,void 0,(function(){return s(this,(function(t){return this.dbname=e,[2]}))}))},t.prototype.clear=function(){return r(this,void 0,void 0,(function(){var e;return s(this,(function(t){switch(t.label){case 0:return[4,this.getAllKeys()];case 1:return e=t.sent(),[4,this.removeMany(e)];case 2:return t.sent(),[2]}}))}))},t}(ot);!function(e){function t(t){var n,r=this;return(r=e.call(this,o(o({},t),{itemSizeLimit:null!==(n=t.itemSizeLimit)&&void 0!==n?n:6291456}))||this)._mmkv=t.MMKV,r}u(t,e),t.prototype._isBelonging=function(e){return e.startsWith("".concat(this.dbname,"/"))},t.prototype._getActualKey=function(e){return"".concat(this.dbname,"/").concat(e)},t.prototype._getAllRawKeys=function(){return r(this,void 0,void 0,(function(){var e,t=this;return s(this,(function(n){switch(n.label){case 0:return[4,this._mmkv.getAllKeys()];case 1:return e=n.sent(),[2,e.filter((function(e){return t._isBelonging(e)})).map((function(e){return e.substring("".concat(t.dbname,"/").length)}))]}}))}))},t.prototype._getRaw=function(e){return r(this,void 0,void 0,(function(){var t;return s(this,(function(n){switch(n.label){case 0:return[4,this._mmkv.getString(this._getActualKey(e))];case 1:return[2,(t=n.sent())?JSON.parse(t):null]}}))}))},t.prototype._setRaw=function(e){return r(this,void 0,void 0,(function(){var t,n,r,o,a,c;return s(this,(function(s){try{for(t=i(e),n=t.next();!n.done;n=t.next())r=n.value,o=r.key,r.data.length<=this.adjustedItemSizeLimit&&this._mmkv.set(this._getActualKey(o),JSON.stringify(r))}catch(e){a={error:e}}finally{try{n&&!n.done&&(c=t.return)&&c.call(t)}finally{if(a)throw a.error}}return[2]}))}))},t.prototype._removeRaw=function(e){return r(this,void 0,void 0,(function(){var t,n,r,o,a;return s(this,(function(s){try{for(t=i(e),n=t.next();!n.done;n=t.next())r=n.value,this._mmkv.delete(this._getActualKey(r))}catch(e){o={error:e}}finally{try{n&&!n.done&&(a=t.return)&&a.call(t)}finally{if(o)throw o.error}}return[2]}))}))},t.prototype.isAvailable=function(){return r(this,void 0,void 0,(function(){return s(this,(function(e){return[2,!!this._mmkv]}))}))},t.prototype.init=function(e){return r(this,void 0,void 0,(function(){return s(this,(function(t){return this.dbname=e,[2]}))}))},t.prototype.clear=function(){return r(this,void 0,void 0,(function(){var e;return s(this,(function(t){switch(t.label){case 0:return[4,this.getAllKeys()];case 1:return e=t.sent(),[4,this.removeMany(e)];case 2:return t.sent(),[2]}}))}))}}(ot);var dt,ft="[NESTDB]",_t=!0,vt=function(){function e(){}return e.off=function(){_t=!1},e.log=function(){for(var e=[],t=0;t0&&!this.customTypesFilter.includes(r.customType))return!1;if(this.senderUserIdsFilter&&this.senderUserIdsFilter.length>0){if(!(r instanceof B))return!1;if(!this.senderUserIdsFilter.includes(r.sender.userId))return!1}switch(this.replyType){case n.NONE:if(r.parentMessageId>0)return!1;break;case n.ONLY_REPLY_TO_CHANNEL:if(r instanceof B&&r.parentMessageId>0&&!r.replyToChannel)return!1}return!0},r}();!function(e){e.CHANNEL_LATEST="channel_latest",e.NEWEST_CHILD_MESSAGE="newest_child_message"}(j||(j={}));var W=function(e){switch(e){case j.CHANNEL_LATEST:return["channelUrl","-createdAt","-messageId"];case j.NEWEST_CHILD_MESSAGE:return["channelUrl","-parentMessageId","-createdAt","-messageId"]}},Y="undefined"!=typeof document&&"undefined"!=typeof navigator;Y&&navigator.userAgent&&navigator.userAgent.includes("Chrome/")&&navigator.userAgent.includes("Chromium/");var Q=Y&&navigator.userAgent&&navigator.userAgent.includes("Firefox/")&&!navigator.userAgent.includes("Seamonkey/");Y&&navigator.userAgent&&navigator.userAgent.includes("Safari/")&&!navigator.userAgent.includes("Chrome/")&&navigator.userAgent.includes("Chromium/"),Y&&navigator.userAgent&&(navigator.userAgent.includes("OPR/")||navigator.userAgent.includes("Opera/")),Y&&navigator.userAgent&&navigator.userAgent.includes("Trident/7.0");var J,X,Z=Y&&navigator.userAgent&&navigator.userAgent.includes("Edge/"),$=function(){var e=(new Date).getTime();return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,(function(t){var n=(e+16*Math.random())%16|0;return e=Math.floor(e/16),("x"===t?n:3&n|8).toString(16)}))};!function(e){e[e.PROCESSING=0]="PROCESSING",e[e.DONE=1]="DONE"}(J||(J={})),function(e){e.NEWNODE="newnode",e.REMOVENODE="removenode",e.CLAIM_HOST="claimhost",e.SYNC_HOST="synchost",e.REQUEST_LOCK="requestlock",e.ACQUIRE_LOCK="acquirelock",e.RELEASE_LOCK="releaselock"}(X||(X={}));var ee,te={},ne=function(){function e(e,t){void 0===t&&(t={});var n=this;return this._state=J.PROCESSING,this._hostId=null,this._queue=[],this._currentItem=null,this._activationTimeout=null,this._activationQueue=[],te[e]&&!t.forceCreate||(this.nodeId=$(),this.key=e,Y&&(t.startAsInvisible?this.registerNode():"visible"===document.visibilityState?this.claimHost():this.registerNode(),document.addEventListener("visibilitychange",(function(){"visible"===document.visibilityState&&n.claimHost()})),window.addEventListener("message",(function(e){var t,r,s=e.data,o=s.nodeId,a=s.requestId,c=s.key,u=s.op,l=s.data;if(o!==n.nodeId&&c===n.key)switch(u){case X.NEWNODE:n._sendSync();break;case X.CLAIM_HOST:n._sendSync(),n._hostId=o;break;case X.SYNC_HOST:if(!n.isInSync){n._activationTimeout&&clearTimeout(n._activationTimeout);var h=l,d=h.currentItemRequestId,f=h.queue,_=function(e){var t=n._queue.findIndex((function(t){return t.requestId===e.requestId}));t<0&&n._requestLock({nodeId:e.nodeId,requestId:e.requestId,key:n.key,op:X.REQUEST_LOCK,ts:e.ts})};try{for(var v=i(f),m=v.next();!m.done;m=v.next()){_(m.value)}}catch(e){t={error:e}}finally{try{m&&!m.done&&(r=v.return)&&r.call(v)}finally{if(t)throw t.error}}n._currentItem=n._queue.find((function(e){return e.requestId===d})),n._completeSync()}break;case X.REMOVENODE:n._queue=n._queue.filter((function(e){return e.nodeId!==s.nodeId})),n._currentItem&&n._currentItem.nodeId===s.nodeId&&(n._currentItem=null,n._acquire(n._queue[0]));break;case X.REQUEST_LOCK:n._requestLock(s);break;case X.ACQUIRE_LOCK:var p=n._queue.find((function(e){return e.requestId===a}));n._acquire(p);break;case X.RELEASE_LOCK:n._release(a)}})),window.addEventListener("beforeunload",(function(){n._send(X.REMOVENODE)}))),te[e]=this),te[e]}return Object.defineProperty(e.prototype,"locked",{get:function(){return!!this._currentItem},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"isHost",{get:function(){return this._hostId===this.nodeId},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"isInSync",{get:function(){return this._state==J.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:$(),key:this.key,op:e,data:null!==(r=t.data)&&void 0!==r?r:null,ts:Date.now()};return Y&&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(X.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(X.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(X.SYNC_HOST,{data:{currentItemRequestId:null===(e=this._currentItem)||void 0===e?void 0:e.requestId,queue:this._queue.map((function(e){return{nodeId:e.nodeId,requestId:e.requestId,ts:e.ts}}))}})},e.prototype._waitUntilSyncCompleted=function(){return r(this,void 0,void 0,(function(){var e=this;return s(this,(function(t){return this.isHost&&!this.isInSync?[2,new Promise((function(t){e._activationQueue.push(t)}))]:[2]}))}))},e.prototype._waitSync=function(){var e=this;this.isInSync||(this._activationTimeout=setTimeout((function(){e._completeSync()}),8))},e.prototype._completeSync=function(){this.isInSync||(this._state=J.DONE,this._activationQueue.forEach((function(e){return e()})),this._activationQueue=[])},e.prototype.registerNode=function(){this._send(X.NEWNODE),this._waitSync()},e.prototype.claimHost=function(){this._hostId=this.nodeId,this._send(X.CLAIM_HOST),this._waitSync()},e.prototype.lock=function(){return r(this,void 0,void 0,(function(){var e;return s(this,(function(t){switch(t.label){case 0:return[4,this._waitUntilSyncCompleted()];case 1:return t.sent(),e=this._send(X.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}(),re=o(o({},T),{scheduledAt:null}),ie=function(e){return C(e)&&a("number",e.scheduledAt,!0)},se=o(o({},S),{scheduledAt:null,file:null,fileUrl:null,fileName:null,mimeType:null,fileSize:null,thumbnailSizes:null,requireAuth:!1}),oe=function(e){return L(e)&&a("number",e.scheduledAt)&&(c(e.file)||a("string",e.fileUrl))&&a("string",e.fileName,!0)&&a("string",e.mimeType,!0)&&a("number",e.fileSize,!0)&&(null===e.thumbnailSizes||e.thumbnailSizes.every((function(e){return a("object",e)&&e.maxWidth>0&&e.maxHeight>0})))},ae="UnsentMessage",ce="reqId",ue={},le=function(e){function t(t,n){var r=n.sdkState,i=n.cacheContext,s=e.call(this,t)||this;return s._sdkState=r,s._cacheContext=i,ue[t]=s,s._mutex=new ne("unsendmessagecache.lock"),s}return u(t,e),t.of=function(e){return ue[e]},Object.defineProperty(t.prototype,"collection",{get:function(){var e=this._cacheContext.nestdb;return e&&e.collection(ae)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"localCacheEnabled",{get:function(){return this._cacheContext.localCacheEnabled&&!!this.collection},enumerable:!1,configurable:!0}),t.prototype._serialize=function(e){if(e.messageId>0)throw l.invalidParameters;var t,n=o({},e.serialize());return e instanceof H?(e.messageParams&&(n.messageParams=O(e.messageParams)),e.scheduledInfo&&e.scheduledInfo.scheduledMessageParams&&(n.scheduledInfo.scheduledMessageParams=(t=e.scheduledInfo.scheduledMessageParams,o(o({},O(t)),{scheduledAt:t.scheduledAt})))):e instanceof V&&(e.messageParams&&(n.messageParams=k(e.messageParams)),e.scheduledInfo&&e.scheduledInfo.scheduledMessageParams&&(n.scheduledInfo.scheduledMessageParams=function(e){return o(o({},k(e)),{scheduledAt:e.scheduledAt})}(e.scheduledInfo.scheduledMessageParams))),n},t.prototype._deserialize=function(e){return e?(e=o(o({},e),{messageId:parseInt(e.messageId)}),U.of(this._iid).buildMessageFromSerializedData(e)):null},t.prototype._deserializeWithMessageCreateParams=function(e){return r(this,void 0,void 0,(function(){var t,n,r,i,o,a;return s(this,(function(s){switch(s.label){case 0:return t=U.of(this._iid),n=this._deserialize(e),e.messageParams?n instanceof H?(r=e.messageParams,n.messageParams=t.buildUserMessageCreateParamsFromSerializedData(r,n),[3,4]):[3,1]:[3,4];case 1:return n instanceof V?(r=e.messageParams).fileKey&&"string"==typeof r.fileKey&&x(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 H?(o=e.scheduledInfo.scheduledMessageParams,n.scheduledInfo.scheduledMessageParams=t.buildScheduledUserMessageCreateParamsFromSerializedData(o,n),[3,8]):[3,5]:[3,8];case 5:return n instanceof V?(o=e.scheduledInfo.scheduledMessageParams).fileKey&&"string"==typeof o.fileKey&&x(o.fileType)?(a=o,[4,this.collection.getBlob(o.fileKey)]):[3,7]:[3,8];case 6:a.file=s.sent(),s.label=7;case 7:n.scheduledInfo.scheduledMessageParams=t.buildScheduledFileMessageCreateParamsFromSerializedData(o,n),s.label=8;case 8:return[2,n]}}))}))},t.prototype.get=function(e){return r(this,void 0,void 0,(function(){var t;return s(this,(function(n){switch(n.label){case 0:return this.localCacheEnabled?[4,this.collection.getByKey("".concat(e))]:[3,2];case 1:if(t=n.sent())return[2,this._deserializeWithMessageCreateParams(t)];n.label=2;case 2:return[2,null]}}))}))},t.prototype.fetch=function(e){var t=e.channelUrl,n=void 0===t?null:t,i=e.filter,o=void 0===i?new z:i,a=e.order,c=void 0===a?j.CHANNEL_LATEST:a,u=e.sendingStatus,l=void 0===u?null:u,h=e.backward,d=void 0!==h&&h,f=e.parentMessageId,_=void 0===f?null:f;return r(this,void 0,void 0,(function(){var e,t,i,a,u=this;return s(this,(function(h){switch(h.label){case 0:return this.localCacheEnabled?(e=W(c),t={"/where":function(e){return!!(c!==j.NEWEST_CHILD_MESSAGE||_&&0!==e.parentMessageId&&e.parentMessageId===_)&&o.match(u._deserialize(e))}},n&&(t.channelUrl=n),l&&(t.sendingStatus=l),i={where:t,index:e,backward:d},[4,this.collection.query(i)]):[3,3];case 1:return[4,h.sent().fetch({})];case 2:return a=h.sent(),[2,Promise.all(a.map((function(e){return r(u,void 0,void 0,(function(){return s(this,(function(t){switch(t.label){case 0:return[4,this._deserializeWithMessageCreateParams(e)];case 1:return[2,t.sent()]}}))}))})))];case 3:return[2,[]]}}))}))},t.prototype.getAllChildMessages=function(e,t){return void 0===t&&(t=new z),r(this,void 0,void 0,(function(){return s(this,(function(n){switch(n.label){case 0:return[4,this.fetch({filter:t,order:j.NEWEST_CHILD_MESSAGE,channelUrl:e.channelUrl,backward:!1,parentMessageId:e.messageId})];case 1:return[2,n.sent()]}}))}))},t.prototype.upsert=function(e){return r(this,void 0,void 0,(function(){var t=this;return s(this,(function(n){switch(n.label){case 0:return this.localCacheEnabled?[4,Promise.all(e.map((function(e){return r(t,void 0,void 0,(function(){var t;return s(this,(function(n){switch(n.label){case 0:return e instanceof V?[4,this._mutex.lock()]:[3,4];case 1:return n.sent(),[4,this.saveBlob(e)];case 2:return n.sent(),[4,this._mutex.unlock()];case 3:n.sent(),n.label=4;case 4:return t=this._serialize(e),[4,this.collection.upsertOne(t)];case 5:return n.sent(),[2]}}))}))})))]:[3,2];case 1:n.sent(),n.label=2;case 2:return[2]}}))}))},t.prototype.upsertChildMessages=function(e){return r(this,void 0,void 0,(function(){var t=this;return s(this,(function(n){switch(n.label){case 0:return this.localCacheEnabled?[4,Promise.all(e.map((function(e){return r(t,void 0,void 0,(function(){var t,n;return s(this,(function(r){switch(r.label){case 0:return t=[],(null===(n=e.threadInfo)||void 0===n?void 0:n.replyCount)>0?[4,this.getAllChildMessages(e)]:[3,2];case 1:t=r.sent(),r.label=2;case 2:return t.length>0?(t.forEach((function(t){return t.applyParentMessage(e)})),[4,this.upsert(t)]):[3,4];case 3:r.sent(),r.label=4;case 4:return[2]}}))}))})))]:[3,2];case 1:n.sent(),n.label=2;case 2:return[2]}}))}))},t.prototype.remove=function(e){return r(this,void 0,void 0,(function(){var t,n,r,o,a,c;return s(this,(function(s){switch(s.label){case 0:if(!this.localCacheEnabled)return[3,8];s.label=1;case 1:s.trys.push([1,6,7,8]),t=i(e),n=t.next(),s.label=2;case 2:return n.done?[3,5]:(r=n.value,[4,this.collection.remove(r)]);case 3:s.sent(),s.label=4;case 4:return n=t.next(),[3,2];case 5:return[3,8];case 6:return o=s.sent(),a={error:o},[3,8];case 7:try{n&&!n.done&&(c=t.return)&&c.call(t)}finally{if(a)throw a.error}return[7];case 8:return[2]}}))}))},t.prototype.removeMessagesOfChannel=function(e){return r(this,void 0,void 0,(function(){return s(this,(function(t){switch(t.label){case 0:return this.localCacheEnabled?[4,this.collection.removeIf({where:{channelUrl:e}})]:[3,2];case 1:t.sent(),t.label=2;case 2:return[2]}}))}))},t.prototype.clear=function(){return r(this,void 0,void 0,(function(){return s(this,(function(e){switch(e.label){case 0:return this.localCacheEnabled?[4,this.collection.clear()]:[3,2];case 1:e.sent(),e.label=2;case 2:return[2]}}))}))},t.prototype.saveBlob=function(e){return r(this,void 0,void 0,(function(){var t,n,r;return s(this,(function(i){switch(i.label){case 0:return e instanceof V?e.messageParams&&(t=e.messageParams).file&&D(t.file)?[4,this.collection.saveBlob(t.file,e.reqId)]:[3,2]:[3,4];case 1:r=i.sent(),t.fileKey=r,t.fileType=R.BLOB,i.label=2;case 2:return e.scheduledInfo&&e.scheduledInfo.scheduledMessageParams&&((n=e.scheduledInfo.scheduledMessageParams).file&&D(n.file))?[4,this.collection.saveBlob(n.file,e.reqId)]:[3,4];case 3:r=i.sent(),n.fileKey=r,n.fileType=R.BLOB,i.label=4;case 4:return[2]}}))}))},t}(h),he={},de=function(e){function t(t,n){var r=n.sdkState,i=n.cacheContext,s=n.unsentMessageCache,o=e.call(this,t)||this;return o._sdkState=r,o._cacheContext=i,o._unsentMessageCache=s,he[t]=o,o}return u(t,e),t.of=function(e){return he[e]},Object.defineProperty(t.prototype,"collection",{get:function(){var e=this._cacheContext.nestdb;return e?e.collection(P):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 o(o({},e.serialize()),{messageId:"".concat(e.messageId)})},t.prototype._deserialize=function(e){return e=o(o({},e),{messageId:parseInt(e.messageId)}),U.of(this._iid).buildMessageFromSerializedData(e)},t.prototype.get=function(e){return r(this,void 0,void 0,(function(){var t;return s(this,(function(n){switch(n.label){case 0:return this.localCacheEnabled?[4,this.collection.getByKey("".concat(e))]:[3,2];case 1:if(t=n.sent())return[2,this._deserialize(t)];n.label=2;case 2:return[2,null]}}))}))},t.prototype.fetch=function(e){var t=e.channelUrl,n=e.token,i=e.limit,o=void 0===i?M:i,a=e.filter,c=void 0===a?new z:a,u=e.order,l=void 0===u?j.CHANNEL_LATEST:u,h=e.backward,d=void 0!==h&&h,f=e.parentMessageId,_=void 0===f?null:f,v=e.isPollOnly,m=void 0!==v&&v;return r(this,void 0,void 0,(function(){var e,i,a,u=this;return s(this,(function(h){switch(h.label){case 0:return this.localCacheEnabled?(e=W(l),i={where:{channelUrl:t,"/where":function(e){if(n)switch(l){case j.CHANNEL_LATEST:if(!d&&e.createdAt>n||d&&e.createdAt0?[4,this.getAllChildMessages(e)]:[3,2];case 1:t=r.sent(),r.label=2;case 2:return t.length>0?(t.forEach((function(t){return t.applyParentMessage(e)})),[4,this.upsert(t)]):[3,4];case 3:r.sent(),r.label=4;case 4:return[2]}}))}))})))]:[3,2];case 1:n.sent(),n.label=2;case 2:return[2]}}))}))},t.prototype.remove=function(e){return r(this,void 0,void 0,(function(){var t,n,r,o,a,c;return s(this,(function(s){switch(s.label){case 0:if(!this.localCacheEnabled)return[3,8];s.label=1;case 1:s.trys.push([1,6,7,8]),t=i(e),n=t.next(),s.label=2;case 2:return n.done?[3,5]:(r=n.value,[4,this.collection.remove("".concat(r))]);case 3:s.sent(),s.label=4;case 4:return n=t.next(),[3,2];case 5:return[3,8];case 6:return o=s.sent(),a={error:o},[3,8];case 7:try{n&&!n.done&&(c=t.return)&&c.call(t)}finally{if(a)throw a.error}return[7];case 8:return[2]}}))}))},t.prototype.removeMessagesOfChannel=function(e){return r(this,void 0,void 0,(function(){var t;return s(this,(function(n){switch(n.label){case 0:return this.localCacheEnabled?[4,this.collection.removeIf({where:{channelUrl:e},index:W(j.CHANNEL_LATEST)})]:[3,6];case 1:return n.sent(),[4,(t=this._cacheContext.preference).remove("sendbird:".concat(this._sdkState.userId,"@groupchannel/").concat(e,"/message/sync"))];case 2:return n.sent(),[4,t.remove("sendbird:".concat(this._sdkState.userId,"@groupchannel/").concat(e,"/message/sync.meta"))];case 3:return n.sent(),[4,t.remove("sendbird:".concat(this._sdkState.userId,"@groupchannel/").concat(e,"/message/changelogs"))];case 4:return n.sent(),[4,t.remove("sendbird:".concat(this._sdkState.userId,"@groupchannel/").concat(e,"/message/changelogs.meta"))];case 5:n.sent(),n.label=6;case 6:return[2]}}))}))},t.prototype.removeUnderOffset=function(e,t){return r(this,void 0,void 0,(function(){return s(this,(function(n){switch(n.label){case 0:return this.localCacheEnabled?[4,this.collection.removeIf({where:{channelUrl:e,createdAt:{"<":t}},index:W(j.CHANNEL_LATEST)})]:[3,2];case 1:n.sent(),n.label=2;case 2:return[2]}}))}))},t.prototype.clear=function(){return r(this,void 0,void 0,(function(){return s(this,(function(e){switch(e.label){case 0:return this.localCacheEnabled?[4,this.collection.clear()]:[3,2];case 1:e.sent(),e.label=2;case 2:return[2]}}))}))},t.prototype.countBetween=function(e,t,n){return r(this,void 0,void 0,(function(){var r,i=this;return s(this,(function(s){switch(s.label){case 0:return this.localCacheEnabled?(r=W(j.CHANNEL_LATEST),[4,this.collection.query({where:{channelUrl:e,"/where":function(e){var r=i._deserialize(e);return n.includes(r.createdAt)&&t.match(r)}},index:r}).count()]):[3,2];case 1:return[2,s.sent()];case 2:return[2,0]}}))}))},t.prototype.saveBlobs=function(e){return r(this,void 0,void 0,(function(){var t=this;return s(this,(function(n){switch(n.label){case 0:return[4,Promise.all(e.map((function(e){return r(t,void 0,void 0,(function(){var t,n;return s(this,(function(r){switch(r.label){case 0:return e instanceof V&&e.messageParams&&((t=e.messageParams).file&&D(t.file))?[4,this.collection.saveBlob(t.file,e.reqId)]:[3,2];case 1:n=r.sent(),t.fileKey=n,r.label=2;case 2:return[2]}}))}))})))];case 1:return n.sent(),[2]}}))}))},t.prototype._getGroupChannelPreferenceSize=function(e){return r(this,void 0,void 0,(function(){var t,n,r,i,o,a;return s(this,(function(s){switch(s.label){case 0:return t=0,[4,(n=this._cacheContext.preference).get("sendbird:".concat(this._sdkState.userId,"@groupchannel/").concat(e,"/message/sync"))];case 1:return r=s.sent(),[4,n.get("sendbird:".concat(this._sdkState.userId,"@groupchannel/").concat(e,"/message/sync.meta"))];case 2:return i=s.sent(),[4,n.get("sendbird:".concat(this._sdkState.userId,"@groupchannel/").concat(e,"/message/changelogs"))];case 3:return o=s.sent(),[4,n.get("sendbird:".concat(this._sdkState.userId,"@groupchannel/").concat(e,"/message/changelogs.meta"))];case 4:return a=s.sent(),r&&(t+=JSON.stringify(r).length),i&&(t+=JSON.stringify(i).length),o&&(t+=JSON.stringify(o).length),a&&(t+=JSON.stringify(a).length),[2,t]}}))}))},t}(h),fe=function(e){function t(t){var n=t.message,r=e.call(this)||this;return r.message=n,r}return u(t,e),t}(d),_e={},ve=function(){function e(e,t){var n=t.localCacheEnabled,r=t.dispatcher,i=t.sdkState,s=t.logger,o=this;this._iid=e,_e[e]=this,this._localCacheEnabled=n,this._isProcessingAutoResend=!1,this._autoResendQueue=[],this._dispatcher=r,this._logger=s,this._sdkState=i,this._localCacheEnabled&&r.on((function(e){if(e instanceof v)switch(e.stateType){case m.CONNECTED:o._isProcessingAutoResend||o.processAutoResendRegisteredPendingMessages().then((function(){return o._processNextAutoResend()}));break;case m.INTERNAL_DISCONNECTED:case m.EXTERNAL_DISCONNECTED:o._isProcessingAutoResend=!1}}))}return e.of=function(e){return _e[e]},e.prototype.processNonAutoResendRegisteredPendingMessages=function(){return r(this,void 0,void 0,(function(){var e,t,n,r,o,a;return s(this,(function(s){switch(s.label){case 0:return[4,this._fetchAllCachedPendingMessages()];case 1:e=s.sent();try{for(t=i(e),n=t.next();!n.done;n=t.next())0===(r=n.value).errorCode&&(this._logger.debug("cached pending message is not auto-resend registered. changing its sending status to failed: ",r.reqId),r.sendingStatus=f.FAILED,r.errorCode=p.ACK_TIMEOUT,this._dispatcher.dispatch(new y({messages:[r],source:E.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.processAutoResendRegisteredPendingMessages=function(){return r(this,void 0,void 0,(function(){var e,t,n,r,o,a,c,u;return s(this,(function(s){switch(s.label){case 0:return[4,this._fetchAllCachedPendingMessages()];case 1:e=s.sent();try{for(t=i(e),n=t.next();!n.done;n=t.next())(r=n.value).errorCode&&_(r.errorCode)&&(o=(new Date).getTime(),a=r.createdAt+2592e5,o<=a?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(a).toLocaleString()),r.sendingStatus=f.FAILED,this._dispatcher.dispatch(new y({messages:[r],source:E.LOCAL_MESSAGE_FAILED}))))}catch(e){c={error:e}}finally{try{n&&!n.done&&(u=t.return)&&u.call(t)}finally{if(c)throw c.error}}return[2]}}))}))},e.prototype.completeCurrentAndProcessNextAutoResend=function(e){if(this._localCacheEnabled&&(e.sendingStatus===f.SUCCEEDED||e.sendingStatus===f.FAILED&&!_(e.errorCode))){var t=this.indexOf(e);t>=0&&this._autoResendQueue.splice(t,1),0===t&&this._processNextAutoResend()}},e.prototype._fetchAllCachedPendingMessages=function(){return r(this,void 0,void 0,(function(){var e,t;return s(this,(function(n){switch(n.label){case 0:return(e=le.of(this._iid))?[4,e.fetch({sendingStatus:f.PENDING,backward:!0})]:[3,2];case 1:return t=n.sent(),[3,3];case 2:t=[],n.label=3;case 3:return[2,t]}}))}))},e.prototype.indexOf=function(e){return this._autoResendQueue.length>0?this._autoResendQueue.map((function(e){return e.reqId})).indexOf(e.reqId):-1},e.prototype._isNotInQueue=function(e){return-1===this._autoResendQueue.map((function(e){return e.reqId})).indexOf(e.reqId)},e.prototype._processNextAutoResend=function(){return r(this,void 0,void 0,(function(){var e;return s(this,(function(t){if(this._localCacheEnabled&&"foreground"===this._sdkState.appState)try{this._autoResendQueue.length>0?(this._isProcessingAutoResend||(this._logger.debug("auto-resend queue started."),this._isProcessingAutoResend=!0),e=this._autoResendQueue[0],this._dispatcher.dispatch(new fe({message:e})),this._logger.debug("processing auto-resend for message request id: ",e.reqId)):(this._logger.debug("auto-resend queue finished."),this._isProcessingAutoResend=!1)}catch(e){this._logger.warn("process auto-resend error: ",e),this._isProcessingAutoResend=!1}return[2]}))}))},e}();!function(e){e[e.USER_BLOCK=20001]="USER_BLOCK",e[e.USER_UNBLOCK=2e4]="USER_UNBLOCK",e[e.FRIEND_DISCOVERED=20900]="FRIEND_DISCOVERED"}(ee||(ee={}));var me,pe=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 b(e,r),blockee:new b(e,i)}},e.getDataAsFriendDiscoveredEvent=function(e,t){var n=t.data.friend_discoveries;return{friendDiscoveries:Array.isArray(n)?n.map((function(t){return new b(e,t)})):[]}},e}(),ye=function(e){function t(t,n){var r=n.userId,i=e.call(this)||this;return i._iid=t,i.userId=r,i}return u(t,e),t}(d);!function(e){e.UNKNOWN="UNKNOWN",e.EVENT_CHANNEL_CREATED="EVENT_CHANNEL_CREATED",e.EVENT_CHANNEL_UPDATED="EVENT_CHANNEL_UPDATED",e.EVENT_CHANNEL_DELETED="EVENT_CHANNEL_DELETED",e.EVENT_CHANNEL_READ="EVENT_CHANNEL_READ",e.EVENT_CHANNEL_DELIVERED="EVENT_CHANNEL_DELIVERED",e.EVENT_CHANNEL_INVITED="EVENT_CHANNEL_INVITED",e.EVENT_CHANNEL_JOINED="EVENT_CHANNEL_JOINED",e.EVENT_CHANNEL_LEFT="EVENT_CHANNEL_LEFT",e.EVENT_CHANNEL_ACCEPTED_INVITE="EVENT_CHANNEL_ACCEPTED_INVITE",e.EVENT_CHANNEL_DECLINED_INVITE="EVENT_CHANNEL_DECLINED_INVITE",e.EVENT_CHANNEL_OPERATOR_UPDATED="EVENT_CHANNEL_OPERATOR_UPDATED",e.EVENT_CHANNEL_MUTED="EVENT_CHANNEL_MUTED",e.EVENT_CHANNEL_UNMUTED="EVENT_CHANNEL_UNMUTED",e.EVENT_CHANNEL_FROZEN="EVENT_CHANNEL_FROZEN",e.EVENT_CHANNEL_UNFROZEN="EVENT_CHANNEL_UNFROZEN",e.EVENT_CHANNEL_HIDDEN="EVENT_CHANNEL_HIDDEN",e.EVENT_CHANNEL_UNHIDDEN="EVENT_CHANNEL_UNHIDDEN",e.EVENT_CHANNEL_RESET_HISTORY="EVENT_CHANNEL_RESET_HISTORY",e.EVENT_CHANNEL_TYPING_STATUS_UPDATE="EVENT_CHANNEL_TYPING_STATUS_UPDATE",e.EVENT_CHANNEL_MEMBER_COUNT_UPDATED="EVENT_CHANNEL_MEMBER_COUNT_UPDATED",e.EVENT_MESSAGE_SENT="EVENT_MESSAGE_SENT",e.EVENT_MESSAGE_RECEIVED="EVENT_MESSAGE_RECEIVED",e.EVENT_MESSAGE_UPDATED="EVENT_MESSAGE_UPDATED",e.EVENT_PINNED_MESSAGE_UPDATED="EVENT_PINNED_MESSAGE_UPDATED",e.REQUEST_CHANNEL="REQUEST_CHANNEL",e.REQUEST_CHANNEL_CHANGELOGS="REQUEST_CHANNEL_CHANGELOGS",e.REFRESH_CHANNEL="REFRESH_CHANNEL",e.CHANNEL_LASTACCESSEDAT_UPDATED="CHANNEL_LASTACCESSEDAT_UPDATED",e.SYNC_CHANNEL_BACKGROUND="SYNC_CHANNEL_BACKGROUND",e.SYNC_CHANNEL_CHANGELOGS="SYNC_CHANNEL_CHANGELOGS"}(me||(me={}));var Ee,be=function(e){return e.startsWith("EVENT_")||e===me.SYNC_CHANNEL_CHANGELOGS||e===me.REFRESH_CHANNEL},ge=function(e){function t(t){var n=t.channels,r=t.source,i=t.data,s=void 0===i?null:i,o=e.call(this)||this;return o.channels=n,o.source=r,o.data=s,o}return u(t,e),t}(d),Ne=function(e){function t(t){var n=t.channelUrls,r=t.source,i=e.call(this)||this;return i.channelUrls=n,i.source=r,i}return u(t,e),t}(d),Ie=function(e){function t(){return e.call(this)||this}return u(t,e),t}(d),we=function(e){function t(t,n,r){var i=e.call(this,t,"USEV",r)||this;return i.event=new pe(r),i}return u(t,e),t}(g),Ae={},Te=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,c=e.blockHashMultiplier,u=void 0===c?10:c,l=e.blockHashConstant,h=void 0===l?11:l,d=e.transactionApplyDelay,f=void 0===d?200:d,_=e.disableLogger,v=void 0!==_&&_;return Ae[t]||(this.itemSizeLimit=r,this.cacheLimit=s,this.blockHashBase=a,this.blockHashMultiplier=u,this.blockHashConstant=h,this.transactionApplyDelay=f,this.disableLogger=v,Ae[t]=this),Ae[t]}return e.get=function(e){return Ae[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"}(Ee||(Ee={}));var Oe,Ce=function(e){function t(n){var r=n.code,i=void 0===r?Ee.UNKNOWN_ERROR:r,s=n.message,o=void 0===s?"Unknown error occurred.":s,a=e.call(this,o)||this;return a.code=i,Object.setPrototypeOf(a,t.prototype),a}return u(t,e),Object.defineProperty(t,"storeNotDefined",{get:function(){return new t({code:Ee.STORE_NOT_DEFINED,message:"Store is not defined. Specify the store on NestDB()"})},enumerable:!1,configurable:!0}),Object.defineProperty(t,"storeNotAvailable",{get:function(){return new t({code:Ee.STORE_NOT_AVAILABLE,message:"Store is not available. Check your environment settings."})},enumerable:!1,configurable:!0}),Object.defineProperty(t,"storeNotAvailableInPrivateBrowsing",{get:function(){return new t({code:Ee.STORE_NOT_AVAILABLE_IN_PRIVATE_BROWSING,message:"Store is not available because it is in private browsing."})},enumerable:!1,configurable:!0}),Object.defineProperty(t,"storeIsFull",{get:function(){return new t({code:Ee.STORE_IS_FULL,message:"Store is full."})},enumerable:!1,configurable:!0}),Object.defineProperty(t,"storeKeyTypeIsInvalid",{get:function(){return new t({code:Ee.STORE_INVALID_KEY_TYPE,message:"Store key should be string type."})},enumerable:!1,configurable:!0}),Object.defineProperty(t,"storeBrokenIntegrity",{get:function(){return new t({code:Ee.STORE_BROKEN_INTEGRITY,message:"Data should be in a store but it does not. Integrity is broken."})},enumerable:!1,configurable:!0}),Object.defineProperty(t,"storeBrokenBlob",{get:function(){return new t({code:Ee.STORE_BROKEN_BLOB,message:"Data should be in a store but it does not. Blob data is broken."})},enumerable:!1,configurable:!0}),Object.defineProperty(t,"storeEncryptionInvalid",{get:function(){return new t({code:Ee.STORE_ENCRYPTION_INVALID,message:"Encryption algorithm has changed. All the store should reset."})},enumerable:!1,configurable:!0}),Object.defineProperty(t,"storeItemSizeExceeded",{get:function(){return new t({code:Ee.STORE_ITEM_SIZE_LIMIT_EXCEEDED,message:"The size of the item exceeds the limit that the store allows."})},enumerable:!1,configurable:!0}),Object.defineProperty(t,"storeReadFailed",{get:function(){return new t({code:Ee.STORE_READ_FAILED,message:"Failed to read from store."})},enumerable:!1,configurable:!0}),Object.defineProperty(t,"storeWriteFailed",{get:function(){return new t({code:Ee.STORE_WRITE_FAILED,message:"Failed to write to store."})},enumerable:!1,configurable:!0}),Object.defineProperty(t,"databaseSchemaNotOnUpgrade",{get:function(){return new t({code:Ee.DATABASE_SCHEMA_NOT_ON_UPGRADE,message:"Committing schema is not allowed when upgrade is not running."})},enumerable:!1,configurable:!0}),Object.defineProperty(t,"collectionNotReady",{get:function(){return new t({code:Ee.COLLECTION_NOT_READY,message:"Collection is not ready due to an error during initialization."})},enumerable:!1,configurable:!0}),Object.defineProperty(t,"collectionKeyNotMatch",{get:function(){return new t({code:Ee.COLLECTION_KEY_NOT_MATCH,message:"keyName of collection could not change."})},enumerable:!1,configurable:!0}),Object.defineProperty(t,"collectionQueryNotValid",{get:function(){return new t({code:Ee.COLLECTION_QUERY_NOT_VALID,message:"Query parameter is not a valid format."})},enumerable:!1,configurable:!0}),Object.defineProperty(t,"collectionInsertDuplicate",{get:function(){return new t({code:Ee.COLLECTION_INSERT_DUPLICATE,message:"The key already exists."})},enumerable:!1,configurable:!0}),Object.defineProperty(t,"collectionKeyNotFound",{get:function(){return new t({code:Ee.COLLECTION_KEY_NOT_FOUND,message:"The key is not found."})},enumerable:!1,configurable:!0}),Object.defineProperty(t,"collectionKeyNotGiven",{get:function(){return new t({code:Ee.COLLECTION_KEY_NOT_GIVEN,message:"The item should contain [keyName] property."})},enumerable:!1,configurable:!0}),Object.defineProperty(t,"collectionWriteFailed",{get:function(){return new t({code:Ee.COLLECTION_WRITE_FAILED,message:"Failed to write an item."})},enumerable:!1,configurable:!0}),Object.defineProperty(t,"collectionItemSizeExceeded",{get:function(){return new t({code:Ee.COLLECTION_ITEM_SIZE_LIMIT_EXCEEDED,message:"The size of the item exceeds the limit that a collection allows."})},enumerable:!1,configurable:!0}),Object.defineProperty(t,"indexTableIsRequired",{get:function(){return new t({code:Ee.INDEX_TABLE_IS_REQUIRED,message:"Index table is required."})},enumerable:!1,configurable:!0}),Object.defineProperty(t,"indexTypesNotMatch",{get:function(){return new t({code:Ee.INDEX_TYPE_NOT_MATCH,message:"Indexed column should have primitive type."})},enumerable:!1,configurable:!0}),Object.defineProperty(t,"compareTypesNotMatch",{get:function(){return new t({code:Ee.COMPARE_TYPE_NOT_MATCH,message:"Values to compare have different types."})},enumerable:!1,configurable:!0}),Object.defineProperty(t,"circularReferenceFound",{get:function(){return new t({code:Ee.CIRCULAR_REFERENCE_FOUND,message:"Cannot handle circular referenced object."})},enumerable:!1,configurable:!0}),t}(Error);!function(e){e.INIT="init",e.READY="ready",e.CLOSED="closed"}(Oe||(Oe={}));var Se,ke=function(e,t){if(void 0===t&&(t=new WeakMap),"object"==typeof e&&null!==e){if(t.has(e))throw Ce.circularReferenceFound;t.set(e,!0);var n=null;if(Array.isArray(e))n=e.map((function(e){return ke(e,t)}));else if(e instanceof RegExp)n=e;else if(e instanceof Date)n=e;else for(var r in n={},e)n[r]=ke(e[r],t);return t.delete(e),n}return e},Le=function(e,t){if(null==t)return 1;if(null==e)return-1;if(typeof e!=typeof t)throw Ce.compareTypesNotMatch;var n=0;switch(typeof e){case"boolean":case"number":n=e-t;break;case"string":n=e.localeCompare(t)}return n},xe=function(e,t){for(var n=0,r=0;r>>0)%t},Re=function(e){return new Promise((function(t){setTimeout((function(){return t()}),e)}))},De=function(e,t){if(!t)return!1;if("function"!=typeof e){for(var n in e){if(["/and","&&"].includes(n)){if(e[n].some((function(e){return!De(e,t)})))return!1}else if(["/or","||"].includes(n)){if(e[n].every((function(e){return!De(e,t)})))return!1}else if("/where"===n){if(!(0,e[n])(t))return!1}else{var r=n;if("object"==typeof e[r]){var i=e[r];for(var s in i)switch(s){case"/eq":case"=":if((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(!(Le(o,a)>0))return!1;break;case"/gte":case">=":o=t[r],a=i[s];if(!(Le(o,a)>=0))return!1;break;case"/lt":case"<":o=t[r],a=i[s];if(!(Le(o,a)<0))return!1;break;case"/lte":case"<=":o=t[r],a=i[s];if(!(Le(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)},Pe=function(){},Me=function(){return Promise.resolve()},Be=function(e){return e},He=function(e,t){t(null)};!function(e){e[e.FORWARD=0]="FORWARD",e[e.BACKWARD=1]="BACKWARD"}(Se||(Se={}));var Ve,Ue,Ke,qe=function(){function e(e){var t=e.initialPrevValue,n=void 0===t?null:t,r=e.initialNextValue,i=void 0===r?null:r,s=e.iterator,o=e.map,a=void 0===o?Be:o,c=e.backward,u=void 0===c?Me:c,l=e.forward,h=void 0===l?Me:l,d=e.complete,f=void 0===d?Pe:d;this._prevValue=n,this._nextValue=i,this._error=null,this._map=a,this._backward=u,this._forward=h,this._iterator=s,this._complete=f}return Object.defineProperty(e.prototype,"prevValue",{get:function(){return this._map(this._prevValue)},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"nextValue",{get:function(){return this._map(this._nextValue)},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"error",{get:function(){return this._error},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"hasPrevious",{get:function(){return!!this._prevValue},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"hasNext",{get:function(){return!!this._nextValue},enumerable:!1,configurable:!0}),e.prototype.prev=function(){return r(this,void 0,void 0,(function(){var e,t,n;return s(this,(function(r){switch(r.label){case 0:if(!this.hasPrevious)return[3,6];r.label=1;case 1:return r.trys.push([1,3,,4]),e=this._prevValue,t=this,[4,this._backward()];case 2:return t._prevValue=r.sent()||null,this._nextValue=e,[3,4];case 3:return n=r.sent(),this._error=n,[3,4];case 4:return[4,this._iterator(this)];case 5:return[2,r.sent()];case 6:this._complete(),r.label=7;case 7:return[2]}}))}))},e.prototype.next=function(){return r(this,void 0,void 0,(function(){var e,t,n;return s(this,(function(r){switch(r.label){case 0:if(!this.hasNext)return[3,6];r.label=1;case 1:return r.trys.push([1,3,,4]),e=this._nextValue,t=this,[4,this._forward()];case 2:return t._nextValue=r.sent()||null,this._prevValue=e,[3,4];case 3:return n=r.sent(),this._error=n,[3,4];case 4:return[4,this._iterator(this)];case 5:return[2,r.sent()];case 6:this._complete(),r.label=7;case 7:return[2]}}))}))},e.prototype.stop=function(){this._prevValue=null,this._nextValue=null,this._complete()},e}(),Fe=function(){function e(e){var t=e.condition,n=void 0===t?{}:t,r=e.backward,i=void 0!==r&&r,s=e.blockManager,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 c in this.condition[s])if(a.includes(c))for(var u=r;u>=0;u--)if(o*Le(this._indexer.origin[u].columnValues[i],this.condition[s][c])<=0){r=u;break}}else for(u=r;u>=0;u--)if(o*Le(this._indexer.origin[u].columnValues[i],this.condition[s])<=0){r=u;break}}return Math.min(r+1,this._indexer.origin.length-1)}var l=0;if("function"!=typeof this.condition)for(var h=function(r){var i=d._indexer.fields[r],s=1;if("-"===i[0]&&(i=i.slice(1),s=-1),d.condition[i])if("object"==typeof d.condition[i])Object.keys(d.condition[i]).forEach((function(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;i-1){var r=this._items[n];return t===Ke.PERSISTENT&&(r.state=Ue.PERSISTENT),t!==Ke.NO_CACHE&&this.put(r),r}return null},e.prototype.put=function(e){var t,n;if(this._limit>0){var r=this._items.map((function(e){return e.key})).indexOf(e.key);if(r>-1)Xe.includes(this._items[r].state)&&Xe.includes(e.state)?(this._items.splice(r,1),this._items.push(e)):(this._items[r].state=e.state,this._items[r].generation=e.generation,this._items[r].value=e.value);else{this._items.push(e);var s=this._items.filter((function(e){return e.state===Ue.VOLATILE})),o=s.length-this._limit;if(o>0){var a=[];try{for(var c=i(this._items),u=c.next();!u.done;u=c.next()){var l=u.value;l.state===Ue.VOLATILE&&o>0?o--:a.push(l)}}catch(e){t={error:e}}finally{try{u&&!u.done&&(n=c.return)&&n.call(c)}finally{if(t)throw t.error}}this._items=a}}}},e.prototype.remove=function(e){var t=this._items.map((function(e){return e.key})).indexOf(e);t>-1&&this._items.splice(t,1)},e.prototype.clearByCondition=function(e){this._items=this._items.filter((function(t){return!e(t)}))},e.prototype.clear=function(e){void 0===e&&(e=!1),this._items=e?[]:this._items.filter((function(e){return e.state!==Ue.VOLATILE}))},e}(),et=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(ze(e,t),"/trans.metadata")}(t,n),this.recordsetKey=function(e,t){return"".concat(ze(e,t),"/trans.recordset")}(t,n),this._store=r}return Object.defineProperty(e.prototype,"generation",{get:function(){return this._metadata?this._metadata.generation:0},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"requestCount",{get:function(){return this._requests.length},enumerable:!1,configurable:!0}),e.prototype._getReducedRecordset=function(e){return void 0===e&&(e=[]),r(this,void 0,void 0,(function(){var t;return s(this,(function(n){switch(n.label){case 0:return[4,this._store.get(this.recordsetKey)];case 1:return(t=n.sent()||[]).push.apply(t,N([],I(e),!1)),[2,this._reduceRecordSet(t)]}}))}))},e.prototype._reduceRecordSet=function(e){for(var t=[],n={},r=e.length-1;r>=0;r--){for(var i=e[r],s=[],o=i.requests.length-1;o>=0;o--){var a=i.requests[o],c=a.data;n[c.key]||(s.unshift(a),n[c.key]=!0)}s.length>0&&(i.requests=s,t.unshift(i))}return t},e.prototype._applyRecord=function(e,t){return r(this,void 0,void 0,(function(){var n,r,i,a,c,u,l,h,d;return s(this,(function(s){switch(s.label){case 0:n=$e.get(this.dbname),r=t.generation,i=t.requests,a=null,s.label=1;case 1:return s.trys.push([1,3,,4]),[4,this._store.setMany(i.map((function(e){return o(o({},e.data),{generation:r})})))];case 2:for(c=s.sent(),u=0;u0))return[3,4];for(t=[],n={},u=e.length-1;u>=0;u--)r=e[u],h=r.data,n[h.key]||(n[h.key]=!0,t.unshift(r));return i={generation:this.generation,requests:t},[4,this._getReducedRecordset([i])];case 1:return a=s.sent(),[4,this._store.set({key:this.recordsetKey,value:a,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(),c=$e.get(this.dbname),u=0;u0?(r=this.createBlockId(e,n),[4,t.find(this._store,r)]):[3,4];case 2:if((i=s.sent())&&(o=tt.createFromCacheItem(i),o.getItemByKey(e)))return[2,o];s.label=3;case 3:return n--,[3,1];case 4:return[2,null]}}))}))},e.prototype.getFromBlock=function(e){return r(this,void 0,void 0,(function(){var t;return s(this,(function(n){switch(n.label){case 0:return[4,this._findBlock(e)];case 1:return[2,(t=n.sent())?t.getItemByKey(e):null]}}))}))},e.prototype.putToBlock=function(e,t){return r(this,void 0,void 0,(function(){var n,r,i,o,a;return s(this,(function(s){switch(s.label){case 0:return n=Te.get(this.dbname),r=this.createBlockId(e),i=Math.floor(this._store.itemSizeLimit/n.itemSizeLimit),[4,$e.get(this.dbname).find(this._store,r)];case 1:return o=s.sent(),(a=o?tt.createFromCacheItem(o):new tt({blockId:r,keyName:this.keyName,items:[],limit:i})).add(t)?(this._transaction.requestWrite({key:a.blockId,value:a.serialize()}),[2,!0]):[2,!1]}}))}))},e.prototype.removeFromBlock=function(e){return r(this,void 0,void 0,(function(){var t;return s(this,(function(n){switch(n.label){case 0:return[4,this._findBlock(e)];case 1:return(t=n.sent())&&t.remove(e)?(this._transaction.requestWrite({key:t.blockId,value:t.serialize()}),[2,!0]):[2,!1]}}))}))},e.prototype.clearAllBlocks=function(){return r(this,void 0,void 0,(function(){var e,t,n;return s(this,(function(r){switch(r.label){case 0:return e=Ye(this.dbname,this.collectionName),[4,this._store.getAllKeys()];case 1:return t=r.sent(),n=t.filter((function(t){return t.startsWith(e)})),[4,this._store.removeMany(n)];case 2:return r.sent(),[4,this._transaction.clear()];case 3:return r.sent(),$e.get(this.dbname).clearByCondition((function(t){return t.key.startsWith(e)})),[2]}}))}))},e}(),rt={},it=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=[];var c=function(e,t,n){return"".concat(ze(e,t),"/index.").concat(n)}(t,n,i.join(">"));return rt[c]||(this.dbname=t,this.collectionName=n,this.keyName=r,this.fields=i,this.indexerKey=c,this._transaction=s,this._store=o,this._transaction.on(Ve.COMMIT,this.indexerKey,(function(){return a.commit()})),this._transaction.on(Ve.ERROR,this.indexerKey,(function(){return a.abort()}))),rt[c]}return e.createKey=function(e){return e.join(">")},e.parseKey=function(e){return e.split(">")},e.clearIndexerMap=function(){for(var e in rt)delete rt[e]},e.prototype._addItem=function(e){var t=e[this.keyName],n=this.getColumnValues(e),r=I(this.indexOf(n),2),i=r[0];return r[1]?!this._table[i].keys.includes(t)&&(this._table[i].keys.push(t),!0):(this._table.splice(i,0,{columnValues:n,keys:[t]}),!0)},e.prototype._removeItem=function(e){var t=e[this.keyName],n=this.getColumnValues(e),r=I(this.indexOf(n),2),i=r[0];if(r[1]){var s=this._table[i].keys.indexOf(t);if(s>-1)return this._table[i].keys.splice(s,1),0===this._table[i].keys.length&&this._table.splice(i,1),!0}return!1},Object.defineProperty(e.prototype,"origin",{get:function(){return this._origin},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"table",{get:function(){return this._table},enumerable:!1,configurable:!0}),e.prototype.getColumnValues=function(e){var t,n,r,s,o=[];try{for(var a=i(this.fields),c=a.next();!c.done;c=a.next()){var u=c.value;if("-"===u[0]&&(u=u.slice(1)),r=e[u],s=void 0,s=typeof r,null!==r&&"undefined"!==s&&"boolean"!==s&&"number"!==s&&"string"!==s)throw Ce.indexTypesNotMatch;o.push(e[u])}}catch(e){t={error:e}}finally{try{c&&!c.done&&(n=a.return)&&n.call(a)}finally{if(t)throw t.error}}return o},e.prototype.diff=function(e,t){for(var n in this.fields){var r="-"===this.fields[n][0]?-1:1,i=Le(e[n],t[n]);if(0!==i)return r*i}return 0},e.prototype.indexOf=function(e){if(this._table.length>0){for(var t=0,n=this._table.length-1;t<=n;){var r=Math.floor((t+n)/2),i=this.diff(e,this._table[r].columnValues);if(i>0)t=r+1;else{if(!(i<0))return[r,!0];n=r-1}}return[t,!1]}return[0,!1]},e.prototype.ensure=function(){return r(this,void 0,void 0,(function(){var e,t,n,r,o,a,c,u,l,h,d,f,_,v,m,p,y;return s(this,(function(s){switch(s.label){case 0:return[4,(e=$e.get(this.dbname)).find(this._store,this.indexerKey,Ke.PERSISTENT)];case 1:return(t=s.sent())?[3,11]:(n=Ye(this.dbname,this.collectionName),[4,this._store.getAllKeys()]);case 2:r=s.sent(),s.label=3;case 3:s.trys.push([3,8,9,10]),o=i(r),a=o.next(),s.label=4;case 4:return a.done?[3,7]:(c=a.value).startsWith(n)?[4,e.find(this._store,c,Ke.NO_CACHE)]:[3,6];case 5:u=s.sent(),l=tt.createFromCacheItem(u);try{for(p=void 0,h=i(l.items),d=h.next();!d.done;d=h.next())f=d.value,this._addItem(f)}catch(e){p={error:e}}finally{try{d&&!d.done&&(y=h.return)&&y.call(h)}finally{if(p)throw p.error}}s.label=6;case 6:return a=o.next(),[3,4];case 7:return[3,10];case 8:return _=s.sent(),v={error:_},[3,10];case 9:try{a&&!a.done&&(m=o.return)&&m.call(o)}finally{if(v)throw v.error}return[7];case 10:return this._transaction.requestWrite({key:this.indexerKey,value:this._table},{persistent:!0}),[3,12];case 11:this._origin=t.value,this._table=ke(this._origin),s.label=12;case 12:return rt[this.indexerKey]=this,[2]}}))}))},e.prototype.drop=function(){return r(this,void 0,void 0,(function(){return s(this,(function(e){switch(e.label){case 0:return $e.get(this.dbname).remove(this.indexerKey),[4,this._store.remove(this.indexerKey)];case 1:return e.sent(),delete rt[this.indexerKey],[2]}}))}))},e.prototype.addItem=function(e){return r(this,void 0,void 0,(function(){return s(this,(function(t){return this._addItem(e)&&this._transaction.requestWrite({key:this.indexerKey,value:this._table},{persistent:!0}),[2]}))}))},e.prototype.removeItem=function(e){return r(this,void 0,void 0,(function(){return s(this,(function(t){return this._removeItem(e)&&this._transaction.requestWrite({key:this.indexerKey,value:this._table},{persistent:!0}),[2]}))}))},e.prototype.clear=function(){return r(this,void 0,void 0,(function(){return s(this,(function(e){return this._table=[],this._transaction.requestWrite({key:this.indexerKey,value:this._table},{persistent:!0}),[2]}))}))},e.prototype.commit=function(){this._origin=this._table,this._table=ke(this._origin)},e.prototype.abort=function(){this._table=ke(this._origin)},e}(),st=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=Oe.INIT,this._metadata=null,this._indexers=[],this.dbname=t,this.name=n,this.keyName=r,this.indexes=N([[r]],I(s.filter((function(e){return it.createKey(e)!==a.keyName}))),!1),this._keyHash=i,this._store=o,this._mutex=new ne(function(e,t){return"".concat(ze(e,t),".lock")}(t,n)),this._blobContainer=new Je({dbname:t,collectionName:n,store:o}),this._transaction=new et({dbname:t,collectionName:n,store:o})}return e.metadataOf=function(e,t,n){return r(this,void 0,void 0,(function(){var r;return s(this,(function(i){switch(i.label){case 0:return r=We(e,t),[4,n.get(r)];case 1:return[2,i.sent()]}}))}))},Object.defineProperty(e.prototype,"state",{get:function(){return this._state},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"isReady",{get:function(){return this._state===Oe.READY},enumerable:!1,configurable:!0}),e.prototype.init=function(){return r(this,void 0,void 0,(function(){var t,n,r,o,a,c,u,l,h,d,f,_,v,m,p=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=Te.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 nt({dbname:this.dbname,collectionName:this.name,hashFunction:this._keyHash,metadata:this._metadata,transaction:this._transaction,store:this._store}),r=N([],I(this.indexes),!1),o=[],a=r.map((function(e){return it.createKey(e)})),c=n?n.indexes.map((function(e){return it.createKey(e)})):[];try{for(u=i(c),l=u.next();!l.done;l=u.next())h=l.value,a.includes(h)||o.push(it.parseKey(h))}catch(e){v={error:e}}finally{try{l&&!l.done&&(m=u.return)&&m.call(u)}finally{if(v)throw v.error}}return(d=[]).push.apply(d,N([],I(r.map((function(e){var t=new it({dbname:p.dbname,collectionName:p.name,keyName:p.keyName,fields:e,transaction:p._transaction,store:p._store});return p._indexers.push(t),t.ensure()}))),!1)),d.push.apply(d,N([],I(o.map((function(e){return new it({dbname:p.dbname,collectionName:p.name,keyName:p.keyName,fields:e,transaction:p._transaction,store:p._store}).drop()}))),!1)),[4,Promise.all(d)];case 5:return s.sent(),[4,this._transaction.commit()];case 6:return s.sent(),a.sort().join(",")===c.sort().join(",")?[3,8]:(f=We(this.dbname,this.name),this._metadata.indexes=r,[4,this._store.set({key:f,value:this._metadata,generation:1})]);case 7:s.sent(),s.label=8;case 8:return this._state=Oe.READY,this._mutex.unlock(),[3,10];case 9:throw _=s.sent(),this._mutex.unlock(),_;case 10:return[2]}}))}))},e.prototype.close=function(){this._state=Oe.CLOSED},e.prototype._hasPropertyOfKeyName=function(e){var t=e[this.keyName];return"string"==typeof t&&!!t},e.prototype._getIndexerBy=function(e){var t,n;void 0===e&&(e=null),e||(e=[this.keyName]);var r=it.createKey(e);try{for(var s=i(this._indexers),o=s.next();!o.done;o=s.next()){var a=o.value;if(r===it.createKey(a.fields))return a}}catch(e){t={error:e}}finally{try{o&&!o.done&&(n=s.return)&&n.call(s)}finally{if(t)throw t.error}}return null},e.prototype._upgradeBlockLevel=function(){return r(this,void 0,void 0,(function(){var e;return s(this,(function(t){switch(t.label){case 0:return e=We(this.dbname,this.name),this._metadata.blockLevel++,[4,this._store.set({key:e,value:this._metadata,generation:1})];case 1:return t.sent(),[2]}}))}))},e.prototype._requestInsert=function(e){return r(this,void 0,void 0,(function(){var t,n,r,o,a,c;return s(this,(function(s){switch(s.label){case 0:return t=e[this.keyName],[4,this._blockManager.getFromBlock(t)];case 1:return s.sent()?[3,13]:[4,this._blockManager.putToBlock(t,e)];case 2:return s.sent()?[3,5]:[4,this._upgradeBlockLevel()];case 3:return s.sent(),[4,this._blockManager.putToBlock(t,e)];case 4:s.sent(),s.label=5;case 5:s.trys.push([5,10,11,12]),n=i(this._indexers),r=n.next(),s.label=6;case 6:return r.done?[3,9]:[4,r.value.addItem(e)];case 7:s.sent(),s.label=8;case 8:return r=n.next(),[3,6];case 9:return[3,12];case 10:return o=s.sent(),a={error:o},[3,12];case 11:try{r&&!r.done&&(c=n.return)&&c.call(n)}finally{if(a)throw a.error}return[7];case 12:return[3,14];case 13:throw Ce.collectionInsertDuplicate;case 14:return[2]}}))}))},e.prototype._requestUpsert=function(e){return r(this,void 0,void 0,(function(){var t,n,r,o,a,c,u,l,h,d,f,_,v;return s(this,(function(s){switch(s.label){case 0:return t=e[this.keyName],[4,this._blockManager.getFromBlock(t)];case 1:return(n=s.sent())?[3,13]:[4,this._blockManager.putToBlock(t,e)];case 2:return s.sent()?[3,5]:[4,this._upgradeBlockLevel()];case 3:return s.sent(),[4,this._blockManager.putToBlock(t,e)];case 4:s.sent(),s.label=5;case 5:s.trys.push([5,10,11,12]),r=i(this._indexers),o=r.next(),s.label=6;case 6:return o.done?[3,9]:[4,(l=o.value).addItem(e)];case 7:s.sent(),s.label=8;case 8:return o=r.next(),[3,6];case 9:return[3,12];case 10:return a=s.sent(),d={error:a},[3,12];case 11:try{o&&!o.done&&(f=r.return)&&f.call(r)}finally{if(d)throw d.error}return[7];case 12:return[3,23];case 13:return[4,this._blockManager.putToBlock(t,e)];case 14:s.sent(),s.label=15;case 15:s.trys.push([15,21,22,23]),c=i(this._indexers),u=c.next(),s.label=16;case 16:return u.done?[3,20]:0===(l=u.value).diff(l.getColumnValues(n),l.getColumnValues(e))?[3,19]:[4,l.removeItem(n)];case 17:return s.sent(),[4,l.addItem(e)];case 18:s.sent(),s.label=19;case 19:return u=c.next(),[3,16];case 20:return[3,23];case 21:return h=s.sent(),_={error:h},[3,23];case 22:try{u&&!u.done&&(v=c.return)&&v.call(c)}finally{if(_)throw _.error}return[7];case 23:return[2]}}))}))},e.prototype._requestUpdate=function(e){return r(this,void 0,void 0,(function(){var t,n,r,o,a,c,u,l;return s(this,(function(s){switch(s.label){case 0:return t=e[this.keyName],[4,this._blockManager.getFromBlock(t)];case 1:return(n=s.sent())?[4,this._blockManager.putToBlock(t,e)]:[3,11];case 2:s.sent(),s.label=3;case 3:s.trys.push([3,9,10,11]),r=i(this._indexers),o=r.next(),s.label=4;case 4:return o.done?[3,8]:0===(a=o.value).diff(a.getColumnValues(n),a.getColumnValues(e))?[3,7]:[4,a.removeItem(n)];case 5:return s.sent(),[4,a.addItem(e)];case 6:s.sent(),s.label=7;case 7:return o=r.next(),[3,4];case 8:return[3,11];case 9:return c=s.sent(),u={error:c},[3,11];case 10:try{o&&!o.done&&(l=r.return)&&l.call(r)}finally{if(u)throw u.error}return[7];case 11:return[2]}}))}))},e.prototype._requestRemove=function(e){return r(this,void 0,void 0,(function(){var t,n,r,o,a,c;return s(this,(function(s){switch(s.label){case 0:return[4,this._blockManager.getFromBlock(e)];case 1:return(t=s.sent())?[4,this._blockManager.removeFromBlock(e)]:[3,10];case 2:s.sent(),s.label=3;case 3:s.trys.push([3,8,9,10]),n=i(this._indexers),r=n.next(),s.label=4;case 4:return r.done?[3,7]:[4,r.value.removeItem(t)];case 5:s.sent(),s.label=6;case 6:return r=n.next(),[3,4];case 7:return[3,10];case 8:return o=s.sent(),a={error:o},[3,10];case 9:try{r&&!r.done&&(c=n.return)&&c.call(n)}finally{if(a)throw a.error}return[7];case 10:return[2]}}))}))},e.prototype._requestClear=function(){return r(this,void 0,void 0,(function(){var e,t,n,r,o;return s(this,(function(s){switch(s.label){case 0:return[4,this._blockManager.clearAllBlocks()];case 1:s.sent(),s.label=2;case 2:s.trys.push([2,7,8,9]),e=i(this._indexers),t=e.next(),s.label=3;case 3:return t.done?[3,6]:[4,t.value.clear()];case 4:s.sent(),s.label=5;case 5:return t=e.next(),[3,3];case 6:return[3,9];case 7:return n=s.sent(),r={error:n},[3,9];case 8:try{t&&!t.done&&(o=e.return)&&o.call(e)}finally{if(r)throw r.error}return[7];case 9:return[2]}}))}))},e.prototype.getByKey=function(e){return r(this,void 0,void 0,(function(){var t,n;return s(this,(function(r){switch(r.label){case 0:return this.isReady?[4,this._mutex.lock()]:[3,6];case 1:r.sent(),r.label=2;case 2:return r.trys.push([2,4,,5]),[4,this._blockManager.getFromBlock(e)];case 3:return t=r.sent(),this._mutex.unlock(),[2,ke(t)];case 4:throw n=r.sent(),this._mutex.unlock(),n;case 5:return[3,7];case 6:throw Ce.collectionNotReady;case 7:return[2]}}))}))},e.prototype.query=function(e){return void 0===e&&(e={}),this.isReady?new je({condition:e.where,mutex:this._mutex,blockManager:this._blockManager,indexer:this._getIndexerBy(e.index),backward:!!e.backward}):null},e.prototype.insertOne=function(e){return r(this,void 0,void 0,(function(){var t;return s(this,(function(n){switch(n.label){case 0:return this.isReady?[4,this._mutex.lock()]:[3,8];case 1:n.sent(),n.label=2;case 2:if(n.trys.push([2,5,,7]),!this._hasPropertyOfKeyName(e))throw Ce.collectionKeyNotGiven;return[4,this._requestInsert(ke(e))];case 3:return n.sent(),[4,this._transaction.commit()];case 4:return n.sent(),this._mutex.unlock(),[2,e];case 5:return t=n.sent(),[4,this._transaction.clear()];case 6:throw n.sent(),this._mutex.unlock(),t;case 7:return[3,9];case 8:throw Ce.collectionNotReady;case 9:return[2]}}))}))},e.prototype.insertMany=function(e){return r(this,void 0,void 0,(function(){var t,n,r,o,a,c,u,l=this;return s(this,(function(s){switch(s.label){case 0:return this.isReady?[4,this._mutex.lock()]:[3,15];case 1:s.sent(),s.label=2;case 2:if(s.trys.push([2,12,,14]),e.some((function(e){return!l._hasPropertyOfKeyName(e)})))throw Ce.collectionKeyNotGiven;s.label=3;case 3:s.trys.push([3,8,9,10]),t=i(e),n=t.next(),s.label=4;case 4:return n.done?[3,7]:(r=n.value,[4,this._requestInsert(ke(r))]);case 5:s.sent(),s.label=6;case 6:return n=t.next(),[3,4];case 7:return[3,10];case 8:return o=s.sent(),c={error:o},[3,10];case 9:try{n&&!n.done&&(u=t.return)&&u.call(t)}finally{if(c)throw c.error}return[7];case 10:return[4,this._transaction.commit()];case 11:return s.sent(),this._mutex.unlock(),[2,e];case 12:return a=s.sent(),[4,this._transaction.clear()];case 13:throw s.sent(),this._mutex.unlock(),a;case 14:return[3,16];case 15:throw Ce.collectionNotReady;case 16:return[2]}}))}))},e.prototype.upsertOne=function(e){return r(this,void 0,void 0,(function(){var t;return s(this,(function(n){switch(n.label){case 0:return this.isReady?[4,this._mutex.lock()]:[3,8];case 1:n.sent(),n.label=2;case 2:if(n.trys.push([2,5,,7]),!this._hasPropertyOfKeyName(e))throw Ce.collectionKeyNotGiven;return[4,this._requestUpsert(ke(e))];case 3:return n.sent(),[4,this._transaction.commit()];case 4:return n.sent(),this._mutex.unlock(),[2,e];case 5:return t=n.sent(),[4,this._transaction.clear()];case 6:throw n.sent(),this._mutex.unlock(),t;case 7:return[3,9];case 8:throw Ce.collectionNotReady;case 9:return[2]}}))}))},e.prototype.upsertMany=function(e){return r(this,void 0,void 0,(function(){var t,n,r,o,a,c,u,l=this;return s(this,(function(s){switch(s.label){case 0:return this.isReady?[4,this._mutex.lock()]:[3,15];case 1:s.sent(),s.label=2;case 2:if(s.trys.push([2,12,,14]),e.some((function(e){return!l._hasPropertyOfKeyName(e)})))throw Ce.collectionKeyNotGiven;s.label=3;case 3:s.trys.push([3,8,9,10]),t=i(e),n=t.next(),s.label=4;case 4:return n.done?[3,7]:(r=n.value,[4,this._requestUpsert(ke(r))]);case 5:s.sent(),s.label=6;case 6:return n=t.next(),[3,4];case 7:return[3,10];case 8:return o=s.sent(),c={error:o},[3,10];case 9:try{n&&!n.done&&(u=t.return)&&u.call(t)}finally{if(c)throw c.error}return[7];case 10:return[4,this._transaction.commit()];case 11:return s.sent(),this._mutex.unlock(),[2,e];case 12:return a=s.sent(),[4,this._transaction.clear()];case 13:throw s.sent(),this._mutex.unlock(),a;case 14:return[3,16];case 15:throw Ce.collectionNotReady;case 16:return[2]}}))}))},e.prototype.update=function(e){return r(this,void 0,void 0,(function(){var t;return s(this,(function(n){switch(n.label){case 0:return this.isReady?[4,this._mutex.lock()]:[3,8];case 1:n.sent(),n.label=2;case 2:if(n.trys.push([2,5,,7]),!this._hasPropertyOfKeyName(e))throw Ce.collectionKeyNotGiven;return[4,this._requestUpdate(ke(e))];case 3:return n.sent(),[4,this._transaction.commit()];case 4:return n.sent(),this._mutex.unlock(),[2,e];case 5:return t=n.sent(),[4,this._transaction.clear()];case 6:throw n.sent(),this._mutex.unlock(),t;case 7:return[3,9];case 8:throw Ce.collectionNotReady;case 9:return[2]}}))}))},e.prototype.updateIf=function(e,t){return r(this,void 0,void 0,(function(){var n,o,a,c,u,l,h,d,f,_,v,m,p,y,E=this;return s(this,(function(b){switch(b.label){case 0:return this.isReady?[4,this._mutex.lock()]:[3,16];case 1:b.sent(),b.label=2;case 2:return b.trys.push([2,13,,15]),n=e.where,o=void 0===n?{}:n,a=e.index,c=void 0===a?null:a,u=e.backward,l=void 0!==u&&u,h=[],[4,new Fe({condition:o,blockManager:this._blockManager,backward:l,indexer:this._getIndexerBy(c)}).each((function(e){return r(E,void 0,void 0,(function(){var n,r;return s(this,(function(i){if(e.error)throw e.stop(),e.error;if(e.hasNext){if(n=e.nextValue,De(o,n)&&t.set){if("function"!=typeof t.set)for(r in t.set)n[r]=t.set[r];else t.set(n);h.push(n)}e.next()}else e.stop();return[2]}))}))}))];case 3:b.sent(),b.label=4;case 4:b.trys.push([4,9,10,11]),d=i(h),f=d.next(),b.label=5;case 5:return f.done?[3,8]:(_=f.value,[4,this._requestUpdate(ke(_))]);case 6:b.sent(),b.label=7;case 7:return f=d.next(),[3,5];case 8:return[3,11];case 9:return v=b.sent(),p={error:v},[3,11];case 10:try{f&&!f.done&&(y=d.return)&&y.call(d)}finally{if(p)throw p.error}return[7];case 11:return[4,this._transaction.commit()];case 12:return b.sent(),this._mutex.unlock(),[2,h];case 13:return m=b.sent(),[4,this._transaction.clear()];case 14:throw b.sent(),this._mutex.unlock(),m;case 15:return[3,17];case 16:throw this._transaction.clear(),Ce.collectionNotReady;case 17:return[2]}}))}))},e.prototype.remove=function(e){return r(this,void 0,void 0,(function(){var t;return s(this,(function(n){switch(n.label){case 0:return this.isReady?[4,this._mutex.lock()]:[3,8];case 1:n.sent(),n.label=2;case 2:return n.trys.push([2,5,,7]),[4,this._requestRemove(e)];case 3:return n.sent(),[4,this._transaction.commit()];case 4:return n.sent(),this._mutex.unlock(),[3,7];case 5:return t=n.sent(),[4,this._transaction.clear()];case 6:throw n.sent(),this._mutex.unlock(),t;case 7:return[3,9];case 8:throw Ce.collectionNotReady;case 9:return[2]}}))}))},e.prototype.removeIf=function(e){return r(this,void 0,void 0,(function(){var t,n,o,a,c,u,l,h,d,f,_,v,m,p,y=this;return s(this,(function(E){switch(E.label){case 0:return this.isReady?[4,this._mutex.lock()]:[3,15];case 1:E.sent(),E.label=2;case 2:return E.trys.push([2,13,,14]),t=e.where,n=void 0===t?{}:t,o=e.index,a=void 0===o?null:o,c=e.backward,u=void 0!==c&&c,l=[],[4,new Fe({condition:n,blockManager:this._blockManager,backward:u,indexer:this._getIndexerBy(a)}).each((function(e){return r(y,void 0,void 0,(function(){var t,r;return s(this,(function(i){if(e.error)throw e.stop(),e.error;return e.hasNext?(t=e.nextValue,De(n,t)&&(r=t[this.keyName],l.push(r)),e.next()):e.stop(),[2]}))}))}))];case 3:E.sent(),E.label=4;case 4:E.trys.push([4,9,10,11]),h=i(l),d=h.next(),E.label=5;case 5:return d.done?[3,8]:(f=d.value,[4,this._requestRemove(f)]);case 6:E.sent(),E.label=7;case 7:return d=h.next(),[3,5];case 8:return[3,11];case 9:return _=E.sent(),m={error:_},[3,11];case 10:try{d&&!d.done&&(p=h.return)&&p.call(h)}finally{if(m)throw m.error}return[7];case 11:return[4,this._transaction.commit()];case 12:return E.sent(),this._mutex.unlock(),[2,l];case 13:throw v=E.sent(),this._mutex.unlock(),v;case 14:return[3,16];case 15:throw this._transaction.clear(),Ce.collectionNotReady;case 16:return[2]}}))}))},e.prototype.clear=function(){return r(this,void 0,void 0,(function(){var e;return s(this,(function(t){switch(t.label){case 0:return this.isReady?[4,this._mutex.lock()]:[3,8];case 1:t.sent(),t.label=2;case 2:return t.trys.push([2,5,,7]),[4,this._requestClear()];case 3:return t.sent(),[4,this._transaction.commit()];case 4:return t.sent(),this._mutex.unlock(),[3,7];case 5:return e=t.sent(),[4,this._transaction.clear()];case 6:throw t.sent(),this._mutex.unlock(),e;case 7:return[3,9];case 8:throw Ce.collectionNotReady;case 9:return[2]}}))}))},e.prototype.getBlob=function(e){return r(this,void 0,void 0,(function(){return s(this,(function(t){switch(t.label){case 0:return[4,this._blobContainer.get(e)];case 1:return[2,t.sent()]}}))}))},e.prototype.saveBlob=function(e,t){return void 0===t&&(t=null),r(this,void 0,void 0,(function(){return s(this,(function(n){switch(n.label){case 0:return[4,this._blobContainer.save(e,t)];case 1:return[2,n.sent()]}}))}))},e.prototype.removeBlob=function(e){return r(this,void 0,void 0,(function(){return s(this,(function(t){switch(t.label){case 0:return[4,this._blobContainer.remove(e)];case 1:return t.sent(),[2]}}))}))},e.prototype.removeAllBlobs=function(){return r(this,void 0,void 0,(function(){return s(this,(function(e){switch(e.label){case 0:return[4,this._blobContainer.clear()];case 1:return e.sent(),[2]}}))}))},e}(),ot=function(){function e(e){var t,n,r;this.encryption=null!==(t=e.encryption)&&void 0!==t?t:w,this.itemSizeLimit=null!==(n=e.itemSizeLimit)&&void 0!==n?n:4194304,this.metadataBuffer=null!==(r=e.metadataBuffer)&&void 0!==r?r:256}return e.prototype._getRawKey=function(e,t){return void 0===t&&(t=""),"".concat(e).concat(t)},e.prototype._generateShardPostfixArray=function(e){return void 0===e&&(e=1),N([],I(Array(e).keys()),!1)},e.prototype._shardify=function(e){var t=this,n=e.key,r=e.value,i=JSON.stringify(this.encryption.encrypt(r)),s=Math.ceil(i.length/this.adjustedItemSizeLimit);return this._generateShardPostfixArray(s).map((function(e){var r={key:t._getRawKey(n,".".concat(e)),data:i.substring(e*t.adjustedItemSizeLimit,(e+1)*t.adjustedItemSizeLimit)};return 0===e&&(r.metadata={shards:s}),r}))},Object.defineProperty(e.prototype,"adjustedItemSizeLimit",{get:function(){return Math.max(this.itemSizeLimit-this.metadataBuffer,4)},enumerable:!1,configurable:!0}),e.prototype.usage=function(){return r(this,void 0,void 0,(function(){var e,t,n,r,o,a,c,u,l;return s(this,(function(s){switch(s.label){case 0:return e=0,[4,this._getAllRawKeys()];case 1:t=s.sent(),s.label=2;case 2:s.trys.push([2,7,8,9]),n=i(t),r=n.next(),s.label=3;case 3:return r.done?[3,6]:(o=r.value,[4,this._getRaw(o)]);case 4:(a=s.sent())&&(e+=JSON.stringify(a).length),s.label=5;case 5:return r=n.next(),[3,3];case 6:return[3,9];case 7:return c=s.sent(),u={error:c},[3,9];case 8:try{r&&!r.done&&(l=n.return)&&l.call(n)}finally{if(u)throw u.error}return[7];case 9:return[2,e]}}))}))},e.prototype.getAllKeys=function(){return r(this,void 0,void 0,(function(){return s(this,(function(e){switch(e.label){case 0:return[4,this._getAllRawKeys()];case 1:return[2,e.sent().filter((function(e){return e.endsWith(".0")})).map((function(e){return e.replace(/\.0$/,"")}))]}}))}))},e.prototype.get=function(e){return r(this,void 0,void 0,(function(){var t,n,i,o,a,c,u=this;return s(this,(function(l){switch(l.label){case 0:return t=this._getRawKey(e,".0"),[4,this._getRaw(t)];case 1:if(!(n=l.sent()))return[3,7];l.label=2;case 2:return l.trys.push([2,6,,7]),i=n.data,(null==(o=n.metadata)?void 0:o.shards)>1?[4,Promise.all(this._generateShardPostfixArray(null==o?void 0:o.shards).map((function(t){return r(u,void 0,void 0,(function(){var n,r;return s(this,(function(s){switch(s.label){case 0:return t>0?(n=this._getRawKey(e,".".concat(t)),[4,this._getRaw(n)]):[3,2];case 1:if(!(r=s.sent()))throw Ce.storeBrokenIntegrity;return[2,r.data];case 2:return[2,i]}}))}))})))]:[3,4];case 3:return c=l.sent(),[3,5];case 4:c=[i],l.label=5;case 5:return a=c,[2,this.encryption.decrypt(JSON.parse(a.join("")))];case 6:return l.sent(),[2,null];case 7:return[2,null]}}))}))},e.prototype.set=function(e){return r(this,void 0,void 0,(function(){var t;return s(this,(function(n){switch(n.label){case 0:return t=this._shardify(e),[4,this._setRaw(t)];case 1:return n.sent(),[2,o({},e.value)]}}))}))},e.prototype.setMany=function(e){return r(this,void 0,void 0,(function(){var t=this;return s(this,(function(n){switch(n.label){case 0:return[4,this._setRaw([].concat.apply([],N([],I(e.map((function(e){return t._shardify(e)}))),!1)))];case 1:return n.sent(),[2,e.map((function(e){return e.value}))]}}))}))},e.prototype.remove=function(e){return r(this,void 0,void 0,(function(){var t,n,r,i=this;return s(this,(function(s){switch(s.label){case 0:return t=this._getRawKey(e,".0"),[4,this._getRaw(t)];case 1:return(n=s.sent())?(r=n.metadata,[4,this._removeRaw(this._generateShardPostfixArray(null==r?void 0:r.shards).map((function(t){return i._getRawKey(e,".".concat(t))})))]):[3,3];case 2:return s.sent(),[2,!0];case 3:return[2,!1]}}))}))},e.prototype.removeMany=function(e){return r(this,void 0,void 0,(function(){var t,n,r,o,a,c,u,l,h,d=this;return s(this,(function(f){switch(f.label){case 0:t=[],n=function(e){var n,i,o;return s(this,(function(s){switch(s.label){case 0:return n=r._getRawKey(e,".0"),[4,r._getRaw(n)];case 1:return(i=s.sent())&&(o=i.metadata,t.push.apply(t,N([],I(r._generateShardPostfixArray(null==o?void 0:o.shards).map((function(t){return d._getRawKey(e,".".concat(t))}))),!1))),[2]}}))},r=this,f.label=1;case 1:f.trys.push([1,6,7,8]),o=i(e),a=o.next(),f.label=2;case 2:return a.done?[3,5]:(c=a.value,[5,n(c)]);case 3:f.sent(),f.label=4;case 4:return a=o.next(),[3,2];case 5:return[3,8];case 6:return u=f.sent(),l={error:u},[3,8];case 7:try{a&&!a.done&&(h=o.return)&&h.call(o)}finally{if(l)throw l.error}return[7];case 8:return t.length>0?[4,this._removeRaw(t)]:[3,10];case 9:f.sent(),f.label=10;case 10:return[2,e]}}))}))},e}(),at={},ct=function(e){function t(t){void 0===t&&(t={});var n,r=this;r=e.call(this,o(o({},t),{itemSizeLimit:null!==(n=t.itemSizeLimit)&&void 0!==n?n:4194304}))||this;var i=t.delay,s=void 0===i?1:i;return r.delay=s,r.observer={},r}return u(t,e),Object.defineProperty(t.prototype,"rawData",{get:function(){return at[this.dbname]},set:function(e){at[this.dbname]=e},enumerable:!1,configurable:!0}),t.prototype._getAllRawKeys=function(){return r(this,void 0,void 0,(function(){return s(this,(function(e){if(at[this.dbname])return[2,Object.keys(at[this.dbname])];throw Ce.storeNotAvailable}))}))},t.prototype._getRaw=function(e){return r(this,void 0,void 0,(function(){return s(this,(function(t){switch(t.label){case 0:return at[this.dbname]?[4,Re(this.delay)]:[3,2];case 1:return t.sent(),[2,at[this.dbname][e]?o({key:e},at[this.dbname][e]):null];case 2:throw Ce.storeNotAvailable}}))}))},t.prototype._setRaw=function(e){return r(this,void 0,void 0,(function(){var t,n,r,o,a,c,u,l;return s(this,(function(s){switch(s.label){case 0:return at[this.dbname]?[4,Re(this.delay)]:[3,2];case 1:s.sent();try{for(t=i(e),n=t.next();!n.done;n=t.next())r=n.value,o=r.key,a=r.data,c=r.metadata,at[this.dbname][o]=Object.freeze({data:a,metadata:c})}catch(e){u={error:e}}finally{try{n&&!n.done&&(l=t.return)&&l.call(t)}finally{if(u)throw u.error}}return[3,3];case 2:throw Ce.storeNotAvailable;case 3:return[2]}}))}))},t.prototype._removeRaw=function(e){return r(this,void 0,void 0,(function(){var t,n,r,o,a;return s(this,(function(s){switch(s.label){case 0:return at[this.dbname]?[4,Re(this.delay)]:[3,2];case 1:s.sent();try{for(t=i(e),n=t.next();!n.done;n=t.next())r=n.value,at[this.dbname][r]&&delete at[this.dbname][r]}catch(e){o={error:e}}finally{try{n&&!n.done&&(a=t.return)&&a.call(t)}finally{if(o)throw o.error}}return[3,3];case 2:throw Ce.storeNotAvailable;case 3:return[2]}}))}))},t.prototype.observe=function(e,t,n){var r=this;this.observer[e]||(this.observer[e]={}),t.forEach((function(t){return r.observer[e][t]=n}))},t.prototype.isAvailable=function(){return r(this,void 0,void 0,(function(){return s(this,(function(e){return[2,!0]}))}))},t.prototype.init=function(e){return r(this,void 0,void 0,(function(){return s(this,(function(t){return this.dbname=e,at[this.dbname]={},[2]}))}))},t.prototype.set=function(t){return r(this,void 0,void 0,(function(){var n;return s(this,(function(r){if(this.observer[t.key]&&"function"==typeof this.observer[t.key].set&&(n=this.observer[t.key].set()))throw n;return[2,e.prototype.set.call(this,t)]}))}))},t.prototype.setMany=function(t){return r(this,void 0,void 0,(function(){var n,r,o,a,c,u;return s(this,(function(s){try{for(n=i(t),r=n.next();!r.done;r=n.next())if(o=r.value,this.observer[o.key]&&"function"==typeof this.observer[o.key].set&&(a=this.observer[o.key].set()))throw a}catch(e){c={error:e}}finally{try{r&&!r.done&&(u=n.return)&&u.call(n)}finally{if(c)throw c.error}}return[2,e.prototype.setMany.call(this,t)]}))}))},t.prototype.clear=function(){return r(this,void 0,void 0,(function(){return s(this,(function(e){switch(e.label){case 0:return[4,Re(this.delay)];case 1:return e.sent(),at[this.dbname]={},[2]}}))}))},t}(ot),ut="NestDBStore",lt=function(e){function t(t){void 0===t&&(t={});var n,r=this;return(r=e.call(this,o(o({},t),{itemSizeLimit:null!==(n=t.itemSizeLimit)&&void 0!==n?n:104857600}))||this)._storeName=ut,r._window="undefined"!=typeof window?window:null,r._indexedDb=r._window?r._window.indexedDB||r._window.mozIndexedDB||r._window.webkitIndexedDB||r._window.msIndexedDB:null,r}return u(t,e),t.prototype._getObjectStore=function(e){return this._database.transaction(this._storeName,e).objectStore(this._storeName)},t.prototype._getAllRawKeys=function(){return r(this,void 0,void 0,(function(){var e=this;return s(this,(function(t){switch(t.label){case 0:return[4,new Promise((function(t,n){var r=e._getObjectStore("readonly").getAllKeys();r.addEventListener("success",(function(e){t(e.target.result)})),r.addEventListener("error",(function(e){return n(e.target.error)}))}))];case 1:return[2,t.sent()]}}))}))},t.prototype._getRaw=function(e){return r(this,void 0,void 0,(function(){var t=this;return s(this,(function(n){switch(n.label){case 0:return[4,new Promise((function(n,r){var i=t._getObjectStore("readonly").get(e);i.addEventListener("success",(function(e){var t;n(null===(t=null==e?void 0:e.target)||void 0===t?void 0:t.result)})),i.addEventListener("error",(function(e){return r(e.target.error)}))}))];case 1:return[2,n.sent()]}}))}))},t.prototype._setRaw=function(e){return r(this,void 0,void 0,(function(){var t;return s(this,(function(n){switch(n.label){case 0:return t=this._getObjectStore("readwrite"),[4,Promise.all(e.map((function(e){return new Promise((function(n,r){var i=t.put(e);i.addEventListener("success",(function(e){n(e.target.result)})),i.addEventListener("error",(function(){r("Failed to write.")}))}))})))];case 1:return n.sent(),[2]}}))}))},t.prototype._removeRaw=function(e){return r(this,void 0,void 0,(function(){var t;return s(this,(function(n){switch(n.label){case 0:return t=this._getObjectStore("readwrite"),[4,Promise.all(e.map((function(e){return new Promise((function(n,r){var i=t.delete(e);i.addEventListener("success",(function(){return n(e)})),i.addEventListener("error",(function(e){return r(e.target.error)}))}))})))];case 1:return n.sent(),[2]}}))}))},t.prototype.isAvailable=function(){return r(this,void 0,void 0,(function(){var e,t,n,r,i=this;return s(this,(function(s){switch(s.label){case 0:if(!((null==(e="undefined"!=typeof window?window:null)?void 0:e.indexedDB)||(null==e?void 0:e.mozIndexedDB)||(null==e?void 0:e.webkitIndexedDB)||(null==e?void 0:e.msIndexedDB)))return[3,4];s.label=1;case 1:return s.trys.push([1,3,,4]),this._indexedDb=e.indexedDB||e.mozIndexedDB||e.webkitIndexedDB||e.msIndexedDB,t="undefined"!=typeof document&&"undefined"!=typeof navigator,n=navigator.userAgent&&navigator.userAgent.includes("Firefox/")&&!navigator.userAgent.includes("Seamonkey/"),r=navigator.userAgent&&navigator.userAgent.includes("Edge/"),[4,new Promise((function(s,o){if(t)if(n){var a=i._indexedDb.open("_testMozilla");a.onerror=function(){return o("Private browsing mode.")},a.onsuccess=function(){return s()}}else r?(e.PointerEvent||e.MSPointerEvent)&&o("Private browsing mode."):s()}))];case 2:return s.sent(),[2,!0];case 3:return s.sent(),[2,!1];case 4:return[2,!1]}}))}))},t.prototype.init=function(e){return r(this,void 0,void 0,(function(){var t,n=this;return s(this,(function(r){switch(r.label){case 0:return this.dbname=e,[4,new Promise((function(e,t){if(n._window&&Y)if(Q){var r=n._indexedDb.open("_testMozilla");r.onerror=function(){return t(Ce.storeNotAvailableInPrivateBrowsing)},r.onsuccess=function(){return e()}}else Z?n._window.indexedDB||!n._window.PointerEvent&&!n._window.MSPointerEvent||t(Ce.storeNotAvailableInPrivateBrowsing):e();else t(Ce.storeNotAvailable)}))];case 1:return r.sent(),t=this,[4,new Promise((function(t,r){var i=n._indexedDb.open(e);i.addEventListener("upgradeneeded",(function(e){e.target.result.createObjectStore(ut,{keyPath:"key"})})),i.addEventListener("success",(function(e){return t(e.target.result)})),i.addEventListener("error",(function(e){return r(e.target.error)}))}))];case 2:return t._database=r.sent(),[2]}}))}))},t.prototype.clear=function(){return r(this,void 0,void 0,(function(){var e=this;return s(this,(function(t){switch(t.label){case 0:return[4,new Promise((function(t,n){var r=e._getObjectStore("readwrite").clear();r.addEventListener("success",(function(){return t()})),r.addEventListener("error",(function(e){return n(e.target.error)}))}))];case 1:return[2,t.sent()]}}))}))},t}(ot),ht=function(e){function t(t){var n=this,r=t.AsyncStorage,i=t.itemSizeLimit,s=void 0===i?6291456:i,a=A(t,["AsyncStorage","itemSizeLimit"]);return(n=e.call(this,o(o({},a),{itemSizeLimit:s}))||this)._asyncStorage=r,n}return u(t,e),t.prototype._isBelonging=function(e){return e.startsWith("".concat(this.dbname,"/"))},t.prototype._getActualKey=function(e){return"".concat(this.dbname,"/").concat(e)},t.prototype._getAllRawKeys=function(){return r(this,void 0,void 0,(function(){var e,t=this;return s(this,(function(n){switch(n.label){case 0:return[4,this._asyncStorage.getAllKeys()];case 1:return e=n.sent(),[2,e.filter((function(e){return t._isBelonging(e)})).map((function(e){return e.substring("".concat(t.dbname,"/").length)}))]}}))}))},t.prototype._getRaw=function(e){return r(this,void 0,void 0,(function(){var t;return s(this,(function(n){switch(n.label){case 0:return[4,this._asyncStorage.getItem(this._getActualKey(e))];case 1:return[2,(t=n.sent())?JSON.parse(t):null]}}))}))},t.prototype._setRaw=function(e){return r(this,void 0,void 0,(function(){var t,n,r,o,a,c,u;return s(this,(function(s){switch(s.label){case 0:t=[];try{for(n=i(e),r=n.next();!r.done;r=n.next())o=r.value,a=o.key,o.data.length<=this.adjustedItemSizeLimit&&t.push([this._getActualKey(a),JSON.stringify(o)])}catch(e){c={error:e}}finally{try{r&&!r.done&&(u=n.return)&&u.call(n)}finally{if(c)throw c.error}}return[4,this._asyncStorage.multiSet(t)];case 1:return s.sent(),[2]}}))}))},t.prototype._removeRaw=function(e){return r(this,void 0,void 0,(function(){var t=this;return s(this,(function(n){switch(n.label){case 0:return[4,this._asyncStorage.multiRemove(e.map((function(e){return t._getActualKey(e)})))];case 1:return n.sent(),[2]}}))}))},t.prototype.isAvailable=function(){return r(this,void 0,void 0,(function(){return s(this,(function(e){return[2,!!this._asyncStorage]}))}))},t.prototype.init=function(e){return r(this,void 0,void 0,(function(){return s(this,(function(t){return this.dbname=e,[2]}))}))},t.prototype.clear=function(){return r(this,void 0,void 0,(function(){var e;return s(this,(function(t){switch(t.label){case 0:return[4,this.getAllKeys()];case 1:return e=t.sent(),[4,this.removeMany(e)];case 2:return t.sent(),[2]}}))}))},t}(ot);!function(e){function t(t){var n,r=this;return(r=e.call(this,o(o({},t),{itemSizeLimit:null!==(n=t.itemSizeLimit)&&void 0!==n?n:6291456}))||this)._mmkv=t.MMKV,r}u(t,e),t.prototype._isBelonging=function(e){return e.startsWith("".concat(this.dbname,"/"))},t.prototype._getActualKey=function(e){return"".concat(this.dbname,"/").concat(e)},t.prototype._getAllRawKeys=function(){return r(this,void 0,void 0,(function(){var e,t=this;return s(this,(function(n){switch(n.label){case 0:return[4,this._mmkv.getAllKeys()];case 1:return e=n.sent(),[2,e.filter((function(e){return t._isBelonging(e)})).map((function(e){return e.substring("".concat(t.dbname,"/").length)}))]}}))}))},t.prototype._getRaw=function(e){return r(this,void 0,void 0,(function(){var t;return s(this,(function(n){switch(n.label){case 0:return[4,this._mmkv.getString(this._getActualKey(e))];case 1:return[2,(t=n.sent())?JSON.parse(t):null]}}))}))},t.prototype._setRaw=function(e){return r(this,void 0,void 0,(function(){var t,n,r,o,a,c;return s(this,(function(s){try{for(t=i(e),n=t.next();!n.done;n=t.next())r=n.value,o=r.key,r.data.length<=this.adjustedItemSizeLimit&&this._mmkv.set(this._getActualKey(o),JSON.stringify(r))}catch(e){a={error:e}}finally{try{n&&!n.done&&(c=t.return)&&c.call(t)}finally{if(a)throw a.error}}return[2]}))}))},t.prototype._removeRaw=function(e){return r(this,void 0,void 0,(function(){var t,n,r,o,a;return s(this,(function(s){try{for(t=i(e),n=t.next();!n.done;n=t.next())r=n.value,this._mmkv.delete(this._getActualKey(r))}catch(e){o={error:e}}finally{try{n&&!n.done&&(a=t.return)&&a.call(t)}finally{if(o)throw o.error}}return[2]}))}))},t.prototype.isAvailable=function(){return r(this,void 0,void 0,(function(){return s(this,(function(e){return[2,!!this._mmkv]}))}))},t.prototype.init=function(e){return r(this,void 0,void 0,(function(){return s(this,(function(t){return this.dbname=e,[2]}))}))},t.prototype.clear=function(){return r(this,void 0,void 0,(function(){var e;return s(this,(function(t){switch(t.label){case 0:return[4,this.getAllKeys()];case 1:return e=t.sent(),[4,this.removeMany(e)];case 2:return t.sent(),[2]}}))}))}}(ot);var dt,ft="[NESTDB]",_t=!0,vt=function(){function e(){}return e.off=function(){_t=!1},e.log=function(){for(var e=[],t=0;t0&&i[i.length-1])||6!==a[0]&&2!==a[0])){s=0;continue}if(3===a[0]&&(!i||a[1]>i[0]&&a[1]=e.length&&(e=void 0),{value:e&&e[r++],done:!e}}};throw new TypeError(t?"Object is not iterable.":"Symbol.iterator is not defined.")}function a(e,t){var n="function"==typeof Symbol&&e[Symbol.iterator];if(!n)return e;var r,i,o=n.call(e),s=[];try{for(;(void 0===t||t-- >0)&&!(r=o.next()).done;)s.push(r.value)}catch(e){i={error:e}}finally{try{r&&!r.done&&(n=o.return)&&n.call(o)}finally{if(i)throw i.error}}return s}function c(e,t,n){if(n||2===arguments.length)for(var r,i=0,o=t.length;i0&&b.indexOf(e)>=0},O=function(e){return e>0&&m.indexOf(e)>=0},A=function(e,t){if(void 0===t&&(t=!1),t&&null===e)return!0;var n=w("object",e)&&null!==e&&e.hasOwnProperty("name")&&"string"==typeof e.name&&e.hasOwnProperty("uri")&&"string"==typeof e.uri&&e.hasOwnProperty("type")&&"string"==typeof e.type;if(!n){if("undefined"!=typeof Blob)return e instanceof Blob;if("undefined"!=typeof File)return e instanceof File}return n},N=function(e,t){if(e===t)return!0;if(null==e||null==t)return!1;if(e.length!==t.length)return!1;for(var n=c([],a(e),!1).sort(),r=c([],a(t),!1).sort(),i=0;i=1e3&&e<=9e3&&(this._typingIndicatorThrottle=e)},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"websocketResponseTimeout",{get:function(){return this._websocketResponseTimeout},set:function(e){w("number",e)&&e>=5e3&&e<=3e4&&(this._websocketResponseTimeout=e)},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"sessionTokenRefreshTimeout",{get:function(){return this._sessionTokenRefreshTimeout},set:function(e){w("number",e)&&(e<60?e=60:e>1800&&(e=1800),this._sessionTokenRefreshTimeout=e)},enumerable:!1,configurable:!0}),e}(),I={encrypt:function(e){return e},decrypt:function(e){return e}},D=function(){function e(e){var t=e.store;this._preference=new Map,this._store=t}return e.prototype._savePreferenceKeys=function(){return i(this,void 0,void 0,(function(){return o(this,(function(e){switch(e.label){case 0:return[4,this._store.set({key:this._keysAddress,value:c([],a(this._preference.keys()),!1),generation:1})];case 1:return e.sent(),[2]}}))}))},e.prototype.init=function(e,t){var n;return void 0===t&&(t=1),i(this,void 0,void 0,(function(){var r,i,a,c,u,l,h,d,_,f;return o(this,(function(o){switch(o.label){case 0:return this._version=t,this._keysAddress=e,r="".concat(e,".metadata.version"),[4,this._store.get(r)];case 1:return i=o.sent(),[4,this._store.get(e)];case 2:return a=null!==(n=o.sent())&&void 0!==n?n:[],!i||i.versiont.channel.messageCollectionLastAccessedAt?1:-1},this._maxSize=Math.max(r,64),a?(this._clearOrder=o,this._customClearOrderComparator=a):this._clearOrder=g.MESSAGE_COLLECTION_ACCESSED_AT}return Object.defineProperty(e.prototype,"maxSize",{get:function(){return this._maxSize},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"clearOrder",{get:function(){return this._clearOrder},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"clearOrderComparator",{get:function(){var e;return this._clearOrder===g.MESSAGE_COLLECTION_ACCESSED_AT?this._clearOrderComparatorUseMessageCollectionAccessedAt:null!==(e=this._customClearOrderComparator)&&void 0!==e?e:this._clearOrderComparatorUseMessageCollectionAccessedAt},enumerable:!1,configurable:!0}),e}(),P=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}(),z=function(){var e=(new Date).getTime();return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,(function(t){var n=(e+16*Math.random())%16|0;return e=Math.floor(e/16),("x"===t?n:3&n|8).toString(16)}))},F=function(){function e(e){var t=e.container;this._container={},this._container=t,this.key=z()}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}(),q=function(){function e(){this._container={}}return e.prototype.on=function(e,t){return new F({container:this._container}).on(e,t)},e.prototype.once=function(e,t){return new F({container:this._container}).once(e,t)},e.prototype.dispatch=function(e,t){var n,r,i=this._container[e];if(i){var o=[];try{for(var a=s(i.keys()),c=a.next();!c.done;c=a.next()){var u=c.value,l=i.get(u);l.handler(t),l.occurence>0&&(l.occurence--,0===l.occurence&&o.push(u))}}catch(e){n={error:e}}finally{try{c&&!c.done&&(r=a.return)&&r.call(a)}finally{if(n)throw n.error}}o.forEach((function(e){return i.delete(e)}))}},e}(),G=function(){function e(){this._dispatcher=new q}return e.prototype.on=function(e){return this._dispatcher.on("event",e)},e.prototype.once=function(e){return this._dispatcher.once("event",e)},e.prototype.dispatch=function(e){this._dispatcher.dispatch("event",e)},e}(),j=function(){},K=function(e){var t={};return e&&Object.keys(e).forEach((function(n){void 0===e[n]||Number.isNaN(e[n])||null===e[n]||(t[n]=e[n])})),t};!function(e){e.GET="GET",e.POST="POST",e.PUT="PUT",e.DELETE="DELETE"}(x||(x={}));var B,Z=function(e){function n(){var t=null!==e&&e.apply(this,arguments)||this;return t.params={},t.requireAuth=!0,t.headers={},t.requestId=z(),t}return t(n,e),n.prototype.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=K(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=K(this.params);if(Object.keys(t).some((function(e){return A(t[e])}))){var n=new FormData;return Object.keys(t).forEach((function(r){var i,o=t[r];if(A(o)){var s=o;n.append(r,s,null!==(i=s.name)&&void 0!==i?i:"filename")}else n.append(r,e.stringifyParams(o))})),n}return JSON.stringify(t)},enumerable:!1,configurable:!0}),n}(j),V=function(e){function r(t,n){var r=e.call(this)||this;return r._iid=t,r._payload=n,r}return t(r,e),Object.defineProperty(r.prototype,"payload",{get:function(){return n({},this._payload)},enumerable:!1,configurable:!0}),r.prototype.as=function(e){return new e(this._iid,this.payload)},r}(j),H=function(e){function n(t){var n=e.call(this)||this;return n.requestId=t,n}return t(n,e),n}(j),W=function(e){function n(){return null!==e&&e.apply(this,arguments)||this}return t(n,e),n}(j),Q=function(e){function n(t){var n=e.call(this)||this;return n.statLog=t,n}return t(n,e),n}(j);!function(e){e.FEATURE_LOCALCACHE="feature:local_cache",e.WEBSOCKET_CONNECT="ws:connect",e.API_RESULT="api:result"}(B||(B={}));var Y=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 K({stat_type:e.type,ts:e.createdAt,data:K(e.data)})},e}(),X=function(){return"undefined"==typeof document&&"undefined"!=typeof navigator&&"ReactNative"==navigator.product},J=function(){function e(e,t){var n=t.auth,r=t.sdkState,i=t.dispatcher,o=t.logger,s=t.useFetchCompat,a=void 0!==s&&s,c=this;this._abortControl=new Map,this._shouldImportFetchCompat=!1,this._iid=e,this._auth=n,this._sdkState=r,this._dispatcher=i,this._dispatcher.on((function(e){e instanceof H&&c.cancel(e.requestId)})),this._logger=o,this._shouldImportFetchCompat=a}return Object.defineProperty(e.prototype,"_userAgentWithExtension",{get:function(){var e=this._sdkState.extensions,t=X()?"reactnative":"JS",n=e.sb_syncmanager?"s".concat(e.sb_syncmanager):"",r=e.sb_uikit?"u".concat(e.sb_uikit):"",i=e["device-os-platform"]?"o".concat(e["device-os-platform"]):"";return"".concat(t,"/c").concat(h.SDK_VERSION,"/").concat(n,"/").concat(r,"/").concat(i)},enumerable:!1,configurable:!0}),e.prototype._createHeader=function(e,t){void 0===t&&(t=null);var r=this._sdkState,i=r.appId,o=r.appVersion,s=n(n({},e.headers),{SendBird:"JS,".concat(h.OS_VERSION,",").concat(h.SDK_VERSION,",").concat(i).concat(o?",".concat(o):""),"SB-User-Agent":encodeURIComponent(this._userAgentWithExtension),"Request-Sent-Timestamp":Date.now().toString()});return t||(s["Content-Type"]="application/json; charset=utf-8"),e.requireAuth&&this._auth.hasSession&&(s["Session-Key"]=this._auth.sessionKey),this._auth&&this._auth.authToken&&(s["App-Id"]=i,s["Access-Token"]=this._auth.authToken),s},e.prototype._statLogApiResult=function(e,t,n){this._dispatcher.dispatch(new Q(new Y({type:B.API_RESULT,data:{endpoint:e.path,method:e.method,success:!n,latency:Date.now()-t,error_code:null==n?void 0:n.code,error_description:null==n?void 0:n.message}})))},e.prototype.send=function(e){return i(this,void 0,void 0,(function(){var t,n,r,i,s,a,c,u,l,h,d,_,f,p,g;return o(this,(function(o){switch(o.label){case 0:t=e.path,n=e.method,r=![x.GET,x.DELETE].includes(n),i=this._sdkState.api,s="".concat(i.host).concat(t).concat(r?"":e.query),a=r?e.payload:null,c=this._createHeader(e,a instanceof FormData?a:null),u=new AbortController,l=u.signal,this._abortControl.set(e.requestId,u),h=Date.now(),o.label=1;case 1:return o.trys.push([1,8,,9]),this._shouldImportFetchCompat&&(this._shouldImportFetchCompat=!1,("undefined"!=typeof globalThis&&globalThis||"undefined"!=typeof self&&self||"undefined"!=typeof global&&global||{fetch:null}).fetch=void 0),"undefined"!=typeof AbortController?[3,3]:[4,import("./__bundle-4a640e46.js")];case 2:o.sent(),o.label=3;case 3:return"function"==typeof fetch?[3,5]:[4,import("./__bundle-53e684a6.js")];case 4:o.sent(),o.label=5;case 5:return[4,fetch(s,{method:n,body:a,headers:c,signal:l})];case 6:return[4,(d=o.sent()).json()];case 7:if(_=o.sent(),d.ok||d.redirected)return this._logger.debug("receive api response",e.requestId),this._statLogApiResult(e,h,null),[2,new V(this._iid,_)];throw _?(f=new E(_),!e.requireAuth&&f.isSessionKeyExpiredError&&this._dispatcher.dispatch(new W),this._statLogApiResult(e,h,f),f):(f=E.requestFailed,this._statLogApiResult(e,h,f),f);case 8:throw p=o.sent(),this._statLogApiResult(e,h,p),p instanceof E?(this._logger.debug("fail api request",p),p):"AbortError"===p.name?E.requestCanceled:(g=E.networkError,this._logger.debug("fail api request",g),g);case 9:return[2]}}))}))},e.prototype.cancel=function(e){this._abortControl.has(e)&&(this._abortControl.get(e).abort(),this._abortControl.delete(e))},e.prototype.cancelAll=function(){var e,t;try{for(var n=s(this._abortControl.values()),r=n.next();!r.done;r=n.next()){r.value.abort()}}catch(t){e={error:t}}finally{try{r&&!r.done&&(t=n.return)&&t.call(n)}finally{if(e)throw e.error}}this._abortControl.clear()},e}(),$=function(e){function n(t,n,r,i){void 0===i&&(i="");var o=e.call(this)||this;return o._iid=t,o.code=n,o.payload=r,o.requestId=r?r.req_id:i,o}return t(n,e),n.createFromRawMessage=function(e,t){var r=t.substring(0,4),i=null;try{i=JSON.parse(t.substring(4))}catch(e){r="NOOP"}finally{return new n(e,r,i)}},n.prototype.convertToMessage=function(){return"".concat(this.code).concat(JSON.stringify(this.payload),"\n")},n.prototype.as=function(e){return new e(this._iid,this.code,this.payload)},n}(j),ee=function(){};function te(e){let t=e.length;for(;--t>=0;)e[t]=0}const ne=256,re=286,ie=30,oe=15,se=new Uint8Array([0,0,0,0,0,0,0,0,1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4,5,5,5,5,0]),ae=new Uint8Array([0,0,0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9,9,10,10,11,11,12,12,13,13]),ce=new Uint8Array([0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,3,7]),ue=new Uint8Array([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),le=new Array(576);te(le);const he=new Array(60);te(he);const de=new Array(512);te(de);const _e=new Array(256);te(_e);const fe=new Array(29);te(fe);const pe=new Array(ie);function ge(e,t,n,r,i){this.static_tree=e,this.extra_bits=t,this.extra_base=n,this.elems=r,this.max_length=i,this.has_stree=e&&e.length}let ve,Ee,be;function me(e,t){this.dyn_tree=e,this.max_code=0,this.stat_desc=t}te(pe);const ye=e=>e<256?de[e]:de[256+(e>>>7)],we=(e,t)=>{e.pending_buf[e.pending++]=255&t,e.pending_buf[e.pending++]=t>>>8&255},Se=(e,t,n)=>{e.bi_valid>16-n?(e.bi_buf|=t<>16-e.bi_valid,e.bi_valid+=n-16):(e.bi_buf|=t<{Se(e,n[2*t],n[2*t+1])},Te=(e,t)=>{let n=0;do{n|=1&e,e>>>=1,n<<=1}while(--t>0);return n>>>1},Ce=(e,t,n)=>{const r=new Array(16);let i,o,s=0;for(i=1;i<=oe;i++)s=s+n[i-1]<<1,r[i]=s;for(o=0;o<=t;o++){let t=e[2*o+1];0!==t&&(e[2*o]=Te(r[t]++,t))}},Oe=e=>{let t;for(t=0;t{e.bi_valid>8?we(e,e.bi_buf):e.bi_valid>0&&(e.pending_buf[e.pending++]=e.bi_buf),e.bi_buf=0,e.bi_valid=0},Ne=(e,t,n,r)=>{const i=2*t,o=2*n;return e[i]{const r=e.heap[n];let i=n<<1;for(;i<=e.heap_len&&(i{let r,i,o,s,a=0;if(0!==e.sym_next)do{r=255&e.pending_buf[e.sym_buf+a++],r+=(255&e.pending_buf[e.sym_buf+a++])<<8,i=e.pending_buf[e.sym_buf+a++],0===r?ke(e,i,t):(o=_e[i],ke(e,o+ne+1,t),s=se[o],0!==s&&(i-=fe[o],Se(e,i,s)),r--,o=ye(r),ke(e,o,n),s=ae[o],0!==s&&(r-=pe[o],Se(e,r,s)))}while(a{const n=t.dyn_tree,r=t.stat_desc.static_tree,i=t.stat_desc.has_stree,o=t.stat_desc.elems;let s,a,c,u=-1;for(e.heap_len=0,e.heap_max=573,s=0;s>1;s>=1;s--)Re(e,n,s);c=o;do{s=e.heap[1],e.heap[1]=e.heap[e.heap_len--],Re(e,n,1),a=e.heap[1],e.heap[--e.heap_max]=s,e.heap[--e.heap_max]=a,n[2*c]=n[2*s]+n[2*a],e.depth[c]=(e.depth[s]>=e.depth[a]?e.depth[s]:e.depth[a])+1,n[2*s+1]=n[2*a+1]=c,e.heap[1]=c++,Re(e,n,1)}while(e.heap_len>=2);e.heap[--e.heap_max]=e.heap[1],((e,t)=>{const n=t.dyn_tree,r=t.max_code,i=t.stat_desc.static_tree,o=t.stat_desc.has_stree,s=t.stat_desc.extra_bits,a=t.stat_desc.extra_base,c=t.stat_desc.max_length;let u,l,h,d,_,f,p=0;for(d=0;d<=oe;d++)e.bl_count[d]=0;for(n[2*e.heap[e.heap_max]+1]=0,u=e.heap_max+1;u<573;u++)l=e.heap[u],d=n[2*n[2*l+1]+1]+1,d>c&&(d=c,p++),n[2*l+1]=d,l>r||(e.bl_count[d]++,_=0,l>=a&&(_=s[l-a]),f=n[2*l],e.opt_len+=f*(d+_),o&&(e.static_len+=f*(i[2*l+1]+_)));if(0!==p){do{for(d=c-1;0===e.bl_count[d];)d--;e.bl_count[d]--,e.bl_count[d+1]+=2,e.bl_count[c]--,p-=2}while(p>0);for(d=c;0!==d;d--)for(l=e.bl_count[d];0!==l;)h=e.heap[--u],h>r||(n[2*h+1]!==d&&(e.opt_len+=(d-n[2*h+1])*n[2*h],n[2*h+1]=d),l--)}})(e,t),Ce(n,u,e.bl_count)},Le=(e,t,n)=>{let r,i,o=-1,s=t[1],a=0,c=7,u=4;for(0===s&&(c=138,u=3),t[2*(n+1)+1]=65535,r=0;r<=n;r++)i=s,s=t[2*(r+1)+1],++a{let r,i,o=-1,s=t[1],a=0,c=7,u=4;for(0===s&&(c=138,u=3),r=0;r<=n;r++)if(i=s,s=t[2*(r+1)+1],!(++a{Se(e,0+(r?1:0),3),Ae(e),we(e,n),we(e,~n),n&&e.pending_buf.set(e.window.subarray(t,t+n),e.pending),e.pending+=n};var Pe=(e,t,n,r)=>{let i,o,s=0;e.level>0?(2===e.strm.data_type&&(e.strm.data_type=(e=>{let t,n=4093624447;for(t=0;t<=31;t++,n>>>=1)if(1&n&&0!==e.dyn_ltree[2*t])return 0;if(0!==e.dyn_ltree[18]||0!==e.dyn_ltree[20]||0!==e.dyn_ltree[26])return 1;for(t=32;t{let t;for(Le(e,e.dyn_ltree,e.l_desc.max_code),Le(e,e.dyn_dtree,e.d_desc.max_code),De(e,e.bl_desc),t=18;t>=3&&0===e.bl_tree[2*ue[t]+1];t--);return e.opt_len+=3*(t+1)+5+5+4,t})(e),i=e.opt_len+3+7>>>3,o=e.static_len+3+7>>>3,o<=i&&(i=o)):i=o=n+5,n+4<=i&&-1!==t?Ue(e,t,n,r):4===e.strategy||o===i?(Se(e,2+(r?1:0),3),Ie(e,le,he)):(Se(e,4+(r?1:0),3),((e,t,n,r)=>{let i;for(Se(e,t-257,5),Se(e,n-1,5),Se(e,r-4,4),i=0;i{Me||((()=>{let e,t,n,r,i;const o=new Array(16);for(n=0,r=0;r<28;r++)for(fe[r]=n,e=0;e<1<>=7;r(e.pending_buf[e.sym_buf+e.sym_next++]=t,e.pending_buf[e.sym_buf+e.sym_next++]=t>>8,e.pending_buf[e.sym_buf+e.sym_next++]=n,0===t?e.dyn_ltree[2*n]++:(e.matches++,t--,e.dyn_ltree[2*(_e[n]+ne+1)]++,e.dyn_dtree[2*ye(t)]++),e.sym_next===e.sym_end),_tr_align:e=>{Se(e,2,3),ke(e,256,le),(e=>{16===e.bi_valid?(we(e,e.bi_buf),e.bi_buf=0,e.bi_valid=0):e.bi_valid>=8&&(e.pending_buf[e.pending++]=255&e.bi_buf,e.bi_buf>>=8,e.bi_valid-=8)})(e)}};var Fe=(e,t,n,r)=>{let i=65535&e|0,o=e>>>16&65535|0,s=0;for(;0!==n;){s=n>2e3?2e3:n,n-=s;do{i=i+t[r++]|0,o=o+i|0}while(--s);i%=65521,o%=65521}return i|o<<16|0};const qe=new Uint32Array((()=>{let e,t=[];for(var n=0;n<256;n++){e=n;for(var r=0;r<8;r++)e=1&e?3988292384^e>>>1:e>>>1;t[n]=e}return t})());var Ge=(e,t,n,r)=>{const i=qe,o=r+n;e^=-1;for(let n=r;n>>8^i[255&(e^t[n])];return-1^e},je={2:"need dictionary",1:"stream end",0:"","-1":"file error","-2":"stream error","-3":"data error","-4":"insufficient memory","-5":"buffer error","-6":"incompatible version"},Ke={Z_NO_FLUSH:0,Z_PARTIAL_FLUSH:1,Z_SYNC_FLUSH:2,Z_FULL_FLUSH:3,Z_FINISH:4,Z_BLOCK:5,Z_TREES:6,Z_OK:0,Z_STREAM_END:1,Z_NEED_DICT:2,Z_ERRNO:-1,Z_STREAM_ERROR:-2,Z_DATA_ERROR:-3,Z_MEM_ERROR:-4,Z_BUF_ERROR:-5,Z_NO_COMPRESSION:0,Z_BEST_SPEED:1,Z_BEST_COMPRESSION:9,Z_DEFAULT_COMPRESSION:-1,Z_FILTERED:1,Z_HUFFMAN_ONLY:2,Z_RLE:3,Z_FIXED:4,Z_DEFAULT_STRATEGY:0,Z_BINARY:0,Z_TEXT:1,Z_UNKNOWN:2,Z_DEFLATED:8};const{_tr_init:Be,_tr_stored_block:Ze,_tr_flush_block:Ve,_tr_tally:He,_tr_align:We}=ze,{Z_NO_FLUSH:Qe,Z_PARTIAL_FLUSH:Ye,Z_FULL_FLUSH:Xe,Z_FINISH:Je,Z_BLOCK:$e,Z_OK:et,Z_STREAM_END:tt,Z_STREAM_ERROR:nt,Z_DATA_ERROR:rt,Z_BUF_ERROR:it,Z_DEFAULT_COMPRESSION:ot,Z_FILTERED:st,Z_HUFFMAN_ONLY:at,Z_RLE:ct,Z_FIXED:ut,Z_DEFAULT_STRATEGY:lt,Z_UNKNOWN:ht,Z_DEFLATED:dt}=Ke,_t=258,ft=262,pt=42,gt=113,vt=666,Et=(e,t)=>(e.msg=je[t],t),bt=e=>2*e-(e>4?9:0),mt=e=>{let t=e.length;for(;--t>=0;)e[t]=0},yt=e=>{let t,n,r,i=e.w_size;t=e.hash_size,r=t;do{n=e.head[--r],e.head[r]=n>=i?n-i:0}while(--t);t=i,r=t;do{n=e.prev[--r],e.prev[r]=n>=i?n-i:0}while(--t)};let wt=(e,t,n)=>(t<{const t=e.state;let n=t.pending;n>e.avail_out&&(n=e.avail_out),0!==n&&(e.output.set(t.pending_buf.subarray(t.pending_out,t.pending_out+n),e.next_out),e.next_out+=n,t.pending_out+=n,e.total_out+=n,e.avail_out-=n,t.pending-=n,0===t.pending&&(t.pending_out=0))},kt=(e,t)=>{Ve(e,e.block_start>=0?e.block_start:-1,e.strstart-e.block_start,t),e.block_start=e.strstart,St(e.strm)},Tt=(e,t)=>{e.pending_buf[e.pending++]=t},Ct=(e,t)=>{e.pending_buf[e.pending++]=t>>>8&255,e.pending_buf[e.pending++]=255&t},Ot=(e,t,n,r)=>{let i=e.avail_in;return i>r&&(i=r),0===i?0:(e.avail_in-=i,t.set(e.input.subarray(e.next_in,e.next_in+i),n),1===e.state.wrap?e.adler=Fe(e.adler,t,i,n):2===e.state.wrap&&(e.adler=Ge(e.adler,t,i,n)),e.next_in+=i,e.total_in+=i,i)},At=(e,t)=>{let n,r,i=e.max_chain_length,o=e.strstart,s=e.prev_length,a=e.nice_match;const c=e.strstart>e.w_size-ft?e.strstart-(e.w_size-ft):0,u=e.window,l=e.w_mask,h=e.prev,d=e.strstart+_t;let _=u[o+s-1],f=u[o+s];e.prev_length>=e.good_match&&(i>>=2),a>e.lookahead&&(a=e.lookahead);do{if(n=t,u[n+s]===f&&u[n+s-1]===_&&u[n]===u[o]&&u[++n]===u[o+1]){o+=2,n++;do{}while(u[++o]===u[++n]&&u[++o]===u[++n]&&u[++o]===u[++n]&&u[++o]===u[++n]&&u[++o]===u[++n]&&u[++o]===u[++n]&&u[++o]===u[++n]&&u[++o]===u[++n]&&os){if(e.match_start=t,s=r,r>=a)break;_=u[o+s-1],f=u[o+s]}}}while((t=h[t&l])>c&&0!=--i);return s<=e.lookahead?s:e.lookahead},Nt=e=>{const t=e.w_size;let n,r,i;do{if(r=e.window_size-e.lookahead-e.strstart,e.strstart>=t+(t-ft)&&(e.window.set(e.window.subarray(t,t+t-r),0),e.match_start-=t,e.strstart-=t,e.block_start-=t,e.insert>e.strstart&&(e.insert=e.strstart),yt(e),r+=t),0===e.strm.avail_in)break;if(n=Ot(e.strm,e.window,e.strstart+e.lookahead,r),e.lookahead+=n,e.lookahead+e.insert>=3)for(i=e.strstart-e.insert,e.ins_h=e.window[i],e.ins_h=wt(e,e.ins_h,e.window[i+1]);e.insert&&(e.ins_h=wt(e,e.ins_h,e.window[i+3-1]),e.prev[i&e.w_mask]=e.head[e.ins_h],e.head[e.ins_h]=i,i++,e.insert--,!(e.lookahead+e.insert<3)););}while(e.lookahead{let n,r,i,o=e.pending_buf_size-5>e.w_size?e.w_size:e.pending_buf_size-5,s=0,a=e.strm.avail_in;do{if(n=65535,i=e.bi_valid+42>>3,e.strm.avail_outr+e.strm.avail_in&&(n=r+e.strm.avail_in),n>i&&(n=i),n>8,e.pending_buf[e.pending-2]=~n,e.pending_buf[e.pending-1]=~n>>8,St(e.strm),r&&(r>n&&(r=n),e.strm.output.set(e.window.subarray(e.block_start,e.block_start+r),e.strm.next_out),e.strm.next_out+=r,e.strm.avail_out-=r,e.strm.total_out+=r,e.block_start+=r,n-=r),n&&(Ot(e.strm,e.strm.output,e.strm.next_out,n),e.strm.next_out+=n,e.strm.avail_out-=n,e.strm.total_out+=n)}while(0===s);return a-=e.strm.avail_in,a&&(a>=e.w_size?(e.matches=2,e.window.set(e.strm.input.subarray(e.strm.next_in-e.w_size,e.strm.next_in),0),e.strstart=e.w_size,e.insert=e.strstart):(e.window_size-e.strstart<=a&&(e.strstart-=e.w_size,e.window.set(e.window.subarray(e.w_size,e.w_size+e.strstart),0),e.matches<2&&e.matches++,e.insert>e.strstart&&(e.insert=e.strstart)),e.window.set(e.strm.input.subarray(e.strm.next_in-a,e.strm.next_in),e.strstart),e.strstart+=a,e.insert+=a>e.w_size-e.insert?e.w_size-e.insert:a),e.block_start=e.strstart),e.high_wateri&&e.block_start>=e.w_size&&(e.block_start-=e.w_size,e.strstart-=e.w_size,e.window.set(e.window.subarray(e.w_size,e.w_size+e.strstart),0),e.matches<2&&e.matches++,i+=e.w_size,e.insert>e.strstart&&(e.insert=e.strstart)),i>e.strm.avail_in&&(i=e.strm.avail_in),i&&(Ot(e.strm,e.window,e.strstart,i),e.strstart+=i,e.insert+=i>e.w_size-e.insert?e.w_size-e.insert:i),e.high_water>3,i=e.pending_buf_size-i>65535?65535:e.pending_buf_size-i,o=i>e.w_size?e.w_size:i,r=e.strstart-e.block_start,(r>=o||(r||t===Je)&&t!==Qe&&0===e.strm.avail_in&&r<=i)&&(n=r>i?i:r,s=t===Je&&0===e.strm.avail_in&&n===r?1:0,Ze(e,e.block_start,n,s),e.block_start+=n,St(e.strm)),s?3:1)},It=(e,t)=>{let n,r;for(;;){if(e.lookahead=3&&(e.ins_h=wt(e,e.ins_h,e.window[e.strstart+3-1]),n=e.prev[e.strstart&e.w_mask]=e.head[e.ins_h],e.head[e.ins_h]=e.strstart),0!==n&&e.strstart-n<=e.w_size-ft&&(e.match_length=At(e,n)),e.match_length>=3)if(r=He(e,e.strstart-e.match_start,e.match_length-3),e.lookahead-=e.match_length,e.match_length<=e.max_lazy_match&&e.lookahead>=3){e.match_length--;do{e.strstart++,e.ins_h=wt(e,e.ins_h,e.window[e.strstart+3-1]),n=e.prev[e.strstart&e.w_mask]=e.head[e.ins_h],e.head[e.ins_h]=e.strstart}while(0!=--e.match_length);e.strstart++}else e.strstart+=e.match_length,e.match_length=0,e.ins_h=e.window[e.strstart],e.ins_h=wt(e,e.ins_h,e.window[e.strstart+1]);else r=He(e,0,e.window[e.strstart]),e.lookahead--,e.strstart++;if(r&&(kt(e,!1),0===e.strm.avail_out))return 1}return e.insert=e.strstart<2?e.strstart:2,t===Je?(kt(e,!0),0===e.strm.avail_out?3:4):e.sym_next&&(kt(e,!1),0===e.strm.avail_out)?1:2},Dt=(e,t)=>{let n,r,i;for(;;){if(e.lookahead=3&&(e.ins_h=wt(e,e.ins_h,e.window[e.strstart+3-1]),n=e.prev[e.strstart&e.w_mask]=e.head[e.ins_h],e.head[e.ins_h]=e.strstart),e.prev_length=e.match_length,e.prev_match=e.match_start,e.match_length=2,0!==n&&e.prev_length4096)&&(e.match_length=2)),e.prev_length>=3&&e.match_length<=e.prev_length){i=e.strstart+e.lookahead-3,r=He(e,e.strstart-1-e.prev_match,e.prev_length-3),e.lookahead-=e.prev_length-1,e.prev_length-=2;do{++e.strstart<=i&&(e.ins_h=wt(e,e.ins_h,e.window[e.strstart+3-1]),n=e.prev[e.strstart&e.w_mask]=e.head[e.ins_h],e.head[e.ins_h]=e.strstart)}while(0!=--e.prev_length);if(e.match_available=0,e.match_length=2,e.strstart++,r&&(kt(e,!1),0===e.strm.avail_out))return 1}else if(e.match_available){if(r=He(e,0,e.window[e.strstart-1]),r&&kt(e,!1),e.strstart++,e.lookahead--,0===e.strm.avail_out)return 1}else e.match_available=1,e.strstart++,e.lookahead--}return e.match_available&&(r=He(e,0,e.window[e.strstart-1]),e.match_available=0),e.insert=e.strstart<2?e.strstart:2,t===Je?(kt(e,!0),0===e.strm.avail_out?3:4):e.sym_next&&(kt(e,!1),0===e.strm.avail_out)?1:2};function Lt(e,t,n,r,i){this.good_length=e,this.max_lazy=t,this.nice_length=n,this.max_chain=r,this.func=i}const xt=[new Lt(0,0,0,0,Rt),new Lt(4,4,8,4,It),new Lt(4,5,16,8,It),new Lt(4,6,32,32,It),new Lt(4,4,16,16,Dt),new Lt(8,16,32,32,Dt),new Lt(8,16,128,128,Dt),new Lt(8,32,128,256,Dt),new Lt(32,128,258,1024,Dt),new Lt(32,258,258,4096,Dt)];function Mt(){this.strm=null,this.status=0,this.pending_buf=null,this.pending_buf_size=0,this.pending_out=0,this.pending=0,this.wrap=0,this.gzhead=null,this.gzindex=0,this.method=dt,this.last_flush=-1,this.w_size=0,this.w_bits=0,this.w_mask=0,this.window=null,this.window_size=0,this.prev=null,this.head=null,this.ins_h=0,this.hash_size=0,this.hash_bits=0,this.hash_mask=0,this.hash_shift=0,this.block_start=0,this.match_length=0,this.prev_match=0,this.match_available=0,this.strstart=0,this.match_start=0,this.lookahead=0,this.prev_length=0,this.max_chain_length=0,this.max_lazy_match=0,this.level=0,this.strategy=0,this.good_match=0,this.nice_match=0,this.dyn_ltree=new Uint16Array(1146),this.dyn_dtree=new Uint16Array(122),this.bl_tree=new Uint16Array(78),mt(this.dyn_ltree),mt(this.dyn_dtree),mt(this.bl_tree),this.l_desc=null,this.d_desc=null,this.bl_desc=null,this.bl_count=new Uint16Array(16),this.heap=new Uint16Array(573),mt(this.heap),this.heap_len=0,this.heap_max=0,this.depth=new Uint16Array(573),mt(this.depth),this.sym_buf=0,this.lit_bufsize=0,this.sym_next=0,this.sym_end=0,this.opt_len=0,this.static_len=0,this.matches=0,this.insert=0,this.bi_buf=0,this.bi_valid=0}const Ut=e=>{if(!e)return 1;const t=e.state;return!t||t.strm!==e||t.status!==pt&&57!==t.status&&69!==t.status&&73!==t.status&&91!==t.status&&103!==t.status&&t.status!==gt&&t.status!==vt?1:0},Pt=e=>{if(Ut(e))return Et(e,nt);e.total_in=e.total_out=0,e.data_type=ht;const t=e.state;return t.pending=0,t.pending_out=0,t.wrap<0&&(t.wrap=-t.wrap),t.status=2===t.wrap?57:t.wrap?pt:gt,e.adler=2===t.wrap?0:1,t.last_flush=-2,Be(t),et},zt=e=>{const t=Pt(e);var n;return t===et&&((n=e.state).window_size=2*n.w_size,mt(n.head),n.max_lazy_match=xt[n.level].max_lazy,n.good_match=xt[n.level].good_length,n.nice_match=xt[n.level].nice_length,n.max_chain_length=xt[n.level].max_chain,n.strstart=0,n.block_start=0,n.lookahead=0,n.insert=0,n.match_length=n.prev_length=2,n.match_available=0,n.ins_h=0),t},Ft=(e,t,n,r,i,o)=>{if(!e)return nt;let s=1;if(t===ot&&(t=6),r<0?(s=0,r=-r):r>15&&(s=2,r-=16),i<1||i>9||n!==dt||r<8||r>15||t<0||t>9||o<0||o>ut||8===r&&1!==s)return Et(e,nt);8===r&&(r=9);const a=new Mt;return e.state=a,a.strm=e,a.status=pt,a.wrap=s,a.gzhead=null,a.w_bits=r,a.w_size=1<Ft(e,t,dt,15,8,lt),deflateInit2:Ft,deflateReset:zt,deflateResetKeep:Pt,deflateSetHeader:(e,t)=>Ut(e)||2!==e.state.wrap?nt:(e.state.gzhead=t,et),deflate:(e,t)=>{if(Ut(e)||t>$e||t<0)return e?Et(e,nt):nt;const n=e.state;if(!e.output||0!==e.avail_in&&!e.input||n.status===vt&&t!==Je)return Et(e,0===e.avail_out?it:nt);const r=n.last_flush;if(n.last_flush=t,0!==n.pending){if(St(e),0===e.avail_out)return n.last_flush=-1,et}else if(0===e.avail_in&&bt(t)<=bt(r)&&t!==Je)return Et(e,it);if(n.status===vt&&0!==e.avail_in)return Et(e,it);if(n.status===pt&&0===n.wrap&&(n.status=gt),n.status===pt){let t=dt+(n.w_bits-8<<4)<<8,r=-1;if(r=n.strategy>=at||n.level<2?0:n.level<6?1:6===n.level?2:3,t|=r<<6,0!==n.strstart&&(t|=32),t+=31-t%31,Ct(n,t),0!==n.strstart&&(Ct(n,e.adler>>>16),Ct(n,65535&e.adler)),e.adler=1,n.status=gt,St(e),0!==n.pending)return n.last_flush=-1,et}if(57===n.status)if(e.adler=0,Tt(n,31),Tt(n,139),Tt(n,8),n.gzhead)Tt(n,(n.gzhead.text?1:0)+(n.gzhead.hcrc?2:0)+(n.gzhead.extra?4:0)+(n.gzhead.name?8:0)+(n.gzhead.comment?16:0)),Tt(n,255&n.gzhead.time),Tt(n,n.gzhead.time>>8&255),Tt(n,n.gzhead.time>>16&255),Tt(n,n.gzhead.time>>24&255),Tt(n,9===n.level?2:n.strategy>=at||n.level<2?4:0),Tt(n,255&n.gzhead.os),n.gzhead.extra&&n.gzhead.extra.length&&(Tt(n,255&n.gzhead.extra.length),Tt(n,n.gzhead.extra.length>>8&255)),n.gzhead.hcrc&&(e.adler=Ge(e.adler,n.pending_buf,n.pending,0)),n.gzindex=0,n.status=69;else if(Tt(n,0),Tt(n,0),Tt(n,0),Tt(n,0),Tt(n,0),Tt(n,9===n.level?2:n.strategy>=at||n.level<2?4:0),Tt(n,3),n.status=gt,St(e),0!==n.pending)return n.last_flush=-1,et;if(69===n.status){if(n.gzhead.extra){let t=n.pending,r=(65535&n.gzhead.extra.length)-n.gzindex;for(;n.pending+r>n.pending_buf_size;){let i=n.pending_buf_size-n.pending;if(n.pending_buf.set(n.gzhead.extra.subarray(n.gzindex,n.gzindex+i),n.pending),n.pending=n.pending_buf_size,n.gzhead.hcrc&&n.pending>t&&(e.adler=Ge(e.adler,n.pending_buf,n.pending-t,t)),n.gzindex+=i,St(e),0!==n.pending)return n.last_flush=-1,et;t=0,r-=i}let i=new Uint8Array(n.gzhead.extra);n.pending_buf.set(i.subarray(n.gzindex,n.gzindex+r),n.pending),n.pending+=r,n.gzhead.hcrc&&n.pending>t&&(e.adler=Ge(e.adler,n.pending_buf,n.pending-t,t)),n.gzindex=0}n.status=73}if(73===n.status){if(n.gzhead.name){let t,r=n.pending;do{if(n.pending===n.pending_buf_size){if(n.gzhead.hcrc&&n.pending>r&&(e.adler=Ge(e.adler,n.pending_buf,n.pending-r,r)),St(e),0!==n.pending)return n.last_flush=-1,et;r=0}t=n.gzindexr&&(e.adler=Ge(e.adler,n.pending_buf,n.pending-r,r)),n.gzindex=0}n.status=91}if(91===n.status){if(n.gzhead.comment){let t,r=n.pending;do{if(n.pending===n.pending_buf_size){if(n.gzhead.hcrc&&n.pending>r&&(e.adler=Ge(e.adler,n.pending_buf,n.pending-r,r)),St(e),0!==n.pending)return n.last_flush=-1,et;r=0}t=n.gzindexr&&(e.adler=Ge(e.adler,n.pending_buf,n.pending-r,r))}n.status=103}if(103===n.status){if(n.gzhead.hcrc){if(n.pending+2>n.pending_buf_size&&(St(e),0!==n.pending))return n.last_flush=-1,et;Tt(n,255&e.adler),Tt(n,e.adler>>8&255),e.adler=0}if(n.status=gt,St(e),0!==n.pending)return n.last_flush=-1,et}if(0!==e.avail_in||0!==n.lookahead||t!==Qe&&n.status!==vt){let r=0===n.level?Rt(n,t):n.strategy===at?((e,t)=>{let n;for(;;){if(0===e.lookahead&&(Nt(e),0===e.lookahead)){if(t===Qe)return 1;break}if(e.match_length=0,n=He(e,0,e.window[e.strstart]),e.lookahead--,e.strstart++,n&&(kt(e,!1),0===e.strm.avail_out))return 1}return e.insert=0,t===Je?(kt(e,!0),0===e.strm.avail_out?3:4):e.sym_next&&(kt(e,!1),0===e.strm.avail_out)?1:2})(n,t):n.strategy===ct?((e,t)=>{let n,r,i,o;const s=e.window;for(;;){if(e.lookahead<=_t){if(Nt(e),e.lookahead<=_t&&t===Qe)return 1;if(0===e.lookahead)break}if(e.match_length=0,e.lookahead>=3&&e.strstart>0&&(i=e.strstart-1,r=s[i],r===s[++i]&&r===s[++i]&&r===s[++i])){o=e.strstart+_t;do{}while(r===s[++i]&&r===s[++i]&&r===s[++i]&&r===s[++i]&&r===s[++i]&&r===s[++i]&&r===s[++i]&&r===s[++i]&&ie.lookahead&&(e.match_length=e.lookahead)}if(e.match_length>=3?(n=He(e,1,e.match_length-3),e.lookahead-=e.match_length,e.strstart+=e.match_length,e.match_length=0):(n=He(e,0,e.window[e.strstart]),e.lookahead--,e.strstart++),n&&(kt(e,!1),0===e.strm.avail_out))return 1}return e.insert=0,t===Je?(kt(e,!0),0===e.strm.avail_out?3:4):e.sym_next&&(kt(e,!1),0===e.strm.avail_out)?1:2})(n,t):xt[n.level].func(n,t);if(3!==r&&4!==r||(n.status=vt),1===r||3===r)return 0===e.avail_out&&(n.last_flush=-1),et;if(2===r&&(t===Ye?We(n):t!==$e&&(Ze(n,0,0,!1),t===Xe&&(mt(n.head),0===n.lookahead&&(n.strstart=0,n.block_start=0,n.insert=0))),St(e),0===e.avail_out))return n.last_flush=-1,et}return t!==Je?et:n.wrap<=0?tt:(2===n.wrap?(Tt(n,255&e.adler),Tt(n,e.adler>>8&255),Tt(n,e.adler>>16&255),Tt(n,e.adler>>24&255),Tt(n,255&e.total_in),Tt(n,e.total_in>>8&255),Tt(n,e.total_in>>16&255),Tt(n,e.total_in>>24&255)):(Ct(n,e.adler>>>16),Ct(n,65535&e.adler)),St(e),n.wrap>0&&(n.wrap=-n.wrap),0!==n.pending?et:tt)},deflateEnd:e=>{if(Ut(e))return nt;const t=e.state.status;return e.state=null,t===gt?Et(e,rt):et},deflateSetDictionary:(e,t)=>{let n=t.length;if(Ut(e))return nt;const r=e.state,i=r.wrap;if(2===i||1===i&&r.status!==pt||r.lookahead)return nt;if(1===i&&(e.adler=Fe(e.adler,t,n,0)),r.wrap=0,n>=r.w_size){0===i&&(mt(r.head),r.strstart=0,r.block_start=0,r.insert=0);let e=new Uint8Array(r.w_size);e.set(t.subarray(n-r.w_size,n),0),t=e,n=r.w_size}const o=e.avail_in,s=e.next_in,a=e.input;for(e.avail_in=n,e.next_in=0,e.input=t,Nt(r);r.lookahead>=3;){let e=r.strstart,t=r.lookahead-2;do{r.ins_h=wt(r,r.ins_h,r.window[e+3-1]),r.prev[e&r.w_mask]=r.head[r.ins_h],r.head[r.ins_h]=e,e++}while(--t);r.strstart=e,r.lookahead=2,Nt(r)}return r.strstart+=r.lookahead,r.block_start=r.strstart,r.insert=r.lookahead,r.lookahead=0,r.match_length=r.prev_length=2,r.match_available=0,e.next_in=s,e.input=a,e.avail_in=o,r.wrap=i,et},deflateInfo:"pako deflate (from Nodeca project)"};const Gt=(e,t)=>Object.prototype.hasOwnProperty.call(e,t);var jt={assign:function(e){const t=Array.prototype.slice.call(arguments,1);for(;t.length;){const n=t.shift();if(n){if("object"!=typeof n)throw new TypeError(n+"must be non-object");for(const t in n)Gt(n,t)&&(e[t]=n[t])}}return e},flattenChunks:e=>{let t=0;for(let n=0,r=e.length;n=252?6:e>=248?5:e>=240?4:e>=224?3:e>=192?2:1;Bt[254]=Bt[254]=1;var Zt={string2buf:e=>{if("function"==typeof TextEncoder&&TextEncoder.prototype.encode)return(new TextEncoder).encode(e);let t,n,r,i,o,s=e.length,a=0;for(i=0;i>>6,t[o++]=128|63&n):n<65536?(t[o++]=224|n>>>12,t[o++]=128|n>>>6&63,t[o++]=128|63&n):(t[o++]=240|n>>>18,t[o++]=128|n>>>12&63,t[o++]=128|n>>>6&63,t[o++]=128|63&n);return t},buf2string:(e,t)=>{const n=t||e.length;if("function"==typeof TextDecoder&&TextDecoder.prototype.decode)return(new TextDecoder).decode(e.subarray(0,t));let r,i;const o=new Array(2*n);for(i=0,r=0;r4)o[i++]=65533,r+=s-1;else{for(t&=2===s?31:3===s?15:7;s>1&&r1?o[i++]=65533:t<65536?o[i++]=t:(t-=65536,o[i++]=55296|t>>10&1023,o[i++]=56320|1023&t)}}return((e,t)=>{if(t<65534&&e.subarray&&Kt)return String.fromCharCode.apply(null,e.length===t?e:e.subarray(0,t));let n="";for(let r=0;r{(t=t||e.length)>e.length&&(t=e.length);let n=t-1;for(;n>=0&&128==(192&e[n]);)n--;return n<0||0===n?t:n+Bt[e[n]]>t?n:t}};var Vt=function(){this.input=null,this.next_in=0,this.avail_in=0,this.total_in=0,this.output=null,this.next_out=0,this.avail_out=0,this.total_out=0,this.msg="",this.state=null,this.data_type=2,this.adler=0};const Ht=Object.prototype.toString,{Z_NO_FLUSH:Wt,Z_SYNC_FLUSH:Qt,Z_FULL_FLUSH:Yt,Z_FINISH:Xt,Z_OK:Jt,Z_STREAM_END:$t,Z_DEFAULT_COMPRESSION:en,Z_DEFAULT_STRATEGY:tn,Z_DEFLATED:nn}=Ke;function rn(e){this.options=jt.assign({level:en,method:nn,chunkSize:16384,windowBits:15,memLevel:8,strategy:tn},e||{});let t=this.options;t.raw&&t.windowBits>0?t.windowBits=-t.windowBits:t.gzip&&t.windowBits>0&&t.windowBits<16&&(t.windowBits+=16),this.err=0,this.msg="",this.ended=!1,this.chunks=[],this.strm=new Vt,this.strm.avail_out=0;let n=qt.deflateInit2(this.strm,t.level,t.method,t.windowBits,t.memLevel,t.strategy);if(n!==Jt)throw new Error(je[n]);if(t.header&&qt.deflateSetHeader(this.strm,t.header),t.dictionary){let e;if(e="string"==typeof t.dictionary?Zt.string2buf(t.dictionary):"[object ArrayBuffer]"===Ht.call(t.dictionary)?new Uint8Array(t.dictionary):t.dictionary,n=qt.deflateSetDictionary(this.strm,e),n!==Jt)throw new Error(je[n]);this._dict_set=!0}}function on(e,t){const n=new rn(t);if(n.push(e,!0),n.err)throw n.msg||je[n.err];return n.result}rn.prototype.push=function(e,t){const n=this.strm,r=this.options.chunkSize;let i,o;if(this.ended)return!1;for(o=t===~~t?t:!0===t?Xt:Wt,"string"==typeof e?n.input=Zt.string2buf(e):"[object ArrayBuffer]"===Ht.call(e)?n.input=new Uint8Array(e):n.input=e,n.next_in=0,n.avail_in=n.input.length;;)if(0===n.avail_out&&(n.output=new Uint8Array(r),n.next_out=0,n.avail_out=r),(o===Qt||o===Yt)&&n.avail_out<=6)this.onData(n.output.subarray(0,n.next_out)),n.avail_out=0;else{if(i=qt.deflate(n,o),i===$t)return n.next_out>0&&this.onData(n.output.subarray(0,n.next_out)),i=qt.deflateEnd(this.strm),this.onEnd(i),this.ended=!0,i===Jt;if(0!==n.avail_out){if(o>0&&n.next_out>0)this.onData(n.output.subarray(0,n.next_out)),n.avail_out=0;else if(0===n.avail_in)break}else this.onData(n.output)}return!0},rn.prototype.onData=function(e){this.chunks.push(e)},rn.prototype.onEnd=function(e){e===Jt&&(this.result=jt.flattenChunks(this.chunks)),this.chunks=[],this.err=e,this.msg=this.strm.msg};var sn={Deflate:rn,deflate:on,deflateRaw:function(e,t){return(t=t||{}).raw=!0,on(e,t)},gzip:function(e,t){return(t=t||{}).gzip=!0,on(e,t)},constants:Ke};const an=16209;var cn=function(e,t){let n,r,i,o,s,a,c,u,l,h,d,_,f,p,g,v,E,b,m,y,w,S,k,T;const C=e.state;n=e.next_in,k=e.input,r=n+(e.avail_in-5),i=e.next_out,T=e.output,o=i-(t-e.avail_out),s=i+(e.avail_out-257),a=C.dmax,c=C.wsize,u=C.whave,l=C.wnext,h=C.window,d=C.hold,_=C.bits,f=C.lencode,p=C.distcode,g=(1<>>24,d>>>=b,_-=b,b=E>>>16&255,0===b)T[i++]=65535&E;else{if(!(16&b)){if(0==(64&b)){E=f[(65535&E)+(d&(1<>>=b,_-=b),_<15&&(d+=k[n++]<<_,_+=8,d+=k[n++]<<_,_+=8),E=p[d&v];n:for(;;){if(b=E>>>24,d>>>=b,_-=b,b=E>>>16&255,!(16&b)){if(0==(64&b)){E=p[(65535&E)+(d&(1<a){e.msg="invalid distance too far back",C.mode=an;break e}if(d>>>=b,_-=b,b=i-o,y>b){if(b=y-b,b>u&&C.sane){e.msg="invalid distance too far back",C.mode=an;break e}if(w=0,S=h,0===l){if(w+=c-b,b2;)T[i++]=S[w++],T[i++]=S[w++],T[i++]=S[w++],m-=3;m&&(T[i++]=S[w++],m>1&&(T[i++]=S[w++]))}else{w=i-y;do{T[i++]=T[w++],T[i++]=T[w++],T[i++]=T[w++],m-=3}while(m>2);m&&(T[i++]=T[w++],m>1&&(T[i++]=T[w++]))}break}}break}}while(n>3,n-=m,_-=m<<3,d&=(1<<_)-1,e.next_in=n,e.next_out=i,e.avail_in=n{const c=a.bits;let u,l,h,d,_,f,p=0,g=0,v=0,E=0,b=0,m=0,y=0,w=0,S=0,k=0,T=null;const C=new Uint16Array(16),O=new Uint16Array(16);let A,N,R,I=null;for(p=0;p<=un;p++)C[p]=0;for(g=0;g=1&&0===C[E];E--);if(b>E&&(b=E),0===E)return i[o++]=20971520,i[o++]=20971520,a.bits=1,0;for(v=1;v0&&(0===e||1!==E))return-1;for(O[1]=0,p=1;p852||2===e&&S>592)return 1;for(;;){A=p-y,s[g]+1=f?(N=I[s[g]-f],R=T[s[g]-f]):(N=96,R=0),u=1<>y)+l]=A<<24|N<<16|R|0}while(0!==l);for(u=1<>=1;if(0!==u?(k&=u-1,k+=u):k=0,g++,0==--C[p]){if(p===E)break;p=t[n+s[g]]}if(p>b&&(k&d)!==h){for(0===y&&(y=b),_+=v,m=p-y,w=1<852||2===e&&S>592)return 1;h=k&d,i[h]=b<<24|m<<16|_-o|0}}return 0!==k&&(i[_+k]=p-y<<24|64<<16|0),a.bits=b,0};const{Z_FINISH:pn,Z_BLOCK:gn,Z_TREES:vn,Z_OK:En,Z_STREAM_END:bn,Z_NEED_DICT:mn,Z_STREAM_ERROR:yn,Z_DATA_ERROR:wn,Z_MEM_ERROR:Sn,Z_BUF_ERROR:kn,Z_DEFLATED:Tn}=Ke,Cn=16180,On=16190,An=16191,Nn=16192,Rn=16194,In=16199,Dn=16200,Ln=16206,xn=16209,Mn=e=>(e>>>24&255)+(e>>>8&65280)+((65280&e)<<8)+((255&e)<<24);function Un(){this.strm=null,this.mode=0,this.last=!1,this.wrap=0,this.havedict=!1,this.flags=0,this.dmax=0,this.check=0,this.total=0,this.head=null,this.wbits=0,this.wsize=0,this.whave=0,this.wnext=0,this.window=null,this.hold=0,this.bits=0,this.length=0,this.offset=0,this.extra=0,this.lencode=null,this.distcode=null,this.lenbits=0,this.distbits=0,this.ncode=0,this.nlen=0,this.ndist=0,this.have=0,this.next=null,this.lens=new Uint16Array(320),this.work=new Uint16Array(288),this.lendyn=null,this.distdyn=null,this.sane=0,this.back=0,this.was=0}const Pn=e=>{if(!e)return 1;const t=e.state;return!t||t.strm!==e||t.mode16211?1:0},zn=e=>{if(Pn(e))return yn;const t=e.state;return e.total_in=e.total_out=t.total=0,e.msg="",t.wrap&&(e.adler=1&t.wrap),t.mode=Cn,t.last=0,t.havedict=0,t.flags=-1,t.dmax=32768,t.head=null,t.hold=0,t.bits=0,t.lencode=t.lendyn=new Int32Array(852),t.distcode=t.distdyn=new Int32Array(592),t.sane=1,t.back=-1,En},Fn=e=>{if(Pn(e))return yn;const t=e.state;return t.wsize=0,t.whave=0,t.wnext=0,zn(e)},qn=(e,t)=>{let n;if(Pn(e))return yn;const r=e.state;return t<0?(n=0,t=-t):(n=5+(t>>4),t<48&&(t&=15)),t&&(t<8||t>15)?yn:(null!==r.window&&r.wbits!==t&&(r.window=null),r.wrap=n,r.wbits=t,Fn(e))},Gn=(e,t)=>{if(!e)return yn;const n=new Un;e.state=n,n.strm=e,n.window=null,n.mode=Cn;const r=qn(e,t);return r!==En&&(e.state=null),r};let jn,Kn,Bn=!0;const Zn=e=>{if(Bn){jn=new Int32Array(512),Kn=new Int32Array(32);let t=0;for(;t<144;)e.lens[t++]=8;for(;t<256;)e.lens[t++]=9;for(;t<280;)e.lens[t++]=7;for(;t<288;)e.lens[t++]=8;for(fn(1,e.lens,0,288,jn,0,e.work,{bits:9}),t=0;t<32;)e.lens[t++]=5;fn(2,e.lens,0,32,Kn,0,e.work,{bits:5}),Bn=!1}e.lencode=jn,e.lenbits=9,e.distcode=Kn,e.distbits=5},Vn=(e,t,n,r)=>{let i;const o=e.state;return null===o.window&&(o.wsize=1<=o.wsize?(o.window.set(t.subarray(n-o.wsize,n),0),o.wnext=0,o.whave=o.wsize):(i=o.wsize-o.wnext,i>r&&(i=r),o.window.set(t.subarray(n-r,n-r+i),o.wnext),(r-=i)?(o.window.set(t.subarray(n-r,n),0),o.wnext=r,o.whave=o.wsize):(o.wnext+=i,o.wnext===o.wsize&&(o.wnext=0),o.whaveGn(e,15),inflateInit2:Gn,inflate:(e,t)=>{let n,r,i,o,s,a,c,u,l,h,d,_,f,p,g,v,E,b,m,y,w,S,k=0;const T=new Uint8Array(4);let C,O;const A=new Uint8Array([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]);if(Pn(e)||!e.output||!e.input&&0!==e.avail_in)return yn;n=e.state,n.mode===An&&(n.mode=Nn),s=e.next_out,i=e.output,c=e.avail_out,o=e.next_in,r=e.input,a=e.avail_in,u=n.hold,l=n.bits,h=a,d=c,S=En;e:for(;;)switch(n.mode){case Cn:if(0===n.wrap){n.mode=Nn;break}for(;l<16;){if(0===a)break e;a--,u+=r[o++]<>>8&255,n.check=Ge(n.check,T,2,0),u=0,l=0,n.mode=16181;break}if(n.head&&(n.head.done=!1),!(1&n.wrap)||(((255&u)<<8)+(u>>8))%31){e.msg="incorrect header check",n.mode=xn;break}if((15&u)!==Tn){e.msg="unknown compression method",n.mode=xn;break}if(u>>>=4,l-=4,w=8+(15&u),0===n.wbits&&(n.wbits=w),w>15||w>n.wbits){e.msg="invalid window size",n.mode=xn;break}n.dmax=1<>8&1),512&n.flags&&4&n.wrap&&(T[0]=255&u,T[1]=u>>>8&255,n.check=Ge(n.check,T,2,0)),u=0,l=0,n.mode=16182;case 16182:for(;l<32;){if(0===a)break e;a--,u+=r[o++]<>>8&255,T[2]=u>>>16&255,T[3]=u>>>24&255,n.check=Ge(n.check,T,4,0)),u=0,l=0,n.mode=16183;case 16183:for(;l<16;){if(0===a)break e;a--,u+=r[o++]<>8),512&n.flags&&4&n.wrap&&(T[0]=255&u,T[1]=u>>>8&255,n.check=Ge(n.check,T,2,0)),u=0,l=0,n.mode=16184;case 16184:if(1024&n.flags){for(;l<16;){if(0===a)break e;a--,u+=r[o++]<>>8&255,n.check=Ge(n.check,T,2,0)),u=0,l=0}else n.head&&(n.head.extra=null);n.mode=16185;case 16185:if(1024&n.flags&&(_=n.length,_>a&&(_=a),_&&(n.head&&(w=n.head.extra_len-n.length,n.head.extra||(n.head.extra=new Uint8Array(n.head.extra_len)),n.head.extra.set(r.subarray(o,o+_),w)),512&n.flags&&4&n.wrap&&(n.check=Ge(n.check,r,_,o)),a-=_,o+=_,n.length-=_),n.length))break e;n.length=0,n.mode=16186;case 16186:if(2048&n.flags){if(0===a)break e;_=0;do{w=r[o+_++],n.head&&w&&n.length<65536&&(n.head.name+=String.fromCharCode(w))}while(w&&_>9&1,n.head.done=!0),e.adler=n.check=0,n.mode=An;break;case 16189:for(;l<32;){if(0===a)break e;a--,u+=r[o++]<>>=7&l,l-=7&l,n.mode=Ln;break}for(;l<3;){if(0===a)break e;a--,u+=r[o++]<>>=1,l-=1,3&u){case 0:n.mode=16193;break;case 1:if(Zn(n),n.mode=In,t===vn){u>>>=2,l-=2;break e}break;case 2:n.mode=16196;break;case 3:e.msg="invalid block type",n.mode=xn}u>>>=2,l-=2;break;case 16193:for(u>>>=7&l,l-=7&l;l<32;){if(0===a)break e;a--,u+=r[o++]<>>16^65535)){e.msg="invalid stored block lengths",n.mode=xn;break}if(n.length=65535&u,u=0,l=0,n.mode=Rn,t===vn)break e;case Rn:n.mode=16195;case 16195:if(_=n.length,_){if(_>a&&(_=a),_>c&&(_=c),0===_)break e;i.set(r.subarray(o,o+_),s),a-=_,o+=_,c-=_,s+=_,n.length-=_;break}n.mode=An;break;case 16196:for(;l<14;){if(0===a)break e;a--,u+=r[o++]<>>=5,l-=5,n.ndist=1+(31&u),u>>>=5,l-=5,n.ncode=4+(15&u),u>>>=4,l-=4,n.nlen>286||n.ndist>30){e.msg="too many length or distance symbols",n.mode=xn;break}n.have=0,n.mode=16197;case 16197:for(;n.have>>=3,l-=3}for(;n.have<19;)n.lens[A[n.have++]]=0;if(n.lencode=n.lendyn,n.lenbits=7,C={bits:n.lenbits},S=fn(0,n.lens,0,19,n.lencode,0,n.work,C),n.lenbits=C.bits,S){e.msg="invalid code lengths set",n.mode=xn;break}n.have=0,n.mode=16198;case 16198:for(;n.have>>24,v=k>>>16&255,E=65535&k,!(g<=l);){if(0===a)break e;a--,u+=r[o++]<>>=g,l-=g,n.lens[n.have++]=E;else{if(16===E){for(O=g+2;l>>=g,l-=g,0===n.have){e.msg="invalid bit length repeat",n.mode=xn;break}w=n.lens[n.have-1],_=3+(3&u),u>>>=2,l-=2}else if(17===E){for(O=g+3;l>>=g,l-=g,w=0,_=3+(7&u),u>>>=3,l-=3}else{for(O=g+7;l>>=g,l-=g,w=0,_=11+(127&u),u>>>=7,l-=7}if(n.have+_>n.nlen+n.ndist){e.msg="invalid bit length repeat",n.mode=xn;break}for(;_--;)n.lens[n.have++]=w}}if(n.mode===xn)break;if(0===n.lens[256]){e.msg="invalid code -- missing end-of-block",n.mode=xn;break}if(n.lenbits=9,C={bits:n.lenbits},S=fn(1,n.lens,0,n.nlen,n.lencode,0,n.work,C),n.lenbits=C.bits,S){e.msg="invalid literal/lengths set",n.mode=xn;break}if(n.distbits=6,n.distcode=n.distdyn,C={bits:n.distbits},S=fn(2,n.lens,n.nlen,n.ndist,n.distcode,0,n.work,C),n.distbits=C.bits,S){e.msg="invalid distances set",n.mode=xn;break}if(n.mode=In,t===vn)break e;case In:n.mode=Dn;case Dn:if(a>=6&&c>=258){e.next_out=s,e.avail_out=c,e.next_in=o,e.avail_in=a,n.hold=u,n.bits=l,cn(e,d),s=e.next_out,i=e.output,c=e.avail_out,o=e.next_in,r=e.input,a=e.avail_in,u=n.hold,l=n.bits,n.mode===An&&(n.back=-1);break}for(n.back=0;k=n.lencode[u&(1<>>24,v=k>>>16&255,E=65535&k,!(g<=l);){if(0===a)break e;a--,u+=r[o++]<>b)],g=k>>>24,v=k>>>16&255,E=65535&k,!(b+g<=l);){if(0===a)break e;a--,u+=r[o++]<>>=b,l-=b,n.back+=b}if(u>>>=g,l-=g,n.back+=g,n.length=E,0===v){n.mode=16205;break}if(32&v){n.back=-1,n.mode=An;break}if(64&v){e.msg="invalid literal/length code",n.mode=xn;break}n.extra=15&v,n.mode=16201;case 16201:if(n.extra){for(O=n.extra;l>>=n.extra,l-=n.extra,n.back+=n.extra}n.was=n.length,n.mode=16202;case 16202:for(;k=n.distcode[u&(1<>>24,v=k>>>16&255,E=65535&k,!(g<=l);){if(0===a)break e;a--,u+=r[o++]<>b)],g=k>>>24,v=k>>>16&255,E=65535&k,!(b+g<=l);){if(0===a)break e;a--,u+=r[o++]<>>=b,l-=b,n.back+=b}if(u>>>=g,l-=g,n.back+=g,64&v){e.msg="invalid distance code",n.mode=xn;break}n.offset=E,n.extra=15&v,n.mode=16203;case 16203:if(n.extra){for(O=n.extra;l>>=n.extra,l-=n.extra,n.back+=n.extra}if(n.offset>n.dmax){e.msg="invalid distance too far back",n.mode=xn;break}n.mode=16204;case 16204:if(0===c)break e;if(_=d-c,n.offset>_){if(_=n.offset-_,_>n.whave&&n.sane){e.msg="invalid distance too far back",n.mode=xn;break}_>n.wnext?(_-=n.wnext,f=n.wsize-_):f=n.wnext-_,_>n.length&&(_=n.length),p=n.window}else p=i,f=s-n.offset,_=n.length;_>c&&(_=c),c-=_,n.length-=_;do{i[s++]=p[f++]}while(--_);0===n.length&&(n.mode=Dn);break;case 16205:if(0===c)break e;i[s++]=n.length,c--,n.mode=Dn;break;case Ln:if(n.wrap){for(;l<32;){if(0===a)break e;a--,u|=r[o++]<{if(Pn(e))return yn;let t=e.state;return t.window&&(t.window=null),e.state=null,En},inflateGetHeader:(e,t)=>{if(Pn(e))return yn;const n=e.state;return 0==(2&n.wrap)?yn:(n.head=t,t.done=!1,En)},inflateSetDictionary:(e,t)=>{const n=t.length;let r,i,o;return Pn(e)?yn:(r=e.state,0!==r.wrap&&r.mode!==On?yn:r.mode===On&&(i=1,i=Fe(i,t,n,0),i!==r.check)?wn:(o=Vn(e,t,n,n),o?(r.mode=16210,Sn):(r.havedict=1,En)))},inflateInfo:"pako inflate (from Nodeca project)"};var Wn=function(){this.text=0,this.time=0,this.xflags=0,this.os=0,this.extra=null,this.extra_len=0,this.name="",this.comment="",this.hcrc=0,this.done=!1};const Qn=Object.prototype.toString,{Z_NO_FLUSH:Yn,Z_FINISH:Xn,Z_OK:Jn,Z_STREAM_END:$n,Z_NEED_DICT:er,Z_STREAM_ERROR:tr,Z_DATA_ERROR:nr,Z_MEM_ERROR:rr}=Ke;function ir(e){this.options=jt.assign({chunkSize:65536,windowBits:15,to:""},e||{});const t=this.options;t.raw&&t.windowBits>=0&&t.windowBits<16&&(t.windowBits=-t.windowBits,0===t.windowBits&&(t.windowBits=-15)),!(t.windowBits>=0&&t.windowBits<16)||e&&e.windowBits||(t.windowBits+=32),t.windowBits>15&&t.windowBits<48&&0==(15&t.windowBits)&&(t.windowBits|=15),this.err=0,this.msg="",this.ended=!1,this.chunks=[],this.strm=new Vt,this.strm.avail_out=0;let n=Hn.inflateInit2(this.strm,t.windowBits);if(n!==Jn)throw new Error(je[n]);if(this.header=new Wn,Hn.inflateGetHeader(this.strm,this.header),t.dictionary&&("string"==typeof t.dictionary?t.dictionary=Zt.string2buf(t.dictionary):"[object ArrayBuffer]"===Qn.call(t.dictionary)&&(t.dictionary=new Uint8Array(t.dictionary)),t.raw&&(n=Hn.inflateSetDictionary(this.strm,t.dictionary),n!==Jn)))throw new Error(je[n])}function or(e,t){const n=new ir(t);if(n.push(e),n.err)throw n.msg||je[n.err];return n.result}ir.prototype.push=function(e,t){const n=this.strm,r=this.options.chunkSize,i=this.options.dictionary;let o,s,a;if(this.ended)return!1;for(s=t===~~t?t:!0===t?Xn:Yn,"[object ArrayBuffer]"===Qn.call(e)?n.input=new Uint8Array(e):n.input=e,n.next_in=0,n.avail_in=n.input.length;;){for(0===n.avail_out&&(n.output=new Uint8Array(r),n.next_out=0,n.avail_out=r),o=Hn.inflate(n,s),o===er&&i&&(o=Hn.inflateSetDictionary(n,i),o===Jn?o=Hn.inflate(n,s):o===nr&&(o=er));n.avail_in>0&&o===$n&&n.state.wrap>0&&0!==e[n.next_in];)Hn.inflateReset(n),o=Hn.inflate(n,s);switch(o){case tr:case nr:case er:case rr:return this.onEnd(o),this.ended=!0,!1}if(a=n.avail_out,n.next_out&&(0===n.avail_out||o===$n))if("string"===this.options.to){let e=Zt.utf8border(n.output,n.next_out),t=n.next_out-e,i=Zt.buf2string(n.output,e);n.next_out=t,n.avail_out=r-t,t&&n.output.set(n.output.subarray(e,e+t),0),this.onData(i)}else this.onData(n.output.length===n.next_out?n.output:n.output.subarray(0,n.next_out));if(o!==Jn||0!==a){if(o===$n)return o=Hn.inflateEnd(this.strm),this.onEnd(o),this.ended=!0,!0;if(0===n.avail_in)break}}return!0},ir.prototype.onData=function(e){this.chunks.push(e)},ir.prototype.onEnd=function(e){e===Jn&&("string"===this.options.to?this.result=this.chunks.join(""):this.result=jt.flattenChunks(this.chunks)),this.chunks=[],this.err=e,this.msg=this.strm.msg};var sr={Inflate:ir,inflate:or,inflateRaw:function(e,t){return(t=t||{}).raw=!0,or(e,t)},ungzip:or,constants:Ke};const{Deflate:ar,deflate:cr,deflateRaw:ur,gzip:lr}=sn,{Inflate:hr,inflate:dr,inflateRaw:_r,ungzip:fr}=sr;var pr,gr={Deflate:ar,deflate:cr,deflateRaw:ur,gzip:lr,Inflate:hr,inflate:dr,inflateRaw:_r,ungzip:fr,constants:Ke};!function(e){e.CONNECTING="CONNECTING",e.OPEN="OPEN",e.CLOSED="CLOSED"}(pr||(pr={}));var vr,Er=function(e){function n(t,n){var r=n.sdkState,i=n.dispatcher,o=n.logger,s=e.call(this)||this;return s.lastActive=0,s._iid=t,s._sdkState=r,s._dispatcher=i,s._logger=o,s}return t(n,e),Object.defineProperty(n.prototype,"isOpen",{get:function(){return this.connectionState===pr.OPEN},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"connectionState",{get:function(){if(this._ws)switch(this._ws.readyState){case 0:return pr.CONNECTING;case 1:return pr.OPEN}return pr.CLOSED},enumerable:!1,configurable:!0}),n.prototype._handleMessage=function(e){var t=this;e.split("\n").forEach((function(e){if(e){var n=$.createFromRawMessage(t._iid,e);t._logger.debug("receive websocket event",n),"LOGI"===n.code?t.dispatch("message",n):"PONG"===n.code?t.dispatch("pong"):"EXPR"===n.code?n.payload&&n.payload.expires_in>=0&&t._dispatcher.dispatch(new W):"NOOP"===n.code||t.dispatch("message",n)}}))},n.prototype.connect=function(e){var t=this;this._ws=new WebSocket(e),this._ws.onopen=function(){t._logger.debug("websocket open"),t.dispatch("open")},this._ws.onmessage=function(e){return i(t,void 0,void 0,(function(){var t,n,r=this;return o(this,(function(s){return(null===(n=this._sdkState.websocket)||void 0===n?void 0:n.compression)?e.data instanceof Blob?((t=new FileReader).readAsArrayBuffer(e.data),t.onloadend=function(){return i(r,void 0,void 0,(function(){var e;return o(this,(function(n){switch(n.label){case 0:return[4,(r=t.result,i(void 0,void 0,void 0,(function(){var e;return o(this,(function(t){return e=gr.ungzip(r),[2,String.fromCharCode.apply(null,e)]}))})))];case 1:return e=n.sent(),this._handleMessage(e),[2]}var r}))}))}):"string"==typeof e.data&&this._handleMessage(e.data):this._handleMessage(e.data),[2]}))}))},this._ws.onerror=function(){t._logger.debug("websocket error"),t.dispatch("error",E.networkError)},this._ws.onclose=function(){t._logger.debug("websocket close"),t.dispatch("close")},this.lastActive=Date.now()},n.prototype.disconnect=function(){var e=this;return new Promise((function(t){e._logger.debug("websocket disconnect"),e._ws&&e.connectionState!==pr.CLOSED?(e._ws.onopen=ee,e._ws.onmessage=ee,e._ws.onerror=ee,e._ws.onclose=function(){e.dispatch("close"),t()},e._ws.close(),e._ws=null):t()}))},n.prototype.send=function(e){if(!this._ws)throw E.connectionClosed;"PING"!==e.code?this.dispatch("ping-refresh"):this._logger.debug("send ping",e),this._ws.send(e.convertToMessage())},n.prototype.error=function(e){this._logger.debug("websocket error",e),this.dispatch("error",e)},n}(q),br=function(e){function n(t){var n,r=t.code,i=t.ackRequired,o=t.payload,s=void 0===o?null:o,a=this;return(a=e.call(this)||this).code=r,a.payload=s,a.requestId=null!==(n=a.payload.req_id)&&void 0!==n?n:z(),a.ackRequired=i,a.payload.req_id=a.requestId,a}return t(n,e),n.prototype.convertToMessage=function(){return"".concat(this.code).concat(JSON.stringify(this.payload),"\n")},n}(j),mr=function(e){function n(t){var n=t.all,r=t.custom_types,i=t.ts,o=e.call(this)||this;return o.all=n,o.customTypes=r,o.ts=i,o}return t(n,e),n}(j),yr=function(){var e=this;this.promise=new Promise((function(t,n){e.resolve=t,e.reject=n}))},wr=function(){function e(e,t){var n=t.auth,r=t.sdkState,i=t.dispatcher,o=t.logger,s=t.useFetchCompat,a=void 0!==s&&s,c=this;this._ackStateMap=new Map,this._sdkState=r,this._dispatcher=i,this._logger=o,this.apiClient=new J(e,{auth:n,sdkState:r,dispatcher:i,logger:o,useFetchCompat:a}),this.websocketClient=new Er(e,{sdkState:r,dispatcher:i,logger:o}),this.websocketClient.on("message",(function(e){if(e.payload.unread_cnt&&c._dispatcher.dispatch(new mr(e.payload.unread_cnt)),e.requestId){if(c._ackStateMap.has(e.requestId)){var t=c._ackStateMap.get(e.requestId);"EROR"!==e.code?t.resolve(e):t.reject(new E({code:e.payload.code,message:e.payload.message}))}}else c._dispatcher.dispatch(e)})).on("close",(function(){c._ackStateMap.forEach((function(e){e.reject(E.connectionClosed)})),c._ackStateMap.clear()}))}return e.prototype._sendApiRequest=function(e){return i(this,void 0,void 0,(function(){return o(this,(function(t){switch(t.label){case 0:return[4,this.apiClient.send(e)];case 1:return[2,t.sent()]}}))}))},e.prototype._sendWebsocketRequest=function(e){return i(this,void 0,void 0,(function(){var t,n,r,i=this;return o(this,(function(o){if(t=new yr,e.ackRequired){n=null,r=function(r,o){void 0===r&&(r=null),void 0===o&&(o=null),i._ackStateMap.has(e.requestId)&&(i._ackStateMap.delete(e.requestId),n&&(clearTimeout(n),n=null),r?(i._logger.debug("fail websocket request",r),t.reject(r)):(i._logger.debug("receive websocket ack",e.requestId),t.resolve(o)))};try{n=setTimeout((function(){return r(E.noAckTimeout)}),this._sdkState.websocket.responseTimeout),this._ackStateMap.set(e.requestId,{resolve:function(e){return r(null,e)},reject:function(e){return r(e)}}),this.websocketClient.send(e)}catch(e){r(e)}}else try{this.websocketClient.send(e),t.resolve(null)}catch(e){t.reject(e)}return[2,t.promise]}))}))},e.prototype.send=function(e){return i(this,void 0,void 0,(function(){return o(this,(function(t){switch(t.label){case 0:return e instanceof Z?[4,this._sendApiRequest(e)]:[3,2];case 1:case 3:return[2,t.sent()];case 2:return e instanceof br?[4,this._sendWebsocketRequest(e)]:[3,4];case 4:throw E.invalidParameters}}))}))},e.prototype.cancel=function(e){this.apiClient.cancel(e)},e.prototype.cancelAll=function(){this.apiClient.cancelAll()},e}();!function(e){e[e.NONE=0]="NONE",e[e.INITIALIZED=1]="INITIALIZED",e[e.CONNECTING=2]="CONNECTING",e[e.CONNECTED=3]="CONNECTED",e[e.RECONNECTING=4]="RECONNECTING",e[e.INTERNAL_DISCONNECTED=5]="INTERNAL_DISCONNECTED",e[e.EXTERNAL_DISCONNECTED=6]="EXTERNAL_DISCONNECTED",e[e.LOGOUT=7]="LOGOUT"}(vr||(vr={}));var Sr=function(e){function n(t){var n=t.stateType,r=e.call(this)||this;return r.stateType=n,r}return t(n,e),n}(j),kr=function(){function e(e,t){var n=t.auth,r=t.sdkState,s=t.dispatcher,a=t.logger,c=t.useFetchCompat,u=void 0!==c&&c,l=this;this._currentConnectionStateType=vr.INITIALIZED,this._lazyCallQueue=[],this.commandRouter=new wr(e,{auth:n,sdkState:r,dispatcher:s,logger:a,useFetchCompat:u}),this._auth=n,this._logger=a,this._dispatcher=s,this._dispatcher.on((function(e){if(e instanceof Sr){var t=e.stateType;switch(l._currentConnectionStateType=t,t){case vr.CONNECTED:var n=l._lazyCallQueue;l._lazyCallQueue=[],n.forEach((function(e){return i(l,void 0,void 0,(function(){var t,n,r,i,s;return o(this,(function(o){switch(o.label){case 0:t=e.command,n=e.deferred,r=e.timeout,clearTimeout(r),o.label=1;case 1:return o.trys.push([1,3,,4]),[4,this.send(t)];case 2:return i=o.sent(),n.resolve(i),[3,4];case 3:return s=o.sent(),n.reject(s),[3,4];case 4:return[2]}}))}))}));break;case vr.INITIALIZED:case vr.INTERNAL_DISCONNECTED:case vr.EXTERNAL_DISCONNECTED:case vr.LOGOUT:n=l._lazyCallQueue;l._lazyCallQueue=[],n.forEach((function(e){return i(l,void 0,void 0,(function(){var t,n;return o(this,(function(r){return t=e.deferred,n=e.timeout,clearTimeout(n),this._auth&&this._auth.hasSession?t.reject(E.connectionClosed):t.reject(E.connectionRequired),[2]}))}))}))}}}))}return Object.defineProperty(e.prototype,"isReady",{get:function(){return this._currentConnectionStateType===vr.CONNECTED},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"isLazyCallActivated",{get:function(){return this._currentConnectionStateType===vr.CONNECTING||this._currentConnectionStateType===vr.RECONNECTING},enumerable:!1,configurable:!0}),e.prototype.send=function(e){return i(this,void 0,void 0,(function(){var t,n,r=this;return o(this,(function(i){switch(i.label){case 0:return e instanceof br?this.isReady?(this._logger.debug("send websocket request",e),[4,this.commandRouter.send(e)]):[3,2]:[3,4];case 1:case 5:return[2,i.sent()];case 2:if(this.isLazyCallActivated)return this._logger.debug("wait websocket request",e),t=new yr,this._lazyCallQueue.push({command:e,deferred:t,timeout:setTimeout((function(){return r.timeout(e.requestId)}),1e4)}),[2,t.promise];throw this._logger.debug("fail websocket request"),E.connectionRequired;case 3:return[3,7];case 4:return e instanceof Z?this._auth.hasSession?(this._logger.debug("send api request",e),[4,this.commandRouter.send(e)]):[3,6]:[3,7];case 6:if(this.isLazyCallActivated)return this._logger.debug("wait api request",e),t=new yr,this._lazyCallQueue.push({command:e,deferred:t,timeout:setTimeout((function(){return r.timeout(e.requestId)}),1e4)}),[2,t.promise];throw n=E.connectionRequired,this._logger.debug("fail api request",n),n;case 7:return[2]}}))}))},e.prototype.forceSend=function(e){return i(this,void 0,void 0,(function(){return o(this,(function(t){switch(t.label){case 0:return this._logger.debug("send forced request",e),[4,this.commandRouter.send(e)];case 1:return[2,t.sent()]}}))}))},e.prototype.timeout=function(e){this._logger.debug("timeout request",e);var t=this._lazyCallQueue.findIndex((function(t){return t.command.requestId===e}));t>-1&&(this._lazyCallQueue[t].deferred.reject(E.connectionRequired),this._lazyCallQueue.splice(t,1))},e.prototype.cancel=function(e){this._logger.debug("cancel api request",e),this.commandRouter.cancel(e)},e.prototype.cancelAll=function(){this._logger.debug("cancel all api requests"),this.commandRouter.cancelAll()},e}(),Tr="sendbird@devicetokens",Cr=function(){function e(e){var t=e.type,n=e.token;this.type=t,this.token=n}return e.payloadify=function(e){return{type:e.type,token:e.token}},e}(),Or="v3",Ar="/".concat(Or,"/users"),Nr="/".concat(Or,"/storage/file"),Rr="/".concat(Or,"/group_channels"),Ir="/".concat(Or,"/sdk/group_channels"),Dr="/".concat(Or,"/open_channels"),Lr="/".concat(Or,"/sdk/open_channels"),xr="/".concat(Or,"/search"),Mr="/".concat(Or,"/report"),Ur="/".concat(Or,"/emojis"),Pr="/".concat(Or,"/emoji_categories"),zr="/".concat(Or,"/polls"),Fr="/".concat(Or,"/scheduled_messages"),qr="/".concat(Or,"/sdk/statistics"),Gr=function(e){function n(t){var n=t.userId,r=t.authToken,i=t.expiringSession,o=void 0===i||i,s=e.call(this)||this;return s.path="".concat(Ar,"/").concat(n,"/session_key"),s.method=x.POST,s.params={token:r,expiring_session:!!o},s.requireAuth=!1,s}return t(n,e),n}(Z),jr=function(e){function n(t){var n=t.authToken,r=t.expiringSession,i=void 0===r||r,o=t.requestId,s=void 0===o?null:o;return e.call(this,{code:"LOGI",payload:{token:n,expiring_session:i?1:0,req_id:s},ackRequired:!0})||this}return t(n,e),n}(br),Kr=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}(V),Br=function(e){function n(t,n,r){var i=e.call(this,t,"LOGI",r)||this;return i.error=null,i.newKey=r.new_key,i.error=r.error?new E(r.error):null,i}return t(n,e),n}($),Zr=function(e){function n(){return null!==e&&e.apply(this,arguments)||this}return t(n,e),n}(j),Vr=function(e){return i(void 0,void 0,void 0,(function(){return o(this,(function(t){return[2,new Promise((function(t){return setTimeout(t,e)}))]}))}))},Hr=function(){function e(){}return e.prototype.calcTimeout=function(){return 0},e}(),Wr=function(e,t,n){return void 0===n&&(n=new Hr),i(void 0,void 0,void 0,(function(){var r,i,s,a,c,u;return o(this,(function(o){switch(o.label){case 0:r=0,i=null,s=function(e){return void 0===e&&(e=null),i=null!=e?e:new Error("Halted")},a=function(){r=0},o.label=1;case 1:if(!(-1===t||r=0},n.prototype.createRefreshWebsocketCommand=function(e,t){return void 0===t&&(t=null),new jr({authToken:e,expiringSession:!0,requestId:t})},n.prototype._refreshSessionKeyByWebSocket=function(e){return i(this,void 0,void 0,(function(){var t,n,r,i,s;return o(this,(function(o){switch(o.label){case 0:return t=this.createRefreshWebsocketCommand(e),[4,this._requestQueue.forceSend(t)];case 1:if(n=o.sent(),r=n.as(Br),i=r.newKey,s=r.error)throw s;return this.auth.sessionKey=null!=i?i:this.auth.sessionKey,[2]}}))}))},n.prototype._refreshSessionKeyByApi=function(e){return i(this,void 0,void 0,(function(){var t,n=this;return o(this,(function(r){switch(r.label){case 0:return t=new Gr({userId:this._sdkState.userId,authToken:e,expiringSession:!0}),[4,Wr((function(e){return i(n,void 0,void 0,(function(){var n,r,i;return o(this,(function(o){switch(o.label){case 0:return o.trys.push([0,2,,3]),[4,this._requestQueue.forceSend(t)];case 1:return n=o.sent(),r=n.as(Kr).key,this.auth.sessionKey=r,[3,3];case 2:if(i=o.sent(),!this._isSessionRelatedError(i))throw i;return e(i),[3,3];case 3:return[2]}}))}))}),3)];case 1:return r.sent(),[2]}}))}))},n.prototype._refreshSessionKey=function(e,t){return void 0===t&&(t=!0),i(this,void 0,void 0,(function(){var n,r,i,s;return o(this,(function(o){switch(o.label){case 0:if(this._currentConnectionStateType!==vr.CONNECTED)return[3,10];o.label=1;case 1:return o.trys.push([1,3,,10]),[4,this._refreshSessionKeyByWebSocket(e)];case 2:return o.sent(),this.complete(),[2];case 3:return n=o.sent(),this._isSessionRelatedError(n)?t?(r=this.auth,[4,this._receiveNewAuthToken()]):[3,9]:[3,9];case 4:return r.authToken=o.sent(),this.auth.authToken?[4,this._refreshSessionKey(this.auth.authToken,!1)]:[3,6];case 5:return o.sent(),this.complete(),[3,8];case 6:return[4,this.clear()];case 7:o.sent(),this.close(),o.label=8;case 8:return[2];case 9:return[3,10];case 10:return o.trys.push([10,12,,22]),[4,this._refreshSessionKeyByApi(e)];case 11:return o.sent(),this.complete(),[3,22];case 12:return i=o.sent(),this._isSessionRelatedError(i)?t?(s=this.auth,[4,this._receiveNewAuthToken()]):[3,18]:[3,20];case 13:return s.authToken=o.sent(),this.auth.authToken?[4,this._refreshSessionKeyByApi(this.auth.authToken)]:[3,15];case 14:return o.sent(),this.complete(),[3,17];case 15:return[4,this.clear()];case 16:o.sent(),this.close(),o.label=17;case 17:return[3,19];case 18:throw i;case 19:return[3,21];case 20:throw i;case 21:return[3,22];case 22:return[2]}}))}))},n.prototype._receiveNewAuthToken=function(){var e=this,t=new yr;return Qr((function(){return i(e,void 0,void 0,(function(){var e,n,r=this;return o(this,(function(i){return this._isRefreshingAuthToken=!0,this.auth.clear(),e=null,n=function(){e&&(clearTimeout(e),e=null)},e=setTimeout((function(){r._isRefreshingAuthToken=!1,t.reject()}),1e3*this._sdkState.sessionTokenRefreshTimeout),this.handler.onSessionTokenRequired((function(e){n(),r._isRefreshingAuthToken&&(r._isRefreshingAuthToken=!1,r.dispatch("refresh-authtoken"),t.resolve(e))}),(function(e){n(),r._isRefreshingAuthToken=!1,t.reject(e)})),[2]}))}))})),t.promise},n.prototype._isSessionRelatedError=function(e){return e instanceof E&&(e.isSessionKeyExpiredError||e.isSessionTokenExpiredError)},Object.defineProperty(n.prototype,"isSessionKeyRefreshing",{get:function(){return this._isRefreshingSessionKey},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"isRefreshingAuthToken",{get:function(){return this._isRefreshingAuthToken},enumerable:!1,configurable:!0}),n.prototype.login=function(e){var t;return i(this,void 0,void 0,(function(){var n,r,i,s,a,c,u;return o(this,(function(o){switch(o.label){case 0:return n=e.key,r=e.ekey,i=e.userProfile,s=e.deviceTokenLastDeletedAt,a=void 0===s?0:s,this.auth.sessionKey=n,Xr.set(this,r),this._deviceTokenCacheEnabled=null===(t=null==i?void 0:i.appInfo)||void 0===t?void 0:t.deviceTokenCache,c=this._cacheContext.preference,this._deviceTokenCacheEnabled?[4,c.get(Tr)]:[3,5];case 1:return!(u=o.sent())||u.lastDeletedAt=0&&this._deviceTokens.splice(n,1)}},n.prototype.unsetDeviceTokens=function(e){this._deviceTokenCacheEnabled&&(this._deviceTokens=e?this._deviceTokens.filter((function(t){return t.type!==e})):[])},n.prototype.setDeviceTokenDeletedAt=function(e){e>0&&(this._deviceTokenLastDeletedAt=e)},n.prototype.saveDeviceToken=function(){return i(this,void 0,void 0,(function(){return o(this,(function(e){switch(e.label){case 0:return this._deviceTokenCacheEnabled?[4,this._cacheContext.preference.set(Tr,{tokens:this._deviceTokens,lastDeletedAt:this._deviceTokenLastDeletedAt})]:[3,2];case 1:e.sent(),e.label=2;case 2:return[2]}}))}))},n.prototype.clear=function(){return i(this,void 0,void 0,(function(){return o(this,(function(e){switch(e.label){case 0:return this.currentUser=null,this.auth.clear(),Xr.delete(this),this._deviceTokens=[],this._deviceTokenLastDeletedAt=0,[4,this.saveDeviceToken()];case 1:return e.sent(),[2]}}))}))},n}(q),$r=function(){function e(){this.type=vr.NONE,this.name="none"}return e.prototype.run=function(e){return i(this,void 0,void 0,(function(){return o(this,(function(e){return[2]}))}))},e.prototype.onConnect=function(e,t){return i(this,void 0,void 0,(function(){return o(this,(function(e){return[2]}))}))},e.prototype.onReconnect=function(e,t){return t.resetReconnectCount,i(this,void 0,void 0,(function(){return o(this,(function(e){return[2]}))}))},e.prototype.onDisconnect=function(e,t){return t.error,t.autoReconnect,i(this,void 0,void 0,(function(){return o(this,(function(e){return[2]}))}))},e.prototype.onDisconnectWebSocket=function(e){return i(this,void 0,void 0,(function(){return o(this,(function(e){return[2]}))}))},e.prototype.onLogout=function(e){return i(this,void 0,void 0,(function(){return o(this,(function(e){return[2]}))}))},e}(),ei=function(e){function n(){var t=null!==e&&e.apply(this,arguments)||this;return t.type=vr.LOGOUT,t.name="logout",t}return t(n,e),n.prototype.run=function(e){return i(this,void 0,void 0,(function(){var t,n,r=this;return o(this,(function(s){switch(s.label){case 0:return t=Date.now(),n=e.sdkState.userId,[4,e.logout()];case 1:return s.sent(),[4,e.changeState(new si,t)];case 2:return s.sent(),Qr((function(){return i(r,void 0,void 0,(function(){return o(this,(function(t){return e.connectionHandlers.forEach((function(e){e.onDisconnected(n)})),[2]}))}))})),[2]}}))}))},n}($r),ti=function(e){function n(){var t=e.call(this)||this;return t.type=vr.EXTERNAL_DISCONNECTED,t.name="externaldisconnected",t}return t(n,e),n.prototype.run=function(e){return i(this,void 0,void 0,(function(){return o(this,(function(t){switch(t.label){case 0:return[4,e.disconnect()];case 1:return t.sent(),[2]}}))}))},n.prototype.onConnect=function(e,t){return i(this,void 0,void 0,(function(){var n;return o(this,(function(r){switch(r.label){case 0:return n=Date.now(),[4,e.disconnect()];case 1:return r.sent(),[4,e.changeState(new oi({authToken:t}),n)];case 2:return r.sent(),[2]}}))}))},n.prototype.onReconnect=function(e){return i(this,void 0,void 0,(function(){var t;return o(this,(function(n){switch(n.label){case 0:return t=Date.now(),[4,e.changeState(new ri,t)];case 1:return n.sent(),[2]}}))}))},n.prototype.onLogout=function(e){return i(this,void 0,void 0,(function(){var t;return o(this,(function(n){switch(n.label){case 0:return t=Date.now(),[4,e.changeState(new ei,t)];case 1:return n.sent(),[2]}}))}))},n}($r),ni=function(e){function n(t){var n=t.autoReconnect,r=e.call(this)||this;return r.type=vr.INTERNAL_DISCONNECTED,r.name="internaldisconnected",r._autoReconnect=!1,r._autoReconnect=n,r}return t(n,e),n.prototype.run=function(e){return i(this,void 0,void 0,(function(){var t;return o(this,(function(n){switch(n.label){case 0:return t=Date.now(),[4,e.disconnect()];case 1:return n.sent(),this._autoReconnect?[4,e.changeState(new ri,t)]:[3,3];case 2:n.sent(),n.label=3;case 3:return[2]}}))}))},n.prototype.onConnect=function(e,t){return i(this,void 0,void 0,(function(){var n;return o(this,(function(r){switch(r.label){case 0:return n=Date.now(),[4,e.disconnect()];case 1:return r.sent(),[4,e.changeState(new oi({authToken:t}),n)];case 2:return r.sent(),[2]}}))}))},n.prototype.onReconnect=function(e){return i(this,void 0,void 0,(function(){var t;return o(this,(function(n){switch(n.label){case 0:return t=Date.now(),[4,e.changeState(new ri,t)];case 1:return n.sent(),[2]}}))}))},n.prototype.onDisconnectWebSocket=function(e){return i(this,void 0,void 0,(function(){var t;return o(this,(function(n){switch(n.label){case 0:return t=Date.now(),[4,e.changeState(new ti,t)];case 1:return n.sent(),[2]}}))}))},n.prototype.onLogout=function(e){return i(this,void 0,void 0,(function(){var t;return o(this,(function(n){switch(n.label){case 0:return t=Date.now(),[4,e.changeState(new ei,t)];case 1:return n.sent(),[2]}}))}))},n}($r),ri=function(e){function n(){var t=null!==e&&e.apply(this,arguments)||this;return t.type=vr.RECONNECTING,t.name="reconnecting",t._haltConnect=null,t._resetConnect=null,t._callbacks=[],t}return t(n,e),n.prototype._halt=function(e){this._haltConnect&&(this._haltConnect(e),this._haltConnect=null)},n.prototype._flushCallbacks=function(e){void 0===e&&(e=null),this._haltConnect=null,this._resetConnect=null,this._callbacks.forEach((function(t){return t(e)}))},n.prototype.run=function(e){return i(this,void 0,void 0,(function(){var t,n,r,s,a,c,l=this;return o(this,(function(h){switch(h.label){case 0:t=Date.now(),n=new yr,this._callbacks.push((function(e){return e?n.reject(e):n.resolve()})),Qr((function(){return i(l,void 0,void 0,(function(){return o(this,(function(t){return e.connectionHandlers.forEach((function(e){e.onReconnectStarted()})),[2]}))}))})),h.label=1;case 1:return h.trys.push([1,4,,9]),r=e.sdkState.websocket,s=r.reconnectMaxRetry,a=r.reconnectRetryStrategy,[4,Wr((function(t,n){return i(l,void 0,void 0,(function(){var r;return o(this,(function(i){switch(i.label){case 0:this._haltConnect=t,this._resetConnect=n,i.label=1;case 1:return i.trys.push([1,3,,4]),[4,e.connect()];case 2:return i.sent(),[3,4];case 3:if(r=i.sent(),e.clearLoginTimer(),r instanceof E&&r.code===u.CONNECTION_CANCELED)return t(r),[2];throw r;case 4:return[2]}}))}))}),s,a)];case 2:return h.sent(),[4,e.changeState(new ii,t)];case 3:return h.sent(),Qr((function(){return i(l,void 0,void 0,(function(){return o(this,(function(t){return this._flushCallbacks(null),e.connectionHandlers.forEach((function(e){e.onReconnectSucceeded()})),[2]}))}))})),[3,9];case 4:return c=h.sent(),v(c)?[3,7]:c instanceof E?c.code===u.CONNECTION_CANCELED?[3,6]:[4,e.changeState(new ni({autoReconnect:!1}),t)]:[3,6];case 5:h.sent(),h.label=6;case 6:return Qr((function(){return i(l,void 0,void 0,(function(){return o(this,(function(t){return this._flushCallbacks(c),e.connectionHandlers.forEach((function(e){e.onReconnectFailed()})),[2]}))}))})),[3,8];case 7:throw c;case 8:return[3,9];case 9:return[2,n.promise]}}))}))},n.prototype.onConnect=function(e,t){return i(this,void 0,void 0,(function(){var n;return o(this,(function(r){return n=new yr,this._halt(E.connectionCanceled),e.cancelConnectForRetry(),this._callbacks.push((function(){var r=Date.now();e.changeState(new oi({authToken:t}),r).then((function(){n.resolve()})).catch((function(e){n.reject(e)}))})),[2,n.promise]}))}))},n.prototype.onReconnect=function(e,t){var n=t.resetReconnectCount,r=void 0!==n&&n;return i(this,void 0,void 0,(function(){var e;return o(this,(function(t){return e=new yr,this._resetConnect&&r&&this._resetConnect(),this._callbacks.push((function(t){return t?e.reject(t):e.resolve()})),[2,e.promise]}))}))},n.prototype.onDisconnect=function(e,t){t.error;var n=t.autoReconnect,r=void 0===n||n;return i(this,void 0,void 0,(function(){var t;return o(this,(function(n){switch(n.label){case 0:return t=Date.now(),this._halt(E.connectionCanceled),[4,e.changeState(new ni({autoReconnect:r}),t)];case 1:return n.sent(),[2]}}))}))},n.prototype.onDisconnectWebSocket=function(e){return i(this,void 0,void 0,(function(){var t;return o(this,(function(n){switch(n.label){case 0:return t=Date.now(),this._halt(E.connectionCanceled),[4,e.changeState(new ti,t)];case 1:return n.sent(),[2]}}))}))},n.prototype.onLogout=function(e){return i(this,void 0,void 0,(function(){var t;return o(this,(function(n){switch(n.label){case 0:return t=Date.now(),this._halt(E.connectionCanceled),[4,e.changeState(new ei,t)];case 1:return n.sent(),[2]}}))}))},n}($r),ii=function(e){function n(){var t=null!==e&&e.apply(this,arguments)||this;return t.type=vr.CONNECTED,t.name="connected",t}return t(n,e),n.prototype.onReconnect=function(e){return i(this,void 0,void 0,(function(){var t;return o(this,(function(n){switch(n.label){case 0:return t=Date.now(),[4,e.disconnect()];case 1:return n.sent(),[4,e.changeState(new ri,t)];case 2:return n.sent(),[2]}}))}))},n.prototype.onDisconnect=function(e,t){var n=t.autoReconnect;return i(this,void 0,void 0,(function(){var t;return o(this,(function(r){switch(r.label){case 0:return t=Date.now(),[4,e.changeState(new ni({autoReconnect:n}),t)];case 1:return r.sent(),[2]}}))}))},n.prototype.onDisconnectWebSocket=function(e){return i(this,void 0,void 0,(function(){var t;return o(this,(function(n){switch(n.label){case 0:return t=Date.now(),[4,e.changeState(new ti,t)];case 1:return n.sent(),[2]}}))}))},n.prototype.onLogout=function(e){return i(this,void 0,void 0,(function(){var t;return o(this,(function(n){switch(n.label){case 0:return t=Date.now(),[4,e.changeState(new ei,t)];case 1:return n.sent(),[2]}}))}))},n}($r),oi=function(e){function n(t){var n=t.authToken,r=e.call(this)||this;return r.type=vr.CONNECTING,r.name="connecting",r._authToken="",r._haltConnect=null,r._callbacks=[],r._authToken=n,r}return t(n,e),n.prototype._halt=function(e){this._haltConnect&&(this._haltConnect(e),this._haltConnect=null)},n.prototype._flushCallbacks=function(e){void 0===e&&(e=null),this._haltConnect=null,this._callbacks.forEach((function(t){return t(e)}))},n.prototype.run=function(e){return i(this,void 0,void 0,(function(){var t,n,r,s=this;return o(this,(function(a){switch(a.label){case 0:t=Date.now(),n=new yr,this._callbacks.push((function(e){return e?n.reject(e):n.resolve()})),a.label=1;case 1:return a.trys.push([1,4,,10]),[4,Wr((function(t){return i(s,void 0,void 0,(function(){var n;return o(this,(function(r){switch(r.label){case 0:this._haltConnect=t,r.label=1;case 1:return r.trys.push([1,3,,4]),[4,e.connect(this._authToken)];case 2:return r.sent(),[3,4];case 3:if(n=r.sent(),e.clearLoginTimer(),n instanceof E&&n.code===u.CONNECTION_CANCELED)return t(n),[2];throw n;case 4:return[2]}}))}))}),e.sdkState.websocket.connectMaxRetry)];case 2:return a.sent(),[4,e.changeState(new ii,t)];case 3:return a.sent(),Qr((function(){return i(s,void 0,void 0,(function(){return o(this,(function(t){return this._flushCallbacks(null),e.connectionHandlers.forEach((function(t){t.onConnected(e.sdkState.userId)})),[2]}))}))})),[3,10];case 4:return r=a.sent(),v(r)?[3,8]:[4,e.disconnect()];case 5:return a.sent(),r instanceof E?r.code===u.CONNECTION_CANCELED?[3,7]:[4,e.changeState(new si,t)]:[3,7];case 6:a.sent(),a.label=7;case 7:return Qr((function(){return i(s,void 0,void 0,(function(){return o(this,(function(e){return this._flushCallbacks(r),[2]}))}))})),[3,9];case 8:throw r;case 9:return[3,10];case 10:return[2,n.promise]}}))}))},n.prototype.onConnect=function(e){return i(this,void 0,void 0,(function(){var e;return o(this,(function(t){return e=new yr,this._callbacks.push((function(t){return t?e.reject(t):e.resolve()})),[2,e.promise]}))}))},n.prototype.onDisconnect=function(e,t){var n=t.error,r=void 0===n?null:n,s=t.autoReconnect;return i(this,void 0,void 0,(function(){var t;return o(this,(function(n){switch(n.label){case 0:return t=Date.now(),this._halt(null!=r?r:E.connectionCanceled),e.hasSession?[4,e.changeState(new ni({autoReconnect:s}),t)]:[3,2];case 1:return n.sent(),[3,4];case 2:return[4,e.changeState(new ei,t)];case 3:n.sent(),n.label=4;case 4:return[2]}}))}))},n.prototype.onDisconnectWebSocket=function(e){return i(this,void 0,void 0,(function(){var t;return o(this,(function(n){switch(n.label){case 0:return t=Date.now(),this._halt(E.connectionCanceled),e.hasSession?[4,e.changeState(new ti,t)]:[3,2];case 1:return n.sent(),[3,4];case 2:return[4,e.changeState(new ei,t)];case 3:n.sent(),n.label=4;case 4:return[2]}}))}))},n.prototype.onLogout=function(e){return i(this,void 0,void 0,(function(){var t;return o(this,(function(n){switch(n.label){case 0:return t=Date.now(),this._halt(E.connectionCanceled),[4,e.changeState(new ei,t)];case 1:return n.sent(),[2]}}))}))},n}($r),si=function(e){function n(){var t=null!==e&&e.apply(this,arguments)||this;return t.type=vr.INITIALIZED,t.name="initialized",t}return t(n,e),n.prototype.onConnect=function(e,t){return i(this,void 0,void 0,(function(){var n;return o(this,(function(r){switch(r.label){case 0:return n=Date.now(),[4,e.changeState(new oi({authToken:t}),n)];case 1:return r.sent(),[2]}}))}))},n}($r),ai=function(e){function n(){return e.call(this,{code:"PING",payload:{id:Date.now(),active:1},ackRequired:!1})||this}return t(n,e),n}(br),ci=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 ai;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}(),ui=1048576,li=function(){function e(e){var t,n,r;void 0===e&&(e={}),this.emojiHash=e.emoji_hash||"",this.uploadSizeLimit=e.file_upload_size_limit?e.file_upload_size_limit*ui:Number.MAX_SAFE_INTEGER,this.useReaction=!!e.use_reaction,this.applicationAttributes=null!==(t=e.application_attributes)&&void 0!==t?t:[],this.premiumFeatureList=null!==(n=e.premium_feature_list)&&void 0!==n?n:[],this.deviceTokenCache=this.applicationAttributes.includes("sdk_device_token_cache"),this.enabledChannelMemberShipHistory=this.applicationAttributes.includes("channel_membership_history"),this.allowSdkStatsUpload=null===(r=e.allow_sdk_log_ingestion)||void 0===r||r}return e.payloadify=function(e){return{emoji_hash:e.emojiHash,file_upload_size_limit:e.uploadSizeLimit/ui,application_attributes:e.applicationAttributes,premium_feature_list:e.premiumFeatureList,use_reaction:e.useReaction,allow_sdk_log_ingestion:e.allowSdkStatsUpload}},e}(),hi=function(){function e(e){this._iid="",this._iid=e}return e.payloadify=function(e){return e?{}:null},e}(),di=function(e){function n(t){var n=t.userId,r=t.metadata,i=e.call(this)||this;return i.method=x.POST,i.path="".concat(Ar,"/").concat(n,"/metadata"),i.params={metadata:r},i}return t(n,e),n}(Z),_i=function(e){function n(t,n){var r=e.call(this,t,n)||this;return r.metaData=n,r}return t(n,e),n}(V),fi=function(e){function n(t){var n=t.userId,r=t.metadata,i=t.upsert,o=e.call(this)||this;return o.method=x.PUT,o.path="".concat(Ar,"/").concat(n,"/metadata"),o.params={metadata:r,upsert:i},o}return t(n,e),n}(Z),pi=function(e){function n(t,n){var r=e.call(this,t,n)||this;return r.metadata=n,r}return t(n,e),n}(V),gi=function(e){function n(t){var n=t.userId,r=t.metadataKey,i=e.call(this)||this;return i.method=x.DELETE,i.path="".concat(Ar,"/").concat(n,"/metadata/").concat(r),i}return t(n,e),n}(Z);!function(e){function n(){return null!==e&&e.apply(this,arguments)||this}t(n,e)}(V);var vi=function(e){function n(t){var n=t.userId,r=e.call(this)||this;return r.method=x.DELETE,r.path="".concat(Ar,"/").concat(n,"/metadata"),r}return t(n,e),n}(Z);!function(e){function n(){return null!==e&&e.apply(this,arguments)||this}t(n,e)}(V);var Ei,bi=function(e,t){void 0===t&&(t=null);var n=JSON.parse(JSON.stringify(e));return n._iid&&delete n._iid,t&&t(n),n},mi=function(e,t){void 0===t&&(t=null);var n=JSON.parse(JSON.stringify(e));return t&&t(n),n},yi=function(e){return{do:function(t){e||t()},throw:function(t){if(!e)throw t}}};!function(e){e.ONLINE="online",e.OFFLINE="offline",e.NON_AVAILABLE="nonavailable"}(Ei||(Ei={}));var wi,Si=function(e){function r(t,n){var r,i,o,s,u,l,h,d,_,f,p,g,v=this;return(v=e.call(this,t)||this).userId=null!==(i=null!==(r=n.guest_id)&&void 0!==r?r:n.user_id)&&void 0!==i?i:"",v.nickname=null!==(s=null!==(o=n.nickname)&&void 0!==o?o:n.name)&&void 0!==s?s:"",v.plainProfileUrl=null!==(l=null!==(u=n.profile_url)&&void 0!==u?u:n.image)&&void 0!==l?l:"",v.requireAuth=null!==(h=n.require_auth_for_profile_image)&&void 0!==h&&h,v.metaData=null!==(d=n.metadata)&&void 0!==d?d:{},v.connectionStatus=Ei.NON_AVAILABLE,S(Ei,n.is_online)?v.connectionStatus=n.is_online:w("boolean",n.is_online)&&(v.connectionStatus=n.is_online?Ei.ONLINE:Ei.OFFLINE),v.isActive=null===(_=n.is_active)||void 0===_||_,v.lastSeenAt=null!==(f=n.last_seen_at)&&void 0!==f?f:null,v.preferredLanguages=n.preferred_languages?c([],a(n.preferred_languages),!1):null,v.friendDiscoveryKey=null!==(p=n.friend_discovery_key)&&void 0!==p?p:null,v.friendName=null!==(g=n.friend_name)&&void 0!==g?g:null,v}return t(r,e),r.payloadify=function(t){return t?K(n(n({},e.payloadify.call(this,t)),{user_id:t.userId,nickname:t.nickname,profile_url:t.plainProfileUrl,require_auth_for_profile_image:t.requireAuth,metadata:t.metaData,is_online:t.connectionStatus,is_active:t.isActive,last_seen_at:t.lastSeenAt,preferred_languages:t.preferredLanguages,friend_discovery_key:t.friendDiscoveryKey,friend_name:t.friendName})):null},Object.defineProperty(r.prototype,"profileUrl",{get:function(){var e=Hi.of(this._iid).sessionManager;return this.requireAuth?"".concat(this.plainProfileUrl,"?auth=").concat(e.ekey):this.plainProfileUrl},enumerable:!1,configurable:!0}),r.prototype.serialize=function(){return bi(this)},r.prototype._isValidMetaData=function(e){return!Array.isArray(e)&&Object.keys(e).length>0&&Object.keys(e).map((function(t){return e[t]})).every((function(e){return w("string",e)}))},r.prototype._applyMetaData=function(e,t){var n=this;void 0===t&&(t=!1),Object.keys(e).forEach((function(r){t?delete n.metaData[r]:n.metaData[r]=e[r]}))},r.prototype.createMetaData=function(e){return i(this,void 0,void 0,(function(){var t,n,r,i,s,a;return o(this,(function(o){switch(o.label){case 0:return yi(this._isValidMetaData(e)).throw(E.invalidParameters),t=Hi.of(this._iid),n=t.sdkState,r=t.requestQueue,i=new di({userId:n.userId,metadata:e}),[4,r.send(i)];case 1:return s=o.sent(),a=s.as(_i).metaData,this._applyMetaData(a),[2,this.metaData]}}))}))},r.prototype.updateMetaData=function(e,t){return void 0===t&&(t=!1),i(this,void 0,void 0,(function(){var n,r,i,s,a,c;return o(this,(function(o){switch(o.label){case 0:return yi(this._isValidMetaData(e)).throw(E.invalidParameters),n=Hi.of(this._iid),r=n.sdkState,i=n.requestQueue,s=new fi({userId:r.userId,metadata:e,upsert:t}),[4,i.send(s)];case 1:return a=o.sent(),c=a.as(pi).metadata,this._applyMetaData(c),[2,this.metaData]}}))}))},r.prototype.deleteMetaData=function(e){return i(this,void 0,void 0,(function(){var t,n,r,i,s;return o(this,(function(o){switch(o.label){case 0:return yi(w("string",e)).throw(E.invalidParameters),t=Hi.of(this._iid),n=t.sdkState,r=t.requestQueue,i=new gi({userId:n.userId,metadataKey:e}),[4,r.send(i)];case 1:return o.sent(),this._applyMetaData(((s={})[e]=!0,s),!0),[2,this.metaData]}}))}))},r.prototype.deleteAllMetaData=function(){return i(this,void 0,void 0,(function(){var e,t,n,r;return o(this,(function(i){switch(i.label){case 0:return e=Hi.of(this._iid),t=e.sdkState,n=e.requestQueue,r=new vi({userId:t.userId}),[4,n.send(r)];case 1:return i.sent(),this.metaData={},[2]}}))}))},r}(hi),ki=function(e){function n(t){var n=t.userProfile,r=e.call(this)||this;return r.userProfile=n,r}return t(n,e),n}(j),Ti=function(){function e(e,t){var n,r,i,o,s,a,c,u,l,h,d,_,f,p;this._iid=e,this.appInfo=new li(t),this.user=new Si(e,t),this.connectedAt=null!==(n=t.login_ts)&&void 0!==n?n:0,this.firstConnectedAt=0,this.pingInterval=null!==(r=t.ping_interval)&&void 0!==r?r:15e3,this.pongTimeout=null!==(i=t.pong_timeout)&&void 0!==i?i:5e3,this.reconnectInterval=null!==(s=null===(o=t.reconnect)||void 0===o?void 0:o.interval)&&void 0!==s?s:3e3,this.reconnectMaxInterval=null!==(c=null===(a=t.reconnect)||void 0===a?void 0:a.max_interval)&&void 0!==c?c:6e4,this.reconnectRetryCount=null!==(l=null===(u=t.reconnect)||void 0===u?void 0:u.retry_cnt)&&void 0!==l?l:5,this.reconnectIntervalMultiple=null!==(d=null===(h=t.reconnect)||void 0===h?void 0:h.mul)&&void 0!==d?d:2,this.maxUnreadCountOnSuperGroup=null!==(_=t.max_unread_cnt_on_super_group)&&void 0!==_?_:100,this.profileImageEncryption=!!t.profile_image_encryption,this.concurrentCallLimit=null!==(f=t.concurrent_call_limit)&&void 0!==f?f:5,this.backOffDelay=null!==(p=t.back_off_delay)&&void 0!==p?p:100}return e.payloadify=function(e){return n(n(n({},Si.payloadify(e.user)),li.payloadify(e.appInfo)),{login_ts:e.connectedAt,ping_interval:e.pingInterval,pong_timeout:e.pongTimeout,reconnect:{interval:e.reconnectInterval,max_interval:e.reconnectMaxInterval,retry_cnt:e.reconnectRetryCount,mul:e.reconnectIntervalMultiple},max_unread_cnt_on_super_group:e.maxUnreadCountOnSuperGroup,profile_image_encryption:e.profileImageEncryption,concurrent_call_limit:e.concurrentCallLimit,back_off_delay:e.backOffDelay})},e.prototype.apply=function(){var e=this.reconnectInterval,t=this.reconnectMaxInterval,n=this.reconnectIntervalMultiple,r=Hi.of(this._iid);r.sdkState.websocket.pingInterval=1e3*this.pingInterval,r.sdkState.websocket.pongTimeout=1e3*this.pongTimeout,r.sdkState.websocket.reconnectMaxRetry=this.reconnectRetryCount,r.sdkState.websocket.reconnectRetryStrategy={calcTimeout:function(r){return r>0?1e3*Math.min(e*Math.pow(n,r-1),t):10}},r.appInfo=this.appInfo,r.sessionManager.currentUser=this.user,r.connectedAt=this.connectedAt,this.firstConnectedAt||(r.firstConnectedAt=this.connectedAt),r.maxSuperGroupChannelUnreadCount=this.maxUnreadCountOnSuperGroup,r.concurrentCallLimit=this.concurrentCallLimit,r.backOffDelay=this.backOffDelay,r.dispatcher.dispatch(new ki({userProfile:this}))},e}(),Ci=function(e){function r(t,n,r){var i,o=this;return(o=e.call(this,t,n,r)||this).error=null,o.userProfile=new Ti(t,r),o.deviceTokenLastDeletedAt=r.device_token_last_deleted_at,o.key=r.key,o.ekey=null!==(i=r.ekey)&&void 0!==i?i:"",o.error=r.error?new E(r):null,o}return t(r,e),r.asError=function(e){return new r(null,"LOGI",n({user_id:null,error:!0},e))},r.prototype.applyTo=function(e){return i(this,void 0,void 0,(function(){var t;return o(this,(function(n){switch(n.label){case 0:return this.error?[3,4]:(t=Hi.of(e))?[4,t.sessionManager.login(this)]:[3,2];case 1:return n.sent(),this.userProfile.apply(),[3,3];case 2:throw E.lostInstance;case 3:return[3,5];case 4:throw this.error;case 5:return[2]}}))}))},r}($),Oi=function(e){function r(t){var r=t.request,i=void 0===r||r,o=t.features,s=void 0===o?{}:o,a=t.options,c=void 0===a?{}:a,u=e.call(this)||this;return u.request=i,u.features=n({localCache:!0},s),u.options=n({ingestion:!0},c),u}return t(r,e),r}(j),Ai=function(e){function n(t,n){var r=n.sdkState,i=n.cacheContext,o=n.connectionHandlers,s=n.sessionManager,a=n.websocketClient,c=n.dispatcher,u=n.logger,l=n.entryState,h=void 0===l?new si:l,d=e.call(this)||this;return d._currentState=null,d._loginTimer=null,d._unresolvedLogi=null,d._stateUpdatedAt=0,d._connectingAt=0,d._connectionRequestQueue=[],d._iid=t,d.sdkState=r,d.cacheContext=i,d.connectionHandlers=o,d._sessionManager=s,d._websocketClient=a,d._dispatcher=c,d._logger=u,d._currentState=h,d.sdkState.websocket.pingerDisabled||(d._pinger=new ci({pingDelegate:{send:function(e){return d._websocketClient.send(e)},error:function(e){return d._websocketClient.error(e)}},sdkState:d.sdkState,logger:u})),d._websocketClient.on("open",(function(){d._tryResolveConnectionRequest()})).on("message",(function(e){if("LOGI"===e.code)d.clearLoginTimer(),d._dispatcher.dispatch(e.as(Ci))})).on("ping-refresh",(function(){var e;return null===(e=d._pinger)||void 0===e?void 0:e.refreshTimer()})).on("pong",(function(){var e;return null===(e=d._pinger)||void 0===e?void 0:e.pong()})).on("error",(function(){var e;return null===(e=d._pinger)||void 0===e?void 0:e.stop()})).on("close",(function(){return d._rejectConnectionRequest(E.networkError)})),d._dispatcher.on((function(e){e instanceof Ci&&(d._unresolvedLogi=e,d._tryResolveConnectionRequest())})),d}return t(n,e),Object.defineProperty(n.prototype,"currentState",{get:function(){return this._currentState},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"hasSession",{get:function(){return this._sessionManager.auth.hasSession},enumerable:!1,configurable:!0}),n.prototype.changeState=function(e,t){return i(this,void 0,void 0,(function(){return o(this,(function(n){switch(n.label){case 0:return t>=this._stateUpdatedAt?(this._currentState=e,this._stateUpdatedAt=t,this._dispatcher.dispatch(new Sr({stateType:e.type})),this._logger.debug("connection state changes to ".concat(e.name)),[4,this._currentState.run(this)]):[3,2];case 1:return n.sent(),[2,!0];case 2:return[2,!1]}}))}))},n.prototype._tryResolveConnectionRequest=function(){var e;return i(this,void 0,void 0,(function(){var t,n;return o(this,(function(r){switch(r.label){case 0:return t=this._unresolvedLogi,this._websocketClient.isOpen&&t?(this._unresolvedLogi=null,t.error?[3,2]:[4,t.applyTo(this._iid)]):[3,3];case 1:return r.sent(),n=t.userProfile,this._enableStatLog({request:n.appInfo.applicationAttributes.includes("allow_sdk_request_log_publish"),features:{localCache:n.appInfo.applicationAttributes.includes("allow_sdk_feature_local_cache_log_publish")},options:{ingestion:n.appInfo.allowSdkStatsUpload}}),this._statLogConnection(null),null===(e=this._pinger)||void 0===e||e.start(),this._connectionRequestQueue.forEach((function(e){return e.resolve()})),this._connectionRequestQueue=[],this.sdkState.appState="foreground",[3,3];case 2:this._sessionManager.auth.authToken=null,(t.error.isSessionKeyExpiredError||t.error.isSessionTokenExpiredError)&&this._dispatcher.dispatch(new W),this._rejectConnectionRequest(t.error),r.label=3;case 3:return[2]}}))}))},n.prototype._rejectConnectionRequest=function(e){var t;if(null===(t=this._pinger)||void 0===t||t.stop(),this.clearLoginTimer(),this._connectionRequestQueue.length>0){var n=this._connectionRequestQueue;this._connectionRequestQueue=[],n.forEach((function(t){return t.reject(e)})),this._statLogConnection(e)}},n.prototype._url=function(e){var t;void 0===e&&(e="");var n=this.sdkState,r=n.appId,i=n.appVersion,o=n.userId,s=n.extensions,a=this.cacheContext.localCacheEnabled,c=this._sessionManager.auth,u=null===(t=this.sdkState.websocket)||void 0===t?void 0:t.compression,l=s.sb_syncmanager?"s".concat(s.sb_syncmanager):"",d=s.sb_uikit?"u".concat(s.sb_uikit):"",_="JS/c".concat(h.SDK_VERSION,"/").concat(l,"/").concat(d);return"".concat(this.sdkState.websocket.host,"/?p=JS&pv=").concat(encodeURIComponent(h.OS_VERSION),"&sv=").concat(encodeURIComponent(h.SDK_VERSION),"&ai=").concat(r).concat(i?"&av=".concat(i):"").concat(c.hasSession?"&key=".concat(encodeURIComponent(c.sessionKey)):"&user_id=".concat(encodeURIComponent(o),"&access_token=").concat(encodeURIComponent(e)),"&pmce=").concat(u?1:0,"&active=1&device_token_types=").concat(encodeURIComponent(["gcm","huawei","apns"].join(",")),"&SB-User-Agent=").concat(_,"&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")},n.prototype._enableStatLog=function(e){var t=e.request,n=e.features,r=e.options,i=void 0===r?{}:r;this._dispatcher.dispatch(new Oi({request:t,features:n,options:i}))},n.prototype._statLogConnection=function(e){this._dispatcher.dispatch(new Q(new Y({type:B.WEBSOCKET_CONNECT,data:{host_url:this.sdkState.websocket.host,success:!e,latency:Date.now()-this._connectingAt,error_code:null==e?void 0:e.code,error_description:null==e?void 0:e.message}})))},n.prototype.connect=function(e){return void 0===e&&(e=""),i(this,void 0,void 0,(function(){var t,n,r=this;return o(this,(function(i){return t=this._url(e),n=new yr,this._connectionRequestQueue.push(n),1===this._connectionRequestQueue.length&&(this._connectingAt=Date.now(),this._loginTimer=setTimeout((function(){r._loginTimer=null,r._dispatcher.dispatch(Ci.asError(E.loginTimeout))}),this.sdkState.websocket.responseTimeout),e&&(this._sessionManager.auth.authToken=e),this._websocketClient.connect(t)),[2,n.promise]}))}))},n.prototype.cancelConnectForRetry=function(){this._dispatcher.dispatch(Ci.asError(E.connectionRenew))},n.prototype.disconnect=function(){return i(this,void 0,void 0,(function(){return o(this,(function(e){switch(e.label){case 0:return[4,this._websocketClient.disconnect()];case 1:return e.sent(),[2]}}))}))},n.prototype.logout=function(){return i(this,void 0,void 0,(function(){return o(this,(function(e){switch(e.label){case 0:return this.sdkState.userId=null,this._unresolvedLogi=null,[4,this._sessionManager.clear()];case 1:return e.sent(),[4,this.disconnect()];case 2:return e.sent(),[2]}}))}))},n.prototype.clearLoginTimer=function(){this._loginTimer&&(clearTimeout(this._loginTimer),this._loginTimer=null)},n}(q),Ni=function(){function e(e,t){var n=t.sdkState,r=t.cacheContext,i=t.connectionHandlers,o=t.sessionManager,s=t.websocketClient,a=t.dispatcher,c=t.logger,u=t.disableWebSocketCloseEventHandling,l=void 0!==u&&u;this._context=null,this._disableWebSocketCloseEventHandling=!1,this._externalCalledWebSocketClose=!1,this._logger=c,this._disableWebSocketCloseEventHandling=l,this._context=new Ai(e,{sdkState:n,cacheContext:r,connectionHandlers:i,sessionManager:o,websocketClient:s,dispatcher:a,logger:c}),this._sdkState=n,this._sessionManager=o,this._websocketClient=s}return e.prototype._registerEventDispatcher=function(){var e=this;this._disableWebSocketCloseEventHandling||(this._clearEventDispatcher(),this._sessionEventDispatcherContext=this._sessionManager.on("refresh-authtoken",(function(){e.isConnected||(e._logger.debug("try reconnect by session token refresh"),e.reconnect())})).on("refresh",(function(){e.isConnecting||e.isConnected||(e._logger.debug("try reconnect by session key refresh"),e.reconnect())})),this._websocketEventDispatcherContext=this._websocketClient.on("close",(function(){"foreground"!==e._sdkState.appState||e._externalCalledWebSocketClose||e._sessionManager.isRefreshingAuthToken||(e._logger.debug("try reconnect by websocket connection closed"),e.reconnect())})))},e.prototype._clearEventDispatcher=function(){this._sessionEventDispatcherContext&&(this._sessionEventDispatcherContext.close(),this._sessionEventDispatcherContext=null),this._websocketEventDispatcherContext&&(this._websocketEventDispatcherContext.close(),this._websocketEventDispatcherContext=null)},Object.defineProperty(e.prototype,"isConnected",{get:function(){return this._context.currentState.type===vr.CONNECTED},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"isConnecting",{get:function(){var e=this._context.currentState;return e.type===vr.CONNECTING||e.type===vr.RECONNECTING},enumerable:!1,configurable:!0}),e.prototype.connect=function(e){return i(this,void 0,void 0,(function(){var t;return o(this,(function(n){switch(n.label){case 0:return t=this._context.currentState,this._externalCalledWebSocketClose=!1,[4,t.onConnect(this._context,e)];case 1:return n.sent(),this._registerEventDispatcher(),[2]}}))}))},e.prototype.reconnect=function(){return i(this,void 0,void 0,(function(){var e;return o(this,(function(t){switch(t.label){case 0:return e=this._context.currentState,this._externalCalledWebSocketClose=!1,[4,e.onReconnect(this._context,{})];case 1:return t.sent(),[2]}}))}))},e.prototype.resetAndReconnect=function(){return i(this,void 0,void 0,(function(){var e;return o(this,(function(t){switch(t.label){case 0:return e=this._context.currentState,this._externalCalledWebSocketClose=!1,[4,e.onReconnect(this._context,{resetReconnectCount:!0})];case 1:return t.sent(),[2]}}))}))},e.prototype.background=function(){return i(this,void 0,void 0,(function(){var e;return o(this,(function(t){switch(t.label){case 0:return e=this._context.currentState,this._externalCalledWebSocketClose=!0,[4,e.onDisconnect(this._context,{autoReconnect:!1})];case 1:return t.sent(),[2]}}))}))},e.prototype.disconnect=function(e){return void 0===e&&(e=null),i(this,void 0,void 0,(function(){return o(this,(function(t){switch(t.label){case 0:return[4,this._context.currentState.onDisconnect(this._context,{error:e,autoReconnect:!0})];case 1:return t.sent(),[2]}}))}))},e.prototype.disconnectWebSocket=function(){return i(this,void 0,void 0,(function(){var e;return o(this,(function(t){switch(t.label){case 0:return e=this._context.currentState,this._externalCalledWebSocketClose=!0,[4,e.onDisconnectWebSocket(this._context)];case 1:return t.sent(),[2]}}))}))},e.prototype.logout=function(){return i(this,void 0,void 0,(function(){var e;return o(this,(function(t){switch(t.label){case 0:return e=this._context.currentState,this._clearEventDispatcher(),[4,e.onLogout(this._context)];case 1:return t.sent(),[2]}}))}))},e}(),Ri=function(e){function n(t){var n,r,i,o,s=t.type,a=t.data,c=t.ts,u=void 0===c?Date.now():c,l=e.call(this,{type:s,data:a,ts:u})||this;return l.date=new Date(u),l.key="".concat((n=l.date,r=n.getFullYear(),i=String(n.getMonth()+1).padStart(2,"0"),o=String(n.getDate()).padStart(2,"0"),"".concat(r).concat(i).concat(o)),"_").concat(s),l}return t(n,e),n}(Y),Ii=function(e){function n(t){var n=t.deviceId,r=t.statLogs,i=e.call(this)||this;return i.method=x.POST,i.path="".concat(qr),i.params={device_id:n,log_entries:r.map((function(e){return Y.payloadify(e)}))},i}return t(n,e),n}(Z),Di=function(e,t){var n,r;if(null!==e&&null!==t){var i=Object.keys(e),o=Object.keys(t),u=c([],a(new Set(c(c([],a(i),!1),a(o),!1))),!1),l={};try{for(var h=s(u),d=h.next();!d.done;d=h.next()){var _=d.value,f=typeof e[_],p=typeof t[_];"undefined"===f?l[_]=t[_]:"undefined"===p?l[_]=e[_]:f!==p?l[_]=t[_]:"object"===f&&e[_]&&t[_]?l[_]=Di(e[_],t[_]):l[_]=t[_]}}catch(e){n={error:e}}finally{try{d&&!d.done&&(r=h.return)&&r.call(h)}finally{if(n)throw n.error}}return l}return t};!function(e){e[e.PENDING=0]="PENDING",e[e.COLLECT_ONLY=1]="COLLECT_ONLY",e[e.ENABLED=2]="ENABLED",e[e.DISABLED=3]="DISABLED"}(wi||(wi={}));var Li,xi=function(e){function n(t){var n=t.cacheContext,r=t.requestQueue,i=t.dispatcher,o=t.baseLimit,s=void 0===o?100:o,a=t.maxLimit,c=void 0===a?1e3:a,u=t.minLimit,l=void 0===u?10:u,h=e.call(this)||this;return h.queue=[],h.enabledState=wi.PENDING,h.isFlushing=!1,h.generation=1,h.lastFlushedAt=0,h.commandEventContext=null,h._collectRequestStat=!0,h._collectFeatureLocalCacheStat=!0,h.deviceId=z(),h.cacheContext=n,h.requestQueue=r,h.dispatcher=i,h.baseLimit=s,h.limit=s,h.maxLimit=c,h.minLimit=l,h}return t(n,e),Object.defineProperty(n.prototype,"isEnabled",{get:function(){return this.enabledState===wi.ENABLED},enumerable:!1,configurable:!0}),n.prototype._arrangeStat=function(){var e=[];this._collectRequestStat&&e.push.apply(e,c([],a(this.queue.filter((function(e){return e.type===B.API_RESULT||e.type===B.WEBSOCKET_CONNECT}))),!1)),this._collectFeatureLocalCacheStat&&e.push.apply(e,c([],a(this.queue.filter((function(e){return e.type===B.FEATURE_LOCALCACHE}))),!1)),this.queue=e},n.prototype._save=function(){return i(this,void 0,void 0,(function(){return o(this,(function(e){switch(e.label){case 0:return this.enabledState!==wi.ENABLED?[3,2]:[4,this.cacheContext.preference.set(this.key,{deviceId:this.deviceId,statLogs:this.queue.map((function(e){return Y.payloadify(e)})),generation:this.generation++,lastFlushedAt:this.lastFlushedAt})];case 1:e.sent(),this.dispatch("save",c([],a(this.queue),!1)),e.label=2;case 2:return[2]}}))}))},n.prototype._flush=function(){return i(this,void 0,void 0,(function(){var e,t,n,r,i;return o(this,(function(o){switch(o.label){case 0:if(!this.isEnabled)return[3,10];if(this.isFlushing)return[3,10];this.isFlushing=!0,o.label=1;case 1:return o.trys.push([1,5,9,10]),this._arrangeStat(),e=this.queue.filter((function(e){if(e instanceof Ri){var t=new Date,n=a([e.date.getFullYear(),t.getFullYear()],2),r=n[0],i=n[1];if(r0?(r=new Ii({deviceId:this.deviceId,statLogs:n}),[4,this.requestQueue.send(r)]):[3,4];case 2:return o.sent(),this.dispatch("flush",n),this.queue=c(c([],a(e),!1),a(t),!1).slice(n.length),[4,this._save()];case 3:o.sent(),o.label=4;case 4:return this.limit=this.baseLimit,this.lastFlushedAt=Date.now(),[3,10];case 5:return(i=o.sent())instanceof E?i.code!==u.STAT_LOG_NOT_ALLOWED?[3,7]:[4,this.clear()]:[3,8];case 6:return o.sent(),this.enabledState=wi.DISABLED,[3,8];case 7:i.code===u.STAT_UPLOAD_NOT_ALLOWED&&(this.enabledState=wi.COLLECT_ONLY),o.label=8;case 8:return this.limit=this.limit+20,[3,10];case 9:return this.isFlushing=!1,[7];case 10:return[2]}}))}))},n.prototype.init=function(e){return i(this,void 0,void 0,(function(){var t,n,r=this;return o(this,(function(i){switch(i.label){case 0:return this.key=e,[4,this.cacheContext.preference.get(this.key)];case 1:return(t=i.sent())?(this.deviceId=t.deviceId,this.queue=t.statLogs.map((function(e){return new Y({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,Vr(n)]):[3,4]):[3,4];case 2:return i.sent(),[4,this._flush()];case 3:i.sent(),i.label=4;case 4:return this.commandEventContext||(this.commandEventContext=this.dispatcher.on((function(e){if(e instanceof Q){var t=e.statLog;r.put(t)}else if(e instanceof Oi){var n=e.request,i=e.features,o=e.options;r._collectRequestStat=n,r._collectFeatureLocalCacheStat=null==i?void 0:i.localCache,r._arrangeStat(),r._collectRequestStat||r._collectFeatureLocalCacheStat?r.enabledState=o.ingestion?wi.ENABLED:wi.COLLECT_ONLY:r.enabledState=wi.DISABLED,r.isEnabled?r.queue.length>=r.limit&&r._flush():r.clear()}}))),[2]}}))}))},n.prototype.put=function(e){return i(this,void 0,void 0,(function(){var t,n;return o(this,(function(r){switch(r.label){case 0:return this.enabledState===wi.DISABLED?[3,3]:(e instanceof Ri?this._collectFeatureLocalCacheStat&&(t=a(this.queue.filter((function(t){return t instanceof Ri&&t.key===e.key})),1),(n=t[0])?n.data=Di(n.data,e.data):this.queue.push(e)):this._collectRequestStat&&this.queue.push(e),[4,this._save()]);case 1:return r.sent(),this.queue.length>=this.limit?[4,this._flush()]:[3,3];case 2:r.sent(),r.label=3;case 3:return[2]}}))}))},n.prototype.clear=function(){return i(this,void 0,void 0,(function(){return o(this,(function(e){switch(e.label){case 0:return this.queue=[],this.generation=1,[4,this._save()];case 1:return e.sent(),[2]}}))}))},n.prototype.close=function(){this.commandEventContext&&(this.commandEventContext.close(),this.commandEventContext=null)},n}(q);!function(e){e[e.NONE=0]="NONE",e[e.VERBOSE=1]="VERBOSE",e[e.DEBUG=2]="DEBUG",e[e.INFO=3]="INFO",e[e.WARN=4]="WARN",e[e.ERROR=5]="ERROR"}(Li||(Li={}));var Mi,Ui,Pi,zi,Fi,qi,Gi,ji,Ki,Bi,Zi=function(){function e(){this.level=Li.WARN}return e.prototype.verbose=function(){for(var e=[],t=0;t0})).map((function(e){return e.id}))),this.allowUserSuggestion=null!==(a=e.allow_user_suggestion)&&void 0!==a?a:this.allowUserSuggestion,this.allowMultipleVotes=null!==(c=e.allow_multiple_votes)&&void 0!==c?c:this.allowMultipleVotes},r.payloadify=function(t){return t?K(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 eo.payloadify(e)})),created_by:t.createdBy,allow_user_suggestion:t.allowUserSuggestion,allow_multiple_votes:t.allowMultipleVotes,voted_option_ids:t.votedPollOptionIds})):null},r.prototype.applyPollUpdateEvent=function(e){var t=e._payload.poll;return!(!t||this.id!==t.id||t.updated_at-1){var o=t[r];i>=o._lastVotedAt&&(o.voteCount=e.vote_count,o._lastVotedAt=i)}})),r.req_id&&r.voted_option_ids&&(this.votedPollOptionIds=r.voted_option_ids),!0},r.prototype.serialize=function(){return bi(this)},r}(hi),no=function(e){switch(e){case ji.GROUP:return Rr;case ji.OPEN:return Dr;default:return null}},ro=function(e){switch(e){case ji.GROUP:return"".concat(Mr,"/group_channels");case ji.OPEN:return"".concat(Mr,"/open_channels");default:return null}},io=function(e,t,n){var r,i;switch(e){case zi.CHANNEL:return!0;case zi.USERS:if(t)try{for(var o=s(t),a=o.next();!a.done;a=o.next()){if(a.value===n)return!0}}catch(e){r={error:e}}finally{try{a&&!a.done&&(i=o.return)&&i.call(o)}finally{if(r)throw r.error}}}return!1},oo=function(e,t,n){var r=io(e.mentionType,e.mentionedUserIds,n),i=io(t.mentionType,t.mentionedUserIds,n);return!r&&i?1:r&&!i?-1:0};!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"}(Qi||(Qi={}));var so=function(e){return e.startsWith("EVENT_")||e===Qi.SYNC_MESSAGE_FILL||e===Qi.SYNC_MESSAGE_CHANGELOGS||e===Qi.SYNC_POLL_CHANGELOGS},ao=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}(j),co=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}(j),uo=function(e){function n(t){var n=t.reqId,r=t.source,i=e.call(this)||this;return i.reqId=n,i.source=r,i}return t(n,e),n}(j),lo=function(e){function n(t){var n=t.polls,r=t.source,i=e.call(this)||this;return i.polls=n,i.source=r,i}return t(n,e),n}(j),ho=function(e){function n(t){var n=t.event,r=t.source,i=e.call(this)||this;return i.event=n,i.source=r,i}return t(n,e),n}(j),_o=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}(j),fo=function(){function e(e,t){var n;this._iid=null,this.limit=20,this._isLoading=!1,this._hasNext=!0,this._token="",this._iid=e,this.limit=null!==(n=t.limit)&&void 0!==n?n:20}return Object.defineProperty(e.prototype,"hasNext",{get:function(){return this._hasNext},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"isLoading",{get:function(){return this._isLoading},enumerable:!1,configurable:!0}),e.prototype._validate=function(){return w("number",this.limit)&&this.limit>0},e}(),po=function(e){function n(t,n,r,i){var o=e.call(this,t,i)||this;return o.channelUrl=n,o.channelType=r,o}return t(n,e),n.prototype._validate=function(){return e.prototype._validate.call(this)&&w("string",this.channelUrl)&&S(ji,this.channelType)},n}(fo);export{bi as $,x as A,fo as B,pr as C,Ti as D,q as E,d as F,Yr as G,s as H,S as I,_ as J,p as K,U as L,ji as M,M as N,Li as O,f as P,Ei as Q,Ki as R,E as S,Nr as T,Si as U,Hi as V,$ as W,hi as X,y as Y,Mi as Z,t as _,w as a,zi as a0,Gi as a1,C as a2,Ui as a3,to as a4,qi as a5,br as a6,no as a7,io as a8,u as a9,N as aA,ho as aB,uo as aC,Ir as aD,Fr as aE,Yi as aF,so as aG,Ri as aH,B as aI,Wr as aJ,Xi as aK,Lr as aL,Dr as aM,Vr as aa,yr as ab,Fi as ac,Rr as ad,Qi as ae,ao as af,co as ag,xr as ah,po as ai,Wi as aj,eo as ak,Bi as al,j as am,O as an,I as ao,r as ap,zr as aq,$i as ar,Ji as as,lo as at,ro as au,Mr as av,oo as aw,Pi as ax,v as ay,_o as az,i as b,o as c,Ar as d,K as e,Z as f,n as g,V as h,A as i,Pr as j,Ur as k,T as l,R as m,ee as n,X as o,c as p,a as q,yi as r,mi as s,Sr as t,z as u,l as v,vr as w,Qr as x,mr as y,ki 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!==a[0]&&2!==a[0])){s=0;continue}if(3===a[0]&&(!i||a[1]>i[0]&&a[1]=e.length&&(e=void 0),{value:e&&e[r++],done:!e}}};throw new TypeError(t?"Object is not iterable.":"Symbol.iterator is not defined.")}function a(e,t){var n="function"==typeof Symbol&&e[Symbol.iterator];if(!n)return e;var r,i,o=n.call(e),s=[];try{for(;(void 0===t||t-- >0)&&!(r=o.next()).done;)s.push(r.value)}catch(e){i={error:e}}finally{try{r&&!r.done&&(n=o.return)&&n.call(o)}finally{if(i)throw i.error}}return s}function c(e,t,n){if(n||2===arguments.length)for(var r,i=0,o=t.length;i0&&b.indexOf(e)>=0},O=function(e){return e>0&&m.indexOf(e)>=0},A=function(e,t){if(void 0===t&&(t=!1),t&&null===e)return!0;var n=w("object",e)&&null!==e&&e.hasOwnProperty("name")&&"string"==typeof e.name&&e.hasOwnProperty("uri")&&"string"==typeof e.uri&&e.hasOwnProperty("type")&&"string"==typeof e.type;if(!n){if("undefined"!=typeof Blob)return e instanceof Blob;if("undefined"!=typeof File)return e instanceof File}return n},N=function(e,t){if(e===t)return!0;if(null==e||null==t)return!1;if(e.length!==t.length)return!1;for(var n=c([],a(e),!1).sort(),r=c([],a(t),!1).sort(),i=0;i=1e3&&e<=9e3&&(this._typingIndicatorThrottle=e)},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"websocketResponseTimeout",{get:function(){return this._websocketResponseTimeout},set:function(e){w("number",e)&&e>=5e3&&e<=3e4&&(this._websocketResponseTimeout=e)},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"sessionTokenRefreshTimeout",{get:function(){return this._sessionTokenRefreshTimeout},set:function(e){w("number",e)&&(e<60?e=60:e>1800&&(e=1800),this._sessionTokenRefreshTimeout=e)},enumerable:!1,configurable:!0}),e}(),I={encrypt:function(e){return e},decrypt:function(e){return e}},D=function(){function e(e){var t=e.store;this._preference=new Map,this._store=t}return e.prototype._savePreferenceKeys=function(){return i(this,void 0,void 0,(function(){return o(this,(function(e){switch(e.label){case 0:return[4,this._store.set({key:this._keysAddress,value:c([],a(this._preference.keys()),!1),generation:1})];case 1:return e.sent(),[2]}}))}))},e.prototype.init=function(e,t){var n;return void 0===t&&(t=1),i(this,void 0,void 0,(function(){var r,i,a,c,u,l,h,d,_,f;return o(this,(function(o){switch(o.label){case 0:return this._version=t,this._keysAddress=e,r="".concat(e,".metadata.version"),[4,this._store.get(r)];case 1:return i=o.sent(),[4,this._store.get(e)];case 2:return a=null!==(n=o.sent())&&void 0!==n?n:[],!i||i.versiont.channel.messageCollectionLastAccessedAt?1:-1},this._maxSize=Math.max(r,64),a?(this._clearOrder=o,this._customClearOrderComparator=a):this._clearOrder=g.MESSAGE_COLLECTION_ACCESSED_AT}return Object.defineProperty(e.prototype,"maxSize",{get:function(){return this._maxSize},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"clearOrder",{get:function(){return this._clearOrder},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"clearOrderComparator",{get:function(){var e;return this._clearOrder===g.MESSAGE_COLLECTION_ACCESSED_AT?this._clearOrderComparatorUseMessageCollectionAccessedAt:null!==(e=this._customClearOrderComparator)&&void 0!==e?e:this._clearOrderComparatorUseMessageCollectionAccessedAt},enumerable:!1,configurable:!0}),e}(),P=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}(),z=function(){var e=(new Date).getTime();return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,(function(t){var n=(e+16*Math.random())%16|0;return e=Math.floor(e/16),("x"===t?n:3&n|8).toString(16)}))},F=function(){function e(e){var t=e.container;this._container={},this._container=t,this.key=z()}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}(),q=function(){function e(){this._container={}}return e.prototype.on=function(e,t){return new F({container:this._container}).on(e,t)},e.prototype.once=function(e,t){return new F({container:this._container}).once(e,t)},e.prototype.dispatch=function(e,t){var n,r,i=this._container[e];if(i){var o=[];try{for(var a=s(i.keys()),c=a.next();!c.done;c=a.next()){var u=c.value,l=i.get(u);l.handler(t),l.occurence>0&&(l.occurence--,0===l.occurence&&o.push(u))}}catch(e){n={error:e}}finally{try{c&&!c.done&&(r=a.return)&&r.call(a)}finally{if(n)throw n.error}}o.forEach((function(e){return i.delete(e)}))}},e}(),G=function(){function e(){this._dispatcher=new q}return e.prototype.on=function(e){return this._dispatcher.on("event",e)},e.prototype.once=function(e){return this._dispatcher.once("event",e)},e.prototype.dispatch=function(e){this._dispatcher.dispatch("event",e)},e}(),j=function(){},K=function(e){var t={};return e&&Object.keys(e).forEach((function(n){void 0===e[n]||Number.isNaN(e[n])||null===e[n]||(t[n]=e[n])})),t};!function(e){e.GET="GET",e.POST="POST",e.PUT="PUT",e.DELETE="DELETE"}(x||(x={}));var B,Z=function(e){function n(){var t=null!==e&&e.apply(this,arguments)||this;return t.params={},t.requireAuth=!0,t.headers={},t.requestId=z(),t}return t(n,e),n.prototype.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=K(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=K(this.params);if(Object.keys(t).some((function(e){return A(t[e])}))){var n=new FormData;return Object.keys(t).forEach((function(r){var i,o=t[r];if(A(o)){var s=o;n.append(r,s,null!==(i=s.name)&&void 0!==i?i:"filename")}else n.append(r,e.stringifyParams(o))})),n}return JSON.stringify(t)},enumerable:!1,configurable:!0}),n}(j),V=function(e){function r(t,n){var r=e.call(this)||this;return r._iid=t,r._payload=n,r}return t(r,e),Object.defineProperty(r.prototype,"payload",{get:function(){return n({},this._payload)},enumerable:!1,configurable:!0}),r.prototype.as=function(e){return new e(this._iid,this.payload)},r}(j),H=function(e){function n(t){var n=e.call(this)||this;return n.requestId=t,n}return t(n,e),n}(j),W=function(e){function n(){return null!==e&&e.apply(this,arguments)||this}return t(n,e),n}(j),Q=function(e){function n(t){var n=e.call(this)||this;return n.statLog=t,n}return t(n,e),n}(j);!function(e){e.FEATURE_LOCALCACHE="feature:local_cache",e.WEBSOCKET_CONNECT="ws:connect",e.API_RESULT="api:result"}(B||(B={}));var Y=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 K({stat_type:e.type,ts:e.createdAt,data:K(e.data)})},e}(),X=function(){return"undefined"==typeof document&&"undefined"!=typeof navigator&&"ReactNative"==navigator.product},J=function(){function e(e,t){var n=t.auth,r=t.sdkState,i=t.dispatcher,o=t.logger,s=t.useFetchCompat,a=void 0!==s&&s,c=this;this._abortControl=new Map,this._shouldImportFetchCompat=!1,this._iid=e,this._auth=n,this._sdkState=r,this._dispatcher=i,this._dispatcher.on((function(e){e instanceof H&&c.cancel(e.requestId)})),this._logger=o,this._shouldImportFetchCompat=a}return Object.defineProperty(e.prototype,"_userAgentWithExtension",{get:function(){var e=this._sdkState.extensions,t=X()?"reactnative":"JS",n=e.sb_syncmanager?"s".concat(e.sb_syncmanager):"",r=e.sb_uikit?"u".concat(e.sb_uikit):"",i=e["device-os-platform"]?"o".concat(e["device-os-platform"]):"";return"".concat(t,"/c").concat(h.SDK_VERSION,"/").concat(n,"/").concat(r,"/").concat(i)},enumerable:!1,configurable:!0}),e.prototype._createHeader=function(e,t){void 0===t&&(t=null);var r=this._sdkState,i=r.appId,o=r.appVersion,s=n(n({},e.headers),{SendBird:"JS,".concat(h.OS_VERSION,",").concat(h.SDK_VERSION,",").concat(i).concat(o?",".concat(o):""),"SB-User-Agent":encodeURIComponent(this._userAgentWithExtension),"Request-Sent-Timestamp":Date.now().toString()});return t||(s["Content-Type"]="application/json; charset=utf-8"),e.requireAuth&&this._auth.hasSession&&(s["Session-Key"]=this._auth.sessionKey),this._auth&&this._auth.authToken&&(s["App-Id"]=i,s["Access-Token"]=this._auth.authToken),s},e.prototype._statLogApiResult=function(e,t,n){this._dispatcher.dispatch(new Q(new Y({type:B.API_RESULT,data:{endpoint:e.path,method:e.method,success:!n,latency:Date.now()-t,error_code:null==n?void 0:n.code,error_description:null==n?void 0:n.message}})))},e.prototype.send=function(e){return i(this,void 0,void 0,(function(){var t,n,r,i,s,a,c,u,l,h,d,_,f,p,g;return o(this,(function(o){switch(o.label){case 0:t=e.path,n=e.method,r=![x.GET,x.DELETE].includes(n),i=this._sdkState.api,s="".concat(i.host).concat(t).concat(r?"":e.query),a=r?e.payload:null,c=this._createHeader(e,a instanceof FormData?a:null),u=new AbortController,l=u.signal,this._abortControl.set(e.requestId,u),h=Date.now(),o.label=1;case 1:return o.trys.push([1,8,,9]),this._shouldImportFetchCompat&&(this._shouldImportFetchCompat=!1,("undefined"!=typeof globalThis&&globalThis||"undefined"!=typeof self&&self||"undefined"!=typeof global&&global||{fetch:null}).fetch=void 0),"undefined"!=typeof AbortController?[3,3]:[4,import("./__bundle-4a640e46.js")];case 2:o.sent(),o.label=3;case 3:return"function"==typeof fetch?[3,5]:[4,import("./__bundle-53e684a6.js")];case 4:o.sent(),o.label=5;case 5:return[4,fetch(s,{method:n,body:a,headers:c,signal:l})];case 6:return[4,(d=o.sent()).json()];case 7:if(_=o.sent(),d.ok||d.redirected)return this._logger.debug("receive api response",e.requestId),this._statLogApiResult(e,h,null),[2,new V(this._iid,_)];throw _?(f=new E(_),!e.requireAuth&&f.isSessionKeyExpiredError&&this._dispatcher.dispatch(new W),this._statLogApiResult(e,h,f),f):(f=E.requestFailed,this._statLogApiResult(e,h,f),f);case 8:throw p=o.sent(),this._statLogApiResult(e,h,p),p instanceof E?(this._logger.debug("fail api request",p),p):"AbortError"===p.name?E.requestCanceled:(g=E.networkError,this._logger.debug("fail api request",g),g);case 9:return[2]}}))}))},e.prototype.cancel=function(e){this._abortControl.has(e)&&(this._abortControl.get(e).abort(),this._abortControl.delete(e))},e.prototype.cancelAll=function(){var e,t;try{for(var n=s(this._abortControl.values()),r=n.next();!r.done;r=n.next()){r.value.abort()}}catch(t){e={error:t}}finally{try{r&&!r.done&&(t=n.return)&&t.call(n)}finally{if(e)throw e.error}}this._abortControl.clear()},e}(),$=function(e){function n(t,n,r,i){void 0===i&&(i="");var o=e.call(this)||this;return o._iid=t,o.code=n,o.payload=r,o.requestId=r?r.req_id:i,o}return t(n,e),n.createFromRawMessage=function(e,t){var r=t.substring(0,4),i=null;try{i=JSON.parse(t.substring(4))}catch(e){r="NOOP"}finally{return new n(e,r,i)}},n.prototype.convertToMessage=function(){return"".concat(this.code).concat(JSON.stringify(this.payload),"\n")},n.prototype.as=function(e){return new e(this._iid,this.code,this.payload)},n}(j),ee=function(){};function te(e){let t=e.length;for(;--t>=0;)e[t]=0}const ne=256,re=286,ie=30,oe=15,se=new Uint8Array([0,0,0,0,0,0,0,0,1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4,5,5,5,5,0]),ae=new Uint8Array([0,0,0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9,9,10,10,11,11,12,12,13,13]),ce=new Uint8Array([0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,3,7]),ue=new Uint8Array([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),le=new Array(576);te(le);const he=new Array(60);te(he);const de=new Array(512);te(de);const _e=new Array(256);te(_e);const fe=new Array(29);te(fe);const pe=new Array(ie);function ge(e,t,n,r,i){this.static_tree=e,this.extra_bits=t,this.extra_base=n,this.elems=r,this.max_length=i,this.has_stree=e&&e.length}let ve,Ee,be;function me(e,t){this.dyn_tree=e,this.max_code=0,this.stat_desc=t}te(pe);const ye=e=>e<256?de[e]:de[256+(e>>>7)],we=(e,t)=>{e.pending_buf[e.pending++]=255&t,e.pending_buf[e.pending++]=t>>>8&255},Se=(e,t,n)=>{e.bi_valid>16-n?(e.bi_buf|=t<>16-e.bi_valid,e.bi_valid+=n-16):(e.bi_buf|=t<{Se(e,n[2*t],n[2*t+1])},Te=(e,t)=>{let n=0;do{n|=1&e,e>>>=1,n<<=1}while(--t>0);return n>>>1},Ce=(e,t,n)=>{const r=new Array(16);let i,o,s=0;for(i=1;i<=oe;i++)s=s+n[i-1]<<1,r[i]=s;for(o=0;o<=t;o++){let t=e[2*o+1];0!==t&&(e[2*o]=Te(r[t]++,t))}},Oe=e=>{let t;for(t=0;t{e.bi_valid>8?we(e,e.bi_buf):e.bi_valid>0&&(e.pending_buf[e.pending++]=e.bi_buf),e.bi_buf=0,e.bi_valid=0},Ne=(e,t,n,r)=>{const i=2*t,o=2*n;return e[i]{const r=e.heap[n];let i=n<<1;for(;i<=e.heap_len&&(i{let r,i,o,s,a=0;if(0!==e.sym_next)do{r=255&e.pending_buf[e.sym_buf+a++],r+=(255&e.pending_buf[e.sym_buf+a++])<<8,i=e.pending_buf[e.sym_buf+a++],0===r?ke(e,i,t):(o=_e[i],ke(e,o+ne+1,t),s=se[o],0!==s&&(i-=fe[o],Se(e,i,s)),r--,o=ye(r),ke(e,o,n),s=ae[o],0!==s&&(r-=pe[o],Se(e,r,s)))}while(a{const n=t.dyn_tree,r=t.stat_desc.static_tree,i=t.stat_desc.has_stree,o=t.stat_desc.elems;let s,a,c,u=-1;for(e.heap_len=0,e.heap_max=573,s=0;s>1;s>=1;s--)Re(e,n,s);c=o;do{s=e.heap[1],e.heap[1]=e.heap[e.heap_len--],Re(e,n,1),a=e.heap[1],e.heap[--e.heap_max]=s,e.heap[--e.heap_max]=a,n[2*c]=n[2*s]+n[2*a],e.depth[c]=(e.depth[s]>=e.depth[a]?e.depth[s]:e.depth[a])+1,n[2*s+1]=n[2*a+1]=c,e.heap[1]=c++,Re(e,n,1)}while(e.heap_len>=2);e.heap[--e.heap_max]=e.heap[1],((e,t)=>{const n=t.dyn_tree,r=t.max_code,i=t.stat_desc.static_tree,o=t.stat_desc.has_stree,s=t.stat_desc.extra_bits,a=t.stat_desc.extra_base,c=t.stat_desc.max_length;let u,l,h,d,_,f,p=0;for(d=0;d<=oe;d++)e.bl_count[d]=0;for(n[2*e.heap[e.heap_max]+1]=0,u=e.heap_max+1;u<573;u++)l=e.heap[u],d=n[2*n[2*l+1]+1]+1,d>c&&(d=c,p++),n[2*l+1]=d,l>r||(e.bl_count[d]++,_=0,l>=a&&(_=s[l-a]),f=n[2*l],e.opt_len+=f*(d+_),o&&(e.static_len+=f*(i[2*l+1]+_)));if(0!==p){do{for(d=c-1;0===e.bl_count[d];)d--;e.bl_count[d]--,e.bl_count[d+1]+=2,e.bl_count[c]--,p-=2}while(p>0);for(d=c;0!==d;d--)for(l=e.bl_count[d];0!==l;)h=e.heap[--u],h>r||(n[2*h+1]!==d&&(e.opt_len+=(d-n[2*h+1])*n[2*h],n[2*h+1]=d),l--)}})(e,t),Ce(n,u,e.bl_count)},Le=(e,t,n)=>{let r,i,o=-1,s=t[1],a=0,c=7,u=4;for(0===s&&(c=138,u=3),t[2*(n+1)+1]=65535,r=0;r<=n;r++)i=s,s=t[2*(r+1)+1],++a{let r,i,o=-1,s=t[1],a=0,c=7,u=4;for(0===s&&(c=138,u=3),r=0;r<=n;r++)if(i=s,s=t[2*(r+1)+1],!(++a{Se(e,0+(r?1:0),3),Ae(e),we(e,n),we(e,~n),n&&e.pending_buf.set(e.window.subarray(t,t+n),e.pending),e.pending+=n};var Pe=(e,t,n,r)=>{let i,o,s=0;e.level>0?(2===e.strm.data_type&&(e.strm.data_type=(e=>{let t,n=4093624447;for(t=0;t<=31;t++,n>>>=1)if(1&n&&0!==e.dyn_ltree[2*t])return 0;if(0!==e.dyn_ltree[18]||0!==e.dyn_ltree[20]||0!==e.dyn_ltree[26])return 1;for(t=32;t{let t;for(Le(e,e.dyn_ltree,e.l_desc.max_code),Le(e,e.dyn_dtree,e.d_desc.max_code),De(e,e.bl_desc),t=18;t>=3&&0===e.bl_tree[2*ue[t]+1];t--);return e.opt_len+=3*(t+1)+5+5+4,t})(e),i=e.opt_len+3+7>>>3,o=e.static_len+3+7>>>3,o<=i&&(i=o)):i=o=n+5,n+4<=i&&-1!==t?Ue(e,t,n,r):4===e.strategy||o===i?(Se(e,2+(r?1:0),3),Ie(e,le,he)):(Se(e,4+(r?1:0),3),((e,t,n,r)=>{let i;for(Se(e,t-257,5),Se(e,n-1,5),Se(e,r-4,4),i=0;i{Me||((()=>{let e,t,n,r,i;const o=new Array(16);for(n=0,r=0;r<28;r++)for(fe[r]=n,e=0;e<1<>=7;r(e.pending_buf[e.sym_buf+e.sym_next++]=t,e.pending_buf[e.sym_buf+e.sym_next++]=t>>8,e.pending_buf[e.sym_buf+e.sym_next++]=n,0===t?e.dyn_ltree[2*n]++:(e.matches++,t--,e.dyn_ltree[2*(_e[n]+ne+1)]++,e.dyn_dtree[2*ye(t)]++),e.sym_next===e.sym_end),_tr_align:e=>{Se(e,2,3),ke(e,256,le),(e=>{16===e.bi_valid?(we(e,e.bi_buf),e.bi_buf=0,e.bi_valid=0):e.bi_valid>=8&&(e.pending_buf[e.pending++]=255&e.bi_buf,e.bi_buf>>=8,e.bi_valid-=8)})(e)}};var Fe=(e,t,n,r)=>{let i=65535&e|0,o=e>>>16&65535|0,s=0;for(;0!==n;){s=n>2e3?2e3:n,n-=s;do{i=i+t[r++]|0,o=o+i|0}while(--s);i%=65521,o%=65521}return i|o<<16|0};const qe=new Uint32Array((()=>{let e,t=[];for(var n=0;n<256;n++){e=n;for(var r=0;r<8;r++)e=1&e?3988292384^e>>>1:e>>>1;t[n]=e}return t})());var Ge=(e,t,n,r)=>{const i=qe,o=r+n;e^=-1;for(let n=r;n>>8^i[255&(e^t[n])];return-1^e},je={2:"need dictionary",1:"stream end",0:"","-1":"file error","-2":"stream error","-3":"data error","-4":"insufficient memory","-5":"buffer error","-6":"incompatible version"},Ke={Z_NO_FLUSH:0,Z_PARTIAL_FLUSH:1,Z_SYNC_FLUSH:2,Z_FULL_FLUSH:3,Z_FINISH:4,Z_BLOCK:5,Z_TREES:6,Z_OK:0,Z_STREAM_END:1,Z_NEED_DICT:2,Z_ERRNO:-1,Z_STREAM_ERROR:-2,Z_DATA_ERROR:-3,Z_MEM_ERROR:-4,Z_BUF_ERROR:-5,Z_NO_COMPRESSION:0,Z_BEST_SPEED:1,Z_BEST_COMPRESSION:9,Z_DEFAULT_COMPRESSION:-1,Z_FILTERED:1,Z_HUFFMAN_ONLY:2,Z_RLE:3,Z_FIXED:4,Z_DEFAULT_STRATEGY:0,Z_BINARY:0,Z_TEXT:1,Z_UNKNOWN:2,Z_DEFLATED:8};const{_tr_init:Be,_tr_stored_block:Ze,_tr_flush_block:Ve,_tr_tally:He,_tr_align:We}=ze,{Z_NO_FLUSH:Qe,Z_PARTIAL_FLUSH:Ye,Z_FULL_FLUSH:Xe,Z_FINISH:Je,Z_BLOCK:$e,Z_OK:et,Z_STREAM_END:tt,Z_STREAM_ERROR:nt,Z_DATA_ERROR:rt,Z_BUF_ERROR:it,Z_DEFAULT_COMPRESSION:ot,Z_FILTERED:st,Z_HUFFMAN_ONLY:at,Z_RLE:ct,Z_FIXED:ut,Z_DEFAULT_STRATEGY:lt,Z_UNKNOWN:ht,Z_DEFLATED:dt}=Ke,_t=258,ft=262,pt=42,gt=113,vt=666,Et=(e,t)=>(e.msg=je[t],t),bt=e=>2*e-(e>4?9:0),mt=e=>{let t=e.length;for(;--t>=0;)e[t]=0},yt=e=>{let t,n,r,i=e.w_size;t=e.hash_size,r=t;do{n=e.head[--r],e.head[r]=n>=i?n-i:0}while(--t);t=i,r=t;do{n=e.prev[--r],e.prev[r]=n>=i?n-i:0}while(--t)};let wt=(e,t,n)=>(t<{const t=e.state;let n=t.pending;n>e.avail_out&&(n=e.avail_out),0!==n&&(e.output.set(t.pending_buf.subarray(t.pending_out,t.pending_out+n),e.next_out),e.next_out+=n,t.pending_out+=n,e.total_out+=n,e.avail_out-=n,t.pending-=n,0===t.pending&&(t.pending_out=0))},kt=(e,t)=>{Ve(e,e.block_start>=0?e.block_start:-1,e.strstart-e.block_start,t),e.block_start=e.strstart,St(e.strm)},Tt=(e,t)=>{e.pending_buf[e.pending++]=t},Ct=(e,t)=>{e.pending_buf[e.pending++]=t>>>8&255,e.pending_buf[e.pending++]=255&t},Ot=(e,t,n,r)=>{let i=e.avail_in;return i>r&&(i=r),0===i?0:(e.avail_in-=i,t.set(e.input.subarray(e.next_in,e.next_in+i),n),1===e.state.wrap?e.adler=Fe(e.adler,t,i,n):2===e.state.wrap&&(e.adler=Ge(e.adler,t,i,n)),e.next_in+=i,e.total_in+=i,i)},At=(e,t)=>{let n,r,i=e.max_chain_length,o=e.strstart,s=e.prev_length,a=e.nice_match;const c=e.strstart>e.w_size-ft?e.strstart-(e.w_size-ft):0,u=e.window,l=e.w_mask,h=e.prev,d=e.strstart+_t;let _=u[o+s-1],f=u[o+s];e.prev_length>=e.good_match&&(i>>=2),a>e.lookahead&&(a=e.lookahead);do{if(n=t,u[n+s]===f&&u[n+s-1]===_&&u[n]===u[o]&&u[++n]===u[o+1]){o+=2,n++;do{}while(u[++o]===u[++n]&&u[++o]===u[++n]&&u[++o]===u[++n]&&u[++o]===u[++n]&&u[++o]===u[++n]&&u[++o]===u[++n]&&u[++o]===u[++n]&&u[++o]===u[++n]&&os){if(e.match_start=t,s=r,r>=a)break;_=u[o+s-1],f=u[o+s]}}}while((t=h[t&l])>c&&0!=--i);return s<=e.lookahead?s:e.lookahead},Nt=e=>{const t=e.w_size;let n,r,i;do{if(r=e.window_size-e.lookahead-e.strstart,e.strstart>=t+(t-ft)&&(e.window.set(e.window.subarray(t,t+t-r),0),e.match_start-=t,e.strstart-=t,e.block_start-=t,e.insert>e.strstart&&(e.insert=e.strstart),yt(e),r+=t),0===e.strm.avail_in)break;if(n=Ot(e.strm,e.window,e.strstart+e.lookahead,r),e.lookahead+=n,e.lookahead+e.insert>=3)for(i=e.strstart-e.insert,e.ins_h=e.window[i],e.ins_h=wt(e,e.ins_h,e.window[i+1]);e.insert&&(e.ins_h=wt(e,e.ins_h,e.window[i+3-1]),e.prev[i&e.w_mask]=e.head[e.ins_h],e.head[e.ins_h]=i,i++,e.insert--,!(e.lookahead+e.insert<3)););}while(e.lookahead{let n,r,i,o=e.pending_buf_size-5>e.w_size?e.w_size:e.pending_buf_size-5,s=0,a=e.strm.avail_in;do{if(n=65535,i=e.bi_valid+42>>3,e.strm.avail_outr+e.strm.avail_in&&(n=r+e.strm.avail_in),n>i&&(n=i),n>8,e.pending_buf[e.pending-2]=~n,e.pending_buf[e.pending-1]=~n>>8,St(e.strm),r&&(r>n&&(r=n),e.strm.output.set(e.window.subarray(e.block_start,e.block_start+r),e.strm.next_out),e.strm.next_out+=r,e.strm.avail_out-=r,e.strm.total_out+=r,e.block_start+=r,n-=r),n&&(Ot(e.strm,e.strm.output,e.strm.next_out,n),e.strm.next_out+=n,e.strm.avail_out-=n,e.strm.total_out+=n)}while(0===s);return a-=e.strm.avail_in,a&&(a>=e.w_size?(e.matches=2,e.window.set(e.strm.input.subarray(e.strm.next_in-e.w_size,e.strm.next_in),0),e.strstart=e.w_size,e.insert=e.strstart):(e.window_size-e.strstart<=a&&(e.strstart-=e.w_size,e.window.set(e.window.subarray(e.w_size,e.w_size+e.strstart),0),e.matches<2&&e.matches++,e.insert>e.strstart&&(e.insert=e.strstart)),e.window.set(e.strm.input.subarray(e.strm.next_in-a,e.strm.next_in),e.strstart),e.strstart+=a,e.insert+=a>e.w_size-e.insert?e.w_size-e.insert:a),e.block_start=e.strstart),e.high_wateri&&e.block_start>=e.w_size&&(e.block_start-=e.w_size,e.strstart-=e.w_size,e.window.set(e.window.subarray(e.w_size,e.w_size+e.strstart),0),e.matches<2&&e.matches++,i+=e.w_size,e.insert>e.strstart&&(e.insert=e.strstart)),i>e.strm.avail_in&&(i=e.strm.avail_in),i&&(Ot(e.strm,e.window,e.strstart,i),e.strstart+=i,e.insert+=i>e.w_size-e.insert?e.w_size-e.insert:i),e.high_water>3,i=e.pending_buf_size-i>65535?65535:e.pending_buf_size-i,o=i>e.w_size?e.w_size:i,r=e.strstart-e.block_start,(r>=o||(r||t===Je)&&t!==Qe&&0===e.strm.avail_in&&r<=i)&&(n=r>i?i:r,s=t===Je&&0===e.strm.avail_in&&n===r?1:0,Ze(e,e.block_start,n,s),e.block_start+=n,St(e.strm)),s?3:1)},It=(e,t)=>{let n,r;for(;;){if(e.lookahead=3&&(e.ins_h=wt(e,e.ins_h,e.window[e.strstart+3-1]),n=e.prev[e.strstart&e.w_mask]=e.head[e.ins_h],e.head[e.ins_h]=e.strstart),0!==n&&e.strstart-n<=e.w_size-ft&&(e.match_length=At(e,n)),e.match_length>=3)if(r=He(e,e.strstart-e.match_start,e.match_length-3),e.lookahead-=e.match_length,e.match_length<=e.max_lazy_match&&e.lookahead>=3){e.match_length--;do{e.strstart++,e.ins_h=wt(e,e.ins_h,e.window[e.strstart+3-1]),n=e.prev[e.strstart&e.w_mask]=e.head[e.ins_h],e.head[e.ins_h]=e.strstart}while(0!=--e.match_length);e.strstart++}else e.strstart+=e.match_length,e.match_length=0,e.ins_h=e.window[e.strstart],e.ins_h=wt(e,e.ins_h,e.window[e.strstart+1]);else r=He(e,0,e.window[e.strstart]),e.lookahead--,e.strstart++;if(r&&(kt(e,!1),0===e.strm.avail_out))return 1}return e.insert=e.strstart<2?e.strstart:2,t===Je?(kt(e,!0),0===e.strm.avail_out?3:4):e.sym_next&&(kt(e,!1),0===e.strm.avail_out)?1:2},Dt=(e,t)=>{let n,r,i;for(;;){if(e.lookahead=3&&(e.ins_h=wt(e,e.ins_h,e.window[e.strstart+3-1]),n=e.prev[e.strstart&e.w_mask]=e.head[e.ins_h],e.head[e.ins_h]=e.strstart),e.prev_length=e.match_length,e.prev_match=e.match_start,e.match_length=2,0!==n&&e.prev_length4096)&&(e.match_length=2)),e.prev_length>=3&&e.match_length<=e.prev_length){i=e.strstart+e.lookahead-3,r=He(e,e.strstart-1-e.prev_match,e.prev_length-3),e.lookahead-=e.prev_length-1,e.prev_length-=2;do{++e.strstart<=i&&(e.ins_h=wt(e,e.ins_h,e.window[e.strstart+3-1]),n=e.prev[e.strstart&e.w_mask]=e.head[e.ins_h],e.head[e.ins_h]=e.strstart)}while(0!=--e.prev_length);if(e.match_available=0,e.match_length=2,e.strstart++,r&&(kt(e,!1),0===e.strm.avail_out))return 1}else if(e.match_available){if(r=He(e,0,e.window[e.strstart-1]),r&&kt(e,!1),e.strstart++,e.lookahead--,0===e.strm.avail_out)return 1}else e.match_available=1,e.strstart++,e.lookahead--}return e.match_available&&(r=He(e,0,e.window[e.strstart-1]),e.match_available=0),e.insert=e.strstart<2?e.strstart:2,t===Je?(kt(e,!0),0===e.strm.avail_out?3:4):e.sym_next&&(kt(e,!1),0===e.strm.avail_out)?1:2};function Lt(e,t,n,r,i){this.good_length=e,this.max_lazy=t,this.nice_length=n,this.max_chain=r,this.func=i}const xt=[new Lt(0,0,0,0,Rt),new Lt(4,4,8,4,It),new Lt(4,5,16,8,It),new Lt(4,6,32,32,It),new Lt(4,4,16,16,Dt),new Lt(8,16,32,32,Dt),new Lt(8,16,128,128,Dt),new Lt(8,32,128,256,Dt),new Lt(32,128,258,1024,Dt),new Lt(32,258,258,4096,Dt)];function Mt(){this.strm=null,this.status=0,this.pending_buf=null,this.pending_buf_size=0,this.pending_out=0,this.pending=0,this.wrap=0,this.gzhead=null,this.gzindex=0,this.method=dt,this.last_flush=-1,this.w_size=0,this.w_bits=0,this.w_mask=0,this.window=null,this.window_size=0,this.prev=null,this.head=null,this.ins_h=0,this.hash_size=0,this.hash_bits=0,this.hash_mask=0,this.hash_shift=0,this.block_start=0,this.match_length=0,this.prev_match=0,this.match_available=0,this.strstart=0,this.match_start=0,this.lookahead=0,this.prev_length=0,this.max_chain_length=0,this.max_lazy_match=0,this.level=0,this.strategy=0,this.good_match=0,this.nice_match=0,this.dyn_ltree=new Uint16Array(1146),this.dyn_dtree=new Uint16Array(122),this.bl_tree=new Uint16Array(78),mt(this.dyn_ltree),mt(this.dyn_dtree),mt(this.bl_tree),this.l_desc=null,this.d_desc=null,this.bl_desc=null,this.bl_count=new Uint16Array(16),this.heap=new Uint16Array(573),mt(this.heap),this.heap_len=0,this.heap_max=0,this.depth=new Uint16Array(573),mt(this.depth),this.sym_buf=0,this.lit_bufsize=0,this.sym_next=0,this.sym_end=0,this.opt_len=0,this.static_len=0,this.matches=0,this.insert=0,this.bi_buf=0,this.bi_valid=0}const Ut=e=>{if(!e)return 1;const t=e.state;return!t||t.strm!==e||t.status!==pt&&57!==t.status&&69!==t.status&&73!==t.status&&91!==t.status&&103!==t.status&&t.status!==gt&&t.status!==vt?1:0},Pt=e=>{if(Ut(e))return Et(e,nt);e.total_in=e.total_out=0,e.data_type=ht;const t=e.state;return t.pending=0,t.pending_out=0,t.wrap<0&&(t.wrap=-t.wrap),t.status=2===t.wrap?57:t.wrap?pt:gt,e.adler=2===t.wrap?0:1,t.last_flush=-2,Be(t),et},zt=e=>{const t=Pt(e);var n;return t===et&&((n=e.state).window_size=2*n.w_size,mt(n.head),n.max_lazy_match=xt[n.level].max_lazy,n.good_match=xt[n.level].good_length,n.nice_match=xt[n.level].nice_length,n.max_chain_length=xt[n.level].max_chain,n.strstart=0,n.block_start=0,n.lookahead=0,n.insert=0,n.match_length=n.prev_length=2,n.match_available=0,n.ins_h=0),t},Ft=(e,t,n,r,i,o)=>{if(!e)return nt;let s=1;if(t===ot&&(t=6),r<0?(s=0,r=-r):r>15&&(s=2,r-=16),i<1||i>9||n!==dt||r<8||r>15||t<0||t>9||o<0||o>ut||8===r&&1!==s)return Et(e,nt);8===r&&(r=9);const a=new Mt;return e.state=a,a.strm=e,a.status=pt,a.wrap=s,a.gzhead=null,a.w_bits=r,a.w_size=1<Ft(e,t,dt,15,8,lt),deflateInit2:Ft,deflateReset:zt,deflateResetKeep:Pt,deflateSetHeader:(e,t)=>Ut(e)||2!==e.state.wrap?nt:(e.state.gzhead=t,et),deflate:(e,t)=>{if(Ut(e)||t>$e||t<0)return e?Et(e,nt):nt;const n=e.state;if(!e.output||0!==e.avail_in&&!e.input||n.status===vt&&t!==Je)return Et(e,0===e.avail_out?it:nt);const r=n.last_flush;if(n.last_flush=t,0!==n.pending){if(St(e),0===e.avail_out)return n.last_flush=-1,et}else if(0===e.avail_in&&bt(t)<=bt(r)&&t!==Je)return Et(e,it);if(n.status===vt&&0!==e.avail_in)return Et(e,it);if(n.status===pt&&0===n.wrap&&(n.status=gt),n.status===pt){let t=dt+(n.w_bits-8<<4)<<8,r=-1;if(r=n.strategy>=at||n.level<2?0:n.level<6?1:6===n.level?2:3,t|=r<<6,0!==n.strstart&&(t|=32),t+=31-t%31,Ct(n,t),0!==n.strstart&&(Ct(n,e.adler>>>16),Ct(n,65535&e.adler)),e.adler=1,n.status=gt,St(e),0!==n.pending)return n.last_flush=-1,et}if(57===n.status)if(e.adler=0,Tt(n,31),Tt(n,139),Tt(n,8),n.gzhead)Tt(n,(n.gzhead.text?1:0)+(n.gzhead.hcrc?2:0)+(n.gzhead.extra?4:0)+(n.gzhead.name?8:0)+(n.gzhead.comment?16:0)),Tt(n,255&n.gzhead.time),Tt(n,n.gzhead.time>>8&255),Tt(n,n.gzhead.time>>16&255),Tt(n,n.gzhead.time>>24&255),Tt(n,9===n.level?2:n.strategy>=at||n.level<2?4:0),Tt(n,255&n.gzhead.os),n.gzhead.extra&&n.gzhead.extra.length&&(Tt(n,255&n.gzhead.extra.length),Tt(n,n.gzhead.extra.length>>8&255)),n.gzhead.hcrc&&(e.adler=Ge(e.adler,n.pending_buf,n.pending,0)),n.gzindex=0,n.status=69;else if(Tt(n,0),Tt(n,0),Tt(n,0),Tt(n,0),Tt(n,0),Tt(n,9===n.level?2:n.strategy>=at||n.level<2?4:0),Tt(n,3),n.status=gt,St(e),0!==n.pending)return n.last_flush=-1,et;if(69===n.status){if(n.gzhead.extra){let t=n.pending,r=(65535&n.gzhead.extra.length)-n.gzindex;for(;n.pending+r>n.pending_buf_size;){let i=n.pending_buf_size-n.pending;if(n.pending_buf.set(n.gzhead.extra.subarray(n.gzindex,n.gzindex+i),n.pending),n.pending=n.pending_buf_size,n.gzhead.hcrc&&n.pending>t&&(e.adler=Ge(e.adler,n.pending_buf,n.pending-t,t)),n.gzindex+=i,St(e),0!==n.pending)return n.last_flush=-1,et;t=0,r-=i}let i=new Uint8Array(n.gzhead.extra);n.pending_buf.set(i.subarray(n.gzindex,n.gzindex+r),n.pending),n.pending+=r,n.gzhead.hcrc&&n.pending>t&&(e.adler=Ge(e.adler,n.pending_buf,n.pending-t,t)),n.gzindex=0}n.status=73}if(73===n.status){if(n.gzhead.name){let t,r=n.pending;do{if(n.pending===n.pending_buf_size){if(n.gzhead.hcrc&&n.pending>r&&(e.adler=Ge(e.adler,n.pending_buf,n.pending-r,r)),St(e),0!==n.pending)return n.last_flush=-1,et;r=0}t=n.gzindexr&&(e.adler=Ge(e.adler,n.pending_buf,n.pending-r,r)),n.gzindex=0}n.status=91}if(91===n.status){if(n.gzhead.comment){let t,r=n.pending;do{if(n.pending===n.pending_buf_size){if(n.gzhead.hcrc&&n.pending>r&&(e.adler=Ge(e.adler,n.pending_buf,n.pending-r,r)),St(e),0!==n.pending)return n.last_flush=-1,et;r=0}t=n.gzindexr&&(e.adler=Ge(e.adler,n.pending_buf,n.pending-r,r))}n.status=103}if(103===n.status){if(n.gzhead.hcrc){if(n.pending+2>n.pending_buf_size&&(St(e),0!==n.pending))return n.last_flush=-1,et;Tt(n,255&e.adler),Tt(n,e.adler>>8&255),e.adler=0}if(n.status=gt,St(e),0!==n.pending)return n.last_flush=-1,et}if(0!==e.avail_in||0!==n.lookahead||t!==Qe&&n.status!==vt){let r=0===n.level?Rt(n,t):n.strategy===at?((e,t)=>{let n;for(;;){if(0===e.lookahead&&(Nt(e),0===e.lookahead)){if(t===Qe)return 1;break}if(e.match_length=0,n=He(e,0,e.window[e.strstart]),e.lookahead--,e.strstart++,n&&(kt(e,!1),0===e.strm.avail_out))return 1}return e.insert=0,t===Je?(kt(e,!0),0===e.strm.avail_out?3:4):e.sym_next&&(kt(e,!1),0===e.strm.avail_out)?1:2})(n,t):n.strategy===ct?((e,t)=>{let n,r,i,o;const s=e.window;for(;;){if(e.lookahead<=_t){if(Nt(e),e.lookahead<=_t&&t===Qe)return 1;if(0===e.lookahead)break}if(e.match_length=0,e.lookahead>=3&&e.strstart>0&&(i=e.strstart-1,r=s[i],r===s[++i]&&r===s[++i]&&r===s[++i])){o=e.strstart+_t;do{}while(r===s[++i]&&r===s[++i]&&r===s[++i]&&r===s[++i]&&r===s[++i]&&r===s[++i]&&r===s[++i]&&r===s[++i]&&ie.lookahead&&(e.match_length=e.lookahead)}if(e.match_length>=3?(n=He(e,1,e.match_length-3),e.lookahead-=e.match_length,e.strstart+=e.match_length,e.match_length=0):(n=He(e,0,e.window[e.strstart]),e.lookahead--,e.strstart++),n&&(kt(e,!1),0===e.strm.avail_out))return 1}return e.insert=0,t===Je?(kt(e,!0),0===e.strm.avail_out?3:4):e.sym_next&&(kt(e,!1),0===e.strm.avail_out)?1:2})(n,t):xt[n.level].func(n,t);if(3!==r&&4!==r||(n.status=vt),1===r||3===r)return 0===e.avail_out&&(n.last_flush=-1),et;if(2===r&&(t===Ye?We(n):t!==$e&&(Ze(n,0,0,!1),t===Xe&&(mt(n.head),0===n.lookahead&&(n.strstart=0,n.block_start=0,n.insert=0))),St(e),0===e.avail_out))return n.last_flush=-1,et}return t!==Je?et:n.wrap<=0?tt:(2===n.wrap?(Tt(n,255&e.adler),Tt(n,e.adler>>8&255),Tt(n,e.adler>>16&255),Tt(n,e.adler>>24&255),Tt(n,255&e.total_in),Tt(n,e.total_in>>8&255),Tt(n,e.total_in>>16&255),Tt(n,e.total_in>>24&255)):(Ct(n,e.adler>>>16),Ct(n,65535&e.adler)),St(e),n.wrap>0&&(n.wrap=-n.wrap),0!==n.pending?et:tt)},deflateEnd:e=>{if(Ut(e))return nt;const t=e.state.status;return e.state=null,t===gt?Et(e,rt):et},deflateSetDictionary:(e,t)=>{let n=t.length;if(Ut(e))return nt;const r=e.state,i=r.wrap;if(2===i||1===i&&r.status!==pt||r.lookahead)return nt;if(1===i&&(e.adler=Fe(e.adler,t,n,0)),r.wrap=0,n>=r.w_size){0===i&&(mt(r.head),r.strstart=0,r.block_start=0,r.insert=0);let e=new Uint8Array(r.w_size);e.set(t.subarray(n-r.w_size,n),0),t=e,n=r.w_size}const o=e.avail_in,s=e.next_in,a=e.input;for(e.avail_in=n,e.next_in=0,e.input=t,Nt(r);r.lookahead>=3;){let e=r.strstart,t=r.lookahead-2;do{r.ins_h=wt(r,r.ins_h,r.window[e+3-1]),r.prev[e&r.w_mask]=r.head[r.ins_h],r.head[r.ins_h]=e,e++}while(--t);r.strstart=e,r.lookahead=2,Nt(r)}return r.strstart+=r.lookahead,r.block_start=r.strstart,r.insert=r.lookahead,r.lookahead=0,r.match_length=r.prev_length=2,r.match_available=0,e.next_in=s,e.input=a,e.avail_in=o,r.wrap=i,et},deflateInfo:"pako deflate (from Nodeca project)"};const Gt=(e,t)=>Object.prototype.hasOwnProperty.call(e,t);var jt={assign:function(e){const t=Array.prototype.slice.call(arguments,1);for(;t.length;){const n=t.shift();if(n){if("object"!=typeof n)throw new TypeError(n+"must be non-object");for(const t in n)Gt(n,t)&&(e[t]=n[t])}}return e},flattenChunks:e=>{let t=0;for(let n=0,r=e.length;n=252?6:e>=248?5:e>=240?4:e>=224?3:e>=192?2:1;Bt[254]=Bt[254]=1;var Zt={string2buf:e=>{if("function"==typeof TextEncoder&&TextEncoder.prototype.encode)return(new TextEncoder).encode(e);let t,n,r,i,o,s=e.length,a=0;for(i=0;i>>6,t[o++]=128|63&n):n<65536?(t[o++]=224|n>>>12,t[o++]=128|n>>>6&63,t[o++]=128|63&n):(t[o++]=240|n>>>18,t[o++]=128|n>>>12&63,t[o++]=128|n>>>6&63,t[o++]=128|63&n);return t},buf2string:(e,t)=>{const n=t||e.length;if("function"==typeof TextDecoder&&TextDecoder.prototype.decode)return(new TextDecoder).decode(e.subarray(0,t));let r,i;const o=new Array(2*n);for(i=0,r=0;r4)o[i++]=65533,r+=s-1;else{for(t&=2===s?31:3===s?15:7;s>1&&r1?o[i++]=65533:t<65536?o[i++]=t:(t-=65536,o[i++]=55296|t>>10&1023,o[i++]=56320|1023&t)}}return((e,t)=>{if(t<65534&&e.subarray&&Kt)return String.fromCharCode.apply(null,e.length===t?e:e.subarray(0,t));let n="";for(let r=0;r{(t=t||e.length)>e.length&&(t=e.length);let n=t-1;for(;n>=0&&128==(192&e[n]);)n--;return n<0||0===n?t:n+Bt[e[n]]>t?n:t}};var Vt=function(){this.input=null,this.next_in=0,this.avail_in=0,this.total_in=0,this.output=null,this.next_out=0,this.avail_out=0,this.total_out=0,this.msg="",this.state=null,this.data_type=2,this.adler=0};const Ht=Object.prototype.toString,{Z_NO_FLUSH:Wt,Z_SYNC_FLUSH:Qt,Z_FULL_FLUSH:Yt,Z_FINISH:Xt,Z_OK:Jt,Z_STREAM_END:$t,Z_DEFAULT_COMPRESSION:en,Z_DEFAULT_STRATEGY:tn,Z_DEFLATED:nn}=Ke;function rn(e){this.options=jt.assign({level:en,method:nn,chunkSize:16384,windowBits:15,memLevel:8,strategy:tn},e||{});let t=this.options;t.raw&&t.windowBits>0?t.windowBits=-t.windowBits:t.gzip&&t.windowBits>0&&t.windowBits<16&&(t.windowBits+=16),this.err=0,this.msg="",this.ended=!1,this.chunks=[],this.strm=new Vt,this.strm.avail_out=0;let n=qt.deflateInit2(this.strm,t.level,t.method,t.windowBits,t.memLevel,t.strategy);if(n!==Jt)throw new Error(je[n]);if(t.header&&qt.deflateSetHeader(this.strm,t.header),t.dictionary){let e;if(e="string"==typeof t.dictionary?Zt.string2buf(t.dictionary):"[object ArrayBuffer]"===Ht.call(t.dictionary)?new Uint8Array(t.dictionary):t.dictionary,n=qt.deflateSetDictionary(this.strm,e),n!==Jt)throw new Error(je[n]);this._dict_set=!0}}function on(e,t){const n=new rn(t);if(n.push(e,!0),n.err)throw n.msg||je[n.err];return n.result}rn.prototype.push=function(e,t){const n=this.strm,r=this.options.chunkSize;let i,o;if(this.ended)return!1;for(o=t===~~t?t:!0===t?Xt:Wt,"string"==typeof e?n.input=Zt.string2buf(e):"[object ArrayBuffer]"===Ht.call(e)?n.input=new Uint8Array(e):n.input=e,n.next_in=0,n.avail_in=n.input.length;;)if(0===n.avail_out&&(n.output=new Uint8Array(r),n.next_out=0,n.avail_out=r),(o===Qt||o===Yt)&&n.avail_out<=6)this.onData(n.output.subarray(0,n.next_out)),n.avail_out=0;else{if(i=qt.deflate(n,o),i===$t)return n.next_out>0&&this.onData(n.output.subarray(0,n.next_out)),i=qt.deflateEnd(this.strm),this.onEnd(i),this.ended=!0,i===Jt;if(0!==n.avail_out){if(o>0&&n.next_out>0)this.onData(n.output.subarray(0,n.next_out)),n.avail_out=0;else if(0===n.avail_in)break}else this.onData(n.output)}return!0},rn.prototype.onData=function(e){this.chunks.push(e)},rn.prototype.onEnd=function(e){e===Jt&&(this.result=jt.flattenChunks(this.chunks)),this.chunks=[],this.err=e,this.msg=this.strm.msg};var sn={Deflate:rn,deflate:on,deflateRaw:function(e,t){return(t=t||{}).raw=!0,on(e,t)},gzip:function(e,t){return(t=t||{}).gzip=!0,on(e,t)},constants:Ke};const an=16209;var cn=function(e,t){let n,r,i,o,s,a,c,u,l,h,d,_,f,p,g,v,E,b,m,y,w,S,k,T;const C=e.state;n=e.next_in,k=e.input,r=n+(e.avail_in-5),i=e.next_out,T=e.output,o=i-(t-e.avail_out),s=i+(e.avail_out-257),a=C.dmax,c=C.wsize,u=C.whave,l=C.wnext,h=C.window,d=C.hold,_=C.bits,f=C.lencode,p=C.distcode,g=(1<>>24,d>>>=b,_-=b,b=E>>>16&255,0===b)T[i++]=65535&E;else{if(!(16&b)){if(0==(64&b)){E=f[(65535&E)+(d&(1<>>=b,_-=b),_<15&&(d+=k[n++]<<_,_+=8,d+=k[n++]<<_,_+=8),E=p[d&v];n:for(;;){if(b=E>>>24,d>>>=b,_-=b,b=E>>>16&255,!(16&b)){if(0==(64&b)){E=p[(65535&E)+(d&(1<a){e.msg="invalid distance too far back",C.mode=an;break e}if(d>>>=b,_-=b,b=i-o,y>b){if(b=y-b,b>u&&C.sane){e.msg="invalid distance too far back",C.mode=an;break e}if(w=0,S=h,0===l){if(w+=c-b,b2;)T[i++]=S[w++],T[i++]=S[w++],T[i++]=S[w++],m-=3;m&&(T[i++]=S[w++],m>1&&(T[i++]=S[w++]))}else{w=i-y;do{T[i++]=T[w++],T[i++]=T[w++],T[i++]=T[w++],m-=3}while(m>2);m&&(T[i++]=T[w++],m>1&&(T[i++]=T[w++]))}break}}break}}while(n>3,n-=m,_-=m<<3,d&=(1<<_)-1,e.next_in=n,e.next_out=i,e.avail_in=n{const c=a.bits;let u,l,h,d,_,f,p=0,g=0,v=0,E=0,b=0,m=0,y=0,w=0,S=0,k=0,T=null;const C=new Uint16Array(16),O=new Uint16Array(16);let A,N,R,I=null;for(p=0;p<=un;p++)C[p]=0;for(g=0;g=1&&0===C[E];E--);if(b>E&&(b=E),0===E)return i[o++]=20971520,i[o++]=20971520,a.bits=1,0;for(v=1;v0&&(0===e||1!==E))return-1;for(O[1]=0,p=1;p852||2===e&&S>592)return 1;for(;;){A=p-y,s[g]+1=f?(N=I[s[g]-f],R=T[s[g]-f]):(N=96,R=0),u=1<>y)+l]=A<<24|N<<16|R|0}while(0!==l);for(u=1<>=1;if(0!==u?(k&=u-1,k+=u):k=0,g++,0==--C[p]){if(p===E)break;p=t[n+s[g]]}if(p>b&&(k&d)!==h){for(0===y&&(y=b),_+=v,m=p-y,w=1<852||2===e&&S>592)return 1;h=k&d,i[h]=b<<24|m<<16|_-o|0}}return 0!==k&&(i[_+k]=p-y<<24|64<<16|0),a.bits=b,0};const{Z_FINISH:pn,Z_BLOCK:gn,Z_TREES:vn,Z_OK:En,Z_STREAM_END:bn,Z_NEED_DICT:mn,Z_STREAM_ERROR:yn,Z_DATA_ERROR:wn,Z_MEM_ERROR:Sn,Z_BUF_ERROR:kn,Z_DEFLATED:Tn}=Ke,Cn=16180,On=16190,An=16191,Nn=16192,Rn=16194,In=16199,Dn=16200,Ln=16206,xn=16209,Mn=e=>(e>>>24&255)+(e>>>8&65280)+((65280&e)<<8)+((255&e)<<24);function Un(){this.strm=null,this.mode=0,this.last=!1,this.wrap=0,this.havedict=!1,this.flags=0,this.dmax=0,this.check=0,this.total=0,this.head=null,this.wbits=0,this.wsize=0,this.whave=0,this.wnext=0,this.window=null,this.hold=0,this.bits=0,this.length=0,this.offset=0,this.extra=0,this.lencode=null,this.distcode=null,this.lenbits=0,this.distbits=0,this.ncode=0,this.nlen=0,this.ndist=0,this.have=0,this.next=null,this.lens=new Uint16Array(320),this.work=new Uint16Array(288),this.lendyn=null,this.distdyn=null,this.sane=0,this.back=0,this.was=0}const Pn=e=>{if(!e)return 1;const t=e.state;return!t||t.strm!==e||t.mode16211?1:0},zn=e=>{if(Pn(e))return yn;const t=e.state;return e.total_in=e.total_out=t.total=0,e.msg="",t.wrap&&(e.adler=1&t.wrap),t.mode=Cn,t.last=0,t.havedict=0,t.flags=-1,t.dmax=32768,t.head=null,t.hold=0,t.bits=0,t.lencode=t.lendyn=new Int32Array(852),t.distcode=t.distdyn=new Int32Array(592),t.sane=1,t.back=-1,En},Fn=e=>{if(Pn(e))return yn;const t=e.state;return t.wsize=0,t.whave=0,t.wnext=0,zn(e)},qn=(e,t)=>{let n;if(Pn(e))return yn;const r=e.state;return t<0?(n=0,t=-t):(n=5+(t>>4),t<48&&(t&=15)),t&&(t<8||t>15)?yn:(null!==r.window&&r.wbits!==t&&(r.window=null),r.wrap=n,r.wbits=t,Fn(e))},Gn=(e,t)=>{if(!e)return yn;const n=new Un;e.state=n,n.strm=e,n.window=null,n.mode=Cn;const r=qn(e,t);return r!==En&&(e.state=null),r};let jn,Kn,Bn=!0;const Zn=e=>{if(Bn){jn=new Int32Array(512),Kn=new Int32Array(32);let t=0;for(;t<144;)e.lens[t++]=8;for(;t<256;)e.lens[t++]=9;for(;t<280;)e.lens[t++]=7;for(;t<288;)e.lens[t++]=8;for(fn(1,e.lens,0,288,jn,0,e.work,{bits:9}),t=0;t<32;)e.lens[t++]=5;fn(2,e.lens,0,32,Kn,0,e.work,{bits:5}),Bn=!1}e.lencode=jn,e.lenbits=9,e.distcode=Kn,e.distbits=5},Vn=(e,t,n,r)=>{let i;const o=e.state;return null===o.window&&(o.wsize=1<=o.wsize?(o.window.set(t.subarray(n-o.wsize,n),0),o.wnext=0,o.whave=o.wsize):(i=o.wsize-o.wnext,i>r&&(i=r),o.window.set(t.subarray(n-r,n-r+i),o.wnext),(r-=i)?(o.window.set(t.subarray(n-r,n),0),o.wnext=r,o.whave=o.wsize):(o.wnext+=i,o.wnext===o.wsize&&(o.wnext=0),o.whaveGn(e,15),inflateInit2:Gn,inflate:(e,t)=>{let n,r,i,o,s,a,c,u,l,h,d,_,f,p,g,v,E,b,m,y,w,S,k=0;const T=new Uint8Array(4);let C,O;const A=new Uint8Array([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]);if(Pn(e)||!e.output||!e.input&&0!==e.avail_in)return yn;n=e.state,n.mode===An&&(n.mode=Nn),s=e.next_out,i=e.output,c=e.avail_out,o=e.next_in,r=e.input,a=e.avail_in,u=n.hold,l=n.bits,h=a,d=c,S=En;e:for(;;)switch(n.mode){case Cn:if(0===n.wrap){n.mode=Nn;break}for(;l<16;){if(0===a)break e;a--,u+=r[o++]<>>8&255,n.check=Ge(n.check,T,2,0),u=0,l=0,n.mode=16181;break}if(n.head&&(n.head.done=!1),!(1&n.wrap)||(((255&u)<<8)+(u>>8))%31){e.msg="incorrect header check",n.mode=xn;break}if((15&u)!==Tn){e.msg="unknown compression method",n.mode=xn;break}if(u>>>=4,l-=4,w=8+(15&u),0===n.wbits&&(n.wbits=w),w>15||w>n.wbits){e.msg="invalid window size",n.mode=xn;break}n.dmax=1<>8&1),512&n.flags&&4&n.wrap&&(T[0]=255&u,T[1]=u>>>8&255,n.check=Ge(n.check,T,2,0)),u=0,l=0,n.mode=16182;case 16182:for(;l<32;){if(0===a)break e;a--,u+=r[o++]<>>8&255,T[2]=u>>>16&255,T[3]=u>>>24&255,n.check=Ge(n.check,T,4,0)),u=0,l=0,n.mode=16183;case 16183:for(;l<16;){if(0===a)break e;a--,u+=r[o++]<>8),512&n.flags&&4&n.wrap&&(T[0]=255&u,T[1]=u>>>8&255,n.check=Ge(n.check,T,2,0)),u=0,l=0,n.mode=16184;case 16184:if(1024&n.flags){for(;l<16;){if(0===a)break e;a--,u+=r[o++]<>>8&255,n.check=Ge(n.check,T,2,0)),u=0,l=0}else n.head&&(n.head.extra=null);n.mode=16185;case 16185:if(1024&n.flags&&(_=n.length,_>a&&(_=a),_&&(n.head&&(w=n.head.extra_len-n.length,n.head.extra||(n.head.extra=new Uint8Array(n.head.extra_len)),n.head.extra.set(r.subarray(o,o+_),w)),512&n.flags&&4&n.wrap&&(n.check=Ge(n.check,r,_,o)),a-=_,o+=_,n.length-=_),n.length))break e;n.length=0,n.mode=16186;case 16186:if(2048&n.flags){if(0===a)break e;_=0;do{w=r[o+_++],n.head&&w&&n.length<65536&&(n.head.name+=String.fromCharCode(w))}while(w&&_>9&1,n.head.done=!0),e.adler=n.check=0,n.mode=An;break;case 16189:for(;l<32;){if(0===a)break e;a--,u+=r[o++]<>>=7&l,l-=7&l,n.mode=Ln;break}for(;l<3;){if(0===a)break e;a--,u+=r[o++]<>>=1,l-=1,3&u){case 0:n.mode=16193;break;case 1:if(Zn(n),n.mode=In,t===vn){u>>>=2,l-=2;break e}break;case 2:n.mode=16196;break;case 3:e.msg="invalid block type",n.mode=xn}u>>>=2,l-=2;break;case 16193:for(u>>>=7&l,l-=7&l;l<32;){if(0===a)break e;a--,u+=r[o++]<>>16^65535)){e.msg="invalid stored block lengths",n.mode=xn;break}if(n.length=65535&u,u=0,l=0,n.mode=Rn,t===vn)break e;case Rn:n.mode=16195;case 16195:if(_=n.length,_){if(_>a&&(_=a),_>c&&(_=c),0===_)break e;i.set(r.subarray(o,o+_),s),a-=_,o+=_,c-=_,s+=_,n.length-=_;break}n.mode=An;break;case 16196:for(;l<14;){if(0===a)break e;a--,u+=r[o++]<>>=5,l-=5,n.ndist=1+(31&u),u>>>=5,l-=5,n.ncode=4+(15&u),u>>>=4,l-=4,n.nlen>286||n.ndist>30){e.msg="too many length or distance symbols",n.mode=xn;break}n.have=0,n.mode=16197;case 16197:for(;n.have>>=3,l-=3}for(;n.have<19;)n.lens[A[n.have++]]=0;if(n.lencode=n.lendyn,n.lenbits=7,C={bits:n.lenbits},S=fn(0,n.lens,0,19,n.lencode,0,n.work,C),n.lenbits=C.bits,S){e.msg="invalid code lengths set",n.mode=xn;break}n.have=0,n.mode=16198;case 16198:for(;n.have>>24,v=k>>>16&255,E=65535&k,!(g<=l);){if(0===a)break e;a--,u+=r[o++]<>>=g,l-=g,n.lens[n.have++]=E;else{if(16===E){for(O=g+2;l>>=g,l-=g,0===n.have){e.msg="invalid bit length repeat",n.mode=xn;break}w=n.lens[n.have-1],_=3+(3&u),u>>>=2,l-=2}else if(17===E){for(O=g+3;l>>=g,l-=g,w=0,_=3+(7&u),u>>>=3,l-=3}else{for(O=g+7;l>>=g,l-=g,w=0,_=11+(127&u),u>>>=7,l-=7}if(n.have+_>n.nlen+n.ndist){e.msg="invalid bit length repeat",n.mode=xn;break}for(;_--;)n.lens[n.have++]=w}}if(n.mode===xn)break;if(0===n.lens[256]){e.msg="invalid code -- missing end-of-block",n.mode=xn;break}if(n.lenbits=9,C={bits:n.lenbits},S=fn(1,n.lens,0,n.nlen,n.lencode,0,n.work,C),n.lenbits=C.bits,S){e.msg="invalid literal/lengths set",n.mode=xn;break}if(n.distbits=6,n.distcode=n.distdyn,C={bits:n.distbits},S=fn(2,n.lens,n.nlen,n.ndist,n.distcode,0,n.work,C),n.distbits=C.bits,S){e.msg="invalid distances set",n.mode=xn;break}if(n.mode=In,t===vn)break e;case In:n.mode=Dn;case Dn:if(a>=6&&c>=258){e.next_out=s,e.avail_out=c,e.next_in=o,e.avail_in=a,n.hold=u,n.bits=l,cn(e,d),s=e.next_out,i=e.output,c=e.avail_out,o=e.next_in,r=e.input,a=e.avail_in,u=n.hold,l=n.bits,n.mode===An&&(n.back=-1);break}for(n.back=0;k=n.lencode[u&(1<>>24,v=k>>>16&255,E=65535&k,!(g<=l);){if(0===a)break e;a--,u+=r[o++]<>b)],g=k>>>24,v=k>>>16&255,E=65535&k,!(b+g<=l);){if(0===a)break e;a--,u+=r[o++]<>>=b,l-=b,n.back+=b}if(u>>>=g,l-=g,n.back+=g,n.length=E,0===v){n.mode=16205;break}if(32&v){n.back=-1,n.mode=An;break}if(64&v){e.msg="invalid literal/length code",n.mode=xn;break}n.extra=15&v,n.mode=16201;case 16201:if(n.extra){for(O=n.extra;l>>=n.extra,l-=n.extra,n.back+=n.extra}n.was=n.length,n.mode=16202;case 16202:for(;k=n.distcode[u&(1<>>24,v=k>>>16&255,E=65535&k,!(g<=l);){if(0===a)break e;a--,u+=r[o++]<>b)],g=k>>>24,v=k>>>16&255,E=65535&k,!(b+g<=l);){if(0===a)break e;a--,u+=r[o++]<>>=b,l-=b,n.back+=b}if(u>>>=g,l-=g,n.back+=g,64&v){e.msg="invalid distance code",n.mode=xn;break}n.offset=E,n.extra=15&v,n.mode=16203;case 16203:if(n.extra){for(O=n.extra;l>>=n.extra,l-=n.extra,n.back+=n.extra}if(n.offset>n.dmax){e.msg="invalid distance too far back",n.mode=xn;break}n.mode=16204;case 16204:if(0===c)break e;if(_=d-c,n.offset>_){if(_=n.offset-_,_>n.whave&&n.sane){e.msg="invalid distance too far back",n.mode=xn;break}_>n.wnext?(_-=n.wnext,f=n.wsize-_):f=n.wnext-_,_>n.length&&(_=n.length),p=n.window}else p=i,f=s-n.offset,_=n.length;_>c&&(_=c),c-=_,n.length-=_;do{i[s++]=p[f++]}while(--_);0===n.length&&(n.mode=Dn);break;case 16205:if(0===c)break e;i[s++]=n.length,c--,n.mode=Dn;break;case Ln:if(n.wrap){for(;l<32;){if(0===a)break e;a--,u|=r[o++]<{if(Pn(e))return yn;let t=e.state;return t.window&&(t.window=null),e.state=null,En},inflateGetHeader:(e,t)=>{if(Pn(e))return yn;const n=e.state;return 0==(2&n.wrap)?yn:(n.head=t,t.done=!1,En)},inflateSetDictionary:(e,t)=>{const n=t.length;let r,i,o;return Pn(e)?yn:(r=e.state,0!==r.wrap&&r.mode!==On?yn:r.mode===On&&(i=1,i=Fe(i,t,n,0),i!==r.check)?wn:(o=Vn(e,t,n,n),o?(r.mode=16210,Sn):(r.havedict=1,En)))},inflateInfo:"pako inflate (from Nodeca project)"};var Wn=function(){this.text=0,this.time=0,this.xflags=0,this.os=0,this.extra=null,this.extra_len=0,this.name="",this.comment="",this.hcrc=0,this.done=!1};const Qn=Object.prototype.toString,{Z_NO_FLUSH:Yn,Z_FINISH:Xn,Z_OK:Jn,Z_STREAM_END:$n,Z_NEED_DICT:er,Z_STREAM_ERROR:tr,Z_DATA_ERROR:nr,Z_MEM_ERROR:rr}=Ke;function ir(e){this.options=jt.assign({chunkSize:65536,windowBits:15,to:""},e||{});const t=this.options;t.raw&&t.windowBits>=0&&t.windowBits<16&&(t.windowBits=-t.windowBits,0===t.windowBits&&(t.windowBits=-15)),!(t.windowBits>=0&&t.windowBits<16)||e&&e.windowBits||(t.windowBits+=32),t.windowBits>15&&t.windowBits<48&&0==(15&t.windowBits)&&(t.windowBits|=15),this.err=0,this.msg="",this.ended=!1,this.chunks=[],this.strm=new Vt,this.strm.avail_out=0;let n=Hn.inflateInit2(this.strm,t.windowBits);if(n!==Jn)throw new Error(je[n]);if(this.header=new Wn,Hn.inflateGetHeader(this.strm,this.header),t.dictionary&&("string"==typeof t.dictionary?t.dictionary=Zt.string2buf(t.dictionary):"[object ArrayBuffer]"===Qn.call(t.dictionary)&&(t.dictionary=new Uint8Array(t.dictionary)),t.raw&&(n=Hn.inflateSetDictionary(this.strm,t.dictionary),n!==Jn)))throw new Error(je[n])}function or(e,t){const n=new ir(t);if(n.push(e),n.err)throw n.msg||je[n.err];return n.result}ir.prototype.push=function(e,t){const n=this.strm,r=this.options.chunkSize,i=this.options.dictionary;let o,s,a;if(this.ended)return!1;for(s=t===~~t?t:!0===t?Xn:Yn,"[object ArrayBuffer]"===Qn.call(e)?n.input=new Uint8Array(e):n.input=e,n.next_in=0,n.avail_in=n.input.length;;){for(0===n.avail_out&&(n.output=new Uint8Array(r),n.next_out=0,n.avail_out=r),o=Hn.inflate(n,s),o===er&&i&&(o=Hn.inflateSetDictionary(n,i),o===Jn?o=Hn.inflate(n,s):o===nr&&(o=er));n.avail_in>0&&o===$n&&n.state.wrap>0&&0!==e[n.next_in];)Hn.inflateReset(n),o=Hn.inflate(n,s);switch(o){case tr:case nr:case er:case rr:return this.onEnd(o),this.ended=!0,!1}if(a=n.avail_out,n.next_out&&(0===n.avail_out||o===$n))if("string"===this.options.to){let e=Zt.utf8border(n.output,n.next_out),t=n.next_out-e,i=Zt.buf2string(n.output,e);n.next_out=t,n.avail_out=r-t,t&&n.output.set(n.output.subarray(e,e+t),0),this.onData(i)}else this.onData(n.output.length===n.next_out?n.output:n.output.subarray(0,n.next_out));if(o!==Jn||0!==a){if(o===$n)return o=Hn.inflateEnd(this.strm),this.onEnd(o),this.ended=!0,!0;if(0===n.avail_in)break}}return!0},ir.prototype.onData=function(e){this.chunks.push(e)},ir.prototype.onEnd=function(e){e===Jn&&("string"===this.options.to?this.result=this.chunks.join(""):this.result=jt.flattenChunks(this.chunks)),this.chunks=[],this.err=e,this.msg=this.strm.msg};var sr={Inflate:ir,inflate:or,inflateRaw:function(e,t){return(t=t||{}).raw=!0,or(e,t)},ungzip:or,constants:Ke};const{Deflate:ar,deflate:cr,deflateRaw:ur,gzip:lr}=sn,{Inflate:hr,inflate:dr,inflateRaw:_r,ungzip:fr}=sr;var pr,gr={Deflate:ar,deflate:cr,deflateRaw:ur,gzip:lr,Inflate:hr,inflate:dr,inflateRaw:_r,ungzip:fr,constants:Ke};!function(e){e.CONNECTING="CONNECTING",e.OPEN="OPEN",e.CLOSED="CLOSED"}(pr||(pr={}));var vr,Er=function(e){function n(t,n){var r=n.sdkState,i=n.dispatcher,o=n.logger,s=e.call(this)||this;return s.lastActive=0,s._iid=t,s._sdkState=r,s._dispatcher=i,s._logger=o,s}return t(n,e),Object.defineProperty(n.prototype,"isOpen",{get:function(){return this.connectionState===pr.OPEN},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"connectionState",{get:function(){if(this._ws)switch(this._ws.readyState){case 0:return pr.CONNECTING;case 1:return pr.OPEN}return pr.CLOSED},enumerable:!1,configurable:!0}),n.prototype._handleMessage=function(e){var t=this;e.split("\n").forEach((function(e){if(e){var n=$.createFromRawMessage(t._iid,e);t._logger.debug("receive websocket event",n),"LOGI"===n.code?t.dispatch("message",n):"PONG"===n.code?t.dispatch("pong"):"EXPR"===n.code?n.payload&&n.payload.expires_in>=0&&t._dispatcher.dispatch(new W):"NOOP"===n.code||t.dispatch("message",n)}}))},n.prototype.connect=function(e){var t=this;this._ws=new WebSocket(e),this._ws.onopen=function(){t._logger.debug("websocket open"),t.dispatch("open")},this._ws.onmessage=function(e){return i(t,void 0,void 0,(function(){var t,n,r=this;return o(this,(function(s){return(null===(n=this._sdkState.websocket)||void 0===n?void 0:n.compression)?e.data instanceof Blob?((t=new FileReader).readAsArrayBuffer(e.data),t.onloadend=function(){return i(r,void 0,void 0,(function(){var e;return o(this,(function(n){switch(n.label){case 0:return[4,(r=t.result,i(void 0,void 0,void 0,(function(){var e;return o(this,(function(t){return e=gr.ungzip(r),[2,String.fromCharCode.apply(null,e)]}))})))];case 1:return e=n.sent(),this._handleMessage(e),[2]}var r}))}))}):"string"==typeof e.data&&this._handleMessage(e.data):this._handleMessage(e.data),[2]}))}))},this._ws.onerror=function(){t._logger.debug("websocket error"),t.dispatch("error",E.networkError)},this._ws.onclose=function(){t._logger.debug("websocket close"),t.dispatch("close")},this.lastActive=Date.now()},n.prototype.disconnect=function(){var e=this;return new Promise((function(t){e._logger.debug("websocket disconnect"),e._ws&&e.connectionState!==pr.CLOSED?(e._ws.onopen=ee,e._ws.onmessage=ee,e._ws.onerror=ee,e._ws.onclose=function(){e.dispatch("close"),t()},e._ws.close(),e._ws=null):t()}))},n.prototype.send=function(e){if(!this._ws)throw E.connectionClosed;"PING"!==e.code?this.dispatch("ping-refresh"):this._logger.debug("send ping",e),this._ws.send(e.convertToMessage())},n.prototype.error=function(e){this._logger.debug("websocket error",e),this.dispatch("error",e)},n}(q),br=function(e){function n(t){var n,r=t.code,i=t.ackRequired,o=t.payload,s=void 0===o?null:o,a=this;return(a=e.call(this)||this).code=r,a.payload=s,a.requestId=null!==(n=a.payload.req_id)&&void 0!==n?n:z(),a.ackRequired=i,a.payload.req_id=a.requestId,a}return t(n,e),n.prototype.convertToMessage=function(){return"".concat(this.code).concat(JSON.stringify(this.payload),"\n")},n}(j),mr=function(e){function n(t){var n=t.all,r=t.custom_types,i=t.ts,o=e.call(this)||this;return o.all=n,o.customTypes=r,o.ts=i,o}return t(n,e),n}(j),yr=function(){var e=this;this.promise=new Promise((function(t,n){e.resolve=t,e.reject=n}))},wr=function(){function e(e,t){var n=t.auth,r=t.sdkState,i=t.dispatcher,o=t.logger,s=t.useFetchCompat,a=void 0!==s&&s,c=this;this._ackStateMap=new Map,this._sdkState=r,this._dispatcher=i,this._logger=o,this.apiClient=new J(e,{auth:n,sdkState:r,dispatcher:i,logger:o,useFetchCompat:a}),this.websocketClient=new Er(e,{sdkState:r,dispatcher:i,logger:o}),this.websocketClient.on("message",(function(e){if(e.payload.unread_cnt&&c._dispatcher.dispatch(new mr(e.payload.unread_cnt)),e.requestId){if(c._ackStateMap.has(e.requestId)){var t=c._ackStateMap.get(e.requestId);"EROR"!==e.code?t.resolve(e):t.reject(new E({code:e.payload.code,message:e.payload.message}))}}else c._dispatcher.dispatch(e)})).on("close",(function(){c._ackStateMap.forEach((function(e){e.reject(E.connectionClosed)})),c._ackStateMap.clear()}))}return e.prototype._sendApiRequest=function(e){return i(this,void 0,void 0,(function(){return o(this,(function(t){switch(t.label){case 0:return[4,this.apiClient.send(e)];case 1:return[2,t.sent()]}}))}))},e.prototype._sendWebsocketRequest=function(e){return i(this,void 0,void 0,(function(){var t,n,r,i=this;return o(this,(function(o){if(t=new yr,e.ackRequired){n=null,r=function(r,o){void 0===r&&(r=null),void 0===o&&(o=null),i._ackStateMap.has(e.requestId)&&(i._ackStateMap.delete(e.requestId),n&&(clearTimeout(n),n=null),r?(i._logger.debug("fail websocket request",r),t.reject(r)):(i._logger.debug("receive websocket ack",e.requestId),t.resolve(o)))};try{n=setTimeout((function(){return r(E.noAckTimeout)}),this._sdkState.websocket.responseTimeout),this._ackStateMap.set(e.requestId,{resolve:function(e){return r(null,e)},reject:function(e){return r(e)}}),this.websocketClient.send(e)}catch(e){r(e)}}else try{this.websocketClient.send(e),t.resolve(null)}catch(e){t.reject(e)}return[2,t.promise]}))}))},e.prototype.send=function(e){return i(this,void 0,void 0,(function(){return o(this,(function(t){switch(t.label){case 0:return e instanceof Z?[4,this._sendApiRequest(e)]:[3,2];case 1:case 3:return[2,t.sent()];case 2:return e instanceof br?[4,this._sendWebsocketRequest(e)]:[3,4];case 4:throw E.invalidParameters}}))}))},e.prototype.cancel=function(e){this.apiClient.cancel(e)},e.prototype.cancelAll=function(){this.apiClient.cancelAll()},e}();!function(e){e[e.NONE=0]="NONE",e[e.INITIALIZED=1]="INITIALIZED",e[e.CONNECTING=2]="CONNECTING",e[e.CONNECTED=3]="CONNECTED",e[e.RECONNECTING=4]="RECONNECTING",e[e.INTERNAL_DISCONNECTED=5]="INTERNAL_DISCONNECTED",e[e.EXTERNAL_DISCONNECTED=6]="EXTERNAL_DISCONNECTED",e[e.LOGOUT=7]="LOGOUT"}(vr||(vr={}));var Sr=function(e){function n(t){var n=t.stateType,r=e.call(this)||this;return r.stateType=n,r}return t(n,e),n}(j),kr=function(){function e(e,t){var n=t.auth,r=t.sdkState,s=t.dispatcher,a=t.logger,c=t.useFetchCompat,u=void 0!==c&&c,l=this;this._currentConnectionStateType=vr.INITIALIZED,this._lazyCallQueue=[],this.commandRouter=new wr(e,{auth:n,sdkState:r,dispatcher:s,logger:a,useFetchCompat:u}),this._auth=n,this._logger=a,this._dispatcher=s,this._dispatcher.on((function(e){if(e instanceof Sr){var t=e.stateType;switch(l._currentConnectionStateType=t,t){case vr.CONNECTED:var n=l._lazyCallQueue;l._lazyCallQueue=[],n.forEach((function(e){return i(l,void 0,void 0,(function(){var t,n,r,i,s;return o(this,(function(o){switch(o.label){case 0:t=e.command,n=e.deferred,r=e.timeout,clearTimeout(r),o.label=1;case 1:return o.trys.push([1,3,,4]),[4,this.send(t)];case 2:return i=o.sent(),n.resolve(i),[3,4];case 3:return s=o.sent(),n.reject(s),[3,4];case 4:return[2]}}))}))}));break;case vr.INITIALIZED:case vr.INTERNAL_DISCONNECTED:case vr.EXTERNAL_DISCONNECTED:case vr.LOGOUT:n=l._lazyCallQueue;l._lazyCallQueue=[],n.forEach((function(e){return i(l,void 0,void 0,(function(){var t,n;return o(this,(function(r){return t=e.deferred,n=e.timeout,clearTimeout(n),this._auth&&this._auth.hasSession?t.reject(E.connectionClosed):t.reject(E.connectionRequired),[2]}))}))}))}}}))}return Object.defineProperty(e.prototype,"isReady",{get:function(){return this._currentConnectionStateType===vr.CONNECTED},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"isLazyCallActivated",{get:function(){return this._currentConnectionStateType===vr.CONNECTING||this._currentConnectionStateType===vr.RECONNECTING},enumerable:!1,configurable:!0}),e.prototype.send=function(e){return i(this,void 0,void 0,(function(){var t,n,r=this;return o(this,(function(i){switch(i.label){case 0:return e instanceof br?this.isReady?(this._logger.debug("send websocket request",e),[4,this.commandRouter.send(e)]):[3,2]:[3,4];case 1:case 5:return[2,i.sent()];case 2:if(this.isLazyCallActivated)return this._logger.debug("wait websocket request",e),t=new yr,this._lazyCallQueue.push({command:e,deferred:t,timeout:setTimeout((function(){return r.timeout(e.requestId)}),1e4)}),[2,t.promise];throw this._logger.debug("fail websocket request"),E.connectionRequired;case 3:return[3,7];case 4:return e instanceof Z?this._auth.hasSession?(this._logger.debug("send api request",e),[4,this.commandRouter.send(e)]):[3,6]:[3,7];case 6:if(this.isLazyCallActivated)return this._logger.debug("wait api request",e),t=new yr,this._lazyCallQueue.push({command:e,deferred:t,timeout:setTimeout((function(){return r.timeout(e.requestId)}),1e4)}),[2,t.promise];throw n=E.connectionRequired,this._logger.debug("fail api request",n),n;case 7:return[2]}}))}))},e.prototype.forceSend=function(e){return i(this,void 0,void 0,(function(){return o(this,(function(t){switch(t.label){case 0:return this._logger.debug("send forced request",e),[4,this.commandRouter.send(e)];case 1:return[2,t.sent()]}}))}))},e.prototype.timeout=function(e){this._logger.debug("timeout request",e);var t=this._lazyCallQueue.findIndex((function(t){return t.command.requestId===e}));t>-1&&(this._lazyCallQueue[t].deferred.reject(E.connectionRequired),this._lazyCallQueue.splice(t,1))},e.prototype.cancel=function(e){this._logger.debug("cancel api request",e),this.commandRouter.cancel(e)},e.prototype.cancelAll=function(){this._logger.debug("cancel all api requests"),this.commandRouter.cancelAll()},e}(),Tr="sendbird@devicetokens",Cr=function(){function e(e){var t=e.type,n=e.token;this.type=t,this.token=n}return e.payloadify=function(e){return{type:e.type,token:e.token}},e}(),Or="v3",Ar="/".concat(Or,"/users"),Nr="/".concat(Or,"/storage/file"),Rr="/".concat(Or,"/group_channels"),Ir="/".concat(Or,"/sdk/group_channels"),Dr="/".concat(Or,"/open_channels"),Lr="/".concat(Or,"/sdk/open_channels"),xr="/".concat(Or,"/search"),Mr="/".concat(Or,"/report"),Ur="/".concat(Or,"/emojis"),Pr="/".concat(Or,"/emoji_categories"),zr="/".concat(Or,"/polls"),Fr="/".concat(Or,"/scheduled_messages"),qr="/".concat(Or,"/sdk/statistics"),Gr=function(e){function n(t){var n=t.userId,r=t.authToken,i=t.expiringSession,o=void 0===i||i,s=e.call(this)||this;return s.path="".concat(Ar,"/").concat(n,"/session_key"),s.method=x.POST,s.params={token:r,expiring_session:!!o},s.requireAuth=!1,s}return t(n,e),n}(Z),jr=function(e){function n(t){var n=t.authToken,r=t.expiringSession,i=void 0===r||r,o=t.requestId,s=void 0===o?null:o;return e.call(this,{code:"LOGI",payload:{token:n,expiring_session:i?1:0,req_id:s},ackRequired:!0})||this}return t(n,e),n}(br),Kr=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}(V),Br=function(e){function n(t,n,r){var i=e.call(this,t,"LOGI",r)||this;return i.error=null,i.newKey=r.new_key,i.error=r.error?new E(r.error):null,i}return t(n,e),n}($),Zr=function(e){function n(){return null!==e&&e.apply(this,arguments)||this}return t(n,e),n}(j),Vr=function(e){return i(void 0,void 0,void 0,(function(){return o(this,(function(t){return[2,new Promise((function(t){return setTimeout(t,e)}))]}))}))},Hr=function(){function e(){}return e.prototype.calcTimeout=function(){return 0},e}(),Wr=function(e,t,n){return void 0===n&&(n=new Hr),i(void 0,void 0,void 0,(function(){var r,i,s,a,c,u;return o(this,(function(o){switch(o.label){case 0:r=0,i=null,s=function(e){return void 0===e&&(e=null),i=null!=e?e:new Error("Halted")},a=function(){r=0},o.label=1;case 1:if(!(-1===t||r=0},n.prototype.createRefreshWebsocketCommand=function(e,t){return void 0===t&&(t=null),new jr({authToken:e,expiringSession:!0,requestId:t})},n.prototype._refreshSessionKeyByWebSocket=function(e){return i(this,void 0,void 0,(function(){var t,n,r,i,s;return o(this,(function(o){switch(o.label){case 0:return t=this.createRefreshWebsocketCommand(e),[4,this._requestQueue.forceSend(t)];case 1:if(n=o.sent(),r=n.as(Br),i=r.newKey,s=r.error)throw s;return this.auth.sessionKey=null!=i?i:this.auth.sessionKey,[2]}}))}))},n.prototype._refreshSessionKeyByApi=function(e){return i(this,void 0,void 0,(function(){var t,n=this;return o(this,(function(r){switch(r.label){case 0:return t=new Gr({userId:this._sdkState.userId,authToken:e,expiringSession:!0}),[4,Wr((function(e){return i(n,void 0,void 0,(function(){var n,r,i;return o(this,(function(o){switch(o.label){case 0:return o.trys.push([0,2,,3]),[4,this._requestQueue.forceSend(t)];case 1:return n=o.sent(),r=n.as(Kr).key,this.auth.sessionKey=r,[3,3];case 2:if(i=o.sent(),!this._isSessionRelatedError(i))throw i;return e(i),[3,3];case 3:return[2]}}))}))}),3)];case 1:return r.sent(),[2]}}))}))},n.prototype._refreshSessionKey=function(e,t){return void 0===t&&(t=!0),i(this,void 0,void 0,(function(){var n,r,i,s;return o(this,(function(o){switch(o.label){case 0:if(this._currentConnectionStateType!==vr.CONNECTED)return[3,10];o.label=1;case 1:return o.trys.push([1,3,,10]),[4,this._refreshSessionKeyByWebSocket(e)];case 2:return o.sent(),this.complete(),[2];case 3:return n=o.sent(),this._isSessionRelatedError(n)?t?(r=this.auth,[4,this._receiveNewAuthToken()]):[3,9]:[3,9];case 4:return r.authToken=o.sent(),this.auth.authToken?[4,this._refreshSessionKey(this.auth.authToken,!1)]:[3,6];case 5:return o.sent(),this.complete(),[3,8];case 6:return[4,this.clear()];case 7:o.sent(),this.close(),o.label=8;case 8:return[2];case 9:return[3,10];case 10:return o.trys.push([10,12,,22]),[4,this._refreshSessionKeyByApi(e)];case 11:return o.sent(),this.complete(),[3,22];case 12:return i=o.sent(),this._isSessionRelatedError(i)?t?(s=this.auth,[4,this._receiveNewAuthToken()]):[3,18]:[3,20];case 13:return s.authToken=o.sent(),this.auth.authToken?[4,this._refreshSessionKeyByApi(this.auth.authToken)]:[3,15];case 14:return o.sent(),this.complete(),[3,17];case 15:return[4,this.clear()];case 16:o.sent(),this.close(),o.label=17;case 17:return[3,19];case 18:throw i;case 19:return[3,21];case 20:throw i;case 21:return[3,22];case 22:return[2]}}))}))},n.prototype._receiveNewAuthToken=function(){var e=this,t=new yr;return Qr((function(){return i(e,void 0,void 0,(function(){var e,n,r=this;return o(this,(function(i){return this._isRefreshingAuthToken=!0,this.auth.clear(),e=null,n=function(){e&&(clearTimeout(e),e=null)},e=setTimeout((function(){r._isRefreshingAuthToken=!1,t.reject()}),1e3*this._sdkState.sessionTokenRefreshTimeout),this.handler.onSessionTokenRequired((function(e){n(),r._isRefreshingAuthToken&&(r._isRefreshingAuthToken=!1,r.dispatch("refresh-authtoken"),t.resolve(e))}),(function(e){n(),r._isRefreshingAuthToken=!1,t.reject(e)})),[2]}))}))})),t.promise},n.prototype._isSessionRelatedError=function(e){return e instanceof E&&(e.isSessionKeyExpiredError||e.isSessionTokenExpiredError)},Object.defineProperty(n.prototype,"isSessionKeyRefreshing",{get:function(){return this._isRefreshingSessionKey},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"isRefreshingAuthToken",{get:function(){return this._isRefreshingAuthToken},enumerable:!1,configurable:!0}),n.prototype.login=function(e){var t;return i(this,void 0,void 0,(function(){var n,r,i,s,a,c,u;return o(this,(function(o){switch(o.label){case 0:return n=e.key,r=e.ekey,i=e.userProfile,s=e.deviceTokenLastDeletedAt,a=void 0===s?0:s,this.auth.sessionKey=n,Xr.set(this,r),this._deviceTokenCacheEnabled=null===(t=null==i?void 0:i.appInfo)||void 0===t?void 0:t.deviceTokenCache,c=this._cacheContext.preference,this._deviceTokenCacheEnabled?[4,c.get(Tr)]:[3,5];case 1:return!(u=o.sent())||u.lastDeletedAt=0&&this._deviceTokens.splice(n,1)}},n.prototype.unsetDeviceTokens=function(e){this._deviceTokenCacheEnabled&&(this._deviceTokens=e?this._deviceTokens.filter((function(t){return t.type!==e})):[])},n.prototype.setDeviceTokenDeletedAt=function(e){e>0&&(this._deviceTokenLastDeletedAt=e)},n.prototype.saveDeviceToken=function(){return i(this,void 0,void 0,(function(){return o(this,(function(e){switch(e.label){case 0:return this._deviceTokenCacheEnabled?[4,this._cacheContext.preference.set(Tr,{tokens:this._deviceTokens,lastDeletedAt:this._deviceTokenLastDeletedAt})]:[3,2];case 1:e.sent(),e.label=2;case 2:return[2]}}))}))},n.prototype.clear=function(){return i(this,void 0,void 0,(function(){return o(this,(function(e){switch(e.label){case 0:return this.currentUser=null,this.auth.clear(),Xr.delete(this),this._deviceTokens=[],this._deviceTokenLastDeletedAt=0,[4,this.saveDeviceToken()];case 1:return e.sent(),[2]}}))}))},n}(q),$r=function(){function e(){this.type=vr.NONE,this.name="none"}return e.prototype.run=function(e){return i(this,void 0,void 0,(function(){return o(this,(function(e){return[2]}))}))},e.prototype.onConnect=function(e,t){return i(this,void 0,void 0,(function(){return o(this,(function(e){return[2]}))}))},e.prototype.onReconnect=function(e,t){return t.resetReconnectCount,i(this,void 0,void 0,(function(){return o(this,(function(e){return[2]}))}))},e.prototype.onDisconnect=function(e,t){return t.error,t.autoReconnect,i(this,void 0,void 0,(function(){return o(this,(function(e){return[2]}))}))},e.prototype.onDisconnectWebSocket=function(e){return i(this,void 0,void 0,(function(){return o(this,(function(e){return[2]}))}))},e.prototype.onLogout=function(e){return i(this,void 0,void 0,(function(){return o(this,(function(e){return[2]}))}))},e}(),ei=function(e){function n(){var t=null!==e&&e.apply(this,arguments)||this;return t.type=vr.LOGOUT,t.name="logout",t}return t(n,e),n.prototype.run=function(e){return i(this,void 0,void 0,(function(){var t,n,r=this;return o(this,(function(s){switch(s.label){case 0:return t=Date.now(),n=e.sdkState.userId,[4,e.logout()];case 1:return s.sent(),[4,e.changeState(new si,t)];case 2:return s.sent(),Qr((function(){return i(r,void 0,void 0,(function(){return o(this,(function(t){return e.connectionHandlers.forEach((function(e){e.onDisconnected(n)})),[2]}))}))})),[2]}}))}))},n}($r),ti=function(e){function n(){var t=e.call(this)||this;return t.type=vr.EXTERNAL_DISCONNECTED,t.name="externaldisconnected",t}return t(n,e),n.prototype.run=function(e){return i(this,void 0,void 0,(function(){return o(this,(function(t){switch(t.label){case 0:return[4,e.disconnect()];case 1:return t.sent(),[2]}}))}))},n.prototype.onConnect=function(e,t){return i(this,void 0,void 0,(function(){var n;return o(this,(function(r){switch(r.label){case 0:return n=Date.now(),[4,e.disconnect()];case 1:return r.sent(),[4,e.changeState(new oi({authToken:t}),n)];case 2:return r.sent(),[2]}}))}))},n.prototype.onReconnect=function(e){return i(this,void 0,void 0,(function(){var t;return o(this,(function(n){switch(n.label){case 0:return t=Date.now(),[4,e.changeState(new ri,t)];case 1:return n.sent(),[2]}}))}))},n.prototype.onLogout=function(e){return i(this,void 0,void 0,(function(){var t;return o(this,(function(n){switch(n.label){case 0:return t=Date.now(),[4,e.changeState(new ei,t)];case 1:return n.sent(),[2]}}))}))},n}($r),ni=function(e){function n(t){var n=t.autoReconnect,r=e.call(this)||this;return r.type=vr.INTERNAL_DISCONNECTED,r.name="internaldisconnected",r._autoReconnect=!1,r._autoReconnect=n,r}return t(n,e),n.prototype.run=function(e){return i(this,void 0,void 0,(function(){var t;return o(this,(function(n){switch(n.label){case 0:return t=Date.now(),[4,e.disconnect()];case 1:return n.sent(),this._autoReconnect?[4,e.changeState(new ri,t)]:[3,3];case 2:n.sent(),n.label=3;case 3:return[2]}}))}))},n.prototype.onConnect=function(e,t){return i(this,void 0,void 0,(function(){var n;return o(this,(function(r){switch(r.label){case 0:return n=Date.now(),[4,e.disconnect()];case 1:return r.sent(),[4,e.changeState(new oi({authToken:t}),n)];case 2:return r.sent(),[2]}}))}))},n.prototype.onReconnect=function(e){return i(this,void 0,void 0,(function(){var t;return o(this,(function(n){switch(n.label){case 0:return t=Date.now(),[4,e.changeState(new ri,t)];case 1:return n.sent(),[2]}}))}))},n.prototype.onDisconnectWebSocket=function(e){return i(this,void 0,void 0,(function(){var t;return o(this,(function(n){switch(n.label){case 0:return t=Date.now(),[4,e.changeState(new ti,t)];case 1:return n.sent(),[2]}}))}))},n.prototype.onLogout=function(e){return i(this,void 0,void 0,(function(){var t;return o(this,(function(n){switch(n.label){case 0:return t=Date.now(),[4,e.changeState(new ei,t)];case 1:return n.sent(),[2]}}))}))},n}($r),ri=function(e){function n(){var t=null!==e&&e.apply(this,arguments)||this;return t.type=vr.RECONNECTING,t.name="reconnecting",t._haltConnect=null,t._resetConnect=null,t._callbacks=[],t}return t(n,e),n.prototype._halt=function(e){this._haltConnect&&(this._haltConnect(e),this._haltConnect=null)},n.prototype._flushCallbacks=function(e){void 0===e&&(e=null),this._haltConnect=null,this._resetConnect=null,this._callbacks.forEach((function(t){return t(e)}))},n.prototype.run=function(e){return i(this,void 0,void 0,(function(){var t,n,r,s,a,c,l=this;return o(this,(function(h){switch(h.label){case 0:t=Date.now(),n=new yr,this._callbacks.push((function(e){return e?n.reject(e):n.resolve()})),Qr((function(){return i(l,void 0,void 0,(function(){return o(this,(function(t){return e.connectionHandlers.forEach((function(e){e.onReconnectStarted()})),[2]}))}))})),h.label=1;case 1:return h.trys.push([1,4,,9]),r=e.sdkState.websocket,s=r.reconnectMaxRetry,a=r.reconnectRetryStrategy,[4,Wr((function(t,n){return i(l,void 0,void 0,(function(){var r;return o(this,(function(i){switch(i.label){case 0:this._haltConnect=t,this._resetConnect=n,i.label=1;case 1:return i.trys.push([1,3,,4]),[4,e.connect()];case 2:return i.sent(),[3,4];case 3:if(r=i.sent(),e.clearLoginTimer(),r instanceof E&&r.code===u.CONNECTION_CANCELED)return t(r),[2];throw r;case 4:return[2]}}))}))}),s,a)];case 2:return h.sent(),[4,e.changeState(new ii,t)];case 3:return h.sent(),Qr((function(){return i(l,void 0,void 0,(function(){return o(this,(function(t){return this._flushCallbacks(null),e.connectionHandlers.forEach((function(e){e.onReconnectSucceeded()})),[2]}))}))})),[3,9];case 4:return c=h.sent(),v(c)?[3,7]:c instanceof E?c.code===u.CONNECTION_CANCELED?[3,6]:[4,e.changeState(new ni({autoReconnect:!1}),t)]:[3,6];case 5:h.sent(),h.label=6;case 6:return Qr((function(){return i(l,void 0,void 0,(function(){return o(this,(function(t){return this._flushCallbacks(c),e.connectionHandlers.forEach((function(e){e.onReconnectFailed()})),[2]}))}))})),[3,8];case 7:throw c;case 8:return[3,9];case 9:return[2,n.promise]}}))}))},n.prototype.onConnect=function(e,t){return i(this,void 0,void 0,(function(){var n;return o(this,(function(r){return n=new yr,this._halt(E.connectionCanceled),e.cancelConnectForRetry(),this._callbacks.push((function(){var r=Date.now();e.changeState(new oi({authToken:t}),r).then((function(){n.resolve()})).catch((function(e){n.reject(e)}))})),[2,n.promise]}))}))},n.prototype.onReconnect=function(e,t){var n=t.resetReconnectCount,r=void 0!==n&&n;return i(this,void 0,void 0,(function(){var e;return o(this,(function(t){return e=new yr,this._resetConnect&&r&&this._resetConnect(),this._callbacks.push((function(t){return t?e.reject(t):e.resolve()})),[2,e.promise]}))}))},n.prototype.onDisconnect=function(e,t){t.error;var n=t.autoReconnect,r=void 0===n||n;return i(this,void 0,void 0,(function(){var t;return o(this,(function(n){switch(n.label){case 0:return t=Date.now(),this._halt(E.connectionCanceled),[4,e.changeState(new ni({autoReconnect:r}),t)];case 1:return n.sent(),[2]}}))}))},n.prototype.onDisconnectWebSocket=function(e){return i(this,void 0,void 0,(function(){var t;return o(this,(function(n){switch(n.label){case 0:return t=Date.now(),this._halt(E.connectionCanceled),[4,e.changeState(new ti,t)];case 1:return n.sent(),[2]}}))}))},n.prototype.onLogout=function(e){return i(this,void 0,void 0,(function(){var t;return o(this,(function(n){switch(n.label){case 0:return t=Date.now(),this._halt(E.connectionCanceled),[4,e.changeState(new ei,t)];case 1:return n.sent(),[2]}}))}))},n}($r),ii=function(e){function n(){var t=null!==e&&e.apply(this,arguments)||this;return t.type=vr.CONNECTED,t.name="connected",t}return t(n,e),n.prototype.onReconnect=function(e){return i(this,void 0,void 0,(function(){var t;return o(this,(function(n){switch(n.label){case 0:return t=Date.now(),[4,e.disconnect()];case 1:return n.sent(),[4,e.changeState(new ri,t)];case 2:return n.sent(),[2]}}))}))},n.prototype.onDisconnect=function(e,t){var n=t.autoReconnect;return i(this,void 0,void 0,(function(){var t;return o(this,(function(r){switch(r.label){case 0:return t=Date.now(),[4,e.changeState(new ni({autoReconnect:n}),t)];case 1:return r.sent(),[2]}}))}))},n.prototype.onDisconnectWebSocket=function(e){return i(this,void 0,void 0,(function(){var t;return o(this,(function(n){switch(n.label){case 0:return t=Date.now(),[4,e.changeState(new ti,t)];case 1:return n.sent(),[2]}}))}))},n.prototype.onLogout=function(e){return i(this,void 0,void 0,(function(){var t;return o(this,(function(n){switch(n.label){case 0:return t=Date.now(),[4,e.changeState(new ei,t)];case 1:return n.sent(),[2]}}))}))},n}($r),oi=function(e){function n(t){var n=t.authToken,r=e.call(this)||this;return r.type=vr.CONNECTING,r.name="connecting",r._authToken="",r._haltConnect=null,r._callbacks=[],r._authToken=n,r}return t(n,e),n.prototype._halt=function(e){this._haltConnect&&(this._haltConnect(e),this._haltConnect=null)},n.prototype._flushCallbacks=function(e){void 0===e&&(e=null),this._haltConnect=null,this._callbacks.forEach((function(t){return t(e)}))},n.prototype.run=function(e){return i(this,void 0,void 0,(function(){var t,n,r,s=this;return o(this,(function(a){switch(a.label){case 0:t=Date.now(),n=new yr,this._callbacks.push((function(e){return e?n.reject(e):n.resolve()})),a.label=1;case 1:return a.trys.push([1,4,,10]),[4,Wr((function(t){return i(s,void 0,void 0,(function(){var n;return o(this,(function(r){switch(r.label){case 0:this._haltConnect=t,r.label=1;case 1:return r.trys.push([1,3,,4]),[4,e.connect(this._authToken)];case 2:return r.sent(),[3,4];case 3:if(n=r.sent(),e.clearLoginTimer(),n instanceof E&&n.code===u.CONNECTION_CANCELED)return t(n),[2];throw n;case 4:return[2]}}))}))}),e.sdkState.websocket.connectMaxRetry)];case 2:return a.sent(),[4,e.changeState(new ii,t)];case 3:return a.sent(),Qr((function(){return i(s,void 0,void 0,(function(){return o(this,(function(t){return this._flushCallbacks(null),e.connectionHandlers.forEach((function(t){t.onConnected(e.sdkState.userId)})),[2]}))}))})),[3,10];case 4:return r=a.sent(),v(r)?[3,8]:[4,e.disconnect()];case 5:return a.sent(),r instanceof E?r.code===u.CONNECTION_CANCELED?[3,7]:[4,e.changeState(new si,t)]:[3,7];case 6:a.sent(),a.label=7;case 7:return Qr((function(){return i(s,void 0,void 0,(function(){return o(this,(function(e){return this._flushCallbacks(r),[2]}))}))})),[3,9];case 8:throw r;case 9:return[3,10];case 10:return[2,n.promise]}}))}))},n.prototype.onConnect=function(e){return i(this,void 0,void 0,(function(){var e;return o(this,(function(t){return e=new yr,this._callbacks.push((function(t){return t?e.reject(t):e.resolve()})),[2,e.promise]}))}))},n.prototype.onDisconnect=function(e,t){var n=t.error,r=void 0===n?null:n,s=t.autoReconnect;return i(this,void 0,void 0,(function(){var t;return o(this,(function(n){switch(n.label){case 0:return t=Date.now(),this._halt(null!=r?r:E.connectionCanceled),e.hasSession?[4,e.changeState(new ni({autoReconnect:s}),t)]:[3,2];case 1:return n.sent(),[3,4];case 2:return[4,e.changeState(new ei,t)];case 3:n.sent(),n.label=4;case 4:return[2]}}))}))},n.prototype.onDisconnectWebSocket=function(e){return i(this,void 0,void 0,(function(){var t;return o(this,(function(n){switch(n.label){case 0:return t=Date.now(),this._halt(E.connectionCanceled),e.hasSession?[4,e.changeState(new ti,t)]:[3,2];case 1:return n.sent(),[3,4];case 2:return[4,e.changeState(new ei,t)];case 3:n.sent(),n.label=4;case 4:return[2]}}))}))},n.prototype.onLogout=function(e){return i(this,void 0,void 0,(function(){var t;return o(this,(function(n){switch(n.label){case 0:return t=Date.now(),this._halt(E.connectionCanceled),[4,e.changeState(new ei,t)];case 1:return n.sent(),[2]}}))}))},n}($r),si=function(e){function n(){var t=null!==e&&e.apply(this,arguments)||this;return t.type=vr.INITIALIZED,t.name="initialized",t}return t(n,e),n.prototype.onConnect=function(e,t){return i(this,void 0,void 0,(function(){var n;return o(this,(function(r){switch(r.label){case 0:return n=Date.now(),[4,e.changeState(new oi({authToken:t}),n)];case 1:return r.sent(),[2]}}))}))},n}($r),ai=function(e){function n(){return e.call(this,{code:"PING",payload:{id:Date.now(),active:1},ackRequired:!1})||this}return t(n,e),n}(br),ci=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 ai;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}(),ui=1048576,li=function(){function e(e){var t,n,r;void 0===e&&(e={}),this.emojiHash=e.emoji_hash||"",this.uploadSizeLimit=e.file_upload_size_limit?e.file_upload_size_limit*ui:Number.MAX_SAFE_INTEGER,this.useReaction=!!e.use_reaction,this.applicationAttributes=null!==(t=e.application_attributes)&&void 0!==t?t:[],this.premiumFeatureList=null!==(n=e.premium_feature_list)&&void 0!==n?n:[],this.deviceTokenCache=this.applicationAttributes.includes("sdk_device_token_cache"),this.enabledChannelMemberShipHistory=this.applicationAttributes.includes("channel_membership_history"),this.allowSdkStatsUpload=null===(r=e.allow_sdk_log_ingestion)||void 0===r||r}return e.payloadify=function(e){return{emoji_hash:e.emojiHash,file_upload_size_limit:e.uploadSizeLimit/ui,application_attributes:e.applicationAttributes,premium_feature_list:e.premiumFeatureList,use_reaction:e.useReaction,allow_sdk_log_ingestion:e.allowSdkStatsUpload}},e}(),hi=function(){function e(e){this._iid="",this._iid=e}return e.payloadify=function(e){return e?{}:null},e}(),di=function(e){function n(t){var n=t.userId,r=t.metadata,i=e.call(this)||this;return i.method=x.POST,i.path="".concat(Ar,"/").concat(n,"/metadata"),i.params={metadata:r},i}return t(n,e),n}(Z),_i=function(e){function n(t,n){var r=e.call(this,t,n)||this;return r.metaData=n,r}return t(n,e),n}(V),fi=function(e){function n(t){var n=t.userId,r=t.metadata,i=t.upsert,o=e.call(this)||this;return o.method=x.PUT,o.path="".concat(Ar,"/").concat(n,"/metadata"),o.params={metadata:r,upsert:i},o}return t(n,e),n}(Z),pi=function(e){function n(t,n){var r=e.call(this,t,n)||this;return r.metadata=n,r}return t(n,e),n}(V),gi=function(e){function n(t){var n=t.userId,r=t.metadataKey,i=e.call(this)||this;return i.method=x.DELETE,i.path="".concat(Ar,"/").concat(n,"/metadata/").concat(r),i}return t(n,e),n}(Z);!function(e){function n(){return null!==e&&e.apply(this,arguments)||this}t(n,e)}(V);var vi=function(e){function n(t){var n=t.userId,r=e.call(this)||this;return r.method=x.DELETE,r.path="".concat(Ar,"/").concat(n,"/metadata"),r}return t(n,e),n}(Z);!function(e){function n(){return null!==e&&e.apply(this,arguments)||this}t(n,e)}(V);var Ei,bi=function(e,t){void 0===t&&(t=null);var n=JSON.parse(JSON.stringify(e));return n._iid&&delete n._iid,t&&t(n),n},mi=function(e,t){void 0===t&&(t=null);var n=JSON.parse(JSON.stringify(e));return t&&t(n),n},yi=function(e){return{do:function(t){e||t()},throw:function(t){if(!e)throw t}}};!function(e){e.ONLINE="online",e.OFFLINE="offline",e.NON_AVAILABLE="nonavailable"}(Ei||(Ei={}));var wi,Si=function(e){function r(t,n){var r,i,o,s,u,l,h,d,_,f,p,g,v=this;return(v=e.call(this,t)||this).userId=null!==(i=null!==(r=n.guest_id)&&void 0!==r?r:n.user_id)&&void 0!==i?i:"",v.nickname=null!==(s=null!==(o=n.nickname)&&void 0!==o?o:n.name)&&void 0!==s?s:"",v.plainProfileUrl=null!==(l=null!==(u=n.profile_url)&&void 0!==u?u:n.image)&&void 0!==l?l:"",v.requireAuth=null!==(h=n.require_auth_for_profile_image)&&void 0!==h&&h,v.metaData=null!==(d=n.metadata)&&void 0!==d?d:{},v.connectionStatus=Ei.NON_AVAILABLE,S(Ei,n.is_online)?v.connectionStatus=n.is_online:w("boolean",n.is_online)&&(v.connectionStatus=n.is_online?Ei.ONLINE:Ei.OFFLINE),v.isActive=null===(_=n.is_active)||void 0===_||_,v.lastSeenAt=null!==(f=n.last_seen_at)&&void 0!==f?f:null,v.preferredLanguages=n.preferred_languages?c([],a(n.preferred_languages),!1):null,v.friendDiscoveryKey=null!==(p=n.friend_discovery_key)&&void 0!==p?p:null,v.friendName=null!==(g=n.friend_name)&&void 0!==g?g:null,v}return t(r,e),r.payloadify=function(t){return t?K(n(n({},e.payloadify.call(this,t)),{user_id:t.userId,nickname:t.nickname,profile_url:t.plainProfileUrl,require_auth_for_profile_image:t.requireAuth,metadata:t.metaData,is_online:t.connectionStatus,is_active:t.isActive,last_seen_at:t.lastSeenAt,preferred_languages:t.preferredLanguages,friend_discovery_key:t.friendDiscoveryKey,friend_name:t.friendName})):null},Object.defineProperty(r.prototype,"profileUrl",{get:function(){var e=Hi.of(this._iid).sessionManager;return this.requireAuth?"".concat(this.plainProfileUrl,"?auth=").concat(e.ekey):this.plainProfileUrl},enumerable:!1,configurable:!0}),r.prototype.serialize=function(){return bi(this)},r.prototype._isValidMetaData=function(e){return!Array.isArray(e)&&Object.keys(e).length>0&&Object.keys(e).map((function(t){return e[t]})).every((function(e){return w("string",e)}))},r.prototype._applyMetaData=function(e,t){var n=this;void 0===t&&(t=!1),Object.keys(e).forEach((function(r){t?delete n.metaData[r]:n.metaData[r]=e[r]}))},r.prototype.createMetaData=function(e){return i(this,void 0,void 0,(function(){var t,n,r,i,s,a;return o(this,(function(o){switch(o.label){case 0:return yi(this._isValidMetaData(e)).throw(E.invalidParameters),t=Hi.of(this._iid),n=t.sdkState,r=t.requestQueue,i=new di({userId:n.userId,metadata:e}),[4,r.send(i)];case 1:return s=o.sent(),a=s.as(_i).metaData,this._applyMetaData(a),[2,this.metaData]}}))}))},r.prototype.updateMetaData=function(e,t){return void 0===t&&(t=!1),i(this,void 0,void 0,(function(){var n,r,i,s,a,c;return o(this,(function(o){switch(o.label){case 0:return yi(this._isValidMetaData(e)).throw(E.invalidParameters),n=Hi.of(this._iid),r=n.sdkState,i=n.requestQueue,s=new fi({userId:r.userId,metadata:e,upsert:t}),[4,i.send(s)];case 1:return a=o.sent(),c=a.as(pi).metadata,this._applyMetaData(c),[2,this.metaData]}}))}))},r.prototype.deleteMetaData=function(e){return i(this,void 0,void 0,(function(){var t,n,r,i,s;return o(this,(function(o){switch(o.label){case 0:return yi(w("string",e)).throw(E.invalidParameters),t=Hi.of(this._iid),n=t.sdkState,r=t.requestQueue,i=new gi({userId:n.userId,metadataKey:e}),[4,r.send(i)];case 1:return o.sent(),this._applyMetaData(((s={})[e]=!0,s),!0),[2,this.metaData]}}))}))},r.prototype.deleteAllMetaData=function(){return i(this,void 0,void 0,(function(){var e,t,n,r;return o(this,(function(i){switch(i.label){case 0:return e=Hi.of(this._iid),t=e.sdkState,n=e.requestQueue,r=new vi({userId:t.userId}),[4,n.send(r)];case 1:return i.sent(),this.metaData={},[2]}}))}))},r}(hi),ki=function(e){function n(t){var n=t.userProfile,r=e.call(this)||this;return r.userProfile=n,r}return t(n,e),n}(j),Ti=function(){function e(e,t){var n,r,i,o,s,a,c,u,l,h,d,_,f,p;this._iid=e,this.appInfo=new li(t),this.user=new Si(e,t),this.connectedAt=null!==(n=t.login_ts)&&void 0!==n?n:0,this.firstConnectedAt=0,this.pingInterval=null!==(r=t.ping_interval)&&void 0!==r?r:15e3,this.pongTimeout=null!==(i=t.pong_timeout)&&void 0!==i?i:5e3,this.reconnectInterval=null!==(s=null===(o=t.reconnect)||void 0===o?void 0:o.interval)&&void 0!==s?s:3e3,this.reconnectMaxInterval=null!==(c=null===(a=t.reconnect)||void 0===a?void 0:a.max_interval)&&void 0!==c?c:6e4,this.reconnectRetryCount=null!==(l=null===(u=t.reconnect)||void 0===u?void 0:u.retry_cnt)&&void 0!==l?l:5,this.reconnectIntervalMultiple=null!==(d=null===(h=t.reconnect)||void 0===h?void 0:h.mul)&&void 0!==d?d:2,this.maxUnreadCountOnSuperGroup=null!==(_=t.max_unread_cnt_on_super_group)&&void 0!==_?_:100,this.profileImageEncryption=!!t.profile_image_encryption,this.concurrentCallLimit=null!==(f=t.concurrent_call_limit)&&void 0!==f?f:5,this.backOffDelay=null!==(p=t.back_off_delay)&&void 0!==p?p:100}return e.payloadify=function(e){return n(n(n({},Si.payloadify(e.user)),li.payloadify(e.appInfo)),{login_ts:e.connectedAt,ping_interval:e.pingInterval,pong_timeout:e.pongTimeout,reconnect:{interval:e.reconnectInterval,max_interval:e.reconnectMaxInterval,retry_cnt:e.reconnectRetryCount,mul:e.reconnectIntervalMultiple},max_unread_cnt_on_super_group:e.maxUnreadCountOnSuperGroup,profile_image_encryption:e.profileImageEncryption,concurrent_call_limit:e.concurrentCallLimit,back_off_delay:e.backOffDelay})},e.prototype.apply=function(){var e=this.reconnectInterval,t=this.reconnectMaxInterval,n=this.reconnectIntervalMultiple,r=Hi.of(this._iid);r.sdkState.websocket.pingInterval=1e3*this.pingInterval,r.sdkState.websocket.pongTimeout=1e3*this.pongTimeout,r.sdkState.websocket.reconnectMaxRetry=this.reconnectRetryCount,r.sdkState.websocket.reconnectRetryStrategy={calcTimeout:function(r){return r>0?1e3*Math.min(e*Math.pow(n,r-1),t):10}},r.appInfo=this.appInfo,r.sessionManager.currentUser=this.user,r.connectedAt=this.connectedAt,this.firstConnectedAt||(r.firstConnectedAt=this.connectedAt),r.maxSuperGroupChannelUnreadCount=this.maxUnreadCountOnSuperGroup,r.concurrentCallLimit=this.concurrentCallLimit,r.backOffDelay=this.backOffDelay,r.dispatcher.dispatch(new ki({userProfile:this}))},e}(),Ci=function(e){function r(t,n,r){var i,o=this;return(o=e.call(this,t,n,r)||this).error=null,o.userProfile=new Ti(t,r),o.deviceTokenLastDeletedAt=r.device_token_last_deleted_at,o.key=r.key,o.ekey=null!==(i=r.ekey)&&void 0!==i?i:"",o.error=r.error?new E(r):null,o}return t(r,e),r.asError=function(e){return new r(null,"LOGI",n({user_id:null,error:!0},e))},r.prototype.applyTo=function(e){return i(this,void 0,void 0,(function(){var t;return o(this,(function(n){switch(n.label){case 0:return this.error?[3,4]:(t=Hi.of(e))?[4,t.sessionManager.login(this)]:[3,2];case 1:return n.sent(),this.userProfile.apply(),[3,3];case 2:throw E.lostInstance;case 3:return[3,5];case 4:throw this.error;case 5:return[2]}}))}))},r}($),Oi=function(e){function r(t){var r=t.request,i=void 0===r||r,o=t.features,s=void 0===o?{}:o,a=t.options,c=void 0===a?{}:a,u=e.call(this)||this;return u.request=i,u.features=n({localCache:!0},s),u.options=n({ingestion:!0},c),u}return t(r,e),r}(j),Ai=function(e){function n(t,n){var r=n.sdkState,i=n.cacheContext,o=n.connectionHandlers,s=n.sessionManager,a=n.websocketClient,c=n.dispatcher,u=n.logger,l=n.entryState,h=void 0===l?new si:l,d=e.call(this)||this;return d._currentState=null,d._loginTimer=null,d._unresolvedLogi=null,d._stateUpdatedAt=0,d._connectingAt=0,d._connectionRequestQueue=[],d._iid=t,d.sdkState=r,d.cacheContext=i,d.connectionHandlers=o,d._sessionManager=s,d._websocketClient=a,d._dispatcher=c,d._logger=u,d._currentState=h,d.sdkState.websocket.pingerDisabled||(d._pinger=new ci({pingDelegate:{send:function(e){return d._websocketClient.send(e)},error:function(e){return d._websocketClient.error(e)}},sdkState:d.sdkState,logger:u})),d._websocketClient.on("open",(function(){d._tryResolveConnectionRequest()})).on("message",(function(e){if("LOGI"===e.code)d.clearLoginTimer(),d._dispatcher.dispatch(e.as(Ci))})).on("ping-refresh",(function(){var e;return null===(e=d._pinger)||void 0===e?void 0:e.refreshTimer()})).on("pong",(function(){var e;return null===(e=d._pinger)||void 0===e?void 0:e.pong()})).on("error",(function(){var e;return null===(e=d._pinger)||void 0===e?void 0:e.stop()})).on("close",(function(){return d._rejectConnectionRequest(E.networkError)})),d._dispatcher.on((function(e){e instanceof Ci&&(d._unresolvedLogi=e,d._tryResolveConnectionRequest())})),d}return t(n,e),Object.defineProperty(n.prototype,"currentState",{get:function(){return this._currentState},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"hasSession",{get:function(){return this._sessionManager.auth.hasSession},enumerable:!1,configurable:!0}),n.prototype.changeState=function(e,t){return i(this,void 0,void 0,(function(){return o(this,(function(n){switch(n.label){case 0:return t>=this._stateUpdatedAt?(this._currentState=e,this._stateUpdatedAt=t,this._dispatcher.dispatch(new Sr({stateType:e.type})),this._logger.debug("connection state changes to ".concat(e.name)),[4,this._currentState.run(this)]):[3,2];case 1:return n.sent(),[2,!0];case 2:return[2,!1]}}))}))},n.prototype._tryResolveConnectionRequest=function(){var e;return i(this,void 0,void 0,(function(){var t,n;return o(this,(function(r){switch(r.label){case 0:return t=this._unresolvedLogi,this._websocketClient.isOpen&&t?(this._unresolvedLogi=null,t.error?[3,2]:[4,t.applyTo(this._iid)]):[3,3];case 1:return r.sent(),n=t.userProfile,this._enableStatLog({request:n.appInfo.applicationAttributes.includes("allow_sdk_request_log_publish"),features:{localCache:n.appInfo.applicationAttributes.includes("allow_sdk_feature_local_cache_log_publish")},options:{ingestion:n.appInfo.allowSdkStatsUpload}}),this._statLogConnection(null),null===(e=this._pinger)||void 0===e||e.start(),this._connectionRequestQueue.forEach((function(e){return e.resolve()})),this._connectionRequestQueue=[],this.sdkState.appState="foreground",[3,3];case 2:this._sessionManager.auth.authToken=null,(t.error.isSessionKeyExpiredError||t.error.isSessionTokenExpiredError)&&this._dispatcher.dispatch(new W),this._rejectConnectionRequest(t.error),r.label=3;case 3:return[2]}}))}))},n.prototype._rejectConnectionRequest=function(e){var t;if(null===(t=this._pinger)||void 0===t||t.stop(),this.clearLoginTimer(),this._connectionRequestQueue.length>0){var n=this._connectionRequestQueue;this._connectionRequestQueue=[],n.forEach((function(t){return t.reject(e)})),this._statLogConnection(e)}},n.prototype._url=function(e){var t;void 0===e&&(e="");var n=this.sdkState,r=n.appId,i=n.appVersion,o=n.userId,s=n.extensions,a=this.cacheContext.localCacheEnabled,c=this._sessionManager.auth,u=null===(t=this.sdkState.websocket)||void 0===t?void 0:t.compression,l=s.sb_syncmanager?"s".concat(s.sb_syncmanager):"",d=s.sb_uikit?"u".concat(s.sb_uikit):"",_="JS/c".concat(h.SDK_VERSION,"/").concat(l,"/").concat(d);return"".concat(this.sdkState.websocket.host,"/?p=JS&pv=").concat(encodeURIComponent(h.OS_VERSION),"&sv=").concat(encodeURIComponent(h.SDK_VERSION),"&ai=").concat(r).concat(i?"&av=".concat(i):"").concat(c.hasSession?"&key=".concat(encodeURIComponent(c.sessionKey)):"&user_id=".concat(encodeURIComponent(o),"&access_token=").concat(encodeURIComponent(e)),"&pmce=").concat(u?1:0,"&active=1&device_token_types=").concat(encodeURIComponent(["gcm","huawei","apns"].join(",")),"&SB-User-Agent=").concat(_,"&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")},n.prototype._enableStatLog=function(e){var t=e.request,n=e.features,r=e.options,i=void 0===r?{}:r;this._dispatcher.dispatch(new Oi({request:t,features:n,options:i}))},n.prototype._statLogConnection=function(e){this._dispatcher.dispatch(new Q(new Y({type:B.WEBSOCKET_CONNECT,data:{host_url:this.sdkState.websocket.host,success:!e,latency:Date.now()-this._connectingAt,error_code:null==e?void 0:e.code,error_description:null==e?void 0:e.message}})))},n.prototype.connect=function(e){return void 0===e&&(e=""),i(this,void 0,void 0,(function(){var t,n,r=this;return o(this,(function(i){return t=this._url(e),n=new yr,this._connectionRequestQueue.push(n),1===this._connectionRequestQueue.length&&(this._connectingAt=Date.now(),this._loginTimer=setTimeout((function(){r._loginTimer=null,r._dispatcher.dispatch(Ci.asError(E.loginTimeout))}),this.sdkState.websocket.responseTimeout),e&&(this._sessionManager.auth.authToken=e),this._websocketClient.connect(t)),[2,n.promise]}))}))},n.prototype.cancelConnectForRetry=function(){this._dispatcher.dispatch(Ci.asError(E.connectionRenew))},n.prototype.disconnect=function(){return i(this,void 0,void 0,(function(){return o(this,(function(e){switch(e.label){case 0:return[4,this._websocketClient.disconnect()];case 1:return e.sent(),[2]}}))}))},n.prototype.logout=function(){return i(this,void 0,void 0,(function(){return o(this,(function(e){switch(e.label){case 0:return this.sdkState.userId=null,this._unresolvedLogi=null,[4,this._sessionManager.clear()];case 1:return e.sent(),[4,this.disconnect()];case 2:return e.sent(),[2]}}))}))},n.prototype.clearLoginTimer=function(){this._loginTimer&&(clearTimeout(this._loginTimer),this._loginTimer=null)},n}(q),Ni=function(){function e(e,t){var n=t.sdkState,r=t.cacheContext,i=t.connectionHandlers,o=t.sessionManager,s=t.websocketClient,a=t.dispatcher,c=t.logger,u=t.disableWebSocketCloseEventHandling,l=void 0!==u&&u;this._context=null,this._disableWebSocketCloseEventHandling=!1,this._externalCalledWebSocketClose=!1,this._logger=c,this._disableWebSocketCloseEventHandling=l,this._context=new Ai(e,{sdkState:n,cacheContext:r,connectionHandlers:i,sessionManager:o,websocketClient:s,dispatcher:a,logger:c}),this._sdkState=n,this._sessionManager=o,this._websocketClient=s}return e.prototype._registerEventDispatcher=function(){var e=this;this._disableWebSocketCloseEventHandling||(this._clearEventDispatcher(),this._sessionEventDispatcherContext=this._sessionManager.on("refresh-authtoken",(function(){e.isConnected||(e._logger.debug("try reconnect by session token refresh"),e.reconnect())})).on("refresh",(function(){e.isConnecting||e.isConnected||(e._logger.debug("try reconnect by session key refresh"),e.reconnect())})),this._websocketEventDispatcherContext=this._websocketClient.on("close",(function(){"foreground"!==e._sdkState.appState||e._externalCalledWebSocketClose||e._sessionManager.isRefreshingAuthToken||(e._logger.debug("try reconnect by websocket connection closed"),e.reconnect())})))},e.prototype._clearEventDispatcher=function(){this._sessionEventDispatcherContext&&(this._sessionEventDispatcherContext.close(),this._sessionEventDispatcherContext=null),this._websocketEventDispatcherContext&&(this._websocketEventDispatcherContext.close(),this._websocketEventDispatcherContext=null)},Object.defineProperty(e.prototype,"isConnected",{get:function(){return this._context.currentState.type===vr.CONNECTED},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"isConnecting",{get:function(){var e=this._context.currentState;return e.type===vr.CONNECTING||e.type===vr.RECONNECTING},enumerable:!1,configurable:!0}),e.prototype.connect=function(e){return i(this,void 0,void 0,(function(){var t;return o(this,(function(n){switch(n.label){case 0:return t=this._context.currentState,this._externalCalledWebSocketClose=!1,[4,t.onConnect(this._context,e)];case 1:return n.sent(),this._registerEventDispatcher(),[2]}}))}))},e.prototype.reconnect=function(){return i(this,void 0,void 0,(function(){var e;return o(this,(function(t){switch(t.label){case 0:return e=this._context.currentState,this._externalCalledWebSocketClose=!1,[4,e.onReconnect(this._context,{})];case 1:return t.sent(),[2]}}))}))},e.prototype.resetAndReconnect=function(){return i(this,void 0,void 0,(function(){var e;return o(this,(function(t){switch(t.label){case 0:return e=this._context.currentState,this._externalCalledWebSocketClose=!1,[4,e.onReconnect(this._context,{resetReconnectCount:!0})];case 1:return t.sent(),[2]}}))}))},e.prototype.background=function(){return i(this,void 0,void 0,(function(){var e;return o(this,(function(t){switch(t.label){case 0:return e=this._context.currentState,this._externalCalledWebSocketClose=!0,[4,e.onDisconnect(this._context,{autoReconnect:!1})];case 1:return t.sent(),[2]}}))}))},e.prototype.disconnect=function(e){return void 0===e&&(e=null),i(this,void 0,void 0,(function(){return o(this,(function(t){switch(t.label){case 0:return[4,this._context.currentState.onDisconnect(this._context,{error:e,autoReconnect:!0})];case 1:return t.sent(),[2]}}))}))},e.prototype.disconnectWebSocket=function(){return i(this,void 0,void 0,(function(){var e;return o(this,(function(t){switch(t.label){case 0:return e=this._context.currentState,this._externalCalledWebSocketClose=!0,[4,e.onDisconnectWebSocket(this._context)];case 1:return t.sent(),[2]}}))}))},e.prototype.logout=function(){return i(this,void 0,void 0,(function(){var e;return o(this,(function(t){switch(t.label){case 0:return e=this._context.currentState,this._clearEventDispatcher(),[4,e.onLogout(this._context)];case 1:return t.sent(),[2]}}))}))},e}(),Ri=function(e){function n(t){var n,r,i,o,s=t.type,a=t.data,c=t.ts,u=void 0===c?Date.now():c,l=e.call(this,{type:s,data:a,ts:u})||this;return l.date=new Date(u),l.key="".concat((n=l.date,r=n.getFullYear(),i=String(n.getMonth()+1).padStart(2,"0"),o=String(n.getDate()).padStart(2,"0"),"".concat(r).concat(i).concat(o)),"_").concat(s),l}return t(n,e),n}(Y),Ii=function(e){function n(t){var n=t.deviceId,r=t.statLogs,i=e.call(this)||this;return i.method=x.POST,i.path="".concat(qr),i.params={device_id:n,log_entries:r.map((function(e){return Y.payloadify(e)}))},i}return t(n,e),n}(Z),Di=function(e,t){var n,r;if(null!==e&&null!==t){var i=Object.keys(e),o=Object.keys(t),u=c([],a(new Set(c(c([],a(i),!1),a(o),!1))),!1),l={};try{for(var h=s(u),d=h.next();!d.done;d=h.next()){var _=d.value,f=typeof e[_],p=typeof t[_];"undefined"===f?l[_]=t[_]:"undefined"===p?l[_]=e[_]:f!==p?l[_]=t[_]:"object"===f&&e[_]&&t[_]?l[_]=Di(e[_],t[_]):l[_]=t[_]}}catch(e){n={error:e}}finally{try{d&&!d.done&&(r=h.return)&&r.call(h)}finally{if(n)throw n.error}}return l}return t};!function(e){e[e.PENDING=0]="PENDING",e[e.COLLECT_ONLY=1]="COLLECT_ONLY",e[e.ENABLED=2]="ENABLED",e[e.DISABLED=3]="DISABLED"}(wi||(wi={}));var Li,xi=function(e){function n(t){var n=t.cacheContext,r=t.requestQueue,i=t.dispatcher,o=t.baseLimit,s=void 0===o?100:o,a=t.maxLimit,c=void 0===a?1e3:a,u=t.minLimit,l=void 0===u?10:u,h=e.call(this)||this;return h.queue=[],h.enabledState=wi.PENDING,h.isFlushing=!1,h.generation=1,h.lastFlushedAt=0,h.commandEventContext=null,h._collectRequestStat=!0,h._collectFeatureLocalCacheStat=!0,h.deviceId=z(),h.cacheContext=n,h.requestQueue=r,h.dispatcher=i,h.baseLimit=s,h.limit=s,h.maxLimit=c,h.minLimit=l,h}return t(n,e),Object.defineProperty(n.prototype,"isEnabled",{get:function(){return this.enabledState===wi.ENABLED},enumerable:!1,configurable:!0}),n.prototype._arrangeStat=function(){var e=[];this._collectRequestStat&&e.push.apply(e,c([],a(this.queue.filter((function(e){return e.type===B.API_RESULT||e.type===B.WEBSOCKET_CONNECT}))),!1)),this._collectFeatureLocalCacheStat&&e.push.apply(e,c([],a(this.queue.filter((function(e){return e.type===B.FEATURE_LOCALCACHE}))),!1)),this.queue=e},n.prototype._save=function(){return i(this,void 0,void 0,(function(){return o(this,(function(e){switch(e.label){case 0:return this.enabledState!==wi.ENABLED?[3,2]:[4,this.cacheContext.preference.set(this.key,{deviceId:this.deviceId,statLogs:this.queue.map((function(e){return Y.payloadify(e)})),generation:this.generation++,lastFlushedAt:this.lastFlushedAt})];case 1:e.sent(),this.dispatch("save",c([],a(this.queue),!1)),e.label=2;case 2:return[2]}}))}))},n.prototype._flush=function(){return i(this,void 0,void 0,(function(){var e,t,n,r,i;return o(this,(function(o){switch(o.label){case 0:if(!this.isEnabled)return[3,10];if(this.isFlushing)return[3,10];this.isFlushing=!0,o.label=1;case 1:return o.trys.push([1,5,9,10]),this._arrangeStat(),e=this.queue.filter((function(e){if(e instanceof Ri){var t=new Date,n=a([e.date.getFullYear(),t.getFullYear()],2),r=n[0],i=n[1];if(r0?(r=new Ii({deviceId:this.deviceId,statLogs:n}),[4,this.requestQueue.send(r)]):[3,4];case 2:return o.sent(),this.dispatch("flush",n),this.queue=c(c([],a(e),!1),a(t),!1).slice(n.length),[4,this._save()];case 3:o.sent(),o.label=4;case 4:return this.limit=this.baseLimit,this.lastFlushedAt=Date.now(),[3,10];case 5:return(i=o.sent())instanceof E?i.code!==u.STAT_LOG_NOT_ALLOWED?[3,7]:[4,this.clear()]:[3,8];case 6:return o.sent(),this.enabledState=wi.DISABLED,[3,8];case 7:i.code===u.STAT_UPLOAD_NOT_ALLOWED&&(this.enabledState=wi.COLLECT_ONLY),o.label=8;case 8:return this.limit=this.limit+20,[3,10];case 9:return this.isFlushing=!1,[7];case 10:return[2]}}))}))},n.prototype.init=function(e){return i(this,void 0,void 0,(function(){var t,n,r=this;return o(this,(function(i){switch(i.label){case 0:return this.key=e,[4,this.cacheContext.preference.get(this.key)];case 1:return(t=i.sent())?(this.deviceId=t.deviceId,this.queue=t.statLogs.map((function(e){return new Y({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,Vr(n)]):[3,4]):[3,4];case 2:return i.sent(),[4,this._flush()];case 3:i.sent(),i.label=4;case 4:return this.commandEventContext||(this.commandEventContext=this.dispatcher.on((function(e){if(e instanceof Q){var t=e.statLog;r.put(t)}else if(e instanceof Oi){var n=e.request,i=e.features,o=e.options;r._collectRequestStat=n,r._collectFeatureLocalCacheStat=null==i?void 0:i.localCache,r._arrangeStat(),r._collectRequestStat||r._collectFeatureLocalCacheStat?r.enabledState=o.ingestion?wi.ENABLED:wi.COLLECT_ONLY:r.enabledState=wi.DISABLED,r.isEnabled?r.queue.length>=r.limit&&r._flush():r.clear()}}))),[2]}}))}))},n.prototype.put=function(e){return i(this,void 0,void 0,(function(){var t,n;return o(this,(function(r){switch(r.label){case 0:return this.enabledState===wi.DISABLED?[3,3]:(e instanceof Ri?this._collectFeatureLocalCacheStat&&(t=a(this.queue.filter((function(t){return t instanceof Ri&&t.key===e.key})),1),(n=t[0])?n.data=Di(n.data,e.data):this.queue.push(e)):this._collectRequestStat&&this.queue.push(e),[4,this._save()]);case 1:return r.sent(),this.queue.length>=this.limit?[4,this._flush()]:[3,3];case 2:r.sent(),r.label=3;case 3:return[2]}}))}))},n.prototype.clear=function(){return i(this,void 0,void 0,(function(){return o(this,(function(e){switch(e.label){case 0:return this.queue=[],this.generation=1,[4,this._save()];case 1:return e.sent(),[2]}}))}))},n.prototype.close=function(){this.commandEventContext&&(this.commandEventContext.close(),this.commandEventContext=null)},n}(q);!function(e){e[e.NONE=0]="NONE",e[e.VERBOSE=1]="VERBOSE",e[e.DEBUG=2]="DEBUG",e[e.INFO=3]="INFO",e[e.WARN=4]="WARN",e[e.ERROR=5]="ERROR"}(Li||(Li={}));var Mi,Ui,Pi,zi,Fi,qi,Gi,ji,Ki,Bi,Zi=function(){function e(){this.level=Li.WARN}return e.prototype.verbose=function(){for(var e=[],t=0;t0})).map((function(e){return e.id}))),this.allowUserSuggestion=null!==(a=e.allow_user_suggestion)&&void 0!==a?a:this.allowUserSuggestion,this.allowMultipleVotes=null!==(c=e.allow_multiple_votes)&&void 0!==c?c:this.allowMultipleVotes},r.payloadify=function(t){return t?K(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 eo.payloadify(e)})),created_by:t.createdBy,allow_user_suggestion:t.allowUserSuggestion,allow_multiple_votes:t.allowMultipleVotes,voted_option_ids:t.votedPollOptionIds})):null},r.prototype.applyPollUpdateEvent=function(e){var t=e._payload.poll;return!(!t||this.id!==t.id||t.updated_at-1){var o=t[r];i>=o._lastVotedAt&&(o.voteCount=e.vote_count,o._lastVotedAt=i)}})),r.req_id&&r.voted_option_ids&&(this.votedPollOptionIds=r.voted_option_ids),!0},r.prototype.serialize=function(){return bi(this)},r}(hi),no=function(e){switch(e){case ji.GROUP:return Rr;case ji.OPEN:return Dr;default:return null}},ro=function(e){switch(e){case ji.GROUP:return"".concat(Mr,"/group_channels");case ji.OPEN:return"".concat(Mr,"/open_channels");default:return null}},io=function(e,t,n){var r,i;switch(e){case zi.CHANNEL:return!0;case zi.USERS:if(t)try{for(var o=s(t),a=o.next();!a.done;a=o.next()){if(a.value===n)return!0}}catch(e){r={error:e}}finally{try{a&&!a.done&&(i=o.return)&&i.call(o)}finally{if(r)throw r.error}}}return!1},oo=function(e,t,n){var r=io(e.mentionType,e.mentionedUserIds,n),i=io(t.mentionType,t.mentionedUserIds,n);return!r&&i?1:r&&!i?-1:0};!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"}(Qi||(Qi={}));var so=function(e){return e.startsWith("EVENT_")||e===Qi.SYNC_MESSAGE_FILL||e===Qi.SYNC_MESSAGE_CHANGELOGS||e===Qi.SYNC_POLL_CHANGELOGS},ao=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}(j),co=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}(j),uo=function(e){function n(t){var n=t.reqId,r=t.source,i=e.call(this)||this;return i.reqId=n,i.source=r,i}return t(n,e),n}(j),lo=function(e){function n(t){var n=t.polls,r=t.source,i=e.call(this)||this;return i.polls=n,i.source=r,i}return t(n,e),n}(j),ho=function(e){function n(t){var n=t.event,r=t.source,i=e.call(this)||this;return i.event=n,i.source=r,i}return t(n,e),n}(j),_o=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}(j),fo=function(){function e(e,t){var n;this._iid=null,this.limit=20,this._isLoading=!1,this._hasNext=!0,this._token="",this._iid=e,this.limit=null!==(n=t.limit)&&void 0!==n?n:20}return Object.defineProperty(e.prototype,"hasNext",{get:function(){return this._hasNext},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"isLoading",{get:function(){return this._isLoading},enumerable:!1,configurable:!0}),e.prototype._validate=function(){return w("number",this.limit)&&this.limit>0},e}(),po=function(e){function n(t,n,r,i){var o=e.call(this,t,i)||this;return o.channelUrl=n,o.channelType=r,o}return t(n,e),n.prototype._validate=function(){return e.prototype._validate.call(this)&&w("string",this.channelUrl)&&S(ji,this.channelType)},n}(fo);export{bi as $,x as A,fo as B,pr as C,Ti as D,q as E,d as F,Yr as G,s as H,S as I,_ as J,p as K,U as L,ji as M,M as N,Li as O,f as P,Ei as Q,Ki as R,E as S,Nr as T,Si as U,Hi as V,$ as W,hi as X,y as Y,Mi as Z,t as _,w as a,zi as a0,Gi as a1,C as a2,Ui as a3,to as a4,qi as a5,br as a6,no as a7,io as a8,u as a9,N as aA,ho as aB,uo as aC,Ir as aD,Fr as aE,Yi as aF,so as aG,Ri as aH,B as aI,Wr as aJ,Xi as aK,Lr as aL,Dr as aM,Vr as aa,yr as ab,Fi as ac,Rr as ad,Qi as ae,ao as af,co as ag,xr as ah,po as ai,Wi as aj,eo as ak,Bi as al,j as am,O as an,I as ao,r as ap,zr as aq,$i as ar,Ji as as,lo as at,ro as au,Mr as av,oo as aw,Pi as ax,v as ay,_o as az,i as b,o as c,Ar as d,K as e,Z as f,n as g,V as h,A as i,Pr as j,Ur as k,T as l,R as m,ee as n,X as o,c as p,a as q,yi as r,mi as s,Sr as t,z as u,l as v,vr as w,Qr as x,mr as y,ki as z}; diff --git a/groupChannel.js b/groupChannel.js index 7adcbc8..dd37275 100644 --- a/groupChannel.js +++ b/groupChannel.js @@ -1 +1 @@ -import{_ as e,e as r,g as s,I as i,R as a,M as o,U as u,X as c,aA as l,p as h,q as d,b as f,c as _,H as m,l as v,a as g,i as y,a3 as C,G as E,az as b,aB as M,at as N,aC as S,ag as U,af as T,A as I,d as A,f as w,h as D,aD as L,ad as k,aE as x,a6 as R,W as F,$ as O,B as H,S as V,s as q,V as B,N as z,ay as Q,x as W,ae as K,r as Y,a9 as J,aF as X,E as Z,t as $,w as ee,ac as te,a7 as ne,aG as re,aH as se,aI as ie,u as oe,a1 as ue,aJ as ce,ai as le,a0 as he,ax as de,aa as pe,J as fe,n as _e,aj as me}from"./__bundle-03ba89c3.js";export{ae as MessageEventSource}from"./__bundle-03ba89c3.js";import{g as ve,N as ge,o as ye,p as Ce,q as Ee,r as be,t as Me,u as Ne,w as Se,x as Ue,P as Te,y as Ie,z as Ae,A as we,C as De,D as Le,E as ke,G as Pe,H as xe,I as Re,f as Fe,J as Oe,K as He}from"./__bundle-edc633d6.js";import{G as Ge,g as Ve,D as qe,l as Be,m as je,n as ze,j as Qe,i as We,o as Ke,R as Ye,p as Je,k as Xe,U as Ze,e as $e,f as et,s as tt,d as nt,S as rt,v as st,q as it,r as at,P as ot,t as ut}from"./__bundle-7ac921c4.js";export{n as GroupChannelEventSource,G as GroupChannelListOrder,p as MessageFilter,P as PublicGroupChannelListOrder,t as ScheduledMessageListOrder}from"./__bundle-7ac921c4.js";import{C as ct,a as lt,O as ht,P as dt,M as pt,T as ft,R as _t,U as mt,A as vt,B as gt}from"./__bundle-7e9a42ec.js";import{j as yt,S as Ct,I as Et,p as bt,U as Mt,F as Nt,k as St,b as Ut,T as Tt,c as It,A as At,l as wt,f as Dt,m as Lt,n as kt}from"./__bundle-51a2cdbc.js";export{j as ScheduledStatus}from"./__bundle-51a2cdbc.js";import{b as Pt}from"./__bundle-9e0eba5d.js";var xt;!function(e){e.NONE="none",e.JOINED="joined",e.INVITED="invited",e.LEFT="left"}(xt||(xt={}));var Rt,Ft,Ot,Ht,Gt,Vt,qt,Bt,jt=function(t){function n(e,n){var r=t.call(this,e,n)||this;return r.state=null,r.role=null,r.isMuted=!1,r.isBlockedByMe=!1,r.isBlockingMe=!1,r.state=i(xt,n.state)?n.state:null,r.role=i(a,n.role)?n.role:null,n.hasOwnProperty("is_muted")&&(r.isMuted=n.is_muted),n.hasOwnProperty("is_blocked_by_me")&&(r.isBlockedByMe=n.is_blocked_by_me),n.hasOwnProperty("is_blocking_me")&&(r.isBlockingMe=n.is_blocking_me),r}return e(n,t),n.payloadify=function(e){return e?r(s(s({},t.payloadify.call(this,e)),{state:e.state,role:e.role,is_muted:e.isMuted,is_blocked_by_me:e.isBlockedByMe,is_blocking_me:e.isBlockingMe})):null},n}(ve),zt=function(t){function n(e,n){var r,s,i=this;return(i=t.call(this,e)||this).channelUrl=null!==(r=n.channel_url)&&void 0!==r?r:"",i.channelType=null!==(s=n.channel_type)&&void 0!==s?s:o.GROUP,i.reader=new u(i._iid,n.user),i.readAt=n.ts,i}return e(n,t),n}(c);!function(e){e.ALL="all",e.PUBLIC="public",e.PRIVATE="private"}(Rt||(Rt={})),function(e){e.ALL="all",e.JOINED="joined_only",e.INVITED="invited_only",e.INVITED_BY_FRIEND="invited_by_friend",e.INVITED_BY_NON_FRIEND="invited_by_non_friend"}(Ft||(Ft={})),function(e){e.ALL="all",e.SUPER="super",e.NON_SUPER="nonsuper",e.BROADCAST_ONLY="broadcast_only",e.EXCLUSIVE_ONLY="exclusive_only"}(Ot||(Ot={})),function(e){e.ALL="all",e.UNREAD_MESSAGE="unread_message"}(Ht||(Ht={})),function(e){e.ALL="all",e.UNHIDDEN="unhidden_only",e.HIDDEN="hidden_only",e.HIDDEN_ALLOW_AUTO_UNHIDE="hidden_allow_auto_unhide",e.HIDDEN_PREVENT_AUTO_UNHIDE="hidden_prevent_auto_unhide"}(Gt||(Gt={})),function(e){e.ALL="all",e.OPERATOR="operator",e.NONOPERATOR="nonoperator"}(Vt||(Vt={})),function(e){e.AND="AND",e.OR="OR"}(qt||(qt={})),function(e){e.MEMBER_NICKNAME="member_nickname",e.CHANNEL_NAME="channel_name"}(Bt||(Bt={}));var Qt,Wt=function(){function e(){this._searchFilter=null,this._userIdsFilter=null,this.includeEmpty=!1,this.nicknameContainsFilter=null,this.nicknameStartsWithFilter=null,this.nicknameExactMatchFilter=null,this.channelNameContainsFilter="",this.myMemberStateFilter=Ft.ALL,this.customTypesFilter=null,this.channelUrlsFilter=null,this.superChannelFilter=Ot.ALL,this.publicChannelFilter=Rt.ALL,this.customTypeStartsWithFilter=null,this.unreadChannelFilter=Ht.ALL,this.hiddenChannelFilter=Gt.UNHIDDEN,this.includeFrozen=!0}return e.prototype._isFriend=function(e){return!!e.friendDiscoveryKey||!!e.friendName},Object.defineProperty(e.prototype,"searchFilter",{get:function(){return this._searchFilter},enumerable:!1,configurable:!0}),e.prototype.setSearchFilter=function(e,t){Array.isArray(e)&&0!==e.length&&"string"==typeof t&&t&&(this._searchFilter={query:t,fields:e})},Object.defineProperty(e.prototype,"userIdsFilter",{get:function(){return this._userIdsFilter},enumerable:!1,configurable:!0}),e.prototype.setUserIdsFilter=function(e,t,n){void 0===n&&(n=qt.AND),this._userIdsFilter={userIds:e,includeMode:t,queryType:n}},e.prototype.clone=function(){var t=new e;this.searchFilter&&t.setSearchFilter(this.searchFilter.fields,this.searchFilter.query),this.userIdsFilter&&t.setUserIdsFilter(this.userIdsFilter.userIds,this.userIdsFilter.includeMode,this.userIdsFilter.queryType);var n=JSON.parse(JSON.stringify(this));return Object.keys(n).forEach((function(e){t[e]=n[e]})),t},e.prototype.match=function(e,t){if(this._searchFilter){var n=this._searchFilter,r=n.query,s=n.fields;if(r&&s&&s.length>0&&!s.some((function(t){switch(t){case Bt.CHANNEL_NAME:return e.name.toLowerCase().includes(r.toLowerCase());case Bt.MEMBER_NICKNAME:return e.members.some((function(e){return e.nickname.toLowerCase().includes(r.toLowerCase())}));default:return!0}})))return!1}if(this._userIdsFilter){var i=this._userIdsFilter,a=i.userIds,o=i.includeMode,u=i.queryType,c=e.members.map((function(e){return e.userId}));if(o){if(a.length>0)switch(u){case qt.AND:if(a.some((function(e){return!c.includes(e)})))return!1;break;case qt.OR:if(a.every((function(e){return!c.includes(e)})))return!1}}else{if(a.includes(t)||a.push(t),e.members.length>a.length)return!1;if(!l(a,c))return!1}}if(!this.includeEmpty&&!e.lastMessage)return!1;if(!this.includeFrozen&&e.isFrozen)return!1;if(this.customTypesFilter&&this.customTypesFilter.length>0&&!this.customTypesFilter.includes(e.customType))return!1;if(this.customTypeStartsWithFilter&&!new RegExp("^".concat(this.customTypeStartsWithFilter)).test(e.customType))return!1;if(this.channelNameContainsFilter&&!e.name.toLowerCase().includes(this.channelNameContainsFilter.toLowerCase()))return!1;if(this.nicknameContainsFilter){var h=this.nicknameContainsFilter.toLowerCase();if(!e.members.some((function(e){return e.userId!==t&&e.nickname.toLowerCase().includes(h)})))return!1}if(this.nicknameStartsWithFilter){var d=this.nicknameStartsWithFilter.toLowerCase();if(!e.members.some((function(e){return e.userId!==t&&e.nickname.toLowerCase().startsWith(d)})))return!1}if(this.nicknameExactMatchFilter){var p=this.nicknameExactMatchFilter.toLowerCase();if(!e.members.some((function(e){return e.userId!==t&&e.nickname.toLowerCase()!=p})))return!1}if(this.channelUrlsFilter&&this.channelUrlsFilter.length>0&&!this.channelUrlsFilter.includes(e.url))return!1;if(this.myMemberStateFilter)switch(this.myMemberStateFilter){case Ft.JOINED:if("joined"!==e.myMemberState)return!1;break;case Ft.INVITED:if("invited"!==e.myMemberState)return!1;break;case Ft.INVITED_BY_FRIEND:if("invited"!==e.myMemberState||!this._isFriend(e.inviter))return!1;break;case Ft.INVITED_BY_NON_FRIEND:if("invited"!==e.myMemberState||this._isFriend(e.inviter))return!1}if(this.hiddenChannelFilter)switch(this.hiddenChannelFilter){case Gt.UNHIDDEN:if(e.isHidden||"unhidden"!==e.hiddenState)return!1;break;case Gt.HIDDEN:if(!e.isHidden)return!1;break;case Gt.HIDDEN_ALLOW_AUTO_UNHIDE:if(!e.isHidden||"hidden_allow_auto_unhide"!==e.hiddenState)return!1;break;case Gt.HIDDEN_PREVENT_AUTO_UNHIDE:if(!e.isHidden||"hidden_prevent_auto_unhide"!==e.hiddenState)return!1}if(this.unreadChannelFilter&&this.unreadChannelFilter===Ht.UNREAD_MESSAGE)if(0===e.unreadMessageCount)return!1;if(this.publicChannelFilter)switch(this.publicChannelFilter){case Rt.PUBLIC:if(!e.isPublic)return!1;break;case Rt.PRIVATE:if(e.isPublic)return!1}if(this.superChannelFilter)switch(this.superChannelFilter){case Ot.SUPER:if(!e.isSuper)return!1;break;case Ot.NON_SUPER:if(e.isSuper)return!1}return!0},e}(),Kt=function(t){function n(e,n){var r=n.sdkState,s=n.cacheContext,i=t.call(this,e)||this;return i._channels=new Map,i._sdkState=r,i._cacheContext=s,i}return e(n,t),Object.defineProperty(n.prototype,"collection",{get:function(){var e=this._cacheContext.nestdb;return e?e.collection(ge):null},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"localCacheEnabled",{get:function(){return this._cacheContext.localCacheEnabled&&!!this.collection},enumerable:!1,configurable:!0}),n.prototype._serialize=function(e,t){return void 0===t&&(t=0),s(s({},e.serialize()),{lastMessageUpdatedAt:e.lastMessage?e.lastMessage.createdAt:0,syncIndex:t})},n.prototype._deserialize=function(e){return er.of(this._iid).buildGroupChannelFromSerializedData(e)},Object.defineProperty(n.prototype,"channels",{get:function(){return h([],d(this._channels.values()),!1)},enumerable:!1,configurable:!0}),n.prototype.isCachedInMemory=function(e){return this._channels.has(e)},n.prototype.filterOffsetChanged=function(e){var t=this;return e.filter((function(e){if(t._channels.has(e.url))return t._channels.get(e.url).messageOffsetTimestamp0)return!1;if(h&&h===e.url)return!1;break;case Ge.CHRONOLOGICAL:if(!i&&e.createdAt>t||i&&e.createdAtt||i&&e.lastMessageUpdatedAt0?[4,this.upsert(r)]:[3,2];case 1:_.sent(),_.label=2;case 2:return[2]}}))}))},n.prototype.block=function(e,t){return f(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]}}))}))},n.prototype.unblock=function(e,t){return f(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]}}))}))},n.prototype.markAsRead=function(e,t){return void 0===t&&(t=h([],d(this._channels.keys()),!1)),f(this,void 0,void 0,(function(){var n,r,s,i,a,o,u,c;return _(this,(function(l){switch(l.label){case 0:n=[],l.label=1;case 1:l.trys.push([1,6,7,8]),r=m(t),s=r.next(),l.label=2;case 2:return s.done?[3,5]:(i=s.value,[4,this.get(i)]);case 3:(a=l.sent())._updateUnreadMemberState(this._sdkState.userId,e)&&(a._updateUnreadCount(0,0),n.push(a)),l.label=4;case 4:return s=r.next(),[3,2];case 5:return[3,8];case 6:return o=l.sent(),u={error:o},[3,8];case 7:try{s&&!s.done&&(c=r.return)&&c.call(r)}finally{if(u)throw u.error}return[7];case 8:return n.length>0?[4,this.upsert(n)]:[3,10];case 9:l.sent(),l.label=10;case 10:return[2]}}))}))},n}(c),Yt={invitedUserIds:null,channelUrl:null,coverUrl:null,coverImage:null,isDistinct:null,isSuper:null,isBroadcast:null,isExclusive:null,isPublic:null,isDiscoverable:null,isStrict:null,isEphemeral:null,accessCode:null,name:null,data:null,customType:null,operatorUserIds:null,messageSurvivalSeconds:null},Jt=function(e){return 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)},Xt={customTypes:null,includeEmpty:!1,includeFrozen:!0},Zt=function(e){return v("string",e.customTypes,!0)&&g("boolean",e.includeEmpty)&&g("boolean",e.includeFrozen)},$t={myMemberStateFilter:Ft.ALL},en=function(e){return i(Ft,e.myMemberStateFilter)};!function(e){e.GROUP_CHANNEL_UNREAD_MENTION_COUNT="group_channel_unread_mention_count",e.NONSUPER_UNREAD_MENTION_COUNT="non_super_group_channel_unread_mention_count",e.SUPER_UNREAD_MENTION_COUNT="super_group_channel_unread_mention_count",e.GROUP_CHANNEL_UNREAD_MESSAGE_COUNT="group_channel_unread_message_count",e.NONSUPER_UNREAD_MESSAGE_COUNT="non_super_group_channel_unread_message_count",e.SUPER_UNREAD_MESSAGE_COUNT="super_group_channel_unread_message_count",e.GROUP_CHANNEL_INVITATION_COUNT="group_channel_invitation_count",e.NONSUPER_INVITATION_COUNT="non_super_group_channel_invitation_count",e.SUPER_INVITATION_COUNT="super_group_channel_invitation_count"}(Qt||(Qt={}));var tn={keys:[]},nn={channelCustomTypesFilter:null,superChannelFilter:Ot.ALL},rn={channelUrl:null,scheduledStatus:null,messageTypeFilter:C.ALL},sn=function(){function e(e){var t=e.groupChannelCache,n=e.messageCache,r=e.unsentMessageCache,s=e.dispatcher,i=this;this._observers=new Map,s.on((function(e){return f(i,void 0,void 0,(function(){var s,i,a,o,u,c,l,h,d,p,v,g,y=this;return _(this,(function(C){switch(C.label){case 0:if(!(e instanceof je))return[3,10];s=e.channels,p=e.source,i=e.data,a=s.filter((function(e){return e instanceof os})),o=t.filterOffsetChanged(a),C.label=1;case 1:C.trys.push([1,6,7,8]),u=m(o),c=u.next(),C.label=2;case 2:return c.done?[3,5]:(l=c.value,[4,n.removeUnderOffset(l.url,l.messageOffsetTimestamp)]);case 3:C.sent(),C.label=4;case 4:return c=u.next(),[3,2];case 5:return[3,8];case 6:return h=C.sent(),v={error:h},[3,8];case 7:try{c&&!c.done&&(g=u.return)&&g.call(u)}finally{if(v)throw v.error}return[7];case 8:return[4,t.upsert(a)];case 9:return C.sent(),this._broadcastUpdateEvent(a,p,i),[3,15];case 10:return e instanceof Be?(d=e.channelUrls,p=e.source,[4,t.remove(d)]):[3,13];case 11:return C.sent(),[4,E((function(){return f(y,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(d),t=e.next(),u.label=1;case 1:return t.done?[3,5]:(s=t.value,[4,n.removeMessagesOfChannel(s)]);case 2:return u.sent(),[4,r.removeMessagesOfChannel(s)];case 3:u.sent(),u.label=4;case 4:return t=e.next(),[3,1];case 5:return[3,8];case 6:return i=u.sent(),a={error:i},[3,8];case 7:try{t&&!t.done&&(o=e.return)&&o.call(e)}finally{if(a)throw a.error}return[7];case 8:return[2]}}))}))}))];case 12:return C.sent(),this._broadcastRemoveEvent(d,p),[3,15];case 13:return e instanceof qe?[4,t.fetch({token:Number.MAX_SAFE_INTEGER,limit:Number.MAX_SAFE_INTEGER})]:[3,15];case 14:C.sent(),C.label=15;case 15:return[2]}}))}))}))}return e.prototype._broadcastUpdateEvent=function(e,t,n){var r,s;try{for(var i=m(this._observers.values()),a=i.next();!a.done;a=i.next()){a.value.onUpdate(e,t,n)}}catch(e){r={error:e}}finally{try{a&&!a.done&&(s=i.return)&&s.call(i)}finally{if(r)throw r.error}}},e.prototype._broadcastRemoveEvent=function(e,t){var n,r;try{for(var s=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.prototype.unsubscribeAll=function(){this._observers.clear()},e}(),an=function(){function e(e){var t=e.cacheContext,n=e.messageCache,r=e.unsentMessageCache,s=e.dispatcher,i=e.logger,a=this;this._cacheContext=null,this._observers=new Map,this._logger=null,this._cacheContext=t,this._logger=i,s.on((function(e){return f(a,void 0,void 0,(function(){var t,s,i,a,o,u,c,l,h,d,p,m,v,g=this;return _(this,(function(y){switch(y.label){case 0:return e instanceof T?(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,E((function(){return f(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 Ct?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,E((function(){return f(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 U?(a=e.messageIds,m=e.source,[4,E((function(){return f(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 S?(o=e.reqId,m=e.source,[4,E((function(){return f(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 N?(u=e.polls,m=e.source,this._cacheContext.localCacheEnabled?(c=u.map((function(e){return e.messageId})),[4,Promise.all(c.map((function(e){return n.get(e)})))]):[3,12]):[3,13];case 10:return(l=y.sent().filter((function(e){return e}))).length>0&&u.forEach((function(e){var t=l.find((function(t){return t.messageId===e.messageId}));t&&t.applyPoll(e)})),[4,E((function(){return f(g,void 0,void 0,(function(){return _(this,(function(e){switch(e.label){case 0:return[4,n.upsert(l)];case 1:return[2,e.sent()]}}))}))}))];case 11:y.sent(),y.label=12;case 12:return this._broadcastPollChangeLogEvent(u,m),[3,21];case 13:return e instanceof M?(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,E((function(){return f(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 b?(p=e.event,m=e.source,[4,n.get(p.messageId)]):[3,21];case 18:return(v=y.sent())&&v.isUserMessage()&&v.poll&&v.poll.applyPollVoteEvent(p)?[4,E((function(){return f(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(p,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.prototype.unsubscribeAll=function(){this._observers.clear()},e}(),on=function(t){function n(e){var n=e.userId,i=e.ts,a=e.token,o=e.filter,u=t.call(this)||this,c=s(s({},Xt),o),l=c.customTypes,h=c.includeEmpty,d=c.includeFrozen;return u.method=I.GET,u.path="".concat(A,"/").concat(encodeURIComponent(n),"/my_group_channels/changelogs"),u.params=r({show_delivery_receipt:!0,show_member:!0,show_read_receipt:!0,change_ts:i>0?i:null,token:a,custom_types:l,show_empty:h,show_frozen:d}),u}return e(n,t),n}(w),un=function(t){function n(e,n){var r=t.call(this,e,n)||this;return r.updatedChannels=n.updated.map((function(t){return new os(e,t)})),r.deletedChannelUrls=n.deleted,r.hasMore=n.has_more,r.token=n.next,r}return e(n,t),n}(D),cn=function(t){function n(e){var n=e.channelUrl,r=e.isInternalCall,s=t.call(this)||this;return s.method=I.GET,s.path="".concat(r?L:k,"/").concat(encodeURIComponent(n)),s.params={show_member:!0,show_read_receipt:!0,show_delivery_receipt:!0},s}return e(n,t),n}(w),ln=function(t){function n(e,n){var r=t.call(this,e,n)||this;return r.channel=null,r.channel=new os(e,n),r}return e(n,t),n}(D),hn=function(t){function n(e){var n=this,s=e.userId,i=e.token,a=e.limit,o=e.order,u=e.includeEmpty,c=e.myMemberStateFilter,l=e.superChannelFilter,h=e.publicChannelFilter,d=e.unreadChannelFilter,p=e.nicknameContainsFilter,f=e.nicknameStartsWithFilter,_=e.nicknameExactMatchFilter,m=e.channelNameContainsFilter,v=e.channelUrlsFilter,g=e.customTypesFilter,y=e.customTypeStartsWithFilter,C=e.hiddenChannelFilter,E=e.metadataOrderKeyFilter,b=e.metadataKey,M=e.metadataValues,N=e.metadataValueStartsWith,S=e.includeFrozen,U=e.includeMetaData,T=e.searchFilter,w=e.userIdsFilter;return(n=t.call(this)||this).method=I.GET,n.path="".concat(A,"/").concat(encodeURIComponent(s),"/my_group_channels"),n.params=r({token:i,limit:a,order:o,show_member:!0,show_read_receipt:!0,show_delivery_receipt:!0,show_empty:u,member_state_filter:c,super_mode:l,public_mode:h,unread_filter:d,members_nickname_contains:p,members_nickname_startswith:f,members_nickname:_,name_contains:m,channel_urls:v,custom_types:g,custom_type_startswith:y,hidden_mode:C,metadata_order_key:E,metadata_key:b,metadata_values:M,metadata_value_startswith:N,show_frozen:S,show_metadata:U}),T&&T.query&&T.fields&&(n.params.search_query=T.query,n.params.search_fields=T.fields),w&&w.userIds&&w.userIds.length>0&&(w.includeMode?(n.params.members_include_in=w.userIds,n.params.query_type=w.queryType.toUpperCase()):n.params.members_exactly_in=w.userIds),n}return e(n,t),n}(w),dn=function(t){function n(e,n){var r=t.call(this,e,n)||this;r.token=null,r.channels=[],r.ts=null;var s=n.next,i=n.channels,a=n.ts;return r.token=s,i&&i.length>0&&(r.channels=i.map((function(t){return t.ts=a,new os(e,t)}))),r.ts=null!=a?a:null,r}return e(n,t),n}(D),pn=function(t){function n(e){var n=e.userId,r=e.filter,s=t.call(this)||this,i=r.myMemberStateFilter;return s.method=I.GET,s.path="".concat(A,"/").concat(encodeURIComponent(n),"/group_channel_count"),s.params={state:null!=i?i:Ft.ALL},s}return e(n,t),n}(w),fn=function(t){function n(e,n){var r=t.call(this,e,n)||this;return r.groupChannelCount=n.group_channel_count,r}return e(n,t),n}(D),_n=function(t){function n(e){var n=e.userId,r=e.filter,s=t.call(this)||this,i=r.keys;return s.method=I.GET,s.path="".concat(A,"/").concat(encodeURIComponent(n),"/unread_item_count"),s.params={item_keys:i},s}return e(n,t),n}(w),mn=function(t){function n(e,n){var r=t.call(this,e,n)||this;return"number"==typeof n[Qt.GROUP_CHANNEL_UNREAD_MENTION_COUNT]&&(r.groupChannelUnreadMentionCount=n[Qt.GROUP_CHANNEL_UNREAD_MENTION_COUNT]),"number"==typeof n[Qt.GROUP_CHANNEL_UNREAD_MESSAGE_COUNT]&&(r.groupChannelUnreadMessageCount=n[Qt.GROUP_CHANNEL_UNREAD_MESSAGE_COUNT]),"number"==typeof n[Qt.GROUP_CHANNEL_INVITATION_COUNT]&&(r.groupChannelInvitationCount=n[Qt.GROUP_CHANNEL_INVITATION_COUNT]),"number"==typeof n[Qt.SUPER_UNREAD_MENTION_COUNT]&&(r.superGroupChannelUnreadMentionCount=n[Qt.SUPER_UNREAD_MENTION_COUNT]),"number"==typeof n[Qt.SUPER_UNREAD_MESSAGE_COUNT]&&(r.superGroupChannelUnreadMessageCount=n[Qt.SUPER_UNREAD_MESSAGE_COUNT]),"number"==typeof n[Qt.SUPER_INVITATION_COUNT]&&(r.superGroupChannelInvitationCount=n[Qt.SUPER_INVITATION_COUNT]),"number"==typeof n[Qt.NONSUPER_UNREAD_MENTION_COUNT]&&(r.nonSuperGroupChannelUnreadMentionCount=n[Qt.NONSUPER_UNREAD_MENTION_COUNT]),"number"==typeof n[Qt.NONSUPER_UNREAD_MESSAGE_COUNT]&&(r.nonSuperGroupChannelUnreadMessageCount=n[Qt.NONSUPER_UNREAD_MESSAGE_COUNT]),"number"==typeof n[Qt.NONSUPER_INVITATION_COUNT]&&(r.nonSuperGroupChannelInvitationCount=n[Qt.NONSUPER_INVITATION_COUNT]),r}return e(n,t),n}(D),vn=function(t){function n(e){var n=e.userId,r=t.call(this)||this;return r.method=I.GET,r.path="".concat(A,"/").concat(encodeURIComponent(n),"/unread_channel_count"),r}return e(n,t),n}(w),gn=function(t){function n(e,n){var r=t.call(this,e,n)||this;return r.unreadCount=n.unread_count,r}return e(n,t),n}(D),yn=function(t){function n(e){var n=e.userId,r=e.filter,s=t.call(this)||this,i=r.channelCustomTypesFilter,a=r.superChannelFilter;return s.method=I.GET,s.path="".concat(A,"/").concat(encodeURIComponent(n),"/unread_message_count"),s.params={super_mode:null!=a?a:Ot.ALL,custom_types:i},s}return e(n,t),n}(w),Cn=function(t){function n(e,n){var r=t.call(this,e,n)||this;return r.unreadCount=n.unread_count,r}return e(n,t),n}(D),En=function(t){function n(e){var n=e.channelUrl,r=e.scheduledStatus,s=e.messageTypeFilter,i=t.call(this)||this;return i.method=I.GET,i.path="".concat(x,"/count"),i.params={channel_url:n,status:Mn(r)},s&&(i.params.message_type=s),i}return e(n,t),n}(w),bn=function(t){function n(e,n){var r=t.call(this,e,n)||this;return r.count=n.count,r}return e(n,t),n}(D),Mn=function(e){if(e){var t=[];return e.forEach((function(e){switch(e){case yt.PENDING:t.push(Et.PENDING);break;case yt.SENT:t.push(Et.IN_QUEUE),t.push(Et.SENT);break;case yt.CANCELED:t.push(Et.CANCELED);break;case yt.FAILED:t.push(Et.FAILED)}})),t}},Nn=function(t){function n(e){var n=this,s=e.userId,i=e.channelUrl,a=e.coverUrl,o=e.coverImage,u=e.isDistinct,c=e.isSuper,l=e.isBroadcast,p=e.isPublic,f=e.isExclusive,_=e.isDiscoverable,m=e.isStrict,v=e.isEphemeral,g=e.accessCode,y=e.name,C=e.data,E=e.customType,b=e.messageSurvivalSeconds,M=e.invitedUserIds,N=e.operatorUserIds;return(n=t.call(this)||this).method=I.POST,n.path=k,n.params=r({user_ids:h([s],d(null!=M?M:[]),!1).filter((function(e,t,n){return t===n.indexOf(e)})),channel_url:i,cover_url:a,cover_file:o,is_distinct:u,is_super:c,is_broadcast:l,is_exclusive:f,is_public:p,is_discoverable:_,strict:m,is_ephemeral:v,access_code:g,name:y,data:C,custom_type:E,operator_ids:N,message_survival_seconds:b}),n}return e(n,t),n}(w),Sn=function(t){function n(e,n){var r=t.call(this,e,n)||this;return r.channel=new os(e,n),r.isCreated=n.is_created,r}return e(n,t),n}(D),Un=function(t){function n(e){var n=e.userId,r=e.channelUrls,s=t.call(this)||this;return s.method=I.PUT,s.path="".concat(A,"/").concat(encodeURIComponent(n),"/mark_as_read_all"),s.params={channel_urls:r},s}return e(n,t),n}(w);!function(t){function n(){return null!==t&&t.apply(this,arguments)||this}e(n,t)}(D);var Tn=function(t){function n(e){var n=this,r=e.channelUrl,s=e.userId,i=e.accessCode;return(n=t.call(this)||this).method=I.PUT,n.path="".concat(k,"/").concat(encodeURIComponent(r),"/join"),n.params={user_id:s,access_code:i},n}return e(n,t),n}(w),In=function(t){function n(e,n){var r=t.call(this,e,n)||this;return r.channel=new os(e,n),r}return e(n,t),n}(D),An=function(t){function n(e,n,r){var s=t.call(this,e,n,r)||this,i=r.data,a=i.member_count,o=void 0===a?null:a,u=i.joined_member_count,c=void 0===u?null:u,l=i.users,h=void 0===l?null:l;return s.memberCount=o,s.joinedMemberCount=c,s.members=Array.isArray(h)?h.map((function(t){return new jt(e,t)})):[new jt(e,r.data)],s}return e(n,t),n}(ct),wn=function(t){function n(e){var n=this,r=e.channelUrl,s=e.userId,i=e.shouldRemoveOperatorStatus;return(n=t.call(this)||this).method=I.PUT,n.path="".concat(k,"/").concat(encodeURIComponent(r),"/leave"),n.params={user_id:s,should_remove_operator_status:i},n}return e(n,t),n}(w);!function(t){function n(e,n){return t.call(this,e,n)||this}e(n,t)}(D);var Dn=function(t){function n(e,n,r){var s=t.call(this,e,n,r)||this,i=r.data,a=i.member_count,o=void 0===a?null:a,u=i.joined_member_count,c=void 0===u?null:u;return s.memberCount=o,s.joinedMemberCount=c,s.member=new jt(s._iid,r.data),s}return e(n,t),n}(ct),Ln=function(t){function n(e){var n=this,r=e.channelUrl,s=e.userIds;return(n=t.call(this)||this).method=I.POST,n.path="".concat(k,"/").concat(encodeURIComponent(r),"/invite"),n.params={user_ids:s},n}return e(n,t),n}(w),kn=function(t){function n(e,n){var r=t.call(this,e,n)||this;return r.channel=new os(e,n),r}return e(n,t),n}(D),Pn=function(t){function n(e,n,r){var s=t.call(this,e,n,r)||this,i=r.data,a=i.member_count,o=void 0===a?null:a,c=i.joined_member_count,l=void 0===c?null:c,h=i.inviter,d=void 0===h?null:h,p=i.invitees,f=void 0===p?[]:p;return s.memberCount=o,s.joinedMemberCount=l,s.inviter=d?new u(e,d):null,s.invitees=f.map((function(t){return new jt(e,t)})),s}return e(n,t),n}(ct),xn=function(t){function n(e){var n=this,r=e.channelUrl,s=e.userId;return(n=t.call(this)||this).method=I.PUT,n.path="".concat(k,"/").concat(encodeURIComponent(r),"/decline"),n.params={user_id:s},n}return e(n,t),n}(w);!function(t){function n(e,n){var r=t.call(this,e,n)||this;return r.channel=new os(e,n),r.channel.myMemberState=xt.NONE,r}e(n,t)}(D);var Rn=function(t){function n(e,n,r){var s=t.call(this,e,n,r)||this,i=r.data,a=i.member_count,o=void 0===a?null:a,c=i.joined_member_count,l=void 0===c?null:c,h=i.inviter,d=void 0===h?null:h,p=i.invitee,f=void 0===p?null:p;return s.memberCount=o,s.joinedMemberCount=l,s.inviter=d?new u(e,d):null,s.invitee=f?new jt(e,f):null,s}return e(n,t),n}(ct),Fn=function(t){function n(e){var n=e.channelUrl;return t.call(this,{code:"READ",ackRequired:!0,payload:{channel_url:n}})||this}return e(n,t),n}(R),On=function(t){function n(e,n,r){var s=t.call(this,e,"READ",r)||this;return s.readStatus=new zt(e,r),s}return e(n,t),n}(F),Hn=function(t){function n(e){var n=e.channelUrl,s=e.userId,i=t.call(this)||this;return(i=t.call(this)||this).method=I.PUT,i.path="".concat(k,"/").concat(encodeURIComponent(n),"/messages/mark_as_delivered"),i.params=r({userId:s}),i}return e(n,t),n}(w);!function(t){function n(){return null!==t&&t.apply(this,arguments)||this}e(n,t)}(D);var Gn,Vn=function(t){function n(e,n,r){var s=t.call(this,e,"DLVR",r)||this;return s.channelUrl=r.channel_url,s.deliveredStateUpdate=r.updated,s}return e(n,t),n}(F),qn=function(t){function n(e){var n=this,r=e.channelUrl,s=e.userId,i=e.hidePreviousMessages,a=e.allowAutoUnhide;return(n=t.call(this)||this).method=I.PUT,n.path="".concat(k,"/").concat(encodeURIComponent(r),"/hide"),n.params={user_id:s,hide_previous_messages:i,allow_auto_unhide:a},n}return e(n,t),n}(w),Bn=function(t){function n(e,n){var r=t.call(this,e,n)||this;r.messageOffsetTimestamp=null;var s=n.ts_message_offset;return r.messageOffsetTimestamp=null!=s?s:null,r}return e(n,t),n}(D),jn=function(t){function n(e,n,r){var s=t.call(this,e,"SYEV",r)||this;return s.allowAutoUnhide=null,s.hidePreviousMessages=null,s.messageOffsetTimestamp=null,r.data&&(s.allowAutoUnhide=r.data.allow_auto_unhide,s.hidePreviousMessages=r.data.hide_previous_messages),s.messageOffsetTimestamp=r.ts_message_offset,s}return e(n,t),n}(F),zn=function(t){function n(e){var n=e.channelUrl,r=e.time;return t.call(this,{code:"TPST",ackRequired:!1,payload:{channel_url:n,time:r}})||this}return e(n,t),n}(R),Qn=function(t){function n(e,n,r){var s=t.call(this,e,"SYEV",r)||this;return s.user=new u(e,r.data),s}return e(n,t),n}(F),Wn=function(t){function n(e){var n=e.channelUrl,r=e.time;return t.call(this,{code:"TPEN",ackRequired:!1,payload:{channel_url:n,time:r}})||this}return e(n,t),n}(R),Kn=function(t){function n(e,n,r){var s=t.call(this,e,"SYEV",r)||this;return s.user=new u(e,r.data),s}return e(n,t),n}(F),Yn=function(t){function n(e){var n=e.channelUrl,r=e.messageId;return t.call(this,{code:"MACK",ackRequired:!1,payload:{channel_url:n,msg_id:r}})||this}return e(n,t),n}(R),Jn=function(t){function n(e,n){var r,s,i,a,o,u,c,l,h,d,p,f,_,m,v,g,y,C,E,b,M,N,S=this;return(S=t.call(this,e,n)||this).includeEmpty=!1,S.includeFrozen=!0,S.includeMetaData=!0,S.channelUrlsFilter=null,S.customTypesFilter=null,S.customTypeStartsWithFilter=null,S.nicknameContainsFilter=null,S.nicknameStartsWithFilter=null,S.nicknameExactMatchFilter=null,S.channelNameContainsFilter="",S.myMemberStateFilter=Ft.ALL,S.unreadChannelFilter=Ht.ALL,S.superChannelFilter=Ot.ALL,S.publicChannelFilter=Rt.ALL,S.hiddenChannelFilter=Gt.UNHIDDEN,S.searchFilter={fields:[],query:null},S.userIdsFilter={userIds:[],includeMode:!0,queryType:qt.AND},S.metadataKey=null,S.metadataValues=null,S.metadataOrderKeyFilter=null,S.metadataValueStartsWith=null,S.order=Ge.LATEST_LAST_MESSAGE,S.includeEmpty=null!==(r=n.includeEmpty)&&void 0!==r&&r,S.includeFrozen=null===(s=n.includeFrozen)||void 0===s||s,S.includeMetaData=null===(i=n.includeMetaData)||void 0===i||i,S.channelUrlsFilter=null!==(a=n.channelUrlsFilter)&&void 0!==a?a:null,S.customTypesFilter=null!==(o=n.customTypesFilter)&&void 0!==o?o:null,S.customTypeStartsWithFilter=null!==(u=n.customTypeStartsWithFilter)&&void 0!==u?u:"",S.nicknameContainsFilter=null!==(c=n.nicknameContainsFilter)&&void 0!==c?c:null,S.nicknameStartsWithFilter=null!==(l=n.nicknameStartsWithFilter)&&void 0!==l?l:null,S.nicknameExactMatchFilter=null!==(h=n.nicknameExactMatchFilter)&&void 0!==h?h:null,S.channelNameContainsFilter=null!==(d=n.channelNameContainsFilter)&&void 0!==d?d:"",S.myMemberStateFilter=null!==(p=n.myMemberStateFilter)&&void 0!==p?p:Ft.ALL,S.unreadChannelFilter=null!==(f=n.unreadChannelFilter)&&void 0!==f?f:Ht.ALL,S.superChannelFilter=null!==(_=n.superChannelFilter)&&void 0!==_?_:Ot.ALL,S.publicChannelFilter=null!==(m=n.publicChannelFilter)&&void 0!==m?m:Rt.ALL,S.hiddenChannelFilter=null!==(v=n.hiddenChannelFilter)&&void 0!==v?v:Gt.UNHIDDEN,S.searchFilter=null!==(g=n.searchFilter)&&void 0!==g?g:{fields:[],query:null},S.userIdsFilter=null!==(y=n.userIdsFilter)&&void 0!==y?y:{userIds:[],includeMode:!0,queryType:qt.AND},S.metadataKey=null!==(C=n.metadataKey)&&void 0!==C?C:null,S.metadataValues=null!==(E=n.metadataValues)&&void 0!==E?E:null,S.metadataOrderKeyFilter=null!==(b=n.metadataOrderKeyFilter)&&void 0!==b?b:null,S.metadataValueStartsWith=null!==(M=n.metadataValueStartsWith)&&void 0!==M?M:null,S.order=null!==(N=n.order)&&void 0!==N?N:Ge.LATEST_LAST_MESSAGE,S}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)&&i(Ft,this.myMemberStateFilter)&&i(Ot,this.superChannelFilter)&&i(Rt,this.publicChannelFilter)&&i(Ht,this.unreadChannelFilter)&&i(Gt,this.hiddenChannelFilter)&&v(Bt,this.searchFilter.fields)&&g("string",this.searchFilter.query,!0)&&v("string",this.userIdsFilter.userIds)&&g("boolean",this.userIdsFilter.includeMode)&&i(qt,this.userIdsFilter.queryType)&&i(Ge,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 O(this)},n.prototype.next=function(){return f(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,er.of(this._iid).getMyGroupChannels(this._token,this,this.limit)]):[3,2]:[3,5];case 1:return e=r.sent(),t=e.channels,n=e.token,this._token=n,this._hasNext=!!n,this._isLoading=!1,[2,t];case 2:return[2,[]];case 3:throw V.queryInProgress;case 4:return[3,6];case 5:throw V.invalidParameters;case 6:return[2]}}))}))},n}(H),Xn=function(){function e(e){var t=e.top,n=void 0===t?Number.MAX_SAFE_INTEGER:t,r=e.bottom,s=void 0===r?0:r;this.top=n,this.bottom=s}return e.prototype.includes=function(){for(var e=this,t=[],n=0;n0||w.unreadMentionCount>0)&&(w._updateUnreadCount(0,0),this._dispatcher.dispatch(new je({channels:[w],source:ze.EVENT_CHANNEL_READ})),W((function(){return f(En,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(w)}catch(e){n={error:e}}finally{try{t&&!t.done&&(r=e.return)&&r.call(e)}finally{if(n)throw n.error}}return[2]}))}))}))):0!==w.unreadMessageCount&&0!==w.unreadMentionCount||(this._dispatcher.dispatch(new je({channels:[w],source:ze.EVENT_CHANNEL_READ})),W((function(){return f(En,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(w)}catch(e){n={error:e}}finally{try{t&&!t.done&&(r=e.return)&&r.call(e)}finally{if(n)throw n.error}}return[2]}))}))}))):(this._dispatcher.dispatch(new je({channels:[w],source:ze.EVENT_CHANNEL_READ})),W((function(){return f(En,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(w)}catch(e){n={error:e}}finally{try{t&&!t.done&&(r=e.return)&&r.call(e)}finally{if(n)throw n.error}}return[2]}))}))}))),bn.label=12;case 12:return[3,77];case 13:return D=e.as(Vn),ue=D.channelUrl,L=D.deliveredStateUpdate,k=void 0===L?{}:L,P=this._groupChannelCache.isCachedInMemory(ue),[4,this.getChannel(ue,!0)];case 14:if(x=bn.sent(),P)for(R in k)x._updateUndeliveredMemberState(R,k[R]);return Object.keys(k).some((function(e){return e!==En._sdkState.userId}))&&(this._dispatcher.dispatch(new je({channels:[x],source:ze.EVENT_CHANNEL_DELIVERED})),W((function(){return f(En,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(x)}catch(e){n={error:e}}finally{try{t&&!t.done&&(r=e.return)&&r.call(e)}finally{if(n)throw n.error}}return[2]}))}))}))),[3,77];case 15:return F=e.as(_t),ue=F.channelUrl,ce=F.channelType,O=F.event,ce!==o.GROUP?[3,18]:[4,this.getChannel(ue,!0)];case 16:return H=bn.sent(),[4,this.getMessageFromCache(O.messageId)];case 17:(q=bn.sent())&&(q.applyReactionEvent(O),this._dispatcher.dispatch(new T({messages:[q],source:K.EVENT_MESSAGE_REACTION_UPDATED}))),W((function(){return f(En,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,O)}catch(e){n={error:e}}finally{try{t&&!t.done&&(r=e.return)&&r.call(e)}finally{if(n)throw n.error}}return[2]}))}))})),bn.label=18;case 18:return[3,77];case 19:return(G=e.as(ft).event).channelType!==o.GROUP?[3,22]:[4,this.getChannel(G.channelUrl,!0)];case 20:return V=bn.sent(),[4,this.getMessageFromCache(G.targetMessageId)];case 21:(q=bn.sent())&&(q.applyThreadInfoUpdateEvent(G),this._dispatcher.dispatch(new T({messages:[q],source:K.EVENT_MESSAGE_THREADINFO_UPDATED}))),W((function(){return f(En,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(V,G)}catch(e){n={error:e}}finally{try{t&&!t.done&&(r=e.return)&&r.call(e)}finally{if(n)throw n.error}}return[2]}))}))})),bn.label=22;case 22:return[3,77];case 23:j=e.as(pt).groupChannelMemberCounts,z=[],bn.label=24;case 24:bn.trys.push([24,29,30,31]),Y=m(j),J=Y.next(),bn.label=25;case 25:return J.done?[3,28]:(Z=J.value,ue=Z.channelUrl,nt=Z.memberCount,rt=Z.joinedMemberCount,$=Z.updatedAt,[4,this.getChannelFromCache(ue)]);case 26:(ee=bn.sent())&&ee._setLatestMemberCount(nt,rt,$)&&z.push(ee),bn.label=27;case 27:return J=Y.next(),[3,25];case 28:return[3,31];case 29:return te=bn.sent(),pn={error:te},[3,31];case 30:try{J&&!J.done&&(fn=Y.return)&&fn.call(Y)}finally{if(pn)throw pn.error}return[7];case 31:return z.length>0&&(this._dispatcher.dispatch(new je({channels:z,source:ze.EVENT_CHANNEL_MEMBER_COUNT_UPDATED})),W((function(){return f(En,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(z)}catch(e){n={error:e}}finally{try{t&&!t.done&&(r=e.return)&&r.call(e)}finally{if(n)throw n.error}}return[2]}))}))}))),[3,77];case 32:return ne=e.as(dt),re=ne.event,se=ne.status,ue=ne.channelUrl,ce=ne.channelType,ue&&ce?[4,this.getChannel(ue,!0)]:[3,77];case 33:return ie=bn.sent(),this._dispatcher.dispatch(new M({event:re,source:K.EVENT_POLL_UPDATED})),W(se===X?function(){return f(En,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(ie,re.pollId)}catch(e){n={error:e}}finally{try{t&&!t.done&&(r=e.return)&&r.call(e)}finally{if(n)throw n.error}}return[2]}))}))}:function(){return f(En,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(ie,re)}catch(e){n={error:e}}finally{try{t&&!t.done&&(r=e.return)&&r.call(e)}finally{if(n)throw n.error}}return[2]}))}))}),[3,77];case 34:return ae=e.as(Te),oe=ae.event,ue=ae.channelUrl,ce=ae.channelType,ue&&ce?[4,this.getChannel(ue,!0)]:[3,77];case 35:return le=bn.sent(),this._dispatcher.dispatch(new b({event:oe,source:K.EVENT_POLL_VOTED})),W((function(){return f(En,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(le,oe)}catch(e){n={error:e}}finally{try{t&&!t.done&&(r=e.return)&&r.call(e)}finally{if(n)throw n.error}}return[2]}))}))})),[3,77];case 36:if(!(he=e.as(ct).event).isGroupChannelEvent)return[3,75];switch(he.category){case lt.CHANNEL_JOIN:return[3,37];case lt.CHANNEL_LEAVE:return[3,39];case lt.CHANNEL_OPERATOR_UPDATE:return[3,43];case lt.CHANNEL_INVITE:return[3,45];case lt.CHANNEL_DECLINE_INVITE:return[3,47];case lt.TYPING_START:case lt.TYPING_END:return[3,49];case lt.USER_CHANNEL_MUTE:case lt.USER_CHANNEL_UNMUTE:return[3,51];case lt.USER_CHANNEL_BAN:return[3,53];case lt.USER_CHANNEL_UNBAN:return[3,57];case lt.CHANNEL_FREEZE:case lt.CHANNEL_UNFREEZE:return[3,59];case lt.CHANNEL_HIDE:return[3,61];case lt.CHANNEL_UNHIDE:return[3,63];case lt.CHANNEL_DELETED:return[3,65];case lt.CHANNEL_PROP_CHANGED:return[3,67];case lt.CHANNEL_META_DATA_CHANGED:return[3,69];case lt.CHANNEL_META_COUNTERS_CHANGED:return[3,71];case lt.PINNED_MESSAGE_CHANGED:return[3,73]}return[3,75];case 37:return[4,this.getChannel(he.channelUrl,!0)];case 38:return de=bn.sent(),pe=e.as(An),fe=pe.memberCount,_e=pe.joinedMemberCount,me=pe.members,ve=!1,me.forEach((function(e){de.isExclusive||de.isSuper||de.isBroadcast?ve=ve||de._setLatestMemberCount(fe,_e,he.ts):(e.state=xt.JOINED,de.addMember(e,he.ts),En._updateJoinedMemberCount(de)),e.userId===En._sdkState.userId&&(de.myMemberState=xt.JOINED)})),this._dispatcher.dispatch(new je({channels:[de],source:ze.EVENT_CHANNEL_JOINED})),W((function(){return f(En,void 0,void 0,(function(){return _(this,(function(e){return this._groupChannelHandlers.forEach((function(e){var t,n;try{for(var r=m(me),s=r.next();!s.done;s=r.next()){var i=s.value;e.onUserJoined(de,i)}}catch(e){t={error:e}}finally{try{s&&!s.done&&(n=r.return)&&n.call(r)}finally{if(t)throw t.error}}de.isBroadcast&&ve&&e.onChannelMemberCountChanged([de])})),[2]}))}))})),[3,75];case 39:return(Ut=this._leftChannels.get(he.channelUrl))?(ye=Ut.channel,[3,42]):[3,40];case 40:return[4,this.getChannel(he.channelUrl,!0)];case 41:ye=bn.sent(),bn.label=42;case 42:return ge=ye,Le=e.as(Dn),nt=Le.memberCount,rt=Le.joinedMemberCount,ke=Le.member,Pe=!1,xe=B.of(this._iid).appInfo,ge.isExclusive||ge.isSuper||ge.isBroadcast?Pe=ge._setLatestMemberCount(nt,rt,he.ts):(xe.enabledChannelMemberShipHistory?(ge.members.find((function(e){return e.userId===ke.userId})).state=xt.LEFT,ge.memberCount=nt):ge.removeMember(ke),this._updateJoinedMemberCount(ge)),ke.userId===this._sdkState.userId?(ge.myMemberState=xt.NONE,ge.invitedAt=0,ge.joinedAt=0,ge._updateUnreadCount(0,0),ge.isPublic?this._dispatcher.dispatch(new je({channels:[ge],source:ze.EVENT_CHANNEL_LEFT})):(this._markAsLeave(ge),this._dispatcher.dispatch(new Be({channelUrls:[ge.url],source:ze.EVENT_CHANNEL_LEFT})))):this._dispatcher.dispatch(new je({channels:[ge],source:ze.EVENT_CHANNEL_LEFT})),W((function(){return f(En,void 0,void 0,(function(){return _(this,(function(e){return this._groupChannelHandlers.forEach((function(e){e.onUserLeft(ge,ke),ge.isBroadcast&&Pe&&e.onChannelMemberCountChanged([ge])})),[2]}))}))})),[3,75];case 43:return[4,this.getChannel(he.channelUrl,!0)];case 44:Re=bn.sent(),Fe=e.as(ht).operators,Oe=Fe.map((function(e){return e.userId}));try{for(He=m(Re.members),Ge=He.next();!Ge.done;Ge=He.next())(Nt=Ge.value).role=Oe.includes(Nt.userId)?a.OPERATOR:a.NONE}catch(e){_n={error:e}}finally{try{Ge&&!Ge.done&&(mn=He.return)&&mn.call(He)}finally{if(_n)throw _n.error}}return Re.myRole=Oe.includes(this._sdkState.userId)?a.OPERATOR:a.NONE,this._dispatcher.dispatch(new je({channels:[Re],source:ze.EVENT_CHANNEL_OPERATOR_UPDATED})),W((function(){return f(En,void 0,void 0,(function(){return _(this,(function(e){return this._groupChannelHandlers.forEach((function(e){e.onOperatorUpdated(Re,Fe)})),[2]}))}))})),[3,75];case 45:return[4,this.getChannel(he.channelUrl,!0)];case 46:Ve=bn.sent(),qe=e.as(Pn),nt=qe.memberCount,rt=qe.joinedMemberCount,Qe=qe.inviter,(We=qe.invitees).forEach((function(e){return e.state=xt.INVITED}));try{for(Ke=m(We),Ye=Ke.next();!Ye.done;Ye=Ke.next())Je=Ye.value,Ve.isExclusive||Ve.isSuper||Ve.isBroadcast?Ve._setLatestMemberCount(nt,rt,he.ts):Ve.addMember(Je,he.ts),this._sdkState.userId===Je.userId&&(Ve.hiddenState=ts.UNHIDDEN,Ve.myMemberState!==xt.JOINED&&(Ve.myMemberState=xt.INVITED),Ve.invitedAt=he.ts)}catch(e){vn={error:e}}finally{try{Ye&&!Ye.done&&(gn=Ke.return)&&gn.call(Ke)}finally{if(vn)throw vn.error}}return this._dispatcher.dispatch(new je({channels:[Ve],source:ze.EVENT_CHANNEL_INVITED})),W((function(){return f(En,void 0,void 0,(function(){return _(this,(function(e){return this._groupChannelHandlers.forEach((function(e){e.onUserReceivedInvitation(Ve,Qe,We)})),[2]}))}))})),[3,75];case 47:return[4,this.getChannel(he.channelUrl,!0)];case 48:return Xe=bn.sent(),tt=e.as(Rn),nt=tt.memberCount,rt=tt.joinedMemberCount,st=tt.inviter,it=tt.invitee,Xe.isExclusive||Xe.isSuper||Xe.isBroadcast?Xe._setLatestMemberCount(nt,rt,he.ts):Xe.removeMember(it),this._sdkState.userId===it.userId?(Xe.invitedAt=0,Xe.myMemberState=xt.NONE,Xe.isPublic?this._dispatcher.dispatch(new je({channels:[Xe],source:ze.EVENT_CHANNEL_DECLINED_INVITE})):this._dispatcher.dispatch(new Be({channelUrls:[Xe.url],source:ze.EVENT_CHANNEL_DECLINED_INVITE}))):this._dispatcher.dispatch(new je({channels:[Xe],source:ze.EVENT_CHANNEL_DECLINED_INVITE})),W((function(){return f(En,void 0,void 0,(function(){return _(this,(function(e){return this._groupChannelHandlers.forEach((function(e){e.onUserDeclinedInvitation(Xe,st,it)})),[2]}))}))})),[3,75];case 49:return[4,this.getChannel(he.channelUrl,!0)];case 50:return at=bn.sent(),ot=he.category===lt.TYPING_START,ut=e.as(ot?Qn:Kn).user,at._updateTypingStatus(ut,ot?he.ts:0),this._dispatcher.dispatch(new je({channels:[at],source:ze.EVENT_CHANNEL_TYPING_STATUS_UPDATE})),W((function(){return f(En,void 0,void 0,(function(){return _(this,(function(e){return this._groupChannelHandlers.forEach((function(e){e.onTypingStatusUpdated(at)})),[2]}))}))})),[3,75];case 51:return[4,this.getChannel(he.channelUrl,!0)];case 52:gt=bn.sent(),yt=he.category===lt.USER_CHANNEL_MUTE,(Et=e.as(yt?Se:Ue).user).userId===this._sdkState.userId&&(gt.myMutedState=yt?es.MUTED:es.UNMUTED,gt._myMutedRemainingTime=Et.restrictionInfo.remainingDuration);try{for(bt=m(gt.members),Mt=bt.next();!Mt.done;Mt=bt.next())if((Nt=Mt.value).userId===Et.userId){Nt.isMuted=yt;break}}catch(e){yn={error:e}}finally{try{Mt&&!Mt.done&&(Cn=bt.return)&&Cn.call(bt)}finally{if(yn)throw yn.error}}return this._dispatcher.dispatch(new je({channels:[gt],source:yt?ze.EVENT_CHANNEL_MUTED:ze.EVENT_CHANNEL_UNMUTED,data:Et.userId})),W((function(){return f(En,void 0,void 0,(function(){return _(this,(function(e){return this._groupChannelHandlers.forEach((function(e){yt?e.onUserMuted(gt,Et):e.onUserUnmuted(gt,Et)})),[2]}))}))})),[3,75];case 53:return(Ut=this._leftChannels.get(he.channelUrl))?(It=Ut.channel,[3,56]):[3,54];case 54:return[4,this.getChannel(he.channelUrl,!0)];case 55:It=bn.sent(),bn.label=56;case 56:return Tt=It,this._markAsLeave(Tt),At=e.as(Ne).user,W((function(){return f(En,void 0,void 0,(function(){return _(this,(function(e){return this._groupChannelHandlers.forEach((function(e){e.onUserBanned(Tt,At)})),[2]}))}))})),[3,75];case 57:return[4,this.getChannel(he.channelUrl,!0)];case 58:return wt=bn.sent(),Dt=e.as(Me).user,W((function(){return f(En,void 0,void 0,(function(){return _(this,(function(e){return this._groupChannelHandlers.forEach((function(e){e.onUserUnbanned(wt,Dt)})),[2]}))}))})),[3,75];case 59:return[4,this.getChannel(he.channelUrl,!0)];case 60:return Lt=bn.sent(),kt=e.as(be).freeze,Lt.isFrozen=kt,this._dispatcher.dispatch(new je({channels:[Lt],source:kt?ze.EVENT_CHANNEL_FROZEN:ze.EVENT_CHANNEL_UNFROZEN})),W((function(){return f(En,void 0,void 0,(function(){return _(this,(function(e){return this._groupChannelHandlers.forEach((function(e){kt?e.onChannelFrozen(Lt):e.onChannelUnfrozen(Lt)})),[2]}))}))})),[3,75];case 61:return[4,this.getChannel(he.channelUrl,!0)];case 62:return Pt=bn.sent(),Rt=e.as(jn),Ft=Rt.allowAutoUnhide,Ot=Rt.hidePreviousMessages,Ht=Rt.messageOffsetTimestamp,null!==Ft&&(Pt.hiddenState=Ft?ts.HIDDEN_ALLOW_AUTO_UNHIDE:ts.HIDDEN_PREVENT_AUTO_UNHIDE),null!==Ot&&Ot&&Pt._updateUnreadCount(0,0),null!==Ht&&(Pt.messageOffsetTimestamp=Ht),this._dispatcher.dispatch(new je({channels:[Pt],source:ze.EVENT_CHANNEL_HIDDEN})),W((function(){return f(En,void 0,void 0,(function(){return _(this,(function(e){return this._groupChannelHandlers.forEach((function(e){e.onChannelHidden(Pt)})),[2]}))}))})),[3,75];case 63:return[4,this.getChannel(he.channelUrl,!0)];case 64:return(Gt=bn.sent()).hiddenState=ts.UNHIDDEN,this._dispatcher.dispatch(new je({channels:[Gt],source:ze.EVENT_CHANNEL_UNHIDDEN})),W((function(){return f(En,void 0,void 0,(function(){return _(this,(function(e){return this._groupChannelHandlers.forEach((function(e){e.onChannelChanged(Gt)})),[2]}))}))})),[3,75];case 65:return[4,this.getChannel(he.channelUrl,!0)];case 66:return Vt=bn.sent(),this._dispatcher.dispatch(new Be({channelUrls:[he.channelUrl],source:ze.EVENT_CHANNEL_DELETED})),W((function(){return f(En,void 0,void 0,(function(){return _(this,(function(e){return this._groupChannelHandlers.forEach((function(e){e.onChannelDeleted(Vt.url,Vt.channelType)})),[2]}))}))})),[3,75];case 67:return[4,this.getChannelWithoutCache(he.channelUrl,!0)];case 68:return qt=bn.sent(),this._dispatcher.dispatch(new je({channels:[qt],source:ze.EVENT_CHANNEL_UPDATED})),W((function(){return f(En,void 0,void 0,(function(){return _(this,(function(e){return this._groupChannelHandlers.forEach((function(e){e.onChannelChanged(qt)})),[2]}))}))})),[3,75];case 69:return[4,this.getChannel(he.channelUrl,!0)];case 70:return Bt=bn.sent(),jt=e.as(Ee),zt=jt.created,Qt=jt.updated,Wt=jt.deleted,zt&&Bt._upsertCachedMetaData(zt,he.ts),Qt&&Bt._upsertCachedMetaData(Qt,he.ts),Wt&&Bt._removeFromCachedMetaData(Wt,he.ts),W((function(){return f(En,void 0,void 0,(function(){return _(this,(function(e){return this._groupChannelHandlers.forEach((function(e){zt&&e.onMetaDataCreated(Bt,zt),Qt&&e.onMetaDataUpdated(Bt,Qt),Wt&&e.onMetaDataDeleted(Bt,Wt)})),[2]}))}))})),[3,75];case 71:return[4,this.getChannel(he.channelUrl,!0)];case 72:return Kt=bn.sent(),Yt=e.as(Ce),Jt=Yt.created,Xt=Yt.updated,Zt=Yt.deleted,W((function(){return f(En,void 0,void 0,(function(){return _(this,(function(e){return this._groupChannelHandlers.forEach((function(e){Jt&&e.onMetaCounterCreated(Kt,Jt),Xt&&e.onMetaCounterUpdated(Kt,Xt),Zt&&e.onMetaCounterDeleted(Kt,Zt)})),[2]}))}))})),[3,75];case 73:return[4,this.getChannel(he.channelUrl,!0)];case 74:return $t=bn.sent(),en=e.as(Zn),tn=en.pinnedMessageIds,nn=en.latestPinnedMessage,(rn=en.ts)>$t._pinnedMessagesUpdatedAt&&($t.pinnedMessageIds=tn,$t.lastPinnedMessage=nn,$t._pinnedMessagesUpdatedAt=rn,this._dispatcher.dispatch(new je({channels:[$t],source:ze.EVENT_PINNED_MESSAGE_UPDATED})),W((function(){return f(En,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($t)}catch(e){n={error:e}}finally{try{t&&!t.done&&(r=e.return)&&r.call(e)}finally{if(n)throw n.error}}return[2]}))}))})),W((function(){return f(En,void 0,void 0,(function(){return _(this,(function(e){return this._groupChannelHandlers.forEach((function(e){e.onPinnedMessageUpdated($t)})),[2]}))}))}))),[3,75];case 75:return[3,77];case 76:switch((sn=e.as(Ze).event).category){case $e.USER_BLOCK:an=et.getDataAsUserBlockEvent(this._iid,sn),un=an.blocker,cn=an.blockee,this._groupChannelCache.block(un.userId,cn.userId);break;case $e.USER_UNBLOCK:on=et.getDataAsUserBlockEvent(this._iid,sn),un=on.blocker,cn=on.blockee,this._groupChannelCache.unblock(un.userId,cn.userId)}return[3,77];case 77:return[3,79];case 78:if(ln=bn.sent(),Q(ln))throw ln;return[3,79];case 79:return[2]}}))}))},e.prototype._markAsLeave=function(e){var t,n=this,r=null!==(t=this._leftChannels.get(e.url))&&void 0!==t?t:{channel:e,ref:0};r.ref++,this._leftChannels.set(e.url,r),setTimeout((function(){r.ref--,0===r.ref&&n._leftChannels.delete(e.url)}),1e4)},e.prototype.addHandler=function(e,t){this._groupChannelHandlers.set(e,t)},e.prototype.removeHandler=function(e){this._groupChannelHandlers.delete(e)},e.prototype.clearHandler=function(){this._groupChannelHandlers.clear()},e.prototype.subscribeGroupChannelEvent=function(e,t){this._groupChannelBroadcast.subscribe(e,t)},e.prototype.unsubscribeGroupChannelEvent=function(e){this._groupChannelBroadcast.unsubscribe(e)},e.prototype.subscribeMessageEvent=function(e,t){this._messageBroadcast.subscribe(e,t)},e.prototype.unsubscribeMessageEvent=function(e){this._messageBroadcast.unsubscribe(e)},e.prototype._updateJoinedMemberCount=function(e){e.joinedMemberCount=e.members.filter((function(e){return e.state===xt.JOINED})).length},e.prototype.getChannel=function(e,t){return void 0===t&&(t=!1),f(this,void 0,void 0,(function(){var n;return _(this,(function(r){switch(r.label){case 0:Y(g("string",e)).throw(V.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),f(this,void 0,void 0,(function(){var n,r,s,i,a;return _(this,(function(o){switch(o.label){case 0:return Y(g("string",e)).throw(V.invalidParameters),n=new cn({channelUrl:e,isInternalCall:t}),[4,this._requestQueue.send(n)];case 1:switch(r=o.sent(),s=r.as(ln).channel,i=s.unreadMessageCount,a=s.unreadMentionCount,s.myCountPreference){case $r.UNREAD_MESSAGE_COUNT_ONLY:a=0;break;case $r.UNREAD_MENTION_COUNT_ONLY:i=0;break;case $r.OFF:i=0,a=0}return s._updateUnreadCount(i,a),[4,this.upsertChannelsToCache([s])];case 2:return o.sent(),[2,s]}}))}))},e.prototype.refreshChannel=function(e,t,n){return void 0===t&&(t=!0),void 0===n&&(n=ze.REFRESH_CHANNEL),f(this,void 0,void 0,(function(){var r,s,i,a;return _(this,(function(o){switch(o.label){case 0:return o.trys.push([0,2,,3]),r=new cn({channelUrl:e,isInternalCall:t}),[4,this._requestQueue.send(r)];case 1:return s=o.sent(),(i=s.as(ln).channel).myMemberState===xt.NONE?this._dispatcher.dispatch(new Be({channelUrls:[i.url],source:n})):this._dispatcher.dispatch(new je({channels:[i],source:n})),[3,3];case 2:return(a=o.sent()).code!==J.NON_AUTHORIZED&&a.code!==J.NOT_FOUND_IN_DATABASE||this._dispatcher.dispatch(new Be({channelUrls:[e],source:n})),[3,3];case 3:return[2]}}))}))},e.prototype.getMyGroupChannels=function(e,t,n,r){return void 0===r&&(r=ze.REQUEST_CHANNEL),f(this,void 0,void 0,(function(){var i,a,o,u,c;return _(this,(function(l){switch(l.label){case 0:return i=new hn(s(s({},t),{userId:this._sdkState.userId,token:e,limit:n})),[4,this._requestQueue.send(i)];case 1:return a=l.sent(),o=a.as(dn),u=o.channels,c=o.token,this._dispatcher.dispatch(new je({channels:u,source:r})),[2,{channels:u,token:c}]}}))}))},e.prototype.getMessageFromCache=function(e){return f(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=Le),f(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=Le),f(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.getUnsentMessagesFromCache=function(e,t){return f(this,void 0,void 0,(function(){return _(this,(function(n){switch(n.label){case 0:return[4,this._unsentMessageCache.fetch({channelUrl:e,filter:t})];case 1:return[2,n.sent()]}}))}))},e.prototype.removeFailedMessageFromCache=function(e){return f(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 f(this,void 0,void 0,(function(){return _(this,(function(s){switch(s.label){case 0:return[4,this._messageCache.countBetween(e,t,new Xn({top:n,bottom:r}))];case 1:return[2,s.sent()]}}))}))},e.prototype.getMyGroupChannelChangeLogs=function(e,t,n){return void 0===n&&(n=ze.REQUEST_CHANNEL_CHANGELOGS),f(this,void 0,void 0,(function(){var i,a,o,u,c,l,h;return _(this,(function(d){switch(d.label){case 0:return i=s(s({},Xt),t),Y((g("string",e)||g("number",e))&&Zt(i)).throw(V.invalidParameters),a=new on(r({userId:this._sdkState.userId,ts:"number"==typeof e?e:null,token:"string"==typeof e?e:null,filter:i})),[4,this._requestQueue.send(a)];case 1:return o=d.sent(),u=o.as(un),c=u.updatedChannels,l=u.deletedChannelUrls,h=u.hasMore,c.length>0&&this._dispatcher.dispatch(new je({channels:c,source:n})),l.length>0&&this._dispatcher.dispatch(new Be({channelUrls:l,source:n})),[2,{updatedChannels:c,deletedChannelUrls:l,hasMore:h,token:u.token}]}}))}))},e.prototype.getGroupChannelCount=function(e){return f(this,void 0,void 0,(function(){var t,n,r;return _(this,(function(i){switch(i.label){case 0:return t=s(s({},$t),e),Y(en(t)).throw(V.invalidParameters),n=new pn({userId:this._sdkState.userId,filter:t}),[4,this._requestQueue.send(n)];case 1:return r=i.sent(),[2,r.as(fn).groupChannelCount]}}))}))},e.prototype.getUnreadItemCount=function(e){return f(this,void 0,void 0,(function(){var t,n,i,a,o,u,c,l,h,d,p,f,m,g,y,C;return _(this,(function(_){switch(_.label){case 0:return t=s(s({},tn),e),Y(function(e){return v(Qt,e.keys)}(t)).throw(V.invalidParameters),n=B.of(this._iid),i=n.sdkState,a=n.requestQueue,o=new _n({userId:i.userId,filter:t}),[4,a.send(o)];case 1:return u=_.sent(),c=u.as(mn),l=c.groupChannelUnreadMentionCount,h=c.groupChannelUnreadMessageCount,d=c.groupChannelInvitationCount,p=c.superGroupChannelUnreadMentionCount,f=c.superGroupChannelUnreadMessageCount,m=c.superGroupChannelInvitationCount,g=c.nonSuperGroupChannelUnreadMentionCount,y=c.nonSuperGroupChannelUnreadMessageCount,C=c.nonSuperGroupChannelInvitationCount,[2,r({groupChannelUnreadMentionCount:l,groupChannelUnreadMessageCount:h,groupChannelInvitationCount:d,superGroupChannelUnreadMentionCount:p,superGroupChannelUnreadMessageCount:f,superGroupChannelInvitationCount:m,nonSuperGroupChannelUnreadMentionCount:g,nonSuperGroupChannelUnreadMessageCount:y,nonSuperGroupChannelInvitationCount:C})]}}))}))},e.prototype.getTotalUnreadChannelCount=function(){return f(this,void 0,void 0,(function(){var e,t,n,r,s;return _(this,(function(i){switch(i.label){case 0:return e=B.of(this._iid),t=e.sdkState,n=e.requestQueue,r=new vn({userId:t.userId}),[4,n.send(r)];case 1:return s=i.sent(),[2,s.as(gn).unreadCount]}}))}))},e.prototype.getTotalUnreadMessageCount=function(e){return f(this,void 0,void 0,(function(){var t,n,r,a,o,u;return _(this,(function(c){switch(c.label){case 0:return t=s(s({},nn),e),Y(function(e){return v("string",e.channelCustomTypesFilter,!0)&&i(Ot,e.superChannelFilter)}(t)).throw(V.invalidParameters),n=B.of(this._iid),r=n.sdkState,a=n.requestQueue,o=new yn({userId:r.userId,filter:t}),[4,a.send(o)];case 1:return u=c.sent(),[2,u.as(Cn).unreadCount]}}))}))},e.prototype.getTotalScheduledMessageCount=function(e){return void 0===e&&(e={}),f(this,void 0,void 0,(function(){var t,n,r,a;return _(this,(function(o){switch(o.label){case 0:return t=s(s({},rn),e),Y(function(e){return g("string",e.channelUrl,!0)&&v(yt,e.scheduledStatus,!0)&&i(C,e.messageTypeFilter)}(t)).throw(V.invalidParameters),n=B.of(this._iid).requestQueue,r=new En(t),[4,n.send(r)];case 1:return a=o.sent(),[2,a.as(bn).count]}}))}))},e.prototype.getSubscribedTotalUnreadMessageCount=function(){var e=B.of(this._iid).subscribedUnreadMessageCount;return e.all>=0?e.all:0},e.prototype.getSubscribedCustomTypeTotalUnreadMessageCount=function(){var e=0,t=B.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=B.of(this._iid).subscribedUnreadMessageCount.customTypes[e])&&void 0!==t?t:0},e.prototype.createChannel=function(e){return f(this,void 0,void 0,(function(){var t,n,r,i;return _(this,(function(a){switch(a.label){case 0:return t=s(s({},Yt),e),Y(Jt(t)).throw(V.invalidParameters),t.isPublic||(t.accessCode=null),n=new Nn(s({userId:this._sdkState.userId},t)),[4,this._requestQueue.send(n)];case 1:return r=a.sent(),i=r.as(Sn).channel,[4,this.upsertChannelsToCache([i])];case 2:return a.sent(),[2,i]}}))}))},e.prototype.markAsReadAll=function(){return f(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(),Y(e-this._markAsReadAllLastSentAt>=1e3).throw(V.markAsReadAllRateLimitExceeded),this._markAsReadAllLastSentAt=e,t=new Un({userId:this._sdkState.userId}),[4,this._requestQueue.send(t)];case 1:u.sent(),n=this._groupChannelCache.channels;try{for(r=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.upsertChannelsToCache(n)]:[3,3];case 2:u.sent(),u.label=3;case 3:return[2]}}))}))},e.prototype.markAsReadWithChannelUrls=function(e){return f(this,void 0,void 0,(function(){var t,n,r,s,i,a,o,u,c;return _(this,(function(l){switch(l.label){case 0:return t=Date.now(),Y(v("string",e)&&t-this._markAsReadAllLastSentAt>=1e3).throw(V.markAsReadAllRateLimitExceeded),this._markAsReadAllLastSentAt=t,n=new Un({userId:this._sdkState.userId,channelUrls:e}),[4,this._requestQueue.send(n)];case 1:l.sent(),r=this._groupChannelCache.channels,s=[];try{for(i=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&&(c=i.return)&&c.call(i)}finally{if(u)throw u.error}}return s.length>0?[4,this.upsertChannelsToCache(s)]:[3,3];case 2:l.sent(),l.label=3;case 3:return[2]}}))}))},e.prototype.markAsDelivered=function(e){return f(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}();!function(e){e[e.IDLE=0]="IDLE",e[e.RUNNING=1]="RUNNING",e[e.END=2]="END"}(Gn||(Gn={}));var tr,nr=function(t){function n(e,n,r,s){var i=t.call(this)||this;return i._worker=null,i._state=Gn.IDLE,i._semaphore=null,i._retryCount=0,i._retryLimit=3,i.priority=0,i._worker=n,i}return e(n,t),Object.defineProperty(n.prototype,"isIdle",{get:function(){return this._state===Gn.IDLE},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"isRunning",{get:function(){return this._state===Gn.RUNNING},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"isDone",{get:function(){return this._state===Gn.END},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"retryCount",{get:function(){return this._retryCount},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"retryLimit",{get:function(){return this._retryLimit},enumerable:!1,configurable:!0}),n.prototype._run=function(e){return f(this,void 0,void 0,(function(){var t,n;return _(this,(function(r){switch(r.label){case 0:if(!this.isRunning)return[3,4];r.label=1;case 1:return r.trys.push([1,3,,4]),[4,this._worker(e)];case 2:return t=r.sent(),this._retryCount=0,this.dispatch("progress",t),t.hasNext?this._run(t.nextToken):this.end(),[3,4];case 3:return n=r.sent(),this.dispatch("error",n),this._retryCount0&&(r=n.map((function(e){return e.createdAt})),(i=this._metadata.range).intersect.apply(i,h([],d(r),!1))?this.extendRange(n):this._metadata={range:new Xn({top:Math.min.apply(Math,h([],d(r),!1)),bottom:Math.max.apply(Math,h([],d(r),!1))}),previousComplete:!1}),t.hasNext=n.length>=this._limit&&this._prevSyncLoopCount<1,t.nextToken=this._metadata.range.top,this._metadata.previousComplete=n.length0&&(r=n.map((function(e){return e.createdAt})),(i=this._metadata.range).intersect.apply(i,h([],d(r),!1))?this.extendRange(n):this._metadata={range:new Xn({top:Math.min.apply(Math,h([],d(r),!1)),bottom:Math.max.apply(Math,h([],d(r),!1))}),previousComplete:!1}),t.hasNext=n.length>=this._limit&&this._nextSyncLoopCount<1,t.nextToken=this._metadata.range.bottom,p.debug("message background next sync progress",t),[4,this.saveMetadata()];case 4:return u.sent(),[3,6];case 5:throw s=u.sent(),p.debug("message background next sync error",s),s;case 6:return[2,t]}}))}))})),this._connectionEventContext=l.on((function(e){if(e instanceof $)if(e.stateType===ee.CONNECTED)i.resume();else i.pause()}))}return e.of=function(t,n){return ir[t]||(ir[t]={}),ir[t][n.url]||(ir[t][n.url]=new e({_iid:t,channel:n})),ir[t][n.url].ref++,ir[t][n.url]},e.clear=function(e,t){ir[e]&&ir[e][t]&&(ir[e][t].close(),delete ir[e])},Object.defineProperty(e.prototype,"range",{get:function(){var e;return null===(e=this._metadata)||void 0===e?void 0:e.range},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"previousComplete",{get:function(){var e;return!!(null===(e=this._metadata)||void 0===e?void 0:e.previousComplete)},enumerable:!1,configurable:!0}),e.prototype.isWrappingMessages=function(e){var t;return null===(t=this.range)||void 0===t?void 0:t.includes.apply(t,h([],d(e.map((function(e){return e.createdAt}))),!1))},e.prototype.extendRange=function(e){var t;this._metadata&&(t=this._metadata.range).extends.apply(t,h([],d(e.map((function(e){return e.createdAt}))),!1))},e.prototype.loadMetadata=function(e){return f(this,void 0,void 0,(function(){var t;return _(this,(function(n){switch(n.label){case 0:return this._metadata?[3,2]:[4,B.of(this._iid).cacheContext.preference.get(this._metadataKey)];case 1:(t=n.sent())?t.range.bottom0||r.length>0)&&(this._metadata.token=i),o.debug("message changelog sync progress",e),[4,this.saveMetadata()];case 4:return c.sent(),[3,8];case 5:return a=c.sent(),o.debug("message changelog sync error",a),a instanceof V&&a.isInvalidTokenError?[4,this.clearMetadata()]:[3,7];case 6:c.sent(),c.label=7;case 7:throw a;case 8:return[2,e]}}))}))})),this._connectionEventContext=c.on((function(e){if(e instanceof $)if(e.stateType===ee.CONNECTED)r.resume();else r.pause()}))}return e.of=function(t,n){return or[t]||(or[t]={}),or[t][n.url]||(or[t][n.url]=new e({_iid:t,channel:n})),or[t][n.url].ref++,or[t][n.url]},e.clear=function(e,t){or[e]&&or[e][t]&&(or[e][t].close(),delete or[e])},e.prototype.loadMetadata=function(){return f(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=B.of(this._iid),t=e.cacheContext,n=e.firstConnectedAt,[4,t.preference.get(this._metadataKey)]);case 1:r=s.sent(),this._metadata={token:r?r.token:n},s.label=2;case 2:return[2,this._metadata]}}))}))},e.prototype.saveMetadata=function(){return f(this,void 0,void 0,(function(){return _(this,(function(e){switch(e.label){case 0:return this._metadata?[4,B.of(this._iid).cacheContext.preference.set(this._metadataKey,this._metadata)]:[3,2];case 1:return e.sent(),[2,!0];case 2:return[2,!1]}}))}))},e.prototype.clearMetadata=function(){return f(this,void 0,void 0,(function(){return _(this,(function(e){switch(e.label){case 0:return[4,B.of(this._iid).cacheContext.preference.remove(this._metadataKey)];case 1:return e.sent(),this._metadata=null,[2]}}))}))},e.prototype.resume=function(){var e=B.of(this._iid),t=e.logger;e.connectionManager.isConnected&&(t.debug("message changelog sync resume()"),this._sync.start(0))},e.prototype.pause=function(){var e=B.of(this._iid),t=e.logger;e.connectionManager.isConnected&&(t.debug("message changelog sync pause()"),this._sync.stop())},e.prototype.close=function(){this.ref--,this.ref<=0&&(this.ref=0,this.pause(),this._connectionEventContext.close(),delete or[this._iid][this._channel.url])},e}(),cr={},lr=function(){function e(e){var t=e._iid,n=e.channel,r=e.hasPollMessage,s=this;this._sync=null,this.ref=0,this._metadata=null,this._iid=t,this._channel=n;var i,a,o=B.of(this._iid),u=o.logger,c=o.sdkState,l=o.dispatcher;this._metadataKey=(i=c.userId,a=n.url,"sendbird:".concat(i,"@groupchannel/").concat(a,"/poll/changelogs.meta"));var h=function(e,t){return"sendbird:".concat(e,"@groupchannel/").concat(t,"/poll/changelogs")}(c.userId,this._channel.url);this._sync=new nr(h,(function(){return f(s,void 0,void 0,(function(){var e,t,n,s,i,a,o,c;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===(c=this._metadata)||void 0===c?void 0:c.token),(t=!this._metadata||!this._metadata.token)?[4,r()]:[3,3];case 2:t=!l.sent(),l.label=3;case 3:if(t)return[2,{hasNext:!1,nextToken:0}];this._metadata||(n=B.of(this._iid).firstConnectedAt,this._metadata={token:n}),l.label=4;case 4:return l.trys.push([4,7,,10]),[4,Pt.of(this._iid).getPollChangeLogs(this._channel.url,this._channel.channelType,this._metadata.token)];case 5:return s=l.sent(),i=s.hasMore,a=s.token,e.hasNext=i,e.nextToken=a,this._metadata.token=a,u.debug("poll changelog sync progress",e),[4,this.saveMetadata()];case 6:return l.sent(),[3,10];case 7:return o=l.sent(),u.debug("poll changelog sync error",o),o instanceof V&&o.isInvalidTokenError?[4,this.clearMetadata()]:[3,9];case 8:l.sent(),l.label=9;case 9:throw o;case 10:return[2,e]}}))}))})),this._connectionEventContext=l.on((function(e){if(e instanceof $)if(e.stateType===ee.CONNECTED)s.resume();else s.pause()}))}return e.of=function(t,n,r){return cr[t]||(cr[t]={}),cr[t][n.url]||(cr[t][n.url]=new e({_iid:t,channel:n,hasPollMessage:r})),cr[t][n.url].ref++,cr[t][n.url]},e.prototype.loadMetadata=function(){return f(this,void 0,void 0,(function(){var e;return _(this,(function(t){switch(t.label){case 0:return this._metadata?[3,2]:[4,B.of(this._iid).cacheContext.preference.get(this._metadataKey)];case 1:e=t.sent(),this._metadata=e?{token:e.token}:null,t.label=2;case 2:return[2]}}))}))},e.prototype.saveMetadata=function(){return f(this,void 0,void 0,(function(){return _(this,(function(e){switch(e.label){case 0:return this._metadata?[4,B.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 f(this,void 0,void 0,(function(){return _(this,(function(e){switch(e.label){case 0:return[4,B.of(this._iid).cacheContext.preference.remove(this._metadataKey)];case 1:return e.sent(),this._metadata=null,[2]}}))}))},e.prototype.resume=function(){B.of(this._iid).logger.debug("poll changelog sync resume()"),this._sync.start(0)},e.prototype.pause=function(){B.of(this._iid).logger.debug("poll changelog sync pause()"),this._sync.stop()},e.prototype.close=function(){this.ref--,this.ref<=0&&(this.ref=0,this.pause(),this._connectionEventContext.close(),delete cr[this._iid][this._channel.url])},e}(),hr=function(t){function n(e){var n,s,i,a,o,u,c=this;return(c=t.call(this)||this).method=I.GET,c.path="".concat(ne(e.channelType),"/").concat(e.channelUrl,"/messages_gap"),c.params=r({prev_start_ts:e.prevStart,prev_end_ts:e.prevEnd,prev_cache_count:e.prevCount,next_start_ts:e.nextStart,next_end_ts:e.nextEnd,next_cache_count:e.nextCount,huge_gap_threshold:null!==(n=e.threshold)&&void 0!==n?n:null,reverse:!0,custom_types:null!==(s=e.customTypes)&&void 0!==s?s:["*"],message_type:null!==(i=e.messageType)&&void 0!==i?i:null,include_reactions:null===(a=e.includeReactions)||void 0===a||a,with_sorted_meta_array:null===(o=e.includeMetaArray)||void 0===o||o,show_subchannel_messages_only:null!==(u=e.showSubchannelMessagesOnly)&&void 0!==u&&u,include_poll_details:!0,checking_continuous_messages:e.checkingContinuousMessages}),c}return e(n,t),n}(w),dr=function(t){function n(e,n){var r,s,i,a,o,u,c=this;return(c=t.call(this,e,n)||this).isHugeGap=n.is_huge_gap,c.prevMessages=(null!==(r=n.prev_messages)&&void 0!==r?r:[]).map((function(t){return bt(e,t)})),c.prevHasMore=null!==(s=n.prev_hasmore)&&void 0!==s&&s,c.isContinuousPrevMessages=null!==(i=n.is_continuous_prev_messages)&&void 0!==i&&i,c.nextMessages=(null!==(a=n.next_messages)&&void 0!==a?a:[]).map((function(t){return bt(e,t)})),c.nextHasmore=null!==(o=n.next_hasmore)&&void 0!==o&&o,c.isContinuousNextMessages=null!==(u=n.is_continuous_next_messages)&&void 0!==u&&u,c}return e(n,t),n}(D),pr=function(e,t){return e.findIndex((function(e){return e.isIdentical(t)}))},fr=function(e,t,n){if(e.length>0){for(var r=pr(e,t),s=0,i=e.length-1,a=Math.floor((s+i)/2);s0)i=a,a=Math.floor((s+i)/2);else{if(!(o<0))return{place:a,oldPosition:r};s=a+1,a=Math.floor((s+i)/2)}}return{place:_r(e[a],t,n)>=0?a:a+1,oldPosition:r}}return{place:e.length,oldPosition:-1}},_r=function(e,t,n){switch(n){case Ge.LATEST_LAST_MESSAGE:return e.lastMessage&&t.lastMessage?t.lastMessage.createdAt-e.lastMessage.createdAt:e.lastMessage?-1:t.lastMessage?1:t.createdAt-e.createdAt;case Ge.CHRONOLOGICAL:return t.createdAt-e.createdAt;case Ge.CHANNEL_NAME_ALPHABETICAL:var r=e.name.localeCompare(t.name);return 0===r?e.createdAt-t.createdAt:r}},mr=function(e,t){return t instanceof Ct?e.findIndex((function(e){return e instanceof Ct&&t.isIdentical(e)})):e.findIndex((function(e){return e.isIdentical(t)}))},vr=function(e,t){return e.findIndex((function(e){return e.messageId===t}))},gr=function(e,t){if(e.length>0){for(var n=0,r=e.length-1,s=Math.floor((n+r)/2);n0)r=s,s=Math.floor((n+r)/2);else{if(!(i<0))return s;n=s+1,s=Math.floor((n+r)/2)}}return e[s].createdAt>t.createdAt?s:s+1}return e.length},yr=6e5;!function(e){e.CACHE_AND_REPLACE_BY_API="cache_and_replace_by_api"}(tr||(tr={}));var Cr,Er,br,Mr=function(){function e(){}return e.prototype._invokeResponse=function(e,t,n){var r=this;W((function(){return f(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}(),Nr=function(){function e(e,t){var n=t.channel,r=t.filter,s=t.startingPoint,i=t.limit,a=this;this._channel=null,this._messages=[],this._unsentMessages=[],this._backgroundSync=null,this._changelogSync=null,this._pollChangelogSync=null,this._checkMyMutedStateTimer=null,this._iid=e,this._key="mc-".concat(oe()),this.filter=null!=r?r:new Je,this._channel=n,this._syncRange=new Xn({}),this._hasPrevious=!0,this._hasNext=!0,this._startingPoint="number"==typeof s?s:Date.now()+yr,this._limit=i||Le;var o=er.of(this._iid);o.subscribeGroupChannelEvent(this._key,{onUpdate:function(e,t,n){var r=pr(e,a._channel);if(r>=0)switch(W((function(){return f(a,void 0,void 0,(function(){var n,s;return _(this,(function(i){return n=new rr(t),this._channel=e[r],tt(t)&&(null===(s=this._handler)||void 0===s?void 0:s.onChannelUpdated)&&this._handler.onChannelUpdated(n,this.channel),[2]}))}))})),t){case ze.EVENT_CHANNEL_UPDATED:var s=!1;for(var i in a._messages){if(a._messages[i].createdAt>=a._channel.messageOffsetTimestamp){s=!0;var o=parseInt(i);if(o>0){var u=a._messages.splice(0,o);a._removeMessagesFromView(u.map((function(e){return e.messageId})),K.EVENT_MESSAGE_OFFSET_UPDATED)}break}}!s&&a._messages.length>0&&a._removeMessagesFromView(a._messages.map((function(e){return e.messageId})),K.EVENT_MESSAGE_OFFSET_UPDATED);break;case ze.EVENT_CHANNEL_UNMUTED:var c=n;B.of(a._iid).sdkState.userId===c&&a._clearCheckMyMutedTimer();break;case ze.EVENT_CHANNEL_MUTED:var l=n;B.of(a._iid).sdkState.userId===l&&-1!==a.channel._myMutedRemainingTime&&a._startCheckMyMutedTimer(a.channel._myMutedRemainingTime);break;case ze.EVENT_CHANNEL_LEFT:a.channel.isPublic&&a._clearCheckMyMutedTimer()}},onRemove:function(e,t){e.indexOf(a.channel.url)>=0&&(a._clearCheckMyMutedTimer(),W((function(){return f(a,void 0,void 0,(function(){var e,n;return _(this,(function(r){return e=new rr(t),(null===(n=this._handler)||void 0===n?void 0:n.onChannelDeleted)&&this._handler.onChannelDeleted(e,this.channel.url),[2]}))}))})))}}),o.subscribeMessageEvent(this._key,{onUpdate:function(e,t){var n,r,s=[],i=[];try{for(var o=m(e),u=o.next();!u.done;u=o.next()){var c=u.value;c.channelUrl===a._channel.url&&(a.filter.match(c)?s.push(c):i.push(c.messageId))}}catch(e){n={error:e}}finally{try{u&&!u.done&&(r=o.return)&&r.call(o)}finally{if(n)throw n.error}}if(re(t)){if(s.length>0)switch(t){case K.EVENT_MESSAGE_SENT_FAILED:case K.EVENT_MESSAGE_SENT_SUCCESS:case K.EVENT_MESSAGE_UPDATED:case K.EVENT_MESSAGE_THREADINFO_UPDATED:case K.EVENT_MESSAGE_REACTION_UPDATED:case K.SYNC_MESSAGE_CHANGELOGS:a._updateMessagesToView(s,t);break;case K.EVENT_MESSAGE_SENT_PENDING:a._addMessagesToView(s,t);break;case K.EVENT_MESSAGE_RECEIVED:a.hasNext||a._addMessagesToView(s,t);break;case K.SYNC_MESSAGE_FILL:a._addMessagesToView(s,t)}i.length>0&&a._removeMessagesFromView(i,t)}},onRemove:function(e,t){a._removeMessagesFromView(e,t)},onRemoveUnsent:function(e,t){a._removeUnsentMessageFromView(e,t)},onPollChangeLogUpdate:function(e,t){a._updatePollsToView(e,t)},onPollUpdate:function(e,t){a._applyPollUpdateEventToView(e,t)},onPollVote:function(e,t){a._applyPollVoteEventToView(e,t)}});var u=B.of(this._iid),c=u.cacheContext,l=u.dispatcher,p=u.logger;this._channel._updateMessageCollectionLastAccessedAt(),l.dispatch(new je({channels:[this._channel],source:ze.CHANNEL_LASTACCESSEDAT_UPDATED})),!this._channel.isSuper&&c.localCacheEnabled&&(this._backgroundSync=ar.of(this._iid,this._channel),this._backgroundSync.resume(this._startingPoint)),this._changelogSync=ur.of(this._iid,this._channel),this._changelogSync.resume(),this._pollChangelogSync=lr.of(this._iid,this._channel,this._hasPollMessage.bind(this)),this._pollChangelogSync.resume(),this._prevFill=new nr(this._key,(function(e){return f(a,void 0,void 0,(function(){var t,n,r,s,i;return _(this,(function(a){switch(a.label){case 0:return[4,this._getRemoteMessages(e,{prevLimit:this._limit,source:K.SYNC_MESSAGE_FILL,checkingContinuousMessages:c.localCacheEnabled})];case 1:return t=a.sent(),n=t.messages,r=t.isContinuousMessages,n.length>0?(s=Math.min.apply(Math,h([],d(n.map((function(e){return e.createdAt}))),!1)),this._syncRange.extends(s),r&&(null===(i=this._backgroundSync)||void 0===i||i.range.extends(s)),[2,{hasNext:n.length>=this._limit&&this.viewTop0?(s=Math.max.apply(Math,h([],d(n.map((function(e){return e.createdAt}))),!1)),this._syncRange.extends(s),r&&(null===(i=this._backgroundSync)||void 0===i||i.range.extends(s)),[2,{hasNext:!(n.length>=this._limit&&this._hasNext)||this.viewBottom>s,nextToken:this._syncRange.bottom}]):[2,{hasNext:!1,nextToken:0}]}}))}))})),this._connectionEventContext=l.on((function(e){if(e instanceof $)switch(e.stateType){case ee.CONNECTED:a._refreshChannel(ze.SYNC_CHANNEL_CHANGELOGS),E((function(){return f(a,void 0,void 0,(function(){var e;return _(this,(function(t){switch(t.label){case 0:return[4,this.channel.getMyMutedInfo()];case 1:return(e=t.sent()).isMuted&&-1!==e.remainingDuration&&this._startCheckMyMutedTimer(e.remainingDuration),[2]}}))}))})),p.debug("check huge gap"),a._checkHugeGap();break;case ee.LOGOUT:a.dispose();break;default:a._clearCheckMyMutedTimer(),a._prevFill.stop(),a._nextFill.stop()}})),B.of(this._iid).statLogCollector.put(new se({type:ie.FEATURE_LOCALCACHE,data:{use_local_cache:c.localCacheEnabled,collection_interface:{message:!0}}}))}return Object.defineProperty(e.prototype,"channel",{get:function(){return this._channel},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"succeededMessages",{get:function(){return h([],d(this._messages),!1)},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"failedMessages",{get:function(){return this._unsentMessages.filter((function(e){return e.sendingStatus===ue.FAILED}))},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"pendingMessages",{get:function(){return this._unsentMessages.filter((function(e){return e.sendingStatus===ue.PENDING}))},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"hasPrevious",{get:function(){return this._hasPrevious},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"hasNext",{get:function(){return this._hasNext},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"viewTop",{get:function(){return Math.min.apply(Math,h(h([],d(this._messages.map((function(e){return e.createdAt}))),!1),[Number.MAX_SAFE_INTEGER],!1))},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"viewBottom",{get:function(){return Math.max.apply(Math,h(h([],d(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),c=u.next();!c.done;c=u.next()){var l=c.value;if(t===K.SYNC_MESSAGE_FILL){if(l.messageId>0){if((y=mr(this._messages,l))<0){mr(this._unsentMessages,l)<0&&a.push(l);var p=gr(this._messages,l);this._messages.splice(p,0,l)}}else if(l instanceof Ct){(y=mr(this._unsentMessages,l))<0&&mr(this._messages,l)<0&&(this._unsentMessages.push(l),a.push(l))}}else if(l.messageId>0){if((y=mr(this._messages,l))<0){var v=mr(this._unsentMessages,l);v<0?a.push(l):(this._unsentMessages.splice(v,1),o.push(l));p=gr(this._messages,l);this._messages.splice(p,0,l)}else o.push(l),this._messages[y]=l;if(l.updatedAt>0){var g=this._updateChildMessagesInView(l);o.push.apply(o,h([],d(g),!1))}}else if(l instanceof Ct){var y;(y=mr(this._unsentMessages,l))<0?mr(this._messages,l)<0&&(this._unsentMessages.push(l),a.push(l)):(o.push(l),this._unsentMessages[y]=l)}}}catch(e){n={error:e}}finally{try{c&&!c.done&&(r=u.return)&&r.call(u)}finally{if(n)throw n.error}}re(t)&&W((function(){return f(s,void 0,void 0,(function(){var e,n,r;return _(this,(function(s){return e=new sr(t),a.length>0&&(null===(n=this._handler)||void 0===n||n.onMessagesAdded(e,this.channel,a)),o.length>0&&(null===(r=this._handler)||void 0===r||r.onMessagesUpdated(e,this.channel,o)),[2]}))}))}))},e.prototype._updateChildMessagesInView=function(e){var t=[];return this._messages.forEach((function(n){n.applyParentMessage(e)&&t.push(n)})),t},e.prototype._updatePollsToView=function(e,t){var n,r,s=this,i=[];try{for(var a=m(e),o=a.next();!o.done;o=a.next()){var u=o.value,c=vr(this._messages,u.messageId);if(c>=0){var l=this._messages[c];l&&l.applyPoll(u),i.push(l)}}}catch(e){n={error:e}}finally{try{o&&!o.done&&(r=a.return)&&r.call(a)}finally{if(n)throw n.error}}return i.length>0&&re(t)&&W((function(){return f(s,void 0,void 0,(function(){var e,n;return _(this,(function(r){return e=new sr(t),i.length>0&&(null===(n=this._handler)||void 0===n||n.onMessagesUpdated(e,this.channel,i)),[2]}))}))})),i},e.prototype._applyPollUpdateEventToView=function(e,t){var n=this,r=vr(this._messages,e.messageId);if(r>=0){var s=this._messages[r];s&&s.isUserMessage()&&s.poll&&s.poll.applyPollUpdateEvent(e)&&re(t)&&W((function(){return f(n,void 0,void 0,(function(){var e,n;return _(this,(function(r){return e=new sr(t),null===(n=this._handler)||void 0===n||n.onMessagesUpdated(e,this.channel,[s]),[2]}))}))}))}},e.prototype._applyPollVoteEventToView=function(e,t){var n=this,r=vr(this._messages,e.messageId);if(r>=0){var s=this._messages[r];s&&s.isUserMessage()&&s.poll&&s.poll.applyPollVoteEvent(e)&&re(t)&&W((function(){return f(n,void 0,void 0,(function(){var e,n;return _(this,(function(r){return e=new sr(t),null===(n=this._handler)||void 0===n||n.onMessagesUpdated(e,this.channel,[s]),[2]}))}))}))}},e.prototype._updateMessagesToView=function(e,t){var n,r,s=this,i=[],a=[];try{for(var o=m(e),u=o.next();!u.done;u=o.next()){var c,l=u.value;if(l.messageId>0)if((c=mr(this._messages,l))>=0)i.push(l),this._messages[c]=l;else{var h=mr(this._unsentMessages,l);if(h>=0){var d=this._unsentMessages.splice(h,1);if(this.hasNext&&d.length>0)a.push(d[0]);else{i.push(l);var p=gr(this._messages,l);this._messages.splice(p,0,l)}}}else if(l instanceof Ct)(c=mr(this._unsentMessages,l))>=0&&(i.push(l),this._unsentMessages[c]=l)}}catch(e){n={error:e}}finally{try{u&&!u.done&&(r=o.return)&&r.call(o)}finally{if(n)throw n.error}}return re(t)&&W((function(){return f(s,void 0,void 0,(function(){var e,n,r;return _(this,(function(s){return e=new sr(t),i.length>0?null===(n=this._handler)||void 0===n||n.onMessagesUpdated(e,this.channel,i):a.length>0&&(null===(r=this._handler)||void 0===r||r.onMessagesDeleted(e,this.channel,[],a)),[2]}))}))})),i},e.prototype._removeMessagesFromView=function(e,t){var n,r,s=this,i=[],a=[],o=function(e){var t=u._messages.findIndex((function(t){return t.messageId===e}));if(t>=0){var n=u._messages[t];i.push(n.messageId),a.push(n),u._messages.splice(t,1)}},u=this;try{for(var c=m(e),l=c.next();!l.done;l=c.next()){o(l.value)}}catch(e){n={error:e}}finally{try{l&&!l.done&&(r=c.return)&&r.call(c)}finally{if(n)throw n.error}}return re(t)&&a.length>0&&W((function(){return f(s,void 0,void 0,(function(){var e,n;return _(this,(function(r){return e=new sr(t),null===(n=this._handler)||void 0===n||n.onMessagesDeleted(e,this.channel,i,a),[2]}))}))})),i},e.prototype._removeUnsentMessageFromView=function(e,t){var n=this._unsentMessages.findIndex((function(t){return t.reqId===e}));n>=0&&this._unsentMessages.splice(n,1)},e.prototype._getLocalMessages=function(e,t){var n=t.prevLimit,r=void 0===n?0:n,s=t.nextLimit,i=void 0===s?0:s;return f(this,void 0,void 0,(function(){var t,n,s,a,o,u,c;return _(this,(function(l){switch(l.label){case 0:return t=er.of(this._iid),r>0?[4,t.getMessagesFromCache(this._channel.url,e,"prev",this.filter,r)]:[3,2];case 1:return s=l.sent(),[3,3];case 2:s=[],l.label=3;case 3:return n=s,i>0?[4,t.getMessagesFromCache(this._channel.url,e,"next",this.filter,i)]:[3,5];case 4:return o=l.sent(),[3,6];case 5:o=[],l.label=6;case 6:if(a=o,n.length>0&&a.length>0)for(c in u=n.map((function(e){return e.messageId})),a)if(u.includes(a[c].messageId)){a.splice(parseInt(c),1);break}return[2,h(h([],d(n),!1),d(a),!1).sort((function(e,t){return t.createdAt-e.createdAt}))]}}))}))},e.prototype._getRemoteMessages=function(e,t){var n=t.prevLimit,r=void 0===n?0:n,i=t.nextLimit,a=void 0===i?0:i,o=t.source,u=void 0===o?K.REQUEST_MESSAGE:o,c=t.reverse,l=void 0!==c&&c,h=t.checkingContinuousMessages,d=void 0!==h&&h;return f(this,void 0,void 0,(function(){var t,n;return _(this,(function(i){switch(i.label){case 0:return t=Ut.of(this._iid),r>0||a>0?[4,t._getMessagesByTimestampForCollection(this._channel.url,this._channel.channelType,e,s(s({},this.filter),{isInclusive:!0,reverse:l,prevResultSize:r,nextResultSize:a,includeMetaArray:!0,includeReactions:!0,includeThreadInfo:!0,includeParentMessageInfo:!0}),u,d)]:[3,2];case 1:return n=i.sent(),[3,3];case 2:n={messages:[],isContinuousMessages:!1},i.label=3;case 3:return[2,n]}}))}))},e.prototype._checkHugeGap=function(){var e;return f(this,void 0,void 0,(function(){var t,n,r,i,a,o,u,c,l,p,m,v,g,y,C,E,b,M,N,S,U=this;return _(this,(function(I){switch(I.label){case 0:return this._messages.length>0?(t=this._syncRange.top,n=this.viewTop,r=this._syncRange.bottom,i=this.hasNext?this.viewBottom:Number.MAX_SAFE_INTEGER,[4,(a=er.of(this._iid)).getCachedMessageCountBetween(this._channel.url,this.filter,n,t)]):[3,4];case 1:return o=I.sent(),[4,a.getCachedMessageCountBetween(this._channel.url,this.filter,r,i)];case 2:return u=I.sent(),[4,ce((function(){return f(U,void 0,void 0,(function(){var e,a,c,l,p,m,v,g,y,C,E,b,M,N,S,U,I,A,w,D,L,k=this;return _(this,(function(P){switch(P.label){case 0:return e=B.of(this._iid),a=e.dispatcher,c=e.requestQueue,l=e.cacheContext,p=new hr(s({channelUrl:this._channel.url,channelType:this._channel.channelType,prevStart:n,prevEnd:t,prevCount:o,nextStart:r,nextEnd:i,nextCount:u,checkingContinuousMessages:l.localCacheEnabled},this.filter)),[4,c.send(p)];case 1:return m=P.sent(),v=m.as(dr),g=v.isHugeGap,y=v.prevMessages,C=void 0===y?[]:y,E=v.prevHasMore,b=v.isContinuousPrevMessages,M=v.nextMessages,N=void 0===M?[]:M,S=v.nextHasmore,U=v.isContinuousNextMessages,g?W((function(){return f(k,void 0,void 0,(function(){var e;return _(this,(function(t){return null===(e=this._handler)||void 0===e||e.onHugeGapDetected(),[2]}))}))})):(this._hasPrevious=E,this._hasNext=S,I=this.viewTop,A=this.viewBottom,w=Math.min.apply(Math,h([Number.MAX_SAFE_INTEGER,I],d(C.map((function(e){return e.createdAt}))),!1)),D=Math.max.apply(Math,h([0,A],d(N.map((function(e){return e.createdAt}))),!1)),a.dispatch(new T({messages:C,source:K.SYNC_MESSAGE_FILL})),a.dispatch(new T({messages:N,source:K.SYNC_MESSAGE_FILL})),this._syncRange.extends(w,D),(b||U)&&(null===(L=this._backgroundSync)||void 0===L||L.range.extends(w,D)),ID&&this._nextFill.start(D)),[2]}}))}))}),1)];case 3:return I.sent(),[3,8];case 4:c=B.of(this._iid).cacheContext,l=Math.floor(this._limit/2),p=Date.now(),I.label=5;case 5:return I.trys.push([5,7,,8]),[4,this._getRemoteMessages(p,{prevLimit:l,nextLimit:l,source:K.SYNC_MESSAGE_FILL,checkingContinuousMessages:c.localCacheEnabled})];case 6:if(m=I.sent(),v=m.messages,g=m.isContinuousMessages,v.length>0){for(y=v.map((function(e){return e.createdAt})),C=0,E=0,b=0;b=p&&E++;this._hasPrevious=C>=l,this._hasNext=E>=l,(S=this._syncRange).extends.apply(S,h([],d(y),!1)),g&&(null===(e=this._backgroundSync)||void 0===e||e.range.extends(this._syncRange.top,this._syncRange.bottom)),this._addMessagesToView(v,K.SYNC_MESSAGE_FILL)}else this._hasPrevious=!1,this._hasNext=!1;return[3,8];case 7:return(N=I.sent())instanceof V&&N.code===J.NOT_FOUND_IN_DATABASE&&(this._hasPrevious=!1,this._hasNext=!1),[3,8];case 8:return[2]}}))}))},e.prototype._loadUnsentMessages=function(){return f(this,void 0,void 0,(function(){var e,t;return _(this,(function(n){switch(n.label){case 0:return e=er.of(this._iid),t=this,[4,e.getUnsentMessagesFromCache(this._channel.url,this.filter)];case 1:return t._unsentMessages=n.sent(),[2]}}))}))},e.prototype._hasPollMessage=function(){return f(this,void 0,void 0,(function(){return _(this,(function(e){switch(e.label){case 0:return[4,er.of(this._iid).getPollMessagesFromCache(this._channel.url,Date.now()+yr,this.filter,1)];case 1:return e.sent().length>0?[2,!0]:[2,!1]}}))}))},e.prototype._refreshChannel=function(e){er.of(this._iid).refreshChannel(this.channel.url,!0,e)},e.prototype._startCheckMyMutedTimer=function(e){var t=this;this._clearCheckMyMutedTimer(),this._checkMyMutedStateTimer=setTimeout((function(){return f(t,void 0,void 0,(function(){var e,t,n,r;return _(this,(function(s){switch(s.label){case 0:this._checkMyMutedStateTimer=null,e=!0,s.label=1;case 1:return s.trys.push([1,3,4,5]),[4,this._channel.getMyMutedInfo()];case 2:return t=s.sent(),e=!t.isMuted,[3,5];case 3:return s.sent(),e=!0,[3,5];case 4:return e&&(this.channel.myMutedState=es.UNMUTED,n=new rr(ze.EVENT_CHANNEL_UNMUTED),null===(r=this._handler)||void 0===r||r.onChannelUpdated(n,this.channel)),[7];case 5:return[2]}}))}))}),e+1e3)},e.prototype._clearCheckMyMutedTimer=function(){this._checkMyMutedStateTimer&&(clearTimeout(this._checkMyMutedStateTimer),this._checkMyMutedStateTimer=null)},e.prototype.initialize=function(e){var t=this,n=new Mr;this._messages=[],this._unsentMessages=[],this._syncRange=new Xn({}),this._hasNext=!0,this._hasPrevious=!0,this._refreshChannel(ze.REFRESH_CHANNEL),E((function(){return f(t,void 0,void 0,(function(){var e;return _(this,(function(t){switch(t.label){case 0:return[4,this.channel.getMyMutedInfo()];case 1:return(e=t.sent()).isMuted&&-1!==e.remainingDuration&&this._startCheckMyMutedTimer(e.remainingDuration),[2]}}))}))}));var r=Math.floor(this._limit/2);if(e===tr.CACHE_AND_REPLACE_BY_API)this._getLocalMessages(this._startingPoint,{prevLimit:r,nextLimit:r}).then((function(e){return f(t,void 0,void 0,(function(){var t;return _(this,(function(r){switch(r.label){case 0:return t=this._filterUnderOffsetMessage(e),this._addMessagesToView(t,K.REQUEST_MESSAGE),[4,this._loadUnsentMessages()];case 1:return r.sent(),n._invokeResponse("local",null,t),[2]}}))}))})).catch((function(e){if(Q(e))throw e;n._invokeResponse("local",e,null)})).finally((function(){var e=B.of(t._iid).cacheContext;t._getRemoteMessages(t._startingPoint,{prevLimit:r,nextLimit:r,reverse:!0,checkingContinuousMessages:e.localCacheEnabled}).then((function(e){var s,i,a=e.messages,o=e.isContinuousMessages;t._messages=[];var u=t._filterUnderOffsetMessage(a);if(u.length>0){for(var c=u.map((function(e){return e.createdAt})),l=0,p=0,f=0;f=t._startingPoint&&p++}t._hasPrevious=l>=r,t._hasNext=p>=r,(s=t._syncRange).extends.apply(s,h([],d(u.map((function(e){return e.createdAt}))),!1)),o&&(null===(i=t._backgroundSync)||void 0===i||i.range.extends(t._syncRange.top,t._syncRange.bottom)),t._addMessagesToView(u,K.REQUEST_MESSAGE)}else t._hasPrevious=!1,t._hasNext=!1;n._invokeResponse("remote",null,u)})).catch((function(e){if(Q(e))throw e;n._invokeResponse("remote",e,null)}))}));var s=B.of(this._iid),i=s.cacheContext;return s.statLogCollector.put(new se({type:ie.FEATURE_LOCALCACHE,data:{use_local_cache:i.localCacheEnabled,collection_interface:{message_init_policy:e}}})),n},e.prototype.loadPrevious=function(){return f(this,void 0,void 0,(function(){var e,t,n,r=this;return _(this,(function(s){switch(s.label){case 0:return this._hasPrevious?(e=this.viewTop,t=[],[4,E((function(){return f(r,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 s.sent(),0!==t.length&&this._backgroundSync&&this._backgroundSync.isWrappingMessages(t)?[3,3]:[4,E((function(){return f(r,void 0,void 0,(function(){var n,r,s,i,a;return _(this,(function(o){switch(o.label){case 0:return n=B.of(this._iid).cacheContext,[4,this._getRemoteMessages(e,{prevLimit:this._limit,checkingContinuousMessages:n.localCacheEnabled})];case 1:return r=o.sent(),t=this._filterUnderOffsetMessage(r.messages),this._hasPrevious=t.length>=this._limit,t.length>0&&((s=this._syncRange).extends.apply(s,h([],d(t.map((function(e){return e.createdAt}))),!1)),(null===(i=this._backgroundSync)||void 0===i?void 0:i.range.overlap(this._syncRange))&&r.isContinuousMessages&&(null===(a=this._backgroundSync)||void 0===a||a.range.extends(this._syncRange.top))),[2]}}))}))}))];case 2:return s.sent(),this._addMessagesToView(t,K.REQUEST_MESSAGE),[3,4];case 3:this._hasPrevious=t.length>=this._limit,t.length>0&&((n=this._syncRange).extends.apply(n,h([],d(t.map((function(e){return e.createdAt}))),!1)),this._addMessagesToView(t,K.REQUEST_MESSAGE)),s.label=4;case 4:return[2,t];case 5:return[2,[]]}}))}))},e.prototype.loadNext=function(){var e;return f(this,void 0,void 0,(function(){var t,n,r,s=this;return _(this,(function(i){switch(i.label){case 0:return this._hasNext?(t=this.viewBottom,n=[],[4,E((function(){return f(s,void 0,void 0,(function(){var e;return _(this,(function(r){switch(r.label){case 0:return e=this._filterUnderOffsetMessage,[4,this._getLocalMessages(t,{nextLimit:this._limit})];case 1:return n=e.apply(this,[r.sent()]),[2]}}))}))}))]):[2,[]];case 1:return i.sent(),0!==n.length&&(null===(e=this._backgroundSync)||void 0===e?void 0:e.isWrappingMessages(n))?[3,3]:[4,E((function(){return f(s,void 0,void 0,(function(){var e,r,s,i,a;return _(this,(function(o){switch(o.label){case 0:return e=B.of(this._iid).cacheContext,[4,this._getRemoteMessages(t,{nextLimit:this._limit,checkingContinuousMessages:e.localCacheEnabled})];case 1:return r=o.sent(),n=this._filterUnderOffsetMessage(r.messages),this._hasNext=n.length>=this._limit,n.length>0&&((s=this._syncRange).extends.apply(s,h([],d(n.map((function(e){return e.createdAt}))),!1)),(null===(i=this._backgroundSync)||void 0===i?void 0:i.range.overlap(this._syncRange))&&r.isContinuousMessages&&(null===(a=this._backgroundSync)||void 0===a||a.range.extends(this._syncRange.bottom))),[2]}}))}))}))];case 2:return i.sent(),this._addMessagesToView(n,K.REQUEST_MESSAGE),[3,4];case 3:this._hasNext=n.length>=this._limit,n.length>0&&((r=this._syncRange).extends.apply(r,h([],d(n.map((function(e){return e.createdAt}))),!1)),this._addMessagesToView(n,K.REQUEST_MESSAGE)),i.label=4;case 4:return[2,n]}}))}))},e.prototype.removeFailedMessage=function(e){return f(this,void 0,void 0,(function(){var t;return _(this,(function(n){switch(n.label){case 0:return[4,er.of(this._iid).removeFailedMessageFromCache(e)];case 1:return n.sent(),(t=this._unsentMessages.findIndex((function(t){return t.reqId===e})))>-1&&this._unsentMessages.splice(t,1),[2]}}))}))},e.prototype.dispose=function(){var e,t,n,r=B.of(this._iid),s=r.cacheContext,i=r.dispatcher;this._clearCheckMyMutedTimer(),this._channel._updateMessageCollectionLastAccessedAt(),i.dispatch(new je({channels:[this._channel],source:ze.CHANNEL_LASTACCESSEDAT_UPDATED})),s.localCacheEnabled&&(this._prevFill.stop(),this._nextFill.stop()),null===(e=this._backgroundSync)||void 0===e||e.close(),null===(t=this._changelogSync)||void 0===t||t.close(),null===(n=this._pollChangelogSync)||void 0===n||n.close();var a=er.of(this._iid);a.unsubscribeGroupChannelEvent(this._key),a.unsubscribeMessageEvent(this._key),this._connectionEventContext&&this._connectionEventContext.close()},e}(),Sr={coverUrl:null,coverImage:null,isDistinct:null,isPublic:null,isDiscoverable:null,accessCode:null,name:null,data:null,customType:null,operatorUserIds:null,messageSurvivalSeconds:null},Ur={hidePreviousMessages:!1,allowAutoUnhide:!0},Tr=function(t){function n(e){var n=this,r=e.channelUrl,s=e.token,i=e.limit,a=e.order,o=e.mutedMemberFilter,u=e.memberStateFilter,c=e.nicknameStartsWithFilter,l=e.operatorFilter;return(n=t.call(this)||this).method=I.GET,n.path="".concat(k,"/").concat(encodeURIComponent(r),"/members"),n.params={token:s,limit:i,order:a,muted_member_filter:o,member_state_filter:u,nickname_startswith:c,operator_filter:l,show_member_is_muted:!0,show_read_receipt:!0,show_delivery_receipt:!0},n}return e(n,t),n}(w),Ir=function(t){function n(e,n){var r=t.call(this,e,n)||this;r.token=null,r.members=[];var s=n.next,i=n.members;return r.token=s,i&&i.length>0&&(r.members=i.map((function(t){return new jt(e,t)}))),r}return e(n,t),n}(D);!function(e){e.ALL="all",e.MUTED="muted",e.UNMUTED="unmuted"}(Cr||(Cr={})),function(e){e.MEMBER_NICKNAME_ALPHABETICAL="member_nickname_alphabetical",e.OPERATOR_THEN_MEMBER_ALPHABETICAL="operator_then_member_alphabetical"}(Er||(Er={})),function(e){e.ALL="all",e.JOINED="joined_only",e.INVITED="invited_only",e.INVITED_BY_FRIEND="invited_by_friend",e.INVITED_BY_NON_FRIEND="invited_by_non_friend"}(br||(br={}));var Ar=function(t){function n(e,n,r){var s,i,a,u,c=this;return(c=t.call(this,e,n,o.GROUP,r)||this).mutedMemberFilter=Cr.ALL,c.memberStateFilter=br.ALL,c.nicknameStartsWithFilter=null,c.operatorFilter=Vt.ALL,c.order=Er.MEMBER_NICKNAME_ALPHABETICAL,c.mutedMemberFilter=null!==(s=r.mutedMemberFilter)&&void 0!==s?s:Cr.ALL,c.memberStateFilter=null!==(i=r.memberStateFilter)&&void 0!==i?i:br.ALL,c.nicknameStartsWithFilter=null!==(a=r.nicknameStartsWithFilter)&&void 0!==a?a:null,c.order=null!==(u=r.order)&&void 0!==u?u:Er.MEMBER_NICKNAME_ALPHABETICAL,c}return e(n,t),n.prototype._validate=function(){return t.prototype._validate.call(this)&&i(Cr,this.mutedMemberFilter)&&i(br,this.memberStateFilter)&&(g("string",this.nicknameStartsWithFilter)||null===this.nicknameStartsWithFilter)&&i(Vt,this.operatorFilter)&&i(Er,this.order)},n.prototype.next=function(){return f(this,void 0,void 0,(function(){var e,t,n,r,i,a;return _(this,(function(o){switch(o.label){case 0:return this._validate()?this._isLoading?[3,3]:this._hasNext?(this._isLoading=!0,e=B.of(this._iid).requestQueue,t=new Tr(s(s({},this),{token:this._token})),[4,e.send(t)]):[3,2]:[3,5];case 1:return n=o.sent(),r=n.as(Ir),i=r.members,a=r.token,this._token=a,this._hasNext=!!a,this._isLoading=!1,[2,i];case 2:return[2,[]];case 3:throw V.queryInProgress;case 4:return[3,6];case 5:throw V.invalidParameters;case 6:return[2]}}))}))},n}(le),wr=function(t){function n(e){var n=this,r=e.channelUrl,s=e.userId,i=e.accessCode;return(n=t.call(this)||this).method=I.PUT,n.path="".concat(k,"/").concat(encodeURIComponent(r),"/accept"),n.params={user_id:s,access_code:i},n}return e(n,t),n}(w),Dr=function(t){function n(e,n){var r=t.call(this,e,n)||this;return r.channel=new os(e,n),r.channel.myMemberState=xt.JOINED,r}return e(n,t),n}(D),Lr=function(t){function n(e){var n=this,s=e.channelUrl,i=e.isDistinct,a=e.isPublic,o=e.isDiscoverable,u=e.coverUrl,c=e.coverImage,l=e.accessCode,h=e.name,d=e.data,p=e.customType,f=e.operatorUserIds,_=e.messageSurvivalSeconds;return(n=t.call(this)||this).method=I.PUT,n.path="".concat(k,"/").concat(encodeURIComponent(s)),n.params=r({is_distinct:i,is_public:a,is_discoverable:o,name:h,data:d,custom_type:p,cover_url:u,cover_file:c,access_code:l,operator_ids:f,message_survival_seconds:_}),n}return e(n,t),n}(w),kr=function(t){function n(e,n){var r=t.call(this,e,n)||this;return r.channel=new os(e,n),r}return e(n,t),n}(D),Pr=function(t){function n(e){var n=this,r=e.channelUrl;return(n=t.call(this)||this).method=I.DELETE,n.path="".concat(k,"/").concat(encodeURIComponent(r)),n}return e(n,t),n}(w);!function(t){function n(e,n){return t.call(this,e,n)||this}e(n,t)}(D);var xr=function(t){function n(e){var n=this,r=e.channelUrl;return(n=t.call(this)||this).method=I.DELETE,n.path="".concat(k,"/").concat(encodeURIComponent(r),"/hide"),n}return e(n,t),n}(w);!function(t){function n(){return null!==t&&t.apply(this,arguments)||this}e(n,t)}(D);var Rr=function(t){function n(e){var n=e.userId,r=e.channelUrl,s=e.countPreference,i=t.call(this)||this;return i.method=I.PUT,i.path="".concat(A,"/").concat(encodeURIComponent(n),"/count_preference/").concat(encodeURIComponent(r)),i.params={count_preference:s},i}return e(n,t),n}(w),Fr=function(t){function n(e,n){var r=t.call(this,e,n)||this;return r.countPreference=n.count_preference,r}return e(n,t),n}(D),Or=function(t){function n(e){var n=this,r=e.channelUrl;return(n=t.call(this)||this).method=I.PUT,n.path="".concat(k,"/").concat(encodeURIComponent(r),"/reset_user_history"),n}return e(n,t),n}(w),Hr=function(t){function n(e,n){var r=t.call(this,e,n)||this;r.messageOffsetTimestamp=null;var s=n.ts_message_offset;return r.messageOffsetTimestamp=null!=s?s:null,r}return e(n,t),n}(D),Gr=s(s({},ke),{scheduledAt:null,file:null,fileUrl:null,fileName:null,mimeType:null,fileSize:null,thumbnailSizes:null,requireAuth:!1}),Vr=s(s({},xe),{scheduledAt:null}),qr=function(t){function n(e){var n,s=this;s=t.call(this)||this;var i=null;e.mentionType===he.USERS&&(e.mentionedUserIds?i=e.mentionedUserIds:e.mentionedUsers&&(i=e.mentionedUsers.map((function(e){return e.userId}))));var a=e.channelType,o=e.channelUrl,u=e.scheduledMessageId;return s.method=I.PUT,s.path="".concat(ne(a),"/").concat(encodeURIComponent(o),"/scheduled_messages/").concat(encodeURIComponent(u)),s.params=r({req_id:e.reqId,scheduled_at:e.scheduledAt,message_type:de.FILE,url:e.fileUrl,file_name:e.fileName,file_size:e.fileSize,file_type:e.mimeType,thumbnails:e.thumbnailSizes?e.thumbnailSizes.map((function(e){return Tt.payloadify(e)})):[],custom_type:e.customType,data:e.data,require_auth:e.requireAuth,mention_type:e.mentionType,mentioned_user_ids:i,sorted_metaarray:null===(n=e.metaArrays)||void 0===n?void 0:n.map((function(e){return It.payloadify(e)})),apple_critical_alert_options:At.payloadify(e.appleCriticalAlertOptions),push_option:e.pushNotificationDeliveryOption}),s}return e(n,t),n}(w),Br=function(t){function n(e,n){var r=t.call(this,e,n)||this;return r.message=new Nt(e,n),r}return e(n,t),n}(D),jr=function(t){function n(e){var n,s=this;s=t.call(this)||this;var i=null;e.mentionType===he.USERS&&(e.mentionedUserIds?i=e.mentionedUserIds:e.mentionedUsers&&(i=e.mentionedUsers.map((function(e){return e.userId}))));var a=e.channelType,o=e.channelUrl,u=e.scheduledMessageId;return s.method=I.PUT,s.path="".concat(ne(a),"/").concat(encodeURIComponent(o),"/scheduled_messages/").concat(encodeURIComponent(u)),s.params=r({req_id:e.reqId,scheduled_at:e.scheduledAt,message_type:de.USER,message:e.message,custom_type:e.customType,data:e.data,mention_type:e.mentionType,mentioned_user_ids:i,sorted_metaarray:null===(n=e.metaArrays)||void 0===n?void 0:n.map((function(e){return It.payloadify(e)})),apple_critical_alert_options:At.payloadify(e.appleCriticalAlertOptions),target_langs:e.translationTargetLanguages,push_option:e.pushNotificationDeliveryOption}),s}return e(n,t),n}(w);!function(t){function n(e,n){var r=t.call(this,e,n)||this;return r.message=new Mt(e,n),r}e(n,t)}(D);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=I.DELETE,n.path="".concat(ne(r),"/").concat(encodeURIComponent(s),"/scheduled_messages/").concat(encodeURIComponent(i)),n}return e(n,t),n}(w),Qr=function(t){function n(e){var n=t.call(this)||this,r=e.channelType,s=e.channelUrl,i=e.scheduledMessageId;return n.method=I.POST,n.path="".concat(ne(r),"/").concat(encodeURIComponent(s),"/scheduled_messages/").concat(encodeURIComponent(i),"/send_now"),n}return e(n,t),n}(w),Wr=function(t){function n(e){var n=e.userId,r=e.channelUrl,s=e.pushTriggerOption,i=t.call(this)||this;return i.method=I.PUT,i.path="".concat(A,"/").concat(encodeURIComponent(n),"/push_preference/").concat(encodeURIComponent(r)),i.params={push_trigger_option:s},i}return e(n,t),n}(w),Kr=function(t){function n(e,n){var r=t.call(this,e,n)||this;return r.pushTriggerOption=n.push_trigger_option,r.enabled=n.enable,r}return e(n,t),n}(D),Yr=function(t){function n(e){var n=e.userId,r=e.channelUrl,s=t.call(this)||this;return s.method=I.GET,s.path="".concat(A,"/").concat(encodeURIComponent(n),"/push_preference/").concat(encodeURIComponent(r)),s}return e(n,t),n}(w),Jr=function(t){function n(e,n){var r=t.call(this,e,n)||this;return r.pushTriggerOption=n.push_trigger_option,r.enabled=n.enable,r}return e(n,t),n}(D),Xr=function(t){function n(e){var n=e.channelType,r=e.channelUrl,s=e.messageId,i=t.call(this)||this;return i.method=I.POST,i.path="".concat(ne(n),"/").concat(encodeURIComponent(r),"/messages/").concat(s,"/pin"),i}return e(n,t),n}(w);!function(t){function n(e,n){return t.call(this,e,n)||this}e(n,t)}(D);var Zr=function(t){function n(e){var n=e.channelType,r=e.channelUrl,s=e.messageId,i=t.call(this)||this;return i.method=I.DELETE,i.path="".concat(ne(n),"/").concat(encodeURIComponent(r),"/messages/").concat(s,"/pin"),i}return e(n,t),n}(w);!function(t){function n(e,n){return t.call(this,e,n)||this}e(n,t)}(D);var $r,es,ts,ns=function(t){function n(e,n){var r=t.call(this,e)||this;return r.message=bt(e,n.message),r}return e(n,t),n}(c),rs=function(t){function n(e){var n=this,s=e.channelType,i=e.channelUrl,a=e.limit,o=e.token,u=e.includeReactions,c=e.includeMetaArray,l=e.includeParentMessageInfo,h=e.includeThreadInfo,d=e.includePollDetails;return(n=t.call(this)||this).method=I.GET,n.path="".concat(ne(s),"/").concat(encodeURIComponent(i),"/pinned_messages"),n.params=r({limit:a,token:o,include_reactions:u,with_sorted_meta_array:c,include_thread_info:h,include_parent_message_info:l,include_poll_details:d}),n}return e(n,t),n}(w),ss=function(t){function n(e,n){var r=t.call(this,e,n)||this;r.hasMore=null,r.token=null;var s=n.pinned_messages,i=n.has_more,a=n.next;return r.pinnedMessages=s.map((function(t){return new ns(e,t)})),r.hasMore=i,r.token=a,r}return e(n,t),n}(D),is=function(t){function n(e,n,r,s){var i=t.call(this,e,n,r,s)||this;return i.includeMetaArray=s.includeMetaArray,i.includeReactions=s.includeReactions,i.includeParentMessageInfo=s.includeParentMessageInfo,i.includeThreadInfo=s.includeThreadInfo,i.includePollDetails=s.includePollDetails,i}return e(n,t),n.prototype._validate=function(){return t.prototype._validate.call(this)&&g("boolean",this.includeMetaArray,!0)&&g("boolean",this.includeReactions,!0)&&g("boolean",this.includeParentMessageInfo,!0)&&g("boolean",this.includeThreadInfo,!0)&&g("boolean",this.includePollDetails,!0)},n.prototype.next=function(){return f(this,void 0,void 0,(function(){var e,t,n,r,i,a,o;return _(this,(function(u){switch(u.label){case 0:return this._validate()?this._isLoading?[3,3]:this._hasNext?(this._isLoading=!0,e=B.of(this._iid).requestQueue,t=new rs(s(s({},this),{token:this._token})),[4,e.send(t)]):[3,2]:[3,5];case 1:return n=u.sent(),r=n.as(ss),i=r.pinnedMessages,a=r.hasMore,o=r.token,this._token=o,this._hasNext=!!a,this._isLoading=!1,[2,i];case 2:return[2,[]];case 3:throw V.queryInProgress;case 4:return[3,6];case 5:throw V.invalidParameters;case 6:return[2]}}))}))},n}(le);!function(e){e.ALL="all",e.UNREAD_MESSAGE_COUNT_ONLY="unread_message_count_only",e.UNREAD_MENTION_COUNT_ONLY="unread_mention_count_only",e.OFF="off"}($r||($r={})),function(e){e.MUTED="muted",e.UNMUTED="unmuted"}(es||(es={})),function(e){e.UNHIDDEN="unhidden",e.HIDDEN_ALLOW_AUTO_UNHIDE="hidden_allow_auto_unhide",e.HIDDEN_PREVENT_AUTO_UNHIDE="hidden_prevent_auto_unhide"}(ts||(ts={}));var as,os=function(t){function n(e,n){var r,c,l,p,f,_,m,v,y,C,E,b,M,N,S,U,T,I,A,w=this;return(w=t.call(this,e,n)||this)._unreadMemberStateMap=new Map,w._undeliveredMemberStateMap=new Map,w._typingStatus=new Map,w._lastMemberCountUpdated=0,w._typingStarted=0,w._typingEnded=0,w.isDistinct=!1,w.isSuper=!1,w.isBroadcast=!1,w.isExclusive=!1,w.isPublic=!1,w.isDiscoverable=!0,w.isAccessCodeRequired=!1,w.isPushEnabled=!1,w.unreadMessageCount=0,w.unreadMentionCount=0,w.members=[],w.memberCount=0,w.joinedMemberCount=0,w.hiddenState=ts.UNHIDDEN,w.lastMessage=null,w.messageOffsetTimestamp=0,w.messageSurvivalSeconds=-1,w.myMemberState=xt.NONE,w.myRole=a.NONE,w.myMutedState=es.UNMUTED,w.myLastRead=0,w.myCountPreference=$r.ALL,w.myPushTriggerOption=fe.DEFAULT,w.inviter=null,w.invitedAt=0,w.joinedAt=0,w.pinnedMessageIds=[],w.lastPinnedMessage=null,w._pinnedMessagesUpdatedAt=0,w._myMutedRemainingTime=-1,w.channelType=o.GROUP,w.isDistinct=null!==(c=n.is_distinct)&&void 0!==c&&c,w.isSuper=null!==(l=n.is_super)&&void 0!==l&&l,w.isBroadcast=null!==(p=n.is_broadcast)&&void 0!==p&&p,w.isExclusive=null!==(f=n.is_exclusive)&&void 0!==f&&f,w.isPublic=null!==(_=n.is_public)&&void 0!==_&&_,w.isDiscoverable=null!==(m=n.is_discoverable)&&void 0!==m?m:w.isPublic,w.isAccessCodeRequired=null!==(v=n.is_access_code_required)&&void 0!==v&&v,w.isPushEnabled=null!==(y=n.is_push_enabled)&&void 0!==y&&y,Array.isArray(n.members)&&(r=w.members).push.apply(r,h([],d(n.members.map((function(e){return new jt(w._iid,e)}))),!1)),w.memberCount=null!==(C=n.member_count)&&void 0!==C?C:0,w.joinedMemberCount=null!==(E=n.joined_member_count)&&void 0!==E?E:0,w.hiddenState=i(ts,n.hidden_state)?n.hidden_state:ts.UNHIDDEN,w.messageOffsetTimestamp=null!==(b=n.ts_message_offset)&&void 0!==b?b:0,w.messageSurvivalSeconds=null!==(M=n.message_survival_seconds)&&void 0!==M?M:-1,w.lastMessage=n.last_message?bt(w._iid,s({channel_type:w.channelType},n.last_message)):null,n.read_receipt&&Object.keys(n.read_receipt).forEach((function(e){g("number",n.read_receipt[e])&&w._updateUnreadMemberState(e,n.read_receipt[e])})),n.delivery_receipt&&Object.keys(n.delivery_receipt).forEach((function(e){g("number",n.delivery_receipt[e])&&w._updateUndeliveredMemberState(e,n.delivery_receipt[e])})),w.myMemberState=i(xt,n.member_state)?n.member_state:xt.NONE,w.myRole=i(a,n.my_role)?n.my_role:a.NONE,i(es,n.is_muted)?w.myMutedState=n.is_muted:g("boolean",n.is_muted)?w.myMutedState=n.is_muted?es.MUTED:es.UNMUTED:w.myMutedState=es.UNMUTED,w.myCountPreference=i($r,n.count_preference)?n.count_preference:$r.ALL,w.myPushTriggerOption=i(fe,n.push_trigger_option)?n.push_trigger_option:fe.ALL,w.myLastRead=null!==(N=n.user_last_read)&&void 0!==N?N:0,w.inviter=n.inviter?new u(w._iid,n.inviter):null,w.invitedAt=null!==(S=n.invited_at)&&void 0!==S?S:0,w.joinedAt=null!==(U=n.joined_ts)&&void 0!==U?U:0,w._updateUnreadCount(null!==(T=n.unread_message_count)&&void 0!==T?T:0,null!==(I=n.unread_mention_count)&&void 0!==I?I:0),w.pinnedMessageIds=null!==(A=n.pinned_message_ids)&&void 0!==A?A:[],w.lastPinnedMessage=n.latest_pinned_message?bt(w._iid,s({channel_type:w.channelType},n.latest_pinned_message)):null,w}return e(n,t),Object.defineProperty(n.prototype,"isHidden",{get:function(){return this.hiddenState!==ts.UNHIDDEN},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"isTyping",{get:function(){return this._typingStatus.size>0},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"cachedUnreadMemberState",{get:function(){var e,t,n={};try{for(var r=m(this._unreadMemberStateMap),s=r.next();!s.done;s=r.next()){var i=d(s.value,2),a=i[0],o=i[1];n[a]=o}}catch(t){e={error:t}}finally{try{s&&!s.done&&(t=r.return)&&t.call(r)}finally{if(e)throw e.error}}return n},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"cachedUndeliveredMemberState",{get:function(){var e,t,n={};try{for(var r=m(this._undeliveredMemberStateMap),s=r.next();!s.done;s=r.next()){var i=d(s.value,2),a=i[0],o=i[1];n[a]=o}}catch(t){e={error:t}}finally{try{s&&!s.done&&(t=r.return)&&t.call(r)}finally{if(e)throw e.error}}return n},enumerable:!1,configurable:!0}),n.payloadify=function(e){return e?r(s(s({},t.payloadify.call(this,e)),{is_access_code_required:e.isAccessCodeRequired,is_distinct:e.isDistinct,is_super:e.isSuper,is_broadcast:e.isBroadcast,is_exclusive:e.isExclusive,is_public:e.isPublic,is_discoverable:e.isDiscoverable,is_muted:e.myMutedState,is_push_enabled:e.isPushEnabled,unread_message_count:e.unreadMessageCount,unread_mention_count:e.unreadMentionCount,push_trigger_option:e.myPushTriggerOption,count_preference:e.myCountPreference,hidden_state:e.hiddenState,member_count:e.memberCount,joined_member_count:e.joinedMemberCount,member_state:e.myMemberState,my_role:e.myRole,user_last_read:e.myLastRead,ts_message_offset:e.messageOffsetTimestamp,message_survival_seconds:e.messageSurvivalSeconds,read_receipt:e.cachedUnreadMemberState,delivery_receipt:e.cachedUndeliveredMemberState,members:e.members.map((function(e){return jt.payloadify(e)})),last_message:wt(e.lastMessage),inviter:e.inviter?u.payloadify(e.inviter):null,invited_at:e.invitedAt,joined_ts:e.joinedAt,pinned_message_ids:e.pinnedMessageIds,latest_pinned_message:wt(e.lastPinnedMessage)})):null},n.prototype._shouldUpdateLastMessageWith=function(e){return!(e instanceof Ct&&e.parentMessageId>0&&!e.replyToChannel)&&(!this.lastMessage||this.lastMessage.createdAt=0)if(this.myCountPreference===$r.ALL||this.myCountPreference===$r.UNREAD_MESSAGE_COUNT_ONLY)if(this.isExclusive||this.isSuper||this.isBroadcast){var n=B.of(this._iid).maxSuperGroupChannelUnreadCount;this.unreadMessageCount=n&&e>=n?n:e}else this.unreadMessageCount=e;else this.unreadMessageCount=0;else this.unreadMessageCount=0;"number"==typeof t&&t>=0&&(this.myCountPreference===$r.ALL||this.myCountPreference===$r.UNREAD_MENTION_COUNT_ONLY)?this.unreadMentionCount=t:this.unreadMentionCount=0},n.prototype._updateUnreadMemberState=function(e,t){var n=this._unreadMemberStateMap.get(e);return(!n||n0?this._typingStatus.set(e.userId,{user:e,ts:t}):this._typingStatus.delete(e.userId)},n.prototype._clearTypingStatus=function(){this._typingStatus.clear(),this._typingStarted=0,this._typingEnded=0},n.prototype._setLatestMemberCount=function(e,t,n){var r=!1;return n>=this._lastMemberCountUpdated&&(this._lastMemberCountUpdated=n,r=e!==this.memberCount||t!==this.joinedMemberCount,this.memberCount=e,this.joinedMemberCount=t),r},n.prototype.isReadMessage=function(e){var t=B.of(this._iid).sdkState,n=this._unreadMemberStateMap.get(t.userId);return n&&n>=e.createdAt},n.prototype.serialize=function(){var e=this;return O(this,(function(t){t.cachedUnreadMemberState=e.cachedUnreadMemberState,t.cachedUndeliveredMemberState=e.cachedUndeliveredMemberState}))},n.prototype.createMessageCollection=function(e){return void 0===e&&(e={}),new Nr(this._iid,s({channel:this},e))},n.prototype.createMemberListQuery=function(e){return void 0===e&&(e={}),new Ar(this._iid,this.url,e)},n.prototype.createPinnedMessageListQuery=function(e){return void 0===e&&(e={}),new is(this._iid,this.url,this.channelType,e)},n.prototype.addMember=function(e,t){if(void 0===t&&(t=0),!this.isExclusive&&!this.isSuper&&!this.isBroadcast){var n=this.members.findIndex((function(t){return t.userId===e.userId}));if(n>-1){var r=this.members[n];r.state===xt.JOINED&&(e.state=r.state),this.members.splice(n,1),this.memberCount--}this.members.push(e),this.memberCount++,this._updateUnreadMemberState(e.userId,t),this._updateUndeliveredMemberState(e.userId,t)}},n.prototype.removeMember=function(e){if(!this.isExclusive&&!this.isSuper&&!this.isBroadcast){var t=e instanceof jt?e.userId:e,n=this.members.findIndex((function(e){return e.userId===t}));if(n>-1)return this.members.splice(n,1),this.memberCount--,!0}return!1},n.prototype.getUnreadMemberCount=function(e){var t,n;if(e instanceof Ct&&!this.isExclusive&&!this.isSuper&&!this.isBroadcast){var r=B.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===xt.JOINED&&e.sender.userId!==u.userId)(this.cachedUnreadMemberState[u.userId]||0)=e.createdAt&&i.push(a))})),i},n.prototype.getUnreadMembers=function(e,t){var n=this;void 0===t&&(t=!1);var r=B.of(this._iid).sdkState;if(!r.userId||this.isExclusive||this.isSuper||this.isBroadcast)return[];var s=e instanceof Ct?e.sender:null,i=[];return this.members.forEach((function(a){(t||a.userId!==r.userId&&a.userId!==(null==s?void 0:s.userId))&&(n._unreadMemberStateMap.get(a.userId)=t&&(e._typingStatus.delete(i),r=!0)})),r},n.prototype.refresh=function(){return f(this,void 0,void 0,(function(){var e,t,n,r,s,i;return _(this,(function(a){switch(a.label){case 0:return e=B.of(this._iid),t=e.requestQueue,n=e.dispatcher,r=new cn({channelUrl:this.url}),[4,t.send(r)];case 1:return s=a.sent(),i=s.as(ln).channel,n.dispatch(new je({channels:[i],source:ze.REQUEST_CHANNEL})),[2,i]}}))}))},n.prototype.freeze=function(){return f(this,void 0,void 0,(function(){return _(this,(function(e){switch(e.label){case 0:return[4,t.prototype.freeze.call(this)];case 1:return e.sent(),B.of(this._iid).dispatcher.dispatch(new je({channels:[this],source:ze.EVENT_CHANNEL_HIDDEN})),[2]}}))}))},n.prototype.unfreeze=function(){return f(this,void 0,void 0,(function(){return _(this,(function(e){switch(e.label){case 0:return[4,t.prototype.unfreeze.call(this)];case 1:return e.sent(),B.of(this._iid).dispatcher.dispatch(new je({channels:[this],source:ze.EVENT_CHANNEL_UNHIDDEN})),[2]}}))}))},n.prototype.updateChannel=function(e){return f(this,void 0,void 0,(function(){var t,n,r,i,a,o,u;return _(this,(function(c){switch(c.label){case 0:return t=s(s({},Sr),e),Y(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(V.invalidParameters),n=B.of(this._iid),r=n.dispatcher,i=n.requestQueue,a=new Lr(s({channelUrl:this.url},t)),[4,i.send(a)];case 1:return o=c.sent(),u=o.as(kr).channel,r.dispatch(new je({channels:[u],source:ze.EVENT_CHANNEL_UPDATED})),[2,u]}}))}))},n.prototype.invite=function(e){return f(this,void 0,void 0,(function(){return _(this,(function(t){return Y(e.every((function(e){return e instanceof u}))).throw(V.invalidParameters),[2,this.inviteWithUserIds(e.map((function(e){return e.userId})))]}))}))},n.prototype.inviteWithUserIds=function(e){return f(this,void 0,void 0,(function(){var t,n,r,s,i,a;return _(this,(function(o){switch(o.label){case 0:return Y(v("string",e)).throw(V.invalidParameters),t=B.of(this._iid),n=t.dispatcher,r=t.requestQueue,s=new Ln({channelUrl:this.url,userIds:e}),[4,r.send(s)];case 1:return i=o.sent(),a=i.as(kn).channel,n.dispatch(new je({channels:[a],source:ze.EVENT_CHANNEL_INVITED})),[2,a]}}))}))},n.prototype.join=function(e){return void 0===e&&(e=null),f(this,void 0,void 0,(function(){var t,n,r,s,i,a,o;return _(this,(function(u){switch(u.label){case 0:return Y(g("string",e)||null===e).throw(V.invalidParameters),t=B.of(this._iid),n=t.dispatcher,r=t.sdkState,s=t.requestQueue,i=new Tn({channelUrl:this.url,userId:r.userId,accessCode:e}),[4,s.send(i)];case 1:return a=u.sent(),(o=a.as(In).channel).myMemberState=this.myMemberState=xt.JOINED,n.dispatch(new je({channels:[o],source:ze.EVENT_CHANNEL_JOINED})),[2,this]}}))}))},n.prototype.leave=function(e){return void 0===e&&(e=!1),f(this,void 0,void 0,(function(){var t,n,r,s;return _(this,(function(i){switch(i.label){case 0:return t=B.of(this._iid),n=t.sdkState,r=t.requestQueue,s=new wn({channelUrl:this.url,userId:n.userId,shouldRemoveOperatorStatus:e}),[4,r.send(s)];case 1:return i.sent(),this.myMemberState=xt.NONE,[2]}}))}))},n.prototype.acceptInvitation=function(e){return void 0===e&&(e=null),f(this,void 0,void 0,(function(){var t,n,r,s,i,a,o;return _(this,(function(u){switch(u.label){case 0:return Y(g("string",e)||null===e).throw(V.invalidParameters),t=B.of(this._iid),n=t.dispatcher,r=t.sdkState,s=t.requestQueue,i=new wr({channelUrl:this.url,userId:r.userId,accessCode:e}),[4,s.send(i)];case 1:return a=u.sent(),(o=a.as(Dr).channel).myMemberState=this.myMemberState=xt.JOINED,n.dispatch(new je({channels:[o],source:ze.EVENT_CHANNEL_ACCEPTED_INVITE})),[2,this]}}))}))},n.prototype.declineInvitation=function(){return f(this,void 0,void 0,(function(){var e,t,n,r;return _(this,(function(s){switch(s.label){case 0:return e=B.of(this._iid),t=e.sdkState,n=e.requestQueue,r=new xn({channelUrl:this.url,userId:t.userId}),[4,n.send(r)];case 1:return s.sent(),this.myMemberState=xt.NONE,[2,this]}}))}))},n.prototype.sendUserMessage=function(e){var n=this,r=new Dt,s=B.of(this._iid).dispatcher,i=nt.of(this._iid);return t.prototype.sendUserMessage.call(this,e).onPending((function(e){i.completeCurrentAndProcessNextAutoResend(e),r._trigger(null,e)})).onFailed((function(e,t){t&&i.completeCurrentAndProcessNextAutoResend(t),r._trigger(e,t)})).onSucceeded((function(e){n.hiddenState===ts.HIDDEN_ALLOW_AUTO_UNHIDE&&(n.hiddenState=ts.UNHIDDEN),i.completeCurrentAndProcessNextAutoResend(e),n._shouldUpdateLastMessageWith(e)&&(n.lastMessage=e),er.of(n._iid).handlers.map((function(e){return e.onChannelChanged(n)})),s.dispatch(new je({channels:[n],source:ze.EVENT_MESSAGE_SENT})),r._trigger(null,e)})),r},n.prototype.updateUserMessage=function(e,n){return f(this,void 0,void 0,(function(){var r,s,i,a,o=this;return _(this,(function(u){switch(u.label){case 0:return r=B.of(this._iid).dispatcher,[4,t.prototype.updateUserMessage.call(this,e,n)];case 1:return s=u.sent(),i=!1,!s.silent&&this._shouldUpdateLastMessageWith(s)&&(this.lastMessage=s,i=!0),a=!1,this.lastPinnedMessage&&this.lastPinnedMessage.messageId===s.messageId&&(this.lastPinnedMessage=s,i=!0,a=!0),i&&(er.of(this._iid).handlers.map((function(e){return e.onChannelChanged(o)})),r.dispatch(new je({channels:[this],source:a?ze.EVENT_PINNED_MESSAGE_UPDATED:ze.EVENT_MESSAGE_UPDATED}))),a&&er.of(this._iid).handlers.map((function(e){return e.onPinnedMessageUpdated(o)})),r.dispatch(new T({messages:[s],source:K.EVENT_MESSAGE_UPDATED})),[2,s]}}))}))},n.prototype._autoResendUserMessage=function(e){var n=this,r=new Dt,s=B.of(this._iid).dispatcher,i=nt.of(this._iid);return t.prototype._autoResendUserMessage.call(this,e).onPending((function(e){i.completeCurrentAndProcessNextAutoResend(e),r._trigger(null,e)})).onFailed((function(e,t){i.completeCurrentAndProcessNextAutoResend(t),r._trigger(e,t)})).onSucceeded((function(e){var t=er.of(n._iid);i.completeCurrentAndProcessNextAutoResend(e),n._shouldUpdateLastMessageWith(e)&&(n.lastMessage=e),t.handlers.map((function(e){return e.onChannelChanged(n)})),s.dispatch(new je({channels:[n],source:ze.EVENT_MESSAGE_SENT})),r._trigger(null,e)})),r},n.prototype.sendFileMessage=function(e){var n=this,r=new Dt,s=B.of(this._iid).dispatcher,i=nt.of(this._iid);return t.prototype.sendFileMessage.call(this,e).onPending((function(e){i.completeCurrentAndProcessNextAutoResend(e),r._trigger(null,e)})).onFailed((function(e,t){t&&i.completeCurrentAndProcessNextAutoResend(t),r._trigger(e,t)})).onSucceeded((function(e){var t=er.of(n._iid);i.completeCurrentAndProcessNextAutoResend(e),n._shouldUpdateLastMessageWith(e)&&(n.lastMessage=e),t.handlers.map((function(e){return e.onChannelChanged(n)})),s.dispatch(new je({channels:[n],source:ze.EVENT_MESSAGE_SENT})),r._trigger(null,e)})),r},n.prototype.updateFileMessage=function(e,n){return f(this,void 0,void 0,(function(){var r,s,i,a,o=this;return _(this,(function(u){switch(u.label){case 0:return r=B.of(this._iid).dispatcher,[4,t.prototype.updateFileMessage.call(this,e,n)];case 1:return s=u.sent(),i=!1,!s.silent&&this._shouldUpdateLastMessageWith(s)&&(this.lastMessage=s,i=!0),a=!1,this.lastPinnedMessage&&this.lastPinnedMessage.messageId===s.messageId&&(this.lastPinnedMessage=s,i=!0,a=!0),i&&(er.of(this._iid).handlers.map((function(e){return e.onChannelChanged(o)})),r.dispatch(new je({channels:[this],source:a?ze.EVENT_PINNED_MESSAGE_UPDATED:ze.EVENT_MESSAGE_UPDATED}))),a&&er.of(this._iid).handlers.map((function(e){return e.onPinnedMessageUpdated(o)})),r.dispatch(new T({messages:[s],source:K.EVENT_MESSAGE_UPDATED})),[2,s]}}))}))},n.prototype._autoResendFileMessage=function(e){var n=this,r=new Dt,s=B.of(this._iid).dispatcher,i=nt.of(this._iid);return t.prototype._autoResendFileMessage.call(this,e).onPending((function(e){i.completeCurrentAndProcessNextAutoResend(e),r._trigger(null,e)})).onFailed((function(e,t){i.completeCurrentAndProcessNextAutoResend(t),r._trigger(e,t)})).onSucceeded((function(e){var t=er.of(n._iid);i.completeCurrentAndProcessNextAutoResend(e),n._shouldUpdateLastMessageWith(e)&&(n.lastMessage=e),t.handlers.map((function(e){return e.onChannelChanged(n)})),s.dispatch(new je({channels:[n],source:ze.EVENT_MESSAGE_SENT})),r._trigger(null,e)})),r},n.prototype.deleteMessage=function(e){return f(this,void 0,void 0,(function(){return _(this,(function(n){switch(n.label){case 0:return[4,t.prototype.deleteMessage.call(this,e)];case 1:return n.sent(),0===e.messageId&&e instanceof Ct&&B.of(this._iid).dispatcher.dispatch(new S({reqId:e.reqId,source:K.EVENT_MESSAGE_DELETED})),[2]}}))}))},n.prototype.hide=function(e){return f(this,void 0,void 0,(function(){var t,n,r,i,a,o,u,c;return _(this,(function(l){switch(l.label){case 0:return t=s(s({},Ur),e),Y(function(e){return g("boolean",e.hidePreviousMessages)&&g("boolean",e.allowAutoUnhide)}(t)).throw(V.invalidParameters),n=B.of(this._iid),r=n.dispatcher,i=n.sdkState,a=n.requestQueue,o=new qn(s({channelUrl:this.url,userId:i.userId},t)),[4,a.send(o)];case 1:return u=l.sent(),c=u.as(Bn).messageOffsetTimestamp,this.hiddenState=t.allowAutoUnhide?ts.HIDDEN_ALLOW_AUTO_UNHIDE:ts.HIDDEN_PREVENT_AUTO_UNHIDE,t.hidePreviousMessages&&this._updateUnreadCount(0,0),c&&(this.messageOffsetTimestamp=c),r.dispatch(new je({channels:[this],source:ze.EVENT_CHANNEL_HIDDEN})),[2,this]}}))}))},n.prototype.unhide=function(){return f(this,void 0,void 0,(function(){var e,t,n,r;return _(this,(function(s){switch(s.label){case 0:return e=B.of(this._iid),t=e.dispatcher,n=e.requestQueue,r=new xr({channelUrl:this.url}),[4,n.send(r)];case 1:return s.sent(),this.hiddenState=ts.UNHIDDEN,t.dispatch(new je({channels:[this],source:ze.EVENT_CHANNEL_UNHIDDEN})),[2,this]}}))}))},n.prototype.delete=function(){return f(this,void 0,void 0,(function(){var e,t;return _(this,(function(n){switch(n.label){case 0:return e=B.of(this._iid).requestQueue,t=new Pr({channelUrl:this.url}),[4,e.send(t)];case 1:return n.sent(),[2]}}))}))},n.prototype.markAsRead=function(){return f(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=B.of(this._iid),t=e.sdkState,n=e.dispatcher,r=e.requestQueue,s=new Fn({channelUrl:this.url}),[4,r.send(s)];case 1:return i=u.sent(),a=i.as(On).readStatus,this._updateUnreadMemberState(t.userId,a.readAt),(this.unreadMessageCount>0||this.unreadMentionCount>0)&&(this._updateUnreadCount(0,0),er.of(this._iid).handlers.map((function(e){return e.onChannelChanged(o)}))),n.dispatch(new je({channels:[this],source:ze.EVENT_CHANNEL_READ})),[2]}}))}))},n.prototype.markAsDelivered=function(){return f(this,void 0,void 0,(function(){var e,t,n,r;return _(this,(function(s){switch(s.label){case 0:return e=B.of(this._iid),t=e.sdkState,n=e.requestQueue,r=new Hn({channelUrl:this.url,userId:t.userId}),[4,n.send(r)];case 1:return s.sent(),[2]}}))}))},n.prototype.startTyping=function(){return f(this,void 0,void 0,(function(){var e,t,n,r,s;return _(this,(function(i){return e=B.of(this._iid),t=e.requestQueue,n=e.typingIndicatorThrottle,(r=(new Date).getTime())-this._typingStarted>=n&&(this._typingStarted=r,this._typingEnded=0,s=new zn({channelUrl:this.url,time:this._typingStarted}),t.send(s)),[2]}))}))},n.prototype.endTyping=function(){return f(this,void 0,void 0,(function(){var e,t,n,r,s;return _(this,(function(i){return e=B.of(this._iid),t=e.requestQueue,n=e.typingIndicatorThrottle,(r=(new Date).getTime())-this._typingEnded>=n&&(this._typingStarted=0,this._typingEnded=r,s=new Wn({channelUrl:this.url,time:this._typingStarted}),t.send(s)),[2]}))}))},n.prototype.createScheduledUserMessage=function(e){e=s(s({},rt),e),Y(st(e)).throw(V.invalidParameters);var t=new Dt;return this._createScheduledUserMessage(e,t),t},n.prototype.updateScheduledUserMessage=function(e,t){return f(this,void 0,void 0,(function(){var n,r,i,a;return _(this,(function(o){switch(o.label){case 0:return n=s(s({},Vr),t),Y(function(e){return Re(e)&&g("number",e.scheduledAt,!0)}(n)).throw(V.invalidParameters),r=B.of(this._iid).requestQueue,i=new jr(s({reqId:this._generateRequestId(),scheduledMessageId:e,channelType:this.channelType,channelUrl:this.url},n)),[4,r.send(i)];case 1:return a=o.sent(),[2,a.as(Oe).message]}}))}))},n.prototype.createScheduledFileMessage=function(e){var t=this;e=s(s({},it),e),Y(at(e)).throw(V.invalidParameters);var n=Date.now(),r=this._generateRequestId(),i=new Dt;return pe(He).then((function(){var s=t._createPendingScheduledFileMessage(e,r,n);W((function(){return f(t,void 0,void 0,(function(){return _(this,(function(e){return[2,i._trigger(null,s)]}))}))}))})),y(e.file)?this._uploadFileAndUpdateParams(e).then((function(){return t._createScheduledFileMessage(e,i,r,n)})):this._createScheduledFileMessage(e,i,r,n),i},n.prototype.updateScheduledFileMessage=function(e,t){return f(this,void 0,void 0,(function(){var n,r,i;return _(this,(function(a){switch(a.label){case 0:return n=s(s({},Gr),t),Y(function(e){return Pe(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})))}(n)).throw(V.invalidParameters),y(n.file)?[4,this._uploadFileAndUpdateParams(n)]:[3,2];case 1:a.sent(),a.label=2;case 2:return r=new qr(s({reqId:this._generateRequestId(),scheduledMessageId:e,channelType:this.channelType,channelUrl:this.url},n)),[4,B.of(this._iid).requestQueue.send(r)];case 3:return i=a.sent(),[2,i.as(Br).message]}}))}))},n.prototype.cancelScheduledMessage=function(e){return f(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,B.of(this._iid).requestQueue.send(t)];case 1:return n.sent(),[2]}}))}))},n.prototype.sendScheduledMessageNow=function(e){return f(this,void 0,void 0,(function(){var t;return _(this,(function(n){switch(n.label){case 0:return t=new Qr({scheduledMessageId:e,channelType:this.channelType,channelUrl:this.url}),[4,B.of(this._iid).requestQueue.send(t)];case 1:return n.sent(),[2]}}))}))},n.prototype.getMyPushTriggerOption=function(){return f(this,void 0,void 0,(function(){var e,t,n,r,s,i;return _(this,(function(a){switch(a.label){case 0:return e=B.of(this._iid),t=e.sdkState,n=e.requestQueue,r=new Yr({userId:t.userId,channelUrl:this.url}),[4,n.send(r)];case 1:return s=a.sent(),i=s.as(Jr).pushTriggerOption,this.myPushTriggerOption=i,[2,i]}}))}))},n.prototype.setMyPushTriggerOption=function(e){return f(this,void 0,void 0,(function(){var t,n,r,s,a,o,u;return _(this,(function(c){switch(c.label){case 0:return Y(i(fe,e)).throw(V.invalidParameters),t=B.of(this._iid),n=t.dispatcher,r=t.sdkState,s=t.requestQueue,a=new Wr({userId:r.userId,channelUrl:this.url,pushTriggerOption:e}),[4,s.send(a)];case 1:return o=c.sent(),u=o.as(Kr).pushTriggerOption,this.myPushTriggerOption=u,n.dispatch(new je({channels:[this],source:ze.EVENT_CHANNEL_UPDATED})),[2,u]}}))}))},n.prototype.setMyCountPreference=function(e){return f(this,void 0,void 0,(function(){var t,n,r,s,a,o,u;return _(this,(function(c){switch(c.label){case 0:return Y(i($r,e)).throw(V.invalidParameters),t=B.of(this._iid),n=t.dispatcher,r=t.sdkState,s=t.requestQueue,a=new Rr({channelUrl:this.url,userId:r.userId,countPreference:e}),[4,s.send(a)];case 1:return o=c.sent(),u=o.as(Fr).countPreference,this.myCountPreference=u,this._updateUnreadCount(this.unreadMessageCount,this.unreadMentionCount),n.dispatch(new je({channels:[this],source:ze.EVENT_CHANNEL_UPDATED})),[2,u]}}))}))},n.prototype.resetMyHistory=function(){return f(this,void 0,void 0,(function(){var e,t,n,r,s,i;return _(this,(function(a){switch(a.label){case 0:return e=B.of(this._iid),t=e.dispatcher,n=e.requestQueue,r=new Or({channelUrl:this.url}),[4,n.send(r)];case 1:return s=a.sent(),i=s.as(Hr).messageOffsetTimestamp,this.messageOffsetTimestamp=i,t.dispatch(new je({channels:[this],source:ze.EVENT_CHANNEL_RESET_HISTORY})),[2,this]}}))}))},n.prototype.pinMessage=function(e){return f(this,void 0,void 0,(function(){var t,n;return _(this,(function(r){switch(r.label){case 0:return Y(g("number",e)&&e>0).throw(V.invalidParameters),t=B.of(this._iid).requestQueue,n=new Xr({channelType:this.channelType,channelUrl:this.url,messageId:e}),[4,t.send(n)];case 1:return r.sent(),[2]}}))}))},n.prototype.unpinMessage=function(e){return f(this,void 0,void 0,(function(){var t,n;return _(this,(function(r){switch(r.label){case 0:return Y(g("number",e)&&e>0).throw(V.invalidParameters),t=B.of(this._iid).requestQueue,n=new Zr({channelType:this.channelType,channelUrl:this.url,messageId:e}),[4,t.send(n)];case 1:return r.sent(),[2]}}))}))},n.prototype._uploadFileAndUpdateParams=function(e){return f(this,void 0,void 0,(function(){var t,n,r,s,i,a,o,u,c,l,h;return _(this,(function(d){switch(d.label){case 0:return y(e.file)?(t=B.of(this._iid).requestQueue,n=new kt({file:e.file,channelUrl:this.url,thumbnailSizes:e.thumbnailSizes,requestId:this._generateRequestId()}),[4,t.send(n)]):[3,2];case 1:r=d.sent(),s=r.as(Lt),i=s.url,a=s.fileSize,o=void 0===a?e.fileSize:a,u=s.thumbnailSizes,c=void 0===u?e.thumbnailSizes:u,l=s.requireAuth,h=void 0!==l&&l,e.fileUrl=i,e.fileSize=o,e.thumbnailSizes=c,e.requireAuth=h,d.label=2;case 2:return[2]}}))}))},n}(Fe),us={},cs=function(){function e(e){var t=e._iid,n=e.limit,r=void 0===n?100:n,s=this;this._sync=null,this._connectionEventContext=null,this.ref=0,this._metadata=null,this._iid=t,this._limit=r;var i,a=B.of(this._iid),o=a.sdkState,u=a.dispatcher,c=a.logger;this._metadataKey=(i=o.userId,"sendbird:".concat(i,"@groupchannel/sync.meta"));var l=function(e){return"sendbird:".concat(e,"@groupchannel/sync")}(o.userId);this._sync=new nr(l,(function(){return f(s,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:""},[4,this.loadMetadata()];case 1:if(a.sent(),c.debug("channel background sync from",this._metadata.token),this._metadata.completed)return[3,9];a.label=2;case 2:return a.trys.push([2,5,,8]),[4,er.of(this._iid).getMyGroupChannels(this._metadata.token,{includeEmpty:!0,order:Ge.CHRONOLOGICAL},this._limit,ze.SYNC_CHANNEL_BACKGROUND)];case 3:return t=a.sent(),n=t.channels,r=t.token,e.hasNext=n.length>=this._limit&&!!r,e.nextToken=r,this._metadata.token=r,(i=this._metadata.range).extends.apply(i,h([],d(n.map((function(e){return e.createdAt}))),!1)),this._metadata.completed=!e.hasNext,c.debug("channel background sync progress",e),[4,this.saveMetadata()];case 4:return a.sent(),[3,8];case 5:return s=a.sent(),c.debug("channel background sync error",s),s instanceof V&&s.isInvalidTokenError?[4,this.clearMetaData()]:[3,7];case 6:a.sent(),a.label=7;case 7:throw s;case 8:return[3,10];case 9:e.hasNext=!1,e.nextToken="",a.label=10;case 10:return[2,e]}}))}))})),this._connectionEventContext=u.on((function(e){if(e instanceof $)if(e.stateType===ee.CONNECTED)s.resume();else s.pause()}))}return e.of=function(t){return us[t]||(us[t]=new e({_iid:t})),us[t].ref++,us[t]},e.clear=function(e){us[e]&&(us[e].close(),delete us[e])},Object.defineProperty(e.prototype,"range",{get:function(){var e;return null===(e=this._metadata)||void 0===e?void 0:e.range},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"completed",{get:function(){var e;return!!(null===(e=this._metadata)||void 0===e?void 0:e.completed)},enumerable:!1,configurable:!0}),e.prototype.loadMetadata=function(){return f(this,void 0,void 0,(function(){var e;return _(this,(function(t){switch(t.label){case 0:return this._metadata?[3,2]:[4,B.of(this._iid).cacheContext.preference.get(this._metadataKey)];case 1:e=t.sent(),this._metadata={token:e?e.token:"",range:new Xn(e?e.range:{top:Number.MAX_SAFE_INTEGER,bottom:0}),completed:!!e&&e.completed},t.label=2;case 2:return[2,this._metadata]}}))}))},e.prototype.saveMetadata=function(){return f(this,void 0,void 0,(function(){return _(this,(function(e){switch(e.label){case 0:return this._metadata?[4,B.of(this._iid).cacheContext.preference.set(this._metadataKey,this._metadata)]:[3,2];case 1:return e.sent(),[2,!0];case 2:return[2,!1]}}))}))},e.prototype.clearMetaData=function(){return f(this,void 0,void 0,(function(){return _(this,(function(e){switch(e.label){case 0:return[4,B.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=B.of(this._iid),r=n.logger;n.connectionManager.isConnected&&(r.debug("channel background sync resume()"),this._sync.start(null!==(t=null===(e=this._metadata)||void 0===e?void 0:e.token)&&void 0!==t?t:""))},e.prototype.pause=function(){B.of(this._iid).logger.debug("channel background sync stop()"),this._sync.stop()},e.prototype.close=function(){this.ref--,this.ref<=0&&(this.ref=0,this.pause(),this._connectionEventContext.close(),delete us[this._iid])},e}(),ls={},hs=function(){function e(e){var t=e._iid,n=this;this._sync=null,this._connectionEventContext=null,this.ref=0,this._metadataKey=null,this._metadata=null,this._iid=t;var r,s=B.of(this._iid),i=s.logger,a=s.sdkState,o=s.dispatcher;this._metadataKey=(r=a.userId,"sendbird:".concat(r,"@groupchannel/changelogs.meta"));var u=function(e){return"sendbird:".concat(e,"@groupchannel/changelogs")}(a.userId);this._sync=new nr(u,(function(){return f(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,er.of(this._iid).getMyGroupChannelChangeLogs(this._metadata.token,{includeEmpty:!0},ze.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 V&&s.isInvalidTokenError?[4,this.clearMetadata()]:[3,7];case 6:a.sent(),a.label=7;case 7:throw s;case 8:return[2,e]}}))}))})),this._connectionEventContext=o.on((function(e){if(e instanceof $)if(e.stateType===ee.CONNECTED)n.resume();else n.pause()}))}return e.of=function(t){return ls[t]||(ls[t]=new e({_iid:t})),ls[t].ref++,ls[t]},e.clear=function(e){ls[e]&&(ls[e].close(),delete ls[e])},e.prototype.loadMetadata=function(){return f(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=B.of(this._iid),t=e.cacheContext,n=e.firstConnectedAt,[4,t.preference.get(this._metadataKey)]);case 1:r=s.sent(),this._metadata={token:r?r.token:n},s.label=2;case 2:return[2,this._metadata]}}))}))},e.prototype.saveMetadata=function(){return f(this,void 0,void 0,(function(){return _(this,(function(e){switch(e.label){case 0:return this._metadata?[4,B.of(this._iid).cacheContext.preference.set(this._metadataKey,this._metadata)]:[3,2];case 1:return e.sent(),[2,!0];case 2:return[2,!1]}}))}))},e.prototype.clearMetadata=function(){return f(this,void 0,void 0,(function(){return _(this,(function(e){switch(e.label){case 0:return[4,B.of(this._iid).cacheContext.preference.remove(this._metadataKey)];case 1:return e.sent(),this._metadata=null,[2]}}))}))},e.prototype.resume=function(){B.of(this._iid).connectionManager.isConnected&&this._sync.start(0)},e.prototype.pause=function(){this._sync.stop()},e.prototype.close=function(){this.ref--,this.ref<=0&&(this.ref=0,this.pause(),this._connectionEventContext.close(),delete ls[this._iid])},e}(),ds=function(){function e(e,t){var n=t.filter,r=t.order,s=t.limit,i=this;this.channels=[],this._backgroundSync=null,this._changelogSync=null,this._iid=e,this._key="gcc-".concat(oe()),this._isDisposed=!1,this.filter=null!=n?n:new Wt,this.order=null!=r?r:Ge.LATEST_LAST_MESSAGE,this._hasMore=!0,this._token="",this._limit=null!=s?s:ye;var a=B.of(this._iid),o=a.sdkState,u=a.cacheContext,c=a.dispatcher;u.localCacheEnabled&&(this._backgroundSync=cs.of(e),this._backgroundSync.resume()),this._changelogSync=hs.of(e),this._changelogSync.resume(),er.of(this._iid).subscribeGroupChannelEvent(this._key,{onUpdate:function(e,t){if(tt(t)){var n=e.filter((function(e){return i.filter.match(e,o.userId)})),r=e.filter((function(e){return!i.filter.match(e,o.userId)})).map((function(e){return e.url}));n.length>0&&i._addChannelsToView(n,t),r.length>0&&i._removeChannelsFromView(r,t)}},onRemove:function(e,t){i._removeChannelsFromView(e,t)}}),B.of(this._iid).statLogCollector.put(new se({type:ie.FEATURE_LOCALCACHE,data:{use_local_cache:u.localCacheEnabled,collection_interface:{group_channel:!0}}})),c.on((function(e){e instanceof $&&e.stateType===ee.LOGOUT&&i.dispose()}))}return Object.defineProperty(e.prototype,"hasMore",{get:function(){return!this._isDisposed&&this._hasMore},enumerable:!1,configurable:!0}),e.prototype.setGroupChannelCollectionHandler=function(e){this._handler=e},e.prototype._addChannelsToView=function(e,t,n){var r,s,i,a,o=this;void 0===n&&(n=!1);var u=[],c=[],l=[];try{for(var h=m(e),d=h.next();!d.done;d=h.next()){var p=d.value,v=fr(this.channels,p,this.order),g=v.place,y=v.oldPosition;if(-1===y)g===this.channels.length?!n&&this._hasMore||(u.push(p),this.channels.push(p)):(u.push(p),this.channels.splice(g,0,p));else switch(t){case ze.EVENT_CHANNEL_UPDATED:case ze.EVENT_MESSAGE_RECEIVED:case ze.SYNC_CHANNEL_CHANGELOGS:case ze.EVENT_MESSAGE_SENT:g!==y?this._hasMore&&g===this.channels.length?l.push(p):(this.channels.splice(y,1),this.channels.splice(y0)try{for(var C=m(l),E=C.next();!E.done;E=C.next()){p=E.value;var b=pr(this.channels,p);-1!==b&&this.channels.splice(b,1)}}catch(e){i={error:e}}finally{try{E&&!E.done&&(a=C.return)&&a.call(C)}finally{if(i)throw i.error}}tt(t)&&W((function(){return f(o,void 0,void 0,(function(){var e,n,r,s;return _(this,(function(i){return e=new rr(t),u.length>0&&(null===(n=this._handler)||void 0===n?void 0:n.onChannelsAdded)&&this._handler.onChannelsAdded(e,u),c.length>0&&(null===(r=this._handler)||void 0===r?void 0:r.onChannelsUpdated)&&this._handler.onChannelsUpdated(e,c),l.length>0&&(null===(s=this._handler)||void 0===s?void 0:s.onChannelsDeleted)&&this._handler.onChannelsDeleted(e,l.map((function(e){return e.url}))),[2]}))}))}))},e.prototype._removeChannelsFromView=function(e,t){var n,r,s=this,i=[],a=function(e){var t=o.channels.findIndex((function(t){return t.url===e}));t>=0&&(i.push(o.channels[t].url),o.channels.splice(t,1))},o=this;try{for(var u=m(e),c=u.next();!c.done;c=u.next()){a(c.value)}}catch(e){n={error:e}}finally{try{c&&!c.done&&(r=u.return)&&r.call(u)}finally{if(n)throw n.error}}return tt(t)&&i.length>0&&W((function(){return f(s,void 0,void 0,(function(){var e,n;return _(this,(function(r){return e=new rr(t),(null===(n=this._handler)||void 0===n?void 0:n.onChannelsDeleted)&&this._handler.onChannelsDeleted(e,i),[2]}))}))})),i},e.prototype._getLocalChannels=function(){return f(this,void 0,void 0,(function(){var e,t;return _(this,(function(n){switch(n.label){case 0:return e=er.of(this._iid),t=this.channels.length>0?function(e,t){var n,r;switch(t){case Ge.LATEST_LAST_MESSAGE:return null!==(r=null===(n=e.lastMessage)||void 0===n?void 0:n.createdAt)&&void 0!==r?r:e.createdAt;case Ge.CHRONOLOGICAL:return e.createdAt;case Ge.CHANNEL_NAME_ALPHABETICAL:return e.name}return null}(this.channels[this.channels.length-1],this.order):null,[4,e.getChannelsFromCache(t,this.filter,this.order,this._limit,t?this.channels[this.channels.length-1].url:null)];case 1:return[2,n.sent()]}}))}))},e.prototype._getRemoteChannels=function(){return f(this,void 0,void 0,(function(){var e,t,n;return _(this,(function(r){switch(r.label){case 0:return[4,er.of(this._iid).getMyGroupChannels(this._token,s(s({},this.filter),{order:this.order}),this._limit)];case 1:return e=r.sent(),t=e.channels,n=e.token,this._token=n,this._hasMore=!!n,[2,t]}}))}))},e.prototype.loadMore=function(){return f(this,void 0,void 0,(function(){var e,t,n=this;return _(this,(function(r){switch(r.label){case 0:if(this._isDisposed)throw new V({code:J.COLLECTION_DISPOSED,message:"Collection has been disposed."});return this._hasMore?(e=B.of(this._iid).cacheContext,t=[],e.localCacheEnabled&&this._backgroundSync.completed?[3,2]:[4,E((function(){return f(n,void 0,void 0,(function(){return _(this,(function(e){switch(e.label){case 0:return[4,this._getRemoteChannels()];case 1:return t=e.sent(),[2]}}))}))}))]):[3,5];case 1:r.sent(),r.label=2;case 2:return e.localCacheEnabled&&0===t.length?[4,E((function(){return f(n,void 0,void 0,(function(){return _(this,(function(e){switch(e.label){case 0:return[4,this._getLocalChannels()];case 1:return t=e.sent(),[2]}}))}))}))]:[3,4];case 3:r.sent(),this._backgroundSync.completed&&(this._hasMore=t.length>=this._limit),r.label=4;case 4:return this._addChannelsToView(t,ze.REQUEST_CHANNEL,!0),[2,t];case 5:return[2,[]]}}))}))},e.prototype.dispose=function(){var e,t;this._isDisposed||(this._isDisposed=!0,this.channels.length>0&&this.channels.splice(0,this.channels.length),null===(e=this._backgroundSync)||void 0===e||e.close(),null===(t=this._changelogSync)||void 0===t||t.close(),er.of(this._iid).unsubscribeGroupChannelEvent(this._key))},e}(),ps=function(t){function n(e){var n=this,s=e.token,i=e.limit,a=e.order,o=e.includeEmpty,u=e.membershipFilter,c=e.channelNameContainsFilter,l=e.channelUrlsFilter,h=e.customTypesFilter,d=e.customTypeStartsWithFilter,p=e.superChannelFilter,f=e.metadataOrderKeyFilter,_=e.metadataKey,m=e.metadataValues,v=e.metadataValueStartsWith,g=e.includeFrozen,y=e.includeMetaData;return(n=t.call(this)||this).method=I.GET,n.path=k,n.params=r({token:s,limit:i,order:a,show_member:!0,show_read_receipt:!0,show_delivery_receipt:!0,show_empty:o,public_mode:Rt.PUBLIC,public_membership_mode:u,name_contains:c,channel_urls:l,custom_types:h,custom_type_startswith:d,super_mode:p,metadata_order_key:f,metadata_key:_,metadata_values:m,metadata_value_startswith:v,show_frozen:g,show_metadata:y}),n}return e(n,t),n}(w),fs=function(t){function n(e,n){var r=t.call(this,e,n)||this;r.token=null,r.channels=[],r.ts=null;var s=n.next,i=n.channels,a=n.ts;return r.token=s,i&&i.length>0&&(r.channels=i.map((function(t){return t.ts=a,new os(e,t)}))),r.ts="number"==typeof a?a:null,r}return e(n,t),n}(D);!function(e){e.ALL="all",e.JOINED="joined"}(as||(as={}));var _s=function(t){function n(e,n){var r,s,i,a,o,u,c,l,h,d,p,f,_,m,v=this;return(v=t.call(this,e,n)||this).includeEmpty=!1,v.includeFrozen=!0,v.includeMetaData=!0,v.channelUrlsFilter=null,v.customTypesFilter=null,v.customTypeStartsWithFilter=null,v.channelNameContainsFilter=null,v.membershipFilter=as.ALL,v.superChannelFilter=Ot.ALL,v.metadataKey=null,v.metadataValues=null,v.metadataOrderKeyFilter=null,v.metadataValueStartsWith=null,v.order=ot.CHRONOLOGICAL,v.includeEmpty=null!==(r=n.includeEmpty)&&void 0!==r&&r,v.includeFrozen=null===(s=n.includeFrozen)||void 0===s||s,v.includeMetaData=null===(i=n.includeMetaData)||void 0===i||i,v.channelUrlsFilter=null!==(a=n.channelUrlsFilter)&&void 0!==a?a:null,v.customTypesFilter=null!==(o=n.customTypesFilter)&&void 0!==o?o:null,v.customTypeStartsWithFilter=null!==(u=n.customTypeStartsWithFilter)&&void 0!==u?u:null,v.channelNameContainsFilter=null!==(c=n.channelNameContainsFilter)&&void 0!==c?c:null,v.membershipFilter=null!==(l=n.membershipFilter)&&void 0!==l?l:as.ALL,v.superChannelFilter=null!==(h=n.superChannelFilter)&&void 0!==h?h:Ot.ALL,v.metadataKey=null!==(d=n.metadataKey)&&void 0!==d?d:null,v.metadataValues=null!==(p=n.metadataValues)&&void 0!==p?p:null,v.metadataOrderKeyFilter=null!==(f=n.metadataOrderKeyFilter)&&void 0!==f?f:null,v.metadataValueStartsWith=null!==(_=n.metadataValueStartsWith)&&void 0!==_?_:null,v.order=null!==(m=n.order)&&void 0!==m?m:ot.CHRONOLOGICAL,v}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,!0)&&v("string",this.channelUrlsFilter,!0)&&v("string",this.customTypesFilter,!0)&&g("string",this.customTypeStartsWithFilter,!0)&&i(as,this.membershipFilter)&&i(Ot,this.superChannelFilter)&&i(ot,this.order)&&g("string",this.metadataOrderKeyFilter,!0)&&g("string",this.metadataKey,!0)&&v("string",this.metadataValues,!0)&&g("string",this.metadataValueStartsWith,!0)},n.prototype.next=function(){return f(this,void 0,void 0,(function(){var e,t,n,r,i,a,o,u,c;return _(this,(function(l){switch(l.label){case 0:return this._validate()?this._isLoading?[3,3]:(e=[],this._hasNext?(this._isLoading=!0,t=B.of(this._iid),n=t.requestQueue,r=t.dispatcher,i=new ps(s(s({},this),{token:this._token})),[4,n.send(i)]):[3,2]):[3,5];case 1:return a=l.sent(),o=a.as(fs),u=o.channels,c=o.token,this._token=c,this._hasNext=!!c,r.dispatch(new je({channels:u,source:ze.REQUEST_CHANNEL})),this._isLoading=!1,[2,u];case 2:return[2,e];case 3:throw V.queryInProgress;case 4:return[3,6];case 5:throw V.invalidParameters;case 6:return[2]}}))}))},n}(H),ms=function(t){function n(e){void 0===e&&(e={});var n=t.call(this)||this;return Object.keys(e).forEach((function(t){n.hasOwnProperty(t)&&(n[t]=e[t])})),n}return e(n,t),n}(function(t){function n(){var e=null!==t&&t.apply(this,arguments)||this;return e.onUserJoined=_e,e.onUserLeft=_e,e.onUserReceivedInvitation=_e,e.onUserDeclinedInvitation=_e,e.onChannelHidden=_e,e.onUnreadMemberStatusUpdated=_e,e.onUndeliveredMemberStatusUpdated=_e,e.onTypingStatusUpdated=_e,e.onPollUpdated=_e,e.onPollVoted=_e,e.onPollDeleted=_e,e.onPinnedMessageUpdated=_e,e}return e(n,t),n}(gt)),vs=function(t){function n(e){var n=this,s=e.token,i=e.limit,a=e.order,o=e.reverse,u=e.channelUrl,c=e.messageTypeFilter,l=e.scheduledStatus;return(n=t.call(this)||this).method=I.GET,n.path="".concat(x),n.params=r({limit:i,reverse:o,channel_url:u,order:a,status:l}),s&&(n.params.token=s),c&&(n.params.message_type=c),n}return e(n,t),n}(w),gs=function(t){function n(e,n){var r=t.call(this,e,n)||this;r.token=null,r.scheduledMessages=[];var s=n.next,i=n.scheduled_messages;return r.token=s,r.scheduledMessages=i.map((function(t){return bt(e,t)})),r}return e(n,t),n}(D),ys=function(t){function n(e,n){var r,s,i,a,o,u=this;return(u=t.call(this,e,n)||this).channelUrl=null,u.order=null,u.reverse=!1,u.scheduledStatus=null,u.messageTypeFilter=C.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:C.ALL,u}return e(n,t),n.prototype._validate=function(){return t.prototype._validate.call(this)&&g("string",this.channelUrl,!0)&&(i(ut,this.order)||null===this.order)&&g("boolean",this.reverse)&&(v(yt,this.scheduledStatus)||null===this.scheduledStatus)&&i(C,this.messageTypeFilter)},n.prototype.next=function(){return f(this,void 0,void 0,(function(){var e,t,n,r,i,a;return _(this,(function(o){switch(o.label){case 0:return this._validate()?this._isLoading?[3,3]:this._hasNext?(this._isLoading=!0,e=B.of(this._iid).requestQueue,t=new vs(s(s({},this),{token:this._token})),[4,e.send(t)]):[3,2]:[3,5];case 1:return n=o.sent(),r=n.as(gs),i=r.scheduledMessages,a=r.token,this._token=a,this._hasNext=!!a,this._isLoading=!1,[2,i];case 2:return[2,[]];case 3:throw V.queryInProgress;case 4:return[3,6];case 5:throw V.invalidParameters;case 6:return[2]}}))}))},n}(H),Cs=function(t){function n(){var e=null!==t&&t.apply(this,arguments)||this;return e.name="groupChannel",e}return e(n,t),n.prototype.init=function(e,n){var r=n.sdkState,s=n.dispatcher,i=n.sessionManager,a=n.requestQueue,o=n.logger,u=n.onlineDetector,c=n.cacheContext;t.prototype.init.call(this,e,{sdkState:r,dispatcher:s,sessionManager:i,requestQueue:a,logger:o,onlineDetector:u,cacheContext:c}),this._manager=new er(e,{sdkState:r,cacheContext:c,dispatcher:s,sessionManager:i,requestQueue:a,logger:o})},n.prototype.createGroupChannelCollection=function(e){return void 0===e&&(e={}),new ds(this._iid,e)},n.prototype.createMyGroupChannelListQuery=function(e){return void 0===e&&(e={}),new Jn(this._iid,e)},n.prototype.createPublicGroupChannelListQuery=function(e){return void 0===e&&(e={}),new _s(this._iid,e)},n.prototype.createScheduledMessageListQuery=function(e){return void 0===e&&(e={}),new ys(this._iid,e)},n.prototype.addGroupChannelHandler=function(e,t){Y(g("string",e)&&t instanceof ms).throw(V.invalidParameters),this._manager.addHandler(e,t)},n.prototype.removeGroupChannelHandler=function(e){Y(g("string",e)).throw(V.invalidParameters),this._manager.removeHandler(e)},n.prototype.removeAllGroupChannelHandlers=function(){this._manager.clearHandler()},n.prototype.buildGroupChannelFromSerializedData=function(e){return this._manager.buildGroupChannelFromSerializedData(e)},n.prototype.buildGroupChannelListQueryFromSerializedData=function(e){return this._manager.buildGroupChannelListQueryFromSerializedData(e)},n.prototype.buildMemberFromSerializedData=function(e){return this._manager.buildMemberFromSerializedData(e)},n.prototype.getChannel=function(e){return f(this,void 0,void 0,(function(){return _(this,(function(t){return Y(g("string",e)).throw(V.invalidParameters),[2,this._manager.getChannel(e)]}))}))},n.prototype.getChannelWithoutCache=function(e){return f(this,void 0,void 0,(function(){return _(this,(function(t){return Y(g("string",e)).throw(V.invalidParameters),[2,this._manager.getChannelWithoutCache(e)]}))}))},n.prototype.getMyGroupChannelChangeLogsByToken=function(e,t){return void 0===t&&(t={}),f(this,void 0,void 0,(function(){var n;return _(this,(function(r){switch(r.label){case 0:return n=s(s({},Xt),t),Y(g("string",e)&&Zt(n)).throw(V.invalidParameters),[4,this._manager.getMyGroupChannelChangeLogs(e,n)];case 1:return[2,r.sent()]}}))}))},n.prototype.getMyGroupChannelChangeLogsByTimestamp=function(e,t){return void 0===t&&(t={}),f(this,void 0,void 0,(function(){var n;return _(this,(function(r){switch(r.label){case 0:return n=s(s({},Xt),t),Y(g("number",e)&&Zt(n)).throw(V.invalidParameters),[4,this._manager.getMyGroupChannelChangeLogs(e,n)];case 1:return[2,r.sent()]}}))}))},n.prototype.getGroupChannelCount=function(e){return f(this,void 0,void 0,(function(){var t;return _(this,(function(n){return t=s(s({},$t),e),Y(en(t)).throw(V.invalidParameters),[2,this._manager.getGroupChannelCount(t)]}))}))},n.prototype.getUnreadItemCount=function(e){return void 0===e&&(e={}),f(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()]}}))}))},n.prototype.getTotalUnreadChannelCount=function(){return f(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()]}}))}))},n.prototype.getTotalUnreadMessageCount=function(e){return void 0===e&&(e={}),f(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()]}}))}))},n.prototype.getTotalScheduledMessageCount=function(e){return void 0===e&&(e={}),f(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()]}}))}))},n.prototype.getSubscribedTotalUnreadMessageCount=function(){return this._manager.getSubscribedTotalUnreadMessageCount()},n.prototype.getSubscribedCustomTypeTotalUnreadMessageCount=function(){return this._manager.getSubscribedCustomTypeTotalUnreadMessageCount()},n.prototype.getSubscribedCustomTypeUnreadMessageCount=function(e){return this._manager.getSubscribedCustomTypeUnreadMessageCount(e)},n.prototype.createChannel=function(e){return void 0===e&&(e={}),f(this,void 0,void 0,(function(){var t;return _(this,(function(n){return t=s(s({},Yt),e),Y(Jt(t)).throw(V.invalidParameters),[2,this._manager.createChannel(t)]}))}))},n.prototype.createDistinctChannelIfNotExist=function(e){return void 0===e&&(e={}),f(this,void 0,void 0,(function(){var t;return _(this,(function(n){return t=s(s({},Yt),e),Y(Jt(t)).throw(V.invalidParameters),t&&(t.isDistinct=!0),[2,this.createChannel(t)]}))}))},n.prototype.createChannelWithUserIds=function(e,t,n,r,i,a){return void 0===t&&(t=!1),void 0===n&&(n=null),void 0===r&&(r=null),void 0===i&&(i=""),void 0===a&&(a=""),f(this,void 0,void 0,(function(){var o;return _(this,(function(u){return o=s(s({},Yt),{invitedUserIds:e,isDistinct:t,name:n,data:i,customType:a}),"string"==typeof r?o.coverUrl=r:o.coverImage=r,[2,this.createChannel(o)]}))}))},n.prototype.markAsReadAll=function(){return f(this,void 0,void 0,(function(){return _(this,(function(e){return this._manager.markAsReadAll(),[2]}))}))},n.prototype.markAsReadWithChannelUrls=function(e){return f(this,void 0,void 0,(function(){return _(this,(function(t){return Y(v("string",e)).throw(V.invalidParameters),this._manager.markAsReadWithChannelUrls(e),[2]}))}))},n.prototype.markAsDelivered=function(e){return f(this,void 0,void 0,(function(){return _(this,(function(t){switch(t.label){case 0:return Y(g("string",e)).throw(V.invalidParameters),[4,this.getChannel(e)];case 1:return[4,t.sent().markAsDelivered()];case 2:return t.sent(),[2]}}))}))},n}(me);export{$r as CountPreference,os as GroupChannel,ds as GroupChannelCollection,rr as GroupChannelEventContext,Wt as GroupChannelFilter,ms as GroupChannelHandler,Jn as GroupChannelListQuery,Cs as GroupChannelModule,Bt as GroupChannelSearchField,Gt as HiddenChannelFilter,ts as HiddenState,jt as Member,Er as MemberListOrder,Ar as MemberListQuery,xt as MemberState,br as MemberStateFilter,as as MembershipFilter,Nr as MessageCollection,Mr as MessageCollectionInitHandler,tr as MessageCollectionInitPolicy,sr as MessageEventContext,Cr as MutedMemberFilter,es as MutedState,Ft as MyMemberStateFilter,Vt as OperatorFilter,ns as PinnedMessage,is as PinnedMessageListQuery,Rt as PublicChannelFilter,_s as PublicGroupChannelListQuery,qt as QueryType,zt as ReadStatus,ys as ScheduledMessageListQuery,Ot as SuperChannelFilter,Ht as UnreadChannelFilter,Qt as UnreadItemKey}; +import{_ as e,e as r,g as s,I as i,R as a,M as o,U as u,X as c,aA as l,p as h,q as d,b as f,c as _,H as m,l as v,a as g,i as y,a3 as C,G as E,az as b,aB as M,at as N,aC as S,ag as U,af as T,A as I,d as A,f as w,h as D,aD as L,ad as k,aE as x,a6 as R,W as F,$ as O,B as H,S as V,s as q,V as B,N as z,ay as Q,x as W,ae as K,r as Y,a9 as J,aF as X,E as Z,t as $,w as ee,ac as te,a7 as ne,aG as re,aH as se,aI as ie,u as oe,a1 as ue,aJ as ce,ai as le,a0 as he,ax as de,aa as pe,J as fe,n as _e,aj as me}from"./__bundle-ea43c8a8.js";export{ae as MessageEventSource}from"./__bundle-ea43c8a8.js";import{g as ve,N as ge,o as ye,p as Ce,q as Ee,r as be,t as Me,u as Ne,w as Se,x as Ue,P as Te,y as Ie,z as Ae,A as we,C as De,D as Le,E as ke,G as Pe,H as xe,I as Re,f as Fe,J as Oe,K as He}from"./__bundle-3b517302.js";import{G as Ge,g as Ve,D as qe,l as Be,m as je,n as ze,j as Qe,i as We,o as Ke,R as Ye,p as Je,k as Xe,U as Ze,e as $e,f as et,s as tt,d as nt,S as rt,v as st,q as it,r as at,P as ot,t as ut}from"./__bundle-da2eac9e.js";export{n as GroupChannelEventSource,G as GroupChannelListOrder,p as MessageFilter,P as PublicGroupChannelListOrder,t as ScheduledMessageListOrder}from"./__bundle-da2eac9e.js";import{C as ct,a as lt,O as ht,P as dt,M as pt,T as ft,R as _t,U as mt,A as vt,B as gt}from"./__bundle-e9aa026e.js";import{j as yt,S as Ct,I as Et,p as bt,U as Mt,F as Nt,k as St,b as Ut,T as Tt,c as It,A as At,l as wt,f as Dt,m as Lt,n as kt}from"./__bundle-12fe2d56.js";export{j as ScheduledStatus}from"./__bundle-12fe2d56.js";import{b as Pt}from"./__bundle-9a0f0a93.js";var xt;!function(e){e.NONE="none",e.JOINED="joined",e.INVITED="invited",e.LEFT="left"}(xt||(xt={}));var Rt,Ft,Ot,Ht,Gt,Vt,qt,Bt,jt=function(t){function n(e,n){var r=t.call(this,e,n)||this;return r.state=null,r.role=null,r.isMuted=!1,r.isBlockedByMe=!1,r.isBlockingMe=!1,r.state=i(xt,n.state)?n.state:null,r.role=i(a,n.role)?n.role:null,n.hasOwnProperty("is_muted")&&(r.isMuted=n.is_muted),n.hasOwnProperty("is_blocked_by_me")&&(r.isBlockedByMe=n.is_blocked_by_me),n.hasOwnProperty("is_blocking_me")&&(r.isBlockingMe=n.is_blocking_me),r}return e(n,t),n.payloadify=function(e){return e?r(s(s({},t.payloadify.call(this,e)),{state:e.state,role:e.role,is_muted:e.isMuted,is_blocked_by_me:e.isBlockedByMe,is_blocking_me:e.isBlockingMe})):null},n}(ve),zt=function(t){function n(e,n){var r,s,i=this;return(i=t.call(this,e)||this).channelUrl=null!==(r=n.channel_url)&&void 0!==r?r:"",i.channelType=null!==(s=n.channel_type)&&void 0!==s?s:o.GROUP,i.reader=new u(i._iid,n.user),i.readAt=n.ts,i}return e(n,t),n}(c);!function(e){e.ALL="all",e.PUBLIC="public",e.PRIVATE="private"}(Rt||(Rt={})),function(e){e.ALL="all",e.JOINED="joined_only",e.INVITED="invited_only",e.INVITED_BY_FRIEND="invited_by_friend",e.INVITED_BY_NON_FRIEND="invited_by_non_friend"}(Ft||(Ft={})),function(e){e.ALL="all",e.SUPER="super",e.NON_SUPER="nonsuper",e.BROADCAST_ONLY="broadcast_only",e.EXCLUSIVE_ONLY="exclusive_only"}(Ot||(Ot={})),function(e){e.ALL="all",e.UNREAD_MESSAGE="unread_message"}(Ht||(Ht={})),function(e){e.ALL="all",e.UNHIDDEN="unhidden_only",e.HIDDEN="hidden_only",e.HIDDEN_ALLOW_AUTO_UNHIDE="hidden_allow_auto_unhide",e.HIDDEN_PREVENT_AUTO_UNHIDE="hidden_prevent_auto_unhide"}(Gt||(Gt={})),function(e){e.ALL="all",e.OPERATOR="operator",e.NONOPERATOR="nonoperator"}(Vt||(Vt={})),function(e){e.AND="AND",e.OR="OR"}(qt||(qt={})),function(e){e.MEMBER_NICKNAME="member_nickname",e.CHANNEL_NAME="channel_name"}(Bt||(Bt={}));var Qt,Wt=function(){function e(){this._searchFilter=null,this._userIdsFilter=null,this.includeEmpty=!1,this.nicknameContainsFilter=null,this.nicknameStartsWithFilter=null,this.nicknameExactMatchFilter=null,this.channelNameContainsFilter="",this.myMemberStateFilter=Ft.ALL,this.customTypesFilter=null,this.channelUrlsFilter=null,this.superChannelFilter=Ot.ALL,this.publicChannelFilter=Rt.ALL,this.customTypeStartsWithFilter=null,this.unreadChannelFilter=Ht.ALL,this.hiddenChannelFilter=Gt.UNHIDDEN,this.includeFrozen=!0}return e.prototype._isFriend=function(e){return!!e.friendDiscoveryKey||!!e.friendName},Object.defineProperty(e.prototype,"searchFilter",{get:function(){return this._searchFilter},enumerable:!1,configurable:!0}),e.prototype.setSearchFilter=function(e,t){Array.isArray(e)&&0!==e.length&&"string"==typeof t&&t&&(this._searchFilter={query:t,fields:e})},Object.defineProperty(e.prototype,"userIdsFilter",{get:function(){return this._userIdsFilter},enumerable:!1,configurable:!0}),e.prototype.setUserIdsFilter=function(e,t,n){void 0===n&&(n=qt.AND),this._userIdsFilter={userIds:e,includeMode:t,queryType:n}},e.prototype.clone=function(){var t=new e;this.searchFilter&&t.setSearchFilter(this.searchFilter.fields,this.searchFilter.query),this.userIdsFilter&&t.setUserIdsFilter(this.userIdsFilter.userIds,this.userIdsFilter.includeMode,this.userIdsFilter.queryType);var n=JSON.parse(JSON.stringify(this));return Object.keys(n).forEach((function(e){t[e]=n[e]})),t},e.prototype.match=function(e,t){if(this._searchFilter){var n=this._searchFilter,r=n.query,s=n.fields;if(r&&s&&s.length>0&&!s.some((function(t){switch(t){case Bt.CHANNEL_NAME:return e.name.toLowerCase().includes(r.toLowerCase());case Bt.MEMBER_NICKNAME:return e.members.some((function(e){return e.nickname.toLowerCase().includes(r.toLowerCase())}));default:return!0}})))return!1}if(this._userIdsFilter){var i=this._userIdsFilter,a=i.userIds,o=i.includeMode,u=i.queryType,c=e.members.map((function(e){return e.userId}));if(o){if(a.length>0)switch(u){case qt.AND:if(a.some((function(e){return!c.includes(e)})))return!1;break;case qt.OR:if(a.every((function(e){return!c.includes(e)})))return!1}}else{if(a.includes(t)||a.push(t),e.members.length>a.length)return!1;if(!l(a,c))return!1}}if(!this.includeEmpty&&!e.lastMessage)return!1;if(!this.includeFrozen&&e.isFrozen)return!1;if(this.customTypesFilter&&this.customTypesFilter.length>0&&!this.customTypesFilter.includes(e.customType))return!1;if(this.customTypeStartsWithFilter&&!new RegExp("^".concat(this.customTypeStartsWithFilter)).test(e.customType))return!1;if(this.channelNameContainsFilter&&!e.name.toLowerCase().includes(this.channelNameContainsFilter.toLowerCase()))return!1;if(this.nicknameContainsFilter){var h=this.nicknameContainsFilter.toLowerCase();if(!e.members.some((function(e){return e.userId!==t&&e.nickname.toLowerCase().includes(h)})))return!1}if(this.nicknameStartsWithFilter){var d=this.nicknameStartsWithFilter.toLowerCase();if(!e.members.some((function(e){return e.userId!==t&&e.nickname.toLowerCase().startsWith(d)})))return!1}if(this.nicknameExactMatchFilter){var p=this.nicknameExactMatchFilter.toLowerCase();if(!e.members.some((function(e){return e.userId!==t&&e.nickname.toLowerCase()!=p})))return!1}if(this.channelUrlsFilter&&this.channelUrlsFilter.length>0&&!this.channelUrlsFilter.includes(e.url))return!1;if(this.myMemberStateFilter)switch(this.myMemberStateFilter){case Ft.JOINED:if("joined"!==e.myMemberState)return!1;break;case Ft.INVITED:if("invited"!==e.myMemberState)return!1;break;case Ft.INVITED_BY_FRIEND:if("invited"!==e.myMemberState||!this._isFriend(e.inviter))return!1;break;case Ft.INVITED_BY_NON_FRIEND:if("invited"!==e.myMemberState||this._isFriend(e.inviter))return!1}if(this.hiddenChannelFilter)switch(this.hiddenChannelFilter){case Gt.UNHIDDEN:if(e.isHidden||"unhidden"!==e.hiddenState)return!1;break;case Gt.HIDDEN:if(!e.isHidden)return!1;break;case Gt.HIDDEN_ALLOW_AUTO_UNHIDE:if(!e.isHidden||"hidden_allow_auto_unhide"!==e.hiddenState)return!1;break;case Gt.HIDDEN_PREVENT_AUTO_UNHIDE:if(!e.isHidden||"hidden_prevent_auto_unhide"!==e.hiddenState)return!1}if(this.unreadChannelFilter&&this.unreadChannelFilter===Ht.UNREAD_MESSAGE)if(0===e.unreadMessageCount)return!1;if(this.publicChannelFilter)switch(this.publicChannelFilter){case Rt.PUBLIC:if(!e.isPublic)return!1;break;case Rt.PRIVATE:if(e.isPublic)return!1}if(this.superChannelFilter)switch(this.superChannelFilter){case Ot.SUPER:if(!e.isSuper)return!1;break;case Ot.NON_SUPER:if(e.isSuper)return!1}return!0},e}(),Kt=function(t){function n(e,n){var r=n.sdkState,s=n.cacheContext,i=t.call(this,e)||this;return i._channels=new Map,i._sdkState=r,i._cacheContext=s,i}return e(n,t),Object.defineProperty(n.prototype,"collection",{get:function(){var e=this._cacheContext.nestdb;return e?e.collection(ge):null},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"localCacheEnabled",{get:function(){return this._cacheContext.localCacheEnabled&&!!this.collection},enumerable:!1,configurable:!0}),n.prototype._serialize=function(e,t){return void 0===t&&(t=0),s(s({},e.serialize()),{lastMessageUpdatedAt:e.lastMessage?e.lastMessage.createdAt:0,syncIndex:t})},n.prototype._deserialize=function(e){return er.of(this._iid).buildGroupChannelFromSerializedData(e)},Object.defineProperty(n.prototype,"channels",{get:function(){return h([],d(this._channels.values()),!1)},enumerable:!1,configurable:!0}),n.prototype.isCachedInMemory=function(e){return this._channels.has(e)},n.prototype.filterOffsetChanged=function(e){var t=this;return e.filter((function(e){if(t._channels.has(e.url))return t._channels.get(e.url).messageOffsetTimestamp0)return!1;if(h&&h===e.url)return!1;break;case Ge.CHRONOLOGICAL:if(!i&&e.createdAt>t||i&&e.createdAtt||i&&e.lastMessageUpdatedAt0?[4,this.upsert(r)]:[3,2];case 1:_.sent(),_.label=2;case 2:return[2]}}))}))},n.prototype.block=function(e,t){return f(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]}}))}))},n.prototype.unblock=function(e,t){return f(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]}}))}))},n.prototype.markAsRead=function(e,t){return void 0===t&&(t=h([],d(this._channels.keys()),!1)),f(this,void 0,void 0,(function(){var n,r,s,i,a,o,u,c;return _(this,(function(l){switch(l.label){case 0:n=[],l.label=1;case 1:l.trys.push([1,6,7,8]),r=m(t),s=r.next(),l.label=2;case 2:return s.done?[3,5]:(i=s.value,[4,this.get(i)]);case 3:(a=l.sent())._updateUnreadMemberState(this._sdkState.userId,e)&&(a._updateUnreadCount(0,0),n.push(a)),l.label=4;case 4:return s=r.next(),[3,2];case 5:return[3,8];case 6:return o=l.sent(),u={error:o},[3,8];case 7:try{s&&!s.done&&(c=r.return)&&c.call(r)}finally{if(u)throw u.error}return[7];case 8:return n.length>0?[4,this.upsert(n)]:[3,10];case 9:l.sent(),l.label=10;case 10:return[2]}}))}))},n}(c),Yt={invitedUserIds:null,channelUrl:null,coverUrl:null,coverImage:null,isDistinct:null,isSuper:null,isBroadcast:null,isExclusive:null,isPublic:null,isDiscoverable:null,isStrict:null,isEphemeral:null,accessCode:null,name:null,data:null,customType:null,operatorUserIds:null,messageSurvivalSeconds:null},Jt=function(e){return 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)},Xt={customTypes:null,includeEmpty:!1,includeFrozen:!0},Zt=function(e){return v("string",e.customTypes,!0)&&g("boolean",e.includeEmpty)&&g("boolean",e.includeFrozen)},$t={myMemberStateFilter:Ft.ALL},en=function(e){return i(Ft,e.myMemberStateFilter)};!function(e){e.GROUP_CHANNEL_UNREAD_MENTION_COUNT="group_channel_unread_mention_count",e.NONSUPER_UNREAD_MENTION_COUNT="non_super_group_channel_unread_mention_count",e.SUPER_UNREAD_MENTION_COUNT="super_group_channel_unread_mention_count",e.GROUP_CHANNEL_UNREAD_MESSAGE_COUNT="group_channel_unread_message_count",e.NONSUPER_UNREAD_MESSAGE_COUNT="non_super_group_channel_unread_message_count",e.SUPER_UNREAD_MESSAGE_COUNT="super_group_channel_unread_message_count",e.GROUP_CHANNEL_INVITATION_COUNT="group_channel_invitation_count",e.NONSUPER_INVITATION_COUNT="non_super_group_channel_invitation_count",e.SUPER_INVITATION_COUNT="super_group_channel_invitation_count"}(Qt||(Qt={}));var tn={keys:[]},nn={channelCustomTypesFilter:null,superChannelFilter:Ot.ALL},rn={channelUrl:null,scheduledStatus:null,messageTypeFilter:C.ALL},sn=function(){function e(e){var t=e.groupChannelCache,n=e.messageCache,r=e.unsentMessageCache,s=e.dispatcher,i=this;this._observers=new Map,s.on((function(e){return f(i,void 0,void 0,(function(){var s,i,a,o,u,c,l,h,d,p,v,g,y=this;return _(this,(function(C){switch(C.label){case 0:if(!(e instanceof je))return[3,10];s=e.channels,p=e.source,i=e.data,a=s.filter((function(e){return e instanceof os})),o=t.filterOffsetChanged(a),C.label=1;case 1:C.trys.push([1,6,7,8]),u=m(o),c=u.next(),C.label=2;case 2:return c.done?[3,5]:(l=c.value,[4,n.removeUnderOffset(l.url,l.messageOffsetTimestamp)]);case 3:C.sent(),C.label=4;case 4:return c=u.next(),[3,2];case 5:return[3,8];case 6:return h=C.sent(),v={error:h},[3,8];case 7:try{c&&!c.done&&(g=u.return)&&g.call(u)}finally{if(v)throw v.error}return[7];case 8:return[4,t.upsert(a)];case 9:return C.sent(),this._broadcastUpdateEvent(a,p,i),[3,15];case 10:return e instanceof Be?(d=e.channelUrls,p=e.source,[4,t.remove(d)]):[3,13];case 11:return C.sent(),[4,E((function(){return f(y,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(d),t=e.next(),u.label=1;case 1:return t.done?[3,5]:(s=t.value,[4,n.removeMessagesOfChannel(s)]);case 2:return u.sent(),[4,r.removeMessagesOfChannel(s)];case 3:u.sent(),u.label=4;case 4:return t=e.next(),[3,1];case 5:return[3,8];case 6:return i=u.sent(),a={error:i},[3,8];case 7:try{t&&!t.done&&(o=e.return)&&o.call(e)}finally{if(a)throw a.error}return[7];case 8:return[2]}}))}))}))];case 12:return C.sent(),this._broadcastRemoveEvent(d,p),[3,15];case 13:return e instanceof qe?[4,t.fetch({token:Number.MAX_SAFE_INTEGER,limit:Number.MAX_SAFE_INTEGER})]:[3,15];case 14:C.sent(),C.label=15;case 15:return[2]}}))}))}))}return e.prototype._broadcastUpdateEvent=function(e,t,n){var r,s;try{for(var i=m(this._observers.values()),a=i.next();!a.done;a=i.next()){a.value.onUpdate(e,t,n)}}catch(e){r={error:e}}finally{try{a&&!a.done&&(s=i.return)&&s.call(i)}finally{if(r)throw r.error}}},e.prototype._broadcastRemoveEvent=function(e,t){var n,r;try{for(var s=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.prototype.unsubscribeAll=function(){this._observers.clear()},e}(),an=function(){function e(e){var t=e.cacheContext,n=e.messageCache,r=e.unsentMessageCache,s=e.dispatcher,i=e.logger,a=this;this._cacheContext=null,this._observers=new Map,this._logger=null,this._cacheContext=t,this._logger=i,s.on((function(e){return f(a,void 0,void 0,(function(){var t,s,i,a,o,u,c,l,h,d,p,m,v,g=this;return _(this,(function(y){switch(y.label){case 0:return e instanceof T?(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,E((function(){return f(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 Ct?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,E((function(){return f(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 U?(a=e.messageIds,m=e.source,[4,E((function(){return f(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 S?(o=e.reqId,m=e.source,[4,E((function(){return f(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 N?(u=e.polls,m=e.source,this._cacheContext.localCacheEnabled?(c=u.map((function(e){return e.messageId})),[4,Promise.all(c.map((function(e){return n.get(e)})))]):[3,12]):[3,13];case 10:return(l=y.sent().filter((function(e){return e}))).length>0&&u.forEach((function(e){var t=l.find((function(t){return t.messageId===e.messageId}));t&&t.applyPoll(e)})),[4,E((function(){return f(g,void 0,void 0,(function(){return _(this,(function(e){switch(e.label){case 0:return[4,n.upsert(l)];case 1:return[2,e.sent()]}}))}))}))];case 11:y.sent(),y.label=12;case 12:return this._broadcastPollChangeLogEvent(u,m),[3,21];case 13:return e instanceof M?(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,E((function(){return f(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 b?(p=e.event,m=e.source,[4,n.get(p.messageId)]):[3,21];case 18:return(v=y.sent())&&v.isUserMessage()&&v.poll&&v.poll.applyPollVoteEvent(p)?[4,E((function(){return f(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(p,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.prototype.unsubscribeAll=function(){this._observers.clear()},e}(),on=function(t){function n(e){var n=e.userId,i=e.ts,a=e.token,o=e.filter,u=t.call(this)||this,c=s(s({},Xt),o),l=c.customTypes,h=c.includeEmpty,d=c.includeFrozen;return u.method=I.GET,u.path="".concat(A,"/").concat(encodeURIComponent(n),"/my_group_channels/changelogs"),u.params=r({show_delivery_receipt:!0,show_member:!0,show_read_receipt:!0,change_ts:i>0?i:null,token:a,custom_types:l,show_empty:h,show_frozen:d}),u}return e(n,t),n}(w),un=function(t){function n(e,n){var r=t.call(this,e,n)||this;return r.updatedChannels=n.updated.map((function(t){return new os(e,t)})),r.deletedChannelUrls=n.deleted,r.hasMore=n.has_more,r.token=n.next,r}return e(n,t),n}(D),cn=function(t){function n(e){var n=e.channelUrl,r=e.isInternalCall,s=t.call(this)||this;return s.method=I.GET,s.path="".concat(r?L:k,"/").concat(encodeURIComponent(n)),s.params={show_member:!0,show_read_receipt:!0,show_delivery_receipt:!0},s}return e(n,t),n}(w),ln=function(t){function n(e,n){var r=t.call(this,e,n)||this;return r.channel=null,r.channel=new os(e,n),r}return e(n,t),n}(D),hn=function(t){function n(e){var n=this,s=e.userId,i=e.token,a=e.limit,o=e.order,u=e.includeEmpty,c=e.myMemberStateFilter,l=e.superChannelFilter,h=e.publicChannelFilter,d=e.unreadChannelFilter,p=e.nicknameContainsFilter,f=e.nicknameStartsWithFilter,_=e.nicknameExactMatchFilter,m=e.channelNameContainsFilter,v=e.channelUrlsFilter,g=e.customTypesFilter,y=e.customTypeStartsWithFilter,C=e.hiddenChannelFilter,E=e.metadataOrderKeyFilter,b=e.metadataKey,M=e.metadataValues,N=e.metadataValueStartsWith,S=e.includeFrozen,U=e.includeMetaData,T=e.searchFilter,w=e.userIdsFilter;return(n=t.call(this)||this).method=I.GET,n.path="".concat(A,"/").concat(encodeURIComponent(s),"/my_group_channels"),n.params=r({token:i,limit:a,order:o,show_member:!0,show_read_receipt:!0,show_delivery_receipt:!0,show_empty:u,member_state_filter:c,super_mode:l,public_mode:h,unread_filter:d,members_nickname_contains:p,members_nickname_startswith:f,members_nickname:_,name_contains:m,channel_urls:v,custom_types:g,custom_type_startswith:y,hidden_mode:C,metadata_order_key:E,metadata_key:b,metadata_values:M,metadata_value_startswith:N,show_frozen:S,show_metadata:U}),T&&T.query&&T.fields&&(n.params.search_query=T.query,n.params.search_fields=T.fields),w&&w.userIds&&w.userIds.length>0&&(w.includeMode?(n.params.members_include_in=w.userIds,n.params.query_type=w.queryType.toUpperCase()):n.params.members_exactly_in=w.userIds),n}return e(n,t),n}(w),dn=function(t){function n(e,n){var r=t.call(this,e,n)||this;r.token=null,r.channels=[],r.ts=null;var s=n.next,i=n.channels,a=n.ts;return r.token=s,i&&i.length>0&&(r.channels=i.map((function(t){return t.ts=a,new os(e,t)}))),r.ts=null!=a?a:null,r}return e(n,t),n}(D),pn=function(t){function n(e){var n=e.userId,r=e.filter,s=t.call(this)||this,i=r.myMemberStateFilter;return s.method=I.GET,s.path="".concat(A,"/").concat(encodeURIComponent(n),"/group_channel_count"),s.params={state:null!=i?i:Ft.ALL},s}return e(n,t),n}(w),fn=function(t){function n(e,n){var r=t.call(this,e,n)||this;return r.groupChannelCount=n.group_channel_count,r}return e(n,t),n}(D),_n=function(t){function n(e){var n=e.userId,r=e.filter,s=t.call(this)||this,i=r.keys;return s.method=I.GET,s.path="".concat(A,"/").concat(encodeURIComponent(n),"/unread_item_count"),s.params={item_keys:i},s}return e(n,t),n}(w),mn=function(t){function n(e,n){var r=t.call(this,e,n)||this;return"number"==typeof n[Qt.GROUP_CHANNEL_UNREAD_MENTION_COUNT]&&(r.groupChannelUnreadMentionCount=n[Qt.GROUP_CHANNEL_UNREAD_MENTION_COUNT]),"number"==typeof n[Qt.GROUP_CHANNEL_UNREAD_MESSAGE_COUNT]&&(r.groupChannelUnreadMessageCount=n[Qt.GROUP_CHANNEL_UNREAD_MESSAGE_COUNT]),"number"==typeof n[Qt.GROUP_CHANNEL_INVITATION_COUNT]&&(r.groupChannelInvitationCount=n[Qt.GROUP_CHANNEL_INVITATION_COUNT]),"number"==typeof n[Qt.SUPER_UNREAD_MENTION_COUNT]&&(r.superGroupChannelUnreadMentionCount=n[Qt.SUPER_UNREAD_MENTION_COUNT]),"number"==typeof n[Qt.SUPER_UNREAD_MESSAGE_COUNT]&&(r.superGroupChannelUnreadMessageCount=n[Qt.SUPER_UNREAD_MESSAGE_COUNT]),"number"==typeof n[Qt.SUPER_INVITATION_COUNT]&&(r.superGroupChannelInvitationCount=n[Qt.SUPER_INVITATION_COUNT]),"number"==typeof n[Qt.NONSUPER_UNREAD_MENTION_COUNT]&&(r.nonSuperGroupChannelUnreadMentionCount=n[Qt.NONSUPER_UNREAD_MENTION_COUNT]),"number"==typeof n[Qt.NONSUPER_UNREAD_MESSAGE_COUNT]&&(r.nonSuperGroupChannelUnreadMessageCount=n[Qt.NONSUPER_UNREAD_MESSAGE_COUNT]),"number"==typeof n[Qt.NONSUPER_INVITATION_COUNT]&&(r.nonSuperGroupChannelInvitationCount=n[Qt.NONSUPER_INVITATION_COUNT]),r}return e(n,t),n}(D),vn=function(t){function n(e){var n=e.userId,r=t.call(this)||this;return r.method=I.GET,r.path="".concat(A,"/").concat(encodeURIComponent(n),"/unread_channel_count"),r}return e(n,t),n}(w),gn=function(t){function n(e,n){var r=t.call(this,e,n)||this;return r.unreadCount=n.unread_count,r}return e(n,t),n}(D),yn=function(t){function n(e){var n=e.userId,r=e.filter,s=t.call(this)||this,i=r.channelCustomTypesFilter,a=r.superChannelFilter;return s.method=I.GET,s.path="".concat(A,"/").concat(encodeURIComponent(n),"/unread_message_count"),s.params={super_mode:null!=a?a:Ot.ALL,custom_types:i},s}return e(n,t),n}(w),Cn=function(t){function n(e,n){var r=t.call(this,e,n)||this;return r.unreadCount=n.unread_count,r}return e(n,t),n}(D),En=function(t){function n(e){var n=e.channelUrl,r=e.scheduledStatus,s=e.messageTypeFilter,i=t.call(this)||this;return i.method=I.GET,i.path="".concat(x,"/count"),i.params={channel_url:n,status:Mn(r)},s&&(i.params.message_type=s),i}return e(n,t),n}(w),bn=function(t){function n(e,n){var r=t.call(this,e,n)||this;return r.count=n.count,r}return e(n,t),n}(D),Mn=function(e){if(e){var t=[];return e.forEach((function(e){switch(e){case yt.PENDING:t.push(Et.PENDING);break;case yt.SENT:t.push(Et.IN_QUEUE),t.push(Et.SENT);break;case yt.CANCELED:t.push(Et.CANCELED);break;case yt.FAILED:t.push(Et.FAILED)}})),t}},Nn=function(t){function n(e){var n=this,s=e.userId,i=e.channelUrl,a=e.coverUrl,o=e.coverImage,u=e.isDistinct,c=e.isSuper,l=e.isBroadcast,p=e.isPublic,f=e.isExclusive,_=e.isDiscoverable,m=e.isStrict,v=e.isEphemeral,g=e.accessCode,y=e.name,C=e.data,E=e.customType,b=e.messageSurvivalSeconds,M=e.invitedUserIds,N=e.operatorUserIds;return(n=t.call(this)||this).method=I.POST,n.path=k,n.params=r({user_ids:h([s],d(null!=M?M:[]),!1).filter((function(e,t,n){return t===n.indexOf(e)})),channel_url:i,cover_url:a,cover_file:o,is_distinct:u,is_super:c,is_broadcast:l,is_exclusive:f,is_public:p,is_discoverable:_,strict:m,is_ephemeral:v,access_code:g,name:y,data:C,custom_type:E,operator_ids:N,message_survival_seconds:b}),n}return e(n,t),n}(w),Sn=function(t){function n(e,n){var r=t.call(this,e,n)||this;return r.channel=new os(e,n),r.isCreated=n.is_created,r}return e(n,t),n}(D),Un=function(t){function n(e){var n=e.userId,r=e.channelUrls,s=t.call(this)||this;return s.method=I.PUT,s.path="".concat(A,"/").concat(encodeURIComponent(n),"/mark_as_read_all"),s.params={channel_urls:r},s}return e(n,t),n}(w);!function(t){function n(){return null!==t&&t.apply(this,arguments)||this}e(n,t)}(D);var Tn=function(t){function n(e){var n=this,r=e.channelUrl,s=e.userId,i=e.accessCode;return(n=t.call(this)||this).method=I.PUT,n.path="".concat(k,"/").concat(encodeURIComponent(r),"/join"),n.params={user_id:s,access_code:i},n}return e(n,t),n}(w),In=function(t){function n(e,n){var r=t.call(this,e,n)||this;return r.channel=new os(e,n),r}return e(n,t),n}(D),An=function(t){function n(e,n,r){var s=t.call(this,e,n,r)||this,i=r.data,a=i.member_count,o=void 0===a?null:a,u=i.joined_member_count,c=void 0===u?null:u,l=i.users,h=void 0===l?null:l;return s.memberCount=o,s.joinedMemberCount=c,s.members=Array.isArray(h)?h.map((function(t){return new jt(e,t)})):[new jt(e,r.data)],s}return e(n,t),n}(ct),wn=function(t){function n(e){var n=this,r=e.channelUrl,s=e.userId,i=e.shouldRemoveOperatorStatus;return(n=t.call(this)||this).method=I.PUT,n.path="".concat(k,"/").concat(encodeURIComponent(r),"/leave"),n.params={user_id:s,should_remove_operator_status:i},n}return e(n,t),n}(w);!function(t){function n(e,n){return t.call(this,e,n)||this}e(n,t)}(D);var Dn=function(t){function n(e,n,r){var s=t.call(this,e,n,r)||this,i=r.data,a=i.member_count,o=void 0===a?null:a,u=i.joined_member_count,c=void 0===u?null:u;return s.memberCount=o,s.joinedMemberCount=c,s.member=new jt(s._iid,r.data),s}return e(n,t),n}(ct),Ln=function(t){function n(e){var n=this,r=e.channelUrl,s=e.userIds;return(n=t.call(this)||this).method=I.POST,n.path="".concat(k,"/").concat(encodeURIComponent(r),"/invite"),n.params={user_ids:s},n}return e(n,t),n}(w),kn=function(t){function n(e,n){var r=t.call(this,e,n)||this;return r.channel=new os(e,n),r}return e(n,t),n}(D),Pn=function(t){function n(e,n,r){var s=t.call(this,e,n,r)||this,i=r.data,a=i.member_count,o=void 0===a?null:a,c=i.joined_member_count,l=void 0===c?null:c,h=i.inviter,d=void 0===h?null:h,p=i.invitees,f=void 0===p?[]:p;return s.memberCount=o,s.joinedMemberCount=l,s.inviter=d?new u(e,d):null,s.invitees=f.map((function(t){return new jt(e,t)})),s}return e(n,t),n}(ct),xn=function(t){function n(e){var n=this,r=e.channelUrl,s=e.userId;return(n=t.call(this)||this).method=I.PUT,n.path="".concat(k,"/").concat(encodeURIComponent(r),"/decline"),n.params={user_id:s},n}return e(n,t),n}(w);!function(t){function n(e,n){var r=t.call(this,e,n)||this;return r.channel=new os(e,n),r.channel.myMemberState=xt.NONE,r}e(n,t)}(D);var Rn=function(t){function n(e,n,r){var s=t.call(this,e,n,r)||this,i=r.data,a=i.member_count,o=void 0===a?null:a,c=i.joined_member_count,l=void 0===c?null:c,h=i.inviter,d=void 0===h?null:h,p=i.invitee,f=void 0===p?null:p;return s.memberCount=o,s.joinedMemberCount=l,s.inviter=d?new u(e,d):null,s.invitee=f?new jt(e,f):null,s}return e(n,t),n}(ct),Fn=function(t){function n(e){var n=e.channelUrl;return t.call(this,{code:"READ",ackRequired:!0,payload:{channel_url:n}})||this}return e(n,t),n}(R),On=function(t){function n(e,n,r){var s=t.call(this,e,"READ",r)||this;return s.readStatus=new zt(e,r),s}return e(n,t),n}(F),Hn=function(t){function n(e){var n=e.channelUrl,s=e.userId,i=t.call(this)||this;return(i=t.call(this)||this).method=I.PUT,i.path="".concat(k,"/").concat(encodeURIComponent(n),"/messages/mark_as_delivered"),i.params=r({userId:s}),i}return e(n,t),n}(w);!function(t){function n(){return null!==t&&t.apply(this,arguments)||this}e(n,t)}(D);var Gn,Vn=function(t){function n(e,n,r){var s=t.call(this,e,"DLVR",r)||this;return s.channelUrl=r.channel_url,s.deliveredStateUpdate=r.updated,s}return e(n,t),n}(F),qn=function(t){function n(e){var n=this,r=e.channelUrl,s=e.userId,i=e.hidePreviousMessages,a=e.allowAutoUnhide;return(n=t.call(this)||this).method=I.PUT,n.path="".concat(k,"/").concat(encodeURIComponent(r),"/hide"),n.params={user_id:s,hide_previous_messages:i,allow_auto_unhide:a},n}return e(n,t),n}(w),Bn=function(t){function n(e,n){var r=t.call(this,e,n)||this;r.messageOffsetTimestamp=null;var s=n.ts_message_offset;return r.messageOffsetTimestamp=null!=s?s:null,r}return e(n,t),n}(D),jn=function(t){function n(e,n,r){var s=t.call(this,e,"SYEV",r)||this;return s.allowAutoUnhide=null,s.hidePreviousMessages=null,s.messageOffsetTimestamp=null,r.data&&(s.allowAutoUnhide=r.data.allow_auto_unhide,s.hidePreviousMessages=r.data.hide_previous_messages),s.messageOffsetTimestamp=r.ts_message_offset,s}return e(n,t),n}(F),zn=function(t){function n(e){var n=e.channelUrl,r=e.time;return t.call(this,{code:"TPST",ackRequired:!1,payload:{channel_url:n,time:r}})||this}return e(n,t),n}(R),Qn=function(t){function n(e,n,r){var s=t.call(this,e,"SYEV",r)||this;return s.user=new u(e,r.data),s}return e(n,t),n}(F),Wn=function(t){function n(e){var n=e.channelUrl,r=e.time;return t.call(this,{code:"TPEN",ackRequired:!1,payload:{channel_url:n,time:r}})||this}return e(n,t),n}(R),Kn=function(t){function n(e,n,r){var s=t.call(this,e,"SYEV",r)||this;return s.user=new u(e,r.data),s}return e(n,t),n}(F),Yn=function(t){function n(e){var n=e.channelUrl,r=e.messageId;return t.call(this,{code:"MACK",ackRequired:!1,payload:{channel_url:n,msg_id:r}})||this}return e(n,t),n}(R),Jn=function(t){function n(e,n){var r,s,i,a,o,u,c,l,h,d,p,f,_,m,v,g,y,C,E,b,M,N,S=this;return(S=t.call(this,e,n)||this).includeEmpty=!1,S.includeFrozen=!0,S.includeMetaData=!0,S.channelUrlsFilter=null,S.customTypesFilter=null,S.customTypeStartsWithFilter=null,S.nicknameContainsFilter=null,S.nicknameStartsWithFilter=null,S.nicknameExactMatchFilter=null,S.channelNameContainsFilter="",S.myMemberStateFilter=Ft.ALL,S.unreadChannelFilter=Ht.ALL,S.superChannelFilter=Ot.ALL,S.publicChannelFilter=Rt.ALL,S.hiddenChannelFilter=Gt.UNHIDDEN,S.searchFilter={fields:[],query:null},S.userIdsFilter={userIds:[],includeMode:!0,queryType:qt.AND},S.metadataKey=null,S.metadataValues=null,S.metadataOrderKeyFilter=null,S.metadataValueStartsWith=null,S.order=Ge.LATEST_LAST_MESSAGE,S.includeEmpty=null!==(r=n.includeEmpty)&&void 0!==r&&r,S.includeFrozen=null===(s=n.includeFrozen)||void 0===s||s,S.includeMetaData=null===(i=n.includeMetaData)||void 0===i||i,S.channelUrlsFilter=null!==(a=n.channelUrlsFilter)&&void 0!==a?a:null,S.customTypesFilter=null!==(o=n.customTypesFilter)&&void 0!==o?o:null,S.customTypeStartsWithFilter=null!==(u=n.customTypeStartsWithFilter)&&void 0!==u?u:"",S.nicknameContainsFilter=null!==(c=n.nicknameContainsFilter)&&void 0!==c?c:null,S.nicknameStartsWithFilter=null!==(l=n.nicknameStartsWithFilter)&&void 0!==l?l:null,S.nicknameExactMatchFilter=null!==(h=n.nicknameExactMatchFilter)&&void 0!==h?h:null,S.channelNameContainsFilter=null!==(d=n.channelNameContainsFilter)&&void 0!==d?d:"",S.myMemberStateFilter=null!==(p=n.myMemberStateFilter)&&void 0!==p?p:Ft.ALL,S.unreadChannelFilter=null!==(f=n.unreadChannelFilter)&&void 0!==f?f:Ht.ALL,S.superChannelFilter=null!==(_=n.superChannelFilter)&&void 0!==_?_:Ot.ALL,S.publicChannelFilter=null!==(m=n.publicChannelFilter)&&void 0!==m?m:Rt.ALL,S.hiddenChannelFilter=null!==(v=n.hiddenChannelFilter)&&void 0!==v?v:Gt.UNHIDDEN,S.searchFilter=null!==(g=n.searchFilter)&&void 0!==g?g:{fields:[],query:null},S.userIdsFilter=null!==(y=n.userIdsFilter)&&void 0!==y?y:{userIds:[],includeMode:!0,queryType:qt.AND},S.metadataKey=null!==(C=n.metadataKey)&&void 0!==C?C:null,S.metadataValues=null!==(E=n.metadataValues)&&void 0!==E?E:null,S.metadataOrderKeyFilter=null!==(b=n.metadataOrderKeyFilter)&&void 0!==b?b:null,S.metadataValueStartsWith=null!==(M=n.metadataValueStartsWith)&&void 0!==M?M:null,S.order=null!==(N=n.order)&&void 0!==N?N:Ge.LATEST_LAST_MESSAGE,S}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)&&i(Ft,this.myMemberStateFilter)&&i(Ot,this.superChannelFilter)&&i(Rt,this.publicChannelFilter)&&i(Ht,this.unreadChannelFilter)&&i(Gt,this.hiddenChannelFilter)&&v(Bt,this.searchFilter.fields)&&g("string",this.searchFilter.query,!0)&&v("string",this.userIdsFilter.userIds)&&g("boolean",this.userIdsFilter.includeMode)&&i(qt,this.userIdsFilter.queryType)&&i(Ge,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 O(this)},n.prototype.next=function(){return f(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,er.of(this._iid).getMyGroupChannels(this._token,this,this.limit)]):[3,2]:[3,5];case 1:return e=r.sent(),t=e.channels,n=e.token,this._token=n,this._hasNext=!!n,this._isLoading=!1,[2,t];case 2:return[2,[]];case 3:throw V.queryInProgress;case 4:return[3,6];case 5:throw V.invalidParameters;case 6:return[2]}}))}))},n}(H),Xn=function(){function e(e){var t=e.top,n=void 0===t?Number.MAX_SAFE_INTEGER:t,r=e.bottom,s=void 0===r?0:r;this.top=n,this.bottom=s}return e.prototype.includes=function(){for(var e=this,t=[],n=0;n0||w.unreadMentionCount>0)&&(w._updateUnreadCount(0,0),this._dispatcher.dispatch(new je({channels:[w],source:ze.EVENT_CHANNEL_READ})),W((function(){return f(En,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(w)}catch(e){n={error:e}}finally{try{t&&!t.done&&(r=e.return)&&r.call(e)}finally{if(n)throw n.error}}return[2]}))}))}))):0!==w.unreadMessageCount&&0!==w.unreadMentionCount||(this._dispatcher.dispatch(new je({channels:[w],source:ze.EVENT_CHANNEL_READ})),W((function(){return f(En,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(w)}catch(e){n={error:e}}finally{try{t&&!t.done&&(r=e.return)&&r.call(e)}finally{if(n)throw n.error}}return[2]}))}))}))):(this._dispatcher.dispatch(new je({channels:[w],source:ze.EVENT_CHANNEL_READ})),W((function(){return f(En,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(w)}catch(e){n={error:e}}finally{try{t&&!t.done&&(r=e.return)&&r.call(e)}finally{if(n)throw n.error}}return[2]}))}))}))),bn.label=12;case 12:return[3,77];case 13:return D=e.as(Vn),ue=D.channelUrl,L=D.deliveredStateUpdate,k=void 0===L?{}:L,P=this._groupChannelCache.isCachedInMemory(ue),[4,this.getChannel(ue,!0)];case 14:if(x=bn.sent(),P)for(R in k)x._updateUndeliveredMemberState(R,k[R]);return Object.keys(k).some((function(e){return e!==En._sdkState.userId}))&&(this._dispatcher.dispatch(new je({channels:[x],source:ze.EVENT_CHANNEL_DELIVERED})),W((function(){return f(En,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(x)}catch(e){n={error:e}}finally{try{t&&!t.done&&(r=e.return)&&r.call(e)}finally{if(n)throw n.error}}return[2]}))}))}))),[3,77];case 15:return F=e.as(_t),ue=F.channelUrl,ce=F.channelType,O=F.event,ce!==o.GROUP?[3,18]:[4,this.getChannel(ue,!0)];case 16:return H=bn.sent(),[4,this.getMessageFromCache(O.messageId)];case 17:(q=bn.sent())&&(q.applyReactionEvent(O),this._dispatcher.dispatch(new T({messages:[q],source:K.EVENT_MESSAGE_REACTION_UPDATED}))),W((function(){return f(En,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,O)}catch(e){n={error:e}}finally{try{t&&!t.done&&(r=e.return)&&r.call(e)}finally{if(n)throw n.error}}return[2]}))}))})),bn.label=18;case 18:return[3,77];case 19:return(G=e.as(ft).event).channelType!==o.GROUP?[3,22]:[4,this.getChannel(G.channelUrl,!0)];case 20:return V=bn.sent(),[4,this.getMessageFromCache(G.targetMessageId)];case 21:(q=bn.sent())&&(q.applyThreadInfoUpdateEvent(G),this._dispatcher.dispatch(new T({messages:[q],source:K.EVENT_MESSAGE_THREADINFO_UPDATED}))),W((function(){return f(En,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(V,G)}catch(e){n={error:e}}finally{try{t&&!t.done&&(r=e.return)&&r.call(e)}finally{if(n)throw n.error}}return[2]}))}))})),bn.label=22;case 22:return[3,77];case 23:j=e.as(pt).groupChannelMemberCounts,z=[],bn.label=24;case 24:bn.trys.push([24,29,30,31]),Y=m(j),J=Y.next(),bn.label=25;case 25:return J.done?[3,28]:(Z=J.value,ue=Z.channelUrl,nt=Z.memberCount,rt=Z.joinedMemberCount,$=Z.updatedAt,[4,this.getChannelFromCache(ue)]);case 26:(ee=bn.sent())&&ee._setLatestMemberCount(nt,rt,$)&&z.push(ee),bn.label=27;case 27:return J=Y.next(),[3,25];case 28:return[3,31];case 29:return te=bn.sent(),pn={error:te},[3,31];case 30:try{J&&!J.done&&(fn=Y.return)&&fn.call(Y)}finally{if(pn)throw pn.error}return[7];case 31:return z.length>0&&(this._dispatcher.dispatch(new je({channels:z,source:ze.EVENT_CHANNEL_MEMBER_COUNT_UPDATED})),W((function(){return f(En,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(z)}catch(e){n={error:e}}finally{try{t&&!t.done&&(r=e.return)&&r.call(e)}finally{if(n)throw n.error}}return[2]}))}))}))),[3,77];case 32:return ne=e.as(dt),re=ne.event,se=ne.status,ue=ne.channelUrl,ce=ne.channelType,ue&&ce?[4,this.getChannel(ue,!0)]:[3,77];case 33:return ie=bn.sent(),this._dispatcher.dispatch(new M({event:re,source:K.EVENT_POLL_UPDATED})),W(se===X?function(){return f(En,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(ie,re.pollId)}catch(e){n={error:e}}finally{try{t&&!t.done&&(r=e.return)&&r.call(e)}finally{if(n)throw n.error}}return[2]}))}))}:function(){return f(En,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(ie,re)}catch(e){n={error:e}}finally{try{t&&!t.done&&(r=e.return)&&r.call(e)}finally{if(n)throw n.error}}return[2]}))}))}),[3,77];case 34:return ae=e.as(Te),oe=ae.event,ue=ae.channelUrl,ce=ae.channelType,ue&&ce?[4,this.getChannel(ue,!0)]:[3,77];case 35:return le=bn.sent(),this._dispatcher.dispatch(new b({event:oe,source:K.EVENT_POLL_VOTED})),W((function(){return f(En,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(le,oe)}catch(e){n={error:e}}finally{try{t&&!t.done&&(r=e.return)&&r.call(e)}finally{if(n)throw n.error}}return[2]}))}))})),[3,77];case 36:if(!(he=e.as(ct).event).isGroupChannelEvent)return[3,75];switch(he.category){case lt.CHANNEL_JOIN:return[3,37];case lt.CHANNEL_LEAVE:return[3,39];case lt.CHANNEL_OPERATOR_UPDATE:return[3,43];case lt.CHANNEL_INVITE:return[3,45];case lt.CHANNEL_DECLINE_INVITE:return[3,47];case lt.TYPING_START:case lt.TYPING_END:return[3,49];case lt.USER_CHANNEL_MUTE:case lt.USER_CHANNEL_UNMUTE:return[3,51];case lt.USER_CHANNEL_BAN:return[3,53];case lt.USER_CHANNEL_UNBAN:return[3,57];case lt.CHANNEL_FREEZE:case lt.CHANNEL_UNFREEZE:return[3,59];case lt.CHANNEL_HIDE:return[3,61];case lt.CHANNEL_UNHIDE:return[3,63];case lt.CHANNEL_DELETED:return[3,65];case lt.CHANNEL_PROP_CHANGED:return[3,67];case lt.CHANNEL_META_DATA_CHANGED:return[3,69];case lt.CHANNEL_META_COUNTERS_CHANGED:return[3,71];case lt.PINNED_MESSAGE_CHANGED:return[3,73]}return[3,75];case 37:return[4,this.getChannel(he.channelUrl,!0)];case 38:return de=bn.sent(),pe=e.as(An),fe=pe.memberCount,_e=pe.joinedMemberCount,me=pe.members,ve=!1,me.forEach((function(e){de.isExclusive||de.isSuper||de.isBroadcast?ve=ve||de._setLatestMemberCount(fe,_e,he.ts):(e.state=xt.JOINED,de.addMember(e,he.ts),En._updateJoinedMemberCount(de)),e.userId===En._sdkState.userId&&(de.myMemberState=xt.JOINED)})),this._dispatcher.dispatch(new je({channels:[de],source:ze.EVENT_CHANNEL_JOINED})),W((function(){return f(En,void 0,void 0,(function(){return _(this,(function(e){return this._groupChannelHandlers.forEach((function(e){var t,n;try{for(var r=m(me),s=r.next();!s.done;s=r.next()){var i=s.value;e.onUserJoined(de,i)}}catch(e){t={error:e}}finally{try{s&&!s.done&&(n=r.return)&&n.call(r)}finally{if(t)throw t.error}}de.isBroadcast&&ve&&e.onChannelMemberCountChanged([de])})),[2]}))}))})),[3,75];case 39:return(Ut=this._leftChannels.get(he.channelUrl))?(ye=Ut.channel,[3,42]):[3,40];case 40:return[4,this.getChannel(he.channelUrl,!0)];case 41:ye=bn.sent(),bn.label=42;case 42:return ge=ye,Le=e.as(Dn),nt=Le.memberCount,rt=Le.joinedMemberCount,ke=Le.member,Pe=!1,xe=B.of(this._iid).appInfo,ge.isExclusive||ge.isSuper||ge.isBroadcast?Pe=ge._setLatestMemberCount(nt,rt,he.ts):(xe.enabledChannelMemberShipHistory?(ge.members.find((function(e){return e.userId===ke.userId})).state=xt.LEFT,ge.memberCount=nt):ge.removeMember(ke),this._updateJoinedMemberCount(ge)),ke.userId===this._sdkState.userId?(ge.myMemberState=xt.NONE,ge.invitedAt=0,ge.joinedAt=0,ge._updateUnreadCount(0,0),ge.isPublic?this._dispatcher.dispatch(new je({channels:[ge],source:ze.EVENT_CHANNEL_LEFT})):(this._markAsLeave(ge),this._dispatcher.dispatch(new Be({channelUrls:[ge.url],source:ze.EVENT_CHANNEL_LEFT})))):this._dispatcher.dispatch(new je({channels:[ge],source:ze.EVENT_CHANNEL_LEFT})),W((function(){return f(En,void 0,void 0,(function(){return _(this,(function(e){return this._groupChannelHandlers.forEach((function(e){e.onUserLeft(ge,ke),ge.isBroadcast&&Pe&&e.onChannelMemberCountChanged([ge])})),[2]}))}))})),[3,75];case 43:return[4,this.getChannel(he.channelUrl,!0)];case 44:Re=bn.sent(),Fe=e.as(ht).operators,Oe=Fe.map((function(e){return e.userId}));try{for(He=m(Re.members),Ge=He.next();!Ge.done;Ge=He.next())(Nt=Ge.value).role=Oe.includes(Nt.userId)?a.OPERATOR:a.NONE}catch(e){_n={error:e}}finally{try{Ge&&!Ge.done&&(mn=He.return)&&mn.call(He)}finally{if(_n)throw _n.error}}return Re.myRole=Oe.includes(this._sdkState.userId)?a.OPERATOR:a.NONE,this._dispatcher.dispatch(new je({channels:[Re],source:ze.EVENT_CHANNEL_OPERATOR_UPDATED})),W((function(){return f(En,void 0,void 0,(function(){return _(this,(function(e){return this._groupChannelHandlers.forEach((function(e){e.onOperatorUpdated(Re,Fe)})),[2]}))}))})),[3,75];case 45:return[4,this.getChannel(he.channelUrl,!0)];case 46:Ve=bn.sent(),qe=e.as(Pn),nt=qe.memberCount,rt=qe.joinedMemberCount,Qe=qe.inviter,(We=qe.invitees).forEach((function(e){return e.state=xt.INVITED}));try{for(Ke=m(We),Ye=Ke.next();!Ye.done;Ye=Ke.next())Je=Ye.value,Ve.isExclusive||Ve.isSuper||Ve.isBroadcast?Ve._setLatestMemberCount(nt,rt,he.ts):Ve.addMember(Je,he.ts),this._sdkState.userId===Je.userId&&(Ve.hiddenState=ts.UNHIDDEN,Ve.myMemberState!==xt.JOINED&&(Ve.myMemberState=xt.INVITED),Ve.invitedAt=he.ts)}catch(e){vn={error:e}}finally{try{Ye&&!Ye.done&&(gn=Ke.return)&&gn.call(Ke)}finally{if(vn)throw vn.error}}return this._dispatcher.dispatch(new je({channels:[Ve],source:ze.EVENT_CHANNEL_INVITED})),W((function(){return f(En,void 0,void 0,(function(){return _(this,(function(e){return this._groupChannelHandlers.forEach((function(e){e.onUserReceivedInvitation(Ve,Qe,We)})),[2]}))}))})),[3,75];case 47:return[4,this.getChannel(he.channelUrl,!0)];case 48:return Xe=bn.sent(),tt=e.as(Rn),nt=tt.memberCount,rt=tt.joinedMemberCount,st=tt.inviter,it=tt.invitee,Xe.isExclusive||Xe.isSuper||Xe.isBroadcast?Xe._setLatestMemberCount(nt,rt,he.ts):Xe.removeMember(it),this._sdkState.userId===it.userId?(Xe.invitedAt=0,Xe.myMemberState=xt.NONE,Xe.isPublic?this._dispatcher.dispatch(new je({channels:[Xe],source:ze.EVENT_CHANNEL_DECLINED_INVITE})):this._dispatcher.dispatch(new Be({channelUrls:[Xe.url],source:ze.EVENT_CHANNEL_DECLINED_INVITE}))):this._dispatcher.dispatch(new je({channels:[Xe],source:ze.EVENT_CHANNEL_DECLINED_INVITE})),W((function(){return f(En,void 0,void 0,(function(){return _(this,(function(e){return this._groupChannelHandlers.forEach((function(e){e.onUserDeclinedInvitation(Xe,st,it)})),[2]}))}))})),[3,75];case 49:return[4,this.getChannel(he.channelUrl,!0)];case 50:return at=bn.sent(),ot=he.category===lt.TYPING_START,ut=e.as(ot?Qn:Kn).user,at._updateTypingStatus(ut,ot?he.ts:0),this._dispatcher.dispatch(new je({channels:[at],source:ze.EVENT_CHANNEL_TYPING_STATUS_UPDATE})),W((function(){return f(En,void 0,void 0,(function(){return _(this,(function(e){return this._groupChannelHandlers.forEach((function(e){e.onTypingStatusUpdated(at)})),[2]}))}))})),[3,75];case 51:return[4,this.getChannel(he.channelUrl,!0)];case 52:gt=bn.sent(),yt=he.category===lt.USER_CHANNEL_MUTE,(Et=e.as(yt?Se:Ue).user).userId===this._sdkState.userId&&(gt.myMutedState=yt?es.MUTED:es.UNMUTED,gt._myMutedRemainingTime=Et.restrictionInfo.remainingDuration);try{for(bt=m(gt.members),Mt=bt.next();!Mt.done;Mt=bt.next())if((Nt=Mt.value).userId===Et.userId){Nt.isMuted=yt;break}}catch(e){yn={error:e}}finally{try{Mt&&!Mt.done&&(Cn=bt.return)&&Cn.call(bt)}finally{if(yn)throw yn.error}}return this._dispatcher.dispatch(new je({channels:[gt],source:yt?ze.EVENT_CHANNEL_MUTED:ze.EVENT_CHANNEL_UNMUTED,data:Et.userId})),W((function(){return f(En,void 0,void 0,(function(){return _(this,(function(e){return this._groupChannelHandlers.forEach((function(e){yt?e.onUserMuted(gt,Et):e.onUserUnmuted(gt,Et)})),[2]}))}))})),[3,75];case 53:return(Ut=this._leftChannels.get(he.channelUrl))?(It=Ut.channel,[3,56]):[3,54];case 54:return[4,this.getChannel(he.channelUrl,!0)];case 55:It=bn.sent(),bn.label=56;case 56:return Tt=It,this._markAsLeave(Tt),At=e.as(Ne).user,W((function(){return f(En,void 0,void 0,(function(){return _(this,(function(e){return this._groupChannelHandlers.forEach((function(e){e.onUserBanned(Tt,At)})),[2]}))}))})),[3,75];case 57:return[4,this.getChannel(he.channelUrl,!0)];case 58:return wt=bn.sent(),Dt=e.as(Me).user,W((function(){return f(En,void 0,void 0,(function(){return _(this,(function(e){return this._groupChannelHandlers.forEach((function(e){e.onUserUnbanned(wt,Dt)})),[2]}))}))})),[3,75];case 59:return[4,this.getChannel(he.channelUrl,!0)];case 60:return Lt=bn.sent(),kt=e.as(be).freeze,Lt.isFrozen=kt,this._dispatcher.dispatch(new je({channels:[Lt],source:kt?ze.EVENT_CHANNEL_FROZEN:ze.EVENT_CHANNEL_UNFROZEN})),W((function(){return f(En,void 0,void 0,(function(){return _(this,(function(e){return this._groupChannelHandlers.forEach((function(e){kt?e.onChannelFrozen(Lt):e.onChannelUnfrozen(Lt)})),[2]}))}))})),[3,75];case 61:return[4,this.getChannel(he.channelUrl,!0)];case 62:return Pt=bn.sent(),Rt=e.as(jn),Ft=Rt.allowAutoUnhide,Ot=Rt.hidePreviousMessages,Ht=Rt.messageOffsetTimestamp,null!==Ft&&(Pt.hiddenState=Ft?ts.HIDDEN_ALLOW_AUTO_UNHIDE:ts.HIDDEN_PREVENT_AUTO_UNHIDE),null!==Ot&&Ot&&Pt._updateUnreadCount(0,0),null!==Ht&&(Pt.messageOffsetTimestamp=Ht),this._dispatcher.dispatch(new je({channels:[Pt],source:ze.EVENT_CHANNEL_HIDDEN})),W((function(){return f(En,void 0,void 0,(function(){return _(this,(function(e){return this._groupChannelHandlers.forEach((function(e){e.onChannelHidden(Pt)})),[2]}))}))})),[3,75];case 63:return[4,this.getChannel(he.channelUrl,!0)];case 64:return(Gt=bn.sent()).hiddenState=ts.UNHIDDEN,this._dispatcher.dispatch(new je({channels:[Gt],source:ze.EVENT_CHANNEL_UNHIDDEN})),W((function(){return f(En,void 0,void 0,(function(){return _(this,(function(e){return this._groupChannelHandlers.forEach((function(e){e.onChannelChanged(Gt)})),[2]}))}))})),[3,75];case 65:return[4,this.getChannel(he.channelUrl,!0)];case 66:return Vt=bn.sent(),this._dispatcher.dispatch(new Be({channelUrls:[he.channelUrl],source:ze.EVENT_CHANNEL_DELETED})),W((function(){return f(En,void 0,void 0,(function(){return _(this,(function(e){return this._groupChannelHandlers.forEach((function(e){e.onChannelDeleted(Vt.url,Vt.channelType)})),[2]}))}))})),[3,75];case 67:return[4,this.getChannelWithoutCache(he.channelUrl,!0)];case 68:return qt=bn.sent(),this._dispatcher.dispatch(new je({channels:[qt],source:ze.EVENT_CHANNEL_UPDATED})),W((function(){return f(En,void 0,void 0,(function(){return _(this,(function(e){return this._groupChannelHandlers.forEach((function(e){e.onChannelChanged(qt)})),[2]}))}))})),[3,75];case 69:return[4,this.getChannel(he.channelUrl,!0)];case 70:return Bt=bn.sent(),jt=e.as(Ee),zt=jt.created,Qt=jt.updated,Wt=jt.deleted,zt&&Bt._upsertCachedMetaData(zt,he.ts),Qt&&Bt._upsertCachedMetaData(Qt,he.ts),Wt&&Bt._removeFromCachedMetaData(Wt,he.ts),W((function(){return f(En,void 0,void 0,(function(){return _(this,(function(e){return this._groupChannelHandlers.forEach((function(e){zt&&e.onMetaDataCreated(Bt,zt),Qt&&e.onMetaDataUpdated(Bt,Qt),Wt&&e.onMetaDataDeleted(Bt,Wt)})),[2]}))}))})),[3,75];case 71:return[4,this.getChannel(he.channelUrl,!0)];case 72:return Kt=bn.sent(),Yt=e.as(Ce),Jt=Yt.created,Xt=Yt.updated,Zt=Yt.deleted,W((function(){return f(En,void 0,void 0,(function(){return _(this,(function(e){return this._groupChannelHandlers.forEach((function(e){Jt&&e.onMetaCounterCreated(Kt,Jt),Xt&&e.onMetaCounterUpdated(Kt,Xt),Zt&&e.onMetaCounterDeleted(Kt,Zt)})),[2]}))}))})),[3,75];case 73:return[4,this.getChannel(he.channelUrl,!0)];case 74:return $t=bn.sent(),en=e.as(Zn),tn=en.pinnedMessageIds,nn=en.latestPinnedMessage,(rn=en.ts)>$t._pinnedMessagesUpdatedAt&&($t.pinnedMessageIds=tn,$t.lastPinnedMessage=nn,$t._pinnedMessagesUpdatedAt=rn,this._dispatcher.dispatch(new je({channels:[$t],source:ze.EVENT_PINNED_MESSAGE_UPDATED})),W((function(){return f(En,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($t)}catch(e){n={error:e}}finally{try{t&&!t.done&&(r=e.return)&&r.call(e)}finally{if(n)throw n.error}}return[2]}))}))})),W((function(){return f(En,void 0,void 0,(function(){return _(this,(function(e){return this._groupChannelHandlers.forEach((function(e){e.onPinnedMessageUpdated($t)})),[2]}))}))}))),[3,75];case 75:return[3,77];case 76:switch((sn=e.as(Ze).event).category){case $e.USER_BLOCK:an=et.getDataAsUserBlockEvent(this._iid,sn),un=an.blocker,cn=an.blockee,this._groupChannelCache.block(un.userId,cn.userId);break;case $e.USER_UNBLOCK:on=et.getDataAsUserBlockEvent(this._iid,sn),un=on.blocker,cn=on.blockee,this._groupChannelCache.unblock(un.userId,cn.userId)}return[3,77];case 77:return[3,79];case 78:if(ln=bn.sent(),Q(ln))throw ln;return[3,79];case 79:return[2]}}))}))},e.prototype._markAsLeave=function(e){var t,n=this,r=null!==(t=this._leftChannels.get(e.url))&&void 0!==t?t:{channel:e,ref:0};r.ref++,this._leftChannels.set(e.url,r),setTimeout((function(){r.ref--,0===r.ref&&n._leftChannels.delete(e.url)}),1e4)},e.prototype.addHandler=function(e,t){this._groupChannelHandlers.set(e,t)},e.prototype.removeHandler=function(e){this._groupChannelHandlers.delete(e)},e.prototype.clearHandler=function(){this._groupChannelHandlers.clear()},e.prototype.subscribeGroupChannelEvent=function(e,t){this._groupChannelBroadcast.subscribe(e,t)},e.prototype.unsubscribeGroupChannelEvent=function(e){this._groupChannelBroadcast.unsubscribe(e)},e.prototype.subscribeMessageEvent=function(e,t){this._messageBroadcast.subscribe(e,t)},e.prototype.unsubscribeMessageEvent=function(e){this._messageBroadcast.unsubscribe(e)},e.prototype._updateJoinedMemberCount=function(e){e.joinedMemberCount=e.members.filter((function(e){return e.state===xt.JOINED})).length},e.prototype.getChannel=function(e,t){return void 0===t&&(t=!1),f(this,void 0,void 0,(function(){var n;return _(this,(function(r){switch(r.label){case 0:Y(g("string",e)).throw(V.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),f(this,void 0,void 0,(function(){var n,r,s,i,a;return _(this,(function(o){switch(o.label){case 0:return Y(g("string",e)).throw(V.invalidParameters),n=new cn({channelUrl:e,isInternalCall:t}),[4,this._requestQueue.send(n)];case 1:switch(r=o.sent(),s=r.as(ln).channel,i=s.unreadMessageCount,a=s.unreadMentionCount,s.myCountPreference){case $r.UNREAD_MESSAGE_COUNT_ONLY:a=0;break;case $r.UNREAD_MENTION_COUNT_ONLY:i=0;break;case $r.OFF:i=0,a=0}return s._updateUnreadCount(i,a),[4,this.upsertChannelsToCache([s])];case 2:return o.sent(),[2,s]}}))}))},e.prototype.refreshChannel=function(e,t,n){return void 0===t&&(t=!0),void 0===n&&(n=ze.REFRESH_CHANNEL),f(this,void 0,void 0,(function(){var r,s,i,a;return _(this,(function(o){switch(o.label){case 0:return o.trys.push([0,2,,3]),r=new cn({channelUrl:e,isInternalCall:t}),[4,this._requestQueue.send(r)];case 1:return s=o.sent(),(i=s.as(ln).channel).myMemberState===xt.NONE?this._dispatcher.dispatch(new Be({channelUrls:[i.url],source:n})):this._dispatcher.dispatch(new je({channels:[i],source:n})),[3,3];case 2:return(a=o.sent()).code!==J.NON_AUTHORIZED&&a.code!==J.NOT_FOUND_IN_DATABASE||this._dispatcher.dispatch(new Be({channelUrls:[e],source:n})),[3,3];case 3:return[2]}}))}))},e.prototype.getMyGroupChannels=function(e,t,n,r){return void 0===r&&(r=ze.REQUEST_CHANNEL),f(this,void 0,void 0,(function(){var i,a,o,u,c;return _(this,(function(l){switch(l.label){case 0:return i=new hn(s(s({},t),{userId:this._sdkState.userId,token:e,limit:n})),[4,this._requestQueue.send(i)];case 1:return a=l.sent(),o=a.as(dn),u=o.channels,c=o.token,this._dispatcher.dispatch(new je({channels:u,source:r})),[2,{channels:u,token:c}]}}))}))},e.prototype.getMessageFromCache=function(e){return f(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=Le),f(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=Le),f(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.getUnsentMessagesFromCache=function(e,t){return f(this,void 0,void 0,(function(){return _(this,(function(n){switch(n.label){case 0:return[4,this._unsentMessageCache.fetch({channelUrl:e,filter:t})];case 1:return[2,n.sent()]}}))}))},e.prototype.removeFailedMessageFromCache=function(e){return f(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 f(this,void 0,void 0,(function(){return _(this,(function(s){switch(s.label){case 0:return[4,this._messageCache.countBetween(e,t,new Xn({top:n,bottom:r}))];case 1:return[2,s.sent()]}}))}))},e.prototype.getMyGroupChannelChangeLogs=function(e,t,n){return void 0===n&&(n=ze.REQUEST_CHANNEL_CHANGELOGS),f(this,void 0,void 0,(function(){var i,a,o,u,c,l,h;return _(this,(function(d){switch(d.label){case 0:return i=s(s({},Xt),t),Y((g("string",e)||g("number",e))&&Zt(i)).throw(V.invalidParameters),a=new on(r({userId:this._sdkState.userId,ts:"number"==typeof e?e:null,token:"string"==typeof e?e:null,filter:i})),[4,this._requestQueue.send(a)];case 1:return o=d.sent(),u=o.as(un),c=u.updatedChannels,l=u.deletedChannelUrls,h=u.hasMore,c.length>0&&this._dispatcher.dispatch(new je({channels:c,source:n})),l.length>0&&this._dispatcher.dispatch(new Be({channelUrls:l,source:n})),[2,{updatedChannels:c,deletedChannelUrls:l,hasMore:h,token:u.token}]}}))}))},e.prototype.getGroupChannelCount=function(e){return f(this,void 0,void 0,(function(){var t,n,r;return _(this,(function(i){switch(i.label){case 0:return t=s(s({},$t),e),Y(en(t)).throw(V.invalidParameters),n=new pn({userId:this._sdkState.userId,filter:t}),[4,this._requestQueue.send(n)];case 1:return r=i.sent(),[2,r.as(fn).groupChannelCount]}}))}))},e.prototype.getUnreadItemCount=function(e){return f(this,void 0,void 0,(function(){var t,n,i,a,o,u,c,l,h,d,p,f,m,g,y,C;return _(this,(function(_){switch(_.label){case 0:return t=s(s({},tn),e),Y(function(e){return v(Qt,e.keys)}(t)).throw(V.invalidParameters),n=B.of(this._iid),i=n.sdkState,a=n.requestQueue,o=new _n({userId:i.userId,filter:t}),[4,a.send(o)];case 1:return u=_.sent(),c=u.as(mn),l=c.groupChannelUnreadMentionCount,h=c.groupChannelUnreadMessageCount,d=c.groupChannelInvitationCount,p=c.superGroupChannelUnreadMentionCount,f=c.superGroupChannelUnreadMessageCount,m=c.superGroupChannelInvitationCount,g=c.nonSuperGroupChannelUnreadMentionCount,y=c.nonSuperGroupChannelUnreadMessageCount,C=c.nonSuperGroupChannelInvitationCount,[2,r({groupChannelUnreadMentionCount:l,groupChannelUnreadMessageCount:h,groupChannelInvitationCount:d,superGroupChannelUnreadMentionCount:p,superGroupChannelUnreadMessageCount:f,superGroupChannelInvitationCount:m,nonSuperGroupChannelUnreadMentionCount:g,nonSuperGroupChannelUnreadMessageCount:y,nonSuperGroupChannelInvitationCount:C})]}}))}))},e.prototype.getTotalUnreadChannelCount=function(){return f(this,void 0,void 0,(function(){var e,t,n,r,s;return _(this,(function(i){switch(i.label){case 0:return e=B.of(this._iid),t=e.sdkState,n=e.requestQueue,r=new vn({userId:t.userId}),[4,n.send(r)];case 1:return s=i.sent(),[2,s.as(gn).unreadCount]}}))}))},e.prototype.getTotalUnreadMessageCount=function(e){return f(this,void 0,void 0,(function(){var t,n,r,a,o,u;return _(this,(function(c){switch(c.label){case 0:return t=s(s({},nn),e),Y(function(e){return v("string",e.channelCustomTypesFilter,!0)&&i(Ot,e.superChannelFilter)}(t)).throw(V.invalidParameters),n=B.of(this._iid),r=n.sdkState,a=n.requestQueue,o=new yn({userId:r.userId,filter:t}),[4,a.send(o)];case 1:return u=c.sent(),[2,u.as(Cn).unreadCount]}}))}))},e.prototype.getTotalScheduledMessageCount=function(e){return void 0===e&&(e={}),f(this,void 0,void 0,(function(){var t,n,r,a;return _(this,(function(o){switch(o.label){case 0:return t=s(s({},rn),e),Y(function(e){return g("string",e.channelUrl,!0)&&v(yt,e.scheduledStatus,!0)&&i(C,e.messageTypeFilter)}(t)).throw(V.invalidParameters),n=B.of(this._iid).requestQueue,r=new En(t),[4,n.send(r)];case 1:return a=o.sent(),[2,a.as(bn).count]}}))}))},e.prototype.getSubscribedTotalUnreadMessageCount=function(){var e=B.of(this._iid).subscribedUnreadMessageCount;return e.all>=0?e.all:0},e.prototype.getSubscribedCustomTypeTotalUnreadMessageCount=function(){var e=0,t=B.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=B.of(this._iid).subscribedUnreadMessageCount.customTypes[e])&&void 0!==t?t:0},e.prototype.createChannel=function(e){return f(this,void 0,void 0,(function(){var t,n,r,i;return _(this,(function(a){switch(a.label){case 0:return t=s(s({},Yt),e),Y(Jt(t)).throw(V.invalidParameters),t.isPublic||(t.accessCode=null),n=new Nn(s({userId:this._sdkState.userId},t)),[4,this._requestQueue.send(n)];case 1:return r=a.sent(),i=r.as(Sn).channel,[4,this.upsertChannelsToCache([i])];case 2:return a.sent(),[2,i]}}))}))},e.prototype.markAsReadAll=function(){return f(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(),Y(e-this._markAsReadAllLastSentAt>=1e3).throw(V.markAsReadAllRateLimitExceeded),this._markAsReadAllLastSentAt=e,t=new Un({userId:this._sdkState.userId}),[4,this._requestQueue.send(t)];case 1:u.sent(),n=this._groupChannelCache.channels;try{for(r=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.upsertChannelsToCache(n)]:[3,3];case 2:u.sent(),u.label=3;case 3:return[2]}}))}))},e.prototype.markAsReadWithChannelUrls=function(e){return f(this,void 0,void 0,(function(){var t,n,r,s,i,a,o,u,c;return _(this,(function(l){switch(l.label){case 0:return t=Date.now(),Y(v("string",e)&&t-this._markAsReadAllLastSentAt>=1e3).throw(V.markAsReadAllRateLimitExceeded),this._markAsReadAllLastSentAt=t,n=new Un({userId:this._sdkState.userId,channelUrls:e}),[4,this._requestQueue.send(n)];case 1:l.sent(),r=this._groupChannelCache.channels,s=[];try{for(i=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&&(c=i.return)&&c.call(i)}finally{if(u)throw u.error}}return s.length>0?[4,this.upsertChannelsToCache(s)]:[3,3];case 2:l.sent(),l.label=3;case 3:return[2]}}))}))},e.prototype.markAsDelivered=function(e){return f(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}();!function(e){e[e.IDLE=0]="IDLE",e[e.RUNNING=1]="RUNNING",e[e.END=2]="END"}(Gn||(Gn={}));var tr,nr=function(t){function n(e,n,r,s){var i=t.call(this)||this;return i._worker=null,i._state=Gn.IDLE,i._semaphore=null,i._retryCount=0,i._retryLimit=3,i.priority=0,i._worker=n,i}return e(n,t),Object.defineProperty(n.prototype,"isIdle",{get:function(){return this._state===Gn.IDLE},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"isRunning",{get:function(){return this._state===Gn.RUNNING},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"isDone",{get:function(){return this._state===Gn.END},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"retryCount",{get:function(){return this._retryCount},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"retryLimit",{get:function(){return this._retryLimit},enumerable:!1,configurable:!0}),n.prototype._run=function(e){return f(this,void 0,void 0,(function(){var t,n;return _(this,(function(r){switch(r.label){case 0:if(!this.isRunning)return[3,4];r.label=1;case 1:return r.trys.push([1,3,,4]),[4,this._worker(e)];case 2:return t=r.sent(),this._retryCount=0,this.dispatch("progress",t),t.hasNext?this._run(t.nextToken):this.end(),[3,4];case 3:return n=r.sent(),this.dispatch("error",n),this._retryCount0&&(r=n.map((function(e){return e.createdAt})),(i=this._metadata.range).intersect.apply(i,h([],d(r),!1))?this.extendRange(n):this._metadata={range:new Xn({top:Math.min.apply(Math,h([],d(r),!1)),bottom:Math.max.apply(Math,h([],d(r),!1))}),previousComplete:!1}),t.hasNext=n.length>=this._limit&&this._prevSyncLoopCount<1,t.nextToken=this._metadata.range.top,this._metadata.previousComplete=n.length0&&(r=n.map((function(e){return e.createdAt})),(i=this._metadata.range).intersect.apply(i,h([],d(r),!1))?this.extendRange(n):this._metadata={range:new Xn({top:Math.min.apply(Math,h([],d(r),!1)),bottom:Math.max.apply(Math,h([],d(r),!1))}),previousComplete:!1}),t.hasNext=n.length>=this._limit&&this._nextSyncLoopCount<1,t.nextToken=this._metadata.range.bottom,p.debug("message background next sync progress",t),[4,this.saveMetadata()];case 4:return u.sent(),[3,6];case 5:throw s=u.sent(),p.debug("message background next sync error",s),s;case 6:return[2,t]}}))}))})),this._connectionEventContext=l.on((function(e){if(e instanceof $)if(e.stateType===ee.CONNECTED)i.resume();else i.pause()}))}return e.of=function(t,n){return ir[t]||(ir[t]={}),ir[t][n.url]||(ir[t][n.url]=new e({_iid:t,channel:n})),ir[t][n.url].ref++,ir[t][n.url]},e.clear=function(e,t){ir[e]&&ir[e][t]&&(ir[e][t].close(),delete ir[e])},Object.defineProperty(e.prototype,"range",{get:function(){var e;return null===(e=this._metadata)||void 0===e?void 0:e.range},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"previousComplete",{get:function(){var e;return!!(null===(e=this._metadata)||void 0===e?void 0:e.previousComplete)},enumerable:!1,configurable:!0}),e.prototype.isWrappingMessages=function(e){var t;return null===(t=this.range)||void 0===t?void 0:t.includes.apply(t,h([],d(e.map((function(e){return e.createdAt}))),!1))},e.prototype.extendRange=function(e){var t;this._metadata&&(t=this._metadata.range).extends.apply(t,h([],d(e.map((function(e){return e.createdAt}))),!1))},e.prototype.loadMetadata=function(e){return f(this,void 0,void 0,(function(){var t;return _(this,(function(n){switch(n.label){case 0:return this._metadata?[3,2]:[4,B.of(this._iid).cacheContext.preference.get(this._metadataKey)];case 1:(t=n.sent())?t.range.bottom0||r.length>0)&&(this._metadata.token=i),o.debug("message changelog sync progress",e),[4,this.saveMetadata()];case 4:return c.sent(),[3,8];case 5:return a=c.sent(),o.debug("message changelog sync error",a),a instanceof V&&a.isInvalidTokenError?[4,this.clearMetadata()]:[3,7];case 6:c.sent(),c.label=7;case 7:throw a;case 8:return[2,e]}}))}))})),this._connectionEventContext=c.on((function(e){if(e instanceof $)if(e.stateType===ee.CONNECTED)r.resume();else r.pause()}))}return e.of=function(t,n){return or[t]||(or[t]={}),or[t][n.url]||(or[t][n.url]=new e({_iid:t,channel:n})),or[t][n.url].ref++,or[t][n.url]},e.clear=function(e,t){or[e]&&or[e][t]&&(or[e][t].close(),delete or[e])},e.prototype.loadMetadata=function(){return f(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=B.of(this._iid),t=e.cacheContext,n=e.firstConnectedAt,[4,t.preference.get(this._metadataKey)]);case 1:r=s.sent(),this._metadata={token:r?r.token:n},s.label=2;case 2:return[2,this._metadata]}}))}))},e.prototype.saveMetadata=function(){return f(this,void 0,void 0,(function(){return _(this,(function(e){switch(e.label){case 0:return this._metadata?[4,B.of(this._iid).cacheContext.preference.set(this._metadataKey,this._metadata)]:[3,2];case 1:return e.sent(),[2,!0];case 2:return[2,!1]}}))}))},e.prototype.clearMetadata=function(){return f(this,void 0,void 0,(function(){return _(this,(function(e){switch(e.label){case 0:return[4,B.of(this._iid).cacheContext.preference.remove(this._metadataKey)];case 1:return e.sent(),this._metadata=null,[2]}}))}))},e.prototype.resume=function(){var e=B.of(this._iid),t=e.logger;e.connectionManager.isConnected&&(t.debug("message changelog sync resume()"),this._sync.start(0))},e.prototype.pause=function(){var e=B.of(this._iid),t=e.logger;e.connectionManager.isConnected&&(t.debug("message changelog sync pause()"),this._sync.stop())},e.prototype.close=function(){this.ref--,this.ref<=0&&(this.ref=0,this.pause(),this._connectionEventContext.close(),delete or[this._iid][this._channel.url])},e}(),cr={},lr=function(){function e(e){var t=e._iid,n=e.channel,r=e.hasPollMessage,s=this;this._sync=null,this.ref=0,this._metadata=null,this._iid=t,this._channel=n;var i,a,o=B.of(this._iid),u=o.logger,c=o.sdkState,l=o.dispatcher;this._metadataKey=(i=c.userId,a=n.url,"sendbird:".concat(i,"@groupchannel/").concat(a,"/poll/changelogs.meta"));var h=function(e,t){return"sendbird:".concat(e,"@groupchannel/").concat(t,"/poll/changelogs")}(c.userId,this._channel.url);this._sync=new nr(h,(function(){return f(s,void 0,void 0,(function(){var e,t,n,s,i,a,o,c;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===(c=this._metadata)||void 0===c?void 0:c.token),(t=!this._metadata||!this._metadata.token)?[4,r()]:[3,3];case 2:t=!l.sent(),l.label=3;case 3:if(t)return[2,{hasNext:!1,nextToken:0}];this._metadata||(n=B.of(this._iid).firstConnectedAt,this._metadata={token:n}),l.label=4;case 4:return l.trys.push([4,7,,10]),[4,Pt.of(this._iid).getPollChangeLogs(this._channel.url,this._channel.channelType,this._metadata.token)];case 5:return s=l.sent(),i=s.hasMore,a=s.token,e.hasNext=i,e.nextToken=a,this._metadata.token=a,u.debug("poll changelog sync progress",e),[4,this.saveMetadata()];case 6:return l.sent(),[3,10];case 7:return o=l.sent(),u.debug("poll changelog sync error",o),o instanceof V&&o.isInvalidTokenError?[4,this.clearMetadata()]:[3,9];case 8:l.sent(),l.label=9;case 9:throw o;case 10:return[2,e]}}))}))})),this._connectionEventContext=l.on((function(e){if(e instanceof $)if(e.stateType===ee.CONNECTED)s.resume();else s.pause()}))}return e.of=function(t,n,r){return cr[t]||(cr[t]={}),cr[t][n.url]||(cr[t][n.url]=new e({_iid:t,channel:n,hasPollMessage:r})),cr[t][n.url].ref++,cr[t][n.url]},e.prototype.loadMetadata=function(){return f(this,void 0,void 0,(function(){var e;return _(this,(function(t){switch(t.label){case 0:return this._metadata?[3,2]:[4,B.of(this._iid).cacheContext.preference.get(this._metadataKey)];case 1:e=t.sent(),this._metadata=e?{token:e.token}:null,t.label=2;case 2:return[2]}}))}))},e.prototype.saveMetadata=function(){return f(this,void 0,void 0,(function(){return _(this,(function(e){switch(e.label){case 0:return this._metadata?[4,B.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 f(this,void 0,void 0,(function(){return _(this,(function(e){switch(e.label){case 0:return[4,B.of(this._iid).cacheContext.preference.remove(this._metadataKey)];case 1:return e.sent(),this._metadata=null,[2]}}))}))},e.prototype.resume=function(){B.of(this._iid).logger.debug("poll changelog sync resume()"),this._sync.start(0)},e.prototype.pause=function(){B.of(this._iid).logger.debug("poll changelog sync pause()"),this._sync.stop()},e.prototype.close=function(){this.ref--,this.ref<=0&&(this.ref=0,this.pause(),this._connectionEventContext.close(),delete cr[this._iid][this._channel.url])},e}(),hr=function(t){function n(e){var n,s,i,a,o,u,c=this;return(c=t.call(this)||this).method=I.GET,c.path="".concat(ne(e.channelType),"/").concat(e.channelUrl,"/messages_gap"),c.params=r({prev_start_ts:e.prevStart,prev_end_ts:e.prevEnd,prev_cache_count:e.prevCount,next_start_ts:e.nextStart,next_end_ts:e.nextEnd,next_cache_count:e.nextCount,huge_gap_threshold:null!==(n=e.threshold)&&void 0!==n?n:null,reverse:!0,custom_types:null!==(s=e.customTypes)&&void 0!==s?s:["*"],message_type:null!==(i=e.messageType)&&void 0!==i?i:null,include_reactions:null===(a=e.includeReactions)||void 0===a||a,with_sorted_meta_array:null===(o=e.includeMetaArray)||void 0===o||o,show_subchannel_messages_only:null!==(u=e.showSubchannelMessagesOnly)&&void 0!==u&&u,include_poll_details:!0,checking_continuous_messages:e.checkingContinuousMessages}),c}return e(n,t),n}(w),dr=function(t){function n(e,n){var r,s,i,a,o,u,c=this;return(c=t.call(this,e,n)||this).isHugeGap=n.is_huge_gap,c.prevMessages=(null!==(r=n.prev_messages)&&void 0!==r?r:[]).map((function(t){return bt(e,t)})),c.prevHasMore=null!==(s=n.prev_hasmore)&&void 0!==s&&s,c.isContinuousPrevMessages=null!==(i=n.is_continuous_prev_messages)&&void 0!==i&&i,c.nextMessages=(null!==(a=n.next_messages)&&void 0!==a?a:[]).map((function(t){return bt(e,t)})),c.nextHasmore=null!==(o=n.next_hasmore)&&void 0!==o&&o,c.isContinuousNextMessages=null!==(u=n.is_continuous_next_messages)&&void 0!==u&&u,c}return e(n,t),n}(D),pr=function(e,t){return e.findIndex((function(e){return e.isIdentical(t)}))},fr=function(e,t,n){if(e.length>0){for(var r=pr(e,t),s=0,i=e.length-1,a=Math.floor((s+i)/2);s0)i=a,a=Math.floor((s+i)/2);else{if(!(o<0))return{place:a,oldPosition:r};s=a+1,a=Math.floor((s+i)/2)}}return{place:_r(e[a],t,n)>=0?a:a+1,oldPosition:r}}return{place:e.length,oldPosition:-1}},_r=function(e,t,n){switch(n){case Ge.LATEST_LAST_MESSAGE:return e.lastMessage&&t.lastMessage?t.lastMessage.createdAt-e.lastMessage.createdAt:e.lastMessage?-1:t.lastMessage?1:t.createdAt-e.createdAt;case Ge.CHRONOLOGICAL:return t.createdAt-e.createdAt;case Ge.CHANNEL_NAME_ALPHABETICAL:var r=e.name.localeCompare(t.name);return 0===r?e.createdAt-t.createdAt:r}},mr=function(e,t){return t instanceof Ct?e.findIndex((function(e){return e instanceof Ct&&t.isIdentical(e)})):e.findIndex((function(e){return e.isIdentical(t)}))},vr=function(e,t){return e.findIndex((function(e){return e.messageId===t}))},gr=function(e,t){if(e.length>0){for(var n=0,r=e.length-1,s=Math.floor((n+r)/2);n0)r=s,s=Math.floor((n+r)/2);else{if(!(i<0))return s;n=s+1,s=Math.floor((n+r)/2)}}return e[s].createdAt>t.createdAt?s:s+1}return e.length},yr=6e5;!function(e){e.CACHE_AND_REPLACE_BY_API="cache_and_replace_by_api"}(tr||(tr={}));var Cr,Er,br,Mr=function(){function e(){}return e.prototype._invokeResponse=function(e,t,n){var r=this;W((function(){return f(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}(),Nr=function(){function e(e,t){var n=t.channel,r=t.filter,s=t.startingPoint,i=t.limit,a=this;this._channel=null,this._messages=[],this._unsentMessages=[],this._backgroundSync=null,this._changelogSync=null,this._pollChangelogSync=null,this._checkMyMutedStateTimer=null,this._iid=e,this._key="mc-".concat(oe()),this.filter=null!=r?r:new Je,this._channel=n,this._syncRange=new Xn({}),this._hasPrevious=!0,this._hasNext=!0,this._startingPoint="number"==typeof s?s:Date.now()+yr,this._limit=i||Le;var o=er.of(this._iid);o.subscribeGroupChannelEvent(this._key,{onUpdate:function(e,t,n){var r=pr(e,a._channel);if(r>=0)switch(W((function(){return f(a,void 0,void 0,(function(){var n,s;return _(this,(function(i){return n=new rr(t),this._channel=e[r],tt(t)&&(null===(s=this._handler)||void 0===s?void 0:s.onChannelUpdated)&&this._handler.onChannelUpdated(n,this.channel),[2]}))}))})),t){case ze.EVENT_CHANNEL_UPDATED:var s=!1;for(var i in a._messages){if(a._messages[i].createdAt>=a._channel.messageOffsetTimestamp){s=!0;var o=parseInt(i);if(o>0){var u=a._messages.splice(0,o);a._removeMessagesFromView(u.map((function(e){return e.messageId})),K.EVENT_MESSAGE_OFFSET_UPDATED)}break}}!s&&a._messages.length>0&&a._removeMessagesFromView(a._messages.map((function(e){return e.messageId})),K.EVENT_MESSAGE_OFFSET_UPDATED);break;case ze.EVENT_CHANNEL_UNMUTED:var c=n;B.of(a._iid).sdkState.userId===c&&a._clearCheckMyMutedTimer();break;case ze.EVENT_CHANNEL_MUTED:var l=n;B.of(a._iid).sdkState.userId===l&&-1!==a.channel._myMutedRemainingTime&&a._startCheckMyMutedTimer(a.channel._myMutedRemainingTime);break;case ze.EVENT_CHANNEL_LEFT:a.channel.isPublic&&a._clearCheckMyMutedTimer()}},onRemove:function(e,t){e.indexOf(a.channel.url)>=0&&(a._clearCheckMyMutedTimer(),W((function(){return f(a,void 0,void 0,(function(){var e,n;return _(this,(function(r){return e=new rr(t),(null===(n=this._handler)||void 0===n?void 0:n.onChannelDeleted)&&this._handler.onChannelDeleted(e,this.channel.url),[2]}))}))})))}}),o.subscribeMessageEvent(this._key,{onUpdate:function(e,t){var n,r,s=[],i=[];try{for(var o=m(e),u=o.next();!u.done;u=o.next()){var c=u.value;c.channelUrl===a._channel.url&&(a.filter.match(c)?s.push(c):i.push(c.messageId))}}catch(e){n={error:e}}finally{try{u&&!u.done&&(r=o.return)&&r.call(o)}finally{if(n)throw n.error}}if(re(t)){if(s.length>0)switch(t){case K.EVENT_MESSAGE_SENT_FAILED:case K.EVENT_MESSAGE_SENT_SUCCESS:case K.EVENT_MESSAGE_UPDATED:case K.EVENT_MESSAGE_THREADINFO_UPDATED:case K.EVENT_MESSAGE_REACTION_UPDATED:case K.SYNC_MESSAGE_CHANGELOGS:a._updateMessagesToView(s,t);break;case K.EVENT_MESSAGE_SENT_PENDING:a._addMessagesToView(s,t);break;case K.EVENT_MESSAGE_RECEIVED:a.hasNext||a._addMessagesToView(s,t);break;case K.SYNC_MESSAGE_FILL:a._addMessagesToView(s,t)}i.length>0&&a._removeMessagesFromView(i,t)}},onRemove:function(e,t){a._removeMessagesFromView(e,t)},onRemoveUnsent:function(e,t){a._removeUnsentMessageFromView(e,t)},onPollChangeLogUpdate:function(e,t){a._updatePollsToView(e,t)},onPollUpdate:function(e,t){a._applyPollUpdateEventToView(e,t)},onPollVote:function(e,t){a._applyPollVoteEventToView(e,t)}});var u=B.of(this._iid),c=u.cacheContext,l=u.dispatcher,p=u.logger;this._channel._updateMessageCollectionLastAccessedAt(),l.dispatch(new je({channels:[this._channel],source:ze.CHANNEL_LASTACCESSEDAT_UPDATED})),!this._channel.isSuper&&c.localCacheEnabled&&(this._backgroundSync=ar.of(this._iid,this._channel),this._backgroundSync.resume(this._startingPoint)),this._changelogSync=ur.of(this._iid,this._channel),this._changelogSync.resume(),this._pollChangelogSync=lr.of(this._iid,this._channel,this._hasPollMessage.bind(this)),this._pollChangelogSync.resume(),this._prevFill=new nr(this._key,(function(e){return f(a,void 0,void 0,(function(){var t,n,r,s,i;return _(this,(function(a){switch(a.label){case 0:return[4,this._getRemoteMessages(e,{prevLimit:this._limit,source:K.SYNC_MESSAGE_FILL,checkingContinuousMessages:c.localCacheEnabled})];case 1:return t=a.sent(),n=t.messages,r=t.isContinuousMessages,n.length>0?(s=Math.min.apply(Math,h([],d(n.map((function(e){return e.createdAt}))),!1)),this._syncRange.extends(s),r&&(null===(i=this._backgroundSync)||void 0===i||i.range.extends(s)),[2,{hasNext:n.length>=this._limit&&this.viewTop0?(s=Math.max.apply(Math,h([],d(n.map((function(e){return e.createdAt}))),!1)),this._syncRange.extends(s),r&&(null===(i=this._backgroundSync)||void 0===i||i.range.extends(s)),[2,{hasNext:!(n.length>=this._limit&&this._hasNext)||this.viewBottom>s,nextToken:this._syncRange.bottom}]):[2,{hasNext:!1,nextToken:0}]}}))}))})),this._connectionEventContext=l.on((function(e){if(e instanceof $)switch(e.stateType){case ee.CONNECTED:a._refreshChannel(ze.SYNC_CHANNEL_CHANGELOGS),E((function(){return f(a,void 0,void 0,(function(){var e;return _(this,(function(t){switch(t.label){case 0:return[4,this.channel.getMyMutedInfo()];case 1:return(e=t.sent()).isMuted&&-1!==e.remainingDuration&&this._startCheckMyMutedTimer(e.remainingDuration),[2]}}))}))})),p.debug("check huge gap"),a._checkHugeGap();break;case ee.LOGOUT:a.dispose();break;default:a._clearCheckMyMutedTimer(),a._prevFill.stop(),a._nextFill.stop()}})),B.of(this._iid).statLogCollector.put(new se({type:ie.FEATURE_LOCALCACHE,data:{use_local_cache:c.localCacheEnabled,collection_interface:{message:!0}}}))}return Object.defineProperty(e.prototype,"channel",{get:function(){return this._channel},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"succeededMessages",{get:function(){return h([],d(this._messages),!1)},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"failedMessages",{get:function(){return this._unsentMessages.filter((function(e){return e.sendingStatus===ue.FAILED}))},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"pendingMessages",{get:function(){return this._unsentMessages.filter((function(e){return e.sendingStatus===ue.PENDING}))},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"hasPrevious",{get:function(){return this._hasPrevious},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"hasNext",{get:function(){return this._hasNext},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"viewTop",{get:function(){return Math.min.apply(Math,h(h([],d(this._messages.map((function(e){return e.createdAt}))),!1),[Number.MAX_SAFE_INTEGER],!1))},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"viewBottom",{get:function(){return Math.max.apply(Math,h(h([],d(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),c=u.next();!c.done;c=u.next()){var l=c.value;if(t===K.SYNC_MESSAGE_FILL){if(l.messageId>0){if((y=mr(this._messages,l))<0){mr(this._unsentMessages,l)<0&&a.push(l);var p=gr(this._messages,l);this._messages.splice(p,0,l)}}else if(l instanceof Ct){(y=mr(this._unsentMessages,l))<0&&mr(this._messages,l)<0&&(this._unsentMessages.push(l),a.push(l))}}else if(l.messageId>0){if((y=mr(this._messages,l))<0){var v=mr(this._unsentMessages,l);v<0?a.push(l):(this._unsentMessages.splice(v,1),o.push(l));p=gr(this._messages,l);this._messages.splice(p,0,l)}else o.push(l),this._messages[y]=l;if(l.updatedAt>0){var g=this._updateChildMessagesInView(l);o.push.apply(o,h([],d(g),!1))}}else if(l instanceof Ct){var y;(y=mr(this._unsentMessages,l))<0?mr(this._messages,l)<0&&(this._unsentMessages.push(l),a.push(l)):(o.push(l),this._unsentMessages[y]=l)}}}catch(e){n={error:e}}finally{try{c&&!c.done&&(r=u.return)&&r.call(u)}finally{if(n)throw n.error}}re(t)&&W((function(){return f(s,void 0,void 0,(function(){var e,n,r;return _(this,(function(s){return e=new sr(t),a.length>0&&(null===(n=this._handler)||void 0===n||n.onMessagesAdded(e,this.channel,a)),o.length>0&&(null===(r=this._handler)||void 0===r||r.onMessagesUpdated(e,this.channel,o)),[2]}))}))}))},e.prototype._updateChildMessagesInView=function(e){var t=[];return this._messages.forEach((function(n){n.applyParentMessage(e)&&t.push(n)})),t},e.prototype._updatePollsToView=function(e,t){var n,r,s=this,i=[];try{for(var a=m(e),o=a.next();!o.done;o=a.next()){var u=o.value,c=vr(this._messages,u.messageId);if(c>=0){var l=this._messages[c];l&&l.applyPoll(u),i.push(l)}}}catch(e){n={error:e}}finally{try{o&&!o.done&&(r=a.return)&&r.call(a)}finally{if(n)throw n.error}}return i.length>0&&re(t)&&W((function(){return f(s,void 0,void 0,(function(){var e,n;return _(this,(function(r){return e=new sr(t),i.length>0&&(null===(n=this._handler)||void 0===n||n.onMessagesUpdated(e,this.channel,i)),[2]}))}))})),i},e.prototype._applyPollUpdateEventToView=function(e,t){var n=this,r=vr(this._messages,e.messageId);if(r>=0){var s=this._messages[r];s&&s.isUserMessage()&&s.poll&&s.poll.applyPollUpdateEvent(e)&&re(t)&&W((function(){return f(n,void 0,void 0,(function(){var e,n;return _(this,(function(r){return e=new sr(t),null===(n=this._handler)||void 0===n||n.onMessagesUpdated(e,this.channel,[s]),[2]}))}))}))}},e.prototype._applyPollVoteEventToView=function(e,t){var n=this,r=vr(this._messages,e.messageId);if(r>=0){var s=this._messages[r];s&&s.isUserMessage()&&s.poll&&s.poll.applyPollVoteEvent(e)&&re(t)&&W((function(){return f(n,void 0,void 0,(function(){var e,n;return _(this,(function(r){return e=new sr(t),null===(n=this._handler)||void 0===n||n.onMessagesUpdated(e,this.channel,[s]),[2]}))}))}))}},e.prototype._updateMessagesToView=function(e,t){var n,r,s=this,i=[],a=[];try{for(var o=m(e),u=o.next();!u.done;u=o.next()){var c,l=u.value;if(l.messageId>0)if((c=mr(this._messages,l))>=0)i.push(l),this._messages[c]=l;else{var h=mr(this._unsentMessages,l);if(h>=0){var d=this._unsentMessages.splice(h,1);if(this.hasNext&&d.length>0)a.push(d[0]);else{i.push(l);var p=gr(this._messages,l);this._messages.splice(p,0,l)}}}else if(l instanceof Ct)(c=mr(this._unsentMessages,l))>=0&&(i.push(l),this._unsentMessages[c]=l)}}catch(e){n={error:e}}finally{try{u&&!u.done&&(r=o.return)&&r.call(o)}finally{if(n)throw n.error}}return re(t)&&W((function(){return f(s,void 0,void 0,(function(){var e,n,r;return _(this,(function(s){return e=new sr(t),i.length>0?null===(n=this._handler)||void 0===n||n.onMessagesUpdated(e,this.channel,i):a.length>0&&(null===(r=this._handler)||void 0===r||r.onMessagesDeleted(e,this.channel,[],a)),[2]}))}))})),i},e.prototype._removeMessagesFromView=function(e,t){var n,r,s=this,i=[],a=[],o=function(e){var t=u._messages.findIndex((function(t){return t.messageId===e}));if(t>=0){var n=u._messages[t];i.push(n.messageId),a.push(n),u._messages.splice(t,1)}},u=this;try{for(var c=m(e),l=c.next();!l.done;l=c.next()){o(l.value)}}catch(e){n={error:e}}finally{try{l&&!l.done&&(r=c.return)&&r.call(c)}finally{if(n)throw n.error}}return re(t)&&a.length>0&&W((function(){return f(s,void 0,void 0,(function(){var e,n;return _(this,(function(r){return e=new sr(t),null===(n=this._handler)||void 0===n||n.onMessagesDeleted(e,this.channel,i,a),[2]}))}))})),i},e.prototype._removeUnsentMessageFromView=function(e,t){var n=this._unsentMessages.findIndex((function(t){return t.reqId===e}));n>=0&&this._unsentMessages.splice(n,1)},e.prototype._getLocalMessages=function(e,t){var n=t.prevLimit,r=void 0===n?0:n,s=t.nextLimit,i=void 0===s?0:s;return f(this,void 0,void 0,(function(){var t,n,s,a,o,u,c;return _(this,(function(l){switch(l.label){case 0:return t=er.of(this._iid),r>0?[4,t.getMessagesFromCache(this._channel.url,e,"prev",this.filter,r)]:[3,2];case 1:return s=l.sent(),[3,3];case 2:s=[],l.label=3;case 3:return n=s,i>0?[4,t.getMessagesFromCache(this._channel.url,e,"next",this.filter,i)]:[3,5];case 4:return o=l.sent(),[3,6];case 5:o=[],l.label=6;case 6:if(a=o,n.length>0&&a.length>0)for(c in u=n.map((function(e){return e.messageId})),a)if(u.includes(a[c].messageId)){a.splice(parseInt(c),1);break}return[2,h(h([],d(n),!1),d(a),!1).sort((function(e,t){return t.createdAt-e.createdAt}))]}}))}))},e.prototype._getRemoteMessages=function(e,t){var n=t.prevLimit,r=void 0===n?0:n,i=t.nextLimit,a=void 0===i?0:i,o=t.source,u=void 0===o?K.REQUEST_MESSAGE:o,c=t.reverse,l=void 0!==c&&c,h=t.checkingContinuousMessages,d=void 0!==h&&h;return f(this,void 0,void 0,(function(){var t,n;return _(this,(function(i){switch(i.label){case 0:return t=Ut.of(this._iid),r>0||a>0?[4,t._getMessagesByTimestampForCollection(this._channel.url,this._channel.channelType,e,s(s({},this.filter),{isInclusive:!0,reverse:l,prevResultSize:r,nextResultSize:a,includeMetaArray:!0,includeReactions:!0,includeThreadInfo:!0,includeParentMessageInfo:!0}),u,d)]:[3,2];case 1:return n=i.sent(),[3,3];case 2:n={messages:[],isContinuousMessages:!1},i.label=3;case 3:return[2,n]}}))}))},e.prototype._checkHugeGap=function(){var e;return f(this,void 0,void 0,(function(){var t,n,r,i,a,o,u,c,l,p,m,v,g,y,C,E,b,M,N,S,U=this;return _(this,(function(I){switch(I.label){case 0:return this._messages.length>0?(t=this._syncRange.top,n=this.viewTop,r=this._syncRange.bottom,i=this.hasNext?this.viewBottom:Number.MAX_SAFE_INTEGER,[4,(a=er.of(this._iid)).getCachedMessageCountBetween(this._channel.url,this.filter,n,t)]):[3,4];case 1:return o=I.sent(),[4,a.getCachedMessageCountBetween(this._channel.url,this.filter,r,i)];case 2:return u=I.sent(),[4,ce((function(){return f(U,void 0,void 0,(function(){var e,a,c,l,p,m,v,g,y,C,E,b,M,N,S,U,I,A,w,D,L,k=this;return _(this,(function(P){switch(P.label){case 0:return e=B.of(this._iid),a=e.dispatcher,c=e.requestQueue,l=e.cacheContext,p=new hr(s({channelUrl:this._channel.url,channelType:this._channel.channelType,prevStart:n,prevEnd:t,prevCount:o,nextStart:r,nextEnd:i,nextCount:u,checkingContinuousMessages:l.localCacheEnabled},this.filter)),[4,c.send(p)];case 1:return m=P.sent(),v=m.as(dr),g=v.isHugeGap,y=v.prevMessages,C=void 0===y?[]:y,E=v.prevHasMore,b=v.isContinuousPrevMessages,M=v.nextMessages,N=void 0===M?[]:M,S=v.nextHasmore,U=v.isContinuousNextMessages,g?W((function(){return f(k,void 0,void 0,(function(){var e;return _(this,(function(t){return null===(e=this._handler)||void 0===e||e.onHugeGapDetected(),[2]}))}))})):(this._hasPrevious=E,this._hasNext=S,I=this.viewTop,A=this.viewBottom,w=Math.min.apply(Math,h([Number.MAX_SAFE_INTEGER,I],d(C.map((function(e){return e.createdAt}))),!1)),D=Math.max.apply(Math,h([0,A],d(N.map((function(e){return e.createdAt}))),!1)),a.dispatch(new T({messages:C,source:K.SYNC_MESSAGE_FILL})),a.dispatch(new T({messages:N,source:K.SYNC_MESSAGE_FILL})),this._syncRange.extends(w,D),(b||U)&&(null===(L=this._backgroundSync)||void 0===L||L.range.extends(w,D)),ID&&this._nextFill.start(D)),[2]}}))}))}),1)];case 3:return I.sent(),[3,8];case 4:c=B.of(this._iid).cacheContext,l=Math.floor(this._limit/2),p=Date.now(),I.label=5;case 5:return I.trys.push([5,7,,8]),[4,this._getRemoteMessages(p,{prevLimit:l,nextLimit:l,source:K.SYNC_MESSAGE_FILL,checkingContinuousMessages:c.localCacheEnabled})];case 6:if(m=I.sent(),v=m.messages,g=m.isContinuousMessages,v.length>0){for(y=v.map((function(e){return e.createdAt})),C=0,E=0,b=0;b=p&&E++;this._hasPrevious=C>=l,this._hasNext=E>=l,(S=this._syncRange).extends.apply(S,h([],d(y),!1)),g&&(null===(e=this._backgroundSync)||void 0===e||e.range.extends(this._syncRange.top,this._syncRange.bottom)),this._addMessagesToView(v,K.SYNC_MESSAGE_FILL)}else this._hasPrevious=!1,this._hasNext=!1;return[3,8];case 7:return(N=I.sent())instanceof V&&N.code===J.NOT_FOUND_IN_DATABASE&&(this._hasPrevious=!1,this._hasNext=!1),[3,8];case 8:return[2]}}))}))},e.prototype._loadUnsentMessages=function(){return f(this,void 0,void 0,(function(){var e,t;return _(this,(function(n){switch(n.label){case 0:return e=er.of(this._iid),t=this,[4,e.getUnsentMessagesFromCache(this._channel.url,this.filter)];case 1:return t._unsentMessages=n.sent(),[2]}}))}))},e.prototype._hasPollMessage=function(){return f(this,void 0,void 0,(function(){return _(this,(function(e){switch(e.label){case 0:return[4,er.of(this._iid).getPollMessagesFromCache(this._channel.url,Date.now()+yr,this.filter,1)];case 1:return e.sent().length>0?[2,!0]:[2,!1]}}))}))},e.prototype._refreshChannel=function(e){er.of(this._iid).refreshChannel(this.channel.url,!0,e)},e.prototype._startCheckMyMutedTimer=function(e){var t=this;this._clearCheckMyMutedTimer(),this._checkMyMutedStateTimer=setTimeout((function(){return f(t,void 0,void 0,(function(){var e,t,n,r;return _(this,(function(s){switch(s.label){case 0:this._checkMyMutedStateTimer=null,e=!0,s.label=1;case 1:return s.trys.push([1,3,4,5]),[4,this._channel.getMyMutedInfo()];case 2:return t=s.sent(),e=!t.isMuted,[3,5];case 3:return s.sent(),e=!0,[3,5];case 4:return e&&(this.channel.myMutedState=es.UNMUTED,n=new rr(ze.EVENT_CHANNEL_UNMUTED),null===(r=this._handler)||void 0===r||r.onChannelUpdated(n,this.channel)),[7];case 5:return[2]}}))}))}),e+1e3)},e.prototype._clearCheckMyMutedTimer=function(){this._checkMyMutedStateTimer&&(clearTimeout(this._checkMyMutedStateTimer),this._checkMyMutedStateTimer=null)},e.prototype.initialize=function(e){var t=this,n=new Mr;this._messages=[],this._unsentMessages=[],this._syncRange=new Xn({}),this._hasNext=!0,this._hasPrevious=!0,this._refreshChannel(ze.REFRESH_CHANNEL),E((function(){return f(t,void 0,void 0,(function(){var e;return _(this,(function(t){switch(t.label){case 0:return[4,this.channel.getMyMutedInfo()];case 1:return(e=t.sent()).isMuted&&-1!==e.remainingDuration&&this._startCheckMyMutedTimer(e.remainingDuration),[2]}}))}))}));var r=Math.floor(this._limit/2);if(e===tr.CACHE_AND_REPLACE_BY_API)this._getLocalMessages(this._startingPoint,{prevLimit:r,nextLimit:r}).then((function(e){return f(t,void 0,void 0,(function(){var t;return _(this,(function(r){switch(r.label){case 0:return t=this._filterUnderOffsetMessage(e),this._addMessagesToView(t,K.REQUEST_MESSAGE),[4,this._loadUnsentMessages()];case 1:return r.sent(),n._invokeResponse("local",null,t),[2]}}))}))})).catch((function(e){if(Q(e))throw e;n._invokeResponse("local",e,null)})).finally((function(){var e=B.of(t._iid).cacheContext;t._getRemoteMessages(t._startingPoint,{prevLimit:r,nextLimit:r,reverse:!0,checkingContinuousMessages:e.localCacheEnabled}).then((function(e){var s,i,a=e.messages,o=e.isContinuousMessages;t._messages=[];var u=t._filterUnderOffsetMessage(a);if(u.length>0){for(var c=u.map((function(e){return e.createdAt})),l=0,p=0,f=0;f=t._startingPoint&&p++}t._hasPrevious=l>=r,t._hasNext=p>=r,(s=t._syncRange).extends.apply(s,h([],d(u.map((function(e){return e.createdAt}))),!1)),o&&(null===(i=t._backgroundSync)||void 0===i||i.range.extends(t._syncRange.top,t._syncRange.bottom)),t._addMessagesToView(u,K.REQUEST_MESSAGE)}else t._hasPrevious=!1,t._hasNext=!1;n._invokeResponse("remote",null,u)})).catch((function(e){if(Q(e))throw e;n._invokeResponse("remote",e,null)}))}));var s=B.of(this._iid),i=s.cacheContext;return s.statLogCollector.put(new se({type:ie.FEATURE_LOCALCACHE,data:{use_local_cache:i.localCacheEnabled,collection_interface:{message_init_policy:e}}})),n},e.prototype.loadPrevious=function(){return f(this,void 0,void 0,(function(){var e,t,n,r=this;return _(this,(function(s){switch(s.label){case 0:return this._hasPrevious?(e=this.viewTop,t=[],[4,E((function(){return f(r,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 s.sent(),0!==t.length&&this._backgroundSync&&this._backgroundSync.isWrappingMessages(t)?[3,3]:[4,E((function(){return f(r,void 0,void 0,(function(){var n,r,s,i,a;return _(this,(function(o){switch(o.label){case 0:return n=B.of(this._iid).cacheContext,[4,this._getRemoteMessages(e,{prevLimit:this._limit,checkingContinuousMessages:n.localCacheEnabled})];case 1:return r=o.sent(),t=this._filterUnderOffsetMessage(r.messages),this._hasPrevious=t.length>=this._limit,t.length>0&&((s=this._syncRange).extends.apply(s,h([],d(t.map((function(e){return e.createdAt}))),!1)),(null===(i=this._backgroundSync)||void 0===i?void 0:i.range.overlap(this._syncRange))&&r.isContinuousMessages&&(null===(a=this._backgroundSync)||void 0===a||a.range.extends(this._syncRange.top))),[2]}}))}))}))];case 2:return s.sent(),this._addMessagesToView(t,K.REQUEST_MESSAGE),[3,4];case 3:this._hasPrevious=t.length>=this._limit,t.length>0&&((n=this._syncRange).extends.apply(n,h([],d(t.map((function(e){return e.createdAt}))),!1)),this._addMessagesToView(t,K.REQUEST_MESSAGE)),s.label=4;case 4:return[2,t];case 5:return[2,[]]}}))}))},e.prototype.loadNext=function(){var e;return f(this,void 0,void 0,(function(){var t,n,r,s=this;return _(this,(function(i){switch(i.label){case 0:return this._hasNext?(t=this.viewBottom,n=[],[4,E((function(){return f(s,void 0,void 0,(function(){var e;return _(this,(function(r){switch(r.label){case 0:return e=this._filterUnderOffsetMessage,[4,this._getLocalMessages(t,{nextLimit:this._limit})];case 1:return n=e.apply(this,[r.sent()]),[2]}}))}))}))]):[2,[]];case 1:return i.sent(),0!==n.length&&(null===(e=this._backgroundSync)||void 0===e?void 0:e.isWrappingMessages(n))?[3,3]:[4,E((function(){return f(s,void 0,void 0,(function(){var e,r,s,i,a;return _(this,(function(o){switch(o.label){case 0:return e=B.of(this._iid).cacheContext,[4,this._getRemoteMessages(t,{nextLimit:this._limit,checkingContinuousMessages:e.localCacheEnabled})];case 1:return r=o.sent(),n=this._filterUnderOffsetMessage(r.messages),this._hasNext=n.length>=this._limit,n.length>0&&((s=this._syncRange).extends.apply(s,h([],d(n.map((function(e){return e.createdAt}))),!1)),(null===(i=this._backgroundSync)||void 0===i?void 0:i.range.overlap(this._syncRange))&&r.isContinuousMessages&&(null===(a=this._backgroundSync)||void 0===a||a.range.extends(this._syncRange.bottom))),[2]}}))}))}))];case 2:return i.sent(),this._addMessagesToView(n,K.REQUEST_MESSAGE),[3,4];case 3:this._hasNext=n.length>=this._limit,n.length>0&&((r=this._syncRange).extends.apply(r,h([],d(n.map((function(e){return e.createdAt}))),!1)),this._addMessagesToView(n,K.REQUEST_MESSAGE)),i.label=4;case 4:return[2,n]}}))}))},e.prototype.removeFailedMessage=function(e){return f(this,void 0,void 0,(function(){var t;return _(this,(function(n){switch(n.label){case 0:return[4,er.of(this._iid).removeFailedMessageFromCache(e)];case 1:return n.sent(),(t=this._unsentMessages.findIndex((function(t){return t.reqId===e})))>-1&&this._unsentMessages.splice(t,1),[2]}}))}))},e.prototype.dispose=function(){var e,t,n,r=B.of(this._iid),s=r.cacheContext,i=r.dispatcher;this._clearCheckMyMutedTimer(),this._channel._updateMessageCollectionLastAccessedAt(),i.dispatch(new je({channels:[this._channel],source:ze.CHANNEL_LASTACCESSEDAT_UPDATED})),s.localCacheEnabled&&(this._prevFill.stop(),this._nextFill.stop()),null===(e=this._backgroundSync)||void 0===e||e.close(),null===(t=this._changelogSync)||void 0===t||t.close(),null===(n=this._pollChangelogSync)||void 0===n||n.close();var a=er.of(this._iid);a.unsubscribeGroupChannelEvent(this._key),a.unsubscribeMessageEvent(this._key),this._connectionEventContext&&this._connectionEventContext.close()},e}(),Sr={coverUrl:null,coverImage:null,isDistinct:null,isPublic:null,isDiscoverable:null,accessCode:null,name:null,data:null,customType:null,operatorUserIds:null,messageSurvivalSeconds:null},Ur={hidePreviousMessages:!1,allowAutoUnhide:!0},Tr=function(t){function n(e){var n=this,r=e.channelUrl,s=e.token,i=e.limit,a=e.order,o=e.mutedMemberFilter,u=e.memberStateFilter,c=e.nicknameStartsWithFilter,l=e.operatorFilter;return(n=t.call(this)||this).method=I.GET,n.path="".concat(k,"/").concat(encodeURIComponent(r),"/members"),n.params={token:s,limit:i,order:a,muted_member_filter:o,member_state_filter:u,nickname_startswith:c,operator_filter:l,show_member_is_muted:!0,show_read_receipt:!0,show_delivery_receipt:!0},n}return e(n,t),n}(w),Ir=function(t){function n(e,n){var r=t.call(this,e,n)||this;r.token=null,r.members=[];var s=n.next,i=n.members;return r.token=s,i&&i.length>0&&(r.members=i.map((function(t){return new jt(e,t)}))),r}return e(n,t),n}(D);!function(e){e.ALL="all",e.MUTED="muted",e.UNMUTED="unmuted"}(Cr||(Cr={})),function(e){e.MEMBER_NICKNAME_ALPHABETICAL="member_nickname_alphabetical",e.OPERATOR_THEN_MEMBER_ALPHABETICAL="operator_then_member_alphabetical"}(Er||(Er={})),function(e){e.ALL="all",e.JOINED="joined_only",e.INVITED="invited_only",e.INVITED_BY_FRIEND="invited_by_friend",e.INVITED_BY_NON_FRIEND="invited_by_non_friend"}(br||(br={}));var Ar=function(t){function n(e,n,r){var s,i,a,u,c=this;return(c=t.call(this,e,n,o.GROUP,r)||this).mutedMemberFilter=Cr.ALL,c.memberStateFilter=br.ALL,c.nicknameStartsWithFilter=null,c.operatorFilter=Vt.ALL,c.order=Er.MEMBER_NICKNAME_ALPHABETICAL,c.mutedMemberFilter=null!==(s=r.mutedMemberFilter)&&void 0!==s?s:Cr.ALL,c.memberStateFilter=null!==(i=r.memberStateFilter)&&void 0!==i?i:br.ALL,c.nicknameStartsWithFilter=null!==(a=r.nicknameStartsWithFilter)&&void 0!==a?a:null,c.order=null!==(u=r.order)&&void 0!==u?u:Er.MEMBER_NICKNAME_ALPHABETICAL,c}return e(n,t),n.prototype._validate=function(){return t.prototype._validate.call(this)&&i(Cr,this.mutedMemberFilter)&&i(br,this.memberStateFilter)&&(g("string",this.nicknameStartsWithFilter)||null===this.nicknameStartsWithFilter)&&i(Vt,this.operatorFilter)&&i(Er,this.order)},n.prototype.next=function(){return f(this,void 0,void 0,(function(){var e,t,n,r,i,a;return _(this,(function(o){switch(o.label){case 0:return this._validate()?this._isLoading?[3,3]:this._hasNext?(this._isLoading=!0,e=B.of(this._iid).requestQueue,t=new Tr(s(s({},this),{token:this._token})),[4,e.send(t)]):[3,2]:[3,5];case 1:return n=o.sent(),r=n.as(Ir),i=r.members,a=r.token,this._token=a,this._hasNext=!!a,this._isLoading=!1,[2,i];case 2:return[2,[]];case 3:throw V.queryInProgress;case 4:return[3,6];case 5:throw V.invalidParameters;case 6:return[2]}}))}))},n}(le),wr=function(t){function n(e){var n=this,r=e.channelUrl,s=e.userId,i=e.accessCode;return(n=t.call(this)||this).method=I.PUT,n.path="".concat(k,"/").concat(encodeURIComponent(r),"/accept"),n.params={user_id:s,access_code:i},n}return e(n,t),n}(w),Dr=function(t){function n(e,n){var r=t.call(this,e,n)||this;return r.channel=new os(e,n),r.channel.myMemberState=xt.JOINED,r}return e(n,t),n}(D),Lr=function(t){function n(e){var n=this,s=e.channelUrl,i=e.isDistinct,a=e.isPublic,o=e.isDiscoverable,u=e.coverUrl,c=e.coverImage,l=e.accessCode,h=e.name,d=e.data,p=e.customType,f=e.operatorUserIds,_=e.messageSurvivalSeconds;return(n=t.call(this)||this).method=I.PUT,n.path="".concat(k,"/").concat(encodeURIComponent(s)),n.params=r({is_distinct:i,is_public:a,is_discoverable:o,name:h,data:d,custom_type:p,cover_url:u,cover_file:c,access_code:l,operator_ids:f,message_survival_seconds:_}),n}return e(n,t),n}(w),kr=function(t){function n(e,n){var r=t.call(this,e,n)||this;return r.channel=new os(e,n),r}return e(n,t),n}(D),Pr=function(t){function n(e){var n=this,r=e.channelUrl;return(n=t.call(this)||this).method=I.DELETE,n.path="".concat(k,"/").concat(encodeURIComponent(r)),n}return e(n,t),n}(w);!function(t){function n(e,n){return t.call(this,e,n)||this}e(n,t)}(D);var xr=function(t){function n(e){var n=this,r=e.channelUrl;return(n=t.call(this)||this).method=I.DELETE,n.path="".concat(k,"/").concat(encodeURIComponent(r),"/hide"),n}return e(n,t),n}(w);!function(t){function n(){return null!==t&&t.apply(this,arguments)||this}e(n,t)}(D);var Rr=function(t){function n(e){var n=e.userId,r=e.channelUrl,s=e.countPreference,i=t.call(this)||this;return i.method=I.PUT,i.path="".concat(A,"/").concat(encodeURIComponent(n),"/count_preference/").concat(encodeURIComponent(r)),i.params={count_preference:s},i}return e(n,t),n}(w),Fr=function(t){function n(e,n){var r=t.call(this,e,n)||this;return r.countPreference=n.count_preference,r}return e(n,t),n}(D),Or=function(t){function n(e){var n=this,r=e.channelUrl;return(n=t.call(this)||this).method=I.PUT,n.path="".concat(k,"/").concat(encodeURIComponent(r),"/reset_user_history"),n}return e(n,t),n}(w),Hr=function(t){function n(e,n){var r=t.call(this,e,n)||this;r.messageOffsetTimestamp=null;var s=n.ts_message_offset;return r.messageOffsetTimestamp=null!=s?s:null,r}return e(n,t),n}(D),Gr=s(s({},ke),{scheduledAt:null,file:null,fileUrl:null,fileName:null,mimeType:null,fileSize:null,thumbnailSizes:null,requireAuth:!1}),Vr=s(s({},xe),{scheduledAt:null}),qr=function(t){function n(e){var n,s=this;s=t.call(this)||this;var i=null;e.mentionType===he.USERS&&(e.mentionedUserIds?i=e.mentionedUserIds:e.mentionedUsers&&(i=e.mentionedUsers.map((function(e){return e.userId}))));var a=e.channelType,o=e.channelUrl,u=e.scheduledMessageId;return s.method=I.PUT,s.path="".concat(ne(a),"/").concat(encodeURIComponent(o),"/scheduled_messages/").concat(encodeURIComponent(u)),s.params=r({req_id:e.reqId,scheduled_at:e.scheduledAt,message_type:de.FILE,url:e.fileUrl,file_name:e.fileName,file_size:e.fileSize,file_type:e.mimeType,thumbnails:e.thumbnailSizes?e.thumbnailSizes.map((function(e){return Tt.payloadify(e)})):[],custom_type:e.customType,data:e.data,require_auth:e.requireAuth,mention_type:e.mentionType,mentioned_user_ids:i,sorted_metaarray:null===(n=e.metaArrays)||void 0===n?void 0:n.map((function(e){return It.payloadify(e)})),apple_critical_alert_options:At.payloadify(e.appleCriticalAlertOptions),push_option:e.pushNotificationDeliveryOption}),s}return e(n,t),n}(w),Br=function(t){function n(e,n){var r=t.call(this,e,n)||this;return r.message=new Nt(e,n),r}return e(n,t),n}(D),jr=function(t){function n(e){var n,s=this;s=t.call(this)||this;var i=null;e.mentionType===he.USERS&&(e.mentionedUserIds?i=e.mentionedUserIds:e.mentionedUsers&&(i=e.mentionedUsers.map((function(e){return e.userId}))));var a=e.channelType,o=e.channelUrl,u=e.scheduledMessageId;return s.method=I.PUT,s.path="".concat(ne(a),"/").concat(encodeURIComponent(o),"/scheduled_messages/").concat(encodeURIComponent(u)),s.params=r({req_id:e.reqId,scheduled_at:e.scheduledAt,message_type:de.USER,message:e.message,custom_type:e.customType,data:e.data,mention_type:e.mentionType,mentioned_user_ids:i,sorted_metaarray:null===(n=e.metaArrays)||void 0===n?void 0:n.map((function(e){return It.payloadify(e)})),apple_critical_alert_options:At.payloadify(e.appleCriticalAlertOptions),target_langs:e.translationTargetLanguages,push_option:e.pushNotificationDeliveryOption}),s}return e(n,t),n}(w);!function(t){function n(e,n){var r=t.call(this,e,n)||this;return r.message=new Mt(e,n),r}e(n,t)}(D);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=I.DELETE,n.path="".concat(ne(r),"/").concat(encodeURIComponent(s),"/scheduled_messages/").concat(encodeURIComponent(i)),n}return e(n,t),n}(w),Qr=function(t){function n(e){var n=t.call(this)||this,r=e.channelType,s=e.channelUrl,i=e.scheduledMessageId;return n.method=I.POST,n.path="".concat(ne(r),"/").concat(encodeURIComponent(s),"/scheduled_messages/").concat(encodeURIComponent(i),"/send_now"),n}return e(n,t),n}(w),Wr=function(t){function n(e){var n=e.userId,r=e.channelUrl,s=e.pushTriggerOption,i=t.call(this)||this;return i.method=I.PUT,i.path="".concat(A,"/").concat(encodeURIComponent(n),"/push_preference/").concat(encodeURIComponent(r)),i.params={push_trigger_option:s},i}return e(n,t),n}(w),Kr=function(t){function n(e,n){var r=t.call(this,e,n)||this;return r.pushTriggerOption=n.push_trigger_option,r.enabled=n.enable,r}return e(n,t),n}(D),Yr=function(t){function n(e){var n=e.userId,r=e.channelUrl,s=t.call(this)||this;return s.method=I.GET,s.path="".concat(A,"/").concat(encodeURIComponent(n),"/push_preference/").concat(encodeURIComponent(r)),s}return e(n,t),n}(w),Jr=function(t){function n(e,n){var r=t.call(this,e,n)||this;return r.pushTriggerOption=n.push_trigger_option,r.enabled=n.enable,r}return e(n,t),n}(D),Xr=function(t){function n(e){var n=e.channelType,r=e.channelUrl,s=e.messageId,i=t.call(this)||this;return i.method=I.POST,i.path="".concat(ne(n),"/").concat(encodeURIComponent(r),"/messages/").concat(s,"/pin"),i}return e(n,t),n}(w);!function(t){function n(e,n){return t.call(this,e,n)||this}e(n,t)}(D);var Zr=function(t){function n(e){var n=e.channelType,r=e.channelUrl,s=e.messageId,i=t.call(this)||this;return i.method=I.DELETE,i.path="".concat(ne(n),"/").concat(encodeURIComponent(r),"/messages/").concat(s,"/pin"),i}return e(n,t),n}(w);!function(t){function n(e,n){return t.call(this,e,n)||this}e(n,t)}(D);var $r,es,ts,ns=function(t){function n(e,n){var r=t.call(this,e)||this;return r.message=bt(e,n.message),r}return e(n,t),n}(c),rs=function(t){function n(e){var n=this,s=e.channelType,i=e.channelUrl,a=e.limit,o=e.token,u=e.includeReactions,c=e.includeMetaArray,l=e.includeParentMessageInfo,h=e.includeThreadInfo,d=e.includePollDetails;return(n=t.call(this)||this).method=I.GET,n.path="".concat(ne(s),"/").concat(encodeURIComponent(i),"/pinned_messages"),n.params=r({limit:a,token:o,include_reactions:u,with_sorted_meta_array:c,include_thread_info:h,include_parent_message_info:l,include_poll_details:d}),n}return e(n,t),n}(w),ss=function(t){function n(e,n){var r=t.call(this,e,n)||this;r.hasMore=null,r.token=null;var s=n.pinned_messages,i=n.has_more,a=n.next;return r.pinnedMessages=s.map((function(t){return new ns(e,t)})),r.hasMore=i,r.token=a,r}return e(n,t),n}(D),is=function(t){function n(e,n,r,s){var i=t.call(this,e,n,r,s)||this;return i.includeMetaArray=s.includeMetaArray,i.includeReactions=s.includeReactions,i.includeParentMessageInfo=s.includeParentMessageInfo,i.includeThreadInfo=s.includeThreadInfo,i.includePollDetails=s.includePollDetails,i}return e(n,t),n.prototype._validate=function(){return t.prototype._validate.call(this)&&g("boolean",this.includeMetaArray,!0)&&g("boolean",this.includeReactions,!0)&&g("boolean",this.includeParentMessageInfo,!0)&&g("boolean",this.includeThreadInfo,!0)&&g("boolean",this.includePollDetails,!0)},n.prototype.next=function(){return f(this,void 0,void 0,(function(){var e,t,n,r,i,a,o;return _(this,(function(u){switch(u.label){case 0:return this._validate()?this._isLoading?[3,3]:this._hasNext?(this._isLoading=!0,e=B.of(this._iid).requestQueue,t=new rs(s(s({},this),{token:this._token})),[4,e.send(t)]):[3,2]:[3,5];case 1:return n=u.sent(),r=n.as(ss),i=r.pinnedMessages,a=r.hasMore,o=r.token,this._token=o,this._hasNext=!!a,this._isLoading=!1,[2,i];case 2:return[2,[]];case 3:throw V.queryInProgress;case 4:return[3,6];case 5:throw V.invalidParameters;case 6:return[2]}}))}))},n}(le);!function(e){e.ALL="all",e.UNREAD_MESSAGE_COUNT_ONLY="unread_message_count_only",e.UNREAD_MENTION_COUNT_ONLY="unread_mention_count_only",e.OFF="off"}($r||($r={})),function(e){e.MUTED="muted",e.UNMUTED="unmuted"}(es||(es={})),function(e){e.UNHIDDEN="unhidden",e.HIDDEN_ALLOW_AUTO_UNHIDE="hidden_allow_auto_unhide",e.HIDDEN_PREVENT_AUTO_UNHIDE="hidden_prevent_auto_unhide"}(ts||(ts={}));var as,os=function(t){function n(e,n){var r,c,l,p,f,_,m,v,y,C,E,b,M,N,S,U,T,I,A,w=this;return(w=t.call(this,e,n)||this)._unreadMemberStateMap=new Map,w._undeliveredMemberStateMap=new Map,w._typingStatus=new Map,w._lastMemberCountUpdated=0,w._typingStarted=0,w._typingEnded=0,w.isDistinct=!1,w.isSuper=!1,w.isBroadcast=!1,w.isExclusive=!1,w.isPublic=!1,w.isDiscoverable=!0,w.isAccessCodeRequired=!1,w.isPushEnabled=!1,w.unreadMessageCount=0,w.unreadMentionCount=0,w.members=[],w.memberCount=0,w.joinedMemberCount=0,w.hiddenState=ts.UNHIDDEN,w.lastMessage=null,w.messageOffsetTimestamp=0,w.messageSurvivalSeconds=-1,w.myMemberState=xt.NONE,w.myRole=a.NONE,w.myMutedState=es.UNMUTED,w.myLastRead=0,w.myCountPreference=$r.ALL,w.myPushTriggerOption=fe.DEFAULT,w.inviter=null,w.invitedAt=0,w.joinedAt=0,w.pinnedMessageIds=[],w.lastPinnedMessage=null,w._pinnedMessagesUpdatedAt=0,w._myMutedRemainingTime=-1,w.channelType=o.GROUP,w.isDistinct=null!==(c=n.is_distinct)&&void 0!==c&&c,w.isSuper=null!==(l=n.is_super)&&void 0!==l&&l,w.isBroadcast=null!==(p=n.is_broadcast)&&void 0!==p&&p,w.isExclusive=null!==(f=n.is_exclusive)&&void 0!==f&&f,w.isPublic=null!==(_=n.is_public)&&void 0!==_&&_,w.isDiscoverable=null!==(m=n.is_discoverable)&&void 0!==m?m:w.isPublic,w.isAccessCodeRequired=null!==(v=n.is_access_code_required)&&void 0!==v&&v,w.isPushEnabled=null!==(y=n.is_push_enabled)&&void 0!==y&&y,Array.isArray(n.members)&&(r=w.members).push.apply(r,h([],d(n.members.map((function(e){return new jt(w._iid,e)}))),!1)),w.memberCount=null!==(C=n.member_count)&&void 0!==C?C:0,w.joinedMemberCount=null!==(E=n.joined_member_count)&&void 0!==E?E:0,w.hiddenState=i(ts,n.hidden_state)?n.hidden_state:ts.UNHIDDEN,w.messageOffsetTimestamp=null!==(b=n.ts_message_offset)&&void 0!==b?b:0,w.messageSurvivalSeconds=null!==(M=n.message_survival_seconds)&&void 0!==M?M:-1,w.lastMessage=n.last_message?bt(w._iid,s({channel_type:w.channelType},n.last_message)):null,n.read_receipt&&Object.keys(n.read_receipt).forEach((function(e){g("number",n.read_receipt[e])&&w._updateUnreadMemberState(e,n.read_receipt[e])})),n.delivery_receipt&&Object.keys(n.delivery_receipt).forEach((function(e){g("number",n.delivery_receipt[e])&&w._updateUndeliveredMemberState(e,n.delivery_receipt[e])})),w.myMemberState=i(xt,n.member_state)?n.member_state:xt.NONE,w.myRole=i(a,n.my_role)?n.my_role:a.NONE,i(es,n.is_muted)?w.myMutedState=n.is_muted:g("boolean",n.is_muted)?w.myMutedState=n.is_muted?es.MUTED:es.UNMUTED:w.myMutedState=es.UNMUTED,w.myCountPreference=i($r,n.count_preference)?n.count_preference:$r.ALL,w.myPushTriggerOption=i(fe,n.push_trigger_option)?n.push_trigger_option:fe.ALL,w.myLastRead=null!==(N=n.user_last_read)&&void 0!==N?N:0,w.inviter=n.inviter?new u(w._iid,n.inviter):null,w.invitedAt=null!==(S=n.invited_at)&&void 0!==S?S:0,w.joinedAt=null!==(U=n.joined_ts)&&void 0!==U?U:0,w._updateUnreadCount(null!==(T=n.unread_message_count)&&void 0!==T?T:0,null!==(I=n.unread_mention_count)&&void 0!==I?I:0),w.pinnedMessageIds=null!==(A=n.pinned_message_ids)&&void 0!==A?A:[],w.lastPinnedMessage=n.latest_pinned_message?bt(w._iid,s({channel_type:w.channelType},n.latest_pinned_message)):null,w}return e(n,t),Object.defineProperty(n.prototype,"isHidden",{get:function(){return this.hiddenState!==ts.UNHIDDEN},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"isTyping",{get:function(){return this._typingStatus.size>0},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"cachedUnreadMemberState",{get:function(){var e,t,n={};try{for(var r=m(this._unreadMemberStateMap),s=r.next();!s.done;s=r.next()){var i=d(s.value,2),a=i[0],o=i[1];n[a]=o}}catch(t){e={error:t}}finally{try{s&&!s.done&&(t=r.return)&&t.call(r)}finally{if(e)throw e.error}}return n},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"cachedUndeliveredMemberState",{get:function(){var e,t,n={};try{for(var r=m(this._undeliveredMemberStateMap),s=r.next();!s.done;s=r.next()){var i=d(s.value,2),a=i[0],o=i[1];n[a]=o}}catch(t){e={error:t}}finally{try{s&&!s.done&&(t=r.return)&&t.call(r)}finally{if(e)throw e.error}}return n},enumerable:!1,configurable:!0}),n.payloadify=function(e){return e?r(s(s({},t.payloadify.call(this,e)),{is_access_code_required:e.isAccessCodeRequired,is_distinct:e.isDistinct,is_super:e.isSuper,is_broadcast:e.isBroadcast,is_exclusive:e.isExclusive,is_public:e.isPublic,is_discoverable:e.isDiscoverable,is_muted:e.myMutedState,is_push_enabled:e.isPushEnabled,unread_message_count:e.unreadMessageCount,unread_mention_count:e.unreadMentionCount,push_trigger_option:e.myPushTriggerOption,count_preference:e.myCountPreference,hidden_state:e.hiddenState,member_count:e.memberCount,joined_member_count:e.joinedMemberCount,member_state:e.myMemberState,my_role:e.myRole,user_last_read:e.myLastRead,ts_message_offset:e.messageOffsetTimestamp,message_survival_seconds:e.messageSurvivalSeconds,read_receipt:e.cachedUnreadMemberState,delivery_receipt:e.cachedUndeliveredMemberState,members:e.members.map((function(e){return jt.payloadify(e)})),last_message:wt(e.lastMessage),inviter:e.inviter?u.payloadify(e.inviter):null,invited_at:e.invitedAt,joined_ts:e.joinedAt,pinned_message_ids:e.pinnedMessageIds,latest_pinned_message:wt(e.lastPinnedMessage)})):null},n.prototype._shouldUpdateLastMessageWith=function(e){return!(e instanceof Ct&&e.parentMessageId>0&&!e.replyToChannel)&&(!this.lastMessage||this.lastMessage.createdAt=0)if(this.myCountPreference===$r.ALL||this.myCountPreference===$r.UNREAD_MESSAGE_COUNT_ONLY)if(this.isExclusive||this.isSuper||this.isBroadcast){var n=B.of(this._iid).maxSuperGroupChannelUnreadCount;this.unreadMessageCount=n&&e>=n?n:e}else this.unreadMessageCount=e;else this.unreadMessageCount=0;else this.unreadMessageCount=0;"number"==typeof t&&t>=0&&(this.myCountPreference===$r.ALL||this.myCountPreference===$r.UNREAD_MENTION_COUNT_ONLY)?this.unreadMentionCount=t:this.unreadMentionCount=0},n.prototype._updateUnreadMemberState=function(e,t){var n=this._unreadMemberStateMap.get(e);return(!n||n0?this._typingStatus.set(e.userId,{user:e,ts:t}):this._typingStatus.delete(e.userId)},n.prototype._clearTypingStatus=function(){this._typingStatus.clear(),this._typingStarted=0,this._typingEnded=0},n.prototype._setLatestMemberCount=function(e,t,n){var r=!1;return n>=this._lastMemberCountUpdated&&(this._lastMemberCountUpdated=n,r=e!==this.memberCount||t!==this.joinedMemberCount,this.memberCount=e,this.joinedMemberCount=t),r},n.prototype.isReadMessage=function(e){var t=B.of(this._iid).sdkState,n=this._unreadMemberStateMap.get(t.userId);return n&&n>=e.createdAt},n.prototype.serialize=function(){var e=this;return O(this,(function(t){t.cachedUnreadMemberState=e.cachedUnreadMemberState,t.cachedUndeliveredMemberState=e.cachedUndeliveredMemberState}))},n.prototype.createMessageCollection=function(e){return void 0===e&&(e={}),new Nr(this._iid,s({channel:this},e))},n.prototype.createMemberListQuery=function(e){return void 0===e&&(e={}),new Ar(this._iid,this.url,e)},n.prototype.createPinnedMessageListQuery=function(e){return void 0===e&&(e={}),new is(this._iid,this.url,this.channelType,e)},n.prototype.addMember=function(e,t){if(void 0===t&&(t=0),!this.isExclusive&&!this.isSuper&&!this.isBroadcast){var n=this.members.findIndex((function(t){return t.userId===e.userId}));if(n>-1){var r=this.members[n];r.state===xt.JOINED&&(e.state=r.state),this.members.splice(n,1),this.memberCount--}this.members.push(e),this.memberCount++,this._updateUnreadMemberState(e.userId,t),this._updateUndeliveredMemberState(e.userId,t)}},n.prototype.removeMember=function(e){if(!this.isExclusive&&!this.isSuper&&!this.isBroadcast){var t=e instanceof jt?e.userId:e,n=this.members.findIndex((function(e){return e.userId===t}));if(n>-1)return this.members.splice(n,1),this.memberCount--,!0}return!1},n.prototype.getUnreadMemberCount=function(e){var t,n;if(e instanceof Ct&&!this.isExclusive&&!this.isSuper&&!this.isBroadcast){var r=B.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===xt.JOINED&&e.sender.userId!==u.userId)(this.cachedUnreadMemberState[u.userId]||0)=e.createdAt&&i.push(a))})),i},n.prototype.getUnreadMembers=function(e,t){var n=this;void 0===t&&(t=!1);var r=B.of(this._iid).sdkState;if(!r.userId||this.isExclusive||this.isSuper||this.isBroadcast)return[];var s=e instanceof Ct?e.sender:null,i=[];return this.members.forEach((function(a){(t||a.userId!==r.userId&&a.userId!==(null==s?void 0:s.userId))&&(n._unreadMemberStateMap.get(a.userId)=t&&(e._typingStatus.delete(i),r=!0)})),r},n.prototype.refresh=function(){return f(this,void 0,void 0,(function(){var e,t,n,r,s,i;return _(this,(function(a){switch(a.label){case 0:return e=B.of(this._iid),t=e.requestQueue,n=e.dispatcher,r=new cn({channelUrl:this.url}),[4,t.send(r)];case 1:return s=a.sent(),i=s.as(ln).channel,n.dispatch(new je({channels:[i],source:ze.REQUEST_CHANNEL})),[2,i]}}))}))},n.prototype.freeze=function(){return f(this,void 0,void 0,(function(){return _(this,(function(e){switch(e.label){case 0:return[4,t.prototype.freeze.call(this)];case 1:return e.sent(),B.of(this._iid).dispatcher.dispatch(new je({channels:[this],source:ze.EVENT_CHANNEL_HIDDEN})),[2]}}))}))},n.prototype.unfreeze=function(){return f(this,void 0,void 0,(function(){return _(this,(function(e){switch(e.label){case 0:return[4,t.prototype.unfreeze.call(this)];case 1:return e.sent(),B.of(this._iid).dispatcher.dispatch(new je({channels:[this],source:ze.EVENT_CHANNEL_UNHIDDEN})),[2]}}))}))},n.prototype.updateChannel=function(e){return f(this,void 0,void 0,(function(){var t,n,r,i,a,o,u;return _(this,(function(c){switch(c.label){case 0:return t=s(s({},Sr),e),Y(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(V.invalidParameters),n=B.of(this._iid),r=n.dispatcher,i=n.requestQueue,a=new Lr(s({channelUrl:this.url},t)),[4,i.send(a)];case 1:return o=c.sent(),u=o.as(kr).channel,r.dispatch(new je({channels:[u],source:ze.EVENT_CHANNEL_UPDATED})),[2,u]}}))}))},n.prototype.invite=function(e){return f(this,void 0,void 0,(function(){return _(this,(function(t){return Y(e.every((function(e){return e instanceof u}))).throw(V.invalidParameters),[2,this.inviteWithUserIds(e.map((function(e){return e.userId})))]}))}))},n.prototype.inviteWithUserIds=function(e){return f(this,void 0,void 0,(function(){var t,n,r,s,i,a;return _(this,(function(o){switch(o.label){case 0:return Y(v("string",e)).throw(V.invalidParameters),t=B.of(this._iid),n=t.dispatcher,r=t.requestQueue,s=new Ln({channelUrl:this.url,userIds:e}),[4,r.send(s)];case 1:return i=o.sent(),a=i.as(kn).channel,n.dispatch(new je({channels:[a],source:ze.EVENT_CHANNEL_INVITED})),[2,a]}}))}))},n.prototype.join=function(e){return void 0===e&&(e=null),f(this,void 0,void 0,(function(){var t,n,r,s,i,a,o;return _(this,(function(u){switch(u.label){case 0:return Y(g("string",e)||null===e).throw(V.invalidParameters),t=B.of(this._iid),n=t.dispatcher,r=t.sdkState,s=t.requestQueue,i=new Tn({channelUrl:this.url,userId:r.userId,accessCode:e}),[4,s.send(i)];case 1:return a=u.sent(),(o=a.as(In).channel).myMemberState=this.myMemberState=xt.JOINED,n.dispatch(new je({channels:[o],source:ze.EVENT_CHANNEL_JOINED})),[2,this]}}))}))},n.prototype.leave=function(e){return void 0===e&&(e=!1),f(this,void 0,void 0,(function(){var t,n,r,s;return _(this,(function(i){switch(i.label){case 0:return t=B.of(this._iid),n=t.sdkState,r=t.requestQueue,s=new wn({channelUrl:this.url,userId:n.userId,shouldRemoveOperatorStatus:e}),[4,r.send(s)];case 1:return i.sent(),this.myMemberState=xt.NONE,[2]}}))}))},n.prototype.acceptInvitation=function(e){return void 0===e&&(e=null),f(this,void 0,void 0,(function(){var t,n,r,s,i,a,o;return _(this,(function(u){switch(u.label){case 0:return Y(g("string",e)||null===e).throw(V.invalidParameters),t=B.of(this._iid),n=t.dispatcher,r=t.sdkState,s=t.requestQueue,i=new wr({channelUrl:this.url,userId:r.userId,accessCode:e}),[4,s.send(i)];case 1:return a=u.sent(),(o=a.as(Dr).channel).myMemberState=this.myMemberState=xt.JOINED,n.dispatch(new je({channels:[o],source:ze.EVENT_CHANNEL_ACCEPTED_INVITE})),[2,this]}}))}))},n.prototype.declineInvitation=function(){return f(this,void 0,void 0,(function(){var e,t,n,r;return _(this,(function(s){switch(s.label){case 0:return e=B.of(this._iid),t=e.sdkState,n=e.requestQueue,r=new xn({channelUrl:this.url,userId:t.userId}),[4,n.send(r)];case 1:return s.sent(),this.myMemberState=xt.NONE,[2,this]}}))}))},n.prototype.sendUserMessage=function(e){var n=this,r=new Dt,s=B.of(this._iid).dispatcher,i=nt.of(this._iid);return t.prototype.sendUserMessage.call(this,e).onPending((function(e){i.completeCurrentAndProcessNextAutoResend(e),r._trigger(null,e)})).onFailed((function(e,t){t&&i.completeCurrentAndProcessNextAutoResend(t),r._trigger(e,t)})).onSucceeded((function(e){n.hiddenState===ts.HIDDEN_ALLOW_AUTO_UNHIDE&&(n.hiddenState=ts.UNHIDDEN),i.completeCurrentAndProcessNextAutoResend(e),n._shouldUpdateLastMessageWith(e)&&(n.lastMessage=e),er.of(n._iid).handlers.map((function(e){return e.onChannelChanged(n)})),s.dispatch(new je({channels:[n],source:ze.EVENT_MESSAGE_SENT})),r._trigger(null,e)})),r},n.prototype.updateUserMessage=function(e,n){return f(this,void 0,void 0,(function(){var r,s,i,a,o=this;return _(this,(function(u){switch(u.label){case 0:return r=B.of(this._iid).dispatcher,[4,t.prototype.updateUserMessage.call(this,e,n)];case 1:return s=u.sent(),i=!1,!s.silent&&this._shouldUpdateLastMessageWith(s)&&(this.lastMessage=s,i=!0),a=!1,this.lastPinnedMessage&&this.lastPinnedMessage.messageId===s.messageId&&(this.lastPinnedMessage=s,i=!0,a=!0),i&&(er.of(this._iid).handlers.map((function(e){return e.onChannelChanged(o)})),r.dispatch(new je({channels:[this],source:a?ze.EVENT_PINNED_MESSAGE_UPDATED:ze.EVENT_MESSAGE_UPDATED}))),a&&er.of(this._iid).handlers.map((function(e){return e.onPinnedMessageUpdated(o)})),r.dispatch(new T({messages:[s],source:K.EVENT_MESSAGE_UPDATED})),[2,s]}}))}))},n.prototype._autoResendUserMessage=function(e){var n=this,r=new Dt,s=B.of(this._iid).dispatcher,i=nt.of(this._iid);return t.prototype._autoResendUserMessage.call(this,e).onPending((function(e){i.completeCurrentAndProcessNextAutoResend(e),r._trigger(null,e)})).onFailed((function(e,t){i.completeCurrentAndProcessNextAutoResend(t),r._trigger(e,t)})).onSucceeded((function(e){var t=er.of(n._iid);i.completeCurrentAndProcessNextAutoResend(e),n._shouldUpdateLastMessageWith(e)&&(n.lastMessage=e),t.handlers.map((function(e){return e.onChannelChanged(n)})),s.dispatch(new je({channels:[n],source:ze.EVENT_MESSAGE_SENT})),r._trigger(null,e)})),r},n.prototype.sendFileMessage=function(e){var n=this,r=new Dt,s=B.of(this._iid).dispatcher,i=nt.of(this._iid);return t.prototype.sendFileMessage.call(this,e).onPending((function(e){i.completeCurrentAndProcessNextAutoResend(e),r._trigger(null,e)})).onFailed((function(e,t){t&&i.completeCurrentAndProcessNextAutoResend(t),r._trigger(e,t)})).onSucceeded((function(e){var t=er.of(n._iid);i.completeCurrentAndProcessNextAutoResend(e),n._shouldUpdateLastMessageWith(e)&&(n.lastMessage=e),t.handlers.map((function(e){return e.onChannelChanged(n)})),s.dispatch(new je({channels:[n],source:ze.EVENT_MESSAGE_SENT})),r._trigger(null,e)})),r},n.prototype.updateFileMessage=function(e,n){return f(this,void 0,void 0,(function(){var r,s,i,a,o=this;return _(this,(function(u){switch(u.label){case 0:return r=B.of(this._iid).dispatcher,[4,t.prototype.updateFileMessage.call(this,e,n)];case 1:return s=u.sent(),i=!1,!s.silent&&this._shouldUpdateLastMessageWith(s)&&(this.lastMessage=s,i=!0),a=!1,this.lastPinnedMessage&&this.lastPinnedMessage.messageId===s.messageId&&(this.lastPinnedMessage=s,i=!0,a=!0),i&&(er.of(this._iid).handlers.map((function(e){return e.onChannelChanged(o)})),r.dispatch(new je({channels:[this],source:a?ze.EVENT_PINNED_MESSAGE_UPDATED:ze.EVENT_MESSAGE_UPDATED}))),a&&er.of(this._iid).handlers.map((function(e){return e.onPinnedMessageUpdated(o)})),r.dispatch(new T({messages:[s],source:K.EVENT_MESSAGE_UPDATED})),[2,s]}}))}))},n.prototype._autoResendFileMessage=function(e){var n=this,r=new Dt,s=B.of(this._iid).dispatcher,i=nt.of(this._iid);return t.prototype._autoResendFileMessage.call(this,e).onPending((function(e){i.completeCurrentAndProcessNextAutoResend(e),r._trigger(null,e)})).onFailed((function(e,t){i.completeCurrentAndProcessNextAutoResend(t),r._trigger(e,t)})).onSucceeded((function(e){var t=er.of(n._iid);i.completeCurrentAndProcessNextAutoResend(e),n._shouldUpdateLastMessageWith(e)&&(n.lastMessage=e),t.handlers.map((function(e){return e.onChannelChanged(n)})),s.dispatch(new je({channels:[n],source:ze.EVENT_MESSAGE_SENT})),r._trigger(null,e)})),r},n.prototype.deleteMessage=function(e){return f(this,void 0,void 0,(function(){return _(this,(function(n){switch(n.label){case 0:return[4,t.prototype.deleteMessage.call(this,e)];case 1:return n.sent(),0===e.messageId&&e instanceof Ct&&B.of(this._iid).dispatcher.dispatch(new S({reqId:e.reqId,source:K.EVENT_MESSAGE_DELETED})),[2]}}))}))},n.prototype.hide=function(e){return f(this,void 0,void 0,(function(){var t,n,r,i,a,o,u,c;return _(this,(function(l){switch(l.label){case 0:return t=s(s({},Ur),e),Y(function(e){return g("boolean",e.hidePreviousMessages)&&g("boolean",e.allowAutoUnhide)}(t)).throw(V.invalidParameters),n=B.of(this._iid),r=n.dispatcher,i=n.sdkState,a=n.requestQueue,o=new qn(s({channelUrl:this.url,userId:i.userId},t)),[4,a.send(o)];case 1:return u=l.sent(),c=u.as(Bn).messageOffsetTimestamp,this.hiddenState=t.allowAutoUnhide?ts.HIDDEN_ALLOW_AUTO_UNHIDE:ts.HIDDEN_PREVENT_AUTO_UNHIDE,t.hidePreviousMessages&&this._updateUnreadCount(0,0),c&&(this.messageOffsetTimestamp=c),r.dispatch(new je({channels:[this],source:ze.EVENT_CHANNEL_HIDDEN})),[2,this]}}))}))},n.prototype.unhide=function(){return f(this,void 0,void 0,(function(){var e,t,n,r;return _(this,(function(s){switch(s.label){case 0:return e=B.of(this._iid),t=e.dispatcher,n=e.requestQueue,r=new xr({channelUrl:this.url}),[4,n.send(r)];case 1:return s.sent(),this.hiddenState=ts.UNHIDDEN,t.dispatch(new je({channels:[this],source:ze.EVENT_CHANNEL_UNHIDDEN})),[2,this]}}))}))},n.prototype.delete=function(){return f(this,void 0,void 0,(function(){var e,t;return _(this,(function(n){switch(n.label){case 0:return e=B.of(this._iid).requestQueue,t=new Pr({channelUrl:this.url}),[4,e.send(t)];case 1:return n.sent(),[2]}}))}))},n.prototype.markAsRead=function(){return f(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=B.of(this._iid),t=e.sdkState,n=e.dispatcher,r=e.requestQueue,s=new Fn({channelUrl:this.url}),[4,r.send(s)];case 1:return i=u.sent(),a=i.as(On).readStatus,this._updateUnreadMemberState(t.userId,a.readAt),(this.unreadMessageCount>0||this.unreadMentionCount>0)&&(this._updateUnreadCount(0,0),er.of(this._iid).handlers.map((function(e){return e.onChannelChanged(o)}))),n.dispatch(new je({channels:[this],source:ze.EVENT_CHANNEL_READ})),[2]}}))}))},n.prototype.markAsDelivered=function(){return f(this,void 0,void 0,(function(){var e,t,n,r;return _(this,(function(s){switch(s.label){case 0:return e=B.of(this._iid),t=e.sdkState,n=e.requestQueue,r=new Hn({channelUrl:this.url,userId:t.userId}),[4,n.send(r)];case 1:return s.sent(),[2]}}))}))},n.prototype.startTyping=function(){return f(this,void 0,void 0,(function(){var e,t,n,r,s;return _(this,(function(i){return e=B.of(this._iid),t=e.requestQueue,n=e.typingIndicatorThrottle,(r=(new Date).getTime())-this._typingStarted>=n&&(this._typingStarted=r,this._typingEnded=0,s=new zn({channelUrl:this.url,time:this._typingStarted}),t.send(s)),[2]}))}))},n.prototype.endTyping=function(){return f(this,void 0,void 0,(function(){var e,t,n,r,s;return _(this,(function(i){return e=B.of(this._iid),t=e.requestQueue,n=e.typingIndicatorThrottle,(r=(new Date).getTime())-this._typingEnded>=n&&(this._typingStarted=0,this._typingEnded=r,s=new Wn({channelUrl:this.url,time:this._typingStarted}),t.send(s)),[2]}))}))},n.prototype.createScheduledUserMessage=function(e){e=s(s({},rt),e),Y(st(e)).throw(V.invalidParameters);var t=new Dt;return this._createScheduledUserMessage(e,t),t},n.prototype.updateScheduledUserMessage=function(e,t){return f(this,void 0,void 0,(function(){var n,r,i,a;return _(this,(function(o){switch(o.label){case 0:return n=s(s({},Vr),t),Y(function(e){return Re(e)&&g("number",e.scheduledAt,!0)}(n)).throw(V.invalidParameters),r=B.of(this._iid).requestQueue,i=new jr(s({reqId:this._generateRequestId(),scheduledMessageId:e,channelType:this.channelType,channelUrl:this.url},n)),[4,r.send(i)];case 1:return a=o.sent(),[2,a.as(Oe).message]}}))}))},n.prototype.createScheduledFileMessage=function(e){var t=this;e=s(s({},it),e),Y(at(e)).throw(V.invalidParameters);var n=Date.now(),r=this._generateRequestId(),i=new Dt;return pe(He).then((function(){var s=t._createPendingScheduledFileMessage(e,r,n);W((function(){return f(t,void 0,void 0,(function(){return _(this,(function(e){return[2,i._trigger(null,s)]}))}))}))})),y(e.file)?this._uploadFileAndUpdateParams(e).then((function(){return t._createScheduledFileMessage(e,i,r,n)})):this._createScheduledFileMessage(e,i,r,n),i},n.prototype.updateScheduledFileMessage=function(e,t){return f(this,void 0,void 0,(function(){var n,r,i;return _(this,(function(a){switch(a.label){case 0:return n=s(s({},Gr),t),Y(function(e){return Pe(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})))}(n)).throw(V.invalidParameters),y(n.file)?[4,this._uploadFileAndUpdateParams(n)]:[3,2];case 1:a.sent(),a.label=2;case 2:return r=new qr(s({reqId:this._generateRequestId(),scheduledMessageId:e,channelType:this.channelType,channelUrl:this.url},n)),[4,B.of(this._iid).requestQueue.send(r)];case 3:return i=a.sent(),[2,i.as(Br).message]}}))}))},n.prototype.cancelScheduledMessage=function(e){return f(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,B.of(this._iid).requestQueue.send(t)];case 1:return n.sent(),[2]}}))}))},n.prototype.sendScheduledMessageNow=function(e){return f(this,void 0,void 0,(function(){var t;return _(this,(function(n){switch(n.label){case 0:return t=new Qr({scheduledMessageId:e,channelType:this.channelType,channelUrl:this.url}),[4,B.of(this._iid).requestQueue.send(t)];case 1:return n.sent(),[2]}}))}))},n.prototype.getMyPushTriggerOption=function(){return f(this,void 0,void 0,(function(){var e,t,n,r,s,i;return _(this,(function(a){switch(a.label){case 0:return e=B.of(this._iid),t=e.sdkState,n=e.requestQueue,r=new Yr({userId:t.userId,channelUrl:this.url}),[4,n.send(r)];case 1:return s=a.sent(),i=s.as(Jr).pushTriggerOption,this.myPushTriggerOption=i,[2,i]}}))}))},n.prototype.setMyPushTriggerOption=function(e){return f(this,void 0,void 0,(function(){var t,n,r,s,a,o,u;return _(this,(function(c){switch(c.label){case 0:return Y(i(fe,e)).throw(V.invalidParameters),t=B.of(this._iid),n=t.dispatcher,r=t.sdkState,s=t.requestQueue,a=new Wr({userId:r.userId,channelUrl:this.url,pushTriggerOption:e}),[4,s.send(a)];case 1:return o=c.sent(),u=o.as(Kr).pushTriggerOption,this.myPushTriggerOption=u,n.dispatch(new je({channels:[this],source:ze.EVENT_CHANNEL_UPDATED})),[2,u]}}))}))},n.prototype.setMyCountPreference=function(e){return f(this,void 0,void 0,(function(){var t,n,r,s,a,o,u;return _(this,(function(c){switch(c.label){case 0:return Y(i($r,e)).throw(V.invalidParameters),t=B.of(this._iid),n=t.dispatcher,r=t.sdkState,s=t.requestQueue,a=new Rr({channelUrl:this.url,userId:r.userId,countPreference:e}),[4,s.send(a)];case 1:return o=c.sent(),u=o.as(Fr).countPreference,this.myCountPreference=u,this._updateUnreadCount(this.unreadMessageCount,this.unreadMentionCount),n.dispatch(new je({channels:[this],source:ze.EVENT_CHANNEL_UPDATED})),[2,u]}}))}))},n.prototype.resetMyHistory=function(){return f(this,void 0,void 0,(function(){var e,t,n,r,s,i;return _(this,(function(a){switch(a.label){case 0:return e=B.of(this._iid),t=e.dispatcher,n=e.requestQueue,r=new Or({channelUrl:this.url}),[4,n.send(r)];case 1:return s=a.sent(),i=s.as(Hr).messageOffsetTimestamp,this.messageOffsetTimestamp=i,t.dispatch(new je({channels:[this],source:ze.EVENT_CHANNEL_RESET_HISTORY})),[2,this]}}))}))},n.prototype.pinMessage=function(e){return f(this,void 0,void 0,(function(){var t,n;return _(this,(function(r){switch(r.label){case 0:return Y(g("number",e)&&e>0).throw(V.invalidParameters),t=B.of(this._iid).requestQueue,n=new Xr({channelType:this.channelType,channelUrl:this.url,messageId:e}),[4,t.send(n)];case 1:return r.sent(),[2]}}))}))},n.prototype.unpinMessage=function(e){return f(this,void 0,void 0,(function(){var t,n;return _(this,(function(r){switch(r.label){case 0:return Y(g("number",e)&&e>0).throw(V.invalidParameters),t=B.of(this._iid).requestQueue,n=new Zr({channelType:this.channelType,channelUrl:this.url,messageId:e}),[4,t.send(n)];case 1:return r.sent(),[2]}}))}))},n.prototype._uploadFileAndUpdateParams=function(e){return f(this,void 0,void 0,(function(){var t,n,r,s,i,a,o,u,c,l,h;return _(this,(function(d){switch(d.label){case 0:return y(e.file)?(t=B.of(this._iid).requestQueue,n=new kt({file:e.file,channelUrl:this.url,thumbnailSizes:e.thumbnailSizes,requestId:this._generateRequestId()}),[4,t.send(n)]):[3,2];case 1:r=d.sent(),s=r.as(Lt),i=s.url,a=s.fileSize,o=void 0===a?e.fileSize:a,u=s.thumbnailSizes,c=void 0===u?e.thumbnailSizes:u,l=s.requireAuth,h=void 0!==l&&l,e.fileUrl=i,e.fileSize=o,e.thumbnailSizes=c,e.requireAuth=h,d.label=2;case 2:return[2]}}))}))},n}(Fe),us={},cs=function(){function e(e){var t=e._iid,n=e.limit,r=void 0===n?100:n,s=this;this._sync=null,this._connectionEventContext=null,this.ref=0,this._metadata=null,this._iid=t,this._limit=r;var i,a=B.of(this._iid),o=a.sdkState,u=a.dispatcher,c=a.logger;this._metadataKey=(i=o.userId,"sendbird:".concat(i,"@groupchannel/sync.meta"));var l=function(e){return"sendbird:".concat(e,"@groupchannel/sync")}(o.userId);this._sync=new nr(l,(function(){return f(s,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:""},[4,this.loadMetadata()];case 1:if(a.sent(),c.debug("channel background sync from",this._metadata.token),this._metadata.completed)return[3,9];a.label=2;case 2:return a.trys.push([2,5,,8]),[4,er.of(this._iid).getMyGroupChannels(this._metadata.token,{includeEmpty:!0,order:Ge.CHRONOLOGICAL},this._limit,ze.SYNC_CHANNEL_BACKGROUND)];case 3:return t=a.sent(),n=t.channels,r=t.token,e.hasNext=n.length>=this._limit&&!!r,e.nextToken=r,this._metadata.token=r,(i=this._metadata.range).extends.apply(i,h([],d(n.map((function(e){return e.createdAt}))),!1)),this._metadata.completed=!e.hasNext,c.debug("channel background sync progress",e),[4,this.saveMetadata()];case 4:return a.sent(),[3,8];case 5:return s=a.sent(),c.debug("channel background sync error",s),s instanceof V&&s.isInvalidTokenError?[4,this.clearMetaData()]:[3,7];case 6:a.sent(),a.label=7;case 7:throw s;case 8:return[3,10];case 9:e.hasNext=!1,e.nextToken="",a.label=10;case 10:return[2,e]}}))}))})),this._connectionEventContext=u.on((function(e){if(e instanceof $)if(e.stateType===ee.CONNECTED)s.resume();else s.pause()}))}return e.of=function(t){return us[t]||(us[t]=new e({_iid:t})),us[t].ref++,us[t]},e.clear=function(e){us[e]&&(us[e].close(),delete us[e])},Object.defineProperty(e.prototype,"range",{get:function(){var e;return null===(e=this._metadata)||void 0===e?void 0:e.range},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"completed",{get:function(){var e;return!!(null===(e=this._metadata)||void 0===e?void 0:e.completed)},enumerable:!1,configurable:!0}),e.prototype.loadMetadata=function(){return f(this,void 0,void 0,(function(){var e;return _(this,(function(t){switch(t.label){case 0:return this._metadata?[3,2]:[4,B.of(this._iid).cacheContext.preference.get(this._metadataKey)];case 1:e=t.sent(),this._metadata={token:e?e.token:"",range:new Xn(e?e.range:{top:Number.MAX_SAFE_INTEGER,bottom:0}),completed:!!e&&e.completed},t.label=2;case 2:return[2,this._metadata]}}))}))},e.prototype.saveMetadata=function(){return f(this,void 0,void 0,(function(){return _(this,(function(e){switch(e.label){case 0:return this._metadata?[4,B.of(this._iid).cacheContext.preference.set(this._metadataKey,this._metadata)]:[3,2];case 1:return e.sent(),[2,!0];case 2:return[2,!1]}}))}))},e.prototype.clearMetaData=function(){return f(this,void 0,void 0,(function(){return _(this,(function(e){switch(e.label){case 0:return[4,B.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=B.of(this._iid),r=n.logger;n.connectionManager.isConnected&&(r.debug("channel background sync resume()"),this._sync.start(null!==(t=null===(e=this._metadata)||void 0===e?void 0:e.token)&&void 0!==t?t:""))},e.prototype.pause=function(){B.of(this._iid).logger.debug("channel background sync stop()"),this._sync.stop()},e.prototype.close=function(){this.ref--,this.ref<=0&&(this.ref=0,this.pause(),this._connectionEventContext.close(),delete us[this._iid])},e}(),ls={},hs=function(){function e(e){var t=e._iid,n=this;this._sync=null,this._connectionEventContext=null,this.ref=0,this._metadataKey=null,this._metadata=null,this._iid=t;var r,s=B.of(this._iid),i=s.logger,a=s.sdkState,o=s.dispatcher;this._metadataKey=(r=a.userId,"sendbird:".concat(r,"@groupchannel/changelogs.meta"));var u=function(e){return"sendbird:".concat(e,"@groupchannel/changelogs")}(a.userId);this._sync=new nr(u,(function(){return f(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,er.of(this._iid).getMyGroupChannelChangeLogs(this._metadata.token,{includeEmpty:!0},ze.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 V&&s.isInvalidTokenError?[4,this.clearMetadata()]:[3,7];case 6:a.sent(),a.label=7;case 7:throw s;case 8:return[2,e]}}))}))})),this._connectionEventContext=o.on((function(e){if(e instanceof $)if(e.stateType===ee.CONNECTED)n.resume();else n.pause()}))}return e.of=function(t){return ls[t]||(ls[t]=new e({_iid:t})),ls[t].ref++,ls[t]},e.clear=function(e){ls[e]&&(ls[e].close(),delete ls[e])},e.prototype.loadMetadata=function(){return f(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=B.of(this._iid),t=e.cacheContext,n=e.firstConnectedAt,[4,t.preference.get(this._metadataKey)]);case 1:r=s.sent(),this._metadata={token:r?r.token:n},s.label=2;case 2:return[2,this._metadata]}}))}))},e.prototype.saveMetadata=function(){return f(this,void 0,void 0,(function(){return _(this,(function(e){switch(e.label){case 0:return this._metadata?[4,B.of(this._iid).cacheContext.preference.set(this._metadataKey,this._metadata)]:[3,2];case 1:return e.sent(),[2,!0];case 2:return[2,!1]}}))}))},e.prototype.clearMetadata=function(){return f(this,void 0,void 0,(function(){return _(this,(function(e){switch(e.label){case 0:return[4,B.of(this._iid).cacheContext.preference.remove(this._metadataKey)];case 1:return e.sent(),this._metadata=null,[2]}}))}))},e.prototype.resume=function(){B.of(this._iid).connectionManager.isConnected&&this._sync.start(0)},e.prototype.pause=function(){this._sync.stop()},e.prototype.close=function(){this.ref--,this.ref<=0&&(this.ref=0,this.pause(),this._connectionEventContext.close(),delete ls[this._iid])},e}(),ds=function(){function e(e,t){var n=t.filter,r=t.order,s=t.limit,i=this;this.channels=[],this._backgroundSync=null,this._changelogSync=null,this._iid=e,this._key="gcc-".concat(oe()),this._isDisposed=!1,this.filter=null!=n?n:new Wt,this.order=null!=r?r:Ge.LATEST_LAST_MESSAGE,this._hasMore=!0,this._token="",this._limit=null!=s?s:ye;var a=B.of(this._iid),o=a.sdkState,u=a.cacheContext,c=a.dispatcher;u.localCacheEnabled&&(this._backgroundSync=cs.of(e),this._backgroundSync.resume()),this._changelogSync=hs.of(e),this._changelogSync.resume(),er.of(this._iid).subscribeGroupChannelEvent(this._key,{onUpdate:function(e,t){if(tt(t)){var n=e.filter((function(e){return i.filter.match(e,o.userId)})),r=e.filter((function(e){return!i.filter.match(e,o.userId)})).map((function(e){return e.url}));n.length>0&&i._addChannelsToView(n,t),r.length>0&&i._removeChannelsFromView(r,t)}},onRemove:function(e,t){i._removeChannelsFromView(e,t)}}),B.of(this._iid).statLogCollector.put(new se({type:ie.FEATURE_LOCALCACHE,data:{use_local_cache:u.localCacheEnabled,collection_interface:{group_channel:!0}}})),c.on((function(e){e instanceof $&&e.stateType===ee.LOGOUT&&i.dispose()}))}return Object.defineProperty(e.prototype,"hasMore",{get:function(){return!this._isDisposed&&this._hasMore},enumerable:!1,configurable:!0}),e.prototype.setGroupChannelCollectionHandler=function(e){this._handler=e},e.prototype._addChannelsToView=function(e,t,n){var r,s,i,a,o=this;void 0===n&&(n=!1);var u=[],c=[],l=[];try{for(var h=m(e),d=h.next();!d.done;d=h.next()){var p=d.value,v=fr(this.channels,p,this.order),g=v.place,y=v.oldPosition;if(-1===y)g===this.channels.length?!n&&this._hasMore||(u.push(p),this.channels.push(p)):(u.push(p),this.channels.splice(g,0,p));else switch(t){case ze.EVENT_CHANNEL_UPDATED:case ze.EVENT_MESSAGE_RECEIVED:case ze.SYNC_CHANNEL_CHANGELOGS:case ze.EVENT_MESSAGE_SENT:g!==y?this._hasMore&&g===this.channels.length?l.push(p):(this.channels.splice(y,1),this.channels.splice(y0)try{for(var C=m(l),E=C.next();!E.done;E=C.next()){p=E.value;var b=pr(this.channels,p);-1!==b&&this.channels.splice(b,1)}}catch(e){i={error:e}}finally{try{E&&!E.done&&(a=C.return)&&a.call(C)}finally{if(i)throw i.error}}tt(t)&&W((function(){return f(o,void 0,void 0,(function(){var e,n,r,s;return _(this,(function(i){return e=new rr(t),u.length>0&&(null===(n=this._handler)||void 0===n?void 0:n.onChannelsAdded)&&this._handler.onChannelsAdded(e,u),c.length>0&&(null===(r=this._handler)||void 0===r?void 0:r.onChannelsUpdated)&&this._handler.onChannelsUpdated(e,c),l.length>0&&(null===(s=this._handler)||void 0===s?void 0:s.onChannelsDeleted)&&this._handler.onChannelsDeleted(e,l.map((function(e){return e.url}))),[2]}))}))}))},e.prototype._removeChannelsFromView=function(e,t){var n,r,s=this,i=[],a=function(e){var t=o.channels.findIndex((function(t){return t.url===e}));t>=0&&(i.push(o.channels[t].url),o.channels.splice(t,1))},o=this;try{for(var u=m(e),c=u.next();!c.done;c=u.next()){a(c.value)}}catch(e){n={error:e}}finally{try{c&&!c.done&&(r=u.return)&&r.call(u)}finally{if(n)throw n.error}}return tt(t)&&i.length>0&&W((function(){return f(s,void 0,void 0,(function(){var e,n;return _(this,(function(r){return e=new rr(t),(null===(n=this._handler)||void 0===n?void 0:n.onChannelsDeleted)&&this._handler.onChannelsDeleted(e,i),[2]}))}))})),i},e.prototype._getLocalChannels=function(){return f(this,void 0,void 0,(function(){var e,t;return _(this,(function(n){switch(n.label){case 0:return e=er.of(this._iid),t=this.channels.length>0?function(e,t){var n,r;switch(t){case Ge.LATEST_LAST_MESSAGE:return null!==(r=null===(n=e.lastMessage)||void 0===n?void 0:n.createdAt)&&void 0!==r?r:e.createdAt;case Ge.CHRONOLOGICAL:return e.createdAt;case Ge.CHANNEL_NAME_ALPHABETICAL:return e.name}return null}(this.channels[this.channels.length-1],this.order):null,[4,e.getChannelsFromCache(t,this.filter,this.order,this._limit,t?this.channels[this.channels.length-1].url:null)];case 1:return[2,n.sent()]}}))}))},e.prototype._getRemoteChannels=function(){return f(this,void 0,void 0,(function(){var e,t,n;return _(this,(function(r){switch(r.label){case 0:return[4,er.of(this._iid).getMyGroupChannels(this._token,s(s({},this.filter),{order:this.order}),this._limit)];case 1:return e=r.sent(),t=e.channels,n=e.token,this._token=n,this._hasMore=!!n,[2,t]}}))}))},e.prototype.loadMore=function(){return f(this,void 0,void 0,(function(){var e,t,n=this;return _(this,(function(r){switch(r.label){case 0:if(this._isDisposed)throw new V({code:J.COLLECTION_DISPOSED,message:"Collection has been disposed."});return this._hasMore?(e=B.of(this._iid).cacheContext,t=[],e.localCacheEnabled&&this._backgroundSync.completed?[3,2]:[4,E((function(){return f(n,void 0,void 0,(function(){return _(this,(function(e){switch(e.label){case 0:return[4,this._getRemoteChannels()];case 1:return t=e.sent(),[2]}}))}))}))]):[3,5];case 1:r.sent(),r.label=2;case 2:return e.localCacheEnabled&&0===t.length?[4,E((function(){return f(n,void 0,void 0,(function(){return _(this,(function(e){switch(e.label){case 0:return[4,this._getLocalChannels()];case 1:return t=e.sent(),[2]}}))}))}))]:[3,4];case 3:r.sent(),this._backgroundSync.completed&&(this._hasMore=t.length>=this._limit),r.label=4;case 4:return this._addChannelsToView(t,ze.REQUEST_CHANNEL,!0),[2,t];case 5:return[2,[]]}}))}))},e.prototype.dispose=function(){var e,t;this._isDisposed||(this._isDisposed=!0,this.channels.length>0&&this.channels.splice(0,this.channels.length),null===(e=this._backgroundSync)||void 0===e||e.close(),null===(t=this._changelogSync)||void 0===t||t.close(),er.of(this._iid).unsubscribeGroupChannelEvent(this._key))},e}(),ps=function(t){function n(e){var n=this,s=e.token,i=e.limit,a=e.order,o=e.includeEmpty,u=e.membershipFilter,c=e.channelNameContainsFilter,l=e.channelUrlsFilter,h=e.customTypesFilter,d=e.customTypeStartsWithFilter,p=e.superChannelFilter,f=e.metadataOrderKeyFilter,_=e.metadataKey,m=e.metadataValues,v=e.metadataValueStartsWith,g=e.includeFrozen,y=e.includeMetaData;return(n=t.call(this)||this).method=I.GET,n.path=k,n.params=r({token:s,limit:i,order:a,show_member:!0,show_read_receipt:!0,show_delivery_receipt:!0,show_empty:o,public_mode:Rt.PUBLIC,public_membership_mode:u,name_contains:c,channel_urls:l,custom_types:h,custom_type_startswith:d,super_mode:p,metadata_order_key:f,metadata_key:_,metadata_values:m,metadata_value_startswith:v,show_frozen:g,show_metadata:y}),n}return e(n,t),n}(w),fs=function(t){function n(e,n){var r=t.call(this,e,n)||this;r.token=null,r.channels=[],r.ts=null;var s=n.next,i=n.channels,a=n.ts;return r.token=s,i&&i.length>0&&(r.channels=i.map((function(t){return t.ts=a,new os(e,t)}))),r.ts="number"==typeof a?a:null,r}return e(n,t),n}(D);!function(e){e.ALL="all",e.JOINED="joined"}(as||(as={}));var _s=function(t){function n(e,n){var r,s,i,a,o,u,c,l,h,d,p,f,_,m,v=this;return(v=t.call(this,e,n)||this).includeEmpty=!1,v.includeFrozen=!0,v.includeMetaData=!0,v.channelUrlsFilter=null,v.customTypesFilter=null,v.customTypeStartsWithFilter=null,v.channelNameContainsFilter=null,v.membershipFilter=as.ALL,v.superChannelFilter=Ot.ALL,v.metadataKey=null,v.metadataValues=null,v.metadataOrderKeyFilter=null,v.metadataValueStartsWith=null,v.order=ot.CHRONOLOGICAL,v.includeEmpty=null!==(r=n.includeEmpty)&&void 0!==r&&r,v.includeFrozen=null===(s=n.includeFrozen)||void 0===s||s,v.includeMetaData=null===(i=n.includeMetaData)||void 0===i||i,v.channelUrlsFilter=null!==(a=n.channelUrlsFilter)&&void 0!==a?a:null,v.customTypesFilter=null!==(o=n.customTypesFilter)&&void 0!==o?o:null,v.customTypeStartsWithFilter=null!==(u=n.customTypeStartsWithFilter)&&void 0!==u?u:null,v.channelNameContainsFilter=null!==(c=n.channelNameContainsFilter)&&void 0!==c?c:null,v.membershipFilter=null!==(l=n.membershipFilter)&&void 0!==l?l:as.ALL,v.superChannelFilter=null!==(h=n.superChannelFilter)&&void 0!==h?h:Ot.ALL,v.metadataKey=null!==(d=n.metadataKey)&&void 0!==d?d:null,v.metadataValues=null!==(p=n.metadataValues)&&void 0!==p?p:null,v.metadataOrderKeyFilter=null!==(f=n.metadataOrderKeyFilter)&&void 0!==f?f:null,v.metadataValueStartsWith=null!==(_=n.metadataValueStartsWith)&&void 0!==_?_:null,v.order=null!==(m=n.order)&&void 0!==m?m:ot.CHRONOLOGICAL,v}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,!0)&&v("string",this.channelUrlsFilter,!0)&&v("string",this.customTypesFilter,!0)&&g("string",this.customTypeStartsWithFilter,!0)&&i(as,this.membershipFilter)&&i(Ot,this.superChannelFilter)&&i(ot,this.order)&&g("string",this.metadataOrderKeyFilter,!0)&&g("string",this.metadataKey,!0)&&v("string",this.metadataValues,!0)&&g("string",this.metadataValueStartsWith,!0)},n.prototype.next=function(){return f(this,void 0,void 0,(function(){var e,t,n,r,i,a,o,u;return _(this,(function(c){switch(c.label){case 0:return this._validate()?this._isLoading?[3,3]:(e=[],this._hasNext?(this._isLoading=!0,t=B.of(this._iid),n=t.requestQueue,t.dispatcher,r=new ps(s(s({},this),{token:this._token})),[4,n.send(r)]):[3,2]):[3,5];case 1:return i=c.sent(),a=i.as(fs),o=a.channels,u=a.token,this._token=u,this._hasNext=!!u,this._isLoading=!1,[2,o];case 2:return[2,e];case 3:throw V.queryInProgress;case 4:return[3,6];case 5:throw V.invalidParameters;case 6:return[2]}}))}))},n}(H),ms=function(t){function n(e){void 0===e&&(e={});var n=t.call(this)||this;return Object.keys(e).forEach((function(t){n.hasOwnProperty(t)&&(n[t]=e[t])})),n}return e(n,t),n}(function(t){function n(){var e=null!==t&&t.apply(this,arguments)||this;return e.onUserJoined=_e,e.onUserLeft=_e,e.onUserReceivedInvitation=_e,e.onUserDeclinedInvitation=_e,e.onChannelHidden=_e,e.onUnreadMemberStatusUpdated=_e,e.onUndeliveredMemberStatusUpdated=_e,e.onTypingStatusUpdated=_e,e.onPollUpdated=_e,e.onPollVoted=_e,e.onPollDeleted=_e,e.onPinnedMessageUpdated=_e,e}return e(n,t),n}(gt)),vs=function(t){function n(e){var n=this,s=e.token,i=e.limit,a=e.order,o=e.reverse,u=e.channelUrl,c=e.messageTypeFilter,l=e.scheduledStatus;return(n=t.call(this)||this).method=I.GET,n.path="".concat(x),n.params=r({limit:i,reverse:o,channel_url:u,order:a,status:l}),s&&(n.params.token=s),c&&(n.params.message_type=c),n}return e(n,t),n}(w),gs=function(t){function n(e,n){var r=t.call(this,e,n)||this;r.token=null,r.scheduledMessages=[];var s=n.next,i=n.scheduled_messages;return r.token=s,r.scheduledMessages=i.map((function(t){return bt(e,t)})),r}return e(n,t),n}(D),ys=function(t){function n(e,n){var r,s,i,a,o,u=this;return(u=t.call(this,e,n)||this).channelUrl=null,u.order=null,u.reverse=!1,u.scheduledStatus=null,u.messageTypeFilter=C.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:C.ALL,u}return e(n,t),n.prototype._validate=function(){return t.prototype._validate.call(this)&&g("string",this.channelUrl,!0)&&(i(ut,this.order)||null===this.order)&&g("boolean",this.reverse)&&(v(yt,this.scheduledStatus)||null===this.scheduledStatus)&&i(C,this.messageTypeFilter)},n.prototype.next=function(){return f(this,void 0,void 0,(function(){var e,t,n,r,i,a;return _(this,(function(o){switch(o.label){case 0:return this._validate()?this._isLoading?[3,3]:this._hasNext?(this._isLoading=!0,e=B.of(this._iid).requestQueue,t=new vs(s(s({},this),{token:this._token})),[4,e.send(t)]):[3,2]:[3,5];case 1:return n=o.sent(),r=n.as(gs),i=r.scheduledMessages,a=r.token,this._token=a,this._hasNext=!!a,this._isLoading=!1,[2,i];case 2:return[2,[]];case 3:throw V.queryInProgress;case 4:return[3,6];case 5:throw V.invalidParameters;case 6:return[2]}}))}))},n}(H),Cs=function(t){function n(){var e=null!==t&&t.apply(this,arguments)||this;return e.name="groupChannel",e}return e(n,t),n.prototype.init=function(e,n){var r=n.sdkState,s=n.dispatcher,i=n.sessionManager,a=n.requestQueue,o=n.logger,u=n.onlineDetector,c=n.cacheContext;t.prototype.init.call(this,e,{sdkState:r,dispatcher:s,sessionManager:i,requestQueue:a,logger:o,onlineDetector:u,cacheContext:c}),this._manager=new er(e,{sdkState:r,cacheContext:c,dispatcher:s,sessionManager:i,requestQueue:a,logger:o})},n.prototype.createGroupChannelCollection=function(e){return void 0===e&&(e={}),new ds(this._iid,e)},n.prototype.createMyGroupChannelListQuery=function(e){return void 0===e&&(e={}),new Jn(this._iid,e)},n.prototype.createPublicGroupChannelListQuery=function(e){return void 0===e&&(e={}),new _s(this._iid,e)},n.prototype.createScheduledMessageListQuery=function(e){return void 0===e&&(e={}),new ys(this._iid,e)},n.prototype.addGroupChannelHandler=function(e,t){Y(g("string",e)&&t instanceof ms).throw(V.invalidParameters),this._manager.addHandler(e,t)},n.prototype.removeGroupChannelHandler=function(e){Y(g("string",e)).throw(V.invalidParameters),this._manager.removeHandler(e)},n.prototype.removeAllGroupChannelHandlers=function(){this._manager.clearHandler()},n.prototype.buildGroupChannelFromSerializedData=function(e){return this._manager.buildGroupChannelFromSerializedData(e)},n.prototype.buildGroupChannelListQueryFromSerializedData=function(e){return this._manager.buildGroupChannelListQueryFromSerializedData(e)},n.prototype.buildMemberFromSerializedData=function(e){return this._manager.buildMemberFromSerializedData(e)},n.prototype.getChannel=function(e){return f(this,void 0,void 0,(function(){return _(this,(function(t){return Y(g("string",e)).throw(V.invalidParameters),[2,this._manager.getChannel(e)]}))}))},n.prototype.getChannelWithoutCache=function(e){return f(this,void 0,void 0,(function(){return _(this,(function(t){return Y(g("string",e)).throw(V.invalidParameters),[2,this._manager.getChannelWithoutCache(e)]}))}))},n.prototype.getMyGroupChannelChangeLogsByToken=function(e,t){return void 0===t&&(t={}),f(this,void 0,void 0,(function(){var n;return _(this,(function(r){switch(r.label){case 0:return n=s(s({},Xt),t),Y(g("string",e)&&Zt(n)).throw(V.invalidParameters),[4,this._manager.getMyGroupChannelChangeLogs(e,n)];case 1:return[2,r.sent()]}}))}))},n.prototype.getMyGroupChannelChangeLogsByTimestamp=function(e,t){return void 0===t&&(t={}),f(this,void 0,void 0,(function(){var n;return _(this,(function(r){switch(r.label){case 0:return n=s(s({},Xt),t),Y(g("number",e)&&Zt(n)).throw(V.invalidParameters),[4,this._manager.getMyGroupChannelChangeLogs(e,n)];case 1:return[2,r.sent()]}}))}))},n.prototype.getGroupChannelCount=function(e){return f(this,void 0,void 0,(function(){var t;return _(this,(function(n){return t=s(s({},$t),e),Y(en(t)).throw(V.invalidParameters),[2,this._manager.getGroupChannelCount(t)]}))}))},n.prototype.getUnreadItemCount=function(e){return void 0===e&&(e={}),f(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()]}}))}))},n.prototype.getTotalUnreadChannelCount=function(){return f(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()]}}))}))},n.prototype.getTotalUnreadMessageCount=function(e){return void 0===e&&(e={}),f(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()]}}))}))},n.prototype.getTotalScheduledMessageCount=function(e){return void 0===e&&(e={}),f(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()]}}))}))},n.prototype.getSubscribedTotalUnreadMessageCount=function(){return this._manager.getSubscribedTotalUnreadMessageCount()},n.prototype.getSubscribedCustomTypeTotalUnreadMessageCount=function(){return this._manager.getSubscribedCustomTypeTotalUnreadMessageCount()},n.prototype.getSubscribedCustomTypeUnreadMessageCount=function(e){return this._manager.getSubscribedCustomTypeUnreadMessageCount(e)},n.prototype.createChannel=function(e){return void 0===e&&(e={}),f(this,void 0,void 0,(function(){var t;return _(this,(function(n){return t=s(s({},Yt),e),Y(Jt(t)).throw(V.invalidParameters),[2,this._manager.createChannel(t)]}))}))},n.prototype.createDistinctChannelIfNotExist=function(e){return void 0===e&&(e={}),f(this,void 0,void 0,(function(){var t;return _(this,(function(n){return t=s(s({},Yt),e),Y(Jt(t)).throw(V.invalidParameters),t&&(t.isDistinct=!0),[2,this.createChannel(t)]}))}))},n.prototype.createChannelWithUserIds=function(e,t,n,r,i,a){return void 0===t&&(t=!1),void 0===n&&(n=null),void 0===r&&(r=null),void 0===i&&(i=""),void 0===a&&(a=""),f(this,void 0,void 0,(function(){var o;return _(this,(function(u){return o=s(s({},Yt),{invitedUserIds:e,isDistinct:t,name:n,data:i,customType:a}),"string"==typeof r?o.coverUrl=r:o.coverImage=r,[2,this.createChannel(o)]}))}))},n.prototype.markAsReadAll=function(){return f(this,void 0,void 0,(function(){return _(this,(function(e){return this._manager.markAsReadAll(),[2]}))}))},n.prototype.markAsReadWithChannelUrls=function(e){return f(this,void 0,void 0,(function(){return _(this,(function(t){return Y(v("string",e)).throw(V.invalidParameters),this._manager.markAsReadWithChannelUrls(e),[2]}))}))},n.prototype.markAsDelivered=function(e){return f(this,void 0,void 0,(function(){return _(this,(function(t){switch(t.label){case 0:return Y(g("string",e)).throw(V.invalidParameters),[4,this.getChannel(e)];case 1:return[4,t.sent().markAsDelivered()];case 2:return t.sent(),[2]}}))}))},n}(me);export{$r as CountPreference,os as GroupChannel,ds as GroupChannelCollection,rr as GroupChannelEventContext,Wt as GroupChannelFilter,ms as GroupChannelHandler,Jn as GroupChannelListQuery,Cs as GroupChannelModule,Bt as GroupChannelSearchField,Gt as HiddenChannelFilter,ts as HiddenState,jt as Member,Er as MemberListOrder,Ar as MemberListQuery,xt as MemberState,br as MemberStateFilter,as as MembershipFilter,Nr as MessageCollection,Mr as MessageCollectionInitHandler,tr as MessageCollectionInitPolicy,sr as MessageEventContext,Cr as MutedMemberFilter,es as MutedState,Ft as MyMemberStateFilter,Vt as OperatorFilter,ns as PinnedMessage,is as PinnedMessageListQuery,Rt as PublicChannelFilter,_s as PublicGroupChannelListQuery,qt as QueryType,zt as ReadStatus,ys as ScheduledMessageListQuery,Ot as SuperChannelFilter,Ht as UnreadChannelFilter,Qt as UnreadItemKey}; diff --git a/message.js b/message.js index c2d91f3..e41f9ec 100644 --- a/message.js +++ b/message.js @@ -1 +1 @@ -export{a0 as MentionType,Z as MessageType,a3 as MessageTypeFilter,a5 as PushNotificationDeliveryOption,ac as ReplyType,a1 as SendingStatus}from"./__bundle-03ba89c3.js";export{o as AdminMessage,A as AppleCriticalAlertOptions,B as BaseMessage,F as FileMessage,c as MessageMetaArray,M as MessageModule,f as MessageRequestHandler,r as MessageSearchOrder,a as MessageSearchQuery,O as OGImage,s as OGMetaData,d as PreviousMessageListQuery,t as Reaction,R as ReactionEvent,u as ReactionEventOperation,e as Sender,w as ThreadInfo,q as ThreadInfoUpdateEvent,T as Thumbnail,U as UserMessage}from"./__bundle-51a2cdbc.js"; +export{a0 as MentionType,Z as MessageType,a3 as MessageTypeFilter,a5 as PushNotificationDeliveryOption,ac as ReplyType,a1 as SendingStatus}from"./__bundle-ea43c8a8.js";export{o as AdminMessage,A as AppleCriticalAlertOptions,B as BaseMessage,F as FileMessage,c as MessageMetaArray,M as MessageModule,f as MessageRequestHandler,r as MessageSearchOrder,a as MessageSearchQuery,O as OGImage,s as OGMetaData,d as PreviousMessageListQuery,t as Reaction,R as ReactionEvent,u as ReactionEventOperation,e as Sender,w as ThreadInfo,q as ThreadInfoUpdateEvent,T as Thumbnail,U as UserMessage}from"./__bundle-12fe2d56.js"; diff --git a/openChannel.js b/openChannel.js index 9e97007..543af11 100644 --- a/openChannel.js +++ b/openChannel.js @@ -1 +1 @@ -import{_ as n,b as e,c as t,X as r,l as a,a as i,i as s,A as o,aL as u,aM as c,f as l,h,e as d,a6 as p,U as f,W as v,t as C,w as _,H as y,s as m,ay as E,x as g,az as U,ae as w,aB as T,M as N,r as M,S as b,g as H,aF as P,ai as O,V as x,$ as D,n as I,B as A,aj as L}from"./__bundle-03ba89c3.js";import{p as R,q as F,r as k,u as S,t as q,w as z,x as Q,P as j,y as K,z as B,A as V,C as W,f as G}from"./__bundle-edc633d6.js";import{C as X,a as Y,O as Z,P as $,M as J,T as nn,R as en,U as tn,A as rn,B as an}from"./__bundle-7e9a42ec.js";import{k as sn,b as on}from"./__bundle-51a2cdbc.js";import{P as un}from"./__bundle-5ab69bcd.js";import"./__bundle-9e0eba5d.js";var cn=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),ln={channelUrl:null,name:null,coverUrlOrImage:null,data:null,customType:null,operatorUserIds:null,isEphemeral:null},hn=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),dn=function(e){function t(n,t){var r=e.call(this,n,t)||this;return r.channel=null,r.channel=new bn(n,t),r}return n(t,e),t}(h),pn=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,f=n.isEphemeral;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,is_ephemeral:f}),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 bn(n,t),r}n(t,e)}(h);var fn=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),vn=function(e){function t(n,t,r){var a,i,s=this;return s=e.call(this,n,"SYEV",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}(X),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),_n=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}(X),yn={},mn=function(){function n(n,e){var t=e.sdkState,r=e.dispatcher,a=e.requestQueue,i=this;return yn[n]||(this._iid=n,this._sdkState=t,this._requestQueue=a,this._dispatcher=r,this._openChannelCache=new cn(n),this._openChannelHandlers=new Map,this._dispatcher.on((function(n){var e,t;if(n instanceof v)i._handleEvent(n);else if(n instanceof C&&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}}}})),yn[n]=this),yn[n]}return n.of=function(n){return yn[n]},n.prototype.buildOpenChannelFromSerializedData=function(n){var e=m(n);return new bn(this._iid,bn.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,v,C,_,m,M,b,H,O,x,D,I,A,L,G,an,on,un,cn,ln,hn,dn,pn,fn,Cn,yn,mn,En,gn,Un,wn,Tn,Nn,Mn,bn,Hn,Pn,On,xn,Dn,In,An,Ln,Rn,Fn,kn,Sn,qn,zn,Qn,jn,Kn,Bn,Vn,Wn,Gn,Xn=this;return t(this,(function(Yn){switch(Yn.label){case 0:switch(Yn.trys.push([0,55,,56]),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"PEDI":return[3,27];case"VOTE":return[3,29];case"SYEV":return[3,31]}return[3,54];case 1:return s=null,"MESG"===n.code?s=n.as(W):"FILE"===n.code?s=n.as(sn):"ADMM"!==n.code&&"BRDM"!=n.code||(s=n.as(rn)),s?(r=s.message,a=s.isMentioned,r.channelType!==N.OPEN?[3,3]:[4,this.getChannel(r.channelUrl,!0)]):[3,3];case 2:i=Yn.sent(),g((function(){return e(Xn,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]}))}))})),Yn.label=3;case 3:return[3,54];case 4:return s=null,"MEDI"===n.code?s=n.as(B):"FEDI"===n.code?s=n.as(V):"AEDI"===n.code&&(s=n.as(tn)),s?(o=s.message,u=s.mentionCountChange,o.channelType!==N.OPEN?[3,6]:[4,this.getChannel(o.channelUrl,!0)]):[3,6];case 5:c=Yn.sent(),g((function(){return e(Xn,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(c.url)&&(r.onMessageUpdated(c,o),u>0&&r.onMentionReceived(c,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]}))}))})),Yn.label=6;case 6:return[3,54];case 7:return l=n.as(K),cn=l.channelUrl,ln=l.channelType,h=l.messageId,ln!==N.OPEN?[3,9]:[4,this.getChannel(cn,!0)];case 8:d=Yn.sent(),g((function(){return e(Xn,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(d.url)&&r.onMessageDeleted(d,h)}catch(n){a={error:n}}finally{try{e&&!e.done&&(i=n.return)&&i.call(n)}finally{if(a)throw a.error}}return[2]}))}))})),Yn.label=9;case 9:return[3,54];case 10:return p=n.as(en),cn=p.channelUrl,ln=p.channelType,f=p.event,ln!==N.OPEN?[3,12]:[4,this.getChannel(cn,!0)];case 11:v=Yn.sent(),g((function(){return e(Xn,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(v.url)&&r.onReactionUpdated(v,f)}catch(n){a={error:n}}finally{try{e&&!e.done&&(i=n.return)&&i.call(n)}finally{if(a)throw a.error}}return[2]}))}))})),Yn.label=12;case 12:return[3,54];case 13:return(C=n.as(nn).event).channelType!==N.OPEN?[3,15]:[4,this.getChannel(C.channelUrl,!0)];case 14:_=Yn.sent(),g((function(){return e(Xn,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(_.url)&&r.onThreadInfoUpdated(_,C)}catch(n){a={error:n}}finally{try{e&&!e.done&&(i=n.return)&&i.call(n)}finally{if(a)throw a.error}}return[2]}))}))})),Yn.label=15;case 15:return[3,54];case 16:m=n.as(J).openChannelMemberCounts,M=[],Yn.label=17;case 17:Yn.trys.push([17,22,23,24]),b=y(m),H=b.next(),Yn.label=18;case 18:return H.done?[3,21]:(O=H.value,cn=O.channelUrl,gn=O.participantCount,x=O.updatedAt,[4,this.getChannelFromCache(cn)]);case 19:(D=Yn.sent())&&D._updateParticipantCount(gn,x)&&M.push(D),Yn.label=20;case 20:return H=b.next(),[3,18];case 21:return[3,24];case 22:return I=Yn.sent(),Wn={error:I},[3,24];case 23:try{H&&!H.done&&(Gn=b.return)&&Gn.call(b)}finally{if(Wn)throw Wn.error}return[7];case 24:return M.length>0?[4,this.upsertChannelsToCache(M)]:[3,26];case 25:Yn.sent(),g((function(){return e(Xn,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(M)}catch(n){r={error:n}}finally{try{e&&!e.done&&(a=n.return)&&a.call(n)}finally{if(r)throw r.error}}return[2]}))}))})),Yn.label=26;case 26:return[3,54];case 27:return A=n.as($),L=A.event,G=A.status,cn=A.channelUrl,ln=A.channelType,cn&&ln?[4,this.getChannel(cn,!0)]:[3,54];case 28:return an=Yn.sent(),this._dispatcher.dispatch(new T({event:L,source:w.EVENT_POLL_UPDATED})),g(G===P?function(){return e(Xn,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.onPollDeleted(an,L.pollId)}catch(n){r={error:n}}finally{try{e&&!e.done&&(a=n.return)&&a.call(n)}finally{if(r)throw r.error}}return[2]}))}))}:function(){return e(Xn,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.onPollUpdated(an,L)}catch(n){r={error:n}}finally{try{e&&!e.done&&(a=n.return)&&a.call(n)}finally{if(r)throw r.error}}return[2]}))}))}),[3,54];case 29:return on=n.as(j),un=on.event,cn=on.channelUrl,ln=on.channelType,cn&&ln?[4,this.getChannel(cn,!0)]:[3,54];case 30:return hn=Yn.sent(),this._dispatcher.dispatch(new U({event:un,source:w.EVENT_POLL_VOTED})),g((function(){return e(Xn,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.onPollVoted(hn,un)}catch(n){r={error:n}}finally{try{e&&!e.done&&(a=n.return)&&a.call(n)}finally{if(r)throw r.error}}return[2]}))}))})),[3,54];case 31:if(!(dn=n.as(X).event).isOpenChannelEvent)return[3,53];switch(dn.category){case Y.CHANNEL_ENTER:return[3,32];case Y.CHANNEL_EXIT:return[3,34];case Y.CHANNEL_OPERATOR_UPDATE:return[3,36];case Y.USER_CHANNEL_MUTE:case Y.USER_CHANNEL_UNMUTE:return[3,38];case Y.USER_CHANNEL_BAN:case Y.USER_CHANNEL_UNBAN:return[3,40];case Y.CHANNEL_FREEZE:case Y.CHANNEL_UNFREEZE:return[3,42];case Y.CHANNEL_DELETED:return[3,44];case Y.CHANNEL_PROP_CHANGED:return[3,47];case Y.CHANNEL_META_DATA_CHANGED:return[3,49];case Y.CHANNEL_META_COUNTERS_CHANGED:return[3,51]}return[3,53];case 32:return[4,this.getChannel(dn.channelUrl,!0)];case 33:return pn=Yn.sent(),fn=n.as(vn),gn=fn.participantCount,Cn=fn.user,yn=pn._updateParticipantCount(gn,dn.ts),g((function(){return e(Xn,void 0,void 0,(function(){return t(this,(function(n){return this._openChannelHandlers.forEach((function(n){n.onUserEntered(pn,Cn),yn&&n.onChannelParticipantCountChanged(pn)})),[2]}))}))})),[3,53];case 34:return[4,this.getChannel(dn.channelUrl,!0)];case 35:return mn=Yn.sent(),En=n.as(_n),gn=En.participantCount,Un=En.user,wn=mn._updateParticipantCount(gn,dn.ts),g((function(){return e(Xn,void 0,void 0,(function(){return t(this,(function(n){return this._openChannelHandlers.forEach((function(n){n.onUserExited(mn,Un),wn&&n.onChannelParticipantCountChanged(mn)})),[2]}))}))})),[3,53];case 36:return[4,this.getChannel(dn.channelUrl,!0)];case 37:return Tn=Yn.sent(),Nn=n.as(Z).operators,Tn.operators=Nn,this.upsertChannelsToCache([Tn]),g((function(){return e(Xn,void 0,void 0,(function(){return t(this,(function(n){return this._openChannelHandlers.forEach((function(n){n.onOperatorUpdated(Tn,Nn)})),[2]}))}))})),[3,53];case 38:return[4,this.getChannel(dn.channelUrl,!0)];case 39:return Mn=Yn.sent(),bn=dn.category===Y.USER_CHANNEL_MUTE,Hn=n.as(bn?z:Q).user,g((function(){return e(Xn,void 0,void 0,(function(){return t(this,(function(n){return this._openChannelHandlers.forEach((function(n){bn?n.onUserMuted(Mn,Hn):n.onUserUnmuted(Mn,Hn)})),[2]}))}))})),[3,53];case 40:return[4,this.getChannel(dn.channelUrl,!0)];case 41:return Pn=Yn.sent(),On=dn.category===Y.USER_CHANNEL_BAN,xn=n.as(On?S:q).user,g((function(){return e(Xn,void 0,void 0,(function(){return t(this,(function(n){return this._openChannelHandlers.forEach((function(n){On?n.onUserBanned(Pn,xn):n.onUserUnbanned(Pn,xn)})),[2]}))}))})),[3,53];case 42:return[4,this.getChannel(dn.channelUrl,!0)];case 43:return Dn=Yn.sent(),In=n.as(k).freeze,Dn.isFrozen=In,this.upsertChannelsToCache([Dn]),g((function(){return e(Xn,void 0,void 0,(function(){return t(this,(function(n){return this._openChannelHandlers.forEach((function(n){In?n.onChannelFrozen(Dn):n.onChannelUnfrozen(Dn)})),[2]}))}))})),[3,53];case 44:return[4,this.getChannel(dn.channelUrl,!0)];case 45:return An=Yn.sent(),[4,this.removeChannelsFromCache([An.url])];case 46:return Yn.sent(),g((function(){return e(Xn,void 0,void 0,(function(){return t(this,(function(n){return this._openChannelHandlers.forEach((function(n){n.onChannelDeleted(An.url,An.channelType)})),[2]}))}))})),[3,53];case 47:return[4,this.getChannelWithoutCache(dn.channelUrl,!0)];case 48:return Ln=Yn.sent(),g((function(){return e(Xn,void 0,void 0,(function(){return t(this,(function(n){return this._openChannelHandlers.forEach((function(n){n.onChannelChanged(Ln)})),[2]}))}))})),[3,53];case 49:return[4,this.getChannel(dn.channelUrl,!0)];case 50:return Rn=Yn.sent(),Fn=n.as(F),kn=Fn.created,Sn=Fn.updated,qn=Fn.deleted,kn&&Rn._upsertCachedMetaData(kn,dn.ts),Sn&&Rn._upsertCachedMetaData(Sn,dn.ts),qn&&Rn._removeFromCachedMetaData(qn,dn.ts),g((function(){return e(Xn,void 0,void 0,(function(){return t(this,(function(n){return this._openChannelHandlers.forEach((function(n){kn&&n.onMetaDataCreated(Rn,kn),Sn&&n.onMetaDataUpdated(Rn,Sn),qn&&n.onMetaDataDeleted(Rn,qn)})),[2]}))}))})),[3,53];case 51:return[4,this.getChannel(dn.channelUrl,!0)];case 52:return zn=Yn.sent(),Qn=n.as(R),jn=Qn.created,Kn=Qn.updated,Bn=Qn.deleted,g((function(){return e(Xn,void 0,void 0,(function(){return t(this,(function(n){return this._openChannelHandlers.forEach((function(n){jn&&n.onMetaCounterCreated(zn,jn),Kn&&n.onMetaCounterUpdated(zn,Kn),Bn&&n.onMetaCounterDeleted(zn,Bn)})),[2]}))}))})),[3,53];case 53:return[3,54];case 54:return[3,56];case 55:if(Vn=Yn.sent(),E(Vn))throw Vn;return[3,56];case 56: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:M(i("string",n)).throw(b.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 M(i("string",n)).throw(b.invalidParameters),e=new hn({channelUrl:n,isInternalCall:r}),[4,this._requestQueue.send(e)];case 1:return a=t.sent(),s=a.as(dn).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({},ln),n),M(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)&&i("boolean",n.isEphemeral,!0)}(e)).throw(b.invalidParameters),r=new pn(e),[4,this._requestQueue.send(r)];case 1:return o=t.sent(),u=o.as(dn).channel,this.upsertChannelsToCache([u]),[2,u]}}))}))},n}(),En={name:null,coverUrlOrImage:null,data:null,customType:null,operatorUserIds:null},gn=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),Un=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 un(n,e)})),r}return n(t,e),t}(h),wn=function(r){function a(n,e,t){return r.call(this,n,e,N.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=x.of(this._iid).requestQueue,e=new gn(H(H({},this),{token:this._token})),[4,n.send(e)]):[3,2]:[3,5];case 1:return r=t.sent(),a=r.as(Un),i=a.participants,s=a.token,this._token=s,this._hasNext=!!s,this._isLoading=!1,[2,i];case 2:return[2,[]];case 3:throw b.queryInProgress;case 4:return[3,6];case 5:throw b.invalidParameters;case 6:return[2]}}))}))},a}(O),Tn=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),Nn=function(e){function t(n,t){var r=e.call(this,n,t)||this;return r.channel=new bn(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 bn=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=N.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({},G.payloadify(n)),{participant_count:n.participantCount,operators:n.operators.map((function(n){return f.payloadify(n)}))})):null},o.prototype.serialize=function(){return D(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 wn(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,mn.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=x.of(this._iid).requestQueue,e=new fn({channelUrl:this.url}),[4,n.send(e)];case 1:return r=t.sent(),a=r.as(vn),i=a.participantCount,s=a.ts,this._updateParticipantCount(i,s),mn.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=x.of(this._iid).requestQueue,e=new Cn({channelUrl:this.url}),[4,n.send(e)];case 1:return r=t.sent(),a=r.as(_n),i=a.participantCount,s=a.ts,this._updateParticipantCount(i,s),mn.of(this._iid).setExitedToCache(this),on.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({},En),n),M(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(b.invalidParameters),r=x.of(this._iid).requestQueue,o=new Tn(H({channelUrl:this.url},e)),[4,r.send(o)];case 1:return u=t.sent(),c=u.as(Nn).channel,[4,mn.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({},En),{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=x.of(this._iid).requestQueue,e=new Mn({channelUrl:this.url}),[4,n.send(e)];case 1:return t.sent(),[4,mn.of(this._iid).removeChannelsFromCache([this.url])];case 2:return t.sent(),[2]}}))}))},o.prototype.sendUserMessage=function(n){return M(!n.isPinnedMessage).throw(b.notSupportedError),r.prototype.sendUserMessage.call(this,n)},o.prototype.sendFileMessage=function(n){return M(!n.isPinnedMessage).throw(b.notSupportedError),r.prototype.sendFileMessage.call(this,n)},o}(G),Hn=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=I,n.onUserExited=I,n.onChannelParticipantCountChanged=I,n.onPollUpdated=I,n.onPollVoted=I,n.onPollDeleted=I,n}return n(t,e),t}(an)),Pn=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),On=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 bn(n,e)}))),r.ts="number"==typeof s?s:null,r}return n(t,e),t}(h),xn=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=x.of(this._iid).requestQueue,e=new Pn(H(H({},this),{token:this._token})),[4,n.send(e)]):[3,3]:[3,6];case 1:return r=t.sent(),a=r.as(On),i=a.channels,s=a.token,this._token=s,this._hasNext=!!s,[4,mn.of(this._iid).upsertChannelsToCache(i)];case 2:return t.sent(),this._isLoading=!1,[2,i];case 3:return[2,[]];case 4:throw b.queryInProgress;case 5:return[3,7];case 6:throw b.invalidParameters;case 7:return[2]}}))}))},s}(A),Dn=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 mn(n,{sdkState:t,dispatcher:a,requestQueue:s})},a.prototype.createOpenChannelListQuery=function(n){return void 0===n&&(n={}),new xn(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({},ln)).name=n,e.coverUrlOrImage=r,e.data=a,e.operatorUserIds=i,e.customType=s,[2,this._manager.createChannel(e)]}))}))},a}(L);export{bn as OpenChannel,Hn as OpenChannelHandler,xn as OpenChannelListQuery,Dn as OpenChannelModule,wn as ParticipantListQuery}; +import{_ as n,b as e,c as t,X as r,l as a,a as i,i as s,A as o,aL as u,aM as c,f as l,h,e as d,a6 as p,U as f,W as v,t as C,w as _,H as y,s as m,ay as E,x as g,az as U,ae as w,aB as T,M as N,r as M,S as b,g as H,aF as P,ai as O,V as x,$ as D,n as I,B as A,aj as L}from"./__bundle-ea43c8a8.js";import{p as R,q as F,r as k,u as S,t as q,w as z,x as Q,P as j,y as K,z as B,A as V,C as W,f as G}from"./__bundle-3b517302.js";import{C as X,a as Y,O as Z,P as $,M as J,T as nn,R as en,U as tn,A as rn,B as an}from"./__bundle-e9aa026e.js";import{k as sn,b as on}from"./__bundle-12fe2d56.js";import{P as un}from"./__bundle-5c4b7d2b.js";import"./__bundle-9a0f0a93.js";var cn=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),ln={channelUrl:null,name:null,coverUrlOrImage:null,data:null,customType:null,operatorUserIds:null,isEphemeral:null},hn=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),dn=function(e){function t(n,t){var r=e.call(this,n,t)||this;return r.channel=null,r.channel=new bn(n,t),r}return n(t,e),t}(h),pn=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,f=n.isEphemeral;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,is_ephemeral:f}),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 bn(n,t),r}n(t,e)}(h);var fn=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),vn=function(e){function t(n,t,r){var a,i,s=this;return s=e.call(this,n,"SYEV",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}(X),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),_n=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}(X),yn={},mn=function(){function n(n,e){var t=e.sdkState,r=e.dispatcher,a=e.requestQueue,i=this;return yn[n]||(this._iid=n,this._sdkState=t,this._requestQueue=a,this._dispatcher=r,this._openChannelCache=new cn(n),this._openChannelHandlers=new Map,this._dispatcher.on((function(n){var e,t;if(n instanceof v)i._handleEvent(n);else if(n instanceof C&&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}}}})),yn[n]=this),yn[n]}return n.of=function(n){return yn[n]},n.prototype.buildOpenChannelFromSerializedData=function(n){var e=m(n);return new bn(this._iid,bn.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,v,C,_,m,M,b,H,O,x,D,I,A,L,G,an,on,un,cn,ln,hn,dn,pn,fn,Cn,yn,mn,En,gn,Un,wn,Tn,Nn,Mn,bn,Hn,Pn,On,xn,Dn,In,An,Ln,Rn,Fn,kn,Sn,qn,zn,Qn,jn,Kn,Bn,Vn,Wn,Gn,Xn=this;return t(this,(function(Yn){switch(Yn.label){case 0:switch(Yn.trys.push([0,55,,56]),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"PEDI":return[3,27];case"VOTE":return[3,29];case"SYEV":return[3,31]}return[3,54];case 1:return s=null,"MESG"===n.code?s=n.as(W):"FILE"===n.code?s=n.as(sn):"ADMM"!==n.code&&"BRDM"!=n.code||(s=n.as(rn)),s?(r=s.message,a=s.isMentioned,r.channelType!==N.OPEN?[3,3]:[4,this.getChannel(r.channelUrl,!0)]):[3,3];case 2:i=Yn.sent(),g((function(){return e(Xn,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]}))}))})),Yn.label=3;case 3:return[3,54];case 4:return s=null,"MEDI"===n.code?s=n.as(B):"FEDI"===n.code?s=n.as(V):"AEDI"===n.code&&(s=n.as(tn)),s?(o=s.message,u=s.mentionCountChange,o.channelType!==N.OPEN?[3,6]:[4,this.getChannel(o.channelUrl,!0)]):[3,6];case 5:c=Yn.sent(),g((function(){return e(Xn,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(c.url)&&(r.onMessageUpdated(c,o),u>0&&r.onMentionReceived(c,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]}))}))})),Yn.label=6;case 6:return[3,54];case 7:return l=n.as(K),cn=l.channelUrl,ln=l.channelType,h=l.messageId,ln!==N.OPEN?[3,9]:[4,this.getChannel(cn,!0)];case 8:d=Yn.sent(),g((function(){return e(Xn,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(d.url)&&r.onMessageDeleted(d,h)}catch(n){a={error:n}}finally{try{e&&!e.done&&(i=n.return)&&i.call(n)}finally{if(a)throw a.error}}return[2]}))}))})),Yn.label=9;case 9:return[3,54];case 10:return p=n.as(en),cn=p.channelUrl,ln=p.channelType,f=p.event,ln!==N.OPEN?[3,12]:[4,this.getChannel(cn,!0)];case 11:v=Yn.sent(),g((function(){return e(Xn,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(v.url)&&r.onReactionUpdated(v,f)}catch(n){a={error:n}}finally{try{e&&!e.done&&(i=n.return)&&i.call(n)}finally{if(a)throw a.error}}return[2]}))}))})),Yn.label=12;case 12:return[3,54];case 13:return(C=n.as(nn).event).channelType!==N.OPEN?[3,15]:[4,this.getChannel(C.channelUrl,!0)];case 14:_=Yn.sent(),g((function(){return e(Xn,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(_.url)&&r.onThreadInfoUpdated(_,C)}catch(n){a={error:n}}finally{try{e&&!e.done&&(i=n.return)&&i.call(n)}finally{if(a)throw a.error}}return[2]}))}))})),Yn.label=15;case 15:return[3,54];case 16:m=n.as(J).openChannelMemberCounts,M=[],Yn.label=17;case 17:Yn.trys.push([17,22,23,24]),b=y(m),H=b.next(),Yn.label=18;case 18:return H.done?[3,21]:(O=H.value,cn=O.channelUrl,gn=O.participantCount,x=O.updatedAt,[4,this.getChannelFromCache(cn)]);case 19:(D=Yn.sent())&&D._updateParticipantCount(gn,x)&&M.push(D),Yn.label=20;case 20:return H=b.next(),[3,18];case 21:return[3,24];case 22:return I=Yn.sent(),Wn={error:I},[3,24];case 23:try{H&&!H.done&&(Gn=b.return)&&Gn.call(b)}finally{if(Wn)throw Wn.error}return[7];case 24:return M.length>0?[4,this.upsertChannelsToCache(M)]:[3,26];case 25:Yn.sent(),g((function(){return e(Xn,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(M)}catch(n){r={error:n}}finally{try{e&&!e.done&&(a=n.return)&&a.call(n)}finally{if(r)throw r.error}}return[2]}))}))})),Yn.label=26;case 26:return[3,54];case 27:return A=n.as($),L=A.event,G=A.status,cn=A.channelUrl,ln=A.channelType,cn&&ln?[4,this.getChannel(cn,!0)]:[3,54];case 28:return an=Yn.sent(),this._dispatcher.dispatch(new T({event:L,source:w.EVENT_POLL_UPDATED})),g(G===P?function(){return e(Xn,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.onPollDeleted(an,L.pollId)}catch(n){r={error:n}}finally{try{e&&!e.done&&(a=n.return)&&a.call(n)}finally{if(r)throw r.error}}return[2]}))}))}:function(){return e(Xn,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.onPollUpdated(an,L)}catch(n){r={error:n}}finally{try{e&&!e.done&&(a=n.return)&&a.call(n)}finally{if(r)throw r.error}}return[2]}))}))}),[3,54];case 29:return on=n.as(j),un=on.event,cn=on.channelUrl,ln=on.channelType,cn&&ln?[4,this.getChannel(cn,!0)]:[3,54];case 30:return hn=Yn.sent(),this._dispatcher.dispatch(new U({event:un,source:w.EVENT_POLL_VOTED})),g((function(){return e(Xn,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.onPollVoted(hn,un)}catch(n){r={error:n}}finally{try{e&&!e.done&&(a=n.return)&&a.call(n)}finally{if(r)throw r.error}}return[2]}))}))})),[3,54];case 31:if(!(dn=n.as(X).event).isOpenChannelEvent)return[3,53];switch(dn.category){case Y.CHANNEL_ENTER:return[3,32];case Y.CHANNEL_EXIT:return[3,34];case Y.CHANNEL_OPERATOR_UPDATE:return[3,36];case Y.USER_CHANNEL_MUTE:case Y.USER_CHANNEL_UNMUTE:return[3,38];case Y.USER_CHANNEL_BAN:case Y.USER_CHANNEL_UNBAN:return[3,40];case Y.CHANNEL_FREEZE:case Y.CHANNEL_UNFREEZE:return[3,42];case Y.CHANNEL_DELETED:return[3,44];case Y.CHANNEL_PROP_CHANGED:return[3,47];case Y.CHANNEL_META_DATA_CHANGED:return[3,49];case Y.CHANNEL_META_COUNTERS_CHANGED:return[3,51]}return[3,53];case 32:return[4,this.getChannel(dn.channelUrl,!0)];case 33:return pn=Yn.sent(),fn=n.as(vn),gn=fn.participantCount,Cn=fn.user,yn=pn._updateParticipantCount(gn,dn.ts),g((function(){return e(Xn,void 0,void 0,(function(){return t(this,(function(n){return this._openChannelHandlers.forEach((function(n){n.onUserEntered(pn,Cn),yn&&n.onChannelParticipantCountChanged(pn)})),[2]}))}))})),[3,53];case 34:return[4,this.getChannel(dn.channelUrl,!0)];case 35:return mn=Yn.sent(),En=n.as(_n),gn=En.participantCount,Un=En.user,wn=mn._updateParticipantCount(gn,dn.ts),g((function(){return e(Xn,void 0,void 0,(function(){return t(this,(function(n){return this._openChannelHandlers.forEach((function(n){n.onUserExited(mn,Un),wn&&n.onChannelParticipantCountChanged(mn)})),[2]}))}))})),[3,53];case 36:return[4,this.getChannel(dn.channelUrl,!0)];case 37:return Tn=Yn.sent(),Nn=n.as(Z).operators,Tn.operators=Nn,this.upsertChannelsToCache([Tn]),g((function(){return e(Xn,void 0,void 0,(function(){return t(this,(function(n){return this._openChannelHandlers.forEach((function(n){n.onOperatorUpdated(Tn,Nn)})),[2]}))}))})),[3,53];case 38:return[4,this.getChannel(dn.channelUrl,!0)];case 39:return Mn=Yn.sent(),bn=dn.category===Y.USER_CHANNEL_MUTE,Hn=n.as(bn?z:Q).user,g((function(){return e(Xn,void 0,void 0,(function(){return t(this,(function(n){return this._openChannelHandlers.forEach((function(n){bn?n.onUserMuted(Mn,Hn):n.onUserUnmuted(Mn,Hn)})),[2]}))}))})),[3,53];case 40:return[4,this.getChannel(dn.channelUrl,!0)];case 41:return Pn=Yn.sent(),On=dn.category===Y.USER_CHANNEL_BAN,xn=n.as(On?S:q).user,g((function(){return e(Xn,void 0,void 0,(function(){return t(this,(function(n){return this._openChannelHandlers.forEach((function(n){On?n.onUserBanned(Pn,xn):n.onUserUnbanned(Pn,xn)})),[2]}))}))})),[3,53];case 42:return[4,this.getChannel(dn.channelUrl,!0)];case 43:return Dn=Yn.sent(),In=n.as(k).freeze,Dn.isFrozen=In,this.upsertChannelsToCache([Dn]),g((function(){return e(Xn,void 0,void 0,(function(){return t(this,(function(n){return this._openChannelHandlers.forEach((function(n){In?n.onChannelFrozen(Dn):n.onChannelUnfrozen(Dn)})),[2]}))}))})),[3,53];case 44:return[4,this.getChannel(dn.channelUrl,!0)];case 45:return An=Yn.sent(),[4,this.removeChannelsFromCache([An.url])];case 46:return Yn.sent(),g((function(){return e(Xn,void 0,void 0,(function(){return t(this,(function(n){return this._openChannelHandlers.forEach((function(n){n.onChannelDeleted(An.url,An.channelType)})),[2]}))}))})),[3,53];case 47:return[4,this.getChannelWithoutCache(dn.channelUrl,!0)];case 48:return Ln=Yn.sent(),g((function(){return e(Xn,void 0,void 0,(function(){return t(this,(function(n){return this._openChannelHandlers.forEach((function(n){n.onChannelChanged(Ln)})),[2]}))}))})),[3,53];case 49:return[4,this.getChannel(dn.channelUrl,!0)];case 50:return Rn=Yn.sent(),Fn=n.as(F),kn=Fn.created,Sn=Fn.updated,qn=Fn.deleted,kn&&Rn._upsertCachedMetaData(kn,dn.ts),Sn&&Rn._upsertCachedMetaData(Sn,dn.ts),qn&&Rn._removeFromCachedMetaData(qn,dn.ts),g((function(){return e(Xn,void 0,void 0,(function(){return t(this,(function(n){return this._openChannelHandlers.forEach((function(n){kn&&n.onMetaDataCreated(Rn,kn),Sn&&n.onMetaDataUpdated(Rn,Sn),qn&&n.onMetaDataDeleted(Rn,qn)})),[2]}))}))})),[3,53];case 51:return[4,this.getChannel(dn.channelUrl,!0)];case 52:return zn=Yn.sent(),Qn=n.as(R),jn=Qn.created,Kn=Qn.updated,Bn=Qn.deleted,g((function(){return e(Xn,void 0,void 0,(function(){return t(this,(function(n){return this._openChannelHandlers.forEach((function(n){jn&&n.onMetaCounterCreated(zn,jn),Kn&&n.onMetaCounterUpdated(zn,Kn),Bn&&n.onMetaCounterDeleted(zn,Bn)})),[2]}))}))})),[3,53];case 53:return[3,54];case 54:return[3,56];case 55:if(Vn=Yn.sent(),E(Vn))throw Vn;return[3,56];case 56: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:M(i("string",n)).throw(b.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 M(i("string",n)).throw(b.invalidParameters),e=new hn({channelUrl:n,isInternalCall:r}),[4,this._requestQueue.send(e)];case 1:return a=t.sent(),s=a.as(dn).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({},ln),n),M(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)&&i("boolean",n.isEphemeral,!0)}(e)).throw(b.invalidParameters),r=new pn(e),[4,this._requestQueue.send(r)];case 1:return o=t.sent(),u=o.as(dn).channel,this.upsertChannelsToCache([u]),[2,u]}}))}))},n}(),En={name:null,coverUrlOrImage:null,data:null,customType:null,operatorUserIds:null},gn=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),Un=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 un(n,e)})),r}return n(t,e),t}(h),wn=function(r){function a(n,e,t){return r.call(this,n,e,N.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=x.of(this._iid).requestQueue,e=new gn(H(H({},this),{token:this._token})),[4,n.send(e)]):[3,2]:[3,5];case 1:return r=t.sent(),a=r.as(Un),i=a.participants,s=a.token,this._token=s,this._hasNext=!!s,this._isLoading=!1,[2,i];case 2:return[2,[]];case 3:throw b.queryInProgress;case 4:return[3,6];case 5:throw b.invalidParameters;case 6:return[2]}}))}))},a}(O),Tn=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),Nn=function(e){function t(n,t){var r=e.call(this,n,t)||this;return r.channel=new bn(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 bn=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=N.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({},G.payloadify(n)),{participant_count:n.participantCount,operators:n.operators.map((function(n){return f.payloadify(n)}))})):null},o.prototype.serialize=function(){return D(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 wn(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,mn.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=x.of(this._iid).requestQueue,e=new fn({channelUrl:this.url}),[4,n.send(e)];case 1:return r=t.sent(),a=r.as(vn),i=a.participantCount,s=a.ts,this._updateParticipantCount(i,s),mn.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=x.of(this._iid).requestQueue,e=new Cn({channelUrl:this.url}),[4,n.send(e)];case 1:return r=t.sent(),a=r.as(_n),i=a.participantCount,s=a.ts,this._updateParticipantCount(i,s),mn.of(this._iid).setExitedToCache(this),on.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({},En),n),M(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(b.invalidParameters),r=x.of(this._iid).requestQueue,o=new Tn(H({channelUrl:this.url},e)),[4,r.send(o)];case 1:return u=t.sent(),c=u.as(Nn).channel,[4,mn.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({},En),{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=x.of(this._iid).requestQueue,e=new Mn({channelUrl:this.url}),[4,n.send(e)];case 1:return t.sent(),[4,mn.of(this._iid).removeChannelsFromCache([this.url])];case 2:return t.sent(),[2]}}))}))},o.prototype.sendUserMessage=function(n){return M(!n.isPinnedMessage).throw(b.notSupportedError),r.prototype.sendUserMessage.call(this,n)},o.prototype.sendFileMessage=function(n){return M(!n.isPinnedMessage).throw(b.notSupportedError),r.prototype.sendFileMessage.call(this,n)},o}(G),Hn=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=I,n.onUserExited=I,n.onChannelParticipantCountChanged=I,n.onPollUpdated=I,n.onPollVoted=I,n.onPollDeleted=I,n}return n(t,e),t}(an)),Pn=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),On=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 bn(n,e)}))),r.ts="number"==typeof s?s:null,r}return n(t,e),t}(h),xn=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=x.of(this._iid).requestQueue,e=new Pn(H(H({},this),{token:this._token})),[4,n.send(e)]):[3,3]:[3,6];case 1:return r=t.sent(),a=r.as(On),i=a.channels,s=a.token,this._token=s,this._hasNext=!!s,[4,mn.of(this._iid).upsertChannelsToCache(i)];case 2:return t.sent(),this._isLoading=!1,[2,i];case 3:return[2,[]];case 4:throw b.queryInProgress;case 5:return[3,7];case 6:throw b.invalidParameters;case 7:return[2]}}))}))},s}(A),Dn=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 mn(n,{sdkState:t,dispatcher:a,requestQueue:s})},a.prototype.createOpenChannelListQuery=function(n){return void 0===n&&(n={}),new xn(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({},ln)).name=n,e.coverUrlOrImage=r,e.data=a,e.operatorUserIds=i,e.customType=s,[2,this._manager.createChannel(e)]}))}))},a}(L);export{bn as OpenChannel,Hn as OpenChannelHandler,xn as OpenChannelListQuery,Dn as OpenChannelModule,wn as ParticipantListQuery}; diff --git a/package.json b/package.json index 3a30437..1d5a8f4 100644 --- a/package.json +++ b/package.json @@ -1,5 +1,5 @@ { - "version": "4.8.1", + "version": "4.8.2", "description": "Sendbird SDK for JavaScript", "name": "@sendbird/chat", "author": "Sendbird ", diff --git a/poll.js b/poll.js index 6141945..2713371 100644 --- a/poll.js +++ b/poll.js @@ -1 +1 @@ -import{_ as t,b as e,aj as r,c as n,g as o,r as s,S as u}from"./__bundle-03ba89c3.js";export{a4 as Poll,ak as PollOption,al as PollStatus}from"./__bundle-03ba89c3.js";import{b as l,c,v as d,d as p,e as g,f,g as v}from"./__bundle-9e0eba5d.js";export{P as PollListQuery,h as PollUpdateEvent,i as PollVoteEvent,a as PollVoterListQuery}from"./__bundle-9e0eba5d.js";var m=function(r){function a(){var t=null!==r&&r.apply(this,arguments)||this;return t.name="poll",t}return t(a,r),a.prototype.init=function(t,e){var a=e.sdkState,n=e.dispatcher,o=e.sessionManager,i=e.requestQueue,s=e.logger,u=e.onlineDetector,c=e.cacheContext;r.prototype.init.call(this,t,{sdkState:a,dispatcher:n,sessionManager:o,requestQueue:i,logger:s,onlineDetector:u,cacheContext:c}),this._manager=new l(t,{sdkState:a,dispatcher:n,sessionManager:o,requestQueue:i,logger:s,onlineDetector:u,cacheContext:c})},a.prototype.create=function(t){return e(this,void 0,void 0,(function(){var e;return n(this,(function(r){return e=o(o({},c),t),s(d(e)).throw(u.invalidParameters),[2,this._manager.create(e)]}))}))},a.prototype.get=function(t){return e(this,void 0,void 0,(function(){var e;return n(this,(function(r){return e=o(o({},p),t),s(g(e)).throw(u.invalidParameters),[2,this._manager.get(e)]}))}))},a.prototype.getOption=function(t){return e(this,void 0,void 0,(function(){var e;return n(this,(function(r){return e=o(o({},f),t),s(v(e)).throw(u.invalidParameters),[2,this._manager.getOption(e)]}))}))},a.prototype.buildPollFromSerializedData=function(t){return this._manager.buildPollFromSerializedData(t)},a}(r);export{m as PollModule}; +import{_ as t,b as e,aj as r,c as n,g as o,r as s,S as u}from"./__bundle-ea43c8a8.js";export{a4 as Poll,ak as PollOption,al as PollStatus}from"./__bundle-ea43c8a8.js";import{b as l,c,v as p,d,e as f,f as g,g as v}from"./__bundle-9a0f0a93.js";export{P as PollListQuery,h as PollUpdateEvent,i as PollVoteEvent,a as PollVoterListQuery}from"./__bundle-9a0f0a93.js";var m=function(a){function r(){var t=null!==a&&a.apply(this,arguments)||this;return t.name="poll",t}return t(r,a),r.prototype.init=function(t,e){var r=e.sdkState,n=e.dispatcher,o=e.sessionManager,i=e.requestQueue,s=e.logger,u=e.onlineDetector,c=e.cacheContext;a.prototype.init.call(this,t,{sdkState:r,dispatcher:n,sessionManager:o,requestQueue:i,logger:s,onlineDetector:u,cacheContext:c}),this._manager=new l(t,{sdkState:r,dispatcher:n,sessionManager:o,requestQueue:i,logger:s,onlineDetector:u,cacheContext:c})},r.prototype.create=function(t){return e(this,void 0,void 0,(function(){var e;return n(this,(function(a){return e=o(o({},c),t),s(p(e)).throw(u.invalidParameters),[2,this._manager.create(e)]}))}))},r.prototype.get=function(t){return e(this,void 0,void 0,(function(){var e;return n(this,(function(a){return e=o(o({},d),t),s(f(e)).throw(u.invalidParameters),[2,this._manager.get(e)]}))}))},r.prototype.getOption=function(t){return e(this,void 0,void 0,(function(){var e;return n(this,(function(a){return e=o(o({},g),t),s(v(e)).throw(u.invalidParameters),[2,this._manager.getOption(e)]}))}))},r.prototype.buildPollFromSerializedData=function(t){return this._manager.buildPollFromSerializedData(t)},r}(r);export{m as PollModule}; diff --git a/sendbird.js b/sendbird.js index bd345c6..b98b91b 100644 --- a/sendbird.js +++ b/sendbird.js @@ -1 +1 @@ -import{i as e,a as t,_ as n,n as r,b as s,c as o,E as a,A as u,d,e as l,f as p,U as v,g as _,h as y,P as b,j as w,k,l as I,B as T,S as E,V as D,m as A,L as j,u as z,o as q,p as x,q as H,v as G,C as W,r as V,s as X,t as Y,w as Z,W as $,x as ee,y as te,z as ne,D as re,F as ie,G as se,H as oe,I as ae,J as ue,K as ce}from"./__bundle-03ba89c3.js";export{N as CachedChannelInfo,M as ChannelType,C as ConnectionState,L as LocalCacheConfig,O as LogLevel,K as PushTemplate,F as PushTokenRegistrationState,P as PushTokenType,J as PushTriggerOption,R as Role,m as SendbirdChatOptions,S as SendbirdError,U as User,Q as UserOnlineState}from"./__bundle-03ba89c3.js";import{M as de,a as le}from"./__bundle-51a2cdbc.js";export{P as Plugin}from"./__bundle-51a2cdbc.js";import{PollModule as he}from"./poll.js";import{N as fe,a as pe,b as ve,c as _e,d as me,e as ge}from"./__bundle-edc633d6.js";export{B as BannedUserListQuery,f as BaseChannel,M as MutedUserListQuery,O as OperatorListQuery,R as ReportCategory,g as RestrictedUser,h as RestrictionInfo,i as RestrictionType}from"./__bundle-edc633d6.js";import{g as ye,G as be,a as we,M as ke,N as Ie,b as Se,c as Ce,A as Te,I as Pe,d as Ee,U as De,e as Ue,f as Oe,D as Le,h as Ne,i as Ae,j as Me,R as Re,k as Fe}from"./__bundle-7ac921c4.js";export{c as MemoryStore}from"./__bundle-7ac921c4.js";import{P as je,a as ze}from"./__bundle-9e0eba5d.js";export{P as Participant}from"./__bundle-5ab69bcd.js";var qe={profileImage:null,profileUrl:null,nickname:null},Qe=function(e){function t(t){void 0===t&&(t={});var n=e.call(this)||this;return Object.keys(t).forEach((function(e){n.hasOwnProperty(e)&&(n[e]=t[e])})),n}return n(t,e),t}((function(){this.onSessionExpired=r,this.onSessionTokenRequired=function(e){return e(null)},this.onSessionError=r,this.onSessionRefreshed=r,this.onSessionClosed=r})),xe=function(e){function t(t){void 0===t&&(t={});var n=e.call(this)||this;return Object.keys(t).forEach((function(e){n.hasOwnProperty(e)&&(n[e]=t[e])})),n}return n(t,e),t}((function(){this.onConnected=r,this.onReconnectStarted=r,this.onReconnectSucceeded=r,this.onReconnectFailed=r,this.onDisconnected=r})),He=function(e){function t(t){void 0===t&&(t={});var n=e.call(this)||this;return Object.keys(t).forEach((function(e){n.hasOwnProperty(e)&&(n[e]=t[e])})),n}return n(t,e),t}((function(){this.onFriendsDiscovered=r,this.onTotalUnreadMessageCountUpdated=r})),Ge=function(e,t){return function(n,r){if(1===n)e.clear().then((function(){t.clear().then((function(){(function(e){return s(void 0,void 0,void 0,(function(){return o(this,(function(t){return[2,e.commitSchema([{collectionName:fe,keyName:pe,index:[ye(be.LATEST_LAST_MESSAGE),ye(be.CHRONOLOGICAL),ye(be.CHANNEL_NAME_ALPHABETICAL)]},{collectionName:ve,keyName:_e,index:[we(ke.CHANNEL_LATEST),we(ke.NEWEST_CHILD_MESSAGE)]},{collectionName:Ie,keyName:Se,index:[we(ke.CHANNEL_LATEST),we(ke.NEWEST_CHILD_MESSAGE)]},{collectionName:me,keyName:ge}])]}))}))})(e).then((function(){return r()})).catch((function(e){return r(e)}))})).catch((function(e){return r(e)}))})).catch((function(e){return r(e)}));else r()}},We=function(){return"undefined"!=typeof document?document.visibilityState:"visible"},Ke=function(e){function t(t){var n=t.getVisibilityState,r=void 0===n?We:n,i=t.initialState,s=void 0===i?"visible":i,o=t.isEnabled,a=void 0===o||o,u=t.pauseCheckDelay,c=void 0===u?3e4:u,d=e.call(this)||this;return d._pauseCheckDelay=3e4,d._pauseDelayTimer=null,d._currentState="visible",d._getVisibilityState=r,d._pauseCheckDelay=c,d._currentState=s,d._isEnabled=a,d._boundToggleState=d._toggleState.bind(d),d}return n(t,e),Object.defineProperty(t.prototype,"currentState",{get:function(){return this._currentState},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"isAvailable",{get:function(){return"undefined"!=typeof window&&!!window.addEventListener&&!!window.removeEventListener},enumerable:!1,configurable:!0}),t.prototype._toggleState=function(){var e=this,t=this._getVisibilityState();"hidden"!==t?"hidden"===this._currentState&&(this._pauseDelayTimer&&(clearTimeout(this._pauseDelayTimer),this._pauseDelayTimer=null),this.dispatch("resume")):"hidden"!==this._currentState&&(this._pauseDelayTimer=setTimeout((function(){e._pauseDelayTimer=null,e.dispatch("pause")}),this._pauseCheckDelay)),this._currentState=t},t.prototype.start=function(){this._isEnabled&&this.isAvailable&&(this._boundToggleState=this._toggleState.bind(this),window.addEventListener("visibilitychange",this._boundToggleState,{capture:!0}))},t.prototype.stop=function(){this._isEnabled&&this.isAvailable&&this._boundToggleState&&window.removeEventListener("visibilitychange",this._boundToggleState,{capture:!0})},t}(a),Ve=function(){function e(e){var t=e.logger,n=e.connectionDelegate,r=void 0===n?null:n,i=this;this._onlineWorker=function(){var e;return null===(e=i.connectionDelegate)||void 0===e?void 0:e.reconnect()},this._offlineWorker=function(){var e;return null===(e=i.connectionDelegate)||void 0===e?void 0:e.disconnect()},this.unsubscribes=[],this._onlineListener=function(e){if(i.isAvailableOnWeb)return window.addEventListener("online",e),function(){return window.removeEventListener("online",e,!1)}},this._offlineListener=function(e){if(i.isAvailableOnWeb)return window.addEventListener("offline",e),function(){return window.removeEventListener("offline",e,!1)}},this.logger=t,r&&(this.connectionDelegate=r)}return Object.defineProperty(e.prototype,"isAvailableOnWeb",{get:function(){return"undefined"!=typeof window&&window.addEventListener&&"ononline"in window&&"onoffline"in window&&"undefined"!=typeof navigator&&void 0!==navigator.onLine},enumerable:!1,configurable:!0}),e.prototype.setOnlineListener=function(e){Boolean(e)&&"function"==typeof e&&(this._onlineListener=e)},e.prototype.setOfflineListener=function(e){Boolean(e)&&"function"==typeof e&&(this._offlineListener=e)},e.prototype.start=function(){this.unsubscribes=[this._onlineListener(this._onlineWorker),this._offlineListener(this._offlineWorker)]},e.prototype.stop=function(){var e=this;this.unsubscribes.forEach((function(t){try{null==t||t()}catch(t){e.logger.warn(t.message)}})),this.unsubscribes=[]},e.prototype.isOnline=function(){return s(this,void 0,void 0,(function(){return o(this,(function(e){return this.isAvailableOnWeb?[2,navigator.onLine]:[2,new Promise((function(e){fetch("https://www.google.com",{method:u.GET,mode:"no-cors"}).then((function(){return e(!0)})).catch((function(){return e(!1)}))}))]}))}))},e}(),Be=function(e){function t(t){var n=t.userId,r=t.nickname,i=void 0===r?null:r,s=t.profileUrl,o=void 0===s?null:s,a=t.profileImage,c=void 0===a?null:a,h=t.preferredLanguages,f=void 0===h?null:h,p=e.call(this)||this;return p.method=u.PUT,p.path="".concat(d,"/").concat(encodeURIComponent(n)),p.params=l({nickname:i,profile_url:o,profile_file:c,preferred_languages:f}),p}return n(t,e),t}(p),Je=function(e){function t(t,n){var r=e.call(this,t,n)||this;return r.user=null,r.user=new v(t,_({},n)),r}return n(t,e),t}(y),Xe=function(e){function t(t){var n=t.userId,r=t.token,i=e.call(this)||this;return i.method=u.POST,i.path="".concat(d,"/").concat(encodeURIComponent(n),"/push/apns"),i.params={apns_device_token:r,always_push:!0},i}return n(t,e),t}(p);!function(e){function t(t,n){var r=e.call(this,t,n)||this;return r.token=n.token,r.type=n.type?b[n.type.toLowerCase()]:b.UNKNOWN,r.user=new v(t,n.user),r}n(t,e)}(y);var Ye=function(e){function t(t){var n=t.userId,r=t.token,i=e.call(this)||this;return i.method=u.POST,i.path="".concat(d,"/").concat(encodeURIComponent(n),"/push/gcm"),i.params={gcm_reg_token:r,always_push:!0},i}return n(t,e),t}(p);!function(e){function t(t,n){var r=e.call(this,t,n)||this;return r.token=n.token,r.type=n.type?b[n.type.toLowerCase()]:b.UNKNOWN,r.user=new v(t,n.user),r}n(t,e)}(y);var Ze=function(e){function t(t){var n=t.userId,r=t.token,i=e.call(this)||this;return i.method=u.DELETE,i.path="".concat(d,"/").concat(encodeURIComponent(n),"/push/apns/").concat(encodeURIComponent(r)),i}return n(t,e),t}(p);!function(e){function t(t,n){var r=e.call(this,t,n)||this;return r.token=n.token,r.user=new v(t,n.user),r.lastDeletedAt=n.device_token_last_deleted_at,r}n(t,e)}(y);var $e=function(e){function t(t){var n=t.userId,r=t.token,i=e.call(this)||this;return i.method=u.DELETE,i.path="".concat(d,"/").concat(encodeURIComponent(n),"/push/gcm/").concat(encodeURIComponent(r)),i}return n(t,e),t}(p);!function(e){function t(t,n){var r=e.call(this,t,n)||this;return r.token=n.token,r.user=new v(t,n.user),r.lastDeletedAt=n.device_token_last_deleted_at,r}n(t,e)}(y);var et=function(e){function t(t){var n=t.userId,r=e.call(this)||this;return r.method=u.DELETE,r.path="".concat(d,"/").concat(encodeURIComponent(n),"/push/apns"),r}return n(t,e),t}(p);!function(e){function t(t,n){var r=e.call(this,t,n)||this;return r.type=n.type?b[n.type.toLowerCase()]:b.UNKNOWN,r.user=new v(t,n.user),r.lastDeletedAt=n.device_token_last_deleted_at,r}n(t,e)}(y);var tt=function(e){function t(t){var n=t.userId,r=e.call(this)||this;return r.method=u.DELETE,r.path="".concat(d,"/").concat(encodeURIComponent(n),"/push/gcm"),r}return n(t,e),t}(p);!function(e){function t(t,n){var r=e.call(this,t,n)||this;return r.type=n.type?b[n.type.toLowerCase()]:b.UNKNOWN,r.user=new v(t,n.user),r.lastDeletedAt=n.device_token_last_deleted_at,r}n(t,e)}(y);var nt=function(e){function t(t){var n=t.userId,r=t.type,i=t.token,s=t.ts,o=e.call(this)||this;return o.method=u.GET,o.path="".concat(d,"/").concat(encodeURIComponent(n),"/push/").concat(encodeURIComponent(r),"/device_tokens"),o.params={created_ts:s,token:i},o}return n(t,e),t}(p),rt=function(e){function t(t,n){var r=e.call(this,t,n)||this;return r.pushTokens={type:n.type?b[n.type.toLowerCase()]:b.UNKNOWN,deviceTokens:n.device_tokens,hasMore:n.has_more,token:n.token},r}return n(t,e),t}(y),it=function(e){function t(t){var n=t.userId,r=e.call(this)||this;return r.method=u.GET,r.path="".concat(d,"/").concat(encodeURIComponent(n),"/channel_invitation_preference"),r}return n(t,e),t}(p),st=function(e){function t(t,n){var r=e.call(this,t,n)||this;return r.autoAccept=n.auto_accept,r}return n(t,e),t}(y),ot=function(e){function t(t){var n=t.userId,r=t.willAutoAccept,i=e.call(this)||this;return i.method=u.PUT,i.path="".concat(d,"/").concat(encodeURIComponent(n),"/channel_invitation_preference"),i.params={auto_accept:r},i}return n(t,e),t}(p),at=function(e){function t(t,n){var r=e.call(this,t,n)||this;return r.autoAccept=n.auto_accept,r}return n(t,e),t}(y),ut=function(e){function t(t){var n=t.userId,r=e.call(this)||this;return r.method=u.GET,r.path="".concat(d,"/").concat(encodeURIComponent(n),"/push_preference"),r}return n(t,e),t}(p),ct=function(e){function t(t,n){var r=e.call(this,t,n)||this;return r.preference={doNotDisturbOn:n.do_not_disturb,startHour:n.start_hour,startMin:n.start_min,endHour:n.end_hour,endMin:n.end_min,timezone:n.timezone},r}return n(t,e),t}(y),dt=function(e){function t(t){var n=t.userId,r=t.doNotDisturbOn,i=t.startHour,s=t.startMin,o=t.endHour,a=t.endMin,c=t.timezone,l=e.call(this)||this;return l.method=u.PUT,l.path="".concat(d,"/").concat(encodeURIComponent(n),"/push_preference"),l.params={do_not_disturb:r,start_hour:i,start_min:s,end_hour:o,end_min:a,timezone:c},l}return n(t,e),t}(p),lt=function(e){function t(t,n){var r=e.call(this,t,n)||this;return r.preference={doNotDisturbOn:n.do_not_disturb,startHour:n.start_hour,startMin:n.start_min,endHour:n.end_hour,endMin:n.end_min,timezone:n.timezone},r}return n(t,e),t}(y),ht=function(e){function t(t){var n=t.userId,r=e.call(this)||this;return r.method=u.GET,r.path="".concat(d,"/").concat(encodeURIComponent(n),"/push_preference"),r}return n(t,e),t}(p),ft=function(e){function t(t,n){var r=e.call(this,t,n)||this;return r.snoozePeriod={isSnoozeOn:n.snooze_enabled},"number"==typeof n.snooze_start_ts&&(r.snoozePeriod.startTs=n.snooze_start_ts),"number"==typeof n.snooze_end_ts&&(r.snoozePeriod.endTs=n.snooze_end_ts),r}return n(t,e),t}(y),pt=function(e){function t(t){var n=t.userId,r=t.snoozeOn,i=t.startTs,s=t.endTs,o=e.call(this)||this;return o.method=u.PUT,o.path="".concat(d,"/").concat(encodeURIComponent(n),"/push_preference"),o.params={snooze_enabled:r,snooze_start_ts:i,snooze_end_ts:s},o}return n(t,e),t}(p),vt=function(e){function t(t,n){var r=e.call(this,t,n)||this;return r.snoozePeriod={isSnoozeOn:n.snooze_enabled},"number"==typeof n.snooze_start_ts&&(r.snoozePeriod.startTs=n.snooze_start_ts),"number"==typeof n.snooze_end_ts&&(r.snoozePeriod.endTs=n.snooze_end_ts),r}return n(t,e),t}(y),_t=function(e){function t(t){var n=t.userId,r=t.blockedUserId,i=e.call(this)||this;return i.method=u.POST,i.path="".concat(d,"/").concat(encodeURIComponent(n),"/block"),i.params={target_id:r},i}return n(t,e),t}(p);!function(e){function t(t,n){var r=e.call(this,t,n)||this;return r.user=new v(t,n),r}n(t,e)}(y);var mt=function(e){function t(t){var n=t.userId,r=t.unblockedUserId,i=e.call(this)||this;return i.method=u.DELETE,i.path="".concat(d,"/").concat(encodeURIComponent(n),"/block/").concat(encodeURIComponent(r)),i}return n(t,e),t}(p);!function(e){function t(){return null!==e&&e.apply(this,arguments)||this}n(t,e)}(y);var gt=function(e){function t(t){var n=t.userId,r=e.call(this)||this;return r.method=u.GET,r.path="".concat(d,"/").concat(encodeURIComponent(n),"/push_preference"),r}return n(t,e),t}(p),yt=function(e){function t(t,n){var r=e.call(this,t,n)||this;return r.pushTriggerOption=n.push_trigger_option,r}return n(t,e),t}(y),bt=function(e){function t(t){var n=t.userId,r=t.pushTriggerOption,i=e.call(this)||this;return i.method=u.PUT,i.path="".concat(d,"/").concat(encodeURIComponent(n),"/push_preference"),i.params={push_trigger_option:r},i}return n(t,e),t}(p),wt=function(e){function t(t,n){var r=e.call(this,t,n)||this;return r.pushTriggerOption=n.push_trigger_option,r}return n(t,e),t}(y),kt=function(e){function t(t){var n=t.userId,r=e.call(this)||this;return r.method=u.GET,r.path="".concat(d,"/").concat(encodeURIComponent(n),"/push/template"),r}return n(t,e),t}(p),It=function(e){function t(t,n){var r=e.call(this,t,n)||this;return r.name=n.name,r}return n(t,e),t}(y),St=function(e){function t(t){var n=t.userId,r=t.templateName,i=e.call(this)||this;return i.method=u.PUT,i.path="".concat(d,"/").concat(encodeURIComponent(n),"/push/template"),i.params={name:r},i}return n(t,e),t}(p),Ct=function(e){function t(t,n){var r=e.call(this,t,n)||this;return r.name=n.name,r}return n(t,e),t}(y),Tt=function(e){function t(t){var n=t.userId,r=t.token,i=e.call(this)||this;return i.method=u.GET,i.path="".concat(d,"/").concat(encodeURIComponent(n),"/friends/changelogs"),i.params={token:r},i}return n(t,e),t}(p),Pt=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 v(t,e)})),updatedUsers:n.updated.map((function(e){return new v(t,e)})),deletedUserIds:n.deleted,hasMore:n.has_more,token:n.next},r}return n(t,e),t}(y),Et=function(e){function t(t){var n=t.userId,r=t.discoveries,i=e.call(this)||this;return i.method=u.PUT,i.path="".concat(d,"/").concat(encodeURIComponent(n),"/friend_discoveries"),i.params={friend_discoveries:r.map((function(e){return{friend_discovery_key:e.friendDiscoveryKey,friend_name:e.friendName}}))},i}return n(t,e),t}(p),Dt=function(e){function t(t,n){var r=e.call(this,t,n)||this;return r.friendDiscoveryRequestId=n.friend_discovery_request_id,r}return n(t,e),t}(y),Ut=function(e){function t(t){var n=t.userId,r=t.discoveryKeys,i=e.call(this)||this;return i.method=u.DELETE,i.path="".concat(d,"/").concat(encodeURIComponent(n),"/friend_discoveries"),i.params={friend_discovery_keys:r},i}return n(t,e),t}(p);!function(e){function t(){return null!==e&&e.apply(this,arguments)||this}n(t,e)}(y);var Ot=function(e){function t(t){var n=t.userId,r=t.userIds,i=e.call(this)||this;return i.method=u.POST,i.path="".concat(d,"/").concat(encodeURIComponent(n),"/friends"),i.params={user_ids:r},i}return n(t,e),t}(p),Lt=function(e){function t(t,n){var r=e.call(this,t,n)||this;return r.users=n.users.map((function(e){return new v(t,e)})),r}return n(t,e),t}(y),Nt=function(e){function t(t){var n=t.userId,r=t.userIds,i=e.call(this)||this;return i.method=u.DELETE,i.path="".concat(d,"/").concat(encodeURIComponent(n),"/friends"),i.params={user_ids:r},i}return n(t,e),t}(p);!function(e){function t(){return null!==e&&e.apply(this,arguments)||this}n(t,e)}(y);var At=function(e){function t(t){var n=t.userId,r=e.call(this)||this;return r.method=u.GET,r.path="".concat(d,"/").concat(n,"/allow_friend_discovery"),r.params={},r}return n(t,e),t}(p),Mt=function(e){function t(t,n){var r=e.call(this,t,n)||this;return r.allowFriendDiscovery=n.allow_friend_discovery,r}return n(t,e),t}(y),Rt=function(e){function t(t){var n=t.userId,r=t.allowFriendDiscovery,i=e.call(this)||this;return i.method=u.PUT,i.path="".concat(d,"/").concat(n,"/allow_friend_discovery"),i.params={allow_friend_discovery:r},i}return n(t,e),t}(p);!function(e){function t(){return null!==e&&e.apply(this,arguments)||this}n(t,e)}(y);var Ft=function(e){this.key=null,this.url=null,this.key=e.key,this.url=e.url},jt=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 Ft(e)})):[]},zt=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 jt(e)})):[]},qt=function(e){function t(){var t=e.call(this)||this;return t.method=u.GET,t.path=w,t}return n(t,e),t}(p),Qt=function(e){function t(t,n){var r=e.call(this,t,n)||this;return r.emojiContainer=new zt(n),r}return n(t,e),t}(y),xt=function(e){function t(t){var n=t.categoryId,r=e.call(this)||this;return r.method=u.GET,r.path="".concat(w,"/").concat(n),r}return n(t,e),t}(p),Ht=function(e){function t(t,n){var r=e.call(this,t,n)||this;return r.emojiCategory=new jt(n),r}return n(t,e),t}(y),Gt=function(e){function t(t){var n=t.key,r=e.call(this)||this;return r.method=u.GET,r.path="".concat(k,"/").concat(n),r}return n(t,e),t}(p),Wt=function(e){function t(t,n){var r=e.call(this,t,n)||this;return r.emoji=new Ft(n),r}return n(t,e),t}(y),Kt=function(e){function t(t){var n=t.limit,r=t.token,i=t.userIdsFilter,s=t.metaDataKeyFilter,o=t.metaDataValuesFilter,a=t.nicknameStartsWithFilter,c=e.call(this)||this;return c.method=u.GET,c.path=d,c.params=l({limit:n,token:r,user_ids:i,metadatakey:s,metadatavalues_in:o,nickname_startswith:a}),c}return n(t,e),t}(p),Vt=function(e){function t(t,n){var r=e.call(this,t,n)||this;return r.users=n.users.map((function(e){return new v(t,e)})),r.next=n.next,r}return n(t,e),t}(y),Bt=function(e){function r(t,n){var r,i,s,o=this;return(o=e.call(this,t,n)||this).userIdsFilter=null,o.metaDataKeyFilter=null,o.metaDataValuesFilter=null,o.nicknameStartsWithFilter=null,o.userIdsFilter=null!==(r=n.userIdsFilter)&&void 0!==r?r:null,o.metaDataKeyFilter=null!==(i=n.metaDataKeyFilter)&&void 0!==i?i:null,o.metaDataValuesFilter=null!==(s=n.metaDataValuesFilter)&&void 0!==s?s:null,o.nicknameStartsWithFilter=n.nicknameStartsWithFilter||null,o}return n(r,e),r.prototype._validate=function(){return e.prototype._validate.call(this)&&I("string",this.userIdsFilter,!0)&&t("string",this.metaDataKeyFilter,!0)&&I("string",this.metaDataValuesFilter,!0)&&t("string",this.metaDataKeyFilter,!0)},r.prototype.next=function(){return s(this,void 0,void 0,(function(){var e,t,n,r,i,s;return o(this,(function(o){switch(o.label){case 0:return this._validate()?this._isLoading?[3,3]:this._hasNext?(this._isLoading=!0,e=D.of(this._iid).requestQueue,t=new Kt(_(_({},this),{token:this._token})),[4,e.send(t)]):[3,2]:[3,5];case 1:return n=o.sent(),r=n.as(Vt),i=r.users,s=r.next,this._token=s,this._hasNext=!!s,this._isLoading=!1,[2,i];case 2:return[2,[]];case 3:throw E.queryInProgress;case 4:return[3,6];case 5:throw E.invalidParameters;case 6:return[2]}}))}))},r}(T),Jt=function(e){function t(t){var n=t.userId,r=t.limit,i=t.token,s=t.userIdsFilter,o=e.call(this)||this;return o.method=u.GET,o.path="".concat(d,"/").concat(n,"/block"),o.params=l({limit:r,token:i,user_ids:s}),o}return n(t,e),t}(p),Xt=function(e){function t(t,n){var r=e.call(this,t,n)||this;return r.users=n.users.map((function(e){return new v(t,e)})),r.next=n.next,r}return n(t,e),t}(y),Yt=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)&&I("string",this.userIdsFilter,!0)},t.prototype.next=function(){return s(this,void 0,void 0,(function(){var e,t,n,r,i,s,a,u;return o(this,(function(o){switch(o.label){case 0:return this._validate()?this._isLoading?[3,3]:this._hasNext?(this._isLoading=!0,e=D.of(this._iid),t=e.sdkState,n=e.requestQueue,r=new Jt(_(_({},this),{userId:t.userId,token:this._token})),[4,n.send(r)]):[3,2]:[3,5];case 1:return i=o.sent(),s=i.as(Xt),a=s.users,u=s.next,this._token=u,this._hasNext=!!u,this._isLoading=!1,[2,a];case 2:return[2,[]];case 3:throw E.queryInProgress;case 4:return[3,6];case 5:throw E.invalidParameters;case 6:return[2]}}))}))},t}(T),Zt=function(e){function t(t){var n=t.userId,r=t.limit,i=t.token,s=e.call(this)||this;return s.method=u.GET,s.path="".concat(d,"/").concat(encodeURIComponent(n),"/friends"),s.params={limit:r,token:i},s}return n(t,e),t}(p),$t=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 v(t,e)})),r.next=n.next,r}return n(t,e),t}(y),en=function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return n(t,e),t.prototype._validate=function(){return e.prototype._validate.call(this)},t.prototype.next=function(){return s(this,void 0,void 0,(function(){var e,t,n,r,i,s,a,u,c;return o(this,(function(o){switch(o.label){case 0:return this._validate()?this._isLoading?[3,3]:this._hasNext?(this._isLoading=!0,e=D.of(this._iid),t=e.sdkState,n=e.requestQueue,r=new Zt(_(_({},this),{userId:t.userId,token:this._token})),[4,n.send(r)]):[3,2]:[3,5];case 1:return i=o.sent(),s=i.as($t),a=s.users,u=s.hasMore,c=s.next,this._token=c,this._hasNext=u,this._isLoading=!1,[2,a];case 2:return[2,[]];case 3:throw E.queryInProgress;case 4:return[3,6];case 5:throw E.invalidParameters;case 6:return[2]}}))}))},t}(T),tn=null,nn=function(){function n(e,t,n){var r=this;this._storeInitialized=!1,this._fcmPushToken=null,this._apnsPushToken=null,this._iid=e,this.options=t;var i=D.of(e),a=i.sdkState,u=i.cacheContext,c=i.dispatcher,d=i.sessionManager,l=i.requestQueue,h=i.logger,f=i.userEventHandlers,p=i.appStateToggleEnabled;this._onlineDetector=new Ve({logger:h,connectionDelegate:{reconnect:function(){var t=D.of(e),n=t.sdkState,r=t.connectionManager,i=t.sessionManager;i.auth.hasSession?"foreground"===n.appState&&r.resetAndReconnect():r.connect(i.auth.authToken)},disconnect:function(){D.of(e).connectionManager.disconnect()}}});var v=new Ee(e,{localCacheEnabled:u.localCacheEnabled,dispatcher:c,sdkState:a,logger:h});n.forEach((function(t){t.init(e,{sdkState:a,cacheContext:u,dispatcher:c,sessionManager:d,requestQueue:l,logger:h,onlineDetector:r._onlineDetector}),r[t.name]=t})),this._appStateChangeDetector=new Ke({isEnabled:p}),this._appStateChangeDetector.on("resume",(function(){h.debug("the page resumes from freeze"),r.setForegroundState()})).on("pause",(function(){h.debug("the page freezes"),r.setBackgroundState()})),c.on((function(t){if(t instanceof Y){if(t.stateType===Z.CONNECTED)v.processNonAutoResendRegisteredPendingMessages()}else if(t instanceof $){if("USEV"===t.code){var n=t.as(De).event;if(n.category===Ue.FRIEND_DISCOVERED){var i=Oe.getDataAsFriendDiscoveredEvent(e,n).friendDiscoveries;ee((function(){return s(r,void 0,void 0,(function(){return o(this,(function(e){return[2,f.forEach((function(e){e.onFriendsDiscovered(i)}))]}))}))}))}}}else if(t instanceof te){var c=D.of(r._iid).subscribedUnreadMessageCount,d=!1,l=t.ts;if("number"==typeof l&&l>c.ts){if(c.all!==t.all&&(d=!0),c.all=t.all>=0?t.all:0,t.customTypes)for(var h in t.customTypes)c.customTypes[h]!==t.customTypes[h]&&(d=!0),c.customTypes[h]=t.customTypes[h];d=d&&c.ts>0,c.ts=l}d&&ee((function(){return s(r,void 0,void 0,(function(){return o(this,(function(e){return[2,f.forEach((function(e){e.onTotalUnreadMessageCountUpdated(c.all,c.customTypes)}))]}))}))}))}else t instanceof ne&&u.preference.set(r._getUserProfileCacheKey(a.userId),re.payloadify(t.userProfile))}))}return n.init=function(e){var t=e.appId,r=e.appVersion,i=void 0===r?null:r,s=e.modules,o=void 0===s?[]:s,a=e.options,u=void 0===a?new A:a,c=e.debugMode,d=void 0!==c&&c,l=e.customApiHost,h=e.customWebSocketHost,f=e.newInstance,p=void 0!==f&&f,v=e.logLevel,_=e.localCacheEnabled,m=void 0!==_&&_,g=e.localCacheConfig,y=void 0===g?new j:g,b=e.localCacheEncryption,w=e.useAsyncStorageStore,k=void 0===w?null:w,I=e.appStateToggleEnabled,S=void 0===I||I;if(!tn||p){var C="su-".concat(z()),T=null!=b?b:{encrypt:function(e){return e},decrypt:function(e){return e}},P=new Ce({encryption:T});d||(P=q()?k?new Te({AsyncStorage:k,encryption:T}):new Ce({encryption:T}):new Pe({encryption:T})),new D(C,{appId:t,appVersion:i,options:u,apiHost:null!=l?l:"https://api-".concat(t,".sendbird.com"),websocketHost:null!=h?h:"wss://ws-".concat(t,".sendbird.com"),store:P,encryption:T,logLevel:v,localCacheEnabled:m,localCacheConfig:y,debugMode:d,appStateToggleEnabled:S});var E=[new de,new he],U=new n(C,u,x(x([],H(o),!1),H(E),!1));return tn||(tn=U),U}return tn},Object.defineProperty(n,"instance",{get:function(){return tn},enumerable:!1,configurable:!0}),Object.defineProperty(n,"version",{get:function(){return G},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"appId",{get:function(){return D.of(this._iid).sdkState.appId},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"appInfo",{get:function(){return D.of(this._iid).appInfo},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"appVersion",{get:function(){var e;return null!==(e=D.of(this._iid).sdkState.appVersion)&&void 0!==e?e:""},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"debugMode",{get:function(){return D.of(this._iid).debugMode},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"logLevel",{get:function(){return D.of(this._iid).logger.level},set:function(e){D.of(this._iid).logger.level=e},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"isCacheEnabled",{get:function(){return D.of(this._iid).cacheContext.localCacheEnabled},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"localCacheConfig",{get:function(){var e=D.of(this._iid).cacheContext;return e.localCacheEnabled?e.localCacheConfig:null},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"ekey",{get:function(){return D.of(this._iid).sessionManager.ekey},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"currentUser",{get:function(){var e;return null!==(e=D.of(this._iid).sessionManager.currentUser)&&void 0!==e?e:null},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"connectionState",{get:function(){var e=D.of(this._iid).connectionManager;return e.isConnected?W.OPEN:e.isConnecting?W.CONNECTING:W.CLOSED},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"lastConnectedAt",{get:function(){var e=D.of(this._iid),t=e.connectedAt;return e.connectionManager.isConnected?t:0},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"fcmPushToken",{get:function(){return this._fcmPushToken},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"apnsPushToken",{get:function(){return this._apnsPushToken},enumerable:!1,configurable:!0}),n.prototype._getCurrentPreferenceVersion=function(){return 1},n.prototype._getPreferenceCacheKey=function(e){return"sendbird@".concat(this.appId,"/").concat(e,".pref")},n.prototype._getUserProfileCacheKey=function(e){return"sendbird@".concat(this.appId,"/").concat(e,".profile")},n.prototype.getMemoryStoreForDebugging=function(){var e=D.of(this._iid),t=e.debugMode,n=e.cacheContext;if(t)return n.store instanceof Ce?n.store:null;throw E.debugModeRequired},n.prototype.addExtension=function(e,t){var n=D.of(this._iid).sdkState;["sb_uikit","sb_syncmanager","device-os-platform"].indexOf(e)>-1&&(n.extensions[e]=t)},n.prototype.setOnlineListener=function(e){this._onlineDetector.setOnlineListener(e)},n.prototype.setOfflineListener=function(e){this._onlineDetector.setOfflineListener(e)},n.prototype._safeInitializeStore=function(e){return s(this,void 0,void 0,(function(){var t;return o(this,(function(n){switch(n.label){case 0:t=D.of(this._iid).cacheContext,n.label=1;case 1:return n.trys.push([1,3,,5]),[4,t.store.init(e)];case 2:return n.sent(),this._storeInitialized=!0,[3,5];case 3:return n.sent(),t.store=new Ce,[4,this._safeInitializeStore(e)];case 4:return n.sent(),[3,5];case 5:return[2]}}))}))},n.prototype.initializeCache=function(e){return s(this,void 0,void 0,(function(){var t,n,r,i,s,a,u,c,d;return o(this,(function(o){switch(o.label){case 0:return t=D.of(this._iid),n=t.sdkState,r=t.cacheContext,i=t.connectionManager,s=t.dispatcher,a=t.logger,n.userId&&n.userId===e?[3,10]:[4,i.logout()];case 1:if(o.sent(),u="sendbird@".concat(n.appId,"/").concat(e,".db"),!r.localCacheEnabled)return[3,8];o.label=2;case 2:return o.trys.push([2,5,,7]),r.nestdb&&r.nestdb.state!==Fe.CLOSED&&r.nestdb.name===u?[3,4]:((c=r.nestdb=new Ne({name:"sendbird@".concat(n.appId,"/").concat(e,".db"),version:2,store:r.store})).on("upgrade",Ge(c,r.store)),[4,c.open()]);case 3:o.sent(),this._storeInitialized=!0,s.dispatch(new Le(this._iid,{userId:e})),o.label=4;case 4:return n.userId=e,[3,7];case 5:return d=o.sent(),a.warn("Nest DB Open Failed. ",d),[4,this._safeInitializeStore(u)];case 6:throw o.sent(),n.userId=e,E.databaseError;case 7:return[3,10];case 8:return[4,this._safeInitializeStore(u)];case 9:o.sent(),n.userId=e,o.label=10;case 10:return[2]}}))}))},n.prototype.getCacheDataSize=function(){return s(this,void 0,void 0,(function(){var e;return o(this,(function(t){switch(t.label){case 0:return(e=D.of(this._iid).cacheContext).localCacheEnabled&&e.nestdb?[4,e.nestdb.estimateUsage()]:[3,2];case 1:return[2,t.sent()];case 2:return[2,0]}}))}))},n.prototype.clearCachedData=function(){return s(this,void 0,void 0,(function(){var e;return o(this,(function(t){switch(t.label){case 0:return(e=D.of(this._iid).cacheContext).localCacheEnabled&&e.nestdb?[4,e.nestdb.clear()]:[3,2];case 1:t.sent(),t.label=2;case 2:return this._storeInitialized?[4,e.preference.clear()]:[3,4];case 3:t.sent(),t.label=4;case 4:return[2]}}))}))},n.prototype.clearCachedMessages=function(e){return s(this,void 0,void 0,(function(){var t,n,r=this;return o(this,(function(i){switch(i.label){case 0:return V(I("string",e)).throw(E.invalidParameters),t=Ae.of(this._iid),n=Me.of(this._iid),t&&n?[4,Promise.all(e.map((function(e){return s(r,void 0,void 0,(function(){return o(this,(function(r){switch(r.label){case 0:return[4,t.removeMessagesOfChannel(e)];case 1:return r.sent(),[4,n.removeMessagesOfChannel(e)];case 2:return r.sent(),[2]}}))}))})))]:[3,2];case 1:i.sent(),i.label=2;case 2:return[2]}}))}))},n.prototype.connect=function(e,n){return void 0===n&&(n=null),s(this,void 0,void 0,(function(){var r,i,s,a,u,c,d;return o(this,(function(o){switch(o.label){case 0:V(t("string",e)&&t("string",n,!0)).throw(E.invalidParameters),r=D.of(this._iid),i=r.sdkState,s=r.cacheContext,a=r.connectionManager,u=r.statLogCollector,this._onlineDetector.start(),this._appStateChangeDetector.start(),o.label=1;case 1:return o.trys.push([1,3,,4]),[4,this.initializeCache(e)];case 2:return o.sent(),D.of(this._iid).dispatcher.dispatch(new Re),[3,4];case 3:return o.sent(),c=D.of(this._iid).logger,s.localCacheEnabled=!1,c.warn("Cache initialization failed - cache is not available."),[3,4];case 4:return[4,s.preference.init(this._getPreferenceCacheKey(e),this._getCurrentPreferenceVersion())];case 5:return o.sent(),[4,s.preference.get(this._getUserProfileCacheKey(e))];case 6:return(d=o.sent())&&new re(this._iid,d).apply(),[4,u.init("sendbird@".concat(i.appId,"/").concat(e,".statlog"))];case 7:return o.sent(),[4,a.connect(n)];case 8:return o.sent(),[2,this.currentUser]}}))}))},n.prototype.reconnect=function(){var e=D.of(this._iid),t=e.connectionManager,n=e.sdkState,r=e.sessionManager.auth.hasSession;return r&&(this._appStateChangeDetector.start(),this._onlineDetector.start(),t.resetAndReconnect().then((function(){n.appState="foreground"})).catch((function(){}))),r},n.prototype.disconnect=function(){return s(this,void 0,void 0,(function(){var e,t,n;return o(this,(function(r){switch(r.label){case 0:return e=D.of(this._iid),t=e.connectionManager,n=e.requestQueue,this._appStateChangeDetector.stop(),this._onlineDetector.stop(),n.cancelAll(),[4,t.logout()];case 1:return r.sent(),[4,this.clearCachedData()];case 2:return r.sent(),[2]}}))}))},n.prototype.disconnectWebSocket=function(){return s(this,void 0,void 0,(function(){var e,t,n;return o(this,(function(r){switch(r.label){case 0:return e=D.of(this._iid),t=e.connectionManager,n=e.requestQueue,this._appStateChangeDetector.stop(),this._onlineDetector.stop(),n.cancelAll(),[4,t.disconnectWebSocket()];case 1:return r.sent(),[2]}}))}))},n.prototype.setBackgroundState=function(){var e=D.of(this._iid),t=e.connectionManager,n=e.sdkState,r=e.logger;"foreground"===n.appState&&(n.appState="background",r.debug("going background state"),t.background())},n.prototype.setForegroundState=function(){var e=D.of(this._iid),t=e.connectionManager,n=e.sdkState,r=e.logger;"background"===n.appState&&(n.appState="foreground",r.debug("going foreground state"),t.resetAndReconnect())},n.prototype.setSessionHandler=function(e){V(e instanceof Qe).throw(E.invalidParameters),D.of(this._iid).sessionManager.handler=e},n.prototype.addUserEventHandler=function(e,n){V(t("string",e)&&n instanceof He).throw(E.invalidParameters),D.of(this._iid).userEventHandlers.set(e,n)},n.prototype.removeUserEventHandler=function(e){D.of(this._iid).userEventHandlers.delete(e)},n.prototype.removeAllUserEventHandler=function(){D.of(this._iid).userEventHandlers.clear()},n.prototype.addConnectionHandler=function(e,n){V(t("string",e)&&n instanceof xe).throw(E.invalidParameters),D.of(this._iid).connectionHandlers.set(e,n)},n.prototype.removeConnectionHandler=function(e){D.of(this._iid).connectionHandlers.delete(e)},n.prototype.removeAllConnectionHandler=function(){D.of(this._iid).connectionHandlers.clear()},n.prototype.createApplicationUserListQuery=function(e){return void 0===e&&(e={}),new Bt(this._iid,e)},n.prototype.createBlockedUserListQuery=function(e){return void 0===e&&(e={}),new Yt(this._iid,e)},n.prototype.createFriendListQuery=function(e){return void 0===e&&(e={}),new en(this._iid,e)},n.prototype.createMessageSearchQuery=function(e){return new le(this._iid,e)},n.prototype.createPollListQuery=function(e){return new je(this._iid,_({},e))},n.prototype.createPollVoterListQuery=function(e){return new ze(this._iid,_({},e))},n.prototype.buildUserFromSerializedData=function(e){var t=X(e);return new v(this._iid,v.payloadify(t))},n.prototype.updateCurrentUserInfo=function(n){return void 0===n&&(n={}),s(this,void 0,void 0,(function(){var r,i,s,a,u,c,d;return o(this,(function(o){switch(o.label){case 0:return r=_(_({},qe),n),V(function(n){return e(n.profileImage,!0)&&t("string",n.profileUrl,!0)&&t("string",n.nickname,!0)}(r)).throw(E.invalidParameters),this.currentUser?(i=D.of(this._iid),s=i.sdkState,a=i.requestQueue,u=new Be(_({userId:s.userId},r)),[4,a.send(u)]):[3,2];case 1:return c=o.sent(),d=c.as(Je).user,this.currentUser&&(r.nickname&&(this.currentUser.nickname=d.nickname),(r.profileUrl||r.profileImage)&&(this.currentUser.plainProfileUrl=d.profileUrl)),[2,d];case 2:throw E.connectionRequired}}))}))},n.prototype.updateCurrentUserInfoWithPreferredLanguages=function(e){return s(this,void 0,void 0,(function(){var t,n,r,i,s,a;return o(this,(function(o){switch(o.label){case 0:return V(I("string",e)).throw(E.invalidParameters),this.currentUser?(t=D.of(this._iid),n=t.sdkState,r=t.requestQueue,i=new Be({userId:n.userId,preferredLanguages:e}),[4,r.send(i)]):[3,2];case 1:return s=o.sent(),a=s.as(Je).user,this.currentUser&&(this.currentUser.preferredLanguages=a.preferredLanguages),[2,a];case 2:throw E.connectionRequired}}))}))},n.prototype.registerFCMPushTokenForCurrentUser=function(e){return s(this,void 0,void 0,(function(){var n,r,i,a,u,c=this;return o(this,(function(d){switch(d.label){case 0:if(V(t("string",e)).throw(E.invalidParameters),!this.currentUser)return[3,6];d.label=1;case 1:return d.trys.push([1,4,,5]),n=D.of(this._iid),r=n.sessionManager,i=n.sdkState,a=n.requestQueue,r.hasDeviceToken(b.FCM,e)?[2,ie.SUCCESS]:(u=new Ye({userId:i.userId,token:e}),[4,a.send(u)]);case 2:return d.sent(),[4,se((function(){return s(c,void 0,void 0,(function(){return o(this,(function(t){switch(t.label){case 0:return r.setDeviceToken(b.FCM,e),[4,r.saveDeviceToken()];case 1:return t.sent(),[2]}}))}))}))];case 3:return d.sent(),this._fcmPushToken="",[2,ie.SUCCESS];case 4:return d.sent(),[2,ie.ERROR];case 5:return[3,7];case 6:return this._fcmPushToken=e,[2,ie.PENDING];case 7:return[2]}}))}))},n.prototype.unregisterFCMPushTokenForCurrentUser=function(e){return s(this,void 0,void 0,(function(){var n,r,i,a,u,c,d=this;return o(this,(function(l){switch(l.label){case 0:if(V(t("string",e)).throw(E.invalidParameters),!this.currentUser)return[3,6];l.label=1;case 1:return l.trys.push([1,4,,5]),n=D.of(this._iid),r=n.sessionManager,i=n.sdkState,a=n.requestQueue,u=new $e({userId:i.userId,token:e}),[4,a.send(u)];case 2:return c=l.sent().lastDeletedAt,[4,se((function(){return s(d,void 0,void 0,(function(){return o(this,(function(t){switch(t.label){case 0:return r.unsetDeviceToken(b.FCM,e),r.setDeviceTokenDeletedAt(c),[4,r.saveDeviceToken()];case 1:return t.sent(),[2]}}))}))}))];case 3:return l.sent(),this._fcmPushToken="",[2,ie.SUCCESS];case 4:return l.sent(),[2,ie.ERROR];case 5:return[3,7];case 6:return this._fcmPushToken=e,[2,ie.PENDING];case 7:return[2]}}))}))},n.prototype.unregisterFCMPushTokenAllForCurrentUser=function(){return s(this,void 0,void 0,(function(){var e,t,n,r,i,a,u=this;return o(this,(function(c){switch(c.label){case 0:return this.currentUser?(e=D.of(this._iid),t=e.sessionManager,n=e.sdkState,r=e.requestQueue,i=new tt({userId:n.userId}),[4,r.send(i)]):[3,3];case 1:return a=c.sent().lastDeletedAt,[4,se((function(){return s(u,void 0,void 0,(function(){return o(this,(function(e){switch(e.label){case 0:return t.unsetDeviceTokens(b.FCM),t.setDeviceTokenDeletedAt(a),[4,t.saveDeviceToken()];case 1:return e.sent(),[2]}}))}))}))];case 2:c.sent(),c.label=3;case 3:return[2]}}))}))},n.prototype.registerAPNSPushTokenForCurrentUser=function(e){return s(this,void 0,void 0,(function(){var n,r,i,a,u,c=this;return o(this,(function(d){switch(d.label){case 0:if(V(t("string",e)).throw(E.invalidParameters),!this.currentUser)return[3,6];d.label=1;case 1:return d.trys.push([1,4,,5]),n=D.of(this._iid),r=n.sessionManager,i=n.sdkState,a=n.requestQueue,r.hasDeviceToken(b.APNS,e)?[2,ie.SUCCESS]:(u=new Xe({userId:i.userId,token:e}),[4,a.send(u)]);case 2:return d.sent(),[4,se((function(){return s(c,void 0,void 0,(function(){return o(this,(function(t){switch(t.label){case 0:return r.setDeviceToken(b.APNS,e),[4,r.saveDeviceToken()];case 1:return t.sent(),[2]}}))}))}))];case 3:return d.sent(),this._apnsPushToken="",[2,ie.SUCCESS];case 4:return d.sent(),[2,ie.ERROR];case 5:return[3,7];case 6:return this._apnsPushToken=e,[2,ie.PENDING];case 7:return[2]}}))}))},n.prototype.unregisterAPNSPushTokenForCurrentUser=function(e){return s(this,void 0,void 0,(function(){var n,r,i,a,u,c,d=this;return o(this,(function(l){switch(l.label){case 0:if(V(t("string",e)).throw(E.invalidParameters),!this.currentUser)return[3,6];l.label=1;case 1:return l.trys.push([1,4,,5]),n=D.of(this._iid),r=n.sessionManager,i=n.sdkState,a=n.requestQueue,u=new Ze({userId:i.userId,token:e}),[4,a.send(u)];case 2:return c=l.sent().lastDeletedAt,[4,se((function(){return s(d,void 0,void 0,(function(){return o(this,(function(t){switch(t.label){case 0:return r.unsetDeviceToken(b.APNS,e),r.setDeviceTokenDeletedAt(c),[4,r.saveDeviceToken()];case 1:return t.sent(),[2]}}))}))}))];case 3:return l.sent(),this._apnsPushToken="",[2,ie.SUCCESS];case 4:return l.sent(),[2,ie.ERROR];case 5:return[3,7];case 6:return this._apnsPushToken=e,[2,ie.PENDING];case 7:return[2]}}))}))},n.prototype.unregisterAPNSPushTokenAllForCurrentUser=function(){return s(this,void 0,void 0,(function(){var e,t,n,r,i,a,u=this;return o(this,(function(c){switch(c.label){case 0:return this.currentUser?(e=D.of(this._iid),t=e.sessionManager,n=e.sdkState,r=e.requestQueue,i=new et({userId:n.userId}),[4,r.send(i)]):[3,3];case 1:return a=c.sent().lastDeletedAt,[4,se((function(){return s(u,void 0,void 0,(function(){return o(this,(function(e){switch(e.label){case 0:return t.unsetDeviceTokens(b.APNS),t.setDeviceTokenDeletedAt(a),[4,t.saveDeviceToken()];case 1:return e.sent(),[2]}}))}))}))];case 2:c.sent(),c.label=3;case 3:return[2]}}))}))},n.prototype.getChannelInvitationPreference=function(){return s(this,void 0,void 0,(function(){var e,t,n,r,i;return o(this,(function(s){switch(s.label){case 0:return e=D.of(this._iid),t=e.sdkState,n=e.requestQueue,r=new it({userId:t.userId}),[4,n.send(r)];case 1:return i=s.sent(),[2,{autoAccept:i.as(st).autoAccept}]}}))}))},n.prototype.setChannelInvitationPreference=function(e){return s(this,void 0,void 0,(function(){var n,r,i,s,a;return o(this,(function(o){switch(o.label){case 0:return V(t("boolean",e)).throw(E.invalidParameters),n=D.of(this._iid),r=n.sdkState,i=n.requestQueue,s=new ot({userId:r.userId,willAutoAccept:e}),[4,i.send(s)];case 1:return a=o.sent(),[2,{autoAccept:a.as(at).autoAccept}]}}))}))},n.prototype.getDoNotDisturb=function(){return s(this,void 0,void 0,(function(){var e,t,n,r,i;return o(this,(function(s){switch(s.label){case 0:return e=D.of(this._iid),t=e.sdkState,n=e.requestQueue,r=new ut({userId:t.userId}),[4,n.send(r)];case 1:return i=s.sent(),[2,i.as(ct).preference]}}))}))},n.prototype.setDoNotDisturb=function(e,n,r,i,a,u){return void 0===n&&(n=0),void 0===r&&(r=0),void 0===i&&(i=0),void 0===a&&(a=0),void 0===u&&(u=""),s(this,void 0,void 0,(function(){var s,c,d,l,h;return o(this,(function(o){switch(o.label){case 0:return V(t("boolean",e)&&t("number",n)&&t("number",r)&&t("number",i)&&t("number",a)&&t("string",u)).throw(E.invalidParameters),s=D.of(this._iid),c=s.sdkState,d=s.requestQueue,l=new dt({userId:c.userId,doNotDisturbOn:e,startHour:n,startMin:r,endHour:i,endMin:a,timezone:u}),[4,d.send(l)];case 1:return h=o.sent(),[2,h.as(lt).preference]}}))}))},n.prototype.getSnoozePeriod=function(){return s(this,void 0,void 0,(function(){var e,t,n,r,i;return o(this,(function(s){switch(s.label){case 0:return e=D.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(ft).snoozePeriod]}}))}))},n.prototype.setSnoozePeriod=function(e,n,r){return void 0===n&&(n=0),void 0===r&&(r=0),s(this,void 0,void 0,(function(){var i,s,a,u,c;return o(this,(function(o){switch(o.label){case 0:return V(t("boolean",e)&&t("number",n)&&t("number",r)).throw(E.invalidParameters),i=D.of(this._iid),s=i.sdkState,a=i.requestQueue,u=new pt({userId:s.userId,snoozeOn:e,startTs:n,endTs:r}),[4,a.send(u)];case 1:return c=o.sent(),[2,c.as(vt).snoozePeriod]}}))}))},n.prototype.getMyPushTokensByToken=function(e,n){return s(this,void 0,void 0,(function(){var r,i,s,a,u,c,d,l,h,f,p,v;return o(this,(function(o){switch(o.label){case 0:return V(t("string",e)&&ae(b,n)).throw(E.invalidParameters),r=D.of(this._iid),i=r.sdkState,s=r.requestQueue,a=r.sessionManager,u=new nt({userId:i.userId,type:n,token:e}),[4,s.send(u)];case 1:c=o.sent(),d=c.as(rt).pushTokens;try{for(l=oe(d.deviceTokens),h=l.next();!h.done;h=l.next())f=h.value,a.setDeviceToken(d.type,f)}catch(e){p={error:e}}finally{try{h&&!h.done&&(v=l.return)&&v.call(l)}finally{if(p)throw p.error}}return[4,a.saveDeviceToken()];case 2:return o.sent(),[2,d]}}))}))},n.prototype.getPushTriggerOption=function(){return s(this,void 0,void 0,(function(){var e,t,n,r;return o(this,(function(i){switch(i.label){case 0:return e=D.of(this._iid),t=e.sdkState,n=e.requestQueue,r=new gt({userId:t.userId}),[4,n.send(r)];case 1:return[2,i.sent().as(yt).pushTriggerOption]}}))}))},n.prototype.setPushTriggerOption=function(e){return s(this,void 0,void 0,(function(){var t,n,r,i;return o(this,(function(s){switch(s.label){case 0:return V(ae(ue,e)).throw(E.invalidParameters),t=D.of(this._iid),n=t.sdkState,r=t.requestQueue,i=new bt({userId:n.userId,pushTriggerOption:e}),[4,r.send(i)];case 1:return[2,s.sent().as(wt).pushTriggerOption]}}))}))},n.prototype.getPushTemplate=function(){return s(this,void 0,void 0,(function(){var e,t,n,r;return o(this,(function(i){switch(i.label){case 0:return e=D.of(this._iid),t=e.sdkState,n=e.requestQueue,r=new kt({userId:t.userId}),[4,n.send(r)];case 1:return[2,i.sent().as(It).name]}}))}))},n.prototype.setPushTemplate=function(e){return s(this,void 0,void 0,(function(){var t,n,r,i;return o(this,(function(s){switch(s.label){case 0:return V(ae(ce,e)).throw(E.invalidParameters),t=D.of(this._iid),n=t.sdkState,r=t.requestQueue,i=new St({userId:n.userId,templateName:e}),[4,r.send(i)];case 1:return[2,s.sent().as(Ct).name]}}))}))},n.prototype.blockUser=function(e){return s(this,void 0,void 0,(function(){var n,r,i,s;return o(this,(function(o){switch(o.label){case 0:return V(e instanceof v||t("string",e)).throw(E.invalidParameters),n=D.of(this._iid),r=n.sdkState,i=n.requestQueue,s=new _t({userId:r.userId,blockedUserId:e instanceof v?e.userId:e}),[4,i.send(s)];case 1:return o.sent(),[2]}}))}))},n.prototype.blockUserWithUserId=function(e){return s(this,void 0,void 0,(function(){return o(this,(function(t){return[2,this.blockUser(e)]}))}))},n.prototype.unblockUser=function(e){return s(this,void 0,void 0,(function(){var n,r,i,s;return o(this,(function(o){switch(o.label){case 0:return V(e instanceof v||t("string",e)).throw(E.invalidParameters),n=D.of(this._iid),r=n.sdkState,i=n.requestQueue,s=new mt({userId:r.userId,unblockedUserId:e instanceof v?e.userId:e}),[4,i.send(s)];case 1:return o.sent(),[2]}}))}))},n.prototype.unblockUserWithUserId=function(e){return s(this,void 0,void 0,(function(){return o(this,(function(t){return[2,this.unblockUser(e)]}))}))},n.prototype.getFriendChangeLogsByToken=function(e){return s(this,void 0,void 0,(function(){var n,r,i,s,a;return o(this,(function(o){switch(o.label){case 0:return V(t("string",e)).throw(E.invalidParameters),n=D.of(this._iid),r=n.sdkState,i=n.requestQueue,s=new Tt({userId:r.userId,token:e}),[4,i.send(s)];case 1:return a=o.sent(),[2,a.as(Pt).changelogs]}}))}))},n.prototype.getAllowFriendDiscovery=function(){return s(this,void 0,void 0,(function(){var e,t,n,r,i;return o(this,(function(s){switch(s.label){case 0:return e=D.of(this._iid),t=e.sdkState,n=e.requestQueue,r=new At({userId:t.userId}),[4,n.send(r)];case 1:return i=s.sent(),[2,i.as(Mt).allowFriendDiscovery]}}))}))},n.prototype.setAllowFriendDiscovery=function(e){return s(this,void 0,void 0,(function(){var n,r,i,s;return o(this,(function(o){switch(o.label){case 0:return V(t("boolean",e)).throw(E.invalidParameters),n=D.of(this._iid),r=n.sdkState,i=n.requestQueue,s=new Rt({userId:r.userId,allowFriendDiscovery:e}),[4,i.send(s)];case 1:return o.sent(),[2,e]}}))}))},n.prototype.uploadFriendDiscoveries=function(e){return s(this,void 0,void 0,(function(){var t,n,r,i,s;return o(this,(function(o){switch(o.label){case 0:return t=D.of(this._iid),n=t.sdkState,r=t.requestQueue,i=new Et({userId:n.userId,discoveries:e}),[4,r.send(i)];case 1:return s=o.sent(),[2,s.as(Dt).friendDiscoveryRequestId]}}))}))},n.prototype.deleteFriendDiscovery=function(e){return s(this,void 0,void 0,(function(){return o(this,(function(t){return[2,this.deleteFriendDiscoveries([e])]}))}))},n.prototype.deleteFriendDiscoveries=function(e){return s(this,void 0,void 0,(function(){var t,n,r,i;return o(this,(function(s){switch(s.label){case 0:return V(I("string",e)).throw(E.invalidParameters),t=D.of(this._iid),n=t.sdkState,r=t.requestQueue,i=new Ut({userId:n.userId,discoveryKeys:e}),[4,r.send(i)];case 1:return s.sent(),[2]}}))}))},n.prototype.addFriends=function(e){return s(this,void 0,void 0,(function(){var t,n,r,i,s;return o(this,(function(o){switch(o.label){case 0:return V(I("string",e)).throw(E.invalidParameters),t=D.of(this._iid),n=t.sdkState,r=t.requestQueue,i=new Ot({userId:n.userId,userIds:e}),[4,r.send(i)];case 1:return s=o.sent(),[2,s.as(Lt).users]}}))}))},n.prototype.deleteFriend=function(e){return s(this,void 0,void 0,(function(){return o(this,(function(t){return[2,this.deleteFriends([e])]}))}))},n.prototype.deleteFriends=function(e){return s(this,void 0,void 0,(function(){var t,n,r,i;return o(this,(function(s){switch(s.label){case 0:return V(I("string",e)).throw(E.invalidParameters),t=D.of(this._iid),n=t.sdkState,r=t.requestQueue,i=new Nt({userId:n.userId,userIds:e}),[4,r.send(i)];case 1:return s.sent(),[2]}}))}))},n.prototype.getAllEmoji=function(){return s(this,void 0,void 0,(function(){var e,t,n;return o(this,(function(r){switch(r.label){case 0:return e=D.of(this._iid).requestQueue,t=new qt,[4,e.send(t)];case 1:return n=r.sent(),[2,n.as(Qt).emojiContainer]}}))}))},n.prototype.getEmojiCategory=function(e){return s(this,void 0,void 0,(function(){var t,n,r;return o(this,(function(i){switch(i.label){case 0:return t=D.of(this._iid).requestQueue,n=new xt({categoryId:e}),[4,t.send(n)];case 1:return r=i.sent(),[2,r.as(Ht).emojiCategory]}}))}))},n.prototype.getEmoji=function(e){return s(this,void 0,void 0,(function(){var t,n,r;return o(this,(function(i){switch(i.label){case 0:return t=D.of(this._iid).requestQueue,n=new Gt({key:e}),[4,t.send(n)];case 1:return r=i.sent(),[2,r.as(Wt).emoji]}}))}))},n}();export{Bt as ApplicationUserListQuery,Yt as BlockedUserListQuery,xe as ConnectionHandler,Ft as Emoji,jt as EmojiCategory,zt as EmojiContainer,en as FriendListQuery,Qe as SessionHandler,He as UserEventHandler,nn as default}; +import{i as e,a as t,_ as n,n as r,b as s,c as o,E as a,A as u,d,e as l,f as p,U as v,g as _,h as y,P as b,j as w,k,l as I,B as T,S as E,V as D,m as A,L as j,u as z,o as q,p as x,q as H,v as G,C as W,r as V,s as X,t as Y,w as Z,W as $,x as ee,y as te,z as ne,D as re,F as ie,G as se,H as oe,I as ae,J as ue,K as ce}from"./__bundle-ea43c8a8.js";export{N as CachedChannelInfo,M as ChannelType,C as ConnectionState,L as LocalCacheConfig,O as LogLevel,K as PushTemplate,F as PushTokenRegistrationState,P as PushTokenType,J as PushTriggerOption,R as Role,m as SendbirdChatOptions,S as SendbirdError,U as User,Q as UserOnlineState}from"./__bundle-ea43c8a8.js";import{M as de,a as le}from"./__bundle-12fe2d56.js";export{P as Plugin}from"./__bundle-12fe2d56.js";import{PollModule as he}from"./poll.js";import{N as fe,a as pe,b as ve,c as _e,d as me,e as ge}from"./__bundle-3b517302.js";export{B as BannedUserListQuery,f as BaseChannel,M as MutedUserListQuery,O as OperatorListQuery,R as ReportCategory,g as RestrictedUser,h as RestrictionInfo,i as RestrictionType}from"./__bundle-3b517302.js";import{g as ye,G as be,a as we,M as ke,N as Ie,b as Se,c as Ce,A as Te,I as Pe,d as Ee,U as De,e as Ue,f as Oe,D as Le,h as Ne,i as Ae,j as Me,R as Re,k as Fe}from"./__bundle-da2eac9e.js";export{c as MemoryStore}from"./__bundle-da2eac9e.js";import{P as je,a as ze}from"./__bundle-9a0f0a93.js";export{P as Participant}from"./__bundle-5c4b7d2b.js";var qe={profileImage:null,profileUrl:null,nickname:null},Qe=function(e){function t(t){void 0===t&&(t={});var n=e.call(this)||this;return Object.keys(t).forEach((function(e){n.hasOwnProperty(e)&&(n[e]=t[e])})),n}return n(t,e),t}((function(){this.onSessionExpired=r,this.onSessionTokenRequired=function(e){return e(null)},this.onSessionError=r,this.onSessionRefreshed=r,this.onSessionClosed=r})),xe=function(e){function t(t){void 0===t&&(t={});var n=e.call(this)||this;return Object.keys(t).forEach((function(e){n.hasOwnProperty(e)&&(n[e]=t[e])})),n}return n(t,e),t}((function(){this.onConnected=r,this.onReconnectStarted=r,this.onReconnectSucceeded=r,this.onReconnectFailed=r,this.onDisconnected=r})),He=function(e){function t(t){void 0===t&&(t={});var n=e.call(this)||this;return Object.keys(t).forEach((function(e){n.hasOwnProperty(e)&&(n[e]=t[e])})),n}return n(t,e),t}((function(){this.onFriendsDiscovered=r,this.onTotalUnreadMessageCountUpdated=r})),Ge=function(e,t){return function(n,r){if(1===n)e.clear().then((function(){t.clear().then((function(){(function(e){return s(void 0,void 0,void 0,(function(){return o(this,(function(t){return[2,e.commitSchema([{collectionName:fe,keyName:pe,index:[ye(be.LATEST_LAST_MESSAGE),ye(be.CHRONOLOGICAL),ye(be.CHANNEL_NAME_ALPHABETICAL)]},{collectionName:ve,keyName:_e,index:[we(ke.CHANNEL_LATEST),we(ke.NEWEST_CHILD_MESSAGE)]},{collectionName:Ie,keyName:Se,index:[we(ke.CHANNEL_LATEST),we(ke.NEWEST_CHILD_MESSAGE)]},{collectionName:me,keyName:ge}])]}))}))})(e).then((function(){return r()})).catch((function(e){return r(e)}))})).catch((function(e){return r(e)}))})).catch((function(e){return r(e)}));else r()}},We=function(){return"undefined"!=typeof document?document.visibilityState:"visible"},Ke=function(e){function t(t){var n=t.getVisibilityState,r=void 0===n?We:n,i=t.initialState,s=void 0===i?"visible":i,o=t.isEnabled,a=void 0===o||o,u=t.pauseCheckDelay,c=void 0===u?3e4:u,d=e.call(this)||this;return d._pauseCheckDelay=3e4,d._pauseDelayTimer=null,d._currentState="visible",d._getVisibilityState=r,d._pauseCheckDelay=c,d._currentState=s,d._isEnabled=a,d._boundToggleState=d._toggleState.bind(d),d}return n(t,e),Object.defineProperty(t.prototype,"currentState",{get:function(){return this._currentState},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"isAvailable",{get:function(){return"undefined"!=typeof window&&!!window.addEventListener&&!!window.removeEventListener},enumerable:!1,configurable:!0}),t.prototype._toggleState=function(){var e=this,t=this._getVisibilityState();"hidden"!==t?"hidden"===this._currentState&&(this._pauseDelayTimer&&(clearTimeout(this._pauseDelayTimer),this._pauseDelayTimer=null),this.dispatch("resume")):"hidden"!==this._currentState&&(this._pauseDelayTimer=setTimeout((function(){e._pauseDelayTimer=null,e.dispatch("pause")}),this._pauseCheckDelay)),this._currentState=t},t.prototype.start=function(){this._isEnabled&&this.isAvailable&&(this._boundToggleState=this._toggleState.bind(this),window.addEventListener("visibilitychange",this._boundToggleState,{capture:!0}))},t.prototype.stop=function(){this._isEnabled&&this.isAvailable&&this._boundToggleState&&window.removeEventListener("visibilitychange",this._boundToggleState,{capture:!0})},t}(a),Ve=function(){function e(e){var t=e.logger,n=e.connectionDelegate,r=void 0===n?null:n,i=this;this._onlineWorker=function(){var e;return null===(e=i.connectionDelegate)||void 0===e?void 0:e.reconnect()},this._offlineWorker=function(){var e;return null===(e=i.connectionDelegate)||void 0===e?void 0:e.disconnect()},this.unsubscribes=[],this._onlineListener=function(e){if(i.isAvailableOnWeb)return window.addEventListener("online",e),function(){return window.removeEventListener("online",e,!1)}},this._offlineListener=function(e){if(i.isAvailableOnWeb)return window.addEventListener("offline",e),function(){return window.removeEventListener("offline",e,!1)}},this.logger=t,r&&(this.connectionDelegate=r)}return Object.defineProperty(e.prototype,"isAvailableOnWeb",{get:function(){return"undefined"!=typeof window&&window.addEventListener&&"ononline"in window&&"onoffline"in window&&"undefined"!=typeof navigator&&void 0!==navigator.onLine},enumerable:!1,configurable:!0}),e.prototype.setOnlineListener=function(e){Boolean(e)&&"function"==typeof e&&(this._onlineListener=e)},e.prototype.setOfflineListener=function(e){Boolean(e)&&"function"==typeof e&&(this._offlineListener=e)},e.prototype.start=function(){this.unsubscribes=[this._onlineListener(this._onlineWorker),this._offlineListener(this._offlineWorker)]},e.prototype.stop=function(){var e=this;this.unsubscribes.forEach((function(t){try{null==t||t()}catch(t){e.logger.warn(t.message)}})),this.unsubscribes=[]},e.prototype.isOnline=function(){return s(this,void 0,void 0,(function(){return o(this,(function(e){return this.isAvailableOnWeb?[2,navigator.onLine]:[2,new Promise((function(e){fetch("https://www.google.com",{method:u.GET,mode:"no-cors"}).then((function(){return e(!0)})).catch((function(){return e(!1)}))}))]}))}))},e}(),Be=function(e){function t(t){var n=t.userId,r=t.nickname,i=void 0===r?null:r,s=t.profileUrl,o=void 0===s?null:s,a=t.profileImage,c=void 0===a?null:a,h=t.preferredLanguages,f=void 0===h?null:h,p=e.call(this)||this;return p.method=u.PUT,p.path="".concat(d,"/").concat(encodeURIComponent(n)),p.params=l({nickname:i,profile_url:o,profile_file:c,preferred_languages:f}),p}return n(t,e),t}(p),Je=function(e){function t(t,n){var r=e.call(this,t,n)||this;return r.user=null,r.user=new v(t,_({},n)),r}return n(t,e),t}(y),Xe=function(e){function t(t){var n=t.userId,r=t.token,i=e.call(this)||this;return i.method=u.POST,i.path="".concat(d,"/").concat(encodeURIComponent(n),"/push/apns"),i.params={apns_device_token:r,always_push:!0},i}return n(t,e),t}(p);!function(e){function t(t,n){var r=e.call(this,t,n)||this;return r.token=n.token,r.type=n.type?b[n.type.toLowerCase()]:b.UNKNOWN,r.user=new v(t,n.user),r}n(t,e)}(y);var Ye=function(e){function t(t){var n=t.userId,r=t.token,i=e.call(this)||this;return i.method=u.POST,i.path="".concat(d,"/").concat(encodeURIComponent(n),"/push/gcm"),i.params={gcm_reg_token:r,always_push:!0},i}return n(t,e),t}(p);!function(e){function t(t,n){var r=e.call(this,t,n)||this;return r.token=n.token,r.type=n.type?b[n.type.toLowerCase()]:b.UNKNOWN,r.user=new v(t,n.user),r}n(t,e)}(y);var Ze=function(e){function t(t){var n=t.userId,r=t.token,i=e.call(this)||this;return i.method=u.DELETE,i.path="".concat(d,"/").concat(encodeURIComponent(n),"/push/apns/").concat(encodeURIComponent(r)),i}return n(t,e),t}(p);!function(e){function t(t,n){var r=e.call(this,t,n)||this;return r.token=n.token,r.user=new v(t,n.user),r.lastDeletedAt=n.device_token_last_deleted_at,r}n(t,e)}(y);var $e=function(e){function t(t){var n=t.userId,r=t.token,i=e.call(this)||this;return i.method=u.DELETE,i.path="".concat(d,"/").concat(encodeURIComponent(n),"/push/gcm/").concat(encodeURIComponent(r)),i}return n(t,e),t}(p);!function(e){function t(t,n){var r=e.call(this,t,n)||this;return r.token=n.token,r.user=new v(t,n.user),r.lastDeletedAt=n.device_token_last_deleted_at,r}n(t,e)}(y);var et=function(e){function t(t){var n=t.userId,r=e.call(this)||this;return r.method=u.DELETE,r.path="".concat(d,"/").concat(encodeURIComponent(n),"/push/apns"),r}return n(t,e),t}(p);!function(e){function t(t,n){var r=e.call(this,t,n)||this;return r.type=n.type?b[n.type.toLowerCase()]:b.UNKNOWN,r.user=new v(t,n.user),r.lastDeletedAt=n.device_token_last_deleted_at,r}n(t,e)}(y);var tt=function(e){function t(t){var n=t.userId,r=e.call(this)||this;return r.method=u.DELETE,r.path="".concat(d,"/").concat(encodeURIComponent(n),"/push/gcm"),r}return n(t,e),t}(p);!function(e){function t(t,n){var r=e.call(this,t,n)||this;return r.type=n.type?b[n.type.toLowerCase()]:b.UNKNOWN,r.user=new v(t,n.user),r.lastDeletedAt=n.device_token_last_deleted_at,r}n(t,e)}(y);var nt=function(e){function t(t){var n=t.userId,r=t.type,i=t.token,s=t.ts,o=e.call(this)||this;return o.method=u.GET,o.path="".concat(d,"/").concat(encodeURIComponent(n),"/push/").concat(encodeURIComponent(r),"/device_tokens"),o.params={created_ts:s,token:i},o}return n(t,e),t}(p),rt=function(e){function t(t,n){var r=e.call(this,t,n)||this;return r.pushTokens={type:n.type?b[n.type.toLowerCase()]:b.UNKNOWN,deviceTokens:n.device_tokens,hasMore:n.has_more,token:n.token},r}return n(t,e),t}(y),it=function(e){function t(t){var n=t.userId,r=e.call(this)||this;return r.method=u.GET,r.path="".concat(d,"/").concat(encodeURIComponent(n),"/channel_invitation_preference"),r}return n(t,e),t}(p),st=function(e){function t(t,n){var r=e.call(this,t,n)||this;return r.autoAccept=n.auto_accept,r}return n(t,e),t}(y),ot=function(e){function t(t){var n=t.userId,r=t.willAutoAccept,i=e.call(this)||this;return i.method=u.PUT,i.path="".concat(d,"/").concat(encodeURIComponent(n),"/channel_invitation_preference"),i.params={auto_accept:r},i}return n(t,e),t}(p),at=function(e){function t(t,n){var r=e.call(this,t,n)||this;return r.autoAccept=n.auto_accept,r}return n(t,e),t}(y),ut=function(e){function t(t){var n=t.userId,r=e.call(this)||this;return r.method=u.GET,r.path="".concat(d,"/").concat(encodeURIComponent(n),"/push_preference"),r}return n(t,e),t}(p),ct=function(e){function t(t,n){var r=e.call(this,t,n)||this;return r.preference={doNotDisturbOn:n.do_not_disturb,startHour:n.start_hour,startMin:n.start_min,endHour:n.end_hour,endMin:n.end_min,timezone:n.timezone},r}return n(t,e),t}(y),dt=function(e){function t(t){var n=t.userId,r=t.doNotDisturbOn,i=t.startHour,s=t.startMin,o=t.endHour,a=t.endMin,c=t.timezone,l=e.call(this)||this;return l.method=u.PUT,l.path="".concat(d,"/").concat(encodeURIComponent(n),"/push_preference"),l.params={do_not_disturb:r,start_hour:i,start_min:s,end_hour:o,end_min:a,timezone:c},l}return n(t,e),t}(p),lt=function(e){function t(t,n){var r=e.call(this,t,n)||this;return r.preference={doNotDisturbOn:n.do_not_disturb,startHour:n.start_hour,startMin:n.start_min,endHour:n.end_hour,endMin:n.end_min,timezone:n.timezone},r}return n(t,e),t}(y),ht=function(e){function t(t){var n=t.userId,r=e.call(this)||this;return r.method=u.GET,r.path="".concat(d,"/").concat(encodeURIComponent(n),"/push_preference"),r}return n(t,e),t}(p),ft=function(e){function t(t,n){var r=e.call(this,t,n)||this;return r.snoozePeriod={isSnoozeOn:n.snooze_enabled},"number"==typeof n.snooze_start_ts&&(r.snoozePeriod.startTs=n.snooze_start_ts),"number"==typeof n.snooze_end_ts&&(r.snoozePeriod.endTs=n.snooze_end_ts),r}return n(t,e),t}(y),pt=function(e){function t(t){var n=t.userId,r=t.snoozeOn,i=t.startTs,s=t.endTs,o=e.call(this)||this;return o.method=u.PUT,o.path="".concat(d,"/").concat(encodeURIComponent(n),"/push_preference"),o.params={snooze_enabled:r,snooze_start_ts:i,snooze_end_ts:s},o}return n(t,e),t}(p),vt=function(e){function t(t,n){var r=e.call(this,t,n)||this;return r.snoozePeriod={isSnoozeOn:n.snooze_enabled},"number"==typeof n.snooze_start_ts&&(r.snoozePeriod.startTs=n.snooze_start_ts),"number"==typeof n.snooze_end_ts&&(r.snoozePeriod.endTs=n.snooze_end_ts),r}return n(t,e),t}(y),_t=function(e){function t(t){var n=t.userId,r=t.blockedUserId,i=e.call(this)||this;return i.method=u.POST,i.path="".concat(d,"/").concat(encodeURIComponent(n),"/block"),i.params={target_id:r},i}return n(t,e),t}(p);!function(e){function t(t,n){var r=e.call(this,t,n)||this;return r.user=new v(t,n),r}n(t,e)}(y);var mt=function(e){function t(t){var n=t.userId,r=t.unblockedUserId,i=e.call(this)||this;return i.method=u.DELETE,i.path="".concat(d,"/").concat(encodeURIComponent(n),"/block/").concat(encodeURIComponent(r)),i}return n(t,e),t}(p);!function(e){function t(){return null!==e&&e.apply(this,arguments)||this}n(t,e)}(y);var gt=function(e){function t(t){var n=t.userId,r=e.call(this)||this;return r.method=u.GET,r.path="".concat(d,"/").concat(encodeURIComponent(n),"/push_preference"),r}return n(t,e),t}(p),yt=function(e){function t(t,n){var r=e.call(this,t,n)||this;return r.pushTriggerOption=n.push_trigger_option,r}return n(t,e),t}(y),bt=function(e){function t(t){var n=t.userId,r=t.pushTriggerOption,i=e.call(this)||this;return i.method=u.PUT,i.path="".concat(d,"/").concat(encodeURIComponent(n),"/push_preference"),i.params={push_trigger_option:r},i}return n(t,e),t}(p),wt=function(e){function t(t,n){var r=e.call(this,t,n)||this;return r.pushTriggerOption=n.push_trigger_option,r}return n(t,e),t}(y),kt=function(e){function t(t){var n=t.userId,r=e.call(this)||this;return r.method=u.GET,r.path="".concat(d,"/").concat(encodeURIComponent(n),"/push/template"),r}return n(t,e),t}(p),It=function(e){function t(t,n){var r=e.call(this,t,n)||this;return r.name=n.name,r}return n(t,e),t}(y),St=function(e){function t(t){var n=t.userId,r=t.templateName,i=e.call(this)||this;return i.method=u.PUT,i.path="".concat(d,"/").concat(encodeURIComponent(n),"/push/template"),i.params={name:r},i}return n(t,e),t}(p),Ct=function(e){function t(t,n){var r=e.call(this,t,n)||this;return r.name=n.name,r}return n(t,e),t}(y),Tt=function(e){function t(t){var n=t.userId,r=t.token,i=e.call(this)||this;return i.method=u.GET,i.path="".concat(d,"/").concat(encodeURIComponent(n),"/friends/changelogs"),i.params={token:r},i}return n(t,e),t}(p),Pt=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 v(t,e)})),updatedUsers:n.updated.map((function(e){return new v(t,e)})),deletedUserIds:n.deleted,hasMore:n.has_more,token:n.next},r}return n(t,e),t}(y),Et=function(e){function t(t){var n=t.userId,r=t.discoveries,i=e.call(this)||this;return i.method=u.PUT,i.path="".concat(d,"/").concat(encodeURIComponent(n),"/friend_discoveries"),i.params={friend_discoveries:r.map((function(e){return{friend_discovery_key:e.friendDiscoveryKey,friend_name:e.friendName}}))},i}return n(t,e),t}(p),Dt=function(e){function t(t,n){var r=e.call(this,t,n)||this;return r.friendDiscoveryRequestId=n.friend_discovery_request_id,r}return n(t,e),t}(y),Ut=function(e){function t(t){var n=t.userId,r=t.discoveryKeys,i=e.call(this)||this;return i.method=u.DELETE,i.path="".concat(d,"/").concat(encodeURIComponent(n),"/friend_discoveries"),i.params={friend_discovery_keys:r},i}return n(t,e),t}(p);!function(e){function t(){return null!==e&&e.apply(this,arguments)||this}n(t,e)}(y);var Ot=function(e){function t(t){var n=t.userId,r=t.userIds,i=e.call(this)||this;return i.method=u.POST,i.path="".concat(d,"/").concat(encodeURIComponent(n),"/friends"),i.params={user_ids:r},i}return n(t,e),t}(p),Lt=function(e){function t(t,n){var r=e.call(this,t,n)||this;return r.users=n.users.map((function(e){return new v(t,e)})),r}return n(t,e),t}(y),Nt=function(e){function t(t){var n=t.userId,r=t.userIds,i=e.call(this)||this;return i.method=u.DELETE,i.path="".concat(d,"/").concat(encodeURIComponent(n),"/friends"),i.params={user_ids:r},i}return n(t,e),t}(p);!function(e){function t(){return null!==e&&e.apply(this,arguments)||this}n(t,e)}(y);var At=function(e){function t(t){var n=t.userId,r=e.call(this)||this;return r.method=u.GET,r.path="".concat(d,"/").concat(n,"/allow_friend_discovery"),r.params={},r}return n(t,e),t}(p),Mt=function(e){function t(t,n){var r=e.call(this,t,n)||this;return r.allowFriendDiscovery=n.allow_friend_discovery,r}return n(t,e),t}(y),Rt=function(e){function t(t){var n=t.userId,r=t.allowFriendDiscovery,i=e.call(this)||this;return i.method=u.PUT,i.path="".concat(d,"/").concat(n,"/allow_friend_discovery"),i.params={allow_friend_discovery:r},i}return n(t,e),t}(p);!function(e){function t(){return null!==e&&e.apply(this,arguments)||this}n(t,e)}(y);var Ft=function(e){this.key=null,this.url=null,this.key=e.key,this.url=e.url},jt=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 Ft(e)})):[]},zt=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 jt(e)})):[]},qt=function(e){function t(){var t=e.call(this)||this;return t.method=u.GET,t.path=w,t}return n(t,e),t}(p),Qt=function(e){function t(t,n){var r=e.call(this,t,n)||this;return r.emojiContainer=new zt(n),r}return n(t,e),t}(y),xt=function(e){function t(t){var n=t.categoryId,r=e.call(this)||this;return r.method=u.GET,r.path="".concat(w,"/").concat(n),r}return n(t,e),t}(p),Ht=function(e){function t(t,n){var r=e.call(this,t,n)||this;return r.emojiCategory=new jt(n),r}return n(t,e),t}(y),Gt=function(e){function t(t){var n=t.key,r=e.call(this)||this;return r.method=u.GET,r.path="".concat(k,"/").concat(n),r}return n(t,e),t}(p),Wt=function(e){function t(t,n){var r=e.call(this,t,n)||this;return r.emoji=new Ft(n),r}return n(t,e),t}(y),Kt=function(e){function t(t){var n=t.limit,r=t.token,i=t.userIdsFilter,s=t.metaDataKeyFilter,o=t.metaDataValuesFilter,a=t.nicknameStartsWithFilter,c=e.call(this)||this;return c.method=u.GET,c.path=d,c.params=l({limit:n,token:r,user_ids:i,metadatakey:s,metadatavalues_in:o,nickname_startswith:a}),c}return n(t,e),t}(p),Vt=function(e){function t(t,n){var r=e.call(this,t,n)||this;return r.users=n.users.map((function(e){return new v(t,e)})),r.next=n.next,r}return n(t,e),t}(y),Bt=function(e){function r(t,n){var r,i,s,o=this;return(o=e.call(this,t,n)||this).userIdsFilter=null,o.metaDataKeyFilter=null,o.metaDataValuesFilter=null,o.nicknameStartsWithFilter=null,o.userIdsFilter=null!==(r=n.userIdsFilter)&&void 0!==r?r:null,o.metaDataKeyFilter=null!==(i=n.metaDataKeyFilter)&&void 0!==i?i:null,o.metaDataValuesFilter=null!==(s=n.metaDataValuesFilter)&&void 0!==s?s:null,o.nicknameStartsWithFilter=n.nicknameStartsWithFilter||null,o}return n(r,e),r.prototype._validate=function(){return e.prototype._validate.call(this)&&I("string",this.userIdsFilter,!0)&&t("string",this.metaDataKeyFilter,!0)&&I("string",this.metaDataValuesFilter,!0)&&t("string",this.metaDataKeyFilter,!0)},r.prototype.next=function(){return s(this,void 0,void 0,(function(){var e,t,n,r,i,s;return o(this,(function(o){switch(o.label){case 0:return this._validate()?this._isLoading?[3,3]:this._hasNext?(this._isLoading=!0,e=D.of(this._iid).requestQueue,t=new Kt(_(_({},this),{token:this._token})),[4,e.send(t)]):[3,2]:[3,5];case 1:return n=o.sent(),r=n.as(Vt),i=r.users,s=r.next,this._token=s,this._hasNext=!!s,this._isLoading=!1,[2,i];case 2:return[2,[]];case 3:throw E.queryInProgress;case 4:return[3,6];case 5:throw E.invalidParameters;case 6:return[2]}}))}))},r}(T),Jt=function(e){function t(t){var n=t.userId,r=t.limit,i=t.token,s=t.userIdsFilter,o=e.call(this)||this;return o.method=u.GET,o.path="".concat(d,"/").concat(n,"/block"),o.params=l({limit:r,token:i,user_ids:s}),o}return n(t,e),t}(p),Xt=function(e){function t(t,n){var r=e.call(this,t,n)||this;return r.users=n.users.map((function(e){return new v(t,e)})),r.next=n.next,r}return n(t,e),t}(y),Yt=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)&&I("string",this.userIdsFilter,!0)},t.prototype.next=function(){return s(this,void 0,void 0,(function(){var e,t,n,r,i,s,a,u;return o(this,(function(o){switch(o.label){case 0:return this._validate()?this._isLoading?[3,3]:this._hasNext?(this._isLoading=!0,e=D.of(this._iid),t=e.sdkState,n=e.requestQueue,r=new Jt(_(_({},this),{userId:t.userId,token:this._token})),[4,n.send(r)]):[3,2]:[3,5];case 1:return i=o.sent(),s=i.as(Xt),a=s.users,u=s.next,this._token=u,this._hasNext=!!u,this._isLoading=!1,[2,a];case 2:return[2,[]];case 3:throw E.queryInProgress;case 4:return[3,6];case 5:throw E.invalidParameters;case 6:return[2]}}))}))},t}(T),Zt=function(e){function t(t){var n=t.userId,r=t.limit,i=t.token,s=e.call(this)||this;return s.method=u.GET,s.path="".concat(d,"/").concat(encodeURIComponent(n),"/friends"),s.params={limit:r,token:i},s}return n(t,e),t}(p),$t=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 v(t,e)})),r.next=n.next,r}return n(t,e),t}(y),en=function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return n(t,e),t.prototype._validate=function(){return e.prototype._validate.call(this)},t.prototype.next=function(){return s(this,void 0,void 0,(function(){var e,t,n,r,i,s,a,u,c;return o(this,(function(o){switch(o.label){case 0:return this._validate()?this._isLoading?[3,3]:this._hasNext?(this._isLoading=!0,e=D.of(this._iid),t=e.sdkState,n=e.requestQueue,r=new Zt(_(_({},this),{userId:t.userId,token:this._token})),[4,n.send(r)]):[3,2]:[3,5];case 1:return i=o.sent(),s=i.as($t),a=s.users,u=s.hasMore,c=s.next,this._token=c,this._hasNext=u,this._isLoading=!1,[2,a];case 2:return[2,[]];case 3:throw E.queryInProgress;case 4:return[3,6];case 5:throw E.invalidParameters;case 6:return[2]}}))}))},t}(T),tn=null,nn=function(){function n(e,t,n){var r=this;this._storeInitialized=!1,this._fcmPushToken=null,this._apnsPushToken=null,this._iid=e,this.options=t;var i=D.of(e),a=i.sdkState,u=i.cacheContext,c=i.dispatcher,d=i.sessionManager,l=i.requestQueue,h=i.logger,f=i.userEventHandlers,p=i.appStateToggleEnabled;this._onlineDetector=new Ve({logger:h,connectionDelegate:{reconnect:function(){var t=D.of(e),n=t.sdkState,r=t.connectionManager,i=t.sessionManager;i.auth.hasSession?"foreground"===n.appState&&r.resetAndReconnect():r.connect(i.auth.authToken)},disconnect:function(){D.of(e).connectionManager.disconnect()}}});var v=new Ee(e,{localCacheEnabled:u.localCacheEnabled,dispatcher:c,sdkState:a,logger:h});n.forEach((function(t){t.init(e,{sdkState:a,cacheContext:u,dispatcher:c,sessionManager:d,requestQueue:l,logger:h,onlineDetector:r._onlineDetector}),r[t.name]=t})),this._appStateChangeDetector=new Ke({isEnabled:p}),this._appStateChangeDetector.on("resume",(function(){h.debug("the page resumes from freeze"),r.setForegroundState()})).on("pause",(function(){h.debug("the page freezes"),r.setBackgroundState()})),c.on((function(t){if(t instanceof Y){if(t.stateType===Z.CONNECTED)v.processNonAutoResendRegisteredPendingMessages()}else if(t instanceof $){if("USEV"===t.code){var n=t.as(De).event;if(n.category===Ue.FRIEND_DISCOVERED){var i=Oe.getDataAsFriendDiscoveredEvent(e,n).friendDiscoveries;ee((function(){return s(r,void 0,void 0,(function(){return o(this,(function(e){return[2,f.forEach((function(e){e.onFriendsDiscovered(i)}))]}))}))}))}}}else if(t instanceof te){var c=D.of(r._iid).subscribedUnreadMessageCount,d=!1,l=t.ts;if("number"==typeof l&&l>c.ts){if(c.all!==t.all&&(d=!0),c.all=t.all>=0?t.all:0,t.customTypes)for(var h in t.customTypes)c.customTypes[h]!==t.customTypes[h]&&(d=!0),c.customTypes[h]=t.customTypes[h];d=d&&c.ts>0,c.ts=l}d&&ee((function(){return s(r,void 0,void 0,(function(){return o(this,(function(e){return[2,f.forEach((function(e){e.onTotalUnreadMessageCountUpdated(c.all,c.customTypes)}))]}))}))}))}else t instanceof ne&&u.preference.set(r._getUserProfileCacheKey(a.userId),re.payloadify(t.userProfile))}))}return n.init=function(e){var t=e.appId,r=e.appVersion,i=void 0===r?null:r,s=e.modules,o=void 0===s?[]:s,a=e.options,u=void 0===a?new A:a,c=e.debugMode,d=void 0!==c&&c,l=e.customApiHost,h=e.customWebSocketHost,f=e.newInstance,p=void 0!==f&&f,v=e.logLevel,_=e.localCacheEnabled,m=void 0!==_&&_,g=e.localCacheConfig,y=void 0===g?new j:g,b=e.localCacheEncryption,w=e.useAsyncStorageStore,k=void 0===w?null:w,I=e.appStateToggleEnabled,S=void 0===I||I;if(!tn||p){var C="su-".concat(z()),T=null!=b?b:{encrypt:function(e){return e},decrypt:function(e){return e}},P=new Ce({encryption:T});d||(P=q()?k?new Te({AsyncStorage:k,encryption:T}):new Ce({encryption:T}):new Pe({encryption:T})),new D(C,{appId:t,appVersion:i,options:u,apiHost:null!=l?l:"https://api-".concat(t,".sendbird.com"),websocketHost:null!=h?h:"wss://ws-".concat(t,".sendbird.com"),store:P,encryption:T,logLevel:v,localCacheEnabled:m,localCacheConfig:y,debugMode:d,appStateToggleEnabled:S});var E=[new de,new he],U=new n(C,u,x(x([],H(o),!1),H(E),!1));return tn||(tn=U),U}return tn},Object.defineProperty(n,"instance",{get:function(){return tn},enumerable:!1,configurable:!0}),Object.defineProperty(n,"version",{get:function(){return G},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"appId",{get:function(){return D.of(this._iid).sdkState.appId},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"appInfo",{get:function(){return D.of(this._iid).appInfo},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"appVersion",{get:function(){var e;return null!==(e=D.of(this._iid).sdkState.appVersion)&&void 0!==e?e:""},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"debugMode",{get:function(){return D.of(this._iid).debugMode},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"logLevel",{get:function(){return D.of(this._iid).logger.level},set:function(e){D.of(this._iid).logger.level=e},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"isCacheEnabled",{get:function(){return D.of(this._iid).cacheContext.localCacheEnabled},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"localCacheConfig",{get:function(){var e=D.of(this._iid).cacheContext;return e.localCacheEnabled?e.localCacheConfig:null},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"ekey",{get:function(){return D.of(this._iid).sessionManager.ekey},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"currentUser",{get:function(){var e;return null!==(e=D.of(this._iid).sessionManager.currentUser)&&void 0!==e?e:null},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"connectionState",{get:function(){var e=D.of(this._iid).connectionManager;return e.isConnected?W.OPEN:e.isConnecting?W.CONNECTING:W.CLOSED},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"lastConnectedAt",{get:function(){var e=D.of(this._iid),t=e.connectedAt;return e.connectionManager.isConnected?t:0},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"fcmPushToken",{get:function(){return this._fcmPushToken},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"apnsPushToken",{get:function(){return this._apnsPushToken},enumerable:!1,configurable:!0}),n.prototype._getCurrentPreferenceVersion=function(){return 1},n.prototype._getPreferenceCacheKey=function(e){return"sendbird@".concat(this.appId,"/").concat(e,".pref")},n.prototype._getUserProfileCacheKey=function(e){return"sendbird@".concat(this.appId,"/").concat(e,".profile")},n.prototype.getMemoryStoreForDebugging=function(){var e=D.of(this._iid),t=e.debugMode,n=e.cacheContext;if(t)return n.store instanceof Ce?n.store:null;throw E.debugModeRequired},n.prototype.addExtension=function(e,t){var n=D.of(this._iid).sdkState;["sb_uikit","sb_syncmanager","device-os-platform"].indexOf(e)>-1&&(n.extensions[e]=t)},n.prototype.setOnlineListener=function(e){this._onlineDetector.setOnlineListener(e)},n.prototype.setOfflineListener=function(e){this._onlineDetector.setOfflineListener(e)},n.prototype._safeInitializeStore=function(e){return s(this,void 0,void 0,(function(){var t;return o(this,(function(n){switch(n.label){case 0:t=D.of(this._iid).cacheContext,n.label=1;case 1:return n.trys.push([1,3,,5]),[4,t.store.init(e)];case 2:return n.sent(),this._storeInitialized=!0,[3,5];case 3:return n.sent(),t.store=new Ce,[4,this._safeInitializeStore(e)];case 4:return n.sent(),[3,5];case 5:return[2]}}))}))},n.prototype.initializeCache=function(e){return s(this,void 0,void 0,(function(){var t,n,r,i,s,a,u,c,d;return o(this,(function(o){switch(o.label){case 0:return t=D.of(this._iid),n=t.sdkState,r=t.cacheContext,i=t.connectionManager,s=t.dispatcher,a=t.logger,n.userId&&n.userId===e?[3,10]:[4,i.logout()];case 1:if(o.sent(),u="sendbird@".concat(n.appId,"/").concat(e,".db"),!r.localCacheEnabled)return[3,8];o.label=2;case 2:return o.trys.push([2,5,,7]),r.nestdb&&r.nestdb.state!==Fe.CLOSED&&r.nestdb.name===u?[3,4]:((c=r.nestdb=new Ne({name:"sendbird@".concat(n.appId,"/").concat(e,".db"),version:2,store:r.store})).on("upgrade",Ge(c,r.store)),[4,c.open()]);case 3:o.sent(),this._storeInitialized=!0,s.dispatch(new Le(this._iid,{userId:e})),o.label=4;case 4:return n.userId=e,[3,7];case 5:return d=o.sent(),a.warn("Nest DB Open Failed. ",d),[4,this._safeInitializeStore(u)];case 6:throw o.sent(),n.userId=e,E.databaseError;case 7:return[3,10];case 8:return[4,this._safeInitializeStore(u)];case 9:o.sent(),n.userId=e,o.label=10;case 10:return[2]}}))}))},n.prototype.getCacheDataSize=function(){return s(this,void 0,void 0,(function(){var e;return o(this,(function(t){switch(t.label){case 0:return(e=D.of(this._iid).cacheContext).localCacheEnabled&&e.nestdb?[4,e.nestdb.estimateUsage()]:[3,2];case 1:return[2,t.sent()];case 2:return[2,0]}}))}))},n.prototype.clearCachedData=function(){return s(this,void 0,void 0,(function(){var e;return o(this,(function(t){switch(t.label){case 0:return(e=D.of(this._iid).cacheContext).localCacheEnabled&&e.nestdb?[4,e.nestdb.clear()]:[3,2];case 1:t.sent(),t.label=2;case 2:return this._storeInitialized?[4,e.preference.clear()]:[3,4];case 3:t.sent(),t.label=4;case 4:return[2]}}))}))},n.prototype.clearCachedMessages=function(e){return s(this,void 0,void 0,(function(){var t,n,r=this;return o(this,(function(i){switch(i.label){case 0:return V(I("string",e)).throw(E.invalidParameters),t=Ae.of(this._iid),n=Me.of(this._iid),t&&n?[4,Promise.all(e.map((function(e){return s(r,void 0,void 0,(function(){return o(this,(function(r){switch(r.label){case 0:return[4,t.removeMessagesOfChannel(e)];case 1:return r.sent(),[4,n.removeMessagesOfChannel(e)];case 2:return r.sent(),[2]}}))}))})))]:[3,2];case 1:i.sent(),i.label=2;case 2:return[2]}}))}))},n.prototype.connect=function(e,n){return void 0===n&&(n=null),s(this,void 0,void 0,(function(){var r,i,s,a,u,c,d;return o(this,(function(o){switch(o.label){case 0:V(t("string",e)&&t("string",n,!0)).throw(E.invalidParameters),r=D.of(this._iid),i=r.sdkState,s=r.cacheContext,a=r.connectionManager,u=r.statLogCollector,this._onlineDetector.start(),this._appStateChangeDetector.start(),o.label=1;case 1:return o.trys.push([1,3,,4]),[4,this.initializeCache(e)];case 2:return o.sent(),D.of(this._iid).dispatcher.dispatch(new Re),[3,4];case 3:return o.sent(),c=D.of(this._iid).logger,s.localCacheEnabled=!1,c.warn("Cache initialization failed - cache is not available."),[3,4];case 4:return[4,s.preference.init(this._getPreferenceCacheKey(e),this._getCurrentPreferenceVersion())];case 5:return o.sent(),[4,s.preference.get(this._getUserProfileCacheKey(e))];case 6:return(d=o.sent())&&new re(this._iid,d).apply(),[4,u.init("sendbird@".concat(i.appId,"/").concat(e,".statlog"))];case 7:return o.sent(),[4,a.connect(n)];case 8:return o.sent(),[2,this.currentUser]}}))}))},n.prototype.reconnect=function(){var e=D.of(this._iid),t=e.connectionManager,n=e.sdkState,r=e.sessionManager.auth.hasSession;return r&&(this._appStateChangeDetector.start(),this._onlineDetector.start(),t.resetAndReconnect().then((function(){n.appState="foreground"})).catch((function(){}))),r},n.prototype.disconnect=function(){return s(this,void 0,void 0,(function(){var e,t,n;return o(this,(function(r){switch(r.label){case 0:return e=D.of(this._iid),t=e.connectionManager,n=e.requestQueue,this._appStateChangeDetector.stop(),this._onlineDetector.stop(),n.cancelAll(),[4,t.logout()];case 1:return r.sent(),[4,this.clearCachedData()];case 2:return r.sent(),[2]}}))}))},n.prototype.disconnectWebSocket=function(){return s(this,void 0,void 0,(function(){var e,t,n;return o(this,(function(r){switch(r.label){case 0:return e=D.of(this._iid),t=e.connectionManager,n=e.requestQueue,this._appStateChangeDetector.stop(),this._onlineDetector.stop(),n.cancelAll(),[4,t.disconnectWebSocket()];case 1:return r.sent(),[2]}}))}))},n.prototype.setBackgroundState=function(){var e=D.of(this._iid),t=e.connectionManager,n=e.sdkState,r=e.logger;"foreground"===n.appState&&(n.appState="background",r.debug("going background state"),t.background())},n.prototype.setForegroundState=function(){var e=D.of(this._iid),t=e.connectionManager,n=e.sdkState,r=e.logger;"background"===n.appState&&(n.appState="foreground",r.debug("going foreground state"),t.resetAndReconnect())},n.prototype.setSessionHandler=function(e){V(e instanceof Qe).throw(E.invalidParameters),D.of(this._iid).sessionManager.handler=e},n.prototype.addUserEventHandler=function(e,n){V(t("string",e)&&n instanceof He).throw(E.invalidParameters),D.of(this._iid).userEventHandlers.set(e,n)},n.prototype.removeUserEventHandler=function(e){D.of(this._iid).userEventHandlers.delete(e)},n.prototype.removeAllUserEventHandler=function(){D.of(this._iid).userEventHandlers.clear()},n.prototype.addConnectionHandler=function(e,n){V(t("string",e)&&n instanceof xe).throw(E.invalidParameters),D.of(this._iid).connectionHandlers.set(e,n)},n.prototype.removeConnectionHandler=function(e){D.of(this._iid).connectionHandlers.delete(e)},n.prototype.removeAllConnectionHandler=function(){D.of(this._iid).connectionHandlers.clear()},n.prototype.createApplicationUserListQuery=function(e){return void 0===e&&(e={}),new Bt(this._iid,e)},n.prototype.createBlockedUserListQuery=function(e){return void 0===e&&(e={}),new Yt(this._iid,e)},n.prototype.createFriendListQuery=function(e){return void 0===e&&(e={}),new en(this._iid,e)},n.prototype.createMessageSearchQuery=function(e){return new le(this._iid,e)},n.prototype.createPollListQuery=function(e){return new je(this._iid,_({},e))},n.prototype.createPollVoterListQuery=function(e){return new ze(this._iid,_({},e))},n.prototype.buildUserFromSerializedData=function(e){var t=X(e);return new v(this._iid,v.payloadify(t))},n.prototype.updateCurrentUserInfo=function(n){return void 0===n&&(n={}),s(this,void 0,void 0,(function(){var r,i,s,a,u,c,d;return o(this,(function(o){switch(o.label){case 0:return r=_(_({},qe),n),V(function(n){return e(n.profileImage,!0)&&t("string",n.profileUrl,!0)&&t("string",n.nickname,!0)}(r)).throw(E.invalidParameters),this.currentUser?(i=D.of(this._iid),s=i.sdkState,a=i.requestQueue,u=new Be(_({userId:s.userId},r)),[4,a.send(u)]):[3,2];case 1:return c=o.sent(),d=c.as(Je).user,this.currentUser&&(r.nickname&&(this.currentUser.nickname=d.nickname),(r.profileUrl||r.profileImage)&&(this.currentUser.plainProfileUrl=d.profileUrl)),[2,d];case 2:throw E.connectionRequired}}))}))},n.prototype.updateCurrentUserInfoWithPreferredLanguages=function(e){return s(this,void 0,void 0,(function(){var t,n,r,i,s,a;return o(this,(function(o){switch(o.label){case 0:return V(I("string",e)).throw(E.invalidParameters),this.currentUser?(t=D.of(this._iid),n=t.sdkState,r=t.requestQueue,i=new Be({userId:n.userId,preferredLanguages:e}),[4,r.send(i)]):[3,2];case 1:return s=o.sent(),a=s.as(Je).user,this.currentUser&&(this.currentUser.preferredLanguages=a.preferredLanguages),[2,a];case 2:throw E.connectionRequired}}))}))},n.prototype.registerFCMPushTokenForCurrentUser=function(e){return s(this,void 0,void 0,(function(){var n,r,i,a,u,c=this;return o(this,(function(d){switch(d.label){case 0:if(V(t("string",e)).throw(E.invalidParameters),!this.currentUser)return[3,6];d.label=1;case 1:return d.trys.push([1,4,,5]),n=D.of(this._iid),r=n.sessionManager,i=n.sdkState,a=n.requestQueue,r.hasDeviceToken(b.FCM,e)?[2,ie.SUCCESS]:(u=new Ye({userId:i.userId,token:e}),[4,a.send(u)]);case 2:return d.sent(),[4,se((function(){return s(c,void 0,void 0,(function(){return o(this,(function(t){switch(t.label){case 0:return r.setDeviceToken(b.FCM,e),[4,r.saveDeviceToken()];case 1:return t.sent(),[2]}}))}))}))];case 3:return d.sent(),this._fcmPushToken="",[2,ie.SUCCESS];case 4:return d.sent(),[2,ie.ERROR];case 5:return[3,7];case 6:return this._fcmPushToken=e,[2,ie.PENDING];case 7:return[2]}}))}))},n.prototype.unregisterFCMPushTokenForCurrentUser=function(e){return s(this,void 0,void 0,(function(){var n,r,i,a,u,c,d=this;return o(this,(function(l){switch(l.label){case 0:if(V(t("string",e)).throw(E.invalidParameters),!this.currentUser)return[3,6];l.label=1;case 1:return l.trys.push([1,4,,5]),n=D.of(this._iid),r=n.sessionManager,i=n.sdkState,a=n.requestQueue,u=new $e({userId:i.userId,token:e}),[4,a.send(u)];case 2:return c=l.sent().lastDeletedAt,[4,se((function(){return s(d,void 0,void 0,(function(){return o(this,(function(t){switch(t.label){case 0:return r.unsetDeviceToken(b.FCM,e),r.setDeviceTokenDeletedAt(c),[4,r.saveDeviceToken()];case 1:return t.sent(),[2]}}))}))}))];case 3:return l.sent(),this._fcmPushToken="",[2,ie.SUCCESS];case 4:return l.sent(),[2,ie.ERROR];case 5:return[3,7];case 6:return this._fcmPushToken=e,[2,ie.PENDING];case 7:return[2]}}))}))},n.prototype.unregisterFCMPushTokenAllForCurrentUser=function(){return s(this,void 0,void 0,(function(){var e,t,n,r,i,a,u=this;return o(this,(function(c){switch(c.label){case 0:return this.currentUser?(e=D.of(this._iid),t=e.sessionManager,n=e.sdkState,r=e.requestQueue,i=new tt({userId:n.userId}),[4,r.send(i)]):[3,3];case 1:return a=c.sent().lastDeletedAt,[4,se((function(){return s(u,void 0,void 0,(function(){return o(this,(function(e){switch(e.label){case 0:return t.unsetDeviceTokens(b.FCM),t.setDeviceTokenDeletedAt(a),[4,t.saveDeviceToken()];case 1:return e.sent(),[2]}}))}))}))];case 2:c.sent(),c.label=3;case 3:return[2]}}))}))},n.prototype.registerAPNSPushTokenForCurrentUser=function(e){return s(this,void 0,void 0,(function(){var n,r,i,a,u,c=this;return o(this,(function(d){switch(d.label){case 0:if(V(t("string",e)).throw(E.invalidParameters),!this.currentUser)return[3,6];d.label=1;case 1:return d.trys.push([1,4,,5]),n=D.of(this._iid),r=n.sessionManager,i=n.sdkState,a=n.requestQueue,r.hasDeviceToken(b.APNS,e)?[2,ie.SUCCESS]:(u=new Xe({userId:i.userId,token:e}),[4,a.send(u)]);case 2:return d.sent(),[4,se((function(){return s(c,void 0,void 0,(function(){return o(this,(function(t){switch(t.label){case 0:return r.setDeviceToken(b.APNS,e),[4,r.saveDeviceToken()];case 1:return t.sent(),[2]}}))}))}))];case 3:return d.sent(),this._apnsPushToken="",[2,ie.SUCCESS];case 4:return d.sent(),[2,ie.ERROR];case 5:return[3,7];case 6:return this._apnsPushToken=e,[2,ie.PENDING];case 7:return[2]}}))}))},n.prototype.unregisterAPNSPushTokenForCurrentUser=function(e){return s(this,void 0,void 0,(function(){var n,r,i,a,u,c,d=this;return o(this,(function(l){switch(l.label){case 0:if(V(t("string",e)).throw(E.invalidParameters),!this.currentUser)return[3,6];l.label=1;case 1:return l.trys.push([1,4,,5]),n=D.of(this._iid),r=n.sessionManager,i=n.sdkState,a=n.requestQueue,u=new Ze({userId:i.userId,token:e}),[4,a.send(u)];case 2:return c=l.sent().lastDeletedAt,[4,se((function(){return s(d,void 0,void 0,(function(){return o(this,(function(t){switch(t.label){case 0:return r.unsetDeviceToken(b.APNS,e),r.setDeviceTokenDeletedAt(c),[4,r.saveDeviceToken()];case 1:return t.sent(),[2]}}))}))}))];case 3:return l.sent(),this._apnsPushToken="",[2,ie.SUCCESS];case 4:return l.sent(),[2,ie.ERROR];case 5:return[3,7];case 6:return this._apnsPushToken=e,[2,ie.PENDING];case 7:return[2]}}))}))},n.prototype.unregisterAPNSPushTokenAllForCurrentUser=function(){return s(this,void 0,void 0,(function(){var e,t,n,r,i,a,u=this;return o(this,(function(c){switch(c.label){case 0:return this.currentUser?(e=D.of(this._iid),t=e.sessionManager,n=e.sdkState,r=e.requestQueue,i=new et({userId:n.userId}),[4,r.send(i)]):[3,3];case 1:return a=c.sent().lastDeletedAt,[4,se((function(){return s(u,void 0,void 0,(function(){return o(this,(function(e){switch(e.label){case 0:return t.unsetDeviceTokens(b.APNS),t.setDeviceTokenDeletedAt(a),[4,t.saveDeviceToken()];case 1:return e.sent(),[2]}}))}))}))];case 2:c.sent(),c.label=3;case 3:return[2]}}))}))},n.prototype.getChannelInvitationPreference=function(){return s(this,void 0,void 0,(function(){var e,t,n,r,i;return o(this,(function(s){switch(s.label){case 0:return e=D.of(this._iid),t=e.sdkState,n=e.requestQueue,r=new it({userId:t.userId}),[4,n.send(r)];case 1:return i=s.sent(),[2,{autoAccept:i.as(st).autoAccept}]}}))}))},n.prototype.setChannelInvitationPreference=function(e){return s(this,void 0,void 0,(function(){var n,r,i,s,a;return o(this,(function(o){switch(o.label){case 0:return V(t("boolean",e)).throw(E.invalidParameters),n=D.of(this._iid),r=n.sdkState,i=n.requestQueue,s=new ot({userId:r.userId,willAutoAccept:e}),[4,i.send(s)];case 1:return a=o.sent(),[2,{autoAccept:a.as(at).autoAccept}]}}))}))},n.prototype.getDoNotDisturb=function(){return s(this,void 0,void 0,(function(){var e,t,n,r,i;return o(this,(function(s){switch(s.label){case 0:return e=D.of(this._iid),t=e.sdkState,n=e.requestQueue,r=new ut({userId:t.userId}),[4,n.send(r)];case 1:return i=s.sent(),[2,i.as(ct).preference]}}))}))},n.prototype.setDoNotDisturb=function(e,n,r,i,a,u){return void 0===n&&(n=0),void 0===r&&(r=0),void 0===i&&(i=0),void 0===a&&(a=0),void 0===u&&(u=""),s(this,void 0,void 0,(function(){var s,c,d,l,h;return o(this,(function(o){switch(o.label){case 0:return V(t("boolean",e)&&t("number",n)&&t("number",r)&&t("number",i)&&t("number",a)&&t("string",u)).throw(E.invalidParameters),s=D.of(this._iid),c=s.sdkState,d=s.requestQueue,l=new dt({userId:c.userId,doNotDisturbOn:e,startHour:n,startMin:r,endHour:i,endMin:a,timezone:u}),[4,d.send(l)];case 1:return h=o.sent(),[2,h.as(lt).preference]}}))}))},n.prototype.getSnoozePeriod=function(){return s(this,void 0,void 0,(function(){var e,t,n,r,i;return o(this,(function(s){switch(s.label){case 0:return e=D.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(ft).snoozePeriod]}}))}))},n.prototype.setSnoozePeriod=function(e,n,r){return void 0===n&&(n=0),void 0===r&&(r=0),s(this,void 0,void 0,(function(){var i,s,a,u,c;return o(this,(function(o){switch(o.label){case 0:return V(t("boolean",e)&&t("number",n)&&t("number",r)).throw(E.invalidParameters),i=D.of(this._iid),s=i.sdkState,a=i.requestQueue,u=new pt({userId:s.userId,snoozeOn:e,startTs:n,endTs:r}),[4,a.send(u)];case 1:return c=o.sent(),[2,c.as(vt).snoozePeriod]}}))}))},n.prototype.getMyPushTokensByToken=function(e,n){return s(this,void 0,void 0,(function(){var r,i,s,a,u,c,d,l,h,f,p,v;return o(this,(function(o){switch(o.label){case 0:return V(t("string",e)&&ae(b,n)).throw(E.invalidParameters),r=D.of(this._iid),i=r.sdkState,s=r.requestQueue,a=r.sessionManager,u=new nt({userId:i.userId,type:n,token:e}),[4,s.send(u)];case 1:c=o.sent(),d=c.as(rt).pushTokens;try{for(l=oe(d.deviceTokens),h=l.next();!h.done;h=l.next())f=h.value,a.setDeviceToken(d.type,f)}catch(e){p={error:e}}finally{try{h&&!h.done&&(v=l.return)&&v.call(l)}finally{if(p)throw p.error}}return[4,a.saveDeviceToken()];case 2:return o.sent(),[2,d]}}))}))},n.prototype.getPushTriggerOption=function(){return s(this,void 0,void 0,(function(){var e,t,n,r;return o(this,(function(i){switch(i.label){case 0:return e=D.of(this._iid),t=e.sdkState,n=e.requestQueue,r=new gt({userId:t.userId}),[4,n.send(r)];case 1:return[2,i.sent().as(yt).pushTriggerOption]}}))}))},n.prototype.setPushTriggerOption=function(e){return s(this,void 0,void 0,(function(){var t,n,r,i;return o(this,(function(s){switch(s.label){case 0:return V(ae(ue,e)).throw(E.invalidParameters),t=D.of(this._iid),n=t.sdkState,r=t.requestQueue,i=new bt({userId:n.userId,pushTriggerOption:e}),[4,r.send(i)];case 1:return[2,s.sent().as(wt).pushTriggerOption]}}))}))},n.prototype.getPushTemplate=function(){return s(this,void 0,void 0,(function(){var e,t,n,r;return o(this,(function(i){switch(i.label){case 0:return e=D.of(this._iid),t=e.sdkState,n=e.requestQueue,r=new kt({userId:t.userId}),[4,n.send(r)];case 1:return[2,i.sent().as(It).name]}}))}))},n.prototype.setPushTemplate=function(e){return s(this,void 0,void 0,(function(){var t,n,r,i;return o(this,(function(s){switch(s.label){case 0:return V(ae(ce,e)).throw(E.invalidParameters),t=D.of(this._iid),n=t.sdkState,r=t.requestQueue,i=new St({userId:n.userId,templateName:e}),[4,r.send(i)];case 1:return[2,s.sent().as(Ct).name]}}))}))},n.prototype.blockUser=function(e){return s(this,void 0,void 0,(function(){var n,r,i,s;return o(this,(function(o){switch(o.label){case 0:return V(e instanceof v||t("string",e)).throw(E.invalidParameters),n=D.of(this._iid),r=n.sdkState,i=n.requestQueue,s=new _t({userId:r.userId,blockedUserId:e instanceof v?e.userId:e}),[4,i.send(s)];case 1:return o.sent(),[2]}}))}))},n.prototype.blockUserWithUserId=function(e){return s(this,void 0,void 0,(function(){return o(this,(function(t){return[2,this.blockUser(e)]}))}))},n.prototype.unblockUser=function(e){return s(this,void 0,void 0,(function(){var n,r,i,s;return o(this,(function(o){switch(o.label){case 0:return V(e instanceof v||t("string",e)).throw(E.invalidParameters),n=D.of(this._iid),r=n.sdkState,i=n.requestQueue,s=new mt({userId:r.userId,unblockedUserId:e instanceof v?e.userId:e}),[4,i.send(s)];case 1:return o.sent(),[2]}}))}))},n.prototype.unblockUserWithUserId=function(e){return s(this,void 0,void 0,(function(){return o(this,(function(t){return[2,this.unblockUser(e)]}))}))},n.prototype.getFriendChangeLogsByToken=function(e){return s(this,void 0,void 0,(function(){var n,r,i,s,a;return o(this,(function(o){switch(o.label){case 0:return V(t("string",e)).throw(E.invalidParameters),n=D.of(this._iid),r=n.sdkState,i=n.requestQueue,s=new Tt({userId:r.userId,token:e}),[4,i.send(s)];case 1:return a=o.sent(),[2,a.as(Pt).changelogs]}}))}))},n.prototype.getAllowFriendDiscovery=function(){return s(this,void 0,void 0,(function(){var e,t,n,r,i;return o(this,(function(s){switch(s.label){case 0:return e=D.of(this._iid),t=e.sdkState,n=e.requestQueue,r=new At({userId:t.userId}),[4,n.send(r)];case 1:return i=s.sent(),[2,i.as(Mt).allowFriendDiscovery]}}))}))},n.prototype.setAllowFriendDiscovery=function(e){return s(this,void 0,void 0,(function(){var n,r,i,s;return o(this,(function(o){switch(o.label){case 0:return V(t("boolean",e)).throw(E.invalidParameters),n=D.of(this._iid),r=n.sdkState,i=n.requestQueue,s=new Rt({userId:r.userId,allowFriendDiscovery:e}),[4,i.send(s)];case 1:return o.sent(),[2,e]}}))}))},n.prototype.uploadFriendDiscoveries=function(e){return s(this,void 0,void 0,(function(){var t,n,r,i,s;return o(this,(function(o){switch(o.label){case 0:return t=D.of(this._iid),n=t.sdkState,r=t.requestQueue,i=new Et({userId:n.userId,discoveries:e}),[4,r.send(i)];case 1:return s=o.sent(),[2,s.as(Dt).friendDiscoveryRequestId]}}))}))},n.prototype.deleteFriendDiscovery=function(e){return s(this,void 0,void 0,(function(){return o(this,(function(t){return[2,this.deleteFriendDiscoveries([e])]}))}))},n.prototype.deleteFriendDiscoveries=function(e){return s(this,void 0,void 0,(function(){var t,n,r,i;return o(this,(function(s){switch(s.label){case 0:return V(I("string",e)).throw(E.invalidParameters),t=D.of(this._iid),n=t.sdkState,r=t.requestQueue,i=new Ut({userId:n.userId,discoveryKeys:e}),[4,r.send(i)];case 1:return s.sent(),[2]}}))}))},n.prototype.addFriends=function(e){return s(this,void 0,void 0,(function(){var t,n,r,i,s;return o(this,(function(o){switch(o.label){case 0:return V(I("string",e)).throw(E.invalidParameters),t=D.of(this._iid),n=t.sdkState,r=t.requestQueue,i=new Ot({userId:n.userId,userIds:e}),[4,r.send(i)];case 1:return s=o.sent(),[2,s.as(Lt).users]}}))}))},n.prototype.deleteFriend=function(e){return s(this,void 0,void 0,(function(){return o(this,(function(t){return[2,this.deleteFriends([e])]}))}))},n.prototype.deleteFriends=function(e){return s(this,void 0,void 0,(function(){var t,n,r,i;return o(this,(function(s){switch(s.label){case 0:return V(I("string",e)).throw(E.invalidParameters),t=D.of(this._iid),n=t.sdkState,r=t.requestQueue,i=new Nt({userId:n.userId,userIds:e}),[4,r.send(i)];case 1:return s.sent(),[2]}}))}))},n.prototype.getAllEmoji=function(){return s(this,void 0,void 0,(function(){var e,t,n;return o(this,(function(r){switch(r.label){case 0:return e=D.of(this._iid).requestQueue,t=new qt,[4,e.send(t)];case 1:return n=r.sent(),[2,n.as(Qt).emojiContainer]}}))}))},n.prototype.getEmojiCategory=function(e){return s(this,void 0,void 0,(function(){var t,n,r;return o(this,(function(i){switch(i.label){case 0:return t=D.of(this._iid).requestQueue,n=new xt({categoryId:e}),[4,t.send(n)];case 1:return r=i.sent(),[2,r.as(Ht).emojiCategory]}}))}))},n.prototype.getEmoji=function(e){return s(this,void 0,void 0,(function(){var t,n,r;return o(this,(function(i){switch(i.label){case 0:return t=D.of(this._iid).requestQueue,n=new Gt({key:e}),[4,t.send(n)];case 1:return r=i.sent(),[2,r.as(Wt).emoji]}}))}))},n}();export{Bt as ApplicationUserListQuery,Yt as BlockedUserListQuery,xe as ConnectionHandler,Ft as Emoji,jt as EmojiCategory,zt as EmojiContainer,en as FriendListQuery,Qe as SessionHandler,He as UserEventHandler,nn as default}; diff --git a/sendbird.min.js b/sendbird.min.js index f87abe7..55ec6e8 100644 --- a/sendbird.min.js +++ b/sendbird.min.js @@ -1 +1 @@ -var Sendbird=function(e){"use strict";function t(){t=function(){return e};var e={},n=Object.prototype,r=n.hasOwnProperty,a=Object.defineProperty||function(e,t,n){e[t]=n.value},s="function"==typeof Symbol?Symbol:{},i=s.iterator||"@@iterator",o=s.asyncIterator||"@@asyncIterator",u=s.toStringTag||"@@toStringTag";function c(e,t,n){return Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}),e[t]}try{c({},"")}catch(e){c=function(e,t,n){return e[t]=n}}function l(e,t,n,r){var s=t&&t.prototype instanceof f?t:f,i=Object.create(s.prototype),o=new T(r||[]);return a(i,"_invoke",{value:E(e,n,o)}),i}function h(e,t,n){try{return{type:"normal",arg:e.call(t,n)}}catch(e){return{type:"throw",arg:e}}}e.wrap=l;var d={};function f(){}function p(){}function v(){}var _={};c(_,i,(function(){return this}));var m=Object.getPrototypeOf,g=m&&m(m(S([])));g&&g!==n&&r.call(g,i)&&(_=g);var y=v.prototype=f.prototype=Object.create(_);function k(e){["next","throw","return"].forEach((function(t){c(e,t,(function(e){return this._invoke(t,e)}))}))}function b(e,t){function n(a,s,i,o){var u=h(e[a],e,s);if("throw"!==u.type){var c=u.arg,l=c.value;return l&&"object"==typeof l&&r.call(l,"__await")?t.resolve(l.__await).then((function(e){n("next",e,i,o)}),(function(e){n("throw",e,i,o)})):t.resolve(l).then((function(e){c.value=e,i(c)}),(function(e){return n("throw",e,i,o)}))}o(u.arg)}var s;a(this,"_invoke",{value:function(e,r){function a(){return new t((function(t,a){n(e,r,t,a)}))}return s=s?s.then(a,a):a()}})}function E(e,t,n){var r="suspendedStart";return function(a,s){if("executing"===r)throw new Error("Generator is already running");if("completed"===r){if("throw"===a)throw s;return I()}for(n.method=a,n.arg=s;;){var i=n.delegate;if(i){var o=w(i,n);if(o){if(o===d)continue;return o}}if("next"===n.method)n.sent=n._sent=n.arg;else if("throw"===n.method){if("suspendedStart"===r)throw r="completed",n.arg;n.dispatchException(n.arg)}else"return"===n.method&&n.abrupt("return",n.arg);r="executing";var u=h(e,t,n);if("normal"===u.type){if(r=n.done?"completed":"suspendedYield",u.arg===d)continue;return{value:u.arg,done:n.done}}"throw"===u.type&&(r="completed",n.method="throw",n.arg=u.arg)}}}function w(e,t){var n=t.method,r=e.iterator[n];if(void 0===r)return t.delegate=null,"throw"===n&&e.iterator.return&&(t.method="return",t.arg=void 0,w(e,t),"throw"===t.method)||"return"!==n&&(t.method="throw",t.arg=new TypeError("The iterator does not provide a '"+n+"' method")),d;var a=h(r,e.iterator,t.arg);if("throw"===a.type)return t.method="throw",t.arg=a.arg,t.delegate=null,d;var s=a.arg;return s?s.done?(t[e.resultName]=s.value,t.next=e.nextLoc,"return"!==t.method&&(t.method="next",t.arg=void 0),t.delegate=null,d):s:(t.method="throw",t.arg=new TypeError("iterator result is not an object"),t.delegate=null,d)}function C(e){var t={tryLoc:e[0]};1 in e&&(t.catchLoc=e[1]),2 in e&&(t.finallyLoc=e[2],t.afterLoc=e[3]),this.tryEntries.push(t)}function x(e){var t=e.completion||{};t.type="normal",delete t.arg,e.completion=t}function T(e){this.tryEntries=[{tryLoc:"root"}],e.forEach(C,this),this.reset(!0)}function S(e){if(e){var t=e[i];if(t)return t.call(e);if("function"==typeof e.next)return e;if(!isNaN(e.length)){var n=-1,a=function t(){for(;++n=0;--a){var s=this.tryEntries[a],i=s.completion;if("root"===s.tryLoc)return n("end");if(s.tryLoc<=this.prev){var o=r.call(s,"catchLoc"),u=r.call(s,"finallyLoc");if(o&&u){if(this.prev=0;--n){var a=this.tryEntries[n];if(a.tryLoc<=this.prev&&r.call(a,"finallyLoc")&&this.prev=0;--t){var n=this.tryEntries[t];if(n.finallyLoc===e)return this.complete(n.completion,n.afterLoc),x(n),d}},catch:function(e){for(var t=this.tryEntries.length-1;t>=0;--t){var n=this.tryEntries[t];if(n.tryLoc===e){var r=n.completion;if("throw"===r.type){var a=r.arg;x(n)}return a}}throw new Error("illegal catch attempt")},delegateYield:function(e,t,n){return this.delegate={iterator:S(e),resultName:t,nextLoc:n},"next"===this.method&&(this.arg=void 0),d}},e}function n(e){return n="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},n(e)}function r(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function a(e,t){for(var n=0;ne.length)&&(t=e.length);for(var n=0,r=new Array(t);n=e.length?{done:!0}:{done:!1,value:e[r++]}},e:function(e){throw e},f:a}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var s,i=!0,o=!1;return{s:function(){n=n.call(e)},n:function(){var e=n.next();return i=e.done,e},e:function(e){o=!0,s=e},f:function(){try{i||null==n.return||n.return()}finally{if(o)throw s}}}}function k(e){var t=function(e,t){if("object"!=typeof e||null===e)return e;var n=e[Symbol.toPrimitive];if(void 0!==n){var r=n.call(e,t||"default");if("object"!=typeof r)return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(e,"string");return"symbol"==typeof t?t:String(t)}function b(e,t,n,r){return new(n||(n=Promise))((function(a,s){function i(e){try{u(r.next(e))}catch(e){s(e)}}function o(e){try{u(r.throw(e))}catch(e){s(e)}}function u(e){var t;e.done?a(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(i,o)}u((r=r.apply(e,t||[])).next())}))}var E,w="4.8.1",C=function(){function e(){r(this,e)}return s(e,null,[{key:"OS_VERSION",get:function(){return"undefined"!=typeof navigator&&navigator.userAgent?navigator.userAgent.replace(/,/g,"."):"noAgent"}},{key:"SDK_VERSION",get:function(){return w}},{key:"SDK_MAJOR_VERSION",get:function(){return e.SDK_VERSION.split(".")[0]}},{key:"DEFAULT_MAX_UNREAD_COUNT_OF_SUPER_GROUP_CHANNEL",get:function(){return 100}},{key:"INTERNAL_CALL",get:function(){return"ic"}}]),e}();!function(e){e[e.STAT_LOG_NOT_ALLOWED=400108]="STAT_LOG_NOT_ALLOWED",e[e.NON_AUTHORIZED=400108]="NON_AUTHORIZED",e[e.INVALID_TOKEN=400111]="INVALID_TOKEN",e[e.NOT_FOUND_IN_DATABASE=400201]="NOT_FOUND_IN_DATABASE",e[e.SESSION_TOKEN_EXPIRED=400302]="SESSION_TOKEN_EXPIRED",e[e.SESSION_KEY_EXPIRED=400309]="SESSION_KEY_EXPIRED",e[e.STAT_UPLOAD_NOT_ALLOWED=403200]="STAT_UPLOAD_NOT_ALLOWED",e[e.INTERNAL_SERVER_ERROR=500901]="INTERNAL_SERVER_ERROR",e[e.RATE_LIMIT_EXCEEDED=500910]="RATE_LIMIT_EXCEEDED",e[e.UNKNOWN_SERVER_ERROR=900200]="UNKNOWN_SERVER_ERROR",e[e.DEBUG_MODE_REQUIRED=7e5]="DEBUG_MODE_REQUIRED",e[e.LOST_INSTANCE=700100]="LOST_INSTANCE",e[e.CONNECTION_RENEW=700102]="CONNECTION_RENEW",e[e.INVALID_CONNECTION_STATE_TRANSITION=700200]="INVALID_CONNECTION_STATE_TRANSITION",e[e.INVALID_INITIALIZATION=800100]="INVALID_INITIALIZATION",e[e.CONNECTION_REQUIRED=800101]="CONNECTION_REQUIRED",e[e.CONNECTION_CANCELED=800102]="CONNECTION_CANCELED",e[e.INVALID_PARAMETER=800110]="INVALID_PARAMETER",e[e.NOT_SUPPORTED_ERROR=800111]="NOT_SUPPORTED_ERROR",e[e.NETWORK_ERROR=800120]="NETWORK_ERROR",e[e.NETWORK_ROUTING_ERROR=800121]="NETWORK_ROUTING_ERROR",e[e.MALFORMED_DATA=800130]="MALFORMED_DATA",e[e.MALFORMED_ERROR_DATA=800140]="MALFORMED_ERROR_DATA",e[e.WRONG_CHANNEL_TYPE=800150]="WRONG_CHANNEL_TYPE",e[e.MARK_AS_READ_RATE_LIMIT_EXCEEDED=800160]="MARK_AS_READ_RATE_LIMIT_EXCEEDED",e[e.QUERY_IN_PROGRESS=800170]="QUERY_IN_PROGRESS",e[e.ACK_TIMEOUT=800180]="ACK_TIMEOUT",e[e.LOGIN_TIMEOUT=800190]="LOGIN_TIMEOUT",e[e.WEBSOCKET_CONNECTION_CLOSED=800200]="WEBSOCKET_CONNECTION_CLOSED",e[e.WEBSOCKET_CONNECTION_FAILED=800210]="WEBSOCKET_CONNECTION_FAILED",e[e.REQUEST_FAILED=800220]="REQUEST_FAILED",e[e.FILE_UPLOAD_CANCEL_FAILED=800230]="FILE_UPLOAD_CANCEL_FAILED",e[e.REQUEST_CANCELED=800240]="REQUEST_CANCELED",e[e.REQUEST_DUPLICATED=800250]="REQUEST_DUPLICATED",e[e.FILE_SIZE_LIMIT_EXCEEDED=800260]="FILE_SIZE_LIMIT_EXCEEDED",e[e.SESSION_TOKEN_REQUEST_FAILED=800500]="SESSION_TOKEN_REQUEST_FAILED",e[e.SESSION_TOKEN_REFRESHED=800501]="SESSION_TOKEN_REFRESHED",e[e.SESSION_TOKEN_REFRESH_FAILED=800502]="SESSION_TOKEN_REFRESH_FAILED",e[e.COLLECTION_DISPOSED=800600]="COLLECTION_DISPOSED",e[e.DATABASE_ERROR=800700]="DATABASE_ERROR"}(E||(E={}));var x,T,S,I,N,A=function(e){return!(e instanceof M&&!e.shouldThrowOutside)},M=function(e){i(n,e);var t=f(n);function n(e){var a,s=e.code,i=void 0===s?0:s,o=e.message;return r(this,n),(a=t.call(this,o)).shouldThrowOutside=!1,a.name="SendbirdError",a.code=i,Object.setPrototypeOf(d(a),n.prototype),a}return s(n,[{key:"isInvalidTokenError",get:function(){return this.code===E.INVALID_TOKEN}},{key:"isSessionTokenExpiredError",get:function(){return this.code===E.SESSION_TOKEN_EXPIRED}},{key:"isSessionKeyExpiredError",get:function(){return this.code===E.SESSION_KEY_EXPIRED}},{key:"throwOutside",value:function(){throw this.shouldThrowOutside=!0,this}}],[{key:"debugModeRequired",get:function(){return new n({code:E.DEBUG_MODE_REQUIRED,message:"Cannot run this operation in production mode."})}},{key:"lostInstance",get:function(){return new n({code:E.LOST_INSTANCE,message:"Instance ID is missing. It should belong to an instance."})}},{key:"connectionRenew",get:function(){return new n({code:E.CONNECTION_RENEW,message:"Connection restarts."})}},{key:"invalidConnectionStateTransition",get:function(){return new n({code:E.INVALID_CONNECTION_STATE_TRANSITION,message:"Invalid connection state transition."})}},{key:"connectionRequired",get:function(){return new n({code:E.CONNECTION_REQUIRED,message:"Connection is required."})}},{key:"connectionCanceled",get:function(){return new n({code:E.CONNECTION_CANCELED,message:"Connection is canceled."})}},{key:"invalidParameters",get:function(){return new n({code:E.INVALID_PARAMETER,message:"Invalid parameters."})}},{key:"notSupportedError",get:function(){return new n({code:E.NOT_SUPPORTED_ERROR,message:"Given parameters are not supported."})}},{key:"networkError",get:function(){return new n({code:E.NETWORK_ERROR,message:"There was a network error."})}},{key:"markAsReadAllRateLimitExceeded",get:function(){return new n({code:E.MARK_AS_READ_RATE_LIMIT_EXCEEDED,message:"markAsRead rate limit exceeded."})}},{key:"queryInProgress",get:function(){return new n({code:E.QUERY_IN_PROGRESS,message:"Query in progress."})}},{key:"noAckTimeout",get:function(){return new n({code:E.ACK_TIMEOUT,message:"Command received no ack."})}},{key:"loginTimeout",get:function(){return new n({code:E.LOGIN_TIMEOUT,message:"Connection timeout."})}},{key:"connectionClosed",get:function(){return new n({code:E.WEBSOCKET_CONNECTION_CLOSED,message:"Connection is closed. Please reconnect."})}},{key:"requestFailed",get:function(){return new n({code:E.REQUEST_FAILED,message:"Request failed."})}},{key:"fileUploadCanceled",get:function(){return new n({code:E.FILE_UPLOAD_CANCEL_FAILED,message:"File upload has been canceled."})}},{key:"requestCanceled",get:function(){return new n({code:E.REQUEST_CANCELED,message:"Request has been canceled."})}},{key:"sessionTokenRefreshFailed",get:function(){return new n({code:E.SESSION_TOKEN_REFRESH_FAILED,message:"Failed to refresh the session key."})}},{key:"sessionTokenRequestFailed",get:function(){return new n({code:E.SESSION_TOKEN_REQUEST_FAILED,message:"Failed to get the session token."})}},{key:"databaseError",get:function(){return new n({code:E.DATABASE_ERROR,message:"Database error."})}}]),n}(h(Error)),O=[E.CONNECTION_REQUIRED,E.NETWORK_ERROR,E.ACK_TIMEOUT,E.WEBSOCKET_CONNECTION_CLOSED,E.WEBSOCKET_CONNECTION_FAILED,E.FILE_UPLOAD_CANCEL_FAILED,E.REQUEST_CANCELED,E.INTERNAL_SERVER_ERROR,E.RATE_LIMIT_EXCEEDED,E.UNKNOWN_SERVER_ERROR],U=[E.WEBSOCKET_CONNECTION_CLOSED,E.WEBSOCKET_CONNECTION_FAILED,E.CONNECTION_REQUIRED],R=function(e,t){if(e!==t){var n=Object.assign({},e),r=Object.assign({},t);return(!n.hasOwnProperty("messageId")||!r.hasOwnProperty("messageId")||n.messageId===r.messageId)&&((!n.hasOwnProperty("reqId")||!r.hasOwnProperty("reqId")||n.reqId===r.reqId)&&(n.hasOwnProperty("messageId")&&delete n.messageId,n.hasOwnProperty("reqId")&&delete n.reqId,r.hasOwnProperty("messageId")&&delete r.messageId,r.hasOwnProperty("reqId")&&delete r.reqId,JSON.stringify(n)===JSON.stringify(r)))}return!0},L=function(e,t){return!(!(arguments.length>2&&void 0!==arguments[2]&&arguments[2])||null!=t)||("string"!=typeof e?"object"===n(e)?D(e,t):P(e,t):n(t)===e)},D=function(e,t){return!(!(arguments.length>2&&void 0!==arguments[2]&&arguments[2])||null!=t)||Object.values(e).includes(t)},P=function(e,t){return t instanceof e},F=function(e,t){return!(!(arguments.length>2&&void 0!==arguments[2]&&arguments[2])||null!=t)||Array.isArray(t)&&t.every((function(t){return L(e,t)}))},G=function(e){return e>0&&U.indexOf(e)>=0},H=function(e){if(arguments.length>1&&void 0!==arguments[1]&&arguments[1]&&null===e)return!0;var t=L("object",e)&&null!==e&&e.hasOwnProperty("name")&&"string"==typeof e.name&&e.hasOwnProperty("uri")&&"string"==typeof e.uri&&e.hasOwnProperty("type")&&"string"==typeof e.type;if(!t){if("undefined"!=typeof Blob)return e instanceof Blob;if("undefined"!=typeof File)return e instanceof File}return t},q=function(){function e(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},n=t.useMemberInfoInMessage,a=void 0===n||n,s=t.typingIndicatorInvalidateTime,i=void 0===s?1e4:s,o=t.typingIndicatorThrottle,u=void 0===o?1e3:o,c=t.websocketResponseTimeout,l=void 0===c?1e4:c,h=t.websocketPayloadDecompression,d=void 0===h||h,f=t.sessionTokenRefreshTimeout,p=void 0===f?60:f;r(this,e),this._useMemberInfoInMessage=!0,this._typingIndicatorInvalidateTime=1e4,this._typingIndicatorThrottle=1e3,this._websocketResponseTimeout=1e4,this._sessionTokenRefreshTimeout=60,this._useMemberInfoInMessage=a,this._typingIndicatorInvalidateTime=i,this._typingIndicatorThrottle=u,this._websocketResponseTimeout=l,this._sessionTokenRefreshTimeout=p,this.websocketPayloadDecompression=d}return s(e,[{key:"useMemberInfoInMessage",get:function(){return this._useMemberInfoInMessage},set:function(e){L("boolean",e)&&(this._useMemberInfoInMessage=e)}},{key:"typingIndicatorInvalidateTime",get:function(){return this._typingIndicatorInvalidateTime},set:function(e){L("number",e)&&(this._typingIndicatorInvalidateTime=e)}},{key:"typingIndicatorThrottle",get:function(){return this._typingIndicatorThrottle},set:function(e){L("number",e)&&e>=1e3&&e<=9e3&&(this._typingIndicatorThrottle=e)}},{key:"websocketResponseTimeout",get:function(){return this._websocketResponseTimeout},set:function(e){L("number",e)&&e>=5e3&&e<=3e4&&(this._websocketResponseTimeout=e)}},{key:"sessionTokenRefreshTimeout",get:function(){return this._sessionTokenRefreshTimeout},set:function(e){L("number",e)&&(e<60?e=60:e>1800&&(e=1800),this._sessionTokenRefreshTimeout=e)}}]),e}(),j={encrypt:function(e){return e},decrypt:function(e){return e}},z=function(){function e(t){var n=t.store;r(this,e),this._preference=new Map,this._store=n}return s(e,[{key:"_savePreferenceKeys",value:function(){return b(this,void 0,void 0,t().mark((function e(){return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this._store.set({key:this._keysAddress,value:_(this._preference.keys()),generation:1});case 2:case"end":return e.stop()}}),e,this)})))}},{key:"init",value:function(e){var n,r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:1;return b(this,void 0,void 0,t().mark((function a(){var s,i,o,u,c,l,h;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return this._version=r,this._keysAddress=e,s="".concat(e,".metadata.version"),t.next=5,this._store.get(s);case 5:return i=t.sent,t.next=8,this._store.get(e);case 8:if(t.t1=n=t.sent,t.t0=null!==t.t1,!t.t0){t.next=12;break}t.t0=void 0!==n;case 12:if(!t.t0){t.next=16;break}t.t2=n,t.next=17;break;case 16:t.t2=[];case 17:if(o=t.t2,i&&!(i.version0&&void 0!==arguments[0]?arguments[0]:{},n=t.maxSize,a=void 0===n?256:n,s=t.clearOrder,i=void 0===s?N.MESSAGE_COLLECTION_ACCESSED_AT:s,o=t.customClearOrderComparator,u=void 0===o?null:o;r(this,e),this._customClearOrderComparator=null,this._clearOrderComparatorUseMessageCollectionAccessedAt=function(e,t){return e.channel.messageCollectionLastAccessedAt===t.channel.messageCollectionLastAccessedAt?e.channel.lastMessage&&!t.channel.lastMessage?1:!e.channel.lastMessage&&t.channel.lastMessage?-1:e.channel.lastMessage.createdAt-t.channel.lastMessage.createdAt:e.channel.messageCollectionLastAccessedAt>t.channel.messageCollectionLastAccessedAt?1:-1},this._maxSize=Math.max(a,64),u?(this._clearOrder=i,this._customClearOrderComparator=u):this._clearOrder=N.MESSAGE_COLLECTION_ACCESSED_AT}return s(e,[{key:"maxSize",get:function(){return this._maxSize}},{key:"clearOrder",get:function(){return this._clearOrder}},{key:"clearOrderComparator",get:function(){var e;return this._clearOrder===N.MESSAGE_COLLECTION_ACCESSED_AT?this._clearOrderComparatorUseMessageCollectionAccessedAt:null!==(e=this._customClearOrderComparator)&&void 0!==e?e:this._clearOrderComparatorUseMessageCollectionAccessedAt}}]),e}(),W=function(){function e(){r(this,e),this.sessionKey=null,this.authToken=null}return s(e,[{key:"hasSession",get:function(){return!!this.sessionKey}},{key:"clear",value:function(){this.authToken=null,this.sessionKey=null}}]),e}(),Y=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)}))},Z=function(){function e(t){var n=t.container;r(this,e),this._container={},this._container=n,this.key=Y()}return s(e,[{key:"_register",value:function(e,t,n){return e in this._container||(this._container[e]=new Map),this._container[e].set(this.key,{occurence:t,handler:n}),this}},{key:"on",value:function(e,t){return this._register(e,-1,t)}},{key:"once",value:function(e,t){return this._register(e,1,t)}},{key:"close",value:function(){for(var e in this._container)this._container[e].delete(this.key)}}]),e}(),J=function(){function e(){r(this,e),this._container={}}return s(e,[{key:"on",value:function(e,t){return new Z({container:this._container}).on(e,t)}},{key:"once",value:function(e,t){return new Z({container:this._container}).once(e,t)}},{key:"dispatch",value:function(e,t){var n=this._container[e];if(n){var r,a=[],s=y(n.keys());try{for(s.s();!(r=s.n()).done;){var i=r.value,o=n.get(i);o.handler(t),o.occurence>0&&(o.occurence--,0===o.occurence&&a.push(i))}}catch(e){s.e(e)}finally{s.f()}a.forEach((function(e){return n.delete(e)}))}}}]),e}(),X=function(){function e(){r(this,e),this._dispatcher=new J}return s(e,[{key:"on",value:function(e){return this._dispatcher.on("event",e)}},{key:"once",value:function(e){return this._dispatcher.once("event",e)}},{key:"dispatch",value:function(e){this._dispatcher.dispatch("event",e)}}]),e}(),$=s((function e(){r(this,e)})),ee=function(e){var t={};return e&&Object.keys(e).forEach((function(n){void 0===e[n]||Number.isNaN(e[n])||null===e[n]||(t[n]=e[n])})),t};!function(e){e.GET="GET",e.POST="POST",e.PUT="PUT",e.DELETE="DELETE"}(B||(B={}));var te,ne=function(e){i(a,e);var t=f(a);function a(){var e;return r(this,a),(e=t.apply(this,arguments)).params={},e.requireAuth=!0,e.headers={},e.requestId=Y(),e}return s(a,[{key:"stringifyParams",value:function(e){return"object"!==n(e)||Array.isArray(e)?String(e):e?JSON.stringify(e):""}},{key:"encodeParams",value:function(e){var t=this;return null==e||""===e?encodeURIComponent(""):Array.isArray(e)?e.map((function(e){return t.encodeParams(e)})).join(","):"object"===n(e)?encodeURIComponent(JSON.stringify(e)):encodeURIComponent(String(e))}},{key:"query",get:function(){var e=this,t=ee(this.params);return"?".concat(Object.keys(t).map((function(n){return"".concat(encodeURIComponent(n),"=").concat(e.encodeParams(t[n]))})).join("&"))}},{key:"payload",get:function(){var e=this,t=ee(this.params);if(Object.keys(t).some((function(e){return H(t[e])}))){var n=new FormData;return Object.keys(t).forEach((function(r){var a,s=t[r];if(H(s)){var i=s;n.append(r,i,null!==(a=i.name)&&void 0!==a?a:"filename")}else n.append(r,e.stringifyParams(s))})),n}return JSON.stringify(t)}}]),a}($),re=function(e){i(n,e);var t=f(n);function n(e,a){var s;return r(this,n),(s=t.call(this))._iid=e,s._payload=a,s}return s(n,[{key:"payload",get:function(){return Object.assign({},this._payload)}},{key:"as",value:function(e){return new e(this._iid,this.payload)}}]),n}($),ae=function(e){i(n,e);var t=f(n);function n(e){var a;return r(this,n),(a=t.call(this)).requestId=e,a}return s(n)}($),se=function(e){i(n,e);var t=f(n);function n(){return r(this,n),t.apply(this,arguments)}return s(n)}($),ie=function(e){i(n,e);var t=f(n);function n(e){var a;return r(this,n),(a=t.call(this)).statLog=e,a}return s(n)}($);!function(e){e.FEATURE_LOCALCACHE="feature:local_cache",e.WEBSOCKET_CONNECT="ws:connect",e.API_RESULT="api:result"}(te||(te={}));var oe=function(){function e(t){var n=t.type,a=t.data,s=t.ts,i=void 0===s?Date.now():s;r(this,e),this.type=n,this.createdAt=i,this.data=a}return s(e,null,[{key:"payloadify",value:function(e){return ee({stat_type:e.type,ts:e.createdAt,data:ee(e.data)})}}]),e}(),ue=function(){return"undefined"==typeof document&&"undefined"!=typeof navigator&&"ReactNative"==navigator.product},ce=function(){function e(t,n){var a=this,s=n.auth,i=n.sdkState,o=n.dispatcher,u=n.logger,c=n.useFetchCompat,l=void 0!==c&&c;r(this,e),this._abortControl=new Map,this._shouldImportFetchCompat=!1,this._iid=t,this._auth=s,this._sdkState=i,this._dispatcher=o,this._dispatcher.on((function(e){e instanceof ae&&a.cancel(e.requestId)})),this._logger=u,this._shouldImportFetchCompat=l}return s(e,[{key:"_userAgentWithExtension",get:function(){var e=this._sdkState.extensions,t=ue()?"reactnative":"JS",n=e.sb_syncmanager?"s".concat(e.sb_syncmanager):"",r=e.sb_uikit?"u".concat(e.sb_uikit):"",a=e["device-os-platform"]?"o".concat(e["device-os-platform"]):"";return"".concat(t,"/c").concat(C.SDK_VERSION,"/").concat(n,"/").concat(r,"/").concat(a)}},{key:"_createHeader",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null,n=this._sdkState,r=n.appId,a=n.appVersion,s=Object.assign(Object.assign({},e.headers),{SendBird:"JS,".concat(C.OS_VERSION,",").concat(C.SDK_VERSION,",").concat(r).concat(a?",".concat(a):""),"SB-User-Agent":encodeURIComponent(this._userAgentWithExtension),"Request-Sent-Timestamp":Date.now().toString()});return t||(s["Content-Type"]="application/json; charset=utf-8"),e.requireAuth&&this._auth.hasSession&&(s["Session-Key"]=this._auth.sessionKey),this._auth&&this._auth.authToken&&(s["App-Id"]=r,s["Access-Token"]=this._auth.authToken),s}},{key:"_statLogApiResult",value:function(e,t,n){this._dispatcher.dispatch(new ie(new oe({type:te.API_RESULT,data:{endpoint:e.path,method:e.method,success:!n,latency:Date.now()-t,error_code:null==n?void 0:n.code,error_description:null==n?void 0:n.message}})))}},{key:"send",value:function(e){return b(this,void 0,void 0,t().mark((function n(){var r,a,s,i,o,u,c,l,h,d,f,p,v,_,m;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(r=e.path,a=e.method,s=![B.GET,B.DELETE].includes(a),i=this._sdkState.api,o="".concat(i.host).concat(r).concat(s?"":e.query),u=s?e.payload:null,c=this._createHeader(e,u instanceof FormData?u:null),l=new AbortController,h=l.signal,this._abortControl.set(e.requestId,l),d=Date.now(),t.prev=10,this._shouldImportFetchCompat&&(this._shouldImportFetchCompat=!1,("undefined"!=typeof globalThis&&globalThis||"undefined"!=typeof self&&self||"undefined"!=typeof global&&global||{fetch:null}).fetch=void 0),"undefined"!=typeof AbortController){t.next=15;break}return t.next=15,Promise.resolve().then((function(){return Cv}));case 15:if("function"==typeof fetch){t.next=18;break}return t.next=18,Promise.resolve().then((function(){return Bv}));case 18:return t.next=20,fetch(o,{method:a,body:u,headers:c,signal:h});case 20:return f=t.sent,t.next=23,f.json();case 23:if(p=t.sent,!f.ok&&!f.redirected){t.next=30;break}return this._logger.debug("receive api response",e.requestId),this._statLogApiResult(e,d,null),t.abrupt("return",new re(this._iid,p));case 30:if(!p){t.next=37;break}throw v=new M(p),!e.requireAuth&&v.isSessionKeyExpiredError&&this._dispatcher.dispatch(new se),this._statLogApiResult(e,d,v),v;case 37:throw _=M.requestFailed,this._statLogApiResult(e,d,_),_;case 40:t.next=57;break;case 42:if(t.prev=42,t.t0=t.catch(10),this._statLogApiResult(e,d,t.t0),!(t.t0 instanceof M)){t.next=50;break}throw this._logger.debug("fail api request",t.t0),t.t0;case 50:if("AbortError"!==t.t0.name){t.next=54;break}throw M.requestCanceled;case 54:throw m=M.networkError,this._logger.debug("fail api request",m),m;case 57:case"end":return t.stop()}}),n,this,[[10,42]])})))}},{key:"cancel",value:function(e){this._abortControl.has(e)&&(this._abortControl.get(e).abort(),this._abortControl.delete(e))}},{key:"cancelAll",value:function(){var e,t=y(this._abortControl.values());try{for(t.s();!(e=t.n()).done;){e.value.abort()}}catch(e){t.e(e)}finally{t.f()}this._abortControl.clear()}}]),e}(),le=function(e){i(n,e);var t=f(n);function n(e,a,s){var i,o=arguments.length>3&&void 0!==arguments[3]?arguments[3]:"";return r(this,n),(i=t.call(this))._iid=e,i.code=a,i.payload=s,i.requestId=s?s.req_id:o,i}return s(n,[{key:"convertToMessage",value:function(){return"".concat(this.code).concat(JSON.stringify(this.payload),"\n")}},{key:"as",value:function(e){return new e(this._iid,this.code,this.payload)}}],[{key:"createFromRawMessage",value:function(e,t){var r=t.substring(0,4),a=null;try{a=JSON.parse(t.substring(4))}catch(e){r="NOOP"}finally{return new n(e,r,a)}}}]),n}($),he=function(){};function de(e){let t=e.length;for(;--t>=0;)e[t]=0}const fe=256,pe=286,ve=30,_e=15,me=new Uint8Array([0,0,0,0,0,0,0,0,1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4,5,5,5,5,0]),ge=new Uint8Array([0,0,0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9,9,10,10,11,11,12,12,13,13]),ye=new Uint8Array([0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,3,7]),ke=new Uint8Array([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),be=new Array(576);de(be);const Ee=new Array(60);de(Ee);const we=new Array(512);de(we);const Ce=new Array(256);de(Ce);const xe=new Array(29);de(xe);const Te=new Array(ve);function Se(e,t,n,r,a){this.static_tree=e,this.extra_bits=t,this.extra_base=n,this.elems=r,this.max_length=a,this.has_stree=e&&e.length}let Ie,Ne,Ae;function Me(e,t){this.dyn_tree=e,this.max_code=0,this.stat_desc=t}de(Te);const Oe=e=>e<256?we[e]:we[256+(e>>>7)],Ue=(e,t)=>{e.pending_buf[e.pending++]=255&t,e.pending_buf[e.pending++]=t>>>8&255},Re=(e,t,n)=>{e.bi_valid>16-n?(e.bi_buf|=t<>16-e.bi_valid,e.bi_valid+=n-16):(e.bi_buf|=t<{Re(e,n[2*t],n[2*t+1])},De=(e,t)=>{let n=0;do{n|=1&e,e>>>=1,n<<=1}while(--t>0);return n>>>1},Pe=(e,t,n)=>{const r=new Array(16);let a,s,i=0;for(a=1;a<=_e;a++)i=i+n[a-1]<<1,r[a]=i;for(s=0;s<=t;s++){let t=e[2*s+1];0!==t&&(e[2*s]=De(r[t]++,t))}},Fe=e=>{let t;for(t=0;t{e.bi_valid>8?Ue(e,e.bi_buf):e.bi_valid>0&&(e.pending_buf[e.pending++]=e.bi_buf),e.bi_buf=0,e.bi_valid=0},He=(e,t,n,r)=>{const a=2*t,s=2*n;return e[a]{const r=e.heap[n];let a=n<<1;for(;a<=e.heap_len&&(a{let r,a,s,i,o=0;if(0!==e.sym_next)do{r=255&e.pending_buf[e.sym_buf+o++],r+=(255&e.pending_buf[e.sym_buf+o++])<<8,a=e.pending_buf[e.sym_buf+o++],0===r?Le(e,a,t):(s=Ce[a],Le(e,s+fe+1,t),i=me[s],0!==i&&(a-=xe[s],Re(e,a,i)),r--,s=Oe(r),Le(e,s,n),i=ge[s],0!==i&&(r-=Te[s],Re(e,r,i)))}while(o{const n=t.dyn_tree,r=t.stat_desc.static_tree,a=t.stat_desc.has_stree,s=t.stat_desc.elems;let i,o,u,c=-1;for(e.heap_len=0,e.heap_max=573,i=0;i>1;i>=1;i--)qe(e,n,i);u=s;do{i=e.heap[1],e.heap[1]=e.heap[e.heap_len--],qe(e,n,1),o=e.heap[1],e.heap[--e.heap_max]=i,e.heap[--e.heap_max]=o,n[2*u]=n[2*i]+n[2*o],e.depth[u]=(e.depth[i]>=e.depth[o]?e.depth[i]:e.depth[o])+1,n[2*i+1]=n[2*o+1]=u,e.heap[1]=u++,qe(e,n,1)}while(e.heap_len>=2);e.heap[--e.heap_max]=e.heap[1],((e,t)=>{const n=t.dyn_tree,r=t.max_code,a=t.stat_desc.static_tree,s=t.stat_desc.has_stree,i=t.stat_desc.extra_bits,o=t.stat_desc.extra_base,u=t.stat_desc.max_length;let c,l,h,d,f,p,v=0;for(d=0;d<=_e;d++)e.bl_count[d]=0;for(n[2*e.heap[e.heap_max]+1]=0,c=e.heap_max+1;c<573;c++)l=e.heap[c],d=n[2*n[2*l+1]+1]+1,d>u&&(d=u,v++),n[2*l+1]=d,l>r||(e.bl_count[d]++,f=0,l>=o&&(f=i[l-o]),p=n[2*l],e.opt_len+=p*(d+f),s&&(e.static_len+=p*(a[2*l+1]+f)));if(0!==v){do{for(d=u-1;0===e.bl_count[d];)d--;e.bl_count[d]--,e.bl_count[d+1]+=2,e.bl_count[u]--,v-=2}while(v>0);for(d=u;0!==d;d--)for(l=e.bl_count[d];0!==l;)h=e.heap[--c],h>r||(n[2*h+1]!==d&&(e.opt_len+=(d-n[2*h+1])*n[2*h],n[2*h+1]=d),l--)}})(e,t),Pe(n,c,e.bl_count)},Ve=(e,t,n)=>{let r,a,s=-1,i=t[1],o=0,u=7,c=4;for(0===i&&(u=138,c=3),t[2*(n+1)+1]=65535,r=0;r<=n;r++)a=i,i=t[2*(r+1)+1],++o{let r,a,s=-1,i=t[1],o=0,u=7,c=4;for(0===i&&(u=138,c=3),r=0;r<=n;r++)if(a=i,i=t[2*(r+1)+1],!(++o{Re(e,0+(r?1:0),3),Ge(e),Ue(e,n),Ue(e,~n),n&&e.pending_buf.set(e.window.subarray(t,t+n),e.pending),e.pending+=n};var We=(e,t,n,r)=>{let a,s,i=0;e.level>0?(2===e.strm.data_type&&(e.strm.data_type=(e=>{let t,n=4093624447;for(t=0;t<=31;t++,n>>>=1)if(1&n&&0!==e.dyn_ltree[2*t])return 0;if(0!==e.dyn_ltree[18]||0!==e.dyn_ltree[20]||0!==e.dyn_ltree[26])return 1;for(t=32;t{let t;for(Ve(e,e.dyn_ltree,e.l_desc.max_code),Ve(e,e.dyn_dtree,e.d_desc.max_code),ze(e,e.bl_desc),t=18;t>=3&&0===e.bl_tree[2*ke[t]+1];t--);return e.opt_len+=3*(t+1)+5+5+4,t})(e),a=e.opt_len+3+7>>>3,s=e.static_len+3+7>>>3,s<=a&&(a=s)):a=s=n+5,n+4<=a&&-1!==t?Ke(e,t,n,r):4===e.strategy||s===a?(Re(e,2+(r?1:0),3),je(e,be,Ee)):(Re(e,4+(r?1:0),3),((e,t,n,r)=>{let a;for(Re(e,t-257,5),Re(e,n-1,5),Re(e,r-4,4),a=0;a{Qe||((()=>{let e,t,n,r,a;const s=new Array(16);for(n=0,r=0;r<28;r++)for(xe[r]=n,e=0;e<1<>=7;r(e.pending_buf[e.sym_buf+e.sym_next++]=t,e.pending_buf[e.sym_buf+e.sym_next++]=t>>8,e.pending_buf[e.sym_buf+e.sym_next++]=n,0===t?e.dyn_ltree[2*n]++:(e.matches++,t--,e.dyn_ltree[2*(Ce[n]+fe+1)]++,e.dyn_dtree[2*Oe(t)]++),e.sym_next===e.sym_end),_tr_align:e=>{Re(e,2,3),Le(e,256,be),(e=>{16===e.bi_valid?(Ue(e,e.bi_buf),e.bi_buf=0,e.bi_valid=0):e.bi_valid>=8&&(e.pending_buf[e.pending++]=255&e.bi_buf,e.bi_buf>>=8,e.bi_valid-=8)})(e)}};var Ze=(e,t,n,r)=>{let a=65535&e|0,s=e>>>16&65535|0,i=0;for(;0!==n;){i=n>2e3?2e3:n,n-=i;do{a=a+t[r++]|0,s=s+a|0}while(--i);a%=65521,s%=65521}return a|s<<16|0};const Je=new Uint32Array((()=>{let e,t=[];for(var n=0;n<256;n++){e=n;for(var r=0;r<8;r++)e=1&e?3988292384^e>>>1:e>>>1;t[n]=e}return t})());var Xe=(e,t,n,r)=>{const a=Je,s=r+n;e^=-1;for(let n=r;n>>8^a[255&(e^t[n])];return-1^e},$e={2:"need dictionary",1:"stream end",0:"","-1":"file error","-2":"stream error","-3":"data error","-4":"insufficient memory","-5":"buffer error","-6":"incompatible version"},et={Z_NO_FLUSH:0,Z_PARTIAL_FLUSH:1,Z_SYNC_FLUSH:2,Z_FULL_FLUSH:3,Z_FINISH:4,Z_BLOCK:5,Z_TREES:6,Z_OK:0,Z_STREAM_END:1,Z_NEED_DICT:2,Z_ERRNO:-1,Z_STREAM_ERROR:-2,Z_DATA_ERROR:-3,Z_MEM_ERROR:-4,Z_BUF_ERROR:-5,Z_NO_COMPRESSION:0,Z_BEST_SPEED:1,Z_BEST_COMPRESSION:9,Z_DEFAULT_COMPRESSION:-1,Z_FILTERED:1,Z_HUFFMAN_ONLY:2,Z_RLE:3,Z_FIXED:4,Z_DEFAULT_STRATEGY:0,Z_BINARY:0,Z_TEXT:1,Z_UNKNOWN:2,Z_DEFLATED:8};const{_tr_init:tt,_tr_stored_block:nt,_tr_flush_block:rt,_tr_tally:at,_tr_align:st}=Ye,{Z_NO_FLUSH:it,Z_PARTIAL_FLUSH:ot,Z_FULL_FLUSH:ut,Z_FINISH:ct,Z_BLOCK:lt,Z_OK:ht,Z_STREAM_END:dt,Z_STREAM_ERROR:ft,Z_DATA_ERROR:pt,Z_BUF_ERROR:vt,Z_DEFAULT_COMPRESSION:_t,Z_FILTERED:mt,Z_HUFFMAN_ONLY:gt,Z_RLE:yt,Z_FIXED:kt,Z_DEFAULT_STRATEGY:bt,Z_UNKNOWN:Et,Z_DEFLATED:wt}=et,Ct=258,xt=262,Tt=42,St=113,It=666,Nt=(e,t)=>(e.msg=$e[t],t),At=e=>2*e-(e>4?9:0),Mt=e=>{let t=e.length;for(;--t>=0;)e[t]=0},Ot=e=>{let t,n,r,a=e.w_size;t=e.hash_size,r=t;do{n=e.head[--r],e.head[r]=n>=a?n-a:0}while(--t);t=a,r=t;do{n=e.prev[--r],e.prev[r]=n>=a?n-a:0}while(--t)};let Ut=(e,t,n)=>(t<{const t=e.state;let n=t.pending;n>e.avail_out&&(n=e.avail_out),0!==n&&(e.output.set(t.pending_buf.subarray(t.pending_out,t.pending_out+n),e.next_out),e.next_out+=n,t.pending_out+=n,e.total_out+=n,e.avail_out-=n,t.pending-=n,0===t.pending&&(t.pending_out=0))},Lt=(e,t)=>{rt(e,e.block_start>=0?e.block_start:-1,e.strstart-e.block_start,t),e.block_start=e.strstart,Rt(e.strm)},Dt=(e,t)=>{e.pending_buf[e.pending++]=t},Pt=(e,t)=>{e.pending_buf[e.pending++]=t>>>8&255,e.pending_buf[e.pending++]=255&t},Ft=(e,t,n,r)=>{let a=e.avail_in;return a>r&&(a=r),0===a?0:(e.avail_in-=a,t.set(e.input.subarray(e.next_in,e.next_in+a),n),1===e.state.wrap?e.adler=Ze(e.adler,t,a,n):2===e.state.wrap&&(e.adler=Xe(e.adler,t,a,n)),e.next_in+=a,e.total_in+=a,a)},Gt=(e,t)=>{let n,r,a=e.max_chain_length,s=e.strstart,i=e.prev_length,o=e.nice_match;const u=e.strstart>e.w_size-xt?e.strstart-(e.w_size-xt):0,c=e.window,l=e.w_mask,h=e.prev,d=e.strstart+Ct;let f=c[s+i-1],p=c[s+i];e.prev_length>=e.good_match&&(a>>=2),o>e.lookahead&&(o=e.lookahead);do{if(n=t,c[n+i]===p&&c[n+i-1]===f&&c[n]===c[s]&&c[++n]===c[s+1]){s+=2,n++;do{}while(c[++s]===c[++n]&&c[++s]===c[++n]&&c[++s]===c[++n]&&c[++s]===c[++n]&&c[++s]===c[++n]&&c[++s]===c[++n]&&c[++s]===c[++n]&&c[++s]===c[++n]&&si){if(e.match_start=t,i=r,r>=o)break;f=c[s+i-1],p=c[s+i]}}}while((t=h[t&l])>u&&0!=--a);return i<=e.lookahead?i:e.lookahead},Ht=e=>{const t=e.w_size;let n,r,a;do{if(r=e.window_size-e.lookahead-e.strstart,e.strstart>=t+(t-xt)&&(e.window.set(e.window.subarray(t,t+t-r),0),e.match_start-=t,e.strstart-=t,e.block_start-=t,e.insert>e.strstart&&(e.insert=e.strstart),Ot(e),r+=t),0===e.strm.avail_in)break;if(n=Ft(e.strm,e.window,e.strstart+e.lookahead,r),e.lookahead+=n,e.lookahead+e.insert>=3)for(a=e.strstart-e.insert,e.ins_h=e.window[a],e.ins_h=Ut(e,e.ins_h,e.window[a+1]);e.insert&&(e.ins_h=Ut(e,e.ins_h,e.window[a+3-1]),e.prev[a&e.w_mask]=e.head[e.ins_h],e.head[e.ins_h]=a,a++,e.insert--,!(e.lookahead+e.insert<3)););}while(e.lookahead{let n,r,a,s=e.pending_buf_size-5>e.w_size?e.w_size:e.pending_buf_size-5,i=0,o=e.strm.avail_in;do{if(n=65535,a=e.bi_valid+42>>3,e.strm.avail_outr+e.strm.avail_in&&(n=r+e.strm.avail_in),n>a&&(n=a),n>8,e.pending_buf[e.pending-2]=~n,e.pending_buf[e.pending-1]=~n>>8,Rt(e.strm),r&&(r>n&&(r=n),e.strm.output.set(e.window.subarray(e.block_start,e.block_start+r),e.strm.next_out),e.strm.next_out+=r,e.strm.avail_out-=r,e.strm.total_out+=r,e.block_start+=r,n-=r),n&&(Ft(e.strm,e.strm.output,e.strm.next_out,n),e.strm.next_out+=n,e.strm.avail_out-=n,e.strm.total_out+=n)}while(0===i);return o-=e.strm.avail_in,o&&(o>=e.w_size?(e.matches=2,e.window.set(e.strm.input.subarray(e.strm.next_in-e.w_size,e.strm.next_in),0),e.strstart=e.w_size,e.insert=e.strstart):(e.window_size-e.strstart<=o&&(e.strstart-=e.w_size,e.window.set(e.window.subarray(e.w_size,e.w_size+e.strstart),0),e.matches<2&&e.matches++,e.insert>e.strstart&&(e.insert=e.strstart)),e.window.set(e.strm.input.subarray(e.strm.next_in-o,e.strm.next_in),e.strstart),e.strstart+=o,e.insert+=o>e.w_size-e.insert?e.w_size-e.insert:o),e.block_start=e.strstart),e.high_watera&&e.block_start>=e.w_size&&(e.block_start-=e.w_size,e.strstart-=e.w_size,e.window.set(e.window.subarray(e.w_size,e.w_size+e.strstart),0),e.matches<2&&e.matches++,a+=e.w_size,e.insert>e.strstart&&(e.insert=e.strstart)),a>e.strm.avail_in&&(a=e.strm.avail_in),a&&(Ft(e.strm,e.window,e.strstart,a),e.strstart+=a,e.insert+=a>e.w_size-e.insert?e.w_size-e.insert:a),e.high_water>3,a=e.pending_buf_size-a>65535?65535:e.pending_buf_size-a,s=a>e.w_size?e.w_size:a,r=e.strstart-e.block_start,(r>=s||(r||t===ct)&&t!==it&&0===e.strm.avail_in&&r<=a)&&(n=r>a?a:r,i=t===ct&&0===e.strm.avail_in&&n===r?1:0,nt(e,e.block_start,n,i),e.block_start+=n,Rt(e.strm)),i?3:1)},jt=(e,t)=>{let n,r;for(;;){if(e.lookahead=3&&(e.ins_h=Ut(e,e.ins_h,e.window[e.strstart+3-1]),n=e.prev[e.strstart&e.w_mask]=e.head[e.ins_h],e.head[e.ins_h]=e.strstart),0!==n&&e.strstart-n<=e.w_size-xt&&(e.match_length=Gt(e,n)),e.match_length>=3)if(r=at(e,e.strstart-e.match_start,e.match_length-3),e.lookahead-=e.match_length,e.match_length<=e.max_lazy_match&&e.lookahead>=3){e.match_length--;do{e.strstart++,e.ins_h=Ut(e,e.ins_h,e.window[e.strstart+3-1]),n=e.prev[e.strstart&e.w_mask]=e.head[e.ins_h],e.head[e.ins_h]=e.strstart}while(0!=--e.match_length);e.strstart++}else e.strstart+=e.match_length,e.match_length=0,e.ins_h=e.window[e.strstart],e.ins_h=Ut(e,e.ins_h,e.window[e.strstart+1]);else r=at(e,0,e.window[e.strstart]),e.lookahead--,e.strstart++;if(r&&(Lt(e,!1),0===e.strm.avail_out))return 1}return e.insert=e.strstart<2?e.strstart:2,t===ct?(Lt(e,!0),0===e.strm.avail_out?3:4):e.sym_next&&(Lt(e,!1),0===e.strm.avail_out)?1:2},zt=(e,t)=>{let n,r,a;for(;;){if(e.lookahead=3&&(e.ins_h=Ut(e,e.ins_h,e.window[e.strstart+3-1]),n=e.prev[e.strstart&e.w_mask]=e.head[e.ins_h],e.head[e.ins_h]=e.strstart),e.prev_length=e.match_length,e.prev_match=e.match_start,e.match_length=2,0!==n&&e.prev_length4096)&&(e.match_length=2)),e.prev_length>=3&&e.match_length<=e.prev_length){a=e.strstart+e.lookahead-3,r=at(e,e.strstart-1-e.prev_match,e.prev_length-3),e.lookahead-=e.prev_length-1,e.prev_length-=2;do{++e.strstart<=a&&(e.ins_h=Ut(e,e.ins_h,e.window[e.strstart+3-1]),n=e.prev[e.strstart&e.w_mask]=e.head[e.ins_h],e.head[e.ins_h]=e.strstart)}while(0!=--e.prev_length);if(e.match_available=0,e.match_length=2,e.strstart++,r&&(Lt(e,!1),0===e.strm.avail_out))return 1}else if(e.match_available){if(r=at(e,0,e.window[e.strstart-1]),r&&Lt(e,!1),e.strstart++,e.lookahead--,0===e.strm.avail_out)return 1}else e.match_available=1,e.strstart++,e.lookahead--}return e.match_available&&(r=at(e,0,e.window[e.strstart-1]),e.match_available=0),e.insert=e.strstart<2?e.strstart:2,t===ct?(Lt(e,!0),0===e.strm.avail_out?3:4):e.sym_next&&(Lt(e,!1),0===e.strm.avail_out)?1:2};function Vt(e,t,n,r,a){this.good_length=e,this.max_lazy=t,this.nice_length=n,this.max_chain=r,this.func=a}const Bt=[new Vt(0,0,0,0,qt),new Vt(4,4,8,4,jt),new Vt(4,5,16,8,jt),new Vt(4,6,32,32,jt),new Vt(4,4,16,16,zt),new Vt(8,16,32,32,zt),new Vt(8,16,128,128,zt),new Vt(8,32,128,256,zt),new Vt(32,128,258,1024,zt),new Vt(32,258,258,4096,zt)];function Qt(){this.strm=null,this.status=0,this.pending_buf=null,this.pending_buf_size=0,this.pending_out=0,this.pending=0,this.wrap=0,this.gzhead=null,this.gzindex=0,this.method=wt,this.last_flush=-1,this.w_size=0,this.w_bits=0,this.w_mask=0,this.window=null,this.window_size=0,this.prev=null,this.head=null,this.ins_h=0,this.hash_size=0,this.hash_bits=0,this.hash_mask=0,this.hash_shift=0,this.block_start=0,this.match_length=0,this.prev_match=0,this.match_available=0,this.strstart=0,this.match_start=0,this.lookahead=0,this.prev_length=0,this.max_chain_length=0,this.max_lazy_match=0,this.level=0,this.strategy=0,this.good_match=0,this.nice_match=0,this.dyn_ltree=new Uint16Array(1146),this.dyn_dtree=new Uint16Array(122),this.bl_tree=new Uint16Array(78),Mt(this.dyn_ltree),Mt(this.dyn_dtree),Mt(this.bl_tree),this.l_desc=null,this.d_desc=null,this.bl_desc=null,this.bl_count=new Uint16Array(16),this.heap=new Uint16Array(573),Mt(this.heap),this.heap_len=0,this.heap_max=0,this.depth=new Uint16Array(573),Mt(this.depth),this.sym_buf=0,this.lit_bufsize=0,this.sym_next=0,this.sym_end=0,this.opt_len=0,this.static_len=0,this.matches=0,this.insert=0,this.bi_buf=0,this.bi_valid=0}const Kt=e=>{if(!e)return 1;const t=e.state;return!t||t.strm!==e||t.status!==Tt&&57!==t.status&&69!==t.status&&73!==t.status&&91!==t.status&&103!==t.status&&t.status!==St&&t.status!==It?1:0},Wt=e=>{if(Kt(e))return Nt(e,ft);e.total_in=e.total_out=0,e.data_type=Et;const t=e.state;return t.pending=0,t.pending_out=0,t.wrap<0&&(t.wrap=-t.wrap),t.status=2===t.wrap?57:t.wrap?Tt:St,e.adler=2===t.wrap?0:1,t.last_flush=-2,tt(t),ht},Yt=e=>{const t=Wt(e);var n;return t===ht&&((n=e.state).window_size=2*n.w_size,Mt(n.head),n.max_lazy_match=Bt[n.level].max_lazy,n.good_match=Bt[n.level].good_length,n.nice_match=Bt[n.level].nice_length,n.max_chain_length=Bt[n.level].max_chain,n.strstart=0,n.block_start=0,n.lookahead=0,n.insert=0,n.match_length=n.prev_length=2,n.match_available=0,n.ins_h=0),t},Zt=(e,t,n,r,a,s)=>{if(!e)return ft;let i=1;if(t===_t&&(t=6),r<0?(i=0,r=-r):r>15&&(i=2,r-=16),a<1||a>9||n!==wt||r<8||r>15||t<0||t>9||s<0||s>kt||8===r&&1!==i)return Nt(e,ft);8===r&&(r=9);const o=new Qt;return e.state=o,o.strm=e,o.status=Tt,o.wrap=i,o.gzhead=null,o.w_bits=r,o.w_size=1<Zt(e,t,wt,15,8,bt),deflateInit2:Zt,deflateReset:Yt,deflateResetKeep:Wt,deflateSetHeader:(e,t)=>Kt(e)||2!==e.state.wrap?ft:(e.state.gzhead=t,ht),deflate:(e,t)=>{if(Kt(e)||t>lt||t<0)return e?Nt(e,ft):ft;const n=e.state;if(!e.output||0!==e.avail_in&&!e.input||n.status===It&&t!==ct)return Nt(e,0===e.avail_out?vt:ft);const r=n.last_flush;if(n.last_flush=t,0!==n.pending){if(Rt(e),0===e.avail_out)return n.last_flush=-1,ht}else if(0===e.avail_in&&At(t)<=At(r)&&t!==ct)return Nt(e,vt);if(n.status===It&&0!==e.avail_in)return Nt(e,vt);if(n.status===Tt&&0===n.wrap&&(n.status=St),n.status===Tt){let t=wt+(n.w_bits-8<<4)<<8,r=-1;if(r=n.strategy>=gt||n.level<2?0:n.level<6?1:6===n.level?2:3,t|=r<<6,0!==n.strstart&&(t|=32),t+=31-t%31,Pt(n,t),0!==n.strstart&&(Pt(n,e.adler>>>16),Pt(n,65535&e.adler)),e.adler=1,n.status=St,Rt(e),0!==n.pending)return n.last_flush=-1,ht}if(57===n.status)if(e.adler=0,Dt(n,31),Dt(n,139),Dt(n,8),n.gzhead)Dt(n,(n.gzhead.text?1:0)+(n.gzhead.hcrc?2:0)+(n.gzhead.extra?4:0)+(n.gzhead.name?8:0)+(n.gzhead.comment?16:0)),Dt(n,255&n.gzhead.time),Dt(n,n.gzhead.time>>8&255),Dt(n,n.gzhead.time>>16&255),Dt(n,n.gzhead.time>>24&255),Dt(n,9===n.level?2:n.strategy>=gt||n.level<2?4:0),Dt(n,255&n.gzhead.os),n.gzhead.extra&&n.gzhead.extra.length&&(Dt(n,255&n.gzhead.extra.length),Dt(n,n.gzhead.extra.length>>8&255)),n.gzhead.hcrc&&(e.adler=Xe(e.adler,n.pending_buf,n.pending,0)),n.gzindex=0,n.status=69;else if(Dt(n,0),Dt(n,0),Dt(n,0),Dt(n,0),Dt(n,0),Dt(n,9===n.level?2:n.strategy>=gt||n.level<2?4:0),Dt(n,3),n.status=St,Rt(e),0!==n.pending)return n.last_flush=-1,ht;if(69===n.status){if(n.gzhead.extra){let t=n.pending,r=(65535&n.gzhead.extra.length)-n.gzindex;for(;n.pending+r>n.pending_buf_size;){let a=n.pending_buf_size-n.pending;if(n.pending_buf.set(n.gzhead.extra.subarray(n.gzindex,n.gzindex+a),n.pending),n.pending=n.pending_buf_size,n.gzhead.hcrc&&n.pending>t&&(e.adler=Xe(e.adler,n.pending_buf,n.pending-t,t)),n.gzindex+=a,Rt(e),0!==n.pending)return n.last_flush=-1,ht;t=0,r-=a}let a=new Uint8Array(n.gzhead.extra);n.pending_buf.set(a.subarray(n.gzindex,n.gzindex+r),n.pending),n.pending+=r,n.gzhead.hcrc&&n.pending>t&&(e.adler=Xe(e.adler,n.pending_buf,n.pending-t,t)),n.gzindex=0}n.status=73}if(73===n.status){if(n.gzhead.name){let t,r=n.pending;do{if(n.pending===n.pending_buf_size){if(n.gzhead.hcrc&&n.pending>r&&(e.adler=Xe(e.adler,n.pending_buf,n.pending-r,r)),Rt(e),0!==n.pending)return n.last_flush=-1,ht;r=0}t=n.gzindexr&&(e.adler=Xe(e.adler,n.pending_buf,n.pending-r,r)),n.gzindex=0}n.status=91}if(91===n.status){if(n.gzhead.comment){let t,r=n.pending;do{if(n.pending===n.pending_buf_size){if(n.gzhead.hcrc&&n.pending>r&&(e.adler=Xe(e.adler,n.pending_buf,n.pending-r,r)),Rt(e),0!==n.pending)return n.last_flush=-1,ht;r=0}t=n.gzindexr&&(e.adler=Xe(e.adler,n.pending_buf,n.pending-r,r))}n.status=103}if(103===n.status){if(n.gzhead.hcrc){if(n.pending+2>n.pending_buf_size&&(Rt(e),0!==n.pending))return n.last_flush=-1,ht;Dt(n,255&e.adler),Dt(n,e.adler>>8&255),e.adler=0}if(n.status=St,Rt(e),0!==n.pending)return n.last_flush=-1,ht}if(0!==e.avail_in||0!==n.lookahead||t!==it&&n.status!==It){let r=0===n.level?qt(n,t):n.strategy===gt?((e,t)=>{let n;for(;;){if(0===e.lookahead&&(Ht(e),0===e.lookahead)){if(t===it)return 1;break}if(e.match_length=0,n=at(e,0,e.window[e.strstart]),e.lookahead--,e.strstart++,n&&(Lt(e,!1),0===e.strm.avail_out))return 1}return e.insert=0,t===ct?(Lt(e,!0),0===e.strm.avail_out?3:4):e.sym_next&&(Lt(e,!1),0===e.strm.avail_out)?1:2})(n,t):n.strategy===yt?((e,t)=>{let n,r,a,s;const i=e.window;for(;;){if(e.lookahead<=Ct){if(Ht(e),e.lookahead<=Ct&&t===it)return 1;if(0===e.lookahead)break}if(e.match_length=0,e.lookahead>=3&&e.strstart>0&&(a=e.strstart-1,r=i[a],r===i[++a]&&r===i[++a]&&r===i[++a])){s=e.strstart+Ct;do{}while(r===i[++a]&&r===i[++a]&&r===i[++a]&&r===i[++a]&&r===i[++a]&&r===i[++a]&&r===i[++a]&&r===i[++a]&&ae.lookahead&&(e.match_length=e.lookahead)}if(e.match_length>=3?(n=at(e,1,e.match_length-3),e.lookahead-=e.match_length,e.strstart+=e.match_length,e.match_length=0):(n=at(e,0,e.window[e.strstart]),e.lookahead--,e.strstart++),n&&(Lt(e,!1),0===e.strm.avail_out))return 1}return e.insert=0,t===ct?(Lt(e,!0),0===e.strm.avail_out?3:4):e.sym_next&&(Lt(e,!1),0===e.strm.avail_out)?1:2})(n,t):Bt[n.level].func(n,t);if(3!==r&&4!==r||(n.status=It),1===r||3===r)return 0===e.avail_out&&(n.last_flush=-1),ht;if(2===r&&(t===ot?st(n):t!==lt&&(nt(n,0,0,!1),t===ut&&(Mt(n.head),0===n.lookahead&&(n.strstart=0,n.block_start=0,n.insert=0))),Rt(e),0===e.avail_out))return n.last_flush=-1,ht}return t!==ct?ht:n.wrap<=0?dt:(2===n.wrap?(Dt(n,255&e.adler),Dt(n,e.adler>>8&255),Dt(n,e.adler>>16&255),Dt(n,e.adler>>24&255),Dt(n,255&e.total_in),Dt(n,e.total_in>>8&255),Dt(n,e.total_in>>16&255),Dt(n,e.total_in>>24&255)):(Pt(n,e.adler>>>16),Pt(n,65535&e.adler)),Rt(e),n.wrap>0&&(n.wrap=-n.wrap),0!==n.pending?ht:dt)},deflateEnd:e=>{if(Kt(e))return ft;const t=e.state.status;return e.state=null,t===St?Nt(e,pt):ht},deflateSetDictionary:(e,t)=>{let n=t.length;if(Kt(e))return ft;const r=e.state,a=r.wrap;if(2===a||1===a&&r.status!==Tt||r.lookahead)return ft;if(1===a&&(e.adler=Ze(e.adler,t,n,0)),r.wrap=0,n>=r.w_size){0===a&&(Mt(r.head),r.strstart=0,r.block_start=0,r.insert=0);let e=new Uint8Array(r.w_size);e.set(t.subarray(n-r.w_size,n),0),t=e,n=r.w_size}const s=e.avail_in,i=e.next_in,o=e.input;for(e.avail_in=n,e.next_in=0,e.input=t,Ht(r);r.lookahead>=3;){let e=r.strstart,t=r.lookahead-2;do{r.ins_h=Ut(r,r.ins_h,r.window[e+3-1]),r.prev[e&r.w_mask]=r.head[r.ins_h],r.head[r.ins_h]=e,e++}while(--t);r.strstart=e,r.lookahead=2,Ht(r)}return r.strstart+=r.lookahead,r.block_start=r.strstart,r.insert=r.lookahead,r.lookahead=0,r.match_length=r.prev_length=2,r.match_available=0,e.next_in=i,e.input=o,e.avail_in=s,r.wrap=a,ht},deflateInfo:"pako deflate (from Nodeca project)"};const Xt=(e,t)=>Object.prototype.hasOwnProperty.call(e,t);var $t={assign:function(e){const t=Array.prototype.slice.call(arguments,1);for(;t.length;){const n=t.shift();if(n){if("object"!=typeof n)throw new TypeError(n+"must be non-object");for(const t in n)Xt(n,t)&&(e[t]=n[t])}}return e},flattenChunks:e=>{let t=0;for(let n=0,r=e.length;n=252?6:e>=248?5:e>=240?4:e>=224?3:e>=192?2:1;tn[254]=tn[254]=1;var nn={string2buf:e=>{if("function"==typeof TextEncoder&&TextEncoder.prototype.encode)return(new TextEncoder).encode(e);let t,n,r,a,s,i=e.length,o=0;for(a=0;a>>6,t[s++]=128|63&n):n<65536?(t[s++]=224|n>>>12,t[s++]=128|n>>>6&63,t[s++]=128|63&n):(t[s++]=240|n>>>18,t[s++]=128|n>>>12&63,t[s++]=128|n>>>6&63,t[s++]=128|63&n);return t},buf2string:(e,t)=>{const n=t||e.length;if("function"==typeof TextDecoder&&TextDecoder.prototype.decode)return(new TextDecoder).decode(e.subarray(0,t));let r,a;const s=new Array(2*n);for(a=0,r=0;r4)s[a++]=65533,r+=i-1;else{for(t&=2===i?31:3===i?15:7;i>1&&r1?s[a++]=65533:t<65536?s[a++]=t:(t-=65536,s[a++]=55296|t>>10&1023,s[a++]=56320|1023&t)}}return((e,t)=>{if(t<65534&&e.subarray&&en)return String.fromCharCode.apply(null,e.length===t?e:e.subarray(0,t));let n="";for(let r=0;r{(t=t||e.length)>e.length&&(t=e.length);let n=t-1;for(;n>=0&&128==(192&e[n]);)n--;return n<0||0===n?t:n+tn[e[n]]>t?n:t}};var rn=function(){this.input=null,this.next_in=0,this.avail_in=0,this.total_in=0,this.output=null,this.next_out=0,this.avail_out=0,this.total_out=0,this.msg="",this.state=null,this.data_type=2,this.adler=0};const an=Object.prototype.toString,{Z_NO_FLUSH:sn,Z_SYNC_FLUSH:on,Z_FULL_FLUSH:un,Z_FINISH:cn,Z_OK:ln,Z_STREAM_END:hn,Z_DEFAULT_COMPRESSION:dn,Z_DEFAULT_STRATEGY:fn,Z_DEFLATED:pn}=et;function vn(e){this.options=$t.assign({level:dn,method:pn,chunkSize:16384,windowBits:15,memLevel:8,strategy:fn},e||{});let t=this.options;t.raw&&t.windowBits>0?t.windowBits=-t.windowBits:t.gzip&&t.windowBits>0&&t.windowBits<16&&(t.windowBits+=16),this.err=0,this.msg="",this.ended=!1,this.chunks=[],this.strm=new rn,this.strm.avail_out=0;let n=Jt.deflateInit2(this.strm,t.level,t.method,t.windowBits,t.memLevel,t.strategy);if(n!==ln)throw new Error($e[n]);if(t.header&&Jt.deflateSetHeader(this.strm,t.header),t.dictionary){let e;if(e="string"==typeof t.dictionary?nn.string2buf(t.dictionary):"[object ArrayBuffer]"===an.call(t.dictionary)?new Uint8Array(t.dictionary):t.dictionary,n=Jt.deflateSetDictionary(this.strm,e),n!==ln)throw new Error($e[n]);this._dict_set=!0}}function _n(e,t){const n=new vn(t);if(n.push(e,!0),n.err)throw n.msg||$e[n.err];return n.result}vn.prototype.push=function(e,t){const n=this.strm,r=this.options.chunkSize;let a,s;if(this.ended)return!1;for(s=t===~~t?t:!0===t?cn:sn,"string"==typeof e?n.input=nn.string2buf(e):"[object ArrayBuffer]"===an.call(e)?n.input=new Uint8Array(e):n.input=e,n.next_in=0,n.avail_in=n.input.length;;)if(0===n.avail_out&&(n.output=new Uint8Array(r),n.next_out=0,n.avail_out=r),(s===on||s===un)&&n.avail_out<=6)this.onData(n.output.subarray(0,n.next_out)),n.avail_out=0;else{if(a=Jt.deflate(n,s),a===hn)return n.next_out>0&&this.onData(n.output.subarray(0,n.next_out)),a=Jt.deflateEnd(this.strm),this.onEnd(a),this.ended=!0,a===ln;if(0!==n.avail_out){if(s>0&&n.next_out>0)this.onData(n.output.subarray(0,n.next_out)),n.avail_out=0;else if(0===n.avail_in)break}else this.onData(n.output)}return!0},vn.prototype.onData=function(e){this.chunks.push(e)},vn.prototype.onEnd=function(e){e===ln&&(this.result=$t.flattenChunks(this.chunks)),this.chunks=[],this.err=e,this.msg=this.strm.msg};var mn={Deflate:vn,deflate:_n,deflateRaw:function(e,t){return(t=t||{}).raw=!0,_n(e,t)},gzip:function(e,t){return(t=t||{}).gzip=!0,_n(e,t)},constants:et};const gn=16209;var yn=function(e,t){let n,r,a,s,i,o,u,c,l,h,d,f,p,v,_,m,g,y,k,b,E,w,C,x;const T=e.state;n=e.next_in,C=e.input,r=n+(e.avail_in-5),a=e.next_out,x=e.output,s=a-(t-e.avail_out),i=a+(e.avail_out-257),o=T.dmax,u=T.wsize,c=T.whave,l=T.wnext,h=T.window,d=T.hold,f=T.bits,p=T.lencode,v=T.distcode,_=(1<>>24,d>>>=y,f-=y,y=g>>>16&255,0===y)x[a++]=65535&g;else{if(!(16&y)){if(0==(64&y)){g=p[(65535&g)+(d&(1<>>=y,f-=y),f<15&&(d+=C[n++]<>>24,d>>>=y,f-=y,y=g>>>16&255,!(16&y)){if(0==(64&y)){g=v[(65535&g)+(d&(1<o){e.msg="invalid distance too far back",T.mode=gn;break e}if(d>>>=y,f-=y,y=a-s,b>y){if(y=b-y,y>c&&T.sane){e.msg="invalid distance too far back",T.mode=gn;break e}if(E=0,w=h,0===l){if(E+=u-y,y2;)x[a++]=w[E++],x[a++]=w[E++],x[a++]=w[E++],k-=3;k&&(x[a++]=w[E++],k>1&&(x[a++]=w[E++]))}else{E=a-b;do{x[a++]=x[E++],x[a++]=x[E++],x[a++]=x[E++],k-=3}while(k>2);k&&(x[a++]=x[E++],k>1&&(x[a++]=x[E++]))}break}}break}}while(n>3,n-=k,f-=k<<3,d&=(1<{const u=o.bits;let c,l,h,d,f,p,v=0,_=0,m=0,g=0,y=0,k=0,b=0,E=0,w=0,C=0,x=null;const T=new Uint16Array(16),S=new Uint16Array(16);let I,N,A,M=null;for(v=0;v<=kn;v++)T[v]=0;for(_=0;_=1&&0===T[g];g--);if(y>g&&(y=g),0===g)return a[s++]=20971520,a[s++]=20971520,o.bits=1,0;for(m=1;m0&&(0===e||1!==g))return-1;for(S[1]=0,v=1;v852||2===e&&w>592)return 1;for(;;){I=v-b,i[_]+1=p?(N=M[i[_]-p],A=x[i[_]-p]):(N=96,A=0),c=1<>b)+l]=I<<24|N<<16|A|0}while(0!==l);for(c=1<>=1;if(0!==c?(C&=c-1,C+=c):C=0,_++,0==--T[v]){if(v===g)break;v=t[n+i[_]]}if(v>y&&(C&d)!==h){for(0===b&&(b=y),f+=m,k=v-b,E=1<852||2===e&&w>592)return 1;h=C&d,a[h]=y<<24|k<<16|f-s|0}}return 0!==C&&(a[f+C]=v-b<<24|64<<16|0),o.bits=y,0};const{Z_FINISH:Tn,Z_BLOCK:Sn,Z_TREES:In,Z_OK:Nn,Z_STREAM_END:An,Z_NEED_DICT:Mn,Z_STREAM_ERROR:On,Z_DATA_ERROR:Un,Z_MEM_ERROR:Rn,Z_BUF_ERROR:Ln,Z_DEFLATED:Dn}=et,Pn=16180,Fn=16190,Gn=16191,Hn=16192,qn=16194,jn=16199,zn=16200,Vn=16206,Bn=16209,Qn=e=>(e>>>24&255)+(e>>>8&65280)+((65280&e)<<8)+((255&e)<<24);function Kn(){this.strm=null,this.mode=0,this.last=!1,this.wrap=0,this.havedict=!1,this.flags=0,this.dmax=0,this.check=0,this.total=0,this.head=null,this.wbits=0,this.wsize=0,this.whave=0,this.wnext=0,this.window=null,this.hold=0,this.bits=0,this.length=0,this.offset=0,this.extra=0,this.lencode=null,this.distcode=null,this.lenbits=0,this.distbits=0,this.ncode=0,this.nlen=0,this.ndist=0,this.have=0,this.next=null,this.lens=new Uint16Array(320),this.work=new Uint16Array(288),this.lendyn=null,this.distdyn=null,this.sane=0,this.back=0,this.was=0}const Wn=e=>{if(!e)return 1;const t=e.state;return!t||t.strm!==e||t.mode16211?1:0},Yn=e=>{if(Wn(e))return On;const t=e.state;return e.total_in=e.total_out=t.total=0,e.msg="",t.wrap&&(e.adler=1&t.wrap),t.mode=Pn,t.last=0,t.havedict=0,t.flags=-1,t.dmax=32768,t.head=null,t.hold=0,t.bits=0,t.lencode=t.lendyn=new Int32Array(852),t.distcode=t.distdyn=new Int32Array(592),t.sane=1,t.back=-1,Nn},Zn=e=>{if(Wn(e))return On;const t=e.state;return t.wsize=0,t.whave=0,t.wnext=0,Yn(e)},Jn=(e,t)=>{let n;if(Wn(e))return On;const r=e.state;return t<0?(n=0,t=-t):(n=5+(t>>4),t<48&&(t&=15)),t&&(t<8||t>15)?On:(null!==r.window&&r.wbits!==t&&(r.window=null),r.wrap=n,r.wbits=t,Zn(e))},Xn=(e,t)=>{if(!e)return On;const n=new Kn;e.state=n,n.strm=e,n.window=null,n.mode=Pn;const r=Jn(e,t);return r!==Nn&&(e.state=null),r};let $n,er,tr=!0;const nr=e=>{if(tr){$n=new Int32Array(512),er=new Int32Array(32);let t=0;for(;t<144;)e.lens[t++]=8;for(;t<256;)e.lens[t++]=9;for(;t<280;)e.lens[t++]=7;for(;t<288;)e.lens[t++]=8;for(xn(1,e.lens,0,288,$n,0,e.work,{bits:9}),t=0;t<32;)e.lens[t++]=5;xn(2,e.lens,0,32,er,0,e.work,{bits:5}),tr=!1}e.lencode=$n,e.lenbits=9,e.distcode=er,e.distbits=5},rr=(e,t,n,r)=>{let a;const s=e.state;return null===s.window&&(s.wsize=1<=s.wsize?(s.window.set(t.subarray(n-s.wsize,n),0),s.wnext=0,s.whave=s.wsize):(a=s.wsize-s.wnext,a>r&&(a=r),s.window.set(t.subarray(n-r,n-r+a),s.wnext),(r-=a)?(s.window.set(t.subarray(n-r,n),0),s.wnext=r,s.whave=s.wsize):(s.wnext+=a,s.wnext===s.wsize&&(s.wnext=0),s.whaveXn(e,15),inflateInit2:Xn,inflate:(e,t)=>{let n,r,a,s,i,o,u,c,l,h,d,f,p,v,_,m,g,y,k,b,E,w,C=0;const x=new Uint8Array(4);let T,S;const I=new Uint8Array([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]);if(Wn(e)||!e.output||!e.input&&0!==e.avail_in)return On;n=e.state,n.mode===Gn&&(n.mode=Hn),i=e.next_out,a=e.output,u=e.avail_out,s=e.next_in,r=e.input,o=e.avail_in,c=n.hold,l=n.bits,h=o,d=u,w=Nn;e:for(;;)switch(n.mode){case Pn:if(0===n.wrap){n.mode=Hn;break}for(;l<16;){if(0===o)break e;o--,c+=r[s++]<>>8&255,n.check=Xe(n.check,x,2,0),c=0,l=0,n.mode=16181;break}if(n.head&&(n.head.done=!1),!(1&n.wrap)||(((255&c)<<8)+(c>>8))%31){e.msg="incorrect header check",n.mode=Bn;break}if((15&c)!==Dn){e.msg="unknown compression method",n.mode=Bn;break}if(c>>>=4,l-=4,E=8+(15&c),0===n.wbits&&(n.wbits=E),E>15||E>n.wbits){e.msg="invalid window size",n.mode=Bn;break}n.dmax=1<>8&1),512&n.flags&&4&n.wrap&&(x[0]=255&c,x[1]=c>>>8&255,n.check=Xe(n.check,x,2,0)),c=0,l=0,n.mode=16182;case 16182:for(;l<32;){if(0===o)break e;o--,c+=r[s++]<>>8&255,x[2]=c>>>16&255,x[3]=c>>>24&255,n.check=Xe(n.check,x,4,0)),c=0,l=0,n.mode=16183;case 16183:for(;l<16;){if(0===o)break e;o--,c+=r[s++]<>8),512&n.flags&&4&n.wrap&&(x[0]=255&c,x[1]=c>>>8&255,n.check=Xe(n.check,x,2,0)),c=0,l=0,n.mode=16184;case 16184:if(1024&n.flags){for(;l<16;){if(0===o)break e;o--,c+=r[s++]<>>8&255,n.check=Xe(n.check,x,2,0)),c=0,l=0}else n.head&&(n.head.extra=null);n.mode=16185;case 16185:if(1024&n.flags&&(f=n.length,f>o&&(f=o),f&&(n.head&&(E=n.head.extra_len-n.length,n.head.extra||(n.head.extra=new Uint8Array(n.head.extra_len)),n.head.extra.set(r.subarray(s,s+f),E)),512&n.flags&&4&n.wrap&&(n.check=Xe(n.check,r,f,s)),o-=f,s+=f,n.length-=f),n.length))break e;n.length=0,n.mode=16186;case 16186:if(2048&n.flags){if(0===o)break e;f=0;do{E=r[s+f++],n.head&&E&&n.length<65536&&(n.head.name+=String.fromCharCode(E))}while(E&&f>9&1,n.head.done=!0),e.adler=n.check=0,n.mode=Gn;break;case 16189:for(;l<32;){if(0===o)break e;o--,c+=r[s++]<>>=7&l,l-=7&l,n.mode=Vn;break}for(;l<3;){if(0===o)break e;o--,c+=r[s++]<>>=1,l-=1,3&c){case 0:n.mode=16193;break;case 1:if(nr(n),n.mode=jn,t===In){c>>>=2,l-=2;break e}break;case 2:n.mode=16196;break;case 3:e.msg="invalid block type",n.mode=Bn}c>>>=2,l-=2;break;case 16193:for(c>>>=7&l,l-=7&l;l<32;){if(0===o)break e;o--,c+=r[s++]<>>16^65535)){e.msg="invalid stored block lengths",n.mode=Bn;break}if(n.length=65535&c,c=0,l=0,n.mode=qn,t===In)break e;case qn:n.mode=16195;case 16195:if(f=n.length,f){if(f>o&&(f=o),f>u&&(f=u),0===f)break e;a.set(r.subarray(s,s+f),i),o-=f,s+=f,u-=f,i+=f,n.length-=f;break}n.mode=Gn;break;case 16196:for(;l<14;){if(0===o)break e;o--,c+=r[s++]<>>=5,l-=5,n.ndist=1+(31&c),c>>>=5,l-=5,n.ncode=4+(15&c),c>>>=4,l-=4,n.nlen>286||n.ndist>30){e.msg="too many length or distance symbols",n.mode=Bn;break}n.have=0,n.mode=16197;case 16197:for(;n.have>>=3,l-=3}for(;n.have<19;)n.lens[I[n.have++]]=0;if(n.lencode=n.lendyn,n.lenbits=7,T={bits:n.lenbits},w=xn(0,n.lens,0,19,n.lencode,0,n.work,T),n.lenbits=T.bits,w){e.msg="invalid code lengths set",n.mode=Bn;break}n.have=0,n.mode=16198;case 16198:for(;n.have>>24,m=C>>>16&255,g=65535&C,!(_<=l);){if(0===o)break e;o--,c+=r[s++]<>>=_,l-=_,n.lens[n.have++]=g;else{if(16===g){for(S=_+2;l>>=_,l-=_,0===n.have){e.msg="invalid bit length repeat",n.mode=Bn;break}E=n.lens[n.have-1],f=3+(3&c),c>>>=2,l-=2}else if(17===g){for(S=_+3;l>>=_,l-=_,E=0,f=3+(7&c),c>>>=3,l-=3}else{for(S=_+7;l>>=_,l-=_,E=0,f=11+(127&c),c>>>=7,l-=7}if(n.have+f>n.nlen+n.ndist){e.msg="invalid bit length repeat",n.mode=Bn;break}for(;f--;)n.lens[n.have++]=E}}if(n.mode===Bn)break;if(0===n.lens[256]){e.msg="invalid code -- missing end-of-block",n.mode=Bn;break}if(n.lenbits=9,T={bits:n.lenbits},w=xn(1,n.lens,0,n.nlen,n.lencode,0,n.work,T),n.lenbits=T.bits,w){e.msg="invalid literal/lengths set",n.mode=Bn;break}if(n.distbits=6,n.distcode=n.distdyn,T={bits:n.distbits},w=xn(2,n.lens,n.nlen,n.ndist,n.distcode,0,n.work,T),n.distbits=T.bits,w){e.msg="invalid distances set",n.mode=Bn;break}if(n.mode=jn,t===In)break e;case jn:n.mode=zn;case zn:if(o>=6&&u>=258){e.next_out=i,e.avail_out=u,e.next_in=s,e.avail_in=o,n.hold=c,n.bits=l,yn(e,d),i=e.next_out,a=e.output,u=e.avail_out,s=e.next_in,r=e.input,o=e.avail_in,c=n.hold,l=n.bits,n.mode===Gn&&(n.back=-1);break}for(n.back=0;C=n.lencode[c&(1<>>24,m=C>>>16&255,g=65535&C,!(_<=l);){if(0===o)break e;o--,c+=r[s++]<>y)],_=C>>>24,m=C>>>16&255,g=65535&C,!(y+_<=l);){if(0===o)break e;o--,c+=r[s++]<>>=y,l-=y,n.back+=y}if(c>>>=_,l-=_,n.back+=_,n.length=g,0===m){n.mode=16205;break}if(32&m){n.back=-1,n.mode=Gn;break}if(64&m){e.msg="invalid literal/length code",n.mode=Bn;break}n.extra=15&m,n.mode=16201;case 16201:if(n.extra){for(S=n.extra;l>>=n.extra,l-=n.extra,n.back+=n.extra}n.was=n.length,n.mode=16202;case 16202:for(;C=n.distcode[c&(1<>>24,m=C>>>16&255,g=65535&C,!(_<=l);){if(0===o)break e;o--,c+=r[s++]<>y)],_=C>>>24,m=C>>>16&255,g=65535&C,!(y+_<=l);){if(0===o)break e;o--,c+=r[s++]<>>=y,l-=y,n.back+=y}if(c>>>=_,l-=_,n.back+=_,64&m){e.msg="invalid distance code",n.mode=Bn;break}n.offset=g,n.extra=15&m,n.mode=16203;case 16203:if(n.extra){for(S=n.extra;l>>=n.extra,l-=n.extra,n.back+=n.extra}if(n.offset>n.dmax){e.msg="invalid distance too far back",n.mode=Bn;break}n.mode=16204;case 16204:if(0===u)break e;if(f=d-u,n.offset>f){if(f=n.offset-f,f>n.whave&&n.sane){e.msg="invalid distance too far back",n.mode=Bn;break}f>n.wnext?(f-=n.wnext,p=n.wsize-f):p=n.wnext-f,f>n.length&&(f=n.length),v=n.window}else v=a,p=i-n.offset,f=n.length;f>u&&(f=u),u-=f,n.length-=f;do{a[i++]=v[p++]}while(--f);0===n.length&&(n.mode=zn);break;case 16205:if(0===u)break e;a[i++]=n.length,u--,n.mode=zn;break;case Vn:if(n.wrap){for(;l<32;){if(0===o)break e;o--,c|=r[s++]<{if(Wn(e))return On;let t=e.state;return t.window&&(t.window=null),e.state=null,Nn},inflateGetHeader:(e,t)=>{if(Wn(e))return On;const n=e.state;return 0==(2&n.wrap)?On:(n.head=t,t.done=!1,Nn)},inflateSetDictionary:(e,t)=>{const n=t.length;let r,a,s;return Wn(e)?On:(r=e.state,0!==r.wrap&&r.mode!==Fn?On:r.mode===Fn&&(a=1,a=Ze(a,t,n,0),a!==r.check)?Un:(s=rr(e,t,n,n),s?(r.mode=16210,Rn):(r.havedict=1,Nn)))},inflateInfo:"pako inflate (from Nodeca project)"};var sr=function(){this.text=0,this.time=0,this.xflags=0,this.os=0,this.extra=null,this.extra_len=0,this.name="",this.comment="",this.hcrc=0,this.done=!1};const ir=Object.prototype.toString,{Z_NO_FLUSH:or,Z_FINISH:ur,Z_OK:cr,Z_STREAM_END:lr,Z_NEED_DICT:hr,Z_STREAM_ERROR:dr,Z_DATA_ERROR:fr,Z_MEM_ERROR:pr}=et;function vr(e){this.options=$t.assign({chunkSize:65536,windowBits:15,to:""},e||{});const t=this.options;t.raw&&t.windowBits>=0&&t.windowBits<16&&(t.windowBits=-t.windowBits,0===t.windowBits&&(t.windowBits=-15)),!(t.windowBits>=0&&t.windowBits<16)||e&&e.windowBits||(t.windowBits+=32),t.windowBits>15&&t.windowBits<48&&0==(15&t.windowBits)&&(t.windowBits|=15),this.err=0,this.msg="",this.ended=!1,this.chunks=[],this.strm=new rn,this.strm.avail_out=0;let n=ar.inflateInit2(this.strm,t.windowBits);if(n!==cr)throw new Error($e[n]);if(this.header=new sr,ar.inflateGetHeader(this.strm,this.header),t.dictionary&&("string"==typeof t.dictionary?t.dictionary=nn.string2buf(t.dictionary):"[object ArrayBuffer]"===ir.call(t.dictionary)&&(t.dictionary=new Uint8Array(t.dictionary)),t.raw&&(n=ar.inflateSetDictionary(this.strm,t.dictionary),n!==cr)))throw new Error($e[n])}function _r(e,t){const n=new vr(t);if(n.push(e),n.err)throw n.msg||$e[n.err];return n.result}vr.prototype.push=function(e,t){const n=this.strm,r=this.options.chunkSize,a=this.options.dictionary;let s,i,o;if(this.ended)return!1;for(i=t===~~t?t:!0===t?ur:or,"[object ArrayBuffer]"===ir.call(e)?n.input=new Uint8Array(e):n.input=e,n.next_in=0,n.avail_in=n.input.length;;){for(0===n.avail_out&&(n.output=new Uint8Array(r),n.next_out=0,n.avail_out=r),s=ar.inflate(n,i),s===hr&&a&&(s=ar.inflateSetDictionary(n,a),s===cr?s=ar.inflate(n,i):s===fr&&(s=hr));n.avail_in>0&&s===lr&&n.state.wrap>0&&0!==e[n.next_in];)ar.inflateReset(n),s=ar.inflate(n,i);switch(s){case dr:case fr:case hr:case pr:return this.onEnd(s),this.ended=!0,!1}if(o=n.avail_out,n.next_out&&(0===n.avail_out||s===lr))if("string"===this.options.to){let e=nn.utf8border(n.output,n.next_out),t=n.next_out-e,a=nn.buf2string(n.output,e);n.next_out=t,n.avail_out=r-t,t&&n.output.set(n.output.subarray(e,e+t),0),this.onData(a)}else this.onData(n.output.length===n.next_out?n.output:n.output.subarray(0,n.next_out));if(s!==cr||0!==o){if(s===lr)return s=ar.inflateEnd(this.strm),this.onEnd(s),this.ended=!0,!0;if(0===n.avail_in)break}}return!0},vr.prototype.onData=function(e){this.chunks.push(e)},vr.prototype.onEnd=function(e){e===cr&&("string"===this.options.to?this.result=this.chunks.join(""):this.result=$t.flattenChunks(this.chunks)),this.chunks=[],this.err=e,this.msg=this.strm.msg};var mr={Inflate:vr,inflate:_r,inflateRaw:function(e,t){return(t=t||{}).raw=!0,_r(e,t)},ungzip:_r,constants:et};const{Deflate:gr,deflate:yr,deflateRaw:kr,gzip:br}=mn,{Inflate:Er,inflate:wr,inflateRaw:Cr,ungzip:xr}=mr;var Tr,Sr={Deflate:gr,deflate:yr,deflateRaw:kr,gzip:br,Inflate:Er,inflate:wr,inflateRaw:Cr,ungzip:xr,constants:et},Ir=function(e){return b(void 0,void 0,void 0,t().mark((function n(){var r;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return r=Sr.ungzip(e),t.abrupt("return",String.fromCharCode.apply(null,r));case 2:case"end":return t.stop()}}),n)})))};e.ConnectionState=void 0,(Tr=e.ConnectionState||(e.ConnectionState={})).CONNECTING="CONNECTING",Tr.OPEN="OPEN",Tr.CLOSED="CLOSED";var Nr,Ar=function(n){i(o,n);var a=f(o);function o(e,t){var n,s=t.sdkState,i=t.dispatcher,u=t.logger;return r(this,o),(n=a.call(this)).lastActive=0,n._iid=e,n._sdkState=s,n._dispatcher=i,n._logger=u,n}return s(o,[{key:"isOpen",get:function(){return this.connectionState===e.ConnectionState.OPEN}},{key:"connectionState",get:function(){if(this._ws)switch(this._ws.readyState){case 0:return e.ConnectionState.CONNECTING;case 1:return e.ConnectionState.OPEN}return e.ConnectionState.CLOSED}},{key:"_handleMessage",value:function(e){var t=this;e.split("\n").forEach((function(e){if(e){var n=le.createFromRawMessage(t._iid,e);t._logger.debug("receive websocket event",n),"LOGI"===n.code?t.dispatch("message",n):"PONG"===n.code?t.dispatch("pong"):"EXPR"===n.code?n.payload&&n.payload.expires_in>=0&&t._dispatcher.dispatch(new se):"NOOP"===n.code||t.dispatch("message",n)}}))}},{key:"connect",value:function(e){var n=this;this._ws=new WebSocket(e),this._ws.onopen=function(){n._logger.debug("websocket open"),n.dispatch("open")},this._ws.onmessage=function(e){return b(n,void 0,void 0,t().mark((function n(){var r,a,s=this;return t().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:(null===(r=this._sdkState.websocket)||void 0===r?void 0:r.compression)?e.data instanceof Blob?((a=new FileReader).readAsArrayBuffer(e.data),a.onloadend=function(){return b(s,void 0,void 0,t().mark((function e(){var n;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,Ir(a.result);case 2:n=e.sent,this._handleMessage(n);case 4:case"end":return e.stop()}}),e,this)})))}):"string"==typeof e.data&&this._handleMessage(e.data):this._handleMessage(e.data);case 1:case"end":return n.stop()}}),n,this)})))},this._ws.onerror=function(){n._logger.debug("websocket error"),n.dispatch("error",M.networkError)},this._ws.onclose=function(){n._logger.debug("websocket close"),n.dispatch("close")},this.lastActive=Date.now()}},{key:"disconnect",value:function(){var t=this;return new Promise((function(n){t._logger.debug("websocket disconnect"),t._ws&&t.connectionState!==e.ConnectionState.CLOSED?(t._ws.onopen=he,t._ws.onmessage=he,t._ws.onerror=he,t._ws.onclose=function(){t.dispatch("close"),n()},t._ws.close(),t._ws=null):n()}))}},{key:"send",value:function(e){if(!this._ws)throw M.connectionClosed;"PING"!==e.code?this.dispatch("ping-refresh"):this._logger.debug("send ping",e),this._ws.send(e.convertToMessage())}},{key:"error",value:function(e){this._logger.debug("websocket error",e),this.dispatch("error",e)}}]),o}(J),Mr=function(e){i(n,e);var t=f(n);function n(e){var a,s,i=e.code,o=e.ackRequired,u=e.payload,c=void 0===u?null:u;return r(this,n),(a=t.call(this)).code=i,a.payload=c,a.requestId=null!==(s=a.payload.req_id)&&void 0!==s?s:Y(),a.ackRequired=o,a.payload.req_id=a.requestId,a}return s(n,[{key:"convertToMessage",value:function(){return"".concat(this.code).concat(JSON.stringify(this.payload),"\n")}}]),n}($),Or=function(e){i(n,e);var t=f(n);function n(e){var a,s=e.all,i=e.custom_types,o=e.ts;return r(this,n),(a=t.call(this)).all=s,a.customTypes=i,a.ts=o,a}return s(n)}($),Ur=s((function e(){var t=this;r(this,e),this.promise=new Promise((function(e,n){t.resolve=e,t.reject=n}))})),Rr=function(){function e(t,n){var a=this,s=n.auth,i=n.sdkState,o=n.dispatcher,u=n.logger,c=n.useFetchCompat,l=void 0!==c&&c;r(this,e),this._ackStateMap=new Map,this._sdkState=i,this._dispatcher=o,this._logger=u,this.apiClient=new ce(t,{auth:s,sdkState:i,dispatcher:o,logger:u,useFetchCompat:l}),this.websocketClient=new Ar(t,{sdkState:i,dispatcher:o,logger:u}),this.websocketClient.on("message",(function(e){if(e.payload.unread_cnt&&a._dispatcher.dispatch(new Or(e.payload.unread_cnt)),e.requestId){if(a._ackStateMap.has(e.requestId)){var t=a._ackStateMap.get(e.requestId);"EROR"!==e.code?t.resolve(e):t.reject(new M({code:e.payload.code,message:e.payload.message}))}}else a._dispatcher.dispatch(e)})).on("close",(function(){a._ackStateMap.forEach((function(e){e.reject(M.connectionClosed)})),a._ackStateMap.clear()}))}return s(e,[{key:"_sendApiRequest",value:function(e){return b(this,void 0,void 0,t().mark((function n(){return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,this.apiClient.send(e);case 2:return t.abrupt("return",t.sent);case 3:case"end":return t.stop()}}),n,this)})))}},{key:"_sendWebsocketRequest",value:function(e){return b(this,void 0,void 0,t().mark((function n(){var r,a,s,i=this;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(r=new Ur,e.ackRequired){a=null,s=function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:null,n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null;i._ackStateMap.has(e.requestId)&&(i._ackStateMap.delete(e.requestId),a&&(clearTimeout(a),a=null),t?(i._logger.debug("fail websocket request",t),r.reject(t)):(i._logger.debug("receive websocket ack",e.requestId),r.resolve(n)))};try{a=setTimeout((function(){return s(M.noAckTimeout)}),this._sdkState.websocket.responseTimeout),this._ackStateMap.set(e.requestId,{resolve:function(e){return s(null,e)},reject:function(e){return s(e)}}),this.websocketClient.send(e)}catch(e){s(e)}}else try{this.websocketClient.send(e),r.resolve(null)}catch(e){r.reject(e)}return t.abrupt("return",r.promise);case 3:case"end":return t.stop()}}),n,this)})))}},{key:"send",value:function(e){return b(this,void 0,void 0,t().mark((function n(){return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(!(e instanceof ne)){t.next=6;break}return t.next=3,this._sendApiRequest(e);case 3:case 9:return t.abrupt("return",t.sent);case 6:if(!(e instanceof Mr)){t.next=10;break}return t.next=9,this._sendWebsocketRequest(e);case 10:throw M.invalidParameters;case 11:case"end":return t.stop()}}),n,this)})))}},{key:"cancel",value:function(e){this.apiClient.cancel(e)}},{key:"cancelAll",value:function(){this.apiClient.cancelAll()}}]),e}();!function(e){e[e.NONE=0]="NONE",e[e.INITIALIZED=1]="INITIALIZED",e[e.CONNECTING=2]="CONNECTING",e[e.CONNECTED=3]="CONNECTED",e[e.RECONNECTING=4]="RECONNECTING",e[e.INTERNAL_DISCONNECTED=5]="INTERNAL_DISCONNECTED",e[e.EXTERNAL_DISCONNECTED=6]="EXTERNAL_DISCONNECTED",e[e.LOGOUT=7]="LOGOUT"}(Nr||(Nr={}));var Lr,Dr=function(e){i(n,e);var t=f(n);function n(e){var a,s=e.stateType;return r(this,n),(a=t.call(this)).stateType=s,a}return s(n)}($),Pr=function(){function e(n,a){var s=this,i=a.auth,o=a.sdkState,u=a.dispatcher,c=a.logger,l=a.useFetchCompat,h=void 0!==l&&l;r(this,e),this._currentConnectionStateType=Nr.INITIALIZED,this._lazyCallQueue=[],this.commandRouter=new Rr(n,{auth:i,sdkState:o,dispatcher:u,logger:c,useFetchCompat:h}),this._auth=i,this._logger=c,this._dispatcher=u,this._dispatcher.on((function(e){if(e instanceof Dr){var n=e.stateType;switch(s._currentConnectionStateType=n,n){case Nr.CONNECTED:var r=s._lazyCallQueue;s._lazyCallQueue=[],r.forEach((function(e){return b(s,void 0,void 0,t().mark((function n(){var r,a,s,i;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return r=e.command,a=e.deferred,s=e.timeout,clearTimeout(s),t.prev=2,t.next=5,this.send(r);case 5:i=t.sent,a.resolve(i),t.next=12;break;case 9:t.prev=9,t.t0=t.catch(2),a.reject(t.t0);case 12:case"end":return t.stop()}}),n,this,[[2,9]])})))}));break;case Nr.INITIALIZED:case Nr.INTERNAL_DISCONNECTED:case Nr.EXTERNAL_DISCONNECTED:case Nr.LOGOUT:var a=s._lazyCallQueue;s._lazyCallQueue=[],a.forEach((function(e){return b(s,void 0,void 0,t().mark((function n(){var r,a;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:r=e.deferred,a=e.timeout,clearTimeout(a),this._auth&&this._auth.hasSession?r.reject(M.connectionClosed):r.reject(M.connectionRequired);case 3:case"end":return t.stop()}}),n,this)})))}))}}}))}return s(e,[{key:"isReady",get:function(){return this._currentConnectionStateType===Nr.CONNECTED}},{key:"isLazyCallActivated",get:function(){return this._currentConnectionStateType===Nr.CONNECTING||this._currentConnectionStateType===Nr.RECONNECTING}},{key:"send",value:function(e){return b(this,void 0,void 0,t().mark((function n(){var r,a,s,i=this;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(!(e instanceof Mr)){t.next=19;break}if(!this.isReady){t.next=8;break}return this._logger.debug("send websocket request",e),t.next=5,this.commandRouter.send(e);case 5:case 24:return t.abrupt("return",t.sent);case 8:if(!this.isLazyCallActivated){t.next=15;break}return this._logger.debug("wait websocket request",e),r=new Ur,this._lazyCallQueue.push({command:e,deferred:r,timeout:setTimeout((function(){return i.timeout(e.requestId)}),1e4)}),t.abrupt("return",r.promise);case 15:throw this._logger.debug("fail websocket request"),M.connectionRequired;case 17:t.next=37;break;case 19:if(!(e instanceof ne)){t.next=37;break}if(!this._auth.hasSession){t.next=27;break}return this._logger.debug("send api request",e),t.next=24,this.commandRouter.send(e);case 27:if(!this.isLazyCallActivated){t.next=34;break}return this._logger.debug("wait api request",e),a=new Ur,this._lazyCallQueue.push({command:e,deferred:a,timeout:setTimeout((function(){return i.timeout(e.requestId)}),1e4)}),t.abrupt("return",a.promise);case 34:throw s=M.connectionRequired,this._logger.debug("fail api request",s),s;case 37:case"end":return t.stop()}}),n,this)})))}},{key:"forceSend",value:function(e){return b(this,void 0,void 0,t().mark((function n(){return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return this._logger.debug("send forced request",e),t.next=3,this.commandRouter.send(e);case 3:return t.abrupt("return",t.sent);case 4:case"end":return t.stop()}}),n,this)})))}},{key:"timeout",value:function(e){this._logger.debug("timeout request",e);var t=this._lazyCallQueue.findIndex((function(t){return t.command.requestId===e}));t>-1&&(this._lazyCallQueue[t].deferred.reject(M.connectionRequired),this._lazyCallQueue.splice(t,1))}},{key:"cancel",value:function(e){this._logger.debug("cancel api request",e),this.commandRouter.cancel(e)}},{key:"cancelAll",value:function(){this._logger.debug("cancel all api requests"),this.commandRouter.cancelAll()}}]),e}(),Fr="sendbird@devicetokens",Gr=function(){function e(t){var n=t.type,a=t.token;r(this,e),this.type=n,this.token=a}return s(e,null,[{key:"payloadify",value:function(e){return{type:e.type,token:e.token}}}]),e}(),Hr="v3",qr="/".concat(Hr,"/users"),jr="/".concat(Hr,"/storage/file"),zr="/".concat(Hr,"/group_channels"),Vr="/".concat(Hr,"/sdk/group_channels"),Br="/".concat(Hr,"/open_channels"),Qr="/".concat(Hr,"/sdk/open_channels"),Kr="/".concat(Hr,"/search"),Wr="/".concat(Hr,"/report"),Yr="/".concat(Hr,"/emojis"),Zr="/".concat(Hr,"/emoji_categories"),Jr="/".concat(Hr,"/polls"),Xr="/".concat(Hr,"/scheduled_messages"),$r="/".concat(Hr,"/sdk/statistics"),ea=function(e){i(n,e);var t=f(n);function n(e){var a,s=e.userId,i=e.authToken,o=e.expiringSession,u=void 0===o||o;return r(this,n),(a=t.call(this)).path="".concat(qr,"/").concat(s,"/session_key"),a.method=B.POST,a.params={token:i,expiring_session:!!u},a.requireAuth=!1,a}return s(n)}(ne),ta=function(e){i(n,e);var t=f(n);function n(e){var a=e.authToken,s=e.expiringSession,i=void 0===s||s,o=e.requestId,u=void 0===o?null:o;return r(this,n),t.call(this,{code:"LOGI",payload:{token:a,expiring_session:i?1:0,req_id:u},ackRequired:!0})}return s(n)}(Mr),na=function(e){i(n,e);var t=f(n);function n(e,a){var s;r(this,n),s=t.call(this,e,a);var i=a.key;return s.key=i,s}return s(n)}(re),ra=function(e){i(n,e);var t=f(n);function n(e,a,s){var i;return r(this,n),(i=t.call(this,e,"LOGI",s)).error=null,i.newKey=s.new_key,i.error=s.error?new M(s.error):null,i}return s(n)}(le),aa=function(e){i(n,e);var t=f(n);function n(){return r(this,n),t.apply(this,arguments)}return s(n)}($),sa=function(e){return b(void 0,void 0,void 0,t().mark((function n(){return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.abrupt("return",new Promise((function(t){return setTimeout(t,e)})));case 1:case"end":return t.stop()}}),n)})))},ia=function(){function e(){r(this,e)}return s(e,[{key:"calcTimeout",value:function(){return 0}}]),e}(),oa=function(e,n){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:new ia;return b(void 0,void 0,void 0,t().mark((function a(){var s,i,o,u,c;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:s=0,i=null,o=function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:null;return i=null!=e?e:new Error("Halted")},u=function(){s=0};case 4:if(!(-1===n||s=0}},{key:"createRefreshWebsocketCommand",value:function(e){return new ta({authToken:e,expiringSession:!0,requestId:arguments.length>1&&void 0!==arguments[1]?arguments[1]:null})}},{key:"_refreshSessionKeyByWebSocket",value:function(e){return b(this,void 0,void 0,t().mark((function n(){var r,a,s,i,o;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return r=this.createRefreshWebsocketCommand(e),t.next=3,this._requestQueue.forceSend(r);case 3:if(a=t.sent,s=a.as(ra),i=s.newKey,!(o=s.error)){t.next=7;break}throw o;case 7:this.auth.sessionKey=null!=i?i:this.auth.sessionKey;case 8:case"end":return t.stop()}}),n,this)})))}},{key:"_refreshSessionKeyByApi",value:function(e){return b(this,void 0,void 0,t().mark((function n(){var r,a=this;return t().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return r=new ea({userId:this._sdkState.userId,authToken:e,expiringSession:!0}),n.next=3,oa((function(e){return b(a,void 0,void 0,t().mark((function n(){var a,s,i;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.prev=0,t.next=3,this._requestQueue.forceSend(r);case 3:a=t.sent,s=a.as(na),i=s.key,this.auth.sessionKey=i,t.next=15;break;case 8:if(t.prev=8,t.t0=t.catch(0),!this._isSessionRelatedError(t.t0)){t.next=14;break}e(t.t0),t.next=15;break;case 14:throw t.t0;case 15:case"end":return t.stop()}}),n,this,[[0,8]])})))}),3);case 3:case"end":return n.stop()}}),n,this)})))}},{key:"_refreshSessionKey",value:function(e){var n=!(arguments.length>1&&void 0!==arguments[1])||arguments[1];return b(this,void 0,void 0,t().mark((function r(){return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(this._currentConnectionStateType!==Nr.CONNECTED){t.next=25;break}return t.prev=1,t.next=4,this._refreshSessionKeyByWebSocket(e);case 4:return this.complete(),t.abrupt("return");case 8:if(t.prev=8,t.t0=t.catch(1),!this._isSessionRelatedError(t.t0)){t.next=25;break}if(!n){t.next=25;break}return t.next=14,this._receiveNewAuthToken();case 14:if(this.auth.authToken=t.sent,!this.auth.authToken){t.next=21;break}return t.next=18,this._refreshSessionKey(this.auth.authToken,!1);case 18:this.complete(),t.next=24;break;case 21:return t.next=23,this.clear();case 23:this.close();case 24:return t.abrupt("return");case 25:return t.prev=25,t.next=28,this._refreshSessionKeyByApi(e);case 28:this.complete(),t.next=53;break;case 31:if(t.prev=31,t.t1=t.catch(25),!this._isSessionRelatedError(t.t1)){t.next=52;break}if(!n){t.next=49;break}return t.next=37,this._receiveNewAuthToken();case 37:if(this.auth.authToken=t.sent,!this.auth.authToken){t.next=44;break}return t.next=41,this._refreshSessionKeyByApi(this.auth.authToken);case 41:this.complete(),t.next=47;break;case 44:return t.next=46,this.clear();case 46:this.close();case 47:t.next=50;break;case 49:throw t.t1;case 50:t.next=53;break;case 52:throw t.t1;case 53:case"end":return t.stop()}}),r,this,[[1,8],[25,31]])})))}},{key:"_receiveNewAuthToken",value:function(){var e=this,n=new Ur;return ua((function(){return b(e,void 0,void 0,t().mark((function e(){var r,a,s=this;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:this._isRefreshingAuthToken=!0,this.auth.clear(),r=null,a=function(){r&&(clearTimeout(r),r=null)},r=setTimeout((function(){s._isRefreshingAuthToken=!1,n.reject()}),1e3*this._sdkState.sessionTokenRefreshTimeout),this.handler.onSessionTokenRequired((function(e){a(),s._isRefreshingAuthToken&&(s._isRefreshingAuthToken=!1,s.dispatch("refresh-authtoken"),n.resolve(e))}),(function(e){a(),s._isRefreshingAuthToken=!1,n.reject(e)}));case 6:case"end":return e.stop()}}),e,this)})))})),n.promise}},{key:"_isSessionRelatedError",value:function(e){return e instanceof M&&(e.isSessionKeyExpiredError||e.isSessionTokenExpiredError)}},{key:"isSessionKeyRefreshing",get:function(){return this._isRefreshingSessionKey}},{key:"isRefreshingAuthToken",get:function(){return this._isRefreshingAuthToken}},{key:"login",value:function(e){var n;return b(this,void 0,void 0,t().mark((function r(){var a,s,i,o,u,c,l;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(a=e.key,s=e.ekey,i=e.userProfile,o=e.deviceTokenLastDeletedAt,u=void 0===o?0:o,this.auth.sessionKey=a,la.set(this,s),this._deviceTokenCacheEnabled=null===(n=null==i?void 0:i.appInfo)||void 0===n?void 0:n.deviceTokenCache,c=this._cacheContext.preference,!this._deviceTokenCacheEnabled){t.next=20;break}return t.next=8,c.get(Fr);case 8:if((l=t.sent)&&!(l.lastDeletedAt=0&&this._deviceTokens.splice(n,1)}}},{key:"unsetDeviceTokens",value:function(e){this._deviceTokenCacheEnabled&&(this._deviceTokens=e?this._deviceTokens.filter((function(t){return t.type!==e})):[])}},{key:"setDeviceTokenDeletedAt",value:function(e){e>0&&(this._deviceTokenLastDeletedAt=e)}},{key:"saveDeviceToken",value:function(){return b(this,void 0,void 0,t().mark((function e(){var n;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!this._deviceTokenCacheEnabled){e.next=4;break}return n=this._cacheContext.preference,e.next=4,n.set(Fr,{tokens:this._deviceTokens,lastDeletedAt:this._deviceTokenLastDeletedAt});case 4:case"end":return e.stop()}}),e,this)})))}},{key:"clear",value:function(){return b(this,void 0,void 0,t().mark((function e(){return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return this.currentUser=null,this.auth.clear(),la.delete(this),this._deviceTokens=[],this._deviceTokenLastDeletedAt=0,e.next=7,this.saveDeviceToken();case 7:case"end":return e.stop()}}),e,this)})))}}]),a}(J),da=function(){function e(){r(this,e),this.type=Nr.NONE,this.name="none"}return s(e,[{key:"run",value:function(e){return b(this,void 0,void 0,t().mark((function e(){return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:case"end":return e.stop()}}),e)})))}},{key:"onConnect",value:function(e,n){return b(this,void 0,void 0,t().mark((function e(){return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:case"end":return e.stop()}}),e)})))}},{key:"onReconnect",value:function(e,n){return n.resetReconnectCount,b(this,void 0,void 0,t().mark((function e(){return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:case"end":return e.stop()}}),e)})))}},{key:"onDisconnect",value:function(e,n){return n.error,n.autoReconnect,b(this,void 0,void 0,t().mark((function e(){return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:case"end":return e.stop()}}),e)})))}},{key:"onDisconnectWebSocket",value:function(e){return b(this,void 0,void 0,t().mark((function e(){return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:case"end":return e.stop()}}),e)})))}},{key:"onLogout",value:function(e){return b(this,void 0,void 0,t().mark((function e(){return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:case"end":return e.stop()}}),e)})))}}]),e}(),fa=function(e){i(a,e);var n=f(a);function a(){var e;return r(this,a),(e=n.apply(this,arguments)).type=Nr.LOGOUT,e.name="logout",e}return s(a,[{key:"run",value:function(e){return b(this,void 0,void 0,t().mark((function n(){var r,a,s=this;return t().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return r=Date.now(),a=e.sdkState.userId,n.next=4,e.logout();case 4:return n.next=6,e.changeState(new ya,r);case 6:ua((function(){return b(s,void 0,void 0,t().mark((function n(){return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:e.connectionHandlers.forEach((function(e){e.onDisconnected(a)}));case 1:case"end":return t.stop()}}),n)})))}));case 7:case"end":return n.stop()}}),n)})))}}]),a}(da),pa=function(e){i(a,e);var n=f(a);function a(){var e;return r(this,a),(e=n.call(this)).type=Nr.EXTERNAL_DISCONNECTED,e.name="externaldisconnected",e}return s(a,[{key:"run",value:function(e){return b(this,void 0,void 0,t().mark((function n(){return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,e.disconnect();case 2:case"end":return t.stop()}}),n)})))}},{key:"onConnect",value:function(e,n){return b(this,void 0,void 0,t().mark((function r(){var a;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return a=Date.now(),t.next=3,e.disconnect();case 3:return t.next=5,e.changeState(new ga({authToken:n}),a);case 5:case"end":return t.stop()}}),r)})))}},{key:"onReconnect",value:function(e){return b(this,void 0,void 0,t().mark((function n(){var r;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return r=Date.now(),t.next=3,e.changeState(new _a,r);case 3:case"end":return t.stop()}}),n)})))}},{key:"onLogout",value:function(e){return b(this,void 0,void 0,t().mark((function n(){var r;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return r=Date.now(),t.next=3,e.changeState(new fa,r);case 3:case"end":return t.stop()}}),n)})))}}]),a}(da),va=function(e){i(a,e);var n=f(a);function a(e){var t,s=e.autoReconnect;return r(this,a),(t=n.call(this)).type=Nr.INTERNAL_DISCONNECTED,t.name="internaldisconnected",t._autoReconnect=!1,t._autoReconnect=s,t}return s(a,[{key:"run",value:function(e){return b(this,void 0,void 0,t().mark((function n(){var r;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return r=Date.now(),t.next=3,e.disconnect();case 3:if(!this._autoReconnect){t.next=6;break}return t.next=6,e.changeState(new _a,r);case 6:case"end":return t.stop()}}),n,this)})))}},{key:"onConnect",value:function(e,n){return b(this,void 0,void 0,t().mark((function r(){var a;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return a=Date.now(),t.next=3,e.disconnect();case 3:return t.next=5,e.changeState(new ga({authToken:n}),a);case 5:case"end":return t.stop()}}),r)})))}},{key:"onReconnect",value:function(e){return b(this,void 0,void 0,t().mark((function n(){var r;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return r=Date.now(),t.next=3,e.changeState(new _a,r);case 3:case"end":return t.stop()}}),n)})))}},{key:"onDisconnectWebSocket",value:function(e){return b(this,void 0,void 0,t().mark((function n(){var r;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return r=Date.now(),t.next=3,e.changeState(new pa,r);case 3:case"end":return t.stop()}}),n)})))}},{key:"onLogout",value:function(e){return b(this,void 0,void 0,t().mark((function n(){var r;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return r=Date.now(),t.next=3,e.changeState(new fa,r);case 3:case"end":return t.stop()}}),n)})))}}]),a}(da),_a=function(e){i(a,e);var n=f(a);function a(){var e;return r(this,a),(e=n.apply(this,arguments)).type=Nr.RECONNECTING,e.name="reconnecting",e._haltConnect=null,e._resetConnect=null,e._callbacks=[],e}return s(a,[{key:"_halt",value:function(e){this._haltConnect&&(this._haltConnect(e),this._haltConnect=null)}},{key:"_flushCallbacks",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:null;this._haltConnect=null,this._resetConnect=null,this._callbacks.forEach((function(t){return t(e)}))}},{key:"run",value:function(e){return b(this,void 0,void 0,t().mark((function n(){var r,a,s,i,o,u=this;return t().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return r=Date.now(),a=new Ur,this._callbacks.push((function(e){return e?a.reject(e):a.resolve()})),ua((function(){return b(u,void 0,void 0,t().mark((function n(){return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:e.connectionHandlers.forEach((function(e){e.onReconnectStarted()}));case 1:case"end":return t.stop()}}),n)})))})),n.prev=4,s=e.sdkState.websocket,i=s.reconnectMaxRetry,o=s.reconnectRetryStrategy,n.next=8,oa((function(n,r){return b(u,void 0,void 0,t().mark((function a(){return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return this._haltConnect=n,this._resetConnect=r,t.prev=2,t.next=5,e.connect();case 5:t.next=17;break;case 7:if(t.prev=7,t.t0=t.catch(2),e.clearLoginTimer(),!(t.t0 instanceof M)){t.next=16;break}t.t1=t.t0.code,t.next=t.t1===E.CONNECTION_CANCELED?14:16;break;case 14:return n(t.t0),t.abrupt("return");case 16:throw t.t0;case 17:case"end":return t.stop()}}),a,this,[[2,7]])})))}),i,o);case 8:return n.next=10,e.changeState(new ma,r);case 10:ua((function(){return b(u,void 0,void 0,t().mark((function n(){return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:this._flushCallbacks(null),e.connectionHandlers.forEach((function(e){e.onReconnectSucceeded()}));case 2:case"end":return t.stop()}}),n,this)})))})),n.next=24;break;case 13:if(n.prev=13,n.t0=n.catch(4),A(n.t0)){n.next=23;break}if(!(n.t0 instanceof M)){n.next=20;break}if(n.t0.code===E.CONNECTION_CANCELED){n.next=20;break}return n.next=20,e.changeState(new va({autoReconnect:!1}),r);case 20:ua((function(){return b(u,void 0,void 0,t().mark((function r(){return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:this._flushCallbacks(n.t0),e.connectionHandlers.forEach((function(e){e.onReconnectFailed()}));case 2:case"end":return t.stop()}}),r,this)})))})),n.next=24;break;case 23:throw n.t0;case 24:return n.abrupt("return",a.promise);case 25:case"end":return n.stop()}}),n,this,[[4,13]])})))}},{key:"onConnect",value:function(e,n){return b(this,void 0,void 0,t().mark((function r(){var a;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return a=new Ur,this._halt(M.connectionCanceled),e.cancelConnectForRetry(),this._callbacks.push((function(){var t=Date.now();e.changeState(new ga({authToken:n}),t).then((function(){a.resolve()})).catch((function(e){a.reject(e)}))})),t.abrupt("return",a.promise);case 5:case"end":return t.stop()}}),r,this)})))}},{key:"onReconnect",value:function(e,n){var r=n.resetReconnectCount,a=void 0!==r&&r;return b(this,void 0,void 0,t().mark((function e(){var n;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n=new Ur,this._resetConnect&&a&&this._resetConnect(),this._callbacks.push((function(e){return e?n.reject(e):n.resolve()})),e.abrupt("return",n.promise);case 4:case"end":return e.stop()}}),e,this)})))}},{key:"onDisconnect",value:function(e,n){n.error;var r=n.autoReconnect,a=void 0===r||r;return b(this,void 0,void 0,t().mark((function n(){var r;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return r=Date.now(),this._halt(M.connectionCanceled),t.next=4,e.changeState(new va({autoReconnect:a}),r);case 4:case"end":return t.stop()}}),n,this)})))}},{key:"onDisconnectWebSocket",value:function(e){return b(this,void 0,void 0,t().mark((function n(){var r;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return r=Date.now(),this._halt(M.connectionCanceled),t.next=4,e.changeState(new pa,r);case 4:case"end":return t.stop()}}),n,this)})))}},{key:"onLogout",value:function(e){return b(this,void 0,void 0,t().mark((function n(){var r;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return r=Date.now(),this._halt(M.connectionCanceled),t.next=4,e.changeState(new fa,r);case 4:case"end":return t.stop()}}),n,this)})))}}]),a}(da),ma=function(e){i(a,e);var n=f(a);function a(){var e;return r(this,a),(e=n.apply(this,arguments)).type=Nr.CONNECTED,e.name="connected",e}return s(a,[{key:"onReconnect",value:function(e){return b(this,void 0,void 0,t().mark((function n(){var r;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return r=Date.now(),t.next=3,e.disconnect();case 3:return t.next=5,e.changeState(new _a,r);case 5:case"end":return t.stop()}}),n)})))}},{key:"onDisconnect",value:function(e,n){var r=n.autoReconnect;return b(this,void 0,void 0,t().mark((function n(){var a;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return a=Date.now(),t.next=3,e.changeState(new va({autoReconnect:r}),a);case 3:case"end":return t.stop()}}),n)})))}},{key:"onDisconnectWebSocket",value:function(e){return b(this,void 0,void 0,t().mark((function n(){var r;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return r=Date.now(),t.next=3,e.changeState(new pa,r);case 3:case"end":return t.stop()}}),n)})))}},{key:"onLogout",value:function(e){return b(this,void 0,void 0,t().mark((function n(){var r;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return r=Date.now(),t.next=3,e.changeState(new fa,r);case 3:case"end":return t.stop()}}),n)})))}}]),a}(da),ga=function(e){i(a,e);var n=f(a);function a(e){var t,s=e.authToken;return r(this,a),(t=n.call(this)).type=Nr.CONNECTING,t.name="connecting",t._authToken="",t._haltConnect=null,t._callbacks=[],t._authToken=s,t}return s(a,[{key:"_halt",value:function(e){this._haltConnect&&(this._haltConnect(e),this._haltConnect=null)}},{key:"_flushCallbacks",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:null;this._haltConnect=null,this._callbacks.forEach((function(t){return t(e)}))}},{key:"run",value:function(e){return b(this,void 0,void 0,t().mark((function n(){var r,a,s=this;return t().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return r=Date.now(),a=new Ur,this._callbacks.push((function(e){return e?a.reject(e):a.resolve()})),n.prev=3,n.next=6,oa((function(n){return b(s,void 0,void 0,t().mark((function r(){return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return this._haltConnect=n,t.prev=1,t.next=4,e.connect(this._authToken);case 4:t.next=16;break;case 6:if(t.prev=6,t.t0=t.catch(1),e.clearLoginTimer(),!(t.t0 instanceof M)){t.next=15;break}t.t1=t.t0.code,t.next=t.t1===E.CONNECTION_CANCELED?13:15;break;case 13:return n(t.t0),t.abrupt("return");case 15:throw t.t0;case 16:case"end":return t.stop()}}),r,this,[[1,6]])})))}),e.sdkState.websocket.connectMaxRetry);case 6:return n.next=8,e.changeState(new ma,r);case 8:ua((function(){return b(s,void 0,void 0,t().mark((function n(){return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:this._flushCallbacks(null),e.connectionHandlers.forEach((function(t){t.onConnected(e.sdkState.userId)}));case 2:case"end":return t.stop()}}),n,this)})))})),n.next=24;break;case 11:if(n.prev=11,n.t0=n.catch(3),A(n.t0)){n.next=23;break}return n.next=16,e.disconnect();case 16:if(!(n.t0 instanceof M)){n.next=20;break}if(n.t0.code===E.CONNECTION_CANCELED){n.next=20;break}return n.next=20,e.changeState(new ya,r);case 20:ua((function(){return b(s,void 0,void 0,t().mark((function e(){return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:this._flushCallbacks(n.t0);case 1:case"end":return e.stop()}}),e,this)})))})),n.next=24;break;case 23:throw n.t0;case 24:return n.abrupt("return",a.promise);case 25:case"end":return n.stop()}}),n,this,[[3,11]])})))}},{key:"onConnect",value:function(e){return b(this,void 0,void 0,t().mark((function e(){var n;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n=new Ur,this._callbacks.push((function(e){return e?n.reject(e):n.resolve()})),e.abrupt("return",n.promise);case 3:case"end":return e.stop()}}),e,this)})))}},{key:"onDisconnect",value:function(e,n){var r=n.error,a=void 0===r?null:r,s=n.autoReconnect;return b(this,void 0,void 0,t().mark((function n(){var r;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(r=Date.now(),this._halt(null!=a?a:M.connectionCanceled),!e.hasSession){t.next=7;break}return t.next=5,e.changeState(new va({autoReconnect:s}),r);case 5:t.next=9;break;case 7:return t.next=9,e.changeState(new fa,r);case 9:case"end":return t.stop()}}),n,this)})))}},{key:"onDisconnectWebSocket",value:function(e){return b(this,void 0,void 0,t().mark((function n(){var r;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(r=Date.now(),this._halt(M.connectionCanceled),!e.hasSession){t.next=7;break}return t.next=5,e.changeState(new pa,r);case 5:t.next=9;break;case 7:return t.next=9,e.changeState(new fa,r);case 9:case"end":return t.stop()}}),n,this)})))}},{key:"onLogout",value:function(e){return b(this,void 0,void 0,t().mark((function n(){var r;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return r=Date.now(),this._halt(M.connectionCanceled),t.next=4,e.changeState(new fa,r);case 4:case"end":return t.stop()}}),n,this)})))}}]),a}(da),ya=function(e){i(a,e);var n=f(a);function a(){var e;return r(this,a),(e=n.apply(this,arguments)).type=Nr.INITIALIZED,e.name="initialized",e}return s(a,[{key:"onConnect",value:function(e,n){return b(this,void 0,void 0,t().mark((function r(){var a;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return a=Date.now(),t.next=3,e.changeState(new ga({authToken:n}),a);case 3:case"end":return t.stop()}}),r)})))}}]),a}(da),ka=function(e){i(n,e);var t=f(n);function n(){return r(this,n),t.call(this,{code:"PING",payload:{id:Date.now(),active:1},ackRequired:!1})}return s(n)}(Mr),ba=function(){function e(t){var n=t.pingDelegate,a=t.sdkState,s=t.logger;r(this,e),this._pingTimer=null,this._pingTimeoutTimer=null,this.pingDelegate=n,this.sdkState=a,this._logger=s}return s(e,[{key:"isWaiting",get:function(){return!!this._pingTimeoutTimer}},{key:"ping",value:function(){var e,t=this,n=new ka;try{var r=null!==(e=this.sdkState.websocket.pongTimeout)&&void 0!==e?e:5e3;this._pingTimeoutTimer=setTimeout((function(){t._logger.debug("pinger.ping() timeout"),t.pingDelegate.error(null)}),r),this.pingDelegate.send(n),this._logger.debug("pinger.ping()")}catch(e){this._logger.debug("pinger.ping() error",e),this._pingTimeoutTimer&&(clearTimeout(this._pingTimeoutTimer),this._pingTimeoutTimer=null),this.pingDelegate.error(null)}return n}},{key:"pong",value:function(){this._logger.debug("pinger.pong()"),this._pingTimeoutTimer&&(clearTimeout(this._pingTimeoutTimer),this._pingTimeoutTimer=null)}},{key:"refreshTimer",value:function(){var e,t=this;this._logger.debug("pinger.refreshTimer()");var n=null!==(e=this.sdkState.websocket.pingInterval)&&void 0!==e?e:15e3;this.stop(),this._pingTimer=setInterval((function(){t.ping()}),n)}},{key:"start",value:function(){this._logger.debug("pinger.start()"),this.refreshTimer(),this.ping()}},{key:"stop",value:function(){this._logger.debug("pinger.stop()"),this._pingTimer&&(clearInterval(this._pingTimer),this._pingTimer=null),this._pingTimeoutTimer&&(clearTimeout(this._pingTimeoutTimer),this._pingTimeoutTimer=null)}}]),e}(),Ea=1048576,wa=function(){function e(){var t,n,a,s=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};r(this,e),this.emojiHash=s.emoji_hash||"",this.uploadSizeLimit=s.file_upload_size_limit?s.file_upload_size_limit*Ea:Number.MAX_SAFE_INTEGER,this.useReaction=!!s.use_reaction,this.applicationAttributes=null!==(t=s.application_attributes)&&void 0!==t?t:[],this.premiumFeatureList=null!==(n=s.premium_feature_list)&&void 0!==n?n:[],this.deviceTokenCache=this.applicationAttributes.includes("sdk_device_token_cache"),this.enabledChannelMemberShipHistory=this.applicationAttributes.includes("channel_membership_history"),this.allowSdkStatsUpload=null===(a=s.allow_sdk_log_ingestion)||void 0===a||a}return s(e,null,[{key:"payloadify",value:function(e){return{emoji_hash:e.emojiHash,file_upload_size_limit:e.uploadSizeLimit/Ea,application_attributes:e.applicationAttributes,premium_feature_list:e.premiumFeatureList,use_reaction:e.useReaction,allow_sdk_log_ingestion:e.allowSdkStatsUpload}}}]),e}(),Ca=function(){function e(t){r(this,e),this._iid="",this._iid=t}return s(e,null,[{key:"payloadify",value:function(e){return e?{}:null}}]),e}(),xa=function(e){i(n,e);var t=f(n);function n(e){var a,s=e.userId,i=e.metadata;return r(this,n),(a=t.call(this)).method=B.POST,a.path="".concat(qr,"/").concat(s,"/metadata"),a.params={metadata:i},a}return s(n)}(ne),Ta=function(e){i(n,e);var t=f(n);function n(e,a){var s;return r(this,n),(s=t.call(this,e,a)).metaData=a,s}return s(n)}(re),Sa=function(e){i(n,e);var t=f(n);function n(e){var a,s=e.userId,i=e.metadata,o=e.upsert;return r(this,n),(a=t.call(this)).method=B.PUT,a.path="".concat(qr,"/").concat(s,"/metadata"),a.params={metadata:i,upsert:o},a}return s(n)}(ne),Ia=function(e){i(n,e);var t=f(n);function n(e,a){var s;return r(this,n),(s=t.call(this,e,a)).metadata=a,s}return s(n)}(re),Na=function(e){i(n,e);var t=f(n);function n(e){var a,s=e.userId,i=e.metadataKey;return r(this,n),(a=t.call(this)).method=B.DELETE,a.path="".concat(qr,"/").concat(s,"/metadata/").concat(i),a}return s(n)}(ne),Aa=function(e){i(n,e);var t=f(n);function n(e){var a,s=e.userId;return r(this,n),(a=t.call(this)).method=B.DELETE,a.path="".concat(qr,"/").concat(s,"/metadata"),a}return s(n)}(ne),Ma=function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null,n=JSON.parse(JSON.stringify(e));return n._iid&&delete n._iid,t&&t(n),n},Oa=function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null,n=JSON.parse(JSON.stringify(e));return t&&t(n),n},Ua=function(e){return{do:function(t){e||t()},throw:function(t){if(!e)throw t}}};e.UserOnlineState=void 0,(Lr=e.UserOnlineState||(e.UserOnlineState={})).ONLINE="online",Lr.OFFLINE="offline",Lr.NON_AVAILABLE="nonavailable";var Ra,La=function(n){i(u,n);var a=f(u);function u(t,n){var s,i,o,c,l,h,d,f,p,v,m,g,y;return r(this,u),(s=a.call(this,t)).userId=null!==(o=null!==(i=n.guest_id)&&void 0!==i?i:n.user_id)&&void 0!==o?o:"",s.nickname=null!==(l=null!==(c=n.nickname)&&void 0!==c?c:n.name)&&void 0!==l?l:"",s.plainProfileUrl=null!==(d=null!==(h=n.profile_url)&&void 0!==h?h:n.image)&&void 0!==d?d:"",s.requireAuth=null!==(f=n.require_auth_for_profile_image)&&void 0!==f&&f,s.metaData=null!==(p=n.metadata)&&void 0!==p?p:{},s.connectionStatus=e.UserOnlineState.NON_AVAILABLE,D(e.UserOnlineState,n.is_online)?s.connectionStatus=n.is_online:L("boolean",n.is_online)&&(s.connectionStatus=n.is_online?e.UserOnlineState.ONLINE:e.UserOnlineState.OFFLINE),s.isActive=null===(v=n.is_active)||void 0===v||v,s.lastSeenAt=null!==(m=n.last_seen_at)&&void 0!==m?m:null,s.preferredLanguages=n.preferred_languages?_(n.preferred_languages):null,s.friendDiscoveryKey=null!==(g=n.friend_discovery_key)&&void 0!==g?g:null,s.friendName=null!==(y=n.friend_name)&&void 0!==y?y:null,s}return s(u,[{key:"profileUrl",get:function(){var e=ns.of(this._iid).sessionManager;return this.requireAuth?"".concat(this.plainProfileUrl,"?auth=").concat(e.ekey):this.plainProfileUrl}},{key:"serialize",value:function(){return Ma(this)}},{key:"_isValidMetaData",value:function(e){return!Array.isArray(e)&&Object.keys(e).length>0&&Object.keys(e).map((function(t){return e[t]})).every((function(e){return L("string",e)}))}},{key:"_applyMetaData",value:function(e){var t=this,n=arguments.length>1&&void 0!==arguments[1]&&arguments[1];Object.keys(e).forEach((function(r){n?delete t.metaData[r]:t.metaData[r]=e[r]}))}},{key:"createMetaData",value:function(e){return b(this,void 0,void 0,t().mark((function n(){var r,a,s,i,o,u,c;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return Ua(this._isValidMetaData(e)).throw(M.invalidParameters),r=ns.of(this._iid),a=r.sdkState,s=r.requestQueue,i=new xa({userId:a.userId,metadata:e}),t.next=5,s.send(i);case 5:return o=t.sent,u=o.as(Ta),c=u.metaData,this._applyMetaData(c),t.abrupt("return",this.metaData);case 9:case"end":return t.stop()}}),n,this)})))}},{key:"updateMetaData",value:function(e){var n=arguments.length>1&&void 0!==arguments[1]&&arguments[1];return b(this,void 0,void 0,t().mark((function r(){var a,s,i,o,u,c,l;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return Ua(this._isValidMetaData(e)).throw(M.invalidParameters),a=ns.of(this._iid),s=a.sdkState,i=a.requestQueue,o=new Sa({userId:s.userId,metadata:e,upsert:n}),t.next=5,i.send(o);case 5:return u=t.sent,c=u.as(Ia),l=c.metadata,this._applyMetaData(l),t.abrupt("return",this.metaData);case 9:case"end":return t.stop()}}),r,this)})))}},{key:"deleteMetaData",value:function(e){return b(this,void 0,void 0,t().mark((function n(){var r,a,s,i;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return Ua(L("string",e)).throw(M.invalidParameters),r=ns.of(this._iid),a=r.sdkState,s=r.requestQueue,i=new Na({userId:a.userId,metadataKey:e}),t.next=5,s.send(i);case 5:return this._applyMetaData((n={},u=!0,(o=k(o=e))in n?Object.defineProperty(n,o,{value:u,enumerable:!0,configurable:!0,writable:!0}):n[o]=u,n),!0),t.abrupt("return",this.metaData);case 7:case"end":return t.stop()}var n,o,u}),n,this)})))}},{key:"deleteAllMetaData",value:function(){return b(this,void 0,void 0,t().mark((function e(){var n,r,a,s;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n=ns.of(this._iid),r=n.sdkState,a=n.requestQueue,s=new Aa({userId:r.userId}),e.next=4,a.send(s);case 4:this.metaData={};case 5:case"end":return e.stop()}}),e,this)})))}}],[{key:"payloadify",value:function(e){return e?ee(Object.assign(Object.assign({},p(o(u),"payloadify",this).call(this,e)),{user_id:e.userId,nickname:e.nickname,profile_url:e.plainProfileUrl,require_auth_for_profile_image:e.requireAuth,metadata:e.metaData,is_online:e.connectionStatus,is_active:e.isActive,last_seen_at:e.lastSeenAt,preferred_languages:e.preferredLanguages,friend_discovery_key:e.friendDiscoveryKey,friend_name:e.friendName})):null}}]),u}(Ca),Da=function(e){i(n,e);var t=f(n);function n(e){var a,s=e.userProfile;return r(this,n),(a=t.call(this)).userProfile=s,a}return s(n)}($),Pa=function(){function e(t,n){var a,s,i,o,u,c,l,h,d,f,p,v,_,m;r(this,e),this._iid=t,this.appInfo=new wa(n),this.user=new La(t,n),this.connectedAt=null!==(a=n.login_ts)&&void 0!==a?a:0,this.firstConnectedAt=0,this.pingInterval=null!==(s=n.ping_interval)&&void 0!==s?s:15e3,this.pongTimeout=null!==(i=n.pong_timeout)&&void 0!==i?i:5e3,this.reconnectInterval=null!==(u=null===(o=n.reconnect)||void 0===o?void 0:o.interval)&&void 0!==u?u:3e3,this.reconnectMaxInterval=null!==(l=null===(c=n.reconnect)||void 0===c?void 0:c.max_interval)&&void 0!==l?l:6e4,this.reconnectRetryCount=null!==(d=null===(h=n.reconnect)||void 0===h?void 0:h.retry_cnt)&&void 0!==d?d:5,this.reconnectIntervalMultiple=null!==(p=null===(f=n.reconnect)||void 0===f?void 0:f.mul)&&void 0!==p?p:2,this.maxUnreadCountOnSuperGroup=null!==(v=n.max_unread_cnt_on_super_group)&&void 0!==v?v:100,this.profileImageEncryption=!!n.profile_image_encryption,this.concurrentCallLimit=null!==(_=n.concurrent_call_limit)&&void 0!==_?_:5,this.backOffDelay=null!==(m=n.back_off_delay)&&void 0!==m?m:100}return s(e,[{key:"apply",value:function(){var e=this.reconnectInterval,t=this.reconnectMaxInterval,n=this.reconnectIntervalMultiple,r=ns.of(this._iid);r.sdkState.websocket.pingInterval=1e3*this.pingInterval,r.sdkState.websocket.pongTimeout=1e3*this.pongTimeout,r.sdkState.websocket.reconnectMaxRetry=this.reconnectRetryCount,r.sdkState.websocket.reconnectRetryStrategy={calcTimeout:function(r){return r>0?1e3*Math.min(e*Math.pow(n,r-1),t):10}},r.appInfo=this.appInfo,r.sessionManager.currentUser=this.user,r.connectedAt=this.connectedAt,this.firstConnectedAt||(r.firstConnectedAt=this.connectedAt),r.maxSuperGroupChannelUnreadCount=this.maxUnreadCountOnSuperGroup,r.concurrentCallLimit=this.concurrentCallLimit,r.backOffDelay=this.backOffDelay,r.dispatcher.dispatch(new Da({userProfile:this}))}}],[{key:"payloadify",value:function(e){return Object.assign(Object.assign(Object.assign({},La.payloadify(e.user)),wa.payloadify(e.appInfo)),{login_ts:e.connectedAt,ping_interval:e.pingInterval,pong_timeout:e.pongTimeout,reconnect:{interval:e.reconnectInterval,max_interval:e.reconnectMaxInterval,retry_cnt:e.reconnectRetryCount,mul:e.reconnectIntervalMultiple},max_unread_cnt_on_super_group:e.maxUnreadCountOnSuperGroup,profile_image_encryption:e.profileImageEncryption,concurrent_call_limit:e.concurrentCallLimit,back_off_delay:e.backOffDelay})}}]),e}(),Fa=function(e){i(a,e);var n=f(a);function a(e,t,s){var i,o;return r(this,a),(i=n.call(this,e,t,s)).error=null,i.userProfile=new Pa(e,s),i.deviceTokenLastDeletedAt=s.device_token_last_deleted_at,i.key=s.key,i.ekey=null!==(o=s.ekey)&&void 0!==o?o:"",i.error=s.error?new M(s):null,i}return s(a,[{key:"applyTo",value:function(e){return b(this,void 0,void 0,t().mark((function n(){var r,a;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(this.error){t.next=12;break}if(!(r=ns.of(e))){t.next=9;break}return a=r.sessionManager,t.next=6,a.login(this);case 6:this.userProfile.apply(),t.next=10;break;case 9:throw M.lostInstance;case 10:t.next=13;break;case 12:throw this.error;case 13:case"end":return t.stop()}}),n,this)})))}}],[{key:"asError",value:function(e){return new a(null,"LOGI",Object.assign({user_id:null,error:!0},e))}}]),a}(le),Ga=function(e){i(n,e);var t=f(n);function n(e){var a,s=e.request,i=void 0===s||s,o=e.features,u=void 0===o?{}:o,c=e.options,l=void 0===c?{}:c;return r(this,n),(a=t.call(this)).request=i,a.features=Object.assign({localCache:!0},u),a.options=Object.assign({ingestion:!0},l),a}return s(n)}($),Ha=function(e){i(a,e);var n=f(a);function a(e,t){var s,i=t.sdkState,o=t.cacheContext,u=t.connectionHandlers,c=t.sessionManager,l=t.websocketClient,h=t.dispatcher,d=t.logger,f=t.entryState,p=void 0===f?new ya:f;return r(this,a),(s=n.call(this))._currentState=null,s._loginTimer=null,s._unresolvedLogi=null,s._stateUpdatedAt=0,s._connectingAt=0,s._connectionRequestQueue=[],s._iid=e,s.sdkState=i,s.cacheContext=o,s.connectionHandlers=u,s._sessionManager=c,s._websocketClient=l,s._dispatcher=h,s._logger=d,s._currentState=p,s.sdkState.websocket.pingerDisabled||(s._pinger=new ba({pingDelegate:{send:function(e){return s._websocketClient.send(e)},error:function(e){return s._websocketClient.error(e)}},sdkState:s.sdkState,logger:d})),s._websocketClient.on("open",(function(){s._tryResolveConnectionRequest()})).on("message",(function(e){if("LOGI"===e.code)s.clearLoginTimer(),s._dispatcher.dispatch(e.as(Fa))})).on("ping-refresh",(function(){var e;return null===(e=s._pinger)||void 0===e?void 0:e.refreshTimer()})).on("pong",(function(){var e;return null===(e=s._pinger)||void 0===e?void 0:e.pong()})).on("error",(function(){var e;return null===(e=s._pinger)||void 0===e?void 0:e.stop()})).on("close",(function(){return s._rejectConnectionRequest(M.networkError)})),s._dispatcher.on((function(e){e instanceof Fa&&(s._unresolvedLogi=e,s._tryResolveConnectionRequest())})),s}return s(a,[{key:"currentState",get:function(){return this._currentState}},{key:"hasSession",get:function(){return this._sessionManager.auth.hasSession}},{key:"changeState",value:function(e,n){return b(this,void 0,void 0,t().mark((function r(){return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(!(n>=this._stateUpdatedAt)){t.next=8;break}return this._currentState=e,this._stateUpdatedAt=n,this._dispatcher.dispatch(new Dr({stateType:e.type})),this._logger.debug("connection state changes to ".concat(e.name)),t.next=7,this._currentState.run(this);case 7:return t.abrupt("return",!0);case 8:return t.abrupt("return",!1);case 9:case"end":return t.stop()}}),r,this)})))}},{key:"_tryResolveConnectionRequest",value:function(){var e;return b(this,void 0,void 0,t().mark((function n(){var r,a;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(r=this._unresolvedLogi,!this._websocketClient.isOpen||!r){t.next=18;break}if(this._unresolvedLogi=null,r.error){t.next=15;break}return t.next=6,r.applyTo(this._iid);case 6:a=r.userProfile,this._enableStatLog({request:a.appInfo.applicationAttributes.includes("allow_sdk_request_log_publish"),features:{localCache:a.appInfo.applicationAttributes.includes("allow_sdk_feature_local_cache_log_publish")},options:{ingestion:a.appInfo.allowSdkStatsUpload}}),this._statLogConnection(null),null===(e=this._pinger)||void 0===e||e.start(),this._connectionRequestQueue.forEach((function(e){return e.resolve()})),this._connectionRequestQueue=[],this.sdkState.appState="foreground",t.next=18;break;case 15:this._sessionManager.auth.authToken=null,(r.error.isSessionKeyExpiredError||r.error.isSessionTokenExpiredError)&&this._dispatcher.dispatch(new se),this._rejectConnectionRequest(r.error);case 18:case"end":return t.stop()}}),n,this)})))}},{key:"_rejectConnectionRequest",value:function(e){var t;if(null===(t=this._pinger)||void 0===t||t.stop(),this.clearLoginTimer(),this._connectionRequestQueue.length>0){var n=this._connectionRequestQueue;this._connectionRequestQueue=[],n.forEach((function(t){return t.reject(e)})),this._statLogConnection(e)}}},{key:"_url",value:function(){var e,t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"",n=this.sdkState,r=n.appId,a=n.appVersion,s=n.userId,i=n.extensions,o=this.cacheContext.localCacheEnabled,u=this._sessionManager.auth,c=null===(e=this.sdkState.websocket)||void 0===e?void 0:e.compression,l=i.sb_syncmanager?"s".concat(i.sb_syncmanager):"",h=i.sb_uikit?"u".concat(i.sb_uikit):"",d="JS/c".concat(C.SDK_VERSION,"/").concat(l,"/").concat(h);return"".concat(this.sdkState.websocket.host,"/?p=JS&pv=").concat(encodeURIComponent(C.OS_VERSION),"&sv=").concat(encodeURIComponent(C.SDK_VERSION),"&ai=").concat(r).concat(a?"&av=".concat(a):"").concat(u.hasSession?"&key=".concat(encodeURIComponent(u.sessionKey)):"&user_id=".concat(encodeURIComponent(s),"&access_token=").concat(encodeURIComponent(t)),"&pmce=").concat(c?1:0,"&active=1&device_token_types=").concat(encodeURIComponent(["gcm","huawei","apns"].join(",")),"&SB-User-Agent=").concat(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")}},{key:"_enableStatLog",value:function(e){var t=e.request,n=e.features,r=e.options,a=void 0===r?{}:r;this._dispatcher.dispatch(new Ga({request:t,features:n,options:a}))}},{key:"_statLogConnection",value:function(e){this._dispatcher.dispatch(new ie(new oe({type:te.WEBSOCKET_CONNECT,data:{host_url:this.sdkState.websocket.host,success:!e,latency:Date.now()-this._connectingAt,error_code:null==e?void 0:e.code,error_description:null==e?void 0:e.message}})))}},{key:"connect",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"";return b(this,void 0,void 0,t().mark((function n(){var r,a,s=this;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return r=this._url(e),a=new Ur,this._connectionRequestQueue.push(a),1===this._connectionRequestQueue.length&&(this._connectingAt=Date.now(),this._loginTimer=setTimeout((function(){s._loginTimer=null,s._dispatcher.dispatch(Fa.asError(M.loginTimeout))}),this.sdkState.websocket.responseTimeout),e&&(this._sessionManager.auth.authToken=e),this._websocketClient.connect(r)),t.abrupt("return",a.promise);case 5:case"end":return t.stop()}}),n,this)})))}},{key:"cancelConnectForRetry",value:function(){this._dispatcher.dispatch(Fa.asError(M.connectionRenew))}},{key:"disconnect",value:function(){return b(this,void 0,void 0,t().mark((function e(){return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this._websocketClient.disconnect();case 2:case"end":return e.stop()}}),e,this)})))}},{key:"logout",value:function(){return b(this,void 0,void 0,t().mark((function e(){return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return this.sdkState.userId=null,this._unresolvedLogi=null,e.next=4,this._sessionManager.clear();case 4:return e.next=6,this.disconnect();case 6:case"end":return e.stop()}}),e,this)})))}},{key:"clearLoginTimer",value:function(){this._loginTimer&&(clearTimeout(this._loginTimer),this._loginTimer=null)}}]),a}(J),qa=function(){function e(t,n){var a=n.sdkState,s=n.cacheContext,i=n.connectionHandlers,o=n.sessionManager,u=n.websocketClient,c=n.dispatcher,l=n.logger,h=n.disableWebSocketCloseEventHandling,d=void 0!==h&&h;r(this,e),this._context=null,this._disableWebSocketCloseEventHandling=!1,this._externalCalledWebSocketClose=!1,this._logger=l,this._disableWebSocketCloseEventHandling=d,this._context=new Ha(t,{sdkState:a,cacheContext:s,connectionHandlers:i,sessionManager:o,websocketClient:u,dispatcher:c,logger:l}),this._sdkState=a,this._sessionManager=o,this._websocketClient=u}return s(e,[{key:"_registerEventDispatcher",value:function(){var e=this;this._disableWebSocketCloseEventHandling||(this._clearEventDispatcher(),this._sessionEventDispatcherContext=this._sessionManager.on("refresh-authtoken",(function(){e.isConnected||(e._logger.debug("try reconnect by session token refresh"),e.reconnect())})).on("refresh",(function(){e.isConnecting||e.isConnected||(e._logger.debug("try reconnect by session key refresh"),e.reconnect())})),this._websocketEventDispatcherContext=this._websocketClient.on("close",(function(){"foreground"!==e._sdkState.appState||e._externalCalledWebSocketClose||e._sessionManager.isRefreshingAuthToken||(e._logger.debug("try reconnect by websocket connection closed"),e.reconnect())})))}},{key:"_clearEventDispatcher",value:function(){this._sessionEventDispatcherContext&&(this._sessionEventDispatcherContext.close(),this._sessionEventDispatcherContext=null),this._websocketEventDispatcherContext&&(this._websocketEventDispatcherContext.close(),this._websocketEventDispatcherContext=null)}},{key:"isConnected",get:function(){return this._context.currentState.type===Nr.CONNECTED}},{key:"isConnecting",get:function(){var e=this._context.currentState;return e.type===Nr.CONNECTING||e.type===Nr.RECONNECTING}},{key:"connect",value:function(e){return b(this,void 0,void 0,t().mark((function n(){var r;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return r=this._context.currentState,this._externalCalledWebSocketClose=!1,t.next=4,r.onConnect(this._context,e);case 4:this._registerEventDispatcher();case 5:case"end":return t.stop()}}),n,this)})))}},{key:"reconnect",value:function(){return b(this,void 0,void 0,t().mark((function e(){var n;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n=this._context.currentState,this._externalCalledWebSocketClose=!1,e.next=4,n.onReconnect(this._context,{});case 4:case"end":return e.stop()}}),e,this)})))}},{key:"resetAndReconnect",value:function(){return b(this,void 0,void 0,t().mark((function e(){var n;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n=this._context.currentState,this._externalCalledWebSocketClose=!1,e.next=4,n.onReconnect(this._context,{resetReconnectCount:!0});case 4:case"end":return e.stop()}}),e,this)})))}},{key:"background",value:function(){return b(this,void 0,void 0,t().mark((function e(){var n;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n=this._context.currentState,this._externalCalledWebSocketClose=!0,e.next=4,n.onDisconnect(this._context,{autoReconnect:!1});case 4:case"end":return e.stop()}}),e,this)})))}},{key:"disconnect",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:null;return b(this,void 0,void 0,t().mark((function n(){var r;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return r=this._context.currentState,t.next=3,r.onDisconnect(this._context,{error:e,autoReconnect:!0});case 3:case"end":return t.stop()}}),n,this)})))}},{key:"disconnectWebSocket",value:function(){return b(this,void 0,void 0,t().mark((function e(){var n;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n=this._context.currentState,this._externalCalledWebSocketClose=!0,e.next=4,n.onDisconnectWebSocket(this._context);case 4:case"end":return e.stop()}}),e,this)})))}},{key:"logout",value:function(){return b(this,void 0,void 0,t().mark((function e(){var n;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n=this._context.currentState,this._clearEventDispatcher(),e.next=4,n.onLogout(this._context);case 4:case"end":return e.stop()}}),e,this)})))}}]),e}(),ja=function(e){i(n,e);var t=f(n);function n(e){var a,s,i,o,u,c=e.type,l=e.data,h=e.ts,d=void 0===h?Date.now():h;return r(this,n),(a=t.call(this,{type:c,data:l,ts:d})).date=new Date(d),a.key="".concat((s=a.date,i=s.getFullYear(),o=String(s.getMonth()+1).padStart(2,"0"),u=String(s.getDate()).padStart(2,"0"),"".concat(i).concat(o).concat(u)),"_").concat(c),a}return s(n)}(oe),za=function(e){i(n,e);var t=f(n);function n(e){var a,s=e.deviceId,i=e.statLogs;return r(this,n),(a=t.call(this)).method=B.POST,a.path="".concat($r),a.params={device_id:s,log_entries:i.map((function(e){return oe.payloadify(e)}))},a}return s(n)}(ne),Va=function e(t,r){if(null!==t&&null!==r){var a,s=Object.keys(t),i=Object.keys(r),o={},u=y(_(new Set([].concat(s,i))));try{for(u.s();!(a=u.n()).done;){var c=a.value,l=n(t[c]),h=n(r[c]);"undefined"===l?o[c]=r[c]:"undefined"===h?o[c]=t[c]:l!==h?o[c]=r[c]:"object"===l&&t[c]&&r[c]?o[c]=e(t[c],r[c]):o[c]=r[c]}}catch(e){u.e(e)}finally{u.f()}return o}return r};!function(e){e[e.PENDING=0]="PENDING",e[e.COLLECT_ONLY=1]="COLLECT_ONLY",e[e.ENABLED=2]="ENABLED",e[e.DISABLED=3]="DISABLED"}(Ra||(Ra={}));var Ba,Qa=function(e){i(a,e);var n=f(a);function a(e){var t,s=e.cacheContext,i=e.requestQueue,o=e.dispatcher,u=e.baseLimit,c=void 0===u?100:u,l=e.maxLimit,h=void 0===l?1e3:l,d=e.minLimit,f=void 0===d?10:d;return r(this,a),(t=n.call(this)).queue=[],t.enabledState=Ra.PENDING,t.isFlushing=!1,t.generation=1,t.lastFlushedAt=0,t.commandEventContext=null,t._collectRequestStat=!0,t._collectFeatureLocalCacheStat=!0,t.deviceId=Y(),t.cacheContext=s,t.requestQueue=i,t.dispatcher=o,t.baseLimit=c,t.limit=c,t.maxLimit=h,t.minLimit=f,t}return s(a,[{key:"isEnabled",get:function(){return this.enabledState===Ra.ENABLED}},{key:"_arrangeStat",value:function(){var e=[];this._collectRequestStat&&e.push.apply(e,_(this.queue.filter((function(e){return e.type===te.API_RESULT||e.type===te.WEBSOCKET_CONNECT})))),this._collectFeatureLocalCacheStat&&e.push.apply(e,_(this.queue.filter((function(e){return e.type===te.FEATURE_LOCALCACHE})))),this.queue=e}},{key:"_save",value:function(){return b(this,void 0,void 0,t().mark((function e(){return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(this.enabledState!==Ra.ENABLED){e.next=4;break}return e.next=3,this.cacheContext.preference.set(this.key,{deviceId:this.deviceId,statLogs:this.queue.map((function(e){return oe.payloadify(e)})),generation:this.generation++,lastFlushedAt:this.lastFlushedAt});case 3:this.dispatch("save",_(this.queue));case 4:case"end":return e.stop()}}),e,this)})))}},{key:"_flush",value:function(){return b(this,void 0,void 0,t().mark((function e(){var n,r,a,s;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!this.isEnabled){e.next=34;break}if(this.isFlushing){e.next=34;break}if(this.isFlushing=!0,e.prev=3,this._arrangeStat(),n=this.queue.filter((function(e){if(e instanceof ja){var t=new Date,n=[e.date.getFullYear(),t.getFullYear()],r=n[0],a=n[1];if(r0)){e.next=16;break}return s=new za({deviceId:this.deviceId,statLogs:a}),e.next=12,this.requestQueue.send(s);case 12:return this.dispatch("flush",a),this.queue=[].concat(_(n),_(r)).slice(a.length),e.next=16,this._save();case 16:this.limit=this.baseLimit,this.lastFlushedAt=Date.now(),e.next=31;break;case 20:if(e.prev=20,e.t0=e.catch(3),!(e.t0 instanceof M)){e.next=30;break}if(e.t0.code!==E.STAT_LOG_NOT_ALLOWED){e.next=29;break}return e.next=26,this.clear();case 26:this.enabledState=Ra.DISABLED,e.next=30;break;case 29:e.t0.code===E.STAT_UPLOAD_NOT_ALLOWED&&(this.enabledState=Ra.COLLECT_ONLY);case 30:this.limit=this.limit+20;case 31:return e.prev=31,this.isFlushing=!1,e.finish(31);case 34:case"end":return e.stop()}}),e,this,[[3,20,31,34]])})))}},{key:"init",value:function(e){return b(this,void 0,void 0,t().mark((function n(){var r,a,s=this;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return this.key=e,t.next=3,this.cacheContext.preference.get(this.key);case 3:if(!(r=t.sent)){t.next=15;break}if(this.deviceId=r.deviceId,this.queue=r.statLogs.map((function(e){return new oe({type:e.stat_type,ts:e.ts,data:e.data})})),this.generation=r.generation,this.lastFlushedAt=r.lastFlushedAt,!(Date.now()-this.lastFlushedAt>=108e5&&this.queue.length>=this.minLimit)){t.next=15;break}return a=Math.min(Math.floor(18e4*Math.random()),100),t.next=13,sa(a);case 13:return t.next=15,this._flush();case 15:this.commandEventContext||(this.commandEventContext=this.dispatcher.on((function(e){if(e instanceof ie){var t=e.statLog;s.put(t)}else if(e instanceof Ga){var n=e.request,r=e.features,a=e.options;s._collectRequestStat=n,s._collectFeatureLocalCacheStat=null==r?void 0:r.localCache,s._arrangeStat(),s._collectRequestStat||s._collectFeatureLocalCacheStat?s.enabledState=a.ingestion?Ra.ENABLED:Ra.COLLECT_ONLY:s.enabledState=Ra.DISABLED,s.isEnabled?s.queue.length>=s.limit&&s._flush():s.clear()}})));case 16:case"end":return t.stop()}}),n,this)})))}},{key:"put",value:function(e){return b(this,void 0,void 0,t().mark((function n(){var r,a,s;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(this.enabledState===Ra.DISABLED){t.next=7;break}return e instanceof ja?this._collectFeatureLocalCacheStat&&(r=this.queue.filter((function(t){return t instanceof ja&&t.key===e.key})),a=v(r,1),(s=a[0])?s.data=Va(s.data,e.data):this.queue.push(e)):this._collectRequestStat&&this.queue.push(e),t.next=4,this._save();case 4:if(!(this.queue.length>=this.limit)){t.next=7;break}return t.next=7,this._flush();case 7:case"end":return t.stop()}}),n,this)})))}},{key:"clear",value:function(){return b(this,void 0,void 0,t().mark((function e(){return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return this.queue=[],this.generation=1,e.next=4,this._save();case 4:case"end":return e.stop()}}),e,this)})))}},{key:"close",value:function(){this.commandEventContext&&(this.commandEventContext.close(),this.commandEventContext=null)}}]),a}(J);e.LogLevel=void 0,(Ba=e.LogLevel||(e.LogLevel={}))[Ba.NONE=0]="NONE",Ba[Ba.VERBOSE=1]="VERBOSE",Ba[Ba.DEBUG=2]="DEBUG",Ba[Ba.INFO=3]="INFO",Ba[Ba.WARN=4]="WARN",Ba[Ba.ERROR=5]="ERROR";var Ka,Wa,Ya,Za,Ja,Xa,$a,es=function(){function t(){r(this,t),this.level=e.LogLevel.WARN}return s(t,[{key:"verbose",value:function(){if(this.level<=e.LogLevel.VERBOSE){for(var t,n=arguments.length,r=new Array(n),a=0;a0&&L("number",i)&&(this.key=a,this.userIds=s,this.updatedAt=i);var o,u={},c=y(this.userIds);try{for(c.s();!(o=c.n()).done;){u[o.value]=this.updatedAt}}catch(e){c.e(e)}finally{c.f()}this._version=u}return s(t,[{key:"isEmpty",get:function(){return 0===this.userIds.length}},{key:"applyEvent",value:function(t){if(t.key===this.key&&this.updatedAt<=t.updatedAt){if(!this._version[t.userId]||this._version[t.userId]<=t.updatedAt){var n=this.userIds.indexOf(t.userId);switch(t.operation){case e.ReactionEventOperation.ADD:n<0&&this.userIds.push(t.userId);break;case e.ReactionEventOperation.DELETE:n>=0&&this.userIds.splice(n,1)}this._version[t.userId]=t.updatedAt}this.updatedAt=Math.max(this.updatedAt,t.updatedAt)}}}],[{key:"payloadify",value:function(e){return e?ee({key:e.key,user_ids:e.userIds,updated_at:e.updatedAt}):null}}]),t}(),ps=function(){function e(t){r(this,e),this.key=t.key,this.value=F("string",t.value)?_(t.value):[]}return s(e,null,[{key:"payloadify",value:function(e){var t;return e?ee({key:e.key,value:null!==(t=e.value)&&void 0!==t?t:[]}):null}}]),e}(),vs=function(){function e(t){r(this,e),this.url=null,this.secureUrl=null,this.type=null,this.width=0,this.height=0,this.alt=null,this.url=t.url,t.hasOwnProperty("secure_url")&&(this.secureUrl=t.secure_url),t.hasOwnProperty("type")&&(this.type=t.type),t.hasOwnProperty("width")&&(this.width=t.width),t.hasOwnProperty("height")&&(this.height=t.height),t.hasOwnProperty("alt")&&(this.alt=t.alt)}return s(e,null,[{key:"payloadify",value:function(e){var t,n;return e?ee({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}(),_s=function(){function e(t){r(this,e),this.title=null,this.url=null,this.description=null,this.defaultImage=null,t.hasOwnProperty("og:title")&&(this.title=t["og:title"]),t.hasOwnProperty("og:url")&&(this.url=t["og:url"]),t.hasOwnProperty("og:description")&&(this.description=t["og:description"]),t.hasOwnProperty("og:image")&&(this.defaultImage=new vs(t["og:image"]))}return s(e,null,[{key:"payloadify",value:function(e){return e?ee({"og:title":e.title,"og:url":e.url,"og:description":e.description,"og:image":e.defaultImage?vs.payloadify(e.defaultImage):null}):null}}]),e}(),ms=function(){function e(t){var n,a;r(this,e),this.name=null,this.volume=0,this.name=null!==(n=t.name)&&void 0!==n?n:"default",this.volume=null!==(a=t.volume)&&void 0!==a?a:1}return s(e,[{key:"serialize",value:function(){return{name:this.name,volume:this.volume}}}],[{key:"payloadify",value:function(e){return e?ee({name:e.name,volume:e.volume}):null}}]),e}();e.ChannelType=void 0,(us=e.ChannelType||(e.ChannelType={})).BASE="base",us.GROUP="group",us.OPEN="open",e.Role=void 0,(cs=e.Role||(e.Role={})).OPERATOR="operator",cs.NONE="none",e.ScheduledStatus=void 0,(ls=e.ScheduledStatus||(e.ScheduledStatus={})).PENDING="pending",ls.SENT="sent",ls.FAILED="failed",ls.CANCELED="canceled",function(e){e.PENDING="pending",e.IN_QUEUE="in_queue",e.SENT="sent",e.FAILED="failed",e.CANCELED="canceled",e.REMOVED="removed"}(hs||(hs={}));var gs,ys=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"}},ks=function(t){i(a,t);var n=f(a);function a(t,s){var i,o,u,c,l,h,d,f,p,v,_,m,g,y,k,b;r(this,a),(i=n.call(this,t)).channelUrl=null,i.channelType=e.ChannelType.BASE,i.messageId=0,i.parentMessageId=null,i.parentMessage=null,i.silent=!1,i.isOperatorMessage=!1,i.messageType=e.MessageType.BASE,i.data=null,i.customType=null,i.mentionType=null,i.mentionedUsers=[],i.mentionedUserIds=[],i.mentionedMessageTemplate=null,i.threadInfo=null,i.reactions=[],i.metaArrays=[],i.ogMetaData=null,i.appleCriticalAlertOptions=null,i.createdAt=0,i.updatedAt=0,i.scheduledInfo=null,i.extendedMessage={},i._isContinuousMessages=!1,i._scheduledStatus=null,i.messageId=null!==(u=null!==(o=s.msg_id)&&void 0!==o?o:s.message_id)&&void 0!==u?u:0,i.channelUrl=s.channel_url,i.channelType=D(e.ChannelType,s.channel_type)?s.channel_type:e.ChannelType.GROUP,s.channel&&(s.channel.channel_url&&(i.channelUrl=s.channel.channel_url),s.channel.channel_type&&(i.channelType=s.channel.channel_type)),i.parentMessageId=null!==(c="string"==typeof s.parent_message_id?parseInt(s.parent_message_id):s.parent_message_id)&&void 0!==c?c:0,i.data=null!==(l=s.data)&&void 0!==l?l:"",i.customType=null!==(h=s.custom_type)&&void 0!==h?h:"",i.mentionType=D(e.MentionType,s.mention_type)?s.mention_type:null;var E=s.mentioned_users;i.mentionedUsers=E?E.map((function(e){return new La(i._iid,e)})):null;var w=s.mentioned_user_ids;i.mentionedUserIds=null!=w?w:null,i.mentionedUsers&&!i.mentionedUserIds&&(i.mentionedUserIds=i.mentionedUsers.map((function(e){return e.userId}))),i.mentionedMessageTemplate=null!==(d=s.mentioned_message_template)&&void 0!==d?d:"",i.threadInfo=s.thread_info?new os(i._iid,s.thread_info):null,i.reactions=s.reactions?s.reactions.map((function(e){return new fs(e)})):[];for(var C=null!==(f=s.metaarray)&&void 0!==f?f:{},x=null!==(p=s.metaarray_key_order)&&void 0!==p?p:Object.keys(C).sort((function(e,t){return e.localeCompare(t)})),T=0;T=t)return this.parentMessage=e,!0}return!1}}],[{key:"payloadify",value:function(e){var t,n,r,s;return e?ee(Object.assign(Object.assign({},p(o(a),"payloadify",this).call(this,e)),{channel_url:e.channelUrl,channel_type:e.channelType,message_id:e.messageId,type:ys(e.messageType),parent_message_id:e.parentMessageId,data:e.data,custom_type:e.customType,mention_type:e.mentionType,mentioned_user_ids:e.mentionedUserIds,mentioned_users:null===(t=e.mentionedUsers)||void 0===t?void 0:t.map((function(e){return La.payloadify(e)})),mentioned_message_template:e.mentionedMessageTemplate,thread_info:e.threadInfo?os.payloadify(e.threadInfo):null,reactions:e.reactions.map((function(e){return fs.payloadify(e)})),sorted_metaarray:null===(n=e.metaArrays)||void 0===n?void 0:n.map((function(e){return ps.payloadify(e)})),og_tag:_s.payloadify(e.ogMetaData),silent:e.silent,is_op_msg:e.isOperatorMessage,apple_critical_alert_options:ms.payloadify(e.appleCriticalAlertOptions),created_at:e.createdAt,updated_at:e.updatedAt,scheduled_message_id:null===(r=e.scheduledInfo)||void 0===r?void 0:r.scheduledMessageId,scheduled_at:null===(s=e.scheduledInfo)||void 0===s?void 0:s.scheduledAt,scheduled_status:e._scheduledStatus,extended_message:e.extendedMessage})):null}}]),a}(Ca),bs=function(t){i(a,t);var n=f(a);function a(t,s){var i;return r(this,a),(i=n.call(this,t,s)).role=null,i.isBlockedByMe=!1,i.role=D(e.Role,s.role)?s.role:e.Role.NONE,s.hasOwnProperty("is_blocked_by_me")&&(i.isBlockedByMe=s.is_blocked_by_me),i}return s(a,null,[{key:"payloadify",value:function(e){return e?ee(Object.assign(Object.assign({},p(o(a),"payloadify",this).call(this,e)),{role:e.role,is_blocked_by_me:e.isBlockedByMe})):null}}]),a}(La),Es=function(t){i(a,t);var n=f(a);function a(t,s){var i,o,u,c,l;if(r(this,a),(i=n.call(this,t,s)).sender=null,i.reqId="",i.replyToChannel=!1,i.sendingStatus=null,i.errorCode=0,i.sender=s.user?new bs(i._iid,s.user):s.sender_id,i.reqId=null!==(u=null!==(o=s.req_id)&&void 0!==o?o:s.request_id)&&void 0!==u?u:"",i.replyToChannel=null!==(c=s.is_reply_to_channel)&&void 0!==c&&c,s.request_state&&D(e.SendingStatus,s.request_state)&&(i.sendingStatus=s.request_state),!i.sendingStatus)if(i.messageId>0)i.sendingStatus=e.SendingStatus.SUCCEEDED;else if(i.scheduledInfo)switch(i._scheduledStatus=s.scheduled_status,s.scheduled_status){case hs.SENT:case hs.IN_QUEUE:i.sendingStatus=e.SendingStatus.SUCCEEDED;break;case hs.PENDING:i.sendingStatus=e.SendingStatus.SCHEDULED;break;case hs.FAILED:case hs.REMOVED:i.sendingStatus=e.SendingStatus.FAILED;break;case hs.CANCELED:i.sendingStatus=e.SendingStatus.CANCELED}else i.sendingStatus=e.SendingStatus.PENDING;return i.errorCode=null!==(l=s.error_code)&&void 0!==l?l:0,i}return s(a,[{key:"isResendable",get:function(){return this.sendingStatus===e.SendingStatus.FAILED&&((t=this.errorCode)>0&&O.indexOf(t)>=0);var t}},{key:"isIdentical",value:function(e){return this.messageId>0&&e.messageId>0?this.messageId===e.messageId:this.reqId===e.reqId}}],[{key:"payloadify",value:function(e){return e?ee(Object.assign(Object.assign({},p(o(a),"payloadify",this).call(this,e)),{user:bs.payloadify(e.sender),req_id:e.reqId,is_reply_to_channel:e.replyToChannel,request_state:e.sendingStatus,error_code:e.errorCode})):null}}]),a}(ks),ws=function(){function e(t){var n,a;r(this,e),this.url=null,this.width=0,this.height=0,this.realWidth=0,this.realHeight=0,this.url=t.url,this.width=t.width,this.height=t.height,this.realWidth=null!==(n=t.real_width)&&void 0!==n?n:t.width,this.realHeight=null!==(a=t.real_height)&&void 0!==a?a:t.height}return s(e,[{key:"plainUrl",get:function(){return this.url.split("?auth=")[0]}}],[{key:"payloadify",value:function(e){return e?ee({url:"",width:e.maxWidth,height:e.maxHeight,real_width:0,real_height:0}):null}}]),e}(),Cs={prevResultSize:0,nextResultSize:0,isInclusive:!1,reverse:!1,messageTypeFilter:e.MessageTypeFilter.ALL,customTypesFilter:null,senderUserIdsFilter:null,includeReactions:!1,includeMetaArray:!1,includeParentMessageInfo:!1},xs=function(t){return L("number",t.prevResultSize)&&L("number",t.nextResultSize)&&L("boolean",t.isInclusive)&&L("boolean",t.reverse)&&L("string",t.messageTypeFilter)&&D(e.MessageTypeFilter,t.messageTypeFilter)&&F("string",t.customTypesFilter,!0)&&F("string",t.senderUserIdsFilter,!0)&&L("boolean",t.includeMetaArray)&&L("boolean",t.includeReactions)&&L("boolean",t.includeParentMessageInfo)},Ts=function(n){i(u,n);var a=f(u);function u(t,n){var s,i,o,c,l;if(r(this,u),(s=a.call(this,t,n)).message=null,s.translations={},s.message=null!==(i=n.message)&&void 0!==i?i:"",s.messageType=e.MessageType.ADMIN,s.translations=null!==(o=n.translations)&&void 0!==o?o:{},n.parent_message_info){var h=n.parent_message_info,d=Object.assign(Object.assign({},h),{message_id:s.parentMessageId,channel_url:s.channelUrl,channel_type:s.channelType,file:h.file,url:null===(c=h.file)||void 0===c?void 0:c.url,require_auth:null===(l=h.file)||void 0===l?void 0:l.require_auth});s.parentMessage=Ds(t,d)}return s}return s(u,[{key:"getThreadedMessagesByTimestamp",value:function(e,n){return b(this,void 0,void 0,t().mark((function r(){var a,s;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return a=Object.assign(Object.assign({},Cs),n),Ua(this.messageId>0&&L("number",e)&&xs(a)).throw(M.invalidParameters),s=vi.of(this._iid),t.next=5,s.getThreadedMessagesByTimestamp(this,e,a);case 5:return t.abrupt("return",t.sent);case 6:case"end":return t.stop()}}),r,this)})))}}],[{key:"payloadify",value:function(e){return e?ee(Object.assign(Object.assign({},p(o(u),"payloadify",this).call(this,e)),{message:e.message,translations:e.translations,parent_message_info:Ls(e.parentMessage)})):null}}]),u}(ks),Ss=function(){function e(t){var n,a;r(this,e),this.type=null,this.vendor=null,this.detail={},this.type=null!==(n=t.type)&&void 0!==n?n:"",this.vendor=null!==(a=t.vendor)&&void 0!==a?a:"",t.hasOwnProperty("detail")&&L("object",t.detail)&&!Array.isArray(t.detail)&&(this.detail=t.detail)}return s(e,null,[{key:"payloadify",value:function(e){return e?ee({type:e.type,vendor:e.vendor,detail:e.detail}):null}}]),e}();!function(e){e.OPEN="open",e.CLOSED="closed"}(gs||(gs={}));var Is,Ns="removed",As=function(e){switch(e){case gs.OPEN:return gs.OPEN;case gs.CLOSED:return gs.CLOSED}},Ms=function(e){return!e||e.text&&L("string",e.text)},Os=function(e){i(n,e);var t=f(n);function n(e,a){var s,i,o,u,c,l,h,d;return r(this,n),(s=t.call(this,e)).pollId=0,s.id=0,s.text=null,s.voteCount=0,s.createdBy=null,s.createdAt=0,s.updatedAt=0,s._lastVotedAt=0,s.pollId=null!==(i=a.poll_id)&&void 0!==i?i:0,s.id=null!==(o=a.id)&&void 0!==o?o:0,s.text=null!==(u=a.text)&&void 0!==u?u:null,s.voteCount=null!==(c=a.vote_count)&&void 0!==c?c:0,s.createdBy=null!==(l=a.created_by)&&void 0!==l?l:null,s.createdAt=null!==(h=a.created_at)&&void 0!==h?h:0,s.updatedAt=null!==(d=a.updated_at)&&void 0!==d?d:0,s}return s(n,null,[{key:"payloadify",value:function(e){return e?ee(Object.assign(Object.assign({},p(o(n),"payloadify",this).call(this,e)),{vote_count:e.voteCount,poll_id:e.pollId,text:e.text,created_at:e.createdAt,id:e.id,created_by:e.createdBy,updated_at:e.updatedAt})):null}}]),n}(Ca),Us=function(e){i(n,e);var t=f(n);function n(e,a){var s,i,o,u,c,l,h,d,f,p,v,_,m,g;return r(this,n),(s=t.call(this,e)).id=0,s.title=null,s.createdAt=0,s.updatedAt=0,s.closeAt=-1,s.status=gs.CLOSED,s.messageId=0,s.data=null,s.voterCount=-1,s.options=[],s.createdBy=null,s.allowUserSuggestion=!1,s.allowMultipleVotes=!1,s.votedPollOptionIds=[],s.id=null!==(i=a.id)&&void 0!==i?i:0,s.title=null!==(o=a.title)&&void 0!==o?o:null,s.createdAt=null!==(u=a.created_at)&&void 0!==u?u:0,s.updatedAt=null!==(c=a.updated_at)&&void 0!==c?c:0,s.closeAt=null!==(l=a.close_at)&&void 0!==l?l:-1,s.status=null!==(h=As(a.status))&&void 0!==h?h:gs.CLOSED,s.messageId=null!==(d=a.message_id)&&void 0!==d?d:0,s.data=null!==(f=a.data)&&void 0!==f?f:null,s.voterCount=null!==(p=a.voter_count)&&void 0!==p?p:-1,s.options=a.options?a.options.map((function(e){return new Os(s._iid,e)})):[],s.createdBy=null!==(v=a.created_by)&&void 0!==v?v:null,s.allowUserSuggestion=null!==(_=a.allow_user_suggestion)&&void 0!==_&&_,s.allowMultipleVotes=null!==(m=a.allow_multiple_votes)&&void 0!==m&&m,s.votedPollOptionIds=null!==(g=a.voted_option_ids)&&void 0!==g?g:[],s}return s(n,[{key:"_applyPollUpdatePayload",value:function(e){var t,n,r,a,s,i,o,u,c=this;this.title=null!==(t=e.title)&&void 0!==t?t:this.title,this.updatedAt=null!==(n=e.updated_at)&&void 0!==n?n:this.updatedAt,this.closeAt=null!==(r=e.close_at)&&void 0!==r?r:this.closeAt,this.status=null!==(a=As(e.status))&&void 0!==a?a:this.status,this.data=null!==(s=e.data)&&void 0!==s?s:this.data,this.voterCount=null!==(i=e.voter_count)&&void 0!==i?i:this.voterCount,e.options&&(this.options=e.options.map((function(e){return new Os(c._iid,e)})),this.votedPollOptionIds=e.options.filter((function(e){return e.vote_count>0})).map((function(e){return e.id}))),this.allowUserSuggestion=null!==(o=e.allow_user_suggestion)&&void 0!==o?o:this.allowUserSuggestion,this.allowMultipleVotes=null!==(u=e.allow_multiple_votes)&&void 0!==u?u:this.allowMultipleVotes}},{key:"applyPollUpdateEvent",value:function(e){var t=e._payload.poll;return!(!t||this.id!==t.id||t.updated_at-1){var s=t[r];a>=s._lastVotedAt&&(s.voteCount=e.vote_count,s._lastVotedAt=a)}})),r.req_id&&r.voted_option_ids&&(this.votedPollOptionIds=r.voted_option_ids),!0}},{key:"serialize",value:function(){return Ma(this)}}],[{key:"payloadify",value:function(e){return e?ee(Object.assign(Object.assign({},p(o(n),"payloadify",this).call(this,e)),{id:e.id,title:e.title,created_at:e.createdAt,updated_at:e.updatedAt,close_at:e.closeAt,status:e.status,message_id:e.messageId,data:e.data,voter_count:e.voterCount,options:e.options.map((function(e){return Os.payloadify(e)})),created_by:e.createdBy,allow_user_suggestion:e.allowUserSuggestion,allow_multiple_votes:e.allowMultipleVotes,voted_option_ids:e.votedPollOptionIds})):null}}]),n}(Ca),Rs=function(n){i(u,n);var a=f(u);function u(t,n){var s,i,o,c,l,h;if(r(this,u),(s=a.call(this,t,n)).message="",s.messageParams=null,s.translations={},s.translationTargetLanguages=[],s.messageSurvivalSeconds=-1,s.plugins=[],s._poll=null,s.message=n.message,s.messageType=e.MessageType.USER,s.translations=null!==(i=n.translations)&&void 0!==i?i:{},s.translationTargetLanguages=null!==(o=n.target_langs)&&void 0!==o?o:[],0===Object.keys(s.translations).length&&s.translationTargetLanguages.length>0){var d,f=y(s.translationTargetLanguages);try{for(f.s();!(d=f.n()).done;){var p=d.value;s.translations[p]=""}}catch(e){f.e(e)}finally{f.f()}}if(s.messageSurvivalSeconds=null!==(c=n.message_survival_seconds)&&void 0!==c?c:-1,s.plugins=n.plugins?n.plugins.map((function(e){return new Ss(e)})):[],s._poll=n.poll?new Us(s._iid,n.poll):null,n.parent_message_info){var v=n.parent_message_info,_=Object.assign(Object.assign({},v),{created_at:v.ts,message_id:s.parentMessageId,channel_url:s.channelUrl,channel_type:s.channelType,file:v.file,url:null===(l=v.file)||void 0===l?void 0:l.url,require_auth:null===(h=v.file)||void 0===h?void 0:h.require_auth});s.parentMessage=Ds(t,ee(_))}return s}return s(u,[{key:"getThreadedMessagesByTimestamp",value:function(e,n){return b(this,void 0,void 0,t().mark((function r(){var a,s;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return a=Object.assign(Object.assign({},Cs),n),Ua(this.messageId>0&&L("number",e)&&xs(a)).throw(M.invalidParameters),s=vi.of(this._iid),t.next=5,s.getThreadedMessagesByTimestamp(this,e,a);case 5:return t.abrupt("return",t.sent);case 6:case"end":return t.stop()}}),r,this)})))}},{key:"applyPoll",value:function(e){return!(this._poll&&this._poll.id===e.id&&this._poll.updatedAt>e.updatedAt)&&(this._poll=e,!0)}},{key:"poll",get:function(){return this._poll}}],[{key:"payloadify",value:function(e){return e?ee(Object.assign(Object.assign({},p(o(u),"payloadify",this).call(this,e)),{message:e.message,translations:e.translations,message_survival_seconds:e.messageSurvivalSeconds,plugins:e.plugins.map((function(e){return Ss.payloadify(e)})),poll:Us.payloadify(e._poll),parent_message_info:Ls(e.parentMessage)})):null}}]),u}(Es),Ls=function(t){if(t)switch(t.messageType){case e.MessageType.USER:return Rs.payloadify(t);case e.MessageType.FILE:return Ps.payloadify(t);case e.MessageType.ADMIN:return Ts.payloadify(t)}return null},Ds=function(e,t){switch(t.type){case"MESG":return new Rs(e,t);case"FILE":return new Ps(e,t);case"ADMM":case"BRDM":return new Ts(e,t)}return null},Ps=function(n){i(u,n);var a=f(u);function u(t,n){var s,i,o,c,l,h,d,f,p,v,_,m,g,y,k,b;r(this,u),(s=a.call(this,t,n)).messageParams=null,s.plainUrl="",s.requireAuth=!1,s.name=null,s.size=0,s.type=null,s.thumbnails=[],s.messageSurvivalSeconds=-1,s.messageType=e.MessageType.FILE;var E=null!==(i=n.file)&&void 0!==i?i:null;s.plainUrl=(null!==(c=null!==(o=null==E?void 0:E.url)&&void 0!==o?o:n.url)&&void 0!==c?c:"").split("?auth=")[0],s.name=null!==(h=null!==(l=null==E?void 0:E.name)&&void 0!==l?l:n.name)&&void 0!==h?h:"File",s.size=null!==(f=null!==(d=null==E?void 0:E.size)&&void 0!==d?d:n.size)&&void 0!==f?f:0,s.data=null!==(v=null!==(p=null==E?void 0:E.data)&&void 0!==p?p:n.custom)&&void 0!==v?v:"",s.type=E?null!==(_=E.type)&&void 0!==_?_:"":null!==(m=n.type)&&void 0!==m?m:"";var w=ns.of(s._iid).sessionManager;if(s.requireAuth=null!==(g=n.require_auth)&&void 0!==g&&g,s.thumbnails=n.thumbnails?n.thumbnails.map((function(e){return new ws(Object.assign(Object.assign({},e),{url:"".concat(e.url.split("?auth=")[0]).concat(s.requireAuth?"?auth=".concat(w.ekey):"")}))})):[],s.messageSurvivalSeconds=null!==(y=n.message_survival_seconds)&&void 0!==y?y:-1,n.parent_message_info){var C=n.parent_message_info,x=Object.assign(Object.assign({},C),{message_id:s.parentMessageId,channel_url:s.channelUrl,channel_type:s.channelType,file:C.file,url:null===(k=C.file)||void 0===k?void 0:k.url,require_auth:null===(b=C.file)||void 0===b?void 0:b.require_auth});s.parentMessage=Ds(t,x)}return s}return s(u,[{key:"url",get:function(){var e=ns.of(this._iid).sessionManager;return this.requireAuth?"".concat(this.plainUrl,"?auth=").concat(e.ekey):this.plainUrl}},{key:"getThreadedMessagesByTimestamp",value:function(e,n){return b(this,void 0,void 0,t().mark((function r(){var a,s;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return a=Object.assign(Object.assign({},Cs),n),Ua(this.messageId>0&&L("number",e)&&xs(a)).throw(M.invalidParameters),s=vi.of(this._iid),t.next=5,s.getThreadedMessagesByTimestamp(this,e,a);case 5:return t.abrupt("return",t.sent);case 6:case"end":return t.stop()}}),r,this)})))}}],[{key:"payloadify",value:function(e){return e?ee(Object.assign(Object.assign({},p(o(u),"payloadify",this).call(this,e)),{url:e.plainUrl,require_auth:e.requireAuth,file:{name:e.name,size:e.size,type:e.type,data:e.data},thumbnails: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:Ls(e.parentMessage)})):null}}]),u}(Es),Fs=function(t){switch(t){case e.ChannelType.GROUP:return zr;case e.ChannelType.OPEN:return Br;default:return null}},Gs=function(t){switch(t){case e.ChannelType.GROUP:return"".concat(Wr,"/group_channels");case e.ChannelType.OPEN:return"".concat(Wr,"/open_channels");default:return null}},Hs=function(t,n,r){switch(t){case e.MentionType.CHANNEL:return!0;case e.MentionType.USERS:if(n){var a,s=y(n);try{for(s.s();!(a=s.n()).done;){if(a.value===r)return!0}}catch(e){s.e(e)}finally{s.f()}}}return!1},qs=function(e,t,n){var r=Hs(e.mentionType,e.mentionedUserIds,n),a=Hs(t.mentionType,t.mentionedUserIds,n);return!r&&a?1:r&&!a?-1:0},js=function(t){i(a,t);var n=f(a);function a(t){var s,i,o;r(this,a);var u=[];return t.mentionType===e.MentionType.USERS&&(t.mentionedUserIds?u=t.mentionedUserIds:t.mentionedUsers&&(u=t.mentionedUsers.map((function(e){return e.userId})))),n.call(this,{code:"FILE",ackRequired:!0,payload:ee({channel_url:t.channelUrl,url:t.url,name:null!==(s=t.fileName)&&void 0!==s?s:"",type:null!==(i=t.mimeType)&&void 0!==i?i:"",size:null!==(o=t.fileSize)&&void 0!==o?o:0,custom:t.data,custom_type:t.customType,thumbnails:t.thumbnailSizes,require_auth:t.requireAuth,metaarray:t.metaArrays,mention_type:t.mentionType,mentioned_user_ids:u,push_option:t.pushNotificationDeliveryOption&&t.pushNotificationDeliveryOption!==e.PushNotificationDeliveryOption.DEFAULT?t.pushNotificationDeliveryOption:void 0,apple_critical_alert_options:t.appleCriticalAlertOptions,silent:t.silent,reply_to_channel:t.isReplyToChannel,parent_message_id:t.parentMessageId>0?t.parentMessageId:null,req_id:t.reqId,pin_message:t.isPinnedMessage})})}return s(a)}(Mr),zs=function(t){i(a,t);var n=f(a);function a(t){var s,i;r(this,a),s=n.call(this);var o=[];return t.mentionType===e.MentionType.USERS&&(t.mentionedUserIds?o=t.mentionedUserIds:t.mentionedUsers&&(o=t.mentionedUsers.map((function(e){return e.userId})))),s.method=B.POST,s.path="".concat(Fs(t.channelType),"/").concat(encodeURIComponent(t.channelUrl),"/messages"),s.params=ee({message_type:e.MessageType.FILE,user_id:t.userId,url:t.fileUrl,mention_type:t.mentionType,mentioned_user_ids:o,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 ws.payloadify(e)})),require_auth:t.requireAuth,sorted_metaarray:null===(i=t.metaArrays)||void 0===i?void 0:i.map((function(e){return ps.payloadify(e)})),push_option:t.pushNotificationDeliveryOption,parent_message_id:t.parentMessageId>0?t.parentMessageId:null,apple_critical_alert_options:ms.payloadify(t.appleCriticalAlertOptions),reply_to_channel:t.isReplyToChannel,req_id:t.reqId,pin_message:t.isPinnedMessage}),s}return s(a)}(ne),Vs=function(e){i(n,e);var t=f(n);function n(e,a,s){var i,o,u,c;r(this,n),(i=t.call(this,e,"FILE",s)).message=new Ps(e,s);var l=ns.of(e).sdkState;return i.isMentioned=Hs(i.message.mentionType,null!==(o=i.message.mentionedUserIds)&&void 0!==o?o:null===(u=i.message.mentionedUsers)||void 0===u?void 0:u.map((function(e){return e.userId})),l.userId),i.forceUpdateLastMessage=null!==(c=s.force_update_last_message)&&void 0!==c&&c,i}return s(n)}(le),Bs=function(e){i(n,e);var t=f(n);function n(e,a){var s,i,o;r(this,n),(s=t.call(this,e,a)).message=new Ps(e,a);var u=ns.of(e).sdkState;return s.isMentioned=Hs(s.message.mentionType,null!==(i=s.message.mentionedUserIds)&&void 0!==i?i:s.message.mentionedUsers.map((function(e){return e.userId})),u.userId),s.forceUpdateLastMessage=null!==(o=a.force_update_last_message)&&void 0!==o&&o,s}return s(n)}(re);!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"}(Is||(Is={}));var Qs,Ks=function(){function e(t,n){var a=this,s=n.sdkState,i=n.dispatcher,o=n.requestQueue,u=n.onlineDetector,c=n.cacheContext;r(this,e),this._queueMap=new Map,this._connectionState=null,this._onlineDetector=null,this._iid=t,this._sdkState=s,this._requestQueue=o,this._cacheContext=c,this._dispatcher=i,this._dispatcher.on((function(e){e instanceof Dr&&(a._connectionState=e.stateType)})),this._onlineDetector=u}return s(e,[{key:"_shouldSendThroughWebSocket",get:function(){return this._connectionState===Nr.CONNECTED||this._connectionState===Nr.CONNECTING||this._connectionState===Nr.RECONNECTING}},{key:"_sendFileMessage",value:function(e,n){return b(this,void 0,void 0,t().mark((function r(){var a,s,i,o,u,c,l,h;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(!this._shouldSendThroughWebSocket){t.next=9;break}return a=new js(Object.assign(Object.assign({},n.params),{channelUrl:e.url,channelType:e.channelType,url:n.params.fileUrl,requireAuth:n.requireAuth,reqId:n.requestId})),t.next=4,this._requestQueue.send(a);case 4:return s=t.sent,i=s.as(Vs),o=i.message,t.abrupt("return",o);case 9:return u=new zs(Object.assign(Object.assign({},n.params),{channelUrl:e.url,channelType:e.channelType,url:n.params.fileUrl,userId:this._sdkState.userId,requireAuth:n.requireAuth,reqId:n.requestId})),t.next=12,this._requestQueue.send(u);case 12:return c=t.sent,l=c.as(Bs),h=l.message,t.abrupt("return",h);case 15:case"end":return t.stop()}}),r,this)})))}},{key:"_resolveMessageQueue",value:function(e){return b(this,void 0,void 0,t().mark((function n(){var r,a,s,i,o,u,c,l;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(!(r=this._queueMap.get(e.url))){t.next=57;break}if(r.isResolving){t.next=56;break}r.isResolving=!0,a=[],s=!0,i=y(r.messageQueue),t.prev=7,i.s();case 9:if((o=i.n()).done){t.next=39;break}u=o.value,t.t0=u.state,t.next=t.t0===Is.PENDING||t.t0===Is.UPLOADING?14:t.t0===Is.UPLOADED?17:t.t0===Is.FAILED?35:37;break;case 14:return s=!1,a.push(u),t.abrupt("break",37);case 17:if(!s){t.next=33;break}return t.prev=18,u.state=Is.SENDING,t.next=22,this._sendFileMessage(e,u);case 22:return c=t.sent,u.deferred.resolve(c),t.next=26,sa(100);case 26:t.next=31;break;case 28:t.prev=28,t.t1=t.catch(18),u.deferred.reject(t.t1);case 31:t.next=34;break;case 33:a.push(u);case 34:return t.abrupt("break",37);case 35:return u.deferred.reject(u.error.code===E.REQUEST_CANCELED?M.fileUploadCanceled:u.error),t.abrupt("break",37);case 37:t.next=9;break;case 39:t.next=44;break;case 41:t.prev=41,t.t2=t.catch(7),i.e(t.t2);case 44:return t.prev=44,i.f(),t.finish(44);case 47:if(l=r.isResolveRequestPending,r.messageQueue=a,r.isResolving=!1,r.isResolveRequestPending=!1,!l){t.next=54;break}return t.next=54,this._resolveMessageQueue(e);case 54:t.next=57;break;case 56:r.isResolveRequestPending=!0;case 57:case"end":return t.stop()}}),n,this,[[7,41,44,47],[18,28]])})))}},{key:"_uploadNextPendingItem",value:function(e){return b(this,void 0,void 0,t().mark((function n(){var r,a,s,i,o,u,c,l,h,d,f,p,v,_;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(r=this._queueMap.get(e.url),!(a=r.messageQueue.find((function(e){return e.state===Is.PENDING})))){t.next=49;break}if(!H(a.params.file)){t.next=45;break}if(!(r.uploadQueue.length<6)){t.next=43;break}return a.state=Is.UPLOADING,r.uploadQueue.push(a),t.next=9,this._onlineDetector.isOnline();case 9:if(!t.sent){t.next=37;break}return t.prev=11,s=new as({file:a.params.file,channelUrl:e.url,thumbnailSizes:a.params.thumbnailSizes,requestId:a.requestId}),t.next=15,this._requestQueue.send(s);case 15:i=t.sent,o=i.as(ss),u=o.url,c=o.fileSize,l=void 0===c?a.params.fileSize:c,h=o.thumbnailSizes,d=void 0===h?a.params.thumbnailSizes:h,f=o.requireAuth,p=void 0!==f&&f,a.params.fileUrl=u,a.params.fileSize=l,a.params.thumbnailSizes=d,a.params.requireAuth=p,a.requireAuth=p,a.state=Is.UPLOADED,t.next=29;break;case 25:t.prev=25,t.t0=t.catch(11),t.t0.code===E.REQUEST_FAILED?a.error=new M({code:E.NETWORK_ERROR,message:"Failed to upload a file."}):a.error=t.t0,a.state=Is.FAILED;case 29:return t.prev=29,(v=r.uploadQueue.findIndex((function(e){return e.requestId===a.requestId})))>=0&&(r.uploadQueue.splice(v,1),this._uploadNextPendingItem(e)),t.next=34,this._resolveMessageQueue(e);case 34:return t.finish(29);case 35:t.next=43;break;case 37:return a.state=Is.FAILED,a.error=M.connectionRequired,(_=r.uploadQueue.findIndex((function(e){return e.requestId===a.requestId})))>=0&&(r.uploadQueue.splice(_,1),this._uploadNextPendingItem(e)),t.next=43,this._resolveMessageQueue(e);case 43:t.next=49;break;case 45:return a.params.thumbnailSizes=[],a.state=Is.UPLOADED,t.next=49,this._resolveMessageQueue(e);case 49:case"end":return t.stop()}}),n,this,[[11,25,29,35]])})))}},{key:"request",value:function(e,n,r){var a,s,i;return b(this,void 0,void 0,t().mark((function o(){var u;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return u=new Ur,H(r.file)&&(r.fileName=null!==(a=r.fileName)&&void 0!==a?a:r.file.name,r.mimeType=null!==(s=r.mimeType)&&void 0!==s?s:r.file.type,r.fileSize=null!==(i=r.fileSize)&&void 0!==i?i:r.file.size),this._queueMap.has(e.url)||this._queueMap.set(e.url,{messageQueue:[],uploadQueue:[],isResolving:!1,isResolveRequestPending:!1}),this._queueMap.get(e.url).messageQueue.push({requestId:n,params:r,state:Is.PENDING,deferred:u,requireAuth:r.requireAuth}),this._uploadNextPendingItem(e),t.abrupt("return",u.promise);case 7:case"end":return t.stop()}}),o,this)})))}},{key:"cancel",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null,n=this._queueMap.get(e.url);if(n){var r,a=t?[n.messageQueue.find((function(e){return e.requestId===t}))]:_(n.messageQueue),s=y(a);try{for(s.s();!(r=s.n()).done;){var i=r.value;if(i)switch(i.state){case Is.PENDING:i.state=Is.FAILED,i.error=M.requestCanceled,this._resolveMessageQueue(e);break;case Is.UPLOADING:this._requestQueue.cancel(i.requestId)}}}catch(e){s.e(e)}finally{s.f()}}}}]),e}(),Ws={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},Ys=function(t){return L("number",t.prevResultSize)&&L("number",t.nextResultSize)&&L("boolean",t.isInclusive)&&L("boolean",t.reverse)&&L("string",t.messageTypeFilter)&&D(e.MessageTypeFilter,t.messageTypeFilter)&&F("string",t.customTypesFilter,!0)&&F("string",t.senderUserIdsFilter,!0)&&D(e.ReplyType,t.replyType)&&L("boolean",t.includeMetaArray)&&L("boolean",t.includeReactions)&&L("boolean",t.includeParentMessageInfo)&&L("boolean",t.includeThreadInfo)&&L("boolean",t.showSubchannelMessagesOnly)},Zs={replyType:e.ReplyType.NONE,includeReactions:!1,includeThreadInfo:!1,includeMetaArray:!1,includeParentMessageInfo:!1},Js=function(t){return D(e.ReplyType,t.replyType)&&L("boolean",t.includeReactions)&&L("boolean",t.includeMetaArray)&&L("boolean",t.includeParentMessageInfo)&&L("boolean",t.includeThreadInfo)};e.MessageEventSource=void 0,(Qs=e.MessageEventSource||(e.MessageEventSource={})).UNKNOWN="UNKNOWN",Qs.EVENT_MESSAGE_SENT_SUCCESS="EVENT_MESSAGE_SENT_SUCCESS",Qs.EVENT_MESSAGE_SENT_FAILED="EVENT_MESSAGE_SENT_FAILED",Qs.EVENT_MESSAGE_SENT_PENDING="EVENT_MESSAGE_SENT_PENDING",Qs.EVENT_MESSAGE_RECEIVED="EVENT_MESSAGE_RECEIVED",Qs.EVENT_MESSAGE_UPDATED="EVENT_MESSAGE_UPDATED",Qs.EVENT_MESSAGE_DELETED="EVENT_MESSAGE_DELETED",Qs.EVENT_MESSAGE_READ="EVENT_MESSAGE_READ",Qs.EVENT_MESSAGE_DELIVERED="EVENT_MESSAGE_DELIVERED",Qs.EVENT_MESSAGE_REACTION_UPDATED="EVENT_MESSAGE_REACTION_UPDATED",Qs.EVENT_MESSAGE_THREADINFO_UPDATED="EVENT_MESSAGE_THREADINFO_UPDATED",Qs.EVENT_MESSAGE_OFFSET_UPDATED="EVENT_MESSAGE_OFFSET_UPDATED",Qs.REQUEST_MESSAGE="REQUEST_MESSAGE",Qs.EVENT_POLL_UPDATED="EVENT_POLL_UPDATED",Qs.EVENT_POLL_VOTED="EVENT_POLL_VOTED",Qs.SYNC_POLL_CHANGELOGS="SYNC_POLL_CHANGELOGS",Qs.REQUEST_RESEND_MESSAGE="REQUEST_RESEND_MESSAGE",Qs.REQUEST_THREADED_MESSAGE="REQUEST_THREADED_MESSAGE",Qs.REQUEST_MESSAGE_CHANGELOGS="REQUEST_MESSAGE_CHANGELOGS",Qs.SYNC_MESSAGE_FILL="SYNC_MESSAGE_FILL",Qs.SYNC_MESSAGE_BACKGROUND="SYNC_MESSAGE_BACKGROUND",Qs.SYNC_MESSAGE_CHANGELOGS="SYNC_MESSAGE_CHANGELOGS",Qs.LOCAL_MESSAGE_PENDING_CREATED="LOCAL_MESSAGE_PENDING_CREATED",Qs.LOCAL_MESSAGE_FAILED="LOCAL_MESSAGE_FAILED",Qs.LOCAL_MESSAGE_CANCELED="LOCAL_MESSAGE_CANCELED",Qs.LOCAL_MESSAGE_RESEND_STARTED="LOCAL_MESSAGE_RESEND_STARTED";var Xs,$s=function(t){return t.startsWith("EVENT_")||t===e.MessageEventSource.SYNC_MESSAGE_FILL||t===e.MessageEventSource.SYNC_MESSAGE_CHANGELOGS||t===e.MessageEventSource.SYNC_POLL_CHANGELOGS},ei=function(e){i(n,e);var t=f(n);function n(e){var a,s=e.messages,i=e.source;return r(this,n),(a=t.call(this)).messages=s,a.source=i,a}return s(n)}($),ti=function(e){i(n,e);var t=f(n);function n(e){var a,s=e.messageIds,i=e.source;return r(this,n),(a=t.call(this)).messageIds=s,a.source=i,a}return s(n)}($),ni=function(e){i(n,e);var t=f(n);function n(e){var a,s=e.reqId,i=e.source;return r(this,n),(a=t.call(this)).reqId=s,a.source=i,a}return s(n)}($),ri=function(e){i(n,e);var t=f(n);function n(e){var a,s=e.polls,i=e.source;return r(this,n),(a=t.call(this)).polls=s,a.source=i,a}return s(n)}($),ai=function(e){i(n,e);var t=f(n);function n(e){var a,s=e.event,i=e.source;return r(this,n),(a=t.call(this)).event=s,a.source=i,a}return s(n)}($),si=function(e){i(n,e);var t=f(n);function n(e){var a,s=e.event,i=e.source;return r(this,n),(a=t.call(this)).event=null,a.source=null,a.event=s,a.source=i,a}return s(n)}($),ii=function(e){i(n,e);var t=f(n);function n(e){var a,s=e.channelType,i=e.channelUrl,o=e.messageId,u=e.includeMetaArray,c=e.includeReactions,l=e.includeThreadInfo,h=e.includeParentMessageInfo;return r(this,n),(a=t.call(this)).method=B.GET,a.path="".concat(Fs(s),"/").concat(encodeURIComponent(i),"/messages/").concat(encodeURIComponent(o)),a.params={is_sdk:!0,with_sorted_meta_array:u,include_reactions:c,include_thread_info:l,include_parent_message_info:h,include_poll_details:!0},a}return s(n)}(ne),oi=function(e){i(n,e);var t=f(n);function n(e,a){var s;return r(this,n),(s=t.call(this,e,a)).message=a?Ds(e,Object.assign({},a)):null,s}return s(n)}(re),ui=function(e){i(n,e);var t=f(n);function n(e){var a,s=e.channelType,i=e.channelUrl,o=e.timestamp,u=void 0===o?null:o,c=e.token,l=void 0===c?null:c,h=e.prevResultSize,d=e.nextResultSize,f=e.isInclusive,p=e.reverse,v=e.messageTypeFilter,_=e.customTypesFilter,m=e.senderUserIdsFilter,g=e.replyType,y=e.includeMetaArray,k=e.includeReactions,b=e.parentMessageId,E=e.includeThreadInfo,w=e.includeParentMessageInfo,C=e.showSubchannelMessagesOnly,x=e.checkingContinuousMessages;return r(this,n),(a=t.call(this)).method=B.GET,a.path="".concat(Fs(s),"/").concat(encodeURIComponent(i),"/messages"),a.params=ee({is_sdk:!0,prev_limit:h,next_limit:d,include:f,reverse:p,message_ts:u,message_id:l,message_type:null!=v?v:null,custom_types:_,sender_ids:m,include_reply_type:g,with_sorted_meta_array:y,include_reactions:k,parent_message_id:b,include_thread_info:E,include_parent_message_info:w,show_subchannel_message_only:C,include_poll_details:!0,checking_continuous_messages:x}),a}return s(n)}(ne),ci=function(e){i(n,e);var t=f(n);function n(e,a){var s;return r(this,n),(s=t.call(this,e,a)).messages=a.messages.map((function(t){return Ds(e,t)})),s}return s(n)}(re),li=function(e){i(n,e);var t=f(n);function n(e){var a,s=e.channelType,i=e.channelUrl,o=e.timestamp,u=e.token,c=e.replyType,l=e.includeMetaArray,h=e.includeReactions,d=e.includeThreadInfo,f=e.includeParentMessageInfo;return r(this,n),(a=t.call(this)).method=B.GET,a.path="".concat(Fs(s),"/").concat(encodeURIComponent(i),"/messages/changelogs"),a.params={change_ts:o,token:u,with_sorted_meta_array:l,include_reactions:h,include_thread_info:d,include_reply_type:c,include_parent_message_info:f,include_poll_details:!0},a}return s(n)}(ne),hi=function(e){i(n,e);var t=f(n);function n(e,a){var s;return r(this,n),(s=t.call(this,e,a)).updatedMessages=a.updated.map((function(t){return Ds(e,t)})),s.deletedMessagesInfo=a.deleted.map((function(e){return{messageId:e.message_id,deletedAt:e.deleted_at}})),s.hasMore=a.has_more,s.nextToken=a.next,s}return s(n)}(re),di=function(e){i(n,e);var t=f(n);function n(e){var a,s=e.channelUrl,i=e.scheduledMessageId;return r(this,n),(a=t.call(this)).method=B.GET,a.path="".concat(zr,"/").concat(encodeURIComponent(s),"/scheduled_messages/").concat(encodeURIComponent(i)),a.params={},a}return s(n)}(ne),fi=function(e){i(n,e);var t=f(n);function n(e,a){var s;return r(this,n),(s=t.call(this,e,a)).message=a?Ds(e,Object.assign({},a)):null,s}return s(n)}(re),pi={},vi=function(){function n(e,t){var a=t.sdkState,s=t.dispatcher,i=t.requestQueue,o=t.onlineDetector,u=t.cacheContext;r(this,n),this._iid=e,this._sdkState=a,this._requestQueue=i,this._dispatcher=s,this._cacheContext=u,this.fileMessageQueue=new Ks(e,{sdkState:a,dispatcher:s,requestQueue:i,onlineDetector:o,cacheContext:u}),pi[e]=this}return s(n,[{key:"buildMessageFromSerializedData",value:function(t){var n=Oa(t);switch(n.messageType){case e.MessageType.USER:return new Rs(this._iid,Rs.payloadify(n));case e.MessageType.FILE:return new Ps(this._iid,Ps.payloadify(n));case e.MessageType.ADMIN:return new Ts(this._iid,Ts.payloadify(n))}return null}},{key:"buildUserMessageCreateParamsFromSerializedData",value:function(e,t){return ee({data:t.data,customType:t.customType,mentionType:t.mentionType,mentionedUserIds:t.mentionedUserIds,mentionedUsers:t.mentionedUsers,mentionedMessageTemplate:t.mentionedMessageTemplate,metaArrays:t.metaArrays,parentMessageId:t.parentMessageId,isReplyToChannel:e.isReplyToChannel,pushNotificationDeliveryOption:e.pushNotificationDeliveryOption,appleCriticalAlertOptions:t.appleCriticalAlertOptions,reqId:t.reqId,message:t.message,translationTargetLanguages:Object.keys(t.translations),pollId:e.pollId})}},{key:"buildFileMessageCreateParamsFromSerializedData",value:function(e,t){return ee({data:t.data,customType:t.customType,mentionType:t.mentionType,mentionedUserIds:t.mentionedUserIds,mentionedUsers:t.mentionedUsers,mentionedMessageTemplate:t.mentionedMessageTemplate,metaArrays:t.metaArrays,parentMessageId:t.parentMessageId,isReplyToChannel:e.isReplyToChannel,pushNotificationDeliveryOption:e.pushNotificationDeliveryOption,appleCriticalAlertOptions:t.appleCriticalAlertOptions,reqId:t.reqId,file:e.file,fileKey:e.fileKey,fileUrl:t.plainUrl,fileName:t.name,fileSize:t.size,mimeType:t.type,thumbnailSizes:t.thumbnails.map((function(e){return{maxWidth:e.width,maxHeight:e.height}})),fileType:e.fileType,requireAuth:t.requireAuth})}},{key:"buildScheduledUserMessageCreateParamsFromSerializedData",value:function(e,t){return Object.assign(Object.assign({},this.buildUserMessageCreateParamsFromSerializedData(e,t)),{scheduledAt:e.scheduledAt})}},{key:"buildScheduledFileMessageCreateParamsFromSerializedData",value:function(e,t){return Object.assign(Object.assign({},this.buildFileMessageCreateParamsFromSerializedData(e,t)),{scheduledAt:e.scheduledAt})}},{key:"buildSenderFromSerializedData",value:function(e){var t=Oa(e);return new bs(this._iid,bs.payloadify(t))}},{key:"getMessage",value:function(e){return b(this,void 0,void 0,t().mark((function n(){var r,a,s,i;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return r=new ii(e),t.next=3,this._requestQueue.send(r);case 3:return a=t.sent,s=a.as(oi),i=s.message,t.abrupt("return",i);case 6:case"end":return t.stop()}}),n,this)})))}},{key:"getScheduledMessage",value:function(e){return b(this,void 0,void 0,t().mark((function n(){var r,a,s,i;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return r=new di(e),t.next=3,this._requestQueue.send(r);case 3:return a=t.sent,s=a.as(fi),i=s.message,t.abrupt("return",i);case 6:case"end":return t.stop()}}),n,this)})))}},{key:"getMessagesByMessageId",value:function(n,r,a,s){var i=arguments.length>4&&void 0!==arguments[4]?arguments[4]:e.MessageEventSource.REQUEST_MESSAGE;return b(this,void 0,void 0,t().mark((function e(){var o,u,c,l;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return o=new ui(Object.assign(Object.assign({channelType:r,channelUrl:n,token:String(a)},Ws),s)),e.next=3,this._requestQueue.send(o);case 3:return u=e.sent,c=u.as(ci),l=c.messages,this._dispatcher.dispatch(new ei({messages:l,source:i})),e.abrupt("return",l);case 7:case"end":return e.stop()}}),e,this)})))}},{key:"getMessagesByTimestamp",value:function(n,r,a,s){var i=arguments.length>4&&void 0!==arguments[4]?arguments[4]:e.MessageEventSource.REQUEST_MESSAGE;return b(this,void 0,void 0,t().mark((function e(){var o,u,c,l;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return o=new ui(Object.assign(Object.assign({channelType:r,channelUrl:n,timestamp:a},Ws),s)),e.next=3,this._requestQueue.send(o);case 3:return u=e.sent,c=u.as(ci),l=c.messages,this._dispatcher.dispatch(new ei({messages:l,source:i})),e.abrupt("return",l);case 7:case"end":return e.stop()}}),e,this)})))}},{key:"_getMessagesByTimestampForCollection",value:function(n,r,a,s){var i=arguments.length>4&&void 0!==arguments[4]?arguments[4]:e.MessageEventSource.REQUEST_MESSAGE,o=arguments.length>5?arguments[5]:void 0;return b(this,void 0,void 0,t().mark((function e(){var u,c,l,h,d;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return u=new ui(Object.assign(Object.assign(Object.assign({channelType:r,channelUrl:n,timestamp:a},Ws),s),{checkingContinuousMessages:o})),e.next=3,this._requestQueue.send(u);case 3:return c=e.sent,l=c.payload,h=c.as(ci),d=h.messages,this._dispatcher.dispatch(new ei({messages:d,source:i})),e.abrupt("return",{messages:d,isContinuousMessages:l});case 8:case"end":return e.stop()}}),e,this)})))}},{key:"getThreadedMessagesByTimestamp",value:function(n,r,a){var s=arguments.length>3&&void 0!==arguments[3]?arguments[3]:e.MessageEventSource.REQUEST_THREADED_MESSAGE;return b(this,void 0,void 0,t().mark((function i(){var o,u,c,l,h;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return o=new ui(Object.assign(Object.assign(Object.assign({channelUrl:n.channelUrl,channelType:n.channelType,timestamp:r},Cs),a),{replyType:e.ReplyType.ALL,parentMessageId:n.messageId,includeThreadInfo:!0})),t.next=3,this._requestQueue.send(o);case 3:return u=t.sent,c=u.as(ci),l=c.messages,(h=l.slice(1)).forEach((function(e){e.parentMessage=n})),this._dispatcher.dispatch(new ei({messages:h,source:s})),t.abrupt("return",{parentMessage:l[0],threadedMessages:h});case 9:case"end":return t.stop()}}),i,this)})))}},{key:"getMessageChangelogs",value:function(n,r,a,s){var i=arguments.length>4&&void 0!==arguments[4]?arguments[4]:e.MessageEventSource.REQUEST_MESSAGE_CHANGELOGS;return b(this,void 0,void 0,t().mark((function e(){var o,u,c,l,h,d,f,p;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return o=new li(ee(Object.assign(Object.assign({channelType:r,channelUrl:n,timestamp:"number"==typeof a?a:null,token:"string"==typeof a?a:null},Zs),s))),e.next=3,this._requestQueue.send(o);case 3:return u=e.sent,c=u.as(hi),l=c.updatedMessages,h=c.deletedMessagesInfo,d=c.hasMore,f=c.nextToken,p=h.map((function(e){return e.messageId})),l.length>0&&this._dispatcher.dispatch(new ei({messages:l,source:i})),p.length>0&&this._dispatcher.dispatch(new ti({messageIds:p,source:i})),e.abrupt("return",{updatedMessages:l,deletedMessageIds:p,hasMore:d,token:f});case 9:case"end":return e.stop()}}),e,this)})))}}],[{key:"of",value:function(e){return pi[e]}}]),n}(),_i=function(){function t(){r(this,t),this._onPending=he,this._onFailed=he,this._onSucceeded=he}return s(t,[{key:"_trigger",value:function(t,n){switch(n.sendingStatus){case e.SendingStatus.PENDING:0===n.errorCode&&this._onPending(n);break;case e.SendingStatus.FAILED:case e.SendingStatus.CANCELED:this._onFailed(t,n.scheduledInfo?null:n);break;case e.SendingStatus.SCHEDULED:case e.SendingStatus.SUCCEEDED:this._onSucceeded(n)}}},{key:"onPending",value:function(e){return this._onPending=e,this}},{key:"onFailed",value:function(e){return this._onFailed=e,this}},{key:"onSucceeded",value:function(e){return this._onSucceeded=e,this}}]),t}(),mi=function(e){i(n,e);var t=f(n);function n(e,a){var s;r(this,n),(s=t.call(this,e)).threadInfo=null,s.targetMessageId=0,s.channelUrl=null,s.channelType=null;var i=a.thread_info,o=a.parent_message_id,u=a.channel_url,c=a.channel_type;return i&&L("object",i)&&L("number",o)&&L("string",u)&&L("string",c)&&(s.threadInfo=new os(e,i),s.targetMessageId=o,s.channelUrl=u,s.channelType=c),s}return s(n)}(Ca),gi={channelUrl:null,channelType:null,messageId:0,includeReactions:!1,includeMetaArray:!1,includeParentMessageInfo:!1,includeThreadInfo:!1},yi=function(t){return L("string",t.channelUrl)&&L("string",t.channelType)&&D(e.ChannelType,t.channelType)&&L("number",t.messageId)&&L("boolean",t.includeMetaArray)&&L("boolean",t.includeParentMessageInfo)&&L("boolean",t.includeThreadInfo)},ki=function(){function e(t,n){var a;r(this,e),this._iid=null,this.limit=20,this._isLoading=!1,this._hasNext=!0,this._token="",this._iid=t,this.limit=null!==(a=n.limit)&&void 0!==a?a:20}return s(e,[{key:"hasNext",get:function(){return this._hasNext}},{key:"isLoading",get:function(){return this._isLoading}},{key:"_validate",value:function(){return L("number",this.limit)&&this.limit>0}}]),e}(),bi=function(e){i(n,e);var t=f(n);function n(e){var a,s=e.channelCustomType,i=e.keyword,o=e.limit,u=e.reverse,c=e.exactMatch,l=e.channelUrl,h=e.order,d=e.messageTimestampFrom,f=e.messageTimestampTo,p=e.advancedQuery,v=e.targetFields,_=e.nextToken;return r(this,n),(a=t.call(this)).method=B.GET,a.path="".concat(Kr,"/messages"),a.params={custom_type:s,query:i,limit:o,reverse:u,exact_match:c,channel_url:l,message_ts_from:d,message_ts_to:f,sort_field:h,advanced_query:p,target_fields:v,after:_},a}return s(n)}(ne),Ei=function(e){i(n,e);var t=f(n);function n(e,a){var s;return r(this,n),(s=t.call(this,e,a)).messages=a.results.map((function(t){return Ds(e,t)})),s.hasNext=a.has_next,s.nextToken=a.end_cursor,s.totalCount=a.total_count,s}return s(n)}(re);e.MessageSearchOrder=void 0,(Xs=e.MessageSearchOrder||(e.MessageSearchOrder={})).SCORE="score",Xs.TIMESTAMP="ts";var wi,Ci,xi,Ti=function(n){i(u,n);var a=f(u);function u(t,n){var s,i,o,c,l,h,d,f,p,v;return r(this,u),(s=a.call(this,t,n)).keyword="",s.reverse=!1,s.exactMatch=!1,s.channelUrl="",s.channelCustomType="",s.messageTimestampFrom=null,s.messageTimestampTo=null,s.order=e.MessageSearchOrder.SCORE,s.advancedQuery=!1,s.targetFields=null,s._nextToken="",s.totalCount=-1,s.keyword=n.keyword,s.reverse=null!==(i=n.reverse)&&void 0!==i&&i,s.exactMatch=null!==(o=n.exactMatch)&&void 0!==o&&o,s.channelUrl=null!==(c=n.channelUrl)&&void 0!==c?c:"",s.channelCustomType=null!==(l=n.channelCustomType)&&void 0!==l?l:"",s.messageTimestampFrom=null!==(h=n.messageTimestampFrom)&&void 0!==h?h:null,s.messageTimestampTo=null!==(d=n.messageTimestampTo)&&void 0!==d?d:null,s.order=null!==(f=n.order)&&void 0!==f?f:e.MessageSearchOrder.SCORE,s.advancedQuery=null!==(p=n.advancedQuery)&&void 0!==p&&p,s.targetFields=null!==(v=n.targetFields)&&void 0!==v?v:null,s}return s(u,[{key:"_validate",value:function(){return p(o(u.prototype),"_validate",this).call(this)&&L("string",this.keyword)&&this.keyword.length>0&&L("boolean",this.reverse)&&L("boolean",this.exactMatch)&&L("string",this.channelUrl)&&L("string",this.channelCustomType)&&(L("number",this.messageTimestampFrom)||null===this.messageTimestampFrom)&&(L("number",this.messageTimestampTo)||null===this.messageTimestampTo)&&D(e.MessageSearchOrder,this.order)&&L("boolean",this.advancedQuery)&&F("string",this.targetFields,!0)}},{key:"next",value:function(){return b(this,void 0,void 0,t().mark((function e(){var n,r,a,s,i,o,u,c,l;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!this._validate()){e.next=21;break}if(this._isLoading){e.next=18;break}if(!this._hasNext){e.next=15;break}return this._isLoading=!0,n=ns.of(this._iid),r=n.requestQueue,a=new bi(Object.assign(Object.assign({},this),{nextToken:this._nextToken?this._nextToken:null})),e.next=8,r.send(a);case 8:return s=e.sent,i=s.as(Ei),o=i.messages,u=i.hasNext,c=i.nextToken,l=i.totalCount,this._nextToken=c,this._hasNext=u,this._isLoading=!1,this.totalCount=l,e.abrupt("return",o);case 15:return e.abrupt("return",[]);case 18:throw M.queryInProgress;case 19:e.next=22;break;case 21:throw M.invalidParameters;case 22:case"end":return e.stop()}}),e,this)})))}}]),u}(ki),Si=function(t){i(a,t);var n=f(a);function a(e,t,s,i){var o;return r(this,a),(o=n.call(this,e,i)).channelUrl=t,o.channelType=s,o}return s(a,[{key:"_validate",value:function(){return p(o(a.prototype),"_validate",this).call(this)&&L("string",this.channelUrl)&&D(e.ChannelType,this.channelType)}}]),a}(ki),Ii=function(n){i(u,n);var a=f(u);function u(t,n,s,i){var o,c,l,h,d,f,p,v,_,m,g;return r(this,u),(o=a.call(this,t,n,s,i)).reverse=!1,o.messageTypeFilter=e.MessageTypeFilter.ALL,o.customTypesFilter=null,o.senderUserIdsFilter=null,o.replyType=e.ReplyType.NONE,o.includeMetaArray=!1,o.includeReactions=!1,o.includeParentMessageInfo=!1,o.includeThreadInfo=!1,o.showSubchannelMessagesOnly=!1,o._edge=Number.MAX_SAFE_INTEGER,o.reverse=null!==(c=i.reverse)&&void 0!==c&&c,o.messageTypeFilter=null!==(l=i.messageTypeFilter)&&void 0!==l?l:e.MessageTypeFilter.ALL,o.customTypesFilter=null!==(h=i.customTypesFilter)&&void 0!==h?h:null,o.senderUserIdsFilter=null!==(d=i.senderUserIdsFilter)&&void 0!==d?d:null,o.replyType=null!==(f=i.replyType)&&void 0!==f?f:e.ReplyType.NONE,o.includeMetaArray=null!==(p=i.includeMetaArray)&&void 0!==p&&p,o.includeReactions=null!==(v=i.includeReactions)&&void 0!==v&&v,o.includeParentMessageInfo=null!==(_=i.includeParentMessageInfo)&&void 0!==_&&_,o.includeThreadInfo=null!==(m=i.includeThreadInfo)&&void 0!==m&&m,o.showSubchannelMessagesOnly=null!==(g=i.showSubchannelMessagesOnly)&&void 0!==g&&g,o}return s(u,[{key:"_validate",value:function(){return p(o(u.prototype),"_validate",this).call(this)&&L("boolean",this.reverse)&&D(e.MessageTypeFilter,this.messageTypeFilter)&&D(e.ReplyType,this.replyType)&&F("string",this.customTypesFilter,!0)&&F("string",this.senderUserIdsFilter,!0)&&L("boolean",this.includeMetaArray)&&L("boolean",this.includeReactions)&&L("boolean",this.includeParentMessageInfo)&&L("boolean",this.includeThreadInfo)&&L("boolean",this.showSubchannelMessagesOnly)}},{key:"load",value:function(){return b(this,void 0,void 0,t().mark((function e(){var n,r;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!this._validate()){e.next=18;break}if(this._isLoading){e.next=15;break}if(!this._hasNext){e.next=12;break}return this._isLoading=!0,n=vi.of(this._iid),e.next=7,n.getMessagesByTimestamp(this.channelUrl,this.channelType,this._edge,{prevResultSize:this.limit,nextResultSize:0,isInclusive:!1,reverse:this.reverse,messageTypeFilter:this.messageTypeFilter,customTypesFilter:this.customTypesFilter,replyType:this.replyType,senderUserIdsFilter:this.senderUserIdsFilter,includeReactions:this.includeReactions,includeMetaArray:this.includeMetaArray,includeParentMessageInfo:this.includeParentMessageInfo,includeThreadInfo:this.includeThreadInfo,showSubchannelMessagesOnly:this.showSubchannelMessagesOnly});case 7:return r=e.sent,this._edge=Math.min.apply(Math,[Number.MAX_SAFE_INTEGER].concat(_(r.map((function(e){return e.createdAt}))))),this._hasNext=r.length>=this.limit,this._isLoading=!1,e.abrupt("return",r);case 12:return e.abrupt("return",[]);case 15:throw M.queryInProgress;case 16:e.next=19;break;case 18:throw M.invalidParameters;case 19:case"end":return e.stop()}}),e,this)})))}}]),u}(Si),Ni={channelUrl:null,scheduledMessageId:0},Ai=function(e){return L("string",e.channelUrl)&&L("number",e.scheduledMessageId)},Mi=function(e){i(a,e);var n=f(a);function a(){var e;return r(this,a),(e=n.apply(this,arguments)).name="message",e}return s(a,[{key:"init",value:function(e,t){var n=t.sdkState,r=t.dispatcher,s=t.sessionManager,i=t.requestQueue,u=t.logger,c=t.onlineDetector,l=t.cacheContext;p(o(a.prototype),"init",this).call(this,e,{sdkState:n,dispatcher:r,sessionManager:s,requestQueue:i,logger:u,onlineDetector:c,cacheContext:l}),this._manager=new vi(e,{sdkState:n,dispatcher:r,requestQueue:i,onlineDetector:c,cacheContext:l})}},{key:"buildMessageFromSerializedData",value:function(e){return this._manager.buildMessageFromSerializedData(e)}},{key:"buildSenderFromSerializedData",value:function(e){return this._manager.buildSenderFromSerializedData(e)}},{key:"getMessage",value:function(e){return b(this,void 0,void 0,t().mark((function n(){var r;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return r=Object.assign(Object.assign({},gi),e),Ua(yi(r)).throw(M.invalidParameters),t.abrupt("return",this._manager.getMessage(r));case 3:case"end":return t.stop()}}),n,this)})))}},{key:"getScheduledMessage",value:function(e){return b(this,void 0,void 0,t().mark((function n(){var r;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return r=Object.assign(Object.assign({},Ni),e),Ua(Ai(r)).throw(M.invalidParameters),t.abrupt("return",this._manager.getScheduledMessage(r));case 3:case"end":return t.stop()}}),n,this)})))}}]),a}(rs),Oi=function(e){i(n,e);var t=f(n);function n(e){var a,s=e.title,i=e.optionTexts,o=e.data,u=e.allowUserSuggestion,c=e.allowMultipleVotes,l=e.closeAt;return r(this,n),(a=t.call(this)).method=B.POST,a.path=Jr,a.params={title:s,options:i,data:o,allow_user_suggestion:u,allow_multiple_votes:c,close_at:l},a}return s(n)}(ne),Ui=function(e){i(n,e);var t=f(n);function n(e,a){var s;return r(this,n),(s=t.call(this,e,a)).poll=new Us(e,a),s}return s(n)}(re),Ri=function(e){i(n,e);var t=f(n);function n(e){var a,s=e.channelUrl,i=e.channelType,o=e.pollId;return r(this,n),(a=t.call(this)).method=B.GET,a.path="".concat(Jr,"/").concat(encodeURIComponent(o)),a.params={channel_url:s,channel_type:i},a}return s(n)}(ne),Li=function(e){i(n,e);var t=f(n);function n(e,a){var s;return r(this,n),(s=t.call(this,e,a)).poll=new Us(e,a),s}return s(n)}(re),Di=function(e){i(n,e);var t=f(n);function n(e){var a,s=e.channelUrl,i=e.channelType,o=e.pollId,u=e.pollOptionId;return r(this,n),(a=t.call(this)).method=B.GET,a.path="".concat(Jr,"/").concat(encodeURIComponent(o),"/options/").concat(encodeURIComponent(u)),a.params={channel_url:s,channel_type:i},a}return s(n)}(ne),Pi=function(e){i(n,e);var t=f(n);function n(e,a){var s;return r(this,n),(s=t.call(this,e,a)).pollOption=new Os(e,a),s}return s(n)}(re),Fi=function(e){i(n,e);var t=f(n);function n(e){var a,s=e.channelType,i=e.channelUrl,o=e.timestamp,u=e.token;return r(this,n),(a=t.call(this)).method=B.GET,a.path="".concat(Fs(s),"/").concat(encodeURIComponent(i),"/polls/changelogs"),a.params=ee({change_ts:o,token:u}),a}return s(n)}(ne),Gi=function(e){i(n,e);var t=f(n);function n(e,a){var s;return r(this,n),(s=t.call(this,e,a)).updatedPolls=a.updated.map((function(t){return function(e,t){return t?new Us(e,t):null}(e,t)})),s.deletedPollIds=a.deleted.map((function(e){return e})),s.hasMore=a.has_more,s.nextToken=a.next,s}return s(n)}(re),Hi={title:null,optionTexts:null,data:null,allowUserSuggestion:null,allowMultipleVotes:null,closeAt:-1},qi=function(e){return L("string",e.title)&&(t=e.optionTexts,F("string",t)&&t.every((function(e){return""!==e.trim()})))&&Ms(e.data)&&L("boolean",e.allowUserSuggestion,!0)&&L("boolean",e.allowMultipleVotes,!0)&&L("number",e.closeAt,!0);var t},ji={channelUrl:null,channelType:null,pollId:null,pollOptionId:null},zi=function(t){return L("string",t.channelUrl)&&D(e.ChannelType,t.channelType)&&L("number",t.pollId)&&L("number",t.pollOptionId)},Vi={channelUrl:null,channelType:null,pollId:null},Bi=function(t){return L("string",t.channelUrl)&&""!==t.channelUrl&&D(e.ChannelType,t.channelType)&&L("number",t.pollId)},Qi={},Ki=function(){function n(e,t){var a=t.sdkState,s=t.dispatcher,i=t.sessionManager,o=t.requestQueue,u=t.logger;r(this,n),this._iid=e,this._sdkState=a,this._sessionManager=i,this._requestQueue=o,this._dispatcher=s,this._logger=u,Qi[e]=this}return s(n,[{key:"buildPollFromSerializedData",value:function(e){var t=Oa(e);return new Us(this._iid,Us.payloadify(t))}},{key:"get",value:function(e){return b(this,void 0,void 0,t().mark((function n(){var r,a,s,i;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return Ua(Bi(e)).throw(M.invalidParameters),r=new Ri(Object.assign({},e)),t.next=4,this._requestQueue.send(r);case 4:return a=t.sent,s=a.as(Li),i=s.poll,t.abrupt("return",i);case 7:case"end":return t.stop()}}),n,this)})))}},{key:"create",value:function(e){return b(this,void 0,void 0,t().mark((function n(){var r,a,s,i,o;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return Ua(qi(e)).throw(M.invalidParameters),r=e.data,a=new Oi(Object.assign(Object.assign({},e),{data:r})),t.next=5,this._requestQueue.send(a);case 5:return s=t.sent,i=s.as(Ui),o=i.poll,t.abrupt("return",o);case 8:case"end":return t.stop()}}),n,this)})))}},{key:"getOption",value:function(e){return b(this,void 0,void 0,t().mark((function n(){var r,a,s,i;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return Ua(zi(e)).throw(M.invalidParameters),r=new Di(Object.assign({},e)),t.next=4,this._requestQueue.send(r);case 4:return a=t.sent,s=a.as(Pi),i=s.pollOption,t.abrupt("return",i);case 7:case"end":return t.stop()}}),n,this)})))}},{key:"getPollChangeLogs",value:function(n,r,a){var s=arguments.length>3&&void 0!==arguments[3]?arguments[3]:e.MessageEventSource.SYNC_POLL_CHANGELOGS;return b(this,void 0,void 0,t().mark((function e(){var i,o,u,c,l,h,d;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return i=new Fi(ee({channelType:r,channelUrl:n,timestamp:"number"==typeof a?a:null,token:"string"==typeof a?a:null})),e.next=3,this._requestQueue.send(i);case 3:return o=e.sent,u=o.as(Gi),c=u.updatedPolls,l=u.deletedPollIds,h=u.hasMore,d=u.nextToken,c.length>0&&this._dispatcher.dispatch(new ri({polls:c,source:s})),e.abrupt("return",{updatedPolls:c,deletedPollIds:l,hasMore:h,token:d});case 7:case"end":return e.stop()}}),e,this)})))}}],[{key:"of",value:function(e){return Qi[e]}}]),n}(),Wi=s((function e(t,n){r(this,e),this.pollId=0,this.messageId=0,this.pollId=n.poll.id,this.messageId=n.poll.message_id,this._iid=t,this._payload=n})),Yi=s((function e(t){r(this,e),this.pollId=0,this.messageId=0,this.pollId=t.poll_id,this.messageId=t.message_id,this._payload=t})),Zi=function(e){i(n,e);var t=f(n);function n(e){var a,s=e.channelUrl,i=e.channelType,o=e.token,u=e.limit;return r(this,n),(a=t.call(this)).method=B.GET,a.path=Jr,a.params={channel_url:s,channel_type:i,token:o,limit:u},a}return s(n)}(ne),Ji=function(e){i(n,e);var t=f(n);function n(e,a){var s,i;return r(this,n),(s=t.call(this,e,a)).polls=(null!==(i=a.polls)&&void 0!==i?i:[]).map((function(t){return new Us(e,t)})),s.token=a.next,s}return s(n)}(re),Xi=function(e){i(a,e);var n=f(a);function a(e,t){return r(this,a),n.call(this,e,t.channelUrl,t.channelType,t)}return s(a,[{key:"next",value:function(){return b(this,void 0,void 0,t().mark((function e(){var n,r,a,s,i,o,u;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!this._validate()){e.next=20;break}if(this._isLoading){e.next=17;break}if(!this._hasNext){e.next=14;break}return this._isLoading=!0,n=ns.of(this._iid),r=n.requestQueue,a=new Zi(Object.assign(Object.assign({},this),{token:this._token})),e.next=8,r.send(a);case 8:return s=e.sent,i=s.as(Ji),o=i.polls,u=i.token,this._token=u,this._hasNext=!!u,this._isLoading=!1,e.abrupt("return",o);case 14:return e.abrupt("return",[]);case 17:throw M.queryInProgress;case 18:e.next=21;break;case 20:throw M.invalidParameters;case 21:case"end":return e.stop()}}),e,this)})))}}]),a}(Si),$i=function(e){i(n,e);var t=f(n);function n(e){var a,s=e.channelUrl,i=e.channelType,o=e.pollId,u=e.pollOptionId,c=e.token,l=e.limit;return r(this,n),(a=t.call(this)).method=B.GET,a.path="".concat(Jr,"/").concat(encodeURIComponent(o),"/options/").concat(encodeURIComponent(u),"/voters"),a.params={channel_url:s,channel_type:i,token:c,limit:l},a}return s(n)}(ne),eo=function(e){i(n,e);var t=f(n);function n(e,a){var s,i;return r(this,n),(s=t.call(this,e,a)).voters=(null!==(i=a.voters)&&void 0!==i?i:[]).map((function(t){return new La(e,t)})),s.token=a.next,s}return s(n)}(re),to=function(e){i(a,e);var n=f(a);function a(e,t){var s;return r(this,a),(s=n.call(this,e,t.channelUrl,t.channelType,t)).pollId=t.pollId,s.pollOptionId=t.pollOptionId,s}return s(a,[{key:"_validate",value:function(){return p(o(a.prototype),"_validate",this).call(this)&&L("number",this.pollId)&&L("number",this.pollOptionId)}},{key:"next",value:function(){return b(this,void 0,void 0,t().mark((function e(){var n,r,a,s,i,o,u;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!this._validate()){e.next=20;break}if(this._isLoading){e.next=17;break}if(!this._hasNext){e.next=14;break}return this._isLoading=!0,n=ns.of(this._iid),r=n.requestQueue,a=new $i(Object.assign(Object.assign({},this),{pollId:this.pollId,pollOptionId:this.pollOptionId,token:this._token})),e.next=8,r.send(a);case 8:return s=e.sent,i=s.as(eo),o=i.voters,u=i.token,this._token=u,this._hasNext=!!u,this._isLoading=!1,e.abrupt("return",o);case 14:return e.abrupt("return",[]);case 17:throw M.queryInProgress;case 18:e.next=21;break;case 20:throw M.invalidParameters;case 21:case"end":return e.stop()}}),e,this)})))}}]),a}(Si),no=function(e){i(a,e);var n=f(a);function a(){var e;return r(this,a),(e=n.apply(this,arguments)).name="poll",e}return s(a,[{key:"init",value:function(e,t){var n=t.sdkState,r=t.dispatcher,s=t.sessionManager,i=t.requestQueue,u=t.logger,c=t.onlineDetector,l=t.cacheContext;p(o(a.prototype),"init",this).call(this,e,{sdkState:n,dispatcher:r,sessionManager:s,requestQueue:i,logger:u,onlineDetector:c,cacheContext:l}),this._manager=new Ki(e,{sdkState:n,dispatcher:r,sessionManager:s,requestQueue:i,logger:u,onlineDetector:c,cacheContext:l})}},{key:"create",value:function(e){return b(this,void 0,void 0,t().mark((function n(){var r;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return r=Object.assign(Object.assign({},Hi),e),Ua(qi(r)).throw(M.invalidParameters),t.abrupt("return",this._manager.create(r));case 3:case"end":return t.stop()}}),n,this)})))}},{key:"get",value:function(e){return b(this,void 0,void 0,t().mark((function n(){var r;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return r=Object.assign(Object.assign({},Vi),e),Ua(Bi(r)).throw(M.invalidParameters),t.abrupt("return",this._manager.get(r));case 3:case"end":return t.stop()}}),n,this)})))}},{key:"getOption",value:function(e){return b(this,void 0,void 0,t().mark((function n(){var r;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return r=Object.assign(Object.assign({},ji),e),Ua(zi(r)).throw(M.invalidParameters),t.abrupt("return",this._manager.getOption(r));case 3:case"end":return t.stop()}}),n,this)})))}},{key:"buildPollFromSerializedData",value:function(e){return this._manager.buildPollFromSerializedData(e)}}]),a}(rs),ro={profileImage:null,profileUrl:null,nickname:null},ao=function(e){return H(e.profileImage,!0)&&L("string",e.profileUrl,!0)&&L("string",e.nickname,!0)},so=function(e){i(n,e);var t=f(n);function n(){var e,a=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return r(this,n),e=t.call(this),Object.keys(a).forEach((function(t){e.hasOwnProperty(t)&&(e[t]=a[t])})),e}return s(n)}(s((function e(){r(this,e),this.onSessionExpired=he,this.onSessionTokenRequired=function(e){return e(null)},this.onSessionError=he,this.onSessionRefreshed=he,this.onSessionClosed=he}))),io=function(e){i(n,e);var t=f(n);function n(){var e,a=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return r(this,n),e=t.call(this),Object.keys(a).forEach((function(t){e.hasOwnProperty(t)&&(e[t]=a[t])})),e}return s(n)}(s((function e(){r(this,e),this.onConnected=he,this.onReconnectStarted=he,this.onReconnectSucceeded=he,this.onReconnectFailed=he,this.onDisconnected=he}))),oo=function(e){i(n,e);var t=f(n);function n(){var e,a=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return r(this,n),e=t.call(this),Object.keys(a).forEach((function(t){e.hasOwnProperty(t)&&(e[t]=a[t])})),e}return s(n)}(s((function e(){r(this,e),this.onFriendsDiscovered=he,this.onTotalUnreadMessageCountUpdated=he}))),uo="GroupChannel",co=100,lo="Message";e.GroupChannelListOrder=void 0,(wi=e.GroupChannelListOrder||(e.GroupChannelListOrder={})).LATEST_LAST_MESSAGE="latest_last_message",wi.CHRONOLOGICAL="chronological",wi.CHANNEL_NAME_ALPHABETICAL="channel_name_alphabetical",wi.METADATA_VALUE_ALPHABETICAL="metadata_value_alphabetical",e.PublicGroupChannelListOrder=void 0,(Ci=e.PublicGroupChannelListOrder||(e.PublicGroupChannelListOrder={})).CHRONOLOGICAL="chronological",Ci.CHANNEL_NAME_ALPHABETICAL="channel_name_alphabetical",Ci.METADATA_VALUE_ALPHABETICAL="metadata_value_alphabetical",e.ScheduledMessageListOrder=void 0,(xi=e.ScheduledMessageListOrder||(e.ScheduledMessageListOrder={})).CREATED_AT="created_at",xi.SCHEDULED_AT="scheduled_at";var ho,fo=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"]}},po=function(){function t(){r(this,t),this.messageTypeFilter=e.MessageTypeFilter.ALL,this.customTypesFilter=null,this.senderUserIdsFilter=null,this.replyType=e.ReplyType.NONE}return s(t,[{key:"clone",value:function(){var e=new t,n=JSON.parse(JSON.stringify(this));return Object.keys(n).forEach((function(t){e[t]=n[t]})),e}},{key:"match",value:function(t){switch(this.messageTypeFilter){case e.MessageTypeFilter.USER:if(t.messageType!==e.MessageType.USER)return!1;break;case e.MessageTypeFilter.FILE:if(t.messageType!==e.MessageType.FILE)return!1;break;case e.MessageTypeFilter.ADMIN:if(t.messageType!==e.MessageType.ADMIN)return!1}if(this.customTypesFilter&&this.customTypesFilter.length>0&&!this.customTypesFilter.includes(t.customType))return!1;if(this.senderUserIdsFilter&&this.senderUserIdsFilter.length>0){if(!(t instanceof Es))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 Es&&t.parentMessageId>0&&!t.replyToChannel)return!1}return!0}}]),t}();!function(e){e.CHANNEL_LATEST="channel_latest",e.NEWEST_CHILD_MESSAGE="newest_child_message"}(ho||(ho={}));var vo,_o=function(e){switch(e){case ho.CHANNEL_LATEST:return["channelUrl","-createdAt","-messageId"];case ho.NEWEST_CHILD_MESSAGE:return["channelUrl","-parentMessageId","-createdAt","-messageId"]}},mo={data:null,customType:null,mentionType:e.MentionType.USERS,mentionedUserIds:null,mentionedUsers:null,mentionedMessageTemplate:null,metaArrays:null,parentMessageId:null,isReplyToChannel:!1,pushNotificationDeliveryOption:null,appleCriticalAlertOptions:null,isPinnedMessage:!1},go=function(t){return L("string",t.data,!0)&&L("string",t.customType,!0)&&D(e.MentionType,t.mentionType)&&F("string",t.mentionedUserIds,!0)&&F(La,t.mentionedUsers,!0)&&L("string",t.mentionedMessageTemplate,!0)&&F(ps,t.metaArrays,!0)&&L("number",t.parentMessageId,!0)&&L("boolean",t.isReplyToChannel)&&D(e.PushNotificationDeliveryOption,t.pushNotificationDeliveryOption,!0)&&L(ms,t.appleCriticalAlertOptions,!0)&&L("boolean",t.isPinnedMessage,!0)},yo=function(e){return e?{isReplyToChannel:e.isReplyToChannel,pushNotificationDeliveryOption:e.pushNotificationDeliveryOption,pollId:e.pollId}:null},ko=Object.assign(Object.assign({},mo),{message:null,translationTargetLanguages:null,pollId:null}),bo=function(e){var t;return ee({data:e.data,customType:e.customType,mentionType:e.mentionType,mentionedUsers:e.mentionedUsers,mentionedUserIds:e.mentionedUserIds,mentionedMessageTemplate:e.mentionedMessageTemplate,metaArrays:e.metaArrays,pollId:null===(t=e.poll)||void 0===t?void 0:t.id,parentMessageId:e.parentMessageId,appleCriticalAlertOptions:e.appleCriticalAlertOptions,message:e.message,translationTargetLanguages:Object.keys(e.translations)})},Eo=function(e){return go(e)&&L("string",e.message)&&F("string",e.translationTargetLanguages,!0)&&L("number",e.pollId,!0)};!function(e){e.FILE="file",e.BLOB="blob",e.BLOB_LIKE_OBJECT="blobLikeObject",e.URL="url"}(vo||(vo={}));var wo=function(e){return"undefined"!=typeof window&&"Blob"in window&&"undefined"!=typeof Blob&&e instanceof Blob},Co=function(e){return e===vo.BLOB||e===vo.FILE},xo=function(e){return e?{file:e.file,fileKey:e.fileKey,fileType:e.fileType,isReplyToChannel:e.isReplyToChannel,pushNotificationDeliveryOption:e.pushNotificationDeliveryOption}:null},To=Object.assign(Object.assign({},mo),{file:null,fileKey:null,fileUrl:null,fileName:null,fileType:null,fileSize:null,mimeType:null,thumbnailSizes:null,requireAuth:!1}),So=function(e){var t,n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null;return e.messageParams?(!e.url&&H(n)&&(e.messageParams.file=n),e.messageParams):ee({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!=n?n:null===(t=e.messageParams)||void 0===t?void 0:t.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}}))})},Io=function(e){return go(e)&&(H(e.file)||L("string",e.fileUrl))&&L("string",e.fileName,!0)&&L("string",e.mimeType,!0)&&L("number",e.fileSize,!0)&&(null===e.thumbnailSizes||Array.isArray(e.thumbnailSizes)&&e.thumbnailSizes.every((function(e){return L("object",e)&&e.maxWidth>0&&e.maxHeight>0})))},No="undefined"!=typeof document&&"undefined"!=typeof navigator;No&&navigator.userAgent&&navigator.userAgent.includes("Chrome/")&&navigator.userAgent.includes("Chromium/");var Ao=No&&navigator.userAgent&&navigator.userAgent.includes("Firefox/")&&!navigator.userAgent.includes("Seamonkey/");No&&navigator.userAgent&&navigator.userAgent.includes("Safari/")&&!navigator.userAgent.includes("Chrome/")&&navigator.userAgent.includes("Chromium/"),No&&navigator.userAgent&&(navigator.userAgent.includes("OPR/")||navigator.userAgent.includes("Opera/")),No&&navigator.userAgent&&navigator.userAgent.includes("Trident/7.0");var Mo,Oo,Uo=No&&navigator.userAgent&&navigator.userAgent.includes("Edge/"),Ro=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"}(Mo||(Mo={})),function(e){e.NEWNODE="newnode",e.REMOVENODE="removenode",e.CLAIM_HOST="claimhost",e.SYNC_HOST="synchost",e.REQUEST_LOCK="requestlock",e.ACQUIRE_LOCK="acquirelock",e.RELEASE_LOCK="releaselock"}(Oo||(Oo={}));var Lo,Do={},Po=function(){function e(t){var n=this,a=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return r(this,e),this._state=Mo.PROCESSING,this._hostId=null,this._queue=[],this._currentItem=null,this._activationTimeout=null,this._activationQueue=[],Do[t]&&!a.forceCreate||(this.nodeId=Ro(),this.key=t,No&&(a.startAsInvisible?this.registerNode():"visible"===document.visibilityState?this.claimHost():this.registerNode(),document.addEventListener("visibilitychange",(function(){"visible"===document.visibilityState&&n.claimHost()})),window.addEventListener("message",(function(e){var t=e.data,r=t.nodeId,a=t.requestId,s=t.key,i=t.op,o=t.data;if(r!==n.nodeId&&s===n.key)switch(i){case Oo.NEWNODE:n._sendSync();break;case Oo.CLAIM_HOST:n._sendSync(),n._hostId=r;break;case Oo.SYNC_HOST:if(!n.isInSync){n._activationTimeout&&clearTimeout(n._activationTimeout);var u,c=o.currentItemRequestId,l=y(o.queue);try{var h=function(){var e=u.value,t=n._queue.findIndex((function(t){return t.requestId===e.requestId}));t<0&&n._requestLock({nodeId:e.nodeId,requestId:e.requestId,key:n.key,op:Oo.REQUEST_LOCK,ts:e.ts})};for(l.s();!(u=l.n()).done;)h()}catch(e){l.e(e)}finally{l.f()}n._currentItem=n._queue.find((function(e){return e.requestId===c})),n._completeSync()}break;case Oo.REMOVENODE:n._queue=n._queue.filter((function(e){return e.nodeId!==t.nodeId})),n._currentItem&&n._currentItem.nodeId===t.nodeId&&(n._currentItem=null,n._acquire(n._queue[0]));break;case Oo.REQUEST_LOCK:n._requestLock(t);break;case Oo.ACQUIRE_LOCK:var d=n._queue.find((function(e){return e.requestId===a}));n._acquire(d);break;case Oo.RELEASE_LOCK:n._release(a)}})),window.addEventListener("beforeunload",(function(){n._send(Oo.REMOVENODE)}))),Do[t]=this),Do[t]}return s(e,[{key:"locked",get:function(){return!!this._currentItem}},{key:"isHost",get:function(){return this._hostId===this.nodeId}},{key:"isInSync",get:function(){return this._state==Mo.DONE}},{key:"_send",value:function(e){var t,n,r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},a={nodeId:this.nodeId,requestId:null!==(t=null==r?void 0:r.requestId)&&void 0!==t?t:Ro(),key:this.key,op:e,data:null!==(n=r.data)&&void 0!==n?n:null,ts:Date.now()};return No&&window.postMessage(a,"*"),a}},{key:"_acquire",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:null;e?(this._currentItem=e,this._currentItem.onAcquired(e.requestId)):this._currentItem=null}},{key:"_release",value:function(e){if(this._currentItem&&this._currentItem.requestId===e){var t=this._currentItem;this._currentItem=null,t.nodeId===this.nodeId&&this._send(Oo.RELEASE_LOCK,{requestId:t.requestId});var n=this._queue.findIndex((function(t){return t.requestId===e}));n>-1&&this._queue.splice(n,1),t.onReleased(e)}}},{key:"_requestLock",value:function(e){var t=this;return new Promise((function(n){var r={nodeId:e.nodeId,requestId:e.requestId,ts:e.ts,onAcquired:function(e){t.isHost&&t._send(Oo.ACQUIRE_LOCK,{requestId:e}),n()},onReleased:function(){t._acquire(t._queue[0])}},a=!1;for(var s in t._queue)if(t._queue[s].ts>r.ts){t._queue.splice(parseInt(s),0,r),a=!0;break}a||t._queue.push(r),t._currentItem||t._acquire(t._queue[0])}))}},{key:"_sendSync",value:function(){var e;this.isHost&&this._send(Oo.SYNC_HOST,{data:{currentItemRequestId:null===(e=this._currentItem)||void 0===e?void 0:e.requestId,queue:this._queue.map((function(e){return{nodeId:e.nodeId,requestId:e.requestId,ts:e.ts}}))}})}},{key:"_waitUntilSyncCompleted",value:function(){return b(this,void 0,void 0,t().mark((function e(){var n=this;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!this.isHost||this.isInSync){e.next=2;break}return e.abrupt("return",new Promise((function(e){n._activationQueue.push(e)})));case 2:case"end":return e.stop()}}),e,this)})))}},{key:"_waitSync",value:function(){var e=this;this.isInSync||(this._activationTimeout=setTimeout((function(){e._completeSync()}),8))}},{key:"_completeSync",value:function(){this.isInSync||(this._state=Mo.DONE,this._activationQueue.forEach((function(e){return e()})),this._activationQueue=[])}},{key:"registerNode",value:function(){this._send(Oo.NEWNODE),this._waitSync()}},{key:"claimHost",value:function(){this._hostId=this.nodeId,this._send(Oo.CLAIM_HOST),this._waitSync()}},{key:"lock",value:function(){return b(this,void 0,void 0,t().mark((function e(){var n;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this._waitUntilSyncCompleted();case 2:return n=this._send(Oo.REQUEST_LOCK),e.next=5,this._requestLock(n);case 5:case"end":return e.stop()}}),e,this)})))}},{key:"unlock",value:function(){var e;this._release(null===(e=this._currentItem)||void 0===e?void 0:e.requestId)}}]),e}(),Fo=Object.assign(Object.assign({},ko),{scheduledAt:null}),Go=Object.assign(Object.assign({},mo),{scheduledAt:null,file:null,fileUrl:null,fileName:null,mimeType:null,fileSize:null,thumbnailSizes:null,requireAuth:!1}),Ho="UnsentMessage",qo={},jo=function(e){i(a,e);var n=f(a);function a(e,t){var s,i=t.sdkState,o=t.cacheContext;return r(this,a),(s=n.call(this,e))._sdkState=i,s._cacheContext=o,qo[e]=d(s),s._mutex=new Po("unsendmessagecache.lock"),s}return s(a,[{key:"collection",get:function(){var e=this._cacheContext.nestdb;return e&&e.collection(Ho)}},{key:"localCacheEnabled",get:function(){return this._cacheContext.localCacheEnabled&&!!this.collection}},{key:"_serialize",value:function(e){if(e.messageId>0)throw M.invalidParameters;var t,n=Object.assign({},e.serialize());return e instanceof Rs?(e.messageParams&&(n.messageParams=yo(e.messageParams)),e.scheduledInfo&&e.scheduledInfo.scheduledMessageParams&&(n.scheduledInfo.scheduledMessageParams=(t=e.scheduledInfo.scheduledMessageParams,Object.assign(Object.assign({},yo(t)),{scheduledAt:t.scheduledAt})))):e instanceof Ps&&(e.messageParams&&(n.messageParams=xo(e.messageParams)),e.scheduledInfo&&e.scheduledInfo.scheduledMessageParams&&(n.scheduledInfo.scheduledMessageParams=function(e){return Object.assign(Object.assign({},xo(e)),{scheduledAt:e.scheduledAt})}(e.scheduledInfo.scheduledMessageParams))),n}},{key:"_deserialize",value:function(e){return e?(e=Object.assign(Object.assign({},e),{messageId:parseInt(e.messageId)}),vi.of(this._iid).buildMessageFromSerializedData(e)):null}},{key:"_deserializeWithMessageCreateParams",value:function(e){return b(this,void 0,void 0,t().mark((function n(){var r,a,s,i,o,u;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(r=vi.of(this._iid),a=this._deserialize(e),!e.messageParams){t.next=15;break}if(!(a instanceof Rs)){t.next=8;break}s=e.messageParams,a.messageParams=r.buildUserMessageCreateParamsFromSerializedData(s,a),t.next=15;break;case 8:if(!(a instanceof Ps)){t.next=15;break}if(!(i=e.messageParams).fileKey||"string"!=typeof i.fileKey||!Co(i.fileType)){t.next=14;break}return t.next=13,this.collection.getBlob(i.fileKey);case 13:i.file=t.sent;case 14:a.messageParams=r.buildFileMessageCreateParamsFromSerializedData(i,a);case 15:if(!(a.scheduledInfo&&e.scheduledInfo&&e.scheduledInfo.scheduledMessageParams)){t.next=28;break}if(!(a instanceof Rs)){t.next=21;break}o=e.scheduledInfo.scheduledMessageParams,a.scheduledInfo.scheduledMessageParams=r.buildScheduledUserMessageCreateParamsFromSerializedData(o,a),t.next=28;break;case 21:if(!(a instanceof Ps)){t.next=28;break}if(!(u=e.scheduledInfo.scheduledMessageParams).fileKey||"string"!=typeof u.fileKey||!Co(u.fileType)){t.next=27;break}return t.next=26,this.collection.getBlob(u.fileKey);case 26:u.file=t.sent;case 27:a.scheduledInfo.scheduledMessageParams=r.buildScheduledFileMessageCreateParamsFromSerializedData(u,a);case 28:return t.abrupt("return",a);case 29:case"end":return t.stop()}}),n,this)})))}},{key:"get",value:function(e){return b(this,void 0,void 0,t().mark((function n(){var r;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(!this.localCacheEnabled){t.next=6;break}return t.next=3,this.collection.getByKey("".concat(e));case 3:if(!(r=t.sent)){t.next=6;break}return t.abrupt("return",this._deserializeWithMessageCreateParams(r));case 6:return t.abrupt("return",null);case 7:case"end":return t.stop()}}),n,this)})))}},{key:"fetch",value:function(e){var n=e.channelUrl,r=void 0===n?null:n,a=e.filter,s=void 0===a?new po:a,i=e.order,o=void 0===i?ho.CHANNEL_LATEST:i,u=e.sendingStatus,c=void 0===u?null:u,l=e.backward,h=void 0!==l&&l,d=e.parentMessageId,f=void 0===d?null:d;return b(this,void 0,void 0,t().mark((function e(){var n,a,i,u,l,d=this;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!this.localCacheEnabled){e.next=13;break}return n=_o(o),a={"/where":function(e){return!!(o!==ho.NEWEST_CHILD_MESSAGE||f&&0!==e.parentMessageId&&e.parentMessageId===f)&&s.match(d._deserialize(e))}},r&&(a.channelUrl=r),c&&(a.sendingStatus=c),i={where:a,index:n,backward:h},e.next=8,this.collection.query(i);case 8:return u=e.sent,e.next=11,u.fetch({});case 11:return l=e.sent,e.abrupt("return",Promise.all(l.map((function(e){return b(d,void 0,void 0,t().mark((function n(){return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,this._deserializeWithMessageCreateParams(e);case 2:return t.abrupt("return",t.sent);case 3:case"end":return t.stop()}}),n,this)})))}))));case 13:return e.abrupt("return",[]);case 14:case"end":return e.stop()}}),e,this)})))}},{key:"getAllChildMessages",value:function(e){var n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:new po;return b(this,void 0,void 0,t().mark((function r(){return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,this.fetch({filter:n,order:ho.NEWEST_CHILD_MESSAGE,channelUrl:e.channelUrl,backward:!1,parentMessageId:e.messageId});case 2:return t.abrupt("return",t.sent);case 3:case"end":return t.stop()}}),r,this)})))}},{key:"upsert",value:function(e){return b(this,void 0,void 0,t().mark((function n(){var r=this;return t().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:if(!this.localCacheEnabled){n.next=3;break}return n.next=3,Promise.all(e.map((function(e){return b(r,void 0,void 0,t().mark((function n(){var r;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(!(e instanceof Ps)){t.next=7;break}return t.next=3,this._mutex.lock();case 3:return t.next=5,this.saveBlob(e);case 5:return t.next=7,this._mutex.unlock();case 7:return r=this._serialize(e),t.next=10,this.collection.upsertOne(r);case 10:case"end":return t.stop()}}),n,this)})))})));case 3:case"end":return n.stop()}}),n,this)})))}},{key:"upsertChildMessages",value:function(e){return b(this,void 0,void 0,t().mark((function n(){var r=this;return t().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:if(!this.localCacheEnabled){n.next=3;break}return n.next=3,Promise.all(e.map((function(e){return b(r,void 0,void 0,t().mark((function n(){var r,a;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(a=[],!((null===(r=e.threadInfo)||void 0===r?void 0:r.replyCount)>0)){t.next=5;break}return t.next=4,this.getAllChildMessages(e);case 4:a=t.sent;case 5:if(!(a.length>0)){t.next=9;break}return a.forEach((function(t){return t.applyParentMessage(e)})),t.next=9,this.upsert(a);case 9:case"end":return t.stop()}}),n,this)})))})));case 3:case"end":return n.stop()}}),n,this)})))}},{key:"remove",value:function(e){return b(this,void 0,void 0,t().mark((function n(){var r,a,s;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(!this.localCacheEnabled){t.next=18;break}r=y(e),t.prev=2,r.s();case 4:if((a=r.n()).done){t.next=10;break}return s=a.value,t.next=8,this.collection.remove(s);case 8:t.next=4;break;case 10:t.next=15;break;case 12:t.prev=12,t.t0=t.catch(2),r.e(t.t0);case 15:return t.prev=15,r.f(),t.finish(15);case 18:case"end":return t.stop()}}),n,this,[[2,12,15,18]])})))}},{key:"removeMessagesOfChannel",value:function(e){return b(this,void 0,void 0,t().mark((function n(){return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(!this.localCacheEnabled){t.next=3;break}return t.next=3,this.collection.removeIf({where:{channelUrl:e}});case 3:case"end":return t.stop()}}),n,this)})))}},{key:"clear",value:function(){return b(this,void 0,void 0,t().mark((function e(){return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!this.localCacheEnabled){e.next=3;break}return e.next=3,this.collection.clear();case 3:case"end":return e.stop()}}),e,this)})))}},{key:"saveBlob",value:function(e){return b(this,void 0,void 0,t().mark((function n(){var r,a,s,i;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(!(e instanceof Ps)){t.next=17;break}if(!e.messageParams){t.next=9;break}if(!(r=e.messageParams).file||!wo(r.file)){t.next=9;break}return t.next=6,this.collection.saveBlob(r.file,e.reqId);case 6:a=t.sent,r.fileKey=a,r.fileType=vo.BLOB;case 9:if(!e.scheduledInfo||!e.scheduledInfo.scheduledMessageParams){t.next=17;break}if(!(s=e.scheduledInfo.scheduledMessageParams).file||!wo(s.file)){t.next=17;break}return t.next=14,this.collection.saveBlob(s.file,e.reqId);case 14:i=t.sent,s.fileKey=i,s.fileType=vo.BLOB;case 17:case"end":return t.stop()}}),n,this)})))}}],[{key:"of",value:function(e){return qo[e]}}]),a}(Ca),zo=function(n,r){return function(a,s){if(1===a)n.clear().then((function(){r.clear().then((function(){(function(n){return b(void 0,void 0,void 0,t().mark((function r(){return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.abrupt("return",n.commitSchema([{collectionName:uo,keyName:"url",index:[fo(e.GroupChannelListOrder.LATEST_LAST_MESSAGE),fo(e.GroupChannelListOrder.CHRONOLOGICAL),fo(e.GroupChannelListOrder.CHANNEL_NAME_ALPHABETICAL)]},{collectionName:lo,keyName:"messageId",index:[_o(ho.CHANNEL_LATEST),_o(ho.NEWEST_CHILD_MESSAGE)]},{collectionName:Ho,keyName:"reqId",index:[_o(ho.CHANNEL_LATEST),_o(ho.NEWEST_CHILD_MESSAGE)]},{collectionName:"Poll",keyName:"pollId"}]));case 1:case"end":return t.stop()}}),r)})))})(n).then((function(){return s()})).catch((function(e){return s(e)}))})).catch((function(e){return s(e)}))})).catch((function(e){return s(e)}));else s()}},Vo={},Bo=function(e){i(a,e);var n=f(a);function a(e,t){var s,i=t.sdkState,o=t.cacheContext,u=t.unsentMessageCache;return r(this,a),(s=n.call(this,e))._sdkState=i,s._cacheContext=o,s._unsentMessageCache=u,Vo[e]=d(s),s}return s(a,[{key:"collection",get:function(){var e=this._cacheContext.nestdb;return e?e.collection(lo):null}},{key:"localCacheEnabled",get:function(){return this._cacheContext.localCacheEnabled&&!!this.collection}},{key:"_serialize",value:function(e){return Object.assign(Object.assign({},e.serialize()),{messageId:"".concat(e.messageId)})}},{key:"_deserialize",value:function(e){return e=Object.assign(Object.assign({},e),{messageId:parseInt(e.messageId)}),vi.of(this._iid).buildMessageFromSerializedData(e)}},{key:"get",value:function(e){return b(this,void 0,void 0,t().mark((function n(){var r;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(!this.localCacheEnabled){t.next=6;break}return t.next=3,this.collection.getByKey("".concat(e));case 3:if(!(r=t.sent)){t.next=6;break}return t.abrupt("return",this._deserialize(r));case 6:return t.abrupt("return",null);case 7:case"end":return t.stop()}}),n,this)})))}},{key:"fetch",value:function(e){var n=e.channelUrl,r=e.token,a=e.limit,s=void 0===a?co:a,i=e.filter,o=void 0===i?new po:i,u=e.order,c=void 0===u?ho.CHANNEL_LATEST:u,l=e.backward,h=void 0!==l&&l,d=e.parentMessageId,f=void 0===d?null:d,p=e.isPollOnly,v=void 0!==p&&p;return b(this,void 0,void 0,t().mark((function e(){var a,i,u,l,d=this;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!this.localCacheEnabled){e.next=10;break}return a=_o(c),i={where:{channelUrl:n,"/where":function(e){if(r)switch(c){case ho.CHANNEL_LATEST:if(!h&&e.createdAt>r||h&&e.createdAt1&&void 0!==arguments[1]?arguments[1]:new po;return b(this,void 0,void 0,t().mark((function r(){return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,this.fetch({channelUrl:e.channelUrl,token:Date.now(),limit:null,backward:!1,filter:n,order:ho.NEWEST_CHILD_MESSAGE,parentMessageId:e.messageId});case 2:return t.abrupt("return",t.sent);case 3:case"end":return t.stop()}}),r,this)})))}},{key:"upsert",value:function(e){return b(this,void 0,void 0,t().mark((function n(){var r,a=this;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(!this.localCacheEnabled){t.next=10;break}return t.next=3,this.saveBlobs(e);case 3:return r=e.map((function(e){return a._serialize(e)})),t.next=6,this.collection.upsertMany(r);case 6:return t.next=8,this.upsertChildMessages(e);case 8:return t.next=10,this._unsentMessageCache.upsertChildMessages(e);case 10:case"end":return t.stop()}}),n,this)})))}},{key:"upsertChildMessages",value:function(e){return b(this,void 0,void 0,t().mark((function n(){var r=this;return t().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:if(!this.localCacheEnabled){n.next=3;break}return n.next=3,Promise.all(e.map((function(e){return b(r,void 0,void 0,t().mark((function n(){var r,a;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(a=[],!((null===(r=e.threadInfo)||void 0===r?void 0:r.replyCount)>0)){t.next=5;break}return t.next=4,this.getAllChildMessages(e);case 4:a=t.sent;case 5:if(!(a.length>0)){t.next=9;break}return a.forEach((function(t){return t.applyParentMessage(e)})),t.next=9,this.upsert(a);case 9:case"end":return t.stop()}}),n,this)})))})));case 3:case"end":return n.stop()}}),n,this)})))}},{key:"remove",value:function(e){return b(this,void 0,void 0,t().mark((function n(){var r,a,s;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(!this.localCacheEnabled){t.next=18;break}r=y(e),t.prev=2,r.s();case 4:if((a=r.n()).done){t.next=10;break}return s=a.value,t.next=8,this.collection.remove("".concat(s));case 8:t.next=4;break;case 10:t.next=15;break;case 12:t.prev=12,t.t0=t.catch(2),r.e(t.t0);case 15:return t.prev=15,r.f(),t.finish(15);case 18:case"end":return t.stop()}}),n,this,[[2,12,15,18]])})))}},{key:"removeMessagesOfChannel",value:function(e){return b(this,void 0,void 0,t().mark((function n(){var r;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(!this.localCacheEnabled){t.next=12;break}return t.next=3,this.collection.removeIf({where:{channelUrl:e},index:_o(ho.CHANNEL_LATEST)});case 3:return r=this._cacheContext.preference,t.next=6,r.remove("sendbird:".concat(this._sdkState.userId,"@groupchannel/").concat(e,"/message/sync"));case 6:return t.next=8,r.remove("sendbird:".concat(this._sdkState.userId,"@groupchannel/").concat(e,"/message/sync.meta"));case 8:return t.next=10,r.remove("sendbird:".concat(this._sdkState.userId,"@groupchannel/").concat(e,"/message/changelogs"));case 10:return t.next=12,r.remove("sendbird:".concat(this._sdkState.userId,"@groupchannel/").concat(e,"/message/changelogs.meta"));case 12:case"end":return t.stop()}}),n,this)})))}},{key:"removeUnderOffset",value:function(e,n){return b(this,void 0,void 0,t().mark((function r(){return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(!this.localCacheEnabled){t.next=3;break}return t.next=3,this.collection.removeIf({where:{channelUrl:e,createdAt:{"<":n}},index:_o(ho.CHANNEL_LATEST)});case 3:case"end":return t.stop()}}),r,this)})))}},{key:"clear",value:function(){return b(this,void 0,void 0,t().mark((function e(){return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!this.localCacheEnabled){e.next=3;break}return e.next=3,this.collection.clear();case 3:case"end":return e.stop()}}),e,this)})))}},{key:"countBetween",value:function(e,n,r){return b(this,void 0,void 0,t().mark((function a(){var s,i,o=this;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(!this.localCacheEnabled){t.next=6;break}return s=_o(ho.CHANNEL_LATEST),i=this.collection.query({where:{channelUrl:e,"/where":function(e){var t=o._deserialize(e);return r.includes(t.createdAt)&&n.match(t)}},index:s}),t.next=5,i.count();case 5:return t.abrupt("return",t.sent);case 6:return t.abrupt("return",0);case 7:case"end":return t.stop()}}),a,this)})))}},{key:"saveBlobs",value:function(e){return b(this,void 0,void 0,t().mark((function n(){var r=this;return t().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return n.next=2,Promise.all(e.map((function(e){return b(r,void 0,void 0,t().mark((function n(){var r,a;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(!(e instanceof Ps&&e.messageParams)){t.next=7;break}if(!(r=e.messageParams).file||!wo(r.file)){t.next=7;break}return t.next=5,this.collection.saveBlob(r.file,e.reqId);case 5:a=t.sent,r.fileKey=a;case 7:case"end":return t.stop()}}),n,this)})))})));case 2:case"end":return n.stop()}}),n)})))}},{key:"_getGroupChannelPreferenceSize",value:function(e){return b(this,void 0,void 0,t().mark((function n(){var r,a,s,i,o,u;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return r=0,a=this._cacheContext.preference,t.next=4,a.get("sendbird:".concat(this._sdkState.userId,"@groupchannel/").concat(e,"/message/sync"));case 4:return s=t.sent,t.next=7,a.get("sendbird:".concat(this._sdkState.userId,"@groupchannel/").concat(e,"/message/sync.meta"));case 7:return i=t.sent,t.next=10,a.get("sendbird:".concat(this._sdkState.userId,"@groupchannel/").concat(e,"/message/changelogs"));case 10:return o=t.sent,t.next=13,a.get("sendbird:".concat(this._sdkState.userId,"@groupchannel/").concat(e,"/message/changelogs.meta"));case 13:return u=t.sent,s&&(r+=JSON.stringify(s).length),i&&(r+=JSON.stringify(i).length),o&&(r+=JSON.stringify(o).length),u&&(r+=JSON.stringify(u).length),t.abrupt("return",r);case 19:case"end":return t.stop()}}),n,this)})))}}],[{key:"of",value:function(e){return Vo[e]}}]),a}(Ca),Qo=function(){return"undefined"!=typeof document?document.visibilityState:"visible"},Ko=function(e){i(n,e);var t=f(n);function n(e){var a,s=e.getVisibilityState,i=void 0===s?Qo:s,o=e.initialState,u=void 0===o?"visible":o,c=e.isEnabled,l=void 0===c||c,h=e.pauseCheckDelay,f=void 0===h?3e4:h;return r(this,n),(a=t.call(this))._pauseCheckDelay=3e4,a._pauseDelayTimer=null,a._currentState="visible",a._getVisibilityState=i,a._pauseCheckDelay=f,a._currentState=u,a._isEnabled=l,a._boundToggleState=a._toggleState.bind(d(a)),a}return s(n,[{key:"currentState",get:function(){return this._currentState}},{key:"isAvailable",get:function(){return"undefined"!=typeof window&&!!window.addEventListener&&!!window.removeEventListener}},{key:"_toggleState",value:function(){var e=this,t=this._getVisibilityState();"hidden"!==t?"hidden"===this._currentState&&(this._pauseDelayTimer&&(clearTimeout(this._pauseDelayTimer),this._pauseDelayTimer=null),this.dispatch("resume")):"hidden"!==this._currentState&&(this._pauseDelayTimer=setTimeout((function(){e._pauseDelayTimer=null,e.dispatch("pause")}),this._pauseCheckDelay)),this._currentState=t}},{key:"start",value:function(){this._isEnabled&&this.isAvailable&&(this._boundToggleState=this._toggleState.bind(this),window.addEventListener("visibilitychange",this._boundToggleState,{capture:!0}))}},{key:"stop",value:function(){this._isEnabled&&this.isAvailable&&this._boundToggleState&&window.removeEventListener("visibilitychange",this._boundToggleState,{capture:!0})}}]),n}(J),Wo=function(){function e(t){var n=this,a=t.logger,s=t.connectionDelegate,i=void 0===s?null:s;r(this,e),this._onlineWorker=function(){var e;return null===(e=n.connectionDelegate)||void 0===e?void 0:e.reconnect()},this._offlineWorker=function(){var e;return null===(e=n.connectionDelegate)||void 0===e?void 0:e.disconnect()},this.unsubscribes=[],this._onlineListener=function(e){if(n.isAvailableOnWeb)return window.addEventListener("online",e),function(){return window.removeEventListener("online",e,!1)}},this._offlineListener=function(e){if(n.isAvailableOnWeb)return window.addEventListener("offline",e),function(){return window.removeEventListener("offline",e,!1)}},this.logger=a,i&&(this.connectionDelegate=i)}return s(e,[{key:"isAvailableOnWeb",get:function(){return"undefined"!=typeof window&&window.addEventListener&&"ononline"in window&&"onoffline"in window&&"undefined"!=typeof navigator&&void 0!==navigator.onLine}},{key:"setOnlineListener",value:function(e){Boolean(e)&&"function"==typeof e&&(this._onlineListener=e)}},{key:"setOfflineListener",value:function(e){Boolean(e)&&"function"==typeof e&&(this._offlineListener=e)}},{key:"start",value:function(){this.unsubscribes=[this._onlineListener(this._onlineWorker),this._offlineListener(this._offlineWorker)]}},{key:"stop",value:function(){var e=this;this.unsubscribes.forEach((function(t){try{null==t||t()}catch(t){e.logger.warn(t.message)}})),this.unsubscribes=[]}},{key:"isOnline",value:function(){return b(this,void 0,void 0,t().mark((function e(){return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!this.isAvailableOnWeb){e.next=4;break}return e.abrupt("return",navigator.onLine);case 4:return e.abrupt("return",new Promise((function(e){fetch("https://www.google.com",{method:B.GET,mode:"no-cors"}).then((function(){return e(!0)})).catch((function(){return e(!1)}))})));case 5:case"end":return e.stop()}}),e,this)})))}}]),e}(),Yo=function(e){i(n,e);var t=f(n);function n(e){var a,s=e.message;return r(this,n),(a=t.call(this)).message=s,a}return s(n)}($),Zo={},Jo=function(){function n(e,t){var a=this,s=t.localCacheEnabled,i=t.dispatcher,o=t.sdkState,u=t.logger;r(this,n),this._iid=e,Zo[e]=this,this._localCacheEnabled=s,this._isProcessingAutoResend=!1,this._autoResendQueue=[],this._dispatcher=i,this._logger=u,this._sdkState=o,this._localCacheEnabled&&i.on((function(e){if(e instanceof Dr)switch(e.stateType){case Nr.CONNECTED:a._isProcessingAutoResend||a.processAutoResendRegisteredPendingMessages().then((function(){return a._processNextAutoResend()}));break;case Nr.INTERNAL_DISCONNECTED:case Nr.EXTERNAL_DISCONNECTED:a._isProcessingAutoResend=!1}}))}return s(n,[{key:"processNonAutoResendRegisteredPendingMessages",value:function(){return b(this,void 0,void 0,t().mark((function n(){var r,a,s,i;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,this._fetchAllCachedPendingMessages();case 2:r=t.sent,a=y(r);try{for(a.s();!(s=a.n()).done;)0===(i=s.value).errorCode&&(this._logger.debug("cached pending message is not auto-resend registered. changing its sending status to failed: ",i.reqId),i.sendingStatus=e.SendingStatus.FAILED,i.errorCode=E.ACK_TIMEOUT,this._dispatcher.dispatch(new ei({messages:[i],source:e.MessageEventSource.LOCAL_MESSAGE_FAILED})))}catch(e){a.e(e)}finally{a.f()}case 5:case"end":return t.stop()}}),n,this)})))}},{key:"processAutoResendRegisteredPendingMessages",value:function(){return b(this,void 0,void 0,t().mark((function n(){var r,a,s,i,o,u;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,this._fetchAllCachedPendingMessages();case 2:r=t.sent,a=y(r);try{for(a.s();!(s=a.n()).done;)(i=s.value).errorCode&&G(i.errorCode)&&(o=(new Date).getTime(),u=i.createdAt+2592e5,o<=u?this._autoResendQueue.map((function(e){return e.reqId})).indexOf(i.reqId)<0&&this._autoResendQueue.push(i):(this._logger.debug("auto-resend registered pending messaged expired. expiration date: ",new Date(u).toLocaleString()),i.sendingStatus=e.SendingStatus.FAILED,this._dispatcher.dispatch(new ei({messages:[i],source:e.MessageEventSource.LOCAL_MESSAGE_FAILED}))))}catch(e){a.e(e)}finally{a.f()}case 5:case"end":return t.stop()}}),n,this)})))}},{key:"completeCurrentAndProcessNextAutoResend",value:function(t){if(this._localCacheEnabled&&(t.sendingStatus===e.SendingStatus.SUCCEEDED||t.sendingStatus===e.SendingStatus.FAILED&&!G(t.errorCode))){var n=this.indexOf(t);n>=0&&this._autoResendQueue.splice(n,1),0===n&&this._processNextAutoResend()}}},{key:"_fetchAllCachedPendingMessages",value:function(){return b(this,void 0,void 0,t().mark((function n(){var r;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(!(r=jo.of(this._iid))){t.next=7;break}return t.next=4,r.fetch({sendingStatus:e.SendingStatus.PENDING,backward:!0});case 4:t.t0=t.sent,t.next=8;break;case 7:t.t0=[];case 8:return t.abrupt("return",t.t0);case 9:case"end":return t.stop()}}),n,this)})))}},{key:"indexOf",value:function(e){return this._autoResendQueue.length>0?this._autoResendQueue.map((function(e){return e.reqId})).indexOf(e.reqId):-1}},{key:"_isNotInQueue",value:function(e){return-1===this._autoResendQueue.map((function(e){return e.reqId})).indexOf(e.reqId)}},{key:"_processNextAutoResend",value:function(){return b(this,void 0,void 0,t().mark((function e(){var n;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(this._localCacheEnabled&&"foreground"===this._sdkState.appState)try{this._autoResendQueue.length>0?(this._isProcessingAutoResend||(this._logger.debug("auto-resend queue started."),this._isProcessingAutoResend=!0),n=this._autoResendQueue[0],this._dispatcher.dispatch(new Yo({message:n})),this._logger.debug("processing auto-resend for message request id: ",n.reqId)):(this._logger.debug("auto-resend queue finished."),this._isProcessingAutoResend=!1)}catch(e){this._logger.warn("process auto-resend error: ",e),this._isProcessingAutoResend=!1}case 1:case"end":return e.stop()}}),e,this)})))}}],[{key:"of",value:function(e){return Zo[e]}}]),n}();!function(e){e[e.USER_BLOCK=20001]="USER_BLOCK",e[e.USER_UNBLOCK=2e4]="USER_UNBLOCK",e[e.FRIEND_DISCOVERED=20900]="FRIEND_DISCOVERED"}(Lo||(Lo={}));var Xo,$o=function(){function e(t){r(this,e),this.category=t.cat,this.data=t.data}return s(e,null,[{key:"getDataAsUserBlockEvent",value:function(e,t){var n=t.data,r=n.blocker,a=n.blockee;return{blocker:new La(e,r),blockee:new La(e,a)}}},{key:"getDataAsFriendDiscoveredEvent",value:function(e,t){var n=t.data.friend_discoveries;return{friendDiscoveries:Array.isArray(n)?n.map((function(t){return new La(e,t)})):[]}}}]),e}(),eu=function(e){i(n,e);var t=f(n);function n(e,a){var s,i=a.userId;return r(this,n),(s=t.call(this))._iid=e,s.userId=i,s}return s(n)}($);e.GroupChannelEventSource=void 0,(Xo=e.GroupChannelEventSource||(e.GroupChannelEventSource={})).UNKNOWN="UNKNOWN",Xo.EVENT_CHANNEL_CREATED="EVENT_CHANNEL_CREATED",Xo.EVENT_CHANNEL_UPDATED="EVENT_CHANNEL_UPDATED",Xo.EVENT_CHANNEL_DELETED="EVENT_CHANNEL_DELETED",Xo.EVENT_CHANNEL_READ="EVENT_CHANNEL_READ",Xo.EVENT_CHANNEL_DELIVERED="EVENT_CHANNEL_DELIVERED",Xo.EVENT_CHANNEL_INVITED="EVENT_CHANNEL_INVITED",Xo.EVENT_CHANNEL_JOINED="EVENT_CHANNEL_JOINED",Xo.EVENT_CHANNEL_LEFT="EVENT_CHANNEL_LEFT",Xo.EVENT_CHANNEL_ACCEPTED_INVITE="EVENT_CHANNEL_ACCEPTED_INVITE",Xo.EVENT_CHANNEL_DECLINED_INVITE="EVENT_CHANNEL_DECLINED_INVITE",Xo.EVENT_CHANNEL_OPERATOR_UPDATED="EVENT_CHANNEL_OPERATOR_UPDATED",Xo.EVENT_CHANNEL_MUTED="EVENT_CHANNEL_MUTED",Xo.EVENT_CHANNEL_UNMUTED="EVENT_CHANNEL_UNMUTED",Xo.EVENT_CHANNEL_FROZEN="EVENT_CHANNEL_FROZEN",Xo.EVENT_CHANNEL_UNFROZEN="EVENT_CHANNEL_UNFROZEN",Xo.EVENT_CHANNEL_HIDDEN="EVENT_CHANNEL_HIDDEN",Xo.EVENT_CHANNEL_UNHIDDEN="EVENT_CHANNEL_UNHIDDEN",Xo.EVENT_CHANNEL_RESET_HISTORY="EVENT_CHANNEL_RESET_HISTORY",Xo.EVENT_CHANNEL_TYPING_STATUS_UPDATE="EVENT_CHANNEL_TYPING_STATUS_UPDATE",Xo.EVENT_CHANNEL_MEMBER_COUNT_UPDATED="EVENT_CHANNEL_MEMBER_COUNT_UPDATED",Xo.EVENT_MESSAGE_SENT="EVENT_MESSAGE_SENT",Xo.EVENT_MESSAGE_RECEIVED="EVENT_MESSAGE_RECEIVED",Xo.EVENT_MESSAGE_UPDATED="EVENT_MESSAGE_UPDATED",Xo.EVENT_PINNED_MESSAGE_UPDATED="EVENT_PINNED_MESSAGE_UPDATED",Xo.REQUEST_CHANNEL="REQUEST_CHANNEL",Xo.REQUEST_CHANNEL_CHANGELOGS="REQUEST_CHANNEL_CHANGELOGS",Xo.REFRESH_CHANNEL="REFRESH_CHANNEL",Xo.CHANNEL_LASTACCESSEDAT_UPDATED="CHANNEL_LASTACCESSEDAT_UPDATED",Xo.SYNC_CHANNEL_BACKGROUND="SYNC_CHANNEL_BACKGROUND",Xo.SYNC_CHANNEL_CHANGELOGS="SYNC_CHANNEL_CHANGELOGS";var tu,nu=function(t){return t.startsWith("EVENT_")||t===e.GroupChannelEventSource.SYNC_CHANNEL_CHANGELOGS||t===e.GroupChannelEventSource.REFRESH_CHANNEL},ru=function(e){i(n,e);var t=f(n);function n(e){var a,s=e.channels,i=e.source,o=e.data,u=void 0===o?null:o;return r(this,n),(a=t.call(this)).channels=s,a.source=i,a.data=u,a}return s(n)}($),au=function(e){i(n,e);var t=f(n);function n(e){var a,s=e.channelUrls,i=e.source;return r(this,n),(a=t.call(this)).channelUrls=s,a.source=i,a}return s(n)}($),su=function(e){i(n,e);var t=f(n);function n(){return r(this,n),t.call(this)}return s(n)}($),iu=function(e){i(n,e);var t=f(n);function n(e,a,s){var i;return r(this,n),(i=t.call(this,e,"USEV",s)).event=new $o(s),i}return s(n)}(le),ou=function(e){i(n,e);var t=f(n);function n(e){var a,s=e.userId,i=e.nickname,o=void 0===i?null:i,u=e.profileUrl,c=void 0===u?null:u,l=e.profileImage,h=void 0===l?null:l,d=e.preferredLanguages,f=void 0===d?null:d;return r(this,n),(a=t.call(this)).method=B.PUT,a.path="".concat(qr,"/").concat(encodeURIComponent(s)),a.params=ee({nickname:o,profile_url:c,profile_file:h,preferred_languages:f}),a}return s(n)}(ne),uu=function(e){i(n,e);var t=f(n);function n(e,a){var s;return r(this,n),(s=t.call(this,e,a)).user=null,s.user=new La(e,Object.assign({},a)),s}return s(n)}(re),cu=function(e){i(n,e);var t=f(n);function n(e){var a,s=e.userId,i=e.token;return r(this,n),(a=t.call(this)).method=B.POST,a.path="".concat(qr,"/").concat(encodeURIComponent(s),"/push/apns"),a.params={apns_device_token:i,always_push:!0},a}return s(n)}(ne),lu=function(e){i(n,e);var t=f(n);function n(e){var a,s=e.userId,i=e.token;return r(this,n),(a=t.call(this)).method=B.POST,a.path="".concat(qr,"/").concat(encodeURIComponent(s),"/push/gcm"),a.params={gcm_reg_token:i,always_push:!0},a}return s(n)}(ne),hu=function(e){i(n,e);var t=f(n);function n(e){var a,s=e.userId,i=e.token;return r(this,n),(a=t.call(this)).method=B.DELETE,a.path="".concat(qr,"/").concat(encodeURIComponent(s),"/push/apns/").concat(encodeURIComponent(i)),a}return s(n)}(ne),du=function(e){i(n,e);var t=f(n);function n(e){var a,s=e.userId,i=e.token;return r(this,n),(a=t.call(this)).method=B.DELETE,a.path="".concat(qr,"/").concat(encodeURIComponent(s),"/push/gcm/").concat(encodeURIComponent(i)),a}return s(n)}(ne),fu=function(e){i(n,e);var t=f(n);function n(e){var a,s=e.userId;return r(this,n),(a=t.call(this)).method=B.DELETE,a.path="".concat(qr,"/").concat(encodeURIComponent(s),"/push/apns"),a}return s(n)}(ne),pu=function(e){i(n,e);var t=f(n);function n(e){var a,s=e.userId;return r(this,n),(a=t.call(this)).method=B.DELETE,a.path="".concat(qr,"/").concat(encodeURIComponent(s),"/push/gcm"),a}return s(n)}(ne),vu=function(e){i(n,e);var t=f(n);function n(e){var a,s=e.userId,i=e.type,o=e.token,u=e.ts;return r(this,n),(a=t.call(this)).method=B.GET,a.path="".concat(qr,"/").concat(encodeURIComponent(s),"/push/").concat(encodeURIComponent(i),"/device_tokens"),a.params={created_ts:u,token:o},a}return s(n)}(ne),_u=function(t){i(a,t);var n=f(a);function a(t,s){var i;return r(this,a),(i=n.call(this,t,s)).pushTokens={type:s.type?e.PushTokenType[s.type.toLowerCase()]:e.PushTokenType.UNKNOWN,deviceTokens:s.device_tokens,hasMore:s.has_more,token:s.token},i}return s(a)}(re),mu=function(e){i(n,e);var t=f(n);function n(e){var a,s=e.userId;return r(this,n),(a=t.call(this)).method=B.GET,a.path="".concat(qr,"/").concat(encodeURIComponent(s),"/channel_invitation_preference"),a}return s(n)}(ne),gu=function(e){i(n,e);var t=f(n);function n(e,a){var s;return r(this,n),(s=t.call(this,e,a)).autoAccept=a.auto_accept,s}return s(n)}(re),yu=function(e){i(n,e);var t=f(n);function n(e){var a,s=e.userId,i=e.willAutoAccept;return r(this,n),(a=t.call(this)).method=B.PUT,a.path="".concat(qr,"/").concat(encodeURIComponent(s),"/channel_invitation_preference"),a.params={auto_accept:i},a}return s(n)}(ne),ku=function(e){i(n,e);var t=f(n);function n(e,a){var s;return r(this,n),(s=t.call(this,e,a)).autoAccept=a.auto_accept,s}return s(n)}(re),bu=function(e){i(n,e);var t=f(n);function n(e){var a,s=e.userId;return r(this,n),(a=t.call(this)).method=B.GET,a.path="".concat(qr,"/").concat(encodeURIComponent(s),"/push_preference"),a}return s(n)}(ne),Eu=function(e){i(n,e);var t=f(n);function n(e,a){var s;return r(this,n),(s=t.call(this,e,a)).preference={doNotDisturbOn:a.do_not_disturb,startHour:a.start_hour,startMin:a.start_min,endHour:a.end_hour,endMin:a.end_min,timezone:a.timezone},s}return s(n)}(re),wu=function(e){i(n,e);var t=f(n);function n(e){var a,s=e.userId,i=e.doNotDisturbOn,o=e.startHour,u=e.startMin,c=e.endHour,l=e.endMin,h=e.timezone;return r(this,n),(a=t.call(this)).method=B.PUT,a.path="".concat(qr,"/").concat(encodeURIComponent(s),"/push_preference"),a.params={do_not_disturb:i,start_hour:o,start_min:u,end_hour:c,end_min:l,timezone:h},a}return s(n)}(ne),Cu=function(e){i(n,e);var t=f(n);function n(e,a){var s;return r(this,n),(s=t.call(this,e,a)).preference={doNotDisturbOn:a.do_not_disturb,startHour:a.start_hour,startMin:a.start_min,endHour:a.end_hour,endMin:a.end_min,timezone:a.timezone},s}return s(n)}(re),xu=function(e){i(n,e);var t=f(n);function n(e){var a,s=e.userId;return r(this,n),(a=t.call(this)).method=B.GET,a.path="".concat(qr,"/").concat(encodeURIComponent(s),"/push_preference"),a}return s(n)}(ne),Tu=function(e){i(n,e);var t=f(n);function n(e,a){var s;return r(this,n),(s=t.call(this,e,a)).snoozePeriod={isSnoozeOn:a.snooze_enabled},"number"==typeof a.snooze_start_ts&&(s.snoozePeriod.startTs=a.snooze_start_ts),"number"==typeof a.snooze_end_ts&&(s.snoozePeriod.endTs=a.snooze_end_ts),s}return s(n)}(re),Su=function(e){i(n,e);var t=f(n);function n(e){var a,s=e.userId,i=e.snoozeOn,o=e.startTs,u=e.endTs;return r(this,n),(a=t.call(this)).method=B.PUT,a.path="".concat(qr,"/").concat(encodeURIComponent(s),"/push_preference"),a.params={snooze_enabled:i,snooze_start_ts:o,snooze_end_ts:u},a}return s(n)}(ne),Iu=function(e){i(n,e);var t=f(n);function n(e,a){var s;return r(this,n),(s=t.call(this,e,a)).snoozePeriod={isSnoozeOn:a.snooze_enabled},"number"==typeof a.snooze_start_ts&&(s.snoozePeriod.startTs=a.snooze_start_ts),"number"==typeof a.snooze_end_ts&&(s.snoozePeriod.endTs=a.snooze_end_ts),s}return s(n)}(re),Nu=function(e){i(n,e);var t=f(n);function n(e){var a,s=e.userId,i=e.blockedUserId;return r(this,n),(a=t.call(this)).method=B.POST,a.path="".concat(qr,"/").concat(encodeURIComponent(s),"/block"),a.params={target_id:i},a}return s(n)}(ne),Au=function(e){i(n,e);var t=f(n);function n(e){var a,s=e.userId,i=e.unblockedUserId;return r(this,n),(a=t.call(this)).method=B.DELETE,a.path="".concat(qr,"/").concat(encodeURIComponent(s),"/block/").concat(encodeURIComponent(i)),a}return s(n)}(ne),Mu=function(e){i(n,e);var t=f(n);function n(e){var a,s=e.userId;return r(this,n),(a=t.call(this)).method=B.GET,a.path="".concat(qr,"/").concat(encodeURIComponent(s),"/push_preference"),a}return s(n)}(ne),Ou=function(e){i(n,e);var t=f(n);function n(e,a){var s;return r(this,n),(s=t.call(this,e,a)).pushTriggerOption=a.push_trigger_option,s}return s(n)}(re),Uu=function(e){i(n,e);var t=f(n);function n(e){var a,s=e.userId,i=e.pushTriggerOption;return r(this,n),(a=t.call(this)).method=B.PUT,a.path="".concat(qr,"/").concat(encodeURIComponent(s),"/push_preference"),a.params={push_trigger_option:i},a}return s(n)}(ne),Ru=function(e){i(n,e);var t=f(n);function n(e,a){var s;return r(this,n),(s=t.call(this,e,a)).pushTriggerOption=a.push_trigger_option,s}return s(n)}(re),Lu=function(e){i(n,e);var t=f(n);function n(e){var a,s=e.userId;return r(this,n),(a=t.call(this)).method=B.GET,a.path="".concat(qr,"/").concat(encodeURIComponent(s),"/push/template"),a}return s(n)}(ne),Du=function(e){i(n,e);var t=f(n);function n(e,a){var s;return r(this,n),(s=t.call(this,e,a)).name=a.name,s}return s(n)}(re),Pu=function(e){i(n,e);var t=f(n);function n(e){var a,s=e.userId,i=e.templateName;return r(this,n),(a=t.call(this)).method=B.PUT,a.path="".concat(qr,"/").concat(encodeURIComponent(s),"/push/template"),a.params={name:i},a}return s(n)}(ne),Fu=function(e){i(n,e);var t=f(n);function n(e,a){var s;return r(this,n),(s=t.call(this,e,a)).name=a.name,s}return s(n)}(re),Gu=function(e){i(n,e);var t=f(n);function n(e){var a,s=e.userId,i=e.token;return r(this,n),(a=t.call(this)).method=B.GET,a.path="".concat(qr,"/").concat(encodeURIComponent(s),"/friends/changelogs"),a.params={token:i},a}return s(n)}(ne),Hu=function(e){i(n,e);var t=f(n);function n(e,a){var s;return r(this,n),(s=t.call(this,e,a)).changelogs={addedUsers:a.added.map((function(t){return new La(e,t)})),updatedUsers:a.updated.map((function(t){return new La(e,t)})),deletedUserIds:a.deleted,hasMore:a.has_more,token:a.next},s}return s(n)}(re),qu=function(e){i(n,e);var t=f(n);function n(e){var a,s=e.userId,i=e.discoveries;return r(this,n),(a=t.call(this)).method=B.PUT,a.path="".concat(qr,"/").concat(encodeURIComponent(s),"/friend_discoveries"),a.params={friend_discoveries:i.map((function(e){return{friend_discovery_key:e.friendDiscoveryKey,friend_name:e.friendName}}))},a}return s(n)}(ne),ju=function(e){i(n,e);var t=f(n);function n(e,a){var s;return r(this,n),(s=t.call(this,e,a)).friendDiscoveryRequestId=a.friend_discovery_request_id,s}return s(n)}(re),zu=function(e){i(n,e);var t=f(n);function n(e){var a,s=e.userId,i=e.discoveryKeys;return r(this,n),(a=t.call(this)).method=B.DELETE,a.path="".concat(qr,"/").concat(encodeURIComponent(s),"/friend_discoveries"),a.params={friend_discovery_keys:i},a}return s(n)}(ne),Vu=function(e){i(n,e);var t=f(n);function n(e){var a,s=e.userId,i=e.userIds;return r(this,n),(a=t.call(this)).method=B.POST,a.path="".concat(qr,"/").concat(encodeURIComponent(s),"/friends"),a.params={user_ids:i},a}return s(n)}(ne),Bu=function(e){i(n,e);var t=f(n);function n(e,a){var s;return r(this,n),(s=t.call(this,e,a)).users=a.users.map((function(t){return new La(e,t)})),s}return s(n)}(re),Qu=function(e){i(n,e);var t=f(n);function n(e){var a,s=e.userId,i=e.userIds;return r(this,n),(a=t.call(this)).method=B.DELETE,a.path="".concat(qr,"/").concat(encodeURIComponent(s),"/friends"),a.params={user_ids:i},a}return s(n)}(ne),Ku=function(e){i(n,e);var t=f(n);function n(e){var a,s=e.userId;return r(this,n),(a=t.call(this)).method=B.GET,a.path="".concat(qr,"/").concat(s,"/allow_friend_discovery"),a.params={},a}return s(n)}(ne),Wu=function(e){i(n,e);var t=f(n);function n(e,a){var s;return r(this,n),(s=t.call(this,e,a)).allowFriendDiscovery=a.allow_friend_discovery,s}return s(n)}(re),Yu=function(e){i(n,e);var t=f(n);function n(e){var a,s=e.userId,i=e.allowFriendDiscovery;return r(this,n),(a=t.call(this)).method=B.PUT,a.path="".concat(qr,"/").concat(s,"/allow_friend_discovery"),a.params={allow_friend_discovery:i},a}return s(n)}(ne),Zu=s((function e(t){r(this,e),this.key=null,this.url=null,this.key=t.key,this.url=t.url})),Ju=s((function e(t){var n,a,s;r(this,e),this.id=0,this.name=null,this.url=null,this.emojis=[],this.id=null!==(n=t.id)&&void 0!==n?n:0,this.name=null!==(a=t.name)&&void 0!==a?a:"",this.url=null!==(s=t.url)&&void 0!==s?s:"",this.emojis=t.emojis?t.emojis.map((function(e){return new Zu(e)})):[]})),Xu=s((function e(t){r(this,e),this.emojiHash=null,this.emojiCategories=[],this.emojiHash=t.emoji_hash||"",this.emojiCategories=t.emoji_categories?t.emoji_categories.map((function(e){return new Ju(e)})):[]})),$u=function(e){i(n,e);var t=f(n);function n(){var e;return r(this,n),(e=t.call(this)).method=B.GET,e.path=Zr,e}return s(n)}(ne),ec=function(e){i(n,e);var t=f(n);function n(e,a){var s;return r(this,n),(s=t.call(this,e,a)).emojiContainer=new Xu(a),s}return s(n)}(re),tc=function(e){i(n,e);var t=f(n);function n(e){var a,s=e.categoryId;return r(this,n),(a=t.call(this)).method=B.GET,a.path="".concat(Zr,"/").concat(s),a}return s(n)}(ne),nc=function(e){i(n,e);var t=f(n);function n(e,a){var s;return r(this,n),(s=t.call(this,e,a)).emojiCategory=new Ju(a),s}return s(n)}(re),rc=function(e){i(n,e);var t=f(n);function n(e){var a,s=e.key;return r(this,n),(a=t.call(this)).method=B.GET,a.path="".concat(Yr,"/").concat(s),a}return s(n)}(ne),ac=function(e){i(n,e);var t=f(n);function n(e,a){var s;return r(this,n),(s=t.call(this,e,a)).emoji=new Zu(a),s}return s(n)}(re),sc=function(e){i(n,e);var t=f(n);function n(e){var a,s=e.limit,i=e.token,o=e.userIdsFilter,u=e.metaDataKeyFilter,c=e.metaDataValuesFilter,l=e.nicknameStartsWithFilter;return r(this,n),(a=t.call(this)).method=B.GET,a.path=qr,a.params=ee({limit:s,token:i,user_ids:o,metadatakey:u,metadatavalues_in:c,nickname_startswith:l}),a}return s(n)}(ne),ic=function(e){i(n,e);var t=f(n);function n(e,a){var s;return r(this,n),(s=t.call(this,e,a)).users=a.users.map((function(t){return new La(e,t)})),s.next=a.next,s}return s(n)}(re),oc=function(e){i(a,e);var n=f(a);function a(e,t){var s,i,o,u;return r(this,a),(s=n.call(this,e,t)).userIdsFilter=null,s.metaDataKeyFilter=null,s.metaDataValuesFilter=null,s.nicknameStartsWithFilter=null,s.userIdsFilter=null!==(i=t.userIdsFilter)&&void 0!==i?i:null,s.metaDataKeyFilter=null!==(o=t.metaDataKeyFilter)&&void 0!==o?o:null,s.metaDataValuesFilter=null!==(u=t.metaDataValuesFilter)&&void 0!==u?u:null,s.nicknameStartsWithFilter=t.nicknameStartsWithFilter||null,s}return s(a,[{key:"_validate",value:function(){return p(o(a.prototype),"_validate",this).call(this)&&F("string",this.userIdsFilter,!0)&&L("string",this.metaDataKeyFilter,!0)&&F("string",this.metaDataValuesFilter,!0)&&L("string",this.metaDataKeyFilter,!0)}},{key:"next",value:function(){return b(this,void 0,void 0,t().mark((function e(){var n,r,a,s,i,o,u;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!this._validate()){e.next=20;break}if(this._isLoading){e.next=17;break}if(!this._hasNext){e.next=14;break}return this._isLoading=!0,n=ns.of(this._iid),r=n.requestQueue,a=new sc(Object.assign(Object.assign({},this),{token:this._token})),e.next=8,r.send(a);case 8:return s=e.sent,i=s.as(ic),o=i.users,u=i.next,this._token=u,this._hasNext=!!u,this._isLoading=!1,e.abrupt("return",o);case 14:return e.abrupt("return",[]);case 17:throw M.queryInProgress;case 18:e.next=21;break;case 20:throw M.invalidParameters;case 21:case"end":return e.stop()}}),e,this)})))}}]),a}(ki),uc=function(e){i(n,e);var t=f(n);function n(e){var a,s=e.userId,i=e.limit,o=e.token,u=e.userIdsFilter;return r(this,n),(a=t.call(this)).method=B.GET,a.path="".concat(qr,"/").concat(s,"/block"),a.params=ee({limit:i,token:o,user_ids:u}),a}return s(n)}(ne),cc=function(e){i(n,e);var t=f(n);function n(e,a){var s;return r(this,n),(s=t.call(this,e,a)).users=a.users.map((function(t){return new La(e,t)})),s.next=a.next,s}return s(n)}(re),lc=function(e){i(a,e);var n=f(a);function a(e,t){var s,i;return r(this,a),(s=n.call(this,e,t)).userIdsFilter=null,s.userIdsFilter=null!==(i=t.userIdsFilter)&&void 0!==i?i:null,s}return s(a,[{key:"_validate",value:function(){return p(o(a.prototype),"_validate",this).call(this)&&F("string",this.userIdsFilter,!0)}},{key:"next",value:function(){return b(this,void 0,void 0,t().mark((function e(){var n,r,a,s,i,o,u,c;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!this._validate()){e.next=20;break}if(this._isLoading){e.next=17;break}if(!this._hasNext){e.next=14;break}return this._isLoading=!0,n=ns.of(this._iid),r=n.sdkState,a=n.requestQueue,s=new uc(Object.assign(Object.assign({},this),{userId:r.userId,token:this._token})),e.next=8,a.send(s);case 8:return i=e.sent,o=i.as(cc),u=o.users,c=o.next,this._token=c,this._hasNext=!!c,this._isLoading=!1,e.abrupt("return",u);case 14:return e.abrupt("return",[]);case 17:throw M.queryInProgress;case 18:e.next=21;break;case 20:throw M.invalidParameters;case 21:case"end":return e.stop()}}),e,this)})))}}]),a}(ki),hc=function(e){i(n,e);var t=f(n);function n(e){var a,s=e.userId,i=e.limit,o=e.token;return r(this,n),(a=t.call(this)).method=B.GET,a.path="".concat(qr,"/").concat(encodeURIComponent(s),"/friends"),a.params={limit:i,token:o},a}return s(n)}(ne),dc=function(e){i(n,e);var t=f(n);function n(e,a){var s;return r(this,n),(s=t.call(this,e,a)).hasMore=a.has_more,s.users=a.users.map((function(t){return new La(e,t)})),s.next=a.next,s}return s(n)}(re),fc=function(e){i(a,e);var n=f(a);function a(){return r(this,a),n.apply(this,arguments)}return s(a,[{key:"_validate",value:function(){return p(o(a.prototype),"_validate",this).call(this)}},{key:"next",value:function(){return b(this,void 0,void 0,t().mark((function e(){var n,r,a,s,i,o,u,c,l;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!this._validate()){e.next=20;break}if(this._isLoading){e.next=17;break}if(!this._hasNext){e.next=14;break}return this._isLoading=!0,n=ns.of(this._iid),r=n.sdkState,a=n.requestQueue,s=new hc(Object.assign(Object.assign({},this),{userId:r.userId,token:this._token})),e.next=8,a.send(s);case 8:return i=e.sent,o=i.as(dc),u=o.users,c=o.hasMore,l=o.next,this._token=l,this._hasNext=c,this._isLoading=!1,e.abrupt("return",u);case 14:return e.abrupt("return",[]);case 17:throw M.queryInProgress;case 18:e.next=21;break;case 20:throw M.invalidParameters;case 21:case"end":return e.stop()}}),e,this)})))}}]),a}(ki),pc={},vc=function(){function e(t){var n=t.dbname,a=t.itemSizeLimit,s=void 0===a?1048576:a,i=t.cacheLimit,o=void 0===i?256:i,u=t.blockHashBase,c=void 0===u?2:u,l=t.blockHashMultiplier,h=void 0===l?10:l,d=t.blockHashConstant,f=void 0===d?11:d,p=t.transactionApplyDelay,v=void 0===p?200:p,_=t.disableLogger,m=void 0!==_&&_;return r(this,e),pc[n]||(this.itemSizeLimit=s,this.cacheLimit=o,this.blockHashBase=c,this.blockHashMultiplier=h,this.blockHashConstant=f,this.transactionApplyDelay=v,this.disableLogger=m,pc[n]=this),pc[n]}return s(e,null,[{key:"get",value:function(e){return pc[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"}(tu||(tu={}));var _c,mc=function(e){i(n,e);var t=f(n);function n(e){var a,s=e.code,i=void 0===s?tu.UNKNOWN_ERROR:s,o=e.message,u=void 0===o?"Unknown error occurred.":o;return r(this,n),(a=t.call(this,u)).code=i,Object.setPrototypeOf(d(a),n.prototype),a}return s(n,null,[{key:"storeNotDefined",get:function(){return new n({code:tu.STORE_NOT_DEFINED,message:"Store is not defined. Specify the store on NestDB()"})}},{key:"storeNotAvailable",get:function(){return new n({code:tu.STORE_NOT_AVAILABLE,message:"Store is not available. Check your environment settings."})}},{key:"storeNotAvailableInPrivateBrowsing",get:function(){return new n({code:tu.STORE_NOT_AVAILABLE_IN_PRIVATE_BROWSING,message:"Store is not available because it is in private browsing."})}},{key:"storeIsFull",get:function(){return new n({code:tu.STORE_IS_FULL,message:"Store is full."})}},{key:"storeKeyTypeIsInvalid",get:function(){return new n({code:tu.STORE_INVALID_KEY_TYPE,message:"Store key should be string type."})}},{key:"storeBrokenIntegrity",get:function(){return new n({code:tu.STORE_BROKEN_INTEGRITY,message:"Data should be in a store but it does not. Integrity is broken."})}},{key:"storeBrokenBlob",get:function(){return new n({code:tu.STORE_BROKEN_BLOB,message:"Data should be in a store but it does not. Blob data is broken."})}},{key:"storeEncryptionInvalid",get:function(){return new n({code:tu.STORE_ENCRYPTION_INVALID,message:"Encryption algorithm has changed. All the store should reset."})}},{key:"storeItemSizeExceeded",get:function(){return new n({code:tu.STORE_ITEM_SIZE_LIMIT_EXCEEDED,message:"The size of the item exceeds the limit that the store allows."})}},{key:"storeReadFailed",get:function(){return new n({code:tu.STORE_READ_FAILED,message:"Failed to read from store."})}},{key:"storeWriteFailed",get:function(){return new n({code:tu.STORE_WRITE_FAILED,message:"Failed to write to store."})}},{key:"databaseSchemaNotOnUpgrade",get:function(){return new n({code:tu.DATABASE_SCHEMA_NOT_ON_UPGRADE,message:"Committing schema is not allowed when upgrade is not running."})}},{key:"collectionNotReady",get:function(){return new n({code:tu.COLLECTION_NOT_READY,message:"Collection is not ready due to an error during initialization."})}},{key:"collectionKeyNotMatch",get:function(){return new n({code:tu.COLLECTION_KEY_NOT_MATCH,message:"keyName of collection could not change."})}},{key:"collectionQueryNotValid",get:function(){return new n({code:tu.COLLECTION_QUERY_NOT_VALID,message:"Query parameter is not a valid format."})}},{key:"collectionInsertDuplicate",get:function(){return new n({code:tu.COLLECTION_INSERT_DUPLICATE,message:"The key already exists."})}},{key:"collectionKeyNotFound",get:function(){return new n({code:tu.COLLECTION_KEY_NOT_FOUND,message:"The key is not found."})}},{key:"collectionKeyNotGiven",get:function(){return new n({code:tu.COLLECTION_KEY_NOT_GIVEN,message:"The item should contain [keyName] property."})}},{key:"collectionWriteFailed",get:function(){return new n({code:tu.COLLECTION_WRITE_FAILED,message:"Failed to write an item."})}},{key:"collectionItemSizeExceeded",get:function(){return new n({code:tu.COLLECTION_ITEM_SIZE_LIMIT_EXCEEDED,message:"The size of the item exceeds the limit that a collection allows."})}},{key:"indexTableIsRequired",get:function(){return new n({code:tu.INDEX_TABLE_IS_REQUIRED,message:"Index table is required."})}},{key:"indexTypesNotMatch",get:function(){return new n({code:tu.INDEX_TYPE_NOT_MATCH,message:"Indexed column should have primitive type."})}},{key:"compareTypesNotMatch",get:function(){return new n({code:tu.COMPARE_TYPE_NOT_MATCH,message:"Values to compare have different types."})}},{key:"circularReferenceFound",get:function(){return new n({code:tu.CIRCULAR_REFERENCE_FOUND,message:"Cannot handle circular referenced object."})}}]),n}(h(Error));!function(e){e.INIT="init",e.READY="ready",e.CLOSED="closed"}(_c||(_c={}));var gc,yc=function e(t){var r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:new WeakMap;if("object"===n(t)&&null!==t){if(r.has(t))throw mc.circularReferenceFound;r.set(t,!0);var a=null;if(Array.isArray(t))a=t.map((function(t){return e(t,r)}));else if(t instanceof RegExp)a=t;else if(t instanceof Date)a=t;else for(var s in a={},t)a[s]=e(t[s],r);return r.delete(t),a}return t},kc=function(e,t){if(null==t)return 1;if(null==e)return-1;if(n(e)!==n(t))throw mc.compareTypesNotMatch;var r=0;switch(n(e)){case"boolean":case"number":r=e-t;break;case"string":r=e.localeCompare(t)}return r},bc=function(e,t){for(var n=0,r=0;r>>0)%t},Ec=function(e){return new Promise((function(t){setTimeout((function(){return t()}),e)}))},wc=function e(t,r){if(!r)return!1;if("function"!=typeof t){for(var a in t){if(["/and","&&"].includes(a)){if(t[a].some((function(t){return!e(t,r)})))return!1}else if(["/or","||"].includes(a)){if(t[a].every((function(t){return!e(t,r)})))return!1}else if("/where"===a){if(!(0,t[a])(r))return!1}else{var s=a;if("object"===n(t[s])){var i=t[s];for(var o in i)switch(o){case"/eq":case"=":if(r[s]!==i[o])return!1;break;case"/neq":case"!=":if(r[s]===i[o])return!1;break;case"/gt":case">":var u=r[s],c=i[o];if(!(kc(u,c)>0))return!1;break;case"/gte":case">=":var l=r[s],h=i[o];if(!(kc(l,h)>=0))return!1;break;case"/lt":case"<":var d=r[s],f=i[o];if(!(kc(d,f)<0))return!1;break;case"/lte":case"<=":var p=r[s],v=i[o];if(!(kc(p,v)<=0))return!1;break;case"/in":var _=r[s];if(!i[o].includes(_))return!1;break;case"/nin":var m=r[s];if(i[o].includes(m))return!1;break;case"/contain":var g=r[s],y=i[o];if(!g.includes(y))return!1;break;case"/regex":var k=r[s];if(!i[o].test(k))return!1;break;case"/where":var b=r[s];if(!(0,i[o])(b))return!1}}else if("function"==typeof t[s]){if(!t[s](r[s]))return!1}else if(t[s]!==r[s])return!1}}return!0}return t(r)},Cc=function(){},xc=function(){return Promise.resolve()},Tc=function(e){return e},Sc=function(e,t){t(null)};!function(e){e[e.FORWARD=0]="FORWARD",e[e.BACKWARD=1]="BACKWARD"}(gc||(gc={}));var Ic,Nc,Ac,Mc=function(){function e(t){var n=t.initialPrevValue,a=void 0===n?null:n,s=t.initialNextValue,i=void 0===s?null:s,o=t.iterator,u=t.map,c=void 0===u?Tc:u,l=t.backward,h=void 0===l?xc:l,d=t.forward,f=void 0===d?xc:d,p=t.complete,v=void 0===p?Cc:p;r(this,e),this._prevValue=a,this._nextValue=i,this._error=null,this._map=c,this._backward=h,this._forward=f,this._iterator=o,this._complete=v}return s(e,[{key:"prevValue",get:function(){return this._map(this._prevValue)}},{key:"nextValue",get:function(){return this._map(this._nextValue)}},{key:"error",get:function(){return this._error}},{key:"hasPrevious",get:function(){return!!this._prevValue}},{key:"hasNext",get:function(){return!!this._nextValue}},{key:"prev",value:function(){return b(this,void 0,void 0,t().mark((function e(){var n;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!this.hasPrevious){e.next=20;break}return e.prev=1,n=this._prevValue,e.next=5,this._backward();case 5:if(e.t0=e.sent,e.t0){e.next=8;break}e.t0=null;case 8:this._prevValue=e.t0,this._nextValue=n,e.next=15;break;case 12:e.prev=12,e.t1=e.catch(1),this._error=e.t1;case 15:return e.next=17,this._iterator(this);case 17:return e.abrupt("return",e.sent);case 20:this._complete();case 21:case"end":return e.stop()}}),e,this,[[1,12]])})))}},{key:"next",value:function(){return b(this,void 0,void 0,t().mark((function e(){var n;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!this.hasNext){e.next=20;break}return e.prev=1,n=this._nextValue,e.next=5,this._forward();case 5:if(e.t0=e.sent,e.t0){e.next=8;break}e.t0=null;case 8:this._nextValue=e.t0,this._prevValue=n,e.next=15;break;case 12:e.prev=12,e.t1=e.catch(1),this._error=e.t1;case 15:return e.next=17,this._iterator(this);case 17:return e.abrupt("return",e.sent);case 20:this._complete();case 21:case"end":return e.stop()}}),e,this,[[1,12]])})))}},{key:"stop",value:function(){this._prevValue=null,this._nextValue=null,this._complete()}}]),e}(),Oc=function(){function e(t){var n=t.condition,a=void 0===n?{}:n,s=t.backward,i=void 0!==s&&s,o=t.blockManager,u=t.indexer;r(this,e),this.condition=a,this.backward=i,this._blockManager=o,this._indexer=u}return s(e,[{key:"findOptimizedStartPosition",value:function(){var e=this,t=["=","/eq",">",">=","/gt","/gte"],r=["=","/eq","<","<=","/lt","/lte"];if(this.backward){var a=this._indexer.origin.length-1;if("function"!=typeof this.condition)for(var s in this._indexer.fields){var i=this._indexer.fields[s],o=1;if("-"===i[0]&&(i=i.slice(1),o=-1),this.condition[i])if("object"===n(this.condition[i])){var u=o>0?r:t;for(var c in this.condition[i])if(u.includes(c))for(var l=a;l>=0;l--)if(o*kc(this._indexer.origin[l].columnValues[s],this.condition[i][c])<=0){a=l;break}}else for(var h=a;h>=0;h--)if(o*kc(this._indexer.origin[h].columnValues[s],this.condition[i])<=0){a=h;break}}return Math.min(a+1,this._indexer.origin.length-1)}var d=0;if("function"!=typeof this.condition)for(var f=function(a){var s=e._indexer.fields[a],i=1;if("-"===s[0]&&(s=s.slice(1),i=-1),e.condition[s])if("object"===n(e.condition[s]))Object.keys(e.condition[s]).forEach((function(n){if((i>0?t:r).includes(n))for(var o=d;o=0){d=o;break}}));else for(var o=d;o=0){d=o;break}},p=0;p0&&void 0!==arguments[0]?arguments[0]:{};return b(this,void 0,void 0,t().mark((function n(){var r,a,s,i=this;return t().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:if(r=Math.max(e.offset||0,0),0!==(a="number"==typeof e.limit?e.limit:Number.MAX_SAFE_INTEGER)){n.next=6;break}return n.abrupt("return",[]);case 6:if(!(a<0)){n.next=8;break}throw mc.collectionQueryNotValid;case 8:return n.prev=8,s=[],n.next=12,this._mutex.lock();case 12:return n.next=14,this._iterator.each((function(e){return b(i,void 0,void 0,t().mark((function n(){return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:e.error?e.stop():e.hasNext?0===r?(s.push(e.nextValue),03&&void 0!==arguments[3]?arguments[3]:0;return"".concat(Fc(e,t)).concat(n,".").concat(r)},Hc=function(){function e(t){var n=t.dbname,a=t.collectionName,s=t.store;r(this,e),this.dbname=n,this.collectionName=a,this.store=s}return s(e,[{key:"get",value:function(e){return b(this,void 0,void 0,t().mark((function n(){var r,a,s,i,o,u,c,l,h,d;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,this.store.get(e);case 2:if(!(r=t.sent)){t.next=19;break}if(a=r.data,s=r.type,"undefined"==typeof fetch){t.next=14;break}return t.next=8,fetch(a);case 8:return i=t.sent,t.next=11,i.blob();case 11:return t.abrupt("return",t.sent);case 14:for(512,o=[],u=atob(a.split(",")[1]),c=0;c1&&void 0!==arguments[1]?arguments[1]:"".concat(Date.now());return b(this,void 0,void 0,t().mark((function r(){var a,s,i,o,u=this;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,new Promise((function(t){var r=Gc(u.dbname,u.collectionName,n),a=new FileReader;a.onload=function(){t({blobId:r,data:a.result,type:e.type})},a.readAsDataURL(e)}));case 2:return a=t.sent,s=a.blobId,i=a.data,o=a.type,t.next=8,this.store.set({key:s,value:{data:i,type:o},generation:1});case 8:return t.abrupt("return",s);case 9:case"end":return t.stop()}}),r,this)})))}},{key:"remove",value:function(e){return b(this,void 0,void 0,t().mark((function n(){return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,this.store.remove(e);case 2:case"end":return t.stop()}}),n,this)})))}},{key:"clear",value:function(){return b(this,void 0,void 0,t().mark((function e(){var n,r,a=this;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n=Fc(this.dbname,this.collectionName),e.next=3,this.store.getAllKeys();case 3:return r=e.sent,e.next=6,Promise.all(r.filter((function(e){return e.startsWith(n)})).map((function(e){return b(a,void 0,void 0,t().mark((function n(){return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,this.store.remove(e);case 2:return t.abrupt("return",t.sent);case 3:case"end":return t.stop()}}),n,this)})))})));case 6:case"end":return e.stop()}}),e,this)})))}}]),e}();!function(e){e[e.COMMIT=0]="COMMIT",e[e.WRITE=1]="WRITE",e[e.ERROR=2]="ERROR"}(Ic||(Ic={})),function(e){e.PENDING="pending",e.PERSISTENT="persistent",e.VOLATILE="volatile"}(Nc||(Nc={})),function(e){e[e.NO_CACHE=0]="NO_CACHE",e[e.DEFAULT=1]="DEFAULT",e[e.PERSISTENT=2]="PERSISTENT"}(Ac||(Ac={}));var qc,jc=[Nc.PENDING,Nc.VOLATILE],zc={},Vc=function(){function e(t){var n=t.dbname,a=t.limit,s=void 0===a?256:a;return r(this,e),zc[n]||(this.dbname=n,this._items=[],this._limit=s,zc[n]=this),zc[n]}return s(e,[{key:"items",get:function(){return this._items}},{key:"find",value:function(e,n){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:Ac.DEFAULT;return b(this,void 0,void 0,t().mark((function a(){var s,i;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(s=this.get(n)){t.next=8;break}return t.next=4,e.get(n);case 4:(i=t.sent)&&(s={key:n,value:i,generation:1,state:r===Ac.PERSISTENT?Nc.PERSISTENT:Nc.VOLATILE},this.put(s)),t.next=9;break;case 8:r===Ac.PERSISTENT&&(s.state=Nc.PERSISTENT);case 9:return t.abrupt("return",s);case 10:case"end":return t.stop()}}),a,this)})))}},{key:"get",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:Ac.DEFAULT,n=this._items.map((function(e){return e.key})).indexOf(e);if(n>-1){var r=this._items[n];return t===Ac.PERSISTENT&&(r.state=Nc.PERSISTENT),t!==Ac.NO_CACHE&&this.put(r),r}return null}},{key:"put",value:function(e){if(this._limit>0){var t=this._items.map((function(e){return e.key})).indexOf(e.key);if(t>-1)jc.includes(this._items[t].state)&&jc.includes(e.state)?(this._items.splice(t,1),this._items.push(e)):(this._items[t].state=e.state,this._items[t].generation=e.generation,this._items[t].value=e.value);else{this._items.push(e);var n=this._items.filter((function(e){return e.state===Nc.VOLATILE})),r=n.length-this._limit;if(r>0){var a,s=[],i=y(this._items);try{for(i.s();!(a=i.n()).done;){var o=a.value;o.state===Nc.VOLATILE&&r>0?r--:s.push(o)}}catch(e){i.e(e)}finally{i.f()}this._items=s}}}}},{key:"remove",value:function(e){var t=this._items.map((function(e){return e.key})).indexOf(e);t>-1&&this._items.splice(t,1)}},{key:"clearByCondition",value:function(e){this._items=this._items.filter((function(t){return!e(t)}))}},{key:"clear",value:function(){var e=arguments.length>0&&void 0!==arguments[0]&&arguments[0];this._items=e?[]:this._items.filter((function(e){return e.state!==Nc.VOLATILE}))}}],[{key:"get",value:function(e){return zc[e]}}]),e}(),Bc=function(){function e(t){var n=t.dbname,a=t.collectionName,s=t.store;r(this,e),this._metadata=null,this._requests=[],this._onCommit=new Map,this._onWrite=new Map,this._onError=new Map,this.dbname=n,this.collectionName=a,this.metadataKey=function(e,t){return"".concat(Lc(e,t),"/trans.metadata")}(n,a),this.recordsetKey=function(e,t){return"".concat(Lc(e,t),"/trans.recordset")}(n,a),this._store=s}return s(e,[{key:"generation",get:function(){return this._metadata?this._metadata.generation:0}},{key:"requestCount",get:function(){return this._requests.length}},{key:"_getReducedRecordset",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[];return b(this,void 0,void 0,t().mark((function n(){var r;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,this._store.get(this.recordsetKey);case 2:if(t.t0=t.sent,t.t0){t.next=5;break}t.t0=[];case 5:return(r=t.t0).push.apply(r,_(e)),t.abrupt("return",this._reduceRecordSet(r));case 8:case"end":return t.stop()}}),n,this)})))}},{key:"_reduceRecordSet",value:function(e){for(var t=[],n={},r=e.length-1;r>=0;r--){for(var a=e[r],s=[],i=a.requests.length-1;i>=0;i--){var o=a.requests[i],u=o.data;n[u.key]||(s.unshift(o),n[u.key]=!0)}s.length>0&&(a.requests=s,t.unshift(a))}return t}},{key:"_applyRecord",value:function(e,n){return b(this,void 0,void 0,t().mark((function r(){var a,s,i,o,u,c,l,h;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return a=Vc.get(this.dbname),s=n.generation,i=n.requests,o=null,t.prev=3,t.next=6,this._store.setMany(i.map((function(e){return Object.assign(Object.assign({},e.data),{generation:s})})));case 6:for(u=t.sent,c=0;c1&&void 0!==arguments[1]?arguments[1]:null;this._requests.push({data:e,options:t}),Vc.get(this.dbname).put(Object.assign({state:Nc.PENDING,generation:this.generation},e))}},{key:"requestMultipleWrite",value:function(e){var t,n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null,r=Vc.get(this.dbname),a=y(e);try{for(a.s();!(t=a.n()).done;){var s=t.value;this._requests.push({data:s,options:n}),r.put(Object.assign({state:Nc.PENDING,generation:this.generation},s))}}catch(e){a.e(e)}finally{a.f()}}},{key:"clear",value:function(){return b(this,void 0,void 0,t().mark((function e(){return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:Vc.get(this.dbname).clearByCondition((function(e){return e.state===Nc.PENDING})),this._requests=[];case 3:case"end":return e.stop()}}),e,this)})))}},{key:"commit",value:function(){return b(this,void 0,void 0,t().mark((function e(){var n,r,a,s,i,o,u,c,l,h,d,f,p,v,_=this;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!((n=this._requests).length>0)){e.next=20;break}for(r=[],a={},s=n.length-1;s>=0;s--)i=n[s],o=i.data,a[o.key]||(a[o.key]=!0,r.unshift(i));return u={generation:this.generation,requests:r},e.next=8,this._getReducedRecordset([u]);case 8:return c=e.sent,e.next=11,this._store.set({key:this.recordsetKey,value:c,generation:this.generation});case 11:return this._metadata.generation++,e.next=14,this._store.set({key:this.metadataKey,value:this._metadata,generation:1});case 14:for(l=Vc.get(this.dbname),h=0;h1&&void 0!==arguments[1]?arguments[1]:this.metadata.blockLevel;return t=this.dbname,n=this.collectionName,r=s,a="".concat(function(e,t,n){var r=n.base*Math.pow(n.multiplier,t)+n.constant;return(n.hashFunction||bc)(e,r)}(e,s,{hashFunction:this.hashFunction,base:this.metadata.blockHashBase,multiplier:this.metadata.blockHashMultiplier,constant:this.metadata.blockHashConstant})),"".concat(Pc(t,n)).concat(r,".").concat(a)}},{key:"_findBlock",value:function(e){return b(this,void 0,void 0,t().mark((function n(){var r,a,s,i,o;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:r=Vc.get(this.dbname),a=this.metadata.blockLevel;case 2:if(!(a>0)){t.next=15;break}return s=this.createBlockId(e,a),t.next=6,r.find(this._store,s);case 6:if(!(i=t.sent)){t.next=12;break}if(o=Qc.createFromCacheItem(i),!o.getItemByKey(e)){t.next=12;break}return t.abrupt("return",o);case 12:a--,t.next=2;break;case 15:return t.abrupt("return",null);case 16:case"end":return t.stop()}}),n,this)})))}},{key:"getFromBlock",value:function(e){return b(this,void 0,void 0,t().mark((function n(){var r;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,this._findBlock(e);case 2:return r=t.sent,t.abrupt("return",r?r.getItemByKey(e):null);case 4:case"end":return t.stop()}}),n,this)})))}},{key:"putToBlock",value:function(e,n){return b(this,void 0,void 0,t().mark((function r(){var a,s,i,o,u,c;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return a=vc.get(this.dbname),s=this.createBlockId(e),i=Math.floor(this._store.itemSizeLimit/a.itemSizeLimit),o=Vc.get(this.dbname),t.next=6,o.find(this._store,s);case 6:if(u=t.sent,!(c=u?Qc.createFromCacheItem(u):new Qc({blockId:s,keyName:this.keyName,items:[],limit:i})).add(n)){t.next=11;break}return this._transaction.requestWrite({key:c.blockId,value:c.serialize()}),t.abrupt("return",!0);case 11:return t.abrupt("return",!1);case 12:case"end":return t.stop()}}),r,this)})))}},{key:"removeFromBlock",value:function(e){return b(this,void 0,void 0,t().mark((function n(){var r;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,this._findBlock(e);case 2:if(!(r=t.sent)){t.next=7;break}if(!r.remove(e)){t.next=7;break}return this._transaction.requestWrite({key:r.blockId,value:r.serialize()}),t.abrupt("return",!0);case 7:return t.abrupt("return",!1);case 8:case"end":return t.stop()}}),n,this)})))}},{key:"clearAllBlocks",value:function(){return b(this,void 0,void 0,t().mark((function e(){var n,r,a;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n=Pc(this.dbname,this.collectionName),e.next=3,this._store.getAllKeys();case 3:return r=e.sent,a=r.filter((function(e){return e.startsWith(n)})),e.next=7,this._store.removeMany(a);case 7:return e.next=9,this._transaction.clear();case 9:Vc.get(this.dbname).clearByCondition((function(e){return e.key.startsWith(n)}));case 11:case"end":return e.stop()}}),e,this)})))}}]),e}(),Wc={},Yc=function(){function e(t){var n=this,a=t.dbname,s=t.collectionName,i=t.keyName,o=t.fields,u=t.transaction,c=t.store;r(this,e),this._origin=[],this._table=[];var l=function(e,t,n){return"".concat(Lc(e,t),"/index.").concat(n)}(a,s,o.join(">"));return Wc[l]||(this.dbname=a,this.collectionName=s,this.keyName=i,this.fields=o,this.indexerKey=l,this._transaction=u,this._store=c,this._transaction.on(Ic.COMMIT,this.indexerKey,(function(){return n.commit()})),this._transaction.on(Ic.ERROR,this.indexerKey,(function(){return n.abort()}))),Wc[l]}return s(e,[{key:"_addItem",value:function(e){var t=e[this.keyName],n=this.getColumnValues(e),r=v(this.indexOf(n),2),a=r[0];return r[1]?!this._table[a].keys.includes(t)&&(this._table[a].keys.push(t),!0):(this._table.splice(a,0,{columnValues:n,keys:[t]}),!0)}},{key:"_removeItem",value:function(e){var t=e[this.keyName],n=this.getColumnValues(e),r=v(this.indexOf(n),2),a=r[0];if(r[1]){var s=this._table[a].keys.indexOf(t);if(s>-1)return this._table[a].keys.splice(s,1),0===this._table[a].keys.length&&this._table.splice(a,1),!0}return!1}},{key:"origin",get:function(){return this._origin}},{key:"table",get:function(){return this._table}},{key:"getColumnValues",value:function(e){var t,r,a,s=[],i=y(this.fields);try{for(i.s();!(t=i.n()).done;){var o=t.value;if("-"===o[0]&&(o=o.slice(1)),r=e[o],a=void 0,a=n(r),null!==r&&"undefined"!==a&&"boolean"!==a&&"number"!==a&&"string"!==a)throw mc.indexTypesNotMatch;s.push(e[o])}}catch(e){i.e(e)}finally{i.f()}return s}},{key:"diff",value:function(e,t){for(var n in this.fields){var r="-"===this.fields[n][0]?-1:1,a=kc(e[n],t[n]);if(0!==a)return r*a}return 0}},{key:"indexOf",value:function(e){if(this._table.length>0){for(var t=0,n=this._table.length-1;t<=n;){var r=Math.floor((t+n)/2),a=this.diff(e,this._table[r].columnValues);if(a>0)t=r+1;else{if(!(a<0))return[r,!0];n=r-1}}return[t,!1]}return[0,!1]}},{key:"ensure",value:function(){return b(this,void 0,void 0,t().mark((function e(){var n,r,a,s,i,o,u,c,l,h,d,f;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n=Vc.get(this.dbname),e.next=3,n.find(this._store,this.indexerKey,Ac.PERSISTENT);case 3:if(r=e.sent){e.next=34;break}return a=Pc(this.dbname,this.collectionName),e.next=8,this._store.getAllKeys();case 8:s=e.sent,i=y(s),e.prev=10,i.s();case 12:if((o=i.n()).done){e.next=23;break}if(!(u=o.value).startsWith(a)){e.next=21;break}return e.next=17,n.find(this._store,u,Ac.NO_CACHE);case 17:c=e.sent,l=Qc.createFromCacheItem(c),h=y(l.items);try{for(h.s();!(d=h.n()).done;)f=d.value,this._addItem(f)}catch(e){h.e(e)}finally{h.f()}case 21:e.next=12;break;case 23:e.next=28;break;case 25:e.prev=25,e.t0=e.catch(10),i.e(e.t0);case 28:return e.prev=28,i.f(),e.finish(28);case 31:this._transaction.requestWrite({key:this.indexerKey,value:this._table},{persistent:!0}),e.next=36;break;case 34:this._origin=r.value,this._table=yc(this._origin);case 36:Wc[this.indexerKey]=this;case 37:case"end":return e.stop()}}),e,this,[[10,25,28,31]])})))}},{key:"drop",value:function(){return b(this,void 0,void 0,t().mark((function e(){return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return Vc.get(this.dbname).remove(this.indexerKey),e.next=4,this._store.remove(this.indexerKey);case 4:delete Wc[this.indexerKey];case 5:case"end":return e.stop()}}),e,this)})))}},{key:"addItem",value:function(e){return b(this,void 0,void 0,t().mark((function n(){return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:this._addItem(e)&&this._transaction.requestWrite({key:this.indexerKey,value:this._table},{persistent:!0});case 1:case"end":return t.stop()}}),n,this)})))}},{key:"removeItem",value:function(e){return b(this,void 0,void 0,t().mark((function n(){return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:this._removeItem(e)&&this._transaction.requestWrite({key:this.indexerKey,value:this._table},{persistent:!0});case 1:case"end":return t.stop()}}),n,this)})))}},{key:"clear",value:function(){return b(this,void 0,void 0,t().mark((function e(){return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:this._table=[],this._transaction.requestWrite({key:this.indexerKey,value:this._table},{persistent:!0});case 2:case"end":return e.stop()}}),e,this)})))}},{key:"commit",value:function(){this._origin=this._table,this._table=yc(this._origin)}},{key:"abort",value:function(){this._table=yc(this._origin)}}],[{key:"createKey",value:function(e){return e.join(">")}},{key:"parseKey",value:function(e){return e.split(">")}},{key:"clearIndexerMap",value:function(){for(var e in Wc)delete Wc[e]}}]),e}(),Zc=function(){function e(t){var n=this,a=t.dbname,s=t.collectionName,i=t.keyName,o=t.keyHash,u=t.indexes,c=t.store;r(this,e),this._state=_c.INIT,this._metadata=null,this._indexers=[],this.dbname=a,this.name=s,this.keyName=i,this.indexes=[[i]].concat(_(u.filter((function(e){return Yc.createKey(e)!==n.keyName})))),this._keyHash=o,this._store=c,this._mutex=new Po(function(e,t){return"".concat(Lc(e,t),".lock")}(a,s)),this._blobContainer=new Hc({dbname:a,collectionName:s,store:c}),this._transaction=new Bc({dbname:a,collectionName:s,store:c})}return s(e,[{key:"state",get:function(){return this._state}},{key:"isReady",get:function(){return this._state===_c.READY}},{key:"init",value:function(){return b(this,void 0,void 0,t().mark((function n(){var r,a,s,i,o,u,c,l,h,d,f,p=this;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,this._mutex.lock();case 2:return t.prev=2,r=vc.get(this.dbname),t.next=6,e.metadataOf(this.dbname,this.name,this._store);case 6:return a=t.sent,this._metadata=a||{keyName:this.keyName,blockLevel:1,blockHashBase:r.blockHashBase,blockHashMultiplier:r.blockHashMultiplier,blockHashConstant:r.blockHashConstant,indexes:this.indexes},t.next=10,this._transaction.init();case 10:this._blockManager=new Kc({dbname:this.dbname,collectionName:this.name,hashFunction:this._keyHash,metadata:this._metadata,transaction:this._transaction,store:this._store}),s=_(this.indexes),i=[],o=s.map((function(e){return Yc.createKey(e)})),u=a?a.indexes.map((function(e){return Yc.createKey(e)})):[],c=y(u);try{for(c.s();!(l=c.n()).done;)h=l.value,o.includes(h)||i.push(Yc.parseKey(h))}catch(e){c.e(e)}finally{c.f()}return(d=[]).push.apply(d,_(s.map((function(e){var t=new Yc({dbname:p.dbname,collectionName:p.name,keyName:p.keyName,fields:e,transaction:p._transaction,store:p._store});return p._indexers.push(t),t.ensure()})))),d.push.apply(d,_(i.map((function(e){return new Yc({dbname:p.dbname,collectionName:p.name,keyName:p.keyName,fields:e,transaction:p._transaction,store:p._store}).drop()})))),t.next=22,Promise.all(d);case 22:return t.next=24,this._transaction.commit();case 24:if(o.sort().join(",")===u.sort().join(",")){t.next=29;break}return f=Dc(this.dbname,this.name),this._metadata.indexes=s,t.next=29,this._store.set({key:f,value:this._metadata,generation:1});case 29:this._state=_c.READY,this._mutex.unlock(),t.next=37;break;case 33:throw t.prev=33,t.t0=t.catch(2),this._mutex.unlock(),t.t0;case 37:case"end":return t.stop()}}),n,this,[[2,33]])})))}},{key:"close",value:function(){this._state=_c.CLOSED}},{key:"_hasPropertyOfKeyName",value:function(e){var t=e[this.keyName];return"string"==typeof t&&!!t}},{key:"_getIndexerBy",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:null;e||(e=[this.keyName]);var t,n=Yc.createKey(e),r=y(this._indexers);try{for(r.s();!(t=r.n()).done;){var a=t.value;if(n===Yc.createKey(a.fields))return a}}catch(e){r.e(e)}finally{r.f()}return null}},{key:"_upgradeBlockLevel",value:function(){return b(this,void 0,void 0,t().mark((function e(){var n;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n=Dc(this.dbname,this.name),this._metadata.blockLevel++,e.next=4,this._store.set({key:n,value:this._metadata,generation:1});case 4:case"end":return e.stop()}}),e,this)})))}},{key:"_requestInsert",value:function(e){return b(this,void 0,void 0,t().mark((function n(){var r,a,s,i;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return r=e[this.keyName],t.next=3,this._blockManager.getFromBlock(r);case 3:if(t.sent){t.next=32;break}return t.next=7,this._blockManager.putToBlock(r,e);case 7:if(t.sent){t.next=13;break}return t.next=11,this._upgradeBlockLevel();case 11:return t.next=13,this._blockManager.putToBlock(r,e);case 13:a=y(this._indexers),t.prev=14,a.s();case 16:if((s=a.n()).done){t.next=22;break}return i=s.value,t.next=20,i.addItem(e);case 20:t.next=16;break;case 22:t.next=27;break;case 24:t.prev=24,t.t0=t.catch(14),a.e(t.t0);case 27:return t.prev=27,a.f(),t.finish(27);case 30:t.next=33;break;case 32:throw mc.collectionInsertDuplicate;case 33:case"end":return t.stop()}}),n,this,[[14,24,27,30]])})))}},{key:"_requestUpsert",value:function(e){return b(this,void 0,void 0,t().mark((function n(){var r,a,s,i,o,u,c,l;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return r=e[this.keyName],t.next=3,this._blockManager.getFromBlock(r);case 3:if(a=t.sent){t.next=32;break}return t.next=7,this._blockManager.putToBlock(r,e);case 7:if(t.sent){t.next=13;break}return t.next=11,this._upgradeBlockLevel();case 11:return t.next=13,this._blockManager.putToBlock(r,e);case 13:s=y(this._indexers),t.prev=14,s.s();case 16:if((i=s.n()).done){t.next=22;break}return o=i.value,t.next=20,o.addItem(e);case 20:t.next=16;break;case 22:t.next=27;break;case 24:t.prev=24,t.t0=t.catch(14),s.e(t.t0);case 27:return t.prev=27,s.f(),t.finish(27);case 30:t.next=54;break;case 32:return t.next=34,this._blockManager.putToBlock(r,e);case 34:u=y(this._indexers),t.prev=35,u.s();case 37:if((c=u.n()).done){t.next=46;break}if(0===(l=c.value).diff(l.getColumnValues(a),l.getColumnValues(e))){t.next=44;break}return t.next=42,l.removeItem(a);case 42:return t.next=44,l.addItem(e);case 44:t.next=37;break;case 46:t.next=51;break;case 48:t.prev=48,t.t1=t.catch(35),u.e(t.t1);case 51:return t.prev=51,u.f(),t.finish(51);case 54:case"end":return t.stop()}}),n,this,[[14,24,27,30],[35,48,51,54]])})))}},{key:"_requestUpdate",value:function(e){return b(this,void 0,void 0,t().mark((function n(){var r,a,s,i,o;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return r=e[this.keyName],t.next=3,this._blockManager.getFromBlock(r);case 3:if(!(a=t.sent)){t.next=27;break}return t.next=7,this._blockManager.putToBlock(r,e);case 7:s=y(this._indexers),t.prev=8,s.s();case 10:if((i=s.n()).done){t.next=19;break}if(0===(o=i.value).diff(o.getColumnValues(a),o.getColumnValues(e))){t.next=17;break}return t.next=15,o.removeItem(a);case 15:return t.next=17,o.addItem(e);case 17:t.next=10;break;case 19:t.next=24;break;case 21:t.prev=21,t.t0=t.catch(8),s.e(t.t0);case 24:return t.prev=24,s.f(),t.finish(24);case 27:case"end":return t.stop()}}),n,this,[[8,21,24,27]])})))}},{key:"_requestRemove",value:function(e){return b(this,void 0,void 0,t().mark((function n(){var r,a,s,i;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,this._blockManager.getFromBlock(e);case 2:if(!(r=t.sent)){t.next=23;break}return t.next=6,this._blockManager.removeFromBlock(e);case 6:a=y(this._indexers),t.prev=7,a.s();case 9:if((s=a.n()).done){t.next=15;break}return i=s.value,t.next=13,i.removeItem(r);case 13:t.next=9;break;case 15:t.next=20;break;case 17:t.prev=17,t.t0=t.catch(7),a.e(t.t0);case 20:return t.prev=20,a.f(),t.finish(20);case 23:case"end":return t.stop()}}),n,this,[[7,17,20,23]])})))}},{key:"_requestClear",value:function(){return b(this,void 0,void 0,t().mark((function e(){var n,r,a;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this._blockManager.clearAllBlocks();case 2:n=y(this._indexers),e.prev=3,n.s();case 5:if((r=n.n()).done){e.next=11;break}return a=r.value,e.next=9,a.clear();case 9:e.next=5;break;case 11:e.next=16;break;case 13:e.prev=13,e.t0=e.catch(3),n.e(e.t0);case 16:return e.prev=16,n.f(),e.finish(16);case 19:case"end":return e.stop()}}),e,this,[[3,13,16,19]])})))}},{key:"getByKey",value:function(e){return b(this,void 0,void 0,t().mark((function n(){var r;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(!this.isReady){t.next=17;break}return t.next=3,this._mutex.lock();case 3:return t.prev=3,t.next=6,this._blockManager.getFromBlock(e);case 6:return r=t.sent,this._mutex.unlock(),t.abrupt("return",yc(r));case 11:throw t.prev=11,t.t0=t.catch(3),this._mutex.unlock(),t.t0;case 15:t.next=18;break;case 17:throw mc.collectionNotReady;case 18:case"end":return t.stop()}}),n,this,[[3,11]])})))}},{key:"query",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return this.isReady?new Uc({condition:e.where,mutex:this._mutex,blockManager:this._blockManager,indexer:this._getIndexerBy(e.index),backward:!!e.backward}):null}},{key:"insertOne",value:function(e){return b(this,void 0,void 0,t().mark((function n(){return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(!this.isReady){t.next=22;break}return t.next=3,this._mutex.lock();case 3:if(t.prev=3,this._hasPropertyOfKeyName(e)){t.next=6;break}throw mc.collectionKeyNotGiven;case 6:return t.next=8,this._requestInsert(yc(e));case 8:return t.next=10,this._transaction.commit();case 10:return this._mutex.unlock(),t.abrupt("return",e);case 14:return t.prev=14,t.t0=t.catch(3),t.next=18,this._transaction.clear();case 18:throw this._mutex.unlock(),t.t0;case 20:t.next=23;break;case 22:throw mc.collectionNotReady;case 23:case"end":return t.stop()}}),n,this,[[3,14]])})))}},{key:"insertMany",value:function(e){return b(this,void 0,void 0,t().mark((function n(){var r,a,s,i=this;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(!this.isReady){t.next=37;break}return t.next=3,this._mutex.lock();case 3:if(t.prev=3,!e.some((function(e){return!i._hasPropertyOfKeyName(e)}))){t.next=6;break}throw mc.collectionKeyNotGiven;case 6:r=y(e),t.prev=7,r.s();case 9:if((a=r.n()).done){t.next=15;break}return s=a.value,t.next=13,this._requestInsert(yc(s));case 13:t.next=9;break;case 15:t.next=20;break;case 17:t.prev=17,t.t0=t.catch(7),r.e(t.t0);case 20:return t.prev=20,r.f(),t.finish(20);case 23:return t.next=25,this._transaction.commit();case 25:return this._mutex.unlock(),t.abrupt("return",e);case 29:return t.prev=29,t.t1=t.catch(3),t.next=33,this._transaction.clear();case 33:throw this._mutex.unlock(),t.t1;case 35:t.next=38;break;case 37:throw mc.collectionNotReady;case 38:case"end":return t.stop()}}),n,this,[[3,29],[7,17,20,23]])})))}},{key:"upsertOne",value:function(e){return b(this,void 0,void 0,t().mark((function n(){return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(!this.isReady){t.next=22;break}return t.next=3,this._mutex.lock();case 3:if(t.prev=3,this._hasPropertyOfKeyName(e)){t.next=6;break}throw mc.collectionKeyNotGiven;case 6:return t.next=8,this._requestUpsert(yc(e));case 8:return t.next=10,this._transaction.commit();case 10:return this._mutex.unlock(),t.abrupt("return",e);case 14:return t.prev=14,t.t0=t.catch(3),t.next=18,this._transaction.clear();case 18:throw this._mutex.unlock(),t.t0;case 20:t.next=23;break;case 22:throw mc.collectionNotReady;case 23:case"end":return t.stop()}}),n,this,[[3,14]])})))}},{key:"upsertMany",value:function(e){return b(this,void 0,void 0,t().mark((function n(){var r,a,s,i=this;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(!this.isReady){t.next=37;break}return t.next=3,this._mutex.lock();case 3:if(t.prev=3,!e.some((function(e){return!i._hasPropertyOfKeyName(e)}))){t.next=6;break}throw mc.collectionKeyNotGiven;case 6:r=y(e),t.prev=7,r.s();case 9:if((a=r.n()).done){t.next=15;break}return s=a.value,t.next=13,this._requestUpsert(yc(s));case 13:t.next=9;break;case 15:t.next=20;break;case 17:t.prev=17,t.t0=t.catch(7),r.e(t.t0);case 20:return t.prev=20,r.f(),t.finish(20);case 23:return t.next=25,this._transaction.commit();case 25:return this._mutex.unlock(),t.abrupt("return",e);case 29:return t.prev=29,t.t1=t.catch(3),t.next=33,this._transaction.clear();case 33:throw this._mutex.unlock(),t.t1;case 35:t.next=38;break;case 37:throw mc.collectionNotReady;case 38:case"end":return t.stop()}}),n,this,[[3,29],[7,17,20,23]])})))}},{key:"update",value:function(e){return b(this,void 0,void 0,t().mark((function n(){return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(!this.isReady){t.next=22;break}return t.next=3,this._mutex.lock();case 3:if(t.prev=3,this._hasPropertyOfKeyName(e)){t.next=6;break}throw mc.collectionKeyNotGiven;case 6:return t.next=8,this._requestUpdate(yc(e));case 8:return t.next=10,this._transaction.commit();case 10:return this._mutex.unlock(),t.abrupt("return",e);case 14:return t.prev=14,t.t0=t.catch(3),t.next=18,this._transaction.clear();case 18:throw this._mutex.unlock(),t.t0;case 20:t.next=23;break;case 22:throw mc.collectionNotReady;case 23:case"end":return t.stop()}}),n,this,[[3,14]])})))}},{key:"updateIf",value:function(e,n){return b(this,void 0,void 0,t().mark((function r(){var a,s,i,o,u,c,l,h,d,f,p,v=this;return t().wrap((function(r){for(;;)switch(r.prev=r.next){case 0:if(!this.isReady){r.next=31;break}return r.next=3,this._mutex.lock();case 3:return r.prev=3,a=e.where,s=void 0===a?{}:a,i=e.index,o=void 0===i?null:i,u=e.backward,c=void 0!==u&&u,l=[],h=new Oc({condition:s,blockManager:this._blockManager,backward:c,indexer:this._getIndexerBy(o)}),r.next=9,h.each((function(e){return b(v,void 0,void 0,t().mark((function r(){var a,i;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(e.error){t.next=4;break}if(e.hasNext){if(a=e.nextValue,wc(s,a)&&n.set){if("function"!=typeof n.set)for(i in n.set)a[i]=n.set[i];else n.set(a);l.push(a)}e.next()}else e.stop();t.next=6;break;case 4:throw e.stop(),e.error;case 6:case"end":return t.stop()}}),r)})))}));case 9:d=0,f=l;case 10:if(!(d1&&void 0!==arguments[1]?arguments[1]:null;return b(this,void 0,void 0,t().mark((function r(){return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,this._blobContainer.save(e,n);case 2:return t.abrupt("return",t.sent);case 3:case"end":return t.stop()}}),r,this)})))}},{key:"removeBlob",value:function(e){return b(this,void 0,void 0,t().mark((function n(){return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,this._blobContainer.remove(e);case 2:case"end":return t.stop()}}),n,this)})))}},{key:"removeAllBlobs",value:function(){return b(this,void 0,void 0,t().mark((function e(){return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this._blobContainer.clear();case 2:case"end":return e.stop()}}),e,this)})))}}],[{key:"metadataOf",value:function(e,n,r){return b(this,void 0,void 0,t().mark((function a(){var s;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return s=Dc(e,n),t.next=3,r.get(s);case 3:return t.abrupt("return",t.sent);case 4:case"end":return t.stop()}}),a)})))}}]),e}(),Jc=function(){function e(t){var n,a,s;r(this,e),this.encryption=null!==(n=t.encryption)&&void 0!==n?n:j,this.itemSizeLimit=null!==(a=t.itemSizeLimit)&&void 0!==a?a:4194304,this.metadataBuffer=null!==(s=t.metadataBuffer)&&void 0!==s?s:256}return s(e,[{key:"_getRawKey",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"";return"".concat(e).concat(t)}},{key:"_generateShardPostfixArray",value:function(){return _(Array(arguments.length>0&&void 0!==arguments[0]?arguments[0]:1).keys())}},{key:"_shardify",value:function(e){var t=this,n=e.key,r=e.value,a=JSON.stringify(this.encryption.encrypt(r)),s=Math.ceil(a.length/this.adjustedItemSizeLimit);return this._generateShardPostfixArray(s).map((function(e){var r={key:t._getRawKey(n,".".concat(e)),data:a.substring(e*t.adjustedItemSizeLimit,(e+1)*t.adjustedItemSizeLimit)};return 0===e&&(r.metadata={shards:s}),r}))}},{key:"adjustedItemSizeLimit",get:function(){return Math.max(this.itemSizeLimit-this.metadataBuffer,4)}},{key:"usage",value:function(){return b(this,void 0,void 0,t().mark((function e(){var n,r,a,s,i,o;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n=0,e.next=3,this._getAllRawKeys();case 3:r=e.sent,a=y(r),e.prev=5,a.s();case 7:if((s=a.n()).done){e.next=15;break}return i=s.value,e.next=11,this._getRaw(i);case 11:(o=e.sent)&&(n+=JSON.stringify(o).length);case 13:e.next=7;break;case 15:e.next=20;break;case 17:e.prev=17,e.t0=e.catch(5),a.e(e.t0);case 20:return e.prev=20,a.f(),e.finish(20);case 23:return e.abrupt("return",n);case 24:case"end":return e.stop()}}),e,this,[[5,17,20,23]])})))}},{key:"getAllKeys",value:function(){return b(this,void 0,void 0,t().mark((function e(){var n;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this._getAllRawKeys();case 2:return n=e.sent,e.abrupt("return",n.filter((function(e){return e.endsWith(".0")})).map((function(e){return e.replace(/\.0$/,"")})));case 4:case"end":return e.stop()}}),e,this)})))}},{key:"get",value:function(e){return b(this,void 0,void 0,t().mark((function n(){var r,a,s,i,o,u=this;return t().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return r=this._getRawKey(e,".0"),n.next=3,this._getRaw(r);case 3:if(!(a=n.sent)){n.next=21;break}if(n.prev=5,s=a.data,!((null==(i=a.metadata)?void 0:i.shards)>1)){n.next=13;break}return n.next=10,Promise.all(this._generateShardPostfixArray(null==i?void 0:i.shards).map((function(n){return b(u,void 0,void 0,t().mark((function r(){var a,i;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(!(n>0)){t.next=10;break}return a=this._getRawKey(e,".".concat(n)),t.next=4,this._getRaw(a);case 4:if(i=t.sent){t.next=7;break}throw mc.storeBrokenIntegrity;case 7:return t.abrupt("return",i.data);case 10:return t.abrupt("return",s);case 11:case"end":return t.stop()}}),r,this)})))})));case 10:n.t0=n.sent,n.next=14;break;case 13:n.t0=[s];case 14:return o=n.t0,n.abrupt("return",this.encryption.decrypt(JSON.parse(o.join(""))));case 18:return n.prev=18,n.t1=n.catch(5),n.abrupt("return",null);case 21:return n.abrupt("return",null);case 22:case"end":return n.stop()}}),n,this,[[5,18]])})))}},{key:"set",value:function(e){return b(this,void 0,void 0,t().mark((function n(){var r;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return r=this._shardify(e),t.next=3,this._setRaw(r);case 3:return t.abrupt("return",Object.assign({},e.value));case 4:case"end":return t.stop()}}),n,this)})))}},{key:"setMany",value:function(e){return b(this,void 0,void 0,t().mark((function n(){var r,a=this;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,this._setRaw((r=[]).concat.apply(r,_(e.map((function(e){return a._shardify(e)})))));case 2:return t.abrupt("return",e.map((function(e){return e.value})));case 3:case"end":return t.stop()}}),n,this)})))}},{key:"remove",value:function(e){return b(this,void 0,void 0,t().mark((function n(){var r,a,s,i=this;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return r=this._getRawKey(e,".0"),t.next=3,this._getRaw(r);case 3:if(!(a=t.sent)){t.next=9;break}return s=a.metadata,t.next=8,this._removeRaw(this._generateShardPostfixArray(null==s?void 0:s.shards).map((function(t){return i._getRawKey(e,".".concat(t))})));case 8:return t.abrupt("return",!0);case 9:return t.abrupt("return",!1);case 10:case"end":return t.stop()}}),n,this)})))}},{key:"removeMany",value:function(e){return b(this,void 0,void 0,t().mark((function n(){var r,a,s,i,o=this;return t().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:r=[],a=y(e),n.prev=2,i=t().mark((function e(){var n,a,i,u;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n=s.value,a=o._getRawKey(n,".0"),e.next=4,o._getRaw(a);case 4:(i=e.sent)&&(u=i.metadata,r.push.apply(r,_(o._generateShardPostfixArray(null==u?void 0:u.shards).map((function(e){return o._getRawKey(n,".".concat(e))})))));case 6:case"end":return e.stop()}}),e)})),a.s();case 5:if((s=a.n()).done){n.next=9;break}return n.delegateYield(i(),"t0",7);case 7:n.next=5;break;case 9:n.next=14;break;case 11:n.prev=11,n.t1=n.catch(2),a.e(n.t1);case 14:return n.prev=14,a.f(),n.finish(14);case 17:if(!(r.length>0)){n.next=20;break}return n.next=20,this._removeRaw(r);case 20:return n.abrupt("return",e);case 21:case"end":return n.stop()}}),n,this,[[2,11,14,17]])})))}}]),e}(),Xc={},$c=function(e){i(a,e);var n=f(a);function a(){var e,t,s=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};r(this,a),e=n.call(this,Object.assign(Object.assign({},s),{itemSizeLimit:null!==(t=s.itemSizeLimit)&&void 0!==t?t:4194304}));var i=s.delay,o=void 0===i?1:i;return e.delay=o,e.observer={},e}return s(a,[{key:"rawData",get:function(){return Xc[this.dbname]},set:function(e){Xc[this.dbname]=e}},{key:"_getAllRawKeys",value:function(){return b(this,void 0,void 0,t().mark((function e(){return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!Xc[this.dbname]){e.next=4;break}return e.abrupt("return",Object.keys(Xc[this.dbname]));case 4:throw mc.storeNotAvailable;case 5:case"end":return e.stop()}}),e,this)})))}},{key:"_getRaw",value:function(e){return b(this,void 0,void 0,t().mark((function n(){return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(!Xc[this.dbname]){t.next=6;break}return t.next=3,Ec(this.delay);case 3:return t.abrupt("return",Xc[this.dbname][e]?Object.assign({key:e},Xc[this.dbname][e]):null);case 6:throw mc.storeNotAvailable;case 7:case"end":return t.stop()}}),n,this)})))}},{key:"_setRaw",value:function(e){return b(this,void 0,void 0,t().mark((function n(){var r,a,s,i,o,u;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(!Xc[this.dbname]){t.next=7;break}return t.next=3,Ec(this.delay);case 3:r=y(e);try{for(r.s();!(a=r.n()).done;)s=a.value,i=s.key,o=s.data,u=s.metadata,Xc[this.dbname][i]=Object.freeze({data:o,metadata:u})}catch(e){r.e(e)}finally{r.f()}t.next=8;break;case 7:throw mc.storeNotAvailable;case 8:case"end":return t.stop()}}),n,this)})))}},{key:"_removeRaw",value:function(e){return b(this,void 0,void 0,t().mark((function n(){var r,a,s;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(!Xc[this.dbname]){t.next=7;break}return t.next=3,Ec(this.delay);case 3:r=y(e);try{for(r.s();!(a=r.n()).done;)s=a.value,Xc[this.dbname][s]&&delete Xc[this.dbname][s]}catch(e){r.e(e)}finally{r.f()}t.next=8;break;case 7:throw mc.storeNotAvailable;case 8:case"end":return t.stop()}}),n,this)})))}},{key:"observe",value:function(e,t,n){var r=this;this.observer[e]||(this.observer[e]={}),t.forEach((function(t){return r.observer[e][t]=n}))}},{key:"isAvailable",value:function(){return b(this,void 0,void 0,t().mark((function e(){return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",!0);case 1:case"end":return e.stop()}}),e)})))}},{key:"init",value:function(e){return b(this,void 0,void 0,t().mark((function n(){return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:this.dbname=e,Xc[this.dbname]={};case 2:case"end":return t.stop()}}),n,this)})))}},{key:"set",value:function(e){var n=this,r=Object.create(null,{set:{get:function(){return p(o(a.prototype),"set",n)}}});return b(this,void 0,void 0,t().mark((function n(){var a;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(!this.observer[e.key]||"function"!=typeof this.observer[e.key].set){t.next=4;break}if(!(a=this.observer[e.key].set())){t.next=4;break}throw a;case 4:return t.abrupt("return",r.set.call(this,e));case 5:case"end":return t.stop()}}),n,this)})))}},{key:"setMany",value:function(e){var n=this,r=Object.create(null,{setMany:{get:function(){return p(o(a.prototype),"setMany",n)}}});return b(this,void 0,void 0,t().mark((function n(){var a,s,i,o;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:a=y(e),t.prev=1,a.s();case 3:if((s=a.n()).done){t.next=11;break}if(i=s.value,!this.observer[i.key]||"function"!=typeof this.observer[i.key].set){t.next=9;break}if(!(o=this.observer[i.key].set())){t.next=9;break}throw o;case 9:t.next=3;break;case 11:t.next=16;break;case 13:t.prev=13,t.t0=t.catch(1),a.e(t.t0);case 16:return t.prev=16,a.f(),t.finish(16);case 19:return t.abrupt("return",r.setMany.call(this,e));case 20:case"end":return t.stop()}}),n,this,[[1,13,16,19]])})))}},{key:"clear",value:function(){return b(this,void 0,void 0,t().mark((function e(){return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,Ec(this.delay);case 2:Xc[this.dbname]={};case 3:case"end":return e.stop()}}),e,this)})))}}]),a}(Jc),el="NestDBStore",tl=function(e){i(a,e);var n=f(a);function a(){var e,t,s=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return r(this,a),(e=n.call(this,Object.assign(Object.assign({},s),{itemSizeLimit:null!==(t=s.itemSizeLimit)&&void 0!==t?t:104857600})))._storeName=el,e._window="undefined"!=typeof window?window:null,e._indexedDb=e._window?e._window.indexedDB||e._window.mozIndexedDB||e._window.webkitIndexedDB||e._window.msIndexedDB:null,e}return s(a,[{key:"_getObjectStore",value:function(e){return this._database.transaction(this._storeName,e).objectStore(this._storeName)}},{key:"_getAllRawKeys",value:function(){return b(this,void 0,void 0,t().mark((function e(){var n=this;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,new Promise((function(e,t){var r=n._getObjectStore("readonly").getAllKeys();r.addEventListener("success",(function(t){e(t.target.result)})),r.addEventListener("error",(function(e){return t(e.target.error)}))}));case 2:return e.abrupt("return",e.sent);case 3:case"end":return e.stop()}}),e)})))}},{key:"_getRaw",value:function(e){return b(this,void 0,void 0,t().mark((function n(){var r=this;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,new Promise((function(t,n){var a=r._getObjectStore("readonly").get(e);a.addEventListener("success",(function(e){var n;t(null===(n=null==e?void 0:e.target)||void 0===n?void 0:n.result)})),a.addEventListener("error",(function(e){return n(e.target.error)}))}));case 2:return t.abrupt("return",t.sent);case 3:case"end":return t.stop()}}),n)})))}},{key:"_setRaw",value:function(e){return b(this,void 0,void 0,t().mark((function n(){var r;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return r=this._getObjectStore("readwrite"),t.next=3,Promise.all(e.map((function(e){return new Promise((function(t,n){var a=r.put(e);a.addEventListener("success",(function(e){t(e.target.result)})),a.addEventListener("error",(function(){n("Failed to write.")}))}))})));case 3:case"end":return t.stop()}}),n,this)})))}},{key:"_removeRaw",value:function(e){return b(this,void 0,void 0,t().mark((function n(){var r;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return r=this._getObjectStore("readwrite"),t.next=3,Promise.all(e.map((function(e){return new Promise((function(t,n){var a=r.delete(e);a.addEventListener("success",(function(){return t(e)})),a.addEventListener("error",(function(e){return n(e.target.error)}))}))})));case 3:case"end":return t.stop()}}),n,this)})))}},{key:"isAvailable",value:function(){return b(this,void 0,void 0,t().mark((function e(){var n,r,a,s,i=this;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!((null==(n="undefined"!=typeof window?window:null)?void 0:n.indexedDB)||(null==n?void 0:n.mozIndexedDB)||(null==n?void 0:n.webkitIndexedDB)||(null==n?void 0:n.msIndexedDB))){e.next=15;break}return e.prev=2,this._indexedDb=n.indexedDB||n.mozIndexedDB||n.webkitIndexedDB||n.msIndexedDB,r="undefined"!=typeof document&&"undefined"!=typeof navigator,a=navigator.userAgent&&navigator.userAgent.includes("Firefox/")&&!navigator.userAgent.includes("Seamonkey/"),s=navigator.userAgent&&navigator.userAgent.includes("Edge/"),e.next=9,new Promise((function(e,t){if(r)if(a){var o=i._indexedDb.open("_testMozilla");o.onerror=function(){return t("Private browsing mode.")},o.onsuccess=function(){return e()}}else s?(n.PointerEvent||n.MSPointerEvent)&&t("Private browsing mode."):e()}));case 9:return e.abrupt("return",!0);case 12:return e.prev=12,e.t0=e.catch(2),e.abrupt("return",!1);case 15:return e.abrupt("return",!1);case 16:case"end":return e.stop()}}),e,this,[[2,12]])})))}},{key:"init",value:function(e){return b(this,void 0,void 0,t().mark((function n(){var r,a=this;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return this.dbname=e,r=new Promise((function(e,t){if(a._window&&No)if(Ao){var n=a._indexedDb.open("_testMozilla");n.onerror=function(){return t(mc.storeNotAvailableInPrivateBrowsing)},n.onsuccess=function(){return e()}}else Uo?a._window.indexedDB||!a._window.PointerEvent&&!a._window.MSPointerEvent||t(mc.storeNotAvailableInPrivateBrowsing):e();else t(mc.storeNotAvailable)})),t.next=4,r;case 4:return t.next=6,new Promise((function(t,n){var r=a._indexedDb.open(e);r.addEventListener("upgradeneeded",(function(e){e.target.result.createObjectStore(el,{keyPath:"key"})})),r.addEventListener("success",(function(e){return t(e.target.result)})),r.addEventListener("error",(function(e){return n(e.target.error)}))}));case 6:this._database=t.sent;case 7:case"end":return t.stop()}}),n,this)})))}},{key:"clear",value:function(){return b(this,void 0,void 0,t().mark((function e(){var n=this;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,new Promise((function(e,t){var r=n._getObjectStore("readwrite").clear();r.addEventListener("success",(function(){return e()})),r.addEventListener("error",(function(e){return t(e.target.error)}))}));case 2:return e.abrupt("return",e.sent);case 3:case"end":return e.stop()}}),e)})))}}]),a}(Jc),nl=function(e){i(a,e);var n=f(a);function a(e){var t;r(this,a);var s=e.AsyncStorage,i=e.itemSizeLimit,o=void 0===i?6291456:i,u=function(e,t){var n={};for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&t.indexOf(r)<0&&(n[r]=e[r]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var a=0;for(r=Object.getOwnPropertySymbols(e);a0&&(s.mutedUsers=o.map((function(t){return new hl(e,t)}))),s}return s(n)}(re),Cl=function(e){i(a,e);var n=f(a);function a(e,t,s,i){return r(this,a),n.call(this,e,t,s,i)}return s(a,[{key:"next",value:function(){return b(this,void 0,void 0,t().mark((function e(){var n,r,a,s,i,o,u;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!this._validate()){e.next=20;break}if(this._isLoading){e.next=17;break}if(!this._hasNext){e.next=14;break}return this._isLoading=!0,n=ns.of(this._iid),r=n.requestQueue,a=new El(Object.assign(Object.assign({},this),{token:this._token})),e.next=8,r.send(a);case 8:return s=e.sent,i=s.as(wl),o=i.mutedUsers,u=i.token,this._token=u,this._hasNext=!!u,this._isLoading=!1,e.abrupt("return",o);case 14:return e.abrupt("return",[]);case 17:throw M.queryInProgress;case 18:e.next=21;break;case 20:throw M.invalidParameters;case 21:case"end":return e.stop()}}),e,this)})))}}]),a}(Si),xl=function(e){i(n,e);var t=f(n);function n(e){var a;r(this,n);var s=e.channelUrl,i=e.channelType,o=e.limit,u=e.token;return(a=t.call(this)).method=B.GET,a.path="".concat(Fs(i),"/").concat(encodeURIComponent(s),"/ban"),a.params=ee({limit:o,token:u}),a}return s(n)}(ne),Tl=function(e){i(n,e);var t=f(n);function n(e,a){var s;r(this,n),(s=t.call(this,e,a)).token=null,s.bannedUsers=[];var i=a.next,o=a.banned_list;return s.token=i,o&&o.length>0&&(s.bannedUsers=o.map((function(t){return new hl(e,t.user)}))),s}return s(n)}(re),Sl=function(e){i(a,e);var n=f(a);function a(e,t,s,i){return r(this,a),n.call(this,e,t,s,i)}return s(a,[{key:"_validate",value:function(){return p(o(a.prototype),"_validate",this).call(this)}},{key:"next",value:function(){return b(this,void 0,void 0,t().mark((function e(){var n,r,a,s,i,o,u;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!this._validate()){e.next=20;break}if(this._isLoading){e.next=17;break}if(!this._hasNext){e.next=14;break}return this._isLoading=!0,n=ns.of(this._iid),r=n.requestQueue,a=new xl(Object.assign(Object.assign({},this),{token:this._token})),e.next=8,r.send(a);case 8:return s=e.sent,i=s.as(Tl),o=i.bannedUsers,u=i.token,this._token=u,this._hasNext=!!u,this._isLoading=!1,e.abrupt("return",o);case 14:return e.abrupt("return",[]);case 17:throw M.queryInProgress;case 18:e.next=21;break;case 20:throw M.invalidParameters;case 21:case"end":return e.stop()}}),e,this)})))}}]),a}(Si);e.ReportCategory=void 0,(cl=e.ReportCategory||(e.ReportCategory={})).SPAM="spam",cl.HARASSING="harassing",cl.SUSPICIOUS="suspicious",cl.INAPPROPRIATE="inappropriate";var Il,Nl=function(e){i(n,e);var t=f(n);function n(e){var a;r(this,n);var s=e.channelUrl,i=e.channelType,o=e.operatorUserIds;return(a=t.call(this)).method=B.POST,a.path="".concat(Fs(i),"/").concat(encodeURIComponent(s),"/operators"),a.params={operator_ids:o},a}return s(n)}(ne),Al=function(e){i(n,e);var t=f(n);function n(e){var a;r(this,n);var s=e.channelUrl,i=e.channelType,o=e.operatorUserIds;return(a=t.call(this)).method=B.DELETE,a.path="".concat(Fs(i),"/").concat(encodeURIComponent(s),"/operators"),a.params={operator_ids:o},a}return s(n)}(ne),Ml=function(e){i(n,e);var t=f(n);function n(e){var a;r(this,n);var s=e.channelUrl,i=e.channelType,o=e.userId;return(a=t.call(this)).method=B.GET,a.path="".concat(Fs(i),"/").concat(encodeURIComponent(s),"/mute/").concat(o),a}return s(n)}(ne),Ol=function(e){i(n,e);var t=f(n);function n(e,a){var s;r(this,n),(s=t.call(this,e,a)).isMuted=!1,s.startAt=null,s.endAt=null,s.remainingDuration=null,s.description=null;var i=a.is_muted,o=a.start_at,u=a.end_at,c=a.remaining_duration,l=a.description;return s.isMuted=i,s.startAt=o,s.endAt=u,s.remainingDuration=c,s.description=l,s}return s(n)}(re),Ul=function(e){i(n,e);var t=f(n);function n(e){var a;r(this,n);var s=e.channelUrl,i=e.channelType,o=e.keys;return(a=t.call(this)).method=B.GET,a.path="".concat(Fs(i),"/").concat(encodeURIComponent(s),"/metadata"),a.params={keys:o,include_ts:!0},a}return s(n)}(ne),Rl=function(e){i(n,e);var t=f(n);function n(e,a){var s;r(this,n),(s=t.call(this,e,a)).ts=null;var i=a.metadata,o=a.ts;return s.metadata=i,s.ts=null!=o?o:null,s}return s(n)}(re),Ll=function(e){i(n,e);var t=f(n);function n(e){var a;r(this,n);var s=e.channelUrl,i=e.channelType,o=e.metadata;return(a=t.call(this)).method=B.POST,a.path="".concat(Fs(i),"/").concat(encodeURIComponent(s),"/metadata"),a.params={metadata:o,include_ts:!0},a}return s(n)}(ne),Dl=function(e){i(n,e);var t=f(n);function n(e,a){var s,i,o;return r(this,n),(s=t.call(this,e,a)).metaData=null!==(i=a.metadata)&&void 0!==i?i:{},s.ts=null!==(o=a.ts)&&void 0!==o?o:null,s}return s(n)}(re),Pl=function(e){i(n,e);var t=f(n);function n(e){var a;r(this,n);var s=e.channelUrl,i=e.channelType,o=e.metadata,u=e.upsert;return(a=t.call(this)).method=B.PUT,a.path="".concat(Fs(i),"/").concat(encodeURIComponent(s),"/metadata"),a.params={metadata:o,include_ts:!0,upsert:null!=u&&u},a}return s(n)}(ne),Fl=function(e){i(n,e);var t=f(n);function n(e,a){var s;r(this,n),(s=t.call(this,e,a)).ts=null;var i=a.metadata,o=a.ts;return s.metadata=i,s.ts=null!=o?o:null,s}return s(n)}(re),Gl=function(e){i(n,e);var t=f(n);function n(e,a,s){var i;return r(this,n),(i=t.call(this,e,"SYEV",s)).created=null,i.updated=null,i.deleted=null,s.data&&(i.created=s.data.created,i.updated=s.data.updated,i.deleted=s.data.deleted),i}return s(n)}(le),Hl=function(e){i(n,e);var t=f(n);function n(e){var a;r(this,n);var s=e.channelUrl,i=e.channelType,o=e.key;return(a=t.call(this)).method=B.DELETE,a.path="".concat(Fs(i),"/").concat(encodeURIComponent(s),"/metadata/").concat(o),a.params={include_ts:!0},a}return s(n)}(ne),ql=function(e){i(n,e);var t=f(n);function n(e,a){var s;r(this,n),(s=t.call(this,e,a)).ts=null;var i=a.ts;return s.ts=null!=i?i:null,s}return s(n)}(re),jl=function(e){i(n,e);var t=f(n);function n(e){var a;r(this,n);var s=e.channelUrl,i=e.channelType;return(a=t.call(this)).method=B.DELETE,a.path="".concat(Fs(i),"/").concat(encodeURIComponent(s),"/metadata"),a.params={include_ts:!0},a}return s(n)}(ne),zl=function(e){i(n,e);var t=f(n);function n(e,a){var s;r(this,n),(s=t.call(this,e,a)).ts=null;var i=a.ts;return s.ts=null!=i?i:null,s}return s(n)}(re),Vl=function(e){i(n,e);var t=f(n);function n(e){var a;r(this,n);var s=e.channelUrl,i=e.channelType,o=e.keys;return(a=t.call(this)).method=B.GET,a.path="".concat(Fs(i),"/").concat(encodeURIComponent(s),"/metacounter"),a.params={keys:o},a}return s(n)}(ne),Bl=function(e){i(n,e);var t=f(n);function n(e,a){var s;return r(this,n),(s=t.call(this,e,a)).metaCounter=a,s}return s(n)}(re),Ql=function(e){i(n,e);var t=f(n);function n(e){var a;r(this,n);var s=e.channelUrl,i=e.channelType,o=e.metaCounter;return(a=t.call(this)).method=B.POST,a.path="".concat(Fs(i),"/").concat(encodeURIComponent(s),"/metacounter"),a.params={metacounter:o},a}return s(n)}(ne),Kl=function(e){i(n,e);var t=f(n);function n(e,a){var s;return r(this,n),(s=t.call(this,e,a)).metaCounter=a,s}return s(n)}(re),Wl=function(e){i(n,e);var t=f(n);function n(e){var a;r(this,n);var s=e.channelUrl,i=e.channelType,o=e.metaCounter,u=e.upsert,c=void 0!==u&&u,l=e.mode,h=void 0===l?"set":l;return(a=t.call(this)).method=B.PUT,a.path="".concat(Fs(i),"/").concat(encodeURIComponent(s),"/metacounter"),a.params={metacounter:o,upsert:c,mode:h},a}return s(n)}(ne),Yl=function(e){i(n,e);var t=f(n);function n(e,a){var s;return r(this,n),(s=t.call(this,e,a)).metaCounter=a,s}return s(n)}(re),Zl=function(e){i(n,e);var t=f(n);function n(e,a,s){var i;return r(this,n),(i=t.call(this,e,"SYEV",s)).created=null,i.updated=null,i.deleted=null,s.data&&(i.created=s.data.created,i.updated=s.data.updated,i.deleted=s.data.deleted),i}return s(n)}(le),Jl=function(e){i(n,e);var t=f(n);function n(e){var a;r(this,n);var s=e.channelUrl,i=e.channelType,o=e.key;return(a=t.call(this)).method=B.DELETE,a.path="".concat(Fs(i),"/").concat(encodeURIComponent(s),"/metacounter/").concat(o),a.params=null,a}return s(n)}(ne),Xl=function(e){i(n,e);var t=f(n);function n(e){var a;r(this,n);var s=e.channelUrl,i=e.channelType;return(a=t.call(this)).method=B.DELETE,a.path="".concat(Fs(i),"/").concat(encodeURIComponent(s),"/metacounter"),a.params=null,a}return s(n)}(ne),$l=function(e){i(n,e);var t=f(n);function n(e){var a;r(this,n);var s=e.channelUrl,i=e.channelType,o=e.userId,u=e.seconds,c=e.description;return(a=t.call(this)).method=B.POST,a.path="".concat(Fs(i),"/").concat(encodeURIComponent(s),"/mute"),a.params={user_id:o,seconds:u,description:c},a}return s(n)}(ne),eh=function(e){i(n,e);var t=f(n);function n(e,a,s){var i;return r(this,n),(i=t.call(this,e,"SYEV",s)).user=new hl(e,s.data),i}return s(n)}(le),th=function(e){i(n,e);var t=f(n);function n(e){var a;r(this,n);var s=e.channelUrl,i=e.channelType,o=e.userId;return(a=t.call(this)).method=B.DELETE,a.path="".concat(Fs(i),"/").concat(encodeURIComponent(s),"/mute/").concat(encodeURIComponent(o)),a}return s(n)}(ne),nh=function(e){i(n,e);var t=f(n);function n(e,a,s){var i;return r(this,n),(i=t.call(this,e,"SYEV",s)).user=new hl(e,s.data),i}return s(n)}(le),rh=function(e){i(n,e);var t=f(n);function n(e){var a;r(this,n);var s=e.channelUrl,i=e.channelType,o=e.userId,u=e.seconds,c=e.description;return(a=t.call(this)).method=B.POST,a.path="".concat(Fs(i),"/").concat(encodeURIComponent(s),"/ban"),a.params=ee({user_id:o,seconds:u,description:c}),a}return s(n)}(ne),ah=function(e){i(n,e);var t=f(n);function n(e,a,s){var i;return r(this,n),(i=t.call(this,e,"SYEV",s)).memberCount=null,i.joinedMemberCount=null,i.user=new hl(e,s.data),s.data.member_count&&(i.memberCount=s.data.member_count),s.data.joined_member_count&&(i.joinedMemberCount=s.data.joined_member_count),i}return s(n)}(le),sh=function(e){i(n,e);var t=f(n);function n(e){var a;r(this,n);var s=e.channelUrl,i=e.channelType,o=e.userId;return(a=t.call(this)).method=B.DELETE,a.path="".concat(Fs(i),"/").concat(encodeURIComponent(s),"/ban/").concat(encodeURIComponent(o)),a}return s(n)}(ne),ih=function(e){i(n,e);var t=f(n);function n(e,a,s){var i;return r(this,n),(i=t.call(this,e,"SYEV",s)).user=new hl(e,s.data),i}return s(n)}(le),oh=function(e){i(n,e);var t=f(n);function n(e){var a;r(this,n);var s=e.channelUrl,i=e.channelType,o=e.freezing;return(a=t.call(this)).method=B.PUT,a.path="".concat(Fs(i),"/").concat(encodeURIComponent(s),"/freeze"),a.params={freeze:o},a}return s(n)}(ne),uh=function(e){i(n,e);var t=f(n);function n(e,a,s){var i;return r(this,n),(i=t.call(this,e,"SYEV",s)).freeze=s.data.freeze,i}return s(n)}(le),ch=function(e){i(n,e);var t=f(n);function n(e){var a;r(this,n);var s=e.channelUrl,i=e.channelType,o=e.category,u=e.userId,c=e.description;return(a=t.call(this)).method=B.POST,a.path="".concat(Gs(i),"/").concat(encodeURIComponent(s)),a.params={report_category:o,reporting_user_id:u,report_description:c},a}return s(n)}(ne),lh=function(t){i(a,t);var n=f(a);function a(t){var s;r(this,a);var i=t.channelUrl,o=t.channelType,u=t.category,c=t.userId,l=t.offendingUserId,h=t.description;return(s=n.call(this)).method=B.POST,s.path="".concat(Wr,"/users/").concat(l),s.params={channel_url:i,channel_type:o===e.ChannelType.OPEN?"open_channels":"group_channels",report_category:u,reporting_user_id:c,report_description:h},s}return s(a)}(ne),hh=function(e){i(n,e);var t=f(n);function n(e){var a;r(this,n);var s=e.channelUrl,i=e.channelType,o=e.category,u=e.userId,c=e.offendingUserId,l=e.messageId,h=e.description;return(a=t.call(this)).method=B.POST,a.path="".concat(Gs(i),"/").concat(encodeURIComponent(s),"/messages/").concat(l),a.params={report_category:o,reporting_user_id:u,report_description:h,offending_user_id:c},a}return s(n)}(ne),dh=function(t){i(a,t);var n=f(a);function a(t){r(this,a);var s=[];return t.mentionType===e.MentionType.USERS&&(t.mentionedUserIds?s=t.mentionedUserIds:t.mentionedUsers&&(s=t.mentionedUsers.map((function(e){return e.userId})))),n.call(this,{code:"MESG",ackRequired:!0,payload:ee({channel_url:t.channelUrl,message:t.message,data:t.data,custom_type:t.customType,metaarray:t.metaArrays,mention_type:t.mentionType,mentioned_user_ids:s,mentioned_message_template:t.mentionedMessageTemplate,target_langs:t.translationTargetLanguages,push_option:t.pushNotificationDeliveryOption&&t.pushNotificationDeliveryOption!==e.PushNotificationDeliveryOption.DEFAULT?t.pushNotificationDeliveryOption:void 0,apple_critical_alert_options:t.appleCriticalAlertOptions,silent:t.silent,reply_to_channel:t.isReplyToChannel,parent_message_id:t.parentMessageId>0?t.parentMessageId:null,req_id:t.reqId,poll_id:t.pollId,pin_message:t.isPinnedMessage})})}return s(a)}(Mr),fh=function(e){i(n,e);var t=f(n);function n(e,a,s){var i,o,u,c;r(this,n),(i=t.call(this,e,"MESG",s)).message=new Rs(e,s);var l=ns.of(e).sdkState;return i.isMentioned=Hs(i.message.mentionType,null!==(o=i.message.mentionedUserIds)&&void 0!==o?o:null===(u=i.message.mentionedUsers)||void 0===u?void 0:u.map((function(e){return e.userId})),l.userId),i.forceUpdateLastMessage=null!==(c=s.force_update_last_message)&&void 0!==c&&c,i}return s(n)}(le),ph=function(t){i(a,t);var n=f(a);function a(t){var s;r(this,a);var i=null;return t.mentionType===e.MentionType.USERS&&(t.mentionedUserIds?i=t.mentionedUserIds:t.mentionedUsers&&(i=t.mentionedUsers.map((function(e){return e.userId})))),n.call(this,{code:"MEDI",ackRequired:!0,payload:ee({channel_url:t.channelUrl,msg_id:t.messageId,message:t.message,data:t.data,custom_type:t.customType,metaarray:t.metaArrayParams,mention_type:t.mentionType,mentioned_user_ids:i,mentioned_message_template:t.mentionedMessageTemplate,apple_critical_alert_options:null===(s=t.appleCriticalAlertOptions)||void 0===s?void 0:s.serialize(),poll_id:t.pollId})})}return s(a)}(Mr),vh=function(e){i(n,e);var t=f(n);function n(e,a,s){var i,o,u,c,l,h,d;r(this,n),(i=t.call(this,e,"MEDI",s)).message=new Rs(e,s);var f=ns.of(e).sdkState;return i.mentionCountChange=qs({mentionType:null!==(u=null===(o=s.old_values)||void 0===o?void 0:o.mention_type)&&void 0!==u?u:null,mentionedUserIds:null!==(l=null===(c=s.old_values)||void 0===c?void 0:c.mentioned_user_ids)&&void 0!==l?l:[]},{mentionType:i.message.mentionType,mentionedUserIds:null!==(h=i.message.mentionedUserIds)&&void 0!==h?h:null===(d=i.message.mentionedUsers)||void 0===d?void 0:d.map((function(e){return e.userId}))},f.userId),i}return s(n)}(le),_h=function(t){i(a,t);var n=f(a);function a(t){r(this,a);var s=null;return t.mentionType===e.MentionType.USERS&&(t.mentionedUserIds?s=t.mentionedUserIds:t.mentionedUsers&&(s=t.mentionedUsers.map((function(e){return e.userId})))),n.call(this,{code:"FEDI",ackRequired:!0,payload:ee({channel_url:t.channelUrl,msg_id:t.messageId,data:t.data,custom_type:t.customType,metaarray:t.metaArrayParams,mention_type:t.mentionType,mentioned_user_ids:s,apple_critical_alert_options:t.appleCriticalAlertOptions})})}return s(a)}(Mr),mh=function(e){i(n,e);var t=f(n);function n(e,a,s){var i,o,u,c,l,h,d;r(this,n),(i=t.call(this,e,"FEDI",s)).message=new Ps(e,s);var f=ns.of(e).sdkState;return i.mentionCountChange=qs({mentionType:null!==(u=null===(o=s.old_values)||void 0===o?void 0:o.mention_type)&&void 0!==u?u:null,mentionedUserIds:null!==(l=null===(c=s.old_values)||void 0===c?void 0:c.mentioned_user_ids)&&void 0!==l?l:[]},{mentionType:i.message.mentionType,mentionedUserIds:null!==(h=i.message.mentionedUserIds)&&void 0!==h?h:null===(d=i.message.mentionedUsers)||void 0===d?void 0:d.map((function(e){return e.userId}))},f.userId),i}return s(n)}(le),gh=function(e){i(n,e);var t=f(n);function n(e){var a;return r(this,n),(a=t.call(this)).method=B.DELETE,a.path="".concat(Fs(e.channelType),"/").concat(e.channelUrl,"/messages/").concat(e.messageId),a}return s(n)}(ne),yh=function(e){i(n,e);var t=f(n);function n(e,a,s){var i;return r(this,n),(i=t.call(this,e,"DELM",s)).channelUrl=s.channel_url,i.channelType=s.channel_type,i.messageId=Number(s.msg_id),i}return s(n)}(le),kh=function(e){i(n,e);var t=f(n);function n(e){var a,s=e.channelType,i=e.channelUrl,o=e.messageId,u=e.reactionKey;return r(this,n),(a=t.call(this)).method=B.POST,a.path="".concat(Fs(s),"/").concat(encodeURIComponent(i),"/messages/").concat(o,"/reactions"),a.params={reaction:u},a}return s(n)}(ne),bh=function(e){i(n,e);var t=f(n);function n(e,a){var s;return r(this,n),(s=t.call(this,e,a)).reactionEvent=new ds(a),s}return s(n)}(re),Eh=function(e){i(n,e);var t=f(n);function n(e){var a,s=e.channelType,i=e.channelUrl,o=e.messageId,u=e.reactionKey;return r(this,n),(a=t.call(this)).method=B.DELETE,a.path="".concat(Fs(s),"/").concat(encodeURIComponent(i),"/messages/").concat(o,"/reactions"),a.params={reaction:u},a}return s(n)}(ne),wh=function(e){i(n,e);var t=f(n);function n(e,a){var s;return r(this,n),(s=t.call(this,e,a)).reactionEvent=new ds(Object.assign({},a)),s}return s(n)}(re),Ch=function(e){i(n,e);var t=f(n);function n(e){var a,s=e.channelType,i=e.channelUrl,o=e.messageId,u=e.translationTargetLanguages;return r(this,n),(a=t.call(this)).method=B.POST,a.path="".concat(Fs(s),"/").concat(encodeURIComponent(i),"/messages/").concat(encodeURIComponent(o),"/translation"),a.params={target_langs:u},a}return s(n)}(ne),xh=function(e){i(n,e);var t=f(n);function n(e,a){var s;return r(this,n),(s=t.call(this,e,a)).message=new Rs(e,a),s}return s(n)}(re),Th=function(t){i(a,t);var n=f(a);function a(t){var s,i;r(this,a),s=n.call(this);var o=[];t.mentionType===e.MentionType.USERS&&(t.mentionedUserIds?o=t.mentionedUserIds:t.mentionedUsers&&(o=t.mentionedUsers.map((function(e){return e.userId}))));var u=t.channelType,c=t.channelUrl;return s.method=B.POST,s.path="".concat(Fs(u),"/").concat(encodeURIComponent(c),"/scheduled_messages"),s.params={req_id:t.reqId,scheduled_at:t.scheduledAt,message_type:Ya.USER,message:t.message,custom_type:t.customType,data:t.data,mention_type:t.mentionType,mentioned_user_ids:o,sorted_metaarray:null===(i=t.metaArrays)||void 0===i?void 0:i.map((function(e){return ps.payloadify(e)})),apple_critical_alert_options:ms.payloadify(t.appleCriticalAlertOptions),target_langs:t.translationTargetLanguages,push_option:t.pushNotificationDeliveryOption},s}return s(a)}(ne),Sh=function(e){i(n,e);var t=f(n);function n(e,a){var s;return r(this,n),(s=t.call(this,e,a)).message=new Rs(e,a),s}return s(n)}(re),Ih=function(t){i(a,t);var n=f(a);function a(t){var s,i;r(this,a),s=n.call(this);var o=[];t.mentionType===e.MentionType.USERS&&(t.mentionedUserIds?o=t.mentionedUserIds:t.mentionedUsers&&(o=t.mentionedUsers.map((function(e){return e.userId}))));var u=t.channelType,c=t.channelUrl;return s.method=B.POST,s.path="".concat(Fs(u),"/").concat(encodeURIComponent(c),"/scheduled_messages"),s.params={req_id:t.reqId,scheduled_at:t.scheduledAt,message_type:Ya.FILE,url:t.fileUrl,file_name:t.fileName,file_size:t.fileSize,file_type:t.mimeType,thumbnails:t.thumbnailSizes?t.thumbnailSizes.map((function(e){return ws.payloadify(e)})):[],custom_type:t.customType,data:t.data,require_auth:t.requireAuth,mention_type:t.mentionType,mentioned_user_ids:o,sorted_metaarray:null===(i=t.metaArrays)||void 0===i?void 0:i.map((function(e){return ps.payloadify(e)})),apple_critical_alert_options:ms.payloadify(t.appleCriticalAlertOptions),push_option:t.pushNotificationDeliveryOption},s}return s(a)}(ne),Nh=function(e){i(n,e);var t=f(n);function n(e,a){var s;return r(this,n),(s=t.call(this,e,a)).message=new Ps(e,a),s}return s(n)}(re),Ah=function(e){return L("string",e.title,!0)&&Ms(e.data)&&L("boolean",e.allowUserSuggestion,!0)&&L("boolean",e.allowMultipleVotes,!0)&&L("number",e.closeAt,!0)},Mh=function(e){i(n,e);var t=f(n);function n(e){var a,s=e.pollId,i=e.title,o=e.data,u=e.allowUserSuggestion,c=e.allowMultipleVotes,l=e.closeAt;return r(this,n),(a=t.call(this)).method=B.PUT,a.path="".concat(Jr,"/").concat(encodeURIComponent(s)),a.params={title:i,data:o,allow_user_suggestion:u,allow_multiple_votes:c,close_at:l},a}return s(n)}(ne),Oh=function(e){i(n,e);var t=f(n);function n(e,a){var s;return r(this,n),(s=t.call(this,e,a)).poll=new Us(e,a),s}return s(n)}(re),Uh=function(e){i(n,e);var t=f(n);function n(e){var a,s=e.pollId;return r(this,n),(a=t.call(this)).method=B.DELETE,a.path="".concat(Jr,"/").concat(encodeURIComponent(s)),a}return s(n)}(ne),Rh=function(e){i(n,e);var t=f(n);function n(e){var a,s=e.pollId;return r(this,n),(a=t.call(this)).method=B.PUT,a.path="".concat(Jr,"/").concat(encodeURIComponent(s),"/close"),a}return s(n)}(ne),Lh=function(e){i(n,e);var t=f(n);function n(e,a){var s;return r(this,n),(s=t.call(this,e,a)).poll=new Us(e,a),s}return s(n)}(re),Dh=function(e){i(n,e);var t=f(n);function n(e){var a,s=e.channelUrl,i=e.channelType,o=e.pollId,u=e.optionText;return r(this,n),(a=t.call(this)).method=B.POST,a.path="".concat(Jr,"/").concat(encodeURIComponent(o),"/options"),a.params={channel_url:s,channel_type:i,text:u},a}return s(n)}(ne),Ph=function(e){i(n,e);var t=f(n);function n(e,a){var s;return r(this,n),(s=t.call(this,e,a)).poll=new Us(e,a),s}return s(n)}(re),Fh=function(e){i(n,e);var t=f(n);function n(e){var a,s=e.pollId,i=e.pollOptionId,o=e.optionText;return r(this,n),(a=t.call(this)).method=B.PUT,a.path="".concat(Jr,"/").concat(encodeURIComponent(s),"/options/").concat(encodeURIComponent(i)),a.params={text:o},a}return s(n)}(ne),Gh=function(e){i(n,e);var t=f(n);function n(e,a){var s;return r(this,n),(s=t.call(this,e,a)).poll=new Us(e,a),s}return s(n)}(re),Hh=function(e){i(n,e);var t=f(n);function n(e){var a,s=e.pollId,i=e.pollOptionId;return r(this,n),(a=t.call(this)).method=B.DELETE,a.path="".concat(Jr,"/").concat(encodeURIComponent(s),"/options/").concat(encodeURIComponent(i)),a}return s(n)}(ne),qh=function(t){i(a,t);var n=f(a);function a(t){var s=t.reqId,i=t.channelType,o=t.channelUrl,u=t.pollId,c=t.pollOptionIds;return r(this,a),n.call(this,{code:"VOTE",ackRequired:!0,payload:ee({req_id:s,channel_type:i===e.ChannelType.OPEN?"open_channels":"group_channels",channel_url:o,poll_id:u,option_ids:c})})}return s(a)}(Mr),jh=function(e){i(n,e);var t=f(n);function n(e,a,s){var i;return r(this,n),(i=t.call(this,e,"VOTE",s)).event=null,i.channelUrl=null,i.channelType=null,i.event=new Yi(s),i.channelUrl=s.channel_url,i.channelType=s.channel_type,i}return s(n)}(le),zh=function(n){i(u,n);var a=f(u);function u(t,n){var s,i,o,c,l;return r(this,u),(s=a.call(this,t)).url="",s.channelType=e.ChannelType.BASE,s.name="",s.coverUrl="",s.customType="",s.data="",s.isFrozen=!1,s.isEphemeral=!1,s.creator=null,s.createdAt=0,s._messageCollectionLastAccessedAt=0,s.url=n.channel_url,s.name=null!==(i=n.name)&&void 0!==i?i:"",s.coverUrl=null!==(o=n.cover_url)&&void 0!==o?o:"",s.customType=null!==(c=n.custom_type)&&void 0!==c?c:"",s.data=null!==(l=n.data)&&void 0!==l?l:"",s.isFrozen=!!L("boolean",n.freeze)&&n.freeze,s.isEphemeral=!!L("boolean",n.is_ephemeral)&&n.is_ephemeral,s.creator=n.created_by?new La(s._iid,n.created_by):null,s.createdAt=1e3*n.created_at,s._cachedMetaData=new Map,n.metadata&&n.ts&&Object.keys(n.metadata).forEach((function(e){s._cachedMetaData.set(e,{value:n.metadata[e],isRemoved:!1,updatedAt:n.ts})})),s}return s(u,[{key:"isGroupChannel",value:function(){return this.channelType===e.ChannelType.GROUP}},{key:"isOpenChannel",value:function(){return this.channelType===e.ChannelType.OPEN}},{key:"cachedMetaData",get:function(){var e={};return this._cachedMetaData.forEach((function(t,n){t.isRemoved||(e[n]=t.value)})),e}},{key:"messageCollectionLastAccessedAt",get:function(){return this._messageCollectionLastAccessedAt}},{key:"_updateMessageCollectionLastAccessedAt",value:function(){this._messageCollectionLastAccessedAt=Date.now()}},{key:"_upsertCachedMetaData",value:function(e,t){var n=this;Object.keys(e).forEach((function(r){var a=n._cachedMetaData.get(r);(!a||a.updatedAt<=t)&&n._cachedMetaData.set(r,{value:e[r],isRemoved:!1,updatedAt:t})}))}},{key:"_removeFromCachedMetaData",value:function(e,t){var n=this;e.forEach((function(e){var r=n._cachedMetaData.get(e);r&&r.updatedAt0&&void 0!==arguments[0]?arguments[0]:{};return new bl(this._iid,this.url,this.channelType,e)}},{key:"createMutedUserListQuery",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return new Cl(this._iid,this.url,this.channelType,e)}},{key:"createBannedUserListQuery",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return new Sl(this._iid,this.url,this.channelType,e)}},{key:"createPreviousMessageListQuery",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return new Ii(this._iid,this.url,this.channelType,e)}},{key:"addOperators",value:function(e){return b(this,void 0,void 0,t().mark((function n(){var r,a,s;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return Ua(F("string",e)).throw(M.invalidParameters),r=ns.of(this._iid),a=r.requestQueue,s=new Nl({channelUrl:this.url,channelType:this.channelType,operatorUserIds:e}),t.next=5,a.send(s);case 5:case"end":return t.stop()}}),n,this)})))}},{key:"removeOperators",value:function(e){return b(this,void 0,void 0,t().mark((function n(){var r,a,s;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return Ua(F("string",e)).throw(M.invalidParameters),r=ns.of(this._iid),a=r.requestQueue,s=new Al({channelUrl:this.url,channelType:this.channelType,operatorUserIds:e}),t.next=5,a.send(s);case 5:case"end":return t.stop()}}),n,this)})))}},{key:"getMyMutedInfo",value:function(){return b(this,void 0,void 0,t().mark((function e(){var n,r,a,s,i,o,u,c,l,h,d;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n=ns.of(this._iid),r=n.sdkState,a=n.requestQueue,s=new Ml({channelUrl:this.url,channelType:this.channelType,userId:r.userId}),e.next=4,a.send(s);case 4:return i=e.sent,o=i.as(Ol),u=o.isMuted,c=o.startAt,l=o.endAt,h=o.remainingDuration,d=o.description,e.abrupt("return",{isMuted:u,startAt:c,endAt:l,remainingDuration:h,description:d});case 7:case"end":return e.stop()}}),e,this)})))}},{key:"getMetaData",value:function(e){return b(this,void 0,void 0,t().mark((function n(){var r,a,s,i,o,u,c;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return Ua(F("string",e)).throw(M.invalidParameters),r=ns.of(this._iid),a=r.requestQueue,s=new Ul({channelUrl:this.url,channelType:this.channelType,keys:e}),t.next=5,a.send(s);case 5:return i=t.sent,o=i.as(Rl),u=o.metadata,c=o.ts,this._upsertCachedMetaData(u,c),t.abrupt("return",u);case 9:case"end":return t.stop()}}),n,this)})))}},{key:"getAllMetaData",value:function(){return b(this,void 0,void 0,t().mark((function e(){var n,r,a,s,i,o,u;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n=ns.of(this._iid),r=n.requestQueue,a=new Ul({channelUrl:this.url,channelType:this.channelType,keys:[]}),e.next=4,r.send(a);case 4:return s=e.sent,i=s.as(Rl),o=i.metadata,u=i.ts,this._upsertCachedMetaData(o,u),e.abrupt("return",o);case 8:case"end":return e.stop()}}),e,this)})))}},{key:"createMetaData",value:function(e){return b(this,void 0,void 0,t().mark((function n(){var r,a,s,i,o,u;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return r=ns.of(this._iid),a=r.requestQueue,s=new Ll({channelUrl:this.url,channelType:this.channelType,metadata:e}),t.next=4,a.send(s);case 4:return i=t.sent,o=i.as(Dl),u=o.metaData,this._upsertCachedMetaData(u,0),t.abrupt("return",u);case 8:case"end":return t.stop()}}),n,this)})))}},{key:"updateMetaData",value:function(e){var n=arguments.length>1&&void 0!==arguments[1]&&arguments[1];return b(this,void 0,void 0,t().mark((function r(){var a,s,i,o,u,c,l;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return a=ns.of(this._iid),s=a.requestQueue,i=new Pl({channelUrl:this.url,channelType:this.channelType,metadata:e,upsert:n}),t.next=4,s.send(i);case 4:return o=t.sent,u=o.as(Fl),c=u.metadata,l=u.ts,this._upsertCachedMetaData(c,l),t.abrupt("return",c);case 8:case"end":return t.stop()}}),r,this)})))}},{key:"deleteMetaData",value:function(e){return b(this,void 0,void 0,t().mark((function n(){var r,a,s,i,o,u;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return Ua(L("string",e)).throw(M.invalidParameters),r=ns.of(this._iid),a=r.requestQueue,s=new Hl({channelUrl:this.url,channelType:this.channelType,key:e}),t.next=5,a.send(s);case 5:i=t.sent,o=i.as(ql),u=o.ts,this._removeFromCachedMetaData([e],u);case 8:case"end":return t.stop()}}),n,this)})))}},{key:"deleteAllMetaData",value:function(){return b(this,void 0,void 0,t().mark((function e(){var n,r,a,s,i,o;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n=ns.of(this._iid),r=n.requestQueue,a=new jl({channelUrl:this.url,channelType:this.channelType}),e.next=4,r.send(a);case 4:s=e.sent,i=s.as(zl),o=i.ts,this._removeFromCachedMetaData(_(this._cachedMetaData.keys()),o);case 7:case"end":return e.stop()}}),e,this)})))}},{key:"getMetaCounters",value:function(e){return b(this,void 0,void 0,t().mark((function n(){var r,a,s,i,o,u;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return Ua(F("string",e)).throw(M.invalidParameters),r=ns.of(this._iid),a=r.requestQueue,s=new Vl({channelUrl:this.url,channelType:this.channelType,keys:e}),t.next=5,a.send(s);case 5:return i=t.sent,o=i.as(Bl),u=o.metaCounter,t.abrupt("return",u);case 8:case"end":return t.stop()}}),n,this)})))}},{key:"getAllMetaCounters",value:function(){return b(this,void 0,void 0,t().mark((function e(){var n,r,a,s,i,o;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n=ns.of(this._iid),r=n.requestQueue,a=new Vl({channelUrl:this.url,channelType:this.channelType,keys:[]}),e.next=4,r.send(a);case 4:return s=e.sent,i=s.as(Bl),o=i.metaCounter,e.abrupt("return",o);case 7:case"end":return e.stop()}}),e,this)})))}},{key:"createMetaCounters",value:function(e){return b(this,void 0,void 0,t().mark((function n(){var r,a,s,i,o,u;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return r=ns.of(this._iid),a=r.requestQueue,s=new Ql({channelUrl:this.url,channelType:this.channelType,metaCounter:e}),t.next=4,a.send(s);case 4:return i=t.sent,o=i.as(Kl),u=o.metaCounter,t.abrupt("return",u);case 7:case"end":return t.stop()}}),n,this)})))}},{key:"updateMetaCounters",value:function(e){var n=arguments.length>1&&void 0!==arguments[1]&&arguments[1];return b(this,void 0,void 0,t().mark((function r(){var a,s,i,o,u,c;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return a=ns.of(this._iid),s=a.requestQueue,i=new Wl({channelUrl:this.url,channelType:this.channelType,metaCounter:e,upsert:n}),t.next=4,s.send(i);case 4:return o=t.sent,u=o.as(Yl),c=u.metaCounter,t.abrupt("return",c);case 7:case"end":return t.stop()}}),r,this)})))}},{key:"increaseMetaCounters",value:function(e){return b(this,void 0,void 0,t().mark((function n(){var r,a,s,i,o,u;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return r=ns.of(this._iid),a=r.requestQueue,s=new Wl({channelUrl:this.url,channelType:this.channelType,metaCounter:e,upsert:!1,mode:"increase"}),t.next=4,a.send(s);case 4:return i=t.sent,o=i.as(Yl),u=o.metaCounter,t.abrupt("return",u);case 7:case"end":return t.stop()}}),n,this)})))}},{key:"decreaseMetaCounters",value:function(e){return b(this,void 0,void 0,t().mark((function n(){var r,a,s,i,o,u;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return r=ns.of(this._iid),a=r.requestQueue,s=new Wl({channelUrl:this.url,channelType:this.channelType,metaCounter:e,upsert:!1,mode:"decrease"}),t.next=4,a.send(s);case 4:return i=t.sent,o=i.as(Yl),u=o.metaCounter,t.abrupt("return",u);case 7:case"end":return t.stop()}}),n,this)})))}},{key:"deleteMetaCounter",value:function(e){return b(this,void 0,void 0,t().mark((function n(){var r,a,s;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return Ua(L("string",e)).throw(M.invalidParameters),r=ns.of(this._iid),a=r.requestQueue,s=new Jl({channelUrl:this.url,channelType:this.channelType,key:e}),t.next=5,a.send(s);case 5:case"end":return t.stop()}}),n,this)})))}},{key:"deleteAllMetaCounters",value:function(){return b(this,void 0,void 0,t().mark((function e(){var n,r,a;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n=ns.of(this._iid),r=n.requestQueue,a=new Xl({channelUrl:this.url,channelType:this.channelType}),e.next=4,r.send(a);case 4:case"end":return e.stop()}}),e,this)})))}},{key:"muteUser",value:function(e,n,r){return b(this,void 0,void 0,t().mark((function a(){return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.abrupt("return",this.muteUserWithUserId(e.userId,n,r));case 1:case"end":return t.stop()}}),a,this)})))}},{key:"muteUserWithUserId",value:function(e,n,r){return b(this,void 0,void 0,t().mark((function a(){var s,i,o;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return Ua(L("string",e)&&L("number",n,!0)&&L("string",r,!0)).throw(M.invalidParameters),s=ns.of(this._iid),i=s.requestQueue,o=new $l({channelUrl:this.url,channelType:this.channelType,userId:e,seconds:n,description:r}),t.next=5,i.send(o);case 5:case"end":return t.stop()}}),a,this)})))}},{key:"unmuteUser",value:function(e){return b(this,void 0,void 0,t().mark((function n(){return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.abrupt("return",this.unmuteUserWithUserId(e.userId));case 1:case"end":return t.stop()}}),n,this)})))}},{key:"unmuteUserWithUserId",value:function(e){return b(this,void 0,void 0,t().mark((function n(){var r,a,s;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return Ua(L("string",e)).throw(M.invalidParameters),r=ns.of(this._iid),a=r.requestQueue,s=new th({channelUrl:this.url,channelType:this.channelType,userId:e}),t.next=5,a.send(s);case 5:case"end":return t.stop()}}),n,this)})))}},{key:"banUser",value:function(e,n,r){return b(this,void 0,void 0,t().mark((function a(){return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.abrupt("return",this.banUserWithUserId(e.userId,n,r));case 1:case"end":return t.stop()}}),a,this)})))}},{key:"banUserWithUserId",value:function(e,n,r){return b(this,void 0,void 0,t().mark((function a(){var s,i,o;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return Ua(L("string",e)&&L("number",n,!0)&&L("string",r,!0)).throw(M.invalidParameters),s=ns.of(this._iid),i=s.requestQueue,o=new rh({channelUrl:this.url,channelType:this.channelType,userId:e,seconds:n,description:r}),t.next=5,i.send(o);case 5:case"end":return t.stop()}}),a,this)})))}},{key:"unbanUser",value:function(e){return b(this,void 0,void 0,t().mark((function n(){return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.abrupt("return",this.unbanUserWithUserId(e.userId));case 1:case"end":return t.stop()}}),n,this)})))}},{key:"unbanUserWithUserId",value:function(e){return b(this,void 0,void 0,t().mark((function n(){var r,a,s;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return Ua(L("string",e)).throw(M.invalidParameters),r=ns.of(this._iid),a=r.requestQueue,s=new sh({channelUrl:this.url,channelType:this.channelType,userId:e}),t.next=5,a.send(s);case 5:case"end":return t.stop()}}),n,this)})))}},{key:"freeze",value:function(){return b(this,void 0,void 0,t().mark((function e(){var n,r,a;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n=ns.of(this._iid),r=n.requestQueue,a=new oh({channelUrl:this.url,channelType:this.channelType,freezing:!0}),e.next=4,r.send(a);case 4:this.isFrozen=!0;case 5:case"end":return e.stop()}}),e,this)})))}},{key:"unfreeze",value:function(){return b(this,void 0,void 0,t().mark((function e(){var n,r,a;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n=ns.of(this._iid),r=n.requestQueue,a=new oh({channelUrl:this.url,channelType:this.channelType,freezing:!1}),e.next=4,r.send(a);case 4:this.isFrozen=!1;case 5:case"end":return e.stop()}}),e,this)})))}},{key:"getMessagesByMessageId",value:function(e,n){return b(this,void 0,void 0,t().mark((function r(){var a,s;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return a=Object.assign(Object.assign({},Ws),n),Ua(L("number",e)&&Ys(a)).throw(M.invalidParameters),s=vi.of(this._iid),t.next=5,s.getMessagesByMessageId(this.url,this.channelType,e,a);case 5:return t.abrupt("return",t.sent);case 6:case"end":return t.stop()}}),r,this)})))}},{key:"getMessagesByTimestamp",value:function(e,n){return b(this,void 0,void 0,t().mark((function r(){var a,s;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return a=Object.assign(Object.assign({},Ws),n),Ua(L("number",e)&&Ys(a)).throw(M.invalidParameters),s=vi.of(this._iid),t.next=5,s.getMessagesByTimestamp(this.url,this.channelType,e,a);case 5:return t.abrupt("return",t.sent);case 6:case"end":return t.stop()}}),r,this)})))}},{key:"getMessageChangeLogsSinceTimestamp",value:function(e){var n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return b(this,void 0,void 0,t().mark((function r(){var a,s;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return a=Object.assign(Object.assign({},Zs),n),Ua(L("number",e)&&Js(a)).throw(M.invalidParameters),s=vi.of(this._iid),t.next=5,s.getMessageChangelogs(this.url,this.channelType,e,a);case 5:return t.abrupt("return",t.sent);case 6:case"end":return t.stop()}}),r,this)})))}},{key:"getMessageChangeLogsSinceToken",value:function(e){var n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return b(this,void 0,void 0,t().mark((function r(){var a,s;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return a=Object.assign(Object.assign({},Zs),n),Ua(L("string",e)&&Js(a)).throw(M.invalidParameters),s=vi.of(this._iid),t.next=5,s.getMessageChangelogs(this.url,this.channelType,e,a);case 5:return t.abrupt("return",t.sent);case 6:case"end":return t.stop()}}),r,this)})))}},{key:"_createPendingSendableMessagePayload",value:function(t,n,r){var a=ns.of(this._iid).sessionManager;return ee({channel_url:this.url,channel_type:this.channelType,msg_id:0,parent_message_id:t.parentMessageId,data:t.data,custom_type:t.customType,mention_type:t.mentionType,sorted_metaarray:t.metaArrays?t.metaArrays.map((function(e){return ps.payloadify(e)})):null,apple_critical_alert_options:t.appleCriticalAlertOptions?ms.payloadify(t.appleCriticalAlertOptions):null,created_at:r,user:bs.payloadify(a.currentUser),req_id:n,request_state:e.SendingStatus.PENDING,mentioned_user_ids:t.mentionedUserIds,mentioned_users:t.mentionedUsers})}},{key:"_createPendingUserMessage",value:function(t,n,r){var a={};if(t.translationTargetLanguages){var s,i=y(t.translationTargetLanguages);try{for(i.s();!(s=i.n()).done;){a[s.value]=""}}catch(e){i.e(e)}finally{i.f()}}var o=ee(Object.assign(Object.assign({},this._createPendingSendableMessagePayload(t,n,r)),{type:e.MessageType.USER,message:t.message,translations:a})),u=new Rs(this._iid,o);return u.messageParams=t,u}},{key:"_createPendingScheduledUserMessage",value:function(e,t,n){var r=this._createPendingUserMessage(e,t,n);return r.scheduledInfo={scheduledMessageId:0,scheduledAt:e.scheduledAt,scheduledMessageParams:e},r}},{key:"_createPendingFileMessage",value:function(t,n,r){var a=ee(Object.assign(Object.assign({},this._createPendingSendableMessagePayload(t,n,r)),{type:e.MessageType.FILE,url:t.fileUrl,file:{name:t.fileName,size:t.fileSize,type:t.mimeType,data:t.data},thumbnails:t.thumbnailSizes?t.thumbnailSizes.map((function(e){return{url:"",width:e.maxWidth,height:e.maxHeight}})):[]})),s=new Ps(this._iid,a);return s.messageParams=t,s}},{key:"_createPendingScheduledFileMessage",value:function(e,t,n){var r=this._createPendingFileMessage(e,t,n);return r.scheduledInfo={scheduledMessageId:0,scheduledAt:e.scheduledAt,scheduledMessageParams:e},r}},{key:"_markMessageAsFailed",value:function(t,n){var r=arguments.length>2&&void 0!==arguments[2]&&arguments[2];t.errorCode=n.code,n.code===E.REQUEST_CANCELED?t.sendingStatus=e.SendingStatus.CANCELED:r||(t.sendingStatus=e.SendingStatus.FAILED)}},{key:"sendUserMessage",value:function(e){var t=Object.assign(Object.assign({},ko),e);return Ua(Eo(t)).throw(M.invalidParameters),this._sendUserMessage(t)}},{key:"_sendUserMessage",value:function(n){var r=this,a=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null,s=ns.of(this._iid),i=s.dispatcher,o=s.requestQueue,u=a,c=Date.now(),l=new _i;u||(u=this._generateRequestId(),sa(2).then((function(){var a=r._createPendingUserMessage(n,u,c);i.dispatch(new ei({messages:[a],source:e.MessageEventSource.EVENT_MESSAGE_SENT_PENDING})),ua((function(){return b(r,void 0,void 0,t().mark((function e(){return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",l._trigger(null,a));case 1:case"end":return e.stop()}}),e)})))}))})));var h=new dh(Object.assign(Object.assign({},n),{channelUrl:this.url,channelType:this.channelType,reqId:u}));return o.send(h).then((function(n){var a=n.as(fh).message;i.dispatch(new ei({messages:[a],source:e.MessageEventSource.EVENT_MESSAGE_SENT_SUCCESS})),ua((function(){return b(r,void 0,void 0,t().mark((function e(){return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",l._trigger(null,a));case 1:case"end":return e.stop()}}),e)})))}))})).catch((function(a){if(A(a))throw a;sa(2).then((function(){var s=r._createPendingUserMessage(n,u,c),o=ns.of(r._iid).cacheContext.localCacheEnabled&&G(a.code);r._markMessageAsFailed(s,a,o),i.dispatch(new ei({messages:[s],source:s.sendingStatus===e.SendingStatus.PENDING?e.MessageEventSource.REQUEST_RESEND_MESSAGE:e.MessageEventSource.EVENT_MESSAGE_SENT_FAILED})),ua((function(){return b(r,void 0,void 0,t().mark((function e(){return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",l._trigger(a,s));case 1:case"end":return e.stop()}}),e)})))}))}))})),l}},{key:"_autoResendUserMessage",value:function(e){return Ua(e instanceof Rs).throw(M.invalidParameters),this._sendUserMessage(e.messageParams,e.reqId)}},{key:"resendUserMessage",value:function(e){var n;return b(this,void 0,void 0,t().mark((function r(){var a,s;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return Ua(e instanceof Rs&&!e.scheduledInfo).throw(M.invalidParameters),a=new Ur,s=null!==(n=e.messageParams)&&void 0!==n?n:bo(e),this._sendUserMessage(s,e.reqId).onFailed((function(e){return a.reject(e)})).onSucceeded((function(e){return a.resolve(e)})),t.abrupt("return",a.promise);case 5:case"end":return t.stop()}}),r,this)})))}},{key:"updateUserMessage",value:function(e,n){return b(this,void 0,void 0,t().mark((function r(){var a,s,i,o,u,c,l;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return a=Object.assign(Object.assign({},vl),n),Ua(L("number",e)&&_l(a)).throw(M.invalidParameters),s=ns.of(this._iid),i=s.requestQueue,o=new ph(Object.assign({channelType:this.channelType,channelUrl:this.url,messageId:e},a)),t.next=6,i.send(o);case 6:return u=t.sent,c=u.as(vh),l=c.message,t.abrupt("return",l);case 9:case"end":return t.stop()}}),r,this)})))}},{key:"copyUserMessage",value:function(n,r){var a,s,i;return b(this,void 0,void 0,t().mark((function o(){var c,l;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return Ua(n instanceof u&&r instanceof Rs&&r.sendingStatus===e.SendingStatus.SUCCEEDED&&this.url===r.channelUrl&&!r.scheduledInfo).throw(M.invalidParameters),Ua(!r.poll).throw(M.notSupportedError),c=new Ur,l=null!==(a=r.messageParams)&&void 0!==a?a:Object.assign(Object.assign({},r),{mentionType:r.mentionType,mentionedUserIds:null!==(s=r.mentionedUserIds)&&void 0!==s?s:null===(i=r.mentionedUsers)||void 0===i?void 0:i.map((function(e){return e.userId})),translationTargetLanguages:Object.keys(r.translations),pushNotificationDeliveryOption:e.PushNotificationDeliveryOption.DEFAULT,parentMessageId:null,isReplyToChannel:!1,isPinnedMessage:!1}),n._sendUserMessage(l).onSucceeded((function(e){c.resolve(e)})).onFailed((function(e){return c.reject(e)})),t.abrupt("return",c.promise);case 6:case"end":return t.stop()}}),o,this)})))}},{key:"translateUserMessage",value:function(e,n){return b(this,void 0,void 0,t().mark((function r(){var a,s,i,o,u,c;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return Ua(e instanceof Rs&&e.messageId>0&&F("string",n)).throw(M.invalidParameters),a=ns.of(this._iid),s=a.requestQueue,i=new Ch({channelType:this.channelType,channelUrl:this.url,messageId:e.messageId,translationTargetLanguages:n}),t.next=5,s.send(i);case 5:return o=t.sent,u=o.as(xh),c=u.message,t.abrupt("return",c);case 8:case"end":return t.stop()}}),r,this)})))}},{key:"_createScheduledUserMessage",value:function(e,n){var r=this,a=ns.of(this._iid).requestQueue,s=Date.now(),i=this._generateRequestId();sa(2).then((function(){var a=r._createPendingScheduledUserMessage(e,i,s);ua((function(){return b(r,void 0,void 0,t().mark((function e(){return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",n._trigger(null,a));case 1:case"end":return e.stop()}}),e)})))}))}));var o=new Th(Object.assign({reqId:i,channelType:this.channelType,channelUrl:this.url},e));a.send(o).then((function(e){var a=e.as(Sh).message;ua((function(){return b(r,void 0,void 0,t().mark((function e(){return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",n._trigger(null,a));case 1:case"end":return e.stop()}}),e)})))}))})).catch((function(a){if(A(a))throw a;sa(2).then((function(){var o=r._createPendingScheduledUserMessage(e,i,s);r._markMessageAsFailed(o,a),ua((function(){return b(r,void 0,void 0,t().mark((function e(){return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",n._trigger(a,o));case 1:case"end":return e.stop()}}),e)})))}))}))}))}},{key:"sendFileMessage",value:function(e){var t=Object.assign(Object.assign({},To),e);return Ua(Io(t)).throw(M.invalidParameters),this._sendFileMessage(t)}},{key:"_sendFileMessage",value:function(n){var r=this,a=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null,s=ns.of(this._iid).dispatcher,i=vi.of(this._iid).fileMessageQueue,o=a,u=Date.now(),c=new _i;return o||(o=this._generateRequestId(),sa(2).then((function(){var a=r._createPendingFileMessage(n,o,u);s.dispatch(new ei({messages:[a],source:e.MessageEventSource.EVENT_MESSAGE_SENT_PENDING})),ua((function(){return b(r,void 0,void 0,t().mark((function e(){return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",c._trigger(null,a));case 1:case"end":return e.stop()}}),e)})))}))}))),i.request(this,o,n).then((function(n){s.dispatch(new ei({messages:[n],source:e.MessageEventSource.EVENT_MESSAGE_SENT_SUCCESS})),ua((function(){return b(r,void 0,void 0,t().mark((function e(){return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",c._trigger(null,n));case 1:case"end":return e.stop()}}),e)})))}))})).catch((function(a){if(A(a))throw a;sa(2).then((function(){var i=r._createPendingFileMessage(n,o,u),l=ns.of(r._iid).cacheContext.localCacheEnabled&&G(a.code);r._markMessageAsFailed(i,a,l),s.dispatch(new ei({messages:[i],source:i.sendingStatus===e.SendingStatus.PENDING?e.MessageEventSource.REQUEST_RESEND_MESSAGE:e.MessageEventSource.EVENT_MESSAGE_SENT_FAILED})),ua((function(){return b(r,void 0,void 0,t().mark((function e(){return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",c._trigger(a,i));case 1:case"end":return e.stop()}}),e)})))}))}))})),c}},{key:"_autoResendFileMessage",value:function(e){Ua(e instanceof Ps).throw(M.invalidParameters);var t=ns.of(this._iid).logger;return t.debug("autoResendFileMessage pending",e),this._sendFileMessage(e.messageParams,e.reqId).onFailed((function(e){t.debug("autoResendFileMessage failed",e)})).onSucceeded((function(e){t.debug("autoResendFileMessage success",e)}))}},{key:"_createScheduledFileMessage",value:function(e,n,r,a){var s=this,i=ns.of(this._iid).requestQueue,o=new Ih(Object.assign(Object.assign({reqId:r,channelType:this.channelType,channelUrl:this.url},e),{fileUrl:e.fileUrl,requireAuth:e.requireAuth}));i.send(o).then((function(e){var r=e.as(Nh).message;ua((function(){return b(s,void 0,void 0,t().mark((function e(){return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",n._trigger(null,r));case 1:case"end":return e.stop()}}),e)})))}))})).catch((function(i){if(A(i))throw i;sa(2).then((function(){var o=s._createPendingScheduledFileMessage(e,r,a);s._markMessageAsFailed(o,i),ua((function(){return b(s,void 0,void 0,t().mark((function e(){return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",n._trigger(i,o));case 1:case"end":return e.stop()}}),e)})))}))}))}))}},{key:"sendFileMessages",value:function(e){Ua(e.every((function(e){return Io(Object.assign(Object.assign({},To),e))}))).throw(M.invalidParameters);var t,n=new _i,r=y(e);try{for(r.s();!(t=r.n()).done;){var a=t.value;this.sendFileMessage(a).onPending((function(e){return n._trigger(null,e)})).onFailed((function(e,t){return n._trigger(e,t)})).onSucceeded((function(e){return n._trigger(null,e)}))}}catch(e){r.e(e)}finally{r.f()}return n}},{key:"resendFileMessage",value:function(e,n){var r;return b(this,void 0,void 0,t().mark((function a(){var s,i,o;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return s=Boolean(e.url)||H(n)||H(null===(r=e.messageParams)||void 0===r?void 0:r.file),Ua(e instanceof Ps&&s&&!e.scheduledInfo).throw(M.invalidParameters),i=new Ur,o=So(e,n),this._sendFileMessage(o,e.reqId).onFailed((function(e){return i.reject(e)})).onSucceeded((function(e){return i.resolve(e)})),t.abrupt("return",i.promise);case 6:case"end":return t.stop()}}),a,this)})))}},{key:"updateFileMessage",value:function(e,n){return b(this,void 0,void 0,t().mark((function r(){var a,s,i,o,u,c,l;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return a=Object.assign(Object.assign({},ml),n),Ua(L("number",e)&&gl(a)).throw(M.invalidParameters),s=ns.of(this._iid),i=s.requestQueue,o=new _h(Object.assign({channelType:this.channelType,channelUrl:this.url,messageId:e},a)),t.next=6,i.send(o);case 6:return u=t.sent,c=u.as(mh),l=c.message,t.abrupt("return",l);case 9:case"end":return t.stop()}}),r,this)})))}},{key:"cancelUploadingFileMessage",value:function(e){return b(this,void 0,void 0,t().mark((function n(){var r;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return Ua(L("string",e)).throw(M.invalidParameters),r=vi.of(this._iid),r.fileMessageQueue.cancel(this,e),t.abrupt("return",!0);case 4:case"end":return t.stop()}}),n,this)})))}},{key:"copyFileMessage",value:function(n,r){var a,s;return b(this,void 0,void 0,t().mark((function i(){var o,c;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return Ua(n instanceof u&&r instanceof Ps&&r.sendingStatus===e.SendingStatus.SUCCEEDED&&this.url===r.channelUrl&&!r.scheduledInfo).throw(M.invalidParameters),o=new Ur,c=Object.assign(Object.assign({},r),{fileUrl:r.url,fileName:r.name,fileSize:r.size,mimeType:r.type,mentionType:r.mentionType,mentionedUserIds:null!==(a=r.mentionedUserIds)&&void 0!==a?a:null===(s=r.mentionedUsers)||void 0===s?void 0:s.map((function(e){return e.userId})),pushNotificationDeliveryOption:e.PushNotificationDeliveryOption.DEFAULT,parentMessageId:null,isReplyToChannel:!1,thumbnailSizes:r.thumbnails.map((function(e){return{maxWidth:e.width,maxHeight:e.height}})),requireAuth:r.requireAuth,isPinnedMessage:!1}),n._sendFileMessage(c).onSucceeded((function(e){return o.resolve(e)})).onFailed((function(e){return o.reject(e)})),t.abrupt("return",o.promise);case 5:case"end":return t.stop()}}),i,this)})))}},{key:"deleteMessage",value:function(e){return b(this,void 0,void 0,t().mark((function n(){var r,a,s;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(Ua(e instanceof ks).throw(M.invalidParameters),!(e.messageId>0)){t.next=6;break}return r=ns.of(this._iid),a=r.requestQueue,s=new gh({channelType:this.channelType,channelUrl:this.url,messageId:e.messageId}),t.next=6,a.send(s);case 6:case"end":return t.stop()}}),n,this)})))}},{key:"addReaction",value:function(e,n){return b(this,void 0,void 0,t().mark((function r(){var a,s,i,o,u,c;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return Ua(e instanceof ks&&e.messageId>0&&L("string",n)).throw(M.invalidParameters),a=ns.of(this._iid),s=a.requestQueue,i=new kh({channelType:this.channelType,channelUrl:this.url,messageId:e.messageId,reactionKey:n}),t.next=5,s.send(i);case 5:return o=t.sent,u=o.as(bh),c=u.reactionEvent,t.abrupt("return",c);case 8:case"end":return t.stop()}}),r,this)})))}},{key:"deleteReaction",value:function(e,n){return b(this,void 0,void 0,t().mark((function r(){var a,s,i,o,u,c;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return Ua(e instanceof ks&&e.messageId>0&&L("string",n)).throw(M.invalidParameters),a=ns.of(this._iid),s=a.requestQueue,i=new Eh({channelType:this.channelType,channelUrl:this.url,messageId:e.messageId,reactionKey:n}),t.next=5,s.send(i);case 5:return o=t.sent,u=o.as(wh),c=u.reactionEvent,t.abrupt("return",c);case 8:case"end":return t.stop()}}),r,this)})))}},{key:"_updateUserMessageMetaArray",value:function(n,r,a,s){return b(this,void 0,void 0,t().mark((function i(){var o,u,c,l,h,d,f;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return o=ns.of(this._iid),u=o.dispatcher,c=o.requestQueue,l=new ph({channelType:this.channelType,channelUrl:this.url,messageId:n,metaArrayParams:{array:r,mode:a,upsert:s}}),t.next=4,c.send(l);case 4:return h=t.sent,d=h.as(vh),f=d.message,u.dispatch(new ei({messages:[f],source:e.MessageEventSource.EVENT_MESSAGE_UPDATED})),t.abrupt("return",f);case 8:case"end":return t.stop()}}),i,this)})))}},{key:"_updateFileMessageMetaArray",value:function(n,r,a,s){return b(this,void 0,void 0,t().mark((function i(){var o,u,c,l,h,d,f;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return o=ns.of(this._iid),u=o.dispatcher,c=o.requestQueue,l=new _h({channelType:this.channelType,channelUrl:this.url,messageId:n,metaArrayParams:{array:r,mode:a,upsert:s}}),t.next=4,c.send(l);case 4:return h=t.sent,d=h.as(mh),f=d.message,u.dispatch(new ei({messages:[f],source:e.MessageEventSource.EVENT_MESSAGE_UPDATED})),t.abrupt("return",f);case 8:case"end":return t.stop()}}),i,this)})))}},{key:"createMessageMetaArrayKeys",value:function(e,n){return b(this,void 0,void 0,t().mark((function r(){var a;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(Ua(e instanceof ks&&e.messageId>0&&F("string",n)).throw(M.invalidParameters),a=n.map((function(e){return new ps({key:e})})),!(e instanceof Ps)){t.next=6;break}return t.abrupt("return",this._updateFileMessageMetaArray(e.messageId,a,"add",!0));case 6:return t.abrupt("return",this._updateUserMessageMetaArray(e.messageId,a,"add",!0));case 7:case"end":return t.stop()}}),r,this)})))}},{key:"deleteMessageMetaArrayKeys",value:function(e,n){return b(this,void 0,void 0,t().mark((function r(){var a;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(Ua(e instanceof ks&&e.messageId>0&&F("string",n)).throw(M.invalidParameters),a=n.map((function(e){return new ps({key:e})})),!(e instanceof Ps)){t.next=6;break}return t.abrupt("return",this._updateFileMessageMetaArray(e.messageId,a,"remove",!0));case 6:return t.abrupt("return",this._updateUserMessageMetaArray(e.messageId,a,"remove",!0));case 7:case"end":return t.stop()}}),r,this)})))}},{key:"addMessageMetaArrayValues",value:function(e,n){return b(this,void 0,void 0,t().mark((function r(){return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(Ua(e instanceof ks&&e.messageId>0&&n.every((function(e){return e instanceof ps}))).throw(M.invalidParameters),!(e instanceof Ps)){t.next=5;break}return t.abrupt("return",this._updateFileMessageMetaArray(e.messageId,n,"add",!0));case 5:return t.abrupt("return",this._updateUserMessageMetaArray(e.messageId,n,"add",!0));case 6:case"end":return t.stop()}}),r,this)})))}},{key:"removeMessageMetaArrayValues",value:function(e,n){return b(this,void 0,void 0,t().mark((function r(){return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(Ua(e instanceof ks&&e.messageId>0&&n.every((function(e){return e instanceof ps}))).throw(M.invalidParameters),!(e instanceof Ps)){t.next=5;break}return t.abrupt("return",this._updateFileMessageMetaArray(e.messageId,n,"remove",!0));case 5:return t.abrupt("return",this._updateUserMessageMetaArray(e.messageId,n,"remove",!0));case 6:case"end":return t.stop()}}),r,this)})))}},{key:"report",value:function(n,r){return b(this,void 0,void 0,t().mark((function a(){var s,i,o,u;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return Ua(D(e.ReportCategory,n)&&L("string",r)).throw(M.invalidParameters),s=ns.of(this._iid),i=s.sdkState,o=s.requestQueue,u=new ch({channelUrl:this.url,channelType:this.channelType,userId:i.userId,category:n,description:r}),t.next=5,o.send(u);case 5:case"end":return t.stop()}}),a,this)})))}},{key:"reportUser",value:function(n,r,a){return b(this,void 0,void 0,t().mark((function s(){var i,o,u,c;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return Ua(n instanceof La&&D(e.ReportCategory,r)&&L("string",a)).throw(M.invalidParameters),i=ns.of(this._iid),o=i.sdkState,u=i.requestQueue,c=new lh({channelUrl:this.url,channelType:this.channelType,userId:o.userId,offendingUserId:n.userId,category:r,description:a}),t.next=5,u.send(c);case 5:case"end":return t.stop()}}),s,this)})))}},{key:"reportMessage",value:function(n,r,a){return b(this,void 0,void 0,t().mark((function s(){var i,o,u,c;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return Ua(n instanceof Es&&D(e.ReportCategory,r)&&L("string",a)).throw(M.invalidParameters),i=ns.of(this._iid),o=i.sdkState,u=i.requestQueue,c=new hh({channelUrl:this.url,channelType:this.channelType,userId:o.userId,offendingUserId:n.sender.userId,messageId:n.messageId,category:r,description:a}),t.next=5,u.send(c);case 5:case"end":return t.stop()}}),s,this)})))}},{key:"updatePoll",value:function(e,n){return b(this,void 0,void 0,t().mark((function r(){var a,s,i,o,u,c;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return Ua(L("number",e)&&Ah(n)).throw(M.invalidParameters),a=ns.of(this._iid),s=a.requestQueue,i=new Mh(Object.assign({pollId:e},n)),t.next=5,s.send(i);case 5:return o=t.sent,u=o.as(Oh),c=u.poll,t.abrupt("return",c);case 8:case"end":return t.stop()}}),r,this)})))}},{key:"deletePoll",value:function(e){return b(this,void 0,void 0,t().mark((function n(){var r,a,s,i;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return r=L("number",e),Ua(r).throw(M.invalidParameters),a=ns.of(this._iid),s=a.requestQueue,i=new Uh({pollId:e}),t.next=6,s.send(i);case 6:case"end":return t.stop()}}),n,this)})))}},{key:"closePoll",value:function(e){return b(this,void 0,void 0,t().mark((function n(){var r,a,s,i,o,u,c;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return r=L("number",e),Ua(r).throw(M.invalidParameters),a=ns.of(this._iid),s=a.requestQueue,i=new Rh({pollId:e}),t.next=6,s.send(i);case 6:return o=t.sent,u=o.as(Lh),c=u.poll,t.abrupt("return",c);case 9:case"end":return t.stop()}}),n,this)})))}},{key:"addPollOption",value:function(e,n){return b(this,void 0,void 0,t().mark((function r(){var a,s,i,o,u,c,l;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return a=L("number",e)&&L("string",n)&&""!==n.trim(),Ua(a).throw(M.invalidParameters),s=ns.of(this._iid),i=s.requestQueue,o=new Dh({channelUrl:this.url,channelType:this.channelType,pollId:e,optionText:n}),t.next=6,i.send(o);case 6:return u=t.sent,c=u.as(Ph),l=c.poll,t.abrupt("return",l);case 9:case"end":return t.stop()}}),r,this)})))}},{key:"updatePollOption",value:function(e,n,r){return b(this,void 0,void 0,t().mark((function a(){var s,i,o,u,c,l,h;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return s=L("number",e)&&L("number",n)&&L("string",r)&&""!==r.trim(),Ua(s).throw(M.invalidParameters),i=ns.of(this._iid),o=i.requestQueue,u=new Fh({pollId:e,pollOptionId:n,optionText:r}),t.next=6,o.send(u);case 6:return c=t.sent,l=c.as(Gh),h=l.poll,t.abrupt("return",h);case 9:case"end":return t.stop()}}),a,this)})))}},{key:"deletePollOption",value:function(e,n){return b(this,void 0,void 0,t().mark((function r(){var a,s,i,o;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return a=L("number",e)&&L("number",n),Ua(a).throw(M.invalidParameters),s=ns.of(this._iid),i=s.requestQueue,o=new Hh({pollId:e,pollOptionId:n}),t.next=6,i.send(o);case 6:case"end":return t.stop()}}),r,this)})))}},{key:"votePoll",value:function(n,r){return b(this,void 0,void 0,t().mark((function a(){var s,i,o,u,c,l,h,d;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return s=L("number",n)&&F("number",r),Ua(s).throw(M.invalidParameters),i=ns.of(this._iid),o=i.requestQueue,u=i.dispatcher,c=new qh({reqId:this._generateRequestId(),channelUrl:this.url,channelType:this.channelType,pollId:n,pollOptionIds:r}),t.next=6,o.send(c);case 6:return l=t.sent,h=l.as(jh),d=h.event,u.dispatch(new si({event:d,source:e.MessageEventSource.EVENT_POLL_VOTED})),t.abrupt("return",d);case 10:case"end":return t.stop()}}),a,this)})))}},{key:"getPollChangeLogsSinceTimestamp",value:function(e){return b(this,void 0,void 0,t().mark((function n(){var r;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return Ua(L("number",e)).throw(M.invalidParameters),r=Ki.of(this._iid),t.next=4,r.getPollChangeLogs(this.url,this.channelType,e);case 4:return t.abrupt("return",t.sent);case 5:case"end":return t.stop()}}),n,this)})))}},{key:"getPollChangeLogsSinceToken",value:function(e){return b(this,void 0,void 0,t().mark((function n(){var r;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return Ua(L("string",e,!0)),r=Ki.of(this._iid),t.next=4,r.getPollChangeLogs(this.url,this.channelType,e);case 4:return t.abrupt("return",t.sent);case 5:case"end":return t.stop()}}),n,this)})))}},{key:"createPollListQuery",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:10;return new Xi(this._iid,{channelUrl:this.url,channelType:this.channelType,limit:e})}},{key:"createPollVoterListQuery",value:function(e,t){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:20;return new to(this._iid,{channelUrl:this.url,channelType:this.channelType,pollId:e,pollOptionId:t,limit:n})}}],[{key:"payloadify",value:function(e){return ee(Object.assign(Object.assign({},p(o(u),"payloadify",this).call(this,e)),{channel_url:e.url,name:e.name,cover_url:e.coverUrl,custom_type:e.customType,data:e.data,freeze:e.isFrozen,is_ephemeral:e.isEphemeral,created_by:La.payloadify(e.creator),created_at:e.createdAt/1e3}))}}]),u}(Ca),Vh=null,Bh=function(){function n(e,a,s){var i=this;r(this,n),this._storeInitialized=!1,this._fcmPushToken=null,this._apnsPushToken=null,this._iid=e,this.options=a;var o=ns.of(e),u=o.sdkState,c=o.cacheContext,l=o.dispatcher,h=o.sessionManager,d=o.requestQueue,f=o.logger,p=o.userEventHandlers,v=o.appStateToggleEnabled;this._onlineDetector=new Wo({logger:f,connectionDelegate:{reconnect:function(){var t=ns.of(e),n=t.sdkState,r=t.connectionManager,a=t.sessionManager;a.auth.hasSession?"foreground"===n.appState&&r.resetAndReconnect():r.connect(a.auth.authToken)},disconnect:function(){ns.of(e).connectionManager.disconnect()}}});var _=new Jo(e,{localCacheEnabled:c.localCacheEnabled,dispatcher:l,sdkState:u,logger:f});s.forEach((function(t){t.init(e,{sdkState:u,cacheContext:c,dispatcher:l,sessionManager:h,requestQueue:d,logger:f,onlineDetector:i._onlineDetector}),i[t.name]=t})),this._appStateChangeDetector=new Ko({isEnabled:v}),this._appStateChangeDetector.on("resume",(function(){f.debug("the page resumes from freeze"),i.setForegroundState()})).on("pause",(function(){f.debug("the page freezes"),i.setBackgroundState()})),l.on((function(n){if(n instanceof Dr){if(n.stateType===Nr.CONNECTED)_.processNonAutoResendRegisteredPendingMessages()}else if(n instanceof le){if("USEV"===n.code){var r=n.as(iu).event;if(r.category===Lo.FRIEND_DISCOVERED){var a=$o.getDataAsFriendDiscoveredEvent(e,r).friendDiscoveries;ua((function(){return b(i,void 0,void 0,t().mark((function e(){return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",p.forEach((function(e){e.onFriendsDiscovered(a)})));case 1:case"end":return e.stop()}}),e)})))}))}}}else if(n instanceof Or){var s=ns.of(i._iid).subscribedUnreadMessageCount,o=!1,l=n.ts;if("number"==typeof l&&l>s.ts){if(s.all!==n.all&&(o=!0),s.all=n.all>=0?n.all:0,n.customTypes)for(var h in n.customTypes)s.customTypes[h]!==n.customTypes[h]&&(o=!0),s.customTypes[h]=n.customTypes[h];o=o&&s.ts>0,s.ts=l}o&&ua((function(){return b(i,void 0,void 0,t().mark((function e(){return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",p.forEach((function(e){e.onTotalUnreadMessageCountUpdated(s.all,s.customTypes)})));case 1:case"end":return e.stop()}}),e)})))}))}else n instanceof Da&&c.preference.set(i._getUserProfileCacheKey(u.userId),Pa.payloadify(n.userProfile))}))}return s(n,[{key:"appId",get:function(){return ns.of(this._iid).sdkState.appId}},{key:"appInfo",get:function(){return ns.of(this._iid).appInfo}},{key:"appVersion",get:function(){var e;return null!==(e=ns.of(this._iid).sdkState.appVersion)&&void 0!==e?e:""}},{key:"debugMode",get:function(){return ns.of(this._iid).debugMode}},{key:"logLevel",get:function(){return ns.of(this._iid).logger.level},set:function(e){ns.of(this._iid).logger.level=e}},{key:"isCacheEnabled",get:function(){return ns.of(this._iid).cacheContext.localCacheEnabled}},{key:"localCacheConfig",get:function(){var e=ns.of(this._iid).cacheContext;return e.localCacheEnabled?e.localCacheConfig:null}},{key:"ekey",get:function(){return ns.of(this._iid).sessionManager.ekey}},{key:"currentUser",get:function(){var e;return null!==(e=ns.of(this._iid).sessionManager.currentUser)&&void 0!==e?e:null}},{key:"connectionState",get:function(){var t=ns.of(this._iid).connectionManager;return t.isConnected?e.ConnectionState.OPEN:t.isConnecting?e.ConnectionState.CONNECTING:e.ConnectionState.CLOSED}},{key:"lastConnectedAt",get:function(){var e=ns.of(this._iid),t=e.connectedAt;return e.connectionManager.isConnected?t:0}},{key:"fcmPushToken",get:function(){return this._fcmPushToken}},{key:"apnsPushToken",get:function(){return this._apnsPushToken}},{key:"_getCurrentPreferenceVersion",value:function(){return 1}},{key:"_getPreferenceCacheKey",value:function(e){return"sendbird@".concat(this.appId,"/").concat(e,".pref")}},{key:"_getUserProfileCacheKey",value:function(e){return"sendbird@".concat(this.appId,"/").concat(e,".profile")}},{key:"getMemoryStoreForDebugging",value:function(){var e=ns.of(this._iid),t=e.debugMode,n=e.cacheContext;if(t)return n.store instanceof $c?n.store:null;throw M.debugModeRequired}},{key:"addExtension",value:function(e,t){var n=ns.of(this._iid).sdkState;["sb_uikit","sb_syncmanager","device-os-platform"].indexOf(e)>-1&&(n.extensions[e]=t)}},{key:"setOnlineListener",value:function(e){this._onlineDetector.setOnlineListener(e)}},{key:"setOfflineListener",value:function(e){this._onlineDetector.setOfflineListener(e)}},{key:"_safeInitializeStore",value:function(e){return b(this,void 0,void 0,t().mark((function n(){var r,a;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return r=ns.of(this._iid),a=r.cacheContext,t.prev=1,t.next=4,a.store.init(e);case 4:this._storeInitialized=!0,t.next=12;break;case 7:return t.prev=7,t.t0=t.catch(1),a.store=new $c,t.next=12,this._safeInitializeStore(e);case 12:case"end":return t.stop()}}),n,this,[[1,7]])})))}},{key:"initializeCache",value:function(e){return b(this,void 0,void 0,t().mark((function n(){var r,a,s,i,o,u,c,l;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(r=ns.of(this._iid),a=r.sdkState,s=r.cacheContext,i=r.connectionManager,o=r.dispatcher,u=r.logger,a.userId&&a.userId===e){t.next=29;break}return t.next=4,i.logout();case 4:if(c="sendbird@".concat(a.appId,"/").concat(e,".db"),!s.localCacheEnabled){t.next=26;break}if(t.prev=6,s.nestdb&&s.nestdb.state!==qc.CLOSED&&s.nestdb.name===c){t.next=14;break}return(l=s.nestdb=new ul({name:"sendbird@".concat(a.appId,"/").concat(e,".db"),version:2,store:s.store})).on("upgrade",zo(l,s.store)),t.next=12,l.open();case 12:this._storeInitialized=!0,o.dispatch(new eu(this._iid,{userId:e}));case 14:a.userId=e,t.next=24;break;case 17:return t.prev=17,t.t0=t.catch(6),u.warn("Nest DB Open Failed. ",t.t0),t.next=22,this._safeInitializeStore(c);case 22:throw a.userId=e,M.databaseError;case 24:t.next=29;break;case 26:return t.next=28,this._safeInitializeStore(c);case 28:a.userId=e;case 29:case"end":return t.stop()}}),n,this,[[6,17]])})))}},{key:"getCacheDataSize",value:function(){return b(this,void 0,void 0,t().mark((function e(){var n,r;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(n=ns.of(this._iid),!(r=n.cacheContext).localCacheEnabled||!r.nestdb){e.next=5;break}return e.next=4,r.nestdb.estimateUsage();case 4:return e.abrupt("return",e.sent);case 5:return e.abrupt("return",0);case 6:case"end":return e.stop()}}),e,this)})))}},{key:"clearCachedData",value:function(){return b(this,void 0,void 0,t().mark((function e(){var n,r;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(n=ns.of(this._iid),!(r=n.cacheContext).localCacheEnabled){e.next=5;break}if(!r.nestdb){e.next=5;break}return e.next=5,r.nestdb.clear();case 5:if(!this._storeInitialized){e.next=8;break}return e.next=8,r.preference.clear();case 8:case"end":return e.stop()}}),e,this)})))}},{key:"clearCachedMessages",value:function(e){return b(this,void 0,void 0,t().mark((function n(){var r,a,s=this;return t().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:if(Ua(F("string",e)).throw(M.invalidParameters),r=Bo.of(this._iid),a=jo.of(this._iid),!r||!a){n.next=6;break}return n.next=6,Promise.all(e.map((function(e){return b(s,void 0,void 0,t().mark((function n(){return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,r.removeMessagesOfChannel(e);case 2:return t.next=4,a.removeMessagesOfChannel(e);case 4:case"end":return t.stop()}}),n)})))})));case 6:case"end":return n.stop()}}),n,this)})))}},{key:"connect",value:function(e){var n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null;return b(this,void 0,void 0,t().mark((function r(){var a,s,i,o,u,c,l,h,d;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return Ua(L("string",e)&&L("string",n,!0)).throw(M.invalidParameters),a=ns.of(this._iid),s=a.sdkState,i=a.cacheContext,o=a.connectionManager,u=a.statLogCollector,this._onlineDetector.start(),this._appStateChangeDetector.start(),t.prev=4,t.next=7,this.initializeCache(e);case 7:c=ns.of(this._iid),c.dispatcher.dispatch(new su),t.next=16;break;case 11:t.prev=11,t.t0=t.catch(4),l=ns.of(this._iid),h=l.logger,i.localCacheEnabled=!1,h.warn("Cache initialization failed - cache is not available.");case 16:return t.next=18,i.preference.init(this._getPreferenceCacheKey(e),this._getCurrentPreferenceVersion());case 18:return t.next=20,i.preference.get(this._getUserProfileCacheKey(e));case 20:return(d=t.sent)&&new Pa(this._iid,d).apply(),t.next=24,u.init("sendbird@".concat(s.appId,"/").concat(e,".statlog"));case 24:return t.next=26,o.connect(n);case 26:return t.abrupt("return",this.currentUser);case 27:case"end":return t.stop()}}),r,this,[[4,11]])})))}},{key:"reconnect",value:function(){var e=ns.of(this._iid),t=e.connectionManager,n=e.sdkState,r=e.sessionManager.auth.hasSession;return r&&(this._appStateChangeDetector.start(),this._onlineDetector.start(),t.resetAndReconnect().then((function(){n.appState="foreground"})).catch((function(){}))),r}},{key:"disconnect",value:function(){return b(this,void 0,void 0,t().mark((function e(){var n,r,a;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n=ns.of(this._iid),r=n.connectionManager,a=n.requestQueue,this._appStateChangeDetector.stop(),this._onlineDetector.stop(),a.cancelAll(),e.next=6,r.logout();case 6:return e.next=8,this.clearCachedData();case 8:case"end":return e.stop()}}),e,this)})))}},{key:"disconnectWebSocket",value:function(){return b(this,void 0,void 0,t().mark((function e(){var n,r,a;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n=ns.of(this._iid),r=n.connectionManager,a=n.requestQueue,this._appStateChangeDetector.stop(),this._onlineDetector.stop(),a.cancelAll(),e.next=6,r.disconnectWebSocket();case 6:case"end":return e.stop()}}),e,this)})))}},{key:"setBackgroundState",value:function(){var e=ns.of(this._iid),t=e.connectionManager,n=e.sdkState,r=e.logger;"foreground"===n.appState&&(n.appState="background",r.debug("going background state"),t.background())}},{key:"setForegroundState",value:function(){var e=ns.of(this._iid),t=e.connectionManager,n=e.sdkState,r=e.logger;"background"===n.appState&&(n.appState="foreground",r.debug("going foreground state"),t.resetAndReconnect())}},{key:"setSessionHandler",value:function(e){Ua(e instanceof so).throw(M.invalidParameters),ns.of(this._iid).sessionManager.handler=e}},{key:"addUserEventHandler",value:function(e,t){Ua(L("string",e)&&t instanceof oo).throw(M.invalidParameters),ns.of(this._iid).userEventHandlers.set(e,t)}},{key:"removeUserEventHandler",value:function(e){ns.of(this._iid).userEventHandlers.delete(e)}},{key:"removeAllUserEventHandler",value:function(){ns.of(this._iid).userEventHandlers.clear()}},{key:"addConnectionHandler",value:function(e,t){Ua(L("string",e)&&t instanceof io).throw(M.invalidParameters),ns.of(this._iid).connectionHandlers.set(e,t)}},{key:"removeConnectionHandler",value:function(e){ns.of(this._iid).connectionHandlers.delete(e)}},{key:"removeAllConnectionHandler",value:function(){ns.of(this._iid).connectionHandlers.clear()}},{key:"createApplicationUserListQuery",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return new oc(this._iid,e)}},{key:"createBlockedUserListQuery",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return new lc(this._iid,e)}},{key:"createFriendListQuery",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return new fc(this._iid,e)}},{key:"createMessageSearchQuery",value:function(e){return new Ti(this._iid,e)}},{key:"createPollListQuery",value:function(e){return new Xi(this._iid,Object.assign({},e))}},{key:"createPollVoterListQuery",value:function(e){return new to(this._iid,Object.assign({},e))}},{key:"buildUserFromSerializedData",value:function(e){var t=Oa(e);return new La(this._iid,La.payloadify(t))}},{key:"updateCurrentUserInfo",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return b(this,void 0,void 0,t().mark((function n(){var r,a,s,i,o,u,c,l;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(r=Object.assign(Object.assign({},ro),e),Ua(ao(r)).throw(M.invalidParameters),!this.currentUser){t.next=13;break}return a=ns.of(this._iid),s=a.sdkState,i=a.requestQueue,o=new ou(Object.assign({userId:s.userId},r)),t.next=7,i.send(o);case 7:return u=t.sent,c=u.as(uu),l=c.user,this.currentUser&&(r.nickname&&(this.currentUser.nickname=l.nickname),(r.profileUrl||r.profileImage)&&(this.currentUser.plainProfileUrl=l.profileUrl)),t.abrupt("return",l);case 13:throw M.connectionRequired;case 14:case"end":return t.stop()}}),n,this)})))}},{key:"updateCurrentUserInfoWithPreferredLanguages",value:function(e){return b(this,void 0,void 0,t().mark((function n(){var r,a,s,i,o,u,c;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(Ua(F("string",e)).throw(M.invalidParameters),!this.currentUser){t.next=12;break}return r=ns.of(this._iid),a=r.sdkState,s=r.requestQueue,i=new ou({userId:a.userId,preferredLanguages:e}),t.next=6,s.send(i);case 6:return o=t.sent,u=o.as(uu),c=u.user,this.currentUser&&(this.currentUser.preferredLanguages=c.preferredLanguages),t.abrupt("return",c);case 12:throw M.connectionRequired;case 13:case"end":return t.stop()}}),n,this)})))}},{key:"registerFCMPushTokenForCurrentUser",value:function(n){return b(this,void 0,void 0,t().mark((function r(){var a,s,i,o,u,c=this;return t().wrap((function(r){for(;;)switch(r.prev=r.next){case 0:if(Ua(L("string",n)).throw(M.invalidParameters),!this.currentUser){r.next=20;break}if(r.prev=2,a=ns.of(this._iid),s=a.sessionManager,i=a.sdkState,o=a.requestQueue,!s.hasDeviceToken(e.PushTokenType.FCM,n)){r.next=6;break}return r.abrupt("return",e.PushTokenRegistrationState.SUCCESS);case 6:return u=new lu({userId:i.userId,token:n}),r.next=9,o.send(u);case 9:return r.next=11,ca((function(){return b(c,void 0,void 0,t().mark((function r(){return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return s.setDeviceToken(e.PushTokenType.FCM,n),t.next=3,s.saveDeviceToken();case 3:case"end":return t.stop()}}),r)})))}));case 11:return this._fcmPushToken="",r.abrupt("return",e.PushTokenRegistrationState.SUCCESS);case 15:return r.prev=15,r.t0=r.catch(2),r.abrupt("return",e.PushTokenRegistrationState.ERROR);case 18:r.next=22;break;case 20:return this._fcmPushToken=n,r.abrupt("return",e.PushTokenRegistrationState.PENDING);case 22:case"end":return r.stop()}}),r,this,[[2,15]])})))}},{key:"unregisterFCMPushTokenForCurrentUser",value:function(n){return b(this,void 0,void 0,t().mark((function r(){var a,s,i,o,u,c,l,h=this;return t().wrap((function(r){for(;;)switch(r.prev=r.next){case 0:if(Ua(L("string",n)).throw(M.invalidParameters),!this.currentUser){r.next=20;break}return r.prev=2,a=ns.of(this._iid),s=a.sessionManager,i=a.sdkState,o=a.requestQueue,u=new du({userId:i.userId,token:n}),r.next=7,o.send(u);case 7:return c=r.sent,l=c.lastDeletedAt,r.next=11,ca((function(){return b(h,void 0,void 0,t().mark((function r(){return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return s.unsetDeviceToken(e.PushTokenType.FCM,n),s.setDeviceTokenDeletedAt(l),t.next=4,s.saveDeviceToken();case 4:case"end":return t.stop()}}),r)})))}));case 11:return this._fcmPushToken="",r.abrupt("return",e.PushTokenRegistrationState.SUCCESS);case 15:return r.prev=15,r.t0=r.catch(2),r.abrupt("return",e.PushTokenRegistrationState.ERROR);case 18:r.next=22;break;case 20:return this._fcmPushToken=n,r.abrupt("return",e.PushTokenRegistrationState.PENDING);case 22:case"end":return r.stop()}}),r,this,[[2,15]])})))}},{key:"unregisterFCMPushTokenAllForCurrentUser",value:function(){return b(this,void 0,void 0,t().mark((function n(){var r,a,s,i,o,u,c,l=this;return t().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:if(!this.currentUser){n.next=9;break}return r=ns.of(this._iid),a=r.sessionManager,s=r.sdkState,i=r.requestQueue,o=new pu({userId:s.userId}),n.next=5,i.send(o);case 5:return u=n.sent,c=u.lastDeletedAt,n.next=9,ca((function(){return b(l,void 0,void 0,t().mark((function n(){return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return a.unsetDeviceTokens(e.PushTokenType.FCM),a.setDeviceTokenDeletedAt(c),t.next=4,a.saveDeviceToken();case 4:case"end":return t.stop()}}),n)})))}));case 9:case"end":return n.stop()}}),n,this)})))}},{key:"registerAPNSPushTokenForCurrentUser",value:function(n){return b(this,void 0,void 0,t().mark((function r(){var a,s,i,o,u,c=this;return t().wrap((function(r){for(;;)switch(r.prev=r.next){case 0:if(Ua(L("string",n)).throw(M.invalidParameters),!this.currentUser){r.next=20;break}if(r.prev=2,a=ns.of(this._iid),s=a.sessionManager,i=a.sdkState,o=a.requestQueue,!s.hasDeviceToken(e.PushTokenType.APNS,n)){r.next=6;break}return r.abrupt("return",e.PushTokenRegistrationState.SUCCESS);case 6:return u=new cu({userId:i.userId,token:n}),r.next=9,o.send(u);case 9:return r.next=11,ca((function(){return b(c,void 0,void 0,t().mark((function r(){return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return s.setDeviceToken(e.PushTokenType.APNS,n),t.next=3,s.saveDeviceToken();case 3:case"end":return t.stop()}}),r)})))}));case 11:return this._apnsPushToken="",r.abrupt("return",e.PushTokenRegistrationState.SUCCESS);case 15:return r.prev=15,r.t0=r.catch(2),r.abrupt("return",e.PushTokenRegistrationState.ERROR);case 18:r.next=22;break;case 20:return this._apnsPushToken=n,r.abrupt("return",e.PushTokenRegistrationState.PENDING);case 22:case"end":return r.stop()}}),r,this,[[2,15]])})))}},{key:"unregisterAPNSPushTokenForCurrentUser",value:function(n){return b(this,void 0,void 0,t().mark((function r(){var a,s,i,o,u,c,l,h=this;return t().wrap((function(r){for(;;)switch(r.prev=r.next){case 0:if(Ua(L("string",n)).throw(M.invalidParameters),!this.currentUser){r.next=20;break}return r.prev=2,a=ns.of(this._iid),s=a.sessionManager,i=a.sdkState,o=a.requestQueue,u=new hu({userId:i.userId,token:n}),r.next=7,o.send(u);case 7:return c=r.sent,l=c.lastDeletedAt,r.next=11,ca((function(){return b(h,void 0,void 0,t().mark((function r(){return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return s.unsetDeviceToken(e.PushTokenType.APNS,n),s.setDeviceTokenDeletedAt(l),t.next=4,s.saveDeviceToken();case 4:case"end":return t.stop()}}),r)})))}));case 11:return this._apnsPushToken="",r.abrupt("return",e.PushTokenRegistrationState.SUCCESS);case 15:return r.prev=15,r.t0=r.catch(2),r.abrupt("return",e.PushTokenRegistrationState.ERROR);case 18:r.next=22;break;case 20:return this._apnsPushToken=n,r.abrupt("return",e.PushTokenRegistrationState.PENDING);case 22:case"end":return r.stop()}}),r,this,[[2,15]])})))}},{key:"unregisterAPNSPushTokenAllForCurrentUser",value:function(){return b(this,void 0,void 0,t().mark((function n(){var r,a,s,i,o,u,c,l=this;return t().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:if(!this.currentUser){n.next=9;break}return r=ns.of(this._iid),a=r.sessionManager,s=r.sdkState,i=r.requestQueue,o=new fu({userId:s.userId}),n.next=5,i.send(o);case 5:return u=n.sent,c=u.lastDeletedAt,n.next=9,ca((function(){return b(l,void 0,void 0,t().mark((function n(){return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return a.unsetDeviceTokens(e.PushTokenType.APNS),a.setDeviceTokenDeletedAt(c),t.next=4,a.saveDeviceToken();case 4:case"end":return t.stop()}}),n)})))}));case 9:case"end":return n.stop()}}),n,this)})))}},{key:"getChannelInvitationPreference",value:function(){return b(this,void 0,void 0,t().mark((function e(){var n,r,a,s,i,o,u;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n=ns.of(this._iid),r=n.sdkState,a=n.requestQueue,s=new mu({userId:r.userId}),e.next=4,a.send(s);case 4:return i=e.sent,o=i.as(gu),u=o.autoAccept,e.abrupt("return",{autoAccept:u});case 7:case"end":return e.stop()}}),e,this)})))}},{key:"setChannelInvitationPreference",value:function(e){return b(this,void 0,void 0,t().mark((function n(){var r,a,s,i,o,u,c;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return Ua(L("boolean",e)).throw(M.invalidParameters),r=ns.of(this._iid),a=r.sdkState,s=r.requestQueue,i=new yu({userId:a.userId,willAutoAccept:e}),t.next=5,s.send(i);case 5:return o=t.sent,u=o.as(ku),c=u.autoAccept,t.abrupt("return",{autoAccept:c});case 8:case"end":return t.stop()}}),n,this)})))}},{key:"getDoNotDisturb",value:function(){return b(this,void 0,void 0,t().mark((function e(){var n,r,a,s,i,o,u;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n=ns.of(this._iid),r=n.sdkState,a=n.requestQueue,s=new bu({userId:r.userId}),e.next=4,a.send(s);case 4:return i=e.sent,o=i.as(Eu),u=o.preference,e.abrupt("return",u);case 7:case"end":return e.stop()}}),e,this)})))}},{key:"setDoNotDisturb",value:function(e){var n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:0,a=arguments.length>3&&void 0!==arguments[3]?arguments[3]:0,s=arguments.length>4&&void 0!==arguments[4]?arguments[4]:0,i=arguments.length>5&&void 0!==arguments[5]?arguments[5]:"";return b(this,void 0,void 0,t().mark((function o(){var u,c,l,h,d,f,p;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return Ua(L("boolean",e)&&L("number",n)&&L("number",r)&&L("number",a)&&L("number",s)&&L("string",i)).throw(M.invalidParameters),u=ns.of(this._iid),c=u.sdkState,l=u.requestQueue,h=new wu({userId:c.userId,doNotDisturbOn:e,startHour:n,startMin:r,endHour:a,endMin:s,timezone:i}),t.next=5,l.send(h);case 5:return d=t.sent,f=d.as(Cu),p=f.preference,t.abrupt("return",p);case 8:case"end":return t.stop()}}),o,this)})))}},{key:"getSnoozePeriod",value:function(){return b(this,void 0,void 0,t().mark((function e(){var n,r,a,s,i,o,u;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n=ns.of(this._iid),r=n.sdkState,a=n.requestQueue,s=new xu({userId:r.userId}),e.next=4,a.send(s);case 4:return i=e.sent,o=i.as(Tu),u=o.snoozePeriod,e.abrupt("return",u);case 7:case"end":return e.stop()}}),e,this)})))}},{key:"setSnoozePeriod",value:function(e){var n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:0;return b(this,void 0,void 0,t().mark((function a(){var s,i,o,u,c,l,h;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return Ua(L("boolean",e)&&L("number",n)&&L("number",r)).throw(M.invalidParameters),s=ns.of(this._iid),i=s.sdkState,o=s.requestQueue,u=new Su({userId:i.userId,snoozeOn:e,startTs:n,endTs:r}),t.next=5,o.send(u);case 5:return c=t.sent,l=c.as(Iu),h=l.snoozePeriod,t.abrupt("return",h);case 8:case"end":return t.stop()}}),a,this)})))}},{key:"getMyPushTokensByToken",value:function(n,r){return b(this,void 0,void 0,t().mark((function a(){var s,i,o,u,c,l,h,d,f,p,v;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return Ua(L("string",n)&&D(e.PushTokenType,r)).throw(M.invalidParameters),s=ns.of(this._iid),i=s.sdkState,o=s.requestQueue,u=s.sessionManager,c=new vu({userId:i.userId,type:r,token:n}),t.next=5,o.send(c);case 5:l=t.sent,h=l.as(_u),d=h.pushTokens,f=y(d.deviceTokens);try{for(f.s();!(p=f.n()).done;)v=p.value,u.setDeviceToken(d.type,v)}catch(e){f.e(e)}finally{f.f()}return t.next=11,u.saveDeviceToken();case 11:return t.abrupt("return",d);case 12:case"end":return t.stop()}}),a,this)})))}},{key:"getPushTriggerOption",value:function(){return b(this,void 0,void 0,t().mark((function e(){var n,r,a,s,i;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n=ns.of(this._iid),r=n.sdkState,a=n.requestQueue,s=new Mu({userId:r.userId}),e.next=4,a.send(s);case 4:return i=e.sent,e.abrupt("return",i.as(Ou).pushTriggerOption);case 6:case"end":return e.stop()}}),e,this)})))}},{key:"setPushTriggerOption",value:function(n){return b(this,void 0,void 0,t().mark((function r(){var a,s,i,o,u;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return Ua(D(e.PushTriggerOption,n)).throw(M.invalidParameters),a=ns.of(this._iid),s=a.sdkState,i=a.requestQueue,o=new Uu({userId:s.userId,pushTriggerOption:n}),t.next=5,i.send(o);case 5:return u=t.sent,t.abrupt("return",u.as(Ru).pushTriggerOption);case 7:case"end":return t.stop()}}),r,this)})))}},{key:"getPushTemplate",value:function(){return b(this,void 0,void 0,t().mark((function e(){var n,r,a,s,i;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n=ns.of(this._iid),r=n.sdkState,a=n.requestQueue,s=new Lu({userId:r.userId}),e.next=4,a.send(s);case 4:return i=e.sent,e.abrupt("return",i.as(Du).name);case 6:case"end":return e.stop()}}),e,this)})))}},{key:"setPushTemplate",value:function(n){return b(this,void 0,void 0,t().mark((function r(){var a,s,i,o,u;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return Ua(D(e.PushTemplate,n)).throw(M.invalidParameters),a=ns.of(this._iid),s=a.sdkState,i=a.requestQueue,o=new Pu({userId:s.userId,templateName:n}),t.next=5,i.send(o);case 5:return u=t.sent,t.abrupt("return",u.as(Fu).name);case 7:case"end":return t.stop()}}),r,this)})))}},{key:"blockUser",value:function(e){return b(this,void 0,void 0,t().mark((function n(){var r,a,s,i;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return Ua(e instanceof La||L("string",e)).throw(M.invalidParameters),r=ns.of(this._iid),a=r.sdkState,s=r.requestQueue,i=new Nu({userId:a.userId,blockedUserId:e instanceof La?e.userId:e}),t.next=5,s.send(i);case 5:case"end":return t.stop()}}),n,this)})))}},{key:"blockUserWithUserId",value:function(e){return b(this,void 0,void 0,t().mark((function n(){return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.abrupt("return",this.blockUser(e));case 1:case"end":return t.stop()}}),n,this)})))}},{key:"unblockUser",value:function(e){return b(this,void 0,void 0,t().mark((function n(){var r,a,s,i;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return Ua(e instanceof La||L("string",e)).throw(M.invalidParameters),r=ns.of(this._iid),a=r.sdkState,s=r.requestQueue,i=new Au({userId:a.userId,unblockedUserId:e instanceof La?e.userId:e}),t.next=5,s.send(i);case 5:case"end":return t.stop()}}),n,this)})))}},{key:"unblockUserWithUserId",value:function(e){return b(this,void 0,void 0,t().mark((function n(){return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.abrupt("return",this.unblockUser(e));case 1:case"end":return t.stop()}}),n,this)})))}},{key:"getFriendChangeLogsByToken",value:function(e){return b(this,void 0,void 0,t().mark((function n(){var r,a,s,i,o,u,c;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return Ua(L("string",e)).throw(M.invalidParameters),r=ns.of(this._iid),a=r.sdkState,s=r.requestQueue,i=new Gu({userId:a.userId,token:e}),t.next=5,s.send(i);case 5:return o=t.sent,u=o.as(Hu),c=u.changelogs,t.abrupt("return",c);case 8:case"end":return t.stop()}}),n,this)})))}},{key:"getAllowFriendDiscovery",value:function(){return b(this,void 0,void 0,t().mark((function e(){var n,r,a,s,i,o,u;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n=ns.of(this._iid),r=n.sdkState,a=n.requestQueue,s=new Ku({userId:r.userId}),e.next=4,a.send(s);case 4:return i=e.sent,o=i.as(Wu),u=o.allowFriendDiscovery,e.abrupt("return",u);case 7:case"end":return e.stop()}}),e,this)})))}},{key:"setAllowFriendDiscovery",value:function(e){return b(this,void 0,void 0,t().mark((function n(){var r,a,s,i;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return Ua(L("boolean",e)).throw(M.invalidParameters),r=ns.of(this._iid),a=r.sdkState,s=r.requestQueue,i=new Yu({userId:a.userId,allowFriendDiscovery:e}),t.next=5,s.send(i);case 5:return t.abrupt("return",e);case 6:case"end":return t.stop()}}),n,this)})))}},{key:"uploadFriendDiscoveries",value:function(e){return b(this,void 0,void 0,t().mark((function n(){var r,a,s,i,o,u,c;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return r=ns.of(this._iid),a=r.sdkState,s=r.requestQueue,i=new qu({userId:a.userId,discoveries:e}),t.next=4,s.send(i);case 4:return o=t.sent,u=o.as(ju),c=u.friendDiscoveryRequestId,t.abrupt("return",c);case 7:case"end":return t.stop()}}),n,this)})))}},{key:"deleteFriendDiscovery",value:function(e){return b(this,void 0,void 0,t().mark((function n(){return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.abrupt("return",this.deleteFriendDiscoveries([e]));case 1:case"end":return t.stop()}}),n,this)})))}},{key:"deleteFriendDiscoveries",value:function(e){return b(this,void 0,void 0,t().mark((function n(){var r,a,s,i;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return Ua(F("string",e)).throw(M.invalidParameters),r=ns.of(this._iid),a=r.sdkState,s=r.requestQueue,i=new zu({userId:a.userId,discoveryKeys:e}),t.next=5,s.send(i);case 5:case"end":return t.stop()}}),n,this)})))}},{key:"addFriends",value:function(e){return b(this,void 0,void 0,t().mark((function n(){var r,a,s,i,o,u,c;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return Ua(F("string",e)).throw(M.invalidParameters),r=ns.of(this._iid),a=r.sdkState,s=r.requestQueue,i=new Vu({userId:a.userId,userIds:e}),t.next=5,s.send(i);case 5:return o=t.sent,u=o.as(Bu),c=u.users,t.abrupt("return",c);case 8:case"end":return t.stop()}}),n,this)})))}},{key:"deleteFriend",value:function(e){return b(this,void 0,void 0,t().mark((function n(){return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.abrupt("return",this.deleteFriends([e]));case 1:case"end":return t.stop()}}),n,this)})))}},{key:"deleteFriends",value:function(e){return b(this,void 0,void 0,t().mark((function n(){var r,a,s,i;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return Ua(F("string",e)).throw(M.invalidParameters),r=ns.of(this._iid),a=r.sdkState,s=r.requestQueue,i=new Qu({userId:a.userId,userIds:e}),t.next=5,s.send(i);case 5:case"end":return t.stop()}}),n,this)})))}},{key:"getAllEmoji",value:function(){return b(this,void 0,void 0,t().mark((function e(){var n,r,a,s,i,o;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n=ns.of(this._iid),r=n.requestQueue,a=new $u,e.next=4,r.send(a);case 4:return s=e.sent,i=s.as(ec),o=i.emojiContainer,e.abrupt("return",o);case 7:case"end":return e.stop()}}),e,this)})))}},{key:"getEmojiCategory",value:function(e){return b(this,void 0,void 0,t().mark((function n(){var r,a,s,i,o,u;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return r=ns.of(this._iid),a=r.requestQueue,s=new tc({categoryId:e}),t.next=4,a.send(s);case 4:return i=t.sent,o=i.as(nc),u=o.emojiCategory,t.abrupt("return",u);case 7:case"end":return t.stop()}}),n,this)})))}},{key:"getEmoji",value:function(e){return b(this,void 0,void 0,t().mark((function n(){var r,a,s,i,o,u;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return r=ns.of(this._iid),a=r.requestQueue,s=new rc({key:e}),t.next=4,a.send(s);case 4:return i=t.sent,o=i.as(ac),u=o.emoji,t.abrupt("return",u);case 7:case"end":return t.stop()}}),n,this)})))}}],[{key:"init",value:function(e){var t=e.appId,r=e.appVersion,a=void 0===r?null:r,s=e.modules,i=void 0===s?[]:s,o=e.options,u=void 0===o?new q:o,c=e.debugMode,l=void 0!==c&&c,h=e.customApiHost,d=e.customWebSocketHost,f=e.newInstance,p=void 0!==f&&f,v=e.logLevel,m=e.localCacheEnabled,g=void 0!==m&&m,y=e.localCacheConfig,k=void 0===y?new K:y,b=e.localCacheEncryption,E=e.useAsyncStorageStore,w=void 0===E?null:E,C=e.appStateToggleEnabled,x=void 0===C||C;if(!Vh||p){var T="su-".concat(Y()),S=null!=b?b:{encrypt:function(e){return e},decrypt:function(e){return e}},I=new $c({encryption:S});l||(I=ue()?w?new nl({AsyncStorage:w,encryption:S}):new $c({encryption:S}):new tl({encryption:S})),new ns(T,{appId:t,appVersion:a,options:u,apiHost:null!=h?h:"https://api-".concat(t,".sendbird.com"),websocketHost:null!=d?d:"wss://ws-".concat(t,".sendbird.com"),store:I,encryption:S,logLevel:v,localCacheEnabled:g,localCacheConfig:k,debugMode:l,appStateToggleEnabled:x});var N=[new Mi,new no],A=new n(T,u,[].concat(_(i),N));return Vh||(Vh=A),A}return Vh}},{key:"instance",get:function(){return Vh}},{key:"version",get:function(){return w}}]),n}();e.MemberState=void 0,(Il=e.MemberState||(e.MemberState={})).NONE="none",Il.JOINED="joined",Il.INVITED="invited",Il.LEFT="left";var Qh,Kh,Wh,Yh,Zh,Jh,Xh,$h,ed=function(t){i(a,t);var n=f(a);function a(t,s){var i;return r(this,a),(i=n.call(this,t,s)).state=null,i.role=null,i.isMuted=!1,i.isBlockedByMe=!1,i.isBlockingMe=!1,i.state=D(e.MemberState,s.state)?s.state:null,i.role=D(e.Role,s.role)?s.role:null,s.hasOwnProperty("is_muted")&&(i.isMuted=s.is_muted),s.hasOwnProperty("is_blocked_by_me")&&(i.isBlockedByMe=s.is_blocked_by_me),s.hasOwnProperty("is_blocking_me")&&(i.isBlockingMe=s.is_blocking_me),i}return s(a,null,[{key:"payloadify",value:function(e){return e?ee(Object.assign(Object.assign({},p(o(a),"payloadify",this).call(this,e)),{state:e.state,role:e.role,is_muted:e.isMuted,is_blocked_by_me:e.isBlockedByMe,is_blocking_me:e.isBlockingMe})):null}}]),a}(hl),td=function(t){i(a,t);var n=f(a);function a(t,s){var i,o,u;return r(this,a),(i=n.call(this,t)).channelUrl=null!==(o=s.channel_url)&&void 0!==o?o:"",i.channelType=null!==(u=s.channel_type)&&void 0!==u?u:e.ChannelType.GROUP,i.reader=new La(i._iid,s.user),i.readAt=s.ts,i}return s(a)}(Ca);e.PublicChannelFilter=void 0,(Qh=e.PublicChannelFilter||(e.PublicChannelFilter={})).ALL="all",Qh.PUBLIC="public",Qh.PRIVATE="private",e.MyMemberStateFilter=void 0,(Kh=e.MyMemberStateFilter||(e.MyMemberStateFilter={})).ALL="all",Kh.JOINED="joined_only",Kh.INVITED="invited_only",Kh.INVITED_BY_FRIEND="invited_by_friend",Kh.INVITED_BY_NON_FRIEND="invited_by_non_friend",e.SuperChannelFilter=void 0,(Wh=e.SuperChannelFilter||(e.SuperChannelFilter={})).ALL="all",Wh.SUPER="super",Wh.NON_SUPER="nonsuper",Wh.BROADCAST_ONLY="broadcast_only",Wh.EXCLUSIVE_ONLY="exclusive_only",e.UnreadChannelFilter=void 0,(Yh=e.UnreadChannelFilter||(e.UnreadChannelFilter={})).ALL="all",Yh.UNREAD_MESSAGE="unread_message",e.HiddenChannelFilter=void 0,(Zh=e.HiddenChannelFilter||(e.HiddenChannelFilter={})).ALL="all",Zh.UNHIDDEN="unhidden_only",Zh.HIDDEN="hidden_only",Zh.HIDDEN_ALLOW_AUTO_UNHIDE="hidden_allow_auto_unhide",Zh.HIDDEN_PREVENT_AUTO_UNHIDE="hidden_prevent_auto_unhide",e.OperatorFilter=void 0,(Jh=e.OperatorFilter||(e.OperatorFilter={})).ALL="all",Jh.OPERATOR="operator",Jh.NONOPERATOR="nonoperator",e.QueryType=void 0,(Xh=e.QueryType||(e.QueryType={})).AND="AND",Xh.OR="OR",e.GroupChannelSearchField=void 0,($h=e.GroupChannelSearchField||(e.GroupChannelSearchField={})).MEMBER_NICKNAME="member_nickname",$h.CHANNEL_NAME="channel_name";var nd,rd=function(){function t(){r(this,t),this._searchFilter=null,this._userIdsFilter=null,this.includeEmpty=!1,this.nicknameContainsFilter=null,this.nicknameStartsWithFilter=null,this.nicknameExactMatchFilter=null,this.channelNameContainsFilter="",this.myMemberStateFilter=e.MyMemberStateFilter.ALL,this.customTypesFilter=null,this.channelUrlsFilter=null,this.superChannelFilter=e.SuperChannelFilter.ALL,this.publicChannelFilter=e.PublicChannelFilter.ALL,this.customTypeStartsWithFilter=null,this.unreadChannelFilter=e.UnreadChannelFilter.ALL,this.hiddenChannelFilter=e.HiddenChannelFilter.UNHIDDEN,this.includeFrozen=!0}return s(t,[{key:"_isFriend",value:function(e){return!!e.friendDiscoveryKey||!!e.friendName}},{key:"searchFilter",get:function(){return this._searchFilter}},{key:"setSearchFilter",value:function(e,t){Array.isArray(e)&&0!==e.length&&"string"==typeof t&&t&&(this._searchFilter={query:t,fields:e})}},{key:"userIdsFilter",get:function(){return this._userIdsFilter}},{key:"setUserIdsFilter",value:function(t,n){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:e.QueryType.AND;this._userIdsFilter={userIds:t,includeMode:n,queryType:r}}},{key:"clone",value:function(){var e=new t;this.searchFilter&&e.setSearchFilter(this.searchFilter.fields,this.searchFilter.query),this.userIdsFilter&&e.setUserIdsFilter(this.userIdsFilter.userIds,this.userIdsFilter.includeMode,this.userIdsFilter.queryType);var n=JSON.parse(JSON.stringify(this));return Object.keys(n).forEach((function(t){e[t]=n[t]})),e}},{key:"match",value:function(t,n){if(this._searchFilter){var r=this._searchFilter,a=r.query,s=r.fields;if(a&&s&&s.length>0&&!s.some((function(n){switch(n){case e.GroupChannelSearchField.CHANNEL_NAME:return t.name.toLowerCase().includes(a.toLowerCase());case e.GroupChannelSearchField.MEMBER_NICKNAME:return t.members.some((function(e){return e.nickname.toLowerCase().includes(a.toLowerCase())}));default:return!0}})))return!1}if(this._userIdsFilter){var i=this._userIdsFilter,o=i.userIds,u=i.includeMode,c=i.queryType,l=t.members.map((function(e){return e.userId}));if(u){if(o.length>0)switch(c){case e.QueryType.AND:if(o.some((function(e){return!l.includes(e)})))return!1;break;case e.QueryType.OR:if(o.every((function(e){return!l.includes(e)})))return!1}}else{if(o.includes(n)||o.push(n),t.members.length>o.length)return!1;if(!function(e,t){if(e===t)return!0;if(null==e||null==t)return!1;if(e.length!==t.length)return!1;for(var n=_(e).sort(),r=_(t).sort(),a=0;a0&&!this.customTypesFilter.includes(t.customType))return!1;if(this.customTypeStartsWithFilter&&!new RegExp("^".concat(this.customTypeStartsWithFilter)).test(t.customType))return!1;if(this.channelNameContainsFilter&&!t.name.toLowerCase().includes(this.channelNameContainsFilter.toLowerCase()))return!1;if(this.nicknameContainsFilter){var h=this.nicknameContainsFilter.toLowerCase();if(!t.members.some((function(e){return e.userId!==n&&e.nickname.toLowerCase().includes(h)})))return!1}if(this.nicknameStartsWithFilter){var d=this.nicknameStartsWithFilter.toLowerCase();if(!t.members.some((function(e){return e.userId!==n&&e.nickname.toLowerCase().startsWith(d)})))return!1}if(this.nicknameExactMatchFilter){var f=this.nicknameExactMatchFilter.toLowerCase();if(!t.members.some((function(e){return e.userId!==n&&e.nickname.toLowerCase()!=f})))return!1}if(this.channelUrlsFilter&&this.channelUrlsFilter.length>0&&!this.channelUrlsFilter.includes(t.url))return!1;if(this.myMemberStateFilter)switch(this.myMemberStateFilter){case e.MyMemberStateFilter.JOINED:if("joined"!==t.myMemberState)return!1;break;case e.MyMemberStateFilter.INVITED:if("invited"!==t.myMemberState)return!1;break;case e.MyMemberStateFilter.INVITED_BY_FRIEND:if("invited"!==t.myMemberState||!this._isFriend(t.inviter))return!1;break;case e.MyMemberStateFilter.INVITED_BY_NON_FRIEND:if("invited"!==t.myMemberState||this._isFriend(t.inviter))return!1}if(this.hiddenChannelFilter)switch(this.hiddenChannelFilter){case e.HiddenChannelFilter.UNHIDDEN:if(t.isHidden||"unhidden"!==t.hiddenState)return!1;break;case e.HiddenChannelFilter.HIDDEN:if(!t.isHidden)return!1;break;case e.HiddenChannelFilter.HIDDEN_ALLOW_AUTO_UNHIDE:if(!t.isHidden||"hidden_allow_auto_unhide"!==t.hiddenState)return!1;break;case e.HiddenChannelFilter.HIDDEN_PREVENT_AUTO_UNHIDE:if(!t.isHidden||"hidden_prevent_auto_unhide"!==t.hiddenState)return!1}if(this.unreadChannelFilter&&this.unreadChannelFilter===e.UnreadChannelFilter.UNREAD_MESSAGE)if(0===t.unreadMessageCount)return!1;if(this.publicChannelFilter)switch(this.publicChannelFilter){case e.PublicChannelFilter.PUBLIC:if(!t.isPublic)return!1;break;case e.PublicChannelFilter.PRIVATE:if(t.isPublic)return!1}if(this.superChannelFilter)switch(this.superChannelFilter){case e.SuperChannelFilter.SUPER:if(!t.isSuper)return!1;break;case e.SuperChannelFilter.NON_SUPER:if(t.isSuper)return!1}return!0}}]),t}(),ad=function(n){i(o,n);var a=f(o);function o(e,t){var n,s=t.sdkState,i=t.cacheContext;return r(this,o),(n=a.call(this,e))._channels=new Map,n._sdkState=s,n._cacheContext=i,n}return s(o,[{key:"collection",get:function(){var e=this._cacheContext.nestdb;return e?e.collection(uo):null}},{key:"localCacheEnabled",get:function(){return this._cacheContext.localCacheEnabled&&!!this.collection}},{key:"_serialize",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0;return Object.assign(Object.assign({},e.serialize()),{lastMessageUpdatedAt:e.lastMessage?e.lastMessage.createdAt:0,syncIndex:t})}},{key:"_deserialize",value:function(e){return wf.of(this._iid).buildGroupChannelFromSerializedData(e)}},{key:"channels",get:function(){return _(this._channels.values())}},{key:"isCachedInMemory",value:function(e){return this._channels.has(e)}},{key:"filterOffsetChanged",value:function(e){var t=this;return e.filter((function(e){if(t._channels.has(e.url))return t._channels.get(e.url).messageOffsetTimestamp0)return!1;if(f&&f===t.url)return!1;break;case e.GroupChannelListOrder.CHRONOLOGICAL:if(!o&&t.createdAt>r||o&&t.createdAtr||o&&t.lastMessageUpdatedAt0)){t.next=76;break}return t.next=76,this.upsert(s);case 76:case"end":return t.stop()}}),a,this,[[3,30,33,36],[8,20,23,26],[40,67,70,73],[45,57,60,63]])})))}},{key:"block",value:function(e,n){return b(this,void 0,void 0,t().mark((function r(){return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,this._setBlockStateOfAllChannels(e,n,!0);case 2:case"end":return t.stop()}}),r,this)})))}},{key:"unblock",value:function(e,n){return b(this,void 0,void 0,t().mark((function r(){return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,this._setBlockStateOfAllChannels(e,n,!1);case 2:case"end":return t.stop()}}),r,this)})))}},{key:"markAsRead",value:function(e){var n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:_(this._channels.keys());return b(this,void 0,void 0,t().mark((function r(){var a,s,i,o,u;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:a=[],s=y(n),t.prev=2,s.s();case 4:if((i=s.n()).done){t.next=12;break}return o=i.value,t.next=8,this.get(o);case 8:(u=t.sent)._updateUnreadMemberState(this._sdkState.userId,e)&&(u._updateUnreadCount(0,0),a.push(u));case 10:t.next=4;break;case 12:t.next=17;break;case 14:t.prev=14,t.t0=t.catch(2),s.e(t.t0);case 17:return t.prev=17,s.f(),t.finish(17);case 20:if(!(a.length>0)){t.next=23;break}return t.next=23,this.upsert(a);case 23:case"end":return t.stop()}}),r,this,[[2,14,17,20]])})))}}]),o}(Ca);!function(e){e[e.NONE=0]="NONE",e[e.CHANNEL_ENTER=10102]="CHANNEL_ENTER",e[e.CHANNEL_EXIT=10103]="CHANNEL_EXIT",e[e.USER_CHANNEL_MUTE=10201]="USER_CHANNEL_MUTE",e[e.USER_CHANNEL_UNMUTE=10200]="USER_CHANNEL_UNMUTE",e[e.USER_CHANNEL_BAN=10601]="USER_CHANNEL_BAN",e[e.USER_CHANNEL_UNBAN=10600]="USER_CHANNEL_UNBAN",e[e.CHANNEL_FREEZE=10701]="CHANNEL_FREEZE",e[e.CHANNEL_UNFREEZE=10700]="CHANNEL_UNFREEZE",e[e.TYPING_START=10900]="TYPING_START",e[e.TYPING_END=10901]="TYPING_END",e[e.CHANNEL_JOIN=1e4]="CHANNEL_JOIN",e[e.CHANNEL_LEAVE=10001]="CHANNEL_LEAVE",e[e.CHANNEL_OPERATOR_UPDATE=10002]="CHANNEL_OPERATOR_UPDATE",e[e.CHANNEL_INVITE=10020]="CHANNEL_INVITE",e[e.CHANNEL_ACCEPT_INVITE=10021]="CHANNEL_ACCEPT_INVITE",e[e.CHANNEL_DECLINE_INVITE=10022]="CHANNEL_DECLINE_INVITE",e[e.CHANNEL_PROP_CHANGED=11e3]="CHANNEL_PROP_CHANGED",e[e.CHANNEL_DELETED=12e3]="CHANNEL_DELETED",e[e.CHANNEL_META_DATA_CHANGED=11100]="CHANNEL_META_DATA_CHANGED",e[e.CHANNEL_META_COUNTERS_CHANGED=11200]="CHANNEL_META_COUNTERS_CHANGED",e[e.CHANNEL_HIDE=13e3]="CHANNEL_HIDE",e[e.CHANNEL_UNHIDE=13001]="CHANNEL_UNHIDE",e[e.PINNED_MESSAGE_CHANGED=11300]="PINNED_MESSAGE_CHANGED"}(nd||(nd={}));var sd,id=function(){function t(e){r(this,t),this.channelUrl=e.channel_url,this.channelType=e.channel_type,this.category=e.cat,this.data=e.data,this.ts=e.ts}return s(t,[{key:"isGroupChannelEvent",get:function(){return this.channelType===e.ChannelType.GROUP}},{key:"isOpenChannelEvent",get:function(){return this.channelType===e.ChannelType.OPEN}}]),t}(),od={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},ud=function(e){return F("string",e.invitedUserIds,!0)&&L("string",e.channelUrl,!0)&&L("string",e.coverUrl,!0)&&(H(e.coverImage)||L("string",e.coverImage)||null===e.coverImage)&&L("boolean",e.isDistinct,!0)&&L("boolean",e.isSuper,!0)&&L("boolean",e.isBroadcast,!0)&&L("boolean",e.isExclusive,!0)&&L("boolean",e.isPublic,!0)&&L("boolean",e.isStrict,!0)&&L("boolean",e.isDiscoverable,!0)&&L("boolean",e.isEphemeral,!0)&&L("string",e.accessCode,!0)&&L("string",e.name,!0)&&L("string",e.data,!0)&&L("string",e.customType,!0)&&F("string",e.operatorUserIds,!0)&&L("number",e.messageSurvivalSeconds,!0)},cd={customTypes:null,includeEmpty:!1,includeFrozen:!0},ld=function(e){return F("string",e.customTypes,!0)&&L("boolean",e.includeEmpty)&&L("boolean",e.includeFrozen)},hd={myMemberStateFilter:e.MyMemberStateFilter.ALL},dd=function(t){return D(e.MyMemberStateFilter,t.myMemberStateFilter)};e.UnreadItemKey=void 0,(sd=e.UnreadItemKey||(e.UnreadItemKey={})).GROUP_CHANNEL_UNREAD_MENTION_COUNT="group_channel_unread_mention_count",sd.NONSUPER_UNREAD_MENTION_COUNT="non_super_group_channel_unread_mention_count",sd.SUPER_UNREAD_MENTION_COUNT="super_group_channel_unread_mention_count",sd.GROUP_CHANNEL_UNREAD_MESSAGE_COUNT="group_channel_unread_message_count",sd.NONSUPER_UNREAD_MESSAGE_COUNT="non_super_group_channel_unread_message_count",sd.SUPER_UNREAD_MESSAGE_COUNT="super_group_channel_unread_message_count",sd.GROUP_CHANNEL_INVITATION_COUNT="group_channel_invitation_count",sd.NONSUPER_INVITATION_COUNT="non_super_group_channel_invitation_count",sd.SUPER_INVITATION_COUNT="super_group_channel_invitation_count";var fd,pd={keys:[]},vd=function(t){return F(e.UnreadItemKey,t.keys)},_d={channelCustomTypesFilter:null,superChannelFilter:e.SuperChannelFilter.ALL},md=function(t){return F("string",t.channelCustomTypesFilter,!0)&&D(e.SuperChannelFilter,t.superChannelFilter)},gd={channelUrl:null,scheduledStatus:null,messageTypeFilter:e.MessageTypeFilter.ALL},yd=function(t){return L("string",t.channelUrl,!0)&&F(e.ScheduledStatus,t.scheduledStatus,!0)&&D(e.MessageTypeFilter,t.messageTypeFilter)},kd=function(){function e(n){var a=this,s=n.groupChannelCache,i=n.messageCache,o=n.unsentMessageCache,u=n.dispatcher;r(this,e),this._observers=new Map,u.on((function(e){return b(a,void 0,void 0,t().mark((function n(){var r,a,u,c,l,h,d,f,p,v,_=this;return t().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:if(!(e instanceof ru)){n.next=26;break}r=e.channels,a=e.source,u=e.data,c=r.filter((function(e){return e instanceof Rp})),l=s.filterOffsetChanged(c),h=y(l),n.prev=5,h.s();case 7:if((d=h.n()).done){n.next=13;break}return f=d.value,n.next=11,i.removeUnderOffset(f.url,f.messageOffsetTimestamp);case 11:n.next=7;break;case 13:n.next=18;break;case 15:n.prev=15,n.t0=n.catch(5),h.e(n.t0);case 18:return n.prev=18,h.f(),n.finish(18);case 21:return n.next=23,s.upsert(c);case 23:this._broadcastUpdateEvent(c,a,u),n.next=38;break;case 26:if(!(e instanceof au)){n.next=35;break}return p=e.channelUrls,v=e.source,n.next=30,s.remove(p);case 30:return n.next=32,ca((function(){return b(_,void 0,void 0,t().mark((function e(){var n,r,a;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:n=y(p),e.prev=1,n.s();case 3:if((r=n.n()).done){e.next=11;break}return a=r.value,e.next=7,i.removeMessagesOfChannel(a);case 7:return e.next=9,o.removeMessagesOfChannel(a);case 9:e.next=3;break;case 11:e.next=16;break;case 13:e.prev=13,e.t0=e.catch(1),n.e(e.t0);case 16:return e.prev=16,n.f(),e.finish(16);case 19:case"end":return e.stop()}}),e,null,[[1,13,16,19]])})))}));case 32:this._broadcastRemoveEvent(p,v),n.next=38;break;case 35:if(!(e instanceof eu)){n.next=38;break}return n.next=38,s.fetch({token:Number.MAX_SAFE_INTEGER,limit:Number.MAX_SAFE_INTEGER});case 38:case"end":return n.stop()}}),n,this,[[5,15,18,21]])})))}))}return s(e,[{key:"_broadcastUpdateEvent",value:function(e,t,n){var r,a=y(this._observers.values());try{for(a.s();!(r=a.n()).done;){r.value.onUpdate(e,t,n)}}catch(e){a.e(e)}finally{a.f()}}},{key:"_broadcastRemoveEvent",value:function(e,t){var n,r=y(this._observers.values());try{for(r.s();!(n=r.n()).done;){n.value.onRemove(e,t)}}catch(e){r.e(e)}finally{r.f()}}},{key:"subscribe",value:function(e,t){this._observers.set(e,t)}},{key:"unsubscribe",value:function(e){this._observers.delete(e)}},{key:"unsubscribeAll",value:function(){this._observers.clear()}}]),e}(),bd=function(){function e(n){var a=this,s=n.cacheContext,i=n.messageCache,o=n.unsentMessageCache,u=n.dispatcher,c=n.logger;r(this,e),this._cacheContext=null,this._observers=new Map,this._logger=null,this._cacheContext=s,this._logger=c,u.on((function(e){return b(a,void 0,void 0,t().mark((function n(){var r,a,s,u,c,l,h,d,f,p,v,_,m,g,y,k,E,w,C=this;return t().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:if(!(e instanceof ei)){n.next=14;break}if(r=e.messages,a=e.source,s=r.filter((function(e){return e.messageId>0})),u=r.filter((function(e){return 0===e.messageId})),!(s.length>0)){n.next=8;break}return n.next=7,ca((function(){return b(C,void 0,void 0,t().mark((function e(){return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,i.upsert(s);case 2:return e.next=4,o.remove(s.map((function(e){return e instanceof Es?e.reqId:null})).filter((function(e){return null!==e})));case 4:case"end":return e.stop()}}),e)})))}));case 7:this._broadcastUpdateEvent(s,a);case 8:if(!(u.length>0)){n.next=12;break}return n.next=11,ca((function(){return b(C,void 0,void 0,t().mark((function e(){return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,o.upsert(u);case 2:case"end":return e.stop()}}),e)})))}));case 11:this._broadcastUpdateEvent(u,a);case 12:n.next=61;break;case 14:if(!(e instanceof ti)){n.next=21;break}return c=e.messageIds,l=e.source,n.next=18,ca((function(){return b(C,void 0,void 0,t().mark((function e(){return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,i.remove(c);case 2:case"end":return e.stop()}}),e)})))}));case 18:this._broadcastRemoveEvent(c,l),n.next=61;break;case 21:if(!(e instanceof ni)){n.next=28;break}return h=e.reqId,d=e.source,n.next=25,ca((function(){return b(C,void 0,void 0,t().mark((function e(){return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,o.remove([h]);case 2:case"end":return e.stop()}}),e)})))}));case 25:this._broadcastRemoveUnsentEvent(h,d),n.next=61;break;case 28:if(!(e instanceof ri)){n.next=41;break}if(f=e.polls,p=e.source,!this._cacheContext.localCacheEnabled){n.next=38;break}return v=f.map((function(e){return e.messageId})),n.next=34,Promise.all(v.map((function(e){return i.get(e)})));case 34:return _=n.sent.filter((function(e){return e})),_.length>0&&f.forEach((function(e){var t=_.find((function(t){return t.messageId===e.messageId}));t&&t.applyPoll(e)})),n.next=38,ca((function(){return b(C,void 0,void 0,t().mark((function e(){return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,i.upsert(_);case 2:return e.abrupt("return",e.sent);case 3:case"end":return e.stop()}}),e)})))}));case 38:this._broadcastPollChangeLogEvent(f,p),n.next=61;break;case 41:if(!(e instanceof ai)){n.next=52;break}return m=e.event,g=e.source,n.next=45,i.get(m.messageId);case 45:if(!((y=n.sent)&&y.isUserMessage()&&y.poll&&y.poll.applyPollUpdateEvent(m))){n.next=49;break}return n.next=49,ca((function(){return b(C,void 0,void 0,t().mark((function e(){return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,i.upsert([y]);case 2:return e.abrupt("return",e.sent);case 3:case"end":return e.stop()}}),e)})))}));case 49:this._broadcastPollUpdateEvent(m,g),n.next=61;break;case 52:if(!(e instanceof si)){n.next=61;break}return k=e.event,E=e.source,n.next=56,i.get(k.messageId);case 56:if(!((w=n.sent)&&w.isUserMessage()&&w.poll&&w.poll.applyPollVoteEvent(k))){n.next=60;break}return n.next=60,ca((function(){return b(C,void 0,void 0,t().mark((function e(){return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,i.upsert([w]);case 2:return e.abrupt("return",e.sent);case 3:case"end":return e.stop()}}),e)})))}));case 60:this._broadcastPollVoteEvent(k,E);case 61:case"end":return n.stop()}}),n,this)})))}))}return s(e,[{key:"_broadcastUpdateEvent",value:function(e,t){var n,r=y(this._observers.values());try{for(r.s();!(n=r.n()).done;){n.value.onUpdate(e,t)}}catch(e){r.e(e)}finally{r.f()}}},{key:"_broadcastPollChangeLogEvent",value:function(e,t){var n,r=y(this._observers.values());try{for(r.s();!(n=r.n()).done;){n.value.onPollChangeLogUpdate(e,t)}}catch(e){r.e(e)}finally{r.f()}}},{key:"_broadcastPollUpdateEvent",value:function(e,t){var n,r=y(this._observers.values());try{for(r.s();!(n=r.n()).done;){n.value.onPollUpdate(e,t)}}catch(e){r.e(e)}finally{r.f()}}},{key:"_broadcastPollVoteEvent",value:function(e,t){var n,r=y(this._observers.values());try{for(r.s();!(n=r.n()).done;){n.value.onPollVote(e,t)}}catch(e){r.e(e)}finally{r.f()}}},{key:"_broadcastRemoveEvent",value:function(e,t){var n,r=y(this._observers.values());try{for(r.s();!(n=r.n()).done;){n.value.onRemove(e,t)}}catch(e){r.e(e)}finally{r.f()}}},{key:"_broadcastRemoveUnsentEvent",value:function(e,t){var n,r=y(this._observers.values());try{for(r.s();!(n=r.n()).done;){n.value.onRemoveUnsent(e,t)}}catch(e){r.e(e)}finally{r.f()}}},{key:"subscribe",value:function(e,t){this._observers.set(e,t)}},{key:"unsubscribe",value:function(e){this._observers.delete(e)}},{key:"unsubscribeAll",value:function(){this._observers.clear()}}]),e}(),Ed=function(e){i(n,e);var t=f(n);function n(e){var a,s=e.userId,i=e.ts,o=e.token,u=e.filter;r(this,n),a=t.call(this);var c=Object.assign(Object.assign({},cd),u),l=c.customTypes,h=c.includeEmpty,d=c.includeFrozen;return a.method=B.GET,a.path="".concat(qr,"/").concat(encodeURIComponent(s),"/my_group_channels/changelogs"),a.params=ee({show_delivery_receipt:!0,show_member:!0,show_read_receipt:!0,change_ts:i>0?i:null,token:o,custom_types:l,show_empty:h,show_frozen:d}),a}return s(n)}(ne),wd=function(e){i(n,e);var t=f(n);function n(e,a){var s;return r(this,n),(s=t.call(this,e,a)).updatedChannels=a.updated.map((function(t){return new Rp(e,t)})),s.deletedChannelUrls=a.deleted,s.hasMore=a.has_more,s.token=a.next,s}return s(n)}(re),Cd=function(e){i(n,e);var t=f(n);function n(e){var a,s=e.channelUrl,i=e.isInternalCall;return r(this,n),(a=t.call(this)).method=B.GET,a.path="".concat(i?Vr:zr,"/").concat(encodeURIComponent(s)),a.params={show_member:!0,show_read_receipt:!0,show_delivery_receipt:!0},a}return s(n)}(ne),xd=function(e){i(n,e);var t=f(n);function n(e,a){var s;return r(this,n),(s=t.call(this,e,a)).channel=null,s.channel=new Rp(e,a),s}return s(n)}(re),Td=function(e){i(n,e);var t=f(n);function n(e){var a;r(this,n);var s=e.userId,i=e.token,o=e.limit,u=e.order,c=e.includeEmpty,l=e.myMemberStateFilter,h=e.superChannelFilter,d=e.publicChannelFilter,f=e.unreadChannelFilter,p=e.nicknameContainsFilter,v=e.nicknameStartsWithFilter,_=e.nicknameExactMatchFilter,m=e.channelNameContainsFilter,g=e.channelUrlsFilter,y=e.customTypesFilter,k=e.customTypeStartsWithFilter,b=e.hiddenChannelFilter,E=e.metadataOrderKeyFilter,w=e.metadataKey,C=e.metadataValues,x=e.metadataValueStartsWith,T=e.includeFrozen,S=e.includeMetaData,I=e.searchFilter,N=e.userIdsFilter;return(a=t.call(this)).method=B.GET,a.path="".concat(qr,"/").concat(encodeURIComponent(s),"/my_group_channels"),a.params=ee({token:i,limit:o,order:u,show_member:!0,show_read_receipt:!0,show_delivery_receipt:!0,show_empty:c,member_state_filter:l,super_mode:h,public_mode:d,unread_filter:f,members_nickname_contains:p,members_nickname_startswith:v,members_nickname:_,name_contains:m,channel_urls:g,custom_types:y,custom_type_startswith:k,hidden_mode:b,metadata_order_key:E,metadata_key:w,metadata_values:C,metadata_value_startswith:x,show_frozen:T,show_metadata:S}),I&&I.query&&I.fields&&(a.params.search_query=I.query,a.params.search_fields=I.fields),N&&N.userIds&&N.userIds.length>0&&(N.includeMode?(a.params.members_include_in=N.userIds,a.params.query_type=N.queryType.toUpperCase()):a.params.members_exactly_in=N.userIds),a}return s(n)}(ne),Sd=function(e){i(n,e);var t=f(n);function n(e,a){var s;r(this,n),(s=t.call(this,e,a)).token=null,s.channels=[],s.ts=null;var i=a.next,o=a.channels,u=a.ts;return s.token=i,o&&o.length>0&&(s.channels=o.map((function(t){return t.ts=u,new Rp(e,t)}))),s.ts=null!=u?u:null,s}return s(n)}(re),Id=function(t){i(a,t);var n=f(a);function a(t){var s,i=t.userId,o=t.filter;r(this,a),s=n.call(this);var u=o.myMemberStateFilter;return s.method=B.GET,s.path="".concat(qr,"/").concat(encodeURIComponent(i),"/group_channel_count"),s.params={state:null!=u?u:e.MyMemberStateFilter.ALL},s}return s(a)}(ne),Nd=function(e){i(n,e);var t=f(n);function n(e,a){var s;return r(this,n),(s=t.call(this,e,a)).groupChannelCount=a.group_channel_count,s}return s(n)}(re),Ad=function(e){i(n,e);var t=f(n);function n(e){var a,s=e.userId,i=e.filter;r(this,n),a=t.call(this);var o=i.keys;return a.method=B.GET,a.path="".concat(qr,"/").concat(encodeURIComponent(s),"/unread_item_count"),a.params={item_keys:o},a}return s(n)}(ne),Md=function(t){i(a,t);var n=f(a);function a(t,s){var i;return r(this,a),i=n.call(this,t,s),"number"==typeof s[e.UnreadItemKey.GROUP_CHANNEL_UNREAD_MENTION_COUNT]&&(i.groupChannelUnreadMentionCount=s[e.UnreadItemKey.GROUP_CHANNEL_UNREAD_MENTION_COUNT]),"number"==typeof s[e.UnreadItemKey.GROUP_CHANNEL_UNREAD_MESSAGE_COUNT]&&(i.groupChannelUnreadMessageCount=s[e.UnreadItemKey.GROUP_CHANNEL_UNREAD_MESSAGE_COUNT]),"number"==typeof s[e.UnreadItemKey.GROUP_CHANNEL_INVITATION_COUNT]&&(i.groupChannelInvitationCount=s[e.UnreadItemKey.GROUP_CHANNEL_INVITATION_COUNT]),"number"==typeof s[e.UnreadItemKey.SUPER_UNREAD_MENTION_COUNT]&&(i.superGroupChannelUnreadMentionCount=s[e.UnreadItemKey.SUPER_UNREAD_MENTION_COUNT]),"number"==typeof s[e.UnreadItemKey.SUPER_UNREAD_MESSAGE_COUNT]&&(i.superGroupChannelUnreadMessageCount=s[e.UnreadItemKey.SUPER_UNREAD_MESSAGE_COUNT]),"number"==typeof s[e.UnreadItemKey.SUPER_INVITATION_COUNT]&&(i.superGroupChannelInvitationCount=s[e.UnreadItemKey.SUPER_INVITATION_COUNT]),"number"==typeof s[e.UnreadItemKey.NONSUPER_UNREAD_MENTION_COUNT]&&(i.nonSuperGroupChannelUnreadMentionCount=s[e.UnreadItemKey.NONSUPER_UNREAD_MENTION_COUNT]),"number"==typeof s[e.UnreadItemKey.NONSUPER_UNREAD_MESSAGE_COUNT]&&(i.nonSuperGroupChannelUnreadMessageCount=s[e.UnreadItemKey.NONSUPER_UNREAD_MESSAGE_COUNT]),"number"==typeof s[e.UnreadItemKey.NONSUPER_INVITATION_COUNT]&&(i.nonSuperGroupChannelInvitationCount=s[e.UnreadItemKey.NONSUPER_INVITATION_COUNT]),i}return s(a)}(re),Od=function(e){i(n,e);var t=f(n);function n(e){var a,s=e.userId;return r(this,n),(a=t.call(this)).method=B.GET,a.path="".concat(qr,"/").concat(encodeURIComponent(s),"/unread_channel_count"),a}return s(n)}(ne),Ud=function(e){i(n,e);var t=f(n);function n(e,a){var s;return r(this,n),(s=t.call(this,e,a)).unreadCount=a.unread_count,s}return s(n)}(re),Rd=function(t){i(a,t);var n=f(a);function a(t){var s,i=t.userId,o=t.filter;r(this,a),s=n.call(this);var u=o.channelCustomTypesFilter,c=o.superChannelFilter;return s.method=B.GET,s.path="".concat(qr,"/").concat(encodeURIComponent(i),"/unread_message_count"),s.params={super_mode:null!=c?c:e.SuperChannelFilter.ALL,custom_types:u},s}return s(a)}(ne),Ld=function(e){i(n,e);var t=f(n);function n(e,a){var s;return r(this,n),(s=t.call(this,e,a)).unreadCount=a.unread_count,s}return s(n)}(re),Dd=function(e){i(n,e);var t=f(n);function n(e){var a,s=e.channelUrl,i=e.scheduledStatus,o=e.messageTypeFilter;return r(this,n),(a=t.call(this)).method=B.GET,a.path="".concat(Xr,"/count"),a.params={channel_url:s,status:Fd(i)},o&&(a.params.message_type=o),a}return s(n)}(ne),Pd=function(e){i(n,e);var t=f(n);function n(e,a){var s;return r(this,n),(s=t.call(this,e,a)).count=a.count,s}return s(n)}(re),Fd=function(t){if(t){var n=[];return t.forEach((function(t){switch(t){case e.ScheduledStatus.PENDING:n.push(hs.PENDING);break;case e.ScheduledStatus.SENT:n.push(hs.IN_QUEUE),n.push(hs.SENT);break;case e.ScheduledStatus.CANCELED:n.push(hs.CANCELED);break;case e.ScheduledStatus.FAILED:n.push(hs.FAILED)}})),n}},Gd=function(e){i(n,e);var t=f(n);function n(e){var a;r(this,n);var s=e.userId,i=e.channelUrl,o=e.coverUrl,u=e.coverImage,c=e.isDistinct,l=e.isSuper,h=e.isBroadcast,d=e.isPublic,f=e.isExclusive,p=e.isDiscoverable,v=e.isStrict,m=e.isEphemeral,g=e.accessCode,y=e.name,k=e.data,b=e.customType,E=e.messageSurvivalSeconds,w=e.invitedUserIds,C=e.operatorUserIds;return(a=t.call(this)).method=B.POST,a.path=zr,a.params=ee({user_ids:[s].concat(_(null!=w?w:[])).filter((function(e,t,n){return t===n.indexOf(e)})),channel_url:i,cover_url:o,cover_file:u,is_distinct:c,is_super:l,is_broadcast:h,is_exclusive:f,is_public:d,is_discoverable:p,strict:v,is_ephemeral:m,access_code:g,name:y,data:k,custom_type:b,operator_ids:C,message_survival_seconds:E}),a}return s(n)}(ne),Hd=function(e){i(n,e);var t=f(n);function n(e,a){var s;return r(this,n),(s=t.call(this,e,a)).channel=new Rp(e,a),s.isCreated=a.is_created,s}return s(n)}(re),qd=function(e){i(n,e);var t=f(n);function n(e){var a,s=e.userId,i=e.channelUrls;return r(this,n),(a=t.call(this)).method=B.PUT,a.path="".concat(qr,"/").concat(encodeURIComponent(s),"/mark_as_read_all"),a.params={channel_urls:i},a}return s(n)}(ne),jd=function(e){i(n,e);var t=f(n);function n(e,a,s){var i;return r(this,n),(i=t.call(this,e,"SYEV",s)).event=new id(s),i}return s(n)}(le),zd=function(e){i(n,e);var t=f(n);function n(e){var a;r(this,n);var s=e.channelUrl,i=e.userId,o=e.accessCode;return(a=t.call(this)).method=B.PUT,a.path="".concat(zr,"/").concat(encodeURIComponent(s),"/join"),a.params={user_id:i,access_code:o},a}return s(n)}(ne),Vd=function(e){i(n,e);var t=f(n);function n(e,a){var s;return r(this,n),(s=t.call(this,e,a)).channel=new Rp(e,a),s}return s(n)}(re),Bd=function(e){i(n,e);var t=f(n);function n(e,a,s){var i;r(this,n),i=t.call(this,e,a,s);var o=s.data,u=o.member_count,c=void 0===u?null:u,l=o.joined_member_count,h=void 0===l?null:l,d=o.users,f=void 0===d?null:d;return i.memberCount=c,i.joinedMemberCount=h,i.members=Array.isArray(f)?f.map((function(t){return new ed(e,t)})):[new ed(e,s.data)],i}return s(n)}(jd),Qd=function(e){i(n,e);var t=f(n);function n(e){var a;r(this,n);var s=e.channelUrl,i=e.userId,o=e.shouldRemoveOperatorStatus;return(a=t.call(this)).method=B.PUT,a.path="".concat(zr,"/").concat(encodeURIComponent(s),"/leave"),a.params={user_id:i,should_remove_operator_status:o},a}return s(n)}(ne),Kd=function(e){i(n,e);var t=f(n);function n(e,a,s){var i;r(this,n),i=t.call(this,e,a,s);var o=s.data,u=o.member_count,c=void 0===u?null:u,l=o.joined_member_count,h=void 0===l?null:l;return i.memberCount=c,i.joinedMemberCount=h,i.member=new ed(i._iid,s.data),i}return s(n)}(jd),Wd=function(e){i(n,e);var t=f(n);function n(e){var a;r(this,n);var s=e.channelUrl,i=e.userIds;return(a=t.call(this)).method=B.POST,a.path="".concat(zr,"/").concat(encodeURIComponent(s),"/invite"),a.params={user_ids:i},a}return s(n)}(ne),Yd=function(e){i(n,e);var t=f(n);function n(e,a){var s;return r(this,n),(s=t.call(this,e,a)).channel=new Rp(e,a),s}return s(n)}(re),Zd=function(e){i(n,e);var t=f(n);function n(e,a,s){var i;r(this,n),i=t.call(this,e,a,s);var o=s.data,u=o.member_count,c=void 0===u?null:u,l=o.joined_member_count,h=void 0===l?null:l,d=o.inviter,f=void 0===d?null:d,p=o.invitees,v=void 0===p?[]:p;return i.memberCount=c,i.joinedMemberCount=h,i.inviter=f?new La(e,f):null,i.invitees=v.map((function(t){return new ed(e,t)})),i}return s(n)}(jd),Jd=function(e){i(n,e);var t=f(n);function n(e){var a;r(this,n);var s=e.channelUrl,i=e.userId;return(a=t.call(this)).method=B.PUT,a.path="".concat(zr,"/").concat(encodeURIComponent(s),"/decline"),a.params={user_id:i},a}return s(n)}(ne),Xd=function(e){i(n,e);var t=f(n);function n(e,a,s){var i;r(this,n),i=t.call(this,e,a,s);var o=s.data,u=o.member_count,c=void 0===u?null:u,l=o.joined_member_count,h=void 0===l?null:l,d=o.inviter,f=void 0===d?null:d,p=o.invitee,v=void 0===p?null:p;return i.memberCount=c,i.joinedMemberCount=h,i.inviter=f?new La(e,f):null,i.invitee=v?new ed(e,v):null,i}return s(n)}(jd),$d=function(e){i(n,e);var t=f(n);function n(e){var a=e.channelUrl;return r(this,n),t.call(this,{code:"READ",ackRequired:!0,payload:{channel_url:a}})}return s(n)}(Mr),ef=function(e){i(n,e);var t=f(n);function n(e,a,s){var i;return r(this,n),(i=t.call(this,e,"READ",s)).readStatus=new td(e,s),i}return s(n)}(le),tf=function(e){i(n,e);var t=f(n);function n(e){var a,s=e.channelUrl,i=e.userId;return r(this,n),a=t.call(this),(a=t.call(this)).method=B.PUT,a.path="".concat(zr,"/").concat(encodeURIComponent(s),"/messages/mark_as_delivered"),a.params=ee({userId:i}),a}return s(n)}(ne),nf=function(e){i(n,e);var t=f(n);function n(e,a,s){var i;return r(this,n),(i=t.call(this,e,"DLVR",s)).channelUrl=s.channel_url,i.deliveredStateUpdate=s.updated,i}return s(n)}(le),rf=function(e){i(n,e);var t=f(n);function n(e){var a;r(this,n);var s=e.channelUrl,i=e.userId,o=e.hidePreviousMessages,u=e.allowAutoUnhide;return(a=t.call(this)).method=B.PUT,a.path="".concat(zr,"/").concat(encodeURIComponent(s),"/hide"),a.params={user_id:i,hide_previous_messages:o,allow_auto_unhide:u},a}return s(n)}(ne),af=function(e){i(n,e);var t=f(n);function n(e,a){var s;r(this,n),(s=t.call(this,e,a)).messageOffsetTimestamp=null;var i=a.ts_message_offset;return s.messageOffsetTimestamp=null!=i?i:null,s}return s(n)}(re),sf=function(e){i(n,e);var t=f(n);function n(e,a,s){var i;return r(this,n),(i=t.call(this,e,"SYEV",s)).allowAutoUnhide=null,i.hidePreviousMessages=null,i.messageOffsetTimestamp=null,s.data&&(i.allowAutoUnhide=s.data.allow_auto_unhide,i.hidePreviousMessages=s.data.hide_previous_messages),i.messageOffsetTimestamp=s.ts_message_offset,i}return s(n)}(le),of=function(e){i(n,e);var t=f(n);function n(e){var a=e.channelUrl,s=e.time;return r(this,n),t.call(this,{code:"TPST",ackRequired:!1,payload:{channel_url:a,time:s}})}return s(n)}(Mr),uf=function(e){i(n,e);var t=f(n);function n(e,a,s){var i;return r(this,n),(i=t.call(this,e,"SYEV",s)).user=new La(e,s.data),i}return s(n)}(le),cf=function(e){i(n,e);var t=f(n);function n(e){var a=e.channelUrl,s=e.time;return r(this,n),t.call(this,{code:"TPEN",ackRequired:!1,payload:{channel_url:a,time:s}})}return s(n)}(Mr),lf=function(e){i(n,e);var t=f(n);function n(e,a,s){var i;return r(this,n),(i=t.call(this,e,"SYEV",s)).user=new La(e,s.data),i}return s(n)}(le),hf=function(e){i(n,e);var t=f(n);function n(e,a,s){var i;r(this,n),i=t.call(this,e,a,s);var o=s.data.operators,u=void 0===o?[]:o;return i.operators=u.map((function(e){return new La(i._iid,e)})),i}return s(n)}(jd),df=function(e){i(n,e);var t=f(n);function n(e,a,s){var i;return r(this,n),(i=t.call(this,e,"MCNT",s)).groupChannelMemberCounts=s.group_channels.map((function(e){return{channelUrl:e.channel_url,memberCount:e.member_count,joinedMemberCount:e.joined_member_count,updatedAt:e.ts}})),i.openChannelMemberCounts=s.open_channels.map((function(e){return{channelUrl:e.channel_url,participantCount:e.participant_count,updatedAt:e.ts}})),i}return s(n)}(le),ff=function(e){i(n,e);var t=f(n);function n(e){var a=e.channelUrl,s=e.messageId;return r(this,n),t.call(this,{code:"MACK",ackRequired:!1,payload:{channel_url:a,msg_id:s}})}return s(n)}(Mr),pf=function(e){i(n,e);var t=f(n);function n(e,a,s){var i,o,u,c;r(this,n),(i=t.call(this,e,"ADMM",s)).message=new Ts(e,s);var l=ns.of(e).sdkState;return i.isMentioned=Hs(i.message.mentionType,null!==(o=i.message.mentionedUserIds)&&void 0!==o?o:null===(u=i.message.mentionedUsers)||void 0===u?void 0:u.map((function(e){return e.userId})),l.userId),i.forceUpdateLastMessage=null!==(c=s.force_update_last_message)&&void 0!==c&&c,i}return s(n)}(le),vf=function(e){i(n,e);var t=f(n);function n(e,a,s){var i,o,u,c,l,h,d;r(this,n),(i=t.call(this,e,"AEDI",s)).message=new Ts(e,s);var f=ns.of(e).sdkState;return i.mentionCountChange=qs({mentionType:null!==(u=null===(o=s.old_values)||void 0===o?void 0:o.mention_type)&&void 0!==u?u:null,mentionedUserIds:null!==(l=null===(c=s.old_values)||void 0===c?void 0:c.mentioned_user_ids)&&void 0!==l?l:[]},{mentionType:i.message.mentionType,mentionedUserIds:null!==(h=i.message.mentionedUserIds)&&void 0!==h?h:null===(d=i.message.mentionedUsers)||void 0===d?void 0:d.map((function(e){return e.userId}))},f.userId),i}return s(n)}(le),_f=function(e){i(n,e);var t=f(n);function n(e,a,s){var i;return r(this,n),(i=t.call(this,e,"MRCT",s)).channelUrl=s.channel_url,i.channelType=s.channel_type,i.event=new ds(s),i}return s(n)}(le),mf=function(e){i(n,e);var t=f(n);function n(e,a,s){var i;return r(this,n),(i=t.call(this,e,"MTHD",s)).event=new mi(e,s),i}return s(n)}(le),gf=function(e){i(n,e);var t=f(n);function n(e,a,s){var i;return r(this,n),(i=t.call(this,e,"PEDI",s)).event=null,i.status=null,i.channelUrl=null,i.channelType=null,i.event=new Wi(e,s),i.status=As(s.poll.status)||s.poll.status,i.channelUrl=s.channel_url,i.channelType=s.channel_type,i}return s(n)}(le),yf=function(n){i(u,n);var a=f(u);function u(t,n){var s,i,o,c,l,h,d,f,p,v,_,m,g,y,k,b,E,w,C,x,T,S,I;return r(this,u),(s=a.call(this,t,n)).includeEmpty=!1,s.includeFrozen=!0,s.includeMetaData=!0,s.channelUrlsFilter=null,s.customTypesFilter=null,s.customTypeStartsWithFilter=null,s.nicknameContainsFilter=null,s.nicknameStartsWithFilter=null,s.nicknameExactMatchFilter=null,s.channelNameContainsFilter="",s.myMemberStateFilter=e.MyMemberStateFilter.ALL,s.unreadChannelFilter=e.UnreadChannelFilter.ALL,s.superChannelFilter=e.SuperChannelFilter.ALL,s.publicChannelFilter=e.PublicChannelFilter.ALL,s.hiddenChannelFilter=e.HiddenChannelFilter.UNHIDDEN,s.searchFilter={fields:[],query:null},s.userIdsFilter={userIds:[],includeMode:!0,queryType:e.QueryType.AND},s.metadataKey=null,s.metadataValues=null,s.metadataOrderKeyFilter=null,s.metadataValueStartsWith=null,s.order=e.GroupChannelListOrder.LATEST_LAST_MESSAGE,s.includeEmpty=null!==(i=n.includeEmpty)&&void 0!==i&&i,s.includeFrozen=null===(o=n.includeFrozen)||void 0===o||o,s.includeMetaData=null===(c=n.includeMetaData)||void 0===c||c,s.channelUrlsFilter=null!==(l=n.channelUrlsFilter)&&void 0!==l?l:null,s.customTypesFilter=null!==(h=n.customTypesFilter)&&void 0!==h?h:null,s.customTypeStartsWithFilter=null!==(d=n.customTypeStartsWithFilter)&&void 0!==d?d:"",s.nicknameContainsFilter=null!==(f=n.nicknameContainsFilter)&&void 0!==f?f:null,s.nicknameStartsWithFilter=null!==(p=n.nicknameStartsWithFilter)&&void 0!==p?p:null,s.nicknameExactMatchFilter=null!==(v=n.nicknameExactMatchFilter)&&void 0!==v?v:null,s.channelNameContainsFilter=null!==(_=n.channelNameContainsFilter)&&void 0!==_?_:"",s.myMemberStateFilter=null!==(m=n.myMemberStateFilter)&&void 0!==m?m:e.MyMemberStateFilter.ALL,s.unreadChannelFilter=null!==(g=n.unreadChannelFilter)&&void 0!==g?g:e.UnreadChannelFilter.ALL,s.superChannelFilter=null!==(y=n.superChannelFilter)&&void 0!==y?y:e.SuperChannelFilter.ALL,s.publicChannelFilter=null!==(k=n.publicChannelFilter)&&void 0!==k?k:e.PublicChannelFilter.ALL,s.hiddenChannelFilter=null!==(b=n.hiddenChannelFilter)&&void 0!==b?b:e.HiddenChannelFilter.UNHIDDEN,s.searchFilter=null!==(E=n.searchFilter)&&void 0!==E?E:{fields:[],query:null},s.userIdsFilter=null!==(w=n.userIdsFilter)&&void 0!==w?w:{userIds:[],includeMode:!0,queryType:e.QueryType.AND},s.metadataKey=null!==(C=n.metadataKey)&&void 0!==C?C:null,s.metadataValues=null!==(x=n.metadataValues)&&void 0!==x?x:null,s.metadataOrderKeyFilter=null!==(T=n.metadataOrderKeyFilter)&&void 0!==T?T:null,s.metadataValueStartsWith=null!==(S=n.metadataValueStartsWith)&&void 0!==S?S:null,s.order=null!==(I=n.order)&&void 0!==I?I:e.GroupChannelListOrder.LATEST_LAST_MESSAGE,s}return s(u,[{key:"_validate",value:function(){return p(o(u.prototype),"_validate",this).call(this)&&L("boolean",this.includeEmpty)&&L("boolean",this.includeFrozen)&&L("boolean",this.includeMetaData)&&L("string",this.channelNameContainsFilter)&&F("string",this.channelUrlsFilter,!0)&&F("string",this.customTypesFilter,!0)&&L("string",this.customTypeStartsWithFilter)&&L("string",this.nicknameContainsFilter,!0)&&L("string",this.nicknameStartsWithFilter,!0)&&L("string",this.nicknameExactMatchFilter,!0)&&D(e.MyMemberStateFilter,this.myMemberStateFilter)&&D(e.SuperChannelFilter,this.superChannelFilter)&&D(e.PublicChannelFilter,this.publicChannelFilter)&&D(e.UnreadChannelFilter,this.unreadChannelFilter)&&D(e.HiddenChannelFilter,this.hiddenChannelFilter)&&F(e.GroupChannelSearchField,this.searchFilter.fields)&&L("string",this.searchFilter.query,!0)&&F("string",this.userIdsFilter.userIds)&&L("boolean",this.userIdsFilter.includeMode)&&D(e.QueryType,this.userIdsFilter.queryType)&&D(e.GroupChannelListOrder,this.order)&&L("string",this.metadataOrderKeyFilter,!0)&&L("string",this.metadataKey,!0)&&F("string",this.metadataValues,!0)&&L("string",this.metadataValueStartsWith,!0)}},{key:"serialize",value:function(){return Ma(this)}},{key:"next",value:function(){return b(this,void 0,void 0,t().mark((function e(){var n,r,a,s;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!this._validate()){e.next=20;break}if(this._isLoading){e.next=17;break}if(!this._hasNext){e.next=14;break}return this._isLoading=!0,n=wf.of(this._iid),e.next=7,n.getMyGroupChannels(this._token,this,this.limit);case 7:return r=e.sent,a=r.channels,s=r.token,this._token=s,this._hasNext=!!s,this._isLoading=!1,e.abrupt("return",a);case 14:return e.abrupt("return",[]);case 17:throw M.queryInProgress;case 18:e.next=21;break;case 20:throw M.invalidParameters;case 21:case"end":return e.stop()}}),e,this)})))}}]),u}(ki),kf=function(){function e(t){var n=t.top,a=void 0===n?Number.MAX_SAFE_INTEGER:n,s=t.bottom,i=void 0===s?0:s;r(this,e),this.top=a,this.bottom=i}return s(e,[{key:"includes",value:function(){for(var e=this,t=arguments.length,n=new Array(t),r=0;r0||G.unreadMentionCount>0)&&(G._updateUnreadCount(0,0),this._dispatcher.dispatch(new ru({channels:[G],source:e.GroupChannelEventSource.EVENT_CHANNEL_READ})),ua((function(){return b(cn,void 0,void 0,t().mark((function e(){var n,r;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:n=y(this._groupChannelHandlers.values());try{for(n.s();!(r=n.n()).done;)r.value.onChannelChanged(G)}catch(e){n.e(e)}finally{n.f()}case 2:case"end":return e.stop()}}),e,this)})))}))):0!==G.unreadMessageCount&&0!==G.unreadMentionCount||(this._dispatcher.dispatch(new ru({channels:[G],source:e.GroupChannelEventSource.EVENT_CHANNEL_READ})),ua((function(){return b(cn,void 0,void 0,t().mark((function e(){var n,r;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:n=y(this._groupChannelHandlers.values());try{for(n.s();!(r=n.n()).done;)r.value.onChannelChanged(G)}catch(e){n.e(e)}finally{n.f()}case 2:case"end":return e.stop()}}),e,this)})))}))):(this._dispatcher.dispatch(new ru({channels:[G],source:e.GroupChannelEventSource.EVENT_CHANNEL_READ})),ua((function(){return b(cn,void 0,void 0,t().mark((function e(){var n,r;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:n=y(this._groupChannelHandlers.values());try{for(n.s();!(r=n.n()).done;)r.value.onUnreadMemberStatusUpdated(G)}catch(e){n.e(e)}finally{n.f()}case 2:case"end":return e.stop()}}),e,this)})))})));case 80:return r.abrupt("break",337);case 81:return H=n.as(nf),q=H.channelUrl,j=H.deliveredStateUpdate,z=void 0===j?{}:j,V=this._groupChannelCache.isCachedInMemory(q),r.next=85,this.getChannel(q,!0);case 85:if(B=r.sent,V)for(Q in z)B._updateUndeliveredMemberState(Q,z[Q]);return Object.keys(z).some((function(e){return e!==cn._sdkState.userId}))&&(this._dispatcher.dispatch(new ru({channels:[B],source:e.GroupChannelEventSource.EVENT_CHANNEL_DELIVERED})),ua((function(){return b(cn,void 0,void 0,t().mark((function e(){var n,r;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:n=y(this._groupChannelHandlers.values());try{for(n.s();!(r=n.n()).done;)r.value.onUndeliveredMemberStatusUpdated(B)}catch(e){n.e(e)}finally{n.f()}case 2:case"end":return e.stop()}}),e,this)})))}))),r.abrupt("break",337);case 89:if(K=n.as(_f),W=K.channelUrl,Y=K.channelType,Z=K.event,Y!==e.ChannelType.GROUP){r.next=99;break}return r.next=93,this.getChannel(W,!0);case 93:return J=r.sent,r.next=96,this.getMessageFromCache(Z.messageId);case 96:(X=r.sent)&&(X.applyReactionEvent(Z),this._dispatcher.dispatch(new ei({messages:[X],source:e.MessageEventSource.EVENT_MESSAGE_REACTION_UPDATED}))),ua((function(){return b(cn,void 0,void 0,t().mark((function e(){var n,r;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:n=y(this._groupChannelHandlers.values());try{for(n.s();!(r=n.n()).done;)r.value.onReactionUpdated(J,Z)}catch(e){n.e(e)}finally{n.f()}case 2:case"end":return e.stop()}}),e,this)})))}));case 99:return r.abrupt("break",337);case 100:if($=n.as(mf),(ee=$.event).channelType!==e.ChannelType.GROUP){r.next=110;break}return r.next=104,this.getChannel(ee.channelUrl,!0);case 104:return te=r.sent,r.next=107,this.getMessageFromCache(ee.targetMessageId);case 107:(ne=r.sent)&&(ne.applyThreadInfoUpdateEvent(ee),this._dispatcher.dispatch(new ei({messages:[ne],source:e.MessageEventSource.EVENT_MESSAGE_THREADINFO_UPDATED}))),ua((function(){return b(cn,void 0,void 0,t().mark((function e(){var n,r;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:n=y(this._groupChannelHandlers.values());try{for(n.s();!(r=n.n()).done;)r.value.onThreadInfoUpdated(te,ee)}catch(e){n.e(e)}finally{n.f()}case 2:case"end":return e.stop()}}),e,this)})))}));case 110:return r.abrupt("break",337);case 111:re=n.as(df),ae=re.groupChannelMemberCounts,se=[],ie=y(ae),r.prev=114,ie.s();case 116:if((oe=ie.n()).done){r.next=125;break}return ue=oe.value,ce=ue.channelUrl,le=ue.memberCount,he=ue.joinedMemberCount,de=ue.updatedAt,r.next=121,this.getChannelFromCache(ce);case 121:(fe=r.sent)&&fe._setLatestMemberCount(le,he,de)&&se.push(fe);case 123:r.next=116;break;case 125:r.next=130;break;case 127:r.prev=127,r.t2=r.catch(114),ie.e(r.t2);case 130:return r.prev=130,ie.f(),r.finish(130);case 133:return se.length>0&&(this._dispatcher.dispatch(new ru({channels:se,source:e.GroupChannelEventSource.EVENT_CHANNEL_MEMBER_COUNT_UPDATED})),ua((function(){return b(cn,void 0,void 0,t().mark((function e(){var n,r;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:n=y(this._groupChannelHandlers.values());try{for(n.s();!(r=n.n()).done;)r.value.onChannelMemberCountChanged(se)}catch(e){n.e(e)}finally{n.f()}case 2:case"end":return e.stop()}}),e,this)})))}))),r.abrupt("break",337);case 135:if(pe=n.as(gf),ve=pe.event,_e=pe.status,me=pe.channelUrl,ge=pe.channelType,me&&ge){r.next=138;break}return r.abrupt("break",337);case 138:return r.next=140,this.getChannel(me,!0);case 140:return ye=r.sent,this._dispatcher.dispatch(new ai({event:ve,source:e.MessageEventSource.EVENT_POLL_UPDATED})),ua(_e===Ns?function(){return b(cn,void 0,void 0,t().mark((function e(){var n,r;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:n=y(this._groupChannelHandlers.values());try{for(n.s();!(r=n.n()).done;)r.value.onPollDeleted(ye,ve.pollId)}catch(e){n.e(e)}finally{n.f()}case 2:case"end":return e.stop()}}),e,this)})))}:function(){return b(cn,void 0,void 0,t().mark((function e(){var n,r;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:n=y(this._groupChannelHandlers.values());try{for(n.s();!(r=n.n()).done;)r.value.onPollUpdated(ye,ve)}catch(e){n.e(e)}finally{n.f()}case 2:case"end":return e.stop()}}),e,this)})))}),r.abrupt("break",337);case 144:if(ke=n.as(jh),be=ke.event,Ee=ke.channelUrl,we=ke.channelType,Ee&&we){r.next=147;break}return r.abrupt("break",337);case 147:return r.next=149,this.getChannel(Ee,!0);case 149:return Ce=r.sent,this._dispatcher.dispatch(new si({event:be,source:e.MessageEventSource.EVENT_POLL_VOTED})),ua((function(){return b(cn,void 0,void 0,t().mark((function e(){var n,r;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:n=y(this._groupChannelHandlers.values());try{for(n.s();!(r=n.n()).done;)r.value.onPollVoted(Ce,be)}catch(e){n.e(e)}finally{n.f()}case 2:case"end":return e.stop()}}),e,this)})))})),r.abrupt("break",337);case 153:if(xe=n.as(jd),!(Te=xe.event).isGroupChannelEvent){r.next=325;break}r.t3=Te.category,r.next=r.t3===nd.CHANNEL_JOIN?158:r.t3===nd.CHANNEL_LEAVE?167:r.t3===nd.CHANNEL_OPERATOR_UPDATE?183:r.t3===nd.CHANNEL_INVITE?194:r.t3===nd.CHANNEL_DECLINE_INVITE?204:r.t3===nd.TYPING_START||r.t3===nd.TYPING_END?212:r.t3===nd.USER_CHANNEL_MUTE||r.t3===nd.USER_CHANNEL_UNMUTE?221:r.t3===nd.USER_CHANNEL_BAN?248:r.t3===nd.USER_CHANNEL_UNBAN?261:r.t3===nd.CHANNEL_FREEZE||r.t3===nd.CHANNEL_UNFREEZE?267:r.t3===nd.CHANNEL_HIDE?275:r.t3===nd.CHANNEL_UNHIDE?285:r.t3===nd.CHANNEL_DELETED?292:r.t3===nd.CHANNEL_PROP_CHANGED?298:r.t3===nd.CHANNEL_META_DATA_CHANGED?304:r.t3===nd.CHANNEL_META_COUNTERS_CHANGED?313:r.t3===nd.PINNED_MESSAGE_CHANGED?319:325;break;case 158:return r.next=160,this.getChannel(Te.channelUrl,!0);case 160:return Se=r.sent,Ie=n.as(Bd),Ne=Ie.memberCount,Ae=Ie.joinedMemberCount,Me=Ie.members,Oe=!1,Me.forEach((function(t){Se.isExclusive||Se.isSuper||Se.isBroadcast?Oe=Oe||Se._setLatestMemberCount(Ne,Ae,Te.ts):(t.state=e.MemberState.JOINED,Se.addMember(t,Te.ts),cn._updateJoinedMemberCount(Se)),t.userId===cn._sdkState.userId&&(Se.myMemberState=e.MemberState.JOINED)})),this._dispatcher.dispatch(new ru({channels:[Se],source:e.GroupChannelEventSource.EVENT_CHANNEL_JOINED})),ua((function(){return b(cn,void 0,void 0,t().mark((function e(){return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:this._groupChannelHandlers.forEach((function(e){var t,n=y(Me);try{for(n.s();!(t=n.n()).done;){var r=t.value;e.onUserJoined(Se,r)}}catch(e){n.e(e)}finally{n.f()}Se.isBroadcast&&Oe&&e.onChannelMemberCountChanged([Se])}));case 1:case"end":return e.stop()}}),e,this)})))})),r.abrupt("break",325);case 167:if(!(Ue=this._leftChannels.get(Te.channelUrl))){r.next=172;break}r.t4=Ue.channel,r.next=175;break;case 172:return r.next=174,this.getChannel(Te.channelUrl,!0);case 174:r.t4=r.sent;case 175:return Re=r.t4,Le=n.as(Kd),De=Le.memberCount,Pe=Le.joinedMemberCount,Fe=Le.member,Ge=!1,He=ns.of(this._iid),qe=He.appInfo,Re.isExclusive||Re.isSuper||Re.isBroadcast?Ge=Re._setLatestMemberCount(De,Pe,Te.ts):(qe.enabledChannelMemberShipHistory?(Re.members.find((function(e){return e.userId===Fe.userId})).state=e.MemberState.LEFT,Re.memberCount=De):Re.removeMember(Fe),this._updateJoinedMemberCount(Re)),Fe.userId===this._sdkState.userId?(Re.myMemberState=e.MemberState.NONE,Re.invitedAt=0,Re.joinedAt=0,Re._updateUnreadCount(0,0),Re.isPublic?this._dispatcher.dispatch(new ru({channels:[Re],source:e.GroupChannelEventSource.EVENT_CHANNEL_LEFT})):(this._markAsLeave(Re),this._dispatcher.dispatch(new au({channelUrls:[Re.url],source:e.GroupChannelEventSource.EVENT_CHANNEL_LEFT})))):this._dispatcher.dispatch(new ru({channels:[Re],source:e.GroupChannelEventSource.EVENT_CHANNEL_LEFT})),ua((function(){return b(cn,void 0,void 0,t().mark((function e(){return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:this._groupChannelHandlers.forEach((function(e){e.onUserLeft(Re,Fe),Re.isBroadcast&&Ge&&e.onChannelMemberCountChanged([Re])}));case 1:case"end":return e.stop()}}),e,this)})))})),r.abrupt("break",325);case 183:return r.next=185,this.getChannel(Te.channelUrl,!0);case 185:je=r.sent,ze=n.as(hf),Ve=ze.operators,Be=Ve.map((function(e){return e.userId})),Qe=y(je.members);try{for(Qe.s();!(Ke=Qe.n()).done;)(We=Ke.value).role=Be.includes(We.userId)?e.Role.OPERATOR:e.Role.NONE}catch(e){Qe.e(e)}finally{Qe.f()}return je.myRole=Be.includes(this._sdkState.userId)?e.Role.OPERATOR:e.Role.NONE,this._dispatcher.dispatch(new ru({channels:[je],source:e.GroupChannelEventSource.EVENT_CHANNEL_OPERATOR_UPDATED})),ua((function(){return b(cn,void 0,void 0,t().mark((function e(){return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:this._groupChannelHandlers.forEach((function(e){e.onOperatorUpdated(je,Ve)}));case 1:case"end":return e.stop()}}),e,this)})))})),r.abrupt("break",325);case 194:return r.next=196,this.getChannel(Te.channelUrl,!0);case 196:Ye=r.sent,Ze=n.as(Zd),Je=Ze.memberCount,Xe=Ze.joinedMemberCount,$e=Ze.inviter,(et=Ze.invitees).forEach((function(t){return t.state=e.MemberState.INVITED})),tt=y(et);try{for(tt.s();!(nt=tt.n()).done;)rt=nt.value,Ye.isExclusive||Ye.isSuper||Ye.isBroadcast?Ye._setLatestMemberCount(Je,Xe,Te.ts):Ye.addMember(rt,Te.ts),this._sdkState.userId===rt.userId&&(Ye.hiddenState=e.HiddenState.UNHIDDEN,Ye.myMemberState!==e.MemberState.JOINED&&(Ye.myMemberState=e.MemberState.INVITED),Ye.invitedAt=Te.ts)}catch(e){tt.e(e)}finally{tt.f()}return this._dispatcher.dispatch(new ru({channels:[Ye],source:e.GroupChannelEventSource.EVENT_CHANNEL_INVITED})),ua((function(){return b(cn,void 0,void 0,t().mark((function e(){return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:this._groupChannelHandlers.forEach((function(e){e.onUserReceivedInvitation(Ye,$e,et)}));case 1:case"end":return e.stop()}}),e,this)})))})),r.abrupt("break",325);case 204:return r.next=206,this.getChannel(Te.channelUrl,!0);case 206:return at=r.sent,st=n.as(Xd),it=st.memberCount,ot=st.joinedMemberCount,ut=st.inviter,ct=st.invitee,at.isExclusive||at.isSuper||at.isBroadcast?at._setLatestMemberCount(it,ot,Te.ts):at.removeMember(ct),this._sdkState.userId===ct.userId?(at.invitedAt=0,at.myMemberState=e.MemberState.NONE,at.isPublic?this._dispatcher.dispatch(new ru({channels:[at],source:e.GroupChannelEventSource.EVENT_CHANNEL_DECLINED_INVITE})):this._dispatcher.dispatch(new au({channelUrls:[at.url],source:e.GroupChannelEventSource.EVENT_CHANNEL_DECLINED_INVITE}))):this._dispatcher.dispatch(new ru({channels:[at],source:e.GroupChannelEventSource.EVENT_CHANNEL_DECLINED_INVITE})),ua((function(){return b(cn,void 0,void 0,t().mark((function e(){return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:this._groupChannelHandlers.forEach((function(e){e.onUserDeclinedInvitation(at,ut,ct)}));case 1:case"end":return e.stop()}}),e,this)})))})),r.abrupt("break",325);case 212:return r.next=214,this.getChannel(Te.channelUrl,!0);case 214:return lt=r.sent,ht=Te.category===nd.TYPING_START,dt=n.as(ht?uf:lf),ft=dt.user,lt._updateTypingStatus(ft,ht?Te.ts:0),this._dispatcher.dispatch(new ru({channels:[lt],source:e.GroupChannelEventSource.EVENT_CHANNEL_TYPING_STATUS_UPDATE})),ua((function(){return b(cn,void 0,void 0,t().mark((function e(){return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:this._groupChannelHandlers.forEach((function(e){e.onTypingStatusUpdated(lt)}));case 1:case"end":return e.stop()}}),e,this)})))})),r.abrupt("break",325);case 221:return r.next=223,this.getChannel(Te.channelUrl,!0);case 223:pt=r.sent,vt=Te.category===nd.USER_CHANNEL_MUTE,_t=n.as(vt?eh:nh),(mt=_t.user).userId===this._sdkState.userId&&(pt.myMutedState=vt?e.MutedState.MUTED:e.MutedState.UNMUTED,pt._myMutedRemainingTime=mt.restrictionInfo.remainingDuration),gt=y(pt.members),r.prev=228,gt.s();case 230:if((yt=gt.n()).done){r.next=237;break}if((kt=yt.value).userId!==mt.userId){r.next=235;break}return kt.isMuted=vt,r.abrupt("break",237);case 235:r.next=230;break;case 237:r.next=242;break;case 239:r.prev=239,r.t5=r.catch(228),gt.e(r.t5);case 242:return r.prev=242,gt.f(),r.finish(242);case 245:return this._dispatcher.dispatch(new ru({channels:[pt],source:vt?e.GroupChannelEventSource.EVENT_CHANNEL_MUTED:e.GroupChannelEventSource.EVENT_CHANNEL_UNMUTED,data:mt.userId})),ua((function(){return b(cn,void 0,void 0,t().mark((function e(){return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:this._groupChannelHandlers.forEach((function(e){vt?e.onUserMuted(pt,mt):e.onUserUnmuted(pt,mt)}));case 1:case"end":return e.stop()}}),e,this)})))})),r.abrupt("break",325);case 248:if(!(bt=this._leftChannels.get(Te.channelUrl))){r.next=253;break}r.t6=bt.channel,r.next=256;break;case 253:return r.next=255,this.getChannel(Te.channelUrl,!0);case 255:r.t6=r.sent;case 256:return Et=r.t6,this._markAsLeave(Et),wt=n.as(ah),Ct=wt.user,ua((function(){return b(cn,void 0,void 0,t().mark((function e(){return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:this._groupChannelHandlers.forEach((function(e){e.onUserBanned(Et,Ct)}));case 1:case"end":return e.stop()}}),e,this)})))})),r.abrupt("break",325);case 261:return r.next=263,this.getChannel(Te.channelUrl,!0);case 263:return xt=r.sent,Tt=n.as(ih),St=Tt.user,ua((function(){return b(cn,void 0,void 0,t().mark((function e(){return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:this._groupChannelHandlers.forEach((function(e){e.onUserUnbanned(xt,St)}));case 1:case"end":return e.stop()}}),e,this)})))})),r.abrupt("break",325);case 267:return r.next=269,this.getChannel(Te.channelUrl,!0);case 269:return It=r.sent,Nt=n.as(uh),At=Nt.freeze,It.isFrozen=At,this._dispatcher.dispatch(new ru({channels:[It],source:At?e.GroupChannelEventSource.EVENT_CHANNEL_FROZEN:e.GroupChannelEventSource.EVENT_CHANNEL_UNFROZEN})),ua((function(){return b(cn,void 0,void 0,t().mark((function e(){return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:this._groupChannelHandlers.forEach((function(e){At?e.onChannelFrozen(It):e.onChannelUnfrozen(It)}));case 1:case"end":return e.stop()}}),e,this)})))})),r.abrupt("break",325);case 275:return r.next=277,this.getChannel(Te.channelUrl,!0);case 277:return Mt=r.sent,Ot=n.as(sf),Ut=Ot.allowAutoUnhide,Rt=Ot.hidePreviousMessages,Lt=Ot.messageOffsetTimestamp,null!==Ut&&(Mt.hiddenState=Ut?e.HiddenState.HIDDEN_ALLOW_AUTO_UNHIDE:e.HiddenState.HIDDEN_PREVENT_AUTO_UNHIDE),null!==Rt&&Rt&&Mt._updateUnreadCount(0,0),null!==Lt&&(Mt.messageOffsetTimestamp=Lt),this._dispatcher.dispatch(new ru({channels:[Mt],source:e.GroupChannelEventSource.EVENT_CHANNEL_HIDDEN})),ua((function(){return b(cn,void 0,void 0,t().mark((function e(){return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:this._groupChannelHandlers.forEach((function(e){e.onChannelHidden(Mt)}));case 1:case"end":return e.stop()}}),e,this)})))})),r.abrupt("break",325);case 285:return r.next=287,this.getChannel(Te.channelUrl,!0);case 287:return(Dt=r.sent).hiddenState=e.HiddenState.UNHIDDEN,this._dispatcher.dispatch(new ru({channels:[Dt],source:e.GroupChannelEventSource.EVENT_CHANNEL_UNHIDDEN})),ua((function(){return b(cn,void 0,void 0,t().mark((function e(){return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:this._groupChannelHandlers.forEach((function(e){e.onChannelChanged(Dt)}));case 1:case"end":return e.stop()}}),e,this)})))})),r.abrupt("break",325);case 292:return r.next=294,this.getChannel(Te.channelUrl,!0);case 294:return Pt=r.sent,this._dispatcher.dispatch(new au({channelUrls:[Te.channelUrl],source:e.GroupChannelEventSource.EVENT_CHANNEL_DELETED})),ua((function(){return b(cn,void 0,void 0,t().mark((function e(){return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:this._groupChannelHandlers.forEach((function(e){e.onChannelDeleted(Pt.url,Pt.channelType)}));case 1:case"end":return e.stop()}}),e,this)})))})),r.abrupt("break",325);case 298:return r.next=300,this.getChannelWithoutCache(Te.channelUrl,!0);case 300:return Ft=r.sent,this._dispatcher.dispatch(new ru({channels:[Ft],source:e.GroupChannelEventSource.EVENT_CHANNEL_UPDATED})),ua((function(){return b(cn,void 0,void 0,t().mark((function e(){return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:this._groupChannelHandlers.forEach((function(e){e.onChannelChanged(Ft)}));case 1:case"end":return e.stop()}}),e,this)})))})),r.abrupt("break",325);case 304:return r.next=306,this.getChannel(Te.channelUrl,!0);case 306:return Gt=r.sent,Ht=n.as(Gl),qt=Ht.created,jt=Ht.updated,zt=Ht.deleted,qt&&Gt._upsertCachedMetaData(qt,Te.ts),jt&&Gt._upsertCachedMetaData(jt,Te.ts),zt&&Gt._removeFromCachedMetaData(zt,Te.ts),ua((function(){return b(cn,void 0,void 0,t().mark((function e(){return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:this._groupChannelHandlers.forEach((function(e){qt&&e.onMetaDataCreated(Gt,qt),jt&&e.onMetaDataUpdated(Gt,jt),zt&&e.onMetaDataDeleted(Gt,zt)}));case 1:case"end":return e.stop()}}),e,this)})))})),r.abrupt("break",325);case 313:return r.next=315,this.getChannel(Te.channelUrl,!0);case 315:return Vt=r.sent,Bt=n.as(Zl),Qt=Bt.created,Kt=Bt.updated,Wt=Bt.deleted,ua((function(){return b(cn,void 0,void 0,t().mark((function e(){return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:this._groupChannelHandlers.forEach((function(e){Qt&&e.onMetaCounterCreated(Vt,Qt),Kt&&e.onMetaCounterUpdated(Vt,Kt),Wt&&e.onMetaCounterDeleted(Vt,Wt)}));case 1:case"end":return e.stop()}}),e,this)})))})),r.abrupt("break",325);case 319:return r.next=321,this.getChannel(Te.channelUrl,!0);case 321:return Yt=r.sent,Zt=n.as(bf),Jt=Zt.pinnedMessageIds,Xt=Zt.latestPinnedMessage,($t=Zt.ts)>Yt._pinnedMessagesUpdatedAt&&(Yt.pinnedMessageIds=Jt,Yt.lastPinnedMessage=Xt,Yt._pinnedMessagesUpdatedAt=$t,this._dispatcher.dispatch(new ru({channels:[Yt],source:e.GroupChannelEventSource.EVENT_PINNED_MESSAGE_UPDATED})),ua((function(){return b(cn,void 0,void 0,t().mark((function e(){var n,r;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:n=y(this._groupChannelHandlers.values());try{for(n.s();!(r=n.n()).done;)r.value.onChannelChanged(Yt)}catch(e){n.e(e)}finally{n.f()}case 2:case"end":return e.stop()}}),e,this)})))})),ua((function(){return b(cn,void 0,void 0,t().mark((function e(){return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:this._groupChannelHandlers.forEach((function(e){e.onPinnedMessageUpdated(Yt)}));case 1:case"end":return e.stop()}}),e,this)})))}))),r.abrupt("break",325);case 325:return r.abrupt("break",337);case 326:en=n.as(iu),tn=en.event,r.t7=tn.category,r.next=r.t7===Lo.USER_BLOCK?330:r.t7===Lo.USER_UNBLOCK?333:336;break;case 330:return nn=$o.getDataAsUserBlockEvent(this._iid,tn),rn=nn.blocker,an=nn.blockee,this._groupChannelCache.block(rn.userId,an.userId),r.abrupt("break",336);case 333:return sn=$o.getDataAsUserBlockEvent(this._iid,tn),on=sn.blocker,un=sn.blockee,this._groupChannelCache.unblock(on.userId,un.userId),r.abrupt("break",336);case 336:return r.abrupt("break",337);case 337:r.next=343;break;case 339:if(r.prev=339,r.t8=r.catch(0),!A(r.t8)){r.next=343;break}throw r.t8;case 343:case"end":return r.stop()}}),r,this,[[0,339],[19,30,33,36],[114,127,130,133],[228,239,242,245]])})))}},{key:"_markAsLeave",value:function(e){var t,n=this,r=null!==(t=this._leftChannels.get(e.url))&&void 0!==t?t:{channel:e,ref:0};r.ref++,this._leftChannels.set(e.url,r),setTimeout((function(){r.ref--,0===r.ref&&n._leftChannels.delete(e.url)}),1e4)}},{key:"addHandler",value:function(e,t){this._groupChannelHandlers.set(e,t)}},{key:"removeHandler",value:function(e){this._groupChannelHandlers.delete(e)}},{key:"clearHandler",value:function(){this._groupChannelHandlers.clear()}},{key:"subscribeGroupChannelEvent",value:function(e,t){this._groupChannelBroadcast.subscribe(e,t)}},{key:"unsubscribeGroupChannelEvent",value:function(e){this._groupChannelBroadcast.unsubscribe(e)}},{key:"subscribeMessageEvent",value:function(e,t){this._messageBroadcast.subscribe(e,t)}},{key:"unsubscribeMessageEvent",value:function(e){this._messageBroadcast.unsubscribe(e)}},{key:"_updateJoinedMemberCount",value:function(t){t.joinedMemberCount=t.members.filter((function(t){return t.state===e.MemberState.JOINED})).length}},{key:"getChannel",value:function(e){var n=arguments.length>1&&void 0!==arguments[1]&&arguments[1];return b(this,void 0,void 0,t().mark((function r(){var a;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return Ua(L("string",e)).throw(M.invalidParameters),t.prev=1,t.next=4,this.getChannelFromCache(e);case 4:if(!(a=t.sent)){t.next=7;break}return t.abrupt("return",a);case 7:t.next=11;break;case 9:t.prev=9,t.t0=t.catch(1);case 11:return t.next=13,this.getChannelWithoutCache(e,n);case 13:return t.abrupt("return",t.sent);case 14:case"end":return t.stop()}}),r,this,[[1,9]])})))}},{key:"getChannelWithoutCache",value:function(n){var r=arguments.length>1&&void 0!==arguments[1]&&arguments[1];return b(this,void 0,void 0,t().mark((function a(){var s,i,o,u,c,l;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return Ua(L("string",n)).throw(M.invalidParameters),s=new Cd({channelUrl:n,isInternalCall:r}),t.next=4,this._requestQueue.send(s);case 4:i=t.sent,o=i.as(xd),u=o.channel,c=u.unreadMessageCount,l=u.unreadMentionCount,t.t0=u.myCountPreference,t.next=t.t0===e.CountPreference.UNREAD_MESSAGE_COUNT_ONLY?10:t.t0===e.CountPreference.UNREAD_MENTION_COUNT_ONLY?12:t.t0===e.CountPreference.OFF?14:17;break;case 10:return l=0,t.abrupt("break",17);case 12:return c=0,t.abrupt("break",17);case 14:return c=0,l=0,t.abrupt("break",17);case 17:return u._updateUnreadCount(c,l),t.next=20,this.upsertChannelsToCache([u]);case 20:return t.abrupt("return",u);case 21:case"end":return t.stop()}}),a,this)})))}},{key:"refreshChannel",value:function(n){var r=!(arguments.length>1&&void 0!==arguments[1])||arguments[1],a=arguments.length>2&&void 0!==arguments[2]?arguments[2]:e.GroupChannelEventSource.REFRESH_CHANNEL;return b(this,void 0,void 0,t().mark((function s(){var i,o,u,c;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.prev=0,i=new Cd({channelUrl:n,isInternalCall:r}),t.next=4,this._requestQueue.send(i);case 4:o=t.sent,u=o.as(xd),(c=u.channel).myMemberState===e.MemberState.NONE?this._dispatcher.dispatch(new au({channelUrls:[c.url],source:a})):this._dispatcher.dispatch(new ru({channels:[c],source:a})),t.next=12;break;case 9:t.prev=9,t.t0=t.catch(0),t.t0.code!==E.NON_AUTHORIZED&&t.t0.code!==E.NOT_FOUND_IN_DATABASE||this._dispatcher.dispatch(new au({channelUrls:[n],source:a}));case 12:case"end":return t.stop()}}),s,this,[[0,9]])})))}},{key:"getMyGroupChannels",value:function(n,r,a){var s=arguments.length>3&&void 0!==arguments[3]?arguments[3]:e.GroupChannelEventSource.REQUEST_CHANNEL;return b(this,void 0,void 0,t().mark((function e(){var i,o,u,c,l;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return i=new Td(Object.assign(Object.assign({},r),{userId:this._sdkState.userId,token:n,limit:a})),e.next=3,this._requestQueue.send(i);case 3:return o=e.sent,u=o.as(Sd),c=u.channels,l=u.token,this._dispatcher.dispatch(new ru({channels:c,source:s})),e.abrupt("return",{channels:c,token:l});case 7:case"end":return e.stop()}}),e,this)})))}},{key:"getMessageFromCache",value:function(e){return b(this,void 0,void 0,t().mark((function n(){return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,this._messageCache.get(e);case 2:return t.abrupt("return",t.sent);case 3:case"end":return t.stop()}}),n,this)})))}},{key:"getMessagesFromCache",value:function(e,n,r,a){var s=arguments.length>4&&void 0!==arguments[4]?arguments[4]:co;return b(this,void 0,void 0,t().mark((function i(){return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,this._messageCache.fetch({channelUrl:e,token:n,limit:s,filter:a,backward:"next"===r});case 2:return t.abrupt("return",t.sent);case 3:case"end":return t.stop()}}),i,this)})))}},{key:"getPollMessagesFromCache",value:function(e,n,r){var a=arguments.length>3&&void 0!==arguments[3]?arguments[3]:co;return b(this,void 0,void 0,t().mark((function s(){return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,this._messageCache.fetch({channelUrl:e,token:n,limit:a,filter:r,backward:!1,isPollOnly:!0});case 2:return t.abrupt("return",t.sent);case 3:case"end":return t.stop()}}),s,this)})))}},{key:"getUnsentMessagesFromCache",value:function(e,n){return b(this,void 0,void 0,t().mark((function r(){return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,this._unsentMessageCache.fetch({channelUrl:e,filter:n});case 2:return t.abrupt("return",t.sent);case 3:case"end":return t.stop()}}),r,this)})))}},{key:"removeFailedMessageFromCache",value:function(e){return b(this,void 0,void 0,t().mark((function n(){return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,this._unsentMessageCache.remove([e]);case 2:case"end":return t.stop()}}),n,this)})))}},{key:"getCachedMessageCountBetween",value:function(e,n,r,a){return b(this,void 0,void 0,t().mark((function s(){return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,this._messageCache.countBetween(e,n,new kf({top:r,bottom:a}));case 2:return t.abrupt("return",t.sent);case 3:case"end":return t.stop()}}),s,this)})))}},{key:"getMyGroupChannelChangeLogs",value:function(n,r){var a=arguments.length>2&&void 0!==arguments[2]?arguments[2]:e.GroupChannelEventSource.REQUEST_CHANNEL_CHANGELOGS;return b(this,void 0,void 0,t().mark((function e(){var s,i,o,u,c,l,h;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return s=Object.assign(Object.assign({},cd),r),Ua((L("string",n)||L("number",n))&&ld(s)).throw(M.invalidParameters),i=new Ed(ee({userId:this._sdkState.userId,ts:"number"==typeof n?n:null,token:"string"==typeof n?n:null,filter:s})),e.next=5,this._requestQueue.send(i);case 5:return o=e.sent,u=o.as(wd),c=u.updatedChannels,l=u.deletedChannelUrls,h=u.hasMore,c.length>0&&this._dispatcher.dispatch(new ru({channels:c,source:a})),l.length>0&&this._dispatcher.dispatch(new au({channelUrls:l,source:a})),e.abrupt("return",{updatedChannels:c,deletedChannelUrls:l,hasMore:h,token:u.token});case 11:case"end":return e.stop()}}),e,this)})))}},{key:"getGroupChannelCount",value:function(e){return b(this,void 0,void 0,t().mark((function n(){var r,a,s,i,o;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return r=Object.assign(Object.assign({},hd),e),Ua(dd(r)).throw(M.invalidParameters),a=new Id({userId:this._sdkState.userId,filter:r}),t.next=5,this._requestQueue.send(a);case 5:return s=t.sent,i=s.as(Nd),o=i.groupChannelCount,t.abrupt("return",o);case 8:case"end":return t.stop()}}),n,this)})))}},{key:"getUnreadItemCount",value:function(e){return b(this,void 0,void 0,t().mark((function n(){var r,a,s,i,o,u,c,l,h,d,f,p,v,_,m,g;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return r=Object.assign(Object.assign({},pd),e),Ua(vd(r)).throw(M.invalidParameters),a=ns.of(this._iid),s=a.sdkState,i=a.requestQueue,o=new Ad({userId:s.userId,filter:r}),t.next=6,i.send(o);case 6:return u=t.sent,c=u.as(Md),l=c.groupChannelUnreadMentionCount,h=c.groupChannelUnreadMessageCount,d=c.groupChannelInvitationCount,f=c.superGroupChannelUnreadMentionCount,p=c.superGroupChannelUnreadMessageCount,v=c.superGroupChannelInvitationCount,_=c.nonSuperGroupChannelUnreadMentionCount,m=c.nonSuperGroupChannelUnreadMessageCount,g=c.nonSuperGroupChannelInvitationCount,t.abrupt("return",ee({groupChannelUnreadMentionCount:l,groupChannelUnreadMessageCount:h,groupChannelInvitationCount:d,superGroupChannelUnreadMentionCount:f,superGroupChannelUnreadMessageCount:p,superGroupChannelInvitationCount:v,nonSuperGroupChannelUnreadMentionCount:_,nonSuperGroupChannelUnreadMessageCount:m,nonSuperGroupChannelInvitationCount:g}));case 9:case"end":return t.stop()}}),n,this)})))}},{key:"getTotalUnreadChannelCount",value:function(){return b(this,void 0,void 0,t().mark((function e(){var n,r,a,s,i,o,u;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n=ns.of(this._iid),r=n.sdkState,a=n.requestQueue,s=new Od({userId:r.userId}),e.next=4,a.send(s);case 4:return i=e.sent,o=i.as(Ud),u=o.unreadCount,e.abrupt("return",u);case 7:case"end":return e.stop()}}),e,this)})))}},{key:"getTotalUnreadMessageCount",value:function(e){return b(this,void 0,void 0,t().mark((function n(){var r,a,s,i,o,u,c,l;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return r=Object.assign(Object.assign({},_d),e),Ua(md(r)).throw(M.invalidParameters),a=ns.of(this._iid),s=a.sdkState,i=a.requestQueue,o=new Rd({userId:s.userId,filter:r}),t.next=6,i.send(o);case 6:return u=t.sent,c=u.as(Ld),l=c.unreadCount,t.abrupt("return",l);case 9:case"end":return t.stop()}}),n,this)})))}},{key:"getTotalScheduledMessageCount",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return b(this,void 0,void 0,t().mark((function n(){var r,a,s,i,o,u,c;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return r=Object.assign(Object.assign({},gd),e),Ua(yd(r)).throw(M.invalidParameters),a=ns.of(this._iid),s=a.requestQueue,i=new Dd(r),t.next=6,s.send(i);case 6:return o=t.sent,u=o.as(Pd),c=u.count,t.abrupt("return",c);case 9:case"end":return t.stop()}}),n,this)})))}},{key:"getSubscribedTotalUnreadMessageCount",value:function(){var e=ns.of(this._iid).subscribedUnreadMessageCount;return e.all>=0?e.all:0}},{key:"getSubscribedCustomTypeTotalUnreadMessageCount",value:function(){var e=0,t=ns.of(this._iid).subscribedUnreadMessageCount;for(var n in t.customTypes)e+=t.customTypes[n];return e}},{key:"getSubscribedCustomTypeUnreadMessageCount",value:function(e){var t;return null!==(t=ns.of(this._iid).subscribedUnreadMessageCount.customTypes[e])&&void 0!==t?t:0}},{key:"createChannel",value:function(e){return b(this,void 0,void 0,t().mark((function n(){var r,a,s,i,o;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return r=Object.assign(Object.assign({},od),e),Ua(ud(r)).throw(M.invalidParameters),r.isPublic||(r.accessCode=null),a=new Gd(Object.assign({userId:this._sdkState.userId},r)),t.next=6,this._requestQueue.send(a);case 6:return s=t.sent,i=s.as(Hd),o=i.channel,t.next=10,this.upsertChannelsToCache([o]);case 10:return t.abrupt("return",o);case 11:case"end":return t.stop()}}),n,this)})))}},{key:"markAsReadAll",value:function(){return b(this,void 0,void 0,t().mark((function e(){var n,r,a,s,i,o;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n=Date.now(),Ua(n-this._markAsReadAllLastSentAt>=1e3).throw(M.markAsReadAllRateLimitExceeded),this._markAsReadAllLastSentAt=n,r=new qd({userId:this._sdkState.userId}),e.next=6,this._requestQueue.send(r);case 6:a=this._groupChannelCache.channels,s=y(a);try{for(s.s();!(i=s.n()).done;)(o=i.value)._updateUnreadMemberState(this._sdkState.userId,n),o._updateUnreadCount(0,0)}catch(e){s.e(e)}finally{s.f()}if(!(a.length>0)){e.next=12;break}return e.next=12,this.upsertChannelsToCache(a);case 12:case"end":return e.stop()}}),e,this)})))}},{key:"markAsReadWithChannelUrls",value:function(e){return b(this,void 0,void 0,t().mark((function n(){var r,a,s,i,o,u,c;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return r=Date.now(),Ua(F("string",e)&&r-this._markAsReadAllLastSentAt>=1e3).throw(M.markAsReadAllRateLimitExceeded),this._markAsReadAllLastSentAt=r,a=new qd({userId:this._sdkState.userId,channelUrls:e}),t.next=6,this._requestQueue.send(a);case 6:s=this._groupChannelCache.channels,i=[],o=y(s);try{for(o.s();!(u=o.n()).done;)c=u.value,e.includes(c.url)&&(c._updateUnreadMemberState(this._sdkState.userId,r),c._updateUnreadCount(0,0),i.push(c))}catch(e){o.e(e)}finally{o.f()}if(!(i.length>0)){t.next=13;break}return t.next=13,this.upsertChannelsToCache(i);case 13:case"end":return t.stop()}}),n,this)})))}},{key:"markAsDelivered",value:function(e){return b(this,void 0,void 0,t().mark((function n(){var r;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,this.getChannel(e);case 2:return r=t.sent,t.next=5,r.markAsDelivered();case 5:case"end":return t.stop()}}),n,this)})))}}],[{key:"of",value:function(e){return Ef[e]}},{key:"clear",value:function(e){Ef[e]&&delete Ef[e]}}]),n}();!function(e){e[e.IDLE=0]="IDLE",e[e.RUNNING=1]="RUNNING",e[e.END=2]="END"}(fd||(fd={}));var Cf=function(e){i(a,e);var n=f(a);function a(e,t){var s;return r(this,a),(s=n.call(this))._worker=null,s._state=fd.IDLE,s._semaphore=null,s._retryCount=0,s._retryLimit=3,s.priority=0,s._worker=t,s}return s(a,[{key:"isIdle",get:function(){return this._state===fd.IDLE}},{key:"isRunning",get:function(){return this._state===fd.RUNNING}},{key:"isDone",get:function(){return this._state===fd.END}},{key:"retryCount",get:function(){return this._retryCount}},{key:"retryLimit",get:function(){return this._retryLimit}},{key:"_run",value:function(e){return b(this,void 0,void 0,t().mark((function n(){var r;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(!this.isRunning){t.next=14;break}return t.prev=1,t.next=4,this._worker(e);case 4:r=t.sent,this._retryCount=0,this.dispatch("progress",r),r.hasNext?this._run(r.nextToken):this.end(),t.next=14;break;case 10:t.prev=10,t.t0=t.catch(1),this.dispatch("error",t.t0),this._retryCount0&&(l=u.map((function(e){return e.createdAt})),(c=this._metadata.range).intersect.apply(c,_(l))?this.extendRange(u):this._metadata={range:new kf({top:Math.min.apply(Math,_(l)),bottom:Math.max.apply(Math,_(l))}),previousComplete:!1}),i.hasNext=u.length>=this._limit&&this._prevSyncLoopCount<1,i.nextToken=this._metadata.range.top,this._metadata.previousComplete=u.length0&&(l=u.map((function(e){return e.createdAt})),(c=this._metadata.range).intersect.apply(c,_(l))?this.extendRange(u):this._metadata={range:new kf({top:Math.min.apply(Math,_(l)),bottom:Math.max.apply(Math,_(l))}),previousComplete:!1}),i.hasNext=u.length>=this._limit&&this._nextSyncLoopCount<1,i.nextToken=this._metadata.range.bottom,v.debug("message background next sync progress",i),t.next=16,this.saveMetadata();case 16:t.next=22;break;case 18:throw t.prev=18,t.t0=t.catch(5),v.debug("message background next sync error",t.t0),t.t0;case 22:return t.abrupt("return",i);case 23:case"end":return t.stop()}}),r,this,[[5,18]])})))})),this._connectionEventContext=p.on((function(e){if(e instanceof Dr)if(e.stateType===Nr.CONNECTED)s.resume();else s.pause()}))}return s(n,[{key:"range",get:function(){var e;return null===(e=this._metadata)||void 0===e?void 0:e.range}},{key:"previousComplete",get:function(){var e;return!!(null===(e=this._metadata)||void 0===e?void 0:e.previousComplete)}},{key:"isWrappingMessages",value:function(e){var t,n;return null===(n=this.range)||void 0===n?void 0:(t=n).includes.apply(t,_(e.map((function(e){return e.createdAt}))))}},{key:"extendRange",value:function(e){var t;this._metadata&&(t=this._metadata.range).extends.apply(t,_(e.map((function(e){return e.createdAt}))))}},{key:"loadMetadata",value:function(e){return b(this,void 0,void 0,t().mark((function n(){var r,a,s;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(this._metadata){t.next=6;break}return r=ns.of(this._iid),a=r.cacheContext,t.next=4,a.preference.get(this._metadataKey);case 4:(s=t.sent)?s.range.bottom0&&void 0!==arguments[0]?arguments[0]:Date.now(),s=ns.of(this._iid),i=s.logger;s.connectionManager.isConnected&&(i.debug("message background sync resume()"),this._prevSyncLoopCount=this._nextSyncLoopCount=0,this._metadata&&this._metadata.previousComplete||this._prevSync.start(null!==(t=null===(e=this._metadata)||void 0===e?void 0:e.range.top)&&void 0!==t?t:a),this._nextSync.start(null!==(r=null===(n=this._metadata)||void 0===n?void 0:n.range.bottom)&&void 0!==r?r:a))}},{key:"pause",value:function(){ns.of(this._iid).logger.debug("message background sync stop()"),this._prevSync.stop(),this._nextSync.stop()}},{key:"close",value:function(){this.ref--,this.ref<=0&&(this.ref=0,this.pause(),this._connectionEventContext.close(),delete Sf[this._iid][this._channel.url])}}],[{key:"of",value:function(e,t){return Sf[e]||(Sf[e]={}),Sf[e][t.url]||(Sf[e][t.url]=new n({_iid:e,channel:t})),Sf[e][t.url].ref++,Sf[e][t.url]}},{key:"clear",value:function(e,t){Sf[e]&&Sf[e][t]&&(Sf[e][t].close(),delete Sf[e])}}]),n}(),Nf={},Af=function(){function n(a){var s=this,i=a._iid,o=a.channel;r(this,n),this._sync=null,this._connectionEventContext=null,this.ref=0,this._metadata=null,this._iid=i,this._channel=o;var u,c,l=ns.of(this._iid),h=l.logger,d=l.sdkState,f=l.dispatcher;this._metadataKey=(u=d.userId,c=o.url,"sendbird:".concat(u,"@groupchannel/").concat(c,"/message/changelogs.meta"));var p=function(e,t){return"sendbird:".concat(e,"@groupchannel/").concat(t,"/message/changelogs")}(d.userId,this._channel.url);this._sync=new Cf(p,(function(){return b(s,void 0,void 0,t().mark((function n(){var r,a,s,i,o,u,c,l;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return a={hasNext:!0,nextToken:0},t.next=3,this.loadMetadata();case 3:return h.debug("message changelog sync from",null===(r=this._metadata)||void 0===r?void 0:r.token),t.prev=4,s=vi.of(this._iid),t.next=8,s.getMessageChangelogs(this._channel.url,this._channel.channelType,this._metadata.token,{replyType:e.ReplyType.ALL,includeReactions:!0,includeThreadInfo:!0,includeMetaArray:!0,includeParentMessageInfo:!0},e.MessageEventSource.SYNC_MESSAGE_CHANGELOGS);case 8:return i=t.sent,o=i.updatedMessages,u=i.deletedMessageIds,c=i.hasMore,l=i.token,a.hasNext=c,a.nextToken=l,(o.length>0||u.length>0)&&(this._metadata.token=l),h.debug("message changelog sync progress",a),t.next=19,this.saveMetadata();case 19:t.next=28;break;case 21:if(t.prev=21,t.t0=t.catch(4),h.debug("message changelog sync error",t.t0),!(t.t0 instanceof M&&t.t0.isInvalidTokenError)){t.next=27;break}return t.next=27,this.clearMetadata();case 27:throw t.t0;case 28:return t.abrupt("return",a);case 29:case"end":return t.stop()}}),n,this,[[4,21]])})))})),this._connectionEventContext=f.on((function(e){if(e instanceof Dr)if(e.stateType===Nr.CONNECTED)s.resume();else s.pause()}))}return s(n,[{key:"loadMetadata",value:function(){return b(this,void 0,void 0,t().mark((function e(){var n,r,a,s;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(this._metadata){e.next=6;break}return n=ns.of(this._iid),r=n.cacheContext,a=n.firstConnectedAt,e.next=4,r.preference.get(this._metadataKey);case 4:s=e.sent,this._metadata={token:s?s.token:a};case 6:return e.abrupt("return",this._metadata);case 7:case"end":return e.stop()}}),e,this)})))}},{key:"saveMetadata",value:function(){return b(this,void 0,void 0,t().mark((function e(){var n,r;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!this._metadata){e.next=5;break}return n=ns.of(this._iid),r=n.cacheContext,e.next=4,r.preference.set(this._metadataKey,this._metadata);case 4:return e.abrupt("return",!0);case 5:return e.abrupt("return",!1);case 6:case"end":return e.stop()}}),e,this)})))}},{key:"clearMetadata",value:function(){return b(this,void 0,void 0,t().mark((function e(){var n,r;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n=ns.of(this._iid),r=n.cacheContext,e.next=3,r.preference.remove(this._metadataKey);case 3:this._metadata=null;case 4:case"end":return e.stop()}}),e,this)})))}},{key:"resume",value:function(){var e=ns.of(this._iid),t=e.logger;e.connectionManager.isConnected&&(t.debug("message changelog sync resume()"),this._sync.start(0))}},{key:"pause",value:function(){var e=ns.of(this._iid),t=e.logger;e.connectionManager.isConnected&&(t.debug("message changelog sync pause()"),this._sync.stop())}},{key:"close",value:function(){this.ref--,this.ref<=0&&(this.ref=0,this.pause(),this._connectionEventContext.close(),delete Nf[this._iid][this._channel.url])}}],[{key:"of",value:function(e,t){return Nf[e]||(Nf[e]={}),Nf[e][t.url]||(Nf[e][t.url]=new n({_iid:e,channel:t})),Nf[e][t.url].ref++,Nf[e][t.url]}},{key:"clear",value:function(e,t){Nf[e]&&Nf[e][t]&&(Nf[e][t].close(),delete Nf[e])}}]),n}(),Mf={},Of=function(){function e(n){var a=this,s=n._iid,i=n.channel,o=n.hasPollMessage;r(this,e),this._sync=null,this.ref=0,this._metadata=null,this._iid=s,this._channel=i;var u,c,l=ns.of(this._iid),h=l.logger,d=l.sdkState,f=l.dispatcher;this._metadataKey=(u=d.userId,c=i.url,"sendbird:".concat(u,"@groupchannel/").concat(c,"/poll/changelogs.meta"));var p=function(e,t){return"sendbird:".concat(e,"@groupchannel/").concat(t,"/poll/changelogs")}(d.userId,this._channel.url);this._sync=new Cf(p,(function(){return b(a,void 0,void 0,t().mark((function e(){var n,r,a,s,i,u,c,l,d;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return r={hasNext:!0,nextToken:0},e.next=3,this.loadMetadata();case 3:if(h.debug("poll changelog sync from",null===(n=this._metadata)||void 0===n?void 0:n.token),e.t0=!this._metadata||!this._metadata.token,!e.t0){e.next=9;break}return e.next=8,o();case 8:e.t0=!e.sent;case 9:if(!e.t0){e.next=12;break}return a={hasNext:!1,nextToken:0},e.abrupt("return",a);case 12:return this._metadata||(s=ns.of(this._iid),i=s.firstConnectedAt,this._metadata={token:i}),e.prev=13,u=Ki.of(this._iid),e.next=17,u.getPollChangeLogs(this._channel.url,this._channel.channelType,this._metadata.token);case 17:return c=e.sent,l=c.hasMore,d=c.token,r.hasNext=l,r.nextToken=d,this._metadata.token=d,h.debug("poll changelog sync progress",r),e.next=26,this.saveMetadata();case 26:e.next=35;break;case 28:if(e.prev=28,e.t1=e.catch(13),h.debug("poll changelog sync error",e.t1),!(e.t1 instanceof M&&e.t1.isInvalidTokenError)){e.next=34;break}return e.next=34,this.clearMetadata();case 34:throw e.t1;case 35:return e.abrupt("return",r);case 36:case"end":return e.stop()}}),e,this,[[13,28]])})))})),this._connectionEventContext=f.on((function(e){if(e instanceof Dr)if(e.stateType===Nr.CONNECTED)a.resume();else a.pause()}))}return s(e,[{key:"loadMetadata",value:function(){return b(this,void 0,void 0,t().mark((function e(){var n,r,a;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(this._metadata){e.next=6;break}return n=ns.of(this._iid),r=n.cacheContext,e.next=4,r.preference.get(this._metadataKey);case 4:a=e.sent,this._metadata=a?{token:a.token}:null;case 6:case"end":return e.stop()}}),e,this)})))}},{key:"saveMetadata",value:function(){return b(this,void 0,void 0,t().mark((function e(){var n,r;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!this._metadata){e.next=4;break}return n=ns.of(this._iid),r=n.cacheContext,e.next=4,r.preference.set(this._metadataKey,this._metadata);case 4:case"end":return e.stop()}}),e,this)})))}},{key:"clearMetadata",value:function(){return b(this,void 0,void 0,t().mark((function e(){var n,r;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n=ns.of(this._iid),r=n.cacheContext,e.next=3,r.preference.remove(this._metadataKey);case 3:this._metadata=null;case 4:case"end":return e.stop()}}),e,this)})))}},{key:"resume",value:function(){ns.of(this._iid).logger.debug("poll changelog sync resume()"),this._sync.start(0)}},{key:"pause",value:function(){ns.of(this._iid).logger.debug("poll changelog sync pause()"),this._sync.stop()}},{key:"close",value:function(){this.ref--,this.ref<=0&&(this.ref=0,this.pause(),this._connectionEventContext.close(),delete Mf[this._iid][this._channel.url])}}],[{key:"of",value:function(t,n,r){return Mf[t]||(Mf[t]={}),Mf[t][n.url]||(Mf[t][n.url]=new e({_iid:t,channel:n,hasPollMessage:r})),Mf[t][n.url].ref++,Mf[t][n.url]}}]),e}(),Uf=function(e){i(n,e);var t=f(n);function n(e){var a,s,i,o,u,c,l;return r(this,n),(a=t.call(this)).method=B.GET,a.path="".concat(Fs(e.channelType),"/").concat(e.channelUrl,"/messages_gap"),a.params=ee({prev_start_ts:e.prevStart,prev_end_ts:e.prevEnd,prev_cache_count:e.prevCount,next_start_ts:e.nextStart,next_end_ts:e.nextEnd,next_cache_count:e.nextCount,huge_gap_threshold:null!==(s=e.threshold)&&void 0!==s?s:null,reverse:!0,custom_types:null!==(i=e.customTypes)&&void 0!==i?i:["*"],message_type:null!==(o=e.messageType)&&void 0!==o?o:null,include_reactions:null===(u=e.includeReactions)||void 0===u||u,with_sorted_meta_array:null===(c=e.includeMetaArray)||void 0===c||c,show_subchannel_messages_only:null!==(l=e.showSubchannelMessagesOnly)&&void 0!==l&&l,include_poll_details:!0,checking_continuous_messages:e.checkingContinuousMessages}),a}return s(n)}(ne),Rf=function(e){i(n,e);var t=f(n);function n(e,a){var s,i,o,u,c,l,h;return r(this,n),(s=t.call(this,e,a)).isHugeGap=a.is_huge_gap,s.prevMessages=(null!==(i=a.prev_messages)&&void 0!==i?i:[]).map((function(t){return Ds(e,t)})),s.prevHasMore=null!==(o=a.prev_hasmore)&&void 0!==o&&o,s.isContinuousPrevMessages=null!==(u=a.is_continuous_prev_messages)&&void 0!==u&&u,s.nextMessages=(null!==(c=a.next_messages)&&void 0!==c?c:[]).map((function(t){return Ds(e,t)})),s.nextHasmore=null!==(l=a.next_hasmore)&&void 0!==l&&l,s.isContinuousNextMessages=null!==(h=a.is_continuous_next_messages)&&void 0!==h&&h,s}return s(n)}(re),Lf=function(t,n){var r,a;switch(n){case e.GroupChannelListOrder.LATEST_LAST_MESSAGE:return null!==(a=null===(r=t.lastMessage)||void 0===r?void 0:r.createdAt)&&void 0!==a?a:t.createdAt;case e.GroupChannelListOrder.CHRONOLOGICAL:return t.createdAt;case e.GroupChannelListOrder.CHANNEL_NAME_ALPHABETICAL:return t.name}return null},Df=function(e,t){return e.findIndex((function(e){return e.isIdentical(t)}))},Pf=function(e,t,n){if(e.length>0){for(var r=Df(e,t),a=0,s=e.length-1,i=Math.floor((a+s)/2);a0)s=i,i=Math.floor((a+s)/2);else{if(!(o<0))return{place:i,oldPosition:r};a=i+1,i=Math.floor((a+s)/2)}}return{place:Ff(e[i],t,n)>=0?i:i+1,oldPosition:r}}return{place:e.length,oldPosition:-1}},Ff=function(t,n,r){switch(r){case e.GroupChannelListOrder.LATEST_LAST_MESSAGE:return t.lastMessage&&n.lastMessage?n.lastMessage.createdAt-t.lastMessage.createdAt:t.lastMessage?-1:n.lastMessage?1:n.createdAt-t.createdAt;case e.GroupChannelListOrder.CHRONOLOGICAL:return n.createdAt-t.createdAt;case e.GroupChannelListOrder.CHANNEL_NAME_ALPHABETICAL:var a=t.name.localeCompare(n.name);return 0===a?t.createdAt-n.createdAt:a}},Gf=function(e,t){return t instanceof Es?e.findIndex((function(e){return e instanceof Es&&t.isIdentical(e)})):e.findIndex((function(e){return e.isIdentical(t)}))},Hf=function(e,t){return e.findIndex((function(e){return e.messageId===t}))},qf=function(e,t){if(e.length>0){for(var n=0,r=e.length-1,a=Math.floor((n+r)/2);n0)r=a,a=Math.floor((n+r)/2);else{if(!(s<0))return a;n=a+1,a=Math.floor((n+r)/2)}}return e[a].createdAt>t.createdAt?a:a+1}return e.length},jf=6e5;e.MessageCollectionInitPolicy=void 0,(e.MessageCollectionInitPolicy||(e.MessageCollectionInitPolicy={})).CACHE_AND_REPLACE_BY_API="cache_and_replace_by_api";var zf,Vf,Bf,Qf=function(){function e(){r(this,e)}return s(e,[{key:"_invokeResponse",value:function(e,n,r){var a=this;ua((function(){return b(a,void 0,void 0,t().mark((function a(){return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:t.t0=e,t.next="local"===t.t0?3:"remote"===t.t0?5:7;break;case 3:return this._onCacheResult(n,r),t.abrupt("break",7);case 5:return this._onApiResult(n,r),t.abrupt("break",7);case 7:case"end":return t.stop()}}),a,this)})))}))}},{key:"onCacheResult",value:function(e){return this._onCacheResult=e,this}},{key:"onApiResult",value:function(e){return this._onApiResult=e,this}}]),e}(),Kf=function(){function n(a,s){var i=this,o=s.channel,u=s.filter,c=s.startingPoint,l=s.limit;r(this,n),this._channel=null,this._messages=[],this._unsentMessages=[],this._backgroundSync=null,this._changelogSync=null,this._pollChangelogSync=null,this._checkMyMutedStateTimer=null,this._iid=a,this._key="mc-".concat(Y()),this.filter=null!=u?u:new po,this._channel=o,this._syncRange=new kf({}),this._hasPrevious=!0,this._hasNext=!0,this._startingPoint="number"==typeof c?c:Date.now()+jf,this._limit=l||co;var h=wf.of(this._iid);h.subscribeGroupChannelEvent(this._key,{onUpdate:function(n,r,a){var s=Df(n,i._channel);if(s>=0)switch(ua((function(){return b(i,void 0,void 0,t().mark((function e(){var a,i;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:i=new xf(r),this._channel=n[s],nu(r)&&(null===(a=this._handler)||void 0===a?void 0:a.onChannelUpdated)&&this._handler.onChannelUpdated(i,this.channel);case 3:case"end":return e.stop()}}),e,this)})))})),r){case e.GroupChannelEventSource.EVENT_CHANNEL_UPDATED:var o=!1;for(var u in i._messages){if(i._messages[u].createdAt>=i._channel.messageOffsetTimestamp){o=!0;var c=parseInt(u);if(c>0){var l=i._messages.splice(0,c);i._removeMessagesFromView(l.map((function(e){return e.messageId})),e.MessageEventSource.EVENT_MESSAGE_OFFSET_UPDATED)}break}}!o&&i._messages.length>0&&i._removeMessagesFromView(i._messages.map((function(e){return e.messageId})),e.MessageEventSource.EVENT_MESSAGE_OFFSET_UPDATED);break;case e.GroupChannelEventSource.EVENT_CHANNEL_UNMUTED:var h=a;ns.of(i._iid).sdkState.userId===h&&i._clearCheckMyMutedTimer();break;case e.GroupChannelEventSource.EVENT_CHANNEL_MUTED:var d=a;ns.of(i._iid).sdkState.userId===d&&-1!==i.channel._myMutedRemainingTime&&i._startCheckMyMutedTimer(i.channel._myMutedRemainingTime);break;case e.GroupChannelEventSource.EVENT_CHANNEL_LEFT:i.channel.isPublic&&i._clearCheckMyMutedTimer()}},onRemove:function(e,n){e.indexOf(i.channel.url)>=0&&(i._clearCheckMyMutedTimer(),ua((function(){return b(i,void 0,void 0,t().mark((function e(){var r,a;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:a=new xf(n),(null===(r=this._handler)||void 0===r?void 0:r.onChannelDeleted)&&this._handler.onChannelDeleted(a,this.channel.url);case 2:case"end":return e.stop()}}),e,this)})))})))}}),h.subscribeMessageEvent(this._key,{onUpdate:function(t,n){var r,a=[],s=[],o=y(t);try{for(o.s();!(r=o.n()).done;){var u=r.value;u.channelUrl===i._channel.url&&(i.filter.match(u)?a.push(u):s.push(u.messageId))}}catch(e){o.e(e)}finally{o.f()}if($s(n)){if(a.length>0)switch(n){case e.MessageEventSource.EVENT_MESSAGE_SENT_FAILED:case e.MessageEventSource.EVENT_MESSAGE_SENT_SUCCESS:case e.MessageEventSource.EVENT_MESSAGE_UPDATED:case e.MessageEventSource.EVENT_MESSAGE_THREADINFO_UPDATED:case e.MessageEventSource.EVENT_MESSAGE_REACTION_UPDATED:case e.MessageEventSource.SYNC_MESSAGE_CHANGELOGS:i._updateMessagesToView(a,n);break;case e.MessageEventSource.EVENT_MESSAGE_SENT_PENDING:i._addMessagesToView(a,n);break;case e.MessageEventSource.EVENT_MESSAGE_RECEIVED:i.hasNext||i._addMessagesToView(a,n);break;case e.MessageEventSource.SYNC_MESSAGE_FILL:i._addMessagesToView(a,n)}s.length>0&&i._removeMessagesFromView(s,n)}},onRemove:function(e,t){i._removeMessagesFromView(e,t)},onRemoveUnsent:function(e,t){i._removeUnsentMessageFromView(e,t)},onPollChangeLogUpdate:function(e,t){i._updatePollsToView(e,t)},onPollUpdate:function(e,t){i._applyPollUpdateEventToView(e,t)},onPollVote:function(e,t){i._applyPollVoteEventToView(e,t)}});var d=ns.of(this._iid),f=d.cacheContext,p=d.dispatcher,v=d.logger;this._channel._updateMessageCollectionLastAccessedAt(),p.dispatch(new ru({channels:[this._channel],source:e.GroupChannelEventSource.CHANNEL_LASTACCESSEDAT_UPDATED})),!this._channel.isSuper&&f.localCacheEnabled&&(this._backgroundSync=If.of(this._iid,this._channel),this._backgroundSync.resume(this._startingPoint)),this._changelogSync=Af.of(this._iid,this._channel),this._changelogSync.resume(),this._pollChangelogSync=Of.of(this._iid,this._channel,this._hasPollMessage.bind(this)),this._pollChangelogSync.resume(),this._prevFill=new Cf(this._key,(function(n){return b(i,void 0,void 0,t().mark((function r(){var a,s,i,o,u;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,this._getRemoteMessages(n,{prevLimit:this._limit,source:e.MessageEventSource.SYNC_MESSAGE_FILL,checkingContinuousMessages:f.localCacheEnabled});case 2:if(s=t.sent,i=s.messages,o=s.isContinuousMessages,!(i.length>0)){t.next=10;break}return u=Math.min.apply(Math,_(i.map((function(e){return e.createdAt})))),this._syncRange.extends(u),o&&(null===(a=this._backgroundSync)||void 0===a||a.range.extends(u)),t.abrupt("return",{hasNext:i.length>=this._limit&&this.viewTop0)){t.next=10;break}return u=Math.max.apply(Math,_(i.map((function(e){return e.createdAt})))),this._syncRange.extends(u),o&&(null===(a=this._backgroundSync)||void 0===a||a.range.extends(u)),t.abrupt("return",{hasNext:!(i.length>=this._limit&&this._hasNext)||this.viewBottom>u,nextToken:this._syncRange.bottom});case 10:return t.abrupt("return",{hasNext:!1,nextToken:0});case 11:case"end":return t.stop()}}),r,this)})))})),this._connectionEventContext=p.on((function(n){if(n instanceof Dr)switch(n.stateType){case Nr.CONNECTED:i._refreshChannel(e.GroupChannelEventSource.SYNC_CHANNEL_CHANGELOGS),ca((function(){return b(i,void 0,void 0,t().mark((function e(){var n;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this.channel.getMyMutedInfo();case 2:(n=e.sent).isMuted&&-1!==n.remainingDuration&&this._startCheckMyMutedTimer(n.remainingDuration);case 4:case"end":return e.stop()}}),e,this)})))})),v.debug("check huge gap"),i._checkHugeGap();break;case Nr.LOGOUT:i.dispose();break;default:i._clearCheckMyMutedTimer(),i._prevFill.stop(),i._nextFill.stop()}})),ns.of(this._iid).statLogCollector.put(new ja({type:te.FEATURE_LOCALCACHE,data:{use_local_cache:f.localCacheEnabled,collection_interface:{message:!0}}}))}return s(n,[{key:"channel",get:function(){return this._channel}},{key:"succeededMessages",get:function(){return _(this._messages)}},{key:"failedMessages",get:function(){return this._unsentMessages.filter((function(t){return t.sendingStatus===e.SendingStatus.FAILED}))}},{key:"pendingMessages",get:function(){return this._unsentMessages.filter((function(t){return t.sendingStatus===e.SendingStatus.PENDING}))}},{key:"hasPrevious",get:function(){return this._hasPrevious}},{key:"hasNext",get:function(){return this._hasNext}},{key:"viewTop",get:function(){return Math.min.apply(Math,_(this._messages.map((function(e){return e.createdAt}))).concat([Number.MAX_SAFE_INTEGER]))}},{key:"viewBottom",get:function(){return Math.max.apply(Math,_(this._messages.map((function(e){return e.createdAt}))).concat([0]))}},{key:"setMessageCollectionHandler",value:function(e){this._handler=e}},{key:"_filterUnderOffsetMessage",value:function(e){return e}},{key:"_addMessagesToView",value:function(n,r){var a,s=this,i=this._filterUnderOffsetMessage(n),o=[],u=[],c=y(i);try{for(c.s();!(a=c.n()).done;){var l=a.value;if(r===e.MessageEventSource.SYNC_MESSAGE_FILL){if(l.messageId>0){if(Gf(this._messages,l)<0){Gf(this._unsentMessages,l)<0&&o.push(l);var h=qf(this._messages,l);this._messages.splice(h,0,l)}}else if(l instanceof Es){Gf(this._unsentMessages,l)<0&&Gf(this._messages,l)<0&&(this._unsentMessages.push(l),o.push(l))}}else if(l.messageId>0){var d=Gf(this._messages,l);if(d<0){var f=Gf(this._unsentMessages,l);f<0?o.push(l):(this._unsentMessages.splice(f,1),u.push(l));var p=qf(this._messages,l);this._messages.splice(p,0,l)}else u.push(l),this._messages[d]=l;if(l.updatedAt>0){var v=this._updateChildMessagesInView(l);u.push.apply(u,_(v))}}else if(l instanceof Es){var m=Gf(this._unsentMessages,l);m<0?Gf(this._messages,l)<0&&(this._unsentMessages.push(l),o.push(l)):(u.push(l),this._unsentMessages[m]=l)}}}catch(e){c.e(e)}finally{c.f()}$s(r)&&ua((function(){return b(s,void 0,void 0,t().mark((function e(){var n,a,s;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:s=new Tf(r),o.length>0&&(null===(n=this._handler)||void 0===n||n.onMessagesAdded(s,this.channel,o)),u.length>0&&(null===(a=this._handler)||void 0===a||a.onMessagesUpdated(s,this.channel,u));case 3:case"end":return e.stop()}}),e,this)})))}))}},{key:"_updateChildMessagesInView",value:function(e){var t=[];return this._messages.forEach((function(n){n.applyParentMessage(e)&&t.push(n)})),t}},{key:"_updatePollsToView",value:function(e,n){var r,a=this,s=[],i=y(e);try{for(i.s();!(r=i.n()).done;){var o=r.value,u=Hf(this._messages,o.messageId);if(u>=0){var c=this._messages[u];c&&c.applyPoll(o),s.push(c)}}}catch(e){i.e(e)}finally{i.f()}return s.length>0&&$s(n)&&ua((function(){return b(a,void 0,void 0,t().mark((function e(){var r,a;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:a=new Tf(n),s.length>0&&(null===(r=this._handler)||void 0===r||r.onMessagesUpdated(a,this.channel,s));case 2:case"end":return e.stop()}}),e,this)})))})),s}},{key:"_applyPollUpdateEventToView",value:function(e,n){var r=this,a=Hf(this._messages,e.messageId);if(a>=0){var s=this._messages[a];s&&s.isUserMessage()&&s.poll&&s.poll.applyPollUpdateEvent(e)&&$s(n)&&ua((function(){return b(r,void 0,void 0,t().mark((function e(){var r,a;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:a=new Tf(n),null===(r=this._handler)||void 0===r||r.onMessagesUpdated(a,this.channel,[s]);case 2:case"end":return e.stop()}}),e,this)})))}))}}},{key:"_applyPollVoteEventToView",value:function(e,n){var r=this,a=Hf(this._messages,e.messageId);if(a>=0){var s=this._messages[a];s&&s.isUserMessage()&&s.poll&&s.poll.applyPollVoteEvent(e)&&$s(n)&&ua((function(){return b(r,void 0,void 0,t().mark((function e(){var r,a;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:a=new Tf(n),null===(r=this._handler)||void 0===r||r.onMessagesUpdated(a,this.channel,[s]);case 2:case"end":return e.stop()}}),e,this)})))}))}}},{key:"_updateMessagesToView",value:function(e,n){var r,a=this,s=[],i=[],o=y(e);try{for(o.s();!(r=o.n()).done;){var u=r.value;if(u.messageId>0){var c=Gf(this._messages,u);if(c>=0)s.push(u),this._messages[c]=u;else{var l=Gf(this._unsentMessages,u);if(l>=0){var h=this._unsentMessages.splice(l,1);if(this.hasNext&&h.length>0)i.push(h[0]);else{s.push(u);var d=qf(this._messages,u);this._messages.splice(d,0,u)}}}}else if(u instanceof Es){var f=Gf(this._unsentMessages,u);f>=0&&(s.push(u),this._unsentMessages[f]=u)}}}catch(e){o.e(e)}finally{o.f()}return $s(n)&&ua((function(){return b(a,void 0,void 0,t().mark((function e(){var r,a,o;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:o=new Tf(n),s.length>0?null===(r=this._handler)||void 0===r||r.onMessagesUpdated(o,this.channel,s):i.length>0&&(null===(a=this._handler)||void 0===a||a.onMessagesDeleted(o,this.channel,[],i));case 2:case"end":return e.stop()}}),e,this)})))})),s}},{key:"_removeMessagesFromView",value:function(e,n){var r,a=this,s=[],i=[],o=y(e);try{var u=function(){var e=r.value,t=a._messages.findIndex((function(t){return t.messageId===e}));if(t>=0){var n=a._messages[t];s.push(n.messageId),i.push(n),a._messages.splice(t,1)}};for(o.s();!(r=o.n()).done;)u()}catch(e){o.e(e)}finally{o.f()}return $s(n)&&i.length>0&&ua((function(){return b(a,void 0,void 0,t().mark((function e(){var r,a;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:a=new Tf(n),null===(r=this._handler)||void 0===r||r.onMessagesDeleted(a,this.channel,s,i);case 2:case"end":return e.stop()}}),e,this)})))})),s}},{key:"_removeUnsentMessageFromView",value:function(e,t){var n=this._unsentMessages.findIndex((function(t){return t.reqId===e}));n>=0&&this._unsentMessages.splice(n,1)}},{key:"_getLocalMessages",value:function(e,n){var r=n.prevLimit,a=void 0===r?0:r,s=n.nextLimit,i=void 0===s?0:s;return b(this,void 0,void 0,t().mark((function n(){var r,s,o,u,c;return t().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:if(r=wf.of(this._iid),!(a>0)){n.next=7;break}return n.next=4,r.getMessagesFromCache(this._channel.url,e,"prev",this.filter,a);case 4:n.t0=n.sent,n.next=8;break;case 7:n.t0=[];case 8:if(s=n.t0,!(i>0)){n.next=15;break}return n.next=12,r.getMessagesFromCache(this._channel.url,e,"next",this.filter,i);case 12:n.t1=n.sent,n.next=16;break;case 15:n.t1=[];case 16:if(o=n.t1,!(s.length>0&&o.length>0)){n.next=27;break}u=s.map((function(e){return e.messageId})),n.t2=t().keys(o);case 20:if((n.t3=n.t2()).done){n.next=27;break}if(c=n.t3.value,!u.includes(o[c].messageId)){n.next=25;break}return o.splice(parseInt(c),1),n.abrupt("break",27);case 25:n.next=20;break;case 27:return n.abrupt("return",[].concat(_(s),_(o)).sort((function(e,t){return t.createdAt-e.createdAt})));case 28:case"end":return n.stop()}}),n,this)})))}},{key:"_getRemoteMessages",value:function(n,r){var a=r.prevLimit,s=void 0===a?0:a,i=r.nextLimit,o=void 0===i?0:i,u=r.source,c=void 0===u?e.MessageEventSource.REQUEST_MESSAGE:u,l=r.reverse,h=void 0!==l&&l,d=r.checkingContinuousMessages,f=void 0!==d&&d;return b(this,void 0,void 0,t().mark((function e(){var r;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(r=vi.of(this._iid),!(s>0||o>0)){e.next=7;break}return e.next=4,r._getMessagesByTimestampForCollection(this._channel.url,this._channel.channelType,n,Object.assign(Object.assign({},this.filter),{isInclusive:!0,reverse:h,prevResultSize:s,nextResultSize:o,includeMetaArray:!0,includeReactions:!0,includeThreadInfo:!0,includeParentMessageInfo:!0}),c,f);case 4:e.t0=e.sent,e.next=8;break;case 7:e.t0={messages:[],isContinuousMessages:!1};case 8:return e.abrupt("return",e.t0);case 9:case"end":return e.stop()}}),e,this)})))}},{key:"_checkHugeGap",value:function(){var n;return b(this,void 0,void 0,t().mark((function r(){var a,s,i,o,u,c,l,h,d,f,p,v,m,g,y,k,w,C,x,T,S=this;return t().wrap((function(r){for(;;)switch(r.prev=r.next){case 0:if(!(this._messages.length>0)){r.next=16;break}return a=this._syncRange.top,s=this.viewTop,i=this._syncRange.bottom,o=this.hasNext?this.viewBottom:Number.MAX_SAFE_INTEGER,u=wf.of(this._iid),r.next=8,u.getCachedMessageCountBetween(this._channel.url,this.filter,s,a);case 8:return c=r.sent,r.next=11,u.getCachedMessageCountBetween(this._channel.url,this.filter,i,o);case 11:return l=r.sent,r.next=14,oa((function(){return b(S,void 0,void 0,t().mark((function n(){var r,u,h,d,f,p,v,m,g,y,k,E,w,C,x,T,S,I,N,A,M,O=this;return t().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return u=ns.of(this._iid),h=u.dispatcher,d=u.requestQueue,f=u.cacheContext,p=new Uf(Object.assign({channelUrl:this._channel.url,channelType:this._channel.channelType,prevStart:s,prevEnd:a,prevCount:c,nextStart:i,nextEnd:o,nextCount:l,checkingContinuousMessages:f.localCacheEnabled},this.filter)),n.next=4,d.send(p);case 4:v=n.sent,m=v.as(Rf),g=m.isHugeGap,y=m.prevMessages,k=void 0===y?[]:y,E=m.prevHasMore,w=m.isContinuousPrevMessages,C=m.nextMessages,x=void 0===C?[]:C,T=m.nextHasmore,S=m.isContinuousNextMessages,g?ua((function(){return b(O,void 0,void 0,t().mark((function e(){var n;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:null===(n=this._handler)||void 0===n||n.onHugeGapDetected();case 1:case"end":return e.stop()}}),e,this)})))})):(this._hasPrevious=E,this._hasNext=T,I=this.viewTop,N=this.viewBottom,A=Math.min.apply(Math,[Number.MAX_SAFE_INTEGER,I].concat(_(k.map((function(e){return e.createdAt}))))),M=Math.max.apply(Math,[0,N].concat(_(x.map((function(e){return e.createdAt}))))),h.dispatch(new ei({messages:k,source:e.MessageEventSource.SYNC_MESSAGE_FILL})),h.dispatch(new ei({messages:x,source:e.MessageEventSource.SYNC_MESSAGE_FILL})),this._syncRange.extends(A,M),(w||S)&&(null===(r=this._backgroundSync)||void 0===r||r.range.extends(A,M)),IM&&this._nextFill.start(M));case 7:case"end":return n.stop()}}),n,this)})))}),1);case 14:r.next=31;break;case 16:return h=ns.of(this._iid),d=h.cacheContext,f=Math.floor(this._limit/2),p=Date.now(),r.prev=19,r.next=22,this._getRemoteMessages(p,{prevLimit:f,nextLimit:f,source:e.MessageEventSource.SYNC_MESSAGE_FILL,checkingContinuousMessages:d.localCacheEnabled});case 22:if(v=r.sent,m=v.messages,g=v.isContinuousMessages,m.length>0){for(k=m.map((function(e){return e.createdAt})),w=0,C=0,x=0;x=p&&C++;this._hasPrevious=w>=f,this._hasNext=C>=f,(y=this._syncRange).extends.apply(y,_(k)),g&&(null===(n=this._backgroundSync)||void 0===n||n.range.extends(this._syncRange.top,this._syncRange.bottom)),this._addMessagesToView(m,e.MessageEventSource.SYNC_MESSAGE_FILL)}else this._hasPrevious=!1,this._hasNext=!1;r.next=31;break;case 28:r.prev=28,r.t0=r.catch(19),r.t0 instanceof M&&r.t0.code===E.NOT_FOUND_IN_DATABASE&&(this._hasPrevious=!1,this._hasNext=!1);case 31:case"end":return r.stop()}}),r,this,[[19,28]])})))}},{key:"_loadUnsentMessages",value:function(){return b(this,void 0,void 0,t().mark((function e(){var n;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n=wf.of(this._iid),e.next=3,n.getUnsentMessagesFromCache(this._channel.url,this.filter);case 3:this._unsentMessages=e.sent;case 4:case"end":return e.stop()}}),e,this)})))}},{key:"_hasPollMessage",value:function(){return b(this,void 0,void 0,t().mark((function e(){var n;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n=wf.of(this._iid),e.next=3,n.getPollMessagesFromCache(this._channel.url,Date.now()+jf,this.filter,1);case 3:if(!(e.sent.length>0)){e.next=6;break}return e.abrupt("return",!0);case 6:return e.abrupt("return",!1);case 7:case"end":return e.stop()}}),e,this)})))}},{key:"_refreshChannel",value:function(e){wf.of(this._iid).refreshChannel(this.channel.url,!0,e)}},{key:"_startCheckMyMutedTimer",value:function(n){var r=this;this._clearCheckMyMutedTimer(),this._checkMyMutedStateTimer=setTimeout((function(){return b(r,void 0,void 0,t().mark((function n(){var r,a,s,i;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return this._checkMyMutedStateTimer=null,a=!0,t.prev=2,t.next=5,this._channel.getMyMutedInfo();case 5:s=t.sent,a=!s.isMuted,t.next=12;break;case 9:t.prev=9,t.t0=t.catch(2),a=!0;case 12:return t.prev=12,a&&(this.channel.myMutedState=e.MutedState.UNMUTED,i=new xf(e.GroupChannelEventSource.EVENT_CHANNEL_UNMUTED),null===(r=this._handler)||void 0===r||r.onChannelUpdated(i,this.channel)),t.finish(12);case 15:case"end":return t.stop()}}),n,this,[[2,9,12,15]])})))}),n+1e3)}},{key:"_clearCheckMyMutedTimer",value:function(){this._checkMyMutedStateTimer&&(clearTimeout(this._checkMyMutedStateTimer),this._checkMyMutedStateTimer=null)}},{key:"initialize",value:function(n){var r=this,a=new Qf;this._messages=[],this._unsentMessages=[],this._syncRange=new kf({}),this._hasNext=!0,this._hasPrevious=!0,this._refreshChannel(e.GroupChannelEventSource.REFRESH_CHANNEL),ca((function(){return b(r,void 0,void 0,t().mark((function e(){var n;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this.channel.getMyMutedInfo();case 2:(n=e.sent).isMuted&&-1!==n.remainingDuration&&this._startCheckMyMutedTimer(n.remainingDuration);case 4:case"end":return e.stop()}}),e,this)})))}));var s=Math.floor(this._limit/2);if(n===e.MessageCollectionInitPolicy.CACHE_AND_REPLACE_BY_API)this._getLocalMessages(this._startingPoint,{prevLimit:s,nextLimit:s}).then((function(n){return b(r,void 0,void 0,t().mark((function r(){var s;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return s=this._filterUnderOffsetMessage(n),this._addMessagesToView(s,e.MessageEventSource.REQUEST_MESSAGE),t.next=4,this._loadUnsentMessages();case 4:a._invokeResponse("local",null,s);case 5:case"end":return t.stop()}}),r,this)})))})).catch((function(e){if(A(e))throw e;a._invokeResponse("local",e,null)})).finally((function(){var t=ns.of(r._iid).cacheContext;r._getRemoteMessages(r._startingPoint,{prevLimit:s,nextLimit:s,reverse:!0,checkingContinuousMessages:t.localCacheEnabled}).then((function(t){var n,i=t.messages,o=t.isContinuousMessages;r._messages=[];var u=r._filterUnderOffsetMessage(i);if(u.length>0){for(var c,l=u.map((function(e){return e.createdAt})),h=0,d=0,f=0;f=r._startingPoint&&d++}r._hasPrevious=h>=s,r._hasNext=d>=s,(c=r._syncRange).extends.apply(c,_(u.map((function(e){return e.createdAt})))),o&&(null===(n=r._backgroundSync)||void 0===n||n.range.extends(r._syncRange.top,r._syncRange.bottom)),r._addMessagesToView(u,e.MessageEventSource.REQUEST_MESSAGE)}else r._hasPrevious=!1,r._hasNext=!1;a._invokeResponse("remote",null,u)})).catch((function(e){if(A(e))throw e;a._invokeResponse("remote",e,null)}))}));var i=ns.of(this._iid),o=i.cacheContext;return i.statLogCollector.put(new ja({type:te.FEATURE_LOCALCACHE,data:{use_local_cache:o.localCacheEnabled,collection_interface:{message_init_policy:n}}})),a}},{key:"loadPrevious",value:function(){return b(this,void 0,void 0,t().mark((function n(){var r,a,s,i=this;return t().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:if(!this._hasPrevious){n.next=14;break}return r=this.viewTop,a=[],n.next=5,ca((function(){return b(i,void 0,void 0,t().mark((function e(){return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.t0=this,e.next=3,this._getLocalMessages(r,{prevLimit:this._limit});case 3:e.t1=e.sent,a=e.t0._filterUnderOffsetMessage.call(e.t0,e.t1);case 5:case"end":return e.stop()}}),e,this)})))}));case 5:if(0!==a.length&&this._backgroundSync&&this._backgroundSync.isWrappingMessages(a)){n.next=11;break}return n.next=8,ca((function(){return b(i,void 0,void 0,t().mark((function e(){var n,s,i,o,u,c;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return i=ns.of(this._iid),o=i.cacheContext,e.next=3,this._getRemoteMessages(r,{prevLimit:this._limit,checkingContinuousMessages:o.localCacheEnabled});case 3:u=e.sent,a=this._filterUnderOffsetMessage(u.messages),this._hasPrevious=a.length>=this._limit,a.length>0&&((c=this._syncRange).extends.apply(c,_(a.map((function(e){return e.createdAt})))),(null===(n=this._backgroundSync)||void 0===n?void 0:n.range.overlap(this._syncRange))&&u.isContinuousMessages&&(null===(s=this._backgroundSync)||void 0===s||s.range.extends(this._syncRange.top)));case 7:case"end":return e.stop()}}),e,this)})))}));case 8:this._addMessagesToView(a,e.MessageEventSource.REQUEST_MESSAGE),n.next=13;break;case 11:this._hasPrevious=a.length>=this._limit,a.length>0&&((s=this._syncRange).extends.apply(s,_(a.map((function(e){return e.createdAt})))),this._addMessagesToView(a,e.MessageEventSource.REQUEST_MESSAGE));case 13:return n.abrupt("return",a);case 14:return n.abrupt("return",[]);case 15:case"end":return n.stop()}}),n,this)})))}},{key:"loadNext",value:function(){var n;return b(this,void 0,void 0,t().mark((function r(){var a,s,i,o=this;return t().wrap((function(r){for(;;)switch(r.prev=r.next){case 0:if(this._hasNext){r.next=2;break}return r.abrupt("return",[]);case 2:return a=this.viewBottom,s=[],r.next=6,ca((function(){return b(o,void 0,void 0,t().mark((function e(){return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.t0=this,e.next=3,this._getLocalMessages(a,{nextLimit:this._limit});case 3:e.t1=e.sent,s=e.t0._filterUnderOffsetMessage.call(e.t0,e.t1);case 5:case"end":return e.stop()}}),e,this)})))}));case 6:if(0!==s.length&&(null===(n=this._backgroundSync)||void 0===n?void 0:n.isWrappingMessages(s))){r.next=12;break}return r.next=9,ca((function(){return b(o,void 0,void 0,t().mark((function e(){var n,r,i,o,u,c;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return i=ns.of(this._iid),o=i.cacheContext,e.next=3,this._getRemoteMessages(a,{nextLimit:this._limit,checkingContinuousMessages:o.localCacheEnabled});case 3:u=e.sent,s=this._filterUnderOffsetMessage(u.messages),this._hasNext=s.length>=this._limit,s.length>0&&((c=this._syncRange).extends.apply(c,_(s.map((function(e){return e.createdAt})))),(null===(n=this._backgroundSync)||void 0===n?void 0:n.range.overlap(this._syncRange))&&u.isContinuousMessages&&(null===(r=this._backgroundSync)||void 0===r||r.range.extends(this._syncRange.bottom)));case 7:case"end":return e.stop()}}),e,this)})))}));case 9:this._addMessagesToView(s,e.MessageEventSource.REQUEST_MESSAGE),r.next=14;break;case 12:this._hasNext=s.length>=this._limit,s.length>0&&((i=this._syncRange).extends.apply(i,_(s.map((function(e){return e.createdAt})))),this._addMessagesToView(s,e.MessageEventSource.REQUEST_MESSAGE));case 14:return r.abrupt("return",s);case 15:case"end":return r.stop()}}),r,this)})))}},{key:"removeFailedMessage",value:function(e){return b(this,void 0,void 0,t().mark((function n(){var r,a;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return r=wf.of(this._iid),t.next=3,r.removeFailedMessageFromCache(e);case 3:(a=this._unsentMessages.findIndex((function(t){return t.reqId===e})))>-1&&this._unsentMessages.splice(a,1);case 5:case"end":return t.stop()}}),n,this)})))}},{key:"dispose",value:function(){var t,n,r,a=ns.of(this._iid),s=a.cacheContext,i=a.dispatcher;this._clearCheckMyMutedTimer(),this._channel._updateMessageCollectionLastAccessedAt(),i.dispatch(new ru({channels:[this._channel],source:e.GroupChannelEventSource.CHANNEL_LASTACCESSEDAT_UPDATED})),s.localCacheEnabled&&(this._prevFill.stop(),this._nextFill.stop()),null===(t=this._backgroundSync)||void 0===t||t.close(),null===(n=this._changelogSync)||void 0===n||n.close(),null===(r=this._pollChangelogSync)||void 0===r||r.close();var o=wf.of(this._iid);o.unsubscribeGroupChannelEvent(this._key),o.unsubscribeMessageEvent(this._key),this._connectionEventContext&&this._connectionEventContext.close()}}]),n}(),Wf={coverUrl:null,coverImage:null,isDistinct:null,isPublic:null,isDiscoverable:null,accessCode:null,name:null,data:null,customType:null,operatorUserIds:null,messageSurvivalSeconds:null},Yf=function(e){return L("string",e.coverUrl,!0)&&(H(e.coverImage)||L("string",e.coverImage)||null===e.coverImage)&&L("boolean",e.isDistinct,!0)&&L("boolean",e.isPublic,!0)&&L("boolean",e.isDiscoverable,!0)&&L("string",e.accessCode,!0)&&L("string",e.name,!0)&&L("string",e.data,!0)&&L("string",e.customType,!0)&&F("string",e.operatorUserIds,!0)&&L("number",e.messageSurvivalSeconds,!0)},Zf={hidePreviousMessages:!1,allowAutoUnhide:!0},Jf=function(e){return L("boolean",e.hidePreviousMessages)&&L("boolean",e.allowAutoUnhide)},Xf=function(e){i(n,e);var t=f(n);function n(e){var a;r(this,n);var s=e.channelUrl,i=e.token,o=e.limit,u=e.order,c=e.mutedMemberFilter,l=e.memberStateFilter,h=e.nicknameStartsWithFilter,d=e.operatorFilter;return(a=t.call(this)).method=B.GET,a.path="".concat(zr,"/").concat(encodeURIComponent(s),"/members"),a.params={token:i,limit:o,order:u,muted_member_filter:c,member_state_filter:l,nickname_startswith:h,operator_filter:d,show_member_is_muted:!0,show_read_receipt:!0,show_delivery_receipt:!0},a}return s(n)}(ne),$f=function(e){i(n,e);var t=f(n);function n(e,a){var s;r(this,n),(s=t.call(this,e,a)).token=null,s.members=[];var i=a.next,o=a.members;return s.token=i,o&&o.length>0&&(s.members=o.map((function(t){return new ed(e,t)}))),s}return s(n)}(re);e.MutedMemberFilter=void 0,(zf=e.MutedMemberFilter||(e.MutedMemberFilter={})).ALL="all",zf.MUTED="muted",zf.UNMUTED="unmuted",e.MemberListOrder=void 0,(Vf=e.MemberListOrder||(e.MemberListOrder={})).MEMBER_NICKNAME_ALPHABETICAL="member_nickname_alphabetical",Vf.OPERATOR_THEN_MEMBER_ALPHABETICAL="operator_then_member_alphabetical",e.MemberStateFilter=void 0,(Bf=e.MemberStateFilter||(e.MemberStateFilter={})).ALL="all",Bf.JOINED="joined_only",Bf.INVITED="invited_only",Bf.INVITED_BY_FRIEND="invited_by_friend",Bf.INVITED_BY_NON_FRIEND="invited_by_non_friend";var ep,tp,np,rp=function(n){i(u,n);var a=f(u);function u(t,n,s){var i,o,c,l,h;return r(this,u),(i=a.call(this,t,n,e.ChannelType.GROUP,s)).mutedMemberFilter=e.MutedMemberFilter.ALL,i.memberStateFilter=e.MemberStateFilter.ALL,i.nicknameStartsWithFilter=null,i.operatorFilter=e.OperatorFilter.ALL,i.order=e.MemberListOrder.MEMBER_NICKNAME_ALPHABETICAL,i.mutedMemberFilter=null!==(o=s.mutedMemberFilter)&&void 0!==o?o:e.MutedMemberFilter.ALL,i.memberStateFilter=null!==(c=s.memberStateFilter)&&void 0!==c?c:e.MemberStateFilter.ALL,i.nicknameStartsWithFilter=null!==(l=s.nicknameStartsWithFilter)&&void 0!==l?l:null,i.order=null!==(h=s.order)&&void 0!==h?h:e.MemberListOrder.MEMBER_NICKNAME_ALPHABETICAL,i}return s(u,[{key:"_validate",value:function(){return p(o(u.prototype),"_validate",this).call(this)&&D(e.MutedMemberFilter,this.mutedMemberFilter)&&D(e.MemberStateFilter,this.memberStateFilter)&&(L("string",this.nicknameStartsWithFilter)||null===this.nicknameStartsWithFilter)&&D(e.OperatorFilter,this.operatorFilter)&&D(e.MemberListOrder,this.order)}},{key:"next",value:function(){return b(this,void 0,void 0,t().mark((function e(){var n,r,a,s,i,o,u;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!this._validate()){e.next=20;break}if(this._isLoading){e.next=17;break}if(!this._hasNext){e.next=14;break}return this._isLoading=!0,n=ns.of(this._iid),r=n.requestQueue,a=new Xf(Object.assign(Object.assign({},this),{token:this._token})),e.next=8,r.send(a);case 8:return s=e.sent,i=s.as($f),o=i.members,u=i.token,this._token=u,this._hasNext=!!u,this._isLoading=!1,e.abrupt("return",o);case 14:return e.abrupt("return",[]);case 17:throw M.queryInProgress;case 18:e.next=21;break;case 20:throw M.invalidParameters;case 21:case"end":return e.stop()}}),e,this)})))}}]),u}(Si),ap=function(e){i(n,e);var t=f(n);function n(e){var a;r(this,n);var s=e.channelUrl,i=e.userId,o=e.accessCode;return(a=t.call(this)).method=B.PUT,a.path="".concat(zr,"/").concat(encodeURIComponent(s),"/accept"),a.params={user_id:i,access_code:o},a}return s(n)}(ne),sp=function(t){i(a,t);var n=f(a);function a(t,s){var i;return r(this,a),(i=n.call(this,t,s)).channel=new Rp(t,s),i.channel.myMemberState=e.MemberState.JOINED,i}return s(a)}(re),ip=function(e){i(n,e);var t=f(n);function n(e){var a;r(this,n);var s=e.channelUrl,i=e.isDistinct,o=e.isPublic,u=e.isDiscoverable,c=e.coverUrl,l=e.coverImage,h=e.accessCode,d=e.name,f=e.data,p=e.customType,v=e.operatorUserIds,_=e.messageSurvivalSeconds;return(a=t.call(this)).method=B.PUT,a.path="".concat(zr,"/").concat(encodeURIComponent(s)),a.params=ee({is_distinct:i,is_public:o,is_discoverable:u,name:d,data:f,custom_type:p,cover_url:c,cover_file:l,access_code:h,operator_ids:v,message_survival_seconds:_}),a}return s(n)}(ne),op=function(e){i(n,e);var t=f(n);function n(e,a){var s;return r(this,n),(s=t.call(this,e,a)).channel=new Rp(e,a),s}return s(n)}(re),up=function(e){i(n,e);var t=f(n);function n(e){var a;r(this,n);var s=e.channelUrl;return(a=t.call(this)).method=B.DELETE,a.path="".concat(zr,"/").concat(encodeURIComponent(s)),a}return s(n)}(ne),cp=function(e){i(n,e);var t=f(n);function n(e){var a;r(this,n);var s=e.channelUrl;return(a=t.call(this)).method=B.DELETE,a.path="".concat(zr,"/").concat(encodeURIComponent(s),"/hide"),a}return s(n)}(ne),lp=function(e){i(n,e);var t=f(n);function n(e){var a,s=e.userId,i=e.channelUrl,o=e.countPreference;return r(this,n),(a=t.call(this)).method=B.PUT,a.path="".concat(qr,"/").concat(encodeURIComponent(s),"/count_preference/").concat(encodeURIComponent(i)),a.params={count_preference:o},a}return s(n)}(ne),hp=function(e){i(n,e);var t=f(n);function n(e,a){var s;return r(this,n),(s=t.call(this,e,a)).countPreference=a.count_preference,s}return s(n)}(re),dp=function(e){i(n,e);var t=f(n);function n(e){var a;r(this,n);var s=e.channelUrl;return(a=t.call(this)).method=B.PUT,a.path="".concat(zr,"/").concat(encodeURIComponent(s),"/reset_user_history"),a}return s(n)}(ne),fp=function(e){i(n,e);var t=f(n);function n(e,a){var s;r(this,n),(s=t.call(this,e,a)).messageOffsetTimestamp=null;var i=a.ts_message_offset;return s.messageOffsetTimestamp=null!=i?i:null,s}return s(n)}(re),pp=Object.assign(Object.assign({},fl),{scheduledAt:null,file:null,fileUrl:null,fileName:null,mimeType:null,fileSize:null,thumbnailSizes:null,requireAuth:!1}),vp=function(e){return pl(e)&&L("number",e.scheduledAt,!0)&&(H(e.file)||L("string",e.fileUrl))&&L("string",e.fileName,!0)&&L("string",e.mimeType,!0)&&L("number",e.fileSize,!0)&&(null===e.thumbnailSizes||e.thumbnailSizes.every((function(e){return L("object",e)&&e.maxWidth>0&&e.maxHeight>0})))},_p=Object.assign(Object.assign({},vl),{scheduledAt:null}),mp=function(e){return _l(e)&&L("number",e.scheduledAt,!0)},gp=function(t){i(a,t);var n=f(a);function a(t){var s,i;r(this,a),s=n.call(this);var o=null;t.mentionType===e.MentionType.USERS&&(t.mentionedUserIds?o=t.mentionedUserIds:t.mentionedUsers&&(o=t.mentionedUsers.map((function(e){return e.userId}))));var u=t.channelType,c=t.channelUrl,l=t.scheduledMessageId;return s.method=B.PUT,s.path="".concat(Fs(u),"/").concat(encodeURIComponent(c),"/scheduled_messages/").concat(encodeURIComponent(l)),s.params=ee({req_id:t.reqId,scheduled_at:t.scheduledAt,message_type:Ya.FILE,url:t.fileUrl,file_name:t.fileName,file_size:t.fileSize,file_type:t.mimeType,thumbnails:t.thumbnailSizes?t.thumbnailSizes.map((function(e){return ws.payloadify(e)})):[],custom_type:t.customType,data:t.data,require_auth:t.requireAuth,mention_type:t.mentionType,mentioned_user_ids:o,sorted_metaarray:null===(i=t.metaArrays)||void 0===i?void 0:i.map((function(e){return ps.payloadify(e)})),apple_critical_alert_options:ms.payloadify(t.appleCriticalAlertOptions),push_option:t.pushNotificationDeliveryOption}),s}return s(a)}(ne),yp=function(e){i(n,e);var t=f(n);function n(e,a){var s;return r(this,n),(s=t.call(this,e,a)).message=new Ps(e,a),s}return s(n)}(re),kp=function(t){i(a,t);var n=f(a);function a(t){var s,i;r(this,a),s=n.call(this);var o=null;t.mentionType===e.MentionType.USERS&&(t.mentionedUserIds?o=t.mentionedUserIds:t.mentionedUsers&&(o=t.mentionedUsers.map((function(e){return e.userId}))));var u=t.channelType,c=t.channelUrl,l=t.scheduledMessageId;return s.method=B.PUT,s.path="".concat(Fs(u),"/").concat(encodeURIComponent(c),"/scheduled_messages/").concat(encodeURIComponent(l)),s.params=ee({req_id:t.reqId,scheduled_at:t.scheduledAt,message_type:Ya.USER,message:t.message,custom_type:t.customType,data:t.data,mention_type:t.mentionType,mentioned_user_ids:o,sorted_metaarray:null===(i=t.metaArrays)||void 0===i?void 0:i.map((function(e){return ps.payloadify(e)})),apple_critical_alert_options:ms.payloadify(t.appleCriticalAlertOptions),target_langs:t.translationTargetLanguages,push_option:t.pushNotificationDeliveryOption}),s}return s(a)}(ne),bp=function(e){i(n,e);var t=f(n);function n(e){var a;r(this,n),a=t.call(this);var s=e.channelType,i=e.channelUrl,o=e.scheduledMessageId;return a.method=B.DELETE,a.path="".concat(Fs(s),"/").concat(encodeURIComponent(i),"/scheduled_messages/").concat(encodeURIComponent(o)),a}return s(n)}(ne),Ep=function(e){i(n,e);var t=f(n);function n(e){var a;r(this,n),a=t.call(this);var s=e.channelType,i=e.channelUrl,o=e.scheduledMessageId;return a.method=B.POST,a.path="".concat(Fs(s),"/").concat(encodeURIComponent(i),"/scheduled_messages/").concat(encodeURIComponent(o),"/send_now"),a}return s(n)}(ne),wp=function(e){i(n,e);var t=f(n);function n(e){var a,s=e.userId,i=e.channelUrl,o=e.pushTriggerOption;return r(this,n),(a=t.call(this)).method=B.PUT,a.path="".concat(qr,"/").concat(encodeURIComponent(s),"/push_preference/").concat(encodeURIComponent(i)),a.params={push_trigger_option:o},a}return s(n)}(ne),Cp=function(e){i(n,e);var t=f(n);function n(e,a){var s;return r(this,n),(s=t.call(this,e,a)).pushTriggerOption=a.push_trigger_option,s.enabled=a.enable,s}return s(n)}(re),xp=function(e){i(n,e);var t=f(n);function n(e){var a,s=e.userId,i=e.channelUrl;return r(this,n),(a=t.call(this)).method=B.GET,a.path="".concat(qr,"/").concat(encodeURIComponent(s),"/push_preference/").concat(encodeURIComponent(i)),a}return s(n)}(ne),Tp=function(e){i(n,e);var t=f(n);function n(e,a){var s;return r(this,n),(s=t.call(this,e,a)).pushTriggerOption=a.push_trigger_option,s.enabled=a.enable,s}return s(n)}(re),Sp=function(e){i(n,e);var t=f(n);function n(e){var a,s=e.channelType,i=e.channelUrl,o=e.messageId;return r(this,n),(a=t.call(this)).method=B.POST,a.path="".concat(Fs(s),"/").concat(encodeURIComponent(i),"/messages/").concat(o,"/pin"),a}return s(n)}(ne),Ip=function(e){i(n,e);var t=f(n);function n(e){var a,s=e.channelType,i=e.channelUrl,o=e.messageId;return r(this,n),(a=t.call(this)).method=B.DELETE,a.path="".concat(Fs(s),"/").concat(encodeURIComponent(i),"/messages/").concat(o,"/pin"),a}return s(n)}(ne),Np=function(e){i(n,e);var t=f(n);function n(e,a){var s;return r(this,n),(s=t.call(this,e)).message=Ds(e,a.message),s}return s(n)}(Ca),Ap=function(e){i(n,e);var t=f(n);function n(e){var a;r(this,n);var s=e.channelType,i=e.channelUrl,o=e.limit,u=e.token,c=e.includeReactions,l=e.includeMetaArray,h=e.includeParentMessageInfo,d=e.includeThreadInfo,f=e.includePollDetails;return(a=t.call(this)).method=B.GET,a.path="".concat(Fs(s),"/").concat(encodeURIComponent(i),"/pinned_messages"),a.params=ee({limit:o,token:u,include_reactions:c,with_sorted_meta_array:l,include_thread_info:d,include_parent_message_info:h,include_poll_details:f}),a}return s(n)}(ne),Mp=function(e){i(n,e);var t=f(n);function n(e,a){var s;r(this,n),(s=t.call(this,e,a)).hasMore=null,s.token=null;var i=a.pinned_messages,o=a.has_more,u=a.next;return s.pinnedMessages=i.map((function(t){return new Np(e,t)})),s.hasMore=o,s.token=u,s}return s(n)}(re),Op=function(e){i(a,e);var n=f(a);function a(e,t,s,i){var o;return r(this,a),(o=n.call(this,e,t,s,i)).includeMetaArray=i.includeMetaArray,o.includeReactions=i.includeReactions,o.includeParentMessageInfo=i.includeParentMessageInfo,o.includeThreadInfo=i.includeThreadInfo,o.includePollDetails=i.includePollDetails,o}return s(a,[{key:"_validate",value:function(){return p(o(a.prototype),"_validate",this).call(this)&&L("boolean",this.includeMetaArray,!0)&&L("boolean",this.includeReactions,!0)&&L("boolean",this.includeParentMessageInfo,!0)&&L("boolean",this.includeThreadInfo,!0)&&L("boolean",this.includePollDetails,!0)}},{key:"next",value:function(){return b(this,void 0,void 0,t().mark((function e(){var n,r,a,s,i,o,u,c;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!this._validate()){e.next=20;break}if(this._isLoading){e.next=17;break}if(!this._hasNext){e.next=14;break}return this._isLoading=!0,n=ns.of(this._iid),r=n.requestQueue,a=new Ap(Object.assign(Object.assign({},this),{token:this._token})),e.next=8,r.send(a);case 8:return s=e.sent,i=s.as(Mp),o=i.pinnedMessages,u=i.hasMore,c=i.token,this._token=c,this._hasNext=!!u,this._isLoading=!1,e.abrupt("return",o);case 14:return e.abrupt("return",[]);case 17:throw M.queryInProgress;case 18:e.next=21;break;case 20:throw M.invalidParameters;case 21:case"end":return e.stop()}}),e,this)})))}}]),a}(Si);e.CountPreference=void 0,(ep=e.CountPreference||(e.CountPreference={})).ALL="all",ep.UNREAD_MESSAGE_COUNT_ONLY="unread_message_count_only",ep.UNREAD_MENTION_COUNT_ONLY="unread_mention_count_only",ep.OFF="off",e.MutedState=void 0,(tp=e.MutedState||(e.MutedState={})).MUTED="muted",tp.UNMUTED="unmuted",e.HiddenState=void 0,(np=e.HiddenState||(e.HiddenState={})).UNHIDDEN="unhidden",np.HIDDEN_ALLOW_AUTO_UNHIDE="hidden_allow_auto_unhide",np.HIDDEN_PREVENT_AUTO_UNHIDE="hidden_prevent_auto_unhide";var Up,Rp=function(n){i(u,n);var a=f(u);function u(t,n){var s,i,o,c,l,h,d,f,p,v,m,g,y,k,b,E,w,C,x,T;(r(this,u),(s=a.call(this,t,n))._unreadMemberStateMap=new Map,s._undeliveredMemberStateMap=new Map,s._typingStatus=new Map,s._lastMemberCountUpdated=0,s._typingStarted=0,s._typingEnded=0,s.isDistinct=!1,s.isSuper=!1,s.isBroadcast=!1,s.isExclusive=!1,s.isPublic=!1,s.isDiscoverable=!0,s.isAccessCodeRequired=!1,s.isPushEnabled=!1,s.unreadMessageCount=0,s.unreadMentionCount=0,s.members=[],s.memberCount=0,s.joinedMemberCount=0,s.hiddenState=e.HiddenState.UNHIDDEN,s.lastMessage=null,s.messageOffsetTimestamp=0,s.messageSurvivalSeconds=-1,s.myMemberState=e.MemberState.NONE,s.myRole=e.Role.NONE,s.myMutedState=e.MutedState.UNMUTED,s.myLastRead=0,s.myCountPreference=e.CountPreference.ALL,s.myPushTriggerOption=e.PushTriggerOption.DEFAULT,s.inviter=null,s.invitedAt=0,s.joinedAt=0,s.pinnedMessageIds=[],s.lastPinnedMessage=null,s._pinnedMessagesUpdatedAt=0,s._myMutedRemainingTime=-1,s.channelType=e.ChannelType.GROUP,s.isDistinct=null!==(i=n.is_distinct)&&void 0!==i&&i,s.isSuper=null!==(o=n.is_super)&&void 0!==o&&o,s.isBroadcast=null!==(c=n.is_broadcast)&&void 0!==c&&c,s.isExclusive=null!==(l=n.is_exclusive)&&void 0!==l&&l,s.isPublic=null!==(h=n.is_public)&&void 0!==h&&h,s.isDiscoverable=null!==(d=n.is_discoverable)&&void 0!==d?d:s.isPublic,s.isAccessCodeRequired=null!==(f=n.is_access_code_required)&&void 0!==f&&f,s.isPushEnabled=null!==(p=n.is_push_enabled)&&void 0!==p&&p,Array.isArray(n.members))&&(T=s.members).push.apply(T,_(n.members.map((function(e){return new ed(s._iid,e)}))));return s.memberCount=null!==(v=n.member_count)&&void 0!==v?v:0,s.joinedMemberCount=null!==(m=n.joined_member_count)&&void 0!==m?m:0,s.hiddenState=D(e.HiddenState,n.hidden_state)?n.hidden_state:e.HiddenState.UNHIDDEN,s.messageOffsetTimestamp=null!==(g=n.ts_message_offset)&&void 0!==g?g:0,s.messageSurvivalSeconds=null!==(y=n.message_survival_seconds)&&void 0!==y?y:-1,s.lastMessage=n.last_message?Ds(s._iid,Object.assign({channel_type:s.channelType},n.last_message)):null,n.read_receipt&&Object.keys(n.read_receipt).forEach((function(e){L("number",n.read_receipt[e])&&s._updateUnreadMemberState(e,n.read_receipt[e])})),n.delivery_receipt&&Object.keys(n.delivery_receipt).forEach((function(e){L("number",n.delivery_receipt[e])&&s._updateUndeliveredMemberState(e,n.delivery_receipt[e])})),s.myMemberState=D(e.MemberState,n.member_state)?n.member_state:e.MemberState.NONE,s.myRole=D(e.Role,n.my_role)?n.my_role:e.Role.NONE,D(e.MutedState,n.is_muted)?s.myMutedState=n.is_muted:L("boolean",n.is_muted)?s.myMutedState=n.is_muted?e.MutedState.MUTED:e.MutedState.UNMUTED:s.myMutedState=e.MutedState.UNMUTED,s.myCountPreference=D(e.CountPreference,n.count_preference)?n.count_preference:e.CountPreference.ALL,s.myPushTriggerOption=D(e.PushTriggerOption,n.push_trigger_option)?n.push_trigger_option:e.PushTriggerOption.ALL,s.myLastRead=null!==(k=n.user_last_read)&&void 0!==k?k:0,s.inviter=n.inviter?new La(s._iid,n.inviter):null,s.invitedAt=null!==(b=n.invited_at)&&void 0!==b?b:0,s.joinedAt=null!==(E=n.joined_ts)&&void 0!==E?E:0,s._updateUnreadCount(null!==(w=n.unread_message_count)&&void 0!==w?w:0,null!==(C=n.unread_mention_count)&&void 0!==C?C:0),s.pinnedMessageIds=null!==(x=n.pinned_message_ids)&&void 0!==x?x:[],s.lastPinnedMessage=n.latest_pinned_message?Ds(s._iid,Object.assign({channel_type:s.channelType},n.latest_pinned_message)):null,s}return s(u,[{key:"isHidden",get:function(){return this.hiddenState!==e.HiddenState.UNHIDDEN}},{key:"isTyping",get:function(){return this._typingStatus.size>0}},{key:"cachedUnreadMemberState",get:function(){var e,t={},n=y(this._unreadMemberStateMap);try{for(n.s();!(e=n.n()).done;){var r=v(e.value,2),a=r[0],s=r[1];t[a]=s}}catch(e){n.e(e)}finally{n.f()}return t}},{key:"cachedUndeliveredMemberState",get:function(){var e,t={},n=y(this._undeliveredMemberStateMap);try{for(n.s();!(e=n.n()).done;){var r=v(e.value,2),a=r[0],s=r[1];t[a]=s}}catch(e){n.e(e)}finally{n.f()}return t}},{key:"_shouldUpdateLastMessageWith",value:function(e){return!(e instanceof Es&&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=ns.of(this._iid).maxSuperGroupChannelUnreadCount;this.unreadMessageCount=r&&t>=r?r:t}else this.unreadMessageCount=t;else this.unreadMessageCount=0;else this.unreadMessageCount=0;"number"==typeof n&&n>=0&&(this.myCountPreference===e.CountPreference.ALL||this.myCountPreference===e.CountPreference.UNREAD_MENTION_COUNT_ONLY)?this.unreadMentionCount=n:this.unreadMentionCount=0}},{key:"_updateUnreadMemberState",value:function(e,t){var n=this._unreadMemberStateMap.get(e);return(!n||n1&&void 0!==arguments[1]?arguments[1]:(new Date).getTime();t>0?this._typingStatus.set(e.userId,{user:e,ts:t}):this._typingStatus.delete(e.userId)}},{key:"_clearTypingStatus",value:function(){this._typingStatus.clear(),this._typingStarted=0,this._typingEnded=0}},{key:"_setLatestMemberCount",value:function(e,t,n){var r=!1;return n>=this._lastMemberCountUpdated&&(this._lastMemberCountUpdated=n,r=e!==this.memberCount||t!==this.joinedMemberCount,this.memberCount=e,this.joinedMemberCount=t),r}},{key:"isReadMessage",value:function(e){var t=ns.of(this._iid).sdkState,n=this._unreadMemberStateMap.get(t.userId);return n&&n>=e.createdAt}},{key:"serialize",value:function(){var e=this;return Ma(this,(function(t){t.cachedUnreadMemberState=e.cachedUnreadMemberState,t.cachedUndeliveredMemberState=e.cachedUndeliveredMemberState}))}},{key:"createMessageCollection",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return new Kf(this._iid,Object.assign({channel:this},e))}},{key:"createMemberListQuery",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return new rp(this._iid,this.url,e)}},{key:"createPinnedMessageListQuery",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return new Op(this._iid,this.url,this.channelType,e)}},{key:"addMember",value:function(t){var n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0;if(!this.isExclusive&&!this.isSuper&&!this.isBroadcast){var r=this.members.findIndex((function(e){return e.userId===t.userId}));if(r>-1){var a=this.members[r];a.state===e.MemberState.JOINED&&(t.state=a.state),this.members.splice(r,1),this.memberCount--}this.members.push(t),this.memberCount++,this._updateUnreadMemberState(t.userId,n),this._updateUndeliveredMemberState(t.userId,n)}}},{key:"removeMember",value:function(e){if(!this.isExclusive&&!this.isSuper&&!this.isBroadcast){var t=e instanceof ed?e.userId:e,n=this.members.findIndex((function(e){return e.userId===t}));if(n>-1)return this.members.splice(n,1),this.memberCount--,!0}return!1}},{key:"getUnreadMemberCount",value:function(t){if(t instanceof Es&&!this.isExclusive&&!this.isSuper&&!this.isBroadcast){var n,r=ns.of(this._iid).sdkState,a=t.createdAt,s=0,i=y(this.members);try{for(i.s();!(n=i.n()).done;){var o=n.value;if(r.userId!==o.userId&&o.state===e.MemberState.JOINED&&t.sender.userId!==o.userId)(this.cachedUnreadMemberState[o.userId]||0)1&&void 0!==arguments[1]&&arguments[1],r=ns.of(this._iid).sdkState;if(!r.userId||this.isExclusive||this.isSuper||this.isBroadcast)return[];var a=e instanceof Es?e.sender:null,s=[];return this.members.forEach((function(i){(n||i.userId!==r.userId&&i.userId!==(null==a?void 0:a.userId))&&(t._unreadMemberStateMap.get(i.userId)>=e.createdAt&&s.push(i))})),s}},{key:"getUnreadMembers",value:function(e){var t=this,n=arguments.length>1&&void 0!==arguments[1]&&arguments[1],r=ns.of(this._iid).sdkState;if(!r.userId||this.isExclusive||this.isSuper||this.isBroadcast)return[];var a=e instanceof Es?e.sender:null,s=[];return this.members.forEach((function(i){(n||i.userId!==r.userId&&i.userId!==(null==a?void 0:a.userId))&&(t._unreadMemberStateMap.get(i.userId)0&&void 0!==arguments[0]&&arguments[0],n=ns.of(this._iid).sdkState;if(!n.userId||this.isExclusive||this.isSuper||this.isBroadcast)return null;var r={};return this.members.forEach((function(a){if(t||a.userId!==n.userId){var s=e._unreadMemberStateMap.get(a.userId);r[a.userId]=new td(e._iid,{channel_url:e.url,channel_type:e.channelType,user:ed.payloadify(a),ts:s})}})),r}},{key:"getTypingUsers",value:function(){var e=[];return this._typingStatus.forEach((function(t){var n=t.user;e.push(n)})),e}},{key:"invalidateTypingStatus",value:function(){var e=this,t=ns.of(this._iid).typingIndicatorInvalidateTime,n=Date.now(),r=!1;return this._typingStatus.forEach((function(a,s){var i=a.ts;n-i>=t&&(e._typingStatus.delete(s),r=!0)})),r}},{key:"refresh",value:function(){return b(this,void 0,void 0,t().mark((function n(){var r,a,s,i,o,u,c;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return r=ns.of(this._iid),a=r.requestQueue,s=r.dispatcher,i=new Cd({channelUrl:this.url}),t.next=4,a.send(i);case 4:return o=t.sent,u=o.as(xd),c=u.channel,s.dispatch(new ru({channels:[c],source:e.GroupChannelEventSource.REQUEST_CHANNEL})),t.abrupt("return",c);case 8:case"end":return t.stop()}}),n,this)})))}},{key:"freeze",value:function(){var n=this,r=Object.create(null,{freeze:{get:function(){return p(o(u.prototype),"freeze",n)}}});return b(this,void 0,void 0,t().mark((function n(){var a;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,r.freeze.call(this);case 2:a=ns.of(this._iid),a.dispatcher.dispatch(new ru({channels:[this],source:e.GroupChannelEventSource.EVENT_CHANNEL_HIDDEN}));case 4:case"end":return t.stop()}}),n,this)})))}},{key:"unfreeze",value:function(){var n=this,r=Object.create(null,{unfreeze:{get:function(){return p(o(u.prototype),"unfreeze",n)}}});return b(this,void 0,void 0,t().mark((function n(){var a;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,r.unfreeze.call(this);case 2:a=ns.of(this._iid),a.dispatcher.dispatch(new ru({channels:[this],source:e.GroupChannelEventSource.EVENT_CHANNEL_UNHIDDEN}));case 4:case"end":return t.stop()}}),n,this)})))}},{key:"updateChannel",value:function(n){return b(this,void 0,void 0,t().mark((function r(){var a,s,i,o,u,c,l,h;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return a=Object.assign(Object.assign({},Wf),n),Ua(Yf(a)).throw(M.invalidParameters),s=ns.of(this._iid),i=s.dispatcher,o=s.requestQueue,u=new ip(Object.assign({channelUrl:this.url},a)),t.next=6,o.send(u);case 6:return c=t.sent,l=c.as(op),h=l.channel,i.dispatch(new ru({channels:[h],source:e.GroupChannelEventSource.EVENT_CHANNEL_UPDATED})),t.abrupt("return",h);case 10:case"end":return t.stop()}}),r,this)})))}},{key:"invite",value:function(e){return b(this,void 0,void 0,t().mark((function n(){return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return Ua(e.every((function(e){return e instanceof La}))).throw(M.invalidParameters),t.abrupt("return",this.inviteWithUserIds(e.map((function(e){return e.userId}))));case 2:case"end":return t.stop()}}),n,this)})))}},{key:"inviteWithUserIds",value:function(n){return b(this,void 0,void 0,t().mark((function r(){var a,s,i,o,u,c,l;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return Ua(F("string",n)).throw(M.invalidParameters),a=ns.of(this._iid),s=a.dispatcher,i=a.requestQueue,o=new Wd({channelUrl:this.url,userIds:n}),t.next=5,i.send(o);case 5:return u=t.sent,c=u.as(Yd),l=c.channel,s.dispatch(new ru({channels:[l],source:e.GroupChannelEventSource.EVENT_CHANNEL_INVITED})),t.abrupt("return",l);case 9:case"end":return t.stop()}}),r,this)})))}},{key:"join",value:function(){var n=arguments.length>0&&void 0!==arguments[0]?arguments[0]:null;return b(this,void 0,void 0,t().mark((function r(){var a,s,i,o,u,c,l,h;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return Ua(L("string",n)||null===n).throw(M.invalidParameters),a=ns.of(this._iid),s=a.dispatcher,i=a.sdkState,o=a.requestQueue,u=new zd({channelUrl:this.url,userId:i.userId,accessCode:n}),t.next=5,o.send(u);case 5:return c=t.sent,l=c.as(Vd),(h=l.channel).myMemberState=this.myMemberState=e.MemberState.JOINED,s.dispatch(new ru({channels:[h],source:e.GroupChannelEventSource.EVENT_CHANNEL_JOINED})),t.abrupt("return",this);case 10:case"end":return t.stop()}}),r,this)})))}},{key:"leave",value:function(){var n=arguments.length>0&&void 0!==arguments[0]&&arguments[0];return b(this,void 0,void 0,t().mark((function r(){var a,s,i,o;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return a=ns.of(this._iid),s=a.sdkState,i=a.requestQueue,o=new Qd({channelUrl:this.url,userId:s.userId,shouldRemoveOperatorStatus:n}),t.next=4,i.send(o);case 4:this.myMemberState=e.MemberState.NONE;case 5:case"end":return t.stop()}}),r,this)})))}},{key:"acceptInvitation",value:function(){var n=arguments.length>0&&void 0!==arguments[0]?arguments[0]:null;return b(this,void 0,void 0,t().mark((function r(){var a,s,i,o,u,c,l,h;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return Ua(L("string",n)||null===n).throw(M.invalidParameters),a=ns.of(this._iid),s=a.dispatcher,i=a.sdkState,o=a.requestQueue,u=new ap({channelUrl:this.url,userId:i.userId,accessCode:n}),t.next=5,o.send(u);case 5:return c=t.sent,l=c.as(sp),(h=l.channel).myMemberState=this.myMemberState=e.MemberState.JOINED,s.dispatch(new ru({channels:[h],source:e.GroupChannelEventSource.EVENT_CHANNEL_ACCEPTED_INVITE})),t.abrupt("return",this);case 10:case"end":return t.stop()}}),r,this)})))}},{key:"declineInvitation",value:function(){return b(this,void 0,void 0,t().mark((function n(){var r,a,s,i;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return r=ns.of(this._iid),a=r.sdkState,s=r.requestQueue,i=new Jd({channelUrl:this.url,userId:a.userId}),t.next=4,s.send(i);case 4:return this.myMemberState=e.MemberState.NONE,t.abrupt("return",this);case 6:case"end":return t.stop()}}),n,this)})))}},{key:"sendUserMessage",value:function(t){var n=this,r=new _i,a=ns.of(this._iid).dispatcher,s=Jo.of(this._iid);return p(o(u.prototype),"sendUserMessage",this).call(this,t).onPending((function(e){s.completeCurrentAndProcessNextAutoResend(e),r._trigger(null,e)})).onFailed((function(e,t){t&&s.completeCurrentAndProcessNextAutoResend(t),r._trigger(e,t)})).onSucceeded((function(t){n.hiddenState===e.HiddenState.HIDDEN_ALLOW_AUTO_UNHIDE&&(n.hiddenState=e.HiddenState.UNHIDDEN),s.completeCurrentAndProcessNextAutoResend(t),n._shouldUpdateLastMessageWith(t)&&(n.lastMessage=t),wf.of(n._iid).handlers.map((function(e){return e.onChannelChanged(n)})),a.dispatch(new ru({channels:[n],source:e.GroupChannelEventSource.EVENT_MESSAGE_SENT})),r._trigger(null,t)})),r}},{key:"updateUserMessage",value:function(n,r){var a=this,s=Object.create(null,{updateUserMessage:{get:function(){return p(o(u.prototype),"updateUserMessage",a)}}});return b(this,void 0,void 0,t().mark((function a(){var i,o,u,c,l,h=this;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return i=ns.of(this._iid),o=i.dispatcher,t.next=3,s.updateUserMessage.call(this,n,r);case 3:return u=t.sent,c=!1,!u.silent&&this._shouldUpdateLastMessageWith(u)&&(this.lastMessage=u,c=!0),l=!1,this.lastPinnedMessage&&this.lastPinnedMessage.messageId===u.messageId&&(this.lastPinnedMessage=u,c=!0,l=!0),c&&(wf.of(this._iid).handlers.map((function(e){return e.onChannelChanged(h)})),o.dispatch(new ru({channels:[this],source:l?e.GroupChannelEventSource.EVENT_PINNED_MESSAGE_UPDATED:e.GroupChannelEventSource.EVENT_MESSAGE_UPDATED}))),l&&wf.of(this._iid).handlers.map((function(e){return e.onPinnedMessageUpdated(h)})),o.dispatch(new ei({messages:[u],source:e.MessageEventSource.EVENT_MESSAGE_UPDATED})),t.abrupt("return",u);case 12:case"end":return t.stop()}}),a,this)})))}},{key:"_autoResendUserMessage",value:function(t){var n=this,r=new _i,a=ns.of(this._iid).dispatcher,s=Jo.of(this._iid);return p(o(u.prototype),"_autoResendUserMessage",this).call(this,t).onPending((function(e){s.completeCurrentAndProcessNextAutoResend(e),r._trigger(null,e)})).onFailed((function(e,t){s.completeCurrentAndProcessNextAutoResend(t),r._trigger(e,t)})).onSucceeded((function(t){var i=wf.of(n._iid);s.completeCurrentAndProcessNextAutoResend(t),n._shouldUpdateLastMessageWith(t)&&(n.lastMessage=t),i.handlers.map((function(e){return e.onChannelChanged(n)})),a.dispatch(new ru({channels:[n],source:e.GroupChannelEventSource.EVENT_MESSAGE_SENT})),r._trigger(null,t)})),r}},{key:"sendFileMessage",value:function(t){var n=this,r=new _i,a=ns.of(this._iid).dispatcher,s=Jo.of(this._iid);return p(o(u.prototype),"sendFileMessage",this).call(this,t).onPending((function(e){s.completeCurrentAndProcessNextAutoResend(e),r._trigger(null,e)})).onFailed((function(e,t){t&&s.completeCurrentAndProcessNextAutoResend(t),r._trigger(e,t)})).onSucceeded((function(t){var i=wf.of(n._iid);s.completeCurrentAndProcessNextAutoResend(t),n._shouldUpdateLastMessageWith(t)&&(n.lastMessage=t),i.handlers.map((function(e){return e.onChannelChanged(n)})),a.dispatch(new ru({channels:[n],source:e.GroupChannelEventSource.EVENT_MESSAGE_SENT})),r._trigger(null,t)})),r}},{key:"updateFileMessage",value:function(n,r){var a=this,s=Object.create(null,{updateFileMessage:{get:function(){return p(o(u.prototype),"updateFileMessage",a)}}});return b(this,void 0,void 0,t().mark((function a(){var i,o,u,c,l,h=this;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return i=ns.of(this._iid),o=i.dispatcher,t.next=3,s.updateFileMessage.call(this,n,r);case 3:return u=t.sent,c=!1,!u.silent&&this._shouldUpdateLastMessageWith(u)&&(this.lastMessage=u,c=!0),l=!1,this.lastPinnedMessage&&this.lastPinnedMessage.messageId===u.messageId&&(this.lastPinnedMessage=u,c=!0,l=!0),c&&(wf.of(this._iid).handlers.map((function(e){return e.onChannelChanged(h)})),o.dispatch(new ru({channels:[this],source:l?e.GroupChannelEventSource.EVENT_PINNED_MESSAGE_UPDATED:e.GroupChannelEventSource.EVENT_MESSAGE_UPDATED}))),l&&wf.of(this._iid).handlers.map((function(e){return e.onPinnedMessageUpdated(h)})),o.dispatch(new ei({messages:[u],source:e.MessageEventSource.EVENT_MESSAGE_UPDATED})),t.abrupt("return",u);case 12:case"end":return t.stop()}}),a,this)})))}},{key:"_autoResendFileMessage",value:function(t){var n=this,r=new _i,a=ns.of(this._iid).dispatcher,s=Jo.of(this._iid);return p(o(u.prototype),"_autoResendFileMessage",this).call(this,t).onPending((function(e){s.completeCurrentAndProcessNextAutoResend(e),r._trigger(null,e)})).onFailed((function(e,t){s.completeCurrentAndProcessNextAutoResend(t),r._trigger(e,t)})).onSucceeded((function(t){var i=wf.of(n._iid);s.completeCurrentAndProcessNextAutoResend(t),n._shouldUpdateLastMessageWith(t)&&(n.lastMessage=t),i.handlers.map((function(e){return e.onChannelChanged(n)})),a.dispatch(new ru({channels:[n],source:e.GroupChannelEventSource.EVENT_MESSAGE_SENT})),r._trigger(null,t)})),r}},{key:"deleteMessage",value:function(n){var r=this,a=Object.create(null,{deleteMessage:{get:function(){return p(o(u.prototype),"deleteMessage",r)}}});return b(this,void 0,void 0,t().mark((function r(){var s;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,a.deleteMessage.call(this,n);case 2:0===n.messageId&&n instanceof Es&&(s=ns.of(this._iid),s.dispatcher.dispatch(new ni({reqId:n.reqId,source:e.MessageEventSource.EVENT_MESSAGE_DELETED})));case 3:case"end":return t.stop()}}),r,this)})))}},{key:"hide",value:function(n){return b(this,void 0,void 0,t().mark((function r(){var a,s,i,o,u,c,l,h,d;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return a=Object.assign(Object.assign({},Zf),n),Ua(Jf(a)).throw(M.invalidParameters),s=ns.of(this._iid),i=s.dispatcher,o=s.sdkState,u=s.requestQueue,c=new rf(Object.assign({channelUrl:this.url,userId:o.userId},a)),t.next=6,u.send(c);case 6:return l=t.sent,h=l.as(af),d=h.messageOffsetTimestamp,this.hiddenState=a.allowAutoUnhide?e.HiddenState.HIDDEN_ALLOW_AUTO_UNHIDE:e.HiddenState.HIDDEN_PREVENT_AUTO_UNHIDE,a.hidePreviousMessages&&this._updateUnreadCount(0,0),d&&(this.messageOffsetTimestamp=d),i.dispatch(new ru({channels:[this],source:e.GroupChannelEventSource.EVENT_CHANNEL_HIDDEN})),t.abrupt("return",this);case 13:case"end":return t.stop()}}),r,this)})))}},{key:"unhide",value:function(){return b(this,void 0,void 0,t().mark((function n(){var r,a,s,i;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return r=ns.of(this._iid),a=r.dispatcher,s=r.requestQueue,i=new cp({channelUrl:this.url}),t.next=4,s.send(i);case 4:return this.hiddenState=e.HiddenState.UNHIDDEN,a.dispatch(new ru({channels:[this],source:e.GroupChannelEventSource.EVENT_CHANNEL_UNHIDDEN})),t.abrupt("return",this);case 7:case"end":return t.stop()}}),n,this)})))}},{key:"delete",value:function(){return b(this,void 0,void 0,t().mark((function e(){var n,r,a;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n=ns.of(this._iid),r=n.requestQueue,a=new up({channelUrl:this.url}),e.next=4,r.send(a);case 4:case"end":return e.stop()}}),e,this)})))}},{key:"markAsRead",value:function(){return b(this,void 0,void 0,t().mark((function n(){var r,a,s,i,o,u,c,l,h=this;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return r=ns.of(this._iid),a=r.sdkState,s=r.dispatcher,i=r.requestQueue,o=new $d({channelUrl:this.url}),t.next=4,i.send(o);case 4:u=t.sent,c=u.as(ef),l=c.readStatus,this._updateUnreadMemberState(a.userId,l.readAt),(this.unreadMessageCount>0||this.unreadMentionCount>0)&&(this._updateUnreadCount(0,0),wf.of(this._iid).handlers.map((function(e){return e.onChannelChanged(h)}))),s.dispatch(new ru({channels:[this],source:e.GroupChannelEventSource.EVENT_CHANNEL_READ}));case 9:case"end":return t.stop()}}),n,this)})))}},{key:"markAsDelivered",value:function(){return b(this,void 0,void 0,t().mark((function e(){var n,r,a,s;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n=ns.of(this._iid),r=n.sdkState,a=n.requestQueue,s=new tf({channelUrl:this.url,userId:r.userId}),e.next=4,a.send(s);case 4:case"end":return e.stop()}}),e,this)})))}},{key:"startTyping",value:function(){return b(this,void 0,void 0,t().mark((function e(){var n,r,a,s,i;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:n=ns.of(this._iid),r=n.requestQueue,a=n.typingIndicatorThrottle,(s=(new Date).getTime())-this._typingStarted>=a&&(this._typingStarted=s,this._typingEnded=0,i=new of({channelUrl:this.url,time:this._typingStarted}),r.send(i));case 3:case"end":return e.stop()}}),e,this)})))}},{key:"endTyping",value:function(){return b(this,void 0,void 0,t().mark((function e(){var n,r,a,s,i;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:n=ns.of(this._iid),r=n.requestQueue,a=n.typingIndicatorThrottle,(s=(new Date).getTime())-this._typingEnded>=a&&(this._typingStarted=0,this._typingEnded=s,i=new cf({channelUrl:this.url,time:this._typingStarted}),r.send(i));case 3:case"end":return e.stop()}}),e,this)})))}},{key:"createScheduledUserMessage",value:function(e){e=Object.assign(Object.assign({},Fo),e),Ua(function(e){return Eo(e)&&L("number",e.scheduledAt,!0)}(e)).throw(M.invalidParameters);var t=new _i;return this._createScheduledUserMessage(e,t),t}},{key:"updateScheduledUserMessage",value:function(e,n){return b(this,void 0,void 0,t().mark((function r(){var a,s,i,o,u,c,l;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return a=Object.assign(Object.assign({},_p),n),Ua(mp(a)).throw(M.invalidParameters),s=ns.of(this._iid),i=s.requestQueue,o=new kp(Object.assign({reqId:this._generateRequestId(),scheduledMessageId:e,channelType:this.channelType,channelUrl:this.url},a)),t.next=6,i.send(o);case 6:return u=t.sent,c=u.as(Sh),l=c.message,t.abrupt("return",l);case 9:case"end":return t.stop()}}),r,this)})))}},{key:"createScheduledFileMessage",value:function(e){var n=this;e=Object.assign(Object.assign({},Go),e),Ua(function(e){return go(e)&&L("number",e.scheduledAt)&&(H(e.file)||L("string",e.fileUrl))&&L("string",e.fileName,!0)&&L("string",e.mimeType,!0)&&L("number",e.fileSize,!0)&&(null===e.thumbnailSizes||e.thumbnailSizes.every((function(e){return L("object",e)&&e.maxWidth>0&&e.maxHeight>0})))}(e)).throw(M.invalidParameters);var r=Date.now(),a=this._generateRequestId(),s=new _i;return sa(2).then((function(){var i=n._createPendingScheduledFileMessage(e,a,r);ua((function(){return b(n,void 0,void 0,t().mark((function e(){return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",s._trigger(null,i));case 1:case"end":return e.stop()}}),e)})))}))})),H(e.file)?this._uploadFileAndUpdateParams(e).then((function(){return n._createScheduledFileMessage(e,s,a,r)})):this._createScheduledFileMessage(e,s,a,r),s}},{key:"updateScheduledFileMessage",value:function(e,n){return b(this,void 0,void 0,t().mark((function r(){var a,s,i,o,u,c,l;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(a=Object.assign(Object.assign({},pp),n),Ua(vp(a)).throw(M.invalidParameters),!H(a.file)){t.next=5;break}return t.next=5,this._uploadFileAndUpdateParams(a);case 5:return s=new gp(Object.assign({reqId:this._generateRequestId(),scheduledMessageId:e,channelType:this.channelType,channelUrl:this.url},a)),i=ns.of(this._iid),o=i.requestQueue,t.next=9,o.send(s);case 9:return u=t.sent,c=u.as(yp),l=c.message,t.abrupt("return",l);case 12:case"end":return t.stop()}}),r,this)})))}},{key:"cancelScheduledMessage",value:function(e){return b(this,void 0,void 0,t().mark((function n(){var r,a,s;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return r=new bp({scheduledMessageId:e,channelType:this.channelType,channelUrl:this.url}),a=ns.of(this._iid),s=a.requestQueue,t.next=4,s.send(r);case 4:return t.abrupt("return");case 5:case"end":return t.stop()}}),n,this)})))}},{key:"sendScheduledMessageNow",value:function(e){return b(this,void 0,void 0,t().mark((function n(){var r,a,s;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return r=new Ep({scheduledMessageId:e,channelType:this.channelType,channelUrl:this.url}),a=ns.of(this._iid),s=a.requestQueue,t.next=4,s.send(r);case 4:return t.abrupt("return");case 5:case"end":return t.stop()}}),n,this)})))}},{key:"getMyPushTriggerOption",value:function(){return b(this,void 0,void 0,t().mark((function e(){var n,r,a,s,i,o,u;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n=ns.of(this._iid),r=n.sdkState,a=n.requestQueue,s=new xp({userId:r.userId,channelUrl:this.url}),e.next=4,a.send(s);case 4:return i=e.sent,o=i.as(Tp),u=o.pushTriggerOption,this.myPushTriggerOption=u,e.abrupt("return",u);case 8:case"end":return e.stop()}}),e,this)})))}},{key:"setMyPushTriggerOption",value:function(n){return b(this,void 0,void 0,t().mark((function r(){var a,s,i,o,u,c,l,h;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return Ua(D(e.PushTriggerOption,n)).throw(M.invalidParameters),a=ns.of(this._iid),s=a.dispatcher,i=a.sdkState,o=a.requestQueue,u=new wp({userId:i.userId,channelUrl:this.url,pushTriggerOption:n}),t.next=5,o.send(u);case 5:return c=t.sent,l=c.as(Cp),h=l.pushTriggerOption,this.myPushTriggerOption=h,s.dispatch(new ru({channels:[this],source:e.GroupChannelEventSource.EVENT_CHANNEL_UPDATED})),t.abrupt("return",h);case 10:case"end":return t.stop()}}),r,this)})))}},{key:"setMyCountPreference",value:function(n){return b(this,void 0,void 0,t().mark((function r(){var a,s,i,o,u,c,l,h;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return Ua(D(e.CountPreference,n)).throw(M.invalidParameters),a=ns.of(this._iid),s=a.dispatcher,i=a.sdkState,o=a.requestQueue,u=new lp({channelUrl:this.url,userId:i.userId,countPreference:n}),t.next=5,o.send(u);case 5:return c=t.sent,l=c.as(hp),h=l.countPreference,this.myCountPreference=h,this._updateUnreadCount(this.unreadMessageCount,this.unreadMentionCount),s.dispatch(new ru({channels:[this],source:e.GroupChannelEventSource.EVENT_CHANNEL_UPDATED})),t.abrupt("return",h);case 11:case"end":return t.stop()}}),r,this)})))}},{key:"resetMyHistory",value:function(){return b(this,void 0,void 0,t().mark((function n(){var r,a,s,i,o,u,c;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return r=ns.of(this._iid),a=r.dispatcher,s=r.requestQueue,i=new dp({channelUrl:this.url}),t.next=4,s.send(i);case 4:return o=t.sent,u=o.as(fp),c=u.messageOffsetTimestamp,this.messageOffsetTimestamp=c,a.dispatch(new ru({channels:[this],source:e.GroupChannelEventSource.EVENT_CHANNEL_RESET_HISTORY})),t.abrupt("return",this);case 9:case"end":return t.stop()}}),n,this)})))}},{key:"pinMessage",value:function(e){return b(this,void 0,void 0,t().mark((function n(){var r,a,s;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return Ua(L("number",e)&&e>0).throw(M.invalidParameters),r=ns.of(this._iid),a=r.requestQueue,s=new Sp({channelType:this.channelType,channelUrl:this.url,messageId:e}),t.next=5,a.send(s);case 5:case"end":return t.stop()}}),n,this)})))}},{key:"unpinMessage",value:function(e){return b(this,void 0,void 0,t().mark((function n(){var r,a,s;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return Ua(L("number",e)&&e>0).throw(M.invalidParameters),r=ns.of(this._iid),a=r.requestQueue,s=new Ip({channelType:this.channelType,channelUrl:this.url,messageId:e}),t.next=5,a.send(s);case 5:case"end":return t.stop()}}),n,this)})))}},{key:"_uploadFileAndUpdateParams",value:function(e){return b(this,void 0,void 0,t().mark((function n(){var r,a,s,i,o,u,c,l,h,d,f,p;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(!H(e.file)){t.next=11;break}return r=ns.of(this._iid),a=r.requestQueue,s=new as({file:e.file,channelUrl:this.url,thumbnailSizes:e.thumbnailSizes,requestId:this._generateRequestId()}),t.next=5,a.send(s);case 5:i=t.sent,o=i.as(ss),u=o.url,c=o.fileSize,l=void 0===c?e.fileSize:c,h=o.thumbnailSizes,d=void 0===h?e.thumbnailSizes:h,f=o.requireAuth,p=void 0!==f&&f,e.fileUrl=u,e.fileSize=l,e.thumbnailSizes=d,e.requireAuth=p;case 11:case"end":return t.stop()}}),n,this)})))}}],[{key:"payloadify",value:function(e){return e?ee(Object.assign(Object.assign({},p(o(u),"payloadify",this).call(this,e)),{is_access_code_required:e.isAccessCodeRequired,is_distinct:e.isDistinct,is_super:e.isSuper,is_broadcast:e.isBroadcast,is_exclusive:e.isExclusive,is_public:e.isPublic,is_discoverable:e.isDiscoverable,is_muted:e.myMutedState,is_push_enabled:e.isPushEnabled,unread_message_count:e.unreadMessageCount,unread_mention_count:e.unreadMentionCount,push_trigger_option:e.myPushTriggerOption,count_preference:e.myCountPreference,hidden_state:e.hiddenState,member_count:e.memberCount,joined_member_count:e.joinedMemberCount,member_state:e.myMemberState,my_role:e.myRole,user_last_read:e.myLastRead,ts_message_offset:e.messageOffsetTimestamp,message_survival_seconds:e.messageSurvivalSeconds,read_receipt:e.cachedUnreadMemberState,delivery_receipt:e.cachedUndeliveredMemberState,members:e.members.map((function(e){return ed.payloadify(e)})),last_message:Ls(e.lastMessage),inviter:e.inviter?La.payloadify(e.inviter):null,invited_at:e.invitedAt,joined_ts:e.joinedAt,pinned_message_ids:e.pinnedMessageIds,latest_pinned_message:Ls(e.lastPinnedMessage)})):null}}]),u}(zh),Lp={},Dp=function(){function n(a){var s=this,i=a._iid,o=a.limit,u=void 0===o?100:o;r(this,n),this._sync=null,this._connectionEventContext=null,this.ref=0,this._metadata=null,this._iid=i,this._limit=u;var c,l=ns.of(this._iid),h=l.sdkState,d=l.dispatcher,f=l.logger;this._metadataKey=(c=h.userId,"sendbird:".concat(c,"@groupchannel/sync.meta"));var p=function(e){return"sendbird:".concat(e,"@groupchannel/sync")}(h.userId);this._sync=new Cf(p,(function(){return b(s,void 0,void 0,t().mark((function n(){var r,a,s,i,o,u;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return r={hasNext:!0,nextToken:""},t.next=3,this.loadMetadata();case 3:if(f.debug("channel background sync from",this._metadata.token),this._metadata.completed){t.next=31;break}return t.prev=5,s=wf.of(this._iid),t.next=9,s.getMyGroupChannels(this._metadata.token,{includeEmpty:!0,order:e.GroupChannelListOrder.CHRONOLOGICAL},this._limit,e.GroupChannelEventSource.SYNC_CHANNEL_BACKGROUND);case 9:return i=t.sent,o=i.channels,u=i.token,r.hasNext=o.length>=this._limit&&!!u,r.nextToken=u,this._metadata.token=u,(a=this._metadata.range).extends.apply(a,_(o.map((function(e){return e.createdAt})))),this._metadata.completed=!r.hasNext,f.debug("channel background sync progress",r),t.next=20,this.saveMetadata();case 20:t.next=29;break;case 22:if(t.prev=22,t.t0=t.catch(5),f.debug("channel background sync error",t.t0),!(t.t0 instanceof M&&t.t0.isInvalidTokenError)){t.next=28;break}return t.next=28,this.clearMetaData();case 28:throw t.t0;case 29:t.next=33;break;case 31:r.hasNext=!1,r.nextToken="";case 33:return t.abrupt("return",r);case 34:case"end":return t.stop()}}),n,this,[[5,22]])})))})),this._connectionEventContext=d.on((function(e){if(e instanceof Dr)if(e.stateType===Nr.CONNECTED)s.resume();else s.pause()}))}return s(n,[{key:"range",get:function(){var e;return null===(e=this._metadata)||void 0===e?void 0:e.range}},{key:"completed",get:function(){var e;return!!(null===(e=this._metadata)||void 0===e?void 0:e.completed)}},{key:"loadMetadata",value:function(){return b(this,void 0,void 0,t().mark((function e(){var n,r,a;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(this._metadata){e.next=6;break}return n=ns.of(this._iid),r=n.cacheContext,e.next=4,r.preference.get(this._metadataKey);case 4:a=e.sent,this._metadata={token:a?a.token:"",range:new kf(a?a.range:{top:Number.MAX_SAFE_INTEGER,bottom:0}),completed:!!a&&a.completed};case 6:return e.abrupt("return",this._metadata);case 7:case"end":return e.stop()}}),e,this)})))}},{key:"saveMetadata",value:function(){return b(this,void 0,void 0,t().mark((function e(){var n,r;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!this._metadata){e.next=5;break}return n=ns.of(this._iid),r=n.cacheContext,e.next=4,r.preference.set(this._metadataKey,this._metadata);case 4:return e.abrupt("return",!0);case 5:return e.abrupt("return",!1);case 6:case"end":return e.stop()}}),e,this)})))}},{key:"clearMetaData",value:function(){return b(this,void 0,void 0,t().mark((function e(){var n,r;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n=ns.of(this._iid),r=n.cacheContext,e.next=3,r.preference.remove(this._metadataKey);case 3:this._metadata=null;case 4:case"end":return e.stop()}}),e,this)})))}},{key:"resume",value:function(){var e,t,n=ns.of(this._iid),r=n.logger;n.connectionManager.isConnected&&(r.debug("channel background sync resume()"),this._sync.start(null!==(t=null===(e=this._metadata)||void 0===e?void 0:e.token)&&void 0!==t?t:""))}},{key:"pause",value:function(){ns.of(this._iid).logger.debug("channel background sync stop()"),this._sync.stop()}},{key:"close",value:function(){this.ref--,this.ref<=0&&(this.ref=0,this.pause(),this._connectionEventContext.close(),delete Lp[this._iid])}}],[{key:"of",value:function(e){return Lp[e]||(Lp[e]=new n({_iid:e})),Lp[e].ref++,Lp[e]}},{key:"clear",value:function(e){Lp[e]&&(Lp[e].close(),delete Lp[e])}}]),n}(),Pp={},Fp=function(){function n(a){var s=this,i=a._iid;r(this,n),this._sync=null,this._connectionEventContext=null,this.ref=0,this._metadataKey=null,this._metadata=null,this._iid=i;var o,u=ns.of(this._iid),c=u.logger,l=u.sdkState,h=u.dispatcher;this._metadataKey=(o=l.userId,"sendbird:".concat(o,"@groupchannel/changelogs.meta"));var d=function(e){return"sendbird:".concat(e,"@groupchannel/changelogs")}(l.userId);this._sync=new Cf(d,(function(){return b(s,void 0,void 0,t().mark((function n(){var r,a,s,i,o;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return r={hasNext:!0,nextToken:0},t.next=3,this.loadMetadata();case 3:return c.debug("channel changelog sync from",this._metadata.token),t.prev=4,a=wf.of(this._iid),t.next=8,a.getMyGroupChannelChangeLogs(this._metadata.token,{includeEmpty:!0},e.GroupChannelEventSource.SYNC_CHANNEL_CHANGELOGS);case 8:return s=t.sent,i=s.hasMore,o=s.token,r.hasNext=i,r.nextToken=o,this._metadata.token=o,c.debug("channel changelog sync progress",r),t.next=17,this.saveMetadata();case 17:t.next=26;break;case 19:if(t.prev=19,t.t0=t.catch(4),c.debug("channel changelog sync error",t.t0),!(t.t0 instanceof M&&t.t0.isInvalidTokenError)){t.next=25;break}return t.next=25,this.clearMetadata();case 25:throw t.t0;case 26:return t.abrupt("return",r);case 27:case"end":return t.stop()}}),n,this,[[4,19]])})))})),this._connectionEventContext=h.on((function(e){if(e instanceof Dr)if(e.stateType===Nr.CONNECTED)s.resume();else s.pause()}))}return s(n,[{key:"loadMetadata",value:function(){return b(this,void 0,void 0,t().mark((function e(){var n,r,a,s;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(this._metadata){e.next=6;break}return n=ns.of(this._iid),r=n.cacheContext,a=n.firstConnectedAt,e.next=4,r.preference.get(this._metadataKey);case 4:s=e.sent,this._metadata={token:s?s.token:a};case 6:return e.abrupt("return",this._metadata);case 7:case"end":return e.stop()}}),e,this)})))}},{key:"saveMetadata",value:function(){return b(this,void 0,void 0,t().mark((function e(){var n,r;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!this._metadata){e.next=5;break}return n=ns.of(this._iid),r=n.cacheContext,e.next=4,r.preference.set(this._metadataKey,this._metadata);case 4:return e.abrupt("return",!0);case 5:return e.abrupt("return",!1);case 6:case"end":return e.stop()}}),e,this)})))}},{key:"clearMetadata",value:function(){return b(this,void 0,void 0,t().mark((function e(){var n,r;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n=ns.of(this._iid),r=n.cacheContext,e.next=3,r.preference.remove(this._metadataKey);case 3:this._metadata=null;case 4:case"end":return e.stop()}}),e,this)})))}},{key:"resume",value:function(){ns.of(this._iid).connectionManager.isConnected&&this._sync.start(0)}},{key:"pause",value:function(){this._sync.stop()}},{key:"close",value:function(){this.ref--,this.ref<=0&&(this.ref=0,this.pause(),this._connectionEventContext.close(),delete Pp[this._iid])}}],[{key:"of",value:function(e){return Pp[e]||(Pp[e]=new n({_iid:e})),Pp[e].ref++,Pp[e]}},{key:"clear",value:function(e){Pp[e]&&(Pp[e].close(),delete Pp[e])}}]),n}(),Gp=function(){function n(t,a){var s=this,i=a.filter,o=a.order,u=a.limit;r(this,n),this.channels=[],this._backgroundSync=null,this._changelogSync=null,this._iid=t,this._key="gcc-".concat(Y()),this._isDisposed=!1,this.filter=null!=i?i:new rd,this.order=null!=o?o:e.GroupChannelListOrder.LATEST_LAST_MESSAGE,this._hasMore=!0,this._token="",this._limit=null!=u?u:100;var c=ns.of(this._iid),l=c.sdkState,h=c.cacheContext,d=c.dispatcher;h.localCacheEnabled&&(this._backgroundSync=Dp.of(t),this._backgroundSync.resume()),this._changelogSync=Fp.of(t),this._changelogSync.resume(),wf.of(this._iid).subscribeGroupChannelEvent(this._key,{onUpdate:function(e,t){if(nu(t)){var n=e.filter((function(e){return s.filter.match(e,l.userId)})),r=e.filter((function(e){return!s.filter.match(e,l.userId)})).map((function(e){return e.url}));n.length>0&&s._addChannelsToView(n,t),r.length>0&&s._removeChannelsFromView(r,t)}},onRemove:function(e,t){s._removeChannelsFromView(e,t)}}),ns.of(this._iid).statLogCollector.put(new ja({type:te.FEATURE_LOCALCACHE,data:{use_local_cache:h.localCacheEnabled,collection_interface:{group_channel:!0}}})),d.on((function(e){e instanceof Dr&&e.stateType===Nr.LOGOUT&&s.dispose()}))}return s(n,[{key:"hasMore",get:function(){return!this._isDisposed&&this._hasMore}},{key:"setGroupChannelCollectionHandler",value:function(e){this._handler=e}},{key:"_addChannelsToView",value:function(n,r){var a,s=this,i=arguments.length>2&&void 0!==arguments[2]&&arguments[2],o=[],u=[],c=[],l=y(n);try{for(l.s();!(a=l.n()).done;){var h=a.value,d=Pf(this.channels,h,this.order),f=d.place,p=d.oldPosition;if(-1===p)f===this.channels.length?!i&&this._hasMore||(o.push(h),this.channels.push(h)):(o.push(h),this.channels.splice(f,0,h));else switch(r){case e.GroupChannelEventSource.EVENT_CHANNEL_UPDATED:case e.GroupChannelEventSource.EVENT_MESSAGE_RECEIVED:case e.GroupChannelEventSource.SYNC_CHANNEL_CHANGELOGS:case e.GroupChannelEventSource.EVENT_MESSAGE_SENT:f!==p?this._hasMore&&f===this.channels.length?c.push(h):(this.channels.splice(p,1),this.channels.splice(p0){var v,_=y(c);try{for(_.s();!(v=_.n()).done;){var m=v.value,g=Df(this.channels,m);-1!==g&&this.channels.splice(g,1)}}catch(e){_.e(e)}finally{_.f()}}nu(r)&&ua((function(){return b(s,void 0,void 0,t().mark((function e(){var n,a,s,i;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:i=new xf(r),o.length>0&&(null===(n=this._handler)||void 0===n?void 0:n.onChannelsAdded)&&this._handler.onChannelsAdded(i,o),u.length>0&&(null===(a=this._handler)||void 0===a?void 0:a.onChannelsUpdated)&&this._handler.onChannelsUpdated(i,u),c.length>0&&(null===(s=this._handler)||void 0===s?void 0:s.onChannelsDeleted)&&this._handler.onChannelsDeleted(i,c.map((function(e){return e.url})));case 4:case"end":return e.stop()}}),e,this)})))}))}},{key:"_removeChannelsFromView",value:function(e,n){var r,a=this,s=[],i=y(e);try{var o=function(){var e=r.value,t=a.channels.findIndex((function(t){return t.url===e}));t>=0&&(s.push(a.channels[t].url),a.channels.splice(t,1))};for(i.s();!(r=i.n()).done;)o()}catch(e){i.e(e)}finally{i.f()}return nu(n)&&s.length>0&&ua((function(){return b(a,void 0,void 0,t().mark((function e(){var r,a;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:a=new xf(n),(null===(r=this._handler)||void 0===r?void 0:r.onChannelsDeleted)&&this._handler.onChannelsDeleted(a,s);case 2:case"end":return e.stop()}}),e,this)})))})),s}},{key:"_getLocalChannels",value:function(){return b(this,void 0,void 0,t().mark((function e(){var n,r;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n=wf.of(this._iid),r=this.channels.length>0?Lf(this.channels[this.channels.length-1],this.order):null,e.next=4,n.getChannelsFromCache(r,this.filter,this.order,this._limit,r?this.channels[this.channels.length-1].url:null);case 4:return e.abrupt("return",e.sent);case 5:case"end":return e.stop()}}),e,this)})))}},{key:"_getRemoteChannels",value:function(){return b(this,void 0,void 0,t().mark((function e(){var n,r,a,s;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n=wf.of(this._iid),e.next=3,n.getMyGroupChannels(this._token,Object.assign(Object.assign({},this.filter),{order:this.order}),this._limit);case 3:return r=e.sent,a=r.channels,s=r.token,this._token=s,this._hasMore=!!s,e.abrupt("return",a);case 9:case"end":return e.stop()}}),e,this)})))}},{key:"loadMore",value:function(){return b(this,void 0,void 0,t().mark((function n(){var r,a,s,i=this;return t().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:if(!this._isDisposed){n.next=2;break}throw new M({code:E.COLLECTION_DISPOSED,message:"Collection has been disposed."});case 2:if(!this._hasMore){n.next=14;break}if(r=ns.of(this._iid),a=r.cacheContext,s=[],a.localCacheEnabled&&this._backgroundSync.completed){n.next=8;break}return n.next=8,ca((function(){return b(i,void 0,void 0,t().mark((function e(){return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this._getRemoteChannels();case 2:s=e.sent;case 3:case"end":return e.stop()}}),e,this)})))}));case 8:if(!a.localCacheEnabled||0!==s.length){n.next=12;break}return n.next=11,ca((function(){return b(i,void 0,void 0,t().mark((function e(){return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this._getLocalChannels();case 2:s=e.sent;case 3:case"end":return e.stop()}}),e,this)})))}));case 11:this._backgroundSync.completed&&(this._hasMore=s.length>=this._limit);case 12:return this._addChannelsToView(s,e.GroupChannelEventSource.REQUEST_CHANNEL,!0),n.abrupt("return",s);case 14:return n.abrupt("return",[]);case 15:case"end":return n.stop()}}),n,this)})))}},{key:"dispose",value:function(){var e,t;this._isDisposed||(this._isDisposed=!0,this.channels.length>0&&this.channels.splice(0,this.channels.length),null===(e=this._backgroundSync)||void 0===e||e.close(),null===(t=this._changelogSync)||void 0===t||t.close(),wf.of(this._iid).unsubscribeGroupChannelEvent(this._key))}}]),n}(),Hp=function(t){i(a,t);var n=f(a);function a(t){var s;r(this,a);var i=t.token,o=t.limit,u=t.order,c=t.includeEmpty,l=t.membershipFilter,h=t.channelNameContainsFilter,d=t.channelUrlsFilter,f=t.customTypesFilter,p=t.customTypeStartsWithFilter,v=t.superChannelFilter,_=t.metadataOrderKeyFilter,m=t.metadataKey,g=t.metadataValues,y=t.metadataValueStartsWith,k=t.includeFrozen,b=t.includeMetaData;return(s=n.call(this)).method=B.GET,s.path=zr,s.params=ee({token:i,limit:o,order:u,show_member:!0,show_read_receipt:!0,show_delivery_receipt:!0,show_empty:c,public_mode:e.PublicChannelFilter.PUBLIC,public_membership_mode:l,name_contains:h,channel_urls:d,custom_types:f,custom_type_startswith:p,super_mode:v,metadata_order_key:_,metadata_key:m,metadata_values:g,metadata_value_startswith:y,show_frozen:k,show_metadata:b}),s}return s(a)}(ne),qp=function(e){i(n,e);var t=f(n);function n(e,a){var s;r(this,n),(s=t.call(this,e,a)).token=null,s.channels=[],s.ts=null;var i=a.next,o=a.channels,u=a.ts;return s.token=i,o&&o.length>0&&(s.channels=o.map((function(t){return t.ts=u,new Rp(e,t)}))),s.ts="number"==typeof u?u:null,s}return s(n)}(re);e.MembershipFilter=void 0,(Up=e.MembershipFilter||(e.MembershipFilter={})).ALL="all",Up.JOINED="joined";var jp,zp=function(n){i(u,n);var a=f(u);function u(t,n){var s,i,o,c,l,h,d,f,p,v,_,m,g,y,k;return r(this,u),(s=a.call(this,t,n)).includeEmpty=!1,s.includeFrozen=!0,s.includeMetaData=!0,s.channelUrlsFilter=null,s.customTypesFilter=null,s.customTypeStartsWithFilter=null,s.channelNameContainsFilter=null,s.membershipFilter=e.MembershipFilter.ALL,s.superChannelFilter=e.SuperChannelFilter.ALL,s.metadataKey=null,s.metadataValues=null,s.metadataOrderKeyFilter=null,s.metadataValueStartsWith=null,s.order=e.PublicGroupChannelListOrder.CHRONOLOGICAL,s.includeEmpty=null!==(i=n.includeEmpty)&&void 0!==i&&i,s.includeFrozen=null===(o=n.includeFrozen)||void 0===o||o,s.includeMetaData=null===(c=n.includeMetaData)||void 0===c||c,s.channelUrlsFilter=null!==(l=n.channelUrlsFilter)&&void 0!==l?l:null,s.customTypesFilter=null!==(h=n.customTypesFilter)&&void 0!==h?h:null,s.customTypeStartsWithFilter=null!==(d=n.customTypeStartsWithFilter)&&void 0!==d?d:null,s.channelNameContainsFilter=null!==(f=n.channelNameContainsFilter)&&void 0!==f?f:null,s.membershipFilter=null!==(p=n.membershipFilter)&&void 0!==p?p:e.MembershipFilter.ALL,s.superChannelFilter=null!==(v=n.superChannelFilter)&&void 0!==v?v:e.SuperChannelFilter.ALL,s.metadataKey=null!==(_=n.metadataKey)&&void 0!==_?_:null,s.metadataValues=null!==(m=n.metadataValues)&&void 0!==m?m:null,s.metadataOrderKeyFilter=null!==(g=n.metadataOrderKeyFilter)&&void 0!==g?g:null,s.metadataValueStartsWith=null!==(y=n.metadataValueStartsWith)&&void 0!==y?y:null,s.order=null!==(k=n.order)&&void 0!==k?k:e.PublicGroupChannelListOrder.CHRONOLOGICAL,s}return s(u,[{key:"_validate",value:function(){return p(o(u.prototype),"_validate",this).call(this)&&L("boolean",this.includeEmpty)&&L("boolean",this.includeFrozen)&&L("boolean",this.includeMetaData)&&L("string",this.channelNameContainsFilter,!0)&&F("string",this.channelUrlsFilter,!0)&&F("string",this.customTypesFilter,!0)&&L("string",this.customTypeStartsWithFilter,!0)&&D(e.MembershipFilter,this.membershipFilter)&&D(e.SuperChannelFilter,this.superChannelFilter)&&D(e.PublicGroupChannelListOrder,this.order)&&L("string",this.metadataOrderKeyFilter,!0)&&L("string",this.metadataKey,!0)&&F("string",this.metadataValues,!0)&&L("string",this.metadataValueStartsWith,!0)}},{key:"next",value:function(){return b(this,void 0,void 0,t().mark((function n(){var r,a,s,i,o,u,c,l,h;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(!this._validate()){t.next=22;break}if(this._isLoading){t.next=19;break}if(r=[],!this._hasNext){t.next=16;break}return this._isLoading=!0,a=ns.of(this._iid),s=a.requestQueue,i=a.dispatcher,o=new Hp(Object.assign(Object.assign({},this),{token:this._token})),t.next=9,s.send(o);case 9:return u=t.sent,c=u.as(qp),l=c.channels,h=c.token,this._token=h,this._hasNext=!!h,i.dispatch(new ru({channels:l,source:e.GroupChannelEventSource.REQUEST_CHANNEL})),this._isLoading=!1,t.abrupt("return",l);case 16:return t.abrupt("return",r);case 19:throw M.queryInProgress;case 20:t.next=23;break;case 22:throw M.invalidParameters;case 23:case"end":return t.stop()}}),n,this)})))}}]),u}(ki),Vp=s((function e(){r(this,e),this.onUserMuted=he,this.onUserUnmuted=he,this.onUserBanned=he,this.onUserUnbanned=he,this.onChannelChanged=he,this.onChannelDeleted=he,this.onChannelFrozen=he,this.onChannelUnfrozen=he,this.onOperatorUpdated=he,this.onChannelMemberCountChanged=he,this.onMetaDataCreated=he,this.onMetaDataUpdated=he,this.onMetaDataDeleted=he,this.onMetaCounterCreated=he,this.onMetaCounterUpdated=he,this.onMetaCounterDeleted=he,this.onMessageReceived=he,this.onMessageUpdated=he,this.onMessageDeleted=he,this.onMentionReceived=he,this.onReactionUpdated=he,this.onThreadInfoUpdated=he})),Bp=function(e){i(n,e);var t=f(n);function n(){var e;return r(this,n),(e=t.apply(this,arguments)).onUserJoined=he,e.onUserLeft=he,e.onUserReceivedInvitation=he,e.onUserDeclinedInvitation=he,e.onChannelHidden=he,e.onUnreadMemberStatusUpdated=he,e.onUndeliveredMemberStatusUpdated=he,e.onTypingStatusUpdated=he,e.onPollUpdated=he,e.onPollVoted=he,e.onPollDeleted=he,e.onPinnedMessageUpdated=he,e}return s(n)}(Vp),Qp=function(e){i(n,e);var t=f(n);function n(){var e,a=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return r(this,n),e=t.call(this),Object.keys(a).forEach((function(t){e.hasOwnProperty(t)&&(e[t]=a[t])})),e}return s(n)}(Bp),Kp=function(e){i(n,e);var t=f(n);function n(e){var a;r(this,n);var s=e.token,i=e.limit,o=e.order,u=e.reverse,c=e.channelUrl,l=e.messageTypeFilter,h=e.scheduledStatus;return(a=t.call(this)).method=B.GET,a.path="".concat(Xr),a.params=ee({limit:i,reverse:u,channel_url:c,order:o,status:h}),s&&(a.params.token=s),l&&(a.params.message_type=l),a}return s(n)}(ne),Wp=function(e){i(n,e);var t=f(n);function n(e,a){var s;r(this,n),(s=t.call(this,e,a)).token=null,s.scheduledMessages=[];var i=a.next,o=a.scheduled_messages;return s.token=i,s.scheduledMessages=o.map((function(t){return Ds(e,t)})),s}return s(n)}(re),Yp=function(n){i(u,n);var a=f(u);function u(t,n){var s,i,o,c,l,h;return r(this,u),(s=a.call(this,t,n)).channelUrl=null,s.order=null,s.reverse=!1,s.scheduledStatus=null,s.messageTypeFilter=e.MessageTypeFilter.ALL,s.channelUrl=null!==(i=n.channelUrl)&&void 0!==i?i:null,s.order=null!==(o=n.order)&&void 0!==o?o:null,s.reverse=null!==(c=n.reverse)&&void 0!==c&&c,s.scheduledStatus=null!==(l=n.scheduledStatus)&&void 0!==l?l:null,s.messageTypeFilter=null!==(h=n.messageTypeFilter)&&void 0!==h?h:e.MessageTypeFilter.ALL,s}return s(u,[{key:"_validate",value:function(){return p(o(u.prototype),"_validate",this).call(this)&&L("string",this.channelUrl,!0)&&(D(e.ScheduledMessageListOrder,this.order)||null===this.order)&&L("boolean",this.reverse)&&(F(e.ScheduledStatus,this.scheduledStatus)||null===this.scheduledStatus)&&D(e.MessageTypeFilter,this.messageTypeFilter)}},{key:"next",value:function(){return b(this,void 0,void 0,t().mark((function e(){var n,r,a,s,i,o,u;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!this._validate()){e.next=20;break}if(this._isLoading){e.next=17;break}if(!this._hasNext){e.next=14;break}return this._isLoading=!0,n=ns.of(this._iid),r=n.requestQueue,a=new Kp(Object.assign(Object.assign({},this),{token:this._token})),e.next=8,r.send(a);case 8:return s=e.sent,i=s.as(Wp),o=i.scheduledMessages,u=i.token,this._token=u,this._hasNext=!!u,this._isLoading=!1,e.abrupt("return",o);case 14:return e.abrupt("return",[]);case 17:throw M.queryInProgress;case 18:e.next=21;break;case 20:throw M.invalidParameters;case 21:case"end":return e.stop()}}),e,this)})))}}]),u}(ki),Zp=function(e){i(a,e);var n=f(a);function a(){var e;return r(this,a),(e=n.apply(this,arguments)).name="groupChannel",e}return s(a,[{key:"init",value:function(e,t){var n=t.sdkState,r=t.dispatcher,s=t.sessionManager,i=t.requestQueue,u=t.logger,c=t.onlineDetector,l=t.cacheContext;p(o(a.prototype),"init",this).call(this,e,{sdkState:n,dispatcher:r,sessionManager:s,requestQueue:i,logger:u,onlineDetector:c,cacheContext:l}),this._manager=new wf(e,{sdkState:n,cacheContext:l,dispatcher:r,sessionManager:s,requestQueue:i,logger:u})}},{key:"createGroupChannelCollection",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return new Gp(this._iid,e)}},{key:"createMyGroupChannelListQuery",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return new yf(this._iid,e)}},{key:"createPublicGroupChannelListQuery",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return new zp(this._iid,e)}},{key:"createScheduledMessageListQuery",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return new Yp(this._iid,e)}},{key:"addGroupChannelHandler",value:function(e,t){Ua(L("string",e)&&t instanceof Qp).throw(M.invalidParameters),this._manager.addHandler(e,t)}},{key:"removeGroupChannelHandler",value:function(e){Ua(L("string",e)).throw(M.invalidParameters),this._manager.removeHandler(e)}},{key:"removeAllGroupChannelHandlers",value:function(){this._manager.clearHandler()}},{key:"buildGroupChannelFromSerializedData",value:function(e){return this._manager.buildGroupChannelFromSerializedData(e)}},{key:"buildGroupChannelListQueryFromSerializedData",value:function(e){return this._manager.buildGroupChannelListQueryFromSerializedData(e)}},{key:"buildMemberFromSerializedData",value:function(e){return this._manager.buildMemberFromSerializedData(e)}},{key:"getChannel",value:function(e){return b(this,void 0,void 0,t().mark((function n(){return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return Ua(L("string",e)).throw(M.invalidParameters),t.abrupt("return",this._manager.getChannel(e));case 2:case"end":return t.stop()}}),n,this)})))}},{key:"getChannelWithoutCache",value:function(e){return b(this,void 0,void 0,t().mark((function n(){return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return Ua(L("string",e)).throw(M.invalidParameters),t.abrupt("return",this._manager.getChannelWithoutCache(e));case 2:case"end":return t.stop()}}),n,this)})))}},{key:"getMyGroupChannelChangeLogsByToken",value:function(e){var n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return b(this,void 0,void 0,t().mark((function r(){var a;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return a=Object.assign(Object.assign({},cd),n),Ua(L("string",e)&&ld(a)).throw(M.invalidParameters),t.next=4,this._manager.getMyGroupChannelChangeLogs(e,a);case 4:return t.abrupt("return",t.sent);case 5:case"end":return t.stop()}}),r,this)})))}},{key:"getMyGroupChannelChangeLogsByTimestamp",value:function(e){var n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return b(this,void 0,void 0,t().mark((function r(){var a;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return a=Object.assign(Object.assign({},cd),n),Ua(L("number",e)&&ld(a)).throw(M.invalidParameters),t.next=4,this._manager.getMyGroupChannelChangeLogs(e,a);case 4:return t.abrupt("return",t.sent);case 5:case"end":return t.stop()}}),r,this)})))}},{key:"getGroupChannelCount",value:function(e){return b(this,void 0,void 0,t().mark((function n(){var r;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return r=Object.assign(Object.assign({},hd),e),Ua(dd(r)).throw(M.invalidParameters),t.abrupt("return",this._manager.getGroupChannelCount(r));case 3:case"end":return t.stop()}}),n,this)})))}},{key:"getUnreadItemCount",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return b(this,void 0,void 0,t().mark((function n(){return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,this._manager.getUnreadItemCount(e);case 2:return t.abrupt("return",t.sent);case 3:case"end":return t.stop()}}),n,this)})))}},{key:"getTotalUnreadChannelCount",value:function(){return b(this,void 0,void 0,t().mark((function e(){return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this._manager.getTotalUnreadChannelCount();case 2:return e.abrupt("return",e.sent);case 3:case"end":return e.stop()}}),e,this)})))}},{key:"getTotalUnreadMessageCount",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return b(this,void 0,void 0,t().mark((function n(){return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,this._manager.getTotalUnreadMessageCount(e);case 2:return t.abrupt("return",t.sent);case 3:case"end":return t.stop()}}),n,this)})))}},{key:"getTotalScheduledMessageCount",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return b(this,void 0,void 0,t().mark((function n(){return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,this._manager.getTotalScheduledMessageCount(e);case 2:return t.abrupt("return",t.sent);case 3:case"end":return t.stop()}}),n,this)})))}},{key:"getSubscribedTotalUnreadMessageCount",value:function(){return this._manager.getSubscribedTotalUnreadMessageCount()}},{key:"getSubscribedCustomTypeTotalUnreadMessageCount",value:function(){return this._manager.getSubscribedCustomTypeTotalUnreadMessageCount()}},{key:"getSubscribedCustomTypeUnreadMessageCount",value:function(e){return this._manager.getSubscribedCustomTypeUnreadMessageCount(e)}},{key:"createChannel",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return b(this,void 0,void 0,t().mark((function n(){var r;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return r=Object.assign(Object.assign({},od),e),Ua(ud(r)).throw(M.invalidParameters),t.abrupt("return",this._manager.createChannel(r));case 3:case"end":return t.stop()}}),n,this)})))}},{key:"createDistinctChannelIfNotExist",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return b(this,void 0,void 0,t().mark((function n(){var r;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return r=Object.assign(Object.assign({},od),e),Ua(ud(r)).throw(M.invalidParameters),r&&(r.isDistinct=!0),t.abrupt("return",this.createChannel(r));case 4:case"end":return t.stop()}}),n,this)})))}},{key:"createChannelWithUserIds",value:function(e){var n=arguments.length>1&&void 0!==arguments[1]&&arguments[1],r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:null,a=arguments.length>3&&void 0!==arguments[3]?arguments[3]:null,s=arguments.length>4&&void 0!==arguments[4]?arguments[4]:"",i=arguments.length>5&&void 0!==arguments[5]?arguments[5]:"";return b(this,void 0,void 0,t().mark((function o(){var u;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return u=Object.assign(Object.assign({},od),{invitedUserIds:e,isDistinct:n,name:r,data:s,customType:i}),"string"==typeof a?u.coverUrl=a:u.coverImage=a,t.abrupt("return",this.createChannel(u));case 3:case"end":return t.stop()}}),o,this)})))}},{key:"markAsReadAll",value:function(){return b(this,void 0,void 0,t().mark((function e(){return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:this._manager.markAsReadAll();case 1:case"end":return e.stop()}}),e,this)})))}},{key:"markAsReadWithChannelUrls",value:function(e){return b(this,void 0,void 0,t().mark((function n(){return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:Ua(F("string",e)).throw(M.invalidParameters),this._manager.markAsReadWithChannelUrls(e);case 2:case"end":return t.stop()}}),n,this)})))}},{key:"markAsDelivered",value:function(e){return b(this,void 0,void 0,t().mark((function n(){var r;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return Ua(L("string",e)).throw(M.invalidParameters),t.next=3,this.getChannel(e);case 3:return r=t.sent,t.next=6,r.markAsDelivered();case 6:case"end":return t.stop()}}),n,this)})))}}]),a}(rs),Jp=function(e){i(a,e);var n=f(a);function a(){var e;return r(this,a),(e=n.apply(this,arguments))._channels=new Map,e._enteredChannelUrls=[],e}return s(a,[{key:"enteredChannels",get:function(){var e=this;return this._enteredChannelUrls.map((function(t){return e._channels.get(t)})).filter((function(e){return null!==e}))}},{key:"isEnteredChannel",value:function(e){return this._enteredChannelUrls.includes(e)}},{key:"enter",value:function(e){this._enteredChannelUrls.indexOf(e)<0&&this._enteredChannelUrls.push(e)}},{key:"exit",value:function(e){var t=this._enteredChannelUrls.indexOf(e);t>=0&&this._enteredChannelUrls.splice(t,1)}},{key:"exitAll",value:function(){this._enteredChannelUrls=[]}},{key:"get",value:function(e){var n;return b(this,void 0,void 0,t().mark((function r(){return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.abrupt("return",null!==(n=this._channels.get(e))&&void 0!==n?n:null);case 1:case"end":return t.stop()}}),r,this)})))}},{key:"upsert",value:function(e){return b(this,void 0,void 0,t().mark((function n(){var r=this;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:e.forEach((function(e){if(r._channels.has(e.url)){var t=r._channels.get(e.url);Object.assign(t,e)}else r._channels.set(e.url,e)}));case 1:case"end":return t.stop()}}),n)})))}},{key:"remove",value:function(e){return b(this,void 0,void 0,t().mark((function n(){return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:this._channels.delete(e),this.exit(e);case 2:case"end":return t.stop()}}),n,this)})))}},{key:"clear",value:function(){return b(this,void 0,void 0,t().mark((function e(){return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:this._channels.clear(),this._enteredChannelUrls=[];case 2:case"end":return e.stop()}}),e,this)})))}}]),a}(Ca),Xp={channelUrl:null,name:null,coverUrlOrImage:null,data:null,customType:null,operatorUserIds:null,isEphemeral:null},$p=function(e){return F("string",e.operatorUserIds,!0)&&(L("string",e.coverUrlOrImage)||H(e.coverUrlOrImage)||null===e.coverUrlOrImage)&&L("string",e.name,!0)&&L("string",e.data,!0)&&L("string",e.customType,!0)&&(L("string",e.channelUrl)&&/^\w+$/.test(e.channelUrl)||null===e.channelUrl)&&L("boolean",e.isEphemeral,!0)},ev=function(e){i(n,e);var t=f(n);function n(e){var a,s=e.channelUrl,i=e.isInternalCall;return r(this,n),(a=t.call(this)).method=B.GET,a.path="".concat(i?Qr:Br,"/").concat(encodeURIComponent(s)),a}return s(n)}(ne),tv=function(e){i(n,e);var t=f(n);function n(e,a){var s;return r(this,n),(s=t.call(this,e,a)).channel=null,s.channel=new mv(e,a),s}return s(n)}(re),nv=function(e){i(n,e);var t=f(n);function n(e){var a;r(this,n);var s=e.channelUrl,i=e.coverUrlOrImage,o=e.name,u=e.data,c=e.customType,l=e.operatorUserIds,h=e.isEphemeral;return(a=t.call(this)).method=B.POST,a.path=Br,a.params=ee({channel_url:s,cover_url:L("string",i)?i:null,cover_file:H(i)?i:null,name:o,data:u,custom_type:c,operators:l,is_ephemeral:h}),a}return s(n)}(ne),rv=function(e){i(n,e);var t=f(n);function n(e){var a=e.channelUrl;return r(this,n),t.call(this,{code:"ENTR",payload:{channel_url:a},ackRequired:!0})}return s(n)}(Mr),av=function(e){i(n,e);var t=f(n);function n(e,a,s){var i,o,u;return r(this,n),i=t.call(this,e,"SYEV",s),s.data&&(i.participantCount=null!==(o=s.data.participant_count)&&void 0!==o?o:0,i.user=new La(e,s.data),i.ts=null!==(u=s.data.edge_ts)&&void 0!==u?u:0),i}return s(n)}(jd),sv=function(e){i(n,e);var t=f(n);function n(e){var a=e.channelUrl;return r(this,n),t.call(this,{code:"EXIT",payload:{channel_url:a},ackRequired:!0})}return s(n)}(Mr),iv=function(e){i(n,e);var t=f(n);function n(e,a,s){var i,o,u;return r(this,n),i=t.call(this,e,"EXIT",s),s.data&&(i.participantCount=null!==(o=s.data.participant_count)&&void 0!==o?o:0,i.user=new La(e,s.data),i.ts=null!==(u=s.data.edge_ts)&&void 0!==u?u:0),i}return s(n)}(jd),ov={},uv=function(){function n(e,t){var a=this,s=t.sdkState,i=t.dispatcher,o=t.requestQueue;return r(this,n),ov[e]||(this._iid=e,this._sdkState=s,this._requestQueue=o,this._dispatcher=i,this._openChannelCache=new Jp(e),this._openChannelHandlers=new Map,this._dispatcher.on((function(e){if(e instanceof le)a._handleEvent(e);else if(e instanceof Dr&&e.stateType===Nr.CONNECTED){var t,n=y(a._openChannelCache.enteredChannels);try{for(n.s();!(t=n.n()).done;){t.value.enter()}}catch(e){n.e(e)}finally{n.f()}}})),ov[e]=this),ov[e]}return s(n,[{key:"buildOpenChannelFromSerializedData",value:function(e){var t=Oa(e);return new mv(this._iid,mv.payloadify(t))}},{key:"getChannelFromCache",value:function(e){return b(this,void 0,void 0,t().mark((function n(){return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,this._openChannelCache.get(e);case 2:return t.abrupt("return",t.sent);case 3:case"end":return t.stop()}}),n,this)})))}},{key:"upsertChannelsToCache",value:function(e){return b(this,void 0,void 0,t().mark((function n(){return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,this._openChannelCache.upsert(e);case 2:case"end":return t.stop()}}),n,this)})))}},{key:"removeChannelsFromCache",value:function(e){return b(this,void 0,void 0,t().mark((function n(){var r,a,s;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:r=y(e),t.prev=1,r.s();case 3:if((a=r.n()).done){t.next=9;break}return s=a.value,t.next=7,this._openChannelCache.remove(s);case 7:t.next=3;break;case 9:t.next=14;break;case 11:t.prev=11,t.t0=t.catch(1),r.e(t.t0);case 14:return t.prev=14,r.f(),t.finish(14);case 17:case"end":return t.stop()}}),n,this,[[1,11,14,17]])})))}},{key:"setEnteredToCache",value:function(e){this._openChannelCache.enter(e.url)}},{key:"setExitedToCache",value:function(e){this._openChannelCache.exit(e.url)}},{key:"_handleEvent",value:function(n){return b(this,void 0,void 0,t().mark((function r(){var a,s,i,o,u,c,l,h,d,f,p,v,_,m,g,k,E,w,C,x,T,S,I,N,M,O,U,R,L,D,P,F,G,H,q,j,z,V,B,Q,K,W,Y,Z,J,X,$,ee,te,ne,re,ae,se,ie,oe,ue,ce,le,he,de,fe,pe,ve,_e,me,ge,ye,ke,be,Ee,we,Ce,xe,Te,Se,Ie,Ne,Ae,Me,Oe,Ue,Re,Le=this;return t().wrap((function(r){for(;;)switch(r.prev=r.next){case 0:r.prev=0,r.t0=n.code,r.next="MESG"===r.t0||"FILE"===r.t0||"ADMM"===r.t0||"BRDM"===r.t0?4:"MEDI"===r.t0||"FEDI"===r.t0||"AEDI"===r.t0?14:"DELM"===r.t0?24:"MRCT"===r.t0?31:"MTHD"===r.t0?38:"MCNT"===r.t0?45:"PEDI"===r.t0?72:"VOTE"===r.t0?81:"SYEV"===r.t0?90:167;break;case 4:if(a=null,"MESG"===n.code?a=n.as(fh):"FILE"===n.code?a=n.as(Vs):"ADMM"!==n.code&&"BRDM"!=n.code||(a=n.as(pf)),!a){r.next=13;break}if(i=(s=a).message,o=s.isMentioned,i.channelType!==e.ChannelType.OPEN){r.next=13;break}return r.next=11,this.getChannel(i.channelUrl,!0);case 11:u=r.sent,ua((function(){return b(Le,void 0,void 0,t().mark((function e(){var n,r,a;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:n=y(this._openChannelHandlers.values());try{for(n.s();!(r=n.n()).done;)a=r.value,this._openChannelCache.isEnteredChannel(u.url)&&(a.onMessageReceived(u,i),o&&a.onMentionReceived(u,i))}catch(e){n.e(e)}finally{n.f()}case 2:case"end":return e.stop()}}),e,this)})))}));case 13:return r.abrupt("break",167);case 14:if(c=null,"MEDI"===n.code?c=n.as(vh):"FEDI"===n.code?c=n.as(mh):"AEDI"===n.code&&(c=n.as(vf)),!c){r.next=23;break}if(h=(l=c).message,d=l.mentionCountChange,h.channelType!==e.ChannelType.OPEN){r.next=23;break}return r.next=21,this.getChannel(h.channelUrl,!0);case 21:f=r.sent,ua((function(){return b(Le,void 0,void 0,t().mark((function e(){var n,r,a;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:n=y(this._openChannelHandlers.values());try{for(n.s();!(r=n.n()).done;)a=r.value,this._openChannelCache.isEnteredChannel(f.url)&&(a.onMessageUpdated(f,h),d>0&&a.onMentionReceived(f,h))}catch(e){n.e(e)}finally{n.f()}case 2:case"end":return e.stop()}}),e,this)})))}));case 23:return r.abrupt("break",167);case 24:if(p=n.as(yh),v=p.channelUrl,_=p.channelType,m=p.messageId,_!==e.ChannelType.OPEN){r.next=30;break}return r.next=28,this.getChannel(v,!0);case 28:g=r.sent,ua((function(){return b(Le,void 0,void 0,t().mark((function e(){var n,r,a;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:n=y(this._openChannelHandlers.values());try{for(n.s();!(r=n.n()).done;)a=r.value,this._openChannelCache.isEnteredChannel(g.url)&&a.onMessageDeleted(g,m)}catch(e){n.e(e)}finally{n.f()}case 2:case"end":return e.stop()}}),e,this)})))}));case 30:return r.abrupt("break",167);case 31:if(k=n.as(_f),E=k.channelUrl,w=k.channelType,C=k.event,w!==e.ChannelType.OPEN){r.next=37;break}return r.next=35,this.getChannel(E,!0);case 35:x=r.sent,ua((function(){return b(Le,void 0,void 0,t().mark((function e(){var n,r,a;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:n=y(this._openChannelHandlers.values());try{for(n.s();!(r=n.n()).done;)a=r.value,this._openChannelCache.isEnteredChannel(x.url)&&a.onReactionUpdated(x,C)}catch(e){n.e(e)}finally{n.f()}case 2:case"end":return e.stop()}}),e,this)})))}));case 37:return r.abrupt("break",167);case 38:if(T=n.as(mf),(S=T.event).channelType!==e.ChannelType.OPEN){r.next=44;break}return r.next=42,this.getChannel(S.channelUrl,!0);case 42:I=r.sent,ua((function(){return b(Le,void 0,void 0,t().mark((function e(){var n,r,a;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:n=y(this._openChannelHandlers.values());try{for(n.s();!(r=n.n()).done;)a=r.value,this._openChannelCache.isEnteredChannel(I.url)&&a.onThreadInfoUpdated(I,S)}catch(e){n.e(e)}finally{n.f()}case 2:case"end":return e.stop()}}),e,this)})))}));case 44:return r.abrupt("break",167);case 45:N=n.as(df),M=N.openChannelMemberCounts,O=[],U=y(M),r.prev=48,U.s();case 50:if((R=U.n()).done){r.next=59;break}return L=R.value,D=L.channelUrl,P=L.participantCount,F=L.updatedAt,r.next=55,this.getChannelFromCache(D);case 55:(G=r.sent)&&G._updateParticipantCount(P,F)&&O.push(G);case 57:r.next=50;break;case 59:r.next=64;break;case 61:r.prev=61,r.t1=r.catch(48),U.e(r.t1);case 64:return r.prev=64,U.f(),r.finish(64);case 67:if(!(O.length>0)){r.next=71;break}return r.next=70,this.upsertChannelsToCache(O);case 70:ua((function(){return b(Le,void 0,void 0,t().mark((function e(){var n,r;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:n=y(this._openChannelHandlers.values());try{for(n.s();!(r=n.n()).done;)r.value.onChannelMemberCountChanged(O)}catch(e){n.e(e)}finally{n.f()}case 2:case"end":return e.stop()}}),e,this)})))}));case 71:return r.abrupt("break",167);case 72:if(H=n.as(gf),q=H.event,j=H.status,z=H.channelUrl,V=H.channelType,z&&V){r.next=75;break}return r.abrupt("break",167);case 75:return r.next=77,this.getChannel(z,!0);case 77:return B=r.sent,this._dispatcher.dispatch(new ai({event:q,source:e.MessageEventSource.EVENT_POLL_UPDATED})),ua(j===Ns?function(){return b(Le,void 0,void 0,t().mark((function e(){var n,r;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:n=y(this._openChannelHandlers.values());try{for(n.s();!(r=n.n()).done;)r.value.onPollDeleted(B,q.pollId)}catch(e){n.e(e)}finally{n.f()}case 2:case"end":return e.stop()}}),e,this)})))}:function(){return b(Le,void 0,void 0,t().mark((function e(){var n,r;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:n=y(this._openChannelHandlers.values());try{for(n.s();!(r=n.n()).done;)r.value.onPollUpdated(B,q)}catch(e){n.e(e)}finally{n.f()}case 2:case"end":return e.stop()}}),e,this)})))}),r.abrupt("break",167);case 81:if(Q=n.as(jh),K=Q.event,W=Q.channelUrl,Y=Q.channelType,W&&Y){r.next=84;break}return r.abrupt("break",167);case 84:return r.next=86,this.getChannel(W,!0);case 86:return Z=r.sent,this._dispatcher.dispatch(new si({event:K,source:e.MessageEventSource.EVENT_POLL_VOTED})),ua((function(){return b(Le,void 0,void 0,t().mark((function e(){var n,r;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:n=y(this._openChannelHandlers.values());try{for(n.s();!(r=n.n()).done;)r.value.onPollVoted(Z,K)}catch(e){n.e(e)}finally{n.f()}case 2:case"end":return e.stop()}}),e,this)})))})),r.abrupt("break",167);case 90:if(J=n.as(jd),!(X=J.event).isOpenChannelEvent){r.next=166;break}r.t2=X.category,r.next=r.t2===nd.CHANNEL_ENTER?95:r.t2===nd.CHANNEL_EXIT?102:r.t2===nd.CHANNEL_OPERATOR_UPDATE?109:r.t2===nd.USER_CHANNEL_MUTE||r.t2===nd.USER_CHANNEL_UNMUTE?117:r.t2===nd.USER_CHANNEL_BAN||r.t2===nd.USER_CHANNEL_UNBAN?124:r.t2===nd.CHANNEL_FREEZE||r.t2===nd.CHANNEL_UNFREEZE?131:r.t2===nd.CHANNEL_DELETED?139:r.t2===nd.CHANNEL_PROP_CHANGED?146:r.t2===nd.CHANNEL_META_DATA_CHANGED?151:r.t2===nd.CHANNEL_META_COUNTERS_CHANGED?160:166;break;case 95:return r.next=97,this.getChannel(X.channelUrl,!0);case 97:return $=r.sent,ee=n.as(av),te=ee.participantCount,ne=ee.user,re=$._updateParticipantCount(te,X.ts),ua((function(){return b(Le,void 0,void 0,t().mark((function e(){return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:this._openChannelHandlers.forEach((function(e){e.onUserEntered($,ne),re&&e.onChannelParticipantCountChanged($)}));case 1:case"end":return e.stop()}}),e,this)})))})),r.abrupt("break",166);case 102:return r.next=104,this.getChannel(X.channelUrl,!0);case 104:return ae=r.sent,se=n.as(iv),ie=se.participantCount,oe=se.user,ue=ae._updateParticipantCount(ie,X.ts),ua((function(){return b(Le,void 0,void 0,t().mark((function e(){return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:this._openChannelHandlers.forEach((function(e){e.onUserExited(ae,oe),ue&&e.onChannelParticipantCountChanged(ae)}));case 1:case"end":return e.stop()}}),e,this)})))})),r.abrupt("break",166);case 109:return r.next=111,this.getChannel(X.channelUrl,!0);case 111:return ce=r.sent,le=n.as(hf),he=le.operators,ce.operators=he,this.upsertChannelsToCache([ce]),ua((function(){return b(Le,void 0,void 0,t().mark((function e(){return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:this._openChannelHandlers.forEach((function(e){e.onOperatorUpdated(ce,he)}));case 1:case"end":return e.stop()}}),e,this)})))})),r.abrupt("break",166);case 117:return r.next=119,this.getChannel(X.channelUrl,!0);case 119:return de=r.sent,fe=X.category===nd.USER_CHANNEL_MUTE,pe=n.as(fe?eh:nh),ve=pe.user,ua((function(){return b(Le,void 0,void 0,t().mark((function e(){return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:this._openChannelHandlers.forEach((function(e){fe?e.onUserMuted(de,ve):e.onUserUnmuted(de,ve)}));case 1:case"end":return e.stop()}}),e,this)})))})),r.abrupt("break",166);case 124:return r.next=126,this.getChannel(X.channelUrl,!0);case 126:return _e=r.sent,me=X.category===nd.USER_CHANNEL_BAN,ge=n.as(me?ah:ih),ye=ge.user,ua((function(){return b(Le,void 0,void 0,t().mark((function e(){return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:this._openChannelHandlers.forEach((function(e){me?e.onUserBanned(_e,ye):e.onUserUnbanned(_e,ye)}));case 1:case"end":return e.stop()}}),e,this)})))})),r.abrupt("break",166);case 131:return r.next=133,this.getChannel(X.channelUrl,!0);case 133:return ke=r.sent,be=n.as(uh),Ee=be.freeze,ke.isFrozen=Ee,this.upsertChannelsToCache([ke]),ua((function(){return b(Le,void 0,void 0,t().mark((function e(){return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:this._openChannelHandlers.forEach((function(e){Ee?e.onChannelFrozen(ke):e.onChannelUnfrozen(ke)}));case 1:case"end":return e.stop()}}),e,this)})))})),r.abrupt("break",166);case 139:return r.next=141,this.getChannel(X.channelUrl,!0);case 141:return we=r.sent,r.next=144,this.removeChannelsFromCache([we.url]);case 144:return ua((function(){return b(Le,void 0,void 0,t().mark((function e(){return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:this._openChannelHandlers.forEach((function(e){e.onChannelDeleted(we.url,we.channelType)}));case 1:case"end":return e.stop()}}),e,this)})))})),r.abrupt("break",166);case 146:return r.next=148,this.getChannelWithoutCache(X.channelUrl,!0);case 148:return Ce=r.sent,ua((function(){return b(Le,void 0,void 0,t().mark((function e(){return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:this._openChannelHandlers.forEach((function(e){e.onChannelChanged(Ce)}));case 1:case"end":return e.stop()}}),e,this)})))})),r.abrupt("break",166);case 151:return r.next=153,this.getChannel(X.channelUrl,!0);case 153:return xe=r.sent,Te=n.as(Gl),Se=Te.created,Ie=Te.updated,Ne=Te.deleted,Se&&xe._upsertCachedMetaData(Se,X.ts),Ie&&xe._upsertCachedMetaData(Ie,X.ts),Ne&&xe._removeFromCachedMetaData(Ne,X.ts),ua((function(){return b(Le,void 0,void 0,t().mark((function e(){return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:this._openChannelHandlers.forEach((function(e){Se&&e.onMetaDataCreated(xe,Se),Ie&&e.onMetaDataUpdated(xe,Ie),Ne&&e.onMetaDataDeleted(xe,Ne)}));case 1:case"end":return e.stop()}}),e,this)})))})),r.abrupt("break",166);case 160:return r.next=162,this.getChannel(X.channelUrl,!0);case 162:return Ae=r.sent,Me=n.as(Zl),Oe=Me.created,Ue=Me.updated,Re=Me.deleted,ua((function(){return b(Le,void 0,void 0,t().mark((function e(){return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:this._openChannelHandlers.forEach((function(e){Oe&&e.onMetaCounterCreated(Ae,Oe),Ue&&e.onMetaCounterUpdated(Ae,Ue),Re&&e.onMetaCounterDeleted(Ae,Re)}));case 1:case"end":return e.stop()}}),e,this)})))})),r.abrupt("break",166);case 166:return r.abrupt("break",167);case 167:r.next=173;break;case 169:if(r.prev=169,r.t3=r.catch(0),!A(r.t3)){r.next=173;break}throw r.t3;case 173:case"end":return r.stop()}}),r,this,[[0,169],[48,61,64,67]])})))}},{key:"addHandler",value:function(e,t){this._openChannelHandlers.set(e,t)}},{key:"removeHandler",value:function(e){this._openChannelHandlers.delete(e)}},{key:"clearHandler",value:function(){this._openChannelHandlers.clear()}},{key:"getChannel",value:function(e){return b(this,void 0,void 0,t().mark((function n(){var r;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return Ua(L("string",e)).throw(M.invalidParameters),t.prev=1,t.next=4,this.getChannelFromCache(e);case 4:if(!(r=t.sent)){t.next=7;break}return t.abrupt("return",r);case 7:t.next=11;break;case 9:t.prev=9,t.t0=t.catch(1);case 11:return t.next=13,this.getChannelWithoutCache(e);case 13:return t.abrupt("return",t.sent);case 14:case"end":return t.stop()}}),n,this,[[1,9]])})))}},{key:"getChannelWithoutCache",value:function(e){var n=arguments.length>1&&void 0!==arguments[1]&&arguments[1];return b(this,void 0,void 0,t().mark((function r(){var a,s,i,o;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return Ua(L("string",e)).throw(M.invalidParameters),a=new ev({channelUrl:e,isInternalCall:n}),t.next=4,this._requestQueue.send(a);case 4:return s=t.sent,i=s.as(tv),o=i.channel,t.next=8,this.upsertChannelsToCache([o]);case 8:return t.abrupt("return",o);case 9:case"end":return t.stop()}}),r,this)})))}},{key:"createChannel",value:function(e){return b(this,void 0,void 0,t().mark((function n(){var r,a,s,i,o;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return r=Object.assign(Object.assign({},Xp),e),Ua($p(r)).throw(M.invalidParameters),a=new nv(r),t.next=5,this._requestQueue.send(a);case 5:return s=t.sent,i=s.as(tv),o=i.channel,this.upsertChannelsToCache([o]),t.abrupt("return",o);case 9:case"end":return t.stop()}}),n,this)})))}}],[{key:"of",value:function(e){return ov[e]}}]),n}(),cv={name:null,coverUrlOrImage:null,data:null,customType:null,operatorUserIds:null},lv=function(e){return F("string",e.operatorUserIds,!0)&&(L("string",e.coverUrlOrImage)||H(e.coverUrlOrImage)||null===e.coverUrlOrImage)&&L("string",e.name,!0)&&L("string",e.data,!0)&&L("string",e.customType,!0)},hv=function(e){i(n,e);var t=f(n);function n(e){var a;r(this,n);var s=e.channelUrl,i=e.token,o=e.limit;return(a=t.call(this)).method=B.GET,a.path="".concat(Br,"/").concat(encodeURIComponent(s),"/participants"),a.params={token:i,limit:o},a}return s(n)}(ne),dv=function(e){i(n,e);var t=f(n);function n(e,a){var s;r(this,n),(s=t.call(this,e,a)).token=null,s.participants=[];var i=a.next,o=a.participants;return s.token=i,s.participants=o.map((function(t){return new dl(e,t)})),s}return s(n)}(re),fv=function(n){i(u,n);var a=f(u);function u(t,n,s){return r(this,u),a.call(this,t,n,e.ChannelType.OPEN,s)}return s(u,[{key:"_validate",value:function(){return p(o(u.prototype),"_validate",this).call(this)}},{key:"next",value:function(){return b(this,void 0,void 0,t().mark((function e(){var n,r,a,s,i,o,u;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!this._validate()){e.next=20;break}if(this._isLoading){e.next=17;break}if(!this._hasNext){e.next=14;break}return this._isLoading=!0,n=ns.of(this._iid),r=n.requestQueue,a=new hv(Object.assign(Object.assign({},this),{token:this._token})),e.next=8,r.send(a);case 8:return s=e.sent,i=s.as(dv),o=i.participants,u=i.token,this._token=u,this._hasNext=!!u,this._isLoading=!1,e.abrupt("return",o);case 14:return e.abrupt("return",[]);case 17:throw M.queryInProgress;case 18:e.next=21;break;case 20:throw M.invalidParameters;case 21:case"end":return e.stop()}}),e,this)})))}}]),u}(Si),pv=function(e){i(n,e);var t=f(n);function n(e){var a;r(this,n);var s=e.channelUrl,i=e.coverUrlOrImage,o=e.name,u=e.data,c=e.customType,l=e.operatorUserIds;return(a=t.call(this)).method=B.PUT,a.path="".concat(Br,"/").concat(encodeURIComponent(s)),a.params=ee({cover_url:L("string",i)?i:null,cover_file:H(i)?i:null,name:o,data:u,custom_type:c,operators:l}),a}return s(n)}(ne),vv=function(e){i(n,e);var t=f(n);function n(e,a){var s;return r(this,n),(s=t.call(this,e,a)).channel=new mv(e,a),s}return s(n)}(re),_v=function(e){i(n,e);var t=f(n);function n(e){var a;r(this,n);var s=e.channelUrl;return(a=t.call(this)).method=B.DELETE,a.path="".concat(Br,"/").concat(encodeURIComponent(s)),a}return s(n)}(ne),mv=function(n){i(u,n);var a=f(u);function u(t,n){var s,i;return r(this,u),(s=a.call(this,t,n))._lastParticipantCountUpdated=0,s.participantCount=0,s.operators=[],s.channelType=e.ChannelType.OPEN,s.participantCount=null!==(i=n.participant_count)&&void 0!==i?i:0,s.operators=Array.isArray(n.operators)?n.operators.map((function(e){return new La(t,e)})):[],s}return s(u,[{key:"serialize",value:function(){return Ma(this)}},{key:"isOperator",value:function(e){return e instanceof La?this.isOperator(e.userId):this.operators.some((function(t){return t.userId===e}))}},{key:"_updateParticipantCount",value:function(e,t){return t>this._lastParticipantCountUpdated&&(this.participantCount=e,this._lastParticipantCountUpdated=t,!0)}},{key:"createParticipantListQuery",value:function(e){return new fv(this._iid,this.url,e)}},{key:"refresh",value:function(){return b(this,void 0,void 0,t().mark((function e(){var n;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n=uv.of(this._iid),e.next=3,n.getChannelWithoutCache(this.url);case 3:return e.abrupt("return",e.sent);case 4:case"end":return e.stop()}}),e,this)})))}},{key:"enter",value:function(){return b(this,void 0,void 0,t().mark((function e(){var n,r,a,s,i,o,u;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n=ns.of(this._iid),r=n.requestQueue,a=new rv({channelUrl:this.url}),e.next=4,r.send(a);case 4:s=e.sent,i=s.as(av),o=i.participantCount,u=i.ts,this._updateParticipantCount(o,u),uv.of(this._iid).setEnteredToCache(this);case 9:case"end":return e.stop()}}),e,this)})))}},{key:"exit",value:function(){return b(this,void 0,void 0,t().mark((function e(){var n,r,a,s,i,o,u;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n=ns.of(this._iid),r=n.requestQueue,a=new sv({channelUrl:this.url}),e.next=4,r.send(a);case 4:s=e.sent,i=s.as(iv),o=i.participantCount,u=i.ts,this._updateParticipantCount(o,u),uv.of(this._iid).setExitedToCache(this),vi.of(this._iid).fileMessageQueue.cancel(this);case 11:case"end":return e.stop()}}),e,this)})))}},{key:"updateChannel",value:function(e){return b(this,void 0,void 0,t().mark((function n(){var r,a,s,i,o,u,c,l;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return r=Object.assign(Object.assign({},cv),e),Ua(lv(r)).throw(M.invalidParameters),a=ns.of(this._iid),s=a.requestQueue,i=new pv(Object.assign({channelUrl:this.url},r)),t.next=6,s.send(i);case 6:return o=t.sent,u=o.as(vv),c=u.channel,l=uv.of(this._iid),t.next=11,l.upsertChannelsToCache([c]);case 11:return t.abrupt("return",c);case 12:case"end":return t.stop()}}),n,this)})))}},{key:"updateChannelWithOperatorUserIds",value:function(e,n,r,a,s){return b(this,void 0,void 0,t().mark((function i(){var o;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return o=Object.assign(Object.assign({},cv),{name:e,coverUrlOrImage:n,data:r,operatorUserIds:a,customType:s}),t.abrupt("return",this.updateChannel(o));case 2:case"end":return t.stop()}}),i,this)})))}},{key:"delete",value:function(){return b(this,void 0,void 0,t().mark((function e(){var n,r,a,s;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n=ns.of(this._iid),r=n.requestQueue,a=new _v({channelUrl:this.url}),e.next=4,r.send(a);case 4:return s=uv.of(this._iid),e.next=7,s.removeChannelsFromCache([this.url]);case 7:case"end":return e.stop()}}),e,this)})))}},{key:"sendUserMessage",value:function(e){return Ua(!e.isPinnedMessage).throw(M.notSupportedError),p(o(u.prototype),"sendUserMessage",this).call(this,e)}},{key:"sendFileMessage",value:function(e){return Ua(!e.isPinnedMessage).throw(M.notSupportedError),p(o(u.prototype),"sendFileMessage",this).call(this,e)}}],[{key:"payloadify",value:function(e){return e?ee(Object.assign(Object.assign({},zh.payloadify(e)),{participant_count:e.participantCount,operators:e.operators.map((function(e){return La.payloadify(e)}))})):null}}]),u}(zh),gv=function(e){i(n,e);var t=f(n);function n(){var e;return r(this,n),(e=t.apply(this,arguments)).onUserEntered=he,e.onUserExited=he,e.onChannelParticipantCountChanged=he,e.onPollUpdated=he,e.onPollVoted=he,e.onPollDeleted=he,e}return s(n)}(Vp),yv=function(e){i(n,e);var t=f(n);function n(){var e,a=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return r(this,n),e=t.call(this),Object.keys(a).forEach((function(t){e.hasOwnProperty(t)&&(e[t]=a[t])})),e}return s(n)}(gv),kv=function(e){i(n,e);var t=f(n);function n(e){var a;r(this,n);var s=e.token,i=e.limit,o=e.nameKeyword,u=e.urlKeyword,c=e.customTypes,l=e.includeFrozen,h=e.includeMetaData;return(a=t.call(this)).method=B.GET,a.path=Br,a.params=ee({token:s,limit:i,name_contains:o,url_contains:u,custom_types:c,show_frozen:l,show_metadata:h}),a}return s(n)}(ne),bv=function(e){i(n,e);var t=f(n);function n(e,a){var s;r(this,n),(s=t.call(this,e,a)).token=null,s.channels=[],s.ts=null;var i=a.next,o=a.channels,u=a.ts;return s.token=i,o&&o.length>0&&(s.channels=o.map((function(t){return new mv(e,t)}))),s.ts="number"==typeof u?u:null,s}return s(n)}(re),Ev=function(e){i(a,e);var n=f(a);function a(e,t){var s,i,o,u,c,l;return r(this,a),(s=n.call(this,e,t)).includeFrozen=!0,s.includeMetaData=!0,s.nameKeyword=null,s.urlKeyword=null,s.customTypes=null,s.includeFrozen=null===(i=t.includeFrozen)||void 0===i||i,s.includeMetaData=null===(o=t.includeMetaData)||void 0===o||o,s.nameKeyword=null!==(u=t.nameKeyword)&&void 0!==u?u:null,s.urlKeyword=null!==(c=t.urlKeyword)&&void 0!==c?c:null,s.customTypes=null!==(l=t.customTypes)&&void 0!==l?l:null,s}return s(a,[{key:"_validate",value:function(){return p(o(a.prototype),"_validate",this).call(this)&&L("boolean",this.includeFrozen)&&L("boolean",this.includeMetaData)&&L("string",this.nameKeyword,!0)&&L("string",this.urlKeyword,!0)&&F("string",this.customTypes,!0)}},{key:"next",value:function(){return b(this,void 0,void 0,t().mark((function e(){var n,r,a,s,i,o,u,c;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!this._validate()){e.next=23;break}if(this._isLoading){e.next=20;break}if(!this._hasNext){e.next=17;break}return this._isLoading=!0,n=ns.of(this._iid),r=n.requestQueue,a=new kv(Object.assign(Object.assign({},this),{token:this._token})),e.next=8,r.send(a);case 8:return s=e.sent,i=s.as(bv),o=i.channels,u=i.token,this._token=u,this._hasNext=!!u,c=uv.of(this._iid),e.next=15,c.upsertChannelsToCache(o);case 15:return this._isLoading=!1,e.abrupt("return",o);case 17:return e.abrupt("return",[]);case 20:throw M.queryInProgress;case 21:e.next=24;break;case 23:throw M.invalidParameters;case 24:case"end":return e.stop()}}),e,this)})))}}]),a}(ki),wv=function(e){i(a,e);var n=f(a);function a(){var e;return r(this,a),(e=n.apply(this,arguments)).name="openChannel",e}return s(a,[{key:"init",value:function(e,t){var n=t.sdkState,r=t.dispatcher,s=t.sessionManager,i=t.requestQueue,u=t.logger,c=t.onlineDetector,l=t.cacheContext;p(o(a.prototype),"init",this).call(this,e,{sdkState:n,dispatcher:r,sessionManager:s,requestQueue:i,logger:u,onlineDetector:c,cacheContext:l}),this._manager=new uv(e,{sdkState:n,dispatcher:r,requestQueue:i})}},{key:"createOpenChannelListQuery",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return new Ev(this._iid,e)}},{key:"addOpenChannelHandler",value:function(e,t){this._manager.addHandler(e,t)}},{key:"removeOpenChannelHandler",value:function(e){this._manager.removeHandler(e)}},{key:"removeAllOpenChannelHandlers",value:function(){this._manager.clearHandler()}},{key:"buildOpenChannelFromSerializedData",value:function(e){return this._manager.buildOpenChannelFromSerializedData(e)}},{key:"getChannel",value:function(e){return b(this,void 0,void 0,t().mark((function n(){return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.abrupt("return",this._manager.getChannel(e));case 1:case"end":return t.stop()}}),n,this)})))}},{key:"getChannelWithoutCache",value:function(e){return b(this,void 0,void 0,t().mark((function n(){return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.abrupt("return",this._manager.getChannelWithoutCache(e));case 1:case"end":return t.stop()}}),n,this)})))}},{key:"createChannel",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return b(this,void 0,void 0,t().mark((function n(){return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.abrupt("return",this._manager.createChannel(e));case 1:case"end":return t.stop()}}),n,this)})))}},{key:"createChannelWithOperatorUserIds",value:function(e,n,r,a,s){return b(this,void 0,void 0,t().mark((function i(){var o;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return(o=Object.assign({},Xp)).name=e,o.coverUrlOrImage=n,o.data=r,o.operatorUserIds=a,o.customType=s,t.abrupt("return",this._manager.createChannel(o));case 7:case"end":return t.stop()}}),i,this)})))}}]),a}(rs);jp=function(){function e(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function t(e,t){for(var n=0;n-1};function Nv(e){if("string"!=typeof e&&(e=String(e)),/[^a-z0-9\-#$%&'*+.^_`|~!]/i.test(e)||""===e)throw new TypeError('Invalid character in header field name: "'+e+'"');return e.toLowerCase()}function Av(e){return"string"!=typeof e&&(e=String(e)),e}function Mv(e){var t={next:function(){var t=e.shift();return{done:void 0===t,value:t}}};return Tv.iterable&&(t[Symbol.iterator]=function(){return t}),t}function Ov(e){this.map={},e instanceof Ov?e.forEach((function(e,t){this.append(t,e)}),this):Array.isArray(e)?e.forEach((function(e){this.append(e[0],e[1])}),this):e&&Object.getOwnPropertyNames(e).forEach((function(t){this.append(t,e[t])}),this)}function Uv(e){if(e.bodyUsed)return Promise.reject(new TypeError("Already read"));e.bodyUsed=!0}function Rv(e){return new Promise((function(t,n){e.onload=function(){t(e.result)},e.onerror=function(){n(e.error)}}))}function Lv(e){var t=new FileReader,n=Rv(t);return t.readAsArrayBuffer(e),n}function Dv(e){if(e.slice)return e.slice(0);var t=new Uint8Array(e.byteLength);return t.set(new Uint8Array(e)),t.buffer}function Pv(){return this.bodyUsed=!1,this._initBody=function(e){var t;this.bodyUsed=this.bodyUsed,this._bodyInit=e,e?"string"==typeof e?this._bodyText=e:Tv.blob&&Blob.prototype.isPrototypeOf(e)?this._bodyBlob=e:Tv.formData&&FormData.prototype.isPrototypeOf(e)?this._bodyFormData=e:Tv.searchParams&&URLSearchParams.prototype.isPrototypeOf(e)?this._bodyText=e.toString():Tv.arrayBuffer&&Tv.blob&&((t=e)&&DataView.prototype.isPrototypeOf(t))?(this._bodyArrayBuffer=Dv(e.buffer),this._bodyInit=new Blob([this._bodyArrayBuffer])):Tv.arrayBuffer&&(ArrayBuffer.prototype.isPrototypeOf(e)||Iv(e))?this._bodyArrayBuffer=Dv(e):this._bodyText=e=Object.prototype.toString.call(e):this._bodyText="",this.headers.get("content-type")||("string"==typeof e?this.headers.set("content-type","text/plain;charset=UTF-8"):this._bodyBlob&&this._bodyBlob.type?this.headers.set("content-type",this._bodyBlob.type):Tv.searchParams&&URLSearchParams.prototype.isPrototypeOf(e)&&this.headers.set("content-type","application/x-www-form-urlencoded;charset=UTF-8"))},Tv.blob&&(this.blob=function(){var e=Uv(this);if(e)return e;if(this._bodyBlob)return Promise.resolve(this._bodyBlob);if(this._bodyArrayBuffer)return Promise.resolve(new Blob([this._bodyArrayBuffer]));if(this._bodyFormData)throw new Error("could not read FormData body as blob");return Promise.resolve(new Blob([this._bodyText]))},this.arrayBuffer=function(){if(this._bodyArrayBuffer){var e=Uv(this);return e||(ArrayBuffer.isView(this._bodyArrayBuffer)?Promise.resolve(this._bodyArrayBuffer.buffer.slice(this._bodyArrayBuffer.byteOffset,this._bodyArrayBuffer.byteOffset+this._bodyArrayBuffer.byteLength)):Promise.resolve(this._bodyArrayBuffer))}return this.blob().then(Lv)}),this.text=function(){var e,t,n,r=Uv(this);if(r)return r;if(this._bodyBlob)return e=this._bodyBlob,t=new FileReader,n=Rv(t),t.readAsText(e),n;if(this._bodyArrayBuffer)return Promise.resolve(function(e){for(var t=new Uint8Array(e),n=new Array(t.length),r=0;r-1?r:n),this.mode=t.mode||this.mode||null,this.signal=t.signal||this.signal,this.referrer=null,("GET"===this.method||"HEAD"===this.method)&&a)throw new TypeError("Body not allowed for GET or HEAD requests");if(this._initBody(a),!("GET"!==this.method&&"HEAD"!==this.method||"no-store"!==t.cache&&"no-cache"!==t.cache)){var s=/([?&])_=[^&]*/;if(s.test(this.url))this.url=this.url.replace(s,"$1_="+(new Date).getTime());else{this.url+=(/\?/.test(this.url)?"&":"?")+"_="+(new Date).getTime()}}}function Hv(e){var t=new FormData;return e.trim().split("&").forEach((function(e){if(e){var n=e.split("="),r=n.shift().replace(/\+/g," "),a=n.join("=").replace(/\+/g," ");t.append(decodeURIComponent(r),decodeURIComponent(a))}})),t}function qv(e,t){if(!(this instanceof qv))throw new TypeError('Please use the "new" operator, this DOM object constructor cannot be called as a function.');t||(t={}),this.type="default",this.status=void 0===t.status?200:t.status,this.ok=this.status>=200&&this.status<300,this.statusText=void 0===t.statusText?"":""+t.statusText,this.headers=new Ov(t.headers),this.url=t.url||"",this._initBody(e)}Gv.prototype.clone=function(){return new Gv(this,{body:this._bodyInit})},Pv.call(Gv.prototype),Pv.call(qv.prototype),qv.prototype.clone=function(){return new qv(this._bodyInit,{status:this.status,statusText:this.statusText,headers:new Ov(this.headers),url:this.url})},qv.error=function(){var e=new qv(null,{status:0,statusText:""});return e.type="error",e};var jv=[301,302,303,307,308];qv.redirect=function(e,t){if(-1===jv.indexOf(t))throw new RangeError("Invalid status code");return new qv(null,{status:t,headers:{location:e}})};var zv=xv.DOMException;try{new zv}catch(Nt){(zv=function(e,t){this.message=e,this.name=t;var n=Error(e);this.stack=n.stack}).prototype=Object.create(Error.prototype),zv.prototype.constructor=zv}function Vv(e,t){return new Promise((function(r,a){var s=new Gv(e,t);if(s.signal&&s.signal.aborted)return a(new zv("Aborted","AbortError"));var i=new XMLHttpRequest;function o(){i.abort()}i.onload=function(){var e,t,n={status:i.status,statusText:i.statusText,headers:(e=i.getAllResponseHeaders()||"",t=new Ov,e.replace(/\r?\n[\t ]+/g," ").split("\r").map((function(e){return 0===e.indexOf("\n")?e.substr(1,e.length):e})).forEach((function(e){var n=e.split(":"),r=n.shift().trim();if(r){var a=n.join(":").trim();t.append(r,a)}})),t)};n.url="responseURL"in i?i.responseURL:n.headers.get("X-Request-URL");var a="response"in i?i.response:i.responseText;setTimeout((function(){r(new qv(a,n))}),0)},i.onerror=function(){setTimeout((function(){a(new TypeError("Network request failed"))}),0)},i.ontimeout=function(){setTimeout((function(){a(new TypeError("Network request failed"))}),0)},i.onabort=function(){setTimeout((function(){a(new zv("Aborted","AbortError"))}),0)},i.open(s.method,function(e){try{return""===e&&xv.location.href?xv.location.href:e}catch(t){return e}}(s.url),!0),"include"===s.credentials?i.withCredentials=!0:"omit"===s.credentials&&(i.withCredentials=!1),"responseType"in i&&(Tv.blob?i.responseType="blob":Tv.arrayBuffer&&s.headers.get("Content-Type")&&-1!==s.headers.get("Content-Type").indexOf("application/octet-stream")&&(i.responseType="arraybuffer")),!t||"object"!==n(t.headers)||t.headers instanceof Ov?s.headers.forEach((function(e,t){i.setRequestHeader(t,e)})):Object.getOwnPropertyNames(t.headers).forEach((function(e){i.setRequestHeader(e,Av(t.headers[e]))})),s.signal&&(s.signal.addEventListener("abort",o),i.onreadystatechange=function(){4===i.readyState&&s.signal.removeEventListener("abort",o)}),i.send(void 0===s._bodyInit?null:s._bodyInit)}))}Vv.polyfill=!0,xv.fetch||(xv.fetch=Vv,xv.Headers=Ov,xv.Request=Gv,xv.Response=qv);var Bv=Object.freeze({__proto__:null});return e.AdminMessage=Ts,e.AppleCriticalAlertOptions=ms,e.ApplicationUserListQuery=oc,e.BannedUserListQuery=Sl,e.BaseChannel=zh,e.BaseMessage=ks,e.BlockedUserListQuery=lc,e.CachedChannelInfo=Q,e.ConnectionHandler=io,e.Emoji=Zu,e.EmojiCategory=Ju,e.EmojiContainer=Xu,e.FileMessage=Ps,e.FriendListQuery=fc,e.GroupChannel=Rp,e.GroupChannelCollection=Gp,e.GroupChannelEventContext=xf,e.GroupChannelFilter=rd,e.GroupChannelHandler=Qp,e.GroupChannelListQuery=yf,e.GroupChannelModule=Zp,e.LocalCacheConfig=K,e.Member=ed,e.MemberListQuery=rp,e.MemoryStore=$c,e.MessageCollection=Kf,e.MessageCollectionInitHandler=Qf,e.MessageEventContext=Tf,e.MessageFilter=po,e.MessageMetaArray=ps,e.MessageModule=Mi,e.MessageRequestHandler=_i,e.MessageSearchQuery=Ti,e.MutedUserListQuery=Cl,e.OGImage=vs,e.OGMetaData=_s,e.OpenChannel=mv,e.OpenChannelHandler=yv,e.OpenChannelListQuery=Ev,e.OpenChannelModule=wv,e.OperatorListQuery=bl,e.Participant=dl,e.ParticipantListQuery=fv,e.PinnedMessage=Np,e.PinnedMessageListQuery=Op,e.Plugin=Ss,e.PreviousMessageListQuery=Ii,e.PublicGroupChannelListQuery=zp,e.Reaction=fs,e.ReactionEvent=ds,e.ReadStatus=td,e.RestrictedUser=hl,e.RestrictionInfo=ll,e.ScheduledMessageListQuery=Yp,e.SendbirdChat=Bh,e.SendbirdChatOptions=q,e.SendbirdError=M,e.Sender=bs,e.SessionHandler=so,e.ThreadInfo=os,e.ThreadInfoUpdateEvent=mi,e.Thumbnail=ws,e.User=La,e.UserEventHandler=oo,e.UserMessage=Rs,Object.defineProperty(e,"__esModule",{value:!0}),e}({}); +var Sendbird=function(e){"use strict";function t(){t=function(){return e};var e={},n=Object.prototype,r=n.hasOwnProperty,a=Object.defineProperty||function(e,t,n){e[t]=n.value},s="function"==typeof Symbol?Symbol:{},i=s.iterator||"@@iterator",o=s.asyncIterator||"@@asyncIterator",u=s.toStringTag||"@@toStringTag";function c(e,t,n){return Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}),e[t]}try{c({},"")}catch(e){c=function(e,t,n){return e[t]=n}}function l(e,t,n,r){var s=t&&t.prototype instanceof f?t:f,i=Object.create(s.prototype),o=new T(r||[]);return a(i,"_invoke",{value:E(e,n,o)}),i}function h(e,t,n){try{return{type:"normal",arg:e.call(t,n)}}catch(e){return{type:"throw",arg:e}}}e.wrap=l;var d={};function f(){}function p(){}function v(){}var _={};c(_,i,(function(){return this}));var m=Object.getPrototypeOf,g=m&&m(m(S([])));g&&g!==n&&r.call(g,i)&&(_=g);var y=v.prototype=f.prototype=Object.create(_);function k(e){["next","throw","return"].forEach((function(t){c(e,t,(function(e){return this._invoke(t,e)}))}))}function b(e,t){function n(a,s,i,o){var u=h(e[a],e,s);if("throw"!==u.type){var c=u.arg,l=c.value;return l&&"object"==typeof l&&r.call(l,"__await")?t.resolve(l.__await).then((function(e){n("next",e,i,o)}),(function(e){n("throw",e,i,o)})):t.resolve(l).then((function(e){c.value=e,i(c)}),(function(e){return n("throw",e,i,o)}))}o(u.arg)}var s;a(this,"_invoke",{value:function(e,r){function a(){return new t((function(t,a){n(e,r,t,a)}))}return s=s?s.then(a,a):a()}})}function E(e,t,n){var r="suspendedStart";return function(a,s){if("executing"===r)throw new Error("Generator is already running");if("completed"===r){if("throw"===a)throw s;return I()}for(n.method=a,n.arg=s;;){var i=n.delegate;if(i){var o=w(i,n);if(o){if(o===d)continue;return o}}if("next"===n.method)n.sent=n._sent=n.arg;else if("throw"===n.method){if("suspendedStart"===r)throw r="completed",n.arg;n.dispatchException(n.arg)}else"return"===n.method&&n.abrupt("return",n.arg);r="executing";var u=h(e,t,n);if("normal"===u.type){if(r=n.done?"completed":"suspendedYield",u.arg===d)continue;return{value:u.arg,done:n.done}}"throw"===u.type&&(r="completed",n.method="throw",n.arg=u.arg)}}}function w(e,t){var n=t.method,r=e.iterator[n];if(void 0===r)return t.delegate=null,"throw"===n&&e.iterator.return&&(t.method="return",t.arg=void 0,w(e,t),"throw"===t.method)||"return"!==n&&(t.method="throw",t.arg=new TypeError("The iterator does not provide a '"+n+"' method")),d;var a=h(r,e.iterator,t.arg);if("throw"===a.type)return t.method="throw",t.arg=a.arg,t.delegate=null,d;var s=a.arg;return s?s.done?(t[e.resultName]=s.value,t.next=e.nextLoc,"return"!==t.method&&(t.method="next",t.arg=void 0),t.delegate=null,d):s:(t.method="throw",t.arg=new TypeError("iterator result is not an object"),t.delegate=null,d)}function C(e){var t={tryLoc:e[0]};1 in e&&(t.catchLoc=e[1]),2 in e&&(t.finallyLoc=e[2],t.afterLoc=e[3]),this.tryEntries.push(t)}function x(e){var t=e.completion||{};t.type="normal",delete t.arg,e.completion=t}function T(e){this.tryEntries=[{tryLoc:"root"}],e.forEach(C,this),this.reset(!0)}function S(e){if(e){var t=e[i];if(t)return t.call(e);if("function"==typeof e.next)return e;if(!isNaN(e.length)){var n=-1,a=function t(){for(;++n=0;--a){var s=this.tryEntries[a],i=s.completion;if("root"===s.tryLoc)return n("end");if(s.tryLoc<=this.prev){var o=r.call(s,"catchLoc"),u=r.call(s,"finallyLoc");if(o&&u){if(this.prev=0;--n){var a=this.tryEntries[n];if(a.tryLoc<=this.prev&&r.call(a,"finallyLoc")&&this.prev=0;--t){var n=this.tryEntries[t];if(n.finallyLoc===e)return this.complete(n.completion,n.afterLoc),x(n),d}},catch:function(e){for(var t=this.tryEntries.length-1;t>=0;--t){var n=this.tryEntries[t];if(n.tryLoc===e){var r=n.completion;if("throw"===r.type){var a=r.arg;x(n)}return a}}throw new Error("illegal catch attempt")},delegateYield:function(e,t,n){return this.delegate={iterator:S(e),resultName:t,nextLoc:n},"next"===this.method&&(this.arg=void 0),d}},e}function n(e){return n="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},n(e)}function r(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function a(e,t){for(var n=0;ne.length)&&(t=e.length);for(var n=0,r=new Array(t);n=e.length?{done:!0}:{done:!1,value:e[r++]}},e:function(e){throw e},f:a}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var s,i=!0,o=!1;return{s:function(){n=n.call(e)},n:function(){var e=n.next();return i=e.done,e},e:function(e){o=!0,s=e},f:function(){try{i||null==n.return||n.return()}finally{if(o)throw s}}}}function k(e){var t=function(e,t){if("object"!=typeof e||null===e)return e;var n=e[Symbol.toPrimitive];if(void 0!==n){var r=n.call(e,t||"default");if("object"!=typeof r)return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(e,"string");return"symbol"==typeof t?t:String(t)}function b(e,t,n,r){return new(n||(n=Promise))((function(a,s){function i(e){try{u(r.next(e))}catch(e){s(e)}}function o(e){try{u(r.throw(e))}catch(e){s(e)}}function u(e){var t;e.done?a(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(i,o)}u((r=r.apply(e,t||[])).next())}))}var E,w="4.8.2",C=function(){function e(){r(this,e)}return s(e,null,[{key:"OS_VERSION",get:function(){return"undefined"!=typeof navigator&&navigator.userAgent?navigator.userAgent.replace(/,/g,"."):"noAgent"}},{key:"SDK_VERSION",get:function(){return w}},{key:"SDK_MAJOR_VERSION",get:function(){return e.SDK_VERSION.split(".")[0]}},{key:"DEFAULT_MAX_UNREAD_COUNT_OF_SUPER_GROUP_CHANNEL",get:function(){return 100}},{key:"INTERNAL_CALL",get:function(){return"ic"}}]),e}();!function(e){e[e.STAT_LOG_NOT_ALLOWED=400108]="STAT_LOG_NOT_ALLOWED",e[e.NON_AUTHORIZED=400108]="NON_AUTHORIZED",e[e.INVALID_TOKEN=400111]="INVALID_TOKEN",e[e.NOT_FOUND_IN_DATABASE=400201]="NOT_FOUND_IN_DATABASE",e[e.SESSION_TOKEN_EXPIRED=400302]="SESSION_TOKEN_EXPIRED",e[e.SESSION_KEY_EXPIRED=400309]="SESSION_KEY_EXPIRED",e[e.STAT_UPLOAD_NOT_ALLOWED=403200]="STAT_UPLOAD_NOT_ALLOWED",e[e.INTERNAL_SERVER_ERROR=500901]="INTERNAL_SERVER_ERROR",e[e.RATE_LIMIT_EXCEEDED=500910]="RATE_LIMIT_EXCEEDED",e[e.UNKNOWN_SERVER_ERROR=900200]="UNKNOWN_SERVER_ERROR",e[e.DEBUG_MODE_REQUIRED=7e5]="DEBUG_MODE_REQUIRED",e[e.LOST_INSTANCE=700100]="LOST_INSTANCE",e[e.CONNECTION_RENEW=700102]="CONNECTION_RENEW",e[e.INVALID_CONNECTION_STATE_TRANSITION=700200]="INVALID_CONNECTION_STATE_TRANSITION",e[e.INVALID_INITIALIZATION=800100]="INVALID_INITIALIZATION",e[e.CONNECTION_REQUIRED=800101]="CONNECTION_REQUIRED",e[e.CONNECTION_CANCELED=800102]="CONNECTION_CANCELED",e[e.INVALID_PARAMETER=800110]="INVALID_PARAMETER",e[e.NOT_SUPPORTED_ERROR=800111]="NOT_SUPPORTED_ERROR",e[e.NETWORK_ERROR=800120]="NETWORK_ERROR",e[e.NETWORK_ROUTING_ERROR=800121]="NETWORK_ROUTING_ERROR",e[e.MALFORMED_DATA=800130]="MALFORMED_DATA",e[e.MALFORMED_ERROR_DATA=800140]="MALFORMED_ERROR_DATA",e[e.WRONG_CHANNEL_TYPE=800150]="WRONG_CHANNEL_TYPE",e[e.MARK_AS_READ_RATE_LIMIT_EXCEEDED=800160]="MARK_AS_READ_RATE_LIMIT_EXCEEDED",e[e.QUERY_IN_PROGRESS=800170]="QUERY_IN_PROGRESS",e[e.ACK_TIMEOUT=800180]="ACK_TIMEOUT",e[e.LOGIN_TIMEOUT=800190]="LOGIN_TIMEOUT",e[e.WEBSOCKET_CONNECTION_CLOSED=800200]="WEBSOCKET_CONNECTION_CLOSED",e[e.WEBSOCKET_CONNECTION_FAILED=800210]="WEBSOCKET_CONNECTION_FAILED",e[e.REQUEST_FAILED=800220]="REQUEST_FAILED",e[e.FILE_UPLOAD_CANCEL_FAILED=800230]="FILE_UPLOAD_CANCEL_FAILED",e[e.REQUEST_CANCELED=800240]="REQUEST_CANCELED",e[e.REQUEST_DUPLICATED=800250]="REQUEST_DUPLICATED",e[e.FILE_SIZE_LIMIT_EXCEEDED=800260]="FILE_SIZE_LIMIT_EXCEEDED",e[e.SESSION_TOKEN_REQUEST_FAILED=800500]="SESSION_TOKEN_REQUEST_FAILED",e[e.SESSION_TOKEN_REFRESHED=800501]="SESSION_TOKEN_REFRESHED",e[e.SESSION_TOKEN_REFRESH_FAILED=800502]="SESSION_TOKEN_REFRESH_FAILED",e[e.COLLECTION_DISPOSED=800600]="COLLECTION_DISPOSED",e[e.DATABASE_ERROR=800700]="DATABASE_ERROR"}(E||(E={}));var x,T,S,I,N,A=function(e){return!(e instanceof M&&!e.shouldThrowOutside)},M=function(e){i(n,e);var t=f(n);function n(e){var a,s=e.code,i=void 0===s?0:s,o=e.message;return r(this,n),(a=t.call(this,o)).shouldThrowOutside=!1,a.name="SendbirdError",a.code=i,Object.setPrototypeOf(d(a),n.prototype),a}return s(n,[{key:"isInvalidTokenError",get:function(){return this.code===E.INVALID_TOKEN}},{key:"isSessionTokenExpiredError",get:function(){return this.code===E.SESSION_TOKEN_EXPIRED}},{key:"isSessionKeyExpiredError",get:function(){return this.code===E.SESSION_KEY_EXPIRED}},{key:"throwOutside",value:function(){throw this.shouldThrowOutside=!0,this}}],[{key:"debugModeRequired",get:function(){return new n({code:E.DEBUG_MODE_REQUIRED,message:"Cannot run this operation in production mode."})}},{key:"lostInstance",get:function(){return new n({code:E.LOST_INSTANCE,message:"Instance ID is missing. It should belong to an instance."})}},{key:"connectionRenew",get:function(){return new n({code:E.CONNECTION_RENEW,message:"Connection restarts."})}},{key:"invalidConnectionStateTransition",get:function(){return new n({code:E.INVALID_CONNECTION_STATE_TRANSITION,message:"Invalid connection state transition."})}},{key:"connectionRequired",get:function(){return new n({code:E.CONNECTION_REQUIRED,message:"Connection is required."})}},{key:"connectionCanceled",get:function(){return new n({code:E.CONNECTION_CANCELED,message:"Connection is canceled."})}},{key:"invalidParameters",get:function(){return new n({code:E.INVALID_PARAMETER,message:"Invalid parameters."})}},{key:"notSupportedError",get:function(){return new n({code:E.NOT_SUPPORTED_ERROR,message:"Given parameters are not supported."})}},{key:"networkError",get:function(){return new n({code:E.NETWORK_ERROR,message:"There was a network error."})}},{key:"markAsReadAllRateLimitExceeded",get:function(){return new n({code:E.MARK_AS_READ_RATE_LIMIT_EXCEEDED,message:"markAsRead rate limit exceeded."})}},{key:"queryInProgress",get:function(){return new n({code:E.QUERY_IN_PROGRESS,message:"Query in progress."})}},{key:"noAckTimeout",get:function(){return new n({code:E.ACK_TIMEOUT,message:"Command received no ack."})}},{key:"loginTimeout",get:function(){return new n({code:E.LOGIN_TIMEOUT,message:"Connection timeout."})}},{key:"connectionClosed",get:function(){return new n({code:E.WEBSOCKET_CONNECTION_CLOSED,message:"Connection is closed. Please reconnect."})}},{key:"requestFailed",get:function(){return new n({code:E.REQUEST_FAILED,message:"Request failed."})}},{key:"fileUploadCanceled",get:function(){return new n({code:E.FILE_UPLOAD_CANCEL_FAILED,message:"File upload has been canceled."})}},{key:"requestCanceled",get:function(){return new n({code:E.REQUEST_CANCELED,message:"Request has been canceled."})}},{key:"sessionTokenRefreshFailed",get:function(){return new n({code:E.SESSION_TOKEN_REFRESH_FAILED,message:"Failed to refresh the session key."})}},{key:"sessionTokenRequestFailed",get:function(){return new n({code:E.SESSION_TOKEN_REQUEST_FAILED,message:"Failed to get the session token."})}},{key:"databaseError",get:function(){return new n({code:E.DATABASE_ERROR,message:"Database error."})}}]),n}(h(Error)),O=[E.CONNECTION_REQUIRED,E.NETWORK_ERROR,E.ACK_TIMEOUT,E.WEBSOCKET_CONNECTION_CLOSED,E.WEBSOCKET_CONNECTION_FAILED,E.FILE_UPLOAD_CANCEL_FAILED,E.REQUEST_CANCELED,E.INTERNAL_SERVER_ERROR,E.RATE_LIMIT_EXCEEDED,E.UNKNOWN_SERVER_ERROR],U=[E.WEBSOCKET_CONNECTION_CLOSED,E.WEBSOCKET_CONNECTION_FAILED,E.CONNECTION_REQUIRED],R=function(e,t){if(e!==t){var n=Object.assign({},e),r=Object.assign({},t);return(!n.hasOwnProperty("messageId")||!r.hasOwnProperty("messageId")||n.messageId===r.messageId)&&((!n.hasOwnProperty("reqId")||!r.hasOwnProperty("reqId")||n.reqId===r.reqId)&&(n.hasOwnProperty("messageId")&&delete n.messageId,n.hasOwnProperty("reqId")&&delete n.reqId,r.hasOwnProperty("messageId")&&delete r.messageId,r.hasOwnProperty("reqId")&&delete r.reqId,JSON.stringify(n)===JSON.stringify(r)))}return!0},L=function(e,t){return!(!(arguments.length>2&&void 0!==arguments[2]&&arguments[2])||null!=t)||("string"!=typeof e?"object"===n(e)?D(e,t):P(e,t):n(t)===e)},D=function(e,t){return!(!(arguments.length>2&&void 0!==arguments[2]&&arguments[2])||null!=t)||Object.values(e).includes(t)},P=function(e,t){return t instanceof e},F=function(e,t){return!(!(arguments.length>2&&void 0!==arguments[2]&&arguments[2])||null!=t)||Array.isArray(t)&&t.every((function(t){return L(e,t)}))},G=function(e){return e>0&&U.indexOf(e)>=0},H=function(e){if(arguments.length>1&&void 0!==arguments[1]&&arguments[1]&&null===e)return!0;var t=L("object",e)&&null!==e&&e.hasOwnProperty("name")&&"string"==typeof e.name&&e.hasOwnProperty("uri")&&"string"==typeof e.uri&&e.hasOwnProperty("type")&&"string"==typeof e.type;if(!t){if("undefined"!=typeof Blob)return e instanceof Blob;if("undefined"!=typeof File)return e instanceof File}return t},q=function(){function e(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},n=t.useMemberInfoInMessage,a=void 0===n||n,s=t.typingIndicatorInvalidateTime,i=void 0===s?1e4:s,o=t.typingIndicatorThrottle,u=void 0===o?1e3:o,c=t.websocketResponseTimeout,l=void 0===c?1e4:c,h=t.websocketPayloadDecompression,d=void 0===h||h,f=t.sessionTokenRefreshTimeout,p=void 0===f?60:f;r(this,e),this._useMemberInfoInMessage=!0,this._typingIndicatorInvalidateTime=1e4,this._typingIndicatorThrottle=1e3,this._websocketResponseTimeout=1e4,this._sessionTokenRefreshTimeout=60,this._useMemberInfoInMessage=a,this._typingIndicatorInvalidateTime=i,this._typingIndicatorThrottle=u,this._websocketResponseTimeout=l,this._sessionTokenRefreshTimeout=p,this.websocketPayloadDecompression=d}return s(e,[{key:"useMemberInfoInMessage",get:function(){return this._useMemberInfoInMessage},set:function(e){L("boolean",e)&&(this._useMemberInfoInMessage=e)}},{key:"typingIndicatorInvalidateTime",get:function(){return this._typingIndicatorInvalidateTime},set:function(e){L("number",e)&&(this._typingIndicatorInvalidateTime=e)}},{key:"typingIndicatorThrottle",get:function(){return this._typingIndicatorThrottle},set:function(e){L("number",e)&&e>=1e3&&e<=9e3&&(this._typingIndicatorThrottle=e)}},{key:"websocketResponseTimeout",get:function(){return this._websocketResponseTimeout},set:function(e){L("number",e)&&e>=5e3&&e<=3e4&&(this._websocketResponseTimeout=e)}},{key:"sessionTokenRefreshTimeout",get:function(){return this._sessionTokenRefreshTimeout},set:function(e){L("number",e)&&(e<60?e=60:e>1800&&(e=1800),this._sessionTokenRefreshTimeout=e)}}]),e}(),j={encrypt:function(e){return e},decrypt:function(e){return e}},z=function(){function e(t){var n=t.store;r(this,e),this._preference=new Map,this._store=n}return s(e,[{key:"_savePreferenceKeys",value:function(){return b(this,void 0,void 0,t().mark((function e(){return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this._store.set({key:this._keysAddress,value:_(this._preference.keys()),generation:1});case 2:case"end":return e.stop()}}),e,this)})))}},{key:"init",value:function(e){var n,r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:1;return b(this,void 0,void 0,t().mark((function a(){var s,i,o,u,c,l,h;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return this._version=r,this._keysAddress=e,s="".concat(e,".metadata.version"),t.next=5,this._store.get(s);case 5:return i=t.sent,t.next=8,this._store.get(e);case 8:if(t.t1=n=t.sent,t.t0=null!==t.t1,!t.t0){t.next=12;break}t.t0=void 0!==n;case 12:if(!t.t0){t.next=16;break}t.t2=n,t.next=17;break;case 16:t.t2=[];case 17:if(o=t.t2,i&&!(i.version0&&void 0!==arguments[0]?arguments[0]:{},n=t.maxSize,a=void 0===n?256:n,s=t.clearOrder,i=void 0===s?N.MESSAGE_COLLECTION_ACCESSED_AT:s,o=t.customClearOrderComparator,u=void 0===o?null:o;r(this,e),this._customClearOrderComparator=null,this._clearOrderComparatorUseMessageCollectionAccessedAt=function(e,t){return e.channel.messageCollectionLastAccessedAt===t.channel.messageCollectionLastAccessedAt?e.channel.lastMessage&&!t.channel.lastMessage?1:!e.channel.lastMessage&&t.channel.lastMessage?-1:e.channel.lastMessage.createdAt-t.channel.lastMessage.createdAt:e.channel.messageCollectionLastAccessedAt>t.channel.messageCollectionLastAccessedAt?1:-1},this._maxSize=Math.max(a,64),u?(this._clearOrder=i,this._customClearOrderComparator=u):this._clearOrder=N.MESSAGE_COLLECTION_ACCESSED_AT}return s(e,[{key:"maxSize",get:function(){return this._maxSize}},{key:"clearOrder",get:function(){return this._clearOrder}},{key:"clearOrderComparator",get:function(){var e;return this._clearOrder===N.MESSAGE_COLLECTION_ACCESSED_AT?this._clearOrderComparatorUseMessageCollectionAccessedAt:null!==(e=this._customClearOrderComparator)&&void 0!==e?e:this._clearOrderComparatorUseMessageCollectionAccessedAt}}]),e}(),W=function(){function e(){r(this,e),this.sessionKey=null,this.authToken=null}return s(e,[{key:"hasSession",get:function(){return!!this.sessionKey}},{key:"clear",value:function(){this.authToken=null,this.sessionKey=null}}]),e}(),Y=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)}))},Z=function(){function e(t){var n=t.container;r(this,e),this._container={},this._container=n,this.key=Y()}return s(e,[{key:"_register",value:function(e,t,n){return e in this._container||(this._container[e]=new Map),this._container[e].set(this.key,{occurence:t,handler:n}),this}},{key:"on",value:function(e,t){return this._register(e,-1,t)}},{key:"once",value:function(e,t){return this._register(e,1,t)}},{key:"close",value:function(){for(var e in this._container)this._container[e].delete(this.key)}}]),e}(),J=function(){function e(){r(this,e),this._container={}}return s(e,[{key:"on",value:function(e,t){return new Z({container:this._container}).on(e,t)}},{key:"once",value:function(e,t){return new Z({container:this._container}).once(e,t)}},{key:"dispatch",value:function(e,t){var n=this._container[e];if(n){var r,a=[],s=y(n.keys());try{for(s.s();!(r=s.n()).done;){var i=r.value,o=n.get(i);o.handler(t),o.occurence>0&&(o.occurence--,0===o.occurence&&a.push(i))}}catch(e){s.e(e)}finally{s.f()}a.forEach((function(e){return n.delete(e)}))}}}]),e}(),X=function(){function e(){r(this,e),this._dispatcher=new J}return s(e,[{key:"on",value:function(e){return this._dispatcher.on("event",e)}},{key:"once",value:function(e){return this._dispatcher.once("event",e)}},{key:"dispatch",value:function(e){this._dispatcher.dispatch("event",e)}}]),e}(),$=s((function e(){r(this,e)})),ee=function(e){var t={};return e&&Object.keys(e).forEach((function(n){void 0===e[n]||Number.isNaN(e[n])||null===e[n]||(t[n]=e[n])})),t};!function(e){e.GET="GET",e.POST="POST",e.PUT="PUT",e.DELETE="DELETE"}(B||(B={}));var te,ne=function(e){i(a,e);var t=f(a);function a(){var e;return r(this,a),(e=t.apply(this,arguments)).params={},e.requireAuth=!0,e.headers={},e.requestId=Y(),e}return s(a,[{key:"stringifyParams",value:function(e){return"object"!==n(e)||Array.isArray(e)?String(e):e?JSON.stringify(e):""}},{key:"encodeParams",value:function(e){var t=this;return null==e||""===e?encodeURIComponent(""):Array.isArray(e)?e.map((function(e){return t.encodeParams(e)})).join(","):"object"===n(e)?encodeURIComponent(JSON.stringify(e)):encodeURIComponent(String(e))}},{key:"query",get:function(){var e=this,t=ee(this.params);return"?".concat(Object.keys(t).map((function(n){return"".concat(encodeURIComponent(n),"=").concat(e.encodeParams(t[n]))})).join("&"))}},{key:"payload",get:function(){var e=this,t=ee(this.params);if(Object.keys(t).some((function(e){return H(t[e])}))){var n=new FormData;return Object.keys(t).forEach((function(r){var a,s=t[r];if(H(s)){var i=s;n.append(r,i,null!==(a=i.name)&&void 0!==a?a:"filename")}else n.append(r,e.stringifyParams(s))})),n}return JSON.stringify(t)}}]),a}($),re=function(e){i(n,e);var t=f(n);function n(e,a){var s;return r(this,n),(s=t.call(this))._iid=e,s._payload=a,s}return s(n,[{key:"payload",get:function(){return Object.assign({},this._payload)}},{key:"as",value:function(e){return new e(this._iid,this.payload)}}]),n}($),ae=function(e){i(n,e);var t=f(n);function n(e){var a;return r(this,n),(a=t.call(this)).requestId=e,a}return s(n)}($),se=function(e){i(n,e);var t=f(n);function n(){return r(this,n),t.apply(this,arguments)}return s(n)}($),ie=function(e){i(n,e);var t=f(n);function n(e){var a;return r(this,n),(a=t.call(this)).statLog=e,a}return s(n)}($);!function(e){e.FEATURE_LOCALCACHE="feature:local_cache",e.WEBSOCKET_CONNECT="ws:connect",e.API_RESULT="api:result"}(te||(te={}));var oe=function(){function e(t){var n=t.type,a=t.data,s=t.ts,i=void 0===s?Date.now():s;r(this,e),this.type=n,this.createdAt=i,this.data=a}return s(e,null,[{key:"payloadify",value:function(e){return ee({stat_type:e.type,ts:e.createdAt,data:ee(e.data)})}}]),e}(),ue=function(){return"undefined"==typeof document&&"undefined"!=typeof navigator&&"ReactNative"==navigator.product},ce=function(){function e(t,n){var a=this,s=n.auth,i=n.sdkState,o=n.dispatcher,u=n.logger,c=n.useFetchCompat,l=void 0!==c&&c;r(this,e),this._abortControl=new Map,this._shouldImportFetchCompat=!1,this._iid=t,this._auth=s,this._sdkState=i,this._dispatcher=o,this._dispatcher.on((function(e){e instanceof ae&&a.cancel(e.requestId)})),this._logger=u,this._shouldImportFetchCompat=l}return s(e,[{key:"_userAgentWithExtension",get:function(){var e=this._sdkState.extensions,t=ue()?"reactnative":"JS",n=e.sb_syncmanager?"s".concat(e.sb_syncmanager):"",r=e.sb_uikit?"u".concat(e.sb_uikit):"",a=e["device-os-platform"]?"o".concat(e["device-os-platform"]):"";return"".concat(t,"/c").concat(C.SDK_VERSION,"/").concat(n,"/").concat(r,"/").concat(a)}},{key:"_createHeader",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null,n=this._sdkState,r=n.appId,a=n.appVersion,s=Object.assign(Object.assign({},e.headers),{SendBird:"JS,".concat(C.OS_VERSION,",").concat(C.SDK_VERSION,",").concat(r).concat(a?",".concat(a):""),"SB-User-Agent":encodeURIComponent(this._userAgentWithExtension),"Request-Sent-Timestamp":Date.now().toString()});return t||(s["Content-Type"]="application/json; charset=utf-8"),e.requireAuth&&this._auth.hasSession&&(s["Session-Key"]=this._auth.sessionKey),this._auth&&this._auth.authToken&&(s["App-Id"]=r,s["Access-Token"]=this._auth.authToken),s}},{key:"_statLogApiResult",value:function(e,t,n){this._dispatcher.dispatch(new ie(new oe({type:te.API_RESULT,data:{endpoint:e.path,method:e.method,success:!n,latency:Date.now()-t,error_code:null==n?void 0:n.code,error_description:null==n?void 0:n.message}})))}},{key:"send",value:function(e){return b(this,void 0,void 0,t().mark((function n(){var r,a,s,i,o,u,c,l,h,d,f,p,v,_,m;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(r=e.path,a=e.method,s=![B.GET,B.DELETE].includes(a),i=this._sdkState.api,o="".concat(i.host).concat(r).concat(s?"":e.query),u=s?e.payload:null,c=this._createHeader(e,u instanceof FormData?u:null),l=new AbortController,h=l.signal,this._abortControl.set(e.requestId,l),d=Date.now(),t.prev=10,this._shouldImportFetchCompat&&(this._shouldImportFetchCompat=!1,("undefined"!=typeof globalThis&&globalThis||"undefined"!=typeof self&&self||"undefined"!=typeof global&&global||{fetch:null}).fetch=void 0),"undefined"!=typeof AbortController){t.next=15;break}return t.next=15,Promise.resolve().then((function(){return Cv}));case 15:if("function"==typeof fetch){t.next=18;break}return t.next=18,Promise.resolve().then((function(){return Bv}));case 18:return t.next=20,fetch(o,{method:a,body:u,headers:c,signal:h});case 20:return f=t.sent,t.next=23,f.json();case 23:if(p=t.sent,!f.ok&&!f.redirected){t.next=30;break}return this._logger.debug("receive api response",e.requestId),this._statLogApiResult(e,d,null),t.abrupt("return",new re(this._iid,p));case 30:if(!p){t.next=37;break}throw v=new M(p),!e.requireAuth&&v.isSessionKeyExpiredError&&this._dispatcher.dispatch(new se),this._statLogApiResult(e,d,v),v;case 37:throw _=M.requestFailed,this._statLogApiResult(e,d,_),_;case 40:t.next=57;break;case 42:if(t.prev=42,t.t0=t.catch(10),this._statLogApiResult(e,d,t.t0),!(t.t0 instanceof M)){t.next=50;break}throw this._logger.debug("fail api request",t.t0),t.t0;case 50:if("AbortError"!==t.t0.name){t.next=54;break}throw M.requestCanceled;case 54:throw m=M.networkError,this._logger.debug("fail api request",m),m;case 57:case"end":return t.stop()}}),n,this,[[10,42]])})))}},{key:"cancel",value:function(e){this._abortControl.has(e)&&(this._abortControl.get(e).abort(),this._abortControl.delete(e))}},{key:"cancelAll",value:function(){var e,t=y(this._abortControl.values());try{for(t.s();!(e=t.n()).done;){e.value.abort()}}catch(e){t.e(e)}finally{t.f()}this._abortControl.clear()}}]),e}(),le=function(e){i(n,e);var t=f(n);function n(e,a,s){var i,o=arguments.length>3&&void 0!==arguments[3]?arguments[3]:"";return r(this,n),(i=t.call(this))._iid=e,i.code=a,i.payload=s,i.requestId=s?s.req_id:o,i}return s(n,[{key:"convertToMessage",value:function(){return"".concat(this.code).concat(JSON.stringify(this.payload),"\n")}},{key:"as",value:function(e){return new e(this._iid,this.code,this.payload)}}],[{key:"createFromRawMessage",value:function(e,t){var r=t.substring(0,4),a=null;try{a=JSON.parse(t.substring(4))}catch(e){r="NOOP"}finally{return new n(e,r,a)}}}]),n}($),he=function(){};function de(e){let t=e.length;for(;--t>=0;)e[t]=0}const fe=256,pe=286,ve=30,_e=15,me=new Uint8Array([0,0,0,0,0,0,0,0,1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4,5,5,5,5,0]),ge=new Uint8Array([0,0,0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9,9,10,10,11,11,12,12,13,13]),ye=new Uint8Array([0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,3,7]),ke=new Uint8Array([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),be=new Array(576);de(be);const Ee=new Array(60);de(Ee);const we=new Array(512);de(we);const Ce=new Array(256);de(Ce);const xe=new Array(29);de(xe);const Te=new Array(ve);function Se(e,t,n,r,a){this.static_tree=e,this.extra_bits=t,this.extra_base=n,this.elems=r,this.max_length=a,this.has_stree=e&&e.length}let Ie,Ne,Ae;function Me(e,t){this.dyn_tree=e,this.max_code=0,this.stat_desc=t}de(Te);const Oe=e=>e<256?we[e]:we[256+(e>>>7)],Ue=(e,t)=>{e.pending_buf[e.pending++]=255&t,e.pending_buf[e.pending++]=t>>>8&255},Re=(e,t,n)=>{e.bi_valid>16-n?(e.bi_buf|=t<>16-e.bi_valid,e.bi_valid+=n-16):(e.bi_buf|=t<{Re(e,n[2*t],n[2*t+1])},De=(e,t)=>{let n=0;do{n|=1&e,e>>>=1,n<<=1}while(--t>0);return n>>>1},Pe=(e,t,n)=>{const r=new Array(16);let a,s,i=0;for(a=1;a<=_e;a++)i=i+n[a-1]<<1,r[a]=i;for(s=0;s<=t;s++){let t=e[2*s+1];0!==t&&(e[2*s]=De(r[t]++,t))}},Fe=e=>{let t;for(t=0;t{e.bi_valid>8?Ue(e,e.bi_buf):e.bi_valid>0&&(e.pending_buf[e.pending++]=e.bi_buf),e.bi_buf=0,e.bi_valid=0},He=(e,t,n,r)=>{const a=2*t,s=2*n;return e[a]{const r=e.heap[n];let a=n<<1;for(;a<=e.heap_len&&(a{let r,a,s,i,o=0;if(0!==e.sym_next)do{r=255&e.pending_buf[e.sym_buf+o++],r+=(255&e.pending_buf[e.sym_buf+o++])<<8,a=e.pending_buf[e.sym_buf+o++],0===r?Le(e,a,t):(s=Ce[a],Le(e,s+fe+1,t),i=me[s],0!==i&&(a-=xe[s],Re(e,a,i)),r--,s=Oe(r),Le(e,s,n),i=ge[s],0!==i&&(r-=Te[s],Re(e,r,i)))}while(o{const n=t.dyn_tree,r=t.stat_desc.static_tree,a=t.stat_desc.has_stree,s=t.stat_desc.elems;let i,o,u,c=-1;for(e.heap_len=0,e.heap_max=573,i=0;i>1;i>=1;i--)qe(e,n,i);u=s;do{i=e.heap[1],e.heap[1]=e.heap[e.heap_len--],qe(e,n,1),o=e.heap[1],e.heap[--e.heap_max]=i,e.heap[--e.heap_max]=o,n[2*u]=n[2*i]+n[2*o],e.depth[u]=(e.depth[i]>=e.depth[o]?e.depth[i]:e.depth[o])+1,n[2*i+1]=n[2*o+1]=u,e.heap[1]=u++,qe(e,n,1)}while(e.heap_len>=2);e.heap[--e.heap_max]=e.heap[1],((e,t)=>{const n=t.dyn_tree,r=t.max_code,a=t.stat_desc.static_tree,s=t.stat_desc.has_stree,i=t.stat_desc.extra_bits,o=t.stat_desc.extra_base,u=t.stat_desc.max_length;let c,l,h,d,f,p,v=0;for(d=0;d<=_e;d++)e.bl_count[d]=0;for(n[2*e.heap[e.heap_max]+1]=0,c=e.heap_max+1;c<573;c++)l=e.heap[c],d=n[2*n[2*l+1]+1]+1,d>u&&(d=u,v++),n[2*l+1]=d,l>r||(e.bl_count[d]++,f=0,l>=o&&(f=i[l-o]),p=n[2*l],e.opt_len+=p*(d+f),s&&(e.static_len+=p*(a[2*l+1]+f)));if(0!==v){do{for(d=u-1;0===e.bl_count[d];)d--;e.bl_count[d]--,e.bl_count[d+1]+=2,e.bl_count[u]--,v-=2}while(v>0);for(d=u;0!==d;d--)for(l=e.bl_count[d];0!==l;)h=e.heap[--c],h>r||(n[2*h+1]!==d&&(e.opt_len+=(d-n[2*h+1])*n[2*h],n[2*h+1]=d),l--)}})(e,t),Pe(n,c,e.bl_count)},Ve=(e,t,n)=>{let r,a,s=-1,i=t[1],o=0,u=7,c=4;for(0===i&&(u=138,c=3),t[2*(n+1)+1]=65535,r=0;r<=n;r++)a=i,i=t[2*(r+1)+1],++o{let r,a,s=-1,i=t[1],o=0,u=7,c=4;for(0===i&&(u=138,c=3),r=0;r<=n;r++)if(a=i,i=t[2*(r+1)+1],!(++o{Re(e,0+(r?1:0),3),Ge(e),Ue(e,n),Ue(e,~n),n&&e.pending_buf.set(e.window.subarray(t,t+n),e.pending),e.pending+=n};var We=(e,t,n,r)=>{let a,s,i=0;e.level>0?(2===e.strm.data_type&&(e.strm.data_type=(e=>{let t,n=4093624447;for(t=0;t<=31;t++,n>>>=1)if(1&n&&0!==e.dyn_ltree[2*t])return 0;if(0!==e.dyn_ltree[18]||0!==e.dyn_ltree[20]||0!==e.dyn_ltree[26])return 1;for(t=32;t{let t;for(Ve(e,e.dyn_ltree,e.l_desc.max_code),Ve(e,e.dyn_dtree,e.d_desc.max_code),ze(e,e.bl_desc),t=18;t>=3&&0===e.bl_tree[2*ke[t]+1];t--);return e.opt_len+=3*(t+1)+5+5+4,t})(e),a=e.opt_len+3+7>>>3,s=e.static_len+3+7>>>3,s<=a&&(a=s)):a=s=n+5,n+4<=a&&-1!==t?Ke(e,t,n,r):4===e.strategy||s===a?(Re(e,2+(r?1:0),3),je(e,be,Ee)):(Re(e,4+(r?1:0),3),((e,t,n,r)=>{let a;for(Re(e,t-257,5),Re(e,n-1,5),Re(e,r-4,4),a=0;a{Qe||((()=>{let e,t,n,r,a;const s=new Array(16);for(n=0,r=0;r<28;r++)for(xe[r]=n,e=0;e<1<>=7;r(e.pending_buf[e.sym_buf+e.sym_next++]=t,e.pending_buf[e.sym_buf+e.sym_next++]=t>>8,e.pending_buf[e.sym_buf+e.sym_next++]=n,0===t?e.dyn_ltree[2*n]++:(e.matches++,t--,e.dyn_ltree[2*(Ce[n]+fe+1)]++,e.dyn_dtree[2*Oe(t)]++),e.sym_next===e.sym_end),_tr_align:e=>{Re(e,2,3),Le(e,256,be),(e=>{16===e.bi_valid?(Ue(e,e.bi_buf),e.bi_buf=0,e.bi_valid=0):e.bi_valid>=8&&(e.pending_buf[e.pending++]=255&e.bi_buf,e.bi_buf>>=8,e.bi_valid-=8)})(e)}};var Ze=(e,t,n,r)=>{let a=65535&e|0,s=e>>>16&65535|0,i=0;for(;0!==n;){i=n>2e3?2e3:n,n-=i;do{a=a+t[r++]|0,s=s+a|0}while(--i);a%=65521,s%=65521}return a|s<<16|0};const Je=new Uint32Array((()=>{let e,t=[];for(var n=0;n<256;n++){e=n;for(var r=0;r<8;r++)e=1&e?3988292384^e>>>1:e>>>1;t[n]=e}return t})());var Xe=(e,t,n,r)=>{const a=Je,s=r+n;e^=-1;for(let n=r;n>>8^a[255&(e^t[n])];return-1^e},$e={2:"need dictionary",1:"stream end",0:"","-1":"file error","-2":"stream error","-3":"data error","-4":"insufficient memory","-5":"buffer error","-6":"incompatible version"},et={Z_NO_FLUSH:0,Z_PARTIAL_FLUSH:1,Z_SYNC_FLUSH:2,Z_FULL_FLUSH:3,Z_FINISH:4,Z_BLOCK:5,Z_TREES:6,Z_OK:0,Z_STREAM_END:1,Z_NEED_DICT:2,Z_ERRNO:-1,Z_STREAM_ERROR:-2,Z_DATA_ERROR:-3,Z_MEM_ERROR:-4,Z_BUF_ERROR:-5,Z_NO_COMPRESSION:0,Z_BEST_SPEED:1,Z_BEST_COMPRESSION:9,Z_DEFAULT_COMPRESSION:-1,Z_FILTERED:1,Z_HUFFMAN_ONLY:2,Z_RLE:3,Z_FIXED:4,Z_DEFAULT_STRATEGY:0,Z_BINARY:0,Z_TEXT:1,Z_UNKNOWN:2,Z_DEFLATED:8};const{_tr_init:tt,_tr_stored_block:nt,_tr_flush_block:rt,_tr_tally:at,_tr_align:st}=Ye,{Z_NO_FLUSH:it,Z_PARTIAL_FLUSH:ot,Z_FULL_FLUSH:ut,Z_FINISH:ct,Z_BLOCK:lt,Z_OK:ht,Z_STREAM_END:dt,Z_STREAM_ERROR:ft,Z_DATA_ERROR:pt,Z_BUF_ERROR:vt,Z_DEFAULT_COMPRESSION:_t,Z_FILTERED:mt,Z_HUFFMAN_ONLY:gt,Z_RLE:yt,Z_FIXED:kt,Z_DEFAULT_STRATEGY:bt,Z_UNKNOWN:Et,Z_DEFLATED:wt}=et,Ct=258,xt=262,Tt=42,St=113,It=666,Nt=(e,t)=>(e.msg=$e[t],t),At=e=>2*e-(e>4?9:0),Mt=e=>{let t=e.length;for(;--t>=0;)e[t]=0},Ot=e=>{let t,n,r,a=e.w_size;t=e.hash_size,r=t;do{n=e.head[--r],e.head[r]=n>=a?n-a:0}while(--t);t=a,r=t;do{n=e.prev[--r],e.prev[r]=n>=a?n-a:0}while(--t)};let Ut=(e,t,n)=>(t<{const t=e.state;let n=t.pending;n>e.avail_out&&(n=e.avail_out),0!==n&&(e.output.set(t.pending_buf.subarray(t.pending_out,t.pending_out+n),e.next_out),e.next_out+=n,t.pending_out+=n,e.total_out+=n,e.avail_out-=n,t.pending-=n,0===t.pending&&(t.pending_out=0))},Lt=(e,t)=>{rt(e,e.block_start>=0?e.block_start:-1,e.strstart-e.block_start,t),e.block_start=e.strstart,Rt(e.strm)},Dt=(e,t)=>{e.pending_buf[e.pending++]=t},Pt=(e,t)=>{e.pending_buf[e.pending++]=t>>>8&255,e.pending_buf[e.pending++]=255&t},Ft=(e,t,n,r)=>{let a=e.avail_in;return a>r&&(a=r),0===a?0:(e.avail_in-=a,t.set(e.input.subarray(e.next_in,e.next_in+a),n),1===e.state.wrap?e.adler=Ze(e.adler,t,a,n):2===e.state.wrap&&(e.adler=Xe(e.adler,t,a,n)),e.next_in+=a,e.total_in+=a,a)},Gt=(e,t)=>{let n,r,a=e.max_chain_length,s=e.strstart,i=e.prev_length,o=e.nice_match;const u=e.strstart>e.w_size-xt?e.strstart-(e.w_size-xt):0,c=e.window,l=e.w_mask,h=e.prev,d=e.strstart+Ct;let f=c[s+i-1],p=c[s+i];e.prev_length>=e.good_match&&(a>>=2),o>e.lookahead&&(o=e.lookahead);do{if(n=t,c[n+i]===p&&c[n+i-1]===f&&c[n]===c[s]&&c[++n]===c[s+1]){s+=2,n++;do{}while(c[++s]===c[++n]&&c[++s]===c[++n]&&c[++s]===c[++n]&&c[++s]===c[++n]&&c[++s]===c[++n]&&c[++s]===c[++n]&&c[++s]===c[++n]&&c[++s]===c[++n]&&si){if(e.match_start=t,i=r,r>=o)break;f=c[s+i-1],p=c[s+i]}}}while((t=h[t&l])>u&&0!=--a);return i<=e.lookahead?i:e.lookahead},Ht=e=>{const t=e.w_size;let n,r,a;do{if(r=e.window_size-e.lookahead-e.strstart,e.strstart>=t+(t-xt)&&(e.window.set(e.window.subarray(t,t+t-r),0),e.match_start-=t,e.strstart-=t,e.block_start-=t,e.insert>e.strstart&&(e.insert=e.strstart),Ot(e),r+=t),0===e.strm.avail_in)break;if(n=Ft(e.strm,e.window,e.strstart+e.lookahead,r),e.lookahead+=n,e.lookahead+e.insert>=3)for(a=e.strstart-e.insert,e.ins_h=e.window[a],e.ins_h=Ut(e,e.ins_h,e.window[a+1]);e.insert&&(e.ins_h=Ut(e,e.ins_h,e.window[a+3-1]),e.prev[a&e.w_mask]=e.head[e.ins_h],e.head[e.ins_h]=a,a++,e.insert--,!(e.lookahead+e.insert<3)););}while(e.lookahead{let n,r,a,s=e.pending_buf_size-5>e.w_size?e.w_size:e.pending_buf_size-5,i=0,o=e.strm.avail_in;do{if(n=65535,a=e.bi_valid+42>>3,e.strm.avail_outr+e.strm.avail_in&&(n=r+e.strm.avail_in),n>a&&(n=a),n>8,e.pending_buf[e.pending-2]=~n,e.pending_buf[e.pending-1]=~n>>8,Rt(e.strm),r&&(r>n&&(r=n),e.strm.output.set(e.window.subarray(e.block_start,e.block_start+r),e.strm.next_out),e.strm.next_out+=r,e.strm.avail_out-=r,e.strm.total_out+=r,e.block_start+=r,n-=r),n&&(Ft(e.strm,e.strm.output,e.strm.next_out,n),e.strm.next_out+=n,e.strm.avail_out-=n,e.strm.total_out+=n)}while(0===i);return o-=e.strm.avail_in,o&&(o>=e.w_size?(e.matches=2,e.window.set(e.strm.input.subarray(e.strm.next_in-e.w_size,e.strm.next_in),0),e.strstart=e.w_size,e.insert=e.strstart):(e.window_size-e.strstart<=o&&(e.strstart-=e.w_size,e.window.set(e.window.subarray(e.w_size,e.w_size+e.strstart),0),e.matches<2&&e.matches++,e.insert>e.strstart&&(e.insert=e.strstart)),e.window.set(e.strm.input.subarray(e.strm.next_in-o,e.strm.next_in),e.strstart),e.strstart+=o,e.insert+=o>e.w_size-e.insert?e.w_size-e.insert:o),e.block_start=e.strstart),e.high_watera&&e.block_start>=e.w_size&&(e.block_start-=e.w_size,e.strstart-=e.w_size,e.window.set(e.window.subarray(e.w_size,e.w_size+e.strstart),0),e.matches<2&&e.matches++,a+=e.w_size,e.insert>e.strstart&&(e.insert=e.strstart)),a>e.strm.avail_in&&(a=e.strm.avail_in),a&&(Ft(e.strm,e.window,e.strstart,a),e.strstart+=a,e.insert+=a>e.w_size-e.insert?e.w_size-e.insert:a),e.high_water>3,a=e.pending_buf_size-a>65535?65535:e.pending_buf_size-a,s=a>e.w_size?e.w_size:a,r=e.strstart-e.block_start,(r>=s||(r||t===ct)&&t!==it&&0===e.strm.avail_in&&r<=a)&&(n=r>a?a:r,i=t===ct&&0===e.strm.avail_in&&n===r?1:0,nt(e,e.block_start,n,i),e.block_start+=n,Rt(e.strm)),i?3:1)},jt=(e,t)=>{let n,r;for(;;){if(e.lookahead=3&&(e.ins_h=Ut(e,e.ins_h,e.window[e.strstart+3-1]),n=e.prev[e.strstart&e.w_mask]=e.head[e.ins_h],e.head[e.ins_h]=e.strstart),0!==n&&e.strstart-n<=e.w_size-xt&&(e.match_length=Gt(e,n)),e.match_length>=3)if(r=at(e,e.strstart-e.match_start,e.match_length-3),e.lookahead-=e.match_length,e.match_length<=e.max_lazy_match&&e.lookahead>=3){e.match_length--;do{e.strstart++,e.ins_h=Ut(e,e.ins_h,e.window[e.strstart+3-1]),n=e.prev[e.strstart&e.w_mask]=e.head[e.ins_h],e.head[e.ins_h]=e.strstart}while(0!=--e.match_length);e.strstart++}else e.strstart+=e.match_length,e.match_length=0,e.ins_h=e.window[e.strstart],e.ins_h=Ut(e,e.ins_h,e.window[e.strstart+1]);else r=at(e,0,e.window[e.strstart]),e.lookahead--,e.strstart++;if(r&&(Lt(e,!1),0===e.strm.avail_out))return 1}return e.insert=e.strstart<2?e.strstart:2,t===ct?(Lt(e,!0),0===e.strm.avail_out?3:4):e.sym_next&&(Lt(e,!1),0===e.strm.avail_out)?1:2},zt=(e,t)=>{let n,r,a;for(;;){if(e.lookahead=3&&(e.ins_h=Ut(e,e.ins_h,e.window[e.strstart+3-1]),n=e.prev[e.strstart&e.w_mask]=e.head[e.ins_h],e.head[e.ins_h]=e.strstart),e.prev_length=e.match_length,e.prev_match=e.match_start,e.match_length=2,0!==n&&e.prev_length4096)&&(e.match_length=2)),e.prev_length>=3&&e.match_length<=e.prev_length){a=e.strstart+e.lookahead-3,r=at(e,e.strstart-1-e.prev_match,e.prev_length-3),e.lookahead-=e.prev_length-1,e.prev_length-=2;do{++e.strstart<=a&&(e.ins_h=Ut(e,e.ins_h,e.window[e.strstart+3-1]),n=e.prev[e.strstart&e.w_mask]=e.head[e.ins_h],e.head[e.ins_h]=e.strstart)}while(0!=--e.prev_length);if(e.match_available=0,e.match_length=2,e.strstart++,r&&(Lt(e,!1),0===e.strm.avail_out))return 1}else if(e.match_available){if(r=at(e,0,e.window[e.strstart-1]),r&&Lt(e,!1),e.strstart++,e.lookahead--,0===e.strm.avail_out)return 1}else e.match_available=1,e.strstart++,e.lookahead--}return e.match_available&&(r=at(e,0,e.window[e.strstart-1]),e.match_available=0),e.insert=e.strstart<2?e.strstart:2,t===ct?(Lt(e,!0),0===e.strm.avail_out?3:4):e.sym_next&&(Lt(e,!1),0===e.strm.avail_out)?1:2};function Vt(e,t,n,r,a){this.good_length=e,this.max_lazy=t,this.nice_length=n,this.max_chain=r,this.func=a}const Bt=[new Vt(0,0,0,0,qt),new Vt(4,4,8,4,jt),new Vt(4,5,16,8,jt),new Vt(4,6,32,32,jt),new Vt(4,4,16,16,zt),new Vt(8,16,32,32,zt),new Vt(8,16,128,128,zt),new Vt(8,32,128,256,zt),new Vt(32,128,258,1024,zt),new Vt(32,258,258,4096,zt)];function Qt(){this.strm=null,this.status=0,this.pending_buf=null,this.pending_buf_size=0,this.pending_out=0,this.pending=0,this.wrap=0,this.gzhead=null,this.gzindex=0,this.method=wt,this.last_flush=-1,this.w_size=0,this.w_bits=0,this.w_mask=0,this.window=null,this.window_size=0,this.prev=null,this.head=null,this.ins_h=0,this.hash_size=0,this.hash_bits=0,this.hash_mask=0,this.hash_shift=0,this.block_start=0,this.match_length=0,this.prev_match=0,this.match_available=0,this.strstart=0,this.match_start=0,this.lookahead=0,this.prev_length=0,this.max_chain_length=0,this.max_lazy_match=0,this.level=0,this.strategy=0,this.good_match=0,this.nice_match=0,this.dyn_ltree=new Uint16Array(1146),this.dyn_dtree=new Uint16Array(122),this.bl_tree=new Uint16Array(78),Mt(this.dyn_ltree),Mt(this.dyn_dtree),Mt(this.bl_tree),this.l_desc=null,this.d_desc=null,this.bl_desc=null,this.bl_count=new Uint16Array(16),this.heap=new Uint16Array(573),Mt(this.heap),this.heap_len=0,this.heap_max=0,this.depth=new Uint16Array(573),Mt(this.depth),this.sym_buf=0,this.lit_bufsize=0,this.sym_next=0,this.sym_end=0,this.opt_len=0,this.static_len=0,this.matches=0,this.insert=0,this.bi_buf=0,this.bi_valid=0}const Kt=e=>{if(!e)return 1;const t=e.state;return!t||t.strm!==e||t.status!==Tt&&57!==t.status&&69!==t.status&&73!==t.status&&91!==t.status&&103!==t.status&&t.status!==St&&t.status!==It?1:0},Wt=e=>{if(Kt(e))return Nt(e,ft);e.total_in=e.total_out=0,e.data_type=Et;const t=e.state;return t.pending=0,t.pending_out=0,t.wrap<0&&(t.wrap=-t.wrap),t.status=2===t.wrap?57:t.wrap?Tt:St,e.adler=2===t.wrap?0:1,t.last_flush=-2,tt(t),ht},Yt=e=>{const t=Wt(e);var n;return t===ht&&((n=e.state).window_size=2*n.w_size,Mt(n.head),n.max_lazy_match=Bt[n.level].max_lazy,n.good_match=Bt[n.level].good_length,n.nice_match=Bt[n.level].nice_length,n.max_chain_length=Bt[n.level].max_chain,n.strstart=0,n.block_start=0,n.lookahead=0,n.insert=0,n.match_length=n.prev_length=2,n.match_available=0,n.ins_h=0),t},Zt=(e,t,n,r,a,s)=>{if(!e)return ft;let i=1;if(t===_t&&(t=6),r<0?(i=0,r=-r):r>15&&(i=2,r-=16),a<1||a>9||n!==wt||r<8||r>15||t<0||t>9||s<0||s>kt||8===r&&1!==i)return Nt(e,ft);8===r&&(r=9);const o=new Qt;return e.state=o,o.strm=e,o.status=Tt,o.wrap=i,o.gzhead=null,o.w_bits=r,o.w_size=1<Zt(e,t,wt,15,8,bt),deflateInit2:Zt,deflateReset:Yt,deflateResetKeep:Wt,deflateSetHeader:(e,t)=>Kt(e)||2!==e.state.wrap?ft:(e.state.gzhead=t,ht),deflate:(e,t)=>{if(Kt(e)||t>lt||t<0)return e?Nt(e,ft):ft;const n=e.state;if(!e.output||0!==e.avail_in&&!e.input||n.status===It&&t!==ct)return Nt(e,0===e.avail_out?vt:ft);const r=n.last_flush;if(n.last_flush=t,0!==n.pending){if(Rt(e),0===e.avail_out)return n.last_flush=-1,ht}else if(0===e.avail_in&&At(t)<=At(r)&&t!==ct)return Nt(e,vt);if(n.status===It&&0!==e.avail_in)return Nt(e,vt);if(n.status===Tt&&0===n.wrap&&(n.status=St),n.status===Tt){let t=wt+(n.w_bits-8<<4)<<8,r=-1;if(r=n.strategy>=gt||n.level<2?0:n.level<6?1:6===n.level?2:3,t|=r<<6,0!==n.strstart&&(t|=32),t+=31-t%31,Pt(n,t),0!==n.strstart&&(Pt(n,e.adler>>>16),Pt(n,65535&e.adler)),e.adler=1,n.status=St,Rt(e),0!==n.pending)return n.last_flush=-1,ht}if(57===n.status)if(e.adler=0,Dt(n,31),Dt(n,139),Dt(n,8),n.gzhead)Dt(n,(n.gzhead.text?1:0)+(n.gzhead.hcrc?2:0)+(n.gzhead.extra?4:0)+(n.gzhead.name?8:0)+(n.gzhead.comment?16:0)),Dt(n,255&n.gzhead.time),Dt(n,n.gzhead.time>>8&255),Dt(n,n.gzhead.time>>16&255),Dt(n,n.gzhead.time>>24&255),Dt(n,9===n.level?2:n.strategy>=gt||n.level<2?4:0),Dt(n,255&n.gzhead.os),n.gzhead.extra&&n.gzhead.extra.length&&(Dt(n,255&n.gzhead.extra.length),Dt(n,n.gzhead.extra.length>>8&255)),n.gzhead.hcrc&&(e.adler=Xe(e.adler,n.pending_buf,n.pending,0)),n.gzindex=0,n.status=69;else if(Dt(n,0),Dt(n,0),Dt(n,0),Dt(n,0),Dt(n,0),Dt(n,9===n.level?2:n.strategy>=gt||n.level<2?4:0),Dt(n,3),n.status=St,Rt(e),0!==n.pending)return n.last_flush=-1,ht;if(69===n.status){if(n.gzhead.extra){let t=n.pending,r=(65535&n.gzhead.extra.length)-n.gzindex;for(;n.pending+r>n.pending_buf_size;){let a=n.pending_buf_size-n.pending;if(n.pending_buf.set(n.gzhead.extra.subarray(n.gzindex,n.gzindex+a),n.pending),n.pending=n.pending_buf_size,n.gzhead.hcrc&&n.pending>t&&(e.adler=Xe(e.adler,n.pending_buf,n.pending-t,t)),n.gzindex+=a,Rt(e),0!==n.pending)return n.last_flush=-1,ht;t=0,r-=a}let a=new Uint8Array(n.gzhead.extra);n.pending_buf.set(a.subarray(n.gzindex,n.gzindex+r),n.pending),n.pending+=r,n.gzhead.hcrc&&n.pending>t&&(e.adler=Xe(e.adler,n.pending_buf,n.pending-t,t)),n.gzindex=0}n.status=73}if(73===n.status){if(n.gzhead.name){let t,r=n.pending;do{if(n.pending===n.pending_buf_size){if(n.gzhead.hcrc&&n.pending>r&&(e.adler=Xe(e.adler,n.pending_buf,n.pending-r,r)),Rt(e),0!==n.pending)return n.last_flush=-1,ht;r=0}t=n.gzindexr&&(e.adler=Xe(e.adler,n.pending_buf,n.pending-r,r)),n.gzindex=0}n.status=91}if(91===n.status){if(n.gzhead.comment){let t,r=n.pending;do{if(n.pending===n.pending_buf_size){if(n.gzhead.hcrc&&n.pending>r&&(e.adler=Xe(e.adler,n.pending_buf,n.pending-r,r)),Rt(e),0!==n.pending)return n.last_flush=-1,ht;r=0}t=n.gzindexr&&(e.adler=Xe(e.adler,n.pending_buf,n.pending-r,r))}n.status=103}if(103===n.status){if(n.gzhead.hcrc){if(n.pending+2>n.pending_buf_size&&(Rt(e),0!==n.pending))return n.last_flush=-1,ht;Dt(n,255&e.adler),Dt(n,e.adler>>8&255),e.adler=0}if(n.status=St,Rt(e),0!==n.pending)return n.last_flush=-1,ht}if(0!==e.avail_in||0!==n.lookahead||t!==it&&n.status!==It){let r=0===n.level?qt(n,t):n.strategy===gt?((e,t)=>{let n;for(;;){if(0===e.lookahead&&(Ht(e),0===e.lookahead)){if(t===it)return 1;break}if(e.match_length=0,n=at(e,0,e.window[e.strstart]),e.lookahead--,e.strstart++,n&&(Lt(e,!1),0===e.strm.avail_out))return 1}return e.insert=0,t===ct?(Lt(e,!0),0===e.strm.avail_out?3:4):e.sym_next&&(Lt(e,!1),0===e.strm.avail_out)?1:2})(n,t):n.strategy===yt?((e,t)=>{let n,r,a,s;const i=e.window;for(;;){if(e.lookahead<=Ct){if(Ht(e),e.lookahead<=Ct&&t===it)return 1;if(0===e.lookahead)break}if(e.match_length=0,e.lookahead>=3&&e.strstart>0&&(a=e.strstart-1,r=i[a],r===i[++a]&&r===i[++a]&&r===i[++a])){s=e.strstart+Ct;do{}while(r===i[++a]&&r===i[++a]&&r===i[++a]&&r===i[++a]&&r===i[++a]&&r===i[++a]&&r===i[++a]&&r===i[++a]&&ae.lookahead&&(e.match_length=e.lookahead)}if(e.match_length>=3?(n=at(e,1,e.match_length-3),e.lookahead-=e.match_length,e.strstart+=e.match_length,e.match_length=0):(n=at(e,0,e.window[e.strstart]),e.lookahead--,e.strstart++),n&&(Lt(e,!1),0===e.strm.avail_out))return 1}return e.insert=0,t===ct?(Lt(e,!0),0===e.strm.avail_out?3:4):e.sym_next&&(Lt(e,!1),0===e.strm.avail_out)?1:2})(n,t):Bt[n.level].func(n,t);if(3!==r&&4!==r||(n.status=It),1===r||3===r)return 0===e.avail_out&&(n.last_flush=-1),ht;if(2===r&&(t===ot?st(n):t!==lt&&(nt(n,0,0,!1),t===ut&&(Mt(n.head),0===n.lookahead&&(n.strstart=0,n.block_start=0,n.insert=0))),Rt(e),0===e.avail_out))return n.last_flush=-1,ht}return t!==ct?ht:n.wrap<=0?dt:(2===n.wrap?(Dt(n,255&e.adler),Dt(n,e.adler>>8&255),Dt(n,e.adler>>16&255),Dt(n,e.adler>>24&255),Dt(n,255&e.total_in),Dt(n,e.total_in>>8&255),Dt(n,e.total_in>>16&255),Dt(n,e.total_in>>24&255)):(Pt(n,e.adler>>>16),Pt(n,65535&e.adler)),Rt(e),n.wrap>0&&(n.wrap=-n.wrap),0!==n.pending?ht:dt)},deflateEnd:e=>{if(Kt(e))return ft;const t=e.state.status;return e.state=null,t===St?Nt(e,pt):ht},deflateSetDictionary:(e,t)=>{let n=t.length;if(Kt(e))return ft;const r=e.state,a=r.wrap;if(2===a||1===a&&r.status!==Tt||r.lookahead)return ft;if(1===a&&(e.adler=Ze(e.adler,t,n,0)),r.wrap=0,n>=r.w_size){0===a&&(Mt(r.head),r.strstart=0,r.block_start=0,r.insert=0);let e=new Uint8Array(r.w_size);e.set(t.subarray(n-r.w_size,n),0),t=e,n=r.w_size}const s=e.avail_in,i=e.next_in,o=e.input;for(e.avail_in=n,e.next_in=0,e.input=t,Ht(r);r.lookahead>=3;){let e=r.strstart,t=r.lookahead-2;do{r.ins_h=Ut(r,r.ins_h,r.window[e+3-1]),r.prev[e&r.w_mask]=r.head[r.ins_h],r.head[r.ins_h]=e,e++}while(--t);r.strstart=e,r.lookahead=2,Ht(r)}return r.strstart+=r.lookahead,r.block_start=r.strstart,r.insert=r.lookahead,r.lookahead=0,r.match_length=r.prev_length=2,r.match_available=0,e.next_in=i,e.input=o,e.avail_in=s,r.wrap=a,ht},deflateInfo:"pako deflate (from Nodeca project)"};const Xt=(e,t)=>Object.prototype.hasOwnProperty.call(e,t);var $t={assign:function(e){const t=Array.prototype.slice.call(arguments,1);for(;t.length;){const n=t.shift();if(n){if("object"!=typeof n)throw new TypeError(n+"must be non-object");for(const t in n)Xt(n,t)&&(e[t]=n[t])}}return e},flattenChunks:e=>{let t=0;for(let n=0,r=e.length;n=252?6:e>=248?5:e>=240?4:e>=224?3:e>=192?2:1;tn[254]=tn[254]=1;var nn={string2buf:e=>{if("function"==typeof TextEncoder&&TextEncoder.prototype.encode)return(new TextEncoder).encode(e);let t,n,r,a,s,i=e.length,o=0;for(a=0;a>>6,t[s++]=128|63&n):n<65536?(t[s++]=224|n>>>12,t[s++]=128|n>>>6&63,t[s++]=128|63&n):(t[s++]=240|n>>>18,t[s++]=128|n>>>12&63,t[s++]=128|n>>>6&63,t[s++]=128|63&n);return t},buf2string:(e,t)=>{const n=t||e.length;if("function"==typeof TextDecoder&&TextDecoder.prototype.decode)return(new TextDecoder).decode(e.subarray(0,t));let r,a;const s=new Array(2*n);for(a=0,r=0;r4)s[a++]=65533,r+=i-1;else{for(t&=2===i?31:3===i?15:7;i>1&&r1?s[a++]=65533:t<65536?s[a++]=t:(t-=65536,s[a++]=55296|t>>10&1023,s[a++]=56320|1023&t)}}return((e,t)=>{if(t<65534&&e.subarray&&en)return String.fromCharCode.apply(null,e.length===t?e:e.subarray(0,t));let n="";for(let r=0;r{(t=t||e.length)>e.length&&(t=e.length);let n=t-1;for(;n>=0&&128==(192&e[n]);)n--;return n<0||0===n?t:n+tn[e[n]]>t?n:t}};var rn=function(){this.input=null,this.next_in=0,this.avail_in=0,this.total_in=0,this.output=null,this.next_out=0,this.avail_out=0,this.total_out=0,this.msg="",this.state=null,this.data_type=2,this.adler=0};const an=Object.prototype.toString,{Z_NO_FLUSH:sn,Z_SYNC_FLUSH:on,Z_FULL_FLUSH:un,Z_FINISH:cn,Z_OK:ln,Z_STREAM_END:hn,Z_DEFAULT_COMPRESSION:dn,Z_DEFAULT_STRATEGY:fn,Z_DEFLATED:pn}=et;function vn(e){this.options=$t.assign({level:dn,method:pn,chunkSize:16384,windowBits:15,memLevel:8,strategy:fn},e||{});let t=this.options;t.raw&&t.windowBits>0?t.windowBits=-t.windowBits:t.gzip&&t.windowBits>0&&t.windowBits<16&&(t.windowBits+=16),this.err=0,this.msg="",this.ended=!1,this.chunks=[],this.strm=new rn,this.strm.avail_out=0;let n=Jt.deflateInit2(this.strm,t.level,t.method,t.windowBits,t.memLevel,t.strategy);if(n!==ln)throw new Error($e[n]);if(t.header&&Jt.deflateSetHeader(this.strm,t.header),t.dictionary){let e;if(e="string"==typeof t.dictionary?nn.string2buf(t.dictionary):"[object ArrayBuffer]"===an.call(t.dictionary)?new Uint8Array(t.dictionary):t.dictionary,n=Jt.deflateSetDictionary(this.strm,e),n!==ln)throw new Error($e[n]);this._dict_set=!0}}function _n(e,t){const n=new vn(t);if(n.push(e,!0),n.err)throw n.msg||$e[n.err];return n.result}vn.prototype.push=function(e,t){const n=this.strm,r=this.options.chunkSize;let a,s;if(this.ended)return!1;for(s=t===~~t?t:!0===t?cn:sn,"string"==typeof e?n.input=nn.string2buf(e):"[object ArrayBuffer]"===an.call(e)?n.input=new Uint8Array(e):n.input=e,n.next_in=0,n.avail_in=n.input.length;;)if(0===n.avail_out&&(n.output=new Uint8Array(r),n.next_out=0,n.avail_out=r),(s===on||s===un)&&n.avail_out<=6)this.onData(n.output.subarray(0,n.next_out)),n.avail_out=0;else{if(a=Jt.deflate(n,s),a===hn)return n.next_out>0&&this.onData(n.output.subarray(0,n.next_out)),a=Jt.deflateEnd(this.strm),this.onEnd(a),this.ended=!0,a===ln;if(0!==n.avail_out){if(s>0&&n.next_out>0)this.onData(n.output.subarray(0,n.next_out)),n.avail_out=0;else if(0===n.avail_in)break}else this.onData(n.output)}return!0},vn.prototype.onData=function(e){this.chunks.push(e)},vn.prototype.onEnd=function(e){e===ln&&(this.result=$t.flattenChunks(this.chunks)),this.chunks=[],this.err=e,this.msg=this.strm.msg};var mn={Deflate:vn,deflate:_n,deflateRaw:function(e,t){return(t=t||{}).raw=!0,_n(e,t)},gzip:function(e,t){return(t=t||{}).gzip=!0,_n(e,t)},constants:et};const gn=16209;var yn=function(e,t){let n,r,a,s,i,o,u,c,l,h,d,f,p,v,_,m,g,y,k,b,E,w,C,x;const T=e.state;n=e.next_in,C=e.input,r=n+(e.avail_in-5),a=e.next_out,x=e.output,s=a-(t-e.avail_out),i=a+(e.avail_out-257),o=T.dmax,u=T.wsize,c=T.whave,l=T.wnext,h=T.window,d=T.hold,f=T.bits,p=T.lencode,v=T.distcode,_=(1<>>24,d>>>=y,f-=y,y=g>>>16&255,0===y)x[a++]=65535&g;else{if(!(16&y)){if(0==(64&y)){g=p[(65535&g)+(d&(1<>>=y,f-=y),f<15&&(d+=C[n++]<>>24,d>>>=y,f-=y,y=g>>>16&255,!(16&y)){if(0==(64&y)){g=v[(65535&g)+(d&(1<o){e.msg="invalid distance too far back",T.mode=gn;break e}if(d>>>=y,f-=y,y=a-s,b>y){if(y=b-y,y>c&&T.sane){e.msg="invalid distance too far back",T.mode=gn;break e}if(E=0,w=h,0===l){if(E+=u-y,y2;)x[a++]=w[E++],x[a++]=w[E++],x[a++]=w[E++],k-=3;k&&(x[a++]=w[E++],k>1&&(x[a++]=w[E++]))}else{E=a-b;do{x[a++]=x[E++],x[a++]=x[E++],x[a++]=x[E++],k-=3}while(k>2);k&&(x[a++]=x[E++],k>1&&(x[a++]=x[E++]))}break}}break}}while(n>3,n-=k,f-=k<<3,d&=(1<{const u=o.bits;let c,l,h,d,f,p,v=0,_=0,m=0,g=0,y=0,k=0,b=0,E=0,w=0,C=0,x=null;const T=new Uint16Array(16),S=new Uint16Array(16);let I,N,A,M=null;for(v=0;v<=kn;v++)T[v]=0;for(_=0;_=1&&0===T[g];g--);if(y>g&&(y=g),0===g)return a[s++]=20971520,a[s++]=20971520,o.bits=1,0;for(m=1;m0&&(0===e||1!==g))return-1;for(S[1]=0,v=1;v852||2===e&&w>592)return 1;for(;;){I=v-b,i[_]+1=p?(N=M[i[_]-p],A=x[i[_]-p]):(N=96,A=0),c=1<>b)+l]=I<<24|N<<16|A|0}while(0!==l);for(c=1<>=1;if(0!==c?(C&=c-1,C+=c):C=0,_++,0==--T[v]){if(v===g)break;v=t[n+i[_]]}if(v>y&&(C&d)!==h){for(0===b&&(b=y),f+=m,k=v-b,E=1<852||2===e&&w>592)return 1;h=C&d,a[h]=y<<24|k<<16|f-s|0}}return 0!==C&&(a[f+C]=v-b<<24|64<<16|0),o.bits=y,0};const{Z_FINISH:Tn,Z_BLOCK:Sn,Z_TREES:In,Z_OK:Nn,Z_STREAM_END:An,Z_NEED_DICT:Mn,Z_STREAM_ERROR:On,Z_DATA_ERROR:Un,Z_MEM_ERROR:Rn,Z_BUF_ERROR:Ln,Z_DEFLATED:Dn}=et,Pn=16180,Fn=16190,Gn=16191,Hn=16192,qn=16194,jn=16199,zn=16200,Vn=16206,Bn=16209,Qn=e=>(e>>>24&255)+(e>>>8&65280)+((65280&e)<<8)+((255&e)<<24);function Kn(){this.strm=null,this.mode=0,this.last=!1,this.wrap=0,this.havedict=!1,this.flags=0,this.dmax=0,this.check=0,this.total=0,this.head=null,this.wbits=0,this.wsize=0,this.whave=0,this.wnext=0,this.window=null,this.hold=0,this.bits=0,this.length=0,this.offset=0,this.extra=0,this.lencode=null,this.distcode=null,this.lenbits=0,this.distbits=0,this.ncode=0,this.nlen=0,this.ndist=0,this.have=0,this.next=null,this.lens=new Uint16Array(320),this.work=new Uint16Array(288),this.lendyn=null,this.distdyn=null,this.sane=0,this.back=0,this.was=0}const Wn=e=>{if(!e)return 1;const t=e.state;return!t||t.strm!==e||t.mode16211?1:0},Yn=e=>{if(Wn(e))return On;const t=e.state;return e.total_in=e.total_out=t.total=0,e.msg="",t.wrap&&(e.adler=1&t.wrap),t.mode=Pn,t.last=0,t.havedict=0,t.flags=-1,t.dmax=32768,t.head=null,t.hold=0,t.bits=0,t.lencode=t.lendyn=new Int32Array(852),t.distcode=t.distdyn=new Int32Array(592),t.sane=1,t.back=-1,Nn},Zn=e=>{if(Wn(e))return On;const t=e.state;return t.wsize=0,t.whave=0,t.wnext=0,Yn(e)},Jn=(e,t)=>{let n;if(Wn(e))return On;const r=e.state;return t<0?(n=0,t=-t):(n=5+(t>>4),t<48&&(t&=15)),t&&(t<8||t>15)?On:(null!==r.window&&r.wbits!==t&&(r.window=null),r.wrap=n,r.wbits=t,Zn(e))},Xn=(e,t)=>{if(!e)return On;const n=new Kn;e.state=n,n.strm=e,n.window=null,n.mode=Pn;const r=Jn(e,t);return r!==Nn&&(e.state=null),r};let $n,er,tr=!0;const nr=e=>{if(tr){$n=new Int32Array(512),er=new Int32Array(32);let t=0;for(;t<144;)e.lens[t++]=8;for(;t<256;)e.lens[t++]=9;for(;t<280;)e.lens[t++]=7;for(;t<288;)e.lens[t++]=8;for(xn(1,e.lens,0,288,$n,0,e.work,{bits:9}),t=0;t<32;)e.lens[t++]=5;xn(2,e.lens,0,32,er,0,e.work,{bits:5}),tr=!1}e.lencode=$n,e.lenbits=9,e.distcode=er,e.distbits=5},rr=(e,t,n,r)=>{let a;const s=e.state;return null===s.window&&(s.wsize=1<=s.wsize?(s.window.set(t.subarray(n-s.wsize,n),0),s.wnext=0,s.whave=s.wsize):(a=s.wsize-s.wnext,a>r&&(a=r),s.window.set(t.subarray(n-r,n-r+a),s.wnext),(r-=a)?(s.window.set(t.subarray(n-r,n),0),s.wnext=r,s.whave=s.wsize):(s.wnext+=a,s.wnext===s.wsize&&(s.wnext=0),s.whaveXn(e,15),inflateInit2:Xn,inflate:(e,t)=>{let n,r,a,s,i,o,u,c,l,h,d,f,p,v,_,m,g,y,k,b,E,w,C=0;const x=new Uint8Array(4);let T,S;const I=new Uint8Array([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]);if(Wn(e)||!e.output||!e.input&&0!==e.avail_in)return On;n=e.state,n.mode===Gn&&(n.mode=Hn),i=e.next_out,a=e.output,u=e.avail_out,s=e.next_in,r=e.input,o=e.avail_in,c=n.hold,l=n.bits,h=o,d=u,w=Nn;e:for(;;)switch(n.mode){case Pn:if(0===n.wrap){n.mode=Hn;break}for(;l<16;){if(0===o)break e;o--,c+=r[s++]<>>8&255,n.check=Xe(n.check,x,2,0),c=0,l=0,n.mode=16181;break}if(n.head&&(n.head.done=!1),!(1&n.wrap)||(((255&c)<<8)+(c>>8))%31){e.msg="incorrect header check",n.mode=Bn;break}if((15&c)!==Dn){e.msg="unknown compression method",n.mode=Bn;break}if(c>>>=4,l-=4,E=8+(15&c),0===n.wbits&&(n.wbits=E),E>15||E>n.wbits){e.msg="invalid window size",n.mode=Bn;break}n.dmax=1<>8&1),512&n.flags&&4&n.wrap&&(x[0]=255&c,x[1]=c>>>8&255,n.check=Xe(n.check,x,2,0)),c=0,l=0,n.mode=16182;case 16182:for(;l<32;){if(0===o)break e;o--,c+=r[s++]<>>8&255,x[2]=c>>>16&255,x[3]=c>>>24&255,n.check=Xe(n.check,x,4,0)),c=0,l=0,n.mode=16183;case 16183:for(;l<16;){if(0===o)break e;o--,c+=r[s++]<>8),512&n.flags&&4&n.wrap&&(x[0]=255&c,x[1]=c>>>8&255,n.check=Xe(n.check,x,2,0)),c=0,l=0,n.mode=16184;case 16184:if(1024&n.flags){for(;l<16;){if(0===o)break e;o--,c+=r[s++]<>>8&255,n.check=Xe(n.check,x,2,0)),c=0,l=0}else n.head&&(n.head.extra=null);n.mode=16185;case 16185:if(1024&n.flags&&(f=n.length,f>o&&(f=o),f&&(n.head&&(E=n.head.extra_len-n.length,n.head.extra||(n.head.extra=new Uint8Array(n.head.extra_len)),n.head.extra.set(r.subarray(s,s+f),E)),512&n.flags&&4&n.wrap&&(n.check=Xe(n.check,r,f,s)),o-=f,s+=f,n.length-=f),n.length))break e;n.length=0,n.mode=16186;case 16186:if(2048&n.flags){if(0===o)break e;f=0;do{E=r[s+f++],n.head&&E&&n.length<65536&&(n.head.name+=String.fromCharCode(E))}while(E&&f>9&1,n.head.done=!0),e.adler=n.check=0,n.mode=Gn;break;case 16189:for(;l<32;){if(0===o)break e;o--,c+=r[s++]<>>=7&l,l-=7&l,n.mode=Vn;break}for(;l<3;){if(0===o)break e;o--,c+=r[s++]<>>=1,l-=1,3&c){case 0:n.mode=16193;break;case 1:if(nr(n),n.mode=jn,t===In){c>>>=2,l-=2;break e}break;case 2:n.mode=16196;break;case 3:e.msg="invalid block type",n.mode=Bn}c>>>=2,l-=2;break;case 16193:for(c>>>=7&l,l-=7&l;l<32;){if(0===o)break e;o--,c+=r[s++]<>>16^65535)){e.msg="invalid stored block lengths",n.mode=Bn;break}if(n.length=65535&c,c=0,l=0,n.mode=qn,t===In)break e;case qn:n.mode=16195;case 16195:if(f=n.length,f){if(f>o&&(f=o),f>u&&(f=u),0===f)break e;a.set(r.subarray(s,s+f),i),o-=f,s+=f,u-=f,i+=f,n.length-=f;break}n.mode=Gn;break;case 16196:for(;l<14;){if(0===o)break e;o--,c+=r[s++]<>>=5,l-=5,n.ndist=1+(31&c),c>>>=5,l-=5,n.ncode=4+(15&c),c>>>=4,l-=4,n.nlen>286||n.ndist>30){e.msg="too many length or distance symbols",n.mode=Bn;break}n.have=0,n.mode=16197;case 16197:for(;n.have>>=3,l-=3}for(;n.have<19;)n.lens[I[n.have++]]=0;if(n.lencode=n.lendyn,n.lenbits=7,T={bits:n.lenbits},w=xn(0,n.lens,0,19,n.lencode,0,n.work,T),n.lenbits=T.bits,w){e.msg="invalid code lengths set",n.mode=Bn;break}n.have=0,n.mode=16198;case 16198:for(;n.have>>24,m=C>>>16&255,g=65535&C,!(_<=l);){if(0===o)break e;o--,c+=r[s++]<>>=_,l-=_,n.lens[n.have++]=g;else{if(16===g){for(S=_+2;l>>=_,l-=_,0===n.have){e.msg="invalid bit length repeat",n.mode=Bn;break}E=n.lens[n.have-1],f=3+(3&c),c>>>=2,l-=2}else if(17===g){for(S=_+3;l>>=_,l-=_,E=0,f=3+(7&c),c>>>=3,l-=3}else{for(S=_+7;l>>=_,l-=_,E=0,f=11+(127&c),c>>>=7,l-=7}if(n.have+f>n.nlen+n.ndist){e.msg="invalid bit length repeat",n.mode=Bn;break}for(;f--;)n.lens[n.have++]=E}}if(n.mode===Bn)break;if(0===n.lens[256]){e.msg="invalid code -- missing end-of-block",n.mode=Bn;break}if(n.lenbits=9,T={bits:n.lenbits},w=xn(1,n.lens,0,n.nlen,n.lencode,0,n.work,T),n.lenbits=T.bits,w){e.msg="invalid literal/lengths set",n.mode=Bn;break}if(n.distbits=6,n.distcode=n.distdyn,T={bits:n.distbits},w=xn(2,n.lens,n.nlen,n.ndist,n.distcode,0,n.work,T),n.distbits=T.bits,w){e.msg="invalid distances set",n.mode=Bn;break}if(n.mode=jn,t===In)break e;case jn:n.mode=zn;case zn:if(o>=6&&u>=258){e.next_out=i,e.avail_out=u,e.next_in=s,e.avail_in=o,n.hold=c,n.bits=l,yn(e,d),i=e.next_out,a=e.output,u=e.avail_out,s=e.next_in,r=e.input,o=e.avail_in,c=n.hold,l=n.bits,n.mode===Gn&&(n.back=-1);break}for(n.back=0;C=n.lencode[c&(1<>>24,m=C>>>16&255,g=65535&C,!(_<=l);){if(0===o)break e;o--,c+=r[s++]<>y)],_=C>>>24,m=C>>>16&255,g=65535&C,!(y+_<=l);){if(0===o)break e;o--,c+=r[s++]<>>=y,l-=y,n.back+=y}if(c>>>=_,l-=_,n.back+=_,n.length=g,0===m){n.mode=16205;break}if(32&m){n.back=-1,n.mode=Gn;break}if(64&m){e.msg="invalid literal/length code",n.mode=Bn;break}n.extra=15&m,n.mode=16201;case 16201:if(n.extra){for(S=n.extra;l>>=n.extra,l-=n.extra,n.back+=n.extra}n.was=n.length,n.mode=16202;case 16202:for(;C=n.distcode[c&(1<>>24,m=C>>>16&255,g=65535&C,!(_<=l);){if(0===o)break e;o--,c+=r[s++]<>y)],_=C>>>24,m=C>>>16&255,g=65535&C,!(y+_<=l);){if(0===o)break e;o--,c+=r[s++]<>>=y,l-=y,n.back+=y}if(c>>>=_,l-=_,n.back+=_,64&m){e.msg="invalid distance code",n.mode=Bn;break}n.offset=g,n.extra=15&m,n.mode=16203;case 16203:if(n.extra){for(S=n.extra;l>>=n.extra,l-=n.extra,n.back+=n.extra}if(n.offset>n.dmax){e.msg="invalid distance too far back",n.mode=Bn;break}n.mode=16204;case 16204:if(0===u)break e;if(f=d-u,n.offset>f){if(f=n.offset-f,f>n.whave&&n.sane){e.msg="invalid distance too far back",n.mode=Bn;break}f>n.wnext?(f-=n.wnext,p=n.wsize-f):p=n.wnext-f,f>n.length&&(f=n.length),v=n.window}else v=a,p=i-n.offset,f=n.length;f>u&&(f=u),u-=f,n.length-=f;do{a[i++]=v[p++]}while(--f);0===n.length&&(n.mode=zn);break;case 16205:if(0===u)break e;a[i++]=n.length,u--,n.mode=zn;break;case Vn:if(n.wrap){for(;l<32;){if(0===o)break e;o--,c|=r[s++]<{if(Wn(e))return On;let t=e.state;return t.window&&(t.window=null),e.state=null,Nn},inflateGetHeader:(e,t)=>{if(Wn(e))return On;const n=e.state;return 0==(2&n.wrap)?On:(n.head=t,t.done=!1,Nn)},inflateSetDictionary:(e,t)=>{const n=t.length;let r,a,s;return Wn(e)?On:(r=e.state,0!==r.wrap&&r.mode!==Fn?On:r.mode===Fn&&(a=1,a=Ze(a,t,n,0),a!==r.check)?Un:(s=rr(e,t,n,n),s?(r.mode=16210,Rn):(r.havedict=1,Nn)))},inflateInfo:"pako inflate (from Nodeca project)"};var sr=function(){this.text=0,this.time=0,this.xflags=0,this.os=0,this.extra=null,this.extra_len=0,this.name="",this.comment="",this.hcrc=0,this.done=!1};const ir=Object.prototype.toString,{Z_NO_FLUSH:or,Z_FINISH:ur,Z_OK:cr,Z_STREAM_END:lr,Z_NEED_DICT:hr,Z_STREAM_ERROR:dr,Z_DATA_ERROR:fr,Z_MEM_ERROR:pr}=et;function vr(e){this.options=$t.assign({chunkSize:65536,windowBits:15,to:""},e||{});const t=this.options;t.raw&&t.windowBits>=0&&t.windowBits<16&&(t.windowBits=-t.windowBits,0===t.windowBits&&(t.windowBits=-15)),!(t.windowBits>=0&&t.windowBits<16)||e&&e.windowBits||(t.windowBits+=32),t.windowBits>15&&t.windowBits<48&&0==(15&t.windowBits)&&(t.windowBits|=15),this.err=0,this.msg="",this.ended=!1,this.chunks=[],this.strm=new rn,this.strm.avail_out=0;let n=ar.inflateInit2(this.strm,t.windowBits);if(n!==cr)throw new Error($e[n]);if(this.header=new sr,ar.inflateGetHeader(this.strm,this.header),t.dictionary&&("string"==typeof t.dictionary?t.dictionary=nn.string2buf(t.dictionary):"[object ArrayBuffer]"===ir.call(t.dictionary)&&(t.dictionary=new Uint8Array(t.dictionary)),t.raw&&(n=ar.inflateSetDictionary(this.strm,t.dictionary),n!==cr)))throw new Error($e[n])}function _r(e,t){const n=new vr(t);if(n.push(e),n.err)throw n.msg||$e[n.err];return n.result}vr.prototype.push=function(e,t){const n=this.strm,r=this.options.chunkSize,a=this.options.dictionary;let s,i,o;if(this.ended)return!1;for(i=t===~~t?t:!0===t?ur:or,"[object ArrayBuffer]"===ir.call(e)?n.input=new Uint8Array(e):n.input=e,n.next_in=0,n.avail_in=n.input.length;;){for(0===n.avail_out&&(n.output=new Uint8Array(r),n.next_out=0,n.avail_out=r),s=ar.inflate(n,i),s===hr&&a&&(s=ar.inflateSetDictionary(n,a),s===cr?s=ar.inflate(n,i):s===fr&&(s=hr));n.avail_in>0&&s===lr&&n.state.wrap>0&&0!==e[n.next_in];)ar.inflateReset(n),s=ar.inflate(n,i);switch(s){case dr:case fr:case hr:case pr:return this.onEnd(s),this.ended=!0,!1}if(o=n.avail_out,n.next_out&&(0===n.avail_out||s===lr))if("string"===this.options.to){let e=nn.utf8border(n.output,n.next_out),t=n.next_out-e,a=nn.buf2string(n.output,e);n.next_out=t,n.avail_out=r-t,t&&n.output.set(n.output.subarray(e,e+t),0),this.onData(a)}else this.onData(n.output.length===n.next_out?n.output:n.output.subarray(0,n.next_out));if(s!==cr||0!==o){if(s===lr)return s=ar.inflateEnd(this.strm),this.onEnd(s),this.ended=!0,!0;if(0===n.avail_in)break}}return!0},vr.prototype.onData=function(e){this.chunks.push(e)},vr.prototype.onEnd=function(e){e===cr&&("string"===this.options.to?this.result=this.chunks.join(""):this.result=$t.flattenChunks(this.chunks)),this.chunks=[],this.err=e,this.msg=this.strm.msg};var mr={Inflate:vr,inflate:_r,inflateRaw:function(e,t){return(t=t||{}).raw=!0,_r(e,t)},ungzip:_r,constants:et};const{Deflate:gr,deflate:yr,deflateRaw:kr,gzip:br}=mn,{Inflate:Er,inflate:wr,inflateRaw:Cr,ungzip:xr}=mr;var Tr,Sr={Deflate:gr,deflate:yr,deflateRaw:kr,gzip:br,Inflate:Er,inflate:wr,inflateRaw:Cr,ungzip:xr,constants:et},Ir=function(e){return b(void 0,void 0,void 0,t().mark((function n(){var r;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return r=Sr.ungzip(e),t.abrupt("return",String.fromCharCode.apply(null,r));case 2:case"end":return t.stop()}}),n)})))};e.ConnectionState=void 0,(Tr=e.ConnectionState||(e.ConnectionState={})).CONNECTING="CONNECTING",Tr.OPEN="OPEN",Tr.CLOSED="CLOSED";var Nr,Ar=function(n){i(o,n);var a=f(o);function o(e,t){var n,s=t.sdkState,i=t.dispatcher,u=t.logger;return r(this,o),(n=a.call(this)).lastActive=0,n._iid=e,n._sdkState=s,n._dispatcher=i,n._logger=u,n}return s(o,[{key:"isOpen",get:function(){return this.connectionState===e.ConnectionState.OPEN}},{key:"connectionState",get:function(){if(this._ws)switch(this._ws.readyState){case 0:return e.ConnectionState.CONNECTING;case 1:return e.ConnectionState.OPEN}return e.ConnectionState.CLOSED}},{key:"_handleMessage",value:function(e){var t=this;e.split("\n").forEach((function(e){if(e){var n=le.createFromRawMessage(t._iid,e);t._logger.debug("receive websocket event",n),"LOGI"===n.code?t.dispatch("message",n):"PONG"===n.code?t.dispatch("pong"):"EXPR"===n.code?n.payload&&n.payload.expires_in>=0&&t._dispatcher.dispatch(new se):"NOOP"===n.code||t.dispatch("message",n)}}))}},{key:"connect",value:function(e){var n=this;this._ws=new WebSocket(e),this._ws.onopen=function(){n._logger.debug("websocket open"),n.dispatch("open")},this._ws.onmessage=function(e){return b(n,void 0,void 0,t().mark((function n(){var r,a,s=this;return t().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:(null===(r=this._sdkState.websocket)||void 0===r?void 0:r.compression)?e.data instanceof Blob?((a=new FileReader).readAsArrayBuffer(e.data),a.onloadend=function(){return b(s,void 0,void 0,t().mark((function e(){var n;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,Ir(a.result);case 2:n=e.sent,this._handleMessage(n);case 4:case"end":return e.stop()}}),e,this)})))}):"string"==typeof e.data&&this._handleMessage(e.data):this._handleMessage(e.data);case 1:case"end":return n.stop()}}),n,this)})))},this._ws.onerror=function(){n._logger.debug("websocket error"),n.dispatch("error",M.networkError)},this._ws.onclose=function(){n._logger.debug("websocket close"),n.dispatch("close")},this.lastActive=Date.now()}},{key:"disconnect",value:function(){var t=this;return new Promise((function(n){t._logger.debug("websocket disconnect"),t._ws&&t.connectionState!==e.ConnectionState.CLOSED?(t._ws.onopen=he,t._ws.onmessage=he,t._ws.onerror=he,t._ws.onclose=function(){t.dispatch("close"),n()},t._ws.close(),t._ws=null):n()}))}},{key:"send",value:function(e){if(!this._ws)throw M.connectionClosed;"PING"!==e.code?this.dispatch("ping-refresh"):this._logger.debug("send ping",e),this._ws.send(e.convertToMessage())}},{key:"error",value:function(e){this._logger.debug("websocket error",e),this.dispatch("error",e)}}]),o}(J),Mr=function(e){i(n,e);var t=f(n);function n(e){var a,s,i=e.code,o=e.ackRequired,u=e.payload,c=void 0===u?null:u;return r(this,n),(a=t.call(this)).code=i,a.payload=c,a.requestId=null!==(s=a.payload.req_id)&&void 0!==s?s:Y(),a.ackRequired=o,a.payload.req_id=a.requestId,a}return s(n,[{key:"convertToMessage",value:function(){return"".concat(this.code).concat(JSON.stringify(this.payload),"\n")}}]),n}($),Or=function(e){i(n,e);var t=f(n);function n(e){var a,s=e.all,i=e.custom_types,o=e.ts;return r(this,n),(a=t.call(this)).all=s,a.customTypes=i,a.ts=o,a}return s(n)}($),Ur=s((function e(){var t=this;r(this,e),this.promise=new Promise((function(e,n){t.resolve=e,t.reject=n}))})),Rr=function(){function e(t,n){var a=this,s=n.auth,i=n.sdkState,o=n.dispatcher,u=n.logger,c=n.useFetchCompat,l=void 0!==c&&c;r(this,e),this._ackStateMap=new Map,this._sdkState=i,this._dispatcher=o,this._logger=u,this.apiClient=new ce(t,{auth:s,sdkState:i,dispatcher:o,logger:u,useFetchCompat:l}),this.websocketClient=new Ar(t,{sdkState:i,dispatcher:o,logger:u}),this.websocketClient.on("message",(function(e){if(e.payload.unread_cnt&&a._dispatcher.dispatch(new Or(e.payload.unread_cnt)),e.requestId){if(a._ackStateMap.has(e.requestId)){var t=a._ackStateMap.get(e.requestId);"EROR"!==e.code?t.resolve(e):t.reject(new M({code:e.payload.code,message:e.payload.message}))}}else a._dispatcher.dispatch(e)})).on("close",(function(){a._ackStateMap.forEach((function(e){e.reject(M.connectionClosed)})),a._ackStateMap.clear()}))}return s(e,[{key:"_sendApiRequest",value:function(e){return b(this,void 0,void 0,t().mark((function n(){return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,this.apiClient.send(e);case 2:return t.abrupt("return",t.sent);case 3:case"end":return t.stop()}}),n,this)})))}},{key:"_sendWebsocketRequest",value:function(e){return b(this,void 0,void 0,t().mark((function n(){var r,a,s,i=this;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(r=new Ur,e.ackRequired){a=null,s=function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:null,n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null;i._ackStateMap.has(e.requestId)&&(i._ackStateMap.delete(e.requestId),a&&(clearTimeout(a),a=null),t?(i._logger.debug("fail websocket request",t),r.reject(t)):(i._logger.debug("receive websocket ack",e.requestId),r.resolve(n)))};try{a=setTimeout((function(){return s(M.noAckTimeout)}),this._sdkState.websocket.responseTimeout),this._ackStateMap.set(e.requestId,{resolve:function(e){return s(null,e)},reject:function(e){return s(e)}}),this.websocketClient.send(e)}catch(e){s(e)}}else try{this.websocketClient.send(e),r.resolve(null)}catch(e){r.reject(e)}return t.abrupt("return",r.promise);case 3:case"end":return t.stop()}}),n,this)})))}},{key:"send",value:function(e){return b(this,void 0,void 0,t().mark((function n(){return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(!(e instanceof ne)){t.next=6;break}return t.next=3,this._sendApiRequest(e);case 3:case 9:return t.abrupt("return",t.sent);case 6:if(!(e instanceof Mr)){t.next=10;break}return t.next=9,this._sendWebsocketRequest(e);case 10:throw M.invalidParameters;case 11:case"end":return t.stop()}}),n,this)})))}},{key:"cancel",value:function(e){this.apiClient.cancel(e)}},{key:"cancelAll",value:function(){this.apiClient.cancelAll()}}]),e}();!function(e){e[e.NONE=0]="NONE",e[e.INITIALIZED=1]="INITIALIZED",e[e.CONNECTING=2]="CONNECTING",e[e.CONNECTED=3]="CONNECTED",e[e.RECONNECTING=4]="RECONNECTING",e[e.INTERNAL_DISCONNECTED=5]="INTERNAL_DISCONNECTED",e[e.EXTERNAL_DISCONNECTED=6]="EXTERNAL_DISCONNECTED",e[e.LOGOUT=7]="LOGOUT"}(Nr||(Nr={}));var Lr,Dr=function(e){i(n,e);var t=f(n);function n(e){var a,s=e.stateType;return r(this,n),(a=t.call(this)).stateType=s,a}return s(n)}($),Pr=function(){function e(n,a){var s=this,i=a.auth,o=a.sdkState,u=a.dispatcher,c=a.logger,l=a.useFetchCompat,h=void 0!==l&&l;r(this,e),this._currentConnectionStateType=Nr.INITIALIZED,this._lazyCallQueue=[],this.commandRouter=new Rr(n,{auth:i,sdkState:o,dispatcher:u,logger:c,useFetchCompat:h}),this._auth=i,this._logger=c,this._dispatcher=u,this._dispatcher.on((function(e){if(e instanceof Dr){var n=e.stateType;switch(s._currentConnectionStateType=n,n){case Nr.CONNECTED:var r=s._lazyCallQueue;s._lazyCallQueue=[],r.forEach((function(e){return b(s,void 0,void 0,t().mark((function n(){var r,a,s,i;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return r=e.command,a=e.deferred,s=e.timeout,clearTimeout(s),t.prev=2,t.next=5,this.send(r);case 5:i=t.sent,a.resolve(i),t.next=12;break;case 9:t.prev=9,t.t0=t.catch(2),a.reject(t.t0);case 12:case"end":return t.stop()}}),n,this,[[2,9]])})))}));break;case Nr.INITIALIZED:case Nr.INTERNAL_DISCONNECTED:case Nr.EXTERNAL_DISCONNECTED:case Nr.LOGOUT:var a=s._lazyCallQueue;s._lazyCallQueue=[],a.forEach((function(e){return b(s,void 0,void 0,t().mark((function n(){var r,a;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:r=e.deferred,a=e.timeout,clearTimeout(a),this._auth&&this._auth.hasSession?r.reject(M.connectionClosed):r.reject(M.connectionRequired);case 3:case"end":return t.stop()}}),n,this)})))}))}}}))}return s(e,[{key:"isReady",get:function(){return this._currentConnectionStateType===Nr.CONNECTED}},{key:"isLazyCallActivated",get:function(){return this._currentConnectionStateType===Nr.CONNECTING||this._currentConnectionStateType===Nr.RECONNECTING}},{key:"send",value:function(e){return b(this,void 0,void 0,t().mark((function n(){var r,a,s,i=this;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(!(e instanceof Mr)){t.next=19;break}if(!this.isReady){t.next=8;break}return this._logger.debug("send websocket request",e),t.next=5,this.commandRouter.send(e);case 5:case 24:return t.abrupt("return",t.sent);case 8:if(!this.isLazyCallActivated){t.next=15;break}return this._logger.debug("wait websocket request",e),r=new Ur,this._lazyCallQueue.push({command:e,deferred:r,timeout:setTimeout((function(){return i.timeout(e.requestId)}),1e4)}),t.abrupt("return",r.promise);case 15:throw this._logger.debug("fail websocket request"),M.connectionRequired;case 17:t.next=37;break;case 19:if(!(e instanceof ne)){t.next=37;break}if(!this._auth.hasSession){t.next=27;break}return this._logger.debug("send api request",e),t.next=24,this.commandRouter.send(e);case 27:if(!this.isLazyCallActivated){t.next=34;break}return this._logger.debug("wait api request",e),a=new Ur,this._lazyCallQueue.push({command:e,deferred:a,timeout:setTimeout((function(){return i.timeout(e.requestId)}),1e4)}),t.abrupt("return",a.promise);case 34:throw s=M.connectionRequired,this._logger.debug("fail api request",s),s;case 37:case"end":return t.stop()}}),n,this)})))}},{key:"forceSend",value:function(e){return b(this,void 0,void 0,t().mark((function n(){return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return this._logger.debug("send forced request",e),t.next=3,this.commandRouter.send(e);case 3:return t.abrupt("return",t.sent);case 4:case"end":return t.stop()}}),n,this)})))}},{key:"timeout",value:function(e){this._logger.debug("timeout request",e);var t=this._lazyCallQueue.findIndex((function(t){return t.command.requestId===e}));t>-1&&(this._lazyCallQueue[t].deferred.reject(M.connectionRequired),this._lazyCallQueue.splice(t,1))}},{key:"cancel",value:function(e){this._logger.debug("cancel api request",e),this.commandRouter.cancel(e)}},{key:"cancelAll",value:function(){this._logger.debug("cancel all api requests"),this.commandRouter.cancelAll()}}]),e}(),Fr="sendbird@devicetokens",Gr=function(){function e(t){var n=t.type,a=t.token;r(this,e),this.type=n,this.token=a}return s(e,null,[{key:"payloadify",value:function(e){return{type:e.type,token:e.token}}}]),e}(),Hr="v3",qr="/".concat(Hr,"/users"),jr="/".concat(Hr,"/storage/file"),zr="/".concat(Hr,"/group_channels"),Vr="/".concat(Hr,"/sdk/group_channels"),Br="/".concat(Hr,"/open_channels"),Qr="/".concat(Hr,"/sdk/open_channels"),Kr="/".concat(Hr,"/search"),Wr="/".concat(Hr,"/report"),Yr="/".concat(Hr,"/emojis"),Zr="/".concat(Hr,"/emoji_categories"),Jr="/".concat(Hr,"/polls"),Xr="/".concat(Hr,"/scheduled_messages"),$r="/".concat(Hr,"/sdk/statistics"),ea=function(e){i(n,e);var t=f(n);function n(e){var a,s=e.userId,i=e.authToken,o=e.expiringSession,u=void 0===o||o;return r(this,n),(a=t.call(this)).path="".concat(qr,"/").concat(s,"/session_key"),a.method=B.POST,a.params={token:i,expiring_session:!!u},a.requireAuth=!1,a}return s(n)}(ne),ta=function(e){i(n,e);var t=f(n);function n(e){var a=e.authToken,s=e.expiringSession,i=void 0===s||s,o=e.requestId,u=void 0===o?null:o;return r(this,n),t.call(this,{code:"LOGI",payload:{token:a,expiring_session:i?1:0,req_id:u},ackRequired:!0})}return s(n)}(Mr),na=function(e){i(n,e);var t=f(n);function n(e,a){var s;r(this,n),s=t.call(this,e,a);var i=a.key;return s.key=i,s}return s(n)}(re),ra=function(e){i(n,e);var t=f(n);function n(e,a,s){var i;return r(this,n),(i=t.call(this,e,"LOGI",s)).error=null,i.newKey=s.new_key,i.error=s.error?new M(s.error):null,i}return s(n)}(le),aa=function(e){i(n,e);var t=f(n);function n(){return r(this,n),t.apply(this,arguments)}return s(n)}($),sa=function(e){return b(void 0,void 0,void 0,t().mark((function n(){return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.abrupt("return",new Promise((function(t){return setTimeout(t,e)})));case 1:case"end":return t.stop()}}),n)})))},ia=function(){function e(){r(this,e)}return s(e,[{key:"calcTimeout",value:function(){return 0}}]),e}(),oa=function(e,n){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:new ia;return b(void 0,void 0,void 0,t().mark((function a(){var s,i,o,u,c;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:s=0,i=null,o=function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:null;return i=null!=e?e:new Error("Halted")},u=function(){s=0};case 4:if(!(-1===n||s=0}},{key:"createRefreshWebsocketCommand",value:function(e){return new ta({authToken:e,expiringSession:!0,requestId:arguments.length>1&&void 0!==arguments[1]?arguments[1]:null})}},{key:"_refreshSessionKeyByWebSocket",value:function(e){return b(this,void 0,void 0,t().mark((function n(){var r,a,s,i,o;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return r=this.createRefreshWebsocketCommand(e),t.next=3,this._requestQueue.forceSend(r);case 3:if(a=t.sent,s=a.as(ra),i=s.newKey,!(o=s.error)){t.next=7;break}throw o;case 7:this.auth.sessionKey=null!=i?i:this.auth.sessionKey;case 8:case"end":return t.stop()}}),n,this)})))}},{key:"_refreshSessionKeyByApi",value:function(e){return b(this,void 0,void 0,t().mark((function n(){var r,a=this;return t().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return r=new ea({userId:this._sdkState.userId,authToken:e,expiringSession:!0}),n.next=3,oa((function(e){return b(a,void 0,void 0,t().mark((function n(){var a,s,i;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.prev=0,t.next=3,this._requestQueue.forceSend(r);case 3:a=t.sent,s=a.as(na),i=s.key,this.auth.sessionKey=i,t.next=15;break;case 8:if(t.prev=8,t.t0=t.catch(0),!this._isSessionRelatedError(t.t0)){t.next=14;break}e(t.t0),t.next=15;break;case 14:throw t.t0;case 15:case"end":return t.stop()}}),n,this,[[0,8]])})))}),3);case 3:case"end":return n.stop()}}),n,this)})))}},{key:"_refreshSessionKey",value:function(e){var n=!(arguments.length>1&&void 0!==arguments[1])||arguments[1];return b(this,void 0,void 0,t().mark((function r(){return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(this._currentConnectionStateType!==Nr.CONNECTED){t.next=25;break}return t.prev=1,t.next=4,this._refreshSessionKeyByWebSocket(e);case 4:return this.complete(),t.abrupt("return");case 8:if(t.prev=8,t.t0=t.catch(1),!this._isSessionRelatedError(t.t0)){t.next=25;break}if(!n){t.next=25;break}return t.next=14,this._receiveNewAuthToken();case 14:if(this.auth.authToken=t.sent,!this.auth.authToken){t.next=21;break}return t.next=18,this._refreshSessionKey(this.auth.authToken,!1);case 18:this.complete(),t.next=24;break;case 21:return t.next=23,this.clear();case 23:this.close();case 24:return t.abrupt("return");case 25:return t.prev=25,t.next=28,this._refreshSessionKeyByApi(e);case 28:this.complete(),t.next=53;break;case 31:if(t.prev=31,t.t1=t.catch(25),!this._isSessionRelatedError(t.t1)){t.next=52;break}if(!n){t.next=49;break}return t.next=37,this._receiveNewAuthToken();case 37:if(this.auth.authToken=t.sent,!this.auth.authToken){t.next=44;break}return t.next=41,this._refreshSessionKeyByApi(this.auth.authToken);case 41:this.complete(),t.next=47;break;case 44:return t.next=46,this.clear();case 46:this.close();case 47:t.next=50;break;case 49:throw t.t1;case 50:t.next=53;break;case 52:throw t.t1;case 53:case"end":return t.stop()}}),r,this,[[1,8],[25,31]])})))}},{key:"_receiveNewAuthToken",value:function(){var e=this,n=new Ur;return ua((function(){return b(e,void 0,void 0,t().mark((function e(){var r,a,s=this;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:this._isRefreshingAuthToken=!0,this.auth.clear(),r=null,a=function(){r&&(clearTimeout(r),r=null)},r=setTimeout((function(){s._isRefreshingAuthToken=!1,n.reject()}),1e3*this._sdkState.sessionTokenRefreshTimeout),this.handler.onSessionTokenRequired((function(e){a(),s._isRefreshingAuthToken&&(s._isRefreshingAuthToken=!1,s.dispatch("refresh-authtoken"),n.resolve(e))}),(function(e){a(),s._isRefreshingAuthToken=!1,n.reject(e)}));case 6:case"end":return e.stop()}}),e,this)})))})),n.promise}},{key:"_isSessionRelatedError",value:function(e){return e instanceof M&&(e.isSessionKeyExpiredError||e.isSessionTokenExpiredError)}},{key:"isSessionKeyRefreshing",get:function(){return this._isRefreshingSessionKey}},{key:"isRefreshingAuthToken",get:function(){return this._isRefreshingAuthToken}},{key:"login",value:function(e){var n;return b(this,void 0,void 0,t().mark((function r(){var a,s,i,o,u,c,l;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(a=e.key,s=e.ekey,i=e.userProfile,o=e.deviceTokenLastDeletedAt,u=void 0===o?0:o,this.auth.sessionKey=a,la.set(this,s),this._deviceTokenCacheEnabled=null===(n=null==i?void 0:i.appInfo)||void 0===n?void 0:n.deviceTokenCache,c=this._cacheContext.preference,!this._deviceTokenCacheEnabled){t.next=20;break}return t.next=8,c.get(Fr);case 8:if((l=t.sent)&&!(l.lastDeletedAt=0&&this._deviceTokens.splice(n,1)}}},{key:"unsetDeviceTokens",value:function(e){this._deviceTokenCacheEnabled&&(this._deviceTokens=e?this._deviceTokens.filter((function(t){return t.type!==e})):[])}},{key:"setDeviceTokenDeletedAt",value:function(e){e>0&&(this._deviceTokenLastDeletedAt=e)}},{key:"saveDeviceToken",value:function(){return b(this,void 0,void 0,t().mark((function e(){var n;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!this._deviceTokenCacheEnabled){e.next=4;break}return n=this._cacheContext.preference,e.next=4,n.set(Fr,{tokens:this._deviceTokens,lastDeletedAt:this._deviceTokenLastDeletedAt});case 4:case"end":return e.stop()}}),e,this)})))}},{key:"clear",value:function(){return b(this,void 0,void 0,t().mark((function e(){return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return this.currentUser=null,this.auth.clear(),la.delete(this),this._deviceTokens=[],this._deviceTokenLastDeletedAt=0,e.next=7,this.saveDeviceToken();case 7:case"end":return e.stop()}}),e,this)})))}}]),a}(J),da=function(){function e(){r(this,e),this.type=Nr.NONE,this.name="none"}return s(e,[{key:"run",value:function(e){return b(this,void 0,void 0,t().mark((function e(){return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:case"end":return e.stop()}}),e)})))}},{key:"onConnect",value:function(e,n){return b(this,void 0,void 0,t().mark((function e(){return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:case"end":return e.stop()}}),e)})))}},{key:"onReconnect",value:function(e,n){return n.resetReconnectCount,b(this,void 0,void 0,t().mark((function e(){return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:case"end":return e.stop()}}),e)})))}},{key:"onDisconnect",value:function(e,n){return n.error,n.autoReconnect,b(this,void 0,void 0,t().mark((function e(){return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:case"end":return e.stop()}}),e)})))}},{key:"onDisconnectWebSocket",value:function(e){return b(this,void 0,void 0,t().mark((function e(){return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:case"end":return e.stop()}}),e)})))}},{key:"onLogout",value:function(e){return b(this,void 0,void 0,t().mark((function e(){return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:case"end":return e.stop()}}),e)})))}}]),e}(),fa=function(e){i(a,e);var n=f(a);function a(){var e;return r(this,a),(e=n.apply(this,arguments)).type=Nr.LOGOUT,e.name="logout",e}return s(a,[{key:"run",value:function(e){return b(this,void 0,void 0,t().mark((function n(){var r,a,s=this;return t().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return r=Date.now(),a=e.sdkState.userId,n.next=4,e.logout();case 4:return n.next=6,e.changeState(new ya,r);case 6:ua((function(){return b(s,void 0,void 0,t().mark((function n(){return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:e.connectionHandlers.forEach((function(e){e.onDisconnected(a)}));case 1:case"end":return t.stop()}}),n)})))}));case 7:case"end":return n.stop()}}),n)})))}}]),a}(da),pa=function(e){i(a,e);var n=f(a);function a(){var e;return r(this,a),(e=n.call(this)).type=Nr.EXTERNAL_DISCONNECTED,e.name="externaldisconnected",e}return s(a,[{key:"run",value:function(e){return b(this,void 0,void 0,t().mark((function n(){return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,e.disconnect();case 2:case"end":return t.stop()}}),n)})))}},{key:"onConnect",value:function(e,n){return b(this,void 0,void 0,t().mark((function r(){var a;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return a=Date.now(),t.next=3,e.disconnect();case 3:return t.next=5,e.changeState(new ga({authToken:n}),a);case 5:case"end":return t.stop()}}),r)})))}},{key:"onReconnect",value:function(e){return b(this,void 0,void 0,t().mark((function n(){var r;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return r=Date.now(),t.next=3,e.changeState(new _a,r);case 3:case"end":return t.stop()}}),n)})))}},{key:"onLogout",value:function(e){return b(this,void 0,void 0,t().mark((function n(){var r;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return r=Date.now(),t.next=3,e.changeState(new fa,r);case 3:case"end":return t.stop()}}),n)})))}}]),a}(da),va=function(e){i(a,e);var n=f(a);function a(e){var t,s=e.autoReconnect;return r(this,a),(t=n.call(this)).type=Nr.INTERNAL_DISCONNECTED,t.name="internaldisconnected",t._autoReconnect=!1,t._autoReconnect=s,t}return s(a,[{key:"run",value:function(e){return b(this,void 0,void 0,t().mark((function n(){var r;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return r=Date.now(),t.next=3,e.disconnect();case 3:if(!this._autoReconnect){t.next=6;break}return t.next=6,e.changeState(new _a,r);case 6:case"end":return t.stop()}}),n,this)})))}},{key:"onConnect",value:function(e,n){return b(this,void 0,void 0,t().mark((function r(){var a;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return a=Date.now(),t.next=3,e.disconnect();case 3:return t.next=5,e.changeState(new ga({authToken:n}),a);case 5:case"end":return t.stop()}}),r)})))}},{key:"onReconnect",value:function(e){return b(this,void 0,void 0,t().mark((function n(){var r;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return r=Date.now(),t.next=3,e.changeState(new _a,r);case 3:case"end":return t.stop()}}),n)})))}},{key:"onDisconnectWebSocket",value:function(e){return b(this,void 0,void 0,t().mark((function n(){var r;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return r=Date.now(),t.next=3,e.changeState(new pa,r);case 3:case"end":return t.stop()}}),n)})))}},{key:"onLogout",value:function(e){return b(this,void 0,void 0,t().mark((function n(){var r;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return r=Date.now(),t.next=3,e.changeState(new fa,r);case 3:case"end":return t.stop()}}),n)})))}}]),a}(da),_a=function(e){i(a,e);var n=f(a);function a(){var e;return r(this,a),(e=n.apply(this,arguments)).type=Nr.RECONNECTING,e.name="reconnecting",e._haltConnect=null,e._resetConnect=null,e._callbacks=[],e}return s(a,[{key:"_halt",value:function(e){this._haltConnect&&(this._haltConnect(e),this._haltConnect=null)}},{key:"_flushCallbacks",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:null;this._haltConnect=null,this._resetConnect=null,this._callbacks.forEach((function(t){return t(e)}))}},{key:"run",value:function(e){return b(this,void 0,void 0,t().mark((function n(){var r,a,s,i,o,u=this;return t().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return r=Date.now(),a=new Ur,this._callbacks.push((function(e){return e?a.reject(e):a.resolve()})),ua((function(){return b(u,void 0,void 0,t().mark((function n(){return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:e.connectionHandlers.forEach((function(e){e.onReconnectStarted()}));case 1:case"end":return t.stop()}}),n)})))})),n.prev=4,s=e.sdkState.websocket,i=s.reconnectMaxRetry,o=s.reconnectRetryStrategy,n.next=8,oa((function(n,r){return b(u,void 0,void 0,t().mark((function a(){return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return this._haltConnect=n,this._resetConnect=r,t.prev=2,t.next=5,e.connect();case 5:t.next=17;break;case 7:if(t.prev=7,t.t0=t.catch(2),e.clearLoginTimer(),!(t.t0 instanceof M)){t.next=16;break}t.t1=t.t0.code,t.next=t.t1===E.CONNECTION_CANCELED?14:16;break;case 14:return n(t.t0),t.abrupt("return");case 16:throw t.t0;case 17:case"end":return t.stop()}}),a,this,[[2,7]])})))}),i,o);case 8:return n.next=10,e.changeState(new ma,r);case 10:ua((function(){return b(u,void 0,void 0,t().mark((function n(){return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:this._flushCallbacks(null),e.connectionHandlers.forEach((function(e){e.onReconnectSucceeded()}));case 2:case"end":return t.stop()}}),n,this)})))})),n.next=24;break;case 13:if(n.prev=13,n.t0=n.catch(4),A(n.t0)){n.next=23;break}if(!(n.t0 instanceof M)){n.next=20;break}if(n.t0.code===E.CONNECTION_CANCELED){n.next=20;break}return n.next=20,e.changeState(new va({autoReconnect:!1}),r);case 20:ua((function(){return b(u,void 0,void 0,t().mark((function r(){return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:this._flushCallbacks(n.t0),e.connectionHandlers.forEach((function(e){e.onReconnectFailed()}));case 2:case"end":return t.stop()}}),r,this)})))})),n.next=24;break;case 23:throw n.t0;case 24:return n.abrupt("return",a.promise);case 25:case"end":return n.stop()}}),n,this,[[4,13]])})))}},{key:"onConnect",value:function(e,n){return b(this,void 0,void 0,t().mark((function r(){var a;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return a=new Ur,this._halt(M.connectionCanceled),e.cancelConnectForRetry(),this._callbacks.push((function(){var t=Date.now();e.changeState(new ga({authToken:n}),t).then((function(){a.resolve()})).catch((function(e){a.reject(e)}))})),t.abrupt("return",a.promise);case 5:case"end":return t.stop()}}),r,this)})))}},{key:"onReconnect",value:function(e,n){var r=n.resetReconnectCount,a=void 0!==r&&r;return b(this,void 0,void 0,t().mark((function e(){var n;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n=new Ur,this._resetConnect&&a&&this._resetConnect(),this._callbacks.push((function(e){return e?n.reject(e):n.resolve()})),e.abrupt("return",n.promise);case 4:case"end":return e.stop()}}),e,this)})))}},{key:"onDisconnect",value:function(e,n){n.error;var r=n.autoReconnect,a=void 0===r||r;return b(this,void 0,void 0,t().mark((function n(){var r;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return r=Date.now(),this._halt(M.connectionCanceled),t.next=4,e.changeState(new va({autoReconnect:a}),r);case 4:case"end":return t.stop()}}),n,this)})))}},{key:"onDisconnectWebSocket",value:function(e){return b(this,void 0,void 0,t().mark((function n(){var r;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return r=Date.now(),this._halt(M.connectionCanceled),t.next=4,e.changeState(new pa,r);case 4:case"end":return t.stop()}}),n,this)})))}},{key:"onLogout",value:function(e){return b(this,void 0,void 0,t().mark((function n(){var r;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return r=Date.now(),this._halt(M.connectionCanceled),t.next=4,e.changeState(new fa,r);case 4:case"end":return t.stop()}}),n,this)})))}}]),a}(da),ma=function(e){i(a,e);var n=f(a);function a(){var e;return r(this,a),(e=n.apply(this,arguments)).type=Nr.CONNECTED,e.name="connected",e}return s(a,[{key:"onReconnect",value:function(e){return b(this,void 0,void 0,t().mark((function n(){var r;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return r=Date.now(),t.next=3,e.disconnect();case 3:return t.next=5,e.changeState(new _a,r);case 5:case"end":return t.stop()}}),n)})))}},{key:"onDisconnect",value:function(e,n){var r=n.autoReconnect;return b(this,void 0,void 0,t().mark((function n(){var a;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return a=Date.now(),t.next=3,e.changeState(new va({autoReconnect:r}),a);case 3:case"end":return t.stop()}}),n)})))}},{key:"onDisconnectWebSocket",value:function(e){return b(this,void 0,void 0,t().mark((function n(){var r;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return r=Date.now(),t.next=3,e.changeState(new pa,r);case 3:case"end":return t.stop()}}),n)})))}},{key:"onLogout",value:function(e){return b(this,void 0,void 0,t().mark((function n(){var r;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return r=Date.now(),t.next=3,e.changeState(new fa,r);case 3:case"end":return t.stop()}}),n)})))}}]),a}(da),ga=function(e){i(a,e);var n=f(a);function a(e){var t,s=e.authToken;return r(this,a),(t=n.call(this)).type=Nr.CONNECTING,t.name="connecting",t._authToken="",t._haltConnect=null,t._callbacks=[],t._authToken=s,t}return s(a,[{key:"_halt",value:function(e){this._haltConnect&&(this._haltConnect(e),this._haltConnect=null)}},{key:"_flushCallbacks",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:null;this._haltConnect=null,this._callbacks.forEach((function(t){return t(e)}))}},{key:"run",value:function(e){return b(this,void 0,void 0,t().mark((function n(){var r,a,s=this;return t().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return r=Date.now(),a=new Ur,this._callbacks.push((function(e){return e?a.reject(e):a.resolve()})),n.prev=3,n.next=6,oa((function(n){return b(s,void 0,void 0,t().mark((function r(){return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return this._haltConnect=n,t.prev=1,t.next=4,e.connect(this._authToken);case 4:t.next=16;break;case 6:if(t.prev=6,t.t0=t.catch(1),e.clearLoginTimer(),!(t.t0 instanceof M)){t.next=15;break}t.t1=t.t0.code,t.next=t.t1===E.CONNECTION_CANCELED?13:15;break;case 13:return n(t.t0),t.abrupt("return");case 15:throw t.t0;case 16:case"end":return t.stop()}}),r,this,[[1,6]])})))}),e.sdkState.websocket.connectMaxRetry);case 6:return n.next=8,e.changeState(new ma,r);case 8:ua((function(){return b(s,void 0,void 0,t().mark((function n(){return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:this._flushCallbacks(null),e.connectionHandlers.forEach((function(t){t.onConnected(e.sdkState.userId)}));case 2:case"end":return t.stop()}}),n,this)})))})),n.next=24;break;case 11:if(n.prev=11,n.t0=n.catch(3),A(n.t0)){n.next=23;break}return n.next=16,e.disconnect();case 16:if(!(n.t0 instanceof M)){n.next=20;break}if(n.t0.code===E.CONNECTION_CANCELED){n.next=20;break}return n.next=20,e.changeState(new ya,r);case 20:ua((function(){return b(s,void 0,void 0,t().mark((function e(){return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:this._flushCallbacks(n.t0);case 1:case"end":return e.stop()}}),e,this)})))})),n.next=24;break;case 23:throw n.t0;case 24:return n.abrupt("return",a.promise);case 25:case"end":return n.stop()}}),n,this,[[3,11]])})))}},{key:"onConnect",value:function(e){return b(this,void 0,void 0,t().mark((function e(){var n;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n=new Ur,this._callbacks.push((function(e){return e?n.reject(e):n.resolve()})),e.abrupt("return",n.promise);case 3:case"end":return e.stop()}}),e,this)})))}},{key:"onDisconnect",value:function(e,n){var r=n.error,a=void 0===r?null:r,s=n.autoReconnect;return b(this,void 0,void 0,t().mark((function n(){var r;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(r=Date.now(),this._halt(null!=a?a:M.connectionCanceled),!e.hasSession){t.next=7;break}return t.next=5,e.changeState(new va({autoReconnect:s}),r);case 5:t.next=9;break;case 7:return t.next=9,e.changeState(new fa,r);case 9:case"end":return t.stop()}}),n,this)})))}},{key:"onDisconnectWebSocket",value:function(e){return b(this,void 0,void 0,t().mark((function n(){var r;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(r=Date.now(),this._halt(M.connectionCanceled),!e.hasSession){t.next=7;break}return t.next=5,e.changeState(new pa,r);case 5:t.next=9;break;case 7:return t.next=9,e.changeState(new fa,r);case 9:case"end":return t.stop()}}),n,this)})))}},{key:"onLogout",value:function(e){return b(this,void 0,void 0,t().mark((function n(){var r;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return r=Date.now(),this._halt(M.connectionCanceled),t.next=4,e.changeState(new fa,r);case 4:case"end":return t.stop()}}),n,this)})))}}]),a}(da),ya=function(e){i(a,e);var n=f(a);function a(){var e;return r(this,a),(e=n.apply(this,arguments)).type=Nr.INITIALIZED,e.name="initialized",e}return s(a,[{key:"onConnect",value:function(e,n){return b(this,void 0,void 0,t().mark((function r(){var a;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return a=Date.now(),t.next=3,e.changeState(new ga({authToken:n}),a);case 3:case"end":return t.stop()}}),r)})))}}]),a}(da),ka=function(e){i(n,e);var t=f(n);function n(){return r(this,n),t.call(this,{code:"PING",payload:{id:Date.now(),active:1},ackRequired:!1})}return s(n)}(Mr),ba=function(){function e(t){var n=t.pingDelegate,a=t.sdkState,s=t.logger;r(this,e),this._pingTimer=null,this._pingTimeoutTimer=null,this.pingDelegate=n,this.sdkState=a,this._logger=s}return s(e,[{key:"isWaiting",get:function(){return!!this._pingTimeoutTimer}},{key:"ping",value:function(){var e,t=this,n=new ka;try{var r=null!==(e=this.sdkState.websocket.pongTimeout)&&void 0!==e?e:5e3;this._pingTimeoutTimer=setTimeout((function(){t._logger.debug("pinger.ping() timeout"),t.pingDelegate.error(null)}),r),this.pingDelegate.send(n),this._logger.debug("pinger.ping()")}catch(e){this._logger.debug("pinger.ping() error",e),this._pingTimeoutTimer&&(clearTimeout(this._pingTimeoutTimer),this._pingTimeoutTimer=null),this.pingDelegate.error(null)}return n}},{key:"pong",value:function(){this._logger.debug("pinger.pong()"),this._pingTimeoutTimer&&(clearTimeout(this._pingTimeoutTimer),this._pingTimeoutTimer=null)}},{key:"refreshTimer",value:function(){var e,t=this;this._logger.debug("pinger.refreshTimer()");var n=null!==(e=this.sdkState.websocket.pingInterval)&&void 0!==e?e:15e3;this.stop(),this._pingTimer=setInterval((function(){t.ping()}),n)}},{key:"start",value:function(){this._logger.debug("pinger.start()"),this.refreshTimer(),this.ping()}},{key:"stop",value:function(){this._logger.debug("pinger.stop()"),this._pingTimer&&(clearInterval(this._pingTimer),this._pingTimer=null),this._pingTimeoutTimer&&(clearTimeout(this._pingTimeoutTimer),this._pingTimeoutTimer=null)}}]),e}(),Ea=1048576,wa=function(){function e(){var t,n,a,s=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};r(this,e),this.emojiHash=s.emoji_hash||"",this.uploadSizeLimit=s.file_upload_size_limit?s.file_upload_size_limit*Ea:Number.MAX_SAFE_INTEGER,this.useReaction=!!s.use_reaction,this.applicationAttributes=null!==(t=s.application_attributes)&&void 0!==t?t:[],this.premiumFeatureList=null!==(n=s.premium_feature_list)&&void 0!==n?n:[],this.deviceTokenCache=this.applicationAttributes.includes("sdk_device_token_cache"),this.enabledChannelMemberShipHistory=this.applicationAttributes.includes("channel_membership_history"),this.allowSdkStatsUpload=null===(a=s.allow_sdk_log_ingestion)||void 0===a||a}return s(e,null,[{key:"payloadify",value:function(e){return{emoji_hash:e.emojiHash,file_upload_size_limit:e.uploadSizeLimit/Ea,application_attributes:e.applicationAttributes,premium_feature_list:e.premiumFeatureList,use_reaction:e.useReaction,allow_sdk_log_ingestion:e.allowSdkStatsUpload}}}]),e}(),Ca=function(){function e(t){r(this,e),this._iid="",this._iid=t}return s(e,null,[{key:"payloadify",value:function(e){return e?{}:null}}]),e}(),xa=function(e){i(n,e);var t=f(n);function n(e){var a,s=e.userId,i=e.metadata;return r(this,n),(a=t.call(this)).method=B.POST,a.path="".concat(qr,"/").concat(s,"/metadata"),a.params={metadata:i},a}return s(n)}(ne),Ta=function(e){i(n,e);var t=f(n);function n(e,a){var s;return r(this,n),(s=t.call(this,e,a)).metaData=a,s}return s(n)}(re),Sa=function(e){i(n,e);var t=f(n);function n(e){var a,s=e.userId,i=e.metadata,o=e.upsert;return r(this,n),(a=t.call(this)).method=B.PUT,a.path="".concat(qr,"/").concat(s,"/metadata"),a.params={metadata:i,upsert:o},a}return s(n)}(ne),Ia=function(e){i(n,e);var t=f(n);function n(e,a){var s;return r(this,n),(s=t.call(this,e,a)).metadata=a,s}return s(n)}(re),Na=function(e){i(n,e);var t=f(n);function n(e){var a,s=e.userId,i=e.metadataKey;return r(this,n),(a=t.call(this)).method=B.DELETE,a.path="".concat(qr,"/").concat(s,"/metadata/").concat(i),a}return s(n)}(ne),Aa=function(e){i(n,e);var t=f(n);function n(e){var a,s=e.userId;return r(this,n),(a=t.call(this)).method=B.DELETE,a.path="".concat(qr,"/").concat(s,"/metadata"),a}return s(n)}(ne),Ma=function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null,n=JSON.parse(JSON.stringify(e));return n._iid&&delete n._iid,t&&t(n),n},Oa=function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null,n=JSON.parse(JSON.stringify(e));return t&&t(n),n},Ua=function(e){return{do:function(t){e||t()},throw:function(t){if(!e)throw t}}};e.UserOnlineState=void 0,(Lr=e.UserOnlineState||(e.UserOnlineState={})).ONLINE="online",Lr.OFFLINE="offline",Lr.NON_AVAILABLE="nonavailable";var Ra,La=function(n){i(u,n);var a=f(u);function u(t,n){var s,i,o,c,l,h,d,f,p,v,m,g,y;return r(this,u),(s=a.call(this,t)).userId=null!==(o=null!==(i=n.guest_id)&&void 0!==i?i:n.user_id)&&void 0!==o?o:"",s.nickname=null!==(l=null!==(c=n.nickname)&&void 0!==c?c:n.name)&&void 0!==l?l:"",s.plainProfileUrl=null!==(d=null!==(h=n.profile_url)&&void 0!==h?h:n.image)&&void 0!==d?d:"",s.requireAuth=null!==(f=n.require_auth_for_profile_image)&&void 0!==f&&f,s.metaData=null!==(p=n.metadata)&&void 0!==p?p:{},s.connectionStatus=e.UserOnlineState.NON_AVAILABLE,D(e.UserOnlineState,n.is_online)?s.connectionStatus=n.is_online:L("boolean",n.is_online)&&(s.connectionStatus=n.is_online?e.UserOnlineState.ONLINE:e.UserOnlineState.OFFLINE),s.isActive=null===(v=n.is_active)||void 0===v||v,s.lastSeenAt=null!==(m=n.last_seen_at)&&void 0!==m?m:null,s.preferredLanguages=n.preferred_languages?_(n.preferred_languages):null,s.friendDiscoveryKey=null!==(g=n.friend_discovery_key)&&void 0!==g?g:null,s.friendName=null!==(y=n.friend_name)&&void 0!==y?y:null,s}return s(u,[{key:"profileUrl",get:function(){var e=ns.of(this._iid).sessionManager;return this.requireAuth?"".concat(this.plainProfileUrl,"?auth=").concat(e.ekey):this.plainProfileUrl}},{key:"serialize",value:function(){return Ma(this)}},{key:"_isValidMetaData",value:function(e){return!Array.isArray(e)&&Object.keys(e).length>0&&Object.keys(e).map((function(t){return e[t]})).every((function(e){return L("string",e)}))}},{key:"_applyMetaData",value:function(e){var t=this,n=arguments.length>1&&void 0!==arguments[1]&&arguments[1];Object.keys(e).forEach((function(r){n?delete t.metaData[r]:t.metaData[r]=e[r]}))}},{key:"createMetaData",value:function(e){return b(this,void 0,void 0,t().mark((function n(){var r,a,s,i,o,u,c;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return Ua(this._isValidMetaData(e)).throw(M.invalidParameters),r=ns.of(this._iid),a=r.sdkState,s=r.requestQueue,i=new xa({userId:a.userId,metadata:e}),t.next=5,s.send(i);case 5:return o=t.sent,u=o.as(Ta),c=u.metaData,this._applyMetaData(c),t.abrupt("return",this.metaData);case 9:case"end":return t.stop()}}),n,this)})))}},{key:"updateMetaData",value:function(e){var n=arguments.length>1&&void 0!==arguments[1]&&arguments[1];return b(this,void 0,void 0,t().mark((function r(){var a,s,i,o,u,c,l;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return Ua(this._isValidMetaData(e)).throw(M.invalidParameters),a=ns.of(this._iid),s=a.sdkState,i=a.requestQueue,o=new Sa({userId:s.userId,metadata:e,upsert:n}),t.next=5,i.send(o);case 5:return u=t.sent,c=u.as(Ia),l=c.metadata,this._applyMetaData(l),t.abrupt("return",this.metaData);case 9:case"end":return t.stop()}}),r,this)})))}},{key:"deleteMetaData",value:function(e){return b(this,void 0,void 0,t().mark((function n(){var r,a,s,i;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return Ua(L("string",e)).throw(M.invalidParameters),r=ns.of(this._iid),a=r.sdkState,s=r.requestQueue,i=new Na({userId:a.userId,metadataKey:e}),t.next=5,s.send(i);case 5:return this._applyMetaData((n={},u=!0,(o=k(o=e))in n?Object.defineProperty(n,o,{value:u,enumerable:!0,configurable:!0,writable:!0}):n[o]=u,n),!0),t.abrupt("return",this.metaData);case 7:case"end":return t.stop()}var n,o,u}),n,this)})))}},{key:"deleteAllMetaData",value:function(){return b(this,void 0,void 0,t().mark((function e(){var n,r,a,s;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n=ns.of(this._iid),r=n.sdkState,a=n.requestQueue,s=new Aa({userId:r.userId}),e.next=4,a.send(s);case 4:this.metaData={};case 5:case"end":return e.stop()}}),e,this)})))}}],[{key:"payloadify",value:function(e){return e?ee(Object.assign(Object.assign({},p(o(u),"payloadify",this).call(this,e)),{user_id:e.userId,nickname:e.nickname,profile_url:e.plainProfileUrl,require_auth_for_profile_image:e.requireAuth,metadata:e.metaData,is_online:e.connectionStatus,is_active:e.isActive,last_seen_at:e.lastSeenAt,preferred_languages:e.preferredLanguages,friend_discovery_key:e.friendDiscoveryKey,friend_name:e.friendName})):null}}]),u}(Ca),Da=function(e){i(n,e);var t=f(n);function n(e){var a,s=e.userProfile;return r(this,n),(a=t.call(this)).userProfile=s,a}return s(n)}($),Pa=function(){function e(t,n){var a,s,i,o,u,c,l,h,d,f,p,v,_,m;r(this,e),this._iid=t,this.appInfo=new wa(n),this.user=new La(t,n),this.connectedAt=null!==(a=n.login_ts)&&void 0!==a?a:0,this.firstConnectedAt=0,this.pingInterval=null!==(s=n.ping_interval)&&void 0!==s?s:15e3,this.pongTimeout=null!==(i=n.pong_timeout)&&void 0!==i?i:5e3,this.reconnectInterval=null!==(u=null===(o=n.reconnect)||void 0===o?void 0:o.interval)&&void 0!==u?u:3e3,this.reconnectMaxInterval=null!==(l=null===(c=n.reconnect)||void 0===c?void 0:c.max_interval)&&void 0!==l?l:6e4,this.reconnectRetryCount=null!==(d=null===(h=n.reconnect)||void 0===h?void 0:h.retry_cnt)&&void 0!==d?d:5,this.reconnectIntervalMultiple=null!==(p=null===(f=n.reconnect)||void 0===f?void 0:f.mul)&&void 0!==p?p:2,this.maxUnreadCountOnSuperGroup=null!==(v=n.max_unread_cnt_on_super_group)&&void 0!==v?v:100,this.profileImageEncryption=!!n.profile_image_encryption,this.concurrentCallLimit=null!==(_=n.concurrent_call_limit)&&void 0!==_?_:5,this.backOffDelay=null!==(m=n.back_off_delay)&&void 0!==m?m:100}return s(e,[{key:"apply",value:function(){var e=this.reconnectInterval,t=this.reconnectMaxInterval,n=this.reconnectIntervalMultiple,r=ns.of(this._iid);r.sdkState.websocket.pingInterval=1e3*this.pingInterval,r.sdkState.websocket.pongTimeout=1e3*this.pongTimeout,r.sdkState.websocket.reconnectMaxRetry=this.reconnectRetryCount,r.sdkState.websocket.reconnectRetryStrategy={calcTimeout:function(r){return r>0?1e3*Math.min(e*Math.pow(n,r-1),t):10}},r.appInfo=this.appInfo,r.sessionManager.currentUser=this.user,r.connectedAt=this.connectedAt,this.firstConnectedAt||(r.firstConnectedAt=this.connectedAt),r.maxSuperGroupChannelUnreadCount=this.maxUnreadCountOnSuperGroup,r.concurrentCallLimit=this.concurrentCallLimit,r.backOffDelay=this.backOffDelay,r.dispatcher.dispatch(new Da({userProfile:this}))}}],[{key:"payloadify",value:function(e){return Object.assign(Object.assign(Object.assign({},La.payloadify(e.user)),wa.payloadify(e.appInfo)),{login_ts:e.connectedAt,ping_interval:e.pingInterval,pong_timeout:e.pongTimeout,reconnect:{interval:e.reconnectInterval,max_interval:e.reconnectMaxInterval,retry_cnt:e.reconnectRetryCount,mul:e.reconnectIntervalMultiple},max_unread_cnt_on_super_group:e.maxUnreadCountOnSuperGroup,profile_image_encryption:e.profileImageEncryption,concurrent_call_limit:e.concurrentCallLimit,back_off_delay:e.backOffDelay})}}]),e}(),Fa=function(e){i(a,e);var n=f(a);function a(e,t,s){var i,o;return r(this,a),(i=n.call(this,e,t,s)).error=null,i.userProfile=new Pa(e,s),i.deviceTokenLastDeletedAt=s.device_token_last_deleted_at,i.key=s.key,i.ekey=null!==(o=s.ekey)&&void 0!==o?o:"",i.error=s.error?new M(s):null,i}return s(a,[{key:"applyTo",value:function(e){return b(this,void 0,void 0,t().mark((function n(){var r,a;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(this.error){t.next=12;break}if(!(r=ns.of(e))){t.next=9;break}return a=r.sessionManager,t.next=6,a.login(this);case 6:this.userProfile.apply(),t.next=10;break;case 9:throw M.lostInstance;case 10:t.next=13;break;case 12:throw this.error;case 13:case"end":return t.stop()}}),n,this)})))}}],[{key:"asError",value:function(e){return new a(null,"LOGI",Object.assign({user_id:null,error:!0},e))}}]),a}(le),Ga=function(e){i(n,e);var t=f(n);function n(e){var a,s=e.request,i=void 0===s||s,o=e.features,u=void 0===o?{}:o,c=e.options,l=void 0===c?{}:c;return r(this,n),(a=t.call(this)).request=i,a.features=Object.assign({localCache:!0},u),a.options=Object.assign({ingestion:!0},l),a}return s(n)}($),Ha=function(e){i(a,e);var n=f(a);function a(e,t){var s,i=t.sdkState,o=t.cacheContext,u=t.connectionHandlers,c=t.sessionManager,l=t.websocketClient,h=t.dispatcher,d=t.logger,f=t.entryState,p=void 0===f?new ya:f;return r(this,a),(s=n.call(this))._currentState=null,s._loginTimer=null,s._unresolvedLogi=null,s._stateUpdatedAt=0,s._connectingAt=0,s._connectionRequestQueue=[],s._iid=e,s.sdkState=i,s.cacheContext=o,s.connectionHandlers=u,s._sessionManager=c,s._websocketClient=l,s._dispatcher=h,s._logger=d,s._currentState=p,s.sdkState.websocket.pingerDisabled||(s._pinger=new ba({pingDelegate:{send:function(e){return s._websocketClient.send(e)},error:function(e){return s._websocketClient.error(e)}},sdkState:s.sdkState,logger:d})),s._websocketClient.on("open",(function(){s._tryResolveConnectionRequest()})).on("message",(function(e){if("LOGI"===e.code)s.clearLoginTimer(),s._dispatcher.dispatch(e.as(Fa))})).on("ping-refresh",(function(){var e;return null===(e=s._pinger)||void 0===e?void 0:e.refreshTimer()})).on("pong",(function(){var e;return null===(e=s._pinger)||void 0===e?void 0:e.pong()})).on("error",(function(){var e;return null===(e=s._pinger)||void 0===e?void 0:e.stop()})).on("close",(function(){return s._rejectConnectionRequest(M.networkError)})),s._dispatcher.on((function(e){e instanceof Fa&&(s._unresolvedLogi=e,s._tryResolveConnectionRequest())})),s}return s(a,[{key:"currentState",get:function(){return this._currentState}},{key:"hasSession",get:function(){return this._sessionManager.auth.hasSession}},{key:"changeState",value:function(e,n){return b(this,void 0,void 0,t().mark((function r(){return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(!(n>=this._stateUpdatedAt)){t.next=8;break}return this._currentState=e,this._stateUpdatedAt=n,this._dispatcher.dispatch(new Dr({stateType:e.type})),this._logger.debug("connection state changes to ".concat(e.name)),t.next=7,this._currentState.run(this);case 7:return t.abrupt("return",!0);case 8:return t.abrupt("return",!1);case 9:case"end":return t.stop()}}),r,this)})))}},{key:"_tryResolveConnectionRequest",value:function(){var e;return b(this,void 0,void 0,t().mark((function n(){var r,a;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(r=this._unresolvedLogi,!this._websocketClient.isOpen||!r){t.next=18;break}if(this._unresolvedLogi=null,r.error){t.next=15;break}return t.next=6,r.applyTo(this._iid);case 6:a=r.userProfile,this._enableStatLog({request:a.appInfo.applicationAttributes.includes("allow_sdk_request_log_publish"),features:{localCache:a.appInfo.applicationAttributes.includes("allow_sdk_feature_local_cache_log_publish")},options:{ingestion:a.appInfo.allowSdkStatsUpload}}),this._statLogConnection(null),null===(e=this._pinger)||void 0===e||e.start(),this._connectionRequestQueue.forEach((function(e){return e.resolve()})),this._connectionRequestQueue=[],this.sdkState.appState="foreground",t.next=18;break;case 15:this._sessionManager.auth.authToken=null,(r.error.isSessionKeyExpiredError||r.error.isSessionTokenExpiredError)&&this._dispatcher.dispatch(new se),this._rejectConnectionRequest(r.error);case 18:case"end":return t.stop()}}),n,this)})))}},{key:"_rejectConnectionRequest",value:function(e){var t;if(null===(t=this._pinger)||void 0===t||t.stop(),this.clearLoginTimer(),this._connectionRequestQueue.length>0){var n=this._connectionRequestQueue;this._connectionRequestQueue=[],n.forEach((function(t){return t.reject(e)})),this._statLogConnection(e)}}},{key:"_url",value:function(){var e,t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"",n=this.sdkState,r=n.appId,a=n.appVersion,s=n.userId,i=n.extensions,o=this.cacheContext.localCacheEnabled,u=this._sessionManager.auth,c=null===(e=this.sdkState.websocket)||void 0===e?void 0:e.compression,l=i.sb_syncmanager?"s".concat(i.sb_syncmanager):"",h=i.sb_uikit?"u".concat(i.sb_uikit):"",d="JS/c".concat(C.SDK_VERSION,"/").concat(l,"/").concat(h);return"".concat(this.sdkState.websocket.host,"/?p=JS&pv=").concat(encodeURIComponent(C.OS_VERSION),"&sv=").concat(encodeURIComponent(C.SDK_VERSION),"&ai=").concat(r).concat(a?"&av=".concat(a):"").concat(u.hasSession?"&key=".concat(encodeURIComponent(u.sessionKey)):"&user_id=".concat(encodeURIComponent(s),"&access_token=").concat(encodeURIComponent(t)),"&pmce=").concat(c?1:0,"&active=1&device_token_types=").concat(encodeURIComponent(["gcm","huawei","apns"].join(",")),"&SB-User-Agent=").concat(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")}},{key:"_enableStatLog",value:function(e){var t=e.request,n=e.features,r=e.options,a=void 0===r?{}:r;this._dispatcher.dispatch(new Ga({request:t,features:n,options:a}))}},{key:"_statLogConnection",value:function(e){this._dispatcher.dispatch(new ie(new oe({type:te.WEBSOCKET_CONNECT,data:{host_url:this.sdkState.websocket.host,success:!e,latency:Date.now()-this._connectingAt,error_code:null==e?void 0:e.code,error_description:null==e?void 0:e.message}})))}},{key:"connect",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"";return b(this,void 0,void 0,t().mark((function n(){var r,a,s=this;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return r=this._url(e),a=new Ur,this._connectionRequestQueue.push(a),1===this._connectionRequestQueue.length&&(this._connectingAt=Date.now(),this._loginTimer=setTimeout((function(){s._loginTimer=null,s._dispatcher.dispatch(Fa.asError(M.loginTimeout))}),this.sdkState.websocket.responseTimeout),e&&(this._sessionManager.auth.authToken=e),this._websocketClient.connect(r)),t.abrupt("return",a.promise);case 5:case"end":return t.stop()}}),n,this)})))}},{key:"cancelConnectForRetry",value:function(){this._dispatcher.dispatch(Fa.asError(M.connectionRenew))}},{key:"disconnect",value:function(){return b(this,void 0,void 0,t().mark((function e(){return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this._websocketClient.disconnect();case 2:case"end":return e.stop()}}),e,this)})))}},{key:"logout",value:function(){return b(this,void 0,void 0,t().mark((function e(){return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return this.sdkState.userId=null,this._unresolvedLogi=null,e.next=4,this._sessionManager.clear();case 4:return e.next=6,this.disconnect();case 6:case"end":return e.stop()}}),e,this)})))}},{key:"clearLoginTimer",value:function(){this._loginTimer&&(clearTimeout(this._loginTimer),this._loginTimer=null)}}]),a}(J),qa=function(){function e(t,n){var a=n.sdkState,s=n.cacheContext,i=n.connectionHandlers,o=n.sessionManager,u=n.websocketClient,c=n.dispatcher,l=n.logger,h=n.disableWebSocketCloseEventHandling,d=void 0!==h&&h;r(this,e),this._context=null,this._disableWebSocketCloseEventHandling=!1,this._externalCalledWebSocketClose=!1,this._logger=l,this._disableWebSocketCloseEventHandling=d,this._context=new Ha(t,{sdkState:a,cacheContext:s,connectionHandlers:i,sessionManager:o,websocketClient:u,dispatcher:c,logger:l}),this._sdkState=a,this._sessionManager=o,this._websocketClient=u}return s(e,[{key:"_registerEventDispatcher",value:function(){var e=this;this._disableWebSocketCloseEventHandling||(this._clearEventDispatcher(),this._sessionEventDispatcherContext=this._sessionManager.on("refresh-authtoken",(function(){e.isConnected||(e._logger.debug("try reconnect by session token refresh"),e.reconnect())})).on("refresh",(function(){e.isConnecting||e.isConnected||(e._logger.debug("try reconnect by session key refresh"),e.reconnect())})),this._websocketEventDispatcherContext=this._websocketClient.on("close",(function(){"foreground"!==e._sdkState.appState||e._externalCalledWebSocketClose||e._sessionManager.isRefreshingAuthToken||(e._logger.debug("try reconnect by websocket connection closed"),e.reconnect())})))}},{key:"_clearEventDispatcher",value:function(){this._sessionEventDispatcherContext&&(this._sessionEventDispatcherContext.close(),this._sessionEventDispatcherContext=null),this._websocketEventDispatcherContext&&(this._websocketEventDispatcherContext.close(),this._websocketEventDispatcherContext=null)}},{key:"isConnected",get:function(){return this._context.currentState.type===Nr.CONNECTED}},{key:"isConnecting",get:function(){var e=this._context.currentState;return e.type===Nr.CONNECTING||e.type===Nr.RECONNECTING}},{key:"connect",value:function(e){return b(this,void 0,void 0,t().mark((function n(){var r;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return r=this._context.currentState,this._externalCalledWebSocketClose=!1,t.next=4,r.onConnect(this._context,e);case 4:this._registerEventDispatcher();case 5:case"end":return t.stop()}}),n,this)})))}},{key:"reconnect",value:function(){return b(this,void 0,void 0,t().mark((function e(){var n;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n=this._context.currentState,this._externalCalledWebSocketClose=!1,e.next=4,n.onReconnect(this._context,{});case 4:case"end":return e.stop()}}),e,this)})))}},{key:"resetAndReconnect",value:function(){return b(this,void 0,void 0,t().mark((function e(){var n;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n=this._context.currentState,this._externalCalledWebSocketClose=!1,e.next=4,n.onReconnect(this._context,{resetReconnectCount:!0});case 4:case"end":return e.stop()}}),e,this)})))}},{key:"background",value:function(){return b(this,void 0,void 0,t().mark((function e(){var n;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n=this._context.currentState,this._externalCalledWebSocketClose=!0,e.next=4,n.onDisconnect(this._context,{autoReconnect:!1});case 4:case"end":return e.stop()}}),e,this)})))}},{key:"disconnect",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:null;return b(this,void 0,void 0,t().mark((function n(){var r;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return r=this._context.currentState,t.next=3,r.onDisconnect(this._context,{error:e,autoReconnect:!0});case 3:case"end":return t.stop()}}),n,this)})))}},{key:"disconnectWebSocket",value:function(){return b(this,void 0,void 0,t().mark((function e(){var n;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n=this._context.currentState,this._externalCalledWebSocketClose=!0,e.next=4,n.onDisconnectWebSocket(this._context);case 4:case"end":return e.stop()}}),e,this)})))}},{key:"logout",value:function(){return b(this,void 0,void 0,t().mark((function e(){var n;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n=this._context.currentState,this._clearEventDispatcher(),e.next=4,n.onLogout(this._context);case 4:case"end":return e.stop()}}),e,this)})))}}]),e}(),ja=function(e){i(n,e);var t=f(n);function n(e){var a,s,i,o,u,c=e.type,l=e.data,h=e.ts,d=void 0===h?Date.now():h;return r(this,n),(a=t.call(this,{type:c,data:l,ts:d})).date=new Date(d),a.key="".concat((s=a.date,i=s.getFullYear(),o=String(s.getMonth()+1).padStart(2,"0"),u=String(s.getDate()).padStart(2,"0"),"".concat(i).concat(o).concat(u)),"_").concat(c),a}return s(n)}(oe),za=function(e){i(n,e);var t=f(n);function n(e){var a,s=e.deviceId,i=e.statLogs;return r(this,n),(a=t.call(this)).method=B.POST,a.path="".concat($r),a.params={device_id:s,log_entries:i.map((function(e){return oe.payloadify(e)}))},a}return s(n)}(ne),Va=function e(t,r){if(null!==t&&null!==r){var a,s=Object.keys(t),i=Object.keys(r),o={},u=y(_(new Set([].concat(s,i))));try{for(u.s();!(a=u.n()).done;){var c=a.value,l=n(t[c]),h=n(r[c]);"undefined"===l?o[c]=r[c]:"undefined"===h?o[c]=t[c]:l!==h?o[c]=r[c]:"object"===l&&t[c]&&r[c]?o[c]=e(t[c],r[c]):o[c]=r[c]}}catch(e){u.e(e)}finally{u.f()}return o}return r};!function(e){e[e.PENDING=0]="PENDING",e[e.COLLECT_ONLY=1]="COLLECT_ONLY",e[e.ENABLED=2]="ENABLED",e[e.DISABLED=3]="DISABLED"}(Ra||(Ra={}));var Ba,Qa=function(e){i(a,e);var n=f(a);function a(e){var t,s=e.cacheContext,i=e.requestQueue,o=e.dispatcher,u=e.baseLimit,c=void 0===u?100:u,l=e.maxLimit,h=void 0===l?1e3:l,d=e.minLimit,f=void 0===d?10:d;return r(this,a),(t=n.call(this)).queue=[],t.enabledState=Ra.PENDING,t.isFlushing=!1,t.generation=1,t.lastFlushedAt=0,t.commandEventContext=null,t._collectRequestStat=!0,t._collectFeatureLocalCacheStat=!0,t.deviceId=Y(),t.cacheContext=s,t.requestQueue=i,t.dispatcher=o,t.baseLimit=c,t.limit=c,t.maxLimit=h,t.minLimit=f,t}return s(a,[{key:"isEnabled",get:function(){return this.enabledState===Ra.ENABLED}},{key:"_arrangeStat",value:function(){var e=[];this._collectRequestStat&&e.push.apply(e,_(this.queue.filter((function(e){return e.type===te.API_RESULT||e.type===te.WEBSOCKET_CONNECT})))),this._collectFeatureLocalCacheStat&&e.push.apply(e,_(this.queue.filter((function(e){return e.type===te.FEATURE_LOCALCACHE})))),this.queue=e}},{key:"_save",value:function(){return b(this,void 0,void 0,t().mark((function e(){return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(this.enabledState!==Ra.ENABLED){e.next=4;break}return e.next=3,this.cacheContext.preference.set(this.key,{deviceId:this.deviceId,statLogs:this.queue.map((function(e){return oe.payloadify(e)})),generation:this.generation++,lastFlushedAt:this.lastFlushedAt});case 3:this.dispatch("save",_(this.queue));case 4:case"end":return e.stop()}}),e,this)})))}},{key:"_flush",value:function(){return b(this,void 0,void 0,t().mark((function e(){var n,r,a,s;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!this.isEnabled){e.next=34;break}if(this.isFlushing){e.next=34;break}if(this.isFlushing=!0,e.prev=3,this._arrangeStat(),n=this.queue.filter((function(e){if(e instanceof ja){var t=new Date,n=[e.date.getFullYear(),t.getFullYear()],r=n[0],a=n[1];if(r0)){e.next=16;break}return s=new za({deviceId:this.deviceId,statLogs:a}),e.next=12,this.requestQueue.send(s);case 12:return this.dispatch("flush",a),this.queue=[].concat(_(n),_(r)).slice(a.length),e.next=16,this._save();case 16:this.limit=this.baseLimit,this.lastFlushedAt=Date.now(),e.next=31;break;case 20:if(e.prev=20,e.t0=e.catch(3),!(e.t0 instanceof M)){e.next=30;break}if(e.t0.code!==E.STAT_LOG_NOT_ALLOWED){e.next=29;break}return e.next=26,this.clear();case 26:this.enabledState=Ra.DISABLED,e.next=30;break;case 29:e.t0.code===E.STAT_UPLOAD_NOT_ALLOWED&&(this.enabledState=Ra.COLLECT_ONLY);case 30:this.limit=this.limit+20;case 31:return e.prev=31,this.isFlushing=!1,e.finish(31);case 34:case"end":return e.stop()}}),e,this,[[3,20,31,34]])})))}},{key:"init",value:function(e){return b(this,void 0,void 0,t().mark((function n(){var r,a,s=this;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return this.key=e,t.next=3,this.cacheContext.preference.get(this.key);case 3:if(!(r=t.sent)){t.next=15;break}if(this.deviceId=r.deviceId,this.queue=r.statLogs.map((function(e){return new oe({type:e.stat_type,ts:e.ts,data:e.data})})),this.generation=r.generation,this.lastFlushedAt=r.lastFlushedAt,!(Date.now()-this.lastFlushedAt>=108e5&&this.queue.length>=this.minLimit)){t.next=15;break}return a=Math.min(Math.floor(18e4*Math.random()),100),t.next=13,sa(a);case 13:return t.next=15,this._flush();case 15:this.commandEventContext||(this.commandEventContext=this.dispatcher.on((function(e){if(e instanceof ie){var t=e.statLog;s.put(t)}else if(e instanceof Ga){var n=e.request,r=e.features,a=e.options;s._collectRequestStat=n,s._collectFeatureLocalCacheStat=null==r?void 0:r.localCache,s._arrangeStat(),s._collectRequestStat||s._collectFeatureLocalCacheStat?s.enabledState=a.ingestion?Ra.ENABLED:Ra.COLLECT_ONLY:s.enabledState=Ra.DISABLED,s.isEnabled?s.queue.length>=s.limit&&s._flush():s.clear()}})));case 16:case"end":return t.stop()}}),n,this)})))}},{key:"put",value:function(e){return b(this,void 0,void 0,t().mark((function n(){var r,a,s;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(this.enabledState===Ra.DISABLED){t.next=7;break}return e instanceof ja?this._collectFeatureLocalCacheStat&&(r=this.queue.filter((function(t){return t instanceof ja&&t.key===e.key})),a=v(r,1),(s=a[0])?s.data=Va(s.data,e.data):this.queue.push(e)):this._collectRequestStat&&this.queue.push(e),t.next=4,this._save();case 4:if(!(this.queue.length>=this.limit)){t.next=7;break}return t.next=7,this._flush();case 7:case"end":return t.stop()}}),n,this)})))}},{key:"clear",value:function(){return b(this,void 0,void 0,t().mark((function e(){return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return this.queue=[],this.generation=1,e.next=4,this._save();case 4:case"end":return e.stop()}}),e,this)})))}},{key:"close",value:function(){this.commandEventContext&&(this.commandEventContext.close(),this.commandEventContext=null)}}]),a}(J);e.LogLevel=void 0,(Ba=e.LogLevel||(e.LogLevel={}))[Ba.NONE=0]="NONE",Ba[Ba.VERBOSE=1]="VERBOSE",Ba[Ba.DEBUG=2]="DEBUG",Ba[Ba.INFO=3]="INFO",Ba[Ba.WARN=4]="WARN",Ba[Ba.ERROR=5]="ERROR";var Ka,Wa,Ya,Za,Ja,Xa,$a,es=function(){function t(){r(this,t),this.level=e.LogLevel.WARN}return s(t,[{key:"verbose",value:function(){if(this.level<=e.LogLevel.VERBOSE){for(var t,n=arguments.length,r=new Array(n),a=0;a0&&L("number",i)&&(this.key=a,this.userIds=s,this.updatedAt=i);var o,u={},c=y(this.userIds);try{for(c.s();!(o=c.n()).done;){u[o.value]=this.updatedAt}}catch(e){c.e(e)}finally{c.f()}this._version=u}return s(t,[{key:"isEmpty",get:function(){return 0===this.userIds.length}},{key:"applyEvent",value:function(t){if(t.key===this.key&&this.updatedAt<=t.updatedAt){if(!this._version[t.userId]||this._version[t.userId]<=t.updatedAt){var n=this.userIds.indexOf(t.userId);switch(t.operation){case e.ReactionEventOperation.ADD:n<0&&this.userIds.push(t.userId);break;case e.ReactionEventOperation.DELETE:n>=0&&this.userIds.splice(n,1)}this._version[t.userId]=t.updatedAt}this.updatedAt=Math.max(this.updatedAt,t.updatedAt)}}}],[{key:"payloadify",value:function(e){return e?ee({key:e.key,user_ids:e.userIds,updated_at:e.updatedAt}):null}}]),t}(),ps=function(){function e(t){r(this,e),this.key=t.key,this.value=F("string",t.value)?_(t.value):[]}return s(e,null,[{key:"payloadify",value:function(e){var t;return e?ee({key:e.key,value:null!==(t=e.value)&&void 0!==t?t:[]}):null}}]),e}(),vs=function(){function e(t){r(this,e),this.url=null,this.secureUrl=null,this.type=null,this.width=0,this.height=0,this.alt=null,this.url=t.url,t.hasOwnProperty("secure_url")&&(this.secureUrl=t.secure_url),t.hasOwnProperty("type")&&(this.type=t.type),t.hasOwnProperty("width")&&(this.width=t.width),t.hasOwnProperty("height")&&(this.height=t.height),t.hasOwnProperty("alt")&&(this.alt=t.alt)}return s(e,null,[{key:"payloadify",value:function(e){var t,n;return e?ee({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}(),_s=function(){function e(t){r(this,e),this.title=null,this.url=null,this.description=null,this.defaultImage=null,t.hasOwnProperty("og:title")&&(this.title=t["og:title"]),t.hasOwnProperty("og:url")&&(this.url=t["og:url"]),t.hasOwnProperty("og:description")&&(this.description=t["og:description"]),t.hasOwnProperty("og:image")&&(this.defaultImage=new vs(t["og:image"]))}return s(e,null,[{key:"payloadify",value:function(e){return e?ee({"og:title":e.title,"og:url":e.url,"og:description":e.description,"og:image":e.defaultImage?vs.payloadify(e.defaultImage):null}):null}}]),e}(),ms=function(){function e(t){var n,a;r(this,e),this.name=null,this.volume=0,this.name=null!==(n=t.name)&&void 0!==n?n:"default",this.volume=null!==(a=t.volume)&&void 0!==a?a:1}return s(e,[{key:"serialize",value:function(){return{name:this.name,volume:this.volume}}}],[{key:"payloadify",value:function(e){return e?ee({name:e.name,volume:e.volume}):null}}]),e}();e.ChannelType=void 0,(us=e.ChannelType||(e.ChannelType={})).BASE="base",us.GROUP="group",us.OPEN="open",e.Role=void 0,(cs=e.Role||(e.Role={})).OPERATOR="operator",cs.NONE="none",e.ScheduledStatus=void 0,(ls=e.ScheduledStatus||(e.ScheduledStatus={})).PENDING="pending",ls.SENT="sent",ls.FAILED="failed",ls.CANCELED="canceled",function(e){e.PENDING="pending",e.IN_QUEUE="in_queue",e.SENT="sent",e.FAILED="failed",e.CANCELED="canceled",e.REMOVED="removed"}(hs||(hs={}));var gs,ys=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"}},ks=function(t){i(a,t);var n=f(a);function a(t,s){var i,o,u,c,l,h,d,f,p,v,_,m,g,y,k,b;r(this,a),(i=n.call(this,t)).channelUrl=null,i.channelType=e.ChannelType.BASE,i.messageId=0,i.parentMessageId=null,i.parentMessage=null,i.silent=!1,i.isOperatorMessage=!1,i.messageType=e.MessageType.BASE,i.data=null,i.customType=null,i.mentionType=null,i.mentionedUsers=[],i.mentionedUserIds=[],i.mentionedMessageTemplate=null,i.threadInfo=null,i.reactions=[],i.metaArrays=[],i.ogMetaData=null,i.appleCriticalAlertOptions=null,i.createdAt=0,i.updatedAt=0,i.scheduledInfo=null,i.extendedMessage={},i._isContinuousMessages=!1,i._scheduledStatus=null,i.messageId=null!==(u=null!==(o=s.msg_id)&&void 0!==o?o:s.message_id)&&void 0!==u?u:0,i.channelUrl=s.channel_url,i.channelType=D(e.ChannelType,s.channel_type)?s.channel_type:e.ChannelType.GROUP,s.channel&&(s.channel.channel_url&&(i.channelUrl=s.channel.channel_url),s.channel.channel_type&&(i.channelType=s.channel.channel_type)),i.parentMessageId=null!==(c="string"==typeof s.parent_message_id?parseInt(s.parent_message_id):s.parent_message_id)&&void 0!==c?c:0,i.data=null!==(l=s.data)&&void 0!==l?l:"",i.customType=null!==(h=s.custom_type)&&void 0!==h?h:"",i.mentionType=D(e.MentionType,s.mention_type)?s.mention_type:null;var E=s.mentioned_users;i.mentionedUsers=E?E.map((function(e){return new La(i._iid,e)})):null;var w=s.mentioned_user_ids;i.mentionedUserIds=null!=w?w:null,i.mentionedUsers&&!i.mentionedUserIds&&(i.mentionedUserIds=i.mentionedUsers.map((function(e){return e.userId}))),i.mentionedMessageTemplate=null!==(d=s.mentioned_message_template)&&void 0!==d?d:"",i.threadInfo=s.thread_info?new os(i._iid,s.thread_info):null,i.reactions=s.reactions?s.reactions.map((function(e){return new fs(e)})):[];for(var C=null!==(f=s.metaarray)&&void 0!==f?f:{},x=null!==(p=s.metaarray_key_order)&&void 0!==p?p:Object.keys(C).sort((function(e,t){return e.localeCompare(t)})),T=0;T=t)return this.parentMessage=e,!0}return!1}}],[{key:"payloadify",value:function(e){var t,n,r,s;return e?ee(Object.assign(Object.assign({},p(o(a),"payloadify",this).call(this,e)),{channel_url:e.channelUrl,channel_type:e.channelType,message_id:e.messageId,type:ys(e.messageType),parent_message_id:e.parentMessageId,data:e.data,custom_type:e.customType,mention_type:e.mentionType,mentioned_user_ids:e.mentionedUserIds,mentioned_users:null===(t=e.mentionedUsers)||void 0===t?void 0:t.map((function(e){return La.payloadify(e)})),mentioned_message_template:e.mentionedMessageTemplate,thread_info:e.threadInfo?os.payloadify(e.threadInfo):null,reactions:e.reactions.map((function(e){return fs.payloadify(e)})),sorted_metaarray:null===(n=e.metaArrays)||void 0===n?void 0:n.map((function(e){return ps.payloadify(e)})),og_tag:_s.payloadify(e.ogMetaData),silent:e.silent,is_op_msg:e.isOperatorMessage,apple_critical_alert_options:ms.payloadify(e.appleCriticalAlertOptions),created_at:e.createdAt,updated_at:e.updatedAt,scheduled_message_id:null===(r=e.scheduledInfo)||void 0===r?void 0:r.scheduledMessageId,scheduled_at:null===(s=e.scheduledInfo)||void 0===s?void 0:s.scheduledAt,scheduled_status:e._scheduledStatus,extended_message:e.extendedMessage})):null}}]),a}(Ca),bs=function(t){i(a,t);var n=f(a);function a(t,s){var i;return r(this,a),(i=n.call(this,t,s)).role=null,i.isBlockedByMe=!1,i.role=D(e.Role,s.role)?s.role:e.Role.NONE,s.hasOwnProperty("is_blocked_by_me")&&(i.isBlockedByMe=s.is_blocked_by_me),i}return s(a,null,[{key:"payloadify",value:function(e){return e?ee(Object.assign(Object.assign({},p(o(a),"payloadify",this).call(this,e)),{role:e.role,is_blocked_by_me:e.isBlockedByMe})):null}}]),a}(La),Es=function(t){i(a,t);var n=f(a);function a(t,s){var i,o,u,c,l;if(r(this,a),(i=n.call(this,t,s)).sender=null,i.reqId="",i.replyToChannel=!1,i.sendingStatus=null,i.errorCode=0,i.sender=s.user?new bs(i._iid,s.user):s.sender_id,i.reqId=null!==(u=null!==(o=s.req_id)&&void 0!==o?o:s.request_id)&&void 0!==u?u:"",i.replyToChannel=null!==(c=s.is_reply_to_channel)&&void 0!==c&&c,s.request_state&&D(e.SendingStatus,s.request_state)&&(i.sendingStatus=s.request_state),!i.sendingStatus)if(i.messageId>0)i.sendingStatus=e.SendingStatus.SUCCEEDED;else if(i.scheduledInfo)switch(i._scheduledStatus=s.scheduled_status,s.scheduled_status){case hs.SENT:case hs.IN_QUEUE:i.sendingStatus=e.SendingStatus.SUCCEEDED;break;case hs.PENDING:i.sendingStatus=e.SendingStatus.SCHEDULED;break;case hs.FAILED:case hs.REMOVED:i.sendingStatus=e.SendingStatus.FAILED;break;case hs.CANCELED:i.sendingStatus=e.SendingStatus.CANCELED}else i.sendingStatus=e.SendingStatus.PENDING;return i.errorCode=null!==(l=s.error_code)&&void 0!==l?l:0,i}return s(a,[{key:"isResendable",get:function(){return this.sendingStatus===e.SendingStatus.FAILED&&((t=this.errorCode)>0&&O.indexOf(t)>=0);var t}},{key:"isIdentical",value:function(e){return this.messageId>0&&e.messageId>0?this.messageId===e.messageId:this.reqId===e.reqId}}],[{key:"payloadify",value:function(e){return e?ee(Object.assign(Object.assign({},p(o(a),"payloadify",this).call(this,e)),{user:bs.payloadify(e.sender),req_id:e.reqId,is_reply_to_channel:e.replyToChannel,request_state:e.sendingStatus,error_code:e.errorCode})):null}}]),a}(ks),ws=function(){function e(t){var n,a;r(this,e),this.url=null,this.width=0,this.height=0,this.realWidth=0,this.realHeight=0,this.url=t.url,this.width=t.width,this.height=t.height,this.realWidth=null!==(n=t.real_width)&&void 0!==n?n:t.width,this.realHeight=null!==(a=t.real_height)&&void 0!==a?a:t.height}return s(e,[{key:"plainUrl",get:function(){return this.url.split("?auth=")[0]}}],[{key:"payloadify",value:function(e){return e?ee({url:"",width:e.maxWidth,height:e.maxHeight,real_width:0,real_height:0}):null}}]),e}(),Cs={prevResultSize:0,nextResultSize:0,isInclusive:!1,reverse:!1,messageTypeFilter:e.MessageTypeFilter.ALL,customTypesFilter:null,senderUserIdsFilter:null,includeReactions:!1,includeMetaArray:!1,includeParentMessageInfo:!1},xs=function(t){return L("number",t.prevResultSize)&&L("number",t.nextResultSize)&&L("boolean",t.isInclusive)&&L("boolean",t.reverse)&&L("string",t.messageTypeFilter)&&D(e.MessageTypeFilter,t.messageTypeFilter)&&F("string",t.customTypesFilter,!0)&&F("string",t.senderUserIdsFilter,!0)&&L("boolean",t.includeMetaArray)&&L("boolean",t.includeReactions)&&L("boolean",t.includeParentMessageInfo)},Ts=function(n){i(u,n);var a=f(u);function u(t,n){var s,i,o,c,l;if(r(this,u),(s=a.call(this,t,n)).message=null,s.translations={},s.message=null!==(i=n.message)&&void 0!==i?i:"",s.messageType=e.MessageType.ADMIN,s.translations=null!==(o=n.translations)&&void 0!==o?o:{},n.parent_message_info){var h=n.parent_message_info,d=Object.assign(Object.assign({},h),{message_id:s.parentMessageId,channel_url:s.channelUrl,channel_type:s.channelType,file:h.file,url:null===(c=h.file)||void 0===c?void 0:c.url,require_auth:null===(l=h.file)||void 0===l?void 0:l.require_auth});s.parentMessage=Ds(t,d)}return s}return s(u,[{key:"getThreadedMessagesByTimestamp",value:function(e,n){return b(this,void 0,void 0,t().mark((function r(){var a,s;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return a=Object.assign(Object.assign({},Cs),n),Ua(this.messageId>0&&L("number",e)&&xs(a)).throw(M.invalidParameters),s=vi.of(this._iid),t.next=5,s.getThreadedMessagesByTimestamp(this,e,a);case 5:return t.abrupt("return",t.sent);case 6:case"end":return t.stop()}}),r,this)})))}}],[{key:"payloadify",value:function(e){return e?ee(Object.assign(Object.assign({},p(o(u),"payloadify",this).call(this,e)),{message:e.message,translations:e.translations,parent_message_info:Ls(e.parentMessage)})):null}}]),u}(ks),Ss=function(){function e(t){var n,a;r(this,e),this.type=null,this.vendor=null,this.detail={},this.type=null!==(n=t.type)&&void 0!==n?n:"",this.vendor=null!==(a=t.vendor)&&void 0!==a?a:"",t.hasOwnProperty("detail")&&L("object",t.detail)&&!Array.isArray(t.detail)&&(this.detail=t.detail)}return s(e,null,[{key:"payloadify",value:function(e){return e?ee({type:e.type,vendor:e.vendor,detail:e.detail}):null}}]),e}();!function(e){e.OPEN="open",e.CLOSED="closed"}(gs||(gs={}));var Is,Ns="removed",As=function(e){switch(e){case gs.OPEN:return gs.OPEN;case gs.CLOSED:return gs.CLOSED}},Ms=function(e){return!e||e.text&&L("string",e.text)},Os=function(e){i(n,e);var t=f(n);function n(e,a){var s,i,o,u,c,l,h,d;return r(this,n),(s=t.call(this,e)).pollId=0,s.id=0,s.text=null,s.voteCount=0,s.createdBy=null,s.createdAt=0,s.updatedAt=0,s._lastVotedAt=0,s.pollId=null!==(i=a.poll_id)&&void 0!==i?i:0,s.id=null!==(o=a.id)&&void 0!==o?o:0,s.text=null!==(u=a.text)&&void 0!==u?u:null,s.voteCount=null!==(c=a.vote_count)&&void 0!==c?c:0,s.createdBy=null!==(l=a.created_by)&&void 0!==l?l:null,s.createdAt=null!==(h=a.created_at)&&void 0!==h?h:0,s.updatedAt=null!==(d=a.updated_at)&&void 0!==d?d:0,s}return s(n,null,[{key:"payloadify",value:function(e){return e?ee(Object.assign(Object.assign({},p(o(n),"payloadify",this).call(this,e)),{vote_count:e.voteCount,poll_id:e.pollId,text:e.text,created_at:e.createdAt,id:e.id,created_by:e.createdBy,updated_at:e.updatedAt})):null}}]),n}(Ca),Us=function(e){i(n,e);var t=f(n);function n(e,a){var s,i,o,u,c,l,h,d,f,p,v,_,m,g;return r(this,n),(s=t.call(this,e)).id=0,s.title=null,s.createdAt=0,s.updatedAt=0,s.closeAt=-1,s.status=gs.CLOSED,s.messageId=0,s.data=null,s.voterCount=-1,s.options=[],s.createdBy=null,s.allowUserSuggestion=!1,s.allowMultipleVotes=!1,s.votedPollOptionIds=[],s.id=null!==(i=a.id)&&void 0!==i?i:0,s.title=null!==(o=a.title)&&void 0!==o?o:null,s.createdAt=null!==(u=a.created_at)&&void 0!==u?u:0,s.updatedAt=null!==(c=a.updated_at)&&void 0!==c?c:0,s.closeAt=null!==(l=a.close_at)&&void 0!==l?l:-1,s.status=null!==(h=As(a.status))&&void 0!==h?h:gs.CLOSED,s.messageId=null!==(d=a.message_id)&&void 0!==d?d:0,s.data=null!==(f=a.data)&&void 0!==f?f:null,s.voterCount=null!==(p=a.voter_count)&&void 0!==p?p:-1,s.options=a.options?a.options.map((function(e){return new Os(s._iid,e)})):[],s.createdBy=null!==(v=a.created_by)&&void 0!==v?v:null,s.allowUserSuggestion=null!==(_=a.allow_user_suggestion)&&void 0!==_&&_,s.allowMultipleVotes=null!==(m=a.allow_multiple_votes)&&void 0!==m&&m,s.votedPollOptionIds=null!==(g=a.voted_option_ids)&&void 0!==g?g:[],s}return s(n,[{key:"_applyPollUpdatePayload",value:function(e){var t,n,r,a,s,i,o,u,c=this;this.title=null!==(t=e.title)&&void 0!==t?t:this.title,this.updatedAt=null!==(n=e.updated_at)&&void 0!==n?n:this.updatedAt,this.closeAt=null!==(r=e.close_at)&&void 0!==r?r:this.closeAt,this.status=null!==(a=As(e.status))&&void 0!==a?a:this.status,this.data=null!==(s=e.data)&&void 0!==s?s:this.data,this.voterCount=null!==(i=e.voter_count)&&void 0!==i?i:this.voterCount,e.options&&(this.options=e.options.map((function(e){return new Os(c._iid,e)})),this.votedPollOptionIds=e.options.filter((function(e){return e.vote_count>0})).map((function(e){return e.id}))),this.allowUserSuggestion=null!==(o=e.allow_user_suggestion)&&void 0!==o?o:this.allowUserSuggestion,this.allowMultipleVotes=null!==(u=e.allow_multiple_votes)&&void 0!==u?u:this.allowMultipleVotes}},{key:"applyPollUpdateEvent",value:function(e){var t=e._payload.poll;return!(!t||this.id!==t.id||t.updated_at-1){var s=t[r];a>=s._lastVotedAt&&(s.voteCount=e.vote_count,s._lastVotedAt=a)}})),r.req_id&&r.voted_option_ids&&(this.votedPollOptionIds=r.voted_option_ids),!0}},{key:"serialize",value:function(){return Ma(this)}}],[{key:"payloadify",value:function(e){return e?ee(Object.assign(Object.assign({},p(o(n),"payloadify",this).call(this,e)),{id:e.id,title:e.title,created_at:e.createdAt,updated_at:e.updatedAt,close_at:e.closeAt,status:e.status,message_id:e.messageId,data:e.data,voter_count:e.voterCount,options:e.options.map((function(e){return Os.payloadify(e)})),created_by:e.createdBy,allow_user_suggestion:e.allowUserSuggestion,allow_multiple_votes:e.allowMultipleVotes,voted_option_ids:e.votedPollOptionIds})):null}}]),n}(Ca),Rs=function(n){i(u,n);var a=f(u);function u(t,n){var s,i,o,c,l,h;if(r(this,u),(s=a.call(this,t,n)).message="",s.messageParams=null,s.translations={},s.translationTargetLanguages=[],s.messageSurvivalSeconds=-1,s.plugins=[],s._poll=null,s.message=n.message,s.messageType=e.MessageType.USER,s.translations=null!==(i=n.translations)&&void 0!==i?i:{},s.translationTargetLanguages=null!==(o=n.target_langs)&&void 0!==o?o:[],0===Object.keys(s.translations).length&&s.translationTargetLanguages.length>0){var d,f=y(s.translationTargetLanguages);try{for(f.s();!(d=f.n()).done;){var p=d.value;s.translations[p]=""}}catch(e){f.e(e)}finally{f.f()}}if(s.messageSurvivalSeconds=null!==(c=n.message_survival_seconds)&&void 0!==c?c:-1,s.plugins=n.plugins?n.plugins.map((function(e){return new Ss(e)})):[],s._poll=n.poll?new Us(s._iid,n.poll):null,n.parent_message_info){var v=n.parent_message_info,_=Object.assign(Object.assign({},v),{created_at:v.ts,message_id:s.parentMessageId,channel_url:s.channelUrl,channel_type:s.channelType,file:v.file,url:null===(l=v.file)||void 0===l?void 0:l.url,require_auth:null===(h=v.file)||void 0===h?void 0:h.require_auth});s.parentMessage=Ds(t,ee(_))}return s}return s(u,[{key:"getThreadedMessagesByTimestamp",value:function(e,n){return b(this,void 0,void 0,t().mark((function r(){var a,s;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return a=Object.assign(Object.assign({},Cs),n),Ua(this.messageId>0&&L("number",e)&&xs(a)).throw(M.invalidParameters),s=vi.of(this._iid),t.next=5,s.getThreadedMessagesByTimestamp(this,e,a);case 5:return t.abrupt("return",t.sent);case 6:case"end":return t.stop()}}),r,this)})))}},{key:"applyPoll",value:function(e){return!(this._poll&&this._poll.id===e.id&&this._poll.updatedAt>e.updatedAt)&&(this._poll=e,!0)}},{key:"poll",get:function(){return this._poll}}],[{key:"payloadify",value:function(e){return e?ee(Object.assign(Object.assign({},p(o(u),"payloadify",this).call(this,e)),{message:e.message,translations:e.translations,message_survival_seconds:e.messageSurvivalSeconds,plugins:e.plugins.map((function(e){return Ss.payloadify(e)})),poll:Us.payloadify(e._poll),parent_message_info:Ls(e.parentMessage)})):null}}]),u}(Es),Ls=function(t){if(t)switch(t.messageType){case e.MessageType.USER:return Rs.payloadify(t);case e.MessageType.FILE:return Ps.payloadify(t);case e.MessageType.ADMIN:return Ts.payloadify(t)}return null},Ds=function(e,t){switch(t.type){case"MESG":return new Rs(e,t);case"FILE":return new Ps(e,t);case"ADMM":case"BRDM":return new Ts(e,t)}return null},Ps=function(n){i(u,n);var a=f(u);function u(t,n){var s,i,o,c,l,h,d,f,p,v,_,m,g,y,k,b;r(this,u),(s=a.call(this,t,n)).messageParams=null,s.plainUrl="",s.requireAuth=!1,s.name=null,s.size=0,s.type=null,s.thumbnails=[],s.messageSurvivalSeconds=-1,s.messageType=e.MessageType.FILE;var E=null!==(i=n.file)&&void 0!==i?i:null;s.plainUrl=(null!==(c=null!==(o=null==E?void 0:E.url)&&void 0!==o?o:n.url)&&void 0!==c?c:"").split("?auth=")[0],s.name=null!==(h=null!==(l=null==E?void 0:E.name)&&void 0!==l?l:n.name)&&void 0!==h?h:"File",s.size=null!==(f=null!==(d=null==E?void 0:E.size)&&void 0!==d?d:n.size)&&void 0!==f?f:0,s.data=null!==(v=null!==(p=null==E?void 0:E.data)&&void 0!==p?p:n.custom)&&void 0!==v?v:"",s.type=E?null!==(_=E.type)&&void 0!==_?_:"":null!==(m=n.type)&&void 0!==m?m:"";var w=ns.of(s._iid).sessionManager;if(s.requireAuth=null!==(g=n.require_auth)&&void 0!==g&&g,s.thumbnails=n.thumbnails?n.thumbnails.map((function(e){return new ws(Object.assign(Object.assign({},e),{url:"".concat(e.url.split("?auth=")[0]).concat(s.requireAuth?"?auth=".concat(w.ekey):"")}))})):[],s.messageSurvivalSeconds=null!==(y=n.message_survival_seconds)&&void 0!==y?y:-1,n.parent_message_info){var C=n.parent_message_info,x=Object.assign(Object.assign({},C),{message_id:s.parentMessageId,channel_url:s.channelUrl,channel_type:s.channelType,file:C.file,url:null===(k=C.file)||void 0===k?void 0:k.url,require_auth:null===(b=C.file)||void 0===b?void 0:b.require_auth});s.parentMessage=Ds(t,x)}return s}return s(u,[{key:"url",get:function(){var e=ns.of(this._iid).sessionManager;return this.requireAuth?"".concat(this.plainUrl,"?auth=").concat(e.ekey):this.plainUrl}},{key:"getThreadedMessagesByTimestamp",value:function(e,n){return b(this,void 0,void 0,t().mark((function r(){var a,s;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return a=Object.assign(Object.assign({},Cs),n),Ua(this.messageId>0&&L("number",e)&&xs(a)).throw(M.invalidParameters),s=vi.of(this._iid),t.next=5,s.getThreadedMessagesByTimestamp(this,e,a);case 5:return t.abrupt("return",t.sent);case 6:case"end":return t.stop()}}),r,this)})))}}],[{key:"payloadify",value:function(e){return e?ee(Object.assign(Object.assign({},p(o(u),"payloadify",this).call(this,e)),{url:e.plainUrl,require_auth:e.requireAuth,file:{name:e.name,size:e.size,type:e.type,data:e.data},thumbnails: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:Ls(e.parentMessage)})):null}}]),u}(Es),Fs=function(t){switch(t){case e.ChannelType.GROUP:return zr;case e.ChannelType.OPEN:return Br;default:return null}},Gs=function(t){switch(t){case e.ChannelType.GROUP:return"".concat(Wr,"/group_channels");case e.ChannelType.OPEN:return"".concat(Wr,"/open_channels");default:return null}},Hs=function(t,n,r){switch(t){case e.MentionType.CHANNEL:return!0;case e.MentionType.USERS:if(n){var a,s=y(n);try{for(s.s();!(a=s.n()).done;){if(a.value===r)return!0}}catch(e){s.e(e)}finally{s.f()}}}return!1},qs=function(e,t,n){var r=Hs(e.mentionType,e.mentionedUserIds,n),a=Hs(t.mentionType,t.mentionedUserIds,n);return!r&&a?1:r&&!a?-1:0},js=function(t){i(a,t);var n=f(a);function a(t){var s,i,o;r(this,a);var u=[];return t.mentionType===e.MentionType.USERS&&(t.mentionedUserIds?u=t.mentionedUserIds:t.mentionedUsers&&(u=t.mentionedUsers.map((function(e){return e.userId})))),n.call(this,{code:"FILE",ackRequired:!0,payload:ee({channel_url:t.channelUrl,url:t.url,name:null!==(s=t.fileName)&&void 0!==s?s:"",type:null!==(i=t.mimeType)&&void 0!==i?i:"",size:null!==(o=t.fileSize)&&void 0!==o?o:0,custom:t.data,custom_type:t.customType,thumbnails:t.thumbnailSizes,require_auth:t.requireAuth,metaarray:t.metaArrays,mention_type:t.mentionType,mentioned_user_ids:u,push_option:t.pushNotificationDeliveryOption&&t.pushNotificationDeliveryOption!==e.PushNotificationDeliveryOption.DEFAULT?t.pushNotificationDeliveryOption:void 0,apple_critical_alert_options:t.appleCriticalAlertOptions,silent:t.silent,reply_to_channel:t.isReplyToChannel,parent_message_id:t.parentMessageId>0?t.parentMessageId:null,req_id:t.reqId,pin_message:t.isPinnedMessage})})}return s(a)}(Mr),zs=function(t){i(a,t);var n=f(a);function a(t){var s,i;r(this,a),s=n.call(this);var o=[];return t.mentionType===e.MentionType.USERS&&(t.mentionedUserIds?o=t.mentionedUserIds:t.mentionedUsers&&(o=t.mentionedUsers.map((function(e){return e.userId})))),s.method=B.POST,s.path="".concat(Fs(t.channelType),"/").concat(encodeURIComponent(t.channelUrl),"/messages"),s.params=ee({message_type:e.MessageType.FILE,user_id:t.userId,url:t.fileUrl,mention_type:t.mentionType,mentioned_user_ids:o,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 ws.payloadify(e)})),require_auth:t.requireAuth,sorted_metaarray:null===(i=t.metaArrays)||void 0===i?void 0:i.map((function(e){return ps.payloadify(e)})),push_option:t.pushNotificationDeliveryOption,parent_message_id:t.parentMessageId>0?t.parentMessageId:null,apple_critical_alert_options:ms.payloadify(t.appleCriticalAlertOptions),reply_to_channel:t.isReplyToChannel,req_id:t.reqId,pin_message:t.isPinnedMessage}),s}return s(a)}(ne),Vs=function(e){i(n,e);var t=f(n);function n(e,a,s){var i,o,u,c;r(this,n),(i=t.call(this,e,"FILE",s)).message=new Ps(e,s);var l=ns.of(e).sdkState;return i.isMentioned=Hs(i.message.mentionType,null!==(o=i.message.mentionedUserIds)&&void 0!==o?o:null===(u=i.message.mentionedUsers)||void 0===u?void 0:u.map((function(e){return e.userId})),l.userId),i.forceUpdateLastMessage=null!==(c=s.force_update_last_message)&&void 0!==c&&c,i}return s(n)}(le),Bs=function(e){i(n,e);var t=f(n);function n(e,a){var s,i,o;r(this,n),(s=t.call(this,e,a)).message=new Ps(e,a);var u=ns.of(e).sdkState;return s.isMentioned=Hs(s.message.mentionType,null!==(i=s.message.mentionedUserIds)&&void 0!==i?i:s.message.mentionedUsers.map((function(e){return e.userId})),u.userId),s.forceUpdateLastMessage=null!==(o=a.force_update_last_message)&&void 0!==o&&o,s}return s(n)}(re);!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"}(Is||(Is={}));var Qs,Ks=function(){function e(t,n){var a=this,s=n.sdkState,i=n.dispatcher,o=n.requestQueue,u=n.onlineDetector,c=n.cacheContext;r(this,e),this._queueMap=new Map,this._connectionState=null,this._onlineDetector=null,this._iid=t,this._sdkState=s,this._requestQueue=o,this._cacheContext=c,this._dispatcher=i,this._dispatcher.on((function(e){e instanceof Dr&&(a._connectionState=e.stateType)})),this._onlineDetector=u}return s(e,[{key:"_shouldSendThroughWebSocket",get:function(){return this._connectionState===Nr.CONNECTED||this._connectionState===Nr.CONNECTING||this._connectionState===Nr.RECONNECTING}},{key:"_sendFileMessage",value:function(e,n){return b(this,void 0,void 0,t().mark((function r(){var a,s,i,o,u,c,l,h;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(!this._shouldSendThroughWebSocket){t.next=9;break}return a=new js(Object.assign(Object.assign({},n.params),{channelUrl:e.url,channelType:e.channelType,url:n.params.fileUrl,requireAuth:n.requireAuth,reqId:n.requestId})),t.next=4,this._requestQueue.send(a);case 4:return s=t.sent,i=s.as(Vs),o=i.message,t.abrupt("return",o);case 9:return u=new zs(Object.assign(Object.assign({},n.params),{channelUrl:e.url,channelType:e.channelType,url:n.params.fileUrl,userId:this._sdkState.userId,requireAuth:n.requireAuth,reqId:n.requestId})),t.next=12,this._requestQueue.send(u);case 12:return c=t.sent,l=c.as(Bs),h=l.message,t.abrupt("return",h);case 15:case"end":return t.stop()}}),r,this)})))}},{key:"_resolveMessageQueue",value:function(e){return b(this,void 0,void 0,t().mark((function n(){var r,a,s,i,o,u,c,l;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(!(r=this._queueMap.get(e.url))){t.next=57;break}if(r.isResolving){t.next=56;break}r.isResolving=!0,a=[],s=!0,i=y(r.messageQueue),t.prev=7,i.s();case 9:if((o=i.n()).done){t.next=39;break}u=o.value,t.t0=u.state,t.next=t.t0===Is.PENDING||t.t0===Is.UPLOADING?14:t.t0===Is.UPLOADED?17:t.t0===Is.FAILED?35:37;break;case 14:return s=!1,a.push(u),t.abrupt("break",37);case 17:if(!s){t.next=33;break}return t.prev=18,u.state=Is.SENDING,t.next=22,this._sendFileMessage(e,u);case 22:return c=t.sent,u.deferred.resolve(c),t.next=26,sa(100);case 26:t.next=31;break;case 28:t.prev=28,t.t1=t.catch(18),u.deferred.reject(t.t1);case 31:t.next=34;break;case 33:a.push(u);case 34:return t.abrupt("break",37);case 35:return u.deferred.reject(u.error.code===E.REQUEST_CANCELED?M.fileUploadCanceled:u.error),t.abrupt("break",37);case 37:t.next=9;break;case 39:t.next=44;break;case 41:t.prev=41,t.t2=t.catch(7),i.e(t.t2);case 44:return t.prev=44,i.f(),t.finish(44);case 47:if(l=r.isResolveRequestPending,r.messageQueue=a,r.isResolving=!1,r.isResolveRequestPending=!1,!l){t.next=54;break}return t.next=54,this._resolveMessageQueue(e);case 54:t.next=57;break;case 56:r.isResolveRequestPending=!0;case 57:case"end":return t.stop()}}),n,this,[[7,41,44,47],[18,28]])})))}},{key:"_uploadNextPendingItem",value:function(e){return b(this,void 0,void 0,t().mark((function n(){var r,a,s,i,o,u,c,l,h,d,f,p,v,_;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(r=this._queueMap.get(e.url),!(a=r.messageQueue.find((function(e){return e.state===Is.PENDING})))){t.next=49;break}if(!H(a.params.file)){t.next=45;break}if(!(r.uploadQueue.length<6)){t.next=43;break}return a.state=Is.UPLOADING,r.uploadQueue.push(a),t.next=9,this._onlineDetector.isOnline();case 9:if(!t.sent){t.next=37;break}return t.prev=11,s=new as({file:a.params.file,channelUrl:e.url,thumbnailSizes:a.params.thumbnailSizes,requestId:a.requestId}),t.next=15,this._requestQueue.send(s);case 15:i=t.sent,o=i.as(ss),u=o.url,c=o.fileSize,l=void 0===c?a.params.fileSize:c,h=o.thumbnailSizes,d=void 0===h?a.params.thumbnailSizes:h,f=o.requireAuth,p=void 0!==f&&f,a.params.fileUrl=u,a.params.fileSize=l,a.params.thumbnailSizes=d,a.params.requireAuth=p,a.requireAuth=p,a.state=Is.UPLOADED,t.next=29;break;case 25:t.prev=25,t.t0=t.catch(11),t.t0.code===E.REQUEST_FAILED?a.error=new M({code:E.NETWORK_ERROR,message:"Failed to upload a file."}):a.error=t.t0,a.state=Is.FAILED;case 29:return t.prev=29,(v=r.uploadQueue.findIndex((function(e){return e.requestId===a.requestId})))>=0&&(r.uploadQueue.splice(v,1),this._uploadNextPendingItem(e)),t.next=34,this._resolveMessageQueue(e);case 34:return t.finish(29);case 35:t.next=43;break;case 37:return a.state=Is.FAILED,a.error=M.connectionRequired,(_=r.uploadQueue.findIndex((function(e){return e.requestId===a.requestId})))>=0&&(r.uploadQueue.splice(_,1),this._uploadNextPendingItem(e)),t.next=43,this._resolveMessageQueue(e);case 43:t.next=49;break;case 45:return a.params.thumbnailSizes=[],a.state=Is.UPLOADED,t.next=49,this._resolveMessageQueue(e);case 49:case"end":return t.stop()}}),n,this,[[11,25,29,35]])})))}},{key:"request",value:function(e,n,r){var a,s,i;return b(this,void 0,void 0,t().mark((function o(){var u;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return u=new Ur,H(r.file)&&(r.fileName=null!==(a=r.fileName)&&void 0!==a?a:r.file.name,r.mimeType=null!==(s=r.mimeType)&&void 0!==s?s:r.file.type,r.fileSize=null!==(i=r.fileSize)&&void 0!==i?i:r.file.size),this._queueMap.has(e.url)||this._queueMap.set(e.url,{messageQueue:[],uploadQueue:[],isResolving:!1,isResolveRequestPending:!1}),this._queueMap.get(e.url).messageQueue.push({requestId:n,params:r,state:Is.PENDING,deferred:u,requireAuth:r.requireAuth}),this._uploadNextPendingItem(e),t.abrupt("return",u.promise);case 7:case"end":return t.stop()}}),o,this)})))}},{key:"cancel",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null,n=this._queueMap.get(e.url);if(n){var r,a=t?[n.messageQueue.find((function(e){return e.requestId===t}))]:_(n.messageQueue),s=y(a);try{for(s.s();!(r=s.n()).done;){var i=r.value;if(i)switch(i.state){case Is.PENDING:i.state=Is.FAILED,i.error=M.requestCanceled,this._resolveMessageQueue(e);break;case Is.UPLOADING:this._requestQueue.cancel(i.requestId)}}}catch(e){s.e(e)}finally{s.f()}}}}]),e}(),Ws={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},Ys=function(t){return L("number",t.prevResultSize)&&L("number",t.nextResultSize)&&L("boolean",t.isInclusive)&&L("boolean",t.reverse)&&L("string",t.messageTypeFilter)&&D(e.MessageTypeFilter,t.messageTypeFilter)&&F("string",t.customTypesFilter,!0)&&F("string",t.senderUserIdsFilter,!0)&&D(e.ReplyType,t.replyType)&&L("boolean",t.includeMetaArray)&&L("boolean",t.includeReactions)&&L("boolean",t.includeParentMessageInfo)&&L("boolean",t.includeThreadInfo)&&L("boolean",t.showSubchannelMessagesOnly)},Zs={replyType:e.ReplyType.NONE,includeReactions:!1,includeThreadInfo:!1,includeMetaArray:!1,includeParentMessageInfo:!1},Js=function(t){return D(e.ReplyType,t.replyType)&&L("boolean",t.includeReactions)&&L("boolean",t.includeMetaArray)&&L("boolean",t.includeParentMessageInfo)&&L("boolean",t.includeThreadInfo)};e.MessageEventSource=void 0,(Qs=e.MessageEventSource||(e.MessageEventSource={})).UNKNOWN="UNKNOWN",Qs.EVENT_MESSAGE_SENT_SUCCESS="EVENT_MESSAGE_SENT_SUCCESS",Qs.EVENT_MESSAGE_SENT_FAILED="EVENT_MESSAGE_SENT_FAILED",Qs.EVENT_MESSAGE_SENT_PENDING="EVENT_MESSAGE_SENT_PENDING",Qs.EVENT_MESSAGE_RECEIVED="EVENT_MESSAGE_RECEIVED",Qs.EVENT_MESSAGE_UPDATED="EVENT_MESSAGE_UPDATED",Qs.EVENT_MESSAGE_DELETED="EVENT_MESSAGE_DELETED",Qs.EVENT_MESSAGE_READ="EVENT_MESSAGE_READ",Qs.EVENT_MESSAGE_DELIVERED="EVENT_MESSAGE_DELIVERED",Qs.EVENT_MESSAGE_REACTION_UPDATED="EVENT_MESSAGE_REACTION_UPDATED",Qs.EVENT_MESSAGE_THREADINFO_UPDATED="EVENT_MESSAGE_THREADINFO_UPDATED",Qs.EVENT_MESSAGE_OFFSET_UPDATED="EVENT_MESSAGE_OFFSET_UPDATED",Qs.REQUEST_MESSAGE="REQUEST_MESSAGE",Qs.EVENT_POLL_UPDATED="EVENT_POLL_UPDATED",Qs.EVENT_POLL_VOTED="EVENT_POLL_VOTED",Qs.SYNC_POLL_CHANGELOGS="SYNC_POLL_CHANGELOGS",Qs.REQUEST_RESEND_MESSAGE="REQUEST_RESEND_MESSAGE",Qs.REQUEST_THREADED_MESSAGE="REQUEST_THREADED_MESSAGE",Qs.REQUEST_MESSAGE_CHANGELOGS="REQUEST_MESSAGE_CHANGELOGS",Qs.SYNC_MESSAGE_FILL="SYNC_MESSAGE_FILL",Qs.SYNC_MESSAGE_BACKGROUND="SYNC_MESSAGE_BACKGROUND",Qs.SYNC_MESSAGE_CHANGELOGS="SYNC_MESSAGE_CHANGELOGS",Qs.LOCAL_MESSAGE_PENDING_CREATED="LOCAL_MESSAGE_PENDING_CREATED",Qs.LOCAL_MESSAGE_FAILED="LOCAL_MESSAGE_FAILED",Qs.LOCAL_MESSAGE_CANCELED="LOCAL_MESSAGE_CANCELED",Qs.LOCAL_MESSAGE_RESEND_STARTED="LOCAL_MESSAGE_RESEND_STARTED";var Xs,$s=function(t){return t.startsWith("EVENT_")||t===e.MessageEventSource.SYNC_MESSAGE_FILL||t===e.MessageEventSource.SYNC_MESSAGE_CHANGELOGS||t===e.MessageEventSource.SYNC_POLL_CHANGELOGS},ei=function(e){i(n,e);var t=f(n);function n(e){var a,s=e.messages,i=e.source;return r(this,n),(a=t.call(this)).messages=s,a.source=i,a}return s(n)}($),ti=function(e){i(n,e);var t=f(n);function n(e){var a,s=e.messageIds,i=e.source;return r(this,n),(a=t.call(this)).messageIds=s,a.source=i,a}return s(n)}($),ni=function(e){i(n,e);var t=f(n);function n(e){var a,s=e.reqId,i=e.source;return r(this,n),(a=t.call(this)).reqId=s,a.source=i,a}return s(n)}($),ri=function(e){i(n,e);var t=f(n);function n(e){var a,s=e.polls,i=e.source;return r(this,n),(a=t.call(this)).polls=s,a.source=i,a}return s(n)}($),ai=function(e){i(n,e);var t=f(n);function n(e){var a,s=e.event,i=e.source;return r(this,n),(a=t.call(this)).event=s,a.source=i,a}return s(n)}($),si=function(e){i(n,e);var t=f(n);function n(e){var a,s=e.event,i=e.source;return r(this,n),(a=t.call(this)).event=null,a.source=null,a.event=s,a.source=i,a}return s(n)}($),ii=function(e){i(n,e);var t=f(n);function n(e){var a,s=e.channelType,i=e.channelUrl,o=e.messageId,u=e.includeMetaArray,c=e.includeReactions,l=e.includeThreadInfo,h=e.includeParentMessageInfo;return r(this,n),(a=t.call(this)).method=B.GET,a.path="".concat(Fs(s),"/").concat(encodeURIComponent(i),"/messages/").concat(encodeURIComponent(o)),a.params={is_sdk:!0,with_sorted_meta_array:u,include_reactions:c,include_thread_info:l,include_parent_message_info:h,include_poll_details:!0},a}return s(n)}(ne),oi=function(e){i(n,e);var t=f(n);function n(e,a){var s;return r(this,n),(s=t.call(this,e,a)).message=a?Ds(e,Object.assign({},a)):null,s}return s(n)}(re),ui=function(e){i(n,e);var t=f(n);function n(e){var a,s=e.channelType,i=e.channelUrl,o=e.timestamp,u=void 0===o?null:o,c=e.token,l=void 0===c?null:c,h=e.prevResultSize,d=e.nextResultSize,f=e.isInclusive,p=e.reverse,v=e.messageTypeFilter,_=e.customTypesFilter,m=e.senderUserIdsFilter,g=e.replyType,y=e.includeMetaArray,k=e.includeReactions,b=e.parentMessageId,E=e.includeThreadInfo,w=e.includeParentMessageInfo,C=e.showSubchannelMessagesOnly,x=e.checkingContinuousMessages;return r(this,n),(a=t.call(this)).method=B.GET,a.path="".concat(Fs(s),"/").concat(encodeURIComponent(i),"/messages"),a.params=ee({is_sdk:!0,prev_limit:h,next_limit:d,include:f,reverse:p,message_ts:u,message_id:l,message_type:null!=v?v:null,custom_types:_,sender_ids:m,include_reply_type:g,with_sorted_meta_array:y,include_reactions:k,parent_message_id:b,include_thread_info:E,include_parent_message_info:w,show_subchannel_message_only:C,include_poll_details:!0,checking_continuous_messages:x}),a}return s(n)}(ne),ci=function(e){i(n,e);var t=f(n);function n(e,a){var s;return r(this,n),(s=t.call(this,e,a)).messages=a.messages.map((function(t){return Ds(e,t)})),s}return s(n)}(re),li=function(e){i(n,e);var t=f(n);function n(e){var a,s=e.channelType,i=e.channelUrl,o=e.timestamp,u=e.token,c=e.replyType,l=e.includeMetaArray,h=e.includeReactions,d=e.includeThreadInfo,f=e.includeParentMessageInfo;return r(this,n),(a=t.call(this)).method=B.GET,a.path="".concat(Fs(s),"/").concat(encodeURIComponent(i),"/messages/changelogs"),a.params={change_ts:o,token:u,with_sorted_meta_array:l,include_reactions:h,include_thread_info:d,include_reply_type:c,include_parent_message_info:f,include_poll_details:!0},a}return s(n)}(ne),hi=function(e){i(n,e);var t=f(n);function n(e,a){var s;return r(this,n),(s=t.call(this,e,a)).updatedMessages=a.updated.map((function(t){return Ds(e,t)})),s.deletedMessagesInfo=a.deleted.map((function(e){return{messageId:e.message_id,deletedAt:e.deleted_at}})),s.hasMore=a.has_more,s.nextToken=a.next,s}return s(n)}(re),di=function(e){i(n,e);var t=f(n);function n(e){var a,s=e.channelUrl,i=e.scheduledMessageId;return r(this,n),(a=t.call(this)).method=B.GET,a.path="".concat(zr,"/").concat(encodeURIComponent(s),"/scheduled_messages/").concat(encodeURIComponent(i)),a.params={},a}return s(n)}(ne),fi=function(e){i(n,e);var t=f(n);function n(e,a){var s;return r(this,n),(s=t.call(this,e,a)).message=a?Ds(e,Object.assign({},a)):null,s}return s(n)}(re),pi={},vi=function(){function n(e,t){var a=t.sdkState,s=t.dispatcher,i=t.requestQueue,o=t.onlineDetector,u=t.cacheContext;r(this,n),this._iid=e,this._sdkState=a,this._requestQueue=i,this._dispatcher=s,this._cacheContext=u,this.fileMessageQueue=new Ks(e,{sdkState:a,dispatcher:s,requestQueue:i,onlineDetector:o,cacheContext:u}),pi[e]=this}return s(n,[{key:"buildMessageFromSerializedData",value:function(t){var n=Oa(t);switch(n.messageType){case e.MessageType.USER:return new Rs(this._iid,Rs.payloadify(n));case e.MessageType.FILE:return new Ps(this._iid,Ps.payloadify(n));case e.MessageType.ADMIN:return new Ts(this._iid,Ts.payloadify(n))}return null}},{key:"buildUserMessageCreateParamsFromSerializedData",value:function(e,t){return ee({data:t.data,customType:t.customType,mentionType:t.mentionType,mentionedUserIds:t.mentionedUserIds,mentionedUsers:t.mentionedUsers,mentionedMessageTemplate:t.mentionedMessageTemplate,metaArrays:t.metaArrays,parentMessageId:t.parentMessageId,isReplyToChannel:e.isReplyToChannel,pushNotificationDeliveryOption:e.pushNotificationDeliveryOption,appleCriticalAlertOptions:t.appleCriticalAlertOptions,reqId:t.reqId,message:t.message,translationTargetLanguages:Object.keys(t.translations),pollId:e.pollId})}},{key:"buildFileMessageCreateParamsFromSerializedData",value:function(e,t){return ee({data:t.data,customType:t.customType,mentionType:t.mentionType,mentionedUserIds:t.mentionedUserIds,mentionedUsers:t.mentionedUsers,mentionedMessageTemplate:t.mentionedMessageTemplate,metaArrays:t.metaArrays,parentMessageId:t.parentMessageId,isReplyToChannel:e.isReplyToChannel,pushNotificationDeliveryOption:e.pushNotificationDeliveryOption,appleCriticalAlertOptions:t.appleCriticalAlertOptions,reqId:t.reqId,file:e.file,fileKey:e.fileKey,fileUrl:t.plainUrl,fileName:t.name,fileSize:t.size,mimeType:t.type,thumbnailSizes:t.thumbnails.map((function(e){return{maxWidth:e.width,maxHeight:e.height}})),fileType:e.fileType,requireAuth:t.requireAuth})}},{key:"buildScheduledUserMessageCreateParamsFromSerializedData",value:function(e,t){return Object.assign(Object.assign({},this.buildUserMessageCreateParamsFromSerializedData(e,t)),{scheduledAt:e.scheduledAt})}},{key:"buildScheduledFileMessageCreateParamsFromSerializedData",value:function(e,t){return Object.assign(Object.assign({},this.buildFileMessageCreateParamsFromSerializedData(e,t)),{scheduledAt:e.scheduledAt})}},{key:"buildSenderFromSerializedData",value:function(e){var t=Oa(e);return new bs(this._iid,bs.payloadify(t))}},{key:"getMessage",value:function(e){return b(this,void 0,void 0,t().mark((function n(){var r,a,s,i;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return r=new ii(e),t.next=3,this._requestQueue.send(r);case 3:return a=t.sent,s=a.as(oi),i=s.message,t.abrupt("return",i);case 6:case"end":return t.stop()}}),n,this)})))}},{key:"getScheduledMessage",value:function(e){return b(this,void 0,void 0,t().mark((function n(){var r,a,s,i;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return r=new di(e),t.next=3,this._requestQueue.send(r);case 3:return a=t.sent,s=a.as(fi),i=s.message,t.abrupt("return",i);case 6:case"end":return t.stop()}}),n,this)})))}},{key:"getMessagesByMessageId",value:function(n,r,a,s){var i=arguments.length>4&&void 0!==arguments[4]?arguments[4]:e.MessageEventSource.REQUEST_MESSAGE;return b(this,void 0,void 0,t().mark((function e(){var o,u,c,l;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return o=new ui(Object.assign(Object.assign({channelType:r,channelUrl:n,token:String(a)},Ws),s)),e.next=3,this._requestQueue.send(o);case 3:return u=e.sent,c=u.as(ci),l=c.messages,this._dispatcher.dispatch(new ei({messages:l,source:i})),e.abrupt("return",l);case 7:case"end":return e.stop()}}),e,this)})))}},{key:"getMessagesByTimestamp",value:function(n,r,a,s){var i=arguments.length>4&&void 0!==arguments[4]?arguments[4]:e.MessageEventSource.REQUEST_MESSAGE;return b(this,void 0,void 0,t().mark((function e(){var o,u,c,l;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return o=new ui(Object.assign(Object.assign({channelType:r,channelUrl:n,timestamp:a},Ws),s)),e.next=3,this._requestQueue.send(o);case 3:return u=e.sent,c=u.as(ci),l=c.messages,this._dispatcher.dispatch(new ei({messages:l,source:i})),e.abrupt("return",l);case 7:case"end":return e.stop()}}),e,this)})))}},{key:"_getMessagesByTimestampForCollection",value:function(n,r,a,s){var i=arguments.length>4&&void 0!==arguments[4]?arguments[4]:e.MessageEventSource.REQUEST_MESSAGE,o=arguments.length>5?arguments[5]:void 0;return b(this,void 0,void 0,t().mark((function e(){var u,c,l,h,d;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return u=new ui(Object.assign(Object.assign(Object.assign({channelType:r,channelUrl:n,timestamp:a},Ws),s),{checkingContinuousMessages:o})),e.next=3,this._requestQueue.send(u);case 3:return c=e.sent,l=c.payload,h=c.as(ci),d=h.messages,this._dispatcher.dispatch(new ei({messages:d,source:i})),e.abrupt("return",{messages:d,isContinuousMessages:l});case 8:case"end":return e.stop()}}),e,this)})))}},{key:"getThreadedMessagesByTimestamp",value:function(n,r,a){var s=arguments.length>3&&void 0!==arguments[3]?arguments[3]:e.MessageEventSource.REQUEST_THREADED_MESSAGE;return b(this,void 0,void 0,t().mark((function i(){var o,u,c,l,h;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return o=new ui(Object.assign(Object.assign(Object.assign({channelUrl:n.channelUrl,channelType:n.channelType,timestamp:r},Cs),a),{replyType:e.ReplyType.ALL,parentMessageId:n.messageId,includeThreadInfo:!0})),t.next=3,this._requestQueue.send(o);case 3:return u=t.sent,c=u.as(ci),l=c.messages,(h=l.slice(1)).forEach((function(e){e.parentMessage=n})),this._dispatcher.dispatch(new ei({messages:h,source:s})),t.abrupt("return",{parentMessage:l[0],threadedMessages:h});case 9:case"end":return t.stop()}}),i,this)})))}},{key:"getMessageChangelogs",value:function(n,r,a,s){var i=arguments.length>4&&void 0!==arguments[4]?arguments[4]:e.MessageEventSource.REQUEST_MESSAGE_CHANGELOGS;return b(this,void 0,void 0,t().mark((function e(){var o,u,c,l,h,d,f,p;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return o=new li(ee(Object.assign(Object.assign({channelType:r,channelUrl:n,timestamp:"number"==typeof a?a:null,token:"string"==typeof a?a:null},Zs),s))),e.next=3,this._requestQueue.send(o);case 3:return u=e.sent,c=u.as(hi),l=c.updatedMessages,h=c.deletedMessagesInfo,d=c.hasMore,f=c.nextToken,p=h.map((function(e){return e.messageId})),l.length>0&&this._dispatcher.dispatch(new ei({messages:l,source:i})),p.length>0&&this._dispatcher.dispatch(new ti({messageIds:p,source:i})),e.abrupt("return",{updatedMessages:l,deletedMessageIds:p,hasMore:d,token:f});case 9:case"end":return e.stop()}}),e,this)})))}}],[{key:"of",value:function(e){return pi[e]}}]),n}(),_i=function(){function t(){r(this,t),this._onPending=he,this._onFailed=he,this._onSucceeded=he}return s(t,[{key:"_trigger",value:function(t,n){switch(n.sendingStatus){case e.SendingStatus.PENDING:0===n.errorCode&&this._onPending(n);break;case e.SendingStatus.FAILED:case e.SendingStatus.CANCELED:this._onFailed(t,n.scheduledInfo?null:n);break;case e.SendingStatus.SCHEDULED:case e.SendingStatus.SUCCEEDED:this._onSucceeded(n)}}},{key:"onPending",value:function(e){return this._onPending=e,this}},{key:"onFailed",value:function(e){return this._onFailed=e,this}},{key:"onSucceeded",value:function(e){return this._onSucceeded=e,this}}]),t}(),mi=function(e){i(n,e);var t=f(n);function n(e,a){var s;r(this,n),(s=t.call(this,e)).threadInfo=null,s.targetMessageId=0,s.channelUrl=null,s.channelType=null;var i=a.thread_info,o=a.parent_message_id,u=a.channel_url,c=a.channel_type;return i&&L("object",i)&&L("number",o)&&L("string",u)&&L("string",c)&&(s.threadInfo=new os(e,i),s.targetMessageId=o,s.channelUrl=u,s.channelType=c),s}return s(n)}(Ca),gi={channelUrl:null,channelType:null,messageId:0,includeReactions:!1,includeMetaArray:!1,includeParentMessageInfo:!1,includeThreadInfo:!1},yi=function(t){return L("string",t.channelUrl)&&L("string",t.channelType)&&D(e.ChannelType,t.channelType)&&L("number",t.messageId)&&L("boolean",t.includeMetaArray)&&L("boolean",t.includeParentMessageInfo)&&L("boolean",t.includeThreadInfo)},ki=function(){function e(t,n){var a;r(this,e),this._iid=null,this.limit=20,this._isLoading=!1,this._hasNext=!0,this._token="",this._iid=t,this.limit=null!==(a=n.limit)&&void 0!==a?a:20}return s(e,[{key:"hasNext",get:function(){return this._hasNext}},{key:"isLoading",get:function(){return this._isLoading}},{key:"_validate",value:function(){return L("number",this.limit)&&this.limit>0}}]),e}(),bi=function(e){i(n,e);var t=f(n);function n(e){var a,s=e.channelCustomType,i=e.keyword,o=e.limit,u=e.reverse,c=e.exactMatch,l=e.channelUrl,h=e.order,d=e.messageTimestampFrom,f=e.messageTimestampTo,p=e.advancedQuery,v=e.targetFields,_=e.nextToken;return r(this,n),(a=t.call(this)).method=B.GET,a.path="".concat(Kr,"/messages"),a.params={custom_type:s,query:i,limit:o,reverse:u,exact_match:c,channel_url:l,message_ts_from:d,message_ts_to:f,sort_field:h,advanced_query:p,target_fields:v,after:_},a}return s(n)}(ne),Ei=function(e){i(n,e);var t=f(n);function n(e,a){var s;return r(this,n),(s=t.call(this,e,a)).messages=a.results.map((function(t){return Ds(e,t)})),s.hasNext=a.has_next,s.nextToken=a.end_cursor,s.totalCount=a.total_count,s}return s(n)}(re);e.MessageSearchOrder=void 0,(Xs=e.MessageSearchOrder||(e.MessageSearchOrder={})).SCORE="score",Xs.TIMESTAMP="ts";var wi,Ci,xi,Ti=function(n){i(u,n);var a=f(u);function u(t,n){var s,i,o,c,l,h,d,f,p,v;return r(this,u),(s=a.call(this,t,n)).keyword="",s.reverse=!1,s.exactMatch=!1,s.channelUrl="",s.channelCustomType="",s.messageTimestampFrom=null,s.messageTimestampTo=null,s.order=e.MessageSearchOrder.SCORE,s.advancedQuery=!1,s.targetFields=null,s._nextToken="",s.totalCount=-1,s.keyword=n.keyword,s.reverse=null!==(i=n.reverse)&&void 0!==i&&i,s.exactMatch=null!==(o=n.exactMatch)&&void 0!==o&&o,s.channelUrl=null!==(c=n.channelUrl)&&void 0!==c?c:"",s.channelCustomType=null!==(l=n.channelCustomType)&&void 0!==l?l:"",s.messageTimestampFrom=null!==(h=n.messageTimestampFrom)&&void 0!==h?h:null,s.messageTimestampTo=null!==(d=n.messageTimestampTo)&&void 0!==d?d:null,s.order=null!==(f=n.order)&&void 0!==f?f:e.MessageSearchOrder.SCORE,s.advancedQuery=null!==(p=n.advancedQuery)&&void 0!==p&&p,s.targetFields=null!==(v=n.targetFields)&&void 0!==v?v:null,s}return s(u,[{key:"_validate",value:function(){return p(o(u.prototype),"_validate",this).call(this)&&L("string",this.keyword)&&this.keyword.length>0&&L("boolean",this.reverse)&&L("boolean",this.exactMatch)&&L("string",this.channelUrl)&&L("string",this.channelCustomType)&&(L("number",this.messageTimestampFrom)||null===this.messageTimestampFrom)&&(L("number",this.messageTimestampTo)||null===this.messageTimestampTo)&&D(e.MessageSearchOrder,this.order)&&L("boolean",this.advancedQuery)&&F("string",this.targetFields,!0)}},{key:"next",value:function(){return b(this,void 0,void 0,t().mark((function e(){var n,r,a,s,i,o,u,c,l;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!this._validate()){e.next=21;break}if(this._isLoading){e.next=18;break}if(!this._hasNext){e.next=15;break}return this._isLoading=!0,n=ns.of(this._iid),r=n.requestQueue,a=new bi(Object.assign(Object.assign({},this),{nextToken:this._nextToken?this._nextToken:null})),e.next=8,r.send(a);case 8:return s=e.sent,i=s.as(Ei),o=i.messages,u=i.hasNext,c=i.nextToken,l=i.totalCount,this._nextToken=c,this._hasNext=u,this._isLoading=!1,this.totalCount=l,e.abrupt("return",o);case 15:return e.abrupt("return",[]);case 18:throw M.queryInProgress;case 19:e.next=22;break;case 21:throw M.invalidParameters;case 22:case"end":return e.stop()}}),e,this)})))}}]),u}(ki),Si=function(t){i(a,t);var n=f(a);function a(e,t,s,i){var o;return r(this,a),(o=n.call(this,e,i)).channelUrl=t,o.channelType=s,o}return s(a,[{key:"_validate",value:function(){return p(o(a.prototype),"_validate",this).call(this)&&L("string",this.channelUrl)&&D(e.ChannelType,this.channelType)}}]),a}(ki),Ii=function(n){i(u,n);var a=f(u);function u(t,n,s,i){var o,c,l,h,d,f,p,v,_,m,g;return r(this,u),(o=a.call(this,t,n,s,i)).reverse=!1,o.messageTypeFilter=e.MessageTypeFilter.ALL,o.customTypesFilter=null,o.senderUserIdsFilter=null,o.replyType=e.ReplyType.NONE,o.includeMetaArray=!1,o.includeReactions=!1,o.includeParentMessageInfo=!1,o.includeThreadInfo=!1,o.showSubchannelMessagesOnly=!1,o._edge=Number.MAX_SAFE_INTEGER,o.reverse=null!==(c=i.reverse)&&void 0!==c&&c,o.messageTypeFilter=null!==(l=i.messageTypeFilter)&&void 0!==l?l:e.MessageTypeFilter.ALL,o.customTypesFilter=null!==(h=i.customTypesFilter)&&void 0!==h?h:null,o.senderUserIdsFilter=null!==(d=i.senderUserIdsFilter)&&void 0!==d?d:null,o.replyType=null!==(f=i.replyType)&&void 0!==f?f:e.ReplyType.NONE,o.includeMetaArray=null!==(p=i.includeMetaArray)&&void 0!==p&&p,o.includeReactions=null!==(v=i.includeReactions)&&void 0!==v&&v,o.includeParentMessageInfo=null!==(_=i.includeParentMessageInfo)&&void 0!==_&&_,o.includeThreadInfo=null!==(m=i.includeThreadInfo)&&void 0!==m&&m,o.showSubchannelMessagesOnly=null!==(g=i.showSubchannelMessagesOnly)&&void 0!==g&&g,o}return s(u,[{key:"_validate",value:function(){return p(o(u.prototype),"_validate",this).call(this)&&L("boolean",this.reverse)&&D(e.MessageTypeFilter,this.messageTypeFilter)&&D(e.ReplyType,this.replyType)&&F("string",this.customTypesFilter,!0)&&F("string",this.senderUserIdsFilter,!0)&&L("boolean",this.includeMetaArray)&&L("boolean",this.includeReactions)&&L("boolean",this.includeParentMessageInfo)&&L("boolean",this.includeThreadInfo)&&L("boolean",this.showSubchannelMessagesOnly)}},{key:"load",value:function(){return b(this,void 0,void 0,t().mark((function e(){var n,r;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!this._validate()){e.next=18;break}if(this._isLoading){e.next=15;break}if(!this._hasNext){e.next=12;break}return this._isLoading=!0,n=vi.of(this._iid),e.next=7,n.getMessagesByTimestamp(this.channelUrl,this.channelType,this._edge,{prevResultSize:this.limit,nextResultSize:0,isInclusive:!1,reverse:this.reverse,messageTypeFilter:this.messageTypeFilter,customTypesFilter:this.customTypesFilter,replyType:this.replyType,senderUserIdsFilter:this.senderUserIdsFilter,includeReactions:this.includeReactions,includeMetaArray:this.includeMetaArray,includeParentMessageInfo:this.includeParentMessageInfo,includeThreadInfo:this.includeThreadInfo,showSubchannelMessagesOnly:this.showSubchannelMessagesOnly});case 7:return r=e.sent,this._edge=Math.min.apply(Math,[Number.MAX_SAFE_INTEGER].concat(_(r.map((function(e){return e.createdAt}))))),this._hasNext=r.length>=this.limit,this._isLoading=!1,e.abrupt("return",r);case 12:return e.abrupt("return",[]);case 15:throw M.queryInProgress;case 16:e.next=19;break;case 18:throw M.invalidParameters;case 19:case"end":return e.stop()}}),e,this)})))}}]),u}(Si),Ni={channelUrl:null,scheduledMessageId:0},Ai=function(e){return L("string",e.channelUrl)&&L("number",e.scheduledMessageId)},Mi=function(e){i(a,e);var n=f(a);function a(){var e;return r(this,a),(e=n.apply(this,arguments)).name="message",e}return s(a,[{key:"init",value:function(e,t){var n=t.sdkState,r=t.dispatcher,s=t.sessionManager,i=t.requestQueue,u=t.logger,c=t.onlineDetector,l=t.cacheContext;p(o(a.prototype),"init",this).call(this,e,{sdkState:n,dispatcher:r,sessionManager:s,requestQueue:i,logger:u,onlineDetector:c,cacheContext:l}),this._manager=new vi(e,{sdkState:n,dispatcher:r,requestQueue:i,onlineDetector:c,cacheContext:l})}},{key:"buildMessageFromSerializedData",value:function(e){return this._manager.buildMessageFromSerializedData(e)}},{key:"buildSenderFromSerializedData",value:function(e){return this._manager.buildSenderFromSerializedData(e)}},{key:"getMessage",value:function(e){return b(this,void 0,void 0,t().mark((function n(){var r;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return r=Object.assign(Object.assign({},gi),e),Ua(yi(r)).throw(M.invalidParameters),t.abrupt("return",this._manager.getMessage(r));case 3:case"end":return t.stop()}}),n,this)})))}},{key:"getScheduledMessage",value:function(e){return b(this,void 0,void 0,t().mark((function n(){var r;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return r=Object.assign(Object.assign({},Ni),e),Ua(Ai(r)).throw(M.invalidParameters),t.abrupt("return",this._manager.getScheduledMessage(r));case 3:case"end":return t.stop()}}),n,this)})))}}]),a}(rs),Oi=function(e){i(n,e);var t=f(n);function n(e){var a,s=e.title,i=e.optionTexts,o=e.data,u=e.allowUserSuggestion,c=e.allowMultipleVotes,l=e.closeAt;return r(this,n),(a=t.call(this)).method=B.POST,a.path=Jr,a.params={title:s,options:i,data:o,allow_user_suggestion:u,allow_multiple_votes:c,close_at:l},a}return s(n)}(ne),Ui=function(e){i(n,e);var t=f(n);function n(e,a){var s;return r(this,n),(s=t.call(this,e,a)).poll=new Us(e,a),s}return s(n)}(re),Ri=function(e){i(n,e);var t=f(n);function n(e){var a,s=e.channelUrl,i=e.channelType,o=e.pollId;return r(this,n),(a=t.call(this)).method=B.GET,a.path="".concat(Jr,"/").concat(encodeURIComponent(o)),a.params={channel_url:s,channel_type:i},a}return s(n)}(ne),Li=function(e){i(n,e);var t=f(n);function n(e,a){var s;return r(this,n),(s=t.call(this,e,a)).poll=new Us(e,a),s}return s(n)}(re),Di=function(e){i(n,e);var t=f(n);function n(e){var a,s=e.channelUrl,i=e.channelType,o=e.pollId,u=e.pollOptionId;return r(this,n),(a=t.call(this)).method=B.GET,a.path="".concat(Jr,"/").concat(encodeURIComponent(o),"/options/").concat(encodeURIComponent(u)),a.params={channel_url:s,channel_type:i},a}return s(n)}(ne),Pi=function(e){i(n,e);var t=f(n);function n(e,a){var s;return r(this,n),(s=t.call(this,e,a)).pollOption=new Os(e,a),s}return s(n)}(re),Fi=function(e){i(n,e);var t=f(n);function n(e){var a,s=e.channelType,i=e.channelUrl,o=e.timestamp,u=e.token;return r(this,n),(a=t.call(this)).method=B.GET,a.path="".concat(Fs(s),"/").concat(encodeURIComponent(i),"/polls/changelogs"),a.params=ee({change_ts:o,token:u}),a}return s(n)}(ne),Gi=function(e){i(n,e);var t=f(n);function n(e,a){var s;return r(this,n),(s=t.call(this,e,a)).updatedPolls=a.updated.map((function(t){return function(e,t){return t?new Us(e,t):null}(e,t)})),s.deletedPollIds=a.deleted.map((function(e){return e})),s.hasMore=a.has_more,s.nextToken=a.next,s}return s(n)}(re),Hi={title:null,optionTexts:null,data:null,allowUserSuggestion:null,allowMultipleVotes:null,closeAt:-1},qi=function(e){return L("string",e.title)&&(t=e.optionTexts,F("string",t)&&t.every((function(e){return""!==e.trim()})))&&Ms(e.data)&&L("boolean",e.allowUserSuggestion,!0)&&L("boolean",e.allowMultipleVotes,!0)&&L("number",e.closeAt,!0);var t},ji={channelUrl:null,channelType:null,pollId:null,pollOptionId:null},zi=function(t){return L("string",t.channelUrl)&&D(e.ChannelType,t.channelType)&&L("number",t.pollId)&&L("number",t.pollOptionId)},Vi={channelUrl:null,channelType:null,pollId:null},Bi=function(t){return L("string",t.channelUrl)&&""!==t.channelUrl&&D(e.ChannelType,t.channelType)&&L("number",t.pollId)},Qi={},Ki=function(){function n(e,t){var a=t.sdkState,s=t.dispatcher,i=t.sessionManager,o=t.requestQueue,u=t.logger;r(this,n),this._iid=e,this._sdkState=a,this._sessionManager=i,this._requestQueue=o,this._dispatcher=s,this._logger=u,Qi[e]=this}return s(n,[{key:"buildPollFromSerializedData",value:function(e){var t=Oa(e);return new Us(this._iid,Us.payloadify(t))}},{key:"get",value:function(e){return b(this,void 0,void 0,t().mark((function n(){var r,a,s,i;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return Ua(Bi(e)).throw(M.invalidParameters),r=new Ri(Object.assign({},e)),t.next=4,this._requestQueue.send(r);case 4:return a=t.sent,s=a.as(Li),i=s.poll,t.abrupt("return",i);case 7:case"end":return t.stop()}}),n,this)})))}},{key:"create",value:function(e){return b(this,void 0,void 0,t().mark((function n(){var r,a,s,i,o;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return Ua(qi(e)).throw(M.invalidParameters),r=e.data,a=new Oi(Object.assign(Object.assign({},e),{data:r})),t.next=5,this._requestQueue.send(a);case 5:return s=t.sent,i=s.as(Ui),o=i.poll,t.abrupt("return",o);case 8:case"end":return t.stop()}}),n,this)})))}},{key:"getOption",value:function(e){return b(this,void 0,void 0,t().mark((function n(){var r,a,s,i;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return Ua(zi(e)).throw(M.invalidParameters),r=new Di(Object.assign({},e)),t.next=4,this._requestQueue.send(r);case 4:return a=t.sent,s=a.as(Pi),i=s.pollOption,t.abrupt("return",i);case 7:case"end":return t.stop()}}),n,this)})))}},{key:"getPollChangeLogs",value:function(n,r,a){var s=arguments.length>3&&void 0!==arguments[3]?arguments[3]:e.MessageEventSource.SYNC_POLL_CHANGELOGS;return b(this,void 0,void 0,t().mark((function e(){var i,o,u,c,l,h,d;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return i=new Fi(ee({channelType:r,channelUrl:n,timestamp:"number"==typeof a?a:null,token:"string"==typeof a?a:null})),e.next=3,this._requestQueue.send(i);case 3:return o=e.sent,u=o.as(Gi),c=u.updatedPolls,l=u.deletedPollIds,h=u.hasMore,d=u.nextToken,c.length>0&&this._dispatcher.dispatch(new ri({polls:c,source:s})),e.abrupt("return",{updatedPolls:c,deletedPollIds:l,hasMore:h,token:d});case 7:case"end":return e.stop()}}),e,this)})))}}],[{key:"of",value:function(e){return Qi[e]}}]),n}(),Wi=s((function e(t,n){r(this,e),this.pollId=0,this.messageId=0,this.pollId=n.poll.id,this.messageId=n.poll.message_id,this._iid=t,this._payload=n})),Yi=s((function e(t){r(this,e),this.pollId=0,this.messageId=0,this.pollId=t.poll_id,this.messageId=t.message_id,this._payload=t})),Zi=function(e){i(n,e);var t=f(n);function n(e){var a,s=e.channelUrl,i=e.channelType,o=e.token,u=e.limit;return r(this,n),(a=t.call(this)).method=B.GET,a.path=Jr,a.params={channel_url:s,channel_type:i,token:o,limit:u},a}return s(n)}(ne),Ji=function(e){i(n,e);var t=f(n);function n(e,a){var s,i;return r(this,n),(s=t.call(this,e,a)).polls=(null!==(i=a.polls)&&void 0!==i?i:[]).map((function(t){return new Us(e,t)})),s.token=a.next,s}return s(n)}(re),Xi=function(e){i(a,e);var n=f(a);function a(e,t){return r(this,a),n.call(this,e,t.channelUrl,t.channelType,t)}return s(a,[{key:"next",value:function(){return b(this,void 0,void 0,t().mark((function e(){var n,r,a,s,i,o,u;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!this._validate()){e.next=20;break}if(this._isLoading){e.next=17;break}if(!this._hasNext){e.next=14;break}return this._isLoading=!0,n=ns.of(this._iid),r=n.requestQueue,a=new Zi(Object.assign(Object.assign({},this),{token:this._token})),e.next=8,r.send(a);case 8:return s=e.sent,i=s.as(Ji),o=i.polls,u=i.token,this._token=u,this._hasNext=!!u,this._isLoading=!1,e.abrupt("return",o);case 14:return e.abrupt("return",[]);case 17:throw M.queryInProgress;case 18:e.next=21;break;case 20:throw M.invalidParameters;case 21:case"end":return e.stop()}}),e,this)})))}}]),a}(Si),$i=function(e){i(n,e);var t=f(n);function n(e){var a,s=e.channelUrl,i=e.channelType,o=e.pollId,u=e.pollOptionId,c=e.token,l=e.limit;return r(this,n),(a=t.call(this)).method=B.GET,a.path="".concat(Jr,"/").concat(encodeURIComponent(o),"/options/").concat(encodeURIComponent(u),"/voters"),a.params={channel_url:s,channel_type:i,token:c,limit:l},a}return s(n)}(ne),eo=function(e){i(n,e);var t=f(n);function n(e,a){var s,i;return r(this,n),(s=t.call(this,e,a)).voters=(null!==(i=a.voters)&&void 0!==i?i:[]).map((function(t){return new La(e,t)})),s.token=a.next,s}return s(n)}(re),to=function(e){i(a,e);var n=f(a);function a(e,t){var s;return r(this,a),(s=n.call(this,e,t.channelUrl,t.channelType,t)).pollId=t.pollId,s.pollOptionId=t.pollOptionId,s}return s(a,[{key:"_validate",value:function(){return p(o(a.prototype),"_validate",this).call(this)&&L("number",this.pollId)&&L("number",this.pollOptionId)}},{key:"next",value:function(){return b(this,void 0,void 0,t().mark((function e(){var n,r,a,s,i,o,u;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!this._validate()){e.next=20;break}if(this._isLoading){e.next=17;break}if(!this._hasNext){e.next=14;break}return this._isLoading=!0,n=ns.of(this._iid),r=n.requestQueue,a=new $i(Object.assign(Object.assign({},this),{pollId:this.pollId,pollOptionId:this.pollOptionId,token:this._token})),e.next=8,r.send(a);case 8:return s=e.sent,i=s.as(eo),o=i.voters,u=i.token,this._token=u,this._hasNext=!!u,this._isLoading=!1,e.abrupt("return",o);case 14:return e.abrupt("return",[]);case 17:throw M.queryInProgress;case 18:e.next=21;break;case 20:throw M.invalidParameters;case 21:case"end":return e.stop()}}),e,this)})))}}]),a}(Si),no=function(e){i(a,e);var n=f(a);function a(){var e;return r(this,a),(e=n.apply(this,arguments)).name="poll",e}return s(a,[{key:"init",value:function(e,t){var n=t.sdkState,r=t.dispatcher,s=t.sessionManager,i=t.requestQueue,u=t.logger,c=t.onlineDetector,l=t.cacheContext;p(o(a.prototype),"init",this).call(this,e,{sdkState:n,dispatcher:r,sessionManager:s,requestQueue:i,logger:u,onlineDetector:c,cacheContext:l}),this._manager=new Ki(e,{sdkState:n,dispatcher:r,sessionManager:s,requestQueue:i,logger:u,onlineDetector:c,cacheContext:l})}},{key:"create",value:function(e){return b(this,void 0,void 0,t().mark((function n(){var r;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return r=Object.assign(Object.assign({},Hi),e),Ua(qi(r)).throw(M.invalidParameters),t.abrupt("return",this._manager.create(r));case 3:case"end":return t.stop()}}),n,this)})))}},{key:"get",value:function(e){return b(this,void 0,void 0,t().mark((function n(){var r;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return r=Object.assign(Object.assign({},Vi),e),Ua(Bi(r)).throw(M.invalidParameters),t.abrupt("return",this._manager.get(r));case 3:case"end":return t.stop()}}),n,this)})))}},{key:"getOption",value:function(e){return b(this,void 0,void 0,t().mark((function n(){var r;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return r=Object.assign(Object.assign({},ji),e),Ua(zi(r)).throw(M.invalidParameters),t.abrupt("return",this._manager.getOption(r));case 3:case"end":return t.stop()}}),n,this)})))}},{key:"buildPollFromSerializedData",value:function(e){return this._manager.buildPollFromSerializedData(e)}}]),a}(rs),ro={profileImage:null,profileUrl:null,nickname:null},ao=function(e){return H(e.profileImage,!0)&&L("string",e.profileUrl,!0)&&L("string",e.nickname,!0)},so=function(e){i(n,e);var t=f(n);function n(){var e,a=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return r(this,n),e=t.call(this),Object.keys(a).forEach((function(t){e.hasOwnProperty(t)&&(e[t]=a[t])})),e}return s(n)}(s((function e(){r(this,e),this.onSessionExpired=he,this.onSessionTokenRequired=function(e){return e(null)},this.onSessionError=he,this.onSessionRefreshed=he,this.onSessionClosed=he}))),io=function(e){i(n,e);var t=f(n);function n(){var e,a=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return r(this,n),e=t.call(this),Object.keys(a).forEach((function(t){e.hasOwnProperty(t)&&(e[t]=a[t])})),e}return s(n)}(s((function e(){r(this,e),this.onConnected=he,this.onReconnectStarted=he,this.onReconnectSucceeded=he,this.onReconnectFailed=he,this.onDisconnected=he}))),oo=function(e){i(n,e);var t=f(n);function n(){var e,a=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return r(this,n),e=t.call(this),Object.keys(a).forEach((function(t){e.hasOwnProperty(t)&&(e[t]=a[t])})),e}return s(n)}(s((function e(){r(this,e),this.onFriendsDiscovered=he,this.onTotalUnreadMessageCountUpdated=he}))),uo="GroupChannel",co=100,lo="Message";e.GroupChannelListOrder=void 0,(wi=e.GroupChannelListOrder||(e.GroupChannelListOrder={})).LATEST_LAST_MESSAGE="latest_last_message",wi.CHRONOLOGICAL="chronological",wi.CHANNEL_NAME_ALPHABETICAL="channel_name_alphabetical",wi.METADATA_VALUE_ALPHABETICAL="metadata_value_alphabetical",e.PublicGroupChannelListOrder=void 0,(Ci=e.PublicGroupChannelListOrder||(e.PublicGroupChannelListOrder={})).CHRONOLOGICAL="chronological",Ci.CHANNEL_NAME_ALPHABETICAL="channel_name_alphabetical",Ci.METADATA_VALUE_ALPHABETICAL="metadata_value_alphabetical",e.ScheduledMessageListOrder=void 0,(xi=e.ScheduledMessageListOrder||(e.ScheduledMessageListOrder={})).CREATED_AT="created_at",xi.SCHEDULED_AT="scheduled_at";var ho,fo=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"]}},po=function(){function t(){r(this,t),this.messageTypeFilter=e.MessageTypeFilter.ALL,this.customTypesFilter=null,this.senderUserIdsFilter=null,this.replyType=e.ReplyType.NONE}return s(t,[{key:"clone",value:function(){var e=new t,n=JSON.parse(JSON.stringify(this));return Object.keys(n).forEach((function(t){e[t]=n[t]})),e}},{key:"match",value:function(t){switch(this.messageTypeFilter){case e.MessageTypeFilter.USER:if(t.messageType!==e.MessageType.USER)return!1;break;case e.MessageTypeFilter.FILE:if(t.messageType!==e.MessageType.FILE)return!1;break;case e.MessageTypeFilter.ADMIN:if(t.messageType!==e.MessageType.ADMIN)return!1}if(this.customTypesFilter&&this.customTypesFilter.length>0&&!this.customTypesFilter.includes(t.customType))return!1;if(this.senderUserIdsFilter&&this.senderUserIdsFilter.length>0){if(!(t instanceof Es))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 Es&&t.parentMessageId>0&&!t.replyToChannel)return!1}return!0}}]),t}();!function(e){e.CHANNEL_LATEST="channel_latest",e.NEWEST_CHILD_MESSAGE="newest_child_message"}(ho||(ho={}));var vo,_o=function(e){switch(e){case ho.CHANNEL_LATEST:return["channelUrl","-createdAt","-messageId"];case ho.NEWEST_CHILD_MESSAGE:return["channelUrl","-parentMessageId","-createdAt","-messageId"]}},mo={data:null,customType:null,mentionType:e.MentionType.USERS,mentionedUserIds:null,mentionedUsers:null,mentionedMessageTemplate:null,metaArrays:null,parentMessageId:null,isReplyToChannel:!1,pushNotificationDeliveryOption:null,appleCriticalAlertOptions:null,isPinnedMessage:!1},go=function(t){return L("string",t.data,!0)&&L("string",t.customType,!0)&&D(e.MentionType,t.mentionType)&&F("string",t.mentionedUserIds,!0)&&F(La,t.mentionedUsers,!0)&&L("string",t.mentionedMessageTemplate,!0)&&F(ps,t.metaArrays,!0)&&L("number",t.parentMessageId,!0)&&L("boolean",t.isReplyToChannel)&&D(e.PushNotificationDeliveryOption,t.pushNotificationDeliveryOption,!0)&&L(ms,t.appleCriticalAlertOptions,!0)&&L("boolean",t.isPinnedMessage,!0)},yo=function(e){return e?{isReplyToChannel:e.isReplyToChannel,pushNotificationDeliveryOption:e.pushNotificationDeliveryOption,pollId:e.pollId}:null},ko=Object.assign(Object.assign({},mo),{message:null,translationTargetLanguages:null,pollId:null}),bo=function(e){var t;return ee({data:e.data,customType:e.customType,mentionType:e.mentionType,mentionedUsers:e.mentionedUsers,mentionedUserIds:e.mentionedUserIds,mentionedMessageTemplate:e.mentionedMessageTemplate,metaArrays:e.metaArrays,pollId:null===(t=e.poll)||void 0===t?void 0:t.id,parentMessageId:e.parentMessageId,appleCriticalAlertOptions:e.appleCriticalAlertOptions,message:e.message,translationTargetLanguages:Object.keys(e.translations)})},Eo=function(e){return go(e)&&L("string",e.message)&&F("string",e.translationTargetLanguages,!0)&&L("number",e.pollId,!0)};!function(e){e.FILE="file",e.BLOB="blob",e.BLOB_LIKE_OBJECT="blobLikeObject",e.URL="url"}(vo||(vo={}));var wo=function(e){return"undefined"!=typeof window&&"Blob"in window&&"undefined"!=typeof Blob&&e instanceof Blob},Co=function(e){return e===vo.BLOB||e===vo.FILE},xo=function(e){return e?{file:e.file,fileKey:e.fileKey,fileType:e.fileType,isReplyToChannel:e.isReplyToChannel,pushNotificationDeliveryOption:e.pushNotificationDeliveryOption}:null},To=Object.assign(Object.assign({},mo),{file:null,fileKey:null,fileUrl:null,fileName:null,fileType:null,fileSize:null,mimeType:null,thumbnailSizes:null,requireAuth:!1}),So=function(e){var t,n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null;return e.messageParams?(!e.url&&H(n)&&(e.messageParams.file=n),e.messageParams):ee({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!=n?n:null===(t=e.messageParams)||void 0===t?void 0:t.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}}))})},Io=function(e){return go(e)&&(H(e.file)||L("string",e.fileUrl))&&L("string",e.fileName,!0)&&L("string",e.mimeType,!0)&&L("number",e.fileSize,!0)&&(null===e.thumbnailSizes||Array.isArray(e.thumbnailSizes)&&e.thumbnailSizes.every((function(e){return L("object",e)&&e.maxWidth>0&&e.maxHeight>0})))},No="undefined"!=typeof document&&"undefined"!=typeof navigator;No&&navigator.userAgent&&navigator.userAgent.includes("Chrome/")&&navigator.userAgent.includes("Chromium/");var Ao=No&&navigator.userAgent&&navigator.userAgent.includes("Firefox/")&&!navigator.userAgent.includes("Seamonkey/");No&&navigator.userAgent&&navigator.userAgent.includes("Safari/")&&!navigator.userAgent.includes("Chrome/")&&navigator.userAgent.includes("Chromium/"),No&&navigator.userAgent&&(navigator.userAgent.includes("OPR/")||navigator.userAgent.includes("Opera/")),No&&navigator.userAgent&&navigator.userAgent.includes("Trident/7.0");var Mo,Oo,Uo=No&&navigator.userAgent&&navigator.userAgent.includes("Edge/"),Ro=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"}(Mo||(Mo={})),function(e){e.NEWNODE="newnode",e.REMOVENODE="removenode",e.CLAIM_HOST="claimhost",e.SYNC_HOST="synchost",e.REQUEST_LOCK="requestlock",e.ACQUIRE_LOCK="acquirelock",e.RELEASE_LOCK="releaselock"}(Oo||(Oo={}));var Lo,Do={},Po=function(){function e(t){var n=this,a=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return r(this,e),this._state=Mo.PROCESSING,this._hostId=null,this._queue=[],this._currentItem=null,this._activationTimeout=null,this._activationQueue=[],Do[t]&&!a.forceCreate||(this.nodeId=Ro(),this.key=t,No&&(a.startAsInvisible?this.registerNode():"visible"===document.visibilityState?this.claimHost():this.registerNode(),document.addEventListener("visibilitychange",(function(){"visible"===document.visibilityState&&n.claimHost()})),window.addEventListener("message",(function(e){var t=e.data,r=t.nodeId,a=t.requestId,s=t.key,i=t.op,o=t.data;if(r!==n.nodeId&&s===n.key)switch(i){case Oo.NEWNODE:n._sendSync();break;case Oo.CLAIM_HOST:n._sendSync(),n._hostId=r;break;case Oo.SYNC_HOST:if(!n.isInSync){n._activationTimeout&&clearTimeout(n._activationTimeout);var u,c=o.currentItemRequestId,l=y(o.queue);try{var h=function(){var e=u.value,t=n._queue.findIndex((function(t){return t.requestId===e.requestId}));t<0&&n._requestLock({nodeId:e.nodeId,requestId:e.requestId,key:n.key,op:Oo.REQUEST_LOCK,ts:e.ts})};for(l.s();!(u=l.n()).done;)h()}catch(e){l.e(e)}finally{l.f()}n._currentItem=n._queue.find((function(e){return e.requestId===c})),n._completeSync()}break;case Oo.REMOVENODE:n._queue=n._queue.filter((function(e){return e.nodeId!==t.nodeId})),n._currentItem&&n._currentItem.nodeId===t.nodeId&&(n._currentItem=null,n._acquire(n._queue[0]));break;case Oo.REQUEST_LOCK:n._requestLock(t);break;case Oo.ACQUIRE_LOCK:var d=n._queue.find((function(e){return e.requestId===a}));n._acquire(d);break;case Oo.RELEASE_LOCK:n._release(a)}})),window.addEventListener("beforeunload",(function(){n._send(Oo.REMOVENODE)}))),Do[t]=this),Do[t]}return s(e,[{key:"locked",get:function(){return!!this._currentItem}},{key:"isHost",get:function(){return this._hostId===this.nodeId}},{key:"isInSync",get:function(){return this._state==Mo.DONE}},{key:"_send",value:function(e){var t,n,r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},a={nodeId:this.nodeId,requestId:null!==(t=null==r?void 0:r.requestId)&&void 0!==t?t:Ro(),key:this.key,op:e,data:null!==(n=r.data)&&void 0!==n?n:null,ts:Date.now()};return No&&window.postMessage(a,"*"),a}},{key:"_acquire",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:null;e?(this._currentItem=e,this._currentItem.onAcquired(e.requestId)):this._currentItem=null}},{key:"_release",value:function(e){if(this._currentItem&&this._currentItem.requestId===e){var t=this._currentItem;this._currentItem=null,t.nodeId===this.nodeId&&this._send(Oo.RELEASE_LOCK,{requestId:t.requestId});var n=this._queue.findIndex((function(t){return t.requestId===e}));n>-1&&this._queue.splice(n,1),t.onReleased(e)}}},{key:"_requestLock",value:function(e){var t=this;return new Promise((function(n){var r={nodeId:e.nodeId,requestId:e.requestId,ts:e.ts,onAcquired:function(e){t.isHost&&t._send(Oo.ACQUIRE_LOCK,{requestId:e}),n()},onReleased:function(){t._acquire(t._queue[0])}},a=!1;for(var s in t._queue)if(t._queue[s].ts>r.ts){t._queue.splice(parseInt(s),0,r),a=!0;break}a||t._queue.push(r),t._currentItem||t._acquire(t._queue[0])}))}},{key:"_sendSync",value:function(){var e;this.isHost&&this._send(Oo.SYNC_HOST,{data:{currentItemRequestId:null===(e=this._currentItem)||void 0===e?void 0:e.requestId,queue:this._queue.map((function(e){return{nodeId:e.nodeId,requestId:e.requestId,ts:e.ts}}))}})}},{key:"_waitUntilSyncCompleted",value:function(){return b(this,void 0,void 0,t().mark((function e(){var n=this;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!this.isHost||this.isInSync){e.next=2;break}return e.abrupt("return",new Promise((function(e){n._activationQueue.push(e)})));case 2:case"end":return e.stop()}}),e,this)})))}},{key:"_waitSync",value:function(){var e=this;this.isInSync||(this._activationTimeout=setTimeout((function(){e._completeSync()}),8))}},{key:"_completeSync",value:function(){this.isInSync||(this._state=Mo.DONE,this._activationQueue.forEach((function(e){return e()})),this._activationQueue=[])}},{key:"registerNode",value:function(){this._send(Oo.NEWNODE),this._waitSync()}},{key:"claimHost",value:function(){this._hostId=this.nodeId,this._send(Oo.CLAIM_HOST),this._waitSync()}},{key:"lock",value:function(){return b(this,void 0,void 0,t().mark((function e(){var n;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this._waitUntilSyncCompleted();case 2:return n=this._send(Oo.REQUEST_LOCK),e.next=5,this._requestLock(n);case 5:case"end":return e.stop()}}),e,this)})))}},{key:"unlock",value:function(){var e;this._release(null===(e=this._currentItem)||void 0===e?void 0:e.requestId)}}]),e}(),Fo=Object.assign(Object.assign({},ko),{scheduledAt:null}),Go=Object.assign(Object.assign({},mo),{scheduledAt:null,file:null,fileUrl:null,fileName:null,mimeType:null,fileSize:null,thumbnailSizes:null,requireAuth:!1}),Ho="UnsentMessage",qo={},jo=function(e){i(a,e);var n=f(a);function a(e,t){var s,i=t.sdkState,o=t.cacheContext;return r(this,a),(s=n.call(this,e))._sdkState=i,s._cacheContext=o,qo[e]=d(s),s._mutex=new Po("unsendmessagecache.lock"),s}return s(a,[{key:"collection",get:function(){var e=this._cacheContext.nestdb;return e&&e.collection(Ho)}},{key:"localCacheEnabled",get:function(){return this._cacheContext.localCacheEnabled&&!!this.collection}},{key:"_serialize",value:function(e){if(e.messageId>0)throw M.invalidParameters;var t,n=Object.assign({},e.serialize());return e instanceof Rs?(e.messageParams&&(n.messageParams=yo(e.messageParams)),e.scheduledInfo&&e.scheduledInfo.scheduledMessageParams&&(n.scheduledInfo.scheduledMessageParams=(t=e.scheduledInfo.scheduledMessageParams,Object.assign(Object.assign({},yo(t)),{scheduledAt:t.scheduledAt})))):e instanceof Ps&&(e.messageParams&&(n.messageParams=xo(e.messageParams)),e.scheduledInfo&&e.scheduledInfo.scheduledMessageParams&&(n.scheduledInfo.scheduledMessageParams=function(e){return Object.assign(Object.assign({},xo(e)),{scheduledAt:e.scheduledAt})}(e.scheduledInfo.scheduledMessageParams))),n}},{key:"_deserialize",value:function(e){return e?(e=Object.assign(Object.assign({},e),{messageId:parseInt(e.messageId)}),vi.of(this._iid).buildMessageFromSerializedData(e)):null}},{key:"_deserializeWithMessageCreateParams",value:function(e){return b(this,void 0,void 0,t().mark((function n(){var r,a,s,i,o,u;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(r=vi.of(this._iid),a=this._deserialize(e),!e.messageParams){t.next=15;break}if(!(a instanceof Rs)){t.next=8;break}s=e.messageParams,a.messageParams=r.buildUserMessageCreateParamsFromSerializedData(s,a),t.next=15;break;case 8:if(!(a instanceof Ps)){t.next=15;break}if(!(i=e.messageParams).fileKey||"string"!=typeof i.fileKey||!Co(i.fileType)){t.next=14;break}return t.next=13,this.collection.getBlob(i.fileKey);case 13:i.file=t.sent;case 14:a.messageParams=r.buildFileMessageCreateParamsFromSerializedData(i,a);case 15:if(!(a.scheduledInfo&&e.scheduledInfo&&e.scheduledInfo.scheduledMessageParams)){t.next=28;break}if(!(a instanceof Rs)){t.next=21;break}o=e.scheduledInfo.scheduledMessageParams,a.scheduledInfo.scheduledMessageParams=r.buildScheduledUserMessageCreateParamsFromSerializedData(o,a),t.next=28;break;case 21:if(!(a instanceof Ps)){t.next=28;break}if(!(u=e.scheduledInfo.scheduledMessageParams).fileKey||"string"!=typeof u.fileKey||!Co(u.fileType)){t.next=27;break}return t.next=26,this.collection.getBlob(u.fileKey);case 26:u.file=t.sent;case 27:a.scheduledInfo.scheduledMessageParams=r.buildScheduledFileMessageCreateParamsFromSerializedData(u,a);case 28:return t.abrupt("return",a);case 29:case"end":return t.stop()}}),n,this)})))}},{key:"get",value:function(e){return b(this,void 0,void 0,t().mark((function n(){var r;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(!this.localCacheEnabled){t.next=6;break}return t.next=3,this.collection.getByKey("".concat(e));case 3:if(!(r=t.sent)){t.next=6;break}return t.abrupt("return",this._deserializeWithMessageCreateParams(r));case 6:return t.abrupt("return",null);case 7:case"end":return t.stop()}}),n,this)})))}},{key:"fetch",value:function(e){var n=e.channelUrl,r=void 0===n?null:n,a=e.filter,s=void 0===a?new po:a,i=e.order,o=void 0===i?ho.CHANNEL_LATEST:i,u=e.sendingStatus,c=void 0===u?null:u,l=e.backward,h=void 0!==l&&l,d=e.parentMessageId,f=void 0===d?null:d;return b(this,void 0,void 0,t().mark((function e(){var n,a,i,u,l,d=this;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!this.localCacheEnabled){e.next=13;break}return n=_o(o),a={"/where":function(e){return!!(o!==ho.NEWEST_CHILD_MESSAGE||f&&0!==e.parentMessageId&&e.parentMessageId===f)&&s.match(d._deserialize(e))}},r&&(a.channelUrl=r),c&&(a.sendingStatus=c),i={where:a,index:n,backward:h},e.next=8,this.collection.query(i);case 8:return u=e.sent,e.next=11,u.fetch({});case 11:return l=e.sent,e.abrupt("return",Promise.all(l.map((function(e){return b(d,void 0,void 0,t().mark((function n(){return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,this._deserializeWithMessageCreateParams(e);case 2:return t.abrupt("return",t.sent);case 3:case"end":return t.stop()}}),n,this)})))}))));case 13:return e.abrupt("return",[]);case 14:case"end":return e.stop()}}),e,this)})))}},{key:"getAllChildMessages",value:function(e){var n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:new po;return b(this,void 0,void 0,t().mark((function r(){return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,this.fetch({filter:n,order:ho.NEWEST_CHILD_MESSAGE,channelUrl:e.channelUrl,backward:!1,parentMessageId:e.messageId});case 2:return t.abrupt("return",t.sent);case 3:case"end":return t.stop()}}),r,this)})))}},{key:"upsert",value:function(e){return b(this,void 0,void 0,t().mark((function n(){var r=this;return t().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:if(!this.localCacheEnabled){n.next=3;break}return n.next=3,Promise.all(e.map((function(e){return b(r,void 0,void 0,t().mark((function n(){var r;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(!(e instanceof Ps)){t.next=7;break}return t.next=3,this._mutex.lock();case 3:return t.next=5,this.saveBlob(e);case 5:return t.next=7,this._mutex.unlock();case 7:return r=this._serialize(e),t.next=10,this.collection.upsertOne(r);case 10:case"end":return t.stop()}}),n,this)})))})));case 3:case"end":return n.stop()}}),n,this)})))}},{key:"upsertChildMessages",value:function(e){return b(this,void 0,void 0,t().mark((function n(){var r=this;return t().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:if(!this.localCacheEnabled){n.next=3;break}return n.next=3,Promise.all(e.map((function(e){return b(r,void 0,void 0,t().mark((function n(){var r,a;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(a=[],!((null===(r=e.threadInfo)||void 0===r?void 0:r.replyCount)>0)){t.next=5;break}return t.next=4,this.getAllChildMessages(e);case 4:a=t.sent;case 5:if(!(a.length>0)){t.next=9;break}return a.forEach((function(t){return t.applyParentMessage(e)})),t.next=9,this.upsert(a);case 9:case"end":return t.stop()}}),n,this)})))})));case 3:case"end":return n.stop()}}),n,this)})))}},{key:"remove",value:function(e){return b(this,void 0,void 0,t().mark((function n(){var r,a,s;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(!this.localCacheEnabled){t.next=18;break}r=y(e),t.prev=2,r.s();case 4:if((a=r.n()).done){t.next=10;break}return s=a.value,t.next=8,this.collection.remove(s);case 8:t.next=4;break;case 10:t.next=15;break;case 12:t.prev=12,t.t0=t.catch(2),r.e(t.t0);case 15:return t.prev=15,r.f(),t.finish(15);case 18:case"end":return t.stop()}}),n,this,[[2,12,15,18]])})))}},{key:"removeMessagesOfChannel",value:function(e){return b(this,void 0,void 0,t().mark((function n(){return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(!this.localCacheEnabled){t.next=3;break}return t.next=3,this.collection.removeIf({where:{channelUrl:e}});case 3:case"end":return t.stop()}}),n,this)})))}},{key:"clear",value:function(){return b(this,void 0,void 0,t().mark((function e(){return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!this.localCacheEnabled){e.next=3;break}return e.next=3,this.collection.clear();case 3:case"end":return e.stop()}}),e,this)})))}},{key:"saveBlob",value:function(e){return b(this,void 0,void 0,t().mark((function n(){var r,a,s,i;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(!(e instanceof Ps)){t.next=17;break}if(!e.messageParams){t.next=9;break}if(!(r=e.messageParams).file||!wo(r.file)){t.next=9;break}return t.next=6,this.collection.saveBlob(r.file,e.reqId);case 6:a=t.sent,r.fileKey=a,r.fileType=vo.BLOB;case 9:if(!e.scheduledInfo||!e.scheduledInfo.scheduledMessageParams){t.next=17;break}if(!(s=e.scheduledInfo.scheduledMessageParams).file||!wo(s.file)){t.next=17;break}return t.next=14,this.collection.saveBlob(s.file,e.reqId);case 14:i=t.sent,s.fileKey=i,s.fileType=vo.BLOB;case 17:case"end":return t.stop()}}),n,this)})))}}],[{key:"of",value:function(e){return qo[e]}}]),a}(Ca),zo=function(n,r){return function(a,s){if(1===a)n.clear().then((function(){r.clear().then((function(){(function(n){return b(void 0,void 0,void 0,t().mark((function r(){return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.abrupt("return",n.commitSchema([{collectionName:uo,keyName:"url",index:[fo(e.GroupChannelListOrder.LATEST_LAST_MESSAGE),fo(e.GroupChannelListOrder.CHRONOLOGICAL),fo(e.GroupChannelListOrder.CHANNEL_NAME_ALPHABETICAL)]},{collectionName:lo,keyName:"messageId",index:[_o(ho.CHANNEL_LATEST),_o(ho.NEWEST_CHILD_MESSAGE)]},{collectionName:Ho,keyName:"reqId",index:[_o(ho.CHANNEL_LATEST),_o(ho.NEWEST_CHILD_MESSAGE)]},{collectionName:"Poll",keyName:"pollId"}]));case 1:case"end":return t.stop()}}),r)})))})(n).then((function(){return s()})).catch((function(e){return s(e)}))})).catch((function(e){return s(e)}))})).catch((function(e){return s(e)}));else s()}},Vo={},Bo=function(e){i(a,e);var n=f(a);function a(e,t){var s,i=t.sdkState,o=t.cacheContext,u=t.unsentMessageCache;return r(this,a),(s=n.call(this,e))._sdkState=i,s._cacheContext=o,s._unsentMessageCache=u,Vo[e]=d(s),s}return s(a,[{key:"collection",get:function(){var e=this._cacheContext.nestdb;return e?e.collection(lo):null}},{key:"localCacheEnabled",get:function(){return this._cacheContext.localCacheEnabled&&!!this.collection}},{key:"_serialize",value:function(e){return Object.assign(Object.assign({},e.serialize()),{messageId:"".concat(e.messageId)})}},{key:"_deserialize",value:function(e){return e=Object.assign(Object.assign({},e),{messageId:parseInt(e.messageId)}),vi.of(this._iid).buildMessageFromSerializedData(e)}},{key:"get",value:function(e){return b(this,void 0,void 0,t().mark((function n(){var r;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(!this.localCacheEnabled){t.next=6;break}return t.next=3,this.collection.getByKey("".concat(e));case 3:if(!(r=t.sent)){t.next=6;break}return t.abrupt("return",this._deserialize(r));case 6:return t.abrupt("return",null);case 7:case"end":return t.stop()}}),n,this)})))}},{key:"fetch",value:function(e){var n=e.channelUrl,r=e.token,a=e.limit,s=void 0===a?co:a,i=e.filter,o=void 0===i?new po:i,u=e.order,c=void 0===u?ho.CHANNEL_LATEST:u,l=e.backward,h=void 0!==l&&l,d=e.parentMessageId,f=void 0===d?null:d,p=e.isPollOnly,v=void 0!==p&&p;return b(this,void 0,void 0,t().mark((function e(){var a,i,u,l,d=this;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!this.localCacheEnabled){e.next=10;break}return a=_o(c),i={where:{channelUrl:n,"/where":function(e){if(r)switch(c){case ho.CHANNEL_LATEST:if(!h&&e.createdAt>r||h&&e.createdAt1&&void 0!==arguments[1]?arguments[1]:new po;return b(this,void 0,void 0,t().mark((function r(){return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,this.fetch({channelUrl:e.channelUrl,token:Date.now(),limit:null,backward:!1,filter:n,order:ho.NEWEST_CHILD_MESSAGE,parentMessageId:e.messageId});case 2:return t.abrupt("return",t.sent);case 3:case"end":return t.stop()}}),r,this)})))}},{key:"upsert",value:function(e){return b(this,void 0,void 0,t().mark((function n(){var r,a=this;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(!this.localCacheEnabled){t.next=10;break}return t.next=3,this.saveBlobs(e);case 3:return r=e.map((function(e){return a._serialize(e)})),t.next=6,this.collection.upsertMany(r);case 6:return t.next=8,this.upsertChildMessages(e);case 8:return t.next=10,this._unsentMessageCache.upsertChildMessages(e);case 10:case"end":return t.stop()}}),n,this)})))}},{key:"upsertChildMessages",value:function(e){return b(this,void 0,void 0,t().mark((function n(){var r=this;return t().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:if(!this.localCacheEnabled){n.next=3;break}return n.next=3,Promise.all(e.map((function(e){return b(r,void 0,void 0,t().mark((function n(){var r,a;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(a=[],!((null===(r=e.threadInfo)||void 0===r?void 0:r.replyCount)>0)){t.next=5;break}return t.next=4,this.getAllChildMessages(e);case 4:a=t.sent;case 5:if(!(a.length>0)){t.next=9;break}return a.forEach((function(t){return t.applyParentMessage(e)})),t.next=9,this.upsert(a);case 9:case"end":return t.stop()}}),n,this)})))})));case 3:case"end":return n.stop()}}),n,this)})))}},{key:"remove",value:function(e){return b(this,void 0,void 0,t().mark((function n(){var r,a,s;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(!this.localCacheEnabled){t.next=18;break}r=y(e),t.prev=2,r.s();case 4:if((a=r.n()).done){t.next=10;break}return s=a.value,t.next=8,this.collection.remove("".concat(s));case 8:t.next=4;break;case 10:t.next=15;break;case 12:t.prev=12,t.t0=t.catch(2),r.e(t.t0);case 15:return t.prev=15,r.f(),t.finish(15);case 18:case"end":return t.stop()}}),n,this,[[2,12,15,18]])})))}},{key:"removeMessagesOfChannel",value:function(e){return b(this,void 0,void 0,t().mark((function n(){var r;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(!this.localCacheEnabled){t.next=12;break}return t.next=3,this.collection.removeIf({where:{channelUrl:e},index:_o(ho.CHANNEL_LATEST)});case 3:return r=this._cacheContext.preference,t.next=6,r.remove("sendbird:".concat(this._sdkState.userId,"@groupchannel/").concat(e,"/message/sync"));case 6:return t.next=8,r.remove("sendbird:".concat(this._sdkState.userId,"@groupchannel/").concat(e,"/message/sync.meta"));case 8:return t.next=10,r.remove("sendbird:".concat(this._sdkState.userId,"@groupchannel/").concat(e,"/message/changelogs"));case 10:return t.next=12,r.remove("sendbird:".concat(this._sdkState.userId,"@groupchannel/").concat(e,"/message/changelogs.meta"));case 12:case"end":return t.stop()}}),n,this)})))}},{key:"removeUnderOffset",value:function(e,n){return b(this,void 0,void 0,t().mark((function r(){return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(!this.localCacheEnabled){t.next=3;break}return t.next=3,this.collection.removeIf({where:{channelUrl:e,createdAt:{"<":n}},index:_o(ho.CHANNEL_LATEST)});case 3:case"end":return t.stop()}}),r,this)})))}},{key:"clear",value:function(){return b(this,void 0,void 0,t().mark((function e(){return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!this.localCacheEnabled){e.next=3;break}return e.next=3,this.collection.clear();case 3:case"end":return e.stop()}}),e,this)})))}},{key:"countBetween",value:function(e,n,r){return b(this,void 0,void 0,t().mark((function a(){var s,i,o=this;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(!this.localCacheEnabled){t.next=6;break}return s=_o(ho.CHANNEL_LATEST),i=this.collection.query({where:{channelUrl:e,"/where":function(e){var t=o._deserialize(e);return r.includes(t.createdAt)&&n.match(t)}},index:s}),t.next=5,i.count();case 5:return t.abrupt("return",t.sent);case 6:return t.abrupt("return",0);case 7:case"end":return t.stop()}}),a,this)})))}},{key:"saveBlobs",value:function(e){return b(this,void 0,void 0,t().mark((function n(){var r=this;return t().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return n.next=2,Promise.all(e.map((function(e){return b(r,void 0,void 0,t().mark((function n(){var r,a;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(!(e instanceof Ps&&e.messageParams)){t.next=7;break}if(!(r=e.messageParams).file||!wo(r.file)){t.next=7;break}return t.next=5,this.collection.saveBlob(r.file,e.reqId);case 5:a=t.sent,r.fileKey=a;case 7:case"end":return t.stop()}}),n,this)})))})));case 2:case"end":return n.stop()}}),n)})))}},{key:"_getGroupChannelPreferenceSize",value:function(e){return b(this,void 0,void 0,t().mark((function n(){var r,a,s,i,o,u;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return r=0,a=this._cacheContext.preference,t.next=4,a.get("sendbird:".concat(this._sdkState.userId,"@groupchannel/").concat(e,"/message/sync"));case 4:return s=t.sent,t.next=7,a.get("sendbird:".concat(this._sdkState.userId,"@groupchannel/").concat(e,"/message/sync.meta"));case 7:return i=t.sent,t.next=10,a.get("sendbird:".concat(this._sdkState.userId,"@groupchannel/").concat(e,"/message/changelogs"));case 10:return o=t.sent,t.next=13,a.get("sendbird:".concat(this._sdkState.userId,"@groupchannel/").concat(e,"/message/changelogs.meta"));case 13:return u=t.sent,s&&(r+=JSON.stringify(s).length),i&&(r+=JSON.stringify(i).length),o&&(r+=JSON.stringify(o).length),u&&(r+=JSON.stringify(u).length),t.abrupt("return",r);case 19:case"end":return t.stop()}}),n,this)})))}}],[{key:"of",value:function(e){return Vo[e]}}]),a}(Ca),Qo=function(){return"undefined"!=typeof document?document.visibilityState:"visible"},Ko=function(e){i(n,e);var t=f(n);function n(e){var a,s=e.getVisibilityState,i=void 0===s?Qo:s,o=e.initialState,u=void 0===o?"visible":o,c=e.isEnabled,l=void 0===c||c,h=e.pauseCheckDelay,f=void 0===h?3e4:h;return r(this,n),(a=t.call(this))._pauseCheckDelay=3e4,a._pauseDelayTimer=null,a._currentState="visible",a._getVisibilityState=i,a._pauseCheckDelay=f,a._currentState=u,a._isEnabled=l,a._boundToggleState=a._toggleState.bind(d(a)),a}return s(n,[{key:"currentState",get:function(){return this._currentState}},{key:"isAvailable",get:function(){return"undefined"!=typeof window&&!!window.addEventListener&&!!window.removeEventListener}},{key:"_toggleState",value:function(){var e=this,t=this._getVisibilityState();"hidden"!==t?"hidden"===this._currentState&&(this._pauseDelayTimer&&(clearTimeout(this._pauseDelayTimer),this._pauseDelayTimer=null),this.dispatch("resume")):"hidden"!==this._currentState&&(this._pauseDelayTimer=setTimeout((function(){e._pauseDelayTimer=null,e.dispatch("pause")}),this._pauseCheckDelay)),this._currentState=t}},{key:"start",value:function(){this._isEnabled&&this.isAvailable&&(this._boundToggleState=this._toggleState.bind(this),window.addEventListener("visibilitychange",this._boundToggleState,{capture:!0}))}},{key:"stop",value:function(){this._isEnabled&&this.isAvailable&&this._boundToggleState&&window.removeEventListener("visibilitychange",this._boundToggleState,{capture:!0})}}]),n}(J),Wo=function(){function e(t){var n=this,a=t.logger,s=t.connectionDelegate,i=void 0===s?null:s;r(this,e),this._onlineWorker=function(){var e;return null===(e=n.connectionDelegate)||void 0===e?void 0:e.reconnect()},this._offlineWorker=function(){var e;return null===(e=n.connectionDelegate)||void 0===e?void 0:e.disconnect()},this.unsubscribes=[],this._onlineListener=function(e){if(n.isAvailableOnWeb)return window.addEventListener("online",e),function(){return window.removeEventListener("online",e,!1)}},this._offlineListener=function(e){if(n.isAvailableOnWeb)return window.addEventListener("offline",e),function(){return window.removeEventListener("offline",e,!1)}},this.logger=a,i&&(this.connectionDelegate=i)}return s(e,[{key:"isAvailableOnWeb",get:function(){return"undefined"!=typeof window&&window.addEventListener&&"ononline"in window&&"onoffline"in window&&"undefined"!=typeof navigator&&void 0!==navigator.onLine}},{key:"setOnlineListener",value:function(e){Boolean(e)&&"function"==typeof e&&(this._onlineListener=e)}},{key:"setOfflineListener",value:function(e){Boolean(e)&&"function"==typeof e&&(this._offlineListener=e)}},{key:"start",value:function(){this.unsubscribes=[this._onlineListener(this._onlineWorker),this._offlineListener(this._offlineWorker)]}},{key:"stop",value:function(){var e=this;this.unsubscribes.forEach((function(t){try{null==t||t()}catch(t){e.logger.warn(t.message)}})),this.unsubscribes=[]}},{key:"isOnline",value:function(){return b(this,void 0,void 0,t().mark((function e(){return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!this.isAvailableOnWeb){e.next=4;break}return e.abrupt("return",navigator.onLine);case 4:return e.abrupt("return",new Promise((function(e){fetch("https://www.google.com",{method:B.GET,mode:"no-cors"}).then((function(){return e(!0)})).catch((function(){return e(!1)}))})));case 5:case"end":return e.stop()}}),e,this)})))}}]),e}(),Yo=function(e){i(n,e);var t=f(n);function n(e){var a,s=e.message;return r(this,n),(a=t.call(this)).message=s,a}return s(n)}($),Zo={},Jo=function(){function n(e,t){var a=this,s=t.localCacheEnabled,i=t.dispatcher,o=t.sdkState,u=t.logger;r(this,n),this._iid=e,Zo[e]=this,this._localCacheEnabled=s,this._isProcessingAutoResend=!1,this._autoResendQueue=[],this._dispatcher=i,this._logger=u,this._sdkState=o,this._localCacheEnabled&&i.on((function(e){if(e instanceof Dr)switch(e.stateType){case Nr.CONNECTED:a._isProcessingAutoResend||a.processAutoResendRegisteredPendingMessages().then((function(){return a._processNextAutoResend()}));break;case Nr.INTERNAL_DISCONNECTED:case Nr.EXTERNAL_DISCONNECTED:a._isProcessingAutoResend=!1}}))}return s(n,[{key:"processNonAutoResendRegisteredPendingMessages",value:function(){return b(this,void 0,void 0,t().mark((function n(){var r,a,s,i;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,this._fetchAllCachedPendingMessages();case 2:r=t.sent,a=y(r);try{for(a.s();!(s=a.n()).done;)0===(i=s.value).errorCode&&(this._logger.debug("cached pending message is not auto-resend registered. changing its sending status to failed: ",i.reqId),i.sendingStatus=e.SendingStatus.FAILED,i.errorCode=E.ACK_TIMEOUT,this._dispatcher.dispatch(new ei({messages:[i],source:e.MessageEventSource.LOCAL_MESSAGE_FAILED})))}catch(e){a.e(e)}finally{a.f()}case 5:case"end":return t.stop()}}),n,this)})))}},{key:"processAutoResendRegisteredPendingMessages",value:function(){return b(this,void 0,void 0,t().mark((function n(){var r,a,s,i,o,u;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,this._fetchAllCachedPendingMessages();case 2:r=t.sent,a=y(r);try{for(a.s();!(s=a.n()).done;)(i=s.value).errorCode&&G(i.errorCode)&&(o=(new Date).getTime(),u=i.createdAt+2592e5,o<=u?this._autoResendQueue.map((function(e){return e.reqId})).indexOf(i.reqId)<0&&this._autoResendQueue.push(i):(this._logger.debug("auto-resend registered pending messaged expired. expiration date: ",new Date(u).toLocaleString()),i.sendingStatus=e.SendingStatus.FAILED,this._dispatcher.dispatch(new ei({messages:[i],source:e.MessageEventSource.LOCAL_MESSAGE_FAILED}))))}catch(e){a.e(e)}finally{a.f()}case 5:case"end":return t.stop()}}),n,this)})))}},{key:"completeCurrentAndProcessNextAutoResend",value:function(t){if(this._localCacheEnabled&&(t.sendingStatus===e.SendingStatus.SUCCEEDED||t.sendingStatus===e.SendingStatus.FAILED&&!G(t.errorCode))){var n=this.indexOf(t);n>=0&&this._autoResendQueue.splice(n,1),0===n&&this._processNextAutoResend()}}},{key:"_fetchAllCachedPendingMessages",value:function(){return b(this,void 0,void 0,t().mark((function n(){var r;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(!(r=jo.of(this._iid))){t.next=7;break}return t.next=4,r.fetch({sendingStatus:e.SendingStatus.PENDING,backward:!0});case 4:t.t0=t.sent,t.next=8;break;case 7:t.t0=[];case 8:return t.abrupt("return",t.t0);case 9:case"end":return t.stop()}}),n,this)})))}},{key:"indexOf",value:function(e){return this._autoResendQueue.length>0?this._autoResendQueue.map((function(e){return e.reqId})).indexOf(e.reqId):-1}},{key:"_isNotInQueue",value:function(e){return-1===this._autoResendQueue.map((function(e){return e.reqId})).indexOf(e.reqId)}},{key:"_processNextAutoResend",value:function(){return b(this,void 0,void 0,t().mark((function e(){var n;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(this._localCacheEnabled&&"foreground"===this._sdkState.appState)try{this._autoResendQueue.length>0?(this._isProcessingAutoResend||(this._logger.debug("auto-resend queue started."),this._isProcessingAutoResend=!0),n=this._autoResendQueue[0],this._dispatcher.dispatch(new Yo({message:n})),this._logger.debug("processing auto-resend for message request id: ",n.reqId)):(this._logger.debug("auto-resend queue finished."),this._isProcessingAutoResend=!1)}catch(e){this._logger.warn("process auto-resend error: ",e),this._isProcessingAutoResend=!1}case 1:case"end":return e.stop()}}),e,this)})))}}],[{key:"of",value:function(e){return Zo[e]}}]),n}();!function(e){e[e.USER_BLOCK=20001]="USER_BLOCK",e[e.USER_UNBLOCK=2e4]="USER_UNBLOCK",e[e.FRIEND_DISCOVERED=20900]="FRIEND_DISCOVERED"}(Lo||(Lo={}));var Xo,$o=function(){function e(t){r(this,e),this.category=t.cat,this.data=t.data}return s(e,null,[{key:"getDataAsUserBlockEvent",value:function(e,t){var n=t.data,r=n.blocker,a=n.blockee;return{blocker:new La(e,r),blockee:new La(e,a)}}},{key:"getDataAsFriendDiscoveredEvent",value:function(e,t){var n=t.data.friend_discoveries;return{friendDiscoveries:Array.isArray(n)?n.map((function(t){return new La(e,t)})):[]}}}]),e}(),eu=function(e){i(n,e);var t=f(n);function n(e,a){var s,i=a.userId;return r(this,n),(s=t.call(this))._iid=e,s.userId=i,s}return s(n)}($);e.GroupChannelEventSource=void 0,(Xo=e.GroupChannelEventSource||(e.GroupChannelEventSource={})).UNKNOWN="UNKNOWN",Xo.EVENT_CHANNEL_CREATED="EVENT_CHANNEL_CREATED",Xo.EVENT_CHANNEL_UPDATED="EVENT_CHANNEL_UPDATED",Xo.EVENT_CHANNEL_DELETED="EVENT_CHANNEL_DELETED",Xo.EVENT_CHANNEL_READ="EVENT_CHANNEL_READ",Xo.EVENT_CHANNEL_DELIVERED="EVENT_CHANNEL_DELIVERED",Xo.EVENT_CHANNEL_INVITED="EVENT_CHANNEL_INVITED",Xo.EVENT_CHANNEL_JOINED="EVENT_CHANNEL_JOINED",Xo.EVENT_CHANNEL_LEFT="EVENT_CHANNEL_LEFT",Xo.EVENT_CHANNEL_ACCEPTED_INVITE="EVENT_CHANNEL_ACCEPTED_INVITE",Xo.EVENT_CHANNEL_DECLINED_INVITE="EVENT_CHANNEL_DECLINED_INVITE",Xo.EVENT_CHANNEL_OPERATOR_UPDATED="EVENT_CHANNEL_OPERATOR_UPDATED",Xo.EVENT_CHANNEL_MUTED="EVENT_CHANNEL_MUTED",Xo.EVENT_CHANNEL_UNMUTED="EVENT_CHANNEL_UNMUTED",Xo.EVENT_CHANNEL_FROZEN="EVENT_CHANNEL_FROZEN",Xo.EVENT_CHANNEL_UNFROZEN="EVENT_CHANNEL_UNFROZEN",Xo.EVENT_CHANNEL_HIDDEN="EVENT_CHANNEL_HIDDEN",Xo.EVENT_CHANNEL_UNHIDDEN="EVENT_CHANNEL_UNHIDDEN",Xo.EVENT_CHANNEL_RESET_HISTORY="EVENT_CHANNEL_RESET_HISTORY",Xo.EVENT_CHANNEL_TYPING_STATUS_UPDATE="EVENT_CHANNEL_TYPING_STATUS_UPDATE",Xo.EVENT_CHANNEL_MEMBER_COUNT_UPDATED="EVENT_CHANNEL_MEMBER_COUNT_UPDATED",Xo.EVENT_MESSAGE_SENT="EVENT_MESSAGE_SENT",Xo.EVENT_MESSAGE_RECEIVED="EVENT_MESSAGE_RECEIVED",Xo.EVENT_MESSAGE_UPDATED="EVENT_MESSAGE_UPDATED",Xo.EVENT_PINNED_MESSAGE_UPDATED="EVENT_PINNED_MESSAGE_UPDATED",Xo.REQUEST_CHANNEL="REQUEST_CHANNEL",Xo.REQUEST_CHANNEL_CHANGELOGS="REQUEST_CHANNEL_CHANGELOGS",Xo.REFRESH_CHANNEL="REFRESH_CHANNEL",Xo.CHANNEL_LASTACCESSEDAT_UPDATED="CHANNEL_LASTACCESSEDAT_UPDATED",Xo.SYNC_CHANNEL_BACKGROUND="SYNC_CHANNEL_BACKGROUND",Xo.SYNC_CHANNEL_CHANGELOGS="SYNC_CHANNEL_CHANGELOGS";var tu,nu=function(t){return t.startsWith("EVENT_")||t===e.GroupChannelEventSource.SYNC_CHANNEL_CHANGELOGS||t===e.GroupChannelEventSource.REFRESH_CHANNEL},ru=function(e){i(n,e);var t=f(n);function n(e){var a,s=e.channels,i=e.source,o=e.data,u=void 0===o?null:o;return r(this,n),(a=t.call(this)).channels=s,a.source=i,a.data=u,a}return s(n)}($),au=function(e){i(n,e);var t=f(n);function n(e){var a,s=e.channelUrls,i=e.source;return r(this,n),(a=t.call(this)).channelUrls=s,a.source=i,a}return s(n)}($),su=function(e){i(n,e);var t=f(n);function n(){return r(this,n),t.call(this)}return s(n)}($),iu=function(e){i(n,e);var t=f(n);function n(e,a,s){var i;return r(this,n),(i=t.call(this,e,"USEV",s)).event=new $o(s),i}return s(n)}(le),ou=function(e){i(n,e);var t=f(n);function n(e){var a,s=e.userId,i=e.nickname,o=void 0===i?null:i,u=e.profileUrl,c=void 0===u?null:u,l=e.profileImage,h=void 0===l?null:l,d=e.preferredLanguages,f=void 0===d?null:d;return r(this,n),(a=t.call(this)).method=B.PUT,a.path="".concat(qr,"/").concat(encodeURIComponent(s)),a.params=ee({nickname:o,profile_url:c,profile_file:h,preferred_languages:f}),a}return s(n)}(ne),uu=function(e){i(n,e);var t=f(n);function n(e,a){var s;return r(this,n),(s=t.call(this,e,a)).user=null,s.user=new La(e,Object.assign({},a)),s}return s(n)}(re),cu=function(e){i(n,e);var t=f(n);function n(e){var a,s=e.userId,i=e.token;return r(this,n),(a=t.call(this)).method=B.POST,a.path="".concat(qr,"/").concat(encodeURIComponent(s),"/push/apns"),a.params={apns_device_token:i,always_push:!0},a}return s(n)}(ne),lu=function(e){i(n,e);var t=f(n);function n(e){var a,s=e.userId,i=e.token;return r(this,n),(a=t.call(this)).method=B.POST,a.path="".concat(qr,"/").concat(encodeURIComponent(s),"/push/gcm"),a.params={gcm_reg_token:i,always_push:!0},a}return s(n)}(ne),hu=function(e){i(n,e);var t=f(n);function n(e){var a,s=e.userId,i=e.token;return r(this,n),(a=t.call(this)).method=B.DELETE,a.path="".concat(qr,"/").concat(encodeURIComponent(s),"/push/apns/").concat(encodeURIComponent(i)),a}return s(n)}(ne),du=function(e){i(n,e);var t=f(n);function n(e){var a,s=e.userId,i=e.token;return r(this,n),(a=t.call(this)).method=B.DELETE,a.path="".concat(qr,"/").concat(encodeURIComponent(s),"/push/gcm/").concat(encodeURIComponent(i)),a}return s(n)}(ne),fu=function(e){i(n,e);var t=f(n);function n(e){var a,s=e.userId;return r(this,n),(a=t.call(this)).method=B.DELETE,a.path="".concat(qr,"/").concat(encodeURIComponent(s),"/push/apns"),a}return s(n)}(ne),pu=function(e){i(n,e);var t=f(n);function n(e){var a,s=e.userId;return r(this,n),(a=t.call(this)).method=B.DELETE,a.path="".concat(qr,"/").concat(encodeURIComponent(s),"/push/gcm"),a}return s(n)}(ne),vu=function(e){i(n,e);var t=f(n);function n(e){var a,s=e.userId,i=e.type,o=e.token,u=e.ts;return r(this,n),(a=t.call(this)).method=B.GET,a.path="".concat(qr,"/").concat(encodeURIComponent(s),"/push/").concat(encodeURIComponent(i),"/device_tokens"),a.params={created_ts:u,token:o},a}return s(n)}(ne),_u=function(t){i(a,t);var n=f(a);function a(t,s){var i;return r(this,a),(i=n.call(this,t,s)).pushTokens={type:s.type?e.PushTokenType[s.type.toLowerCase()]:e.PushTokenType.UNKNOWN,deviceTokens:s.device_tokens,hasMore:s.has_more,token:s.token},i}return s(a)}(re),mu=function(e){i(n,e);var t=f(n);function n(e){var a,s=e.userId;return r(this,n),(a=t.call(this)).method=B.GET,a.path="".concat(qr,"/").concat(encodeURIComponent(s),"/channel_invitation_preference"),a}return s(n)}(ne),gu=function(e){i(n,e);var t=f(n);function n(e,a){var s;return r(this,n),(s=t.call(this,e,a)).autoAccept=a.auto_accept,s}return s(n)}(re),yu=function(e){i(n,e);var t=f(n);function n(e){var a,s=e.userId,i=e.willAutoAccept;return r(this,n),(a=t.call(this)).method=B.PUT,a.path="".concat(qr,"/").concat(encodeURIComponent(s),"/channel_invitation_preference"),a.params={auto_accept:i},a}return s(n)}(ne),ku=function(e){i(n,e);var t=f(n);function n(e,a){var s;return r(this,n),(s=t.call(this,e,a)).autoAccept=a.auto_accept,s}return s(n)}(re),bu=function(e){i(n,e);var t=f(n);function n(e){var a,s=e.userId;return r(this,n),(a=t.call(this)).method=B.GET,a.path="".concat(qr,"/").concat(encodeURIComponent(s),"/push_preference"),a}return s(n)}(ne),Eu=function(e){i(n,e);var t=f(n);function n(e,a){var s;return r(this,n),(s=t.call(this,e,a)).preference={doNotDisturbOn:a.do_not_disturb,startHour:a.start_hour,startMin:a.start_min,endHour:a.end_hour,endMin:a.end_min,timezone:a.timezone},s}return s(n)}(re),wu=function(e){i(n,e);var t=f(n);function n(e){var a,s=e.userId,i=e.doNotDisturbOn,o=e.startHour,u=e.startMin,c=e.endHour,l=e.endMin,h=e.timezone;return r(this,n),(a=t.call(this)).method=B.PUT,a.path="".concat(qr,"/").concat(encodeURIComponent(s),"/push_preference"),a.params={do_not_disturb:i,start_hour:o,start_min:u,end_hour:c,end_min:l,timezone:h},a}return s(n)}(ne),Cu=function(e){i(n,e);var t=f(n);function n(e,a){var s;return r(this,n),(s=t.call(this,e,a)).preference={doNotDisturbOn:a.do_not_disturb,startHour:a.start_hour,startMin:a.start_min,endHour:a.end_hour,endMin:a.end_min,timezone:a.timezone},s}return s(n)}(re),xu=function(e){i(n,e);var t=f(n);function n(e){var a,s=e.userId;return r(this,n),(a=t.call(this)).method=B.GET,a.path="".concat(qr,"/").concat(encodeURIComponent(s),"/push_preference"),a}return s(n)}(ne),Tu=function(e){i(n,e);var t=f(n);function n(e,a){var s;return r(this,n),(s=t.call(this,e,a)).snoozePeriod={isSnoozeOn:a.snooze_enabled},"number"==typeof a.snooze_start_ts&&(s.snoozePeriod.startTs=a.snooze_start_ts),"number"==typeof a.snooze_end_ts&&(s.snoozePeriod.endTs=a.snooze_end_ts),s}return s(n)}(re),Su=function(e){i(n,e);var t=f(n);function n(e){var a,s=e.userId,i=e.snoozeOn,o=e.startTs,u=e.endTs;return r(this,n),(a=t.call(this)).method=B.PUT,a.path="".concat(qr,"/").concat(encodeURIComponent(s),"/push_preference"),a.params={snooze_enabled:i,snooze_start_ts:o,snooze_end_ts:u},a}return s(n)}(ne),Iu=function(e){i(n,e);var t=f(n);function n(e,a){var s;return r(this,n),(s=t.call(this,e,a)).snoozePeriod={isSnoozeOn:a.snooze_enabled},"number"==typeof a.snooze_start_ts&&(s.snoozePeriod.startTs=a.snooze_start_ts),"number"==typeof a.snooze_end_ts&&(s.snoozePeriod.endTs=a.snooze_end_ts),s}return s(n)}(re),Nu=function(e){i(n,e);var t=f(n);function n(e){var a,s=e.userId,i=e.blockedUserId;return r(this,n),(a=t.call(this)).method=B.POST,a.path="".concat(qr,"/").concat(encodeURIComponent(s),"/block"),a.params={target_id:i},a}return s(n)}(ne),Au=function(e){i(n,e);var t=f(n);function n(e){var a,s=e.userId,i=e.unblockedUserId;return r(this,n),(a=t.call(this)).method=B.DELETE,a.path="".concat(qr,"/").concat(encodeURIComponent(s),"/block/").concat(encodeURIComponent(i)),a}return s(n)}(ne),Mu=function(e){i(n,e);var t=f(n);function n(e){var a,s=e.userId;return r(this,n),(a=t.call(this)).method=B.GET,a.path="".concat(qr,"/").concat(encodeURIComponent(s),"/push_preference"),a}return s(n)}(ne),Ou=function(e){i(n,e);var t=f(n);function n(e,a){var s;return r(this,n),(s=t.call(this,e,a)).pushTriggerOption=a.push_trigger_option,s}return s(n)}(re),Uu=function(e){i(n,e);var t=f(n);function n(e){var a,s=e.userId,i=e.pushTriggerOption;return r(this,n),(a=t.call(this)).method=B.PUT,a.path="".concat(qr,"/").concat(encodeURIComponent(s),"/push_preference"),a.params={push_trigger_option:i},a}return s(n)}(ne),Ru=function(e){i(n,e);var t=f(n);function n(e,a){var s;return r(this,n),(s=t.call(this,e,a)).pushTriggerOption=a.push_trigger_option,s}return s(n)}(re),Lu=function(e){i(n,e);var t=f(n);function n(e){var a,s=e.userId;return r(this,n),(a=t.call(this)).method=B.GET,a.path="".concat(qr,"/").concat(encodeURIComponent(s),"/push/template"),a}return s(n)}(ne),Du=function(e){i(n,e);var t=f(n);function n(e,a){var s;return r(this,n),(s=t.call(this,e,a)).name=a.name,s}return s(n)}(re),Pu=function(e){i(n,e);var t=f(n);function n(e){var a,s=e.userId,i=e.templateName;return r(this,n),(a=t.call(this)).method=B.PUT,a.path="".concat(qr,"/").concat(encodeURIComponent(s),"/push/template"),a.params={name:i},a}return s(n)}(ne),Fu=function(e){i(n,e);var t=f(n);function n(e,a){var s;return r(this,n),(s=t.call(this,e,a)).name=a.name,s}return s(n)}(re),Gu=function(e){i(n,e);var t=f(n);function n(e){var a,s=e.userId,i=e.token;return r(this,n),(a=t.call(this)).method=B.GET,a.path="".concat(qr,"/").concat(encodeURIComponent(s),"/friends/changelogs"),a.params={token:i},a}return s(n)}(ne),Hu=function(e){i(n,e);var t=f(n);function n(e,a){var s;return r(this,n),(s=t.call(this,e,a)).changelogs={addedUsers:a.added.map((function(t){return new La(e,t)})),updatedUsers:a.updated.map((function(t){return new La(e,t)})),deletedUserIds:a.deleted,hasMore:a.has_more,token:a.next},s}return s(n)}(re),qu=function(e){i(n,e);var t=f(n);function n(e){var a,s=e.userId,i=e.discoveries;return r(this,n),(a=t.call(this)).method=B.PUT,a.path="".concat(qr,"/").concat(encodeURIComponent(s),"/friend_discoveries"),a.params={friend_discoveries:i.map((function(e){return{friend_discovery_key:e.friendDiscoveryKey,friend_name:e.friendName}}))},a}return s(n)}(ne),ju=function(e){i(n,e);var t=f(n);function n(e,a){var s;return r(this,n),(s=t.call(this,e,a)).friendDiscoveryRequestId=a.friend_discovery_request_id,s}return s(n)}(re),zu=function(e){i(n,e);var t=f(n);function n(e){var a,s=e.userId,i=e.discoveryKeys;return r(this,n),(a=t.call(this)).method=B.DELETE,a.path="".concat(qr,"/").concat(encodeURIComponent(s),"/friend_discoveries"),a.params={friend_discovery_keys:i},a}return s(n)}(ne),Vu=function(e){i(n,e);var t=f(n);function n(e){var a,s=e.userId,i=e.userIds;return r(this,n),(a=t.call(this)).method=B.POST,a.path="".concat(qr,"/").concat(encodeURIComponent(s),"/friends"),a.params={user_ids:i},a}return s(n)}(ne),Bu=function(e){i(n,e);var t=f(n);function n(e,a){var s;return r(this,n),(s=t.call(this,e,a)).users=a.users.map((function(t){return new La(e,t)})),s}return s(n)}(re),Qu=function(e){i(n,e);var t=f(n);function n(e){var a,s=e.userId,i=e.userIds;return r(this,n),(a=t.call(this)).method=B.DELETE,a.path="".concat(qr,"/").concat(encodeURIComponent(s),"/friends"),a.params={user_ids:i},a}return s(n)}(ne),Ku=function(e){i(n,e);var t=f(n);function n(e){var a,s=e.userId;return r(this,n),(a=t.call(this)).method=B.GET,a.path="".concat(qr,"/").concat(s,"/allow_friend_discovery"),a.params={},a}return s(n)}(ne),Wu=function(e){i(n,e);var t=f(n);function n(e,a){var s;return r(this,n),(s=t.call(this,e,a)).allowFriendDiscovery=a.allow_friend_discovery,s}return s(n)}(re),Yu=function(e){i(n,e);var t=f(n);function n(e){var a,s=e.userId,i=e.allowFriendDiscovery;return r(this,n),(a=t.call(this)).method=B.PUT,a.path="".concat(qr,"/").concat(s,"/allow_friend_discovery"),a.params={allow_friend_discovery:i},a}return s(n)}(ne),Zu=s((function e(t){r(this,e),this.key=null,this.url=null,this.key=t.key,this.url=t.url})),Ju=s((function e(t){var n,a,s;r(this,e),this.id=0,this.name=null,this.url=null,this.emojis=[],this.id=null!==(n=t.id)&&void 0!==n?n:0,this.name=null!==(a=t.name)&&void 0!==a?a:"",this.url=null!==(s=t.url)&&void 0!==s?s:"",this.emojis=t.emojis?t.emojis.map((function(e){return new Zu(e)})):[]})),Xu=s((function e(t){r(this,e),this.emojiHash=null,this.emojiCategories=[],this.emojiHash=t.emoji_hash||"",this.emojiCategories=t.emoji_categories?t.emoji_categories.map((function(e){return new Ju(e)})):[]})),$u=function(e){i(n,e);var t=f(n);function n(){var e;return r(this,n),(e=t.call(this)).method=B.GET,e.path=Zr,e}return s(n)}(ne),ec=function(e){i(n,e);var t=f(n);function n(e,a){var s;return r(this,n),(s=t.call(this,e,a)).emojiContainer=new Xu(a),s}return s(n)}(re),tc=function(e){i(n,e);var t=f(n);function n(e){var a,s=e.categoryId;return r(this,n),(a=t.call(this)).method=B.GET,a.path="".concat(Zr,"/").concat(s),a}return s(n)}(ne),nc=function(e){i(n,e);var t=f(n);function n(e,a){var s;return r(this,n),(s=t.call(this,e,a)).emojiCategory=new Ju(a),s}return s(n)}(re),rc=function(e){i(n,e);var t=f(n);function n(e){var a,s=e.key;return r(this,n),(a=t.call(this)).method=B.GET,a.path="".concat(Yr,"/").concat(s),a}return s(n)}(ne),ac=function(e){i(n,e);var t=f(n);function n(e,a){var s;return r(this,n),(s=t.call(this,e,a)).emoji=new Zu(a),s}return s(n)}(re),sc=function(e){i(n,e);var t=f(n);function n(e){var a,s=e.limit,i=e.token,o=e.userIdsFilter,u=e.metaDataKeyFilter,c=e.metaDataValuesFilter,l=e.nicknameStartsWithFilter;return r(this,n),(a=t.call(this)).method=B.GET,a.path=qr,a.params=ee({limit:s,token:i,user_ids:o,metadatakey:u,metadatavalues_in:c,nickname_startswith:l}),a}return s(n)}(ne),ic=function(e){i(n,e);var t=f(n);function n(e,a){var s;return r(this,n),(s=t.call(this,e,a)).users=a.users.map((function(t){return new La(e,t)})),s.next=a.next,s}return s(n)}(re),oc=function(e){i(a,e);var n=f(a);function a(e,t){var s,i,o,u;return r(this,a),(s=n.call(this,e,t)).userIdsFilter=null,s.metaDataKeyFilter=null,s.metaDataValuesFilter=null,s.nicknameStartsWithFilter=null,s.userIdsFilter=null!==(i=t.userIdsFilter)&&void 0!==i?i:null,s.metaDataKeyFilter=null!==(o=t.metaDataKeyFilter)&&void 0!==o?o:null,s.metaDataValuesFilter=null!==(u=t.metaDataValuesFilter)&&void 0!==u?u:null,s.nicknameStartsWithFilter=t.nicknameStartsWithFilter||null,s}return s(a,[{key:"_validate",value:function(){return p(o(a.prototype),"_validate",this).call(this)&&F("string",this.userIdsFilter,!0)&&L("string",this.metaDataKeyFilter,!0)&&F("string",this.metaDataValuesFilter,!0)&&L("string",this.metaDataKeyFilter,!0)}},{key:"next",value:function(){return b(this,void 0,void 0,t().mark((function e(){var n,r,a,s,i,o,u;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!this._validate()){e.next=20;break}if(this._isLoading){e.next=17;break}if(!this._hasNext){e.next=14;break}return this._isLoading=!0,n=ns.of(this._iid),r=n.requestQueue,a=new sc(Object.assign(Object.assign({},this),{token:this._token})),e.next=8,r.send(a);case 8:return s=e.sent,i=s.as(ic),o=i.users,u=i.next,this._token=u,this._hasNext=!!u,this._isLoading=!1,e.abrupt("return",o);case 14:return e.abrupt("return",[]);case 17:throw M.queryInProgress;case 18:e.next=21;break;case 20:throw M.invalidParameters;case 21:case"end":return e.stop()}}),e,this)})))}}]),a}(ki),uc=function(e){i(n,e);var t=f(n);function n(e){var a,s=e.userId,i=e.limit,o=e.token,u=e.userIdsFilter;return r(this,n),(a=t.call(this)).method=B.GET,a.path="".concat(qr,"/").concat(s,"/block"),a.params=ee({limit:i,token:o,user_ids:u}),a}return s(n)}(ne),cc=function(e){i(n,e);var t=f(n);function n(e,a){var s;return r(this,n),(s=t.call(this,e,a)).users=a.users.map((function(t){return new La(e,t)})),s.next=a.next,s}return s(n)}(re),lc=function(e){i(a,e);var n=f(a);function a(e,t){var s,i;return r(this,a),(s=n.call(this,e,t)).userIdsFilter=null,s.userIdsFilter=null!==(i=t.userIdsFilter)&&void 0!==i?i:null,s}return s(a,[{key:"_validate",value:function(){return p(o(a.prototype),"_validate",this).call(this)&&F("string",this.userIdsFilter,!0)}},{key:"next",value:function(){return b(this,void 0,void 0,t().mark((function e(){var n,r,a,s,i,o,u,c;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!this._validate()){e.next=20;break}if(this._isLoading){e.next=17;break}if(!this._hasNext){e.next=14;break}return this._isLoading=!0,n=ns.of(this._iid),r=n.sdkState,a=n.requestQueue,s=new uc(Object.assign(Object.assign({},this),{userId:r.userId,token:this._token})),e.next=8,a.send(s);case 8:return i=e.sent,o=i.as(cc),u=o.users,c=o.next,this._token=c,this._hasNext=!!c,this._isLoading=!1,e.abrupt("return",u);case 14:return e.abrupt("return",[]);case 17:throw M.queryInProgress;case 18:e.next=21;break;case 20:throw M.invalidParameters;case 21:case"end":return e.stop()}}),e,this)})))}}]),a}(ki),hc=function(e){i(n,e);var t=f(n);function n(e){var a,s=e.userId,i=e.limit,o=e.token;return r(this,n),(a=t.call(this)).method=B.GET,a.path="".concat(qr,"/").concat(encodeURIComponent(s),"/friends"),a.params={limit:i,token:o},a}return s(n)}(ne),dc=function(e){i(n,e);var t=f(n);function n(e,a){var s;return r(this,n),(s=t.call(this,e,a)).hasMore=a.has_more,s.users=a.users.map((function(t){return new La(e,t)})),s.next=a.next,s}return s(n)}(re),fc=function(e){i(a,e);var n=f(a);function a(){return r(this,a),n.apply(this,arguments)}return s(a,[{key:"_validate",value:function(){return p(o(a.prototype),"_validate",this).call(this)}},{key:"next",value:function(){return b(this,void 0,void 0,t().mark((function e(){var n,r,a,s,i,o,u,c,l;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!this._validate()){e.next=20;break}if(this._isLoading){e.next=17;break}if(!this._hasNext){e.next=14;break}return this._isLoading=!0,n=ns.of(this._iid),r=n.sdkState,a=n.requestQueue,s=new hc(Object.assign(Object.assign({},this),{userId:r.userId,token:this._token})),e.next=8,a.send(s);case 8:return i=e.sent,o=i.as(dc),u=o.users,c=o.hasMore,l=o.next,this._token=l,this._hasNext=c,this._isLoading=!1,e.abrupt("return",u);case 14:return e.abrupt("return",[]);case 17:throw M.queryInProgress;case 18:e.next=21;break;case 20:throw M.invalidParameters;case 21:case"end":return e.stop()}}),e,this)})))}}]),a}(ki),pc={},vc=function(){function e(t){var n=t.dbname,a=t.itemSizeLimit,s=void 0===a?1048576:a,i=t.cacheLimit,o=void 0===i?256:i,u=t.blockHashBase,c=void 0===u?2:u,l=t.blockHashMultiplier,h=void 0===l?10:l,d=t.blockHashConstant,f=void 0===d?11:d,p=t.transactionApplyDelay,v=void 0===p?200:p,_=t.disableLogger,m=void 0!==_&&_;return r(this,e),pc[n]||(this.itemSizeLimit=s,this.cacheLimit=o,this.blockHashBase=c,this.blockHashMultiplier=h,this.blockHashConstant=f,this.transactionApplyDelay=v,this.disableLogger=m,pc[n]=this),pc[n]}return s(e,null,[{key:"get",value:function(e){return pc[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"}(tu||(tu={}));var _c,mc=function(e){i(n,e);var t=f(n);function n(e){var a,s=e.code,i=void 0===s?tu.UNKNOWN_ERROR:s,o=e.message,u=void 0===o?"Unknown error occurred.":o;return r(this,n),(a=t.call(this,u)).code=i,Object.setPrototypeOf(d(a),n.prototype),a}return s(n,null,[{key:"storeNotDefined",get:function(){return new n({code:tu.STORE_NOT_DEFINED,message:"Store is not defined. Specify the store on NestDB()"})}},{key:"storeNotAvailable",get:function(){return new n({code:tu.STORE_NOT_AVAILABLE,message:"Store is not available. Check your environment settings."})}},{key:"storeNotAvailableInPrivateBrowsing",get:function(){return new n({code:tu.STORE_NOT_AVAILABLE_IN_PRIVATE_BROWSING,message:"Store is not available because it is in private browsing."})}},{key:"storeIsFull",get:function(){return new n({code:tu.STORE_IS_FULL,message:"Store is full."})}},{key:"storeKeyTypeIsInvalid",get:function(){return new n({code:tu.STORE_INVALID_KEY_TYPE,message:"Store key should be string type."})}},{key:"storeBrokenIntegrity",get:function(){return new n({code:tu.STORE_BROKEN_INTEGRITY,message:"Data should be in a store but it does not. Integrity is broken."})}},{key:"storeBrokenBlob",get:function(){return new n({code:tu.STORE_BROKEN_BLOB,message:"Data should be in a store but it does not. Blob data is broken."})}},{key:"storeEncryptionInvalid",get:function(){return new n({code:tu.STORE_ENCRYPTION_INVALID,message:"Encryption algorithm has changed. All the store should reset."})}},{key:"storeItemSizeExceeded",get:function(){return new n({code:tu.STORE_ITEM_SIZE_LIMIT_EXCEEDED,message:"The size of the item exceeds the limit that the store allows."})}},{key:"storeReadFailed",get:function(){return new n({code:tu.STORE_READ_FAILED,message:"Failed to read from store."})}},{key:"storeWriteFailed",get:function(){return new n({code:tu.STORE_WRITE_FAILED,message:"Failed to write to store."})}},{key:"databaseSchemaNotOnUpgrade",get:function(){return new n({code:tu.DATABASE_SCHEMA_NOT_ON_UPGRADE,message:"Committing schema is not allowed when upgrade is not running."})}},{key:"collectionNotReady",get:function(){return new n({code:tu.COLLECTION_NOT_READY,message:"Collection is not ready due to an error during initialization."})}},{key:"collectionKeyNotMatch",get:function(){return new n({code:tu.COLLECTION_KEY_NOT_MATCH,message:"keyName of collection could not change."})}},{key:"collectionQueryNotValid",get:function(){return new n({code:tu.COLLECTION_QUERY_NOT_VALID,message:"Query parameter is not a valid format."})}},{key:"collectionInsertDuplicate",get:function(){return new n({code:tu.COLLECTION_INSERT_DUPLICATE,message:"The key already exists."})}},{key:"collectionKeyNotFound",get:function(){return new n({code:tu.COLLECTION_KEY_NOT_FOUND,message:"The key is not found."})}},{key:"collectionKeyNotGiven",get:function(){return new n({code:tu.COLLECTION_KEY_NOT_GIVEN,message:"The item should contain [keyName] property."})}},{key:"collectionWriteFailed",get:function(){return new n({code:tu.COLLECTION_WRITE_FAILED,message:"Failed to write an item."})}},{key:"collectionItemSizeExceeded",get:function(){return new n({code:tu.COLLECTION_ITEM_SIZE_LIMIT_EXCEEDED,message:"The size of the item exceeds the limit that a collection allows."})}},{key:"indexTableIsRequired",get:function(){return new n({code:tu.INDEX_TABLE_IS_REQUIRED,message:"Index table is required."})}},{key:"indexTypesNotMatch",get:function(){return new n({code:tu.INDEX_TYPE_NOT_MATCH,message:"Indexed column should have primitive type."})}},{key:"compareTypesNotMatch",get:function(){return new n({code:tu.COMPARE_TYPE_NOT_MATCH,message:"Values to compare have different types."})}},{key:"circularReferenceFound",get:function(){return new n({code:tu.CIRCULAR_REFERENCE_FOUND,message:"Cannot handle circular referenced object."})}}]),n}(h(Error));!function(e){e.INIT="init",e.READY="ready",e.CLOSED="closed"}(_c||(_c={}));var gc,yc=function e(t){var r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:new WeakMap;if("object"===n(t)&&null!==t){if(r.has(t))throw mc.circularReferenceFound;r.set(t,!0);var a=null;if(Array.isArray(t))a=t.map((function(t){return e(t,r)}));else if(t instanceof RegExp)a=t;else if(t instanceof Date)a=t;else for(var s in a={},t)a[s]=e(t[s],r);return r.delete(t),a}return t},kc=function(e,t){if(null==t)return 1;if(null==e)return-1;if(n(e)!==n(t))throw mc.compareTypesNotMatch;var r=0;switch(n(e)){case"boolean":case"number":r=e-t;break;case"string":r=e.localeCompare(t)}return r},bc=function(e,t){for(var n=0,r=0;r>>0)%t},Ec=function(e){return new Promise((function(t){setTimeout((function(){return t()}),e)}))},wc=function e(t,r){if(!r)return!1;if("function"!=typeof t){for(var a in t){if(["/and","&&"].includes(a)){if(t[a].some((function(t){return!e(t,r)})))return!1}else if(["/or","||"].includes(a)){if(t[a].every((function(t){return!e(t,r)})))return!1}else if("/where"===a){if(!(0,t[a])(r))return!1}else{var s=a;if("object"===n(t[s])){var i=t[s];for(var o in i)switch(o){case"/eq":case"=":if(r[s]!==i[o])return!1;break;case"/neq":case"!=":if(r[s]===i[o])return!1;break;case"/gt":case">":var u=r[s],c=i[o];if(!(kc(u,c)>0))return!1;break;case"/gte":case">=":var l=r[s],h=i[o];if(!(kc(l,h)>=0))return!1;break;case"/lt":case"<":var d=r[s],f=i[o];if(!(kc(d,f)<0))return!1;break;case"/lte":case"<=":var p=r[s],v=i[o];if(!(kc(p,v)<=0))return!1;break;case"/in":var _=r[s];if(!i[o].includes(_))return!1;break;case"/nin":var m=r[s];if(i[o].includes(m))return!1;break;case"/contain":var g=r[s],y=i[o];if(!g.includes(y))return!1;break;case"/regex":var k=r[s];if(!i[o].test(k))return!1;break;case"/where":var b=r[s];if(!(0,i[o])(b))return!1}}else if("function"==typeof t[s]){if(!t[s](r[s]))return!1}else if(t[s]!==r[s])return!1}}return!0}return t(r)},Cc=function(){},xc=function(){return Promise.resolve()},Tc=function(e){return e},Sc=function(e,t){t(null)};!function(e){e[e.FORWARD=0]="FORWARD",e[e.BACKWARD=1]="BACKWARD"}(gc||(gc={}));var Ic,Nc,Ac,Mc=function(){function e(t){var n=t.initialPrevValue,a=void 0===n?null:n,s=t.initialNextValue,i=void 0===s?null:s,o=t.iterator,u=t.map,c=void 0===u?Tc:u,l=t.backward,h=void 0===l?xc:l,d=t.forward,f=void 0===d?xc:d,p=t.complete,v=void 0===p?Cc:p;r(this,e),this._prevValue=a,this._nextValue=i,this._error=null,this._map=c,this._backward=h,this._forward=f,this._iterator=o,this._complete=v}return s(e,[{key:"prevValue",get:function(){return this._map(this._prevValue)}},{key:"nextValue",get:function(){return this._map(this._nextValue)}},{key:"error",get:function(){return this._error}},{key:"hasPrevious",get:function(){return!!this._prevValue}},{key:"hasNext",get:function(){return!!this._nextValue}},{key:"prev",value:function(){return b(this,void 0,void 0,t().mark((function e(){var n;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!this.hasPrevious){e.next=20;break}return e.prev=1,n=this._prevValue,e.next=5,this._backward();case 5:if(e.t0=e.sent,e.t0){e.next=8;break}e.t0=null;case 8:this._prevValue=e.t0,this._nextValue=n,e.next=15;break;case 12:e.prev=12,e.t1=e.catch(1),this._error=e.t1;case 15:return e.next=17,this._iterator(this);case 17:return e.abrupt("return",e.sent);case 20:this._complete();case 21:case"end":return e.stop()}}),e,this,[[1,12]])})))}},{key:"next",value:function(){return b(this,void 0,void 0,t().mark((function e(){var n;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!this.hasNext){e.next=20;break}return e.prev=1,n=this._nextValue,e.next=5,this._forward();case 5:if(e.t0=e.sent,e.t0){e.next=8;break}e.t0=null;case 8:this._nextValue=e.t0,this._prevValue=n,e.next=15;break;case 12:e.prev=12,e.t1=e.catch(1),this._error=e.t1;case 15:return e.next=17,this._iterator(this);case 17:return e.abrupt("return",e.sent);case 20:this._complete();case 21:case"end":return e.stop()}}),e,this,[[1,12]])})))}},{key:"stop",value:function(){this._prevValue=null,this._nextValue=null,this._complete()}}]),e}(),Oc=function(){function e(t){var n=t.condition,a=void 0===n?{}:n,s=t.backward,i=void 0!==s&&s,o=t.blockManager,u=t.indexer;r(this,e),this.condition=a,this.backward=i,this._blockManager=o,this._indexer=u}return s(e,[{key:"findOptimizedStartPosition",value:function(){var e=this,t=["=","/eq",">",">=","/gt","/gte"],r=["=","/eq","<","<=","/lt","/lte"];if(this.backward){var a=this._indexer.origin.length-1;if("function"!=typeof this.condition)for(var s in this._indexer.fields){var i=this._indexer.fields[s],o=1;if("-"===i[0]&&(i=i.slice(1),o=-1),this.condition[i])if("object"===n(this.condition[i])){var u=o>0?r:t;for(var c in this.condition[i])if(u.includes(c))for(var l=a;l>=0;l--)if(o*kc(this._indexer.origin[l].columnValues[s],this.condition[i][c])<=0){a=l;break}}else for(var h=a;h>=0;h--)if(o*kc(this._indexer.origin[h].columnValues[s],this.condition[i])<=0){a=h;break}}return Math.min(a+1,this._indexer.origin.length-1)}var d=0;if("function"!=typeof this.condition)for(var f=function(a){var s=e._indexer.fields[a],i=1;if("-"===s[0]&&(s=s.slice(1),i=-1),e.condition[s])if("object"===n(e.condition[s]))Object.keys(e.condition[s]).forEach((function(n){if((i>0?t:r).includes(n))for(var o=d;o=0){d=o;break}}));else for(var o=d;o=0){d=o;break}},p=0;p0&&void 0!==arguments[0]?arguments[0]:{};return b(this,void 0,void 0,t().mark((function n(){var r,a,s,i=this;return t().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:if(r=Math.max(e.offset||0,0),0!==(a="number"==typeof e.limit?e.limit:Number.MAX_SAFE_INTEGER)){n.next=6;break}return n.abrupt("return",[]);case 6:if(!(a<0)){n.next=8;break}throw mc.collectionQueryNotValid;case 8:return n.prev=8,s=[],n.next=12,this._mutex.lock();case 12:return n.next=14,this._iterator.each((function(e){return b(i,void 0,void 0,t().mark((function n(){return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:e.error?e.stop():e.hasNext?0===r?(s.push(e.nextValue),03&&void 0!==arguments[3]?arguments[3]:0;return"".concat(Fc(e,t)).concat(n,".").concat(r)},Hc=function(){function e(t){var n=t.dbname,a=t.collectionName,s=t.store;r(this,e),this.dbname=n,this.collectionName=a,this.store=s}return s(e,[{key:"get",value:function(e){return b(this,void 0,void 0,t().mark((function n(){var r,a,s,i,o,u,c,l,h,d;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,this.store.get(e);case 2:if(!(r=t.sent)){t.next=19;break}if(a=r.data,s=r.type,"undefined"==typeof fetch){t.next=14;break}return t.next=8,fetch(a);case 8:return i=t.sent,t.next=11,i.blob();case 11:return t.abrupt("return",t.sent);case 14:for(512,o=[],u=atob(a.split(",")[1]),c=0;c1&&void 0!==arguments[1]?arguments[1]:"".concat(Date.now());return b(this,void 0,void 0,t().mark((function r(){var a,s,i,o,u=this;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,new Promise((function(t){var r=Gc(u.dbname,u.collectionName,n),a=new FileReader;a.onload=function(){t({blobId:r,data:a.result,type:e.type})},a.readAsDataURL(e)}));case 2:return a=t.sent,s=a.blobId,i=a.data,o=a.type,t.next=8,this.store.set({key:s,value:{data:i,type:o},generation:1});case 8:return t.abrupt("return",s);case 9:case"end":return t.stop()}}),r,this)})))}},{key:"remove",value:function(e){return b(this,void 0,void 0,t().mark((function n(){return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,this.store.remove(e);case 2:case"end":return t.stop()}}),n,this)})))}},{key:"clear",value:function(){return b(this,void 0,void 0,t().mark((function e(){var n,r,a=this;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n=Fc(this.dbname,this.collectionName),e.next=3,this.store.getAllKeys();case 3:return r=e.sent,e.next=6,Promise.all(r.filter((function(e){return e.startsWith(n)})).map((function(e){return b(a,void 0,void 0,t().mark((function n(){return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,this.store.remove(e);case 2:return t.abrupt("return",t.sent);case 3:case"end":return t.stop()}}),n,this)})))})));case 6:case"end":return e.stop()}}),e,this)})))}}]),e}();!function(e){e[e.COMMIT=0]="COMMIT",e[e.WRITE=1]="WRITE",e[e.ERROR=2]="ERROR"}(Ic||(Ic={})),function(e){e.PENDING="pending",e.PERSISTENT="persistent",e.VOLATILE="volatile"}(Nc||(Nc={})),function(e){e[e.NO_CACHE=0]="NO_CACHE",e[e.DEFAULT=1]="DEFAULT",e[e.PERSISTENT=2]="PERSISTENT"}(Ac||(Ac={}));var qc,jc=[Nc.PENDING,Nc.VOLATILE],zc={},Vc=function(){function e(t){var n=t.dbname,a=t.limit,s=void 0===a?256:a;return r(this,e),zc[n]||(this.dbname=n,this._items=[],this._limit=s,zc[n]=this),zc[n]}return s(e,[{key:"items",get:function(){return this._items}},{key:"find",value:function(e,n){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:Ac.DEFAULT;return b(this,void 0,void 0,t().mark((function a(){var s,i;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(s=this.get(n)){t.next=8;break}return t.next=4,e.get(n);case 4:(i=t.sent)&&(s={key:n,value:i,generation:1,state:r===Ac.PERSISTENT?Nc.PERSISTENT:Nc.VOLATILE},this.put(s)),t.next=9;break;case 8:r===Ac.PERSISTENT&&(s.state=Nc.PERSISTENT);case 9:return t.abrupt("return",s);case 10:case"end":return t.stop()}}),a,this)})))}},{key:"get",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:Ac.DEFAULT,n=this._items.map((function(e){return e.key})).indexOf(e);if(n>-1){var r=this._items[n];return t===Ac.PERSISTENT&&(r.state=Nc.PERSISTENT),t!==Ac.NO_CACHE&&this.put(r),r}return null}},{key:"put",value:function(e){if(this._limit>0){var t=this._items.map((function(e){return e.key})).indexOf(e.key);if(t>-1)jc.includes(this._items[t].state)&&jc.includes(e.state)?(this._items.splice(t,1),this._items.push(e)):(this._items[t].state=e.state,this._items[t].generation=e.generation,this._items[t].value=e.value);else{this._items.push(e);var n=this._items.filter((function(e){return e.state===Nc.VOLATILE})),r=n.length-this._limit;if(r>0){var a,s=[],i=y(this._items);try{for(i.s();!(a=i.n()).done;){var o=a.value;o.state===Nc.VOLATILE&&r>0?r--:s.push(o)}}catch(e){i.e(e)}finally{i.f()}this._items=s}}}}},{key:"remove",value:function(e){var t=this._items.map((function(e){return e.key})).indexOf(e);t>-1&&this._items.splice(t,1)}},{key:"clearByCondition",value:function(e){this._items=this._items.filter((function(t){return!e(t)}))}},{key:"clear",value:function(){var e=arguments.length>0&&void 0!==arguments[0]&&arguments[0];this._items=e?[]:this._items.filter((function(e){return e.state!==Nc.VOLATILE}))}}],[{key:"get",value:function(e){return zc[e]}}]),e}(),Bc=function(){function e(t){var n=t.dbname,a=t.collectionName,s=t.store;r(this,e),this._metadata=null,this._requests=[],this._onCommit=new Map,this._onWrite=new Map,this._onError=new Map,this.dbname=n,this.collectionName=a,this.metadataKey=function(e,t){return"".concat(Lc(e,t),"/trans.metadata")}(n,a),this.recordsetKey=function(e,t){return"".concat(Lc(e,t),"/trans.recordset")}(n,a),this._store=s}return s(e,[{key:"generation",get:function(){return this._metadata?this._metadata.generation:0}},{key:"requestCount",get:function(){return this._requests.length}},{key:"_getReducedRecordset",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[];return b(this,void 0,void 0,t().mark((function n(){var r;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,this._store.get(this.recordsetKey);case 2:if(t.t0=t.sent,t.t0){t.next=5;break}t.t0=[];case 5:return(r=t.t0).push.apply(r,_(e)),t.abrupt("return",this._reduceRecordSet(r));case 8:case"end":return t.stop()}}),n,this)})))}},{key:"_reduceRecordSet",value:function(e){for(var t=[],n={},r=e.length-1;r>=0;r--){for(var a=e[r],s=[],i=a.requests.length-1;i>=0;i--){var o=a.requests[i],u=o.data;n[u.key]||(s.unshift(o),n[u.key]=!0)}s.length>0&&(a.requests=s,t.unshift(a))}return t}},{key:"_applyRecord",value:function(e,n){return b(this,void 0,void 0,t().mark((function r(){var a,s,i,o,u,c,l,h;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return a=Vc.get(this.dbname),s=n.generation,i=n.requests,o=null,t.prev=3,t.next=6,this._store.setMany(i.map((function(e){return Object.assign(Object.assign({},e.data),{generation:s})})));case 6:for(u=t.sent,c=0;c1&&void 0!==arguments[1]?arguments[1]:null;this._requests.push({data:e,options:t}),Vc.get(this.dbname).put(Object.assign({state:Nc.PENDING,generation:this.generation},e))}},{key:"requestMultipleWrite",value:function(e){var t,n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null,r=Vc.get(this.dbname),a=y(e);try{for(a.s();!(t=a.n()).done;){var s=t.value;this._requests.push({data:s,options:n}),r.put(Object.assign({state:Nc.PENDING,generation:this.generation},s))}}catch(e){a.e(e)}finally{a.f()}}},{key:"clear",value:function(){return b(this,void 0,void 0,t().mark((function e(){return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:Vc.get(this.dbname).clearByCondition((function(e){return e.state===Nc.PENDING})),this._requests=[];case 3:case"end":return e.stop()}}),e,this)})))}},{key:"commit",value:function(){return b(this,void 0,void 0,t().mark((function e(){var n,r,a,s,i,o,u,c,l,h,d,f,p,v,_=this;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!((n=this._requests).length>0)){e.next=20;break}for(r=[],a={},s=n.length-1;s>=0;s--)i=n[s],o=i.data,a[o.key]||(a[o.key]=!0,r.unshift(i));return u={generation:this.generation,requests:r},e.next=8,this._getReducedRecordset([u]);case 8:return c=e.sent,e.next=11,this._store.set({key:this.recordsetKey,value:c,generation:this.generation});case 11:return this._metadata.generation++,e.next=14,this._store.set({key:this.metadataKey,value:this._metadata,generation:1});case 14:for(l=Vc.get(this.dbname),h=0;h1&&void 0!==arguments[1]?arguments[1]:this.metadata.blockLevel;return t=this.dbname,n=this.collectionName,r=s,a="".concat(function(e,t,n){var r=n.base*Math.pow(n.multiplier,t)+n.constant;return(n.hashFunction||bc)(e,r)}(e,s,{hashFunction:this.hashFunction,base:this.metadata.blockHashBase,multiplier:this.metadata.blockHashMultiplier,constant:this.metadata.blockHashConstant})),"".concat(Pc(t,n)).concat(r,".").concat(a)}},{key:"_findBlock",value:function(e){return b(this,void 0,void 0,t().mark((function n(){var r,a,s,i,o;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:r=Vc.get(this.dbname),a=this.metadata.blockLevel;case 2:if(!(a>0)){t.next=15;break}return s=this.createBlockId(e,a),t.next=6,r.find(this._store,s);case 6:if(!(i=t.sent)){t.next=12;break}if(o=Qc.createFromCacheItem(i),!o.getItemByKey(e)){t.next=12;break}return t.abrupt("return",o);case 12:a--,t.next=2;break;case 15:return t.abrupt("return",null);case 16:case"end":return t.stop()}}),n,this)})))}},{key:"getFromBlock",value:function(e){return b(this,void 0,void 0,t().mark((function n(){var r;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,this._findBlock(e);case 2:return r=t.sent,t.abrupt("return",r?r.getItemByKey(e):null);case 4:case"end":return t.stop()}}),n,this)})))}},{key:"putToBlock",value:function(e,n){return b(this,void 0,void 0,t().mark((function r(){var a,s,i,o,u,c;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return a=vc.get(this.dbname),s=this.createBlockId(e),i=Math.floor(this._store.itemSizeLimit/a.itemSizeLimit),o=Vc.get(this.dbname),t.next=6,o.find(this._store,s);case 6:if(u=t.sent,!(c=u?Qc.createFromCacheItem(u):new Qc({blockId:s,keyName:this.keyName,items:[],limit:i})).add(n)){t.next=11;break}return this._transaction.requestWrite({key:c.blockId,value:c.serialize()}),t.abrupt("return",!0);case 11:return t.abrupt("return",!1);case 12:case"end":return t.stop()}}),r,this)})))}},{key:"removeFromBlock",value:function(e){return b(this,void 0,void 0,t().mark((function n(){var r;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,this._findBlock(e);case 2:if(!(r=t.sent)){t.next=7;break}if(!r.remove(e)){t.next=7;break}return this._transaction.requestWrite({key:r.blockId,value:r.serialize()}),t.abrupt("return",!0);case 7:return t.abrupt("return",!1);case 8:case"end":return t.stop()}}),n,this)})))}},{key:"clearAllBlocks",value:function(){return b(this,void 0,void 0,t().mark((function e(){var n,r,a;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n=Pc(this.dbname,this.collectionName),e.next=3,this._store.getAllKeys();case 3:return r=e.sent,a=r.filter((function(e){return e.startsWith(n)})),e.next=7,this._store.removeMany(a);case 7:return e.next=9,this._transaction.clear();case 9:Vc.get(this.dbname).clearByCondition((function(e){return e.key.startsWith(n)}));case 11:case"end":return e.stop()}}),e,this)})))}}]),e}(),Wc={},Yc=function(){function e(t){var n=this,a=t.dbname,s=t.collectionName,i=t.keyName,o=t.fields,u=t.transaction,c=t.store;r(this,e),this._origin=[],this._table=[];var l=function(e,t,n){return"".concat(Lc(e,t),"/index.").concat(n)}(a,s,o.join(">"));return Wc[l]||(this.dbname=a,this.collectionName=s,this.keyName=i,this.fields=o,this.indexerKey=l,this._transaction=u,this._store=c,this._transaction.on(Ic.COMMIT,this.indexerKey,(function(){return n.commit()})),this._transaction.on(Ic.ERROR,this.indexerKey,(function(){return n.abort()}))),Wc[l]}return s(e,[{key:"_addItem",value:function(e){var t=e[this.keyName],n=this.getColumnValues(e),r=v(this.indexOf(n),2),a=r[0];return r[1]?!this._table[a].keys.includes(t)&&(this._table[a].keys.push(t),!0):(this._table.splice(a,0,{columnValues:n,keys:[t]}),!0)}},{key:"_removeItem",value:function(e){var t=e[this.keyName],n=this.getColumnValues(e),r=v(this.indexOf(n),2),a=r[0];if(r[1]){var s=this._table[a].keys.indexOf(t);if(s>-1)return this._table[a].keys.splice(s,1),0===this._table[a].keys.length&&this._table.splice(a,1),!0}return!1}},{key:"origin",get:function(){return this._origin}},{key:"table",get:function(){return this._table}},{key:"getColumnValues",value:function(e){var t,r,a,s=[],i=y(this.fields);try{for(i.s();!(t=i.n()).done;){var o=t.value;if("-"===o[0]&&(o=o.slice(1)),r=e[o],a=void 0,a=n(r),null!==r&&"undefined"!==a&&"boolean"!==a&&"number"!==a&&"string"!==a)throw mc.indexTypesNotMatch;s.push(e[o])}}catch(e){i.e(e)}finally{i.f()}return s}},{key:"diff",value:function(e,t){for(var n in this.fields){var r="-"===this.fields[n][0]?-1:1,a=kc(e[n],t[n]);if(0!==a)return r*a}return 0}},{key:"indexOf",value:function(e){if(this._table.length>0){for(var t=0,n=this._table.length-1;t<=n;){var r=Math.floor((t+n)/2),a=this.diff(e,this._table[r].columnValues);if(a>0)t=r+1;else{if(!(a<0))return[r,!0];n=r-1}}return[t,!1]}return[0,!1]}},{key:"ensure",value:function(){return b(this,void 0,void 0,t().mark((function e(){var n,r,a,s,i,o,u,c,l,h,d,f;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n=Vc.get(this.dbname),e.next=3,n.find(this._store,this.indexerKey,Ac.PERSISTENT);case 3:if(r=e.sent){e.next=34;break}return a=Pc(this.dbname,this.collectionName),e.next=8,this._store.getAllKeys();case 8:s=e.sent,i=y(s),e.prev=10,i.s();case 12:if((o=i.n()).done){e.next=23;break}if(!(u=o.value).startsWith(a)){e.next=21;break}return e.next=17,n.find(this._store,u,Ac.NO_CACHE);case 17:c=e.sent,l=Qc.createFromCacheItem(c),h=y(l.items);try{for(h.s();!(d=h.n()).done;)f=d.value,this._addItem(f)}catch(e){h.e(e)}finally{h.f()}case 21:e.next=12;break;case 23:e.next=28;break;case 25:e.prev=25,e.t0=e.catch(10),i.e(e.t0);case 28:return e.prev=28,i.f(),e.finish(28);case 31:this._transaction.requestWrite({key:this.indexerKey,value:this._table},{persistent:!0}),e.next=36;break;case 34:this._origin=r.value,this._table=yc(this._origin);case 36:Wc[this.indexerKey]=this;case 37:case"end":return e.stop()}}),e,this,[[10,25,28,31]])})))}},{key:"drop",value:function(){return b(this,void 0,void 0,t().mark((function e(){return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return Vc.get(this.dbname).remove(this.indexerKey),e.next=4,this._store.remove(this.indexerKey);case 4:delete Wc[this.indexerKey];case 5:case"end":return e.stop()}}),e,this)})))}},{key:"addItem",value:function(e){return b(this,void 0,void 0,t().mark((function n(){return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:this._addItem(e)&&this._transaction.requestWrite({key:this.indexerKey,value:this._table},{persistent:!0});case 1:case"end":return t.stop()}}),n,this)})))}},{key:"removeItem",value:function(e){return b(this,void 0,void 0,t().mark((function n(){return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:this._removeItem(e)&&this._transaction.requestWrite({key:this.indexerKey,value:this._table},{persistent:!0});case 1:case"end":return t.stop()}}),n,this)})))}},{key:"clear",value:function(){return b(this,void 0,void 0,t().mark((function e(){return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:this._table=[],this._transaction.requestWrite({key:this.indexerKey,value:this._table},{persistent:!0});case 2:case"end":return e.stop()}}),e,this)})))}},{key:"commit",value:function(){this._origin=this._table,this._table=yc(this._origin)}},{key:"abort",value:function(){this._table=yc(this._origin)}}],[{key:"createKey",value:function(e){return e.join(">")}},{key:"parseKey",value:function(e){return e.split(">")}},{key:"clearIndexerMap",value:function(){for(var e in Wc)delete Wc[e]}}]),e}(),Zc=function(){function e(t){var n=this,a=t.dbname,s=t.collectionName,i=t.keyName,o=t.keyHash,u=t.indexes,c=t.store;r(this,e),this._state=_c.INIT,this._metadata=null,this._indexers=[],this.dbname=a,this.name=s,this.keyName=i,this.indexes=[[i]].concat(_(u.filter((function(e){return Yc.createKey(e)!==n.keyName})))),this._keyHash=o,this._store=c,this._mutex=new Po(function(e,t){return"".concat(Lc(e,t),".lock")}(a,s)),this._blobContainer=new Hc({dbname:a,collectionName:s,store:c}),this._transaction=new Bc({dbname:a,collectionName:s,store:c})}return s(e,[{key:"state",get:function(){return this._state}},{key:"isReady",get:function(){return this._state===_c.READY}},{key:"init",value:function(){return b(this,void 0,void 0,t().mark((function n(){var r,a,s,i,o,u,c,l,h,d,f,p=this;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,this._mutex.lock();case 2:return t.prev=2,r=vc.get(this.dbname),t.next=6,e.metadataOf(this.dbname,this.name,this._store);case 6:return a=t.sent,this._metadata=a||{keyName:this.keyName,blockLevel:1,blockHashBase:r.blockHashBase,blockHashMultiplier:r.blockHashMultiplier,blockHashConstant:r.blockHashConstant,indexes:this.indexes},t.next=10,this._transaction.init();case 10:this._blockManager=new Kc({dbname:this.dbname,collectionName:this.name,hashFunction:this._keyHash,metadata:this._metadata,transaction:this._transaction,store:this._store}),s=_(this.indexes),i=[],o=s.map((function(e){return Yc.createKey(e)})),u=a?a.indexes.map((function(e){return Yc.createKey(e)})):[],c=y(u);try{for(c.s();!(l=c.n()).done;)h=l.value,o.includes(h)||i.push(Yc.parseKey(h))}catch(e){c.e(e)}finally{c.f()}return(d=[]).push.apply(d,_(s.map((function(e){var t=new Yc({dbname:p.dbname,collectionName:p.name,keyName:p.keyName,fields:e,transaction:p._transaction,store:p._store});return p._indexers.push(t),t.ensure()})))),d.push.apply(d,_(i.map((function(e){return new Yc({dbname:p.dbname,collectionName:p.name,keyName:p.keyName,fields:e,transaction:p._transaction,store:p._store}).drop()})))),t.next=22,Promise.all(d);case 22:return t.next=24,this._transaction.commit();case 24:if(o.sort().join(",")===u.sort().join(",")){t.next=29;break}return f=Dc(this.dbname,this.name),this._metadata.indexes=s,t.next=29,this._store.set({key:f,value:this._metadata,generation:1});case 29:this._state=_c.READY,this._mutex.unlock(),t.next=37;break;case 33:throw t.prev=33,t.t0=t.catch(2),this._mutex.unlock(),t.t0;case 37:case"end":return t.stop()}}),n,this,[[2,33]])})))}},{key:"close",value:function(){this._state=_c.CLOSED}},{key:"_hasPropertyOfKeyName",value:function(e){var t=e[this.keyName];return"string"==typeof t&&!!t}},{key:"_getIndexerBy",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:null;e||(e=[this.keyName]);var t,n=Yc.createKey(e),r=y(this._indexers);try{for(r.s();!(t=r.n()).done;){var a=t.value;if(n===Yc.createKey(a.fields))return a}}catch(e){r.e(e)}finally{r.f()}return null}},{key:"_upgradeBlockLevel",value:function(){return b(this,void 0,void 0,t().mark((function e(){var n;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n=Dc(this.dbname,this.name),this._metadata.blockLevel++,e.next=4,this._store.set({key:n,value:this._metadata,generation:1});case 4:case"end":return e.stop()}}),e,this)})))}},{key:"_requestInsert",value:function(e){return b(this,void 0,void 0,t().mark((function n(){var r,a,s,i;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return r=e[this.keyName],t.next=3,this._blockManager.getFromBlock(r);case 3:if(t.sent){t.next=32;break}return t.next=7,this._blockManager.putToBlock(r,e);case 7:if(t.sent){t.next=13;break}return t.next=11,this._upgradeBlockLevel();case 11:return t.next=13,this._blockManager.putToBlock(r,e);case 13:a=y(this._indexers),t.prev=14,a.s();case 16:if((s=a.n()).done){t.next=22;break}return i=s.value,t.next=20,i.addItem(e);case 20:t.next=16;break;case 22:t.next=27;break;case 24:t.prev=24,t.t0=t.catch(14),a.e(t.t0);case 27:return t.prev=27,a.f(),t.finish(27);case 30:t.next=33;break;case 32:throw mc.collectionInsertDuplicate;case 33:case"end":return t.stop()}}),n,this,[[14,24,27,30]])})))}},{key:"_requestUpsert",value:function(e){return b(this,void 0,void 0,t().mark((function n(){var r,a,s,i,o,u,c,l;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return r=e[this.keyName],t.next=3,this._blockManager.getFromBlock(r);case 3:if(a=t.sent){t.next=32;break}return t.next=7,this._blockManager.putToBlock(r,e);case 7:if(t.sent){t.next=13;break}return t.next=11,this._upgradeBlockLevel();case 11:return t.next=13,this._blockManager.putToBlock(r,e);case 13:s=y(this._indexers),t.prev=14,s.s();case 16:if((i=s.n()).done){t.next=22;break}return o=i.value,t.next=20,o.addItem(e);case 20:t.next=16;break;case 22:t.next=27;break;case 24:t.prev=24,t.t0=t.catch(14),s.e(t.t0);case 27:return t.prev=27,s.f(),t.finish(27);case 30:t.next=54;break;case 32:return t.next=34,this._blockManager.putToBlock(r,e);case 34:u=y(this._indexers),t.prev=35,u.s();case 37:if((c=u.n()).done){t.next=46;break}if(0===(l=c.value).diff(l.getColumnValues(a),l.getColumnValues(e))){t.next=44;break}return t.next=42,l.removeItem(a);case 42:return t.next=44,l.addItem(e);case 44:t.next=37;break;case 46:t.next=51;break;case 48:t.prev=48,t.t1=t.catch(35),u.e(t.t1);case 51:return t.prev=51,u.f(),t.finish(51);case 54:case"end":return t.stop()}}),n,this,[[14,24,27,30],[35,48,51,54]])})))}},{key:"_requestUpdate",value:function(e){return b(this,void 0,void 0,t().mark((function n(){var r,a,s,i,o;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return r=e[this.keyName],t.next=3,this._blockManager.getFromBlock(r);case 3:if(!(a=t.sent)){t.next=27;break}return t.next=7,this._blockManager.putToBlock(r,e);case 7:s=y(this._indexers),t.prev=8,s.s();case 10:if((i=s.n()).done){t.next=19;break}if(0===(o=i.value).diff(o.getColumnValues(a),o.getColumnValues(e))){t.next=17;break}return t.next=15,o.removeItem(a);case 15:return t.next=17,o.addItem(e);case 17:t.next=10;break;case 19:t.next=24;break;case 21:t.prev=21,t.t0=t.catch(8),s.e(t.t0);case 24:return t.prev=24,s.f(),t.finish(24);case 27:case"end":return t.stop()}}),n,this,[[8,21,24,27]])})))}},{key:"_requestRemove",value:function(e){return b(this,void 0,void 0,t().mark((function n(){var r,a,s,i;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,this._blockManager.getFromBlock(e);case 2:if(!(r=t.sent)){t.next=23;break}return t.next=6,this._blockManager.removeFromBlock(e);case 6:a=y(this._indexers),t.prev=7,a.s();case 9:if((s=a.n()).done){t.next=15;break}return i=s.value,t.next=13,i.removeItem(r);case 13:t.next=9;break;case 15:t.next=20;break;case 17:t.prev=17,t.t0=t.catch(7),a.e(t.t0);case 20:return t.prev=20,a.f(),t.finish(20);case 23:case"end":return t.stop()}}),n,this,[[7,17,20,23]])})))}},{key:"_requestClear",value:function(){return b(this,void 0,void 0,t().mark((function e(){var n,r,a;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this._blockManager.clearAllBlocks();case 2:n=y(this._indexers),e.prev=3,n.s();case 5:if((r=n.n()).done){e.next=11;break}return a=r.value,e.next=9,a.clear();case 9:e.next=5;break;case 11:e.next=16;break;case 13:e.prev=13,e.t0=e.catch(3),n.e(e.t0);case 16:return e.prev=16,n.f(),e.finish(16);case 19:case"end":return e.stop()}}),e,this,[[3,13,16,19]])})))}},{key:"getByKey",value:function(e){return b(this,void 0,void 0,t().mark((function n(){var r;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(!this.isReady){t.next=17;break}return t.next=3,this._mutex.lock();case 3:return t.prev=3,t.next=6,this._blockManager.getFromBlock(e);case 6:return r=t.sent,this._mutex.unlock(),t.abrupt("return",yc(r));case 11:throw t.prev=11,t.t0=t.catch(3),this._mutex.unlock(),t.t0;case 15:t.next=18;break;case 17:throw mc.collectionNotReady;case 18:case"end":return t.stop()}}),n,this,[[3,11]])})))}},{key:"query",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return this.isReady?new Uc({condition:e.where,mutex:this._mutex,blockManager:this._blockManager,indexer:this._getIndexerBy(e.index),backward:!!e.backward}):null}},{key:"insertOne",value:function(e){return b(this,void 0,void 0,t().mark((function n(){return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(!this.isReady){t.next=22;break}return t.next=3,this._mutex.lock();case 3:if(t.prev=3,this._hasPropertyOfKeyName(e)){t.next=6;break}throw mc.collectionKeyNotGiven;case 6:return t.next=8,this._requestInsert(yc(e));case 8:return t.next=10,this._transaction.commit();case 10:return this._mutex.unlock(),t.abrupt("return",e);case 14:return t.prev=14,t.t0=t.catch(3),t.next=18,this._transaction.clear();case 18:throw this._mutex.unlock(),t.t0;case 20:t.next=23;break;case 22:throw mc.collectionNotReady;case 23:case"end":return t.stop()}}),n,this,[[3,14]])})))}},{key:"insertMany",value:function(e){return b(this,void 0,void 0,t().mark((function n(){var r,a,s,i=this;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(!this.isReady){t.next=37;break}return t.next=3,this._mutex.lock();case 3:if(t.prev=3,!e.some((function(e){return!i._hasPropertyOfKeyName(e)}))){t.next=6;break}throw mc.collectionKeyNotGiven;case 6:r=y(e),t.prev=7,r.s();case 9:if((a=r.n()).done){t.next=15;break}return s=a.value,t.next=13,this._requestInsert(yc(s));case 13:t.next=9;break;case 15:t.next=20;break;case 17:t.prev=17,t.t0=t.catch(7),r.e(t.t0);case 20:return t.prev=20,r.f(),t.finish(20);case 23:return t.next=25,this._transaction.commit();case 25:return this._mutex.unlock(),t.abrupt("return",e);case 29:return t.prev=29,t.t1=t.catch(3),t.next=33,this._transaction.clear();case 33:throw this._mutex.unlock(),t.t1;case 35:t.next=38;break;case 37:throw mc.collectionNotReady;case 38:case"end":return t.stop()}}),n,this,[[3,29],[7,17,20,23]])})))}},{key:"upsertOne",value:function(e){return b(this,void 0,void 0,t().mark((function n(){return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(!this.isReady){t.next=22;break}return t.next=3,this._mutex.lock();case 3:if(t.prev=3,this._hasPropertyOfKeyName(e)){t.next=6;break}throw mc.collectionKeyNotGiven;case 6:return t.next=8,this._requestUpsert(yc(e));case 8:return t.next=10,this._transaction.commit();case 10:return this._mutex.unlock(),t.abrupt("return",e);case 14:return t.prev=14,t.t0=t.catch(3),t.next=18,this._transaction.clear();case 18:throw this._mutex.unlock(),t.t0;case 20:t.next=23;break;case 22:throw mc.collectionNotReady;case 23:case"end":return t.stop()}}),n,this,[[3,14]])})))}},{key:"upsertMany",value:function(e){return b(this,void 0,void 0,t().mark((function n(){var r,a,s,i=this;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(!this.isReady){t.next=37;break}return t.next=3,this._mutex.lock();case 3:if(t.prev=3,!e.some((function(e){return!i._hasPropertyOfKeyName(e)}))){t.next=6;break}throw mc.collectionKeyNotGiven;case 6:r=y(e),t.prev=7,r.s();case 9:if((a=r.n()).done){t.next=15;break}return s=a.value,t.next=13,this._requestUpsert(yc(s));case 13:t.next=9;break;case 15:t.next=20;break;case 17:t.prev=17,t.t0=t.catch(7),r.e(t.t0);case 20:return t.prev=20,r.f(),t.finish(20);case 23:return t.next=25,this._transaction.commit();case 25:return this._mutex.unlock(),t.abrupt("return",e);case 29:return t.prev=29,t.t1=t.catch(3),t.next=33,this._transaction.clear();case 33:throw this._mutex.unlock(),t.t1;case 35:t.next=38;break;case 37:throw mc.collectionNotReady;case 38:case"end":return t.stop()}}),n,this,[[3,29],[7,17,20,23]])})))}},{key:"update",value:function(e){return b(this,void 0,void 0,t().mark((function n(){return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(!this.isReady){t.next=22;break}return t.next=3,this._mutex.lock();case 3:if(t.prev=3,this._hasPropertyOfKeyName(e)){t.next=6;break}throw mc.collectionKeyNotGiven;case 6:return t.next=8,this._requestUpdate(yc(e));case 8:return t.next=10,this._transaction.commit();case 10:return this._mutex.unlock(),t.abrupt("return",e);case 14:return t.prev=14,t.t0=t.catch(3),t.next=18,this._transaction.clear();case 18:throw this._mutex.unlock(),t.t0;case 20:t.next=23;break;case 22:throw mc.collectionNotReady;case 23:case"end":return t.stop()}}),n,this,[[3,14]])})))}},{key:"updateIf",value:function(e,n){return b(this,void 0,void 0,t().mark((function r(){var a,s,i,o,u,c,l,h,d,f,p,v=this;return t().wrap((function(r){for(;;)switch(r.prev=r.next){case 0:if(!this.isReady){r.next=31;break}return r.next=3,this._mutex.lock();case 3:return r.prev=3,a=e.where,s=void 0===a?{}:a,i=e.index,o=void 0===i?null:i,u=e.backward,c=void 0!==u&&u,l=[],h=new Oc({condition:s,blockManager:this._blockManager,backward:c,indexer:this._getIndexerBy(o)}),r.next=9,h.each((function(e){return b(v,void 0,void 0,t().mark((function r(){var a,i;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(e.error){t.next=4;break}if(e.hasNext){if(a=e.nextValue,wc(s,a)&&n.set){if("function"!=typeof n.set)for(i in n.set)a[i]=n.set[i];else n.set(a);l.push(a)}e.next()}else e.stop();t.next=6;break;case 4:throw e.stop(),e.error;case 6:case"end":return t.stop()}}),r)})))}));case 9:d=0,f=l;case 10:if(!(d1&&void 0!==arguments[1]?arguments[1]:null;return b(this,void 0,void 0,t().mark((function r(){return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,this._blobContainer.save(e,n);case 2:return t.abrupt("return",t.sent);case 3:case"end":return t.stop()}}),r,this)})))}},{key:"removeBlob",value:function(e){return b(this,void 0,void 0,t().mark((function n(){return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,this._blobContainer.remove(e);case 2:case"end":return t.stop()}}),n,this)})))}},{key:"removeAllBlobs",value:function(){return b(this,void 0,void 0,t().mark((function e(){return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this._blobContainer.clear();case 2:case"end":return e.stop()}}),e,this)})))}}],[{key:"metadataOf",value:function(e,n,r){return b(this,void 0,void 0,t().mark((function a(){var s;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return s=Dc(e,n),t.next=3,r.get(s);case 3:return t.abrupt("return",t.sent);case 4:case"end":return t.stop()}}),a)})))}}]),e}(),Jc=function(){function e(t){var n,a,s;r(this,e),this.encryption=null!==(n=t.encryption)&&void 0!==n?n:j,this.itemSizeLimit=null!==(a=t.itemSizeLimit)&&void 0!==a?a:4194304,this.metadataBuffer=null!==(s=t.metadataBuffer)&&void 0!==s?s:256}return s(e,[{key:"_getRawKey",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"";return"".concat(e).concat(t)}},{key:"_generateShardPostfixArray",value:function(){return _(Array(arguments.length>0&&void 0!==arguments[0]?arguments[0]:1).keys())}},{key:"_shardify",value:function(e){var t=this,n=e.key,r=e.value,a=JSON.stringify(this.encryption.encrypt(r)),s=Math.ceil(a.length/this.adjustedItemSizeLimit);return this._generateShardPostfixArray(s).map((function(e){var r={key:t._getRawKey(n,".".concat(e)),data:a.substring(e*t.adjustedItemSizeLimit,(e+1)*t.adjustedItemSizeLimit)};return 0===e&&(r.metadata={shards:s}),r}))}},{key:"adjustedItemSizeLimit",get:function(){return Math.max(this.itemSizeLimit-this.metadataBuffer,4)}},{key:"usage",value:function(){return b(this,void 0,void 0,t().mark((function e(){var n,r,a,s,i,o;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n=0,e.next=3,this._getAllRawKeys();case 3:r=e.sent,a=y(r),e.prev=5,a.s();case 7:if((s=a.n()).done){e.next=15;break}return i=s.value,e.next=11,this._getRaw(i);case 11:(o=e.sent)&&(n+=JSON.stringify(o).length);case 13:e.next=7;break;case 15:e.next=20;break;case 17:e.prev=17,e.t0=e.catch(5),a.e(e.t0);case 20:return e.prev=20,a.f(),e.finish(20);case 23:return e.abrupt("return",n);case 24:case"end":return e.stop()}}),e,this,[[5,17,20,23]])})))}},{key:"getAllKeys",value:function(){return b(this,void 0,void 0,t().mark((function e(){var n;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this._getAllRawKeys();case 2:return n=e.sent,e.abrupt("return",n.filter((function(e){return e.endsWith(".0")})).map((function(e){return e.replace(/\.0$/,"")})));case 4:case"end":return e.stop()}}),e,this)})))}},{key:"get",value:function(e){return b(this,void 0,void 0,t().mark((function n(){var r,a,s,i,o,u=this;return t().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return r=this._getRawKey(e,".0"),n.next=3,this._getRaw(r);case 3:if(!(a=n.sent)){n.next=21;break}if(n.prev=5,s=a.data,!((null==(i=a.metadata)?void 0:i.shards)>1)){n.next=13;break}return n.next=10,Promise.all(this._generateShardPostfixArray(null==i?void 0:i.shards).map((function(n){return b(u,void 0,void 0,t().mark((function r(){var a,i;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(!(n>0)){t.next=10;break}return a=this._getRawKey(e,".".concat(n)),t.next=4,this._getRaw(a);case 4:if(i=t.sent){t.next=7;break}throw mc.storeBrokenIntegrity;case 7:return t.abrupt("return",i.data);case 10:return t.abrupt("return",s);case 11:case"end":return t.stop()}}),r,this)})))})));case 10:n.t0=n.sent,n.next=14;break;case 13:n.t0=[s];case 14:return o=n.t0,n.abrupt("return",this.encryption.decrypt(JSON.parse(o.join(""))));case 18:return n.prev=18,n.t1=n.catch(5),n.abrupt("return",null);case 21:return n.abrupt("return",null);case 22:case"end":return n.stop()}}),n,this,[[5,18]])})))}},{key:"set",value:function(e){return b(this,void 0,void 0,t().mark((function n(){var r;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return r=this._shardify(e),t.next=3,this._setRaw(r);case 3:return t.abrupt("return",Object.assign({},e.value));case 4:case"end":return t.stop()}}),n,this)})))}},{key:"setMany",value:function(e){return b(this,void 0,void 0,t().mark((function n(){var r,a=this;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,this._setRaw((r=[]).concat.apply(r,_(e.map((function(e){return a._shardify(e)})))));case 2:return t.abrupt("return",e.map((function(e){return e.value})));case 3:case"end":return t.stop()}}),n,this)})))}},{key:"remove",value:function(e){return b(this,void 0,void 0,t().mark((function n(){var r,a,s,i=this;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return r=this._getRawKey(e,".0"),t.next=3,this._getRaw(r);case 3:if(!(a=t.sent)){t.next=9;break}return s=a.metadata,t.next=8,this._removeRaw(this._generateShardPostfixArray(null==s?void 0:s.shards).map((function(t){return i._getRawKey(e,".".concat(t))})));case 8:return t.abrupt("return",!0);case 9:return t.abrupt("return",!1);case 10:case"end":return t.stop()}}),n,this)})))}},{key:"removeMany",value:function(e){return b(this,void 0,void 0,t().mark((function n(){var r,a,s,i,o=this;return t().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:r=[],a=y(e),n.prev=2,i=t().mark((function e(){var n,a,i,u;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n=s.value,a=o._getRawKey(n,".0"),e.next=4,o._getRaw(a);case 4:(i=e.sent)&&(u=i.metadata,r.push.apply(r,_(o._generateShardPostfixArray(null==u?void 0:u.shards).map((function(e){return o._getRawKey(n,".".concat(e))})))));case 6:case"end":return e.stop()}}),e)})),a.s();case 5:if((s=a.n()).done){n.next=9;break}return n.delegateYield(i(),"t0",7);case 7:n.next=5;break;case 9:n.next=14;break;case 11:n.prev=11,n.t1=n.catch(2),a.e(n.t1);case 14:return n.prev=14,a.f(),n.finish(14);case 17:if(!(r.length>0)){n.next=20;break}return n.next=20,this._removeRaw(r);case 20:return n.abrupt("return",e);case 21:case"end":return n.stop()}}),n,this,[[2,11,14,17]])})))}}]),e}(),Xc={},$c=function(e){i(a,e);var n=f(a);function a(){var e,t,s=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};r(this,a),e=n.call(this,Object.assign(Object.assign({},s),{itemSizeLimit:null!==(t=s.itemSizeLimit)&&void 0!==t?t:4194304}));var i=s.delay,o=void 0===i?1:i;return e.delay=o,e.observer={},e}return s(a,[{key:"rawData",get:function(){return Xc[this.dbname]},set:function(e){Xc[this.dbname]=e}},{key:"_getAllRawKeys",value:function(){return b(this,void 0,void 0,t().mark((function e(){return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!Xc[this.dbname]){e.next=4;break}return e.abrupt("return",Object.keys(Xc[this.dbname]));case 4:throw mc.storeNotAvailable;case 5:case"end":return e.stop()}}),e,this)})))}},{key:"_getRaw",value:function(e){return b(this,void 0,void 0,t().mark((function n(){return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(!Xc[this.dbname]){t.next=6;break}return t.next=3,Ec(this.delay);case 3:return t.abrupt("return",Xc[this.dbname][e]?Object.assign({key:e},Xc[this.dbname][e]):null);case 6:throw mc.storeNotAvailable;case 7:case"end":return t.stop()}}),n,this)})))}},{key:"_setRaw",value:function(e){return b(this,void 0,void 0,t().mark((function n(){var r,a,s,i,o,u;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(!Xc[this.dbname]){t.next=7;break}return t.next=3,Ec(this.delay);case 3:r=y(e);try{for(r.s();!(a=r.n()).done;)s=a.value,i=s.key,o=s.data,u=s.metadata,Xc[this.dbname][i]=Object.freeze({data:o,metadata:u})}catch(e){r.e(e)}finally{r.f()}t.next=8;break;case 7:throw mc.storeNotAvailable;case 8:case"end":return t.stop()}}),n,this)})))}},{key:"_removeRaw",value:function(e){return b(this,void 0,void 0,t().mark((function n(){var r,a,s;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(!Xc[this.dbname]){t.next=7;break}return t.next=3,Ec(this.delay);case 3:r=y(e);try{for(r.s();!(a=r.n()).done;)s=a.value,Xc[this.dbname][s]&&delete Xc[this.dbname][s]}catch(e){r.e(e)}finally{r.f()}t.next=8;break;case 7:throw mc.storeNotAvailable;case 8:case"end":return t.stop()}}),n,this)})))}},{key:"observe",value:function(e,t,n){var r=this;this.observer[e]||(this.observer[e]={}),t.forEach((function(t){return r.observer[e][t]=n}))}},{key:"isAvailable",value:function(){return b(this,void 0,void 0,t().mark((function e(){return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",!0);case 1:case"end":return e.stop()}}),e)})))}},{key:"init",value:function(e){return b(this,void 0,void 0,t().mark((function n(){return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:this.dbname=e,Xc[this.dbname]={};case 2:case"end":return t.stop()}}),n,this)})))}},{key:"set",value:function(e){var n=this,r=Object.create(null,{set:{get:function(){return p(o(a.prototype),"set",n)}}});return b(this,void 0,void 0,t().mark((function n(){var a;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(!this.observer[e.key]||"function"!=typeof this.observer[e.key].set){t.next=4;break}if(!(a=this.observer[e.key].set())){t.next=4;break}throw a;case 4:return t.abrupt("return",r.set.call(this,e));case 5:case"end":return t.stop()}}),n,this)})))}},{key:"setMany",value:function(e){var n=this,r=Object.create(null,{setMany:{get:function(){return p(o(a.prototype),"setMany",n)}}});return b(this,void 0,void 0,t().mark((function n(){var a,s,i,o;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:a=y(e),t.prev=1,a.s();case 3:if((s=a.n()).done){t.next=11;break}if(i=s.value,!this.observer[i.key]||"function"!=typeof this.observer[i.key].set){t.next=9;break}if(!(o=this.observer[i.key].set())){t.next=9;break}throw o;case 9:t.next=3;break;case 11:t.next=16;break;case 13:t.prev=13,t.t0=t.catch(1),a.e(t.t0);case 16:return t.prev=16,a.f(),t.finish(16);case 19:return t.abrupt("return",r.setMany.call(this,e));case 20:case"end":return t.stop()}}),n,this,[[1,13,16,19]])})))}},{key:"clear",value:function(){return b(this,void 0,void 0,t().mark((function e(){return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,Ec(this.delay);case 2:Xc[this.dbname]={};case 3:case"end":return e.stop()}}),e,this)})))}}]),a}(Jc),el="NestDBStore",tl=function(e){i(a,e);var n=f(a);function a(){var e,t,s=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return r(this,a),(e=n.call(this,Object.assign(Object.assign({},s),{itemSizeLimit:null!==(t=s.itemSizeLimit)&&void 0!==t?t:104857600})))._storeName=el,e._window="undefined"!=typeof window?window:null,e._indexedDb=e._window?e._window.indexedDB||e._window.mozIndexedDB||e._window.webkitIndexedDB||e._window.msIndexedDB:null,e}return s(a,[{key:"_getObjectStore",value:function(e){return this._database.transaction(this._storeName,e).objectStore(this._storeName)}},{key:"_getAllRawKeys",value:function(){return b(this,void 0,void 0,t().mark((function e(){var n=this;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,new Promise((function(e,t){var r=n._getObjectStore("readonly").getAllKeys();r.addEventListener("success",(function(t){e(t.target.result)})),r.addEventListener("error",(function(e){return t(e.target.error)}))}));case 2:return e.abrupt("return",e.sent);case 3:case"end":return e.stop()}}),e)})))}},{key:"_getRaw",value:function(e){return b(this,void 0,void 0,t().mark((function n(){var r=this;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,new Promise((function(t,n){var a=r._getObjectStore("readonly").get(e);a.addEventListener("success",(function(e){var n;t(null===(n=null==e?void 0:e.target)||void 0===n?void 0:n.result)})),a.addEventListener("error",(function(e){return n(e.target.error)}))}));case 2:return t.abrupt("return",t.sent);case 3:case"end":return t.stop()}}),n)})))}},{key:"_setRaw",value:function(e){return b(this,void 0,void 0,t().mark((function n(){var r;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return r=this._getObjectStore("readwrite"),t.next=3,Promise.all(e.map((function(e){return new Promise((function(t,n){var a=r.put(e);a.addEventListener("success",(function(e){t(e.target.result)})),a.addEventListener("error",(function(){n("Failed to write.")}))}))})));case 3:case"end":return t.stop()}}),n,this)})))}},{key:"_removeRaw",value:function(e){return b(this,void 0,void 0,t().mark((function n(){var r;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return r=this._getObjectStore("readwrite"),t.next=3,Promise.all(e.map((function(e){return new Promise((function(t,n){var a=r.delete(e);a.addEventListener("success",(function(){return t(e)})),a.addEventListener("error",(function(e){return n(e.target.error)}))}))})));case 3:case"end":return t.stop()}}),n,this)})))}},{key:"isAvailable",value:function(){return b(this,void 0,void 0,t().mark((function e(){var n,r,a,s,i=this;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!((null==(n="undefined"!=typeof window?window:null)?void 0:n.indexedDB)||(null==n?void 0:n.mozIndexedDB)||(null==n?void 0:n.webkitIndexedDB)||(null==n?void 0:n.msIndexedDB))){e.next=15;break}return e.prev=2,this._indexedDb=n.indexedDB||n.mozIndexedDB||n.webkitIndexedDB||n.msIndexedDB,r="undefined"!=typeof document&&"undefined"!=typeof navigator,a=navigator.userAgent&&navigator.userAgent.includes("Firefox/")&&!navigator.userAgent.includes("Seamonkey/"),s=navigator.userAgent&&navigator.userAgent.includes("Edge/"),e.next=9,new Promise((function(e,t){if(r)if(a){var o=i._indexedDb.open("_testMozilla");o.onerror=function(){return t("Private browsing mode.")},o.onsuccess=function(){return e()}}else s?(n.PointerEvent||n.MSPointerEvent)&&t("Private browsing mode."):e()}));case 9:return e.abrupt("return",!0);case 12:return e.prev=12,e.t0=e.catch(2),e.abrupt("return",!1);case 15:return e.abrupt("return",!1);case 16:case"end":return e.stop()}}),e,this,[[2,12]])})))}},{key:"init",value:function(e){return b(this,void 0,void 0,t().mark((function n(){var r,a=this;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return this.dbname=e,r=new Promise((function(e,t){if(a._window&&No)if(Ao){var n=a._indexedDb.open("_testMozilla");n.onerror=function(){return t(mc.storeNotAvailableInPrivateBrowsing)},n.onsuccess=function(){return e()}}else Uo?a._window.indexedDB||!a._window.PointerEvent&&!a._window.MSPointerEvent||t(mc.storeNotAvailableInPrivateBrowsing):e();else t(mc.storeNotAvailable)})),t.next=4,r;case 4:return t.next=6,new Promise((function(t,n){var r=a._indexedDb.open(e);r.addEventListener("upgradeneeded",(function(e){e.target.result.createObjectStore(el,{keyPath:"key"})})),r.addEventListener("success",(function(e){return t(e.target.result)})),r.addEventListener("error",(function(e){return n(e.target.error)}))}));case 6:this._database=t.sent;case 7:case"end":return t.stop()}}),n,this)})))}},{key:"clear",value:function(){return b(this,void 0,void 0,t().mark((function e(){var n=this;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,new Promise((function(e,t){var r=n._getObjectStore("readwrite").clear();r.addEventListener("success",(function(){return e()})),r.addEventListener("error",(function(e){return t(e.target.error)}))}));case 2:return e.abrupt("return",e.sent);case 3:case"end":return e.stop()}}),e)})))}}]),a}(Jc),nl=function(e){i(a,e);var n=f(a);function a(e){var t;r(this,a);var s=e.AsyncStorage,i=e.itemSizeLimit,o=void 0===i?6291456:i,u=function(e,t){var n={};for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&t.indexOf(r)<0&&(n[r]=e[r]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var a=0;for(r=Object.getOwnPropertySymbols(e);a0&&(s.mutedUsers=o.map((function(t){return new hl(e,t)}))),s}return s(n)}(re),Cl=function(e){i(a,e);var n=f(a);function a(e,t,s,i){return r(this,a),n.call(this,e,t,s,i)}return s(a,[{key:"next",value:function(){return b(this,void 0,void 0,t().mark((function e(){var n,r,a,s,i,o,u;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!this._validate()){e.next=20;break}if(this._isLoading){e.next=17;break}if(!this._hasNext){e.next=14;break}return this._isLoading=!0,n=ns.of(this._iid),r=n.requestQueue,a=new El(Object.assign(Object.assign({},this),{token:this._token})),e.next=8,r.send(a);case 8:return s=e.sent,i=s.as(wl),o=i.mutedUsers,u=i.token,this._token=u,this._hasNext=!!u,this._isLoading=!1,e.abrupt("return",o);case 14:return e.abrupt("return",[]);case 17:throw M.queryInProgress;case 18:e.next=21;break;case 20:throw M.invalidParameters;case 21:case"end":return e.stop()}}),e,this)})))}}]),a}(Si),xl=function(e){i(n,e);var t=f(n);function n(e){var a;r(this,n);var s=e.channelUrl,i=e.channelType,o=e.limit,u=e.token;return(a=t.call(this)).method=B.GET,a.path="".concat(Fs(i),"/").concat(encodeURIComponent(s),"/ban"),a.params=ee({limit:o,token:u}),a}return s(n)}(ne),Tl=function(e){i(n,e);var t=f(n);function n(e,a){var s;r(this,n),(s=t.call(this,e,a)).token=null,s.bannedUsers=[];var i=a.next,o=a.banned_list;return s.token=i,o&&o.length>0&&(s.bannedUsers=o.map((function(t){return new hl(e,t.user)}))),s}return s(n)}(re),Sl=function(e){i(a,e);var n=f(a);function a(e,t,s,i){return r(this,a),n.call(this,e,t,s,i)}return s(a,[{key:"_validate",value:function(){return p(o(a.prototype),"_validate",this).call(this)}},{key:"next",value:function(){return b(this,void 0,void 0,t().mark((function e(){var n,r,a,s,i,o,u;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!this._validate()){e.next=20;break}if(this._isLoading){e.next=17;break}if(!this._hasNext){e.next=14;break}return this._isLoading=!0,n=ns.of(this._iid),r=n.requestQueue,a=new xl(Object.assign(Object.assign({},this),{token:this._token})),e.next=8,r.send(a);case 8:return s=e.sent,i=s.as(Tl),o=i.bannedUsers,u=i.token,this._token=u,this._hasNext=!!u,this._isLoading=!1,e.abrupt("return",o);case 14:return e.abrupt("return",[]);case 17:throw M.queryInProgress;case 18:e.next=21;break;case 20:throw M.invalidParameters;case 21:case"end":return e.stop()}}),e,this)})))}}]),a}(Si);e.ReportCategory=void 0,(cl=e.ReportCategory||(e.ReportCategory={})).SPAM="spam",cl.HARASSING="harassing",cl.SUSPICIOUS="suspicious",cl.INAPPROPRIATE="inappropriate";var Il,Nl=function(e){i(n,e);var t=f(n);function n(e){var a;r(this,n);var s=e.channelUrl,i=e.channelType,o=e.operatorUserIds;return(a=t.call(this)).method=B.POST,a.path="".concat(Fs(i),"/").concat(encodeURIComponent(s),"/operators"),a.params={operator_ids:o},a}return s(n)}(ne),Al=function(e){i(n,e);var t=f(n);function n(e){var a;r(this,n);var s=e.channelUrl,i=e.channelType,o=e.operatorUserIds;return(a=t.call(this)).method=B.DELETE,a.path="".concat(Fs(i),"/").concat(encodeURIComponent(s),"/operators"),a.params={operator_ids:o},a}return s(n)}(ne),Ml=function(e){i(n,e);var t=f(n);function n(e){var a;r(this,n);var s=e.channelUrl,i=e.channelType,o=e.userId;return(a=t.call(this)).method=B.GET,a.path="".concat(Fs(i),"/").concat(encodeURIComponent(s),"/mute/").concat(o),a}return s(n)}(ne),Ol=function(e){i(n,e);var t=f(n);function n(e,a){var s;r(this,n),(s=t.call(this,e,a)).isMuted=!1,s.startAt=null,s.endAt=null,s.remainingDuration=null,s.description=null;var i=a.is_muted,o=a.start_at,u=a.end_at,c=a.remaining_duration,l=a.description;return s.isMuted=i,s.startAt=o,s.endAt=u,s.remainingDuration=c,s.description=l,s}return s(n)}(re),Ul=function(e){i(n,e);var t=f(n);function n(e){var a;r(this,n);var s=e.channelUrl,i=e.channelType,o=e.keys;return(a=t.call(this)).method=B.GET,a.path="".concat(Fs(i),"/").concat(encodeURIComponent(s),"/metadata"),a.params={keys:o,include_ts:!0},a}return s(n)}(ne),Rl=function(e){i(n,e);var t=f(n);function n(e,a){var s;r(this,n),(s=t.call(this,e,a)).ts=null;var i=a.metadata,o=a.ts;return s.metadata=i,s.ts=null!=o?o:null,s}return s(n)}(re),Ll=function(e){i(n,e);var t=f(n);function n(e){var a;r(this,n);var s=e.channelUrl,i=e.channelType,o=e.metadata;return(a=t.call(this)).method=B.POST,a.path="".concat(Fs(i),"/").concat(encodeURIComponent(s),"/metadata"),a.params={metadata:o,include_ts:!0},a}return s(n)}(ne),Dl=function(e){i(n,e);var t=f(n);function n(e,a){var s,i,o;return r(this,n),(s=t.call(this,e,a)).metaData=null!==(i=a.metadata)&&void 0!==i?i:{},s.ts=null!==(o=a.ts)&&void 0!==o?o:null,s}return s(n)}(re),Pl=function(e){i(n,e);var t=f(n);function n(e){var a;r(this,n);var s=e.channelUrl,i=e.channelType,o=e.metadata,u=e.upsert;return(a=t.call(this)).method=B.PUT,a.path="".concat(Fs(i),"/").concat(encodeURIComponent(s),"/metadata"),a.params={metadata:o,include_ts:!0,upsert:null!=u&&u},a}return s(n)}(ne),Fl=function(e){i(n,e);var t=f(n);function n(e,a){var s;r(this,n),(s=t.call(this,e,a)).ts=null;var i=a.metadata,o=a.ts;return s.metadata=i,s.ts=null!=o?o:null,s}return s(n)}(re),Gl=function(e){i(n,e);var t=f(n);function n(e,a,s){var i;return r(this,n),(i=t.call(this,e,"SYEV",s)).created=null,i.updated=null,i.deleted=null,s.data&&(i.created=s.data.created,i.updated=s.data.updated,i.deleted=s.data.deleted),i}return s(n)}(le),Hl=function(e){i(n,e);var t=f(n);function n(e){var a;r(this,n);var s=e.channelUrl,i=e.channelType,o=e.key;return(a=t.call(this)).method=B.DELETE,a.path="".concat(Fs(i),"/").concat(encodeURIComponent(s),"/metadata/").concat(o),a.params={include_ts:!0},a}return s(n)}(ne),ql=function(e){i(n,e);var t=f(n);function n(e,a){var s;r(this,n),(s=t.call(this,e,a)).ts=null;var i=a.ts;return s.ts=null!=i?i:null,s}return s(n)}(re),jl=function(e){i(n,e);var t=f(n);function n(e){var a;r(this,n);var s=e.channelUrl,i=e.channelType;return(a=t.call(this)).method=B.DELETE,a.path="".concat(Fs(i),"/").concat(encodeURIComponent(s),"/metadata"),a.params={include_ts:!0},a}return s(n)}(ne),zl=function(e){i(n,e);var t=f(n);function n(e,a){var s;r(this,n),(s=t.call(this,e,a)).ts=null;var i=a.ts;return s.ts=null!=i?i:null,s}return s(n)}(re),Vl=function(e){i(n,e);var t=f(n);function n(e){var a;r(this,n);var s=e.channelUrl,i=e.channelType,o=e.keys;return(a=t.call(this)).method=B.GET,a.path="".concat(Fs(i),"/").concat(encodeURIComponent(s),"/metacounter"),a.params={keys:o},a}return s(n)}(ne),Bl=function(e){i(n,e);var t=f(n);function n(e,a){var s;return r(this,n),(s=t.call(this,e,a)).metaCounter=a,s}return s(n)}(re),Ql=function(e){i(n,e);var t=f(n);function n(e){var a;r(this,n);var s=e.channelUrl,i=e.channelType,o=e.metaCounter;return(a=t.call(this)).method=B.POST,a.path="".concat(Fs(i),"/").concat(encodeURIComponent(s),"/metacounter"),a.params={metacounter:o},a}return s(n)}(ne),Kl=function(e){i(n,e);var t=f(n);function n(e,a){var s;return r(this,n),(s=t.call(this,e,a)).metaCounter=a,s}return s(n)}(re),Wl=function(e){i(n,e);var t=f(n);function n(e){var a;r(this,n);var s=e.channelUrl,i=e.channelType,o=e.metaCounter,u=e.upsert,c=void 0!==u&&u,l=e.mode,h=void 0===l?"set":l;return(a=t.call(this)).method=B.PUT,a.path="".concat(Fs(i),"/").concat(encodeURIComponent(s),"/metacounter"),a.params={metacounter:o,upsert:c,mode:h},a}return s(n)}(ne),Yl=function(e){i(n,e);var t=f(n);function n(e,a){var s;return r(this,n),(s=t.call(this,e,a)).metaCounter=a,s}return s(n)}(re),Zl=function(e){i(n,e);var t=f(n);function n(e,a,s){var i;return r(this,n),(i=t.call(this,e,"SYEV",s)).created=null,i.updated=null,i.deleted=null,s.data&&(i.created=s.data.created,i.updated=s.data.updated,i.deleted=s.data.deleted),i}return s(n)}(le),Jl=function(e){i(n,e);var t=f(n);function n(e){var a;r(this,n);var s=e.channelUrl,i=e.channelType,o=e.key;return(a=t.call(this)).method=B.DELETE,a.path="".concat(Fs(i),"/").concat(encodeURIComponent(s),"/metacounter/").concat(o),a.params=null,a}return s(n)}(ne),Xl=function(e){i(n,e);var t=f(n);function n(e){var a;r(this,n);var s=e.channelUrl,i=e.channelType;return(a=t.call(this)).method=B.DELETE,a.path="".concat(Fs(i),"/").concat(encodeURIComponent(s),"/metacounter"),a.params=null,a}return s(n)}(ne),$l=function(e){i(n,e);var t=f(n);function n(e){var a;r(this,n);var s=e.channelUrl,i=e.channelType,o=e.userId,u=e.seconds,c=e.description;return(a=t.call(this)).method=B.POST,a.path="".concat(Fs(i),"/").concat(encodeURIComponent(s),"/mute"),a.params={user_id:o,seconds:u,description:c},a}return s(n)}(ne),eh=function(e){i(n,e);var t=f(n);function n(e,a,s){var i;return r(this,n),(i=t.call(this,e,"SYEV",s)).user=new hl(e,s.data),i}return s(n)}(le),th=function(e){i(n,e);var t=f(n);function n(e){var a;r(this,n);var s=e.channelUrl,i=e.channelType,o=e.userId;return(a=t.call(this)).method=B.DELETE,a.path="".concat(Fs(i),"/").concat(encodeURIComponent(s),"/mute/").concat(encodeURIComponent(o)),a}return s(n)}(ne),nh=function(e){i(n,e);var t=f(n);function n(e,a,s){var i;return r(this,n),(i=t.call(this,e,"SYEV",s)).user=new hl(e,s.data),i}return s(n)}(le),rh=function(e){i(n,e);var t=f(n);function n(e){var a;r(this,n);var s=e.channelUrl,i=e.channelType,o=e.userId,u=e.seconds,c=e.description;return(a=t.call(this)).method=B.POST,a.path="".concat(Fs(i),"/").concat(encodeURIComponent(s),"/ban"),a.params=ee({user_id:o,seconds:u,description:c}),a}return s(n)}(ne),ah=function(e){i(n,e);var t=f(n);function n(e,a,s){var i;return r(this,n),(i=t.call(this,e,"SYEV",s)).memberCount=null,i.joinedMemberCount=null,i.user=new hl(e,s.data),s.data.member_count&&(i.memberCount=s.data.member_count),s.data.joined_member_count&&(i.joinedMemberCount=s.data.joined_member_count),i}return s(n)}(le),sh=function(e){i(n,e);var t=f(n);function n(e){var a;r(this,n);var s=e.channelUrl,i=e.channelType,o=e.userId;return(a=t.call(this)).method=B.DELETE,a.path="".concat(Fs(i),"/").concat(encodeURIComponent(s),"/ban/").concat(encodeURIComponent(o)),a}return s(n)}(ne),ih=function(e){i(n,e);var t=f(n);function n(e,a,s){var i;return r(this,n),(i=t.call(this,e,"SYEV",s)).user=new hl(e,s.data),i}return s(n)}(le),oh=function(e){i(n,e);var t=f(n);function n(e){var a;r(this,n);var s=e.channelUrl,i=e.channelType,o=e.freezing;return(a=t.call(this)).method=B.PUT,a.path="".concat(Fs(i),"/").concat(encodeURIComponent(s),"/freeze"),a.params={freeze:o},a}return s(n)}(ne),uh=function(e){i(n,e);var t=f(n);function n(e,a,s){var i;return r(this,n),(i=t.call(this,e,"SYEV",s)).freeze=s.data.freeze,i}return s(n)}(le),ch=function(e){i(n,e);var t=f(n);function n(e){var a;r(this,n);var s=e.channelUrl,i=e.channelType,o=e.category,u=e.userId,c=e.description;return(a=t.call(this)).method=B.POST,a.path="".concat(Gs(i),"/").concat(encodeURIComponent(s)),a.params={report_category:o,reporting_user_id:u,report_description:c},a}return s(n)}(ne),lh=function(t){i(a,t);var n=f(a);function a(t){var s;r(this,a);var i=t.channelUrl,o=t.channelType,u=t.category,c=t.userId,l=t.offendingUserId,h=t.description;return(s=n.call(this)).method=B.POST,s.path="".concat(Wr,"/users/").concat(l),s.params={channel_url:i,channel_type:o===e.ChannelType.OPEN?"open_channels":"group_channels",report_category:u,reporting_user_id:c,report_description:h},s}return s(a)}(ne),hh=function(e){i(n,e);var t=f(n);function n(e){var a;r(this,n);var s=e.channelUrl,i=e.channelType,o=e.category,u=e.userId,c=e.offendingUserId,l=e.messageId,h=e.description;return(a=t.call(this)).method=B.POST,a.path="".concat(Gs(i),"/").concat(encodeURIComponent(s),"/messages/").concat(l),a.params={report_category:o,reporting_user_id:u,report_description:h,offending_user_id:c},a}return s(n)}(ne),dh=function(t){i(a,t);var n=f(a);function a(t){r(this,a);var s=[];return t.mentionType===e.MentionType.USERS&&(t.mentionedUserIds?s=t.mentionedUserIds:t.mentionedUsers&&(s=t.mentionedUsers.map((function(e){return e.userId})))),n.call(this,{code:"MESG",ackRequired:!0,payload:ee({channel_url:t.channelUrl,message:t.message,data:t.data,custom_type:t.customType,metaarray:t.metaArrays,mention_type:t.mentionType,mentioned_user_ids:s,mentioned_message_template:t.mentionedMessageTemplate,target_langs:t.translationTargetLanguages,push_option:t.pushNotificationDeliveryOption&&t.pushNotificationDeliveryOption!==e.PushNotificationDeliveryOption.DEFAULT?t.pushNotificationDeliveryOption:void 0,apple_critical_alert_options:t.appleCriticalAlertOptions,silent:t.silent,reply_to_channel:t.isReplyToChannel,parent_message_id:t.parentMessageId>0?t.parentMessageId:null,req_id:t.reqId,poll_id:t.pollId,pin_message:t.isPinnedMessage})})}return s(a)}(Mr),fh=function(e){i(n,e);var t=f(n);function n(e,a,s){var i,o,u,c;r(this,n),(i=t.call(this,e,"MESG",s)).message=new Rs(e,s);var l=ns.of(e).sdkState;return i.isMentioned=Hs(i.message.mentionType,null!==(o=i.message.mentionedUserIds)&&void 0!==o?o:null===(u=i.message.mentionedUsers)||void 0===u?void 0:u.map((function(e){return e.userId})),l.userId),i.forceUpdateLastMessage=null!==(c=s.force_update_last_message)&&void 0!==c&&c,i}return s(n)}(le),ph=function(t){i(a,t);var n=f(a);function a(t){var s;r(this,a);var i=null;return t.mentionType===e.MentionType.USERS&&(t.mentionedUserIds?i=t.mentionedUserIds:t.mentionedUsers&&(i=t.mentionedUsers.map((function(e){return e.userId})))),n.call(this,{code:"MEDI",ackRequired:!0,payload:ee({channel_url:t.channelUrl,msg_id:t.messageId,message:t.message,data:t.data,custom_type:t.customType,metaarray:t.metaArrayParams,mention_type:t.mentionType,mentioned_user_ids:i,mentioned_message_template:t.mentionedMessageTemplate,apple_critical_alert_options:null===(s=t.appleCriticalAlertOptions)||void 0===s?void 0:s.serialize(),poll_id:t.pollId})})}return s(a)}(Mr),vh=function(e){i(n,e);var t=f(n);function n(e,a,s){var i,o,u,c,l,h,d;r(this,n),(i=t.call(this,e,"MEDI",s)).message=new Rs(e,s);var f=ns.of(e).sdkState;return i.mentionCountChange=qs({mentionType:null!==(u=null===(o=s.old_values)||void 0===o?void 0:o.mention_type)&&void 0!==u?u:null,mentionedUserIds:null!==(l=null===(c=s.old_values)||void 0===c?void 0:c.mentioned_user_ids)&&void 0!==l?l:[]},{mentionType:i.message.mentionType,mentionedUserIds:null!==(h=i.message.mentionedUserIds)&&void 0!==h?h:null===(d=i.message.mentionedUsers)||void 0===d?void 0:d.map((function(e){return e.userId}))},f.userId),i}return s(n)}(le),_h=function(t){i(a,t);var n=f(a);function a(t){r(this,a);var s=null;return t.mentionType===e.MentionType.USERS&&(t.mentionedUserIds?s=t.mentionedUserIds:t.mentionedUsers&&(s=t.mentionedUsers.map((function(e){return e.userId})))),n.call(this,{code:"FEDI",ackRequired:!0,payload:ee({channel_url:t.channelUrl,msg_id:t.messageId,data:t.data,custom_type:t.customType,metaarray:t.metaArrayParams,mention_type:t.mentionType,mentioned_user_ids:s,apple_critical_alert_options:t.appleCriticalAlertOptions})})}return s(a)}(Mr),mh=function(e){i(n,e);var t=f(n);function n(e,a,s){var i,o,u,c,l,h,d;r(this,n),(i=t.call(this,e,"FEDI",s)).message=new Ps(e,s);var f=ns.of(e).sdkState;return i.mentionCountChange=qs({mentionType:null!==(u=null===(o=s.old_values)||void 0===o?void 0:o.mention_type)&&void 0!==u?u:null,mentionedUserIds:null!==(l=null===(c=s.old_values)||void 0===c?void 0:c.mentioned_user_ids)&&void 0!==l?l:[]},{mentionType:i.message.mentionType,mentionedUserIds:null!==(h=i.message.mentionedUserIds)&&void 0!==h?h:null===(d=i.message.mentionedUsers)||void 0===d?void 0:d.map((function(e){return e.userId}))},f.userId),i}return s(n)}(le),gh=function(e){i(n,e);var t=f(n);function n(e){var a;return r(this,n),(a=t.call(this)).method=B.DELETE,a.path="".concat(Fs(e.channelType),"/").concat(e.channelUrl,"/messages/").concat(e.messageId),a}return s(n)}(ne),yh=function(e){i(n,e);var t=f(n);function n(e,a,s){var i;return r(this,n),(i=t.call(this,e,"DELM",s)).channelUrl=s.channel_url,i.channelType=s.channel_type,i.messageId=Number(s.msg_id),i}return s(n)}(le),kh=function(e){i(n,e);var t=f(n);function n(e){var a,s=e.channelType,i=e.channelUrl,o=e.messageId,u=e.reactionKey;return r(this,n),(a=t.call(this)).method=B.POST,a.path="".concat(Fs(s),"/").concat(encodeURIComponent(i),"/messages/").concat(o,"/reactions"),a.params={reaction:u},a}return s(n)}(ne),bh=function(e){i(n,e);var t=f(n);function n(e,a){var s;return r(this,n),(s=t.call(this,e,a)).reactionEvent=new ds(a),s}return s(n)}(re),Eh=function(e){i(n,e);var t=f(n);function n(e){var a,s=e.channelType,i=e.channelUrl,o=e.messageId,u=e.reactionKey;return r(this,n),(a=t.call(this)).method=B.DELETE,a.path="".concat(Fs(s),"/").concat(encodeURIComponent(i),"/messages/").concat(o,"/reactions"),a.params={reaction:u},a}return s(n)}(ne),wh=function(e){i(n,e);var t=f(n);function n(e,a){var s;return r(this,n),(s=t.call(this,e,a)).reactionEvent=new ds(Object.assign({},a)),s}return s(n)}(re),Ch=function(e){i(n,e);var t=f(n);function n(e){var a,s=e.channelType,i=e.channelUrl,o=e.messageId,u=e.translationTargetLanguages;return r(this,n),(a=t.call(this)).method=B.POST,a.path="".concat(Fs(s),"/").concat(encodeURIComponent(i),"/messages/").concat(encodeURIComponent(o),"/translation"),a.params={target_langs:u},a}return s(n)}(ne),xh=function(e){i(n,e);var t=f(n);function n(e,a){var s;return r(this,n),(s=t.call(this,e,a)).message=new Rs(e,a),s}return s(n)}(re),Th=function(t){i(a,t);var n=f(a);function a(t){var s,i;r(this,a),s=n.call(this);var o=[];t.mentionType===e.MentionType.USERS&&(t.mentionedUserIds?o=t.mentionedUserIds:t.mentionedUsers&&(o=t.mentionedUsers.map((function(e){return e.userId}))));var u=t.channelType,c=t.channelUrl;return s.method=B.POST,s.path="".concat(Fs(u),"/").concat(encodeURIComponent(c),"/scheduled_messages"),s.params={req_id:t.reqId,scheduled_at:t.scheduledAt,message_type:Ya.USER,message:t.message,custom_type:t.customType,data:t.data,mention_type:t.mentionType,mentioned_user_ids:o,sorted_metaarray:null===(i=t.metaArrays)||void 0===i?void 0:i.map((function(e){return ps.payloadify(e)})),apple_critical_alert_options:ms.payloadify(t.appleCriticalAlertOptions),target_langs:t.translationTargetLanguages,push_option:t.pushNotificationDeliveryOption},s}return s(a)}(ne),Sh=function(e){i(n,e);var t=f(n);function n(e,a){var s;return r(this,n),(s=t.call(this,e,a)).message=new Rs(e,a),s}return s(n)}(re),Ih=function(t){i(a,t);var n=f(a);function a(t){var s,i;r(this,a),s=n.call(this);var o=[];t.mentionType===e.MentionType.USERS&&(t.mentionedUserIds?o=t.mentionedUserIds:t.mentionedUsers&&(o=t.mentionedUsers.map((function(e){return e.userId}))));var u=t.channelType,c=t.channelUrl;return s.method=B.POST,s.path="".concat(Fs(u),"/").concat(encodeURIComponent(c),"/scheduled_messages"),s.params={req_id:t.reqId,scheduled_at:t.scheduledAt,message_type:Ya.FILE,url:t.fileUrl,file_name:t.fileName,file_size:t.fileSize,file_type:t.mimeType,thumbnails:t.thumbnailSizes?t.thumbnailSizes.map((function(e){return ws.payloadify(e)})):[],custom_type:t.customType,data:t.data,require_auth:t.requireAuth,mention_type:t.mentionType,mentioned_user_ids:o,sorted_metaarray:null===(i=t.metaArrays)||void 0===i?void 0:i.map((function(e){return ps.payloadify(e)})),apple_critical_alert_options:ms.payloadify(t.appleCriticalAlertOptions),push_option:t.pushNotificationDeliveryOption},s}return s(a)}(ne),Nh=function(e){i(n,e);var t=f(n);function n(e,a){var s;return r(this,n),(s=t.call(this,e,a)).message=new Ps(e,a),s}return s(n)}(re),Ah=function(e){return L("string",e.title,!0)&&Ms(e.data)&&L("boolean",e.allowUserSuggestion,!0)&&L("boolean",e.allowMultipleVotes,!0)&&L("number",e.closeAt,!0)},Mh=function(e){i(n,e);var t=f(n);function n(e){var a,s=e.pollId,i=e.title,o=e.data,u=e.allowUserSuggestion,c=e.allowMultipleVotes,l=e.closeAt;return r(this,n),(a=t.call(this)).method=B.PUT,a.path="".concat(Jr,"/").concat(encodeURIComponent(s)),a.params={title:i,data:o,allow_user_suggestion:u,allow_multiple_votes:c,close_at:l},a}return s(n)}(ne),Oh=function(e){i(n,e);var t=f(n);function n(e,a){var s;return r(this,n),(s=t.call(this,e,a)).poll=new Us(e,a),s}return s(n)}(re),Uh=function(e){i(n,e);var t=f(n);function n(e){var a,s=e.pollId;return r(this,n),(a=t.call(this)).method=B.DELETE,a.path="".concat(Jr,"/").concat(encodeURIComponent(s)),a}return s(n)}(ne),Rh=function(e){i(n,e);var t=f(n);function n(e){var a,s=e.pollId;return r(this,n),(a=t.call(this)).method=B.PUT,a.path="".concat(Jr,"/").concat(encodeURIComponent(s),"/close"),a}return s(n)}(ne),Lh=function(e){i(n,e);var t=f(n);function n(e,a){var s;return r(this,n),(s=t.call(this,e,a)).poll=new Us(e,a),s}return s(n)}(re),Dh=function(e){i(n,e);var t=f(n);function n(e){var a,s=e.channelUrl,i=e.channelType,o=e.pollId,u=e.optionText;return r(this,n),(a=t.call(this)).method=B.POST,a.path="".concat(Jr,"/").concat(encodeURIComponent(o),"/options"),a.params={channel_url:s,channel_type:i,text:u},a}return s(n)}(ne),Ph=function(e){i(n,e);var t=f(n);function n(e,a){var s;return r(this,n),(s=t.call(this,e,a)).poll=new Us(e,a),s}return s(n)}(re),Fh=function(e){i(n,e);var t=f(n);function n(e){var a,s=e.pollId,i=e.pollOptionId,o=e.optionText;return r(this,n),(a=t.call(this)).method=B.PUT,a.path="".concat(Jr,"/").concat(encodeURIComponent(s),"/options/").concat(encodeURIComponent(i)),a.params={text:o},a}return s(n)}(ne),Gh=function(e){i(n,e);var t=f(n);function n(e,a){var s;return r(this,n),(s=t.call(this,e,a)).poll=new Us(e,a),s}return s(n)}(re),Hh=function(e){i(n,e);var t=f(n);function n(e){var a,s=e.pollId,i=e.pollOptionId;return r(this,n),(a=t.call(this)).method=B.DELETE,a.path="".concat(Jr,"/").concat(encodeURIComponent(s),"/options/").concat(encodeURIComponent(i)),a}return s(n)}(ne),qh=function(t){i(a,t);var n=f(a);function a(t){var s=t.reqId,i=t.channelType,o=t.channelUrl,u=t.pollId,c=t.pollOptionIds;return r(this,a),n.call(this,{code:"VOTE",ackRequired:!0,payload:ee({req_id:s,channel_type:i===e.ChannelType.OPEN?"open_channels":"group_channels",channel_url:o,poll_id:u,option_ids:c})})}return s(a)}(Mr),jh=function(e){i(n,e);var t=f(n);function n(e,a,s){var i;return r(this,n),(i=t.call(this,e,"VOTE",s)).event=null,i.channelUrl=null,i.channelType=null,i.event=new Yi(s),i.channelUrl=s.channel_url,i.channelType=s.channel_type,i}return s(n)}(le),zh=function(n){i(u,n);var a=f(u);function u(t,n){var s,i,o,c,l;return r(this,u),(s=a.call(this,t)).url="",s.channelType=e.ChannelType.BASE,s.name="",s.coverUrl="",s.customType="",s.data="",s.isFrozen=!1,s.isEphemeral=!1,s.creator=null,s.createdAt=0,s._messageCollectionLastAccessedAt=0,s.url=n.channel_url,s.name=null!==(i=n.name)&&void 0!==i?i:"",s.coverUrl=null!==(o=n.cover_url)&&void 0!==o?o:"",s.customType=null!==(c=n.custom_type)&&void 0!==c?c:"",s.data=null!==(l=n.data)&&void 0!==l?l:"",s.isFrozen=!!L("boolean",n.freeze)&&n.freeze,s.isEphemeral=!!L("boolean",n.is_ephemeral)&&n.is_ephemeral,s.creator=n.created_by?new La(s._iid,n.created_by):null,s.createdAt=1e3*n.created_at,s._cachedMetaData=new Map,n.metadata&&n.ts&&Object.keys(n.metadata).forEach((function(e){s._cachedMetaData.set(e,{value:n.metadata[e],isRemoved:!1,updatedAt:n.ts})})),s}return s(u,[{key:"isGroupChannel",value:function(){return this.channelType===e.ChannelType.GROUP}},{key:"isOpenChannel",value:function(){return this.channelType===e.ChannelType.OPEN}},{key:"cachedMetaData",get:function(){var e={};return this._cachedMetaData.forEach((function(t,n){t.isRemoved||(e[n]=t.value)})),e}},{key:"messageCollectionLastAccessedAt",get:function(){return this._messageCollectionLastAccessedAt}},{key:"_updateMessageCollectionLastAccessedAt",value:function(){this._messageCollectionLastAccessedAt=Date.now()}},{key:"_upsertCachedMetaData",value:function(e,t){var n=this;Object.keys(e).forEach((function(r){var a=n._cachedMetaData.get(r);(!a||a.updatedAt<=t)&&n._cachedMetaData.set(r,{value:e[r],isRemoved:!1,updatedAt:t})}))}},{key:"_removeFromCachedMetaData",value:function(e,t){var n=this;e.forEach((function(e){var r=n._cachedMetaData.get(e);r&&r.updatedAt0&&void 0!==arguments[0]?arguments[0]:{};return new bl(this._iid,this.url,this.channelType,e)}},{key:"createMutedUserListQuery",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return new Cl(this._iid,this.url,this.channelType,e)}},{key:"createBannedUserListQuery",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return new Sl(this._iid,this.url,this.channelType,e)}},{key:"createPreviousMessageListQuery",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return new Ii(this._iid,this.url,this.channelType,e)}},{key:"addOperators",value:function(e){return b(this,void 0,void 0,t().mark((function n(){var r,a,s;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return Ua(F("string",e)).throw(M.invalidParameters),r=ns.of(this._iid),a=r.requestQueue,s=new Nl({channelUrl:this.url,channelType:this.channelType,operatorUserIds:e}),t.next=5,a.send(s);case 5:case"end":return t.stop()}}),n,this)})))}},{key:"removeOperators",value:function(e){return b(this,void 0,void 0,t().mark((function n(){var r,a,s;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return Ua(F("string",e)).throw(M.invalidParameters),r=ns.of(this._iid),a=r.requestQueue,s=new Al({channelUrl:this.url,channelType:this.channelType,operatorUserIds:e}),t.next=5,a.send(s);case 5:case"end":return t.stop()}}),n,this)})))}},{key:"getMyMutedInfo",value:function(){return b(this,void 0,void 0,t().mark((function e(){var n,r,a,s,i,o,u,c,l,h,d;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n=ns.of(this._iid),r=n.sdkState,a=n.requestQueue,s=new Ml({channelUrl:this.url,channelType:this.channelType,userId:r.userId}),e.next=4,a.send(s);case 4:return i=e.sent,o=i.as(Ol),u=o.isMuted,c=o.startAt,l=o.endAt,h=o.remainingDuration,d=o.description,e.abrupt("return",{isMuted:u,startAt:c,endAt:l,remainingDuration:h,description:d});case 7:case"end":return e.stop()}}),e,this)})))}},{key:"getMetaData",value:function(e){return b(this,void 0,void 0,t().mark((function n(){var r,a,s,i,o,u,c;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return Ua(F("string",e)).throw(M.invalidParameters),r=ns.of(this._iid),a=r.requestQueue,s=new Ul({channelUrl:this.url,channelType:this.channelType,keys:e}),t.next=5,a.send(s);case 5:return i=t.sent,o=i.as(Rl),u=o.metadata,c=o.ts,this._upsertCachedMetaData(u,c),t.abrupt("return",u);case 9:case"end":return t.stop()}}),n,this)})))}},{key:"getAllMetaData",value:function(){return b(this,void 0,void 0,t().mark((function e(){var n,r,a,s,i,o,u;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n=ns.of(this._iid),r=n.requestQueue,a=new Ul({channelUrl:this.url,channelType:this.channelType,keys:[]}),e.next=4,r.send(a);case 4:return s=e.sent,i=s.as(Rl),o=i.metadata,u=i.ts,this._upsertCachedMetaData(o,u),e.abrupt("return",o);case 8:case"end":return e.stop()}}),e,this)})))}},{key:"createMetaData",value:function(e){return b(this,void 0,void 0,t().mark((function n(){var r,a,s,i,o,u;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return r=ns.of(this._iid),a=r.requestQueue,s=new Ll({channelUrl:this.url,channelType:this.channelType,metadata:e}),t.next=4,a.send(s);case 4:return i=t.sent,o=i.as(Dl),u=o.metaData,this._upsertCachedMetaData(u,0),t.abrupt("return",u);case 8:case"end":return t.stop()}}),n,this)})))}},{key:"updateMetaData",value:function(e){var n=arguments.length>1&&void 0!==arguments[1]&&arguments[1];return b(this,void 0,void 0,t().mark((function r(){var a,s,i,o,u,c,l;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return a=ns.of(this._iid),s=a.requestQueue,i=new Pl({channelUrl:this.url,channelType:this.channelType,metadata:e,upsert:n}),t.next=4,s.send(i);case 4:return o=t.sent,u=o.as(Fl),c=u.metadata,l=u.ts,this._upsertCachedMetaData(c,l),t.abrupt("return",c);case 8:case"end":return t.stop()}}),r,this)})))}},{key:"deleteMetaData",value:function(e){return b(this,void 0,void 0,t().mark((function n(){var r,a,s,i,o,u;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return Ua(L("string",e)).throw(M.invalidParameters),r=ns.of(this._iid),a=r.requestQueue,s=new Hl({channelUrl:this.url,channelType:this.channelType,key:e}),t.next=5,a.send(s);case 5:i=t.sent,o=i.as(ql),u=o.ts,this._removeFromCachedMetaData([e],u);case 8:case"end":return t.stop()}}),n,this)})))}},{key:"deleteAllMetaData",value:function(){return b(this,void 0,void 0,t().mark((function e(){var n,r,a,s,i,o;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n=ns.of(this._iid),r=n.requestQueue,a=new jl({channelUrl:this.url,channelType:this.channelType}),e.next=4,r.send(a);case 4:s=e.sent,i=s.as(zl),o=i.ts,this._removeFromCachedMetaData(_(this._cachedMetaData.keys()),o);case 7:case"end":return e.stop()}}),e,this)})))}},{key:"getMetaCounters",value:function(e){return b(this,void 0,void 0,t().mark((function n(){var r,a,s,i,o,u;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return Ua(F("string",e)).throw(M.invalidParameters),r=ns.of(this._iid),a=r.requestQueue,s=new Vl({channelUrl:this.url,channelType:this.channelType,keys:e}),t.next=5,a.send(s);case 5:return i=t.sent,o=i.as(Bl),u=o.metaCounter,t.abrupt("return",u);case 8:case"end":return t.stop()}}),n,this)})))}},{key:"getAllMetaCounters",value:function(){return b(this,void 0,void 0,t().mark((function e(){var n,r,a,s,i,o;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n=ns.of(this._iid),r=n.requestQueue,a=new Vl({channelUrl:this.url,channelType:this.channelType,keys:[]}),e.next=4,r.send(a);case 4:return s=e.sent,i=s.as(Bl),o=i.metaCounter,e.abrupt("return",o);case 7:case"end":return e.stop()}}),e,this)})))}},{key:"createMetaCounters",value:function(e){return b(this,void 0,void 0,t().mark((function n(){var r,a,s,i,o,u;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return r=ns.of(this._iid),a=r.requestQueue,s=new Ql({channelUrl:this.url,channelType:this.channelType,metaCounter:e}),t.next=4,a.send(s);case 4:return i=t.sent,o=i.as(Kl),u=o.metaCounter,t.abrupt("return",u);case 7:case"end":return t.stop()}}),n,this)})))}},{key:"updateMetaCounters",value:function(e){var n=arguments.length>1&&void 0!==arguments[1]&&arguments[1];return b(this,void 0,void 0,t().mark((function r(){var a,s,i,o,u,c;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return a=ns.of(this._iid),s=a.requestQueue,i=new Wl({channelUrl:this.url,channelType:this.channelType,metaCounter:e,upsert:n}),t.next=4,s.send(i);case 4:return o=t.sent,u=o.as(Yl),c=u.metaCounter,t.abrupt("return",c);case 7:case"end":return t.stop()}}),r,this)})))}},{key:"increaseMetaCounters",value:function(e){return b(this,void 0,void 0,t().mark((function n(){var r,a,s,i,o,u;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return r=ns.of(this._iid),a=r.requestQueue,s=new Wl({channelUrl:this.url,channelType:this.channelType,metaCounter:e,upsert:!1,mode:"increase"}),t.next=4,a.send(s);case 4:return i=t.sent,o=i.as(Yl),u=o.metaCounter,t.abrupt("return",u);case 7:case"end":return t.stop()}}),n,this)})))}},{key:"decreaseMetaCounters",value:function(e){return b(this,void 0,void 0,t().mark((function n(){var r,a,s,i,o,u;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return r=ns.of(this._iid),a=r.requestQueue,s=new Wl({channelUrl:this.url,channelType:this.channelType,metaCounter:e,upsert:!1,mode:"decrease"}),t.next=4,a.send(s);case 4:return i=t.sent,o=i.as(Yl),u=o.metaCounter,t.abrupt("return",u);case 7:case"end":return t.stop()}}),n,this)})))}},{key:"deleteMetaCounter",value:function(e){return b(this,void 0,void 0,t().mark((function n(){var r,a,s;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return Ua(L("string",e)).throw(M.invalidParameters),r=ns.of(this._iid),a=r.requestQueue,s=new Jl({channelUrl:this.url,channelType:this.channelType,key:e}),t.next=5,a.send(s);case 5:case"end":return t.stop()}}),n,this)})))}},{key:"deleteAllMetaCounters",value:function(){return b(this,void 0,void 0,t().mark((function e(){var n,r,a;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n=ns.of(this._iid),r=n.requestQueue,a=new Xl({channelUrl:this.url,channelType:this.channelType}),e.next=4,r.send(a);case 4:case"end":return e.stop()}}),e,this)})))}},{key:"muteUser",value:function(e,n,r){return b(this,void 0,void 0,t().mark((function a(){return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.abrupt("return",this.muteUserWithUserId(e.userId,n,r));case 1:case"end":return t.stop()}}),a,this)})))}},{key:"muteUserWithUserId",value:function(e,n,r){return b(this,void 0,void 0,t().mark((function a(){var s,i,o;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return Ua(L("string",e)&&L("number",n,!0)&&L("string",r,!0)).throw(M.invalidParameters),s=ns.of(this._iid),i=s.requestQueue,o=new $l({channelUrl:this.url,channelType:this.channelType,userId:e,seconds:n,description:r}),t.next=5,i.send(o);case 5:case"end":return t.stop()}}),a,this)})))}},{key:"unmuteUser",value:function(e){return b(this,void 0,void 0,t().mark((function n(){return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.abrupt("return",this.unmuteUserWithUserId(e.userId));case 1:case"end":return t.stop()}}),n,this)})))}},{key:"unmuteUserWithUserId",value:function(e){return b(this,void 0,void 0,t().mark((function n(){var r,a,s;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return Ua(L("string",e)).throw(M.invalidParameters),r=ns.of(this._iid),a=r.requestQueue,s=new th({channelUrl:this.url,channelType:this.channelType,userId:e}),t.next=5,a.send(s);case 5:case"end":return t.stop()}}),n,this)})))}},{key:"banUser",value:function(e,n,r){return b(this,void 0,void 0,t().mark((function a(){return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.abrupt("return",this.banUserWithUserId(e.userId,n,r));case 1:case"end":return t.stop()}}),a,this)})))}},{key:"banUserWithUserId",value:function(e,n,r){return b(this,void 0,void 0,t().mark((function a(){var s,i,o;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return Ua(L("string",e)&&L("number",n,!0)&&L("string",r,!0)).throw(M.invalidParameters),s=ns.of(this._iid),i=s.requestQueue,o=new rh({channelUrl:this.url,channelType:this.channelType,userId:e,seconds:n,description:r}),t.next=5,i.send(o);case 5:case"end":return t.stop()}}),a,this)})))}},{key:"unbanUser",value:function(e){return b(this,void 0,void 0,t().mark((function n(){return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.abrupt("return",this.unbanUserWithUserId(e.userId));case 1:case"end":return t.stop()}}),n,this)})))}},{key:"unbanUserWithUserId",value:function(e){return b(this,void 0,void 0,t().mark((function n(){var r,a,s;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return Ua(L("string",e)).throw(M.invalidParameters),r=ns.of(this._iid),a=r.requestQueue,s=new sh({channelUrl:this.url,channelType:this.channelType,userId:e}),t.next=5,a.send(s);case 5:case"end":return t.stop()}}),n,this)})))}},{key:"freeze",value:function(){return b(this,void 0,void 0,t().mark((function e(){var n,r,a;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n=ns.of(this._iid),r=n.requestQueue,a=new oh({channelUrl:this.url,channelType:this.channelType,freezing:!0}),e.next=4,r.send(a);case 4:this.isFrozen=!0;case 5:case"end":return e.stop()}}),e,this)})))}},{key:"unfreeze",value:function(){return b(this,void 0,void 0,t().mark((function e(){var n,r,a;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n=ns.of(this._iid),r=n.requestQueue,a=new oh({channelUrl:this.url,channelType:this.channelType,freezing:!1}),e.next=4,r.send(a);case 4:this.isFrozen=!1;case 5:case"end":return e.stop()}}),e,this)})))}},{key:"getMessagesByMessageId",value:function(e,n){return b(this,void 0,void 0,t().mark((function r(){var a,s;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return a=Object.assign(Object.assign({},Ws),n),Ua(L("number",e)&&Ys(a)).throw(M.invalidParameters),s=vi.of(this._iid),t.next=5,s.getMessagesByMessageId(this.url,this.channelType,e,a);case 5:return t.abrupt("return",t.sent);case 6:case"end":return t.stop()}}),r,this)})))}},{key:"getMessagesByTimestamp",value:function(e,n){return b(this,void 0,void 0,t().mark((function r(){var a,s;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return a=Object.assign(Object.assign({},Ws),n),Ua(L("number",e)&&Ys(a)).throw(M.invalidParameters),s=vi.of(this._iid),t.next=5,s.getMessagesByTimestamp(this.url,this.channelType,e,a);case 5:return t.abrupt("return",t.sent);case 6:case"end":return t.stop()}}),r,this)})))}},{key:"getMessageChangeLogsSinceTimestamp",value:function(e){var n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return b(this,void 0,void 0,t().mark((function r(){var a,s;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return a=Object.assign(Object.assign({},Zs),n),Ua(L("number",e)&&Js(a)).throw(M.invalidParameters),s=vi.of(this._iid),t.next=5,s.getMessageChangelogs(this.url,this.channelType,e,a);case 5:return t.abrupt("return",t.sent);case 6:case"end":return t.stop()}}),r,this)})))}},{key:"getMessageChangeLogsSinceToken",value:function(e){var n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return b(this,void 0,void 0,t().mark((function r(){var a,s;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return a=Object.assign(Object.assign({},Zs),n),Ua(L("string",e)&&Js(a)).throw(M.invalidParameters),s=vi.of(this._iid),t.next=5,s.getMessageChangelogs(this.url,this.channelType,e,a);case 5:return t.abrupt("return",t.sent);case 6:case"end":return t.stop()}}),r,this)})))}},{key:"_createPendingSendableMessagePayload",value:function(t,n,r){var a=ns.of(this._iid).sessionManager;return ee({channel_url:this.url,channel_type:this.channelType,msg_id:0,parent_message_id:t.parentMessageId,data:t.data,custom_type:t.customType,mention_type:t.mentionType,sorted_metaarray:t.metaArrays?t.metaArrays.map((function(e){return ps.payloadify(e)})):null,apple_critical_alert_options:t.appleCriticalAlertOptions?ms.payloadify(t.appleCriticalAlertOptions):null,created_at:r,user:bs.payloadify(a.currentUser),req_id:n,request_state:e.SendingStatus.PENDING,mentioned_user_ids:t.mentionedUserIds,mentioned_users:t.mentionedUsers})}},{key:"_createPendingUserMessage",value:function(t,n,r){var a={};if(t.translationTargetLanguages){var s,i=y(t.translationTargetLanguages);try{for(i.s();!(s=i.n()).done;){a[s.value]=""}}catch(e){i.e(e)}finally{i.f()}}var o=ee(Object.assign(Object.assign({},this._createPendingSendableMessagePayload(t,n,r)),{type:e.MessageType.USER,message:t.message,translations:a})),u=new Rs(this._iid,o);return u.messageParams=t,u}},{key:"_createPendingScheduledUserMessage",value:function(e,t,n){var r=this._createPendingUserMessage(e,t,n);return r.scheduledInfo={scheduledMessageId:0,scheduledAt:e.scheduledAt,scheduledMessageParams:e},r}},{key:"_createPendingFileMessage",value:function(t,n,r){var a=ee(Object.assign(Object.assign({},this._createPendingSendableMessagePayload(t,n,r)),{type:e.MessageType.FILE,url:t.fileUrl,file:{name:t.fileName,size:t.fileSize,type:t.mimeType,data:t.data},thumbnails:t.thumbnailSizes?t.thumbnailSizes.map((function(e){return{url:"",width:e.maxWidth,height:e.maxHeight}})):[]})),s=new Ps(this._iid,a);return s.messageParams=t,s}},{key:"_createPendingScheduledFileMessage",value:function(e,t,n){var r=this._createPendingFileMessage(e,t,n);return r.scheduledInfo={scheduledMessageId:0,scheduledAt:e.scheduledAt,scheduledMessageParams:e},r}},{key:"_markMessageAsFailed",value:function(t,n){var r=arguments.length>2&&void 0!==arguments[2]&&arguments[2];t.errorCode=n.code,n.code===E.REQUEST_CANCELED?t.sendingStatus=e.SendingStatus.CANCELED:r||(t.sendingStatus=e.SendingStatus.FAILED)}},{key:"sendUserMessage",value:function(e){var t=Object.assign(Object.assign({},ko),e);return Ua(Eo(t)).throw(M.invalidParameters),this._sendUserMessage(t)}},{key:"_sendUserMessage",value:function(n){var r=this,a=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null,s=ns.of(this._iid),i=s.dispatcher,o=s.requestQueue,u=a,c=Date.now(),l=new _i;u||(u=this._generateRequestId(),sa(2).then((function(){var a=r._createPendingUserMessage(n,u,c);i.dispatch(new ei({messages:[a],source:e.MessageEventSource.EVENT_MESSAGE_SENT_PENDING})),ua((function(){return b(r,void 0,void 0,t().mark((function e(){return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",l._trigger(null,a));case 1:case"end":return e.stop()}}),e)})))}))})));var h=new dh(Object.assign(Object.assign({},n),{channelUrl:this.url,channelType:this.channelType,reqId:u}));return o.send(h).then((function(n){var a=n.as(fh).message;i.dispatch(new ei({messages:[a],source:e.MessageEventSource.EVENT_MESSAGE_SENT_SUCCESS})),ua((function(){return b(r,void 0,void 0,t().mark((function e(){return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",l._trigger(null,a));case 1:case"end":return e.stop()}}),e)})))}))})).catch((function(a){if(A(a))throw a;sa(2).then((function(){var s=r._createPendingUserMessage(n,u,c),o=ns.of(r._iid).cacheContext.localCacheEnabled&&G(a.code);r._markMessageAsFailed(s,a,o),i.dispatch(new ei({messages:[s],source:s.sendingStatus===e.SendingStatus.PENDING?e.MessageEventSource.REQUEST_RESEND_MESSAGE:e.MessageEventSource.EVENT_MESSAGE_SENT_FAILED})),ua((function(){return b(r,void 0,void 0,t().mark((function e(){return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",l._trigger(a,s));case 1:case"end":return e.stop()}}),e)})))}))}))})),l}},{key:"_autoResendUserMessage",value:function(e){return Ua(e instanceof Rs).throw(M.invalidParameters),this._sendUserMessage(e.messageParams,e.reqId)}},{key:"resendUserMessage",value:function(e){var n;return b(this,void 0,void 0,t().mark((function r(){var a,s;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return Ua(e instanceof Rs&&!e.scheduledInfo).throw(M.invalidParameters),a=new Ur,s=null!==(n=e.messageParams)&&void 0!==n?n:bo(e),this._sendUserMessage(s,e.reqId).onFailed((function(e){return a.reject(e)})).onSucceeded((function(e){return a.resolve(e)})),t.abrupt("return",a.promise);case 5:case"end":return t.stop()}}),r,this)})))}},{key:"updateUserMessage",value:function(e,n){return b(this,void 0,void 0,t().mark((function r(){var a,s,i,o,u,c,l;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return a=Object.assign(Object.assign({},vl),n),Ua(L("number",e)&&_l(a)).throw(M.invalidParameters),s=ns.of(this._iid),i=s.requestQueue,o=new ph(Object.assign({channelType:this.channelType,channelUrl:this.url,messageId:e},a)),t.next=6,i.send(o);case 6:return u=t.sent,c=u.as(vh),l=c.message,t.abrupt("return",l);case 9:case"end":return t.stop()}}),r,this)})))}},{key:"copyUserMessage",value:function(n,r){var a,s,i;return b(this,void 0,void 0,t().mark((function o(){var c,l;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return Ua(n instanceof u&&r instanceof Rs&&r.sendingStatus===e.SendingStatus.SUCCEEDED&&this.url===r.channelUrl&&!r.scheduledInfo).throw(M.invalidParameters),Ua(!r.poll).throw(M.notSupportedError),c=new Ur,l=null!==(a=r.messageParams)&&void 0!==a?a:Object.assign(Object.assign({},r),{mentionType:r.mentionType,mentionedUserIds:null!==(s=r.mentionedUserIds)&&void 0!==s?s:null===(i=r.mentionedUsers)||void 0===i?void 0:i.map((function(e){return e.userId})),translationTargetLanguages:Object.keys(r.translations),pushNotificationDeliveryOption:e.PushNotificationDeliveryOption.DEFAULT,parentMessageId:null,isReplyToChannel:!1,isPinnedMessage:!1}),n._sendUserMessage(l).onSucceeded((function(e){c.resolve(e)})).onFailed((function(e){return c.reject(e)})),t.abrupt("return",c.promise);case 6:case"end":return t.stop()}}),o,this)})))}},{key:"translateUserMessage",value:function(e,n){return b(this,void 0,void 0,t().mark((function r(){var a,s,i,o,u,c;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return Ua(e instanceof Rs&&e.messageId>0&&F("string",n)).throw(M.invalidParameters),a=ns.of(this._iid),s=a.requestQueue,i=new Ch({channelType:this.channelType,channelUrl:this.url,messageId:e.messageId,translationTargetLanguages:n}),t.next=5,s.send(i);case 5:return o=t.sent,u=o.as(xh),c=u.message,t.abrupt("return",c);case 8:case"end":return t.stop()}}),r,this)})))}},{key:"_createScheduledUserMessage",value:function(e,n){var r=this,a=ns.of(this._iid).requestQueue,s=Date.now(),i=this._generateRequestId();sa(2).then((function(){var a=r._createPendingScheduledUserMessage(e,i,s);ua((function(){return b(r,void 0,void 0,t().mark((function e(){return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",n._trigger(null,a));case 1:case"end":return e.stop()}}),e)})))}))}));var o=new Th(Object.assign({reqId:i,channelType:this.channelType,channelUrl:this.url},e));a.send(o).then((function(e){var a=e.as(Sh).message;ua((function(){return b(r,void 0,void 0,t().mark((function e(){return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",n._trigger(null,a));case 1:case"end":return e.stop()}}),e)})))}))})).catch((function(a){if(A(a))throw a;sa(2).then((function(){var o=r._createPendingScheduledUserMessage(e,i,s);r._markMessageAsFailed(o,a),ua((function(){return b(r,void 0,void 0,t().mark((function e(){return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",n._trigger(a,o));case 1:case"end":return e.stop()}}),e)})))}))}))}))}},{key:"sendFileMessage",value:function(e){var t=Object.assign(Object.assign({},To),e);return Ua(Io(t)).throw(M.invalidParameters),this._sendFileMessage(t)}},{key:"_sendFileMessage",value:function(n){var r=this,a=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null,s=ns.of(this._iid).dispatcher,i=vi.of(this._iid).fileMessageQueue,o=a,u=Date.now(),c=new _i;return o||(o=this._generateRequestId(),sa(2).then((function(){var a=r._createPendingFileMessage(n,o,u);s.dispatch(new ei({messages:[a],source:e.MessageEventSource.EVENT_MESSAGE_SENT_PENDING})),ua((function(){return b(r,void 0,void 0,t().mark((function e(){return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",c._trigger(null,a));case 1:case"end":return e.stop()}}),e)})))}))}))),i.request(this,o,n).then((function(n){s.dispatch(new ei({messages:[n],source:e.MessageEventSource.EVENT_MESSAGE_SENT_SUCCESS})),ua((function(){return b(r,void 0,void 0,t().mark((function e(){return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",c._trigger(null,n));case 1:case"end":return e.stop()}}),e)})))}))})).catch((function(a){if(A(a))throw a;sa(2).then((function(){var i=r._createPendingFileMessage(n,o,u),l=ns.of(r._iid).cacheContext.localCacheEnabled&&G(a.code);r._markMessageAsFailed(i,a,l),s.dispatch(new ei({messages:[i],source:i.sendingStatus===e.SendingStatus.PENDING?e.MessageEventSource.REQUEST_RESEND_MESSAGE:e.MessageEventSource.EVENT_MESSAGE_SENT_FAILED})),ua((function(){return b(r,void 0,void 0,t().mark((function e(){return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",c._trigger(a,i));case 1:case"end":return e.stop()}}),e)})))}))}))})),c}},{key:"_autoResendFileMessage",value:function(e){Ua(e instanceof Ps).throw(M.invalidParameters);var t=ns.of(this._iid).logger;return t.debug("autoResendFileMessage pending",e),this._sendFileMessage(e.messageParams,e.reqId).onFailed((function(e){t.debug("autoResendFileMessage failed",e)})).onSucceeded((function(e){t.debug("autoResendFileMessage success",e)}))}},{key:"_createScheduledFileMessage",value:function(e,n,r,a){var s=this,i=ns.of(this._iid).requestQueue,o=new Ih(Object.assign(Object.assign({reqId:r,channelType:this.channelType,channelUrl:this.url},e),{fileUrl:e.fileUrl,requireAuth:e.requireAuth}));i.send(o).then((function(e){var r=e.as(Nh).message;ua((function(){return b(s,void 0,void 0,t().mark((function e(){return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",n._trigger(null,r));case 1:case"end":return e.stop()}}),e)})))}))})).catch((function(i){if(A(i))throw i;sa(2).then((function(){var o=s._createPendingScheduledFileMessage(e,r,a);s._markMessageAsFailed(o,i),ua((function(){return b(s,void 0,void 0,t().mark((function e(){return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",n._trigger(i,o));case 1:case"end":return e.stop()}}),e)})))}))}))}))}},{key:"sendFileMessages",value:function(e){Ua(e.every((function(e){return Io(Object.assign(Object.assign({},To),e))}))).throw(M.invalidParameters);var t,n=new _i,r=y(e);try{for(r.s();!(t=r.n()).done;){var a=t.value;this.sendFileMessage(a).onPending((function(e){return n._trigger(null,e)})).onFailed((function(e,t){return n._trigger(e,t)})).onSucceeded((function(e){return n._trigger(null,e)}))}}catch(e){r.e(e)}finally{r.f()}return n}},{key:"resendFileMessage",value:function(e,n){var r;return b(this,void 0,void 0,t().mark((function a(){var s,i,o;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return s=Boolean(e.url)||H(n)||H(null===(r=e.messageParams)||void 0===r?void 0:r.file),Ua(e instanceof Ps&&s&&!e.scheduledInfo).throw(M.invalidParameters),i=new Ur,o=So(e,n),this._sendFileMessage(o,e.reqId).onFailed((function(e){return i.reject(e)})).onSucceeded((function(e){return i.resolve(e)})),t.abrupt("return",i.promise);case 6:case"end":return t.stop()}}),a,this)})))}},{key:"updateFileMessage",value:function(e,n){return b(this,void 0,void 0,t().mark((function r(){var a,s,i,o,u,c,l;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return a=Object.assign(Object.assign({},ml),n),Ua(L("number",e)&&gl(a)).throw(M.invalidParameters),s=ns.of(this._iid),i=s.requestQueue,o=new _h(Object.assign({channelType:this.channelType,channelUrl:this.url,messageId:e},a)),t.next=6,i.send(o);case 6:return u=t.sent,c=u.as(mh),l=c.message,t.abrupt("return",l);case 9:case"end":return t.stop()}}),r,this)})))}},{key:"cancelUploadingFileMessage",value:function(e){return b(this,void 0,void 0,t().mark((function n(){var r;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return Ua(L("string",e)).throw(M.invalidParameters),r=vi.of(this._iid),r.fileMessageQueue.cancel(this,e),t.abrupt("return",!0);case 4:case"end":return t.stop()}}),n,this)})))}},{key:"copyFileMessage",value:function(n,r){var a,s;return b(this,void 0,void 0,t().mark((function i(){var o,c;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return Ua(n instanceof u&&r instanceof Ps&&r.sendingStatus===e.SendingStatus.SUCCEEDED&&this.url===r.channelUrl&&!r.scheduledInfo).throw(M.invalidParameters),o=new Ur,c=Object.assign(Object.assign({},r),{fileUrl:r.url,fileName:r.name,fileSize:r.size,mimeType:r.type,mentionType:r.mentionType,mentionedUserIds:null!==(a=r.mentionedUserIds)&&void 0!==a?a:null===(s=r.mentionedUsers)||void 0===s?void 0:s.map((function(e){return e.userId})),pushNotificationDeliveryOption:e.PushNotificationDeliveryOption.DEFAULT,parentMessageId:null,isReplyToChannel:!1,thumbnailSizes:r.thumbnails.map((function(e){return{maxWidth:e.width,maxHeight:e.height}})),requireAuth:r.requireAuth,isPinnedMessage:!1}),n._sendFileMessage(c).onSucceeded((function(e){return o.resolve(e)})).onFailed((function(e){return o.reject(e)})),t.abrupt("return",o.promise);case 5:case"end":return t.stop()}}),i,this)})))}},{key:"deleteMessage",value:function(e){return b(this,void 0,void 0,t().mark((function n(){var r,a,s;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(Ua(e instanceof ks).throw(M.invalidParameters),!(e.messageId>0)){t.next=6;break}return r=ns.of(this._iid),a=r.requestQueue,s=new gh({channelType:this.channelType,channelUrl:this.url,messageId:e.messageId}),t.next=6,a.send(s);case 6:case"end":return t.stop()}}),n,this)})))}},{key:"addReaction",value:function(e,n){return b(this,void 0,void 0,t().mark((function r(){var a,s,i,o,u,c;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return Ua(e instanceof ks&&e.messageId>0&&L("string",n)).throw(M.invalidParameters),a=ns.of(this._iid),s=a.requestQueue,i=new kh({channelType:this.channelType,channelUrl:this.url,messageId:e.messageId,reactionKey:n}),t.next=5,s.send(i);case 5:return o=t.sent,u=o.as(bh),c=u.reactionEvent,t.abrupt("return",c);case 8:case"end":return t.stop()}}),r,this)})))}},{key:"deleteReaction",value:function(e,n){return b(this,void 0,void 0,t().mark((function r(){var a,s,i,o,u,c;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return Ua(e instanceof ks&&e.messageId>0&&L("string",n)).throw(M.invalidParameters),a=ns.of(this._iid),s=a.requestQueue,i=new Eh({channelType:this.channelType,channelUrl:this.url,messageId:e.messageId,reactionKey:n}),t.next=5,s.send(i);case 5:return o=t.sent,u=o.as(wh),c=u.reactionEvent,t.abrupt("return",c);case 8:case"end":return t.stop()}}),r,this)})))}},{key:"_updateUserMessageMetaArray",value:function(n,r,a,s){return b(this,void 0,void 0,t().mark((function i(){var o,u,c,l,h,d,f;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return o=ns.of(this._iid),u=o.dispatcher,c=o.requestQueue,l=new ph({channelType:this.channelType,channelUrl:this.url,messageId:n,metaArrayParams:{array:r,mode:a,upsert:s}}),t.next=4,c.send(l);case 4:return h=t.sent,d=h.as(vh),f=d.message,u.dispatch(new ei({messages:[f],source:e.MessageEventSource.EVENT_MESSAGE_UPDATED})),t.abrupt("return",f);case 8:case"end":return t.stop()}}),i,this)})))}},{key:"_updateFileMessageMetaArray",value:function(n,r,a,s){return b(this,void 0,void 0,t().mark((function i(){var o,u,c,l,h,d,f;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return o=ns.of(this._iid),u=o.dispatcher,c=o.requestQueue,l=new _h({channelType:this.channelType,channelUrl:this.url,messageId:n,metaArrayParams:{array:r,mode:a,upsert:s}}),t.next=4,c.send(l);case 4:return h=t.sent,d=h.as(mh),f=d.message,u.dispatch(new ei({messages:[f],source:e.MessageEventSource.EVENT_MESSAGE_UPDATED})),t.abrupt("return",f);case 8:case"end":return t.stop()}}),i,this)})))}},{key:"createMessageMetaArrayKeys",value:function(e,n){return b(this,void 0,void 0,t().mark((function r(){var a;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(Ua(e instanceof ks&&e.messageId>0&&F("string",n)).throw(M.invalidParameters),a=n.map((function(e){return new ps({key:e})})),!(e instanceof Ps)){t.next=6;break}return t.abrupt("return",this._updateFileMessageMetaArray(e.messageId,a,"add",!0));case 6:return t.abrupt("return",this._updateUserMessageMetaArray(e.messageId,a,"add",!0));case 7:case"end":return t.stop()}}),r,this)})))}},{key:"deleteMessageMetaArrayKeys",value:function(e,n){return b(this,void 0,void 0,t().mark((function r(){var a;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(Ua(e instanceof ks&&e.messageId>0&&F("string",n)).throw(M.invalidParameters),a=n.map((function(e){return new ps({key:e})})),!(e instanceof Ps)){t.next=6;break}return t.abrupt("return",this._updateFileMessageMetaArray(e.messageId,a,"remove",!0));case 6:return t.abrupt("return",this._updateUserMessageMetaArray(e.messageId,a,"remove",!0));case 7:case"end":return t.stop()}}),r,this)})))}},{key:"addMessageMetaArrayValues",value:function(e,n){return b(this,void 0,void 0,t().mark((function r(){return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(Ua(e instanceof ks&&e.messageId>0&&n.every((function(e){return e instanceof ps}))).throw(M.invalidParameters),!(e instanceof Ps)){t.next=5;break}return t.abrupt("return",this._updateFileMessageMetaArray(e.messageId,n,"add",!0));case 5:return t.abrupt("return",this._updateUserMessageMetaArray(e.messageId,n,"add",!0));case 6:case"end":return t.stop()}}),r,this)})))}},{key:"removeMessageMetaArrayValues",value:function(e,n){return b(this,void 0,void 0,t().mark((function r(){return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(Ua(e instanceof ks&&e.messageId>0&&n.every((function(e){return e instanceof ps}))).throw(M.invalidParameters),!(e instanceof Ps)){t.next=5;break}return t.abrupt("return",this._updateFileMessageMetaArray(e.messageId,n,"remove",!0));case 5:return t.abrupt("return",this._updateUserMessageMetaArray(e.messageId,n,"remove",!0));case 6:case"end":return t.stop()}}),r,this)})))}},{key:"report",value:function(n,r){return b(this,void 0,void 0,t().mark((function a(){var s,i,o,u;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return Ua(D(e.ReportCategory,n)&&L("string",r)).throw(M.invalidParameters),s=ns.of(this._iid),i=s.sdkState,o=s.requestQueue,u=new ch({channelUrl:this.url,channelType:this.channelType,userId:i.userId,category:n,description:r}),t.next=5,o.send(u);case 5:case"end":return t.stop()}}),a,this)})))}},{key:"reportUser",value:function(n,r,a){return b(this,void 0,void 0,t().mark((function s(){var i,o,u,c;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return Ua(n instanceof La&&D(e.ReportCategory,r)&&L("string",a)).throw(M.invalidParameters),i=ns.of(this._iid),o=i.sdkState,u=i.requestQueue,c=new lh({channelUrl:this.url,channelType:this.channelType,userId:o.userId,offendingUserId:n.userId,category:r,description:a}),t.next=5,u.send(c);case 5:case"end":return t.stop()}}),s,this)})))}},{key:"reportMessage",value:function(n,r,a){return b(this,void 0,void 0,t().mark((function s(){var i,o,u,c;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return Ua(n instanceof Es&&D(e.ReportCategory,r)&&L("string",a)).throw(M.invalidParameters),i=ns.of(this._iid),o=i.sdkState,u=i.requestQueue,c=new hh({channelUrl:this.url,channelType:this.channelType,userId:o.userId,offendingUserId:n.sender.userId,messageId:n.messageId,category:r,description:a}),t.next=5,u.send(c);case 5:case"end":return t.stop()}}),s,this)})))}},{key:"updatePoll",value:function(e,n){return b(this,void 0,void 0,t().mark((function r(){var a,s,i,o,u,c;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return Ua(L("number",e)&&Ah(n)).throw(M.invalidParameters),a=ns.of(this._iid),s=a.requestQueue,i=new Mh(Object.assign({pollId:e},n)),t.next=5,s.send(i);case 5:return o=t.sent,u=o.as(Oh),c=u.poll,t.abrupt("return",c);case 8:case"end":return t.stop()}}),r,this)})))}},{key:"deletePoll",value:function(e){return b(this,void 0,void 0,t().mark((function n(){var r,a,s,i;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return r=L("number",e),Ua(r).throw(M.invalidParameters),a=ns.of(this._iid),s=a.requestQueue,i=new Uh({pollId:e}),t.next=6,s.send(i);case 6:case"end":return t.stop()}}),n,this)})))}},{key:"closePoll",value:function(e){return b(this,void 0,void 0,t().mark((function n(){var r,a,s,i,o,u,c;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return r=L("number",e),Ua(r).throw(M.invalidParameters),a=ns.of(this._iid),s=a.requestQueue,i=new Rh({pollId:e}),t.next=6,s.send(i);case 6:return o=t.sent,u=o.as(Lh),c=u.poll,t.abrupt("return",c);case 9:case"end":return t.stop()}}),n,this)})))}},{key:"addPollOption",value:function(e,n){return b(this,void 0,void 0,t().mark((function r(){var a,s,i,o,u,c,l;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return a=L("number",e)&&L("string",n)&&""!==n.trim(),Ua(a).throw(M.invalidParameters),s=ns.of(this._iid),i=s.requestQueue,o=new Dh({channelUrl:this.url,channelType:this.channelType,pollId:e,optionText:n}),t.next=6,i.send(o);case 6:return u=t.sent,c=u.as(Ph),l=c.poll,t.abrupt("return",l);case 9:case"end":return t.stop()}}),r,this)})))}},{key:"updatePollOption",value:function(e,n,r){return b(this,void 0,void 0,t().mark((function a(){var s,i,o,u,c,l,h;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return s=L("number",e)&&L("number",n)&&L("string",r)&&""!==r.trim(),Ua(s).throw(M.invalidParameters),i=ns.of(this._iid),o=i.requestQueue,u=new Fh({pollId:e,pollOptionId:n,optionText:r}),t.next=6,o.send(u);case 6:return c=t.sent,l=c.as(Gh),h=l.poll,t.abrupt("return",h);case 9:case"end":return t.stop()}}),a,this)})))}},{key:"deletePollOption",value:function(e,n){return b(this,void 0,void 0,t().mark((function r(){var a,s,i,o;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return a=L("number",e)&&L("number",n),Ua(a).throw(M.invalidParameters),s=ns.of(this._iid),i=s.requestQueue,o=new Hh({pollId:e,pollOptionId:n}),t.next=6,i.send(o);case 6:case"end":return t.stop()}}),r,this)})))}},{key:"votePoll",value:function(n,r){return b(this,void 0,void 0,t().mark((function a(){var s,i,o,u,c,l,h,d;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return s=L("number",n)&&F("number",r),Ua(s).throw(M.invalidParameters),i=ns.of(this._iid),o=i.requestQueue,u=i.dispatcher,c=new qh({reqId:this._generateRequestId(),channelUrl:this.url,channelType:this.channelType,pollId:n,pollOptionIds:r}),t.next=6,o.send(c);case 6:return l=t.sent,h=l.as(jh),d=h.event,u.dispatch(new si({event:d,source:e.MessageEventSource.EVENT_POLL_VOTED})),t.abrupt("return",d);case 10:case"end":return t.stop()}}),a,this)})))}},{key:"getPollChangeLogsSinceTimestamp",value:function(e){return b(this,void 0,void 0,t().mark((function n(){var r;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return Ua(L("number",e)).throw(M.invalidParameters),r=Ki.of(this._iid),t.next=4,r.getPollChangeLogs(this.url,this.channelType,e);case 4:return t.abrupt("return",t.sent);case 5:case"end":return t.stop()}}),n,this)})))}},{key:"getPollChangeLogsSinceToken",value:function(e){return b(this,void 0,void 0,t().mark((function n(){var r;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return Ua(L("string",e,!0)),r=Ki.of(this._iid),t.next=4,r.getPollChangeLogs(this.url,this.channelType,e);case 4:return t.abrupt("return",t.sent);case 5:case"end":return t.stop()}}),n,this)})))}},{key:"createPollListQuery",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:10;return new Xi(this._iid,{channelUrl:this.url,channelType:this.channelType,limit:e})}},{key:"createPollVoterListQuery",value:function(e,t){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:20;return new to(this._iid,{channelUrl:this.url,channelType:this.channelType,pollId:e,pollOptionId:t,limit:n})}}],[{key:"payloadify",value:function(e){return ee(Object.assign(Object.assign({},p(o(u),"payloadify",this).call(this,e)),{channel_url:e.url,name:e.name,cover_url:e.coverUrl,custom_type:e.customType,data:e.data,freeze:e.isFrozen,is_ephemeral:e.isEphemeral,created_by:La.payloadify(e.creator),created_at:e.createdAt/1e3}))}}]),u}(Ca),Vh=null,Bh=function(){function n(e,a,s){var i=this;r(this,n),this._storeInitialized=!1,this._fcmPushToken=null,this._apnsPushToken=null,this._iid=e,this.options=a;var o=ns.of(e),u=o.sdkState,c=o.cacheContext,l=o.dispatcher,h=o.sessionManager,d=o.requestQueue,f=o.logger,p=o.userEventHandlers,v=o.appStateToggleEnabled;this._onlineDetector=new Wo({logger:f,connectionDelegate:{reconnect:function(){var t=ns.of(e),n=t.sdkState,r=t.connectionManager,a=t.sessionManager;a.auth.hasSession?"foreground"===n.appState&&r.resetAndReconnect():r.connect(a.auth.authToken)},disconnect:function(){ns.of(e).connectionManager.disconnect()}}});var _=new Jo(e,{localCacheEnabled:c.localCacheEnabled,dispatcher:l,sdkState:u,logger:f});s.forEach((function(t){t.init(e,{sdkState:u,cacheContext:c,dispatcher:l,sessionManager:h,requestQueue:d,logger:f,onlineDetector:i._onlineDetector}),i[t.name]=t})),this._appStateChangeDetector=new Ko({isEnabled:v}),this._appStateChangeDetector.on("resume",(function(){f.debug("the page resumes from freeze"),i.setForegroundState()})).on("pause",(function(){f.debug("the page freezes"),i.setBackgroundState()})),l.on((function(n){if(n instanceof Dr){if(n.stateType===Nr.CONNECTED)_.processNonAutoResendRegisteredPendingMessages()}else if(n instanceof le){if("USEV"===n.code){var r=n.as(iu).event;if(r.category===Lo.FRIEND_DISCOVERED){var a=$o.getDataAsFriendDiscoveredEvent(e,r).friendDiscoveries;ua((function(){return b(i,void 0,void 0,t().mark((function e(){return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",p.forEach((function(e){e.onFriendsDiscovered(a)})));case 1:case"end":return e.stop()}}),e)})))}))}}}else if(n instanceof Or){var s=ns.of(i._iid).subscribedUnreadMessageCount,o=!1,l=n.ts;if("number"==typeof l&&l>s.ts){if(s.all!==n.all&&(o=!0),s.all=n.all>=0?n.all:0,n.customTypes)for(var h in n.customTypes)s.customTypes[h]!==n.customTypes[h]&&(o=!0),s.customTypes[h]=n.customTypes[h];o=o&&s.ts>0,s.ts=l}o&&ua((function(){return b(i,void 0,void 0,t().mark((function e(){return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",p.forEach((function(e){e.onTotalUnreadMessageCountUpdated(s.all,s.customTypes)})));case 1:case"end":return e.stop()}}),e)})))}))}else n instanceof Da&&c.preference.set(i._getUserProfileCacheKey(u.userId),Pa.payloadify(n.userProfile))}))}return s(n,[{key:"appId",get:function(){return ns.of(this._iid).sdkState.appId}},{key:"appInfo",get:function(){return ns.of(this._iid).appInfo}},{key:"appVersion",get:function(){var e;return null!==(e=ns.of(this._iid).sdkState.appVersion)&&void 0!==e?e:""}},{key:"debugMode",get:function(){return ns.of(this._iid).debugMode}},{key:"logLevel",get:function(){return ns.of(this._iid).logger.level},set:function(e){ns.of(this._iid).logger.level=e}},{key:"isCacheEnabled",get:function(){return ns.of(this._iid).cacheContext.localCacheEnabled}},{key:"localCacheConfig",get:function(){var e=ns.of(this._iid).cacheContext;return e.localCacheEnabled?e.localCacheConfig:null}},{key:"ekey",get:function(){return ns.of(this._iid).sessionManager.ekey}},{key:"currentUser",get:function(){var e;return null!==(e=ns.of(this._iid).sessionManager.currentUser)&&void 0!==e?e:null}},{key:"connectionState",get:function(){var t=ns.of(this._iid).connectionManager;return t.isConnected?e.ConnectionState.OPEN:t.isConnecting?e.ConnectionState.CONNECTING:e.ConnectionState.CLOSED}},{key:"lastConnectedAt",get:function(){var e=ns.of(this._iid),t=e.connectedAt;return e.connectionManager.isConnected?t:0}},{key:"fcmPushToken",get:function(){return this._fcmPushToken}},{key:"apnsPushToken",get:function(){return this._apnsPushToken}},{key:"_getCurrentPreferenceVersion",value:function(){return 1}},{key:"_getPreferenceCacheKey",value:function(e){return"sendbird@".concat(this.appId,"/").concat(e,".pref")}},{key:"_getUserProfileCacheKey",value:function(e){return"sendbird@".concat(this.appId,"/").concat(e,".profile")}},{key:"getMemoryStoreForDebugging",value:function(){var e=ns.of(this._iid),t=e.debugMode,n=e.cacheContext;if(t)return n.store instanceof $c?n.store:null;throw M.debugModeRequired}},{key:"addExtension",value:function(e,t){var n=ns.of(this._iid).sdkState;["sb_uikit","sb_syncmanager","device-os-platform"].indexOf(e)>-1&&(n.extensions[e]=t)}},{key:"setOnlineListener",value:function(e){this._onlineDetector.setOnlineListener(e)}},{key:"setOfflineListener",value:function(e){this._onlineDetector.setOfflineListener(e)}},{key:"_safeInitializeStore",value:function(e){return b(this,void 0,void 0,t().mark((function n(){var r,a;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return r=ns.of(this._iid),a=r.cacheContext,t.prev=1,t.next=4,a.store.init(e);case 4:this._storeInitialized=!0,t.next=12;break;case 7:return t.prev=7,t.t0=t.catch(1),a.store=new $c,t.next=12,this._safeInitializeStore(e);case 12:case"end":return t.stop()}}),n,this,[[1,7]])})))}},{key:"initializeCache",value:function(e){return b(this,void 0,void 0,t().mark((function n(){var r,a,s,i,o,u,c,l;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(r=ns.of(this._iid),a=r.sdkState,s=r.cacheContext,i=r.connectionManager,o=r.dispatcher,u=r.logger,a.userId&&a.userId===e){t.next=29;break}return t.next=4,i.logout();case 4:if(c="sendbird@".concat(a.appId,"/").concat(e,".db"),!s.localCacheEnabled){t.next=26;break}if(t.prev=6,s.nestdb&&s.nestdb.state!==qc.CLOSED&&s.nestdb.name===c){t.next=14;break}return(l=s.nestdb=new ul({name:"sendbird@".concat(a.appId,"/").concat(e,".db"),version:2,store:s.store})).on("upgrade",zo(l,s.store)),t.next=12,l.open();case 12:this._storeInitialized=!0,o.dispatch(new eu(this._iid,{userId:e}));case 14:a.userId=e,t.next=24;break;case 17:return t.prev=17,t.t0=t.catch(6),u.warn("Nest DB Open Failed. ",t.t0),t.next=22,this._safeInitializeStore(c);case 22:throw a.userId=e,M.databaseError;case 24:t.next=29;break;case 26:return t.next=28,this._safeInitializeStore(c);case 28:a.userId=e;case 29:case"end":return t.stop()}}),n,this,[[6,17]])})))}},{key:"getCacheDataSize",value:function(){return b(this,void 0,void 0,t().mark((function e(){var n,r;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(n=ns.of(this._iid),!(r=n.cacheContext).localCacheEnabled||!r.nestdb){e.next=5;break}return e.next=4,r.nestdb.estimateUsage();case 4:return e.abrupt("return",e.sent);case 5:return e.abrupt("return",0);case 6:case"end":return e.stop()}}),e,this)})))}},{key:"clearCachedData",value:function(){return b(this,void 0,void 0,t().mark((function e(){var n,r;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(n=ns.of(this._iid),!(r=n.cacheContext).localCacheEnabled){e.next=5;break}if(!r.nestdb){e.next=5;break}return e.next=5,r.nestdb.clear();case 5:if(!this._storeInitialized){e.next=8;break}return e.next=8,r.preference.clear();case 8:case"end":return e.stop()}}),e,this)})))}},{key:"clearCachedMessages",value:function(e){return b(this,void 0,void 0,t().mark((function n(){var r,a,s=this;return t().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:if(Ua(F("string",e)).throw(M.invalidParameters),r=Bo.of(this._iid),a=jo.of(this._iid),!r||!a){n.next=6;break}return n.next=6,Promise.all(e.map((function(e){return b(s,void 0,void 0,t().mark((function n(){return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,r.removeMessagesOfChannel(e);case 2:return t.next=4,a.removeMessagesOfChannel(e);case 4:case"end":return t.stop()}}),n)})))})));case 6:case"end":return n.stop()}}),n,this)})))}},{key:"connect",value:function(e){var n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null;return b(this,void 0,void 0,t().mark((function r(){var a,s,i,o,u,c,l,h,d;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return Ua(L("string",e)&&L("string",n,!0)).throw(M.invalidParameters),a=ns.of(this._iid),s=a.sdkState,i=a.cacheContext,o=a.connectionManager,u=a.statLogCollector,this._onlineDetector.start(),this._appStateChangeDetector.start(),t.prev=4,t.next=7,this.initializeCache(e);case 7:c=ns.of(this._iid),c.dispatcher.dispatch(new su),t.next=16;break;case 11:t.prev=11,t.t0=t.catch(4),l=ns.of(this._iid),h=l.logger,i.localCacheEnabled=!1,h.warn("Cache initialization failed - cache is not available.");case 16:return t.next=18,i.preference.init(this._getPreferenceCacheKey(e),this._getCurrentPreferenceVersion());case 18:return t.next=20,i.preference.get(this._getUserProfileCacheKey(e));case 20:return(d=t.sent)&&new Pa(this._iid,d).apply(),t.next=24,u.init("sendbird@".concat(s.appId,"/").concat(e,".statlog"));case 24:return t.next=26,o.connect(n);case 26:return t.abrupt("return",this.currentUser);case 27:case"end":return t.stop()}}),r,this,[[4,11]])})))}},{key:"reconnect",value:function(){var e=ns.of(this._iid),t=e.connectionManager,n=e.sdkState,r=e.sessionManager.auth.hasSession;return r&&(this._appStateChangeDetector.start(),this._onlineDetector.start(),t.resetAndReconnect().then((function(){n.appState="foreground"})).catch((function(){}))),r}},{key:"disconnect",value:function(){return b(this,void 0,void 0,t().mark((function e(){var n,r,a;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n=ns.of(this._iid),r=n.connectionManager,a=n.requestQueue,this._appStateChangeDetector.stop(),this._onlineDetector.stop(),a.cancelAll(),e.next=6,r.logout();case 6:return e.next=8,this.clearCachedData();case 8:case"end":return e.stop()}}),e,this)})))}},{key:"disconnectWebSocket",value:function(){return b(this,void 0,void 0,t().mark((function e(){var n,r,a;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n=ns.of(this._iid),r=n.connectionManager,a=n.requestQueue,this._appStateChangeDetector.stop(),this._onlineDetector.stop(),a.cancelAll(),e.next=6,r.disconnectWebSocket();case 6:case"end":return e.stop()}}),e,this)})))}},{key:"setBackgroundState",value:function(){var e=ns.of(this._iid),t=e.connectionManager,n=e.sdkState,r=e.logger;"foreground"===n.appState&&(n.appState="background",r.debug("going background state"),t.background())}},{key:"setForegroundState",value:function(){var e=ns.of(this._iid),t=e.connectionManager,n=e.sdkState,r=e.logger;"background"===n.appState&&(n.appState="foreground",r.debug("going foreground state"),t.resetAndReconnect())}},{key:"setSessionHandler",value:function(e){Ua(e instanceof so).throw(M.invalidParameters),ns.of(this._iid).sessionManager.handler=e}},{key:"addUserEventHandler",value:function(e,t){Ua(L("string",e)&&t instanceof oo).throw(M.invalidParameters),ns.of(this._iid).userEventHandlers.set(e,t)}},{key:"removeUserEventHandler",value:function(e){ns.of(this._iid).userEventHandlers.delete(e)}},{key:"removeAllUserEventHandler",value:function(){ns.of(this._iid).userEventHandlers.clear()}},{key:"addConnectionHandler",value:function(e,t){Ua(L("string",e)&&t instanceof io).throw(M.invalidParameters),ns.of(this._iid).connectionHandlers.set(e,t)}},{key:"removeConnectionHandler",value:function(e){ns.of(this._iid).connectionHandlers.delete(e)}},{key:"removeAllConnectionHandler",value:function(){ns.of(this._iid).connectionHandlers.clear()}},{key:"createApplicationUserListQuery",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return new oc(this._iid,e)}},{key:"createBlockedUserListQuery",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return new lc(this._iid,e)}},{key:"createFriendListQuery",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return new fc(this._iid,e)}},{key:"createMessageSearchQuery",value:function(e){return new Ti(this._iid,e)}},{key:"createPollListQuery",value:function(e){return new Xi(this._iid,Object.assign({},e))}},{key:"createPollVoterListQuery",value:function(e){return new to(this._iid,Object.assign({},e))}},{key:"buildUserFromSerializedData",value:function(e){var t=Oa(e);return new La(this._iid,La.payloadify(t))}},{key:"updateCurrentUserInfo",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return b(this,void 0,void 0,t().mark((function n(){var r,a,s,i,o,u,c,l;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(r=Object.assign(Object.assign({},ro),e),Ua(ao(r)).throw(M.invalidParameters),!this.currentUser){t.next=13;break}return a=ns.of(this._iid),s=a.sdkState,i=a.requestQueue,o=new ou(Object.assign({userId:s.userId},r)),t.next=7,i.send(o);case 7:return u=t.sent,c=u.as(uu),l=c.user,this.currentUser&&(r.nickname&&(this.currentUser.nickname=l.nickname),(r.profileUrl||r.profileImage)&&(this.currentUser.plainProfileUrl=l.profileUrl)),t.abrupt("return",l);case 13:throw M.connectionRequired;case 14:case"end":return t.stop()}}),n,this)})))}},{key:"updateCurrentUserInfoWithPreferredLanguages",value:function(e){return b(this,void 0,void 0,t().mark((function n(){var r,a,s,i,o,u,c;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(Ua(F("string",e)).throw(M.invalidParameters),!this.currentUser){t.next=12;break}return r=ns.of(this._iid),a=r.sdkState,s=r.requestQueue,i=new ou({userId:a.userId,preferredLanguages:e}),t.next=6,s.send(i);case 6:return o=t.sent,u=o.as(uu),c=u.user,this.currentUser&&(this.currentUser.preferredLanguages=c.preferredLanguages),t.abrupt("return",c);case 12:throw M.connectionRequired;case 13:case"end":return t.stop()}}),n,this)})))}},{key:"registerFCMPushTokenForCurrentUser",value:function(n){return b(this,void 0,void 0,t().mark((function r(){var a,s,i,o,u,c=this;return t().wrap((function(r){for(;;)switch(r.prev=r.next){case 0:if(Ua(L("string",n)).throw(M.invalidParameters),!this.currentUser){r.next=20;break}if(r.prev=2,a=ns.of(this._iid),s=a.sessionManager,i=a.sdkState,o=a.requestQueue,!s.hasDeviceToken(e.PushTokenType.FCM,n)){r.next=6;break}return r.abrupt("return",e.PushTokenRegistrationState.SUCCESS);case 6:return u=new lu({userId:i.userId,token:n}),r.next=9,o.send(u);case 9:return r.next=11,ca((function(){return b(c,void 0,void 0,t().mark((function r(){return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return s.setDeviceToken(e.PushTokenType.FCM,n),t.next=3,s.saveDeviceToken();case 3:case"end":return t.stop()}}),r)})))}));case 11:return this._fcmPushToken="",r.abrupt("return",e.PushTokenRegistrationState.SUCCESS);case 15:return r.prev=15,r.t0=r.catch(2),r.abrupt("return",e.PushTokenRegistrationState.ERROR);case 18:r.next=22;break;case 20:return this._fcmPushToken=n,r.abrupt("return",e.PushTokenRegistrationState.PENDING);case 22:case"end":return r.stop()}}),r,this,[[2,15]])})))}},{key:"unregisterFCMPushTokenForCurrentUser",value:function(n){return b(this,void 0,void 0,t().mark((function r(){var a,s,i,o,u,c,l,h=this;return t().wrap((function(r){for(;;)switch(r.prev=r.next){case 0:if(Ua(L("string",n)).throw(M.invalidParameters),!this.currentUser){r.next=20;break}return r.prev=2,a=ns.of(this._iid),s=a.sessionManager,i=a.sdkState,o=a.requestQueue,u=new du({userId:i.userId,token:n}),r.next=7,o.send(u);case 7:return c=r.sent,l=c.lastDeletedAt,r.next=11,ca((function(){return b(h,void 0,void 0,t().mark((function r(){return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return s.unsetDeviceToken(e.PushTokenType.FCM,n),s.setDeviceTokenDeletedAt(l),t.next=4,s.saveDeviceToken();case 4:case"end":return t.stop()}}),r)})))}));case 11:return this._fcmPushToken="",r.abrupt("return",e.PushTokenRegistrationState.SUCCESS);case 15:return r.prev=15,r.t0=r.catch(2),r.abrupt("return",e.PushTokenRegistrationState.ERROR);case 18:r.next=22;break;case 20:return this._fcmPushToken=n,r.abrupt("return",e.PushTokenRegistrationState.PENDING);case 22:case"end":return r.stop()}}),r,this,[[2,15]])})))}},{key:"unregisterFCMPushTokenAllForCurrentUser",value:function(){return b(this,void 0,void 0,t().mark((function n(){var r,a,s,i,o,u,c,l=this;return t().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:if(!this.currentUser){n.next=9;break}return r=ns.of(this._iid),a=r.sessionManager,s=r.sdkState,i=r.requestQueue,o=new pu({userId:s.userId}),n.next=5,i.send(o);case 5:return u=n.sent,c=u.lastDeletedAt,n.next=9,ca((function(){return b(l,void 0,void 0,t().mark((function n(){return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return a.unsetDeviceTokens(e.PushTokenType.FCM),a.setDeviceTokenDeletedAt(c),t.next=4,a.saveDeviceToken();case 4:case"end":return t.stop()}}),n)})))}));case 9:case"end":return n.stop()}}),n,this)})))}},{key:"registerAPNSPushTokenForCurrentUser",value:function(n){return b(this,void 0,void 0,t().mark((function r(){var a,s,i,o,u,c=this;return t().wrap((function(r){for(;;)switch(r.prev=r.next){case 0:if(Ua(L("string",n)).throw(M.invalidParameters),!this.currentUser){r.next=20;break}if(r.prev=2,a=ns.of(this._iid),s=a.sessionManager,i=a.sdkState,o=a.requestQueue,!s.hasDeviceToken(e.PushTokenType.APNS,n)){r.next=6;break}return r.abrupt("return",e.PushTokenRegistrationState.SUCCESS);case 6:return u=new cu({userId:i.userId,token:n}),r.next=9,o.send(u);case 9:return r.next=11,ca((function(){return b(c,void 0,void 0,t().mark((function r(){return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return s.setDeviceToken(e.PushTokenType.APNS,n),t.next=3,s.saveDeviceToken();case 3:case"end":return t.stop()}}),r)})))}));case 11:return this._apnsPushToken="",r.abrupt("return",e.PushTokenRegistrationState.SUCCESS);case 15:return r.prev=15,r.t0=r.catch(2),r.abrupt("return",e.PushTokenRegistrationState.ERROR);case 18:r.next=22;break;case 20:return this._apnsPushToken=n,r.abrupt("return",e.PushTokenRegistrationState.PENDING);case 22:case"end":return r.stop()}}),r,this,[[2,15]])})))}},{key:"unregisterAPNSPushTokenForCurrentUser",value:function(n){return b(this,void 0,void 0,t().mark((function r(){var a,s,i,o,u,c,l,h=this;return t().wrap((function(r){for(;;)switch(r.prev=r.next){case 0:if(Ua(L("string",n)).throw(M.invalidParameters),!this.currentUser){r.next=20;break}return r.prev=2,a=ns.of(this._iid),s=a.sessionManager,i=a.sdkState,o=a.requestQueue,u=new hu({userId:i.userId,token:n}),r.next=7,o.send(u);case 7:return c=r.sent,l=c.lastDeletedAt,r.next=11,ca((function(){return b(h,void 0,void 0,t().mark((function r(){return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return s.unsetDeviceToken(e.PushTokenType.APNS,n),s.setDeviceTokenDeletedAt(l),t.next=4,s.saveDeviceToken();case 4:case"end":return t.stop()}}),r)})))}));case 11:return this._apnsPushToken="",r.abrupt("return",e.PushTokenRegistrationState.SUCCESS);case 15:return r.prev=15,r.t0=r.catch(2),r.abrupt("return",e.PushTokenRegistrationState.ERROR);case 18:r.next=22;break;case 20:return this._apnsPushToken=n,r.abrupt("return",e.PushTokenRegistrationState.PENDING);case 22:case"end":return r.stop()}}),r,this,[[2,15]])})))}},{key:"unregisterAPNSPushTokenAllForCurrentUser",value:function(){return b(this,void 0,void 0,t().mark((function n(){var r,a,s,i,o,u,c,l=this;return t().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:if(!this.currentUser){n.next=9;break}return r=ns.of(this._iid),a=r.sessionManager,s=r.sdkState,i=r.requestQueue,o=new fu({userId:s.userId}),n.next=5,i.send(o);case 5:return u=n.sent,c=u.lastDeletedAt,n.next=9,ca((function(){return b(l,void 0,void 0,t().mark((function n(){return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return a.unsetDeviceTokens(e.PushTokenType.APNS),a.setDeviceTokenDeletedAt(c),t.next=4,a.saveDeviceToken();case 4:case"end":return t.stop()}}),n)})))}));case 9:case"end":return n.stop()}}),n,this)})))}},{key:"getChannelInvitationPreference",value:function(){return b(this,void 0,void 0,t().mark((function e(){var n,r,a,s,i,o,u;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n=ns.of(this._iid),r=n.sdkState,a=n.requestQueue,s=new mu({userId:r.userId}),e.next=4,a.send(s);case 4:return i=e.sent,o=i.as(gu),u=o.autoAccept,e.abrupt("return",{autoAccept:u});case 7:case"end":return e.stop()}}),e,this)})))}},{key:"setChannelInvitationPreference",value:function(e){return b(this,void 0,void 0,t().mark((function n(){var r,a,s,i,o,u,c;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return Ua(L("boolean",e)).throw(M.invalidParameters),r=ns.of(this._iid),a=r.sdkState,s=r.requestQueue,i=new yu({userId:a.userId,willAutoAccept:e}),t.next=5,s.send(i);case 5:return o=t.sent,u=o.as(ku),c=u.autoAccept,t.abrupt("return",{autoAccept:c});case 8:case"end":return t.stop()}}),n,this)})))}},{key:"getDoNotDisturb",value:function(){return b(this,void 0,void 0,t().mark((function e(){var n,r,a,s,i,o,u;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n=ns.of(this._iid),r=n.sdkState,a=n.requestQueue,s=new bu({userId:r.userId}),e.next=4,a.send(s);case 4:return i=e.sent,o=i.as(Eu),u=o.preference,e.abrupt("return",u);case 7:case"end":return e.stop()}}),e,this)})))}},{key:"setDoNotDisturb",value:function(e){var n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:0,a=arguments.length>3&&void 0!==arguments[3]?arguments[3]:0,s=arguments.length>4&&void 0!==arguments[4]?arguments[4]:0,i=arguments.length>5&&void 0!==arguments[5]?arguments[5]:"";return b(this,void 0,void 0,t().mark((function o(){var u,c,l,h,d,f,p;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return Ua(L("boolean",e)&&L("number",n)&&L("number",r)&&L("number",a)&&L("number",s)&&L("string",i)).throw(M.invalidParameters),u=ns.of(this._iid),c=u.sdkState,l=u.requestQueue,h=new wu({userId:c.userId,doNotDisturbOn:e,startHour:n,startMin:r,endHour:a,endMin:s,timezone:i}),t.next=5,l.send(h);case 5:return d=t.sent,f=d.as(Cu),p=f.preference,t.abrupt("return",p);case 8:case"end":return t.stop()}}),o,this)})))}},{key:"getSnoozePeriod",value:function(){return b(this,void 0,void 0,t().mark((function e(){var n,r,a,s,i,o,u;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n=ns.of(this._iid),r=n.sdkState,a=n.requestQueue,s=new xu({userId:r.userId}),e.next=4,a.send(s);case 4:return i=e.sent,o=i.as(Tu),u=o.snoozePeriod,e.abrupt("return",u);case 7:case"end":return e.stop()}}),e,this)})))}},{key:"setSnoozePeriod",value:function(e){var n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:0;return b(this,void 0,void 0,t().mark((function a(){var s,i,o,u,c,l,h;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return Ua(L("boolean",e)&&L("number",n)&&L("number",r)).throw(M.invalidParameters),s=ns.of(this._iid),i=s.sdkState,o=s.requestQueue,u=new Su({userId:i.userId,snoozeOn:e,startTs:n,endTs:r}),t.next=5,o.send(u);case 5:return c=t.sent,l=c.as(Iu),h=l.snoozePeriod,t.abrupt("return",h);case 8:case"end":return t.stop()}}),a,this)})))}},{key:"getMyPushTokensByToken",value:function(n,r){return b(this,void 0,void 0,t().mark((function a(){var s,i,o,u,c,l,h,d,f,p,v;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return Ua(L("string",n)&&D(e.PushTokenType,r)).throw(M.invalidParameters),s=ns.of(this._iid),i=s.sdkState,o=s.requestQueue,u=s.sessionManager,c=new vu({userId:i.userId,type:r,token:n}),t.next=5,o.send(c);case 5:l=t.sent,h=l.as(_u),d=h.pushTokens,f=y(d.deviceTokens);try{for(f.s();!(p=f.n()).done;)v=p.value,u.setDeviceToken(d.type,v)}catch(e){f.e(e)}finally{f.f()}return t.next=11,u.saveDeviceToken();case 11:return t.abrupt("return",d);case 12:case"end":return t.stop()}}),a,this)})))}},{key:"getPushTriggerOption",value:function(){return b(this,void 0,void 0,t().mark((function e(){var n,r,a,s,i;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n=ns.of(this._iid),r=n.sdkState,a=n.requestQueue,s=new Mu({userId:r.userId}),e.next=4,a.send(s);case 4:return i=e.sent,e.abrupt("return",i.as(Ou).pushTriggerOption);case 6:case"end":return e.stop()}}),e,this)})))}},{key:"setPushTriggerOption",value:function(n){return b(this,void 0,void 0,t().mark((function r(){var a,s,i,o,u;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return Ua(D(e.PushTriggerOption,n)).throw(M.invalidParameters),a=ns.of(this._iid),s=a.sdkState,i=a.requestQueue,o=new Uu({userId:s.userId,pushTriggerOption:n}),t.next=5,i.send(o);case 5:return u=t.sent,t.abrupt("return",u.as(Ru).pushTriggerOption);case 7:case"end":return t.stop()}}),r,this)})))}},{key:"getPushTemplate",value:function(){return b(this,void 0,void 0,t().mark((function e(){var n,r,a,s,i;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n=ns.of(this._iid),r=n.sdkState,a=n.requestQueue,s=new Lu({userId:r.userId}),e.next=4,a.send(s);case 4:return i=e.sent,e.abrupt("return",i.as(Du).name);case 6:case"end":return e.stop()}}),e,this)})))}},{key:"setPushTemplate",value:function(n){return b(this,void 0,void 0,t().mark((function r(){var a,s,i,o,u;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return Ua(D(e.PushTemplate,n)).throw(M.invalidParameters),a=ns.of(this._iid),s=a.sdkState,i=a.requestQueue,o=new Pu({userId:s.userId,templateName:n}),t.next=5,i.send(o);case 5:return u=t.sent,t.abrupt("return",u.as(Fu).name);case 7:case"end":return t.stop()}}),r,this)})))}},{key:"blockUser",value:function(e){return b(this,void 0,void 0,t().mark((function n(){var r,a,s,i;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return Ua(e instanceof La||L("string",e)).throw(M.invalidParameters),r=ns.of(this._iid),a=r.sdkState,s=r.requestQueue,i=new Nu({userId:a.userId,blockedUserId:e instanceof La?e.userId:e}),t.next=5,s.send(i);case 5:case"end":return t.stop()}}),n,this)})))}},{key:"blockUserWithUserId",value:function(e){return b(this,void 0,void 0,t().mark((function n(){return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.abrupt("return",this.blockUser(e));case 1:case"end":return t.stop()}}),n,this)})))}},{key:"unblockUser",value:function(e){return b(this,void 0,void 0,t().mark((function n(){var r,a,s,i;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return Ua(e instanceof La||L("string",e)).throw(M.invalidParameters),r=ns.of(this._iid),a=r.sdkState,s=r.requestQueue,i=new Au({userId:a.userId,unblockedUserId:e instanceof La?e.userId:e}),t.next=5,s.send(i);case 5:case"end":return t.stop()}}),n,this)})))}},{key:"unblockUserWithUserId",value:function(e){return b(this,void 0,void 0,t().mark((function n(){return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.abrupt("return",this.unblockUser(e));case 1:case"end":return t.stop()}}),n,this)})))}},{key:"getFriendChangeLogsByToken",value:function(e){return b(this,void 0,void 0,t().mark((function n(){var r,a,s,i,o,u,c;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return Ua(L("string",e)).throw(M.invalidParameters),r=ns.of(this._iid),a=r.sdkState,s=r.requestQueue,i=new Gu({userId:a.userId,token:e}),t.next=5,s.send(i);case 5:return o=t.sent,u=o.as(Hu),c=u.changelogs,t.abrupt("return",c);case 8:case"end":return t.stop()}}),n,this)})))}},{key:"getAllowFriendDiscovery",value:function(){return b(this,void 0,void 0,t().mark((function e(){var n,r,a,s,i,o,u;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n=ns.of(this._iid),r=n.sdkState,a=n.requestQueue,s=new Ku({userId:r.userId}),e.next=4,a.send(s);case 4:return i=e.sent,o=i.as(Wu),u=o.allowFriendDiscovery,e.abrupt("return",u);case 7:case"end":return e.stop()}}),e,this)})))}},{key:"setAllowFriendDiscovery",value:function(e){return b(this,void 0,void 0,t().mark((function n(){var r,a,s,i;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return Ua(L("boolean",e)).throw(M.invalidParameters),r=ns.of(this._iid),a=r.sdkState,s=r.requestQueue,i=new Yu({userId:a.userId,allowFriendDiscovery:e}),t.next=5,s.send(i);case 5:return t.abrupt("return",e);case 6:case"end":return t.stop()}}),n,this)})))}},{key:"uploadFriendDiscoveries",value:function(e){return b(this,void 0,void 0,t().mark((function n(){var r,a,s,i,o,u,c;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return r=ns.of(this._iid),a=r.sdkState,s=r.requestQueue,i=new qu({userId:a.userId,discoveries:e}),t.next=4,s.send(i);case 4:return o=t.sent,u=o.as(ju),c=u.friendDiscoveryRequestId,t.abrupt("return",c);case 7:case"end":return t.stop()}}),n,this)})))}},{key:"deleteFriendDiscovery",value:function(e){return b(this,void 0,void 0,t().mark((function n(){return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.abrupt("return",this.deleteFriendDiscoveries([e]));case 1:case"end":return t.stop()}}),n,this)})))}},{key:"deleteFriendDiscoveries",value:function(e){return b(this,void 0,void 0,t().mark((function n(){var r,a,s,i;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return Ua(F("string",e)).throw(M.invalidParameters),r=ns.of(this._iid),a=r.sdkState,s=r.requestQueue,i=new zu({userId:a.userId,discoveryKeys:e}),t.next=5,s.send(i);case 5:case"end":return t.stop()}}),n,this)})))}},{key:"addFriends",value:function(e){return b(this,void 0,void 0,t().mark((function n(){var r,a,s,i,o,u,c;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return Ua(F("string",e)).throw(M.invalidParameters),r=ns.of(this._iid),a=r.sdkState,s=r.requestQueue,i=new Vu({userId:a.userId,userIds:e}),t.next=5,s.send(i);case 5:return o=t.sent,u=o.as(Bu),c=u.users,t.abrupt("return",c);case 8:case"end":return t.stop()}}),n,this)})))}},{key:"deleteFriend",value:function(e){return b(this,void 0,void 0,t().mark((function n(){return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.abrupt("return",this.deleteFriends([e]));case 1:case"end":return t.stop()}}),n,this)})))}},{key:"deleteFriends",value:function(e){return b(this,void 0,void 0,t().mark((function n(){var r,a,s,i;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return Ua(F("string",e)).throw(M.invalidParameters),r=ns.of(this._iid),a=r.sdkState,s=r.requestQueue,i=new Qu({userId:a.userId,userIds:e}),t.next=5,s.send(i);case 5:case"end":return t.stop()}}),n,this)})))}},{key:"getAllEmoji",value:function(){return b(this,void 0,void 0,t().mark((function e(){var n,r,a,s,i,o;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n=ns.of(this._iid),r=n.requestQueue,a=new $u,e.next=4,r.send(a);case 4:return s=e.sent,i=s.as(ec),o=i.emojiContainer,e.abrupt("return",o);case 7:case"end":return e.stop()}}),e,this)})))}},{key:"getEmojiCategory",value:function(e){return b(this,void 0,void 0,t().mark((function n(){var r,a,s,i,o,u;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return r=ns.of(this._iid),a=r.requestQueue,s=new tc({categoryId:e}),t.next=4,a.send(s);case 4:return i=t.sent,o=i.as(nc),u=o.emojiCategory,t.abrupt("return",u);case 7:case"end":return t.stop()}}),n,this)})))}},{key:"getEmoji",value:function(e){return b(this,void 0,void 0,t().mark((function n(){var r,a,s,i,o,u;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return r=ns.of(this._iid),a=r.requestQueue,s=new rc({key:e}),t.next=4,a.send(s);case 4:return i=t.sent,o=i.as(ac),u=o.emoji,t.abrupt("return",u);case 7:case"end":return t.stop()}}),n,this)})))}}],[{key:"init",value:function(e){var t=e.appId,r=e.appVersion,a=void 0===r?null:r,s=e.modules,i=void 0===s?[]:s,o=e.options,u=void 0===o?new q:o,c=e.debugMode,l=void 0!==c&&c,h=e.customApiHost,d=e.customWebSocketHost,f=e.newInstance,p=void 0!==f&&f,v=e.logLevel,m=e.localCacheEnabled,g=void 0!==m&&m,y=e.localCacheConfig,k=void 0===y?new K:y,b=e.localCacheEncryption,E=e.useAsyncStorageStore,w=void 0===E?null:E,C=e.appStateToggleEnabled,x=void 0===C||C;if(!Vh||p){var T="su-".concat(Y()),S=null!=b?b:{encrypt:function(e){return e},decrypt:function(e){return e}},I=new $c({encryption:S});l||(I=ue()?w?new nl({AsyncStorage:w,encryption:S}):new $c({encryption:S}):new tl({encryption:S})),new ns(T,{appId:t,appVersion:a,options:u,apiHost:null!=h?h:"https://api-".concat(t,".sendbird.com"),websocketHost:null!=d?d:"wss://ws-".concat(t,".sendbird.com"),store:I,encryption:S,logLevel:v,localCacheEnabled:g,localCacheConfig:k,debugMode:l,appStateToggleEnabled:x});var N=[new Mi,new no],A=new n(T,u,[].concat(_(i),N));return Vh||(Vh=A),A}return Vh}},{key:"instance",get:function(){return Vh}},{key:"version",get:function(){return w}}]),n}();e.MemberState=void 0,(Il=e.MemberState||(e.MemberState={})).NONE="none",Il.JOINED="joined",Il.INVITED="invited",Il.LEFT="left";var Qh,Kh,Wh,Yh,Zh,Jh,Xh,$h,ed=function(t){i(a,t);var n=f(a);function a(t,s){var i;return r(this,a),(i=n.call(this,t,s)).state=null,i.role=null,i.isMuted=!1,i.isBlockedByMe=!1,i.isBlockingMe=!1,i.state=D(e.MemberState,s.state)?s.state:null,i.role=D(e.Role,s.role)?s.role:null,s.hasOwnProperty("is_muted")&&(i.isMuted=s.is_muted),s.hasOwnProperty("is_blocked_by_me")&&(i.isBlockedByMe=s.is_blocked_by_me),s.hasOwnProperty("is_blocking_me")&&(i.isBlockingMe=s.is_blocking_me),i}return s(a,null,[{key:"payloadify",value:function(e){return e?ee(Object.assign(Object.assign({},p(o(a),"payloadify",this).call(this,e)),{state:e.state,role:e.role,is_muted:e.isMuted,is_blocked_by_me:e.isBlockedByMe,is_blocking_me:e.isBlockingMe})):null}}]),a}(hl),td=function(t){i(a,t);var n=f(a);function a(t,s){var i,o,u;return r(this,a),(i=n.call(this,t)).channelUrl=null!==(o=s.channel_url)&&void 0!==o?o:"",i.channelType=null!==(u=s.channel_type)&&void 0!==u?u:e.ChannelType.GROUP,i.reader=new La(i._iid,s.user),i.readAt=s.ts,i}return s(a)}(Ca);e.PublicChannelFilter=void 0,(Qh=e.PublicChannelFilter||(e.PublicChannelFilter={})).ALL="all",Qh.PUBLIC="public",Qh.PRIVATE="private",e.MyMemberStateFilter=void 0,(Kh=e.MyMemberStateFilter||(e.MyMemberStateFilter={})).ALL="all",Kh.JOINED="joined_only",Kh.INVITED="invited_only",Kh.INVITED_BY_FRIEND="invited_by_friend",Kh.INVITED_BY_NON_FRIEND="invited_by_non_friend",e.SuperChannelFilter=void 0,(Wh=e.SuperChannelFilter||(e.SuperChannelFilter={})).ALL="all",Wh.SUPER="super",Wh.NON_SUPER="nonsuper",Wh.BROADCAST_ONLY="broadcast_only",Wh.EXCLUSIVE_ONLY="exclusive_only",e.UnreadChannelFilter=void 0,(Yh=e.UnreadChannelFilter||(e.UnreadChannelFilter={})).ALL="all",Yh.UNREAD_MESSAGE="unread_message",e.HiddenChannelFilter=void 0,(Zh=e.HiddenChannelFilter||(e.HiddenChannelFilter={})).ALL="all",Zh.UNHIDDEN="unhidden_only",Zh.HIDDEN="hidden_only",Zh.HIDDEN_ALLOW_AUTO_UNHIDE="hidden_allow_auto_unhide",Zh.HIDDEN_PREVENT_AUTO_UNHIDE="hidden_prevent_auto_unhide",e.OperatorFilter=void 0,(Jh=e.OperatorFilter||(e.OperatorFilter={})).ALL="all",Jh.OPERATOR="operator",Jh.NONOPERATOR="nonoperator",e.QueryType=void 0,(Xh=e.QueryType||(e.QueryType={})).AND="AND",Xh.OR="OR",e.GroupChannelSearchField=void 0,($h=e.GroupChannelSearchField||(e.GroupChannelSearchField={})).MEMBER_NICKNAME="member_nickname",$h.CHANNEL_NAME="channel_name";var nd,rd=function(){function t(){r(this,t),this._searchFilter=null,this._userIdsFilter=null,this.includeEmpty=!1,this.nicknameContainsFilter=null,this.nicknameStartsWithFilter=null,this.nicknameExactMatchFilter=null,this.channelNameContainsFilter="",this.myMemberStateFilter=e.MyMemberStateFilter.ALL,this.customTypesFilter=null,this.channelUrlsFilter=null,this.superChannelFilter=e.SuperChannelFilter.ALL,this.publicChannelFilter=e.PublicChannelFilter.ALL,this.customTypeStartsWithFilter=null,this.unreadChannelFilter=e.UnreadChannelFilter.ALL,this.hiddenChannelFilter=e.HiddenChannelFilter.UNHIDDEN,this.includeFrozen=!0}return s(t,[{key:"_isFriend",value:function(e){return!!e.friendDiscoveryKey||!!e.friendName}},{key:"searchFilter",get:function(){return this._searchFilter}},{key:"setSearchFilter",value:function(e,t){Array.isArray(e)&&0!==e.length&&"string"==typeof t&&t&&(this._searchFilter={query:t,fields:e})}},{key:"userIdsFilter",get:function(){return this._userIdsFilter}},{key:"setUserIdsFilter",value:function(t,n){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:e.QueryType.AND;this._userIdsFilter={userIds:t,includeMode:n,queryType:r}}},{key:"clone",value:function(){var e=new t;this.searchFilter&&e.setSearchFilter(this.searchFilter.fields,this.searchFilter.query),this.userIdsFilter&&e.setUserIdsFilter(this.userIdsFilter.userIds,this.userIdsFilter.includeMode,this.userIdsFilter.queryType);var n=JSON.parse(JSON.stringify(this));return Object.keys(n).forEach((function(t){e[t]=n[t]})),e}},{key:"match",value:function(t,n){if(this._searchFilter){var r=this._searchFilter,a=r.query,s=r.fields;if(a&&s&&s.length>0&&!s.some((function(n){switch(n){case e.GroupChannelSearchField.CHANNEL_NAME:return t.name.toLowerCase().includes(a.toLowerCase());case e.GroupChannelSearchField.MEMBER_NICKNAME:return t.members.some((function(e){return e.nickname.toLowerCase().includes(a.toLowerCase())}));default:return!0}})))return!1}if(this._userIdsFilter){var i=this._userIdsFilter,o=i.userIds,u=i.includeMode,c=i.queryType,l=t.members.map((function(e){return e.userId}));if(u){if(o.length>0)switch(c){case e.QueryType.AND:if(o.some((function(e){return!l.includes(e)})))return!1;break;case e.QueryType.OR:if(o.every((function(e){return!l.includes(e)})))return!1}}else{if(o.includes(n)||o.push(n),t.members.length>o.length)return!1;if(!function(e,t){if(e===t)return!0;if(null==e||null==t)return!1;if(e.length!==t.length)return!1;for(var n=_(e).sort(),r=_(t).sort(),a=0;a0&&!this.customTypesFilter.includes(t.customType))return!1;if(this.customTypeStartsWithFilter&&!new RegExp("^".concat(this.customTypeStartsWithFilter)).test(t.customType))return!1;if(this.channelNameContainsFilter&&!t.name.toLowerCase().includes(this.channelNameContainsFilter.toLowerCase()))return!1;if(this.nicknameContainsFilter){var h=this.nicknameContainsFilter.toLowerCase();if(!t.members.some((function(e){return e.userId!==n&&e.nickname.toLowerCase().includes(h)})))return!1}if(this.nicknameStartsWithFilter){var d=this.nicknameStartsWithFilter.toLowerCase();if(!t.members.some((function(e){return e.userId!==n&&e.nickname.toLowerCase().startsWith(d)})))return!1}if(this.nicknameExactMatchFilter){var f=this.nicknameExactMatchFilter.toLowerCase();if(!t.members.some((function(e){return e.userId!==n&&e.nickname.toLowerCase()!=f})))return!1}if(this.channelUrlsFilter&&this.channelUrlsFilter.length>0&&!this.channelUrlsFilter.includes(t.url))return!1;if(this.myMemberStateFilter)switch(this.myMemberStateFilter){case e.MyMemberStateFilter.JOINED:if("joined"!==t.myMemberState)return!1;break;case e.MyMemberStateFilter.INVITED:if("invited"!==t.myMemberState)return!1;break;case e.MyMemberStateFilter.INVITED_BY_FRIEND:if("invited"!==t.myMemberState||!this._isFriend(t.inviter))return!1;break;case e.MyMemberStateFilter.INVITED_BY_NON_FRIEND:if("invited"!==t.myMemberState||this._isFriend(t.inviter))return!1}if(this.hiddenChannelFilter)switch(this.hiddenChannelFilter){case e.HiddenChannelFilter.UNHIDDEN:if(t.isHidden||"unhidden"!==t.hiddenState)return!1;break;case e.HiddenChannelFilter.HIDDEN:if(!t.isHidden)return!1;break;case e.HiddenChannelFilter.HIDDEN_ALLOW_AUTO_UNHIDE:if(!t.isHidden||"hidden_allow_auto_unhide"!==t.hiddenState)return!1;break;case e.HiddenChannelFilter.HIDDEN_PREVENT_AUTO_UNHIDE:if(!t.isHidden||"hidden_prevent_auto_unhide"!==t.hiddenState)return!1}if(this.unreadChannelFilter&&this.unreadChannelFilter===e.UnreadChannelFilter.UNREAD_MESSAGE)if(0===t.unreadMessageCount)return!1;if(this.publicChannelFilter)switch(this.publicChannelFilter){case e.PublicChannelFilter.PUBLIC:if(!t.isPublic)return!1;break;case e.PublicChannelFilter.PRIVATE:if(t.isPublic)return!1}if(this.superChannelFilter)switch(this.superChannelFilter){case e.SuperChannelFilter.SUPER:if(!t.isSuper)return!1;break;case e.SuperChannelFilter.NON_SUPER:if(t.isSuper)return!1}return!0}}]),t}(),ad=function(n){i(o,n);var a=f(o);function o(e,t){var n,s=t.sdkState,i=t.cacheContext;return r(this,o),(n=a.call(this,e))._channels=new Map,n._sdkState=s,n._cacheContext=i,n}return s(o,[{key:"collection",get:function(){var e=this._cacheContext.nestdb;return e?e.collection(uo):null}},{key:"localCacheEnabled",get:function(){return this._cacheContext.localCacheEnabled&&!!this.collection}},{key:"_serialize",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0;return Object.assign(Object.assign({},e.serialize()),{lastMessageUpdatedAt:e.lastMessage?e.lastMessage.createdAt:0,syncIndex:t})}},{key:"_deserialize",value:function(e){return wf.of(this._iid).buildGroupChannelFromSerializedData(e)}},{key:"channels",get:function(){return _(this._channels.values())}},{key:"isCachedInMemory",value:function(e){return this._channels.has(e)}},{key:"filterOffsetChanged",value:function(e){var t=this;return e.filter((function(e){if(t._channels.has(e.url))return t._channels.get(e.url).messageOffsetTimestamp0)return!1;if(f&&f===t.url)return!1;break;case e.GroupChannelListOrder.CHRONOLOGICAL:if(!o&&t.createdAt>r||o&&t.createdAtr||o&&t.lastMessageUpdatedAt0)){t.next=76;break}return t.next=76,this.upsert(s);case 76:case"end":return t.stop()}}),a,this,[[3,30,33,36],[8,20,23,26],[40,67,70,73],[45,57,60,63]])})))}},{key:"block",value:function(e,n){return b(this,void 0,void 0,t().mark((function r(){return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,this._setBlockStateOfAllChannels(e,n,!0);case 2:case"end":return t.stop()}}),r,this)})))}},{key:"unblock",value:function(e,n){return b(this,void 0,void 0,t().mark((function r(){return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,this._setBlockStateOfAllChannels(e,n,!1);case 2:case"end":return t.stop()}}),r,this)})))}},{key:"markAsRead",value:function(e){var n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:_(this._channels.keys());return b(this,void 0,void 0,t().mark((function r(){var a,s,i,o,u;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:a=[],s=y(n),t.prev=2,s.s();case 4:if((i=s.n()).done){t.next=12;break}return o=i.value,t.next=8,this.get(o);case 8:(u=t.sent)._updateUnreadMemberState(this._sdkState.userId,e)&&(u._updateUnreadCount(0,0),a.push(u));case 10:t.next=4;break;case 12:t.next=17;break;case 14:t.prev=14,t.t0=t.catch(2),s.e(t.t0);case 17:return t.prev=17,s.f(),t.finish(17);case 20:if(!(a.length>0)){t.next=23;break}return t.next=23,this.upsert(a);case 23:case"end":return t.stop()}}),r,this,[[2,14,17,20]])})))}}]),o}(Ca);!function(e){e[e.NONE=0]="NONE",e[e.CHANNEL_ENTER=10102]="CHANNEL_ENTER",e[e.CHANNEL_EXIT=10103]="CHANNEL_EXIT",e[e.USER_CHANNEL_MUTE=10201]="USER_CHANNEL_MUTE",e[e.USER_CHANNEL_UNMUTE=10200]="USER_CHANNEL_UNMUTE",e[e.USER_CHANNEL_BAN=10601]="USER_CHANNEL_BAN",e[e.USER_CHANNEL_UNBAN=10600]="USER_CHANNEL_UNBAN",e[e.CHANNEL_FREEZE=10701]="CHANNEL_FREEZE",e[e.CHANNEL_UNFREEZE=10700]="CHANNEL_UNFREEZE",e[e.TYPING_START=10900]="TYPING_START",e[e.TYPING_END=10901]="TYPING_END",e[e.CHANNEL_JOIN=1e4]="CHANNEL_JOIN",e[e.CHANNEL_LEAVE=10001]="CHANNEL_LEAVE",e[e.CHANNEL_OPERATOR_UPDATE=10002]="CHANNEL_OPERATOR_UPDATE",e[e.CHANNEL_INVITE=10020]="CHANNEL_INVITE",e[e.CHANNEL_ACCEPT_INVITE=10021]="CHANNEL_ACCEPT_INVITE",e[e.CHANNEL_DECLINE_INVITE=10022]="CHANNEL_DECLINE_INVITE",e[e.CHANNEL_PROP_CHANGED=11e3]="CHANNEL_PROP_CHANGED",e[e.CHANNEL_DELETED=12e3]="CHANNEL_DELETED",e[e.CHANNEL_META_DATA_CHANGED=11100]="CHANNEL_META_DATA_CHANGED",e[e.CHANNEL_META_COUNTERS_CHANGED=11200]="CHANNEL_META_COUNTERS_CHANGED",e[e.CHANNEL_HIDE=13e3]="CHANNEL_HIDE",e[e.CHANNEL_UNHIDE=13001]="CHANNEL_UNHIDE",e[e.PINNED_MESSAGE_CHANGED=11300]="PINNED_MESSAGE_CHANGED"}(nd||(nd={}));var sd,id=function(){function t(e){r(this,t),this.channelUrl=e.channel_url,this.channelType=e.channel_type,this.category=e.cat,this.data=e.data,this.ts=e.ts}return s(t,[{key:"isGroupChannelEvent",get:function(){return this.channelType===e.ChannelType.GROUP}},{key:"isOpenChannelEvent",get:function(){return this.channelType===e.ChannelType.OPEN}}]),t}(),od={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},ud=function(e){return F("string",e.invitedUserIds,!0)&&L("string",e.channelUrl,!0)&&L("string",e.coverUrl,!0)&&(H(e.coverImage)||L("string",e.coverImage)||null===e.coverImage)&&L("boolean",e.isDistinct,!0)&&L("boolean",e.isSuper,!0)&&L("boolean",e.isBroadcast,!0)&&L("boolean",e.isExclusive,!0)&&L("boolean",e.isPublic,!0)&&L("boolean",e.isStrict,!0)&&L("boolean",e.isDiscoverable,!0)&&L("boolean",e.isEphemeral,!0)&&L("string",e.accessCode,!0)&&L("string",e.name,!0)&&L("string",e.data,!0)&&L("string",e.customType,!0)&&F("string",e.operatorUserIds,!0)&&L("number",e.messageSurvivalSeconds,!0)},cd={customTypes:null,includeEmpty:!1,includeFrozen:!0},ld=function(e){return F("string",e.customTypes,!0)&&L("boolean",e.includeEmpty)&&L("boolean",e.includeFrozen)},hd={myMemberStateFilter:e.MyMemberStateFilter.ALL},dd=function(t){return D(e.MyMemberStateFilter,t.myMemberStateFilter)};e.UnreadItemKey=void 0,(sd=e.UnreadItemKey||(e.UnreadItemKey={})).GROUP_CHANNEL_UNREAD_MENTION_COUNT="group_channel_unread_mention_count",sd.NONSUPER_UNREAD_MENTION_COUNT="non_super_group_channel_unread_mention_count",sd.SUPER_UNREAD_MENTION_COUNT="super_group_channel_unread_mention_count",sd.GROUP_CHANNEL_UNREAD_MESSAGE_COUNT="group_channel_unread_message_count",sd.NONSUPER_UNREAD_MESSAGE_COUNT="non_super_group_channel_unread_message_count",sd.SUPER_UNREAD_MESSAGE_COUNT="super_group_channel_unread_message_count",sd.GROUP_CHANNEL_INVITATION_COUNT="group_channel_invitation_count",sd.NONSUPER_INVITATION_COUNT="non_super_group_channel_invitation_count",sd.SUPER_INVITATION_COUNT="super_group_channel_invitation_count";var fd,pd={keys:[]},vd=function(t){return F(e.UnreadItemKey,t.keys)},_d={channelCustomTypesFilter:null,superChannelFilter:e.SuperChannelFilter.ALL},md=function(t){return F("string",t.channelCustomTypesFilter,!0)&&D(e.SuperChannelFilter,t.superChannelFilter)},gd={channelUrl:null,scheduledStatus:null,messageTypeFilter:e.MessageTypeFilter.ALL},yd=function(t){return L("string",t.channelUrl,!0)&&F(e.ScheduledStatus,t.scheduledStatus,!0)&&D(e.MessageTypeFilter,t.messageTypeFilter)},kd=function(){function e(n){var a=this,s=n.groupChannelCache,i=n.messageCache,o=n.unsentMessageCache,u=n.dispatcher;r(this,e),this._observers=new Map,u.on((function(e){return b(a,void 0,void 0,t().mark((function n(){var r,a,u,c,l,h,d,f,p,v,_=this;return t().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:if(!(e instanceof ru)){n.next=26;break}r=e.channels,a=e.source,u=e.data,c=r.filter((function(e){return e instanceof Rp})),l=s.filterOffsetChanged(c),h=y(l),n.prev=5,h.s();case 7:if((d=h.n()).done){n.next=13;break}return f=d.value,n.next=11,i.removeUnderOffset(f.url,f.messageOffsetTimestamp);case 11:n.next=7;break;case 13:n.next=18;break;case 15:n.prev=15,n.t0=n.catch(5),h.e(n.t0);case 18:return n.prev=18,h.f(),n.finish(18);case 21:return n.next=23,s.upsert(c);case 23:this._broadcastUpdateEvent(c,a,u),n.next=38;break;case 26:if(!(e instanceof au)){n.next=35;break}return p=e.channelUrls,v=e.source,n.next=30,s.remove(p);case 30:return n.next=32,ca((function(){return b(_,void 0,void 0,t().mark((function e(){var n,r,a;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:n=y(p),e.prev=1,n.s();case 3:if((r=n.n()).done){e.next=11;break}return a=r.value,e.next=7,i.removeMessagesOfChannel(a);case 7:return e.next=9,o.removeMessagesOfChannel(a);case 9:e.next=3;break;case 11:e.next=16;break;case 13:e.prev=13,e.t0=e.catch(1),n.e(e.t0);case 16:return e.prev=16,n.f(),e.finish(16);case 19:case"end":return e.stop()}}),e,null,[[1,13,16,19]])})))}));case 32:this._broadcastRemoveEvent(p,v),n.next=38;break;case 35:if(!(e instanceof eu)){n.next=38;break}return n.next=38,s.fetch({token:Number.MAX_SAFE_INTEGER,limit:Number.MAX_SAFE_INTEGER});case 38:case"end":return n.stop()}}),n,this,[[5,15,18,21]])})))}))}return s(e,[{key:"_broadcastUpdateEvent",value:function(e,t,n){var r,a=y(this._observers.values());try{for(a.s();!(r=a.n()).done;){r.value.onUpdate(e,t,n)}}catch(e){a.e(e)}finally{a.f()}}},{key:"_broadcastRemoveEvent",value:function(e,t){var n,r=y(this._observers.values());try{for(r.s();!(n=r.n()).done;){n.value.onRemove(e,t)}}catch(e){r.e(e)}finally{r.f()}}},{key:"subscribe",value:function(e,t){this._observers.set(e,t)}},{key:"unsubscribe",value:function(e){this._observers.delete(e)}},{key:"unsubscribeAll",value:function(){this._observers.clear()}}]),e}(),bd=function(){function e(n){var a=this,s=n.cacheContext,i=n.messageCache,o=n.unsentMessageCache,u=n.dispatcher,c=n.logger;r(this,e),this._cacheContext=null,this._observers=new Map,this._logger=null,this._cacheContext=s,this._logger=c,u.on((function(e){return b(a,void 0,void 0,t().mark((function n(){var r,a,s,u,c,l,h,d,f,p,v,_,m,g,y,k,E,w,C=this;return t().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:if(!(e instanceof ei)){n.next=14;break}if(r=e.messages,a=e.source,s=r.filter((function(e){return e.messageId>0})),u=r.filter((function(e){return 0===e.messageId})),!(s.length>0)){n.next=8;break}return n.next=7,ca((function(){return b(C,void 0,void 0,t().mark((function e(){return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,i.upsert(s);case 2:return e.next=4,o.remove(s.map((function(e){return e instanceof Es?e.reqId:null})).filter((function(e){return null!==e})));case 4:case"end":return e.stop()}}),e)})))}));case 7:this._broadcastUpdateEvent(s,a);case 8:if(!(u.length>0)){n.next=12;break}return n.next=11,ca((function(){return b(C,void 0,void 0,t().mark((function e(){return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,o.upsert(u);case 2:case"end":return e.stop()}}),e)})))}));case 11:this._broadcastUpdateEvent(u,a);case 12:n.next=61;break;case 14:if(!(e instanceof ti)){n.next=21;break}return c=e.messageIds,l=e.source,n.next=18,ca((function(){return b(C,void 0,void 0,t().mark((function e(){return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,i.remove(c);case 2:case"end":return e.stop()}}),e)})))}));case 18:this._broadcastRemoveEvent(c,l),n.next=61;break;case 21:if(!(e instanceof ni)){n.next=28;break}return h=e.reqId,d=e.source,n.next=25,ca((function(){return b(C,void 0,void 0,t().mark((function e(){return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,o.remove([h]);case 2:case"end":return e.stop()}}),e)})))}));case 25:this._broadcastRemoveUnsentEvent(h,d),n.next=61;break;case 28:if(!(e instanceof ri)){n.next=41;break}if(f=e.polls,p=e.source,!this._cacheContext.localCacheEnabled){n.next=38;break}return v=f.map((function(e){return e.messageId})),n.next=34,Promise.all(v.map((function(e){return i.get(e)})));case 34:return _=n.sent.filter((function(e){return e})),_.length>0&&f.forEach((function(e){var t=_.find((function(t){return t.messageId===e.messageId}));t&&t.applyPoll(e)})),n.next=38,ca((function(){return b(C,void 0,void 0,t().mark((function e(){return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,i.upsert(_);case 2:return e.abrupt("return",e.sent);case 3:case"end":return e.stop()}}),e)})))}));case 38:this._broadcastPollChangeLogEvent(f,p),n.next=61;break;case 41:if(!(e instanceof ai)){n.next=52;break}return m=e.event,g=e.source,n.next=45,i.get(m.messageId);case 45:if(!((y=n.sent)&&y.isUserMessage()&&y.poll&&y.poll.applyPollUpdateEvent(m))){n.next=49;break}return n.next=49,ca((function(){return b(C,void 0,void 0,t().mark((function e(){return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,i.upsert([y]);case 2:return e.abrupt("return",e.sent);case 3:case"end":return e.stop()}}),e)})))}));case 49:this._broadcastPollUpdateEvent(m,g),n.next=61;break;case 52:if(!(e instanceof si)){n.next=61;break}return k=e.event,E=e.source,n.next=56,i.get(k.messageId);case 56:if(!((w=n.sent)&&w.isUserMessage()&&w.poll&&w.poll.applyPollVoteEvent(k))){n.next=60;break}return n.next=60,ca((function(){return b(C,void 0,void 0,t().mark((function e(){return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,i.upsert([w]);case 2:return e.abrupt("return",e.sent);case 3:case"end":return e.stop()}}),e)})))}));case 60:this._broadcastPollVoteEvent(k,E);case 61:case"end":return n.stop()}}),n,this)})))}))}return s(e,[{key:"_broadcastUpdateEvent",value:function(e,t){var n,r=y(this._observers.values());try{for(r.s();!(n=r.n()).done;){n.value.onUpdate(e,t)}}catch(e){r.e(e)}finally{r.f()}}},{key:"_broadcastPollChangeLogEvent",value:function(e,t){var n,r=y(this._observers.values());try{for(r.s();!(n=r.n()).done;){n.value.onPollChangeLogUpdate(e,t)}}catch(e){r.e(e)}finally{r.f()}}},{key:"_broadcastPollUpdateEvent",value:function(e,t){var n,r=y(this._observers.values());try{for(r.s();!(n=r.n()).done;){n.value.onPollUpdate(e,t)}}catch(e){r.e(e)}finally{r.f()}}},{key:"_broadcastPollVoteEvent",value:function(e,t){var n,r=y(this._observers.values());try{for(r.s();!(n=r.n()).done;){n.value.onPollVote(e,t)}}catch(e){r.e(e)}finally{r.f()}}},{key:"_broadcastRemoveEvent",value:function(e,t){var n,r=y(this._observers.values());try{for(r.s();!(n=r.n()).done;){n.value.onRemove(e,t)}}catch(e){r.e(e)}finally{r.f()}}},{key:"_broadcastRemoveUnsentEvent",value:function(e,t){var n,r=y(this._observers.values());try{for(r.s();!(n=r.n()).done;){n.value.onRemoveUnsent(e,t)}}catch(e){r.e(e)}finally{r.f()}}},{key:"subscribe",value:function(e,t){this._observers.set(e,t)}},{key:"unsubscribe",value:function(e){this._observers.delete(e)}},{key:"unsubscribeAll",value:function(){this._observers.clear()}}]),e}(),Ed=function(e){i(n,e);var t=f(n);function n(e){var a,s=e.userId,i=e.ts,o=e.token,u=e.filter;r(this,n),a=t.call(this);var c=Object.assign(Object.assign({},cd),u),l=c.customTypes,h=c.includeEmpty,d=c.includeFrozen;return a.method=B.GET,a.path="".concat(qr,"/").concat(encodeURIComponent(s),"/my_group_channels/changelogs"),a.params=ee({show_delivery_receipt:!0,show_member:!0,show_read_receipt:!0,change_ts:i>0?i:null,token:o,custom_types:l,show_empty:h,show_frozen:d}),a}return s(n)}(ne),wd=function(e){i(n,e);var t=f(n);function n(e,a){var s;return r(this,n),(s=t.call(this,e,a)).updatedChannels=a.updated.map((function(t){return new Rp(e,t)})),s.deletedChannelUrls=a.deleted,s.hasMore=a.has_more,s.token=a.next,s}return s(n)}(re),Cd=function(e){i(n,e);var t=f(n);function n(e){var a,s=e.channelUrl,i=e.isInternalCall;return r(this,n),(a=t.call(this)).method=B.GET,a.path="".concat(i?Vr:zr,"/").concat(encodeURIComponent(s)),a.params={show_member:!0,show_read_receipt:!0,show_delivery_receipt:!0},a}return s(n)}(ne),xd=function(e){i(n,e);var t=f(n);function n(e,a){var s;return r(this,n),(s=t.call(this,e,a)).channel=null,s.channel=new Rp(e,a),s}return s(n)}(re),Td=function(e){i(n,e);var t=f(n);function n(e){var a;r(this,n);var s=e.userId,i=e.token,o=e.limit,u=e.order,c=e.includeEmpty,l=e.myMemberStateFilter,h=e.superChannelFilter,d=e.publicChannelFilter,f=e.unreadChannelFilter,p=e.nicknameContainsFilter,v=e.nicknameStartsWithFilter,_=e.nicknameExactMatchFilter,m=e.channelNameContainsFilter,g=e.channelUrlsFilter,y=e.customTypesFilter,k=e.customTypeStartsWithFilter,b=e.hiddenChannelFilter,E=e.metadataOrderKeyFilter,w=e.metadataKey,C=e.metadataValues,x=e.metadataValueStartsWith,T=e.includeFrozen,S=e.includeMetaData,I=e.searchFilter,N=e.userIdsFilter;return(a=t.call(this)).method=B.GET,a.path="".concat(qr,"/").concat(encodeURIComponent(s),"/my_group_channels"),a.params=ee({token:i,limit:o,order:u,show_member:!0,show_read_receipt:!0,show_delivery_receipt:!0,show_empty:c,member_state_filter:l,super_mode:h,public_mode:d,unread_filter:f,members_nickname_contains:p,members_nickname_startswith:v,members_nickname:_,name_contains:m,channel_urls:g,custom_types:y,custom_type_startswith:k,hidden_mode:b,metadata_order_key:E,metadata_key:w,metadata_values:C,metadata_value_startswith:x,show_frozen:T,show_metadata:S}),I&&I.query&&I.fields&&(a.params.search_query=I.query,a.params.search_fields=I.fields),N&&N.userIds&&N.userIds.length>0&&(N.includeMode?(a.params.members_include_in=N.userIds,a.params.query_type=N.queryType.toUpperCase()):a.params.members_exactly_in=N.userIds),a}return s(n)}(ne),Sd=function(e){i(n,e);var t=f(n);function n(e,a){var s;r(this,n),(s=t.call(this,e,a)).token=null,s.channels=[],s.ts=null;var i=a.next,o=a.channels,u=a.ts;return s.token=i,o&&o.length>0&&(s.channels=o.map((function(t){return t.ts=u,new Rp(e,t)}))),s.ts=null!=u?u:null,s}return s(n)}(re),Id=function(t){i(a,t);var n=f(a);function a(t){var s,i=t.userId,o=t.filter;r(this,a),s=n.call(this);var u=o.myMemberStateFilter;return s.method=B.GET,s.path="".concat(qr,"/").concat(encodeURIComponent(i),"/group_channel_count"),s.params={state:null!=u?u:e.MyMemberStateFilter.ALL},s}return s(a)}(ne),Nd=function(e){i(n,e);var t=f(n);function n(e,a){var s;return r(this,n),(s=t.call(this,e,a)).groupChannelCount=a.group_channel_count,s}return s(n)}(re),Ad=function(e){i(n,e);var t=f(n);function n(e){var a,s=e.userId,i=e.filter;r(this,n),a=t.call(this);var o=i.keys;return a.method=B.GET,a.path="".concat(qr,"/").concat(encodeURIComponent(s),"/unread_item_count"),a.params={item_keys:o},a}return s(n)}(ne),Md=function(t){i(a,t);var n=f(a);function a(t,s){var i;return r(this,a),i=n.call(this,t,s),"number"==typeof s[e.UnreadItemKey.GROUP_CHANNEL_UNREAD_MENTION_COUNT]&&(i.groupChannelUnreadMentionCount=s[e.UnreadItemKey.GROUP_CHANNEL_UNREAD_MENTION_COUNT]),"number"==typeof s[e.UnreadItemKey.GROUP_CHANNEL_UNREAD_MESSAGE_COUNT]&&(i.groupChannelUnreadMessageCount=s[e.UnreadItemKey.GROUP_CHANNEL_UNREAD_MESSAGE_COUNT]),"number"==typeof s[e.UnreadItemKey.GROUP_CHANNEL_INVITATION_COUNT]&&(i.groupChannelInvitationCount=s[e.UnreadItemKey.GROUP_CHANNEL_INVITATION_COUNT]),"number"==typeof s[e.UnreadItemKey.SUPER_UNREAD_MENTION_COUNT]&&(i.superGroupChannelUnreadMentionCount=s[e.UnreadItemKey.SUPER_UNREAD_MENTION_COUNT]),"number"==typeof s[e.UnreadItemKey.SUPER_UNREAD_MESSAGE_COUNT]&&(i.superGroupChannelUnreadMessageCount=s[e.UnreadItemKey.SUPER_UNREAD_MESSAGE_COUNT]),"number"==typeof s[e.UnreadItemKey.SUPER_INVITATION_COUNT]&&(i.superGroupChannelInvitationCount=s[e.UnreadItemKey.SUPER_INVITATION_COUNT]),"number"==typeof s[e.UnreadItemKey.NONSUPER_UNREAD_MENTION_COUNT]&&(i.nonSuperGroupChannelUnreadMentionCount=s[e.UnreadItemKey.NONSUPER_UNREAD_MENTION_COUNT]),"number"==typeof s[e.UnreadItemKey.NONSUPER_UNREAD_MESSAGE_COUNT]&&(i.nonSuperGroupChannelUnreadMessageCount=s[e.UnreadItemKey.NONSUPER_UNREAD_MESSAGE_COUNT]),"number"==typeof s[e.UnreadItemKey.NONSUPER_INVITATION_COUNT]&&(i.nonSuperGroupChannelInvitationCount=s[e.UnreadItemKey.NONSUPER_INVITATION_COUNT]),i}return s(a)}(re),Od=function(e){i(n,e);var t=f(n);function n(e){var a,s=e.userId;return r(this,n),(a=t.call(this)).method=B.GET,a.path="".concat(qr,"/").concat(encodeURIComponent(s),"/unread_channel_count"),a}return s(n)}(ne),Ud=function(e){i(n,e);var t=f(n);function n(e,a){var s;return r(this,n),(s=t.call(this,e,a)).unreadCount=a.unread_count,s}return s(n)}(re),Rd=function(t){i(a,t);var n=f(a);function a(t){var s,i=t.userId,o=t.filter;r(this,a),s=n.call(this);var u=o.channelCustomTypesFilter,c=o.superChannelFilter;return s.method=B.GET,s.path="".concat(qr,"/").concat(encodeURIComponent(i),"/unread_message_count"),s.params={super_mode:null!=c?c:e.SuperChannelFilter.ALL,custom_types:u},s}return s(a)}(ne),Ld=function(e){i(n,e);var t=f(n);function n(e,a){var s;return r(this,n),(s=t.call(this,e,a)).unreadCount=a.unread_count,s}return s(n)}(re),Dd=function(e){i(n,e);var t=f(n);function n(e){var a,s=e.channelUrl,i=e.scheduledStatus,o=e.messageTypeFilter;return r(this,n),(a=t.call(this)).method=B.GET,a.path="".concat(Xr,"/count"),a.params={channel_url:s,status:Fd(i)},o&&(a.params.message_type=o),a}return s(n)}(ne),Pd=function(e){i(n,e);var t=f(n);function n(e,a){var s;return r(this,n),(s=t.call(this,e,a)).count=a.count,s}return s(n)}(re),Fd=function(t){if(t){var n=[];return t.forEach((function(t){switch(t){case e.ScheduledStatus.PENDING:n.push(hs.PENDING);break;case e.ScheduledStatus.SENT:n.push(hs.IN_QUEUE),n.push(hs.SENT);break;case e.ScheduledStatus.CANCELED:n.push(hs.CANCELED);break;case e.ScheduledStatus.FAILED:n.push(hs.FAILED)}})),n}},Gd=function(e){i(n,e);var t=f(n);function n(e){var a;r(this,n);var s=e.userId,i=e.channelUrl,o=e.coverUrl,u=e.coverImage,c=e.isDistinct,l=e.isSuper,h=e.isBroadcast,d=e.isPublic,f=e.isExclusive,p=e.isDiscoverable,v=e.isStrict,m=e.isEphemeral,g=e.accessCode,y=e.name,k=e.data,b=e.customType,E=e.messageSurvivalSeconds,w=e.invitedUserIds,C=e.operatorUserIds;return(a=t.call(this)).method=B.POST,a.path=zr,a.params=ee({user_ids:[s].concat(_(null!=w?w:[])).filter((function(e,t,n){return t===n.indexOf(e)})),channel_url:i,cover_url:o,cover_file:u,is_distinct:c,is_super:l,is_broadcast:h,is_exclusive:f,is_public:d,is_discoverable:p,strict:v,is_ephemeral:m,access_code:g,name:y,data:k,custom_type:b,operator_ids:C,message_survival_seconds:E}),a}return s(n)}(ne),Hd=function(e){i(n,e);var t=f(n);function n(e,a){var s;return r(this,n),(s=t.call(this,e,a)).channel=new Rp(e,a),s.isCreated=a.is_created,s}return s(n)}(re),qd=function(e){i(n,e);var t=f(n);function n(e){var a,s=e.userId,i=e.channelUrls;return r(this,n),(a=t.call(this)).method=B.PUT,a.path="".concat(qr,"/").concat(encodeURIComponent(s),"/mark_as_read_all"),a.params={channel_urls:i},a}return s(n)}(ne),jd=function(e){i(n,e);var t=f(n);function n(e,a,s){var i;return r(this,n),(i=t.call(this,e,"SYEV",s)).event=new id(s),i}return s(n)}(le),zd=function(e){i(n,e);var t=f(n);function n(e){var a;r(this,n);var s=e.channelUrl,i=e.userId,o=e.accessCode;return(a=t.call(this)).method=B.PUT,a.path="".concat(zr,"/").concat(encodeURIComponent(s),"/join"),a.params={user_id:i,access_code:o},a}return s(n)}(ne),Vd=function(e){i(n,e);var t=f(n);function n(e,a){var s;return r(this,n),(s=t.call(this,e,a)).channel=new Rp(e,a),s}return s(n)}(re),Bd=function(e){i(n,e);var t=f(n);function n(e,a,s){var i;r(this,n),i=t.call(this,e,a,s);var o=s.data,u=o.member_count,c=void 0===u?null:u,l=o.joined_member_count,h=void 0===l?null:l,d=o.users,f=void 0===d?null:d;return i.memberCount=c,i.joinedMemberCount=h,i.members=Array.isArray(f)?f.map((function(t){return new ed(e,t)})):[new ed(e,s.data)],i}return s(n)}(jd),Qd=function(e){i(n,e);var t=f(n);function n(e){var a;r(this,n);var s=e.channelUrl,i=e.userId,o=e.shouldRemoveOperatorStatus;return(a=t.call(this)).method=B.PUT,a.path="".concat(zr,"/").concat(encodeURIComponent(s),"/leave"),a.params={user_id:i,should_remove_operator_status:o},a}return s(n)}(ne),Kd=function(e){i(n,e);var t=f(n);function n(e,a,s){var i;r(this,n),i=t.call(this,e,a,s);var o=s.data,u=o.member_count,c=void 0===u?null:u,l=o.joined_member_count,h=void 0===l?null:l;return i.memberCount=c,i.joinedMemberCount=h,i.member=new ed(i._iid,s.data),i}return s(n)}(jd),Wd=function(e){i(n,e);var t=f(n);function n(e){var a;r(this,n);var s=e.channelUrl,i=e.userIds;return(a=t.call(this)).method=B.POST,a.path="".concat(zr,"/").concat(encodeURIComponent(s),"/invite"),a.params={user_ids:i},a}return s(n)}(ne),Yd=function(e){i(n,e);var t=f(n);function n(e,a){var s;return r(this,n),(s=t.call(this,e,a)).channel=new Rp(e,a),s}return s(n)}(re),Zd=function(e){i(n,e);var t=f(n);function n(e,a,s){var i;r(this,n),i=t.call(this,e,a,s);var o=s.data,u=o.member_count,c=void 0===u?null:u,l=o.joined_member_count,h=void 0===l?null:l,d=o.inviter,f=void 0===d?null:d,p=o.invitees,v=void 0===p?[]:p;return i.memberCount=c,i.joinedMemberCount=h,i.inviter=f?new La(e,f):null,i.invitees=v.map((function(t){return new ed(e,t)})),i}return s(n)}(jd),Jd=function(e){i(n,e);var t=f(n);function n(e){var a;r(this,n);var s=e.channelUrl,i=e.userId;return(a=t.call(this)).method=B.PUT,a.path="".concat(zr,"/").concat(encodeURIComponent(s),"/decline"),a.params={user_id:i},a}return s(n)}(ne),Xd=function(e){i(n,e);var t=f(n);function n(e,a,s){var i;r(this,n),i=t.call(this,e,a,s);var o=s.data,u=o.member_count,c=void 0===u?null:u,l=o.joined_member_count,h=void 0===l?null:l,d=o.inviter,f=void 0===d?null:d,p=o.invitee,v=void 0===p?null:p;return i.memberCount=c,i.joinedMemberCount=h,i.inviter=f?new La(e,f):null,i.invitee=v?new ed(e,v):null,i}return s(n)}(jd),$d=function(e){i(n,e);var t=f(n);function n(e){var a=e.channelUrl;return r(this,n),t.call(this,{code:"READ",ackRequired:!0,payload:{channel_url:a}})}return s(n)}(Mr),ef=function(e){i(n,e);var t=f(n);function n(e,a,s){var i;return r(this,n),(i=t.call(this,e,"READ",s)).readStatus=new td(e,s),i}return s(n)}(le),tf=function(e){i(n,e);var t=f(n);function n(e){var a,s=e.channelUrl,i=e.userId;return r(this,n),a=t.call(this),(a=t.call(this)).method=B.PUT,a.path="".concat(zr,"/").concat(encodeURIComponent(s),"/messages/mark_as_delivered"),a.params=ee({userId:i}),a}return s(n)}(ne),nf=function(e){i(n,e);var t=f(n);function n(e,a,s){var i;return r(this,n),(i=t.call(this,e,"DLVR",s)).channelUrl=s.channel_url,i.deliveredStateUpdate=s.updated,i}return s(n)}(le),rf=function(e){i(n,e);var t=f(n);function n(e){var a;r(this,n);var s=e.channelUrl,i=e.userId,o=e.hidePreviousMessages,u=e.allowAutoUnhide;return(a=t.call(this)).method=B.PUT,a.path="".concat(zr,"/").concat(encodeURIComponent(s),"/hide"),a.params={user_id:i,hide_previous_messages:o,allow_auto_unhide:u},a}return s(n)}(ne),af=function(e){i(n,e);var t=f(n);function n(e,a){var s;r(this,n),(s=t.call(this,e,a)).messageOffsetTimestamp=null;var i=a.ts_message_offset;return s.messageOffsetTimestamp=null!=i?i:null,s}return s(n)}(re),sf=function(e){i(n,e);var t=f(n);function n(e,a,s){var i;return r(this,n),(i=t.call(this,e,"SYEV",s)).allowAutoUnhide=null,i.hidePreviousMessages=null,i.messageOffsetTimestamp=null,s.data&&(i.allowAutoUnhide=s.data.allow_auto_unhide,i.hidePreviousMessages=s.data.hide_previous_messages),i.messageOffsetTimestamp=s.ts_message_offset,i}return s(n)}(le),of=function(e){i(n,e);var t=f(n);function n(e){var a=e.channelUrl,s=e.time;return r(this,n),t.call(this,{code:"TPST",ackRequired:!1,payload:{channel_url:a,time:s}})}return s(n)}(Mr),uf=function(e){i(n,e);var t=f(n);function n(e,a,s){var i;return r(this,n),(i=t.call(this,e,"SYEV",s)).user=new La(e,s.data),i}return s(n)}(le),cf=function(e){i(n,e);var t=f(n);function n(e){var a=e.channelUrl,s=e.time;return r(this,n),t.call(this,{code:"TPEN",ackRequired:!1,payload:{channel_url:a,time:s}})}return s(n)}(Mr),lf=function(e){i(n,e);var t=f(n);function n(e,a,s){var i;return r(this,n),(i=t.call(this,e,"SYEV",s)).user=new La(e,s.data),i}return s(n)}(le),hf=function(e){i(n,e);var t=f(n);function n(e,a,s){var i;r(this,n),i=t.call(this,e,a,s);var o=s.data.operators,u=void 0===o?[]:o;return i.operators=u.map((function(e){return new La(i._iid,e)})),i}return s(n)}(jd),df=function(e){i(n,e);var t=f(n);function n(e,a,s){var i;return r(this,n),(i=t.call(this,e,"MCNT",s)).groupChannelMemberCounts=s.group_channels.map((function(e){return{channelUrl:e.channel_url,memberCount:e.member_count,joinedMemberCount:e.joined_member_count,updatedAt:e.ts}})),i.openChannelMemberCounts=s.open_channels.map((function(e){return{channelUrl:e.channel_url,participantCount:e.participant_count,updatedAt:e.ts}})),i}return s(n)}(le),ff=function(e){i(n,e);var t=f(n);function n(e){var a=e.channelUrl,s=e.messageId;return r(this,n),t.call(this,{code:"MACK",ackRequired:!1,payload:{channel_url:a,msg_id:s}})}return s(n)}(Mr),pf=function(e){i(n,e);var t=f(n);function n(e,a,s){var i,o,u,c;r(this,n),(i=t.call(this,e,"ADMM",s)).message=new Ts(e,s);var l=ns.of(e).sdkState;return i.isMentioned=Hs(i.message.mentionType,null!==(o=i.message.mentionedUserIds)&&void 0!==o?o:null===(u=i.message.mentionedUsers)||void 0===u?void 0:u.map((function(e){return e.userId})),l.userId),i.forceUpdateLastMessage=null!==(c=s.force_update_last_message)&&void 0!==c&&c,i}return s(n)}(le),vf=function(e){i(n,e);var t=f(n);function n(e,a,s){var i,o,u,c,l,h,d;r(this,n),(i=t.call(this,e,"AEDI",s)).message=new Ts(e,s);var f=ns.of(e).sdkState;return i.mentionCountChange=qs({mentionType:null!==(u=null===(o=s.old_values)||void 0===o?void 0:o.mention_type)&&void 0!==u?u:null,mentionedUserIds:null!==(l=null===(c=s.old_values)||void 0===c?void 0:c.mentioned_user_ids)&&void 0!==l?l:[]},{mentionType:i.message.mentionType,mentionedUserIds:null!==(h=i.message.mentionedUserIds)&&void 0!==h?h:null===(d=i.message.mentionedUsers)||void 0===d?void 0:d.map((function(e){return e.userId}))},f.userId),i}return s(n)}(le),_f=function(e){i(n,e);var t=f(n);function n(e,a,s){var i;return r(this,n),(i=t.call(this,e,"MRCT",s)).channelUrl=s.channel_url,i.channelType=s.channel_type,i.event=new ds(s),i}return s(n)}(le),mf=function(e){i(n,e);var t=f(n);function n(e,a,s){var i;return r(this,n),(i=t.call(this,e,"MTHD",s)).event=new mi(e,s),i}return s(n)}(le),gf=function(e){i(n,e);var t=f(n);function n(e,a,s){var i;return r(this,n),(i=t.call(this,e,"PEDI",s)).event=null,i.status=null,i.channelUrl=null,i.channelType=null,i.event=new Wi(e,s),i.status=As(s.poll.status)||s.poll.status,i.channelUrl=s.channel_url,i.channelType=s.channel_type,i}return s(n)}(le),yf=function(n){i(u,n);var a=f(u);function u(t,n){var s,i,o,c,l,h,d,f,p,v,_,m,g,y,k,b,E,w,C,x,T,S,I;return r(this,u),(s=a.call(this,t,n)).includeEmpty=!1,s.includeFrozen=!0,s.includeMetaData=!0,s.channelUrlsFilter=null,s.customTypesFilter=null,s.customTypeStartsWithFilter=null,s.nicknameContainsFilter=null,s.nicknameStartsWithFilter=null,s.nicknameExactMatchFilter=null,s.channelNameContainsFilter="",s.myMemberStateFilter=e.MyMemberStateFilter.ALL,s.unreadChannelFilter=e.UnreadChannelFilter.ALL,s.superChannelFilter=e.SuperChannelFilter.ALL,s.publicChannelFilter=e.PublicChannelFilter.ALL,s.hiddenChannelFilter=e.HiddenChannelFilter.UNHIDDEN,s.searchFilter={fields:[],query:null},s.userIdsFilter={userIds:[],includeMode:!0,queryType:e.QueryType.AND},s.metadataKey=null,s.metadataValues=null,s.metadataOrderKeyFilter=null,s.metadataValueStartsWith=null,s.order=e.GroupChannelListOrder.LATEST_LAST_MESSAGE,s.includeEmpty=null!==(i=n.includeEmpty)&&void 0!==i&&i,s.includeFrozen=null===(o=n.includeFrozen)||void 0===o||o,s.includeMetaData=null===(c=n.includeMetaData)||void 0===c||c,s.channelUrlsFilter=null!==(l=n.channelUrlsFilter)&&void 0!==l?l:null,s.customTypesFilter=null!==(h=n.customTypesFilter)&&void 0!==h?h:null,s.customTypeStartsWithFilter=null!==(d=n.customTypeStartsWithFilter)&&void 0!==d?d:"",s.nicknameContainsFilter=null!==(f=n.nicknameContainsFilter)&&void 0!==f?f:null,s.nicknameStartsWithFilter=null!==(p=n.nicknameStartsWithFilter)&&void 0!==p?p:null,s.nicknameExactMatchFilter=null!==(v=n.nicknameExactMatchFilter)&&void 0!==v?v:null,s.channelNameContainsFilter=null!==(_=n.channelNameContainsFilter)&&void 0!==_?_:"",s.myMemberStateFilter=null!==(m=n.myMemberStateFilter)&&void 0!==m?m:e.MyMemberStateFilter.ALL,s.unreadChannelFilter=null!==(g=n.unreadChannelFilter)&&void 0!==g?g:e.UnreadChannelFilter.ALL,s.superChannelFilter=null!==(y=n.superChannelFilter)&&void 0!==y?y:e.SuperChannelFilter.ALL,s.publicChannelFilter=null!==(k=n.publicChannelFilter)&&void 0!==k?k:e.PublicChannelFilter.ALL,s.hiddenChannelFilter=null!==(b=n.hiddenChannelFilter)&&void 0!==b?b:e.HiddenChannelFilter.UNHIDDEN,s.searchFilter=null!==(E=n.searchFilter)&&void 0!==E?E:{fields:[],query:null},s.userIdsFilter=null!==(w=n.userIdsFilter)&&void 0!==w?w:{userIds:[],includeMode:!0,queryType:e.QueryType.AND},s.metadataKey=null!==(C=n.metadataKey)&&void 0!==C?C:null,s.metadataValues=null!==(x=n.metadataValues)&&void 0!==x?x:null,s.metadataOrderKeyFilter=null!==(T=n.metadataOrderKeyFilter)&&void 0!==T?T:null,s.metadataValueStartsWith=null!==(S=n.metadataValueStartsWith)&&void 0!==S?S:null,s.order=null!==(I=n.order)&&void 0!==I?I:e.GroupChannelListOrder.LATEST_LAST_MESSAGE,s}return s(u,[{key:"_validate",value:function(){return p(o(u.prototype),"_validate",this).call(this)&&L("boolean",this.includeEmpty)&&L("boolean",this.includeFrozen)&&L("boolean",this.includeMetaData)&&L("string",this.channelNameContainsFilter)&&F("string",this.channelUrlsFilter,!0)&&F("string",this.customTypesFilter,!0)&&L("string",this.customTypeStartsWithFilter)&&L("string",this.nicknameContainsFilter,!0)&&L("string",this.nicknameStartsWithFilter,!0)&&L("string",this.nicknameExactMatchFilter,!0)&&D(e.MyMemberStateFilter,this.myMemberStateFilter)&&D(e.SuperChannelFilter,this.superChannelFilter)&&D(e.PublicChannelFilter,this.publicChannelFilter)&&D(e.UnreadChannelFilter,this.unreadChannelFilter)&&D(e.HiddenChannelFilter,this.hiddenChannelFilter)&&F(e.GroupChannelSearchField,this.searchFilter.fields)&&L("string",this.searchFilter.query,!0)&&F("string",this.userIdsFilter.userIds)&&L("boolean",this.userIdsFilter.includeMode)&&D(e.QueryType,this.userIdsFilter.queryType)&&D(e.GroupChannelListOrder,this.order)&&L("string",this.metadataOrderKeyFilter,!0)&&L("string",this.metadataKey,!0)&&F("string",this.metadataValues,!0)&&L("string",this.metadataValueStartsWith,!0)}},{key:"serialize",value:function(){return Ma(this)}},{key:"next",value:function(){return b(this,void 0,void 0,t().mark((function e(){var n,r,a,s;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!this._validate()){e.next=20;break}if(this._isLoading){e.next=17;break}if(!this._hasNext){e.next=14;break}return this._isLoading=!0,n=wf.of(this._iid),e.next=7,n.getMyGroupChannels(this._token,this,this.limit);case 7:return r=e.sent,a=r.channels,s=r.token,this._token=s,this._hasNext=!!s,this._isLoading=!1,e.abrupt("return",a);case 14:return e.abrupt("return",[]);case 17:throw M.queryInProgress;case 18:e.next=21;break;case 20:throw M.invalidParameters;case 21:case"end":return e.stop()}}),e,this)})))}}]),u}(ki),kf=function(){function e(t){var n=t.top,a=void 0===n?Number.MAX_SAFE_INTEGER:n,s=t.bottom,i=void 0===s?0:s;r(this,e),this.top=a,this.bottom=i}return s(e,[{key:"includes",value:function(){for(var e=this,t=arguments.length,n=new Array(t),r=0;r0||G.unreadMentionCount>0)&&(G._updateUnreadCount(0,0),this._dispatcher.dispatch(new ru({channels:[G],source:e.GroupChannelEventSource.EVENT_CHANNEL_READ})),ua((function(){return b(cn,void 0,void 0,t().mark((function e(){var n,r;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:n=y(this._groupChannelHandlers.values());try{for(n.s();!(r=n.n()).done;)r.value.onChannelChanged(G)}catch(e){n.e(e)}finally{n.f()}case 2:case"end":return e.stop()}}),e,this)})))}))):0!==G.unreadMessageCount&&0!==G.unreadMentionCount||(this._dispatcher.dispatch(new ru({channels:[G],source:e.GroupChannelEventSource.EVENT_CHANNEL_READ})),ua((function(){return b(cn,void 0,void 0,t().mark((function e(){var n,r;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:n=y(this._groupChannelHandlers.values());try{for(n.s();!(r=n.n()).done;)r.value.onChannelChanged(G)}catch(e){n.e(e)}finally{n.f()}case 2:case"end":return e.stop()}}),e,this)})))}))):(this._dispatcher.dispatch(new ru({channels:[G],source:e.GroupChannelEventSource.EVENT_CHANNEL_READ})),ua((function(){return b(cn,void 0,void 0,t().mark((function e(){var n,r;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:n=y(this._groupChannelHandlers.values());try{for(n.s();!(r=n.n()).done;)r.value.onUnreadMemberStatusUpdated(G)}catch(e){n.e(e)}finally{n.f()}case 2:case"end":return e.stop()}}),e,this)})))})));case 80:return r.abrupt("break",337);case 81:return H=n.as(nf),q=H.channelUrl,j=H.deliveredStateUpdate,z=void 0===j?{}:j,V=this._groupChannelCache.isCachedInMemory(q),r.next=85,this.getChannel(q,!0);case 85:if(B=r.sent,V)for(Q in z)B._updateUndeliveredMemberState(Q,z[Q]);return Object.keys(z).some((function(e){return e!==cn._sdkState.userId}))&&(this._dispatcher.dispatch(new ru({channels:[B],source:e.GroupChannelEventSource.EVENT_CHANNEL_DELIVERED})),ua((function(){return b(cn,void 0,void 0,t().mark((function e(){var n,r;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:n=y(this._groupChannelHandlers.values());try{for(n.s();!(r=n.n()).done;)r.value.onUndeliveredMemberStatusUpdated(B)}catch(e){n.e(e)}finally{n.f()}case 2:case"end":return e.stop()}}),e,this)})))}))),r.abrupt("break",337);case 89:if(K=n.as(_f),W=K.channelUrl,Y=K.channelType,Z=K.event,Y!==e.ChannelType.GROUP){r.next=99;break}return r.next=93,this.getChannel(W,!0);case 93:return J=r.sent,r.next=96,this.getMessageFromCache(Z.messageId);case 96:(X=r.sent)&&(X.applyReactionEvent(Z),this._dispatcher.dispatch(new ei({messages:[X],source:e.MessageEventSource.EVENT_MESSAGE_REACTION_UPDATED}))),ua((function(){return b(cn,void 0,void 0,t().mark((function e(){var n,r;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:n=y(this._groupChannelHandlers.values());try{for(n.s();!(r=n.n()).done;)r.value.onReactionUpdated(J,Z)}catch(e){n.e(e)}finally{n.f()}case 2:case"end":return e.stop()}}),e,this)})))}));case 99:return r.abrupt("break",337);case 100:if($=n.as(mf),(ee=$.event).channelType!==e.ChannelType.GROUP){r.next=110;break}return r.next=104,this.getChannel(ee.channelUrl,!0);case 104:return te=r.sent,r.next=107,this.getMessageFromCache(ee.targetMessageId);case 107:(ne=r.sent)&&(ne.applyThreadInfoUpdateEvent(ee),this._dispatcher.dispatch(new ei({messages:[ne],source:e.MessageEventSource.EVENT_MESSAGE_THREADINFO_UPDATED}))),ua((function(){return b(cn,void 0,void 0,t().mark((function e(){var n,r;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:n=y(this._groupChannelHandlers.values());try{for(n.s();!(r=n.n()).done;)r.value.onThreadInfoUpdated(te,ee)}catch(e){n.e(e)}finally{n.f()}case 2:case"end":return e.stop()}}),e,this)})))}));case 110:return r.abrupt("break",337);case 111:re=n.as(df),ae=re.groupChannelMemberCounts,se=[],ie=y(ae),r.prev=114,ie.s();case 116:if((oe=ie.n()).done){r.next=125;break}return ue=oe.value,ce=ue.channelUrl,le=ue.memberCount,he=ue.joinedMemberCount,de=ue.updatedAt,r.next=121,this.getChannelFromCache(ce);case 121:(fe=r.sent)&&fe._setLatestMemberCount(le,he,de)&&se.push(fe);case 123:r.next=116;break;case 125:r.next=130;break;case 127:r.prev=127,r.t2=r.catch(114),ie.e(r.t2);case 130:return r.prev=130,ie.f(),r.finish(130);case 133:return se.length>0&&(this._dispatcher.dispatch(new ru({channels:se,source:e.GroupChannelEventSource.EVENT_CHANNEL_MEMBER_COUNT_UPDATED})),ua((function(){return b(cn,void 0,void 0,t().mark((function e(){var n,r;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:n=y(this._groupChannelHandlers.values());try{for(n.s();!(r=n.n()).done;)r.value.onChannelMemberCountChanged(se)}catch(e){n.e(e)}finally{n.f()}case 2:case"end":return e.stop()}}),e,this)})))}))),r.abrupt("break",337);case 135:if(pe=n.as(gf),ve=pe.event,_e=pe.status,me=pe.channelUrl,ge=pe.channelType,me&&ge){r.next=138;break}return r.abrupt("break",337);case 138:return r.next=140,this.getChannel(me,!0);case 140:return ye=r.sent,this._dispatcher.dispatch(new ai({event:ve,source:e.MessageEventSource.EVENT_POLL_UPDATED})),ua(_e===Ns?function(){return b(cn,void 0,void 0,t().mark((function e(){var n,r;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:n=y(this._groupChannelHandlers.values());try{for(n.s();!(r=n.n()).done;)r.value.onPollDeleted(ye,ve.pollId)}catch(e){n.e(e)}finally{n.f()}case 2:case"end":return e.stop()}}),e,this)})))}:function(){return b(cn,void 0,void 0,t().mark((function e(){var n,r;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:n=y(this._groupChannelHandlers.values());try{for(n.s();!(r=n.n()).done;)r.value.onPollUpdated(ye,ve)}catch(e){n.e(e)}finally{n.f()}case 2:case"end":return e.stop()}}),e,this)})))}),r.abrupt("break",337);case 144:if(ke=n.as(jh),be=ke.event,Ee=ke.channelUrl,we=ke.channelType,Ee&&we){r.next=147;break}return r.abrupt("break",337);case 147:return r.next=149,this.getChannel(Ee,!0);case 149:return Ce=r.sent,this._dispatcher.dispatch(new si({event:be,source:e.MessageEventSource.EVENT_POLL_VOTED})),ua((function(){return b(cn,void 0,void 0,t().mark((function e(){var n,r;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:n=y(this._groupChannelHandlers.values());try{for(n.s();!(r=n.n()).done;)r.value.onPollVoted(Ce,be)}catch(e){n.e(e)}finally{n.f()}case 2:case"end":return e.stop()}}),e,this)})))})),r.abrupt("break",337);case 153:if(xe=n.as(jd),!(Te=xe.event).isGroupChannelEvent){r.next=325;break}r.t3=Te.category,r.next=r.t3===nd.CHANNEL_JOIN?158:r.t3===nd.CHANNEL_LEAVE?167:r.t3===nd.CHANNEL_OPERATOR_UPDATE?183:r.t3===nd.CHANNEL_INVITE?194:r.t3===nd.CHANNEL_DECLINE_INVITE?204:r.t3===nd.TYPING_START||r.t3===nd.TYPING_END?212:r.t3===nd.USER_CHANNEL_MUTE||r.t3===nd.USER_CHANNEL_UNMUTE?221:r.t3===nd.USER_CHANNEL_BAN?248:r.t3===nd.USER_CHANNEL_UNBAN?261:r.t3===nd.CHANNEL_FREEZE||r.t3===nd.CHANNEL_UNFREEZE?267:r.t3===nd.CHANNEL_HIDE?275:r.t3===nd.CHANNEL_UNHIDE?285:r.t3===nd.CHANNEL_DELETED?292:r.t3===nd.CHANNEL_PROP_CHANGED?298:r.t3===nd.CHANNEL_META_DATA_CHANGED?304:r.t3===nd.CHANNEL_META_COUNTERS_CHANGED?313:r.t3===nd.PINNED_MESSAGE_CHANGED?319:325;break;case 158:return r.next=160,this.getChannel(Te.channelUrl,!0);case 160:return Se=r.sent,Ie=n.as(Bd),Ne=Ie.memberCount,Ae=Ie.joinedMemberCount,Me=Ie.members,Oe=!1,Me.forEach((function(t){Se.isExclusive||Se.isSuper||Se.isBroadcast?Oe=Oe||Se._setLatestMemberCount(Ne,Ae,Te.ts):(t.state=e.MemberState.JOINED,Se.addMember(t,Te.ts),cn._updateJoinedMemberCount(Se)),t.userId===cn._sdkState.userId&&(Se.myMemberState=e.MemberState.JOINED)})),this._dispatcher.dispatch(new ru({channels:[Se],source:e.GroupChannelEventSource.EVENT_CHANNEL_JOINED})),ua((function(){return b(cn,void 0,void 0,t().mark((function e(){return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:this._groupChannelHandlers.forEach((function(e){var t,n=y(Me);try{for(n.s();!(t=n.n()).done;){var r=t.value;e.onUserJoined(Se,r)}}catch(e){n.e(e)}finally{n.f()}Se.isBroadcast&&Oe&&e.onChannelMemberCountChanged([Se])}));case 1:case"end":return e.stop()}}),e,this)})))})),r.abrupt("break",325);case 167:if(!(Ue=this._leftChannels.get(Te.channelUrl))){r.next=172;break}r.t4=Ue.channel,r.next=175;break;case 172:return r.next=174,this.getChannel(Te.channelUrl,!0);case 174:r.t4=r.sent;case 175:return Re=r.t4,Le=n.as(Kd),De=Le.memberCount,Pe=Le.joinedMemberCount,Fe=Le.member,Ge=!1,He=ns.of(this._iid),qe=He.appInfo,Re.isExclusive||Re.isSuper||Re.isBroadcast?Ge=Re._setLatestMemberCount(De,Pe,Te.ts):(qe.enabledChannelMemberShipHistory?(Re.members.find((function(e){return e.userId===Fe.userId})).state=e.MemberState.LEFT,Re.memberCount=De):Re.removeMember(Fe),this._updateJoinedMemberCount(Re)),Fe.userId===this._sdkState.userId?(Re.myMemberState=e.MemberState.NONE,Re.invitedAt=0,Re.joinedAt=0,Re._updateUnreadCount(0,0),Re.isPublic?this._dispatcher.dispatch(new ru({channels:[Re],source:e.GroupChannelEventSource.EVENT_CHANNEL_LEFT})):(this._markAsLeave(Re),this._dispatcher.dispatch(new au({channelUrls:[Re.url],source:e.GroupChannelEventSource.EVENT_CHANNEL_LEFT})))):this._dispatcher.dispatch(new ru({channels:[Re],source:e.GroupChannelEventSource.EVENT_CHANNEL_LEFT})),ua((function(){return b(cn,void 0,void 0,t().mark((function e(){return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:this._groupChannelHandlers.forEach((function(e){e.onUserLeft(Re,Fe),Re.isBroadcast&&Ge&&e.onChannelMemberCountChanged([Re])}));case 1:case"end":return e.stop()}}),e,this)})))})),r.abrupt("break",325);case 183:return r.next=185,this.getChannel(Te.channelUrl,!0);case 185:je=r.sent,ze=n.as(hf),Ve=ze.operators,Be=Ve.map((function(e){return e.userId})),Qe=y(je.members);try{for(Qe.s();!(Ke=Qe.n()).done;)(We=Ke.value).role=Be.includes(We.userId)?e.Role.OPERATOR:e.Role.NONE}catch(e){Qe.e(e)}finally{Qe.f()}return je.myRole=Be.includes(this._sdkState.userId)?e.Role.OPERATOR:e.Role.NONE,this._dispatcher.dispatch(new ru({channels:[je],source:e.GroupChannelEventSource.EVENT_CHANNEL_OPERATOR_UPDATED})),ua((function(){return b(cn,void 0,void 0,t().mark((function e(){return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:this._groupChannelHandlers.forEach((function(e){e.onOperatorUpdated(je,Ve)}));case 1:case"end":return e.stop()}}),e,this)})))})),r.abrupt("break",325);case 194:return r.next=196,this.getChannel(Te.channelUrl,!0);case 196:Ye=r.sent,Ze=n.as(Zd),Je=Ze.memberCount,Xe=Ze.joinedMemberCount,$e=Ze.inviter,(et=Ze.invitees).forEach((function(t){return t.state=e.MemberState.INVITED})),tt=y(et);try{for(tt.s();!(nt=tt.n()).done;)rt=nt.value,Ye.isExclusive||Ye.isSuper||Ye.isBroadcast?Ye._setLatestMemberCount(Je,Xe,Te.ts):Ye.addMember(rt,Te.ts),this._sdkState.userId===rt.userId&&(Ye.hiddenState=e.HiddenState.UNHIDDEN,Ye.myMemberState!==e.MemberState.JOINED&&(Ye.myMemberState=e.MemberState.INVITED),Ye.invitedAt=Te.ts)}catch(e){tt.e(e)}finally{tt.f()}return this._dispatcher.dispatch(new ru({channels:[Ye],source:e.GroupChannelEventSource.EVENT_CHANNEL_INVITED})),ua((function(){return b(cn,void 0,void 0,t().mark((function e(){return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:this._groupChannelHandlers.forEach((function(e){e.onUserReceivedInvitation(Ye,$e,et)}));case 1:case"end":return e.stop()}}),e,this)})))})),r.abrupt("break",325);case 204:return r.next=206,this.getChannel(Te.channelUrl,!0);case 206:return at=r.sent,st=n.as(Xd),it=st.memberCount,ot=st.joinedMemberCount,ut=st.inviter,ct=st.invitee,at.isExclusive||at.isSuper||at.isBroadcast?at._setLatestMemberCount(it,ot,Te.ts):at.removeMember(ct),this._sdkState.userId===ct.userId?(at.invitedAt=0,at.myMemberState=e.MemberState.NONE,at.isPublic?this._dispatcher.dispatch(new ru({channels:[at],source:e.GroupChannelEventSource.EVENT_CHANNEL_DECLINED_INVITE})):this._dispatcher.dispatch(new au({channelUrls:[at.url],source:e.GroupChannelEventSource.EVENT_CHANNEL_DECLINED_INVITE}))):this._dispatcher.dispatch(new ru({channels:[at],source:e.GroupChannelEventSource.EVENT_CHANNEL_DECLINED_INVITE})),ua((function(){return b(cn,void 0,void 0,t().mark((function e(){return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:this._groupChannelHandlers.forEach((function(e){e.onUserDeclinedInvitation(at,ut,ct)}));case 1:case"end":return e.stop()}}),e,this)})))})),r.abrupt("break",325);case 212:return r.next=214,this.getChannel(Te.channelUrl,!0);case 214:return lt=r.sent,ht=Te.category===nd.TYPING_START,dt=n.as(ht?uf:lf),ft=dt.user,lt._updateTypingStatus(ft,ht?Te.ts:0),this._dispatcher.dispatch(new ru({channels:[lt],source:e.GroupChannelEventSource.EVENT_CHANNEL_TYPING_STATUS_UPDATE})),ua((function(){return b(cn,void 0,void 0,t().mark((function e(){return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:this._groupChannelHandlers.forEach((function(e){e.onTypingStatusUpdated(lt)}));case 1:case"end":return e.stop()}}),e,this)})))})),r.abrupt("break",325);case 221:return r.next=223,this.getChannel(Te.channelUrl,!0);case 223:pt=r.sent,vt=Te.category===nd.USER_CHANNEL_MUTE,_t=n.as(vt?eh:nh),(mt=_t.user).userId===this._sdkState.userId&&(pt.myMutedState=vt?e.MutedState.MUTED:e.MutedState.UNMUTED,pt._myMutedRemainingTime=mt.restrictionInfo.remainingDuration),gt=y(pt.members),r.prev=228,gt.s();case 230:if((yt=gt.n()).done){r.next=237;break}if((kt=yt.value).userId!==mt.userId){r.next=235;break}return kt.isMuted=vt,r.abrupt("break",237);case 235:r.next=230;break;case 237:r.next=242;break;case 239:r.prev=239,r.t5=r.catch(228),gt.e(r.t5);case 242:return r.prev=242,gt.f(),r.finish(242);case 245:return this._dispatcher.dispatch(new ru({channels:[pt],source:vt?e.GroupChannelEventSource.EVENT_CHANNEL_MUTED:e.GroupChannelEventSource.EVENT_CHANNEL_UNMUTED,data:mt.userId})),ua((function(){return b(cn,void 0,void 0,t().mark((function e(){return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:this._groupChannelHandlers.forEach((function(e){vt?e.onUserMuted(pt,mt):e.onUserUnmuted(pt,mt)}));case 1:case"end":return e.stop()}}),e,this)})))})),r.abrupt("break",325);case 248:if(!(bt=this._leftChannels.get(Te.channelUrl))){r.next=253;break}r.t6=bt.channel,r.next=256;break;case 253:return r.next=255,this.getChannel(Te.channelUrl,!0);case 255:r.t6=r.sent;case 256:return Et=r.t6,this._markAsLeave(Et),wt=n.as(ah),Ct=wt.user,ua((function(){return b(cn,void 0,void 0,t().mark((function e(){return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:this._groupChannelHandlers.forEach((function(e){e.onUserBanned(Et,Ct)}));case 1:case"end":return e.stop()}}),e,this)})))})),r.abrupt("break",325);case 261:return r.next=263,this.getChannel(Te.channelUrl,!0);case 263:return xt=r.sent,Tt=n.as(ih),St=Tt.user,ua((function(){return b(cn,void 0,void 0,t().mark((function e(){return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:this._groupChannelHandlers.forEach((function(e){e.onUserUnbanned(xt,St)}));case 1:case"end":return e.stop()}}),e,this)})))})),r.abrupt("break",325);case 267:return r.next=269,this.getChannel(Te.channelUrl,!0);case 269:return It=r.sent,Nt=n.as(uh),At=Nt.freeze,It.isFrozen=At,this._dispatcher.dispatch(new ru({channels:[It],source:At?e.GroupChannelEventSource.EVENT_CHANNEL_FROZEN:e.GroupChannelEventSource.EVENT_CHANNEL_UNFROZEN})),ua((function(){return b(cn,void 0,void 0,t().mark((function e(){return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:this._groupChannelHandlers.forEach((function(e){At?e.onChannelFrozen(It):e.onChannelUnfrozen(It)}));case 1:case"end":return e.stop()}}),e,this)})))})),r.abrupt("break",325);case 275:return r.next=277,this.getChannel(Te.channelUrl,!0);case 277:return Mt=r.sent,Ot=n.as(sf),Ut=Ot.allowAutoUnhide,Rt=Ot.hidePreviousMessages,Lt=Ot.messageOffsetTimestamp,null!==Ut&&(Mt.hiddenState=Ut?e.HiddenState.HIDDEN_ALLOW_AUTO_UNHIDE:e.HiddenState.HIDDEN_PREVENT_AUTO_UNHIDE),null!==Rt&&Rt&&Mt._updateUnreadCount(0,0),null!==Lt&&(Mt.messageOffsetTimestamp=Lt),this._dispatcher.dispatch(new ru({channels:[Mt],source:e.GroupChannelEventSource.EVENT_CHANNEL_HIDDEN})),ua((function(){return b(cn,void 0,void 0,t().mark((function e(){return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:this._groupChannelHandlers.forEach((function(e){e.onChannelHidden(Mt)}));case 1:case"end":return e.stop()}}),e,this)})))})),r.abrupt("break",325);case 285:return r.next=287,this.getChannel(Te.channelUrl,!0);case 287:return(Dt=r.sent).hiddenState=e.HiddenState.UNHIDDEN,this._dispatcher.dispatch(new ru({channels:[Dt],source:e.GroupChannelEventSource.EVENT_CHANNEL_UNHIDDEN})),ua((function(){return b(cn,void 0,void 0,t().mark((function e(){return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:this._groupChannelHandlers.forEach((function(e){e.onChannelChanged(Dt)}));case 1:case"end":return e.stop()}}),e,this)})))})),r.abrupt("break",325);case 292:return r.next=294,this.getChannel(Te.channelUrl,!0);case 294:return Pt=r.sent,this._dispatcher.dispatch(new au({channelUrls:[Te.channelUrl],source:e.GroupChannelEventSource.EVENT_CHANNEL_DELETED})),ua((function(){return b(cn,void 0,void 0,t().mark((function e(){return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:this._groupChannelHandlers.forEach((function(e){e.onChannelDeleted(Pt.url,Pt.channelType)}));case 1:case"end":return e.stop()}}),e,this)})))})),r.abrupt("break",325);case 298:return r.next=300,this.getChannelWithoutCache(Te.channelUrl,!0);case 300:return Ft=r.sent,this._dispatcher.dispatch(new ru({channels:[Ft],source:e.GroupChannelEventSource.EVENT_CHANNEL_UPDATED})),ua((function(){return b(cn,void 0,void 0,t().mark((function e(){return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:this._groupChannelHandlers.forEach((function(e){e.onChannelChanged(Ft)}));case 1:case"end":return e.stop()}}),e,this)})))})),r.abrupt("break",325);case 304:return r.next=306,this.getChannel(Te.channelUrl,!0);case 306:return Gt=r.sent,Ht=n.as(Gl),qt=Ht.created,jt=Ht.updated,zt=Ht.deleted,qt&&Gt._upsertCachedMetaData(qt,Te.ts),jt&&Gt._upsertCachedMetaData(jt,Te.ts),zt&&Gt._removeFromCachedMetaData(zt,Te.ts),ua((function(){return b(cn,void 0,void 0,t().mark((function e(){return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:this._groupChannelHandlers.forEach((function(e){qt&&e.onMetaDataCreated(Gt,qt),jt&&e.onMetaDataUpdated(Gt,jt),zt&&e.onMetaDataDeleted(Gt,zt)}));case 1:case"end":return e.stop()}}),e,this)})))})),r.abrupt("break",325);case 313:return r.next=315,this.getChannel(Te.channelUrl,!0);case 315:return Vt=r.sent,Bt=n.as(Zl),Qt=Bt.created,Kt=Bt.updated,Wt=Bt.deleted,ua((function(){return b(cn,void 0,void 0,t().mark((function e(){return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:this._groupChannelHandlers.forEach((function(e){Qt&&e.onMetaCounterCreated(Vt,Qt),Kt&&e.onMetaCounterUpdated(Vt,Kt),Wt&&e.onMetaCounterDeleted(Vt,Wt)}));case 1:case"end":return e.stop()}}),e,this)})))})),r.abrupt("break",325);case 319:return r.next=321,this.getChannel(Te.channelUrl,!0);case 321:return Yt=r.sent,Zt=n.as(bf),Jt=Zt.pinnedMessageIds,Xt=Zt.latestPinnedMessage,($t=Zt.ts)>Yt._pinnedMessagesUpdatedAt&&(Yt.pinnedMessageIds=Jt,Yt.lastPinnedMessage=Xt,Yt._pinnedMessagesUpdatedAt=$t,this._dispatcher.dispatch(new ru({channels:[Yt],source:e.GroupChannelEventSource.EVENT_PINNED_MESSAGE_UPDATED})),ua((function(){return b(cn,void 0,void 0,t().mark((function e(){var n,r;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:n=y(this._groupChannelHandlers.values());try{for(n.s();!(r=n.n()).done;)r.value.onChannelChanged(Yt)}catch(e){n.e(e)}finally{n.f()}case 2:case"end":return e.stop()}}),e,this)})))})),ua((function(){return b(cn,void 0,void 0,t().mark((function e(){return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:this._groupChannelHandlers.forEach((function(e){e.onPinnedMessageUpdated(Yt)}));case 1:case"end":return e.stop()}}),e,this)})))}))),r.abrupt("break",325);case 325:return r.abrupt("break",337);case 326:en=n.as(iu),tn=en.event,r.t7=tn.category,r.next=r.t7===Lo.USER_BLOCK?330:r.t7===Lo.USER_UNBLOCK?333:336;break;case 330:return nn=$o.getDataAsUserBlockEvent(this._iid,tn),rn=nn.blocker,an=nn.blockee,this._groupChannelCache.block(rn.userId,an.userId),r.abrupt("break",336);case 333:return sn=$o.getDataAsUserBlockEvent(this._iid,tn),on=sn.blocker,un=sn.blockee,this._groupChannelCache.unblock(on.userId,un.userId),r.abrupt("break",336);case 336:return r.abrupt("break",337);case 337:r.next=343;break;case 339:if(r.prev=339,r.t8=r.catch(0),!A(r.t8)){r.next=343;break}throw r.t8;case 343:case"end":return r.stop()}}),r,this,[[0,339],[19,30,33,36],[114,127,130,133],[228,239,242,245]])})))}},{key:"_markAsLeave",value:function(e){var t,n=this,r=null!==(t=this._leftChannels.get(e.url))&&void 0!==t?t:{channel:e,ref:0};r.ref++,this._leftChannels.set(e.url,r),setTimeout((function(){r.ref--,0===r.ref&&n._leftChannels.delete(e.url)}),1e4)}},{key:"addHandler",value:function(e,t){this._groupChannelHandlers.set(e,t)}},{key:"removeHandler",value:function(e){this._groupChannelHandlers.delete(e)}},{key:"clearHandler",value:function(){this._groupChannelHandlers.clear()}},{key:"subscribeGroupChannelEvent",value:function(e,t){this._groupChannelBroadcast.subscribe(e,t)}},{key:"unsubscribeGroupChannelEvent",value:function(e){this._groupChannelBroadcast.unsubscribe(e)}},{key:"subscribeMessageEvent",value:function(e,t){this._messageBroadcast.subscribe(e,t)}},{key:"unsubscribeMessageEvent",value:function(e){this._messageBroadcast.unsubscribe(e)}},{key:"_updateJoinedMemberCount",value:function(t){t.joinedMemberCount=t.members.filter((function(t){return t.state===e.MemberState.JOINED})).length}},{key:"getChannel",value:function(e){var n=arguments.length>1&&void 0!==arguments[1]&&arguments[1];return b(this,void 0,void 0,t().mark((function r(){var a;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return Ua(L("string",e)).throw(M.invalidParameters),t.prev=1,t.next=4,this.getChannelFromCache(e);case 4:if(!(a=t.sent)){t.next=7;break}return t.abrupt("return",a);case 7:t.next=11;break;case 9:t.prev=9,t.t0=t.catch(1);case 11:return t.next=13,this.getChannelWithoutCache(e,n);case 13:return t.abrupt("return",t.sent);case 14:case"end":return t.stop()}}),r,this,[[1,9]])})))}},{key:"getChannelWithoutCache",value:function(n){var r=arguments.length>1&&void 0!==arguments[1]&&arguments[1];return b(this,void 0,void 0,t().mark((function a(){var s,i,o,u,c,l;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return Ua(L("string",n)).throw(M.invalidParameters),s=new Cd({channelUrl:n,isInternalCall:r}),t.next=4,this._requestQueue.send(s);case 4:i=t.sent,o=i.as(xd),u=o.channel,c=u.unreadMessageCount,l=u.unreadMentionCount,t.t0=u.myCountPreference,t.next=t.t0===e.CountPreference.UNREAD_MESSAGE_COUNT_ONLY?10:t.t0===e.CountPreference.UNREAD_MENTION_COUNT_ONLY?12:t.t0===e.CountPreference.OFF?14:17;break;case 10:return l=0,t.abrupt("break",17);case 12:return c=0,t.abrupt("break",17);case 14:return c=0,l=0,t.abrupt("break",17);case 17:return u._updateUnreadCount(c,l),t.next=20,this.upsertChannelsToCache([u]);case 20:return t.abrupt("return",u);case 21:case"end":return t.stop()}}),a,this)})))}},{key:"refreshChannel",value:function(n){var r=!(arguments.length>1&&void 0!==arguments[1])||arguments[1],a=arguments.length>2&&void 0!==arguments[2]?arguments[2]:e.GroupChannelEventSource.REFRESH_CHANNEL;return b(this,void 0,void 0,t().mark((function s(){var i,o,u,c;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.prev=0,i=new Cd({channelUrl:n,isInternalCall:r}),t.next=4,this._requestQueue.send(i);case 4:o=t.sent,u=o.as(xd),(c=u.channel).myMemberState===e.MemberState.NONE?this._dispatcher.dispatch(new au({channelUrls:[c.url],source:a})):this._dispatcher.dispatch(new ru({channels:[c],source:a})),t.next=12;break;case 9:t.prev=9,t.t0=t.catch(0),t.t0.code!==E.NON_AUTHORIZED&&t.t0.code!==E.NOT_FOUND_IN_DATABASE||this._dispatcher.dispatch(new au({channelUrls:[n],source:a}));case 12:case"end":return t.stop()}}),s,this,[[0,9]])})))}},{key:"getMyGroupChannels",value:function(n,r,a){var s=arguments.length>3&&void 0!==arguments[3]?arguments[3]:e.GroupChannelEventSource.REQUEST_CHANNEL;return b(this,void 0,void 0,t().mark((function e(){var i,o,u,c,l;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return i=new Td(Object.assign(Object.assign({},r),{userId:this._sdkState.userId,token:n,limit:a})),e.next=3,this._requestQueue.send(i);case 3:return o=e.sent,u=o.as(Sd),c=u.channels,l=u.token,this._dispatcher.dispatch(new ru({channels:c,source:s})),e.abrupt("return",{channels:c,token:l});case 7:case"end":return e.stop()}}),e,this)})))}},{key:"getMessageFromCache",value:function(e){return b(this,void 0,void 0,t().mark((function n(){return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,this._messageCache.get(e);case 2:return t.abrupt("return",t.sent);case 3:case"end":return t.stop()}}),n,this)})))}},{key:"getMessagesFromCache",value:function(e,n,r,a){var s=arguments.length>4&&void 0!==arguments[4]?arguments[4]:co;return b(this,void 0,void 0,t().mark((function i(){return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,this._messageCache.fetch({channelUrl:e,token:n,limit:s,filter:a,backward:"next"===r});case 2:return t.abrupt("return",t.sent);case 3:case"end":return t.stop()}}),i,this)})))}},{key:"getPollMessagesFromCache",value:function(e,n,r){var a=arguments.length>3&&void 0!==arguments[3]?arguments[3]:co;return b(this,void 0,void 0,t().mark((function s(){return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,this._messageCache.fetch({channelUrl:e,token:n,limit:a,filter:r,backward:!1,isPollOnly:!0});case 2:return t.abrupt("return",t.sent);case 3:case"end":return t.stop()}}),s,this)})))}},{key:"getUnsentMessagesFromCache",value:function(e,n){return b(this,void 0,void 0,t().mark((function r(){return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,this._unsentMessageCache.fetch({channelUrl:e,filter:n});case 2:return t.abrupt("return",t.sent);case 3:case"end":return t.stop()}}),r,this)})))}},{key:"removeFailedMessageFromCache",value:function(e){return b(this,void 0,void 0,t().mark((function n(){return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,this._unsentMessageCache.remove([e]);case 2:case"end":return t.stop()}}),n,this)})))}},{key:"getCachedMessageCountBetween",value:function(e,n,r,a){return b(this,void 0,void 0,t().mark((function s(){return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,this._messageCache.countBetween(e,n,new kf({top:r,bottom:a}));case 2:return t.abrupt("return",t.sent);case 3:case"end":return t.stop()}}),s,this)})))}},{key:"getMyGroupChannelChangeLogs",value:function(n,r){var a=arguments.length>2&&void 0!==arguments[2]?arguments[2]:e.GroupChannelEventSource.REQUEST_CHANNEL_CHANGELOGS;return b(this,void 0,void 0,t().mark((function e(){var s,i,o,u,c,l,h;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return s=Object.assign(Object.assign({},cd),r),Ua((L("string",n)||L("number",n))&&ld(s)).throw(M.invalidParameters),i=new Ed(ee({userId:this._sdkState.userId,ts:"number"==typeof n?n:null,token:"string"==typeof n?n:null,filter:s})),e.next=5,this._requestQueue.send(i);case 5:return o=e.sent,u=o.as(wd),c=u.updatedChannels,l=u.deletedChannelUrls,h=u.hasMore,c.length>0&&this._dispatcher.dispatch(new ru({channels:c,source:a})),l.length>0&&this._dispatcher.dispatch(new au({channelUrls:l,source:a})),e.abrupt("return",{updatedChannels:c,deletedChannelUrls:l,hasMore:h,token:u.token});case 11:case"end":return e.stop()}}),e,this)})))}},{key:"getGroupChannelCount",value:function(e){return b(this,void 0,void 0,t().mark((function n(){var r,a,s,i,o;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return r=Object.assign(Object.assign({},hd),e),Ua(dd(r)).throw(M.invalidParameters),a=new Id({userId:this._sdkState.userId,filter:r}),t.next=5,this._requestQueue.send(a);case 5:return s=t.sent,i=s.as(Nd),o=i.groupChannelCount,t.abrupt("return",o);case 8:case"end":return t.stop()}}),n,this)})))}},{key:"getUnreadItemCount",value:function(e){return b(this,void 0,void 0,t().mark((function n(){var r,a,s,i,o,u,c,l,h,d,f,p,v,_,m,g;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return r=Object.assign(Object.assign({},pd),e),Ua(vd(r)).throw(M.invalidParameters),a=ns.of(this._iid),s=a.sdkState,i=a.requestQueue,o=new Ad({userId:s.userId,filter:r}),t.next=6,i.send(o);case 6:return u=t.sent,c=u.as(Md),l=c.groupChannelUnreadMentionCount,h=c.groupChannelUnreadMessageCount,d=c.groupChannelInvitationCount,f=c.superGroupChannelUnreadMentionCount,p=c.superGroupChannelUnreadMessageCount,v=c.superGroupChannelInvitationCount,_=c.nonSuperGroupChannelUnreadMentionCount,m=c.nonSuperGroupChannelUnreadMessageCount,g=c.nonSuperGroupChannelInvitationCount,t.abrupt("return",ee({groupChannelUnreadMentionCount:l,groupChannelUnreadMessageCount:h,groupChannelInvitationCount:d,superGroupChannelUnreadMentionCount:f,superGroupChannelUnreadMessageCount:p,superGroupChannelInvitationCount:v,nonSuperGroupChannelUnreadMentionCount:_,nonSuperGroupChannelUnreadMessageCount:m,nonSuperGroupChannelInvitationCount:g}));case 9:case"end":return t.stop()}}),n,this)})))}},{key:"getTotalUnreadChannelCount",value:function(){return b(this,void 0,void 0,t().mark((function e(){var n,r,a,s,i,o,u;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n=ns.of(this._iid),r=n.sdkState,a=n.requestQueue,s=new Od({userId:r.userId}),e.next=4,a.send(s);case 4:return i=e.sent,o=i.as(Ud),u=o.unreadCount,e.abrupt("return",u);case 7:case"end":return e.stop()}}),e,this)})))}},{key:"getTotalUnreadMessageCount",value:function(e){return b(this,void 0,void 0,t().mark((function n(){var r,a,s,i,o,u,c,l;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return r=Object.assign(Object.assign({},_d),e),Ua(md(r)).throw(M.invalidParameters),a=ns.of(this._iid),s=a.sdkState,i=a.requestQueue,o=new Rd({userId:s.userId,filter:r}),t.next=6,i.send(o);case 6:return u=t.sent,c=u.as(Ld),l=c.unreadCount,t.abrupt("return",l);case 9:case"end":return t.stop()}}),n,this)})))}},{key:"getTotalScheduledMessageCount",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return b(this,void 0,void 0,t().mark((function n(){var r,a,s,i,o,u,c;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return r=Object.assign(Object.assign({},gd),e),Ua(yd(r)).throw(M.invalidParameters),a=ns.of(this._iid),s=a.requestQueue,i=new Dd(r),t.next=6,s.send(i);case 6:return o=t.sent,u=o.as(Pd),c=u.count,t.abrupt("return",c);case 9:case"end":return t.stop()}}),n,this)})))}},{key:"getSubscribedTotalUnreadMessageCount",value:function(){var e=ns.of(this._iid).subscribedUnreadMessageCount;return e.all>=0?e.all:0}},{key:"getSubscribedCustomTypeTotalUnreadMessageCount",value:function(){var e=0,t=ns.of(this._iid).subscribedUnreadMessageCount;for(var n in t.customTypes)e+=t.customTypes[n];return e}},{key:"getSubscribedCustomTypeUnreadMessageCount",value:function(e){var t;return null!==(t=ns.of(this._iid).subscribedUnreadMessageCount.customTypes[e])&&void 0!==t?t:0}},{key:"createChannel",value:function(e){return b(this,void 0,void 0,t().mark((function n(){var r,a,s,i,o;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return r=Object.assign(Object.assign({},od),e),Ua(ud(r)).throw(M.invalidParameters),r.isPublic||(r.accessCode=null),a=new Gd(Object.assign({userId:this._sdkState.userId},r)),t.next=6,this._requestQueue.send(a);case 6:return s=t.sent,i=s.as(Hd),o=i.channel,t.next=10,this.upsertChannelsToCache([o]);case 10:return t.abrupt("return",o);case 11:case"end":return t.stop()}}),n,this)})))}},{key:"markAsReadAll",value:function(){return b(this,void 0,void 0,t().mark((function e(){var n,r,a,s,i,o;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n=Date.now(),Ua(n-this._markAsReadAllLastSentAt>=1e3).throw(M.markAsReadAllRateLimitExceeded),this._markAsReadAllLastSentAt=n,r=new qd({userId:this._sdkState.userId}),e.next=6,this._requestQueue.send(r);case 6:a=this._groupChannelCache.channels,s=y(a);try{for(s.s();!(i=s.n()).done;)(o=i.value)._updateUnreadMemberState(this._sdkState.userId,n),o._updateUnreadCount(0,0)}catch(e){s.e(e)}finally{s.f()}if(!(a.length>0)){e.next=12;break}return e.next=12,this.upsertChannelsToCache(a);case 12:case"end":return e.stop()}}),e,this)})))}},{key:"markAsReadWithChannelUrls",value:function(e){return b(this,void 0,void 0,t().mark((function n(){var r,a,s,i,o,u,c;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return r=Date.now(),Ua(F("string",e)&&r-this._markAsReadAllLastSentAt>=1e3).throw(M.markAsReadAllRateLimitExceeded),this._markAsReadAllLastSentAt=r,a=new qd({userId:this._sdkState.userId,channelUrls:e}),t.next=6,this._requestQueue.send(a);case 6:s=this._groupChannelCache.channels,i=[],o=y(s);try{for(o.s();!(u=o.n()).done;)c=u.value,e.includes(c.url)&&(c._updateUnreadMemberState(this._sdkState.userId,r),c._updateUnreadCount(0,0),i.push(c))}catch(e){o.e(e)}finally{o.f()}if(!(i.length>0)){t.next=13;break}return t.next=13,this.upsertChannelsToCache(i);case 13:case"end":return t.stop()}}),n,this)})))}},{key:"markAsDelivered",value:function(e){return b(this,void 0,void 0,t().mark((function n(){var r;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,this.getChannel(e);case 2:return r=t.sent,t.next=5,r.markAsDelivered();case 5:case"end":return t.stop()}}),n,this)})))}}],[{key:"of",value:function(e){return Ef[e]}},{key:"clear",value:function(e){Ef[e]&&delete Ef[e]}}]),n}();!function(e){e[e.IDLE=0]="IDLE",e[e.RUNNING=1]="RUNNING",e[e.END=2]="END"}(fd||(fd={}));var Cf=function(e){i(a,e);var n=f(a);function a(e,t){var s;return r(this,a),(s=n.call(this))._worker=null,s._state=fd.IDLE,s._semaphore=null,s._retryCount=0,s._retryLimit=3,s.priority=0,s._worker=t,s}return s(a,[{key:"isIdle",get:function(){return this._state===fd.IDLE}},{key:"isRunning",get:function(){return this._state===fd.RUNNING}},{key:"isDone",get:function(){return this._state===fd.END}},{key:"retryCount",get:function(){return this._retryCount}},{key:"retryLimit",get:function(){return this._retryLimit}},{key:"_run",value:function(e){return b(this,void 0,void 0,t().mark((function n(){var r;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(!this.isRunning){t.next=14;break}return t.prev=1,t.next=4,this._worker(e);case 4:r=t.sent,this._retryCount=0,this.dispatch("progress",r),r.hasNext?this._run(r.nextToken):this.end(),t.next=14;break;case 10:t.prev=10,t.t0=t.catch(1),this.dispatch("error",t.t0),this._retryCount0&&(l=u.map((function(e){return e.createdAt})),(c=this._metadata.range).intersect.apply(c,_(l))?this.extendRange(u):this._metadata={range:new kf({top:Math.min.apply(Math,_(l)),bottom:Math.max.apply(Math,_(l))}),previousComplete:!1}),i.hasNext=u.length>=this._limit&&this._prevSyncLoopCount<1,i.nextToken=this._metadata.range.top,this._metadata.previousComplete=u.length0&&(l=u.map((function(e){return e.createdAt})),(c=this._metadata.range).intersect.apply(c,_(l))?this.extendRange(u):this._metadata={range:new kf({top:Math.min.apply(Math,_(l)),bottom:Math.max.apply(Math,_(l))}),previousComplete:!1}),i.hasNext=u.length>=this._limit&&this._nextSyncLoopCount<1,i.nextToken=this._metadata.range.bottom,v.debug("message background next sync progress",i),t.next=16,this.saveMetadata();case 16:t.next=22;break;case 18:throw t.prev=18,t.t0=t.catch(5),v.debug("message background next sync error",t.t0),t.t0;case 22:return t.abrupt("return",i);case 23:case"end":return t.stop()}}),r,this,[[5,18]])})))})),this._connectionEventContext=p.on((function(e){if(e instanceof Dr)if(e.stateType===Nr.CONNECTED)s.resume();else s.pause()}))}return s(n,[{key:"range",get:function(){var e;return null===(e=this._metadata)||void 0===e?void 0:e.range}},{key:"previousComplete",get:function(){var e;return!!(null===(e=this._metadata)||void 0===e?void 0:e.previousComplete)}},{key:"isWrappingMessages",value:function(e){var t,n;return null===(n=this.range)||void 0===n?void 0:(t=n).includes.apply(t,_(e.map((function(e){return e.createdAt}))))}},{key:"extendRange",value:function(e){var t;this._metadata&&(t=this._metadata.range).extends.apply(t,_(e.map((function(e){return e.createdAt}))))}},{key:"loadMetadata",value:function(e){return b(this,void 0,void 0,t().mark((function n(){var r,a,s;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(this._metadata){t.next=6;break}return r=ns.of(this._iid),a=r.cacheContext,t.next=4,a.preference.get(this._metadataKey);case 4:(s=t.sent)?s.range.bottom0&&void 0!==arguments[0]?arguments[0]:Date.now(),s=ns.of(this._iid),i=s.logger;s.connectionManager.isConnected&&(i.debug("message background sync resume()"),this._prevSyncLoopCount=this._nextSyncLoopCount=0,this._metadata&&this._metadata.previousComplete||this._prevSync.start(null!==(t=null===(e=this._metadata)||void 0===e?void 0:e.range.top)&&void 0!==t?t:a),this._nextSync.start(null!==(r=null===(n=this._metadata)||void 0===n?void 0:n.range.bottom)&&void 0!==r?r:a))}},{key:"pause",value:function(){ns.of(this._iid).logger.debug("message background sync stop()"),this._prevSync.stop(),this._nextSync.stop()}},{key:"close",value:function(){this.ref--,this.ref<=0&&(this.ref=0,this.pause(),this._connectionEventContext.close(),delete Sf[this._iid][this._channel.url])}}],[{key:"of",value:function(e,t){return Sf[e]||(Sf[e]={}),Sf[e][t.url]||(Sf[e][t.url]=new n({_iid:e,channel:t})),Sf[e][t.url].ref++,Sf[e][t.url]}},{key:"clear",value:function(e,t){Sf[e]&&Sf[e][t]&&(Sf[e][t].close(),delete Sf[e])}}]),n}(),Nf={},Af=function(){function n(a){var s=this,i=a._iid,o=a.channel;r(this,n),this._sync=null,this._connectionEventContext=null,this.ref=0,this._metadata=null,this._iid=i,this._channel=o;var u,c,l=ns.of(this._iid),h=l.logger,d=l.sdkState,f=l.dispatcher;this._metadataKey=(u=d.userId,c=o.url,"sendbird:".concat(u,"@groupchannel/").concat(c,"/message/changelogs.meta"));var p=function(e,t){return"sendbird:".concat(e,"@groupchannel/").concat(t,"/message/changelogs")}(d.userId,this._channel.url);this._sync=new Cf(p,(function(){return b(s,void 0,void 0,t().mark((function n(){var r,a,s,i,o,u,c,l;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return a={hasNext:!0,nextToken:0},t.next=3,this.loadMetadata();case 3:return h.debug("message changelog sync from",null===(r=this._metadata)||void 0===r?void 0:r.token),t.prev=4,s=vi.of(this._iid),t.next=8,s.getMessageChangelogs(this._channel.url,this._channel.channelType,this._metadata.token,{replyType:e.ReplyType.ALL,includeReactions:!0,includeThreadInfo:!0,includeMetaArray:!0,includeParentMessageInfo:!0},e.MessageEventSource.SYNC_MESSAGE_CHANGELOGS);case 8:return i=t.sent,o=i.updatedMessages,u=i.deletedMessageIds,c=i.hasMore,l=i.token,a.hasNext=c,a.nextToken=l,(o.length>0||u.length>0)&&(this._metadata.token=l),h.debug("message changelog sync progress",a),t.next=19,this.saveMetadata();case 19:t.next=28;break;case 21:if(t.prev=21,t.t0=t.catch(4),h.debug("message changelog sync error",t.t0),!(t.t0 instanceof M&&t.t0.isInvalidTokenError)){t.next=27;break}return t.next=27,this.clearMetadata();case 27:throw t.t0;case 28:return t.abrupt("return",a);case 29:case"end":return t.stop()}}),n,this,[[4,21]])})))})),this._connectionEventContext=f.on((function(e){if(e instanceof Dr)if(e.stateType===Nr.CONNECTED)s.resume();else s.pause()}))}return s(n,[{key:"loadMetadata",value:function(){return b(this,void 0,void 0,t().mark((function e(){var n,r,a,s;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(this._metadata){e.next=6;break}return n=ns.of(this._iid),r=n.cacheContext,a=n.firstConnectedAt,e.next=4,r.preference.get(this._metadataKey);case 4:s=e.sent,this._metadata={token:s?s.token:a};case 6:return e.abrupt("return",this._metadata);case 7:case"end":return e.stop()}}),e,this)})))}},{key:"saveMetadata",value:function(){return b(this,void 0,void 0,t().mark((function e(){var n,r;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!this._metadata){e.next=5;break}return n=ns.of(this._iid),r=n.cacheContext,e.next=4,r.preference.set(this._metadataKey,this._metadata);case 4:return e.abrupt("return",!0);case 5:return e.abrupt("return",!1);case 6:case"end":return e.stop()}}),e,this)})))}},{key:"clearMetadata",value:function(){return b(this,void 0,void 0,t().mark((function e(){var n,r;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n=ns.of(this._iid),r=n.cacheContext,e.next=3,r.preference.remove(this._metadataKey);case 3:this._metadata=null;case 4:case"end":return e.stop()}}),e,this)})))}},{key:"resume",value:function(){var e=ns.of(this._iid),t=e.logger;e.connectionManager.isConnected&&(t.debug("message changelog sync resume()"),this._sync.start(0))}},{key:"pause",value:function(){var e=ns.of(this._iid),t=e.logger;e.connectionManager.isConnected&&(t.debug("message changelog sync pause()"),this._sync.stop())}},{key:"close",value:function(){this.ref--,this.ref<=0&&(this.ref=0,this.pause(),this._connectionEventContext.close(),delete Nf[this._iid][this._channel.url])}}],[{key:"of",value:function(e,t){return Nf[e]||(Nf[e]={}),Nf[e][t.url]||(Nf[e][t.url]=new n({_iid:e,channel:t})),Nf[e][t.url].ref++,Nf[e][t.url]}},{key:"clear",value:function(e,t){Nf[e]&&Nf[e][t]&&(Nf[e][t].close(),delete Nf[e])}}]),n}(),Mf={},Of=function(){function e(n){var a=this,s=n._iid,i=n.channel,o=n.hasPollMessage;r(this,e),this._sync=null,this.ref=0,this._metadata=null,this._iid=s,this._channel=i;var u,c,l=ns.of(this._iid),h=l.logger,d=l.sdkState,f=l.dispatcher;this._metadataKey=(u=d.userId,c=i.url,"sendbird:".concat(u,"@groupchannel/").concat(c,"/poll/changelogs.meta"));var p=function(e,t){return"sendbird:".concat(e,"@groupchannel/").concat(t,"/poll/changelogs")}(d.userId,this._channel.url);this._sync=new Cf(p,(function(){return b(a,void 0,void 0,t().mark((function e(){var n,r,a,s,i,u,c,l,d;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return r={hasNext:!0,nextToken:0},e.next=3,this.loadMetadata();case 3:if(h.debug("poll changelog sync from",null===(n=this._metadata)||void 0===n?void 0:n.token),e.t0=!this._metadata||!this._metadata.token,!e.t0){e.next=9;break}return e.next=8,o();case 8:e.t0=!e.sent;case 9:if(!e.t0){e.next=12;break}return a={hasNext:!1,nextToken:0},e.abrupt("return",a);case 12:return this._metadata||(s=ns.of(this._iid),i=s.firstConnectedAt,this._metadata={token:i}),e.prev=13,u=Ki.of(this._iid),e.next=17,u.getPollChangeLogs(this._channel.url,this._channel.channelType,this._metadata.token);case 17:return c=e.sent,l=c.hasMore,d=c.token,r.hasNext=l,r.nextToken=d,this._metadata.token=d,h.debug("poll changelog sync progress",r),e.next=26,this.saveMetadata();case 26:e.next=35;break;case 28:if(e.prev=28,e.t1=e.catch(13),h.debug("poll changelog sync error",e.t1),!(e.t1 instanceof M&&e.t1.isInvalidTokenError)){e.next=34;break}return e.next=34,this.clearMetadata();case 34:throw e.t1;case 35:return e.abrupt("return",r);case 36:case"end":return e.stop()}}),e,this,[[13,28]])})))})),this._connectionEventContext=f.on((function(e){if(e instanceof Dr)if(e.stateType===Nr.CONNECTED)a.resume();else a.pause()}))}return s(e,[{key:"loadMetadata",value:function(){return b(this,void 0,void 0,t().mark((function e(){var n,r,a;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(this._metadata){e.next=6;break}return n=ns.of(this._iid),r=n.cacheContext,e.next=4,r.preference.get(this._metadataKey);case 4:a=e.sent,this._metadata=a?{token:a.token}:null;case 6:case"end":return e.stop()}}),e,this)})))}},{key:"saveMetadata",value:function(){return b(this,void 0,void 0,t().mark((function e(){var n,r;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!this._metadata){e.next=4;break}return n=ns.of(this._iid),r=n.cacheContext,e.next=4,r.preference.set(this._metadataKey,this._metadata);case 4:case"end":return e.stop()}}),e,this)})))}},{key:"clearMetadata",value:function(){return b(this,void 0,void 0,t().mark((function e(){var n,r;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n=ns.of(this._iid),r=n.cacheContext,e.next=3,r.preference.remove(this._metadataKey);case 3:this._metadata=null;case 4:case"end":return e.stop()}}),e,this)})))}},{key:"resume",value:function(){ns.of(this._iid).logger.debug("poll changelog sync resume()"),this._sync.start(0)}},{key:"pause",value:function(){ns.of(this._iid).logger.debug("poll changelog sync pause()"),this._sync.stop()}},{key:"close",value:function(){this.ref--,this.ref<=0&&(this.ref=0,this.pause(),this._connectionEventContext.close(),delete Mf[this._iid][this._channel.url])}}],[{key:"of",value:function(t,n,r){return Mf[t]||(Mf[t]={}),Mf[t][n.url]||(Mf[t][n.url]=new e({_iid:t,channel:n,hasPollMessage:r})),Mf[t][n.url].ref++,Mf[t][n.url]}}]),e}(),Uf=function(e){i(n,e);var t=f(n);function n(e){var a,s,i,o,u,c,l;return r(this,n),(a=t.call(this)).method=B.GET,a.path="".concat(Fs(e.channelType),"/").concat(e.channelUrl,"/messages_gap"),a.params=ee({prev_start_ts:e.prevStart,prev_end_ts:e.prevEnd,prev_cache_count:e.prevCount,next_start_ts:e.nextStart,next_end_ts:e.nextEnd,next_cache_count:e.nextCount,huge_gap_threshold:null!==(s=e.threshold)&&void 0!==s?s:null,reverse:!0,custom_types:null!==(i=e.customTypes)&&void 0!==i?i:["*"],message_type:null!==(o=e.messageType)&&void 0!==o?o:null,include_reactions:null===(u=e.includeReactions)||void 0===u||u,with_sorted_meta_array:null===(c=e.includeMetaArray)||void 0===c||c,show_subchannel_messages_only:null!==(l=e.showSubchannelMessagesOnly)&&void 0!==l&&l,include_poll_details:!0,checking_continuous_messages:e.checkingContinuousMessages}),a}return s(n)}(ne),Rf=function(e){i(n,e);var t=f(n);function n(e,a){var s,i,o,u,c,l,h;return r(this,n),(s=t.call(this,e,a)).isHugeGap=a.is_huge_gap,s.prevMessages=(null!==(i=a.prev_messages)&&void 0!==i?i:[]).map((function(t){return Ds(e,t)})),s.prevHasMore=null!==(o=a.prev_hasmore)&&void 0!==o&&o,s.isContinuousPrevMessages=null!==(u=a.is_continuous_prev_messages)&&void 0!==u&&u,s.nextMessages=(null!==(c=a.next_messages)&&void 0!==c?c:[]).map((function(t){return Ds(e,t)})),s.nextHasmore=null!==(l=a.next_hasmore)&&void 0!==l&&l,s.isContinuousNextMessages=null!==(h=a.is_continuous_next_messages)&&void 0!==h&&h,s}return s(n)}(re),Lf=function(t,n){var r,a;switch(n){case e.GroupChannelListOrder.LATEST_LAST_MESSAGE:return null!==(a=null===(r=t.lastMessage)||void 0===r?void 0:r.createdAt)&&void 0!==a?a:t.createdAt;case e.GroupChannelListOrder.CHRONOLOGICAL:return t.createdAt;case e.GroupChannelListOrder.CHANNEL_NAME_ALPHABETICAL:return t.name}return null},Df=function(e,t){return e.findIndex((function(e){return e.isIdentical(t)}))},Pf=function(e,t,n){if(e.length>0){for(var r=Df(e,t),a=0,s=e.length-1,i=Math.floor((a+s)/2);a0)s=i,i=Math.floor((a+s)/2);else{if(!(o<0))return{place:i,oldPosition:r};a=i+1,i=Math.floor((a+s)/2)}}return{place:Ff(e[i],t,n)>=0?i:i+1,oldPosition:r}}return{place:e.length,oldPosition:-1}},Ff=function(t,n,r){switch(r){case e.GroupChannelListOrder.LATEST_LAST_MESSAGE:return t.lastMessage&&n.lastMessage?n.lastMessage.createdAt-t.lastMessage.createdAt:t.lastMessage?-1:n.lastMessage?1:n.createdAt-t.createdAt;case e.GroupChannelListOrder.CHRONOLOGICAL:return n.createdAt-t.createdAt;case e.GroupChannelListOrder.CHANNEL_NAME_ALPHABETICAL:var a=t.name.localeCompare(n.name);return 0===a?t.createdAt-n.createdAt:a}},Gf=function(e,t){return t instanceof Es?e.findIndex((function(e){return e instanceof Es&&t.isIdentical(e)})):e.findIndex((function(e){return e.isIdentical(t)}))},Hf=function(e,t){return e.findIndex((function(e){return e.messageId===t}))},qf=function(e,t){if(e.length>0){for(var n=0,r=e.length-1,a=Math.floor((n+r)/2);n0)r=a,a=Math.floor((n+r)/2);else{if(!(s<0))return a;n=a+1,a=Math.floor((n+r)/2)}}return e[a].createdAt>t.createdAt?a:a+1}return e.length},jf=6e5;e.MessageCollectionInitPolicy=void 0,(e.MessageCollectionInitPolicy||(e.MessageCollectionInitPolicy={})).CACHE_AND_REPLACE_BY_API="cache_and_replace_by_api";var zf,Vf,Bf,Qf=function(){function e(){r(this,e)}return s(e,[{key:"_invokeResponse",value:function(e,n,r){var a=this;ua((function(){return b(a,void 0,void 0,t().mark((function a(){return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:t.t0=e,t.next="local"===t.t0?3:"remote"===t.t0?5:7;break;case 3:return this._onCacheResult(n,r),t.abrupt("break",7);case 5:return this._onApiResult(n,r),t.abrupt("break",7);case 7:case"end":return t.stop()}}),a,this)})))}))}},{key:"onCacheResult",value:function(e){return this._onCacheResult=e,this}},{key:"onApiResult",value:function(e){return this._onApiResult=e,this}}]),e}(),Kf=function(){function n(a,s){var i=this,o=s.channel,u=s.filter,c=s.startingPoint,l=s.limit;r(this,n),this._channel=null,this._messages=[],this._unsentMessages=[],this._backgroundSync=null,this._changelogSync=null,this._pollChangelogSync=null,this._checkMyMutedStateTimer=null,this._iid=a,this._key="mc-".concat(Y()),this.filter=null!=u?u:new po,this._channel=o,this._syncRange=new kf({}),this._hasPrevious=!0,this._hasNext=!0,this._startingPoint="number"==typeof c?c:Date.now()+jf,this._limit=l||co;var h=wf.of(this._iid);h.subscribeGroupChannelEvent(this._key,{onUpdate:function(n,r,a){var s=Df(n,i._channel);if(s>=0)switch(ua((function(){return b(i,void 0,void 0,t().mark((function e(){var a,i;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:i=new xf(r),this._channel=n[s],nu(r)&&(null===(a=this._handler)||void 0===a?void 0:a.onChannelUpdated)&&this._handler.onChannelUpdated(i,this.channel);case 3:case"end":return e.stop()}}),e,this)})))})),r){case e.GroupChannelEventSource.EVENT_CHANNEL_UPDATED:var o=!1;for(var u in i._messages){if(i._messages[u].createdAt>=i._channel.messageOffsetTimestamp){o=!0;var c=parseInt(u);if(c>0){var l=i._messages.splice(0,c);i._removeMessagesFromView(l.map((function(e){return e.messageId})),e.MessageEventSource.EVENT_MESSAGE_OFFSET_UPDATED)}break}}!o&&i._messages.length>0&&i._removeMessagesFromView(i._messages.map((function(e){return e.messageId})),e.MessageEventSource.EVENT_MESSAGE_OFFSET_UPDATED);break;case e.GroupChannelEventSource.EVENT_CHANNEL_UNMUTED:var h=a;ns.of(i._iid).sdkState.userId===h&&i._clearCheckMyMutedTimer();break;case e.GroupChannelEventSource.EVENT_CHANNEL_MUTED:var d=a;ns.of(i._iid).sdkState.userId===d&&-1!==i.channel._myMutedRemainingTime&&i._startCheckMyMutedTimer(i.channel._myMutedRemainingTime);break;case e.GroupChannelEventSource.EVENT_CHANNEL_LEFT:i.channel.isPublic&&i._clearCheckMyMutedTimer()}},onRemove:function(e,n){e.indexOf(i.channel.url)>=0&&(i._clearCheckMyMutedTimer(),ua((function(){return b(i,void 0,void 0,t().mark((function e(){var r,a;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:a=new xf(n),(null===(r=this._handler)||void 0===r?void 0:r.onChannelDeleted)&&this._handler.onChannelDeleted(a,this.channel.url);case 2:case"end":return e.stop()}}),e,this)})))})))}}),h.subscribeMessageEvent(this._key,{onUpdate:function(t,n){var r,a=[],s=[],o=y(t);try{for(o.s();!(r=o.n()).done;){var u=r.value;u.channelUrl===i._channel.url&&(i.filter.match(u)?a.push(u):s.push(u.messageId))}}catch(e){o.e(e)}finally{o.f()}if($s(n)){if(a.length>0)switch(n){case e.MessageEventSource.EVENT_MESSAGE_SENT_FAILED:case e.MessageEventSource.EVENT_MESSAGE_SENT_SUCCESS:case e.MessageEventSource.EVENT_MESSAGE_UPDATED:case e.MessageEventSource.EVENT_MESSAGE_THREADINFO_UPDATED:case e.MessageEventSource.EVENT_MESSAGE_REACTION_UPDATED:case e.MessageEventSource.SYNC_MESSAGE_CHANGELOGS:i._updateMessagesToView(a,n);break;case e.MessageEventSource.EVENT_MESSAGE_SENT_PENDING:i._addMessagesToView(a,n);break;case e.MessageEventSource.EVENT_MESSAGE_RECEIVED:i.hasNext||i._addMessagesToView(a,n);break;case e.MessageEventSource.SYNC_MESSAGE_FILL:i._addMessagesToView(a,n)}s.length>0&&i._removeMessagesFromView(s,n)}},onRemove:function(e,t){i._removeMessagesFromView(e,t)},onRemoveUnsent:function(e,t){i._removeUnsentMessageFromView(e,t)},onPollChangeLogUpdate:function(e,t){i._updatePollsToView(e,t)},onPollUpdate:function(e,t){i._applyPollUpdateEventToView(e,t)},onPollVote:function(e,t){i._applyPollVoteEventToView(e,t)}});var d=ns.of(this._iid),f=d.cacheContext,p=d.dispatcher,v=d.logger;this._channel._updateMessageCollectionLastAccessedAt(),p.dispatch(new ru({channels:[this._channel],source:e.GroupChannelEventSource.CHANNEL_LASTACCESSEDAT_UPDATED})),!this._channel.isSuper&&f.localCacheEnabled&&(this._backgroundSync=If.of(this._iid,this._channel),this._backgroundSync.resume(this._startingPoint)),this._changelogSync=Af.of(this._iid,this._channel),this._changelogSync.resume(),this._pollChangelogSync=Of.of(this._iid,this._channel,this._hasPollMessage.bind(this)),this._pollChangelogSync.resume(),this._prevFill=new Cf(this._key,(function(n){return b(i,void 0,void 0,t().mark((function r(){var a,s,i,o,u;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,this._getRemoteMessages(n,{prevLimit:this._limit,source:e.MessageEventSource.SYNC_MESSAGE_FILL,checkingContinuousMessages:f.localCacheEnabled});case 2:if(s=t.sent,i=s.messages,o=s.isContinuousMessages,!(i.length>0)){t.next=10;break}return u=Math.min.apply(Math,_(i.map((function(e){return e.createdAt})))),this._syncRange.extends(u),o&&(null===(a=this._backgroundSync)||void 0===a||a.range.extends(u)),t.abrupt("return",{hasNext:i.length>=this._limit&&this.viewTop0)){t.next=10;break}return u=Math.max.apply(Math,_(i.map((function(e){return e.createdAt})))),this._syncRange.extends(u),o&&(null===(a=this._backgroundSync)||void 0===a||a.range.extends(u)),t.abrupt("return",{hasNext:!(i.length>=this._limit&&this._hasNext)||this.viewBottom>u,nextToken:this._syncRange.bottom});case 10:return t.abrupt("return",{hasNext:!1,nextToken:0});case 11:case"end":return t.stop()}}),r,this)})))})),this._connectionEventContext=p.on((function(n){if(n instanceof Dr)switch(n.stateType){case Nr.CONNECTED:i._refreshChannel(e.GroupChannelEventSource.SYNC_CHANNEL_CHANGELOGS),ca((function(){return b(i,void 0,void 0,t().mark((function e(){var n;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this.channel.getMyMutedInfo();case 2:(n=e.sent).isMuted&&-1!==n.remainingDuration&&this._startCheckMyMutedTimer(n.remainingDuration);case 4:case"end":return e.stop()}}),e,this)})))})),v.debug("check huge gap"),i._checkHugeGap();break;case Nr.LOGOUT:i.dispose();break;default:i._clearCheckMyMutedTimer(),i._prevFill.stop(),i._nextFill.stop()}})),ns.of(this._iid).statLogCollector.put(new ja({type:te.FEATURE_LOCALCACHE,data:{use_local_cache:f.localCacheEnabled,collection_interface:{message:!0}}}))}return s(n,[{key:"channel",get:function(){return this._channel}},{key:"succeededMessages",get:function(){return _(this._messages)}},{key:"failedMessages",get:function(){return this._unsentMessages.filter((function(t){return t.sendingStatus===e.SendingStatus.FAILED}))}},{key:"pendingMessages",get:function(){return this._unsentMessages.filter((function(t){return t.sendingStatus===e.SendingStatus.PENDING}))}},{key:"hasPrevious",get:function(){return this._hasPrevious}},{key:"hasNext",get:function(){return this._hasNext}},{key:"viewTop",get:function(){return Math.min.apply(Math,_(this._messages.map((function(e){return e.createdAt}))).concat([Number.MAX_SAFE_INTEGER]))}},{key:"viewBottom",get:function(){return Math.max.apply(Math,_(this._messages.map((function(e){return e.createdAt}))).concat([0]))}},{key:"setMessageCollectionHandler",value:function(e){this._handler=e}},{key:"_filterUnderOffsetMessage",value:function(e){return e}},{key:"_addMessagesToView",value:function(n,r){var a,s=this,i=this._filterUnderOffsetMessage(n),o=[],u=[],c=y(i);try{for(c.s();!(a=c.n()).done;){var l=a.value;if(r===e.MessageEventSource.SYNC_MESSAGE_FILL){if(l.messageId>0){if(Gf(this._messages,l)<0){Gf(this._unsentMessages,l)<0&&o.push(l);var h=qf(this._messages,l);this._messages.splice(h,0,l)}}else if(l instanceof Es){Gf(this._unsentMessages,l)<0&&Gf(this._messages,l)<0&&(this._unsentMessages.push(l),o.push(l))}}else if(l.messageId>0){var d=Gf(this._messages,l);if(d<0){var f=Gf(this._unsentMessages,l);f<0?o.push(l):(this._unsentMessages.splice(f,1),u.push(l));var p=qf(this._messages,l);this._messages.splice(p,0,l)}else u.push(l),this._messages[d]=l;if(l.updatedAt>0){var v=this._updateChildMessagesInView(l);u.push.apply(u,_(v))}}else if(l instanceof Es){var m=Gf(this._unsentMessages,l);m<0?Gf(this._messages,l)<0&&(this._unsentMessages.push(l),o.push(l)):(u.push(l),this._unsentMessages[m]=l)}}}catch(e){c.e(e)}finally{c.f()}$s(r)&&ua((function(){return b(s,void 0,void 0,t().mark((function e(){var n,a,s;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:s=new Tf(r),o.length>0&&(null===(n=this._handler)||void 0===n||n.onMessagesAdded(s,this.channel,o)),u.length>0&&(null===(a=this._handler)||void 0===a||a.onMessagesUpdated(s,this.channel,u));case 3:case"end":return e.stop()}}),e,this)})))}))}},{key:"_updateChildMessagesInView",value:function(e){var t=[];return this._messages.forEach((function(n){n.applyParentMessage(e)&&t.push(n)})),t}},{key:"_updatePollsToView",value:function(e,n){var r,a=this,s=[],i=y(e);try{for(i.s();!(r=i.n()).done;){var o=r.value,u=Hf(this._messages,o.messageId);if(u>=0){var c=this._messages[u];c&&c.applyPoll(o),s.push(c)}}}catch(e){i.e(e)}finally{i.f()}return s.length>0&&$s(n)&&ua((function(){return b(a,void 0,void 0,t().mark((function e(){var r,a;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:a=new Tf(n),s.length>0&&(null===(r=this._handler)||void 0===r||r.onMessagesUpdated(a,this.channel,s));case 2:case"end":return e.stop()}}),e,this)})))})),s}},{key:"_applyPollUpdateEventToView",value:function(e,n){var r=this,a=Hf(this._messages,e.messageId);if(a>=0){var s=this._messages[a];s&&s.isUserMessage()&&s.poll&&s.poll.applyPollUpdateEvent(e)&&$s(n)&&ua((function(){return b(r,void 0,void 0,t().mark((function e(){var r,a;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:a=new Tf(n),null===(r=this._handler)||void 0===r||r.onMessagesUpdated(a,this.channel,[s]);case 2:case"end":return e.stop()}}),e,this)})))}))}}},{key:"_applyPollVoteEventToView",value:function(e,n){var r=this,a=Hf(this._messages,e.messageId);if(a>=0){var s=this._messages[a];s&&s.isUserMessage()&&s.poll&&s.poll.applyPollVoteEvent(e)&&$s(n)&&ua((function(){return b(r,void 0,void 0,t().mark((function e(){var r,a;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:a=new Tf(n),null===(r=this._handler)||void 0===r||r.onMessagesUpdated(a,this.channel,[s]);case 2:case"end":return e.stop()}}),e,this)})))}))}}},{key:"_updateMessagesToView",value:function(e,n){var r,a=this,s=[],i=[],o=y(e);try{for(o.s();!(r=o.n()).done;){var u=r.value;if(u.messageId>0){var c=Gf(this._messages,u);if(c>=0)s.push(u),this._messages[c]=u;else{var l=Gf(this._unsentMessages,u);if(l>=0){var h=this._unsentMessages.splice(l,1);if(this.hasNext&&h.length>0)i.push(h[0]);else{s.push(u);var d=qf(this._messages,u);this._messages.splice(d,0,u)}}}}else if(u instanceof Es){var f=Gf(this._unsentMessages,u);f>=0&&(s.push(u),this._unsentMessages[f]=u)}}}catch(e){o.e(e)}finally{o.f()}return $s(n)&&ua((function(){return b(a,void 0,void 0,t().mark((function e(){var r,a,o;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:o=new Tf(n),s.length>0?null===(r=this._handler)||void 0===r||r.onMessagesUpdated(o,this.channel,s):i.length>0&&(null===(a=this._handler)||void 0===a||a.onMessagesDeleted(o,this.channel,[],i));case 2:case"end":return e.stop()}}),e,this)})))})),s}},{key:"_removeMessagesFromView",value:function(e,n){var r,a=this,s=[],i=[],o=y(e);try{var u=function(){var e=r.value,t=a._messages.findIndex((function(t){return t.messageId===e}));if(t>=0){var n=a._messages[t];s.push(n.messageId),i.push(n),a._messages.splice(t,1)}};for(o.s();!(r=o.n()).done;)u()}catch(e){o.e(e)}finally{o.f()}return $s(n)&&i.length>0&&ua((function(){return b(a,void 0,void 0,t().mark((function e(){var r,a;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:a=new Tf(n),null===(r=this._handler)||void 0===r||r.onMessagesDeleted(a,this.channel,s,i);case 2:case"end":return e.stop()}}),e,this)})))})),s}},{key:"_removeUnsentMessageFromView",value:function(e,t){var n=this._unsentMessages.findIndex((function(t){return t.reqId===e}));n>=0&&this._unsentMessages.splice(n,1)}},{key:"_getLocalMessages",value:function(e,n){var r=n.prevLimit,a=void 0===r?0:r,s=n.nextLimit,i=void 0===s?0:s;return b(this,void 0,void 0,t().mark((function n(){var r,s,o,u,c;return t().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:if(r=wf.of(this._iid),!(a>0)){n.next=7;break}return n.next=4,r.getMessagesFromCache(this._channel.url,e,"prev",this.filter,a);case 4:n.t0=n.sent,n.next=8;break;case 7:n.t0=[];case 8:if(s=n.t0,!(i>0)){n.next=15;break}return n.next=12,r.getMessagesFromCache(this._channel.url,e,"next",this.filter,i);case 12:n.t1=n.sent,n.next=16;break;case 15:n.t1=[];case 16:if(o=n.t1,!(s.length>0&&o.length>0)){n.next=27;break}u=s.map((function(e){return e.messageId})),n.t2=t().keys(o);case 20:if((n.t3=n.t2()).done){n.next=27;break}if(c=n.t3.value,!u.includes(o[c].messageId)){n.next=25;break}return o.splice(parseInt(c),1),n.abrupt("break",27);case 25:n.next=20;break;case 27:return n.abrupt("return",[].concat(_(s),_(o)).sort((function(e,t){return t.createdAt-e.createdAt})));case 28:case"end":return n.stop()}}),n,this)})))}},{key:"_getRemoteMessages",value:function(n,r){var a=r.prevLimit,s=void 0===a?0:a,i=r.nextLimit,o=void 0===i?0:i,u=r.source,c=void 0===u?e.MessageEventSource.REQUEST_MESSAGE:u,l=r.reverse,h=void 0!==l&&l,d=r.checkingContinuousMessages,f=void 0!==d&&d;return b(this,void 0,void 0,t().mark((function e(){var r;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(r=vi.of(this._iid),!(s>0||o>0)){e.next=7;break}return e.next=4,r._getMessagesByTimestampForCollection(this._channel.url,this._channel.channelType,n,Object.assign(Object.assign({},this.filter),{isInclusive:!0,reverse:h,prevResultSize:s,nextResultSize:o,includeMetaArray:!0,includeReactions:!0,includeThreadInfo:!0,includeParentMessageInfo:!0}),c,f);case 4:e.t0=e.sent,e.next=8;break;case 7:e.t0={messages:[],isContinuousMessages:!1};case 8:return e.abrupt("return",e.t0);case 9:case"end":return e.stop()}}),e,this)})))}},{key:"_checkHugeGap",value:function(){var n;return b(this,void 0,void 0,t().mark((function r(){var a,s,i,o,u,c,l,h,d,f,p,v,m,g,y,k,w,C,x,T,S=this;return t().wrap((function(r){for(;;)switch(r.prev=r.next){case 0:if(!(this._messages.length>0)){r.next=16;break}return a=this._syncRange.top,s=this.viewTop,i=this._syncRange.bottom,o=this.hasNext?this.viewBottom:Number.MAX_SAFE_INTEGER,u=wf.of(this._iid),r.next=8,u.getCachedMessageCountBetween(this._channel.url,this.filter,s,a);case 8:return c=r.sent,r.next=11,u.getCachedMessageCountBetween(this._channel.url,this.filter,i,o);case 11:return l=r.sent,r.next=14,oa((function(){return b(S,void 0,void 0,t().mark((function n(){var r,u,h,d,f,p,v,m,g,y,k,E,w,C,x,T,S,I,N,A,M,O=this;return t().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return u=ns.of(this._iid),h=u.dispatcher,d=u.requestQueue,f=u.cacheContext,p=new Uf(Object.assign({channelUrl:this._channel.url,channelType:this._channel.channelType,prevStart:s,prevEnd:a,prevCount:c,nextStart:i,nextEnd:o,nextCount:l,checkingContinuousMessages:f.localCacheEnabled},this.filter)),n.next=4,d.send(p);case 4:v=n.sent,m=v.as(Rf),g=m.isHugeGap,y=m.prevMessages,k=void 0===y?[]:y,E=m.prevHasMore,w=m.isContinuousPrevMessages,C=m.nextMessages,x=void 0===C?[]:C,T=m.nextHasmore,S=m.isContinuousNextMessages,g?ua((function(){return b(O,void 0,void 0,t().mark((function e(){var n;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:null===(n=this._handler)||void 0===n||n.onHugeGapDetected();case 1:case"end":return e.stop()}}),e,this)})))})):(this._hasPrevious=E,this._hasNext=T,I=this.viewTop,N=this.viewBottom,A=Math.min.apply(Math,[Number.MAX_SAFE_INTEGER,I].concat(_(k.map((function(e){return e.createdAt}))))),M=Math.max.apply(Math,[0,N].concat(_(x.map((function(e){return e.createdAt}))))),h.dispatch(new ei({messages:k,source:e.MessageEventSource.SYNC_MESSAGE_FILL})),h.dispatch(new ei({messages:x,source:e.MessageEventSource.SYNC_MESSAGE_FILL})),this._syncRange.extends(A,M),(w||S)&&(null===(r=this._backgroundSync)||void 0===r||r.range.extends(A,M)),IM&&this._nextFill.start(M));case 7:case"end":return n.stop()}}),n,this)})))}),1);case 14:r.next=31;break;case 16:return h=ns.of(this._iid),d=h.cacheContext,f=Math.floor(this._limit/2),p=Date.now(),r.prev=19,r.next=22,this._getRemoteMessages(p,{prevLimit:f,nextLimit:f,source:e.MessageEventSource.SYNC_MESSAGE_FILL,checkingContinuousMessages:d.localCacheEnabled});case 22:if(v=r.sent,m=v.messages,g=v.isContinuousMessages,m.length>0){for(k=m.map((function(e){return e.createdAt})),w=0,C=0,x=0;x=p&&C++;this._hasPrevious=w>=f,this._hasNext=C>=f,(y=this._syncRange).extends.apply(y,_(k)),g&&(null===(n=this._backgroundSync)||void 0===n||n.range.extends(this._syncRange.top,this._syncRange.bottom)),this._addMessagesToView(m,e.MessageEventSource.SYNC_MESSAGE_FILL)}else this._hasPrevious=!1,this._hasNext=!1;r.next=31;break;case 28:r.prev=28,r.t0=r.catch(19),r.t0 instanceof M&&r.t0.code===E.NOT_FOUND_IN_DATABASE&&(this._hasPrevious=!1,this._hasNext=!1);case 31:case"end":return r.stop()}}),r,this,[[19,28]])})))}},{key:"_loadUnsentMessages",value:function(){return b(this,void 0,void 0,t().mark((function e(){var n;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n=wf.of(this._iid),e.next=3,n.getUnsentMessagesFromCache(this._channel.url,this.filter);case 3:this._unsentMessages=e.sent;case 4:case"end":return e.stop()}}),e,this)})))}},{key:"_hasPollMessage",value:function(){return b(this,void 0,void 0,t().mark((function e(){var n;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n=wf.of(this._iid),e.next=3,n.getPollMessagesFromCache(this._channel.url,Date.now()+jf,this.filter,1);case 3:if(!(e.sent.length>0)){e.next=6;break}return e.abrupt("return",!0);case 6:return e.abrupt("return",!1);case 7:case"end":return e.stop()}}),e,this)})))}},{key:"_refreshChannel",value:function(e){wf.of(this._iid).refreshChannel(this.channel.url,!0,e)}},{key:"_startCheckMyMutedTimer",value:function(n){var r=this;this._clearCheckMyMutedTimer(),this._checkMyMutedStateTimer=setTimeout((function(){return b(r,void 0,void 0,t().mark((function n(){var r,a,s,i;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return this._checkMyMutedStateTimer=null,a=!0,t.prev=2,t.next=5,this._channel.getMyMutedInfo();case 5:s=t.sent,a=!s.isMuted,t.next=12;break;case 9:t.prev=9,t.t0=t.catch(2),a=!0;case 12:return t.prev=12,a&&(this.channel.myMutedState=e.MutedState.UNMUTED,i=new xf(e.GroupChannelEventSource.EVENT_CHANNEL_UNMUTED),null===(r=this._handler)||void 0===r||r.onChannelUpdated(i,this.channel)),t.finish(12);case 15:case"end":return t.stop()}}),n,this,[[2,9,12,15]])})))}),n+1e3)}},{key:"_clearCheckMyMutedTimer",value:function(){this._checkMyMutedStateTimer&&(clearTimeout(this._checkMyMutedStateTimer),this._checkMyMutedStateTimer=null)}},{key:"initialize",value:function(n){var r=this,a=new Qf;this._messages=[],this._unsentMessages=[],this._syncRange=new kf({}),this._hasNext=!0,this._hasPrevious=!0,this._refreshChannel(e.GroupChannelEventSource.REFRESH_CHANNEL),ca((function(){return b(r,void 0,void 0,t().mark((function e(){var n;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this.channel.getMyMutedInfo();case 2:(n=e.sent).isMuted&&-1!==n.remainingDuration&&this._startCheckMyMutedTimer(n.remainingDuration);case 4:case"end":return e.stop()}}),e,this)})))}));var s=Math.floor(this._limit/2);if(n===e.MessageCollectionInitPolicy.CACHE_AND_REPLACE_BY_API)this._getLocalMessages(this._startingPoint,{prevLimit:s,nextLimit:s}).then((function(n){return b(r,void 0,void 0,t().mark((function r(){var s;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return s=this._filterUnderOffsetMessage(n),this._addMessagesToView(s,e.MessageEventSource.REQUEST_MESSAGE),t.next=4,this._loadUnsentMessages();case 4:a._invokeResponse("local",null,s);case 5:case"end":return t.stop()}}),r,this)})))})).catch((function(e){if(A(e))throw e;a._invokeResponse("local",e,null)})).finally((function(){var t=ns.of(r._iid).cacheContext;r._getRemoteMessages(r._startingPoint,{prevLimit:s,nextLimit:s,reverse:!0,checkingContinuousMessages:t.localCacheEnabled}).then((function(t){var n,i=t.messages,o=t.isContinuousMessages;r._messages=[];var u=r._filterUnderOffsetMessage(i);if(u.length>0){for(var c,l=u.map((function(e){return e.createdAt})),h=0,d=0,f=0;f=r._startingPoint&&d++}r._hasPrevious=h>=s,r._hasNext=d>=s,(c=r._syncRange).extends.apply(c,_(u.map((function(e){return e.createdAt})))),o&&(null===(n=r._backgroundSync)||void 0===n||n.range.extends(r._syncRange.top,r._syncRange.bottom)),r._addMessagesToView(u,e.MessageEventSource.REQUEST_MESSAGE)}else r._hasPrevious=!1,r._hasNext=!1;a._invokeResponse("remote",null,u)})).catch((function(e){if(A(e))throw e;a._invokeResponse("remote",e,null)}))}));var i=ns.of(this._iid),o=i.cacheContext;return i.statLogCollector.put(new ja({type:te.FEATURE_LOCALCACHE,data:{use_local_cache:o.localCacheEnabled,collection_interface:{message_init_policy:n}}})),a}},{key:"loadPrevious",value:function(){return b(this,void 0,void 0,t().mark((function n(){var r,a,s,i=this;return t().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:if(!this._hasPrevious){n.next=14;break}return r=this.viewTop,a=[],n.next=5,ca((function(){return b(i,void 0,void 0,t().mark((function e(){return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.t0=this,e.next=3,this._getLocalMessages(r,{prevLimit:this._limit});case 3:e.t1=e.sent,a=e.t0._filterUnderOffsetMessage.call(e.t0,e.t1);case 5:case"end":return e.stop()}}),e,this)})))}));case 5:if(0!==a.length&&this._backgroundSync&&this._backgroundSync.isWrappingMessages(a)){n.next=11;break}return n.next=8,ca((function(){return b(i,void 0,void 0,t().mark((function e(){var n,s,i,o,u,c;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return i=ns.of(this._iid),o=i.cacheContext,e.next=3,this._getRemoteMessages(r,{prevLimit:this._limit,checkingContinuousMessages:o.localCacheEnabled});case 3:u=e.sent,a=this._filterUnderOffsetMessage(u.messages),this._hasPrevious=a.length>=this._limit,a.length>0&&((c=this._syncRange).extends.apply(c,_(a.map((function(e){return e.createdAt})))),(null===(n=this._backgroundSync)||void 0===n?void 0:n.range.overlap(this._syncRange))&&u.isContinuousMessages&&(null===(s=this._backgroundSync)||void 0===s||s.range.extends(this._syncRange.top)));case 7:case"end":return e.stop()}}),e,this)})))}));case 8:this._addMessagesToView(a,e.MessageEventSource.REQUEST_MESSAGE),n.next=13;break;case 11:this._hasPrevious=a.length>=this._limit,a.length>0&&((s=this._syncRange).extends.apply(s,_(a.map((function(e){return e.createdAt})))),this._addMessagesToView(a,e.MessageEventSource.REQUEST_MESSAGE));case 13:return n.abrupt("return",a);case 14:return n.abrupt("return",[]);case 15:case"end":return n.stop()}}),n,this)})))}},{key:"loadNext",value:function(){var n;return b(this,void 0,void 0,t().mark((function r(){var a,s,i,o=this;return t().wrap((function(r){for(;;)switch(r.prev=r.next){case 0:if(this._hasNext){r.next=2;break}return r.abrupt("return",[]);case 2:return a=this.viewBottom,s=[],r.next=6,ca((function(){return b(o,void 0,void 0,t().mark((function e(){return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.t0=this,e.next=3,this._getLocalMessages(a,{nextLimit:this._limit});case 3:e.t1=e.sent,s=e.t0._filterUnderOffsetMessage.call(e.t0,e.t1);case 5:case"end":return e.stop()}}),e,this)})))}));case 6:if(0!==s.length&&(null===(n=this._backgroundSync)||void 0===n?void 0:n.isWrappingMessages(s))){r.next=12;break}return r.next=9,ca((function(){return b(o,void 0,void 0,t().mark((function e(){var n,r,i,o,u,c;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return i=ns.of(this._iid),o=i.cacheContext,e.next=3,this._getRemoteMessages(a,{nextLimit:this._limit,checkingContinuousMessages:o.localCacheEnabled});case 3:u=e.sent,s=this._filterUnderOffsetMessage(u.messages),this._hasNext=s.length>=this._limit,s.length>0&&((c=this._syncRange).extends.apply(c,_(s.map((function(e){return e.createdAt})))),(null===(n=this._backgroundSync)||void 0===n?void 0:n.range.overlap(this._syncRange))&&u.isContinuousMessages&&(null===(r=this._backgroundSync)||void 0===r||r.range.extends(this._syncRange.bottom)));case 7:case"end":return e.stop()}}),e,this)})))}));case 9:this._addMessagesToView(s,e.MessageEventSource.REQUEST_MESSAGE),r.next=14;break;case 12:this._hasNext=s.length>=this._limit,s.length>0&&((i=this._syncRange).extends.apply(i,_(s.map((function(e){return e.createdAt})))),this._addMessagesToView(s,e.MessageEventSource.REQUEST_MESSAGE));case 14:return r.abrupt("return",s);case 15:case"end":return r.stop()}}),r,this)})))}},{key:"removeFailedMessage",value:function(e){return b(this,void 0,void 0,t().mark((function n(){var r,a;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return r=wf.of(this._iid),t.next=3,r.removeFailedMessageFromCache(e);case 3:(a=this._unsentMessages.findIndex((function(t){return t.reqId===e})))>-1&&this._unsentMessages.splice(a,1);case 5:case"end":return t.stop()}}),n,this)})))}},{key:"dispose",value:function(){var t,n,r,a=ns.of(this._iid),s=a.cacheContext,i=a.dispatcher;this._clearCheckMyMutedTimer(),this._channel._updateMessageCollectionLastAccessedAt(),i.dispatch(new ru({channels:[this._channel],source:e.GroupChannelEventSource.CHANNEL_LASTACCESSEDAT_UPDATED})),s.localCacheEnabled&&(this._prevFill.stop(),this._nextFill.stop()),null===(t=this._backgroundSync)||void 0===t||t.close(),null===(n=this._changelogSync)||void 0===n||n.close(),null===(r=this._pollChangelogSync)||void 0===r||r.close();var o=wf.of(this._iid);o.unsubscribeGroupChannelEvent(this._key),o.unsubscribeMessageEvent(this._key),this._connectionEventContext&&this._connectionEventContext.close()}}]),n}(),Wf={coverUrl:null,coverImage:null,isDistinct:null,isPublic:null,isDiscoverable:null,accessCode:null,name:null,data:null,customType:null,operatorUserIds:null,messageSurvivalSeconds:null},Yf=function(e){return L("string",e.coverUrl,!0)&&(H(e.coverImage)||L("string",e.coverImage)||null===e.coverImage)&&L("boolean",e.isDistinct,!0)&&L("boolean",e.isPublic,!0)&&L("boolean",e.isDiscoverable,!0)&&L("string",e.accessCode,!0)&&L("string",e.name,!0)&&L("string",e.data,!0)&&L("string",e.customType,!0)&&F("string",e.operatorUserIds,!0)&&L("number",e.messageSurvivalSeconds,!0)},Zf={hidePreviousMessages:!1,allowAutoUnhide:!0},Jf=function(e){return L("boolean",e.hidePreviousMessages)&&L("boolean",e.allowAutoUnhide)},Xf=function(e){i(n,e);var t=f(n);function n(e){var a;r(this,n);var s=e.channelUrl,i=e.token,o=e.limit,u=e.order,c=e.mutedMemberFilter,l=e.memberStateFilter,h=e.nicknameStartsWithFilter,d=e.operatorFilter;return(a=t.call(this)).method=B.GET,a.path="".concat(zr,"/").concat(encodeURIComponent(s),"/members"),a.params={token:i,limit:o,order:u,muted_member_filter:c,member_state_filter:l,nickname_startswith:h,operator_filter:d,show_member_is_muted:!0,show_read_receipt:!0,show_delivery_receipt:!0},a}return s(n)}(ne),$f=function(e){i(n,e);var t=f(n);function n(e,a){var s;r(this,n),(s=t.call(this,e,a)).token=null,s.members=[];var i=a.next,o=a.members;return s.token=i,o&&o.length>0&&(s.members=o.map((function(t){return new ed(e,t)}))),s}return s(n)}(re);e.MutedMemberFilter=void 0,(zf=e.MutedMemberFilter||(e.MutedMemberFilter={})).ALL="all",zf.MUTED="muted",zf.UNMUTED="unmuted",e.MemberListOrder=void 0,(Vf=e.MemberListOrder||(e.MemberListOrder={})).MEMBER_NICKNAME_ALPHABETICAL="member_nickname_alphabetical",Vf.OPERATOR_THEN_MEMBER_ALPHABETICAL="operator_then_member_alphabetical",e.MemberStateFilter=void 0,(Bf=e.MemberStateFilter||(e.MemberStateFilter={})).ALL="all",Bf.JOINED="joined_only",Bf.INVITED="invited_only",Bf.INVITED_BY_FRIEND="invited_by_friend",Bf.INVITED_BY_NON_FRIEND="invited_by_non_friend";var ep,tp,np,rp=function(n){i(u,n);var a=f(u);function u(t,n,s){var i,o,c,l,h;return r(this,u),(i=a.call(this,t,n,e.ChannelType.GROUP,s)).mutedMemberFilter=e.MutedMemberFilter.ALL,i.memberStateFilter=e.MemberStateFilter.ALL,i.nicknameStartsWithFilter=null,i.operatorFilter=e.OperatorFilter.ALL,i.order=e.MemberListOrder.MEMBER_NICKNAME_ALPHABETICAL,i.mutedMemberFilter=null!==(o=s.mutedMemberFilter)&&void 0!==o?o:e.MutedMemberFilter.ALL,i.memberStateFilter=null!==(c=s.memberStateFilter)&&void 0!==c?c:e.MemberStateFilter.ALL,i.nicknameStartsWithFilter=null!==(l=s.nicknameStartsWithFilter)&&void 0!==l?l:null,i.order=null!==(h=s.order)&&void 0!==h?h:e.MemberListOrder.MEMBER_NICKNAME_ALPHABETICAL,i}return s(u,[{key:"_validate",value:function(){return p(o(u.prototype),"_validate",this).call(this)&&D(e.MutedMemberFilter,this.mutedMemberFilter)&&D(e.MemberStateFilter,this.memberStateFilter)&&(L("string",this.nicknameStartsWithFilter)||null===this.nicknameStartsWithFilter)&&D(e.OperatorFilter,this.operatorFilter)&&D(e.MemberListOrder,this.order)}},{key:"next",value:function(){return b(this,void 0,void 0,t().mark((function e(){var n,r,a,s,i,o,u;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!this._validate()){e.next=20;break}if(this._isLoading){e.next=17;break}if(!this._hasNext){e.next=14;break}return this._isLoading=!0,n=ns.of(this._iid),r=n.requestQueue,a=new Xf(Object.assign(Object.assign({},this),{token:this._token})),e.next=8,r.send(a);case 8:return s=e.sent,i=s.as($f),o=i.members,u=i.token,this._token=u,this._hasNext=!!u,this._isLoading=!1,e.abrupt("return",o);case 14:return e.abrupt("return",[]);case 17:throw M.queryInProgress;case 18:e.next=21;break;case 20:throw M.invalidParameters;case 21:case"end":return e.stop()}}),e,this)})))}}]),u}(Si),ap=function(e){i(n,e);var t=f(n);function n(e){var a;r(this,n);var s=e.channelUrl,i=e.userId,o=e.accessCode;return(a=t.call(this)).method=B.PUT,a.path="".concat(zr,"/").concat(encodeURIComponent(s),"/accept"),a.params={user_id:i,access_code:o},a}return s(n)}(ne),sp=function(t){i(a,t);var n=f(a);function a(t,s){var i;return r(this,a),(i=n.call(this,t,s)).channel=new Rp(t,s),i.channel.myMemberState=e.MemberState.JOINED,i}return s(a)}(re),ip=function(e){i(n,e);var t=f(n);function n(e){var a;r(this,n);var s=e.channelUrl,i=e.isDistinct,o=e.isPublic,u=e.isDiscoverable,c=e.coverUrl,l=e.coverImage,h=e.accessCode,d=e.name,f=e.data,p=e.customType,v=e.operatorUserIds,_=e.messageSurvivalSeconds;return(a=t.call(this)).method=B.PUT,a.path="".concat(zr,"/").concat(encodeURIComponent(s)),a.params=ee({is_distinct:i,is_public:o,is_discoverable:u,name:d,data:f,custom_type:p,cover_url:c,cover_file:l,access_code:h,operator_ids:v,message_survival_seconds:_}),a}return s(n)}(ne),op=function(e){i(n,e);var t=f(n);function n(e,a){var s;return r(this,n),(s=t.call(this,e,a)).channel=new Rp(e,a),s}return s(n)}(re),up=function(e){i(n,e);var t=f(n);function n(e){var a;r(this,n);var s=e.channelUrl;return(a=t.call(this)).method=B.DELETE,a.path="".concat(zr,"/").concat(encodeURIComponent(s)),a}return s(n)}(ne),cp=function(e){i(n,e);var t=f(n);function n(e){var a;r(this,n);var s=e.channelUrl;return(a=t.call(this)).method=B.DELETE,a.path="".concat(zr,"/").concat(encodeURIComponent(s),"/hide"),a}return s(n)}(ne),lp=function(e){i(n,e);var t=f(n);function n(e){var a,s=e.userId,i=e.channelUrl,o=e.countPreference;return r(this,n),(a=t.call(this)).method=B.PUT,a.path="".concat(qr,"/").concat(encodeURIComponent(s),"/count_preference/").concat(encodeURIComponent(i)),a.params={count_preference:o},a}return s(n)}(ne),hp=function(e){i(n,e);var t=f(n);function n(e,a){var s;return r(this,n),(s=t.call(this,e,a)).countPreference=a.count_preference,s}return s(n)}(re),dp=function(e){i(n,e);var t=f(n);function n(e){var a;r(this,n);var s=e.channelUrl;return(a=t.call(this)).method=B.PUT,a.path="".concat(zr,"/").concat(encodeURIComponent(s),"/reset_user_history"),a}return s(n)}(ne),fp=function(e){i(n,e);var t=f(n);function n(e,a){var s;r(this,n),(s=t.call(this,e,a)).messageOffsetTimestamp=null;var i=a.ts_message_offset;return s.messageOffsetTimestamp=null!=i?i:null,s}return s(n)}(re),pp=Object.assign(Object.assign({},fl),{scheduledAt:null,file:null,fileUrl:null,fileName:null,mimeType:null,fileSize:null,thumbnailSizes:null,requireAuth:!1}),vp=function(e){return pl(e)&&L("number",e.scheduledAt,!0)&&(H(e.file)||L("string",e.fileUrl))&&L("string",e.fileName,!0)&&L("string",e.mimeType,!0)&&L("number",e.fileSize,!0)&&(null===e.thumbnailSizes||e.thumbnailSizes.every((function(e){return L("object",e)&&e.maxWidth>0&&e.maxHeight>0})))},_p=Object.assign(Object.assign({},vl),{scheduledAt:null}),mp=function(e){return _l(e)&&L("number",e.scheduledAt,!0)},gp=function(t){i(a,t);var n=f(a);function a(t){var s,i;r(this,a),s=n.call(this);var o=null;t.mentionType===e.MentionType.USERS&&(t.mentionedUserIds?o=t.mentionedUserIds:t.mentionedUsers&&(o=t.mentionedUsers.map((function(e){return e.userId}))));var u=t.channelType,c=t.channelUrl,l=t.scheduledMessageId;return s.method=B.PUT,s.path="".concat(Fs(u),"/").concat(encodeURIComponent(c),"/scheduled_messages/").concat(encodeURIComponent(l)),s.params=ee({req_id:t.reqId,scheduled_at:t.scheduledAt,message_type:Ya.FILE,url:t.fileUrl,file_name:t.fileName,file_size:t.fileSize,file_type:t.mimeType,thumbnails:t.thumbnailSizes?t.thumbnailSizes.map((function(e){return ws.payloadify(e)})):[],custom_type:t.customType,data:t.data,require_auth:t.requireAuth,mention_type:t.mentionType,mentioned_user_ids:o,sorted_metaarray:null===(i=t.metaArrays)||void 0===i?void 0:i.map((function(e){return ps.payloadify(e)})),apple_critical_alert_options:ms.payloadify(t.appleCriticalAlertOptions),push_option:t.pushNotificationDeliveryOption}),s}return s(a)}(ne),yp=function(e){i(n,e);var t=f(n);function n(e,a){var s;return r(this,n),(s=t.call(this,e,a)).message=new Ps(e,a),s}return s(n)}(re),kp=function(t){i(a,t);var n=f(a);function a(t){var s,i;r(this,a),s=n.call(this);var o=null;t.mentionType===e.MentionType.USERS&&(t.mentionedUserIds?o=t.mentionedUserIds:t.mentionedUsers&&(o=t.mentionedUsers.map((function(e){return e.userId}))));var u=t.channelType,c=t.channelUrl,l=t.scheduledMessageId;return s.method=B.PUT,s.path="".concat(Fs(u),"/").concat(encodeURIComponent(c),"/scheduled_messages/").concat(encodeURIComponent(l)),s.params=ee({req_id:t.reqId,scheduled_at:t.scheduledAt,message_type:Ya.USER,message:t.message,custom_type:t.customType,data:t.data,mention_type:t.mentionType,mentioned_user_ids:o,sorted_metaarray:null===(i=t.metaArrays)||void 0===i?void 0:i.map((function(e){return ps.payloadify(e)})),apple_critical_alert_options:ms.payloadify(t.appleCriticalAlertOptions),target_langs:t.translationTargetLanguages,push_option:t.pushNotificationDeliveryOption}),s}return s(a)}(ne),bp=function(e){i(n,e);var t=f(n);function n(e){var a;r(this,n),a=t.call(this);var s=e.channelType,i=e.channelUrl,o=e.scheduledMessageId;return a.method=B.DELETE,a.path="".concat(Fs(s),"/").concat(encodeURIComponent(i),"/scheduled_messages/").concat(encodeURIComponent(o)),a}return s(n)}(ne),Ep=function(e){i(n,e);var t=f(n);function n(e){var a;r(this,n),a=t.call(this);var s=e.channelType,i=e.channelUrl,o=e.scheduledMessageId;return a.method=B.POST,a.path="".concat(Fs(s),"/").concat(encodeURIComponent(i),"/scheduled_messages/").concat(encodeURIComponent(o),"/send_now"),a}return s(n)}(ne),wp=function(e){i(n,e);var t=f(n);function n(e){var a,s=e.userId,i=e.channelUrl,o=e.pushTriggerOption;return r(this,n),(a=t.call(this)).method=B.PUT,a.path="".concat(qr,"/").concat(encodeURIComponent(s),"/push_preference/").concat(encodeURIComponent(i)),a.params={push_trigger_option:o},a}return s(n)}(ne),Cp=function(e){i(n,e);var t=f(n);function n(e,a){var s;return r(this,n),(s=t.call(this,e,a)).pushTriggerOption=a.push_trigger_option,s.enabled=a.enable,s}return s(n)}(re),xp=function(e){i(n,e);var t=f(n);function n(e){var a,s=e.userId,i=e.channelUrl;return r(this,n),(a=t.call(this)).method=B.GET,a.path="".concat(qr,"/").concat(encodeURIComponent(s),"/push_preference/").concat(encodeURIComponent(i)),a}return s(n)}(ne),Tp=function(e){i(n,e);var t=f(n);function n(e,a){var s;return r(this,n),(s=t.call(this,e,a)).pushTriggerOption=a.push_trigger_option,s.enabled=a.enable,s}return s(n)}(re),Sp=function(e){i(n,e);var t=f(n);function n(e){var a,s=e.channelType,i=e.channelUrl,o=e.messageId;return r(this,n),(a=t.call(this)).method=B.POST,a.path="".concat(Fs(s),"/").concat(encodeURIComponent(i),"/messages/").concat(o,"/pin"),a}return s(n)}(ne),Ip=function(e){i(n,e);var t=f(n);function n(e){var a,s=e.channelType,i=e.channelUrl,o=e.messageId;return r(this,n),(a=t.call(this)).method=B.DELETE,a.path="".concat(Fs(s),"/").concat(encodeURIComponent(i),"/messages/").concat(o,"/pin"),a}return s(n)}(ne),Np=function(e){i(n,e);var t=f(n);function n(e,a){var s;return r(this,n),(s=t.call(this,e)).message=Ds(e,a.message),s}return s(n)}(Ca),Ap=function(e){i(n,e);var t=f(n);function n(e){var a;r(this,n);var s=e.channelType,i=e.channelUrl,o=e.limit,u=e.token,c=e.includeReactions,l=e.includeMetaArray,h=e.includeParentMessageInfo,d=e.includeThreadInfo,f=e.includePollDetails;return(a=t.call(this)).method=B.GET,a.path="".concat(Fs(s),"/").concat(encodeURIComponent(i),"/pinned_messages"),a.params=ee({limit:o,token:u,include_reactions:c,with_sorted_meta_array:l,include_thread_info:d,include_parent_message_info:h,include_poll_details:f}),a}return s(n)}(ne),Mp=function(e){i(n,e);var t=f(n);function n(e,a){var s;r(this,n),(s=t.call(this,e,a)).hasMore=null,s.token=null;var i=a.pinned_messages,o=a.has_more,u=a.next;return s.pinnedMessages=i.map((function(t){return new Np(e,t)})),s.hasMore=o,s.token=u,s}return s(n)}(re),Op=function(e){i(a,e);var n=f(a);function a(e,t,s,i){var o;return r(this,a),(o=n.call(this,e,t,s,i)).includeMetaArray=i.includeMetaArray,o.includeReactions=i.includeReactions,o.includeParentMessageInfo=i.includeParentMessageInfo,o.includeThreadInfo=i.includeThreadInfo,o.includePollDetails=i.includePollDetails,o}return s(a,[{key:"_validate",value:function(){return p(o(a.prototype),"_validate",this).call(this)&&L("boolean",this.includeMetaArray,!0)&&L("boolean",this.includeReactions,!0)&&L("boolean",this.includeParentMessageInfo,!0)&&L("boolean",this.includeThreadInfo,!0)&&L("boolean",this.includePollDetails,!0)}},{key:"next",value:function(){return b(this,void 0,void 0,t().mark((function e(){var n,r,a,s,i,o,u,c;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!this._validate()){e.next=20;break}if(this._isLoading){e.next=17;break}if(!this._hasNext){e.next=14;break}return this._isLoading=!0,n=ns.of(this._iid),r=n.requestQueue,a=new Ap(Object.assign(Object.assign({},this),{token:this._token})),e.next=8,r.send(a);case 8:return s=e.sent,i=s.as(Mp),o=i.pinnedMessages,u=i.hasMore,c=i.token,this._token=c,this._hasNext=!!u,this._isLoading=!1,e.abrupt("return",o);case 14:return e.abrupt("return",[]);case 17:throw M.queryInProgress;case 18:e.next=21;break;case 20:throw M.invalidParameters;case 21:case"end":return e.stop()}}),e,this)})))}}]),a}(Si);e.CountPreference=void 0,(ep=e.CountPreference||(e.CountPreference={})).ALL="all",ep.UNREAD_MESSAGE_COUNT_ONLY="unread_message_count_only",ep.UNREAD_MENTION_COUNT_ONLY="unread_mention_count_only",ep.OFF="off",e.MutedState=void 0,(tp=e.MutedState||(e.MutedState={})).MUTED="muted",tp.UNMUTED="unmuted",e.HiddenState=void 0,(np=e.HiddenState||(e.HiddenState={})).UNHIDDEN="unhidden",np.HIDDEN_ALLOW_AUTO_UNHIDE="hidden_allow_auto_unhide",np.HIDDEN_PREVENT_AUTO_UNHIDE="hidden_prevent_auto_unhide";var Up,Rp=function(n){i(u,n);var a=f(u);function u(t,n){var s,i,o,c,l,h,d,f,p,v,m,g,y,k,b,E,w,C,x,T;(r(this,u),(s=a.call(this,t,n))._unreadMemberStateMap=new Map,s._undeliveredMemberStateMap=new Map,s._typingStatus=new Map,s._lastMemberCountUpdated=0,s._typingStarted=0,s._typingEnded=0,s.isDistinct=!1,s.isSuper=!1,s.isBroadcast=!1,s.isExclusive=!1,s.isPublic=!1,s.isDiscoverable=!0,s.isAccessCodeRequired=!1,s.isPushEnabled=!1,s.unreadMessageCount=0,s.unreadMentionCount=0,s.members=[],s.memberCount=0,s.joinedMemberCount=0,s.hiddenState=e.HiddenState.UNHIDDEN,s.lastMessage=null,s.messageOffsetTimestamp=0,s.messageSurvivalSeconds=-1,s.myMemberState=e.MemberState.NONE,s.myRole=e.Role.NONE,s.myMutedState=e.MutedState.UNMUTED,s.myLastRead=0,s.myCountPreference=e.CountPreference.ALL,s.myPushTriggerOption=e.PushTriggerOption.DEFAULT,s.inviter=null,s.invitedAt=0,s.joinedAt=0,s.pinnedMessageIds=[],s.lastPinnedMessage=null,s._pinnedMessagesUpdatedAt=0,s._myMutedRemainingTime=-1,s.channelType=e.ChannelType.GROUP,s.isDistinct=null!==(i=n.is_distinct)&&void 0!==i&&i,s.isSuper=null!==(o=n.is_super)&&void 0!==o&&o,s.isBroadcast=null!==(c=n.is_broadcast)&&void 0!==c&&c,s.isExclusive=null!==(l=n.is_exclusive)&&void 0!==l&&l,s.isPublic=null!==(h=n.is_public)&&void 0!==h&&h,s.isDiscoverable=null!==(d=n.is_discoverable)&&void 0!==d?d:s.isPublic,s.isAccessCodeRequired=null!==(f=n.is_access_code_required)&&void 0!==f&&f,s.isPushEnabled=null!==(p=n.is_push_enabled)&&void 0!==p&&p,Array.isArray(n.members))&&(T=s.members).push.apply(T,_(n.members.map((function(e){return new ed(s._iid,e)}))));return s.memberCount=null!==(v=n.member_count)&&void 0!==v?v:0,s.joinedMemberCount=null!==(m=n.joined_member_count)&&void 0!==m?m:0,s.hiddenState=D(e.HiddenState,n.hidden_state)?n.hidden_state:e.HiddenState.UNHIDDEN,s.messageOffsetTimestamp=null!==(g=n.ts_message_offset)&&void 0!==g?g:0,s.messageSurvivalSeconds=null!==(y=n.message_survival_seconds)&&void 0!==y?y:-1,s.lastMessage=n.last_message?Ds(s._iid,Object.assign({channel_type:s.channelType},n.last_message)):null,n.read_receipt&&Object.keys(n.read_receipt).forEach((function(e){L("number",n.read_receipt[e])&&s._updateUnreadMemberState(e,n.read_receipt[e])})),n.delivery_receipt&&Object.keys(n.delivery_receipt).forEach((function(e){L("number",n.delivery_receipt[e])&&s._updateUndeliveredMemberState(e,n.delivery_receipt[e])})),s.myMemberState=D(e.MemberState,n.member_state)?n.member_state:e.MemberState.NONE,s.myRole=D(e.Role,n.my_role)?n.my_role:e.Role.NONE,D(e.MutedState,n.is_muted)?s.myMutedState=n.is_muted:L("boolean",n.is_muted)?s.myMutedState=n.is_muted?e.MutedState.MUTED:e.MutedState.UNMUTED:s.myMutedState=e.MutedState.UNMUTED,s.myCountPreference=D(e.CountPreference,n.count_preference)?n.count_preference:e.CountPreference.ALL,s.myPushTriggerOption=D(e.PushTriggerOption,n.push_trigger_option)?n.push_trigger_option:e.PushTriggerOption.ALL,s.myLastRead=null!==(k=n.user_last_read)&&void 0!==k?k:0,s.inviter=n.inviter?new La(s._iid,n.inviter):null,s.invitedAt=null!==(b=n.invited_at)&&void 0!==b?b:0,s.joinedAt=null!==(E=n.joined_ts)&&void 0!==E?E:0,s._updateUnreadCount(null!==(w=n.unread_message_count)&&void 0!==w?w:0,null!==(C=n.unread_mention_count)&&void 0!==C?C:0),s.pinnedMessageIds=null!==(x=n.pinned_message_ids)&&void 0!==x?x:[],s.lastPinnedMessage=n.latest_pinned_message?Ds(s._iid,Object.assign({channel_type:s.channelType},n.latest_pinned_message)):null,s}return s(u,[{key:"isHidden",get:function(){return this.hiddenState!==e.HiddenState.UNHIDDEN}},{key:"isTyping",get:function(){return this._typingStatus.size>0}},{key:"cachedUnreadMemberState",get:function(){var e,t={},n=y(this._unreadMemberStateMap);try{for(n.s();!(e=n.n()).done;){var r=v(e.value,2),a=r[0],s=r[1];t[a]=s}}catch(e){n.e(e)}finally{n.f()}return t}},{key:"cachedUndeliveredMemberState",get:function(){var e,t={},n=y(this._undeliveredMemberStateMap);try{for(n.s();!(e=n.n()).done;){var r=v(e.value,2),a=r[0],s=r[1];t[a]=s}}catch(e){n.e(e)}finally{n.f()}return t}},{key:"_shouldUpdateLastMessageWith",value:function(e){return!(e instanceof Es&&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=ns.of(this._iid).maxSuperGroupChannelUnreadCount;this.unreadMessageCount=r&&t>=r?r:t}else this.unreadMessageCount=t;else this.unreadMessageCount=0;else this.unreadMessageCount=0;"number"==typeof n&&n>=0&&(this.myCountPreference===e.CountPreference.ALL||this.myCountPreference===e.CountPreference.UNREAD_MENTION_COUNT_ONLY)?this.unreadMentionCount=n:this.unreadMentionCount=0}},{key:"_updateUnreadMemberState",value:function(e,t){var n=this._unreadMemberStateMap.get(e);return(!n||n1&&void 0!==arguments[1]?arguments[1]:(new Date).getTime();t>0?this._typingStatus.set(e.userId,{user:e,ts:t}):this._typingStatus.delete(e.userId)}},{key:"_clearTypingStatus",value:function(){this._typingStatus.clear(),this._typingStarted=0,this._typingEnded=0}},{key:"_setLatestMemberCount",value:function(e,t,n){var r=!1;return n>=this._lastMemberCountUpdated&&(this._lastMemberCountUpdated=n,r=e!==this.memberCount||t!==this.joinedMemberCount,this.memberCount=e,this.joinedMemberCount=t),r}},{key:"isReadMessage",value:function(e){var t=ns.of(this._iid).sdkState,n=this._unreadMemberStateMap.get(t.userId);return n&&n>=e.createdAt}},{key:"serialize",value:function(){var e=this;return Ma(this,(function(t){t.cachedUnreadMemberState=e.cachedUnreadMemberState,t.cachedUndeliveredMemberState=e.cachedUndeliveredMemberState}))}},{key:"createMessageCollection",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return new Kf(this._iid,Object.assign({channel:this},e))}},{key:"createMemberListQuery",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return new rp(this._iid,this.url,e)}},{key:"createPinnedMessageListQuery",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return new Op(this._iid,this.url,this.channelType,e)}},{key:"addMember",value:function(t){var n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0;if(!this.isExclusive&&!this.isSuper&&!this.isBroadcast){var r=this.members.findIndex((function(e){return e.userId===t.userId}));if(r>-1){var a=this.members[r];a.state===e.MemberState.JOINED&&(t.state=a.state),this.members.splice(r,1),this.memberCount--}this.members.push(t),this.memberCount++,this._updateUnreadMemberState(t.userId,n),this._updateUndeliveredMemberState(t.userId,n)}}},{key:"removeMember",value:function(e){if(!this.isExclusive&&!this.isSuper&&!this.isBroadcast){var t=e instanceof ed?e.userId:e,n=this.members.findIndex((function(e){return e.userId===t}));if(n>-1)return this.members.splice(n,1),this.memberCount--,!0}return!1}},{key:"getUnreadMemberCount",value:function(t){if(t instanceof Es&&!this.isExclusive&&!this.isSuper&&!this.isBroadcast){var n,r=ns.of(this._iid).sdkState,a=t.createdAt,s=0,i=y(this.members);try{for(i.s();!(n=i.n()).done;){var o=n.value;if(r.userId!==o.userId&&o.state===e.MemberState.JOINED&&t.sender.userId!==o.userId)(this.cachedUnreadMemberState[o.userId]||0)1&&void 0!==arguments[1]&&arguments[1],r=ns.of(this._iid).sdkState;if(!r.userId||this.isExclusive||this.isSuper||this.isBroadcast)return[];var a=e instanceof Es?e.sender:null,s=[];return this.members.forEach((function(i){(n||i.userId!==r.userId&&i.userId!==(null==a?void 0:a.userId))&&(t._unreadMemberStateMap.get(i.userId)>=e.createdAt&&s.push(i))})),s}},{key:"getUnreadMembers",value:function(e){var t=this,n=arguments.length>1&&void 0!==arguments[1]&&arguments[1],r=ns.of(this._iid).sdkState;if(!r.userId||this.isExclusive||this.isSuper||this.isBroadcast)return[];var a=e instanceof Es?e.sender:null,s=[];return this.members.forEach((function(i){(n||i.userId!==r.userId&&i.userId!==(null==a?void 0:a.userId))&&(t._unreadMemberStateMap.get(i.userId)0&&void 0!==arguments[0]&&arguments[0],n=ns.of(this._iid).sdkState;if(!n.userId||this.isExclusive||this.isSuper||this.isBroadcast)return null;var r={};return this.members.forEach((function(a){if(t||a.userId!==n.userId){var s=e._unreadMemberStateMap.get(a.userId);r[a.userId]=new td(e._iid,{channel_url:e.url,channel_type:e.channelType,user:ed.payloadify(a),ts:s})}})),r}},{key:"getTypingUsers",value:function(){var e=[];return this._typingStatus.forEach((function(t){var n=t.user;e.push(n)})),e}},{key:"invalidateTypingStatus",value:function(){var e=this,t=ns.of(this._iid).typingIndicatorInvalidateTime,n=Date.now(),r=!1;return this._typingStatus.forEach((function(a,s){var i=a.ts;n-i>=t&&(e._typingStatus.delete(s),r=!0)})),r}},{key:"refresh",value:function(){return b(this,void 0,void 0,t().mark((function n(){var r,a,s,i,o,u,c;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return r=ns.of(this._iid),a=r.requestQueue,s=r.dispatcher,i=new Cd({channelUrl:this.url}),t.next=4,a.send(i);case 4:return o=t.sent,u=o.as(xd),c=u.channel,s.dispatch(new ru({channels:[c],source:e.GroupChannelEventSource.REQUEST_CHANNEL})),t.abrupt("return",c);case 8:case"end":return t.stop()}}),n,this)})))}},{key:"freeze",value:function(){var n=this,r=Object.create(null,{freeze:{get:function(){return p(o(u.prototype),"freeze",n)}}});return b(this,void 0,void 0,t().mark((function n(){var a;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,r.freeze.call(this);case 2:a=ns.of(this._iid),a.dispatcher.dispatch(new ru({channels:[this],source:e.GroupChannelEventSource.EVENT_CHANNEL_HIDDEN}));case 4:case"end":return t.stop()}}),n,this)})))}},{key:"unfreeze",value:function(){var n=this,r=Object.create(null,{unfreeze:{get:function(){return p(o(u.prototype),"unfreeze",n)}}});return b(this,void 0,void 0,t().mark((function n(){var a;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,r.unfreeze.call(this);case 2:a=ns.of(this._iid),a.dispatcher.dispatch(new ru({channels:[this],source:e.GroupChannelEventSource.EVENT_CHANNEL_UNHIDDEN}));case 4:case"end":return t.stop()}}),n,this)})))}},{key:"updateChannel",value:function(n){return b(this,void 0,void 0,t().mark((function r(){var a,s,i,o,u,c,l,h;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return a=Object.assign(Object.assign({},Wf),n),Ua(Yf(a)).throw(M.invalidParameters),s=ns.of(this._iid),i=s.dispatcher,o=s.requestQueue,u=new ip(Object.assign({channelUrl:this.url},a)),t.next=6,o.send(u);case 6:return c=t.sent,l=c.as(op),h=l.channel,i.dispatch(new ru({channels:[h],source:e.GroupChannelEventSource.EVENT_CHANNEL_UPDATED})),t.abrupt("return",h);case 10:case"end":return t.stop()}}),r,this)})))}},{key:"invite",value:function(e){return b(this,void 0,void 0,t().mark((function n(){return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return Ua(e.every((function(e){return e instanceof La}))).throw(M.invalidParameters),t.abrupt("return",this.inviteWithUserIds(e.map((function(e){return e.userId}))));case 2:case"end":return t.stop()}}),n,this)})))}},{key:"inviteWithUserIds",value:function(n){return b(this,void 0,void 0,t().mark((function r(){var a,s,i,o,u,c,l;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return Ua(F("string",n)).throw(M.invalidParameters),a=ns.of(this._iid),s=a.dispatcher,i=a.requestQueue,o=new Wd({channelUrl:this.url,userIds:n}),t.next=5,i.send(o);case 5:return u=t.sent,c=u.as(Yd),l=c.channel,s.dispatch(new ru({channels:[l],source:e.GroupChannelEventSource.EVENT_CHANNEL_INVITED})),t.abrupt("return",l);case 9:case"end":return t.stop()}}),r,this)})))}},{key:"join",value:function(){var n=arguments.length>0&&void 0!==arguments[0]?arguments[0]:null;return b(this,void 0,void 0,t().mark((function r(){var a,s,i,o,u,c,l,h;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return Ua(L("string",n)||null===n).throw(M.invalidParameters),a=ns.of(this._iid),s=a.dispatcher,i=a.sdkState,o=a.requestQueue,u=new zd({channelUrl:this.url,userId:i.userId,accessCode:n}),t.next=5,o.send(u);case 5:return c=t.sent,l=c.as(Vd),(h=l.channel).myMemberState=this.myMemberState=e.MemberState.JOINED,s.dispatch(new ru({channels:[h],source:e.GroupChannelEventSource.EVENT_CHANNEL_JOINED})),t.abrupt("return",this);case 10:case"end":return t.stop()}}),r,this)})))}},{key:"leave",value:function(){var n=arguments.length>0&&void 0!==arguments[0]&&arguments[0];return b(this,void 0,void 0,t().mark((function r(){var a,s,i,o;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return a=ns.of(this._iid),s=a.sdkState,i=a.requestQueue,o=new Qd({channelUrl:this.url,userId:s.userId,shouldRemoveOperatorStatus:n}),t.next=4,i.send(o);case 4:this.myMemberState=e.MemberState.NONE;case 5:case"end":return t.stop()}}),r,this)})))}},{key:"acceptInvitation",value:function(){var n=arguments.length>0&&void 0!==arguments[0]?arguments[0]:null;return b(this,void 0,void 0,t().mark((function r(){var a,s,i,o,u,c,l,h;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return Ua(L("string",n)||null===n).throw(M.invalidParameters),a=ns.of(this._iid),s=a.dispatcher,i=a.sdkState,o=a.requestQueue,u=new ap({channelUrl:this.url,userId:i.userId,accessCode:n}),t.next=5,o.send(u);case 5:return c=t.sent,l=c.as(sp),(h=l.channel).myMemberState=this.myMemberState=e.MemberState.JOINED,s.dispatch(new ru({channels:[h],source:e.GroupChannelEventSource.EVENT_CHANNEL_ACCEPTED_INVITE})),t.abrupt("return",this);case 10:case"end":return t.stop()}}),r,this)})))}},{key:"declineInvitation",value:function(){return b(this,void 0,void 0,t().mark((function n(){var r,a,s,i;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return r=ns.of(this._iid),a=r.sdkState,s=r.requestQueue,i=new Jd({channelUrl:this.url,userId:a.userId}),t.next=4,s.send(i);case 4:return this.myMemberState=e.MemberState.NONE,t.abrupt("return",this);case 6:case"end":return t.stop()}}),n,this)})))}},{key:"sendUserMessage",value:function(t){var n=this,r=new _i,a=ns.of(this._iid).dispatcher,s=Jo.of(this._iid);return p(o(u.prototype),"sendUserMessage",this).call(this,t).onPending((function(e){s.completeCurrentAndProcessNextAutoResend(e),r._trigger(null,e)})).onFailed((function(e,t){t&&s.completeCurrentAndProcessNextAutoResend(t),r._trigger(e,t)})).onSucceeded((function(t){n.hiddenState===e.HiddenState.HIDDEN_ALLOW_AUTO_UNHIDE&&(n.hiddenState=e.HiddenState.UNHIDDEN),s.completeCurrentAndProcessNextAutoResend(t),n._shouldUpdateLastMessageWith(t)&&(n.lastMessage=t),wf.of(n._iid).handlers.map((function(e){return e.onChannelChanged(n)})),a.dispatch(new ru({channels:[n],source:e.GroupChannelEventSource.EVENT_MESSAGE_SENT})),r._trigger(null,t)})),r}},{key:"updateUserMessage",value:function(n,r){var a=this,s=Object.create(null,{updateUserMessage:{get:function(){return p(o(u.prototype),"updateUserMessage",a)}}});return b(this,void 0,void 0,t().mark((function a(){var i,o,u,c,l,h=this;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return i=ns.of(this._iid),o=i.dispatcher,t.next=3,s.updateUserMessage.call(this,n,r);case 3:return u=t.sent,c=!1,!u.silent&&this._shouldUpdateLastMessageWith(u)&&(this.lastMessage=u,c=!0),l=!1,this.lastPinnedMessage&&this.lastPinnedMessage.messageId===u.messageId&&(this.lastPinnedMessage=u,c=!0,l=!0),c&&(wf.of(this._iid).handlers.map((function(e){return e.onChannelChanged(h)})),o.dispatch(new ru({channels:[this],source:l?e.GroupChannelEventSource.EVENT_PINNED_MESSAGE_UPDATED:e.GroupChannelEventSource.EVENT_MESSAGE_UPDATED}))),l&&wf.of(this._iid).handlers.map((function(e){return e.onPinnedMessageUpdated(h)})),o.dispatch(new ei({messages:[u],source:e.MessageEventSource.EVENT_MESSAGE_UPDATED})),t.abrupt("return",u);case 12:case"end":return t.stop()}}),a,this)})))}},{key:"_autoResendUserMessage",value:function(t){var n=this,r=new _i,a=ns.of(this._iid).dispatcher,s=Jo.of(this._iid);return p(o(u.prototype),"_autoResendUserMessage",this).call(this,t).onPending((function(e){s.completeCurrentAndProcessNextAutoResend(e),r._trigger(null,e)})).onFailed((function(e,t){s.completeCurrentAndProcessNextAutoResend(t),r._trigger(e,t)})).onSucceeded((function(t){var i=wf.of(n._iid);s.completeCurrentAndProcessNextAutoResend(t),n._shouldUpdateLastMessageWith(t)&&(n.lastMessage=t),i.handlers.map((function(e){return e.onChannelChanged(n)})),a.dispatch(new ru({channels:[n],source:e.GroupChannelEventSource.EVENT_MESSAGE_SENT})),r._trigger(null,t)})),r}},{key:"sendFileMessage",value:function(t){var n=this,r=new _i,a=ns.of(this._iid).dispatcher,s=Jo.of(this._iid);return p(o(u.prototype),"sendFileMessage",this).call(this,t).onPending((function(e){s.completeCurrentAndProcessNextAutoResend(e),r._trigger(null,e)})).onFailed((function(e,t){t&&s.completeCurrentAndProcessNextAutoResend(t),r._trigger(e,t)})).onSucceeded((function(t){var i=wf.of(n._iid);s.completeCurrentAndProcessNextAutoResend(t),n._shouldUpdateLastMessageWith(t)&&(n.lastMessage=t),i.handlers.map((function(e){return e.onChannelChanged(n)})),a.dispatch(new ru({channels:[n],source:e.GroupChannelEventSource.EVENT_MESSAGE_SENT})),r._trigger(null,t)})),r}},{key:"updateFileMessage",value:function(n,r){var a=this,s=Object.create(null,{updateFileMessage:{get:function(){return p(o(u.prototype),"updateFileMessage",a)}}});return b(this,void 0,void 0,t().mark((function a(){var i,o,u,c,l,h=this;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return i=ns.of(this._iid),o=i.dispatcher,t.next=3,s.updateFileMessage.call(this,n,r);case 3:return u=t.sent,c=!1,!u.silent&&this._shouldUpdateLastMessageWith(u)&&(this.lastMessage=u,c=!0),l=!1,this.lastPinnedMessage&&this.lastPinnedMessage.messageId===u.messageId&&(this.lastPinnedMessage=u,c=!0,l=!0),c&&(wf.of(this._iid).handlers.map((function(e){return e.onChannelChanged(h)})),o.dispatch(new ru({channels:[this],source:l?e.GroupChannelEventSource.EVENT_PINNED_MESSAGE_UPDATED:e.GroupChannelEventSource.EVENT_MESSAGE_UPDATED}))),l&&wf.of(this._iid).handlers.map((function(e){return e.onPinnedMessageUpdated(h)})),o.dispatch(new ei({messages:[u],source:e.MessageEventSource.EVENT_MESSAGE_UPDATED})),t.abrupt("return",u);case 12:case"end":return t.stop()}}),a,this)})))}},{key:"_autoResendFileMessage",value:function(t){var n=this,r=new _i,a=ns.of(this._iid).dispatcher,s=Jo.of(this._iid);return p(o(u.prototype),"_autoResendFileMessage",this).call(this,t).onPending((function(e){s.completeCurrentAndProcessNextAutoResend(e),r._trigger(null,e)})).onFailed((function(e,t){s.completeCurrentAndProcessNextAutoResend(t),r._trigger(e,t)})).onSucceeded((function(t){var i=wf.of(n._iid);s.completeCurrentAndProcessNextAutoResend(t),n._shouldUpdateLastMessageWith(t)&&(n.lastMessage=t),i.handlers.map((function(e){return e.onChannelChanged(n)})),a.dispatch(new ru({channels:[n],source:e.GroupChannelEventSource.EVENT_MESSAGE_SENT})),r._trigger(null,t)})),r}},{key:"deleteMessage",value:function(n){var r=this,a=Object.create(null,{deleteMessage:{get:function(){return p(o(u.prototype),"deleteMessage",r)}}});return b(this,void 0,void 0,t().mark((function r(){var s;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,a.deleteMessage.call(this,n);case 2:0===n.messageId&&n instanceof Es&&(s=ns.of(this._iid),s.dispatcher.dispatch(new ni({reqId:n.reqId,source:e.MessageEventSource.EVENT_MESSAGE_DELETED})));case 3:case"end":return t.stop()}}),r,this)})))}},{key:"hide",value:function(n){return b(this,void 0,void 0,t().mark((function r(){var a,s,i,o,u,c,l,h,d;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return a=Object.assign(Object.assign({},Zf),n),Ua(Jf(a)).throw(M.invalidParameters),s=ns.of(this._iid),i=s.dispatcher,o=s.sdkState,u=s.requestQueue,c=new rf(Object.assign({channelUrl:this.url,userId:o.userId},a)),t.next=6,u.send(c);case 6:return l=t.sent,h=l.as(af),d=h.messageOffsetTimestamp,this.hiddenState=a.allowAutoUnhide?e.HiddenState.HIDDEN_ALLOW_AUTO_UNHIDE:e.HiddenState.HIDDEN_PREVENT_AUTO_UNHIDE,a.hidePreviousMessages&&this._updateUnreadCount(0,0),d&&(this.messageOffsetTimestamp=d),i.dispatch(new ru({channels:[this],source:e.GroupChannelEventSource.EVENT_CHANNEL_HIDDEN})),t.abrupt("return",this);case 13:case"end":return t.stop()}}),r,this)})))}},{key:"unhide",value:function(){return b(this,void 0,void 0,t().mark((function n(){var r,a,s,i;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return r=ns.of(this._iid),a=r.dispatcher,s=r.requestQueue,i=new cp({channelUrl:this.url}),t.next=4,s.send(i);case 4:return this.hiddenState=e.HiddenState.UNHIDDEN,a.dispatch(new ru({channels:[this],source:e.GroupChannelEventSource.EVENT_CHANNEL_UNHIDDEN})),t.abrupt("return",this);case 7:case"end":return t.stop()}}),n,this)})))}},{key:"delete",value:function(){return b(this,void 0,void 0,t().mark((function e(){var n,r,a;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n=ns.of(this._iid),r=n.requestQueue,a=new up({channelUrl:this.url}),e.next=4,r.send(a);case 4:case"end":return e.stop()}}),e,this)})))}},{key:"markAsRead",value:function(){return b(this,void 0,void 0,t().mark((function n(){var r,a,s,i,o,u,c,l,h=this;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return r=ns.of(this._iid),a=r.sdkState,s=r.dispatcher,i=r.requestQueue,o=new $d({channelUrl:this.url}),t.next=4,i.send(o);case 4:u=t.sent,c=u.as(ef),l=c.readStatus,this._updateUnreadMemberState(a.userId,l.readAt),(this.unreadMessageCount>0||this.unreadMentionCount>0)&&(this._updateUnreadCount(0,0),wf.of(this._iid).handlers.map((function(e){return e.onChannelChanged(h)}))),s.dispatch(new ru({channels:[this],source:e.GroupChannelEventSource.EVENT_CHANNEL_READ}));case 9:case"end":return t.stop()}}),n,this)})))}},{key:"markAsDelivered",value:function(){return b(this,void 0,void 0,t().mark((function e(){var n,r,a,s;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n=ns.of(this._iid),r=n.sdkState,a=n.requestQueue,s=new tf({channelUrl:this.url,userId:r.userId}),e.next=4,a.send(s);case 4:case"end":return e.stop()}}),e,this)})))}},{key:"startTyping",value:function(){return b(this,void 0,void 0,t().mark((function e(){var n,r,a,s,i;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:n=ns.of(this._iid),r=n.requestQueue,a=n.typingIndicatorThrottle,(s=(new Date).getTime())-this._typingStarted>=a&&(this._typingStarted=s,this._typingEnded=0,i=new of({channelUrl:this.url,time:this._typingStarted}),r.send(i));case 3:case"end":return e.stop()}}),e,this)})))}},{key:"endTyping",value:function(){return b(this,void 0,void 0,t().mark((function e(){var n,r,a,s,i;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:n=ns.of(this._iid),r=n.requestQueue,a=n.typingIndicatorThrottle,(s=(new Date).getTime())-this._typingEnded>=a&&(this._typingStarted=0,this._typingEnded=s,i=new cf({channelUrl:this.url,time:this._typingStarted}),r.send(i));case 3:case"end":return e.stop()}}),e,this)})))}},{key:"createScheduledUserMessage",value:function(e){e=Object.assign(Object.assign({},Fo),e),Ua(function(e){return Eo(e)&&L("number",e.scheduledAt,!0)}(e)).throw(M.invalidParameters);var t=new _i;return this._createScheduledUserMessage(e,t),t}},{key:"updateScheduledUserMessage",value:function(e,n){return b(this,void 0,void 0,t().mark((function r(){var a,s,i,o,u,c,l;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return a=Object.assign(Object.assign({},_p),n),Ua(mp(a)).throw(M.invalidParameters),s=ns.of(this._iid),i=s.requestQueue,o=new kp(Object.assign({reqId:this._generateRequestId(),scheduledMessageId:e,channelType:this.channelType,channelUrl:this.url},a)),t.next=6,i.send(o);case 6:return u=t.sent,c=u.as(Sh),l=c.message,t.abrupt("return",l);case 9:case"end":return t.stop()}}),r,this)})))}},{key:"createScheduledFileMessage",value:function(e){var n=this;e=Object.assign(Object.assign({},Go),e),Ua(function(e){return go(e)&&L("number",e.scheduledAt)&&(H(e.file)||L("string",e.fileUrl))&&L("string",e.fileName,!0)&&L("string",e.mimeType,!0)&&L("number",e.fileSize,!0)&&(null===e.thumbnailSizes||e.thumbnailSizes.every((function(e){return L("object",e)&&e.maxWidth>0&&e.maxHeight>0})))}(e)).throw(M.invalidParameters);var r=Date.now(),a=this._generateRequestId(),s=new _i;return sa(2).then((function(){var i=n._createPendingScheduledFileMessage(e,a,r);ua((function(){return b(n,void 0,void 0,t().mark((function e(){return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",s._trigger(null,i));case 1:case"end":return e.stop()}}),e)})))}))})),H(e.file)?this._uploadFileAndUpdateParams(e).then((function(){return n._createScheduledFileMessage(e,s,a,r)})):this._createScheduledFileMessage(e,s,a,r),s}},{key:"updateScheduledFileMessage",value:function(e,n){return b(this,void 0,void 0,t().mark((function r(){var a,s,i,o,u,c,l;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(a=Object.assign(Object.assign({},pp),n),Ua(vp(a)).throw(M.invalidParameters),!H(a.file)){t.next=5;break}return t.next=5,this._uploadFileAndUpdateParams(a);case 5:return s=new gp(Object.assign({reqId:this._generateRequestId(),scheduledMessageId:e,channelType:this.channelType,channelUrl:this.url},a)),i=ns.of(this._iid),o=i.requestQueue,t.next=9,o.send(s);case 9:return u=t.sent,c=u.as(yp),l=c.message,t.abrupt("return",l);case 12:case"end":return t.stop()}}),r,this)})))}},{key:"cancelScheduledMessage",value:function(e){return b(this,void 0,void 0,t().mark((function n(){var r,a,s;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return r=new bp({scheduledMessageId:e,channelType:this.channelType,channelUrl:this.url}),a=ns.of(this._iid),s=a.requestQueue,t.next=4,s.send(r);case 4:return t.abrupt("return");case 5:case"end":return t.stop()}}),n,this)})))}},{key:"sendScheduledMessageNow",value:function(e){return b(this,void 0,void 0,t().mark((function n(){var r,a,s;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return r=new Ep({scheduledMessageId:e,channelType:this.channelType,channelUrl:this.url}),a=ns.of(this._iid),s=a.requestQueue,t.next=4,s.send(r);case 4:return t.abrupt("return");case 5:case"end":return t.stop()}}),n,this)})))}},{key:"getMyPushTriggerOption",value:function(){return b(this,void 0,void 0,t().mark((function e(){var n,r,a,s,i,o,u;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n=ns.of(this._iid),r=n.sdkState,a=n.requestQueue,s=new xp({userId:r.userId,channelUrl:this.url}),e.next=4,a.send(s);case 4:return i=e.sent,o=i.as(Tp),u=o.pushTriggerOption,this.myPushTriggerOption=u,e.abrupt("return",u);case 8:case"end":return e.stop()}}),e,this)})))}},{key:"setMyPushTriggerOption",value:function(n){return b(this,void 0,void 0,t().mark((function r(){var a,s,i,o,u,c,l,h;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return Ua(D(e.PushTriggerOption,n)).throw(M.invalidParameters),a=ns.of(this._iid),s=a.dispatcher,i=a.sdkState,o=a.requestQueue,u=new wp({userId:i.userId,channelUrl:this.url,pushTriggerOption:n}),t.next=5,o.send(u);case 5:return c=t.sent,l=c.as(Cp),h=l.pushTriggerOption,this.myPushTriggerOption=h,s.dispatch(new ru({channels:[this],source:e.GroupChannelEventSource.EVENT_CHANNEL_UPDATED})),t.abrupt("return",h);case 10:case"end":return t.stop()}}),r,this)})))}},{key:"setMyCountPreference",value:function(n){return b(this,void 0,void 0,t().mark((function r(){var a,s,i,o,u,c,l,h;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return Ua(D(e.CountPreference,n)).throw(M.invalidParameters),a=ns.of(this._iid),s=a.dispatcher,i=a.sdkState,o=a.requestQueue,u=new lp({channelUrl:this.url,userId:i.userId,countPreference:n}),t.next=5,o.send(u);case 5:return c=t.sent,l=c.as(hp),h=l.countPreference,this.myCountPreference=h,this._updateUnreadCount(this.unreadMessageCount,this.unreadMentionCount),s.dispatch(new ru({channels:[this],source:e.GroupChannelEventSource.EVENT_CHANNEL_UPDATED})),t.abrupt("return",h);case 11:case"end":return t.stop()}}),r,this)})))}},{key:"resetMyHistory",value:function(){return b(this,void 0,void 0,t().mark((function n(){var r,a,s,i,o,u,c;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return r=ns.of(this._iid),a=r.dispatcher,s=r.requestQueue,i=new dp({channelUrl:this.url}),t.next=4,s.send(i);case 4:return o=t.sent,u=o.as(fp),c=u.messageOffsetTimestamp,this.messageOffsetTimestamp=c,a.dispatch(new ru({channels:[this],source:e.GroupChannelEventSource.EVENT_CHANNEL_RESET_HISTORY})),t.abrupt("return",this);case 9:case"end":return t.stop()}}),n,this)})))}},{key:"pinMessage",value:function(e){return b(this,void 0,void 0,t().mark((function n(){var r,a,s;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return Ua(L("number",e)&&e>0).throw(M.invalidParameters),r=ns.of(this._iid),a=r.requestQueue,s=new Sp({channelType:this.channelType,channelUrl:this.url,messageId:e}),t.next=5,a.send(s);case 5:case"end":return t.stop()}}),n,this)})))}},{key:"unpinMessage",value:function(e){return b(this,void 0,void 0,t().mark((function n(){var r,a,s;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return Ua(L("number",e)&&e>0).throw(M.invalidParameters),r=ns.of(this._iid),a=r.requestQueue,s=new Ip({channelType:this.channelType,channelUrl:this.url,messageId:e}),t.next=5,a.send(s);case 5:case"end":return t.stop()}}),n,this)})))}},{key:"_uploadFileAndUpdateParams",value:function(e){return b(this,void 0,void 0,t().mark((function n(){var r,a,s,i,o,u,c,l,h,d,f,p;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(!H(e.file)){t.next=11;break}return r=ns.of(this._iid),a=r.requestQueue,s=new as({file:e.file,channelUrl:this.url,thumbnailSizes:e.thumbnailSizes,requestId:this._generateRequestId()}),t.next=5,a.send(s);case 5:i=t.sent,o=i.as(ss),u=o.url,c=o.fileSize,l=void 0===c?e.fileSize:c,h=o.thumbnailSizes,d=void 0===h?e.thumbnailSizes:h,f=o.requireAuth,p=void 0!==f&&f,e.fileUrl=u,e.fileSize=l,e.thumbnailSizes=d,e.requireAuth=p;case 11:case"end":return t.stop()}}),n,this)})))}}],[{key:"payloadify",value:function(e){return e?ee(Object.assign(Object.assign({},p(o(u),"payloadify",this).call(this,e)),{is_access_code_required:e.isAccessCodeRequired,is_distinct:e.isDistinct,is_super:e.isSuper,is_broadcast:e.isBroadcast,is_exclusive:e.isExclusive,is_public:e.isPublic,is_discoverable:e.isDiscoverable,is_muted:e.myMutedState,is_push_enabled:e.isPushEnabled,unread_message_count:e.unreadMessageCount,unread_mention_count:e.unreadMentionCount,push_trigger_option:e.myPushTriggerOption,count_preference:e.myCountPreference,hidden_state:e.hiddenState,member_count:e.memberCount,joined_member_count:e.joinedMemberCount,member_state:e.myMemberState,my_role:e.myRole,user_last_read:e.myLastRead,ts_message_offset:e.messageOffsetTimestamp,message_survival_seconds:e.messageSurvivalSeconds,read_receipt:e.cachedUnreadMemberState,delivery_receipt:e.cachedUndeliveredMemberState,members:e.members.map((function(e){return ed.payloadify(e)})),last_message:Ls(e.lastMessage),inviter:e.inviter?La.payloadify(e.inviter):null,invited_at:e.invitedAt,joined_ts:e.joinedAt,pinned_message_ids:e.pinnedMessageIds,latest_pinned_message:Ls(e.lastPinnedMessage)})):null}}]),u}(zh),Lp={},Dp=function(){function n(a){var s=this,i=a._iid,o=a.limit,u=void 0===o?100:o;r(this,n),this._sync=null,this._connectionEventContext=null,this.ref=0,this._metadata=null,this._iid=i,this._limit=u;var c,l=ns.of(this._iid),h=l.sdkState,d=l.dispatcher,f=l.logger;this._metadataKey=(c=h.userId,"sendbird:".concat(c,"@groupchannel/sync.meta"));var p=function(e){return"sendbird:".concat(e,"@groupchannel/sync")}(h.userId);this._sync=new Cf(p,(function(){return b(s,void 0,void 0,t().mark((function n(){var r,a,s,i,o,u;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return r={hasNext:!0,nextToken:""},t.next=3,this.loadMetadata();case 3:if(f.debug("channel background sync from",this._metadata.token),this._metadata.completed){t.next=31;break}return t.prev=5,s=wf.of(this._iid),t.next=9,s.getMyGroupChannels(this._metadata.token,{includeEmpty:!0,order:e.GroupChannelListOrder.CHRONOLOGICAL},this._limit,e.GroupChannelEventSource.SYNC_CHANNEL_BACKGROUND);case 9:return i=t.sent,o=i.channels,u=i.token,r.hasNext=o.length>=this._limit&&!!u,r.nextToken=u,this._metadata.token=u,(a=this._metadata.range).extends.apply(a,_(o.map((function(e){return e.createdAt})))),this._metadata.completed=!r.hasNext,f.debug("channel background sync progress",r),t.next=20,this.saveMetadata();case 20:t.next=29;break;case 22:if(t.prev=22,t.t0=t.catch(5),f.debug("channel background sync error",t.t0),!(t.t0 instanceof M&&t.t0.isInvalidTokenError)){t.next=28;break}return t.next=28,this.clearMetaData();case 28:throw t.t0;case 29:t.next=33;break;case 31:r.hasNext=!1,r.nextToken="";case 33:return t.abrupt("return",r);case 34:case"end":return t.stop()}}),n,this,[[5,22]])})))})),this._connectionEventContext=d.on((function(e){if(e instanceof Dr)if(e.stateType===Nr.CONNECTED)s.resume();else s.pause()}))}return s(n,[{key:"range",get:function(){var e;return null===(e=this._metadata)||void 0===e?void 0:e.range}},{key:"completed",get:function(){var e;return!!(null===(e=this._metadata)||void 0===e?void 0:e.completed)}},{key:"loadMetadata",value:function(){return b(this,void 0,void 0,t().mark((function e(){var n,r,a;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(this._metadata){e.next=6;break}return n=ns.of(this._iid),r=n.cacheContext,e.next=4,r.preference.get(this._metadataKey);case 4:a=e.sent,this._metadata={token:a?a.token:"",range:new kf(a?a.range:{top:Number.MAX_SAFE_INTEGER,bottom:0}),completed:!!a&&a.completed};case 6:return e.abrupt("return",this._metadata);case 7:case"end":return e.stop()}}),e,this)})))}},{key:"saveMetadata",value:function(){return b(this,void 0,void 0,t().mark((function e(){var n,r;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!this._metadata){e.next=5;break}return n=ns.of(this._iid),r=n.cacheContext,e.next=4,r.preference.set(this._metadataKey,this._metadata);case 4:return e.abrupt("return",!0);case 5:return e.abrupt("return",!1);case 6:case"end":return e.stop()}}),e,this)})))}},{key:"clearMetaData",value:function(){return b(this,void 0,void 0,t().mark((function e(){var n,r;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n=ns.of(this._iid),r=n.cacheContext,e.next=3,r.preference.remove(this._metadataKey);case 3:this._metadata=null;case 4:case"end":return e.stop()}}),e,this)})))}},{key:"resume",value:function(){var e,t,n=ns.of(this._iid),r=n.logger;n.connectionManager.isConnected&&(r.debug("channel background sync resume()"),this._sync.start(null!==(t=null===(e=this._metadata)||void 0===e?void 0:e.token)&&void 0!==t?t:""))}},{key:"pause",value:function(){ns.of(this._iid).logger.debug("channel background sync stop()"),this._sync.stop()}},{key:"close",value:function(){this.ref--,this.ref<=0&&(this.ref=0,this.pause(),this._connectionEventContext.close(),delete Lp[this._iid])}}],[{key:"of",value:function(e){return Lp[e]||(Lp[e]=new n({_iid:e})),Lp[e].ref++,Lp[e]}},{key:"clear",value:function(e){Lp[e]&&(Lp[e].close(),delete Lp[e])}}]),n}(),Pp={},Fp=function(){function n(a){var s=this,i=a._iid;r(this,n),this._sync=null,this._connectionEventContext=null,this.ref=0,this._metadataKey=null,this._metadata=null,this._iid=i;var o,u=ns.of(this._iid),c=u.logger,l=u.sdkState,h=u.dispatcher;this._metadataKey=(o=l.userId,"sendbird:".concat(o,"@groupchannel/changelogs.meta"));var d=function(e){return"sendbird:".concat(e,"@groupchannel/changelogs")}(l.userId);this._sync=new Cf(d,(function(){return b(s,void 0,void 0,t().mark((function n(){var r,a,s,i,o;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return r={hasNext:!0,nextToken:0},t.next=3,this.loadMetadata();case 3:return c.debug("channel changelog sync from",this._metadata.token),t.prev=4,a=wf.of(this._iid),t.next=8,a.getMyGroupChannelChangeLogs(this._metadata.token,{includeEmpty:!0},e.GroupChannelEventSource.SYNC_CHANNEL_CHANGELOGS);case 8:return s=t.sent,i=s.hasMore,o=s.token,r.hasNext=i,r.nextToken=o,this._metadata.token=o,c.debug("channel changelog sync progress",r),t.next=17,this.saveMetadata();case 17:t.next=26;break;case 19:if(t.prev=19,t.t0=t.catch(4),c.debug("channel changelog sync error",t.t0),!(t.t0 instanceof M&&t.t0.isInvalidTokenError)){t.next=25;break}return t.next=25,this.clearMetadata();case 25:throw t.t0;case 26:return t.abrupt("return",r);case 27:case"end":return t.stop()}}),n,this,[[4,19]])})))})),this._connectionEventContext=h.on((function(e){if(e instanceof Dr)if(e.stateType===Nr.CONNECTED)s.resume();else s.pause()}))}return s(n,[{key:"loadMetadata",value:function(){return b(this,void 0,void 0,t().mark((function e(){var n,r,a,s;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(this._metadata){e.next=6;break}return n=ns.of(this._iid),r=n.cacheContext,a=n.firstConnectedAt,e.next=4,r.preference.get(this._metadataKey);case 4:s=e.sent,this._metadata={token:s?s.token:a};case 6:return e.abrupt("return",this._metadata);case 7:case"end":return e.stop()}}),e,this)})))}},{key:"saveMetadata",value:function(){return b(this,void 0,void 0,t().mark((function e(){var n,r;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!this._metadata){e.next=5;break}return n=ns.of(this._iid),r=n.cacheContext,e.next=4,r.preference.set(this._metadataKey,this._metadata);case 4:return e.abrupt("return",!0);case 5:return e.abrupt("return",!1);case 6:case"end":return e.stop()}}),e,this)})))}},{key:"clearMetadata",value:function(){return b(this,void 0,void 0,t().mark((function e(){var n,r;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n=ns.of(this._iid),r=n.cacheContext,e.next=3,r.preference.remove(this._metadataKey);case 3:this._metadata=null;case 4:case"end":return e.stop()}}),e,this)})))}},{key:"resume",value:function(){ns.of(this._iid).connectionManager.isConnected&&this._sync.start(0)}},{key:"pause",value:function(){this._sync.stop()}},{key:"close",value:function(){this.ref--,this.ref<=0&&(this.ref=0,this.pause(),this._connectionEventContext.close(),delete Pp[this._iid])}}],[{key:"of",value:function(e){return Pp[e]||(Pp[e]=new n({_iid:e})),Pp[e].ref++,Pp[e]}},{key:"clear",value:function(e){Pp[e]&&(Pp[e].close(),delete Pp[e])}}]),n}(),Gp=function(){function n(t,a){var s=this,i=a.filter,o=a.order,u=a.limit;r(this,n),this.channels=[],this._backgroundSync=null,this._changelogSync=null,this._iid=t,this._key="gcc-".concat(Y()),this._isDisposed=!1,this.filter=null!=i?i:new rd,this.order=null!=o?o:e.GroupChannelListOrder.LATEST_LAST_MESSAGE,this._hasMore=!0,this._token="",this._limit=null!=u?u:100;var c=ns.of(this._iid),l=c.sdkState,h=c.cacheContext,d=c.dispatcher;h.localCacheEnabled&&(this._backgroundSync=Dp.of(t),this._backgroundSync.resume()),this._changelogSync=Fp.of(t),this._changelogSync.resume(),wf.of(this._iid).subscribeGroupChannelEvent(this._key,{onUpdate:function(e,t){if(nu(t)){var n=e.filter((function(e){return s.filter.match(e,l.userId)})),r=e.filter((function(e){return!s.filter.match(e,l.userId)})).map((function(e){return e.url}));n.length>0&&s._addChannelsToView(n,t),r.length>0&&s._removeChannelsFromView(r,t)}},onRemove:function(e,t){s._removeChannelsFromView(e,t)}}),ns.of(this._iid).statLogCollector.put(new ja({type:te.FEATURE_LOCALCACHE,data:{use_local_cache:h.localCacheEnabled,collection_interface:{group_channel:!0}}})),d.on((function(e){e instanceof Dr&&e.stateType===Nr.LOGOUT&&s.dispose()}))}return s(n,[{key:"hasMore",get:function(){return!this._isDisposed&&this._hasMore}},{key:"setGroupChannelCollectionHandler",value:function(e){this._handler=e}},{key:"_addChannelsToView",value:function(n,r){var a,s=this,i=arguments.length>2&&void 0!==arguments[2]&&arguments[2],o=[],u=[],c=[],l=y(n);try{for(l.s();!(a=l.n()).done;){var h=a.value,d=Pf(this.channels,h,this.order),f=d.place,p=d.oldPosition;if(-1===p)f===this.channels.length?!i&&this._hasMore||(o.push(h),this.channels.push(h)):(o.push(h),this.channels.splice(f,0,h));else switch(r){case e.GroupChannelEventSource.EVENT_CHANNEL_UPDATED:case e.GroupChannelEventSource.EVENT_MESSAGE_RECEIVED:case e.GroupChannelEventSource.SYNC_CHANNEL_CHANGELOGS:case e.GroupChannelEventSource.EVENT_MESSAGE_SENT:f!==p?this._hasMore&&f===this.channels.length?c.push(h):(this.channels.splice(p,1),this.channels.splice(p0){var v,_=y(c);try{for(_.s();!(v=_.n()).done;){var m=v.value,g=Df(this.channels,m);-1!==g&&this.channels.splice(g,1)}}catch(e){_.e(e)}finally{_.f()}}nu(r)&&ua((function(){return b(s,void 0,void 0,t().mark((function e(){var n,a,s,i;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:i=new xf(r),o.length>0&&(null===(n=this._handler)||void 0===n?void 0:n.onChannelsAdded)&&this._handler.onChannelsAdded(i,o),u.length>0&&(null===(a=this._handler)||void 0===a?void 0:a.onChannelsUpdated)&&this._handler.onChannelsUpdated(i,u),c.length>0&&(null===(s=this._handler)||void 0===s?void 0:s.onChannelsDeleted)&&this._handler.onChannelsDeleted(i,c.map((function(e){return e.url})));case 4:case"end":return e.stop()}}),e,this)})))}))}},{key:"_removeChannelsFromView",value:function(e,n){var r,a=this,s=[],i=y(e);try{var o=function(){var e=r.value,t=a.channels.findIndex((function(t){return t.url===e}));t>=0&&(s.push(a.channels[t].url),a.channels.splice(t,1))};for(i.s();!(r=i.n()).done;)o()}catch(e){i.e(e)}finally{i.f()}return nu(n)&&s.length>0&&ua((function(){return b(a,void 0,void 0,t().mark((function e(){var r,a;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:a=new xf(n),(null===(r=this._handler)||void 0===r?void 0:r.onChannelsDeleted)&&this._handler.onChannelsDeleted(a,s);case 2:case"end":return e.stop()}}),e,this)})))})),s}},{key:"_getLocalChannels",value:function(){return b(this,void 0,void 0,t().mark((function e(){var n,r;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n=wf.of(this._iid),r=this.channels.length>0?Lf(this.channels[this.channels.length-1],this.order):null,e.next=4,n.getChannelsFromCache(r,this.filter,this.order,this._limit,r?this.channels[this.channels.length-1].url:null);case 4:return e.abrupt("return",e.sent);case 5:case"end":return e.stop()}}),e,this)})))}},{key:"_getRemoteChannels",value:function(){return b(this,void 0,void 0,t().mark((function e(){var n,r,a,s;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n=wf.of(this._iid),e.next=3,n.getMyGroupChannels(this._token,Object.assign(Object.assign({},this.filter),{order:this.order}),this._limit);case 3:return r=e.sent,a=r.channels,s=r.token,this._token=s,this._hasMore=!!s,e.abrupt("return",a);case 9:case"end":return e.stop()}}),e,this)})))}},{key:"loadMore",value:function(){return b(this,void 0,void 0,t().mark((function n(){var r,a,s,i=this;return t().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:if(!this._isDisposed){n.next=2;break}throw new M({code:E.COLLECTION_DISPOSED,message:"Collection has been disposed."});case 2:if(!this._hasMore){n.next=14;break}if(r=ns.of(this._iid),a=r.cacheContext,s=[],a.localCacheEnabled&&this._backgroundSync.completed){n.next=8;break}return n.next=8,ca((function(){return b(i,void 0,void 0,t().mark((function e(){return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this._getRemoteChannels();case 2:s=e.sent;case 3:case"end":return e.stop()}}),e,this)})))}));case 8:if(!a.localCacheEnabled||0!==s.length){n.next=12;break}return n.next=11,ca((function(){return b(i,void 0,void 0,t().mark((function e(){return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this._getLocalChannels();case 2:s=e.sent;case 3:case"end":return e.stop()}}),e,this)})))}));case 11:this._backgroundSync.completed&&(this._hasMore=s.length>=this._limit);case 12:return this._addChannelsToView(s,e.GroupChannelEventSource.REQUEST_CHANNEL,!0),n.abrupt("return",s);case 14:return n.abrupt("return",[]);case 15:case"end":return n.stop()}}),n,this)})))}},{key:"dispose",value:function(){var e,t;this._isDisposed||(this._isDisposed=!0,this.channels.length>0&&this.channels.splice(0,this.channels.length),null===(e=this._backgroundSync)||void 0===e||e.close(),null===(t=this._changelogSync)||void 0===t||t.close(),wf.of(this._iid).unsubscribeGroupChannelEvent(this._key))}}]),n}(),Hp=function(t){i(a,t);var n=f(a);function a(t){var s;r(this,a);var i=t.token,o=t.limit,u=t.order,c=t.includeEmpty,l=t.membershipFilter,h=t.channelNameContainsFilter,d=t.channelUrlsFilter,f=t.customTypesFilter,p=t.customTypeStartsWithFilter,v=t.superChannelFilter,_=t.metadataOrderKeyFilter,m=t.metadataKey,g=t.metadataValues,y=t.metadataValueStartsWith,k=t.includeFrozen,b=t.includeMetaData;return(s=n.call(this)).method=B.GET,s.path=zr,s.params=ee({token:i,limit:o,order:u,show_member:!0,show_read_receipt:!0,show_delivery_receipt:!0,show_empty:c,public_mode:e.PublicChannelFilter.PUBLIC,public_membership_mode:l,name_contains:h,channel_urls:d,custom_types:f,custom_type_startswith:p,super_mode:v,metadata_order_key:_,metadata_key:m,metadata_values:g,metadata_value_startswith:y,show_frozen:k,show_metadata:b}),s}return s(a)}(ne),qp=function(e){i(n,e);var t=f(n);function n(e,a){var s;r(this,n),(s=t.call(this,e,a)).token=null,s.channels=[],s.ts=null;var i=a.next,o=a.channels,u=a.ts;return s.token=i,o&&o.length>0&&(s.channels=o.map((function(t){return t.ts=u,new Rp(e,t)}))),s.ts="number"==typeof u?u:null,s}return s(n)}(re);e.MembershipFilter=void 0,(Up=e.MembershipFilter||(e.MembershipFilter={})).ALL="all",Up.JOINED="joined";var jp,zp=function(n){i(u,n);var a=f(u);function u(t,n){var s,i,o,c,l,h,d,f,p,v,_,m,g,y,k;return r(this,u),(s=a.call(this,t,n)).includeEmpty=!1,s.includeFrozen=!0,s.includeMetaData=!0,s.channelUrlsFilter=null,s.customTypesFilter=null,s.customTypeStartsWithFilter=null,s.channelNameContainsFilter=null,s.membershipFilter=e.MembershipFilter.ALL,s.superChannelFilter=e.SuperChannelFilter.ALL,s.metadataKey=null,s.metadataValues=null,s.metadataOrderKeyFilter=null,s.metadataValueStartsWith=null,s.order=e.PublicGroupChannelListOrder.CHRONOLOGICAL,s.includeEmpty=null!==(i=n.includeEmpty)&&void 0!==i&&i,s.includeFrozen=null===(o=n.includeFrozen)||void 0===o||o,s.includeMetaData=null===(c=n.includeMetaData)||void 0===c||c,s.channelUrlsFilter=null!==(l=n.channelUrlsFilter)&&void 0!==l?l:null,s.customTypesFilter=null!==(h=n.customTypesFilter)&&void 0!==h?h:null,s.customTypeStartsWithFilter=null!==(d=n.customTypeStartsWithFilter)&&void 0!==d?d:null,s.channelNameContainsFilter=null!==(f=n.channelNameContainsFilter)&&void 0!==f?f:null,s.membershipFilter=null!==(p=n.membershipFilter)&&void 0!==p?p:e.MembershipFilter.ALL,s.superChannelFilter=null!==(v=n.superChannelFilter)&&void 0!==v?v:e.SuperChannelFilter.ALL,s.metadataKey=null!==(_=n.metadataKey)&&void 0!==_?_:null,s.metadataValues=null!==(m=n.metadataValues)&&void 0!==m?m:null,s.metadataOrderKeyFilter=null!==(g=n.metadataOrderKeyFilter)&&void 0!==g?g:null,s.metadataValueStartsWith=null!==(y=n.metadataValueStartsWith)&&void 0!==y?y:null,s.order=null!==(k=n.order)&&void 0!==k?k:e.PublicGroupChannelListOrder.CHRONOLOGICAL,s}return s(u,[{key:"_validate",value:function(){return p(o(u.prototype),"_validate",this).call(this)&&L("boolean",this.includeEmpty)&&L("boolean",this.includeFrozen)&&L("boolean",this.includeMetaData)&&L("string",this.channelNameContainsFilter,!0)&&F("string",this.channelUrlsFilter,!0)&&F("string",this.customTypesFilter,!0)&&L("string",this.customTypeStartsWithFilter,!0)&&D(e.MembershipFilter,this.membershipFilter)&&D(e.SuperChannelFilter,this.superChannelFilter)&&D(e.PublicGroupChannelListOrder,this.order)&&L("string",this.metadataOrderKeyFilter,!0)&&L("string",this.metadataKey,!0)&&F("string",this.metadataValues,!0)&&L("string",this.metadataValueStartsWith,!0)}},{key:"next",value:function(){return b(this,void 0,void 0,t().mark((function e(){var n,r,a,s,i,o,u,c;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!this._validate()){e.next=21;break}if(this._isLoading){e.next=18;break}if(n=[],!this._hasNext){e.next=15;break}return this._isLoading=!0,r=ns.of(this._iid),a=r.requestQueue,r.dispatcher,s=new Hp(Object.assign(Object.assign({},this),{token:this._token})),e.next=9,a.send(s);case 9:return i=e.sent,o=i.as(qp),u=o.channels,c=o.token,this._token=c,this._hasNext=!!c,this._isLoading=!1,e.abrupt("return",u);case 15:return e.abrupt("return",n);case 18:throw M.queryInProgress;case 19:e.next=22;break;case 21:throw M.invalidParameters;case 22:case"end":return e.stop()}}),e,this)})))}}]),u}(ki),Vp=s((function e(){r(this,e),this.onUserMuted=he,this.onUserUnmuted=he,this.onUserBanned=he,this.onUserUnbanned=he,this.onChannelChanged=he,this.onChannelDeleted=he,this.onChannelFrozen=he,this.onChannelUnfrozen=he,this.onOperatorUpdated=he,this.onChannelMemberCountChanged=he,this.onMetaDataCreated=he,this.onMetaDataUpdated=he,this.onMetaDataDeleted=he,this.onMetaCounterCreated=he,this.onMetaCounterUpdated=he,this.onMetaCounterDeleted=he,this.onMessageReceived=he,this.onMessageUpdated=he,this.onMessageDeleted=he,this.onMentionReceived=he,this.onReactionUpdated=he,this.onThreadInfoUpdated=he})),Bp=function(e){i(n,e);var t=f(n);function n(){var e;return r(this,n),(e=t.apply(this,arguments)).onUserJoined=he,e.onUserLeft=he,e.onUserReceivedInvitation=he,e.onUserDeclinedInvitation=he,e.onChannelHidden=he,e.onUnreadMemberStatusUpdated=he,e.onUndeliveredMemberStatusUpdated=he,e.onTypingStatusUpdated=he,e.onPollUpdated=he,e.onPollVoted=he,e.onPollDeleted=he,e.onPinnedMessageUpdated=he,e}return s(n)}(Vp),Qp=function(e){i(n,e);var t=f(n);function n(){var e,a=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return r(this,n),e=t.call(this),Object.keys(a).forEach((function(t){e.hasOwnProperty(t)&&(e[t]=a[t])})),e}return s(n)}(Bp),Kp=function(e){i(n,e);var t=f(n);function n(e){var a;r(this,n);var s=e.token,i=e.limit,o=e.order,u=e.reverse,c=e.channelUrl,l=e.messageTypeFilter,h=e.scheduledStatus;return(a=t.call(this)).method=B.GET,a.path="".concat(Xr),a.params=ee({limit:i,reverse:u,channel_url:c,order:o,status:h}),s&&(a.params.token=s),l&&(a.params.message_type=l),a}return s(n)}(ne),Wp=function(e){i(n,e);var t=f(n);function n(e,a){var s;r(this,n),(s=t.call(this,e,a)).token=null,s.scheduledMessages=[];var i=a.next,o=a.scheduled_messages;return s.token=i,s.scheduledMessages=o.map((function(t){return Ds(e,t)})),s}return s(n)}(re),Yp=function(n){i(u,n);var a=f(u);function u(t,n){var s,i,o,c,l,h;return r(this,u),(s=a.call(this,t,n)).channelUrl=null,s.order=null,s.reverse=!1,s.scheduledStatus=null,s.messageTypeFilter=e.MessageTypeFilter.ALL,s.channelUrl=null!==(i=n.channelUrl)&&void 0!==i?i:null,s.order=null!==(o=n.order)&&void 0!==o?o:null,s.reverse=null!==(c=n.reverse)&&void 0!==c&&c,s.scheduledStatus=null!==(l=n.scheduledStatus)&&void 0!==l?l:null,s.messageTypeFilter=null!==(h=n.messageTypeFilter)&&void 0!==h?h:e.MessageTypeFilter.ALL,s}return s(u,[{key:"_validate",value:function(){return p(o(u.prototype),"_validate",this).call(this)&&L("string",this.channelUrl,!0)&&(D(e.ScheduledMessageListOrder,this.order)||null===this.order)&&L("boolean",this.reverse)&&(F(e.ScheduledStatus,this.scheduledStatus)||null===this.scheduledStatus)&&D(e.MessageTypeFilter,this.messageTypeFilter)}},{key:"next",value:function(){return b(this,void 0,void 0,t().mark((function e(){var n,r,a,s,i,o,u;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!this._validate()){e.next=20;break}if(this._isLoading){e.next=17;break}if(!this._hasNext){e.next=14;break}return this._isLoading=!0,n=ns.of(this._iid),r=n.requestQueue,a=new Kp(Object.assign(Object.assign({},this),{token:this._token})),e.next=8,r.send(a);case 8:return s=e.sent,i=s.as(Wp),o=i.scheduledMessages,u=i.token,this._token=u,this._hasNext=!!u,this._isLoading=!1,e.abrupt("return",o);case 14:return e.abrupt("return",[]);case 17:throw M.queryInProgress;case 18:e.next=21;break;case 20:throw M.invalidParameters;case 21:case"end":return e.stop()}}),e,this)})))}}]),u}(ki),Zp=function(e){i(a,e);var n=f(a);function a(){var e;return r(this,a),(e=n.apply(this,arguments)).name="groupChannel",e}return s(a,[{key:"init",value:function(e,t){var n=t.sdkState,r=t.dispatcher,s=t.sessionManager,i=t.requestQueue,u=t.logger,c=t.onlineDetector,l=t.cacheContext;p(o(a.prototype),"init",this).call(this,e,{sdkState:n,dispatcher:r,sessionManager:s,requestQueue:i,logger:u,onlineDetector:c,cacheContext:l}),this._manager=new wf(e,{sdkState:n,cacheContext:l,dispatcher:r,sessionManager:s,requestQueue:i,logger:u})}},{key:"createGroupChannelCollection",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return new Gp(this._iid,e)}},{key:"createMyGroupChannelListQuery",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return new yf(this._iid,e)}},{key:"createPublicGroupChannelListQuery",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return new zp(this._iid,e)}},{key:"createScheduledMessageListQuery",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return new Yp(this._iid,e)}},{key:"addGroupChannelHandler",value:function(e,t){Ua(L("string",e)&&t instanceof Qp).throw(M.invalidParameters),this._manager.addHandler(e,t)}},{key:"removeGroupChannelHandler",value:function(e){Ua(L("string",e)).throw(M.invalidParameters),this._manager.removeHandler(e)}},{key:"removeAllGroupChannelHandlers",value:function(){this._manager.clearHandler()}},{key:"buildGroupChannelFromSerializedData",value:function(e){return this._manager.buildGroupChannelFromSerializedData(e)}},{key:"buildGroupChannelListQueryFromSerializedData",value:function(e){return this._manager.buildGroupChannelListQueryFromSerializedData(e)}},{key:"buildMemberFromSerializedData",value:function(e){return this._manager.buildMemberFromSerializedData(e)}},{key:"getChannel",value:function(e){return b(this,void 0,void 0,t().mark((function n(){return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return Ua(L("string",e)).throw(M.invalidParameters),t.abrupt("return",this._manager.getChannel(e));case 2:case"end":return t.stop()}}),n,this)})))}},{key:"getChannelWithoutCache",value:function(e){return b(this,void 0,void 0,t().mark((function n(){return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return Ua(L("string",e)).throw(M.invalidParameters),t.abrupt("return",this._manager.getChannelWithoutCache(e));case 2:case"end":return t.stop()}}),n,this)})))}},{key:"getMyGroupChannelChangeLogsByToken",value:function(e){var n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return b(this,void 0,void 0,t().mark((function r(){var a;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return a=Object.assign(Object.assign({},cd),n),Ua(L("string",e)&&ld(a)).throw(M.invalidParameters),t.next=4,this._manager.getMyGroupChannelChangeLogs(e,a);case 4:return t.abrupt("return",t.sent);case 5:case"end":return t.stop()}}),r,this)})))}},{key:"getMyGroupChannelChangeLogsByTimestamp",value:function(e){var n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return b(this,void 0,void 0,t().mark((function r(){var a;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return a=Object.assign(Object.assign({},cd),n),Ua(L("number",e)&&ld(a)).throw(M.invalidParameters),t.next=4,this._manager.getMyGroupChannelChangeLogs(e,a);case 4:return t.abrupt("return",t.sent);case 5:case"end":return t.stop()}}),r,this)})))}},{key:"getGroupChannelCount",value:function(e){return b(this,void 0,void 0,t().mark((function n(){var r;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return r=Object.assign(Object.assign({},hd),e),Ua(dd(r)).throw(M.invalidParameters),t.abrupt("return",this._manager.getGroupChannelCount(r));case 3:case"end":return t.stop()}}),n,this)})))}},{key:"getUnreadItemCount",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return b(this,void 0,void 0,t().mark((function n(){return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,this._manager.getUnreadItemCount(e);case 2:return t.abrupt("return",t.sent);case 3:case"end":return t.stop()}}),n,this)})))}},{key:"getTotalUnreadChannelCount",value:function(){return b(this,void 0,void 0,t().mark((function e(){return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this._manager.getTotalUnreadChannelCount();case 2:return e.abrupt("return",e.sent);case 3:case"end":return e.stop()}}),e,this)})))}},{key:"getTotalUnreadMessageCount",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return b(this,void 0,void 0,t().mark((function n(){return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,this._manager.getTotalUnreadMessageCount(e);case 2:return t.abrupt("return",t.sent);case 3:case"end":return t.stop()}}),n,this)})))}},{key:"getTotalScheduledMessageCount",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return b(this,void 0,void 0,t().mark((function n(){return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,this._manager.getTotalScheduledMessageCount(e);case 2:return t.abrupt("return",t.sent);case 3:case"end":return t.stop()}}),n,this)})))}},{key:"getSubscribedTotalUnreadMessageCount",value:function(){return this._manager.getSubscribedTotalUnreadMessageCount()}},{key:"getSubscribedCustomTypeTotalUnreadMessageCount",value:function(){return this._manager.getSubscribedCustomTypeTotalUnreadMessageCount()}},{key:"getSubscribedCustomTypeUnreadMessageCount",value:function(e){return this._manager.getSubscribedCustomTypeUnreadMessageCount(e)}},{key:"createChannel",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return b(this,void 0,void 0,t().mark((function n(){var r;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return r=Object.assign(Object.assign({},od),e),Ua(ud(r)).throw(M.invalidParameters),t.abrupt("return",this._manager.createChannel(r));case 3:case"end":return t.stop()}}),n,this)})))}},{key:"createDistinctChannelIfNotExist",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return b(this,void 0,void 0,t().mark((function n(){var r;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return r=Object.assign(Object.assign({},od),e),Ua(ud(r)).throw(M.invalidParameters),r&&(r.isDistinct=!0),t.abrupt("return",this.createChannel(r));case 4:case"end":return t.stop()}}),n,this)})))}},{key:"createChannelWithUserIds",value:function(e){var n=arguments.length>1&&void 0!==arguments[1]&&arguments[1],r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:null,a=arguments.length>3&&void 0!==arguments[3]?arguments[3]:null,s=arguments.length>4&&void 0!==arguments[4]?arguments[4]:"",i=arguments.length>5&&void 0!==arguments[5]?arguments[5]:"";return b(this,void 0,void 0,t().mark((function o(){var u;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return u=Object.assign(Object.assign({},od),{invitedUserIds:e,isDistinct:n,name:r,data:s,customType:i}),"string"==typeof a?u.coverUrl=a:u.coverImage=a,t.abrupt("return",this.createChannel(u));case 3:case"end":return t.stop()}}),o,this)})))}},{key:"markAsReadAll",value:function(){return b(this,void 0,void 0,t().mark((function e(){return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:this._manager.markAsReadAll();case 1:case"end":return e.stop()}}),e,this)})))}},{key:"markAsReadWithChannelUrls",value:function(e){return b(this,void 0,void 0,t().mark((function n(){return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:Ua(F("string",e)).throw(M.invalidParameters),this._manager.markAsReadWithChannelUrls(e);case 2:case"end":return t.stop()}}),n,this)})))}},{key:"markAsDelivered",value:function(e){return b(this,void 0,void 0,t().mark((function n(){var r;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return Ua(L("string",e)).throw(M.invalidParameters),t.next=3,this.getChannel(e);case 3:return r=t.sent,t.next=6,r.markAsDelivered();case 6:case"end":return t.stop()}}),n,this)})))}}]),a}(rs),Jp=function(e){i(a,e);var n=f(a);function a(){var e;return r(this,a),(e=n.apply(this,arguments))._channels=new Map,e._enteredChannelUrls=[],e}return s(a,[{key:"enteredChannels",get:function(){var e=this;return this._enteredChannelUrls.map((function(t){return e._channels.get(t)})).filter((function(e){return null!==e}))}},{key:"isEnteredChannel",value:function(e){return this._enteredChannelUrls.includes(e)}},{key:"enter",value:function(e){this._enteredChannelUrls.indexOf(e)<0&&this._enteredChannelUrls.push(e)}},{key:"exit",value:function(e){var t=this._enteredChannelUrls.indexOf(e);t>=0&&this._enteredChannelUrls.splice(t,1)}},{key:"exitAll",value:function(){this._enteredChannelUrls=[]}},{key:"get",value:function(e){var n;return b(this,void 0,void 0,t().mark((function r(){return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.abrupt("return",null!==(n=this._channels.get(e))&&void 0!==n?n:null);case 1:case"end":return t.stop()}}),r,this)})))}},{key:"upsert",value:function(e){return b(this,void 0,void 0,t().mark((function n(){var r=this;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:e.forEach((function(e){if(r._channels.has(e.url)){var t=r._channels.get(e.url);Object.assign(t,e)}else r._channels.set(e.url,e)}));case 1:case"end":return t.stop()}}),n)})))}},{key:"remove",value:function(e){return b(this,void 0,void 0,t().mark((function n(){return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:this._channels.delete(e),this.exit(e);case 2:case"end":return t.stop()}}),n,this)})))}},{key:"clear",value:function(){return b(this,void 0,void 0,t().mark((function e(){return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:this._channels.clear(),this._enteredChannelUrls=[];case 2:case"end":return e.stop()}}),e,this)})))}}]),a}(Ca),Xp={channelUrl:null,name:null,coverUrlOrImage:null,data:null,customType:null,operatorUserIds:null,isEphemeral:null},$p=function(e){return F("string",e.operatorUserIds,!0)&&(L("string",e.coverUrlOrImage)||H(e.coverUrlOrImage)||null===e.coverUrlOrImage)&&L("string",e.name,!0)&&L("string",e.data,!0)&&L("string",e.customType,!0)&&(L("string",e.channelUrl)&&/^\w+$/.test(e.channelUrl)||null===e.channelUrl)&&L("boolean",e.isEphemeral,!0)},ev=function(e){i(n,e);var t=f(n);function n(e){var a,s=e.channelUrl,i=e.isInternalCall;return r(this,n),(a=t.call(this)).method=B.GET,a.path="".concat(i?Qr:Br,"/").concat(encodeURIComponent(s)),a}return s(n)}(ne),tv=function(e){i(n,e);var t=f(n);function n(e,a){var s;return r(this,n),(s=t.call(this,e,a)).channel=null,s.channel=new mv(e,a),s}return s(n)}(re),nv=function(e){i(n,e);var t=f(n);function n(e){var a;r(this,n);var s=e.channelUrl,i=e.coverUrlOrImage,o=e.name,u=e.data,c=e.customType,l=e.operatorUserIds,h=e.isEphemeral;return(a=t.call(this)).method=B.POST,a.path=Br,a.params=ee({channel_url:s,cover_url:L("string",i)?i:null,cover_file:H(i)?i:null,name:o,data:u,custom_type:c,operators:l,is_ephemeral:h}),a}return s(n)}(ne),rv=function(e){i(n,e);var t=f(n);function n(e){var a=e.channelUrl;return r(this,n),t.call(this,{code:"ENTR",payload:{channel_url:a},ackRequired:!0})}return s(n)}(Mr),av=function(e){i(n,e);var t=f(n);function n(e,a,s){var i,o,u;return r(this,n),i=t.call(this,e,"SYEV",s),s.data&&(i.participantCount=null!==(o=s.data.participant_count)&&void 0!==o?o:0,i.user=new La(e,s.data),i.ts=null!==(u=s.data.edge_ts)&&void 0!==u?u:0),i}return s(n)}(jd),sv=function(e){i(n,e);var t=f(n);function n(e){var a=e.channelUrl;return r(this,n),t.call(this,{code:"EXIT",payload:{channel_url:a},ackRequired:!0})}return s(n)}(Mr),iv=function(e){i(n,e);var t=f(n);function n(e,a,s){var i,o,u;return r(this,n),i=t.call(this,e,"EXIT",s),s.data&&(i.participantCount=null!==(o=s.data.participant_count)&&void 0!==o?o:0,i.user=new La(e,s.data),i.ts=null!==(u=s.data.edge_ts)&&void 0!==u?u:0),i}return s(n)}(jd),ov={},uv=function(){function n(e,t){var a=this,s=t.sdkState,i=t.dispatcher,o=t.requestQueue;return r(this,n),ov[e]||(this._iid=e,this._sdkState=s,this._requestQueue=o,this._dispatcher=i,this._openChannelCache=new Jp(e),this._openChannelHandlers=new Map,this._dispatcher.on((function(e){if(e instanceof le)a._handleEvent(e);else if(e instanceof Dr&&e.stateType===Nr.CONNECTED){var t,n=y(a._openChannelCache.enteredChannels);try{for(n.s();!(t=n.n()).done;){t.value.enter()}}catch(e){n.e(e)}finally{n.f()}}})),ov[e]=this),ov[e]}return s(n,[{key:"buildOpenChannelFromSerializedData",value:function(e){var t=Oa(e);return new mv(this._iid,mv.payloadify(t))}},{key:"getChannelFromCache",value:function(e){return b(this,void 0,void 0,t().mark((function n(){return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,this._openChannelCache.get(e);case 2:return t.abrupt("return",t.sent);case 3:case"end":return t.stop()}}),n,this)})))}},{key:"upsertChannelsToCache",value:function(e){return b(this,void 0,void 0,t().mark((function n(){return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,this._openChannelCache.upsert(e);case 2:case"end":return t.stop()}}),n,this)})))}},{key:"removeChannelsFromCache",value:function(e){return b(this,void 0,void 0,t().mark((function n(){var r,a,s;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:r=y(e),t.prev=1,r.s();case 3:if((a=r.n()).done){t.next=9;break}return s=a.value,t.next=7,this._openChannelCache.remove(s);case 7:t.next=3;break;case 9:t.next=14;break;case 11:t.prev=11,t.t0=t.catch(1),r.e(t.t0);case 14:return t.prev=14,r.f(),t.finish(14);case 17:case"end":return t.stop()}}),n,this,[[1,11,14,17]])})))}},{key:"setEnteredToCache",value:function(e){this._openChannelCache.enter(e.url)}},{key:"setExitedToCache",value:function(e){this._openChannelCache.exit(e.url)}},{key:"_handleEvent",value:function(n){return b(this,void 0,void 0,t().mark((function r(){var a,s,i,o,u,c,l,h,d,f,p,v,_,m,g,k,E,w,C,x,T,S,I,N,M,O,U,R,L,D,P,F,G,H,q,j,z,V,B,Q,K,W,Y,Z,J,X,$,ee,te,ne,re,ae,se,ie,oe,ue,ce,le,he,de,fe,pe,ve,_e,me,ge,ye,ke,be,Ee,we,Ce,xe,Te,Se,Ie,Ne,Ae,Me,Oe,Ue,Re,Le=this;return t().wrap((function(r){for(;;)switch(r.prev=r.next){case 0:r.prev=0,r.t0=n.code,r.next="MESG"===r.t0||"FILE"===r.t0||"ADMM"===r.t0||"BRDM"===r.t0?4:"MEDI"===r.t0||"FEDI"===r.t0||"AEDI"===r.t0?14:"DELM"===r.t0?24:"MRCT"===r.t0?31:"MTHD"===r.t0?38:"MCNT"===r.t0?45:"PEDI"===r.t0?72:"VOTE"===r.t0?81:"SYEV"===r.t0?90:167;break;case 4:if(a=null,"MESG"===n.code?a=n.as(fh):"FILE"===n.code?a=n.as(Vs):"ADMM"!==n.code&&"BRDM"!=n.code||(a=n.as(pf)),!a){r.next=13;break}if(i=(s=a).message,o=s.isMentioned,i.channelType!==e.ChannelType.OPEN){r.next=13;break}return r.next=11,this.getChannel(i.channelUrl,!0);case 11:u=r.sent,ua((function(){return b(Le,void 0,void 0,t().mark((function e(){var n,r,a;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:n=y(this._openChannelHandlers.values());try{for(n.s();!(r=n.n()).done;)a=r.value,this._openChannelCache.isEnteredChannel(u.url)&&(a.onMessageReceived(u,i),o&&a.onMentionReceived(u,i))}catch(e){n.e(e)}finally{n.f()}case 2:case"end":return e.stop()}}),e,this)})))}));case 13:return r.abrupt("break",167);case 14:if(c=null,"MEDI"===n.code?c=n.as(vh):"FEDI"===n.code?c=n.as(mh):"AEDI"===n.code&&(c=n.as(vf)),!c){r.next=23;break}if(h=(l=c).message,d=l.mentionCountChange,h.channelType!==e.ChannelType.OPEN){r.next=23;break}return r.next=21,this.getChannel(h.channelUrl,!0);case 21:f=r.sent,ua((function(){return b(Le,void 0,void 0,t().mark((function e(){var n,r,a;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:n=y(this._openChannelHandlers.values());try{for(n.s();!(r=n.n()).done;)a=r.value,this._openChannelCache.isEnteredChannel(f.url)&&(a.onMessageUpdated(f,h),d>0&&a.onMentionReceived(f,h))}catch(e){n.e(e)}finally{n.f()}case 2:case"end":return e.stop()}}),e,this)})))}));case 23:return r.abrupt("break",167);case 24:if(p=n.as(yh),v=p.channelUrl,_=p.channelType,m=p.messageId,_!==e.ChannelType.OPEN){r.next=30;break}return r.next=28,this.getChannel(v,!0);case 28:g=r.sent,ua((function(){return b(Le,void 0,void 0,t().mark((function e(){var n,r,a;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:n=y(this._openChannelHandlers.values());try{for(n.s();!(r=n.n()).done;)a=r.value,this._openChannelCache.isEnteredChannel(g.url)&&a.onMessageDeleted(g,m)}catch(e){n.e(e)}finally{n.f()}case 2:case"end":return e.stop()}}),e,this)})))}));case 30:return r.abrupt("break",167);case 31:if(k=n.as(_f),E=k.channelUrl,w=k.channelType,C=k.event,w!==e.ChannelType.OPEN){r.next=37;break}return r.next=35,this.getChannel(E,!0);case 35:x=r.sent,ua((function(){return b(Le,void 0,void 0,t().mark((function e(){var n,r,a;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:n=y(this._openChannelHandlers.values());try{for(n.s();!(r=n.n()).done;)a=r.value,this._openChannelCache.isEnteredChannel(x.url)&&a.onReactionUpdated(x,C)}catch(e){n.e(e)}finally{n.f()}case 2:case"end":return e.stop()}}),e,this)})))}));case 37:return r.abrupt("break",167);case 38:if(T=n.as(mf),(S=T.event).channelType!==e.ChannelType.OPEN){r.next=44;break}return r.next=42,this.getChannel(S.channelUrl,!0);case 42:I=r.sent,ua((function(){return b(Le,void 0,void 0,t().mark((function e(){var n,r,a;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:n=y(this._openChannelHandlers.values());try{for(n.s();!(r=n.n()).done;)a=r.value,this._openChannelCache.isEnteredChannel(I.url)&&a.onThreadInfoUpdated(I,S)}catch(e){n.e(e)}finally{n.f()}case 2:case"end":return e.stop()}}),e,this)})))}));case 44:return r.abrupt("break",167);case 45:N=n.as(df),M=N.openChannelMemberCounts,O=[],U=y(M),r.prev=48,U.s();case 50:if((R=U.n()).done){r.next=59;break}return L=R.value,D=L.channelUrl,P=L.participantCount,F=L.updatedAt,r.next=55,this.getChannelFromCache(D);case 55:(G=r.sent)&&G._updateParticipantCount(P,F)&&O.push(G);case 57:r.next=50;break;case 59:r.next=64;break;case 61:r.prev=61,r.t1=r.catch(48),U.e(r.t1);case 64:return r.prev=64,U.f(),r.finish(64);case 67:if(!(O.length>0)){r.next=71;break}return r.next=70,this.upsertChannelsToCache(O);case 70:ua((function(){return b(Le,void 0,void 0,t().mark((function e(){var n,r;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:n=y(this._openChannelHandlers.values());try{for(n.s();!(r=n.n()).done;)r.value.onChannelMemberCountChanged(O)}catch(e){n.e(e)}finally{n.f()}case 2:case"end":return e.stop()}}),e,this)})))}));case 71:return r.abrupt("break",167);case 72:if(H=n.as(gf),q=H.event,j=H.status,z=H.channelUrl,V=H.channelType,z&&V){r.next=75;break}return r.abrupt("break",167);case 75:return r.next=77,this.getChannel(z,!0);case 77:return B=r.sent,this._dispatcher.dispatch(new ai({event:q,source:e.MessageEventSource.EVENT_POLL_UPDATED})),ua(j===Ns?function(){return b(Le,void 0,void 0,t().mark((function e(){var n,r;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:n=y(this._openChannelHandlers.values());try{for(n.s();!(r=n.n()).done;)r.value.onPollDeleted(B,q.pollId)}catch(e){n.e(e)}finally{n.f()}case 2:case"end":return e.stop()}}),e,this)})))}:function(){return b(Le,void 0,void 0,t().mark((function e(){var n,r;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:n=y(this._openChannelHandlers.values());try{for(n.s();!(r=n.n()).done;)r.value.onPollUpdated(B,q)}catch(e){n.e(e)}finally{n.f()}case 2:case"end":return e.stop()}}),e,this)})))}),r.abrupt("break",167);case 81:if(Q=n.as(jh),K=Q.event,W=Q.channelUrl,Y=Q.channelType,W&&Y){r.next=84;break}return r.abrupt("break",167);case 84:return r.next=86,this.getChannel(W,!0);case 86:return Z=r.sent,this._dispatcher.dispatch(new si({event:K,source:e.MessageEventSource.EVENT_POLL_VOTED})),ua((function(){return b(Le,void 0,void 0,t().mark((function e(){var n,r;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:n=y(this._openChannelHandlers.values());try{for(n.s();!(r=n.n()).done;)r.value.onPollVoted(Z,K)}catch(e){n.e(e)}finally{n.f()}case 2:case"end":return e.stop()}}),e,this)})))})),r.abrupt("break",167);case 90:if(J=n.as(jd),!(X=J.event).isOpenChannelEvent){r.next=166;break}r.t2=X.category,r.next=r.t2===nd.CHANNEL_ENTER?95:r.t2===nd.CHANNEL_EXIT?102:r.t2===nd.CHANNEL_OPERATOR_UPDATE?109:r.t2===nd.USER_CHANNEL_MUTE||r.t2===nd.USER_CHANNEL_UNMUTE?117:r.t2===nd.USER_CHANNEL_BAN||r.t2===nd.USER_CHANNEL_UNBAN?124:r.t2===nd.CHANNEL_FREEZE||r.t2===nd.CHANNEL_UNFREEZE?131:r.t2===nd.CHANNEL_DELETED?139:r.t2===nd.CHANNEL_PROP_CHANGED?146:r.t2===nd.CHANNEL_META_DATA_CHANGED?151:r.t2===nd.CHANNEL_META_COUNTERS_CHANGED?160:166;break;case 95:return r.next=97,this.getChannel(X.channelUrl,!0);case 97:return $=r.sent,ee=n.as(av),te=ee.participantCount,ne=ee.user,re=$._updateParticipantCount(te,X.ts),ua((function(){return b(Le,void 0,void 0,t().mark((function e(){return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:this._openChannelHandlers.forEach((function(e){e.onUserEntered($,ne),re&&e.onChannelParticipantCountChanged($)}));case 1:case"end":return e.stop()}}),e,this)})))})),r.abrupt("break",166);case 102:return r.next=104,this.getChannel(X.channelUrl,!0);case 104:return ae=r.sent,se=n.as(iv),ie=se.participantCount,oe=se.user,ue=ae._updateParticipantCount(ie,X.ts),ua((function(){return b(Le,void 0,void 0,t().mark((function e(){return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:this._openChannelHandlers.forEach((function(e){e.onUserExited(ae,oe),ue&&e.onChannelParticipantCountChanged(ae)}));case 1:case"end":return e.stop()}}),e,this)})))})),r.abrupt("break",166);case 109:return r.next=111,this.getChannel(X.channelUrl,!0);case 111:return ce=r.sent,le=n.as(hf),he=le.operators,ce.operators=he,this.upsertChannelsToCache([ce]),ua((function(){return b(Le,void 0,void 0,t().mark((function e(){return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:this._openChannelHandlers.forEach((function(e){e.onOperatorUpdated(ce,he)}));case 1:case"end":return e.stop()}}),e,this)})))})),r.abrupt("break",166);case 117:return r.next=119,this.getChannel(X.channelUrl,!0);case 119:return de=r.sent,fe=X.category===nd.USER_CHANNEL_MUTE,pe=n.as(fe?eh:nh),ve=pe.user,ua((function(){return b(Le,void 0,void 0,t().mark((function e(){return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:this._openChannelHandlers.forEach((function(e){fe?e.onUserMuted(de,ve):e.onUserUnmuted(de,ve)}));case 1:case"end":return e.stop()}}),e,this)})))})),r.abrupt("break",166);case 124:return r.next=126,this.getChannel(X.channelUrl,!0);case 126:return _e=r.sent,me=X.category===nd.USER_CHANNEL_BAN,ge=n.as(me?ah:ih),ye=ge.user,ua((function(){return b(Le,void 0,void 0,t().mark((function e(){return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:this._openChannelHandlers.forEach((function(e){me?e.onUserBanned(_e,ye):e.onUserUnbanned(_e,ye)}));case 1:case"end":return e.stop()}}),e,this)})))})),r.abrupt("break",166);case 131:return r.next=133,this.getChannel(X.channelUrl,!0);case 133:return ke=r.sent,be=n.as(uh),Ee=be.freeze,ke.isFrozen=Ee,this.upsertChannelsToCache([ke]),ua((function(){return b(Le,void 0,void 0,t().mark((function e(){return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:this._openChannelHandlers.forEach((function(e){Ee?e.onChannelFrozen(ke):e.onChannelUnfrozen(ke)}));case 1:case"end":return e.stop()}}),e,this)})))})),r.abrupt("break",166);case 139:return r.next=141,this.getChannel(X.channelUrl,!0);case 141:return we=r.sent,r.next=144,this.removeChannelsFromCache([we.url]);case 144:return ua((function(){return b(Le,void 0,void 0,t().mark((function e(){return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:this._openChannelHandlers.forEach((function(e){e.onChannelDeleted(we.url,we.channelType)}));case 1:case"end":return e.stop()}}),e,this)})))})),r.abrupt("break",166);case 146:return r.next=148,this.getChannelWithoutCache(X.channelUrl,!0);case 148:return Ce=r.sent,ua((function(){return b(Le,void 0,void 0,t().mark((function e(){return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:this._openChannelHandlers.forEach((function(e){e.onChannelChanged(Ce)}));case 1:case"end":return e.stop()}}),e,this)})))})),r.abrupt("break",166);case 151:return r.next=153,this.getChannel(X.channelUrl,!0);case 153:return xe=r.sent,Te=n.as(Gl),Se=Te.created,Ie=Te.updated,Ne=Te.deleted,Se&&xe._upsertCachedMetaData(Se,X.ts),Ie&&xe._upsertCachedMetaData(Ie,X.ts),Ne&&xe._removeFromCachedMetaData(Ne,X.ts),ua((function(){return b(Le,void 0,void 0,t().mark((function e(){return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:this._openChannelHandlers.forEach((function(e){Se&&e.onMetaDataCreated(xe,Se),Ie&&e.onMetaDataUpdated(xe,Ie),Ne&&e.onMetaDataDeleted(xe,Ne)}));case 1:case"end":return e.stop()}}),e,this)})))})),r.abrupt("break",166);case 160:return r.next=162,this.getChannel(X.channelUrl,!0);case 162:return Ae=r.sent,Me=n.as(Zl),Oe=Me.created,Ue=Me.updated,Re=Me.deleted,ua((function(){return b(Le,void 0,void 0,t().mark((function e(){return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:this._openChannelHandlers.forEach((function(e){Oe&&e.onMetaCounterCreated(Ae,Oe),Ue&&e.onMetaCounterUpdated(Ae,Ue),Re&&e.onMetaCounterDeleted(Ae,Re)}));case 1:case"end":return e.stop()}}),e,this)})))})),r.abrupt("break",166);case 166:return r.abrupt("break",167);case 167:r.next=173;break;case 169:if(r.prev=169,r.t3=r.catch(0),!A(r.t3)){r.next=173;break}throw r.t3;case 173:case"end":return r.stop()}}),r,this,[[0,169],[48,61,64,67]])})))}},{key:"addHandler",value:function(e,t){this._openChannelHandlers.set(e,t)}},{key:"removeHandler",value:function(e){this._openChannelHandlers.delete(e)}},{key:"clearHandler",value:function(){this._openChannelHandlers.clear()}},{key:"getChannel",value:function(e){return b(this,void 0,void 0,t().mark((function n(){var r;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return Ua(L("string",e)).throw(M.invalidParameters),t.prev=1,t.next=4,this.getChannelFromCache(e);case 4:if(!(r=t.sent)){t.next=7;break}return t.abrupt("return",r);case 7:t.next=11;break;case 9:t.prev=9,t.t0=t.catch(1);case 11:return t.next=13,this.getChannelWithoutCache(e);case 13:return t.abrupt("return",t.sent);case 14:case"end":return t.stop()}}),n,this,[[1,9]])})))}},{key:"getChannelWithoutCache",value:function(e){var n=arguments.length>1&&void 0!==arguments[1]&&arguments[1];return b(this,void 0,void 0,t().mark((function r(){var a,s,i,o;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return Ua(L("string",e)).throw(M.invalidParameters),a=new ev({channelUrl:e,isInternalCall:n}),t.next=4,this._requestQueue.send(a);case 4:return s=t.sent,i=s.as(tv),o=i.channel,t.next=8,this.upsertChannelsToCache([o]);case 8:return t.abrupt("return",o);case 9:case"end":return t.stop()}}),r,this)})))}},{key:"createChannel",value:function(e){return b(this,void 0,void 0,t().mark((function n(){var r,a,s,i,o;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return r=Object.assign(Object.assign({},Xp),e),Ua($p(r)).throw(M.invalidParameters),a=new nv(r),t.next=5,this._requestQueue.send(a);case 5:return s=t.sent,i=s.as(tv),o=i.channel,this.upsertChannelsToCache([o]),t.abrupt("return",o);case 9:case"end":return t.stop()}}),n,this)})))}}],[{key:"of",value:function(e){return ov[e]}}]),n}(),cv={name:null,coverUrlOrImage:null,data:null,customType:null,operatorUserIds:null},lv=function(e){return F("string",e.operatorUserIds,!0)&&(L("string",e.coverUrlOrImage)||H(e.coverUrlOrImage)||null===e.coverUrlOrImage)&&L("string",e.name,!0)&&L("string",e.data,!0)&&L("string",e.customType,!0)},hv=function(e){i(n,e);var t=f(n);function n(e){var a;r(this,n);var s=e.channelUrl,i=e.token,o=e.limit;return(a=t.call(this)).method=B.GET,a.path="".concat(Br,"/").concat(encodeURIComponent(s),"/participants"),a.params={token:i,limit:o},a}return s(n)}(ne),dv=function(e){i(n,e);var t=f(n);function n(e,a){var s;r(this,n),(s=t.call(this,e,a)).token=null,s.participants=[];var i=a.next,o=a.participants;return s.token=i,s.participants=o.map((function(t){return new dl(e,t)})),s}return s(n)}(re),fv=function(n){i(u,n);var a=f(u);function u(t,n,s){return r(this,u),a.call(this,t,n,e.ChannelType.OPEN,s)}return s(u,[{key:"_validate",value:function(){return p(o(u.prototype),"_validate",this).call(this)}},{key:"next",value:function(){return b(this,void 0,void 0,t().mark((function e(){var n,r,a,s,i,o,u;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!this._validate()){e.next=20;break}if(this._isLoading){e.next=17;break}if(!this._hasNext){e.next=14;break}return this._isLoading=!0,n=ns.of(this._iid),r=n.requestQueue,a=new hv(Object.assign(Object.assign({},this),{token:this._token})),e.next=8,r.send(a);case 8:return s=e.sent,i=s.as(dv),o=i.participants,u=i.token,this._token=u,this._hasNext=!!u,this._isLoading=!1,e.abrupt("return",o);case 14:return e.abrupt("return",[]);case 17:throw M.queryInProgress;case 18:e.next=21;break;case 20:throw M.invalidParameters;case 21:case"end":return e.stop()}}),e,this)})))}}]),u}(Si),pv=function(e){i(n,e);var t=f(n);function n(e){var a;r(this,n);var s=e.channelUrl,i=e.coverUrlOrImage,o=e.name,u=e.data,c=e.customType,l=e.operatorUserIds;return(a=t.call(this)).method=B.PUT,a.path="".concat(Br,"/").concat(encodeURIComponent(s)),a.params=ee({cover_url:L("string",i)?i:null,cover_file:H(i)?i:null,name:o,data:u,custom_type:c,operators:l}),a}return s(n)}(ne),vv=function(e){i(n,e);var t=f(n);function n(e,a){var s;return r(this,n),(s=t.call(this,e,a)).channel=new mv(e,a),s}return s(n)}(re),_v=function(e){i(n,e);var t=f(n);function n(e){var a;r(this,n);var s=e.channelUrl;return(a=t.call(this)).method=B.DELETE,a.path="".concat(Br,"/").concat(encodeURIComponent(s)),a}return s(n)}(ne),mv=function(n){i(u,n);var a=f(u);function u(t,n){var s,i;return r(this,u),(s=a.call(this,t,n))._lastParticipantCountUpdated=0,s.participantCount=0,s.operators=[],s.channelType=e.ChannelType.OPEN,s.participantCount=null!==(i=n.participant_count)&&void 0!==i?i:0,s.operators=Array.isArray(n.operators)?n.operators.map((function(e){return new La(t,e)})):[],s}return s(u,[{key:"serialize",value:function(){return Ma(this)}},{key:"isOperator",value:function(e){return e instanceof La?this.isOperator(e.userId):this.operators.some((function(t){return t.userId===e}))}},{key:"_updateParticipantCount",value:function(e,t){return t>this._lastParticipantCountUpdated&&(this.participantCount=e,this._lastParticipantCountUpdated=t,!0)}},{key:"createParticipantListQuery",value:function(e){return new fv(this._iid,this.url,e)}},{key:"refresh",value:function(){return b(this,void 0,void 0,t().mark((function e(){var n;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n=uv.of(this._iid),e.next=3,n.getChannelWithoutCache(this.url);case 3:return e.abrupt("return",e.sent);case 4:case"end":return e.stop()}}),e,this)})))}},{key:"enter",value:function(){return b(this,void 0,void 0,t().mark((function e(){var n,r,a,s,i,o,u;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n=ns.of(this._iid),r=n.requestQueue,a=new rv({channelUrl:this.url}),e.next=4,r.send(a);case 4:s=e.sent,i=s.as(av),o=i.participantCount,u=i.ts,this._updateParticipantCount(o,u),uv.of(this._iid).setEnteredToCache(this);case 9:case"end":return e.stop()}}),e,this)})))}},{key:"exit",value:function(){return b(this,void 0,void 0,t().mark((function e(){var n,r,a,s,i,o,u;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n=ns.of(this._iid),r=n.requestQueue,a=new sv({channelUrl:this.url}),e.next=4,r.send(a);case 4:s=e.sent,i=s.as(iv),o=i.participantCount,u=i.ts,this._updateParticipantCount(o,u),uv.of(this._iid).setExitedToCache(this),vi.of(this._iid).fileMessageQueue.cancel(this);case 11:case"end":return e.stop()}}),e,this)})))}},{key:"updateChannel",value:function(e){return b(this,void 0,void 0,t().mark((function n(){var r,a,s,i,o,u,c,l;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return r=Object.assign(Object.assign({},cv),e),Ua(lv(r)).throw(M.invalidParameters),a=ns.of(this._iid),s=a.requestQueue,i=new pv(Object.assign({channelUrl:this.url},r)),t.next=6,s.send(i);case 6:return o=t.sent,u=o.as(vv),c=u.channel,l=uv.of(this._iid),t.next=11,l.upsertChannelsToCache([c]);case 11:return t.abrupt("return",c);case 12:case"end":return t.stop()}}),n,this)})))}},{key:"updateChannelWithOperatorUserIds",value:function(e,n,r,a,s){return b(this,void 0,void 0,t().mark((function i(){var o;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return o=Object.assign(Object.assign({},cv),{name:e,coverUrlOrImage:n,data:r,operatorUserIds:a,customType:s}),t.abrupt("return",this.updateChannel(o));case 2:case"end":return t.stop()}}),i,this)})))}},{key:"delete",value:function(){return b(this,void 0,void 0,t().mark((function e(){var n,r,a,s;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n=ns.of(this._iid),r=n.requestQueue,a=new _v({channelUrl:this.url}),e.next=4,r.send(a);case 4:return s=uv.of(this._iid),e.next=7,s.removeChannelsFromCache([this.url]);case 7:case"end":return e.stop()}}),e,this)})))}},{key:"sendUserMessage",value:function(e){return Ua(!e.isPinnedMessage).throw(M.notSupportedError),p(o(u.prototype),"sendUserMessage",this).call(this,e)}},{key:"sendFileMessage",value:function(e){return Ua(!e.isPinnedMessage).throw(M.notSupportedError),p(o(u.prototype),"sendFileMessage",this).call(this,e)}}],[{key:"payloadify",value:function(e){return e?ee(Object.assign(Object.assign({},zh.payloadify(e)),{participant_count:e.participantCount,operators:e.operators.map((function(e){return La.payloadify(e)}))})):null}}]),u}(zh),gv=function(e){i(n,e);var t=f(n);function n(){var e;return r(this,n),(e=t.apply(this,arguments)).onUserEntered=he,e.onUserExited=he,e.onChannelParticipantCountChanged=he,e.onPollUpdated=he,e.onPollVoted=he,e.onPollDeleted=he,e}return s(n)}(Vp),yv=function(e){i(n,e);var t=f(n);function n(){var e,a=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return r(this,n),e=t.call(this),Object.keys(a).forEach((function(t){e.hasOwnProperty(t)&&(e[t]=a[t])})),e}return s(n)}(gv),kv=function(e){i(n,e);var t=f(n);function n(e){var a;r(this,n);var s=e.token,i=e.limit,o=e.nameKeyword,u=e.urlKeyword,c=e.customTypes,l=e.includeFrozen,h=e.includeMetaData;return(a=t.call(this)).method=B.GET,a.path=Br,a.params=ee({token:s,limit:i,name_contains:o,url_contains:u,custom_types:c,show_frozen:l,show_metadata:h}),a}return s(n)}(ne),bv=function(e){i(n,e);var t=f(n);function n(e,a){var s;r(this,n),(s=t.call(this,e,a)).token=null,s.channels=[],s.ts=null;var i=a.next,o=a.channels,u=a.ts;return s.token=i,o&&o.length>0&&(s.channels=o.map((function(t){return new mv(e,t)}))),s.ts="number"==typeof u?u:null,s}return s(n)}(re),Ev=function(e){i(a,e);var n=f(a);function a(e,t){var s,i,o,u,c,l;return r(this,a),(s=n.call(this,e,t)).includeFrozen=!0,s.includeMetaData=!0,s.nameKeyword=null,s.urlKeyword=null,s.customTypes=null,s.includeFrozen=null===(i=t.includeFrozen)||void 0===i||i,s.includeMetaData=null===(o=t.includeMetaData)||void 0===o||o,s.nameKeyword=null!==(u=t.nameKeyword)&&void 0!==u?u:null,s.urlKeyword=null!==(c=t.urlKeyword)&&void 0!==c?c:null,s.customTypes=null!==(l=t.customTypes)&&void 0!==l?l:null,s}return s(a,[{key:"_validate",value:function(){return p(o(a.prototype),"_validate",this).call(this)&&L("boolean",this.includeFrozen)&&L("boolean",this.includeMetaData)&&L("string",this.nameKeyword,!0)&&L("string",this.urlKeyword,!0)&&F("string",this.customTypes,!0)}},{key:"next",value:function(){return b(this,void 0,void 0,t().mark((function e(){var n,r,a,s,i,o,u,c;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!this._validate()){e.next=23;break}if(this._isLoading){e.next=20;break}if(!this._hasNext){e.next=17;break}return this._isLoading=!0,n=ns.of(this._iid),r=n.requestQueue,a=new kv(Object.assign(Object.assign({},this),{token:this._token})),e.next=8,r.send(a);case 8:return s=e.sent,i=s.as(bv),o=i.channels,u=i.token,this._token=u,this._hasNext=!!u,c=uv.of(this._iid),e.next=15,c.upsertChannelsToCache(o);case 15:return this._isLoading=!1,e.abrupt("return",o);case 17:return e.abrupt("return",[]);case 20:throw M.queryInProgress;case 21:e.next=24;break;case 23:throw M.invalidParameters;case 24:case"end":return e.stop()}}),e,this)})))}}]),a}(ki),wv=function(e){i(a,e);var n=f(a);function a(){var e;return r(this,a),(e=n.apply(this,arguments)).name="openChannel",e}return s(a,[{key:"init",value:function(e,t){var n=t.sdkState,r=t.dispatcher,s=t.sessionManager,i=t.requestQueue,u=t.logger,c=t.onlineDetector,l=t.cacheContext;p(o(a.prototype),"init",this).call(this,e,{sdkState:n,dispatcher:r,sessionManager:s,requestQueue:i,logger:u,onlineDetector:c,cacheContext:l}),this._manager=new uv(e,{sdkState:n,dispatcher:r,requestQueue:i})}},{key:"createOpenChannelListQuery",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return new Ev(this._iid,e)}},{key:"addOpenChannelHandler",value:function(e,t){this._manager.addHandler(e,t)}},{key:"removeOpenChannelHandler",value:function(e){this._manager.removeHandler(e)}},{key:"removeAllOpenChannelHandlers",value:function(){this._manager.clearHandler()}},{key:"buildOpenChannelFromSerializedData",value:function(e){return this._manager.buildOpenChannelFromSerializedData(e)}},{key:"getChannel",value:function(e){return b(this,void 0,void 0,t().mark((function n(){return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.abrupt("return",this._manager.getChannel(e));case 1:case"end":return t.stop()}}),n,this)})))}},{key:"getChannelWithoutCache",value:function(e){return b(this,void 0,void 0,t().mark((function n(){return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.abrupt("return",this._manager.getChannelWithoutCache(e));case 1:case"end":return t.stop()}}),n,this)})))}},{key:"createChannel",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return b(this,void 0,void 0,t().mark((function n(){return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.abrupt("return",this._manager.createChannel(e));case 1:case"end":return t.stop()}}),n,this)})))}},{key:"createChannelWithOperatorUserIds",value:function(e,n,r,a,s){return b(this,void 0,void 0,t().mark((function i(){var o;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return(o=Object.assign({},Xp)).name=e,o.coverUrlOrImage=n,o.data=r,o.operatorUserIds=a,o.customType=s,t.abrupt("return",this._manager.createChannel(o));case 7:case"end":return t.stop()}}),i,this)})))}}]),a}(rs);jp=function(){function e(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function t(e,t){for(var n=0;n-1};function Nv(e){if("string"!=typeof e&&(e=String(e)),/[^a-z0-9\-#$%&'*+.^_`|~!]/i.test(e)||""===e)throw new TypeError('Invalid character in header field name: "'+e+'"');return e.toLowerCase()}function Av(e){return"string"!=typeof e&&(e=String(e)),e}function Mv(e){var t={next:function(){var t=e.shift();return{done:void 0===t,value:t}}};return Tv.iterable&&(t[Symbol.iterator]=function(){return t}),t}function Ov(e){this.map={},e instanceof Ov?e.forEach((function(e,t){this.append(t,e)}),this):Array.isArray(e)?e.forEach((function(e){this.append(e[0],e[1])}),this):e&&Object.getOwnPropertyNames(e).forEach((function(t){this.append(t,e[t])}),this)}function Uv(e){if(e.bodyUsed)return Promise.reject(new TypeError("Already read"));e.bodyUsed=!0}function Rv(e){return new Promise((function(t,n){e.onload=function(){t(e.result)},e.onerror=function(){n(e.error)}}))}function Lv(e){var t=new FileReader,n=Rv(t);return t.readAsArrayBuffer(e),n}function Dv(e){if(e.slice)return e.slice(0);var t=new Uint8Array(e.byteLength);return t.set(new Uint8Array(e)),t.buffer}function Pv(){return this.bodyUsed=!1,this._initBody=function(e){var t;this.bodyUsed=this.bodyUsed,this._bodyInit=e,e?"string"==typeof e?this._bodyText=e:Tv.blob&&Blob.prototype.isPrototypeOf(e)?this._bodyBlob=e:Tv.formData&&FormData.prototype.isPrototypeOf(e)?this._bodyFormData=e:Tv.searchParams&&URLSearchParams.prototype.isPrototypeOf(e)?this._bodyText=e.toString():Tv.arrayBuffer&&Tv.blob&&((t=e)&&DataView.prototype.isPrototypeOf(t))?(this._bodyArrayBuffer=Dv(e.buffer),this._bodyInit=new Blob([this._bodyArrayBuffer])):Tv.arrayBuffer&&(ArrayBuffer.prototype.isPrototypeOf(e)||Iv(e))?this._bodyArrayBuffer=Dv(e):this._bodyText=e=Object.prototype.toString.call(e):this._bodyText="",this.headers.get("content-type")||("string"==typeof e?this.headers.set("content-type","text/plain;charset=UTF-8"):this._bodyBlob&&this._bodyBlob.type?this.headers.set("content-type",this._bodyBlob.type):Tv.searchParams&&URLSearchParams.prototype.isPrototypeOf(e)&&this.headers.set("content-type","application/x-www-form-urlencoded;charset=UTF-8"))},Tv.blob&&(this.blob=function(){var e=Uv(this);if(e)return e;if(this._bodyBlob)return Promise.resolve(this._bodyBlob);if(this._bodyArrayBuffer)return Promise.resolve(new Blob([this._bodyArrayBuffer]));if(this._bodyFormData)throw new Error("could not read FormData body as blob");return Promise.resolve(new Blob([this._bodyText]))},this.arrayBuffer=function(){if(this._bodyArrayBuffer){var e=Uv(this);return e||(ArrayBuffer.isView(this._bodyArrayBuffer)?Promise.resolve(this._bodyArrayBuffer.buffer.slice(this._bodyArrayBuffer.byteOffset,this._bodyArrayBuffer.byteOffset+this._bodyArrayBuffer.byteLength)):Promise.resolve(this._bodyArrayBuffer))}return this.blob().then(Lv)}),this.text=function(){var e,t,n,r=Uv(this);if(r)return r;if(this._bodyBlob)return e=this._bodyBlob,t=new FileReader,n=Rv(t),t.readAsText(e),n;if(this._bodyArrayBuffer)return Promise.resolve(function(e){for(var t=new Uint8Array(e),n=new Array(t.length),r=0;r-1?r:n),this.mode=t.mode||this.mode||null,this.signal=t.signal||this.signal,this.referrer=null,("GET"===this.method||"HEAD"===this.method)&&a)throw new TypeError("Body not allowed for GET or HEAD requests");if(this._initBody(a),!("GET"!==this.method&&"HEAD"!==this.method||"no-store"!==t.cache&&"no-cache"!==t.cache)){var s=/([?&])_=[^&]*/;if(s.test(this.url))this.url=this.url.replace(s,"$1_="+(new Date).getTime());else{this.url+=(/\?/.test(this.url)?"&":"?")+"_="+(new Date).getTime()}}}function Hv(e){var t=new FormData;return e.trim().split("&").forEach((function(e){if(e){var n=e.split("="),r=n.shift().replace(/\+/g," "),a=n.join("=").replace(/\+/g," ");t.append(decodeURIComponent(r),decodeURIComponent(a))}})),t}function qv(e,t){if(!(this instanceof qv))throw new TypeError('Please use the "new" operator, this DOM object constructor cannot be called as a function.');t||(t={}),this.type="default",this.status=void 0===t.status?200:t.status,this.ok=this.status>=200&&this.status<300,this.statusText=void 0===t.statusText?"":""+t.statusText,this.headers=new Ov(t.headers),this.url=t.url||"",this._initBody(e)}Gv.prototype.clone=function(){return new Gv(this,{body:this._bodyInit})},Pv.call(Gv.prototype),Pv.call(qv.prototype),qv.prototype.clone=function(){return new qv(this._bodyInit,{status:this.status,statusText:this.statusText,headers:new Ov(this.headers),url:this.url})},qv.error=function(){var e=new qv(null,{status:0,statusText:""});return e.type="error",e};var jv=[301,302,303,307,308];qv.redirect=function(e,t){if(-1===jv.indexOf(t))throw new RangeError("Invalid status code");return new qv(null,{status:t,headers:{location:e}})};var zv=xv.DOMException;try{new zv}catch(Nt){(zv=function(e,t){this.message=e,this.name=t;var n=Error(e);this.stack=n.stack}).prototype=Object.create(Error.prototype),zv.prototype.constructor=zv}function Vv(e,t){return new Promise((function(r,a){var s=new Gv(e,t);if(s.signal&&s.signal.aborted)return a(new zv("Aborted","AbortError"));var i=new XMLHttpRequest;function o(){i.abort()}i.onload=function(){var e,t,n={status:i.status,statusText:i.statusText,headers:(e=i.getAllResponseHeaders()||"",t=new Ov,e.replace(/\r?\n[\t ]+/g," ").split("\r").map((function(e){return 0===e.indexOf("\n")?e.substr(1,e.length):e})).forEach((function(e){var n=e.split(":"),r=n.shift().trim();if(r){var a=n.join(":").trim();t.append(r,a)}})),t)};n.url="responseURL"in i?i.responseURL:n.headers.get("X-Request-URL");var a="response"in i?i.response:i.responseText;setTimeout((function(){r(new qv(a,n))}),0)},i.onerror=function(){setTimeout((function(){a(new TypeError("Network request failed"))}),0)},i.ontimeout=function(){setTimeout((function(){a(new TypeError("Network request failed"))}),0)},i.onabort=function(){setTimeout((function(){a(new zv("Aborted","AbortError"))}),0)},i.open(s.method,function(e){try{return""===e&&xv.location.href?xv.location.href:e}catch(t){return e}}(s.url),!0),"include"===s.credentials?i.withCredentials=!0:"omit"===s.credentials&&(i.withCredentials=!1),"responseType"in i&&(Tv.blob?i.responseType="blob":Tv.arrayBuffer&&s.headers.get("Content-Type")&&-1!==s.headers.get("Content-Type").indexOf("application/octet-stream")&&(i.responseType="arraybuffer")),!t||"object"!==n(t.headers)||t.headers instanceof Ov?s.headers.forEach((function(e,t){i.setRequestHeader(t,e)})):Object.getOwnPropertyNames(t.headers).forEach((function(e){i.setRequestHeader(e,Av(t.headers[e]))})),s.signal&&(s.signal.addEventListener("abort",o),i.onreadystatechange=function(){4===i.readyState&&s.signal.removeEventListener("abort",o)}),i.send(void 0===s._bodyInit?null:s._bodyInit)}))}Vv.polyfill=!0,xv.fetch||(xv.fetch=Vv,xv.Headers=Ov,xv.Request=Gv,xv.Response=qv);var Bv=Object.freeze({__proto__:null});return e.AdminMessage=Ts,e.AppleCriticalAlertOptions=ms,e.ApplicationUserListQuery=oc,e.BannedUserListQuery=Sl,e.BaseChannel=zh,e.BaseMessage=ks,e.BlockedUserListQuery=lc,e.CachedChannelInfo=Q,e.ConnectionHandler=io,e.Emoji=Zu,e.EmojiCategory=Ju,e.EmojiContainer=Xu,e.FileMessage=Ps,e.FriendListQuery=fc,e.GroupChannel=Rp,e.GroupChannelCollection=Gp,e.GroupChannelEventContext=xf,e.GroupChannelFilter=rd,e.GroupChannelHandler=Qp,e.GroupChannelListQuery=yf,e.GroupChannelModule=Zp,e.LocalCacheConfig=K,e.Member=ed,e.MemberListQuery=rp,e.MemoryStore=$c,e.MessageCollection=Kf,e.MessageCollectionInitHandler=Qf,e.MessageEventContext=Tf,e.MessageFilter=po,e.MessageMetaArray=ps,e.MessageModule=Mi,e.MessageRequestHandler=_i,e.MessageSearchQuery=Ti,e.MutedUserListQuery=Cl,e.OGImage=vs,e.OGMetaData=_s,e.OpenChannel=mv,e.OpenChannelHandler=yv,e.OpenChannelListQuery=Ev,e.OpenChannelModule=wv,e.OperatorListQuery=bl,e.Participant=dl,e.ParticipantListQuery=fv,e.PinnedMessage=Np,e.PinnedMessageListQuery=Op,e.Plugin=Ss,e.PreviousMessageListQuery=Ii,e.PublicGroupChannelListQuery=zp,e.Reaction=fs,e.ReactionEvent=ds,e.ReadStatus=td,e.RestrictedUser=hl,e.RestrictionInfo=ll,e.ScheduledMessageListQuery=Yp,e.SendbirdChat=Bh,e.SendbirdChatOptions=q,e.SendbirdError=M,e.Sender=bs,e.SessionHandler=so,e.ThreadInfo=os,e.ThreadInfoUpdateEvent=mi,e.Thumbnail=ws,e.User=La,e.UserEventHandler=oo,e.UserMessage=Rs,Object.defineProperty(e,"__esModule",{value:!0}),e}({});