PageSourceSearch

https://directdental.com/packs/js/sendbird-bdb4622c-75970923b26000c6ba83.chunk.js

js directdental.com collected 2026-10-04 15:28:36 UTC 286,482 bytes, 2 lines download raw bytes

1"use strict";(self.webpackChunkDDSJobs=self.webpackChunkDDSJobs||[]).push([[6389,8770,9556],{96389:function(e,t,n){n.d(t,{$:function(){return j},A:function(){return ii},B:function(){return rr},C:function(){return Yn},E:function(){return Wn},F:function(){return ar},I:function(){return ri},J:function(){return Se},L:function(){return ci},M:function(){return ui},N:function(){return An},P:function(){return Ne},S:function(){return Jn},T:function(){return li},U:function(){return $n},V:function(){return En},W:function(){return re},X:function(){return q},_:function(){return w},a:function(){return wn},a0:function(){return Ni},a1:function(){return F},a2:function(){return X},a3:function(){return ie},a4:function(){return xi},a5:function(){return l},a6:function(){return Nt},a7:function(){return yt},a8:function(){return zt},a9:function(){return qt},aA:function(){return pi},aB:function(){return mi},aC:function(){return _i},aD:function(){return vi},aE:function(){return Le},aF:function(){return Qn},aG:function(){return Qe},aH:function(){return De},aI:function(){return Be},aJ:function(){return xn},aK:function(){return Ce},aL:function(){return T},aM:function(){return U},aN:function(){return M},aO:function(){return on},aP:function(){return Gn},aQ:function(){return c},aR:function(){return u},aS:function(){return Ui},aT:function(){return h},aa:function(){return Lt},ab:function(){return Pt},ac:function(){return Dt},ad:function(){return In},ae:function(){return Q},af:function(){return A},ag:function(){return G},ah:function(){return Jt},ai:function(){return Xt},aj:function(){return Y},ak:function(){return Wt},al:function(){return ue},am:function(){return Mn},an:function(){return te},ao:function(){return Di},ap:function(){return he},aq:function(){return He},ar:function(){return We},as:function(){return Ye},at:function(){return Je},au:function(){return o},av:function(){return b},aw:function(){return v},ax:function(){return ne},ay:function(){return Bi},az:function(){return Fn},b:function(){return Tn},b7:function(){return y},b8:function(){return d},c:function(){return Un},d:function(){return yi},e:function(){return gi},f:function(){return Cn},g:function(){return hi},h:function(){return kn},i:function(){return On},j:function(){return Pn},k:function(){return Sn},l:function(){return Nn},m:function(){return fi},n:function(){return Rn},o:function(){return Dn},p:function(){return ai},q:function(){return ei},r:function(){return si},s:function(){return Gi},t:function(){return er},u:function(){return ji},v:function(){return wi},w:function(){return Ii},x:function(){return ni},y:function(){return oi},z:function(){return ur}});var r,i,s=n(22929),a=n(18130),o=function(){function e(e,t,n){var r,i;this.width=0,this.height=0,this.realWidth=0,this.realHeight=0,this._requireAuth=!1,this._iid=e,this.plainUrl=t.url,this.width=t.width,this.height=t.height,this.realWidth=null!==(r=t.real_width)&&void 0!==r?r:t.width,this.realHeight=null!==(i=t.real_height)&&void 0!==i?i:t.height,this._requireAuth=n}return e.payloadify=function(t){return(0,s.e)((0,s.u)(t instanceof e?{url:t.plainUrl,width:t.width,height:t.height,real_width:t.realWidth,real_height:t.realHeight}:{url:"",width:t.maxWidth,height:t.maxHeight,real_width:0,real_height:0}))},Object.defineProperty(e.prototype,"url",{get:function(){var e=s.V.of(this._iid).sessionManager;return this._requireAuth&&e.ekey?"".concat(this.plainUrl,"?auth=").concat(e.ekey):this.plainUrl},enumerable:!1,configurable:!0}),e}(),u=function(e){function t(t){var n=e.call(this)||this;if(n.method=s.A.POST,n.path="".concat(s.aj),n.params=(0,s.e)({file:t.file,channel_url:t.channelUrl}),t.thumbnailSizes)for(var r=0;r<t.thumbnailSizes.length;r++){var i=t.thumbnailSizes[r],a=i.maxWidth,o=i.maxHeight;n.params["thumbnail".concat(r+1)]="".concat(a,",").concat(o)}return n.requestId=t.requestId,n}return(0,s.c)(t,e),t}(s.f),c=function(e){function t(t,n){var r,i,s,a,u=this;return(u=e.call(this,t,n)||this).url=n.url,u.fileSize=null!==(r=n.file_size)&&void 0!==r?r:0,u.thumbnails=null!==(s=null===(i=n.thumbnails)||void 0===i?void 0:i.map(function(e){return new o(t,e,!1)}))&&void 0!==s?s:[],u.requireAuth=null!==(a=n.require_auth)&&void 0!==a&&a,u}return(0,s.c)(t,e),t}(s.g),l=function(e){function t(t,n){var r,i,a,o,u,c=this;return(c=e.call(this,t)||this).replyCount=0,c.memberCount=0,c.lastRepliedAt=0,c.updatedAt=0,c.replyCount=null!==(r=n.reply_count)&&void 0!==r?r:0,c.memberCount=null!==(i=n.member_count)&&void 0!==i?i:0,c.mostRepliedUsers=n.most_replies&&(0,s.$)("object",n.most_replies)?n.most_replies.map(function(e){return new s.U(c._iid,e)}):[],c.unreadReplyCount=null!==(a=n.unread_message_count)&&void 0!==a?a:0,c.isPushNotificationEnabled="number"==typeof n.push_enabled?n.push_enabled>0:void 0,c.lastRepliedAt=null!==(o=n.last_replied_at)&&void 0!==o?o:0,c.updatedAt=null!==(u=n.updated_at)&&void 0!==u?u:0,c}return(0,s.c)(t,e),t.payloadify=function(t){return(0,s.e)((0,s.u)((0,s.j)((0,s.j)({},e.payloadify.call(this,t)),{reply_count:t.replyCount,unread_message_count:t.unreadReplyCount,member_count:t.memberCount,most_replies:Array.isArray(t.mostRepliedUsers
1)?t.mostRepliedUsers.map(function(e){return s.U.payloadify(e)}):[],push_enabled:"boolean"==typeof t.isPushNotificationEnabled?t.isPushNotificationEnabled?1:0:void 0,last_replied_at:t.lastRepliedAt,updated_at:t.updatedAt})))},Object.defineProperty(t.prototype,"_isUpdateRequired",{get:function(){return void 0===this.unreadReplyCount||void 0===this.isPushNotificationEnabled},enumerable:!1,configurable:!0}),t.prototype._updateFrom=function(e){var t,n;this.unreadReplyCount=null!==(t=e.unreadReplyCount)&&void 0!==t?t:this.unreadReplyCount,this.isPushNotificationEnabled=null!==(n=e.isPushNotificationEnabled)&&void 0!==n?n:this.isPushNotificationEnabled},t}(s.ak);(i=r||(r={})).ADD="add",i.DELETE="delete";var d,h=function(e){var t;this.messageId=0,this.operation=null,this.updatedAt=0;var n=(0,s.a)("string",e.msg_id)?parseInt(e.msg_id):e.msg_id,i=e.user_id,a=e.operation?e.operation.toLowerCase():null,o=e.reaction,u=e.updated_at,c=e.count,l=e.sampled_user_ids,d=null!==(t=e.sampled_user_info)&&void 0!==t?t:{};n&&(0,s.a)("string",i)&&(0,s.a)("string",a)&&(0,s.a2)(r,a)&&(0,s.a)("string",o)&&o&&(0,s.a)("number",u)&&(this.messageId=n,this.userId=i,this.key=o,this.operation=a,this.updatedAt=u,this._count=c,this._sampledUserIds=l,this._sampledUserInfoList=d)},f=function(e){function t(t,n,r){var i,s=this;return(s=e.call(this,t)||this).userId=n,s.nickname=r.nickname,s.plainProfileUrl=r.profile_url,s.requireAuth=null!==(i=r.require_auth_for_profile_image)&&void 0!==i&&i,s}return(0,s.c)(t,e),Object.defineProperty(t.prototype,"profileUrl",{get:function(){var e=s.V.of(this._iid).sessionManager;return this.requireAuth&&e.ekey?"".concat(this.plainProfileUrl,"?auth=").concat(e.ekey):this.plainProfileUrl},enumerable:!1,configurable:!0}),t.payloadify=function(e){return{nickname:e.nickname,profile_url:e.plainProfileUrl,require_auth_for_profile_image:e.requireAuth}},t}(s.ak),p=function(e){function t(t,n){var r,i,a,o,u,c,l,d,h,p=this;(p=e.call(this,t)||this)._sampledUserInfoList=[],p._count=0,p._hasCurrentUserReacted=!1;var m=n.key,_=(0,s.q)([],(0,s.r)(null!==(o=null!==(a=n.sampled_user_ids)&&void 0!==a?a:n.user_ids)&&void 0!==o?o:[]),!1),v=null!==(c=null!==(u=n.last_ts)&&void 0!==u?u:n.updated_at)&&void 0!==c?c:0,y=null!==(l=n.is_self_included)&&void 0!==l?l:_.includes(s.V.of(t).sdkState.userId),g=null!==(d=n.sampled_user_info)&&void 0!==d?d:{};(0,s.a)("string",m)&&m&&(0,s.$)("string",_)&&_.length>0&&(0,s.a)("number",v)&&(p.key=m,p._sampledUserIds=_,p._updatedAt=v,p._count=null!==(h=n.count)&&void 0!==h?h:_.length,p._hasCurrentUserReacted=y,Object.keys(g).forEach(function(e){p._sampledUserInfoList.push(new f(t,e,g[e]))}));var b={};try{for(var I=(0,s.w)(p.sampledUserIds),E=I.next();!E.done;E=I.next())b[E.value]=p.updatedAt}catch(t){r={error:t}}finally{try{E&&!E.done&&(i=I.return)&&i.call(I)}finally{if(r)throw r.error}}return p._version=b,p}return(0,s.c)(t,e),Object.defineProperty(t.prototype,"isEmpty",{get:function(){return 0===this._count},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"userIds",{get:function(){return this._sampledUserIds},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"sampledUserIds",{get:function(){return this._sampledUserIds},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"sampledUserInfoList",{get:function(){return this._sampledUserInfoList},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"count",{get:function(){return this._count},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"updatedAt",{get:function(){return this._updatedAt},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"hasCurrentUserReacted",{get:function(){return this._hasCurrentUserReacted},enumerable:!1,configurable:!0}),t.payloadify=function(e){var t={};return e._sampledUserInfoList.forEach(function(e){t[e.userId]=f.payloadify(e)}),(0,s.e)((0,s.u)({key:e.key,sampled_user_ids:e._sampledUserIds,sampled_user_info:t,count:e._count,is_self_included:e._hasCurrentUserReacted,last_ts:e._updatedAt}))},t.prototype.applyEvent=function(e){var t=this;if(e.key===this.key&&this.updatedAt<=e.updatedAt)if(e._sampledUserIds)this._sampledUserIds=e._sampledUserIds,this._sampledUserInfoList=[],Object.keys(e._sampledUserInfoList).forEach(function(n){t._sampledUserInfoList.push(new f(t._iid,n,e._sampledUserInfoList[n]))}),this._count=e._count,void 0!==e._hasCurrentUserReacted&&(this._hasCurrentUserReacted=e._hasCurrentUserReacted),this._updatedAt=e.updatedAt;else{if(!this._version[e.userId]||this._version[e.userId]<=e.updatedAt){var n=this._sampledUserIds.indexOf(e.userId);switch(e.operation){case r.ADD:n<0&&this._sampledUserIds.push(e.userId);break;
1case r.DELETE:n>=0&&this._sampledUserIds.splice(n,1)}this._count=this._sampledUserIds.length,this._version[e.userId]=e.updatedAt}this._updatedAt=Math.max(this.updatedAt,e.updatedAt)}},t}(s.ak),m=function(){function e(e){this.secureUrl=null,this.type=null,this.width=0,this.height=0,this.alt=null,this.url=e.url,e.secure_url&&(this.secureUrl=e.secure_url),e.type&&(this.type=e.type),e.width&&(this.width=e.width),e.height&&(this.height=e.height),e.alt&&(this.alt=e.alt)}return e.payloadify=function(e){var t,n;return(0,s.e)((0,s.u)({url:e.url,secure_url:e.secureUrl,type:e.type,width:null!==(t=e.width)&&void 0!==t?t:0,height:null!==(n=e.height)&&void 0!==n?n:0,alt:e.alt}))},e}(),_=function(){function e(e){this.title=null,this.url=null,this.description=null,this.defaultImage=null,e["og:title"]&&(this.title=e["og:title"]),e["og:url"]&&(this.url=e["og:url"]),e["og:description"]&&(this.description=e["og:description"]),e["og:image"]&&(this.defaultImage=new m(e["og:image"]))}return e.payloadify=function(e){return(0,s.e)((0,s.u)({"og:title":e.title,"og:url":e.url,"og:description":e.description,"og:image":e.defaultImage?m.payloadify(e.defaultImage):null}))},e}(),v=function(){function e(e){var t,n;this.volume=0,this.name=null!==(t=e.name)&&void 0!==t?t:"default",this.volume=null!==(n=e.volume)&&void 0!==n?n:1}return e.prototype.serialize=function(){return{name:this.name,volume:this.volume}},e.payloadify=function(e){return(0,s.e)((0,s.u)({name:e.name,volume:e.volume}))},e}();!function(e){e.GOOD="good",e.BAD="bad"}(d||(d={}));var y=function(){function e(e){this.id=e.id,this.rating=e.rating,this.comment=e.comment}return e._getStatus=function(e){return e?"id"in e?"SUBMITTED":"NO_FEEDBACK":"NOT_APPLICABLE"},e._isSubmitted=function(t){return"SUBMITTED"===e._getStatus(t)},e._getPayloadByStatus=function(e){return"NO_FEEDBACK"===e?{}:null},e.payloadify=function(e){return(0,s.e)((0,s.u)({id:e.id,rating:e.rating,comment:e.comment}))},e}(),g=function(e){function t(t,n){var r,i=this;return(i=e.call(this,t,n)||this).isBlockedByMe=!1,i.role=(0,s.a2)(s.ad,n.role)?n.role:s.ad.NONE,i.isBlockedByMe=null!==(r=n.is_blocked_by_me)&&void 0!==r&&r,i}return(0,s.c)(t,e),t.payloadify=function(t){return(0,s.e)((0,s.u)((0,s.j)((0,s.j)({},e.payloadify.call(this,t)),{role:t.role,is_blocked_by_me:t.isBlockedByMe})))},t}(s.U),b=function(){function e(e){this.key=e.key,this.value=(0,s.$)("string",e.value)?(0,s.q)([],(0,s.r)(e.value),!1):[]}return e.payloadify=function(e){var t;return(0,s.e)((0,s.u)({key:e.key,value:null!==(t=e.value)&&void 0!==t?t:[]}))},e}(),I=function(e){switch(e){case s.am.BASE:return"";case s.am.USER:return"MESG";case s.am.FILE:return"FILE";case s.am.ADMIN:return"ADMM"}},E=function(e){function t(t,n){var r,i,a,o,u,c,l,d,h,f=this;(f=e.call(this,t)||this).channelType=s.C.BASE,f.messageType=s.am.BASE,f.mentionType=null,f.mentionedUsers=null,f.mentionedUserIds=null,f.metaArrays=[],f.extendedMessage={},f.createdAt=0,f.updatedAt=0,f.channelUrl=n.channel_url,f.channelType=(0,s.a2)(s.C,n.channel_type)?n.channel_type:s.C.GROUP,n.channel&&(n.channel.channel_url&&(f.channelUrl=n.channel.channel_url),n.channel.channel_type&&(f.channelType=n.channel.channel_type)),f.data=null!==(r=n.data)&&void 0!==r?r:"",f.customType=null!==(i=n.custom_type)&&void 0!==i?i:"",f.mentionType=(0,s.a2)(s.ao,n.mention_type)?n.mention_type:null,f.mentionedUsers=n.mentioned_users?n.mentioned_users.map(function(e){return new s.U(f._iid,e)}):null,f.mentionedUserIds=null!==(a=n.mentioned_user_ids)&&void 0!==a?a:null,f.mentionedUsers&&!f.mentionedUserIds&&(f.mentionedUserIds=f.mentionedUsers.map(function(e){return e.userId}));var p=null!==(o=n.metaarray)&&void 0!==o?o:{},m=null!==(u=n.metaarray_key_order)&&void 0!==u?u:Object.keys(p).sort(function(e,t){return e.localeCompare(t)});f.metaArrays=[];for(var _=0;_<m.length;_++){var v=m[_];f.metaArrays.push(new b({key:v,value:p[v]||[]}))}return n.sorted_metaarray&&(f.metaArrays=n.sorted_metaarray.map(function(e){return new b(e)})),f.extendedMessage=null!==(c=n.extended_message)&&void 0!==c?c:{},f.extendedMessagePayload=n.extended_message_payload,f.createdAt=null!==(d=null!==(l=n.created_at)&&void 0!==l?l:n.ts)&&void 0!==d?d:0,f.updatedAt=null!==(h=n.updated_at)&&void 0!==h?h:0,f}return(0,s.c)(t,e),t.payloadify=function(t){var n,r;return(0,s.e)((0,s.u)((0,s.j)((0,s.j)({},e.payloadify.call(this,t)),{channel_url:t.channelUrl,channel_type:t.channelType,type:I(t.messageType),data:t.data,custom_type:t.customType,mention_type:t.mentionType,mentioned_user_ids:t.mentionedUserIds,mentioned_users:null===(n=t.mentionedUsers)||void 0===n?void 0:n.map(function(e){return s.U.payloadify(e)}),sorted_metaarray:null===(r=t.metaArrays)||void 0===r?void 0:r.map(function(e){return b.payloadify(e)}),extended_message:t.extendedMessage,extended_message_payload:t.extendedMessagePayload,created_at:t.createdAt,updated_at:t.updatedAt})))},t.prototype.isIdentical=function(e){return!0},t.prototype.isEqual=function(e){return(0,s.al)(this,e)},t.prototype.isUserMessage=function(){return this.messageType===s.am.USER},t.prototype.isFileMessage=function(){return this.messageType===s.am.FILE&&!Object.prototype.hasOwnProperty.call(this,"fileInfoList")},t.prototype.isMultipleFilesMessage=function(){return this.messageType===s.am.FILE&&Object.prototype.hasOwnProperty.call(this,"fileInfoList")},t.prototype.isAdminMessage=function(){return this.messageType===s.am.ADMIN},t.prototype.serialize=function(){return(0,s.an)(this)},t.prototype.getMetaArraysByKeys=function(e){return this.metaArrays.filter(function(t){return e.includes(t.key)})},t}(s.ak),w=function(e){function t(t,n){var r,i,a,o=this;return(o=e.call(this,t)||this).channelUrl=null!==(r=n.channel_url)&&void 0!==r?r:"",o.channelType=null!==(i=n.channel_type)&&void 0!==i?i:s.C.GROUP,o.reader=new s.U(o._iid,n.user),o.readAt=n.ts,o.isExcluded=null!==(a=n.is_excluded)&&void 0!==a&&a,o}return(0,s.c)(t,e),t}(s.ak),T=function(e){function t(t){var n=t.channelUrl;return e.call(this,{code:"READ",ackRequired:!0,payload:{channel_url:n}})||this}return(0,s.c)(t,e),t}(s.ap),M=function(e){function t(t){var n=e.call(this)||this,r=t.channelUrl,i=t.channelType,a=t.userId,o=t.notificationIds,u=t.messageId,c=t.isExcluded,l=t.uniqueId;return n.method=s.A.PUT,n.path="".concat((0,s.aq)(i),"/").concat(encodeURIComponent(r),"/messages/mark_as_read"),n.params=(0,s.e)((0,s.u)({user_id:a,message_ids:o,message_id:u,is_excluded:c,unique_id:l})),n}return(0,s.c)(t,e),t}(s.f),A=function(e){function t(t,n,r){var i=e.call(this,t,"READ",r)||this;return i.readStatus=new w(t,r),i}return(0,s.c)(t,e),t}(s.W),U=function(e){function t(t,n){var r=e.call(this,t,n)||this;return r.readAt=n.ts,r.unreadMessageCount=n.unread_message_count,r.totalUnreadCount=n.total_unread_count,r.channelUrl=n.channel_url,r.userId=n.user_id,r.isExcluded=n.is_excluded,r.uniqueId=n.unique_id,r}return(0,s.c)(t,e),t}(s.g),S=function(e){function t(t){var n=t.channelUrl,r=t.messageId;return e.call(this,{code:"READ",ackRequired:!0,payload:{channel_url:n,parent_message_id:r}})||this}return(0,s.c)(t,e),t}(s.ap),N=function(e){function t(t){var n=t.channelType,r=t.channelUrl,i=t.messageId,a=t.pushEnabled,o=e.call(this)||this;return o.method=s.A.PUT,o.path="".concat((0,s.aq)(n),"/").concat(encodeURIComponent(r),"/messages/").concat(i,"/thread_push"),o.params={push_enabled:a},o}return(0,s.c)(t,e),t}(s.f);!function(e){(0,s.c)(function(t,n){return e.call(this,t,n)||this},e)}(s.g);var C=function(e){function t(t){var n=t.channelType,r=t.channelUrl,i=t.messageId,a=t.rating,o=t.comment,u=e.call(this)||this;return u.method=s.A.POST,u.path="".concat((0,s.aq)(n),"/").concat(encodeURIComponent(r),"/messages/").concat(i,"/feedbacks"),u.params={rating:a,comment:o},u}return(0,s.c)(t,e),t}(s.f),k=function(e){function t(t,n){var r=e.call(this,t,n)||this;return r.feedback=new y(n),r}return(0,s.c)(t,e),t}(s.g),O=function(e){function t(t){var n=t.channelType,r=t.channelUrl,i=t.messageId,a=t.feedbackId,o=t.rating,u=t.comment,c=e.call(this)||this;return c.method=s.A.PUT,c.path="".concat((0,s.aq)(n),"/").concat(encodeURIComponent(r),"/messages/").concat(i,"/feedbacks/").concat(a),c.params={rating:o,c
1omment:u},c}return(0,s.c)(t,e),t}(s.f),P=function(e){function t(t,n){var r=e.call(this,t,n)||this;return r.feedback=new y(n),r}return(0,s.c)(t,e),t}(s.g),R=function(e){function t(t){var n=t.channelType,r=t.channelUrl,i=t.messageId,a=t.feedbackId,o=e.call(this)||this;return o.method=s.A.DELETE,o.path="".concat((0,s.aq)(n),"/").concat(encodeURIComponent(r),"/messages/").concat(i,"/feedbacks/").concat(a),o}return(0,s.c)(t,e),t}(s.f);!function(e){(0,s.c)(function(t,n){var r=e.call(this,t,n)||this;return r.feedback=new y(n),r},e)}(s.g);var D,x,L=function(e){function t(t,n){var r,i,a,u,c,l=this;return(l=e.call(this,t)||this).plainUrl="",l.fileName=null,l.mimeType=null,l.fileSize=0,l.thumbnails=[],l._requireAuth=!1,l.plainUrl=null!==(r=n.url)&&void 0!==r?r:"",l.fileName=null!==(i=n.file_name)&&void 0!==i?i:null,l.mimeType=null!==(a=n.file_type)&&void 0!==a?a:null,l.fileSize=null!==(u=n.file_size)&&void 0!==u?u:0,l._requireAuth=null!==(c=n.require_auth)&&void 0!==c&&c,l.thumbnails=n.thumbnails?n.thumbnails.map(function(e){var t;return new o(l._iid,"string"==typeof e?{url:e,width:0,height:0}:(0,s.j)((0,s.j)({},e),{url:(null!==(t=e.url)&&void 0!==t?t:"").split("auth=")[0]}),l._requireAuth)}):[],l}return(0,s.c)(t,e),t.payloadify=function(e){var t;return(0,s.e)((0,s.u)({url:e.plainUrl,file_name:e.fileName,file_type:e.mimeType,file_size:e.fileSize,thumbnails:null===(t=e.thumbnails)||void 0===t?void 0:t.map(function(e){var t;return{url:(null!==(t=e.plainUrl)&&void 0!==t?t:"").split("auth=")[0],width:e.width,height:e.height,real_width:e.realWidth,real_height:e.realHeight}}),require_auth:e._requireAuth}))},Object.defineProperty(t.prototype,"url",{get:function(){var e=s.V.of(this._iid).sessionManager;return this._requireAuth&&e.ekey?"".concat(this.plainUrl,"?auth=").concat(e.ekey):this.plainUrl},enumerable:!1,configurable:!0}),t}(s.ak),F=function(e){var t=e.channelUrl,n=e.channelType,r=e.parentMessage;this.channelUrl=t,this.channelType=n,this.parentMessage=r};!function(e){e.NUMBER="number",e.ENUM="enum",e.TEXT="text",e.REGEX="regex",e.DECIMAL_PLACE="decimal_place"}(D||(D={})),function(e){e.TEXT="text",e.TEXTAREA="textarea",e.NUMBER="number",e.PHONE="phone",e.EMAIL="email",e.CHIP="chip"}(x||(x={}));var q,j,z=function(){function e(e,t){var n=t.id,r=t.name,i=t.items,s=t.ver
1sion,a=t.is_submitted;this.messageId=e,this.id=n,this.name=r,this.items=i.map(function(e){return new V(e)}).sort(function(e,t){return e.sortOrder-t.sortOrder}),this.version=null!=s?s:1,this._isSubmitted=a}return Object.defineProperty(e.prototype,"isSubmitted",{get:function(){var e;return null!==(e=this._isSubmitted)&&void 0!==e?e:this.items.some(function(e){return Array.isArray(e.submittedValues)})},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"isSubmittable",{get:function(){return this.items.every(function(e){return e.required?!!(Array.isArray(e.draftValues)&&e.draftValues.length>0)&&e.isValid(e.draftValues):!(Array.isArray(e.draftValues)&&e.draftValues.length>0)||e.isValid(e.draftValues)})},enumerable:!1,configurable:!0}),e.payloadify=function(e){return(0,s.e)((0,s.u)({id:e.id,name:e.name,items:e.items.map(function(e){return V.payloadify(e)}),version:e.version,is_submitted:e._isSubmitted}))},e.isMessageFormPayload=function(e){return Boolean(null==e?void 0:e.message_form)},e}(),V=function(){function e(e){var t=e.id,n=e.name,r=e.required,i=e.sort_order,a=e.placeholder,o=e.style,u=e.item_type,c=e.validators,l=e.value,d=e.values;this.id=t,this.name=n,this.required=r,this.sortOrder=i,this.placeholder=a,0===Object.keys(o).length?this.style={layout:u}:this.style=(0,s.e)({layout:o.layout,options:o.options,defaultOptions:o.default_options,resultCount:o.result_count}),d?this.submittedValues=d:l&&(this.submittedValues=[l]),this._validators=c}return e.prototype.isValid=function(e){var t=this;return e.every(function(e){var n=function(e,t){return t.every(function(t){switch(t.key){case D.NUMBER:var n=Number(e);return!(isNaN(n)||t.min&&"number"!=typeof t.min||t.max&&"number"!=typeof t.max||"number"==typeof t.min&&n<t.min||"number"==typeof t.max&&n>t.max);case D.ENUM:return"string"==typeof e&&(!(t.enums&&Array.isArray(t.enums)&&t.enums.length>0&&!t.enums.includes(e))||t.allow_other);case D.TEXT:return!("string"!=typeof e||"number"==typeof t.min_length&&e.length<t.min_length||"number"==typeof t.max_length&&e.length>t.max_length);case D.REGEX:if("string"!=typeof e)return!1;if(t.regex){if("string"!=typeof t.regex)return!1;if(!new RegExp(t.regex).test(e))return!1}return!0;case D.DECIMAL_PLACE:return 0!==e.length&&(n=Number(e),!(isNaN(n)||(!t.max_decimal_place||"number"==typeof t.max_decimal_place)&&t.max_decimal_place&&!function(e,t){var n=e.toString(),r=n.indexOf(".");return-1===r||n.slice(r+1).length<=t}(n,t.max_decimal_place)));default:return!0}})}(e,t._validators);return n})},e.payloadify=function(e){return(0,s.e)((0,s.u)({id:e.id,name:e.name,required:e.required,sort_order:e.sortOrder,placeholder:e.placeholder,style:(0,s.e)({layout:e.style.layout,options:e.style.options,default_options:e.style.defaultOptions,result_count:e.style.resultCount}),item_type:e.style.layout,validators:e._validators,values:e.submittedValues}))},e}(),B=function(e){function t(t){var n=e.call(this)||this;return n.method=s.A.POST,n.path="".concat(s.ar,"/").concat(t.formId,"/submit"),n.params=(0,s.e)({message_id:t.messageId,items:t.items}),n}return(0,s.c)(t,e),t}(s.f);!function(e){e.PENDING="pending",e.SENT="sent",e.FAILED="failed",e.CANCELED="canceled"}(q||(q={})),function(e){e.PENDING="pending",e.IN_QUEUE="in_queue",e.SENT="sent",e.FAILED="failed",e.CANCELED="canceled",e.REMOVED="removed"}(j||(j={}));var K,Q=function(e){function t(t,n){var r,i,s,o,u,c,d,h,f,m=this;return(m=e.call(this,t,n)||this).parentMessage=null,m.silent=!1,m.isOperatorMessage=!1,m.threadInfo=null,m.reactions=[],m.appleCriticalAlertOptions=null,m.scheduledInfo=null,m.suggestedReplies=null,m.myFeedback=null,m.myFeedbackStatus="NOT_APPLICABLE",m.messageForm=null,m._isContinuousMessages=!1,m._scheduledStatus=null,m._poll=null,m.messageId=null!==(i=null!==(r=n.msg_id)&&void 0!==r?r:n.message_id)&&void 0!==i?i:0,m.parentMessageId=null!==(s="string"==typeof n.parent_message_id?parseInt(n.parent_message_id):n.parent_message_id)&&void 0!==s?s:0,m.threadInfo=n.thread_info?new l(m._iid,n.thread_info):null,n.reactions_summary?m.reactions=n.reactions_summary.map(function(e){return new p(t,e)}):n.reactions?m.reactions=n.reactions.map(function(e){return new p(t,e)}):m.reactions=[],m.ogMetaData=n.og_tag?new _(n.og_tag):null,m.silent=null!==(o=n.silent)&&void 0!==o&&o,m.isOperatorMessage=null!==(u=n.is_op_msg)&&void 0!==u&&u,m.appleCriticalAlertOptions=n.apple_critical_alert_options?new v(n.apple_critical_alert_options):null,"number"==typeof n.scheduled_message_id&&"number"==typeof n.scheduled_at&&n.scheduled_status&&(m.scheduledInfo={sc
1heduledMessageId:n.scheduled_message_id,scheduledAt:n.scheduled_at},m._scheduledStatus=n.scheduled_status),m._isContinuousMessages=null!==(c=n.is_continuous_messages)&&void 0!==c&&c,m.myFeedback=y._isSubmitted(n.feedback)?new y(n.feedback):null,m.myFeedbackStatus=y._getStatus(n.feedback),m.suggestedReplies=null!==(h=null===(d=n.extended_message_payload)||void 0===d?void 0:d.suggested_replies)&&void 0!==h?h:null,m.messageForm=z.isMessageFormPayload(n.extended_message_payload)?new z(m.messageId,n.extended_message_payload.message_form):null,m.message=null!==(f=n.message)&&void 0!==f?f:"",m._poll=n.poll?new a.b(m._iid,n.poll):null,m}return(0,s.c)(t,e),t.payloadify=function(t){var n,r;return(0,s.e)((0,s.u)((0,s.j)((0,s.j)({},e.payloadify.call(this,t)),{message_id:t.messageId,parent_message_id:t.parentMessageId,thread_info:t.threadInfo?l.payloadify(t.threadInfo):null,reactions_summary:t.reactions.map(function(e){return p.payloadify(e)}),og_tag:t.ogMetaData?_.payloadify(t.ogMetaData):null,silent:t.silent,is_op_msg:t.isOperatorMessage,apple_critical_alert_options:t.appleCriticalAlertOptions?v.payloadify(t.appleCriticalAlertOptions):null,scheduled_message_id:null===(n=t.scheduledInfo)||void 0===n?void 0:n.scheduledMessageId,scheduled_at:null===(r=t.scheduledInfo)||void 0===r?void 0:r.scheduledAt,scheduled_status:t._scheduledStatus,feedback:t.myFeedback?y.payloadify(t.myFeedback):y._getPayloadByStatus(t.myFeedbackStatus),message:t.message,poll:t._poll?a.b.payloadify(t._poll):null})))},t._getParentMessageInfoPayload=function(e){return(0,s.e)((0,s.u)({type:I(e.messageType),ts:e.createdAt,user:e.sender?g.payloadify(e.sender):null,message:e.message,file:{url:e.plainUrl,name:e.name,type:e.type,require_auth:e.requireAuth},files:Array.isArray(e.fileInfoList)?e.fileInfoList.map(function(e){return L.payloadify(e)}):null}))},t.prototype.isIdentical=function(e){return this.messageId===e.messageId},t.prototype.applyThreadInfoUpdateEvent=function(e){return this.messageId===e.targetMessageId&&(e.threadInfo._isUpdateRequired&&this.threadInfo&&e.threadInfo._updateFrom(this.threadInfo),this.threadInfo=e.threadInfo,!0)},t.prototype._findReactionIndex=function(e){for(var t=0;t<this.reactions.length;t++)if(this.reactions[t].key===e)return t;return-1},t.prototype.applyReactionEvent=function(e){var t=s.V.of(this._iid).sdkState;if(this.messageId===e.messageId)switch(e.operation){case r.ADD:e.userId===t.userId&&(e._hasCurrentUserReacted=!0),-1!==(n=this._findReactionIndex(e.key))?this.reactions[n].applyEvent(e):e._sampledUserIds?this.reactions.push(new p(this._iid,{key:e.key,sampled_user_ids:e._sampledUserIds,sampled_user_info:e._sampledUserInfoList,count:e._count,is_self_included:e._hasCurrentUserReacted,last_ts:e.updatedAt})):this.reactions.push(new p(this._iid,{key:e.key,user_ids:[e.userId],updated_at:e.updatedAt}));break;case r.DELETE:var n;-1!==(n=this._findReactionIndex(e.key))&&(e._sampledUserIds?0===e._count?this.reactions.splice(n,1):(e.userId===t.userId&&(e._hasCurrentUserReacted=!1),this.reactions[n].applyEvent(e)):(this.reactions[n].applyEvent(e),this.reactions[n].isEmpty&&this.reactions.splice(n,1)))}},t.prototype.applyParentMessage=function(e){if(!this.parentMessage)return this.parentMessage=e,!0;if(this.parentMessageId===e.messageId){var t=this.parentMessage.updatedAt;if(e.updatedAt>=t)return this.parentMessage=e,!0}return!1},t.prototype.applyPoll=function(e){return!(this._poll&&this._poll.id===e.id&&this._poll.updatedAt>e.updatedAt)&&(this._poll=e,!0)},Object.defineProperty(t.prototype,"poll",{get:function(){return this._poll},enumerable:!1,configurable:!0}),t.prototype._triggerThreadInfoUpdatedEvent=function(){return(0,s._)(this,void 0,void 0,function(){var e;return(0,s.b)(this,function(t){return(e=s.V.of(this._iid).dispatcher).dispatch(new F({channelType:s.C.GROUP,channelUrl:this.channelUrl,parentMessage:this})),e.dispatch(new a.M({messages:[this],source:a.C.EVENT_MESSAGE_THREADINFO_UPDATED})),[2]})})},t.prototype.markThreadAsRead=function(){return(0,s._)(this,void 0,void 0,function(){var e,t;return(0,s.b)(this,function(n){switch(n.label){case 0:return e=s.V.of(this._iid).requestQueue,t=new S({channelUrl:this.channelUrl,messageId:this.messageId}),[4,e.send(t)];case 1:return n.sent(),this.threadInfo&&0!==this.threadInfo.unreadReplyCount?(this.threadInfo.unreadReplyCount=0,[4,this._triggerThreadInfoUpdatedEvent()]):[3,3];case 2:n.sent(),n.label=3;case 3:return[2]}})})},t.prototype.setPushNotificationEnabled=function(e){return(0,s._)(this,void 0,void 0,function(){var t,n;return(0,s.b)(this,function(r){switch(r.label){case 0:return t=s.V.of(this._iid).requestQueue,n=new N({channelUrl:this.channelUrl,channelType:this.channelType,messageId:this.messageId,pushEnabled:e}),[4,t.send(n)];case 1:return r.sent(),this.threadInfo&&this.threadInfo.isPushNotificationEnabled!==e&&(this.threadInfo.isPushNotificationEnabled=e),[2]}})})},t.prototype.submitMessageForm=function(e){return(0,s._)(this,void 0,void 0,function(){var t,n,r,i,a;return(0,s.b)(this,function(o){switch(o.label){case 0:if(t=s.V.of(this._iid).requestQueue,n=null,r=null,i=this.messageForm,!e&&i){if(!i.isSubmittable)throw new s.t({code:s.D.INVALID_PARAMETER,message:"The form is not submittable. Please check all form items are valid before submitting."});if(i.isSubmitted)throw new s.t({code:s.D.INVALID_PARAMETER,message:"The form has already been submitted."});n=i.id,r=i.items.reduce(function(e,t){return e.push({form_item_id:t.id,values:Array.isArray(t.draftValues)?t.draftValues:[]}),e},[])}
1else e&&(n=e.formId,r=Object.entries(e.answers).reduce(function(e,t){var n=(0,s.r)(t,2),r=n[0],i=n[1],a=Number(r);if(Number.isNaN(a))throw new s.t({code:s.D.INVALID_PARAMETER,message:"Keys in answers must be numeric string."});return e.push({form_item_id:a,value:i}),e},[]));if(!n||!r)throw new s.t({code:s.D.INVALID_PARAMETER,message:"Missing one or more required inputs: formId, answers."});return a=new B({messageId:this.messageId,formId:n,items:r}),[4,t.send(a)];case 1:return o.sent(),[2]}})})},t.prototype.submitFeedback=function(e){return(0,s._)(this,void 0,void 0,function(){var t,n,r,i,o,u;return(0,s.b)(this,function(c){switch(c.label){case 0:return t=s.V.of(this._iid),n=t.requestQueue,r=t.dispatcher,i=new C({channelUrl:this.channelUrl,channelType:this.channelType,messageId:this.messageId,rating:e.rating,comment:e.comment}),[4,n.send(i)];case 1:return o=c.sent(),u=o.as(k),this.myFeedback=u.feedback,this.myFeedbackStatus="SUBMITTED",r.dispatch(new a.M({messages:[this],source:a.C.EVENT_MESSAGE_FEEDBACK_ADDED})),[2]}})})},t.prototype.updateFeedback=function(e){return(0,s._)(this,void 0,void 0,function(){var t,n,r,i,o,u;return(0,s.b)(this,function(c){switch(c.label){case 0:return t=s.V.of(this._iid),n=t.requestQueue,r=t.dispatcher,i=new O({channelUrl:this.channelUrl,channelType:this.channelType,messageId:this.messageId,feedbackId:e.id,rating:e.rating,comment:e.comment}),[4,n.send(i)];case 1:return o=c.sent(),u=o.as(P),this.myFeedback=u.feedback,this.myFeedbackStatus="SUBMITTED",r.dispatch(new a.M({messages:[this],source:a.C.EVENT_MESSAGE_FEEDBACK_UPDATED})),[2]}})})},t.prototype.deleteFeedback=function(e){return(0,s._)(this,void 0,void 0,function(){var t,n,r,i;return(0,s.b)(this,function(o){switch(o.label){case 0:return t=s.V.of(this._iid),n=t.requestQueue,r=t.dispatcher,i=new R({channelUrl:this.channelUrl,channelType:this.channelType,messageId:this.messageId,feedbackId:e}),[4,n.send(i)];case 1:return o.sent(),this.myFeedback=null,this.myFeedbackStatus="NO_FEEDBACK",r.dispatch(new a.M({messages:[this],source:a.C.EVENT_MESSAGE_FEEDBACK_DELETED})),[2]}})})},t}(E),G=function(e){function t(t,n){var r,i,a,o,u=this;if((u=e.call(this,t,n)||this).reqId="",u.replyToChannel=!1,u.errorCode=0,u.sender=n.user?new g(u._iid,n.user):n.sender_id,u.reqId=null!==(i=null!==(r=n.req_id)&&void 0!==r?r:n.request_id)&&void 0!==i?i:"",u.replyToChannel=null!==(a=n.is_reply_to_channel)&&void 0!==a&&a,n.request_state&&(0,s.a2)(s.as,n.request_state)&&(u.sendingStatus=n.request_state),!u.sendingStatus)if(u.messageId>0)u.sendingStatus=s.as.SUCCEEDED;else if(u.scheduledInfo)switch(n.scheduled_status&&(u._scheduledStatus=n.scheduled_status),n.scheduled_status){case j.SENT:case j.IN_QUEUE:u.sendingStatus=s.as.SUCCEEDED;break;case j.PENDING:u.sendingStatus=s.as.SCHEDULED;break;case j.FAILED:case j.REMOVED:u.sendingStatus=s.as.FAILED;break;case j.CANCELED:u.sendingStatus=s.as.CANCELED}else u.sendingStatus=s.as.PENDING;return u.errorCode=null!==(o=n.error_code)&&void 0!==o?o:0,u._messageToken=n.mesg_token,u}return(0,s.c)(t,e),t.payloadify=function(t){return(0,s.e)((0,s.u)((0,s.j)((0,s.j)({},e.payloadify.call(this,t)),{user:g.payloadify(t.sender),req_id:t.reqId,is_reply_to_channel:t.replyToChannel,request_state:t.sendingStatus,error_code:t.errorCode,mesg_token:t._messageToken})))},Object.defineProperty(t.prototype,"isResendable",{get:function(){return(this.sendingStatus===s.as.FAILED||this.sendingStatus===s.as.CANCELED)&&(0,s.at)(this.errorCode)},enumerable:!1,configurable:!0}),t.prototype.isIdentical=function(e){return this.messageId>0&&e.messageId>0?this.messageId===e.messageId:this.reqId===e.reqId},t}(Q),H={prevResultSize:0,nextResultSize:0,isInclusive:!1,reverse:!1,messageTypeFilter:s.au.ALL,customTypesFilter:void 0,senderUserIdsFilter:void 0,includeReactions:!1,includeMetaArray:!1,includeParentMessageInfo:!1},W=function(e){return(0,s.a)("number",e.prevResultSize)&&(0,s.a)("number",e.nextResultSize)&&(0,s.a)("boolean",e.isInclusive)&&(0,s.a)("boolean",e.reverse)&&(0,s.a)("string",e.messageTypeFilter)&&(0,s.a2)(s.au,e.messageTypeFilter)&&(0,s.$)("string",e.customTypesFilter,!0)&&(0,s.$)("string",e.senderUserIdsFilter,!0)&&(0,s.a)("boolean",e.includeMetaArray)&&(0,s.a)("boolean",e.includeReactions)&&(0,s.a)("boolean",e.includeParentMessageInfo)},Y=function(e){function t(t,n){var r,i,a,o=this;if((o=e.call(this,t,n)||this).translations={},o.messageType=s.am.ADMIN,o.translations=null!==(r=n.translations)&&void 0!==r?r:{},n.parent_message_info){var u=n.parent_message_info;o.parentMessage=re(t,(0,s.e)((0,s.u)((0,s.j)((0,s.j)({},u),{message_id:o.parentMessageId,channel_url:o.channelUrl,channel_type:o.channelType,file:u.file,url:null===(i=u.file)||void 0===i?void 0:i.url,require_auth:null===(a=u.file)||void 0===a?void 0:a.require_auth}))))}return o}return(0,s.c)(t,e),t.payloadify=function(t){return(0,s.e)((0,s.u)((0,s.j)((0,s.j)({},e.payloadify.call(this,t)),{translations:t.translations,parent_message_info:t.parentMessage?e._getParentMessageInfoPayload.call(this,t.parentMessage):null})))},t.prototype.getThreadedMessagesByTimestamp=function(e,t){return(0,s._)(this,void 0,void 0,function(){var n;return(0,s.b)(this,function(r){switch(r.label){case 0:return n=(0,s.j)((0,s.j)({},H),t),(0,s.F)(this.messageId>0&&(0,s.a)("number",e)&&W(n)).throw(s.t.invalidParameters),[4,Di.of(this._iid).getThreadedMessagesByTimestamp(this,e,n)];case 1:return[2,r.sent()]}})})},t}(Q),J=function(){function e(e){var t,n;this.detail={},this.type=null!==(t=e.type)&&void 0!==t?t:"",this.vendor=null!==(n=e.vendor)&&void 0!==n?n:"",e.detail&&(0,s.a)("object",e.detail)&&!Array.isArray(e.detail)&&(this.detail=e.detail)}return e.payloadify=function(e){return(0,s.e)((0,s.u)({type:e.type,vendor:e.vend
1or,detail:e.detail}))},e}(),$=function(){function e(e){this.status=e.status,e.original_message_info&&(this.originalMessageInfo={createdAt:e.original_message_info.ts,messageId:e.original_message_info.id})}return e.payloadify=function(e){return(0,s.e)({status:e.status,original_message_info:e.originalMessageInfo?{id:e.originalMessageInfo.messageId,ts:e.originalMessageInfo.createdAt}:void 0})},e}(),X=function(e){function t(t,n){var r,a,o,u,c,l,d,h=this;if((h=e.call(this,t,n)||this).messageParams=null,h.mentionedMessageTemplate=void 0,h.translations={},h.translationTargetLanguages=[],h.messageSurvivalSeconds=-1,h.plugins=[],h.messageType=s.am.USER,h.translations=null!==(o=n.translations)&&void 0!==o?o:{},h.translationTargetLanguages=null!==(u=n.target_langs)&&void 0!==u?u:[],0===Object.keys(h.translations).length&&h.translationTargetLanguages.length>0)try{for(var f=(0,s.w)(h.translationTargetLanguages),p=f.next();!p.done;p=f.next()){var m=p.value;h.translations[m]=""}}catch(i){r={error:i}}finally{try{p&&!p.done&&(a=f.return)&&a.call(f)}finally{if(r)throw r.error}}if(h.mentionedMessageTemplate=n.mentioned_message_template,h.messageSurvivalSeconds=null!==(c=n.message_survival_seconds)&&void 0!==c?c:-1,h.plugins=n.plugins?n.plugins.map(function(e){return new J(e)}):[],n.parent_message_info){var _=n.parent_message_info;h.parentMessage=re(t,(0,s.e)((0,s.u)((0,s.j)((0,s.j)({},_),{created_at:_.ts,message_id:h.parentMessageId,channel_url:h.channelUrl,channel_type:h.channelType,file:_.file,url:null===(l=_.file)||void 0===l?void 0:l.url,require_auth:null===(d=_.file)||void 0===d?void 0:d.require_auth}))))}return n.review_info&&(h.messageReviewInfo=new $(n.review_info)),h}return(0,s.c)(t,e),t.payloadify=function(t){return(0,s.e)((0,s.u)((0,s.j)((0,s.j)({},e.payloadify.call(this,t)),{translations:t.translations,message_survival_seconds:t.messageSurvivalSeconds,mentioned_message_template:t.mentionedMessageTemplate,plugins:t.plugins.map(function(e){return J.payloadify(e)}),parent_message_info:t.parentMessage?e._getParentMessageInfoPayload.call(this,t.parentMessage):null,review_info:t.messageReviewInfo?$.payloadify(t.messageReviewInfo):void 0})))},t.prototype.getThreadedMessagesByTimestamp=function(e,t){return(0,s._)(this,void 0,void 0,function(){var n;return(0,s.b)(this,function(r){switch(r.label){case 0:return n=(0,s.j)((0,s.j)({},H),t),(0,s.F)(this.messageId>0&&(0,s.a)("number",e)&&W(n)).throw(s.t.invalidParameters),[4,Di.of(this._iid).getThreadedMessagesByTimestamp(this,e,n)];case 1:return[2,r.sent()]}})})},t}(G),Z=function(e){function t(t,n){var r,i,a,o,u,c,l,d,h=this;if((h=e.call(this,t,n)||this).messageParams=null,h.fileInfoList=[],h.messageSurvivalSeconds=-1,h.messageType=s.am.FILE,h.data=null!==(a=null!==(i=null===(r=n.file)||void 0===r?void 0:r.data)&&void 0!==i?i:n.custom)&&void 0!==a?a:"",h.fileInfoList=null!==(u=null===(o=n.files)||void 0===o?void 0:o.map(function(e){return new L(t,e)}))&&void 0!==u?u:[],h.messageSurvivalSeconds=null!==(c=n.message_survival_seconds)&&void 0!==c?c:-1,n.parent_message_info){var f=n.parent_message_info;h.parentMessage=re(t,(0,s.e)((0,s.u)((0,s.j)((0,s.j)({},f),{created_at:f.ts,message_id:h.parentMessageId,channel_url:h.channelUrl,channel_type:h.channelType,file:f.file,url:null===(l=f.file)||void 0===l?void 0:l.url,require_auth:null===(d=f.file)||void 0===d?void 0:d.require_auth}))))}return h}return(0,s.c)(t,e),t.prototype.getThreadedMessagesByTimestamp=function(e,t){return(0,s._)(this,void 0,void 0,function(){var n;return(0,s.b)(this,function(r){switch(r.label){case 0:return n=(0,s.j)((0,s.j)({},H),t),(0,s.F)(this.messageId>0&&(0,s.a)("number",e)&&W(n)).throw(s.t.invalidParameters),[4,Di.of(this._iid).getThreadedMessagesByTimestamp(this,e,n)];case 1:return[2,r.sent()]}})})},t.payloadify=function(t){var n,r,i,a,o,u;return(0,s.e)((0,s.u)((0,s.j)((0,s.j)({},e.payloadify.call(this,t)),{file:{name:null!==(r=null===(n=t.fileInfoList[0])||void 0===n?void 0:n.fileName)&&void 0!==r?r:"",size:null!==(a=null===(i=t.fileInfoList[0])||void 0===i?void 0:i.fileSize)&&void 0!==a?a:0,type:null!==(u=null===(o=t.fileInfoList[0])||void 0===o?void 0:o.mimeType)&&void 0!==u?u:"",data:t.data},files:Array.isArray(t.fileInfoList)?t.fileInfoList.map(function(e){return L.payloadify(e)}):null,message_survival_seconds:t.messageSurvivalSeconds,parent_message_info:t.parentMessage?e._getParentMessageInfoPayload.call(this,t.parentMessage):null})))},t._isMultipleFilesMessagePayload=function(e){var t=e.files;return Array.isArray(t)&&t.length>=2},t._isMultipleFilesMessageSerializedData=function(e){var t=e.fileInfoList;return Array.isArray(t)},t}(G);!function(e){e.SENT="SENT",e.READ="READ"}(K||(K={}));var ee,te=function(e){function t(t,n){var r,i,a=this;if((a=e.call(this,t,n)||this).notificationData=null,a.notificationId=n.notification_message_id,a.messageType=s.am.ADMIN,a.messageStatus=null!==(r=n.message_status)&&void 0!==r?r:K.SENT,a.priority=null!==(i=n.priority)&&void 0!==i?i:s.av.NORMAL,a.notificationEventDeadline=n.notification_event_deadline,0===a.extendedMessage.sub_type)try{var o=JSON.parse(a.extendedMessage.sub_data),u=o.label,c=o.tags,l=void 0===c?[]:c,d=o.template_key,h=o.template_variables;a.notificationData={label:u,tags:l,templateKey:d,templateVariables:h}}catch(t){}return a}return(0,s.c)(t,e),t.payloadify=function(t){return(0,s.e)((0,s.u)((0,s.j)((0,s.j)({},e.payloadify.call(this,t)),{notification_message_id:t.notificationId,message_status:t.messageStatus,priority:t.priority,notification_event_deadline:t.notificationEventDeadline})))},t.prototype.isIdentical=function(e){return this.notificationId===e.notificationId},t}(E),ne=function(e){if(e.notificationId)return te.payloadify(e);switch(e.messageType){case s.am.USER:return X.payloadify(e);case s.am.FILE:return e.fileInfoList?Z.payloadify(e):ie.payloadify(e);case s.am.ADMIN:return Y.payloadify(e);default:throw s.t.unknown}},re=function(e,t){if(t.notification_message_id)return new te(e,t);switch(t.type){case"MESG":return new X(e,t);case"FILE":return Z._isMultipleFilesMessagePayload(t)?new Z(e,t):new ie(e,t);case"ADMM":case"BRDM":return new Y(e,t);default:return null}},ie=function(e){function t(t,n){var r,i,a,u,c,l,d,h,f,p,m,_,v,y,g=this;(g=e.call(this,t,n)||this).messageParams=null,g.plainUrl="",g.requireAuth=!1,g.thumbnails=[],g.messageSurvivalSeconds=-1,g.messageType=s.am.FILE;var b=n.file;if(g.plainUrl=(null!==(i=null!==(r=null==b?void 0:b.url)&&void 0!==r?r:n.url)&&void 0!==i?i:"").split("?auth=")[0],g.name=null!==(u=null!==(a=null==b?void 0:b.name)&&void 0!==a?a:n.name)&&void 0!==u?u:"File",g.size=null!==(l=null!==(c=null==b?void 0:b.size)&&void 0!==c?c:n.size)&&void 0!==l?l:0,g.data=null!==(h=null!==(d=null==b?void 0:b.data)&&void 0!==d?d:n.custom)&&void 0!==h?h:"",g.type=b?null!==(f=b.type)&&void 0!==f?f:"":null!==(p=n.type)&&void 0!==p?p:"",g.requireAuth=null!==(m=n.require_auth)&&void 0!==m&&m,g.thumbnails=n.thumbnails?n.thumbnails.map(function(e){var t;return new o(g._iid,"string"==typeof e?{url:e,width:0,height:0}:(0,s.j)((0,s.j)({},e),{url:(null!==(t=e.url)&&void 0!==t?t:"").split("auth=")[0]}),g.requireAuth)}):[],g.messageSurvivalSeconds=null!==(_=n.message_survival_seconds)&&void 0!==_?_:-1,n.parent_message_info){var I=n.parent_message_info;g.parentMessage=re(t,(0,s.e)((0,s.u)((0,s.j)((0,s.j)({},I),{created_at:I.ts,message_id:g.parentMessageId,channel_url:g.channelUrl,channel_type:g.channelType,file:I.file,url:null===(v=I.file)||void 0===v?void 0:v.url,require_auth:null===(y=I.file)||void 0===y?void 0:y.require_auth}))))}return g}return(0,s.c)(t,e),t.payloadify=function(t){var n;return(0,s.e)((0,s.u)((0,s.j)((0,s.j)({},e.payloadify.call(this,t)),{url:t.plainUrl,require_auth:t.requireAuth,file:{name:t.name,size:t.size,type:t.type,data:t.data},thumbnails:null===(n=t.thumbnails)||void 0===n?void 0:n.map(function(e){return{url:e.plainUrl,width:e.width,height:e.height,real_width:e.realWidth,real_height:e.realHeight}}),message_survival_seconds:t.messageSurvivalSeconds,parent_message_info:t.parentMessage?e._getParentMessageInfoPayload.call(this,t.parentMessage):null})))},Object.defineProperty(t.prototype,"url",{get:function(){var e=s.V.of(this._iid).sessionManager;return this.requireAuth&&e.ekey?"".concat(this.plainUrl,"?auth=").concat(e.ekey):this.plainUrl}
1,enumerable:!1,configurable:!0}),t.prototype.getThreadedMessagesByTimestamp=function(e,t){return(0,s._)(this,void 0,void 0,function(){var n;return(0,s.b)(this,function(r){switch(r.label){case 0:return n=(0,s.j)((0,s.j)({},H),t),(0,s.F)(this.messageId>0&&(0,s.a)("number",e)&&W(n)).throw(s.t.invalidParameters),[4,Di.of(this._iid).getThreadedMessagesByTimestamp(this,e,n)];case 1:return[2,r.sent()]}})})},t}(G),se=function(e){function t(t,n){var r=n.file,i=n.fileUrl,s=n.fileName,a=n.fileSize,o=n.mimeType,u=n.thumbnailSizes,c=n._uploadedMetaData,l=n._thumbnails,d=e.call(this,t)||this;return d._plainUrl=i,d.file=r,d.fileName=s,d.fileSize=a,d.mimeType=o,d.thumbnailSizes=u,d._uploadedMetaData=c,d._thumbnails=l,d}return(0,s.c)(t,e),t.getPlainUrl=function(e){return e instanceof t?e._plainUrl:e.fileUrl},Object.defineProperty(t.prototype,"fileUrl",{get:function(){var e,t=s.V.of(this._iid).sessionManager;return this._plainUrl&&(null===(e=this._uploadedMetaData)||void 0===e?void 0:e.requireAuth)&&t.ekey?"".concat(this._plainUrl,"?auth=").concat(t.ekey):this._plainUrl},set:function(e){this._plainUrl=e},enumerable:!1,configurable:!0}),t.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}},t}(s.ak),ae=function(e){function t(t){var n,r,i,a,u=[];return t.mentionType===s.ao.USERS&&(t.mentionedUserIds?u=t.mentionedUserIds:t.mentionedUsers&&(u=t.mentionedUsers.map(function(e){return e.userId}))),e.call(this,{code:"FILE",ackRequired:!0,payload:(0,s.e)((0,s.u)({channel_url:t.channelUrl,files:t.files?le(t.files):null,url:t.url,name:null!==(n=t.fileName)&&void 0!==n?n:"",type:null!==(r=t.mimeType)&&void 0!==r?r:"",size:null!==(i=t.fileSize)&&void 0!==i?i:0,custom:t.data,custom_type:t.customType,thumbnails:null===(a=t._thumbnails)||void 0===a?void 0:a.map(function(e){return o.payloadify(e)}),require_auth:t.requireAuth,metaarray:t.metaArrays,mention_type:t.mentionType,mentioned_user_ids:u,push_option:t.pushNotificationDeliveryOption&&t.pushNotificationDeliveryOption!==s.aw.DEFAULT?t.pushNotificationDeliveryOption:void 0,apple_critical_alert_options:t.appleCriticalAlertOptions?v.payloadify(t.appleCriticalAlertOptions):null,silent:t.silent,reply_to_channel:t.isReplyToChannel,parent_message_id:t.parentMessageId?t.parentMessageId:null,req_id:t.reqId,poll_id:t.pollId,pin_message:t.isPinnedMessage,message:t.message}))})||this}return(0,s.c)(t,e),t}(s.ap),oe=function(e){function t(t){var n,r,i=this;i=e.call(this)||this;var a=[];return t.mentionType===s.ao.USERS&&(t.mentionedUserIds?a=t.mentionedUserIds:t.mentionedUsers&&(a=t.mentionedUsers.map(function(e){return e.userId}))),i.method=s.A.POST,i.path="".concat((0,s.aq)(t.channelType),"/").concat(encodeURIComponent(t.channelUrl),"/messages"),i.params=(0,s.e)((0,s.u)({message_type:s.am.FILE,user_id:t.userId,files:t.files?le(t.files):null,url:t.fileUrl,mention_type:t.mentionType,mentioned_user_ids:a,file_name:t.fileName,file_size:t.fileSize,file_type:t.mimeType,data:t.data,custom_type:t.customType,thumbnails:null===(n=t._thumbnails)||void 0===n?void 0:n.map(function(e){return o.payloadify(e)}),require_auth:t.requireAuth,sorted_metaarray:null===(r=t.metaArrays)||void 0===r?void 0:r.map(function(e){return b.payloadify(e)}),push_option:t.pushNotificationDeliveryOption,parent_message_id:t.parentMessageId?t.parentMessageId:null,apple_critical_alert_options:t.appleCriticalAlertOptions?v.payloadify(t.appleCriticalAlertOptions):null,reply_to_channel:t.isReplyToChannel,req_id:t.reqId,poll_id:t.pollId,pin_message:t.isPinnedMessage})),i}return(0,s.c)(t,e),t}(s.f),ue=function(e){function t(t,n,r){var i,a,o,u,c=this;(c=e.call(this,t,"FILE",r)||this).message=r.files&&r.files.length>=2?new Z(t,r):new ie(t,r);var l=s.V.of(t).sdkState;return c.isMentioned=(0,s.ax)(c.message.mentionType,null!==(o=null!==(i=c.message.mentionedUserIds)&&void 0!==i?i:null===(a=c.message.mentionedUsers)||void 0===a?void 0:a.map(function(e){return e.userId}
1))&&void 0!==o?o:[],l.userId),c.forceUpdateLastMessage=null!==(u=r.force_update_last_message)&&void 0!==u&&u,c}return(0,s.c)(t,e),t}(s.W),ce=function(e){function t(t,n){var r,i,a,o,u=this;(u=e.call(this,t,n)||this).message=n.files&&n.files.length>=2?new Z(t,n):new ie(t,n);var c=s.V.of(t).sdkState;return u.isMentioned=(0,s.ax)(u.message.mentionType,null!==(a=null!==(r=u.message.mentionedUserIds)&&void 0!==r?r:null===(i=u.message.mentionedUsers)||void 0===i?void 0:i.map(function(e){return e.userId}))&&void 0!==a?a:[],c.userId),u.forceUpdateLastMessage=null!==(o=n.force_update_last_message)&&void 0!==o&&o,u}return(0,s.c)(t,e),t}(s.g);function le(e){return e.map(function(e){var t,n;return(0,s.e)((0,s.u)({url:se.getPlainUrl(e),file_name:e.fileName,file_type:e.mimeType,file_size:e.fileSize,thumbnails:null===(t=e._thumbnails)||void 0===t?void 0:t.map(function(e){return o.payloadify(e)}),require_auth:null===(n=e._uploadedMetaData)||void 0===n?void 0:n.requireAuth}))})}!function(e){e[e.PENDING=0]="PENDING",e[e.UPLOADING=1]="UPLOADING",e[e.UPLOADED=2]="UPLOADED",e[e.SENDING=3]="SENDING",e[e.FAILED=4]="FAILED"}(ee||(ee={}));var de,he,fe=function(){function e(e,t){var n=t.sdkState,r=t.dispatcher,i=t.requestQueue,a=t.onlineDetector,o=t.cacheContext,u=this;this._queueMap=new Map,this._iid=e,this._sdkState=n,this._requestQueue=i,this._cacheContext=o,this._dispatcher=r,this._dispatcher.on(function(e){e instanceof s.I&&(u._connectionState=e.stateType)}),this._onlineDetector=a}return Object.defineProperty(e.prototype,"_shouldSendThroughWebSocket",{get:function(){return this._connectionState===s.J.CONNECTED||this._connectionState===s.J.CONNECTING||this._connectionState===s.J.RECONNECTING},enumerable:!1,configurable:!0}),e.prototype._sendFileMessage=function(e,t){return(0,s._)(this,void 0,void 0,function(){var n,r;return(0,s.b)(this,function(i){switch(i.label){case 0:return n=this._createSendFileMessageRequestParam
1s(e,t),this._shouldSendThroughWebSocket?(r=new ae(n),[4,this._requestQueue.send(r)]):[3,2];case 1:return[2,i.sent().as(ue).message];case 2:return r=new oe((0,s.j)((0,s.j)({},n),{userId:this._sdkState.userId})),[4,this._requestQueue.send(r)];case 3:return[2,i.sent().as(ce).message]}})})},e.prototype._createSendFileMessageRequestParams=function(e,t){var n=(0,s.j)((0,s.j)({},t.params),{channelUrl:e.url,channelType:e.channelType,reqId:t.requestId,url:""});if(t.multipleFileUploadInfo){var r=t.params;n.files=r.fileInfoList}else r=t.params,n.url=r.fileUrl,n.requireAuth=r.requireAuth;return n},e.prototype._resolveMessageQueue=function(e){var t;return(0,s._)(this,void 0,void 0,function(){var n,r,i,a,o,u,c,l,d,h,f,p,m;return(0,s.b)(this,function(_){switch(_.label){case 0:if(!(n=this._queueMap.get(e.url)))return[3,21];if(n.isResolving)return[3,20];n.isResolving=!0,r=[],i=!0,_.label=1;case 1:_.trys.push([1,15,16,17]),a=(0,s.w)(n.messageQueue),o=a.next(),_.label=2;case 2:if(o.done)return[3,14];switch((u=o.value).state){case ee.PENDING:case ee.UPLOADING:return[3,3];case ee.UPLOADED:return[3,4];case ee.FAILED:return[3,12]}return[3,13];case 3:return i=!1,r.push(u),[3,13];case 4:if(!i)return[3,10];_.label=5;case 5:return _.trys.push([5,8,,9]),u.state=ee.SENDING,[4,this._sendFileMessage(e,u)];case 6:return c=_.sent(),u.deferred.resolve(c),[4,(0,s.az)(100)];case 7:return _.sent(),[3,9];case 8:return l=_.sent(),u.deferred.reject(l),[3,9];case 9:return[3,11];case 10:r.push(u),_.label=11;case 11:return[3,13];case 12:return d=null!==(t=u.error)&&void 0!==t?t:s.t.unknown,u.deferred.reject(d.code===s.D.REQUEST_CANCELED?s.t.fileUploadCanceled:d),[3,13];case 13:return o=a.next(),[3,2];case 14:return[3,17];case 15:return h=_.sent(),p={error:h},[3,17];case 16:try{o&&!o.done&&(m=a.return)&&m.call(a)}finally{if(p)throw p.error}return[7];case 17:return f=n.isResolveRequestPending,n.messageQueue=r,n.isResolving=!1,n.isResolveRequestPending=!1,f?[4,this._resolveMessageQueue(e)]:[3,19];case 18:_.sent(),_.label=19;case 19:return[3,21];case 20:n.isResolveRequestPending=!0,_.label=21;case 21:return[2]}})})},e.prototype._uploadNextPendingItem=function(e){var t;return(0,s._)(this,void 0,void 0,function(){var n,r,i,a,o,u,c,l,d,h;return(0,s.b)(this,function(f){switch(f.label){case 0:return(n=this._queueMap.get(e.url))&&(r=n.messageQueue.find(function(e){return e.state===ee.PENDING}))?r.multipleFileUploadInfo?(i=r.multipleFileUploadInfo,a=i.uploadIndex,o=i.uploadCount,u=i.requestHandler,h=r.params,c=h.fileInfoList[a],!(0,s.i)(c.file)||(null===(t=c._uploadedMetaData)||void 0===t?void 0:t.isUploaded)?[3,2]:[4,this._tryUploadNextItemAndUpdateItemState(e,n,r)]):[3,4]:[3,9];case 1:return f.sent(),[3,3];case 2:r.state=a<o-1?ee.PENDING:ee.UPLOADED,f.label=3;case 3:return l=h.fileInfoList[a],d=r.multipleFileUploadInfo.uploadIndex++,r.multipleFileUploadInfo.isCopy||null==u||u._triggerOnFileUploaded(r.requestId,d,l,r.error),[3,7];case 4:return h=r.params,(0,s.i)(h.file)?[4,this._tryUploadNextItemAndUpdateItemState(e,n,r)]:[3,6];case 5:return f.sent(),[3,7];case 6:h.thumbnailSizes=[],r.state=ee.UPLOADED,f.label=7;case 7:return this._uploadNextPendingItem(e),[4,this._resolveMessageQueue(e)];case 8:f.sent(),f.label=9;case 9:return[2]}})})},e.prototype._tryUploadNextItemAndUpdateItemState=function(e,t,n){return(0,s._)(this,void 0,void 0,function(){var r,i,a,o,u,c;return(0,s.b)(this,function(l){switch(l.label){case 0:return[4,this._onlineDetector.isOnline()];case 1:if(r=l.sent(),!s.V.of(this._iid).sessionManager.currentUser||!r)return n.error=s.t.connectionRequired,n.state=ee.FAILED,[2];if(!(t.uploadQueue.length<6))return[3,9];n.state=ee.UPLOADING,t.uploadQueue.push(n),l.label=2;case 2:return l.trys.push([2,7,,8]),n.multipleFileUploadInfo?(i=n.multipleFileUploadInfo,a=i.uploadIndex,o=i.uploadCount,u=n.params,[4,this._uploadNextFileForMultipleFilesItemAndUpdateParams(e,n,u)]):[3,4];case 3:return l.sent(),n.state=a<o-1?ee.PENDING:ee.UPLOADED,[3,6];case 4:return u=n.params,[4,this._uploadNextFileForSingleFileItemAndUpdateParams(e,n,u)];case 5:l.sent(),n.state=ee.UPLOADED,l.label=6;case 6:return[3,8];case 7:switch((c=l.sent()).code){case s.D.REQUEST_FAILED:n.error=new s.t({code:s.D.NETWORK_E
1RROR,message:"Failed to upload a file."});break;case s.D.REQUEST_CANCELED:n.error=s.t.fileUploadCanceled;break;default:n.error=c}return n.state=ee.FAILED,[3,8];case 8:this._dequeueUploadItem(t,n),l.label=9;case 9:return[2]}})})},e.prototype._dequeueUploadItem=function(e,t){var n=e.uploadQueue.findIndex(function(e){return e.requestId===t.requestId});n>=0&&e.uploadQueue.splice(n,1)},e.prototype._uploadNextFileForSingleFileItemAndUpdateParams=function(e,t,n){var r,i,a;return(0,s._)(this,void 0,void 0,function(){var o,l,d,h,f,p,m,_,v,y;return(0,s.b)(this,function(s){switch(s.label){case 0:return o=new u({file:n.file,channelUrl:e.url,thumbnailSizes:n.thumbnailSizes,requestId:t.requestId}),[4,this._requestQueue.send(o)];case 1:return l=s.sent(),d=l.as(c),h=d.url,f=d.fileSize,p=void 0===f?n.fileSize:f,m=d.thumbnails,_=void 0===m?[]:m,v=d.requireAuth,y=void 0!==v&&v,n.fileName=null!==(r=n.fileName)&&void 0!==r?r:n.file.name,n.mimeType=null!==(i=n.mimeType)&&void 0!==i?i:n.file.type,n.fileSize=null!==(a=n.fileSize)&&void 0!==a?a:n.file.size,n.fileUrl=h,n.fileSize=p,n.requireAuth=y,n._thumbnails=_,[2]}})})},e.prototype._uploadNextFileForMultipleFilesItemAndUpdateParams=function(e,t,n){var r,i,a;return(0,s._)(this,void 0,void 0,function(){var o,l,d,h,f,p,m,_,v,y,g;return(0,s.b)(this,function(b){switch(b.label){case 0:return o=t.multipleFileUploadInfo.uploadIndex,l=n.fileInfoList[o],d=new u({file:l.file,channelUrl:e.url,thumbnailSizes:l.thumbnailSizes,requestId:t.requestId}),[4,this._requestQueue.send(d)];case 1:return h=b.sent(),f=h.as(c),p=f.url,m=f.fileSize,_=void 0===m?l.fileSize:m,v=f.thumbnails,y=f.requireAuth,g=void 0!==y&&y,l.fileName=null!==(r=l.fileName)&&void 0!==r?r:l.file.name,l.mimeType=null!==(i=l.mimeType)&&void 0!==i?i:l.file.type,l.fileSize=null!==(a=l.fileSize)&&void 0!==a?a:l.file.size,l.file=void 0,l.fileUrl=p,l.fileSize=_,l._thumbnails=v,l._uploadedMetaData=(0,s.j)((0,s.j)({},l._uploadedMetaData),{requireAuth:g,isUploaded:!0}),l instanceof se||(n.fileInfoList[o]=new se(this._iid,l)),[2]}})})},e.prototype.request=function(e,t,n,r){return void 0===r&&(r={}),(0,s._)(this,void 0,void 0,function(){var i,a,o,u,c;return(0,s.b)(this,function(l){return this._queueMap.has(e.url)||(i={messageQueue:[],uploadQueue:[],isResolving:!1,isResolveRequestPending:!1},this._queueMap.set(e.url,i)),a=this._queueMap.get(e.url),o=new s.aA,u={requestId:t,params:n,state:ee.PENDING,deferred:o},function(e){return"fileInfoList"in e}(n)&&(c=(0,s.j)({uploadIndex:0,uploadCount:n.fileInfoList.length},r),u.multipleFileUploadInfo=c),a.messageQueue.push(u),this._uploadNextPendingItem(e),[2,o.promise]})})},e.prototype.cancel=function(e,t){var n,r,i=this._queueMap.get(e.url);if(i){var a=t?[i.messageQueue.find(function(e){return e.requestId===t})]:(0,s.q)([],(0,s.r)(i.messageQueue),!1);try{for(var o=(0,s.w)(a),u=o.next();!u.done;u=o.next()){var c=u.value;if(c)switch(c.state){case ee.PENDING:if(c.state=ee.FAILED,c.error=s.t.requestCanceled,c.multipleFileUploadInfo&&!c.multipleFileUploadInfo.isCopy){var l=c.multipleFileUploadInfo,d=l.uploadIndex,h=l.requestHandler,f=c.params.fileInfoList[d];null==h||h._triggerOnFileUploaded(c.requestId,d,f,s.t.fileUploadCanceled)}this._resolveMessageQueue(e);break;case ee.UPLOADING:this._requestQueue.cancel(c.requestId),this._dispatcher.dispatch(new s.ay({requestId:c.requestId}))}}}catch(e){n={error:e}}finally{try{u&&!u.done&&(r=o.return)&&r.call(o)}finally{if(n)throw n.error}}}else t&&(this._requestQueue.cancel(t),this._dispatcher.dispatch(new s.ay({requestId:t})))},e}(),pe={prevResultSize:0,nextResultSize:0,isInclusive:!1,reverse:!1,messageTypeFilter:s.au.ALL,customTypesFilter:void 0,senderUserIdsFilter:void 0,replyType:s.aB.NONE,includeReactions:!1,includeMetaArray:!1,includeParentMessageInfo:!1,includeThreadInfo:!1,showSubchannelMessagesOnly:!1},me=function(e){return(0,s.a)("number",e.prevResultSize)&&(0,s.a)("number",e.nextResultSize)&&(0,s.a)("boolean",e.isInclusive)&&(0,s.a)("boolean",e.reverse)&&(0,s.a)("string",e.messageTypeFilter)&&(0,s.a2)(s.au,e.messageTypeFilter)&&(0,s.$)("string",e.customTypesFilter,!0)&&(0,s.$)("string",e.senderUserIdsFilter,!0)&&(0,s.a2)(s.aB,e.replyType)&&(0,s.a)("boolean",e.includeMetaArray)&&(0,s.a)("boolean",e.includeReactions)&&(0,s.a)("boolean",e.includeParentMessageInfo)&&(0,s.a)("boolean",e.includeThreadInfo)&&(0,s.a)("boolean",e.showSubchannelMessagesOnly)},_e={replyType:s.aB.NONE,includeReactions:!1,includeThreadInfo:!1,includeMetaArray:!1,includeParentMessageInfo:!1},ve=function(e){return(0,s.a2)(s.aB,e.replyType)&&(0,s.a)("boolean",e.includeReactions)&&(0,s.a)("boolean",e.includeMetaArray)&&(0,s.a)("boolean",e.includeParentMessageInfo)&&(0,s.a)("boolean",e.includeThreadInfo)};!function(e){e.MESSAGE="message"}(de||(de={})),function(e){e.INTERNAL_BACKSYNC="internal_backsync",e.INTERNAL_FILL_GAP="internal_fill_gap",e.EXTERNAL_LEGACY="external_legacy",e.EXT
1ERNAL_COLLECTION="external_collection"}(he||(he={}));var ye,ge=function(e){function t(t){var n=t.channelType,r=t.channelUrl,i=t.messageId,a=t.includeMetaArray,o=t.includeReactions,u=t.includeThreadInfo,c=t.includeParentMessageInfo,l=e.call(this)||this;return l.method=s.A.GET,l.path="".concat((0,s.aq)(n),"/").concat(encodeURIComponent(r),"/messages/").concat(encodeURIComponent(i)),l.params={is_sdk:!0,with_sorted_meta_array:a,include_reactions_summary:null!=o&&o,include_thread_info:u,include_parent_message_info:c,include_poll_details:!0},l}return(0,s.c)(t,e),t}(s.f),be=function(e){function t(t,n){var r=e.call(this,t,n)||this;return r.message=n?re(t,(0,s.j)({},n)):null,r}return(0,s.c)(t,e),t}(s.g),Ie=function(e){function t(t){var n=t.channelType,r=t.channelUrl,i=t.timestamp,a=t.token,o=t.prevResultSize,u=t.nextResultSize,c=t.isInclusive,l=t.reverse,d=t.messageTypeFilter,h=t.customTypesFilter,f=t.senderUserIdsFilter,p=t.replyType,m=t.includeMetaArray,_=t.includeReactions,v=t.parentMessageId,y=t.includeThreadInfo,g=t.includeParentMessageInfo,b=t.showSubchannelMessagesOnly,I=t.checkingHasNext,E=t.checkingContinuousMessages,w=t.sdkSource,T=e.call(this)||this;return T.method=s.A.GET,T.path="".concat((0,s.aq)(n),"/").concat(encodeURIComponent(r),"/messages"),T.params=(0,s.e)((0,s.u)({is_sdk:!0,prev_limit:o,next_limit:u,include:c,reverse:l,message_ts:i,message_id:a,message_type:null!=d?d:null,custom_types:h,sender_ids:f,include_reply_type:p,with_sorted_meta_array:m,include_reactions_summary:_,parent_message_id:v,include_thread_info:y,include_parent_message_info:g,show_subchannel_message_only:b,include_poll_details:!0,checking_has_next:I,checking_continuous_messages:E,sdk_source:w})),T}return(0,s.c)(t,e),t}(s.f),Ee=function(e){function t(t,n){var r=e.call(this,t,n)||this;return void 0!==n.is_continuous_messages&&(r.isContinuousMessages=n.is_continuous_messages),void 0!==n.has_next&&(r.hasNext=n.has_next),r.messages=n.messages.map(function(e){return re(t,e)}),r}return(0,s.c)(t,e),t}(s.g),we=function(e){function t(t){var n=t.channelType,r=t.channelUrl,i=t.timestamp,a=t.token,o=t.replyType,u=t.includeMetaArray,c=t.includeReactions,l=t.includeThreadInfo,d=t.includeParentMessageInfo,h=e.call(this)||this;return h.method=s.A.GET,h.path="".concat((0,s.aq)(n),"/").concat(encodeURIComponent(r),"/messages/changelogs"),h.params={change_ts:i,token:a,with_sorted_meta_array:u,include_reactions_summary:c,include_thread_info:l,include_reply_type:o,include_parent_message_info:d,include_poll_details:!0},h}return(0,s.c)(t,e),t}(s.f),Te=function(e){function t(t,n){var r=e.call(this,t,n)||this;return r.updatedMessages=n.updated.map(function(e){return re(t,e)}),r.deletedMessagesInfo=n.deleted.map(function(e){return{messageId:e.message_id,deletedAt:e.deleted_at}}),r.hasMore=n.has_more,r.nextToken=n.next,r.forceUseNextToken=n.force_use_next_token||!1,r}return(0,s.c)(t,e),t}(s.g),Me=function(e){function t(t){var n=t.channelUrl,r=t.scheduledMessageId,i=e.call(this)||this;return i.method=s.A.GET,i.path="".concat(s.aC,"/").concat(encodeURIComponent(n),"/scheduled_messages/").concat(encodeURIComponent(r)),i.params={},i}return(0,s.c)(t,e),t}(s.f),Ae=function(e){function t(t,n){var r=e.call(this,t,n)||this;return r.message=n?re(t,(0,s.j)({},n)):null,r}return(0,s.c)(t,e),t}(s.g);!function(e){e.MUTED="muted",e.BANNED="banned"}(ye||(ye={}));var Ue=function(){function e(e){var t,n,r,i;this.restrictionType=null,(0,s.a2)(ye,e.restriction_type)&&(this.restrictionType=e.restriction_type),this.description=null!==(t=e.description)&&void 0!==t?t:null,this.endAt=null!==(r=null!==(n=e.end_at)&&void 0!==n?n:e.muted_end_at)&&void 0!==r?r:-1,this.remainingDuration=null!==(i=e.remaining_duration)&&void 0!==i?i:-1}return e.payloadify=function(e){return(0,s.e)((0,s.u)({restriction_type:e.restrictionType,description:e.description,end_at:e.endAt,remaining_duration:e.remainingDuration}))},e}(),Se=function(e){function t(t,n){var r=e.call(this,t,n)||this;return r.restrictionInfo=new Ue(n),r}return(0,s.c)(t,e),t.payloadify=function(t){return(0,s.e)((0,s.u)((0,s.j)((0,s.j)({},e.payloadify.call(this,t)),Ue.payloadify(t.restrictionInfo))))},t}(s.U),Ne=function(e){function t(t,n){var r,i=this;return(i=e.call(this,t,n)||this).isMuted=!1,i.isMuted=null!==(r=n.is_muted)&&void 0!==r&&r,i}return(0,s.c)(t,e),t}(s.U),Ce=function(){function e(){this._onPending=s.aD,this._onFailed=s.aD,this._onSucceeded=s.aD}return e.prototype._trigger=function(e){switch(null==e?void 0:e.sendingStatus){case s.as.PENDING:0===e.errorCode&&this._onPending(e);break;case s.as.SCHEDULED:case s.as.SUCCEEDED:this._onSucceeded(e)}},e.prototype._triggerFailed=function(e,t){switch(null==t?void 0:t.sendingStatus){case s.as.FAILED:case s.as.CANCELED:this._onFailed(e,t.scheduledInfo?null:t)}},e.prototype.onPending=function(e){return this._onPending=e,this},e.prototype.onFailed=function(e){return this._onFailed=e,this},e.prototype.onSucceeded=function(e){return this._onSucceeded=e,this},e}(),ke={data:void 0,customType:void 0,mentionType:s.ao.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},Oe=function(e){return(0,s.a)("string",e.data,!0)&&(0,s.a)("string",e.customType,!0)&&(0,s.a2)(s.ao,e.mentionType)&&(0,s.$)("string",e.mentionedUserIds,!0)&&(0,s.$)(s.U,e.mentionedUsers,!0)&&(0,s.$)(b,e.metaArrays,!0)&&(0,s.a)("number",e.parentMessageId,!0)&&(0,s.a)("boolean",e.isReplyToChannel)&&(0,s.a2)(s.aw,e.pushNotificationDeliveryOption,!0)&&(0,s.a)(v,e.appleCriticalAlertOptions,!0)&&(0,s.a)("boolean",e.isPinnedMessage,!0)&&(0,s.a)("number",e.pollId,!0)},Pe=function(e){return{isReplyToChannel:e.isReplyToChannel,pushNotificationDeliveryOption:e.pushNotificationDeliveryOption,pollId:e.pollId}},Re=(0,s.j)((0,s.j)({},ke),{message:"",mentionedMessageTemplate:void 0,translationTargetLanguages:void 0,extendedMessagePayload:void 0});function De(e){var t,n,r;return null!==(t=e.messageParams)&&void 0!==t?t:(0,s.u)((0,s.j)((0,s.j)({},e),{mentionType:e.mentionType,mentionedUserIds:null!==(n=e.mentionedUserIds)&&void 0!==n?n:null===(r=e.mentionedUsers)||void 0===r?void 0:r.map(function(e){return e.userId}),mentionedMessageTemplate:e.mentionedMessageTemplate,translationTargetLanguages:Object.keys(e.translations),pushNotificationDeliveryOption:s.aw.DEFAULT,parentMessageId:null,isReplyToChannel:!1,isPinnedMessage:!1}))}var xe,Le=function(e){var t;return(0,s.e)((0,s.u)({data:e.data,customType:e.customType,mentionType:e.mentionType,mentionedUsers:e.mentionedUsers,mentionedUserIds:e.mentionedUserIds,mentionedMessageTemplate:e.mentionedMessageTemplate,metaArrays:e.metaArrays,pollId:null===(t=e.poll)||void 0===t?void 0:t.id,parentMessageId:e.parentMessageId,appleCriticalAlertOptions:e.appleCriticalAlertOptions,message:e.message,translationTargetLanguages:Object.keys(e.translations),extendedMessagePayload:e.extendedMessagePayload}))},Fe=function(e){return Oe(e)&&(0,s.a)("string",e.message)&&(0,s.a)("string",e.mentionedMessageTemplate,!0)&&(0,s.$)("string",e.translationTargetLanguages,!0)&&(0,s.a)("object",e.extendedMessagePayload,!0)};!function(e){e.FILE="file",e.BLOB="blob",e.BLOB_LIKE_OBJECT="blobLikeObject",e.URL="url"}(xe||(xe={}));var qe=function(e){return"undefined"!=typeof window&&"Blob"in window&&"undefined"!=typeof Blob&&e instanceof Blob},je=function(e){return e===xe.BLOB||e===xe.FILE},ze=function(e){return{file:e.file,fileKey:e.fileKey,fileType:e.fileType,isReplyToChannel:e.isReplyToChannel,pushNotificationDeliveryOption:e.pushNotificationDeliveryOption}},Ve=(0,s.j)((0,s.j)({},ke),{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 Be(e){var t,n,r,i;return null!==(t=e.messageParams)&&void 0!==t?t:(0,s.u)((0,s.j)((0,s.j)({},e),{fileUrl:e.plainUrl,fileName:e.name,fileSize:e.size,mimeType:e.type,mentionType:e.mentionType,mentionedUserIds:null!==(n=e.mentionedUserIds)&&void 0!==n?n:null===(r=e.mentionedUsers)||void 0===r?void 0:r.map(function(e){return e.userId}),pushNotificationDeliveryOption:s.aw.DEFAULT,parentMessageId:null,isReplyToChannel:!1,thumbnailSizes:null===(i=e.thumbnails)||void 0===i?void 0:i.map(function(e){return{maxWidth:e.width,maxHeight:e.height}}),requireAuth:e.requireAuth,isPinnedMessage:!1,_thumbnails:e.thumbnails,message:e.message}))}var Ke,Qe=function(e,t){var n,r;return e.messageParams?(!e.url&&(0,s.i)(t)&&(e.messageParams.file=t),e.messageParams):(0,s.e)((0,s.u)({data:e.data,customType:e.customType,mentionType:e.mentionType,mentionedUsers:e.mentionedUsers,mentionedUserIds:e.mentionedUserIds,metaArrays:e.metaArrays,parentMessageId:e.parentMessageId,appleCriticalAlertOptions:e.appleCriticalAlertOptions,file:t,fileUrl:e.url,fileName:e.name,fileSize:e.size,mimeType:e.type,thumbnailSizes:null===(n=e.thumbnails)||void 0===n?void 0:n.map(function(e){return{maxWidth:e.width,maxHeight:e.height}}),message:e.message,pollId:null===(r=e.poll)||void 0===r?void 0:r.id}))},Ge=function(e){return Oe(e)&&((0,s.i)(e.file)||(0,s.a)("string",e.fileUrl))&&(0,s.a)("string",e.fileName,!0)&&(0,s.a)("string",e.mimeType,!0)&&(0,s.a)("number",e.fileSize,!0)&&(0,s.a)("string",e.message,!0)&&(null===e.thumbnailSizes||void 0===e.thumbnailSizes||Array.isArray(e.thumbnailSizes)&&e.thumbnailSizes.every(function(e){return(0,s.a)("object",e)&&e.maxWidth>0&&e.maxHeight>0}))},He={data:void 0,customType:void 0,mentionType:s.ao.USERS,mentionedUserIds:void 0,mentionedUsers:void 0,metaArrays:void 0,pushNotificationDeliveryOption:void 0,appleCriticalAlertOptions:void 0},We=function(e){return(0,s.a)("string",e.data,!0)&&(0,s.a)("string",e.customType,!0)&&(0,s.a2)(s.ao,e.mentionType)&&(0,s.$)("string",e.mentionedUserIds,!0)&&(0,s.$)(s.U,e.mentionedUsers,!0)&&(0,s.$)(b,e.metaArrays,!0)&&(0,s.a2)(s.aw,e.pushNotificationDeliveryOption,!0)&&(0,s.a)(v,e.appleCriticalAlertOptions,!0)},Ye=(0,s.j)((0,s.j)({},He),{message:void 0,mentionedMessageTemplate:void 0,translationTargetLanguages:void 0,pollId:void 0}),Je=function(e){return We(e)&&(0,s.a)("string",e.mentionedMessageTemplate,!0)&&(0,s.a)("string",e.message,!0)&&(0,s.$)("string",e.translationTargetLanguages,!0)&&(0,s.a)("number",e.pollId,!0)},$e=(0,s.j)({},He),Xe=function(e){function t(t){var n=t.channelUrl,r=t.channelType,i=t.token,a=t.limit,o=e.call(this)||this;return o.method=s.A.GET,o.path="".concat((0,s.aq)(r),"/").concat(encodeURIComponent(n),"/operators"),o.params={token:i,limit:a},o}return(0,s.c)(t,e),t}(s.f),Ze=function(e){function t(t,n){var r=e.call(this,t,n)||this;return r.operators=n.operators.map(function(e){return new s.U(t,e)}),r.token=n.next,r}return(0,s.c)(t,e),t}(s.g),et=function(e){function t(t,n,r,i){return e.call(this,t,n,r,i)||this}return(0,s.c)(t,e),t.prototype._validate=function(){return e.prototype._validate.call(this)},t.prototype.next=function(){return(0,s._)(this,void 0,void 0,function(){var e,t,n,r,i,a,o;return(0,s.b)(this,function(u){switch(u.label){case 0:return this._val
1idate()?this._isLoading?[3,3]:(e=[],this._hasNext?(this._isLoading=!0,t=s.V.of(this._iid).requestQueue,n=new Xe((0,s.j)((0,s.j)({},this),{channelUrl:this.channelUrl,token:this._token})),[4,t.send(n)]):[3,2]):[3,5];case 1:return r=u.sent(),i=r.as(Ze),a=i.operators,o=i.token,this._token=o,this._hasNext=!!o,this._isLoading=!1,[2,a];case 2:return[2,e];case 3:throw s.t.queryInProgress;case 4:return[3,6];case 5:throw s.t.invalidParameters;case 6:return[2]}})})},t}(a.c),tt=function(e){function t(t,n,r,i){var a,o,u,c,l,d,h,f,p,m,_=this;return(_=e.call(this,t,n,r,i)||this).reverse=!1,_.messageTypeFilter=s.au.ALL,_.customTypesFilter=null,_.senderUserIdsFilter=null,_.replyType=s.aB.NONE,_.includeMetaArray=!1,_.includeReactions=!1,_.includeParentMessageInfo=!1,_.includeThreadInfo=!1,_.showSubchannelMessagesOnly=!1,_._edge=Number.MAX_SAFE_INTEGER,_.reverse=null!==(a=i.reverse)&&void 0!==a&&a,_.messageTypeFilter=null!==(o=i.messageTypeFilter)&&void 0!==o?o:s.au.ALL,_.customTypesFilter=null!==(u=i.customTypesFilter)&&void 0!==u?u:null,_.senderUserIdsFilter=null!==(c=i.senderUserIdsFilter)&&void 0!==c?c:null,_.replyType=null!==(l=i.replyType)&&void 0!==l?l:s.aB.NONE,_.includeMetaArray=null!==(d=i.includeMetaArray)&&void 0!==d&&d,_.includeReactions=null!==(h=i.includeReactions)&&void 0!==h&&h,_.includeParentMessageInfo=null!==(f=i.includeParentMessageInfo)&&void 0!==f&&f,_.includeThreadInfo=null!==(p=i.includeThreadInfo)&&void 0!==p&&p,_.showSubchannelMessagesOnly=null!==(m=i.showSubchannelMessagesOnly)&&void 0!==m&&m,_}return(0,s.c)(t,e),t.prototype._validate=function(){return e.prototype._validate.call(this)&&(0,s.a)("boolean",this.reverse)&&(0,s.a2)(s.au,this.messageTypeFilter)&&(0,s.a2)(s.aB,this.replyType)&&(0,s.$)("string",this.customTypesFilter,!0)&&(0,s.$)("string",this.senderUserIdsFilter,!0)&&(0,s.a)("boolean",this.includeMetaArray)&&(0,s.a)("boolean",this.includeReactions)&&(0,s.a)("boolean",this.includeParentMessageInfo)&&(0,s.a)("boolean",this.includeThreadInfo)&&(0,s.a)("boolean",this.showSubchannelMessagesOnly)},t.prototype.load=function(){return(0,s._)(this,void 0,void 0,function(){var e;return(0,s.b)(this,function(t){switch(t.label){case 0:return this._validate()?this._isLoading?[3,3]:this._hasNext?(this._isLoading=!0,[4,Di.of(this._iid).getMessagesByTimestamp(this.channelUrl,this.channelType,this._edge,(0,s.u)({prevResultSize:this.limit,nextResultSize:0,isInclusive:!1,reverse:this.reverse,messageTypeFilter:this.messageTypeFilter,customTypesFilter:this.customTypesFilter,replyType:this.replyType,senderUserIdsFilter:this.senderUserIdsFilter,includeReactions:this.includeReactions,includeMetaArray:this.includeMetaArray,includeParentMessageInfo:this.includeParentMessageInfo,includeThreadInfo:this.includeThreadInfo,showSubchannelMessagesOnly:this.showSubchannelMessagesOnly}))]):[3,2]:[3,5];case 1:return e=t.sent(),this._edge=Math.min.apply(Math,(0,s.q)([Number.MAX_SAFE_INTEGER],(0,s.r)(e.map(function(e){return e.createdAt})),!1)),this._hasNext=e.length>=this.limit,this._isLoading=!1,[2,e];case 2:return[2,[]];case 3:throw s.t.queryInProgress;case 4:return[3,6];case 5:throw s.t.invalidParameters;case 6:return[2]}})})},t}(a.c),nt=function(e){function t(t){var n=this,r=t.channelUrl,i=t.channelType,a=t.limit,o=t.token;return(n=e.call(this)||this).method=s.A.GET,n.path="".concat((0,s.aq)(i),"/").concat(encodeURIComponent(r),"/mute"),n.params={limit:a,token:o},n}return(0,s.c)(t,e),t}(s.f),rt=function(e){function t(t,n){var r=e.call(this,t,n)||this;r.mutedUsers=[];var i=n.next,s=n.muted_list;return r.token=i,s&&s.length>0&&(r.mutedUsers=s.map(function(e){return new Se(t,e)})),r}return(0,s.c)(t,e),t}(s.g),it=function(e){function t(t,n,r,i){return e.call(this,t,n,r,i)||this}return(0,s.c)(t,e),t.prototype.next=function(){return(0,s._)(this,void 0,void 0,function(){var e,t,n,r,i,a;return(0,s.b)(this,function(o){switch(o.label){case 0:return this._validate()?this._isLoading?[3,3]:this._hasNext?(this._isLoading=!0,e=s.V.of(this._iid).requestQueue,t=new nt((0,s.j)((0,s.j)({},this),{token:this._token})),[4,e.send(t)]):[3,2]:[3,5];case 1:return n=o.sent(),r=n.as(rt),i=r.mutedUsers,a=r.token,this._token=a,this._hasNext=!!a,this._isLoading=!1,[2,i];case 2:return[2,[]];case 3:throw s.t.queryInProgress;case 4:return[3,6];case 5:throw s.t.invalidParameters;case 6:return[2]}})})},t}(a.c),st=function(e){function t(t){var n=this,r=t.channelUrl,i=t.channelType,a=t.limit,o=t.token;return(n=e.call(this)||this).method=s.A.GET,n.path="".concat((0,s.aq)(i),"/").concat(encodeURIComponent(r),"/ban"),n.params=(0,s.e)({limit:a,token:o}),n}return(0,s.c)(t,e),t}(s.f),at=function(e){function t(t,n){var r=e.call(this,t,n)||this;r.bannedUsers=[];var i=n.next,s=n.banned_list;return r.token=i,s&&s.length>0&&(r.bannedUsers=s.map(function(e){return new Se(t,e.user)})),r}return(0,s.c)(t,e),t}(s.g),ot=function(e){function t(t,n,r,i){return e.call(this,t,n,r,i)||this}return(0,s.c)(t,e),t.prototype._validate=function(){return e.prototype._validate.call(this)},t.prototype.next=function(){return(0,s._)(this,void 0,void 0,function(){var e,t,n,r,i,a;return(0,s.b)(this,function(o){switch(o.label){case 0:return this._val
1idate()?this._isLoading?[3,3]:this._hasNext?(this._isLoading=!0,e=s.V.of(this._iid).requestQueue,t=new st((0,s.j)((0,s.j)({},this),{token:this._token})),[4,e.send(t)]):[3,2]:[3,5];case 1:return n=o.sent(),r=n.as(at),i=r.bannedUsers,a=r.token,this._token=a,this._hasNext=!!a,this._isLoading=!1,[2,i];case 2:return[2,[]];case 3:throw s.t.queryInProgress;case 4:return[3,6];case 5:throw s.t.invalidParameters;case 6:return[2]}})})},t}(a.c);!function(e){e.SPAM="spam",e.HARASSING="harassing",e.SUSPICIOUS="suspicious",e.INAPPROPRIATE="inappropriate"}(Ke||(Ke={}));var ut=function(e){function t(t){var n=this,r=t.channelUrl,i=t.channelType,a=t.operatorUserIds;return(n=e.call(this)||this).method=s.A.POST,n.path="".concat((0,s.aq)(i),"/").concat(encodeURIComponent(r),"/operators"),n.params={operator_ids:a},n}return(0,s.c)(t,e),t}(s.f);!function(e){(0,s.c)(function(){return null!==e&&e.apply(this,arguments)||this},e)}(s.g);var ct=function(e){function t(t){var n=this,r=t.channelUrl,i=t.channelType,a=t.operatorUserIds;return(n=e.call(this)||this).method=s.A.DELETE,n.path="".concat((0,s.aq)(i),"/").concat(encodeURIComponent(r),"/operators"),n.params={operator_ids:a},n}return(0,s.c)(t,e),t}(s.f);!function(e){(0,s.c)(function(t,n){return e.call(this,t,n)||this},e)}(s.g);var lt=function(e){function t(t){var n=this,r=t.channelUrl,i=t.channelType,a=t.userId;return(n=e.call(this)||this).method=s.A.GET,n.path="".concat((0,s.aq)(i),"/").concat(encodeURIComponent(r),"/mute/").concat(a),n}return(0,s.c)(t,e),t}(s.f),dt=function(e){function t(t,n){var r=e.call(this,t,n)||this;r.isMuted=!1,r.startAt=0,r.endAt=0;var i=n.is_muted,s=n.start_at,a=n.end_at,o=n.remaining_duration,u=n.description;return r.isMuted=i,r.startAt=s,r.endAt=a,r.remainingDuration=o,r.description=u,r}return(0,s.c)(t,e),t}(s.g),ht=function(e){function t(t){var n=this,r=t.channelUrl,i=t.channelType,a=t.keys;return(n=e.call(this)||this).method=s.A.GET,n.path="".concat((0,s.aq)(i),"/").concat(encodeURIComponent(r),"/metadata"),n.params={keys:a,include_ts:!0},n}return(0,s.c)(t,e),t}(s.f),ft=function(e){function t(t,n){var r=e.call(this,t,n)||this,i=n.metadata,s=n.ts;return r.metadata=i,r.ts=s,r}return(0,s.c)(t,e),t}(s.g),pt=function(e){function t(t){var n=this,r=t.channelUrl,i=t.channelType,a=t.metadata;return(n=e.call(this)||this).method=s.A.POST,n.path="".concat((0,s.aq)(i),"/").concat(encodeURIComponent(r),"/metadata"),n.params={metadata:a,include_ts:!0},n}return(0,s.c)(t,e),t}(s.f),mt=function(e){function t(t,n){var r,i,s=this;return(s=e.call(this,t,n)||this).metaData=null!==(r=n.metadata)&&void 0!==r?r:{},s.ts=null!==(i=n.ts)&&void 0!==i?i:null,s}return(0,s.c)(t,e),t}(s.g),_t=function(e){function t(t){var n=this,r=t.channelUrl,i=t.channelType,a=t.metadata,o=t.upsert;return(n=e.call(this)||this).method=s.A.PUT,n.path="".concat((0,s.aq)(i),"/").concat(encodeURIComponent(r),"/metadata"),n.params={metadata:a,include_ts:!0,upsert:null!=o&&o},n}return(0,s.c)(t,e),t}(s.f),vt=function(e){function t(t,n){var r=e.call(this,t,n)||this,i=n.metadata,s=n.ts;return r.metadata=i,r.ts=s,r}return(0,s.c)(t,e),t}(s.g),yt=function(e){function t(t,n,r){var i=e.call(this,t,"SYEV",r)||this;return r.data&&(i.created=r.data.created,i.updated=r.data.updated,i.deleted=r.data.deleted),i}return(0,s.c)(t,e),t}(s.W),gt=function(e){function t(t){var n=this,r=t.channelUrl,i=t.channelType,a=t.key;return(n=e.call(this)||this).method=s.A.DELETE,n.path="".concat((0,s.aq)(i),"/").concat(encodeURIComponent(r),"/metadata/").concat(a),n.params={include_ts:!0},n}return(0,s.c)(t,e),t}(s.f),bt=function(e){function t(t,n){var r=e.call(this,t,n)||this,i=n.ts;return r.ts=i,r}return(0,s.c)(t,e),t}(s.g),It=function(e){function t(t){var n=this,r=t.channelUrl,i=t.channelType;return(n=e.call(this)||this).method=s.A.DELETE,n.path="".concat((0,s.aq)(i),"/").concat(encodeURIComponent(r),"/metadata"),n.params={include_ts:!0},n}return(0,s.c)(t,e),t}(s.f),Et=function(e){function t(t,n){var r=e.call(this,t,n)||this,i=n.ts;return r.ts=i,r}return(0,s.c)(t,e),t}(s.g),wt=function(e){function t(t){var n=this,r=t.channelUrl,i=t.channelType,a=t.keys;return(n=e.call(this)||this).method=s.A.GET,n.path="".concat((0,s.aq)(i),"/").concat(encodeURIComponent(r),"/metacounter"),n.params={keys:a},n}return(0,s.c)(t,e),t}(s.f),Tt=function(e){function t(t,n){var r=e.call(this,t,n)||this;return r.metaCounter=n,r}return(0,s.c)(t,e),t}(s.g),Mt=function(e){function t(t){var n=this,r=t.channelUrl,i=t.channelType,a=t.metaCounter;return(n=e.call(this)||this).method=s.A.POST,n.path="".concat((0,s.aq)(i),"/").concat(encodeURIComponent(r),"/metacounter"),n.params={metacounter:a},n}return(0,s.c)(t,e),t}(s.f),At=function(e){function t(t,n){var r=e.call(this,t,n)||this;return r.metaCounter=n,r}return(0,s.c)(t,e),t}(s.g),Ut=function(e){function t(t){var n=this,r=t.channelUrl,i=t.channelType,a=t.metaCounter,o=t.upsert,u=void 0!==o&&o,c=t.mode,l=void 0===c?"set":c;return(n=e.call(this)||this).method=s.A.PUT,n.path="".concat((0,s.aq)(i),"/").concat(encodeURIComponent(r),"/metacounter"),n.params={metacounter:a,upsert:u,mode:l},n}return(0,s.c)(t,e),t}(s.f),St=function(e){function t(t,n){var r=e.call(this,t,n)||this;return r.metaCounter=n,r}return(0,s.c)(t,e),t}(s.g),Nt=function(e){function t(t,n,r){var i=e.call(this,t,"SYEV",r)||this;return r.data&&(i.created=r.data.created,i.updated=r.data.updated,i.deleted=r.data.deleted),i}return(0,s.c)(t,e),t}(s.W),Ct=function(e){function t(t){var n=this,r=t.channelUrl,i=t.channelType,a=t.key;return(n=e.call(this)||this).method=s.A.DELETE,n.path="".concat((0,s.aq)(i),"/").concat(encodeURIComponent(r),"/metacounter/").concat(a),n.params={},n}return(0,s.c)(t,e),t}(s.f);!function(e){(0,s.c)(function(t,n){return e.call(this,t,n)||this},e)}(s.g);var kt=function(e){function t(t){var n=this,r=t.channelUrl,i=t.channelType;return(n=e.call(this)||this).method=s.A.DELETE,n.path="".concat((0,s.aq)(i),"/").concat(encodeURIComponent(r),"/metacounter"),n.params={},n}return(0,s.c)(t,e),t}(s.f);!function(e){(0,s.c)(function(){return null!==e&&e.apply(this,arguments)||this},e)}(s.g);var Ot=function(e){function t(t){var n=this,r=t.channelUrl,i=t.channelType,a=t.userId,o=t.seconds,u=t.description;return(n=e.call(this)||this).method=s.A.POST,n.path="".concat((0,s.aq)(i),"/").concat(encodeURIComponent(r),"/mute"),n.params={user_id:a,seconds:o,description:u},n}return(0,s.c)(t,e),t}(s.f);!function(e){(0,s.c)(function(t,n){return e.call(this,t,n)||this},e)}(s.g);var Pt=function(e){function t(t,n,r){var i=e.call(this,t,"SYEV",r)||this;return i.user=new Se(t,r.data),i}return(0,s.c)(t,e),t}(s.W),Rt=function(e){function t(t){var n=this,r=t.channelUrl,i=t.channelType,a=t.userId;return(n=e.call(this)||this).method=s.A.DELETE,n.path="".concat((0,s.aq)(i),"/").concat(encodeURIComponent(r),"/mute/").concat(encodeURIComponent(a)),n}return(0,s.c)(t,e),t}(s.f);!function(e){(0,s.c)(function(){return null!==e&&e.apply(this,arguments)||this},e)}(s.g);var Dt=function(e){function t(t,n,r){var i=e.call(this,t,"SYEV",r)||this;return i.user=new Se(t,r.data),i}return(0,s.c)(t,e),t}(s.W),xt=function(e){function t(t){var n=this,r=t.channelUrl,i=t.channelType,a=t.userId,o=t.seconds,u=t.description;return(n=e.call(this)||this).method=s.A.POST,n.path="".concat((0,s.aq)(i),"/").concat(encodeURIComponent(r),"/ban"),n.params=(0,s.e)({user_id:a,seconds:o,description:u}),n}return(0,s.c)(t,e),t}(s.f);!function(e){(0,s.c)(function(){return null!==e&&e.apply(this,arguments)||this},e)}(s.g);var Lt=function(e){function t(t,n,r){var i=e.call(this,t,"SYEV",r)||this;return i.user=new Se(t,r.data),r.data.member_count&&(i.memberCount=r.data.member_count),r.data.joined_member_count&&(i.joinedMemberCount=r.data.joined_member_count),i}return(0,s.c)(t,e),t}(s.W),Ft=function(e){function t(t){var n=this,r=t.channelUrl,i=t.channelType,a=t.userId;return(n=e.call(this)||this).method=s.A.DELETE,n.path="".concat((0,s.aq)(i),"/").concat(encodeURIComponent(r),"/ban/").concat(encodeURIComponent(a)),n}return(0,s.c)(t,e),t}(s.f);!function(e){(0,s.c)(function(){return null!==e&&e.apply(this,arguments)||this},e)}(s.g);var qt=function(e){function t(t,n,r){var i=e.call(this,t,"SYEV",r)||this;return i.user=new Se(t,r.data),i}return(0,s.c)(t,e),t}(s.W),jt=function(e){function t(t){var n=this,r=t.channelUrl,i=t.channelType,a=t.freezing;return(n=e.call(this)||this).method=s.A.PUT,n.path="".concat((0,s.aq)(i),"/").concat(encodeURIComponent(r),"/freeze"),n.params={freeze:a},n}return(0,s.c)(t,e),t}(s.f);!function(e){(0,s.c)(function(){return null!==e&&e.apply(this,arguments)||this},e)}(s.g);var zt=function(e){function t(t,n,r){var i=e.call(this,t,"SYEV",r)||this;return i.freeze=r.data.freeze,i}return(0,s.c)(t,e),t}(s.W),Vt=function(e){return e instanceof s.ac?e._custom?"custom"
1:e.name:e},Bt=function(e){if(e instanceof s.ac&&e._custom)return e.name},Kt=function(e){function t(t){var n=this,r=t.channelUrl,i=t.channelType,a=t.category,o=t.userId,u=t.description;return(n=e.call(this)||this).method=s.A.POST,n.path="".concat((0,s.aE)(i),"/").concat(encodeURIComponent(r)),n.params=(0,s.e)({report_category:Vt(a),reporting_user_id:o,report_description:u,custom_report_category_name:Bt(a)}),n}return(0,s.c)(t,e),t}(s.f),Qt=function(e){function t(t){var n=this,r=t.channelUrl,i=t.channelType,a=t.category,o=t.userId,u=t.offendingUserId,c=t.description;return(n=e.call(this)||this).method=s.A.POST,n.path="".concat(s.aF,"/users/").concat(u),n.params=(0,s.e)({channel_url:r,channel_type:i===s.C.OPEN?"open_channels":"group_channels",report_category:Vt(a),reporting_user_id:o,report_description:c,custom_report_category_name:Bt(a)}),n}return(0,s.c)(t,e),t}(s.f),Gt=function(e){function t(t){var n=this,r=t.channelUrl,i=t.channelType,a=t.category,o=t.userId,u=t.offendingUserId,c=t.messageId,l=t.description;return(n=e.call(this)||this).method=s.A.POST,n.path="".concat((0,s.aE)(i),"/").concat(encodeURIComponent(r),"/messages/").concat(c),n.params=(0,s.e)({report_category:Vt(a),reporting_user_id:o,report_description:l,offending_user_id:u,custom_report_category_name:Bt(a)}),n}return(0,s.c)(t,e),t}(s.f),Ht=function(e){function t(t){var n=[];return t.mentionType===s.ao.USERS&&(t.mentionedUserIds?n=t.mentionedUserIds:t.mentionedUsers&&(n=t.mentionedUsers.map(function(e){return e.userId}))),e.call(this,{code:"MESG",ackRequired:!0,payload:(0,s.e)((0,s.u)({channel_url:t.channelUrl,message:t.message,data:t.data,custom_type:t.customType,metaarray:t.metaArrays,mention_type:t.mentionType,mentioned_user_ids:n,mentioned_message_template:t.mentionedMessageTemplate,target_langs:t.translationTargetLanguages,push_option:t.pushNotificationDeliveryOption&&t.pushNotificationDeliveryOption!==s.aw.DEFAULT?t.pushNotificationDeliveryOption:void 0,apple_critical_alert_options:t.appleCriticalAlertOptions,silent:t.silent,reply_to_channel:t.isReplyToChannel,parent_message_id:t.parentMessageId?t.parentMessageId:null,req_id:t.reqId,poll_id:t.pollId,pin_message:t.isPinnedMessage,extended_message_payload:t.extendedMessagePayload}))})||this}return(0,s.c)(t,e),t}(s.ap),Wt=function(e){function t(t,n,r){var i,a,o,u,c=this;(c=e.call(this,t,"MESG",r)||this).message=new X(t,r);var l=s.V.of(t).sdkState;return c.isMentioned=(0,s.ax)(c.message.mentionType,null!==(o=null!==(i=c.message.mentionedUserIds)&&void 0!==i?i:null===(a=c.message.mentionedUsers)||void 0===a?void 0:a.map(function(e){return e.userId}))&&void 0!==o?o:[],l.userId),c.forceUpdateLastMessage=null!==(u=r.force_update_last_message)&&void 0!==u&&u,c}return(0,s.c)(t,e),t}(s.W),Yt=function(e){function t(t){var n=null;return t.mentionType===s.ao.USERS&&(t.mentionedUserIds?n=t.mentionedUserIds:t.mentionedUsers&&(n=t.mentionedUsers.map(function(e){return e.userId}))),e.call(this,{code:"MEDI",ackRequired:!0,payload:(0,s.e)((0,s.u)({channel_url:t.channelUrl,msg_id:t.messageId,message:t.message,data:t.data,custom_type:t.customType,metaarray:t.metaArrayParams,mention_type:t.mentionType,mentioned_user_ids:n,mentioned_message_template:t.mentionedMessageTemplate,apple_critical_alert_options:t.appleCriticalAlertOptions?v.payloadify(t.appleCriticalAlertOptions):null,poll_id:t.pollId}))})||this}return(0,s.c)(t,e),t}(s.ap),Jt=function(e){function t(t,n,r){var i,a,o,u,c,l=this;(l=e.call(this,t,"MEDI",r)||this).message=new X(t,r);var d=s.V.of(t).sdkState;return l.mentionCountChange=(0,s.aG)({mentionType:null===(i=r.old_values)||void 0===i?void 0:i.mention_type,mentionedUserIds:null!==(o=null===(a=r.old_values)||void 0===a?void 0:a.mentioned_user_ids)&&void 0!==o?o:[]},(0,s.u)({mentionType:l.message.mentionType,mentionedUserIds:null!==(u=l.message.mentionedUserIds)&&void 0!==u?u:null===(c=l.message.mentionedUsers)||void 0===c?void 0:c.map(function(e){return e.userId})}),d.userId),l}return(0,s.c)(t,e),t}(s.W),$t=function(e){function t(t){var n=null;return t.mentionType===s.ao.USERS&&(t.mentionedUserIds?n=t.mentionedUserIds:t.mentionedUsers&&(n=t.mentionedUsers.map(function(e){return e.userId}))),e.call(this,{code:"FEDI",ackRequired:!0,payload:(0,s.e)((0,s.u)({channel_url:t.channelUrl,msg_id:t.messageId,data:t.data,custom_type:t.customType,metaarray:t.metaArrayParams,mention_type:t.mentionType,mentioned_user_ids:n,apple_critical_alert_options:t.appleCriticalAlertOptions}))})||this}return(0,s.c)(t,e),t}(s.ap),Xt=function(e){function t(t,n,r){var i,a,o,u,c,l=this;(l=e.call(this,t,"FEDI",r)||this).message=new ie(t,r);var d=s.V.of(t).sdkState;return l.mentionCountChange=(0,s.aG)({mentionType:null===(i=r.old_values)||void 0===i?void 0:i.mention_type,mentionedUserIds:null!==(o=null===(a=r.old_values)||void 0===a?void 0:a.mentioned_user_ids)&&void 0!==o?o:[]},(0,s.u)({mentionType:l.message.mentionType,mentionedUserIds:null!==(u=l.message.mentionedUserIds)&&void 0!==u?u:null===(c=l.message.mentionedUsers)||void 0===c?void 0:c.map(function(e){return e.userId})}),d.userId),l}return(0,s.c)(t,e),t}(s.W),Zt=function(e){function t(t){var n=t.channelType,r=t.channelUrl,i=t.messageId,a=t.reactionKey,o=e.call(this)||this;return o.method=s.A.POST,o.path="".concat((0,s.aq)(n),"/").concat(encodeURIComponent(r),"/messages/").concat(i,"/reactions"),o.params={reaction:a},o}return(0,s.c)(t,e),t}(s.f),en=function(e){function t(t,n){var r=e.call(this,t,n)||this;return r.reactionEvent=new h(n),r}return(0,s.c)(t,e),t}(s.g),tn=function(e){function t(t){var n=t.channelType,r=t.channelUrl,i=t.messageId,a=t.reactionKey,o=e.call(this)||this;return o.method=s.A.DELETE,o.path="".concat((0,s.aq)(n),"/").concat(encodeURIComponent(r),"/messages/").concat(i,"/reactions"),o.params={reaction:a},o}return(0,s.c)(t,e),t}(s.f),nn=function(e){function t(t,n){var r=e.call(this,t,n)||this;return r.reactionEvent=new h((0,s.j)({},n)),r}return(0,s.c)(t,e),t}(s.g),rn=function(e){function t(t){var n=t.channelType,r=t.channelUrl,i=t.messageId,a=t.translationTargetLanguages,o=e.call(this)||this;return o.method=s.A.POST,o.path="".concat((0,s.aq)(n),"/").concat(encodeURIComponent(r),"/messages/").concat(encodeURIComponent(i),"/translation"),o.params={target_langs:a},o}return(0,s.c)(t,e),t}(s.f),sn=function(e){function t(t,n){var r=e.call(this,t,n)||this;return r.message=new X(t,n),r}return(0,s.c)(t,e),t}(s.g),an=function(e){function t(t){var n,r=this;r=e.call(this)||this;var i=[];t.mentionType===s.ao.USERS&&(t.mentionedUserIds?i=t.mentionedUserIds:t.mentionedUsers&&(i=t.mentionedUsers.map(function(e){return e.userId})));var a=t.channelType,o=t.channelUrl;return r.method=s.A.POST,r.path="".concat((0,s.aq)(a),"/").concat(encodeURIComponent(o),"/scheduled_messages"),r.params=(0,s.e)((0,s.u)({req_id:t.reqId,scheduled_at:t.scheduledAt,message_type:s.aH.USER,message:t.message,custom_type:t.customType,data:t.data,mention_type:t.mentionType,mentioned_user_ids:i,sorted_metaarray:null===(n=t.metaArrays)||void 0===n?void 0:n.map(function(e){return b.payloadify(e)}),apple_critical_alert_options:t.appleCriticalAlertOptions?v.payloadify(t.appleCriticalAlertOptions):null,target_langs:t.translationTargetLanguages,push_option:t.pushNotificationDeliveryOption})),r}return(0,s.c)(t,e),t}(s.f),on=function(e){function t(t,n){var r=e.call(this,t,n)||this;return r.message=new X(t,n),r}return(0,s.c)(t,e),t}(s.g),un=function(e){function t(t){var n,r,i=this;i=e.call(this)||this;var a=[];t.mentionType===s.ao.USERS&&(t.mentionedUserIds?a=t.mentionedUserIds:t.mentionedUsers&&(a=t.mentionedUsers.map(function(e){return e.userId})));var u=t.channelType,c=t.channelUrl;return i.method=s.A.POST,i.path="".concat((0,s.aq)(u),"/").concat(encodeURIComponent(c),"/scheduled_messages"),i.params=(0,s.u)({req_id:t.reqId,scheduled_at:t.scheduledAt,message_type:s.aH.FILE,url:t.fileUrl,file_name:t.fileName,file_size:t.fileSize,file_type:t.mimeType,thumbnails:null===(n=t._thumbnails)||void 0===n?void 0:n.map(function(e){return o.payloadify(e)}),custom_type:t.customType,data:t.data,require_auth:t.requireAuth,mention_type:t.mentionType,mentioned_user_ids:a,sorted_metaarray:null===(r=t.metaArrays)||void 0===r?void 0:r.map(function(e){return b.payloadify(e)}),apple_critical_alert_options:t.appleCriticalAlertOptions?v.payloadify(t.appleCriticalAlertOptions):null,push_option:t.pushNotificationDeliveryOption}),i}return(0,s.c)(t,e),t}(s.f),cn=function(e){function t(t,n){var r=e.call(this,t,n)||this;return r.message=new ie(t,n),r}return(0,s.c)(t,e),t}(s.g),ln=function(e){function t(t){var n=t.pollId,r=t.title,i=t.data,a=t.allowUserSuggestion,o=t.allowMultipleVotes,u=t.closeAt,c=e.call(this)||this;return c.method=s.A.PUT,c.path="".concat(s.aI,"/").concat(encodeURIComponent(n)),c.params={title:r,data:i,allow_user_suggestion:a,allow_multiple_votes:o,close_at:u},c}return(0,s.c)(t,e),t}(s.f),dn=function(e){function t(t,n){var r=e.call(this,t,n)||this;return r.poll=new a.b(t,n),r}return(0,s.c)(t,e),t}(s.g),hn=function(e){function t(t){var n=t.pollId,r=e.call(this)||this;return r.method=s.A.DELETE,r.path="".concat(s.aI,"/").concat(encodeURIComponent(n)),r}return(0,s.c)(t,e),t}(s.f);!function(e){(0,s.c)(function(){return null!==e&&e.apply(this,arguments)||this},e)}(s.g);var fn=function(e){function t(t){var n=t.pollId,r=e.call(this)||this;return r.method=s.A.PUT,r.path="".concat(s.aI,"/").concat(encodeURIComponent(n),"/close"),r}return(0,s.c)(t,e),t}(s.f),pn=function(e){function t(t,n){var r=e.call(this,t,n)||this;return r.poll=new a.b(t,n),r}return(0,s.c)(t,e),t}(s.g),mn=function(e){function t(t){var n=t.channelUrl,r=t.channelType,i=t.pollId,a=t.optionText,o=e.call(this)||this;return o.method=s.A.POST,o.path="".concat(s.aI,"/").concat(encodeURIComponent(i),"/options"),o.params={channel_url:n,channel_type:r,text:a},o}return(0,s.c)(t,e),t}(s.f),_n=function(e){function t(t,n){var r=e.call(this,t,n)||this;return r.poll=new a.b(t,n),r}return(0,s.c)(t,e),t}(s.g),vn=function(e){function t(t){var n=t.pollId,r=t.pollOptionId,i=t.o
1ptionText,a=e.call(this)||this;return a.method=s.A.PUT,a.path="".concat(s.aI,"/").concat(encodeURIComponent(n),"/options/").concat(encodeURIComponent(r)),a.params={text:i},a}return(0,s.c)(t,e),t}(s.f),yn=function(e){function t(t,n){var r=e.call(this,t,n)||this;return r.poll=new a.b(t,n),r}return(0,s.c)(t,e),t}(s.g),gn=function(e){function t(t){var n=t.pollId,r=t.pollOptionId,i=e.call(this)||this;return i.method=s.A.DELETE,i.path="".concat(s.aI,"/").concat(encodeURIComponent(n),"/options/").concat(encodeURIComponent(r)),i}return(0,s.c)(t,e),t}(s.f);!function(e){(0,s.c)(function(){return null!==e&&e.apply(this,arguments)||this},e)}(s.g);var bn=function(e){function t(t){var n=t.reqId,r=t.channelType,i=t.channelUrl,a=t.pollId,o=t.pollOptionIds;return e.call(this,{code:"VOTE",ackRequired:!0,payload:(0,s.e)({req_id:n,channel_type:r===s.C.OPEN?"open_channels":"group_channels",channel_url:i,poll_id:a,option_ids:o})})||this}return(0,s.c)(t,e),t}(s.ap),In=function(e){function t(t,n,r){var i=e.call(this,t,"VOTE",r)||this;return i.event=new a.d(r),i.channelUrl=r.channel_url,i.channelType=r.channel_type,i}return(0,s.c)(t,e),t}(s.W),En=100,wn="GroupChannel",Tn="url",Mn=100,An="Message",Un="messageId",Sn="NotificationMessage",Nn="notificationId",Cn="Poll",kn="pollId",On="FeedChannel",Pn="url",Rn="UserInfo",Dn="userId";function xn(e){var t,n,r;return null!==(t=e.messageParams)&&void 0!==t?t:(0,s.u)((0,s.j)((0,s.j)({},e),{isReplyToChannel:!1,mentionedUserIds:null!==(n=e.mentionedUserIds)&&void 0!==n?n:null===(r=e.mentionedUsers)||void 0===r?void 0:r.map(function(e){return e.userId}),pushNotificationDeliveryOption:s.aw.DEFAULT,isPinnedMessage:!1,fileInfoList:e.fileInfoList.map(function(e){var t;return{fileUrl:e.plainUrl,fileName:e.fileName,fileSize:e.fileSize,mimeType:e.mimeType,thumbnailSizes:null===(t=e.thumbnails)||void 0===t?void 0:t.map(function(e){return{maxWidth:e.width,maxHeight:e.height}}),_thumbnails:e.thumbnails,_uploadedMetaData:{requireAuth:e._requireAuth,isUploaded:!0}}})}))}var Ln=(0,s.j)((0,s.j)({},ke),{fileInfoList:[],message:""}),Fn=function(e){function t(){var t=null!==e&&e.apply(this,arguments)||this;return t._onFileUploaded=s.aD,t}return(0,s.c)(t,e),t.prototype._triggerOnFileUploaded=function(e,t,n,r){this._onFileUploaded(e,t,n,r)},t.prototype.onFileUploaded=function(e){return this._onFileUploaded=e,this},t.prototype.onPending=function(t){return e.prototype.onPending.call(this,t),this},t.prototype.onFailed=function(t){return e.prototype.onFailed.call(this,t),this},t.prototype.onSucceeded=function(t){return e.prototype.onSucceeded.call(this,t),this},t}(Ce),qn=function(e){function t(t,n){var r=e.call(this,t)||this;return r.message=null,r.message=re(t,n.message),r}return(0,s.c)(t,e),t}(s.ak),jn=function(e){function t(t){var n=this,r=t.channelType,i=t.channelUrl,a=t.limit,o=t.token,u=t.includeReactions,c=t.includeMetaArray,l=t.includeParentMessageInfo,d=t.includeThreadInfo,h=t.includePollDetails;return(n=e.call(this)||this).method=s.A.GET,n.path="".concat((0,s.aq)(r),"/").concat(encodeURIComponent(i),"/pinned_messages"),n.params=(0,s.e)({limit:a,token:o,include_reactions_summary:u,with_sorted_meta_array:c,include_thread_info:d,include_parent_message_info:l,include_poll_details:h}),n}return(0,s.c)(t,e),t}(s.f),zn=function(e){function t(t,n){var r=e.call(this,t,n)||this,i=n.pinned_messages,s=n.has_more,a=n.next;return r.pinnedMessages=i.map(function(e){return new qn(t,e)}),r.hasMore=s,r.token=a,r}return(0,s.c)(t,e),t}(s.g),Vn=function(e){function t(t,n,r,i){var s=e.call(this,t,n,r,i)||this;return s.includeMetaArray=i.includeMetaArray,s.includeReactions=i.includeReactions,s.includeParentMessageInfo=i.includeParentMessageInfo,s.includeThreadInfo=i.includeThreadInfo,s.includePollDetails=i.includePollDetails,s}return(0,s.c)(t,e),t.prototype._validate=function(){return e.prototype._validate.call(this)&&(0,s.a)("boolean",this.includeMetaArray,!0)&&(0,s.a)("boolean",this.includeReactions,!0)&&(0,s.a)("boolean",this.includeParentMessageInfo,!0)&&(0,s.a)("boolean",this.includeThreadInfo,!0)&&(0,s.a)("boolean",this.includePollDetails,!0)},t.prototype.next=function(){return(0,s._)(this,void 0,void 0,function(){var e,t,n,r,i,a,o;return(0,s.b)(this,function(u){switch(u.label){case 0:return this._val
1idate()?this._isLoading?[3,3]:this._hasNext?(this._isLoading=!0,e=s.V.of(this._iid).requestQueue,t=new jn((0,s.j)((0,s.j)({},this),{token:this._token})),[4,e.send(t)]):[3,2]:[3,5];case 1:return n=u.sent(),r=n.as(zn),i=r.pinnedMessages,a=r.hasMore,o=r.token,this._token=o,this._hasNext=!!a,this._isLoading=!1,[2,i];case 2:return[2,[]];case 3:throw s.t.queryInProgress;case 4:return[3,6];case 5:throw s.t.invalidParameters;case 6:return[2]}})})},t}(a.c),Bn=function(e){function t(t){var n=t.channelType,r=t.channelUrl,i=t.messageId,a=e.call(this)||this;return a.method=s.A.POST,a.path="".concat((0,s.aq)(n),"/").concat(encodeURIComponent(r),"/messages/").concat(i,"/pin"),a}return(0,s.c)(t,e),t}(s.f);!function(e){(0,s.c)(function(t,n){return e.call(this,t,n)||this},e)}(s.g);var Kn=function(e){function t(t){var n=t.channelType,r=t.channelUrl,i=t.messageId,a=e.call(this)||this;return a.method=s.A.DELETE,a.path="".concat((0,s.aq)(n),"/").concat(encodeURIComponent(r),"/messages/").concat(i,"/pin"),a}return(0,s.c)(t,e),t}(s.f);!function(e){(0,s.c)(function(t,n){return e.call(this,t,n)||this},e)}(s.g);var Qn,Gn=2;!function(e){e.SEND="send",e.RESEND="resend",e.COPY="copy"}(Qn||(Qn={}));var Hn,Wn=function(e){function t(t,n){var r,i,a,o,u,c,l,d=this;return(d=e.call(this,t)||this)._name="",d._createdAt=0,d.pinnedMessageIds=[],d.channelType=s.C.BASE,d.coverUrl="",d.customType="",d.data="",d.isFrozen=!1,d.isEphemeral=!1,d.creator=null,d._messageCollectionLastAccessedAt=0,d._url=n.channel_url,d._name=null!==(r=n.name)&&void 0!==r?r:"",d._createdAt=1e3*n.created_at,d.coverUrl=null!==(i=n.cover_url)&&void 0!==i?i:"",d.customType=null!==(a=n.custom_type)&&void 0!==a?a:"",d.data=null!==(o=n.data)&&void 0!==o?o:"",d.isFrozen=null!==(u=n.freeze)&&void 0!==u&&u,d.isEphemeral=null!==(c=n.is_ephemeral)&&void 0!==c&&c,d.creator=n.created_by?new s.U(d._iid,n.created_by):null,n.metadata&&Object.keys(n.metadata).length>0&&n.ts?(d._cachedMetaData=new Map,Object.keys(n.metadata).forEach(function(e){d._cachedMetaData.set(e,{value:n.metadata[e],isRemoved:!1,updatedAt:n.ts})})):"string"==typeof n.metadata&&(d._cachedMetaData=new Map(Object.entries(JSON.parse(n.metadata)))),d.pinnedMessageIds=null!==(l=n.pinned_message_ids)&&void 0!==l?l:[],d}return(0,s.c)(t,e),Object.defineProperty(t.prototype,"url",{get:function(){return this._url},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"name",{get:function(){return this._name},set:function(e){this._name=e},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"createdAt",{get:function(){return this._createdAt},enumerable:!1,configurable:!0}),t.prototype.toJSON=function(){return(0,s.j)((0,s.j)({},this),{url:this._url,name:this._name,createdAt:this._createdAt})},t.payloadify=function(t,n){void 0===n&&(n=!1);var r=(0,s.j)((0,s.j)({},e.payloadify.call(this,t)),{channel_url:t.url,name:t.name,cover_url:t.coverUrl,custom_type:t.customType,data:t.data,freeze:t.isFrozen,is_ephemeral:t.isEphemeral,created_by:t.creator?s.U.payloadify(t.creator):null,created_at:t.createdAt/1e3,metadata:t.cachedMetaData,pinned_message_ids:t.pinnedMessageIds});return n?r:(0,s.e)((0,s.u)(r))},t.prototype.isGroupChannel=function(){return this.channelType===s.C.GROUP},t.prototype.isOpenChannel=function(){return this.channelType===s.C.OPEN},t.prototype.isFeedChannel=function(){return this.channelType===s.C.FEED},Object.defineProperty(t.prototype,"cachedMetaData",{get:function(){var e={};return this._cachedMetaData?(this._cachedMetaData.forEach(function(t,n){t.isRemoved||(e[n]=t.value)}),e):e},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"messageCollectionLastAccessedAt",{get:function(){return this._messageCollectionLastAccessedAt},enumerable:!1,configurable:!0}),t.prototype._serializeCachedMetaData=function(){return this._cachedMetaData?{cachedMetaData:JSON.stringify(Object.fromEntries(this._cachedMetaData))}:{}},t.prototype._updateMessageCollectionLastAccessedAt=function(){this._messageCollectionLastAccessedAt=Date.now()},t.prototype._update=function(e){Object.assign(this,e)},t.prototype._upsertCachedMetaData=function(e,t){var n=this;Object.keys(e).forEach(function(r){n._cachedMetaData||(n._cachedMetaData=new Map);var i=n._cachedMetaData.get(r);(!i||i.updatedAt<=t)&&n._cachedMetaData.set(r,{value:e[r],isRemoved:!1,updatedAt:t})})},t.prototype._updateCachedMetaData=function(e,t){var n=this,r=!1;return this._cachedMetaData?this._cachedMetaData.forEach(function(i,s){var a;i.updatedAt<=t&&(n._cachedMetaData.set(s,{value:null!==(a=e[s])&&void 0!==a?a:i.value,isRemoved:!e[s],updatedAt:t}),r=!0)}):(this._cachedMetaData=new Map,Object.keys(e).forEach(function(r){n._cachedMetaData.set(r,{value:e[r],isRemoved:!1,updatedAt:t})}
1),r=!0),{isUpdated:r}},t.prototype._removeFromCachedMetaData=function(e,t){var n=this;this._cachedMetaData&&e.forEach(function(e){var r=n._cachedMetaData.get(e);r&&r.updatedAt<t&&(r.isRemoved=!0,r.updatedAt=t)})},t.prototype._clearCachedMetaData=function(){this._cachedMetaData&&this._cachedMetaData.clear()},t.prototype._runIfHandleableWithGroupChannel=function(e){this.isGroupChannel()?e(this):this.isFeedChannel()&&e(this.groupChannel)},t.prototype._generateRequestId=function(){return"rq-".concat((0,s.o)())},t.prototype.isIdentical=function(e){return e&&this.url===e.url},t.prototype.isEqual=function(e){return(0,s.al)(this,e)},t.prototype.createOperatorListQuery=function(e){return void 0===e&&(e={}),new et(this._iid,this.url,this.channelType,e)},t.prototype.createMutedUserListQuery=function(e){return void 0===e&&(e={}),new it(this._iid,this.url,this.channelType,e)},t.prototype.createBannedUserListQuery=function(e){return void 0===e&&(e={}),new ot(this._iid,this.url,this.channelType,e)},t.prototype.createPreviousMessageListQuery=function(e){return void 0===e&&(e={}),new tt(this._iid,this.url,this.channelType,e)},t.prototype.createPinnedMessageListQuery=function(e){return void 0===e&&(e={}),new Vn(this._iid,this.url,this.channelType,e)},t.prototype.addOperators=function(e){return(0,s._)(this,void 0,void 0,function(){var t,n;return(0,s.b)(this,function(r){switch(r.label){case 0:return(0,s.F)((0,s.$)("string",e)).throw(s.t.invalidParameters),t=s.V.of(this._iid).requestQueue,n=new ut({channelUrl:this.url,channelType:this.channelType,operatorUserIds:e}),[4,t.send(n)];case 1:return r.sent(),[2]}})})},t.prototype.removeOperators=function(e){return(0,s._)(this,void 0,void 0,function(){var t,n;return(0,s.b)(this,function(r){switch(r.label){case 0:return(0,s.F)((0,s.$)("string",e)).throw(s.t.invalidParameters),t=s.V.of(this._iid).requestQueue,n=new ct({channelUrl:this.url,channelType:this.channelType,operatorUserIds:e}),[4,t.send(n)];case 1:return r.sent(),[2]}})})},t.prototype.getMyMutedInfo=function(){return(0,s._)(this,void 0,void 0,function(){var e,t,n,r,i,a,o,u,c,l,d;return(0,s.b)(this,function(h){switch(h.label){case 0:return e=s.V.of(this._iid),t=e.sdkState,n=e.requestQueue,r=new lt({channelUrl:this.url,channelType:this.channelType,userId:t.userId}),[4,n.send(r)];case 1:return i=h.sent(),a=i.as(dt),o=a.isMuted,u=a.startAt,c=a.endAt,l=a.remainingDuration,d=a.description,[2,{isMuted:o,startAt:u,endAt:c,remainingDuration:l,description:d}]}})})},t.prototype.getMetaData=function(e){return(0,s._)(this,void 0,void 0,function(){var t,n,r,i,a,o;return(0,s.b)(this,function(u){switch(u.label){case 0:return(0,s.F)((0,s.$)("string",e)).throw(s.t.invalidParameters),t=s.V.of(this._iid).requestQueue,n=new ht({channelUrl:this.url,channelType:this.channelType,keys:e}),[4,t.send(n)];case 1:return r=u.sent(),i=r.as(ft),a=i.metadata,o=i.ts,this._upsertCachedMetaData(a,o),[2,a]}})})},t.prototype.getAllMetaData=function(){return(0,s._)(this,void 0,void 0,function(){var e,t,n,r,i,a;return(0,s.b)(this,function(o){switch(o.label){case 0:return e=s.V.of(this._iid).requestQueue,t=new ht({channelUrl:this.url,channelType:this.channelType,keys:[]}),[4,e.send(t)];case 1:return n=o.sent(),r=n.as(ft),i=r.metadata,a=r.ts,this._updateCachedMetaData(i,a),[2,i]}})})},t.prototype.createMetaData=function(e){return(0,s._)(this,void 0,void 0,function(){var t,n,r,i;return(0,s.b)(this,function(a){switch(a.label){case 0:return t=s.V.of(this._iid).requestQueue,n=new pt({channelUrl:this.url,channelType:this.channelType,metadata:e}),[4,t.send(n)];case 1:return r=a.sent(),i=r.as(mt).metaData,this._upsertCachedMetaData(i,0),[2,i]}})})},t.prototype.updateMetaData=function(e,t){return void 0===t&&(t=!1),(0,s._)(this,void 0,void 0,function(){var n,r,i,a,o,u;return(0,s.b)(this,function(c){switch(c.label){case 0:return n=s.V.of(this._iid).requestQueue,r=new _t({channelUrl:this.url,channelType:this.channelType,metadata:e,upsert:t}),[4,n.send(r)];case 1:return i=c.sent(),a=i.as(vt),o=a.metadata,u=a.ts,this._upsertCachedMetaData(o,u),[2,o]}})})},t.prototype.deleteMetaData=function(e){return(0,s._)(this,void 0,void 0,function(){var t,n,r,i;return(0,s.b)(this,function(a){switch(a.label){case 0:return(0,s.F)((0,s.a)("string",e)).throw(s.t.invalidParameters),t=s.V.of(this._iid).requestQueue,n=new gt({channelUrl:this.url,channelType:this.channelType,key:e}),[4,t.send(n)];case 1:return r=a.sent(),i=r.as(bt).ts,this._removeFromCachedMetaData([e],i),[2]}})})},t.prototype.deleteAllMetaData=function(){return(0,s._)(this,void 0,void 0,function(){var e,t,n,r;return(0,s.b)(this,function(i){switch(i.label){case 0:return e=s.V.of(this._iid).requestQueue,t=new It({channelUrl:this.url,channelType:this.channelType}),[4,e.send(t)];case 1:return n=i.sent(),r=n.as(Et).ts,this._removeFromCachedMetaData((0,s.q)([],(0,s.r)(this._cachedMetaData.keys()),!1),r),[2]}})})},t.prototype.getMetaCounters=function(e){return(0,s._)(this,void 0,void 0,function(){var t,n;return(0,s.b)(this,function(r){switch(r.label){case 0:return(0,s.F)((0,s.$)("string",e)).throw(s.t.invalidParameters),t=s.V.of(this._iid).requestQueue,n=new wt({channelUrl:this.url,channelType:this.channelType,keys:e}),[4,t.send(n)];case 1:return[2,r.sent().as(Tt).metaCounter]}})})},t.prototype.getAllMetaCounters=function(){return(0,s._)(this,void 0,void 0,function(){var e,t;return(0,s.b)(this,function(n){switch(n.label){case 0:return e=s.V.of(this._iid).requestQueue,t=new wt({channelUrl:this.url,channelType:this.channelType,keys:[]}),[4,e.send(t)];case 1:return[2,n.sent().as(Tt).metaCounter]}})})},t.prototype.createMetaCounters=function(e){return(0,s._)(this,void 0,void 0,function(){var t,n;return(0,s.b)(this,function(r){switch(r.label){case 0:return t=s.V.of(this._iid).requestQueue,n=new Mt({channelUrl:this.url,channelType:this.channelType,metaCounter:e}),[4,t.send(n)];case 1:return[2,r.sent().as(At).metaCounter]}})})},t.prototype.updateMetaCounters=function(e,t){return void 0===t&&(t=!1),(0,s._)(this,void 0,void 0,function(){var n,r;return(0,s.b)(this,function(i){switch(i.label){case 0:return n=s.V.of(this._iid).requestQueue,r=new Ut({channelUrl:this.url,channelType:this.channelType,metaCounter:e,upsert:t}),[4,n.send(r)];case 1:return[2,i.sent().as(St).metaCounter]}})})},t.prototype.increaseMetaCounters=function(e){return(0,s._)(this,void 0,void 0,function(){var t,n;return(0,s.b)(this,function(r){switch(r.label){case 0:return t=s.V.of(this._iid).requestQueue,n=new Ut({channelUrl:this.url,channelType:this.channelType,metaCounter:e,upsert:!1,mode:"increase"}),[4,t.send(n)];case 1:return[2,r.sent().as(St).metaCounter]}})})},t.prototype.decreaseMetaCounters=function(e){return(0,s._)(this,void 0,void 0,function(){var t,n;return(0,s.b)(this,function(r){switch(r.label){case 0:return t=s.V.of(this._iid).requestQueue,n=new Ut({channelUrl:this.url,channelType:this.channelType,metaCounter:e,upsert:!1,mode:"decrease"}),[4,t.send(n)];case 1:return[2,r.sent().as(St).metaCounter]}})})},t.prototype.deleteMetaCounter=function(e){return(0,s._)(this,void 0,void 0,function(){var t,n;return(0,s.b)(this,function(r){switch(r.label){case 0:return(0,s.F)((0,s.a)("string",e)).throw(s.t.invalidParameters),t=s.V.of(this._iid).requestQueue,n=new Ct({channelUrl:this.url,channelType:this.channelType,key:e}),[4,t.send(n)];case 1:return r.sent(),[2]}})})},t.prototype.deleteAllMetaCounters=function(){return(0,s._)(this,void 0,void 0,function(){var e,t;return(0,s.b)(this,function(n){switch(n.label){case 0:return e=s.V.of(this._iid).requestQueue,t=new kt({channelUrl:this.url,channelType:this.channelType}),[4,e.send(t)];case 1:return n.sent(),[2]}})})},t.prototype.muteUser=function(e,t,n){return(0,s._)(this,void 0,void 0,function(){return(0,s.b)(this,function(r){return[2,this.muteUserWithUserId(e.userId,t,n)]})})},t.prototype.muteUserWithUserId=function(e,t,n){return(0,s._)(this,void 0,void 0,function(){var r,i;return(0,s.b)(this,function(a){switch(a.label){case 0:return(0,s.F)((0,s.a)("string",e)&&(0,s.a)("number",t,!0)&&(0,s.a)("string",n,!0)).throw(s.t.invalidParameters),r=s.V.of(this._iid).requestQueue,i=new Ot({channelUrl:this.url,channelType:this.channelType,userId:e,seconds:t,description:n}),[4,r.send(i)];case 1:return a.sent(),[2]}})})},t.prototype.unmuteUser=function(e){return(0,s._)(this,void 0,void 0,function(){return(0,s.b)(this,function(t){return[2,this.unmuteUserWithUserId(e.userId)]})})},t.prototype.unmuteUserWithUserId=function(e){return(0,s._)(this,void 0,void 0,function(){var t,n;return(0,s.b)(this,function(r){switch(r.label){case 0:return(0,s.F)((0,s.a)("string",e)).throw(s.t.invalidParameters),t=s.V.of(this._iid).requestQueue,n=new Rt({channelUrl:this.url,channelType:this.channelType,userId:e}),[4,t.send(n)];case 1:return r.sent(),[2]}})})},t.prototype.banUser=function(e,t,n){return(0,s._)(this,void 0,void 0,function(){return(0,s.b)(this,function(r){return[2,this.banUserWithUserId(e.userId,t,n)]})})},t.prototype.banUserWithUserId=function(e,t,n){return(0,s._)(this,void 0,void 0,function(){var r,i;return(0,s.b)(this,function(a){switch(a.label){case 0:return(0,s.F)((0,s.a)("string",e)&&(0,s.a)("number",t,!0)&&(0,s.a)("string",n,!0)).throw(s.t.invalidParameters),r=s.V.of(this._iid).requestQueue,i=new xt({channelUrl:this.url,channelType:this.channelType,userId:e,seconds:t,description:n}),[4,r.send(i)];case 1:return a.sent(),[2]}})})},t.prototype.unbanUser=function(e){return(0,s._)(this,void 0,void 0,function(){return(0,s.b)(this,function(t){return[2,this.unbanUserWithUserId(e.userId)]})})},t.prototype.unbanUserWithUserId=function(e){return(0,s._)(this,void 0,void 0,function(){var t,n;return(0,s.b)(this,function(r){switch(r.label){case 0:return(0,s.F)((0,s.a)("string",e)).throw(s.t.invalidParameters),t=s.V.of(this._iid).requestQueue,n=new Ft({channelUrl:this.url,channelType:this.channelType,userId:e}),[4,t.send(n)];case 1:return r.sent(),[2]}})})},t.prototype.freeze=function(){return(0,s._)(this,void 0,void 0,function(){var e,t;return(0,s.b)(this,function(n){switch(n.label){case 0:return e=s.V.of(this._iid).requestQueue,t=new jt({channelUrl:this.url,channelType:this.channelType,freezing:!0}),[4,e.send(t)];case 1:return n.sent(),this.isFrozen=!0,[2]}})})},t.prototype.unfreeze=function(){return(0,s._)(this,void 0,void 0,function(){var e,t;return(0,s.b)(this,function(n){switch(n.label){case 0:return e=s.V.of(this._iid).requestQueue,t=new jt({channelUrl:this.url,channelType:this.channelType,freezing:!1}),[4,e.send(t)];case 1:return n.sent(),this.isFrozen=!1,[2]}})})},t.prototype.getMessagesByMessageId=function(e,t){return(0,s._)(this,void 0,void 0,function(){var n;return(0,s.b)(this,function(r){switch(r.label){case 0:return n=(0,s.j)((0,s.j)({},pe),t),(0,s.F)((0,s.a)("number",e)&&me(n)).throw(s.t.invalidParameters),[4,Di.of(this._iid).getMessagesByMessageId(this.url,this.channelType,e,n)];case 1:return[2,r.sent()]}})})},t.prototype.getMessagesByTimestamp=function(e,t){return(0,s._)(this,void 0,void 0,function(){var n;return(0,s.b)(this,function(r){switch(r.label){case 0:return n=(0,s.j)((0,s.j)({},pe),t),(0,s.F)((0,s.a)("number",e)&&me(n)).throw(s.t.invalidParameters),[4,Di.of(this._iid).getMessagesByTimestamp(this.url,this.channelType,e,n)];case 1:return[2,r.sent()]}})})},t.prototype.getMessageChangeLogsSinceTimestamp=function(e,t){return void 0===t&&(t={}),(0,s._)(this,void 0,void 0,function(){var n;return(0,s.b)(this,function(r){switch(r.label){case 0:return n=(0,s.j)((0,s.j)({},_e),t),(0,s.F)((0,s.a)("number",e)&&ve(n)).throw(s.t.invalidParameters),[4,Di.of(this._iid).getMessageChangelogs(this.url,this.channelType,e,n)];case 1:return[2,r.sent()]}})})},t.prototype.getMessageChangeLogsSinceToken=function(e,t){return void 0===t&&(t={}),(0,s._)(this,void 0,void 0,function(){var n;return(0,s.b)(this,function(r){switch(r.label){case 0:return n=(0,s.j)((0,s.j)({},_e),t),(0,s.F)((0,s.a)("string",e)&&ve(n)).throw(s.t.invalidParameters),[4,Di.of(this._iid).getMessageChangelogs(this.url,this.channelType,e,n)];case 1:return[2,r.sent()]}})})},t.prototype._createPendingSendableMessagePayload=function(e,t,n){var r,i=s.V.of(this._iid).sessionManager;return(0,s.e)((0,s.u)({channel_url:this.url,channel_type:this.channelType,msg_id:0,parent_message_id:e.parentMessageId,data:e.data,custom_type:e.customType,mention_type:e.mentionType,sorted_metaarray:e.metaArrays?e.metaArrays.map(function(e){return b.payloadify(e)}):null,apple_critical_alert_options:e.appleCriticalAlertOptions?v.payloadify(e.appleCriticalAlertOptions):null,created_at:n,user:i.currentUser?g.payloadify(i.currentUser):null,req_id:t,request_state:s.as.PENDING,mentioned_user_ids:e.mentionedUserIds,mentioned_users:null===(r=e.mentionedUsers)||void 0===r?void 0:r.map(function(e){return s.U.payloadify(e)})}))},t.prototype._createPendingUserMessage=function(e,t,n){var r,a,o={};if(e.translationTargetLanguages)try{for(var u=(0,s.w)(e.translationTargetLanguages),c=u.next();!c.done;c=u.next())o[c.value]=""}catch(i){r={error:i}}finally{try{c&&!c.done&&(a=u.return)&&a.call(u)}finally{if(r)throw r.error}}var l=(0,s.e)((0,s.j)((0,s.j)({},this._createPendingSendableMessagePayload(e,t,n)),{type:s.am.USER,message:e.message,translations:o,extended_message_payload:e.extendedMessagePayload})),d=new X(this._iid,l);return d.messageParams=e,d},t.prototype._createPendingScheduledUserMessage=function(e,t,n){var r=this._createPendingUserMessage(e,t,n);
1return r.scheduledInfo={scheduledMessageId:0,scheduledAt:e.scheduledAt,scheduledMessageParams:e},r},t.prototype._createPendingFileMessage=function(e,t,n){var r,i,a,u,c,l,d,h=(0,s.e)((0,s.j)((0,s.j)({},this._createPendingSendableMessagePayload(e,t,n)),{type:s.am.FILE,url:e.fileUrl,file:{name:null!==(r=e.fileName)&&void 0!==r?r:null===(i=e.file)||void 0===i?void 0:i.name,size:null!==(a=e.fileSize)&&void 0!==a?a:null===(u=e.file)||void 0===u?void 0:u.size,type:null!==(c=e.mimeType)&&void 0!==c?c:null===(l=e.file)||void 0===l?void 0:l.type,data:e.data},thumbnails:null===(d=e._thumbnails)||void 0===d?void 0:d.map(function(e){return o.payloadify(e)}),message:e.message})),f=new ie(this._iid,h);return f.messageParams=e,f},t.prototype._createPendingMultipleFilesMessage=function(e,t,n){var r=(0,s.e)((0,s.j)((0,s.j)({},this._createPendingSendableMessagePayload(e,t,n)),{type:s.am.FILE,file:e.fileInfoList.length>0?{name:e.fileInfoList[0].fileName,size:e.fileInfoList[0].fileSize,type:e.fileInfoList[0].mimeType,data:e.data}:void 0,message:e.message})),i=new Z(this._iid,r);return i.messageParams=e,i},t.prototype._validateFailedFileMessageHasFile=function(e,t){var n;return Boolean(e.url)||(0,s.i)(t)||(0,s.i)(null===(n=e.messageParams)||void 0===n?void 0:n.file)},t.prototype._createPendingScheduledFileMessage=function(e,t,n){var r=this._createPendingFileMessage(e,t,n);return r.scheduledInfo={scheduledMessageId:0,scheduledAt:e.scheduledAt,scheduledMessageParams:e},r},t.prototype._markMessageAsFailed=function(e,t,n){void 0===n&&(n=!1),e.errorCode=t.code,t.code===s.D.REQUEST_CANCELED||t.code===s.D.FILE_UPLOAD_CANCEL_FAILED?e.sendingStatus=s.as.CANCELED:n||(e.sendingStatus=s.as.FAILED)},t.prototype.sendUserMessage=function(e){var t=(0,s.j)((0,s.j)({},Re),e);return(0,s.F)(Fe(t)).throw(s.t.invalidParameters),this._sendUserMessage(t)},t.prototype._sendUserMessage=function(e,t,n){var r=this;void 0===t&&(t=Qn.SEND);var i=s.V.of(this._iid),o=i.dispatcher,u=i.requestQueue,c=null!=n?n:this._generateRequestId(),l=Date.now(),d=new Ce;return(0,s.az)(2).then(function(){var n=r._createPendingUserMessage(e,c,l);o.dispatch(new a.M({messages:[n],source:t===Qn.RESEND?a.C.LOCAL_MESSAGE_RESEND_STARTED:a.C.EVENT_MESSAGE_SENT_PENDING})),(0,s.K)(function(){return(0,s._)(r,void 0,void 0,function(){return(0,s.b)(this,function(e){return[2,d._trigger(n)]})})});var i=new Ht((0,s.j)((0,s.j)({},e),{channelUrl:r.url,channelType:r.channelType,reqId:c}));
1u.send(i).then(function(e){var t=e.as(Wt).message;o.dispatch(new a.M({messages:[t],source:a.C.EVENT_MESSAGE_SENT_SUCCESS})),(0,s.K)(function(){return(0,s._)(r,void 0,void 0,function(){return(0,s.b)(this,function(e){return[2,d._trigger(t)]})})})}).catch(function(t){if((0,s.Z)(t))throw t;(0,s.az)(2).then(function(){var n=r._createPendingUserMessage(e,c,l),i=s.V.of(r._iid).cacheContext,u=i.localCacheEnabled&&i.localCacheConfig.enableAutoResend&&(0,s.aK)(t.code);r._markMessageAsFailed(n,t,u),o.dispatch(new a.M({messages:[n],source:n.sendingStatus===s.as.PENDING?a.C.REQUEST_RESEND_MESSAGE:a.C.EVENT_MESSAGE_SENT_FAILED})),(0,s.K)(function(){return(0,s._)(r,void 0,void 0,function(){return(0,s.b)(this,function(e){return[2,d._triggerFailed(t,n)]})})})})})}),d},t.prototype._autoResendUserMessage=function(e){return(0,s.F)(e instanceof X&&!!e.messageParams).throw(s.t.invalidParameters),this._sendUserMessage(e.messageParams,Qn.SEND,e.reqId)},t.prototype.resendUserMessage=function(e){var t;return(0,s._)(this,void 0,void 0,function(){var n,r;return(0,s.b)(this,function(i){return(0,s.F)(e instanceof X&&!e.scheduledInfo).throw(s.t.invalidParameters),n=new s.aA,r=null!==(t=e.messageParams)&&void 0!==t?t:Le(e),this._sendUserMessage(r,Qn.RESEND,e.reqId).onFailed(function(e){return n.reject(e)}).onSucceeded(function(e){return n.resolve(e)}),[2,n.promise]})})},t.prototype.updateUserMessage=function(e,t){return(0,s._)(this,void 0,void 0,function(){var n,r,i;return(0,s.b)(this,function(a){switch(a.label){case 0:return n=(0,s.j)((0,s.j)({},Ye),t),(0,s.F)((0,s.a)("number",e)&&Je(n)).throw(s.t.invalidParameters),r=s.V.of(this._iid).requestQueue,i=new Yt((0,s.j)({channelType:this.channelType,channelUrl:this.url,messageId:e,metaArrayParams:n.metaArrays?{array:n.metaArrays,mode:"add",upsert:!0}:void 0},n)),[4,r.send(i)];case 1:return[2,a.sent().as(Jt).message]}})})},t.prototype.copyUserMessage=function(e,n){var r,i,a;return(0,s._)(this,void 0,void 0,function(){var o,u;return(0,s.b)(this,function(c){return(0,s.F)(e instanceof t&&n instanceof X&&n.sendingStatus===s.as.SUCCEEDED&&this.url===n.channelUrl&&!n.scheduledInfo).throw(s.t.invalidParameters),(0,s.F)(!n.poll).throw(s.t.notSupportedError),o=new s.aA,u=null!==(r=n.messageParams)&&void 0!==r?r:(0,s.u)((0,s.j)((0,s.j)({},n),{mentionType:n.mentionType,mentionedUserIds:null!==(i=n.mentionedUserIds)&&void 0!==i?i:null===(a=n.mentionedUsers)||void 0===a?void 0:a.map(function(e){return e.userId}),translationTargetLanguages:Object.keys(n.translations),pushNotificationDeliveryOption:s.aw.DEFAULT,parentMessageId:null,isReplyToChannel:!1,isPinnedMessage:!1})),e._sendUserMessage(u).onSucceeded(function(e){o.resolve(e)}).onFailed(function(e){return o.reject(e)}),[2,o.promise]})})},t.prototype.translateUserMessage=function(e,t){return(0,s._)(this,void 0,void 0,function(){var n,r;return(0,s.b)(this,function(i){switch(i.label){case 0:return(0,s.F)(e instanceof X&&e.messageId>0&&(0,s.$)("string",t)).throw(s.t.invalidParameters),n=s.V.of(this._iid).requestQueue,r=new rn({channelType:this.channelType,channelUrl:this.url,messageId:e.messageId,translationTargetLanguages:t}),[4,n.send(r)];case 1:return[2,i.sent().as(sn).message]}})})},t.prototype._createScheduledUserMessage=function(e,t){var n=this,r=s.V.of(this._iid).requestQueue,i=Date.now(),a=this._generateRequestId();(0,s.az)(2).then(function(){var r=n._createPendingScheduledUserMessage(e,a,i);(0,s.K)(function(){return(0,s._)(n,void 0,void 0,function(){return(0,s.b)(this,function(e){return[2,t._trigger(r)]})})})});var o=new an((0,s.j)({reqId:a,channelType:this.channelType,channelUrl:this.url},e));r.send(o).then(function(e){var r=e.as(on).message;(0,s.K)(function(){return(0,s._)(n,void 0,void 0,function(){return(0,s.b)(this,function(e){return[2,t._trigger(r)]})})})}).catch(function(r){if((0,s.Z)(r))throw r;(0,s.az)(2).then(function(){var o=n._createPendingScheduledUserMessage(e,a,i);n._markMessageAsFailed(o,r),(0,s.K)(function(){return(0,s._)(n,void 0,void 0,function(){return(0,s.b)(this,function(e){return[2,t._triggerFailed(r,o)]})})})})})},t.prototype.sendFileMessage=function(e){var t=(0,s.j)((0,s.j)({},Ve),e);return(0,s.F)(Ge(t)).throw(s.t.invalidParameters),this._sendFileMessage(t)},t.prototype.sendMultipleFilesMessage=function(e){var t,n=(0,s.j)((0,s.j)({},Ln),e),r=s.V.of(this._iid);(0,s.F)(function(e,t){return void 0===t&&(t=s.aJ),Oe(e)&&(0,s.a)("string",e.message,!0)&&Array.isArray(e.fileInfoList)&&e.fileInfoList.length>=2&&e.fileInfoList.length<=t&&e.fileInfoList.every(function(e){return function(e){return((0,s.i)(e.file)||(0,s.a)("string",e.fileUrl))&&(0,s.a)("string",e.fileName,!0)&&(0,s.a)("string",e.mimeType,!0)&&(0,s.a)("number",e.fileSize,!0)&&(void 0===e.thumbnailSizes||Array.isArray(e.thumbnailSizes)&&e.thumbnailSizes.every(function(e){return e.maxWidth>0&&e.maxHeight>0}))}(e)})}(n,null===(t=r.appInfo)||void 0===t?void 0:t.multipleFilesMessageFileCountLimit)).throw(s.t.invalidParameters);var i=!!e.fileInfoList.find(function(e){var t=r.appInfo.uploadSizeLimit;return e.file instanceof Blob&&e.file.size>t||e.fileSize>t});return(0,s.F)(!i).throw(s.t.fileSizeLimitExceededError),this._sendMultipleFilesMessage(n)},t.prototype._sendFileMessage=function(e,t,n){var r=this;void 0===t&&(t=Qn.SEND);var i=s.V.of(this._iid).dispatcher,o=Di.of(this._iid).fileMessageQueue,u=null!=n?n:this._generateRequestId(),c=Date.now(),l=new Ce;return(0,s.az)(2).then(function(){var n=r._createPendingFileMessage(e,u,c);i.dispatch(new a.M({messages:[n],source:t===Qn.RESEND?a.C.LOCAL_MESSAGE_RESEND_STARTED:a.C.EVENT_MESSAGE_SENT_PENDING})),(0,s.K)(function(){return(0,s._)(r,void 0,void 0,function(){return(0,s.b)(this,function(e){return[2,l._trigger(n)]})})}),o.request(r,u,e).then(function(e){i.dispatch(new a.M({messages:[e],source:a.C.EVENT_MESSAGE_SENT_SUCCESS})),(0,s.K)(function(){return(0,s._)(r,void 0,void 0,function(){return(0,s.b)(this,function(t){return[2,l._trigger(e)]})})})}).catch(function(t){if((0,s.Z)(t))throw t;(0,s.az)(2).then(function(){var n=r._createPendingFileMessage(e,u,c),o=s.V.of(r._iid).cacheContext,d=o.localCacheEnabled&&o.localCacheConfig.enableAutoResend&&
1(0,s.aK)(t.code);r._markMessageAsFailed(n,t,d),i.dispatch(new a.M({messages:[n],source:n.sendingStatus===s.as.PENDING?a.C.REQUEST_RESEND_MESSAGE:t.code===s.D.FILE_UPLOAD_CANCEL_FAILED?a.C.LOCAL_MESSAGE_CANCELED:a.C.EVENT_MESSAGE_SENT_FAILED})),(0,s.K)(function(){return(0,s._)(r,void 0,void 0,function(){return(0,s.b)(this,function(e){return[2,l._triggerFailed(t,n)]})})})})})}),l},t.prototype._autoResendFileMessage=function(e){(0,s.F)(e instanceof ie&&!!e.messageParams).throw(s.t.invalidParameters);var t=s.V.of(this._iid).logger;return t.debug("autoResendFileMessage pending",e),this._sendFileMessage(e.messageParams,Qn.SEND,e.reqId).onFailed(function(e){t.debug("autoResendFileMessage failed",e)}).onSucceeded(function(e){t.debug("autoResendFileMessage success",e)})},t.prototype._sendMultipleFilesMessage=function(e,t,n){var r=this,i=s.V.of(this._iid).dispatcher,o=Di.of(this._iid).fileMessageQueue,u=null!=n?n:this._generateRequestId(),c=Date.now(),l=new Fn;return(0,s.az)(2).then(function(){var n=r._createPendingMultipleFilesMessage(e,u,c);i.dispatch(new a.M({messages:[n],source:t===Qn.RESEND?a.C.LOCAL_MESSAGE_RESEND_STARTED:a.C.EVENT_MESSAGE_SENT_PENDING})),(0,s.K)(function(){return(0,s._)(r,void 0,void 0,function(){return(0,s.b)(this,function(e){return[2,l._trigger(n)]})})}),o.request(r,u,e,{requestHandler:l,isCopy:t===Qn.COPY}).then(function(e){i.dispatch(new a.M({messages:[e],source:a.C.EVENT_MESSAGE_SENT_SUCCESS})),(0,s.K)(function(){return(0,s._)(r,void 0,void 0,function(){return(0,s.b)(this,function(t){return[2,l._trigger(e)]})})})}).catch(function(t){if((0,s.Z)(t))throw t;(0,s.az)(2).then(function(){var n=r._createPendingMultipleFilesMessage(e,u,c);r._markMessageAsFailed(n,t),i.dispatch(new a.M({messages:[n],source:a.C.EVENT_MESSAGE_SENT_FAILED})),(0,s.K)(function(){return(0,s._)(r,void 0,void 0,function(){return(0,s.b)(this,function(e){return[2,l._triggerFailed(t,n)]})})})})})}),l},t.prototype._createScheduledFileMessage=function(e,t,n,r){var i=this,a=s.V.of(this._iid).requestQueue,o=new un((0,s.j)((0,s.j)({reqId:n,channelType:this.channelType,channelUrl:this.url},e),{fileUrl:e.fileUrl,requireAuth:e.requireAuth}));a.send(o).then(function(e){var n=e.as(cn).message;(0,s.K)(function(){return(0,s._)(i,void 0,void 0,function(){return(0,s.b)(this,function(e){return[2,t._trigger(n)]})})})}).catch(function(a){if((0,s.Z)(a))throw a;(0,s.az)(2).then(function(){var o=i._createPendingScheduledFileMessage(e,n,r);i._markMessageAsFailed(o,a),(0,s.K)(function(){return(0,s._)(i,void 0,void 0,function(){return(0,s.b)(this,function(e){return[2,t._triggerFailed(a,o)]})})})})})},t.prototype.sendFileMessages=function(e){var t,n;(0,s.F)(e.every(function(e){return Ge((0,s.j)((0,s.j)({},Ve),e))})).throw(s.t.invalidParameters);var r=new Ce;try{for(var i=(0,s.w)(e),a=i.next();!a.done;a=i.next()){var o=a.value;this.sendFileMessage(o).onPending(function(e){return r._trigger(e)}).onFailed(function(e,t){return r._triggerFailed(e,t)}).onSucceeded(function(e){return r._trigger(e)})}}catch(e){t={error:e}}finally{try{a&&!a.done&&(n=i.return)&&n.call(i)}finally{if(t)throw t.error}}return r},t.prototype.resendFileMessage=function(e,t){return(0,s._)(this,void 0,void 0,function(){var n,r,i;return(0,s.b)(this,function(a){return n=this._validateFailedFileMessageHasFile(e,t),(0,s.F)(e instanceof ie&&n&&!e.scheduledInfo).throw(s.t.invalidParameters),r=new s.aA,i=Qe(e,t),this._sendFileMessage(i,Qn.RESEND,e.reqId).onFailed(function(e){return r.reject(e)}).onSucceeded(function(e){return r.resolve(e)}),[2,r.promise]})})},t.prototype.resendMessage=function(e,t){var n,r;if((0,s.F)(e instanceof G&&!e.scheduledInfo&&e.isResendable).throw(s.t.invalidParameters),e.isUserMessage()){var i=null!==(n=e.messageParams)&&void 0!==n?n:Le(e);return this._sendUserMessage(i,Qn.RESEND,e.reqId)}if(e.isFileMessage()){var a=this._validateFailedFileMessageHasFile(e,t);return(0,s.F)(a).throw(s.t.invalidParameters),i=null!==(r=e.messageParams)&&void 0!==r?r:Qe(e,t),this._sendFileMessage(i,Qn.RESEND,e.reqId)}if(e.isMultipleFilesMessage())throw s.t.channelTypeNotSupportedError},t.prototype.updateFileMessage=function(e,t){return(0,s._)(this,void 0,void 0,function(){var n,r,i;return(0,s.b)(this,function(a){switch(a.label){case 0:return n=(0,s.j)((0,s.j)({},$e),t),(0,s.F)((0,s.a)("number",e)&&function(e){return We(e)}(n)).throw(s.t.invalidParameters),r=s.V.of(this._iid).requestQueue,i=new $t((0,s.j)({channelType:this.channelType,channelUrl:this.url,messageId:e,metaArrayParams:n.metaArrays?{array:n.metaArrays,mode:"add",upsert:!0}:void 0},n)),[4,r.send(i)];case 1:return[2,a.sent().as(Xt).message]}})})},t.prototype.uploadFile=function(e){return(0,s._)(this,void 0,void 0,function(){var t,n,r,i,a,o,l;return(0,s.b)(this,function(d){switch(d.label){case 0:return t=s.V.of(this._iid).requestQueue,n=(0,s.o)(),(r=new u({file:e.file,channelUrl:this.url,thumbnailSizes:e.thumbnailSizes,requestId:n})).uploadProgressHandler=e.progressHandler,e.uploadStartedHandler&&e.uploadStartedHandler(n),[4,t.send(r)];case 1:return i=d.sent(),a=i.as(c),o=a.url,l=a.thumbnails,[2,{requestId:n,url:o,thumbnails:l}]}})})},t.prototype.cancelUploadingFileMessage=function(e){return(0,s._)(this,void 0,void 0,function(){return(0,s.b)(this,function(t){return(0,s.F)((0,s.a)("string",e)).throw(s.t.invalidParameters),Di.of(this._iid).fileMessageQueue.cancel(this,e),[2,!0]})})},t.prototype.copyFileMessage=function(e,n){var r,i,a;return(0,s._)(this,void 0,void 0,function(){var o,u;return(0,s.b)(this,function(c){return(0,s.F)(e instanceof t&&n instanceof ie&&n.sendingStatus===s.as.SUCCEEDED&&this.url===n.channelUrl&&!n.scheduledInfo).throw(s.t.invalidParameters),o=new s.aA,u=(0,s.u)((0,s.j)((0,s.j)({},n),{fileUrl:n.url,fileName:n.name,fileSize:n.size,mimeType:n.type,mentionType:n.mentionType,mentionedUserIds:null!==(r=n.mentionedUserIds)&&void 0!==r?r:null===(i=n.mentionedUsers)||void 0===i?void 0:i.map(function(e){return e.userId}),pushNotificationDeliveryOption:s.aw.DEFAULT,parentMessageId:null,isReplyToChannel:!1,thumbnailSizes:null===(a=n.thumbnails)||void 0===a?void 0:a.map(function(e){return{maxWidth:e.width,maxHeight:e.height}}),requireAuth:n.requireAuth,isPinnedMessage:!1})),e._sendFileMessage(u).onSucceeded(function(e){return o.resolve(e)}).onFailed(function(e){return o.reject(e)}),[2,o.promise]})})},t.prototype.copyMessage=function(e,n){(0,s.F)(e instanceof t&&n instanceof G&&n.sendingStatus===s.as.SUCCEEDED&&this.url===n.channelUrl&&!n.scheduledInfo).throw(s.t.invalidParameters);var r=n,i=e;if(r.isUserMessage()){(0,s.F)(!r.poll).throw(s.t.notSupportedError);var a=De(r);
1return i._sendUserMessage(a)}if(r.isFileMessage())return a=Be(r),i._sendFileMessage(a);if(n.isMultipleFilesMessage())throw s.t.channelTypeNotSupportedError},t.prototype.deleteMessage=function(e){return(0,s._)(this,void 0,void 0,function(){var t,n;return(0,s.b)(this,function(r){switch(r.label){case 0:return(0,s.F)(e instanceof Q).throw(s.t.invalidParameters),e.messageId>0?(t=s.V.of(this._iid).requestQueue,n=new s.aL({channelType:this.channelType,channelUrl:this.url,messageId:e.messageId,messageToken:e instanceof G?e._messageToken:void 0}),[4,t.send(n)]):[3,2];case 1:r.sent(),r.label=2;case 2:return[2]}})})},t.prototype.addReaction=function(e,t){return(0,s._)(this,void 0,void 0,function(){var n,r;return(0,s.b)(this,function(i){switch(i.label){case 0:return(0,s.F)(e instanceof Q&&e.messageId>0&&(0,s.a)("string",t)).throw(s.t.invalidParameters),n=s.V.of(this._iid).requestQueue,r=new Zt({channelType:this.channelType,channelUrl:this.url,messageId:e.messageId,reactionKey:t}),[4,n.send(r)];case 1:return[2,i.sent().as(en).reactionEvent]}})})},t.prototype.deleteReaction=function(e,t){return(0,s._)(this,void 0,void 0,function(){var n,r;return(0,s.b)(this,function(i){switch(i.label){case 0:return(0,s.F)(e instanceof Q&&e.messageId>0&&(0,s.a)("string",t)).throw(s.t.invalidParameters),n=s.V.of(this._iid).requestQueue,r=new tn({channelType:this.channelType,channelUrl:this.url,messageId:e.messageId,reactionKey:t}),[4,n.send(r)];case 1:return[2,i.sent().as(nn).reactionEvent]}})})},t.prototype._updateUserMessageMetaArray=function(e,t,n,r){return(0,s._)(this,void 0,void 0,function(){var i,o,u,c,l,d;return(0,s.b)(this,function(h){switch(h.label){case 0:return i=s.V.of(this._iid),o=i.dispatcher,u=i.requestQueue,c=new Yt({channelType:this.channelType,channelUrl:this.url,messageId:e,metaArrayParams:{array:t,mode:n,upsert:r}}),[4,u.send(c)];case 1:return l=h.sent(),d=l.as(Jt).message,o.dispatch(new a.M({messages:[d],source:a.C.EVENT_MESSAGE_UPDATED})),[2,d]}})})},t.prototype._updateFileMessageMetaArray=function(e,t,n,r){return(0,s._)(this,void 0,void 0,function(){var i,o,u,c,l,d;return(0,s.b)(this,function(h){switch(h.label){case 0:return i=s.V.of(this._iid),o=i.dispatcher,u=i.requestQueue,c=new $t({channelType:this.channelType,channelUrl:this.url,messageId:e,metaArrayParams:{array:t,mode:n,upsert:r}}),[4,u.send(c)];case 1:return l=h.sent(),d=l.as(Xt).message,o.dispatch(new a.M({messages:[d],source:a.C.EVENT_MESSAGE_UPDATED})),[2,d]}})})},t.prototype.createMessageMetaArrayKeys=function(e,t){return(0,s._)(this,void 0,void 0,function(){var n;return(0,s.b)(this,function(r){return(0,s.F)(e instanceof Q&&e.messageId>0&&(0,s.$)("string",t)).throw(s.t.invalidParameters),n=t.map(function(e){return new b({key:e})}),e instanceof ie?[2,this._updateFileMessageMetaArray(e.messageId,n,"add",!0)]:[2,this._updateUserMessageMetaArray(e.messageId,n,"add",!0)]})})},t.prototype.deleteMessageMetaArrayKeys=function(e,t){return(0,s._)(this,void 0,void 0,function(){var n;return(0,s.b)(this,function(r){return(0,s.F)(e instanceof Q&&e.messageId>0&&(0,s.$)("string",t)).throw(s.t.invalidParameters),n=t.map(function(e){return new b({key:e})}),e instanceof ie?[2,this._updateFileMessageMetaArray(e.messageId,n,"remove",!0)]:[2,this._updateUserMessageMetaArray(e.messageId,n,"remove",!0)]})})},t.prototype.addMessageMetaArrayValues=function(e,t){return(0,s._)(this,void 0,void 0,function(){return(0,s.b)(this,function(n){return(0,s.F)(e instanceof Q&&e.messageId>0&&t.every(function(e){return e instanceof b})).throw(s.t.invalidParameters),e instanceof ie?[2,this._updateFileMessageMetaArray(e.messageId,t,"add",!0)]:[2,this._updateUserMessageMetaArray(e.messageId,t,"add",!0)]})})},t.prototype.removeMessageMetaArrayValues=function(e,t){return(0,s._)(this,void 0,void 0,function(){return(0,s.b)(this,function(n){return(0,s.F)(e instanceof Q&&e.messageId>0&&t.every(function(e){return e instanceof b})).throw(s.t.invalidParameters),e instanceof ie?[2,this._updateFileMessageMetaArray(e.messageId,t,"remove",!0)]:[2,this._updateUserMessageMetaArray(e.messageId,t,"remove",!0)]})})},t.prototype.report=function(e,t){return(0,s._)(this,void 0,void 0,function(){var n,r,i,a;return(0,s.b)(this,function(o){switch(o.label){case 0:return(0,s.F)(((0,s.a2)(Ke,e)||e instanceof s.ac)&&(0,s.a)("string",t)).throw(s.t.invalidParameters),n=s.V.of(this._iid),r=n.sdkState,i=n.requestQueue,a=new Kt({channelUrl:this.url,channelType:this.channelType,userId:r.userId,category:e,description:t}),[4,i.send(a)];case 1:return o.sent(),[2]}})})},t.prototype.reportUser=function(e,t,n){return(0,s._)(this,void 0,void 0,function(){var r,i,a,o;return(0,s.b)(this,function(u){switch(u.label){case 0:return(0,s.F)(e instanceof s.U&&((0,s.a2)(Ke,t)||t instanceof s.ac)&&(0,s.a)("string",n)).throw(s.t.invalidParameters),r=s.V.of(this._iid),i=r.sdkState,a=r.requestQueue,o=new Qt({channelUrl:this.url,channelType:this.channelType,userId:i.userId,offendingUserId:e.userId,category:t,description:n}),[4,a.send(o)];case 1:return u.sent(),[2]}})})},t.prototype.reportMessage=function(e,t,n){return(0,s._)(this,void 0,void 0,function(){var r,i,a,o;return(0,s.b)(this,function(u){switch(u.label){case 0:return(0,s.F)(e instanceof G&&((0,s.a2)(Ke,t)||t instanceof s.ac)&&(0,s.a)("string",n)).throw(s.t.invalidParameters),r=s.V.of(this._iid),i=r.sdkState,a=r.requestQueue,o=new Gt({channelUrl:this.url,channelType:this.channelType,userId:i.userId,offendingUserId:e.sender.userId,messageId:e.messageId,category:t,description:n,messageToken:e._messageToken}),[4,a.send(o)];case 1:return u.sent(),[2]}})})},t.prototype.updatePoll=function(e,t){return(0,s._)(this,void 0,void 0,function(){var n,r;return(0,s.b)(this,function(i){switch(i.label){case 0:return(0,s.F)((0,s.a)("number",e)&&function(e){return(0,s.a)("string",e.title,!0)&&(0,a.v)(e.data)&&(0,s.a)("boolean",e.allowUserSuggestion,!0)&&(0,s.a)("boolean",e.allowMultipleVotes,!0)&&(0,s.a)("number",e.closeAt,!0)}(t)).throw(s.t.invalidParameters),n=s.V.of(this._iid).requestQueue,r=new ln((0,s.j)({pollId:e},t)),[4,n.send(r)];case 1:return[2,i.sent().as(dn).poll]}})})},t.prototype.deletePoll=function(e){return(0,s._)(this,void 0,void 0,function(){var t,n,r;return(0,s.b)(this,function(i){switch(i.label){case 0:return t=(0,s.a)("number",e),(0,s.F)(t).throw(s.t.invalidParameters),n=s.V.of(this._iid).requestQueue,r=new hn({pollId:e}),[4,n.send(r)];case 1:return i.sent(),[2]}})})},t.prototype.closePoll=function(e){return(0,s._)(this,void 0,void 0,function(){var t,n,r;return(0,s.b)(this,function(i){switch(i.label){case 0:return t=(0,s.a)("number",e),(0,s.F)(t).throw(s.t.invalidParameters),n=s.V.of(this._iid).requestQueue,r=new fn({pollId:e}),[4,n.send(r)];case 1:return[2,i.sent().as(pn).poll]}})})},t.prototype.addPollOption=function(e,t){return(0,s._)(this,void 0,void 0,function(){var n,r,i;return(0,s.b)(this,function(a){switch(a.label){case 0:return n=(0,s.a)("number",e)&&(0,s.a)("string",t)&&""!==t.trim(),(0,s.F)(n).throw(s.t.invalidParameters),r=s.V.of(this._iid).requestQueue,i=new mn({channelUrl:this.url,channelType:this.channelType,pollId:e,optionText:t}),[4,r.send(i)];case 1:return[2,a.sent().as(_n).poll]}})})},t.prototype.updatePollOption=function(e,t,n){return(0,s._)(this,void 0,void 0,function(){var r,i,a;return(0,s.b)(this,function(o){switch(o.label){case 0:return r=(0,s.a)("number",e)&&(0,s.a)("number",t)&&(0,s.a)("string",n)&&""!==n.trim(),(0,s.F)(r).throw(s.t.invalidParameters),i=s.V.of(this._iid).requestQueue,a=new vn({pollId:e,pollOptionId:t,optionText:n}),[4,i.send(a)];case 1:return[2,o.sent().as(yn).poll]}})})},t.prototype.deletePollOption=function(e,t){return(0,s._)(this,void 0,void 0,function(){var n,r,i;return(0,s.b)(this,function(a){switch(a.label){case 0:return n=(0,s.a)("number",e)&&(0,s.a)("number",t),(0,s.F)(n).throw(s.t.invalidParameters),r=s.V.of(this._iid).requestQueue,i=new gn({pollId:e,pollOptionId:t}),[4,r.send(i)];case 1:return a.sent(),[2]}})})},t.prototype.votePoll=function(e,t){return(0,s._)(this,void 0,void 0,function(){var n,r,i,o,u,c,l;return(0,s.b)(this,function(d){switch(d.label){case 0:return n=(0,s.a)("number",e)&&(0,s.$)("number",t),(0,s.F)(n).throw(s.t.invalidParameters),r=s.V.of(this._iid),i=r.requestQueue,o=r.dispatcher,u=new bn({reqId:this._generateRequestId(),channelUrl:this.url,channelType:this.channelType,pollId:e,pollOptionIds:t}),[4,i.send(u)];case 1:return c=d.sent(),l=c.as(In).event,o.dispatch(new a.e({event:l,source:a.C.EVENT_POLL_VOTED})),[2,l]}})})},t.prototype.getPollChangeLogsSinceTimestamp=function(e){return(0,s._)(this,void 0,void 0,function(){return(0,s.b)(this,function(t){switch(t.label){case 0:return(0,s.F)((0,s.a)("number",e)).throw(s.t.invalidParameters),[4,a.f.of(this._iid).getPollChangeLogs(this.url,this.channelType,e)];case 1:return[2,t.sent()]}})})},t.prototype.getPollChangeLogsSinceToken=function(e){return(0,s._)(this,void 0,void 0,function(){return(0,s.b)(this,function(t){switch(t.label){case 0:return(0,s.F)((0,s.a)("string",e,!0)),[4,a.f.of(this._iid).getPollChangeLogs(this.url,this.channelType,e)];case 1:return[2,t.sent()]}})})},t.prototype.createPollListQuery=function(e){return void 0===e&&(e=10),new a.P(this._iid,{channelUrl:this.url,channelType:this.channelType,limit:e})},t.prototype.createPollVoterListQuery=function(e,t,n){return void 0===n&&(n=20),new a.a(this._iid,{channelUrl:this.url,channelType:this.channelType,pollId:e,pollOptionId:t,limit:n})},t.prototype.pinMessage=function(e){return(0,s._)(this,void 0,void 0,function(){var t,n;return(0,s.b)(this,function(r){switch(r.label){case 0:return(0,s.F)((0,s.a)("number",e)&&e>0).throw(s.t.invalidParameters),t=s.V.of(this._iid).requestQueue,n=new Bn({channelType:this.channelType,channelUrl:this.url,messageId:e}),[4,t.send(n)];case 1:return r.sent(),[2]}})})},t.prototype.unpinMessage=function(e){return(0,s._)(this,void 0,void 0,function(){var t,n;return(0,s.b)(this,function(r){switch(r.label){case 0:return(0,s.F)((0,s.a)("number",e)&&e>0).throw(s.t.invalidParameters),t=s.V.of(this._iid).requestQueue,n=new Kn({channelType:this.channelType,channelUrl:this.url,messageId:e}),[4,t.send(n)];case 1:return r.sent(),[2]}})})},t}(s.ak),Yn=function(e){function t(t){void 0===t&&(t={});var n=e.call(this)||this;return Object.keys(t).forEach(function(e){n.hasOwnProperty(e)&&(n[e]=t[e])}),n}return(0,s.c)(t,e),t}(function(){this.onConnected=s.aD,this.onReconnectStarted=s.aD,this.onReconnectSucceeded=s.aD,this.onReconnectFailed=s.aD,this.onDisconnected=s.aD}),Jn=function(e){function t(t){void 0===t&&(t={});var n=e.call(this)||this;return Object.keys(t).forEach(function(e){n.hasOwnProperty(e)&&(n[e]=t[e])}),n}return(0,s.c)(t,e),t}(function(){this.onSessionExpired=s.aD,this.onSessionTokenRequired=function(e){return e(null)},this.onSessionError=s.aD,this.onSessionRefreshed=s.aD,this.onSessionClosed=s.aD}),$n=function(e){function t(t){void 0===t&&(t={});var n=e.call(this)||this;return Object.keys(t).forEach(function(e){n.hasOwnProperty(e)&&(n[e]=t[e])}),n}return(0,s.c)(t,e),t}(function(){this.onFriendsDiscovered=s.aD,this.onTotalUnreadMessageCountChanged=s.aD,this.onTotalUnreadMessageCountUpdated=s.aD}),Xn=function(e){function t(t){var n=t.limit,r=t.token,i=t.userIdsFilter,a=t.metaDataKeyFilter,o=t.metaDataValuesFilter,u=t.nicknameStartsWithFilter,c=e.call(this)||this;return c.method=s.A.GET,c.path=s.h,c.params=(0,s.e)({limit:n,token:r,user_ids:i,metadatakey:a,metadatavalues_in:o,nickname_startswith:u}),c}return(0,s.c)(t,e),t}(s.f),Zn=function(e){function t(t,n){var r=e.call(this,t,n)||this;return r.users=n.users.map(function(e){return new s.U(t,e)}),r.next=n.next,r}return(0,s.c)(t,e),t}(s.g),er=function(e){function t(t,n){var r,i,s,a=this;return(a=e.call(this,t,n)||this).userIdsFilter=null,a.metaDataKeyFilter=null,a.metaDataValuesFilter=null,a.nicknameStartsWithFilter=null,a.userIdsFilter=null!==(r=n.userIdsFilter)&&void 0!==r?r:null,a.metaDataKeyFilter=null!==(i=n.metaDataKeyFilter)&&void 0!==i?i:null,a.metaDataValuesFilter=null!==(s=n.metaDataValuesFilter)&&void 0!==s?s:null,a.nicknameStartsWithFilter=n.nicknameStartsWithFilter||null,a}return(0,s.c)(t,e),t.prototype._validate=function(){return e.prototype._validate.call(this)&&(0,s.$)("string",this.userIdsFilter,!0)&&(0,s.a)("string",this.metaDataKeyFilter,!0)&&(0,s.$)("string",this.metaDataValuesFilter,!0)&&(0,s.a)("string",this.nicknameStartsWithFilter,!0)},t.prototype.next=function(){return(0,s._)(this,void 0,void 0,function(){var e,t,n,r,i,a;return(0,s.b)(this,function(o){switch(o.label){case 0:return this._val
1idate()?this._isLoading?[3,3]:this._hasNext?(this._isLoading=!0,e=s.V.of(this._iid).requestQueue,t=new Xn((0,s.u)((0,s.j)((0,s.j)({},this),{token:this._token}))),[4,e.send(t)]):[3,2]:[3,5];case 1:return n=o.sent(),r=n.as(Zn),i=r.users,a=r.next,this._token=a,this._hasNext=!!a,this._isLoading=!1,[2,i];case 2:return[2,[]];case 3:throw s.t.queryInProgress;case 4:return[3,6];case 5:throw s.t.invalidParameters;case 6:return[2]}})})},t}(s.aM),tr=function(e){function t(t){var n=t.userId,r=t.limit,i=t.token,a=t.userIdsFilter,o=e.call(this)||this;return o.method=s.A.GET,o.path="".concat(s.h,"/").concat(n,"/block"),o.params=(0,s.e)({limit:r,token:i,user_ids:a}),o}return(0,s.c)(t,e),t}(s.f),nr=function(e){function t(t,n){var r=e.call(this,t,n)||this;return r.users=n.users.map(function(e){return new s.U(t,e)}),r.next=n.next,r}return(0,s.c)(t,e),t}(s.g),rr=function(e){function t(t,n){var r,i=this;return(i=e.call(this,t,n)||this).userIdsFilter=null,i.userIdsFilter=null!==(r=n.userIdsFilter)&&void 0!==r?r:null,i}return(0,s.c)(t,e),t.prototype._validate=function(){return e.prototype._validate.call(this)&&(0,s.$)("string",this.userIdsFilter,!0)},t.prototype.next=function(){return(0,s._)(this,void 0,void 0,function(){var e,t,n,r,i,a,o,u;return(0,s.b)(this,function(c){switch(c.label){case 0:return this._validate()?this._isLoading?[3,3]:this._hasNext?(this._isLoading=!0,e=s.V.of(this._iid),t=e.sdkState,n=e.requestQueue,r=new tr((0,s.u)((0,s.j)((0,s.j)({},this),{userId:t.userId,token:this._token}))),[4,n.send(r)]):[3,2]:[3,5];case 1:return i=c.sent(),a=i.as(nr),o=a.users,u=a.next,this._token=u,this._hasNext=!!u,this._isLoading=!1,[2,o];case 2:return[2,[]];case 3:throw s.t.queryInProgress;case 4:return[3,6];case 5:throw s.t.invalidParameters;case 6:return[2]}})})},t}(s.aM),ir=function(e){function t(t){var n=t.userId,r=t.limit,i=t.token,a=e.call(this)||this;return a.method=s.A.GET,a.path="".concat(s.h,"/").concat(encodeURIComponent(n),"/friends"),a.params={limit:r,token:i},a}return(0,s.c)(t,e),t}(s.f),sr=function(e){function t(t,n){var r=e.call(this,t,n)||this;return r.hasMore=n.has_more,r.users=n.users.map(function(e){return new s.U(t,e)}),r.next=n.next,r}return(0,s.c)(t,e),t}(s.g),ar=function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return(0,s.c)(t,e),t.prototype._validate=function(){return e.prototype._validate.call(this)},t.prototype.next=function(){return(0,s._)(this,void 0,void 0,function(){var e,t,n,r,i,a,o,u,c;return(0,s.b)(this,function(l){switch(l.label){case 0:return this._validate()?this._isLoading?[3,3]:this._hasNext?(this._isLoading=!0,e=s.V.of(this._iid),t=e.sdkState,n=e.requestQueue,r=new ir((0,s.j)((0,s.j)({},this),{userId:t.userId,token:this._token})),[4,n.send(r)]):[3,2]:[3,5];case 1:return i=l.sent(),a=i.as(sr),o=a.users,u=a.hasMore,c=a.next,this._token=c,this._hasNext=u,this._isLoading=!1,[2,o];case 2:return[2,[]];case 3:throw s.t.queryInProgress;case 4:return[3,6];case 5:throw s.t.invalidParameters;case 6:return[2]}})})},t}(s.aM),or={},ur=function(){function e(e){var t=e.dbname,n=e.itemSizeLimit,r=void 0===n?1048576:n,i=e.cacheLimit,s=void 0===i?256:i,a=e.blockHashBase,o=void 0===a?2:a,u=e.blockHashMultiplier,c=void 0===u?10:u,l=e.blockHashConstant,d=void 0===l?11:l,h=e.transactionApplyDelay,f=void 0===h?200:h,p=e.disableLogger,m=void 0!==p&&p;return or[t]||(this.itemSizeLimit=r,this.cacheLimit=s,this.blockHashBase=o,this.blockHashMultiplier=c,this.blockHashConstant=d,this.transactionApplyDelay=f,this.disableLogger=m,or[t]=this),or[t]}return e.get=function(e){return or[e]},e}();!function(e){e[e.UNKNOWN_ERROR=6e7]="UNKNOWN_ERROR",e[e.STORE_NOT_DEFINED=61001e3]="STORE_NOT_DEFINED",e[e.STORE_NOT_AVAILABLE=61001001]="STORE_NOT_AVAILABLE",e[e.STORE_NOT_AVAILABLE_IN_PRIVATE_BROWSING=61001002]="STORE_NOT_AVAILABLE_IN_PRIVATE_BROWSING",e[e.STORE_IS_FULL=61001003]="STORE_IS_FULL",e[e.STORE_NOT_INITIALIZED=61001004]="STORE_NOT_INITIALIZED",e[e.STORE_INVALID_KEY_TYPE=61002e3]="STORE_INVALID_KEY_TYPE",e[e.STORE_BROKEN_INTEGRITY=61002001]="STORE_BROKEN_INTEGRITY",e[e.STORE_BROKEN_BLOB=61002002]="STORE_BROKEN_BLOB",e[e.STORE_ENCRYPTION_INVA
1LID=61002003]="STORE_ENCRYPTION_INVALID",e[e.STORE_ITEM_SIZE_LIMIT_EXCEEDED=61017e3]="STORE_ITEM_SIZE_LIMIT_EXCEEDED",e[e.STORE_READ_FAILED=61017001]="STORE_READ_FAILED",e[e.STORE_WRITE_FAILED=61017002]="STORE_WRITE_FAILED",e[e.DATABASE_SCHEMA_NOT_ON_UPGRADE=62002e3]="DATABASE_SCHEMA_NOT_ON_UPGRADE",e[e.COLLECTION_NOT_READY=63001e3]="COLLECTION_NOT_READY",e[e.COLLECTION_KEY_NOT_MATCH=63002e3]="COLLECTION_KEY_NOT_MATCH",e[e.COLLECTION_QUERY_NOT_VALID=63002001]="COLLECTION_QUERY_NOT_VALID",e[e.COLLECTION_KEY_NOT_FOUND=63004e3]="COLLECTION_KEY_NOT_FOUND",e[e.COLLECTION_KEY_NOT_GIVEN=63004001]="COLLECTION_KEY_NOT_GIVEN",e[e.COLLECTION_INSERT_DUPLICATE=63009e3]="COLLECTION_INSERT_DUPLICATE",e[e.COLLECTION_WRITE_FAILED=63017e3]="COLLECTION_WRITE_FAILED",e[e.COLLECTION_ITEM_SIZE_LIMIT_EXCEEDED=63017001]="COLLECTION_ITEM_SIZE_LIMIT_EXCEEDED",e[e.INDEX_TABLE_IS_REQUIRED=65001e3]="INDEX_TABLE_IS_REQUIRED",e[e.INDEX_TYPE_NOT_MATCH=65002e3]="INDEX_TYPE_NOT_MATCH",e[e.COMPARE_TYPE_NOT_MATCH=69002001]="COMPARE_TYPE_NOT_MATCH",e[e.CIRCULAR_REFERENCE_FOUND=69002002]="CIRCULAR_REFERENCE_FOUND"}(Hn||(Hn={}));var cr,lr=function(e){function t(n){var r=n.code,i=void 0===r?Hn.UNKNOWN_ERROR:r,s=n.message,a=void 0===s?"Unknown error occurred.":s,o=e.call(this,a)||this;return o.code=i,Object.setPrototypeOf(o,t.prototype),o}return(0,s.c)(t,e),Object.defineProperty(t,"storeNotDefined",{get:function(){return new t({code:Hn.STORE_NOT_DEFINED,message:"Store is not defined. Specify the store on NestDB()"})},enumerable:!1,configurable:!0}),Object.defineProperty(t,"storeNotAvailable",{get:function(){return new t({code:Hn.STORE_NOT_AVAILABLE,message:"Store is not available. Check your environment settings."})},enumerable:!1,configurable:!0}),Object.defineProperty(t,"storeNotAvailableInPrivateBrowsing",{get:function(){return new t({code:Hn.STORE_NOT_AVAILABLE_IN_PRIVATE_BROWSING,message:"Store is not available because it is in private browsing."})},enumerable:!1,configurable:!0}),Object.defineProperty(t,"storeIsFull",{get:function(){return new t({code:Hn.STORE_IS_FULL,message:"Store is full."})},enumerable:!1,configurable:!0}),Object.defineProperty(t,"storeNotInitialized",{get:function(){return new t({code:Hn.STORE_NOT_INITIALIZED,message:"Store is not initialized."})},enumerable:!1,configurable:!0}),Object.defineProperty(t,"storeKeyTypeIsInvalid",{get:function(){return new t({code:Hn.STORE_INVALID_KEY_TYPE,message:"Store key should be string type."})},enumerable:!1,configurable:!0}),Object.defineProperty(t,"storeBrokenIntegrity",{get:function(){return new t({code:Hn.STORE_BROKEN_INTEGRITY,message:"Data should be in a store but it does not. Integrity is broken."})},enumerable:!1,configurable:!0}),Object.defineProperty(t,"storeBrokenBlob",{get:function(){return new t({code:Hn.STORE_BROKEN_BLOB,message:"Data should be in a store but it does not. Blob data is broken."})},enumerable:!1,configurable:!0}),Object.defineProperty(t,"storeEncryptionInvalid",{get:function(){return new t({code:Hn.STORE_ENCRYPTION_INVA
1LID,message:"Encryption algorithm has changed. All the store should reset."})},enumerable:!1,configurable:!0}),Object.defineProperty(t,"storeItemSizeExceeded",{get:function(){return new t({code:Hn.STORE_ITEM_SIZE_LIMIT_EXCEEDED,message:"The size of the item exceeds the limit that the store allows."})},enumerable:!1,configurable:!0}),Object.defineProperty(t,"storeReadFailed",{get:function(){return new t({code:Hn.STORE_READ_FAILED,message:"Failed to read from store."})},enumerable:!1,configurable:!0}),Object.defineProperty(t,"storeWriteFailed",{get:function(){return new t({code:Hn.STORE_WRITE_FAILED,message:"Failed to write to store."})},enumerable:!1,configurable:!0}),Object.defineProperty(t,"databaseSchemaNotOnUpgrade",{get:function(){return new t({code:Hn.DATABASE_SCHEMA_NOT_ON_UPGRADE,message:"Committing schema is not allowed when upgrade is not running."})},enumerable:!1,configurable:!0}),Object.defineProperty(t,"collectionNotReady",{get:function(){return new t({code:Hn.COLLECTION_NOT_READY,message:"Collection is not ready due to an error during initialization."})},enumerable:!1,configurable:!0}),Object.defineProperty(t,"collectionKeyNotMatch",{get:function(){return new t({code:Hn.COLLECTION_KEY_NOT_MATCH,message:"keyName of collection could not change."})},enumerable:!1,configurable:!0}),Object.defineProperty(t,"collectionQueryNotValid",{get:function(){return new t({code:Hn.COLLECTION_QUERY_NOT_VALID,message:"Query parameter is not a valid format."})},enumerable:!1,configurable:!0}),Object.defineProperty(t,"collectionInsertDuplicate",{get:function(){return new t({code:Hn.COLLECTION_INSERT_DUPLICATE,message:"The key already exists."})},enumerable:!1,configurable:!0}),Object.defineProperty(t,"collectionKeyNotFound",{get:function(){return new t({code:Hn.COLLECTION_KEY_NOT_FOUND,message:"The key is not found."})},enumerable:!1,configurable:!0}),Object.defineProperty(t,"collectionKeyNotGiven",{get:function(){return new t({code:Hn.COLLECTION_KEY_NOT_GIVEN,message:"The item should contain [keyName] property."})},enumerable:!1,configurable:!0}),Object.defineProperty(t,"collectionWriteFailed",{get:function(){return new t({code:Hn.COLLECTION_WRITE_FAILED,message:"Failed to write an item."})},enumerable:!1,configurable:!0}),Object.defineProperty(t,"collectionItemSizeExceeded",{get:function(){return new t({code:Hn.COLLECTION_ITEM_SIZE_LIMIT_EXCEEDED,message:"The size of the item exceeds the limit that a collection allows."})},enumerable:!1,configurable:!0}),Object.defineProperty(t,"indexTableIsRequired",{get:function(){return new t({code:Hn.INDEX_TABLE_IS_REQUIRED,message:"Index table is required."})},enumerable:!1,configurable:!0}),Object.defineProperty(t,"indexTypesNotMatch",{get:function(){return new t({code:Hn.INDEX_TYPE_NOT_MATCH,message:"Indexed column should have primitive type."})},enumerable:!1,configurable:!0}),Object.defineProperty(t,"compareTypesNotMatch",{get:function(){return new t({code:Hn.COMPARE_TYPE_NOT_MATCH,message:"Values to compare have different types."})},enumerable:!1,configurable:!0}),Object.defineProperty(t,"circularReferenceFound",{get:function(){return new t({code:Hn.CIRCULAR_REFERENCE_FOUND,message:"Cannot handle circular referenced object."})},enumerable:!1,configurable:!0}),t}(Error);!function(e){e.INIT="init",e.READY="ready",e.CLOSED="closed"}(cr||(cr={}));var dr,hr=function(e,t){if(void 0===t&&(t=new WeakMap),"object"==typeof e&&null!==e){if(t.has(e))throw lr.circularReferenceFound;var n;return t.set(e,!0),Array.isArray(e)?n=e.map(function(e){return hr(e,t)}):e instanceof RegExp||e instanceof Date?n=e:(n={},Object.keys(e).forEach(function(r){n[r]=hr(e[r],t)})),t.delete(e),n}return e},fr=function(e,t){if(null==t)return 1;if(null==e)return-1;if(typeof e!=typeof t)throw lr.compareTypesNotMatch;var n=0;switch(typeof e){case"boolean":case"number":n=e-t;break;case"string":n=e.localeCompare(t)}return n},pr=function(e,t){for(var n=0,r=0;r<e.length;r++)n=e.charCodeAt(r)+(n<<6)+(n<<16)-n;return(n>>>0)%t},mr=function(e){return new Promise(function(t){setTimeout(function(){return t()},e)})},_r=function(e,t){if(!t)return!1;if("function"!=typeof e){for(var n in e)if(["/and","&&"].includes(n)){if(e[n].some(function(e){return!_r(e,t)}))return!1}else if(["/or","||"].includes(n)){if(e[n].every(function(e){return!_r(e,t)}))return!1}else if("/where"===n){if(!(0,e[n])(t))return!1}else{var r=n;if("object"==typeof e[r]){var i=e[r];for(var s in i)switch(s){case"/eq":case"=":if((a=t[r])!==(o=i[s]))return!1;break;case"/neq":case"!=":if((a=t[r])===(o=i[s]))return!1;break;case"/gt":case">":var a=t[r],o=i[s];if(!(fr(a,o)>0))return!1;break;case"/gte":case">=":if(a=t[r],o=i[s],!(fr(a,o)>=0))return!1;break;case"/lt":case"<":if(a=t[r],o=i[s],!(fr(a,o)<0))return!1;break;case"/lte":case"<=":if(a=t[r],o=i[s],!(fr(a,o)<=0))return!1;break;case"/in":if(a=t[r],!(o=i[s]).includes(a))return!1;break;case"/nin":if(a=t[r],(o=i[s]).includes(a))return!1;break;case"/contain":if(a=t[r],o=i[s],!a.includes(o))return!1;break;case"/regex":if(a=t[r],!(o=i[s]).test(a))return!1;break;case"/where":if(a=t[r],!(0,i[s])(a))return!1}}else if("function"==typeof e[r]){if(!e[r](t[r]))return!1}else if(e[r]!==t[r])return!1}return!0}return e(t)},vr=function(){},yr=function(){return Promise.resolve()},gr=function(e){return e},br=function(e,t){t()};!function(e){e[e.FORWARD=0]="FORWARD",e[e.BACKWARD=1]="BACKWARD"}(dr||(dr={}));var Ir,Er,wr,Tr=function(){function e(e){var t=e.initialPrevValue,n=void 0===t?null:t,r=e.initialNextValue,i=void 0===r?null:r,s=e.iterator,a=e.map,o=void 0===a?gr:a,u=e.backward,c=void 0===u?yr:u,l=e.forward,d=void 0===l?yr:l,h=e.complete,f=void 0===h?vr:h;this._prevValue=n,this._nextValue=i,this._error=null,this._map=o,this._backward=c,this._forward=d,this._iterator=s,this._complete=f}return Object.defineProperty(e.prototype,"prevValue",{get:function(){return this._map(this._prevValue)}
1,enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"nextValue",{get:function(){return this._map(this._nextValue)},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"error",{get:function(){return this._error},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"hasPrevious",{get:function(){return!!this._prevValue},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"hasNext",{get:function(){return!!this._nextValue},enumerable:!1,configurable:!0}),e.prototype.prev=function(){return(0,s._)(this,void 0,void 0,function(){var e,t,n;return(0,s.b)(this,function(r){switch(r.label){case 0:if(!this.hasPrevious)return[3,6];r.label=1;case 1:return r.trys.push([1,3,,4]),e=this._prevValue,t=this,[4,this._backward()];case 2:return t._prevValue=r.sent()||null,this._nextValue=e,[3,4];case 3:return n=r.sent(),this._error=n,[3,4];case 4:return[4,this._iterator(this)];case 5:return[2,r.sent()];case 6:this._complete(),r.label=7;case 7:return[2]}})})},e.prototype.next=function(){return(0,s._)(this,void 0,void 0,function(){var e,t,n;return(0,s.b)(this,function(r){switch(r.label){case 0:if(!this.hasNext)return[3,6];r.label=1;case 1:return r.trys.push([1,3,,4]),e=this._nextValue,t=this,[4,this._forward()];case 2:return t._nextValue=r.sent()||null,this._prevValue=e,[3,4];case 3:return n=r.sent(),this._error=n,[3,4];case 4:return[4,this._iterator(this)];case 5:return[2,r.sent()];case 6:this._complete(),r.label=7;case 7:return[2]}})})},e.prototype.stop=function(){this._prevValue=null,this._nextValue=null,this._complete()},e}(),Mr=function(){function e(e){var t=e.condition,n=void 0===t?{}:t,r=e.backward,i=void 0!==r&&r,s=e.blockManager,a=e.indexer;this.condition=n,this.backward=i,this._blockManager=s,this._indexer=a}return e.prototype.findOptimizedStartPosition=function(){var e=this,t=["=","/eq",">",">=","/gt","/gte"],n=["=","/eq","<","<=","/lt","/lte"];if(this.backward){var r=this._indexer.origin.length-1;if("function"!=typeof this.condition)for(h=0;h<this._indexer.fields.length;h++){var i=this._indexer.fields[h],s=1;if("-"===i[0]&&(i=i.slice(1),s=-1),this.condition[i])if("object"==typeof this.condition[i]){var a=s>0?n:t;for(var o in this.condition[i])if(a.includes(o))for(var u=r;u>=0;u--)if(s*fr(this._indexer.origin[u].columnValues[h],this.condition[i][o])<=0){r=u;break}}else for(u=r;u>=0;u--)if(s*fr(this._indexer.origin[u].columnValues[h],this.condition[i])<=0){r=u;break}}return Math.min(r+1,this._indexer.origin.length-1)}var c=0;if("function"!=typeof this.condition)for(var l=function(r){var i=d._indexer.fields[r],s=1;if("-"===i[0]&&(i=i.slice(1),s=-1),d.condition[i])if("object"==typeof d.condition[i])Object.keys(d.condition[i]).forEach(function(a){if((s>0?t:n).includes(a))for(var o=c;o<e._indexer.origin.length;o++)if(s*fr(e._indexer.origin[o].columnValues[r],e.condition[i][a])>=0){c=o;break}});else for(var a=c;a<d._indexer.origin.length;a++)if(s*fr(d._indexer.origin[a].columnValues[r],d.condition[i])>=0){c=a;break}},d=this,h=0;h<this._indexer.fields.length;h++)l(h);return Math.max(c-1,0)},e.prototype.each=function(e){return(0,s._)(this,void 0,void 0,function(){var t,n,r,i,a,o,u,c=this;return(0,s.b)(this,function(l){switch(l.label){case 0:if(t=this.findOptimizedStartPosition(),n=0,this.backward&&this._indexer.origin[t]&&(n=this._indexer.origin[t].keys.length-1),r=function(){if(c._indexer.origin[t]){if(!c._indexer.origin[t].keys[++n]){if(!c._indexer.origin[++t])return!1;n=0}return!0}return!1},i=function(){if(c._indexer.origin[t]){if(!c._indexer.origin[t].keys[--n]){if(!c._indexer.origin[--t])return!1;n=c._indexer.origin[t].keys.length-1}return!0}return!1},a=null,!this._indexer.origin[t])return[3,4];o=this.backward?i:r,l.label=1;case 1:return[4,this._blockManager.getFromBlock(this._indexer.origin[t].keys[n])];case 2:if((u=l.sent())&&_r(this.condition,u))return a=u,[3,4];l.label=3;case 3:if(o())return[3,1];l.label=4;case 4:return[4,new Promise(function(o){var u=new Tr({initialNextValue:hr(a),iterator:e,forward:function(){return(0,s._)(c,void 0,void 0,function(){var e,a;return(0,s.b)(this,function(s){switch(s.label){case 0:e=this.backward?
1i:r,s.label=1;case 1:return e()?[4,this._blockManager.getFromBlock(this._indexer.origin[t].keys[n])]:[3,3];case 2:return(a=s.sent())&&_r(this.condition,a)?[2,hr(a)]:[3,1];case 3:return[2,null]}})})},backward:function(){return(0,s._)(c,void 0,void 0,function(){var e,a;return(0,s.b)(this,function(s){switch(s.label){case 0:e=this.backward?r:i,s.label=1;case 1:return e()?[4,this._blockManager.getFromBlock(this._indexer.origin[t].keys[n])]:[3,3];case 2:return(a=s.sent())&&_r(this.condition,a)?[2,hr(a)]:[3,1];case 3:return[2,null]}})})},complete:o});e(u)})];case 5:return[2,l.sent()]}})})},e}(),Ar=function(){function e(e){var t=e.condition,n=void 0===t?{}:t,r=e.backward,i=void 0!==r&&r,s=e.mutex,a=e.blockManager,o=e.indexer;this._mutex=s,this._iterator=new Mr({condition:n,backward:i,blockManager:a,indexer:o})}return e.prototype.fetch=function(e){return void 0===e&&(e={}),(0,s._)(this,void 0,void 0,function(){var t,n,r,i,a=this;return(0,s.b)(this,function(o){switch(o.label){case 0:if(t=Math.max(e.offset||0,0),0===(n="number"==typeof e.limit?e.limit:Number.MAX_SAFE_INTEGER))return[2,[]];if(n<0)throw lr.collectionQueryNotValid;o.label=1;case 1:return o.trys.push([1,4,,5]),r=[],[4,this._mutex.lock()];case 2:return o.sent(),[4,this._iterator.each(function(e){return(0,s._)(a,void 0,void 0,function(){return(0,s.b)(this,function(i){return e.error?e.stop():e.hasNext?0===t?(r.push(e.nextValue),0<n&&n<=r.length?e.stop():e.next()):(t--,e.next()):e.stop(),[2]})})})];case 3:return o.sent(),this._mutex.unlock(),[2,r];case 4:throw i=o.sent(),this._mutex.unlock(),i;case 5:return[2]}})})},e.prototype.count=function(){return(0,s._)(this,void 0,void 0,function(){var e,t,n=this;return(0,s.b)(this,function(r){switch(r.label){case 0:return r.trys.push([0,3,,4]),e=0,[4,this._mutex.lock()];case 1:return r.sent(),[4,this._iterator.each(function(t){return(0,s._)(n,void 0,void 0,function(){return(0,s.b)(this,function(n){return t.error?t.stop():t.hasNext?(e++,t.next()):t.stop(),[2]})})})];case 2:return r.sent(),this._mutex.unlock(),[2,e];case 3:throw t=r.sent(),this._mutex.unlock(),t;case 4:return[2]}})})},e}(),Ur=function(e){return"".concat("nest","@").concat(e)},Sr=function(e,t){return"".concat(Ur(e),"/").concat(t)},Nr=function(e,t){return"".concat(Sr(e,t),".metadata")},Cr=function(e,t){return"".concat(Sr(e,t),"/block.")},kr=function(e,t){return"".concat(Sr(e,t),"/blob.")},Or=function(){function e(e){var t=e.dbname,n=e.collectionName,r=e.store;this.dbname=t,this.collectionName=n,this.store=r}return e.prototype.get=function(e){return(0,s._)(this,void 0,void 0,function(){var t,n,r,i,a,o,u,c,l;return(0,s.b)(this,function(s){switch(s.label){case 0:return[4,this.store.get(e)];case 1:return(t=s.sent())?(n=t.data,r=t.type,"undefined"==typeof fetch?[3,4]:[4,fetch(n)]):[3,5];case 2:return[4,s.sent().blob()];case 3:return[2,s.sent()];case 4:for(i=[],a=atob(n.split(",")[1]),o=0;o<a.length;o+=512){for(u=a.slice(o,o+512),c=new Array(u.length),l=0;l<u.length;l++)c[l]=u.charCodeAt(l);i.push(new Uint8Array(c))}return[2,new Blob(i,{type:r})];case 5:return[2,null]}})})},e.prototype.save=function(e,t){return void 0===t&&(t="".concat(Date.now())),(0,s._)(this,void 0,void 0,function(){var n,r,i,a,o=this;return(0,s.b)(this,function(s){switch(s.label){case 0:return[4,new Promise(function(n){var r=function(e,t,n,r){return void 0===r&&(r=0),"".concat(kr(e,t)).concat(n,".").concat(r)}(o.dbname,o.collectionName,t),i=new FileReader;i.onload=function(){n({blobId:r,data:i.result,type:e.type})},i.readAsDataURL(e)})];case 1:return n=s.sent(),r=n.blobId,i=n.data,a=n.type,[4,this.store.set({key:r,value:{data:i,type:a}})];case 2:return s.sent(),[2,r]}})})},e.prototype.remove=function(e){return(0,s._)(this,void 0,void 0,function(){return(0,s.b)(this,function(t){switch(t.label){case 0:return[4,this.store.remove(e)
1];case 1:return t.sent(),[2]}})})},e.prototype.clear=function(){return(0,s._)(this,void 0,void 0,function(){var e,t,n=this;return(0,s.b)(this,function(r){switch(r.label){case 0:return e=kr(this.dbname,this.collectionName),[4,this.store.getAllKeys()];case 1:return t=r.sent(),[4,Promise.all(t.filter(function(t){return t.startsWith(e)}).map(function(e){return(0,s._)(n,void 0,void 0,function(){return(0,s.b)(this,function(t){switch(t.label){case 0:return[4,this.store.remove(e)];case 1:return[2,t.sent()]}})})}))];case 2:return r.sent(),[2]}})})},e}();!function(e){e[e.COMMIT=0]="COMMIT",e[e.WRITE=1]="WRITE",e[e.ERROR=2]="ERROR"}(Ir||(Ir={})),function(e){e.PENDING="pending",e.PERSISTENT="persistent",e.VOLATILE="volatile"}(Er||(Er={})),function(e){e[e.NO_CACHE=0]="NO_CACHE",e[e.DEFAULT=1]="DEFAULT",e[e.PERSISTENT=2]="PERSISTENT"}(wr||(wr={}));var Pr,Rr,Dr=[Er.PENDING,Er.VOLATILE],xr={},Lr=function(){function e(e){var t=e.dbname,n=e.limit,r=void 0===n?256:n;return xr[t]||(this.dbname=t,this._items=[],this._limit=r,xr[t]=this),xr[t]}return e.get=function(e){return xr[e]},Object.defineProperty(e.prototype,"items",{get:function(){return this._items},enumerable:!1,configurable:!0}),e.prototype.find=function(e,t,n){return void 0===n&&(n=wr.DEFAULT),(0,s._)(this,void 0,void 0,function(){var r,i;return(0,s.b)(this,function(s){switch(s.label){case 0:return(r=this.get(t))?[3,2]:[4,e.get(t)];case 1:return(i=s.sent())&&(r={key:t,value:i,state:n===wr.PERSISTENT?Er.PERSISTENT:Er.VOLATILE},this.put(r)),[3,3];case 2:n===wr.PERSISTENT&&(r.state=Er.PERSISTENT),s.label=3;case 3:return[2,r]}})})},e.prototype.get=function(e,t){void 0===t&&(t=wr.DEFAULT);var n=this._items.map(function(e){return e.key}).indexOf(e);if(n>-1){var r=this._items[n];return t===wr.PERSISTENT&&(r.state=Er.PERSISTENT),t!==wr.NO_CACHE&&this.put(r),r}return null},e.prototype.put=function(e){var t,n;if(this._limit>0){var r=this._items.map(function(e){return e.key}).indexOf(e.key);if(r>-1)Dr.includes(this._items[r].state)&&Dr.includes(e.state)?(this._items.splice(r,1),this._items.push(e)):(this._items[r].state=e.state,this._items[r].value=e.value);else{this._items.push(e);var i=this._items.filter(function(e){return e.state===Er.VOLATILE}),a=i.length-this._limit;if(a>0){var o=[];try{for(var u=(0,s.w)(this._items),c=u.next();!c.done;c=u.next()){var l=c.value;l.state===Er.VOLATILE&&a>0?a--:o.push(l)}}catch(e){t={error:e}}finally{try{c&&!c.done&&(n=u.return)&&n.call(u)}finally{if(t)throw t.error}}this._items=o}}}},e.prototype.remove=function(e){var t=this._items.map(function(e){return e.key}).indexOf(e);t>-1&&this._items.splice(t,1)},e.prototype.clearByCondition=function(e){this._items=this._items.filter(function(t){return!e(t)})},e.prototype.clearForDatabase=function(e){this.clearByCondition(function(t){return t.key.startsWith(Ur(e))})},e.prototype.clear=function(e){void 0===e&&(e=!1),this._items=e?[]:this._items.filter(function(e){return e.state!==Er.VOLATILE})},e}(),Fr=function(){function e(e){var t=e.dbname,n=e.collectionName,r=e.store;this._requests=[],this._onCommit=new Map,this._onWrite=new Map,this._onError=new Map,this.dbname=t,this.collectionName=n,this.metadataKey=function(e,t){return"".concat(Sr(e,t),"/trans.metadata")}(t,n),this.recordsetKey=function(e,t){return"".concat(Sr(e,t),"/trans.recordset")}(t,n),this._store=r}return Object.defineProperty(e.prototype,"generation",{get:function(){return this._metadata?this._metadata.generation:0},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"requestCount",{get:function(){return this._requests.length},enumerable:!1,configurable:!0}),e.prototype._getReducedRecordset=function(e){return void 0===e&&(e=[]),(0,s._)(this,void 0,void 0,function(){var t;return(0,s.b)(this,function(n){switch(n.label){case 0:return[4,this._store.get(this.recordsetKey)];case 1:return(t=n.sent()||[]).push.apply(t,(0,s.q)([],(0,s.r)(e),!1)),[2,this._reduceRecordSet(t)]}})})},e.prototype._reduceRecordSet=function(e){for(var t=[],n={},r=e.length-1;r>=0;r--){for(var i=e[r],s=[],a=i.requests.length-1;a>=0;a--){var o=i.requests[a],u=o.data;n[u.key]||(s.unshift(o),n[u.key]=!0)}s.length>0&&(i.requests=s,t.unshift(i))}return t},e.prototype._applyRecord=function(e,t){return(0,s._)(this,void 0,void 0,function(){var n,r,i,a,o,u,c,l,d;return(0,s.b)(this,function(h){switch(h.label){case 0:n=Lr.get(this.dbname),r=t.generation,i=t.requests,a=null,h.label=1;case 1:return h.trys.push([1,3,,4]),[4,this._store.setMany(i.map(function(e){return(0,s.j)((0,s.j)({},e.data),{generation:r})}))];case 2:for(o=h.sent(),u=0;u<i.length;u++)o[u]instanceof Error&&(a||(a=o[u]),c=i[u].data,n.put((0,s.j)((0,s.j)({},c),{state:Er.PERSISTENT})));return[3,4];case 3:return l=h.sent(),a=l,[3,4];case 4:return a?[3,6]:(d=e.filter(function(e){return e.generation!==r}),[4,this._store.set({key:this.recordsetKey,value:d})]);case 5:return h.sent(),this._onWrite.forEach(function(e){e(i.map(function(e){return e.data}))}),[3,7];case 6:this._onError.forEach(function(e){a&&e(a)}),h.label=7;case 7:return[2]}})})},e.prototype.init=function(){return(0,s._)(this,void 0,void 0,function(){var e,t,n,r,i,a,o,u;return(0,s.b)(this,function(c){switch(c.label){case 0:return e=this,[4,this._store.get(this.metadataKey)];case 1:return e._metadata=c.sent()||{generation:1},[4,this._getReducedRecordset()];case 2:t=c.sent(),c.label=3;case 3:c.trys.push([3,8,9,10]),n=(0,s.w)(t),r=n.next(),c.label=4;case 4:return r.done?[3,7]:(i=r.value,[4,this._applyRecord(t,i)]);case 5:c.sent(),c.label=6;case 6:return r=n.next(),[3,4];case 7:return[3,10];case 8:return a=c.sent(),o={error:a},[3,10];case 9:try{r&&!r.done&&(u=n.return)&&u.call(n)}finally{if(o)throw o.error}
1return[7];case 10:return[2]}})})},e.prototype.on=function(e,t,n){switch(e){case Ir.COMMIT:this._onCommit.set(t,n);break;case Ir.WRITE:this._onWrite.set(t,n);break;case Ir.ERROR:this._onError.set(t,n)}},e.prototype.requestWrite=function(e,t){this._requests.push({data:e,options:t}),Lr.get(this.dbname).put((0,s.j)({state:Er.PENDING},e))},e.prototype.requestMultipleWrite=function(e,t){var n,r,i=Lr.get(this.dbname);try{for(var a=(0,s.w)(e),o=a.next();!o.done;o=a.next()){var u=o.value;this._requests.push({data:u,options:t}),i.put((0,s.j)({state:Er.PENDING},u))}}catch(e){n={error:e}}finally{try{o&&!o.done&&(r=a.return)&&r.call(a)}finally{if(n)throw n.error}}},e.prototype.clear=function(){return(0,s._)(this,void 0,void 0,function(){return(0,s.b)(this,function(e){return Lr.get(this.dbname).clearByCondition(function(e){return e.state===Er.PENDING}),this._requests=[],[2]})})},e.prototype.commit=function(){return(0,s._)(this,void 0,void 0,function(){var e,t,n,r,i,a,o,u,c,l,d,h,f=this;return(0,s.b)(this,function(p){switch(p.label){case 0:if(!((e=this._requests).length>0))return[3,4];for(t=[],n={},u=e.length-1;u>=0;u--)r=e[u],l=r.data,n[l.key]||(n[l.key]=!0,t.unshift(r));return i={generation:this.generation,requests:t},[4,this._getReducedRecordset([i])];case 1:return a=p.sent(),[4,this._store.set({key:this.recordsetKey,value:a})];case 2:return p.sent(),this._metadata.generation++,[4,this._store.set({key:this.metadataKey,value:this._metadata})];case 3:for(p.sent(),o=Lr.get(this.dbname),u=0;u<t.length;u++)c=t[u],l=c.data,d=c.options,o.put((0,s.j)((0,s.j)({},l),{state:d&&d.persistent?Er.PERSISTENT:Er.VOLATILE}));this._requests=[],this._onCommit.forEach(function(t){t(e.map(function(e){return e.data}))}),h=ur.get(this.dbname),setTimeout(function(){try{f._applyRecord(a,i)}catch(e){f._onError.forEach(function(n){return n(e)})}},h.transactionApplyDelay),p.label=4;case 4:return[2]}})})},e}(),qr=function(){function e(e){var t=e.blockId,n=e.keyName,r=e.items,i=void 0===r?[]:r,a=e.limit;this.blockId=t,this.keyName=n,this.limit=a,this._items=(0,s.q)([],(0,s.r)(i),!1)}return e.createFromCacheItem=function(t){return t?new e(t.value):null},Object.defineProperty(e.prototype,"isEmpty",{get:function(){return 0===this._items.length},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"items",{get:function(){return this._items},enumerable:!1,configurable:!0}),e.prototype.serialize=function(){return{blockId:this.blockId,keyName:this.keyName,limit:this.limit,items:this._items}},e.prototype.getItemByKey=function(e){var t=this,n=this._items.find(function(n){var r=n[t.keyName];return e===r});return null!=n?n:null},e.prototype.has=function(e){var t=this;return this._items.map(function(e){return e[t.keyName]}).includes(e)},e.prototype.add=function(e){var t=this,n=this._items.map(function(e){return e[t.keyName]}).indexOf(e[this.keyName]);return n<0?this._items.length<this.limit&&(this._items.push(e),!0):(this._items[n]=e,!0)},e.prototype.remove=function(e){for(var t=0;t<this._items.length;t++)if(this._items[t][this.keyName]===e)return this._items.splice(t,1),!0;return!1},e.prototype.clear=function(){this._items=[]},e}(),jr=function(){function e(e){var t=e.dbname,n=e.collectionName,r=e.metadata,i=e.hashFunction,s=void 0===i?pr:i,a=e.transaction,o=e.store;this.dbname=t,this.collectionName=n,this.hashFunction=s,this.metadata=r,this._transaction=a,this._store=o}return Object.defineProperty(e.prototype,"keyName",{get:function(){return this.metadata.keyName},enumerable:!1,configurable:!0}),e.prototype.createBlockId=function(e,t){return void 0===t&&(t=this.metadata.blockLevel),n=this.dbname,r=this.collectionName,i=t,s="".concat(function(e,t,n){var r=n.base*Math.pow(n.multiplier,t)+n.constant;return(n.hashFunction||pr)(e,r)}(e,t,{hashFunction:this.hashFunction,base:this.metadata.blockHashBase,multiplier:this.metadata.blockHashMultiplier,constant:this.metadata.blockHashConstant})),"".concat(Cr(n,r)).concat(i,".").concat(s);var n,r,i,s},e.prototype._findBlock=function(e){return(0,s._)(this,void 0,void 0,function(){var t,n,r,i,a;return(0,s.b)(this,function(s){switch(s.label){case 0:t=Lr.get(this.dbname),n=this.metadata.blockLevel,s.label=1;case 1:return n>0?(r=this.createBlockId(e,n),[4,t.find(this._store,r)]):[3,4];case 2:if((i=s.sent())&&(null==(a=qr.createFromCacheItem(i))?void 0:a.getItemByKey(e)))return[2,a];s.label=3;case 3:return n--,[3,1];case 4:return[2,null]}})})},e.prototype.getFromBlock=function(e){return(0,s._)(this,void 0,void 0,function(){var t;return(0,s.b)(this,function(n){switch(n.label){case 0:return[4,this._findBlock(e)];case 1:return[2,(t=n.sent())?t.getItemByKey(e):null]}})})},e.prototype.putToBlock=function(e,t){return(0,s._)(this,void 0,void 0,function(){var n,r,i,a,o;return(0,s.b)(this,function(s){switch(s.label){case 0:return n=ur.get(this.dbname),r=this.createBlockId(e),i=Math.floor(this._store.itemSizeLimit/n.itemSizeLimit),[4,Lr.get(this.dbname).find(this._store,r)];case 1:return a=s.sent(),(null==(o=a?qr.createFromCacheItem(a):new qr({blockId:r,keyName:this.keyName,items:[],limit:i}))?void 0:o.add(t))?(this._transaction.requestWrite({key:o.blockId,value:o.serialize()}),[2,!0]):[2,!1]}})})},e.prototype.removeFromBlock=function(e){return(0,s._)(this,void 0,void 0,function(){var t;return(0,s.b)(this,function(n){switch(n.label){case 0:return[4,this._findBlock(e)];case 1:return(t=n.sent())&&t.remove(e)?(this._transaction.requestWrite({key:t.blockId,value:t.serialize()}),[2,!0]):[2,!1]}})})},e.prototype.clearAllBlocks=function(){return(0,s._)(this,void 0,void 0,function(){var e,t,n;return(0,s.b)(this,function(r){switch(r.label){case 0:return e=Cr(this.dbname,this.collectionName),[4,this._store.getAllKeys()];case 1:return t=r.sent(),n=t.filter(function(t){return t.startsWith(e)}),[4,this._store.removeMany(n)];case 2:return r.sent(),[4,this._transaction.clear()];case 3:return r.sent(),Lr.get(this.dbname).clearByCondition(function(t){return t.key.startsWith(e)}),[2]}})})},e}(),zr=function(){function e(e){var t=e.dbname,n=e.collectionName,r=e.keyName,i=e.fields,s=e.transaction,a=e.store,o=this;this._origin=[],this._table=[];var u=function(e,t,n){return"".concat(Sr(e,t),"/index.").concat(n)}(t,n,i.join(">"));this.dbname=t,this.collectionName=n,this.keyName=r,this.fields=i,this.indexerKey=u,this._store=a,this._transaction=s,this._transaction.on(Ir.COMMIT,this.indexerKey,function(){return o.commit()}),this._transaction.on(Ir.ERROR,this.indexerKey,function(){return o.abort()})}return e.createKey=function(e){return e.join(">")},e.parseKey=function(e){return e.split(">")},e.prototype._addItem=function(e){var t=e[this.keyName],n=this.getColumnValues(e),r=(0,s.r)(this.indexOf(n),2),i=r[0];return r[1]?!this._table[i].keys.includes(t)&&(this._table[i].keys.push(t),!0):(this._table.splice(i,0,{columnValues:n,keys:[t]}),!0)},e.prototype._removeItem=function(e){var t=e[this.keyName],n=this.getColumnValues(e),r=(0,s.r)(this.indexOf(n),2),i=r[0];if(r[1]){var a=this._table[i].keys.indexOf(t);if(a>-1)return this._table[i].keys.splice(a,1),0===this._table[i].keys.length&&this._table.splice(i,1),!0}return!1},Object.defineProperty(e.prototype,"origin",{get:function(){return this._origin}
1,enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"table",{get:function(){return this._table},enumerable:!1,configurable:!0}),e.prototype.getColumnValues=function(e){var t,n,r,i,a=[];try{for(var o=(0,s.w)(this.fields),u=o.next();!u.done;u=o.next()){var c=u.value;if("-"===c[0]&&(c=c.slice(1)),r=e[c],void 0,i=typeof r,null!==r&&"undefined"!==i&&"boolean"!==i&&"number"!==i&&"string"!==i)throw lr.indexTypesNotMatch;a.push(e[c])}}catch(e){t={error:e}}finally{try{u&&!u.done&&(n=o.return)&&n.call(o)}finally{if(t)throw t.error}}return a},e.prototype.diff=function(e,t){for(var n in this.fields){var r="-"===this.fields[n][0]?-1:1,i=fr(e[n],t[n]);if(0!==i)return r*i}return 0},e.prototype.indexOf=function(e){if(this._table.length>0){for(var t=0,n=this._table.length-1;t<=n;){var r=Math.floor((t+n)/2),i=this.diff(e,this._table[r].columnValues);if(i>0)t=r+1;else{if(!(i<0))return[r,!0];n=r-1}}return[t,!1]}return[0,!1]},e.prototype.ensure=function(){return(0,s._)(this,void 0,void 0,function(){var e,t,n,r,i,a,o,u,c,l,d,h,f,p,m,_,v;return(0,s.b)(this,function(y){switch(y.label){case 0:return[4,(e=Lr.get(this.dbname)).find(this._store,this.indexerKey,wr.PERSISTENT)];case 1:return(t=y.sent())?[3,11]:(n=Cr(this.dbname,this.collectionName),[4,this._store.getAllKeys()]);case 2:r=y.sent(),y.label=3;case 3:y.trys.push([3,8,9,10]),i=(0,s.w)(r),a=i.next(),y.label=4;case 4:return a.done?[3,7]:(o=a.value).startsWith(n)?[4,e.find(this._store,o,wr.NO_CACHE)]:[3,6];case 5:if(u=y.sent(),c=qr.createFromCacheItem(u))try{for(_=void 0,l=(0,s.w)(c.items),d=l.next();!d.done;d=l.next())h=d.value,this._addItem(h)}catch(e){_={error:e}}finally{try{d&&!d.done&&(v=l.return)&&v.call(l)}finally{if(_)throw _.error}}y.label=6;case 6:return a=i.next(),[3,4];case 7:return[3,10];case 8:return f=y.sent(),p={error:f},[3,10];case 9:try{a&&!a.done&&(m=i.return)&&m.call(i)}finally{if(p)throw p.error}return[7];case 10:return this._transaction.requestWrite({key:this.indexerKey,value:this._table},{persistent:!0}),[3,12];case 11:this._origin=t.value,this._table=hr(this._origin),y.label=12;case 12:return[2]}})})},e.prototype.drop=function(){return(0,s._)(this,void 0,void 0,function(){return(0,s.b)(this,function(e){switch(e.label){case 0:return Lr.get(this.dbname).remove(this.indexerKey),[4,this._store.remove(this.indexerKey)];case 1:return e.sent(),[2]}})})},e.prototype.addItem=function(e){return(0,s._)(this,void 0,void 0,function(){return(0,s.b)(this,function(t){return this._addItem(e)&&this._transaction.requestWrite({key:this.indexerKey,value:this._table},{persistent:!0}),[2]})})},e.prototype.removeItem=function(e){return(0,s._)(this,void 0,void 0,function(){return(0,s.b)(this,function(t){return this._removeItem(e)&&this._transaction.requestWrite({key:this.indexerKey,value:this._table},{persistent:!0}),[2]})})},e.prototype.clear=function(){return(0,s._)(this,void 0,void 0,function(){return(0,s.b)(this,function(e){return this._table=[],this._transaction.requestWrite({key:this.indexerKey,value:this._table},{persistent:!0}),[2]})})},e.prototype.commit=function(){this._origin=this._table,this._table=hr(this._origin)},e.prototype.abort=function(){this._table=hr(this._origin)},e}(),Vr=function(){return"undefined"!=typeof document&&"undefined"!=typeof navigator&&"ReactNative"!==navigator.product},Br=function(){var e=(new Date).getTime();return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,function(t){var n=(e+16*Math.random())%16|0;return e=Math.floor(e/16),("x"===t?n:3&n|8).toString(16)})};!function(e){e[e.PROCESSING=0]="PROCESSING",e[e.DONE=1]="DONE"}(Pr||(Pr={})),function(e){e.NEWNODE="newnode",e.REMOVENODE="removenode",e.CLAIM_HOST="claimhost",e.SYNC_HOST="synchost",e.REQUEST_LOCK="requestlock",e.ACQUIRE_LOCK="acquirelock",e.RELEASE_LOCK="releaselock"}(Rr||(Rr={}));var Kr,Qr={},Gr=function(){function e(e,t){void 0===t&&(t={});var n=this;return this._state=Pr.PROCESSING,this._queue=[],this._activationQueue=[],Qr[e]&&!t.forceCreate||(this.nodeId=Br(),this.key=e,Vr()&&(t.startAsInvisible?this.registerNode():"visible"===document.visibilityState?this.claimHost():this.registerNode(),document.addEventListener("visibilitychange",function(){"visible"===document.visibilityState&&n.claimHost()}),window.addEventListener("message",function(e){var t,r,i=e.data;if(null==i?void 0:i.isNestDbMessage){var a=i.nodeId,o=i.requestId,u=i.key,c=i.op,l=i.data;if(a!==n.nodeId&&u===n.key)switch(c){case Rr.NEWNODE:n._sendSync();break;case Rr.CLAIM_HOST:n._sendSync(),n._hostId=a;break;case Rr.SYNC_HOST:if(!n.isInSync){n._activationTimeout&&clearTimeout(n._activationTimeout);var d=l,h=d.currentItemRequestId,f=d.queue,p=function(e){n._queue.findIndex(function(t){return t.requestId===e.requestId})<0&&n._requestLock({isNestDbMessage:!0,nodeId:e.nodeId,requestId:e.requestId,key:n.key,op:Rr.REQUEST_LOCK,ts:e.ts})};try{for(var m=(0,s.w)(f),_=m.next();!_.done;_=m.next())p(_.value)}catch(e){t={error:e}}finally{try{_&&!_.done&&(r=m.return)&&r.call(m)}finally{if(t)throw t.error}}n._currentItem=n._queue.find(function(e){return e.requestId===h}),n._completeSync()}break;case Rr.REMOVENODE:n._queue=n._queue.filter(function(e){return e.no
1deId!==i.nodeId}),n._currentItem&&n._currentItem.nodeId===i.nodeId&&(n._currentItem=void 0,n._acquire(n._queue[0]));break;case Rr.REQUEST_LOCK:n._requestLock(i);break;case Rr.ACQUIRE_LOCK:var v=n._queue.find(function(e){return e.requestId===o});n._acquire(v);break;case Rr.RELEASE_LOCK:n._release(o)}}}),window.addEventListener("beforeunload",function(){n._send(Rr.REMOVENODE)})),Qr[e]=this),Qr[e]}return Object.defineProperty(e.prototype,"locked",{get:function(){return!!this._currentItem},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"isHost",{get:function(){return this._hostId===this.nodeId},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"isInSync",{get:function(){return this._state==Pr.DONE},enumerable:!1,configurable:!0}),e.prototype._send=function(e,t){var n;void 0===t&&(t={});var r={isNestDbMessage:!0,nodeId:this.nodeId,requestId:null!==(n=null==t?void 0:t.requestId)&&void 0!==n?n:Br(),key:this.key,op:e,data:t.data,ts:Date.now()};return Vr()&&window.postMessage(r,"*"),r},e.prototype._acquire=function(e){e?(this._currentItem=e,this._currentItem.onAcquired&&this._currentItem.onAcquired(e.requestId)):this._currentItem=void 0},e.prototype._release=function(e){if(this._currentItem&&this._currentItem.requestId===e){var t=this._currentItem;this._currentItem=void 0,t.nodeId===this.nodeId&&this._send(Rr.RELEASE_LOCK,{requestId:t.requestId});var n=this._queue.findIndex(function(t){return t.requestId===e});n>-1&&this._queue.splice(n,1),t.onReleased&&t.onReleased(e)}},e.prototype._requestLock=function(e){var t=this;return new Promise(function(n){for(var r={nodeId:e.nodeId,requestId:e.requestId,ts:e.ts,onAcquired:function(e){t.isHost&&t._send(Rr.ACQUIRE_LOCK,{requestId:e}),n()},onReleased:function(){t._acquire(t._queue[0])}},i=!1,s=0;s<t._queue.length;s++)if(t._queue[s].ts>r.ts){t._queue.splice(s,0,r),i=!0;break}i||t._queue.push(r),t._currentItem||t._acquire(t._queue[0])})},e.prototype._sendSync=function(){var e;this.isHost&&this._send(Rr.SYNC_HOST,{data:{currentItemRequestId:null===(e=this._currentItem)||void 0===e?void 0:e.requestId,queue:this._queue.map(function(e){return{nodeId:e.nodeId,requestId:e.requestId,ts:e.ts}})}})},e.prototype._waitUntilSyncCompleted=function(){return(0,s._)(this,void 0,void 0,function(){var e=this;return(0,s.b)(this,function(t){return this.isHost&&!this.isInSync?[2,new Promise(function(t){e._activationQueue.push(t)})]:[2]})})},e.prototype._waitSync=function(){var e=this;this.isInSync||(this._activationTimeout=setTimeout(function(){e._completeSync()},8))},e.prototype._completeSync=function(){this.isInSync||(this._state=Pr.DONE,this._activationQueue.forEach(function(e){return e()}),this._activationQueue=[])},e.prototype.registerNode=function(){this._send(Rr.NEWNODE),this._waitSync()},e.prototype.claimHost=function(){this._hostId=this.nodeId,this._send(Rr.CLAIM_HOST),this._waitSync()},e.prototype.lock=function(){return(0,s._)(this,void 0,void 0,function(){var e;return(0,s.b)(this,function(t){switch(t.label){case 0:return[4,this._waitUntilSyncCompleted()];case 1:return t.sent(),e=this._send(Rr.REQUEST_LOCK),[4,this._requestLock(e)];case 2:return t.sent(),[2]}})})},e.prototype.unlock=function(){var e;(null===(e=this._currentItem)||void 0===e?void 0:e.requestId)&&this._release(this._currentItem.requestId)},e}(),Hr=function(){function e(e){var t=e.dbname,n=e.collectionName,r=e.keyName,i=e.keyHash,a=e.indexes,o=e.store,u=this;this._state=cr.INIT,this._indexers=[],this.dbname=t,this.name=n,this.keyName=r,this.indexes=(0,s.q)([[r]],(0,s.r)(a.filter(function(e){return zr.createKey(e)!==u.keyName})),!1),this._keyHash=i,this._store=o,this._mutex=new Gr(function(e,t){return"".concat(Sr(e,t),".lock")}(t,n)),this._blobContainer=new Or({dbname:t,collectionName:n,store:o}),this._transaction=new Fr({dbname:t,collectionName:n,store:o})}return e.metadataOf=function(e,t,n){return(0,s._)(this,void 0,void 0,function(){var r;return(0,s.b)(this,function(i){switch(i.label){case 0:return r=Nr(e,t),[4,n.get(r)];case 1:return[2,i.sent()]}})})},Object.defineProperty(e.prototype,"state",{get:function(){return this._state}
1,enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"isReady",{get:function(){return this._state===cr.READY},enumerable:!1,configurable:!0}),e.prototype.init=function(){return(0,s._)(this,void 0,void 0,function(){var t,n,r,i,a,o,u,c,l,d,h,f,p,m,_=this;return(0,s.b)(this,function(v){switch(v.label){case 0:return[4,this._mutex.lock()];case 1:v.sent(),v.label=2;case 2:return v.trys.push([2,9,,10]),t=ur.get(this.dbname),[4,e.metadataOf(this.dbname,this.name,this._store)];case 3:return n=v.sent(),this._metadata=n||{keyName:this.keyName,blockLevel:1,blockHashBase:t.blockHashBase,blockHashMultiplier:t.blockHashMultiplier,blockHashConstant:t.blockHashConstant,indexes:this.indexes},[4,this._transaction.init()];case 4:v.sent(),this._blockManager=new jr({dbname:this.dbname,collectionName:this.name,hashFunction:this._keyHash,metadata:this._metadata,transaction:this._transaction,store:this._store}),r=(0,s.q)([],(0,s.r)(this.indexes),!1),i=[],a=r.map(function(e){return zr.createKey(e)}),o=n?n.indexes.map(function(e){return zr.createKey(e)}):[];try{for(u=(0,s.w)(o),c=u.next();!c.done;c=u.next())l=c.value,a.includes(l)||i.push(zr.parseKey(l))}catch(e){p={error:e}}finally{try{c&&!c.done&&(m=u.return)&&m.call(u)}finally{if(p)throw p.error}}return(d=[]).push.apply(d,(0,s.q)([],(0,s.r)(r.map(function(e){var t=new zr({dbname:_.dbname,collectionName:_.name,keyName:_.keyName,fields:e,transaction:_._transaction,store:_._store});return _._indexers.push(t),t.ensure()})),!1)),d.push.apply(d,(0,s.q)([],(0,s.r)(i.map(function(e){return new zr({dbname:_.dbname,collectionName:_.name,keyName:_.keyName,fields:e,transaction:_._transaction,store:_._store}).drop()})),!1)),[4,Promise.all(d)];case 5:return v.sent(),[4,this._transaction.commit()];case 6:return v.sent(),a.sort().join(",")===o.sort().join(",")?[3,8]:(h=Nr(this.dbname,this.name),this._metadata.indexes=r,[4,this._store.set({key:h,value:this._metadata})]);case 7:v.sent(),v.label=8;case 8:return this._state=cr.READY,this._mutex.unlock(),[3,10];case 9:throw f=v.sent(),this._mutex.unlock(),f;case 10:return[2]}})})},e.prototype.close=function(){this._state=cr.CLOSED},e.prototype._hasPropertyOfKeyName=function(e){var t=e[this.keyName];return"string"==typeof t&&!!t},e.prototype._getIndexerBy=function(e){var t,n;void 0===e&&(e=null),e||(e=[this.keyName]);var r=zr.createKey(e);try{for(var i=(0,s.w)(this._indexers),a=i.next();!a.done;a=i.next()){var o=a.value;if(r===zr.createKey(o.fields))return o}}catch(e){t={error:e}}finally{try{a&&!a.done&&(n=i.return)&&n.call(i)}finally{if(t)throw t.error}}throw lr.indexTableIsRequired},e.prototype._upgradeBlockLevel=function(){return(0,s._)(this,void 0,void 0,function(){var e;return(0,s.b)(this,function(t){switch(t.label){case 0:return e=Nr(this.dbname,this.name),this._metadata.blockLevel++,[4,this._store.set({key:e,value:this._metadata})];case 1:return t.sent(),[2]}})})},e.prototype._requestInsert=function(e){return(0,s._)(this,void 0,void 0,function(){var t,n,r,i,a,o;return(0,s.b)(this,function(u){switch(u.label){case 0:return t=e[this.keyName],[4,this._blockManager.getFromBlock(t)];case 1:return u.sent()?[3,13]:[4,this._blockManager.putToBlock(t,e)];case 2:return u.sent()?[3,5]:[4,this._upgradeBlockLevel()];case 3:return u.sent(),[4,this._blockManager.putToBlock(t,e)];case 4:u.sent(),u.label=5;case 5:u.trys.push([5,10,11,12]),n=(0,s.w)(this._indexers),r=n.next(),u.label=6;case 6:return r.done?[3,9]:[4,r.value.addItem(e)];case 7:u.sent(),u.label=8;case 8:return r=n.next(),[3,6];case 9:return[3,12];case 10:return i=u.sent(),a={error:i},[3,12];case 11:try{r&&!r.done&&(o=n.return)&&o.call(n)}finally{if(a)throw a.error}return[7];case 12:return[3,14];case 13:throw lr.collectionInsertDuplicate;case 14:return[2]}})})},e.prototype._requestUpsert=function(e){return(0,s._)(this,void 0,void 0,function(){var t,n,r,i,a,o,u,c,l,d,h,f,p;return(0,s.b)(this,function(m){switch(m.label){case 0:return t=e[this.keyName],[4,this._blockManager.getFromBlock(t)];case 1:return(n=m.sent())?[3,13]:[4,this._blockManager.putToBlock(t,e)];case 2:return m.sent()?[3,5]:[4,this._upgradeBlockLevel()];case 3:return m.sent(),[4,this._blockManager.putToBlock(t,e)];case 4:m.sent(),m.label=5;case 5:m.trys.push([5,10,11,12]),r=(0,s.w)(this._indexers),i=r.next(),m.label=6;case 6:return i.done?[3,9]:[4,(c=i.value).addItem(e)];case 7:m.sent(),m.label=8;case 8:return i=r.next(),[3,6];case 9:return[3,12];case 10:return a=m.sent(),d={error:a},[3,12];case 11:try{i&&!i.done&&(h=r.return)&&h.call(r)}finally{if(d)throw d.error}
1return[7];case 12:return[3,23];case 13:return[4,this._blockManager.putToBlock(t,e)];case 14:m.sent(),m.label=15;case 15:m.trys.push([15,21,22,23]),o=(0,s.w)(this._indexers),u=o.next(),m.label=16;case 16:return u.done?[3,20]:0===(c=u.value).diff(c.getColumnValues(n),c.getColumnValues(e))?[3,19]:[4,c.removeItem(n)];case 17:return m.sent(),[4,c.addItem(e)];case 18:m.sent(),m.label=19;case 19:return u=o.next(),[3,16];case 20:return[3,23];case 21:return l=m.sent(),f={error:l},[3,23];case 22:try{u&&!u.done&&(p=o.return)&&p.call(o)}finally{if(f)throw f.error}return[7];case 23:return[2]}})})},e.prototype._requestUpdate=function(e){return(0,s._)(this,void 0,void 0,function(){var t,n,r,i,a,o,u,c;return(0,s.b)(this,function(l){switch(l.label){case 0:return t=e[this.keyName],[4,this._blockManager.getFromBlock(t)];case 1:return(n=l.sent())?[4,this._blockManager.putToBlock(t,e)]:[3,11];case 2:l.sent(),l.label=3;case 3:l.trys.push([3,9,10,11]),r=(0,s.w)(this._indexers),i=r.next(),l.label=4;case 4:return i.done?[3,8]:0===(a=i.value).diff(a.getColumnValues(n),a.getColumnValues(e))?[3,7]:[4,a.removeItem(n)];case 5:return l.sent(),[4,a.addItem(e)];case 6:l.sent(),l.label=7;case 7:return i=r.next(),[3,4];case 8:return[3,11];case 9:return o=l.sent(),u={error:o},[3,11];case 10:try{i&&!i.done&&(c=r.return)&&c.call(r)}finally{if(u)throw u.error}return[7];case 11:return[2]}})})},e.prototype._requestRemove=function(e){return(0,s._)(this,void 0,void 0,function(){var t,n,r,i,a,o;return(0,s.b)(this,function(u){switch(u.label){case 0:return[4,this._blockManager.getFromBlock(e)];case 1:return(t=u.sent())?[4,this._blockManager.removeFromBlock(e)]:[3,10];case 2:u.sent(),u.label=3;case 3:u.trys.push([3,8,9,10]),n=(0,s.w)(this._indexers),r=n.next(),u.label=4;case 4:return r.done?[3,7]:[4,r.value.removeItem(t)];case 5:u.sent(),u.label=6;case 6:return r=n.next(),[3,4];case 7:return[3,10];case 8:return i=u.sent(),a={error:i},[3,10];case 9:try{r&&!r.done&&(o=n.return)&&o.call(n)}finally{if(a)throw a.error}return[7];case 10:return[2]}})})},e.prototype._requestClear=function(){return(0,s._)(this,void 0,void 0,function(){var e,t,n,r,i;return(0,s.b)(this,function(a){switch(a.label){case 0:return[4,this._blockManager.clearAllBlocks()];case 1:a.sent(),a.label=2;case 2:a.trys.push([2,7,8,9]),e=(0,s.w)(this._indexers),t=e.next(),a.label=3;case 3:return t.done?[3,6]:[4,t.value.clear()];case 4:a.sent(),a.label=5;case 5:return t=e.next(),[3,3];case 6:return[3,9];case 7:return n=a.sent(),r={error:n},[3,9];case 8:try{t&&!t.done&&(i=e.return)&&i.call(e)}finally{if(r)throw r.error}return[7];case 9:return[2]}})})},e.prototype.getByKey=function(e){return(0,s._)(this,void 0,void 0,function(){var t,n;return(0,s.b)(this,function(r){switch(r.label){case 0:return this.isReady?[4,this._mutex.lock()]:[3,6];case 1:r.sent(),r.label=2;case 2:return r.trys.push([2,4,,5]),[4,this._blockManager.getFromBlock(e)];case 3:return t=r.sent(),this._mutex.unlock(),[2,hr(t)];case 4:throw n=r.sent(),this._mutex.unlock(),n;case 5:return[3,7];case 6:throw lr.collectionNotReady;case 7:return[2]}})})},e.prototype.query=function(e){if(void 0===e&&(e={}),this.isReady)return new Ar({condition:e.where,mutex:this._mutex,blockManager:this._blockManager,indexer:this._getIndexerBy(e.index),backward:!!e.backward});throw lr.collectionNotReady},e.prototype.insertOne=function(e){return(0,s._)(this,void 0,void 0,function(){var t;return(0,s.b)(this,function(n){switch(n.label){case 0:return this.isReady?[4,this._mutex.lock()]:[3,8];case 1:n.sent(),n.label=2;case 2:if(n.trys.push([2,5,,7]),!this._hasPropertyOfKeyName(e))throw lr.collectionKeyNotGiven;return[4,this._requestInsert(hr(e))];case 3:return n.sent(),[4,this._transaction.commit()];case 4:return n.sent(),this._mutex.unlock(),[2,e];case 5:return t=n.sent(),[4,this._transaction.clear()];case 6:throw n.sent(),this._mutex.unlock(),t;case 7:return[3,9];case 8:throw lr.collectionNotReady;case 9:return[2]}})})},e.prototype.insertMany=function(e){return(0,s._)(this,void 0,void 0,function(){var t,n,r,i,a,o,u,c=this;return(0,s.b)(this,function(l){switch(l.label){case 0:return this.isReady?[4,this._mutex.lock()]:[3,15];case 1:l.sent(),l.label=2;case 2:if(l.trys.push([2,12,,14]),e.some(function(e){return!c._hasPropertyOfKeyName(e)}))throw lr.collectionKeyNotGiven;l.label=3;case 3:l.trys.push([3,8,9,10]),t=(0,s.w)(e),n=t.next(),l.label=4;case 4:return n.done?[3,7]:(r=n.value,[4,this._requestInsert(hr(r))]);case 5:l.sent(),l.label=6;case 6:return n=t.next(),[3,4];case 7:return[3,10];case 8:return i=l.sent(),o={error:i},[3,10];case 9:try{n&&!n.done&&(u=t.return)&&u.call(t)}finally{if(o)throw o.error}
1return[7];case 10:return[4,this._transaction.commit()];case 11:return l.sent(),this._mutex.unlock(),[2,e];case 12:return a=l.sent(),[4,this._transaction.clear()];case 13:throw l.sent(),this._mutex.unlock(),a;case 14:return[3,16];case 15:throw lr.collectionNotReady;case 16:return[2]}})})},e.prototype.upsertOne=function(e){return(0,s._)(this,void 0,void 0,function(){var t;return(0,s.b)(this,function(n){switch(n.label){case 0:return this.isReady?[4,this._mutex.lock()]:[3,8];case 1:n.sent(),n.label=2;case 2:if(n.trys.push([2,5,,7]),!this._hasPropertyOfKeyName(e))throw lr.collectionKeyNotGiven;return[4,this._requestUpsert(hr(e))];case 3:return n.sent(),[4,this._transaction.commit()];case 4:return n.sent(),this._mutex.unlock(),[2,e];case 5:return t=n.sent(),[4,this._transaction.clear()];case 6:throw n.sent(),this._mutex.unlock(),t;case 7:return[3,9];case 8:throw lr.collectionNotReady;case 9:return[2]}})})},e.prototype.upsertMany=function(e){return(0,s._)(this,void 0,void 0,function(){var t,n,r,i,a,o,u,c=this;return(0,s.b)(this,function(l){switch(l.label){case 0:return this.isReady?[4,this._mutex.lock()]:[3,15];case 1:l.sent(),l.label=2;case 2:if(l.trys.push([2,12,,14]),e.some(function(e){return!c._hasPropertyOfKeyName(e)}))throw lr.collectionKeyNotGiven;l.label=3;case 3:l.trys.push([3,8,9,10]),t=(0,s.w)(e),n=t.next(),l.label=4;case 4:return n.done?[3,7]:(r=n.value,[4,this._requestUpsert(hr(r))]);case 5:l.sent(),l.label=6;case 6:return n=t.next(),[3,4];case 7:return[3,10];case 8:return i=l.sent(),o={error:i},[3,10];case 9:try{n&&!n.done&&(u=t.return)&&u.call(t)}finally{if(o)throw o.error}return[7];case 10:return[4,this._transaction.commit()];case 11:return l.sent(),this._mutex.unlock(),[2,e];case 12:return a=l.sent(),[4,this._transaction.clear()];case 13:throw l.sent(),this._mutex.unlock(),a;case 14:return[3,16];case 15:throw lr.collectionNotReady;case 16:return[2]}})})},e.prototype.update=function(e){return(0,s._)(this,void 0,void 0,function(){var t;return(0,s.b)(this,function(n){switch(n.label){case 0:return this.isReady?[4,this._mutex.lock()]:[3,8];case 1:n.sent(),n.label=2;case 2:if(n.trys.push([2,5,,7]),!this._hasPropertyOfKeyName(e))throw lr.collectionKeyNotGiven;return[4,this._requestUpdate(hr(e))];case 3:return n.sent(),[4,this._transaction.commit()];case 4:return n.sent(),this._mutex.unlock(),[2,e];case 5:return t=n.sent(),[4,this._transaction.clear()];case 6:throw n.sent(),this._mutex.unlock(),t;case 7:return[3,9];case 8:throw lr.collectionNotReady;case 9:return[2]}})})},e.prototype.updateIf=function(e,t){return(0,s._)(this,void 0,void 0,function(){var n,r,i,a,o,u,c,l,d,h,f,p,m,_,v=this;return(0,s.b)(this,function(y){switch(y.label){case 0:return this.isReady?[4,this._mutex.lock()]:[3,16];case 1:y.sent(),y.label=2;case 2:return y.trys.push([2,13,,15]),n=e.where,r=void 0===n?{}:n,i=e.index,a=void 0===i?null:i,o=e.backward,u=void 0!==o&&o,c=[],[4,new Mr({condition:r,blockManager:this._blockManager,backward:u,indexer:this._getIndexerBy(a)}).each(function(e){return(0,s._)(v,void 0,void 0,function(){var n;return(0,s.b)(this,function(i){if(e.error)throw e.stop(),e.error;return e.hasNext?(n=e.nextValue,_r(r,n)&&t.set&&("function"!=typeof t.set?Object.keys(t.set).forEach(function(e){var r;n[e]=null===(r=t.set)||void 0===r?void 0:r[e]}):t.set(n),c.push(n)),e.next()):e.stop(),[2]})})})];case 3:y.sent(),y.label=4;case 4:y.trys.push([4,9,10,11]),l=(0,s.w)(c),d=l.next(),y.label=5;case 5:return d.done?[3,8]:(h=d.value,[4,this._requestUpdate(hr(h))]);case 6:y.sent(),y.label=7;case 7:return d=l.next(),[3,5];case 8:return[3,11];case 9:return f=y.sent(),m={error:f},[3,11];case 10:try{d&&!d.done&&(_=l.return)&&_.call(l)}finally{if(m)throw m.error}return[7];case 11:return[4,this._transaction.commit()];case 12:return y.sent(),this._mutex.unlock(),[2,c];case 13:return p=y.sent(),[4,this._transaction.clear()];case 14:throw y.sent(),this._mutex.unlock(),p;case 15:return[3,17];case 16:throw this._transaction.clear(),lr.collectionNotReady;case 17:return[2]}})})},e.prototype.remove=function(e){return(0,s._)(this,void 0,void 0,function(){var t;return(0,s.b)(this,function(n){switch(n.label){case 0:return this.isReady?[4,this._mutex.lock()]:[3,8];case 1:n.sent(),n.label=2;case 2:return n.trys.push([2,5,,7]),[4,this._requestRemove(e)];case 3:return n.sent(),[4,this._transaction.commit()];case 4:return n.sent(),this._mutex.unlock(),[3,7];case 5:return t=n.sent(),[4,this._transaction.clear()];case 6:throw n.sent(),this._mutex.unlock(),t;
1case 7:return[3,9];case 8:throw lr.collectionNotReady;case 9:return[2]}})})},e.prototype.removeIf=function(e){return(0,s._)(this,void 0,void 0,function(){var t,n,r,i,a,o,u,c,l,d,h,f,p,m,_=this;return(0,s.b)(this,function(v){switch(v.label){case 0:return this.isReady?[4,this._mutex.lock()]:[3,15];case 1:v.sent(),v.label=2;case 2:return v.trys.push([2,13,,14]),t=e.where,n=void 0===t?{}:t,r=e.index,i=void 0===r?null:r,a=e.backward,o=void 0!==a&&a,u=[],[4,new Mr({condition:n,blockManager:this._blockManager,backward:o,indexer:this._getIndexerBy(i)}).each(function(e){return(0,s._)(_,void 0,void 0,function(){var t,r;return(0,s.b)(this,function(i){if(e.error)throw e.stop(),e.error;return e.hasNext?(t=e.nextValue,_r(n,t)&&(r=t[this.keyName],u.push(r)),e.next()):e.stop(),[2]})})})];case 3:v.sent(),v.label=4;case 4:v.trys.push([4,9,10,11]),c=(0,s.w)(u),l=c.next(),v.label=5;case 5:return l.done?[3,8]:(d=l.value,[4,this._requestRemove(d)]);case 6:v.sent(),v.label=7;case 7:return l=c.next(),[3,5];case 8:return[3,11];case 9:return h=v.sent(),p={error:h},[3,11];case 10:try{l&&!l.done&&(m=c.return)&&m.call(c)}finally{if(p)throw p.error}return[7];case 11:return[4,this._transaction.commit()];case 12:return v.sent(),this._mutex.unlock(),[2,u];case 13:throw f=v.sent(),this._mutex.unlock(),f;case 14:return[3,16];case 15:throw this._transaction.clear(),lr.collectionNotReady;case 16:return[2]}})})},e.prototype.clear=function(){return(0,s._)(this,void 0,void 0,function(){var e;return(0,s.b)(this,function(t){switch(t.label){case 0:return this.isReady?[4,this._mutex.lock()]:[3,8];case 1:t.sent(),t.label=2;case 2:return t.trys.push([2,5,,7]),[4,this._requestClear()];case 3:return t.sent(),[4,this._transaction.commit()];case 4:return t.sent(),this._mutex.unlock(),[3,7];case 5:return e=t.sent(),[4,this._transaction.clear()];case 6:throw t.sent(),this._mutex.unlock(),e;case 7:return[3,9];case 8:throw lr.collectionNotReady;case 9:return[2]}})})},e.prototype.getBlob=function(e){return(0,s._)(this,void 0,void 0,function(){return(0,s.b)(this,function(t){switch(t.label){case 0:return[4,this._blobContainer.get(e)];case 1:return[2,t.sent()]}})})},e.prototype.saveBlob=function(e,t){return(0,s._)(this,void 0,void 0,function(){return(0,s.b)(this,function(n){switch(n.label){case 0:return[4,this._blobContainer.save(e,t)];case 1:return[2,n.sent()]}})})},e.prototype.removeBlob=function(e){return(0,s._)(this,void 0,void 0,function(){return(0,s.b)(this,function(t){switch(t.label){case 0:return[4,this._blobContainer.remove(e)];case 1:return t.sent(),[2]}})})},e.prototype.removeAllBlobs=function(){return(0,s._)(this,void 0,void 0,function(){return(0,s.b)(this,function(e){switch(e.label){case 0:return[4,this._blobContainer.clear()];case 1:return e.sent(),[2]}})})},e}(),Wr="[NESTDB]",Yr=!0,Jr=function(){function e(){}return e.off=function(){Yr=!1},e.log=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t]},e.warning=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];Yr&&console.warn.apply(console,(0,s.q)(["".concat(Wr,"[WARNING]")],(0,s.r)(e),!1))},e.error=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];Yr&&console.error.apply(console,(0,s.q)(["".concat(Wr,"[ERROR]")],(0,s.r)(e),!1))},e}(),$r=[{},{a:700400,n:"error"}],Xr=function(){function e(e){var t,n,r;this.encryption=null!==(t=e.encryption)&&void 0!==t?t:s.aN,this.itemSizeLimit=null!==(n=e.itemSizeLimit)&&void 0!==n?n:4194304,this.metadataBuffer=null!==(r=e.metadataBuffer)&&void 0!==r?r:256}return Object.defineProperty(e.prototype,"_encryptionCheckKey",{get:function(){return"".concat(this.dbname,".encrypt")},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"_reservedKeys",{get:function(){return[this._encryptionCheckKey]},enumerable:!1,configurable:!0}),e.prototype._getRawKey=function(e,t){return void 0===t&&(t=""),"".concat(e).concat(t)},e.prototype._generateShardPostfixArray=function(e){return void 0===e&&(e=1),(0,s.q)([],(0,s.r)(Array(e).keys()),!1)},e.prototype._shardify=function(e){var t=this,n=e.key,r=e.value,i=JSON.stringify(this.encryption.encrypt
1(r)),s=Math.ceil(i.length/this.adjustedItemSizeLimit);return this._generateShardPostfixArray(s).map(function(e){var r={key:t._getRawKey(n,".".concat(e)),data:i.substring(e*t.adjustedItemSizeLimit,(e+1)*t.adjustedItemSizeLimit)};return 0===e&&(r.metadata={shards:s}),r})},e.prototype._resetIfEncryptionChanged=function(){return(0,s._)(this,void 0,void 0,function(){var e,t,n,r,i,a,o,u,c,l=this;return(0,s.b)(this,function(s){switch(s.label){case 0:return[4,this.get(this._encryptionCheckKey)];case 1:if(e=s.sent(),t={encrypted:$r.map(function(e){var t;return null===(t=l.encryption)||void 0===t?void 0:t.encrypt(e)})},!e)return[3,8];if(!e.encrypted||!Array.isArray(e.encrypted))return[3,6];for(i in n=e.encrypted,r=[],n)r.push(i);a=0,s.label=2;case 2:return a<r.length?(i=r[a])in n?(o=i,u=JSON.stringify(e.encrypted[o]),c=JSON.stringify(t.encrypted[o]),u===c?[3,4]:(Jr.warning("Encryption algorithm has changed. Stored data would be cleared."),[4,this.clear()])):[3,4]:[3,5];case 3:return s.sent(),[3,5];case 4:return a++,[3,2];case 5:return[3,8];case 6:return[4,this.clear()];case 7:s.sent(),s.label=8;case 8:return[4,this.set({key:this._encryptionCheckKey,value:t})];case 9:return s.sent(),[2]}})})},Object.defineProperty(e.prototype,"adjustedItemSizeLimit",{get:function(){return Math.max(this.itemSizeLimit-this.metadataBuffer,4)},enumerable:!1,configurable:!0}),e.prototype.usage=function(){return(0,s._)(this,void 0,void 0,function(){var e,t,n,r,i,a,o,u,c;return(0,s.b)(this,function(l){switch(l.label){case 0:return e=0,[4,this._getAllRawKeys()];case 1:t=l.sent(),l.label=2;case 2:l.trys.push([2,7,8,9]),n=(0,s.w)(t),r=n.next(),l.label=3;case 3:return r.done?[3,6]:(i=r.value,[4,this._getRaw(i)]);case 4:(a=l.sent())&&(e+=JSON.stringify(a).length),l.label=5;case 5:return r=n.next(),[3,3];case 6:return[3,9];case 7:return o=l.sent(),u={error:o},[3,9];case 8:try{r&&!r.done&&(c=n.return)&&c.call(n)}finally{if(u)throw u.error}return[7];case 9:return[2,e]}})})},e.prototype.getAllKeys=function(){return(0,s._)(this,void 0,void 0,function(){var e=this;return(0,s.b)(this,function(t){switch(t.label){case 0:return[4,this._getAllRawKeys()];case 1:return[2,t.sent().filter(function(e){return e.endsWith(".0")}).map(function(e){return e.replace(/\.0$/,"")}).filter(function(t){return!e._reservedKeys.includes(t)})]}})})},e.prototype.get=function(e){return(0,s._)(this,void 0,void 0,function(){var t,n,r,i,a,o,u=this;return(0,s.b)(this,function(c){switch(c.label){case 0:return t=this._getRawKey(e,".0"),[4,this._getRaw(t)];case 1:if(!(n=c.sent()))return[3,7];c.label=2;case 2:return c.trys.push([2,6,,7]),r=n.data,(null==(i=n.metadata)?void 0:i.shards)&&i.shards>1?[4,Promise.all(this._generateShardPostfixArray(null==i?void 0:i.shards).map(function(t){return(0,s._)(u,void 0,void 0,function(){var n,i;return(0,s.b)(this,function(s){switch(s.label){case 0:return t>0?(n=this._getRawKey(e,".".concat(t)),[4,this._getRaw(n)]):[3,2];case 1:if(!(i=s.sent()))throw lr.storeBrokenIntegrity;return[2,i.data];case 2:return[2,r]}})})}))]:[3,4];case 3:return o=c.sent(),[3,5];case 4:o=[r],c.label=5;case 5:return a=o,[2,this.encryption.decrypt(JSON.parse(a.join("")))];case 6:return c.sent(),[2,null];case 7:return[2,null]}})})},e.prototype.set=function(e){return(0,s._)(this,void 0,void 0,function(){var t;return(0,s.b)(this,function(n){switch(n.label){case 0:return t=this._shardify(e),[4,this._setRaw(t)];case 1:return n.sent(),[2,(0,s.j)({},e.value)]}})})},e.prototype.setMany=function(e){return(0,s._)(this,void 0,void 0,function(){var t,n=this;return(0,s.b)(this,function(r){switch(r.label){case 0:return t=[],[4,this._setRaw(t.concat.apply(t,(0,s.q)([],(0,s.r)(e.map(function(e){return n._shardify(e)})),!1)))];case 1:return r.sent(),[2,e.map(function(e){return e.value})]}})})},e.prototype.remove=function(e){return(0,s._)(this,void 0,void 0,function(){var t,n,r,i,a,o=this;return(0,s.b)(this,function(s){switch(s.label){case 0:return t=this._getRawKey(e,".0"),[4,this._getRaw(t)];case 1:return(n=s.sent())?(r=n.metadata,i=this._generateShardPostfixArray(null==r?void 0:r.shards).map(function(t){return o._getRawKey(e,".".concat(t))}),[4,this._removeRaw(i)]):[3,3];case 2:return s.sent(),null==(a=Lr.get(this.dbname))||a.remove(e),[2,!0];case 3:return[2,!1]}})})},e.prototype.removeMany=function(e){return(0,s._)(this,void 0,void 0,function(){var t,n,r,i,a,o,u,c,l,d,h=this;return(0,s.b)(this,function(f){switch(f.label){case 0:t=Lr.get(this.dbname),n=[],r=function(e){var r,a,o;return(0,s.b)(this,function(u){switch(u.label){case 0:return r=i._getRawKey(e,".0"),[4,i._getRaw(r)];case 1:return(a=u.sent())&&(o=a.metadata,n.push.apply(n,(0,s.q)([],(0,s.r)(i._generateShardPostfixArray(null==o?void 0:o.shards).map(function(t){return h._getRawKey(e,".".concat(t))})),!1))),null==t||t.remove(e),[2]}})},i=this,f.label=1;case 1:f.trys.push([1,6,7,8]),a=(0,s.w)(e),o=a.next(),f.label=2;case 2:return o.done?[3,5]:(u=o.value,[5,r(u)]);case 3:f.sent(),f.label=4;case 4:return o=a.next(),[3,2];case 5:return[3,8];case 6:return c=f.sent(),l={error:c},[3,8];case 7:try{o&&!o.done&&(d=a.return)&&d.call(a)}finally{if(l)throw l.error}
1return[7];case 8:return n.length>0?[4,this._removeRaw(n)]:[3,10];case 9:f.sent(),f.label=10;case 10:return[2,e]}})})},e.prototype.clear=function(){return(0,s._)(this,void 0,void 0,function(){var e;return(0,s.b)(this,function(t){return null==(e=Lr.get(this.dbname))||e.clearForDatabase(this.dbname),[2]})})},e}(),Zr={},ei=function(e){function t(t){void 0===t&&(t={});var n,r=this;r=e.call(this,(0,s.j)((0,s.j)({},t),{itemSizeLimit:null!==(n=t.itemSizeLimit)&&void 0!==n?n:4194304}))||this;var i=t.delay,a=void 0===i?1:i;return r.delay=a,r.observer={},r}return(0,s.c)(t,e),Object.defineProperty(t.prototype,"rawData",{get:function(){return Zr[this.dbname]},set:function(e){Zr[this.dbname]=e},enumerable:!1,configurable:!0}),t.prototype._getAllRawKeys=function(){return(0,s._)(this,void 0,void 0,function(){return(0,s.b)(this,function(e){if(Zr[this.dbname])return[2,Object.keys(Zr[this.dbname])];throw lr.storeNotAvailable})})},t.prototype._getRaw=function(e){return(0,s._)(this,void 0,void 0,function(){return(0,s.b)(this,function(t){switch(t.label){case 0:return Zr[this.dbname]?[4,mr(this.delay)]:[3,2];case 1:return t.sent(),[2,Zr[this.dbname][e]?(0,s.j)({key:e},Zr[this.dbname][e]):null];case 2:throw lr.storeNotAvailable}})})},t.prototype._setRaw=function(e){return(0,s._)(this,void 0,void 0,function(){var t,n,r,i,a,o,u,c;return(0,s.b)(this,function(l){switch(l.label){case 0:return Zr[this.dbname]?[4,mr(this.delay)]:[3,2];case 1:l.sent();try{for(t=(0,s.w)(e),n=t.next();!n.done;n=t.next())r=n.value,i=r.key,a=r.data,o=r.metadata,Zr[this.dbname][i]=Object.freeze({data:a,metadata:o})}catch(e){u={error:e}}finally{try{n&&!n.done&&(c=t.return)&&c.call(t)}finally{if(u)throw u.error}}return[3,3];case 2:throw lr.storeNotAvailable;case 3:return[2]}})})},t.prototype._removeRaw=function(e){return(0,s._)(this,void 0,void 0,function(){var t,n,r,i,a;return(0,s.b)(this,function(o){switch(o.label){case 0:return Zr[this.dbname]?[4,mr(this.delay)]:[3,2];case 1:o.sent();try{for(t=(0,s.w)(e),n=t.next();!n.done;n=t.next())r=n.value,Zr[this.dbname][r]&&delete Zr[this.dbname][r]}catch(e){i={error:e}}finally{try{n&&!n.done&&(a=t.return)&&a.call(t)}finally{if(i)throw i.error}}return[3,3];case 2:throw lr.storeNotAvailable;case 3:return[2]}})})},t.prototype.observe=function(e,t,n){var r=this;this.observer[e]||(this.observer[e]={}),t.forEach(function(t){return r.observer[e][t]=n})},t.prototype.checkAvailability=function(){return(0,s._)(this,void 0,void 0,function(){return(0,s.b)(this,function(e){return[2]})})},t.prototype.init=function(e){return(0,s._)(this,void 0,void 0,function(){return(0,s.b)(this,function(t){switch(t.label){case 0:return this.dbname=e,Zr[this.dbname]||(Zr[this.dbname]={}),[4,this._resetIfEncryptionChanged()];case 1:return t.sent(),[2]}})})},t.prototype.set=function(t){return(0,s._)(this,void 0,void 0,function(){var n,r;return(0,s.b)(this,function(i){if((n=this.observer[t.key])&&"function"==typeof n.set&&(r=n.set()))throw r;return[2,e.prototype.set.call(this,t)]})})},t.prototype.setMany=function(t){return(0,s._)(this,void 0,void 0,function(){var n,r,i,a,o,u,c;return(0,s.b)(this,function(l){try{for(n=(0,s.w)(t),r=n.next();!r.done;r=n.next())if(i=r.value,(a=this.observer[i.key])&&"function"==typeof a.set&&(o=a.set()))throw o}catch(e){u={error:e}}finally{try{r&&!r.done&&(c=n.return)&&c.call(n)}finally{if(u)throw u.error}}return[2,e.prototype.setMany.call(this,t)]})})},t.prototype.clear=function(){return(0,s._)(this,void 0,void 0,function(){return(0,s.b)(this,function(t){switch(t.label){case 0:return[4,e.prototype.clear.call(this)];case 1:return t.sent(),[4,mr(this.delay)];case 2:return t.sent(),Zr[this.dbname]={},[2]}})})},t}(Xr),ti="NestDBStore";!function(e){e[e.UNINITIALIZED=0]="UNINITIALIZED",e[e.OPENING=1]="OPENING",e[e.OPEN=2]="OPEN",e[e.CLOSED=3]="CLOSED"}(Kr||(Kr={}));var ni,ri=function(e){function t(t){void 0===t&&(t={});var n,r=this;return(r=e.call(this,(0,s.j)((0,s.j)({},t),{itemSizeLimit:null!==(n=t.itemSizeLimit)&&void 0!==n?n:104857600}))||this)._storeName=ti,r._state=Kr.UNINITIALIZED,r._openJobQueue=[],r._window="undefined"!=typeof window?window:void 0,r._indexedDb=r._window?r._window.indexedDB||r._window.mozIndexedDB||r._window.webkitIndexedDB||r._window.msIndexedDB:void 0,r}return(0,s.c)(t,e),Object.defineProperty(t.prototype,"state",{get:function(){return this._state}
1,enumerable:!1,configurable:!0}),t.prototype.isTransactionInactiveError=function(e){return e instanceof Error&&e.message.includes("The transaction is inactive")},t.prototype._putToObjectStore=function(e,t){return(0,s._)(this,void 0,void 0,function(){return(0,s.b)(this,function(n){return[2,new Promise(function(n,r){var i=e.put(t);i.addEventListener("success",function(e){n(e.target.result)}),i.addEventListener("error",function(e){r(e.target.error)})})]})})},t.prototype._deleteFromObjectStore=function(e,t){return(0,s._)(this,void 0,void 0,function(){return(0,s.b)(this,function(n){return[2,new Promise(function(n,r){var i=e.delete(t);i.addEventListener("success",function(){return n(t)}),i.addEventListener("error",function(e){return r(e.target.error)})})]})})},t.prototype._openDatabase=function(e){var t=this;return new Promise(function(n,r){if(t._indexedDb){t._state=Kr.OPENING;var i=t._indexedDb.open(e);i.addEventListener("upgradeneeded",function(e){e.target.result.createObjectStore(ti,{keyPath:"key"})}),i.addEventListener("success",function(r){t._state=Kr.OPEN,t._database=r.target.result,t._openJobQueue.forEach(function(e){return e()}),t._openJobQueue=[],t._database.onclose=function(){t._database=void 0,t._state=Kr.OPENING,setTimeout(function(){t._openDatabase(e)},5)},n(t._database)}),i.addEventListener("error",function(e){t._state=Kr.UNINITIALIZED,r(e.target.error)})}else r(lr.storeNotAvailable)})},t.prototype._getObjectStore=function(e){return(0,s._)(this,void 0,void 0,function(){var t,n=this;return(0,s.b)(this,function(r){switch(r.label){case 0:return this._database?((t=this._database.transaction(this._storeName,e)).addEventListener("abort",function(e){throw e.target.error}),[2,t.objectStore(this._storeName)]):[3,1];case 1:switch(this._state){case Kr.UNINITIALIZED:case Kr.OPEN:return[3,2];case Kr.OPENING:case Kr.CLOSED:return[3,3]}return[3,4];case 2:throw lr.storeNotInitialized;case 3:return[2,new Promise(function(t){n._openJobQueue.push(function(){return t(n._getObjectStore(e))})})];case 4:return[4,this._getObjectStore(e)];case 5:return[2,r.sent()]}})})},t.prototype._getAllRawKeys=function(){return(0,s._)(this,void 0,void 0,function(){var e=this;return(0,s.b)(this,function(t){switch(t.label){case 0:return[4,new Promise(function(t,n){return(0,s._)(e,void 0,void 0,function(){var e,r;return(0,s.b)(this,function(i){switch(i.label){case 0:return[4,this._getObjectStore("readonly")];case 1:return e=i.sent(),(r=e.getAllKeys()).addEventListener("success",function(e){t(e.target.result)}),r.addEventListener("error",function(e){return n(e.target.error)}),[2]}})})})];case 1:return[2,t.sent()]}})})},t.prototype._getRaw=function(e){return(0,s._)(this,void 0,void 0,function(){var t=this;return(0,s.b)(this,function(n){switch(n.label){case 0:return[4,new Promise(function(n,r){return(0,s._)(t,void 0,void 0,function(){var t,i;return(0,s.b)(this,function(s){switch(s.label){case 0:return[4,this._getObjectStore("readonly")];case 1:return t=s.sent(),(i=t.get(e)).addEventListener("success",function(e){var t;n(null===(t=null==e?void 0:e.target)||void 0===t?void 0:t.result)}),i.addEventListener("error",function(e){return r(e.target.error)}),[2]}})})})];case 1:return[2,n.sent()]}})})},t.prototype._setRaw=function(e){return(0,s._)(this,void 0,void 0,function(){var t,n,r,i,a,o,u,c,l,d=this;return(0,s.b)(this,function(h){switch(h.label){case 0:return h.trys.push([0,3,,15]),[4,this._getObjectStore("readwrite")];case 1:return t=h.sent(),[4,Promise.all(e.map(function(e){return d._putToObjectStore(t,e)}))];case 2:return h.sent(),[3,15];case 3:return n=h.sent(),this.isTransactionInactiveError(n)?[4,this._getObjectStore("readwrite")]:[3,13];case 4:r=h.sent(),h.label=5;case 5:h.trys.push([5,10,11,12]),i=(0,s.w)(e),a=i.next(),h.label=6;case 6:return a.done?[3,9]:(o=a.value,[4,this._putToObjectStore(r,o)]);case 7:h.sent(),h.label=8;case 8:return a=i.next(),[3,6];case 9:return[3,12];case 10:return u=h.sent(),c={error:u},[3,12];case 11:try{a&&!a.done&&(l=i.return)&&l.call(i)}finally{if(c)throw c.error}return[7];case 12:return[3,14];case 13:throw n;case 14:return[3,15];case 15:return[2]}})})},t.prototype._removeRaw=function(e){return(0,s._)(this,void 0,void 0,function(){var t,n,r,i,a,o,u,c,l,d=this;return(0,s.b)(this,function(h){switch(h.label){case 0:return h.trys.push([0,3,,15]),[4,this._getObjectStore("readwrite")];case 1:return t=h.sent(),[4,Promise.all(e.map(function(e){return d._deleteFromObjectStore(t,e)}))];case 2:return h.sent(),[3,15];case 3:return n=h.sent(),this.isTransactionInactiveError(n)?[4,this._getObjectStore("readwrite")]:[3,13];case 4:r=h.sent(),h.label=5;
1case 5:h.trys.push([5,10,11,12]),i=(0,s.w)(e),a=i.next(),h.label=6;case 6:return a.done?[3,9]:(o=a.value,[4,this._deleteFromObjectStore(r,o)]);case 7:h.sent(),h.label=8;case 8:return a=i.next(),[3,6];case 9:return[3,12];case 10:return u=h.sent(),c={error:u},[3,12];case 11:try{a&&!a.done&&(l=i.return)&&l.call(i)}finally{if(c)throw c.error}return[7];case 12:return[3,14];case 13:throw n;case 14:return[3,15];case 15:return[2]}})})},t.prototype._triggerDatabaseClose=function(){this._database&&this._database.onclose&&this._database.onclose(new Event("dummy"))},t.prototype.checkAvailability=function(){return(0,s._)(this,void 0,void 0,function(){var e,t=this;return(0,s.b)(this,function(n){switch(n.label){case 0:if(!((null==(e="undefined"!=typeof window?window:null)?void 0:e.indexedDB)||(null==e?void 0:e.mozIndexedDB)||(null==e?void 0:e.webkitIndexedDB)||(null==e?void 0:e.msIndexedDB)))return[3,6];if(this._indexedDb=e.indexedDB||e.mozIndexedDB||e.webkitIndexedDB||e.msIndexedDB,!this._window||!Vr())return[3,4];if(!(Vr()&&navigator.userAgent&&navigator.userAgent.includes("Edge/")))return[3,1];if(!this._window.indexedDB&&(e.PointerEvent||e.MSPointerEvent))throw lr.storeNotAvailableInPrivateBrowsing;return[3,3];case 1:return[4,new Promise(function(e,n){if(t._indexedDb)try{var r=t._indexedDb.open("_testMozilla");r.onerror=function(){return n(lr.storeNotAvailableInPrivateBrowsing)},r.onsuccess=function(r){if(r.target.result.close(),t._indexedDb){var i=t._indexedDb.deleteDatabase("_testMozilla");i.onerror=function(){return e()},i.onsuccess=function(){return e()}}else n(lr.storeNotAvailable)}}catch(e){n(lr.storeNotAvailableInPrivateBrowsing)}else n(lr.storeNotAvailable)})];case 2:n.sent(),n.label=3;case 3:return[3,5];case 4:throw lr.storeNotAvailable;case 5:return[3,7];case 6:throw lr.storeNotAvailable;case 7:return[2]}})})},t.prototype.init=function(e){return(0,s._)(this,void 0,void 0,function(){return(0,s.b)(this,function(t){switch(t.label){case 0:return this.dbname=e,[4,this.checkAvailability()];case 1:return t.sent(),[4,this._openDatabase(e)];case 2:return t.sent(),[4,this._resetIfEncryptionChanged()];case 3:return t.sent(),[2]}})})},t.prototype.clear=function(){return(0,s._)(this,void 0,void 0,function(){var t=this;return(0,s.b)(this,function(n){switch(n.label){case 0:return[4,e.prototype.clear.call(this)];case 1:return n.sent(),[4,new Promise(function(e,n){return(0,s._)(t,void 0,void 0,function(){var t,r;return(0,s.b)(this,function(i){switch(i.label){case 0:return[4,this._getObjectStore("readwrite")];case 1:return t=i.sent(),(r=t.clear()).addEventListener("success",function(){return e()}),r.addEventListener("error",function(e){return n(e.target.error)}),[2]}})})})];case 2:return[2,n.sent()]}})})},t}(Xr),ii=function(e){function t(t){var n=this,r=t.AsyncStorage,i=t.itemSizeLimit,a=void 0===i?2097152:i,o=(0,s.aO)(t,["AsyncStorage","itemSizeLimit"]);return(n=e.call(this,(0,s.j)((0,s.j)({},o),{itemSizeLimit:a}))||this)._asyncStorage=r,n}return(0,s.c)(t,e),t.prototype._isBelonging=function(e){return e.startsWith("".concat(this.dbname,"/"))},t.prototype._getActualKey=function(e){return"".concat(this.dbname,"/").concat(e)},t.prototype._getAllRawKeys=function(){return(0,s._)(this,void 0,void 0,function(){var e=this;return(0,s.b)(this,function(t){switch(t.label){case 0:return[4,this._asyncStorage.getAllKeys()];case 1:return[2,t.sent().filter(function(t){return e._isBelonging(t)}).map(function(t){return t.substring("".concat(e.dbname,"/").length)})]}})})},t.prototype._getRaw=function(e){return(0,s._)(this,void 0,void 0,function(){var t;return(0,s.b)(this,function(n){switch(n.label){case 0:return[4,this._asyncStorage.getItem(this._getActualKey(e))];case 1:return[2,(t=n.sent())?JSON.parse(t):null]}})})},t.prototype._setRaw=function(e){return(0,s._)(this,void 0,void 0,function(){var t,n,r,i,a,o,u;return(0,s.b)(this,function(c){switch(c.label){case 0:t=[];try{for(n=(0,s.w)(e),r=n.next();!r.done;r=n.next())i=r.value,a=i.key,i.data.length<=this.adjustedItemSizeLimit&&t.push([this._getActualKey(a),JSON.stringify(i)])}catch(e){o={error:e}}finally{try{r&&!r.done&&(u=n.return)&&u.call(n)}finally{if(o)throw o.error}}return[4,this._asyncStorage.multiSet(t)];case 1:return c.sent(),[2]}})})},t.prototype._removeRaw=function(e){return(0,s._)(this,void 0,void 0,function(){var t=this;return(0,s.b)(this,function(n){switch(n.label){case 0:return[4,this._asyncStorage.multiRemove(e.map(function(e){return t._getActualKey(e)}))];case 1:return n.sent(),[2]}})})},t.prototype.checkAvailability=function(){return(0,s._)(this,void 0,void 0,function(){return(0,s.b)(this,function(e){if(!this._asyncStorage)throw lr.storeNotAvailable;return[2]})})},t.prototype.init=function(e){return(0,s._)(this,void 0,void 0,function(){return(0,s.b)(this,function(t){switch(t.label){case 0:return this.dbname=e,[4,this._resetIfEncryptionChanged()];case 1:return t.sent(),[2]}})})},t.prototype.clear=function(){return(0,s._)(this,void 0,void 0,function(){var t;return(0,s.b)(this,function(n){switch(n.label){case 0:return[4,e.prototype.clear.call(this)];case 1:return n.sent(),[4,this.getAllKeys()];case 2:return t=n.sent(),[4,this.removeMany(t)];case 3:return n.sent(),[2]}})})},t}(Xr),si=function(e){function t(t){var n,r=this;return(r=e.call(this,(0,s.j)((0,s.j)({},t),{itemSizeLimit:null!==(n=t.itemSizeLimit)&&void 0!==n?n:6291456}))||this)._mmkv=t.MMKV,r}return(0,s.c)(t,e),t.prototype._isBelonging=function(e){return e.startsWith("".concat(this.dbname,"/"))},t.prototype._getActualKey=function(e){return"".concat(this.dbname,"/").concat(e)},t.prototype._getAllRawKeys=function(){return(0,s._)(this,void 0,void 0,function(){var e=this;return(0,s.b)(this,function(t){switch(t.label){case 0:return[4,this._mmkv.getAllKeys()];case 1:return[2,t.sent().filter(function(t){return e._isBelonging(t)}).map(function(t){return t.substring("".concat(e.dbname,"/").length)})]}})})},t.prototype._getRaw=function(e){return(0,s._)(this,void 0,void 0,function(){var t;return(0,s.b)(this,function(n){switch(n.label){case 0:return[4,this._mmkv.getString(this._getActualKey(e))];case 1:return[2,(t=n.sent())?JSON.parse(t):null]}})})},t.prototype._setRaw=function(e){return(0,s._)(this,void 0,void 0,function(){var t,n,r,i,a,o;return(0,s.b)(this,function(u){try{for(t=(0,s.w)(e),n=t.next();!n.done;n=t.next())r=n.value,i=r.key,r.data.length<=this.adjustedItemSizeLimit&&this._mmkv.set(this._getActualKey(i),JSON.stringify(r))}catch(e){a={error:e}}
1finally{try{n&&!n.done&&(o=t.return)&&o.call(t)}finally{if(a)throw a.error}}return[2]})})},t.prototype._removeRaw=function(e){return(0,s._)(this,void 0,void 0,function(){var t,n,r,i,a;return(0,s.b)(this,function(o){try{for(t=(0,s.w)(e),n=t.next();!n.done;n=t.next())r=n.value,this._mmkv.delete(this._getActualKey(r))}catch(e){i={error:e}}finally{try{n&&!n.done&&(a=t.return)&&a.call(t)}finally{if(i)throw i.error}}return[2]})})},t.prototype.checkAvailability=function(){return(0,s._)(this,void 0,void 0,function(){return(0,s.b)(this,function(e){if(!this._mmkv)throw lr.storeNotAvailable;return[2]})})},t.prototype.init=function(e){return(0,s._)(this,void 0,void 0,function(){return(0,s.b)(this,function(t){switch(t.label){case 0:return this.dbname=e,[4,this._resetIfEncryptionChanged()];case 1:return t.sent(),[2]}})})},t.prototype.clear=function(){return(0,s._)(this,void 0,void 0,function(){var t;return(0,s.b)(this,function(n){switch(n.label){case 0:return[4,e.prototype.clear.call(this)];case 1:return n.sent(),[4,this.getAllKeys()];case 2:return t=n.sent(),[4,this.removeMany(t)];case 3:return n.sent(),[2]}})})},t}(Xr);!function(e){e.INIT="INIT",e.OPENING="OPENING",e.OPENED="OPENED",e.CLOSED="CLOSED"}(ni||(ni={}));var ai,oi=function(){function e(e){var t=e.name,n=e.version,r=e.store,i=e.config;this.name=t,this._version=n,this._state=ni.INIT,this._config=i||new ur({dbname:t}),this._store=r,this._event={success:vr,error:vr,storeReplaced:vr,upgrade:br},this._collections=new Map,this._globalMutex=new Gr("".concat(this.name,".lock")),this._config.disableLogger&&Jr.off(),new Lr({dbname:t,limit:this._config.cacheLimit})}return Object.defineProperty(e.prototype,"version",{get:function(){return this._version},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"state",{get:function(){return this._state},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"store",{get:function(){return this._store},enumerable:!1,configurable:!0}),e.prototype._initializeCollection=function(e,t){var n;return(0,s._)(this,void 0,void 0,function(){var r,i,a;return(0,s.b)(this,function(s){switch(s.label){case 0:return i=this._collections.get(e),t?(r=new Hr({dbname:this.name,collectionName:e,keyName:t.keyName,indexes:null!==(n=t.index)&&void 0!==n?n:[[t.keyName]],store:this._store}),[3,3]):[3,1];case 1:return i&&i.state===cr.READY?[3,3]:[4,Hr.metadataOf(this.name,e,this._store)];case 2:(a=s.sent())&&(r=new Hr({dbname:this.name,collectionName:e,keyName:a.keyName,indexes:a.indexes,store:this._store})),s.label=3;case 3:return r?(this._collections.set(e,r),[4,r.init()]):[3,5];case 4:s.sent(),s.label=5;case 5:return[2]}})})},e.prototype.estimateUsage=function(){return(0,s._)(this,void 0,void 0,function(){return(0,s.b)(this,function(e){switch(e.label){case 0:return[4,(t=this._store,(0,s._)(void 0,void 0,void 0,function(){return(0,s.b)(this,function(e){switch(e.label){case 0:return[4,t.usage()];case 1:return[2,e.sent()]}})}))];case 1:return[2,e.sent()]}var t})})},e.prototype.commitSchema=function(e){return(0,s._)(this,void 0,void 0,function(){var t=this;return(0,s.b)(this,function(n){switch(n.label){case 0:return this._state!==ni.OPENING?[3,2]:[4,Promise.all(e.map(function(e){return(0,s._)(t,void 0,void 0,function(){return(0,s.b)(this,function(t){switch(t.label){case 0:return[4,this._initializeCollection(e.collectionName,e)];case 1:return t.sent(),[2]}})})}))];case 1:return n.sent(),[3,3];case 2:throw lr.databaseSchemaNotOnUpgrade;case 3:return[2]}})})},e.prototype.open=function(){var e;return(0,s._)(this,void 0,void 0,function(){var t,n,r,i,a,o,u,c,l,d,h=this;return(0,s.b)(this,function(f){switch(f.label){case 0:return[4,this._globalMutex.lock()];case 1:if(f.sent(),this._state===ni.OPENED)return[3,20];this._state=ni.OPENING,f.label=2;case 2:return f.trys.push([2,13,,20]),[4,this._store.init(this.name)];case 3:return f.sent(),p=this.name,t="".concat(Ur(p),".metadata"),n={version:0,collectionNames:[]},[4,this._store.get(t)];case 4:r=null!==(e=f.sent())&&void 0!==e?e:n,f.label=5;case 5:f.trys.push([5,10,11,12]),i=(0,s.w)(r.collectionNames),a=i.next(),f.label=6;case 6:return a.done?[3,9]:(o=a.value,[4,this._initializeCollection(o)]);case 7:f.sent(),f.label=8;case 8:return a=i.next(),[3,6];case 9:return[3,12];case 10:return u=f.sent(),l={error:u},[3,12];case 11:try{a&&!a.done&&(d=i.return)&&d.call(i)}finally{if(l)throw l.error}
1return[7];case 12:return[2,new Promise(function(e,n){var i=function(e){r.version<h._version?h._event.upgrade(r.version,function(n){return(0,s._)(h,void 0,void 0,function(){var i;return(0,s.b)(this,function(s){switch(s.label){case 0:if(n)return[3,5];r.version++,r.collectionNames=Array.from(this._collections.keys()),s.label=1;case 1:return s.trys.push([1,3,,4]),[4,this._store.set({key:t,value:r})];case 2:return s.sent(),e({continued:!0}),[3,4];case 3:return i=s.sent(),e({continued:!1,err:i}),[3,4];case 4:return[3,6];case 5:e({continued:!1,err:n}),s.label=6;case 6:return[2]}})})}):e({continued:!1})},a=function(t){var s=t.continued,o=void 0!==s&&s,u=t.err,c=void 0===u?null:u;o?setTimeout(function(){return i(a)},10):c?(Jr.error(c.message),h._globalMutex.unlock(),h._event.error(c),n(c)):Promise.all(r.collectionNames.map(function(e){return h._initializeCollection(e)})).then(function(){h._state=ni.OPENED,h._globalMutex.unlock(),h._event.success(),e()}).catch(function(e){Jr.error(e.message),h._globalMutex.unlock(),h._event.error(e),n(e)})};i(a)})];case 13:switch((c=f.sent()).code){case Hn.STORE_NOT_AVAILABLE_IN_PRIVATE_BROWSING:return[3,14];case Hn.STORE_NOT_AVAILABLE:return[3,16]}return[3,18];case 14:return Jr.warning("Access to the local storage is not allowed. Switched to MemoryStore automatically."),this._store=new ei({}),this._globalMutex.unlock(),this._event.error(c),this._event.storeReplaced(this._store),[4,this.open()];case 15:return f.sent(),[3,19];case 16:return Jr.warning("IndexedDB is not available in this environment. Switched to MemoryStore automatically. Consider using other store to save data persistently (e.g. AsyncStorage)."),this._store=new ei({}),this._globalMutex.unlock(),this._event.error(c),this._event.storeReplaced(this._store),[4,this.open()];case 17:return f.sent(),[3,19];case 18:throw Jr.error(c.message),this._globalMutex.unlock(),this._event.error(c),c;case 19:return[3,20];case 20:return[2]}var p})})},e.prototype.close=function(){this._collections.forEach(function(e){return e.close()}),this._state=ni.CLOSED},e.prototype.clear=function(){return(0,s._)(this,void 0,void 0,function(){return(0,s.b)(this,function(e){switch(e.label){case 0:return[4,Promise.all(Array.from(this._collections.values()).map(function(e){return e.clear()}))];case 1:return e.sent(),[2]}})})},e.prototype.reset=function(){return(0,s._)(this,void 0,void 0,function(){var e;return(0,s.b)(this,function(t){switch(t.label){case 0:return(e=Lr.get(this.name))&&e.clearForDatabase(this.name),[4,this._store.clear()];case 1:return t.sent(),[2]}})})},e.prototype.on=function(e,t){this._event[e]=t},e.prototype.off=function(e){"function"==typeof this._event[e]&&(this._event[e]="upgrade"===e?br:vr)},e.prototype.collection=function(e){var t=this._collections.get(e);if(t)return t;throw lr.collectionNotReady},e}();!function(e){e[e.VERBOSE=0]="VERBOSE",e[e.DEBUG=1]="DEBUG",e[e.INFO=2]="INFO",e[e.WARN=3]="WARN",e[e.ERROR=4]="ERROR",e[e.NONE=5]="NONE"}(ai||(ai={}));var ui,ci=function(){function e(){this.level=ai.WARN}return e.prototype.verbose=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];this.level,ai.VERBOSE},e.prototype.debug=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];this.level,ai.DEBUG},e.prototype.info=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];this.level,ai.INFO},e.prototype.warn=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];this.level<=ai.WARN&&console.warn.apply(console,(0,s.q)(["[warn]"],(0,s.r)(e),!1))},e.prototype.error=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];this.level<=ai.ERROR&&console.error.apply(console,(0,s.q)(["[error]"],(0,s.r)(e),!1))},e}(),li=function(){function e(e){var t,n,r,i;this.messageTypeFilter=null!==(t=null==e?void 0:e.messageTypeFilter)&&void 0!==t?t:s.au.ALL,this.customTypesFilter=null!==(n=null==e?void 0:e.customTypesFilter)&&void 0!==n?n:null,this.senderUserIdsFilter=null!==(r=null==e?void 0:e.senderUserIdsFilter)&&void 0!==r?r:null,this.replyType=null!==(i=null==e?void 0:e.replyType)&&void 0!==i?i:s.aB.NONE}return e.prototype.clone=function(){var t=new e,n=JSON.parse(JSON.stringify(this));
1return Object.keys(n).forEach(function(e){t[e]=n[e]}),t},e.prototype.match=function(e){switch(this.messageTypeFilter){case s.au.USER:if(e.messageType!==s.am.USER)return!1;break;case s.au.FILE:if(e.messageType!==s.am.FILE)return!1;break;case s.au.ADMIN:if(e.messageType!==s.am.ADMIN)return!1}if(this.customTypesFilter&&this.customTypesFilter.length>0&&!this.customTypesFilter.includes("*")&&!this.customTypesFilter.includes(e.customType))return!1;if(this.senderUserIdsFilter&&this.senderUserIdsFilter.length>0){if(!(e instanceof G))return!1;if(!this.senderUserIdsFilter.includes(e.sender.userId))return!1}if(e instanceof Q)switch(this.replyType){case s.aB.NONE:if(e.parentMessageId>0)return!1;break;case s.aB.ONLY_REPLY_TO_CHANNEL:if(e instanceof G&&e.parentMessageId>0&&!e.replyToChannel)return!1}return!0},e}();!function(e){e.CHANNEL_LATEST="channel_latest",e.NEWEST_CHILD_MESSAGE="newest_child_message"}(ui||(ui={}));var di,hi=function(e){switch(e){case ui.CHANNEL_LATEST:return["channelUrl","-createdAt","-messageId"];case ui.NEWEST_CHILD_MESSAGE:return["channelUrl","-parentMessageId","-createdAt","-messageId"]}},fi=function(){return["channelUrl","-createdAt","-notificationId"]},pi=(0,s.j)((0,s.j)({},Re),{scheduledAt:void 0}),mi=function(e){return Fe(e)&&(0,s.a)("number",e.scheduledAt,!0)},_i=(0,s.j)((0,s.j)({},ke),{scheduledAt:0,file:void 0,fileUrl:void 0,fileName:void 0,mimeType:void 0,fileSize:void 0,thumbnailSizes:void 0,requireAuth:!1}),vi=function(e){return Oe(e)&&(0,s.a)("number",e.scheduledAt)&&((0,s.i)(e.file)||(0,s.a)("string",e.fileUrl))&&(0,s.a)("string",e.fileName,!0)&&(0,s.a)("string",e.mimeType,!0)&&(0,s.a)("number",e.fileSize,!0)&&(null===e.thumbnailSizes||void 0===e.thumbnailSizes||e.thumbnailSizes.every(function(e){return(0,s.a)("object",e)&&e.maxWidth>0&&e.maxHeight>0}))},yi="UnsentMessage",gi="reqId",bi={},Ii=function(e){function t(t){var n=e.call(this,t)||this;return n._mutex=new Gr("unsendmessagecache.lock"),bi[t]=n,n}return(0,s.c)(t,e),Object.defineProperty(t.prototype,"_cacheContext",{get:function(){return s.V.of(this._iid).cacheContext},enumerable:!1,configurable:!0}),t.of=function(e,n){return void 0===n&&(n=!1),bi[e]&&!n||(bi[e]=new t(e)),bi[e]},Object.defineProperty(t.prototype,"collection",{get:function(){var e=this._cacheContext.nestdb,t=null==e?void 0:e.collection(yi);if(!t)throw s.t.databaseError;return t},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"localCacheEnabled",{get:function(){return this._cacheContext.localCacheEnabled&&!!this.collection},enumerable:!1,configurable:!0}),t.prototype._serialize=function(e){if(e.messageId>0)throw s.t.invalidParameters;var t,n=(0,s.j)({},e.serialize());return e instanceof X?(e.messageParams&&(n.messageParams=Pe(e.messageParams)),e.scheduledInfo&&e.scheduledInfo.scheduledMessageParams&&(n.scheduledInfo.scheduledMessageParams=(t=e.scheduledInfo.scheduledMessageParams,(0,s.j)((0,s.j)({},Pe(t)),{scheduledAt:t.scheduledAt})))):e instanceof ie?(e.messageParams&&(n.messageParams=ze(e.messageParams)),e.scheduledInfo&&e.scheduledInfo.scheduledMessageParams&&(n.scheduledInfo.scheduledMessageParams=function(e){return(0,s.j)((0,s.j)({},ze(e)),{scheduledAt:e.scheduledAt})}(e.scheduledInfo.scheduledMessageParams))):e instanceof Z&&e.messageParams&&(n.messageParams=function(e){return(0,s.e)({fileInfoList:e.fileInfoList.map(function(e){return{file:e.file,fileUrl:se.getPlainUrl(e),fileName:e.fileName,fileSize:e.fileSize,mimeType:e.mimeType,thumbnailSizes:e.thumbnailSizes,_thumbnails:e._thumbnails,_uploadedMetaData:e._uploadedMetaData}}),isReplyToChannel:e.isReplyToChannel,pushNotificationDeliveryOption:e.pushNotificationDeliveryOption})}(e.messageParams)),n},t.prototype._deserialize=function(e){return e=(0,s.j)((0,s.j)({},e),{messageId:parseInt(e.messageId)}),Di.of(this._iid).buildMessageFromSerializedData(e)},t.prototype._deserializeWithMessageCreateParams=function(e){var t,n,r;return(0,s._)(this,void 0,void 0,function(){var i,a,o,u,c,l,d=this;return(0,s.b)(this,function(h){switch(h.label){case 0:return i=Di.of(this._iid),a=this._deserialize(e),e.messageParams?a instanceof X?(u=e.messageParams,a.messageParams=i.buildUserMessageCreateParamsFromSerializedData(u,a),[3,6]):[3,1]:[3,6];case 1:return a instanceof ie?(u=e.messageParams).fileKey&&"string"==typeof u.fileKey&&je(null!==(t=u.fileType)&&void 0!==t?t:"")?(o=u,[4,this.collection.getBlob(u.fileKey)]):[3,3]:[3,4];case 2:o.file=null!==(n=h.sent())&&void 0!==n?n:void 0,h.label=3;case 3:return a.messageParams=i.buildFileMessageCreateParamsFromSerializedData(u,a),[3,6];case 4:return a instanceof Z&&(u=e.messageParams)&&u.fileInfoList?(a.messageParams=i.buildMultipleFilesMessageCreateParamsFromSerializedData(u,a),[4,Promise.all(a.messageParams.fileInfoList.map(function(e){return(0,s._)(d,void 0,void 0,function(){var t,n,r,i,a;return(0,s.b)(this,function(s){switch(s.label){case 0:return"string"==typeof(null===(n=e._uploadedMetaData)||void 0===n?void 0:n.fileKey)&&je(null!==(i=null===(r=e._uploadedMetaData)||void 0===r?void 0:r.fileType)&&void 0!==i?i:"")?(t=e,[4,this.collection.getBlob(e._uploadedMetaData.fileKey)]):[3,2];case 1:t.file=null!==(a=s.sent())&&void 0!==a?a:void 0,s.label=2;case 2:return[2]}})})}))]):[3,6];case 5:h.sent(),h.label=6;case 6:return a.scheduledInfo&&e.scheduledInfo&&e.scheduledInfo.scheduledMessageParams?a instanceof X?(c=e.scheduledInfo.scheduledMessageParams,a.scheduledInfo.scheduledMessageParams=i.buildScheduledUserMessageCreateParamsFromSerializedData(c,a),[3,10]):[3,7]:[3,10];case 7:return a instanceof ie?(c=e.scheduledInfo.scheduledMessageParams).fileKey&&"string"==typeof c.fileKey&&"string"==typeof c.fileType&&je(c.fileType)?(l=c,[4,this.collection.getBlob(c.fileKey)]):[3,9]:[3,10];case 8:l.file=null!==(r=h.sent())&&void 0!==r?r:void 0,h.label=9;case 9:a.scheduledInfo.scheduledMessageParams=i.buildScheduledFileMessageCreateParamsFromSerializedData(c,a),h.label=10;case 10:return[2,a]}})})},t.prototype._getFileInfoBlobKey=function(e,t){return"".concat(e,".").concat(t)},t.prototype.get=function(e){return(0,s._)(this,void 0,void 0,function(){var t;return(0,s.b)(this,function(n){switch(n.label){case 0:return this.localCacheEnabled?[4,this.collection.getByKey("".concat(e))]:[3,2];case 1:if(t=n.sent())return[2,this._deserializeWithMessageCreateParams(t)];n.label=2;case 2:return[2,void 0]}})})},t.prototype.fetch=function(e){var t=e.channelUrl,n=e.filter,r=void 0===n?new li:n,i=e.order,a=void 0===i?ui.CHANNEL_LATEST:i,o=e.sendingStatus,u=e.backward,c=void 0!==u&&u,l=e.parentMessageId;return(0,s._)(this,void 0,void 0,function(){var e,n,i,u,d=this;return(0,s.b)(this,function(h){switch(h.label){case 0:return this.localCacheEnabled?(e=hi(a),n={"/where":function(e){return!!(a!==ui.NEWEST_CHILD_MESSAGE||l&&0!==e.parentMessageId&&e.parentMessageId===l)&&r.match(d._deserialize(e))}},t&&(n.channelUrl=t),o&&(n.sendingStatus=o),i={where:n,index:e,backward:c},[4,this.collection.query(i)]):[3,3];case 1:return[4,h.sent().fetch({})];case 2:return u=h.sent(),[2,Promise.all(u.map(function(e){return(0,s._)(d,void 0,void 0,function(){return(0,s.b)(this,function(t){switch(t.label){case 0:return[4,this._deserializeWithMessageCreateParams(e)];case 1:return[2,t.sent()]}})})}))];case 3:return[2,[]]}})})},t.prototype.getAllChildMessages=function(e,t){return void 0===t&&(t=new li),(0,s._)(this,void 0,void 0,function(){return(0,s.b)(this,function(n){switch(n.label){case 0:return[4,this.fetch({filter:t,order:ui.NEWEST_CHILD_MESSAGE,channelUrl:e.channelUrl,backward:!1,parentMessageId:e.messageId})];case 1:return[2,n.sent()]}})})},t.prototype.upsert=function(e){return(0,s._)(this,void 0,void 0,function(){var t=this;return(0,s.b)(this,function(n){switch(n.label){case 0:return this.localCacheEnabled?[4,Promise.all(e.map(function(e){return(0,s._)(t,void 0,void 0,function(){var t;return(0,s.b)(this,function(n){switch(n.label){case 0:return e instanceof ie||e instanceof Z?[4,this._mutex.lock()]:[3,4];case 1:return n.sent(),[4,this.saveBlob(e)];case 2:return n.sent(),[4,this._mutex.unlock()];case 3:n.sent(),n.label=4;case 4:return t=this._serialize(e),[4,this.collection.upsertOne(t)];case 5:return n.sent(),[2]}})})}))]:[3,2];case 1:n.sent(),n.label=2;case 2:return[2]}})})},t.prototype.upsertChildMessages=function(e){return(0,s._)(this,void 0,void 0,function(){var t=this;return(0,s.b)(this,function(n){switch(n.label){case 0:return this.localCacheEnabled?[4,Promise.all(e.map(function(e){return(0,s._)(t,void 0,void 0,function(){var t;return(0,s.b)(this,function(n){switch(n.label){case 0:return t=[],e.threadInfo&&e.threadInfo.replyCount>0?[4,this.getAllChildMessages(e)]:[3,2];case 1:t=n.sent(),n.label=2;case 2:return t.length>0?(t.forEach(function(t){return t.applyParentMessage(e)}),[4,this.upsert(t)]):[3,4];case 3:n.sent(),n.label=4;case 4:return[2]}})})}))]:[3,2];case 1:n.sent(),n.label=2;case 2:return[2]}})})},t.prototype.remove=function(e){return(0,s._)(this,void 0,void 0,function(){var t,n,r,i,a,o;return(0,s.b)(this,function(u){switch(u.label){case 0:if(!this.localCacheEnabled)return[3,8];u.label=1;case 1:u.trys.push([1,6,7,8]),t=(0,s.w)(e),n=t.next(),u.label=2;case 2:return n.done?[3,5]:(r=n.value,[4,this.collection.remove(r)]);case 3:u.sent(),u.label=4;case 4:return n=t.next(),[3,2];case 5:return[3,8];case 6:return i=u.sent(),a={error:i},[3,8];
1case 7:try{n&&!n.done&&(o=t.return)&&o.call(t)}finally{if(a)throw a.error}return[7];case 8:return[2]}})})},t.prototype.removeMessagesOfChannel=function(e){return(0,s._)(this,void 0,void 0,function(){return(0,s.b)(this,function(t){switch(t.label){case 0:return this.localCacheEnabled?[4,this.collection.removeIf({where:{channelUrl:e}})]:[3,2];case 1:t.sent(),t.label=2;case 2:return[2]}})})},t.prototype.clear=function(){return(0,s._)(this,void 0,void 0,function(){return(0,s.b)(this,function(e){switch(e.label){case 0:return this.localCacheEnabled?[4,this.collection.clear()]:[3,2];case 1:e.sent(),e.label=2;case 2:return[2]}})})},t.prototype.saveBlob=function(e){return(0,s._)(this,void 0,void 0,function(){var t,n,r,i=this;return(0,s.b)(this,function(a){switch(a.label){case 0:return e instanceof ie?e.messageParams&&(r=e.messageParams).file&&qe(r.file)?[4,this.collection.saveBlob(r.file,e.reqId)]:[3,2]:[3,5];case 1:n=a.sent(),r.fileKey=n,r.fileType=xe.BLOB,a.label=2;case 2:return e.scheduledInfo&&e.scheduledInfo.scheduledMessageParams&&(t=e.scheduledInfo.scheduledMessageParams).file&&qe(t.file)?[4,this.collection.saveBlob(t.file,e.reqId)]:[3,4];case 3:n=a.sent(),t.fileKey=n,t.fileType=xe.BLOB,a.label=4;case 4:return[3,7];case 5:return e instanceof Z&&(r=e.messageParams)&&r.fileInfoList&&Array.isArray(r.fileInfoList)?[4,Promise.all(r.fileInfoList.map(function(t,n){return(0,s._)(i,void 0,void 0,function(){var r;return(0,s.b)(this,function(i){switch(i.label){case 0:return t.file&&qe(t.file)?[4,this.collection.saveBlob(t.file,this._getFileInfoBlobKey(e.reqId,n))]:[3,2];case 1:r=i.sent(),t._uploadedMetaData||(t._uploadedMetaData={}),t._uploadedMetaData.fileKey=r,t._uploadedMetaData.fileType=xe.BLOB,i.label=2;case 2:return[2]}})})}))]:[3,7];case 6:a.sent(),a.label=7;case 7:return[2]}})})},t}(s.ak),Ei={},wi=function(e){function t(t){var n=e.call(this,t)||this;return Ei[t]=n,n}return(0,s.c)(t,e),Object.defineProperty(t.prototype,"_sdkState",{get:function(){return s.V.of(this._iid).sdkState},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"_cacheContext",{get:function(){return s.V.of(this._iid).cacheContext},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"_unsentMessageCache",{get:function(){return Ii.of(this._iid)},enumerable:!1,configurable:!0}),t.of=function(e,n){return void 0===n&&(n=!1),Ei[e]&&!n||(Ei[e]=new t(e)),Ei[e]},Object.defineProperty(t.prototype,"collection",{get:function(){var e=this._cacheContext.nestdb;return(0,s.F)(!!e).throw(s.t.databaseError),e.collection(An)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"localCacheEnabled",{get:function(){return this._cacheContext.localCacheEnabled&&!!this.collection},enumerable:!1,configurable:!0}),t.prototype._serialize=function(e){return(0,s.j)((0,s.j)({},e.serialize()),{messageId:"".concat(e.messageId)})},t.prototype._deserialize=function(e){return e=(0,s.j)((0,s.j)({},e),{messageId:parseInt(e.messageId)}),Di.of(this._iid).buildMessageFromSerializedData(e)},t.prototype.get=function(e){return(0,s._)(this,void 0,void 0,function(){var t;return(0,s.b)(this,function(n){switch(n.label){case 0:return this.localCacheEnabled?[4,this.collection.getByKey("".concat(e))]:[3,2];case 1:if(t=n.sent())return[2,this._deserialize(t)];n.label=2;case 2:return[2,void 0]}})})},t.prototype.fetch=function(e){var t=e.channelUrl,n=e.token,r=e.limit,i=void 0===r?100:r,a=e.filter,o=void 0===a?new li:a,u=e.order,c=void 0===u?ui.CHA
1NNEL_LATEST:u,l=e.backward,d=void 0!==l&&l,h=e.parentMessageId,f=e.isPollOnly,p=void 0!==f&&f,m=e.exactMatch,_=void 0!==m&&m,v=e.inclusive,y=void 0===v||v;return(0,s._)(this,void 0,void 0,function(){var e,r,a,u=this;return(0,s.b)(this,function(l){switch(l.label){case 0:return this.localCacheEnabled?(e=hi(c),r={where:{channelUrl:t,"/where":function(e){if(null!=n&&""!==n)switch(c){case ui.CHANNEL_LATEST:if(_&&e.createdAt!==n)return!1;if(d){if(y&&e.createdAt<n||!y&&e.createdAt<=n)return!1}else if(y&&e.createdAt>n||!y&&e.createdAt>=n)return!1;break;case ui.NEWEST_CHILD_MESSAGE:if(!h||0===e.parentMessageId||e.parentMessageId!==h)return!1}return!(p&&!e._poll)&&o.match(u._deserialize(e))}},index:e,backward:d},[4,this.collection.query(r)]):[3,3];case 1:return[4,l.sent().fetch({limit:null!=i?i:void 0})];case 2:return a=l.sent(),[2,Promise.all(a.map(function(e){return(0,s._)(u,void 0,void 0,function(){return(0,s.b)(this,function(t){return[2,this._deserialize(e)]})})}))];case 3:return[2,[]]}})})},t.prototype.getAllChildMessages=function(e,t){return void 0===t&&(t=new li),(0,s._)(this,void 0,void 0,function(){return(0,s.b)(this,function(n){switch(n.label){case 0:return[4,this.fetch({channelUrl:e.channelUrl,token:Date.now(),limit:null,backward:!1,filter:t,order:ui.NEWEST_CHILD_MESSAGE,parentMessageId:e.messageId})];case 1:return[2,n.sent()]}})})},t.prototype.upsert=function(e){var t;return(0,s._)(this,void 0,void 0,function(){var n,r,i,a,o,u,c,l,d=this;return(0,s.b)(this,function(h){switch(h.label){case 0:return this.localCacheEnabled?[4,this.saveBlobs(e)]:[3,13];case 1:h.sent(),h.label=2;case 2:h.trys.push([2,7,8,9]),n=(0,s.w)(e),r=n.next(),h.label=3;case 3:return r.done?[3,6]:(i=r.value,(null===(t=i.threadInfo)||void 0===t?void 0:t._isUpdateRequired)?[4,this.get(i.messageId)]:[3,5]);case 4:(null==(a=h.sent())?void 0:a.threadInfo)&&i.threadInfo._updateFrom(a.threadInfo),h.label=5;case 5:return r=n.next(),[3,3];case 6:return[3,9];case 7:return o=h.sent(),c={error:o},[3,9];case 8:try{r&&!r.done&&(l=n.return)&&l.call(n)}finally{if(c)throw c.error}return[7];case 9:return u=e.map(function(e){return d._serialize(e)}),[4,this.collection.upsertMany(u)];case 10:return h.sent(),[4,this.upsertChildMessages(e)];case 11:return h.sent(),[4,this._unsentMessageCache.upsertChildMessages(e)];case 12:h.sent(),h.label=13;case 13:return[2]}})})},t.prototype.upsertChildMessages=function(e){return(0,s._)(this,void 0,void 0,function(){var t=this;return(0,s.b)(this,function(n){switch(n.label){case 0:return this.localCacheEnabled?[4,Promise.all(e.map(function(e){return(0,s._)(t,void 0,void 0,function(){var t,n;return(0,s.b)(this,function(r){switch(r.label){case 0:return t=[],(null===(n=e.threadInfo)||void 0===n?void 0:n.replyCount)&&e.threadInfo.replyCount>0?[4,this.getAllChildMessages(e)]:[3,2];case 1:t=r.sent(),r.label=2;case 2:return t.length>0?(t.forEach(function(t){return t.applyParentMessage(e)}),[4,this.upsert(t)]):[3,4];case 3:r.sent(),r.label=4;case 4:return[2]}})})}))]:[3,2];case 1:n.sent(),n.label=2;case 2:return[2]}})})},t.prototype.remove=function(e){return(0,s._)(this,void 0,void 0,function(){var t,n,r,i,a,o;return(0,s.b)(this,function(u){switch(u.label){case 0:if(!this.localCacheEnabled)return[3,8];u.label=1;case 1:u.trys.push([1,6,7,8]),t=(0,s.w)(e),n=t.next(),u.label=2;case 2:return n.done?[3,5]:(r=n.value,[4,this.collection.remove("".concat(r))]);case 3:u.sent(),u.label=4;case 4:return n=t.next(),[3,2];case 5:return[3,8];case 6:return i=u.sent(),a={error:i},[3,8];case 7:try{n&&!n.done&&(o=t.return)&&o.call(t)}finally{if(a)throw a.error}return[7];case 8:return[2]}})})},t.prototype.removeMessagesOfChannel=function(e){return(0,s._)(this,void 0,void 0,function(){var t;return(0,s.b)(this,function(n){switch(n.label){case 0:return this.localCacheEnabled?[4,this.collection.removeIf({where:{channelUrl:e},index:hi(ui.CHANNEL_LATEST)})]:[3,6];case 1:return n.sent(),[4,(t=this._cacheContext.preference).remove("sendbird:".concat(this._sdkState.userId,"@groupchannel/").concat(e,"/message/sync"))];case 2:return n.sent(),[4,t.remove("sendbird:".concat(this._sdkState.userId,"@groupchannel/").concat(e,"/message/sync.meta"))];case 3:return n.sent(),[4,t.remove("sendbird:".concat(this._sdkState.userId,"@groupchannel/").concat(e,"/message/changelogs"))];case 4:return n.sent(),[4,t.remove("sendbird:".concat(this._sdkState.userId,"@groupchannel/").concat(e,"/message/changelogs.meta"))];case 5:n.sent(),n.label=6;case 6:return[2]}})})},t.prototype.removeUnderOffset=function(e,t,n){return void 0===n&&(n=!1),(0,s._)(this,void 0,void 0,function(){return(0,s.b)(this,function(r){switch(r.label){case 0:return this.localCacheEnabled?[4,this.collection.removeIf({where:{channelUrl:e,createdAt:n?{"<=":t}:{"<":t}},index:hi(ui.CHANNEL_LATEST)})]:[3,2];case 1:r.sent(),r.label=2;case 2:return[2]}})})},t.prototype.clear=function(){return(0,s._)(this,void 0,void 0,function(){return(0,s.b)(this,function(e){switch(e.label){case 0:return this.localCacheEnabled?[4,this.collection.clear()]:[3,2];case 1:e.sent(),e.label=2;case 2:return[2]}})})},t.prototype.countBetween=function(e,t,n){return(0,s._)(this,void 0,void 0,function(){var r,i=this;return(0,s.b)(this,function(s){switch(s.label){case 0:return this.localCacheEnabled?(r=hi(ui.CHANNEL_LATEST),[4,this.collection.query({where:{channelUrl:e,"/where":function(e){var r=i._deserialize(e);return n.includes(r.createdAt)&&t.match(r)}},index:r}).count()]):[3,2];case 1:return[2,s.sent()];case 2:return[2,0]}})})},t.prototype.saveBlobs=function(e){return(0,s._)(this,void 0,void 0,function(){var t=this;return(0,s.b)(this,function(n){switch(n.label){case 0:return[4,Promise.all(e.map(function(e){return(0,s._)(t,void 0,void 0,function(){var t,n;return(0,s.b)(this,function(r){switch(r.label){case 0:return e instanceof ie&&e.messageParams&&(t=e.messageParams).file&&qe(t.file)?[4,this.collection.saveBlob(t.file,e.reqId)]:[3,2];case 1:n=r.sent(),t.fileKey=n,r.label=2;case 2:return[2]}})})}))];case 1:return n.sent(),[2]}})})},t.prototype._getGroupChannelPreferenceSize=function(e){return(0,s._)(this,void 0,void 0,function(){var t,n,r,i,a,o;return(0,s.b)(this,function(s){switch(s.label){case 0:return t=0,[4,(n=this._cacheContext.preference).get("sendbird:".concat(this._sdkState.userId,"@groupchannel/").concat(e,"/message/sync"))];case 1:return r=s.sent(),[4,n.get("sendbird:".concat(this._sdkState.userId,"@groupchannel/").concat(e,"/message/sync.meta"))];case 2:return i=s.sent(),[4,n.get("sendbird:".concat(this._sdkState.userId,"@groupchannel/").concat(e,"/message/changelogs"))];case 3:return a=s.sent(),[4,n.get("sendbird:".concat(this._sdkState.userId,"@groupchannel/").concat(e,"/message/changelogs.meta"))];case 4:return o=s.sent(),r&&(t+=JSON.stringify(r).length),i&&(t+=JSON.stringify(i).length),a&&(t+=JSON.stringify(a).length),o&&(t+=JSON.stringify(o).length),[2,t]}})})},t}(s.ak),Ti={},Mi=function(e){function t(t){var n=e.call(this,t)||this;return Ti[t]=n,n}return(0,s.c)(t,e),Object.defineProperty(t.prototype,"_sdkState",{get:function(){return s.V.of(this._iid).sdkState}
1,enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"_cacheContext",{get:function(){return s.V.of(this._iid).cacheContext},enumerable:!1,configurable:!0}),t.of=function(e,n){return void 0===n&&(n=!1),Ti[e]&&!n||(Ti[e]=new t(e)),Ti[e]},Object.defineProperty(t.prototype,"collection",{get:function(){var e=this._cacheContext.nestdb;return(0,s.F)(!!e).throw(s.t.databaseError),e.collection(Sn)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"localCacheEnabled",{get:function(){return this._cacheContext.localCacheEnabled&&!!this.collection},enumerable:!1,configurable:!0}),t.prototype._serialize=function(e){return(0,s.j)({},e.serialize())},t.prototype._deserialize=function(e){return Di.of(this._iid).buildMessageFromSerializedData(e)},t.prototype.get=function(e){return(0,s._)(this,void 0,void 0,function(){var t;return(0,s.b)(this,function(n){switch(n.label){case 0:return this.localCacheEnabled?[4,this.collection.getByKey(e)]:[3,2];case 1:if(t=n.sent())return[2,this._deserialize(t)];n.label=2;case 2:return[2,void 0]}})})},t.prototype.fetch=function(e){var t=e.channelUrl,n=e.token,r=e.limit,i=void 0===r?100:r,a=e.filter,o=void 0===a?new li:a,u=e.backward,c=void 0!==u&&u,l=e.exactMatch,d=void 0!==l&&l,h=e.inclusive,f=void 0===h||h;return(0,s._)(this,void 0,void 0,function(){var e,r=this;return(0,s.b)(this,function(s){switch(s.label){case 0:return this.localCacheEnabled?(e={where:{channelUrl:t,"/where":function(e){if(n){if(d&&e.createdAt!==n)return!1;if(c){if(f&&e.createdAt<n||!f&&e.createdAt<=n)return!1}else if(f&&e.createdAt>n||!f&&e.createdAt>=n)return!1}return o.match(r._deserialize(e))}},index:["channelUrl","-createdAt","-notificationId"],backward:c},[4,this.collection.query(e)]):[3,3];case 1:return[4,s.sent().fetch({limit:null!=i?i:void 0})];case 2:return[2,s.sent().map(function(e){return r._deserialize(e)})];case 3:return[2,[]]}})})},t.prototype.upsert=function(e){return(0,s._)(this,void 0,void 0,function(){var t,n=this;return(0,s.b)(this,function(r){switch(r.label){case 0:return this.localCacheEnabled?(t=e.map(function(e){return n._serialize(e)}),[4,this.collection.upsertMany(t)]):[3,2];case 1:r.sent(),r.label=2;case 2:return[2]}})})},t.prototype.remove=function(e){return(0,s._)(this,void 0,void 0,function(){var t,n,r,i,a,o;return(0,s.b)(this,function(u){switch(u.label){case 0:if(!this.localCacheEnabled)return[3,8];u.label=1;case 1:u.trys.push([1,6,7,8]),t=(0,s.w)(e),n=t.next(),u.label=2;case 2:return n.done?[3,5]:(r=n.value,[4,this.collection.remove(r)]);case 3:u.sent(),u.label=4;case 4:return n=t.next(),[3,2];case 5:return[3,8];case 6:return i=u.sent(),a={error:i},[3,8];case 7:try{n&&!n.done&&(o=t.return)&&o.call(t)}finally{if(a)throw a.error}return[7];case 8:return[2]}})})},t.prototype.markAsReadByTimestamp=function(e,t){return(0,s._)(this,void 0,void 0,function(){return(0,s.b)(this,function(n){switch(n.label){case 0:return this.localCacheEnabled?[4,this.collection.updateIf({where:{channelUrl:e,messageStatus:K.SENT,createdAt:{"<":t}}},{set:{messageStatus:K.READ}})]:[3,2];case 1:n.sent(),n.label=2;case 2:return[2]}})})},t.prototype.markAsReadByMessageIds=function(e,t){return(0,s._)(this,void 0,void 0,function(){return(0,s.b)(this,function(n){switch(n.label){case 0:return this.localCacheEnabled?[4,this.collection.updateIf({where:{channelUrl:e,notificationId:{"/in":t},messageStatus:K.SENT}},{set:{messageStatus:K.READ}})]:[3,2];case 1:return[2,n.sent().length];case 2:return[2,0]}})})},t.prototype.removeMessagesOfChannel=function(e){return(0,s._)(this,void 0,void 0,function(){var t;return(0,s.b)(this,function(n){switch(n.label){case 0:return this.localCacheEnabled?[4,this.collection.removeIf({where:{channelUrl:e},index:["channelUrl","-createdAt","-notificationId"]})]:[3,6];case 1:return n.sent(),[4,(t=this._cacheContext.preference).remove("sendbird:".concat(this._sdkState.userId,"@groupchannel/").concat(e,"/message/sync"))];case 2:return n.sent(),[4,t.remove("sendbird:".concat(this._sdkState.userId,"@groupchannel/").concat(e,"/message/sync.meta"))];case 3:return n.sent(),[4,t.remove("sendbird:".concat(this._sdkState.userId,"@groupchannel/").concat(e,"/message/changelogs"))];case 4:return n.sent(),[4,t.remove("sendbird:".concat(this._sdkState.userId,"@groupchannel/").concat(e,"/message/changelogs.meta"))];case 5:n.sent(),n.label=6;case 6:return[2]}})})},t.prototype.removeUnderOffset=function(e,t){return(0,s._)(this,void 0,void 0,function(){return(0,s.b)(this,function(n){switch(n.label){case 0:return this.localCacheEnabled?[4,this.collection.removeIf({where:{channelUrl:e,createdAt:{"<":t}},index:hi(ui.CHANNEL_LATEST)})]:[3,2];case 1:n.sent(),n.label=2;case 2:return[2]}})})},t.prototype.clear=function(){return(0,s._)(this,void 0,void 0,function(){return(0,s.b)(this,function(e){switch(e.label){case 0:return this.localCacheEnabled?[4,this.collection.clear()]:[3,2];case 1:e.sent(),e.label=2;case 2:return[2]}})})},t.prototype.countBetween=function(e,t,n){return(0,s._)(this,void 0,void 0,function(){var r,i=this;return(0,s.b)(this,function(s){switch(s.label){case 0:return this.localCacheEnabled?(r=["channelUrl","-createdAt","-notificationId"],[4,this.collection.query({where:{channelUrl:e,"/where":function(e){var r=i._deserialize(e);return n.includes(r.createdAt)&&t.match(r)}},index:r}).count()]):[3,2];case 1:return[2,s.sent()];case 2:return[2,0]}})})},t}(s.ak),Ai={},Ui=function(e){function t(t){var n=e.call(this,t)||this;return n._observers=new Map,n._dispatcherContext=n._dispatcher.on(function(e){return(0,s._)(n,void 0,void 0,function(){var t,n,r,i,o,u,c,l,d,h,f,p,m,_,v,y,g,b,I,E,w,T=this;return(0,s.b)(this,function(M){switch(M.label){case 0:return e instanceof a.M?(t=e.messages,w=e.source,u=e.isWebSocketEventComing,n=t.filter(function(e){return e instanceof Q&&e.channelType!==s.C.OPEN&&e.messageId>0}),r=t.filter(function(e){return e instanceof Q&&e.channelType!==s.C.OPEN&&0===e.messageId}),i=t.filter(function(e){return e instanceof te}),n.length>0?[4,(0,s.H)(function(){return(0,s._)(T,void 0,void 0,function(){return(0,s.b)(this,function(e){switch(e.label){case 0:return[4,this._messageCache.upsert(n)];case 1:return e.sent(),[4,this._unsentMessageCache.remove(n.map(function(e){return e instanceof G?e.reqId:null}).filter(function(e){return null!==e}))];case 2:return e.sent(),[2]}})})})]:[3,2]):[3,7];case 1:M.sent(),u||this._broadcastUpdateEvent(n,w),M.label=2;case 2:return r.length>0?[4,(0,s.H)(function(){return(0,s._)(T,void 0,void 0,function(){return(0,s.b)(this,function(e){switch(e.label){case 0:return[4,this._unsentMessageCache.upsert(r)];case 1:return e.sent(),[2]}})})})]:[3,4];case 3:M.sent(),u||this._broadcastUpdateEvent(r,w),M.label=4;case 4:return i.length>0?[4,(0,s.H)(function(){return(0,s._)(T,void 0,void 0,function(){return(0,s.b)(this,function(e){switch(e.label){case 0:return[4,this._notificationCache.upsert(i)];case 1:return e.sent(),[2]}})})})]:[3,6];case 5:M.sent(),u||this._broadcastUpdateEvent(i,w),M.label=6;case 6:return[3,24];case 7:return e instanceof a.j?(o=e.messageIds,w=e.source,u=e.isWebSocketEventComing,c=o.filter(function(e){return"number"==typeof e}),l=o.filter(function(e){return"string"==typeof e}),[4,(0,s.H)(function(){return(0,s._)(T,void 0,void 0,function(){return(0,s.b)(this,function(e){switch(e.label){case 0:return c.length>0?[4,this._messageCache.remove(c)]:[3,2];case 1:e.sent(),e.label=2;case 2:return l.length>0?[4,this._notificationCache.remove(l)]:[3,4];case 3:e.sent(),e.label=4;case 4:return[2]}})})})]):[3,9];case 8:return M.sent(),u||this._broadcastRemoveEvent(o,w),[3,24];case 9:return e instanceof a.U?(d=e.reqId,w=e.source,[4,(0,s.H)(function(){return(0,s._)(T,void 0,void 0,function(){return(0,s.b)(this,function(e){switch(e.label){case 0:return[4,this._unsentMessageCache.remove([d])];case 1:return e.sent(),[2]}})})})]):[3,11];case 10:return M.sent(),this._broadcastRemoveUnsentEvent(d,w),[3,24];case 11:return e instanceof a.i?(h=e.polls,w=e.source,this._cacheContext.localCacheEnabled?(f=h.map(function(e){return e.messageId}),[4,Promise.all(f.map(function(e){return T._messageCache.get(e)}))]):[3,14]):[3,15];case 12:return(p=M.sent().filter(function(e){return e})).length>0&&h.forEach(function(e){var t=p.find(function(t){return t.messageId===e.messageId});t&&t.applyPoll(e)}),[4,(0,s.H)(function(){return(0,s._)(T,void 0,void 0,function(){return(0,s.b)(this,function(e){switch(e.label){case 0:return[4,this._messageCache.upsert(p)];case 1:return[2,e.sent()]}})})})];case 13:M.sent(),M.label=14;case 14:return this._broadcastPollChangeLogEvent(h,w),[3,24];case 15:return e instanceof a.h?(m=e.event,w=e.source,[4,this._messageCache.get(m.messageId)]):[3,19];case 16:return(_=M.sent())&&_.isUserMessage()&&_.poll&&_.poll.applyPollUpdateEvent(m)?[4,(0,s.H)(function(){return(0,s._)(T,void 0,void 0,function(){return(0,s.b)(this,function(e){switch(e.label){case 0:return[4,this._messageCache.upsert([_])];case 1:return[2,e.sent()]}})})})]:[3,18];case 17:M.sent(),M.label=18;case 18:return this._broadcastPollUpdateEvent(m,w),[3,24];case 19:return e instanceof a.e?(v=e.event,w=e.source,[4,this._messageCache.get(v.messageId)]):[3,23];case 20:return(y=M.sent())&&y.isUserMessage()&&y.poll&&y.poll.applyPollVoteEvent(v)?[4,(0,s.H)(function(){return(0,s._)(T,void 0,void 0,function(){return(0,s.b)(this,function(e){switch(e.label){case 0:return[4,this._messageCache.upsert([y])];case 1:return[2,e.sent()]}})})})]:[3,22];case 21:M.sent(),M.label=22;case 22:return this._broadcastPollVoteEvent(v,w),[3,24];case 23:e instanceof a.R?(g=e.event,w=e.source,g.messageId>0&&this._broadcastReactionUpdateEvent(g,w)):e instanceof a.T?(b=e.event,w=e.source,this._broadcastThreadUpdateEvent(b,w)):e instanceof a.g&&(I=e.messageDeletionTimestamp,E=e.channelUrl,w=e.source,this._broadcastMessageRetentionEvent(I,E,w)),M.label=24;case 24:return[2]}})})}),n}return(0,s.c)(t,e),Object.defineProperty(t.prototype,"_cacheContext",{get:function(){return s.V.of(this._iid).cacheContext}
1,enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"_dispatcher",{get:function(){return s.V.of(this._iid).dispatcher},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"_messageCache",{get:function(){return wi.of(this._iid)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"_unsentMessageCache",{get:function(){return Ii.of(this._iid)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"_notificationCache",{get:function(){return Mi.of(this._iid)},enumerable:!1,configurable:!0}),t.of=function(e,n){var r;return void 0===n&&(n=!1),Ai[e]&&!n||(Ai[e]&&(null===(r=Ai[e]._dispatcherContext)||void 0===r||r.close()),Ai[e]=new t(e)),Ai[e]},t.prototype._broadcastUpdateEvent=function(e,t){var n,r;try{for(var i=(0,s.w)(this._observers.values()),a=i.next();!a.done;a=i.next()){var o=a.value;o.onUpdate&&o.onUpdate(e,t)}}catch(e){n={error:e}}finally{try{a&&!a.done&&(r=i.return)&&r.call(i)}finally{if(n)throw n.error}}},t.prototype._broadcastPollChangeLogEvent=function(e,t){var n,r;try{for(var i=(0,s.w)(this._observers.values()),a=i.next();!a.done;a=i.next()){var o=a.value;o.onPollChangeLogUpdate&&o.onPollChangeLogUpdate(e,t)}}catch(e){n={error:e}}finally{try{a&&!a.done&&(r=i.return)&&r.call(i)}finally{if(n)throw n.error}}},t.prototype._broadcastPollUpdateEvent=function(e,t){var n,r;try{for(var i=(0,s.w)(this._observers.values()),a=i.next();!a.done;a=i.next()){var o=a.value;o.onPollUpdate&&o.onPollUpdate(e,t)}}catch(e){n={error:e}}finally{try{a&&!a.done&&(r=i.return)&&r.call(i)}finally{if(n)throw n.error}}},t.prototype._broadcastPollVoteEvent=function(e,t){var n,r;try{for(var i=(0,s.w)(this._observers.values()),a=i.next();!a.done;a=i.next()){var o=a.value;o.onPollVote&&o.onPollVote(e,t)}}catch(e){n={error:e}}finally{try{a&&!a.done&&(r=i.return)&&r.call(i)}finally{if(n)throw n.error}}},t.prototype._broadcastRemoveEvent=function(e,t){var n,r;try{for(var i=(0,s.w)(this._observers.values()),a=i.next();!a.done;a=i.next()){var o=a.value;o.onRemove&&o.onRemove(e,t)}}catch(e){n={error:e}}finally{try{a&&!a.done&&(r=i.return)&&r.call(i)}finally{if(n)throw n.error}}},t.prototype._broadcastRemoveUnsentEvent=function(e,t){var n,r;try{for(var i=(0,s.w)(this._observers.values()),a=i.next();!a.done;a=i.next()){var o=a.value;o.onRemoveUnsent&&o.onRemoveUnsent(e,t)}}catch(e){n={error:e}}finally{try{a&&!a.done&&(r=i.return)&&r.call(i)}finally{if(n)throw n.error}}},t.prototype._broadcastReactionUpdateEvent=function(e,t){var n,r;try{for(var i=(0,s.w)(this._observers.values()),a=i.next();!a.done;a=i.next()){var o=a.value;o.onReactionUpdate&&o.onReactionUpdate(e,t)}}catch(e){n={error:e}}finally{try{a&&!a.done&&(r=i.return)&&r.call(i)}finally{if(n)throw n.error}}},t.prototype._broadcastThreadUpdateEvent=function(e,t){var n,r;try{for(var i=(0,s.w)(this._observers.values()),a=i.next();!a.done;a=i.next()){var o=a.value;o.onThreadInfoUpdate&&o.onThreadInfoUpdate(e,t)}}catch(e){n={error:e}}finally{try{a&&!a.done&&(r=i.return)&&r.call(i)}finally{if(n)throw n.error}}},t.prototype._broadcastMessageRetentionEvent=function(e,t,n){var r,i;try{for(var a=(0,s.w)(this._observers.values()),o=a.next();!o.done;o=a.next()){var u=o.value;u.onDeletedByRetentionPolicy&&u.onDeletedByRetentionPolicy(e,t,n)}}catch(e){r={error:e}}finally{try{o&&!o.done&&(i=a.return)&&i.call(a)}finally{if(r)throw r.error}}},t.prototype.subscribe=function(e,t){this._observers.set(e,t)},t.prototype.unsubscribe=function(e){this._observers.delete(e)},t.prototype.unsubscribeAll=function(){this._observers.clear()},t}(s.ak),Si={},Ni=function(e){function t(t,n){var r=n.sdkState,i=n.cacheContext,s=e.call(this,t)||this;return s._users=new Map,s._sdkState=r,s._cacheContext=i,Si[t]=s,s}return(0,s.c)(t,e),t.of=function(e){return Si[e]},Object.defineProperty(t.prototype,"collection",{get:function(){var e=this._cacheContext.nestdb;return(0,s.F)(!!e).throw(s.t.databaseError),e.collection(Rn)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"localCacheEnabled",{get:function(){return this._cacheContext.localCacheEnabled&&!!this.collection}
1,enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"users",{get:function(){return(0,s.q)([],(0,s.r)(this._users.values()),!1)},enumerable:!1,configurable:!0}),t.prototype._serialize=function(e,t){return(0,s.j)((0,s.j)({},e.serialize()),{updatedAt:t})},t.prototype._deserialize=function(e){return s.U._buildUserFromSerializedData(e)},t.prototype.isCachedInMemory=function(e){return this._users.has(e)},t.prototype.getUserInfoFromCache=function(e){if(this._users.has(e))return this._users.get(e)},t.prototype.get=function(e){return(0,s._)(this,void 0,void 0,function(){var t,n;return(0,s.b)(this,function(r){switch(r.label){case 0:return this._users.has(e)?[3,3]:this.localCacheEnabled?[4,this.collection.getByKey(e)]:[3,2];case 1:if(t=r.sent())return n=this._deserialize(t),this._users.set(n.userId,n),[2,n];r.label=2;case 2:return[2,void 0];case 3:return[2,this._users.get(e)]}})})},t.prototype.fetch=function(e){var t=e.limit,n=void 0===t?100:t,r=e.backward,i=void 0!==r&&r;return(0,s._)(this,void 0,void 0,function(){var e,t,r,a=this;return(0,s.b)(this,function(s){switch(s.label){case 0:if(!this.localCacheEnabled)return[2,[]];s.label=1;case 1:return s.trys.push([1,4,,5]),e={index:["-userId","-updatedAt"],backward:i},[4,this.collection.query(e)];case 2:return[4,s.sent().fetch({limit:n})];case 3:return t=s.sent(),(r=t.map(function(e){return a._deserialize(e)})).forEach(function(e){a._users.has(e.userId)||a._users.set(e.userId,e)}),[2,r];case 4:return s.sent(),[2,[]];case 5:return[2]}})})},t.prototype.upsert=function(e,t){return(0,s._)(this,void 0,void 0,function(){var n,r;return(0,s.b)(this,function(i){switch(i.label){case 0:if(!this.localCacheEnabled)return[3,2];if(n=this._serialize(e,t),r=this._users.get(e.userId)){if(r._hashValue===e._hashValue)return[2];if(r._updatedAt>t)return[2]}return this._users.set(e.userId,s.U._buildUserFromSerializedData(n)),[4,this.collection.upsertOne(n)];case 1:i.sent(),i.label=2;case 2:return[2]}})})},t.prototype.remove=function(e){return(0,s._)(this,void 0,void 0,function(){return(0,s.b)(this,function(t){switch(t.label){case 0:return this._users.has(e)&&this._users.delete(e),this.localCacheEnabled?[4,this.collection.remove(e)]:[3,2];case 1:t.sent(),t.label=2;case 2:return[2]}})})},t.prototype.clearMemoryCache=function(){this._users.clear()},t.prototype.clear=function(){return(0,s._)(this,void 0,void 0,function(){return(0,s.b)(this,function(e){switch(e.label){case 0:return this.clearMemoryCache(),this.localCacheEnabled?[4,this.collection.clear()]:[3,2];case 1:e.sent(),e.label=2;case 2:return[2]}})})},t}(s.ak),Ci=function(e){function t(t){var n=this,r=t.reverse,i=void 0!==r&&r,a=t.limit,o=void 0===a?20:a,u=t.keys,c=t.token;return(n=e.call(this)||this).method=s.A.GET,n.path="".concat(s.aP),n.params=(0,s.e)({token:c,limit:o,reverse:i,order:s.aQ.UPDATED_AT,show_ui_template:!0,show_color_variables:!0,keys:u}),n}return(0,s.c)(t,e),t}(s.f),ki=function(e){function t(t,n){var r=e.call(this,t,n)||this,i=n.next,s=n.has_more,a=void 0!==s&&s,o=n.templates;return r.nextToken=i,r.hasMore=a,r.templates=o.map(function(e){return{template:JSON.stringify(e)}}),r}return(0,s.c)(t,e),t}(s.g),Oi=function(e){function t(t){var n=this,r=t.key;return(n=e.call(this)||this).method=s.A.GET,n.path="".concat(s.aP,"/").concat(r),n}return(0,s.c)(t,e),t}(s.f),Pi=function(e){function t(t,n){var r=e.call(this,t,n)||this;return r.template=JSON.stringify(n),r}return(0,s.c)(t,e),t}(s.g),Ri={},Di=function(){function e(e,t){var n=t.sdkState,r=t.dispatcher,i=t.requestQueue,s=t.onlineDetector,a=t.cacheContext;this._iid=e,this._sdkState=n,this._requestQueue=i,this._dispatcher=r,this._cacheContext=a,wi.of(e),Ii.of(e),Ui.of(e),this.fileMessageQueue=new fe(e,{sdkState:n,dispatcher:r,requestQueue:i,onlineDetector:s,cacheContext:a}),Ri[e]=this}return e.of=function(e){return Ri[e]},e.prototype._setSenderInfo=function(e){if(this._cacheContext.localCacheEnabled&&(e.messageType===s.am.USER||e.messageType===s.am.FILE)){var t=e.sender;if(t){var n=Ni.of(this._iid).getUserInfoFromCache(t.user_id);n&&(e.sender=s.U.payloadify(n))}}},e.prototype.buildMessageFromSerializedData=function(e){var t=(0,s.G)(e);if(t.notificationId)return new te(this._iid,te.payloadify(t));switch(this._setSenderInfo(t),t.messageType){case s.am.USER:return new X(this._iid,X.payloadify(t));case s.am.FILE:return Z._isMultipleFilesMessageSerializedData(t)?new Z(this._iid,Z.payloadify(t)):new ie(this._iid,ie.payloadify(t));case s.am.ADMIN:return new Y(this._iid,Y.payloadify(t))}throw s.t.invalidParameters},e.prototype.buildUserMessageCreateParamsFromSerializedData=function(e,t){return(0,s.e)((0,s.u)({data:t.data,customType:t.customType,mentionType:t.mentionType,mentionedUserIds:t.mentionedUserIds,mentionedUsers:t.mentionedUsers,mentionedMessageTemplate:t.mentionedMessageTemplate,metaArrays:t.metaArrays,parentMessageId:t.parentMessageId,isReplyToChannel:e.isReplyToChannel,pushNotificationDeliveryOption:e.pushNotificationDeliveryOption,appleCriticalAlertOptions:t.appleCriticalAlertOptions,reqId:t.reqId,message:t.message,translationTargetLanguages:Object.keys(t.translations),pollId:e.pollId}))},e.prototype.buildFileMessageCreateParamsFromSerializedData=function(e,t){var n;return(0,s.e)((0,s.u)({data:t.data,customType:t.customType,mentionType:t.mentionType,mentionedUserIds:t.mentionedUserIds,mentionedUsers:t.mentionedUsers,metaArrays:t.metaArrays,parentMessageId:t.parentMessageId,isReplyToChannel:e.isReplyToChannel,pushNotificationDeliveryOption:e.pushNotificationDeliveryOption,appleCriticalAlertOptions:t.appleCriticalAlertOptions,reqId:t.reqId,file:e.file,fileKey:e.fileKey,fileUrl:t.plainUrl,fileName:t.name,fileSize:t.size,mimeType:t.type,thumbnailSizes:null===(n=t.thumbnails)||void 0===n?void 0:n.map(function(e){return{maxWidth:e.width,maxHeight:e.height}}),fileType:e.fileType,requireAuth:t.requireAuth}))},e.prototype.buildMultipleFilesMessageCreateParamsFromSerializedData=function(e,t){var n=this;return(0,s.e)({data:t.data,customType:t.customType,mentionType:t.mentionType,mentionedUserIds:t.mentionedUserIds,mentionedUsers:t.mentionedUsers,metaArrays:t.metaArrays,parentMessageId:t.parentMessageId,isReplyToChannel:e.isReplyToChannel,pushNotificationDeliveryOption:e.pushNotificationDeliveryOption,appleCriticalAlertOptions:t.appleCriticalAlertOptions,reqId:t.reqId,fileInfoList:e.fileInfoList.map(function(e){return new se(n._iid,e)})})},e.prototype.buildScheduledUserMessageCreateParamsFromSerializedData=function(e,t){return(0,s.j)((0,s.j)({},this.buildUserMessageCreateParamsFromSerializedData(e,t)),{scheduledAt:e.scheduledAt})},e.prototype.buildScheduledFileMessageCreateParamsFromSerializedData=function(e,t){return(0,s.j)((0,s.j)({},this.buildFileMessageCreateParamsFromSerializedData(e,t)),{scheduledAt:e.scheduledAt})},e.prototype.buildSenderFromSerializedData=function(e){var t=(0,s.G)(e);return new g(this._iid,g.payloadify(t))},e.prototype.getMessage=function(e){return(0,s._)(this,void 0,void 0,function(){var t;return(0,s.b)(this,function(n){switch(n.label){case 0:return t=new ge(e),[4,this._requestQueue.send(t)];case 1:return[2,n.sent().as(be).message]}})})},e.prototype.getScheduledMessage=function(e){return(0,s._)(this,void 0,void 0,function(){var t;return(0,s.b)(this,function(n){switch(n.label){case 0:return t=new Me(e),[4,this._requestQueue.send(t)];case 1:return[2,n.sent().as(Ae).message]}})})},e.prototype.getMessagesByMessageId=function(e,t,n,r,i){return void 0===i&&(i=a.
1C.REQUEST_MESSAGE),(0,s._)(this,void 0,void 0,function(){var o,u,c;return(0,s.b)(this,function(l){switch(l.label){case 0:return o=new Ie((0,s.j)((0,s.j)((0,s.j)({channelType:t,channelUrl:e,token:String(n)},pe),r),{sdkSource:he.EXTERNAL_LEGACY})),[4,this._requestQueue.send(o)];case 1:return u=l.sent(),c=u.as(Ee).messages,this._dispatcher.dispatch(new a.M({messages:c,source:i})),[2,c]}})})},e.prototype.getMessagesByTimestamp=function(e,t,n,r,i){return void 0===i&&(i=a.C.REQUEST_MESSAGE),(0,s._)(this,void 0,void 0,function(){var o,u,c;return(0,s.b)(this,function(l){switch(l.label){case 0:return o=new Ie((0,s.j)((0,s.j)((0,s.j)({channelType:t,channelUrl:e,timestamp:n},pe),r),{sdkSource:he.EXTERNAL_LEGACY})),[4,this._requestQueue.send(o)];case 1:return u=l.sent(),c=u.as(Ee).messages,this._dispatcher.dispatch(new a.M({messages:c,source:i})),[2,c]}})})},e.prototype._getMessagesByTimestampForCollection=function(e,t,n,r,i,o,u,c){return void 0===i&&(i=a.C.REQUEST_MESSAGE),(0,s._)(this,void 0,void 0,function(){var l,d,h,f,p,m;return(0,s.b)(this,function(_){switch(_.label){case 0:return l=new Ie((0,s.j)((0,s.j)((0,s.j)({channelType:t,channelUrl:e,timestamp:n},pe),r),{checkingHasNext:o,checkingContinuousMessages:u,sdkSource:c})),[4,this._requestQueue.send(l)];case 1:return d=_.sent(),h=d.as(Ee),f=h.messages,p=h.isContinuousMessages,m=h.hasNext,this._dispatcher.dispatch(new a.M({messages:f,source:i})),[2,{messages:f,isContinuousMessages:p,hasNext:m}]}})})},e.prototype.getThreadedMessagesByTimestamp=function(e,t,n,r){return void 0===r&&(r=a.C.REQUEST_THREADED_MESSAGE),(0,s._)(this,void 0,void 0,function(){var i,o,u,c;return(0,s.b)(this,function(l){switch(l.label){case 0:return i=new Ie((0,s.j)((0,s.j)((0,s.j)({channelUrl:e.channelUrl,channelType:e.channelType,timestamp:t},H),n),{replyType:s.aB.ALL,parentMessageId:e.messageId,includeThreadInfo:!0})),[4,this._requestQueue.send(i)];case 1:return o=l.sent(),u=o.as(Ee).messages,(c=u.slice(1)).forEach(function(t){t.parentMessage=e}),this._dispatcher.dispatch(new a.M({messages:c,source:r})),[2,{parentMessage:u[0],threadedMessages:c}]}})})},e.prototype.getMessageTemplatesByToken=function(e,t){return void 0===t&&(t={}),(0,s._)(this,void 0,void 0,function(){var n,r,i,a,o,u;return(0,s.b)(this,function(c){switch(c.label){case 0:return n=new Ci((0,s.j)({token:e},t)),[4,this._requestQueue.send(n)];case 1:return r=c.sent(),i=r.as(ki),a=i.hasMore,o=i.nextToken,u=i.templates,[2,{hasMore:a,token:o,templates:u}]}})})},e.prototype.getMessageTemplate=function(e){return(0,s._)(this,void 0,void 0,function(){var t;return(0,s.b)(this,function(n){switch(n.label){case 0:return t=new Oi({key:e}),[4,this._requestQueue.send(t)];case 1:return[2,{template:n.sent().as(Pi).template}]}})})},e.prototype.getMessageChangelogs=function(e,t,n,r,i){return void 0===i&&(i=a.C.REQUEST_MESSAGE_CHANGELOGS),(0,s._)(this,void 0,void 0,function(){var o,u,c,l,d,h,f,p,m;return(0,s.b)(this,function(_){switch(_.label){case 0:return o=new we((0,s.e)((0,s.u)((0,s.j)((0,s.j)({channelType:t,channelUrl:e,timestamp:"number"==typeof n?n:null,token:"string"==typeof n?n:null},_e),r)))),[4,this._requestQueue.send(o)];case 1:return u=_.sent(),c=u.as(Te),l=c.updatedMessages,d=c.deletedMessagesInfo,h=c.hasMore,f=c.nextToken,p=c.forceUseNextToken,m=d.map(function(e){return e.messageId}),l.length>0&&this._dispatcher.dispatch(new a.M({messages:l,source:i})),m.length>0&&this._dispatcher.dispatch(new a.j({messageIds:m,source:i})),[2,{updatedMessages:l,deletedMessageIds:m,hasMore:h,token:f,forceUseNextToken:p}]}})})},e}(),xi=function(e){function t(t,n){var r=e.call(this,t)||this;r.targetMessageId=0;var i=n.thread_info,a=n.parent_message_id,o=n.channel_url,u=n.channel_type;return i&&(0,s.a)("object",i)&&(0,s.a)("number",a)&&(0,s.a)("string",o)&&(0,s.a)("string",u)&&(r.threadInfo=new l(t,i),r.targetMessageId=a,r.channelUrl=o,r.channelType=u),r}return(0,s.c)(t,e),t}(s.ak),Li={channelUrl:"",channelType:s.C.BASE,messageId:0,includeReactions:!1,includeMetaArray:!1,includeParentMessageInfo:!1,includeThreadInfo:!1},Fi=function(e){function t(t){var n=t.channelCustomType,r=t.keyword,i=t.limit,a=t.reverse,o=t.exactMatch,u=t.channelUrl,c=t.order,l=t.messageTimestampFrom,d=t.messageTimestampTo,h=t.advancedQuery,f=t.targetFields,p=t.nextToken,m=e.call(this)||this;return m.method=s.A.GET,m.path="".concat(s.aR,"/messages"),m.params=(0,s.e)({custom_type:n,query:r,limit:i,reverse:a,exact_match:o,channel_url:u,message_ts_from:l,message_ts_to:d,sort_field:c,advanced_query:h,target_fields:f,after:p}),m}return(0,s.c)(t,e),t}(s.f),qi=function(e){function t(t,n){var r=e.call(this,t,n)||this;return r.messages=n.results.map(function(e){return re(t,e)}),r.hasNext=n.has_next,r.nextToken=n.end_cursor,r.totalCount=n.total_count,r}return(0,s.c)(t,e),t}(s.g);!function(e){e.SCORE="score",e.TIMESTAMP="ts"}(di||(di={}));var ji=function(e){function t(t,n){var r,i,s,a,o,u,c,l,d,h=this;
1return(h=e.call(this,t,n)||this).keyword="",h.reverse=!1,h.exactMatch=!1,h.channelUrl=null,h.channelCustomType=null,h.messageTimestampFrom=null,h.messageTimestampTo=null,h.order=di.SCORE,h.advancedQuery=!1,h.targetFields=null,h._nextToken="",h.totalCount=-1,h.keyword=n.keyword,h.reverse=null!==(r=n.reverse)&&void 0!==r&&r,h.exactMatch=null!==(i=n.exactMatch)&&void 0!==i&&i,h.channelUrl=null!==(s=n.channelUrl)&&void 0!==s?s:null,h.channelCustomType=null!==(a=n.channelCustomType)&&void 0!==a?a:null,h.messageTimestampFrom=null!==(o=n.messageTimestampFrom)&&void 0!==o?o:null,h.messageTimestampTo=null!==(u=n.messageTimestampTo)&&void 0!==u?u:null,h.order=null!==(c=n.order)&&void 0!==c?c:di.SCORE,h.advancedQuery=null!==(l=n.advancedQuery)&&void 0!==l&&l,h.targetFields=null!==(d=n.targetFields)&&void 0!==d?d:null,h}return(0,s.c)(t,e),t.prototype._validate=function(){return e.prototype._validate.call(this)&&(0,s.a)("string",this.keyword)&&this.keyword.length>0&&(0,s.a)("boolean",this.reverse)&&(0,s.a)("boolean",this.exactMatch)&&(0,s.a)("string",this.channelUrl,!0)&&(0,s.a)("string",this.channelCustomType,!0)&&(0,s.a)("number",this.messageTimestampFrom,!0)&&(0,s.a)("number",this.messageTimestampTo,!0)&&(0,s.a2)(di,this.order)&&(0,s.a)("boolean",this.advancedQuery)&&(0,s.$)("string",this.targetFields,!0)},t.prototype.next=function(){return(0,s._)(this,void 0,void 0,function(){var e,t,n,r,i,a,o,u;return(0,s.b)(this,function(c){switch(c.label){case 0:return this._validate()?this._isLoading?[3,3]:this._hasNext?(this._isLoading=!0,e=s.V.of(this._iid).requestQueue,t=new Fi((0,s.u)((0,s.j)((0,s.j)({},this),{nextToken:this._nextToken?this._nextToken:null}))),[4,e.send(t)]):[3,2]:[3,5];case 1:return n=c.sent(),r=n.as(qi),i=r.messages,a=r.hasNext,o=r.nextToken,u=r.totalCount,this._nextToken=o,this._hasNext=a,this._isLoading=!1,this.totalCount=u,[2,i];case 2:return[2,[]];case 3:throw s.t.queryInProgress;case 4:return[3,6];case 5:throw s.t.invalidParameters;case 6:return[2]}})})},t}(s.aM),zi=function(e){function t(t){var n=t.channelType,r=t.channelUrl,i=t.limit,a=t.token,o=e.call(this)||this;return o.method=s.A.GET,o.path="".concat((0,s.aq)(n),"/").concat(encodeURIComponent(r),"/messages/parent_thread_message"),o.params=(0,s.e)((0,s.u)({limit:i,token:a})),o}return(0,s.c)(t,e),t}(s.f),Vi=function(e){function t(t,n){var r=e.call(this,t,n)||this;return r.token=n.next,r.messages=n.messages.map(function(e){return re(t,e)}),r}return(0,s.c)(t,e),t}(s.g),Bi=function(e){function t(t,n,r,i){var s=e.call(this,t,n,r,i)||this;return s._edge="",s}return(0,s.c)(t,e),t.prototype._validate=function(){return e.prototype._validate.call(this)},t.prototype.load=function(){return(0,s._)(this,void 0,void 0,function(){var e,t,n,r,i,a;return(0,s.b)(this,function(o){switch(o.label){case 0:return this._validate()?this._isLoading?[3,3]:this._hasNext?(this._isLoading=!0,e=s.V.of(this._iid).requestQueue,t=new zi({channelType:this.channelType,channelUrl:this.channelUrl,token:this._edge,limit:this.limit}),[4,e.send(t)]):[3,2]:[3,5];case 1:return n=o.sent(),r=n.as(Vi),i=r.messages,a=r.token,this._edge=a,this._hasNext=!!a,this._isLoading=!1,[2,i];case 2:return[2,[]];case 3:throw s.t.queryInProgress;case 4:return[3,6];case 5:throw s.t.invalidParameters;case 6:return[2]}})})},t}(a.c),Ki={channelUrl:"",scheduledMessageId:0},Qi={reverse:!1,limit:20},Gi=function(e){function t(){var t=null!==e&&e.apply(this,arguments)||this;return t.name="message",t}return(0,s.c)(t,e),t.prototype.init=function(t,n){var r=n.sdkState,i=n.dispatcher,s=n.sessionManager,a=n.requestQueue,o=n.logger,u=n.onlineDetector,c=n.cacheContext;e.prototype.init.call(this,t,{sdkState:r,dispatcher:i,sessionManager:s,requestQueue:a,logger:o,onlineDetector:u,cacheContext:c}),this._manager=new Di(t,{sdkState:r,dispatcher:i,requestQueue:a,onlineDetector:u,cacheContext:c})},t.prototype.buildMessageFromSerializedData=function(e){return this._manager.buildMessageFromSerializedData(e)},t.prototype.buildSenderFromSerializedData=function(e){return this._manager.buildSenderFromSerializedData(e)},t.prototype.getMessage=function(e){return(0,s._)(this,void 0,void 0,function(){var t,n;return(0,s.b)(this,function(r){switch(r.label){case 0:return t=(0,s.j)((0,s.j)({},Li),e),(0,s.F)(function(e){return(0,s.a)("string",e.channelUrl)&&(0,s.a2)(s.C,e.channelType)&&(0,s.a)("number",e.messageId)&&(0,s.a)("boolean",e.includeReactions,!0)&&(0,s.a)("boolean",e.includeMetaArray,!0)&&(0,s.a)("boolean",e.includeParentMessageInfo,!0)&&(0,s.a)("boolean",e.includeThreadInfo,!0)}(t)).throw(s.t.invalidParameters),[4,this._manager.getMessage(t)];case 1:if((n=r.sent())instanceof Q||n instanceof te||null===n)return[2,n];throw"Unknown message type is given."}})})},t.prototype.getScheduledMessage=function(e){return(0,s._)(this,void 0,void 0,function(){var t;return(0,s.b)(this,function(n){return t=(0,s.j)((0,s.j)({},Ki),e),(0,s.F)(function(e){return(0,s.a)("string",e.channelUrl)&&""!==e.channelUrl&&(0,s.a)("number",e.scheduledMessageId)&&e.scheduledMessageId>0}(t)).throw(s.t.invalidParameters),[2,this._manager.getScheduledMessage(t)]})})},t.prototype.getMessageTemplatesByToken=function(e,t){return void 0===t&&(t={}),(0,s._)(this,void 0,void 0,function(){var n;return(0,s.b)(this,function(r){return n=(0,s.j)((0,s.j)({},Qi),t),(0,s.F)((0,s.a)("string",e,!0)&&function(e){return(0,s.a)("boolean",e.reverse,!0)&&(0,s.a)("number",e.limit,!0)&&(0,s.$)("string",e.keys,!0)}(n)).throw(s.t.invalidParameters),[2,this._manager.getMessageTemplatesByToken(e,n)]})})},t.prototype.getMessageTemplate=function(e){return(0,s._)(this,void 0,void 0,function(){return(0,s.b)(this,function(t){return(0,s.F)((0,s.a)("string",e)).throw(s.t.invalidParameters),[2,this._manager.getMessageTemplate(e)]})})},t}(s.aS)}}]);
2//# sourceMappingURL=sendbird-bdb4622c-75970923b26000c6ba83.chunk.js.map

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.