"use strict";(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[3307],{89531:function(a,b,c){c.d(b,{"$":function(){return az},A:function(){return dW},B:function(){return cW},C:function(){return cO},D:function(){return d3},F:function(){return cZ},H:function(){return ay},I:function(){return dV},L:function(){return d2},M:function(){return d0},N:function(){return cn},Q:function(){return V},S:function(){return cP},T:function(){return es},U:function(){return cQ},V:function(){return K},W:function(){return T},X:function(){return O},Y:function(){return q},Z:function(){return W},"_":function(){return s},a:function(){return ck},"a$":function(){return ek},a2:function(){return cA},a7:function(){return l},aA:function(){return bV},aB:function(){return bX},aC:function(){return bT},aD:function(){return $},aE:function(){return cm},aF:function(){return aS},aG:function(){return aT},aH:function(){return aU},aI:function(){return aV},aJ:function(){return U},aK:function(){return d7},aL:function(){return d8},aM:function(){return d9},aN:function(){return ea},aO:function(){return aH},aP:function(){return cI},aQ:function(){return aQ},aR:function(){return aE},aS:function(){return aN},aT:function(){return cx},aU:function(){return w},aV:function(){return z},aW:function(){return x},aX:function(){return b3},aY:function(){return cK},aZ:function(){return i},a_:function(){return h},ab:function(){return j},ac:function(){return et},ad:function(){return g},af:function(){return R},ag:function(){return d4},ah:function(){return cj},ai:function(){return C},al:function(){return v},am:function(){return D},an:function(){return ae},ao:function(){return em},ap:function(){return H},aq:function(){return bt},ar:function(){return bi},as:function(){return bM},at:function(){return bJ},au:function(){return bG},av:function(){return bA},aw:function(){return bD},ax:function(){return ci},ay:function(){return y},az:function(){return L},b:function(){return cl},c:function(){return co},d:function(){return eb},e:function(){return ec},f:function(){return cr},g:function(){return d5},h:function(){return cs},i:function(){return ct},j:function(){return cu},k:function(){return cp},l:function(){return cq},m:function(){return d6},n:function(){return cv},o:function(){return cw},p:function(){return dZ},q:function(){return dS},r:function(){return dX},s:function(){return dY},t:function(){return cT},u:function(){return eg},v:function(){return ee},w:function(){return d_},x:function(){return c_},z:function(){return cN}});var d,e,f=c(84663),g=function(){function a(a,b,c){var d,e;this.width=0,this.height=0,this.realWidth=0,this.realHeight=0,this._requireAuth=!1,this._iid=a,this.plainUrl=b.url,this.width=b.width,this.height=b.height,this.realWidth=null!==(d=b.real_width)&& void 0!==d?d:b.width,this.realHeight=null!==(e=b.real_height)&& void 0!==e?e:b.height,this._requireAuth=c}return a.payloadify=function(b){return(0,f.f)((0,f.g)(b instanceof a?{url:b.plainUrl,width:b.width,height:b.height,real_width:b.realWidth,real_height:b.realHeight}:{url:"",width:b.maxWidth,height:b.maxHeight,real_width:0,real_height:0}))},Object.defineProperty(a.prototype,"url",{get:function(){var a=f.V.of(this._iid).sessionManager;return this._requireAuth&&a.ekey?"".concat(this.plainUrl,"?auth=").concat(a.ekey):this.plainUrl},enumerable:!1,configurable:!0}),a}(),h=function(a){function b(b){var c=a.call(this)||this;if(c.method=f.A.POST,c.path="".concat(f.aJ),c.params=(0,f.f)({file:b.file,channel_url:b.channelUrl}),b.thumbnailSizes)for(var d=0;d0:void 0,j.lastRepliedAt=null!==(h=c.last_replied_at)&& void 0!==h?h:0,j.updatedAt=null!==(i=c.updated_at)&& void 0!==i?i:0,j}return(0,f.c)(b,a),b.payloadify=function(b){return(0,f.f)((0,f.g)((0,f.d)((0,f.d)({},a.payloadify.call(this,b)),{reply_count:b.replyCount,unread_message_count:b.unreadReplyCount,member_count:b.memberCount,most_replies:Array.isArray(b.mostRepliedUsers)?b.mostRepliedUsers.map(function(a){return f.U.payloadify(a)}):[],push_enabled:"boolean"==typeof b.isPushNotificationEnabled?b.isPushNotificationEnabled?1:0:void 0,last_replied_at:b.lastRepliedAt,updated_at:b.updatedAt})))},Object.defineProperty(b.prototype,"_isUpdateRequired",{get:function(){return void 0===this.unreadReplyCount|| void 0===this.isPushNotificationEnabled},enumerable:!1,configurable:!0}),b.prototype._updateFrom=function(a){var b,c;this.unreadReplyCount=null!==(b=a.unreadReplyCount)&& void 0!==b?b:this.unreadReplyCount,this.isPushNotificationEnabled=null!==(c=a.isPushNotificationEnabled)&& void 0!==c?c:this.isPushNotificationEnabled},b}(f.aK);(e=d||(d={})).ADD="add",e.DELETE="delete";var k,l=function(a){this.messageId=0,this.operation=null,this.updatedAt=0;var b,c=(0,f.a)("string",a.msg_id)?parseInt(a.msg_id):a.msg_id,e=a.user_id,g=a.operation?a.operation.toLowerCase():null,h=a.reaction,i=a.updated_at,j=a.count,k=a.sampled_user_ids,l=null!==(b=a.sampled_user_info)&& void 0!==b?b:{};c&&(0,f.a)("string",e)&&(0,f.a)("string",g)&&(0,f.a5)(d,g)&&(0,f.a)("string",h)&&h&&(0,f.a)("number",i)&&(this.messageId=c,this.userId=e,this.key=h,this.operation=g,this.updatedAt=i,this._count=j,this._sampledUserIds=k,this._sampledUserInfoList=l)},m=function(a){function b(b,c,d){var e,f=this;return(f=a.call(this,b)||this).userId=c,f.nickname=d.nickname,f.plainProfileUrl=d.profile_url,f.requireAuth=null!==(e=d.require_auth_for_profile_image)&& void 0!==e&&e,f}return(0,f.c)(b,a),Object.defineProperty(b.prototype,"profileUrl",{get:function(){var a=f.V.of(this._iid).sessionManager;return this.requireAuth&&a.ekey?"".concat(this.plainProfileUrl,"?auth=").concat(a.ekey):this.plainProfileUrl},enumerable:!1,configurable:!0}),b.payloadify=function(a){return{nickname:a.nickname,profile_url:a.plainProfileUrl,require_auth_for_profile_image:a.requireAuth}},b}(f.aK),n=function(a){function b(b,c){var d,e,g,h,i,j,k,l,n,o=this;(o=a.call(this,b)||this)._sampledUserInfoList=[],o._count=0,o._hasCurrentUserReacted=!1;var p=c.key,q=(0,f.s)([],(0,f.t)(null!==(h=null!==(g=c.sampled_user_ids)&& void 0!==g?g:c.user_ids)&& void 0!==h?h:[]),!1),r=null!==(j=null!==(i=c.last_ts)&& void 0!==i?i:c.updated_at)&& void 0!==j?j:0,s=null!==(k=c.is_self_included)&& void 0!==k?k:q.includes(f.V.of(b).sdkState.userId),t=null!==(l=c.sampled_user_info)&& void 0!==l?l:{};(0,f.a)("string",p)&&p&&(0,f.a2)("string",q)&&q.length>0&&(0,f.a)("number",r)&&(o.key=p,o._sampledUserIds=q,o._updatedAt=r,o._count=null!==(n=c.count)&& void 0!==n?n:q.length,o._hasCurrentUserReacted=s,Object.keys(t).forEach(function(a){o._sampledUserInfoList.push(new m(b,a,t[a]))}));var u={};try{for(var v=(0,f.x)(o.sampledUserIds),w=v.next();!w.done;w=v.next())u[w.value]=o.updatedAt}catch(x){d={error:x}}finally{try{w&&!w.done&&(e=v.return)&&e.call(v)}finally{if(d)throw d.error}}return o._version=u,o}return(0,f.c)(b,a),Object.defineProperty(b.prototype,"isEmpty",{get:function(){return 0===this._count},enumerable:!1,configurable:!0}),Object.defineProperty(b.prototype,"userIds",{get:function(){return this._sampledUserIds},enumerable:!1,configurable:!0}),Object.defineProperty(b.prototype,"sampledUserIds",{get:function(){return this._sampledUserIds},enumerable:!1,configurable:!0}),Object.defineProperty(b.prototype,"sampledUserInfoList",{get:function(){return this._sampledUserInfoList},enumerable:!1,configurable:!0}),Object.defineProperty(b.prototype,"count",{get:function(){return this._count},enumerable:!1,configurable:!0}),Object.defineProperty(b.prototype,"updatedAt",{get:function(){return this._updatedAt},enumerable:!1,configurable:!0}),Object.defineProperty(b.prototype,"hasCurrentUserReacted",{get:function(){return this._hasCurrentUserReacted},enumerable:!1,configurable:!0}),b.payloadify=function(a){var b={};return a._sampledUserInfoList.forEach(function(a){b[a.userId]=m.payloadify(a)}),(0,f.f)((0,f.g)({key:a.key,sampled_user_ids:a._sampledUserIds,sampled_user_info:b,count:a._count,is_self_included:a._hasCurrentUserReacted,last_ts:a._updatedAt}))},b.prototype.applyEvent=function(a){var b=this;if(a.key===this.key&&this.updatedAt<=a.updatedAt){if(a._sampledUserIds)this._sampledUserIds=a._sampledUserIds,this._sampledUserInfoList=[],Object.keys(a._sampledUserInfoList).forEach(function(c){b._sampledUserInfoList.push(new m(b._iid,c,a._sampledUserInfoList[c]))}),this._count=a._count,void 0!==a._hasCurrentUserReacted?this._hasCurrentUserReacted=a._hasCurrentUserReacted:this._sampledUserIds.includes(f.V.of(this._iid).sdkState.userId)&&(this._hasCurrentUserReacted=!0),this._updatedAt=a.updatedAt;else{if(!this._version[a.userId]||this._version[a.userId]<=a.updatedAt){var c=this._sampledUserIds.indexOf(a.userId);switch(a.operation){case d.ADD:c<0&&this._sampledUserIds.push(a.userId);break;case d.DELETE:c>=0&&this._sampledUserIds.splice(c,1)}this._count=this._sampledUserIds.length,this._version[a.userId]=a.updatedAt}this._updatedAt=Math.max(this.updatedAt,a.updatedAt)}}},b}(f.aK),o=function(){function a(a){this.secureUrl=null,this.type=null,this.width=0,this.height=0,this.alt=null,this.url=a.url,a.secure_url&&(this.secureUrl=a.secure_url),a.type&&(this.type=a.type),a.width&&(this.width=a.width),a.height&&(this.height=a.height),a.alt&&(this.alt=a.alt)}return a.payloadify=function(a){var b,c;return(0,f.f)((0,f.g)({url:a.url,secure_url:a.secureUrl,type:a.type,width:null!==(b=a.width)&& void 0!==b?b:0,height:null!==(c=a.height)&& void 0!==c?c:0,alt:a.alt}))},a}(),p=function(){function a(a){this.title=null,this.url=null,this.description=null,this.defaultImage=null,a["og:title"]&&(this.title=a["og:title"]),a["og:url"]&&(this.url=a["og:url"]),a["og:description"]&&(this.description=a["og:description"]),a["og:image"]&&(this.defaultImage=new o(a["og:image"]))}return a.payloadify=function(a){return(0,f.f)((0,f.g)({"og:title":a.title,"og:url":a.url,"og:description":a.description,"og:image":a.defaultImage?o.payloadify(a.defaultImage):null}))},a}(),q=function(){function a(a){var b,c;this.volume=0,this.name=null!==(b=a.name)&& void 0!==b?b:"default",this.volume=null!==(c=a.volume)&& void 0!==c?c:1}return a.prototype.serialize=function(){return{name:this.name,volume:this.volume}},a.payloadify=function(a){return(0,f.f)((0,f.g)({name:a.name,volume:a.volume}))},a}(),r=function(a){function b(b,c){var d,e=this;return(e=a.call(this,b,c)||this).isBlockedByMe=!1,e.role=(0,f.a5)(f.ai,c.role)?c.role:f.ai.NONE,e.isBlockedByMe=null!==(d=c.is_blocked_by_me)&& void 0!==d&&d,e}return(0,f.c)(b,a),b.payloadify=function(b){return(0,f.f)((0,f.g)((0,f.d)((0,f.d)({},a.payloadify.call(this,b)),{role:b.role,is_blocked_by_me:b.isBlockedByMe})))},b}(f.U),s=function(){function a(a){this.key=a.key,this.value=(0,f.a2)("string",a.value)?(0,f.s)([],(0,f.t)(a.value),!1):[]}return a.payloadify=function(a){var b;return(0,f.f)((0,f.g)({key:a.key,value:null!==(b=a.value)&& void 0!==b?b:[]}))},a}(),t=function(a){switch(a){case f.at.BASE:return"";case f.at.USER:return"MESG";case f.at.FILE:return"FILE";case f.at.ADMIN:return"ADMM"}},u=function(a){function b(b,c){var d,e,g,h,i,j,k,l,m,n=this;(n=a.call(this,b)||this).channelType=f.C.BASE,n.messageType=f.at.BASE,n.mentionType=null,n.mentionedUsers=null,n.mentionedUserIds=null,n.metaArrays=[],n.extendedMessage={},n.createdAt=0,n.updatedAt=0,n.channelUrl=c.channel_url,n.channelType=(0,f.a5)(f.C,c.channel_type)?c.channel_type:f.C.GROUP,c.channel&&(c.channel.channel_url&&(n.channelUrl=c.channel.channel_url),c.channel.channel_type&&(n.channelType=c.channel.channel_type)),n.data=null!==(d=c.data)&& void 0!==d?d:"",n.customType=null!==(e=c.custom_type)&& void 0!==e?e:"",n.mentionType=(0,f.a5)(f.ar,c.mention_type)?c.mention_type:null,n.mentionedUsers=c.mentioned_users?c.mentioned_users.map(function(a){return new f.U(n._iid,a)}):null,n.mentionedUserIds=null!==(g=c.mentioned_user_ids)&& void 0!==g?g:null,n.mentionedUsers&&!n.mentionedUserIds&&(n.mentionedUserIds=n.mentionedUsers.map(function(a){return a.userId}));var o=null!==(h=c.metaarray)&& void 0!==h?h:{},p=null!==(i=c.metaarray_key_order)&& void 0!==i?i:Object.keys(o).sort(function(a,b){return a.localeCompare(b)});n.metaArrays=[];for(var q=0;q=b)return this.parentMessage=a,!0}return!1},b.prototype.applyPoll=function(a){return!(this._poll&&this._poll.id===a.id&&this._poll.updatedAt>a.updatedAt)&&(this._poll=a,!0)},Object.defineProperty(b.prototype,"poll",{get:function(){return this._poll},enumerable:!1,configurable:!0}),b.prototype._triggerThreadInfoUpdatedEvent=function(){return(0,f._)(this,void 0,void 0,function(){var a;return(0,f.b)(this,function(b){return(a=f.V.of(this._iid).dispatcher).dispatch(new H({channelType:f.C.GROUP,channelUrl:this.channelUrl,parentMessage:this})),a.dispatch(new f.aP({messages:[this],source:f.ab.EVENT_MESSAGE_THREADINFO_UPDATED})),[2]})})},b.prototype.markThreadAsRead=function(){return(0,f._)(this,void 0,void 0,function(){var a,b;return(0,f.b)(this,function(c){switch(c.label){case 0:return a=f.V.of(this._iid).requestQueue,b=new A({channelUrl:this.channelUrl,messageId:this.messageId}),[4,a.send(b)];case 1:return c.sent(),this.threadInfo&&0!==this.threadInfo.unreadReplyCount?(this.threadInfo.unreadReplyCount=0,[4,this._triggerThreadInfoUpdatedEvent()]):[3,3];case 2:c.sent(),c.label=3;case 3:return[2]}})})},b.prototype.setPushNotificationEnabled=function(a){return(0,f._)(this,void 0,void 0,function(){var b,c;return(0,f.b)(this,function(d){switch(d.label){case 0:return b=f.V.of(this._iid).requestQueue,c=new B({channelUrl:this.channelUrl,channelType:this.channelType,messageId:this.messageId,pushEnabled:a}),[4,b.send(c)];case 1:return d.sent(),this.threadInfo&&this.threadInfo.isPushNotificationEnabled!==a&&(this.threadInfo.isPushNotificationEnabled=a),[2]}})})},b.prototype.submitMessageForm=function(a){return(0,f._)(this,void 0,void 0,function(){return(0,f.b)(this,function(a){throw f.q.legacyChatbotFeatureNotSupported})})},b.prototype.submitFeedback=function(a){return(0,f._)(this,void 0,void 0,function(){return(0,f.b)(this,function(a){throw f.q.legacyChatbotFeatureNotSupported})})},b.prototype.updateFeedback=function(a){return(0,f._)(this,void 0,void 0,function(){return(0,f.b)(this,function(a){throw f.q.legacyChatbotFeatureNotSupported})})},b.prototype.deleteFeedback=function(a){return(0,f._)(this,void 0,void 0,function(){return(0,f.b)(this,function(a){throw f.q.legacyChatbotFeatureNotSupported})})},b}(u),L=function(a){function b(b,c){var d,e,g,h,i=this;if((i=a.call(this,b,c)||this).reqId="",i.replyToChannel=!1,i.errorCode=0,c.user)i.sender=new r(i._iid,c.user);else{var j="string"==typeof c.sender_id?c.sender_id:"";i.sender=new r(i._iid,{user_id:j})}if(i.reqId=null!==(e=null!==(d=c.req_id)&& void 0!==d?d:c.request_id)&& void 0!==e?e:"",i.replyToChannel=null!==(g=c.is_reply_to_channel)&& void 0!==g&&g,c.request_state&&(0,f.a5)(f.ax,c.request_state)&&(i.sendingStatus=c.request_state),!i.sendingStatus){if(i.messageId>0)i.sendingStatus=f.ax.SUCCEEDED;else if(i.scheduledInfo)switch(c.scheduled_status&&(i._scheduledStatus=c.scheduled_status),c.scheduled_status){case D.SENT:case D.IN_QUEUE:i.sendingStatus=f.ax.SUCCEEDED;break;case D.PENDING:i.sendingStatus=f.ax.SCHEDULED;break;case D.FAILED:case D.REMOVED:i.sendingStatus=f.ax.FAILED;break;case D.CANCELED:i.sendingStatus=f.ax.CANCELED}else i.sendingStatus=f.ax.PENDING}return i.errorCode=null!==(h=c.error_code)&& void 0!==h?h:0,i._messageToken=c.mesg_token,i}return(0,f.c)(b,a),b.payloadify=function(b){return(0,f.f)((0,f.g)((0,f.d)((0,f.d)({},a.payloadify.call(this,b)),{user:r.payloadify(b.sender),req_id:b.reqId,is_reply_to_channel:b.replyToChannel,request_state:b.sendingStatus,error_code:b.errorCode,mesg_token:b._messageToken})))},Object.defineProperty(b.prototype,"isResendable",{get:function(){return(this.sendingStatus===f.ax.FAILED||this.sendingStatus===f.ax.CANCELED)&&(0,f.aQ)(this.errorCode)},enumerable:!1,configurable:!0}),b.prototype.isIdentical=function(a){return this.messageId>0&&a.messageId>0?this.messageId===a.messageId:this.reqId===a.reqId},b}(K),M={prevResultSize:0,nextResultSize:0,isInclusive:!1,reverse:!1,messageTypeFilter:f.au.ALL,customTypesFilter:void 0,senderUserIdsFilter:void 0,includeReactions:!1,includeMetaArray:!1,includeParentMessageInfo:!1},N=function(a){return(0,f.a)("number",a.prevResultSize)&&(0,f.a)("number",a.nextResultSize)&&(0,f.a)("boolean",a.isInclusive)&&(0,f.a)("boolean",a.reverse)&&(0,f.a)("string",a.messageTypeFilter)&&(0,f.a5)(f.au,a.messageTypeFilter)&&(0,f.a2)("string",a.customTypesFilter,!0)&&(0,f.a2)("string",a.senderUserIdsFilter,!0)&&(0,f.a)("boolean",a.includeMetaArray)&&(0,f.a)("boolean",a.includeReactions)&&(0,f.a)("boolean",a.includeParentMessageInfo)},O=function(a){function b(b,c){var d,e,g,h=this;if((h=a.call(this,b,c)||this).translations={},h.messageType=f.at.ADMIN,h.translations=null!==(d=c.translations)&& void 0!==d?d:{},c.parent_message_info){var i=c.parent_message_info;h.parentMessage=V(b,(0,f.f)((0,f.g)((0,f.d)((0,f.d)({},i),{message_id:h.parentMessageId,channel_url:h.channelUrl,channel_type:h.channelType,file:i.file,url:null===(e=i.file)|| void 0===e?void 0:e.url,require_auth:null===(g=i.file)|| void 0===g?void 0:g.require_auth}))))}return h}return(0,f.c)(b,a),b.payloadify=function(b){return(0,f.f)((0,f.g)((0,f.d)((0,f.d)({},a.payloadify.call(this,b)),{translations:b.translations,parent_message_info:b.parentMessage?a._getParentMessageInfoPayload.call(this,b.parentMessage):null})))},b.prototype.getThreadedMessagesByTimestamp=function(a,b){return(0,f._)(this,void 0,void 0,function(){var c;return(0,f.b)(this,function(d){switch(d.label){case 0:return c=(0,f.d)((0,f.d)({},M),b),(0,f.p)(this.messageId>0&&(0,f.a)("number",a)&&N(c)).throw(f.q.invalidParameters),[4,es.of(this._iid).getThreadedMessagesByTimestamp(this,a,c)];case 1:return[2,d.sent()]}})})},b}(K),P=function(){function a(a){var b,c;this.detail={},this.type=null!==(b=a.type)&& void 0!==b?b:"",this.vendor=null!==(c=a.vendor)&& void 0!==c?c:"",a.detail&&(0,f.a)("object",a.detail)&&!Array.isArray(a.detail)&&(this.detail=a.detail)}return a.payloadify=function(a){return(0,f.f)((0,f.g)({type:a.type,vendor:a.vendor,detail:a.detail}))},a}(),Q=function(){function a(a){this.status=a.status,a.original_message_info&&(this.originalMessageInfo={createdAt:a.original_message_info.ts,messageId:a.original_message_info.id})}return a.payloadify=function(a){return(0,f.f)({status:a.status,original_message_info:a.originalMessageInfo?{id:a.originalMessageInfo.messageId,ts:a.originalMessageInfo.createdAt}:void 0})},a}(),R=function(a){function b(b,c){var d,e,g,h,i,j,k,l=this;if((l=a.call(this,b,c)||this).messageParams=null,l.mentionedMessageTemplate=void 0,l.translations={},l.translationTargetLanguages=[],l.messageSurvivalSeconds=-1,l.plugins=[],l.messageType=f.at.USER,l.translations=null!==(g=c.translations)&& void 0!==g?g:{},l.translationTargetLanguages=null!==(h=c.target_langs)&& void 0!==h?h:[],0===Object.keys(l.translations).length&&l.translationTargetLanguages.length>0)try{for(var m=(0,f.x)(l.translationTargetLanguages),n=m.next();!n.done;n=m.next()){var o=n.value;l.translations[o]=""}}catch(p){d={error:p}}finally{try{n&&!n.done&&(e=m.return)&&e.call(m)}finally{if(d)throw d.error}}if(l.mentionedMessageTemplate=c.mentioned_message_template,l.messageSurvivalSeconds=null!==(i=c.message_survival_seconds)&& void 0!==i?i:-1,l.plugins=c.plugins?c.plugins.map(function(a){return new P(a)}):[],c.parent_message_info){var q=c.parent_message_info;l.parentMessage=V(b,(0,f.f)((0,f.g)((0,f.d)((0,f.d)({},q),{created_at:q.ts,message_id:l.parentMessageId,channel_url:l.channelUrl,channel_type:l.channelType,file:q.file,url:null===(j=q.file)|| void 0===j?void 0:j.url,require_auth:null===(k=q.file)|| void 0===k?void 0:k.require_auth}))))}return c.review_info&&(l.messageReviewInfo=new Q(c.review_info)),l}return(0,f.c)(b,a),b.payloadify=function(b){return(0,f.f)((0,f.g)((0,f.d)((0,f.d)({},a.payloadify.call(this,b)),{translations:b.translations,message_survival_seconds:b.messageSurvivalSeconds,mentioned_message_template:b.mentionedMessageTemplate,plugins:b.plugins.map(function(a){return P.payloadify(a)}),parent_message_info:b.parentMessage?a._getParentMessageInfoPayload.call(this,b.parentMessage):null,review_info:b.messageReviewInfo?Q.payloadify(b.messageReviewInfo):void 0})))},b.prototype.getThreadedMessagesByTimestamp=function(a,b){return(0,f._)(this,void 0,void 0,function(){var c;return(0,f.b)(this,function(d){switch(d.label){case 0:return c=(0,f.d)((0,f.d)({},M),b),(0,f.p)(this.messageId>0&&(0,f.a)("number",a)&&N(c)).throw(f.q.invalidParameters),[4,es.of(this._iid).getThreadedMessagesByTimestamp(this,a,c)];case 1:return[2,d.sent()]}})})},b}(L),S=function(a){function b(b,c){var d,e,g,h,i,j,k,l,m=this;if((m=a.call(this,b,c)||this).messageParams=null,m.fileInfoList=[],m.messageSurvivalSeconds=-1,m.messageType=f.at.FILE,m.data=null!==(g=null!==(e=null===(d=c.file)|| void 0===d?void 0:d.data)&& void 0!==e?e:c.custom)&& void 0!==g?g:"",m.fileInfoList=null!==(i=null===(h=c.files)|| void 0===h?void 0:h.map(function(a){return new G(b,a)}))&& void 0!==i?i:[],m.messageSurvivalSeconds=null!==(j=c.message_survival_seconds)&& void 0!==j?j:-1,c.parent_message_info){var n=c.parent_message_info;m.parentMessage=V(b,(0,f.f)((0,f.g)((0,f.d)((0,f.d)({},n),{created_at:n.ts,message_id:m.parentMessageId,channel_url:m.channelUrl,channel_type:m.channelType,file:n.file,url:null===(k=n.file)|| void 0===k?void 0:k.url,require_auth:null===(l=n.file)|| void 0===l?void 0:l.require_auth}))))}return m}return(0,f.c)(b,a),b.prototype.getThreadedMessagesByTimestamp=function(a,b){return(0,f._)(this,void 0,void 0,function(){var c;return(0,f.b)(this,function(d){switch(d.label){case 0:return c=(0,f.d)((0,f.d)({},M),b),(0,f.p)(this.messageId>0&&(0,f.a)("number",a)&&N(c)).throw(f.q.invalidParameters),[4,es.of(this._iid).getThreadedMessagesByTimestamp(this,a,c)];case 1:return[2,d.sent()]}})})},b.payloadify=function(b){var c,d,e,g,h,i;return(0,f.f)((0,f.g)((0,f.d)((0,f.d)({},a.payloadify.call(this,b)),{file:{name:null!==(d=null===(c=b.fileInfoList[0])|| void 0===c?void 0:c.fileName)&& void 0!==d?d:"",size:null!==(g=null===(e=b.fileInfoList[0])|| void 0===e?void 0:e.fileSize)&& void 0!==g?g:0,type:null!==(i=null===(h=b.fileInfoList[0])|| void 0===h?void 0:h.mimeType)&& void 0!==i?i:"",data:b.data},files:Array.isArray(b.fileInfoList)?b.fileInfoList.map(function(a){return G.payloadify(a)}):null,message_survival_seconds:b.messageSurvivalSeconds,parent_message_info:b.parentMessage?a._getParentMessageInfoPayload.call(this,b.parentMessage):null})))},b._isMultipleFilesMessagePayload=function(a){var b=a.files;return Array.isArray(b)&&b.length>=2},b._isMultipleFilesMessageSerializedData=function(a){return Array.isArray(a.fileInfoList)},b}(L);(J=I||(I={})).SENT="SENT",J.READ="READ";var T=function(a){function b(b,c){var d,e,g=this;if((g=a.call(this,b,c)||this).notificationData=null,g.notificationId=c.notification_message_id,g.messageType=f.at.ADMIN,g.messageStatus=null!==(d=c.message_status)&& void 0!==d?d:I.SENT,g.priority=null!==(e=c.priority)&& void 0!==e?e:f.aR.NORMAL,g.notificationEventDeadline=c.notification_event_deadline,0===g.extendedMessage.sub_type)try{var h=JSON.parse(g.extendedMessage.sub_data),i=h.label,j=h.tags,k=void 0===j?[]:j,l=h.template_key,m=h.template_variables;g.notificationData={label:i,tags:k,templateKey:l,templateVariables:m}}catch(n){}return g}return(0,f.c)(b,a),b.payloadify=function(b){return(0,f.f)((0,f.g)((0,f.d)((0,f.d)({},a.payloadify.call(this,b)),{notification_message_id:b.notificationId,message_status:b.messageStatus,priority:b.priority,notification_event_deadline:b.notificationEventDeadline})))},b.prototype.isIdentical=function(a){return this.notificationId===a.notificationId},b}(u),U=function(a){if(a.notificationId)return T.payloadify(a);switch(a.messageType){case f.at.USER:return R.payloadify(a);case f.at.FILE:return a.fileInfoList?S.payloadify(a):W.payloadify(a);case f.at.ADMIN:return O.payloadify(a);default:throw f.q.unknown}},V=function(a,b){if(b.notification_message_id)return new T(a,b);switch(b.type){case"MESG":return new R(a,b);case"FILE":return S._isMultipleFilesMessagePayload(b)?new S(a,b):new W(a,b);case"ADMM":case"BRDM":return new O(a,b);default:return null}},W=function(a){function b(b,c){var d,e,h,i,j,k,l,m,n,o,p,q,r,s,t,u=this;(u=a.call(this,b,c)||this).messageParams=null,u.plainUrl="",u.requireAuth=!1,u.thumbnails=[],u.messageSurvivalSeconds=-1,u.messageType=f.at.FILE;var v=c.file;if(u.plainUrl=(null!==(e=null!==(d=null==v?void 0:v.url)&& void 0!==d?d:c.url)&& void 0!==e?e:"").split("?auth=")[0],u.name=null!==(i=null!==(h=null==v?void 0:v.name)&& void 0!==h?h:c.name)&& void 0!==i?i:"File",u.size=null!==(k=null!==(j=null==v?void 0:v.size)&& void 0!==j?j:c.size)&& void 0!==k?k:0,u.data=null!==(n=null!==(m=null!==(l=null==v?void 0:v.data)&& void 0!==l?l:c.custom)&& void 0!==m?m:u.data)&& void 0!==n?n:"",u.type=v?null!==(o=v.type)&& void 0!==o?o:"":null!==(p=c.type)&& void 0!==p?p:"",u.requireAuth=null!==(q=c.require_auth)&& void 0!==q&&q,u.thumbnails=c.thumbnails?c.thumbnails.map(function(a){var b;return new g(u._iid,"string"==typeof a?{url:a,width:0,height:0}:(0,f.d)((0,f.d)({},a),{url:(null!==(b=a.url)&& void 0!==b?b:"").split("auth=")[0]}),u.requireAuth)}):[],u.messageSurvivalSeconds=null!==(r=c.message_survival_seconds)&& void 0!==r?r:-1,c.parent_message_info){var w=c.parent_message_info;u.parentMessage=V(b,(0,f.f)((0,f.g)((0,f.d)((0,f.d)({},w),{created_at:w.ts,message_id:u.parentMessageId,channel_url:u.channelUrl,channel_type:u.channelType,file:w.file,url:null===(s=w.file)|| void 0===s?void 0:s.url,require_auth:null===(t=w.file)|| void 0===t?void 0:t.require_auth}))))}return u}return(0,f.c)(b,a),b.payloadify=function(b){var c;return(0,f.f)((0,f.g)((0,f.d)((0,f.d)({},a.payloadify.call(this,b)),{url:b.plainUrl,require_auth:b.requireAuth,file:{name:b.name,size:b.size,type:b.type,data:b.data},thumbnails:null===(c=b.thumbnails)|| void 0===c?void 0:c.map(function(a){return{url:a.plainUrl,width:a.width,height:a.height,real_width:a.realWidth,real_height:a.realHeight}}),message_survival_seconds:b.messageSurvivalSeconds,parent_message_info:b.parentMessage?a._getParentMessageInfoPayload.call(this,b.parentMessage):null})))},Object.defineProperty(b.prototype,"url",{get:function(){var a=f.V.of(this._iid).sessionManager;return this.requireAuth&&a.ekey?"".concat(this.plainUrl,"?auth=").concat(a.ekey):this.plainUrl},enumerable:!1,configurable:!0}),b.prototype.getThreadedMessagesByTimestamp=function(a,b){return(0,f._)(this,void 0,void 0,function(){var c;return(0,f.b)(this,function(d){switch(d.label){case 0:return c=(0,f.d)((0,f.d)({},M),b),(0,f.p)(this.messageId>0&&(0,f.a)("number",a)&&N(c)).throw(f.q.invalidParameters),[4,es.of(this._iid).getThreadedMessagesByTimestamp(this,a,c)];case 1:return[2,d.sent()]}})})},b}(L),X=function(a){function b(b,c){var d=c.file,e=c.fileUrl,f=c.fileName,g=c.fileSize,h=c.mimeType,i=c.thumbnailSizes,j=c._uploadedMetaData,k=c._thumbnails,l=a.call(this,b)||this;return l._plainUrl=e,l.file=d,l.fileName=f,l.fileSize=g,l.mimeType=h,l.thumbnailSizes=i,l._uploadedMetaData=j,l._thumbnails=k,l}return(0,f.c)(b,a),b.getPlainUrl=function(a){return a instanceof b?a._plainUrl:a.fileUrl},Object.defineProperty(b.prototype,"fileUrl",{get:function(){var a,b=f.V.of(this._iid).sessionManager;return this._plainUrl&&(null===(a=this._uploadedMetaData)|| void 0===a?void 0:a.requireAuth)&&b.ekey?"".concat(this._plainUrl,"?auth=").concat(b.ekey):this._plainUrl},set:function(a){this._plainUrl=a},enumerable:!1,configurable:!0}),b.prototype.toJSON=function(){return{file:this.file,fileUrl:this._plainUrl,fileName:this.fileName,fileSize:this.fileSize,mimeType:this.mimeType,thumbnailSizes:this.thumbnailSizes,_thumbnails:this._thumbnails,_uploadedMetaData:this._uploadedMetaData}},b}(f.aK),Y=function(a){function b(b){var c,d,e,h,i=[];return b.mentionType===f.ar.USERS&&(b.mentionedUserIds?i=b.mentionedUserIds:b.mentionedUsers&&(i=b.mentionedUsers.map(function(a){return a.userId}))),a.call(this,{code:"FILE",ackRequired:!0,payload:(0,f.f)((0,f.g)({channel_url:b.channelUrl,files:b.files?aa(b.files):null,url:b.url,name:null!==(c=b.fileName)&& void 0!==c?c:"",type:null!==(d=b.mimeType)&& void 0!==d?d:"",size:null!==(e=b.fileSize)&& void 0!==e?e:0,custom:b.data,custom_type:b.customType,thumbnails:null===(h=b._thumbnails)|| void 0===h?void 0:h.map(function(a){return g.payloadify(a)}),require_auth:b.requireAuth,metaarray:b.metaArrays,mention_type:b.mentionType,mentioned_user_ids:i,push_option:b.pushNotificationDeliveryOption&&b.pushNotificationDeliveryOption!==f.av.DEFAULT?b.pushNotificationDeliveryOption:void 0,apple_critical_alert_options:b.appleCriticalAlertOptions?q.payloadify(b.appleCriticalAlertOptions):null,silent:b.silent,reply_to_channel:b.isReplyToChannel,parent_message_id:b.parentMessageId?b.parentMessageId:null,req_id:b.reqId,poll_id:b.pollId,pin_message:b.isPinnedMessage,message:b.message?b.message:void 0}))})||this}return(0,f.c)(b,a),b}(f.aN),Z=function(a){function b(b){var c,d,e=this;e=a.call(this)||this;var h=[];return b.mentionType===f.ar.USERS&&(b.mentionedUserIds?h=b.mentionedUserIds:b.mentionedUsers&&(h=b.mentionedUsers.map(function(a){return a.userId}))),e.method=f.A.POST,e.path="".concat((0,f.aO)(b.channelType),"/").concat(encodeURIComponent(b.channelUrl),"/messages"),e.params=(0,f.f)((0,f.g)({message_type:f.at.FILE,user_id:b.userId,files:b.files?aa(b.files):null,url:b.fileUrl,mention_type:b.mentionType,mentioned_user_ids:h,file_name:b.fileName,file_size:b.fileSize,file_type:b.mimeType,data:b.data,custom_type:b.customType,thumbnails:null===(c=b._thumbnails)|| void 0===c?void 0:c.map(function(a){return g.payloadify(a)}),require_auth:b.requireAuth,sorted_metaarray:null===(d=b.metaArrays)|| void 0===d?void 0:d.map(function(a){return s.payloadify(a)}),push_option:b.pushNotificationDeliveryOption,parent_message_id:b.parentMessageId?b.parentMessageId:null,apple_critical_alert_options:b.appleCriticalAlertOptions?q.payloadify(b.appleCriticalAlertOptions):null,reply_to_channel:b.isReplyToChannel,req_id:b.reqId,poll_id:b.pollId,pin_message:b.isPinnedMessage})),e}return(0,f.c)(b,a),b}(f.h),$=function(a){function b(b,c,d){var e,g,h,i,j=this;(j=a.call(this,b,"FILE",d)||this).message=d.files&&d.files.length>=2?new S(b,d):new W(b,d);var k=f.V.of(b).sdkState;return j.isMentioned=(0,f.aS)(j.message.mentionType,null!==(h=null!==(e=j.message.mentionedUserIds)&& void 0!==e?e:null===(g=j.message.mentionedUsers)|| void 0===g?void 0:g.map(function(a){return a.userId}))&& void 0!==h?h:[],k.userId),j.forceUpdateLastMessage=null!==(i=d.force_update_last_message)&& void 0!==i&&i,j}return(0,f.c)(b,a),b}(f.W),_=function(a){function b(b,c){var d,e,g,h,i=this;(i=a.call(this,b,c)||this).message=c.files&&c.files.length>=2?new S(b,c):new W(b,c);var j=f.V.of(b).sdkState;return i.isMentioned=(0,f.aS)(i.message.mentionType,null!==(g=null!==(d=i.message.mentionedUserIds)&& void 0!==d?d:null===(e=i.message.mentionedUsers)|| void 0===e?void 0:e.map(function(a){return a.userId}))&& void 0!==g?g:[],j.userId),i.forceUpdateLastMessage=null!==(h=c.force_update_last_message)&& void 0!==h&&h,i}return(0,f.c)(b,a),b}(f.j);function aa(a){return a.map(function(a){var b,c;return(0,f.f)((0,f.g)({url:X.getPlainUrl(a),file_name:a.fileName,file_type:a.mimeType,file_size:a.fileSize,thumbnails:null===(b=a._thumbnails)|| void 0===b?void 0:b.map(function(a){return g.payloadify(a)}),require_auth:null===(c=a._uploadedMetaData)|| void 0===c?void 0:c.requireAuth}))})}(ab=ac||(ac={}))[ab.PENDING=0]="PENDING",ab[ab.UPLOADING=1]="UPLOADING",ab[ab.UPLOADED=2]="UPLOADED",ab[ab.SENDING=3]="SENDING",ab[ab.FAILED=4]="FAILED";var ab,ac,ad,ae,af,ag,ah=function(){function a(a,b){var c=b.sdkState,d=b.dispatcher,e=b.requestQueue,g=b.onlineDetector,h=b.cacheContext,i=this;this._queueMap=new Map,this._iid=a,this._sdkState=c,this._requestQueue=e,this._cacheContext=h,this._dispatcher=d,this._dispatcher.on(function(a){a instanceof f.K&&(i._connectionState=a.stateType)}),this._onlineDetector=g}return Object.defineProperty(a.prototype,"_shouldSendThroughWebSocket",{get:function(){return this._connectionState===f.M.CONNECTED||this._connectionState===f.M.CONNECTING||this._connectionState===f.M.RECONNECTING},enumerable:!1,configurable:!0}),a.prototype._sendFileMessage=function(a,b){return(0,f._)(this,void 0,void 0,function(){var c,d,e;return(0,f.b)(this,function(g){switch(g.label){case 0:return c=this._createSendFileMessageRequestParams(a,b),this._shouldSendThroughWebSocket?(d=new Y(c),[4,this._requestQueue.send(d)]):[3,2];case 1:return[2,(e=g.sent()).as($).message];case 2:return d=new Z((0,f.d)((0,f.d)({},c),{userId:this._sdkState.userId})),[4,this._requestQueue.send(d)];case 3:return[2,(e=g.sent()).as(_).message]}})})},a.prototype._createSendFileMessageRequestParams=function(a,b){var c=(0,f.d)((0,f.d)({},b.params),{channelUrl:a.url,channelType:a.channelType,reqId:b.requestId,url:""});if(b.multipleFileUploadInfo){var d=b.params;c.files=d.fileInfoList}else d=b.params,c.url=d.fileUrl,c.requireAuth=d.requireAuth;return c},a.prototype._resolveMessageQueue=function(a){var b;return(0,f._)(this,void 0,void 0,function(){var c,d,e,g,h,i,j,k,l,m,n,o,p;return(0,f.b)(this,function(q){switch(q.label){case 0:if(!(c=this._queueMap.get(a.url)))return[3,21];if(c.isResolving)return[3,20];c.isResolving=!0,d=[],e=!0,q.label=1;case 1:q.trys.push([1,15,16,17]),h=(g=(0,f.x)(c.messageQueue)).next(),q.label=2;case 2:if(h.done)return[3,14];switch((i=h.value).state){case ac.PENDING:case ac.UPLOADING:return[3,3];case ac.UPLOADED:return[3,4];case ac.FAILED:return[3,12]}return[3,13];case 3:return e=!1,d.push(i),[3,13];case 4:if(!e)return[3,10];q.label=5;case 5:return q.trys.push([5,8,,9]),i.state=ac.SENDING,[4,this._sendFileMessage(a,i)];case 6:return j=q.sent(),i.deferred.resolve(j),[4,(0,f.aU)(100)];case 7:return q.sent(),[3,9];case 8:return k=q.sent(),i.deferred.reject(k),[3,9];case 9:return[3,11];case 10:d.push(i),q.label=11;case 11:return[3,13];case 12:return l=null!==(b=i.error)&& void 0!==b?b:f.q.unknown,i.deferred.reject(l.code===f.F.REQUEST_CANCELED?f.q.fileUploadCanceled:l),[3,13];case 13:return h=g.next(),[3,2];case 14:return[3,17];case 15:return o={error:m=q.sent()},[3,17];case 16:try{h&&!h.done&&(p=g.return)&&p.call(g)}finally{if(o)throw o.error}return[7];case 17:return n=c.isResolveRequestPending,c.messageQueue=d,c.isResolving=!1,c.isResolveRequestPending=!1,n?[4,this._resolveMessageQueue(a)]:[3,19];case 18:q.sent(),q.label=19;case 19:return[3,21];case 20:c.isResolveRequestPending=!0,q.label=21;case 21:return[2]}})})},a.prototype._uploadNextPendingItem=function(a){var b;return(0,f._)(this,void 0,void 0,function(){var c,d,e,g,h,i,j,k,l,m;return(0,f.b)(this,function(n){switch(n.label){case 0:return(c=this._queueMap.get(a.url))&&(d=c.messageQueue.find(function(a){return a.state===ac.PENDING}))?d.multipleFileUploadInfo?(g=(e=d.multipleFileUploadInfo).uploadIndex,h=e.uploadCount,i=e.requestHandler,m=d.params,j=m.fileInfoList[g],!(0,f.i)(j.file)||(null===(b=j._uploadedMetaData)|| void 0===b?void 0:b.isUploaded)?[3,2]:[4,this._tryUploadNextItemAndUpdateItemState(a,c,d)]):[3,4]:[3,9];case 1:return n.sent(),[3,3];case 2:d.state=g=0&&a.uploadQueue.splice(c,1)},a.prototype._uploadNextFileForSingleFileItemAndUpdateParams=function(a,b,c){var d,e,g;return(0,f._)(this,void 0,void 0,function(){var j,k,l,m,n,o,p,q,r,s;return(0,f.b)(this,function(f){switch(f.label){case 0:return j=new h({file:c.file,channelUrl:a.url,thumbnailSizes:c.thumbnailSizes,requestId:b.requestId}),[4,this._requestQueue.send(j)];case 1:return m=(l=(k=f.sent()).as(i)).url,n=l.fileSize,o=void 0===n?c.fileSize:n,p=l.thumbnails,q=void 0===p?[]:p,r=l.requireAuth,s=void 0!==r&&r,c.fileName=null!==(d=c.fileName)&& void 0!==d?d:c.file.name,c.mimeType=null!==(e=c.mimeType)&& void 0!==e?e:c.file.type,c.fileSize=null!==(g=c.fileSize)&& void 0!==g?g:c.file.size,c.fileUrl=m,c.fileSize=o,c.requireAuth=s,c._thumbnails=q,[2]}})})},a.prototype._uploadNextFileForMultipleFilesItemAndUpdateParams=function(a,b,c){var d,e,g;return(0,f._)(this,void 0,void 0,function(){var j,k,l,m,n,o,p,q,r,s,t;return(0,f.b)(this,function(u){switch(u.label){case 0:return j=b.multipleFileUploadInfo.uploadIndex,k=c.fileInfoList[j],l=new h({file:k.file,channelUrl:a.url,thumbnailSizes:k.thumbnailSizes,requestId:b.requestId}),[4,this._requestQueue.send(l)];case 1:return o=(n=(m=u.sent()).as(i)).url,p=n.fileSize,q=void 0===p?k.fileSize:p,r=n.thumbnails,s=n.requireAuth,t=void 0!==s&&s,k.fileName=null!==(d=k.fileName)&& void 0!==d?d:k.file.name,k.mimeType=null!==(e=k.mimeType)&& void 0!==e?e:k.file.type,k.fileSize=null!==(g=k.fileSize)&& void 0!==g?g:k.file.size,k.file=void 0,k.fileUrl=o,k.fileSize=q,k._thumbnails=r,k._uploadedMetaData=(0,f.d)((0,f.d)({},k._uploadedMetaData),{requireAuth:t,isUploaded:!0}),k instanceof X||(c.fileInfoList[j]=new X(this._iid,k)),[2]}})})},a.prototype.request=function(a,b,c,d){return void 0===d&&(d={}),(0,f._)(this,void 0,void 0,function(){var e,g,h,i,j;return(0,f.b)(this,function(k){var l;return this._queueMap.has(a.url)||(e={messageQueue:[],uploadQueue:[],isResolving:!1,isResolveRequestPending:!1},this._queueMap.set(a.url,e)),g=this._queueMap.get(a.url),h=new f.aV,i={requestId:b,params:c,state:ac.PENDING,deferred:h},l=c,"fileInfoList"in l&&(j=(0,f.d)({uploadIndex:0,uploadCount:c.fileInfoList.length},d),i.multipleFileUploadInfo=j),g.messageQueue.push(i),this._uploadNextPendingItem(a),[2,h.promise]})})},a.prototype.cancel=function(a,b){var c,d,e=this._queueMap.get(a.url);if(e){var g=b?[e.messageQueue.find(function(a){return a.requestId===b})]:(0,f.s)([],(0,f.t)(e.messageQueue),!1);try{for(var h=(0,f.x)(g),i=h.next();!i.done;i=h.next()){var j=i.value;if(j)switch(j.state){case ac.PENDING:if(j.state=ac.FAILED,j.error=f.q.requestCanceled,j.multipleFileUploadInfo&&!j.multipleFileUploadInfo.isCopy){var k=j.multipleFileUploadInfo,l=k.uploadIndex,m=k.requestHandler,n=j.params.fileInfoList[l];null==m||m._triggerOnFileUploaded(j.requestId,l,n,f.q.fileUploadCanceled)}this._resolveMessageQueue(a);break;case ac.UPLOADING:this._requestQueue.cancel(j.requestId),this._dispatcher.dispatch(new f.aT({requestId:j.requestId}))}}}catch(o){c={error:o}}finally{try{i&&!i.done&&(d=h.return)&&d.call(h)}finally{if(c)throw c.error}}}else b&&(this._requestQueue.cancel(b),this._dispatcher.dispatch(new f.aT({requestId:b})))},a}(),ai={prevResultSize:0,nextResultSize:0,isInclusive:!1,reverse:!1,messageTypeFilter:f.au.ALL,customTypesFilter:void 0,senderUserIdsFilter:void 0,replyType:f.aw.NONE,includeReactions:!1,includeMetaArray:!1,includeParentMessageInfo:!1,includeThreadInfo:!1,showSubchannelMessagesOnly:!1},aj=function(a){return(0,f.a)("number",a.prevResultSize)&&(0,f.a)("number",a.nextResultSize)&&(0,f.a)("boolean",a.isInclusive)&&(0,f.a)("boolean",a.reverse)&&(0,f.a)("string",a.messageTypeFilter)&&(0,f.a5)(f.au,a.messageTypeFilter)&&(0,f.a2)("string",a.customTypesFilter,!0)&&(0,f.a2)("string",a.senderUserIdsFilter,!0)&&(0,f.a5)(f.aw,a.replyType)&&(0,f.a)("boolean",a.includeMetaArray)&&(0,f.a)("boolean",a.includeReactions)&&(0,f.a)("boolean",a.includeParentMessageInfo)&&(0,f.a)("boolean",a.includeThreadInfo)&&(0,f.a)("boolean",a.showSubchannelMessagesOnly)},ak={replyType:f.aw.NONE,includeReactions:!1,includeThreadInfo:!1,includeMetaArray:!1,includeParentMessageInfo:!1},al=function(a){return(0,f.a5)(f.aw,a.replyType)&&(0,f.a)("boolean",a.includeReactions)&&(0,f.a)("boolean",a.includeMetaArray)&&(0,f.a)("boolean",a.includeParentMessageInfo)&&(0,f.a)("boolean",a.includeThreadInfo)};(ad||(ad={})).MESSAGE="message",(ag=ae||(ae={})).INTERNAL_BACKSYNC="internal_backsync",ag.INTERNAL_FILL_GAP="internal_fill_gap",ag.EXTERNAL_LEGACY="external_legacy",ag.EXTERNAL_COLLECTION="external_collection";var am,an,ao,ap=function(a){function b(b){var c=b.channelType,d=b.channelUrl,e=b.messageId,g=b.includeMetaArray,h=b.includeReactions,i=b.includeThreadInfo,j=b.includeParentMessageInfo,k=a.call(this)||this;return k.method=f.A.GET,k.path="".concat((0,f.aO)(c),"/").concat(encodeURIComponent(d),"/messages/").concat(encodeURIComponent(e)),k.params={is_sdk:!0,with_sorted_meta_array:g,include_reactions_summary:null!=h&&h,include_thread_info:i,include_parent_message_info:j,include_poll_details:!0},k}return(0,f.c)(b,a),b}(f.h),aq=function(a){function b(b,c){var d=a.call(this,b,c)||this;return d.message=c?V(b,(0,f.d)({},c)):null,d}return(0,f.c)(b,a),b}(f.j),ar=function(a){function b(b){var c=b.channelType,d=b.channelUrl,e=b.timestamp,g=b.token,h=b.prevResultSize,i=b.nextResultSize,j=b.isInclusive,k=b.reverse,l=b.messageTypeFilter,m=b.customTypesFilter,n=b.senderUserIdsFilter,o=b.replyType,p=b.includeMetaArray,q=b.includeReactions,r=b.parentMessageId,s=b.includeThreadInfo,t=b.includeParentMessageInfo,u=b.showSubchannelMessagesOnly,v=b.checkingHasNext,w=b.checkingContinuousMessages,x=b.sdkSource,y=a.call(this)||this;return y.method=f.A.GET,y.path="".concat((0,f.aO)(c),"/").concat(encodeURIComponent(d),"/messages"),y.params=(0,f.f)((0,f.g)({is_sdk:!0,prev_limit:h,next_limit:i,include:j,reverse:k,message_ts:e,message_id:g,message_type:null!=l?l:null,custom_types:m,sender_ids:n,include_reply_type:o,with_sorted_meta_array:p,include_reactions_summary:q,parent_message_id:r,include_thread_info:s,include_parent_message_info:t,show_subchannel_message_only:u,include_poll_details:!0,checking_has_next:v,checking_continuous_messages:w,sdk_source:x})),y}return(0,f.c)(b,a),b}(f.h),as=function(a){function b(b,c){var d=a.call(this,b,c)||this;return void 0!==c.is_continuous_messages&&(d.isContinuousMessages=c.is_continuous_messages),void 0!==c.has_next&&(d.hasNext=c.has_next),d.messages=c.messages.map(function(a){return V(b,a)}),d}return(0,f.c)(b,a),b}(f.j),at=function(a){function b(b){var c=b.channelType,d=b.channelUrl,e=b.timestamp,g=b.token,h=b.replyType,i=b.includeMetaArray,j=b.includeReactions,k=b.includeThreadInfo,l=b.includeParentMessageInfo,m=a.call(this)||this;return m.method=f.A.GET,m.path="".concat((0,f.aO)(c),"/").concat(encodeURIComponent(d),"/messages/changelogs"),m.params={change_ts:e,token:g,with_sorted_meta_array:i,include_reactions_summary:j,include_thread_info:k,include_reply_type:h,include_parent_message_info:l,include_poll_details:!0},m}return(0,f.c)(b,a),b}(f.h),au=function(a){function b(b,c){var d=a.call(this,b,c)||this;return d.updatedMessages=c.updated.map(function(a){return V(b,a)}),d.deletedMessagesInfo=c.deleted.map(function(a){return{messageId:a.message_id,deletedAt:a.deleted_at}}),d.hasMore=c.has_more,d.nextToken=c.next,d.forceUseNextToken=c.force_use_next_token||!1,d}return(0,f.c)(b,a),b}(f.j),av=function(a){function b(b){var c=b.channelUrl,d=b.scheduledMessageId,e=a.call(this)||this;return e.method=f.A.GET,e.path="".concat(f.aW,"/").concat(encodeURIComponent(c),"/scheduled_messages/").concat(encodeURIComponent(d)),e.params={},e}return(0,f.c)(b,a),b}(f.h),aw=function(a){function b(b,c){var d=a.call(this,b,c)||this;return d.message=c?V(b,(0,f.d)({},c)):null,d}return(0,f.c)(b,a),b}(f.j);(an=am||(am={})).MUTED="muted",an.BANNED="banned";var ax=function(){function a(a){var b,c,d,e;this.restrictionType=null,(0,f.a5)(am,a.restriction_type)&&(this.restrictionType=a.restriction_type),this.description=null!==(b=a.description)&& void 0!==b?b:null,this.endAt=null!==(d=null!==(c=a.end_at)&& void 0!==c?c:a.muted_end_at)&& void 0!==d?d:-1,this.remainingDuration=null!==(e=a.remaining_duration)&& void 0!==e?e:-1}return a.payloadify=function(a){return(0,f.f)((0,f.g)({restriction_type:a.restrictionType,description:a.description,end_at:a.endAt,remaining_duration:a.remainingDuration}))},a}(),ay=function(a){function b(b,c){var d=a.call(this,b,c)||this;return d.restrictionInfo=new ax(c),d}return(0,f.c)(b,a),b.payloadify=function(b){return(0,f.f)((0,f.g)((0,f.d)((0,f.d)({},a.payloadify.call(this,b)),ax.payloadify(b.restrictionInfo))))},b}(f.U),az=(ao=f.U,(0,f.c)(function a(b,c){var d,e=this;return(e=ao.call(this,b,c)||this).isMuted=!1,e.isMuted=null!==(d=c.is_muted)&& void 0!==d&&d,e},ao),function(){function a(){this._onPending=f.aX,this._onFailed=f.aX,this._onSucceeded=f.aX}return a.prototype._trigger=function(a){switch(null==a?void 0:a.sendingStatus){case f.ax.PENDING:0===a.errorCode&&this._onPending(a);break;case f.ax.SCHEDULED:case f.ax.SUCCEEDED:this._onSucceeded(a)}},a.prototype._triggerFailed=function(a,b){switch(null==b?void 0:b.sendingStatus){case f.ax.FAILED:case f.ax.CANCELED:this._onFailed(a,b.scheduledInfo?null:b)}},a.prototype.onPending=function(a){return this._onPending=a,this},a.prototype.onFailed=function(a){return this._onFailed=a,this},a.prototype.onSucceeded=function(a){return this._onSucceeded=a,this},a}()),aA={data:void 0,customType:void 0,mentionType:f.ar.USERS,mentionedUserIds:void 0,mentionedUsers:void 0,metaArrays:void 0,parentMessageId:void 0,isReplyToChannel:!1,pushNotificationDeliveryOption:void 0,appleCriticalAlertOptions:void 0,isPinnedMessage:!1,pollId:void 0},aB=function(a){return(0,f.a)("string",a.data,!0)&&(0,f.a)("string",a.customType,!0)&&(0,f.a5)(f.ar,a.mentionType)&&(0,f.a2)("string",a.mentionedUserIds,!0)&&(0,f.a2)(f.U,a.mentionedUsers,!0)&&(0,f.a2)(s,a.metaArrays,!0)&&(0,f.a)("number",a.parentMessageId,!0)&&(0,f.a)("boolean",a.isReplyToChannel)&&(0,f.a5)(f.av,a.pushNotificationDeliveryOption,!0)&&(0,f.a)(q,a.appleCriticalAlertOptions,!0)&&(0,f.a)("boolean",a.isPinnedMessage,!0)&&(0,f.a)("number",a.pollId,!0)},aC=function(a){return{isReplyToChannel:a.isReplyToChannel,pushNotificationDeliveryOption:a.pushNotificationDeliveryOption,pollId:a.pollId}},aD=(0,f.d)((0,f.d)({},aA),{message:"",mentionedMessageTemplate:void 0,translationTargetLanguages:void 0,extendedMessagePayload:void 0});function aE(a){var b,c,d;return null!==(b=a.messageParams)&& void 0!==b?b:(0,f.g)((0,f.d)((0,f.d)({},a),{mentionType:a.mentionType,mentionedUserIds:null!==(c=a.mentionedUserIds)&& void 0!==c?c:null===(d=a.mentionedUsers)|| void 0===d?void 0:d.map(function(a){return a.userId}),mentionedMessageTemplate:a.mentionedMessageTemplate,translationTargetLanguages:Object.keys(a.translations),pushNotificationDeliveryOption:f.av.DEFAULT,parentMessageId:null,isReplyToChannel:!1,isPinnedMessage:!1}))}var aF,aG,aH=function(a){var b;return(0,f.f)((0,f.g)({data:a.data,customType:a.customType,mentionType:a.mentionType,mentionedUsers:a.mentionedUsers,mentionedUserIds:a.mentionedUserIds,mentionedMessageTemplate:a.mentionedMessageTemplate,metaArrays:a.metaArrays,pollId:null===(b=a.poll)|| void 0===b?void 0:b.id,parentMessageId:a.parentMessageId,appleCriticalAlertOptions:a.appleCriticalAlertOptions,message:a.message,translationTargetLanguages:Object.keys(a.translations),extendedMessagePayload:a.extendedMessagePayload}))},aI=function(a){return aB(a)&&(0,f.a)("string",a.message)&&(0,f.a)("string",a.mentionedMessageTemplate,!0)&&(0,f.a2)("string",a.translationTargetLanguages,!0)&&(0,f.a)("object",a.extendedMessagePayload,!0)};(aG=aF||(aF={})).FILE="file",aG.BLOB="blob",aG.BLOB_LIKE_OBJECT="blobLikeObject",aG.URL="url";var aJ=function(a){return"undefined"!=typeof window&&"Blob"in window&&"undefined"!=typeof Blob&&a instanceof Blob},aK=function(a){return a===aF.BLOB||a===aF.FILE},aL=function(a){return{file:a.file,fileKey:a.fileKey,fileType:a.fileType,isReplyToChannel:a.isReplyToChannel,pushNotificationDeliveryOption:a.pushNotificationDeliveryOption}},aM=(0,f.d)((0,f.d)({},aA),{file:void 0,fileKey:void 0,fileUrl:void 0,fileName:void 0,fileType:void 0,fileSize:void 0,mimeType:void 0,thumbnailSizes:void 0,requireAuth:!1,message:void 0});function aN(a){var b,c,d,e;return null!==(b=a.messageParams)&& void 0!==b?b:(0,f.g)((0,f.d)((0,f.d)({},a),{fileUrl:a.plainUrl,fileName:a.name,fileSize:a.size,mimeType:a.type,mentionType:a.mentionType,mentionedUserIds:null!==(c=a.mentionedUserIds)&& void 0!==c?c:null===(d=a.mentionedUsers)|| void 0===d?void 0:d.map(function(a){return a.userId}),pushNotificationDeliveryOption:f.av.DEFAULT,parentMessageId:null,isReplyToChannel:!1,thumbnailSizes:null===(e=a.thumbnails)|| void 0===e?void 0:e.map(function(a){return{maxWidth:a.width,maxHeight:a.height}}),requireAuth:a.requireAuth,isPinnedMessage:!1,_thumbnails:a.thumbnails,message:a.message}))}var aO,aP,aQ=function(a,b){var c,d;return a.messageParams?(!a.url&&(0,f.i)(b)&&(a.messageParams.file=b),a.messageParams):(0,f.f)((0,f.g)({data:a.data,customType:a.customType,mentionType:a.mentionType,mentionedUsers:a.mentionedUsers,mentionedUserIds:a.mentionedUserIds,metaArrays:a.metaArrays,parentMessageId:a.parentMessageId,appleCriticalAlertOptions:a.appleCriticalAlertOptions,file:b,fileUrl:a.url,fileName:a.name,fileSize:a.size,mimeType:a.type,thumbnailSizes:null===(c=a.thumbnails)|| void 0===c?void 0:c.map(function(a){return{maxWidth:a.width,maxHeight:a.height}}),message:a.message,pollId:null===(d=a.poll)|| void 0===d?void 0:d.id}))},aR=function(a){return aB(a)&&((0,f.i)(a.file)||(0,f.a)("string",a.fileUrl))&&(0,f.a)("string",a.fileName,!0)&&(0,f.a)("string",a.mimeType,!0)&&(0,f.a)("number",a.fileSize,!0)&&(0,f.a)("string",a.message,!0)&&(null===a.thumbnailSizes|| void 0===a.thumbnailSizes||Array.isArray(a.thumbnailSizes)&&a.thumbnailSizes.every(function(a){return(0,f.a)("object",a)&&a.maxWidth>0&&a.maxHeight>0}))},aS={data:void 0,customType:void 0,mentionType:f.ar.USERS,mentionedUserIds:void 0,mentionedUsers:void 0,metaArrays:void 0,pushNotificationDeliveryOption:void 0,appleCriticalAlertOptions:void 0},aT=function(a){return(0,f.a)("string",a.data,!0)&&(0,f.a)("string",a.customType,!0)&&(0,f.a5)(f.ar,a.mentionType)&&(0,f.a2)("string",a.mentionedUserIds,!0)&&(0,f.a2)(f.U,a.mentionedUsers,!0)&&(0,f.a2)(s,a.metaArrays,!0)&&(0,f.a5)(f.av,a.pushNotificationDeliveryOption,!0)&&(0,f.a)(q,a.appleCriticalAlertOptions,!0)},aU=(0,f.d)((0,f.d)({},aS),{message:void 0,mentionedMessageTemplate:void 0,translationTargetLanguages:void 0,pollId:void 0}),aV=function(a){return aT(a)&&(0,f.a)("string",a.mentionedMessageTemplate,!0)&&(0,f.a)("string",a.message,!0)&&(0,f.a2)("string",a.translationTargetLanguages,!0)&&(0,f.a)("number",a.pollId,!0)},aW=(0,f.d)({},aS),aX=function(a){function b(b){var c=b.channelUrl,d=b.channelType,e=b.token,g=b.limit,h=a.call(this)||this;return h.method=f.A.GET,h.path="".concat((0,f.aO)(d),"/").concat(encodeURIComponent(c),"/operators"),h.params={token:e,limit:g},h}return(0,f.c)(b,a),b}(f.h),aY=function(a){function b(b,c){var d=a.call(this,b,c)||this;return d.operators=c.operators.map(function(a){return new f.U(b,a)}),d.token=c.next,d}return(0,f.c)(b,a),b}(f.j),aZ=function(a){function b(b,c,d,e){return a.call(this,b,c,d,e)||this}return(0,f.c)(b,a),b.prototype._validate=function(){return a.prototype._validate.call(this)},b.prototype.next=function(){return(0,f._)(this,void 0,void 0,function(){var a,b,c,d,e,g,h;return(0,f.b)(this,function(i){switch(i.label){case 0:return this._validate()?this._isLoading?[3,3]:(a=[],this._hasNext?(this._isLoading=!0,b=f.V.of(this._iid).requestQueue,c=new aX((0,f.d)((0,f.d)({},this),{channelUrl:this.channelUrl,token:this._token})),[4,b.send(c)]):[3,2]):[3,5];case 1:return g=(e=(d=i.sent()).as(aY)).operators,h=e.token,this._token=h,this._hasNext=!!h,this._isLoading=!1,[2,g];case 2:return[2,a];case 3:throw f.q.queryInProgress;case 4:return[3,6];case 5:throw f.q.invalidParameters;case 6:return[2]}})})},b}(f.aY),a$=function(a){function b(b,c,d,e){var g,h,i,j,k,l,m,n,o,p,q=this;return(q=a.call(this,b,c,d,e)||this).reverse=!1,q.messageTypeFilter=f.au.ALL,q.customTypesFilter=null,q.senderUserIdsFilter=null,q.replyType=f.aw.NONE,q.includeMetaArray=!1,q.includeReactions=!1,q.includeParentMessageInfo=!1,q.includeThreadInfo=!1,q.showSubchannelMessagesOnly=!1,q._edge=Number.MAX_SAFE_INTEGER,q.reverse=null!==(g=e.reverse)&& void 0!==g&&g,q.messageTypeFilter=null!==(h=e.messageTypeFilter)&& void 0!==h?h:f.au.ALL,q.customTypesFilter=null!==(i=e.customTypesFilter)&& void 0!==i?i:null,q.senderUserIdsFilter=null!==(j=e.senderUserIdsFilter)&& void 0!==j?j:null,q.replyType=null!==(k=e.replyType)&& void 0!==k?k:f.aw.NONE,q.includeMetaArray=null!==(l=e.includeMetaArray)&& void 0!==l&&l,q.includeReactions=null!==(m=e.includeReactions)&& void 0!==m&&m,q.includeParentMessageInfo=null!==(n=e.includeParentMessageInfo)&& void 0!==n&&n,q.includeThreadInfo=null!==(o=e.includeThreadInfo)&& void 0!==o&&o,q.showSubchannelMessagesOnly=null!==(p=e.showSubchannelMessagesOnly)&& void 0!==p&&p,q}return(0,f.c)(b,a),b.prototype._validate=function(){return a.prototype._validate.call(this)&&(0,f.a)("boolean",this.reverse)&&(0,f.a5)(f.au,this.messageTypeFilter)&&(0,f.a5)(f.aw,this.replyType)&&(0,f.a2)("string",this.customTypesFilter,!0)&&(0,f.a2)("string",this.senderUserIdsFilter,!0)&&(0,f.a)("boolean",this.includeMetaArray)&&(0,f.a)("boolean",this.includeReactions)&&(0,f.a)("boolean",this.includeParentMessageInfo)&&(0,f.a)("boolean",this.includeThreadInfo)&&(0,f.a)("boolean",this.showSubchannelMessagesOnly)},b.prototype.load=function(){return(0,f._)(this,void 0,void 0,function(){var a;return(0,f.b)(this,function(b){switch(b.label){case 0:return this._validate()?this._isLoading?[3,3]:this._hasNext?(this._isLoading=!0,[4,es.of(this._iid).getMessagesByTimestamp(this.channelUrl,this.channelType,this._edge,(0,f.g)({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 a=b.sent(),this._edge=Math.min.apply(Math,(0,f.s)([Number.MAX_SAFE_INTEGER],(0,f.t)(a.map(function(a){return a.createdAt})),!1)),this._hasNext=a.length>=this.limit,this._isLoading=!1,[2,a];case 2:return[2,[]];case 3:throw f.q.queryInProgress;case 4:return[3,6];case 5:throw f.q.invalidParameters;case 6:return[2]}})})},b}(f.aY),a_=function(a){function b(b){var c=this,d=b.channelUrl,e=b.channelType,g=b.limit,h=b.token;return(c=a.call(this)||this).method=f.A.GET,c.path="".concat((0,f.aO)(e),"/").concat(encodeURIComponent(d),"/mute"),c.params={limit:g,token:h},c}return(0,f.c)(b,a),b}(f.h),a0=function(a){function b(b,c){var d=a.call(this,b,c)||this;d.mutedUsers=[];var e=c.next,f=c.muted_list;return d.token=e,f&&f.length>0&&(d.mutedUsers=f.map(function(a){return new ay(b,a)})),d}return(0,f.c)(b,a),b}(f.j),a1=function(a){function b(b,c,d,e){return a.call(this,b,c,d,e)||this}return(0,f.c)(b,a),b.prototype.next=function(){return(0,f._)(this,void 0,void 0,function(){var a,b,c,d,e,g;return(0,f.b)(this,function(h){switch(h.label){case 0:return this._validate()?this._isLoading?[3,3]:this._hasNext?(this._isLoading=!0,a=f.V.of(this._iid).requestQueue,b=new a_((0,f.d)((0,f.d)({},this),{token:this._token})),[4,a.send(b)]):[3,2]:[3,5];case 1:return e=(d=(c=h.sent()).as(a0)).mutedUsers,g=d.token,this._token=g,this._hasNext=!!g,this._isLoading=!1,[2,e];case 2:return[2,[]];case 3:throw f.q.queryInProgress;case 4:return[3,6];case 5:throw f.q.invalidParameters;case 6:return[2]}})})},b}(f.aY),a2=function(a){function b(b){var c=this,d=b.channelUrl,e=b.channelType,g=b.limit,h=b.token;return(c=a.call(this)||this).method=f.A.GET,c.path="".concat((0,f.aO)(e),"/").concat(encodeURIComponent(d),"/ban"),c.params=(0,f.f)({limit:g,token:h}),c}return(0,f.c)(b,a),b}(f.h),a3=function(a){function b(b,c){var d=a.call(this,b,c)||this;d.bannedUsers=[];var e=c.next,f=c.banned_list;return d.token=e,f&&f.length>0&&(d.bannedUsers=f.map(function(a){return new ay(b,a.user)})),d}return(0,f.c)(b,a),b}(f.j),a4=function(a){function b(b,c,d,e){return a.call(this,b,c,d,e)||this}return(0,f.c)(b,a),b.prototype._validate=function(){return a.prototype._validate.call(this)},b.prototype.next=function(){return(0,f._)(this,void 0,void 0,function(){var a,b,c,d,e,g;return(0,f.b)(this,function(h){switch(h.label){case 0:return this._validate()?this._isLoading?[3,3]:this._hasNext?(this._isLoading=!0,a=f.V.of(this._iid).requestQueue,b=new a2((0,f.d)((0,f.d)({},this),{token:this._token})),[4,a.send(b)]):[3,2]:[3,5];case 1:return e=(d=(c=h.sent()).as(a3)).bannedUsers,g=d.token,this._token=g,this._hasNext=!!g,this._isLoading=!1,[2,e];case 2:return[2,[]];case 3:throw f.q.queryInProgress;case 4:return[3,6];case 5:throw f.q.invalidParameters;case 6:return[2]}})})},b}(f.aY);(aP=aO||(aO={})).SPAM="spam",aP.HARASSING="harassing",aP.SUSPICIOUS="suspicious",aP.INAPPROPRIATE="inappropriate";var a5,a6=function(a){function b(b){var c=this,d=b.channelUrl,e=b.channelType,g=b.operatorUserIds;return(c=a.call(this)||this).method=f.A.POST,c.path="".concat((0,f.aO)(e),"/").concat(encodeURIComponent(d),"/operators"),c.params={operator_ids:g},c}return(0,f.c)(b,a),b}(f.h);a5=f.j,(0,f.c)(function(){return null!==a5&&a5.apply(this,arguments)||this},a5);var a7,a8=function(a){function b(b){var c=this,d=b.channelUrl,e=b.channelType,g=b.operatorUserIds;return(c=a.call(this)||this).method=f.A.DELETE,c.path="".concat((0,f.aO)(e),"/").concat(encodeURIComponent(d),"/operators"),c.params={operator_ids:g},c}return(0,f.c)(b,a),b}(f.h);a7=f.j,(0,f.c)(function(a,b){return a7.call(this,a,b)||this},a7);var a9,ba=function(a){function b(b){var c=this,d=b.channelUrl,e=b.channelType,g=b.userId;return(c=a.call(this)||this).method=f.A.GET,c.path="".concat((0,f.aO)(e),"/").concat(encodeURIComponent(d),"/mute/").concat(encodeURIComponent(g)),c}return(0,f.c)(b,a),b}(f.h),bb=function(a){function b(b,c){var d=a.call(this,b,c)||this;d.isMuted=!1,d.startAt=0,d.endAt=0;var e=c.is_muted,f=c.start_at,g=c.end_at,h=c.remaining_duration,i=c.description;return d.isMuted=e,d.startAt=f,d.endAt=g,d.remainingDuration=h,d.description=i,d}return(0,f.c)(b,a),b}(f.j),bc=function(a){function b(b){var c=this,d=b.channelUrl,e=b.channelType,g=b.keys;return(c=a.call(this)||this).method=f.A.GET,c.path="".concat((0,f.aO)(e),"/").concat(encodeURIComponent(d),"/metadata"),c.params={keys:g,include_ts:!0},c}return(0,f.c)(b,a),b}(f.h),bd=function(a){function b(b,c){var d=a.call(this,b,c)||this,e=c.metadata,f=c.ts;return d.metadata=e,d.ts=f,d}return(0,f.c)(b,a),b}(f.j),be=function(a){function b(b){var c=this,d=b.channelUrl,e=b.channelType,g=b.metadata;return(c=a.call(this)||this).method=f.A.POST,c.path="".concat((0,f.aO)(e),"/").concat(encodeURIComponent(d),"/metadata"),c.params={metadata:g,include_ts:!0},c}return(0,f.c)(b,a),b}(f.h),bf=function(a){function b(b,c){var d,e,f=this;return(f=a.call(this,b,c)||this).metaData=null!==(d=c.metadata)&& void 0!==d?d:{},f.ts=null!==(e=c.ts)&& void 0!==e?e:null,f}return(0,f.c)(b,a),b}(f.j),bg=function(a){function b(b){var c=this,d=b.channelUrl,e=b.channelType,g=b.metadata,h=b.upsert;return(c=a.call(this)||this).method=f.A.PUT,c.path="".concat((0,f.aO)(e),"/").concat(encodeURIComponent(d),"/metadata"),c.params={metadata:g,include_ts:!0,upsert:null!=h&&h},c}return(0,f.c)(b,a),b}(f.h),bh=function(a){function b(b,c){var d=a.call(this,b,c)||this,e=c.metadata,f=c.ts;return d.metadata=e,d.ts=f,d}return(0,f.c)(b,a),b}(f.j),bi=function(a){function b(b,c,d){var e=a.call(this,b,"SYEV",d)||this;return d.data&&(e.created=d.data.created,e.updated=d.data.updated,e.deleted=d.data.deleted),e}return(0,f.c)(b,a),b}(f.W),bj=function(a){function b(b){var c=this,d=b.channelUrl,e=b.channelType,g=b.key;return(c=a.call(this)||this).method=f.A.DELETE,c.path="".concat((0,f.aO)(e),"/").concat(encodeURIComponent(d),"/metadata/").concat(g),c.params={include_ts:!0},c}return(0,f.c)(b,a),b}(f.h),bk=function(a){function b(b,c){var d=a.call(this,b,c)||this,e=c.ts;return d.ts=e,d}return(0,f.c)(b,a),b}(f.j),bl=function(a){function b(b){var c=this,d=b.channelUrl,e=b.channelType;return(c=a.call(this)||this).method=f.A.DELETE,c.path="".concat((0,f.aO)(e),"/").concat(encodeURIComponent(d),"/metadata"),c.params={include_ts:!0},c}return(0,f.c)(b,a),b}(f.h),bm=function(a){function b(b,c){var d=a.call(this,b,c)||this,e=c.ts;return d.ts=e,d}return(0,f.c)(b,a),b}(f.j),bn=function(a){function b(b){var c=this,d=b.channelUrl,e=b.channelType,g=b.keys;return(c=a.call(this)||this).method=f.A.GET,c.path="".concat((0,f.aO)(e),"/").concat(encodeURIComponent(d),"/metacounter"),c.params={keys:g},c}return(0,f.c)(b,a),b}(f.h),bo=function(a){function b(b,c){var d=a.call(this,b,c)||this;return d.metaCounter=c,d}return(0,f.c)(b,a),b}(f.j),bp=function(a){function b(b){var c=this,d=b.channelUrl,e=b.channelType,g=b.metaCounter;return(c=a.call(this)||this).method=f.A.POST,c.path="".concat((0,f.aO)(e),"/").concat(encodeURIComponent(d),"/metacounter"),c.params={metacounter:g},c}return(0,f.c)(b,a),b}(f.h),bq=function(a){function b(b,c){var d=a.call(this,b,c)||this;return d.metaCounter=c,d}return(0,f.c)(b,a),b}(f.j),br=function(a){function b(b){var c=this,d=b.channelUrl,e=b.channelType,g=b.metaCounter,h=b.upsert,i=b.mode;return(c=a.call(this)||this).method=f.A.PUT,c.path="".concat((0,f.aO)(e),"/").concat(encodeURIComponent(d),"/metacounter"),c.params={metacounter:g,upsert:void 0!==h&&h,mode:void 0===i?"set":i},c}return(0,f.c)(b,a),b}(f.h),bs=function(a){function b(b,c){var d=a.call(this,b,c)||this;return d.metaCounter=c,d}return(0,f.c)(b,a),b}(f.j),bt=function(a){function b(b,c,d){var e=a.call(this,b,"SYEV",d)||this;return d.data&&(e.created=d.data.created,e.updated=d.data.updated,e.deleted=d.data.deleted),e}return(0,f.c)(b,a),b}(f.W),bu=function(a){function b(b){var c=this,d=b.channelUrl,e=b.channelType,g=b.key;return(c=a.call(this)||this).method=f.A.DELETE,c.path="".concat((0,f.aO)(e),"/").concat(encodeURIComponent(d),"/metacounter/").concat(g),c.params={},c}return(0,f.c)(b,a),b}(f.h);a9=f.j,(0,f.c)(function(a,b){return a9.call(this,a,b)||this},a9);var bv,bw=function(a){function b(b){var c=this,d=b.channelUrl,e=b.channelType;return(c=a.call(this)||this).method=f.A.DELETE,c.path="".concat((0,f.aO)(e),"/").concat(encodeURIComponent(d),"/metacounter"),c.params={},c}return(0,f.c)(b,a),b}(f.h);bv=f.j,(0,f.c)(function(){return null!==bv&&bv.apply(this,arguments)||this},bv);var bx,by=function(a){function b(b){var c=this,d=b.channelUrl,e=b.channelType,g=b.userId,h=b.seconds,i=b.description;return(c=a.call(this)||this).method=f.A.POST,c.path="".concat((0,f.aO)(e),"/").concat(encodeURIComponent(d),"/mute"),c.params={user_id:g,seconds:h,description:i},c}return(0,f.c)(b,a),b}(f.h);bx=f.j,(0,f.c)(function(a,b){return bx.call(this,a,b)||this},bx);var bz,bA=function(a){function b(b,c,d){var e=a.call(this,b,"SYEV",d)||this;return e.user=new ay(b,d.data),e}return(0,f.c)(b,a),b}(f.W),bB=function(a){function b(b){var c=this,d=b.channelUrl,e=b.channelType,g=b.userId;return(c=a.call(this)||this).method=f.A.DELETE,c.path="".concat((0,f.aO)(e),"/").concat(encodeURIComponent(d),"/mute/").concat(encodeURIComponent(g)),c}return(0,f.c)(b,a),b}(f.h);bz=f.j,(0,f.c)(function(){return null!==bz&&bz.apply(this,arguments)||this},bz);var bC,bD=function(a){function b(b,c,d){var e=a.call(this,b,"SYEV",d)||this;return e.user=new ay(b,d.data),e}return(0,f.c)(b,a),b}(f.W),bE=function(a){function b(b){var c=this,d=b.channelUrl,e=b.channelType,g=b.userId,h=b.seconds,i=b.description;return(c=a.call(this)||this).method=f.A.POST,c.path="".concat((0,f.aO)(e),"/").concat(encodeURIComponent(d),"/ban"),c.params=(0,f.f)({user_id:g,seconds:h,description:i}),c}return(0,f.c)(b,a),b}(f.h);bC=f.j,(0,f.c)(function(){return null!==bC&&bC.apply(this,arguments)||this},bC);var bF,bG=function(a){function b(b,c,d){var e=a.call(this,b,"SYEV",d)||this;return e.user=new ay(b,d.data),d.data.member_count&&(e.memberCount=d.data.member_count),d.data.joined_member_count&&(e.joinedMemberCount=d.data.joined_member_count),e}return(0,f.c)(b,a),b}(f.W),bH=function(a){function b(b){var c=this,d=b.channelUrl,e=b.channelType,g=b.userId;return(c=a.call(this)||this).method=f.A.DELETE,c.path="".concat((0,f.aO)(e),"/").concat(encodeURIComponent(d),"/ban/").concat(encodeURIComponent(g)),c}return(0,f.c)(b,a),b}(f.h);bF=f.j,(0,f.c)(function(){return null!==bF&&bF.apply(this,arguments)||this},bF);var bI,bJ=function(a){function b(b,c,d){var e=a.call(this,b,"SYEV",d)||this;return e.user=new ay(b,d.data),e}return(0,f.c)(b,a),b}(f.W),bK=function(a){function b(b){var c=this,d=b.channelUrl,e=b.channelType,g=b.freezing;return(c=a.call(this)||this).method=f.A.PUT,c.path="".concat((0,f.aO)(e),"/").concat(encodeURIComponent(d),"/freeze"),c.params={freeze:g},c}return(0,f.c)(b,a),b}(f.h);bI=f.j,(0,f.c)(function(){return null!==bI&&bI.apply(this,arguments)||this},bI);var bL,bM=function(a){function b(b,c,d){var e=a.call(this,b,"SYEV",d)||this;return e.freeze=d.data.freeze,e}return(0,f.c)(b,a),b}(f.W),bN=function(a){return a instanceof f.ah?a._custom?"custom":a.name:a},bO=function(a){if(a instanceof f.ah&&a._custom)return a.name},bP=function(a){function b(b){var c=this,d=b.channelUrl,e=b.channelType,g=b.category,h=b.userId,i=b.description;return(c=a.call(this)||this).method=f.A.POST,c.path="".concat((0,f.aZ)(e),"/").concat(encodeURIComponent(d)),c.params=(0,f.f)({report_category:bN(g),reporting_user_id:h,report_description:i,custom_report_category_name:bO(g)}),c}return(0,f.c)(b,a),b}(f.h),bQ=function(a){function b(b){var c=this,d=b.channelUrl,e=b.channelType,g=b.category,h=b.userId,i=b.offendingUserId,j=b.description;return(c=a.call(this)||this).method=f.A.POST,c.path="".concat(f.a_,"/users/").concat(i),c.params=(0,f.f)({channel_url:d,channel_type:e===f.C.OPEN?"open_channels":"group_channels",report_category:bN(g),reporting_user_id:h,report_description:j,custom_report_category_name:bO(g)}),c}return(0,f.c)(b,a),b}(f.h),bR=function(a){function b(b){var c=this,d=b.channelUrl,e=b.channelType,g=b.category,h=b.userId,i=b.offendingUserId,j=b.messageId,k=b.description;return(c=a.call(this)||this).method=f.A.POST,c.path="".concat((0,f.aZ)(e),"/").concat(encodeURIComponent(d),"/messages/").concat(j),c.params=(0,f.f)({report_category:bN(g),reporting_user_id:h,report_description:k,offending_user_id:i,custom_report_category_name:bO(g)}),c}return(0,f.c)(b,a),b}(f.h),bS=function(a){function b(b){var c=[];return b.mentionType===f.ar.USERS&&(b.mentionedUserIds?c=b.mentionedUserIds:b.mentionedUsers&&(c=b.mentionedUsers.map(function(a){return a.userId}))),a.call(this,{code:"MESG",ackRequired:!0,payload:(0,f.f)((0,f.g)({channel_url:b.channelUrl,message:b.message,data:b.data,custom_type:b.customType,metaarray:b.metaArrays,mention_type:b.mentionType,mentioned_user_ids:c,mentioned_message_template:b.mentionedMessageTemplate,target_langs:b.translationTargetLanguages,push_option:b.pushNotificationDeliveryOption&&b.pushNotificationDeliveryOption!==f.av.DEFAULT?b.pushNotificationDeliveryOption:void 0,apple_critical_alert_options:b.appleCriticalAlertOptions,silent:b.silent,reply_to_channel:b.isReplyToChannel,parent_message_id:b.parentMessageId?b.parentMessageId:null,req_id:b.reqId,poll_id:b.pollId,pin_message:b.isPinnedMessage,extended_message_payload:b.extendedMessagePayload}))})||this}return(0,f.c)(b,a),b}(f.aN),bT=function(a){function b(b,c,d){var e,g,h,i,j=this;(j=a.call(this,b,"MESG",d)||this).message=new R(b,d);var k=f.V.of(b).sdkState;return j.isMentioned=(0,f.aS)(j.message.mentionType,null!==(h=null!==(e=j.message.mentionedUserIds)&& void 0!==e?e:null===(g=j.message.mentionedUsers)|| void 0===g?void 0:g.map(function(a){return a.userId}))&& void 0!==h?h:[],k.userId),j.forceUpdateLastMessage=null!==(i=d.force_update_last_message)&& void 0!==i&&i,j}return(0,f.c)(b,a),b}(f.W),bU=function(a){function b(b){var c=null;return b.mentionType===f.ar.USERS&&(b.mentionedUserIds?c=b.mentionedUserIds:b.mentionedUsers&&(c=b.mentionedUsers.map(function(a){return a.userId}))),a.call(this,{code:"MEDI",ackRequired:!0,payload:(0,f.f)((0,f.g)({channel_url:b.channelUrl,msg_id:b.messageId,message:b.message,data:b.data,custom_type:b.customType,metaarray:b.metaArrayParams,mention_type:b.mentionType,mentioned_user_ids:c,mentioned_message_template:b.mentionedMessageTemplate,apple_critical_alert_options:b.appleCriticalAlertOptions?q.payloadify(b.appleCriticalAlertOptions):null,poll_id:b.pollId}))})||this}return(0,f.c)(b,a),b}(f.aN),bV=function(a){function b(b,c,d){var e,g,h,i,j,k=this;(k=a.call(this,b,"MEDI",d)||this).message=new R(b,d);var l=f.V.of(b).sdkState;return k.mentionCountChange=(0,f.a$)({mentionType:null===(e=d.old_values)|| void 0===e?void 0:e.mention_type,mentionedUserIds:null!==(h=null===(g=d.old_values)|| void 0===g?void 0:g.mentioned_user_ids)&& void 0!==h?h:[]},(0,f.g)({mentionType:k.message.mentionType,mentionedUserIds:null!==(i=k.message.mentionedUserIds)&& void 0!==i?i:null===(j=k.message.mentionedUsers)|| void 0===j?void 0:j.map(function(a){return a.userId})}),l.userId),k}return(0,f.c)(b,a),b}(f.W),bW=function(a){function b(b){var c=null;return b.mentionType===f.ar.USERS&&(b.mentionedUserIds?c=b.mentionedUserIds:b.mentionedUsers&&(c=b.mentionedUsers.map(function(a){return a.userId}))),a.call(this,{code:"FEDI",ackRequired:!0,payload:(0,f.f)((0,f.g)({channel_url:b.channelUrl,msg_id:b.messageId,data:b.data,custom_type:b.customType,metaarray:b.metaArrayParams,mention_type:b.mentionType,mentioned_user_ids:c,apple_critical_alert_options:b.appleCriticalAlertOptions}))})||this}return(0,f.c)(b,a),b}(f.aN),bX=function(a){function b(b,c,d){var e,g,h,i,j,k=this;(k=a.call(this,b,"FEDI",d)||this).message=new W(b,d);var l=f.V.of(b).sdkState;return k.mentionCountChange=(0,f.a$)({mentionType:null===(e=d.old_values)|| void 0===e?void 0:e.mention_type,mentionedUserIds:null!==(h=null===(g=d.old_values)|| void 0===g?void 0:g.mentioned_user_ids)&& void 0!==h?h:[]},(0,f.g)({mentionType:k.message.mentionType,mentionedUserIds:null!==(i=k.message.mentionedUserIds)&& void 0!==i?i:null===(j=k.message.mentionedUsers)|| void 0===j?void 0:j.map(function(a){return a.userId})}),l.userId),k}return(0,f.c)(b,a),b}(f.W),bY=function(a){function b(b){var c=b.channelType,d=b.channelUrl,e=b.messageId,g=b.reactionKey,h=a.call(this)||this;return h.method=f.A.POST,h.path="".concat((0,f.aO)(c),"/").concat(encodeURIComponent(d),"/messages/").concat(e,"/reactions"),h.params={reaction:g},h}return(0,f.c)(b,a),b}(f.h),bZ=function(a){function b(b,c){var d=a.call(this,b,c)||this;return d.reactionEvent=new l(c),d}return(0,f.c)(b,a),b}(f.j),b$=function(a){function b(b){var c=b.channelType,d=b.channelUrl,e=b.messageId,g=b.reactionKey,h=a.call(this)||this;return h.method=f.A.DELETE,h.path="".concat((0,f.aO)(c),"/").concat(encodeURIComponent(d),"/messages/").concat(e,"/reactions"),h.params={reaction:g},h}return(0,f.c)(b,a),b}(f.h),b_=function(a){function b(b,c){var d=a.call(this,b,c)||this;return d.reactionEvent=new l((0,f.d)({},c)),d}return(0,f.c)(b,a),b}(f.j),b0=function(a){function b(b){var c=b.channelType,d=b.channelUrl,e=b.messageId,g=b.translationTargetLanguages,h=a.call(this)||this;return h.method=f.A.POST,h.path="".concat((0,f.aO)(c),"/").concat(encodeURIComponent(d),"/messages/").concat(encodeURIComponent(e),"/translation"),h.params={target_langs:g},h}return(0,f.c)(b,a),b}(f.h),b1=function(a){function b(b,c){var d=a.call(this,b,c)||this;return d.message=new R(b,c),d}return(0,f.c)(b,a),b}(f.j),b2=function(a){function b(b){var c,d=this;d=a.call(this)||this;var e=[];b.mentionType===f.ar.USERS&&(b.mentionedUserIds?e=b.mentionedUserIds:b.mentionedUsers&&(e=b.mentionedUsers.map(function(a){return a.userId})));var g=b.channelType,h=b.channelUrl;return d.method=f.A.POST,d.path="".concat((0,f.aO)(g),"/").concat(encodeURIComponent(h),"/scheduled_messages"),d.params=(0,f.f)((0,f.g)({req_id:b.reqId,scheduled_at:b.scheduledAt,message_type:f.b0.USER,message:b.message,custom_type:b.customType,data:b.data,mention_type:b.mentionType,mentioned_user_ids:e,sorted_metaarray:null===(c=b.metaArrays)|| void 0===c?void 0:c.map(function(a){return s.payloadify(a)}),apple_critical_alert_options:b.appleCriticalAlertOptions?q.payloadify(b.appleCriticalAlertOptions):null,target_langs:b.translationTargetLanguages,push_option:b.pushNotificationDeliveryOption})),d}return(0,f.c)(b,a),b}(f.h),b3=function(a){function b(b,c){var d=a.call(this,b,c)||this;return d.message=new R(b,c),d}return(0,f.c)(b,a),b}(f.j),b4=function(a){function b(b){var c,d,e=this;e=a.call(this)||this;var h=[];b.mentionType===f.ar.USERS&&(b.mentionedUserIds?h=b.mentionedUserIds:b.mentionedUsers&&(h=b.mentionedUsers.map(function(a){return a.userId})));var i=b.channelType,j=b.channelUrl;return e.method=f.A.POST,e.path="".concat((0,f.aO)(i),"/").concat(encodeURIComponent(j),"/scheduled_messages"),e.params=(0,f.g)({req_id:b.reqId,scheduled_at:b.scheduledAt,message_type:f.b0.FILE,url:b.fileUrl,file_name:b.fileName,file_size:b.fileSize,file_type:b.mimeType,thumbnails:null===(c=b._thumbnails)|| void 0===c?void 0:c.map(function(a){return g.payloadify(a)}),custom_type:b.customType,data:b.data,require_auth:b.requireAuth,mention_type:b.mentionType,mentioned_user_ids:h,sorted_metaarray:null===(d=b.metaArrays)|| void 0===d?void 0:d.map(function(a){return s.payloadify(a)}),apple_critical_alert_options:b.appleCriticalAlertOptions?q.payloadify(b.appleCriticalAlertOptions):null,push_option:b.pushNotificationDeliveryOption}),e}return(0,f.c)(b,a),b}(f.h),b5=function(a){function b(b,c){var d=a.call(this,b,c)||this;return d.message=new W(b,c),d}return(0,f.c)(b,a),b}(f.j),b6=function(a){function b(b){var c=b.pollId,d=b.title,e=b.data,g=b.allowUserSuggestion,h=b.allowMultipleVotes,i=b.closeAt,j=a.call(this)||this;return j.method=f.A.PUT,j.path="".concat(f.b2,"/").concat(encodeURIComponent(c)),j.params={title:d,data:e,allow_user_suggestion:g,allow_multiple_votes:h,close_at:i},j}return(0,f.c)(b,a),b}(f.h),b7=function(a){function b(b,c){var d=a.call(this,b,c)||this;return d.poll=new f.aF(b,c),d}return(0,f.c)(b,a),b}(f.j),b8=function(a){function b(b){var c=b.pollId,d=a.call(this)||this;return d.method=f.A.DELETE,d.path="".concat(f.b2,"/").concat(encodeURIComponent(c)),d}return(0,f.c)(b,a),b}(f.h);bL=f.j,(0,f.c)(function(){return null!==bL&&bL.apply(this,arguments)||this},bL);var b9,ca=function(a){function b(b){var c=b.pollId,d=a.call(this)||this;return d.method=f.A.PUT,d.path="".concat(f.b2,"/").concat(encodeURIComponent(c),"/close"),d}return(0,f.c)(b,a),b}(f.h),cb=function(a){function b(b,c){var d=a.call(this,b,c)||this;return d.poll=new f.aF(b,c),d}return(0,f.c)(b,a),b}(f.j),cc=function(a){function b(b){var c=b.channelUrl,d=b.channelType,e=b.pollId,g=b.optionText,h=a.call(this)||this;return h.method=f.A.POST,h.path="".concat(f.b2,"/").concat(encodeURIComponent(e),"/options"),h.params={channel_url:c,channel_type:d,text:g},h}return(0,f.c)(b,a),b}(f.h),cd=function(a){function b(b,c){var d=a.call(this,b,c)||this;return d.poll=new f.aF(b,c),d}return(0,f.c)(b,a),b}(f.j),ce=function(a){function b(b){var c=b.pollId,d=b.pollOptionId,e=b.optionText,g=a.call(this)||this;return g.method=f.A.PUT,g.path="".concat(f.b2,"/").concat(encodeURIComponent(c),"/options/").concat(encodeURIComponent(d)),g.params={text:e},g}return(0,f.c)(b,a),b}(f.h),cf=function(a){function b(b,c){var d=a.call(this,b,c)||this;return d.poll=new f.aF(b,c),d}return(0,f.c)(b,a),b}(f.j),cg=function(a){function b(b){var c=b.pollId,d=b.pollOptionId,e=a.call(this)||this;return e.method=f.A.DELETE,e.path="".concat(f.b2,"/").concat(encodeURIComponent(c),"/options/").concat(encodeURIComponent(d)),e}return(0,f.c)(b,a),b}(f.h);b9=f.j,(0,f.c)(function(){return null!==b9&&b9.apply(this,arguments)||this},b9);var ch=function(a){function b(b){var c=b.reqId,d=b.channelType,e=b.channelUrl,g=b.pollId,h=b.pollOptionIds;return a.call(this,{code:"VOTE",ackRequired:!0,payload:(0,f.f)({req_id:c,channel_type:d===f.C.OPEN?"open_channels":"group_channels",channel_url:e,poll_id:g,option_ids:h})})||this}return(0,f.c)(b,a),b}(f.aN),ci=function(a){function b(b,c,d){var e=a.call(this,b,"VOTE",d)||this;return e.event=new f.aI(d),e.channelUrl=d.channel_url,e.channelType=d.channel_type,e}return(0,f.c)(b,a),b}(f.W),cj=100,ck="GroupChannel",cl="url",cm=100,cn="Message",co="messageId",cp="NotificationMessage",cq="notificationId",cr="Poll",cs="pollId",ct="FeedChannel",cu="url",cv="UserInfo",cw="userId";function cx(a){var b,c,d;return null!==(b=a.messageParams)&& void 0!==b?b:(0,f.g)((0,f.d)((0,f.d)({},a),{isReplyToChannel:!1,mentionedUserIds:null!==(c=a.mentionedUserIds)&& void 0!==c?c:null===(d=a.mentionedUsers)|| void 0===d?void 0:d.map(function(a){return a.userId}),pushNotificationDeliveryOption:f.av.DEFAULT,isPinnedMessage:!1,fileInfoList:a.fileInfoList.map(function(a){var b;return{fileUrl:a.plainUrl,fileName:a.fileName,fileSize:a.fileSize,mimeType:a.mimeType,thumbnailSizes:null===(b=a.thumbnails)|| void 0===b?void 0:b.map(function(a){return{maxWidth:a.width,maxHeight:a.height}}),_thumbnails:a.thumbnails,_uploadedMetaData:{requireAuth:a._requireAuth,isUploaded:!0}}})}))}var cy,cz=(0,f.d)((0,f.d)({},aA),{fileInfoList:[],message:""}),cA=function(a){function b(){var b=null!==a&&a.apply(this,arguments)||this;return b._onFileUploaded=f.aX,b}return(0,f.c)(b,a),b.prototype._triggerOnFileUploaded=function(a,b,c,d){this._onFileUploaded(a,b,c,d)},b.prototype.onFileUploaded=function(a){return this._onFileUploaded=a,this},b.prototype.onPending=function(b){return a.prototype.onPending.call(this,b),this},b.prototype.onFailed=function(b){return a.prototype.onFailed.call(this,b),this},b.prototype.onSucceeded=function(b){return a.prototype.onSucceeded.call(this,b),this},b}(az),cB=function(a){function b(b,c){var d=a.call(this,b)||this;return d.message=null,d.message=V(b,c.message),d}return(0,f.c)(b,a),b}(f.aK),cC=function(a){function b(b){var c=this,d=b.channelType,e=b.channelUrl,g=b.limit,h=b.token,i=b.includeReactions,j=b.includeMetaArray,k=b.includeParentMessageInfo,l=b.includeThreadInfo,m=b.includePollDetails;return(c=a.call(this)||this).method=f.A.GET,c.path="".concat((0,f.aO)(d),"/").concat(encodeURIComponent(e),"/pinned_messages"),c.params=(0,f.f)({limit:g,token:h,include_reactions_summary:i,with_sorted_meta_array:j,include_thread_info:l,include_parent_message_info:k,include_poll_details:m}),c}return(0,f.c)(b,a),b}(f.h),cD=function(a){function b(b,c){var d=a.call(this,b,c)||this,e=c.pinned_messages,f=c.has_more,g=c.next;return d.pinnedMessages=e.map(function(a){return new cB(b,a)}),d.hasMore=f,d.token=g,d}return(0,f.c)(b,a),b}(f.j),cE=function(a){function b(b,c,d,e){var f=a.call(this,b,c,d,e)||this;return f.includeMetaArray=e.includeMetaArray,f.includeReactions=e.includeReactions,f.includeParentMessageInfo=e.includeParentMessageInfo,f.includeThreadInfo=e.includeThreadInfo,f.includePollDetails=e.includePollDetails,f}return(0,f.c)(b,a),b.prototype._validate=function(){return a.prototype._validate.call(this)&&(0,f.a)("boolean",this.includeMetaArray,!0)&&(0,f.a)("boolean",this.includeReactions,!0)&&(0,f.a)("boolean",this.includeParentMessageInfo,!0)&&(0,f.a)("boolean",this.includeThreadInfo,!0)&&(0,f.a)("boolean",this.includePollDetails,!0)},b.prototype.next=function(){return(0,f._)(this,void 0,void 0,function(){var a,b,c,d,e,g,h;return(0,f.b)(this,function(i){switch(i.label){case 0:return this._validate()?this._isLoading?[3,3]:this._hasNext?(this._isLoading=!0,a=f.V.of(this._iid).requestQueue,b=new cC((0,f.d)((0,f.d)({},this),{token:this._token})),[4,a.send(b)]):[3,2]:[3,5];case 1:return e=(d=(c=i.sent()).as(cD)).pinnedMessages,g=d.hasMore,h=d.token,this._token=h,this._hasNext=!!g,this._isLoading=!1,[2,e];case 2:return[2,[]];case 3:throw f.q.queryInProgress;case 4:return[3,6];case 5:throw f.q.invalidParameters;case 6:return[2]}})})},b}(f.aY),cF=function(a){function b(b){var c=b.channelType,d=b.channelUrl,e=b.messageId,g=a.call(this)||this;return g.method=f.A.POST,g.path="".concat((0,f.aO)(c),"/").concat(encodeURIComponent(d),"/messages/").concat(e,"/pin"),g}return(0,f.c)(b,a),b}(f.h);cy=f.j,(0,f.c)(function(a,b){return cy.call(this,a,b)||this},cy);var cG,cH=function(a){function b(b){var c=b.channelType,d=b.channelUrl,e=b.messageId,g=a.call(this)||this;return g.method=f.A.DELETE,g.path="".concat((0,f.aO)(c),"/").concat(encodeURIComponent(d),"/messages/").concat(e,"/pin"),g}return(0,f.c)(b,a),b}(f.h);cG=f.j,(0,f.c)(function(a,b){return cG.call(this,a,b)||this},cG);var cI,cJ,cK=2;(cJ=cI||(cI={})).SEND="send",cJ.RESEND="resend",cJ.COPY="copy";var cL,cM,cN=function(a){function b(b,c){var d,e,g,h,i,j,k,l=this;return(l=a.call(this,b)||this)._name="",l._createdAt=0,l.pinnedMessageIds=[],l.channelType=f.C.BASE,l.coverUrl="",l.customType="",l.data="",l.isFrozen=!1,l.isEphemeral=!1,l.creator=null,l._messageCollectionLastAccessedAt=0,l._url=c.channel_url,l._name=null!==(d=c.name)&& void 0!==d?d:"",l._createdAt=1e3*c.created_at,l.coverUrl=null!==(e=c.cover_url)&& void 0!==e?e:"",l.customType=null!==(g=c.custom_type)&& void 0!==g?g:"",l.data=null!==(h=c.data)&& void 0!==h?h:"",l.isFrozen=null!==(i=c.freeze)&& void 0!==i&&i,l.isEphemeral=null!==(j=c.is_ephemeral)&& void 0!==j&&j,l.creator=c.created_by?new f.U(l._iid,c.created_by):null,c.metadata&&Object.keys(c.metadata).length>0&&c.ts?(l._cachedMetaData=new Map,Object.keys(c.metadata).forEach(function(a){l._cachedMetaData.set(a,{value:c.metadata[a],isRemoved:!1,updatedAt:c.ts})})):"string"==typeof c.metadata&&(l._cachedMetaData=new Map(Object.entries(JSON.parse(c.metadata)))),l.pinnedMessageIds=null!==(k=c.pinned_message_ids)&& void 0!==k?k:[],l}return(0,f.c)(b,a),Object.defineProperty(b.prototype,"url",{get:function(){return this._url},enumerable:!1,configurable:!0}),Object.defineProperty(b.prototype,"name",{get:function(){return this._name},set:function(a){this._name=a},enumerable:!1,configurable:!0}),Object.defineProperty(b.prototype,"createdAt",{get:function(){return this._createdAt},enumerable:!1,configurable:!0}),b.prototype.toJSON=function(){return(0,f.d)((0,f.d)({},this),{url:this._url,name:this._name,createdAt:this._createdAt})},b.payloadify=function(b,c){void 0===c&&(c=!1);var d=(0,f.d)((0,f.d)({},a.payloadify.call(this,b)),{channel_url:b.url,name:b.name,cover_url:b.coverUrl,custom_type:b.customType,data:b.data,freeze:b.isFrozen,is_ephemeral:b.isEphemeral,created_by:b.creator?f.U.payloadify(b.creator):null,created_at:b.createdAt/1e3,metadata:b.cachedMetaData,pinned_message_ids:b.pinnedMessageIds});return c?d:(0,f.f)((0,f.g)(d))},b.prototype.isGroupChannel=function(){return this.channelType===f.C.GROUP},b.prototype.isOpenChannel=function(){return this.channelType===f.C.OPEN},b.prototype.isFeedChannel=function(){return this.channelType===f.C.FEED},Object.defineProperty(b.prototype,"cachedMetaData",{get:function(){var a={};return this._cachedMetaData&&this._cachedMetaData.forEach(function(b,c){b.isRemoved||(a[c]=b.value)}),a},enumerable:!1,configurable:!0}),Object.defineProperty(b.prototype,"messageCollectionLastAccessedAt",{get:function(){return this._messageCollectionLastAccessedAt},enumerable:!1,configurable:!0}),b.prototype._serializeCachedMetaData=function(){return this._cachedMetaData?{cachedMetaData:JSON.stringify(Object.fromEntries(this._cachedMetaData))}:{}},b.prototype._updateMessageCollectionLastAccessedAt=function(){this._messageCollectionLastAccessedAt=Date.now()},b.prototype._update=function(a){Object.assign(this,a)},b.prototype._upsertCachedMetaData=function(a,b){var c=this;Object.keys(a).forEach(function(d){c._cachedMetaData||(c._cachedMetaData=new Map);var e=c._cachedMetaData.get(d);(!e||e.updatedAt<=b)&&c._cachedMetaData.set(d,{value:a[d],isRemoved:!1,updatedAt:b})})},b.prototype._updateCachedMetaData=function(a,b){var c=this,d=!1;return this._cachedMetaData?this._cachedMetaData.forEach(function(e,f){var g;e.updatedAt<=b&&(c._cachedMetaData.set(f,{value:null!==(g=a[f])&& void 0!==g?g:e.value,isRemoved:!a[f],updatedAt:b}),d=!0)}):(this._cachedMetaData=new Map,Object.keys(a).forEach(function(d){c._cachedMetaData.set(d,{value:a[d],isRemoved:!1,updatedAt:b})}),d=!0),{isUpdated:d}},b.prototype._removeFromCachedMetaData=function(a,b){var c=this;this._cachedMetaData&&a.forEach(function(a){var d=c._cachedMetaData.get(a);d&&d.updatedAt0?{name:a.fileInfoList[0].fileName,size:a.fileInfoList[0].fileSize,type:a.fileInfoList[0].mimeType,data:a.data}:void 0,message:a.message})),e=new S(this._iid,d);return e.messageParams=a,e},b.prototype._validateFailedFileMessageHasFile=function(a,b){var c;return Boolean(a.url)||(0,f.i)(b)||(0,f.i)(null===(c=a.messageParams)|| void 0===c?void 0:c.file)},b.prototype._createPendingScheduledFileMessage=function(a,b,c){var d=this._createPendingFileMessage(a,b,c);return d.scheduledInfo={scheduledMessageId:0,scheduledAt:a.scheduledAt,scheduledMessageParams:a},d},b.prototype._markMessageAsFailed=function(a,b,c){void 0===c&&(c=!1),a.errorCode=b.code,b.code===f.F.REQUEST_CANCELED||b.code===f.F.FILE_UPLOAD_CANCEL_FAILED?a.sendingStatus=f.ax.CANCELED:c||(a.sendingStatus=f.ax.FAILED)},b.prototype.sendUserMessage=function(a){var b=(0,f.d)((0,f.d)({},aD),a);return(0,f.p)(aI(b)).throw(f.q.invalidParameters),this._sendUserMessage(b)},b.prototype._sendUserMessage=function(a,b,c){var d=this;void 0===b&&(b=cI.SEND);var e=f.V.of(this._iid),g=e.dispatcher,h=e.requestQueue,i=null!=c?c:this._generateRequestId(),j=Date.now(),k=new az;return(0,f.aU)(2).then(function(){var c=d._createPendingUserMessage(a,i,j);g.dispatch(new f.aP({messages:[c],source:b===cI.RESEND?f.ab.LOCAL_MESSAGE_RESEND_STARTED:f.ab.EVENT_MESSAGE_SENT_PENDING})),(0,f.N)(function(){return(0,f._)(d,void 0,void 0,function(){return(0,f.b)(this,function(a){return[2,k._trigger(c)]})})});var e=new bS((0,f.d)((0,f.d)({},a),{channelUrl:d.url,channelType:d.channelType,reqId:i}));h.send(e).then(function(a){var b=a.as(bT).message;g.dispatch(new f.aP({messages:[b],source:f.ab.EVENT_MESSAGE_SENT_SUCCESS})),(0,f.N)(function(){return(0,f._)(d,void 0,void 0,function(){return(0,f.b)(this,function(a){return[2,k._trigger(b)]})})})}).catch(function(b){if((0,f.a1)(b))throw b;(0,f.aU)(2).then(function(){var c=d._createPendingUserMessage(a,i,j),e=f.V.of(d._iid).cacheContext,h=e.localCacheEnabled&&e.localCacheConfig.enableAutoResend&&(0,f.b4)(b.code);d._markMessageAsFailed(c,b,h),g.dispatch(new f.aP({messages:[c],source:c.sendingStatus===f.ax.PENDING?f.ab.REQUEST_RESEND_MESSAGE:f.ab.EVENT_MESSAGE_SENT_FAILED})),(0,f.N)(function(){return(0,f._)(d,void 0,void 0,function(){return(0,f.b)(this,function(a){return[2,k._triggerFailed(b,c)]})})})})})}),k},b.prototype._autoResendUserMessage=function(a){return(0,f.p)(a instanceof R&&!!a.messageParams).throw(f.q.invalidParameters),this._sendUserMessage(a.messageParams,cI.SEND,a.reqId)},b.prototype.resendUserMessage=function(a){var b;return(0,f._)(this,void 0,void 0,function(){var c,d;return(0,f.b)(this,function(e){return(0,f.p)(a instanceof R&&!a.scheduledInfo).throw(f.q.invalidParameters),c=new f.aV,d=null!==(b=a.messageParams)&& void 0!==b?b:aH(a),this._sendUserMessage(d,cI.RESEND,a.reqId).onFailed(function(a){return c.reject(a)}).onSucceeded(function(a){return c.resolve(a)}),[2,c.promise]})})},b.prototype.updateUserMessage=function(a,b){return(0,f._)(this,void 0,void 0,function(){var c,d,e,g;return(0,f.b)(this,function(h){switch(h.label){case 0:return c=(0,f.d)((0,f.d)({},aU),b),(0,f.p)((0,f.a)("number",a)&&aV(c)).throw(f.q.invalidParameters),d=f.V.of(this._iid).requestQueue,e=new bU((0,f.d)({channelType:this.channelType,channelUrl:this.url,messageId:a,metaArrayParams:c.metaArrays?{array:c.metaArrays,mode:"add",upsert:!0}:void 0},c)),[4,d.send(e)];case 1:return[2,(g=h.sent()).as(bV).message]}})})},b.prototype.copyUserMessage=function(a,c){var d,e,g;return(0,f._)(this,void 0,void 0,function(){var h,i;return(0,f.b)(this,function(j){return(0,f.p)(a instanceof b&&c instanceof R&&c.sendingStatus===f.ax.SUCCEEDED&&this.url===c.channelUrl&&!c.scheduledInfo).throw(f.q.invalidParameters),(0,f.p)(!c.poll).throw(f.q.notSupportedError),h=new f.aV,i=null!==(d=c.messageParams)&& void 0!==d?d:(0,f.g)((0,f.d)((0,f.d)({},c),{mentionType:c.mentionType,mentionedUserIds:null!==(e=c.mentionedUserIds)&& void 0!==e?e:null===(g=c.mentionedUsers)|| void 0===g?void 0:g.map(function(a){return a.userId}),translationTargetLanguages:Object.keys(c.translations),pushNotificationDeliveryOption:f.av.DEFAULT,parentMessageId:null,isReplyToChannel:!1,isPinnedMessage:!1})),a._sendUserMessage(i).onSucceeded(function(a){h.resolve(a)}).onFailed(function(a){return h.reject(a)}),[2,h.promise]})})},b.prototype.translateUserMessage=function(a,b){return(0,f._)(this,void 0,void 0,function(){var c,d,e;return(0,f.b)(this,function(g){switch(g.label){case 0:return(0,f.p)(a instanceof R&&a.messageId>0&&(0,f.a2)("string",b)).throw(f.q.invalidParameters),c=f.V.of(this._iid).requestQueue,d=new b0({channelType:this.channelType,channelUrl:this.url,messageId:a.messageId,translationTargetLanguages:b}),[4,c.send(d)];case 1:return[2,(e=g.sent()).as(b1).message]}})})},b.prototype._createScheduledUserMessage=function(a,b){var c=this,d=f.V.of(this._iid).requestQueue,e=Date.now(),g=this._generateRequestId();(0,f.aU)(2).then(function(){var d=c._createPendingScheduledUserMessage(a,g,e);(0,f.N)(function(){return(0,f._)(c,void 0,void 0,function(){return(0,f.b)(this,function(a){return[2,b._trigger(d)]})})})});var h=new b2((0,f.d)({reqId:g,channelType:this.channelType,channelUrl:this.url},a));d.send(h).then(function(a){var d=a.as(b3).message;(0,f.N)(function(){return(0,f._)(c,void 0,void 0,function(){return(0,f.b)(this,function(a){return[2,b._trigger(d)]})})})}).catch(function(d){if((0,f.a1)(d))throw d;(0,f.aU)(2).then(function(){var h=c._createPendingScheduledUserMessage(a,g,e);c._markMessageAsFailed(h,d),(0,f.N)(function(){return(0,f._)(c,void 0,void 0,function(){return(0,f.b)(this,function(a){return[2,b._triggerFailed(d,h)]})})})})})},b.prototype.sendFileMessage=function(a){var b=(0,f.d)((0,f.d)({},aM),a);return(0,f.p)(aR(b)).throw(f.q.invalidParameters),this._sendFileMessage(b)},b.prototype.sendMultipleFilesMessage=function(a){var b,c,d,e=(0,f.d)((0,f.d)({},cz),a),g=f.V.of(this._iid);(0,f.p)((c=e,void 0===(d=null===(b=g.appInfo)|| void 0===b?void 0:b.multipleFilesMessageFileCountLimit)&&(d=f.b3),aB(c)&&(0,f.a)("string",c.message,!0)&&Array.isArray(c.fileInfoList)&&c.fileInfoList.length>=2&&c.fileInfoList.length<=d&&c.fileInfoList.every(function(a){var b;return b=a,((0,f.i)(b.file)||(0,f.a)("string",b.fileUrl))&&(0,f.a)("string",b.fileName,!0)&&(0,f.a)("string",b.mimeType,!0)&&(0,f.a)("number",b.fileSize,!0)&&(void 0===b.thumbnailSizes||Array.isArray(b.thumbnailSizes)&&b.thumbnailSizes.every(function(a){return a.maxWidth>0&&a.maxHeight>0}))}))).throw(f.q.invalidParameters);var h=!!a.fileInfoList.find(function(a){var b=g.appInfo.uploadSizeLimit;return a.file instanceof Blob&&a.file.size>b||a.fileSize>b});return(0,f.p)(!h).throw(f.q.fileSizeLimitExceededError),this._sendMultipleFilesMessage(e)},b.prototype._sendFileMessage=function(a,b,c){var d=this;void 0===b&&(b=cI.SEND);var e=f.V.of(this._iid).dispatcher,g=es.of(this._iid).fileMessageQueue,h=null!=c?c:this._generateRequestId(),i=Date.now(),j=new az;return(0,f.aU)(2).then(function(){var c=d._createPendingFileMessage(a,h,i);e.dispatch(new f.aP({messages:[c],source:b===cI.RESEND?f.ab.LOCAL_MESSAGE_RESEND_STARTED:f.ab.EVENT_MESSAGE_SENT_PENDING})),(0,f.N)(function(){return(0,f._)(d,void 0,void 0,function(){return(0,f.b)(this,function(a){return[2,j._trigger(c)]})})}),g.request(d,h,a).then(function(a){e.dispatch(new f.aP({messages:[a],source:f.ab.EVENT_MESSAGE_SENT_SUCCESS})),(0,f.N)(function(){return(0,f._)(d,void 0,void 0,function(){return(0,f.b)(this,function(b){return[2,j._trigger(a)]})})})}).catch(function(b){if((0,f.a1)(b))throw b;(0,f.aU)(2).then(function(){var c=d._createPendingFileMessage(a,h,i),g=f.V.of(d._iid).cacheContext,k=g.localCacheEnabled&&g.localCacheConfig.enableAutoResend&&(0,f.b4)(b.code);d._markMessageAsFailed(c,b,k),e.dispatch(new f.aP({messages:[c],source:c.sendingStatus===f.ax.PENDING?f.ab.REQUEST_RESEND_MESSAGE:b.code===f.F.FILE_UPLOAD_CANCEL_FAILED?f.ab.LOCAL_MESSAGE_CANCELED:f.ab.EVENT_MESSAGE_SENT_FAILED})),(0,f.N)(function(){return(0,f._)(d,void 0,void 0,function(){return(0,f.b)(this,function(a){return[2,j._triggerFailed(b,c)]})})})})})}),j},b.prototype._autoResendFileMessage=function(a){(0,f.p)(a instanceof W&&!!a.messageParams).throw(f.q.invalidParameters);var b=f.V.of(this._iid).logger;return b.debug("autoResendFileMessage pending",a),this._sendFileMessage(a.messageParams,cI.SEND,a.reqId).onFailed(function(a){b.debug("autoResendFileMessage failed",a)}).onSucceeded(function(a){b.debug("autoResendFileMessage success",a)})},b.prototype._sendMultipleFilesMessage=function(a,b,c){var d=this,e=f.V.of(this._iid).dispatcher,g=es.of(this._iid).fileMessageQueue,h=null!=c?c:this._generateRequestId(),i=Date.now(),j=new cA;return(0,f.aU)(2).then(function(){var c=d._createPendingMultipleFilesMessage(a,h,i);e.dispatch(new f.aP({messages:[c],source:b===cI.RESEND?f.ab.LOCAL_MESSAGE_RESEND_STARTED:f.ab.EVENT_MESSAGE_SENT_PENDING})),(0,f.N)(function(){return(0,f._)(d,void 0,void 0,function(){return(0,f.b)(this,function(a){return[2,j._trigger(c)]})})}),g.request(d,h,a,{requestHandler:j,isCopy:b===cI.COPY}).then(function(a){e.dispatch(new f.aP({messages:[a],source:f.ab.EVENT_MESSAGE_SENT_SUCCESS})),(0,f.N)(function(){return(0,f._)(d,void 0,void 0,function(){return(0,f.b)(this,function(b){return[2,j._trigger(a)]})})})}).catch(function(b){if((0,f.a1)(b))throw b;(0,f.aU)(2).then(function(){var c=d._createPendingMultipleFilesMessage(a,h,i);d._markMessageAsFailed(c,b),e.dispatch(new f.aP({messages:[c],source:f.ab.EVENT_MESSAGE_SENT_FAILED})),(0,f.N)(function(){return(0,f._)(d,void 0,void 0,function(){return(0,f.b)(this,function(a){return[2,j._triggerFailed(b,c)]})})})})})}),j},b.prototype._createScheduledFileMessage=function(a,b,c,d){var e=this,g=f.V.of(this._iid).requestQueue,h=new b4((0,f.d)((0,f.d)({reqId:c,channelType:this.channelType,channelUrl:this.url},a),{fileUrl:a.fileUrl,requireAuth:a.requireAuth}));g.send(h).then(function(a){var c=a.as(b5).message;(0,f.N)(function(){return(0,f._)(e,void 0,void 0,function(){return(0,f.b)(this,function(a){return[2,b._trigger(c)]})})})}).catch(function(g){if((0,f.a1)(g))throw g;(0,f.aU)(2).then(function(){var h=e._createPendingScheduledFileMessage(a,c,d);e._markMessageAsFailed(h,g),(0,f.N)(function(){return(0,f._)(e,void 0,void 0,function(){return(0,f.b)(this,function(a){return[2,b._triggerFailed(g,h)]})})})})})},b.prototype.sendFileMessages=function(a){(0,f.p)(a.every(function(a){return aR((0,f.d)((0,f.d)({},aM),a))})).throw(f.q.invalidParameters);var b,c,d=new az;try{for(var e=(0,f.x)(a),g=e.next();!g.done;g=e.next()){var h=g.value;this.sendFileMessage(h).onPending(function(a){return d._trigger(a)}).onFailed(function(a,b){return d._triggerFailed(a,b)}).onSucceeded(function(a){return d._trigger(a)})}}catch(i){b={error:i}}finally{try{g&&!g.done&&(c=e.return)&&c.call(e)}finally{if(b)throw b.error}}return d},b.prototype.resendFileMessage=function(a,b){return(0,f._)(this,void 0,void 0,function(){var c,d,e;return(0,f.b)(this,function(g){return c=this._validateFailedFileMessageHasFile(a,b),(0,f.p)(a instanceof W&&c&&!a.scheduledInfo).throw(f.q.invalidParameters),d=new f.aV,e=aQ(a,b),this._sendFileMessage(e,cI.RESEND,a.reqId).onFailed(function(a){return d.reject(a)}).onSucceeded(function(a){return d.resolve(a)}),[2,d.promise]})})},b.prototype.resendMessage=function(a,b){var c,d;if((0,f.p)(a instanceof L&&!a.scheduledInfo&&a.isResendable).throw(f.q.invalidParameters),a.isUserMessage()){var e=null!==(c=a.messageParams)&& void 0!==c?c:aH(a);return this._sendUserMessage(e,cI.RESEND,a.reqId)}if(a.isFileMessage()){var g=this._validateFailedFileMessageHasFile(a,b);return(0,f.p)(g).throw(f.q.invalidParameters),e=null!==(d=a.messageParams)&& void 0!==d?d:aQ(a,b),this._sendFileMessage(e,cI.RESEND,a.reqId)}if(a.isMultipleFilesMessage())throw f.q.channelTypeNotSupportedError},b.prototype.updateFileMessage=function(a,b){return(0,f._)(this,void 0,void 0,function(){var c,d,e,g;return(0,f.b)(this,function(h){switch(h.label){case 0:var i;return c=(0,f.d)((0,f.d)({},aW),b),(0,f.p)((0,f.a)("number",a)&&aT(i=c)).throw(f.q.invalidParameters),d=f.V.of(this._iid).requestQueue,e=new bW((0,f.d)({channelType:this.channelType,channelUrl:this.url,messageId:a,metaArrayParams:c.metaArrays?{array:c.metaArrays,mode:"add",upsert:!0}:void 0},c)),[4,d.send(e)];case 1:return[2,(g=h.sent()).as(bX).message]}})})},b.prototype.uploadFile=function(a){return(0,f._)(this,void 0,void 0,function(){var b,c,d,e,g,j,k;return(0,f.b)(this,function(l){switch(l.label){case 0:return b=f.V.of(this._iid).requestQueue,c=(0,f.u)(),(d=new h({file:a.file,channelUrl:this.url,thumbnailSizes:a.thumbnailSizes,requestId:c})).uploadProgressHandler=a.progressHandler,a.uploadStartedHandler&&a.uploadStartedHandler(c),[4,b.send(d)];case 1:return j=(g=(e=l.sent()).as(i)).url,k=g.thumbnails,[2,{requestId:c,url:j,thumbnails:k}]}})})},b.prototype.cancelUploadingFileMessage=function(a){return(0,f._)(this,void 0,void 0,function(){return(0,f.b)(this,function(b){return(0,f.p)((0,f.a)("string",a)).throw(f.q.invalidParameters),es.of(this._iid).fileMessageQueue.cancel(this,a),[2,!0]})})},b.prototype.copyFileMessage=function(a,c){var d,e,g;return(0,f._)(this,void 0,void 0,function(){var h,i;return(0,f.b)(this,function(j){return(0,f.p)(a instanceof b&&c instanceof W&&c.sendingStatus===f.ax.SUCCEEDED&&this.url===c.channelUrl&&!c.scheduledInfo).throw(f.q.invalidParameters),h=new f.aV,i=(0,f.g)((0,f.d)((0,f.d)({},c),{fileUrl:c.url,fileName:c.name,fileSize:c.size,mimeType:c.type,mentionType:c.mentionType,mentionedUserIds:null!==(d=c.mentionedUserIds)&& void 0!==d?d:null===(e=c.mentionedUsers)|| void 0===e?void 0:e.map(function(a){return a.userId}),pushNotificationDeliveryOption:f.av.DEFAULT,parentMessageId:null,isReplyToChannel:!1,thumbnailSizes:null===(g=c.thumbnails)|| void 0===g?void 0:g.map(function(a){return{maxWidth:a.width,maxHeight:a.height}}),requireAuth:c.requireAuth,isPinnedMessage:!1})),a._sendFileMessage(i).onSucceeded(function(a){return h.resolve(a)}).onFailed(function(a){return h.reject(a)}),[2,h.promise]})})},b.prototype.copyMessage=function(a,c){(0,f.p)(a instanceof b&&c instanceof L&&c.sendingStatus===f.ax.SUCCEEDED&&this.url===c.channelUrl&&!c.scheduledInfo).throw(f.q.invalidParameters);var d=c,e=a;if(d.isUserMessage()){(0,f.p)(!d.poll).throw(f.q.notSupportedError);var g=aE(d);return e._sendUserMessage(g)}if(d.isFileMessage())return g=aN(d),e._sendFileMessage(g);if(c.isMultipleFilesMessage())throw f.q.channelTypeNotSupportedError},b.prototype.deleteMessage=function(a){return(0,f._)(this,void 0,void 0,function(){var b,c;return(0,f.b)(this,function(d){switch(d.label){case 0:return(0,f.p)(a instanceof K).throw(f.q.invalidParameters),a.messageId>0?(b=f.V.of(this._iid).requestQueue,c=new f.b5({channelType:this.channelType,channelUrl:this.url,messageId:a.messageId,messageToken:a instanceof L?a._messageToken:void 0}),[4,b.send(c)]):[3,2];case 1:d.sent(),d.label=2;case 2:return[2]}})})},b.prototype.addReaction=function(a,b){return(0,f._)(this,void 0,void 0,function(){var c,d,e;return(0,f.b)(this,function(g){switch(g.label){case 0:return(0,f.p)(a instanceof K&&a.messageId>0&&(0,f.a)("string",b)).throw(f.q.invalidParameters),c=f.V.of(this._iid).requestQueue,d=new bY({channelType:this.channelType,channelUrl:this.url,messageId:a.messageId,reactionKey:b}),[4,c.send(d)];case 1:return[2,(e=g.sent()).as(bZ).reactionEvent]}})})},b.prototype.deleteReaction=function(a,b){return(0,f._)(this,void 0,void 0,function(){var c,d,e;return(0,f.b)(this,function(g){switch(g.label){case 0:return(0,f.p)(a instanceof K&&a.messageId>0&&(0,f.a)("string",b)).throw(f.q.invalidParameters),c=f.V.of(this._iid).requestQueue,d=new b$({channelType:this.channelType,channelUrl:this.url,messageId:a.messageId,reactionKey:b}),[4,c.send(d)];case 1:return[2,(e=g.sent()).as(b_).reactionEvent]}})})},b.prototype._updateUserMessageMetaArray=function(a,b,c,d){return(0,f._)(this,void 0,void 0,function(){var e,g,h,i,j,k;return(0,f.b)(this,function(l){switch(l.label){case 0:return g=(e=f.V.of(this._iid)).dispatcher,h=e.requestQueue,i=new bU({channelType:this.channelType,channelUrl:this.url,messageId:a,metaArrayParams:{array:b,mode:c,upsert:d}}),[4,h.send(i)];case 1:return k=(j=l.sent()).as(bV).message,g.dispatch(new f.aP({messages:[k],source:f.ab.EVENT_MESSAGE_UPDATED})),[2,k]}})})},b.prototype._updateFileMessageMetaArray=function(a,b,c,d){return(0,f._)(this,void 0,void 0,function(){var e,g,h,i,j,k;return(0,f.b)(this,function(l){switch(l.label){case 0:return g=(e=f.V.of(this._iid)).dispatcher,h=e.requestQueue,i=new bW({channelType:this.channelType,channelUrl:this.url,messageId:a,metaArrayParams:{array:b,mode:c,upsert:d}}),[4,h.send(i)];case 1:return k=(j=l.sent()).as(bX).message,g.dispatch(new f.aP({messages:[k],source:f.ab.EVENT_MESSAGE_UPDATED})),[2,k]}})})},b.prototype.createMessageMetaArrayKeys=function(a,b){return(0,f._)(this,void 0,void 0,function(){var c;return(0,f.b)(this,function(d){return(0,f.p)(a instanceof K&&a.messageId>0&&(0,f.a2)("string",b)).throw(f.q.invalidParameters),c=b.map(function(a){return new s({key:a})}),a instanceof W?[2,this._updateFileMessageMetaArray(a.messageId,c,"add",!0)]:[2,this._updateUserMessageMetaArray(a.messageId,c,"add",!0)]})})},b.prototype.deleteMessageMetaArrayKeys=function(a,b){return(0,f._)(this,void 0,void 0,function(){var c;return(0,f.b)(this,function(d){return(0,f.p)(a instanceof K&&a.messageId>0&&(0,f.a2)("string",b)).throw(f.q.invalidParameters),c=b.map(function(a){return new s({key:a})}),a instanceof W?[2,this._updateFileMessageMetaArray(a.messageId,c,"remove",!0)]:[2,this._updateUserMessageMetaArray(a.messageId,c,"remove",!0)]})})},b.prototype.addMessageMetaArrayValues=function(a,b){return(0,f._)(this,void 0,void 0,function(){return(0,f.b)(this,function(c){return(0,f.p)(a instanceof K&&a.messageId>0&&b.every(function(a){return a instanceof s})).throw(f.q.invalidParameters),a instanceof W?[2,this._updateFileMessageMetaArray(a.messageId,b,"add",!0)]:[2,this._updateUserMessageMetaArray(a.messageId,b,"add",!0)]})})},b.prototype.removeMessageMetaArrayValues=function(a,b){return(0,f._)(this,void 0,void 0,function(){return(0,f.b)(this,function(c){return(0,f.p)(a instanceof K&&a.messageId>0&&b.every(function(a){return a instanceof s})).throw(f.q.invalidParameters),a instanceof W?[2,this._updateFileMessageMetaArray(a.messageId,b,"remove",!0)]:[2,this._updateUserMessageMetaArray(a.messageId,b,"remove",!0)]})})},b.prototype.report=function(a,b){return(0,f._)(this,void 0,void 0,function(){var c,d,e,g;return(0,f.b)(this,function(h){switch(h.label){case 0:return(0,f.p)(((0,f.a5)(aO,a)||a instanceof f.ah)&&(0,f.a)("string",b)).throw(f.q.invalidParameters),d=(c=f.V.of(this._iid)).sdkState,e=c.requestQueue,g=new bP({channelUrl:this.url,channelType:this.channelType,userId:d.userId,category:a,description:b}),[4,e.send(g)];case 1:return h.sent(),[2]}})})},b.prototype.reportUser=function(a,b,c){return(0,f._)(this,void 0,void 0,function(){var d,e,g,h;return(0,f.b)(this,function(i){switch(i.label){case 0:return(0,f.p)(a instanceof f.U&&((0,f.a5)(aO,b)||b instanceof f.ah)&&(0,f.a)("string",c)).throw(f.q.invalidParameters),e=(d=f.V.of(this._iid)).sdkState,g=d.requestQueue,h=new bQ({channelUrl:this.url,channelType:this.channelType,userId:e.userId,offendingUserId:a.userId,category:b,description:c}),[4,g.send(h)];case 1:return i.sent(),[2]}})})},b.prototype.reportMessage=function(a,b,c){return(0,f._)(this,void 0,void 0,function(){var d,e,g,h;return(0,f.b)(this,function(i){switch(i.label){case 0:return(0,f.p)(a instanceof L&&((0,f.a5)(aO,b)||b instanceof f.ah)&&(0,f.a)("string",c)).throw(f.q.invalidParameters),e=(d=f.V.of(this._iid)).sdkState,g=d.requestQueue,h=new bR({channelUrl:this.url,channelType:this.channelType,userId:e.userId,offendingUserId:a.sender.userId,messageId:a.messageId,category:b,description:c,messageToken:a._messageToken}),[4,g.send(h)];case 1:return i.sent(),[2]}})})},b.prototype.updatePoll=function(a,b){return(0,f._)(this,void 0,void 0,function(){var c,d,e;return(0,f.b)(this,function(g){switch(g.label){case 0:var h;return(0,f.p)((0,f.a)("number",a)&&(h=b,(0,f.a)("string",h.title,!0)&&(0,f.b1)(h.data)&&(0,f.a)("boolean",h.allowUserSuggestion,!0)&&(0,f.a)("boolean",h.allowMultipleVotes,!0)&&(0,f.a)("number",h.closeAt,!0))).throw(f.q.invalidParameters),c=f.V.of(this._iid).requestQueue,d=new b6((0,f.d)({pollId:a},b)),[4,c.send(d)];case 1:return[2,(e=g.sent()).as(b7).poll]}})})},b.prototype.deletePoll=function(a){return(0,f._)(this,void 0,void 0,function(){var b,c,d;return(0,f.b)(this,function(e){switch(e.label){case 0:return b=(0,f.a)("number",a),(0,f.p)(b).throw(f.q.invalidParameters),c=f.V.of(this._iid).requestQueue,d=new b8({pollId:a}),[4,c.send(d)];case 1:return e.sent(),[2]}})})},b.prototype.closePoll=function(a){return(0,f._)(this,void 0,void 0,function(){var b,c,d,e;return(0,f.b)(this,function(g){switch(g.label){case 0:return b=(0,f.a)("number",a),(0,f.p)(b).throw(f.q.invalidParameters),c=f.V.of(this._iid).requestQueue,d=new ca({pollId:a}),[4,c.send(d)];case 1:return[2,(e=g.sent()).as(cb).poll]}})})},b.prototype.addPollOption=function(a,b){return(0,f._)(this,void 0,void 0,function(){var c,d,e,g;return(0,f.b)(this,function(h){switch(h.label){case 0:return c=(0,f.a)("number",a)&&(0,f.a)("string",b)&&""!==b.trim(),(0,f.p)(c).throw(f.q.invalidParameters),d=f.V.of(this._iid).requestQueue,e=new cc({channelUrl:this.url,channelType:this.channelType,pollId:a,optionText:b}),[4,d.send(e)];case 1:return[2,(g=h.sent()).as(cd).poll]}})})},b.prototype.updatePollOption=function(a,b,c){return(0,f._)(this,void 0,void 0,function(){var d,e,g,h;return(0,f.b)(this,function(i){switch(i.label){case 0:return d=(0,f.a)("number",a)&&(0,f.a)("number",b)&&(0,f.a)("string",c)&&""!==c.trim(),(0,f.p)(d).throw(f.q.invalidParameters),e=f.V.of(this._iid).requestQueue,g=new ce({pollId:a,pollOptionId:b,optionText:c}),[4,e.send(g)];case 1:return[2,(h=i.sent()).as(cf).poll]}})})},b.prototype.deletePollOption=function(a,b){return(0,f._)(this,void 0,void 0,function(){var c,d,e;return(0,f.b)(this,function(g){switch(g.label){case 0:return c=(0,f.a)("number",a)&&(0,f.a)("number",b),(0,f.p)(c).throw(f.q.invalidParameters),d=f.V.of(this._iid).requestQueue,e=new cg({pollId:a,pollOptionId:b}),[4,d.send(e)];case 1:return g.sent(),[2]}})})},b.prototype.votePoll=function(a,b){return(0,f._)(this,void 0,void 0,function(){var c,d,e,g,h,i,j;return(0,f.b)(this,function(k){switch(k.label){case 0:return c=(0,f.a)("number",a)&&(0,f.a2)("number",b),(0,f.p)(c).throw(f.q.invalidParameters),d=f.V.of(this._iid),e=d.requestQueue,g=d.dispatcher,h=new ch({reqId:this._generateRequestId(),channelUrl:this.url,channelType:this.channelType,pollId:a,pollOptionIds:b}),[4,e.send(h)];case 1:return j=(i=k.sent()).as(ci).event,g.dispatch(new f.b6({event:j,source:f.ab.EVENT_POLL_VOTED})),[2,j]}})})},b.prototype.getPollChangeLogsSinceTimestamp=function(a){return(0,f._)(this,void 0,void 0,function(){return(0,f.b)(this,function(b){switch(b.label){case 0:return(0,f.p)((0,f.a)("number",a)).throw(f.q.invalidParameters),[4,f.ay.of(this._iid).getPollChangeLogs(this.url,this.channelType,a)];case 1:return[2,b.sent()]}})})},b.prototype.getPollChangeLogsSinceToken=function(a){return(0,f._)(this,void 0,void 0,function(){return(0,f.b)(this,function(b){switch(b.label){case 0:return(0,f.p)((0,f.a)("string",a,!0)),[4,f.ay.of(this._iid).getPollChangeLogs(this.url,this.channelType,a)];case 1:return[2,b.sent()]}})})},b.prototype.createPollListQuery=function(a){return void 0===a&&(a=10),new f.G(this._iid,{channelUrl:this.url,channelType:this.channelType,limit:a})},b.prototype.createPollVoterListQuery=function(a,b,c){return void 0===c&&(c=20),new f.H(this._iid,{channelUrl:this.url,channelType:this.channelType,pollId:a,pollOptionId:b,limit:c})},b.prototype.pinMessage=function(a){return(0,f._)(this,void 0,void 0,function(){var b,c;return(0,f.b)(this,function(d){switch(d.label){case 0:return(0,f.p)((0,f.a)("number",a)&&a>0).throw(f.q.invalidParameters),b=f.V.of(this._iid).requestQueue,c=new cF({channelType:this.channelType,channelUrl:this.url,messageId:a}),[4,b.send(c)];case 1:return d.sent(),[2]}})})},b.prototype.unpinMessage=function(a){return(0,f._)(this,void 0,void 0,function(){var b,c;return(0,f.b)(this,function(d){switch(d.label){case 0:return(0,f.p)((0,f.a)("number",a)&&a>0).throw(f.q.invalidParameters),b=f.V.of(this._iid).requestQueue,c=new cH({channelType:this.channelType,channelUrl:this.url,messageId:a}),[4,b.send(c)];case 1:return d.sent(),[2]}})})},b}(f.aK),cO=function(a){function b(b){void 0===b&&(b={});var c=a.call(this)||this;return Object.keys(b).forEach(function(a){c.hasOwnProperty(a)&&(c[a]=b[a])}),c}return(0,f.c)(b,a),b}(function(){this.onConnected=f.aX,this.onReconnectStarted=f.aX,this.onReconnectSucceeded=f.aX,this.onReconnectFailed=f.aX,this.onConnectionLost=f.aX,this.onDisconnected=f.aX,this.onConnectionDelayed=f.aX}),cP=function(a){function b(b){void 0===b&&(b={});var c=a.call(this)||this;return Object.keys(b).forEach(function(a){c.hasOwnProperty(a)&&(c[a]=b[a])}),c}return(0,f.c)(b,a),b}(function(){this.onSessionExpired=f.aX,this.onSessionTokenRequired=function(a){return a(null)},this.onSessionError=f.aX,this.onSessionRefreshed=f.aX,this.onSessionClosed=f.aX}),cQ=function(a){function b(b){void 0===b&&(b={});var c=a.call(this)||this;return Object.keys(b).forEach(function(a){c.hasOwnProperty(a)&&(c[a]=b[a])}),c}return(0,f.c)(b,a),b}(function(){this.onFriendsDiscovered=f.aX,this.onTotalUnreadMessageCountChanged=f.aX,this.onTotalUnreadMessageCountUpdated=f.aX}),cR=function(a){function b(b){var c=b.limit,d=b.token,e=b.userIdsFilter,g=b.metaDataKeyFilter,h=b.metaDataValuesFilter,i=b.nicknameStartsWithFilter,j=a.call(this)||this;return j.method=f.A.GET,j.path=f.k,j.params=(0,f.f)({limit:c,token:d,user_ids:e,metadatakey:g,metadatavalues_in:h,nickname_startswith:i}),j}return(0,f.c)(b,a),b}(f.h),cS=function(a){function b(b,c){var d=a.call(this,b,c)||this;return d.users=c.users.map(function(a){return new f.U(b,a)}),d.next=c.next,d}return(0,f.c)(b,a),b}(f.j),cT=function(a){function b(b,c){var d,e,f,g=this;return(g=a.call(this,b,c)||this).userIdsFilter=null,g.metaDataKeyFilter=null,g.metaDataValuesFilter=null,g.nicknameStartsWithFilter=null,g.userIdsFilter=null!==(d=c.userIdsFilter)&& void 0!==d?d:null,g.metaDataKeyFilter=null!==(e=c.metaDataKeyFilter)&& void 0!==e?e:null,g.metaDataValuesFilter=null!==(f=c.metaDataValuesFilter)&& void 0!==f?f:null,g.nicknameStartsWithFilter=c.nicknameStartsWithFilter||null,g}return(0,f.c)(b,a),b.prototype._validate=function(){return a.prototype._validate.call(this)&&(0,f.a2)("string",this.userIdsFilter,!0)&&(0,f.a)("string",this.metaDataKeyFilter,!0)&&(0,f.a2)("string",this.metaDataValuesFilter,!0)&&(0,f.a)("string",this.nicknameStartsWithFilter,!0)},b.prototype.next=function(){return(0,f._)(this,void 0,void 0,function(){var a,b,c,d,e,g;return(0,f.b)(this,function(h){switch(h.label){case 0:return this._validate()?this._isLoading?[3,3]:this._hasNext?(this._isLoading=!0,a=f.V.of(this._iid).requestQueue,b=new cR((0,f.g)((0,f.d)((0,f.d)({},this),{token:this._token}))),[4,a.send(b)]):[3,2]:[3,5];case 1:return e=(d=(c=h.sent()).as(cS)).users,g=d.next,this._token=g,this._hasNext=!!g,this._isLoading=!1,[2,e];case 2:return[2,[]];case 3:throw f.q.queryInProgress;case 4:return[3,6];case 5:throw f.q.invalidParameters;case 6:return[2]}})})},b}(f.ap),cU=function(a){function b(b){var c=b.userId,d=b.limit,e=b.token,g=b.userIdsFilter,h=a.call(this)||this;return h.method=f.A.GET,h.path="".concat(f.k,"/").concat(encodeURIComponent(c),"/block"),h.params=(0,f.f)({limit:d,token:e,user_ids:g}),h}return(0,f.c)(b,a),b}(f.h),cV=function(a){function b(b,c){var d=a.call(this,b,c)||this;return d.users=c.users.map(function(a){return new f.U(b,a)}),d.next=c.next,d}return(0,f.c)(b,a),b}(f.j),cW=function(a){function b(b,c){var d,e=this;return(e=a.call(this,b,c)||this).userIdsFilter=null,e.userIdsFilter=null!==(d=c.userIdsFilter)&& void 0!==d?d:null,e}return(0,f.c)(b,a),b.prototype._validate=function(){return a.prototype._validate.call(this)&&(0,f.a2)("string",this.userIdsFilter,!0)},b.prototype.next=function(){return(0,f._)(this,void 0,void 0,function(){var a,b,c,d,e,g,h,i;return(0,f.b)(this,function(j){switch(j.label){case 0:return this._validate()?this._isLoading?[3,3]:this._hasNext?(this._isLoading=!0,b=(a=f.V.of(this._iid)).sdkState,c=a.requestQueue,d=new cU((0,f.g)((0,f.d)((0,f.d)({},this),{userId:b.userId,token:this._token}))),[4,c.send(d)]):[3,2]:[3,5];case 1:return h=(g=(e=j.sent()).as(cV)).users,i=g.next,this._token=i,this._hasNext=!!i,this._isLoading=!1,[2,h];case 2:return[2,[]];case 3:throw f.q.queryInProgress;case 4:return[3,6];case 5:throw f.q.invalidParameters;case 6:return[2]}})})},b}(f.ap),cX=function(a){function b(b){var c=b.userId,d=b.limit,e=b.token,g=a.call(this)||this;return g.method=f.A.GET,g.path="".concat(f.k,"/").concat(encodeURIComponent(c),"/friends"),g.params={limit:d,token:e},g}return(0,f.c)(b,a),b}(f.h),cY=function(a){function b(b,c){var d=a.call(this,b,c)||this;return d.hasMore=c.has_more,d.users=c.users.map(function(a){return new f.U(b,a)}),d.next=c.next,d}return(0,f.c)(b,a),b}(f.j),cZ=function(a){function b(){return null!==a&&a.apply(this,arguments)||this}return(0,f.c)(b,a),b.prototype._validate=function(){return a.prototype._validate.call(this)},b.prototype.next=function(){return(0,f._)(this,void 0,void 0,function(){var a,b,c,d,e,g,h,i,j;return(0,f.b)(this,function(k){switch(k.label){case 0:return this._validate()?this._isLoading?[3,3]:this._hasNext?(this._isLoading=!0,b=(a=f.V.of(this._iid)).sdkState,c=a.requestQueue,d=new cX((0,f.d)((0,f.d)({},this),{userId:b.userId,token:this._token})),[4,c.send(d)]):[3,2]:[3,5];case 1:return h=(g=(e=k.sent()).as(cY)).users,i=g.hasMore,j=g.next,this._token=j,this._hasNext=i,this._isLoading=!1,[2,h];case 2:return[2,[]];case 3:throw f.q.queryInProgress;case 4:return[3,6];case 5:throw f.q.invalidParameters;case 6:return[2]}})})},b}(f.ap),c$={},c_=function(){function a(a){var b=a.dbname,c=a.itemSizeLimit,d=a.cacheLimit,e=a.blockHashBase,f=a.blockHashMultiplier,g=a.blockHashConstant,h=a.transactionApplyDelay,i=a.disableLogger;return c$[b]||(this.itemSizeLimit=void 0===c?1048576:c,this.cacheLimit=void 0===d?256:d,this.blockHashBase=void 0===e?2:e,this.blockHashMultiplier=void 0===f?10:f,this.blockHashConstant=void 0===g?11:g,this.transactionApplyDelay=void 0===h?200:h,this.disableLogger=void 0!==i&&i,c$[b]=this),c$[b]}return a.get=function(a){return c$[a]},a}();(cM=cL||(cL={}))[cM.UNKNOWN_ERROR=6e7]="UNKNOWN_ERROR",cM[cM.STORE_NOT_DEFINED=61001e3]="STORE_NOT_DEFINED",cM[cM.STORE_NOT_AVAILABLE=61001001]="STORE_NOT_AVAILABLE",cM[cM.STORE_NOT_AVAILABLE_IN_PRIVATE_BROWSING=61001002]="STORE_NOT_AVAILABLE_IN_PRIVATE_BROWSING",cM[cM.STORE_IS_FULL=61001003]="STORE_IS_FULL",cM[cM.STORE_NOT_INITIALIZED=61001004]="STORE_NOT_INITIALIZED",cM[cM.STORE_INVALID_KEY_TYPE=61002e3]="STORE_INVALID_KEY_TYPE",cM[cM.STORE_BROKEN_INTEGRITY=61002001]="STORE_BROKEN_INTEGRITY",cM[cM.STORE_BROKEN_BLOB=61002002]="STORE_BROKEN_BLOB",cM[cM.STORE_ENCRYPTION_INVALID=61002003]="STORE_ENCRYPTION_INVALID",cM[cM.STORE_ITEM_SIZE_LIMIT_EXCEEDED=61017e3]="STORE_ITEM_SIZE_LIMIT_EXCEEDED",cM[cM.STORE_READ_FAILED=61017001]="STORE_READ_FAILED",cM[cM.STORE_WRITE_FAILED=61017002]="STORE_WRITE_FAILED",cM[cM.DATABASE_SCHEMA_NOT_ON_UPGRADE=62002e3]="DATABASE_SCHEMA_NOT_ON_UPGRADE",cM[cM.COLLECTION_NOT_READY=63001e3]="COLLECTION_NOT_READY",cM[cM.COLLECTION_KEY_NOT_MATCH=63002e3]="COLLECTION_KEY_NOT_MATCH",cM[cM.COLLECTION_QUERY_NOT_VALID=63002001]="COLLECTION_QUERY_NOT_VALID",cM[cM.COLLECTION_KEY_NOT_FOUND=63004e3]="COLLECTION_KEY_NOT_FOUND",cM[cM.COLLECTION_KEY_NOT_GIVEN=63004001]="COLLECTION_KEY_NOT_GIVEN",cM[cM.COLLECTION_INSERT_DUPLICATE=63009e3]="COLLECTION_INSERT_DUPLICATE",cM[cM.COLLECTION_WRITE_FAILED=63017e3]="COLLECTION_WRITE_FAILED",cM[cM.COLLECTION_ITEM_SIZE_LIMIT_EXCEEDED=63017001]="COLLECTION_ITEM_SIZE_LIMIT_EXCEEDED",cM[cM.INDEX_TABLE_IS_REQUIRED=65001e3]="INDEX_TABLE_IS_REQUIRED",cM[cM.INDEX_TYPE_NOT_MATCH=65002e3]="INDEX_TYPE_NOT_MATCH",cM[cM.COMPARE_TYPE_NOT_MATCH=69002001]="COMPARE_TYPE_NOT_MATCH",cM[cM.CIRCULAR_REFERENCE_FOUND=69002002]="CIRCULAR_REFERENCE_FOUND";var c0,c1,c2=function(a){function b(c){var d=c.code,e=void 0===d?cL.UNKNOWN_ERROR:d,f=c.message,g=a.call(this,void 0===f?"Unknown error occurred.":f)||this;return g.code=e,Object.setPrototypeOf(g,b.prototype),g}return(0,f.c)(b,a),Object.defineProperty(b,"storeNotDefined",{get:function(){return new b({code:cL.STORE_NOT_DEFINED,message:"Store is not defined. Specify the store on NestDB()"})},enumerable:!1,configurable:!0}),Object.defineProperty(b,"storeNotAvailable",{get:function(){return new b({code:cL.STORE_NOT_AVAILABLE,message:"Store is not available. Check your environment settings."})},enumerable:!1,configurable:!0}),Object.defineProperty(b,"storeNotAvailableInPrivateBrowsing",{get:function(){return new b({code:cL.STORE_NOT_AVAILABLE_IN_PRIVATE_BROWSING,message:"Store is not available because it is in private browsing."})},enumerable:!1,configurable:!0}),Object.defineProperty(b,"storeIsFull",{get:function(){return new b({code:cL.STORE_IS_FULL,message:"Store is full."})},enumerable:!1,configurable:!0}),Object.defineProperty(b,"storeNotInitialized",{get:function(){return new b({code:cL.STORE_NOT_INITIALIZED,message:"Store is not initialized."})},enumerable:!1,configurable:!0}),Object.defineProperty(b,"storeKeyTypeIsInvalid",{get:function(){return new b({code:cL.STORE_INVALID_KEY_TYPE,message:"Store key should be string type."})},enumerable:!1,configurable:!0}),Object.defineProperty(b,"storeBrokenIntegrity",{get:function(){return new b({code:cL.STORE_BROKEN_INTEGRITY,message:"Data should be in a store but it does not. Integrity is broken."})},enumerable:!1,configurable:!0}),Object.defineProperty(b,"storeBrokenBlob",{get:function(){return new b({code:cL.STORE_BROKEN_BLOB,message:"Data should be in a store but it does not. Blob data is broken."})},enumerable:!1,configurable:!0}),Object.defineProperty(b,"storeEncryptionInvalid",{get:function(){return new b({code:cL.STORE_ENCRYPTION_INVALID,message:"Encryption algorithm has changed. All the store should reset."})},enumerable:!1,configurable:!0}),Object.defineProperty(b,"storeItemSizeExceeded",{get:function(){return new b({code:cL.STORE_ITEM_SIZE_LIMIT_EXCEEDED,message:"The size of the item exceeds the limit that the store allows."})},enumerable:!1,configurable:!0}),Object.defineProperty(b,"storeReadFailed",{get:function(){return new b({code:cL.STORE_READ_FAILED,message:"Failed to read from store."})},enumerable:!1,configurable:!0}),Object.defineProperty(b,"storeWriteFailed",{get:function(){return new b({code:cL.STORE_WRITE_FAILED,message:"Failed to write to store."})},enumerable:!1,configurable:!0}),Object.defineProperty(b,"databaseSchemaNotOnUpgrade",{get:function(){return new b({code:cL.DATABASE_SCHEMA_NOT_ON_UPGRADE,message:"Committing schema is not allowed when upgrade is not running."})},enumerable:!1,configurable:!0}),Object.defineProperty(b,"collectionNotReady",{get:function(){return new b({code:cL.COLLECTION_NOT_READY,message:"Collection is not ready due to an error during initialization."})},enumerable:!1,configurable:!0}),Object.defineProperty(b,"collectionKeyNotMatch",{get:function(){return new b({code:cL.COLLECTION_KEY_NOT_MATCH,message:"keyName of collection could not change."})},enumerable:!1,configurable:!0}),Object.defineProperty(b,"collectionQueryNotValid",{get:function(){return new b({code:cL.COLLECTION_QUERY_NOT_VALID,message:"Query parameter is not a valid format."})},enumerable:!1,configurable:!0}),Object.defineProperty(b,"collectionInsertDuplicate",{get:function(){return new b({code:cL.COLLECTION_INSERT_DUPLICATE,message:"The key already exists."})},enumerable:!1,configurable:!0}),Object.defineProperty(b,"collectionKeyNotFound",{get:function(){return new b({code:cL.COLLECTION_KEY_NOT_FOUND,message:"The key is not found."})},enumerable:!1,configurable:!0}),Object.defineProperty(b,"collectionKeyNotGiven",{get:function(){return new b({code:cL.COLLECTION_KEY_NOT_GIVEN,message:"The item should contain [keyName] property."})},enumerable:!1,configurable:!0}),Object.defineProperty(b,"collectionWriteFailed",{get:function(){return new b({code:cL.COLLECTION_WRITE_FAILED,message:"Failed to write an item."})},enumerable:!1,configurable:!0}),Object.defineProperty(b,"collectionItemSizeExceeded",{get:function(){return new b({code:cL.COLLECTION_ITEM_SIZE_LIMIT_EXCEEDED,message:"The size of the item exceeds the limit that a collection allows."})},enumerable:!1,configurable:!0}),Object.defineProperty(b,"indexTableIsRequired",{get:function(){return new b({code:cL.INDEX_TABLE_IS_REQUIRED,message:"Index table is required."})},enumerable:!1,configurable:!0}),Object.defineProperty(b,"indexTypesNotMatch",{get:function(){return new b({code:cL.INDEX_TYPE_NOT_MATCH,message:"Indexed column should have primitive type."})},enumerable:!1,configurable:!0}),Object.defineProperty(b,"compareTypesNotMatch",{get:function(){return new b({code:cL.COMPARE_TYPE_NOT_MATCH,message:"Values to compare have different types."})},enumerable:!1,configurable:!0}),Object.defineProperty(b,"circularReferenceFound",{get:function(){return new b({code:cL.CIRCULAR_REFERENCE_FOUND,message:"Cannot handle circular referenced object."})},enumerable:!1,configurable:!0}),b}(Error);(c1=c0||(c0={})).INIT="init",c1.READY="ready",c1.CLOSED="closed";var c3,c4,c5=function(a,b){if(void 0===b&&(b=new WeakMap),"object"==typeof a&&null!==a){var c;if(b.has(a))throw c2.circularReferenceFound;return b.set(a,!0),Array.isArray(a)?c=a.map(function(a){return c5(a,b)}):a instanceof RegExp||a instanceof Date?c=a:(c={},Object.keys(a).forEach(function(d){c[d]=c5(a[d],b)})),b.delete(a),c}return a},c6=function(a,b){if(null==b)return 1;if(null==a)return -1;if(typeof a!=typeof b)throw c2.compareTypesNotMatch;var c=0;switch(typeof a){case"boolean":case"number":c=a-b;break;case"string":c=a.localeCompare(b)}return c},c7=function(a,b){for(var c=0,d=0;d>>0)%b},c8=function(a){return new Promise(function(b){setTimeout(function(){return b()},a)})},c9=function(a,b){if(!b)return!1;if("function"!=typeof a){for(var c in a)if(["/and","&&"].includes(c)){if(a[c].some(function(a){return!c9(a,b)}))return!1}else if(["/or","||"].includes(c)){if(a[c].every(function(a){return!c9(a,b)}))return!1}else if("/where"===c){if(!(0,a[c])(b))return!1}else{var d=c;if("object"==typeof a[d]){var e=a[d];for(var f in e)switch(f){case"/eq":case"=":if((g=b[d])!==(h=e[f]))return!1;break;case"/neq":case"!=":if((g=b[d])===(h=e[f]))return!1;break;case"/gt":case">":var g=b[d],h=e[f];if(!(c6(g,h)>0))return!1;break;case"/gte":case">=":if(!(c6(g=b[d],h=e[f])>=0))return!1;break;case"/lt":case"<":if(!(0>c6(g=b[d],h=e[f])))return!1;break;case"/lte":case"<=":if(!(0>=c6(g=b[d],h=e[f])))return!1;break;case"/in":if(g=b[d],!(h=e[f]).includes(g))return!1;break;case"/nin":if(g=b[d],(h=e[f]).includes(g))return!1;break;case"/contain":if(g=b[d],h=e[f],!g.includes(h))return!1;break;case"/regex":if(g=b[d],!(h=e[f]).test(g))return!1;break;case"/where":if(g=b[d],!(0,e[f])(g))return!1}}else if("function"==typeof a[d]){if(!a[d](b[d]))return!1}else if(a[d]!==b[d])return!1}return!0}return a(b)},da=function(){},db=function(){return Promise.resolve()},dc=function(a){return a},dd=function(a,b){b()};(c4=c3||(c3={}))[c4.FORWARD=0]="FORWARD",c4[c4.BACKWARD=1]="BACKWARD";var de,df,dg,dh,di,dj,dk=function(){function a(a){var b=a.initialPrevValue,c=a.initialNextValue,d=a.iterator,e=a.map,f=a.backward,g=a.forward,h=a.complete;this._prevValue=void 0===b?null:b,this._nextValue=void 0===c?null:c,this._error=null,this._map=void 0===e?dc:e,this._backward=void 0===f?db:f,this._forward=void 0===g?db:g,this._iterator=d,this._complete=void 0===h?da:h}return Object.defineProperty(a.prototype,"prevValue",{get:function(){return this._map(this._prevValue)},enumerable:!1,configurable:!0}),Object.defineProperty(a.prototype,"nextValue",{get:function(){return this._map(this._nextValue)},enumerable:!1,configurable:!0}),Object.defineProperty(a.prototype,"error",{get:function(){return this._error},enumerable:!1,configurable:!0}),Object.defineProperty(a.prototype,"hasPrevious",{get:function(){return!!this._prevValue},enumerable:!1,configurable:!0}),Object.defineProperty(a.prototype,"hasNext",{get:function(){return!!this._nextValue},enumerable:!1,configurable:!0}),a.prototype.prev=function(){return(0,f._)(this,void 0,void 0,function(){var a,b,c;return(0,f.b)(this,function(d){switch(d.label){case 0:if(!this.hasPrevious)return[3,6];d.label=1;case 1:return d.trys.push([1,3,,4]),a=this._prevValue,b=this,[4,this._backward()];case 2:return b._prevValue=d.sent()||null,this._nextValue=a,[3,4];case 3:return c=d.sent(),this._error=c,[3,4];case 4:return[4,this._iterator(this)];case 5:return[2,d.sent()];case 6:this._complete(),d.label=7;case 7:return[2]}})})},a.prototype.next=function(){return(0,f._)(this,void 0,void 0,function(){var a,b,c;return(0,f.b)(this,function(d){switch(d.label){case 0:if(!this.hasNext)return[3,6];d.label=1;case 1:return d.trys.push([1,3,,4]),a=this._nextValue,b=this,[4,this._forward()];case 2:return b._nextValue=d.sent()||null,this._prevValue=a,[3,4];case 3:return c=d.sent(),this._error=c,[3,4];case 4:return[4,this._iterator(this)];case 5:return[2,d.sent()];case 6:this._complete(),d.label=7;case 7:return[2]}})})},a.prototype.stop=function(){this._prevValue=null,this._nextValue=null,this._complete()},a}(),dl=function(){function a(a){var b=a.condition,c=a.backward,d=a.blockManager,e=a.indexer;this.condition=void 0===b?{}:b,this.backward=void 0!==c&&c,this._blockManager=d,this._indexer=e}return a.prototype.findOptimizedStartPosition=function(){var a=this,b=["=","/eq",">",">=","/gt","/gte"],c=["=","/eq","<","<=","/lt","/lte"];if(this.backward){var d=this._indexer.origin.length-1;if("function"!=typeof this.condition)for(m=0;m0?c:b;for(var h in this.condition[e])if(g.includes(h)){for(var i=d;i>=0;i--)if(f*c6(this._indexer.origin[i].columnValues[m],this.condition[e][h])<=0){d=i;break}}}else for(i=d;i>=0;i--)if(f*c6(this._indexer.origin[i].columnValues[m],this.condition[e])<=0){d=i;break}}}return Math.min(d+1,this._indexer.origin.length-1)}var j=0;if("function"!=typeof this.condition)for(var k=function(d){var e=l._indexer.fields[d],f=1;if("-"===e[0]&&(e=e.slice(1),f=-1),l.condition[e]){if("object"==typeof l.condition[e])Object.keys(l.condition[e]).forEach(function(g){if((f>0?b:c).includes(g)){for(var h=j;h=0){j=h;break}}});else for(var g=j;g=0){j=g;break}}},l=this,m=0;m -1){var d=this._items[c];return b===dg.PERSISTENT&&(d.state=df.PERSISTENT),b!==dg.NO_CACHE&&this.put(d),d}return null},a.prototype.put=function(a){var b,c;if(this._limit>0){var d=this._items.map(function(a){return a.key}).indexOf(a.key);if(d> -1)dy.includes(this._items[d].state)&&dy.includes(a.state)?(this._items.splice(d,1),this._items.push(a)):(this._items[d].state=a.state,this._items[d].value=a.value);else{this._items.push(a);var e=this._items.filter(function(a){return a.state===df.VOLATILE}).length-this._limit;if(e>0){var g=[];try{for(var h=(0,f.x)(this._items),i=h.next();!i.done;i=h.next()){var j=i.value;j.state===df.VOLATILE&&e>0?e--:g.push(j)}}catch(k){b={error:k}}finally{try{i&&!i.done&&(c=h.return)&&c.call(h)}finally{if(b)throw b.error}}this._items=g}}}},a.prototype.remove=function(a){var b=this._items.map(function(a){return a.key}).indexOf(a);b> -1&&this._items.splice(b,1)},a.prototype.clearByCondition=function(a){this._items=this._items.filter(function(b){return!a(b)})},a.prototype.clearForDatabase=function(a){this.clearByCondition(function(b){return b.key.startsWith(dn(a))})},a.prototype.clear=function(a){void 0===a&&(a=!1),this._items=a?[]:this._items.filter(function(a){return a.state!==df.VOLATILE})},a}(),dB=function(){function a(a){var b,c,d,e,f=a.dbname,g=a.collectionName,h=a.store;this._requests=[],this._onCommit=new Map,this._onWrite=new Map,this._onError=new Map,this.dbname=f,this.collectionName=g,this.metadataKey=(b=f,c=g,"".concat(dp(b,c),"/trans.metadata")),this.recordsetKey=(d=f,e=g,"".concat(dp(d,e),"/trans.recordset")),this._store=h}return Object.defineProperty(a.prototype,"generation",{get:function(){return this._metadata?this._metadata.generation:0},enumerable:!1,configurable:!0}),Object.defineProperty(a.prototype,"requestCount",{get:function(){return this._requests.length},enumerable:!1,configurable:!0}),a.prototype._getReducedRecordset=function(a){return void 0===a&&(a=[]),(0,f._)(this,void 0,void 0,function(){var b;return(0,f.b)(this,function(c){switch(c.label){case 0:return[4,this._store.get(this.recordsetKey)];case 1:return(b=c.sent()||[]).push.apply(b,(0,f.s)([],(0,f.t)(a),!1)),[2,this._reduceRecordSet(b)]}})})},a.prototype._reduceRecordSet=function(a){for(var b=[],c={},d=a.length-1;d>=0;d--){for(var e=a[d],f=[],g=e.requests.length-1;g>=0;g--){var h=e.requests[g],i=h.data;c[i.key]||(f.unshift(h),c[i.key]=!0)}f.length>0&&(e.requests=f,b.unshift(e))}return b},a.prototype._applyRecord=function(a,b){return(0,f._)(this,void 0,void 0,function(){var c,d,e,g,h,i,j,k,l;return(0,f.b)(this,function(m){switch(m.label){case 0:c=dA.get(this.dbname),d=b.generation,e=b.requests,g=null,m.label=1;case 1:return m.trys.push([1,3,,4]),[4,this._store.setMany(e.map(function(a){return(0,f.d)((0,f.d)({},a.data),{generation:d})}))];case 2:for(h=m.sent(),i=0;i0))return[3,4];for(b=[],c={},i=a.length-1;i>=0;i--)c[(k=(d=a[i]).data).key]||(c[k.key]=!0,b.unshift(d));return e={generation:this.generation,requests:b},[4,this._getReducedRecordset([e])];case 1:return g=o.sent(),[4,this._store.set({key:this.recordsetKey,value:g})];case 2:return o.sent(),this._metadata.generation++,[4,this._store.set({key:this.metadataKey,value:this._metadata})];case 3:for(o.sent(),h=dA.get(this.dbname),i=0;i0?(d=this.createBlockId(a,c),[4,b.find(this._store,d)]):[3,4];case 2:if((e=f.sent())&&(null==(g=dC.createFromCacheItem(e))?void 0:g.getItemByKey(a)))return[2,g];f.label=3;case 3:return c--,[3,1];case 4:return[2,null]}})})},a.prototype.getFromBlock=function(a){return(0,f._)(this,void 0,void 0,function(){var b;return(0,f.b)(this,function(c){switch(c.label){case 0:return[4,this._findBlock(a)];case 1:return[2,(b=c.sent())?b.getItemByKey(a):null]}})})},a.prototype.putToBlock=function(a,b){return(0,f._)(this,void 0,void 0,function(){var c,d,e,g,h;return(0,f.b)(this,function(f){switch(f.label){case 0:return c=c_.get(this.dbname),d=this.createBlockId(a),e=Math.floor(this._store.itemSizeLimit/c.itemSizeLimit),[4,dA.get(this.dbname).find(this._store,d)];case 1:return(null==(h=(g=f.sent())?dC.createFromCacheItem(g):new dC({blockId:d,keyName:this.keyName,items:[],limit:e}))?void 0:h.add(b))?(this._transaction.requestWrite({key:h.blockId,value:h.serialize()}),[2,!0]):[2,!1]}})})},a.prototype.removeFromBlock=function(a){return(0,f._)(this,void 0,void 0,function(){var b;return(0,f.b)(this,function(c){switch(c.label){case 0:return[4,this._findBlock(a)];case 1:return(b=c.sent())&&b.remove(a)?(this._transaction.requestWrite({key:b.blockId,value:b.serialize()}),[2,!0]):[2,!1]}})})},a.prototype.clearAllBlocks=function(){return(0,f._)(this,void 0,void 0,function(){var a,b,c;return(0,f.b)(this,function(d){switch(d.label){case 0:return a=dr(this.dbname,this.collectionName),[4,this._store.getAllKeys()];case 1:return c=(b=d.sent()).filter(function(b){return b.startsWith(a)}),[4,this._store.removeMany(c)];case 2:return d.sent(),[4,this._transaction.clear()];case 3:return d.sent(),dA.get(this.dbname).clearByCondition(function(b){return b.key.startsWith(a)}),[2]}})})},a}(),dE=function(){function a(a){var b,c,d,e=a.dbname,f=a.collectionName,g=a.keyName,h=a.fields,i=a.transaction,j=a.store,k=a.mutex,l=this;this._origin=[],this._table=[],this.restoreInterval=1e3;var m=(b=e,c=f,d=h.join(">"),"".concat(dp(b,c),"/index.").concat(d));this.dbname=e,this.collectionName=f,this.keyName=g,this.fields=h,this.indexerKey=m,this._store=j,this._transaction=i,this._transaction.on(de.COMMIT,this.indexerKey,function(){return l.commit()}),this._transaction.on(de.ERROR,this.indexerKey,function(){return l.abort()}),this._lastRestoreIndexerTime=0,this._isRestoringIndexer=!1,this._mutex=k}return a.createKey=function(a){return a.join(">")},a.parseKey=function(a){return a.split(">")},a.prototype._addItem=function(a){var b=a[this.keyName],c=this.getColumnValues(a),d=(0,f.t)(this.indexOf(c),2),e=d[0];return d[1]?!this._table[e].keys.includes(b)&&(this._table[e].keys.push(b),!0):(this._table.splice(e,0,{columnValues:c,keys:[b]}),!0)},a.prototype._removeItem=function(a){var b=a[this.keyName],c=this.getColumnValues(a),d=(0,f.t)(this.indexOf(c),2),e=d[0];if(d[1]){var g=this._table[e].keys.indexOf(b);if(g> -1)return this._table[e].keys.splice(g,1),0===this._table[e].keys.length&&this._table.splice(e,1),!0}return!1},Object.defineProperty(a.prototype,"origin",{get:function(){return this._origin},enumerable:!1,configurable:!0}),Object.defineProperty(a.prototype,"table",{get:function(){return this._table},enumerable:!1,configurable:!0}),a.prototype.getColumnValues=function(a){var b,c,d,e,g=[];try{for(var h=(0,f.x)(this.fields),i=h.next();!i.done;i=h.next()){var j=i.value;if("-"===j[0]&&(j=j.slice(1)),d=a[j],e=void 0,e=typeof d,null!==d&&"undefined"!==e&&"boolean"!==e&&"number"!==e&&"string"!==e)throw c2.indexTypesNotMatch;g.push(a[j])}}catch(k){b={error:k}}finally{try{i&&!i.done&&(c=h.return)&&c.call(h)}finally{if(b)throw b.error}}return g},a.prototype.diff=function(a,b){for(var c in this.fields){var d="-"===this.fields[c][0]?-1:1,e=c6(a[c],b[c]);if(0!==e)return d*e}return 0},a.prototype.indexOf=function(a){return this._indexOfInTable(this._table,a)},a.prototype._indexOfInTable=function(a,b){if(a.length>0){for(var c=0,d=a.length-1;c<=d;){var e=Math.floor((c+d)/2),f=this.diff(b,a[e].columnValues);if(f>0)c=e+1;else{if(!(f<0))return[e,!0];d=e-1}}return[c,!1]}return[0,!1]},a.prototype.ensure=function(){return(0,f._)(this,void 0,void 0,function(){var a,b,c,d,e,g,h,i,j,k,l,m,n,o,p,q,r;return(0,f.b)(this,function(s){switch(s.label){case 0:return[4,(a=dA.get(this.dbname)).find(this._store,this.indexerKey,dg.PERSISTENT)];case 1:return(b=s.sent())?[3,11]:(c=dr(this.dbname,this.collectionName),[4,this._store.getAllKeys()]);case 2:d=s.sent(),s.label=3;case 3:s.trys.push([3,8,9,10]),g=(e=(0,f.x)(d)).next(),s.label=4;case 4:return g.done?[3,7]:(h=g.value).startsWith(c)?[4,a.find(this._store,h,dg.NO_CACHE)]:[3,6];case 5:if(i=s.sent(),j=dC.createFromCacheItem(i))try{for(q=void 0,l=(k=(0,f.x)(j.items)).next();!l.done;l=k.next())m=l.value,this._addItem(m)}catch(t){q={error:t}}finally{try{l&&!l.done&&(r=k.return)&&r.call(k)}finally{if(q)throw q.error}}s.label=6;case 6:return g=e.next(),[3,4];case 7:return[3,10];case 8:return o={error:n=s.sent()},[3,10];case 9:try{g&&!g.done&&(p=e.return)&&p.call(e)}finally{if(o)throw o.error}return[7];case 10:return this._transaction.requestWrite({key:this.indexerKey,value:this._table},{persistent:!0}),[3,12];case 11:this._origin=b.value,this._table=c5(this._origin),s.label=12;case 12:return[2]}})})},a.prototype.restoreIndexer=function(){return(0,f._)(this,void 0,void 0,function(){var a,b,c,d,e,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z,A,B,C,D,E,F,G,H,I,J,K,L,M,N,O,P,Q,R;return(0,f.b)(this,function(S){switch(S.label){case 0:if(a=Date.now(),this._isRestoringIndexer||a-this._lastRestoreIndexerTimec._queue.findIndex(function(b){return b.requestId===a.requestId})&&c._requestLock({isNestDbMessage:!0,nodeId:a.nodeId,requestId:a.requestId,key:c.key,op:dv.REQUEST_LOCK,ts:a.ts})};try{for(var p=(0,f.x)(n),q=p.next();!q.done;q=p.next())o(q.value)}catch(r){b={error:r}}finally{try{q&&!q.done&&(d=p.return)&&d.call(p)}finally{if(b)throw b.error}}c._currentItem=c._queue.find(function(a){return a.requestId===m}),c._completeSync()}break;case dv.REMOVENODE:c._queue=c._queue.filter(function(a){return a.nodeId!==e.nodeId}),c._currentItem&&c._currentItem.nodeId===e.nodeId&&(c._currentItem=void 0,c._acquire(c._queue[0]));break;case dv.REQUEST_LOCK:c._requestLock(e);break;case dv.ACQUIRE_LOCK:var s=c._queue.find(function(a){return a.requestId===h});c._acquire(s);break;case dv.RELEASE_LOCK:c._release(h)}}}),window.addEventListener("beforeunload",function(){c._send(dv.REMOVENODE)})),dJ[a]=this),dJ[a]}return Object.defineProperty(a.prototype,"locked",{get:function(){return!!this._currentItem},enumerable:!1,configurable:!0}),Object.defineProperty(a.prototype,"isHost",{get:function(){return this._hostId===this.nodeId},enumerable:!1,configurable:!0}),Object.defineProperty(a.prototype,"isInSync",{get:function(){return this._state==du.DONE},enumerable:!1,configurable:!0}),a.prototype._send=function(a,b){void 0===b&&(b={});var c,d={isNestDbMessage:!0,nodeId:this.nodeId,requestId:null!==(c=null==b?void 0:b.requestId)&& void 0!==c?c:dG(),key:this.key,op:a,data:b.data,ts:Date.now()};return dF()&&window.postMessage(d,"*"),d},a.prototype._acquire=function(a){a?(this._currentItem=a,this._currentItem.onAcquired&&this._currentItem.onAcquired(a.requestId)):this._currentItem=void 0},a.prototype._release=function(a){if(this._currentItem&&this._currentItem.requestId===a){var b=this._currentItem;this._currentItem=void 0,b.nodeId===this.nodeId&&this._send(dv.RELEASE_LOCK,{requestId:b.requestId});var c=this._queue.findIndex(function(b){return b.requestId===a});c> -1&&this._queue.splice(c,1),b.onReleased&&b.onReleased(a)}},a.prototype._requestLock=function(a){var b=this;return new Promise(function(c){for(var d={nodeId:a.nodeId,requestId:a.requestId,ts:a.ts,onAcquired:function(a){b.isHost&&b._send(dv.ACQUIRE_LOCK,{requestId:a}),c()},onReleased:function(){b._acquire(b._queue[0])}},e=!1,f=0;fd.ts){b._queue.splice(f,0,d),e=!0;break}e||b._queue.push(d),b._currentItem||b._acquire(b._queue[0])})},a.prototype._sendSync=function(){var a;this.isHost&&this._send(dv.SYNC_HOST,{data:{currentItemRequestId:null===(a=this._currentItem)|| void 0===a?void 0:a.requestId,queue:this._queue.map(function(a){return{nodeId:a.nodeId,requestId:a.requestId,ts:a.ts}})}})},a.prototype._waitUntilSyncCompleted=function(){return(0,f._)(this,void 0,void 0,function(){var a=this;return(0,f.b)(this,function(b){return this.isHost&&!this.isInSync?[2,new Promise(function(b){a._activationQueue.push(b)})]:[2]})})},a.prototype._waitSync=function(){var a=this;this.isInSync||(this._activationTimeout=setTimeout(function(){a._completeSync()},8))},a.prototype._completeSync=function(){this.isInSync||(this._state=du.DONE,this._activationQueue.forEach(function(a){return a()}),this._activationQueue=[])},a.prototype.registerNode=function(){this._send(dv.NEWNODE),this._waitSync()},a.prototype.claimHost=function(){this._hostId=this.nodeId,this._send(dv.CLAIM_HOST),this._waitSync()},a.prototype.lock=function(){return(0,f._)(this,void 0,void 0,function(){var a;return(0,f.b)(this,function(b){switch(b.label){case 0:return[4,this._waitUntilSyncCompleted()];case 1:return b.sent(),a=this._send(dv.REQUEST_LOCK),[4,this._requestLock(a)];case 2:return b.sent(),[2]}})})},a.prototype.unlock=function(){var a;(null===(a=this._currentItem)|| void 0===a?void 0:a.requestId)&&this._release(this._currentItem.requestId)},a}(),dL=function(){function a(a){var b,c,d=a.dbname,e=a.collectionName,g=a.keyName,h=a.keyHash,i=a.indexes,j=a.store,k=this;this._state=c0.INIT,this._indexers=[],this.dbname=d,this.name=e,this.keyName=g,this.indexes=(0,f.s)([[g]],(0,f.t)(i.filter(function(a){return dE.createKey(a)!==k.keyName})),!1),this._keyHash=h,this._store=j,this._mutex=new dK((b=d,c=e,"".concat(dp(b,c),".lock"))),this._blobContainer=new dt({dbname:d,collectionName:e,store:j}),this._transaction=new dB({dbname:d,collectionName:e,store:j})}return a.metadataOf=function(a,b,c){return(0,f._)(this,void 0,void 0,function(){var d;return(0,f.b)(this,function(e){switch(e.label){case 0:return d=dq(a,b),[4,c.get(d)];case 1:return[2,e.sent()]}})})},Object.defineProperty(a.prototype,"state",{get:function(){return this._state},enumerable:!1,configurable:!0}),Object.defineProperty(a.prototype,"isReady",{get:function(){return this._state===c0.READY},enumerable:!1,configurable:!0}),a.prototype.init=function(){return(0,f._)(this,void 0,void 0,function(){var b,c,d,e,g,h,i,j,k,l,m,n,o,p,q=this;return(0,f.b)(this,function(r){switch(r.label){case 0:return[4,this._mutex.lock()];case 1:r.sent(),r.label=2;case 2:return r.trys.push([2,9,,10]),b=c_.get(this.dbname),[4,a.metadataOf(this.dbname,this.name,this._store)];case 3:return c=r.sent(),this._metadata=c||{keyName:this.keyName,blockLevel:1,blockHashBase:b.blockHashBase,blockHashMultiplier:b.blockHashMultiplier,blockHashConstant:b.blockHashConstant,indexes:this.indexes},[4,this._transaction.init()];case 4:r.sent(),this._blockManager=new dD({dbname:this.dbname,collectionName:this.name,hashFunction:this._keyHash,metadata:this._metadata,transaction:this._transaction,store:this._store}),d=(0,f.s)([],(0,f.t)(this.indexes),!1),e=[],g=d.map(function(a){return dE.createKey(a)}),h=c?c.indexes.map(function(a){return dE.createKey(a)}):[];try{for(j=(i=(0,f.x)(h)).next();!j.done;j=i.next())k=j.value,g.includes(k)||e.push(dE.parseKey(k))}catch(s){o={error:s}}finally{try{j&&!j.done&&(p=i.return)&&p.call(i)}finally{if(o)throw o.error}}return(l=[]).push.apply(l,(0,f.s)([],(0,f.t)(d.map(function(a){var b=new dE({dbname:q.dbname,collectionName:q.name,keyName:q.keyName,fields:a,transaction:q._transaction,store:q._store,mutex:q._mutex});return q._indexers.push(b),b.ensure()})),!1)),l.push.apply(l,(0,f.s)([],(0,f.t)(e.map(function(a){return new dE({dbname:q.dbname,collectionName:q.name,keyName:q.keyName,fields:a,transaction:q._transaction,store:q._store,mutex:q._mutex}).drop()})),!1)),[4,Promise.all(l)];case 5:return r.sent(),[4,this._transaction.commit()];case 6:return r.sent(),g.sort().join(",")===h.sort().join(",")?[3,8]:(m=dq(this.dbname,this.name),this._metadata.indexes=d,[4,this._store.set({key:m,value:this._metadata})]);case 7:r.sent(),r.label=8;case 8:return this._state=c0.READY,this._mutex.unlock(),[3,10];case 9:throw n=r.sent(),this._mutex.unlock(),n;case 10:return[2]}})})},a.prototype.close=function(){this._state=c0.CLOSED},a.prototype._hasPropertyOfKeyName=function(a){var b=a[this.keyName];return"string"==typeof b&&!!b},a.prototype._getIndexerBy=function(a){void 0===a&&(a=null),a||(a=[this.keyName]);var b,c,d=dE.createKey(a);try{for(var e=(0,f.x)(this._indexers),g=e.next();!g.done;g=e.next()){var h=g.value;if(d===dE.createKey(h.fields))return h}}catch(i){b={error:i}}finally{try{g&&!g.done&&(c=e.return)&&c.call(e)}finally{if(b)throw b.error}}throw c2.indexTableIsRequired},a.prototype._upgradeBlockLevel=function(){return(0,f._)(this,void 0,void 0,function(){var a;return(0,f.b)(this,function(b){switch(b.label){case 0:return a=dq(this.dbname,this.name),this._metadata.blockLevel++,[4,this._store.set({key:a,value:this._metadata})];case 1:return b.sent(),[2]}})})},a.prototype._requestInsert=function(a){return(0,f._)(this,void 0,void 0,function(){var b,c,d,e,g,h;return(0,f.b)(this,function(i){switch(i.label){case 0:return b=a[this.keyName],[4,this._blockManager.getFromBlock(b)];case 1:return i.sent()?[3,13]:[4,this._blockManager.putToBlock(b,a)];case 2:return i.sent()?[3,5]:[4,this._upgradeBlockLevel()];case 3:return i.sent(),[4,this._blockManager.putToBlock(b,a)];case 4:i.sent(),i.label=5;case 5:i.trys.push([5,10,11,12]),d=(c=(0,f.x)(this._indexers)).next(),i.label=6;case 6:return d.done?[3,9]:[4,d.value.addItem(a)];case 7:i.sent(),i.label=8;case 8:return d=c.next(),[3,6];case 9:return[3,12];case 10:return g={error:e=i.sent()},[3,12];case 11:try{d&&!d.done&&(h=c.return)&&h.call(c)}finally{if(g)throw g.error}return[7];case 12:return[3,14];case 13:throw c2.collectionInsertDuplicate;case 14:return[2]}})})},a.prototype._requestUpsert=function(a){return(0,f._)(this,void 0,void 0,function(){var b,c,d,e,g,h,i,j,k,l,m,n,o;return(0,f.b)(this,function(p){switch(p.label){case 0:return b=a[this.keyName],[4,this._blockManager.getFromBlock(b)];case 1:return(c=p.sent())?[3,13]:[4,this._blockManager.putToBlock(b,a)];case 2:return p.sent()?[3,5]:[4,this._upgradeBlockLevel()];case 3:return p.sent(),[4,this._blockManager.putToBlock(b,a)];case 4:p.sent(),p.label=5;case 5:p.trys.push([5,10,11,12]),e=(d=(0,f.x)(this._indexers)).next(),p.label=6;case 6:return e.done?[3,9]:[4,(j=e.value).addItem(a)];case 7:p.sent(),p.label=8;case 8:return e=d.next(),[3,6];case 9:return[3,12];case 10:return l={error:g=p.sent()},[3,12];case 11:try{e&&!e.done&&(m=d.return)&&m.call(d)}finally{if(l)throw l.error}return[7];case 12:return[3,23];case 13:return[4,this._blockManager.putToBlock(b,a)];case 14:p.sent(),p.label=15;case 15:p.trys.push([15,21,22,23]),i=(h=(0,f.x)(this._indexers)).next(),p.label=16;case 16:return i.done?[3,20]:0===(j=i.value).diff(j.getColumnValues(c),j.getColumnValues(a))?[3,19]:[4,j.removeItem(c)];case 17:return p.sent(),[4,j.addItem(a)];case 18:p.sent(),p.label=19;case 19:return i=h.next(),[3,16];case 20:return[3,23];case 21:return n={error:k=p.sent()},[3,23];case 22:try{i&&!i.done&&(o=h.return)&&o.call(h)}finally{if(n)throw n.error}return[7];case 23:return[2]}})})},a.prototype._requestUpdate=function(a){return(0,f._)(this,void 0,void 0,function(){var b,c,d,e,g,h,i,j;return(0,f.b)(this,function(k){switch(k.label){case 0:return b=a[this.keyName],[4,this._blockManager.getFromBlock(b)];case 1:return(c=k.sent())?[4,this._blockManager.putToBlock(b,a)]:[3,11];case 2:k.sent(),k.label=3;case 3:k.trys.push([3,9,10,11]),e=(d=(0,f.x)(this._indexers)).next(),k.label=4;case 4:return e.done?[3,8]:0===(g=e.value).diff(g.getColumnValues(c),g.getColumnValues(a))?[3,7]:[4,g.removeItem(c)];case 5:return k.sent(),[4,g.addItem(a)];case 6:k.sent(),k.label=7;case 7:return e=d.next(),[3,4];case 8:return[3,11];case 9:return i={error:h=k.sent()},[3,11];case 10:try{e&&!e.done&&(j=d.return)&&j.call(d)}finally{if(i)throw i.error}return[7];case 11:return[2]}})})},a.prototype._requestRemove=function(a){return(0,f._)(this,void 0,void 0,function(){var b,c,d,e,g,h;return(0,f.b)(this,function(i){switch(i.label){case 0:return[4,this._blockManager.getFromBlock(a)];case 1:return(b=i.sent())?[4,this._blockManager.removeFromBlock(a)]:[3,10];case 2:i.sent(),i.label=3;case 3:i.trys.push([3,8,9,10]),d=(c=(0,f.x)(this._indexers)).next(),i.label=4;case 4:return d.done?[3,7]:[4,d.value.removeItem(b)];case 5:i.sent(),i.label=6;case 6:return d=c.next(),[3,4];case 7:return[3,10];case 8:return g={error:e=i.sent()},[3,10];case 9:try{d&&!d.done&&(h=c.return)&&h.call(c)}finally{if(g)throw g.error}return[7];case 10:return[2]}})})},a.prototype._requestClear=function(){return(0,f._)(this,void 0,void 0,function(){var a,b,c,d,e;return(0,f.b)(this,function(g){switch(g.label){case 0:return[4,this._blockManager.clearAllBlocks()];case 1:g.sent(),g.label=2;case 2:g.trys.push([2,7,8,9]),b=(a=(0,f.x)(this._indexers)).next(),g.label=3;case 3:return b.done?[3,6]:[4,b.value.clear()];case 4:g.sent(),g.label=5;case 5:return b=a.next(),[3,3];case 6:return[3,9];case 7:return d={error:c=g.sent()},[3,9];case 8:try{b&&!b.done&&(e=a.return)&&e.call(a)}finally{if(d)throw d.error}return[7];case 9:return[2]}})})},a.prototype.getByKey=function(a){return(0,f._)(this,void 0,void 0,function(){var b,c;return(0,f.b)(this,function(d){switch(d.label){case 0:return this.isReady?[4,this._mutex.lock()]:[3,6];case 1:d.sent(),d.label=2;case 2:return d.trys.push([2,4,,5]),[4,this._blockManager.getFromBlock(a)];case 3:return b=d.sent(),this._mutex.unlock(),[2,c5(b)];case 4:throw c=d.sent(),this._mutex.unlock(),c;case 5:return[3,7];case 6:throw c2.collectionNotReady;case 7:return[2]}})})},a.prototype.query=function(a){if(void 0===a&&(a={}),this.isReady)return new dm({condition:a.where,mutex:this._mutex,blockManager:this._blockManager,indexer:this._getIndexerBy(a.index),backward:!!a.backward});throw c2.collectionNotReady},a.prototype.insertOne=function(a){return(0,f._)(this,void 0,void 0,function(){var b;return(0,f.b)(this,function(c){switch(c.label){case 0:return this.isReady?[4,this._mutex.lock()]:[3,8];case 1:c.sent(),c.label=2;case 2:if(c.trys.push([2,5,,7]),!this._hasPropertyOfKeyName(a))throw c2.collectionKeyNotGiven;return[4,this._requestInsert(c5(a))];case 3:return c.sent(),[4,this._transaction.commit()];case 4:return c.sent(),this._mutex.unlock(),[2,a];case 5:return b=c.sent(),[4,this._transaction.clear()];case 6:throw c.sent(),this._mutex.unlock(),b;case 7:return[3,9];case 8:throw c2.collectionNotReady;case 9:return[2]}})})},a.prototype.insertMany=function(a){return(0,f._)(this,void 0,void 0,function(){var b,c,d,e,g,h,i,j=this;return(0,f.b)(this,function(k){switch(k.label){case 0:return this.isReady?[4,this._mutex.lock()]:[3,15];case 1:k.sent(),k.label=2;case 2:if(k.trys.push([2,12,,14]),a.some(function(a){return!j._hasPropertyOfKeyName(a)}))throw c2.collectionKeyNotGiven;k.label=3;case 3:k.trys.push([3,8,9,10]),c=(b=(0,f.x)(a)).next(),k.label=4;case 4:return c.done?[3,7]:(d=c.value,[4,this._requestInsert(c5(d))]);case 5:k.sent(),k.label=6;case 6:return c=b.next(),[3,4];case 7:return[3,10];case 8:return h={error:e=k.sent()},[3,10];case 9:try{c&&!c.done&&(i=b.return)&&i.call(b)}finally{if(h)throw h.error}return[7];case 10:return[4,this._transaction.commit()];case 11:return k.sent(),this._mutex.unlock(),[2,a];case 12:return g=k.sent(),[4,this._transaction.clear()];case 13:throw k.sent(),this._mutex.unlock(),g;case 14:return[3,16];case 15:throw c2.collectionNotReady;case 16:return[2]}})})},a.prototype.upsertOne=function(a){return(0,f._)(this,void 0,void 0,function(){var b;return(0,f.b)(this,function(c){switch(c.label){case 0:return this.isReady?[4,this._mutex.lock()]:[3,8];case 1:c.sent(),c.label=2;case 2:if(c.trys.push([2,5,,7]),!this._hasPropertyOfKeyName(a))throw c2.collectionKeyNotGiven;return[4,this._requestUpsert(c5(a))];case 3:return c.sent(),[4,this._transaction.commit()];case 4:return c.sent(),this._mutex.unlock(),[2,a];case 5:return b=c.sent(),[4,this._transaction.clear()];case 6:throw c.sent(),this._mutex.unlock(),b;case 7:return[3,9];case 8:throw c2.collectionNotReady;case 9:return[2]}})})},a.prototype.upsertMany=function(a){return(0,f._)(this,void 0,void 0,function(){var b,c,d,e,g,h,i,j=this;return(0,f.b)(this,function(k){switch(k.label){case 0:return this.isReady?[4,this._mutex.lock()]:[3,15];case 1:k.sent(),k.label=2;case 2:if(k.trys.push([2,12,,14]),a.some(function(a){return!j._hasPropertyOfKeyName(a)}))throw c2.collectionKeyNotGiven;k.label=3;case 3:k.trys.push([3,8,9,10]),c=(b=(0,f.x)(a)).next(),k.label=4;case 4:return c.done?[3,7]:(d=c.value,[4,this._requestUpsert(c5(d))]);case 5:k.sent(),k.label=6;case 6:return c=b.next(),[3,4];case 7:return[3,10];case 8:return h={error:e=k.sent()},[3,10];case 9:try{c&&!c.done&&(i=b.return)&&i.call(b)}finally{if(h)throw h.error}return[7];case 10:return[4,this._transaction.commit()];case 11:return k.sent(),this._mutex.unlock(),[2,a];case 12:return g=k.sent(),[4,this._transaction.clear()];case 13:throw k.sent(),this._mutex.unlock(),g;case 14:return[3,16];case 15:throw c2.collectionNotReady;case 16:return[2]}})})},a.prototype.update=function(a){return(0,f._)(this,void 0,void 0,function(){var b;return(0,f.b)(this,function(c){switch(c.label){case 0:return this.isReady?[4,this._mutex.lock()]:[3,8];case 1:c.sent(),c.label=2;case 2:if(c.trys.push([2,5,,7]),!this._hasPropertyOfKeyName(a))throw c2.collectionKeyNotGiven;return[4,this._requestUpdate(c5(a))];case 3:return c.sent(),[4,this._transaction.commit()];case 4:return c.sent(),this._mutex.unlock(),[2,a];case 5:return b=c.sent(),[4,this._transaction.clear()];case 6:throw c.sent(),this._mutex.unlock(),b;case 7:return[3,9];case 8:throw c2.collectionNotReady;case 9:return[2]}})})},a.prototype.updateIf=function(a,b){return(0,f._)(this,void 0,void 0,function(){var c,d,e,g,h,i,j,k,l,m,n,o,p,q,r=this;return(0,f.b)(this,function(s){switch(s.label){case 0:return this.isReady?[4,this._mutex.lock()]:[3,16];case 1:s.sent(),s.label=2;case 2:return s.trys.push([2,13,,15]),d=void 0===(c=a.where)?{}:c,e=a.index,g=void 0===e?null:e,h=a.backward,i=void 0!==h&&h,j=[],[4,new dl({condition:d,blockManager:this._blockManager,backward:i,indexer:this._getIndexerBy(g)}).each(function(a){return(0,f._)(r,void 0,void 0,function(){var c;return(0,f.b)(this,function(e){if(a.error)throw a.stop(),a.error;return a.hasNext?(c9(d,c=a.nextValue)&&b.set&&("function"!=typeof b.set?Object.keys(b.set).forEach(function(a){var d;c[a]=null===(d=b.set)|| void 0===d?void 0:d[a]}):b.set(c),j.push(c)),a.next()):a.stop(),[2]})})})];case 3:s.sent(),s.label=4;case 4:s.trys.push([4,9,10,11]),l=(k=(0,f.x)(j)).next(),s.label=5;case 5:return l.done?[3,8]:(m=l.value,[4,this._requestUpdate(c5(m))]);case 6:s.sent(),s.label=7;case 7:return l=k.next(),[3,5];case 8:return[3,11];case 9:return p={error:n=s.sent()},[3,11];case 10:try{l&&!l.done&&(q=k.return)&&q.call(k)}finally{if(p)throw p.error}return[7];case 11:return[4,this._transaction.commit()];case 12:return s.sent(),this._mutex.unlock(),[2,j];case 13:return o=s.sent(),[4,this._transaction.clear()];case 14:throw s.sent(),this._mutex.unlock(),o;case 15:return[3,17];case 16:throw this._transaction.clear(),c2.collectionNotReady;case 17:return[2]}})})},a.prototype.remove=function(a){return(0,f._)(this,void 0,void 0,function(){var b;return(0,f.b)(this,function(c){switch(c.label){case 0:return this.isReady?[4,this._mutex.lock()]:[3,8];case 1:c.sent(),c.label=2;case 2:return c.trys.push([2,5,,7]),[4,this._requestRemove(a)];case 3:return c.sent(),[4,this._transaction.commit()];case 4:return c.sent(),this._mutex.unlock(),[3,7];case 5:return b=c.sent(),[4,this._transaction.clear()];case 6:throw c.sent(),this._mutex.unlock(),b;case 7:return[3,9];case 8:throw c2.collectionNotReady;case 9:return[2]}})})},a.prototype.removeIf=function(a){return(0,f._)(this,void 0,void 0,function(){var b,c,d,e,g,h,i,j,k,l,m,n,o,p,q=this;return(0,f.b)(this,function(r){switch(r.label){case 0:return this.isReady?[4,this._mutex.lock()]:[3,15];case 1:r.sent(),r.label=2;case 2:return r.trys.push([2,13,,14]),c=void 0===(b=a.where)?{}:b,d=a.index,e=void 0===d?null:d,g=a.backward,h=void 0!==g&&g,i=[],[4,new dl({condition:c,blockManager:this._blockManager,backward:h,indexer:this._getIndexerBy(e)}).each(function(a){return(0,f._)(q,void 0,void 0,function(){var b,d;return(0,f.b)(this,function(e){if(a.error)throw a.stop(),a.error;return a.hasNext?(c9(c,b=a.nextValue)&&(d=b[this.keyName],i.push(d)),a.next()):a.stop(),[2]})})})];case 3:r.sent(),r.label=4;case 4:r.trys.push([4,9,10,11]),k=(j=(0,f.x)(i)).next(),r.label=5;case 5:return k.done?[3,8]:(l=k.value,[4,this._requestRemove(l)]);case 6:r.sent(),r.label=7;case 7:return k=j.next(),[3,5];case 8:return[3,11];case 9:return o={error:m=r.sent()},[3,11];case 10:try{k&&!k.done&&(p=j.return)&&p.call(j)}finally{if(o)throw o.error}return[7];case 11:return[4,this._transaction.commit()];case 12:return r.sent(),this._mutex.unlock(),[2,i];case 13:throw n=r.sent(),this._mutex.unlock(),n;case 14:return[3,16];case 15:throw this._transaction.clear(),c2.collectionNotReady;case 16:return[2]}})})},a.prototype.clear=function(){return(0,f._)(this,void 0,void 0,function(){var a;return(0,f.b)(this,function(b){switch(b.label){case 0:return this.isReady?[4,this._mutex.lock()]:[3,8];case 1:b.sent(),b.label=2;case 2:return b.trys.push([2,5,,7]),[4,this._requestClear()];case 3:return b.sent(),[4,this._transaction.commit()];case 4:return b.sent(),this._mutex.unlock(),[3,7];case 5:return a=b.sent(),[4,this._transaction.clear()];case 6:throw b.sent(),this._mutex.unlock(),a;case 7:return[3,9];case 8:throw c2.collectionNotReady;case 9:return[2]}})})},a.prototype.getBlob=function(a){return(0,f._)(this,void 0,void 0,function(){return(0,f.b)(this,function(b){switch(b.label){case 0:return[4,this._blobContainer.get(a)];case 1:return[2,b.sent()]}})})},a.prototype.saveBlob=function(a,b){return(0,f._)(this,void 0,void 0,function(){return(0,f.b)(this,function(c){switch(c.label){case 0:return[4,this._blobContainer.save(a,b)];case 1:return[2,c.sent()]}})})},a.prototype.removeBlob=function(a){return(0,f._)(this,void 0,void 0,function(){return(0,f.b)(this,function(b){switch(b.label){case 0:return[4,this._blobContainer.remove(a)];case 1:return b.sent(),[2]}})})},a.prototype.removeAllBlobs=function(){return(0,f._)(this,void 0,void 0,function(){return(0,f.b)(this,function(a){switch(a.label){case 0:return[4,this._blobContainer.clear()];case 1:return a.sent(),[2]}})})},a}(),dM="[NESTDB]",dN=!0,dO=function(){function a(){}return a.off=function(){dN=!1},a.log=function(){for(var a=[],b=0;b=0;d--){var e=a[d];c.has(e.key)||(c.add(e.key),b.unshift(e))}return b},a.prototype._dedupeRemoveManyKeys=function(a){return(0,f.s)([],(0,f.t)(new Set(a)),!1)},a.prototype._calculateRawSize=function(a){return JSON.stringify(a).length},a.prototype._shardify=function(a){var b=this,c=a.key,d=a.value,e=JSON.stringify(this.encryption.encrypt(d)),f=Math.ceil(e.length/this.adjustedItemSizeLimit);return this._generateShardPostfixArray(f).map(function(a){var d={key:b._getRawKey(c,".".concat(a)),data:e.substring(a*b.adjustedItemSizeLimit,(a+1)*b.adjustedItemSizeLimit)};return 0===a&&(d.metadata={shards:f}),d})},a.prototype._getExistingShardInfo=function(a){var b,c;return(0,f._)(this,void 0,void 0,function(){var d,e,g,h,i;return(0,f.b)(this,function(f){switch(f.label){case 0:return[4,this._getRaw(this._getRawKey(a,".0"))];case 1:if(!(d=f.sent()))return[2,{size:0,shardCount:0}];e=null!==(c=null===(b=d.metadata)|| void 0===b?void 0:b.shards)&& void 0!==c?c:1,g=this._calculateRawSize(d),h=1,f.label=2;case 2:return h1?[4,Promise.all(this._generateShardPostfixArray(null==e?void 0:e.shards).map(function(b){return(0,f._)(i,void 0,void 0,function(){var c,e;return(0,f.b)(this,function(f){switch(f.label){case 0:return b>0?(c=this._getRawKey(a,".".concat(b)),[4,this._getRaw(c)]):[3,2];case 1:if(!(e=f.sent()))throw c2.storeBrokenIntegrity;return[2,e.data];case 2:return[2,d]}})})}))]:[3,4];case 3:return h=j.sent(),[3,5];case 4:h=[d],j.label=5;case 5:return g=h,[2,this.encryption.decrypt(JSON.parse(g.join("")))];case 6:return j.sent(),[2,null];case 7:return[2,null]}})})},a.prototype.set=function(a){return(0,f._)(this,void 0,void 0,function(){var b=this;return(0,f.b)(this,function(c){switch(c.label){case 0:return[4,this._withUsageLock(function(){return(0,f._)(b,void 0,void 0,function(){var b,c,d,e,g,h,i,j=this;return(0,f.b)(this,function(k){switch(k.label){case 0:return(d=b=this._shouldAffectUsage(a.key))?[4,this._hasUsageCounterLocked()]:[3,2];case 1:d=k.sent(),k.label=2;case 2:return(c=d)?[4,this._getExistingShardInfo(a.key)]:[3,4];case 3:return g=k.sent(),[3,5];case 4:g={size:0,shardCount:0},k.label=5;case 5:return e=g,h=this._shardify(a),[4,this._setRaw(h)];case 6:return k.sent(),e.shardCount>h.length?[4,this._cleanupOrphanShards(a.key,h.length,e.shardCount)]:[3,8];case 7:k.sent(),k.label=8;case 8:return c?(i=h.reduce(function(a,b){return a+j._calculateRawSize(b)},0),[4,this._applyUsageDeltaLocked(i-e.size)]):[3,10];case 9:k.sent(),k.label=10;case 10:return[2,(0,f.d)({},a.value)]}})})})];case 1:return[2,c.sent()]}})})},a.prototype.setMany=function(a){return(0,f._)(this,void 0,void 0,function(){var b=this;return(0,f.b)(this,function(c){switch(c.label){case 0:return[4,this._withUsageLock(function(){return(0,f._)(b,void 0,void 0,function(){var b,c,d,e,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y=this;return(0,f.b)(this,function(z){switch(z.label){case 0:return b=this._dedupeSetManyItems(a),c=0,d=[],e=[],[4,this._hasUsageCounterLocked()];case 1:g=z.sent(),z.label=2;case 2:z.trys.push([2,9,10,11]),i=(h=(0,f.x)(b)).next(),z.label=3;case 3:return i.done?[3,8]:(j=i.value,(k=this._shouldAffectUsage(j.key)&&g)?[4,this._getExistingShardInfo(j.key)]:[3,5]);case 4:return m=z.sent(),[3,6];case 5:m={size:0,shardCount:0},z.label=6;case 6:l=m,n=this._shardify(j),d.push.apply(d,(0,f.s)([],(0,f.t)(n),!1)),k&&(l.shardCount>n.length&&e.push({key:j.key,newCount:n.length,oldCount:l.shardCount}),c+=(o=n.reduce(function(a,b){return a+y._calculateRawSize(b)},0))-l.size),z.label=7;case 7:return i=h.next(),[3,3];case 8:return[3,11];case 9:return u={error:p=z.sent()},[3,11];case 10:try{i&&!i.done&&(v=h.return)&&v.call(h)}finally{if(u)throw u.error}return[7];case 11:return[4,this._setRaw(d)];case 12:z.sent(),z.label=13;case 13:z.trys.push([13,18,19,20]),r=(q=(0,f.x)(e)).next(),z.label=14;case 14:return r.done?[3,17]:(s=r.value,[4,this._cleanupOrphanShards(s.key,s.newCount,s.oldCount)]);case 15:z.sent(),z.label=16;case 16:return r=q.next(),[3,14];case 17:return[3,20];case 18:return w={error:t=z.sent()},[3,20];case 19:try{r&&!r.done&&(x=q.return)&&x.call(q)}finally{if(w)throw w.error}return[7];case 20:return g?[4,this._applyUsageDeltaLocked(c)]:[3,22];case 21:z.sent(),z.label=22;case 22:return[2,a.map(function(a){return a.value})]}})})})];case 1:return[2,c.sent()]}})})},a.prototype.remove=function(a){return(0,f._)(this,void 0,void 0,function(){var b=this;return(0,f.b)(this,function(c){switch(c.label){case 0:return[4,this._withUsageLock(function(){return(0,f._)(b,void 0,void 0,function(){var b,c,d,e,g;return(0,f.b)(this,function(f){switch(f.label){case 0:return[4,this._hasUsageCounterLocked()];case 1:return b=f.sent(),[4,this._getExistingShardInfo(a)];case 2:return d=(c=f.sent()).size,0===(e=c.shardCount)?[2,!1]:[4,this._removeRaw(this._getShardKeys(a,e))];case 3:return f.sent(),null==(g=dA.get(this.dbname))||g.remove(a),b&&this._shouldAffectUsage(a)?[4,this._applyUsageDeltaLocked(-d)]:[3,5];case 4:f.sent(),f.label=5;case 5:return[2,!0]}})})})];case 1:return[2,c.sent()]}})})},a.prototype.removeMany=function(a){return(0,f._)(this,void 0,void 0,function(){var b=this;return(0,f.b)(this,function(c){switch(c.label){case 0:return[4,this._withUsageLock(function(){return(0,f._)(b,void 0,void 0,function(){var b,c,d,e,g,h,i,j,k,l,m,n,o,p;return(0,f.b)(this,function(q){switch(q.label){case 0:return b=this._dedupeRemoveManyKeys(a),c=dA.get(this.dbname),d=[],e=0,[4,this._hasUsageCounterLocked()];case 1:g=q.sent(),q.label=2;case 2:q.trys.push([2,7,8,9]),i=(h=(0,f.x)(b)).next(),q.label=3;case 3:return i.done?[3,6]:(j=i.value,[4,this._getExistingShardInfo(j)]);case 4:l=(k=q.sent()).size,(m=k.shardCount)>0&&(d.push.apply(d,(0,f.s)([],(0,f.t)(this._getShardKeys(j,m)),!1)),g&&this._shouldAffectUsage(j)&&(e-=l)),null==c||c.remove(j),q.label=5;case 5:return i=h.next(),[3,3];case 6:return[3,9];case 7:return o={error:n=q.sent()},[3,9];case 8:try{i&&!i.done&&(p=h.return)&&p.call(h)}finally{if(o)throw o.error}return[7];case 9:return d.length>0?[4,this._removeRaw(d)]:[3,11];case 10:q.sent(),q.label=11;case 11:return g?[4,this._applyUsageDeltaLocked(e)]:[3,13];case 12:q.sent(),q.label=13;case 13:return[2,a]}})})})];case 1:return[2,c.sent()]}})})},a.prototype.clear=function(){return(0,f._)(this,void 0,void 0,function(){var a;return(0,f.b)(this,function(b){return null==(a=dA.get(this.dbname))||a.clearForDatabase(this.dbname),[2]})})},a.prototype.trim=function(){},a}(),dR={},dS=function(a){function b(b){void 0===b&&(b={});var c,d=this;d=a.call(this,(0,f.d)((0,f.d)({},b),{itemSizeLimit:null!==(c=b.itemSizeLimit)&& void 0!==c?c:4194304}))||this;var e=b.delay;return d.delay=void 0===e?1:e,d.observer={},d}return(0,f.c)(b,a),Object.defineProperty(b.prototype,"rawData",{get:function(){return dR[this.dbname]},set:function(a){dR[this.dbname]=a},enumerable:!1,configurable:!0}),b.prototype._getAllRawKeys=function(){return(0,f._)(this,void 0,void 0,function(){return(0,f.b)(this,function(a){if(dR[this.dbname])return[2,Object.keys(dR[this.dbname])];throw c2.storeNotAvailable})})},b.prototype._getRaw=function(a){return(0,f._)(this,void 0,void 0,function(){return(0,f.b)(this,function(b){switch(b.label){case 0:return dR[this.dbname]?[4,c8(this.delay)]:[3,2];case 1:return b.sent(),[2,dR[this.dbname][a]?(0,f.d)({key:a},dR[this.dbname][a]):null];case 2:throw c2.storeNotAvailable}})})},b.prototype._setRaw=function(a){return(0,f._)(this,void 0,void 0,function(){var b,c,d,e,g,h,i,j;return(0,f.b)(this,function(k){switch(k.label){case 0:return dR[this.dbname]?[4,c8(this.delay)]:[3,2];case 1:k.sent();try{for(c=(b=(0,f.x)(a)).next();!c.done;c=b.next())e=(d=c.value).key,g=d.data,h=d.metadata,dR[this.dbname][e]=Object.freeze({data:g,metadata:h})}catch(l){i={error:l}}finally{try{c&&!c.done&&(j=b.return)&&j.call(b)}finally{if(i)throw i.error}}return[3,3];case 2:throw c2.storeNotAvailable;case 3:return[2]}})})},b.prototype._removeRaw=function(a){return(0,f._)(this,void 0,void 0,function(){var b,c,d,e,g;return(0,f.b)(this,function(h){switch(h.label){case 0:return dR[this.dbname]?[4,c8(this.delay)]:[3,2];case 1:h.sent();try{for(c=(b=(0,f.x)(a)).next();!c.done;c=b.next())d=c.value,dR[this.dbname][d]&&delete dR[this.dbname][d]}catch(i){e={error:i}}finally{try{c&&!c.done&&(g=b.return)&&g.call(b)}finally{if(e)throw e.error}}return[3,3];case 2:throw c2.storeNotAvailable;case 3:return[2]}})})},b.prototype.observe=function(a,b,c){var d=this;this.observer[a]||(this.observer[a]={}),b.forEach(function(b){return d.observer[a][b]=c})},b.prototype.checkAvailability=function(){return(0,f._)(this,void 0,void 0,function(){return(0,f.b)(this,function(a){return[2]})})},b.prototype.init=function(a){return(0,f._)(this,void 0,void 0,function(){return(0,f.b)(this,function(b){switch(b.label){case 0:return this.dbname=a,dR[this.dbname]||(dR[this.dbname]={}),[4,this._resetIfEncryptionChanged()];case 1:return b.sent(),[2]}})})},b.prototype.set=function(b){return(0,f._)(this,void 0,void 0,function(){var c,d;return(0,f.b)(this,function(e){if((c=this.observer[b.key])&&"function"==typeof c.set&&(d=c.set()))throw d;return[2,a.prototype.set.call(this,b)]})})},b.prototype.setMany=function(b){return(0,f._)(this,void 0,void 0,function(){var c,d,e,g,h,i,j;return(0,f.b)(this,function(k){try{for(d=(c=(0,f.x)(b)).next();!d.done;d=c.next())if(e=d.value,(g=this.observer[e.key])&&"function"==typeof g.set&&(h=g.set()))throw h}catch(l){i={error:l}}finally{try{d&&!d.done&&(j=c.return)&&j.call(c)}finally{if(i)throw i.error}}return[2,a.prototype.setMany.call(this,b)]})})},b.prototype.clear=function(){return(0,f._)(this,void 0,void 0,function(){var b=this;return(0,f.b)(this,function(c){switch(c.label){case 0:return[4,this._withUsageLock(function(){return(0,f._)(b,void 0,void 0,function(){return(0,f.b)(this,function(b){switch(b.label){case 0:return[4,a.prototype.clear.call(this)];case 1:return b.sent(),[4,c8(this.delay)];case 2:return b.sent(),dR[this.dbname]={},[2]}})})})];case 1:return c.sent(),[2]}})})},b}(dQ),dT="NestDBStore";(dI=dH||(dH={}))[dI.UNINITIALIZED=0]="UNINITIALIZED",dI[dI.OPENING=1]="OPENING",dI[dI.OPEN=2]="OPEN",dI[dI.CLOSED=3]="CLOSED";var dU,dV=function(a){function b(b){void 0===b&&(b={});var c,d=this;return(d=a.call(this,(0,f.d)((0,f.d)({},b),{itemSizeLimit:null!==(c=b.itemSizeLimit)&& void 0!==c?c:104857600}))||this)._storeName=dT,d._state=dH.UNINITIALIZED,d._openJobQueue=[],d._window="undefined"!=typeof window?window:void 0,d._indexedDb=d._window?d._window.indexedDB||d._window.mozIndexedDB||d._window.webkitIndexedDB||d._window.msIndexedDB:void 0,d}return(0,f.c)(b,a),Object.defineProperty(b.prototype,"state",{get:function(){return this._state},enumerable:!1,configurable:!0}),b.prototype.isTransactionInactiveError=function(a){return a instanceof Error&&a.message.includes("The transaction is inactive")},b.prototype._putToObjectStore=function(a,b){return(0,f._)(this,void 0,void 0,function(){return(0,f.b)(this,function(c){return[2,new Promise(function(c,d){var e=a.put(b);e.addEventListener("success",function(a){c(a.target.result)}),e.addEventListener("error",function(a){d(a.target.error)})})]})})},b.prototype._deleteFromObjectStore=function(a,b){return(0,f._)(this,void 0,void 0,function(){return(0,f.b)(this,function(c){return[2,new Promise(function(c,d){var e=a.delete(b);e.addEventListener("success",function(){return c(b)}),e.addEventListener("error",function(a){return d(a.target.error)})})]})})},b.prototype._openDatabase=function(a){var b=this;return new Promise(function(c,d){if(b._indexedDb){b._state=dH.OPENING;var e=b._indexedDb.open(a);e.addEventListener("upgradeneeded",function(a){a.target.result.createObjectStore(dT,{keyPath:"key"})}),e.addEventListener("success",function(d){b._state=dH.OPEN,b._database=d.target.result,b._openJobQueue.forEach(function(a){return a()}),b._openJobQueue=[],b._database.onclose=function(){b._database=void 0,b._state=dH.OPENING,setTimeout(function(){b._openDatabase(a)},5)},c(b._database)}),e.addEventListener("error",function(a){b._state=dH.UNINITIALIZED,d(a.target.error)})}else d(c2.storeNotAvailable)})},b.prototype._getObjectStore=function(a){return(0,f._)(this,void 0,void 0,function(){var b,c=this;return(0,f.b)(this,function(d){switch(d.label){case 0:return this._database?((b=this._database.transaction(this._storeName,a)).addEventListener("abort",function(a){throw a.target.error}),[2,b.objectStore(this._storeName)]):[3,1];case 1:switch(this._state){case dH.UNINITIALIZED:case dH.OPEN:return[3,2];case dH.OPENING:case dH.CLOSED:return[3,3]}return[3,4];case 2:throw c2.storeNotInitialized;case 3:return[2,new Promise(function(b){c._openJobQueue.push(function(){return b(c._getObjectStore(a))})})];case 4:return[4,this._getObjectStore(a)];case 5:return[2,d.sent()]}})})},b.prototype._getAllRawKeys=function(){return(0,f._)(this,void 0,void 0,function(){var a=this;return(0,f.b)(this,function(b){switch(b.label){case 0:return[4,new Promise(function(b,c){return(0,f._)(a,void 0,void 0,function(){var a,d;return(0,f.b)(this,function(e){switch(e.label){case 0:return[4,this._getObjectStore("readonly")];case 1:return(d=(a=e.sent()).getAllKeys()).addEventListener("success",function(a){b(a.target.result)}),d.addEventListener("error",function(a){return c(a.target.error)}),[2]}})})})];case 1:return[2,b.sent()]}})})},b.prototype._getRaw=function(a){return(0,f._)(this,void 0,void 0,function(){var b=this;return(0,f.b)(this,function(c){switch(c.label){case 0:return[4,new Promise(function(c,d){return(0,f._)(b,void 0,void 0,function(){var b,e;return(0,f.b)(this,function(f){switch(f.label){case 0:return[4,this._getObjectStore("readonly")];case 1:return(e=(b=f.sent()).get(a)).addEventListener("success",function(a){var b;c(null===(b=null==a?void 0:a.target)|| void 0===b?void 0:b.result)}),e.addEventListener("error",function(a){return d(a.target.error)}),[2]}})})})];case 1:return[2,c.sent()]}})})},b.prototype._setRaw=function(a){return(0,f._)(this,void 0,void 0,function(){var b,c,d,e,g,h,i,j,k,l=this;return(0,f.b)(this,function(m){switch(m.label){case 0:return m.trys.push([0,3,,15]),[4,this._getObjectStore("readwrite")];case 1:return b=m.sent(),[4,Promise.all(a.map(function(a){return l._putToObjectStore(b,a)}))];case 2:return m.sent(),[3,15];case 3:return c=m.sent(),this.isTransactionInactiveError(c)?[4,this._getObjectStore("readwrite")]:[3,13];case 4:d=m.sent(),m.label=5;case 5:m.trys.push([5,10,11,12]),g=(e=(0,f.x)(a)).next(),m.label=6;case 6:return g.done?[3,9]:(h=g.value,[4,this._putToObjectStore(d,h)]);case 7:m.sent(),m.label=8;case 8:return g=e.next(),[3,6];case 9:return[3,12];case 10:return j={error:i=m.sent()},[3,12];case 11:try{g&&!g.done&&(k=e.return)&&k.call(e)}finally{if(j)throw j.error}return[7];case 12:return[3,14];case 13:throw c;case 14:return[3,15];case 15:return[2]}})})},b.prototype._removeRaw=function(a){return(0,f._)(this,void 0,void 0,function(){var b,c,d,e,g,h,i,j,k,l=this;return(0,f.b)(this,function(m){switch(m.label){case 0:return m.trys.push([0,3,,15]),[4,this._getObjectStore("readwrite")];case 1:return b=m.sent(),[4,Promise.all(a.map(function(a){return l._deleteFromObjectStore(b,a)}))];case 2:return m.sent(),[3,15];case 3:return c=m.sent(),this.isTransactionInactiveError(c)?[4,this._getObjectStore("readwrite")]:[3,13];case 4:d=m.sent(),m.label=5;case 5:m.trys.push([5,10,11,12]),g=(e=(0,f.x)(a)).next(),m.label=6;case 6:return g.done?[3,9]:(h=g.value,[4,this._deleteFromObjectStore(d,h)]);case 7:m.sent(),m.label=8;case 8:return g=e.next(),[3,6];case 9:return[3,12];case 10:return j={error:i=m.sent()},[3,12];case 11:try{g&&!g.done&&(k=e.return)&&k.call(e)}finally{if(j)throw j.error}return[7];case 12:return[3,14];case 13:throw c;case 14:return[3,15];case 15:return[2]}})})},b.prototype._triggerDatabaseClose=function(){this._database&&this._database.onclose&&this._database.onclose(new Event("dummy"))},b.prototype.checkAvailability=function(){return(0,f._)(this,void 0,void 0,function(){var a,b=this;return(0,f.b)(this,function(c){switch(c.label){case 0:if(!((null==(a="undefined"!=typeof window?window:null)?void 0:a.indexedDB)||(null==a?void 0:a.mozIndexedDB)||(null==a?void 0:a.webkitIndexedDB)||(null==a?void 0:a.msIndexedDB)))return[3,6];if(this._indexedDb=a.indexedDB||a.mozIndexedDB||a.webkitIndexedDB||a.msIndexedDB,!this._window||!dF())return[3,4];if(!(dF()&&navigator.userAgent&&navigator.userAgent.includes("Edge/")))return[3,1];if(!this._window.indexedDB&&(a.PointerEvent||a.MSPointerEvent))throw c2.storeNotAvailableInPrivateBrowsing;return[3,3];case 1:return[4,new Promise(function(a,c){if(b._indexedDb)try{var d=b._indexedDb.open("_testMozilla");d.onerror=function(){return c(c2.storeNotAvailableInPrivateBrowsing)},d.onsuccess=function(d){if(d.target.result.close(),b._indexedDb){var e=b._indexedDb.deleteDatabase("_testMozilla");e.onerror=function(){return a()},e.onsuccess=function(){return a()}}else c(c2.storeNotAvailable)}}catch(e){c(c2.storeNotAvailableInPrivateBrowsing)}else c(c2.storeNotAvailable)})];case 2:c.sent(),c.label=3;case 3:return[3,5];case 4:case 6:throw c2.storeNotAvailable;case 5:return[3,7];case 7:return[2]}})})},b.prototype.init=function(a){return(0,f._)(this,void 0,void 0,function(){return(0,f.b)(this,function(b){switch(b.label){case 0:return this.dbname=a,[4,this.checkAvailability()];case 1:return b.sent(),[4,this._openDatabase(a)];case 2:return b.sent(),[4,this._resetIfEncryptionChanged()];case 3:return b.sent(),[2]}})})},b.prototype.clear=function(){return(0,f._)(this,void 0,void 0,function(){var b=this;return(0,f.b)(this,function(c){switch(c.label){case 0:return[4,this._withUsageLock(function(){return(0,f._)(b,void 0,void 0,function(){var b=this;return(0,f.b)(this,function(c){switch(c.label){case 0:return[4,a.prototype.clear.call(this)];case 1:return c.sent(),[4,new Promise(function(a,c){return(0,f._)(b,void 0,void 0,function(){var b,d;return(0,f.b)(this,function(e){switch(e.label){case 0:return[4,this._getObjectStore("readwrite")];case 1:return(d=(b=e.sent()).clear()).addEventListener("success",function(){return a(void 0)}),d.addEventListener("error",function(a){return c(a.target.error)}),[2]}})})})];case 2:return c.sent(),[2]}})})})];case 1:return c.sent(),[2]}})})},b}(dQ),dW=function(a){function b(b){var c=this,d=b.AsyncStorage,e=b.itemSizeLimit,g=(0,f.b8)(b,["AsyncStorage","itemSizeLimit"]);return(c=a.call(this,(0,f.d)((0,f.d)({},g),{itemSizeLimit:void 0===e?2097152:e}))||this)._asyncStorage=d,c}return(0,f.c)(b,a),b.prototype._isBelonging=function(a){return a.startsWith("".concat(this.dbname,"/"))},b.prototype._getActualKey=function(a){return"".concat(this.dbname,"/").concat(a)},b.prototype._getAllRawKeys=function(){return(0,f._)(this,void 0,void 0,function(){var a,b=this;return(0,f.b)(this,function(c){switch(c.label){case 0:return[4,this._asyncStorage.getAllKeys()];case 1:return[2,(a=c.sent()).filter(function(a){return b._isBelonging(a)}).map(function(a){return a.substring("".concat(b.dbname,"/").length)})]}})})},b.prototype._getRaw=function(a){return(0,f._)(this,void 0,void 0,function(){var b;return(0,f.b)(this,function(c){switch(c.label){case 0:return[4,this._asyncStorage.getItem(this._getActualKey(a))];case 1:return[2,(b=c.sent())?JSON.parse(b):null]}})})},b.prototype._setRaw=function(a){return(0,f._)(this,void 0,void 0,function(){var b,c,d,e,g,h,i;return(0,f.b)(this,function(j){switch(j.label){case 0:b=[];try{for(d=(c=(0,f.x)(a)).next();!d.done;d=c.next())g=(e=d.value).key,e.data.length<=this.adjustedItemSizeLimit&&b.push([this._getActualKey(g),JSON.stringify(e)])}catch(k){h={error:k}}finally{try{d&&!d.done&&(i=c.return)&&i.call(c)}finally{if(h)throw h.error}}return[4,this._asyncStorage.multiSet(b)];case 1:return j.sent(),[2]}})})},b.prototype._removeRaw=function(a){return(0,f._)(this,void 0,void 0,function(){var b=this;return(0,f.b)(this,function(c){switch(c.label){case 0:return[4,this._asyncStorage.multiRemove(a.map(function(a){return b._getActualKey(a)}))];case 1:return c.sent(),[2]}})})},b.prototype.checkAvailability=function(){return(0,f._)(this,void 0,void 0,function(){return(0,f.b)(this,function(a){if(!this._asyncStorage)throw c2.storeNotAvailable;return[2]})})},b.prototype.init=function(a){return(0,f._)(this,void 0,void 0,function(){return(0,f.b)(this,function(b){switch(b.label){case 0:return this.dbname=a,[4,this._resetIfEncryptionChanged()];case 1:return b.sent(),[2]}})})},b.prototype.clear=function(){return(0,f._)(this,void 0,void 0,function(){var b=this;return(0,f.b)(this,function(c){switch(c.label){case 0:return[4,this._withUsageLock(function(){return(0,f._)(b,void 0,void 0,function(){var b;return(0,f.b)(this,function(c){switch(c.label){case 0:return[4,a.prototype.clear.call(this)];case 1:return c.sent(),[4,this._getAllRawKeys()];case 2:return b=c.sent(),[4,this._removeRaw(b)];case 3:return c.sent(),[2]}})})})];case 1:return c.sent(),[2]}})})},b}(dQ),dX=function(a){function b(b){var c,d,e=this;return(e=a.call(this,(0,f.d)((0,f.d)({},b),{itemSizeLimit:null!==(c=b.itemSizeLimit)&& void 0!==c?c:6291456}))||this)._mmkv=(d=b.MMKV,{getString:function(a){return d.getString(a)},set:function(a,b){return d.set(a,b)},delete:function(a){return d.remove?d.remove(a):d.delete(a)},getAllKeys:function(){return d.getAllKeys()},clearAll:function(){var a;return null===(a=d.clearAll)|| void 0===a?void 0:a.call(d)},trim:function(){if(d.trim)return d.trim()}}),e}return(0,f.c)(b,a),b.prototype._isBelonging=function(a){return a.startsWith("".concat(this.dbname,"/"))},b.prototype._getActualKey=function(a){return"".concat(this.dbname,"/").concat(a)},b.prototype._getAllRawKeys=function(){return(0,f._)(this,void 0,void 0,function(){var a,b=this;return(0,f.b)(this,function(c){switch(c.label){case 0:return[4,this._mmkv.getAllKeys()];case 1:return[2,(a=c.sent()).filter(function(a){return b._isBelonging(a)}).map(function(a){return a.substring("".concat(b.dbname,"/").length)})]}})})},b.prototype._getRaw=function(a){return(0,f._)(this,void 0,void 0,function(){var b;return(0,f.b)(this,function(c){switch(c.label){case 0:return[4,this._mmkv.getString(this._getActualKey(a))];case 1:return[2,(b=c.sent())?JSON.parse(b):null]}})})},b.prototype._setRaw=function(a){return(0,f._)(this,void 0,void 0,function(){var b,c,d,e,g,h;return(0,f.b)(this,function(i){try{for(c=(b=(0,f.x)(a)).next();!c.done;c=b.next())e=(d=c.value).key,d.data.length<=this.adjustedItemSizeLimit&&this._mmkv.set(this._getActualKey(e),JSON.stringify(d))}catch(j){g={error:j}}finally{try{c&&!c.done&&(h=b.return)&&h.call(b)}finally{if(g)throw g.error}}return[2]})})},b.prototype._removeRaw=function(a){return(0,f._)(this,void 0,void 0,function(){var b,c,d,e,g;return(0,f.b)(this,function(h){try{for(c=(b=(0,f.x)(a)).next();!c.done;c=b.next())d=c.value,this._mmkv.delete(this._getActualKey(d))}catch(i){e={error:i}}finally{try{c&&!c.done&&(g=b.return)&&g.call(b)}finally{if(e)throw e.error}}return[2]})})},b.prototype.checkAvailability=function(){return(0,f._)(this,void 0,void 0,function(){return(0,f.b)(this,function(a){if(!this._mmkv)throw c2.storeNotAvailable;return[2]})})},b.prototype.init=function(a){return(0,f._)(this,void 0,void 0,function(){return(0,f.b)(this,function(b){switch(b.label){case 0:return this.dbname=a,[4,this._resetIfEncryptionChanged()];case 1:return b.sent(),[2]}})})},b.prototype.clear=function(){return(0,f._)(this,void 0,void 0,function(){var b=this;return(0,f.b)(this,function(c){switch(c.label){case 0:return[4,this._withUsageLock(function(){return(0,f._)(b,void 0,void 0,function(){var b;return(0,f.b)(this,function(c){switch(c.label){case 0:return[4,a.prototype.clear.call(this)];case 1:return c.sent(),[4,this._getAllRawKeys()];case 2:return b=c.sent(),[4,this._removeRaw(b)];case 3:return c.sent(),this.trim(),[2]}})})})];case 1:return c.sent(),[2]}})})},b.prototype.resetStorage=function(){var a;null===(a=this._mmkv)|| void 0===a||a.clearAll()},b.prototype.trim=function(){var a;null===(a=this._mmkv)|| void 0===a||a.trim()},b}(dQ);(dU=dY||(dY={})).INIT="INIT",dU.OPENING="OPENING",dU.OPENED="OPENED",dU.CLOSED="CLOSED";var dY,dZ,d$,d_=function(){function a(a){var b=a.name,c=a.version,d=a.store,e=a.config;this.name=b,this._version=c,this._state=dY.INIT,this._config=e||new c_({dbname:b}),this._store=d,this._event={success:da,error:da,storeReplaced:da,upgrade:dd},this._collections=new Map,this._globalMutex=new dK("".concat(this.name,".lock")),this._config.disableLogger&&dO.off(),new dA({dbname:b,limit:this._config.cacheLimit})}return Object.defineProperty(a.prototype,"version",{get:function(){return this._version},enumerable:!1,configurable:!0}),Object.defineProperty(a.prototype,"state",{get:function(){return this._state},enumerable:!1,configurable:!0}),Object.defineProperty(a.prototype,"store",{get:function(){return this._store},enumerable:!1,configurable:!0}),a.prototype._initializeCollection=function(a,b){var c;return(0,f._)(this,void 0,void 0,function(){var d,e,g;return(0,f.b)(this,function(f){switch(f.label){case 0:return e=this._collections.get(a),b?(d=new dL({dbname:this.name,collectionName:a,keyName:b.keyName,indexes:null!==(c=b.index)&& void 0!==c?c:[[b.keyName]],store:this._store}),[3,3]):[3,1];case 1:return e&&e.state===c0.READY?[3,3]:[4,dL.metadataOf(this.name,a,this._store)];case 2:(g=f.sent())&&(d=new dL({dbname:this.name,collectionName:a,keyName:g.keyName,indexes:g.indexes,store:this._store})),f.label=3;case 3:return d?(this._collections.set(a,d),[4,d.init()]):[3,5];case 4:f.sent(),f.label=5;case 5:return[2]}})})},a.prototype.estimateUsage=function(){return(0,f._)(this,void 0,void 0,function(){return(0,f.b)(this,function(a){var b;switch(a.label){case 0:return[4,(b=this._store,(0,f._)(void 0,void 0,void 0,function(){return(0,f.b)(this,function(a){switch(a.label){case 0:return[4,b.usage()];case 1:return[2,a.sent()]}})}))];case 1:return[2,a.sent()]}})})},a.prototype.commitSchema=function(a){return(0,f._)(this,void 0,void 0,function(){var b=this;return(0,f.b)(this,function(c){switch(c.label){case 0:return this._state!==dY.OPENING?[3,2]:[4,Promise.all(a.map(function(a){return(0,f._)(b,void 0,void 0,function(){return(0,f.b)(this,function(b){switch(b.label){case 0:return[4,this._initializeCollection(a.collectionName,a)];case 1:return b.sent(),[2]}})})}))];case 1:return c.sent(),[3,3];case 2:throw c2.databaseSchemaNotOnUpgrade;case 3:return[2]}})})},a.prototype.open=function(){var a;return(0,f._)(this,void 0,void 0,function(){var b,c,d,e,g,h,i,j,k,l,m=this;return(0,f.b)(this,function(n){var o;switch(n.label){case 0:return[4,this._globalMutex.lock()];case 1:if(n.sent(),this._state===dY.OPENED)return[3,20];this._state=dY.OPENING,n.label=2;case 2:return n.trys.push([2,13,,20]),[4,this._store.init(this.name)];case 3:return n.sent(),o=this.name,b="".concat(dn(o),".metadata"),c={version:0,collectionNames:[]},[4,this._store.get(b)];case 4:d=null!==(a=n.sent())&& void 0!==a?a:c,n.label=5;case 5:n.trys.push([5,10,11,12]),g=(e=(0,f.x)(d.collectionNames)).next(),n.label=6;case 6:return g.done?[3,9]:(h=g.value,[4,this._initializeCollection(h)]);case 7:n.sent(),n.label=8;case 8:return g=e.next(),[3,6];case 9:return[3,12];case 10:return k={error:i=n.sent()},[3,12];case 11:try{g&&!g.done&&(l=e.return)&&l.call(e)}finally{if(k)throw k.error}return[7];case 12:return[2,new Promise(function(a,c){var e=function(a){d.version0&&!this.customTypesFilter.includes("*")&&!this.customTypesFilter.includes(a.customType)||this.senderUserIdsFilter&&this.senderUserIdsFilter.length>0&&(!(a instanceof L)||!this.senderUserIdsFilter.includes(a.sender.userId)))return!1;if(a instanceof K)switch(this.replyType){case f.aw.NONE:if(a.parentMessageId>0)return!1;break;case f.aw.ONLY_REPLY_TO_CHANNEL:if(a instanceof L&&a.parentMessageId>0&&!a.replyToChannel)return!1}return!0},a}();(d1=d0||(d0={})).CHANNEL_LATEST="channel_latest",d1.NEWEST_CHILD_MESSAGE="newest_child_message";var d5=function(a){switch(a){case d0.CHANNEL_LATEST:return["channelUrl","-createdAt","-messageId"];case d0.NEWEST_CHILD_MESSAGE:return["channelUrl","-parentMessageId","-createdAt","-messageId"]}},d6=function(){return["channelUrl","-createdAt","-notificationId"]},d7=(0,f.d)((0,f.d)({},aD),{scheduledAt:void 0}),d8=function(a){return aI(a)&&(0,f.a)("number",a.scheduledAt,!0)},d9=(0,f.d)((0,f.d)({},aA),{scheduledAt:0,file:void 0,fileUrl:void 0,fileName:void 0,mimeType:void 0,fileSize:void 0,thumbnailSizes:void 0,requireAuth:!1}),ea=function(a){return aB(a)&&(0,f.a)("number",a.scheduledAt)&&((0,f.i)(a.file)||(0,f.a)("string",a.fileUrl))&&(0,f.a)("string",a.fileName,!0)&&(0,f.a)("string",a.mimeType,!0)&&(0,f.a)("number",a.fileSize,!0)&&(null===a.thumbnailSizes|| void 0===a.thumbnailSizes||a.thumbnailSizes.every(function(a){return(0,f.a)("object",a)&&a.maxWidth>0&&a.maxHeight>0}))},eb="UnsentMessage",ec="reqId",ed={},ee=function(a){function b(b){var c=a.call(this,b)||this;return c._mutex=new dK("unsendmessagecache.lock"),ed[b]=c,c}return(0,f.c)(b,a),Object.defineProperty(b.prototype,"_cacheContext",{get:function(){return f.V.of(this._iid).cacheContext},enumerable:!1,configurable:!0}),b.of=function(a,c){return void 0===c&&(c=!1),ed[a]&&!c||(ed[a]=new b(a)),ed[a]},Object.defineProperty(b.prototype,"collection",{get:function(){var a=this._cacheContext.nestdb,b=null==a?void 0:a.collection(eb);if(!b)throw f.q.databaseError;return b},enumerable:!1,configurable:!0}),Object.defineProperty(b.prototype,"localCacheEnabled",{get:function(){return this._cacheContext.localCacheEnabled&&!!this.collection},enumerable:!1,configurable:!0}),b.prototype._serialize=function(a){if(a.messageId>0)throw f.q.invalidParameters;var b,c,d,e=(0,f.d)({},a.serialize());return a instanceof R?(a.messageParams&&(e.messageParams=aC(a.messageParams)),a.scheduledInfo&&a.scheduledInfo.scheduledMessageParams&&(e.scheduledInfo.scheduledMessageParams=(b=a.scheduledInfo.scheduledMessageParams,(0,f.d)((0,f.d)({},aC(b)),{scheduledAt:b.scheduledAt})))):a instanceof W?(a.messageParams&&(e.messageParams=aL(a.messageParams)),a.scheduledInfo&&a.scheduledInfo.scheduledMessageParams&&(e.scheduledInfo.scheduledMessageParams=(c=a.scheduledInfo.scheduledMessageParams,(0,f.d)((0,f.d)({},aL(c)),{scheduledAt:c.scheduledAt})))):a instanceof S&&a.messageParams&&(e.messageParams=(d=a.messageParams,(0,f.f)({fileInfoList:d.fileInfoList.map(function(a){return{file:a.file,fileUrl:X.getPlainUrl(a),fileName:a.fileName,fileSize:a.fileSize,mimeType:a.mimeType,thumbnailSizes:a.thumbnailSizes,_thumbnails:a._thumbnails,_uploadedMetaData:a._uploadedMetaData}}),isReplyToChannel:d.isReplyToChannel,pushNotificationDeliveryOption:d.pushNotificationDeliveryOption}))),e},b.prototype._deserialize=function(a){return a=(0,f.d)((0,f.d)({},a),{messageId:parseInt(a.messageId)}),es.of(this._iid).buildMessageFromSerializedData(a)},b.prototype._deserializeWithMessageCreateParams=function(a){var b,c,d;return(0,f._)(this,void 0,void 0,function(){var e,g,h,i,j,k,l=this;return(0,f.b)(this,function(m){switch(m.label){case 0:return e=es.of(this._iid),g=this._deserialize(a),a.messageParams?g instanceof R?(i=a.messageParams,g.messageParams=e.buildUserMessageCreateParamsFromSerializedData(i,g),[3,6]):[3,1]:[3,6];case 1:return g instanceof W?(i=a.messageParams).fileKey&&"string"==typeof i.fileKey&&aK(null!==(b=i.fileType)&& void 0!==b?b:"")?(h=i,[4,this.collection.getBlob(i.fileKey)]):[3,3]:[3,4];case 2:h.file=null!==(c=m.sent())&& void 0!==c?c:void 0,m.label=3;case 3:return g.messageParams=e.buildFileMessageCreateParamsFromSerializedData(i,g),[3,6];case 4:return g instanceof S&&(i=a.messageParams)&&i.fileInfoList?(g.messageParams=e.buildMultipleFilesMessageCreateParamsFromSerializedData(i,g),[4,Promise.all(g.messageParams.fileInfoList.map(function(a){return(0,f._)(l,void 0,void 0,function(){var b,c,d,e,g;return(0,f.b)(this,function(f){switch(f.label){case 0:return"string"==typeof(null===(c=a._uploadedMetaData)|| void 0===c?void 0:c.fileKey)&&aK(null!==(e=null===(d=a._uploadedMetaData)|| void 0===d?void 0:d.fileType)&& void 0!==e?e:"")?(b=a,[4,this.collection.getBlob(a._uploadedMetaData.fileKey)]):[3,2];case 1:b.file=null!==(g=f.sent())&& void 0!==g?g:void 0,f.label=2;case 2:return[2]}})})}))]):[3,6];case 5:m.sent(),m.label=6;case 6:return g.scheduledInfo&&a.scheduledInfo&&a.scheduledInfo.scheduledMessageParams?g instanceof R?(j=a.scheduledInfo.scheduledMessageParams,g.scheduledInfo.scheduledMessageParams=e.buildScheduledUserMessageCreateParamsFromSerializedData(j,g),[3,10]):[3,7]:[3,10];case 7:return g instanceof W?(j=a.scheduledInfo.scheduledMessageParams).fileKey&&"string"==typeof j.fileKey&&"string"==typeof j.fileType&&aK(j.fileType)?(k=j,[4,this.collection.getBlob(j.fileKey)]):[3,9]:[3,10];case 8:k.file=null!==(d=m.sent())&& void 0!==d?d:void 0,m.label=9;case 9:g.scheduledInfo.scheduledMessageParams=e.buildScheduledFileMessageCreateParamsFromSerializedData(j,g),m.label=10;case 10:return[2,g]}})})},b.prototype._getFileInfoBlobKey=function(a,b){return"".concat(a,".").concat(b)},b.prototype.get=function(a){return(0,f._)(this,void 0,void 0,function(){var b;return(0,f.b)(this,function(c){switch(c.label){case 0:return this.localCacheEnabled?[4,this.collection.getByKey("".concat(a))]:[3,2];case 1:if(b=c.sent())return[2,this._deserializeWithMessageCreateParams(b)];c.label=2;case 2:return[2,void 0]}})})},b.prototype.fetch=function(a){var b=a.channelUrl,c=a.filter,d=void 0===c?new d4:c,e=a.order,g=void 0===e?d0.CHANNEL_LATEST:e,h=a.sendingStatus,i=a.backward,j=void 0!==i&&i,k=a.parentMessageId;return(0,f._)(this,void 0,void 0,function(){var a,c,e,i,l=this;return(0,f.b)(this,function(m){switch(m.label){case 0:return this.localCacheEnabled?(a=d5(g),c={"/where":function(a){return!!(g!==d0.NEWEST_CHILD_MESSAGE||k&&0!==a.parentMessageId&&a.parentMessageId===k)&&d.match(l._deserialize(a))}},b&&(c.channelUrl=b),h&&(c.sendingStatus=h),e={where:c,index:a,backward:j},[4,this.collection.query(e)]):[3,3];case 1:return[4,m.sent().fetch({})];case 2:return[2,Promise.all((i=m.sent()).map(function(a){return(0,f._)(l,void 0,void 0,function(){return(0,f.b)(this,function(b){switch(b.label){case 0:return[4,this._deserializeWithMessageCreateParams(a)];case 1:return[2,b.sent()]}})})}))];case 3:return[2,[]]}})})},b.prototype.getAllChildMessages=function(a,b){return void 0===b&&(b=new d4),(0,f._)(this,void 0,void 0,function(){return(0,f.b)(this,function(c){switch(c.label){case 0:return[4,this.fetch({filter:b,order:d0.NEWEST_CHILD_MESSAGE,channelUrl:a.channelUrl,backward:!1,parentMessageId:a.messageId})];case 1:return[2,c.sent()]}})})},b.prototype.upsert=function(a){return(0,f._)(this,void 0,void 0,function(){var b=this;return(0,f.b)(this,function(c){switch(c.label){case 0:return this.localCacheEnabled?[4,Promise.all(a.map(function(a){return(0,f._)(b,void 0,void 0,function(){var b;return(0,f.b)(this,function(c){switch(c.label){case 0:return a instanceof W||a instanceof S?[4,this._mutex.lock()]:[3,4];case 1:return c.sent(),[4,this.saveBlob(a)];case 2:return c.sent(),[4,this._mutex.unlock()];case 3:c.sent(),c.label=4;case 4:return b=this._serialize(a),[4,this.collection.upsertOne(b)];case 5:return c.sent(),[2]}})})}))]:[3,2];case 1:c.sent(),c.label=2;case 2:return[2]}})})},b.prototype.upsertChildMessages=function(a){return(0,f._)(this,void 0,void 0,function(){var b=this;return(0,f.b)(this,function(c){switch(c.label){case 0:return this.localCacheEnabled?[4,Promise.all(a.map(function(a){return(0,f._)(b,void 0,void 0,function(){var b;return(0,f.b)(this,function(c){switch(c.label){case 0:return b=[],a.threadInfo&&a.threadInfo.replyCount>0?[4,this.getAllChildMessages(a)]:[3,2];case 1:b=c.sent(),c.label=2;case 2:return b.length>0?(b.forEach(function(b){return b.applyParentMessage(a)}),[4,this.upsert(b)]):[3,4];case 3:c.sent(),c.label=4;case 4:return[2]}})})}))]:[3,2];case 1:c.sent(),c.label=2;case 2:return[2]}})})},b.prototype.remove=function(a){return(0,f._)(this,void 0,void 0,function(){var b,c,d,e,g,h;return(0,f.b)(this,function(i){switch(i.label){case 0:if(!this.localCacheEnabled)return[3,8];i.label=1;case 1:i.trys.push([1,6,7,8]),c=(b=(0,f.x)(a)).next(),i.label=2;case 2:return c.done?[3,5]:(d=c.value,[4,this.collection.remove(d)]);case 3:i.sent(),i.label=4;case 4:return c=b.next(),[3,2];case 5:return[3,8];case 6:return g={error:e=i.sent()},[3,8];case 7:try{c&&!c.done&&(h=b.return)&&h.call(b)}finally{if(g)throw g.error}return[7];case 8:return[2]}})})},b.prototype.removeMessagesOfChannel=function(a){return(0,f._)(this,void 0,void 0,function(){return(0,f.b)(this,function(b){switch(b.label){case 0:return this.localCacheEnabled?[4,this.collection.removeIf({where:{channelUrl:a}})]:[3,2];case 1:b.sent(),b.label=2;case 2:return[2]}})})},b.prototype.clear=function(){return(0,f._)(this,void 0,void 0,function(){return(0,f.b)(this,function(a){switch(a.label){case 0:return this.localCacheEnabled?[4,this.collection.clear()]:[3,2];case 1:a.sent(),a.label=2;case 2:return[2]}})})},b.prototype.saveBlob=function(a){return(0,f._)(this,void 0,void 0,function(){var b,c,d,e=this;return(0,f.b)(this,function(g){switch(g.label){case 0:return a instanceof W?a.messageParams&&(d=a.messageParams).file&&aJ(d.file)?[4,this.collection.saveBlob(d.file,a.reqId)]:[3,2]:[3,5];case 1:c=g.sent(),d.fileKey=c,d.fileType=aF.BLOB,g.label=2;case 2:return a.scheduledInfo&&a.scheduledInfo.scheduledMessageParams&&(b=a.scheduledInfo.scheduledMessageParams).file&&aJ(b.file)?[4,this.collection.saveBlob(b.file,a.reqId)]:[3,4];case 3:c=g.sent(),b.fileKey=c,b.fileType=aF.BLOB,g.label=4;case 4:return[3,7];case 5:return a instanceof S&&(d=a.messageParams)&&d.fileInfoList&&Array.isArray(d.fileInfoList)?[4,Promise.all(d.fileInfoList.map(function(b,c){return(0,f._)(e,void 0,void 0,function(){var d;return(0,f.b)(this,function(e){switch(e.label){case 0:return b.file&&aJ(b.file)?[4,this.collection.saveBlob(b.file,this._getFileInfoBlobKey(a.reqId,c))]:[3,2];case 1:d=e.sent(),b._uploadedMetaData||(b._uploadedMetaData={}),b._uploadedMetaData.fileKey=d,b._uploadedMetaData.fileType=aF.BLOB,e.label=2;case 2:return[2]}})})}))]:[3,7];case 6:g.sent(),g.label=7;case 7:return[2]}})})},b}(f.aK),ef={},eg=function(a){function b(b){var c=a.call(this,b)||this;return ef[b]=c,c}return(0,f.c)(b,a),Object.defineProperty(b.prototype,"_sdkState",{get:function(){return f.V.of(this._iid).sdkState},enumerable:!1,configurable:!0}),Object.defineProperty(b.prototype,"_cacheContext",{get:function(){return f.V.of(this._iid).cacheContext},enumerable:!1,configurable:!0}),Object.defineProperty(b.prototype,"_unsentMessageCache",{get:function(){return ee.of(this._iid)},enumerable:!1,configurable:!0}),b.of=function(a,c){return void 0===c&&(c=!1),ef[a]&&!c||(ef[a]=new b(a)),ef[a]},Object.defineProperty(b.prototype,"collection",{get:function(){var a=this._cacheContext.nestdb;return(0,f.p)(!!a).throw(f.q.databaseError),a.collection(cn)},enumerable:!1,configurable:!0}),Object.defineProperty(b.prototype,"localCacheEnabled",{get:function(){return this._cacheContext.localCacheEnabled&&!!this.collection},enumerable:!1,configurable:!0}),b.prototype._serialize=function(a){return(0,f.d)((0,f.d)({},a.serialize()),{messageId:"".concat(a.messageId)})},b.prototype._deserialize=function(a){return a=(0,f.d)((0,f.d)({},a),{messageId:parseInt(a.messageId)}),es.of(this._iid).buildMessageFromSerializedData(a)},b.prototype.get=function(a){return(0,f._)(this,void 0,void 0,function(){var b;return(0,f.b)(this,function(c){switch(c.label){case 0:return this.localCacheEnabled?[4,this.collection.getByKey("".concat(a))]:[3,2];case 1:if(b=c.sent())return[2,this._deserialize(b)];c.label=2;case 2:return[2,void 0]}})})},b.prototype.fetch=function(a){var b=a.channelUrl,c=a.token,d=a.limit,e=void 0===d?100:d,g=a.filter,h=void 0===g?new d4:g,i=a.order,j=void 0===i?d0.CHANNEL_LATEST:i,k=a.backward,l=void 0!==k&&k,m=a.parentMessageId,n=a.isPollOnly,o=void 0!==n&&n,p=a.exactMatch,q=void 0!==p&&p,r=a.inclusive,s=void 0===r||r,t=a.isRestoreIndexedDB,u=void 0!==t&&t;return(0,f._)(this,void 0,void 0,function(){var a,d,g,i,k=this;return(0,f.b)(this,function(n){switch(n.label){case 0:return this.localCacheEnabled?(a=d5(j),d={where:{channelUrl:b,"/where":function(a){if(null!=c&&""!==c)switch(j){case d0.CHANNEL_LATEST:if(q&&a.createdAt!==c)return!1;if(l){if(s&&a.createdAtc|| !s&&a.createdAt>=c)return!1;break;case d0.NEWEST_CHILD_MESSAGE:if(!m||0===a.parentMessageId||a.parentMessageId!==m)return!1}return!(o&&!a._poll)&&h.match(k._deserialize(a))}},index:a,backward:l},[4,this.collection.query(d)]):[3,5];case 1:return g=n.sent(),this._cacheContext.localCacheConfig.enableRestoreDB&&u?[4,g.indexer.restoreIndexer()]:[3,3];case 2:n.sent(),n.label=3;case 3:return[4,g.fetch({limit:null!=e?e:void 0})];case 4:return[2,Promise.all((i=n.sent()).map(function(a){return(0,f._)(k,void 0,void 0,function(){return(0,f.b)(this,function(b){return[2,this._deserialize(a)]})})}))];case 5:return[2,[]]}})})},b.prototype.getAllChildMessages=function(a,b){return void 0===b&&(b=new d4),(0,f._)(this,void 0,void 0,function(){return(0,f.b)(this,function(c){switch(c.label){case 0:return[4,this.fetch({channelUrl:a.channelUrl,token:Date.now(),limit:null,backward:!1,filter:b,order:d0.NEWEST_CHILD_MESSAGE,parentMessageId:a.messageId})];case 1:return[2,c.sent()]}})})},b.prototype.upsert=function(a){var b;return(0,f._)(this,void 0,void 0,function(){var c,d,e,g,h,i,j,k,l=this;return(0,f.b)(this,function(m){switch(m.label){case 0:return this.localCacheEnabled?[4,this.saveBlobs(a)]:[3,13];case 1:m.sent(),m.label=2;case 2:m.trys.push([2,7,8,9]),d=(c=(0,f.x)(a)).next(),m.label=3;case 3:return d.done?[3,6]:(null===(b=(e=d.value).threadInfo)|| void 0===b?void 0:b._isUpdateRequired)?[4,this.get(e.messageId)]:[3,5];case 4:(null==(g=m.sent())?void 0:g.threadInfo)&&e.threadInfo._updateFrom(g.threadInfo),m.label=5;case 5:return d=c.next(),[3,3];case 6:return[3,9];case 7:return j={error:h=m.sent()},[3,9];case 8:try{d&&!d.done&&(k=c.return)&&k.call(c)}finally{if(j)throw j.error}return[7];case 9:return i=a.map(function(a){return l._serialize(a)}),[4,this.collection.upsertMany(i)];case 10:return m.sent(),[4,this.upsertChildMessages(a)];case 11:return m.sent(),[4,this._unsentMessageCache.upsertChildMessages(a)];case 12:m.sent(),m.label=13;case 13:return[2]}})})},b.prototype.upsertChildMessages=function(a){return(0,f._)(this,void 0,void 0,function(){var b=this;return(0,f.b)(this,function(c){switch(c.label){case 0:return this.localCacheEnabled?[4,Promise.all(a.map(function(a){return(0,f._)(b,void 0,void 0,function(){var b,c;return(0,f.b)(this,function(d){switch(d.label){case 0:return b=[],(null===(c=a.threadInfo)|| void 0===c?void 0:c.replyCount)&&a.threadInfo.replyCount>0?[4,this.getAllChildMessages(a)]:[3,2];case 1:b=d.sent(),d.label=2;case 2:return b.length>0?(b.forEach(function(b){return b.applyParentMessage(a)}),[4,this.upsert(b)]):[3,4];case 3:d.sent(),d.label=4;case 4:return[2]}})})}))]:[3,2];case 1:c.sent(),c.label=2;case 2:return[2]}})})},b.prototype.remove=function(a){return(0,f._)(this,void 0,void 0,function(){var b,c,d,e,g,h;return(0,f.b)(this,function(i){switch(i.label){case 0:if(!this.localCacheEnabled)return[3,8];i.label=1;case 1:i.trys.push([1,6,7,8]),c=(b=(0,f.x)(a)).next(),i.label=2;case 2:return c.done?[3,5]:(d=c.value,[4,this.collection.remove("".concat(d))]);case 3:i.sent(),i.label=4;case 4:return c=b.next(),[3,2];case 5:return[3,8];case 6:return g={error:e=i.sent()},[3,8];case 7:try{c&&!c.done&&(h=b.return)&&h.call(b)}finally{if(g)throw g.error}return[7];case 8:return[2]}})})},b.prototype.removeMessagesOfChannel=function(a){return(0,f._)(this,void 0,void 0,function(){var b;return(0,f.b)(this,function(c){switch(c.label){case 0:return this.localCacheEnabled?[4,this.collection.removeIf({where:{channelUrl:a},index:d5(d0.CHANNEL_LATEST)})]:[3,6];case 1:return c.sent(),[4,(b=this._cacheContext.preference).remove("sendbird:".concat(this._sdkState.userId,"@groupchannel/").concat(a,"/message/sync"))];case 2:return c.sent(),[4,b.remove("sendbird:".concat(this._sdkState.userId,"@groupchannel/").concat(a,"/message/sync.meta"))];case 3:return c.sent(),[4,b.remove("sendbird:".concat(this._sdkState.userId,"@groupchannel/").concat(a,"/message/changelogs"))];case 4:return c.sent(),[4,b.remove("sendbird:".concat(this._sdkState.userId,"@groupchannel/").concat(a,"/message/changelogs.meta"))];case 5:c.sent(),c.label=6;case 6:return[2]}})})},b.prototype.removeUnderOffset=function(a,b,c){return void 0===c&&(c=!1),(0,f._)(this,void 0,void 0,function(){return(0,f.b)(this,function(d){switch(d.label){case 0:return this.localCacheEnabled?[4,this.collection.removeIf({where:{channelUrl:a,createdAt:c?{"<=":b}:{"<":b}},index:d5(d0.CHANNEL_LATEST)})]:[3,2];case 1:d.sent(),d.label=2;case 2:return[2]}})})},b.prototype.clear=function(){return(0,f._)(this,void 0,void 0,function(){return(0,f.b)(this,function(a){switch(a.label){case 0:return this.localCacheEnabled?[4,this.collection.clear()]:[3,2];case 1:a.sent(),a.label=2;case 2:return[2]}})})},b.prototype.countBetween=function(a,b,c){return(0,f._)(this,void 0,void 0,function(){var d,e=this;return(0,f.b)(this,function(f){switch(f.label){case 0:return this.localCacheEnabled?(d=d5(d0.CHANNEL_LATEST),[4,this.collection.query({where:{channelUrl:a,"/where":function(a){var d=e._deserialize(a);return c.includes(d.createdAt)&&b.match(d)}},index:d}).count()]):[3,2];case 1:return[2,f.sent()];case 2:return[2,0]}})})},b.prototype.countByChannel=function(a){return(0,f._)(this,void 0,void 0,function(){var b;return(0,f.b)(this,function(c){switch(c.label){case 0:return this.localCacheEnabled?(b=d5(d0.CHANNEL_LATEST),[4,this.collection.query({where:{channelUrl:a},index:b}).count()]):[3,2];case 1:return[2,c.sent()];case 2:return[2,0]}})})},b.prototype.saveBlobs=function(a){return(0,f._)(this,void 0,void 0,function(){var b=this;return(0,f.b)(this,function(c){switch(c.label){case 0:return[4,Promise.all(a.map(function(a){return(0,f._)(b,void 0,void 0,function(){var b,c;return(0,f.b)(this,function(d){switch(d.label){case 0:return a instanceof W&&a.messageParams&&(b=a.messageParams).file&&aJ(b.file)?[4,this.collection.saveBlob(b.file,a.reqId)]:[3,2];case 1:c=d.sent(),b.fileKey=c,d.label=2;case 2:return[2]}})})}))];case 1:return c.sent(),[2]}})})},b.prototype._getGroupChannelPreferenceSize=function(a){return(0,f._)(this,void 0,void 0,function(){var b,c,d,e,g,h;return(0,f.b)(this,function(f){switch(f.label){case 0:return b=0,[4,(c=this._cacheContext.preference).get("sendbird:".concat(this._sdkState.userId,"@groupchannel/").concat(a,"/message/sync"))];case 1:return d=f.sent(),[4,c.get("sendbird:".concat(this._sdkState.userId,"@groupchannel/").concat(a,"/message/sync.meta"))];case 2:return e=f.sent(),[4,c.get("sendbird:".concat(this._sdkState.userId,"@groupchannel/").concat(a,"/message/changelogs"))];case 3:return g=f.sent(),[4,c.get("sendbird:".concat(this._sdkState.userId,"@groupchannel/").concat(a,"/message/changelogs.meta"))];case 4:return h=f.sent(),d&&(b+=JSON.stringify(d).length),e&&(b+=JSON.stringify(e).length),g&&(b+=JSON.stringify(g).length),h&&(b+=JSON.stringify(h).length),[2,b]}})})},b}(f.aK),eh={},ei=function(a){function b(b){var c=a.call(this,b)||this;return eh[b]=c,c}return(0,f.c)(b,a),Object.defineProperty(b.prototype,"_sdkState",{get:function(){return f.V.of(this._iid).sdkState},enumerable:!1,configurable:!0}),Object.defineProperty(b.prototype,"_cacheContext",{get:function(){return f.V.of(this._iid).cacheContext},enumerable:!1,configurable:!0}),b.of=function(a,c){return void 0===c&&(c=!1),eh[a]&&!c||(eh[a]=new b(a)),eh[a]},Object.defineProperty(b.prototype,"collection",{get:function(){var a=this._cacheContext.nestdb;return(0,f.p)(!!a).throw(f.q.databaseError),a.collection(cp)},enumerable:!1,configurable:!0}),Object.defineProperty(b.prototype,"localCacheEnabled",{get:function(){return this._cacheContext.localCacheEnabled&&!!this.collection},enumerable:!1,configurable:!0}),b.prototype._serialize=function(a){return(0,f.d)({},a.serialize())},b.prototype._deserialize=function(a){return es.of(this._iid).buildMessageFromSerializedData(a)},b.prototype.get=function(a){return(0,f._)(this,void 0,void 0,function(){var b;return(0,f.b)(this,function(c){switch(c.label){case 0:return this.localCacheEnabled?[4,this.collection.getByKey(a)]:[3,2];case 1:if(b=c.sent())return[2,this._deserialize(b)];c.label=2;case 2:return[2,void 0]}})})},b.prototype.fetch=function(a){var b=a.channelUrl,c=a.token,d=a.limit,e=void 0===d?100:d,g=a.filter,h=void 0===g?new d4:g,i=a.backward,j=void 0!==i&&i,k=a.exactMatch,l=void 0!==k&&k,m=a.inclusive,n=void 0===m||m;return(0,f._)(this,void 0,void 0,function(){var a,d=this;return(0,f.b)(this,function(f){switch(f.label){case 0:return this.localCacheEnabled?(a={where:{channelUrl:b,"/where":function(a){if(c){if(l&&a.createdAt!==c)return!1;if(j){if(n&&a.createdAtc|| !n&&a.createdAt>=c)return!1}return h.match(d._deserialize(a))}},index:["channelUrl","-createdAt","-notificationId"],backward:j},[4,this.collection.query(a)]):[3,3];case 1:return[4,f.sent().fetch({limit:null!=e?e:void 0})];case 2:return[2,f.sent().map(function(a){return d._deserialize(a)})];case 3:return[2,[]]}})})},b.prototype.upsert=function(a){return(0,f._)(this,void 0,void 0,function(){var b,c=this;return(0,f.b)(this,function(d){switch(d.label){case 0:return this.localCacheEnabled?(b=a.map(function(a){return c._serialize(a)}),[4,this.collection.upsertMany(b)]):[3,2];case 1:d.sent(),d.label=2;case 2:return[2]}})})},b.prototype.remove=function(a){return(0,f._)(this,void 0,void 0,function(){var b,c,d,e,g,h;return(0,f.b)(this,function(i){switch(i.label){case 0:if(!this.localCacheEnabled)return[3,8];i.label=1;case 1:i.trys.push([1,6,7,8]),c=(b=(0,f.x)(a)).next(),i.label=2;case 2:return c.done?[3,5]:(d=c.value,[4,this.collection.remove(d)]);case 3:i.sent(),i.label=4;case 4:return c=b.next(),[3,2];case 5:return[3,8];case 6:return g={error:e=i.sent()},[3,8];case 7:try{c&&!c.done&&(h=b.return)&&h.call(b)}finally{if(g)throw g.error}return[7];case 8:return[2]}})})},b.prototype.markAsReadByTimestamp=function(a,b){return(0,f._)(this,void 0,void 0,function(){return(0,f.b)(this,function(c){switch(c.label){case 0:return this.localCacheEnabled?[4,this.collection.updateIf({where:{channelUrl:a,messageStatus:I.SENT,createdAt:{"<":b}}},{set:{messageStatus:I.READ}})]:[3,2];case 1:c.sent(),c.label=2;case 2:return[2]}})})},b.prototype.markAsReadByMessageIds=function(a,b){return(0,f._)(this,void 0,void 0,function(){return(0,f.b)(this,function(c){switch(c.label){case 0:return this.localCacheEnabled?[4,this.collection.updateIf({where:{channelUrl:a,notificationId:{"/in":b},messageStatus:I.SENT}},{set:{messageStatus:I.READ}})]:[3,2];case 1:return[2,c.sent().length];case 2:return[2,0]}})})},b.prototype.removeMessagesOfChannel=function(a){return(0,f._)(this,void 0,void 0,function(){var b;return(0,f.b)(this,function(c){switch(c.label){case 0:return this.localCacheEnabled?[4,this.collection.removeIf({where:{channelUrl:a},index:["channelUrl","-createdAt","-notificationId"]})]:[3,6];case 1:return c.sent(),[4,(b=this._cacheContext.preference).remove("sendbird:".concat(this._sdkState.userId,"@groupchannel/").concat(a,"/message/sync"))];case 2:return c.sent(),[4,b.remove("sendbird:".concat(this._sdkState.userId,"@groupchannel/").concat(a,"/message/sync.meta"))];case 3:return c.sent(),[4,b.remove("sendbird:".concat(this._sdkState.userId,"@groupchannel/").concat(a,"/message/changelogs"))];case 4:return c.sent(),[4,b.remove("sendbird:".concat(this._sdkState.userId,"@groupchannel/").concat(a,"/message/changelogs.meta"))];case 5:c.sent(),c.label=6;case 6:return[2]}})})},b.prototype.removeUnderOffset=function(a,b){return(0,f._)(this,void 0,void 0,function(){return(0,f.b)(this,function(c){switch(c.label){case 0:return this.localCacheEnabled?[4,this.collection.removeIf({where:{channelUrl:a,createdAt:{"<":b}},index:d5(d0.CHANNEL_LATEST)})]:[3,2];case 1:c.sent(),c.label=2;case 2:return[2]}})})},b.prototype.clear=function(){return(0,f._)(this,void 0,void 0,function(){return(0,f.b)(this,function(a){switch(a.label){case 0:return this.localCacheEnabled?[4,this.collection.clear()]:[3,2];case 1:a.sent(),a.label=2;case 2:return[2]}})})},b.prototype.countBetween=function(a,b,c){return(0,f._)(this,void 0,void 0,function(){var d,e=this;return(0,f.b)(this,function(f){switch(f.label){case 0:return this.localCacheEnabled?(d=["channelUrl","-createdAt","-notificationId"],[4,this.collection.query({where:{channelUrl:a,"/where":function(a){var d=e._deserialize(a);return c.includes(d.createdAt)&&b.match(d)}},index:d}).count()]):[3,2];case 1:return[2,f.sent()];case 2:return[2,0]}})})},b}(f.aK),ej={},ek=function(a){function b(b){var c=a.call(this,b)||this;return c._observers=new Map,c._dispatcherContext=c._dispatcher.on(function(a){return(0,f._)(c,void 0,void 0,function(){var b,c,d,e,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x=this;return(0,f.b)(this,function(y){switch(y.label){case 0:return a instanceof f.aP?(b=a.messages,w=a.source,h=a.isWebSocketEventComing,c=b.filter(function(a){return a instanceof K&&a.channelType!==f.C.OPEN&&a.messageId>0}),d=b.filter(function(a){return a instanceof K&&a.channelType!==f.C.OPEN&&0===a.messageId}),e=b.filter(function(a){return a instanceof T}),c.length>0?[4,(0,f.J)(function(){return(0,f._)(x,void 0,void 0,function(){return(0,f.b)(this,function(a){switch(a.label){case 0:return[4,this._messageCache.upsert(c)];case 1:return a.sent(),[4,this._unsentMessageCache.remove(c.map(function(a){return a instanceof L?a.reqId:null}).filter(function(a){return null!==a}))];case 2:return a.sent(),[2]}})})})]:[3,2]):[3,7];case 1:y.sent(),h||this._broadcastUpdateEvent(c,w),y.label=2;case 2:return d.length>0?[4,(0,f.J)(function(){return(0,f._)(x,void 0,void 0,function(){return(0,f.b)(this,function(a){switch(a.label){case 0:return[4,this._unsentMessageCache.upsert(d)];case 1:return a.sent(),[2]}})})})]:[3,4];case 3:y.sent(),h||this._broadcastUpdateEvent(d,w),y.label=4;case 4:return e.length>0?[4,(0,f.J)(function(){return(0,f._)(x,void 0,void 0,function(){return(0,f.b)(this,function(a){switch(a.label){case 0:return[4,this._notificationCache.upsert(e)];case 1:return a.sent(),[2]}})})})]:[3,6];case 5:y.sent(),h||this._broadcastUpdateEvent(e,w),y.label=6;case 6:return[3,24];case 7:return a instanceof f.bh?(g=a.messageIds,w=a.source,h=a.isWebSocketEventComing,i=g.filter(function(a){return"number"==typeof a}),j=g.filter(function(a){return"string"==typeof a}),[4,(0,f.J)(function(){return(0,f._)(x,void 0,void 0,function(){return(0,f.b)(this,function(a){switch(a.label){case 0:return i.length>0?[4,this._messageCache.remove(i)]:[3,2];case 1:a.sent(),a.label=2;case 2:return j.length>0?[4,this._notificationCache.remove(j)]:[3,4];case 3:a.sent(),a.label=4;case 4:return[2]}})})})]):[3,9];case 8:return y.sent(),h||this._broadcastRemoveEvent(g,w),[3,24];case 9:return a instanceof f.bg?(k=a.reqId,w=a.source,[4,(0,f.J)(function(){return(0,f._)(x,void 0,void 0,function(){return(0,f.b)(this,function(a){switch(a.label){case 0:return[4,this._unsentMessageCache.remove([k])];case 1:return a.sent(),[2]}})})})]):[3,11];case 10:return y.sent(),this._broadcastRemoveUnsentEvent(k,w),[3,24];case 11:return a instanceof f.bf?(l=a.polls,w=a.source,this._cacheContext.localCacheEnabled?[4,Promise.all((m=l.map(function(a){return a.messageId})).map(function(a){return x._messageCache.get(a)}))]:[3,14]):[3,15];case 12:return(n=y.sent().filter(function(a){return a})).length>0&&l.forEach(function(a){var b=n.find(function(b){return b.messageId===a.messageId});b&&b.applyPoll(a)}),[4,(0,f.J)(function(){return(0,f._)(x,void 0,void 0,function(){return(0,f.b)(this,function(a){switch(a.label){case 0:return[4,this._messageCache.upsert(n)];case 1:return[2,a.sent()]}})})})];case 13:y.sent(),y.label=14;case 14:return this._broadcastPollChangeLogEvent(l,w),[3,24];case 15:return a instanceof f.be?(o=a.event,w=a.source,[4,this._messageCache.get(o.messageId)]):[3,19];case 16:return(p=y.sent())&&p.isUserMessage()&&p.poll&&p.poll.applyPollUpdateEvent(o)?[4,(0,f.J)(function(){return(0,f._)(x,void 0,void 0,function(){return(0,f.b)(this,function(a){switch(a.label){case 0:return[4,this._messageCache.upsert([p])];case 1:return[2,a.sent()]}})})})]:[3,18];case 17:y.sent(),y.label=18;case 18:return this._broadcastPollUpdateEvent(o,w),[3,24];case 19:return a instanceof f.b6?(q=a.event,w=a.source,[4,this._messageCache.get(q.messageId)]):[3,23];case 20:return(r=y.sent())&&r.isUserMessage()&&r.poll&&r.poll.applyPollVoteEvent(q)?[4,(0,f.J)(function(){return(0,f._)(x,void 0,void 0,function(){return(0,f.b)(this,function(a){switch(a.label){case 0:return[4,this._messageCache.upsert([r])];case 1:return[2,a.sent()]}})})})]:[3,22];case 21:y.sent(),y.label=22;case 22:return this._broadcastPollVoteEvent(q,w),[3,24];case 23:a instanceof f.bb?(s=a.event,w=a.source,s.messageId>0&&this._broadcastReactionUpdateEvent(s,w)):a instanceof f.bc?(t=a.event,w=a.source,this._broadcastThreadUpdateEvent(t,w)):a instanceof f.bd&&(u=a.messageDeletionTimestamp,v=a.channelUrl,w=a.source,this._broadcastMessageRetentionEvent(u,v,w)),y.label=24;case 24:return[2]}})})}),c}return(0,f.c)(b,a),Object.defineProperty(b.prototype,"_cacheContext",{get:function(){return f.V.of(this._iid).cacheContext},enumerable:!1,configurable:!0}),Object.defineProperty(b.prototype,"_dispatcher",{get:function(){return f.V.of(this._iid).dispatcher},enumerable:!1,configurable:!0}),Object.defineProperty(b.prototype,"_messageCache",{get:function(){return eg.of(this._iid)},enumerable:!1,configurable:!0}),Object.defineProperty(b.prototype,"_unsentMessageCache",{get:function(){return ee.of(this._iid)},enumerable:!1,configurable:!0}),Object.defineProperty(b.prototype,"_notificationCache",{get:function(){return ei.of(this._iid)},enumerable:!1,configurable:!0}),b.of=function(a,c){var d;return void 0===c&&(c=!1),ej[a]&&!c||(ej[a]&&(null===(d=ej[a]._dispatcherContext)|| void 0===d||d.close()),ej[a]=new b(a)),ej[a]},b.prototype._broadcastUpdateEvent=function(a,b){var c,d;try{for(var e=(0,f.x)(this._observers.values()),g=e.next();!g.done;g=e.next()){var h=g.value;h.onUpdate&&h.onUpdate(a,b)}}catch(i){c={error:i}}finally{try{g&&!g.done&&(d=e.return)&&d.call(e)}finally{if(c)throw c.error}}},b.prototype._broadcastPollChangeLogEvent=function(a,b){var c,d;try{for(var e=(0,f.x)(this._observers.values()),g=e.next();!g.done;g=e.next()){var h=g.value;h.onPollChangeLogUpdate&&h.onPollChangeLogUpdate(a,b)}}catch(i){c={error:i}}finally{try{g&&!g.done&&(d=e.return)&&d.call(e)}finally{if(c)throw c.error}}},b.prototype._broadcastPollUpdateEvent=function(a,b){var c,d;try{for(var e=(0,f.x)(this._observers.values()),g=e.next();!g.done;g=e.next()){var h=g.value;h.onPollUpdate&&h.onPollUpdate(a,b)}}catch(i){c={error:i}}finally{try{g&&!g.done&&(d=e.return)&&d.call(e)}finally{if(c)throw c.error}}},b.prototype._broadcastPollVoteEvent=function(a,b){var c,d;try{for(var e=(0,f.x)(this._observers.values()),g=e.next();!g.done;g=e.next()){var h=g.value;h.onPollVote&&h.onPollVote(a,b)}}catch(i){c={error:i}}finally{try{g&&!g.done&&(d=e.return)&&d.call(e)}finally{if(c)throw c.error}}},b.prototype._broadcastRemoveEvent=function(a,b){var c,d;try{for(var e=(0,f.x)(this._observers.values()),g=e.next();!g.done;g=e.next()){var h=g.value;h.onRemove&&h.onRemove(a,b)}}catch(i){c={error:i}}finally{try{g&&!g.done&&(d=e.return)&&d.call(e)}finally{if(c)throw c.error}}},b.prototype._broadcastRemoveUnsentEvent=function(a,b){var c,d;try{for(var e=(0,f.x)(this._observers.values()),g=e.next();!g.done;g=e.next()){var h=g.value;h.onRemoveUnsent&&h.onRemoveUnsent(a,b)}}catch(i){c={error:i}}finally{try{g&&!g.done&&(d=e.return)&&d.call(e)}finally{if(c)throw c.error}}},b.prototype._broadcastReactionUpdateEvent=function(a,b){var c,d;try{for(var e=(0,f.x)(this._observers.values()),g=e.next();!g.done;g=e.next()){var h=g.value;h.onReactionUpdate&&h.onReactionUpdate(a,b)}}catch(i){c={error:i}}finally{try{g&&!g.done&&(d=e.return)&&d.call(e)}finally{if(c)throw c.error}}},b.prototype._broadcastThreadUpdateEvent=function(a,b){var c,d;try{for(var e=(0,f.x)(this._observers.values()),g=e.next();!g.done;g=e.next()){var h=g.value;h.onThreadInfoUpdate&&h.onThreadInfoUpdate(a,b)}}catch(i){c={error:i}}finally{try{g&&!g.done&&(d=e.return)&&d.call(e)}finally{if(c)throw c.error}}},b.prototype._broadcastMessageRetentionEvent=function(a,b,c){var d,e;try{for(var g=(0,f.x)(this._observers.values()),h=g.next();!h.done;h=g.next()){var i=h.value;i.onDeletedByRetentionPolicy&&i.onDeletedByRetentionPolicy(a,b,c)}}catch(j){d={error:j}}finally{try{h&&!h.done&&(e=g.return)&&e.call(g)}finally{if(d)throw d.error}}},b.prototype.subscribe=function(a,b){this._observers.set(a,b)},b.prototype.unsubscribe=function(a){this._observers.delete(a)},b.prototype.unsubscribeAll=function(){this._observers.clear()},b}(f.aK),el={},em=function(a){function b(b,c){var d=c.sdkState,e=c.cacheContext,f=a.call(this,b)||this;return f._users=new Map,f._sdkState=d,f._cacheContext=e,el[b]=f,f}return(0,f.c)(b,a),b.of=function(a){return el[a]},Object.defineProperty(b.prototype,"collection",{get:function(){var a=this._cacheContext.nestdb;return(0,f.p)(!!a).throw(f.q.databaseError),a.collection(cv)},enumerable:!1,configurable:!0}),Object.defineProperty(b.prototype,"localCacheEnabled",{get:function(){return this._cacheContext.localCacheEnabled&&!!this.collection},enumerable:!1,configurable:!0}),Object.defineProperty(b.prototype,"users",{get:function(){return(0,f.s)([],(0,f.t)(this._users.values()),!1)},enumerable:!1,configurable:!0}),b.prototype._serialize=function(a,b){return(0,f.d)((0,f.d)({},a.serialize()),{updatedAt:b})},b.prototype._deserialize=function(a){return f.U._buildUserFromSerializedData(a)},b.prototype.isCachedInMemory=function(a){return this._users.has(a)},b.prototype.getUserInfoFromCache=function(a){if(this._users.has(a))return this._users.get(a)},b.prototype.get=function(a){return(0,f._)(this,void 0,void 0,function(){var b,c;return(0,f.b)(this,function(d){switch(d.label){case 0:return this._users.has(a)?[3,3]:this.localCacheEnabled?[4,this.collection.getByKey(a)]:[3,2];case 1:if(b=d.sent())return c=this._deserialize(b),this._users.set(c.userId,c),[2,c];d.label=2;case 2:return[2,void 0];case 3:return[2,this._users.get(a)]}})})},b.prototype.fetch=function(a){var b=a.limit,c=void 0===b?100:b,d=a.backward,e=void 0!==d&&d;return(0,f._)(this,void 0,void 0,function(){var a,b,d,g=this;return(0,f.b)(this,function(f){switch(f.label){case 0:if(!this.localCacheEnabled)return[2,[]];f.label=1;case 1:return f.trys.push([1,4,,5]),a={index:["-userId","-updatedAt"],backward:e},[4,this.collection.query(a)];case 2:return[4,f.sent().fetch({limit:c})];case 3:return(d=(b=f.sent()).map(function(a){return g._deserialize(a)})).forEach(function(a){g._users.has(a.userId)||g._users.set(a.userId,a)}),[2,d];case 4:return f.sent(),[2,[]];case 5:return[2]}})})},b.prototype.upsert=function(a,b){return(0,f._)(this,void 0,void 0,function(){var c,d;return(0,f.b)(this,function(e){switch(e.label){case 0:if(!this.localCacheEnabled)return[3,2];if(c=this._serialize(a,b),(d=this._users.get(a.userId))&&(d._hashValue===a._hashValue||d._updatedAt>b))return[2];return this._users.set(a.userId,f.U._buildUserFromSerializedData(c)),[4,this.collection.upsertOne(c)];case 1:e.sent(),e.label=2;case 2:return[2]}})})},b.prototype.remove=function(a){return(0,f._)(this,void 0,void 0,function(){return(0,f.b)(this,function(b){switch(b.label){case 0:return this._users.has(a)&&this._users.delete(a),this.localCacheEnabled?[4,this.collection.remove(a)]:[3,2];case 1:b.sent(),b.label=2;case 2:return[2]}})})},b.prototype.clearMemoryCache=function(){this._users.clear()},b.prototype.clear=function(){return(0,f._)(this,void 0,void 0,function(){return(0,f.b)(this,function(a){switch(a.label){case 0:return this.clearMemoryCache(),this.localCacheEnabled?[4,this.collection.clear()]:[3,2];case 1:a.sent(),a.label=2;case 2:return[2]}})})},b}(f.aK),en=function(a){function b(b){var c=this,d=b.reverse,e=b.limit,g=b.keys,h=b.token;return(c=a.call(this)||this).method=f.A.GET,c.path="".concat(f.bi),c.params=(0,f.f)({token:h,limit:void 0===e?20:e,reverse:void 0!==d&&d,order:f.bj.UPDATED_AT,show_ui_template:!0,show_color_variables:!0,keys:g}),c}return(0,f.c)(b,a),b}(f.h),eo=function(a){function b(b,c){var d=a.call(this,b,c)||this,e=c.next,f=c.has_more,g=c.templates;return d.nextToken=e,d.hasMore=void 0!==f&&f,d.templates=g.map(function(a){return{template:JSON.stringify(a)}}),d}return(0,f.c)(b,a),b}(f.j),ep=function(a){function b(b){var c=this,d=b.key;return(c=a.call(this)||this).method=f.A.GET,c.path="".concat(f.bi,"/").concat(d),c}return(0,f.c)(b,a),b}(f.h),eq=function(a){function b(b,c){var d=a.call(this,b,c)||this;return d.template=JSON.stringify(c),d}return(0,f.c)(b,a),b}(f.j),er={},es=function(){function a(a,b){var c=b.sdkState,d=b.dispatcher,e=b.requestQueue,f=b.onlineDetector,g=b.cacheContext;this._iid=a,this._sdkState=c,this._requestQueue=e,this._dispatcher=d,this._cacheContext=g,eg.of(a),ee.of(a),ek.of(a),this.fileMessageQueue=new ah(a,{sdkState:c,dispatcher:d,requestQueue:e,onlineDetector:f,cacheContext:g}),er[a]=this}return a.of=function(a){return er[a]},a.prototype._setSenderInfo=function(a){if(this._cacheContext.localCacheEnabled&&(a.messageType===f.at.USER||a.messageType===f.at.FILE)){var b=a.sender;if(b){var c=em.of(this._iid),d=c.getUserInfoFromCache(b.userId);if(d){var e=(0,f.d)((0,f.d)({},a.sender),{nickname:d.nickname,profileUrl:d.plainProfileUrl,requireAuth:d.requireAuth,metadata:d.metaData});a.sender=e}else c.upsert(new f.U(this._iid,f.U.payloadify(b)),a.createdAt)}}},a.prototype.buildMessageFromSerializedData=function(a){var b=(0,f.I)(a);if(b.notificationId)return new T(this._iid,T.payloadify(b));switch(this._setSenderInfo(b),b.messageType){case f.at.USER:return new R(this._iid,R.payloadify(b));case f.at.FILE:return S._isMultipleFilesMessageSerializedData(b)?new S(this._iid,S.payloadify(b)):new W(this._iid,W.payloadify(b));case f.at.ADMIN:return new O(this._iid,O.payloadify(b))}throw f.q.invalidParameters},a.prototype.buildUserMessageCreateParamsFromSerializedData=function(a,b){return(0,f.f)((0,f.g)({data:b.data,customType:b.customType,mentionType:b.mentionType,mentionedUserIds:b.mentionedUserIds,mentionedUsers:b.mentionedUsers,mentionedMessageTemplate:b.mentionedMessageTemplate,metaArrays:b.metaArrays,parentMessageId:b.parentMessageId,isReplyToChannel:a.isReplyToChannel,pushNotificationDeliveryOption:a.pushNotificationDeliveryOption,appleCriticalAlertOptions:b.appleCriticalAlertOptions,reqId:b.reqId,message:b.message,translationTargetLanguages:Object.keys(b.translations),pollId:a.pollId}))},a.prototype.buildFileMessageCreateParamsFromSerializedData=function(a,b){var c;return(0,f.f)((0,f.g)({data:b.data,customType:b.customType,mentionType:b.mentionType,mentionedUserIds:b.mentionedUserIds,mentionedUsers:b.mentionedUsers,metaArrays:b.metaArrays,parentMessageId:b.parentMessageId,isReplyToChannel:a.isReplyToChannel,pushNotificationDeliveryOption:a.pushNotificationDeliveryOption,appleCriticalAlertOptions:b.appleCriticalAlertOptions,reqId:b.reqId,file:a.file,fileKey:a.fileKey,fileUrl:b.plainUrl,fileName:b.name,fileSize:b.size,mimeType:b.type,thumbnailSizes:null===(c=b.thumbnails)|| void 0===c?void 0:c.map(function(a){return{maxWidth:a.width,maxHeight:a.height}}),fileType:a.fileType,requireAuth:b.requireAuth}))},a.prototype.buildMultipleFilesMessageCreateParamsFromSerializedData=function(a,b){var c=this;return(0,f.f)({data:b.data,customType:b.customType,mentionType:b.mentionType,mentionedUserIds:b.mentionedUserIds,mentionedUsers:b.mentionedUsers,metaArrays:b.metaArrays,parentMessageId:b.parentMessageId,isReplyToChannel:a.isReplyToChannel,pushNotificationDeliveryOption:a.pushNotificationDeliveryOption,appleCriticalAlertOptions:b.appleCriticalAlertOptions,reqId:b.reqId,fileInfoList:a.fileInfoList.map(function(a){return new X(c._iid,a)})})},a.prototype.buildScheduledUserMessageCreateParamsFromSerializedData=function(a,b){return(0,f.d)((0,f.d)({},this.buildUserMessageCreateParamsFromSerializedData(a,b)),{scheduledAt:a.scheduledAt})},a.prototype.buildScheduledFileMessageCreateParamsFromSerializedData=function(a,b){return(0,f.d)((0,f.d)({},this.buildFileMessageCreateParamsFromSerializedData(a,b)),{scheduledAt:a.scheduledAt})},a.prototype.buildSenderFromSerializedData=function(a){var b=(0,f.I)(a);return new r(this._iid,r.payloadify(b))},a.prototype.getMessage=function(a){return(0,f._)(this,void 0,void 0,function(){var b,c;return(0,f.b)(this,function(d){switch(d.label){case 0:return b=new ap(a),[4,this._requestQueue.send(b)];case 1:return[2,(c=d.sent()).as(aq).message]}})})},a.prototype.getScheduledMessage=function(a){return(0,f._)(this,void 0,void 0,function(){var b,c;return(0,f.b)(this,function(d){switch(d.label){case 0:return b=new av(a),[4,this._requestQueue.send(b)];case 1:return[2,(c=d.sent()).as(aw).message]}})})},a.prototype.getMessagesByMessageId=function(a,b,c,d,e){return void 0===e&&(e=f.ab.REQUEST_MESSAGE),(0,f._)(this,void 0,void 0,function(){var g,h,i;return(0,f.b)(this,function(j){switch(j.label){case 0:return g=new ar((0,f.d)((0,f.d)((0,f.d)({channelType:b,channelUrl:a,token:String(c)},ai),d),{sdkSource:ae.EXTERNAL_LEGACY})),[4,this._requestQueue.send(g)];case 1:return i=(h=j.sent()).as(as).messages,this._dispatcher.dispatch(new f.aP({messages:i,source:e})),[2,i]}})})},a.prototype.getMessagesByTimestamp=function(a,b,c,d,e){return void 0===e&&(e=f.ab.REQUEST_MESSAGE),(0,f._)(this,void 0,void 0,function(){var g,h,i;return(0,f.b)(this,function(j){switch(j.label){case 0:return g=new ar((0,f.d)((0,f.d)((0,f.d)({channelType:b,channelUrl:a,timestamp:c},ai),d),{sdkSource:ae.EXTERNAL_LEGACY})),[4,this._requestQueue.send(g)];case 1:return i=(h=j.sent()).as(as).messages,this._dispatcher.dispatch(new f.aP({messages:i,source:e})),[2,i]}})})},a.prototype._getMessagesByTimestampForCollection=function(a,b,c,d,e,g,h,i){return void 0===e&&(e=f.ab.REQUEST_MESSAGE),(0,f._)(this,void 0,void 0,function(){var j,k,l,m,n,o;return(0,f.b)(this,function(p){switch(p.label){case 0:return j=new ar((0,f.d)((0,f.d)((0,f.d)({channelType:b,channelUrl:a,timestamp:c},ai),d),{checkingHasNext:g,checkingContinuousMessages:h,sdkSource:i})),[4,this._requestQueue.send(j)];case 1:return m=(l=(k=p.sent()).as(as)).messages,n=l.isContinuousMessages,o=l.hasNext,this._dispatcher.dispatch(new f.aP({messages:m,source:e})),[2,{messages:m,isContinuousMessages:n,hasNext:o}]}})})},a.prototype.getThreadedMessagesByTimestamp=function(a,b,c,d){return void 0===d&&(d=f.ab.REQUEST_THREADED_MESSAGE),(0,f._)(this,void 0,void 0,function(){var e,g,h,i;return(0,f.b)(this,function(j){switch(j.label){case 0:return e=new ar((0,f.d)((0,f.d)((0,f.d)({channelUrl:a.channelUrl,channelType:a.channelType,timestamp:b},M),c),{replyType:f.aw.ALL,parentMessageId:a.messageId,includeThreadInfo:!0})),[4,this._requestQueue.send(e)];case 1:return(i=(h=(g=j.sent()).as(as).messages).slice(1)).forEach(function(b){b.parentMessage=a}),this._dispatcher.dispatch(new f.aP({messages:i,source:d})),[2,{parentMessage:h[0],threadedMessages:i}]}})})},a.prototype.getMessageTemplatesByToken=function(a,b){return void 0===b&&(b={}),(0,f._)(this,void 0,void 0,function(){var c,d,e,g,h,i;return(0,f.b)(this,function(j){switch(j.label){case 0:return c=new en((0,f.d)({token:a},b)),[4,this._requestQueue.send(c)];case 1:return g=(e=(d=j.sent()).as(eo)).hasMore,h=e.nextToken,i=e.templates,[2,{hasMore:g,token:h,templates:i}]}})})},a.prototype.getMessageTemplate=function(a){return(0,f._)(this,void 0,void 0,function(){var b,c;return(0,f.b)(this,function(d){switch(d.label){case 0:return b=new ep({key:a}),[4,this._requestQueue.send(b)];case 1:return[2,{template:(c=d.sent()).as(eq).template}]}})})},a.prototype.getMessageChangelogs=function(a,b,c,d,e){return void 0===e&&(e=f.ab.REQUEST_MESSAGE_CHANGELOGS),(0,f._)(this,void 0,void 0,function(){var g,h,i,j,k,l,m,n,o;return(0,f.b)(this,function(p){switch(p.label){case 0:return g=new at((0,f.f)((0,f.g)((0,f.d)((0,f.d)({channelType:b,channelUrl:a,timestamp:"number"==typeof c?c:null,token:"string"==typeof c?c:null},ak),d)))),[4,this._requestQueue.send(g)];case 1:return j=(i=(h=p.sent()).as(au)).updatedMessages,k=i.deletedMessagesInfo,l=i.hasMore,m=i.nextToken,n=i.forceUseNextToken,o=k.map(function(a){return a.messageId}),j.length>0&&this._dispatcher.dispatch(new f.aP({messages:j,source:e})),o.length>0&&this._dispatcher.dispatch(new f.bh({messageIds:o,source:e})),[2,{updatedMessages:j,deletedMessageIds:o,hasMore:l,token:m,forceUseNextToken:n}]}})})},a}(),et=function(a){function b(b,c){var d=a.call(this,b)||this;d.targetMessageId=0;var e=c.thread_info,g=c.parent_message_id,h=c.channel_url,i=c.channel_type;return e&&(0,f.a)("object",e)&&(0,f.a)("number",g)&&(0,f.a)("string",h)&&(0,f.a)("string",i)&&(d.threadInfo=new j(b,e),d.targetMessageId=g,d.channelUrl=h,d.channelType=i),d}return(0,f.c)(b,a),b}(f.aK)}}]) //# sourceMappingURL=0e5efccb.effadc69f79e94a6.js.map