852||2===e&&y>592)return 1;for(;;){x=E-T,r[f]+1=p?(I=O[r[f]-p],k=A[r[f]-p]):(I=96,k=0),d=1<>T)+c]=x<<24|I<<16|k|0}while(0!==c);for(d=1<>=1;if(0!==d?(N&=d-1,N+=d):N=0,f++,0==--w[E]){if(E===v)break;E=t[s+r[f]]}if(E>S&&(N&u)!==h){for(0===T&&(T=S),_+=g,m=E-T,C=1<852||2===e&&y>592)return 1;h=N&u,n[h]=S<<24|m<<16|_-o|0}}return 0!==N&&(n[_+N]=E-T<<24|64<<16|0),a.bits=S,0};const{Z_FINISH:Hs,Z_BLOCK:zs,Z_TREES:qs,Z_OK:Vs,Z_STREAM_END:Gs,Z_NEED_DICT:Ks,Z_STREAM_ERROR:Bs,Z_DATA_ERROR:js,Z_MEM_ERROR:$s,Z_BUF_ERROR:Qs,Z_DEFLATED:Ws}=pt,Zs=16180,Ys=16190,Xs=16191,Js=16192,ei=16194,ti=16199,si=16200,ii=16206,ni=16209,oi=e=>(e>>>24&255)+(e>>>8&65280)+((65280&e)<<8)+((255&e)<<24);function ri(){this.strm=null,this.mode=0,this.last=!1,this.wrap=0,this.havedict=!1,this.flags=0,this.dmax=0,this.check=0,this.total=0,this.head=null,this.wbits=0,this.wsize=0,this.whave=0,this.wnext=0,this.window=null,this.hold=0,this.bits=0,this.length=0,this.offset=0,this.extra=0,this.lencode=null,this.distcode=null,this.lenbits=0,this.distbits=0,this.ncode=0,this.nlen=0,this.ndist=0,this.have=0,this.next=null,this.lens=new Uint16Array(320),this.work=new Uint16Array(288),this.lendyn=null,this.distdyn=null,this.sane=0,this.back=0,this.was=0}const ai=e=>{if(!e)return 1;const t=e.state;return!t||t.strm!==e||t.mode16211?1:0},li=e=>{if(ai(e))return Bs;const t=e.state;return e.total_in=e.total_out=t.total=0,e.msg="",t.wrap&&(e.adler=1&t.wrap),t.mode=Zs,t.last=0,t.havedict=0,t.flags=-1,t.dmax=32768,t.head=null,t.hold=0,t.bits=0,t.lencode=t.lendyn=new Int32Array(852),t.distcode=t.distdyn=new Int32Array(592),t.sane=1,t.back=-1,Vs},di=e=>{if(ai(e))return Bs;const t=e.state;return t.wsize=0,t.whave=0,t.wnext=0,li(e)},ci=(e,t)=>{let s;if(ai(e))return Bs;const i=e.state;return t<0?(s=0,t=-t):(s=5+(t>>4),t<48&&(t&=15)),t&&(t<8||t>15)?Bs:(null!==i.window&&i.wbits!==t&&(i.window=null),i.wrap=s,i.wbits=t,di(e))},hi=(e,t)=>{if(!e)return Bs;const s=new ri;e.state=s,s.strm=e,s.window=null,s.mode=Zs;const i=ci(e,t);return i!==Vs&&(e.state=null),i};let ui,_i,pi=!0;const Ei=e=>{if(pi){ui=new Int32Array(512),_i=new Int32Array(32);let t=0;for(;t<144;)e.lens[t++]=8;for(;t<256;)e.lens[t++]=9;for(;t<280;)e.lens[t++]=7;for(;t<288;)e.lens[t++]=8;for(Fs(1,e.lens,0,288,ui,0,e.work,{bits:9}),t=0;t<32;)e.lens[t++]=5;Fs(2,e.lens,0,32,_i,0,e.work,{bits:5}),pi=!1}e.lencode=ui,e.lenbits=9,e.distcode=_i,e.distbits=5},fi=(e,t,s,i)=>{let n;const o=e.state;return null===o.window&&(o.wsize=1<=o.wsize?(o.window.set(t.subarray(s-o.wsize,s),0),o.wnext=0,o.whave=o.wsize):(n=o.wsize-o.wnext,n>i&&(n=i),o.window.set(t.subarray(s-i,s-i+n),o.wnext),(i-=n)?(o.window.set(t.subarray(s-i,s),0),o.wnext=i,o.whave=o.wsize):(o.wnext+=n,o.wnext===o.wsize&&(o.wnext=0),o.whavehi(e,15),inflateInit2:hi,inflate:(e,t)=>{let s,i,n,o,r,a,l,d,c,h,u,_,p,E,f,g,v,S,m,T,C,y,N=0;const A=new Uint8Array(4);let w,b;const x=new Uint8Array([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]);if(ai(e)||!e.output||!e.input&&0!==e.avail_in)return Bs;s=e.state,s.mode===Xs&&(s.mode=Js),r=e.next_out,n=e.output,l=e.avail_out,o=e.next_in,i=e.input,a=e.avail_in,d=s.hold,c=s.bits,h=a,u=l,y=Vs;e:for(;;)switch(s.mode){case Zs:if(0===s.wrap){s.mode=Js;break}for(;c<16;){if(0===a)break e;a--,d+=i[o++]<>>8&255,s.check=ut(s.check,A,2,0),d=0,c=0,s.mode=16181;break}if(s.head&&(s.head.done=!1),!(1&s.wrap)||(((255&d)<<8)+(d>>8))%31){e.msg="incorrect header check",s.mode=ni;break}if((15&d)!==Ws){e.msg="unknown compression method",s.mode=ni;break}if(d>>>=4,c-=4,C=8+(15&d),0===s.wbits&&(s.wbits=C),C>15||C>s.wbits){e.msg="invalid window size",s.mode=ni;break}s.dmax=1<>8&1),512&s.flags&&4&s.wrap&&(A[0]=255&d,A[1]=d>>>8&255,s.check=ut(s.check,A,2,0)),d=0,c=0,s.mode=16182;case 16182:for(;c<32;){if(0===a)break e;a--,d+=i[o++]<>>8&255,A[2]=d>>>16&255,A[3]=d>>>24&255,s.check=ut(s.check,A,4,0)),d=0,c=0,s.mode=16183;case 16183:for(;c<16;){if(0===a)break e;a--,d+=i[o++]<>8),512&s.flags&&4&s.wrap&&(A[0]=255&d,A[1]=d>>>8&255,s.check=ut(s.check,A,2,0)),d=0,c=0,s.mode=16184;case 16184:if(1024&s.flags){for(;c<16;){if(0===a)break e;a--,d+=i[o++]<>>8&255,s.check=ut(s.check,A,2,0)),d=0,c=0}else s.head&&(s.head.extra=null);s.mode=16185;case 16185:if(1024&s.flags&&(_=s.length,_>a&&(_=a),_&&(s.head&&(C=s.head.extra_len-s.length,s.head.extra||(s.head.extra=new Uint8Array(s.head.extra_len)),s.head.extra.set(i.subarray(o,o+_),C)),512&s.flags&&4&s.wrap&&(s.check=ut(s.check,i,_,o)),a-=_,o+=_,s.length-=_),s.length))break e;s.length=0,s.mode=16186;case 16186:if(2048&s.flags){if(0===a)break e;_=0;do{C=i[o+_++],s.head&&C&&s.length<65536&&(s.head.name+=String.fromCharCode(C))}while(C&&_>9&1,s.head.done=!0),e.adler=s.check=0,s.mode=Xs;break;case 16189:for(;c<32;){if(0===a)break e;a--,d+=i[o++]<>>=7&c,c-=7&c,s.mode=ii;break}for(;c<3;){if(0===a)break e;a--,d+=i[o++]<>>=1,c-=1,3&d){case 0:s.mode=16193;break;case 1:if(Ei(s),s.mode=ti,t===qs){d>>>=2,c-=2;break e}break;case 2:s.mode=16196;break;case 3:e.msg="invalid block type",s.mode=ni}d>>>=2,c-=2;break;case 16193:for(d>>>=7&c,c-=7&c;c<32;){if(0===a)break e;a--,d+=i[o++]<>>16^65535)){e.msg="invalid stored block lengths",s.mode=ni;break}if(s.length=65535&d,d=0,c=0,s.mode=ei,t===qs)break e;case ei:s.mode=16195;case 16195:if(_=s.length,_){if(_>a&&(_=a),_>l&&(_=l),0===_)break e;n.set(i.subarray(o,o+_),r),a-=_,o+=_,l-=_,r+=_,s.length-=_;break}s.mode=Xs;break;case 16196:for(;c<14;){if(0===a)break e;a--,d+=i[o++]<>>=5,c-=5,s.ndist=1+(31&d),d>>>=5,c-=5,s.ncode=4+(15&d),d>>>=4,c-=4,s.nlen>286||s.ndist>30){e.msg="too many length or distance symbols",s.mode=ni;break}s.have=0,s.mode=16197;case 16197:for(;s.have>>=3,c-=3}for(;s.have<19;)s.lens[x[s.have++]]=0;if(s.lencode=s.lendyn,s.lenbits=7,w={bits:s.lenbits},y=Fs(0,s.lens,0,19,s.lencode,0,s.work,w),s.lenbits=w.bits,y){e.msg="invalid code lengths set",s.mode=ni;break}s.have=0,s.mode=16198;case 16198:for(;s.have>>24,g=N>>>16&255,v=65535&N,!(f<=c);){if(0===a)break e;a--,d+=i[o++]<>>=f,c-=f,s.lens[s.have++]=v;else{if(16===v){for(b=f+2;c>>=f,c-=f,0===s.have){e.msg="invalid bit length repeat",s.mode=ni;break}C=s.lens[s.have-1],_=3+(3&d),d>>>=2,c-=2}else if(17===v){for(b=f+3;c>>=f,c-=f,C=0,_=3+(7&d),d>>>=3,c-=3}else{for(b=f+7;c>>=f,c-=f,C=0,_=11+(127&d),d>>>=7,c-=7}if(s.have+_>s.nlen+s.ndist){e.msg="invalid bit length repeat",s.mode=ni;break}for(;_--;)s.lens[s.have++]=C}}if(s.mode===ni)break;if(0===s.lens[256]){e.msg="invalid code -- missing end-of-block",s.mode=ni;break}if(s.lenbits=9,w={bits:s.lenbits},y=Fs(1,s.lens,0,s.nlen,s.lencode,0,s.work,w),s.lenbits=w.bits,y){e.msg="invalid literal/lengths set",s.mode=ni;break}if(s.distbits=6,s.distcode=s.distdyn,w={bits:s.distbits},y=Fs(2,s.lens,s.nlen,s.ndist,s.distcode,0,s.work,w),s.distbits=w.bits,y){e.msg="invalid distances set",s.mode=ni;break}if(s.mode=ti,t===qs)break e;case ti:s.mode=si;case si:if(a>=6&&l>=258){e.next_out=r,e.avail_out=l,e.next_in=o,e.avail_in=a,s.hold=d,s.bits=c,Rs(e,u),r=e.next_out,n=e.output,l=e.avail_out,o=e.next_in,i=e.input,a=e.avail_in,d=s.hold,c=s.bits,s.mode===Xs&&(s.back=-1);break}for(s.back=0;N=s.lencode[d&(1<>>24,g=N>>>16&255,v=65535&N,!(f<=c);){if(0===a)break e;a--,d+=i[o++]<>S)],f=N>>>24,g=N>>>16&255,v=65535&N,!(S+f<=c);){if(0===a)break e;a--,d+=i[o++]<>>=S,c-=S,s.back+=S}if(d>>>=f,c-=f,s.back+=f,s.length=v,0===g){s.mode=16205;break}if(32&g){s.back=-1,s.mode=Xs;break}if(64&g){e.msg="invalid literal/length code",s.mode=ni;break}s.extra=15&g,s.mode=16201;case 16201:if(s.extra){for(b=s.extra;c>>=s.extra,c-=s.extra,s.back+=s.extra}s.was=s.length,s.mode=16202;case 16202:for(;N=s.distcode[d&(1<>>24,g=N>>>16&255,v=65535&N,!(f<=c);){if(0===a)break e;a--,d+=i[o++]<>S)],f=N>>>24,g=N>>>16&255,v=65535&N,!(S+f<=c);){if(0===a)break e;a--,d+=i[o++]<>>=S,c-=S,s.back+=S}if(d>>>=f,c-=f,s.back+=f,64&g){e.msg="invalid distance code",s.mode=ni;break}s.offset=v,s.extra=15&g,s.mode=16203;case 16203:if(s.extra){for(b=s.extra;c>>=s.extra,c-=s.extra,s.back+=s.extra}if(s.offset>s.dmax){e.msg="invalid distance too far back",s.mode=ni;break}s.mode=16204;case 16204:if(0===l)break e;if(_=u-l,s.offset>_){if(_=s.offset-_,_>s.whave&&s.sane){e.msg="invalid distance too far back",s.mode=ni;break}_>s.wnext?(_-=s.wnext,p=s.wsize-_):p=s.wnext-_,_>s.length&&(_=s.length),E=s.window}else E=n,p=r-s.offset,_=s.length;_>l&&(_=l),l-=_,s.length-=_;do{n[r++]=E[p++]}while(--_);0===s.length&&(s.mode=si);break;case 16205:if(0===l)break e;n[r++]=s.length,l--,s.mode=si;break;case ii:if(s.wrap){for(;c<32;){if(0===a)break e;a--,d|=i[o++]<{if(ai(e))return Bs;let t=e.state;return t.window&&(t.window=null),e.state=null,Vs},inflateGetHeader:(e,t)=>{if(ai(e))return Bs;const s=e.state;return 0==(2&s.wrap)?Bs:(s.head=t,t.done=!1,Vs)},inflateSetDictionary:(e,t)=>{const s=t.length;let i,n,o;return ai(e)?Bs:(i=e.state,0!==i.wrap&&i.mode!==Ys?Bs:i.mode===Ys&&(n=1,n=ct(n,t,s,0),n!==i.check)?js:(o=fi(e,t,s,s),o?(i.mode=16210,$s):(i.havedict=1,Vs)))},inflateInfo:"pako inflate (from Nodeca project)"};var vi=function(){this.text=0,this.time=0,this.xflags=0,this.os=0,this.extra=null,this.extra_len=0,this.name="",this.comment="",this.hcrc=0,this.done=!1};const Si=Object.prototype.toString,{Z_NO_FLUSH:mi,Z_FINISH:Ti,Z_OK:Ci,Z_STREAM_END:yi,Z_NEED_DICT:Ni,Z_STREAM_ERROR:Ai,Z_DATA_ERROR:wi,Z_MEM_ERROR:bi}=pt;function xi(e){this.options=_s.assign({chunkSize:65536,windowBits:15,to:""},e||{});const t=this.options;t.raw&&t.windowBits>=0&&t.windowBits<16&&(t.windowBits=-t.windowBits,0===t.windowBits&&(t.windowBits=-15)),!(t.windowBits>=0&&t.windowBits<16)||e&&e.windowBits||(t.windowBits+=32),t.windowBits>15&&t.windowBits<48&&0==(15&t.windowBits)&&(t.windowBits|=15),this.err=0,this.msg="",this.ended=!1,this.chunks=[],this.strm=new gs,this.strm.avail_out=0;let s=gi.inflateInit2(this.strm,t.windowBits);if(s!==Ci)throw new Error(_t[s]);if(this.header=new vi,gi.inflateGetHeader(this.strm,this.header),t.dictionary&&("string"==typeof t.dictionary?t.dictionary=fs.string2buf(t.dictionary):"[object ArrayBuffer]"===Si.call(t.dictionary)&&(t.dictionary=new Uint8Array(t.dictionary)),t.raw&&(s=gi.inflateSetDictionary(this.strm,t.dictionary),s!==Ci)))throw new Error(_t[s])}function Ii(e,t){const s=new xi(t);if(s.push(e),s.err)throw s.msg||_t[s.err];return s.result}xi.prototype.push=function(e,t){const s=this.strm,i=this.options.chunkSize,n=this.options.dictionary;let o,r,a;if(this.ended)return!1;for(r=t===~~t?t:!0===t?Ti:mi,"[object ArrayBuffer]"===Si.call(e)?s.input=new Uint8Array(e):s.input=e,s.next_in=0,s.avail_in=s.input.length;;){for(0===s.avail_out&&(s.output=new Uint8Array(i),s.next_out=0,s.avail_out=i),o=gi.inflate(s,r),o===Ni&&n&&(o=gi.inflateSetDictionary(s,n),o===Ci?o=gi.inflate(s,r):o===wi&&(o=Ni));s.avail_in>0&&o===yi&&s.state.wrap>0&&0!==e[s.next_in];)gi.inflateReset(s),o=gi.inflate(s,r);switch(o){case Ai:case wi:case Ni:case bi:return this.onEnd(o),this.ended=!0,!1}if(a=s.avail_out,s.next_out&&(0===s.avail_out||o===yi))if("string"===this.options.to){let e=fs.utf8border(s.output,s.next_out),t=s.next_out-e,n=fs.buf2string(s.output,e);s.next_out=t,s.avail_out=i-t,t&&s.output.set(s.output.subarray(e,e+t),0),this.onData(n)}else this.onData(s.output.length===s.next_out?s.output:s.output.subarray(0,s.next_out));if(o!==Ci||0!==a){if(o===yi)return o=gi.inflateEnd(this.strm),this.onEnd(o),this.ended=!0,!0;if(0===s.avail_in)break}}return!0},xi.prototype.onData=function(e){this.chunks.push(e)},xi.prototype.onEnd=function(e){e===Ci&&("string"===this.options.to?this.result=this.chunks.join(""):this.result=_s.flattenChunks(this.chunks)),this.chunks=[],this.err=e,this.msg=this.strm.msg};var ki={Inflate:xi,inflate:Ii,inflateRaw:function(e,t){return(t=t||{}).raw=!0,Ii(e,t)},ungzip:Ii,constants:pt};const{Deflate:Oi,deflate:Ri,deflateRaw:Di,gzip:Li}=ks,{Inflate:Ui,inflate:Pi,inflateRaw:Mi,ungzip:Fi}=ki;var Hi={Deflate:Oi,deflate:Ri,deflateRaw:Di,gzip:Li,Inflate:Ui,inflate:Pi,inflateRaw:Mi,ungzip:Fi,constants:pt};var zi,qi;exports.ConnectionState=void 0,(zi=exports.ConnectionState||(exports.ConnectionState={})).CONNECTING="CONNECTING",zi.OPEN="OPEN",zi.CLOSED="CLOSED";class Vi extends b{constructor(e,{sdkState:t,dispatcher:s,logger:i}){super(),this.lastActive=0,this._iid=e,this._sdkState=t,this._dispatcher=s,this._logger=i}get isOpen(){return this.connectionState===exports.ConnectionState.OPEN}get connectionState(){if(this._ws)switch(this._ws.readyState){case 0:return exports.ConnectionState.CONNECTING;case 1:return exports.ConnectionState.OPEN}return exports.ConnectionState.CLOSED}get ws(){var e;return null!==(e=this._ws)&&void 0!==e?e:null}_handleMessage(e){e.split("\n").forEach((e=>{if(e){const t=Ne.createFromRawMessage(this._iid,e);if(this._logger.debug("receive websocket event",t),"LOGI"===t.code)this.dispatch("message",t);else if("PONG"===t.code)this.dispatch("pong");else if("EXPR"===t.code){if(t.payload){const e=new ue(t.payload);e.expiresIn>=0&&this._dispatcher.dispatch(e)}}else"NOOP"===t.code||this.dispatch("message",t)}}))}connect(t,s){this._ws=new WebSocket(t,encodeURIComponent(s)),this._ws.onopen=()=>{this._logger.debug("websocket open"),this.dispatch("open")},this._ws.onmessage=t=>e(this,void 0,void 0,(function*(){var s;if(null===(s=this._sdkState.websocket)||void 0===s?void 0:s.compression)if(t.data instanceof Blob){const s=new FileReader;s.readAsArrayBuffer(t.data),s.onloadend=()=>e(this,void 0,void 0,(function*(){const t=yield(i=s.result,e(void 0,void 0,void 0,(function*(){const e=Hi.ungzip(i);return String.fromCharCode.apply(null,e)})));var i;this._handleMessage(t)}))}else"string"==typeof t.data&&this._handleMessage(t.data);else this._handleMessage(t.data)})),this._ws.onerror=()=>{this._logger.debug("websocket error"),this.dispatch("error",o.networkError)},this._ws.onclose=()=>{this._logger.debug("websocket close"),this.dispatch("close")},this.lastActive=Date.now()}disconnect(){return new Promise((e=>{this._logger.debug("websocket disconnect"),this._ws&&this.connectionState!==exports.ConnectionState.CLOSED?(this._ws.onopen=Ae,this._ws.onmessage=Ae,this._ws.onerror=Ae,this._ws.onclose=()=>{this.dispatch("close"),e()},this._ws.close(),this._ws=void 0):e()}))}send(e){if(!this._ws)throw o.connectionClosed;"PING"!==e.code?this.dispatch("ping-refresh"):this._logger.debug("send ping",e),this._ws.send(e.convertToMessage())}error(e){this._logger.debug("websocket error",e),this.dispatch("error",e)}}class Gi extends I{constructor({code:e,ackRequired:t,payload:s={}}){var i;super(),this.code=e,this.payload=s,this.requestId=null!==(i=this.payload.req_id)&&void 0!==i?i:A(),this.ackRequired=t,this.payload.req_id=this.requestId}convertToMessage(){return`${this.code}${JSON.stringify(this.payload)}\n`}}class Ki extends I{constructor({all:e,feed:t,custom_types:s,ts:i}){super(),this.all=e,this.feed=t,this.customTypes=s,this.ts=i}}class Bi{constructor(e,{session:t,sdkState:s,dispatcher:i,logger:n,useFetchCompat:r=!1}){this._ackStateMap=new Map,this._sdkState=s,this._dispatcher=i,this._logger=n,this.apiClient=new ye(e,{session:t,sdkState:s,dispatcher:i,logger:n,useFetchCompat:r}),this.websocketClient=new Vi(e,{sdkState:s,dispatcher:i,logger:n}),this.websocketClient.on("message",(e=>{if(e.payload.unread_cnt&&this._dispatcher.dispatch(new Ki(e.payload.unread_cnt)),e.requestId){if(this._ackStateMap.has(e.requestId)){const t=this._ackStateMap.get(e.requestId);"EROR"!==e.code?t.resolve(e):t.reject(new o({code:e.payload.code,message:e.payload.message}))}}else this._dispatcher.dispatch(e)})).on("close",(()=>{this._ackStateMap.forEach((e=>{e.reject(o.connectionClosed)})),this._ackStateMap.clear()}))}_sendApiRequest(t){return e(this,void 0,void 0,(function*(){return yield this.apiClient.send(t)}))}_sendWebsocketRequest(t){return e(this,void 0,void 0,(function*(){if(!this._sdkState.websocket)throw o.connectionRequired;const e=new Ce;if(t.ackRequired){let s;const i=(i,n)=>{this._ackStateMap.has(t.requestId)&&(this._ackStateMap.delete(t.requestId),s&&(clearTimeout(s),s=null),i?(this._logger.debug("fail websocket request",i),e.reject(i)):(this._logger.debug("receive websocket ack",t.requestId),e.resolve(n)))};try{s=setTimeout((()=>i(o.noAckTimeout)),this._sdkState.websocket.responseTimeout),this._ackStateMap.set(t.requestId,{resolve:e=>i(void 0,e),reject:e=>i(e)}),this.websocketClient.send(t)}catch(e){i(e)}}else try{this.websocketClient.send(t),e.resolve()}catch(t){e.reject(t)}return e.promise}))}send(t){return e(this,void 0,void 0,(function*(){if(t instanceof de)return yield this._sendApiRequest(t);if(t instanceof Gi)return yield this._sendWebsocketRequest(t);throw o.invalidParameters}))}cancel(e){this.apiClient.cancel(e)}cancelAll(){this.apiClient.cancelAll()}}exports.ConnectionStateType=void 0,(qi=exports.ConnectionStateType||(exports.ConnectionStateType={}))[qi.NONE=0]="NONE",qi[qi.INITIALIZED=1]="INITIALIZED",qi[qi.CONNECTING=2]="CONNECTING",qi[qi.CONNECTED=3]="CONNECTED",qi[qi.RECONNECTING=4]="RECONNECTING",qi[qi.INTERNAL_DISCONNECTED=5]="INTERNAL_DISCONNECTED",qi[qi.EXTERNAL_DISCONNECTED=6]="EXTERNAL_DISCONNECTED",qi[qi.LOGOUT=7]="LOGOUT";class ji extends I{constructor({stateType:e}){super(),this.stateType=e}}class $i extends I{}class Qi extends I{}class Wi extends I{}class Zi extends de{constructor({userId:e,authToken:t,services:s=[exports.SessionService.CHAT],expiringSession:i=!0}){super(),this.path=`${G}/${e}/session_key`,this.method=exports.APIRequestMethod.POST,this.params=k({token:t,services:s,expiring_session:!!i}),this.requireAuth=!1}}class Yi extends Gi{constructor({authToken:e,expiringSession:t=!0,requestId:s=""}){super({code:"LOGI",payload:{token:e,expiring_session:t?1:0,req_id:s},ackRequired:!0})}}class Xi extends ce{constructor(e,t){super(e,t);const{key:s,expires_at:i,services:n}=t;this.key=s,this.expiresAt=i,this.services=n}}class Ji extends Ne{constructor(e,t,s){var i;super(e,"LOGI",s),this.error=null,this.newKey=null,this.newKey=null!==(i=s.new_key)&&void 0!==i?i:null,this.error=s.error?new o(s.error):null}}class en{constructor(e){var t,s,i,n;this.isEnabled=null!==(t=e.enabled)&&void 0!==t&&t,this.feedChannels=null!==(s=e.feed_channels)&&void 0!==s?s:{},this.templateListToken=null!==(i=e.template_list_token)&&void 0!==i?i:null,this.settingsUpdatedAt=null!==(n=e.settings_updated_at)&&void 0!==n?n:0}static payloadify(e){return k(O({enabled:e.isEnabled,feed_channels:e.feedChannels,template_list_token:e.templateListToken,settings_updated_at:e.settingsUpdatedAt}))}}class tn{constructor(e){var t;this.lastUpdatedAt=null!==(t=e.last_updated_at)&&void 0!==t?t:0}static payloadify(e){return k(O({last_updated_at:e.lastUpdatedAt}))}}const sn=1048576;class nn{constructor(e={}){var t,s,i,n,o;this.emojiHash=e.emoji_hash||"",this.uploadSizeLimit=e.file_upload_size_limit?e.file_upload_size_limit*sn:Number.MAX_SAFE_INTEGER,this.useReaction=!!e.use_reaction,this.applicationAttributes=null!==(t=e.application_attributes)&&void 0!==t?t:[],this.premiumFeatureList=null!==(s=e.premium_feature_list)&&void 0!==s?s:[],this.deviceTokenCache=this.applicationAttributes.includes("sdk_device_token_cache"),this.enabledChannelMemberShipHistory=this.applicationAttributes.includes("channel_membership_history"),this.multipleFilesMessageFileCountLimit=null!==(i=e.multiple_file_send_max_size)&&void 0!==i?i:5,this.allowSdkStatsUpload=null===(n=e.allow_sdk_log_ingestion)||void 0===n||n,this.uikitConfigInfo=new tn(null!==(o=e.uikit_config)&&void 0!==o?o:{}),this.notificationInfo=e.notifications?new en(e.notifications):null}static payloadify(e){return k(O({emoji_hash:e.emojiHash,file_upload_size_limit:e.uploadSizeLimit/sn,application_attributes:e.applicationAttributes,premium_feature_list:e.premiumFeatureList,use_reaction:e.useReaction,allow_sdk_log_ingestion:e.allowSdkStatsUpload,uikit_config:e.uikitConfigInfo?tn.payloadify(e.uikitConfigInfo):null,notifications:e.notificationInfo?en.payloadify(e.notificationInfo):null}))}}class on{constructor(e){this._iid="",this._iid=e}static payloadify(e){return{}}}class rn extends de{constructor({userId:e,metadata:t}){super(),this.method=exports.APIRequestMethod.POST,this.path=`${G}/${e}/metadata`,this.params={metadata:t}}}class an extends ce{constructor(e,t){super(e,t),this.metaData=t}}class ln extends de{constructor({userId:e,metadata:t,upsert:s}){super(),this.method=exports.APIRequestMethod.PUT,this.path=`${G}/${e}/metadata`,this.params={metadata:t,upsert:s}}}class dn extends ce{constructor(e,t){super(e,t),this.metadata=t}}class cn extends de{constructor({userId:e,metadataKey:t}){super(),this.method=exports.APIRequestMethod.DELETE,this.path=`${G}/${e}/metadata/${t}`}}class hn extends de{constructor({userId:e}){super(),this.method=exports.APIRequestMethod.DELETE,this.path=`${G}/${e}/metadata`}}const un=(e,t)=>{const s=JSON.parse(JSON.stringify(e));return s._iid&&delete s._iid,t&&t(s),s},_n=(e,t)=>{const s=JSON.parse(JSON.stringify(e));return t&&t(s),s},pn=e=>({do:t=>{e||t()},throw:t=>{if(!e)throw t}});var En;exports.UserOnlineState=void 0,(En=exports.UserOnlineState||(exports.UserOnlineState={})).ONLINE="online",En.OFFLINE="offline",En.NON_AVAILABLE="nonavailable";class fn extends on{constructor(e,t){var s,i,n,o,r,a,c,h,u,_,p,E;super(e),this.userId=null!==(i=null!==(s=t.guest_id)&&void 0!==s?s:t.user_id)&&void 0!==i?i:"",this.nickname=null!==(o=null!==(n=t.nickname)&&void 0!==n?n:t.name)&&void 0!==o?o:"",this.plainProfileUrl=null!==(a=null!==(r=t.profile_url)&&void 0!==r?r:t.image)&&void 0!==a?a:"",this.requireAuth=null!==(c=t.require_auth_for_profile_image)&&void 0!==c&&c,this.metaData=null!==(h=t.metadata)&&void 0!==h?h:{},this.connectionStatus=exports.UserOnlineState.NON_AVAILABLE,d(exports.UserOnlineState,t.is_online)?this.connectionStatus=t.is_online:l("boolean",t.is_online)&&(this.connectionStatus=t.is_online?exports.UserOnlineState.ONLINE:exports.UserOnlineState.OFFLINE),this.isActive=null===(u=t.is_active)||void 0===u||u,this.lastSeenAt=null!==(_=t.last_seen_at)&&void 0!==_?_:null,this.preferredLanguages=t.preferred_languages?[...t.preferred_languages]:null,this.friendDiscoveryKey=null!==(p=t.friend_discovery_key)&&void 0!==p?p:null,this.friendName=null!==(E=t.friend_name)&&void 0!==E?E:null}static payloadify(e){return k(O(Object.assign(Object.assign({},super.payloadify(e)),{user_id:e.userId,nickname:e.nickname,profile_url:e.plainProfileUrl,require_auth_for_profile_image:e.requireAuth,metadata:e.metaData,is_online:e.connectionStatus,is_active:e.isActive,last_seen_at:e.lastSeenAt,preferred_languages:e.preferredLanguages,friend_discovery_key:e.friendDiscoveryKey,friend_name:e.friendName})))}get profileUrl(){const{sessionManager:e}=to.of(this._iid);return this.requireAuth?`${this.plainProfileUrl}?auth=${e.ekey}`:this.plainProfileUrl}serialize(){return un(this)}_isValidMetaData(e){return!Array.isArray(e)&&Object.keys(e).length>0&&Object.keys(e).map((t=>e[t])).every((e=>l("string",e)))}_applyMetaData(e,t=!1){Object.keys(e).forEach((s=>{t?delete this.metaData[s]:this.metaData[s]=e[s]}))}createMetaData(t){return e(this,void 0,void 0,(function*(){pn(this._isValidMetaData(t)).throw(o.invalidParameters);const{sdkState:e,requestQueue:s}=to.of(this._iid),i=new rn({userId:e.userId,metadata:t}),n=yield s.send(i),{metaData:r}=n.as(an);return this._applyMetaData(r),this.metaData}))}updateMetaData(t,s=!1){return e(this,void 0,void 0,(function*(){pn(this._isValidMetaData(t)).throw(o.invalidParameters);const{sdkState:e,requestQueue:i}=to.of(this._iid),n=new ln({userId:e.userId,metadata:t,upsert:s}),r=yield i.send(n),{metadata:a}=r.as(dn);return this._applyMetaData(a),this.metaData}))}deleteMetaData(t){return e(this,void 0,void 0,(function*(){pn(l("string",t)).throw(o.invalidParameters);const{sdkState:e,requestQueue:s}=to.of(this._iid),i=new cn({userId:e.userId,metadataKey:t});return yield s.send(i),this._applyMetaData({[t]:!0},!0),this.metaData}))}deleteAllMetaData(){return e(this,void 0,void 0,(function*(){const{sdkState:e,requestQueue:t}=to.of(this._iid),s=new hn({userId:e.userId});yield t.send(s),this.metaData={}}))}}class gn extends I{constructor({userProfile:e}){super(),this.userProfile=e}}class vn{constructor(e,t){var s,i,n,o,r,a,l,d,c,h,u,_,p,E;this._iid=e,this.appInfo=new nn(t),this.user=new fn(e,t),this.connectedAt=null!==(s=t.login_ts)&&void 0!==s?s:0,this.firstConnectedAt=0,this.pingInterval=null!==(i=t.ping_interval)&&void 0!==i?i:15e3,this.pongTimeout=null!==(n=t.pong_timeout)&&void 0!==n?n:5e3,this.reconnectInterval=null!==(r=null===(o=t.reconnect)||void 0===o?void 0:o.interval)&&void 0!==r?r:3e3,this.reconnectMaxInterval=null!==(l=null===(a=t.reconnect)||void 0===a?void 0:a.max_interval)&&void 0!==l?l:6e4,this.reconnectRetryCount=null!==(c=null===(d=t.reconnect)||void 0===d?void 0:d.retry_cnt)&&void 0!==c?c:5,this.reconnectIntervalMultiple=null!==(u=null===(h=t.reconnect)||void 0===h?void 0:h.mul)&&void 0!==u?u:2,this.maxUnreadCountOnSuperGroup=null!==(_=t.max_unread_cnt_on_super_group)&&void 0!==_?_:100,this.profileImageEncryption=!!t.profile_image_encryption,this.concurrentCallLimit=null!==(p=t.concurrent_call_limit)&&void 0!==p?p:5,this.backOffDelay=null!==(E=t.back_off_delay)&&void 0!==E?E:100}static payloadify(e){return k(O(Object.assign(Object.assign(Object.assign({},fn.payloadify(e.user)),nn.payloadify(e.appInfo)),{login_ts:e.connectedAt,ping_interval:e.pingInterval,pong_timeout:e.pongTimeout,reconnect:{interval:e.reconnectInterval,max_interval:e.reconnectMaxInterval,retry_cnt:e.reconnectRetryCount,mul:e.reconnectIntervalMultiple},max_unread_cnt_on_super_group:e.maxUnreadCountOnSuperGroup,profile_image_encryption:e.profileImageEncryption,concurrent_call_limit:e.concurrentCallLimit,back_off_delay:e.backOffDelay})))}apply(){const e=this.reconnectInterval,t=this.reconnectMaxInterval,s=this.reconnectIntervalMultiple,i=to.of(this._iid);i.sdkState.websocket&&(i.sdkState.websocket.pingInterval=1e3*this.pingInterval,i.sdkState.websocket.pongTimeout=1e3*this.pongTimeout,i.sdkState.websocket.reconnectMaxRetry=this.reconnectRetryCount,i.sdkState.websocket.reconnectRetryStrategy={calcTimeout:i=>i>0?1e3*Math.min(e*Math.pow(s,i-1),t):10}),i.appInfo=this.appInfo,i.sessionManager.currentUser=this.user,i.connectedAt=this.connectedAt,this.firstConnectedAt||(i.firstConnectedAt=this.connectedAt),i.maxSuperGroupChannelUnreadCount=this.maxUnreadCountOnSuperGroup,i.concurrentCallLimit=this.concurrentCallLimit,i.backOffDelay=this.backOffDelay,i.dispatcher.dispatch(new gn({userProfile:this}))}}class Sn extends Ne{constructor(e,t,s){var i,n,r,a;super(e,t,s),this.error=null,this.services=[],this.userProfile=new vn(e,s),this.deviceTokenLastDeletedAt=null!==(i=s.device_token_last_deleted_at)&&void 0!==i?i:0,this.key=null!==(n=s.key)&&void 0!==n?n:"",this.ekey=null!==(r=s.ekey)&&void 0!==r?r:"",this.error=s.error?new o(s):null,this.services=null!==(a=s.services)&&void 0!==a?a:[]}static asError(e){return new Sn("","LOGI",Object.assign({user_id:"",error:!0},e))}applyTo(t){return e(this,void 0,void 0,(function*(){if(this.error)throw this.error;{const e=to.of(t);if(!e)throw o.lostInstance;{const{sessionManager:t}=e;yield t.login(this),this.userProfile.apply()}}}))}}class mn{constructor(){this.type=exports.ConnectionStateType.NONE,this.name="none"}run(t){return e(this,void 0,void 0,(function*(){}))}onConnect(t,s){return e(this,void 0,void 0,(function*(){}))}onReconnect(t,{resetReconnectCount:s=!1}){return e(this,void 0,void 0,(function*(){}))}onDisconnect(t,{error:s=null,autoReconnect:i=!1}){return e(this,void 0,void 0,(function*(){}))}onDisconnectWebSocket(t){return e(this,void 0,void 0,(function*(){}))}onLogout(t){return e(this,void 0,void 0,(function*(){}))}}const Tn=t=>e(void 0,void 0,void 0,(function*(){try{yield t()}catch(e){if(!(e instanceof o))throw e;e.throwOutside()}}));class Cn extends mn{constructor(e={}){var t;super(),this.type=exports.ConnectionStateType.LOGOUT,this.name="logout",this._wasPreviouslyConnected=null===(t=e.wasPreviouslyConnected)||void 0===t||t}run(t){return e(this,void 0,void 0,(function*(){const s=Date.now(),i=t.sdkState.userId;yield t.logout(),yield t.changeState(new On,s),this._wasPreviouslyConnected&&Tn((()=>e(this,void 0,void 0,(function*(){t.connectionHandlers.forEach((e=>{e.onDisconnected&&e.onDisconnected(i)}))}))))}))}}class yn extends mn{constructor(){super(),this.type=exports.ConnectionStateType.EXTERNAL_DISCONNECTED,this.name="externaldisconnected"}run(t){return e(this,void 0,void 0,(function*(){yield t.disconnect()}))}onConnect(t,s){return e(this,void 0,void 0,(function*(){const e=Date.now();yield t.disconnect(),yield t.changeState(new kn({authToken:s}),e)}))}onReconnect(t){return e(this,void 0,void 0,(function*(){const e=Date.now();yield t.changeState(new xn,e)}))}onLogout(t){return e(this,void 0,void 0,(function*(){const e=Date.now();yield t.changeState(new Cn,e)}))}}class Nn extends mn{constructor({autoReconnect:e}){super(),this.type=exports.ConnectionStateType.INTERNAL_DISCONNECTED,this.name="internaldisconnected",this._autoReconnect=!1,this._autoReconnect=e}run(t){return e(this,void 0,void 0,(function*(){const e=Date.now();yield t.disconnect(),this._autoReconnect&&(yield t.changeState(new xn,e))}))}onConnect(t,s){return e(this,void 0,void 0,(function*(){const e=Date.now();yield t.disconnect(),yield t.changeState(new kn({authToken:s}),e)}))}onReconnect(t){return e(this,void 0,void 0,(function*(){const e=Date.now();yield t.changeState(new xn,e)}))}onDisconnectWebSocket(t){return e(this,void 0,void 0,(function*(){const e=Date.now();yield t.changeState(new yn,e)}))}onLogout(t){return e(this,void 0,void 0,(function*(){const e=Date.now();yield t.changeState(new Cn,e)}))}}const An=t=>e(void 0,void 0,void 0,(function*(){return new Promise((e=>setTimeout(e,t)))}));class wn{calcTimeout(){return 0}}const bn=(t,s,i=new wn)=>e(void 0,void 0,void 0,(function*(){let e=0,n=null;const o=e=>n=null!=e?e:new Error("Halted"),r=()=>{e=0};for(;-1===s||et(e)))}run(t){return e(this,void 0,void 0,(function*(){const s=Date.now(),i=new Ce;this._callbacks.push((e=>e?i.reject(e):i.resolve())),Tn((()=>e(this,void 0,void 0,(function*(){t.connectionHandlers.forEach((e=>{e.onReconnectStarted&&e.onReconnectStarted()}))}))));try{const{reconnectMaxRetry:i,reconnectRetryStrategy:n}=t.sdkState.websocket;yield bn(((s,i)=>e(this,void 0,void 0,(function*(){this._haltConnect=s,this._resetConnect=i;try{yield t.connect()}catch(e){if(t.clearLoginTimer(),e instanceof o){if(e.code===exports.SendbirdErrorCode.CONNECTION_CANCELED)return void s(e);if(e.isSessionExpiredError||e.isSessionInvalidatedError)return void s(e)}throw e}}))),i,n),yield t.changeState(new In,s),Tn((()=>e(this,void 0,void 0,(function*(){this._flushCallbacks(),t.connectionHandlers.forEach((e=>{e.onReconnectSucceeded&&e.onReconnectSucceeded()}))}))))}catch(i){if(n(i))throw i;i instanceof o&&i.code!==exports.SendbirdErrorCode.CONNECTION_CANCELED&&(yield t.changeState(new Nn({autoReconnect:!1}),s)),Tn((()=>e(this,void 0,void 0,(function*(){this._flushCallbacks(i),t.connectionHandlers.forEach((e=>{e.onReconnectFailed&&e.onReconnectFailed()}))}))))}return i.promise}))}onConnect(t,s){return e(this,void 0,void 0,(function*(){const e=new Ce;return this._halt(o.connectionCanceled),t.cancelConnectForRetry(),this._callbacks.push((()=>{const i=Date.now();t.changeState(new kn({authToken:s}),i).then((()=>{e.resolve()})).catch((t=>{e.reject(t)}))})),e.promise}))}onReconnect(t,{resetReconnectCount:s=!1}){return e(this,void 0,void 0,(function*(){const e=new Ce;return this._resetConnect&&s&&this._resetConnect(),this._callbacks.push((t=>t?e.reject(t):e.resolve())),e.promise}))}onDisconnect(t,{error:s=null,autoReconnect:i=!0}){return e(this,void 0,void 0,(function*(){const e=Date.now();this._halt(o.connectionCanceled),yield t.changeState(new Nn({autoReconnect:i}),e)}))}onDisconnectWebSocket(t){return e(this,void 0,void 0,(function*(){const e=Date.now();this._halt(o.connectionCanceled),yield t.changeState(new yn,e)}))}onLogout(t){return e(this,void 0,void 0,(function*(){const e=Date.now();this._halt(o.connectionCanceled),yield t.changeState(new Cn,e)}))}}class In extends mn{constructor(){super(...arguments),this.type=exports.ConnectionStateType.CONNECTED,this.name="connected"}onReconnect(t){return e(this,void 0,void 0,(function*(){const e=Date.now();yield t.disconnect(),yield t.changeState(new xn,e)}))}onDisconnect(t,{autoReconnect:s}){return e(this,void 0,void 0,(function*(){const e=Date.now();yield t.changeState(new Nn({autoReconnect:s}),e)}))}onDisconnectWebSocket(t){return e(this,void 0,void 0,(function*(){const e=Date.now();yield t.changeState(new yn,e)}))}onLogout(t){return e(this,void 0,void 0,(function*(){const e=Date.now();yield t.changeState(new Cn,e)}))}}class kn extends mn{constructor({authToken:e}){super(),this.type=exports.ConnectionStateType.CONNECTING,this.name="connecting",this._authToken="",this._callbacks=[],this._authToken=e}_halt(e){this._haltConnect&&(this._haltConnect(e),this._haltConnect=void 0)}_flushCallbacks(e){this._haltConnect=void 0,this._callbacks.forEach((t=>t(e)))}run(t){return e(this,void 0,void 0,(function*(){const s=Date.now(),i=new Ce;this._callbacks.push((e=>e?i.reject(e):i.resolve()));try{yield bn((s=>e(this,void 0,void 0,(function*(){this._haltConnect=s;try{yield t.connect(this._authToken)}catch(e){if(t.clearLoginTimer(),e instanceof o&&e.code===exports.SendbirdErrorCode.CONNECTION_CANCELED)return void s(e);throw e}}))),t.sdkState.websocket.connectMaxRetry),yield t.changeState(new In,s),Tn((()=>e(this,void 0,void 0,(function*(){this._flushCallbacks(),t.connectionHandlers.forEach((e=>{e.onConnected&&e.onConnected(t.sdkState.userId)}))}))))}catch(i){if(n(i))throw i;yield t.disconnect(),i instanceof o&&i.code!==exports.SendbirdErrorCode.CONNECTION_CANCELED&&(yield t.changeState(new On,s)),Tn((()=>e(this,void 0,void 0,(function*(){this._flushCallbacks(i)}))))}return i.promise}))}onConnect(t){return e(this,void 0,void 0,(function*(){const e=new Ce;return this._callbacks.push((t=>t?e.reject(t):e.resolve())),e.promise}))}onDisconnect(t,{error:s=null,autoReconnect:i=!1}){return e(this,void 0,void 0,(function*(){const e=Date.now();this._halt(null!=s?s:o.connectionCanceled),t.hasSession?yield t.changeState(new Nn({autoReconnect:i}),e):yield t.changeState(new Cn,e)}))}onDisconnectWebSocket(t){return e(this,void 0,void 0,(function*(){const e=Date.now();this._halt(o.connectionCanceled),t.hasSession?yield t.changeState(new yn,e):yield t.changeState(new Cn,e)}))}onLogout(t){return e(this,void 0,void 0,(function*(){const e=Date.now();this._halt(o.connectionCanceled),yield t.changeState(new Cn,e)}))}}class On extends mn{constructor(){super(...arguments),this.type=exports.ConnectionStateType.INITIALIZED,this.name="initialized"}onConnect(t,s){return e(this,void 0,void 0,(function*(){const e=Date.now();yield t.changeState(new kn({authToken:s}),e)}))}onLogout(t){return e(this,void 0,void 0,(function*(){const e=Date.now();yield t.changeState(new Cn({wasPreviouslyConnected:!1}),e)}))}}class Rn extends Gi{constructor(){super({code:"PING",payload:{id:Date.now(),active:1},ackRequired:!1})}}class Dn{constructor({pingDelegate:e,sdkState:t,logger:s}){this.pingDelegate=e,this.sdkState=t,this._logger=s}get isWaiting(){return!!this._pingTimeoutTimer}ping(){var e;if(!this.sdkState.websocket)throw o.connectionRequired;const t=new Rn;try{const s=null!==(e=this.sdkState.websocket.pongTimeout)&&void 0!==e?e:5e3;this._pingTimeoutTimer=setTimeout((()=>{this._logger.debug("pinger.ping() timeout"),this.pingDelegate.error()}),s),this.pingDelegate.send(t),this._logger.debug("pinger.ping()")}catch(e){this._logger.debug("pinger.ping() error",e),this._pingTimeoutTimer&&(clearTimeout(this._pingTimeoutTimer),this._pingTimeoutTimer=void 0),this.pingDelegate.error()}return t}pong(){this._logger.debug("pinger.pong()"),this._pingTimeoutTimer&&(clearTimeout(this._pingTimeoutTimer),this._pingTimeoutTimer=void 0)}refreshTimer(){var e;if(!this.sdkState.websocket)throw o.connectionRequired;this._logger.debug("pinger.refreshTimer()");const t=null!==(e=this.sdkState.websocket.pingInterval)&&void 0!==e?e:15e3;this.stop(),this._pingTimer=setInterval((()=>{this.ping()}),t)}start(){this._logger.debug("pinger.start()"),this.refreshTimer(),this.ping()}stop(){this._logger.debug("pinger.stop()"),this._pingTimer&&(clearInterval(this._pingTimer),this._pingTimer=void 0),this._pingTimeoutTimer&&(clearTimeout(this._pingTimeoutTimer),this._pingTimeoutTimer=void 0)}}class Ln extends I{constructor({request:e=!0,features:t={},options:s={}}){super(),this.request=e,this.features=Object.assign({localCache:!0},t),this.options=Object.assign({ingestion:!0},s)}}const Un=["premium_feature_list","file_upload_size_limit","application_attributes","emoji_hash","multiple_file_send_max_size","notifications"];class Pn extends b{constructor(e,{sdkState:t,cacheContext:s,connectionHandlers:i,sessionManager:n,websocketClient:r,dispatcher:a,logger:l,entryState:d=new On}){var c;super(),this._stateUpdatedAt=0,this._connectingAt=0,this._connectionRequestQueue=[],this._iid=e,this.sdkState=t,this.cacheContext=s,this.connectionHandlers=i,this._sessionManager=n,this._websocketClient=r,this._dispatcher=a,this._logger=l,this._currentState=d,(null===(c=this.sdkState.websocket)||void 0===c?void 0:c.pingerDisabled)||(this._pinger=new Dn({pingDelegate:{send:e=>this._websocketClient.send(e),error:e=>this._websocketClient.error(e)},sdkState:this.sdkState,logger:l})),this._websocketClient.on("open",(()=>{this._tryResolveConnectionRequest()})).on("message",(e=>{if("LOGI"===e.code)this.clearLoginTimer(),this._dispatcher.dispatch(e.as(Sn))})).on("ping-refresh",(()=>{var e;return null===(e=this._pinger)||void 0===e?void 0:e.refreshTimer()})).on("pong",(()=>{var e;return null===(e=this._pinger)||void 0===e?void 0:e.pong()})).on("error",(()=>{var e;return null===(e=this._pinger)||void 0===e?void 0:e.stop()})).on("close",(()=>{this._logiProcessingTimer=setTimeout((()=>{this._logiProcessingTimer=void 0,this._unresolvedLogi||this._rejectConnectionRequest(o.networkError)}),500)})),this._dispatcher.on((e=>{e instanceof Sn&&(this._unresolvedLogi=e,this._tryResolveConnectionRequest())}))}get currentState(){return this._currentState}get hasSession(){return this._sessionManager.session.hasSession}changeState(t,s){return e(this,void 0,void 0,(function*(){return s>=this._stateUpdatedAt&&(this._currentState=t,this._stateUpdatedAt=s,this._dispatcher.dispatch(new ji({stateType:t.type})),this._logger.debug(`connection state changes to ${t.name}`),yield this._currentState.run(this),!0)}))}_tryResolveConnectionRequest(){var t;return e(this,void 0,void 0,(function*(){const e=this._unresolvedLogi;if(this._websocketClient.isOpen&&e)if(this._unresolvedLogi=void 0,e.error)this._sessionManager.session.authToken=void 0,(e.error.isSessionExpiredError||e.error.isSessionInvalidatedError)&&this._dispatcher.dispatch(new ue({reason:e.error.code})),this._rejectConnectionRequest(e.error);else{yield e.applyTo(this._iid);const{userProfile:s}=e;this._enableStatLog({request:s.appInfo.applicationAttributes.includes("allow_sdk_request_log_publish"),features:{localCache:s.appInfo.applicationAttributes.includes("allow_sdk_feature_local_cache_log_publish")},options:{ingestion:s.appInfo.allowSdkStatsUpload}}),this._statLogConnection(),null===(t=this._pinger)||void 0===t||t.start(),this._connectionRequestQueue.forEach((e=>e.resolve())),this._connectionRequestQueue=[],this.sdkState.appState="foreground"}}))}_rejectConnectionRequest(e){var t;if(null===(t=this._pinger)||void 0===t||t.stop(),this.clearLoginTimer(),this._connectionRequestQueue.length>0){const t=this._connectionRequestQueue;this._connectionRequestQueue=[],t.forEach((t=>t.reject(e))),this._statLogConnection(e)}}_url(){var e;const{appId:t,appVersion:s,userId:n,extensions:o,sendbirdRuntimeEnvironment:r}=this.sdkState,{localCacheEnabled:a}=this.cacheContext,{session:l}=this._sessionManager,d=null===(e=this.sdkState.websocket)||void 0===e?void 0:e.compression,c=!!(null!=o?o:{}).sb_uikit,h=Te.userAgentWithExtension(o);return`${this.sdkState.websocket.host}/?p=JS&pv=${encodeURIComponent(i.OS_VERSION)}&sv=${encodeURIComponent(i.SDK_VERSION)}&ai=${t}${s?`&av=${s}`:""}${l.hasSession?"":`&user_id=${encodeURIComponent(n)}`}&pmce=${d?1:0}&active=1&device_token_types=${encodeURIComponent(["gcm","huawei","apns"].join(","))}&SB-User-Agent=${h}&SB-SDK-User-Agent=${encodeURIComponent(Te.sendbirdSdkUserAgentWithExtension(r))}&Request-Sent-Timestamp=${Date.now().toString()}&include_extra_data=${encodeURIComponent(String(Un))}${this._sessionManager.handler?"&expiring_session=1":""}&use_local_cache=${a?1:0}&include_poll_details=1${c?"&uikit_config=1":""}`}_enableStatLog({request:e,features:t,options:s={}}){this._dispatcher.dispatch(new Ln({request:e,features:t,options:s}))}_statLogConnection(e){var t;this._dispatcher.dispatch(new _e(new Ee({type:exports.StatType.WEBSOCKET_CONNECT,data:{host_url:null===(t=this.sdkState.websocket)||void 0===t?void 0:t.host,success:!e,latency:Date.now()-this._connectingAt,error_code:null==e?void 0:e.code,error_description:null==e?void 0:e.message}})))}connect(t=""){var s;return e(this,void 0,void 0,(function*(){this._logiProcessingTimer&&(clearTimeout(this._logiProcessingTimer),this._logiProcessingTimer=void 0,this._rejectConnectionRequest(o.connectionCanceled));const e=this._url(),i=new Ce;if(this._connectionRequestQueue.push(i),1===this._connectionRequestQueue.length){this._connectingAt=Date.now(),this._loginTimer=setTimeout((()=>{this._loginTimer=void 0,this._rejectConnectionRequest(o.loginTimeout)}),null===(s=this.sdkState.websocket)||void 0===s?void 0:s.responseTimeout);const{session:i}=this._sessionManager;t&&(i.authToken=t),this._websocketClient.connect(e,JSON.stringify(i.hasSession?{auth:i.sessionKey}:{token:t}))}return i.promise}))}cancelConnectForRetry(){this._dispatcher.dispatch(Sn.asError(o.connectionRenew))}disconnect(){return e(this,void 0,void 0,(function*(){yield this._websocketClient.disconnect()}))}logout(){return e(this,void 0,void 0,(function*(){this.sdkState.userId=void 0,this._unresolvedLogi=void 0,yield this._sessionManager.clear(),yield this.disconnect()}))}clearLoginTimer(){this._loginTimer&&(clearTimeout(this._loginTimer),this._loginTimer=void 0)}}class Mn extends de{constructor({appId:e,userId:t,services:s=[exports.SessionService.CHAT],includeUIKitConfig:i=!1,localCacheEnabled:n=!0,expiringSession:o=!0}){super(),this.path=`${G}/${t}/login`,this.method=exports.APIRequestMethod.POST,this.params={expiring_session:!!o,services:s,include_logi:!0,include_extra_data:String(Un),uikit_config:i,use_local_cache:n,app_id:e},this.requireAuth=!1}}class Fn extends ce{constructor(e,t){super(e,t),this.logi=new Sn(e,"LOGI",t)}}var Hn;!function(e){e[e.ALL=0]="ALL",e[e.WEBSOCKET=1]="WEBSOCKET",e[e.API=2]="API"}(Hn||(Hn={}));const zn=[Zi,Mn];class qn{constructor(e,{session:t,sdkState:s,dispatcher:i,logger:n,useFetchCompat:r=!1}){this._currentConnectionStateType=exports.ConnectionStateType.INITIALIZED,this._lazyCallQueue=[],this.commandRouter=new Bi(e,{session:t,sdkState:s,dispatcher:i,logger:n,useFetchCompat:r}),this._session=t,this._logger=n,this._dispatcher=i,this._dispatcher.on((e=>{var t,s;if(e instanceof ji){const{stateType:s}=e;switch(this._currentConnectionStateType=s,s){case exports.ConnectionStateType.CONNECTED:this._resolveLazyCallQueue();break;case exports.ConnectionStateType.INITIALIZED:case exports.ConnectionStateType.INTERNAL_DISCONNECTED:case exports.ConnectionStateType.EXTERNAL_DISCONNECTED:case exports.ConnectionStateType.LOGOUT:this._rejectLazyCallQueue((null===(t=this._session)||void 0===t?void 0:t.hasSession)?o.connectionClosed:o.connectionRequired)}}else if(e instanceof $i)(null===(s=this._session.services)||void 0===s?void 0:s.includes(exports.SessionService.CHAT))||this._resolveLazyCallQueue(Hn.API);else if(e instanceof Qi||e instanceof Wi)this._rejectLazyCallQueue(o.connectionClosed);else if(e instanceof pe){const{request:t,deferred:s,error:i}=e;for(const e of zn)if(t instanceof e)return void s.reject(i);this._lazyCallQueue.push({command:t,deferred:s})}}))}get isReady(){return this._currentConnectionStateType===exports.ConnectionStateType.CONNECTED}get isLazyCallActivated(){return this._currentConnectionStateType===exports.ConnectionStateType.CONNECTING||this._currentConnectionStateType===exports.ConnectionStateType.RECONNECTING||this._session.isRefreshing}_classifyLazyCallQueueByScope(e){const t=[],s=[];let i;switch(e){case Hn.ALL:i=null;break;case Hn.WEBSOCKET:i=Gi;break;case Hn.API:i=de}let n=!1;return this._lazyCallQueue.forEach((e=>{!i||e.command instanceof i||(n=!0),n?s.push(e):t.push(e)})),[t,s]}_resolveLazyCallQueue(t=Hn.ALL){const[s,i]=this._classifyLazyCallQueueByScope(t);this._lazyCallQueue=i,s.forEach((t=>e(this,void 0,void 0,(function*(){const{command:e,deferred:s,timeout:i}=t;i&&clearTimeout(i);try{const t=yield this.send(e);s.resolve(t)}catch(e){s.reject(e)}}))))}_rejectLazyCallQueue(t,s=Hn.ALL){const[i,n]=this._classifyLazyCallQueueByScope(s);this._lazyCallQueue=n,i.forEach((s=>e(this,void 0,void 0,(function*(){const{deferred:e,timeout:i}=s;clearTimeout(i),e.reject(t)}))))}send(t){return e(this,void 0,void 0,(function*(){if(t instanceof Gi){if(this.isReady)return this._logger.debug("send websocket request",t),yield this.commandRouter.send(t);if(this.isLazyCallActivated){this._logger.debug("wait websocket request",t);const e=new Ce;return this._lazyCallQueue.push({command:t,deferred:e,timeout:setTimeout((()=>this.timeout(t.requestId)),1e4)}),e.promise}throw this._logger.debug("fail websocket request"),o.connectionRequired}if(t instanceof de){if(this._session.hasSession)return this._logger.debug("send api request",t),yield this.commandRouter.send(t);if(this.isLazyCallActivated){this._logger.debug("wait api request",t);const e=new Ce;return this._lazyCallQueue.push({command:t,deferred:e,timeout:setTimeout((()=>this.timeout(t.requestId)),1e4)}),e.promise}{const e=o.connectionRequired;throw this._logger.debug("fail api request",e),e}}throw o.invalidCommand}))}forceSend(t){return e(this,void 0,void 0,(function*(){if(this._logger.debug("send forced request",t),t instanceof Gi||t instanceof de)return yield this.commandRouter.send(t);throw o.invalidCommand}))}timeout(e){this._logger.debug("timeout request",e);const t=this._lazyCallQueue.findIndex((t=>t.command.requestId===e));t>-1&&(this._lazyCallQueue[t].deferred.reject(o.connectionRequired),this._lazyCallQueue.splice(t,1))}cancel(e){this._logger.debug("cancel api request",e),this.commandRouter.cancel(e)}cancelAll(){this._logger.debug("cancel all api requests"),this.commandRouter.cancelAll()}}const Vn="sendbird@devicetokens";class Gn{constructor({type:e,token:t}){this.type=e,this.token=t}static payloadify(e){return k(O({type:e.type,token:e.token}))}}const Kn=new WeakMap;class Bn extends b{constructor({session:e,cacheContext:t,sdkState:s,dispatcher:i,requestQueue:n,logger:o}){super(),this._currentConnectionStateType=exports.ConnectionStateType.INITIALIZED,this._isRefreshingAuthToken=!1,this.currentUser=null,this.session=e,this._cacheContext=t,this._sdkState=s,this._dispatcher=i,this._requestQueue=n,this._logger=o,this._deviceTokens=[],this._dispatcher.on((e=>{var t;if(e instanceof ji){const{stateType:t}=e;this._currentConnectionStateType=t}else e instanceof ue&&this.handler&&((null===(t=e.error)||void 0===t?void 0:t.isSessionInvalidatedError)?this.handler.onSessionClosed&&this.handler.onSessionClosed():(e.invalidateSessionToken&&(this.session.authToken=void 0),e.error&&e.error.isSessionExpiredError&&(this._logger.debug("session expired"),this.handler.onSessionExpired&&this.handler.onSessionExpired(),this.refresh())))}))}get ekey(){return Kn.get(this)}get deviceTokens(){return this._deviceTokens}get deviceTokenLastDeletedAt(){return this._deviceTokenLastDeletedAt}indexOfDeviceToken(e,t){return this._deviceTokens.findIndex((s=>s.type===e&&s.token===t))}hasDeviceToken(e,t){return this.indexOfDeviceToken(e,t)>=0}createRefreshWebsocketCommand(e,t){return new Yi({authToken:e,expiringSession:!0,requestId:t})}_refreshSessionKeyByWebSocket(t){return e(this,void 0,void 0,(function*(){const e=this.createRefreshWebsocketCommand(t),s=yield this._requestQueue.forceSend(e),{newKey:i,error:n}=s.as(Ji);if(n)throw n;this.session.sessionKey=null!=i?i:this.session.sessionKey}))}_refreshSessionKeyByApi(t){return e(this,void 0,void 0,(function*(){const s=new Zi({userId:this._sdkState.userId,authToken:t,services:this.session.services,expiringSession:!0});yield bn((t=>e(this,void 0,void 0,(function*(){try{const e=yield this._requestQueue.forceSend(s),{key:t,services:i}=e.as(Xi);this.session.sessionKey=t,this.session.services=i}catch(e){if(!this._isSessionRelatedError(e))throw e;t(e)}}))),3)}))}_refreshSessionKey(t,s=!0){return e(this,void 0,void 0,(function*(){if(this._currentConnectionStateType===exports.ConnectionStateType.CONNECTED)try{return yield this._refreshSessionKeyByWebSocket(t),void this.complete()}catch(e){if(e instanceof o&&e.isSessionTokenExpiredError){if(s){const e=yield this._receiveNewAuthToken();return void(e?(this.session.authToken=e,yield this._refreshSessionKey(this.session.authToken,!1),this.complete()):yield this.clear())}this.session.authToken=void 0}}try{yield this._refreshSessionKeyByApi(t),this.complete()}catch(e){if(!(e instanceof o&&e.isSessionTokenExpiredError))throw e;if(!s)throw this.session.authToken=void 0,e;{const e=yield this._receiveNewAuthToken();e?(this.session.authToken=e,yield this._refreshSessionKeyByApi(this.session.authToken),this.complete()):yield this.clear()}}}))}_receiveNewAuthToken(){const t=new Ce;return Tn((()=>e(this,void 0,void 0,(function*(){var e;if(this._isRefreshingAuthToken=!0,this.session.clear(),null===(e=this.handler)||void 0===e?void 0:e.onSessionTokenRequired){let e=null;const s=()=>{e&&(clearTimeout(e),e=null)},i=e=>{s(),this._isRefreshingAuthToken&&(this._isRefreshingAuthToken=!1,this.dispatch("refresh-authtoken"),t.resolve(e))},n=e=>{s(),this._isRefreshingAuthToken&&(this._isRefreshingAuthToken=!1,t.reject(e))};e=setTimeout((()=>n()),1e3*this._sdkState.sessionTokenRefreshTimeout),this.handler.onSessionTokenRequired(i,n)}else t.resolve(null)})))),t.promise}_isSessionRelatedError(e){return e instanceof o&&(e.isSessionExpiredError||e.isSessionInvalidatedError)}get isSessionKeyRefreshing(){return this.session.isRefreshing}get isRefreshingAuthToken(){return this._isRefreshingAuthToken}get isSessionExpiring(){return!!this.handler}authenticateFeed(t,s){var i;return e(this,void 0,void 0,(function*(){this.session.authToken=s;const e=new Mn({appId:this._sdkState.appId,userId:t,services:[exports.SessionService.FEED],includeUIKitConfig:!!(null!==(i=this._sdkState.extensions)&&void 0!==i?i:{}).sb_uikit,localCacheEnabled:this._cacheContext.localCacheEnabled,expiringSession:!s||this.isSessionExpiring}),n=yield this._requestQueue.commandRouter.send(e),{logi:o}=n.as(Fn);if(o.error)throw o.error;yield this.login(o),o.userProfile.apply()}))}login(t){var s;return e(this,void 0,void 0,(function*(){const{key:e,ekey:i,services:n,userProfile:o,deviceTokenLastDeletedAt:r=0}=t;this.session.hasLessServiceScopeThan(n)&&(this.session.sessionKey=e,this.session.services=n),Kn.set(this,i),this._deviceTokenCacheEnabled=null===(s=null==o?void 0:o.appInfo)||void 0===s?void 0:s.deviceTokenCache;const{preference:a}=this._cacheContext;if(this._deviceTokenCacheEnabled){const e=yield a.get(Vn);!e||e.lastDeletedAtnew Gn(Gn.payloadify(e)))),this._deviceTokenLastDeletedAt=e.lastDeletedAt)}else yield a.remove(Vn)}))}complete(){this.dispatch("refresh"),this._dispatcher.dispatch(new $i),Tn((()=>e(this,void 0,void 0,(function*(){var e;this._logger.debug("session refreshed"),(null===(e=this.handler)||void 0===e?void 0:e.onSessionRefreshed)&&this.handler.onSessionRefreshed()}))))}error(t){Tn((()=>e(this,void 0,void 0,(function*(){var e;(null===(e=this.handler)||void 0===e?void 0:e.onSessionError)&&this.handler.onSessionError(t)}))))}close(){this.dispatch("close"),this._dispatcher.dispatch(new Wi),Tn((()=>e(this,void 0,void 0,(function*(){var e;this._logger.debug("session closed"),(null===(e=this.handler)||void 0===e?void 0:e.onSessionClosed)&&this.handler.onSessionClosed()}))))}refresh(){return e(this,void 0,void 0,(function*(){if(this.isSessionExpiring&&!this.session.isRefreshing){if(this.session.isRefreshing=!0,!this.session.authToken)try{const e=yield this._receiveNewAuthToken();if(!e)return yield this.clear(),void(this.session.isRefreshing=!1);this._logger.debug("session refreshing.."),this.session.authToken=e}catch(e){const t=o.sessionTokenRequestFailed;throw this._dispatcher.dispatch(new Qi),this.error(t),this.session.isRefreshing=!1,t}try{yield this._refreshSessionKey(this.session.authToken),this.session.isRefreshing=!1}catch(e){const t=o.sessionTokenRefreshFailed;throw this._dispatcher.dispatch(new Qi),this.error(t),this.session.isRefreshing=!1,t}}}))}setDeviceToken(e,t){if(this._deviceTokenCacheEnabled){if(this.indexOfDeviceToken(e,t)<0)return this._deviceTokens.push(new Gn({type:e,token:t})),!0}return!1}unsetDeviceToken(e,t){if(this._deviceTokenCacheEnabled){const s=this.indexOfDeviceToken(e,t);s>=0&&this._deviceTokens.splice(s,1)}}unsetDeviceTokens(e){this._deviceTokenCacheEnabled&&(this._deviceTokens=e?this._deviceTokens.filter((t=>t.type!==e)):[])}setDeviceTokenDeletedAt(e){e>0&&(this._deviceTokenLastDeletedAt=e)}saveDeviceToken(){return e(this,void 0,void 0,(function*(){if(this._deviceTokenCacheEnabled){const{preference:e}=this._cacheContext;yield e.set(Vn,{tokens:this._deviceTokens,lastDeletedAt:this._deviceTokenLastDeletedAt})}}))}clear(){return e(this,void 0,void 0,(function*(){this.currentUser=null,this.session.clear(),this.close(),Kn.delete(this),this._deviceTokens=[],this._deviceTokenLastDeletedAt=0,yield this.saveDeviceToken()}))}}class jn{constructor(e,{sdkState:t,cacheContext:s,connectionHandlers:i,sessionManager:n,websocketClient:o,dispatcher:r,logger:a,disableWebSocketCloseEventHandling:l=!1}){this._disableWebSocketCloseEventHandling=!1,this._externalCalledWebSocketClose=!1,this._logger=a,this._disableWebSocketCloseEventHandling=l,this._context=new Pn(e,{sdkState:t,cacheContext:s,connectionHandlers:i,sessionManager:n,websocketClient:o,dispatcher:r,logger:a}),this._sdkState=t,this._sessionManager=n,this._websocketClient=o}_registerEventDispatcher(){this._disableWebSocketCloseEventHandling||(this._clearEventDispatcher(),this._sessionEventDispatcherContext=this._sessionManager.on("refresh-authtoken",(()=>{this.isConnected||(this._logger.debug("try reconnect by session token refresh"),this.reconnect())})).on("refresh",(()=>{this.isConnecting||this.isConnected||(this._logger.debug("try reconnect by session key refresh"),this.reconnect())})),this._websocketEventDispatcherContext=this._websocketClient.on("close",(()=>{"foreground"!==this._sdkState.appState||this._externalCalledWebSocketClose||this._sessionManager.isRefreshingAuthToken||(this._logger.debug("try reconnect by websocket connection closed"),this.reconnect())})))}_clearEventDispatcher(){this._sessionEventDispatcherContext&&(this._sessionEventDispatcherContext.close(),this._sessionEventDispatcherContext=void 0),this._websocketEventDispatcherContext&&(this._websocketEventDispatcherContext.close(),this._websocketEventDispatcherContext=void 0)}get isConnected(){const{currentState:e}=this._context;return e.type===exports.ConnectionStateType.CONNECTED}get isConnecting(){const{currentState:e}=this._context;return e.type===exports.ConnectionStateType.CONNECTING||e.type===exports.ConnectionStateType.RECONNECTING}get websocketClient(){return this._websocketClient}connect(t){return e(this,void 0,void 0,(function*(){const{currentState:e}=this._context;this._externalCalledWebSocketClose=!1,yield e.onConnect(this._context,t),this._registerEventDispatcher()}))}reconnect(){return e(this,void 0,void 0,(function*(){const{currentState:e}=this._context;this._externalCalledWebSocketClose=!1,yield e.onReconnect(this._context,{})}))}resetAndReconnect(){return e(this,void 0,void 0,(function*(){const{currentState:e}=this._context;this._externalCalledWebSocketClose=!1,yield e.onReconnect(this._context,{resetReconnectCount:!0})}))}background(){return e(this,void 0,void 0,(function*(){const{currentState:e}=this._context;this._externalCalledWebSocketClose=!0,yield e.onDisconnect(this._context,{autoReconnect:!1})}))}disconnect(t){return e(this,void 0,void 0,(function*(){const{currentState:e}=this._context;yield e.onDisconnect(this._context,{error:t,autoReconnect:!0})}))}disconnectWebSocket(){return e(this,void 0,void 0,(function*(){const{currentState:e}=this._context;this._externalCalledWebSocketClose=!0,yield e.onDisconnectWebSocket(this._context)}))}logout(){return e(this,void 0,void 0,(function*(){const{currentState:e}=this._context;this._clearEventDispatcher(),yield e.onLogout(this._context)}))}}class $n extends Ee{constructor({type:e,data:t,ts:s=Date.now()}){var i;super({type:e,data:t,ts:s}),this.date=new Date(s),this.key=`${i=this.date,`${i.getFullYear()}${String(i.getMonth()+1).padStart(2,"0")}${String(i.getDate()).padStart(2,"0")}`}_${e}`}}class Qn extends de{constructor({deviceId:e,statLogs:t}){super(),this.method=exports.APIRequestMethod.POST,this.path=`${se}`,this.params={device_id:e,log_entries:t.map((e=>Ee.payloadify(e)))}}}const Wn=(e,t)=>{if(null!==e&&null!==t){const s=Object.keys(e),i=Object.keys(t),n=[...new Set([...s,...i])],o={};for(const s of n){const i=typeof e[s],n=typeof t[s];"undefined"===i?o[s]=t[s]:"undefined"===n?o[s]=e[s]:i!==n?o[s]=t[s]:"object"===i&&e[s]&&t[s]?o[s]=Wn(e[s],t[s]):o[s]=t[s]}return o}return t};var Zn,Yn;!function(e){e[e.PENDING=0]="PENDING",e[e.COLLECT_ONLY=1]="COLLECT_ONLY",e[e.ENABLED=2]="ENABLED",e[e.DISABLED=3]="DISABLED"}(Zn||(Zn={}));class Xn extends b{constructor({cacheContext:e,requestQueue:t,dispatcher:s,baseLimit:i=100,maxLimit:n=1e3,minLimit:o=10}){super(),this.queue=[],this.flushWaitQueue=[],this.enabledState=Zn.PENDING,this.isFlushing=!1,this.generation=1,this.lastFlushedAt=0,this._collectRequestStat=!0,this._collectFeatureLocalCacheStat=!0,this.deviceId=A(),this.cacheContext=e,this.requestQueue=t,this.dispatcher=s,this.baseLimit=i,this.limit=i,this.maxLimit=n,this.minLimit=o}get isEnabled(){return this.enabledState===Zn.ENABLED}_arrangeStat(){let e=[...this.queue];this._collectRequestStat||(e=e.filter((e=>e.type!==exports.StatType.API_RESULT&&e.type!==exports.StatType.WEBSOCKET_CONNECT))),this._collectFeatureLocalCacheStat||(e=e.filter((e=>e.type!==exports.StatType.FEATURE_LOCALCACHE&&e.type!==exports.StatType.FEATURE_LOCALCACHE_EVENT))),this.queue=e}_save(){return e(this,void 0,void 0,(function*(){if(this.enabledState===Zn.ENABLED){const e=[...this.queue,...this.flushWaitQueue];yield this.cacheContext.preference.set(this.key,{deviceId:this.deviceId,statLogs:e.map((e=>Ee.payloadify(e))),generation:this.generation++,lastFlushedAt:this.lastFlushedAt}),this.dispatch("save",e)}}))}_flush(){return e(this,void 0,void 0,(function*(){if(this.isEnabled&&!this.isFlushing){this.isFlushing=!0;try{this._arrangeStat();const e=this.queue.filter((e=>{if(e instanceof $n){const t=new Date,[s,i]=[e.date.getFullYear(),t.getFullYear()];if(s!(e instanceof $n))),s=[...e,...t].slice(0,Math.min(this.limit,this.maxLimit));if(s.length>0){const i=new Qn({deviceId:this.deviceId,statLogs:s});yield this.requestQueue.send(i),this.dispatch("flush",s),this.queue=[...e,...t].slice(s.length).concat(this.flushWaitQueue),this.flushWaitQueue=[],yield this._save()}this.limit=this.baseLimit,this.lastFlushedAt=Date.now()}catch(e){e instanceof o&&(e.code===exports.SendbirdErrorCode.STAT_LOG_NOT_ALLOWED?(yield this.clear(),this.enabledState=Zn.DISABLED):e.code===exports.SendbirdErrorCode.STAT_UPLOAD_NOT_ALLOWED&&(this.enabledState=Zn.COLLECT_ONLY)),this.limit=this.limit+20}finally{this.isFlushing=!1}}}))}init(t){return e(this,void 0,void 0,(function*(){this.key=t;const e=yield this.cacheContext.preference.get(this.key);if(e&&(this.deviceId=e.deviceId,this.queue=e.statLogs.map((e=>(e.stat_type===exports.StatType.FEATURE_LOCALCACHE_EVENT&&(e.data=Object.assign({message_init_policy:"",starting_point:0},e.data)),new Ee({type:e.stat_type,ts:e.ts,data:e.data})))),this.generation=e.generation,this.lastFlushedAt=e.lastFlushedAt,Date.now()-this.lastFlushedAt>=108e5&&this.queue.length>=this.minLimit)){const e=Math.min(Math.floor(18e4*Math.random()),100);yield An(e),yield this._flush()}this.commandEventContext||(this.commandEventContext=this.dispatcher.on((e=>{if(e instanceof _e){const{statLog:t}=e;this.put(t)}else if(e instanceof Ln){const{request:t,features:s,options:i}=e;this._collectRequestStat=t,this._collectFeatureLocalCacheStat=null==s?void 0:s.localCache,this._arrangeStat(),this._collectRequestStat||this._collectFeatureLocalCacheStat?this.enabledState=i.ingestion?Zn.ENABLED:Zn.COLLECT_ONLY:this.enabledState=Zn.DISABLED,this.isEnabled?this.queue.length>=this.limit&&this._flush():this.clear()}})))}))}put(t){return e(this,void 0,void 0,(function*(){if(this.enabledState!==Zn.DISABLED){const e=this.isFlushing?this.flushWaitQueue:this.queue;if(t instanceof $n){if(this._collectFeatureLocalCacheStat){const[s]=this.queue.filter((e=>e instanceof $n&&e.key===t.key));s?s.data=Wn(s.data,t.data):e.push(t)}}else this._collectRequestStat&&e.push(t);yield this._save(),e.length>=this.limit&&(yield this._flush())}}))}clear(){return e(this,void 0,void 0,(function*(){this.queue=[],this.flushWaitQueue=[],this.generation=1,yield this._save()}))}close(){this.commandEventContext&&(this.commandEventContext.close(),this.commandEventContext=void 0)}}exports.LogLevel=void 0,(Yn=exports.LogLevel||(exports.LogLevel={}))[Yn.NONE=0]="NONE",Yn[Yn.VERBOSE=1]="VERBOSE",Yn[Yn.DEBUG=2]="DEBUG",Yn[Yn.INFO=3]="INFO",Yn[Yn.WARN=4]="WARN",Yn[Yn.ERROR=5]="ERROR";class Jn{constructor(){this.level=exports.LogLevel.WARN}verbose(...e){this.level<=exports.LogLevel.VERBOSE&&console.log("[verbose]",...e)}debug(...e){this.level<=exports.LogLevel.DEBUG&&console.log("[debug]",...e)}info(...e){this.level<=exports.LogLevel.INFO&&console.log("[info]",...e)}warn(...e){this.level<=exports.LogLevel.WARN&&console.warn("[warn]",...e)}error(...e){this.level<=exports.LogLevel.ERROR&&console.error("[error]",...e)}}const eo={};class to{constructor(e,t){var s,n,o,r,a,l,d,c,h,u;if(this.connectedAt=0,this.firstConnectedAt=0,this.connectionHandlers=new Map,this.userEventHandlers=new Map,!eo[e]){eo[e]=this;const p=null!==(s=t.options)&&void 0!==s?s:new _,E=this.sdkState={appId:t.appId,appVersion:null!==(n=t.appVersion)&&void 0!==n?n:"",appState:"foreground",userId:void 0,extensions:{},api:{host:null!==(o=t.apiHost)&&void 0!==o?o:`https://api-${t.appId}.sendbird.com`},websocket:{host:null!==(r=t.websocketHost)&&void 0!==r?r:`wss://ws-${t.appId}.sendbird.com`,pingerDisabled:!!t.noPingpong,pingInterval:void 0,pongTimeout:void 0,connectMaxRetry:2,compression:!0,reconnectMaxRetry:-1,reconnectRetryStrategy:new wn,responseTimeout:p.websocketResponseTimeout},sessionTokenRefreshTimeout:p.sessionTokenRefreshTimeout};this.appInfo=void 0,this.subscribedUnreadMessageCount={all:0,feed:0,customTypes:{},ts:0};const g=this.logger=new Jn;this.logger.level=null!==(a=t.logLevel)&&void 0!==a?a:exports.LogLevel.WARN,this.connectedAt=0,this.firstConnectedAt=0,this.connectionHandlers=new Map,this.userEventHandlers=new Map;const v=this.cacheContext=new f({encryption:t.encryption,store:t.store,localCacheEnabled:null!==(l=t.localCacheEnabled)&&void 0!==l&&l,localCacheConfig:null!==(d=t.localCacheConfig)&&void 0!==d?d:new C});this.debugMode=null!==(c=t.debugMode)&&void 0!==c&&c,this.maxSuperGroupChannelUnreadCount=i.DEFAULT_MAX_UNREAD_COUNT_OF_SUPER_GROUP_CHANNEL,this.useMemberInfoInMessage=p.useMemberInfoInMessage,this.typingIndicatorInvalidateTime=p.typingIndicatorInvalidateTime,this.typingIndicatorThrottle=p.typingIndicatorThrottle,this.concurrentCallLimit=void 0,this.backOffDelay=void 0;const S=this.dispatcher=new x,m=new N;this.requestQueue=new qn(e,{session:m,sdkState:E,dispatcher:S,logger:g,useFetchCompat:t.useFetchCompat}),this.sessionManager=new Bn({session:m,cacheContext:v,sdkState:E,dispatcher:S,requestQueue:this.requestQueue,logger:g}),this.connectionManager=new jn(e,{sdkState:E,cacheContext:this.cacheContext,connectionHandlers:this.connectionHandlers,dispatcher:S,sessionManager:this.sessionManager,websocketClient:this.requestQueue.commandRouter.websocketClient,disableWebSocketCloseEventHandling:null!==(h=t.disableWebSocketCloseEventHandling)&&void 0!==h&&h,logger:g}),this.statLogCollector=new Xn({cacheContext:this.cacheContext,requestQueue:this.requestQueue,dispatcher:S}),this.appStateToggleEnabled=null===(u=t.appStateToggleEnabled)||void 0===u||u}return eo[e]}static of(e){if(eo[e])return eo[e];throw o.lostInstance}static clear(e){eo[e]&&delete eo[e]}hasExtension(e){return this.sdkState.extensions&&this.sdkState.extensions[e]}}var so;exports.PollStatus=void 0,(so=exports.PollStatus||(exports.PollStatus={})).OPEN="open",so.CLOSED="closed";const io=e=>{switch(e){case"open":return exports.PollStatus.OPEN;case"closed":return exports.PollStatus.CLOSED;default:return null}},no=e=>!e||!!e.text&&l("string",e.text);class oo extends on{constructor(e,t){var s,i,n,o,r,a,l;super(e),this.pollId=0,this.id=0,this.text=null,this.voteCount=0,this.createdBy=null,this.createdAt=0,this.updatedAt=0,this._lastVotedAt=0,this.pollId=null!==(s=t.poll_id)&&void 0!==s?s:0,this.id=null!==(i=t.id)&&void 0!==i?i:0,this.text=null!==(n=t.text)&&void 0!==n?n:null,this.voteCount=null!==(o=t.vote_count)&&void 0!==o?o:0,this.createdBy=null!==(r=t.created_by)&&void 0!==r?r:null,this.createdAt=null!==(a=t.created_at)&&void 0!==a?a:0,this.updatedAt=null!==(l=t.updated_at)&&void 0!==l?l:0}static payloadify(e){return k(O(Object.assign(Object.assign({},super.payloadify(e)),{vote_count:e.voteCount,poll_id:e.pollId,text:e.text,created_at:e.createdAt,id:e.id,created_by:e.createdBy,updated_at:e.updatedAt})))}}class ro extends on{constructor(e,t){var s,i,n,o,r,a,l,d,c,h,u,_,p;super(e),this.id=0,this.title=null,this.createdAt=0,this.updatedAt=0,this.closeAt=-1,this.status=exports.PollStatus.CLOSED,this.messageId=0,this.data=null,this.voterCount=-1,this.options=[],this.createdBy=null,this.allowUserSuggestion=!1,this.allowMultipleVotes=!1,this.votedPollOptionIds=[],this.id=null!==(s=t.id)&&void 0!==s?s:0,this.title=null!==(i=t.title)&&void 0!==i?i:null,this.createdAt=null!==(n=t.created_at)&&void 0!==n?n:0,this.updatedAt=null!==(o=t.updated_at)&&void 0!==o?o:0,this.closeAt=null!==(r=t.close_at)&&void 0!==r?r:-1,this.status=null!==(a=io(t.status))&&void 0!==a?a:exports.PollStatus.CLOSED,this.messageId=null!==(l=t.message_id)&&void 0!==l?l:0,this.data=null!==(d=t.data)&&void 0!==d?d:null,this.voterCount=null!==(c=t.voter_count)&&void 0!==c?c:-1,this.options=t.options?t.options.map((e=>new oo(this._iid,e))):[],this.createdBy=null!==(h=t.created_by)&&void 0!==h?h:null,this.allowUserSuggestion=null!==(u=t.allow_user_suggestion)&&void 0!==u&&u,this.allowMultipleVotes=null!==(_=t.allow_multiple_votes)&&void 0!==_&&_,this.votedPollOptionIds=null!==(p=t.voted_option_ids)&&void 0!==p?p:[]}_applyPollUpdatePayload(e){var t,s,i,n,o,r,a,l;this.title=null!==(t=e.title)&&void 0!==t?t:this.title,this.updatedAt=null!==(s=e.updated_at)&&void 0!==s?s:this.updatedAt,this.closeAt=null!==(i=e.close_at)&&void 0!==i?i:this.closeAt,this.status=null!==(n=io(e.status))&&void 0!==n?n:this.status,this.data=null!==(o=e.data)&&void 0!==o?o:this.data,this.voterCount=null!==(r=e.voter_count)&&void 0!==r?r:this.voterCount,e.options&&(this.options=e.options.map((e=>new oo(this._iid,e))),this.votedPollOptionIds=e.options.filter((e=>e.vote_count>0)).map((e=>e.id))),this.allowUserSuggestion=null!==(a=e.allow_user_suggestion)&&void 0!==a?a:this.allowUserSuggestion,this.allowMultipleVotes=null!==(l=e.allow_multiple_votes)&&void 0!==l?l:this.allowMultipleVotes}static payloadify(e){return k(O(Object.assign(Object.assign({},super.payloadify(e)),{id:e.id,title:e.title,created_at:e.createdAt,updated_at:e.updatedAt,close_at:e.closeAt,status:e.status,message_id:e.messageId,data:e.data,voter_count:e.voterCount,options:e.options.map((e=>oo.payloadify(e))),created_by:e.createdBy,allow_user_suggestion:e.allowUserSuggestion,allow_multiple_votes:e.allowMultipleVotes,voted_option_ids:e.votedPollOptionIds})))}applyPollUpdateEvent(e){const t=e._payload.poll;return!(!t||this.id!==t.id||t.updated_ate.id)),i=e._payload,n=Math.floor(i.ts/1e3);return i.updated_vote_counts.forEach((e=>{const i=s.indexOf(e.option_id);if(i>-1){const s=t[i];n>=s._lastVotedAt&&(s.voteCount=e.vote_count,s._lastVotedAt=n)}})),i.req_id&&i.voted_option_ids&&(this.votedPollOptionIds=i.voted_option_ids),"number"==typeof i.voter_count&&(this.voterCount=i.voter_count),!0}serialize(){return un(this)}}var ao;exports.CollectionEventSource=void 0,(ao=exports.CollectionEventSource||(exports.CollectionEventSource={})).UNKNOWN="UNKNOWN",ao.EVENT_CHANNEL_CREATED="EVENT_CHANNEL_CREATED",ao.EVENT_CHANNEL_UPDATED="EVENT_CHANNEL_UPDATED",ao.EVENT_CHANNEL_DELETED="EVENT_CHANNEL_DELETED",ao.EVENT_CHANNEL_READ="EVENT_CHANNEL_READ",ao.EVENT_CHANNEL_DELIVERED="EVENT_CHANNEL_DELIVERED",ao.EVENT_CHANNEL_INVITED="EVENT_CHANNEL_INVITED",ao.EVENT_CHANNEL_JOINED="EVENT_CHANNEL_JOINED",ao.EVENT_CHANNEL_LEFT="EVENT_CHANNEL_LEFT",ao.EVENT_CHANNEL_ACCEPTED_INVITE="EVENT_CHANNEL_ACCEPTED_INVITE",ao.EVENT_CHANNEL_DECLINED_INVITE="EVENT_CHANNEL_DECLINED_INVITE",ao.EVENT_CHANNEL_OPERATOR_UPDATED="EVENT_CHANNEL_OPERATOR_UPDATED",ao.EVENT_CHANNEL_BANNED="EVENT_CHANNEL_BANNED",ao.EVENT_CHANNEL_UNBANNED="EVENT_CHANNEL_UNBANNED",ao.EVENT_CHANNEL_MUTED="EVENT_CHANNEL_MUTED",ao.EVENT_CHANNEL_UNMUTED="EVENT_CHANNEL_UNMUTED",ao.EVENT_CHANNEL_FROZEN="EVENT_CHANNEL_FROZEN",ao.EVENT_CHANNEL_UNFROZEN="EVENT_CHANNEL_UNFROZEN",ao.EVENT_CHANNEL_HIDDEN="EVENT_CHANNEL_HIDDEN",ao.EVENT_CHANNEL_UNHIDDEN="EVENT_CHANNEL_UNHIDDEN",ao.EVENT_CHANNEL_RESET_HISTORY="EVENT_CHANNEL_RESET_HISTORY",ao.EVENT_CHANNEL_TYPING_STATUS_UPDATE="EVENT_CHANNEL_TYPING_STATUS_UPDATE",ao.EVENT_CHANNEL_MEMBER_COUNT_UPDATED="EVENT_CHANNEL_MEMBER_COUNT_UPDATED",ao.EVENT_CHANNEL_METADATA_CREATED="EVENT_CHANNEL_METADATA_CREATED",ao.EVENT_CHANNEL_METADATA_UPDATED="EVENT_CHANNEL_METADATA_UPDATED",ao.EVENT_CHANNEL_METADATA_DELETED="EVENT_CHANNEL_METADATA_DELETED",ao.EVENT_CHANNEL_METACOUNTER_CREATED="EVENT_CHANNEL_METACOUNTER_CREATED",ao.EVENT_CHANNEL_METACOUNTER_UPDATED="EVENT_CHANNEL_METACOUNTER_UPDATED",ao.EVENT_CHANNEL_METACOUNTER_DELETED="EVENT_CHANNEL_METACOUNTER_DELETED",ao.EVENT_MESSAGE_SENT="EVENT_MESSAGE_SENT",ao.EVENT_MESSAGE_RECEIVED="EVENT_MESSAGE_RECEIVED",ao.EVENT_MESSAGE_UPDATED="EVENT_MESSAGE_UPDATED",ao.EVENT_PINNED_MESSAGE_UPDATED="EVENT_PINNED_MESSAGE_UPDATED",ao.REQUEST_CHANNEL="REQUEST_CHANNEL",ao.REQUEST_CHANNEL_CHANGELOGS="REQUEST_CHANNEL_CHANGELOGS",ao.REFRESH_CHANNEL="REFRESH_CHANNEL",ao.CHANNEL_LASTACCESSEDAT_UPDATED="CHANNEL_LASTACCESSEDAT_UPDATED",ao.SYNC_CHANNEL_BACKGROUND="SYNC_CHANNEL_BACKGROUND",ao.SYNC_CHANNEL_CHANGELOGS="SYNC_CHANNEL_CHANGELOGS",ao.EVENT_MESSAGE_SENT_SUCCESS="EVENT_MESSAGE_SENT_SUCCESS",ao.EVENT_MESSAGE_SENT_FAILED="EVENT_MESSAGE_SENT_FAILED",ao.EVENT_MESSAGE_SENT_PENDING="EVENT_MESSAGE_SENT_PENDING",ao.EVENT_MESSAGE_DELETED="EVENT_MESSAGE_DELETED",ao.EVENT_MESSAGE_READ="EVENT_MESSAGE_READ",ao.EVENT_MESSAGE_DELIVERED="EVENT_MESSAGE_DELIVERED",ao.EVENT_MESSAGE_REACTION_UPDATED="EVENT_MESSAGE_REACTION_UPDATED",ao.EVENT_MESSAGE_THREADINFO_UPDATED="EVENT_MESSAGE_THREADINFO_UPDATED",ao.EVENT_MESSAGE_OFFSET_UPDATED="EVENT_MESSAGE_OFFSET_UPDATED",ao.REQUEST_MESSAGE="REQUEST_MESSAGE",ao.EVENT_POLL_UPDATED="EVENT_POLL_UPDATED",ao.EVENT_POLL_VOTED="EVENT_POLL_VOTED",ao.SYNC_POLL_CHANGELOGS="SYNC_POLL_CHANGELOGS",ao.REQUEST_RESEND_MESSAGE="REQUEST_RESEND_MESSAGE",ao.REQUEST_THREADED_MESSAGE="REQUEST_THREADED_MESSAGE",ao.REQUEST_MESSAGE_CHANGELOGS="REQUEST_MESSAGE_CHANGELOGS",ao.SYNC_MESSAGE_FILL="SYNC_MESSAGE_FILL",ao.SYNC_MESSAGE_BACKGROUND="SYNC_MESSAGE_BACKGROUND",ao.SYNC_MESSAGE_CHANGELOGS="SYNC_MESSAGE_CHANGELOGS",ao.LOCAL_MESSAGE_PENDING_CREATED="LOCAL_MESSAGE_PENDING_CREATED",ao.LOCAL_MESSAGE_FAILED="LOCAL_MESSAGE_FAILED",ao.LOCAL_MESSAGE_CANCELED="LOCAL_MESSAGE_CANCELED",ao.LOCAL_MESSAGE_RESEND_STARTED="LOCAL_MESSAGE_RESEND_STARTED";const lo=Object.assign({},exports.CollectionEventSource);class co extends I{constructor({polls:e,source:t}){super(),this.polls=e,this.source=t}}class ho{constructor(e,t){var s;this.limit=20,this._isLoading=!1,this._hasNext=!0,this._token="",this._iid=e,this.limit=null!==(s=t.limit)&&void 0!==s?s:20}get hasNext(){return this._hasNext}get isLoading(){return this._isLoading}_validate(){return l("number",this.limit)&&this.limit>0}}class uo extends ho{constructor(e,t,s,i){super(e,i),this.channelUrl=t,this.channelType=s}_validate(){return super._validate()&&l("string",this.channelUrl)&&d(exports.ChannelType,this.channelType)}}class _o extends de{constructor({title:e,optionTexts:t,data:s,allowUserSuggestion:i,allowMultipleVotes:n,closeAt:o}){super(),this.method=exports.APIRequestMethod.POST,this.path=J,this.params={title:e,options:t,data:s,allow_user_suggestion:i,allow_multiple_votes:n,close_at:o}}}class po extends ce{constructor(e,t){super(e,t),this.poll=new ro(e,t)}}class Eo extends de{constructor({channelUrl:e,channelType:t,pollId:s}){super(),this.method=exports.APIRequestMethod.GET,this.path=`${J}/${encodeURIComponent(s)}`,this.params={channel_url:e,channel_type:t}}}class fo extends ce{constructor(e,t){super(e,t),this.poll=new ro(e,t)}}class go extends de{constructor({channelUrl:e,channelType:t,pollId:s,pollOptionId:i}){super(),this.method=exports.APIRequestMethod.GET,this.path=`${J}/${encodeURIComponent(s)}/options/${encodeURIComponent(i)}`,this.params={channel_url:e,channel_type:t}}}class vo extends ce{constructor(e,t){super(e,t),this.pollOption=new oo(e,t)}}class So extends de{constructor({channelType:e,channelUrl:t,timestamp:s,token:i}){super(),this.method=exports.APIRequestMethod.GET,this.path=`${ne(e)}/${encodeURIComponent(t)}/polls/changelogs`,this.params=k({change_ts:s,token:i})}}class mo extends ce{constructor(e,t){super(e,t),this.updatedPolls=t.updated.map((t=>((e,t)=>new ro(e,t))(e,t))),this.deletedPollIds=t.deleted.map((e=>e)),this.hasMore=t.has_more,this.nextToken=t.next}}const To={title:"",optionTexts:[],data:void 0,allowUserSuggestion:void 0,allowMultipleVotes:void 0,closeAt:-1},Co=e=>{return l("string",e.title)&&(t=e.optionTexts,h("string",t)&&t.every((e=>""!==e.trim())))&&no(e.data)&&l("boolean",e.allowUserSuggestion,!0)&&l("boolean",e.allowMultipleVotes,!0)&&l("number",e.closeAt,!0);var t},yo={channelUrl:"",channelType:exports.ChannelType.BASE,pollId:0,pollOptionId:0},No=e=>l("string",e.channelUrl)&&""!==e.channelUrl&&d(exports.ChannelType,e.channelType)&&l("number",e.pollId)&&e.pollId>0&&l("number",e.pollOptionId)&&e.pollOptionId>0,Ao={channelUrl:"",channelType:exports.ChannelType.BASE,pollId:0},wo=e=>l("string",e.channelUrl)&&""!==e.channelUrl&&d(exports.ChannelType,e.channelType)&&l("number",e.pollId),bo={};class xo extends de{constructor({channelUrl:e,channelType:t,token:s,limit:i}){super(),this.method=exports.APIRequestMethod.GET,this.path=J,this.params={channel_url:e,channel_type:t,token:s,limit:i}}}class Io extends ce{constructor(e,t){var s;super(e,t),this.polls=(null!==(s=t.polls)&&void 0!==s?s:[]).map((t=>new ro(e,t))),this.token=t.next}}class ko extends de{constructor({channelUrl:e,channelType:t,pollId:s,pollOptionId:i,token:n,limit:o}){super(),this.method=exports.APIRequestMethod.GET,this.path=`${J}/${encodeURIComponent(s)}/options/${encodeURIComponent(i)}/voters`,this.params={channel_url:e,channel_type:t,token:n,limit:o}}}class Oo extends ce{constructor(e,t){var s;super(e,t),this.voters=(null!==(s=t.voters)&&void 0!==s?s:[]).map((t=>new fn(e,t))),this.token=t.next}}exports.APIRequestCommand=de,exports.APIResponseCommand=ce,exports.API_PATH_EMOJIS=Y,exports.API_PATH_EMOJI_CATEGORIES=X,exports.API_PATH_GROUP_CHANNELS=B,exports.API_PATH_GROUP_CHANNELS_INTERNAL=j,exports.API_PATH_NOTIFICATIONS=ie,exports.API_PATH_OPEN_CHANNELS=$,exports.API_PATH_OPEN_CHANNELS_INTERNAL=Q,exports.API_PATH_POLLS=J,exports.API_PATH_REPORT=Z,exports.API_PATH_SCHEDULED_MESSAGES=ee,exports.API_PATH_SEARCH=W,exports.API_PATH_UIKIT_CONFIGURATION=te,exports.API_PATH_UPLOAD=K,exports.API_PATH_USERS=G,exports.BaseCommand=I,exports.BaseListQuery=ho,exports.CachedChannelInfo=class{constructor({channel:e,cachedMessageCount:t}){this._cachedMessageCount=0,this._channel=e,this._cachedMessageCount=t}get channel(){return this._channel}get cachedMessageCount(){return this._cachedMessageCount}},exports.ChannelDataListQuery=uo,exports.ConnectionStateChangeCommand=ji,exports.DEFAULT_ENCRYPTION=p,exports.DEFAULT_MULTIPLE_FILES_MESSAGE_FILE_COUNT_LIMIT=5,exports.DailyRecordStatLog=$n,exports.Deferred=Ce,exports.EventDispatcher=b,exports.InstancedObject=on,exports.LocalCacheConfig=C,exports.MessageEventSource=lo,exports.MessageRemoveEventCommand=class extends I{constructor({messageIds:e,source:t,isWebSocketEventComing:s=!1}){super(),this.messageIds=e,this.source=t,this.isWebSocketEventComing=s}},exports.MessageUpdateEventCommand=class extends I{constructor({messages:e,source:t,isWebSocketEventComing:s=!1}){super(),this.messages=e,this.source=t,this.isWebSocketEventComing=s}},exports.Module=class{init(e,{sdkState:t,dispatcher:s,sessionManager:i,requestQueue:n,logger:o,onlineDetector:r,cacheContext:a}){this._iid=e,this._cacheContext=a,this._sdkState=t,this._dispatcher=s,this._sessionManager=i,this._requestQueue=n,this._logger=o}},exports.NotificationInfo=en,exports.POLL_REMOVED_STATUS="removed",exports.Poll=ro,exports.PollChangeLogEventCommand=co,exports.PollCreateParamsDefault=To,exports.PollListQuery=class extends uo{constructor(e,t){super(e,t.channelUrl,t.channelType,t)}next(){return e(this,void 0,void 0,(function*(){if(this._validate()){if(this._isLoading)throw o.queryInProgress;if(this._hasNext){this._isLoading=!0;const{requestQueue:e}=to.of(this._iid),t=new xo(Object.assign(Object.assign({},this),{token:this._token})),s=yield e.send(t),{polls:i,token:n}=s.as(Io);return this._token=n,this._hasNext=!!n,this._isLoading=!1,i}return[]}throw o.invalidParameters}))}},exports.PollManager=class{constructor(e,{sdkState:t,dispatcher:s,sessionManager:i,requestQueue:n,logger:o}){this._iid=e,this._sdkState=t,this._sessionManager=i,this._requestQueue=n,this._dispatcher=s,this._logger=o,bo[e]=this}static of(e){return bo[e]}buildPollFromSerializedData(e){const t=_n(e);return new ro(this._iid,ro.payloadify(t))}get(t){return e(this,void 0,void 0,(function*(){pn(wo(t)).throw(o.invalidParameters);const e=new Eo(Object.assign({},t)),s=yield this._requestQueue.send(e),{poll:i}=s.as(fo);return i}))}create(t){return e(this,void 0,void 0,(function*(){pn(Co(t)).throw(o.invalidParameters);const e=new _o(Object.assign({},t)),s=yield this._requestQueue.send(e),{poll:i}=s.as(po);return i}))}getOption(t){return e(this,void 0,void 0,(function*(){pn(No(t)).throw(o.invalidParameters);const e=new go(Object.assign({},t)),s=yield this._requestQueue.send(e),{pollOption:i}=s.as(vo);return i}))}getPollChangeLogs(t,s,i,n=exports.CollectionEventSource.SYNC_POLL_CHANGELOGS){return e(this,void 0,void 0,(function*(){const e=new So(O({channelType:s,channelUrl:t,timestamp:"number"==typeof i?i:null,token:"string"==typeof i?i:null})),o=yield this._requestQueue.send(e),{updatedPolls:r,deletedPollIds:a,hasMore:l,nextToken:d}=o.as(mo);return r.length>0&&this._dispatcher.dispatch(new co({polls:r,source:n})),{updatedPolls:r,deletedPollIds:a,hasMore:l,token:d}}))}},exports.PollOption=oo,exports.PollOptionRetrievalParamsDefault=yo,exports.PollRetrievalParamsDefault=Ao,exports.PollUpdateInternalEventCommand=class extends I{constructor({event:e,source:t}){super(),this.event=e,this.source=t}},exports.PollVoteEvent=class{constructor(e){this.pollId=0,this.messageId=0,this.pollId=e.poll_id,this.messageId=e.message_id,this._payload=e}},exports.PollVoteInternalEventCommand=class extends I{constructor({event:e,source:t}){super(),this.event=e,this.source=t}},exports.PollVoterListQuery=class extends uo{constructor(e,t){super(e,t.channelUrl,t.channelType,t),this.pollId=t.pollId,this.pollOptionId=t.pollOptionId}_validate(){return super._validate()&&l("number",this.pollId)&&l("number",this.pollOptionId)}next(){return e(this,void 0,void 0,(function*(){if(this._validate()){if(this._isLoading)throw o.queryInProgress;if(this._hasNext){this._isLoading=!0;const{requestQueue:e}=to.of(this._iid),t=new ko(Object.assign(Object.assign({},this),{pollId:this.pollId,pollOptionId:this.pollOptionId,token:this._token})),s=yield e.send(t),{voters:i,token:n}=s.as(Oo);return this._token=n,this._hasNext=!!n,this._isLoading=!1,i}return[]}throw o.invalidParameters}))}},exports.SEMVER_REGEX_STRING="^(0|[1-9]\\d*)\\.(0|[1-9]\\d*)\\.(0|[1-9]\\d*)(?:-((?:0|[1-9]\\d*|\\d*[a-zA-Z-][0-9a-zA-Z-]*)(?:\\.(?:0|[1-9]\\d*|\\d*[a-zA-Z-][0-9a-zA-Z-]*))*))?(?:\\+([0-9a-zA-Z-]+(?:\\.[0-9a-zA-Z-]+)*))?$",exports.SendbirdChatOptions=_,exports.SendbirdError=o,exports.SessionExpiredCommand=ue,exports.StatLog=Ee,exports.SubscribedUnreadMessageCountUpdateCommand=Ki,exports.UIKitConfigInfo=tn,exports.UnsentMessageRemoveEventCommand=class extends I{constructor({reqId:e,source:t}){super(),this.reqId=e,this.source=t}},exports.User=fn,exports.UserProfile=vn,exports.UserProfileUpdateCommand=gn,exports.Vault=to,exports.WebSocketEventCommand=Ne,exports.WebSocketRequestCommand=Gi,exports.__awaiter=e,exports.__rest=function(e,t){var s={};for(var i in e)Object.prototype.hasOwnProperty.call(e,i)&&t.indexOf(i)<0&&(s[i]=e[i]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var n=0;for(i=Object.getOwnPropertySymbols(e);n{var i,n,o,r;const a=oe(null!==(i=e.mentionType)&&void 0!==i?i:null,null!==(n=e.mentionedUserIds)&&void 0!==n?n:[],s),l=oe(null!==(o=t.mentionType)&&void 0!==o?o:null,null!==(r=t.mentionedUserIds)&&void 0!==r?r:[],s);return!a&&l?1:a&&!l?-1:0},exports.checkIfMentioned=oe,exports.createChangelogIncludeChatNotificationsCacheKey=e=>`sendbird@${e}/changelog_include_chat_notifications`,exports.deepEqual=(e,t)=>{if(e!==t){const s=Object.assign({},e),i=Object.assign({},t);return(!s.hasOwnProperty("messageId")||!i.hasOwnProperty("messageId")||s.messageId===i.messageId)&&((!s.hasOwnProperty("reqId")||!i.hasOwnProperty("reqId")||s.reqId===i.reqId)&&(s.hasOwnProperty("messageId")&&delete s.messageId,s.hasOwnProperty("reqId")&&delete s.reqId,i.hasOwnProperty("messageId")&&delete i.messageId,i.hasOwnProperty("reqId")&&delete i.reqId,JSON.stringify(s)===JSON.stringify(i)))}return!0},exports.deserialize=_n,exports.deundefined=k,exports.getChannelApiPathByType=ne,exports.getReportApiPathByType=e=>{switch(e){case exports.ChannelType.GROUP:return`${Z}/group_channels`;case exports.ChannelType.OPEN:return`${Z}/open_channels`;default:return null}},exports.hasSameMembers=(e,t)=>{if(e===t)return!0;if(null==e||null==t)return!1;if(e.length!==t.length)return!1;const s=[...e].sort(),i=[...t].sort();for(let e=0;ee>0&&a.indexOf(e)>=0,exports.isEnumOf=d,exports.isFile=u,exports.isMilliSecondOf=(e,t=!1)=>!(!t||void 0!==e)||"number"==typeof e&&13===e.toString().length,exports.isReactNative=fe,exports.isResendableError=e=>e>0&&r.indexOf(e)>=0,exports.isThrowingOutside=n,exports.isTypeOf=l,exports.noop=Ae,exports.parsePollStatusPayload=io,exports.runAsCallback=Tn,exports.runOrNothing=t=>e(void 0,void 0,void 0,(function*(){try{yield t()}catch(e){}})),exports.serialize=un,exports.shouldGiveEvent=e=>e.startsWith("EVENT_")||e.startsWith("LOCAL_MESSAGE_")||e===exports.CollectionEventSource.SYNC_MESSAGE_FILL||e===exports.CollectionEventSource.SYNC_MESSAGE_CHANGELOGS||e===exports.CollectionEventSource.SYNC_POLL_CHANGELOGS,exports.sleep=An,exports.undefineNullProps=O,exports.unless=pn,exports.uuid=A,exports.validatePollCreateParams=Co,exports.validatePollData=no,exports.validatePollOptionRetrievalParams=No,exports.validatePollRetrievalParams=wo,exports.version=s;
diff --git a/cjs/lib/__bundle-83a2a2d5.js b/cjs/lib/__bundle-83a2a2d5.js
deleted file mode 100644
index 591956e..0000000
--- a/cjs/lib/__bundle-83a2a2d5.js
+++ /dev/null
@@ -1 +0,0 @@
-"use strict";var e,t,s,n,i,a,r,o,l,d=require("./__bundle-fc8b8d13.js"),h=require("./__bundle-92ec8a78.js"),c=require("./__bundle-752a7a52.js"),u=require("./__bundle-dec6de91.js");exports.MemberState=void 0,(e=exports.MemberState||(exports.MemberState={})).NONE="none",e.JOINED="joined",e.INVITED="invited",e.LEFT="left";class _ extends h.RestrictedUser{constructor(e,t){super(e,t),this.state=null,this.role=null,this.isMuted=!1,this.isBlockedByMe=!1,this.isBlockingMe=!1,this.state=d.isEnumOf(exports.MemberState,t.state)?t.state:null,this.role=d.isEnumOf(d.Role,t.role)?t.role:null,"boolean"==typeof t.is_muted&&(this.isMuted=t.is_muted),"boolean"==typeof t.is_blocked_by_me&&(this.isBlockedByMe=t.is_blocked_by_me),"boolean"==typeof t.is_blocking_me&&(this.isBlockingMe=t.is_blocking_me)}static payloadify(e){return d.deundefined(d.undefineNullProps(Object.assign(Object.assign({},super.payloadify(e)),{state:e.state,role:e.role,is_muted:e.isMuted,is_blocked_by_me:e.isBlockedByMe,is_blocking_me:e.isBlockingMe})))}}class p extends d.InstancedObject{constructor(e,t){var s,n;super(e),this.channelUrl=null!==(s=t.channel_url)&&void 0!==s?s:"",this.channelType=null!==(n=t.channel_type)&&void 0!==n?n:d.ChannelType.GROUP,this.reader=new d.User(this._iid,t.user),this.readAt=t.ts}}exports.PublicChannelFilter=void 0,(t=exports.PublicChannelFilter||(exports.PublicChannelFilter={})).ALL="all",t.PUBLIC="public",t.PRIVATE="private",exports.MyMemberStateFilter=void 0,(s=exports.MyMemberStateFilter||(exports.MyMemberStateFilter={})).ALL="all",s.JOINED="joined_only",s.INVITED="invited_only",s.INVITED_BY_FRIEND="invited_by_friend",s.INVITED_BY_NON_FRIEND="invited_by_non_friend",exports.SuperChannelFilter=void 0,(n=exports.SuperChannelFilter||(exports.SuperChannelFilter={})).ALL="all",n.SUPER="super",n.NON_SUPER="nonsuper",n.BROADCAST_ONLY="broadcast_only",n.EXCLUSIVE_ONLY="exclusive_only",exports.UnreadChannelFilter=void 0,(i=exports.UnreadChannelFilter||(exports.UnreadChannelFilter={})).ALL="all",i.UNREAD_MESSAGE="unread_message",exports.HiddenChannelFilter=void 0,(a=exports.HiddenChannelFilter||(exports.HiddenChannelFilter={})).ALL="all",a.UNHIDDEN="unhidden_only",a.HIDDEN="hidden_only",a.HIDDEN_ALLOW_AUTO_UNHIDE="hidden_allow_auto_unhide",a.HIDDEN_PREVENT_AUTO_UNHIDE="hidden_prevent_auto_unhide",exports.OperatorFilter=void 0,(r=exports.OperatorFilter||(exports.OperatorFilter={})).ALL="all",r.OPERATOR="operator",r.NONOPERATOR="nonoperator",exports.QueryType=void 0,(o=exports.QueryType||(exports.QueryType={})).AND="AND",o.OR="OR",exports.GroupChannelSearchField=void 0,(l=exports.GroupChannelSearchField||(exports.GroupChannelSearchField={})).MEMBER_NICKNAME="member_nickname",l.CHANNEL_NAME="channel_name";class m{constructor(){this._searchFilter=null,this._userIdsFilter=null,this.includeEmpty=!1,this.nicknameContainsFilter=null,this.nicknameStartsWithFilter=null,this.nicknameExactMatchFilter=null,this.channelNameContainsFilter="",this.myMemberStateFilter=exports.MyMemberStateFilter.ALL,this.customTypesFilter=null,this.channelUrlsFilter=null,this.superChannelFilter=exports.SuperChannelFilter.ALL,this.publicChannelFilter=exports.PublicChannelFilter.ALL,this.customTypeStartsWithFilter=null,this.unreadChannelFilter=exports.UnreadChannelFilter.ALL,this.hiddenChannelFilter=exports.HiddenChannelFilter.UNHIDDEN,this.includeFrozen=!0}_isFriend(e){return!(!e||!e.friendDiscoveryKey&&!e.friendName)}get searchFilter(){return this._searchFilter}setSearchFilter(e,t){Array.isArray(e)&&0!==e.length&&"string"==typeof t&&t&&(this._searchFilter={query:t,fields:e})}get userIdsFilter(){return this._userIdsFilter}setUserIdsFilter(e,t,s=exports.QueryType.AND){this._userIdsFilter={userIds:e,includeMode:t,queryType:s}}clone(){var e;const t=new m;this.searchFilter&&t.setSearchFilter(this.searchFilter.fields,null!==(e=this.searchFilter.query)&&void 0!==e?e:void 0),this.userIdsFilter&&t.setUserIdsFilter(this.userIdsFilter.userIds,this.userIdsFilter.includeMode,this.userIdsFilter.queryType);const s=JSON.parse(JSON.stringify(this));return Object.keys(s).forEach((e=>{t[e]=s[e]})),t}match(e,t){if(this._searchFilter){const{query:t,fields:s}=this._searchFilter;if(t&&s&&s.length>0&&!s.some((s=>{switch(s){case exports.GroupChannelSearchField.CHANNEL_NAME:return e.name.toLowerCase().includes(t.toLowerCase());case exports.GroupChannelSearchField.MEMBER_NICKNAME:return e.members.some((e=>e.nickname.toLowerCase().includes(t.toLowerCase())));default:return!0}})))return!1}if(this._userIdsFilter){const{userIds:s,includeMode:n,queryType:i}=this._userIdsFilter,a=e.members.map((e=>e.userId));if(n){if(s.length>0)switch(i){case exports.QueryType.AND:if(s.some((e=>!a.includes(e))))return!1;break;case exports.QueryType.OR:if(s.every((e=>!a.includes(e))))return!1}}else{if(s.includes(t)||s.push(t),e.members.length>s.length)return!1;if(!d.hasSameMembers(s,a))return!1}}if(!this.includeEmpty&&!e.lastMessage)return!1;if(!this.includeFrozen&&e.isFrozen)return!1;if(this.customTypesFilter&&this.customTypesFilter.length>0&&!this.customTypesFilter.includes("*")&&!this.customTypesFilter.includes(e.customType))return!1;if(this.customTypeStartsWithFilter&&!new RegExp(`^${this.customTypeStartsWithFilter}`).test(e.customType))return!1;if(this.channelNameContainsFilter&&!e.name.toLowerCase().includes(this.channelNameContainsFilter.toLowerCase()))return!1;if(this.nicknameContainsFilter){const s=this.nicknameContainsFilter.toLowerCase();if(!e.members.some((e=>e.userId!==t&&e.nickname.toLowerCase().includes(s))))return!1}if(this.nicknameStartsWithFilter){const s=this.nicknameStartsWithFilter.toLowerCase();if(!e.members.some((e=>e.userId!==t&&e.nickname.toLowerCase().startsWith(s))))return!1}if(this.nicknameExactMatchFilter){const s=this.nicknameExactMatchFilter.toLowerCase();if(!e.members.some((e=>e.userId!==t&&e.nickname.toLowerCase()!=s)))return!1}if(this.channelUrlsFilter&&this.channelUrlsFilter.length>0&&!this.channelUrlsFilter.includes(e.url))return!1;if(this.myMemberStateFilter)switch(this.myMemberStateFilter){case exports.MyMemberStateFilter.JOINED:if("joined"!==e.myMemberState)return!1;break;case exports.MyMemberStateFilter.INVITED:if("invited"!==e.myMemberState)return!1;break;case exports.MyMemberStateFilter.INVITED_BY_FRIEND:if("invited"!==e.myMemberState||!this._isFriend(e.inviter))return!1;break;case exports.MyMemberStateFilter.INVITED_BY_NON_FRIEND:if("invited"!==e.myMemberState||this._isFriend(e.inviter))return!1}if(this.hiddenChannelFilter)switch(this.hiddenChannelFilter){case exports.HiddenChannelFilter.UNHIDDEN:if(e.isHidden||"unhidden"!==e.hiddenState)return!1;break;case exports.HiddenChannelFilter.HIDDEN:if(!e.isHidden)return!1;break;case exports.HiddenChannelFilter.HIDDEN_ALLOW_AUTO_UNHIDE:if(!e.isHidden||"hidden_allow_auto_unhide"!==e.hiddenState)return!1;break;case exports.HiddenChannelFilter.HIDDEN_PREVENT_AUTO_UNHIDE:if(!e.isHidden||"hidden_prevent_auto_unhide"!==e.hiddenState)return!1}if(this.unreadChannelFilter&&this.unreadChannelFilter===exports.UnreadChannelFilter.UNREAD_MESSAGE)if(0===e.unreadMessageCount)return!1;if(this.publicChannelFilter)switch(this.publicChannelFilter){case exports.PublicChannelFilter.PUBLIC:if(!e.isPublic)return!1;break;case exports.PublicChannelFilter.PRIVATE:if(e.isPublic)return!1}if(this.superChannelFilter)switch(this.superChannelFilter){case exports.SuperChannelFilter.SUPER:if(!e.isSuper)return!1;break;case exports.SuperChannelFilter.NON_SUPER:if(e.isSuper)return!1}return!(this.createdAfter&&e.createdAtthis.createdBefore)}}class g extends d.InstancedObject{constructor(e,{sdkState:t,cacheContext:s}){super(e),this._channels=new Map,this._sdkState=t,this._cacheContext=s}get collection(){const{nestdb:e}=this._cacheContext;return d.unless(!!e).throw(d.SendbirdError.databaseError),e.collection(h.NESTDB_GROUPCHANNEL_COLLECTION_NAME)}get localCacheEnabled(){const{localCacheEnabled:e}=this._cacheContext;return e&&!!this.collection}_serialize(e,t=0){return Object.assign(Object.assign({},e.serialize()),{lastMessageUpdatedAt:e.lastMessage?e.lastMessage.createdAt:0,syncIndex:t})}_deserialize(e){return Ne.of(this._iid).buildGroupChannelFromSerializedData(e)}get channels(){return[...this._channels.values()]}isCachedInMemory(e){return this._channels.has(e)}filterOffsetChanged(e){return e.filter((e=>{if(this._channels.has(e.url)){return this._channels.get(e.url).messageOffsetTimestamp{if(e)switch(i){case c.GroupChannelListOrder.CHANNEL_NAME_ALPHABETICAL:if(!s&&t.name.localeCompare(e)<0||s&&t.name.localeCompare(e)>0)return!1;if(a&&a===t.url)return!1;break;case c.GroupChannelListOrder.CHRONOLOGICAL:if(!s&&t.createdAt>e||s&&t.createdAte||s&&t.lastMessageUpdatedAtthis._deserialize(e)));return l.forEach((e=>{this._channels.has(e.url)||this._channels.set(e.url,e)})),l}return[]}))}upsert(e,t){return d.__awaiter(this,void 0,void 0,(function*(){const s=[];if(e.forEach((e=>{if(this._channels.has(e.url)){const n=this._channels.get(e.url);n._pinnedMessagesUpdatedAt0&&(yield this.upsert(n))}))}block(e,t){return d.__awaiter(this,void 0,void 0,(function*(){yield this._setBlockStateOfAllChannels(e,t,!0)}))}unblock(e,t){return d.__awaiter(this,void 0,void 0,(function*(){yield this._setBlockStateOfAllChannels(e,t,!1)}))}markAsRead(e,t=[...this._channels.keys()]){return d.__awaiter(this,void 0,void 0,(function*(){const s=[];for(const n of t){const t=yield this.get(n);(null==t?void 0:t._updateUnreadMemberState(this._sdkState.userId,e))&&(t._updateUnreadCount(0,0),s.push(t))}s.length>0&&(yield this.upsert(s))}))}}const C={invitedUserIds:void 0,channelUrl:void 0,coverUrl:void 0,coverImage:void 0,isDistinct:void 0,isSuper:void 0,isBroadcast:void 0,isExclusive:void 0,isPublic:void 0,isDiscoverable:void 0,isStrict:void 0,isEphemeral:void 0,accessCode:void 0,name:void 0,data:void 0,customType:void 0,operatorUserIds:void 0,messageSurvivalSeconds:void 0},E=e=>d.isArrayOf("string",e.invitedUserIds,!0)&&d.isTypeOf("string",e.channelUrl,!0)&&d.isTypeOf("string",e.coverUrl,!0)&&(d.isFile(e.coverImage)||d.isTypeOf("string",e.coverImage,!0))&&d.isTypeOf("boolean",e.isDistinct,!0)&&d.isTypeOf("boolean",e.isSuper,!0)&&d.isTypeOf("boolean",e.isBroadcast,!0)&&d.isTypeOf("boolean",e.isExclusive,!0)&&d.isTypeOf("boolean",e.isPublic,!0)&&d.isTypeOf("boolean",e.isStrict,!0)&&d.isTypeOf("boolean",e.isDiscoverable,!0)&&d.isTypeOf("boolean",e.isEphemeral,!0)&&d.isTypeOf("string",e.accessCode,!0)&&d.isTypeOf("string",e.name,!0)&&d.isTypeOf("string",e.data,!0)&&d.isTypeOf("string",e.customType,!0)&&d.isArrayOf("string",e.operatorUserIds,!0)&&d.isTypeOf("number",e.messageSurvivalSeconds,!0),v={customTypes:void 0,includeEmpty:!1,includeFrozen:!0,includeChatNotification:!1},f=e=>d.isArrayOf("string",e.customTypes,!0)&&d.isTypeOf("boolean",e.includeEmpty)&&d.isTypeOf("boolean",e.includeFrozen)&&d.isTypeOf("boolean",e.includeChatNotification),M={myMemberStateFilter:exports.MyMemberStateFilter.ALL},S=e=>d.isEnumOf(exports.MyMemberStateFilter,e.myMemberStateFilter);var y;exports.UnreadItemKey=void 0,(y=exports.UnreadItemKey||(exports.UnreadItemKey={})).GROUP_CHANNEL_UNREAD_MENTION_COUNT="group_channel_unread_mention_count",y.NONSUPER_UNREAD_MENTION_COUNT="non_super_group_channel_unread_mention_count",y.SUPER_UNREAD_MENTION_COUNT="super_group_channel_unread_mention_count",y.GROUP_CHANNEL_UNREAD_MESSAGE_COUNT="group_channel_unread_message_count",y.NONSUPER_UNREAD_MESSAGE_COUNT="non_super_group_channel_unread_message_count",y.SUPER_UNREAD_MESSAGE_COUNT="super_group_channel_unread_message_count",y.GROUP_CHANNEL_INVITATION_COUNT="group_channel_invitation_count",y.NONSUPER_INVITATION_COUNT="non_super_group_channel_invitation_count",y.SUPER_INVITATION_COUNT="super_group_channel_invitation_count";const A={keys:[]},b={channelCustomTypesFilter:void 0,superChannelFilter:exports.SuperChannelFilter.ALL},N=e=>d.isArrayOf("string",e.channelCustomTypesFilter,!0)&&d.isEnumOf(exports.SuperChannelFilter,e.superChannelFilter),T={channelUrl:void 0,scheduledStatus:void 0,messageTypeFilter:d.MessageTypeFilter.ALL},U=Object.assign({},d.CollectionEventSource),I=e=>e.startsWith("EVENT_")||e===d.CollectionEventSource.SYNC_CHANNEL_CHANGELOGS||e===d.CollectionEventSource.REFRESH_CHANNEL;class P extends d.BaseCommand{constructor({channels:e,source:t,isWebSocketEventComing:s=!1,data:n=null,ts:i}){super(),this.channels=e,this.source=t,this.isWebSocketEventComing=s,this.data=n,this.ts=i}}class x extends d.BaseCommand{constructor({channelUrls:e,source:t,isWebSocketEventComing:s=!1}){super(),this.channelUrls=e,this.source=t,this.isWebSocketEventComing=s}}class O{constructor({groupChannelCache:e,messageCache:t,unsentMessageCache:s,dispatcher:n}){this._observers=new Map,n.on((n=>d.__awaiter(this,void 0,void 0,(function*(){if(n instanceof P){const{channels:s,source:i,isWebSocketEventComing:a,data:r}=n,o=s.filter((e=>e instanceof Lt)),l=e.filterOffsetChanged(o);for(const e of l)yield t.removeUnderOffset(e.url,e.messageOffsetTimestamp);const d=yield e.upsert(o,n.ts);a||this._broadcastUpdateEvent(d,i,r)}else if(n instanceof x){const{channelUrls:i,source:a,isWebSocketEventComing:r}=n;yield e.remove(i),yield d.runOrNothing((()=>d.__awaiter(this,void 0,void 0,(function*(){for(const e of i)yield t.removeMessagesOfChannel(e),yield s.removeMessagesOfChannel(e)})))),r||this._broadcastRemoveEvent(i,a)}else n instanceof c.DatabaseOpenCommand&&(yield e.fetch({token:Number.MAX_SAFE_INTEGER,limit:Number.MAX_SAFE_INTEGER}))}))))}_broadcastUpdateEvent(e,t,s){for(const n of this._observers.values())n.onUpdate&&n.onUpdate(e,t,s)}_broadcastRemoveEvent(e,t){for(const s of this._observers.values())s.onRemove&&s.onRemove(e,t)}subscribe(e,t){this._observers.set(e,t)}unsubscribe(e){this._observers.delete(e)}unsubscribeAll(){this._observers.clear()}}class R extends d.APIRequestCommand{constructor({userId:e,ts:t,token:s,filter:n,includeChatNotification:i=!1}){super();const{customTypes:a,includeEmpty:r,includeFrozen:o}=Object.assign(Object.assign({},v),n);this.method=d.APIRequestMethod.GET,this.path=`${d.API_PATH_USERS}/${encodeURIComponent(e)}/my_group_channels/changelogs`,this.params=d.deundefined(d.undefineNullProps({show_delivery_receipt:!0,show_member:!0,show_read_receipt:!0,change_ts:t||null,token:s,custom_types:a,show_empty:r,show_frozen:o,include_chat_notification:i}))}}class w extends d.APIResponseCommand{constructor(e,t){super(e,t),this.updatedChannels=t.updated.map((s=>new Lt(e,Object.assign(s,{ts:t.ts})))),this.deletedChannelUrls=t.deleted,this.hasMore=t.has_more,this.token=t.next,this.ts=t.ts}}class L extends d.APIRequestCommand{constructor({channelUrl:e,isInternalCall:t}){super(),this.method=d.APIRequestMethod.GET,this.path=`${t?d.API_PATH_GROUP_CHANNELS_INTERNAL:d.API_PATH_GROUP_CHANNELS}/${encodeURIComponent(e)}`,this.params={show_member:!0,show_read_receipt:!0,show_delivery_receipt:!0}}}class F extends d.APIResponseCommand{constructor(e,t){super(e,t),this.channel=new Lt(e,t)}}const D={includeEmpty:!1,includeFrozen:!0,includeMetaData:!0,includeChatNotification:!1,channelUrlsFilter:void 0,customTypesFilter:void 0,customTypeStartsWithFilter:void 0,nicknameContainsFilter:void 0,nicknameStartsWithFilter:void 0,nicknameExactMatchFilter:void 0,channelNameContainsFilter:void 0,myMemberStateFilter:exports.MyMemberStateFilter.ALL,unreadChannelFilter:exports.UnreadChannelFilter.ALL,superChannelFilter:exports.SuperChannelFilter.ALL,publicChannelFilter:exports.PublicChannelFilter.ALL,hiddenChannelFilter:exports.HiddenChannelFilter.ALL,userIdsFilter:{userIds:[],includeMode:!0,queryType:exports.QueryType.AND},searchFilter:{query:void 0,fields:[]},metadataKey:void 0,metadataValues:void 0,metadataOrderKeyFilter:void 0,metadataValueStartsWith:void 0,order:c.GroupChannelListOrder.LATEST_LAST_MESSAGE,createdAfter:void 0,createdBefore:void 0};class k extends d.APIRequestCommand{constructor(e){const{userId:t,token:s,limit:n,order:i,includeEmpty:a,myMemberStateFilter:r,superChannelFilter:o,publicChannelFilter:l,unreadChannelFilter:h,nicknameContainsFilter:c,nicknameStartsWithFilter:u,nicknameExactMatchFilter:_,channelNameContainsFilter:p,channelUrlsFilter:m,customTypesFilter:g,customTypeStartsWithFilter:C,hiddenChannelFilter:E,metadataOrderKeyFilter:v,metadataKey:f,metadataValues:M,metadataValueStartsWith:S,includeFrozen:y,includeMetaData:A,searchFilter:b,userIdsFilter:N,includeChatNotification:T=!1,createdAfter:U,createdBefore:I}=e;super(),this.method=d.APIRequestMethod.GET,this.path=`${d.API_PATH_USERS}/${encodeURIComponent(t)}/my_group_channels`,this.params=d.deundefined({token:s,limit:n,order:null!=i?i:D.order,show_member:!0,show_read_receipt:!0,show_delivery_receipt:!0,show_empty:null!=a?a:D.includeEmpty,member_state_filter:null!=r?r:D.myMemberStateFilter,super_mode:null!=o?o:D.superChannelFilter,public_mode:null!=l?l:D.publicChannelFilter,unread_filter:null!=h?h:D.unreadChannelFilter,members_nickname_contains:c,members_nickname_startswith:u,members_nickname:_,name_contains:p,channel_urls:m,custom_types:g,custom_type_startswith:C,hidden_mode:E,metadata_order_key:v,metadata_key:f,metadata_values:M,metadata_value_startswith:S,show_frozen:y,show_metadata:A,include_chat_notification:T,created_after:U,created_before:I}),b&&b.query&&b.fields&&(this.params.search_query=b.query,this.params.search_fields=b.fields),N&&N.userIds&&N.userIds.length>0&&(N.includeMode?(this.params.members_include_in=N.userIds,this.params.query_type=N.queryType.toUpperCase()):this.params.members_exactly_in=N.userIds)}}class H extends d.APIResponseCommand{constructor(e,t){super(e,t),this.channels=[];const{next:s,channels:n,ts:i}=t;this.token=s,n&&n.length>0&&(this.channels=n.map((t=>(t.ts=i,new Lt(e,t))))),this.ts=null!=i?i:0}}class V extends d.APIRequestCommand{constructor({userId:e,filter:t}){super();const{myMemberStateFilter:s}=t;this.method=d.APIRequestMethod.GET,this.path=`${d.API_PATH_USERS}/${encodeURIComponent(e)}/group_channel_count`,this.params={state:null!=s?s:exports.MyMemberStateFilter.ALL}}}class G extends d.APIResponseCommand{constructor(e,t){super(e,t),this.groupChannelCount=t.group_channel_count}}class q extends d.APIRequestCommand{constructor({userId:e,filter:t}){super();const{keys:s}=t;this.method=d.APIRequestMethod.GET,this.path=`${d.API_PATH_USERS}/${encodeURIComponent(e)}/unread_item_count`,this.params=d.deundefined({item_keys:s})}}class B extends d.APIResponseCommand{constructor(e,t){super(e,t),"number"==typeof t[exports.UnreadItemKey.GROUP_CHANNEL_UNREAD_MENTION_COUNT]&&(this.groupChannelUnreadMentionCount=t[exports.UnreadItemKey.GROUP_CHANNEL_UNREAD_MENTION_COUNT]),"number"==typeof t[exports.UnreadItemKey.GROUP_CHANNEL_UNREAD_MESSAGE_COUNT]&&(this.groupChannelUnreadMessageCount=t[exports.UnreadItemKey.GROUP_CHANNEL_UNREAD_MESSAGE_COUNT]),"number"==typeof t[exports.UnreadItemKey.GROUP_CHANNEL_INVITATION_COUNT]&&(this.groupChannelInvitationCount=t[exports.UnreadItemKey.GROUP_CHANNEL_INVITATION_COUNT]),"number"==typeof t[exports.UnreadItemKey.SUPER_UNREAD_MENTION_COUNT]&&(this.superGroupChannelUnreadMentionCount=t[exports.UnreadItemKey.SUPER_UNREAD_MENTION_COUNT]),"number"==typeof t[exports.UnreadItemKey.SUPER_UNREAD_MESSAGE_COUNT]&&(this.superGroupChannelUnreadMessageCount=t[exports.UnreadItemKey.SUPER_UNREAD_MESSAGE_COUNT]),"number"==typeof t[exports.UnreadItemKey.SUPER_INVITATION_COUNT]&&(this.superGroupChannelInvitationCount=t[exports.UnreadItemKey.SUPER_INVITATION_COUNT]),"number"==typeof t[exports.UnreadItemKey.NONSUPER_UNREAD_MENTION_COUNT]&&(this.nonSuperGroupChannelUnreadMentionCount=t[exports.UnreadItemKey.NONSUPER_UNREAD_MENTION_COUNT]),"number"==typeof t[exports.UnreadItemKey.NONSUPER_UNREAD_MESSAGE_COUNT]&&(this.nonSuperGroupChannelUnreadMessageCount=t[exports.UnreadItemKey.NONSUPER_UNREAD_MESSAGE_COUNT]),"number"==typeof t[exports.UnreadItemKey.NONSUPER_INVITATION_COUNT]&&(this.nonSuperGroupChannelInvitationCount=t[exports.UnreadItemKey.NONSUPER_INVITATION_COUNT])}}class j extends d.APIRequestCommand{constructor({userId:e}){super(),this.method=d.APIRequestMethod.GET,this.path=`${d.API_PATH_USERS}/${encodeURIComponent(e)}/unread_channel_count`}}class z extends d.APIResponseCommand{constructor(e,t){super(e,t),this.unreadCount=t.unread_count}}class W extends d.APIRequestCommand{constructor({userId:e,filter:t,includeFeedChannel:s=!1}){super();const{channelCustomTypesFilter:n,superChannelFilter:i}=t;this.method=d.APIRequestMethod.GET,this.path=`${d.API_PATH_USERS}/${encodeURIComponent(e)}/unread_message_count`,this.params={super_mode:null!=i?i:exports.SuperChannelFilter.ALL,custom_types:n,include_feed_channel:s}}}class $ extends d.APIResponseCommand{constructor(e,t){super(e,t),this.unreadCount=t.unread_count,this.unreadFeedCount=t.unread_feed_count}}class Q extends d.APIRequestCommand{constructor({channelUrl:e,scheduledStatus:t,messageTypeFilter:s}){super(),this.method=d.APIRequestMethod.GET,this.path=`${d.API_PATH_SCHEDULED_MESSAGES}/count`,this.params={channel_url:e,status:Y(t)},s&&(this.params.message_type=s)}}class K extends d.APIResponseCommand{constructor(e,t){super(e,t),this.count=t.count}}const Y=e=>{if(!e)return[];const t=[];return e.forEach((e=>{switch(e){case h.ScheduledStatus.PENDING:t.push(h.InternalScheduledStatus.PENDING);break;case h.ScheduledStatus.SENT:t.push(h.InternalScheduledStatus.IN_QUEUE),t.push(h.InternalScheduledStatus.SENT);break;case h.ScheduledStatus.CANCELED:t.push(h.InternalScheduledStatus.CANCELED);break;case h.ScheduledStatus.FAILED:t.push(h.InternalScheduledStatus.FAILED)}})),t};class J extends d.APIRequestCommand{constructor(e){const{userId:t,channelUrl:s,coverUrl:n,coverImage:i,isDistinct:a,isSuper:r,isBroadcast:o,isPublic:l,isExclusive:h,isDiscoverable:c,isStrict:u,isEphemeral:_,accessCode:p,name:m,data:g,customType:C,messageSurvivalSeconds:E,invitedUserIds:v,operatorUserIds:f}=e;super(),this.method=d.APIRequestMethod.POST,this.path=d.API_PATH_GROUP_CHANNELS,this.params=d.deundefined({user_ids:[t,...null!=v?v:[]].filter(((e,t,s)=>t===s.indexOf(e))),channel_url:s,cover_url:n,cover_file:i,is_distinct:a,is_super:r,is_broadcast:o,is_exclusive:h,is_public:l,is_discoverable:c,strict:u,is_ephemeral:_,access_code:p,name:m,data:g,custom_type:C,operator_ids:f,message_survival_seconds:E})}}class Z extends d.APIResponseCommand{constructor(e,t){var s;super(e,t),this.channel=new Lt(e,t),this.isCreated=null===(s=t.is_created)||void 0===s||s}}class X extends d.APIRequestCommand{constructor({userId:e,channelUrls:t}){super(),this.method=d.APIRequestMethod.PUT,this.path=`${d.API_PATH_USERS}/${encodeURIComponent(e)}/mark_as_read_all`,this.params={channel_urls:t}}}class ee extends d.APIRequestCommand{constructor(e){const{channelUrl:t,userId:s,accessCode:n}=e;super(),this.method=d.APIRequestMethod.PUT,this.path=`${d.API_PATH_GROUP_CHANNELS}/${encodeURIComponent(t)}/join`,this.params={user_id:s,access_code:n}}}class te extends d.APIResponseCommand{constructor(e,t){super(e,t),this.channel=new Lt(e,t)}}class se extends u.ChannelEventCommand{constructor(e,t,s){super(e,t,s);const{member_count:n=0,joined_member_count:i=0,users:a=null}=s.data;this.memberCount=n,this.joinedMemberCount=i,this.members=Array.isArray(a)?a.map((t=>new _(e,t))):[new _(e,s.data)]}}class ne extends d.APIRequestCommand{constructor(e){const{channelUrl:t,userId:s,shouldRemoveOperatorStatus:n}=e;super(),this.method=d.APIRequestMethod.PUT,this.path=`${d.API_PATH_GROUP_CHANNELS}/${encodeURIComponent(t)}/leave`,this.params={user_id:s,should_remove_operator_status:n}}}class ie extends u.ChannelEventCommand{constructor(e,t,s){super(e,t,s);const{member_count:n=0,joined_member_count:i=0}=s.data;this.memberCount=n,this.joinedMemberCount=i,this.member=new _(this._iid,s.data)}}class ae extends d.APIRequestCommand{constructor(e){const{channelUrl:t,userIds:s}=e;super(),this.method=d.APIRequestMethod.POST,this.path=`${d.API_PATH_GROUP_CHANNELS}/${encodeURIComponent(t)}/invite`,this.params={user_ids:s}}}class re extends d.APIResponseCommand{constructor(e,t){super(e,t),this.channel=new Lt(e,t)}}class oe extends u.ChannelEventCommand{constructor(e,t,s){super(e,t,s),this.inviter=null;const{member_count:n=0,joined_member_count:i=0,inviter:a,invitees:r=[]}=s.data;this.memberCount=n,this.joinedMemberCount=i,a&&Object.keys(a).length>0&&(this.inviter=new d.User(e,a)),this.invitees=r.map((t=>new _(e,t)))}}class le extends d.APIRequestCommand{constructor(e){const{channelUrl:t,userId:s}=e;super(),this.method=d.APIRequestMethod.PUT,this.path=`${d.API_PATH_GROUP_CHANNELS}/${encodeURIComponent(t)}/decline`,this.params={user_id:s}}}class de extends u.ChannelEventCommand{constructor(e,t,s){super(e,t,s);const{member_count:n,joined_member_count:i,inviter:a,invitee:r}=s.data;this.memberCount=null!=n?n:0,this.joinedMemberCount=null!=i?i:0,this.inviter=new d.User(e,a),this.invitee=new _(e,r)}}const he={hidePreviousMessages:!1,allowAutoUnhide:!0};class ce extends d.APIRequestCommand{constructor(e){const{channelUrl:t,userId:s,hidePreviousMessages:n,allowAutoUnhide:i}=e;super(),this.method=d.APIRequestMethod.PUT,this.path=`${d.API_PATH_GROUP_CHANNELS}/${encodeURIComponent(t)}/hide`,this.params={user_id:s,hide_previous_messages:null!=n?n:he.hidePreviousMessages,allow_auto_unhide:null!=i?i:he.allowAutoUnhide}}}class ue extends d.APIResponseCommand{constructor(e,t){super(e,t);const{ts_message_offset:s}=t;this.messageOffsetTimestamp=s}}class _e extends d.WebSocketEventCommand{constructor(e,t,s){var n,i,a;super(e,"SYEV",s),this.allowAutoUnhide=null,this.hidePreviousMessages=null,this.messageOffsetTimestamp=null,s.data&&(this.allowAutoUnhide=null!==(n=s.data.allow_auto_unhide)&&void 0!==n?n:null,this.hidePreviousMessages=null!==(i=s.data.hide_previous_messages)&&void 0!==i?i:null),this.messageOffsetTimestamp=null!==(a=s.ts_message_offset)&&void 0!==a?a:null}}class pe extends d.WebSocketRequestCommand{constructor({channelUrl:e,time:t}){super({code:"TPST",ackRequired:!1,payload:{channel_url:e,time:t}})}}class me extends d.WebSocketEventCommand{constructor(e,t,s){super(e,"SYEV",s),this.user=new d.User(e,s.data)}}class ge extends d.WebSocketRequestCommand{constructor({channelUrl:e,time:t}){super({code:"TPEN",ackRequired:!1,payload:{channel_url:e,time:t}})}}class Ce extends d.WebSocketEventCommand{constructor(e,t,s){super(e,"SYEV",s),this.user=new d.User(e,s.data)}}class Ee extends d.WebSocketRequestCommand{constructor({channelUrl:e,messageId:t}){super({code:"MACK",ackRequired:!1,payload:{channel_url:e,msg_id:t}})}}class ve extends d.BaseListQuery{constructor(e,t){var s,n,i,a,r,o,l,d,h,u,_,p,m,g,C,E,v,f,M,S,y,A,b;super(e,t),this.includeEmpty=!1,this.includeFrozen=!0,this.includeMetaData=!0,this.includeChatNotification=!1,this.channelUrlsFilter=null,this.customTypesFilter=null,this.customTypeStartsWithFilter=null,this.nicknameContainsFilter=null,this.nicknameStartsWithFilter=null,this.nicknameExactMatchFilter=null,this.channelNameContainsFilter="",this.myMemberStateFilter=exports.MyMemberStateFilter.ALL,this.unreadChannelFilter=exports.UnreadChannelFilter.ALL,this.superChannelFilter=exports.SuperChannelFilter.ALL,this.publicChannelFilter=exports.PublicChannelFilter.ALL,this.hiddenChannelFilter=exports.HiddenChannelFilter.UNHIDDEN,this.searchFilter={fields:[],query:null},this.userIdsFilter={userIds:[],includeMode:!0,queryType:exports.QueryType.AND},this.metadataKey=null,this.metadataValues=null,this.metadataOrderKeyFilter=null,this.metadataValueStartsWith=null,this.order=c.GroupChannelListOrder.LATEST_LAST_MESSAGE,this.includeEmpty=null!==(s=t.includeEmpty)&&void 0!==s&&s,this.includeFrozen=null===(n=t.includeFrozen)||void 0===n||n,this.includeMetaData=null===(i=t.includeMetaData)||void 0===i||i,this.includeChatNotification=null!==(a=t.includeChatNotification)&&void 0!==a&&a,this.channelUrlsFilter=null!==(r=t.channelUrlsFilter)&&void 0!==r?r:null,this.customTypesFilter=null!==(o=t.customTypesFilter)&&void 0!==o?o:null,this.customTypeStartsWithFilter=null!==(l=t.customTypeStartsWithFilter)&&void 0!==l?l:"",this.nicknameContainsFilter=null!==(d=t.nicknameContainsFilter)&&void 0!==d?d:null,this.nicknameStartsWithFilter=null!==(h=t.nicknameStartsWithFilter)&&void 0!==h?h:null,this.nicknameExactMatchFilter=null!==(u=t.nicknameExactMatchFilter)&&void 0!==u?u:null,this.channelNameContainsFilter=null!==(_=t.channelNameContainsFilter)&&void 0!==_?_:"",this.myMemberStateFilter=null!==(p=t.myMemberStateFilter)&&void 0!==p?p:exports.MyMemberStateFilter.ALL,this.unreadChannelFilter=null!==(m=t.unreadChannelFilter)&&void 0!==m?m:exports.UnreadChannelFilter.ALL,this.superChannelFilter=null!==(g=t.superChannelFilter)&&void 0!==g?g:exports.SuperChannelFilter.ALL,this.publicChannelFilter=null!==(C=t.publicChannelFilter)&&void 0!==C?C:exports.PublicChannelFilter.ALL,this.hiddenChannelFilter=null!==(E=t.hiddenChannelFilter)&&void 0!==E?E:exports.HiddenChannelFilter.UNHIDDEN,this.searchFilter=null!==(v=t.searchFilter)&&void 0!==v?v:{fields:[],query:null},this.userIdsFilter=null!==(f=t.userIdsFilter)&&void 0!==f?f:{userIds:[],includeMode:!0,queryType:exports.QueryType.AND},this.metadataKey=null!==(M=t.metadataKey)&&void 0!==M?M:null,this.metadataValues=null!==(S=t.metadataValues)&&void 0!==S?S:null,this.metadataOrderKeyFilter=null!==(y=t.metadataOrderKeyFilter)&&void 0!==y?y:null,this.metadataValueStartsWith=null!==(A=t.metadataValueStartsWith)&&void 0!==A?A:null,this.order=null!==(b=t.order)&&void 0!==b?b:c.GroupChannelListOrder.LATEST_LAST_MESSAGE,t.createdAfter&&(this.createdAfter=t.createdAfter),t.createdBefore&&(this.createdBefore=t.createdBefore)}_validate(){return super._validate()&&d.isTypeOf("boolean",this.includeEmpty)&&d.isTypeOf("boolean",this.includeFrozen)&&d.isTypeOf("boolean",this.includeMetaData)&&d.isTypeOf("string",this.channelNameContainsFilter)&&d.isArrayOf("string",this.channelUrlsFilter,!0)&&d.isArrayOf("string",this.customTypesFilter,!0)&&d.isTypeOf("string",this.customTypeStartsWithFilter)&&d.isTypeOf("string",this.nicknameContainsFilter,!0)&&d.isTypeOf("string",this.nicknameStartsWithFilter,!0)&&d.isTypeOf("string",this.nicknameExactMatchFilter,!0)&&d.isEnumOf(exports.MyMemberStateFilter,this.myMemberStateFilter)&&d.isEnumOf(exports.SuperChannelFilter,this.superChannelFilter)&&d.isEnumOf(exports.PublicChannelFilter,this.publicChannelFilter)&&d.isEnumOf(exports.UnreadChannelFilter,this.unreadChannelFilter)&&d.isEnumOf(exports.HiddenChannelFilter,this.hiddenChannelFilter)&&d.isArrayOf(exports.GroupChannelSearchField,this.searchFilter.fields)&&d.isTypeOf("string",this.searchFilter.query,!0)&&d.isArrayOf("string",this.userIdsFilter.userIds)&&d.isTypeOf("boolean",this.userIdsFilter.includeMode)&&d.isEnumOf(exports.QueryType,this.userIdsFilter.queryType)&&d.isEnumOf(c.GroupChannelListOrder,this.order)&&d.isTypeOf("string",this.metadataOrderKeyFilter,!0)&&d.isTypeOf("string",this.metadataKey,!0)&&d.isArrayOf("string",this.metadataValues,!0)&&d.isTypeOf("string",this.metadataValueStartsWith,!0)&&d.isMilliSecondOf(this.createdAfter,!0)&&d.isMilliSecondOf(this.createdBefore,!0)}serialize(){return d.serialize(this)}next(){return d.__awaiter(this,void 0,void 0,(function*(){if(this._validate()){if(this._isLoading)throw d.SendbirdError.queryInProgress;if(this._hasNext){this._isLoading=!0;const e=Ne.of(this._iid),{channels:t,token:s}=yield e.getMyGroupChannels(this._token,d.undefineNullProps(Object.assign({},this)),this.limit);return this._token=s,this._hasNext=!!s,this._isLoading=!1,t}return[]}throw d.SendbirdError.invalidParameters}))}}class fe extends d.WebSocketEventCommand{constructor(e,t,s){var n;super(e,"SYEV",s),this.pinnedMessageIds=[],this.latestPinnedMessage=null,this.ts=0,s.data&&(this.pinnedMessageIds=null!==(n=s.data.pinned_message_ids)&&void 0!==n?n:[],this.latestPinnedMessage=s.data.latest_pinned_message?h.parseMessagePayload(e,Object.assign({},s.data.latest_pinned_message)):null),this.ts=s.ts}}class Me extends d.WebSocketRequestCommand{constructor({channelUrl:e}){super({code:"READ",ackRequired:!0,payload:{channel_url:e}})}}class Se extends d.WebSocketEventCommand{constructor(e,t,s){super(e,"READ",s),this.readStatus=new p(e,s)}}class ye extends d.APIRequestCommand{constructor({channelUrl:e,userId:t}){super(),super(),this.method=d.APIRequestMethod.PUT,this.path=`${d.API_PATH_GROUP_CHANNELS}/${encodeURIComponent(e)}/messages/mark_as_delivered`,this.params=d.deundefined({userId:t})}}class Ae extends d.WebSocketEventCommand{constructor(e,t,s){super(e,"DLVR",s),this.channelUrl=s.channel_url,this.deliveredStateUpdate=s.updated}}const be={};class Ne extends u.BaseChannelManager{constructor(e,t){var s;super(e,Object.assign(Object.assign({},t),{channelType:d.ChannelType.GROUP})),this._leftChannels=new Map,this._disableMack=!1,this._markAsReadAllLastSentAt=0,this._disableMack=null!==(s=t.disableMack)&&void 0!==s&&s,this._groupChannelHandlers=new Map,this._groupChannelCache=new g(this._iid,{sdkState:t.sdkState,cacheContext:t.cacheContext}),this._groupChannelBroadcast=new O({dispatcher:t.dispatcher,groupChannelCache:this._groupChannelCache,messageCache:h.MessageCache.of(this._iid),unsentMessageCache:h.UnsentMessageCache.of(this._iid)}),setInterval((()=>{for(const e of this._groupChannelCache.channels)e.invalidateTypingStatus()&&(this._dispatcher.dispatch(new P({channels:[e],source:d.CollectionEventSource.EVENT_CHANNEL_TYPING_STATUS_UPDATE})),this._groupChannelHandlers.forEach((t=>{t.onTypingStatusUpdated&&t.onTypingStatusUpdated(e)})))}),1e3),this._dispatcher.on((e=>{e instanceof d.WebSocketEventCommand?this._handleEvent(e):e instanceof c.AutoResendRequestCommand?(()=>{d.__awaiter(this,void 0,void 0,(function*(){const{message:t}=e,s=yield this.getChannel(t.channelUrl,!0);t instanceof h.UserMessage?s._autoResendUserMessage(t):t instanceof h.FileMessage&&s._autoResendFileMessage(t)}))})():e instanceof c.ReduceDBSizeEventCommand&&this.reduceDBSize()})),be[e]||(be[e]=this)}static of(e){return be[e]||(be[e]=new Ne(e,d.Vault.of(e))),be[e]}static clear(e){be[e]&&delete be[e]}get handlers(){return[...this._groupChannelHandlers.values()]}buildGroupChannelFromSerializedData(e){const t=d.deserialize(e);return new Lt(this._iid,Lt.payloadify(t))}buildGroupChannelListQueryFromSerializedData(e){const t=d.deserialize(e);return new ve(this._iid,t)}buildMemberFromSerializedData(e){const t=d.deserialize(e);return new _(this._iid,_.payloadify(t))}getChannelFromCache(e){var t;return d.__awaiter(this,void 0,void 0,(function*(){return null!==(t=yield this._groupChannelCache.get(e))&&void 0!==t?t:null}))}getChannelsFromCache(e,t,s,n,i){return d.__awaiter(this,void 0,void 0,(function*(){return yield this._groupChannelCache.fetch({token:e,filter:t,order:s,limit:n,borderlineChannelUrl:i})}))}upsertChannelsToCache(e){return d.__awaiter(this,void 0,void 0,(function*(){return yield this._groupChannelCache.upsert(e)}))}removeChannelsFromCache(e){return d.__awaiter(this,void 0,void 0,(function*(){yield this._groupChannelCache.remove(e)}))}clearChannelsFromCache(){return d.__awaiter(this,void 0,void 0,(function*(){yield this._groupChannelCache.clear()}))}reduceDBSize(){return d.__awaiter(this,void 0,void 0,(function*(){const e=h.MessageCache.of(this._iid),{cacheContext:t}=d.Vault.of(this._iid),{localCacheConfig:s,nestdb:n}=t;if(!t.localCacheEnabled||!n||n.state!=h.NestDBState.OPENED)return;const i=1024*s.maxSize*1024;let a=yield n.estimateUsage();if(ad.__awaiter(this,void 0,void 0,(function*(){const t=new Ee(e);this._requestQueue.send(t)}))));const s=this._groupChannelCache.isCachedInMemory(e.channelUrl),a=e instanceof h.SendableMessage&&e.sender.userId===this._sdkState.userId,r=yield this.getChannel(e.channelUrl,!0);if(r.hiddenState===exports.HiddenState.HIDDEN_ALLOW_AUTO_UNHIDE&&(r.hiddenState=exports.HiddenState.UNHIDDEN),e instanceof h.SendableMessage){const{useMemberInfoInMessage:s}=d.Vault.of(this._iid);for(const t of r.members)if(t.userId===e.sender.userId){s||(e.sender.nickname=t.nickname,e.sender.plainProfileUrl=t.plainProfileUrl,e.sender.metaData=t.metaData,e.sender.isBlockedByMe=t.isBlockedByMe);break}if(!s&&n&&(null===(t=e.mentionedUsers)||void 0===t||t.forEach((e=>{for(const t of r.members)if(e.userId===t.userId){e.nickname=t.nickname,e.plainProfileUrl=t.plainProfileUrl,e.metaData=t.metaData;break}}))),a){const{currentUser:t}=this._sessionManager;t&&(t.nickname=e.sender.nickname,t.plainProfileUrl=e.sender.plainProfileUrl,t.metaData=e.sender.metaData)}}e.silent&&!a||(r.isEphemeral||s)&&((!r.lastMessage||r.lastMessage.createdAtd.__awaiter(this,void 0,void 0,(function*(){for(const e of this._groupChannelHandlers.values())e.onChannelChanged&&e.onChannelChanged(r)})))),this._dispatcher.dispatch(new d.MessageUpdateEventCommand({messages:[e],source:d.CollectionEventSource.EVENT_MESSAGE_RECEIVED})),d.runAsCallback((()=>d.__awaiter(this,void 0,void 0,(function*(){for(const t of this._groupChannelHandlers.values())t.onMessageReceived&&t.onMessageReceived(r,e),n&&t.onMentionReceived&&t.onMentionReceived(r,e)}))))}}break}case"MEDI":case"FEDI":case"AEDI":{let t=null;if("MEDI"===e.code?t=e.as(h.UpdateUserMessageEventCommand):"FEDI"===e.code?t=e.as(h.UpdateFileMessageEventCommand):"AEDI"===e.code&&(t=e.as(u.UpdateAdminMessageEventCommand)),t){const{message:e,mentionCountChange:s}=t;if(e.channelType===d.ChannelType.GROUP){const t=this._groupChannelCache.isCachedInMemory(e.channelUrl),n=yield this.getChannel(e.channelUrl,!0),i=e instanceof h.SendableMessage&&e.sender.userId===this._sdkState.userId;let a=!1;if(i){const t=e.sender,{currentUser:s}=this._sessionManager;s&&(s.nickname=t.nickname,s.plainProfileUrl=t.plainProfileUrl,s.metaData=t.metaData)}else n.isReadMessage(e)||0!==s&&!e.silent&&t&&(n._updateUnreadCount(n.unreadMessageCount,n.unreadMentionCount+s),a=!0);!n.lastMessage||n.lastMessage.createdAtd.__awaiter(this,void 0,void 0,(function*(){for(const e of this._groupChannelHandlers.values())e.onChannelChanged&&e.onChannelChanged(n)})))),r&&d.runAsCallback((()=>d.__awaiter(this,void 0,void 0,(function*(){for(const e of this._groupChannelHandlers.values())e.onPinnedMessageUpdated&&e.onPinnedMessageUpdated(n)}))))),this._dispatcher.dispatch(new d.MessageUpdateEventCommand({messages:[e],source:d.CollectionEventSource.EVENT_MESSAGE_UPDATED})),d.runAsCallback((()=>d.__awaiter(this,void 0,void 0,(function*(){for(const t of this._groupChannelHandlers.values())t.onMessageUpdated&&t.onMessageUpdated(n,e),0!==s&&t.onMentionReceived&&t.onMentionReceived(n,e)}))))}}break}case"DELM":{const{channelUrl:t,channelType:s,messageId:n}=e.as(h.DeleteMessageEventCommand);if(s===d.ChannelType.GROUP){const e=yield this.getChannel(t,!0);this._dispatcher.dispatch(new d.MessageRemoveEventCommand({messageIds:[n],source:d.CollectionEventSource.EVENT_MESSAGE_DELETED})),d.runAsCallback((()=>d.__awaiter(this,void 0,void 0,(function*(){for(const t of this._groupChannelHandlers.values())t.onMessageDeleted&&t.onMessageDeleted(e,n)}))))}break}case"READ":{const{readStatus:t}=e.as(Se);if(t.channelType===d.ChannelType.GROUP){const e=this._groupChannelCache.isCachedInMemory(t.channelUrl),s=yield this.getChannel(t.channelUrl,!0);e&&s._updateUnreadMemberState(t.reader.userId,t.readAt),t.reader.userId===this._sdkState.userId?e?(s.unreadMessageCount>0||s.unreadMentionCount>0)&&(s._updateUnreadCount(0,0),this._dispatcher.dispatch(new P({channels:[s],source:d.CollectionEventSource.EVENT_CHANNEL_READ})),d.runAsCallback((()=>d.__awaiter(this,void 0,void 0,(function*(){for(const e of this._groupChannelHandlers.values())e.onChannelChanged&&e.onChannelChanged(s)}))))):0!==s.unreadMessageCount&&0!==s.unreadMentionCount||(this._dispatcher.dispatch(new P({channels:[s],source:d.CollectionEventSource.EVENT_CHANNEL_READ})),d.runAsCallback((()=>d.__awaiter(this,void 0,void 0,(function*(){for(const e of this._groupChannelHandlers.values())e.onChannelChanged&&e.onChannelChanged(s)}))))):(this._dispatcher.dispatch(new P({channels:[s],source:d.CollectionEventSource.EVENT_CHANNEL_READ})),d.runAsCallback((()=>d.__awaiter(this,void 0,void 0,(function*(){for(const e of this._groupChannelHandlers.values())e.onUnreadMemberStatusUpdated&&e.onUnreadMemberStatusUpdated(s)})))))}break}case"DLVR":{const{channelUrl:t,deliveredStateUpdate:s={}}=e.as(Ae),n=this._groupChannelCache.isCachedInMemory(t),i=yield this.getChannel(t,!0);if(n)for(const e in s)i._updateUndeliveredMemberState(e,s[e]);Object.keys(s).some((e=>e!==this._sdkState.userId))&&(this._dispatcher.dispatch(new P({channels:[i],source:d.CollectionEventSource.EVENT_CHANNEL_DELIVERED})),d.runAsCallback((()=>d.__awaiter(this,void 0,void 0,(function*(){for(const e of this._groupChannelHandlers.values())e.onUndeliveredMemberStatusUpdated&&e.onUndeliveredMemberStatusUpdated(i)})))));break}case"MRCT":{const{channelUrl:t,channelType:s,event:n}=e.as(u.ReactionEventCommand);if(s===d.ChannelType.GROUP){const e=yield this.getChannel(t,!0),s=yield this.getMessageFromCache(n.messageId);s&&(s.applyReactionEvent(n),this._dispatcher.dispatch(new d.MessageUpdateEventCommand({messages:[s],source:d.CollectionEventSource.EVENT_MESSAGE_REACTION_UPDATED}))),d.runAsCallback((()=>d.__awaiter(this,void 0,void 0,(function*(){for(const t of this._groupChannelHandlers.values())t.onReactionUpdated&&t.onReactionUpdated(e,n)}))))}break}case"MTHD":{const{event:t}=e.as(u.ThreadInfoUpdateEventCommand);if(t.channelType===d.ChannelType.GROUP){const e=yield this.getChannel(t.channelUrl,!0),s=yield this.getMessageFromCache(t.targetMessageId);s&&(s.applyThreadInfoUpdateEvent(t),this._dispatcher.dispatch(new d.MessageUpdateEventCommand({messages:[s],source:d.CollectionEventSource.EVENT_MESSAGE_THREADINFO_UPDATED}))),d.runAsCallback((()=>d.__awaiter(this,void 0,void 0,(function*(){for(const s of this._groupChannelHandlers.values())s.onThreadInfoUpdated&&s.onThreadInfoUpdated(e,t)}))))}break}case"MCNT":{const{groupChannelMemberCounts:t}=e.as(u.MemberCountUpdateEventCommand),s=[];for(const e of t){const{channelUrl:t,memberCount:n,joinedMemberCount:i,updatedAt:a}=e,r=yield this.getChannelFromCache(t);r&&r._setLatestMemberCount(n,i,a)&&s.push(r)}s.length>0&&(this._dispatcher.dispatch(new P({channels:s,source:d.CollectionEventSource.EVENT_CHANNEL_MEMBER_COUNT_UPDATED})),d.runAsCallback((()=>d.__awaiter(this,void 0,void 0,(function*(){for(const e of this._groupChannelHandlers.values())e.onChannelMemberCountChanged&&e.onChannelMemberCountChanged(s)})))));break}case"PEDI":{const{event:t,status:s,channelUrl:n,channelType:i}=e.as(u.PollUpdateEventCommand);if(n&&i===d.ChannelType.GROUP){const e=yield this.getChannel(n,!0);this._dispatcher.dispatch(new d.PollUpdateInternalEventCommand({event:t,source:d.CollectionEventSource.EVENT_POLL_UPDATED})),s===d.POLL_REMOVED_STATUS?d.runAsCallback((()=>d.__awaiter(this,void 0,void 0,(function*(){for(const s of this._groupChannelHandlers.values())s.onPollDeleted&&s.onPollDeleted(e,t.pollId)})))):d.runAsCallback((()=>d.__awaiter(this,void 0,void 0,(function*(){for(const s of this._groupChannelHandlers.values())s.onPollUpdated&&s.onPollUpdated(e,t)}))))}break}case"VOTE":{const{event:t,channelUrl:s,channelType:n}=e.as(h.PollVoteEventCommand);if(s&&n===d.ChannelType.GROUP){const e=yield this.getChannel(s,!0);this._dispatcher.dispatch(new d.PollVoteInternalEventCommand({event:t,source:d.CollectionEventSource.EVENT_POLL_VOTED})),d.runAsCallback((()=>d.__awaiter(this,void 0,void 0,(function*(){for(const s of this._groupChannelHandlers.values())s.onPollVoted&&s.onPollVoted(e,t)}))))}break}case"SYEV":{const{event:t}=e.as(u.ChannelEventCommand);if(t.isGroupChannelEvent)switch(t.category){case u.ChannelEventCategory.CHANNEL_JOIN:{const s=yield this.getChannel(t.channelUrl,!0),{memberCount:n,joinedMemberCount:i,members:a}=e.as(se);let r=!1;a.forEach((e=>{s.isExclusive||s.isSuper||s.isBroadcast?r=r||s._setLatestMemberCount(n,i,t.ts):(e.state=exports.MemberState.JOINED,s.addMember(e,t.ts),this._updateJoinedMemberCount(s)),e.userId===this._sdkState.userId&&(s.myMemberState=exports.MemberState.JOINED)})),this._dispatcher.dispatch(new P({channels:[s],source:d.CollectionEventSource.EVENT_CHANNEL_JOINED})),d.runAsCallback((()=>d.__awaiter(this,void 0,void 0,(function*(){this._groupChannelHandlers.forEach((e=>{for(const t of a)e.onUserJoined&&e.onUserJoined(s,t);s.isBroadcast&&r&&e.onChannelMemberCountChanged&&e.onChannelMemberCountChanged([s])}))}))));break}case u.ChannelEventCategory.CHANNEL_LEAVE:{const s=this._leftChannels.get(t.channelUrl),n=s?s.channel:yield this.getChannel(t.channelUrl,!0),{memberCount:i,joinedMemberCount:a,member:r}=e.as(ie);let o=!1;const{appInfo:l}=d.Vault.of(this._iid);if(n.isExclusive||n.isSuper||n.isBroadcast)o=n._setLatestMemberCount(i,a,t.ts);else{if(null==l?void 0:l.enabledChannelMemberShipHistory){const e=n.members.find((t=>t.userId===e.userId));e&&(e.state=exports.MemberState.LEFT),n.memberCount=i}else n.removeMember(r);this._updateJoinedMemberCount(n)}r.userId===this._sdkState.userId?(n.myMemberState=exports.MemberState.NONE,n.invitedAt=0,n.joinedAt=0,n._updateUnreadCount(0,0),n.isPublic?this._dispatcher.dispatch(new P({channels:[n],source:d.CollectionEventSource.EVENT_CHANNEL_LEFT})):(this._markAsLeave(n),this._dispatcher.dispatch(new x({channelUrls:[n.url],source:d.CollectionEventSource.EVENT_CHANNEL_LEFT})))):this._dispatcher.dispatch(new P({channels:[n],source:d.CollectionEventSource.EVENT_CHANNEL_LEFT})),d.runAsCallback((()=>d.__awaiter(this,void 0,void 0,(function*(){this._groupChannelHandlers.forEach((e=>{e.onUserLeft&&e.onUserLeft(n,r),n.isBroadcast&&o&&e.onChannelMemberCountChanged&&e.onChannelMemberCountChanged([n])}))}))));break}case u.ChannelEventCategory.CHANNEL_OPERATOR_UPDATE:{const s=yield this.getChannel(t.channelUrl,!0),{operators:n}=e.as(u.OperatorUpdateEventCommand),i=n.map((e=>e.userId));for(const e of s.members)e.role=i.includes(e.userId)?d.Role.OPERATOR:d.Role.NONE;s.myRole=i.includes(this._sdkState.userId)?d.Role.OPERATOR:d.Role.NONE,this._dispatcher.dispatch(new P({channels:[s],source:d.CollectionEventSource.EVENT_CHANNEL_OPERATOR_UPDATED})),d.runAsCallback((()=>d.__awaiter(this,void 0,void 0,(function*(){this._groupChannelHandlers.forEach((e=>{e.onOperatorUpdated&&e.onOperatorUpdated(s,n)}))}))));break}case u.ChannelEventCategory.CHANNEL_INVITE:{const s=yield this.getChannel(t.channelUrl,!0),{memberCount:n,joinedMemberCount:i,inviter:a,invitees:r}=e.as(oe);r.forEach((e=>e.state=exports.MemberState.INVITED));for(const e of r)s.isExclusive||s.isSuper||s.isBroadcast?s._setLatestMemberCount(n,i,t.ts):s.addMember(e,t.ts),this._sdkState.userId===e.userId&&(s.hiddenState=exports.HiddenState.UNHIDDEN,s.myMemberState!==exports.MemberState.JOINED&&(s.myMemberState=exports.MemberState.INVITED),s.invitedAt=t.ts);this._dispatcher.dispatch(new P({channels:[s],source:d.CollectionEventSource.EVENT_CHANNEL_INVITED})),d.runAsCallback((()=>d.__awaiter(this,void 0,void 0,(function*(){this._groupChannelHandlers.forEach((e=>{e.onUserReceivedInvitation&&e.onUserReceivedInvitation(s,a,r)}))}))));break}case u.ChannelEventCategory.CHANNEL_DECLINE_INVITE:{const s=yield this.getChannel(t.channelUrl,!0),{memberCount:n,joinedMemberCount:i,inviter:a,invitee:r}=e.as(de);s.isExclusive||s.isSuper||s.isBroadcast?s._setLatestMemberCount(n,i,t.ts):s.removeMember(r),this._sdkState.userId===r.userId?(s.invitedAt=0,s.myMemberState=exports.MemberState.NONE,s.isPublic?this._dispatcher.dispatch(new P({channels:[s],source:d.CollectionEventSource.EVENT_CHANNEL_DECLINED_INVITE})):this._dispatcher.dispatch(new x({channelUrls:[s.url],source:d.CollectionEventSource.EVENT_CHANNEL_DECLINED_INVITE}))):this._dispatcher.dispatch(new P({channels:[s],source:d.CollectionEventSource.EVENT_CHANNEL_DECLINED_INVITE})),d.runAsCallback((()=>d.__awaiter(this,void 0,void 0,(function*(){this._groupChannelHandlers.forEach((e=>{e.onUserDeclinedInvitation&&e.onUserDeclinedInvitation(s,a,r)}))}))));break}case u.ChannelEventCategory.TYPING_START:case u.ChannelEventCategory.TYPING_END:{const s=yield this.getChannel(t.channelUrl,!0),n=t.category===u.ChannelEventCategory.TYPING_START,{user:i}=e.as(n?me:Ce);s._updateTypingStatus(i,n?t.ts:0),this._dispatcher.dispatch(new P({channels:[s],source:d.CollectionEventSource.EVENT_CHANNEL_TYPING_STATUS_UPDATE})),d.runAsCallback((()=>d.__awaiter(this,void 0,void 0,(function*(){this._groupChannelHandlers.forEach((e=>{e.onTypingStatusUpdated&&e.onTypingStatusUpdated(s)}))}))));break}case u.ChannelEventCategory.USER_CHANNEL_MUTE:case u.ChannelEventCategory.USER_CHANNEL_UNMUTE:{const s=yield this.getChannel(t.channelUrl,!0),n=t.category===u.ChannelEventCategory.USER_CHANNEL_MUTE,{user:i}=e.as(n?h.MuteUserEventCommand:h.UnmuteUserEventCommand);i.userId===this._sdkState.userId&&(s.myMutedState=n?d.MutedState.MUTED:d.MutedState.UNMUTED,s._myMutedRemainingTime=i.restrictionInfo.remainingDuration);for(const e of s.members)if(e.userId===i.userId){e.isMuted=n;break}this._dispatcher.dispatch(new P({channels:[s],source:n?d.CollectionEventSource.EVENT_CHANNEL_MUTED:d.CollectionEventSource.EVENT_CHANNEL_UNMUTED,data:i.userId})),d.runAsCallback((()=>d.__awaiter(this,void 0,void 0,(function*(){this._groupChannelHandlers.forEach((e=>{n?e.onUserMuted&&e.onUserMuted(s,i):e.onUserUnmuted&&e.onUserUnmuted(s,i)}))}))));break}case u.ChannelEventCategory.USER_CHANNEL_BAN:{const s=this._leftChannels.get(t.channelUrl),n=s?s.channel:yield this.getChannel(t.channelUrl,!0);this._markAsLeave(n);const{user:i}=e.as(h.BanUserEventCommand);i.userId===this._sdkState.userId&&this._dispatcher.dispatch(new x({channelUrls:[n.url],source:d.CollectionEventSource.EVENT_CHANNEL_BANNED})),d.runAsCallback((()=>d.__awaiter(this,void 0,void 0,(function*(){this._groupChannelHandlers.forEach((e=>{e.onUserBanned&&e.onUserBanned(n,i)}))}))));break}case u.ChannelEventCategory.USER_CHANNEL_UNBAN:{const s=yield this.getChannel(t.channelUrl,!0),{user:n}=e.as(h.UnbanUserEventCommand);n.userId===this._sdkState.userId&&this._dispatcher.dispatch(new x({channelUrls:[s.url],source:d.CollectionEventSource.EVENT_CHANNEL_UNBANNED})),d.runAsCallback((()=>d.__awaiter(this,void 0,void 0,(function*(){this._groupChannelHandlers.forEach((e=>{e.onUserUnbanned&&e.onUserUnbanned(s,n)}))}))));break}case u.ChannelEventCategory.CHANNEL_FREEZE:case u.ChannelEventCategory.CHANNEL_UNFREEZE:{const s=yield this.getChannel(t.channelUrl,!0),{freeze:n}=e.as(h.FreezeEventCommand);s.isFrozen=n,this._dispatcher.dispatch(new P({channels:[s],source:n?d.CollectionEventSource.EVENT_CHANNEL_FROZEN:d.CollectionEventSource.EVENT_CHANNEL_UNFROZEN})),d.runAsCallback((()=>d.__awaiter(this,void 0,void 0,(function*(){this._groupChannelHandlers.forEach((e=>{n?e.onChannelFrozen&&e.onChannelFrozen(s):e.onChannelUnfrozen&&e.onChannelUnfrozen(s)}))}))));break}case u.ChannelEventCategory.CHANNEL_HIDE:{const s=yield this.getChannel(t.channelUrl,!0),{allowAutoUnhide:n,hidePreviousMessages:i,messageOffsetTimestamp:a}=e.as(_e);null!==n&&(s.hiddenState=n?exports.HiddenState.HIDDEN_ALLOW_AUTO_UNHIDE:exports.HiddenState.HIDDEN_PREVENT_AUTO_UNHIDE),null!==i&&i&&s._updateUnreadCount(0,0),null!==a&&(s.messageOffsetTimestamp=a),this._dispatcher.dispatch(new P({channels:[s],source:d.CollectionEventSource.EVENT_CHANNEL_HIDDEN})),d.runAsCallback((()=>d.__awaiter(this,void 0,void 0,(function*(){this._groupChannelHandlers.forEach((e=>{e.onChannelHidden&&e.onChannelHidden(s)}))}))));break}case u.ChannelEventCategory.CHANNEL_UNHIDE:{const e=yield this.getChannel(t.channelUrl,!0);e.hiddenState=exports.HiddenState.UNHIDDEN,this._dispatcher.dispatch(new P({channels:[e],source:d.CollectionEventSource.EVENT_CHANNEL_UNHIDDEN})),d.runAsCallback((()=>d.__awaiter(this,void 0,void 0,(function*(){this._groupChannelHandlers.forEach((t=>{t.onChannelChanged&&t.onChannelChanged(e)}))}))));break}case u.ChannelEventCategory.CHANNEL_DELETED:{const e=yield this.getChannel(t.channelUrl,!0);this._dispatcher.dispatch(new x({channelUrls:[t.channelUrl],source:d.CollectionEventSource.EVENT_CHANNEL_DELETED})),d.runAsCallback((()=>d.__awaiter(this,void 0,void 0,(function*(){this._groupChannelHandlers.forEach((t=>{t.onChannelDeleted&&t.onChannelDeleted(e.url,e.channelType)}))}))));break}case u.ChannelEventCategory.CHANNEL_PROP_CHANGED:{const e=yield this.getChannelWithoutCache(t.channelUrl,!0);this._dispatcher.dispatch(new P({channels:[e],source:d.CollectionEventSource.EVENT_CHANNEL_UPDATED})),d.runAsCallback((()=>d.__awaiter(this,void 0,void 0,(function*(){this._groupChannelHandlers.forEach((t=>{t.onChannelChanged&&t.onChannelChanged(e)}))}))));break}case u.ChannelEventCategory.CHANNEL_META_DATA_CHANGED:{const s=yield this.getChannel(t.channelUrl,!0),{created:n,updated:i,deleted:a}=e.as(h.UpdateMetaDataEventCommand);n&&(s._upsertCachedMetaData(n,t.ts),this._dispatcher.dispatch(new P({channels:[s],source:d.CollectionEventSource.EVENT_CHANNEL_METADATA_CREATED}))),i&&(s._upsertCachedMetaData(i,t.ts),this._dispatcher.dispatch(new P({channels:[s],source:d.CollectionEventSource.EVENT_CHANNEL_METADATA_UPDATED}))),a&&(s._removeFromCachedMetaData(a,t.ts),this._dispatcher.dispatch(new P({channels:[s],source:d.CollectionEventSource.EVENT_CHANNEL_METADATA_DELETED}))),d.runAsCallback((()=>d.__awaiter(this,void 0,void 0,(function*(){this._groupChannelHandlers.forEach((e=>{n&&e.onMetaDataCreated&&e.onMetaDataCreated(s,n),i&&e.onMetaDataUpdated&&e.onMetaDataUpdated(s,i),a&&e.onMetaDataDeleted&&e.onMetaDataDeleted(s,a)}))}))));break}case u.ChannelEventCategory.CHANNEL_META_COUNTERS_CHANGED:{const s=yield this.getChannel(t.channelUrl,!0),{created:n,updated:i,deleted:a}=e.as(h.UpdateMetaCounterEventCommand);n&&this._dispatcher.dispatch(new P({channels:[s],source:d.CollectionEventSource.EVENT_CHANNEL_METACOUNTER_CREATED})),i&&this._dispatcher.dispatch(new P({channels:[s],source:d.CollectionEventSource.EVENT_CHANNEL_METACOUNTER_UPDATED})),a&&this._dispatcher.dispatch(new P({channels:[s],source:d.CollectionEventSource.EVENT_CHANNEL_METACOUNTER_DELETED})),d.runAsCallback((()=>d.__awaiter(this,void 0,void 0,(function*(){this._groupChannelHandlers.forEach((e=>{n&&e.onMetaCounterCreated&&e.onMetaCounterCreated(s,n),i&&e.onMetaCounterUpdated&&e.onMetaCounterUpdated(s,i),a&&e.onMetaCounterDeleted&&e.onMetaCounterDeleted(s,a)}))}))));break}case u.ChannelEventCategory.PINNED_MESSAGE_CHANGED:{const s=yield this.getChannel(t.channelUrl,!0),{pinnedMessageIds:n,latestPinnedMessage:i,ts:a}=e.as(fe);a>s._pinnedMessagesUpdatedAt&&(s.pinnedMessageIds=n,s.lastPinnedMessage=i,s._pinnedMessagesUpdatedAt=a,this._dispatcher.dispatch(new P({channels:[s],source:d.CollectionEventSource.EVENT_PINNED_MESSAGE_UPDATED})),d.runAsCallback((()=>d.__awaiter(this,void 0,void 0,(function*(){for(const e of this._groupChannelHandlers.values())e.onChannelChanged&&e.onChannelChanged(s)})))),d.runAsCallback((()=>d.__awaiter(this,void 0,void 0,(function*(){this._groupChannelHandlers.forEach((e=>{e.onPinnedMessageUpdated&&e.onPinnedMessageUpdated(s)}))})))));break}}break}case"USEV":{const{event:t}=e.as(c.UserEventCommand);switch(t.category){case c.UserEventCategory.USER_BLOCK:{const{blocker:e,blockee:s}=c.UserEvent.getDataAsUserBlockEvent(this._iid,t);this._groupChannelCache.block(e.userId,s.userId);break}case c.UserEventCategory.USER_UNBLOCK:{const{blocker:e,blockee:s}=c.UserEvent.getDataAsUserBlockEvent(this._iid,t);this._groupChannelCache.unblock(e.userId,s.userId);break}}break}}}catch(e){if(d.isThrowingOutside(e))throw e}}))}_markAsLeave(e){var t;const s=null!==(t=this._leftChannels.get(e.url))&&void 0!==t?t:{channel:e,ref:0};s.ref++,this._leftChannels.set(e.url,s),setTimeout((()=>{s.ref--,0===s.ref&&this._leftChannels.delete(e.url)}),1e4)}addHandler(e,t){this._groupChannelHandlers.set(e,t)}removeHandler(e){this._groupChannelHandlers.delete(e)}clearHandler(){this._groupChannelHandlers.clear()}subscribeChannelEvent(e,t){this._groupChannelBroadcast.subscribe(e,t)}unsubscribeChannelEvent(e){this._groupChannelBroadcast.unsubscribe(e)}_updateJoinedMemberCount(e){e.joinedMemberCount=e.members.filter((e=>e.state===exports.MemberState.JOINED)).length}getChannel(e,t=!1){return d.__awaiter(this,void 0,void 0,(function*(){d.unless(d.isTypeOf("string",e)).throw(d.SendbirdError.invalidParameters);try{const t=yield this.getChannelFromCache(e);if(t)return t}catch(e){}return yield this.getChannelWithoutCache(e,t)}))}getChannelWithoutCache(e,t=!1){return d.__awaiter(this,void 0,void 0,(function*(){d.unless(d.isTypeOf("string",e)).throw(d.SendbirdError.invalidParameters);const s=new L({channelUrl:e,isInternalCall:t}),n=yield this._requestQueue.send(s),{channel:i}=n.as(F);let{unreadMessageCount:a,unreadMentionCount:r}=i;switch(i.myCountPreference){case exports.CountPreference.UNREAD_MESSAGE_COUNT_ONLY:r=0;break;case exports.CountPreference.UNREAD_MENTION_COUNT_ONLY:a=0;break;case exports.CountPreference.OFF:a=0,r=0}return i._updateUnreadCount(a,r),(yield this.upsertChannelsToCache([i]))[0]}))}refreshChannel(e,t=!0,s=d.CollectionEventSource.REFRESH_CHANNEL){return d.__awaiter(this,void 0,void 0,(function*(){try{const n=new L({channelUrl:e,isInternalCall:t}),i=yield this._requestQueue.send(n),{channel:a}=i.as(F);if(a.myMemberState===exports.MemberState.NONE)this._dispatcher.dispatch(new x({channelUrls:[a.url],source:s}));else{const e=yield this.upsertChannelsToCache([a]);this._dispatcher.dispatch(new P({channels:e,source:s}))}}catch(t){t.code!==d.SendbirdErrorCode.NON_AUTHORIZED&&t.code!==d.SendbirdErrorCode.NOT_FOUND_IN_DATABASE||this._dispatcher.dispatch(new x({channelUrls:[e],source:s}))}}))}getMyGroupChannels(e,t,s,n=d.CollectionEventSource.REQUEST_CHANNEL){return d.__awaiter(this,void 0,void 0,(function*(){t.createdAfter&&(t.createdAfter=Math.floor(t.createdAfter/1e3)),t.createdBefore&&(t.createdBefore=Math.floor(t.createdBefore/1e3));const i=new k(Object.assign(Object.assign({},t),{userId:this._sdkState.userId,token:e,limit:s})),a=yield this._requestQueue.send(i),{channels:r,token:o}=a.as(H);return this._dispatcher.dispatch(new P({channels:r,source:n})),{channels:r,token:o}}))}getMyGroupChannelChangeLogs(e,t,s=d.CollectionEventSource.REQUEST_CHANNEL_CHANGELOGS){return d.__awaiter(this,void 0,void 0,(function*(){const n=Object.assign(Object.assign({},v),t);d.unless((d.isTypeOf("string",e)||d.isTypeOf("number",e))&&f(n)).throw(d.SendbirdError.invalidParameters);const i=new R(d.undefineNullProps({userId:this._sdkState.userId,ts:"number"==typeof e?e:null,token:"string"==typeof e?e:null,filter:n})),a=(yield this._requestQueue.send(i)).as(w),{updatedChannels:r,deletedChannelUrls:o,hasMore:l,ts:h}=a;return r.length>0&&this._dispatcher.dispatch(new P({channels:r,source:s,ts:h})),o.length>0&&this._dispatcher.dispatch(new x({channelUrls:o,source:s})),{updatedChannels:r,deletedChannelUrls:o,hasMore:l,token:a.token}}))}getGroupChannelCount(e){return d.__awaiter(this,void 0,void 0,(function*(){const t=Object.assign(Object.assign({},M),e);d.unless(S(t)).throw(d.SendbirdError.invalidParameters);const s=new V({userId:this._sdkState.userId,filter:t}),n=yield this._requestQueue.send(s),{groupChannelCount:i}=n.as(G);return i}))}getUnreadItemCount(e){return d.__awaiter(this,void 0,void 0,(function*(){const t=Object.assign(Object.assign({},A),e);d.unless((e=>d.isArrayOf(exports.UnreadItemKey,e.keys))(t)).throw(d.SendbirdError.invalidParameters);const{sdkState:s,requestQueue:n}=d.Vault.of(this._iid),i=new q({userId:s.userId,filter:t}),a=yield n.send(i),{groupChannelUnreadMentionCount:r,groupChannelUnreadMessageCount:o,groupChannelInvitationCount:l,superGroupChannelUnreadMentionCount:h,superGroupChannelUnreadMessageCount:c,superGroupChannelInvitationCount:u,nonSuperGroupChannelUnreadMentionCount:_,nonSuperGroupChannelUnreadMessageCount:p,nonSuperGroupChannelInvitationCount:m}=a.as(B);return d.deundefined({groupChannelUnreadMentionCount:r,groupChannelUnreadMessageCount:o,groupChannelInvitationCount:l,superGroupChannelUnreadMentionCount:h,superGroupChannelUnreadMessageCount:c,superGroupChannelInvitationCount:u,nonSuperGroupChannelUnreadMentionCount:_,nonSuperGroupChannelUnreadMessageCount:p,nonSuperGroupChannelInvitationCount:m})}))}getTotalUnreadChannelCount(){return d.__awaiter(this,void 0,void 0,(function*(){const{sdkState:e,requestQueue:t}=d.Vault.of(this._iid),s=new j({userId:e.userId}),n=yield t.send(s),{unreadCount:i}=n.as(z);return i}))}getTotalUnreadMessageCount(e){return d.__awaiter(this,void 0,void 0,(function*(){const t=Object.assign(Object.assign({},b),e);d.unless(N(t)).throw(d.SendbirdError.invalidParameters);const{sdkState:s,requestQueue:n}=d.Vault.of(this._iid),i=new W({userId:s.userId,filter:t}),a=yield n.send(i),{unreadCount:r}=a.as($);return r}))}getTotalScheduledMessageCount(e={}){return d.__awaiter(this,void 0,void 0,(function*(){const t=Object.assign(Object.assign({},T),e);d.unless((e=>d.isTypeOf("string",e.channelUrl,!0)&&d.isArrayOf(h.ScheduledStatus,e.scheduledStatus,!0)&&d.isEnumOf(d.MessageTypeFilter,e.messageTypeFilter))(t)).throw(d.SendbirdError.invalidParameters);const{requestQueue:s}=d.Vault.of(this._iid),n=new Q(t),i=yield s.send(n),{count:a}=i.as(K);return a}))}getSubscribedTotalUnreadMessageCount(){const{subscribedUnreadMessageCount:e}=d.Vault.of(this._iid);return e.all>=0?e.all:0}getSubscribedCustomTypeTotalUnreadMessageCount(){let e=0;const{subscribedUnreadMessageCount:t}=d.Vault.of(this._iid);for(const s in t.customTypes)e+=t.customTypes[s];return e}getSubscribedCustomTypeUnreadMessageCount(e){var t;const{subscribedUnreadMessageCount:s}=d.Vault.of(this._iid);return null!==(t=s.customTypes[e])&&void 0!==t?t:0}createChannel(e){return d.__awaiter(this,void 0,void 0,(function*(){const t=Object.assign(Object.assign({},C),e);d.unless(E(t)).throw(d.SendbirdError.invalidParameters),t.isPublic||(t.accessCode=void 0);const s=new J(Object.assign({userId:this._sdkState.userId},t)),n=yield this._requestQueue.send(s),{channel:i}=n.as(Z);return yield this.upsertChannelsToCache([i]),i}))}markAsReadAll(){return d.__awaiter(this,void 0,void 0,(function*(){const e=Date.now();d.unless(e-this._markAsReadAllLastSentAt>=1e3).throw(d.SendbirdError.markAsReadAllRateLimitExceeded),this._markAsReadAllLastSentAt=e;const t=new X({userId:this._sdkState.userId});yield this._requestQueue.send(t);const s=this._groupChannelCache.channels;for(const t of s)t._updateUnreadMemberState(this._sdkState.userId,e),t._updateUnreadCount(0,0);s.length>0&&(yield this.upsertChannelsToCache(s))}))}markAsReadWithChannelUrls(e){return d.__awaiter(this,void 0,void 0,(function*(){const t=Date.now();d.unless(d.isArrayOf("string",e)&&t-this._markAsReadAllLastSentAt>=1e3).throw(d.SendbirdError.markAsReadAllRateLimitExceeded),this._markAsReadAllLastSentAt=t;const s=new X({userId:this._sdkState.userId,channelUrls:e});yield this._requestQueue.send(s);const n=this._groupChannelCache.channels,i=[];for(const s of n)e.includes(s.url)&&(s._updateUnreadMemberState(this._sdkState.userId,t),s._updateUnreadCount(0,0),i.push(s));i.length>0&&(yield this.upsertChannelsToCache(i))}))}markAsDelivered(e){return d.__awaiter(this,void 0,void 0,(function*(){const t=yield this.getChannel(e);yield t.markAsDelivered()}))}}var Te;!function(e){e[e.IDLE=0]="IDLE",e[e.RUNNING=1]="RUNNING",e[e.END=2]="END"}(Te||(Te={}));class Ue extends d.EventDispatcher{constructor(e,t,s=2,n=10){super(),this._state=Te.IDLE,this._retryCount=0,this._retryLimit=3,this.priority=0,this._worker=t}get isIdle(){return this._state===Te.IDLE}get isRunning(){return this._state===Te.RUNNING}get isDone(){return this._state===Te.END}get retryCount(){return this._retryCount}get retryLimit(){return this._retryLimit}_run(e){return d.__awaiter(this,void 0,void 0,(function*(){if(this.isRunning)try{const t=yield this._worker(e);this._retryCount=0,this.dispatch("progress",t),t.hasNext?this._run(t.nextToken):this.end()}catch(t){this.dispatch("error",t),this._retryCount`sendbird:${e}@groupchannel/${t}/message/sync`)(n.userId,t.url);this._prevSync=new Ue(_,(e=>d.__awaiter(this,void 0,void 0,(function*(){var s,n,a,l,c,_,p;const m={hasNext:!0,nextToken:0};if(this._prevSyncLoopCount++,yield this.loadMetadata(e),r.debug("message background prev sync from",null===(s=this._metadata)||void 0===s?void 0:s.range.top),null===(n=this._metadata)||void 0===n?void 0:n.previousComplete)m.hasNext=!1;else try{const t=h.MessageManager.of(this._iid),s=yield t.getMessagesByTimestamp(this._channel.url,this._channel.channelType,(null===(l=null===(a=this._metadata)||void 0===a?void 0:a.range)||void 0===l?void 0:l.top)?this._metadata.range.top:e,{prevResultSize:this._limit,nextResultSize:0,replyType:d.ReplyType.ALL,includeReactions:!0,includeMetaArray:!0,includeParentMessageInfo:!0,includeThreadInfo:!0},d.CollectionEventSource.SYNC_MESSAGE_BACKGROUND);if(s.length>0){const e=s.map((e=>e.createdAt));(null===(c=this._metadata)||void 0===c?void 0:c.range.intersect(...e))?this.extendRange(s):this._metadata={range:new u.TimeRange({top:Math.min(...e),bottom:Math.max(...e)}),previousComplete:!1}}m.hasNext=s.length>=this._limit&&this._prevSyncLoopCount<1,this._metadata&&(m.nextToken=this._metadata.range.top,this._metadata.previousComplete=s.lengthd.__awaiter(this,void 0,void 0,(function*(){var s,n,a,l,c,_;const p={hasNext:!0,nextToken:0};this._nextSyncLoopCount++,yield this.loadMetadata(e),r.debug("message background next sync from",null===(s=this._metadata)||void 0===s?void 0:s.range.bottom);try{const t=h.MessageManager.of(this._iid),s=yield t.getMessagesByTimestamp(this._channel.url,this._channel.channelType,(null===(a=null===(n=this._metadata)||void 0===n?void 0:n.range)||void 0===a?void 0:a.bottom)?this._metadata.range.bottom:e,{prevResultSize:0,nextResultSize:this._limit,replyType:d.ReplyType.ALL,includeReactions:!0,includeMetaArray:!0,includeParentMessageInfo:!0,includeThreadInfo:!0},d.CollectionEventSource.SYNC_MESSAGE_BACKGROUND);if(s.length>0){const e=s.map((e=>e.createdAt));(null===(l=this._metadata)||void 0===l?void 0:l.range.intersect(...e))?this.extendRange(s):this._metadata={range:new u.TimeRange({top:Math.min(...e),bottom:Math.max(...e)}),previousComplete:!1}}p.hasNext=s.length>=this._limit&&this._nextSyncLoopCount<1,this._metadata&&(p.nextToken=this._metadata.range.bottom),r.debug("message background next sync progress",p),yield this.saveMetadata()}catch(e){throw r.debug("message background next sync error",e),e}finally{o.put(new d.StatLog({type:d.StatType.FEATURE_LOCALCACHE_EVENT,ts:Date.now(),data:{channel_url:t.url,measured_on:"back_sync",event:"cache_fetch",max_db_size:null!==(_=null===(c=i.localCacheConfig)||void 0===c?void 0:c.maxSize)&&void 0!==_?_:0,use_local_cache:i.localCacheEnabled}}))}return p})))),this._connectionEventContext=a.on((e=>{if(e instanceof d.ConnectionStateChangeCommand)if(e.stateType===d.ConnectionStateType.CONNECTED)this.resume();else this.pause()}))}static of(e,t){return Ie[e]||(Ie[e]={}),Ie[e][t.url]||(Ie[e][t.url]=new Pe({_iid:e,channel:t})),Ie[e][t.url].ref++,Ie[e][t.url]}static clear(e,t){Ie[e]&&Ie[e][t]&&(Ie[e][t].close(),delete Ie[e])}get range(){var e,t;return null!==(t=null===(e=this._metadata)||void 0===e?void 0:e.range)&&void 0!==t?t:new u.TimeRange({})}get previousComplete(){var e;return!!(null===(e=this._metadata)||void 0===e?void 0:e.previousComplete)}isWrappingMessages(e){var t;return null===(t=this.range)||void 0===t?void 0:t.includes(...e.map((e=>e.createdAt)))}extendRange(e){this._metadata&&this._metadata.range.extends(...e.map((e=>e.createdAt)))}loadMetadata(e){return d.__awaiter(this,void 0,void 0,(function*(){if(!this._metadata){const{cacheContext:t}=d.Vault.of(this._iid),s=yield t.preference.get(this._metadataKey);s?s.range.bottom`sendbird:${e}@groupchannel/${t}/message/changelogs`)(n.userId,this._channel.url);this._sync=new Ue(o,(()=>d.__awaiter(this,void 0,void 0,(function*(){var e;const t={hasNext:!0,nextToken:0};yield this.loadMetadata(),s.debug("message changelog sync from",null===(e=this._metadata)||void 0===e?void 0:e.token);try{const e=h.MessageManager.of(this._iid),{updatedMessages:n,deletedMessageIds:i,hasMore:a,token:r}=yield e.getMessageChangelogs(this._channel.url,this._channel.channelType,this._metadata.token,{replyType:d.ReplyType.ALL,includeReactions:!0,includeThreadInfo:!0,includeMetaArray:!0,includeParentMessageInfo:!0},d.CollectionEventSource.SYNC_MESSAGE_CHANGELOGS);t.hasNext=a,t.nextToken=r,(n.length>0||i.length>0)&&this._metadata&&(this._metadata.token=r),s.debug("message changelog sync progress",t),yield this.saveMetadata()}catch(e){throw s.debug("message changelog sync error",e),e instanceof d.SendbirdError&&e.isInvalidTokenError&&(yield this.clearMetadata()),e}return t})))),this._connectionEventContext=i.on((e=>{if(e instanceof d.ConnectionStateChangeCommand)if(e.stateType===d.ConnectionStateType.CONNECTED)this.resume();else this.pause()}))}static of(e,t){return xe[e]||(xe[e]={}),xe[e][t.url]||(xe[e][t.url]=new Oe({_iid:e,channel:t})),xe[e][t.url].ref++,xe[e][t.url]}static clear(e,t){xe[e]&&xe[e][t]&&(xe[e][t].close(),delete xe[e])}loadMetadata(){return d.__awaiter(this,void 0,void 0,(function*(){if(!this._metadata){const{cacheContext:e,firstConnectedAt:t}=d.Vault.of(this._iid),s=yield e.preference.get(this._metadataKey);this._metadata={token:s?s.token:t}}return this._metadata}))}saveMetadata(){return d.__awaiter(this,void 0,void 0,(function*(){if(this._metadata){const{cacheContext:e}=d.Vault.of(this._iid);return yield e.preference.set(this._metadataKey,this._metadata),!0}return!1}))}clearMetadata(){return d.__awaiter(this,void 0,void 0,(function*(){const{cacheContext:e}=d.Vault.of(this._iid);yield e.preference.remove(this._metadataKey),this._metadata=void 0}))}resume(){const{logger:e,connectionManager:t}=d.Vault.of(this._iid);t.isConnected&&(e.debug("message changelog sync resume()"),this._sync.start(0))}pause(){const{logger:e,connectionManager:t}=d.Vault.of(this._iid);e.debug("message changelog sync pause()"),this._sync.stop()}close(){this.ref--,this.ref<=0&&(this.ref=0,this.pause(),this._connectionEventContext.close(),delete xe[this._iid][this._channel.url])}}const Re={};class we{constructor({_iid:e,channel:t,hasPollMessage:s}){this.ref=0,this._iid=e,this._channel=t;const{logger:n,sdkState:i,dispatcher:a}=d.Vault.of(this._iid);var r,o;this._metadataKey=(r=i.userId,o=t.url,`sendbird:${r}@groupchannel/${o}/poll/changelogs.meta`);const l=((e,t)=>`sendbird:${e}@groupchannel/${t}/poll/changelogs`)(i.userId,this._channel.url);this._sync=new Ue(l,(()=>d.__awaiter(this,void 0,void 0,(function*(){var e;const t={hasNext:!0,nextToken:0};if(yield this.loadMetadata(),n.debug("poll changelog sync from",null===(e=this._metadata)||void 0===e?void 0:e.token),!(this._metadata&&this._metadata.token||(yield s()))){return{hasNext:!1,nextToken:0}}if(!this._metadata){const{firstConnectedAt:e}=d.Vault.of(this._iid);this._metadata={token:e}}try{const e=d.PollManager.of(this._iid),{hasMore:s,token:i}=yield e.getPollChangeLogs(this._channel.url,this._channel.channelType,this._metadata.token);t.hasNext=s,t.nextToken=i,this._metadata.token=i,n.debug("poll changelog sync progress",t),yield this.saveMetadata()}catch(e){throw n.debug("poll changelog sync error",e),e instanceof d.SendbirdError&&e.isInvalidTokenError&&(yield this.clearMetadata()),e}return t})))),this._connectionEventContext=a.on((e=>{if(e instanceof d.ConnectionStateChangeCommand)if(e.stateType===d.ConnectionStateType.CONNECTED)this.resume();else this.pause()}))}static of(e,t,s){return Re[e]||(Re[e]={}),Re[e][t.url]||(Re[e][t.url]=new we({_iid:e,channel:t,hasPollMessage:s})),Re[e][t.url].ref++,Re[e][t.url]}loadMetadata(){return d.__awaiter(this,void 0,void 0,(function*(){if(!this._metadata){const{cacheContext:e}=d.Vault.of(this._iid),t=yield e.preference.get(this._metadataKey);this._metadata=t?{token:t.token}:void 0}}))}saveMetadata(){return d.__awaiter(this,void 0,void 0,(function*(){if(this._metadata){const{cacheContext:e}=d.Vault.of(this._iid);yield e.preference.set(this._metadataKey,this._metadata)}}))}clearMetadata(){return d.__awaiter(this,void 0,void 0,(function*(){const{cacheContext:e}=d.Vault.of(this._iid);yield e.preference.remove(this._metadataKey),this._metadata=void 0}))}resume(){const{logger:e}=d.Vault.of(this._iid);e.debug("poll changelog sync resume()"),this._sync.start(0)}pause(){const{logger:e}=d.Vault.of(this._iid);e.debug("poll changelog sync pause()"),this._sync.stop()}close(){this.ref--,this.ref<=0&&(this.ref=0,this.pause(),this._connectionEventContext.close(),delete Re[this._iid][this._channel.url])}}const Le=(e,t)=>t instanceof h.SendableMessage?e.findIndex((e=>e instanceof h.SendableMessage&&t.isIdentical(e))):e.findIndex((e=>e.isIdentical(t))),Fe=(e,t)=>e.findIndex((e=>e.messageId===t)),De=(e,t)=>{if(e.length>0){let s=0,n=e.length-1,i=Math.floor((s+n)/2);for(;s0)n=i,i=Math.floor((s+n)/2);else{if(!(a<0))return i;s=i+1,i=Math.floor((s+n)/2)}}return e[i].createdAt>t.createdAt?i:i+1}return e.length};class ke extends d.BaseCommand{constructor({channels:e,source:t,isWebSocketEventComing:s=!1,data:n=null}){super(),this.channels=e,this.source=t,this.isWebSocketEventComing=s,this.data=n}}class He extends d.BaseCommand{constructor({channelUrls:e,source:t,isWebSocketEventComing:s=!1}){super(),this.channelUrls=e,this.source=t,this.isWebSocketEventComing=s}}class Ve extends d.APIRequestCommand{constructor(e){var t,s,n,i,a,r,o,l,h,c;super(),this.method=d.APIRequestMethod.GET,this.path=`${d.getChannelApiPathByType(e.channelType)}/${e.channelUrl}/messages_gap`,this.params=d.deundefined({prev_start_ts:e.prevStart,prev_end_ts:e.prevEnd,prev_cache_count:e.prevCount,next_start_ts:e.nextStart,next_end_ts:e.nextEnd,next_cache_count:e.nextCount,huge_gap_threshold:null!==(t=e.threshold)&&void 0!==t?t:null,reverse:!0,custom_types:null!==(s=e.customTypes)&&void 0!==s?s:["*"],message_type:null!==(n=e.messageType)&&void 0!==n?n:null,include_reply_type:null!==(i=e.replyType)&&void 0!==i?i:d.ReplyType.NONE,include_reactions:null===(a=e.includeReactions)||void 0===a||a,include_meta_array:null===(r=e.includeMetaArray)||void 0===r||r,include_thread_info:null===(o=e.includeThreadInfo)||void 0===o||o,include_parent_message_info:null===(l=e.includeParentMessageInfo)||void 0===l||l,with_sorted_meta_array:null===(h=e.includeMetaArray)||void 0===h||h,show_subchannel_messages_only:null!==(c=e.showSubchannelMessagesOnly)&&void 0!==c&&c,include_poll_details:!0,checking_continuous_messages:e.checkingContinuousMessages})}}class Ge extends d.APIResponseCommand{constructor(e,t){var s,n,i,a,r,o;super(e,t),this.isHugeGap=t.is_huge_gap,this.prevMessages=(null!==(s=t.prev_messages)&&void 0!==s?s:[]).map((t=>h.parseMessagePayload(e,t))),this.prevHasMore=null!==(n=t.prev_hasmore)&&void 0!==n&&n,this.isContinuousPrevMessages=null!==(i=t.is_continuous_prev_messages)&&void 0!==i&&i,this.nextMessages=(null!==(a=t.next_messages)&&void 0!==a?a:[]).map((t=>h.parseMessagePayload(e,t))),this.nextHasmore=null!==(r=t.next_hasmore)&&void 0!==r&&r,this.isContinuousNextMessages=null!==(o=t.is_continuous_next_messages)&&void 0!==o&&o}}class qe{constructor(e){this.source=e}}class Be extends qe{}class je extends qe{}class ze{constructor(e){this.source=e}}class We extends ze{}class $e extends ze{}const Qe=6e5,Ke={includeMetaArray:!0,includeReactions:!0,includeThreadInfo:!0,includeParentMessageInfo:!0};exports.MessageCollectionInitPolicy=void 0,(exports.MessageCollectionInitPolicy||(exports.MessageCollectionInitPolicy={})).CACHE_AND_REPLACE_BY_API="cache_and_replace_by_api";class Ye{constructor(){this._onCacheResult=d.noop,this._onApiResult=d.noop}_invokeResponse(e,t,s){d.runAsCallback((()=>d.__awaiter(this,void 0,void 0,(function*(){switch(e){case"local":this._onCacheResult(t,s);break;case"remote":this._onApiResult(t,s)}}))))}onCacheResult(e){return this._onCacheResult=e,this}onApiResult(e){return this._onApiResult=e,this}}class Je{constructor(e,{filter:t,startingPoint:s,limit:n,channel:i,channelManager:a,disableBackgroundSync:r=!1}){this._messages=[],this._unsentMessages=[],this._iid=e,this._key=`mc-${d.uuid()}`,this._isDisposed=!1,this.filter=null!=t?t:new h.MessageFilter,this._channel=i,this._syncRange=new u.TimeRange({}),this._hasPrevious=!0,this._hasNext=!0,this._startingPoint="number"==typeof s?s:Date.now()+Qe,this._limit=n||h.DEFAULT_MESSAGE_LIMIT,this._channelManager=a,this._channelManager.subscribeChannelEvent(this._key,{onUpdate:(e,t,s)=>{const n=e.findIndex((e=>e.isIdentical(this.channel)));n>=0&&(this._replaceChannelOfCollection(e[n]),this.channel._runIfHandleableWithGroupChannel((e=>{switch(t){case d.CollectionEventSource.EVENT_CHANNEL_UPDATED:{let t=!1;for(const s in this._messages){if(this._messages[s].createdAt>=e.messageOffsetTimestamp){t=!0;const e=parseInt(s);if(e>0){const t=this._messages.splice(0,e);this._removeMessagesFromView(t.map((e=>e.messageId)),d.CollectionEventSource.EVENT_MESSAGE_OFFSET_UPDATED)}break}}!t&&this._messages.length>0&&this._removeMessagesFromView(this._messages.map((e=>e.messageId)),d.CollectionEventSource.EVENT_MESSAGE_OFFSET_UPDATED);break}case d.CollectionEventSource.EVENT_CHANNEL_UNMUTED:{const{sdkState:e}=d.Vault.of(this._iid),t=s;e.userId===t&&this._clearCheckMyMutedTimer();break}case d.CollectionEventSource.EVENT_CHANNEL_MUTED:{const{sdkState:t}=d.Vault.of(this._iid),n=s;t.userId===n&&-1!==e._myMutedRemainingTime&&this._startCheckMyMutedTimer(e._myMutedRemainingTime);break}case d.CollectionEventSource.EVENT_CHANNEL_LEFT:e.isPublic&&this._clearCheckMyMutedTimer()}d.runAsCallback((()=>d.__awaiter(this,void 0,void 0,(function*(){var e;const s=this._createChannelEventContext(t);I(t)&&(null===(e=this._handler)||void 0===e?void 0:e.onChannelUpdated)&&this._handler.onChannelUpdated(s,this.channel)}))))})))},onRemove:(e,t)=>{e.indexOf(this.channel.url)>=0&&(this._clearCheckMyMutedTimer(),d.runAsCallback((()=>d.__awaiter(this,void 0,void 0,(function*(){var e;const s=this._createChannelEventContext(t);(null===(e=this._handler)||void 0===e?void 0:e.onChannelDeleted)&&this._handler.onChannelDeleted(s,this.channel.url)})))))}}),this._channelManager.subscribeMessageEvent(this._key,{onUpdate:(e,t)=>{const s=[],n=[];for(const t of e)t.channelUrl===this._channel.url&&(this.filter.match(t)?s.push(t):n.push(t.messageId));if(d.shouldGiveEvent(t)){if(s.length>0)switch(t){case d.CollectionEventSource.LOCAL_MESSAGE_CANCELED:case d.CollectionEventSource.LOCAL_MESSAGE_RESEND_STARTED:case d.CollectionEventSource.EVENT_MESSAGE_SENT_FAILED:case d.CollectionEventSource.EVENT_MESSAGE_SENT_SUCCESS:case d.CollectionEventSource.EVENT_MESSAGE_UPDATED:case d.CollectionEventSource.EVENT_MESSAGE_THREADINFO_UPDATED:case d.CollectionEventSource.EVENT_MESSAGE_REACTION_UPDATED:case d.CollectionEventSource.SYNC_MESSAGE_CHANGELOGS:this._updateMessagesToView(s,t);break;case d.CollectionEventSource.EVENT_MESSAGE_SENT_PENDING:this._addMessagesToView(s,t);break;case d.CollectionEventSource.EVENT_MESSAGE_RECEIVED:this.hasNext||this._addMessagesToView(s,t);break;case d.CollectionEventSource.SYNC_MESSAGE_FILL:this._addMessagesToView(s,t)}n.length>0&&this._removeMessagesFromView(n,t)}},onRemove:(e,t)=>{this._removeMessagesFromView(e,t)},onRemoveUnsent:(e,t)=>{this._removeUnsentMessageFromView(e,t)},onPollChangeLogUpdate:(e,t)=>{this._updatePollsToView(e,t)},onPollUpdate:(e,t)=>{this._applyPollUpdateEventToView(e,t)},onPollVote:(e,t)=>{this._applyPollVoteEventToView(e,t)}});const{cacheContext:o,dispatcher:l}=d.Vault.of(this._iid);this._channel._updateMessageCollectionLastAccessedAt();const c=this._createChannelUpdateEventCommand(d.CollectionEventSource.CHANNEL_LASTACCESSEDAT_UPDATED);c&&l.dispatch(c),!r&&this._shouldStartBackgroundSync()&&(this._backgroundSync=Pe.of(this._iid,this._channel),this._backgroundSync.resume(this._startingPoint)),this._changelogSync=Oe.of(this._iid,this._channel),this._changelogSync.resume(),this._pollChangelogSync=we.of(this._iid,this._channel,this._hasPollMessage.bind(this)),this._pollChangelogSync.resume(),this._prevFill=new Ue(this._key,(e=>d.__awaiter(this,void 0,void 0,(function*(){var t,s,n;const{messages:i,isContinuousMessages:a}=yield this._getRemoteMessages(e,{prevLimit:this._limit,source:d.CollectionEventSource.SYNC_MESSAGE_FILL,checkingContinuousMessages:o.localCacheEnabled});if(i.length>0){const e=Math.min(...i.map((e=>e.createdAt)));return this._syncRange.extends(e),a&&(null===(t=this._backgroundSync)||void 0===t||t.range.extends(e)),{hasNext:i.length>=this._limit&&this.viewTopd.__awaiter(this,void 0,void 0,(function*(){var t,s,n;const{messages:i,isContinuousMessages:a}=yield this._getRemoteMessages(e,{nextLimit:this._limit,source:d.CollectionEventSource.SYNC_MESSAGE_FILL,checkingContinuousMessages:o.localCacheEnabled});if(i.length>0){const e=Math.max(...i.map((e=>e.createdAt)));return this._syncRange.extends(e),a&&(null===(t=this._backgroundSync)||void 0===t||t.range.extends(e)),{hasNext:!(i.length>=this._limit&&this._hasNext)||this.viewBottom>e,nextToken:this._syncRange.bottom}}return _.put(new d.StatLog({type:d.StatType.FEATURE_LOCALCACHE_EVENT,ts:Date.now(),data:{channel_url:this.channel.url,measured_on:"gap_check",event:"cache_fetch",max_db_size:null!==(n=null===(s=o.localCacheConfig)||void 0===s?void 0:s.maxSize)&&void 0!==n?n:0,use_local_cache:o.localCacheEnabled}})),{hasNext:!1,nextToken:0}})))),this._connectionEventContext=l.on((e=>{if(e instanceof d.ConnectionStateChangeCommand)switch(e.stateType){case d.ConnectionStateType.CONNECTED:d.runOrNothing((()=>d.__awaiter(this,void 0,void 0,(function*(){this._activate()}))));break;case d.ConnectionStateType.LOGOUT:this.dispose();break;default:this._clearCheckMyMutedTimer(),this._prevFill.stop(),this._nextFill.stop()}}));const{statLogCollector:_}=d.Vault.of(this._iid);_.put(new d.DailyRecordStatLog({type:d.StatType.FEATURE_LOCALCACHE,data:{use_local_cache:o.localCacheEnabled,collection_interface:{message:!0}}}))}get channel(){return this._channel}get succeededMessages(){return[...this._messages]}get failedMessages(){return this._unsentMessages.filter((e=>e.sendingStatus===d.SendingStatus.FAILED))}get pendingMessages(){return this._unsentMessages.filter((e=>e.sendingStatus===d.SendingStatus.PENDING))}get hasPrevious(){return this._hasPrevious}get hasNext(){return this._hasNext}get viewTop(){return Math.min(...this._messages.map((e=>e.createdAt)),Number.MAX_SAFE_INTEGER)}get viewBottom(){return Math.max(...this._messages.map((e=>e.createdAt)),0)}_activate(){return d.__awaiter(this,void 0,void 0,(function*(){const{logger:e}=d.Vault.of(this._iid);e.debug("check huge gap"),this._checkHugeGap(),yield this._refreshChannel(d.CollectionEventSource.SYNC_CHANNEL_CHANGELOGS)}))}_replaceChannelOfCollection(e){this._channel.isGroupChannel()?this._channel=e:this._channel.isFeedChannel()&&(this._channel._groupChannel=e._groupChannel)}_shouldStartBackgroundSync(){const{cacheContext:e}=d.Vault.of(this._iid);return this.channel.isGroupChannel()?e.localCacheEnabled&&!this.channel.isSuper:e.localCacheEnabled}_createChannelEventContext(e){switch(!0){case this.channel.isGroupChannel():return new Be(e);case this.channel.isFeedChannel():return new je(e);default:throw new d.SendbirdError({code:d.SendbirdErrorCode.WRONG_CHANNEL_TYPE,message:"Wrong channel type"})}}_createMessageEventContext(e){switch(!0){case this.channel.isGroupChannel():return new We(e);case this.channel.isFeedChannel():return new $e(e);default:throw new d.SendbirdError({code:d.SendbirdErrorCode.WRONG_CHANNEL_TYPE,message:"Wrong channel type"})}}_createChannelUpdateEventCommand(e){switch(!0){case this.channel.isGroupChannel():return new P({channels:[this._channel],source:e});case this.channel.isFeedChannel():return new ke({channels:[this._channel],source:e});default:return null}}_setBaseMessageCollectionHandler(e){this._handler=e}_filterUnderOffsetMessage(e){return e}_addMessagesToView(e,t){const s=this._filterUnderOffsetMessage(e),n=[],i=[];for(const e of s)if(t===d.CollectionEventSource.SYNC_MESSAGE_FILL){if(e.messageId>0){if(Le(this._messages,e)<0){Le(this._unsentMessages,e)<0&&n.push(e);const t=De(this._messages,e);this._messages.splice(t,0,e)}}else if(e instanceof h.SendableMessage){Le(this._unsentMessages,e)<0&&Le(this._messages,e)<0&&(this._unsentMessages.push(e),n.push(e))}}else if(e.messageId>0){const t=Le(this._messages,e);if(t<0){const t=Le(this._unsentMessages,e);t<0?n.push(e):(this._unsentMessages.splice(t,1),i.push(e));const s=De(this._messages,e);this._messages.splice(s,0,e)}else i.push(e),this._messages[t]=e;if(e.updatedAt>0){const t=this._updateChildMessagesInView(e);i.push(...t)}}else if(e instanceof h.SendableMessage){const t=Le(this._unsentMessages,e);t<0?Le(this._messages,e)<0&&(this._unsentMessages.push(e),n.push(e)):(i.push(e),this._unsentMessages[t]=e)}d.shouldGiveEvent(t)&&d.runAsCallback((()=>d.__awaiter(this,void 0,void 0,(function*(){var e,s,a,r;const o=this._createMessageEventContext(t);n.length>0&&(null===(s=null===(e=this._handler)||void 0===e?void 0:e.onMessagesAdded)||void 0===s||s.call(e,o,this.channel,n)),i.length>0&&(null===(r=null===(a=this._handler)||void 0===a?void 0:a.onMessagesUpdated)||void 0===r||r.call(a,o,this.channel,i))}))))}_updateChildMessagesInView(e){const t=[];return this._messages.forEach((s=>{s.parentMessageId===e.messageId&&s.applyParentMessage(e)&&t.push(s)})),t}_updatePollsToView(e,t){const s=[];for(const t of e){const e=Fe(this._messages,t.messageId);if(e>=0){const n=this._messages[e];n&&n.applyPoll(t),s.push(n)}}return s.length>0&&d.shouldGiveEvent(t)&&d.runAsCallback((()=>d.__awaiter(this,void 0,void 0,(function*(){var e,n;const i=this._createMessageEventContext(t);s.length>0&&(null===(n=(e=this._handler).onMessagesUpdated)||void 0===n||n.call(e,i,this.channel,s))})))),s}_applyPollUpdateEventToView(e,t){const s=Fe(this._messages,e.messageId);if(s>=0){const n=this._messages[s];n&&n.isUserMessage()&&n.poll&&n.poll.applyPollUpdateEvent(e)&&d.shouldGiveEvent(t)&&d.runAsCallback((()=>d.__awaiter(this,void 0,void 0,(function*(){var e,s;const i=this._createMessageEventContext(t);null===(s=null===(e=this._handler)||void 0===e?void 0:e.onMessagesUpdated)||void 0===s||s.call(e,i,this.channel,[n])}))))}}_applyPollVoteEventToView(e,t){const s=Fe(this._messages,e.messageId);if(s>=0){const n=this._messages[s];n&&n.isUserMessage()&&n.poll&&n.poll.applyPollVoteEvent(e)&&d.shouldGiveEvent(t)&&d.runAsCallback((()=>d.__awaiter(this,void 0,void 0,(function*(){var e,s;const i=this._createMessageEventContext(t);null===(s=null===(e=this._handler)||void 0===e?void 0:e.onMessagesUpdated)||void 0===s||s.call(e,i,this.channel,[n])}))))}}_updateMessagesToView(e,t){const s=[],n=[],i=[];for(const t of e)if(t.messageId>0){const e=Le(this._messages,t);if(e>=0)n.push(t),this._messages[e]=t;else{const e=Le(this._unsentMessages,t);if(e>=0){const s=this._unsentMessages.splice(e,1);if(this.hasNext&&s.length>0)i.push(s[0]);else{n.push(t);const e=De(this._messages,t);this._messages.splice(e,0,t)}}else{const e=this._messages.map((e=>e.createdAt));(t.createdAtMath.max(...e)&&!this._hasNext)&&s.push(t)}}}else if(t instanceof h.SendableMessage){const e=Le(this._unsentMessages,t);e>=0&&(n.push(t),this._unsentMessages[e]=t)}return d.shouldGiveEvent(t)&&d.runAsCallback((()=>d.__awaiter(this,void 0,void 0,(function*(){var e,a,r,o;const l=this._createMessageEventContext(t);n.length>0?null===(a=null===(e=this._handler)||void 0===e?void 0:e.onMessagesUpdated)||void 0===a||a.call(e,l,this.channel,n):i.length>0?null===(o=null===(r=this._handler)||void 0===r?void 0:r.onMessagesDeleted)||void 0===o||o.call(r,l,this.channel,[],i):s.length>0&&this._addMessagesToView(s,t)})))),n}_removeMessagesFromView(e,t){const s=[],n=[];for(const t of e){const e=this._messages.findIndex((e=>e.messageId===t));if(e>=0){const t=this._messages[e];s.push(t.messageId),n.push(t),this._messages.splice(e,1)}}return d.shouldGiveEvent(t)&&n.length>0&&d.runAsCallback((()=>d.__awaiter(this,void 0,void 0,(function*(){var e,i;const a=this._createMessageEventContext(t);null===(i=null===(e=this._handler)||void 0===e?void 0:e.onMessagesDeleted)||void 0===i||i.call(e,a,this.channel,s,n)})))),s}_removeUnsentMessageFromView(e,t){const s=this._unsentMessages.findIndex((t=>t.reqId===e));s>=0&&this._unsentMessages.splice(s,1)}_getLocalMessages(e,{prevLimit:t=0,nextLimit:s=0,inclusive:n=!0}){return d.__awaiter(this,void 0,void 0,(function*(){let i=[];n&&(i=yield this._channelManager.getExactlyMatchingMessagesForTokenFromCache(this._channel.url,e,this.filter));const a=t>0?yield this._channelManager.getMessagesFromCache(this._channel.url,e,"prev",this.filter,t,!1):[],r=s>0?yield this._channelManager.getMessagesFromCache(this._channel.url,e,"next",this.filter,s,!1):[];return[...i,...a,...r].sort(((e,t)=>t.createdAt-e.createdAt))}))}_getRemoteMessages(e,{prevLimit:t=0,nextLimit:s=0,source:n=d.CollectionEventSource.REQUEST_MESSAGE,reverse:i=!1,checkingHasNext:a=!1,checkingContinuousMessages:r=!1}){return d.__awaiter(this,void 0,void 0,(function*(){const o=h.MessageManager.of(this._iid);return t>0||s>0?yield o._getMessagesByTimestampForCollection(this._channel.url,this._channel.channelType,e,d.undefineNullProps(Object.assign(Object.assign(Object.assign({},this.filter),Ke),{isInclusive:!0,reverse:i,prevResultSize:t,nextResultSize:s})),n,a,r):{messages:[],isContinuousMessages:!1}}))}_checkHugeGap(){var e,t,s,n,i;return d.__awaiter(this,void 0,void 0,(function*(){const{dispatcher:a,requestQueue:r,cacheContext:o,statLogCollector:l}=d.Vault.of(this._iid);if(this._messages.length>0){const s=this._syncRange.top,n=this.viewTop,i=this._syncRange.bottom,h=this.hasNext?this.viewBottom:Number.MAX_SAFE_INTEGER,c=yield this._channelManager.getCachedMessageCountBetween(this._channel.url,this.filter,n,s),u=yield this._channelManager.getCachedMessageCountBetween(this._channel.url,this.filter,i,h);try{yield d.asyncRetry((()=>d.__awaiter(this,void 0,void 0,(function*(){var e;const t=new Ve(Object.assign(Object.assign({channelUrl:this._channel.url,channelType:this._channel.channelType,prevStart:n,prevEnd:s,prevCount:c,nextStart:i,nextEnd:h,nextCount:u,checkingContinuousMessages:o.localCacheEnabled},this.filter),Ke)),l=yield r.send(t),{isHugeGap:_,prevMessages:p=[],prevHasMore:m,isContinuousPrevMessages:g,nextMessages:C=[],nextHasmore:E,isContinuousNextMessages:v}=l.as(Ge);if(_)d.runAsCallback((()=>d.__awaiter(this,void 0,void 0,(function*(){var e;(null===(e=this._handler)||void 0===e?void 0:e.onHugeGapDetected)&&this._handler.onHugeGapDetected()}))));else{const t=this.viewTop,s=this.viewBottom,n=Math.min(Number.MAX_SAFE_INTEGER,t,...p.map((e=>e.createdAt))),i=Math.max(0,s,...C.map((e=>e.createdAt)));a.dispatch(new d.MessageUpdateEventCommand({messages:p,source:d.CollectionEventSource.SYNC_MESSAGE_FILL})),a.dispatch(new d.MessageUpdateEventCommand({messages:C,source:d.CollectionEventSource.SYNC_MESSAGE_FILL})),this._syncRange.extends(n,i),(g||v)&&(null===(e=this._backgroundSync)||void 0===e||e.range.extends(n,i)),m&&this._prevFill.start(n),E&&this._nextFill.start(i)}}))),1)}finally{l.put(new d.StatLog({type:d.StatType.FEATURE_LOCALCACHE_EVENT,ts:Date.now(),data:{channel_url:this.channel.url,measured_on:"gap_check",event:"cache_fetch",max_db_size:null!==(t=null===(e=o.localCacheConfig)||void 0===e?void 0:e.maxSize)&&void 0!==t?t:0,use_local_cache:o.localCacheEnabled}}))}}else{const e=Math.floor(this._limit/2),t=Date.now();try{const{messages:n,isContinuousMessages:i,hasNext:a}=yield this._getRemoteMessages(t,{prevLimit:e,nextLimit:e,source:d.CollectionEventSource.SYNC_MESSAGE_FILL,checkingHasNext:!0,checkingContinuousMessages:o.localCacheEnabled});if(n.length>0){const r=n.map((e=>e.createdAt));let o=0,l=0;for(let e=0;e=t&&l++}this._hasPrevious=o>=e,this._hasNext=null!=a?a:l>=e,this._syncRange.extends(...r),i&&(null===(s=this._backgroundSync)||void 0===s||s.range.extends(this._syncRange.top,this._syncRange.bottom)),this._addMessagesToView(n,d.CollectionEventSource.SYNC_MESSAGE_FILL)}else this._hasPrevious=!1,this._hasNext=!1}catch(e){e instanceof d.SendbirdError&&e.code===d.SendbirdErrorCode.NOT_FOUND_IN_DATABASE&&(this._hasPrevious=!1,this._hasNext=!1)}finally{l.put(new d.StatLog({type:d.StatType.FEATURE_LOCALCACHE_EVENT,ts:Date.now(),data:{channel_url:this.channel.url,measured_on:"gap_check",event:"cache_fetch",max_db_size:null!==(i=null===(n=o.localCacheConfig)||void 0===n?void 0:n.maxSize)&&void 0!==i?i:0,use_local_cache:o.localCacheEnabled}}))}}}))}_loadUnsentMessages(){return d.__awaiter(this,void 0,void 0,(function*(){this._unsentMessages=yield this._channelManager.getUnsentMessagesFromCache(this._channel.url,this.filter)}))}_hasPollMessage(){return d.__awaiter(this,void 0,void 0,(function*(){return(yield this._channelManager.getPollMessagesFromCache(this._channel.url,Date.now()+Qe,this.filter,1)).length>0}))}_refreshChannel(e){this._channelManager.refreshChannel(this.channel.url,!0,e)}_startCheckMyMutedTimer(e){this._clearCheckMyMutedTimer(),this._checkMyMutedStateTimer=setTimeout((()=>d.__awaiter(this,void 0,void 0,(function*(){this._checkMyMutedStateTimer=void 0;let e=!0;try{e=!(yield this._channel.getMyMutedInfo()).isMuted}catch(t){e=!0}finally{e&&this.channel._runIfHandleableWithGroupChannel((e=>{var t,s;e.myMutedState=d.MutedState.UNMUTED;const n=this._createChannelEventContext(d.CollectionEventSource.EVENT_CHANNEL_UNMUTED);null===(s=null===(t=this._handler)||void 0===t?void 0:t.onChannelUpdated)||void 0===s||s.call(t,n,this.channel)}))}}))),e+1e3)}_clearCheckMyMutedTimer(){this._checkMyMutedStateTimer&&(clearTimeout(this._checkMyMutedStateTimer),this._checkMyMutedStateTimer=void 0)}initialize(e){const t=new Ye;this._messages=[],this._unsentMessages=[],this._syncRange=new u.TimeRange({}),this._hasNext=!0,this._hasPrevious=!0,this._refreshChannel(d.CollectionEventSource.REFRESH_CHANNEL),d.runOrNothing((()=>d.__awaiter(this,void 0,void 0,(function*(){const e=yield this.channel.getMyMutedInfo();e.isMuted&&-1!==e.remainingDuration&&this._startCheckMyMutedTimer(e.remainingDuration)}))));const{cacheContext:s,statLogCollector:n}=d.Vault.of(this._iid),i=Math.floor(this._limit/2);if(e===exports.MessageCollectionInitPolicy.CACHE_AND_REPLACE_BY_API)this._getLocalMessages(this._startingPoint,{prevLimit:i,nextLimit:i}).then((e=>d.__awaiter(this,void 0,void 0,(function*(){const s=this._filterUnderOffsetMessage(e);this._addMessagesToView(s,d.CollectionEventSource.REQUEST_MESSAGE),yield this._loadUnsentMessages(),t._invokeResponse("local",null,s)})))).catch((e=>{if(d.isThrowingOutside(e))throw e;t._invokeResponse("local",e,null)})).finally((()=>{const{cacheContext:s}=d.Vault.of(this._iid);this._getRemoteMessages(this._startingPoint,{prevLimit:i,nextLimit:i,reverse:!0,checkingHasNext:!0,checkingContinuousMessages:s.localCacheEnabled}).then((({messages:a,isContinuousMessages:r,hasNext:o})=>{var l,h,c,u,_;const p=this._filterUnderOffsetMessage(a);let m=!0;if(this._messages.length===p.length){const e=this._messages.map((e=>e.messageId));for(const t in p)if(!e.includes(p[t].messageId)){m=!1;break}}else m=!1;if(this._messages=[],p.length>0){const e=p.map((e=>e.createdAt));let t=0,s=0;for(let n=0;nthis._startingPoint&&s++}this._hasPrevious=t>=i,this._hasNext=null!=o?o:s>=i,this._syncRange.extends(...p.map((e=>e.createdAt))),r&&(null===(l=this._backgroundSync)||void 0===l||l.range.extends(this._syncRange.top,this._syncRange.bottom)),this._addMessagesToView(p,d.CollectionEventSource.REQUEST_MESSAGE)}else this._hasPrevious=!1,this._hasNext=!1;n.put(new d.StatLog({type:d.StatType.FEATURE_LOCALCACHE_EVENT,ts:Date.now(),data:{channel_url:this.channel.url,starting_point:this._startingPoint,measured_on:"initial_load",event:m?"cache_hit":"cache_miss",max_db_size:null!==(c=null===(h=s.localCacheConfig)||void 0===h?void 0:h.maxSize)&&void 0!==c?c:0,message_init_policy:e,use_local_cache:s.localCacheEnabled,collection_id:this._key}})),n.put(new d.StatLog({type:d.StatType.FEATURE_LOCALCACHE_EVENT,ts:Date.now(),data:{channel_url:this.channel.url,starting_point:this._startingPoint,measured_on:"initial_load",event:"cache_fetch",max_db_size:null!==(_=null===(u=s.localCacheConfig)||void 0===u?void 0:u.maxSize)&&void 0!==_?_:0,message_init_policy:e,use_local_cache:s.localCacheEnabled,collection_id:this._key}})),t._invokeResponse("remote",null,p)})).catch((e=>{if(d.isThrowingOutside(e))throw e;t._invokeResponse("remote",e,null)}))}));return n.put(new d.DailyRecordStatLog({type:d.StatType.FEATURE_LOCALCACHE,data:{use_local_cache:s.localCacheEnabled,collection_interface:{message_init_policy:e}}})),t}loadPrevious(){var e,t,s;return d.__awaiter(this,void 0,void 0,(function*(){if(this._isDisposed)throw new d.SendbirdError({code:d.SendbirdErrorCode.COLLECTION_DISPOSED,message:"Collection has been disposed."});if(!this._hasPrevious)return[];const n=Math.floor(this._limit/2),i=this.viewTop;let a=[];yield d.runOrNothing((()=>d.__awaiter(this,void 0,void 0,(function*(){a=this._filterUnderOffsetMessage(yield this._getLocalMessages(i,{prevLimit:n,inclusive:!1}))}))));const r=a.length>=n,{cacheContext:o,statLogCollector:l}=d.Vault.of(this._iid);return l.put(new d.StatLog({type:d.StatType.FEATURE_LOCALCACHE_EVENT,ts:Date.now(),data:{channel_url:this.channel.url,starting_point:this._startingPoint,measured_on:"load_prev",event:r?"cache_hit":"cache_miss",max_db_size:null!==(t=null===(e=o.localCacheConfig)||void 0===e?void 0:e.maxSize)&&void 0!==t?t:0,use_local_cache:o.localCacheEnabled,collection_id:this._key}})),r&&(null===(s=this._backgroundSync)||void 0===s?void 0:s.isWrappingMessages(a))?(this._hasPrevious=a.length>=n,a.length>0&&this._addMessagesToView(a,d.CollectionEventSource.REQUEST_MESSAGE)):(yield d.runOrNothing((()=>d.__awaiter(this,void 0,void 0,(function*(){var e,t,s,r;const{cacheContext:o}=d.Vault.of(this._iid),h=yield this._getRemoteMessages(i,{prevLimit:n,reverse:!0,checkingContinuousMessages:o.localCacheEnabled});a=this._filterUnderOffsetMessage(h.messages),a=a.filter((e=>Le(this._messages,e)<0)),this._hasPrevious=a.length>=n,a.length>0&&(this._syncRange.extends(...a.map((e=>e.createdAt))),(null===(e=this._backgroundSync)||void 0===e?void 0:e.range.overlap(this._syncRange))&&h.isContinuousMessages&&(null===(t=this._backgroundSync)||void 0===t||t.range.extends(this._syncRange.top))),l.put(new d.StatLog({type:d.StatType.FEATURE_LOCALCACHE_EVENT,ts:Date.now(),data:{channel_url:this.channel.url,starting_point:this._startingPoint,measured_on:"load_prev",event:"cache_fetch",max_db_size:null!==(r=null===(s=o.localCacheConfig)||void 0===s?void 0:s.maxSize)&&void 0!==r?r:0,use_local_cache:o.localCacheEnabled,collection_id:this._key}}))})))),this._addMessagesToView(a,d.CollectionEventSource.REQUEST_MESSAGE)),a}))}loadNext(){var e,t,s;return d.__awaiter(this,void 0,void 0,(function*(){if(this._isDisposed)throw new d.SendbirdError({code:d.SendbirdErrorCode.COLLECTION_DISPOSED,message:"Collection has been disposed."});if(!this._hasNext)return[];const n=Math.floor(this._limit/2),i=this.viewBottom;let a=[];yield d.runOrNothing((()=>d.__awaiter(this,void 0,void 0,(function*(){a=this._filterUnderOffsetMessage(yield this._getLocalMessages(i,{nextLimit:n,inclusive:!1}))}))));const r=a.length>=n,{cacheContext:o,statLogCollector:l}=d.Vault.of(this._iid);return l.put(new d.StatLog({type:d.StatType.FEATURE_LOCALCACHE_EVENT,ts:Date.now(),data:{channel_url:this.channel.url,starting_point:this._startingPoint,measured_on:"load_next",event:r?"cache_hit":"cache_miss",max_db_size:null!==(t=null===(e=o.localCacheConfig)||void 0===e?void 0:e.maxSize)&&void 0!==t?t:0,use_local_cache:o.localCacheEnabled,collection_id:this._key}})),r&&(null===(s=this._backgroundSync)||void 0===s?void 0:s.isWrappingMessages(a))?(this._hasNext=a.length>=n,a.length>0&&this._addMessagesToView(a,d.CollectionEventSource.REQUEST_MESSAGE)):(yield d.runOrNothing((()=>d.__awaiter(this,void 0,void 0,(function*(){var e,t,s,r,o;const{cacheContext:h}=d.Vault.of(this._iid),c=yield this._getRemoteMessages(i,{nextLimit:n,reverse:!0,checkingHasNext:!0,checkingContinuousMessages:h.localCacheEnabled});a=this._filterUnderOffsetMessage(c.messages),a=a.filter((e=>Le(this._messages,e)<0)),this._hasNext=null!==(e=c.hasNext)&&void 0!==e?e:a.length>=n,a.length>0&&(this._syncRange.extends(...a.map((e=>e.createdAt))),(null===(t=this._backgroundSync)||void 0===t?void 0:t.range.overlap(this._syncRange))&&c.isContinuousMessages&&(null===(s=this._backgroundSync)||void 0===s||s.range.extends(this._syncRange.bottom))),l.put(new d.StatLog({type:d.StatType.FEATURE_LOCALCACHE_EVENT,ts:Date.now(),data:{channel_url:this.channel.url,starting_point:this._startingPoint,measured_on:"load_next",event:"cache_fetch",max_db_size:null!==(o=null===(r=h.localCacheConfig)||void 0===r?void 0:r.maxSize)&&void 0!==o?o:0,use_local_cache:h.localCacheEnabled,collection_id:this._key}}))})))),this._addMessagesToView(a,d.CollectionEventSource.REQUEST_MESSAGE)),a}))}removeFailedMessage(e){return d.__awaiter(this,void 0,void 0,(function*(){if(this._isDisposed)throw new d.SendbirdError({code:d.SendbirdErrorCode.COLLECTION_DISPOSED,message:"Collection has been disposed."});yield this._channelManager.removeFailedMessageFromCache(e);const t=this._unsentMessages.findIndex((t=>t.reqId===e));t>-1&&this._unsentMessages.splice(t,1)}))}dispose(){var e,t,s;if(this._isDisposed)return;this._isDisposed=!0;const{cacheContext:n,dispatcher:i}=d.Vault.of(this._iid);this._messages=[],this._clearCheckMyMutedTimer(),this._channel._runIfHandleableWithGroupChannel((e=>{if(e.myMemberState!==exports.MemberState.NONE){this._channel._updateMessageCollectionLastAccessedAt();const e=this._createChannelUpdateEventCommand(d.CollectionEventSource.CHANNEL_LASTACCESSEDAT_UPDATED);e&&i.dispatch(e)}})),n.localCacheEnabled&&(this._prevFill.stop(),this._nextFill.stop()),null===(e=this._backgroundSync)||void 0===e||e.close(),null===(t=this._changelogSync)||void 0===t||t.close(),null===(s=this._pollChangelogSync)||void 0===s||s.close(),this._channelManager.unsubscribeChannelEvent(this._key),this._channelManager.unsubscribeMessageEvent(this._key),this._connectionEventContext&&this._connectionEventContext.close()}}class Ze extends Je{constructor(e,t){super(e,Object.assign(Object.assign({},t),{channelManager:Ne.of(e)}))}setMessageCollectionHandler(e){this._setBaseMessageCollectionHandler(e)}_activate(){const e=Object.create(null,{_activate:{get:()=>super._activate}});return d.__awaiter(this,void 0,void 0,(function*(){yield e._activate.call(this);const t=yield this.channel.getMyMutedInfo();t.isMuted&&-1!==t.remainingDuration&&this._startCheckMyMutedTimer(t.remainingDuration)}))}}const Xe={coverUrl:void 0,coverImage:void 0,isDistinct:void 0,isPublic:void 0,isDiscoverable:void 0,accessCode:void 0,name:void 0,data:void 0,customType:void 0,operatorUserIds:void 0,messageSurvivalSeconds:void 0};class et extends d.APIRequestCommand{constructor(e){const{channelUrl:t,token:s,limit:n,order:i,mutedMemberFilter:a,memberStateFilter:r,nicknameStartsWithFilter:o,operatorFilter:l}=e;super(),this.method=d.APIRequestMethod.GET,this.path=`${d.API_PATH_GROUP_CHANNELS}/${encodeURIComponent(t)}/members`,this.params={token:s,limit:n,order:i,muted_member_filter:a,member_state_filter:r,nickname_startswith:o,operator_filter:l,show_member_is_muted:!0,show_read_receipt:!0,show_delivery_receipt:!0}}}class tt extends d.APIResponseCommand{constructor(e,t){super(e,t),this.members=[];const{next:s,members:n}=t;this.token=s,n&&n.length>0&&(this.members=n.map((t=>new _(e,t))))}}var st,nt,it;exports.MutedMemberFilter=void 0,(st=exports.MutedMemberFilter||(exports.MutedMemberFilter={})).ALL="all",st.MUTED="muted",st.UNMUTED="unmuted",exports.MemberListOrder=void 0,(nt=exports.MemberListOrder||(exports.MemberListOrder={})).MEMBER_NICKNAME_ALPHABETICAL="member_nickname_alphabetical",nt.OPERATOR_THEN_MEMBER_ALPHABETICAL="operator_then_member_alphabetical",exports.MemberStateFilter=void 0,(it=exports.MemberStateFilter||(exports.MemberStateFilter={})).ALL="all",it.JOINED="joined_only",it.INVITED="invited_only",it.INVITED_BY_FRIEND="invited_by_friend",it.INVITED_BY_NON_FRIEND="invited_by_non_friend";class at extends d.ChannelDataListQuery{constructor(e,t,s){var n,i,a,r;super(e,t,d.ChannelType.GROUP,s),this.mutedMemberFilter=exports.MutedMemberFilter.ALL,this.memberStateFilter=exports.MemberStateFilter.ALL,this.nicknameStartsWithFilter=null,this.operatorFilter=exports.OperatorFilter.ALL,this.order=exports.MemberListOrder.MEMBER_NICKNAME_ALPHABETICAL,this.mutedMemberFilter=null!==(n=s.mutedMemberFilter)&&void 0!==n?n:exports.MutedMemberFilter.ALL,this.memberStateFilter=null!==(i=s.memberStateFilter)&&void 0!==i?i:exports.MemberStateFilter.ALL,this.nicknameStartsWithFilter=null!==(a=s.nicknameStartsWithFilter)&&void 0!==a?a:null,this.order=null!==(r=s.order)&&void 0!==r?r:exports.MemberListOrder.MEMBER_NICKNAME_ALPHABETICAL}_validate(){return super._validate()&&d.isEnumOf(exports.MutedMemberFilter,this.mutedMemberFilter)&&d.isEnumOf(exports.MemberStateFilter,this.memberStateFilter)&&(d.isTypeOf("string",this.nicknameStartsWithFilter)||null===this.nicknameStartsWithFilter)&&d.isEnumOf(exports.OperatorFilter,this.operatorFilter)&&d.isEnumOf(exports.MemberListOrder,this.order)}next(){return d.__awaiter(this,void 0,void 0,(function*(){if(this._validate()){if(this._isLoading)throw d.SendbirdError.queryInProgress;if(this._hasNext){this._isLoading=!0;const{requestQueue:e}=d.Vault.of(this._iid),t=new et(d.undefineNullProps(Object.assign(Object.assign({},this),{token:this._token}))),s=yield e.send(t),{members:n,token:i}=s.as(tt);return this._token=i,this._hasNext=!!i,this._isLoading=!1,n}return[]}throw d.SendbirdError.invalidParameters}))}}class rt extends d.APIRequestCommand{constructor(e){const{channelUrl:t,userId:s,accessCode:n}=e;super(),this.method=d.APIRequestMethod.PUT,this.path=`${d.API_PATH_GROUP_CHANNELS}/${encodeURIComponent(t)}/accept`,this.params={user_id:s,access_code:n}}}class ot extends d.APIResponseCommand{constructor(e,t){super(e,t),this.channel=new Lt(e,t),this.channel.myMemberState=exports.MemberState.JOINED}}class lt extends d.APIRequestCommand{constructor(e){const{channelUrl:t,isDistinct:s,isPublic:n,isDiscoverable:i,coverUrl:a,coverImage:r,accessCode:o,name:l,data:h,customType:c,operatorUserIds:u,messageSurvivalSeconds:_}=e;super(),this.method=d.APIRequestMethod.PUT,this.path=`${d.API_PATH_GROUP_CHANNELS}/${encodeURIComponent(t)}`,this.params=d.deundefined({is_distinct:s,is_public:n,is_discoverable:i,name:l,data:h,custom_type:c,cover_url:a,cover_file:r,access_code:o,operator_ids:u,message_survival_seconds:_})}}class dt extends d.APIResponseCommand{constructor(e,t){super(e,t),this.channel=new Lt(e,t)}}class ht extends d.APIRequestCommand{constructor(e){const{channelUrl:t}=e;super(),this.method=d.APIRequestMethod.DELETE,this.path=`${d.API_PATH_GROUP_CHANNELS}/${encodeURIComponent(t)}`}}class ct extends d.APIRequestCommand{constructor(e){const{channelUrl:t}=e;super(),this.method=d.APIRequestMethod.DELETE,this.path=`${d.API_PATH_GROUP_CHANNELS}/${encodeURIComponent(t)}/hide`}}class ut extends d.APIRequestCommand{constructor({userId:e,channelUrl:t,countPreference:s}){super(),this.method=d.APIRequestMethod.PUT,this.path=`${d.API_PATH_USERS}/${encodeURIComponent(e)}/count_preference/${encodeURIComponent(t)}`,this.params={count_preference:s}}}class _t extends d.APIResponseCommand{constructor(e,t){super(e,t),this.countPreference=t.count_preference}}class pt extends d.APIRequestCommand{constructor(e){const{channelUrl:t}=e;super(),this.method=d.APIRequestMethod.PUT,this.path=`${d.API_PATH_GROUP_CHANNELS}/${encodeURIComponent(t)}/reset_user_history`}}class mt extends d.APIResponseCommand{constructor(e,t){super(e,t);const{ts_message_offset:s}=t;this.messageOffsetTimestamp=s}}const gt=Object.assign(Object.assign({},h.BaseMessageUpdateParamsDefault),{scheduledAt:void 0,file:void 0,fileUrl:void 0,fileName:void 0,mimeType:void 0,fileSize:void 0,thumbnailSizes:void 0,requireAuth:!1}),Ct=Object.assign(Object.assign({},h.UserMessageUpdateParamsDefault),{scheduledAt:void 0});class Et extends d.APIRequestCommand{constructor(e){var t;super();let s=[];e.mentionType===d.MentionType.USERS&&(e.mentionedUserIds?s=e.mentionedUserIds:e.mentionedUsers&&(s=e.mentionedUsers.map((e=>e.userId))));const{channelType:n,channelUrl:i,scheduledMessageId:a}=e;this.method=d.APIRequestMethod.PUT,this.path=`${d.getChannelApiPathByType(n)}/${encodeURIComponent(i)}/scheduled_messages/${encodeURIComponent(a)}`,this.params=d.deundefined(d.undefineNullProps({req_id:e.reqId,scheduled_at:e.scheduledAt,message_type:d.ServerSideMessageType.FILE,url:e.fileUrl,file_name:e.fileName,file_size:e.fileSize,file_type:e.mimeType,thumbnails:e.thumbnailSizes?e.thumbnailSizes.map((e=>h.Thumbnail.payloadify(e))):[],custom_type:e.customType,data:e.data,require_auth:e.requireAuth,mention_type:e.mentionType,mentioned_user_ids:s,sorted_metaarray:null===(t=e.metaArrays)||void 0===t?void 0:t.map((e=>h.MessageMetaArray.payloadify(e))),apple_critical_alert_options:e.appleCriticalAlertOptions?h.AppleCriticalAlertOptions.payloadify(e.appleCriticalAlertOptions):null,push_option:e.pushNotificationDeliveryOption}))}}class vt extends d.APIResponseCommand{constructor(e,t){super(e,t),this.message=new h.FileMessage(e,t)}}class ft extends d.APIRequestCommand{constructor(e){var t;super();let s=[];e.mentionType===d.MentionType.USERS&&(e.mentionedUserIds?s=e.mentionedUserIds:e.mentionedUsers&&(s=e.mentionedUsers.map((e=>e.userId))));const{channelType:n,channelUrl:i,scheduledMessageId:a}=e;this.method=d.APIRequestMethod.PUT,this.path=`${d.getChannelApiPathByType(n)}/${encodeURIComponent(i)}/scheduled_messages/${encodeURIComponent(a)}`,this.params=d.deundefined(d.undefineNullProps({req_id:e.reqId,scheduled_at:e.scheduledAt,message_type:d.ServerSideMessageType.USER,message:e.message,custom_type:e.customType,data:e.data,mention_type:e.mentionType,mentioned_user_ids:s,sorted_metaarray:null===(t=e.metaArrays)||void 0===t?void 0:t.map((e=>h.MessageMetaArray.payloadify(e))),apple_critical_alert_options:e.appleCriticalAlertOptions?h.AppleCriticalAlertOptions.payloadify(e.appleCriticalAlertOptions):null,target_langs:e.translationTargetLanguages,push_option:e.pushNotificationDeliveryOption}))}}class Mt extends d.APIRequestCommand{constructor(e){super();const{channelType:t,channelUrl:s,scheduledMessageId:n}=e;this.method=d.APIRequestMethod.DELETE,this.path=`${d.getChannelApiPathByType(t)}/${encodeURIComponent(s)}/scheduled_messages/${encodeURIComponent(n)}`}}class St extends d.APIRequestCommand{constructor(e){super();const{channelType:t,channelUrl:s,scheduledMessageId:n}=e;this.method=d.APIRequestMethod.POST,this.path=`${d.getChannelApiPathByType(t)}/${encodeURIComponent(s)}/scheduled_messages/${encodeURIComponent(n)}/send_now`}}class yt extends d.APIRequestCommand{constructor({userId:e,channelUrl:t,pushTriggerOption:s}){super(),this.method=d.APIRequestMethod.PUT,this.path=`${d.API_PATH_USERS}/${encodeURIComponent(e)}/push_preference/${encodeURIComponent(t)}`,this.params={push_trigger_option:s}}}class At extends d.APIResponseCommand{constructor(e,t){super(e,t),this.pushTriggerOption=t.push_trigger_option,this.enabled=t.enable}}class bt extends d.APIRequestCommand{constructor({userId:e,channelUrl:t}){super(),this.method=d.APIRequestMethod.GET,this.path=`${d.API_PATH_USERS}/${encodeURIComponent(e)}/push_preference/${encodeURIComponent(t)}`}}class Nt extends d.APIResponseCommand{constructor(e,t){super(e,t),this.pushTriggerOption=t.push_trigger_option,this.enabled=t.enable}}class Tt extends d.APIRequestCommand{constructor({channelType:e,channelUrl:t,messageId:s}){super(),this.method=d.APIRequestMethod.POST,this.path=`${d.getChannelApiPathByType(e)}/${encodeURIComponent(t)}/messages/${s}/pin`}}class Ut extends d.APIRequestCommand{constructor({channelType:e,channelUrl:t,messageId:s}){super(),this.method=d.APIRequestMethod.DELETE,this.path=`${d.getChannelApiPathByType(e)}/${encodeURIComponent(t)}/messages/${s}/pin`}}class It extends d.InstancedObject{constructor(e,t){super(e),this.message=null,this.message=h.parseMessagePayload(e,t.message)}}class Pt extends d.APIRequestCommand{constructor(e){const{channelType:t,channelUrl:s,limit:n,token:i,includeReactions:a,includeMetaArray:r,includeParentMessageInfo:o,includeThreadInfo:l,includePollDetails:h}=e;super(),this.method=d.APIRequestMethod.GET,this.path=`${d.getChannelApiPathByType(t)}/${encodeURIComponent(s)}/pinned_messages`,this.params=d.deundefined({limit:n,token:i,include_reactions:a,with_sorted_meta_array:r,include_thread_info:l,include_parent_message_info:o,include_poll_details:h})}}class xt extends d.APIResponseCommand{constructor(e,t){super(e,t);const{pinned_messages:s,has_more:n,next:i}=t;this.pinnedMessages=s.map((t=>new It(e,t))),this.hasMore=n,this.token=i}}class Ot extends d.ChannelDataListQuery{constructor(e,t,s,n){super(e,t,s,n),this.includeMetaArray=n.includeMetaArray,this.includeReactions=n.includeReactions,this.includeParentMessageInfo=n.includeParentMessageInfo,this.includeThreadInfo=n.includeThreadInfo,this.includePollDetails=n.includePollDetails}_validate(){return super._validate()&&d.isTypeOf("boolean",this.includeMetaArray,!0)&&d.isTypeOf("boolean",this.includeReactions,!0)&&d.isTypeOf("boolean",this.includeParentMessageInfo,!0)&&d.isTypeOf("boolean",this.includeThreadInfo,!0)&&d.isTypeOf("boolean",this.includePollDetails,!0)}next(){return d.__awaiter(this,void 0,void 0,(function*(){if(this._validate()){if(this._isLoading)throw d.SendbirdError.queryInProgress;if(this._hasNext){this._isLoading=!0;const{requestQueue:e}=d.Vault.of(this._iid),t=new Pt(Object.assign(Object.assign({},this),{token:this._token})),s=yield e.send(t),{pinnedMessages:n,hasMore:i,token:a}=s.as(xt);return this._token=a,this._hasNext=!!i,this._isLoading=!1,n}return[]}throw d.SendbirdError.invalidParameters}))}}var Rt,wt;exports.CountPreference=void 0,(Rt=exports.CountPreference||(exports.CountPreference={})).ALL="all",Rt.UNREAD_MESSAGE_COUNT_ONLY="unread_message_count_only",Rt.UNREAD_MENTION_COUNT_ONLY="unread_mention_count_only",Rt.OFF="off",exports.HiddenState=void 0,(wt=exports.HiddenState||(exports.HiddenState={})).UNHIDDEN="unhidden",wt.HIDDEN_ALLOW_AUTO_UNHIDE="hidden_allow_auto_unhide",wt.HIDDEN_PREVENT_AUTO_UNHIDE="hidden_prevent_auto_unhide";class Lt extends h.BaseChannel{constructor(e,t){var s,n,i,a,r,o,l,c,u,p,m,g,C,E,v,f,M,S,y;super(e,t),this._unreadMemberStateMap=new Map,this._undeliveredMemberStateMap=new Map,this._typingStatus=new Map,this._lastMemberCountUpdated=0,this._typingStarted=0,this._typingEnded=0,this.isDistinct=!1,this.isSuper=!1,this.isBroadcast=!1,this.isExclusive=!1,this.isPublic=!1,this.isDiscoverable=!0,this.isChatNotification=!1,this.isAccessCodeRequired=!1,this.isPushEnabled=!1,this.unreadMessageCount=0,this.unreadMentionCount=0,this.members=[],this.memberCount=0,this.joinedMemberCount=0,this.hiddenState=exports.HiddenState.UNHIDDEN,this.lastMessage=null,this.messageOffsetTimestamp=0,this.messageSurvivalSeconds=-1,this.myMemberState=exports.MemberState.NONE,this.myRole=d.Role.NONE,this.myMutedState=d.MutedState.UNMUTED,this.myLastRead=0,this.myCountPreference=exports.CountPreference.ALL,this.myPushTriggerOption=d.PushTriggerOption.DEFAULT,this.inviter=null,this.invitedAt=0,this.joinedAt=0,this.pinnedMessageIds=[],this.lastPinnedMessage=null,this._pinnedMessagesUpdatedAt=0,this._myMutedRemainingTime=-1,this.channelType=d.ChannelType.GROUP,this.isDistinct=null!==(s=t.is_distinct)&&void 0!==s&&s,this.isSuper=null!==(n=t.is_super)&&void 0!==n&&n,this.isBroadcast=null!==(i=t.is_broadcast)&&void 0!==i&&i,this.isExclusive=null!==(a=t.is_exclusive)&&void 0!==a&&a,this.isPublic=null!==(r=t.is_public)&&void 0!==r&&r,this.isDiscoverable=null!==(o=t.is_discoverable)&&void 0!==o?o:this.isPublic,this.isChatNotification=null!==(l=t.is_chat_notification)&&void 0!==l&&l,this.isAccessCodeRequired=null!==(c=t.is_access_code_required)&&void 0!==c&&c,this.isPushEnabled=null!==(u=t.is_push_enabled)&&void 0!==u&&u,Array.isArray(t.members)&&this.members.push(...t.members.map((e=>new _(this._iid,e)))),this.memberCount=null!==(p=t.member_count)&&void 0!==p?p:0,this.joinedMemberCount=null!==(m=t.joined_member_count)&&void 0!==m?m:0,this.hiddenState=d.isEnumOf(exports.HiddenState,t.hidden_state)?t.hidden_state:exports.HiddenState.UNHIDDEN,this.messageOffsetTimestamp=null!==(g=t.ts_message_offset)&&void 0!==g?g:0,this.messageSurvivalSeconds=null!==(C=t.message_survival_seconds)&&void 0!==C?C:-1,this.lastMessage=t.last_message?h.parseMessagePayload(this._iid,Object.assign({channel_type:this.channelType},t.last_message)):null,t.read_receipt&&Object.keys(t.read_receipt).forEach((e=>{d.isTypeOf("number",t.read_receipt[e])&&this._updateUnreadMemberState(e,t.read_receipt[e])})),t.delivery_receipt&&Object.keys(t.delivery_receipt).forEach((e=>{d.isTypeOf("number",t.delivery_receipt[e])&&this._updateUndeliveredMemberState(e,t.delivery_receipt[e])})),this.myMemberState=d.isEnumOf(exports.MemberState,t.member_state)?t.member_state:exports.MemberState.NONE,this.myRole=d.isEnumOf(d.Role,t.my_role)?t.my_role:d.Role.NONE,d.isEnumOf(d.MutedState,t.is_muted)?this.myMutedState=t.is_muted:d.isTypeOf("boolean",t.is_muted)?this.myMutedState=t.is_muted?d.MutedState.MUTED:d.MutedState.UNMUTED:this.myMutedState=d.MutedState.UNMUTED,this.myCountPreference=d.isEnumOf(exports.CountPreference,t.count_preference)?t.count_preference:exports.CountPreference.ALL,this.myPushTriggerOption=d.isEnumOf(d.PushTriggerOption,t.push_trigger_option)?t.push_trigger_option:d.PushTriggerOption.ALL,this.myLastRead=null!==(E=t.user_last_read)&&void 0!==E?E:0,this.inviter=t.inviter?new d.User(this._iid,t.inviter):null,this.invitedAt=null!==(v=t.invited_at)&&void 0!==v?v:0,this.joinedAt=null!==(f=t.joined_ts)&&void 0!==f?f:0,this._updateUnreadCount(null!==(M=t.unread_message_count)&&void 0!==M?M:0,null!==(S=t.unread_mention_count)&&void 0!==S?S:0),this.pinnedMessageIds=null!==(y=t.pinned_message_ids)&&void 0!==y?y:[],this.lastPinnedMessage=t.latest_pinned_message?h.parseMessagePayload(this._iid,Object.assign({channel_type:this.channelType},t.latest_pinned_message)):null}get isHidden(){return this.hiddenState!==exports.HiddenState.UNHIDDEN}get isTyping(){return this._typingStatus.size>0}get cachedUnreadMemberState(){const e={};for(const[t,s]of this._unreadMemberStateMap)e[t]=s;return e}get cachedUndeliveredMemberState(){const e={};for(const[t,s]of this._undeliveredMemberStateMap)e[t]=s;return e}static payloadify(e){return d.deundefined(d.undefineNullProps(Object.assign(Object.assign({},super.payloadify(e)),{is_access_code_required:e.isAccessCodeRequired,is_distinct:e.isDistinct,is_super:e.isSuper,is_broadcast:e.isBroadcast,is_exclusive:e.isExclusive,is_public:e.isPublic,is_discoverable:e.isDiscoverable,is_muted:e.myMutedState,is_push_enabled:e.isPushEnabled,unread_message_count:e.unreadMessageCount,unread_mention_count:e.unreadMentionCount,push_trigger_option:e.myPushTriggerOption,count_preference:e.myCountPreference,hidden_state:e.hiddenState,member_count:e.memberCount,joined_member_count:e.joinedMemberCount,member_state:e.myMemberState,my_role:e.myRole,user_last_read:e.myLastRead,ts_message_offset:e.messageOffsetTimestamp,message_survival_seconds:e.messageSurvivalSeconds,read_receipt:e.cachedUnreadMemberState,delivery_receipt:e.cachedUndeliveredMemberState,members:e.members.map((e=>_.payloadify(e))),last_message:e.lastMessage?h.payloadifyMessage(e.lastMessage):null,inviter:e.inviter?d.User.payloadify(e.inviter):null,invited_at:e.invitedAt,joined_ts:e.joinedAt,pinned_message_ids:e.pinnedMessageIds,latest_pinned_message:e.lastPinnedMessage?h.payloadifyMessage(e.lastPinnedMessage):null})))}_shouldUpdateLastMessageWith(e){return!(e instanceof h.SendableMessage&&e.parentMessageId>0&&!e.replyToChannel)&&(!this.lastMessage||this.lastMessage.createdAt{t.onChannelChanged&&t.onChannelChanged(e)})),s.dispatch(new P({channels:[e],source:d.CollectionEventSource.EVENT_MESSAGE_SENT}))}_updateUnreadCount(e,t){if("number"==typeof e&&e>=0)if(this.myCountPreference===exports.CountPreference.ALL||this.myCountPreference===exports.CountPreference.UNREAD_MESSAGE_COUNT_ONLY)if(this.isExclusive||this.isSuper||this.isBroadcast){const{maxSuperGroupChannelUnreadCount:t}=d.Vault.of(this._iid);this.unreadMessageCount=t&&e>=t?t:e}else this.unreadMessageCount=e;else this.unreadMessageCount=0;else this.unreadMessageCount=0;"number"==typeof t&&t>=0&&(this.myCountPreference===exports.CountPreference.ALL||this.myCountPreference===exports.CountPreference.UNREAD_MENTION_COUNT_ONLY)?this.unreadMentionCount=t:this.unreadMentionCount=0}_updateUnreadMemberState(e,t){const s=this._unreadMemberStateMap.get(e);if(!s||s0?this._typingStatus.set(e.userId,{user:e,ts:t}):this._typingStatus.delete(e.userId)}_clearTypingStatus(){this._typingStatus.clear(),this._typingStarted=0,this._typingEnded=0}_setLatestMemberCount(e,t,s){let n=!1;return s>=this._lastMemberCountUpdated&&(this._lastMemberCountUpdated=s,n=e!==this.memberCount||t!==this.joinedMemberCount,this.memberCount=e,this.joinedMemberCount=t),n}isReadMessage(e){const{sdkState:t}=d.Vault.of(this._iid),s=this._unreadMemberStateMap.get(t.userId);return!!s&&s>=e.createdAt}serialize(){return d.serialize(this,(e=>{e.cachedUnreadMemberState=this.cachedUnreadMemberState,e.cachedUndeliveredMemberState=this.cachedUndeliveredMemberState}))}createMessageCollection(e={}){return new Ze(this._iid,Object.assign(Object.assign({},e),{channel:this}))}createMemberListQuery(e={}){return new at(this._iid,this.url,e)}createPinnedMessageListQuery(e={}){return new Ot(this._iid,this.url,this.channelType,e)}addMember(e,t=0){if(!this.isExclusive&&!this.isSuper&&!this.isBroadcast){const s=this.members.findIndex((t=>t.userId===e.userId));if(s>-1){const t=this.members[s];t.state===exports.MemberState.JOINED&&(e.state=t.state),this.members.splice(s,1),this.memberCount--}this.members.push(e),this.memberCount++,this._updateUnreadMemberState(e.userId,t),this._updateUndeliveredMemberState(e.userId,t)}}removeMember(e){if(!this.isExclusive&&!this.isSuper&&!this.isBroadcast){const t=e instanceof _?e.userId:e,s=this.members.findIndex((e=>e.userId===t));if(s>-1)return this.members.splice(s,1),this.memberCount--,!0}return!1}getUnreadMemberCount(e){if(e instanceof h.SendableMessage&&!this.isExclusive&&!this.isSuper&&!this.isBroadcast){const{sdkState:t}=d.Vault.of(this._iid),s=e.createdAt;let n=0;for(const i of this.members)if(t.userId!==i.userId&&i.state===exports.MemberState.JOINED&&e.sender.userId!==i.userId){(this.cachedUnreadMemberState[i.userId]||0){if(t||a.userId!==s.userId&&a.userId!==(null==n?void 0:n.userId)){const t=this._unreadMemberStateMap.get(a.userId);t&&t>=e.createdAt&&i.push(a)}})),i}getUnreadMembers(e,t=!1){const{sdkState:s}=d.Vault.of(this._iid);if(!s.userId||this.isExclusive||this.isSuper||this.isBroadcast)return[];const n=e instanceof h.SendableMessage?e.sender:null,i=[];return this.members.forEach((a=>{if(t||a.userId!==s.userId&&a.userId!==(null==n?void 0:n.userId)){const t=this._unreadMemberStateMap.get(a.userId);t&&t{if(e||n.userId!==t.userId){const e=this._unreadMemberStateMap.get(n.userId);s[n.userId]=new p(this._iid,{channel_url:this.url,channel_type:this.channelType,user:_.payloadify(n),ts:null!=e?e:0})}})),s}getTypingUsers(){const e=[];return this._typingStatus.forEach((t=>{const{user:s}=t;e.push(s)})),e}invalidateTypingStatus(){const{typingIndicatorInvalidateTime:e}=d.Vault.of(this._iid),t=Date.now();let s=!1;return this._typingStatus.forEach(((n,i)=>{const{ts:a}=n;t-a>=e&&(this._typingStatus.delete(i),s=!0)})),s}refresh(){return d.__awaiter(this,void 0,void 0,(function*(){return this._refresh()}))}_refresh(e=!1){return d.__awaiter(this,void 0,void 0,(function*(){const{requestQueue:t,dispatcher:s}=d.Vault.of(this._iid),n=new L({channelUrl:this.url}),i=yield t.send(n),{channel:a}=i.as(F);return this._update(a),e&&s.dispatch(new P({channels:[a],source:d.CollectionEventSource.REQUEST_CHANNEL})),this}))}freeze(){const e=Object.create(null,{freeze:{get:()=>super.freeze}});return d.__awaiter(this,void 0,void 0,(function*(){yield e.freeze.call(this);const{dispatcher:t}=d.Vault.of(this._iid);t.dispatch(new P({channels:[this],source:d.CollectionEventSource.EVENT_CHANNEL_FROZEN,isWebSocketEventComing:!0}))}))}unfreeze(){const e=Object.create(null,{unfreeze:{get:()=>super.unfreeze}});return d.__awaiter(this,void 0,void 0,(function*(){yield e.unfreeze.call(this);const{dispatcher:t}=d.Vault.of(this._iid);t.dispatch(new P({channels:[this],source:d.CollectionEventSource.EVENT_CHANNEL_UNFROZEN,isWebSocketEventComing:!0}))}))}updateChannel(e){return d.__awaiter(this,void 0,void 0,(function*(){const t=Object.assign(Object.assign({},Xe),e);d.unless((e=>d.isTypeOf("string",e.coverUrl,!0)&&(d.isFile(e.coverImage)||d.isTypeOf("string",e.coverImage,!0))&&d.isTypeOf("boolean",e.isDistinct,!0)&&d.isTypeOf("boolean",e.isPublic,!0)&&d.isTypeOf("boolean",e.isDiscoverable,!0)&&d.isTypeOf("string",e.accessCode,!0)&&d.isTypeOf("string",e.name,!0)&&d.isTypeOf("string",e.data,!0)&&d.isTypeOf("string",e.customType,!0)&&d.isArrayOf("string",e.operatorUserIds,!0)&&d.isTypeOf("number",e.messageSurvivalSeconds,!0))(t)).throw(d.SendbirdError.invalidParameters);const{dispatcher:s,requestQueue:n}=d.Vault.of(this._iid),i=new lt(Object.assign({channelUrl:this.url},t)),a=yield n.send(i),{channel:r}=a.as(dt);return this._update(r),s.dispatch(new P({channels:[r],source:d.CollectionEventSource.EVENT_CHANNEL_UPDATED,isWebSocketEventComing:!0})),this}))}invite(e){return d.__awaiter(this,void 0,void 0,(function*(){return d.unless(e.every((e=>e instanceof d.User))).throw(d.SendbirdError.invalidParameters),this.inviteWithUserIds(e.map((e=>e.userId)))}))}inviteWithUserIds(e){return d.__awaiter(this,void 0,void 0,(function*(){d.unless(d.isArrayOf("string",e)).throw(d.SendbirdError.invalidParameters);const{dispatcher:t,requestQueue:s}=d.Vault.of(this._iid),n=new ae({channelUrl:this.url,userIds:e}),i=yield s.send(n),{channel:a}=i.as(re);return this._update(a),t.dispatch(new P({channels:[a],source:d.CollectionEventSource.EVENT_CHANNEL_INVITED,isWebSocketEventComing:!0})),this}))}join(e){return d.__awaiter(this,void 0,void 0,(function*(){d.unless(d.isTypeOf("string",e,!0)).throw(d.SendbirdError.invalidParameters);const{dispatcher:t,sdkState:s,requestQueue:n}=d.Vault.of(this._iid),i=new ee({channelUrl:this.url,userId:s.userId,accessCode:e}),a=yield n.send(i),{channel:r}=a.as(te);return r.myMemberState=this.myMemberState=exports.MemberState.JOINED,this._update(r),t.dispatch(new P({channels:[r],source:d.CollectionEventSource.EVENT_CHANNEL_JOINED,isWebSocketEventComing:!0})),this}))}leave(e=!1){return d.__awaiter(this,void 0,void 0,(function*(){const{sdkState:t,requestQueue:s}=d.Vault.of(this._iid),n=new ne({channelUrl:this.url,userId:t.userId,shouldRemoveOperatorStatus:e});yield s.send(n),this.myMemberState=exports.MemberState.NONE}))}acceptInvitation(e){return d.__awaiter(this,void 0,void 0,(function*(){d.unless(d.isTypeOf("string",e,!0)).throw(d.SendbirdError.invalidParameters);const{dispatcher:t,sdkState:s,requestQueue:n}=d.Vault.of(this._iid),i=new rt({channelUrl:this.url,userId:s.userId,accessCode:e}),a=yield n.send(i),{channel:r}=a.as(ot);return r.myMemberState=this.myMemberState=exports.MemberState.JOINED,this._update(r),t.dispatch(new P({channels:[r],source:d.CollectionEventSource.EVENT_CHANNEL_ACCEPTED_INVITE,isWebSocketEventComing:!0})),this}))}declineInvitation(){return d.__awaiter(this,void 0,void 0,(function*(){const{sdkState:e,requestQueue:t}=d.Vault.of(this._iid),s=new le({channelUrl:this.url,userId:e.userId});return yield t.send(s),this.myMemberState=exports.MemberState.NONE,this}))}sendUserMessage(e){const t=new h.MessageRequestHandler,{dispatcher:s}=d.Vault.of(this._iid),n=c.AutoResendManager.of(this._iid);return super.sendUserMessage(e).onPending((e=>{n.completeCurrentAndProcessNextAutoResend(e),t._trigger(e)})).onFailed(((e,s)=>{s&&n.completeCurrentAndProcessNextAutoResend(s),t._triggerFailed(e,s)})).onSucceeded((e=>{this.hiddenState===exports.HiddenState.HIDDEN_ALLOW_AUTO_UNHIDE&&(this.hiddenState=exports.HiddenState.UNHIDDEN),n.completeCurrentAndProcessNextAutoResend(e),this._shouldUpdateLastMessageWith(e)&&(this.lastMessage=e);Ne.of(this._iid).handlers.map((e=>{e.onChannelChanged&&e.onChannelChanged(this)})),s.dispatch(new P({channels:[this],source:d.CollectionEventSource.EVENT_MESSAGE_SENT})),t._trigger(e)})),t}updateUserMessage(e,t){const s=Object.create(null,{updateUserMessage:{get:()=>super.updateUserMessage}});return d.__awaiter(this,void 0,void 0,(function*(){const{dispatcher:n}=d.Vault.of(this._iid),i=yield s.updateUserMessage.call(this,e,t);let a=!1;!i.silent&&this._shouldUpdateLastMessageWith(i)&&(this.lastMessage=i,a=!0);let r=!1;if(this.lastPinnedMessage&&this.lastPinnedMessage.messageId===i.messageId&&(this.lastPinnedMessage=i,a=!0,r=!0),a){Ne.of(this._iid).handlers.map((e=>{e.onChannelChanged&&e.onChannelChanged(this)})),n.dispatch(new P({channels:[this],source:r?d.CollectionEventSource.EVENT_PINNED_MESSAGE_UPDATED:d.CollectionEventSource.EVENT_MESSAGE_UPDATED}))}if(r){Ne.of(this._iid).handlers.map((e=>{e.onPinnedMessageUpdated&&e.onPinnedMessageUpdated(this)}))}return n.dispatch(new d.MessageUpdateEventCommand({messages:[i],source:d.CollectionEventSource.EVENT_MESSAGE_UPDATED})),i}))}_autoResendUserMessage(e){const t=new h.MessageRequestHandler,{dispatcher:s}=d.Vault.of(this._iid),n=c.AutoResendManager.of(this._iid);return super._autoResendUserMessage(e).onPending((e=>{n.completeCurrentAndProcessNextAutoResend(e),t._trigger(e)})).onFailed(((e,s)=>{n.completeCurrentAndProcessNextAutoResend(s),t._triggerFailed(e,s)})).onSucceeded((e=>{const i=Ne.of(this._iid);n.completeCurrentAndProcessNextAutoResend(e),this._shouldUpdateLastMessageWith(e)&&(this.lastMessage=e),i.handlers.map((e=>{e.onChannelChanged&&e.onChannelChanged(this)})),s.dispatch(new P({channels:[this],source:d.CollectionEventSource.EVENT_MESSAGE_SENT})),t._trigger(e)})),t}sendFileMessage(e){const t=new h.MessageRequestHandler,{dispatcher:s}=d.Vault.of(this._iid),n=c.AutoResendManager.of(this._iid);return super.sendFileMessage(e).onPending((e=>{n.completeCurrentAndProcessNextAutoResend(e),t._trigger(e)})).onFailed(((e,s)=>{s&&n.completeCurrentAndProcessNextAutoResend(s),t._triggerFailed(e,s)})).onSucceeded((e=>{const i=Ne.of(this._iid);n.completeCurrentAndProcessNextAutoResend(e),this._shouldUpdateLastMessageWith(e)&&(this.lastMessage=e),i.handlers.map((e=>{e.onChannelChanged&&e.onChannelChanged(this)})),s.dispatch(new P({channels:[this],source:d.CollectionEventSource.EVENT_MESSAGE_SENT})),t._trigger(e)})),t}sendMultipleFilesMessage(e){const t=new h.MultipleFilesMessageRequestHandler,{dispatcher:s}=d.Vault.of(this._iid);return super.sendMultipleFilesMessage(e).onPending((e=>{t._trigger(e)})).onFailed(((e,s)=>{t._triggerFailed(e,s)})).onSucceeded((e=>{const n=Ne.of(this._iid);this._shouldUpdateLastMessageWith(e)&&(this.lastMessage=e),n.handlers.map((e=>{e.onChannelChanged&&e.onChannelChanged(this)})),s.dispatch(new P({channels:[this],source:d.CollectionEventSource.EVENT_MESSAGE_SENT})),t._trigger(e)})).onFileUploaded(((e,s,n,i)=>{t._triggerOnFileUploaded(e,s,n,i)})),t}updateFileMessage(e,t){const s=Object.create(null,{updateFileMessage:{get:()=>super.updateFileMessage}});return d.__awaiter(this,void 0,void 0,(function*(){const{dispatcher:n}=d.Vault.of(this._iid),i=yield s.updateFileMessage.call(this,e,t);let a=!1;!i.silent&&this._shouldUpdateLastMessageWith(i)&&(this.lastMessage=i,a=!0);let r=!1;if(this.lastPinnedMessage&&this.lastPinnedMessage.messageId===i.messageId&&(this.lastPinnedMessage=i,a=!0,r=!0),a){Ne.of(this._iid).handlers.map((e=>{e.onChannelChanged&&e.onChannelChanged(this)})),n.dispatch(new P({channels:[this],source:r?d.CollectionEventSource.EVENT_PINNED_MESSAGE_UPDATED:d.CollectionEventSource.EVENT_MESSAGE_UPDATED}))}if(r){Ne.of(this._iid).handlers.map((e=>{e.onPinnedMessageUpdated&&e.onPinnedMessageUpdated(this)}))}return n.dispatch(new d.MessageUpdateEventCommand({messages:[i],source:d.CollectionEventSource.EVENT_MESSAGE_UPDATED})),i}))}_autoResendFileMessage(e){const t=new h.MessageRequestHandler,{dispatcher:s}=d.Vault.of(this._iid),n=c.AutoResendManager.of(this._iid);return super._autoResendFileMessage(e).onPending((e=>{n.completeCurrentAndProcessNextAutoResend(e),t._trigger(e)})).onFailed(((e,s)=>{n.completeCurrentAndProcessNextAutoResend(s),t._triggerFailed(e,s)})).onSucceeded((e=>{const i=Ne.of(this._iid);n.completeCurrentAndProcessNextAutoResend(e),this._shouldUpdateLastMessageWith(e)&&(this.lastMessage=e),i.handlers.map((e=>{e.onChannelChanged&&e.onChannelChanged(this)})),s.dispatch(new P({channels:[this],source:d.CollectionEventSource.EVENT_MESSAGE_SENT})),t._trigger(e)})),t}deleteMessage(e){const t=Object.create(null,{deleteMessage:{get:()=>super.deleteMessage}});return d.__awaiter(this,void 0,void 0,(function*(){if(yield t.deleteMessage.call(this,e),0===e.messageId&&e instanceof h.SendableMessage){const{dispatcher:t}=d.Vault.of(this._iid);t.dispatch(new d.UnsentMessageRemoveEventCommand({reqId:e.reqId,source:d.CollectionEventSource.EVENT_MESSAGE_DELETED}))}}))}hide(e){return d.__awaiter(this,void 0,void 0,(function*(){const t=Object.assign(Object.assign({},he),e);d.unless((e=>d.isTypeOf("boolean",e.hidePreviousMessages,!0)&&d.isTypeOf("boolean",e.allowAutoUnhide,!0))(t)).throw(d.SendbirdError.invalidParameters);const{dispatcher:s,sdkState:n,requestQueue:i}=d.Vault.of(this._iid),a=new ce(Object.assign({channelUrl:this.url,userId:n.userId},t)),r=yield i.send(a),{messageOffsetTimestamp:o}=r.as(ue);return this.hiddenState=t.allowAutoUnhide?exports.HiddenState.HIDDEN_ALLOW_AUTO_UNHIDE:exports.HiddenState.HIDDEN_PREVENT_AUTO_UNHIDE,t.hidePreviousMessages&&this._updateUnreadCount(0,0),o&&(this.messageOffsetTimestamp=o),s.dispatch(new P({channels:[this],source:d.CollectionEventSource.EVENT_CHANNEL_HIDDEN,isWebSocketEventComing:!0})),this}))}unhide(){return d.__awaiter(this,void 0,void 0,(function*(){const{dispatcher:e,requestQueue:t}=d.Vault.of(this._iid),s=new ct({channelUrl:this.url});return yield t.send(s),this.hiddenState=exports.HiddenState.UNHIDDEN,e.dispatch(new P({channels:[this],source:d.CollectionEventSource.EVENT_CHANNEL_UNHIDDEN,isWebSocketEventComing:!0})),this}))}delete(){return d.__awaiter(this,void 0,void 0,(function*(){const{requestQueue:e}=d.Vault.of(this._iid),t=new ht({channelUrl:this.url});yield e.send(t)}))}markAsRead(){return d.__awaiter(this,void 0,void 0,(function*(){const{sdkState:e,dispatcher:t,requestQueue:s}=d.Vault.of(this._iid),n=new Me({channelUrl:this.url}),i=yield s.send(n),{readStatus:a}=i.as(Se);if(this._updateUnreadMemberState(e.userId,a.readAt),this.unreadMessageCount>0||this.unreadMentionCount>0){this._updateUnreadCount(0,0);Ne.of(this._iid).handlers.map((e=>{e.onChannelChanged&&e.onChannelChanged(this)}))}t.dispatch(new P({channels:[this],source:d.CollectionEventSource.EVENT_CHANNEL_READ}))}))}markAsDelivered(){return d.__awaiter(this,void 0,void 0,(function*(){const{sdkState:e,requestQueue:t}=d.Vault.of(this._iid),s=new ye({channelUrl:this.url,userId:e.userId});yield t.send(s)}))}startTyping(){return d.__awaiter(this,void 0,void 0,(function*(){const{requestQueue:e,typingIndicatorThrottle:t}=d.Vault.of(this._iid),s=(new Date).getTime();if(s-this._typingStarted>=t){this._typingStarted=s,this._typingEnded=0;const t=new pe({channelUrl:this.url,time:this._typingStarted});e.send(t)}}))}endTyping(){return d.__awaiter(this,void 0,void 0,(function*(){const{requestQueue:e,typingIndicatorThrottle:t}=d.Vault.of(this._iid),s=(new Date).getTime();if(s-this._typingEnded>=t){this._typingStarted=0,this._typingEnded=s;const t=new ge({channelUrl:this.url,time:this._typingStarted});e.send(t)}}))}createScheduledUserMessage(e){e=Object.assign(Object.assign({},h.ScheduledUserMessageCreateParamsDefault),e),d.unless(h.validateScheduledUserMessageCreateParams(e)).throw(d.SendbirdError.invalidParameters);const t=new h.MessageRequestHandler;return this._createScheduledUserMessage(e,t),t}updateScheduledUserMessage(e,t){return d.__awaiter(this,void 0,void 0,(function*(){const s=Object.assign(Object.assign({},Ct),t);d.unless((e=>h.validateUserMessageUpdateParams(e)&&d.isTypeOf("number",e.scheduledAt,!0))(s)).throw(d.SendbirdError.invalidParameters);const{requestQueue:n}=d.Vault.of(this._iid),i=new ft(Object.assign({reqId:this._generateRequestId(),scheduledMessageId:e,channelType:this.channelType,channelUrl:this.url},s)),a=yield n.send(i),{message:r}=a.as(h.CreateScheduledUserMessageResponseCommand);return r}))}createScheduledFileMessage(e){e=Object.assign(Object.assign({},h.ScheduledFileMessageCreateParamsDefault),e),d.unless(h.validateScheduledFileMessageCreateParams(e)).throw(d.SendbirdError.invalidParameters);const t=Date.now(),s=this._generateRequestId(),n=new h.MessageRequestHandler;return d.sleep(h.PENDING_MESSAGE_DELAY).then((()=>{const i=this._createPendingScheduledFileMessage(e,s,t);d.runAsCallback((()=>d.__awaiter(this,void 0,void 0,(function*(){return n._trigger(i)}))))})),d.isFile(e.file)?this._uploadFileAndUpdateParams(e).then((()=>this._createScheduledFileMessage(e,n,s,t))):this._createScheduledFileMessage(e,n,s,t),n}updateScheduledFileMessage(e,t){return d.__awaiter(this,void 0,void 0,(function*(){const s=Object.assign(Object.assign({},gt),t);d.unless((e=>h.validateBaseMessageUpdateParams(e)&&d.isTypeOf("number",e.scheduledAt,!0)&&(d.isFile(e.file)||d.isTypeOf("string",e.fileUrl))&&d.isTypeOf("string",e.fileName,!0)&&d.isTypeOf("string",e.mimeType,!0)&&d.isTypeOf("number",e.fileSize,!0)&&(null===e.thumbnailSizes||void 0===e.thumbnailSizes||e.thumbnailSizes.every((e=>d.isTypeOf("object",e)&&e.maxWidth>0&&e.maxHeight>0))))(s)).throw(d.SendbirdError.invalidParameters),d.isFile(s.file)&&(yield this._uploadFileAndUpdateParams(s));const n=new Et(Object.assign({reqId:this._generateRequestId(),scheduledMessageId:e,channelType:this.channelType,channelUrl:this.url},s)),{requestQueue:i}=d.Vault.of(this._iid),a=yield i.send(n),{message:r}=a.as(vt);return r}))}cancelScheduledMessage(e){return d.__awaiter(this,void 0,void 0,(function*(){const t=new Mt({scheduledMessageId:e,channelType:this.channelType,channelUrl:this.url}),{requestQueue:s}=d.Vault.of(this._iid);yield s.send(t)}))}sendScheduledMessageNow(e){return d.__awaiter(this,void 0,void 0,(function*(){const t=new St({scheduledMessageId:e,channelType:this.channelType,channelUrl:this.url}),{requestQueue:s}=d.Vault.of(this._iid);yield s.send(t)}))}getMyPushTriggerOption(){return d.__awaiter(this,void 0,void 0,(function*(){const{sdkState:e,requestQueue:t}=d.Vault.of(this._iid),s=new bt({userId:e.userId,channelUrl:this.url}),n=yield t.send(s),{pushTriggerOption:i}=n.as(Nt);return this.myPushTriggerOption=i,i}))}setMyPushTriggerOption(e){return d.__awaiter(this,void 0,void 0,(function*(){d.unless(d.isEnumOf(d.PushTriggerOption,e)).throw(d.SendbirdError.invalidParameters);const{dispatcher:t,sdkState:s,requestQueue:n}=d.Vault.of(this._iid),i=new yt({userId:s.userId,channelUrl:this.url,pushTriggerOption:e}),a=yield n.send(i),{pushTriggerOption:r}=a.as(At);return this.myPushTriggerOption=r,t.dispatch(new P({channels:[this],source:d.CollectionEventSource.EVENT_CHANNEL_UPDATED,isWebSocketEventComing:!0})),r}))}setMyCountPreference(e){return d.__awaiter(this,void 0,void 0,(function*(){d.unless(d.isEnumOf(exports.CountPreference,e)).throw(d.SendbirdError.invalidParameters);const{dispatcher:t,sdkState:s,requestQueue:n}=d.Vault.of(this._iid),i=new ut({channelUrl:this.url,userId:s.userId,countPreference:e}),a=yield n.send(i),{countPreference:r}=a.as(_t);return this.myCountPreference=r,this._updateUnreadCount(this.unreadMessageCount,this.unreadMentionCount),t.dispatch(new P({channels:[this],source:d.CollectionEventSource.EVENT_CHANNEL_UPDATED,isWebSocketEventComing:!0})),r}))}resetMyHistory(){return d.__awaiter(this,void 0,void 0,(function*(){const{dispatcher:e,requestQueue:t}=d.Vault.of(this._iid),s=new pt({channelUrl:this.url}),n=yield t.send(s),{messageOffsetTimestamp:i}=n.as(mt);return this.messageOffsetTimestamp=i,this.lastMessage&&this.lastMessage.createdAt0).throw(d.SendbirdError.invalidParameters);const{requestQueue:t}=d.Vault.of(this._iid),s=new Tt({channelType:this.channelType,channelUrl:this.url,messageId:e});yield t.send(s)}))}unpinMessage(e){return d.__awaiter(this,void 0,void 0,(function*(){d.unless(d.isTypeOf("number",e)&&e>0).throw(d.SendbirdError.invalidParameters);const{requestQueue:t}=d.Vault.of(this._iid),s=new Ut({channelType:this.channelType,channelUrl:this.url,messageId:e});yield t.send(s)}))}_uploadFileAndUpdateParams(e){return d.__awaiter(this,void 0,void 0,(function*(){if(d.isFile(e.file)){const{requestQueue:t}=d.Vault.of(this._iid),s=new h.UploadFileRequestCommand({file:e.file,channelUrl:this.url,thumbnailSizes:e.thumbnailSizes,requestId:this._generateRequestId()}),n=yield t.send(s),{url:i,fileSize:a=e.fileSize,thumbnailSizes:r=e.thumbnailSizes,requireAuth:o=!1}=n.as(h.UploadFileResponseCommand);e.fileUrl=i,e.fileSize=a,e.thumbnailSizes=r,e.requireAuth=o}}))}resendMessage(e,t){var s;if(d.unless(e instanceof h.SendableMessage&&!e.scheduledInfo&&e.isResendable).throw(d.SendbirdError.invalidParameters),e.isUserMessage()){const t=null!==(s=e.messageParams)&&void 0!==s?s:h.createUserMessageCreateParamsFromFailedUserMessage(e),n=new h.MessageRequestHandler;return this._sendUserMessage(t,h.SendMessageRequestType.RESEND,e.reqId).onPending((e=>{n._trigger(e)})).onFailed(((e,t)=>{n._triggerFailed(e,t)})).onSucceeded((e=>{this._tryUpdateLastMessageAndCallEvents(this,e),n._trigger(e)})),n}if(e.isFileMessage()){const s=this._validateFailedFileMessageHasFile(e,t);d.unless(s).throw(d.SendbirdError.invalidParameters);const n=h.createFileMessageCreateParamsFromFailedFileMessage(e,t),i=new h.MessageRequestHandler;return this._sendFileMessage(n,h.SendMessageRequestType.RESEND,e.reqId).onPending((e=>{i._trigger(e)})).onFailed(((e,t)=>{i._triggerFailed(e,t)})).onSucceeded((e=>{this._tryUpdateLastMessageAndCallEvents(this,e),i._trigger(e)})),i}if(e.isMultipleFilesMessage()){const t=e.messageParams,s=new h.MultipleFilesMessageRequestHandler;return this._sendMultipleFilesMessage(t,h.SendMessageRequestType.RESEND,e.reqId).onPending((e=>{s._trigger(e)})).onFailed(((e,t)=>{s._triggerFailed(e,t)})).onSucceeded((e=>{this._tryUpdateLastMessageAndCallEvents(this,e),s._trigger(e)})).onFileUploaded(((e,t,n,i)=>{s._triggerOnFileUploaded(e,t,n,i)})),s}}copyMessage(e,t){if(d.unless(e instanceof h.BaseChannel&&t instanceof h.SendableMessage&&t.sendingStatus===d.SendingStatus.SUCCEEDED&&this.url===t.channelUrl&&!t.scheduledInfo).throw(d.SendbirdError.invalidParameters),t.isUserMessage()){d.unless(!t.poll).throw(d.SendbirdError.notSupportedError);const s=h.createUserMessageCreateParams(t),n=new h.MessageRequestHandler;return e._sendUserMessage(s).onPending((e=>{n._trigger(e)})).onFailed(((e,t)=>{n._triggerFailed(e,t)})).onSucceeded((t=>{e.isGroupChannel()&&this._tryUpdateLastMessageAndCallEvents(e,t),n._trigger(t)})),n}if(t.isFileMessage()){const s=h.createFileMessageCreateParams(t),n=new h.MessageRequestHandler;return e._sendFileMessage(s).onPending((e=>{n._trigger(e)})).onFailed(((e,t)=>{n._triggerFailed(e,t)})).onSucceeded((t=>{e.isGroupChannel()&&this._tryUpdateLastMessageAndCallEvents(e,t),n._trigger(t)})),n}if(t.isMultipleFilesMessage()){if(e.isGroupChannel()){const s=h.createMultipleFilesMessageCreateParams(t),n=new h.MultipleFilesMessageRequestHandler;return e._sendMultipleFilesMessage(s,h.SendMessageRequestType.COPY).onPending((e=>{n._trigger(e)})).onFailed(((e,t)=>{n._triggerFailed(e,t)})).onSucceeded((t=>{this._tryUpdateLastMessageAndCallEvents(e,t),n._trigger(t)})).onFileUploaded(((e,t,s,i)=>{n._triggerOnFileUploaded(e,t,s,i)})),n}throw d.SendbirdError.channelTypeNotSupportedError}}}exports.BaseMessageCollection=Je,exports.DeclineInvitationEventCommand=de,exports.FeedChannelEventContext=je,exports.FeedChannelRemoveEventCommand=He,exports.FeedChannelUpdateEventCommand=ke,exports.GetTotalUnreadMessageCountRequestCommand=W,exports.GetTotalUnreadMessageCountResponseCommand=$,exports.GroupChannel=Lt,exports.GroupChannelChangeLogsParamsDefault=v,exports.GroupChannelCountParamsDefault=M,exports.GroupChannelCreateParamsDefault=C,exports.GroupChannelEventContext=Be,exports.GroupChannelEventSource=U,exports.GroupChannelFilter=m,exports.GroupChannelListQuery=ve,exports.GroupChannelManager=Ne,exports.InviteToGroupChannelEventCommand=oe,exports.Member=_,exports.MemberListQuery=at,exports.MessageAckCommand=Ee,exports.MessageCollection=Ze,exports.MessageCollectionInitHandler=Ye,exports.MessageEventContext=We,exports.NotificationEventContext=$e,exports.PinnedMessage=It,exports.PinnedMessageListQuery=Ot,exports.ReadEventCommand=Se,exports.ReadRequestCommand=Me,exports.ReadStatus=p,exports.Sync=Ue,exports.TotalUnreadMessageCountParamsDefault=b,exports.shouldGiveEvent=I,exports.validateGroupChannelChangeLogsParams=f,exports.validateGroupChannelCountParams=S,exports.validateGroupChannelCreateParams=E,exports.validateTotalUnreadMessageCountParams=N;
diff --git a/cjs/lib/__bundle-92ec8a78.js b/cjs/lib/__bundle-92ec8a78.js
deleted file mode 100644
index e058d7e..0000000
--- a/cjs/lib/__bundle-92ec8a78.js
+++ /dev/null
@@ -1 +0,0 @@
-"use strict";var e,t=require("./__bundle-fc8b8d13.js");class s extends t.APIRequestCommand{constructor(e){if(super(),this.method=t.APIRequestMethod.POST,this.path=`${t.API_PATH_UPLOAD}`,this.params=t.deundefined({file:e.file,channel_url:e.channelUrl}),e.thumbnailSizes)for(let t=0;tnew t.User(this._iid,e))):[],this.lastRepliedAt=null!==(n=s.last_replied_at)&&void 0!==n?n:0,this.updatedAt=null!==(a=s.updated_at)&&void 0!==a?a:0}static payloadify(e){return t.deundefined(t.undefineNullProps(Object.assign(Object.assign({},super.payloadify(e)),{reply_count:e.replyCount,most_replies:Array.isArray(e.mostRepliedUsers)?e.mostRepliedUsers.map((e=>t.User.payloadify(e))):[],last_replied_at:e.lastRepliedAt,updated_at:e.updatedAt})))}}exports.ReactionEventOperation=void 0,(e=exports.ReactionEventOperation||(exports.ReactionEventOperation={})).ADD="add",e.DELETE="delete";class a{constructor(e){this.messageId=0,this.operation=null,this.updatedAt=0;const s=t.isTypeOf("string",e.msg_id)?parseInt(e.msg_id):e.msg_id,i=e.user_id,n=e.operation?e.operation.toLowerCase():null,a=e.reaction,r=e.updated_at;s&&t.isTypeOf("string",i)&&t.isTypeOf("string",n)&&t.isEnumOf(exports.ReactionEventOperation,n)&&t.isTypeOf("string",a)&&a&&t.isTypeOf("number",r)&&(this.messageId=s,this.userId=i,this.key=a,this.operation=n,this.updatedAt=r)}}class r{constructor(e){var s;const i=e.key,n=null!==(s=[...e.user_ids])&&void 0!==s?s:[],a=e.updated_at;t.isTypeOf("string",i)&&i&&t.isArrayOf("string",n)&&n.length>0&&t.isTypeOf("number",a)&&(this.key=i,this.userIds=n,this.updatedAt=a);const r={};for(const e of this.userIds)r[e]=this.updatedAt;this._version=r}get isEmpty(){return 0===this.userIds.length}static payloadify(e){return t.deundefined(t.undefineNullProps({key:e.key,user_ids:e.userIds,updated_at:e.updatedAt}))}applyEvent(e){if(e.key===this.key&&this.updatedAt<=e.updatedAt){if(!this._version[e.userId]||this._version[e.userId]<=e.updatedAt){const t=this.userIds.indexOf(e.userId);switch(e.operation){case exports.ReactionEventOperation.ADD:t<0&&this.userIds.push(e.userId);break;case exports.ReactionEventOperation.DELETE:t>=0&&this.userIds.splice(t,1)}this._version[e.userId]=e.updatedAt}this.updatedAt=Math.max(this.updatedAt,e.updatedAt)}}}class o{constructor(e){this.key=e.key,this.value=t.isArrayOf("string",e.value)?[...e.value]:[]}static payloadify(e){var s;return t.deundefined(t.undefineNullProps({key:e.key,value:null!==(s=e.value)&&void 0!==s?s:[]}))}}class l{constructor(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)}static payloadify(e){var s,i;return t.deundefined(t.undefineNullProps({url:e.url,secure_url:e.secureUrl,type:e.type,width:null!==(s=e.width)&&void 0!==s?s:0,height:null!==(i=e.height)&&void 0!==i?i:0,alt:e.alt}))}}class d{constructor(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 l(e["og:image"]))}static payloadify(e){return t.deundefined(t.undefineNullProps({"og:title":e.title,"og:url":e.url,"og:description":e.description,"og:image":e.defaultImage?l.payloadify(e.defaultImage):null}))}}class u{constructor(e){var t,s;this.volume=0,this.name=null!==(t=e.name)&&void 0!==t?t:"default",this.volume=null!==(s=e.volume)&&void 0!==s?s:1}serialize(){return{name:this.name,volume:this.volume}}static payloadify(e){return t.deundefined(t.undefineNullProps({name:e.name,volume:e.volume}))}}class c extends t.User{constructor(e,s){var i;super(e,s),this.isBlockedByMe=!1,this.role=t.isEnumOf(t.Role,s.role)?s.role:t.Role.NONE,this.isBlockedByMe=null!==(i=s.is_blocked_by_me)&&void 0!==i&&i}static payloadify(e){return t.deundefined(t.undefineNullProps(Object.assign(Object.assign({},super.payloadify(e)),{role:e.role,is_blocked_by_me:e.isBlockedByMe})))}}var h,p;exports.ScheduledStatus=void 0,(h=exports.ScheduledStatus||(exports.ScheduledStatus={})).PENDING="pending",h.SENT="sent",h.FAILED="failed",h.CANCELED="canceled",exports.InternalScheduledStatus=void 0,(p=exports.InternalScheduledStatus||(exports.InternalScheduledStatus={})).PENDING="pending",p.IN_QUEUE="in_queue",p.SENT="sent",p.FAILED="failed",p.CANCELED="canceled",p.REMOVED="removed";const m=e=>{switch(e){case t.MessageType.BASE:return"";case t.MessageType.USER:return"MESG";case t.MessageType.FILE:return"FILE";case t.MessageType.ADMIN:return"ADMM"}};class _ extends t.InstancedObject{constructor(e,s){var i,a,l,c,h,p,m,_,g,y,f,v,I,E,T,b;super(e),this.channelType=t.ChannelType.BASE,this.parentMessage=null,this.silent=!1,this.isOperatorMessage=!1,this.messageType=t.MessageType.BASE,this.mentionType=null,this.threadInfo=null,this.reactions=[],this.metaArrays=[],this.appleCriticalAlertOptions=null,this.createdAt=0,this.updatedAt=0,this.scheduledInfo=null,this.extendedMessage={},this.notificationData=null,this._isContinuousMessages=!1,this._scheduledStatus=null,this.messageId=null!==(a=null!==(i=s.msg_id)&&void 0!==i?i:s.message_id)&&void 0!==a?a:0,this.channelUrl=s.channel_url,this.channelType=t.isEnumOf(t.ChannelType,s.channel_type)?s.channel_type:t.ChannelType.GROUP,s.channel&&(s.channel.channel_url&&(this.channelUrl=s.channel.channel_url),s.channel.channel_type&&(this.channelType=s.channel.channel_type)),this.parentMessageId=null!==(l="string"==typeof s.parent_message_id?parseInt(s.parent_message_id):s.parent_message_id)&&void 0!==l?l:0,this.data=null!==(c=s.data)&&void 0!==c?c:"",this.customType=null!==(h=s.custom_type)&&void 0!==h?h:"",this.mentionType=t.isEnumOf(t.MentionType,s.mention_type)?s.mention_type:null,this.mentionedUsers=s.mentioned_users?s.mentioned_users.map((e=>new t.User(this._iid,e))):null,this.mentionedUserIds=null!==(p=s.mentioned_user_ids)&&void 0!==p?p:null,this.mentionedUsers&&!this.mentionedUserIds&&(this.mentionedUserIds=this.mentionedUsers.map((e=>e.userId))),this.mentionedMessageTemplate=null!==(m=s.mentioned_message_template)&&void 0!==m?m:"",this.threadInfo=s.thread_info?new n(this._iid,s.thread_info):null,this.reactions=s.reactions?s.reactions.map((e=>new r(e))):[];const S=null!==(_=s.metaarray)&&void 0!==_?_:{},O=null!==(g=s.metaarray_key_order)&&void 0!==g?g:Object.keys(S).sort(((e,t)=>e.localeCompare(t)));this.metaArrays=[];for(let e=0;enew o(e)))),this.ogMetaData=s.og_tag?new d(s.og_tag):null,this.silent=null!==(y=s.silent)&&void 0!==y&&y,this.isOperatorMessage=null!==(f=s.is_op_msg)&&void 0!==f&&f,this.appleCriticalAlertOptions=s.apple_critical_alert_options?new u(s.apple_critical_alert_options):null,this.createdAt=null!==(I=null!==(v=s.created_at)&&void 0!==v?v:s.ts)&&void 0!==I?I:0,this.updatedAt=null!==(E=s.updated_at)&&void 0!==E?E:0,"number"==typeof s.scheduled_message_id&&"number"==typeof s.scheduled_at&&s.scheduled_status&&(this.scheduledInfo={scheduledMessageId:s.scheduled_message_id,scheduledAt:s.scheduled_at},this._scheduledStatus=s.scheduled_status),this.extendedMessage=null!==(T=s.extended_message)&&void 0!==T?T:{},0===this.extendedMessage.sub_type)try{const{label:e,tags:t,template_key:s,template_variables:i}=JSON.parse(this.extendedMessage.sub_data);this.notificationData={label:e,tags:t,templateKey:s,templateVariables:i}}catch(e){}this._isContinuousMessages=null!==(b=s.is_continuous_messages)&&void 0!==b&&b}static payloadify(e){var s,i,a,l;return t.deundefined(t.undefineNullProps(Object.assign(Object.assign({},super.payloadify(e)),{channel_url:e.channelUrl,channel_type:e.channelType,message_id:e.messageId,type:m(e.messageType),parent_message_id:e.parentMessageId,data:e.data,custom_type:e.customType,mention_type:e.mentionType,mentioned_user_ids:e.mentionedUserIds,mentioned_users:null===(s=e.mentionedUsers)||void 0===s?void 0:s.map((e=>t.User.payloadify(e))),mentioned_message_template:e.mentionedMessageTemplate,thread_info:e.threadInfo?n.payloadify(e.threadInfo):null,reactions:e.reactions.map((e=>r.payloadify(e))),sorted_metaarray:null===(i=e.metaArrays)||void 0===i?void 0:i.map((e=>o.payloadify(e))),og_tag:e.ogMetaData?d.payloadify(e.ogMetaData):null,silent:e.silent,is_op_msg:e.isOperatorMessage,apple_critical_alert_options:e.appleCriticalAlertOptions?u.payloadify(e.appleCriticalAlertOptions):null,created_at:e.createdAt,updated_at:e.updatedAt,scheduled_message_id:null===(a=e.scheduledInfo)||void 0===a?void 0:a.scheduledMessageId,scheduled_at:null===(l=e.scheduledInfo)||void 0===l?void 0:l.scheduledAt,scheduled_status:e._scheduledStatus,extended_message:e.extendedMessage})))}static _getParentMessageInfoPayload(e){return t.deundefined(t.undefineNullProps({type:m(e.messageType),ts:e.createdAt,user:e.sender?c.payloadify(e.sender):null,message:e.message,file:{url:e.plainUrl,name:e.name,type:e.type,require_auth:e.requireAuth}}))}isIdentical(e){return this.messageId===e.messageId}isEqual(e){return t.deepEqual(this,e)}isUserMessage(){return this.messageType===t.MessageType.USER}isFileMessage(){return this.messageType===t.MessageType.FILE&&!Object.prototype.hasOwnProperty.call(this,"fileInfoList")}isMultipleFilesMessage(){return this.messageType===t.MessageType.FILE&&Object.prototype.hasOwnProperty.call(this,"fileInfoList")}isAdminMessage(){return this.messageType===t.MessageType.ADMIN}serialize(){return t.serialize(this)}getMetaArraysByKeys(e){return this.metaArrays.filter((t=>e.includes(t.key)))}applyThreadInfoUpdateEvent(e){return this.messageId===e.targetMessageId&&(this.threadInfo=e.threadInfo),!1}applyReactionEvent(e){if(this.messageId===e.messageId){let t=!1;for(let s=0;s=t)return this.parentMessage=e,!0}return!1}}class g extends _{constructor(e,s){var i,n,a,r;if(super(e,s),this.reqId="",this.replyToChannel=!1,this.errorCode=0,this.sender=s.user?new c(this._iid,s.user):s.sender_id,this.reqId=null!==(n=null!==(i=s.req_id)&&void 0!==i?i:s.request_id)&&void 0!==n?n:"",this.replyToChannel=null!==(a=s.is_reply_to_channel)&&void 0!==a&&a,s.request_state&&t.isEnumOf(t.SendingStatus,s.request_state)&&(this.sendingStatus=s.request_state),!this.sendingStatus)if(this.messageId>0)this.sendingStatus=t.SendingStatus.SUCCEEDED;else if(this.scheduledInfo)switch(s.scheduled_status&&(this._scheduledStatus=s.scheduled_status),s.scheduled_status){case exports.InternalScheduledStatus.SENT:case exports.InternalScheduledStatus.IN_QUEUE:this.sendingStatus=t.SendingStatus.SUCCEEDED;break;case exports.InternalScheduledStatus.PENDING:this.sendingStatus=t.SendingStatus.SCHEDULED;break;case exports.InternalScheduledStatus.FAILED:case exports.InternalScheduledStatus.REMOVED:this.sendingStatus=t.SendingStatus.FAILED;break;case exports.InternalScheduledStatus.CANCELED:this.sendingStatus=t.SendingStatus.CANCELED}else this.sendingStatus=t.SendingStatus.PENDING;this.errorCode=null!==(r=s.error_code)&&void 0!==r?r:0}static payloadify(e){return t.deundefined(t.undefineNullProps(Object.assign(Object.assign({},super.payloadify(e)),{user:c.payloadify(e.sender),req_id:e.reqId,is_reply_to_channel:e.replyToChannel,request_state:e.sendingStatus,error_code:e.errorCode})))}get isResendable(){return(this.sendingStatus===t.SendingStatus.FAILED||this.sendingStatus===t.SendingStatus.CANCELED)&&t.isResendableError(this.errorCode)}isIdentical(e){return this.messageId>0&&e.messageId>0?this.messageId===e.messageId:this.reqId===e.reqId}}class y{constructor(e,t,s){var i,n;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!==(i=t.real_width)&&void 0!==i?i:t.width,this.realHeight=null!==(n=t.real_height)&&void 0!==n?n:t.height,this._requireAuth=s}static payloadify(e){return t.deundefined(t.undefineNullProps({url:"",width:e.maxWidth,height:e.maxHeight,real_width:0,real_height:0}))}get url(){const{sessionManager:e}=t.Vault.of(this._iid);return this._requireAuth?`${this.plainUrl}?auth=${e.ekey}`:this.plainUrl}}const f={prevResultSize:0,nextResultSize:0,isInclusive:!1,reverse:!1,messageTypeFilter:t.MessageTypeFilter.ALL,customTypesFilter:void 0,senderUserIdsFilter:void 0,includeReactions:!1,includeMetaArray:!1,includeParentMessageInfo:!1},v=e=>t.isTypeOf("number",e.prevResultSize)&&t.isTypeOf("number",e.nextResultSize)&&t.isTypeOf("boolean",e.isInclusive)&&t.isTypeOf("boolean",e.reverse)&&t.isTypeOf("string",e.messageTypeFilter)&&t.isEnumOf(t.MessageTypeFilter,e.messageTypeFilter)&&t.isArrayOf("string",e.customTypesFilter,!0)&&t.isArrayOf("string",e.senderUserIdsFilter,!0)&&t.isTypeOf("boolean",e.includeMetaArray)&&t.isTypeOf("boolean",e.includeReactions)&&t.isTypeOf("boolean",e.includeParentMessageInfo);class I extends _{constructor(e,s){var i,n,a,r;if(super(e,s),this.translations={},this.message=null!==(i=s.message)&&void 0!==i?i:"",this.messageType=t.MessageType.ADMIN,this.translations=null!==(n=s.translations)&&void 0!==n?n:{},s.parent_message_info){const i=s.parent_message_info;this.parentMessage=O(e,t.deundefined(t.undefineNullProps(Object.assign(Object.assign({},i),{message_id:this.parentMessageId,channel_url:this.channelUrl,channel_type:this.channelType,file:i.file,url:null===(a=i.file)||void 0===a?void 0:a.url,require_auth:null===(r=i.file)||void 0===r?void 0:r.require_auth}))))}}static payloadify(e){return t.deundefined(t.undefineNullProps(Object.assign(Object.assign({},super.payloadify(e)),{message:e.message,translations:e.translations,parent_message_info:e.parentMessage?super._getParentMessageInfoPayload(e.parentMessage):null})))}getThreadedMessagesByTimestamp(e,s){return t.__awaiter(this,void 0,void 0,(function*(){const i=Object.assign(Object.assign({},f),s);t.unless(this.messageId>0&&t.isTypeOf("number",e)&&v(i)).throw(t.SendbirdError.invalidParameters);const n=ai.of(this._iid);return yield n.getThreadedMessagesByTimestamp(this,e,i)}))}}class E{constructor(e){var s,i;this.detail={},this.type=null!==(s=e.type)&&void 0!==s?s:"",this.vendor=null!==(i=e.vendor)&&void 0!==i?i:"",e.detail&&t.isTypeOf("object",e.detail)&&!Array.isArray(e.detail)&&(this.detail=e.detail)}static payloadify(e){return t.deundefined(t.undefineNullProps({type:e.type,vendor:e.vendor,detail:e.detail}))}}class T extends g{constructor(e,s){var i,n,a,r,o;if(super(e,s),this.message="",this.messageParams=null,this.translations={},this.translationTargetLanguages=[],this.messageSurvivalSeconds=-1,this.plugins=[],this._poll=null,this.message=s.message,this.messageType=t.MessageType.USER,this.translations=null!==(i=s.translations)&&void 0!==i?i:{},this.translationTargetLanguages=null!==(n=s.target_langs)&&void 0!==n?n:[],0===Object.keys(this.translations).length&&this.translationTargetLanguages.length>0)for(const e of this.translationTargetLanguages)this.translations[e]="";if(this.messageSurvivalSeconds=null!==(a=s.message_survival_seconds)&&void 0!==a?a:-1,this.plugins=s.plugins?s.plugins.map((e=>new E(e))):[],this._poll=s.poll?new t.Poll(this._iid,s.poll):null,s.parent_message_info){const i=s.parent_message_info;this.parentMessage=O(e,t.deundefined(t.undefineNullProps(Object.assign(Object.assign({},i),{created_at:i.ts,message_id:this.parentMessageId,channel_url:this.channelUrl,channel_type:this.channelType,file:i.file,url:null===(r=i.file)||void 0===r?void 0:r.url,require_auth:null===(o=i.file)||void 0===o?void 0:o.require_auth}))))}}static payloadify(e){return t.deundefined(t.undefineNullProps(Object.assign(Object.assign({},super.payloadify(e)),{message:e.message,translations:e.translations,message_survival_seconds:e.messageSurvivalSeconds,plugins:e.plugins.map((e=>E.payloadify(e))),poll:e._poll?t.Poll.payloadify(e._poll):null,parent_message_info:e.parentMessage?super._getParentMessageInfoPayload(e.parentMessage):null})))}getThreadedMessagesByTimestamp(e,s){return t.__awaiter(this,void 0,void 0,(function*(){const i=Object.assign(Object.assign({},f),s);t.unless(this.messageId>0&&t.isTypeOf("number",e)&&v(i)).throw(t.SendbirdError.invalidParameters);const n=ai.of(this._iid);return yield n.getThreadedMessagesByTimestamp(this,e,i)}))}applyPoll(e){return!(this._poll&&this._poll.id===e.id&&this._poll.updatedAt>e.updatedAt)&&(this._poll=e,!0)}get poll(){return this._poll}}class b extends t.InstancedObject{constructor(e,s){var i,n,a,r,o;super(e),this.plainUrl="",this.fileName=null,this.mimeType=null,this.fileSize=0,this.thumbnails=[],this._requireAuth=!1,this.plainUrl=null!==(i=s.url)&&void 0!==i?i:"",this.fileName=null!==(n=s.file_name)&&void 0!==n?n:null,this.mimeType=null!==(a=s.file_type)&&void 0!==a?a:null,this.fileSize=null!==(r=s.file_size)&&void 0!==r?r:0,this._requireAuth=null!==(o=s.require_auth)&&void 0!==o&&o,t.Vault.of(this._iid),this.thumbnails=s.thumbnails?s.thumbnails.map((e=>{var t;return new y(this._iid,"string"==typeof e?{url:e,width:0,height:0}:Object.assign(Object.assign({},e),{url:(null!==(t=e.url)&&void 0!==t?t:"").split("auth=")[0]}),this._requireAuth)})):[]}static payloadify(e){var s;return t.deundefined(t.undefineNullProps({url:e.plainUrl,file_name:e.fileName,file_type:e.mimeType,file_size:e.fileSize,thumbnails:null===(s=e.thumbnails)||void 0===s?void 0:s.map((e=>({url:e.url,width:e.width,height:e.height,real_width:e.realWidth,real_height:e.realHeight}))),require_auth:e._requireAuth}))}get url(){const{sessionManager:e}=t.Vault.of(this._iid);return this._requireAuth?`${this.plainUrl}?auth=${e.ekey}`:this.plainUrl}}class S extends g{constructor(e,s){var i,n,a,r,o;if(super(e,s),this.messageParams=null,this.fileInfoList=[],this.messageSurvivalSeconds=-1,this.messageType=t.MessageType.FILE,this.fileInfoList=null!==(n=null===(i=s.files)||void 0===i?void 0:i.map((t=>new b(e,t))))&&void 0!==n?n:[],this.messageSurvivalSeconds=null!==(a=s.message_survival_seconds)&&void 0!==a?a:-1,s.parent_message_info){const i=s.parent_message_info;this.parentMessage=O(e,t.deundefined(t.undefineNullProps(Object.assign(Object.assign({},i),{created_at:i.ts,message_id:this.parentMessageId,channel_url:this.channelUrl,channel_type:this.channelType,file:i.file,url:null===(r=i.file)||void 0===r?void 0:r.url,require_auth:null===(o=i.file)||void 0===o?void 0:o.require_auth}))))}}getThreadedMessagesByTimestamp(e,s){return t.__awaiter(this,void 0,void 0,(function*(){const i=Object.assign(Object.assign({},f),s);t.unless(this.messageId>0&&t.isTypeOf("number",e)&&v(i)).throw(t.SendbirdError.invalidParameters);const n=ai.of(this._iid);return yield n.getThreadedMessagesByTimestamp(this,e,i)}))}static payloadify(e){return t.deundefined(t.undefineNullProps(Object.assign(Object.assign({},super.payloadify(e)),{files:e.fileInfoList&&e.fileInfoList&&Array.isArray(e.fileInfoList)?e.fileInfoList.map((e=>b.payloadify(e))):null,message_survival_seconds:e.messageSurvivalSeconds,parent_message_info:e.parentMessage?super._getParentMessageInfoPayload(e.parentMessage):null})))}static _isMultipleFilesMessagePayload(e){const t=e.files;return Array.isArray(t)&&t.length>=2}static _isMultipleFilesMessageSerializedData(e){const t=e.fileInfoList;return Array.isArray(t)}}const O=(e,t)=>{switch(t.type){case"MESG":return new T(e,t);case"FILE":return S._isMultipleFilesMessagePayload(t)?new S(e,t):new M(e,t);case"ADMM":case"BRDM":return new I(e,t)}return null};class M extends g{constructor(e,s){var i,n,a,r,o,l,d,u,c,h,p,m,_,g;super(e,s),this.messageParams=null,this.plainUrl="",this.requireAuth=!1,this.thumbnails=[],this.messageSurvivalSeconds=-1,this.messageType=t.MessageType.FILE;const f=s.file;if(this.plainUrl=(null!==(n=null!==(i=null==f?void 0:f.url)&&void 0!==i?i:s.url)&&void 0!==n?n:"").split("?auth=")[0],this.name=null!==(r=null!==(a=null==f?void 0:f.name)&&void 0!==a?a:s.name)&&void 0!==r?r:"File",this.size=null!==(l=null!==(o=null==f?void 0:f.size)&&void 0!==o?o:s.size)&&void 0!==l?l:0,this.data=null!==(u=null!==(d=null==f?void 0:f.data)&&void 0!==d?d:s.custom)&&void 0!==u?u:"",this.type=f?null!==(c=f.type)&&void 0!==c?c:"":null!==(h=s.type)&&void 0!==h?h:"",t.Vault.of(this._iid),this.requireAuth=null!==(p=s.require_auth)&&void 0!==p&&p,this.thumbnails=s.thumbnails?s.thumbnails.map((e=>{var t;return new y(this._iid,"string"==typeof e?{url:e,width:0,height:0}:Object.assign(Object.assign({},e),{url:(null!==(t=e.url)&&void 0!==t?t:"").split("auth=")[0]}),this.requireAuth)})):[],this.messageSurvivalSeconds=null!==(m=s.message_survival_seconds)&&void 0!==m?m:-1,s.parent_message_info){const i=s.parent_message_info;this.parentMessage=O(e,t.deundefined(t.undefineNullProps(Object.assign(Object.assign({},i),{created_at:i.ts,message_id:this.parentMessageId,channel_url:this.channelUrl,channel_type:this.channelType,file:i.file,url:null===(_=i.file)||void 0===_?void 0:_.url,require_auth:null===(g=i.file)||void 0===g?void 0:g.require_auth}))))}}static payloadify(e){var s;return t.deundefined(t.undefineNullProps(Object.assign(Object.assign({},super.payloadify(e)),{url:e.plainUrl,require_auth:e.requireAuth,file:{name:e.name,size:e.size,type:e.type,data:e.data},thumbnails:null===(s=e.thumbnails)||void 0===s?void 0:s.map((e=>({url:e.plainUrl,width:e.width,height:e.height,real_width:e.realWidth,real_height:e.realHeight}))),message_survival_seconds:e.messageSurvivalSeconds,parent_message_info:e.parentMessage?super._getParentMessageInfoPayload(e.parentMessage):null})))}get url(){const{sessionManager:e}=t.Vault.of(this._iid);return this.requireAuth?`${this.plainUrl}?auth=${e.ekey}`:this.plainUrl}getThreadedMessagesByTimestamp(e,s){return t.__awaiter(this,void 0,void 0,(function*(){const i=Object.assign(Object.assign({},f),s);t.unless(this.messageId>0&&t.isTypeOf("number",e)&&v(i)).throw(t.SendbirdError.invalidParameters);const n=ai.of(this._iid);return yield n.getThreadedMessagesByTimestamp(this,e,i)}))}}class A extends t.WebSocketRequestCommand{constructor(e){var s,i,n;let a=[];e.mentionType===t.MentionType.USERS&&(e.mentionedUserIds?a=e.mentionedUserIds:e.mentionedUsers&&(a=e.mentionedUsers.map((e=>e.userId)))),super({code:"FILE",ackRequired:!0,payload:t.deundefined(t.undefineNullProps({channel_url:e.channelUrl,files:e.files?P(e.files):null,url:e.url,name:null!==(s=e.fileName)&&void 0!==s?s:"",type:null!==(i=e.mimeType)&&void 0!==i?i:"",size:null!==(n=e.fileSize)&&void 0!==n?n:0,custom:e.data,custom_type:e.customType,thumbnails:e.thumbnailSizes,require_auth:e.requireAuth,metaarray:e.metaArrays,mention_type:e.mentionType,mentioned_user_ids:a,push_option:e.pushNotificationDeliveryOption&&e.pushNotificationDeliveryOption!==t.PushNotificationDeliveryOption.DEFAULT?e.pushNotificationDeliveryOption:void 0,apple_critical_alert_options:e.appleCriticalAlertOptions?u.payloadify(e.appleCriticalAlertOptions):null,silent:e.silent,reply_to_channel:e.isReplyToChannel,parent_message_id:e.parentMessageId?e.parentMessageId:null,req_id:e.reqId,pin_message:e.isPinnedMessage}))})}}class C extends t.APIRequestCommand{constructor(e){var s,i;super();let n=[];e.mentionType===t.MentionType.USERS&&(e.mentionedUserIds?n=e.mentionedUserIds:e.mentionedUsers&&(n=e.mentionedUsers.map((e=>e.userId)))),this.method=t.APIRequestMethod.POST,this.path=`${t.getChannelApiPathByType(e.channelType)}/${encodeURIComponent(e.channelUrl)}/messages`,this.params=t.deundefined(t.undefineNullProps({message_type:t.MessageType.FILE,user_id:e.userId,files:e.files?P(e.files):null,url:e.fileUrl,mention_type:e.mentionType,mentioned_user_ids:n,file_name:e.fileName,file_size:e.fileSize,file_type:e.mimeType,data:e.data,custom_type:e.customType,thumbnails:null===(s=e.thumbnailSizes)||void 0===s?void 0:s.map((e=>y.payloadify(e))),require_auth:e.requireAuth,sorted_metaarray:null===(i=e.metaArrays)||void 0===i?void 0:i.map((e=>o.payloadify(e))),push_option:e.pushNotificationDeliveryOption,parent_message_id:e.parentMessageId?e.parentMessageId:null,apple_critical_alert_options:e.appleCriticalAlertOptions?u.payloadify(e.appleCriticalAlertOptions):null,reply_to_channel:e.isReplyToChannel,req_id:e.reqId,pin_message:e.isPinnedMessage}))}}class w extends t.WebSocketEventCommand{constructor(e,s,i){var n,a,r,o;super(e,"FILE",i),this.message=i.files&&i.files.length>=2?new S(e,i):new M(e,i);const{sdkState:l}=t.Vault.of(e);this.isMentioned=t.checkIfMentioned(this.message.mentionType,null!==(r=null!==(n=this.message.mentionedUserIds)&&void 0!==n?n:null===(a=this.message.mentionedUsers)||void 0===a?void 0:a.map((e=>e.userId)))&&void 0!==r?r:[],l.userId),this.forceUpdateLastMessage=null!==(o=i.force_update_last_message)&&void 0!==o&&o}}class N extends t.APIResponseCommand{constructor(e,s){var i,n,a,r;super(e,s),this.message=s.files&&s.files.length>=2?new S(e,s):new M(e,s);const{sdkState:o}=t.Vault.of(e);this.isMentioned=t.checkIfMentioned(this.message.mentionType,null!==(a=null!==(i=this.message.mentionedUserIds)&&void 0!==i?i:null===(n=this.message.mentionedUsers)||void 0===n?void 0:n.map((e=>e.userId)))&&void 0!==a?a:[],o.userId),this.forceUpdateLastMessage=null!==(r=s.force_update_last_message)&&void 0!==r&&r}}function P(e){return e.map((e=>{var s,i;return t.deundefined(t.undefineNullProps({url:e.fileUrl,file_name:e.fileName,file_type:e.mimeType,file_size:e.fileSize,thumbnails:null===(s=e.thumbnailSizes)||void 0===s?void 0:s.map((e=>y.payloadify(e))),require_auth:null===(i=e._uploadedMetaData)||void 0===i?void 0:i.requireAuth}))}))}var U;!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"}(U||(U={}));class R{constructor(e,{sdkState:s,dispatcher:i,requestQueue:n,onlineDetector:a,cacheContext:r}){this._queueMap=new Map,this._iid=e,this._sdkState=s,this._requestQueue=n,this._cacheContext=r,this._dispatcher=i,this._dispatcher.on((e=>{e instanceof t.ConnectionStateChangeCommand&&(this._connectionState=e.stateType)})),this._onlineDetector=a}get _shouldSendThroughWebSocket(){return this._connectionState===t.ConnectionStateType.CONNECTED||this._connectionState===t.ConnectionStateType.CONNECTING||this._connectionState===t.ConnectionStateType.RECONNECTING}_sendFileMessage(e,s){return t.__awaiter(this,void 0,void 0,(function*(){const t=this._createSendFileMessageRequestParams(e,s);if(this._shouldSendThroughWebSocket){const e=new A(t),s=yield this._requestQueue.send(e),{message:i}=s.as(w);return i}{const e=new C(Object.assign(Object.assign({},t),{userId:this._sdkState.userId})),s=yield this._requestQueue.send(e),{message:i}=s.as(N);return i}}))}_createSendFileMessageRequestParams(e,t){const s=Object.assign(Object.assign({},t.params),{channelUrl:e.url,channelType:e.channelType,reqId:t.requestId,url:""});if(t.multipleFileUploadInfo){const e=t.params;s.files=e.fileInfoList}else{const e=t.params;s.url=e.fileUrl,s.requireAuth=e.requireAuth}return s}_resolveMessageQueue(e){var s;return t.__awaiter(this,void 0,void 0,(function*(){const i=this._queueMap.get(e.url);if(i)if(i.isResolving)i.isResolveRequestPending=!0;else{i.isResolving=!0;const n=[];let a=!0;for(const r of i.messageQueue)switch(r.state){case U.PENDING:case U.UPLOADING:a=!1,n.push(r);break;case U.UPLOADED:if(a)try{r.state=U.SENDING;const s=yield this._sendFileMessage(e,r);r.deferred.resolve(s),yield t.sleep(100)}catch(e){r.deferred.reject(e)}else n.push(r);break;case U.FAILED:{const e=null!==(s=r.error)&&void 0!==s?s:t.SendbirdError.unknown;r.deferred.reject(e.code===t.SendbirdErrorCode.REQUEST_CANCELED?t.SendbirdError.fileUploadCanceled:e);break}}const r=i.isResolveRequestPending;i.messageQueue=n,i.isResolving=!1,i.isResolveRequestPending=!1,r&&(yield this._resolveMessageQueue(e))}}))}_uploadNextPendingItem(e){var s;return t.__awaiter(this,void 0,void 0,(function*(){const i=this._queueMap.get(e.url);if(i){const n=i.messageQueue.find((e=>e.state===U.PENDING));if(n){if(n.multipleFileUploadInfo){const{uploadIndex:a,uploadCount:r,requestHandler:o}=n.multipleFileUploadInfo,l=n.params.fileInfoList[a];t.isFile(l.file)&&!(null===(s=l._uploadedMetaData)||void 0===s?void 0:s.isUploaded)?yield this._tryUploadNextItemAndUpdateItemState(e,i,n):n.state=ae.requestId===t.requestId));s>=0&&e.uploadQueue.splice(s,1)}_uploadNextFileForSingleFileItemAndUpdateParams(e,n,a){var r,o,l;return t.__awaiter(this,void 0,void 0,(function*(){const t=new s({file:a.file,channelUrl:e.url,thumbnailSizes:a.thumbnailSizes,requestId:n.requestId}),d=yield this._requestQueue.send(t),{url:u,fileSize:c=a.fileSize,thumbnailSizes:h=a.thumbnailSizes,requireAuth:p=!1}=d.as(i);a.fileName=null!==(r=a.fileName)&&void 0!==r?r:a.file.name,a.mimeType=null!==(o=a.mimeType)&&void 0!==o?o:a.file.type,a.fileSize=null!==(l=a.fileSize)&&void 0!==l?l:a.file.size,a.fileUrl=u,a.fileSize=c,a.thumbnailSizes=h,a.requireAuth=p}))}_uploadNextFileForMultipleFilesItemAndUpdateParams(e,n,a){var r,o,l;return t.__awaiter(this,void 0,void 0,(function*(){const{uploadIndex:t}=n.multipleFileUploadInfo,d=a.fileInfoList[t],u=new s({file:d.file,channelUrl:e.url,thumbnailSizes:d.thumbnailSizes,requestId:n.requestId}),c=yield this._requestQueue.send(u),{url:h,fileSize:p=d.fileSize,thumbnailSizes:m=d.thumbnailSizes,requireAuth:_=!1}=c.as(i);d.fileName=null!==(r=d.fileName)&&void 0!==r?r:d.file.name,d.mimeType=null!==(o=d.mimeType)&&void 0!==o?o:d.file.type,d.fileSize=null!==(l=d.fileSize)&&void 0!==l?l:d.file.size,d.file=void 0,d.fileUrl=h,d.fileSize=p,d.thumbnailSizes=m,d._uploadedMetaData=Object.assign(Object.assign({},d._uploadedMetaData),{requireAuth:_,isUploaded:!0})}))}request(e,s,i,n={}){return t.__awaiter(this,void 0,void 0,(function*(){if(!this._queueMap.has(e.url)){const t={messageQueue:[],uploadQueue:[],isResolving:!1,isResolveRequestPending:!1};this._queueMap.set(e.url,t)}const a=this._queueMap.get(e.url),r=new t.Deferred,o={requestId:s,params:i,state:U.PENDING,deferred:r};if(function(e){return"fileInfoList"in e}(i)){const e=i,t=Object.assign({uploadIndex:0,uploadCount:e.fileInfoList.length},n);o.multipleFileUploadInfo=t}return a.messageQueue.push(o),this._uploadNextPendingItem(e),r.promise}))}cancel(e,s){const i=this._queueMap.get(e.url);if(i){const n=s?[i.messageQueue.find((e=>e.requestId===s))]:[...i.messageQueue];for(const s of n)if(s)switch(s.state){case U.PENDING:if(s.state=U.FAILED,s.error=t.SendbirdError.requestCanceled,s.multipleFileUploadInfo&&!s.multipleFileUploadInfo.isCopy){const{uploadIndex:e,requestHandler:i}=s.multipleFileUploadInfo,n=s.params.fileInfoList[e];null==i||i._triggerOnFileUploaded(s.requestId,e,n,t.SendbirdError.fileUploadCanceled)}this._resolveMessageQueue(e);break;case U.UPLOADING:this._requestQueue.cancel(s.requestId)}}}}const x={prevResultSize:0,nextResultSize:0,isInclusive:!1,reverse:!1,messageTypeFilter:t.MessageTypeFilter.ALL,customTypesFilter:void 0,senderUserIdsFilter:void 0,replyType:t.ReplyType.NONE,includeReactions:!1,includeMetaArray:!1,includeParentMessageInfo:!1,includeThreadInfo:!1,showSubchannelMessagesOnly:!1},L=e=>t.isTypeOf("number",e.prevResultSize)&&t.isTypeOf("number",e.nextResultSize)&&t.isTypeOf("boolean",e.isInclusive)&&t.isTypeOf("boolean",e.reverse)&&t.isTypeOf("string",e.messageTypeFilter)&&t.isEnumOf(t.MessageTypeFilter,e.messageTypeFilter)&&t.isArrayOf("string",e.customTypesFilter,!0)&&t.isArrayOf("string",e.senderUserIdsFilter,!0)&&t.isEnumOf(t.ReplyType,e.replyType)&&t.isTypeOf("boolean",e.includeMetaArray)&&t.isTypeOf("boolean",e.includeReactions)&&t.isTypeOf("boolean",e.includeParentMessageInfo)&&t.isTypeOf("boolean",e.includeThreadInfo)&&t.isTypeOf("boolean",e.showSubchannelMessagesOnly),k={replyType:t.ReplyType.NONE,includeReactions:!1,includeThreadInfo:!1,includeMetaArray:!1,includeParentMessageInfo:!1},D=e=>t.isEnumOf(t.ReplyType,e.replyType)&&t.isTypeOf("boolean",e.includeReactions)&&t.isTypeOf("boolean",e.includeMetaArray)&&t.isTypeOf("boolean",e.includeParentMessageInfo)&&t.isTypeOf("boolean",e.includeThreadInfo);class q extends t.APIRequestCommand{constructor({channelType:e,channelUrl:s,messageId:i,includeMetaArray:n,includeReactions:a,includeThreadInfo:r,includeParentMessageInfo:o}){super(),this.method=t.APIRequestMethod.GET,this.path=`${t.getChannelApiPathByType(e)}/${encodeURIComponent(s)}/messages/${encodeURIComponent(i)}`,this.params={is_sdk:!0,with_sorted_meta_array:n,include_reactions:a,include_thread_info:r,include_parent_message_info:o,include_poll_details:!0}}}class F extends t.APIResponseCommand{constructor(e,t){super(e,t),this.message=t?O(e,Object.assign({},t)):null}}class B extends t.APIRequestCommand{constructor({channelType:e,channelUrl:s,timestamp:i,token:n,prevResultSize:a,nextResultSize:r,isInclusive:o,reverse:l,messageTypeFilter:d,customTypesFilter:u,senderUserIdsFilter:c,replyType:h,includeMetaArray:p,includeReactions:m,parentMessageId:_,includeThreadInfo:g,includeParentMessageInfo:y,showSubchannelMessagesOnly:f,checkingHasNext:v,checkingContinuousMessages:I}){super(),this.method=t.APIRequestMethod.GET,this.path=`${t.getChannelApiPathByType(e)}/${encodeURIComponent(s)}/messages`,this.params=t.deundefined(t.undefineNullProps({is_sdk:!0,prev_limit:a,next_limit:r,include:o,reverse:l,message_ts:i,message_id:n,message_type:null!=d?d:null,custom_types:u,sender_ids:c,include_reply_type:h,with_sorted_meta_array:p,include_reactions:m,parent_message_id:_,include_thread_info:g,include_parent_message_info:y,show_subchannel_message_only:f,include_poll_details:!0,checking_has_next:v,checking_continuous_messages:I}))}}class j extends t.APIResponseCommand{constructor(e,t){super(e,t),t.is_continuous_messages&&(this.isContinuousMessages=t.is_continuous_messages),t.has_next&&(this.hasNext=t.has_next),this.messages=t.messages.map((t=>O(e,t)))}}class z extends t.APIRequestCommand{constructor({channelType:e,channelUrl:s,timestamp:i,token:n,replyType:a,includeMetaArray:r,includeReactions:o,includeThreadInfo:l,includeParentMessageInfo:d}){super(),this.method=t.APIRequestMethod.GET,this.path=`${t.getChannelApiPathByType(e)}/${encodeURIComponent(s)}/messages/changelogs`,this.params={change_ts:i,token:n,with_sorted_meta_array:r,include_reactions:o,include_thread_info:l,include_reply_type:a,include_parent_message_info:d,include_poll_details:!0}}}class V extends t.APIResponseCommand{constructor(e,t){super(e,t),this.updatedMessages=t.updated.map((t=>O(e,t))),this.deletedMessagesInfo=t.deleted.map((e=>({messageId:e.message_id,deletedAt:e.deleted_at}))),this.hasMore=t.has_more,this.nextToken=t.next}}class $ extends t.APIRequestCommand{constructor({channelUrl:e,scheduledMessageId:s}){super(),this.method=t.APIRequestMethod.GET,this.path=`${t.API_PATH_GROUP_CHANNELS}/${encodeURIComponent(e)}/scheduled_messages/${encodeURIComponent(s)}`,this.params={}}}class Q extends t.APIResponseCommand{constructor(e,t){super(e,t),this.message=t?O(e,Object.assign({},t)):null}}var K;exports.RestrictionType=void 0,(K=exports.RestrictionType||(exports.RestrictionType={})).MUTED="muted",K.BANNED="banned";class G{constructor(e){var s,i,n,a;this.restrictionType=null,t.isEnumOf(exports.RestrictionType,e.restriction_type)&&(this.restrictionType=e.restriction_type),this.description=null!==(s=e.description)&&void 0!==s?s:null,this.endAt=null!==(n=null!==(i=e.end_at)&&void 0!==i?i:e.muted_end_at)&&void 0!==n?n:-1,this.remainingDuration=null!==(a=e.remaining_duration)&&void 0!==a?a:-1}static payloadify(e){return t.deundefined(t.undefineNullProps({restriction_type:e.restrictionType,description:e.description,end_at:e.endAt,remaining_duration:e.remainingDuration}))}}class H extends t.User{constructor(e,t){super(e,t),this.restrictionInfo=new G(t)}static payloadify(e){return t.deundefined(t.undefineNullProps(Object.assign(Object.assign({},super.payloadify(e)),G.payloadify(e.restrictionInfo))))}}class W{constructor(){this._onPending=t.noop,this._onFailed=t.noop,this._onSucceeded=t.noop}_trigger(e){switch(null==e?void 0:e.sendingStatus){case t.SendingStatus.PENDING:0===e.errorCode&&this._onPending(e);break;case t.SendingStatus.SCHEDULED:case t.SendingStatus.SUCCEEDED:this._onSucceeded(e)}}_triggerFailed(e,s){switch(null==s?void 0:s.sendingStatus){case t.SendingStatus.FAILED:case t.SendingStatus.CANCELED:this._onFailed(e,s.scheduledInfo?null:s)}}onPending(e){return this._onPending=e,this}onFailed(e){return this._onFailed=e,this}onSucceeded(e){return this._onSucceeded=e,this}}const Y={data:void 0,customType:void 0,mentionType:t.MentionType.USERS,mentionedUserIds:void 0,mentionedUsers:void 0,mentionedMessageTemplate:void 0,metaArrays:void 0,parentMessageId:void 0,isReplyToChannel:!1,pushNotificationDeliveryOption:void 0,appleCriticalAlertOptions:void 0,isPinnedMessage:!1},J=e=>t.isTypeOf("string",e.data,!0)&&t.isTypeOf("string",e.customType,!0)&&t.isEnumOf(t.MentionType,e.mentionType)&&t.isArrayOf("string",e.mentionedUserIds,!0)&&t.isArrayOf(t.User,e.mentionedUsers,!0)&&t.isTypeOf("string",e.mentionedMessageTemplate,!0)&&t.isArrayOf(o,e.metaArrays,!0)&&t.isTypeOf("number",e.parentMessageId,!0)&&t.isTypeOf("boolean",e.isReplyToChannel)&&t.isEnumOf(t.PushNotificationDeliveryOption,e.pushNotificationDeliveryOption,!0)&&t.isTypeOf(u,e.appleCriticalAlertOptions,!0)&&t.isTypeOf("boolean",e.isPinnedMessage,!0),X=e=>({isReplyToChannel:e.isReplyToChannel,pushNotificationDeliveryOption:e.pushNotificationDeliveryOption,pollId:e.pollId}),Z=Object.assign(Object.assign({},Y),{message:"",translationTargetLanguages:void 0,pollId:void 0});function ee(e){var s,i,n;return null!==(s=e.messageParams)&&void 0!==s?s:t.undefineNullProps(Object.assign(Object.assign({},e),{mentionType:e.mentionType,mentionedUserIds:null!==(i=e.mentionedUserIds)&&void 0!==i?i:null===(n=e.mentionedUsers)||void 0===n?void 0:n.map((e=>e.userId)),translationTargetLanguages:Object.keys(e.translations),pushNotificationDeliveryOption:t.PushNotificationDeliveryOption.DEFAULT,parentMessageId:null,isReplyToChannel:!1,isPinnedMessage:!1}))}const te=e=>{var s;return t.deundefined(t.undefineNullProps({data:e.data,customType:e.customType,mentionType:e.mentionType,mentionedUsers:e.mentionedUsers,mentionedUserIds:e.mentionedUserIds,mentionedMessageTemplate:e.mentionedMessageTemplate,metaArrays:e.metaArrays,pollId:null===(s=e.poll)||void 0===s?void 0:s.id,parentMessageId:e.parentMessageId,appleCriticalAlertOptions:e.appleCriticalAlertOptions,message:e.message,translationTargetLanguages:Object.keys(e.translations)}))},se=e=>J(e)&&t.isTypeOf("string",e.message)&&t.isArrayOf("string",e.translationTargetLanguages,!0)&&t.isTypeOf("number",e.pollId,!0);var ie;!function(e){e.FILE="file",e.BLOB="blob",e.BLOB_LIKE_OBJECT="blobLikeObject",e.URL="url"}(ie||(ie={}));const ne=e=>"undefined"!=typeof window&&"Blob"in window&&"undefined"!=typeof Blob&&e instanceof Blob,ae=e=>e===ie.BLOB||e===ie.FILE,re=e=>({file:e.file,fileKey:e.fileKey,fileType:e.fileType,isReplyToChannel:e.isReplyToChannel,pushNotificationDeliveryOption:e.pushNotificationDeliveryOption}),oe=Object.assign(Object.assign({},Y),{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});function le(e){var s,i,n,a;return null!==(s=e.messageParams)&&void 0!==s?s:t.undefineNullProps(Object.assign(Object.assign({},e),{fileUrl:e.plainUrl,fileName:e.name,fileSize:e.size,mimeType:e.type,mentionType:e.mentionType,mentionedUserIds:null!==(i=e.mentionedUserIds)&&void 0!==i?i:null===(n=e.mentionedUsers)||void 0===n?void 0:n.map((e=>e.userId)),pushNotificationDeliveryOption:t.PushNotificationDeliveryOption.DEFAULT,parentMessageId:null,isReplyToChannel:!1,thumbnailSizes:null===(a=e.thumbnails)||void 0===a?void 0:a.map((e=>({maxWidth:e.width,maxHeight:e.height}))),requireAuth:e.requireAuth,isPinnedMessage:!1}))}const de=(e,s)=>{var i;return e.messageParams?(!e.url&&t.isFile(s)&&(e.messageParams.file=s),e.messageParams):t.deundefined(t.undefineNullProps({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:s,fileUrl:e.url,fileName:e.name,fileSize:e.size,mimeType:e.type,thumbnailSizes:null===(i=e.thumbnails)||void 0===i?void 0:i.map((e=>({maxWidth:e.width,maxHeight:e.height})))}))},ue=e=>J(e)&&(t.isFile(e.file)||t.isTypeOf("string",e.fileUrl))&&t.isTypeOf("string",e.fileName,!0)&&t.isTypeOf("string",e.mimeType,!0)&&t.isTypeOf("number",e.fileSize,!0)&&(null===e.thumbnailSizes||void 0===e.thumbnailSizes||Array.isArray(e.thumbnailSizes)&&e.thumbnailSizes.every((e=>t.isTypeOf("object",e)&&e.maxWidth>0&&e.maxHeight>0))),ce={data:void 0,customType:void 0,mentionType:t.MentionType.USERS,mentionedUserIds:void 0,mentionedUsers:void 0,mentionedMessageTemplate:void 0,metaArrays:void 0,pushNotificationDeliveryOption:void 0,appleCriticalAlertOptions:void 0},he=e=>t.isTypeOf("string",e.data,!0)&&t.isTypeOf("string",e.customType,!0)&&t.isEnumOf(t.MentionType,e.mentionType)&&t.isArrayOf("string",e.mentionedUserIds,!0)&&t.isArrayOf(t.User,e.mentionedUsers,!0)&&t.isTypeOf("string",e.mentionedMessageTemplate,!0)&&t.isArrayOf(o,e.metaArrays,!0)&&t.isEnumOf(t.PushNotificationDeliveryOption,e.pushNotificationDeliveryOption,!0)&&t.isTypeOf(u,e.appleCriticalAlertOptions,!0),pe=Object.assign(Object.assign({},ce),{message:void 0,translationTargetLanguages:void 0,pollId:void 0}),me=e=>he(e)&&t.isTypeOf("string",e.message,!0)&&t.isArrayOf("string",e.translationTargetLanguages,!0)&&t.isTypeOf("number",e.pollId,!0),_e=Object.assign({},ce);class ge extends t.APIRequestCommand{constructor({channelUrl:e,channelType:s,token:i,limit:n}){super(),this.method=t.APIRequestMethod.GET,this.path=`${t.getChannelApiPathByType(s)}/${encodeURIComponent(e)}/operators`,this.params={token:i,limit:n}}}class ye extends t.APIResponseCommand{constructor(e,s){super(e,s),this.operators=s.operators.map((s=>new t.User(e,s))),this.token=s.next}}class fe extends t.ChannelDataListQuery{constructor(e,t,s,i){super(e,t,s,i)}_validate(){return super._validate()}next(){return t.__awaiter(this,void 0,void 0,(function*(){if(this._validate()){if(this._isLoading)throw t.SendbirdError.queryInProgress;{const e=[];if(this._hasNext){this._isLoading=!0;const{requestQueue:e}=t.Vault.of(this._iid),s=new ge(Object.assign(Object.assign({},this),{channelUrl:this.channelUrl,token:this._token})),i=yield e.send(s),{operators:n,token:a}=i.as(ye);return this._token=a,this._hasNext=!!a,this._isLoading=!1,n}return e}}throw t.SendbirdError.invalidParameters}))}}class ve extends t.ChannelDataListQuery{constructor(e,s,i,n){var a,r,o,l,d,u,c,h,p,m;super(e,s,i,n),this.reverse=!1,this.messageTypeFilter=t.MessageTypeFilter.ALL,this.customTypesFilter=null,this.senderUserIdsFilter=null,this.replyType=t.ReplyType.NONE,this.includeMetaArray=!1,this.includeReactions=!1,this.includeParentMessageInfo=!1,this.includeThreadInfo=!1,this.showSubchannelMessagesOnly=!1,this._edge=Number.MAX_SAFE_INTEGER,this.reverse=null!==(a=n.reverse)&&void 0!==a&&a,this.messageTypeFilter=null!==(r=n.messageTypeFilter)&&void 0!==r?r:t.MessageTypeFilter.ALL,this.customTypesFilter=null!==(o=n.customTypesFilter)&&void 0!==o?o:null,this.senderUserIdsFilter=null!==(l=n.senderUserIdsFilter)&&void 0!==l?l:null,this.replyType=null!==(d=n.replyType)&&void 0!==d?d:t.ReplyType.NONE,this.includeMetaArray=null!==(u=n.includeMetaArray)&&void 0!==u&&u,this.includeReactions=null!==(c=n.includeReactions)&&void 0!==c&&c,this.includeParentMessageInfo=null!==(h=n.includeParentMessageInfo)&&void 0!==h&&h,this.includeThreadInfo=null!==(p=n.includeThreadInfo)&&void 0!==p&&p,this.showSubchannelMessagesOnly=null!==(m=n.showSubchannelMessagesOnly)&&void 0!==m&&m}_validate(){return super._validate()&&t.isTypeOf("boolean",this.reverse)&&t.isEnumOf(t.MessageTypeFilter,this.messageTypeFilter)&&t.isEnumOf(t.ReplyType,this.replyType)&&t.isArrayOf("string",this.customTypesFilter,!0)&&t.isArrayOf("string",this.senderUserIdsFilter,!0)&&t.isTypeOf("boolean",this.includeMetaArray)&&t.isTypeOf("boolean",this.includeReactions)&&t.isTypeOf("boolean",this.includeParentMessageInfo)&&t.isTypeOf("boolean",this.includeThreadInfo)&&t.isTypeOf("boolean",this.showSubchannelMessagesOnly)}load(){return t.__awaiter(this,void 0,void 0,(function*(){if(this._validate()){if(this._isLoading)throw t.SendbirdError.queryInProgress;if(this._hasNext){this._isLoading=!0;const e=ai.of(this._iid),s=yield e.getMessagesByTimestamp(this.channelUrl,this.channelType,this._edge,t.undefineNullProps({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}));return this._edge=Math.min(Number.MAX_SAFE_INTEGER,...s.map((e=>e.createdAt))),this._hasNext=s.length>=this.limit,this._isLoading=!1,s}return[]}throw t.SendbirdError.invalidParameters}))}}class Ie extends t.APIRequestCommand{constructor(e){const{channelUrl:s,channelType:i,limit:n,token:a}=e;super(),this.method=t.APIRequestMethod.GET,this.path=`${t.getChannelApiPathByType(i)}/${encodeURIComponent(s)}/mute`,this.params={limit:n,token:a}}}class Ee extends t.APIResponseCommand{constructor(e,t){super(e,t),this.mutedUsers=[];const{next:s,muted_list:i}=t;this.token=s,i&&i.length>0&&(this.mutedUsers=i.map((t=>new H(e,t))))}}class Te extends t.ChannelDataListQuery{constructor(e,t,s,i){super(e,t,s,i)}next(){return t.__awaiter(this,void 0,void 0,(function*(){if(this._validate()){if(this._isLoading)throw t.SendbirdError.queryInProgress;if(this._hasNext){this._isLoading=!0;const{requestQueue:e}=t.Vault.of(this._iid),s=new Ie(Object.assign(Object.assign({},this),{token:this._token})),i=yield e.send(s),{mutedUsers:n,token:a}=i.as(Ee);return this._token=a,this._hasNext=!!a,this._isLoading=!1,n}return[]}throw t.SendbirdError.invalidParameters}))}}class be extends t.APIRequestCommand{constructor(e){const{channelUrl:s,channelType:i,limit:n,token:a}=e;super(),this.method=t.APIRequestMethod.GET,this.path=`${t.getChannelApiPathByType(i)}/${encodeURIComponent(s)}/ban`,this.params=t.deundefined({limit:n,token:a})}}class Se extends t.APIResponseCommand{constructor(e,t){super(e,t),this.bannedUsers=[];const{next:s,banned_list:i}=t;this.token=s,i&&i.length>0&&(this.bannedUsers=i.map((t=>new H(e,t.user))))}}class Oe extends t.ChannelDataListQuery{constructor(e,t,s,i){super(e,t,s,i)}_validate(){return super._validate()}next(){return t.__awaiter(this,void 0,void 0,(function*(){if(this._validate()){if(this._isLoading)throw t.SendbirdError.queryInProgress;if(this._hasNext){this._isLoading=!0;const{requestQueue:e}=t.Vault.of(this._iid),s=new be(Object.assign(Object.assign({},this),{token:this._token})),i=yield e.send(s),{bannedUsers:n,token:a}=i.as(Se);return this._token=a,this._hasNext=!!a,this._isLoading=!1,n}return[]}throw t.SendbirdError.invalidParameters}))}}var Me;exports.ReportCategory=void 0,(Me=exports.ReportCategory||(exports.ReportCategory={})).SPAM="spam",Me.HARASSING="harassing",Me.SUSPICIOUS="suspicious",Me.INAPPROPRIATE="inappropriate";class Ae extends t.APIRequestCommand{constructor(e){const{channelUrl:s,channelType:i,operatorUserIds:n}=e;super(),this.method=t.APIRequestMethod.POST,this.path=`${t.getChannelApiPathByType(i)}/${encodeURIComponent(s)}/operators`,this.params={operator_ids:n}}}class Ce extends t.APIRequestCommand{constructor(e){const{channelUrl:s,channelType:i,operatorUserIds:n}=e;super(),this.method=t.APIRequestMethod.DELETE,this.path=`${t.getChannelApiPathByType(i)}/${encodeURIComponent(s)}/operators`,this.params={operator_ids:n}}}class we extends t.APIRequestCommand{constructor(e){const{channelUrl:s,channelType:i,userId:n}=e;super(),this.method=t.APIRequestMethod.GET,this.path=`${t.getChannelApiPathByType(i)}/${encodeURIComponent(s)}/mute/${n}`}}class Ne extends t.APIResponseCommand{constructor(e,t){super(e,t),this.isMuted=!1,this.startAt=0,this.endAt=0;const{is_muted:s,start_at:i,end_at:n,remaining_duration:a,description:r}=t;this.isMuted=s,this.startAt=i,this.endAt=n,this.remainingDuration=a,this.description=r}}class Pe extends t.APIRequestCommand{constructor(e){const{channelUrl:s,channelType:i,keys:n}=e;super(),this.method=t.APIRequestMethod.GET,this.path=`${t.getChannelApiPathByType(i)}/${encodeURIComponent(s)}/metadata`,this.params={keys:n,include_ts:!0}}}class Ue extends t.APIResponseCommand{constructor(e,t){super(e,t);const{metadata:s,ts:i}=t;this.metadata=s,this.ts=i}}class Re extends t.APIRequestCommand{constructor(e){const{channelUrl:s,channelType:i,metadata:n}=e;super(),this.method=t.APIRequestMethod.POST,this.path=`${t.getChannelApiPathByType(i)}/${encodeURIComponent(s)}/metadata`,this.params={metadata:n,include_ts:!0}}}class xe extends t.APIResponseCommand{constructor(e,t){var s,i;super(e,t),this.metaData=null!==(s=t.metadata)&&void 0!==s?s:{},this.ts=null!==(i=t.ts)&&void 0!==i?i:null}}class Le extends t.APIRequestCommand{constructor(e){const{channelUrl:s,channelType:i,metadata:n,upsert:a}=e;super(),this.method=t.APIRequestMethod.PUT,this.path=`${t.getChannelApiPathByType(i)}/${encodeURIComponent(s)}/metadata`,this.params={metadata:n,include_ts:!0,upsert:null!=a&&a}}}class ke extends t.APIResponseCommand{constructor(e,t){super(e,t);const{metadata:s,ts:i}=t;this.metadata=s,this.ts=i}}class De extends t.WebSocketEventCommand{constructor(e,t,s){super(e,"SYEV",s),s.data&&(this.created=s.data.created,this.updated=s.data.updated,this.deleted=s.data.deleted)}}class qe extends t.APIRequestCommand{constructor(e){const{channelUrl:s,channelType:i,key:n}=e;super(),this.method=t.APIRequestMethod.DELETE,this.path=`${t.getChannelApiPathByType(i)}/${encodeURIComponent(s)}/metadata/${n}`,this.params={include_ts:!0}}}class Fe extends t.APIResponseCommand{constructor(e,t){super(e,t);const{ts:s}=t;this.ts=s}}class Be extends t.APIRequestCommand{constructor(e){const{channelUrl:s,channelType:i}=e;super(),this.method=t.APIRequestMethod.DELETE,this.path=`${t.getChannelApiPathByType(i)}/${encodeURIComponent(s)}/metadata`,this.params={include_ts:!0}}}class je extends t.APIResponseCommand{constructor(e,t){super(e,t);const{ts:s}=t;this.ts=s}}class ze extends t.APIRequestCommand{constructor(e){const{channelUrl:s,channelType:i,keys:n}=e;super(),this.method=t.APIRequestMethod.GET,this.path=`${t.getChannelApiPathByType(i)}/${encodeURIComponent(s)}/metacounter`,this.params={keys:n}}}class Ve extends t.APIResponseCommand{constructor(e,t){super(e,t),this.metaCounter=t}}class $e extends t.APIRequestCommand{constructor(e){const{channelUrl:s,channelType:i,metaCounter:n}=e;super(),this.method=t.APIRequestMethod.POST,this.path=`${t.getChannelApiPathByType(i)}/${encodeURIComponent(s)}/metacounter`,this.params={metacounter:n}}}class Qe extends t.APIResponseCommand{constructor(e,t){super(e,t),this.metaCounter=t}}class Ke extends t.APIRequestCommand{constructor(e){const{channelUrl:s,channelType:i,metaCounter:n,upsert:a=!1,mode:r="set"}=e;super(),this.method=t.APIRequestMethod.PUT,this.path=`${t.getChannelApiPathByType(i)}/${encodeURIComponent(s)}/metacounter`,this.params={metacounter:n,upsert:a,mode:r}}}class Ge extends t.APIResponseCommand{constructor(e,t){super(e,t),this.metaCounter=t}}class He extends t.WebSocketEventCommand{constructor(e,t,s){super(e,"SYEV",s),s.data&&(this.created=s.data.created,this.updated=s.data.updated,this.deleted=s.data.deleted)}}class We extends t.APIRequestCommand{constructor(e){const{channelUrl:s,channelType:i,key:n}=e;super(),this.method=t.APIRequestMethod.DELETE,this.path=`${t.getChannelApiPathByType(i)}/${encodeURIComponent(s)}/metacounter/${n}`,this.params={}}}class Ye extends t.APIRequestCommand{constructor(e){const{channelUrl:s,channelType:i}=e;super(),this.method=t.APIRequestMethod.DELETE,this.path=`${t.getChannelApiPathByType(i)}/${encodeURIComponent(s)}/metacounter`,this.params={}}}class Je extends t.APIRequestCommand{constructor(e){const{channelUrl:s,channelType:i,userId:n,seconds:a,description:r}=e;super(),this.method=t.APIRequestMethod.POST,this.path=`${t.getChannelApiPathByType(i)}/${encodeURIComponent(s)}/mute`,this.params={user_id:n,seconds:a,description:r}}}class Xe extends t.WebSocketEventCommand{constructor(e,t,s){super(e,"SYEV",s),this.user=new H(e,s.data)}}class Ze extends t.APIRequestCommand{constructor(e){const{channelUrl:s,channelType:i,userId:n}=e;super(),this.method=t.APIRequestMethod.DELETE,this.path=`${t.getChannelApiPathByType(i)}/${encodeURIComponent(s)}/mute/${encodeURIComponent(n)}`}}class et extends t.WebSocketEventCommand{constructor(e,t,s){super(e,"SYEV",s),this.user=new H(e,s.data)}}class tt extends t.APIRequestCommand{constructor(e){const{channelUrl:s,channelType:i,userId:n,seconds:a,description:r}=e;super(),this.method=t.APIRequestMethod.POST,this.path=`${t.getChannelApiPathByType(i)}/${encodeURIComponent(s)}/ban`,this.params=t.deundefined({user_id:n,seconds:a,description:r})}}class st extends t.WebSocketEventCommand{constructor(e,t,s){super(e,"SYEV",s),this.user=new H(e,s.data),s.data.member_count&&(this.memberCount=s.data.member_count),s.data.joined_member_count&&(this.joinedMemberCount=s.data.joined_member_count)}}class it extends t.APIRequestCommand{constructor(e){const{channelUrl:s,channelType:i,userId:n}=e;super(),this.method=t.APIRequestMethod.DELETE,this.path=`${t.getChannelApiPathByType(i)}/${encodeURIComponent(s)}/ban/${encodeURIComponent(n)}`}}class nt extends t.WebSocketEventCommand{constructor(e,t,s){super(e,"SYEV",s),this.user=new H(e,s.data)}}class at extends t.APIRequestCommand{constructor(e){const{channelUrl:s,channelType:i,freezing:n}=e;super(),this.method=t.APIRequestMethod.PUT,this.path=`${t.getChannelApiPathByType(i)}/${encodeURIComponent(s)}/freeze`,this.params={freeze:n}}}class rt extends t.WebSocketEventCommand{constructor(e,t,s){super(e,"SYEV",s),this.freeze=s.data.freeze}}class ot extends t.APIRequestCommand{constructor(e){const{channelUrl:s,channelType:i,category:n,userId:a,description:r}=e;super(),this.method=t.APIRequestMethod.POST,this.path=`${t.getReportApiPathByType(i)}/${encodeURIComponent(s)}`,this.params={report_category:n,reporting_user_id:a,report_description:r}}}class lt extends t.APIRequestCommand{constructor(e){const{channelUrl:s,channelType:i,category:n,userId:a,offendingUserId:r,description:o}=e;super(),this.method=t.APIRequestMethod.POST,this.path=`${t.API_PATH_REPORT}/users/${r}`,this.params={channel_url:s,channel_type:i===t.ChannelType.OPEN?"open_channels":"group_channels",report_category:n,reporting_user_id:a,report_description:o}}}class dt extends t.APIRequestCommand{constructor(e){const{channelUrl:s,channelType:i,category:n,userId:a,offendingUserId:r,messageId:o,description:l}=e;super(),this.method=t.APIRequestMethod.POST,this.path=`${t.getReportApiPathByType(i)}/${encodeURIComponent(s)}/messages/${o}`,this.params={report_category:n,reporting_user_id:a,report_description:l,offending_user_id:r}}}class ut extends t.WebSocketRequestCommand{constructor(e){let s=[];e.mentionType===t.MentionType.USERS&&(e.mentionedUserIds?s=e.mentionedUserIds:e.mentionedUsers&&(s=e.mentionedUsers.map((e=>e.userId)))),super({code:"MESG",ackRequired:!0,payload:t.deundefined(t.undefineNullProps({channel_url:e.channelUrl,message:e.message,data:e.data,custom_type:e.customType,metaarray:e.metaArrays,mention_type:e.mentionType,mentioned_user_ids:s,mentioned_message_template:e.mentionedMessageTemplate,target_langs:e.translationTargetLanguages,push_option:e.pushNotificationDeliveryOption&&e.pushNotificationDeliveryOption!==t.PushNotificationDeliveryOption.DEFAULT?e.pushNotificationDeliveryOption:void 0,apple_critical_alert_options:e.appleCriticalAlertOptions,silent:e.silent,reply_to_channel:e.isReplyToChannel,parent_message_id:e.parentMessageId?e.parentMessageId:null,req_id:e.reqId,poll_id:e.pollId,pin_message:e.isPinnedMessage}))})}}class ct extends t.WebSocketEventCommand{constructor(e,s,i){var n,a,r,o;super(e,"MESG",i),this.message=new T(e,i);const{sdkState:l}=t.Vault.of(e);this.isMentioned=t.checkIfMentioned(this.message.mentionType,null!==(r=null!==(n=this.message.mentionedUserIds)&&void 0!==n?n:null===(a=this.message.mentionedUsers)||void 0===a?void 0:a.map((e=>e.userId)))&&void 0!==r?r:[],l.userId),this.forceUpdateLastMessage=null!==(o=i.force_update_last_message)&&void 0!==o&&o}}class ht extends t.WebSocketRequestCommand{constructor(e){let s=null;e.mentionType===t.MentionType.USERS&&(e.mentionedUserIds?s=e.mentionedUserIds:e.mentionedUsers&&(s=e.mentionedUsers.map((e=>e.userId)))),super({code:"MEDI",ackRequired:!0,payload:t.deundefined(t.undefineNullProps({channel_url:e.channelUrl,msg_id:e.messageId,message:e.message,data:e.data,custom_type:e.customType,metaarray:e.metaArrayParams,mention_type:e.mentionType,mentioned_user_ids:s,mentioned_message_template:e.mentionedMessageTemplate,apple_critical_alert_options:e.appleCriticalAlertOptions?u.payloadify(e.appleCriticalAlertOptions):null,poll_id:e.pollId}))})}}class pt extends t.WebSocketEventCommand{constructor(e,s,i){var n,a,r,o,l;super(e,"MEDI",i),this.message=new T(e,i);const{sdkState:d}=t.Vault.of(e);this.mentionCountChange=t.calculateMentionCountChange({mentionType:null===(n=i.old_values)||void 0===n?void 0:n.mention_type,mentionedUserIds:null!==(r=null===(a=i.old_values)||void 0===a?void 0:a.mentioned_user_ids)&&void 0!==r?r:[]},t.undefineNullProps({mentionType:this.message.mentionType,mentionedUserIds:null!==(o=this.message.mentionedUserIds)&&void 0!==o?o:null===(l=this.message.mentionedUsers)||void 0===l?void 0:l.map((e=>e.userId))}),d.userId)}}class mt extends t.WebSocketRequestCommand{constructor(e){let s=null;e.mentionType===t.MentionType.USERS&&(e.mentionedUserIds?s=e.mentionedUserIds:e.mentionedUsers&&(s=e.mentionedUsers.map((e=>e.userId)))),super({code:"FEDI",ackRequired:!0,payload:t.deundefined(t.undefineNullProps({channel_url:e.channelUrl,msg_id:e.messageId,data:e.data,custom_type:e.customType,metaarray:e.metaArrayParams,mention_type:e.mentionType,mentioned_user_ids:s,apple_critical_alert_options:e.appleCriticalAlertOptions}))})}}class _t extends t.WebSocketEventCommand{constructor(e,s,i){var n,a,r,o,l;super(e,"FEDI",i),this.message=new M(e,i);const{sdkState:d}=t.Vault.of(e);this.mentionCountChange=t.calculateMentionCountChange({mentionType:null===(n=i.old_values)||void 0===n?void 0:n.mention_type,mentionedUserIds:null!==(r=null===(a=i.old_values)||void 0===a?void 0:a.mentioned_user_ids)&&void 0!==r?r:[]},t.undefineNullProps({mentionType:this.message.mentionType,mentionedUserIds:null!==(o=this.message.mentionedUserIds)&&void 0!==o?o:null===(l=this.message.mentionedUsers)||void 0===l?void 0:l.map((e=>e.userId))}),d.userId)}}class gt extends t.APIRequestCommand{constructor(e){super(),this.method=t.APIRequestMethod.DELETE,this.path=`${t.getChannelApiPathByType(e.channelType)}/${e.channelUrl}/messages/${e.messageId}`}}class yt extends t.WebSocketEventCommand{constructor(e,t,s){super(e,"DELM",s),this.channelUrl=s.channel_url,this.channelType=s.channel_type,this.messageId=Number(s.msg_id)}}class ft extends t.APIRequestCommand{constructor({channelType:e,channelUrl:s,messageId:i,reactionKey:n}){super(),this.method=t.APIRequestMethod.POST,this.path=`${t.getChannelApiPathByType(e)}/${encodeURIComponent(s)}/messages/${i}/reactions`,this.params={reaction:n}}}class vt extends t.APIResponseCommand{constructor(e,t){super(e,t),this.reactionEvent=new a(t)}}class It extends t.APIRequestCommand{constructor({channelType:e,channelUrl:s,messageId:i,reactionKey:n}){super(),this.method=t.APIRequestMethod.DELETE,this.path=`${t.getChannelApiPathByType(e)}/${encodeURIComponent(s)}/messages/${i}/reactions`,this.params={reaction:n}}}class Et extends t.APIResponseCommand{constructor(e,t){super(e,t),this.reactionEvent=new a(Object.assign({},t))}}class Tt extends t.APIRequestCommand{constructor({channelType:e,channelUrl:s,messageId:i,translationTargetLanguages:n}){super(),this.method=t.APIRequestMethod.POST,this.path=`${t.getChannelApiPathByType(e)}/${encodeURIComponent(s)}/messages/${encodeURIComponent(i)}/translation`,this.params={target_langs:n}}}class bt extends t.APIResponseCommand{constructor(e,t){super(e,t),this.message=new T(e,t)}}class St extends t.APIRequestCommand{constructor(e){var s;super();let i=[];e.mentionType===t.MentionType.USERS&&(e.mentionedUserIds?i=e.mentionedUserIds:e.mentionedUsers&&(i=e.mentionedUsers.map((e=>e.userId))));const{channelType:n,channelUrl:a}=e;this.method=t.APIRequestMethod.POST,this.path=`${t.getChannelApiPathByType(n)}/${encodeURIComponent(a)}/scheduled_messages`,this.params=t.deundefined(t.undefineNullProps({req_id:e.reqId,scheduled_at:e.scheduledAt,message_type:t.ServerSideMessageType.USER,message:e.message,custom_type:e.customType,data:e.data,mention_type:e.mentionType,mentioned_user_ids:i,sorted_metaarray:null===(s=e.metaArrays)||void 0===s?void 0:s.map((e=>o.payloadify(e))),apple_critical_alert_options:e.appleCriticalAlertOptions?u.payloadify(e.appleCriticalAlertOptions):null,target_langs:e.translationTargetLanguages,push_option:e.pushNotificationDeliveryOption}))}}class Ot extends t.APIResponseCommand{constructor(e,t){super(e,t),this.message=new T(e,t)}}class Mt extends t.APIRequestCommand{constructor(e){var s;super();let i=[];e.mentionType===t.MentionType.USERS&&(e.mentionedUserIds?i=e.mentionedUserIds:e.mentionedUsers&&(i=e.mentionedUsers.map((e=>e.userId))));const{channelType:n,channelUrl:a}=e;this.method=t.APIRequestMethod.POST,this.path=`${t.getChannelApiPathByType(n)}/${encodeURIComponent(a)}/scheduled_messages`,this.params=t.undefineNullProps({req_id:e.reqId,scheduled_at:e.scheduledAt,message_type:t.ServerSideMessageType.FILE,url:e.fileUrl,file_name:e.fileName,file_size:e.fileSize,file_type:e.mimeType,thumbnails:e.thumbnailSizes?e.thumbnailSizes.map((e=>y.payloadify(e))):[],custom_type:e.customType,data:e.data,require_auth:e.requireAuth,mention_type:e.mentionType,mentioned_user_ids:i,sorted_metaarray:null===(s=e.metaArrays)||void 0===s?void 0:s.map((e=>o.payloadify(e))),apple_critical_alert_options:e.appleCriticalAlertOptions?u.payloadify(e.appleCriticalAlertOptions):null,push_option:e.pushNotificationDeliveryOption})}}class At extends t.APIResponseCommand{constructor(e,t){super(e,t),this.message=new M(e,t)}}class Ct extends t.APIRequestCommand{constructor({pollId:e,title:s,data:i,allowUserSuggestion:n,allowMultipleVotes:a,closeAt:r}){super(),this.method=t.APIRequestMethod.PUT,this.path=`${t.API_PATH_POLLS}/${encodeURIComponent(e)}`,this.params={title:s,data:i,allow_user_suggestion:n,allow_multiple_votes:a,close_at:r}}}class wt extends t.APIResponseCommand{constructor(e,s){super(e,s),this.poll=new t.Poll(e,s)}}class Nt extends t.APIRequestCommand{constructor({pollId:e}){super(),this.method=t.APIRequestMethod.DELETE,this.path=`${t.API_PATH_POLLS}/${encodeURIComponent(e)}`}}class Pt extends t.APIRequestCommand{constructor({pollId:e}){super(),this.method=t.APIRequestMethod.PUT,this.path=`${t.API_PATH_POLLS}/${encodeURIComponent(e)}/close`}}class Ut extends t.APIResponseCommand{constructor(e,s){super(e,s),this.poll=new t.Poll(e,s)}}class Rt extends t.APIRequestCommand{constructor({channelUrl:e,channelType:s,pollId:i,optionText:n}){super(),this.method=t.APIRequestMethod.POST,this.path=`${t.API_PATH_POLLS}/${encodeURIComponent(i)}/options`,this.params={channel_url:e,channel_type:s,text:n}}}class xt extends t.APIResponseCommand{constructor(e,s){super(e,s),this.poll=new t.Poll(e,s)}}class Lt extends t.APIRequestCommand{constructor({pollId:e,pollOptionId:s,optionText:i}){super(),this.method=t.APIRequestMethod.PUT,this.path=`${t.API_PATH_POLLS}/${encodeURIComponent(e)}/options/${encodeURIComponent(s)}`,this.params={text:i}}}class kt extends t.APIResponseCommand{constructor(e,s){super(e,s),this.poll=new t.Poll(e,s)}}class Dt extends t.APIRequestCommand{constructor({pollId:e,pollOptionId:s}){super(),this.method=t.APIRequestMethod.DELETE,this.path=`${t.API_PATH_POLLS}/${encodeURIComponent(e)}/options/${encodeURIComponent(s)}`}}class qt extends t.WebSocketRequestCommand{constructor({reqId:e,channelType:s,channelUrl:i,pollId:n,pollOptionIds:a}){super({code:"VOTE",ackRequired:!0,payload:t.deundefined({req_id:e,channel_type:s===t.ChannelType.OPEN?"open_channels":"group_channels",channel_url:i,poll_id:n,option_ids:a})})}}class Ft extends t.WebSocketEventCommand{constructor(e,s,i){super(e,"VOTE",i),this.event=new t.PollVoteEvent(i),this.channelUrl=i.channel_url,this.channelType=i.channel_type}}const Bt="Message";const jt=Object.assign(Object.assign({},Y),{fileInfoList:[]}),zt=e=>(t.isFile(e.file)||t.isTypeOf("string",e.fileUrl))&&t.isTypeOf("string",e.fileName,!0)&&t.isTypeOf("string",e.mimeType,!0)&&t.isTypeOf("number",e.fileSize,!0)&&(void 0===e.thumbnailSizes||Array.isArray(e.thumbnailSizes)&&e.thumbnailSizes.every((e=>e.maxWidth>0&&e.maxHeight>0)));class Vt extends W{constructor(){super(...arguments),this._onFileUploaded=t.noop}_triggerOnFileUploaded(e,t,s,i){this._onFileUploaded(e,t,s,i)}onFileUploaded(e){return this._onFileUploaded=e,this}onPending(e){return super.onPending(e),this}onFailed(e){return super.onFailed(e),this}onSucceeded(e){return super.onSucceeded(e),this}}var $t;exports.SendMessageRequestType=void 0,($t=exports.SendMessageRequestType||(exports.SendMessageRequestType={})).SEND="send",$t.RESEND="resend",$t.COPY="copy";class Qt extends t.InstancedObject{get url(){return this._url}get name(){return this._name}set name(e){this._name=e}get createdAt(){return this._createdAt}toJSON(){return Object.assign(Object.assign({},this),{url:this._url,name:this._name,createdAt:this._createdAt})}constructor(e,s){var i,n,a,r,o,l;super(e),this._name="",this._createdAt=0,this.channelType=t.ChannelType.BASE,this.coverUrl="",this.customType="",this.data="",this.isFrozen=!1,this.isEphemeral=!1,this.creator=null,this._messageCollectionLastAccessedAt=0,this._url=s.channel_url,this._name=null!==(i=s.name)&&void 0!==i?i:"",this._createdAt=1e3*s.created_at,this.coverUrl=null!==(n=s.cover_url)&&void 0!==n?n:"",this.customType=null!==(a=s.custom_type)&&void 0!==a?a:"",this.data=null!==(r=s.data)&&void 0!==r?r:"",this.isFrozen=null!==(o=s.freeze)&&void 0!==o&&o,this.isEphemeral=null!==(l=s.is_ephemeral)&&void 0!==l&&l,this.creator=s.created_by?new t.User(this._iid,s.created_by):null,s.metadata&&Object.keys(s.metadata).length>0&&s.ts&&(this._cachedMetaData=new Map,Object.keys(s.metadata).forEach((e=>{this._cachedMetaData.set(e,{value:s.metadata[e],isRemoved:!1,updatedAt:s.ts})})))}static payloadify(e){return t.deundefined(t.undefineNullProps(Object.assign(Object.assign({},super.payloadify(e)),{channel_url:e.url,name:e.name,cover_url:e.coverUrl,custom_type:e.customType,data:e.data,freeze:e.isFrozen,is_ephemeral:e.isEphemeral,created_by:e.creator?t.User.payloadify(e.creator):null,created_at:e.createdAt/1e3})))}isGroupChannel(){return this.channelType===t.ChannelType.GROUP}isOpenChannel(){return this.channelType===t.ChannelType.OPEN}isFeedChannel(){return this.channelType===t.ChannelType.FEED}get cachedMetaData(){const e={};return this._cachedMetaData?(this._cachedMetaData.forEach(((t,s)=>{t.isRemoved||(e[s]=t.value)})),e):e}get messageCollectionLastAccessedAt(){return this._messageCollectionLastAccessedAt}_updateMessageCollectionLastAccessedAt(){this._messageCollectionLastAccessedAt=Date.now()}_update(e){const s=t.deundefined(e);Object.assign(this,s)}_upsertCachedMetaData(e,t){Object.keys(e).forEach((s=>{this._cachedMetaData||(this._cachedMetaData=new Map);const i=this._cachedMetaData.get(s);(!i||i.updatedAt<=t)&&this._cachedMetaData.set(s,{value:e[s],isRemoved:!1,updatedAt:t})}))}_updateCachedMetaData(e,t){this._cachedMetaData?this._cachedMetaData.forEach(((s,i)=>{var n;s.updatedAt<=t&&this._cachedMetaData.set(i,{value:null!==(n=e[i])&&void 0!==n?n:s.value,isRemoved:!e[i],updatedAt:t})})):(this._cachedMetaData=new Map,Object.keys(e).forEach((s=>{this._cachedMetaData.set(s,{value:e[s],isRemoved:!1,updatedAt:t})})))}_removeFromCachedMetaData(e,t){this._cachedMetaData&&e.forEach((e=>{const s=this._cachedMetaData.get(e);s&&s.updatedAto.payloadify(e))):null,apple_critical_alert_options:e.appleCriticalAlertOptions?u.payloadify(e.appleCriticalAlertOptions):null,created_at:i,user:a.currentUser?c.payloadify(a.currentUser):null,req_id:s,request_state:t.SendingStatus.PENDING,mentioned_user_ids:e.mentionedUserIds,mentioned_users:null===(n=e.mentionedUsers)||void 0===n?void 0:n.map((e=>t.User.payloadify(e)))}))}_createPendingUserMessage(e,s,i){const n={};if(e.translationTargetLanguages)for(const t of e.translationTargetLanguages)n[t]="";const a=t.deundefined(Object.assign(Object.assign({},this._createPendingSendableMessagePayload(e,s,i)),{type:t.MessageType.USER,message:e.message,translations:n})),r=new T(this._iid,a);return r.messageParams=e,r}_createPendingScheduledUserMessage(e,t,s){const i=this._createPendingUserMessage(e,t,s);return i.scheduledInfo={scheduledMessageId:0,scheduledAt:e.scheduledAt,scheduledMessageParams:e},i}_createPendingFileMessage(e,s,i){var n,a,r,o,l,d;const u=t.deundefined(Object.assign(Object.assign({},this._createPendingSendableMessagePayload(e,s,i)),{type:t.MessageType.FILE,url:e.fileUrl,file:{name:null!==(n=e.fileName)&&void 0!==n?n:null===(a=e.file)||void 0===a?void 0:a.name,size:null!==(r=e.fileSize)&&void 0!==r?r:null===(o=e.file)||void 0===o?void 0:o.size,type:null!==(l=e.mimeType)&&void 0!==l?l:null===(d=e.file)||void 0===d?void 0:d.type,data:e.data},thumbnails:e.thumbnailSizes?e.thumbnailSizes.map((e=>({url:"",width:e.maxWidth,height:e.maxHeight}))):[]})),c=new M(this._iid,u);return c.messageParams=e,c}_createPendingMultipleFilesMessage(e,s,i){const n=t.deundefined(Object.assign(Object.assign({},this._createPendingSendableMessagePayload(e,s,i)),{type:t.MessageType.FILE})),a=new S(this._iid,n);return a.messageParams=e,a}_validateFailedFileMessageHasFile(e,s){var i;return Boolean(e.url)||t.isFile(s)||t.isFile(null===(i=e.messageParams)||void 0===i?void 0:i.file)}_createPendingScheduledFileMessage(e,t,s){const i=this._createPendingFileMessage(e,t,s);return i.scheduledInfo={scheduledMessageId:0,scheduledAt:e.scheduledAt,scheduledMessageParams:e},i}_markMessageAsFailed(e,s,i=!1){e.errorCode=s.code,s.code===t.SendbirdErrorCode.REQUEST_CANCELED||s.code===t.SendbirdErrorCode.FILE_UPLOAD_CANCEL_FAILED?e.sendingStatus=t.SendingStatus.CANCELED:i||(e.sendingStatus=t.SendingStatus.FAILED)}sendUserMessage(e){const s=Object.assign(Object.assign({},Z),e);return t.unless(se(s)).throw(t.SendbirdError.invalidParameters),this._sendUserMessage(s)}_sendUserMessage(e,s=exports.SendMessageRequestType.SEND,i){const{dispatcher:n,requestQueue:a}=t.Vault.of(this._iid),r=null!=i?i:this._generateRequestId(),o=Date.now(),l=new W;return t.sleep(2).then((()=>{const i=this._createPendingUserMessage(e,r,o);n.dispatch(new t.MessageUpdateEventCommand({messages:[i],source:s===exports.SendMessageRequestType.RESEND?t.CollectionEventSource.LOCAL_MESSAGE_RESEND_STARTED:t.CollectionEventSource.EVENT_MESSAGE_SENT_PENDING})),t.runAsCallback((()=>t.__awaiter(this,void 0,void 0,(function*(){return l._trigger(i)}))));const d=new ut(Object.assign(Object.assign({},e),{channelUrl:this.url,channelType:this.channelType,reqId:r}));a.send(d).then((e=>{const{message:s}=e.as(ct);n.dispatch(new t.MessageUpdateEventCommand({messages:[s],source:t.CollectionEventSource.EVENT_MESSAGE_SENT_SUCCESS})),t.runAsCallback((()=>t.__awaiter(this,void 0,void 0,(function*(){return l._trigger(s)}))))})).catch((s=>{if(t.isThrowingOutside(s))throw s;t.sleep(2).then((()=>{const i=this._createPendingUserMessage(e,r,o),{cacheContext:a}=t.Vault.of(this._iid),d=a.localCacheEnabled&&a.localCacheConfig.enableAutoResend&&t.isAutoResendableError(s.code);this._markMessageAsFailed(i,s,d),n.dispatch(new t.MessageUpdateEventCommand({messages:[i],source:i.sendingStatus===t.SendingStatus.PENDING?t.CollectionEventSource.REQUEST_RESEND_MESSAGE:t.CollectionEventSource.EVENT_MESSAGE_SENT_FAILED})),t.runAsCallback((()=>t.__awaiter(this,void 0,void 0,(function*(){return l._triggerFailed(s,i)}))))}))}))})),l}_autoResendUserMessage(e){return t.unless(e instanceof T&&!!e.messageParams).throw(t.SendbirdError.invalidParameters),this._sendUserMessage(e.messageParams,exports.SendMessageRequestType.SEND,e.reqId)}resendUserMessage(e){var s;return t.__awaiter(this,void 0,void 0,(function*(){t.unless(e instanceof T&&!e.scheduledInfo).throw(t.SendbirdError.invalidParameters);const i=new t.Deferred,n=null!==(s=e.messageParams)&&void 0!==s?s:te(e);return this._sendUserMessage(n,exports.SendMessageRequestType.RESEND,e.reqId).onFailed((e=>i.reject(e))).onSucceeded((e=>i.resolve(e))),i.promise}))}updateUserMessage(e,s){return t.__awaiter(this,void 0,void 0,(function*(){const i=Object.assign(Object.assign({},pe),s);t.unless(t.isTypeOf("number",e)&&me(i)).throw(t.SendbirdError.invalidParameters);const{requestQueue:n}=t.Vault.of(this._iid),a=new ht(Object.assign({channelType:this.channelType,channelUrl:this.url,messageId:e},i)),r=yield n.send(a),{message:o}=r.as(pt);return o}))}copyUserMessage(e,s){var i,n,a;return t.__awaiter(this,void 0,void 0,(function*(){t.unless(e instanceof Qt&&s instanceof T&&s.sendingStatus===t.SendingStatus.SUCCEEDED&&this.url===s.channelUrl&&!s.scheduledInfo).throw(t.SendbirdError.invalidParameters),t.unless(!s.poll).throw(t.SendbirdError.notSupportedError);const r=new t.Deferred,o=null!==(i=s.messageParams)&&void 0!==i?i:t.undefineNullProps(Object.assign(Object.assign({},s),{mentionType:s.mentionType,mentionedUserIds:null!==(n=s.mentionedUserIds)&&void 0!==n?n:null===(a=s.mentionedUsers)||void 0===a?void 0:a.map((e=>e.userId)),translationTargetLanguages:Object.keys(s.translations),pushNotificationDeliveryOption:t.PushNotificationDeliveryOption.DEFAULT,parentMessageId:null,isReplyToChannel:!1,isPinnedMessage:!1}));return e._sendUserMessage(o).onSucceeded((e=>{r.resolve(e)})).onFailed((e=>r.reject(e))),r.promise}))}translateUserMessage(e,s){return t.__awaiter(this,void 0,void 0,(function*(){t.unless(e instanceof T&&e.messageId>0&&t.isArrayOf("string",s)).throw(t.SendbirdError.invalidParameters);const{requestQueue:i}=t.Vault.of(this._iid),n=new Tt({channelType:this.channelType,channelUrl:this.url,messageId:e.messageId,translationTargetLanguages:s}),a=yield i.send(n),{message:r}=a.as(bt);return r}))}_createScheduledUserMessage(e,s){const{requestQueue:i}=t.Vault.of(this._iid),n=Date.now(),a=this._generateRequestId();t.sleep(2).then((()=>{const i=this._createPendingScheduledUserMessage(e,a,n);t.runAsCallback((()=>t.__awaiter(this,void 0,void 0,(function*(){return s._trigger(i)}))))}));const r=new St(Object.assign({reqId:a,channelType:this.channelType,channelUrl:this.url},e));i.send(r).then((e=>{const{message:i}=e.as(Ot);t.runAsCallback((()=>t.__awaiter(this,void 0,void 0,(function*(){return s._trigger(i)}))))})).catch((i=>{if(t.isThrowingOutside(i))throw i;t.sleep(2).then((()=>{const r=this._createPendingScheduledUserMessage(e,a,n);this._markMessageAsFailed(r,i),t.runAsCallback((()=>t.__awaiter(this,void 0,void 0,(function*(){return s._trigger(r)}))))}))}))}sendFileMessage(e){const s=Object.assign(Object.assign({},oe),e);return t.unless(ue(s)).throw(t.SendbirdError.invalidParameters),this._sendFileMessage(s)}sendMultipleFilesMessage(e){var s;const i=Object.assign(Object.assign({},jt),e),n=t.Vault.of(this._iid);t.unless(((e,s=t.DEFAULT_MULTIPLE_FILES_MESSAGE_FILE_COUNT_LIMIT)=>J(e)&&Array.isArray(e.fileInfoList)&&e.fileInfoList.length>=2&&e.fileInfoList.length<=s&&e.fileInfoList.every((e=>zt(e))))(i,null===(s=n.appInfo)||void 0===s?void 0:s.multipleFilesMessageFileCountLimit)).throw(t.SendbirdError.invalidParameters);const a=!!e.fileInfoList.find((e=>{const t=n.appInfo.uploadSizeLimit;return e.file instanceof Blob&&e.file.size>t||e.fileSize>t}));return t.unless(!a).throw(t.SendbirdError.fileSizeLimitExceededError),this._sendMultipleFilesMessage(i)}_sendFileMessage(e,s=exports.SendMessageRequestType.SEND,i){const{dispatcher:n}=t.Vault.of(this._iid),{fileMessageQueue:a}=ai.of(this._iid),r=null!=i?i:this._generateRequestId(),o=Date.now(),l=new W;return t.sleep(2).then((()=>{const i=this._createPendingFileMessage(e,r,o);n.dispatch(new t.MessageUpdateEventCommand({messages:[i],source:s===exports.SendMessageRequestType.RESEND?t.CollectionEventSource.LOCAL_MESSAGE_RESEND_STARTED:t.CollectionEventSource.EVENT_MESSAGE_SENT_PENDING})),t.runAsCallback((()=>t.__awaiter(this,void 0,void 0,(function*(){return l._trigger(i)})))),a.request(this,r,e).then((e=>{n.dispatch(new t.MessageUpdateEventCommand({messages:[e],source:t.CollectionEventSource.EVENT_MESSAGE_SENT_SUCCESS})),t.runAsCallback((()=>t.__awaiter(this,void 0,void 0,(function*(){return l._trigger(e)}))))})).catch((s=>{if(t.isThrowingOutside(s))throw s;t.sleep(2).then((()=>{const i=this._createPendingFileMessage(e,r,o),{cacheContext:a}=t.Vault.of(this._iid),d=a.localCacheEnabled&&a.localCacheConfig.enableAutoResend&&t.isAutoResendableError(s.code);this._markMessageAsFailed(i,s,d),n.dispatch(new t.MessageUpdateEventCommand({messages:[i],source:i.sendingStatus===t.SendingStatus.PENDING?t.CollectionEventSource.REQUEST_RESEND_MESSAGE:s.code===t.SendbirdErrorCode.FILE_UPLOAD_CANCEL_FAILED?t.CollectionEventSource.LOCAL_MESSAGE_CANCELED:t.CollectionEventSource.EVENT_MESSAGE_SENT_FAILED})),t.runAsCallback((()=>t.__awaiter(this,void 0,void 0,(function*(){return l._triggerFailed(s,i)}))))}))}))})),l}_autoResendFileMessage(e){t.unless(e instanceof M&&!!e.messageParams).throw(t.SendbirdError.invalidParameters);const{logger:s}=t.Vault.of(this._iid);return s.debug("autoResendFileMessage pending",e),this._sendFileMessage(e.messageParams,exports.SendMessageRequestType.SEND,e.reqId).onFailed((e=>{s.debug("autoResendFileMessage failed",e)})).onSucceeded((e=>{s.debug("autoResendFileMessage success",e)}))}_sendMultipleFilesMessage(e,s,i){const{dispatcher:n}=t.Vault.of(this._iid),{fileMessageQueue:a}=ai.of(this._iid),r=null!=i?i:this._generateRequestId(),o=Date.now(),l=new Vt;return t.sleep(2).then((()=>{const i=this._createPendingMultipleFilesMessage(e,r,o);n.dispatch(new t.MessageUpdateEventCommand({messages:[i],source:s===exports.SendMessageRequestType.RESEND?t.CollectionEventSource.LOCAL_MESSAGE_RESEND_STARTED:t.CollectionEventSource.EVENT_MESSAGE_SENT_PENDING})),t.runAsCallback((()=>t.__awaiter(this,void 0,void 0,(function*(){return l._trigger(i)})))),a.request(this,r,e,{requestHandler:l,isCopy:s===exports.SendMessageRequestType.COPY}).then((e=>{n.dispatch(new t.MessageUpdateEventCommand({messages:[e],source:t.CollectionEventSource.EVENT_MESSAGE_SENT_SUCCESS})),t.runAsCallback((()=>t.__awaiter(this,void 0,void 0,(function*(){return l._trigger(e)}))))})).catch((s=>{if(t.isThrowingOutside(s))throw s;t.sleep(2).then((()=>{const i=this._createPendingMultipleFilesMessage(e,r,o);this._markMessageAsFailed(i,s),n.dispatch(new t.MessageUpdateEventCommand({messages:[i],source:t.CollectionEventSource.EVENT_MESSAGE_SENT_FAILED})),t.runAsCallback((()=>t.__awaiter(this,void 0,void 0,(function*(){return l._triggerFailed(s,i)}))))}))}))})),l}_createScheduledFileMessage(e,s,i,n){const{requestQueue:a}=t.Vault.of(this._iid),r=new Mt(Object.assign(Object.assign({reqId:i,channelType:this.channelType,channelUrl:this.url},e),{fileUrl:e.fileUrl,requireAuth:e.requireAuth}));a.send(r).then((e=>{const{message:i}=e.as(At);t.runAsCallback((()=>t.__awaiter(this,void 0,void 0,(function*(){return s._trigger(i)}))))})).catch((a=>{if(t.isThrowingOutside(a))throw a;t.sleep(2).then((()=>{const r=this._createPendingScheduledFileMessage(e,i,n);this._markMessageAsFailed(r,a),t.runAsCallback((()=>t.__awaiter(this,void 0,void 0,(function*(){return s._triggerFailed(a,r)}))))}))}))}sendFileMessages(e){t.unless(e.every((e=>ue(Object.assign(Object.assign({},oe),e))))).throw(t.SendbirdError.invalidParameters);const s=new W;for(const t of e)this.sendFileMessage(t).onPending((e=>s._trigger(e))).onFailed(((e,t)=>s._triggerFailed(e,t))).onSucceeded((e=>s._trigger(e)));return s}resendFileMessage(e,s){return t.__awaiter(this,void 0,void 0,(function*(){const i=this._validateFailedFileMessageHasFile(e,s);t.unless(e instanceof M&&i&&!e.scheduledInfo).throw(t.SendbirdError.invalidParameters);const n=new t.Deferred,a=de(e,s);return this._sendFileMessage(a,exports.SendMessageRequestType.RESEND,e.reqId).onFailed((e=>n.reject(e))).onSucceeded((e=>n.resolve(e))),n.promise}))}resendMessage(e,s){var i,n;if(t.unless(e instanceof g&&!e.scheduledInfo&&e.isResendable).throw(t.SendbirdError.invalidParameters),e.isUserMessage()){const t=null!==(i=e.messageParams)&&void 0!==i?i:te(e);return this._sendUserMessage(t,exports.SendMessageRequestType.RESEND,e.reqId)}if(e.isFileMessage()){const i=this._validateFailedFileMessageHasFile(e,s);t.unless(i).throw(t.SendbirdError.invalidParameters);const a=null!==(n=e.messageParams)&&void 0!==n?n:de(e,s);return this._sendFileMessage(a,exports.SendMessageRequestType.RESEND,e.reqId)}if(e.isMultipleFilesMessage())throw t.SendbirdError.channelTypeNotSupportedError}updateFileMessage(e,s){return t.__awaiter(this,void 0,void 0,(function*(){const i=Object.assign(Object.assign({},_e),s);t.unless(t.isTypeOf("number",e)&&(e=>he(e))(i)).throw(t.SendbirdError.invalidParameters);const{requestQueue:n}=t.Vault.of(this._iid),a=new mt(Object.assign({channelType:this.channelType,channelUrl:this.url,messageId:e},i)),r=yield n.send(a),{message:o}=r.as(_t);return o}))}cancelUploadingFileMessage(e){return t.__awaiter(this,void 0,void 0,(function*(){t.unless(t.isTypeOf("string",e)).throw(t.SendbirdError.invalidParameters);const{fileMessageQueue:s}=ai.of(this._iid);return s.cancel(this,e),!0}))}copyFileMessage(e,s){var i,n,a;return t.__awaiter(this,void 0,void 0,(function*(){t.unless(e instanceof Qt&&s instanceof M&&s.sendingStatus===t.SendingStatus.SUCCEEDED&&this.url===s.channelUrl&&!s.scheduledInfo).throw(t.SendbirdError.invalidParameters);const r=new t.Deferred,o=t.undefineNullProps(Object.assign(Object.assign({},s),{fileUrl:s.url,fileName:s.name,fileSize:s.size,mimeType:s.type,mentionType:s.mentionType,mentionedUserIds:null!==(i=s.mentionedUserIds)&&void 0!==i?i:null===(n=s.mentionedUsers)||void 0===n?void 0:n.map((e=>e.userId)),pushNotificationDeliveryOption:t.PushNotificationDeliveryOption.DEFAULT,parentMessageId:null,isReplyToChannel:!1,thumbnailSizes:null===(a=s.thumbnails)||void 0===a?void 0:a.map((e=>({maxWidth:e.width,maxHeight:e.height}))),requireAuth:s.requireAuth,isPinnedMessage:!1}));return e._sendFileMessage(o).onSucceeded((e=>r.resolve(e))).onFailed((e=>r.reject(e))),r.promise}))}copyMessage(e,s){t.unless(e instanceof Qt&&s instanceof g&&s.sendingStatus===t.SendingStatus.SUCCEEDED&&this.url===s.channelUrl&&!s.scheduledInfo).throw(t.SendbirdError.invalidParameters);const i=s,n=e;if(i.isUserMessage()){t.unless(!i.poll).throw(t.SendbirdError.notSupportedError);const e=ee(i);return n._sendUserMessage(e)}if(i.isFileMessage()){const e=le(i);return n._sendFileMessage(e)}if(s.isMultipleFilesMessage())throw t.SendbirdError.channelTypeNotSupportedError}deleteMessage(e){return t.__awaiter(this,void 0,void 0,(function*(){if(t.unless(e instanceof _).throw(t.SendbirdError.invalidParameters),e.messageId>0){const{requestQueue:s}=t.Vault.of(this._iid),i=new gt({channelType:this.channelType,channelUrl:this.url,messageId:e.messageId});yield s.send(i)}}))}addReaction(e,s){return t.__awaiter(this,void 0,void 0,(function*(){t.unless(e instanceof _&&e.messageId>0&&t.isTypeOf("string",s)).throw(t.SendbirdError.invalidParameters);const{requestQueue:i}=t.Vault.of(this._iid),n=new ft({channelType:this.channelType,channelUrl:this.url,messageId:e.messageId,reactionKey:s}),a=yield i.send(n),{reactionEvent:r}=a.as(vt);return r}))}deleteReaction(e,s){return t.__awaiter(this,void 0,void 0,(function*(){t.unless(e instanceof _&&e.messageId>0&&t.isTypeOf("string",s)).throw(t.SendbirdError.invalidParameters);const{requestQueue:i}=t.Vault.of(this._iid),n=new It({channelType:this.channelType,channelUrl:this.url,messageId:e.messageId,reactionKey:s}),a=yield i.send(n),{reactionEvent:r}=a.as(Et);return r}))}_updateUserMessageMetaArray(e,s,i,n){return t.__awaiter(this,void 0,void 0,(function*(){const{dispatcher:a,requestQueue:r}=t.Vault.of(this._iid),o=new ht({channelType:this.channelType,channelUrl:this.url,messageId:e,metaArrayParams:{array:s,mode:i,upsert:n}}),l=yield r.send(o),{message:d}=l.as(pt);return a.dispatch(new t.MessageUpdateEventCommand({messages:[d],source:t.CollectionEventSource.EVENT_MESSAGE_UPDATED})),d}))}_updateFileMessageMetaArray(e,s,i,n){return t.__awaiter(this,void 0,void 0,(function*(){const{dispatcher:a,requestQueue:r}=t.Vault.of(this._iid),o=new mt({channelType:this.channelType,channelUrl:this.url,messageId:e,metaArrayParams:{array:s,mode:i,upsert:n}}),l=yield r.send(o),{message:d}=l.as(_t);return a.dispatch(new t.MessageUpdateEventCommand({messages:[d],source:t.CollectionEventSource.EVENT_MESSAGE_UPDATED})),d}))}createMessageMetaArrayKeys(e,s){return t.__awaiter(this,void 0,void 0,(function*(){t.unless(e instanceof _&&e.messageId>0&&t.isArrayOf("string",s)).throw(t.SendbirdError.invalidParameters);const i=s.map((e=>new o({key:e})));return e instanceof M?this._updateFileMessageMetaArray(e.messageId,i,"add",!0):this._updateUserMessageMetaArray(e.messageId,i,"add",!0)}))}deleteMessageMetaArrayKeys(e,s){return t.__awaiter(this,void 0,void 0,(function*(){t.unless(e instanceof _&&e.messageId>0&&t.isArrayOf("string",s)).throw(t.SendbirdError.invalidParameters);const i=s.map((e=>new o({key:e})));return e instanceof M?this._updateFileMessageMetaArray(e.messageId,i,"remove",!0):this._updateUserMessageMetaArray(e.messageId,i,"remove",!0)}))}addMessageMetaArrayValues(e,s){return t.__awaiter(this,void 0,void 0,(function*(){return t.unless(e instanceof _&&e.messageId>0&&s.every((e=>e instanceof o))).throw(t.SendbirdError.invalidParameters),e instanceof M?this._updateFileMessageMetaArray(e.messageId,s,"add",!0):this._updateUserMessageMetaArray(e.messageId,s,"add",!0)}))}removeMessageMetaArrayValues(e,s){return t.__awaiter(this,void 0,void 0,(function*(){return t.unless(e instanceof _&&e.messageId>0&&s.every((e=>e instanceof o))).throw(t.SendbirdError.invalidParameters),e instanceof M?this._updateFileMessageMetaArray(e.messageId,s,"remove",!0):this._updateUserMessageMetaArray(e.messageId,s,"remove",!0)}))}report(e,s){return t.__awaiter(this,void 0,void 0,(function*(){t.unless(t.isEnumOf(exports.ReportCategory,e)&&t.isTypeOf("string",s)).throw(t.SendbirdError.invalidParameters);const{sdkState:i,requestQueue:n}=t.Vault.of(this._iid),a=new ot({channelUrl:this.url,channelType:this.channelType,userId:i.userId,category:e,description:s});yield n.send(a)}))}reportUser(e,s,i){return t.__awaiter(this,void 0,void 0,(function*(){t.unless(e instanceof t.User&&t.isEnumOf(exports.ReportCategory,s)&&t.isTypeOf("string",i)).throw(t.SendbirdError.invalidParameters);const{sdkState:n,requestQueue:a}=t.Vault.of(this._iid),r=new lt({channelUrl:this.url,channelType:this.channelType,userId:n.userId,offendingUserId:e.userId,category:s,description:i});yield a.send(r)}))}reportMessage(e,s,i){return t.__awaiter(this,void 0,void 0,(function*(){t.unless(e instanceof g&&t.isEnumOf(exports.ReportCategory,s)&&t.isTypeOf("string",i)).throw(t.SendbirdError.invalidParameters);const{sdkState:n,requestQueue:a}=t.Vault.of(this._iid),r=new dt({channelUrl:this.url,channelType:this.channelType,userId:n.userId,offendingUserId:e.sender.userId,messageId:e.messageId,category:s,description:i});yield a.send(r)}))}updatePoll(e,s){return t.__awaiter(this,void 0,void 0,(function*(){t.unless(t.isTypeOf("number",e)&&(e=>t.isTypeOf("string",e.title,!0)&&t.validatePollData(e.data)&&t.isTypeOf("boolean",e.allowUserSuggestion,!0)&&t.isTypeOf("boolean",e.allowMultipleVotes,!0)&&t.isTypeOf("number",e.closeAt,!0))(s)).throw(t.SendbirdError.invalidParameters);const{requestQueue:i}=t.Vault.of(this._iid),n=new Ct(Object.assign({pollId:e},s)),a=yield i.send(n),{poll:r}=a.as(wt);return r}))}deletePoll(e){return t.__awaiter(this,void 0,void 0,(function*(){const s=t.isTypeOf("number",e);t.unless(s).throw(t.SendbirdError.invalidParameters);const{requestQueue:i}=t.Vault.of(this._iid),n=new Nt({pollId:e});yield i.send(n)}))}closePoll(e){return t.__awaiter(this,void 0,void 0,(function*(){const s=t.isTypeOf("number",e);t.unless(s).throw(t.SendbirdError.invalidParameters);const{requestQueue:i}=t.Vault.of(this._iid),n=new Pt({pollId:e}),a=yield i.send(n),{poll:r}=a.as(Ut);return r}))}addPollOption(e,s){return t.__awaiter(this,void 0,void 0,(function*(){const i=t.isTypeOf("number",e)&&t.isTypeOf("string",s)&&""!==s.trim();t.unless(i).throw(t.SendbirdError.invalidParameters);const{requestQueue:n}=t.Vault.of(this._iid),a=new Rt({channelUrl:this.url,channelType:this.channelType,pollId:e,optionText:s}),r=yield n.send(a),{poll:o}=r.as(xt);return o}))}updatePollOption(e,s,i){return t.__awaiter(this,void 0,void 0,(function*(){const n=t.isTypeOf("number",e)&&t.isTypeOf("number",s)&&t.isTypeOf("string",i)&&""!==i.trim();t.unless(n).throw(t.SendbirdError.invalidParameters);const{requestQueue:a}=t.Vault.of(this._iid),r=new Lt({pollId:e,pollOptionId:s,optionText:i}),o=yield a.send(r),{poll:l}=o.as(kt);return l}))}deletePollOption(e,s){return t.__awaiter(this,void 0,void 0,(function*(){const i=t.isTypeOf("number",e)&&t.isTypeOf("number",s);t.unless(i).throw(t.SendbirdError.invalidParameters);const{requestQueue:n}=t.Vault.of(this._iid),a=new Dt({pollId:e,pollOptionId:s});yield n.send(a)}))}votePoll(e,s){return t.__awaiter(this,void 0,void 0,(function*(){const i=t.isTypeOf("number",e)&&t.isArrayOf("number",s);t.unless(i).throw(t.SendbirdError.invalidParameters);const{requestQueue:n,dispatcher:a}=t.Vault.of(this._iid),r=new qt({reqId:this._generateRequestId(),channelUrl:this.url,channelType:this.channelType,pollId:e,pollOptionIds:s}),o=yield n.send(r),{event:l}=o.as(Ft);return a.dispatch(new t.PollVoteInternalEventCommand({event:l,source:t.CollectionEventSource.EVENT_POLL_VOTED})),l}))}getPollChangeLogsSinceTimestamp(e){return t.__awaiter(this,void 0,void 0,(function*(){t.unless(t.isTypeOf("number",e)).throw(t.SendbirdError.invalidParameters);const s=t.PollManager.of(this._iid);return yield s.getPollChangeLogs(this.url,this.channelType,e)}))}getPollChangeLogsSinceToken(e){return t.__awaiter(this,void 0,void 0,(function*(){t.unless(t.isTypeOf("string",e,!0));const s=t.PollManager.of(this._iid);return yield s.getPollChangeLogs(this.url,this.channelType,e)}))}createPollListQuery(e=10){return new t.PollListQuery(this._iid,{channelUrl:this.url,channelType:this.channelType,limit:e})}createPollVoterListQuery(e,s,i=20){return new t.PollVoterListQuery(this._iid,{channelUrl:this.url,channelType:this.channelType,pollId:e,pollOptionId:s,limit:i})}}const Kt={};class Gt{constructor({dbname:e,itemSizeLimit:t=1048576,cacheLimit:s=256,blockHashBase:i=2,blockHashMultiplier:n=10,blockHashConstant:a=11,transactionApplyDelay:r=200,disableLogger:o=!1}){return Kt[e]||(this.itemSizeLimit=t,this.cacheLimit=s,this.blockHashBase=i,this.blockHashMultiplier=n,this.blockHashConstant=a,this.transactionApplyDelay=r,this.disableLogger=o,Kt[e]=this),Kt[e]}static get(e){return Kt[e]}}var Ht,Wt;!function(e){e[e.UNKNOWN_ERROR=6e7]="UNKNOWN_ERROR",e[e.STORE_NOT_DEFINED=61001e3]="STORE_NOT_DEFINED",e[e.STORE_NOT_AVAILABLE=61001001]="STORE_NOT_AVAILABLE",e[e.STORE_NOT_AVAILABLE_IN_PRIVATE_BROWSING=61001002]="STORE_NOT_AVAILABLE_IN_PRIVATE_BROWSING",e[e.STORE_IS_FULL=61001003]="STORE_IS_FULL",e[e.STORE_NOT_INITIALIZED=61001004]="STORE_NOT_INITIALIZED",e[e.STORE_INVALID_KEY_TYPE=61002e3]="STORE_INVALID_KEY_TYPE",e[e.STORE_BROKEN_INTEGRITY=61002001]="STORE_BROKEN_INTEGRITY",e[e.STORE_BROKEN_BLOB=61002002]="STORE_BROKEN_BLOB",e[e.STORE_ENCRYPTION_INVALID=61002003]="STORE_ENCRYPTION_INVALID",e[e.STORE_ITEM_SIZE_LIMIT_EXCEEDED=61017e3]="STORE_ITEM_SIZE_LIMIT_EXCEEDED",e[e.STORE_READ_FAILED=61017001]="STORE_READ_FAILED",e[e.STORE_WRITE_FAILED=61017002]="STORE_WRITE_FAILED",e[e.DATABASE_SCHEMA_NOT_ON_UPGRADE=62002e3]="DATABASE_SCHEMA_NOT_ON_UPGRADE",e[e.COLLECTION_NOT_READY=63001e3]="COLLECTION_NOT_READY",e[e.COLLECTION_KEY_NOT_MATCH=63002e3]="COLLECTION_KEY_NOT_MATCH",e[e.COLLECTION_QUERY_NOT_VALID=63002001]="COLLECTION_QUERY_NOT_VALID",e[e.COLLECTION_KEY_NOT_FOUND=63004e3]="COLLECTION_KEY_NOT_FOUND",e[e.COLLECTION_KEY_NOT_GIVEN=63004001]="COLLECTION_KEY_NOT_GIVEN",e[e.COLLECTION_INSERT_DUPLICATE=63009e3]="COLLECTION_INSERT_DUPLICATE",e[e.COLLECTION_WRITE_FAILED=63017e3]="COLLECTION_WRITE_FAILED",e[e.COLLECTION_ITEM_SIZE_LIMIT_EXCEEDED=63017001]="COLLECTION_ITEM_SIZE_LIMIT_EXCEEDED",e[e.INDEX_TABLE_IS_REQUIRED=65001e3]="INDEX_TABLE_IS_REQUIRED",e[e.INDEX_TYPE_NOT_MATCH=65002e3]="INDEX_TYPE_NOT_MATCH",e[e.COMPARE_TYPE_NOT_MATCH=69002001]="COMPARE_TYPE_NOT_MATCH",e[e.CIRCULAR_REFERENCE_FOUND=69002002]="CIRCULAR_REFERENCE_FOUND"}(Ht||(Ht={}));class Yt extends Error{constructor({code:e=Ht.UNKNOWN_ERROR,message:t="Unknown error occurred."}){super(t),this.code=e,Object.setPrototypeOf(this,Yt.prototype)}static get storeNotDefined(){return new Yt({code:Ht.STORE_NOT_DEFINED,message:"Store is not defined. Specify the store on NestDB()"})}static get storeNotAvailable(){return new Yt({code:Ht.STORE_NOT_AVAILABLE,message:"Store is not available. Check your environment settings."})}static get storeNotAvailableInPrivateBrowsing(){return new Yt({code:Ht.STORE_NOT_AVAILABLE_IN_PRIVATE_BROWSING,message:"Store is not available because it is in private browsing."})}static get storeIsFull(){return new Yt({code:Ht.STORE_IS_FULL,message:"Store is full."})}static get storeNotInitialized(){return new Yt({code:Ht.STORE_NOT_INITIALIZED,message:"Store is not initialized."})}static get storeKeyTypeIsInvalid(){return new Yt({code:Ht.STORE_INVALID_KEY_TYPE,message:"Store key should be string type."})}static get storeBrokenIntegrity(){return new Yt({code:Ht.STORE_BROKEN_INTEGRITY,message:"Data should be in a store but it does not. Integrity is broken."})}static get storeBrokenBlob(){return new Yt({code:Ht.STORE_BROKEN_BLOB,message:"Data should be in a store but it does not. Blob data is broken."})}static get storeEncryptionInvalid(){return new Yt({code:Ht.STORE_ENCRYPTION_INVALID,message:"Encryption algorithm has changed. All the store should reset."})}static get storeItemSizeExceeded(){return new Yt({code:Ht.STORE_ITEM_SIZE_LIMIT_EXCEEDED,message:"The size of the item exceeds the limit that the store allows."})}static get storeReadFailed(){return new Yt({code:Ht.STORE_READ_FAILED,message:"Failed to read from store."})}static get storeWriteFailed(){return new Yt({code:Ht.STORE_WRITE_FAILED,message:"Failed to write to store."})}static get databaseSchemaNotOnUpgrade(){return new Yt({code:Ht.DATABASE_SCHEMA_NOT_ON_UPGRADE,message:"Committing schema is not allowed when upgrade is not running."})}static get collectionNotReady(){return new Yt({code:Ht.COLLECTION_NOT_READY,message:"Collection is not ready due to an error during initialization."})}static get collectionKeyNotMatch(){return new Yt({code:Ht.COLLECTION_KEY_NOT_MATCH,message:"keyName of collection could not change."})}static get collectionQueryNotValid(){return new Yt({code:Ht.COLLECTION_QUERY_NOT_VALID,message:"Query parameter is not a valid format."})}static get collectionInsertDuplicate(){return new Yt({code:Ht.COLLECTION_INSERT_DUPLICATE,message:"The key already exists."})}static get collectionKeyNotFound(){return new Yt({code:Ht.COLLECTION_KEY_NOT_FOUND,message:"The key is not found."})}static get collectionKeyNotGiven(){return new Yt({code:Ht.COLLECTION_KEY_NOT_GIVEN,message:"The item should contain [keyName] property."})}static get collectionWriteFailed(){return new Yt({code:Ht.COLLECTION_WRITE_FAILED,message:"Failed to write an item."})}static get collectionItemSizeExceeded(){return new Yt({code:Ht.COLLECTION_ITEM_SIZE_LIMIT_EXCEEDED,message:"The size of the item exceeds the limit that a collection allows."})}static get indexTableIsRequired(){return new Yt({code:Ht.INDEX_TABLE_IS_REQUIRED,message:"Index table is required."})}static get indexTypesNotMatch(){return new Yt({code:Ht.INDEX_TYPE_NOT_MATCH,message:"Indexed column should have primitive type."})}static get compareTypesNotMatch(){return new Yt({code:Ht.COMPARE_TYPE_NOT_MATCH,message:"Values to compare have different types."})}static get circularReferenceFound(){return new Yt({code:Ht.CIRCULAR_REFERENCE_FOUND,message:"Cannot handle circular referenced object."})}}!function(e){e.INIT="init",e.READY="ready",e.CLOSED="closed"}(Wt||(Wt={}));const Jt=(e,t=new WeakMap)=>{if("object"==typeof e&&null!==e){if(t.has(e))throw Yt.circularReferenceFound;{let s;if(t.set(e,!0),Array.isArray(e))s=e.map((e=>Jt(e,t)));else if(e instanceof RegExp)s=e;else if(e instanceof Date)s=e;else{s={};for(const i in e)s[i]=Jt(e[i],t)}return t.delete(e),s}}return e},Xt=(e,t)=>{if(null==t)return 1;if(null==e)return-1;if(typeof e!=typeof t)throw Yt.compareTypesNotMatch;let s=0;switch(typeof e){case"boolean":case"number":s=e-t;break;case"string":s=e.localeCompare(t)}return s},Zt=(e,t)=>{let s=0;for(let t=0;t>>0)%t},es=e=>new Promise((t=>{setTimeout((()=>t()),e)})),ts=(e,t)=>{if(!t)return!1;if("function"!=typeof e){for(const s in e)if(["/and","&&"].includes(s)){if(e[s].some((e=>!ts(e,t))))return!1}else if(["/or","||"].includes(s)){if(e[s].every((e=>!ts(e,t))))return!1}else if("/where"===s){if(!(0,e[s])(t))return!1}else{const i=s;if("object"==typeof e[i]){const s=e[i];for(const e in s)switch(e){case"/eq":case"=":if(t[i]!==s[e])return!1;break;case"/neq":case"!=":if(t[i]===s[e])return!1;break;case"/gt":case">":{const n=t[i],a=s[e];if(!(Xt(n,a)>0))return!1;break}case"/gte":case">=":{const n=t[i],a=s[e];if(!(Xt(n,a)>=0))return!1;break}case"/lt":case"<":{const n=t[i],a=s[e];if(!(Xt(n,a)<0))return!1;break}case"/lte":case"<=":{const n=t[i],a=s[e];if(!(Xt(n,a)<=0))return!1;break}case"/in":{const n=t[i];if(!s[e].includes(n))return!1;break}case"/nin":{const n=t[i];if(s[e].includes(n))return!1;break}case"/contain":{const n=t[i],a=s[e];if(!n.includes(a))return!1;break}case"/regex":{const n=t[i];if(!s[e].test(n))return!1;break}case"/where":{const n=t[i];if(!(0,s[e])(n))return!1;break}}}else if("function"==typeof e[i]){if(!e[i](t[i]))return!1}else if(e[i]!==t[i])return!1}return!0}return e(t)},ss=()=>{},is=()=>Promise.resolve(),ns=e=>e,as=(e,t)=>{t()};var rs;!function(e){e[e.FORWARD=0]="FORWARD",e[e.BACKWARD=1]="BACKWARD"}(rs||(rs={}));class os{constructor({initialPrevValue:e=null,initialNextValue:t=null,iterator:s,map:i=ns,backward:n=is,forward:a=is,complete:r=ss}){this._prevValue=e,this._nextValue=t,this._error=null,this._map=i,this._backward=n,this._forward=a,this._iterator=s,this._complete=r}get prevValue(){return this._map(this._prevValue)}get nextValue(){return this._map(this._nextValue)}get error(){return this._error}get hasPrevious(){return!!this._prevValue}get hasNext(){return!!this._nextValue}prev(){return t.__awaiter(this,void 0,void 0,(function*(){if(this.hasPrevious){try{const e=this._prevValue;this._prevValue=(yield this._backward())||null,this._nextValue=e}catch(e){this._error=e}return yield this._iterator(this)}this._complete()}))}next(){return t.__awaiter(this,void 0,void 0,(function*(){if(this.hasNext){try{const e=this._nextValue;this._nextValue=(yield this._forward())||null,this._prevValue=e}catch(e){this._error=e}return yield this._iterator(this)}this._complete()}))}stop(){this._prevValue=null,this._nextValue=null,this._complete()}}class ls{constructor({condition:e={},backward:t=!1,blockManager:s,indexer:i}){this.condition=e,this.backward=t,this._blockManager=s,this._indexer=i}findOptimizedStartPosition(){const e=["=","/eq",">",">=","/gt","/gte"],t=["=","/eq","<","<=","/lt","/lte"];if(this.backward){let s=this._indexer.origin.length-1;if("function"!=typeof this.condition)for(const i in this._indexer.fields){let n=this._indexer.fields[i],a=1;if("-"===n[0]&&(n=n.slice(1),a=-1),this.condition[n])if("object"==typeof this.condition[n]){const r=a>0?t:e;for(const e in this.condition[n])if(r.includes(e))for(let t=s;t>=0;t--)if(a*Xt(this._indexer.origin[t].columnValues[i],this.condition[n][e])<=0){s=t;break}}else for(let e=s;e>=0;e--)if(a*Xt(this._indexer.origin[e].columnValues[i],this.condition[n])<=0){s=e;break}}return Math.min(s+1,this._indexer.origin.length-1)}{let s=0;if("function"!=typeof this.condition)for(let i=0;i{if((a>0?e:t).includes(r))for(let e=s;e=0){s=e;break}}));else for(let e=s;e=0){s=e;break}}return Math.max(s-1,0)}}each(e){return t.__awaiter(this,void 0,void 0,(function*(){let s=this.findOptimizedStartPosition(),i=0;this.backward&&this._indexer.origin[s]&&(i=this._indexer.origin[s].keys.length-1);const n=()=>{if(this._indexer.origin[s]){if(!this._indexer.origin[s].keys[++i]){if(!this._indexer.origin[++s])return!1;i=0}return!0}return!1},a=()=>{if(this._indexer.origin[s]){if(!this._indexer.origin[s].keys[--i]){if(!this._indexer.origin[--s])return!1;i=this._indexer.origin[s].keys.length-1}return!0}return!1};let r=null;if(this._indexer.origin[s]){const e=this.backward?a:n;do{const e=yield this._blockManager.getFromBlock(this._indexer.origin[s].keys[i]);if(e&&ts(this.condition,e)){r=e;break}}while(e())}return yield new Promise((o=>{const l=new os({initialNextValue:Jt(r),iterator:e,forward:()=>t.__awaiter(this,void 0,void 0,(function*(){const e=this.backward?a:n;for(;e();){const e=yield this._blockManager.getFromBlock(this._indexer.origin[s].keys[i]);if(e&&ts(this.condition,e))return Jt(e)}return null})),backward:()=>t.__awaiter(this,void 0,void 0,(function*(){const e=this.backward?n:a;for(;e();){const e=yield this._blockManager.getFromBlock(this._indexer.origin[s].keys[i]);if(e&&ts(this.condition,e))return Jt(e)}return null})),complete:o});e(l)}))}))}}class ds{constructor({condition:e={},backward:t=!1,mutex:s,blockManager:i,indexer:n}){this._mutex=s,this._iterator=new ls({condition:e,backward:t,blockManager:i,indexer:n})}fetch(e={}){return t.__awaiter(this,void 0,void 0,(function*(){let s=Math.max(e.offset||0,0);const i="number"==typeof e.limit?e.limit:Number.MAX_SAFE_INTEGER;if(0===i)return[];if(i<0)throw Yt.collectionQueryNotValid;try{const e=[];return yield this._mutex.lock(),yield this._iterator.each((n=>t.__awaiter(this,void 0,void 0,(function*(){n.error?n.stop():n.hasNext?0===s?(e.push(n.nextValue),0t.__awaiter(this,void 0,void 0,(function*(){s.error?s.stop():s.hasNext?(e++,s.next()):s.stop()})))),this._mutex.unlock(),e}catch(e){throw this._mutex.unlock(),e}}))}}const us=e=>`nest@${e}`,cs=(e,t)=>`${us(e)}/${t}`,hs=(e,t)=>`${cs(e,t)}.metadata`,ps=(e,t)=>`${cs(e,t)}/block.`,ms=(e,t)=>`${cs(e,t)}/blob.`;class _s{constructor({dbname:e,collectionName:t,store:s}){this.dbname=e,this.collectionName=t,this.store=s}get(e){return t.__awaiter(this,void 0,void 0,(function*(){const t=yield this.store.get(e);if(t){const{data:e,type:s}=t;if("undefined"!=typeof fetch){const t=yield fetch(e);return yield t.blob()}{const t=512,i=[],n=atob(e.split(",")[1]);for(let e=0;e{const i=((e,t,s,i=0)=>`${ms(e,t)}${s}.${i}`)(this.dbname,this.collectionName,s),n=new FileReader;n.onload=()=>{t({blobId:i,data:n.result,type:e.type})},n.readAsDataURL(e)}));return yield this.store.set({key:t,value:{data:i,type:n}}),t}))}remove(e){return t.__awaiter(this,void 0,void 0,(function*(){yield this.store.remove(e)}))}clear(){return t.__awaiter(this,void 0,void 0,(function*(){const e=ms(this.dbname,this.collectionName),s=yield this.store.getAllKeys();yield Promise.all(s.filter((t=>t.startsWith(e))).map((e=>t.__awaiter(this,void 0,void 0,(function*(){return yield this.store.remove(e)})))))}))}}var gs,ys,fs;!function(e){e[e.COMMIT=0]="COMMIT",e[e.WRITE=1]="WRITE",e[e.ERROR=2]="ERROR"}(gs||(gs={})),function(e){e.PENDING="pending",e.PERSISTENT="persistent",e.VOLATILE="volatile"}(ys||(ys={})),function(e){e[e.NO_CACHE=0]="NO_CACHE",e[e.DEFAULT=1]="DEFAULT",e[e.PERSISTENT=2]="PERSISTENT"}(fs||(fs={}));const vs=[ys.PENDING,ys.VOLATILE],Is={};class Es{constructor({dbname:e,limit:t=256}){return Is[e]||(this.dbname=e,this._items=[],this._limit=t,Is[e]=this),Is[e]}static get(e){return Is[e]}get items(){return this._items}find(e,s,i=fs.DEFAULT){return t.__awaiter(this,void 0,void 0,(function*(){let t=this.get(s);if(t)i===fs.PERSISTENT&&(t.state=ys.PERSISTENT);else{const n=yield e.get(s);n&&(t={key:s,value:n,state:i===fs.PERSISTENT?ys.PERSISTENT:ys.VOLATILE},this.put(t))}return t}))}get(e,t=fs.DEFAULT){const s=this._items.map((e=>e.key)).indexOf(e);if(s>-1){const e=this._items[s];return t===fs.PERSISTENT&&(e.state=ys.PERSISTENT),t!==fs.NO_CACHE&&this.put(e),e}return null}put(e){if(this._limit>0){const t=this._items.map((e=>e.key)).indexOf(e.key);if(t>-1)vs.includes(this._items[t].state)&&vs.includes(e.state)?(this._items.splice(t,1),this._items.push(e)):(this._items[t].state=e.state,this._items[t].value=e.value);else{this._items.push(e);const t=this._items.filter((e=>e.state===ys.VOLATILE));let s=t.length-this._limit;if(s>0){const e=[];for(const t of this._items)t.state===ys.VOLATILE&&s>0?s--:e.push(t);this._items=e}}}}remove(e){const t=this._items.map((e=>e.key)).indexOf(e);t>-1&&this._items.splice(t,1)}clearByCondition(e){this._items=this._items.filter((t=>!e(t)))}clear(e=!1){this._items=e?[]:this._items.filter((e=>e.state!==ys.VOLATILE))}}class Ts{constructor({dbname:e,collectionName:t,store:s}){this._requests=[],this._onCommit=new Map,this._onWrite=new Map,this._onError=new Map,this.dbname=e,this.collectionName=t,this.metadataKey=((e,t)=>`${cs(e,t)}/trans.metadata`)(e,t),this.recordsetKey=((e,t)=>`${cs(e,t)}/trans.recordset`)(e,t),this._store=s}get generation(){return this._metadata?this._metadata.generation:0}get requestCount(){return this._requests.length}_getReducedRecordset(e=[]){return t.__awaiter(this,void 0,void 0,(function*(){const t=(yield this._store.get(this.recordsetKey))||[];return t.push(...e),this._reduceRecordSet(t)}))}_reduceRecordSet(e){const t=[],s={};for(let i=e.length-1;i>=0;i--){const n=e[i],a=[];for(let e=n.requests.length-1;e>=0;e--){const t=n.requests[e],i=t.data;s[i.key]||(a.unshift(t),s[i.key]=!0)}a.length>0&&(n.requests=a,t.unshift(n))}return t}_applyRecord(e,s){return t.__awaiter(this,void 0,void 0,(function*(){const t=Es.get(this.dbname),{generation:i,requests:n}=s;let a=null;try{const e=yield this._store.setMany(n.map((e=>Object.assign(Object.assign({},e.data),{generation:i}))));for(let s=0;s{a&&e(a)}));else{const t=e.filter((e=>e.generation!==i));yield this._store.set({key:this.recordsetKey,value:t}),this._onWrite.forEach((e=>{e(n.map((e=>e.data)))}))}}))}init(){return t.__awaiter(this,void 0,void 0,(function*(){this._metadata=(yield this._store.get(this.metadataKey))||{generation:1};const e=yield this._getReducedRecordset();for(const t of e)yield this._applyRecord(e,t)}))}on(e,t,s){switch(e){case gs.COMMIT:this._onCommit.set(t,s);break;case gs.WRITE:this._onWrite.set(t,s);break;case gs.ERROR:this._onError.set(t,s)}}requestWrite(e,t){this._requests.push({data:e,options:t});Es.get(this.dbname).put(Object.assign({state:ys.PENDING},e))}requestMultipleWrite(e,t){const s=Es.get(this.dbname);for(const i of e)this._requests.push({data:i,options:t}),s.put(Object.assign({state:ys.PENDING},i))}clear(){return t.__awaiter(this,void 0,void 0,(function*(){Es.get(this.dbname).clearByCondition((e=>e.state===ys.PENDING)),this._requests=[]}))}commit(){return t.__awaiter(this,void 0,void 0,(function*(){const e=this._requests;if(e.length>0){const t=[],s={};for(let i=e.length-1;i>=0;i--){const n=e[i],a=n.data;s[a.key]||(s[a.key]=!0,t.unshift(n))}const i={generation:this.generation,requests:t},n=yield this._getReducedRecordset([i]);yield this._store.set({key:this.recordsetKey,value:n}),this._metadata.generation++,yield this._store.set({key:this.metadataKey,value:this._metadata});const a=Es.get(this.dbname);for(let e=0;e{t(e.map((e=>e.data)))}));const r=Gt.get(this.dbname);setTimeout((()=>{try{this._applyRecord(n,i)}catch(e){this._onError.forEach((t=>t(e)))}}),r.transactionApplyDelay)}}))}}class bs{constructor({blockId:e,keyName:t,items:s=[],limit:i}){this.blockId=e,this.keyName=t,this.limit=i,this._items=[...s]}static createFromCacheItem(e){return e?new bs(e.value):null}get isEmpty(){return 0===this._items.length}get items(){return this._items}serialize(){return{blockId:this.blockId,keyName:this.keyName,limit:this.limit,items:this._items}}getItemByKey(e){const t=this._items.find((t=>{const s=t[this.keyName];return e===s}));return null!=t?t:null}has(e){return this._items.map((e=>e[this.keyName])).includes(e)}add(e){const t=this._items.map((e=>e[this.keyName])).indexOf(e[this.keyName]);return t<0?this._items.length{const i=s.base*Math.pow(s.multiplier,t)+s.constant;return(s.hashFunction||Zt)(e,i)})(e,t,{hashFunction:this.hashFunction,base:this.metadata.blockHashBase,multiplier:this.metadata.blockHashMultiplier,constant:this.metadata.blockHashConstant})}`,`${ps(s,i)}${n}.${a}`;var s,i,n,a}_findBlock(e){return t.__awaiter(this,void 0,void 0,(function*(){const t=Es.get(this.dbname);for(let s=this.metadata.blockLevel;s>0;s--){const i=this.createBlockId(e,s),n=yield t.find(this._store,i);if(n){const t=bs.createFromCacheItem(n);if(null==t?void 0:t.getItemByKey(e))return t}}return null}))}getFromBlock(e){return t.__awaiter(this,void 0,void 0,(function*(){const t=yield this._findBlock(e);return t?t.getItemByKey(e):null}))}putToBlock(e,s){return t.__awaiter(this,void 0,void 0,(function*(){const t=Gt.get(this.dbname),i=this.createBlockId(e),n=Math.floor(this._store.itemSizeLimit/t.itemSizeLimit),a=Es.get(this.dbname),r=yield a.find(this._store,i),o=r?bs.createFromCacheItem(r):new bs({blockId:i,keyName:this.keyName,items:[],limit:n});return!!(null==o?void 0:o.add(s))&&(this._transaction.requestWrite({key:o.blockId,value:o.serialize()}),!0)}))}removeFromBlock(e){return t.__awaiter(this,void 0,void 0,(function*(){const t=yield this._findBlock(e);return!(!t||!t.remove(e))&&(this._transaction.requestWrite({key:t.blockId,value:t.serialize()}),!0)}))}clearAllBlocks(){return t.__awaiter(this,void 0,void 0,(function*(){const e=ps(this.dbname,this.collectionName),t=(yield this._store.getAllKeys()).filter((t=>t.startsWith(e)));yield this._store.removeMany(t),yield this._transaction.clear();Es.get(this.dbname).clearByCondition((t=>t.key.startsWith(e)))}))}}const Os=e=>{const t=typeof e;return null===e||"undefined"===t||"boolean"===t||"number"===t||"string"===t},Ms={};class As{constructor({dbname:e,collectionName:t,keyName:s,fields:i,transaction:n,store:a}){this._origin=[],this._table=[];const r=((e,t,s)=>`${cs(e,t)}/index.${s}`)(e,t,i.join(">"));return Ms[r]||(this.dbname=e,this.collectionName=t,this.keyName=s,this.fields=i,this.indexerKey=r,this._transaction=n,this._store=a,this._transaction.on(gs.COMMIT,this.indexerKey,(()=>this.commit())),this._transaction.on(gs.ERROR,this.indexerKey,(()=>this.abort()))),Ms[r]}static createKey(e){return e.join(">")}static parseKey(e){return e.split(">")}static clearIndexerMap(){for(const e in Ms)delete Ms[e]}_addItem(e){const t=e[this.keyName],s=this.getColumnValues(e),[i,n]=this.indexOf(s);return n?!this._table[i].keys.includes(t)&&(this._table[i].keys.push(t),!0):(this._table.splice(i,0,{columnValues:s,keys:[t]}),!0)}_removeItem(e){const t=e[this.keyName],s=this.getColumnValues(e),[i,n]=this.indexOf(s);if(n){const e=this._table[i].keys.indexOf(t);if(e>-1)return this._table[i].keys.splice(e,1),0===this._table[i].keys.length&&this._table.splice(i,1),!0}return!1}get origin(){return this._origin}get table(){return this._table}getColumnValues(e){const t=[];for(let s of this.fields){if("-"===s[0]&&(s=s.slice(1)),!Os(e[s]))throw Yt.indexTypesNotMatch;t.push(e[s])}return t}diff(e,t){for(const s in this.fields){const i="-"===this.fields[s][0]?-1:1,n=Xt(e[s],t[s]);if(0!==n)return i*n}return 0}indexOf(e){if(this._table.length>0){let t=0,s=this._table.length-1;for(;t<=s;){const i=Math.floor((t+s)/2),n=this.diff(e,this._table[i].columnValues);if(n>0)t=i+1;else{if(!(n<0))return[i,!0];s=i-1}}return[t,!1]}return[0,!1]}ensure(){return t.__awaiter(this,void 0,void 0,(function*(){const e=Es.get(this.dbname),t=yield e.find(this._store,this.indexerKey,fs.PERSISTENT);if(t)this._origin=t.value,this._table=Jt(this._origin);else{const t=ps(this.dbname,this.collectionName),s=yield this._store.getAllKeys();for(const i of s)if(i.startsWith(t)){const t=yield e.find(this._store,i,fs.NO_CACHE),s=bs.createFromCacheItem(t);if(s)for(const e of s.items)this._addItem(e)}this._transaction.requestWrite({key:this.indexerKey,value:this._table},{persistent:!0})}Ms[this.indexerKey]=this}))}drop(){return t.__awaiter(this,void 0,void 0,(function*(){Es.get(this.dbname).remove(this.indexerKey),yield this._store.remove(this.indexerKey),delete Ms[this.indexerKey]}))}addItem(e){return t.__awaiter(this,void 0,void 0,(function*(){this._addItem(e)&&this._transaction.requestWrite({key:this.indexerKey,value:this._table},{persistent:!0})}))}removeItem(e){return t.__awaiter(this,void 0,void 0,(function*(){this._removeItem(e)&&this._transaction.requestWrite({key:this.indexerKey,value:this._table},{persistent:!0})}))}clear(){return t.__awaiter(this,void 0,void 0,(function*(){this._table=[],this._transaction.requestWrite({key:this.indexerKey,value:this._table},{persistent:!0})}))}commit(){this._origin=this._table,this._table=Jt(this._origin)}abort(){this._table=Jt(this._origin)}}const Cs=()=>"undefined"!=typeof document&&"undefined"!=typeof navigator&&"ReactNative"!==navigator.product,ws=()=>{let e=(new Date).getTime();return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,(t=>{const s=(e+16*Math.random())%16|0;return e=Math.floor(e/16),("x"===t?s:3&s|8).toString(16)}))};var Ns,Ps;!function(e){e[e.PROCESSING=0]="PROCESSING",e[e.DONE=1]="DONE"}(Ns||(Ns={})),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"}(Ps||(Ps={}));const Us={};class Rs{constructor(e,t={}){return this._state=Ns.PROCESSING,this._queue=[],this._activationQueue=[],Us[e]&&!t.forceCreate||(this.nodeId=ws(),this.key=e,Cs()&&(t.startAsInvisible?this.registerNode():"visible"===document.visibilityState?this.claimHost():this.registerNode(),document.addEventListener("visibilitychange",(()=>{"visible"===document.visibilityState&&this.claimHost()})),window.addEventListener("message",(e=>{const t=e.data,{nodeId:s,requestId:i,key:n,op:a,data:r}=t;if(s!==this.nodeId&&n===this.key)switch(a){case Ps.NEWNODE:this._sendSync();break;case Ps.CLAIM_HOST:this._sendSync(),this._hostId=s;break;case Ps.SYNC_HOST:if(!this.isInSync){this._activationTimeout&&clearTimeout(this._activationTimeout);const{currentItemRequestId:e,queue:t}=r;for(const e of t){this._queue.findIndex((t=>t.requestId===e.requestId))<0&&this._requestLock({nodeId:e.nodeId,requestId:e.requestId,key:this.key,op:Ps.REQUEST_LOCK,ts:e.ts})}this._currentItem=this._queue.find((t=>t.requestId===e)),this._completeSync()}break;case Ps.REMOVENODE:this._queue=this._queue.filter((e=>e.nodeId!==t.nodeId)),this._currentItem&&this._currentItem.nodeId===t.nodeId&&(this._currentItem=void 0,this._acquire(this._queue[0]));break;case Ps.REQUEST_LOCK:this._requestLock(t);break;case Ps.ACQUIRE_LOCK:{const e=this._queue.find((e=>e.requestId===i));this._acquire(e);break}case Ps.RELEASE_LOCK:this._release(i)}})),window.addEventListener("beforeunload",(()=>{this._send(Ps.REMOVENODE)}))),Us[e]=this),Us[e]}get locked(){return!!this._currentItem}get isHost(){return this._hostId===this.nodeId}get isInSync(){return this._state==Ns.DONE}_send(e,t={}){var s;const i={nodeId:this.nodeId,requestId:null!==(s=null==t?void 0:t.requestId)&&void 0!==s?s:ws(),key:this.key,op:e,data:t.data,ts:Date.now()};return Cs()&&window.postMessage(i,"*"),i}_acquire(e){e?(this._currentItem=e,this._currentItem.onAcquired&&this._currentItem.onAcquired(e.requestId)):this._currentItem=void 0}_release(e){if(this._currentItem&&this._currentItem.requestId===e){const t=this._currentItem;this._currentItem=void 0,t.nodeId===this.nodeId&&this._send(Ps.RELEASE_LOCK,{requestId:t.requestId});const s=this._queue.findIndex((t=>t.requestId===e));s>-1&&this._queue.splice(s,1),t.onReleased&&t.onReleased(e)}}_requestLock(e){return new Promise((t=>{const s={nodeId:e.nodeId,requestId:e.requestId,ts:e.ts,onAcquired:e=>{this.isHost&&this._send(Ps.ACQUIRE_LOCK,{requestId:e}),t()},onReleased:()=>{this._acquire(this._queue[0])}};let i=!1;for(const e in this._queue)if(this._queue[e].ts>s.ts){this._queue.splice(parseInt(e),0,s),i=!0;break}i||this._queue.push(s),this._currentItem||this._acquire(this._queue[0])}))}_sendSync(){var e;this.isHost&&this._send(Ps.SYNC_HOST,{data:{currentItemRequestId:null===(e=this._currentItem)||void 0===e?void 0:e.requestId,queue:this._queue.map((e=>({nodeId:e.nodeId,requestId:e.requestId,ts:e.ts})))}})}_waitUntilSyncCompleted(){return t.__awaiter(this,void 0,void 0,(function*(){if(this.isHost&&!this.isInSync)return new Promise((e=>{this._activationQueue.push(e)}))}))}_waitSync(){this.isInSync||(this._activationTimeout=setTimeout((()=>{this._completeSync()}),8))}_completeSync(){this.isInSync||(this._state=Ns.DONE,this._activationQueue.forEach((e=>e())),this._activationQueue=[])}registerNode(){this._send(Ps.NEWNODE),this._waitSync()}claimHost(){this._hostId=this.nodeId,this._send(Ps.CLAIM_HOST),this._waitSync()}lock(){return t.__awaiter(this,void 0,void 0,(function*(){yield this._waitUntilSyncCompleted();const e=this._send(Ps.REQUEST_LOCK);yield this._requestLock(e)}))}unlock(){var e;(null===(e=this._currentItem)||void 0===e?void 0:e.requestId)&&this._release(this._currentItem.requestId)}}class xs{constructor({dbname:e,collectionName:t,keyName:s,keyHash:i,indexes:n,store:a}){this._state=Wt.INIT,this._indexers=[],this.dbname=e,this.name=t,this.keyName=s,this.indexes=[[s],...n.filter((e=>As.createKey(e)!==this.keyName))],this._keyHash=i,this._store=a,this._mutex=new Rs(((e,t)=>`${cs(e,t)}.lock`)(e,t)),this._blobContainer=new _s({dbname:e,collectionName:t,store:a}),this._transaction=new Ts({dbname:e,collectionName:t,store:a})}static metadataOf(e,s,i){return t.__awaiter(this,void 0,void 0,(function*(){const t=hs(e,s);return yield i.get(t)}))}get state(){return this._state}get isReady(){return this._state===Wt.READY}init(){return t.__awaiter(this,void 0,void 0,(function*(){yield this._mutex.lock();try{const e=Gt.get(this.dbname),t=yield xs.metadataOf(this.dbname,this.name,this._store);this._metadata=t||{keyName:this.keyName,blockLevel:1,blockHashBase:e.blockHashBase,blockHashMultiplier:e.blockHashMultiplier,blockHashConstant:e.blockHashConstant,indexes:this.indexes},yield this._transaction.init(),this._blockManager=new Ss({dbname:this.dbname,collectionName:this.name,hashFunction:this._keyHash,metadata:this._metadata,transaction:this._transaction,store:this._store});const s=[...this.indexes],i=[],n=s.map((e=>As.createKey(e))),a=t?t.indexes.map((e=>As.createKey(e))):[];for(const e of a)n.includes(e)||i.push(As.parseKey(e));const r=[];if(r.push(...s.map((e=>{const t=new As({dbname:this.dbname,collectionName:this.name,keyName:this.keyName,fields:e,transaction:this._transaction,store:this._store});return this._indexers.push(t),t.ensure()}))),r.push(...i.map((e=>new As({dbname:this.dbname,collectionName:this.name,keyName:this.keyName,fields:e,transaction:this._transaction,store:this._store}).drop()))),yield Promise.all(r),yield this._transaction.commit(),n.sort().join(",")!==a.sort().join(",")){const e=hs(this.dbname,this.name);this._metadata.indexes=s,yield this._store.set({key:e,value:this._metadata})}this._state=Wt.READY,this._mutex.unlock()}catch(e){throw this._mutex.unlock(),e}}))}close(){this._state=Wt.CLOSED}_hasPropertyOfKeyName(e){const t=e[this.keyName];return"string"==typeof t&&!!t}_getIndexerBy(e=null){e||(e=[this.keyName]);const t=As.createKey(e);for(const e of this._indexers)if(t===As.createKey(e.fields))return e;throw Yt.indexTableIsRequired}_upgradeBlockLevel(){return t.__awaiter(this,void 0,void 0,(function*(){const e=hs(this.dbname,this.name);this._metadata.blockLevel++,yield this._store.set({key:e,value:this._metadata})}))}_requestInsert(e){return t.__awaiter(this,void 0,void 0,(function*(){const t=e[this.keyName];if(yield this._blockManager.getFromBlock(t))throw Yt.collectionInsertDuplicate;(yield this._blockManager.putToBlock(t,e))||(yield this._upgradeBlockLevel(),yield this._blockManager.putToBlock(t,e));for(const t of this._indexers)yield t.addItem(e)}))}_requestUpsert(e){return t.__awaiter(this,void 0,void 0,(function*(){const t=e[this.keyName],s=yield this._blockManager.getFromBlock(t);if(s){yield this._blockManager.putToBlock(t,e);for(const t of this._indexers)0!==t.diff(t.getColumnValues(s),t.getColumnValues(e))&&(yield t.removeItem(s),yield t.addItem(e))}else{(yield this._blockManager.putToBlock(t,e))||(yield this._upgradeBlockLevel(),yield this._blockManager.putToBlock(t,e));for(const t of this._indexers)yield t.addItem(e)}}))}_requestUpdate(e){return t.__awaiter(this,void 0,void 0,(function*(){const t=e[this.keyName],s=yield this._blockManager.getFromBlock(t);if(s){yield this._blockManager.putToBlock(t,e);for(const t of this._indexers)0!==t.diff(t.getColumnValues(s),t.getColumnValues(e))&&(yield t.removeItem(s),yield t.addItem(e))}}))}_requestRemove(e){return t.__awaiter(this,void 0,void 0,(function*(){const t=yield this._blockManager.getFromBlock(e);if(t){yield this._blockManager.removeFromBlock(e);for(const e of this._indexers)yield e.removeItem(t)}}))}_requestClear(){return t.__awaiter(this,void 0,void 0,(function*(){yield this._blockManager.clearAllBlocks();for(const e of this._indexers)yield e.clear()}))}getByKey(e){return t.__awaiter(this,void 0,void 0,(function*(){if(!this.isReady)throw Yt.collectionNotReady;yield this._mutex.lock();try{const t=yield this._blockManager.getFromBlock(e);return this._mutex.unlock(),Jt(t)}catch(e){throw this._mutex.unlock(),e}}))}query(e={}){if(this.isReady)return new ds({condition:e.where,mutex:this._mutex,blockManager:this._blockManager,indexer:this._getIndexerBy(e.index),backward:!!e.backward});throw Yt.collectionNotReady}insertOne(e){return t.__awaiter(this,void 0,void 0,(function*(){if(!this.isReady)throw Yt.collectionNotReady;yield this._mutex.lock();try{if(!this._hasPropertyOfKeyName(e))throw Yt.collectionKeyNotGiven;return yield this._requestInsert(Jt(e)),yield this._transaction.commit(),this._mutex.unlock(),e}catch(e){throw yield this._transaction.clear(),this._mutex.unlock(),e}}))}insertMany(e){return t.__awaiter(this,void 0,void 0,(function*(){if(!this.isReady)throw Yt.collectionNotReady;yield this._mutex.lock();try{if(e.some((e=>!this._hasPropertyOfKeyName(e))))throw Yt.collectionKeyNotGiven;for(const t of e)yield this._requestInsert(Jt(t));return yield this._transaction.commit(),this._mutex.unlock(),e}catch(e){throw yield this._transaction.clear(),this._mutex.unlock(),e}}))}upsertOne(e){return t.__awaiter(this,void 0,void 0,(function*(){if(!this.isReady)throw Yt.collectionNotReady;yield this._mutex.lock();try{if(!this._hasPropertyOfKeyName(e))throw Yt.collectionKeyNotGiven;return yield this._requestUpsert(Jt(e)),yield this._transaction.commit(),this._mutex.unlock(),e}catch(e){throw yield this._transaction.clear(),this._mutex.unlock(),e}}))}upsertMany(e){return t.__awaiter(this,void 0,void 0,(function*(){if(!this.isReady)throw Yt.collectionNotReady;yield this._mutex.lock();try{if(e.some((e=>!this._hasPropertyOfKeyName(e))))throw Yt.collectionKeyNotGiven;for(const t of e)yield this._requestUpsert(Jt(t));return yield this._transaction.commit(),this._mutex.unlock(),e}catch(e){throw yield this._transaction.clear(),this._mutex.unlock(),e}}))}update(e){return t.__awaiter(this,void 0,void 0,(function*(){if(!this.isReady)throw Yt.collectionNotReady;yield this._mutex.lock();try{if(!this._hasPropertyOfKeyName(e))throw Yt.collectionKeyNotGiven;return yield this._requestUpdate(Jt(e)),yield this._transaction.commit(),this._mutex.unlock(),e}catch(e){throw yield this._transaction.clear(),this._mutex.unlock(),e}}))}updateIf(e,s){return t.__awaiter(this,void 0,void 0,(function*(){if(!this.isReady)throw this._transaction.clear(),Yt.collectionNotReady;yield this._mutex.lock();try{const{where:i={},index:n=null,backward:a=!1}=e,r=[],o=new ls({condition:i,blockManager:this._blockManager,backward:a,indexer:this._getIndexerBy(n)});yield o.each((e=>t.__awaiter(this,void 0,void 0,(function*(){if(e.error)throw e.stop(),e.error;if(e.hasNext){const t=e.nextValue;if(ts(i,t)&&s.set){if("function"!=typeof s.set)for(const e in s.set)t[e]=s.set[e];else s.set(t);r.push(t)}e.next()}else e.stop()}))));for(const e of r)yield this._requestUpdate(Jt(e));return yield this._transaction.commit(),this._mutex.unlock(),r}catch(e){throw yield this._transaction.clear(),this._mutex.unlock(),e}}))}remove(e){return t.__awaiter(this,void 0,void 0,(function*(){if(!this.isReady)throw Yt.collectionNotReady;yield this._mutex.lock();try{yield this._requestRemove(e),yield this._transaction.commit(),this._mutex.unlock()}catch(e){throw yield this._transaction.clear(),this._mutex.unlock(),e}}))}removeIf(e){return t.__awaiter(this,void 0,void 0,(function*(){if(!this.isReady)throw this._transaction.clear(),Yt.collectionNotReady;yield this._mutex.lock();try{const{where:s={},index:i=null,backward:n=!1}=e,a=[],r=new ls({condition:s,blockManager:this._blockManager,backward:n,indexer:this._getIndexerBy(i)});yield r.each((e=>t.__awaiter(this,void 0,void 0,(function*(){if(e.error)throw e.stop(),e.error;if(e.hasNext){const t=e.nextValue;if(ts(s,t)){const e=t[this.keyName];a.push(e)}e.next()}else e.stop()}))));for(const e of a)yield this._requestRemove(e);return yield this._transaction.commit(),this._mutex.unlock(),a}catch(e){throw this._mutex.unlock(),e}}))}clear(){return t.__awaiter(this,void 0,void 0,(function*(){if(!this.isReady)throw Yt.collectionNotReady;yield this._mutex.lock();try{yield this._requestClear(),yield this._transaction.commit(),this._mutex.unlock()}catch(e){throw yield this._transaction.clear(),this._mutex.unlock(),e}}))}getBlob(e){return t.__awaiter(this,void 0,void 0,(function*(){return yield this._blobContainer.get(e)}))}saveBlob(e,s){return t.__awaiter(this,void 0,void 0,(function*(){return yield this._blobContainer.save(e,s)}))}removeBlob(e){return t.__awaiter(this,void 0,void 0,(function*(){yield this._blobContainer.remove(e)}))}removeAllBlobs(){return t.__awaiter(this,void 0,void 0,(function*(){yield this._blobContainer.clear()}))}}const Ls="[NESTDB]";let ks=!0;class Ds{static off(){ks=!1}static log(...e){ks&&console.log(`${Ls}[LOG]`,...e)}static warning(...e){ks&&console.warn(`${Ls}[WARNING]`,...e)}static error(...e){ks&&console.error(`${Ls}[ERROR]`,...e)}}const qs=[{},{a:700400,n:"error"}];class Fs{constructor(e){var s,i,n;this.encryption=null!==(s=e.encryption)&&void 0!==s?s:t.DEFAULT_ENCRYPTION,this.itemSizeLimit=null!==(i=e.itemSizeLimit)&&void 0!==i?i:4194304,this.metadataBuffer=null!==(n=e.metadataBuffer)&&void 0!==n?n:256}get _encryptionCheckKey(){return`${this.dbname}.encrypt`}get _reservedKeys(){return[this._encryptionCheckKey]}_getRawKey(e,t=""){return`${e}${t}`}_generateShardPostfixArray(e=1){return[...Array(e).keys()]}_shardify(e){const{key:t,value:s}=e,i=JSON.stringify(this.encryption.encrypt(s)),n=Math.ceil(i.length/this.adjustedItemSizeLimit);return this._generateShardPostfixArray(n).map((e=>{const s={key:this._getRawKey(t,`.${e}`),data:i.substring(e*this.adjustedItemSizeLimit,(e+1)*this.adjustedItemSizeLimit)};return 0===e&&(s.metadata={shards:n}),s}))}_resetIfEncryptionChanged(){return t.__awaiter(this,void 0,void 0,(function*(){const e=yield this.get(this._encryptionCheckKey),t={encrypted:qs.map((e=>{var t;return null===(t=this.encryption)||void 0===t?void 0:t.encrypt(e)}))};if(e&&e.encrypted&&Array.isArray(e.encrypted))for(const s in e.encrypted){if(JSON.stringify(e.encrypted[s])!==JSON.stringify(t.encrypted[s])){Ds.warning("Encryption algorithm has changed. Stored data would be cleared."),yield this.clear();break}}else e||(yield this.clear());yield this.set({key:this._encryptionCheckKey,value:t})}))}get adjustedItemSizeLimit(){return Math.max(this.itemSizeLimit-this.metadataBuffer,4)}usage(){return t.__awaiter(this,void 0,void 0,(function*(){let e=0;const t=yield this._getAllRawKeys();for(const s of t){const t=yield this._getRaw(s);t&&(e+=JSON.stringify(t).length)}return e}))}getAllKeys(){return t.__awaiter(this,void 0,void 0,(function*(){return(yield this._getAllRawKeys()).filter((e=>e.endsWith(".0"))).map((e=>e.replace(/\.0$/,""))).filter((e=>!this._reservedKeys.includes(e)))}))}get(e){return t.__awaiter(this,void 0,void 0,(function*(){const s=this._getRawKey(e,".0"),i=yield this._getRaw(s);if(i)try{const{data:s,metadata:n}=i,a=(null==n?void 0:n.shards)&&n.shards>1?yield Promise.all(this._generateShardPostfixArray(null==n?void 0:n.shards).map((i=>t.__awaiter(this,void 0,void 0,(function*(){if(i>0){const t=this._getRawKey(e,`.${i}`),s=yield this._getRaw(t);if(!s)throw Yt.storeBrokenIntegrity;return s.data}return s}))))):[s];return this.encryption.decrypt(JSON.parse(a.join("")))}catch(e){return null}return null}))}set(e){return t.__awaiter(this,void 0,void 0,(function*(){const t=this._shardify(e);return yield this._setRaw(t),Object.assign({},e.value)}))}setMany(e){return t.__awaiter(this,void 0,void 0,(function*(){return yield this._setRaw([].concat(...e.map((e=>this._shardify(e))))),e.map((e=>e.value))}))}remove(e){return t.__awaiter(this,void 0,void 0,(function*(){const t=this._getRawKey(e,".0"),s=yield this._getRaw(t);if(s){const{metadata:t}=s;return yield this._removeRaw(this._generateShardPostfixArray(null==t?void 0:t.shards).map((t=>this._getRawKey(e,`.${t}`)))),!0}return!1}))}removeMany(e){return t.__awaiter(this,void 0,void 0,(function*(){const t=[];for(const s of e){const e=this._getRawKey(s,".0"),i=yield this._getRaw(e);if(i){const{metadata:e}=i;t.push(...this._generateShardPostfixArray(null==e?void 0:e.shards).map((e=>this._getRawKey(s,`.${e}`))))}}return t.length>0&&(yield this._removeRaw(t)),e}))}}const Bs=1,js={};class zs extends Fs{constructor(e={}){var t;super(Object.assign(Object.assign({},e),{itemSizeLimit:null!==(t=e.itemSizeLimit)&&void 0!==t?t:4194304}));const{delay:s=Bs}=e;this.delay=s,this.observer={}}get rawData(){return js[this.dbname]}set rawData(e){js[this.dbname]=e}_getAllRawKeys(){return t.__awaiter(this,void 0,void 0,(function*(){if(js[this.dbname])return Object.keys(js[this.dbname]);throw Yt.storeNotAvailable}))}_getRaw(e){return t.__awaiter(this,void 0,void 0,(function*(){if(js[this.dbname])return yield es(this.delay),js[this.dbname][e]?Object.assign({key:e},js[this.dbname][e]):null;throw Yt.storeNotAvailable}))}_setRaw(e){return t.__awaiter(this,void 0,void 0,(function*(){if(!js[this.dbname])throw Yt.storeNotAvailable;yield es(this.delay);for(const t of e){const{key:e,data:s,metadata:i}=t;js[this.dbname][e]=Object.freeze({data:s,metadata:i})}}))}_removeRaw(e){return t.__awaiter(this,void 0,void 0,(function*(){if(!js[this.dbname])throw Yt.storeNotAvailable;yield es(this.delay);for(const t of e)js[this.dbname][t]&&delete js[this.dbname][t]}))}observe(e,t,s){this.observer[e]||(this.observer[e]={}),t.forEach((t=>this.observer[e][t]=s))}checkAvailability(){return t.__awaiter(this,void 0,void 0,(function*(){}))}init(e){return t.__awaiter(this,void 0,void 0,(function*(){this.dbname=e,js[this.dbname]||(js[this.dbname]={}),yield this._resetIfEncryptionChanged()}))}set(e){const s=Object.create(null,{set:{get:()=>super.set}});return t.__awaiter(this,void 0,void 0,(function*(){const t=this.observer[e.key];if(t&&"function"==typeof t.set){const e=t.set();if(e)throw e}return s.set.call(this,e)}))}setMany(e){const s=Object.create(null,{setMany:{get:()=>super.setMany}});return t.__awaiter(this,void 0,void 0,(function*(){for(const t of e){const e=this.observer[t.key];if(e&&"function"==typeof e.set){const t=e.set();if(t)throw t}}return s.setMany.call(this,e)}))}clear(){return t.__awaiter(this,void 0,void 0,(function*(){yield es(this.delay),js[this.dbname]={}}))}}const Vs="NestDBStore";var $s;!function(e){e[e.UNINITIALIZED=0]="UNINITIALIZED",e[e.OPENING=1]="OPENING",e[e.OPEN=2]="OPEN",e[e.CLOSED=3]="CLOSED"}($s||($s={}));var Qs,Ks;exports.NestDBState=void 0,(Qs=exports.NestDBState||(exports.NestDBState={})).INIT="INIT",Qs.OPENING="OPENING",Qs.OPENED="OPENED",Qs.CLOSED="CLOSED";class Gs{constructor(){this.messageTypeFilter=t.MessageTypeFilter.ALL,this.customTypesFilter=null,this.senderUserIdsFilter=null,this.replyType=t.ReplyType.NONE}clone(){const e=new Gs,t=JSON.parse(JSON.stringify(this));return Object.keys(t).forEach((s=>{e[s]=t[s]})),e}match(e){switch(this.messageTypeFilter){case t.MessageTypeFilter.USER:if(e.messageType!==t.MessageType.USER)return!1;break;case t.MessageTypeFilter.FILE:if(e.messageType!==t.MessageType.FILE)return!1;break;case t.MessageTypeFilter.ADMIN:if(e.messageType!==t.MessageType.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}switch(this.replyType){case t.ReplyType.NONE:if(e.parentMessageId>0)return!1;break;case t.ReplyType.ONLY_REPLY_TO_CHANNEL:if(e instanceof g&&e.parentMessageId>0&&!e.replyToChannel)return!1}return!0}}exports.MessageListOrder=void 0,(Ks=exports.MessageListOrder||(exports.MessageListOrder={})).CHANNEL_LATEST="channel_latest",Ks.NEWEST_CHILD_MESSAGE="newest_child_message";const Hs=e=>{switch(e){case exports.MessageListOrder.CHANNEL_LATEST:return["channelUrl","-createdAt","-messageId"];case exports.MessageListOrder.NEWEST_CHILD_MESSAGE:return["channelUrl","-parentMessageId","-createdAt","-messageId"]}},Ws=Object.assign(Object.assign({},Z),{scheduledAt:void 0}),Ys=Object.assign(Object.assign({},Y),{scheduledAt:0,file:void 0,fileUrl:void 0,fileName:void 0,mimeType:void 0,fileSize:void 0,thumbnailSizes:void 0,requireAuth:!1}),Js="UnsentMessage",Xs={};class Zs extends t.InstancedObject{get _cacheContext(){return t.Vault.of(this._iid).cacheContext}constructor(e){super(e),this._mutex=new Rs("unsendmessagecache.lock"),Xs[e]=this}static of(e,t=!1){return Xs[e]&&!t||(Xs[e]=new Zs(e)),Xs[e]}get collection(){const{nestdb:e}=this._cacheContext,s=null==e?void 0:e.collection(Js);if(!s)throw t.SendbirdError.databaseError;return s}get localCacheEnabled(){const{localCacheEnabled:e}=this._cacheContext;return e&&!!this.collection}_serialize(e){if(e.messageId>0)throw t.SendbirdError.invalidParameters;const s=Object.assign({},e.serialize());var i;return e instanceof T?(e.messageParams&&(s.messageParams=X(e.messageParams)),e.scheduledInfo&&e.scheduledInfo.scheduledMessageParams&&(s.scheduledInfo.scheduledMessageParams=(i=e.scheduledInfo.scheduledMessageParams,Object.assign(Object.assign({},X(i)),{scheduledAt:i.scheduledAt})))):e instanceof M?(e.messageParams&&(s.messageParams=re(e.messageParams)),e.scheduledInfo&&e.scheduledInfo.scheduledMessageParams&&(s.scheduledInfo.scheduledMessageParams=(e=>Object.assign(Object.assign({},re(e)),{scheduledAt:e.scheduledAt}))(e.scheduledInfo.scheduledMessageParams))):e instanceof S&&e.messageParams&&(s.messageParams=(e=>t.deundefined({fileInfoList:e.fileInfoList,isReplyToChannel:e.isReplyToChannel,pushNotificationDeliveryOption:e.pushNotificationDeliveryOption}))(e.messageParams)),s}_deserialize(e){e=Object.assign(Object.assign({},e),{messageId:parseInt(e.messageId)});return ai.of(this._iid).buildMessageFromSerializedData(e)}_deserializeWithMessageCreateParams(e){var s,i,n;return t.__awaiter(this,void 0,void 0,(function*(){const a=ai.of(this._iid),r=this._deserialize(e);if(e.messageParams)if(r instanceof T){const t=e.messageParams;r.messageParams=a.buildUserMessageCreateParamsFromSerializedData(t,r)}else if(r instanceof M){const t=e.messageParams;t.fileKey&&"string"==typeof t.fileKey&&ae(null!==(s=t.fileType)&&void 0!==s?s:"")&&(t.file=null!==(i=yield this.collection.getBlob(t.fileKey))&&void 0!==i?i:void 0),r.messageParams=a.buildFileMessageCreateParamsFromSerializedData(t,r)}else if(r instanceof S){const s=e.messageParams;s&&s.fileInfoList&&(r.messageParams=a.buildMultipleFilesMessageCreateParamsFromSerializedData(s,r),yield Promise.all(r.messageParams.fileInfoList.map((e=>t.__awaiter(this,void 0,void 0,(function*(){var t,s,i,n;"string"==typeof(null===(t=e._uploadedMetaData)||void 0===t?void 0:t.fileKey)&&ae(null!==(i=null===(s=e._uploadedMetaData)||void 0===s?void 0:s.fileType)&&void 0!==i?i:"")&&(e.file=null!==(n=yield this.collection.getBlob(e._uploadedMetaData.fileKey))&&void 0!==n?n:void 0)}))))))}if(r.scheduledInfo&&e.scheduledInfo&&e.scheduledInfo.scheduledMessageParams)if(r instanceof T){const t=e.scheduledInfo.scheduledMessageParams;r.scheduledInfo.scheduledMessageParams=a.buildScheduledUserMessageCreateParamsFromSerializedData(t,r)}else if(r instanceof M){const t=e.scheduledInfo.scheduledMessageParams;t.fileKey&&"string"==typeof t.fileKey&&"string"==typeof t.fileType&&ae(t.fileType)&&(t.file=null!==(n=yield this.collection.getBlob(t.fileKey))&&void 0!==n?n:void 0),r.scheduledInfo.scheduledMessageParams=a.buildScheduledFileMessageCreateParamsFromSerializedData(t,r)}return r}))}_getFileInfoBlobKey(e,t){return`${e}.${t}`}get(e){return t.__awaiter(this,void 0,void 0,(function*(){if(this.localCacheEnabled){const t=yield this.collection.getByKey(`${e}`);if(t)return this._deserializeWithMessageCreateParams(t)}}))}fetch({channelUrl:e,filter:s=new Gs,order:i=exports.MessageListOrder.CHANNEL_LATEST,sendingStatus:n,backward:a=!1,parentMessageId:r}){return t.__awaiter(this,void 0,void 0,(function*(){if(this.localCacheEnabled){const o=Hs(i),l={"/where":e=>!!(i!==exports.MessageListOrder.NEWEST_CHILD_MESSAGE||r&&0!==e.parentMessageId&&e.parentMessageId===r)&&s.match(this._deserialize(e))};e&&(l.channelUrl=e),n&&(l.sendingStatus=n);const d={where:l,index:o,backward:a},u=yield this.collection.query(d),c=yield u.fetch({});return Promise.all(c.map((e=>t.__awaiter(this,void 0,void 0,(function*(){return yield this._deserializeWithMessageCreateParams(e)})))))}return[]}))}getAllChildMessages(e,s=new Gs){return t.__awaiter(this,void 0,void 0,(function*(){return yield this.fetch({filter:s,order:exports.MessageListOrder.NEWEST_CHILD_MESSAGE,channelUrl:e.channelUrl,backward:!1,parentMessageId:e.messageId})}))}upsert(e){return t.__awaiter(this,void 0,void 0,(function*(){this.localCacheEnabled&&(yield Promise.all(e.map((e=>t.__awaiter(this,void 0,void 0,(function*(){(e instanceof M||e instanceof S)&&(yield this._mutex.lock(),yield this.saveBlob(e),yield this._mutex.unlock());const t=this._serialize(e);yield this.collection.upsertOne(t)}))))))}))}upsertChildMessages(e){return t.__awaiter(this,void 0,void 0,(function*(){this.localCacheEnabled&&(yield Promise.all(e.map((e=>t.__awaiter(this,void 0,void 0,(function*(){let t=[];e.threadInfo&&e.threadInfo.replyCount>0&&(t=yield this.getAllChildMessages(e)),t.length>0&&(t.forEach((t=>t.applyParentMessage(e))),yield this.upsert(t))}))))))}))}remove(e){return t.__awaiter(this,void 0,void 0,(function*(){if(this.localCacheEnabled)for(const t of e)yield this.collection.remove(t)}))}removeMessagesOfChannel(e){return t.__awaiter(this,void 0,void 0,(function*(){this.localCacheEnabled&&(yield this.collection.removeIf({where:{channelUrl:e}}))}))}clear(){return t.__awaiter(this,void 0,void 0,(function*(){this.localCacheEnabled&&(yield this.collection.clear())}))}saveBlob(e){return t.__awaiter(this,void 0,void 0,(function*(){if(e instanceof M){if(e.messageParams){const t=e.messageParams;if(t.file&&ne(t.file)){const s=yield this.collection.saveBlob(t.file,e.reqId);t.fileKey=s,t.fileType=ie.BLOB}}if(e.scheduledInfo&&e.scheduledInfo.scheduledMessageParams){const t=e.scheduledInfo.scheduledMessageParams;if(t.file&&ne(t.file)){const s=yield this.collection.saveBlob(t.file,e.reqId);t.fileKey=s,t.fileType=ie.BLOB}}}else if(e instanceof S){const s=e.messageParams;s&&s.fileInfoList&&Array.isArray(s.fileInfoList)&&(yield Promise.all(s.fileInfoList.map(((s,i)=>t.__awaiter(this,void 0,void 0,(function*(){if(s.file&&ne(s.file)){const t=yield this.collection.saveBlob(s.file,this._getFileInfoBlobKey(e.reqId,i));s._uploadedMetaData||(s._uploadedMetaData={}),s._uploadedMetaData.fileKey=t,s._uploadedMetaData.fileType=ie.BLOB}}))))))}}))}}const ei={};class ti extends t.InstancedObject{get _sdkState(){return t.Vault.of(this._iid).sdkState}get _cacheContext(){return t.Vault.of(this._iid).cacheContext}get _unsentMessageCache(){return Zs.of(this._iid)}constructor(e){super(e),ei[e]=this}static of(e,t=!1){return ei[e]&&!t||(ei[e]=new ti(e)),ei[e]}get collection(){const{nestdb:e}=this._cacheContext;return t.unless(!!e).throw(t.SendbirdError.databaseError),e.collection(Bt)}get localCacheEnabled(){const{localCacheEnabled:e}=this._cacheContext;return e&&!!this.collection}_serialize(e){return Object.assign(Object.assign({},e.serialize()),{messageId:`${e.messageId}`})}_deserialize(e){e=Object.assign(Object.assign({},e),{messageId:parseInt(e.messageId)});return ai.of(this._iid).buildMessageFromSerializedData(e)}get(e){return t.__awaiter(this,void 0,void 0,(function*(){if(this.localCacheEnabled){const t=yield this.collection.getByKey(`${e}`);if(t)return this._deserialize(t)}}))}fetch({channelUrl:e,token:s,limit:i=100,filter:n=new Gs,order:a=exports.MessageListOrder.CHANNEL_LATEST,backward:r=!1,parentMessageId:o,isPollOnly:l=!1,exactMatch:d=!1,inclusive:u=!0}){return t.__awaiter(this,void 0,void 0,(function*(){if(this.localCacheEnabled){const c=Hs(a),h={where:{channelUrl:e,"/where":e=>{if(s)switch(a){case exports.MessageListOrder.CHANNEL_LATEST:if(d&&e.createdAt!==s)return!1;if(r){if(u&&e.createdAts||!u&&e.createdAt>=s)return!1;break;case exports.MessageListOrder.NEWEST_CHILD_MESSAGE:if(!o||0===e.parentMessageId||e.parentMessageId!==o)return!1}return!(l&&!e._poll)&&n.match(this._deserialize(e))}},index:c,backward:r},p=yield this.collection.query(h),m=yield p.fetch({limit:null!=i?i:void 0});return Promise.all(m.map((e=>t.__awaiter(this,void 0,void 0,(function*(){return this._deserialize(e)})))))}return[]}))}getAllChildMessages(e,s=new Gs){return t.__awaiter(this,void 0,void 0,(function*(){return yield this.fetch({channelUrl:e.channelUrl,token:Date.now(),limit:null,backward:!1,filter:s,order:exports.MessageListOrder.NEWEST_CHILD_MESSAGE,parentMessageId:e.messageId})}))}upsert(e){return t.__awaiter(this,void 0,void 0,(function*(){if(this.localCacheEnabled){yield this.saveBlobs(e);const t=e.map((e=>this._serialize(e)));yield this.collection.upsertMany(t),yield this.upsertChildMessages(e),yield this._unsentMessageCache.upsertChildMessages(e)}}))}upsertChildMessages(e){return t.__awaiter(this,void 0,void 0,(function*(){this.localCacheEnabled&&(yield Promise.all(e.map((e=>t.__awaiter(this,void 0,void 0,(function*(){var t;let s=[];(null===(t=e.threadInfo)||void 0===t?void 0:t.replyCount)&&e.threadInfo.replyCount>0&&(s=yield this.getAllChildMessages(e)),s.length>0&&(s.forEach((t=>t.applyParentMessage(e))),yield this.upsert(s))}))))))}))}remove(e){return t.__awaiter(this,void 0,void 0,(function*(){if(this.localCacheEnabled)for(const t of e)yield this.collection.remove(`${t}`)}))}removeMessagesOfChannel(e){return t.__awaiter(this,void 0,void 0,(function*(){if(this.localCacheEnabled){yield this.collection.removeIf({where:{channelUrl:e},index:Hs(exports.MessageListOrder.CHANNEL_LATEST)});const{preference:t}=this._cacheContext;yield t.remove(`sendbird:${this._sdkState.userId}@groupchannel/${e}/message/sync`),yield t.remove(`sendbird:${this._sdkState.userId}@groupchannel/${e}/message/sync.meta`),yield t.remove(`sendbird:${this._sdkState.userId}@groupchannel/${e}/message/changelogs`),yield t.remove(`sendbird:${this._sdkState.userId}@groupchannel/${e}/message/changelogs.meta`)}}))}removeUnderOffset(e,s){return t.__awaiter(this,void 0,void 0,(function*(){this.localCacheEnabled&&(yield this.collection.removeIf({where:{channelUrl:e,createdAt:{"<":s}},index:Hs(exports.MessageListOrder.CHANNEL_LATEST)}))}))}clear(){return t.__awaiter(this,void 0,void 0,(function*(){this.localCacheEnabled&&(yield this.collection.clear())}))}countBetween(e,s,i){return t.__awaiter(this,void 0,void 0,(function*(){if(this.localCacheEnabled){const t=Hs(exports.MessageListOrder.CHANNEL_LATEST),n=this.collection.query({where:{channelUrl:e,"/where":e=>{const t=this._deserialize(e);return i.includes(t.createdAt)&&s.match(t)}},index:t});return yield n.count()}return 0}))}saveBlobs(e){return t.__awaiter(this,void 0,void 0,(function*(){yield Promise.all(e.map((e=>t.__awaiter(this,void 0,void 0,(function*(){if(e instanceof M&&e.messageParams){const t=e.messageParams;if(t.file&&ne(t.file)){const s=yield this.collection.saveBlob(t.file,e.reqId);t.fileKey=s}}})))))}))}_getGroupChannelPreferenceSize(e){return t.__awaiter(this,void 0,void 0,(function*(){let t=0;const{preference:s}=this._cacheContext,i=yield s.get(`sendbird:${this._sdkState.userId}@groupchannel/${e}/message/sync`),n=yield s.get(`sendbird:${this._sdkState.userId}@groupchannel/${e}/message/sync.meta`),a=yield s.get(`sendbird:${this._sdkState.userId}@groupchannel/${e}/message/changelogs`),r=yield s.get(`sendbird:${this._sdkState.userId}@groupchannel/${e}/message/changelogs.meta`);return i&&(t+=JSON.stringify(i).length),n&&(t+=JSON.stringify(n).length),a&&(t+=JSON.stringify(a).length),r&&(t+=JSON.stringify(r).length),t}))}}const si={};class ii extends t.InstancedObject{get _cacheContext(){return t.Vault.of(this._iid).cacheContext}get _dispatcher(){return t.Vault.of(this._iid).dispatcher}get _messageCache(){return ti.of(this._iid)}get _unsentMessageCache(){return Zs.of(this._iid)}constructor(e){super(e),this._observers=new Map,this._dispatcherContext=this._dispatcher.on((e=>t.__awaiter(this,void 0,void 0,(function*(){if(e instanceof t.MessageUpdateEventCommand){const{messages:s,source:i,isWebSocketEventComing:n}=e,a=s.filter((e=>e.messageId>0)),r=s.filter((e=>0===e.messageId));a.length>0&&(yield t.runOrNothing((()=>t.__awaiter(this,void 0,void 0,(function*(){yield this._messageCache.upsert(a),yield this._unsentMessageCache.remove(a.map((e=>e instanceof g?e.reqId:null)).filter((e=>null!==e)))})))),n||this._broadcastUpdateEvent(a,i)),r.length>0&&(yield t.runOrNothing((()=>t.__awaiter(this,void 0,void 0,(function*(){yield this._unsentMessageCache.upsert(r)})))),n||this._broadcastUpdateEvent(r,i))}else if(e instanceof t.MessageRemoveEventCommand){const{messageIds:s,source:i,isWebSocketEventComing:n}=e;yield t.runOrNothing((()=>t.__awaiter(this,void 0,void 0,(function*(){yield this._messageCache.remove(s)})))),n||this._broadcastRemoveEvent(s,i)}else if(e instanceof t.UnsentMessageRemoveEventCommand){const{reqId:s,source:i}=e;yield t.runOrNothing((()=>t.__awaiter(this,void 0,void 0,(function*(){yield this._unsentMessageCache.remove([s])})))),this._broadcastRemoveUnsentEvent(s,i)}else if(e instanceof t.PollChangeLogEventCommand){const{polls:s,source:i}=e;if(this._cacheContext.localCacheEnabled){const e=s.map((e=>e.messageId)),i=(yield Promise.all(e.map((e=>this._messageCache.get(e))))).filter((e=>e));i.length>0&&s.forEach((e=>{const t=i.find((t=>t.messageId===e.messageId));t&&t.applyPoll(e)})),yield t.runOrNothing((()=>t.__awaiter(this,void 0,void 0,(function*(){return yield this._messageCache.upsert(i)}))))}this._broadcastPollChangeLogEvent(s,i)}else if(e instanceof t.PollUpdateInternalEventCommand){const{event:s,source:i}=e,n=yield this._messageCache.get(s.messageId);n&&n.isUserMessage()&&n.poll&&n.poll.applyPollUpdateEvent(s)&&(yield t.runOrNothing((()=>t.__awaiter(this,void 0,void 0,(function*(){return yield this._messageCache.upsert([n])}))))),this._broadcastPollUpdateEvent(s,i)}else if(e instanceof t.PollVoteInternalEventCommand){const{event:s,source:i}=e,n=yield this._messageCache.get(s.messageId);n&&n.isUserMessage()&&n.poll&&n.poll.applyPollVoteEvent(s)&&(yield t.runOrNothing((()=>t.__awaiter(this,void 0,void 0,(function*(){return yield this._messageCache.upsert([n])}))))),this._broadcastPollVoteEvent(s,i)}}))))}static of(e,t=!1){var s;return si[e]&&!t||(si[e]&&(null===(s=si[e]._dispatcherContext)||void 0===s||s.close()),si[e]=new ii(e)),si[e]}_broadcastUpdateEvent(e,t){for(const s of this._observers.values())s.onUpdate&&s.onUpdate(e,t)}_broadcastPollChangeLogEvent(e,t){for(const s of this._observers.values())s.onPollChangeLogUpdate&&s.onPollChangeLogUpdate(e,t)}_broadcastPollUpdateEvent(e,t){for(const s of this._observers.values())s.onPollUpdate&&s.onPollUpdate(e,t)}_broadcastPollVoteEvent(e,t){for(const s of this._observers.values())s.onPollVote&&s.onPollVote(e,t)}_broadcastRemoveEvent(e,t){for(const s of this._observers.values())s.onRemove&&s.onRemove(e,t)}_broadcastRemoveUnsentEvent(e,t){for(const s of this._observers.values())s.onRemoveUnsent&&s.onRemoveUnsent(e,t)}subscribe(e,t){this._observers.set(e,t)}unsubscribe(e){this._observers.delete(e)}unsubscribeAll(){this._observers.clear()}}const ni={};class ai{constructor(e,{sdkState:t,dispatcher:s,requestQueue:i,onlineDetector:n,cacheContext:a}){this._iid=e,this._sdkState=t,this._requestQueue=i,this._dispatcher=s,this._cacheContext=a,ti.of(e),Zs.of(e),ii.of(e),this.fileMessageQueue=new R(e,{sdkState:t,dispatcher:s,requestQueue:i,onlineDetector:n,cacheContext:a}),ni[e]=this}static of(e){return ni[e]}buildMessageFromSerializedData(e){const s=t.deserialize(e);switch(s.messageType){case t.MessageType.USER:return new T(this._iid,T.payloadify(s));case t.MessageType.FILE:return S._isMultipleFilesMessageSerializedData(s)?new S(this._iid,S.payloadify(s)):new M(this._iid,M.payloadify(s));case t.MessageType.ADMIN:return new I(this._iid,I.payloadify(s))}throw t.SendbirdError.invalidParameters}buildUserMessageCreateParamsFromSerializedData(e,s){return t.deundefined(t.undefineNullProps({data:s.data,customType:s.customType,mentionType:s.mentionType,mentionedUserIds:s.mentionedUserIds,mentionedUsers:s.mentionedUsers,mentionedMessageTemplate:s.mentionedMessageTemplate,metaArrays:s.metaArrays,parentMessageId:s.parentMessageId,isReplyToChannel:e.isReplyToChannel,pushNotificationDeliveryOption:e.pushNotificationDeliveryOption,appleCriticalAlertOptions:s.appleCriticalAlertOptions,reqId:s.reqId,message:s.message,translationTargetLanguages:Object.keys(s.translations),pollId:e.pollId}))}buildFileMessageCreateParamsFromSerializedData(e,s){var i;return t.deundefined(t.undefineNullProps({data:s.data,customType:s.customType,mentionType:s.mentionType,mentionedUserIds:s.mentionedUserIds,mentionedUsers:s.mentionedUsers,mentionedMessageTemplate:s.mentionedMessageTemplate,metaArrays:s.metaArrays,parentMessageId:s.parentMessageId,isReplyToChannel:e.isReplyToChannel,pushNotificationDeliveryOption:e.pushNotificationDeliveryOption,appleCriticalAlertOptions:s.appleCriticalAlertOptions,reqId:s.reqId,file:e.file,fileKey:e.fileKey,fileUrl:s.plainUrl,fileName:s.name,fileSize:s.size,mimeType:s.type,thumbnailSizes:null===(i=s.thumbnails)||void 0===i?void 0:i.map((e=>({maxWidth:e.width,maxHeight:e.height}))),fileType:e.fileType,requireAuth:s.requireAuth}))}buildMultipleFilesMessageCreateParamsFromSerializedData(e,s){return t.deundefined({data:s.data,customType:s.customType,mentionType:s.mentionType,mentionedUserIds:s.mentionedUserIds,mentionedUsers:s.mentionedUsers,mentionedMessageTemplate:s.mentionedMessageTemplate,metaArrays:s.metaArrays,parentMessageId:s.parentMessageId,isReplyToChannel:e.isReplyToChannel,pushNotificationDeliveryOption:e.pushNotificationDeliveryOption,appleCriticalAlertOptions:s.appleCriticalAlertOptions,reqId:s.reqId,fileInfoList:e.fileInfoList})}buildScheduledUserMessageCreateParamsFromSerializedData(e,t){return Object.assign(Object.assign({},this.buildUserMessageCreateParamsFromSerializedData(e,t)),{scheduledAt:e.scheduledAt})}buildScheduledFileMessageCreateParamsFromSerializedData(e,t){return Object.assign(Object.assign({},this.buildFileMessageCreateParamsFromSerializedData(e,t)),{scheduledAt:e.scheduledAt})}buildSenderFromSerializedData(e){const s=t.deserialize(e);return new c(this._iid,c.payloadify(s))}getMessage(e){return t.__awaiter(this,void 0,void 0,(function*(){const t=new q(e),s=yield this._requestQueue.send(t),{message:i}=s.as(F);return i}))}getScheduledMessage(e){return t.__awaiter(this,void 0,void 0,(function*(){const t=new $(e),s=yield this._requestQueue.send(t),{message:i}=s.as(Q);return i}))}getMessagesByMessageId(e,s,i,n,a=t.CollectionEventSource.REQUEST_MESSAGE){return t.__awaiter(this,void 0,void 0,(function*(){const r=new B(Object.assign(Object.assign({channelType:s,channelUrl:e,token:String(i)},x),n)),o=yield this._requestQueue.send(r),{messages:l}=o.as(j);return this._dispatcher.dispatch(new t.MessageUpdateEventCommand({messages:l,source:a})),l}))}getMessagesByTimestamp(e,s,i,n,a=t.CollectionEventSource.REQUEST_MESSAGE){return t.__awaiter(this,void 0,void 0,(function*(){const r=new B(Object.assign(Object.assign({channelType:s,channelUrl:e,timestamp:i},x),n)),o=yield this._requestQueue.send(r),{messages:l}=o.as(j);return this._dispatcher.dispatch(new t.MessageUpdateEventCommand({messages:l,source:a})),l}))}_getMessagesByTimestampForCollection(e,s,i,n,a=t.CollectionEventSource.REQUEST_MESSAGE,r,o){return t.__awaiter(this,void 0,void 0,(function*(){const l=new B(Object.assign(Object.assign(Object.assign({channelType:s,channelUrl:e,timestamp:i},x),n),{checkingHasNext:r,checkingContinuousMessages:o})),d=yield this._requestQueue.send(l),{messages:u,isContinuousMessages:c,hasNext:h}=d.as(j);return this._dispatcher.dispatch(new t.MessageUpdateEventCommand({messages:u,source:a})),{messages:u,isContinuousMessages:c,hasNext:h}}))}getThreadedMessagesByTimestamp(e,s,i,n=t.CollectionEventSource.REQUEST_THREADED_MESSAGE){return t.__awaiter(this,void 0,void 0,(function*(){const a=new B(Object.assign(Object.assign(Object.assign({channelUrl:e.channelUrl,channelType:e.channelType,timestamp:s},f),i),{replyType:t.ReplyType.ALL,parentMessageId:e.messageId,includeThreadInfo:!0})),r=yield this._requestQueue.send(a),{messages:o}=r.as(j),l=o.slice(1);return l.forEach((t=>{t.parentMessage=e})),this._dispatcher.dispatch(new t.MessageUpdateEventCommand({messages:l,source:n})),{parentMessage:o[0],threadedMessages:l}}))}getMessageChangelogs(e,s,i,n,a=t.CollectionEventSource.REQUEST_MESSAGE_CHANGELOGS){return t.__awaiter(this,void 0,void 0,(function*(){const r=new z(t.deundefined(t.undefineNullProps(Object.assign(Object.assign({channelType:s,channelUrl:e,timestamp:"number"==typeof i?i:null,token:"string"==typeof i?i:null},k),n)))),o=yield this._requestQueue.send(r),{updatedMessages:l,deletedMessagesInfo:d,hasMore:u,nextToken:c}=o.as(V),h=d.map((e=>e.messageId));return l.length>0&&this._dispatcher.dispatch(new t.MessageUpdateEventCommand({messages:l,source:a})),h.length>0&&this._dispatcher.dispatch(new t.MessageRemoveEventCommand({messageIds:h,source:a})),{updatedMessages:l,deletedMessageIds:h,hasMore:u,token:c}}))}}class ri extends t.InstancedObject{constructor(e,s){super(e),this.targetMessageId=0;const i=s.thread_info,a=s.parent_message_id,r=s.channel_url,o=s.channel_type;i&&t.isTypeOf("object",i)&&t.isTypeOf("number",a)&&t.isTypeOf("string",r)&&t.isTypeOf("string",o)&&(this.threadInfo=new n(e,i),this.targetMessageId=a,this.channelUrl=r,this.channelType=o)}}const oi={channelUrl:"",channelType:t.ChannelType.BASE,messageId:0,includeReactions:!1,includeMetaArray:!1,includeParentMessageInfo:!1,includeThreadInfo:!1};class li extends t.APIRequestCommand{constructor({channelCustomType:e,keyword:s,limit:i,reverse:n,exactMatch:a,channelUrl:r,order:o,messageTimestampFrom:l,messageTimestampTo:d,advancedQuery:u,targetFields:c,nextToken:h}){super(),this.method=t.APIRequestMethod.GET,this.path=`${t.API_PATH_SEARCH}/messages`,this.params={custom_type:e,query:s,limit:i,reverse:n,exact_match:a,channel_url:r,message_ts_from:l,message_ts_to:d,sort_field:o,advanced_query:u,target_fields:c,after:h}}}class di extends t.APIResponseCommand{constructor(e,t){super(e,t),this.messages=t.results.map((t=>O(e,t))),this.hasNext=t.has_next,this.nextToken=t.end_cursor,this.totalCount=t.total_count}}var ui;exports.MessageSearchOrder=void 0,(ui=exports.MessageSearchOrder||(exports.MessageSearchOrder={})).SCORE="score",ui.TIMESTAMP="ts";class ci extends t.BaseListQuery{constructor(e,t){var s,i,n,a,r,o,l,d,u;super(e,t),this.keyword="",this.reverse=!1,this.exactMatch=!1,this.channelUrl="",this.channelCustomType="",this.messageTimestampFrom=null,this.messageTimestampTo=null,this.order=exports.MessageSearchOrder.SCORE,this.advancedQuery=!1,this.targetFields=null,this._nextToken="",this.totalCount=-1,this.keyword=t.keyword,this.reverse=null!==(s=t.reverse)&&void 0!==s&&s,this.exactMatch=null!==(i=t.exactMatch)&&void 0!==i&&i,this.channelUrl=null!==(n=t.channelUrl)&&void 0!==n?n:"",this.channelCustomType=null!==(a=t.channelCustomType)&&void 0!==a?a:"",this.messageTimestampFrom=null!==(r=t.messageTimestampFrom)&&void 0!==r?r:null,this.messageTimestampTo=null!==(o=t.messageTimestampTo)&&void 0!==o?o:null,this.order=null!==(l=t.order)&&void 0!==l?l:exports.MessageSearchOrder.SCORE,this.advancedQuery=null!==(d=t.advancedQuery)&&void 0!==d&&d,this.targetFields=null!==(u=t.targetFields)&&void 0!==u?u:null}_validate(){return super._validate()&&t.isTypeOf("string",this.keyword)&&this.keyword.length>0&&t.isTypeOf("boolean",this.reverse)&&t.isTypeOf("boolean",this.exactMatch)&&t.isTypeOf("string",this.channelUrl)&&t.isTypeOf("string",this.channelCustomType)&&(t.isTypeOf("number",this.messageTimestampFrom)||null===this.messageTimestampFrom)&&(t.isTypeOf("number",this.messageTimestampTo)||null===this.messageTimestampTo)&&t.isEnumOf(exports.MessageSearchOrder,this.order)&&t.isTypeOf("boolean",this.advancedQuery)&&t.isArrayOf("string",this.targetFields,!0)}next(){return t.__awaiter(this,void 0,void 0,(function*(){if(this._validate()){if(this._isLoading)throw t.SendbirdError.queryInProgress;if(this._hasNext){this._isLoading=!0;const{requestQueue:e}=t.Vault.of(this._iid),s=new li(t.undefineNullProps(Object.assign(Object.assign({},this),{nextToken:this._nextToken?this._nextToken:null}))),i=yield e.send(s),{messages:n,hasNext:a,nextToken:r,totalCount:o}=i.as(di);return this._nextToken=r,this._hasNext=a,this._isLoading=!1,this.totalCount=o,n}return[]}throw t.SendbirdError.invalidParameters}))}}exports.AdminMessage=I,exports.AppleCriticalAlertOptions=u,exports.BanUserEventCommand=st,exports.BannedUserListQuery=Oe,exports.BaseChannel=Qt,exports.BaseMessage=_,exports.BaseMessageUpdateParamsDefault=ce,exports.BaseStore=Fs,exports.CreateScheduledUserMessageResponseCommand=Ot,exports.DEFAULT_FEED_LIMIT=100,exports.DEFAULT_GROUPCHANNEL_LIMIT=100,exports.DEFAULT_MESSAGE_LIMIT=100,exports.DeleteMessageEventCommand=yt,exports.FileMessage=M,exports.FileMessageEventCommand=w,exports.FreezeEventCommand=rt,exports.IndexedDbStore=class extends Fs{constructor(e={}){var t;super(Object.assign(Object.assign({},e),{itemSizeLimit:null!==(t=e.itemSizeLimit)&&void 0!==t?t:104857600})),this._storeName=Vs,this._state=$s.UNINITIALIZED,this._openJobQueue=[],this._window="undefined"!=typeof window?window:void 0,this._indexedDb=this._window?this._window.indexedDB||this._window.mozIndexedDB||this._window.webkitIndexedDB||this._window.msIndexedDB:void 0}get state(){return this._state}_openDatabase(e){return new Promise(((t,s)=>{if(this._indexedDb){this._state=$s.OPENING;const i=this._indexedDb.open(e);i.addEventListener("upgradeneeded",(e=>{e.target.result.createObjectStore(Vs,{keyPath:"key"})})),i.addEventListener("success",(s=>{this._state=$s.OPEN,this._database=s.target.result,this._openJobQueue.forEach((e=>e())),this._openJobQueue=[],this._database.onclose=()=>{this._database=void 0,this._state=$s.OPENING,setTimeout((()=>{this._openDatabase(e)}),5)},t(this._database)})),i.addEventListener("error",(e=>{this._state=$s.UNINITIALIZED,s(e.target.error)}))}else s(Yt.storeNotAvailable)}))}_getObjectStore(e){return t.__awaiter(this,void 0,void 0,(function*(){if(this._database)return this._database.transaction(this._storeName,e).objectStore(this._storeName);switch(this._state){case $s.UNINITIALIZED:case $s.OPEN:throw Yt.storeNotInitialized;case $s.OPENING:case $s.CLOSED:return new Promise((t=>{this._openJobQueue.push((()=>t(this._getObjectStore(e))))}));default:return yield this._getObjectStore(e)}}))}_getAllRawKeys(){return t.__awaiter(this,void 0,void 0,(function*(){const e=yield this._getObjectStore("readonly");return yield new Promise(((t,s)=>{const i=e.getAllKeys();i.addEventListener("success",(e=>{t(e.target.result)})),i.addEventListener("error",(e=>s(e.target.error)))}))}))}_getRaw(e){return t.__awaiter(this,void 0,void 0,(function*(){const t=yield this._getObjectStore("readonly");return yield new Promise(((s,i)=>{const n=t.get(e);n.addEventListener("success",(e=>{var t;s(null===(t=null==e?void 0:e.target)||void 0===t?void 0:t.result)})),n.addEventListener("error",(e=>i(e.target.error)))}))}))}_setRaw(e){return t.__awaiter(this,void 0,void 0,(function*(){const t=yield this._getObjectStore("readwrite");yield Promise.all(e.map((e=>new Promise(((s,i)=>{const n=t.put(e);n.addEventListener("success",(e=>{s(e.target.result)})),n.addEventListener("error",(()=>{i("Failed to write.")}))})))))}))}_removeRaw(e){return t.__awaiter(this,void 0,void 0,(function*(){const t=yield this._getObjectStore("readwrite");yield Promise.all(e.map((e=>new Promise(((s,i)=>{const n=t.delete(e);n.addEventListener("success",(()=>s(e))),n.addEventListener("error",(e=>i(e.target.error)))})))))}))}_triggerDatabaseClose(){this._database&&this._database.onclose&&this._database.onclose(new Event("dummy"))}checkAvailability(){return t.__awaiter(this,void 0,void 0,(function*(){const e="undefined"!=typeof window?window:null;if(!((null==e?void 0:e.indexedDB)||(null==e?void 0:e.mozIndexedDB)||(null==e?void 0:e.webkitIndexedDB)||(null==e?void 0:e.msIndexedDB)))throw Yt.storeNotAvailable;if(this._indexedDb=e.indexedDB||e.mozIndexedDB||e.webkitIndexedDB||e.msIndexedDB,!this._window||!Cs())throw Yt.storeNotAvailable;if(Cs()&&navigator.userAgent&&navigator.userAgent.includes("Edge/")){if(!this._window.indexedDB&&(e.PointerEvent||e.MSPointerEvent))throw Yt.storeNotAvailableInPrivateBrowsing}else yield new Promise(((e,t)=>{if(this._indexedDb)try{const s=this._indexedDb.open("_testMozilla");s.onerror=()=>t(Yt.storeNotAvailableInPrivateBrowsing),s.onsuccess=()=>e()}catch(e){t(Yt.storeNotAvailableInPrivateBrowsing)}else t(Yt.storeNotAvailable)}))}))}init(e){return t.__awaiter(this,void 0,void 0,(function*(){this.dbname=e,yield this.checkAvailability(),yield this._openDatabase(e),yield this._resetIfEncryptionChanged()}))}clear(){return t.__awaiter(this,void 0,void 0,(function*(){const e=yield this._getObjectStore("readwrite");return yield new Promise(((t,s)=>{const i=e.clear();i.addEventListener("success",(()=>t())),i.addEventListener("error",(e=>s(e.target.error)))}))}))}},exports.MemoryStore=zs,exports.MessageBroadcast=ii,exports.MessageCache=ti,exports.MessageFilter=Gs,exports.MessageManager=ai,exports.MessageMetaArray=o,exports.MessageRequestHandler=W,exports.MessageRetrievalParamsDefault=oi,exports.MessageSearchQuery=ci,exports.MultipleFilesMessage=S,exports.MultipleFilesMessageRequestHandler=Vt,exports.MuteUserEventCommand=Xe,exports.MutedUserListQuery=Te,exports.NESTDB_FEEDCHANNEL_COLLECTION_KEY="url",exports.NESTDB_FEEDCHANNEL_COLLECTION_NAME="FeedChannel",exports.NESTDB_GROUPCHANNEL_COLLECTION_KEY="url",exports.NESTDB_GROUPCHANNEL_COLLECTION_NAME="GroupChannel",exports.NESTDB_MESSAGE_COLLECTION_KEY="messageId",exports.NESTDB_MESSAGE_COLLECTION_NAME=Bt,exports.NESTDB_POLL_COLLECTION_KEY="pollId",exports.NESTDB_POLL_COLLECTION_NAME="Poll",exports.NESTDB_UNSENT_MESSAGE_COLLECTION_KEY="reqId",exports.NESTDB_UNSENT_MESSAGE_COLLECTION_NAME=Js,exports.NestDB=class{constructor({name:e,version:t,store:s,config:i}){this.name=e,this._version=t,this._state=exports.NestDBState.INIT,this._config=i||new Gt({dbname:e}),this._store=s,this._event={success:ss,error:ss,storeReplaced:ss,upgrade:as},this._collections=new Map,this._globalMutex=new Rs(`${this.name}.lock`),this._config.disableLogger&&Ds.off(),new Es({dbname:e,limit:this._config.cacheLimit})}get version(){return this._version}get state(){return this._state}get store(){return this._store}estimateUsage(){return t.__awaiter(this,void 0,void 0,(function*(){return yield(e=this._store,t.__awaiter(void 0,void 0,void 0,(function*(){return yield e.usage()})));var e}))}commitSchema(e){return t.__awaiter(this,void 0,void 0,(function*(){if(this._state!==exports.NestDBState.OPENING)throw Yt.databaseSchemaNotOnUpgrade;yield Promise.all(e.map((e=>t.__awaiter(this,void 0,void 0,(function*(){const{collectionName:t,keyName:s,index:i=[]}=e;this._collections.has(t)||this._collections.set(t,new xs({dbname:this.name,collectionName:t,keyName:s,indexes:i,store:this._store}));const n=this._collections.get(t);n&&(yield n.init())})))))}))}open(){var e;return t.__awaiter(this,void 0,void 0,(function*(){if(yield this._globalMutex.lock(),this._state!==exports.NestDBState.OPENED){this._state=exports.NestDBState.OPENING;try{yield this._store.init(this.name);const i=(s=this.name,`${us(s)}.metadata`),n={version:0,collectionNames:[]},a=null!==(e=yield this._store.get(i))&&void 0!==e?e:n;return new Promise(((e,s)=>{const n=e=>{a.versiont.__awaiter(this,void 0,void 0,(function*(){if(s)e({continued:!1,err:s});else{a.version++,a.collectionNames=Array.from(this._collections.keys());try{yield this._store.set({key:i,value:a}),e({continued:!0})}catch(t){e({continued:!1,err:t})}}})))):e({continued:!1})},r=i=>{const{continued:o=!1,err:l=null}=i;if(o)setTimeout((()=>n(r)),10);else if(l)Ds.error(l.message),this._globalMutex.unlock(),this._event.error(l),s(l);else{const i=[];a.collectionNames.forEach((e=>{const s=this._collections.get(e);s&&s.state===Wt.READY||i.push((()=>t.__awaiter(this,void 0,void 0,(function*(){const t=yield xs.metadataOf(this.name,e,this._store);if(t){const s=new xs({dbname:this.name,collectionName:e,keyName:t.keyName,indexes:t.indexes,store:this._store});this._collections.set(e,s),yield s.init()}})))())})),Promise.all(i).then((()=>{this._state=exports.NestDBState.OPENED,this._globalMutex.unlock(),this._event.success(),e()})).catch((e=>{Ds.error(e.message),this._globalMutex.unlock(),this._event.error(e),s(e)}))}};n(r)}))}catch(e){switch(e.code){case Ht.STORE_NOT_AVAILABLE_IN_PRIVATE_BROWSING:Ds.warning("Access to the local storage is not allowed. Switched to MemoryStore automatically."),this._store=new zs({}),this._globalMutex.unlock(),this._event.error(e),this._event.storeReplaced(this._store),yield this.open();break;case Ht.STORE_NOT_AVAILABLE:Ds.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 zs({}),this._globalMutex.unlock(),this._event.error(e),this._event.storeReplaced(this._store),yield this.open();break;default:throw Ds.error(e.message),this._globalMutex.unlock(),this._event.error(e),e}}}var s}))}close(){this._collections.forEach((e=>e.close())),this._state=exports.NestDBState.CLOSED}clear(){return t.__awaiter(this,void 0,void 0,(function*(){yield Promise.all(Array.from(this._collections.values()).map((e=>e.clear())))}))}reset(){return t.__awaiter(this,void 0,void 0,(function*(){this.close();const e=Es.get(this.name);e&&e.clearByCondition((e=>e.key.startsWith(us(this.name)))),yield this._store.clear()}))}on(e,t){this._event[e]=t}off(e){if("function"==typeof this._event[e])if("upgrade"===e)this._event[e]=as;else this._event[e]=ss}collection(e){const t=this._collections.get(e);if(t)return t;throw Yt.collectionNotReady}},exports.NestDBError=Yt,exports.OGImage=l,exports.OGMetaData=d,exports.OperatorListQuery=fe,exports.PENDING_MESSAGE_DELAY=2,exports.Plugin=E,exports.PollVoteEventCommand=Ft,exports.PreviousMessageListQuery=ve,exports.Reaction=r,exports.ReactionEvent=a,exports.RestrictedUser=H,exports.RestrictionInfo=G,exports.ScheduledFileMessageCreateParamsDefault=Ys,exports.ScheduledUserMessageCreateParamsDefault=Ws,exports.SendableMessage=g,exports.Sender=c,exports.ThreadInfo=n,exports.ThreadInfoUpdateEvent=ri,exports.Thumbnail=y,exports.UnbanUserEventCommand=nt,exports.UnmuteUserEventCommand=et,exports.UnsentMessageCache=Zs,exports.UpdateFileMessageEventCommand=_t,exports.UpdateMetaCounterEventCommand=He,exports.UpdateMetaDataEventCommand=De,exports.UpdateUserMessageEventCommand=pt,exports.UploadFileRequestCommand=s,exports.UploadFileResponseCommand=i,exports.UploadedFileInfo=b,exports.UserMessage=T,exports.UserMessageEventCommand=ct,exports.UserMessageUpdateParamsDefault=pe,exports.createFileMessageCreateParams=le,exports.createFileMessageCreateParamsFromFailedFileMessage=de,exports.createMultipleFilesMessageCreateParams=function(e){var s,i,n;return null!==(s=e.messageParams)&&void 0!==s?s:t.undefineNullProps(Object.assign(Object.assign({},e),{isReplyToChannel:!1,mentionedUserIds:null!==(i=e.mentionedUserIds)&&void 0!==i?i:null===(n=e.mentionedUsers)||void 0===n?void 0:n.map((e=>e.userId)),pushNotificationDeliveryOption:t.PushNotificationDeliveryOption.DEFAULT,isPinnedMessage:!1,fileInfoList:e.fileInfoList.map((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((e=>({maxWidth:e.width,maxHeight:e.height}))),_uploadedMetaData:{requireAuth:e._requireAuth,isUploaded:!0}}}))}))},exports.createUserMessageCreateParams=ee,exports.createUserMessageCreateParamsFromFailedUserMessage=te,exports.getMessageIndexBy=Hs,exports.parseMessagePayload=O,exports.payloadifyMessage=e=>{switch(e.messageType){case t.MessageType.USER:return T.payloadify(e);case t.MessageType.FILE:return e.fileInfoList?S.payloadify(e):M.payloadify(e);case t.MessageType.ADMIN:return I.payloadify(e);default:throw t.SendbirdError.unknown}},exports.validateBaseMessageUpdateParams=he,exports.validateMessageRetrievalParams=e=>t.isTypeOf("string",e.channelUrl)&&t.isEnumOf(t.ChannelType,e.channelType)&&t.isTypeOf("number",e.messageId)&&t.isTypeOf("boolean",e.includeReactions,!0)&&t.isTypeOf("boolean",e.includeMetaArray,!0)&&t.isTypeOf("boolean",e.includeParentMessageInfo,!0)&&t.isTypeOf("boolean",e.includeThreadInfo,!0),exports.validateScheduledFileMessageCreateParams=e=>J(e)&&t.isTypeOf("number",e.scheduledAt)&&(t.isFile(e.file)||t.isTypeOf("string",e.fileUrl))&&t.isTypeOf("string",e.fileName,!0)&&t.isTypeOf("string",e.mimeType,!0)&&t.isTypeOf("number",e.fileSize,!0)&&(null===e.thumbnailSizes||void 0===e.thumbnailSizes||e.thumbnailSizes.every((e=>t.isTypeOf("object",e)&&e.maxWidth>0&&e.maxHeight>0))),exports.validateScheduledUserMessageCreateParams=e=>se(e)&&t.isTypeOf("number",e.scheduledAt,!0),exports.validateUserMessageUpdateParams=me;
diff --git a/cjs/lib/__bundle-a29353f5.js b/cjs/lib/__bundle-a29353f5.js
new file mode 100644
index 0000000..8db7870
--- /dev/null
+++ b/cjs/lib/__bundle-a29353f5.js
@@ -0,0 +1 @@
+"use strict";var e,t=require("./__bundle-5d8ae943.js"),n=require("./__bundle-0bbec988.js"),s=require("./__bundle-f6d4722d.js");exports.ChannelEventCategory=void 0,(e=exports.ChannelEventCategory||(exports.ChannelEventCategory={}))[e.NONE=0]="NONE",e[e.CHANNEL_ENTER=10102]="CHANNEL_ENTER",e[e.CHANNEL_EXIT=10103]="CHANNEL_EXIT",e[e.USER_CHANNEL_MUTE=10201]="USER_CHANNEL_MUTE",e[e.USER_CHANNEL_UNMUTE=10200]="USER_CHANNEL_UNMUTE",e[e.USER_CHANNEL_BAN=10601]="USER_CHANNEL_BAN",e[e.USER_CHANNEL_UNBAN=10600]="USER_CHANNEL_UNBAN",e[e.CHANNEL_FREEZE=10701]="CHANNEL_FREEZE",e[e.CHANNEL_UNFREEZE=10700]="CHANNEL_UNFREEZE",e[e.TYPING_START=10900]="TYPING_START",e[e.TYPING_END=10901]="TYPING_END",e[e.CHANNEL_JOIN=1e4]="CHANNEL_JOIN",e[e.CHANNEL_LEAVE=10001]="CHANNEL_LEAVE",e[e.CHANNEL_OPERATOR_UPDATE=10002]="CHANNEL_OPERATOR_UPDATE",e[e.CHANNEL_INVITE=10020]="CHANNEL_INVITE",e[e.CHANNEL_ACCEPT_INVITE=10021]="CHANNEL_ACCEPT_INVITE",e[e.CHANNEL_DECLINE_INVITE=10022]="CHANNEL_DECLINE_INVITE",e[e.CHANNEL_PROP_CHANGED=11e3]="CHANNEL_PROP_CHANGED",e[e.CHANNEL_DELETED=12e3]="CHANNEL_DELETED",e[e.CHANNEL_META_DATA_CHANGED=11100]="CHANNEL_META_DATA_CHANGED",e[e.CHANNEL_META_COUNTERS_CHANGED=11200]="CHANNEL_META_COUNTERS_CHANGED",e[e.CHANNEL_HIDE=13e3]="CHANNEL_HIDE",e[e.CHANNEL_UNHIDE=13001]="CHANNEL_UNHIDE",e[e.PINNED_MESSAGE_CHANGED=11300]="PINNED_MESSAGE_CHANGED";class a{constructor(e){var t;this.channelUrl=e.channel_url,this.channelType=e.channel_type,this.category=e.cat,this.data=null!==(t=e.data)&&void 0!==t?t:{},this.ts=e.ts}get isGroupChannelEvent(){return this.channelType===t.ChannelType.GROUP}get isOpenChannelEvent(){return this.channelType===t.ChannelType.OPEN}}class o extends t.WebSocketEventCommand{constructor(e,t,n){super(e,"SYEV",n),this.event=new a(n)}}class r extends t.InstancedObject{get _messageBroadcast(){return n.MessageBroadcast.of(this._iid)}constructor(e,t){super(e),this._logger=t.logger,this._sdkState=t.sdkState,this._sessionManager=t.sessionManager,this._requestQueue=t.requestQueue,this._dispatcher=t.dispatcher,this._cacheContext=t.cacheContext,this._channelType=t.channelType}subscribeMessageEvent(e,t){this._messageBroadcast.subscribe(e,t)}unsubscribeMessageEvent(e){this._messageBroadcast.unsubscribe(e)}getMessageFromCache(e){return t.__awaiter(this,void 0,void 0,(function*(){return null}))}getExactlyMatchingMessagesForTokenFromCache(e,n,s){return t.__awaiter(this,void 0,void 0,(function*(){return[]}))}getMessagesFromCache(e,n,s,a,o,r){return t.__awaiter(this,void 0,void 0,(function*(){return[]}))}getPollMessagesFromCache(e,n,s,a){return t.__awaiter(this,void 0,void 0,(function*(){return[]}))}getCachedMessageCountBetween(e,n,s,a){return t.__awaiter(this,void 0,void 0,(function*(){return 0}))}getUnsentMessagesFromCache(e,n){return t.__awaiter(this,void 0,void 0,(function*(){return[]}))}removeFailedMessageFromCache(e){return t.__awaiter(this,void 0,void 0,(function*(){}))}}class E extends t.WebSocketEventCommand{constructor(e,s,a){var o,r,E,i;super(e,"ADMM",a),this.message=new n.AdminMessage(e,a);const{sdkState:N}=t.Vault.of(e);this.isMentioned=t.checkIfMentioned(this.message.mentionType,null!==(E=null!==(o=this.message.mentionedUserIds)&&void 0!==o?o:null===(r=this.message.mentionedUsers)||void 0===r?void 0:r.map((e=>e.userId)))&&void 0!==E?E:[],N.userId),this.forceUpdateLastMessage=null!==(i=a.force_update_last_message)&&void 0!==i&&i}}class i extends t.WebSocketEventCommand{constructor(e,s,a){var o,r,E,i,N;super(e,"AEDI",a),this.message=new n.AdminMessage(e,a);const{sdkState:_}=t.Vault.of(e);this.mentionCountChange=t.calculateMentionCountChange({mentionType:null===(o=a.old_values)||void 0===o?void 0:o.mention_type,mentionedUserIds:null!==(E=null===(r=a.old_values)||void 0===r?void 0:r.mentioned_user_ids)&&void 0!==E?E:[]},t.undefineNullProps({mentionType:this.message.mentionType,mentionedUserIds:null!==(i=this.message.mentionedUserIds)&&void 0!==i?i:null===(N=this.message.mentionedUsers)||void 0===N?void 0:N.map((e=>e.userId))}),_.userId)}}class N extends t.WebSocketEventCommand{constructor(e,t,s){super(e,"MRCT",s),this.channelUrl=s.channel_url,this.channelType=s.channel_type,this.event=new n.ReactionEvent(s)}}class _ extends t.WebSocketEventCommand{constructor(e,t,s){super(e,"MTHD",s),this.event=new n.ThreadInfoUpdateEvent(e,s)}}class d extends t.WebSocketEventCommand{constructor(e,t,n){super(e,"MCNT",n),this.groupChannelMemberCounts=n.group_channels.map((e=>({channelUrl:e.channel_url,memberCount:e.member_count,joinedMemberCount:e.joined_member_count,updatedAt:e.ts}))),this.openChannelMemberCounts=n.open_channels.map((e=>({channelUrl:e.channel_url,participantCount:e.participant_count,updatedAt:e.ts})))}}class c extends t.WebSocketEventCommand{constructor(e,n,a){super(e,"PEDI",a),this.event=new s.PollUpdateEvent(e,a),this.status=t.parsePollStatusPayload(a.poll.status)||a.poll.status,this.channelUrl=a.channel_url,this.channelType=a.channel_type}}exports.AdminMessageEventCommand=E,exports.BaseChannelManager=r,exports.ChannelEventCommand=o,exports.MemberCountUpdateEventCommand=d,exports.OperatorUpdateEventCommand=class extends o{constructor(e,n,s){super(e,n,s);const{operators:a=[]}=s.data;this.operators=a.map((e=>new t.User(this._iid,e)))}},exports.PollUpdateEventCommand=c,exports.ReactionEventCommand=N,exports.ThreadInfoUpdateEventCommand=_,exports.UpdateAdminMessageEventCommand=i;
diff --git a/cjs/lib/__bundle-bda78dae.js b/cjs/lib/__bundle-bda78dae.js
new file mode 100644
index 0000000..17a12b8
--- /dev/null
+++ b/cjs/lib/__bundle-bda78dae.js
@@ -0,0 +1 @@
+"use strict";var e,t,s,n,i,a,r,o,l,d=require("./__bundle-5d8ae943.js"),h=require("./__bundle-0bbec988.js"),c=require("./__bundle-197b1725.js"),u=require("./__bundle-a29353f5.js");exports.MemberState=void 0,(e=exports.MemberState||(exports.MemberState={})).NONE="none",e.JOINED="joined",e.INVITED="invited",e.LEFT="left";class _ extends h.RestrictedUser{constructor(e,t){super(e,t),this.state=null,this.role=null,this.isMuted=!1,this.isBlockedByMe=!1,this.isBlockingMe=!1,this.state=d.isEnumOf(exports.MemberState,t.state)?t.state:null,this.role=d.isEnumOf(d.Role,t.role)?t.role:null,"boolean"==typeof t.is_muted&&(this.isMuted=t.is_muted),"boolean"==typeof t.is_blocked_by_me&&(this.isBlockedByMe=t.is_blocked_by_me),"boolean"==typeof t.is_blocking_me&&(this.isBlockingMe=t.is_blocking_me)}static payloadify(e){return d.deundefined(d.undefineNullProps(Object.assign(Object.assign({},super.payloadify(e)),{state:e.state,role:e.role,is_muted:e.isMuted,is_blocked_by_me:e.isBlockedByMe,is_blocking_me:e.isBlockingMe})))}}class p extends d.InstancedObject{constructor(e,t){var s,n;super(e),this.channelUrl=null!==(s=t.channel_url)&&void 0!==s?s:"",this.channelType=null!==(n=t.channel_type)&&void 0!==n?n:d.ChannelType.GROUP,this.reader=new d.User(this._iid,t.user),this.readAt=t.ts}}exports.PublicChannelFilter=void 0,(t=exports.PublicChannelFilter||(exports.PublicChannelFilter={})).ALL="all",t.PUBLIC="public",t.PRIVATE="private",exports.MyMemberStateFilter=void 0,(s=exports.MyMemberStateFilter||(exports.MyMemberStateFilter={})).ALL="all",s.JOINED="joined_only",s.INVITED="invited_only",s.INVITED_BY_FRIEND="invited_by_friend",s.INVITED_BY_NON_FRIEND="invited_by_non_friend",exports.SuperChannelFilter=void 0,(n=exports.SuperChannelFilter||(exports.SuperChannelFilter={})).ALL="all",n.SUPER="super",n.NON_SUPER="nonsuper",n.BROADCAST_ONLY="broadcast_only",n.EXCLUSIVE_ONLY="exclusive_only",exports.UnreadChannelFilter=void 0,(i=exports.UnreadChannelFilter||(exports.UnreadChannelFilter={})).ALL="all",i.UNREAD_MESSAGE="unread_message",exports.HiddenChannelFilter=void 0,(a=exports.HiddenChannelFilter||(exports.HiddenChannelFilter={})).ALL="all",a.UNHIDDEN="unhidden_only",a.HIDDEN="hidden_only",a.HIDDEN_ALLOW_AUTO_UNHIDE="hidden_allow_auto_unhide",a.HIDDEN_PREVENT_AUTO_UNHIDE="hidden_prevent_auto_unhide",exports.OperatorFilter=void 0,(r=exports.OperatorFilter||(exports.OperatorFilter={})).ALL="all",r.OPERATOR="operator",r.NONOPERATOR="nonoperator",exports.QueryType=void 0,(o=exports.QueryType||(exports.QueryType={})).AND="AND",o.OR="OR",exports.GroupChannelSearchField=void 0,(l=exports.GroupChannelSearchField||(exports.GroupChannelSearchField={})).MEMBER_NICKNAME="member_nickname",l.CHANNEL_NAME="channel_name";class m{constructor(){this._searchFilter=null,this._userIdsFilter=null,this.includeEmpty=!1,this.nicknameContainsFilter=null,this.nicknameStartsWithFilter=null,this.nicknameExactMatchFilter=null,this.channelNameContainsFilter="",this.myMemberStateFilter=exports.MyMemberStateFilter.ALL,this.customTypesFilter=null,this.channelUrlsFilter=null,this.superChannelFilter=exports.SuperChannelFilter.ALL,this.publicChannelFilter=exports.PublicChannelFilter.ALL,this.customTypeStartsWithFilter=null,this.unreadChannelFilter=exports.UnreadChannelFilter.ALL,this.hiddenChannelFilter=exports.HiddenChannelFilter.UNHIDDEN,this.includeFrozen=!0}_isFriend(e){return!(!e||!e.friendDiscoveryKey&&!e.friendName)}get searchFilter(){return this._searchFilter}setSearchFilter(e,t){Array.isArray(e)&&0!==e.length&&"string"==typeof t&&t&&(this._searchFilter={query:t,fields:e})}get userIdsFilter(){return this._userIdsFilter}setUserIdsFilter(e,t,s=exports.QueryType.AND){this._userIdsFilter={userIds:e,includeMode:t,queryType:s}}clone(){var e;const t=new m;this.searchFilter&&t.setSearchFilter(this.searchFilter.fields,null!==(e=this.searchFilter.query)&&void 0!==e?e:void 0),this.userIdsFilter&&t.setUserIdsFilter(this.userIdsFilter.userIds,this.userIdsFilter.includeMode,this.userIdsFilter.queryType);const s=JSON.parse(JSON.stringify(this));return Object.keys(s).forEach((e=>{t[e]=s[e]})),t}match(e,t){if(this._searchFilter){const{query:t,fields:s}=this._searchFilter;if(t&&s&&s.length>0&&!s.some((s=>{switch(s){case exports.GroupChannelSearchField.CHANNEL_NAME:return e.name.toLowerCase().includes(t.toLowerCase());case exports.GroupChannelSearchField.MEMBER_NICKNAME:return e.members.some((e=>e.nickname.toLowerCase().includes(t.toLowerCase())));default:return!0}})))return!1}if(this._userIdsFilter){const{userIds:s,includeMode:n,queryType:i}=this._userIdsFilter,a=e.members.map((e=>e.userId));if(n){if(s.length>0)switch(i){case exports.QueryType.AND:if(s.some((e=>!a.includes(e))))return!1;break;case exports.QueryType.OR:if(s.every((e=>!a.includes(e))))return!1}}else{if(s.includes(t)||s.push(t),e.members.length>s.length)return!1;if(!d.hasSameMembers(s,a))return!1}}if(!this.includeEmpty&&!e.lastMessage)return!1;if(!this.includeFrozen&&e.isFrozen)return!1;if(this.customTypesFilter&&this.customTypesFilter.length>0&&!this.customTypesFilter.includes("*")&&!this.customTypesFilter.includes(e.customType))return!1;if(this.customTypeStartsWithFilter&&!new RegExp(`^${this.customTypeStartsWithFilter}`).test(e.customType))return!1;if(this.channelNameContainsFilter&&!e.name.toLowerCase().includes(this.channelNameContainsFilter.toLowerCase()))return!1;if(this.nicknameContainsFilter){const s=this.nicknameContainsFilter.toLowerCase();if(!e.members.some((e=>e.userId!==t&&e.nickname.toLowerCase().includes(s))))return!1}if(this.nicknameStartsWithFilter){const s=this.nicknameStartsWithFilter.toLowerCase();if(!e.members.some((e=>e.userId!==t&&e.nickname.toLowerCase().startsWith(s))))return!1}if(this.nicknameExactMatchFilter){const s=this.nicknameExactMatchFilter.toLowerCase();if(!e.members.some((e=>e.userId!==t&&e.nickname.toLowerCase()!=s)))return!1}if(this.channelUrlsFilter&&this.channelUrlsFilter.length>0&&!this.channelUrlsFilter.includes(e.url))return!1;if(this.myMemberStateFilter)switch(this.myMemberStateFilter){case exports.MyMemberStateFilter.JOINED:if("joined"!==e.myMemberState)return!1;break;case exports.MyMemberStateFilter.INVITED:if("invited"!==e.myMemberState)return!1;break;case exports.MyMemberStateFilter.INVITED_BY_FRIEND:if("invited"!==e.myMemberState||!this._isFriend(e.inviter))return!1;break;case exports.MyMemberStateFilter.INVITED_BY_NON_FRIEND:if("invited"!==e.myMemberState||this._isFriend(e.inviter))return!1}if(this.hiddenChannelFilter)switch(this.hiddenChannelFilter){case exports.HiddenChannelFilter.UNHIDDEN:if(e.isHidden||"unhidden"!==e.hiddenState)return!1;break;case exports.HiddenChannelFilter.HIDDEN:if(!e.isHidden)return!1;break;case exports.HiddenChannelFilter.HIDDEN_ALLOW_AUTO_UNHIDE:if(!e.isHidden||"hidden_allow_auto_unhide"!==e.hiddenState)return!1;break;case exports.HiddenChannelFilter.HIDDEN_PREVENT_AUTO_UNHIDE:if(!e.isHidden||"hidden_prevent_auto_unhide"!==e.hiddenState)return!1}if(this.unreadChannelFilter&&this.unreadChannelFilter===exports.UnreadChannelFilter.UNREAD_MESSAGE)if(0===e.unreadMessageCount)return!1;if(this.publicChannelFilter)switch(this.publicChannelFilter){case exports.PublicChannelFilter.PUBLIC:if(!e.isPublic)return!1;break;case exports.PublicChannelFilter.PRIVATE:if(e.isPublic)return!1}if(this.superChannelFilter)switch(this.superChannelFilter){case exports.SuperChannelFilter.SUPER:if(!e.isSuper)return!1;break;case exports.SuperChannelFilter.NON_SUPER:if(e.isSuper)return!1}return!(this.createdAfter&&e.createdAtthis.createdBefore)}}class g extends d.InstancedObject{constructor(e,{sdkState:t,cacheContext:s}){super(e),this._channels=new Map,this._sdkState=t,this._cacheContext=s}get collection(){const{nestdb:e}=this._cacheContext;return d.unless(!!e).throw(d.SendbirdError.databaseError),e.collection(h.NESTDB_GROUPCHANNEL_COLLECTION_NAME)}get localCacheEnabled(){const{localCacheEnabled:e}=this._cacheContext;return e&&!!this.collection}_serialize(e,t=0){return Object.assign(Object.assign({},e.serialize()),{lastMessageUpdatedAt:e.lastMessage?e.lastMessage.createdAt:0,syncIndex:t})}_deserialize(e){return Ie.of(this._iid).buildGroupChannelFromSerializedData(e)}get channels(){return[...this._channels.values()]}isCachedInMemory(e){return this._channels.has(e)}filterOffsetChanged(e){return e.filter((e=>{if(this._channels.has(e.url)){return this._channels.get(e.url).messageOffsetTimestamp{if(e)switch(i){case c.GroupChannelListOrder.CHANNEL_NAME_ALPHABETICAL:if(!s&&t.name.localeCompare(e)<0||s&&t.name.localeCompare(e)>0)return!1;if(a&&a===t.url)return!1;break;case c.GroupChannelListOrder.CHRONOLOGICAL:if(!s&&t.createdAt>e||s&&t.createdAte||s&&t.lastMessageUpdatedAtthis._deserialize(e)));return l.forEach((e=>{this._channels.has(e.url)||this._channels.set(e.url,e)})),l}return[]}))}upsert(e,t){return d.__awaiter(this,void 0,void 0,(function*(){const s=[];if(e.forEach((e=>{if(this._channels.has(e.url)){const n=this._channels.get(e.url);n._pinnedMessagesUpdatedAt0&&(yield this.upsert(n))}))}block(e,t){return d.__awaiter(this,void 0,void 0,(function*(){yield this._setBlockStateOfAllChannels(e,t,!0)}))}unblock(e,t){return d.__awaiter(this,void 0,void 0,(function*(){yield this._setBlockStateOfAllChannels(e,t,!1)}))}markAsRead(e,t=[...this._channels.keys()]){return d.__awaiter(this,void 0,void 0,(function*(){const s=[];for(const n of t){const t=yield this.get(n);(null==t?void 0:t._updateUnreadMemberState(this._sdkState.userId,e))&&(t._updateUnreadCount(0,0),s.push(t))}s.length>0&&(yield this.upsert(s))}))}}const C={invitedUserIds:void 0,channelUrl:void 0,coverUrl:void 0,coverImage:void 0,isDistinct:void 0,isSuper:void 0,isBroadcast:void 0,isExclusive:void 0,isPublic:void 0,isDiscoverable:void 0,isStrict:void 0,isEphemeral:void 0,accessCode:void 0,name:void 0,data:void 0,customType:void 0,operatorUserIds:void 0,messageSurvivalSeconds:void 0},E=e=>d.isArrayOf("string",e.invitedUserIds,!0)&&d.isTypeOf("string",e.channelUrl,!0)&&d.isTypeOf("string",e.coverUrl,!0)&&(d.isFile(e.coverImage)||d.isTypeOf("string",e.coverImage,!0))&&d.isTypeOf("boolean",e.isDistinct,!0)&&d.isTypeOf("boolean",e.isSuper,!0)&&d.isTypeOf("boolean",e.isBroadcast,!0)&&d.isTypeOf("boolean",e.isExclusive,!0)&&d.isTypeOf("boolean",e.isPublic,!0)&&d.isTypeOf("boolean",e.isStrict,!0)&&d.isTypeOf("boolean",e.isDiscoverable,!0)&&d.isTypeOf("boolean",e.isEphemeral,!0)&&d.isTypeOf("string",e.accessCode,!0)&&d.isTypeOf("string",e.name,!0)&&d.isTypeOf("string",e.data,!0)&&d.isTypeOf("string",e.customType,!0)&&d.isArrayOf("string",e.operatorUserIds,!0)&&d.isTypeOf("number",e.messageSurvivalSeconds,!0),v={customTypes:void 0,includeEmpty:!1,includeFrozen:!0,includeChatNotification:!1},f=e=>d.isArrayOf("string",e.customTypes,!0)&&d.isTypeOf("boolean",e.includeEmpty)&&d.isTypeOf("boolean",e.includeFrozen)&&d.isTypeOf("boolean",e.includeChatNotification),M={myMemberStateFilter:exports.MyMemberStateFilter.ALL},S=e=>d.isEnumOf(exports.MyMemberStateFilter,e.myMemberStateFilter);var y;exports.UnreadItemKey=void 0,(y=exports.UnreadItemKey||(exports.UnreadItemKey={})).GROUP_CHANNEL_UNREAD_MENTION_COUNT="group_channel_unread_mention_count",y.NONSUPER_UNREAD_MENTION_COUNT="non_super_group_channel_unread_mention_count",y.SUPER_UNREAD_MENTION_COUNT="super_group_channel_unread_mention_count",y.GROUP_CHANNEL_UNREAD_MESSAGE_COUNT="group_channel_unread_message_count",y.NONSUPER_UNREAD_MESSAGE_COUNT="non_super_group_channel_unread_message_count",y.SUPER_UNREAD_MESSAGE_COUNT="super_group_channel_unread_message_count",y.GROUP_CHANNEL_INVITATION_COUNT="group_channel_invitation_count",y.NONSUPER_INVITATION_COUNT="non_super_group_channel_invitation_count",y.SUPER_INVITATION_COUNT="super_group_channel_invitation_count";const A={keys:[]},b={channelCustomTypesFilter:void 0,superChannelFilter:exports.SuperChannelFilter.ALL},N=e=>d.isArrayOf("string",e.channelCustomTypesFilter,!0)&&d.isEnumOf(exports.SuperChannelFilter,e.superChannelFilter),T={channelUrl:void 0,scheduledStatus:void 0,messageTypeFilter:d.MessageTypeFilter.ALL},U=Object.assign({},d.CollectionEventSource),I=e=>e.startsWith("EVENT_")||e===d.CollectionEventSource.SYNC_CHANNEL_CHANGELOGS||e===d.CollectionEventSource.REFRESH_CHANNEL;class P extends d.BaseCommand{constructor({channels:e,source:t,isWebSocketEventComing:s=!1,data:n=null,ts:i}){super(),this.channels=e,this.source=t,this.isWebSocketEventComing=s,this.data=n,this.ts=i}}class x extends d.BaseCommand{constructor({channelUrls:e,source:t,isWebSocketEventComing:s=!1}){super(),this.channelUrls=e,this.source=t,this.isWebSocketEventComing=s}}class O{constructor({groupChannelCache:e,messageCache:t,unsentMessageCache:s,dispatcher:n}){this._observers=new Map,n.on((n=>d.__awaiter(this,void 0,void 0,(function*(){if(n instanceof P){const{channels:s,source:i,isWebSocketEventComing:a,data:r}=n,o=s.filter((e=>e instanceof kt)),l=e.filterOffsetChanged(o);for(const e of l)yield t.removeUnderOffset(e.url,e.messageOffsetTimestamp);const d=yield e.upsert(o,n.ts);a||this._broadcastUpdateEvent(d,i,r)}else if(n instanceof x){const{channelUrls:i,source:a,isWebSocketEventComing:r}=n;yield e.remove(i),yield d.runOrNothing((()=>d.__awaiter(this,void 0,void 0,(function*(){for(const e of i)yield t.removeMessagesOfChannel(e),yield s.removeMessagesOfChannel(e)})))),r||this._broadcastRemoveEvent(i,a)}else n instanceof c.DatabaseOpenCommand&&(yield e.fetch({token:Number.MAX_SAFE_INTEGER,limit:Number.MAX_SAFE_INTEGER}))}))))}_broadcastUpdateEvent(e,t,s){for(const n of this._observers.values())n.onUpdate&&n.onUpdate(e,t,s)}_broadcastRemoveEvent(e,t){for(const s of this._observers.values())s.onRemove&&s.onRemove(e,t)}subscribe(e,t){this._observers.set(e,t)}unsubscribe(e){this._observers.delete(e)}unsubscribeAll(){this._observers.clear()}}class w extends d.APIRequestCommand{constructor({userId:e,ts:t,token:s,filter:n,includeChatNotification:i=!1}){super();const{customTypes:a,includeEmpty:r,includeFrozen:o}=Object.assign(Object.assign({},v),n);this.method=d.APIRequestMethod.GET,this.path=`${d.API_PATH_USERS}/${encodeURIComponent(e)}/my_group_channels/changelogs`,this.params=d.deundefined(d.undefineNullProps({show_delivery_receipt:!0,show_member:!0,show_read_receipt:!0,change_ts:t||null,token:s,custom_types:a,show_empty:r,show_frozen:o,include_chat_notification:i}))}}class R extends d.APIResponseCommand{constructor(e,t){super(e,t),this.updatedChannels=t.updated.map((s=>new kt(e,Object.assign(s,{ts:t.ts})))),this.deletedChannelUrls=t.deleted,this.hasMore=t.has_more,this.token=t.next,this.ts=t.ts}}class L extends d.APIRequestCommand{constructor({channelUrl:e,isInternalCall:t}){super(),this.method=d.APIRequestMethod.GET,this.path=`${t?d.API_PATH_GROUP_CHANNELS_INTERNAL:d.API_PATH_GROUP_CHANNELS}/${encodeURIComponent(e)}`,this.params={show_member:!0,show_read_receipt:!0,show_delivery_receipt:!0}}}class F extends d.APIResponseCommand{constructor(e,t){super(e,t),this.channel=new kt(e,t)}}const D={includeEmpty:!1,includeFrozen:!0,includeMetaData:!0,includeChatNotification:!1,channelUrlsFilter:void 0,customTypesFilter:void 0,customTypeStartsWithFilter:void 0,nicknameContainsFilter:void 0,nicknameStartsWithFilter:void 0,nicknameExactMatchFilter:void 0,channelNameContainsFilter:void 0,myMemberStateFilter:exports.MyMemberStateFilter.ALL,unreadChannelFilter:exports.UnreadChannelFilter.ALL,superChannelFilter:exports.SuperChannelFilter.ALL,publicChannelFilter:exports.PublicChannelFilter.ALL,hiddenChannelFilter:exports.HiddenChannelFilter.ALL,userIdsFilter:{userIds:[],includeMode:!0,queryType:exports.QueryType.AND},searchFilter:{query:void 0,fields:[]},metadataKey:void 0,metadataValues:void 0,metadataOrderKeyFilter:void 0,metadataValueStartsWith:void 0,order:c.GroupChannelListOrder.LATEST_LAST_MESSAGE,createdAfter:void 0,createdBefore:void 0};class k extends d.APIRequestCommand{constructor(e){const{userId:t,token:s,limit:n,order:i,includeEmpty:a,myMemberStateFilter:r,superChannelFilter:o,publicChannelFilter:l,unreadChannelFilter:h,nicknameContainsFilter:c,nicknameStartsWithFilter:u,nicknameExactMatchFilter:_,channelNameContainsFilter:p,channelUrlsFilter:m,customTypesFilter:g,customTypeStartsWithFilter:C,hiddenChannelFilter:E,metadataOrderKeyFilter:v,metadataKey:f,metadataValues:M,metadataValueStartsWith:S,includeFrozen:y,includeMetaData:A,searchFilter:b,userIdsFilter:N,includeChatNotification:T=!1,createdAfter:U,createdBefore:I}=e;super(),this.method=d.APIRequestMethod.GET,this.path=`${d.API_PATH_USERS}/${encodeURIComponent(t)}/my_group_channels`,this.params=d.deundefined({token:s,limit:n,order:null!=i?i:D.order,show_member:!0,show_read_receipt:!0,show_delivery_receipt:!0,show_empty:null!=a?a:D.includeEmpty,member_state_filter:null!=r?r:D.myMemberStateFilter,super_mode:null!=o?o:D.superChannelFilter,public_mode:null!=l?l:D.publicChannelFilter,unread_filter:null!=h?h:D.unreadChannelFilter,members_nickname_contains:c,members_nickname_startswith:u,members_nickname:_,name_contains:p,channel_urls:m,custom_types:g,custom_type_startswith:C,hidden_mode:E,metadata_order_key:v,metadata_key:f,metadata_values:M,metadata_value_startswith:S,show_frozen:y,show_metadata:A,include_chat_notification:T,created_after:U,created_before:I}),b&&b.query&&b.fields&&(this.params.search_query=b.query,this.params.search_fields=b.fields),N&&N.userIds&&N.userIds.length>0&&(N.includeMode?(this.params.members_include_in=N.userIds,this.params.query_type=N.queryType.toUpperCase()):this.params.members_exactly_in=N.userIds)}}class H extends d.APIResponseCommand{constructor(e,t){super(e,t),this.channels=[];const{next:s,channels:n,ts:i}=t;this.token=s,n&&n.length>0&&(this.channels=n.map((t=>(t.ts=i,new kt(e,t))))),this.ts=null!=i?i:0}}class V extends d.APIRequestCommand{constructor({userId:e,filter:t}){super();const{myMemberStateFilter:s}=t;this.method=d.APIRequestMethod.GET,this.path=`${d.API_PATH_USERS}/${encodeURIComponent(e)}/group_channel_count`,this.params={state:null!=s?s:exports.MyMemberStateFilter.ALL}}}class G extends d.APIResponseCommand{constructor(e,t){super(e,t),this.groupChannelCount=t.group_channel_count}}class q extends d.APIRequestCommand{constructor({userId:e,filter:t}){super();const{keys:s}=t;this.method=d.APIRequestMethod.GET,this.path=`${d.API_PATH_USERS}/${encodeURIComponent(e)}/unread_item_count`,this.params=d.deundefined({item_keys:s})}}class B extends d.APIResponseCommand{constructor(e,t){super(e,t),"number"==typeof t[exports.UnreadItemKey.GROUP_CHANNEL_UNREAD_MENTION_COUNT]&&(this.groupChannelUnreadMentionCount=t[exports.UnreadItemKey.GROUP_CHANNEL_UNREAD_MENTION_COUNT]),"number"==typeof t[exports.UnreadItemKey.GROUP_CHANNEL_UNREAD_MESSAGE_COUNT]&&(this.groupChannelUnreadMessageCount=t[exports.UnreadItemKey.GROUP_CHANNEL_UNREAD_MESSAGE_COUNT]),"number"==typeof t[exports.UnreadItemKey.GROUP_CHANNEL_INVITATION_COUNT]&&(this.groupChannelInvitationCount=t[exports.UnreadItemKey.GROUP_CHANNEL_INVITATION_COUNT]),"number"==typeof t[exports.UnreadItemKey.SUPER_UNREAD_MENTION_COUNT]&&(this.superGroupChannelUnreadMentionCount=t[exports.UnreadItemKey.SUPER_UNREAD_MENTION_COUNT]),"number"==typeof t[exports.UnreadItemKey.SUPER_UNREAD_MESSAGE_COUNT]&&(this.superGroupChannelUnreadMessageCount=t[exports.UnreadItemKey.SUPER_UNREAD_MESSAGE_COUNT]),"number"==typeof t[exports.UnreadItemKey.SUPER_INVITATION_COUNT]&&(this.superGroupChannelInvitationCount=t[exports.UnreadItemKey.SUPER_INVITATION_COUNT]),"number"==typeof t[exports.UnreadItemKey.NONSUPER_UNREAD_MENTION_COUNT]&&(this.nonSuperGroupChannelUnreadMentionCount=t[exports.UnreadItemKey.NONSUPER_UNREAD_MENTION_COUNT]),"number"==typeof t[exports.UnreadItemKey.NONSUPER_UNREAD_MESSAGE_COUNT]&&(this.nonSuperGroupChannelUnreadMessageCount=t[exports.UnreadItemKey.NONSUPER_UNREAD_MESSAGE_COUNT]),"number"==typeof t[exports.UnreadItemKey.NONSUPER_INVITATION_COUNT]&&(this.nonSuperGroupChannelInvitationCount=t[exports.UnreadItemKey.NONSUPER_INVITATION_COUNT])}}class j extends d.APIRequestCommand{constructor({userId:e}){super(),this.method=d.APIRequestMethod.GET,this.path=`${d.API_PATH_USERS}/${encodeURIComponent(e)}/unread_channel_count`}}class z extends d.APIResponseCommand{constructor(e,t){super(e,t),this.unreadCount=t.unread_count}}class W extends d.APIRequestCommand{constructor({userId:e,filter:t,includeFeedChannel:s=!1}){super();const{channelCustomTypesFilter:n,superChannelFilter:i}=t;this.method=d.APIRequestMethod.GET,this.path=`${d.API_PATH_USERS}/${encodeURIComponent(e)}/unread_message_count`,this.params={super_mode:null!=i?i:exports.SuperChannelFilter.ALL,custom_types:n,include_feed_channel:s}}}class $ extends d.APIResponseCommand{constructor(e,t){super(e,t),this.unreadCount=t.unread_count,this.unreadFeedCount=t.unread_feed_count}}class Q extends d.APIRequestCommand{constructor({channelUrl:e,scheduledStatus:t,messageTypeFilter:s}){super(),this.method=d.APIRequestMethod.GET,this.path=`${d.API_PATH_SCHEDULED_MESSAGES}/count`,this.params={channel_url:e,status:Y(t)},s&&(this.params.message_type=s)}}class K extends d.APIResponseCommand{constructor(e,t){super(e,t),this.count=t.count}}const Y=e=>{if(!e)return[];const t=[];return e.forEach((e=>{switch(e){case h.ScheduledStatus.PENDING:t.push(h.InternalScheduledStatus.PENDING);break;case h.ScheduledStatus.SENT:t.push(h.InternalScheduledStatus.IN_QUEUE),t.push(h.InternalScheduledStatus.SENT);break;case h.ScheduledStatus.CANCELED:t.push(h.InternalScheduledStatus.CANCELED);break;case h.ScheduledStatus.FAILED:t.push(h.InternalScheduledStatus.FAILED)}})),t};class J extends d.APIRequestCommand{constructor(e){const{userId:t,channelUrl:s,coverUrl:n,coverImage:i,isDistinct:a,isSuper:r,isBroadcast:o,isPublic:l,isExclusive:h,isDiscoverable:c,isStrict:u,isEphemeral:_,accessCode:p,name:m,data:g,customType:C,messageSurvivalSeconds:E,invitedUserIds:v,operatorUserIds:f}=e;super(),this.method=d.APIRequestMethod.POST,this.path=d.API_PATH_GROUP_CHANNELS,this.params=d.deundefined({user_ids:[t,...null!=v?v:[]].filter(((e,t,s)=>t===s.indexOf(e))),channel_url:s,cover_url:n,cover_file:i,is_distinct:a,is_super:r,is_broadcast:o,is_exclusive:h,is_public:l,is_discoverable:c,strict:u,is_ephemeral:_,access_code:p,name:m,data:g,custom_type:C,operator_ids:f,message_survival_seconds:E})}}class X extends d.APIResponseCommand{constructor(e,t){var s;super(e,t),this.channel=new kt(e,t),this.isCreated=null===(s=t.is_created)||void 0===s||s}}class Z extends d.APIRequestCommand{constructor({userId:e,channelUrls:t}){super(),this.method=d.APIRequestMethod.PUT,this.path=`${d.API_PATH_USERS}/${encodeURIComponent(e)}/mark_as_read_all`,this.params={channel_urls:t}}}class ee extends d.APIRequestCommand{constructor(e){const{channelUrl:t,userId:s,accessCode:n}=e;super(),this.method=d.APIRequestMethod.PUT,this.path=`${d.API_PATH_GROUP_CHANNELS}/${encodeURIComponent(t)}/join`,this.params={user_id:s,access_code:n}}}class te extends d.APIResponseCommand{constructor(e,t){super(e,t),this.channel=new kt(e,t)}}class se extends u.ChannelEventCommand{constructor(e,t,s){super(e,t,s);const{member_count:n=0,joined_member_count:i=0,users:a=null}=s.data;this.memberCount=n,this.joinedMemberCount=i,this.members=Array.isArray(a)?a.map((t=>new _(e,t))):[new _(e,s.data)]}}class ne extends d.APIRequestCommand{constructor(e){const{channelUrl:t,userId:s,shouldRemoveOperatorStatus:n}=e;super(),this.method=d.APIRequestMethod.PUT,this.path=`${d.API_PATH_GROUP_CHANNELS}/${encodeURIComponent(t)}/leave`,this.params={user_id:s,should_remove_operator_status:n}}}class ie extends u.ChannelEventCommand{constructor(e,t,s){super(e,t,s);const{member_count:n=0,joined_member_count:i=0}=s.data;this.memberCount=n,this.joinedMemberCount=i,this.member=new _(this._iid,s.data)}}class ae extends d.APIRequestCommand{constructor(e){const{channelUrl:t,userIds:s}=e;super(),this.method=d.APIRequestMethod.POST,this.path=`${d.API_PATH_GROUP_CHANNELS}/${encodeURIComponent(t)}/invite`,this.params={user_ids:s}}}class re extends d.APIResponseCommand{constructor(e,t){super(e,t),this.channel=new kt(e,t)}}class oe extends u.ChannelEventCommand{constructor(e,t,s){super(e,t,s),this.inviter=null;const{member_count:n=0,joined_member_count:i=0,inviter:a,invitees:r=[]}=s.data;this.memberCount=n,this.joinedMemberCount=i,a&&Object.keys(a).length>0&&(this.inviter=new d.User(e,a)),this.invitees=r.map((t=>new _(e,t)))}}class le extends d.APIRequestCommand{constructor(e){const{channelUrl:t,userId:s}=e;super(),this.method=d.APIRequestMethod.PUT,this.path=`${d.API_PATH_GROUP_CHANNELS}/${encodeURIComponent(t)}/decline`,this.params={user_id:s}}}class de extends u.ChannelEventCommand{constructor(e,t,s){super(e,t,s);const{member_count:n,joined_member_count:i,inviter:a,invitee:r}=s.data;this.memberCount=null!=n?n:0,this.joinedMemberCount=null!=i?i:0,this.inviter=new d.User(e,a),this.invitee=new _(e,r)}}const he={hidePreviousMessages:!1,allowAutoUnhide:!0};class ce extends d.APIRequestCommand{constructor(e){const{channelUrl:t,userId:s,hidePreviousMessages:n,allowAutoUnhide:i}=e;super(),this.method=d.APIRequestMethod.PUT,this.path=`${d.API_PATH_GROUP_CHANNELS}/${encodeURIComponent(t)}/hide`,this.params={user_id:s,hide_previous_messages:null!=n?n:he.hidePreviousMessages,allow_auto_unhide:null!=i?i:he.allowAutoUnhide}}}class ue extends d.APIResponseCommand{constructor(e,t){super(e,t);const{ts_message_offset:s}=t;this.messageOffsetTimestamp=s}}class _e extends d.WebSocketEventCommand{constructor(e,t,s){var n,i,a;super(e,"SYEV",s),this.allowAutoUnhide=null,this.hidePreviousMessages=null,this.messageOffsetTimestamp=null,s.data&&(this.allowAutoUnhide=null!==(n=s.data.allow_auto_unhide)&&void 0!==n?n:null,this.hidePreviousMessages=null!==(i=s.data.hide_previous_messages)&&void 0!==i?i:null),this.messageOffsetTimestamp=null!==(a=s.ts_message_offset)&&void 0!==a?a:null}}class pe extends d.WebSocketRequestCommand{constructor({channelUrl:e,time:t}){super({code:"TPST",ackRequired:!1,payload:{channel_url:e,time:t}})}}class me extends d.WebSocketEventCommand{constructor(e,t,s){super(e,"SYEV",s),this.user=new d.User(e,s.data)}}class ge extends d.WebSocketRequestCommand{constructor({channelUrl:e,time:t}){super({code:"TPEN",ackRequired:!1,payload:{channel_url:e,time:t}})}}class Ce extends d.WebSocketEventCommand{constructor(e,t,s){super(e,"SYEV",s),this.user=new d.User(e,s.data)}}class Ee extends d.WebSocketRequestCommand{constructor({channelUrl:e,messageId:t}){super({code:"MACK",ackRequired:!1,payload:{channel_url:e,msg_id:t}})}}class ve extends d.BaseListQuery{constructor(e,t){var s,n,i,a,r,o,l,d,h,u,_,p,m,g,C,E,v,f,M,S,y,A,b;super(e,t),this.includeEmpty=!1,this.includeFrozen=!0,this.includeMetaData=!0,this.includeChatNotification=!1,this.channelUrlsFilter=null,this.customTypesFilter=null,this.customTypeStartsWithFilter=null,this.nicknameContainsFilter=null,this.nicknameStartsWithFilter=null,this.nicknameExactMatchFilter=null,this.channelNameContainsFilter="",this.myMemberStateFilter=exports.MyMemberStateFilter.ALL,this.unreadChannelFilter=exports.UnreadChannelFilter.ALL,this.superChannelFilter=exports.SuperChannelFilter.ALL,this.publicChannelFilter=exports.PublicChannelFilter.ALL,this.hiddenChannelFilter=exports.HiddenChannelFilter.UNHIDDEN,this.searchFilter={fields:[],query:null},this.userIdsFilter={userIds:[],includeMode:!0,queryType:exports.QueryType.AND},this.metadataKey=null,this.metadataValues=null,this.metadataOrderKeyFilter=null,this.metadataValueStartsWith=null,this.order=c.GroupChannelListOrder.LATEST_LAST_MESSAGE,this.includeEmpty=null!==(s=t.includeEmpty)&&void 0!==s&&s,this.includeFrozen=null===(n=t.includeFrozen)||void 0===n||n,this.includeMetaData=null===(i=t.includeMetaData)||void 0===i||i,this.includeChatNotification=null!==(a=t.includeChatNotification)&&void 0!==a&&a,this.channelUrlsFilter=null!==(r=t.channelUrlsFilter)&&void 0!==r?r:null,this.customTypesFilter=null!==(o=t.customTypesFilter)&&void 0!==o?o:null,this.customTypeStartsWithFilter=null!==(l=t.customTypeStartsWithFilter)&&void 0!==l?l:"",this.nicknameContainsFilter=null!==(d=t.nicknameContainsFilter)&&void 0!==d?d:null,this.nicknameStartsWithFilter=null!==(h=t.nicknameStartsWithFilter)&&void 0!==h?h:null,this.nicknameExactMatchFilter=null!==(u=t.nicknameExactMatchFilter)&&void 0!==u?u:null,this.channelNameContainsFilter=null!==(_=t.channelNameContainsFilter)&&void 0!==_?_:"",this.myMemberStateFilter=null!==(p=t.myMemberStateFilter)&&void 0!==p?p:exports.MyMemberStateFilter.ALL,this.unreadChannelFilter=null!==(m=t.unreadChannelFilter)&&void 0!==m?m:exports.UnreadChannelFilter.ALL,this.superChannelFilter=null!==(g=t.superChannelFilter)&&void 0!==g?g:exports.SuperChannelFilter.ALL,this.publicChannelFilter=null!==(C=t.publicChannelFilter)&&void 0!==C?C:exports.PublicChannelFilter.ALL,this.hiddenChannelFilter=null!==(E=t.hiddenChannelFilter)&&void 0!==E?E:exports.HiddenChannelFilter.UNHIDDEN,this.searchFilter=null!==(v=t.searchFilter)&&void 0!==v?v:{fields:[],query:null},this.userIdsFilter=null!==(f=t.userIdsFilter)&&void 0!==f?f:{userIds:[],includeMode:!0,queryType:exports.QueryType.AND},this.metadataKey=null!==(M=t.metadataKey)&&void 0!==M?M:null,this.metadataValues=null!==(S=t.metadataValues)&&void 0!==S?S:null,this.metadataOrderKeyFilter=null!==(y=t.metadataOrderKeyFilter)&&void 0!==y?y:null,this.metadataValueStartsWith=null!==(A=t.metadataValueStartsWith)&&void 0!==A?A:null,this.order=null!==(b=t.order)&&void 0!==b?b:c.GroupChannelListOrder.LATEST_LAST_MESSAGE,t.createdAfter&&(this.createdAfter=t.createdAfter),t.createdBefore&&(this.createdBefore=t.createdBefore)}_validate(){return super._validate()&&d.isTypeOf("boolean",this.includeEmpty)&&d.isTypeOf("boolean",this.includeFrozen)&&d.isTypeOf("boolean",this.includeMetaData)&&d.isTypeOf("string",this.channelNameContainsFilter)&&d.isArrayOf("string",this.channelUrlsFilter,!0)&&d.isArrayOf("string",this.customTypesFilter,!0)&&d.isTypeOf("string",this.customTypeStartsWithFilter)&&d.isTypeOf("string",this.nicknameContainsFilter,!0)&&d.isTypeOf("string",this.nicknameStartsWithFilter,!0)&&d.isTypeOf("string",this.nicknameExactMatchFilter,!0)&&d.isEnumOf(exports.MyMemberStateFilter,this.myMemberStateFilter)&&d.isEnumOf(exports.SuperChannelFilter,this.superChannelFilter)&&d.isEnumOf(exports.PublicChannelFilter,this.publicChannelFilter)&&d.isEnumOf(exports.UnreadChannelFilter,this.unreadChannelFilter)&&d.isEnumOf(exports.HiddenChannelFilter,this.hiddenChannelFilter)&&d.isArrayOf(exports.GroupChannelSearchField,this.searchFilter.fields)&&d.isTypeOf("string",this.searchFilter.query,!0)&&d.isArrayOf("string",this.userIdsFilter.userIds)&&d.isTypeOf("boolean",this.userIdsFilter.includeMode)&&d.isEnumOf(exports.QueryType,this.userIdsFilter.queryType)&&d.isEnumOf(c.GroupChannelListOrder,this.order)&&d.isTypeOf("string",this.metadataOrderKeyFilter,!0)&&d.isTypeOf("string",this.metadataKey,!0)&&d.isArrayOf("string",this.metadataValues,!0)&&d.isTypeOf("string",this.metadataValueStartsWith,!0)&&d.isMilliSecondOf(this.createdAfter,!0)&&d.isMilliSecondOf(this.createdBefore,!0)}serialize(){return d.serialize(this)}next(){return d.__awaiter(this,void 0,void 0,(function*(){if(this._validate()){if(this._isLoading)throw d.SendbirdError.queryInProgress;if(this._hasNext){this._isLoading=!0;const e=Ie.of(this._iid),{channels:t,token:s}=yield e.getMyGroupChannels(this._token,d.undefineNullProps(Object.assign({},this)),this.limit);return this._token=s,this._hasNext=!!s,this._isLoading=!1,t}return[]}throw d.SendbirdError.invalidParameters}))}}class fe extends d.WebSocketEventCommand{constructor(e,t,s){var n;super(e,"SYEV",s),this.pinnedMessageIds=[],this.latestPinnedMessage=null,this.ts=0,s.data&&(this.pinnedMessageIds=null!==(n=s.data.pinned_message_ids)&&void 0!==n?n:[],this.latestPinnedMessage=s.data.latest_pinned_message?h.parseMessagePayload(e,Object.assign({},s.data.latest_pinned_message)):null),this.ts=s.ts}}class Me extends d.WebSocketRequestCommand{constructor({channelUrl:e}){super({code:"READ",ackRequired:!0,payload:{channel_url:e}})}}class Se extends d.APIRequestCommand{constructor({channelUrl:e,channelType:t,userId:s}){super(),this.method=d.APIRequestMethod.PUT,this.path=`${d.getChannelApiPathByType(t)}/${encodeURIComponent(e)}/messages/mark_as_read`,this.params=d.deundefined(d.undefineNullProps({user_id:encodeURIComponent(s)}))}}class ye extends d.WebSocketEventCommand{constructor(e,t,s){super(e,"READ",s),this.readStatus=new p(e,s)}}class Ae extends d.APIResponseCommand{constructor(e,t){super(e,t),this.readAt=t.ts}}class be extends d.APIRequestCommand{constructor({channelUrl:e,userId:t}){super(),super(),this.method=d.APIRequestMethod.PUT,this.path=`${d.API_PATH_GROUP_CHANNELS}/${encodeURIComponent(e)}/messages/mark_as_delivered`,this.params=d.deundefined({userId:t})}}class Ne extends d.WebSocketEventCommand{constructor(e,t,s){super(e,"DLVR",s),this.channelUrl=s.channel_url,this.deliveredStateUpdate=s.updated}}class Te{constructor({top:e=Number.MAX_SAFE_INTEGER,bottom:t=0}){this.top=e,this.bottom=t}includes(...e){return e.every((e=>this.top<=e&&e<=this.bottom))}overlap(e){return this.includes(e.top)||this.includes(e.bottom)}intersect(...e){return e.some((e=>this.top<=e&&e<=this.bottom))}extends(...e){this.top=Math.min(this.top,...e),this.bottom=Math.max(this.bottom,...e)}}const Ue={};class Ie extends u.BaseChannelManager{get _messageCache(){return h.MessageCache.of(this._iid)}get _unsentMessageCache(){return h.UnsentMessageCache.of(this._iid)}constructor(e,t){var s;super(e,Object.assign(Object.assign({},t),{channelType:d.ChannelType.GROUP})),this._leftChannels=new Map,this._disableMack=!1,this._markAsReadAllLastSentAt=0,this._disableMack=null!==(s=t.disableMack)&&void 0!==s&&s,this._groupChannelHandlers=new Map,this._groupChannelCache=new g(this._iid,{sdkState:t.sdkState,cacheContext:t.cacheContext}),this._groupChannelBroadcast=new O({dispatcher:t.dispatcher,groupChannelCache:this._groupChannelCache,messageCache:h.MessageCache.of(this._iid),unsentMessageCache:h.UnsentMessageCache.of(this._iid)}),setInterval((()=>{for(const e of this._groupChannelCache.channels)e.invalidateTypingStatus()&&(this._dispatcher.dispatch(new P({channels:[e],source:d.CollectionEventSource.EVENT_CHANNEL_TYPING_STATUS_UPDATE})),this._groupChannelHandlers.forEach((t=>{t.onTypingStatusUpdated&&t.onTypingStatusUpdated(e)})))}),1e3),this._dispatcher.on((e=>{e instanceof d.WebSocketEventCommand?this._handleEvent(e):e instanceof c.AutoResendRequestCommand?(()=>{d.__awaiter(this,void 0,void 0,(function*(){const{message:t}=e,s=yield this.getChannel(t.channelUrl,!0);t instanceof h.UserMessage?s._autoResendUserMessage(t):t instanceof h.FileMessage&&s._autoResendFileMessage(t)}))})():e instanceof c.ReduceDBSizeEventCommand&&this.reduceDBSize()})),Ue[e]||(Ue[e]=this)}static of(e){return Ue[e]||(Ue[e]=new Ie(e,d.Vault.of(e))),Ue[e]}static clear(e){Ue[e]&&delete Ue[e]}get handlers(){return[...this._groupChannelHandlers.values()]}buildGroupChannelFromSerializedData(e){const t=d.deserialize(e);return new kt(this._iid,kt.payloadify(t))}buildGroupChannelListQueryFromSerializedData(e){const t=d.deserialize(e);return new ve(this._iid,t)}buildMemberFromSerializedData(e){const t=d.deserialize(e);return new _(this._iid,_.payloadify(t))}getChannelFromCache(e){var t;return d.__awaiter(this,void 0,void 0,(function*(){return null!==(t=yield this._groupChannelCache.get(e))&&void 0!==t?t:null}))}getChannelsFromCache(e,t,s,n,i){return d.__awaiter(this,void 0,void 0,(function*(){return yield this._groupChannelCache.fetch({token:e,filter:t,order:s,limit:n,borderlineChannelUrl:i})}))}upsertChannelsToCache(e){return d.__awaiter(this,void 0,void 0,(function*(){return yield this._groupChannelCache.upsert(e)}))}removeChannelsFromCache(e){return d.__awaiter(this,void 0,void 0,(function*(){yield this._groupChannelCache.remove(e)}))}clearChannelsFromCache(){return d.__awaiter(this,void 0,void 0,(function*(){yield this._groupChannelCache.clear()}))}reduceDBSize(){return d.__awaiter(this,void 0,void 0,(function*(){const e=h.MessageCache.of(this._iid),{cacheContext:t}=d.Vault.of(this._iid),{localCacheConfig:s,nestdb:n}=t;if(!t.localCacheEnabled||!n||n.state!=h.NestDBState.OPENED)return;const i=1024*s.maxSize*1024;let a=yield n.estimateUsage();if(ad.__awaiter(this,void 0,void 0,(function*(){const t=new Ee(e);this._requestQueue.send(t)}))));const s=this._groupChannelCache.isCachedInMemory(e.channelUrl),a=e instanceof h.SendableMessage&&e.sender.userId===this._sdkState.userId,r=yield this.getChannel(e.channelUrl,!0);if(r.hiddenState===exports.HiddenState.HIDDEN_ALLOW_AUTO_UNHIDE&&(r.hiddenState=exports.HiddenState.UNHIDDEN),e instanceof h.SendableMessage){const{useMemberInfoInMessage:s}=d.Vault.of(this._iid);for(const t of r.members)if(t.userId===e.sender.userId){s||(e.sender.nickname=t.nickname,e.sender.plainProfileUrl=t.plainProfileUrl,e.sender.metaData=t.metaData,e.sender.isBlockedByMe=t.isBlockedByMe);break}if(!s&&n&&(null===(t=e.mentionedUsers)||void 0===t||t.forEach((e=>{for(const t of r.members)if(e.userId===t.userId){e.nickname=t.nickname,e.plainProfileUrl=t.plainProfileUrl,e.metaData=t.metaData;break}}))),a){const{currentUser:t}=this._sessionManager;t&&(t.nickname=e.sender.nickname,t.plainProfileUrl=e.sender.plainProfileUrl,t.metaData=e.sender.metaData)}}e.silent&&!a||(r.isEphemeral||s)&&((!r.lastMessage||r.lastMessage.createdAtd.__awaiter(this,void 0,void 0,(function*(){for(const e of this._groupChannelHandlers.values())e.onChannelChanged&&e.onChannelChanged(r)})))),this._dispatcher.dispatch(new d.MessageUpdateEventCommand({messages:[e],source:d.CollectionEventSource.EVENT_MESSAGE_RECEIVED})),d.runAsCallback((()=>d.__awaiter(this,void 0,void 0,(function*(){for(const t of this._groupChannelHandlers.values())t.onMessageReceived&&t.onMessageReceived(r,e),n&&t.onMentionReceived&&t.onMentionReceived(r,e)}))))}}break}case"MEDI":case"FEDI":case"AEDI":{let t=null;if("MEDI"===e.code?t=e.as(h.UpdateUserMessageEventCommand):"FEDI"===e.code?t=e.as(h.UpdateFileMessageEventCommand):"AEDI"===e.code&&(t=e.as(u.UpdateAdminMessageEventCommand)),t){const{message:e,mentionCountChange:s}=t;if(e.channelType===d.ChannelType.GROUP){const t=this._groupChannelCache.isCachedInMemory(e.channelUrl),n=yield this.getChannel(e.channelUrl,!0),i=e instanceof h.SendableMessage&&e.sender.userId===this._sdkState.userId;let a=!1;if(i){const t=e.sender,{currentUser:s}=this._sessionManager;s&&(s.nickname=t.nickname,s.plainProfileUrl=t.plainProfileUrl,s.metaData=t.metaData)}else n.isReadMessage(e)||0!==s&&!e.silent&&t&&(n._updateUnreadCount(n.unreadMessageCount,n.unreadMentionCount+s),a=!0);!n.lastMessage||n.lastMessage.createdAtd.__awaiter(this,void 0,void 0,(function*(){for(const e of this._groupChannelHandlers.values())e.onChannelChanged&&e.onChannelChanged(n)})))),r&&d.runAsCallback((()=>d.__awaiter(this,void 0,void 0,(function*(){for(const e of this._groupChannelHandlers.values())e.onPinnedMessageUpdated&&e.onPinnedMessageUpdated(n)}))))),this._dispatcher.dispatch(new d.MessageUpdateEventCommand({messages:[e],source:d.CollectionEventSource.EVENT_MESSAGE_UPDATED})),d.runAsCallback((()=>d.__awaiter(this,void 0,void 0,(function*(){for(const t of this._groupChannelHandlers.values())t.onMessageUpdated&&t.onMessageUpdated(n,e),0!==s&&t.onMentionReceived&&t.onMentionReceived(n,e)}))))}}break}case"DELM":{const{channelUrl:t,channelType:s,messageId:n}=e.as(h.DeleteMessageEventCommand);if(s===d.ChannelType.GROUP){const e=yield this.getChannel(t,!0);this._dispatcher.dispatch(new d.MessageRemoveEventCommand({messageIds:[n],source:d.CollectionEventSource.EVENT_MESSAGE_DELETED})),d.runAsCallback((()=>d.__awaiter(this,void 0,void 0,(function*(){for(const t of this._groupChannelHandlers.values())t.onMessageDeleted&&t.onMessageDeleted(e,n)}))))}break}case"READ":{const{readStatus:t}=e.as(ye);if(t.channelType===d.ChannelType.GROUP){const e=this._groupChannelCache.isCachedInMemory(t.channelUrl),s=yield this.getChannel(t.channelUrl,!0);e&&s._updateUnreadMemberState(t.reader.userId,t.readAt),t.reader.userId===this._sdkState.userId?e?(s.unreadMessageCount>0||s.unreadMentionCount>0)&&(s._updateUnreadCount(0,0),this._dispatcher.dispatch(new P({channels:[s],source:d.CollectionEventSource.EVENT_CHANNEL_READ})),d.runAsCallback((()=>d.__awaiter(this,void 0,void 0,(function*(){for(const e of this._groupChannelHandlers.values())e.onChannelChanged&&e.onChannelChanged(s)}))))):0!==s.unreadMessageCount&&0!==s.unreadMentionCount||(this._dispatcher.dispatch(new P({channels:[s],source:d.CollectionEventSource.EVENT_CHANNEL_READ})),d.runAsCallback((()=>d.__awaiter(this,void 0,void 0,(function*(){for(const e of this._groupChannelHandlers.values())e.onChannelChanged&&e.onChannelChanged(s)}))))):(this._dispatcher.dispatch(new P({channels:[s],source:d.CollectionEventSource.EVENT_CHANNEL_READ})),d.runAsCallback((()=>d.__awaiter(this,void 0,void 0,(function*(){for(const e of this._groupChannelHandlers.values())e.onUnreadMemberStatusUpdated&&e.onUnreadMemberStatusUpdated(s)})))))}break}case"DLVR":{const{channelUrl:t,deliveredStateUpdate:s={}}=e.as(Ne),n=this._groupChannelCache.isCachedInMemory(t),i=yield this.getChannel(t,!0);if(n)for(const e in s)i._updateUndeliveredMemberState(e,s[e]);Object.keys(s).some((e=>e!==this._sdkState.userId))&&(this._dispatcher.dispatch(new P({channels:[i],source:d.CollectionEventSource.EVENT_CHANNEL_DELIVERED})),d.runAsCallback((()=>d.__awaiter(this,void 0,void 0,(function*(){for(const e of this._groupChannelHandlers.values())e.onUndeliveredMemberStatusUpdated&&e.onUndeliveredMemberStatusUpdated(i)})))));break}case"MRCT":{const{channelUrl:t,channelType:s,event:n}=e.as(u.ReactionEventCommand);if(s===d.ChannelType.GROUP){const e=yield this.getChannel(t,!0),s=yield this.getMessageFromCache(n.messageId);s instanceof h.BaseMessage&&(s.applyReactionEvent(n),this._dispatcher.dispatch(new d.MessageUpdateEventCommand({messages:[s],source:d.CollectionEventSource.EVENT_MESSAGE_REACTION_UPDATED}))),d.runAsCallback((()=>d.__awaiter(this,void 0,void 0,(function*(){for(const t of this._groupChannelHandlers.values())t.onReactionUpdated&&t.onReactionUpdated(e,n)}))))}break}case"MTHD":{const{event:t}=e.as(u.ThreadInfoUpdateEventCommand);if(t.channelType===d.ChannelType.GROUP){const e=yield this.getChannel(t.channelUrl,!0),s=yield this.getMessageFromCache(t.targetMessageId);s instanceof h.BaseMessage&&(s.applyThreadInfoUpdateEvent(t),this._dispatcher.dispatch(new d.MessageUpdateEventCommand({messages:[s],source:d.CollectionEventSource.EVENT_MESSAGE_THREADINFO_UPDATED}))),d.runAsCallback((()=>d.__awaiter(this,void 0,void 0,(function*(){for(const s of this._groupChannelHandlers.values())s.onThreadInfoUpdated&&s.onThreadInfoUpdated(e,t)}))))}break}case"MCNT":{const{groupChannelMemberCounts:t}=e.as(u.MemberCountUpdateEventCommand),s=[];for(const e of t){const{channelUrl:t,memberCount:n,joinedMemberCount:i,updatedAt:a}=e,r=yield this.getChannelFromCache(t);r&&r._setLatestMemberCount(n,i,a)&&s.push(r)}s.length>0&&(this._dispatcher.dispatch(new P({channels:s,source:d.CollectionEventSource.EVENT_CHANNEL_MEMBER_COUNT_UPDATED})),d.runAsCallback((()=>d.__awaiter(this,void 0,void 0,(function*(){for(const e of this._groupChannelHandlers.values())e.onChannelMemberCountChanged&&e.onChannelMemberCountChanged(s)})))));break}case"PEDI":{const{event:t,status:s,channelUrl:n,channelType:i}=e.as(u.PollUpdateEventCommand);if(n&&i===d.ChannelType.GROUP){const e=yield this.getChannel(n,!0);this._dispatcher.dispatch(new d.PollUpdateInternalEventCommand({event:t,source:d.CollectionEventSource.EVENT_POLL_UPDATED})),s===d.POLL_REMOVED_STATUS?d.runAsCallback((()=>d.__awaiter(this,void 0,void 0,(function*(){for(const s of this._groupChannelHandlers.values())s.onPollDeleted&&s.onPollDeleted(e,t.pollId)})))):d.runAsCallback((()=>d.__awaiter(this,void 0,void 0,(function*(){for(const s of this._groupChannelHandlers.values())s.onPollUpdated&&s.onPollUpdated(e,t)}))))}break}case"VOTE":{const{event:t,channelUrl:s,channelType:n}=e.as(h.PollVoteEventCommand);if(s&&n===d.ChannelType.GROUP){const e=yield this.getChannel(s,!0);this._dispatcher.dispatch(new d.PollVoteInternalEventCommand({event:t,source:d.CollectionEventSource.EVENT_POLL_VOTED})),d.runAsCallback((()=>d.__awaiter(this,void 0,void 0,(function*(){for(const s of this._groupChannelHandlers.values())s.onPollVoted&&s.onPollVoted(e,t)}))))}break}case"SYEV":{const{event:t}=e.as(u.ChannelEventCommand);if(t.isGroupChannelEvent)switch(t.category){case u.ChannelEventCategory.CHANNEL_JOIN:{const s=yield this.getChannel(t.channelUrl,!0),{memberCount:n,joinedMemberCount:i,members:a}=e.as(se);let r=!1;a.forEach((e=>{s.isExclusive||s.isSuper||s.isBroadcast?r=r||s._setLatestMemberCount(n,i,t.ts):(e.state=exports.MemberState.JOINED,s.addMember(e,t.ts),this._updateJoinedMemberCount(s)),e.userId===this._sdkState.userId&&(s.myMemberState=exports.MemberState.JOINED)})),this._dispatcher.dispatch(new P({channels:[s],source:d.CollectionEventSource.EVENT_CHANNEL_JOINED})),d.runAsCallback((()=>d.__awaiter(this,void 0,void 0,(function*(){this._groupChannelHandlers.forEach((e=>{for(const t of a)e.onUserJoined&&e.onUserJoined(s,t);s.isBroadcast&&r&&e.onChannelMemberCountChanged&&e.onChannelMemberCountChanged([s])}))}))));break}case u.ChannelEventCategory.CHANNEL_LEAVE:{const s=this._leftChannels.get(t.channelUrl),n=s?s.channel:yield this.getChannel(t.channelUrl,!0),{memberCount:i,joinedMemberCount:a,member:r}=e.as(ie);let o=!1;const{appInfo:l}=d.Vault.of(this._iid);if(n.isExclusive||n.isSuper||n.isBroadcast)o=n._setLatestMemberCount(i,a,t.ts);else{if(null==l?void 0:l.enabledChannelMemberShipHistory){const e=n.members.find((t=>t.userId===e.userId));e&&(e.state=exports.MemberState.LEFT),n.memberCount=i}else n.removeMember(r);this._updateJoinedMemberCount(n)}r.userId===this._sdkState.userId?(n.myMemberState=exports.MemberState.NONE,n.invitedAt=0,n.joinedAt=0,n._updateUnreadCount(0,0),n.isPublic?this._dispatcher.dispatch(new P({channels:[n],source:d.CollectionEventSource.EVENT_CHANNEL_LEFT})):(this._markAsLeave(n),this._dispatcher.dispatch(new x({channelUrls:[n.url],source:d.CollectionEventSource.EVENT_CHANNEL_LEFT})))):this._dispatcher.dispatch(new P({channels:[n],source:d.CollectionEventSource.EVENT_CHANNEL_LEFT})),d.runAsCallback((()=>d.__awaiter(this,void 0,void 0,(function*(){this._groupChannelHandlers.forEach((e=>{e.onUserLeft&&e.onUserLeft(n,r),n.isBroadcast&&o&&e.onChannelMemberCountChanged&&e.onChannelMemberCountChanged([n])}))}))));break}case u.ChannelEventCategory.CHANNEL_OPERATOR_UPDATE:{const s=yield this.getChannel(t.channelUrl,!0),{operators:n}=e.as(u.OperatorUpdateEventCommand),i=n.map((e=>e.userId));for(const e of s.members)e.role=i.includes(e.userId)?d.Role.OPERATOR:d.Role.NONE;s.myRole=i.includes(this._sdkState.userId)?d.Role.OPERATOR:d.Role.NONE,this._dispatcher.dispatch(new P({channels:[s],source:d.CollectionEventSource.EVENT_CHANNEL_OPERATOR_UPDATED})),d.runAsCallback((()=>d.__awaiter(this,void 0,void 0,(function*(){this._groupChannelHandlers.forEach((e=>{e.onOperatorUpdated&&e.onOperatorUpdated(s,n)}))}))));break}case u.ChannelEventCategory.CHANNEL_INVITE:{const s=yield this.getChannel(t.channelUrl,!0),{memberCount:n,joinedMemberCount:i,inviter:a,invitees:r}=e.as(oe);r.forEach((e=>e.state=exports.MemberState.INVITED));for(const e of r)s.isExclusive||s.isSuper||s.isBroadcast?s._setLatestMemberCount(n,i,t.ts):s.addMember(e,t.ts),this._sdkState.userId===e.userId&&(s.hiddenState=exports.HiddenState.UNHIDDEN,s.myMemberState!==exports.MemberState.JOINED&&(s.myMemberState=exports.MemberState.INVITED),s.invitedAt=t.ts);this._dispatcher.dispatch(new P({channels:[s],source:d.CollectionEventSource.EVENT_CHANNEL_INVITED})),d.runAsCallback((()=>d.__awaiter(this,void 0,void 0,(function*(){this._groupChannelHandlers.forEach((e=>{e.onUserReceivedInvitation&&e.onUserReceivedInvitation(s,a,r)}))}))));break}case u.ChannelEventCategory.CHANNEL_DECLINE_INVITE:{const s=yield this.getChannel(t.channelUrl,!0),{memberCount:n,joinedMemberCount:i,inviter:a,invitee:r}=e.as(de);s.isExclusive||s.isSuper||s.isBroadcast?s._setLatestMemberCount(n,i,t.ts):s.removeMember(r),this._sdkState.userId===r.userId?(s.invitedAt=0,s.myMemberState=exports.MemberState.NONE,s.isPublic?this._dispatcher.dispatch(new P({channels:[s],source:d.CollectionEventSource.EVENT_CHANNEL_DECLINED_INVITE})):this._dispatcher.dispatch(new x({channelUrls:[s.url],source:d.CollectionEventSource.EVENT_CHANNEL_DECLINED_INVITE}))):this._dispatcher.dispatch(new P({channels:[s],source:d.CollectionEventSource.EVENT_CHANNEL_DECLINED_INVITE})),d.runAsCallback((()=>d.__awaiter(this,void 0,void 0,(function*(){this._groupChannelHandlers.forEach((e=>{e.onUserDeclinedInvitation&&e.onUserDeclinedInvitation(s,a,r)}))}))));break}case u.ChannelEventCategory.TYPING_START:case u.ChannelEventCategory.TYPING_END:{const s=yield this.getChannel(t.channelUrl,!0),n=t.category===u.ChannelEventCategory.TYPING_START,{user:i}=e.as(n?me:Ce);s._updateTypingStatus(i,n?t.ts:0),this._dispatcher.dispatch(new P({channels:[s],source:d.CollectionEventSource.EVENT_CHANNEL_TYPING_STATUS_UPDATE})),d.runAsCallback((()=>d.__awaiter(this,void 0,void 0,(function*(){this._groupChannelHandlers.forEach((e=>{e.onTypingStatusUpdated&&e.onTypingStatusUpdated(s)}))}))));break}case u.ChannelEventCategory.USER_CHANNEL_MUTE:case u.ChannelEventCategory.USER_CHANNEL_UNMUTE:{const s=yield this.getChannel(t.channelUrl,!0),n=t.category===u.ChannelEventCategory.USER_CHANNEL_MUTE,{user:i}=e.as(n?h.MuteUserEventCommand:h.UnmuteUserEventCommand);i.userId===this._sdkState.userId&&(s.myMutedState=n?d.MutedState.MUTED:d.MutedState.UNMUTED,s._myMutedRemainingTime=i.restrictionInfo.remainingDuration);for(const e of s.members)if(e.userId===i.userId){e.isMuted=n;break}this._dispatcher.dispatch(new P({channels:[s],source:n?d.CollectionEventSource.EVENT_CHANNEL_MUTED:d.CollectionEventSource.EVENT_CHANNEL_UNMUTED,data:i.userId})),d.runAsCallback((()=>d.__awaiter(this,void 0,void 0,(function*(){this._groupChannelHandlers.forEach((e=>{n?e.onUserMuted&&e.onUserMuted(s,i):e.onUserUnmuted&&e.onUserUnmuted(s,i)}))}))));break}case u.ChannelEventCategory.USER_CHANNEL_BAN:{const s=this._leftChannels.get(t.channelUrl),n=s?s.channel:yield this.getChannel(t.channelUrl,!0);this._markAsLeave(n);const{user:i}=e.as(h.BanUserEventCommand);i.userId===this._sdkState.userId&&this._dispatcher.dispatch(new x({channelUrls:[n.url],source:d.CollectionEventSource.EVENT_CHANNEL_BANNED})),d.runAsCallback((()=>d.__awaiter(this,void 0,void 0,(function*(){this._groupChannelHandlers.forEach((e=>{e.onUserBanned&&e.onUserBanned(n,i)}))}))));break}case u.ChannelEventCategory.USER_CHANNEL_UNBAN:{const s=yield this.getChannel(t.channelUrl,!0),{user:n}=e.as(h.UnbanUserEventCommand);n.userId===this._sdkState.userId&&this._dispatcher.dispatch(new x({channelUrls:[s.url],source:d.CollectionEventSource.EVENT_CHANNEL_UNBANNED})),d.runAsCallback((()=>d.__awaiter(this,void 0,void 0,(function*(){this._groupChannelHandlers.forEach((e=>{e.onUserUnbanned&&e.onUserUnbanned(s,n)}))}))));break}case u.ChannelEventCategory.CHANNEL_FREEZE:case u.ChannelEventCategory.CHANNEL_UNFREEZE:{const s=yield this.getChannel(t.channelUrl,!0),{freeze:n}=e.as(h.FreezeEventCommand);s.isFrozen=n,this._dispatcher.dispatch(new P({channels:[s],source:n?d.CollectionEventSource.EVENT_CHANNEL_FROZEN:d.CollectionEventSource.EVENT_CHANNEL_UNFROZEN})),d.runAsCallback((()=>d.__awaiter(this,void 0,void 0,(function*(){this._groupChannelHandlers.forEach((e=>{n?e.onChannelFrozen&&e.onChannelFrozen(s):e.onChannelUnfrozen&&e.onChannelUnfrozen(s)}))}))));break}case u.ChannelEventCategory.CHANNEL_HIDE:{const s=yield this.getChannel(t.channelUrl,!0),{allowAutoUnhide:n,hidePreviousMessages:i,messageOffsetTimestamp:a}=e.as(_e);null!==n&&(s.hiddenState=n?exports.HiddenState.HIDDEN_ALLOW_AUTO_UNHIDE:exports.HiddenState.HIDDEN_PREVENT_AUTO_UNHIDE),null!==i&&i&&s._updateUnreadCount(0,0),null!==a&&(s.messageOffsetTimestamp=a),this._dispatcher.dispatch(new P({channels:[s],source:d.CollectionEventSource.EVENT_CHANNEL_HIDDEN})),d.runAsCallback((()=>d.__awaiter(this,void 0,void 0,(function*(){this._groupChannelHandlers.forEach((e=>{e.onChannelHidden&&e.onChannelHidden(s)}))}))));break}case u.ChannelEventCategory.CHANNEL_UNHIDE:{const e=yield this.getChannel(t.channelUrl,!0);e.hiddenState=exports.HiddenState.UNHIDDEN,this._dispatcher.dispatch(new P({channels:[e],source:d.CollectionEventSource.EVENT_CHANNEL_UNHIDDEN})),d.runAsCallback((()=>d.__awaiter(this,void 0,void 0,(function*(){this._groupChannelHandlers.forEach((t=>{t.onChannelChanged&&t.onChannelChanged(e)}))}))));break}case u.ChannelEventCategory.CHANNEL_DELETED:{const e=yield this.getChannel(t.channelUrl,!0);this._dispatcher.dispatch(new x({channelUrls:[t.channelUrl],source:d.CollectionEventSource.EVENT_CHANNEL_DELETED})),d.runAsCallback((()=>d.__awaiter(this,void 0,void 0,(function*(){this._groupChannelHandlers.forEach((t=>{t.onChannelDeleted&&t.onChannelDeleted(e.url,e.channelType)}))}))));break}case u.ChannelEventCategory.CHANNEL_PROP_CHANGED:{const e=yield this.getChannelWithoutCache(t.channelUrl,!0);this._dispatcher.dispatch(new P({channels:[e],source:d.CollectionEventSource.EVENT_CHANNEL_UPDATED})),d.runAsCallback((()=>d.__awaiter(this,void 0,void 0,(function*(){this._groupChannelHandlers.forEach((t=>{t.onChannelChanged&&t.onChannelChanged(e)}))}))));break}case u.ChannelEventCategory.CHANNEL_META_DATA_CHANGED:{const s=yield this.getChannel(t.channelUrl,!0),{created:n,updated:i,deleted:a}=e.as(h.UpdateMetaDataEventCommand);n&&(s._upsertCachedMetaData(n,t.ts),this._dispatcher.dispatch(new P({channels:[s],source:d.CollectionEventSource.EVENT_CHANNEL_METADATA_CREATED}))),i&&(s._upsertCachedMetaData(i,t.ts),this._dispatcher.dispatch(new P({channels:[s],source:d.CollectionEventSource.EVENT_CHANNEL_METADATA_UPDATED}))),a&&(s._removeFromCachedMetaData(a,t.ts),this._dispatcher.dispatch(new P({channels:[s],source:d.CollectionEventSource.EVENT_CHANNEL_METADATA_DELETED}))),d.runAsCallback((()=>d.__awaiter(this,void 0,void 0,(function*(){this._groupChannelHandlers.forEach((e=>{n&&e.onMetaDataCreated&&e.onMetaDataCreated(s,n),i&&e.onMetaDataUpdated&&e.onMetaDataUpdated(s,i),a&&e.onMetaDataDeleted&&e.onMetaDataDeleted(s,a)}))}))));break}case u.ChannelEventCategory.CHANNEL_META_COUNTERS_CHANGED:{const s=yield this.getChannel(t.channelUrl,!0),{created:n,updated:i,deleted:a}=e.as(h.UpdateMetaCounterEventCommand);n&&this._dispatcher.dispatch(new P({channels:[s],source:d.CollectionEventSource.EVENT_CHANNEL_METACOUNTER_CREATED})),i&&this._dispatcher.dispatch(new P({channels:[s],source:d.CollectionEventSource.EVENT_CHANNEL_METACOUNTER_UPDATED})),a&&this._dispatcher.dispatch(new P({channels:[s],source:d.CollectionEventSource.EVENT_CHANNEL_METACOUNTER_DELETED})),d.runAsCallback((()=>d.__awaiter(this,void 0,void 0,(function*(){this._groupChannelHandlers.forEach((e=>{n&&e.onMetaCounterCreated&&e.onMetaCounterCreated(s,n),i&&e.onMetaCounterUpdated&&e.onMetaCounterUpdated(s,i),a&&e.onMetaCounterDeleted&&e.onMetaCounterDeleted(s,a)}))}))));break}case u.ChannelEventCategory.PINNED_MESSAGE_CHANGED:{const s=yield this.getChannel(t.channelUrl,!0),{pinnedMessageIds:n,latestPinnedMessage:i,ts:a}=e.as(fe);a>s._pinnedMessagesUpdatedAt&&(s.pinnedMessageIds=n,s.lastPinnedMessage=i,s._pinnedMessagesUpdatedAt=a,this._dispatcher.dispatch(new P({channels:[s],source:d.CollectionEventSource.EVENT_PINNED_MESSAGE_UPDATED})),d.runAsCallback((()=>d.__awaiter(this,void 0,void 0,(function*(){for(const e of this._groupChannelHandlers.values())e.onChannelChanged&&e.onChannelChanged(s)})))),d.runAsCallback((()=>d.__awaiter(this,void 0,void 0,(function*(){this._groupChannelHandlers.forEach((e=>{e.onPinnedMessageUpdated&&e.onPinnedMessageUpdated(s)}))})))));break}}break}case"USEV":{const{event:t}=e.as(c.UserEventCommand);switch(t.category){case c.UserEventCategory.USER_BLOCK:{const{blocker:e,blockee:s}=c.UserEvent.getDataAsUserBlockEvent(this._iid,t);this._groupChannelCache.block(e.userId,s.userId);break}case c.UserEventCategory.USER_UNBLOCK:{const{blocker:e,blockee:s}=c.UserEvent.getDataAsUserBlockEvent(this._iid,t);this._groupChannelCache.unblock(e.userId,s.userId);break}}break}}}catch(e){if(d.isThrowingOutside(e))throw e}}))}_markAsLeave(e){var t;const s=null!==(t=this._leftChannels.get(e.url))&&void 0!==t?t:{channel:e,ref:0};s.ref++,this._leftChannels.set(e.url,s),setTimeout((()=>{s.ref--,0===s.ref&&this._leftChannels.delete(e.url)}),1e4)}addHandler(e,t){this._groupChannelHandlers.set(e,t)}removeHandler(e){this._groupChannelHandlers.delete(e)}clearHandler(){this._groupChannelHandlers.clear()}subscribeChannelEvent(e,t){this._groupChannelBroadcast.subscribe(e,t)}unsubscribeChannelEvent(e){this._groupChannelBroadcast.unsubscribe(e)}_updateJoinedMemberCount(e){e.joinedMemberCount=e.members.filter((e=>e.state===exports.MemberState.JOINED)).length}getChannel(e,t=!1){return d.__awaiter(this,void 0,void 0,(function*(){d.unless(d.isTypeOf("string",e)).throw(d.SendbirdError.invalidParameters);try{const t=yield this.getChannelFromCache(e);if(t)return t}catch(e){}return yield this.getChannelWithoutCache(e,t)}))}getChannelWithoutCache(e,t=!1){return d.__awaiter(this,void 0,void 0,(function*(){d.unless(d.isTypeOf("string",e)).throw(d.SendbirdError.invalidParameters);const s=new L({channelUrl:e,isInternalCall:t}),n=yield this._requestQueue.send(s),{channel:i}=n.as(F);let{unreadMessageCount:a,unreadMentionCount:r}=i;switch(i.myCountPreference){case exports.CountPreference.UNREAD_MESSAGE_COUNT_ONLY:r=0;break;case exports.CountPreference.UNREAD_MENTION_COUNT_ONLY:a=0;break;case exports.CountPreference.OFF:a=0,r=0}return i._updateUnreadCount(a,r),(yield this.upsertChannelsToCache([i]))[0]}))}refreshChannel(e,t=!0,s=d.CollectionEventSource.REFRESH_CHANNEL){return d.__awaiter(this,void 0,void 0,(function*(){try{const n=new L({channelUrl:e,isInternalCall:t}),i=yield this._requestQueue.send(n),{channel:a}=i.as(F);if(a.myMemberState===exports.MemberState.NONE)this._dispatcher.dispatch(new x({channelUrls:[a.url],source:s}));else{const e=yield this.upsertChannelsToCache([a]);this._dispatcher.dispatch(new P({channels:e,source:s}))}}catch(t){t.code!==d.SendbirdErrorCode.NON_AUTHORIZED&&t.code!==d.SendbirdErrorCode.NOT_FOUND_IN_DATABASE||this._dispatcher.dispatch(new x({channelUrls:[e],source:s}))}}))}getMyGroupChannels(e,t,s,n=d.CollectionEventSource.REQUEST_CHANNEL){return d.__awaiter(this,void 0,void 0,(function*(){t.createdAfter&&(t.createdAfter=Math.floor(t.createdAfter/1e3)),t.createdBefore&&(t.createdBefore=Math.floor(t.createdBefore/1e3));const i=new k(Object.assign(Object.assign({},t),{userId:this._sdkState.userId,token:e,limit:s})),a=yield this._requestQueue.send(i),{channels:r,token:o}=a.as(H);return this._dispatcher.dispatch(new P({channels:r,source:n})),{channels:r,token:o}}))}getMyGroupChannelChangeLogs(e,t,s=d.CollectionEventSource.REQUEST_CHANNEL_CHANGELOGS){return d.__awaiter(this,void 0,void 0,(function*(){const n=Object.assign(Object.assign({},v),t);d.unless((d.isTypeOf("string",e)||d.isTypeOf("number",e))&&f(n)).throw(d.SendbirdError.invalidParameters);const i=new w(d.undefineNullProps({userId:this._sdkState.userId,ts:"number"==typeof e?e:null,token:"string"==typeof e?e:null,filter:n})),a=(yield this._requestQueue.send(i)).as(R),{updatedChannels:r,deletedChannelUrls:o,hasMore:l,ts:h}=a;return r.length>0&&this._dispatcher.dispatch(new P({channels:r,source:s,ts:h})),o.length>0&&this._dispatcher.dispatch(new x({channelUrls:o,source:s})),{updatedChannels:r,deletedChannelUrls:o,hasMore:l,token:a.token}}))}getGroupChannelCount(e){return d.__awaiter(this,void 0,void 0,(function*(){const t=Object.assign(Object.assign({},M),e);d.unless(S(t)).throw(d.SendbirdError.invalidParameters);const s=new V({userId:this._sdkState.userId,filter:t}),n=yield this._requestQueue.send(s),{groupChannelCount:i}=n.as(G);return i}))}getUnreadItemCount(e){return d.__awaiter(this,void 0,void 0,(function*(){const t=Object.assign(Object.assign({},A),e);d.unless((e=>d.isArrayOf(exports.UnreadItemKey,e.keys))(t)).throw(d.SendbirdError.invalidParameters);const{sdkState:s,requestQueue:n}=d.Vault.of(this._iid),i=new q({userId:s.userId,filter:t}),a=yield n.send(i),{groupChannelUnreadMentionCount:r,groupChannelUnreadMessageCount:o,groupChannelInvitationCount:l,superGroupChannelUnreadMentionCount:h,superGroupChannelUnreadMessageCount:c,superGroupChannelInvitationCount:u,nonSuperGroupChannelUnreadMentionCount:_,nonSuperGroupChannelUnreadMessageCount:p,nonSuperGroupChannelInvitationCount:m}=a.as(B);return d.deundefined({groupChannelUnreadMentionCount:r,groupChannelUnreadMessageCount:o,groupChannelInvitationCount:l,superGroupChannelUnreadMentionCount:h,superGroupChannelUnreadMessageCount:c,superGroupChannelInvitationCount:u,nonSuperGroupChannelUnreadMentionCount:_,nonSuperGroupChannelUnreadMessageCount:p,nonSuperGroupChannelInvitationCount:m})}))}getTotalUnreadChannelCount(){return d.__awaiter(this,void 0,void 0,(function*(){const{sdkState:e,requestQueue:t}=d.Vault.of(this._iid),s=new j({userId:e.userId}),n=yield t.send(s),{unreadCount:i}=n.as(z);return i}))}getTotalUnreadMessageCount(e){return d.__awaiter(this,void 0,void 0,(function*(){const t=Object.assign(Object.assign({},b),e);d.unless(N(t)).throw(d.SendbirdError.invalidParameters);const{sdkState:s,requestQueue:n}=d.Vault.of(this._iid),i=new W({userId:s.userId,filter:t}),a=yield n.send(i),{unreadCount:r}=a.as($);return r}))}getTotalScheduledMessageCount(e={}){return d.__awaiter(this,void 0,void 0,(function*(){const t=Object.assign(Object.assign({},T),e);d.unless((e=>d.isTypeOf("string",e.channelUrl,!0)&&d.isArrayOf(h.ScheduledStatus,e.scheduledStatus,!0)&&d.isEnumOf(d.MessageTypeFilter,e.messageTypeFilter))(t)).throw(d.SendbirdError.invalidParameters);const{requestQueue:s}=d.Vault.of(this._iid),n=new Q(t),i=yield s.send(n),{count:a}=i.as(K);return a}))}getSubscribedTotalUnreadMessageCount(){const{subscribedUnreadMessageCount:e}=d.Vault.of(this._iid);return e.all>=0?e.all:0}getSubscribedCustomTypeTotalUnreadMessageCount(){let e=0;const{subscribedUnreadMessageCount:t}=d.Vault.of(this._iid);for(const s in t.customTypes)e+=t.customTypes[s];return e}getSubscribedCustomTypeUnreadMessageCount(e){var t;const{subscribedUnreadMessageCount:s}=d.Vault.of(this._iid);return null!==(t=s.customTypes[e])&&void 0!==t?t:0}createChannel(e){return d.__awaiter(this,void 0,void 0,(function*(){const t=Object.assign(Object.assign({},C),e);d.unless(E(t)).throw(d.SendbirdError.invalidParameters),t.isPublic||(t.accessCode=void 0);const s=new J(Object.assign({userId:this._sdkState.userId},t)),n=yield this._requestQueue.send(s),{channel:i}=n.as(X);return yield this.upsertChannelsToCache([i]),i}))}markAsReadAll(){return d.__awaiter(this,void 0,void 0,(function*(){const e=Date.now();d.unless(e-this._markAsReadAllLastSentAt>=1e3).throw(d.SendbirdError.markAsReadAllRateLimitExceeded),this._markAsReadAllLastSentAt=e;const t=new Z({userId:this._sdkState.userId});yield this._requestQueue.send(t);const s=this._groupChannelCache.channels;for(const t of s)t._updateUnreadMemberState(this._sdkState.userId,e),t._updateUnreadCount(0,0);s.length>0&&(yield this.upsertChannelsToCache(s))}))}markAsReadWithChannelUrls(e){return d.__awaiter(this,void 0,void 0,(function*(){const t=Date.now();d.unless(d.isArrayOf("string",e)&&t-this._markAsReadAllLastSentAt>=1e3).throw(d.SendbirdError.markAsReadAllRateLimitExceeded),this._markAsReadAllLastSentAt=t;const s=new Z({userId:this._sdkState.userId,channelUrls:e});yield this._requestQueue.send(s);const n=this._groupChannelCache.channels,i=[];for(const s of n)e.includes(s.url)&&(s._updateUnreadMemberState(this._sdkState.userId,t),s._updateUnreadCount(0,0),i.push(s));i.length>0&&(yield this.upsertChannelsToCache(i))}))}markAsDelivered(e){return d.__awaiter(this,void 0,void 0,(function*(){const t=yield this.getChannel(e);yield t.markAsDelivered()}))}getMessageFromCache(e){var t;return d.__awaiter(this,void 0,void 0,(function*(){return null!==(t=yield this._messageCache.get(e))&&void 0!==t?t:null}))}getExactlyMatchingMessagesForTokenFromCache(e,t,s){return d.__awaiter(this,void 0,void 0,(function*(){return yield this._messageCache.fetch({channelUrl:e,token:t,filter:s,exactMatch:!0})}))}getMessagesFromCache(e,t,s,n,i=h.DEFAULT_MESSAGE_LIMIT,a=!0){return d.__awaiter(this,void 0,void 0,(function*(){return yield this._messageCache.fetch({channelUrl:e,token:t,limit:i,filter:n,backward:"next"===s,inclusive:a})}))}getPollMessagesFromCache(e,t,s,n){return d.__awaiter(this,void 0,void 0,(function*(){return yield this._messageCache.fetch({channelUrl:e,token:t,limit:n,filter:s,backward:!1,isPollOnly:!0})}))}getCachedMessageCountBetween(e,t,s,n){return d.__awaiter(this,void 0,void 0,(function*(){return yield this._messageCache.countBetween(e,t,new Te({top:s,bottom:n}))}))}getUnsentMessagesFromCache(e,t){return d.__awaiter(this,void 0,void 0,(function*(){return yield this._unsentMessageCache.fetch({channelUrl:e,filter:t})}))}removeFailedMessageFromCache(e){return d.__awaiter(this,void 0,void 0,(function*(){yield this._unsentMessageCache.remove([e])}))}}const Pe=(e,t)=>t instanceof h.SendableMessage?e.findIndex((e=>e instanceof h.SendableMessage&&t.isIdentical(e))):e.findIndex((e=>e.isIdentical(t))),xe=(e,t)=>e.findIndex((e=>e instanceof h.BaseMessage?e.messageId===t:e instanceof h.NotificationMessage?e.notificationId===t:void 0)),Oe=(e,t)=>{if(e.length>0){let s=0,n=e.length-1,i=Math.floor((s+n)/2);for(;s0)n=i,i=Math.floor((s+n)/2);else{if(!(a<0))return i;s=i+1,i=Math.floor((s+n)/2)}}return e[i].createdAt>t.createdAt?i:i+1}return e.length};var we;!function(e){e[e.IDLE=0]="IDLE",e[e.RUNNING=1]="RUNNING",e[e.END=2]="END"}(we||(we={}));class Re extends d.EventDispatcher{constructor(e,t,s=2,n=10){super(),this._state=we.IDLE,this._retryCount=0,this._retryLimit=3,this.priority=0,this._worker=t}get isIdle(){return this._state===we.IDLE}get isRunning(){return this._state===we.RUNNING}get isDone(){return this._state===we.END}get retryCount(){return this._retryCount}get retryLimit(){return this._retryLimit}_run(e){return d.__awaiter(this,void 0,void 0,(function*(){if(this.isRunning)try{const t=yield this._worker(e);this._retryCount=0,this.dispatch("progress",t),t.hasNext?this._run(t.nextToken):this.end()}catch(t){this.dispatch("error",t),this._retryCount`sendbird:${e}@groupchannel/${t}/message/sync`)(n.userId,t.url);this._prevSync=new Re(u,(e=>d.__awaiter(this,void 0,void 0,(function*(){var s,n,a,l,c,u,_;const p={hasNext:!0,nextToken:0};if(this._prevSyncLoopCount++,yield this.loadMetadata(e),r.debug("message background prev sync from",null===(s=this._metadata)||void 0===s?void 0:s.range.top),null===(n=this._metadata)||void 0===n?void 0:n.previousComplete)p.hasNext=!1;else try{const t=h.MessageManager.of(this._iid),s=yield t.getMessagesByTimestamp(this._channel.url,this._channel.channelType,(null===(l=null===(a=this._metadata)||void 0===a?void 0:a.range)||void 0===l?void 0:l.top)?this._metadata.range.top:e,{prevResultSize:this._limit,nextResultSize:0,replyType:d.ReplyType.ALL,includeReactions:!0,includeMetaArray:!0,includeParentMessageInfo:!0,includeThreadInfo:!0},d.CollectionEventSource.SYNC_MESSAGE_BACKGROUND);if(s.length>0){const e=s.map((e=>e.createdAt));(null===(c=this._metadata)||void 0===c?void 0:c.range.intersect(...e))?this.extendRange(s):this._metadata={range:new Te({top:Math.min(...e),bottom:Math.max(...e)}),previousComplete:!1}}p.hasNext=s.length>=this._limit&&this._prevSyncLoopCount<1,this._metadata&&(p.nextToken=this._metadata.range.top,this._metadata.previousComplete=s.lengthd.__awaiter(this,void 0,void 0,(function*(){var s,n,a,l,c,u;const _={hasNext:!0,nextToken:0};this._nextSyncLoopCount++,yield this.loadMetadata(e),r.debug("message background next sync from",null===(s=this._metadata)||void 0===s?void 0:s.range.bottom);try{const t=h.MessageManager.of(this._iid),s=yield t.getMessagesByTimestamp(this._channel.url,this._channel.channelType,(null===(a=null===(n=this._metadata)||void 0===n?void 0:n.range)||void 0===a?void 0:a.bottom)?this._metadata.range.bottom:e,{prevResultSize:0,nextResultSize:this._limit,replyType:d.ReplyType.ALL,includeReactions:!0,includeMetaArray:!0,includeParentMessageInfo:!0,includeThreadInfo:!0},d.CollectionEventSource.SYNC_MESSAGE_BACKGROUND);if(s.length>0){const e=s.map((e=>e.createdAt));(null===(l=this._metadata)||void 0===l?void 0:l.range.intersect(...e))?this.extendRange(s):this._metadata={range:new Te({top:Math.min(...e),bottom:Math.max(...e)}),previousComplete:!1}}_.hasNext=s.length>=this._limit&&this._nextSyncLoopCount<1,this._metadata&&(_.nextToken=this._metadata.range.bottom),r.debug("message background next sync progress",_),yield this.saveMetadata()}catch(e){throw r.debug("message background next sync error",e),e}finally{o.put(new d.StatLog({type:d.StatType.FEATURE_LOCALCACHE_EVENT,ts:Date.now(),data:{channel_url:t.url,measured_on:"back_sync",event:"cache_fetch",max_db_size:null!==(u=null===(c=i.localCacheConfig)||void 0===c?void 0:c.maxSize)&&void 0!==u?u:0,use_local_cache:i.localCacheEnabled,starting_point:0,message_init_policy:""}}))}return _})))),this._connectionEventContext=a.on((e=>{if(e instanceof d.ConnectionStateChangeCommand)if(e.stateType===d.ConnectionStateType.CONNECTED)this.resume();else this.pause()}))}static of(e,t){return Le[e]||(Le[e]={}),Le[e][t.url]||(Le[e][t.url]=new Fe({_iid:e,channel:t})),Le[e][t.url].ref++,Le[e][t.url]}static clear(e,t){Le[e]&&Le[e][t]&&(Le[e][t].close(),delete Le[e])}get range(){var e,t;return null!==(t=null===(e=this._metadata)||void 0===e?void 0:e.range)&&void 0!==t?t:new Te({})}get previousComplete(){var e;return!!(null===(e=this._metadata)||void 0===e?void 0:e.previousComplete)}isWrappingMessages(e){var t;return null===(t=this.range)||void 0===t?void 0:t.includes(...e.map((e=>e.createdAt)))}extendRange(e){this._metadata&&this._metadata.range.extends(...e.map((e=>e.createdAt)))}loadMetadata(e){return d.__awaiter(this,void 0,void 0,(function*(){if(!this._metadata){const{cacheContext:t}=d.Vault.of(this._iid),s=yield t.preference.get(this._metadataKey);s?s.range.bottom`sendbird:${e}@groupchannel/${t}/message/changelogs`)(n.userId,this._channel.url);this._sync=new Re(o,(()=>d.__awaiter(this,void 0,void 0,(function*(){var e;const t={hasNext:!0,nextToken:0};yield this.loadMetadata(),s.debug("message changelog sync from",null===(e=this._metadata)||void 0===e?void 0:e.token);try{const e=h.MessageManager.of(this._iid),{updatedMessages:n,deletedMessageIds:i,hasMore:a,token:r}=yield e.getMessageChangelogs(this._channel.url,this._channel.channelType,this._metadata.token,{replyType:d.ReplyType.ALL,includeReactions:!0,includeThreadInfo:!0,includeMetaArray:!0,includeParentMessageInfo:!0},d.CollectionEventSource.SYNC_MESSAGE_CHANGELOGS);t.hasNext=a,t.nextToken=r,(n.length>0||i.length>0)&&this._metadata&&(this._metadata.token=r),s.debug("message changelog sync progress",t),yield this.saveMetadata()}catch(e){throw s.debug("message changelog sync error",e),e instanceof d.SendbirdError&&e.isInvalidTokenError&&(yield this.clearMetadata()),e}return t})))),this._connectionEventContext=i.on((e=>{if(e instanceof d.ConnectionStateChangeCommand)if(e.stateType===d.ConnectionStateType.CONNECTED)this.resume();else this.pause()}))}static of(e,t){return De[e]||(De[e]={}),De[e][t.url]||(De[e][t.url]=new ke({_iid:e,channel:t})),De[e][t.url].ref++,De[e][t.url]}static clear(e,t){De[e]&&De[e][t]&&(De[e][t].close(),delete De[e])}loadMetadata(){return d.__awaiter(this,void 0,void 0,(function*(){if(!this._metadata){const{cacheContext:e,firstConnectedAt:t}=d.Vault.of(this._iid),s=yield e.preference.get(this._metadataKey);this._metadata={token:s?s.token:t}}return this._metadata}))}saveMetadata(){return d.__awaiter(this,void 0,void 0,(function*(){if(this._metadata){const{cacheContext:e}=d.Vault.of(this._iid);return yield e.preference.set(this._metadataKey,this._metadata),!0}return!1}))}clearMetadata(){return d.__awaiter(this,void 0,void 0,(function*(){const{cacheContext:e}=d.Vault.of(this._iid);yield e.preference.remove(this._metadataKey),this._metadata=void 0}))}resume(){const{logger:e,sessionManager:t}=d.Vault.of(this._iid);t.session.hasSession&&(e.debug("message changelog sync resume()"),this._sync.start(0))}pause(){const{logger:e,connectionManager:t}=d.Vault.of(this._iid);e.debug("message changelog sync pause()"),this._sync.stop()}close(){this.ref--,this.ref<=0&&(this.ref=0,this.pause(),this._connectionEventContext.close(),delete De[this._iid][this._channel.url])}}const He={};class Ve{constructor({_iid:e,channel:t,hasPollMessage:s}){this.ref=0,this._iid=e,this._channel=t;const{logger:n,sdkState:i,dispatcher:a}=d.Vault.of(this._iid);var r,o;this._metadataKey=(r=i.userId,o=t.url,`sendbird:${r}@groupchannel/${o}/poll/changelogs.meta`);const l=((e,t)=>`sendbird:${e}@groupchannel/${t}/poll/changelogs`)(i.userId,this._channel.url);this._sync=new Re(l,(()=>d.__awaiter(this,void 0,void 0,(function*(){var e;const t={hasNext:!0,nextToken:0};if(yield this.loadMetadata(),n.debug("poll changelog sync from",null===(e=this._metadata)||void 0===e?void 0:e.token),!(this._metadata&&this._metadata.token||(yield s()))){return{hasNext:!1,nextToken:0}}if(!this._metadata){const{firstConnectedAt:e}=d.Vault.of(this._iid);this._metadata={token:e}}try{const e=d.PollManager.of(this._iid),{hasMore:s,token:i}=yield e.getPollChangeLogs(this._channel.url,this._channel.channelType,this._metadata.token);t.hasNext=s,t.nextToken=i,this._metadata.token=i,n.debug("poll changelog sync progress",t),yield this.saveMetadata()}catch(e){throw n.debug("poll changelog sync error",e),e instanceof d.SendbirdError&&e.isInvalidTokenError&&(yield this.clearMetadata()),e}return t})))),this._connectionEventContext=a.on((e=>{if(e instanceof d.ConnectionStateChangeCommand)if(e.stateType===d.ConnectionStateType.CONNECTED)this.resume();else this.pause()}))}static of(e,t,s){return He[e]||(He[e]={}),He[e][t.url]||(He[e][t.url]=new Ve({_iid:e,channel:t,hasPollMessage:s})),He[e][t.url].ref++,He[e][t.url]}loadMetadata(){return d.__awaiter(this,void 0,void 0,(function*(){if(!this._metadata){const{cacheContext:e}=d.Vault.of(this._iid),t=yield e.preference.get(this._metadataKey);this._metadata=t?{token:t.token}:void 0}}))}saveMetadata(){return d.__awaiter(this,void 0,void 0,(function*(){if(this._metadata){const{cacheContext:e}=d.Vault.of(this._iid);yield e.preference.set(this._metadataKey,this._metadata)}}))}clearMetadata(){return d.__awaiter(this,void 0,void 0,(function*(){const{cacheContext:e}=d.Vault.of(this._iid);yield e.preference.remove(this._metadataKey),this._metadata=void 0}))}resume(){const{logger:e}=d.Vault.of(this._iid);e.debug("poll changelog sync resume()"),this._sync.start(0)}pause(){const{logger:e}=d.Vault.of(this._iid);e.debug("poll changelog sync pause()"),this._sync.stop()}close(){this.ref--,this.ref<=0&&(this.ref=0,this.pause(),this._connectionEventContext.close(),delete He[this._iid][this._channel.url])}}class Ge extends d.BaseCommand{constructor({channels:e,source:t,isWebSocketEventComing:s=!1,data:n=null}){super(),this.channels=e,this.source=t,this.isWebSocketEventComing=s,this.data=n}}class qe extends d.BaseCommand{constructor({channelUrls:e,source:t,isWebSocketEventComing:s=!1}){super(),this.channelUrls=e,this.source=t,this.isWebSocketEventComing=s}}class Be extends d.APIRequestCommand{constructor(e){var t,s,n,i,a,r,o,l,h,c;super(),this.method=d.APIRequestMethod.GET,this.path=`${d.getChannelApiPathByType(e.channelType)}/${e.channelUrl}/messages_gap`,this.params=d.deundefined({prev_start_ts:e.prevStart,prev_end_ts:e.prevEnd,prev_cache_count:e.prevCount,next_start_ts:e.nextStart,next_end_ts:e.nextEnd,next_cache_count:e.nextCount,huge_gap_threshold:null!==(t=e.threshold)&&void 0!==t?t:null,reverse:!0,custom_types:null!==(s=e.customTypes)&&void 0!==s?s:["*"],message_type:null!==(n=e.messageType)&&void 0!==n?n:null,include_reply_type:null!==(i=e.replyType)&&void 0!==i?i:d.ReplyType.NONE,include_reactions:null===(a=e.includeReactions)||void 0===a||a,include_meta_array:null===(r=e.includeMetaArray)||void 0===r||r,include_thread_info:null===(o=e.includeThreadInfo)||void 0===o||o,include_parent_message_info:null===(l=e.includeParentMessageInfo)||void 0===l||l,with_sorted_meta_array:null===(h=e.includeMetaArray)||void 0===h||h,show_subchannel_messages_only:null!==(c=e.showSubchannelMessagesOnly)&&void 0!==c&&c,include_poll_details:!0,checking_continuous_messages:e.checkingContinuousMessages})}}class je extends d.APIResponseCommand{constructor(e,t){var s,n,i,a,r,o;super(e,t),this.isHugeGap=t.is_huge_gap,this.prevMessages=(null!==(s=t.prev_messages)&&void 0!==s?s:[]).map((t=>h.parseMessagePayload(e,t))),this.prevHasMore=null!==(n=t.prev_hasmore)&&void 0!==n&&n,this.isContinuousPrevMessages=null!==(i=t.is_continuous_prev_messages)&&void 0!==i&&i,this.nextMessages=(null!==(a=t.next_messages)&&void 0!==a?a:[]).map((t=>h.parseMessagePayload(e,t))),this.nextHasmore=null!==(r=t.next_hasmore)&&void 0!==r&&r,this.isContinuousNextMessages=null!==(o=t.is_continuous_next_messages)&&void 0!==o&&o}}class ze{constructor(e){this.source=e}}class We extends ze{}class $e extends ze{}class Qe{constructor(e){this.source=e}}class Ke extends Qe{}class Ye extends Qe{}const Je=6e5,Xe={includeMetaArray:!0,includeReactions:!0,includeThreadInfo:!0,includeParentMessageInfo:!0};exports.MessageCollectionInitPolicy=void 0,(exports.MessageCollectionInitPolicy||(exports.MessageCollectionInitPolicy={})).CACHE_AND_REPLACE_BY_API="cache_and_replace_by_api";class Ze{constructor(){this._onCacheResult=d.noop,this._onApiResult=d.noop}_invokeResponse(e,t,s){d.runAsCallback((()=>d.__awaiter(this,void 0,void 0,(function*(){switch(e){case"local":this._onCacheResult(t,s);break;case"remote":this._onApiResult(t,s)}}))))}onCacheResult(e){return this._onCacheResult=e,this}onApiResult(e){return this._onApiResult=e,this}}class et{keyOf(e){return 0}constructor(e,{filter:t,startingPoint:s,limit:n,channel:i,channelManager:a,disableBackgroundSync:r=!1}){this._messages=[],this._unsentMessages=[],this._iid=e,this._key=`mc-${d.uuid()}`,this._isDisposed=!1,this.filter=null!=t?t:new h.MessageFilter,this._channel=i,this._syncRange=new Te({}),this._hasPrevious=!0,this._hasNext=!0,this._startingPoint="number"==typeof s?s:Date.now()+Je,this._limit=n||h.DEFAULT_MESSAGE_LIMIT,this._channelManager=a,this._channelManager.subscribeChannelEvent(this._key,{onUpdate:(e,t,s)=>{const n=e.findIndex((e=>e.isIdentical(this.channel)));n>=0&&(this._replaceChannelOfCollection(e[n]),this.channel._runIfHandleableWithGroupChannel((e=>{switch(t){case d.CollectionEventSource.EVENT_CHANNEL_UPDATED:{let t=!1;for(const s in this._messages){if(this._messages[s].createdAt>=e.messageOffsetTimestamp){t=!0;const e=parseInt(s);if(e>0){const t=this._messages.splice(0,e);this._removeMessagesFromView(t.map((e=>this.keyOf(e))),d.CollectionEventSource.EVENT_MESSAGE_OFFSET_UPDATED)}break}}!t&&this._messages.length>0&&this._removeMessagesFromView(this._messages.map((e=>this.keyOf(e))),d.CollectionEventSource.EVENT_MESSAGE_OFFSET_UPDATED);break}case d.CollectionEventSource.EVENT_CHANNEL_UNMUTED:{const{sdkState:e}=d.Vault.of(this._iid),t=s;e.userId===t&&this._clearCheckMyMutedTimer();break}case d.CollectionEventSource.EVENT_CHANNEL_MUTED:{const{sdkState:t}=d.Vault.of(this._iid),n=s;t.userId===n&&-1!==e._myMutedRemainingTime&&this._startCheckMyMutedTimer(e._myMutedRemainingTime);break}case d.CollectionEventSource.EVENT_CHANNEL_LEFT:e.isPublic&&this._clearCheckMyMutedTimer()}d.runAsCallback((()=>d.__awaiter(this,void 0,void 0,(function*(){var e;const s=this._createChannelEventContext(t);I(t)&&(null===(e=this._handler)||void 0===e?void 0:e.onChannelUpdated)&&this._handler.onChannelUpdated(s,this.channel)}))))})))},onRemove:(e,t)=>{e.indexOf(this.channel.url)>=0&&(this._clearCheckMyMutedTimer(),d.runAsCallback((()=>d.__awaiter(this,void 0,void 0,(function*(){var e;const s=this._createChannelEventContext(t);(null===(e=this._handler)||void 0===e?void 0:e.onChannelDeleted)&&this._handler.onChannelDeleted(s,this.channel.url)})))))}}),this._channelManager.subscribeMessageEvent(this._key,{onUpdate:(e,t)=>{const s=[],n=[];for(const t of e)t.channelUrl===this._channel.url&&(this.filter.match(t)?s.push(t):n.push(this.keyOf(t)));if(d.shouldGiveEvent(t)){if(s.length>0)switch(t){case d.CollectionEventSource.LOCAL_MESSAGE_CANCELED:case d.CollectionEventSource.LOCAL_MESSAGE_RESEND_STARTED:case d.CollectionEventSource.EVENT_MESSAGE_SENT_FAILED:case d.CollectionEventSource.EVENT_MESSAGE_SENT_SUCCESS:case d.CollectionEventSource.EVENT_MESSAGE_UPDATED:case d.CollectionEventSource.EVENT_MESSAGE_THREADINFO_UPDATED:case d.CollectionEventSource.EVENT_MESSAGE_REACTION_UPDATED:case d.CollectionEventSource.SYNC_MESSAGE_CHANGELOGS:this._updateMessagesToView(s,t);break;case d.CollectionEventSource.EVENT_MESSAGE_SENT_PENDING:this._addMessagesToView(s,t);break;case d.CollectionEventSource.EVENT_MESSAGE_RECEIVED:this.hasNext||this._addMessagesToView(s,t);break;case d.CollectionEventSource.SYNC_MESSAGE_FILL:this._addMessagesToView(s,t)}n.length>0&&this._removeMessagesFromView(n,t)}},onRemove:(e,t)=>{this._removeMessagesFromView(e,t)},onRemoveUnsent:(e,t)=>{this._removeUnsentMessageFromView(e,t)},onPollChangeLogUpdate:(e,t)=>{this._updatePollsToView(e,t)},onPollUpdate:(e,t)=>{this._applyPollUpdateEventToView(e,t)},onPollVote:(e,t)=>{this._applyPollVoteEventToView(e,t)}});const{cacheContext:o,dispatcher:l}=d.Vault.of(this._iid);this._channel._updateMessageCollectionLastAccessedAt();const c=this._createChannelUpdateEventCommand(d.CollectionEventSource.CHANNEL_LASTACCESSEDAT_UPDATED);c&&l.dispatch(c),!r&&this._shouldStartBackgroundSync()&&(this._backgroundSync=Fe.of(this._iid,this._channel),this._backgroundSync.resume(this._startingPoint)),this._changelogSync=ke.of(this._iid,this._channel),this._changelogSync.resume(),this._pollChangelogSync=Ve.of(this._iid,this._channel,this._hasPollMessage.bind(this)),this._pollChangelogSync.resume(),this._prevFill=new Re(this._key,(e=>d.__awaiter(this,void 0,void 0,(function*(){var t,s,n;const{messages:i,isContinuousMessages:a}=yield this._getRemoteMessages(e,{prevLimit:this._limit,source:d.CollectionEventSource.SYNC_MESSAGE_FILL,checkingContinuousMessages:o.localCacheEnabled});if(i.length>0){const e=Math.min(...i.map((e=>e.createdAt)));return this._syncRange.extends(e),a&&(null===(t=this._backgroundSync)||void 0===t||t.range.extends(e)),{hasNext:i.length>=this._limit&&this.viewTopd.__awaiter(this,void 0,void 0,(function*(){var t,s,n;const{messages:i,isContinuousMessages:a}=yield this._getRemoteMessages(e,{nextLimit:this._limit,source:d.CollectionEventSource.SYNC_MESSAGE_FILL,checkingContinuousMessages:o.localCacheEnabled});if(i.length>0){const e=Math.max(...i.map((e=>e.createdAt)));return this._syncRange.extends(e),a&&(null===(t=this._backgroundSync)||void 0===t||t.range.extends(e)),{hasNext:!(i.length>=this._limit&&this._hasNext)||this.viewBottom>e,nextToken:this._syncRange.bottom}}return u.put(new d.StatLog({type:d.StatType.FEATURE_LOCALCACHE_EVENT,ts:Date.now(),data:{channel_url:this.channel.url,measured_on:"gap_check",event:"cache_fetch",max_db_size:null!==(n=null===(s=o.localCacheConfig)||void 0===s?void 0:s.maxSize)&&void 0!==n?n:0,use_local_cache:o.localCacheEnabled,starting_point:0,message_init_policy:""}})),{hasNext:!1,nextToken:0}})))),this._connectionEventContext=l.on((e=>{if(e instanceof d.ConnectionStateChangeCommand)switch(e.stateType){case d.ConnectionStateType.CONNECTED:d.runOrNothing((()=>d.__awaiter(this,void 0,void 0,(function*(){this._activate()}))));break;case d.ConnectionStateType.LOGOUT:this.dispose();break;default:this._clearCheckMyMutedTimer(),this._prevFill.stop(),this._nextFill.stop()}}));const{statLogCollector:u}=d.Vault.of(this._iid);u.put(new d.DailyRecordStatLog({type:d.StatType.FEATURE_LOCALCACHE,data:{use_local_cache:o.localCacheEnabled,collection_interface:{message:!0}}}))}get channel(){return this._channel}get succeededMessages(){return[...this._messages]}get failedMessages(){return this._unsentMessages.filter((e=>e.sendingStatus===d.SendingStatus.FAILED))}get pendingMessages(){return this._unsentMessages.filter((e=>e.sendingStatus===d.SendingStatus.PENDING))}get hasPrevious(){return this._hasPrevious}get hasNext(){return this._hasNext}get viewTop(){return Math.min(...this._messages.map((e=>e.createdAt)),Number.MAX_SAFE_INTEGER)}get viewBottom(){return Math.max(...this._messages.map((e=>e.createdAt)),0)}_activate(){return d.__awaiter(this,void 0,void 0,(function*(){const{logger:e}=d.Vault.of(this._iid);e.debug("check huge gap"),this._checkHugeGap(),yield this._refreshChannel(d.CollectionEventSource.SYNC_CHANNEL_CHANGELOGS)}))}_replaceChannelOfCollection(e){this._channel.isGroupChannel()?this._channel=e:this._channel.isFeedChannel()&&(this._channel._groupChannel=e._groupChannel)}_shouldStartBackgroundSync(){const{cacheContext:e}=d.Vault.of(this._iid);return this.channel.isGroupChannel()?e.localCacheEnabled&&!this.channel.isSuper:e.localCacheEnabled}_createChannelEventContext(e){switch(!0){case this.channel.isGroupChannel():return new We(e);case this.channel.isFeedChannel():return new $e(e);default:throw new d.SendbirdError({code:d.SendbirdErrorCode.WRONG_CHANNEL_TYPE,message:"Wrong channel type"})}}_createMessageEventContext(e){switch(!0){case this.channel.isGroupChannel():return new Ke(e);case this.channel.isFeedChannel():return new Ye(e);default:throw new d.SendbirdError({code:d.SendbirdErrorCode.WRONG_CHANNEL_TYPE,message:"Wrong channel type"})}}_createChannelUpdateEventCommand(e){switch(!0){case this.channel.isGroupChannel():return new P({channels:[this._channel],source:e});case this.channel.isFeedChannel():return new Ge({channels:[this._channel],source:e});default:return null}}_setBaseMessageCollectionHandler(e){this._handler=e}_filterUnderOffsetMessage(e){return e}_updateChildMessagesInView(e){const t=[];return this._messages.forEach((s=>{s instanceof h.BaseMessage&&s.parentMessageId===e.messageId&&s.applyParentMessage(e)&&t.push(s)})),t}_updatePollsToView(e,t){const s=[];for(const t of e){const e=xe(this._messages,t.messageId);if(e>=0){const n=this._messages[e];n.isUserMessage()&&n.applyPoll(t),s.push(n)}}return s.length>0&&d.shouldGiveEvent(t)&&d.runAsCallback((()=>d.__awaiter(this,void 0,void 0,(function*(){var e,n;const i=this._createMessageEventContext(t);s.length>0&&(null===(n=(e=this._handler).onMessagesUpdated)||void 0===n||n.call(e,i,this.channel,s))})))),s}_applyPollUpdateEventToView(e,t){const s=xe(this._messages,e.messageId);if(s>=0){const n=this._messages[s];n&&n.isUserMessage()&&n.poll&&n.poll.applyPollUpdateEvent(e)&&d.shouldGiveEvent(t)&&d.runAsCallback((()=>d.__awaiter(this,void 0,void 0,(function*(){var e,s;const i=this._createMessageEventContext(t);null===(s=null===(e=this._handler)||void 0===e?void 0:e.onMessagesUpdated)||void 0===s||s.call(e,i,this.channel,[n])}))))}}_applyPollVoteEventToView(e,t){const s=xe(this._messages,e.messageId);if(s>=0){const n=this._messages[s];n&&n.isUserMessage()&&n.poll&&n.poll.applyPollVoteEvent(e)&&d.shouldGiveEvent(t)&&d.runAsCallback((()=>d.__awaiter(this,void 0,void 0,(function*(){var e,s;const i=this._createMessageEventContext(t);null===(s=null===(e=this._handler)||void 0===e?void 0:e.onMessagesUpdated)||void 0===s||s.call(e,i,this.channel,[n])}))))}}_removeMessagesFromView(e,t){const s=[],n=[];for(const t of e){const e=this._messages.findIndex((e=>this.keyOf(e)===t));if(e>=0){const t=this._messages[e];s.push(this.keyOf(t)),n.push(t),this._messages.splice(e,1)}}return d.shouldGiveEvent(t)&&n.length>0&&d.runAsCallback((()=>d.__awaiter(this,void 0,void 0,(function*(){var e,i;const a=this._createMessageEventContext(t);null===(i=null===(e=this._handler)||void 0===e?void 0:e.onMessagesDeleted)||void 0===i||i.call(e,a,this.channel,s,n)})))),s}_removeUnsentMessageFromView(e,t){const s=this._unsentMessages.findIndex((t=>t.reqId===e));s>=0&&this._unsentMessages.splice(s,1)}_getLocalMessages(e,{prevLimit:t=0,nextLimit:s=0,inclusive:n=!0}){return d.__awaiter(this,void 0,void 0,(function*(){let i=[];n&&(i=yield this._channelManager.getExactlyMatchingMessagesForTokenFromCache(this._channel.url,e,this.filter));const a=t>0?yield this._channelManager.getMessagesFromCache(this._channel.url,e,"prev",this.filter,t,!1):[],r=s>0?yield this._channelManager.getMessagesFromCache(this._channel.url,e,"next",this.filter,s,!1):[];return[...i,...a,...r].sort(((e,t)=>t.createdAt-e.createdAt))}))}_getRemoteMessages(e,{prevLimit:t=0,nextLimit:s=0,source:n=d.CollectionEventSource.REQUEST_MESSAGE,reverse:i=!1,checkingHasNext:a=!1,checkingContinuousMessages:r=!1}){return d.__awaiter(this,void 0,void 0,(function*(){const o=h.MessageManager.of(this._iid);return t>0||s>0?yield o._getMessagesByTimestampForCollection(this._channel.url,this._channel.channelType,e,d.undefineNullProps(Object.assign(Object.assign(Object.assign({},this.filter),Xe),{isInclusive:!0,reverse:i,prevResultSize:t,nextResultSize:s})),n,a,r):{messages:[],isContinuousMessages:!1}}))}_checkHugeGap(){var e,t,s,n,i;return d.__awaiter(this,void 0,void 0,(function*(){const{dispatcher:a,requestQueue:r,cacheContext:o,statLogCollector:l}=d.Vault.of(this._iid);if(this._messages.length>0){const s=this._syncRange.top,n=this.viewTop,i=this._syncRange.bottom,h=this.hasNext?this.viewBottom:Number.MAX_SAFE_INTEGER,c=yield this._channelManager.getCachedMessageCountBetween(this._channel.url,this.filter,n,s),u=yield this._channelManager.getCachedMessageCountBetween(this._channel.url,this.filter,i,h);try{yield d.asyncRetry((()=>d.__awaiter(this,void 0,void 0,(function*(){var e;const t=new Be(Object.assign(Object.assign({channelUrl:this._channel.url,channelType:this._channel.channelType,prevStart:n,prevEnd:s,prevCount:c,nextStart:i,nextEnd:h,nextCount:u,checkingContinuousMessages:o.localCacheEnabled},this.filter),Xe)),l=yield r.send(t),{isHugeGap:_,prevMessages:p=[],prevHasMore:m,isContinuousPrevMessages:g,nextMessages:C=[],nextHasmore:E,isContinuousNextMessages:v}=l.as(je);if(_)d.runAsCallback((()=>d.__awaiter(this,void 0,void 0,(function*(){var e;(null===(e=this._handler)||void 0===e?void 0:e.onHugeGapDetected)&&this._handler.onHugeGapDetected()}))));else{const t=this.viewTop,s=this.viewBottom,n=Math.min(Number.MAX_SAFE_INTEGER,t,...p.map((e=>e.createdAt))),i=Math.max(0,s,...C.map((e=>e.createdAt)));a.dispatch(new d.MessageUpdateEventCommand({messages:p,source:d.CollectionEventSource.SYNC_MESSAGE_FILL})),a.dispatch(new d.MessageUpdateEventCommand({messages:C,source:d.CollectionEventSource.SYNC_MESSAGE_FILL})),this._syncRange.extends(n,i),(g||v)&&(null===(e=this._backgroundSync)||void 0===e||e.range.extends(n,i)),m&&this._prevFill.start(n),E&&this._nextFill.start(i)}}))),1)}finally{l.put(new d.StatLog({type:d.StatType.FEATURE_LOCALCACHE_EVENT,ts:Date.now(),data:{channel_url:this.channel.url,measured_on:"gap_check",event:"cache_fetch",max_db_size:null!==(t=null===(e=o.localCacheConfig)||void 0===e?void 0:e.maxSize)&&void 0!==t?t:0,use_local_cache:o.localCacheEnabled,starting_point:0,message_init_policy:""}}))}}else{const e=Math.floor(this._limit/2),t=Date.now();try{const{messages:n,isContinuousMessages:i,hasNext:a}=yield this._getRemoteMessages(t,{prevLimit:e,nextLimit:e,source:d.CollectionEventSource.SYNC_MESSAGE_FILL,checkingHasNext:!0,checkingContinuousMessages:o.localCacheEnabled});if(n.length>0){const r=n.map((e=>e.createdAt));let o=0,l=0;for(let e=0;e=t&&l++}this._hasPrevious=o>=e,this._hasNext=null!=a?a:l>=e,this._syncRange.extends(...r),i&&(null===(s=this._backgroundSync)||void 0===s||s.range.extends(this._syncRange.top,this._syncRange.bottom)),this._addMessagesToView(n,d.CollectionEventSource.SYNC_MESSAGE_FILL)}else this._hasPrevious=!1,this._hasNext=!1}catch(e){e instanceof d.SendbirdError&&e.code===d.SendbirdErrorCode.NOT_FOUND_IN_DATABASE&&(this._hasPrevious=!1,this._hasNext=!1)}finally{l.put(new d.StatLog({type:d.StatType.FEATURE_LOCALCACHE_EVENT,ts:Date.now(),data:{channel_url:this.channel.url,measured_on:"gap_check",event:"cache_fetch",max_db_size:null!==(i=null===(n=o.localCacheConfig)||void 0===n?void 0:n.maxSize)&&void 0!==i?i:0,use_local_cache:o.localCacheEnabled,starting_point:0,message_init_policy:""}}))}}}))}_loadUnsentMessages(){return d.__awaiter(this,void 0,void 0,(function*(){this._unsentMessages=yield this._channelManager.getUnsentMessagesFromCache(this._channel.url,this.filter)}))}_hasPollMessage(){return d.__awaiter(this,void 0,void 0,(function*(){return(yield this._channelManager.getPollMessagesFromCache(this._channel.url,Date.now()+Je,this.filter,1)).length>0}))}_refreshChannel(e){this._channelManager.refreshChannel(this.channel.url,!0,e)}_startCheckMyMutedTimer(e){this._clearCheckMyMutedTimer(),this._checkMyMutedStateTimer=setTimeout((()=>d.__awaiter(this,void 0,void 0,(function*(){this._checkMyMutedStateTimer=void 0;let e=!0;try{e=!(yield this._channel.getMyMutedInfo()).isMuted}catch(t){e=!0}finally{e&&this.channel._runIfHandleableWithGroupChannel((e=>{var t,s;e.myMutedState=d.MutedState.UNMUTED;const n=this._createChannelEventContext(d.CollectionEventSource.EVENT_CHANNEL_UNMUTED);null===(s=null===(t=this._handler)||void 0===t?void 0:t.onChannelUpdated)||void 0===s||s.call(t,n,this.channel)}))}}))),e+1e3)}_clearCheckMyMutedTimer(){this._checkMyMutedStateTimer&&(clearTimeout(this._checkMyMutedStateTimer),this._checkMyMutedStateTimer=void 0)}initialize(e){const t=new Ze;this._messages=[],this._unsentMessages=[],this._syncRange=new Te({}),this._hasNext=!0,this._hasPrevious=!0,this._refreshChannel(d.CollectionEventSource.REFRESH_CHANNEL);const{cacheContext:s,statLogCollector:n}=d.Vault.of(this._iid),i=Math.floor(this._limit/2);if(e===exports.MessageCollectionInitPolicy.CACHE_AND_REPLACE_BY_API)this._getLocalMessages(this._startingPoint,{prevLimit:i,nextLimit:i}).then((e=>d.__awaiter(this,void 0,void 0,(function*(){const s=this._filterUnderOffsetMessage(e);this._addMessagesToView(s,d.CollectionEventSource.REQUEST_MESSAGE),yield this._loadUnsentMessages(),t._invokeResponse("local",null,s)})))).catch((e=>{if(d.isThrowingOutside(e))throw e;t._invokeResponse("local",e,null)})).finally((()=>{const{cacheContext:s}=d.Vault.of(this._iid);this._getRemoteMessages(this._startingPoint,{prevLimit:i,nextLimit:i,reverse:!0,checkingHasNext:!0,checkingContinuousMessages:s.localCacheEnabled}).then((({messages:a,isContinuousMessages:r,hasNext:o})=>{var l,h,c,u,_;const p=this._filterUnderOffsetMessage(a);let m=!0;if(this._messages.length===p.length){const e=this._messages.map((e=>this.keyOf(e)));for(const t in p)if(!e.includes(this.keyOf(p[t]))){m=!1;break}}else m=!1;if(this._messages=[],p.length>0){const e=p.map((e=>e.createdAt));let t=0,s=0;for(let n=0;nthis._startingPoint&&s++}this._hasPrevious=t>=i,this._hasNext=null!=o?o:s>=i,this._syncRange.extends(...p.map((e=>e.createdAt))),r&&(null===(l=this._backgroundSync)||void 0===l||l.range.extends(this._syncRange.top,this._syncRange.bottom)),this._addMessagesToView(p,d.CollectionEventSource.REQUEST_MESSAGE)}else this._hasPrevious=!1,this._hasNext=!1;n.put(new d.StatLog({type:d.StatType.FEATURE_LOCALCACHE_EVENT,ts:Date.now(),data:{channel_url:this.channel.url,starting_point:this._startingPoint,measured_on:"initial_load",event:m?"cache_hit":"cache_miss",max_db_size:null!==(c=null===(h=s.localCacheConfig)||void 0===h?void 0:h.maxSize)&&void 0!==c?c:0,message_init_policy:e,use_local_cache:s.localCacheEnabled,collection_id:this._key}})),n.put(new d.StatLog({type:d.StatType.FEATURE_LOCALCACHE_EVENT,ts:Date.now(),data:{channel_url:this.channel.url,starting_point:this._startingPoint,measured_on:"initial_load",event:"cache_fetch",max_db_size:null!==(_=null===(u=s.localCacheConfig)||void 0===u?void 0:u.maxSize)&&void 0!==_?_:0,message_init_policy:e,use_local_cache:s.localCacheEnabled,collection_id:this._key}})),t._invokeResponse("remote",null,p)})).catch((e=>{if(d.isThrowingOutside(e))throw e;t._invokeResponse("remote",e,null)}))}));return n.put(new d.DailyRecordStatLog({type:d.StatType.FEATURE_LOCALCACHE,data:{use_local_cache:s.localCacheEnabled,collection_interface:{message_init_policy:e}}})),t}loadPrevious(){var e,t,s;return d.__awaiter(this,void 0,void 0,(function*(){if(this._isDisposed)throw new d.SendbirdError({code:d.SendbirdErrorCode.COLLECTION_DISPOSED,message:"Collection has been disposed."});if(!this._hasPrevious)return[];const n=Math.floor(this._limit/2),i=this.viewTop;let a=[];yield d.runOrNothing((()=>d.__awaiter(this,void 0,void 0,(function*(){a=this._filterUnderOffsetMessage(yield this._getLocalMessages(i,{prevLimit:n,inclusive:!1}))}))));const r=a.length>=n,{cacheContext:o,statLogCollector:l}=d.Vault.of(this._iid);return l.put(new d.StatLog({type:d.StatType.FEATURE_LOCALCACHE_EVENT,ts:Date.now(),data:{channel_url:this.channel.url,starting_point:this._startingPoint,measured_on:"load_prev",event:r?"cache_hit":"cache_miss",max_db_size:null!==(t=null===(e=o.localCacheConfig)||void 0===e?void 0:e.maxSize)&&void 0!==t?t:0,use_local_cache:o.localCacheEnabled,collection_id:this._key,message_init_policy:""}})),r&&(null===(s=this._backgroundSync)||void 0===s?void 0:s.isWrappingMessages(a))?(this._hasPrevious=a.length>=n,a.length>0&&this._addMessagesToView(a,d.CollectionEventSource.REQUEST_MESSAGE)):(yield d.runOrNothing((()=>d.__awaiter(this,void 0,void 0,(function*(){var e,t,s,r;const{cacheContext:o}=d.Vault.of(this._iid),h=yield this._getRemoteMessages(i,{prevLimit:n,reverse:!0,checkingContinuousMessages:o.localCacheEnabled});a=this._filterUnderOffsetMessage(h.messages),a=a.filter((e=>Pe(this._messages,e)<0)),this._hasPrevious=a.length>=n,a.length>0&&(this._syncRange.extends(...a.map((e=>e.createdAt))),(null===(e=this._backgroundSync)||void 0===e?void 0:e.range.overlap(this._syncRange))&&h.isContinuousMessages&&(null===(t=this._backgroundSync)||void 0===t||t.range.extends(this._syncRange.top))),l.put(new d.StatLog({type:d.StatType.FEATURE_LOCALCACHE_EVENT,ts:Date.now(),data:{channel_url:this.channel.url,starting_point:this._startingPoint,measured_on:"load_prev",event:"cache_fetch",max_db_size:null!==(r=null===(s=o.localCacheConfig)||void 0===s?void 0:s.maxSize)&&void 0!==r?r:0,use_local_cache:o.localCacheEnabled,collection_id:this._key,message_init_policy:""}}))})))),this._addMessagesToView(a,d.CollectionEventSource.REQUEST_MESSAGE)),a}))}loadNext(){var e,t,s;return d.__awaiter(this,void 0,void 0,(function*(){if(this._isDisposed)throw new d.SendbirdError({code:d.SendbirdErrorCode.COLLECTION_DISPOSED,message:"Collection has been disposed."});if(!this._hasNext)return[];const n=Math.floor(this._limit/2),i=this.viewBottom;let a=[];yield d.runOrNothing((()=>d.__awaiter(this,void 0,void 0,(function*(){a=this._filterUnderOffsetMessage(yield this._getLocalMessages(i,{nextLimit:n,inclusive:!1}))}))));const r=a.length>=n,{cacheContext:o,statLogCollector:l}=d.Vault.of(this._iid);return l.put(new d.StatLog({type:d.StatType.FEATURE_LOCALCACHE_EVENT,ts:Date.now(),data:{channel_url:this.channel.url,starting_point:this._startingPoint,measured_on:"load_next",event:r?"cache_hit":"cache_miss",max_db_size:null!==(t=null===(e=o.localCacheConfig)||void 0===e?void 0:e.maxSize)&&void 0!==t?t:0,use_local_cache:o.localCacheEnabled,collection_id:this._key,message_init_policy:""}})),r&&(null===(s=this._backgroundSync)||void 0===s?void 0:s.isWrappingMessages(a))?(this._hasNext=a.length>=n,a.length>0&&this._addMessagesToView(a,d.CollectionEventSource.REQUEST_MESSAGE)):(yield d.runOrNothing((()=>d.__awaiter(this,void 0,void 0,(function*(){var e,t,s,r,o;const{cacheContext:h}=d.Vault.of(this._iid),c=yield this._getRemoteMessages(i,{nextLimit:n,reverse:!0,checkingHasNext:!0,checkingContinuousMessages:h.localCacheEnabled});a=this._filterUnderOffsetMessage(c.messages),a=a.filter((e=>Pe(this._messages,e)<0)),this._hasNext=null!==(e=c.hasNext)&&void 0!==e?e:a.length>=n,a.length>0&&(this._syncRange.extends(...a.map((e=>e.createdAt))),(null===(t=this._backgroundSync)||void 0===t?void 0:t.range.overlap(this._syncRange))&&c.isContinuousMessages&&(null===(s=this._backgroundSync)||void 0===s||s.range.extends(this._syncRange.bottom))),l.put(new d.StatLog({type:d.StatType.FEATURE_LOCALCACHE_EVENT,ts:Date.now(),data:{channel_url:this.channel.url,starting_point:this._startingPoint,measured_on:"load_next",event:"cache_fetch",max_db_size:null!==(o=null===(r=h.localCacheConfig)||void 0===r?void 0:r.maxSize)&&void 0!==o?o:0,use_local_cache:h.localCacheEnabled,collection_id:this._key,message_init_policy:""}}))})))),this._addMessagesToView(a,d.CollectionEventSource.REQUEST_MESSAGE)),a}))}removeFailedMessage(e){return d.__awaiter(this,void 0,void 0,(function*(){if(this._isDisposed)throw new d.SendbirdError({code:d.SendbirdErrorCode.COLLECTION_DISPOSED,message:"Collection has been disposed."});yield this._channelManager.removeFailedMessageFromCache(e);const t=this._unsentMessages.findIndex((t=>t.reqId===e));t>-1&&this._unsentMessages.splice(t,1)}))}dispose(){var e,t,s;if(this._isDisposed)return;this._isDisposed=!0;const{cacheContext:n,dispatcher:i}=d.Vault.of(this._iid);this._messages=[],this._clearCheckMyMutedTimer(),this._channel._runIfHandleableWithGroupChannel((e=>{if(e.myMemberState!==exports.MemberState.NONE){this._channel._updateMessageCollectionLastAccessedAt();const e=this._createChannelUpdateEventCommand(d.CollectionEventSource.CHANNEL_LASTACCESSEDAT_UPDATED);e&&i.dispatch(e)}})),n.localCacheEnabled&&(this._prevFill.stop(),this._nextFill.stop()),null===(e=this._backgroundSync)||void 0===e||e.close(),null===(t=this._changelogSync)||void 0===t||t.close(),null===(s=this._pollChangelogSync)||void 0===s||s.close(),this._channelManager.unsubscribeChannelEvent(this._key),this._channelManager.unsubscribeMessageEvent(this._key),this._connectionEventContext&&this._connectionEventContext.close()}}class tt extends et{keyOf(e){return e.messageId}constructor(e,t){super(e,Object.assign(Object.assign({},t),{channelManager:Ie.of(e)}))}initialize(e){return d.runOrNothing((()=>d.__awaiter(this,void 0,void 0,(function*(){const e=yield this.channel.getMyMutedInfo();e.isMuted&&-1!==e.remainingDuration&&this._startCheckMyMutedTimer(e.remainingDuration)})))),super.initialize(e)}setMessageCollectionHandler(e){this._setBaseMessageCollectionHandler(e)}_activate(){const e=Object.create(null,{_activate:{get:()=>super._activate}});return d.__awaiter(this,void 0,void 0,(function*(){yield e._activate.call(this);const t=yield this.channel.getMyMutedInfo();t.isMuted&&-1!==t.remainingDuration&&this._startCheckMyMutedTimer(t.remainingDuration)}))}_addMessagesToView(e,t){const s=this._filterUnderOffsetMessage(e),n=[],i=[];for(const e of s)if(t===d.CollectionEventSource.SYNC_MESSAGE_FILL){if(e.messageId>0){if(Pe(this._messages,e)<0){Pe(this._unsentMessages,e)<0&&n.push(e);const t=Oe(this._messages,e);this._messages.splice(t,0,e)}}else if(e instanceof h.SendableMessage){Pe(this._unsentMessages,e)<0&&Pe(this._messages,e)<0&&(this._unsentMessages.push(e),n.push(e))}}else if(e.messageId>0){const t=Pe(this._messages,e);if(t<0){const t=Pe(this._unsentMessages,e);t<0?n.push(e):(this._unsentMessages.splice(t,1),i.push(e));const s=Oe(this._messages,e);this._messages.splice(s,0,e)}else i.push(e),this._messages[t]=e;if(e.updatedAt>0){const t=this._updateChildMessagesInView(e);i.push(...t)}}else if(e instanceof h.SendableMessage){const t=Pe(this._unsentMessages,e);t<0?Pe(this._messages,e)<0&&(this._unsentMessages.push(e),n.push(e)):(i.push(e),this._unsentMessages[t]=e)}d.shouldGiveEvent(t)&&d.runAsCallback((()=>d.__awaiter(this,void 0,void 0,(function*(){var e,s,a,r;const o=this._createMessageEventContext(t);n.length>0&&(null===(s=null===(e=this._handler)||void 0===e?void 0:e.onMessagesAdded)||void 0===s||s.call(e,o,this.channel,n)),i.length>0&&(null===(r=null===(a=this._handler)||void 0===a?void 0:a.onMessagesUpdated)||void 0===r||r.call(a,o,this.channel,i))}))))}_updateMessagesToView(e,t){const s=[],n=[],i=[];for(const t of e)if(t.messageId>0){const e=Pe(this._messages,t);if(e>=0)n.push(t),this._messages[e]=t;else{const e=Pe(this._unsentMessages,t);if(e>=0){const[s]=this._unsentMessages.splice(e,1);if(this.hasNext&&s)i.push(s);else{n.push(t);const e=Oe(this._messages,t);this._messages.splice(e,0,t)}}else{const e=this._messages.map((e=>e.createdAt));(t.createdAtMath.max(...e)&&!this._hasNext)&&s.push(t)}}}else if(t instanceof h.SendableMessage){const e=Pe(this._unsentMessages,t);e>=0&&(n.push(t),this._unsentMessages[e]=t)}return d.shouldGiveEvent(t)&&d.runAsCallback((()=>d.__awaiter(this,void 0,void 0,(function*(){var e,a,r,o;const l=this._createMessageEventContext(t);n.length>0?null===(a=null===(e=this._handler)||void 0===e?void 0:e.onMessagesUpdated)||void 0===a||a.call(e,l,this.channel,n):i.length>0?null===(o=null===(r=this._handler)||void 0===r?void 0:r.onMessagesDeleted)||void 0===o||o.call(r,l,this.channel,[],i):s.length>0&&this._addMessagesToView(s,t)})))),n}}const st={coverUrl:void 0,coverImage:void 0,isDistinct:void 0,isPublic:void 0,isDiscoverable:void 0,accessCode:void 0,name:void 0,data:void 0,customType:void 0,operatorUserIds:void 0,messageSurvivalSeconds:void 0};class nt extends d.APIRequestCommand{constructor(e){const{channelUrl:t,token:s,limit:n,order:i,mutedMemberFilter:a,memberStateFilter:r,nicknameStartsWithFilter:o,operatorFilter:l}=e;super(),this.method=d.APIRequestMethod.GET,this.path=`${d.API_PATH_GROUP_CHANNELS}/${encodeURIComponent(t)}/members`,this.params={token:s,limit:n,order:i,muted_member_filter:a,member_state_filter:r,nickname_startswith:o,operator_filter:l,show_member_is_muted:!0,show_read_receipt:!0,show_delivery_receipt:!0}}}class it extends d.APIResponseCommand{constructor(e,t){super(e,t),this.members=[];const{next:s,members:n}=t;this.token=s,n&&n.length>0&&(this.members=n.map((t=>new _(e,t))))}}var at,rt,ot;exports.MutedMemberFilter=void 0,(at=exports.MutedMemberFilter||(exports.MutedMemberFilter={})).ALL="all",at.MUTED="muted",at.UNMUTED="unmuted",exports.MemberListOrder=void 0,(rt=exports.MemberListOrder||(exports.MemberListOrder={})).MEMBER_NICKNAME_ALPHABETICAL="member_nickname_alphabetical",rt.OPERATOR_THEN_MEMBER_ALPHABETICAL="operator_then_member_alphabetical",exports.MemberStateFilter=void 0,(ot=exports.MemberStateFilter||(exports.MemberStateFilter={})).ALL="all",ot.JOINED="joined_only",ot.INVITED="invited_only",ot.INVITED_BY_FRIEND="invited_by_friend",ot.INVITED_BY_NON_FRIEND="invited_by_non_friend";class lt extends d.ChannelDataListQuery{constructor(e,t,s){var n,i,a,r;super(e,t,d.ChannelType.GROUP,s),this.mutedMemberFilter=exports.MutedMemberFilter.ALL,this.memberStateFilter=exports.MemberStateFilter.ALL,this.nicknameStartsWithFilter=null,this.operatorFilter=exports.OperatorFilter.ALL,this.order=exports.MemberListOrder.MEMBER_NICKNAME_ALPHABETICAL,this.mutedMemberFilter=null!==(n=s.mutedMemberFilter)&&void 0!==n?n:exports.MutedMemberFilter.ALL,this.memberStateFilter=null!==(i=s.memberStateFilter)&&void 0!==i?i:exports.MemberStateFilter.ALL,this.nicknameStartsWithFilter=null!==(a=s.nicknameStartsWithFilter)&&void 0!==a?a:null,this.order=null!==(r=s.order)&&void 0!==r?r:exports.MemberListOrder.MEMBER_NICKNAME_ALPHABETICAL}_validate(){return super._validate()&&d.isEnumOf(exports.MutedMemberFilter,this.mutedMemberFilter)&&d.isEnumOf(exports.MemberStateFilter,this.memberStateFilter)&&(d.isTypeOf("string",this.nicknameStartsWithFilter)||null===this.nicknameStartsWithFilter)&&d.isEnumOf(exports.OperatorFilter,this.operatorFilter)&&d.isEnumOf(exports.MemberListOrder,this.order)}next(){return d.__awaiter(this,void 0,void 0,(function*(){if(this._validate()){if(this._isLoading)throw d.SendbirdError.queryInProgress;if(this._hasNext){this._isLoading=!0;const{requestQueue:e}=d.Vault.of(this._iid),t=new nt(d.undefineNullProps(Object.assign(Object.assign({},this),{token:this._token}))),s=yield e.send(t),{members:n,token:i}=s.as(it);return this._token=i,this._hasNext=!!i,this._isLoading=!1,n}return[]}throw d.SendbirdError.invalidParameters}))}}class dt extends d.APIRequestCommand{constructor(e){const{channelUrl:t,userId:s,accessCode:n}=e;super(),this.method=d.APIRequestMethod.PUT,this.path=`${d.API_PATH_GROUP_CHANNELS}/${encodeURIComponent(t)}/accept`,this.params={user_id:s,access_code:n}}}class ht extends d.APIResponseCommand{constructor(e,t){super(e,t),this.channel=new kt(e,t),this.channel.myMemberState=exports.MemberState.JOINED}}class ct extends d.APIRequestCommand{constructor(e){const{channelUrl:t,isDistinct:s,isPublic:n,isDiscoverable:i,coverUrl:a,coverImage:r,accessCode:o,name:l,data:h,customType:c,operatorUserIds:u,messageSurvivalSeconds:_}=e;super(),this.method=d.APIRequestMethod.PUT,this.path=`${d.API_PATH_GROUP_CHANNELS}/${encodeURIComponent(t)}`,this.params=d.deundefined({is_distinct:s,is_public:n,is_discoverable:i,name:l,data:h,custom_type:c,cover_url:a,cover_file:r,access_code:o,operator_ids:u,message_survival_seconds:_})}}class ut extends d.APIResponseCommand{constructor(e,t){super(e,t),this.channel=new kt(e,t)}}class _t extends d.APIRequestCommand{constructor(e){const{channelUrl:t}=e;super(),this.method=d.APIRequestMethod.DELETE,this.path=`${d.API_PATH_GROUP_CHANNELS}/${encodeURIComponent(t)}`}}class pt extends d.APIRequestCommand{constructor(e){const{channelUrl:t}=e;super(),this.method=d.APIRequestMethod.DELETE,this.path=`${d.API_PATH_GROUP_CHANNELS}/${encodeURIComponent(t)}/hide`}}class mt extends d.APIRequestCommand{constructor({userId:e,channelUrl:t,countPreference:s}){super(),this.method=d.APIRequestMethod.PUT,this.path=`${d.API_PATH_USERS}/${encodeURIComponent(e)}/count_preference/${encodeURIComponent(t)}`,this.params={count_preference:s}}}class gt extends d.APIResponseCommand{constructor(e,t){super(e,t),this.countPreference=t.count_preference}}class Ct extends d.APIRequestCommand{constructor(e){const{channelUrl:t}=e;super(),this.method=d.APIRequestMethod.PUT,this.path=`${d.API_PATH_GROUP_CHANNELS}/${encodeURIComponent(t)}/reset_user_history`}}class Et extends d.APIResponseCommand{constructor(e,t){super(e,t);const{ts_message_offset:s}=t;this.messageOffsetTimestamp=s}}const vt=Object.assign(Object.assign({},h.BaseMessageUpdateParamsDefault),{scheduledAt:void 0,file:void 0,fileUrl:void 0,fileName:void 0,mimeType:void 0,fileSize:void 0,thumbnailSizes:void 0,requireAuth:!1}),ft=Object.assign(Object.assign({},h.UserMessageUpdateParamsDefault),{scheduledAt:void 0});class Mt extends d.APIRequestCommand{constructor(e){var t;super();let s=[];e.mentionType===d.MentionType.USERS&&(e.mentionedUserIds?s=e.mentionedUserIds:e.mentionedUsers&&(s=e.mentionedUsers.map((e=>e.userId))));const{channelType:n,channelUrl:i,scheduledMessageId:a}=e;this.method=d.APIRequestMethod.PUT,this.path=`${d.getChannelApiPathByType(n)}/${encodeURIComponent(i)}/scheduled_messages/${encodeURIComponent(a)}`,this.params=d.deundefined(d.undefineNullProps({req_id:e.reqId,scheduled_at:e.scheduledAt,message_type:d.ServerSideMessageType.FILE,url:e.fileUrl,file_name:e.fileName,file_size:e.fileSize,file_type:e.mimeType,thumbnails:e.thumbnailSizes?e.thumbnailSizes.map((e=>h.Thumbnail.payloadify(e))):[],custom_type:e.customType,data:e.data,require_auth:e.requireAuth,mention_type:e.mentionType,mentioned_user_ids:s,sorted_metaarray:null===(t=e.metaArrays)||void 0===t?void 0:t.map((e=>h.MessageMetaArray.payloadify(e))),apple_critical_alert_options:e.appleCriticalAlertOptions?h.AppleCriticalAlertOptions.payloadify(e.appleCriticalAlertOptions):null,push_option:e.pushNotificationDeliveryOption}))}}class St extends d.APIResponseCommand{constructor(e,t){super(e,t),this.message=new h.FileMessage(e,t)}}class yt extends d.APIRequestCommand{constructor(e){var t;super();let s=[];e.mentionType===d.MentionType.USERS&&(e.mentionedUserIds?s=e.mentionedUserIds:e.mentionedUsers&&(s=e.mentionedUsers.map((e=>e.userId))));const{channelType:n,channelUrl:i,scheduledMessageId:a}=e;this.method=d.APIRequestMethod.PUT,this.path=`${d.getChannelApiPathByType(n)}/${encodeURIComponent(i)}/scheduled_messages/${encodeURIComponent(a)}`,this.params=d.deundefined(d.undefineNullProps({req_id:e.reqId,scheduled_at:e.scheduledAt,message_type:d.ServerSideMessageType.USER,message:e.message,custom_type:e.customType,data:e.data,mention_type:e.mentionType,mentioned_user_ids:s,sorted_metaarray:null===(t=e.metaArrays)||void 0===t?void 0:t.map((e=>h.MessageMetaArray.payloadify(e))),apple_critical_alert_options:e.appleCriticalAlertOptions?h.AppleCriticalAlertOptions.payloadify(e.appleCriticalAlertOptions):null,target_langs:e.translationTargetLanguages,push_option:e.pushNotificationDeliveryOption}))}}class At extends d.APIRequestCommand{constructor(e){super();const{channelType:t,channelUrl:s,scheduledMessageId:n}=e;this.method=d.APIRequestMethod.DELETE,this.path=`${d.getChannelApiPathByType(t)}/${encodeURIComponent(s)}/scheduled_messages/${encodeURIComponent(n)}`}}class bt extends d.APIRequestCommand{constructor(e){super();const{channelType:t,channelUrl:s,scheduledMessageId:n}=e;this.method=d.APIRequestMethod.POST,this.path=`${d.getChannelApiPathByType(t)}/${encodeURIComponent(s)}/scheduled_messages/${encodeURIComponent(n)}/send_now`}}class Nt extends d.APIRequestCommand{constructor({userId:e,channelUrl:t,pushTriggerOption:s}){super(),this.method=d.APIRequestMethod.PUT,this.path=`${d.API_PATH_USERS}/${encodeURIComponent(e)}/push_preference/${encodeURIComponent(t)}`,this.params={push_trigger_option:s}}}class Tt extends d.APIResponseCommand{constructor(e,t){super(e,t),this.pushTriggerOption=t.push_trigger_option,this.enabled=t.enable}}class Ut extends d.APIRequestCommand{constructor({userId:e,channelUrl:t}){super(),this.method=d.APIRequestMethod.GET,this.path=`${d.API_PATH_USERS}/${encodeURIComponent(e)}/push_preference/${encodeURIComponent(t)}`}}class It extends d.APIResponseCommand{constructor(e,t){super(e,t),this.pushTriggerOption=t.push_trigger_option,this.enabled=t.enable}}class Pt extends d.APIRequestCommand{constructor({channelType:e,channelUrl:t,messageId:s}){super(),this.method=d.APIRequestMethod.POST,this.path=`${d.getChannelApiPathByType(e)}/${encodeURIComponent(t)}/messages/${s}/pin`}}class xt extends d.APIRequestCommand{constructor({channelType:e,channelUrl:t,messageId:s}){super(),this.method=d.APIRequestMethod.DELETE,this.path=`${d.getChannelApiPathByType(e)}/${encodeURIComponent(t)}/messages/${s}/pin`}}class Ot extends d.InstancedObject{constructor(e,t){super(e),this.message=null,this.message=h.parseMessagePayload(e,t.message)}}class wt extends d.APIRequestCommand{constructor(e){const{channelType:t,channelUrl:s,limit:n,token:i,includeReactions:a,includeMetaArray:r,includeParentMessageInfo:o,includeThreadInfo:l,includePollDetails:h}=e;super(),this.method=d.APIRequestMethod.GET,this.path=`${d.getChannelApiPathByType(t)}/${encodeURIComponent(s)}/pinned_messages`,this.params=d.deundefined({limit:n,token:i,include_reactions:a,with_sorted_meta_array:r,include_thread_info:l,include_parent_message_info:o,include_poll_details:h})}}class Rt extends d.APIResponseCommand{constructor(e,t){super(e,t);const{pinned_messages:s,has_more:n,next:i}=t;this.pinnedMessages=s.map((t=>new Ot(e,t))),this.hasMore=n,this.token=i}}class Lt extends d.ChannelDataListQuery{constructor(e,t,s,n){super(e,t,s,n),this.includeMetaArray=n.includeMetaArray,this.includeReactions=n.includeReactions,this.includeParentMessageInfo=n.includeParentMessageInfo,this.includeThreadInfo=n.includeThreadInfo,this.includePollDetails=n.includePollDetails}_validate(){return super._validate()&&d.isTypeOf("boolean",this.includeMetaArray,!0)&&d.isTypeOf("boolean",this.includeReactions,!0)&&d.isTypeOf("boolean",this.includeParentMessageInfo,!0)&&d.isTypeOf("boolean",this.includeThreadInfo,!0)&&d.isTypeOf("boolean",this.includePollDetails,!0)}next(){return d.__awaiter(this,void 0,void 0,(function*(){if(this._validate()){if(this._isLoading)throw d.SendbirdError.queryInProgress;if(this._hasNext){this._isLoading=!0;const{requestQueue:e}=d.Vault.of(this._iid),t=new wt(Object.assign(Object.assign({},this),{token:this._token})),s=yield e.send(t),{pinnedMessages:n,hasMore:i,token:a}=s.as(Rt);return this._token=a,this._hasNext=!!i,this._isLoading=!1,n}return[]}throw d.SendbirdError.invalidParameters}))}}var Ft,Dt;exports.CountPreference=void 0,(Ft=exports.CountPreference||(exports.CountPreference={})).ALL="all",Ft.UNREAD_MESSAGE_COUNT_ONLY="unread_message_count_only",Ft.UNREAD_MENTION_COUNT_ONLY="unread_mention_count_only",Ft.OFF="off",exports.HiddenState=void 0,(Dt=exports.HiddenState||(exports.HiddenState={})).UNHIDDEN="unhidden",Dt.HIDDEN_ALLOW_AUTO_UNHIDE="hidden_allow_auto_unhide",Dt.HIDDEN_PREVENT_AUTO_UNHIDE="hidden_prevent_auto_unhide";class kt extends h.BaseChannel{constructor(e,t){var s,n,i,a,r,o,l,c,u,p,m,g,C,E,v,f,M,S,y;super(e,t),this._unreadMemberStateMap=new Map,this._undeliveredMemberStateMap=new Map,this._typingStatus=new Map,this._lastMemberCountUpdated=0,this._typingStarted=0,this._typingEnded=0,this.isDistinct=!1,this.isSuper=!1,this.isBroadcast=!1,this.isExclusive=!1,this.isPublic=!1,this.isDiscoverable=!0,this.isChatNotification=!1,this.isAccessCodeRequired=!1,this.isPushEnabled=!1,this.unreadMessageCount=0,this.unreadMentionCount=0,this.members=[],this.memberCount=0,this.joinedMemberCount=0,this.hiddenState=exports.HiddenState.UNHIDDEN,this.lastMessage=null,this.messageOffsetTimestamp=0,this.messageSurvivalSeconds=-1,this.myMemberState=exports.MemberState.NONE,this.myRole=d.Role.NONE,this.myMutedState=d.MutedState.UNMUTED,this.myLastRead=0,this.myCountPreference=exports.CountPreference.ALL,this.myPushTriggerOption=d.PushTriggerOption.DEFAULT,this.inviter=null,this.invitedAt=0,this.joinedAt=0,this.pinnedMessageIds=[],this.lastPinnedMessage=null,this._pinnedMessagesUpdatedAt=0,this._myMutedRemainingTime=-1,this.channelType=d.ChannelType.GROUP,this.isDistinct=null!==(s=t.is_distinct)&&void 0!==s&&s,this.isSuper=null!==(n=t.is_super)&&void 0!==n&&n,this.isBroadcast=null!==(i=t.is_broadcast)&&void 0!==i&&i,this.isExclusive=null!==(a=t.is_exclusive)&&void 0!==a&&a,this.isPublic=null!==(r=t.is_public)&&void 0!==r&&r,this.isDiscoverable=null!==(o=t.is_discoverable)&&void 0!==o?o:this.isPublic,this.isChatNotification=null!==(l=t.is_chat_notification)&&void 0!==l&&l,this.isAccessCodeRequired=null!==(c=t.is_access_code_required)&&void 0!==c&&c,this.isPushEnabled=null!==(u=t.is_push_enabled)&&void 0!==u&&u,Array.isArray(t.members)&&this.members.push(...t.members.map((e=>new _(this._iid,e)))),this.memberCount=null!==(p=t.member_count)&&void 0!==p?p:0,this.joinedMemberCount=null!==(m=t.joined_member_count)&&void 0!==m?m:0,this.hiddenState=d.isEnumOf(exports.HiddenState,t.hidden_state)?t.hidden_state:exports.HiddenState.UNHIDDEN,this.messageOffsetTimestamp=null!==(g=t.ts_message_offset)&&void 0!==g?g:0,this.messageSurvivalSeconds=null!==(C=t.message_survival_seconds)&&void 0!==C?C:-1,this.lastMessage=t.last_message?h.parseMessagePayload(this._iid,Object.assign({channel_type:this.channelType},t.last_message)):null,t.read_receipt&&Object.keys(t.read_receipt).forEach((e=>{d.isTypeOf("number",t.read_receipt[e])&&this._updateUnreadMemberState(e,t.read_receipt[e])})),t.delivery_receipt&&Object.keys(t.delivery_receipt).forEach((e=>{d.isTypeOf("number",t.delivery_receipt[e])&&this._updateUndeliveredMemberState(e,t.delivery_receipt[e])})),this.myMemberState=d.isEnumOf(exports.MemberState,t.member_state)?t.member_state:exports.MemberState.NONE,this.myRole=d.isEnumOf(d.Role,t.my_role)?t.my_role:d.Role.NONE,d.isEnumOf(d.MutedState,t.is_muted)?this.myMutedState=t.is_muted:d.isTypeOf("boolean",t.is_muted)?this.myMutedState=t.is_muted?d.MutedState.MUTED:d.MutedState.UNMUTED:this.myMutedState=d.MutedState.UNMUTED,this.myCountPreference=d.isEnumOf(exports.CountPreference,t.count_preference)?t.count_preference:exports.CountPreference.ALL,this.myPushTriggerOption=d.isEnumOf(d.PushTriggerOption,t.push_trigger_option)?t.push_trigger_option:d.PushTriggerOption.ALL,this.myLastRead=null!==(E=t.user_last_read)&&void 0!==E?E:0,this.inviter=t.inviter?new d.User(this._iid,t.inviter):null,this.invitedAt=null!==(v=t.invited_at)&&void 0!==v?v:0,this.joinedAt=null!==(f=t.joined_ts)&&void 0!==f?f:0,this._updateUnreadCount(null!==(M=t.unread_message_count)&&void 0!==M?M:0,null!==(S=t.unread_mention_count)&&void 0!==S?S:0),this.pinnedMessageIds=null!==(y=t.pinned_message_ids)&&void 0!==y?y:[],this.lastPinnedMessage=t.latest_pinned_message?h.parseMessagePayload(this._iid,Object.assign({channel_type:this.channelType},t.latest_pinned_message)):null}get isHidden(){return this.hiddenState!==exports.HiddenState.UNHIDDEN}get isTyping(){return this._typingStatus.size>0}get cachedUnreadMemberState(){const e={};for(const[t,s]of this._unreadMemberStateMap)e[t]=s;return e}get cachedUndeliveredMemberState(){const e={};for(const[t,s]of this._undeliveredMemberStateMap)e[t]=s;return e}static payloadify(e){return d.deundefined(d.undefineNullProps(Object.assign(Object.assign({},super.payloadify(e)),{is_access_code_required:e.isAccessCodeRequired,is_distinct:e.isDistinct,is_super:e.isSuper,is_broadcast:e.isBroadcast,is_exclusive:e.isExclusive,is_public:e.isPublic,is_discoverable:e.isDiscoverable,is_muted:e.myMutedState,is_push_enabled:e.isPushEnabled,unread_message_count:e.unreadMessageCount,unread_mention_count:e.unreadMentionCount,push_trigger_option:e.myPushTriggerOption,count_preference:e.myCountPreference,hidden_state:e.hiddenState,member_count:e.memberCount,joined_member_count:e.joinedMemberCount,member_state:e.myMemberState,my_role:e.myRole,user_last_read:e.myLastRead,ts_message_offset:e.messageOffsetTimestamp,message_survival_seconds:e.messageSurvivalSeconds,read_receipt:e.cachedUnreadMemberState,delivery_receipt:e.cachedUndeliveredMemberState,members:e.members.map((e=>_.payloadify(e))),last_message:e.lastMessage?h.payloadifyMessage(e.lastMessage):null,inviter:e.inviter?d.User.payloadify(e.inviter):null,invited_at:e.invitedAt,joined_ts:e.joinedAt,pinned_message_ids:e.pinnedMessageIds,latest_pinned_message:e.lastPinnedMessage?h.payloadifyMessage(e.lastPinnedMessage):null})))}_shouldUpdateLastMessageWith(e){return!(e instanceof h.SendableMessage&&e.parentMessageId>0&&!e.replyToChannel)&&(!this.lastMessage||this.lastMessage.createdAt{t.onChannelChanged&&t.onChannelChanged(e)})),s.dispatch(new P({channels:[e],source:d.CollectionEventSource.EVENT_MESSAGE_SENT}))}_updateUnreadCount(e,t){if("number"==typeof e&&e>=0)if(this.myCountPreference===exports.CountPreference.ALL||this.myCountPreference===exports.CountPreference.UNREAD_MESSAGE_COUNT_ONLY)if(this.isExclusive||this.isSuper||this.isBroadcast){const{maxSuperGroupChannelUnreadCount:t}=d.Vault.of(this._iid);this.unreadMessageCount=t&&e>=t?t:e}else this.unreadMessageCount=e;else this.unreadMessageCount=0;else this.unreadMessageCount=0;"number"==typeof t&&t>=0&&(this.myCountPreference===exports.CountPreference.ALL||this.myCountPreference===exports.CountPreference.UNREAD_MENTION_COUNT_ONLY)?this.unreadMentionCount=t:this.unreadMentionCount=0}_updateUnreadMemberState(e,t){const s=this._unreadMemberStateMap.get(e);if(!s||s0?this._typingStatus.set(e.userId,{user:e,ts:t}):this._typingStatus.delete(e.userId)}_clearTypingStatus(){this._typingStatus.clear(),this._typingStarted=0,this._typingEnded=0}_setLatestMemberCount(e,t,s){let n=!1;return s>=this._lastMemberCountUpdated&&(this._lastMemberCountUpdated=s,n=e!==this.memberCount||t!==this.joinedMemberCount,this.memberCount=e,this.joinedMemberCount=t),n}isReadMessage(e){const{sdkState:t}=d.Vault.of(this._iid),s=this._unreadMemberStateMap.get(t.userId);return!!s&&s>=e.createdAt}serialize(){return d.serialize(this,(e=>{e.cachedUnreadMemberState=this.cachedUnreadMemberState,e.cachedUndeliveredMemberState=this.cachedUndeliveredMemberState}))}createMessageCollection(e={}){return new tt(this._iid,Object.assign(Object.assign({},e),{channel:this}))}createMemberListQuery(e={}){return new lt(this._iid,this.url,e)}createPinnedMessageListQuery(e={}){return new Lt(this._iid,this.url,this.channelType,e)}addMember(e,t=0){if(!this.isExclusive&&!this.isSuper&&!this.isBroadcast){const s=this.members.findIndex((t=>t.userId===e.userId));if(s>-1){const t=this.members[s];t.state===exports.MemberState.JOINED&&(e.state=t.state),this.members.splice(s,1),this.memberCount--}this.members.push(e),this.memberCount++,this._updateUnreadMemberState(e.userId,t),this._updateUndeliveredMemberState(e.userId,t)}}removeMember(e){if(!this.isExclusive&&!this.isSuper&&!this.isBroadcast){const t=e instanceof _?e.userId:e,s=this.members.findIndex((e=>e.userId===t));if(s>-1)return this.members.splice(s,1),this.memberCount--,!0}return!1}getUnreadMemberCount(e){if(e instanceof h.SendableMessage&&!this.isExclusive&&!this.isSuper&&!this.isBroadcast){const{sdkState:t}=d.Vault.of(this._iid),s=e.createdAt;let n=0;for(const i of this.members)if(t.userId!==i.userId&&i.state===exports.MemberState.JOINED&&e.sender.userId!==i.userId){(this.cachedUnreadMemberState[i.userId]||0){if(t||a.userId!==s.userId&&a.userId!==(null==n?void 0:n.userId)){const t=this._unreadMemberStateMap.get(a.userId);t&&t>=e.createdAt&&i.push(a)}})),i}getUnreadMembers(e,t=!1){const{sdkState:s}=d.Vault.of(this._iid);if(!s.userId||this.isExclusive||this.isSuper||this.isBroadcast)return[];const n=e instanceof h.SendableMessage?e.sender:null,i=[];return this.members.forEach((a=>{if(t||a.userId!==s.userId&&a.userId!==(null==n?void 0:n.userId)){const t=this._unreadMemberStateMap.get(a.userId);t&&t{if(e||n.userId!==t.userId){const e=this._unreadMemberStateMap.get(n.userId);s[n.userId]=new p(this._iid,{channel_url:this.url,channel_type:this.channelType,user:_.payloadify(n),ts:null!=e?e:0})}})),s}getTypingUsers(){const e=[];return this._typingStatus.forEach((t=>{const{user:s}=t;e.push(s)})),e}invalidateTypingStatus(){const{typingIndicatorInvalidateTime:e}=d.Vault.of(this._iid),t=Date.now();let s=!1;return this._typingStatus.forEach(((n,i)=>{const{ts:a}=n;t-a>=e&&(this._typingStatus.delete(i),s=!0)})),s}refresh(){return d.__awaiter(this,void 0,void 0,(function*(){return this._refresh()}))}_refresh(e=!1){return d.__awaiter(this,void 0,void 0,(function*(){const{requestQueue:t,dispatcher:s}=d.Vault.of(this._iid),n=new L({channelUrl:this.url}),i=yield t.send(n),{channel:a}=i.as(F);return this._update(a),e&&s.dispatch(new P({channels:[a],source:d.CollectionEventSource.REQUEST_CHANNEL})),this}))}freeze(){const e=Object.create(null,{freeze:{get:()=>super.freeze}});return d.__awaiter(this,void 0,void 0,(function*(){yield e.freeze.call(this);const{dispatcher:t}=d.Vault.of(this._iid);t.dispatch(new P({channels:[this],source:d.CollectionEventSource.EVENT_CHANNEL_FROZEN,isWebSocketEventComing:!0}))}))}unfreeze(){const e=Object.create(null,{unfreeze:{get:()=>super.unfreeze}});return d.__awaiter(this,void 0,void 0,(function*(){yield e.unfreeze.call(this);const{dispatcher:t}=d.Vault.of(this._iid);t.dispatch(new P({channels:[this],source:d.CollectionEventSource.EVENT_CHANNEL_UNFROZEN,isWebSocketEventComing:!0}))}))}updateChannel(e){return d.__awaiter(this,void 0,void 0,(function*(){const t=Object.assign(Object.assign({},st),e);d.unless((e=>d.isTypeOf("string",e.coverUrl,!0)&&(d.isFile(e.coverImage)||d.isTypeOf("string",e.coverImage,!0))&&d.isTypeOf("boolean",e.isDistinct,!0)&&d.isTypeOf("boolean",e.isPublic,!0)&&d.isTypeOf("boolean",e.isDiscoverable,!0)&&d.isTypeOf("string",e.accessCode,!0)&&d.isTypeOf("string",e.name,!0)&&d.isTypeOf("string",e.data,!0)&&d.isTypeOf("string",e.customType,!0)&&d.isArrayOf("string",e.operatorUserIds,!0)&&d.isTypeOf("number",e.messageSurvivalSeconds,!0))(t)).throw(d.SendbirdError.invalidParameters);const{dispatcher:s,requestQueue:n}=d.Vault.of(this._iid),i=new ct(Object.assign({channelUrl:this.url},t)),a=yield n.send(i),{channel:r}=a.as(ut);return this._update(r),s.dispatch(new P({channels:[r],source:d.CollectionEventSource.EVENT_CHANNEL_UPDATED,isWebSocketEventComing:!0})),this}))}invite(e){return d.__awaiter(this,void 0,void 0,(function*(){return d.unless(e.every((e=>e instanceof d.User))).throw(d.SendbirdError.invalidParameters),this.inviteWithUserIds(e.map((e=>e.userId)))}))}inviteWithUserIds(e){return d.__awaiter(this,void 0,void 0,(function*(){d.unless(d.isArrayOf("string",e)).throw(d.SendbirdError.invalidParameters);const{dispatcher:t,requestQueue:s}=d.Vault.of(this._iid),n=new ae({channelUrl:this.url,userIds:e}),i=yield s.send(n),{channel:a}=i.as(re);return this._update(a),t.dispatch(new P({channels:[a],source:d.CollectionEventSource.EVENT_CHANNEL_INVITED,isWebSocketEventComing:!0})),this}))}join(e){return d.__awaiter(this,void 0,void 0,(function*(){d.unless(d.isTypeOf("string",e,!0)).throw(d.SendbirdError.invalidParameters);const{dispatcher:t,sdkState:s,requestQueue:n}=d.Vault.of(this._iid),i=new ee({channelUrl:this.url,userId:s.userId,accessCode:e}),a=yield n.send(i),{channel:r}=a.as(te);return r.myMemberState=this.myMemberState=exports.MemberState.JOINED,this._update(r),t.dispatch(new P({channels:[r],source:d.CollectionEventSource.EVENT_CHANNEL_JOINED,isWebSocketEventComing:!0})),this}))}leave(e=!1){return d.__awaiter(this,void 0,void 0,(function*(){const{sdkState:t,requestQueue:s}=d.Vault.of(this._iid),n=new ne({channelUrl:this.url,userId:t.userId,shouldRemoveOperatorStatus:e});yield s.send(n),this.myMemberState=exports.MemberState.NONE}))}acceptInvitation(e){return d.__awaiter(this,void 0,void 0,(function*(){d.unless(d.isTypeOf("string",e,!0)).throw(d.SendbirdError.invalidParameters);const{dispatcher:t,sdkState:s,requestQueue:n}=d.Vault.of(this._iid),i=new dt({channelUrl:this.url,userId:s.userId,accessCode:e}),a=yield n.send(i),{channel:r}=a.as(ht);return r.myMemberState=this.myMemberState=exports.MemberState.JOINED,this._update(r),t.dispatch(new P({channels:[r],source:d.CollectionEventSource.EVENT_CHANNEL_ACCEPTED_INVITE,isWebSocketEventComing:!0})),this}))}declineInvitation(){return d.__awaiter(this,void 0,void 0,(function*(){const{sdkState:e,requestQueue:t}=d.Vault.of(this._iid),s=new le({channelUrl:this.url,userId:e.userId});return yield t.send(s),this.myMemberState=exports.MemberState.NONE,this}))}sendUserMessage(e){const t=new h.MessageRequestHandler,{dispatcher:s}=d.Vault.of(this._iid),n=c.AutoResendManager.of(this._iid);return super.sendUserMessage(e).onPending((e=>{n.completeCurrentAndProcessNextAutoResend(e),t._trigger(e)})).onFailed(((e,s)=>{s&&n.completeCurrentAndProcessNextAutoResend(s),t._triggerFailed(e,s)})).onSucceeded((e=>{this.hiddenState===exports.HiddenState.HIDDEN_ALLOW_AUTO_UNHIDE&&(this.hiddenState=exports.HiddenState.UNHIDDEN),n.completeCurrentAndProcessNextAutoResend(e),this._shouldUpdateLastMessageWith(e)&&(this.lastMessage=e);Ie.of(this._iid).handlers.map((e=>{e.onChannelChanged&&e.onChannelChanged(this)})),s.dispatch(new P({channels:[this],source:d.CollectionEventSource.EVENT_MESSAGE_SENT})),t._trigger(e)})),t}updateUserMessage(e,t){const s=Object.create(null,{updateUserMessage:{get:()=>super.updateUserMessage}});return d.__awaiter(this,void 0,void 0,(function*(){const{dispatcher:n}=d.Vault.of(this._iid),i=yield s.updateUserMessage.call(this,e,t);let a=!1;!i.silent&&this._shouldUpdateLastMessageWith(i)&&(this.lastMessage=i,a=!0);let r=!1;if(this.lastPinnedMessage&&this.lastPinnedMessage.messageId===i.messageId&&(this.lastPinnedMessage=i,a=!0,r=!0),a){Ie.of(this._iid).handlers.map((e=>{e.onChannelChanged&&e.onChannelChanged(this)})),n.dispatch(new P({channels:[this],source:r?d.CollectionEventSource.EVENT_PINNED_MESSAGE_UPDATED:d.CollectionEventSource.EVENT_MESSAGE_UPDATED}))}if(r){Ie.of(this._iid).handlers.map((e=>{e.onPinnedMessageUpdated&&e.onPinnedMessageUpdated(this)}))}return n.dispatch(new d.MessageUpdateEventCommand({messages:[i],source:d.CollectionEventSource.EVENT_MESSAGE_UPDATED})),i}))}_autoResendUserMessage(e){const t=new h.MessageRequestHandler,{dispatcher:s}=d.Vault.of(this._iid),n=c.AutoResendManager.of(this._iid);return super._autoResendUserMessage(e).onPending((e=>{n.completeCurrentAndProcessNextAutoResend(e),t._trigger(e)})).onFailed(((e,s)=>{n.completeCurrentAndProcessNextAutoResend(s),t._triggerFailed(e,s)})).onSucceeded((e=>{const i=Ie.of(this._iid);n.completeCurrentAndProcessNextAutoResend(e),this._shouldUpdateLastMessageWith(e)&&(this.lastMessage=e),i.handlers.map((e=>{e.onChannelChanged&&e.onChannelChanged(this)})),s.dispatch(new P({channels:[this],source:d.CollectionEventSource.EVENT_MESSAGE_SENT})),t._trigger(e)})),t}sendFileMessage(e){const t=new h.MessageRequestHandler,{dispatcher:s}=d.Vault.of(this._iid),n=c.AutoResendManager.of(this._iid);return super.sendFileMessage(e).onPending((e=>{n.completeCurrentAndProcessNextAutoResend(e),t._trigger(e)})).onFailed(((e,s)=>{s&&n.completeCurrentAndProcessNextAutoResend(s),t._triggerFailed(e,s)})).onSucceeded((e=>{const i=Ie.of(this._iid);n.completeCurrentAndProcessNextAutoResend(e),this._shouldUpdateLastMessageWith(e)&&(this.lastMessage=e),i.handlers.map((e=>{e.onChannelChanged&&e.onChannelChanged(this)})),s.dispatch(new P({channels:[this],source:d.CollectionEventSource.EVENT_MESSAGE_SENT})),t._trigger(e)})),t}sendMultipleFilesMessage(e){const t=new h.MultipleFilesMessageRequestHandler,{dispatcher:s}=d.Vault.of(this._iid);return super.sendMultipleFilesMessage(e).onPending((e=>{t._trigger(e)})).onFailed(((e,s)=>{t._triggerFailed(e,s)})).onSucceeded((e=>{const n=Ie.of(this._iid);this._shouldUpdateLastMessageWith(e)&&(this.lastMessage=e),n.handlers.map((e=>{e.onChannelChanged&&e.onChannelChanged(this)})),s.dispatch(new P({channels:[this],source:d.CollectionEventSource.EVENT_MESSAGE_SENT})),t._trigger(e)})).onFileUploaded(((e,s,n,i)=>{t._triggerOnFileUploaded(e,s,n,i)})),t}updateFileMessage(e,t){const s=Object.create(null,{updateFileMessage:{get:()=>super.updateFileMessage}});return d.__awaiter(this,void 0,void 0,(function*(){const{dispatcher:n}=d.Vault.of(this._iid),i=yield s.updateFileMessage.call(this,e,t);let a=!1;!i.silent&&this._shouldUpdateLastMessageWith(i)&&(this.lastMessage=i,a=!0);let r=!1;if(this.lastPinnedMessage&&this.lastPinnedMessage.messageId===i.messageId&&(this.lastPinnedMessage=i,a=!0,r=!0),a){Ie.of(this._iid).handlers.map((e=>{e.onChannelChanged&&e.onChannelChanged(this)})),n.dispatch(new P({channels:[this],source:r?d.CollectionEventSource.EVENT_PINNED_MESSAGE_UPDATED:d.CollectionEventSource.EVENT_MESSAGE_UPDATED}))}if(r){Ie.of(this._iid).handlers.map((e=>{e.onPinnedMessageUpdated&&e.onPinnedMessageUpdated(this)}))}return n.dispatch(new d.MessageUpdateEventCommand({messages:[i],source:d.CollectionEventSource.EVENT_MESSAGE_UPDATED})),i}))}_autoResendFileMessage(e){const t=new h.MessageRequestHandler,{dispatcher:s}=d.Vault.of(this._iid),n=c.AutoResendManager.of(this._iid);return super._autoResendFileMessage(e).onPending((e=>{n.completeCurrentAndProcessNextAutoResend(e),t._trigger(e)})).onFailed(((e,s)=>{n.completeCurrentAndProcessNextAutoResend(s),t._triggerFailed(e,s)})).onSucceeded((e=>{const i=Ie.of(this._iid);n.completeCurrentAndProcessNextAutoResend(e),this._shouldUpdateLastMessageWith(e)&&(this.lastMessage=e),i.handlers.map((e=>{e.onChannelChanged&&e.onChannelChanged(this)})),s.dispatch(new P({channels:[this],source:d.CollectionEventSource.EVENT_MESSAGE_SENT})),t._trigger(e)})),t}deleteMessage(e){const t=Object.create(null,{deleteMessage:{get:()=>super.deleteMessage}});return d.__awaiter(this,void 0,void 0,(function*(){if(yield t.deleteMessage.call(this,e),0===e.messageId&&e instanceof h.SendableMessage){const{dispatcher:t}=d.Vault.of(this._iid);t.dispatch(new d.UnsentMessageRemoveEventCommand({reqId:e.reqId,source:d.CollectionEventSource.EVENT_MESSAGE_DELETED}))}}))}hide(e){return d.__awaiter(this,void 0,void 0,(function*(){const t=Object.assign(Object.assign({},he),e);d.unless((e=>d.isTypeOf("boolean",e.hidePreviousMessages,!0)&&d.isTypeOf("boolean",e.allowAutoUnhide,!0))(t)).throw(d.SendbirdError.invalidParameters);const{dispatcher:s,sdkState:n,requestQueue:i}=d.Vault.of(this._iid),a=new ce(Object.assign({channelUrl:this.url,userId:n.userId},t)),r=yield i.send(a),{messageOffsetTimestamp:o}=r.as(ue);return this.hiddenState=t.allowAutoUnhide?exports.HiddenState.HIDDEN_ALLOW_AUTO_UNHIDE:exports.HiddenState.HIDDEN_PREVENT_AUTO_UNHIDE,t.hidePreviousMessages&&this._updateUnreadCount(0,0),o&&(this.messageOffsetTimestamp=o),s.dispatch(new P({channels:[this],source:d.CollectionEventSource.EVENT_CHANNEL_HIDDEN,isWebSocketEventComing:!0})),this}))}unhide(){return d.__awaiter(this,void 0,void 0,(function*(){const{dispatcher:e,requestQueue:t}=d.Vault.of(this._iid),s=new pt({channelUrl:this.url});return yield t.send(s),this.hiddenState=exports.HiddenState.UNHIDDEN,e.dispatch(new P({channels:[this],source:d.CollectionEventSource.EVENT_CHANNEL_UNHIDDEN,isWebSocketEventComing:!0})),this}))}delete(){return d.__awaiter(this,void 0,void 0,(function*(){const{requestQueue:e}=d.Vault.of(this._iid),t=new _t({channelUrl:this.url});yield e.send(t)}))}markAsRead(){return d.__awaiter(this,void 0,void 0,(function*(){const{sdkState:e,dispatcher:t,requestQueue:s}=d.Vault.of(this._iid),n=new Me({channelUrl:this.url}),i=yield s.send(n),{readStatus:a}=i.as(ye);if(this._updateUnreadMemberState(e.userId,a.readAt),this.unreadMessageCount>0||this.unreadMentionCount>0){this._updateUnreadCount(0,0);Ie.of(this._iid).handlers.map((e=>{e.onChannelChanged&&e.onChannelChanged(this)}))}t.dispatch(new P({channels:[this],source:d.CollectionEventSource.EVENT_CHANNEL_READ}))}))}markAsDelivered(){return d.__awaiter(this,void 0,void 0,(function*(){const{sdkState:e,requestQueue:t}=d.Vault.of(this._iid),s=new be({channelUrl:this.url,userId:e.userId});yield t.send(s)}))}startTyping(){return d.__awaiter(this,void 0,void 0,(function*(){const{requestQueue:e,typingIndicatorThrottle:t}=d.Vault.of(this._iid),s=(new Date).getTime();if(s-this._typingStarted>=t){this._typingStarted=s,this._typingEnded=0;const t=new pe({channelUrl:this.url,time:this._typingStarted});e.send(t)}}))}endTyping(){return d.__awaiter(this,void 0,void 0,(function*(){const{requestQueue:e,typingIndicatorThrottle:t}=d.Vault.of(this._iid),s=(new Date).getTime();if(s-this._typingEnded>=t){this._typingStarted=0,this._typingEnded=s;const t=new ge({channelUrl:this.url,time:this._typingStarted});e.send(t)}}))}createScheduledUserMessage(e){e=Object.assign(Object.assign({},h.ScheduledUserMessageCreateParamsDefault),e),d.unless(h.validateScheduledUserMessageCreateParams(e)).throw(d.SendbirdError.invalidParameters);const t=new h.MessageRequestHandler;return this._createScheduledUserMessage(e,t),t}updateScheduledUserMessage(e,t){return d.__awaiter(this,void 0,void 0,(function*(){const s=Object.assign(Object.assign({},ft),t);d.unless((e=>h.validateUserMessageUpdateParams(e)&&d.isTypeOf("number",e.scheduledAt,!0))(s)).throw(d.SendbirdError.invalidParameters);const{requestQueue:n}=d.Vault.of(this._iid),i=new yt(Object.assign({reqId:this._generateRequestId(),scheduledMessageId:e,channelType:this.channelType,channelUrl:this.url},s)),a=yield n.send(i),{message:r}=a.as(h.CreateScheduledUserMessageResponseCommand);return r}))}createScheduledFileMessage(e){e=Object.assign(Object.assign({},h.ScheduledFileMessageCreateParamsDefault),e),d.unless(h.validateScheduledFileMessageCreateParams(e)).throw(d.SendbirdError.invalidParameters);const t=Date.now(),s=this._generateRequestId(),n=new h.MessageRequestHandler;return d.sleep(h.PENDING_MESSAGE_DELAY).then((()=>{const i=this._createPendingScheduledFileMessage(e,s,t);d.runAsCallback((()=>d.__awaiter(this,void 0,void 0,(function*(){return n._trigger(i)}))))})),d.isFile(e.file)?this._uploadFileAndUpdateParams(e).then((()=>this._createScheduledFileMessage(e,n,s,t))):this._createScheduledFileMessage(e,n,s,t),n}updateScheduledFileMessage(e,t){return d.__awaiter(this,void 0,void 0,(function*(){const s=Object.assign(Object.assign({},vt),t);d.unless((e=>h.validateBaseMessageUpdateParams(e)&&d.isTypeOf("number",e.scheduledAt,!0)&&(d.isFile(e.file)||d.isTypeOf("string",e.fileUrl))&&d.isTypeOf("string",e.fileName,!0)&&d.isTypeOf("string",e.mimeType,!0)&&d.isTypeOf("number",e.fileSize,!0)&&(null===e.thumbnailSizes||void 0===e.thumbnailSizes||e.thumbnailSizes.every((e=>d.isTypeOf("object",e)&&e.maxWidth>0&&e.maxHeight>0))))(s)).throw(d.SendbirdError.invalidParameters),d.isFile(s.file)&&(yield this._uploadFileAndUpdateParams(s));const n=new Mt(Object.assign({reqId:this._generateRequestId(),scheduledMessageId:e,channelType:this.channelType,channelUrl:this.url},s)),{requestQueue:i}=d.Vault.of(this._iid),a=yield i.send(n),{message:r}=a.as(St);return r}))}cancelScheduledMessage(e){return d.__awaiter(this,void 0,void 0,(function*(){const t=new At({scheduledMessageId:e,channelType:this.channelType,channelUrl:this.url}),{requestQueue:s}=d.Vault.of(this._iid);yield s.send(t)}))}sendScheduledMessageNow(e){return d.__awaiter(this,void 0,void 0,(function*(){const t=new bt({scheduledMessageId:e,channelType:this.channelType,channelUrl:this.url}),{requestQueue:s}=d.Vault.of(this._iid);yield s.send(t)}))}getMyPushTriggerOption(){return d.__awaiter(this,void 0,void 0,(function*(){const{sdkState:e,requestQueue:t}=d.Vault.of(this._iid),s=new Ut({userId:e.userId,channelUrl:this.url}),n=yield t.send(s),{pushTriggerOption:i}=n.as(It);return this.myPushTriggerOption=i,i}))}setMyPushTriggerOption(e){return d.__awaiter(this,void 0,void 0,(function*(){d.unless(d.isEnumOf(d.PushTriggerOption,e)).throw(d.SendbirdError.invalidParameters);const{dispatcher:t,sdkState:s,requestQueue:n}=d.Vault.of(this._iid),i=new Nt({userId:s.userId,channelUrl:this.url,pushTriggerOption:e}),a=yield n.send(i),{pushTriggerOption:r}=a.as(Tt);return this.myPushTriggerOption=r,t.dispatch(new P({channels:[this],source:d.CollectionEventSource.EVENT_CHANNEL_UPDATED,isWebSocketEventComing:!0})),r}))}setMyCountPreference(e){return d.__awaiter(this,void 0,void 0,(function*(){d.unless(d.isEnumOf(exports.CountPreference,e)).throw(d.SendbirdError.invalidParameters);const{dispatcher:t,sdkState:s,requestQueue:n}=d.Vault.of(this._iid),i=new mt({channelUrl:this.url,userId:s.userId,countPreference:e}),a=yield n.send(i),{countPreference:r}=a.as(gt);return this.myCountPreference=r,this._updateUnreadCount(this.unreadMessageCount,this.unreadMentionCount),t.dispatch(new P({channels:[this],source:d.CollectionEventSource.EVENT_CHANNEL_UPDATED,isWebSocketEventComing:!0})),r}))}resetMyHistory(){return d.__awaiter(this,void 0,void 0,(function*(){const{dispatcher:e,requestQueue:t}=d.Vault.of(this._iid),s=new Ct({channelUrl:this.url}),n=yield t.send(s),{messageOffsetTimestamp:i}=n.as(Et);return this.messageOffsetTimestamp=i,this.lastMessage&&this.lastMessage.createdAt0).throw(d.SendbirdError.invalidParameters);const{requestQueue:t}=d.Vault.of(this._iid),s=new Pt({channelType:this.channelType,channelUrl:this.url,messageId:e});yield t.send(s)}))}unpinMessage(e){return d.__awaiter(this,void 0,void 0,(function*(){d.unless(d.isTypeOf("number",e)&&e>0).throw(d.SendbirdError.invalidParameters);const{requestQueue:t}=d.Vault.of(this._iid),s=new xt({channelType:this.channelType,channelUrl:this.url,messageId:e});yield t.send(s)}))}_uploadFileAndUpdateParams(e){return d.__awaiter(this,void 0,void 0,(function*(){if(d.isFile(e.file)){const{requestQueue:t}=d.Vault.of(this._iid),s=new h.UploadFileRequestCommand({file:e.file,channelUrl:this.url,thumbnailSizes:e.thumbnailSizes,requestId:this._generateRequestId()}),n=yield t.send(s),{url:i,fileSize:a=e.fileSize,thumbnailSizes:r=e.thumbnailSizes,requireAuth:o=!1}=n.as(h.UploadFileResponseCommand);e.fileUrl=i,e.fileSize=a,e.thumbnailSizes=r,e.requireAuth=o}}))}resendMessage(e,t){var s;if(d.unless(e instanceof h.SendableMessage&&!e.scheduledInfo&&e.isResendable).throw(d.SendbirdError.invalidParameters),e.isUserMessage()){const t=null!==(s=e.messageParams)&&void 0!==s?s:h.createUserMessageCreateParamsFromFailedUserMessage(e),n=new h.MessageRequestHandler;return this._sendUserMessage(t,h.SendMessageRequestType.RESEND,e.reqId).onPending((e=>{n._trigger(e)})).onFailed(((e,t)=>{n._triggerFailed(e,t)})).onSucceeded((e=>{this._tryUpdateLastMessageAndCallEvents(this,e),n._trigger(e)})),n}if(e.isFileMessage()){const s=this._validateFailedFileMessageHasFile(e,t);d.unless(s).throw(d.SendbirdError.invalidParameters);const n=h.createFileMessageCreateParamsFromFailedFileMessage(e,t),i=new h.MessageRequestHandler;return this._sendFileMessage(n,h.SendMessageRequestType.RESEND,e.reqId).onPending((e=>{i._trigger(e)})).onFailed(((e,t)=>{i._triggerFailed(e,t)})).onSucceeded((e=>{this._tryUpdateLastMessageAndCallEvents(this,e),i._trigger(e)})),i}if(e.isMultipleFilesMessage()){const t=e.messageParams,s=new h.MultipleFilesMessageRequestHandler;return this._sendMultipleFilesMessage(t,h.SendMessageRequestType.RESEND,e.reqId).onPending((e=>{s._trigger(e)})).onFailed(((e,t)=>{s._triggerFailed(e,t)})).onSucceeded((e=>{this._tryUpdateLastMessageAndCallEvents(this,e),s._trigger(e)})).onFileUploaded(((e,t,n,i)=>{s._triggerOnFileUploaded(e,t,n,i)})),s}}copyMessage(e,t){if(d.unless(e instanceof h.BaseChannel&&t instanceof h.SendableMessage&&t.sendingStatus===d.SendingStatus.SUCCEEDED&&this.url===t.channelUrl&&!t.scheduledInfo).throw(d.SendbirdError.invalidParameters),t.isUserMessage()){d.unless(!t.poll).throw(d.SendbirdError.notSupportedError);const s=h.createUserMessageCreateParams(t),n=new h.MessageRequestHandler;return e._sendUserMessage(s).onPending((e=>{n._trigger(e)})).onFailed(((e,t)=>{n._triggerFailed(e,t)})).onSucceeded((t=>{e.isGroupChannel()&&this._tryUpdateLastMessageAndCallEvents(e,t),n._trigger(t)})),n}if(t.isFileMessage()){const s=h.createFileMessageCreateParams(t),n=new h.MessageRequestHandler;return e._sendFileMessage(s).onPending((e=>{n._trigger(e)})).onFailed(((e,t)=>{n._triggerFailed(e,t)})).onSucceeded((t=>{e.isGroupChannel()&&this._tryUpdateLastMessageAndCallEvents(e,t),n._trigger(t)})),n}if(t.isMultipleFilesMessage()){if(e.isGroupChannel()){const s=h.createMultipleFilesMessageCreateParams(t),n=new h.MultipleFilesMessageRequestHandler;return e._sendMultipleFilesMessage(s,h.SendMessageRequestType.COPY).onPending((e=>{n._trigger(e)})).onFailed(((e,t)=>{n._triggerFailed(e,t)})).onSucceeded((t=>{this._tryUpdateLastMessageAndCallEvents(e,t),n._trigger(t)})).onFileUploaded(((e,t,s,i)=>{n._triggerOnFileUploaded(e,t,s,i)})),n}throw d.SendbirdError.channelTypeNotSupportedError}}}exports.BaseMessageCollection=et,exports.FeedChannelEventContext=$e,exports.FeedChannelRemoveEventCommand=qe,exports.FeedChannelUpdateEventCommand=Ge,exports.GetTotalUnreadMessageCountRequestCommand=W,exports.GetTotalUnreadMessageCountResponseCommand=$,exports.GroupChannel=kt,exports.GroupChannelChangeLogsParamsDefault=v,exports.GroupChannelCountParamsDefault=M,exports.GroupChannelCreateParamsDefault=C,exports.GroupChannelEventContext=We,exports.GroupChannelEventSource=U,exports.GroupChannelFilter=m,exports.GroupChannelListQuery=ve,exports.GroupChannelManager=Ie,exports.Member=_,exports.MemberListQuery=lt,exports.MessageCollection=tt,exports.MessageCollectionInitHandler=Ze,exports.MessageEventContext=Ke,exports.NotificationEventContext=Ye,exports.PinnedMessage=Ot,exports.PinnedMessageListQuery=Lt,exports.ReadAPIRequestCommand=Se,exports.ReadAPIResponseCommand=Ae,exports.ReadEventCommand=ye,exports.ReadStatus=p,exports.Sync=Re,exports.TimeRange=Te,exports.TotalUnreadMessageCountParamsDefault=b,exports.indexOfMessage=Pe,exports.placeOfMessage=Oe,exports.shouldGiveEvent=I,exports.validateGroupChannelChangeLogsParams=f,exports.validateGroupChannelCountParams=S,exports.validateGroupChannelCreateParams=E,exports.validateTotalUnreadMessageCountParams=N;
diff --git a/cjs/lib/__bundle-c301d48f.js b/cjs/lib/__bundle-c301d48f.js
new file mode 100644
index 0000000..0a61954
--- /dev/null
+++ b/cjs/lib/__bundle-c301d48f.js
@@ -0,0 +1 @@
+"use strict";var s=require("./__bundle-5d8ae943.js");class e extends s.User{constructor(s,e){var t;super(s,e),this.isMuted=!1,this.isMuted=null!==(t=e.is_muted)&&void 0!==t&&t}}exports.Participant=e;
diff --git a/cjs/lib/__bundle-dec6de91.js b/cjs/lib/__bundle-dec6de91.js
deleted file mode 100644
index 1e7a96d..0000000
--- a/cjs/lib/__bundle-dec6de91.js
+++ /dev/null
@@ -1 +0,0 @@
-"use strict";var e,t=require("./__bundle-fc8b8d13.js"),n=require("./__bundle-92ec8a78.js"),s=require("./__bundle-f6d4722d.js");exports.ChannelEventCategory=void 0,(e=exports.ChannelEventCategory||(exports.ChannelEventCategory={}))[e.NONE=0]="NONE",e[e.CHANNEL_ENTER=10102]="CHANNEL_ENTER",e[e.CHANNEL_EXIT=10103]="CHANNEL_EXIT",e[e.USER_CHANNEL_MUTE=10201]="USER_CHANNEL_MUTE",e[e.USER_CHANNEL_UNMUTE=10200]="USER_CHANNEL_UNMUTE",e[e.USER_CHANNEL_BAN=10601]="USER_CHANNEL_BAN",e[e.USER_CHANNEL_UNBAN=10600]="USER_CHANNEL_UNBAN",e[e.CHANNEL_FREEZE=10701]="CHANNEL_FREEZE",e[e.CHANNEL_UNFREEZE=10700]="CHANNEL_UNFREEZE",e[e.TYPING_START=10900]="TYPING_START",e[e.TYPING_END=10901]="TYPING_END",e[e.CHANNEL_JOIN=1e4]="CHANNEL_JOIN",e[e.CHANNEL_LEAVE=10001]="CHANNEL_LEAVE",e[e.CHANNEL_OPERATOR_UPDATE=10002]="CHANNEL_OPERATOR_UPDATE",e[e.CHANNEL_INVITE=10020]="CHANNEL_INVITE",e[e.CHANNEL_ACCEPT_INVITE=10021]="CHANNEL_ACCEPT_INVITE",e[e.CHANNEL_DECLINE_INVITE=10022]="CHANNEL_DECLINE_INVITE",e[e.CHANNEL_PROP_CHANGED=11e3]="CHANNEL_PROP_CHANGED",e[e.CHANNEL_DELETED=12e3]="CHANNEL_DELETED",e[e.CHANNEL_META_DATA_CHANGED=11100]="CHANNEL_META_DATA_CHANGED",e[e.CHANNEL_META_COUNTERS_CHANGED=11200]="CHANNEL_META_COUNTERS_CHANGED",e[e.CHANNEL_HIDE=13e3]="CHANNEL_HIDE",e[e.CHANNEL_UNHIDE=13001]="CHANNEL_UNHIDE",e[e.PINNED_MESSAGE_CHANGED=11300]="PINNED_MESSAGE_CHANGED";class o{constructor(e){var t;this.channelUrl=e.channel_url,this.channelType=e.channel_type,this.category=e.cat,this.data=null!==(t=e.data)&&void 0!==t?t:{},this.ts=e.ts}get isGroupChannelEvent(){return this.channelType===t.ChannelType.GROUP}get isOpenChannelEvent(){return this.channelType===t.ChannelType.OPEN}}class a extends t.WebSocketEventCommand{constructor(e,t,n){super(e,"SYEV",n),this.event=new o(n)}}class i{constructor({top:e=Number.MAX_SAFE_INTEGER,bottom:t=0}){this.top=e,this.bottom=t}includes(...e){return e.every((e=>this.top<=e&&e<=this.bottom))}overlap(e){return this.includes(e.top)||this.includes(e.bottom)}intersect(...e){return e.some((e=>this.top<=e&&e<=this.bottom))}extends(...e){this.top=Math.min(this.top,...e),this.bottom=Math.max(this.bottom,...e)}}class r extends t.InstancedObject{get _messageCache(){return n.MessageCache.of(this._iid)}get _unsentMessageCache(){return n.UnsentMessageCache.of(this._iid)}get _messageBroadcast(){return n.MessageBroadcast.of(this._iid)}constructor(e,t){super(e),this._logger=t.logger,this._sdkState=t.sdkState,this._sessionManager=t.sessionManager,this._requestQueue=t.requestQueue,this._dispatcher=t.dispatcher,this._cacheContext=t.cacheContext,this._channelType=t.channelType}subscribeMessageEvent(e,t){this._messageBroadcast.subscribe(e,t)}unsubscribeMessageEvent(e){this._messageBroadcast.unsubscribe(e)}getMessageFromCache(e){var n;return t.__awaiter(this,void 0,void 0,(function*(){return null!==(n=yield this._messageCache.get(e))&&void 0!==n?n:null}))}getExactlyMatchingMessagesForTokenFromCache(e,n,s){return t.__awaiter(this,void 0,void 0,(function*(){return yield this._messageCache.fetch({channelUrl:e,token:n,filter:s,exactMatch:!0})}))}getMessagesFromCache(e,s,o,a,i=n.DEFAULT_MESSAGE_LIMIT,r=!0){return t.__awaiter(this,void 0,void 0,(function*(){return yield this._messageCache.fetch({channelUrl:e,token:s,limit:i,filter:a,backward:"next"===o,inclusive:r})}))}getPollMessagesFromCache(e,n,s,o){return t.__awaiter(this,void 0,void 0,(function*(){return yield this._messageCache.fetch({channelUrl:e,token:n,limit:o,filter:s,backward:!1,isPollOnly:!0})}))}getCachedMessageCountBetween(e,n,s,o){return t.__awaiter(this,void 0,void 0,(function*(){return yield this._messageCache.countBetween(e,n,new i({top:s,bottom:o}))}))}getUnsentMessagesFromCache(e,n){return t.__awaiter(this,void 0,void 0,(function*(){return yield this._unsentMessageCache.fetch({channelUrl:e,filter:n})}))}removeFailedMessageFromCache(e){return t.__awaiter(this,void 0,void 0,(function*(){yield this._unsentMessageCache.remove([e])}))}}class h extends t.WebSocketEventCommand{constructor(e,s,o){var a,i,r,h;super(e,"ADMM",o),this.message=new n.AdminMessage(e,o);const{sdkState:d}=t.Vault.of(e);this.isMentioned=t.checkIfMentioned(this.message.mentionType,null!==(r=null!==(a=this.message.mentionedUserIds)&&void 0!==a?a:null===(i=this.message.mentionedUsers)||void 0===i?void 0:i.map((e=>e.userId)))&&void 0!==r?r:[],d.userId),this.forceUpdateLastMessage=null!==(h=o.force_update_last_message)&&void 0!==h&&h}}class d extends t.WebSocketEventCommand{constructor(e,s,o){var a,i,r,h,d;super(e,"AEDI",o),this.message=new n.AdminMessage(e,o);const{sdkState:E}=t.Vault.of(e);this.mentionCountChange=t.calculateMentionCountChange({mentionType:null===(a=o.old_values)||void 0===a?void 0:a.mention_type,mentionedUserIds:null!==(r=null===(i=o.old_values)||void 0===i?void 0:i.mentioned_user_ids)&&void 0!==r?r:[]},t.undefineNullProps({mentionType:this.message.mentionType,mentionedUserIds:null!==(h=this.message.mentionedUserIds)&&void 0!==h?h:null===(d=this.message.mentionedUsers)||void 0===d?void 0:d.map((e=>e.userId))}),E.userId)}}class E extends t.WebSocketEventCommand{constructor(e,t,s){super(e,"MRCT",s),this.channelUrl=s.channel_url,this.channelType=s.channel_type,this.event=new n.ReactionEvent(s)}}class c extends t.WebSocketEventCommand{constructor(e,t,s){super(e,"MTHD",s),this.event=new n.ThreadInfoUpdateEvent(e,s)}}class l extends t.WebSocketEventCommand{constructor(e,t,n){super(e,"MCNT",n),this.groupChannelMemberCounts=n.group_channels.map((e=>({channelUrl:e.channel_url,memberCount:e.member_count,joinedMemberCount:e.joined_member_count,updatedAt:e.ts}))),this.openChannelMemberCounts=n.open_channels.map((e=>({channelUrl:e.channel_url,participantCount:e.participant_count,updatedAt:e.ts})))}}class _ extends t.WebSocketEventCommand{constructor(e,n,o){super(e,"PEDI",o),this.event=new s.PollUpdateEvent(e,o),this.status=t.parsePollStatusPayload(o.poll.status)||o.poll.status,this.channelUrl=o.channel_url,this.channelType=o.channel_type}}exports.AdminMessageEventCommand=h,exports.BaseChannelHandlerParams=class{constructor(){this.onUserMuted=t.noop,this.onUserUnmuted=t.noop,this.onUserBanned=t.noop,this.onUserUnbanned=t.noop,this.onChannelChanged=t.noop,this.onChannelDeleted=t.noop,this.onChannelFrozen=t.noop,this.onChannelUnfrozen=t.noop,this.onOperatorUpdated=t.noop,this.onChannelMemberCountChanged=t.noop,this.onMetaDataCreated=t.noop,this.onMetaDataUpdated=t.noop,this.onMetaDataDeleted=t.noop,this.onMetaCounterCreated=t.noop,this.onMetaCounterUpdated=t.noop,this.onMetaCounterDeleted=t.noop,this.onMessageReceived=t.noop,this.onMessageUpdated=t.noop,this.onMessageDeleted=t.noop,this.onMentionReceived=t.noop,this.onReactionUpdated=t.noop,this.onThreadInfoUpdated=t.noop}},exports.BaseChannelManager=r,exports.ChannelEventCommand=a,exports.MemberCountUpdateEventCommand=l,exports.OperatorUpdateEventCommand=class extends a{constructor(e,n,s){super(e,n,s);const{operators:o=[]}=s.data;this.operators=o.map((e=>new t.User(this._iid,e)))}},exports.PollUpdateEventCommand=_,exports.ReactionEventCommand=E,exports.ThreadInfoUpdateEventCommand=c,exports.TimeRange=i,exports.UpdateAdminMessageEventCommand=d;
diff --git a/cjs/message.js b/cjs/message.js
index d622521..f87319f 100644
--- a/cjs/message.js
+++ b/cjs/message.js
@@ -1 +1 @@
-"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("./lib/__bundle-fc8b8d13.js"),t=require("./lib/__bundle-92ec8a78.js");const s={channelUrl:"",scheduledMessageId:0};class r extends e.Module{constructor(){super(...arguments),this.name="message"}init(e,{sdkState:s,dispatcher:r,sessionManager:a,requestQueue:n,logger:i,onlineDetector:o,cacheContext:u}){super.init(e,{sdkState:s,dispatcher:r,sessionManager:a,requestQueue:n,logger:i,onlineDetector:o,cacheContext:u}),this._manager=new t.MessageManager(e,{sdkState:s,dispatcher:r,requestQueue:n,onlineDetector:o,cacheContext:u})}buildMessageFromSerializedData(e){return this._manager.buildMessageFromSerializedData(e)}buildSenderFromSerializedData(e){return this._manager.buildSenderFromSerializedData(e)}getMessage(s){return e.__awaiter(this,void 0,void 0,(function*(){const r=Object.assign(Object.assign({},t.MessageRetrievalParamsDefault),s);return e.unless(t.validateMessageRetrievalParams(r)).throw(e.SendbirdError.invalidParameters),this._manager.getMessage(r)}))}getScheduledMessage(t){return e.__awaiter(this,void 0,void 0,(function*(){const r=Object.assign(Object.assign({},s),t);return e.unless((t=>e.isTypeOf("string",t.channelUrl)&&""!==t.channelUrl&&e.isTypeOf("number",t.scheduledMessageId)&&t.scheduledMessageId>0)(r)).throw(e.SendbirdError.invalidParameters),this._manager.getScheduledMessage(r)}))}}Object.defineProperty(exports,"MentionType",{enumerable:!0,get:function(){return e.MentionType}}),Object.defineProperty(exports,"MessageType",{enumerable:!0,get:function(){return e.MessageType}}),Object.defineProperty(exports,"MessageTypeFilter",{enumerable:!0,get:function(){return e.MessageTypeFilter}}),Object.defineProperty(exports,"PushNotificationDeliveryOption",{enumerable:!0,get:function(){return e.PushNotificationDeliveryOption}}),Object.defineProperty(exports,"ReplyType",{enumerable:!0,get:function(){return e.ReplyType}}),Object.defineProperty(exports,"SendingStatus",{enumerable:!0,get:function(){return e.SendingStatus}}),exports.AdminMessage=t.AdminMessage,exports.AppleCriticalAlertOptions=t.AppleCriticalAlertOptions,exports.BaseMessage=t.BaseMessage,exports.FileMessage=t.FileMessage,exports.MessageMetaArray=t.MessageMetaArray,exports.MessageRequestHandler=t.MessageRequestHandler,Object.defineProperty(exports,"MessageSearchOrder",{enumerable:!0,get:function(){return t.MessageSearchOrder}}),exports.MessageSearchQuery=t.MessageSearchQuery,exports.MultipleFilesMessage=t.MultipleFilesMessage,exports.MultipleFilesMessageRequestHandler=t.MultipleFilesMessageRequestHandler,exports.OGImage=t.OGImage,exports.OGMetaData=t.OGMetaData,exports.PreviousMessageListQuery=t.PreviousMessageListQuery,exports.Reaction=t.Reaction,exports.ReactionEvent=t.ReactionEvent,Object.defineProperty(exports,"ReactionEventOperation",{enumerable:!0,get:function(){return t.ReactionEventOperation}}),exports.Sender=t.Sender,exports.ThreadInfo=t.ThreadInfo,exports.ThreadInfoUpdateEvent=t.ThreadInfoUpdateEvent,exports.Thumbnail=t.Thumbnail,exports.UploadedFileInfo=t.UploadedFileInfo,exports.UserMessage=t.UserMessage,exports.MessageModule=r;
+"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("./lib/__bundle-5d8ae943.js"),t=require("./lib/__bundle-0bbec988.js");const s={channelUrl:"",scheduledMessageId:0};class r extends e.Module{constructor(){super(...arguments),this.name="message"}init(e,{sdkState:s,dispatcher:r,sessionManager:a,requestQueue:n,logger:i,onlineDetector:o,cacheContext:l}){super.init(e,{sdkState:s,dispatcher:r,sessionManager:a,requestQueue:n,logger:i,onlineDetector:o,cacheContext:l}),this._manager=new t.MessageManager(e,{sdkState:s,dispatcher:r,requestQueue:n,onlineDetector:o,cacheContext:l})}buildMessageFromSerializedData(e){return this._manager.buildMessageFromSerializedData(e)}buildSenderFromSerializedData(e){return this._manager.buildSenderFromSerializedData(e)}getMessage(s){return e.__awaiter(this,void 0,void 0,(function*(){const r=Object.assign(Object.assign({},t.MessageRetrievalParamsDefault),s);e.unless(t.validateMessageRetrievalParams(r)).throw(e.SendbirdError.invalidParameters);const a=yield this._manager.getMessage(r);if(a instanceof t.BaseMessage||a instanceof t.NotificationMessage||null===a)return a;throw"Unknown message type is given."}))}getScheduledMessage(t){return e.__awaiter(this,void 0,void 0,(function*(){const r=Object.assign(Object.assign({},s),t);return e.unless((t=>e.isTypeOf("string",t.channelUrl)&&""!==t.channelUrl&&e.isTypeOf("number",t.scheduledMessageId)&&t.scheduledMessageId>0)(r)).throw(e.SendbirdError.invalidParameters),this._manager.getScheduledMessage(r)}))}}Object.defineProperty(exports,"MentionType",{enumerable:!0,get:function(){return e.MentionType}}),Object.defineProperty(exports,"MessageType",{enumerable:!0,get:function(){return e.MessageType}}),Object.defineProperty(exports,"MessageTypeFilter",{enumerable:!0,get:function(){return e.MessageTypeFilter}}),Object.defineProperty(exports,"PushNotificationDeliveryOption",{enumerable:!0,get:function(){return e.PushNotificationDeliveryOption}}),Object.defineProperty(exports,"ReplyType",{enumerable:!0,get:function(){return e.ReplyType}}),Object.defineProperty(exports,"SendingStatus",{enumerable:!0,get:function(){return e.SendingStatus}}),exports.AdminMessage=t.AdminMessage,exports.AppleCriticalAlertOptions=t.AppleCriticalAlertOptions,exports.BaseMessage=t.BaseMessage,exports.FileMessage=t.FileMessage,exports.MessageMetaArray=t.MessageMetaArray,exports.MessageRequestHandler=t.MessageRequestHandler,Object.defineProperty(exports,"MessageSearchOrder",{enumerable:!0,get:function(){return t.MessageSearchOrder}}),exports.MessageSearchQuery=t.MessageSearchQuery,exports.MultipleFilesMessage=t.MultipleFilesMessage,exports.MultipleFilesMessageRequestHandler=t.MultipleFilesMessageRequestHandler,exports.OGImage=t.OGImage,exports.OGMetaData=t.OGMetaData,exports.PreviousMessageListQuery=t.PreviousMessageListQuery,exports.Reaction=t.Reaction,exports.ReactionEvent=t.ReactionEvent,Object.defineProperty(exports,"ReactionEventOperation",{enumerable:!0,get:function(){return t.ReactionEventOperation}}),exports.Sender=t.Sender,exports.ThreadInfo=t.ThreadInfo,exports.ThreadInfoUpdateEvent=t.ThreadInfoUpdateEvent,exports.Thumbnail=t.Thumbnail,exports.UploadedFileInfo=t.UploadedFileInfo,exports.UserMessage=t.UserMessage,exports.MessageModule=r;
diff --git a/cjs/openChannel.js b/cjs/openChannel.js
index 831c6a1..b28c9ad 100644
--- a/cjs/openChannel.js
+++ b/cjs/openChannel.js
@@ -1 +1 @@
-"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("./lib/__bundle-fc8b8d13.js"),n=require("./lib/__bundle-92ec8a78.js"),t=require("./lib/__bundle-dec6de91.js"),a=require("./lib/__bundle-0acc0d7b.js");require("./lib/__bundle-f6d4722d.js");class s extends e.InstancedObject{constructor(){super(...arguments),this._channels=new Map,this._enteredChannelUrls=[]}get enteredChannels(){return this._enteredChannelUrls.map((e=>this._channels.get(e))).filter((e=>!!e))}isEnteredChannel(e){return this._enteredChannelUrls.includes(e)}enter(e){this._enteredChannelUrls.indexOf(e)<0&&this._enteredChannelUrls.push(e)}exit(e){const n=this._enteredChannelUrls.indexOf(e);n>=0&&this._enteredChannelUrls.splice(n,1)}exitAll(){this._enteredChannelUrls=[]}get(n){return e.__awaiter(this,void 0,void 0,(function*(){return this._channels.get(n)}))}upsert(n){return e.__awaiter(this,void 0,void 0,(function*(){const e=[];return n.forEach((n=>{if(this._channels.has(n.url)){const t=this._channels.get(n.url);Object.assign(t,n),e.push(t)}else this._channels.set(n.url,n),e.push(n)})),e}))}remove(n){return e.__awaiter(this,void 0,void 0,(function*(){this._channels.delete(n),this.exit(n)}))}clear(){return e.__awaiter(this,void 0,void 0,(function*(){this._channels.clear(),this._enteredChannelUrls=[]}))}}const r={channelUrl:void 0,name:void 0,coverUrlOrImage:void 0,data:void 0,customType:void 0,operatorUserIds:void 0,isEphemeral:void 0};class i extends e.APIRequestCommand{constructor({channelUrl:n,isInternalCall:t}){super(),this.method=e.APIRequestMethod.GET,this.path=`${t?e.API_PATH_OPEN_CHANNELS_INTERNAL:e.API_PATH_OPEN_CHANNELS}/${encodeURIComponent(n)}`}}class o extends e.APIResponseCommand{constructor(e,n){super(e,n),this.channel=new U(e,n)}}class l extends e.APIRequestCommand{constructor(n){const{channelUrl:t,coverUrlOrImage:a,name:s,data:r,customType:i,operatorUserIds:o,isEphemeral:l}=n;super(),this.method=e.APIRequestMethod.POST,this.path=e.API_PATH_OPEN_CHANNELS,this.params=e.deundefined(e.undefineNullProps({channel_url:t,cover_url:e.isTypeOf("string",a)?a:null,cover_file:e.isFile(a)?a:null,name:s,data:r,custom_type:i,operators:o,is_ephemeral:l}))}}class h extends e.WebSocketRequestCommand{constructor({channelUrl:e}){super({code:"ENTR",payload:{channel_url:e},ackRequired:!0})}}class d extends t.ChannelEventCommand{constructor(n,t,a){var s,r;super(n,"SYEV",a),a.data&&(this.participantCount=null!==(s=a.data.participant_count)&&void 0!==s?s:0,this.user=new e.User(n,a.data),this.ts=null!==(r=a.data.edge_ts)&&void 0!==r?r:0)}}class c extends e.WebSocketRequestCommand{constructor({channelUrl:e}){super({code:"EXIT",payload:{channel_url:e},ackRequired:!0})}}class u extends t.ChannelEventCommand{constructor(n,t,a){var s,r;super(n,"EXIT",a),a.data&&(this.participantCount=null!==(s=a.data.participant_count)&&void 0!==s?s:0,this.user=new e.User(n,a.data),this.ts=null!==(r=a.data.edge_ts)&&void 0!==r?r:0)}}const C={};class p extends t.BaseChannelManager{constructor(n,t){super(n,Object.assign(Object.assign({},t),{channelType:e.ChannelType.OPEN})),this.subscribeChannelEvent=e.noop,this.unsubscribeChannelEvent=e.noop,this.refreshChannel=()=>e.__awaiter(this,void 0,void 0,(function*(){return e.noop()})),this._openChannelCache=new s(n),this._openChannelHandlers=new Map,this._dispatcher.on((n=>{if(n instanceof e.WebSocketEventCommand)this._handleEvent(n);else if(n instanceof e.ConnectionStateChangeCommand&&n.stateType===e.ConnectionStateType.CONNECTED){const{enteredChannels:e}=this._openChannelCache;for(const n of e)n.enter()}})),C[n]||(C[n]=this)}static of(e){return C[e]}buildOpenChannelFromSerializedData(n){const t=e.deserialize(n);return new U(this._iid,U.payloadify(t))}getChannelFromCache(n){var t;return e.__awaiter(this,void 0,void 0,(function*(){return null!==(t=yield this._openChannelCache.get(n))&&void 0!==t?t:null}))}upsertChannelsToCache(n){return e.__awaiter(this,void 0,void 0,(function*(){return yield this._openChannelCache.upsert(n)}))}removeChannelsFromCache(n){return e.__awaiter(this,void 0,void 0,(function*(){for(const e of n)yield this._openChannelCache.remove(e)}))}setEnteredToCache(e){this._openChannelCache.enter(e.url)}setExitedToCache(e){this._openChannelCache.exit(e.url)}_handleEvent(a){return e.__awaiter(this,void 0,void 0,(function*(){try{switch(a.code){case"MESG":case"FILE":case"ADMM":case"BRDM":{let s=null;if("MESG"===a.code?s=a.as(n.UserMessageEventCommand):"FILE"===a.code?s=a.as(n.FileMessageEventCommand):"ADMM"!==a.code&&"BRDM"!=a.code||(s=a.as(t.AdminMessageEventCommand)),s){const{message:n,isMentioned:t}=s;if(n.channelType===e.ChannelType.OPEN){const a=yield this.getChannel(n.channelUrl,!0);e.runAsCallback((()=>e.__awaiter(this,void 0,void 0,(function*(){for(const e of this._openChannelHandlers.values())this._openChannelCache.isEnteredChannel(a.url)&&(e.onMessageReceived&&e.onMessageReceived(a,n),t&&e.onMentionReceived&&e.onMentionReceived(a,n))}))))}}break}case"MEDI":case"FEDI":case"AEDI":{let s=null;if("MEDI"===a.code?s=a.as(n.UpdateUserMessageEventCommand):"FEDI"===a.code?s=a.as(n.UpdateFileMessageEventCommand):"AEDI"===a.code&&(s=a.as(t.UpdateAdminMessageEventCommand)),s){const{message:n,mentionCountChange:t}=s;if(n.channelType===e.ChannelType.OPEN){const a=yield this.getChannel(n.channelUrl,!0);e.runAsCallback((()=>e.__awaiter(this,void 0,void 0,(function*(){for(const e of this._openChannelHandlers.values())this._openChannelCache.isEnteredChannel(a.url)&&(e.onMessageUpdated&&e.onMessageUpdated(a,n),t>0&&e.onMentionReceived&&e.onMentionReceived(a,n))}))))}}break}case"DELM":{const{channelUrl:t,channelType:s,messageId:r}=a.as(n.DeleteMessageEventCommand);if(s===e.ChannelType.OPEN){const n=yield this.getChannel(t,!0);e.runAsCallback((()=>e.__awaiter(this,void 0,void 0,(function*(){for(const e of this._openChannelHandlers.values())this._openChannelCache.isEnteredChannel(n.url)&&e.onMessageDeleted&&e.onMessageDeleted(n,r)}))))}break}case"MRCT":{const{channelUrl:n,channelType:s,event:r}=a.as(t.ReactionEventCommand);if(s===e.ChannelType.OPEN){const t=yield this.getChannel(n,!0);e.runAsCallback((()=>e.__awaiter(this,void 0,void 0,(function*(){for(const e of this._openChannelHandlers.values())this._openChannelCache.isEnteredChannel(t.url)&&e.onReactionUpdated&&e.onReactionUpdated(t,r)}))))}break}case"MTHD":{const{event:n}=a.as(t.ThreadInfoUpdateEventCommand);if(n.channelType===e.ChannelType.OPEN){const t=yield this.getChannel(n.channelUrl,!0);e.runAsCallback((()=>e.__awaiter(this,void 0,void 0,(function*(){for(const e of this._openChannelHandlers.values())this._openChannelCache.isEnteredChannel(t.url)&&e.onThreadInfoUpdated&&e.onThreadInfoUpdated(t,n)}))))}break}case"MCNT":{const{openChannelMemberCounts:n}=a.as(t.MemberCountUpdateEventCommand),s=[];for(const e of n){const{channelUrl:n,participantCount:t,updatedAt:a}=e,r=yield this.getChannelFromCache(n);r&&r._updateParticipantCount(t,a)&&s.push(r)}if(s.length>0){const n=yield this.upsertChannelsToCache(s);e.runAsCallback((()=>e.__awaiter(this,void 0,void 0,(function*(){for(const e of this._openChannelHandlers.values())e.onChannelMemberCountChanged&&e.onChannelMemberCountChanged(n)}))))}break}case"PEDI":{const{event:n,status:s,channelUrl:r,channelType:i}=a.as(t.PollUpdateEventCommand);if(r&&i===e.ChannelType.OPEN){const t=yield this.getChannel(r,!0);this._dispatcher.dispatch(new e.PollUpdateInternalEventCommand({event:n,source:e.CollectionEventSource.EVENT_POLL_UPDATED})),s===e.POLL_REMOVED_STATUS?e.runAsCallback((()=>e.__awaiter(this,void 0,void 0,(function*(){for(const e of this._openChannelHandlers.values())e.onPollDeleted&&e.onPollDeleted(t,n.pollId)})))):e.runAsCallback((()=>e.__awaiter(this,void 0,void 0,(function*(){for(const e of this._openChannelHandlers.values())e.onPollUpdated&&e.onPollUpdated(t,n)}))))}break}case"VOTE":{const{event:t,channelUrl:s,channelType:r}=a.as(n.PollVoteEventCommand);if(s&&r===e.ChannelType.OPEN){const n=yield this.getChannel(s,!0);this._dispatcher.dispatch(new e.PollVoteInternalEventCommand({event:t,source:e.CollectionEventSource.EVENT_POLL_VOTED})),e.runAsCallback((()=>e.__awaiter(this,void 0,void 0,(function*(){for(const e of this._openChannelHandlers.values())e.onPollVoted&&e.onPollVoted(n,t)}))))}break}case"SYEV":{const{event:s}=a.as(t.ChannelEventCommand);if(s.isOpenChannelEvent)switch(s.category){case t.ChannelEventCategory.CHANNEL_ENTER:{const n=yield this.getChannel(s.channelUrl,!0),{participantCount:t,user:r}=a.as(d),i=n._updateParticipantCount(t,s.ts);e.runAsCallback((()=>e.__awaiter(this,void 0,void 0,(function*(){this._openChannelHandlers.forEach((e=>{e.onUserEntered&&e.onUserEntered(n,r),i&&e.onChannelParticipantCountChanged&&e.onChannelParticipantCountChanged(n)}))}))));break}case t.ChannelEventCategory.CHANNEL_EXIT:{const n=yield this.getChannel(s.channelUrl,!0),{participantCount:t,user:r}=a.as(u),i=n._updateParticipantCount(t,s.ts);e.runAsCallback((()=>e.__awaiter(this,void 0,void 0,(function*(){this._openChannelHandlers.forEach((e=>{e.onUserExited&&e.onUserExited(n,r),i&&e.onChannelParticipantCountChanged&&e.onChannelParticipantCountChanged(n)}))}))));break}case t.ChannelEventCategory.CHANNEL_OPERATOR_UPDATE:{const n=yield this.getChannel(s.channelUrl,!0),{operators:r}=a.as(t.OperatorUpdateEventCommand);n.operators=r,this.upsertChannelsToCache([n]),e.runAsCallback((()=>e.__awaiter(this,void 0,void 0,(function*(){this._openChannelHandlers.forEach((e=>{e.onOperatorUpdated&&e.onOperatorUpdated(n,r)}))}))));break}case t.ChannelEventCategory.USER_CHANNEL_MUTE:case t.ChannelEventCategory.USER_CHANNEL_UNMUTE:{const r=yield this.getChannel(s.channelUrl,!0),i=s.category===t.ChannelEventCategory.USER_CHANNEL_MUTE,{user:o}=a.as(i?n.MuteUserEventCommand:n.UnmuteUserEventCommand);e.runAsCallback((()=>e.__awaiter(this,void 0,void 0,(function*(){this._openChannelHandlers.forEach((e=>{i?e.onUserMuted&&e.onUserMuted(r,o):e.onUserUnmuted&&e.onUserUnmuted(r,o)}))}))));break}case t.ChannelEventCategory.USER_CHANNEL_BAN:case t.ChannelEventCategory.USER_CHANNEL_UNBAN:{const r=yield this.getChannel(s.channelUrl,!0),i=s.category===t.ChannelEventCategory.USER_CHANNEL_BAN,{user:o}=a.as(i?n.BanUserEventCommand:n.UnbanUserEventCommand);e.runAsCallback((()=>e.__awaiter(this,void 0,void 0,(function*(){this._openChannelHandlers.forEach((e=>{i?e.onUserBanned&&e.onUserBanned(r,o):e.onUserUnbanned&&e.onUserUnbanned(r,o)}))}))));break}case t.ChannelEventCategory.CHANNEL_FREEZE:case t.ChannelEventCategory.CHANNEL_UNFREEZE:{const t=yield this.getChannel(s.channelUrl,!0),{freeze:r}=a.as(n.FreezeEventCommand);t.isFrozen=r,this.upsertChannelsToCache([t]),e.runAsCallback((()=>e.__awaiter(this,void 0,void 0,(function*(){this._openChannelHandlers.forEach((e=>{r?e.onChannelFrozen&&e.onChannelFrozen(t):e.onChannelUnfrozen&&e.onChannelUnfrozen(t)}))}))));break}case t.ChannelEventCategory.CHANNEL_DELETED:{const n=yield this.getChannel(s.channelUrl,!0);yield this.removeChannelsFromCache([n.url]),e.runAsCallback((()=>e.__awaiter(this,void 0,void 0,(function*(){this._openChannelHandlers.forEach((e=>{e.onChannelDeleted&&e.onChannelDeleted(n.url,n.channelType)}))}))));break}case t.ChannelEventCategory.CHANNEL_PROP_CHANGED:{const n=yield this.getChannelWithoutCache(s.channelUrl,!0);e.runAsCallback((()=>e.__awaiter(this,void 0,void 0,(function*(){this._openChannelHandlers.forEach((e=>{e.onChannelChanged&&e.onChannelChanged(n)}))}))));break}case t.ChannelEventCategory.CHANNEL_META_DATA_CHANGED:{const t=yield this.getChannel(s.channelUrl,!0),{created:r,updated:i,deleted:o}=a.as(n.UpdateMetaDataEventCommand);r&&t._upsertCachedMetaData(r,s.ts),i&&t._upsertCachedMetaData(i,s.ts),o&&t._removeFromCachedMetaData(o,s.ts),e.runAsCallback((()=>e.__awaiter(this,void 0,void 0,(function*(){this._openChannelHandlers.forEach((e=>{r&&e.onMetaDataCreated&&e.onMetaDataCreated(t,r),i&&e.onMetaDataUpdated&&e.onMetaDataUpdated(t,i),o&&e.onMetaDataDeleted&&e.onMetaDataDeleted(t,o)}))}))));break}case t.ChannelEventCategory.CHANNEL_META_COUNTERS_CHANGED:{const t=yield this.getChannel(s.channelUrl,!0),{created:r,updated:i,deleted:o}=a.as(n.UpdateMetaCounterEventCommand);e.runAsCallback((()=>e.__awaiter(this,void 0,void 0,(function*(){this._openChannelHandlers.forEach((e=>{r&&e.onMetaCounterCreated&&e.onMetaCounterCreated(t,r),i&&e.onMetaCounterUpdated&&e.onMetaCounterUpdated(t,i),o&&e.onMetaCounterDeleted&&e.onMetaCounterDeleted(t,o)}))}))));break}}break}}}catch(n){if(e.isThrowingOutside(n))throw n}}))}addHandler(e,n){this._openChannelHandlers.set(e,n)}removeHandler(e){this._openChannelHandlers.delete(e)}clearHandler(){this._openChannelHandlers.clear()}getChannel(n,t=!1){return e.__awaiter(this,void 0,void 0,(function*(){e.unless(e.isTypeOf("string",n)).throw(e.SendbirdError.invalidParameters);try{const e=yield this.getChannelFromCache(n);if(e)return e}catch(e){}return yield this.getChannelWithoutCache(n)}))}getChannelWithoutCache(n,t=!1){return e.__awaiter(this,void 0,void 0,(function*(){e.unless(e.isTypeOf("string",n)).throw(e.SendbirdError.invalidParameters);const a=new i({channelUrl:n,isInternalCall:t}),s=yield this._requestQueue.send(a),{channel:r}=s.as(o);return(yield this.upsertChannelsToCache([r]))[0]}))}createChannel(n){return e.__awaiter(this,void 0,void 0,(function*(){const t=Object.assign(Object.assign({},r),n);e.unless((n=>e.isArrayOf("string",n.operatorUserIds,!0)&&(e.isTypeOf("string",n.coverUrlOrImage,!0)||e.isFile(n.coverUrlOrImage,!0))&&e.isTypeOf("string",n.name,!0)&&e.isTypeOf("string",n.data,!0)&&e.isTypeOf("string",n.customType,!0)&&(e.isTypeOf("string",n.channelUrl)&&/^\w+$/.test(n.channelUrl)||null===n.channelUrl||void 0===n.channelUrl)&&e.isTypeOf("boolean",n.isEphemeral,!0))(t)).throw(e.SendbirdError.invalidParameters);const a=new l(t),s=yield this._requestQueue.send(a),{channel:i}=s.as(o);return this.upsertChannelsToCache([i]),i}))}}const _={name:void 0,coverUrlOrImage:void 0,data:void 0,customType:void 0,operatorUserIds:void 0};class v extends e.APIRequestCommand{constructor(n){const{channelUrl:t,token:a,limit:s}=n;super(),this.method=e.APIRequestMethod.GET,this.path=`${e.API_PATH_OPEN_CHANNELS}/${encodeURIComponent(t)}/participants`,this.params={token:a,limit:s}}}class m extends e.APIResponseCommand{constructor(e,n){super(e,n),this.participants=[];const{next:t,participants:s}=n;this.token=t,this.participants=s.map((n=>new a.Participant(e,n)))}}class E extends e.ChannelDataListQuery{constructor(n,t,a){super(n,t,e.ChannelType.OPEN,a)}_validate(){return super._validate()}next(){return e.__awaiter(this,void 0,void 0,(function*(){if(this._validate()){if(this._isLoading)throw e.SendbirdError.queryInProgress;if(this._hasNext){this._isLoading=!0;const{requestQueue:n}=e.Vault.of(this._iid),t=new v(Object.assign(Object.assign({},this),{token:this._token})),a=yield n.send(t),{participants:s,token:r}=a.as(m);return this._token=r,this._hasNext=!!r,this._isLoading=!1,s}return[]}throw e.SendbirdError.invalidParameters}))}}class f extends e.APIRequestCommand{constructor(n){const{channelUrl:t,coverUrlOrImage:a,name:s,data:r,customType:i,operatorUserIds:o}=n;super(),this.method=e.APIRequestMethod.PUT,this.path=`${e.API_PATH_OPEN_CHANNELS}/${encodeURIComponent(t)}`,this.params=e.deundefined(e.undefineNullProps({cover_url:e.isTypeOf("string",a)?a:null,cover_file:e.isFile(a)?a:null,name:s,data:r,custom_type:i,operators:o}))}}class g extends e.APIResponseCommand{constructor(e,n){super(e,n),this.channel=new U(e,n)}}class y extends e.APIRequestCommand{constructor(n){const{channelUrl:t}=n;super(),this.method=e.APIRequestMethod.DELETE,this.path=`${e.API_PATH_OPEN_CHANNELS}/${encodeURIComponent(t)}`}}class U extends n.BaseChannel{constructor(n,t){var a;super(n,t),this._lastParticipantCountUpdated=0,this.participantCount=0,this.operators=[],this.channelType=e.ChannelType.OPEN,this.participantCount=null!==(a=t.participant_count)&&void 0!==a?a:0,this.operators=Array.isArray(t.operators)?t.operators.map((t=>new e.User(n,t))):[]}static payloadify(t){return e.deundefined(e.undefineNullProps(Object.assign(Object.assign({},n.BaseChannel.payloadify(t)),{participant_count:t.participantCount,operators:t.operators.map((n=>e.User.payloadify(n)))})))}serialize(){return e.serialize(this)}isOperator(n){return n instanceof e.User?this.isOperator(n.userId):this.operators.some((e=>e.userId===n))}_updateParticipantCount(e,n){return n>this._lastParticipantCountUpdated&&(this.participantCount=e,this._lastParticipantCountUpdated=n,!0)}createParticipantListQuery(e){return new E(this._iid,this.url,e)}refresh(){return e.__awaiter(this,void 0,void 0,(function*(){const e=p.of(this._iid);return yield e.getChannelWithoutCache(this.url)}))}enter(){return e.__awaiter(this,void 0,void 0,(function*(){const{requestQueue:n}=e.Vault.of(this._iid),t=new h({channelUrl:this.url}),a=yield n.send(t),{participantCount:s,ts:r}=a.as(d);this._updateParticipantCount(s,r);p.of(this._iid).setEnteredToCache(this)}))}exit(){return e.__awaiter(this,void 0,void 0,(function*(){const{requestQueue:t}=e.Vault.of(this._iid),a=new c({channelUrl:this.url}),s=yield t.send(a),{participantCount:r,ts:i}=s.as(u);this._updateParticipantCount(r,i);p.of(this._iid).setExitedToCache(this);n.MessageManager.of(this._iid).fileMessageQueue.cancel(this)}))}updateChannel(n){return e.__awaiter(this,void 0,void 0,(function*(){const t=Object.assign(Object.assign({},_),n);e.unless((n=>e.isArrayOf("string",n.operatorUserIds,!0)&&(e.isTypeOf("string",n.coverUrlOrImage)||e.isFile(n.coverUrlOrImage)||null===n.coverUrlOrImage)&&e.isTypeOf("string",n.name,!0)&&e.isTypeOf("string",n.data,!0)&&e.isTypeOf("string",n.customType,!0))(t)).throw(e.SendbirdError.invalidParameters);const{requestQueue:a}=e.Vault.of(this._iid),s=new f(Object.assign({channelUrl:this.url},t)),r=yield a.send(s),{channel:i}=r.as(g);this._update(i);const o=p.of(this._iid);return yield o.upsertChannelsToCache([i]),this}))}updateChannelWithOperatorUserIds(n,t,a,s,r){return e.__awaiter(this,void 0,void 0,(function*(){const e=Object.assign(Object.assign({},_),{name:n,coverUrlOrImage:t,data:a,operatorUserIds:s,customType:r});return this.updateChannel(e)}))}delete(){return e.__awaiter(this,void 0,void 0,(function*(){const{requestQueue:n}=e.Vault.of(this._iid),t=new y({channelUrl:this.url});yield n.send(t);const a=p.of(this._iid);yield a.removeChannelsFromCache([this.url])}))}sendUserMessage(n){return e.unless(!n.isPinnedMessage).throw(e.SendbirdError.notSupportedError),super.sendUserMessage(n)}sendFileMessage(n){return e.unless(!n.isPinnedMessage).throw(e.SendbirdError.notSupportedError),super.sendFileMessage(n)}}class T extends t.BaseChannelHandlerParams{constructor(){super(...arguments),this.onUserEntered=e.noop,this.onUserExited=e.noop,this.onChannelParticipantCountChanged=e.noop,this.onPollUpdated=e.noop,this.onPollVoted=e.noop,this.onPollDeleted=e.noop}}class P extends e.APIRequestCommand{constructor(n){const{token:t,limit:a,nameKeyword:s,urlKeyword:r,customTypes:i,includeFrozen:o,includeMetaData:l}=n;super(),this.method=e.APIRequestMethod.GET,this.path=e.API_PATH_OPEN_CHANNELS,this.params=e.deundefined({token:t,limit:a,name_contains:s,url_contains:r,custom_types:i,show_frozen:o,show_metadata:l})}}class O extends e.APIResponseCommand{constructor(e,n){super(e,n),this.channels=[];const{next:t,channels:a,ts:s}=n;this.token=t,a&&a.length>0&&(this.channels=a.map((n=>new U(e,n)))),this.ts="number"==typeof s?s:null}}class b extends e.BaseListQuery{constructor(e,n){var t,a,s,r,i;super(e,n),this.includeFrozen=!0,this.includeMetaData=!0,this.nameKeyword=null,this.urlKeyword=null,this.customTypes=null,this.includeFrozen=null===(t=n.includeFrozen)||void 0===t||t,this.includeMetaData=null===(a=n.includeMetaData)||void 0===a||a,this.nameKeyword=null!==(s=n.nameKeyword)&&void 0!==s?s:null,this.urlKeyword=null!==(r=n.urlKeyword)&&void 0!==r?r:null,this.customTypes=null!==(i=n.customTypes)&&void 0!==i?i:null}_validate(){return super._validate()&&e.isTypeOf("boolean",this.includeFrozen)&&e.isTypeOf("boolean",this.includeMetaData)&&e.isTypeOf("string",this.nameKeyword,!0)&&e.isTypeOf("string",this.urlKeyword,!0)&&e.isArrayOf("string",this.customTypes,!0)}next(){return e.__awaiter(this,void 0,void 0,(function*(){if(this._validate()){if(this._isLoading)throw e.SendbirdError.queryInProgress;if(this._hasNext){this._isLoading=!0;const{requestQueue:n}=e.Vault.of(this._iid),t=new P(e.undefineNullProps(Object.assign(Object.assign({},this),{token:this._token}))),a=yield n.send(t),{channels:s,token:r}=a.as(O);this._token=r,this._hasNext=!!r;const i=p.of(this._iid);return yield i.upsertChannelsToCache(s),this._isLoading=!1,s}return[]}throw e.SendbirdError.invalidParameters}))}}class A extends e.Module{constructor(){super(...arguments),this.name="openChannel"}init(e,{sdkState:n,dispatcher:t,sessionManager:a,requestQueue:s,logger:r,onlineDetector:i,cacheContext:o}){super.init(e,{sdkState:n,dispatcher:t,sessionManager:a,requestQueue:s,logger:r,onlineDetector:i,cacheContext:o}),this._manager=new p(e,{sdkState:n,dispatcher:t,requestQueue:s,logger:r,cacheContext:o,sessionManager:a})}createOpenChannelListQuery(e={}){return new b(this._iid,e)}addOpenChannelHandler(e,n){this._manager.addHandler(e,n)}removeOpenChannelHandler(e){this._manager.removeHandler(e)}removeAllOpenChannelHandlers(){this._manager.clearHandler()}buildOpenChannelFromSerializedData(e){return this._manager.buildOpenChannelFromSerializedData(e)}getChannel(n){return e.__awaiter(this,void 0,void 0,(function*(){return this._manager.getChannel(n)}))}getChannelWithoutCache(n){return e.__awaiter(this,void 0,void 0,(function*(){return this._manager.getChannelWithoutCache(n)}))}createChannel(n={}){return e.__awaiter(this,void 0,void 0,(function*(){return this._manager.createChannel(n)}))}createChannelWithOperatorUserIds(n,t,a,s,i){return e.__awaiter(this,void 0,void 0,(function*(){const e=Object.assign({},r);return e.name=n,e.coverUrlOrImage=t,e.data=a,e.operatorUserIds=s,e.customType=i,this._manager.createChannel(e)}))}}exports.OpenChannel=U,exports.OpenChannelHandler=class extends T{constructor(e={}){super(),Object.keys(e).forEach((n=>{this.hasOwnProperty(n)&&(this[n]=e[n])}))}},exports.OpenChannelListQuery=b,exports.OpenChannelModule=A,exports.ParticipantListQuery=E;
+"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("./lib/__bundle-5d8ae943.js"),n=require("./lib/__bundle-0bbec988.js"),t=require("./lib/__bundle-a29353f5.js"),a=require("./lib/__bundle-c301d48f.js"),s=require("./lib/__bundle-381bc53c.js");require("./lib/__bundle-f6d4722d.js");class r extends e.InstancedObject{constructor(){super(...arguments),this._channels=new Map,this._enteredChannelUrls=[]}get enteredChannels(){return this._enteredChannelUrls.map((e=>this._channels.get(e))).filter((e=>!!e))}isEnteredChannel(e){return this._enteredChannelUrls.includes(e)}enter(e){this._enteredChannelUrls.indexOf(e)<0&&this._enteredChannelUrls.push(e)}exit(e){const n=this._enteredChannelUrls.indexOf(e);n>=0&&this._enteredChannelUrls.splice(n,1)}exitAll(){this._enteredChannelUrls=[]}get(n){return e.__awaiter(this,void 0,void 0,(function*(){return this._channels.get(n)}))}upsert(n){return e.__awaiter(this,void 0,void 0,(function*(){const e=[];return n.forEach((n=>{if(this._channels.has(n.url)){const t=this._channels.get(n.url);Object.assign(t,n),e.push(t)}else this._channels.set(n.url,n),e.push(n)})),e}))}remove(n){return e.__awaiter(this,void 0,void 0,(function*(){this._channels.delete(n),this.exit(n)}))}clear(){return e.__awaiter(this,void 0,void 0,(function*(){this._channels.clear(),this._enteredChannelUrls=[]}))}}const i={channelUrl:void 0,name:void 0,coverUrlOrImage:void 0,data:void 0,customType:void 0,operatorUserIds:void 0,isEphemeral:void 0};class o extends e.APIRequestCommand{constructor({channelUrl:n,isInternalCall:t}){super(),this.method=e.APIRequestMethod.GET,this.path=`${t?e.API_PATH_OPEN_CHANNELS_INTERNAL:e.API_PATH_OPEN_CHANNELS}/${encodeURIComponent(n)}`}}class l extends e.APIResponseCommand{constructor(e,n){super(e,n),this.channel=new T(e,n)}}class h extends e.APIRequestCommand{constructor(n){const{channelUrl:t,coverUrlOrImage:a,name:s,data:r,customType:i,operatorUserIds:o,isEphemeral:l}=n;super(),this.method=e.APIRequestMethod.POST,this.path=e.API_PATH_OPEN_CHANNELS,this.params=e.deundefined(e.undefineNullProps({channel_url:t,cover_url:e.isTypeOf("string",a)?a:null,cover_file:e.isFile(a)?a:null,name:s,data:r,custom_type:i,operators:o,is_ephemeral:l}))}}class d extends e.WebSocketRequestCommand{constructor({channelUrl:e}){super({code:"ENTR",payload:{channel_url:e},ackRequired:!0})}}class c extends t.ChannelEventCommand{constructor(n,t,a){var s,r;super(n,"SYEV",a),a.data&&(this.participantCount=null!==(s=a.data.participant_count)&&void 0!==s?s:0,this.user=new e.User(n,a.data),this.ts=null!==(r=a.data.edge_ts)&&void 0!==r?r:0)}}class u extends e.WebSocketRequestCommand{constructor({channelUrl:e}){super({code:"EXIT",payload:{channel_url:e},ackRequired:!0})}}class C extends t.ChannelEventCommand{constructor(n,t,a){var s,r;super(n,"EXIT",a),a.data&&(this.participantCount=null!==(s=a.data.participant_count)&&void 0!==s?s:0,this.user=new e.User(n,a.data),this.ts=null!==(r=a.data.edge_ts)&&void 0!==r?r:0)}}const p={};class _ extends t.BaseChannelManager{constructor(n,t){super(n,Object.assign(Object.assign({},t),{channelType:e.ChannelType.OPEN})),this.subscribeChannelEvent=e.noop,this.unsubscribeChannelEvent=e.noop,this.refreshChannel=()=>e.__awaiter(this,void 0,void 0,(function*(){return e.noop()})),this._openChannelCache=new r(n),this._openChannelHandlers=new Map,this._dispatcher.on((n=>{if(n instanceof e.WebSocketEventCommand)this._handleEvent(n);else if(n instanceof e.ConnectionStateChangeCommand&&n.stateType===e.ConnectionStateType.CONNECTED){const{enteredChannels:e}=this._openChannelCache;for(const n of e)n.enter()}})),p[n]||(p[n]=this)}static of(e){return p[e]}buildOpenChannelFromSerializedData(n){const t=e.deserialize(n);return new T(this._iid,T.payloadify(t))}getChannelFromCache(n){var t;return e.__awaiter(this,void 0,void 0,(function*(){return null!==(t=yield this._openChannelCache.get(n))&&void 0!==t?t:null}))}upsertChannelsToCache(n){return e.__awaiter(this,void 0,void 0,(function*(){return yield this._openChannelCache.upsert(n)}))}removeChannelsFromCache(n){return e.__awaiter(this,void 0,void 0,(function*(){for(const e of n)yield this._openChannelCache.remove(e)}))}setEnteredToCache(e){this._openChannelCache.enter(e.url)}setExitedToCache(e){this._openChannelCache.exit(e.url)}_handleEvent(a){return e.__awaiter(this,void 0,void 0,(function*(){try{switch(a.code){case"MESG":case"FILE":case"ADMM":case"BRDM":{let s=null;if("MESG"===a.code?s=a.as(n.UserMessageEventCommand):"FILE"===a.code?s=a.as(n.FileMessageEventCommand):"ADMM"!==a.code&&"BRDM"!=a.code||(s=a.as(t.AdminMessageEventCommand)),s){const{message:n,isMentioned:t}=s;if(n.channelType===e.ChannelType.OPEN){const a=yield this.getChannel(n.channelUrl,!0);e.runAsCallback((()=>e.__awaiter(this,void 0,void 0,(function*(){for(const e of this._openChannelHandlers.values())this._openChannelCache.isEnteredChannel(a.url)&&(e.onMessageReceived&&e.onMessageReceived(a,n),t&&e.onMentionReceived&&e.onMentionReceived(a,n))}))))}}break}case"MEDI":case"FEDI":case"AEDI":{let s=null;if("MEDI"===a.code?s=a.as(n.UpdateUserMessageEventCommand):"FEDI"===a.code?s=a.as(n.UpdateFileMessageEventCommand):"AEDI"===a.code&&(s=a.as(t.UpdateAdminMessageEventCommand)),s){const{message:n,mentionCountChange:t}=s;if(n.channelType===e.ChannelType.OPEN){const a=yield this.getChannel(n.channelUrl,!0);e.runAsCallback((()=>e.__awaiter(this,void 0,void 0,(function*(){for(const e of this._openChannelHandlers.values())this._openChannelCache.isEnteredChannel(a.url)&&(e.onMessageUpdated&&e.onMessageUpdated(a,n),t>0&&e.onMentionReceived&&e.onMentionReceived(a,n))}))))}}break}case"DELM":{const{channelUrl:t,channelType:s,messageId:r}=a.as(n.DeleteMessageEventCommand);if(s===e.ChannelType.OPEN){const n=yield this.getChannel(t,!0);e.runAsCallback((()=>e.__awaiter(this,void 0,void 0,(function*(){for(const e of this._openChannelHandlers.values())this._openChannelCache.isEnteredChannel(n.url)&&e.onMessageDeleted&&e.onMessageDeleted(n,r)}))))}break}case"MRCT":{const{channelUrl:n,channelType:s,event:r}=a.as(t.ReactionEventCommand);if(s===e.ChannelType.OPEN){const t=yield this.getChannel(n,!0);e.runAsCallback((()=>e.__awaiter(this,void 0,void 0,(function*(){for(const e of this._openChannelHandlers.values())this._openChannelCache.isEnteredChannel(t.url)&&e.onReactionUpdated&&e.onReactionUpdated(t,r)}))))}break}case"MTHD":{const{event:n}=a.as(t.ThreadInfoUpdateEventCommand);if(n.channelType===e.ChannelType.OPEN){const t=yield this.getChannel(n.channelUrl,!0);e.runAsCallback((()=>e.__awaiter(this,void 0,void 0,(function*(){for(const e of this._openChannelHandlers.values())this._openChannelCache.isEnteredChannel(t.url)&&e.onThreadInfoUpdated&&e.onThreadInfoUpdated(t,n)}))))}break}case"MCNT":{const{openChannelMemberCounts:n}=a.as(t.MemberCountUpdateEventCommand),s=[];for(const e of n){const{channelUrl:n,participantCount:t,updatedAt:a}=e,r=yield this.getChannelFromCache(n);r&&r._updateParticipantCount(t,a)&&s.push(r)}if(s.length>0){const n=yield this.upsertChannelsToCache(s);e.runAsCallback((()=>e.__awaiter(this,void 0,void 0,(function*(){for(const e of this._openChannelHandlers.values())e.onChannelMemberCountChanged&&e.onChannelMemberCountChanged(n)}))))}break}case"PEDI":{const{event:n,status:s,channelUrl:r,channelType:i}=a.as(t.PollUpdateEventCommand);if(r&&i===e.ChannelType.OPEN){const t=yield this.getChannel(r,!0);this._dispatcher.dispatch(new e.PollUpdateInternalEventCommand({event:n,source:e.CollectionEventSource.EVENT_POLL_UPDATED})),s===e.POLL_REMOVED_STATUS?e.runAsCallback((()=>e.__awaiter(this,void 0,void 0,(function*(){for(const e of this._openChannelHandlers.values())e.onPollDeleted&&e.onPollDeleted(t,n.pollId)})))):e.runAsCallback((()=>e.__awaiter(this,void 0,void 0,(function*(){for(const e of this._openChannelHandlers.values())e.onPollUpdated&&e.onPollUpdated(t,n)}))))}break}case"VOTE":{const{event:t,channelUrl:s,channelType:r}=a.as(n.PollVoteEventCommand);if(s&&r===e.ChannelType.OPEN){const n=yield this.getChannel(s,!0);this._dispatcher.dispatch(new e.PollVoteInternalEventCommand({event:t,source:e.CollectionEventSource.EVENT_POLL_VOTED})),e.runAsCallback((()=>e.__awaiter(this,void 0,void 0,(function*(){for(const e of this._openChannelHandlers.values())e.onPollVoted&&e.onPollVoted(n,t)}))))}break}case"SYEV":{const{event:s}=a.as(t.ChannelEventCommand);if(s.isOpenChannelEvent)switch(s.category){case t.ChannelEventCategory.CHANNEL_ENTER:{const n=yield this.getChannel(s.channelUrl,!0),{participantCount:t,user:r}=a.as(c),i=n._updateParticipantCount(t,s.ts);e.runAsCallback((()=>e.__awaiter(this,void 0,void 0,(function*(){this._openChannelHandlers.forEach((e=>{e.onUserEntered&&e.onUserEntered(n,r),i&&e.onChannelParticipantCountChanged&&e.onChannelParticipantCountChanged(n)}))}))));break}case t.ChannelEventCategory.CHANNEL_EXIT:{const n=yield this.getChannel(s.channelUrl,!0),{participantCount:t,user:r}=a.as(C),i=n._updateParticipantCount(t,s.ts);e.runAsCallback((()=>e.__awaiter(this,void 0,void 0,(function*(){this._openChannelHandlers.forEach((e=>{e.onUserExited&&e.onUserExited(n,r),i&&e.onChannelParticipantCountChanged&&e.onChannelParticipantCountChanged(n)}))}))));break}case t.ChannelEventCategory.CHANNEL_OPERATOR_UPDATE:{const n=yield this.getChannel(s.channelUrl,!0),{operators:r}=a.as(t.OperatorUpdateEventCommand);n.operators=r,this.upsertChannelsToCache([n]),e.runAsCallback((()=>e.__awaiter(this,void 0,void 0,(function*(){this._openChannelHandlers.forEach((e=>{e.onOperatorUpdated&&e.onOperatorUpdated(n,r)}))}))));break}case t.ChannelEventCategory.USER_CHANNEL_MUTE:case t.ChannelEventCategory.USER_CHANNEL_UNMUTE:{const r=yield this.getChannel(s.channelUrl,!0),i=s.category===t.ChannelEventCategory.USER_CHANNEL_MUTE,{user:o}=a.as(i?n.MuteUserEventCommand:n.UnmuteUserEventCommand);e.runAsCallback((()=>e.__awaiter(this,void 0,void 0,(function*(){this._openChannelHandlers.forEach((e=>{i?e.onUserMuted&&e.onUserMuted(r,o):e.onUserUnmuted&&e.onUserUnmuted(r,o)}))}))));break}case t.ChannelEventCategory.USER_CHANNEL_BAN:case t.ChannelEventCategory.USER_CHANNEL_UNBAN:{const r=yield this.getChannel(s.channelUrl,!0),i=s.category===t.ChannelEventCategory.USER_CHANNEL_BAN,{user:o}=a.as(i?n.BanUserEventCommand:n.UnbanUserEventCommand);e.runAsCallback((()=>e.__awaiter(this,void 0,void 0,(function*(){this._openChannelHandlers.forEach((e=>{i?e.onUserBanned&&e.onUserBanned(r,o):e.onUserUnbanned&&e.onUserUnbanned(r,o)}))}))));break}case t.ChannelEventCategory.CHANNEL_FREEZE:case t.ChannelEventCategory.CHANNEL_UNFREEZE:{const t=yield this.getChannel(s.channelUrl,!0),{freeze:r}=a.as(n.FreezeEventCommand);t.isFrozen=r,this.upsertChannelsToCache([t]),e.runAsCallback((()=>e.__awaiter(this,void 0,void 0,(function*(){this._openChannelHandlers.forEach((e=>{r?e.onChannelFrozen&&e.onChannelFrozen(t):e.onChannelUnfrozen&&e.onChannelUnfrozen(t)}))}))));break}case t.ChannelEventCategory.CHANNEL_DELETED:{const n=yield this.getChannel(s.channelUrl,!0);yield this.removeChannelsFromCache([n.url]),e.runAsCallback((()=>e.__awaiter(this,void 0,void 0,(function*(){this._openChannelHandlers.forEach((e=>{e.onChannelDeleted&&e.onChannelDeleted(n.url,n.channelType)}))}))));break}case t.ChannelEventCategory.CHANNEL_PROP_CHANGED:{const n=yield this.getChannelWithoutCache(s.channelUrl,!0);e.runAsCallback((()=>e.__awaiter(this,void 0,void 0,(function*(){this._openChannelHandlers.forEach((e=>{e.onChannelChanged&&e.onChannelChanged(n)}))}))));break}case t.ChannelEventCategory.CHANNEL_META_DATA_CHANGED:{const t=yield this.getChannel(s.channelUrl,!0),{created:r,updated:i,deleted:o}=a.as(n.UpdateMetaDataEventCommand);r&&t._upsertCachedMetaData(r,s.ts),i&&t._upsertCachedMetaData(i,s.ts),o&&t._removeFromCachedMetaData(o,s.ts),e.runAsCallback((()=>e.__awaiter(this,void 0,void 0,(function*(){this._openChannelHandlers.forEach((e=>{r&&e.onMetaDataCreated&&e.onMetaDataCreated(t,r),i&&e.onMetaDataUpdated&&e.onMetaDataUpdated(t,i),o&&e.onMetaDataDeleted&&e.onMetaDataDeleted(t,o)}))}))));break}case t.ChannelEventCategory.CHANNEL_META_COUNTERS_CHANGED:{const t=yield this.getChannel(s.channelUrl,!0),{created:r,updated:i,deleted:o}=a.as(n.UpdateMetaCounterEventCommand);e.runAsCallback((()=>e.__awaiter(this,void 0,void 0,(function*(){this._openChannelHandlers.forEach((e=>{r&&e.onMetaCounterCreated&&e.onMetaCounterCreated(t,r),i&&e.onMetaCounterUpdated&&e.onMetaCounterUpdated(t,i),o&&e.onMetaCounterDeleted&&e.onMetaCounterDeleted(t,o)}))}))));break}}break}}}catch(n){if(e.isThrowingOutside(n))throw n}}))}addHandler(e,n){this._openChannelHandlers.set(e,n)}removeHandler(e){this._openChannelHandlers.delete(e)}clearHandler(){this._openChannelHandlers.clear()}getChannel(n,t=!1){return e.__awaiter(this,void 0,void 0,(function*(){e.unless(e.isTypeOf("string",n)).throw(e.SendbirdError.invalidParameters);try{const e=yield this.getChannelFromCache(n);if(e)return e}catch(e){}return yield this.getChannelWithoutCache(n)}))}getChannelWithoutCache(n,t=!1){return e.__awaiter(this,void 0,void 0,(function*(){e.unless(e.isTypeOf("string",n)).throw(e.SendbirdError.invalidParameters);const a=new o({channelUrl:n,isInternalCall:t}),s=yield this._requestQueue.send(a),{channel:r}=s.as(l);return(yield this.upsertChannelsToCache([r]))[0]}))}createChannel(n){return e.__awaiter(this,void 0,void 0,(function*(){const t=Object.assign(Object.assign({},i),n);e.unless((n=>e.isArrayOf("string",n.operatorUserIds,!0)&&(e.isTypeOf("string",n.coverUrlOrImage,!0)||e.isFile(n.coverUrlOrImage,!0))&&e.isTypeOf("string",n.name,!0)&&e.isTypeOf("string",n.data,!0)&&e.isTypeOf("string",n.customType,!0)&&(e.isTypeOf("string",n.channelUrl)&&/^\w+$/.test(n.channelUrl)||null===n.channelUrl||void 0===n.channelUrl)&&e.isTypeOf("boolean",n.isEphemeral,!0))(t)).throw(e.SendbirdError.invalidParameters);const a=new h(t),s=yield this._requestQueue.send(a),{channel:r}=s.as(l);return this.upsertChannelsToCache([r]),r}))}}const v={name:void 0,coverUrlOrImage:void 0,data:void 0,customType:void 0,operatorUserIds:void 0};class m extends e.APIRequestCommand{constructor(n){const{channelUrl:t,token:a,limit:s}=n;super(),this.method=e.APIRequestMethod.GET,this.path=`${e.API_PATH_OPEN_CHANNELS}/${encodeURIComponent(t)}/participants`,this.params={token:a,limit:s}}}class E extends e.APIResponseCommand{constructor(e,n){super(e,n),this.participants=[];const{next:t,participants:s}=n;this.token=t,this.participants=s.map((n=>new a.Participant(e,n)))}}class f extends e.ChannelDataListQuery{constructor(n,t,a){super(n,t,e.ChannelType.OPEN,a)}_validate(){return super._validate()}next(){return e.__awaiter(this,void 0,void 0,(function*(){if(this._validate()){if(this._isLoading)throw e.SendbirdError.queryInProgress;if(this._hasNext){this._isLoading=!0;const{requestQueue:n}=e.Vault.of(this._iid),t=new m(Object.assign(Object.assign({},this),{token:this._token})),a=yield n.send(t),{participants:s,token:r}=a.as(E);return this._token=r,this._hasNext=!!r,this._isLoading=!1,s}return[]}throw e.SendbirdError.invalidParameters}))}}class g extends e.APIRequestCommand{constructor(n){const{channelUrl:t,coverUrlOrImage:a,name:s,data:r,customType:i,operatorUserIds:o}=n;super(),this.method=e.APIRequestMethod.PUT,this.path=`${e.API_PATH_OPEN_CHANNELS}/${encodeURIComponent(t)}`,this.params=e.deundefined(e.undefineNullProps({cover_url:e.isTypeOf("string",a)?a:null,cover_file:e.isFile(a)?a:null,name:s,data:r,custom_type:i,operators:o}))}}class y extends e.APIResponseCommand{constructor(e,n){super(e,n),this.channel=new T(e,n)}}class U extends e.APIRequestCommand{constructor(n){const{channelUrl:t}=n;super(),this.method=e.APIRequestMethod.DELETE,this.path=`${e.API_PATH_OPEN_CHANNELS}/${encodeURIComponent(t)}`}}class T extends n.BaseChannel{constructor(n,t){var a;super(n,t),this._lastParticipantCountUpdated=0,this.participantCount=0,this.operators=[],this.channelType=e.ChannelType.OPEN,this.participantCount=null!==(a=t.participant_count)&&void 0!==a?a:0,this.operators=Array.isArray(t.operators)?t.operators.map((t=>new e.User(n,t))):[]}static payloadify(t){return e.deundefined(e.undefineNullProps(Object.assign(Object.assign({},n.BaseChannel.payloadify(t)),{participant_count:t.participantCount,operators:t.operators.map((n=>e.User.payloadify(n)))})))}serialize(){return e.serialize(this)}isOperator(n){return n instanceof e.User?this.isOperator(n.userId):this.operators.some((e=>e.userId===n))}_updateParticipantCount(e,n){return n>this._lastParticipantCountUpdated&&(this.participantCount=e,this._lastParticipantCountUpdated=n,!0)}createParticipantListQuery(e){return new f(this._iid,this.url,e)}refresh(){return e.__awaiter(this,void 0,void 0,(function*(){const e=_.of(this._iid);return yield e.getChannelWithoutCache(this.url)}))}enter(){return e.__awaiter(this,void 0,void 0,(function*(){const{requestQueue:n}=e.Vault.of(this._iid),t=new d({channelUrl:this.url}),a=yield n.send(t),{participantCount:s,ts:r}=a.as(c);this._updateParticipantCount(s,r);_.of(this._iid).setEnteredToCache(this)}))}exit(){return e.__awaiter(this,void 0,void 0,(function*(){const{requestQueue:t}=e.Vault.of(this._iid),a=new u({channelUrl:this.url}),s=yield t.send(a),{participantCount:r,ts:i}=s.as(C);this._updateParticipantCount(r,i);_.of(this._iid).setExitedToCache(this);n.MessageManager.of(this._iid).fileMessageQueue.cancel(this)}))}updateChannel(n){return e.__awaiter(this,void 0,void 0,(function*(){const t=Object.assign(Object.assign({},v),n);e.unless((n=>e.isArrayOf("string",n.operatorUserIds,!0)&&(e.isTypeOf("string",n.coverUrlOrImage)||e.isFile(n.coverUrlOrImage)||null===n.coverUrlOrImage)&&e.isTypeOf("string",n.name,!0)&&e.isTypeOf("string",n.data,!0)&&e.isTypeOf("string",n.customType,!0))(t)).throw(e.SendbirdError.invalidParameters);const{requestQueue:a}=e.Vault.of(this._iid),s=new g(Object.assign({channelUrl:this.url},t)),r=yield a.send(s),{channel:i}=r.as(y);this._update(i);const o=_.of(this._iid);return yield o.upsertChannelsToCache([i]),this}))}updateChannelWithOperatorUserIds(n,t,a,s,r){return e.__awaiter(this,void 0,void 0,(function*(){const e=Object.assign(Object.assign({},v),{name:n,coverUrlOrImage:t,data:a,operatorUserIds:s,customType:r});return this.updateChannel(e)}))}delete(){return e.__awaiter(this,void 0,void 0,(function*(){const{requestQueue:n}=e.Vault.of(this._iid),t=new U({channelUrl:this.url});yield n.send(t);const a=_.of(this._iid);yield a.removeChannelsFromCache([this.url])}))}sendUserMessage(n){return e.unless(!n.isPinnedMessage).throw(e.SendbirdError.notSupportedError),super.sendUserMessage(n)}sendFileMessage(n){return e.unless(!n.isPinnedMessage).throw(e.SendbirdError.notSupportedError),super.sendFileMessage(n)}}class P extends s.BaseChannelHandlerParams{constructor(){super(...arguments),this.onUserEntered=e.noop,this.onUserExited=e.noop,this.onChannelParticipantCountChanged=e.noop,this.onPollUpdated=e.noop,this.onPollVoted=e.noop,this.onPollDeleted=e.noop}}class b extends e.APIRequestCommand{constructor(n){const{token:t,limit:a,nameKeyword:s,urlKeyword:r,customTypes:i,includeFrozen:o,includeMetaData:l}=n;super(),this.method=e.APIRequestMethod.GET,this.path=e.API_PATH_OPEN_CHANNELS,this.params=e.deundefined({token:t,limit:a,name_contains:s,url_contains:r,custom_types:i,show_frozen:o,show_metadata:l})}}class O extends e.APIResponseCommand{constructor(e,n){super(e,n),this.channels=[];const{next:t,channels:a,ts:s}=n;this.token=t,a&&a.length>0&&(this.channels=a.map((n=>new T(e,n)))),this.ts="number"==typeof s?s:null}}class A extends e.BaseListQuery{constructor(e,n){var t,a,s,r,i;super(e,n),this.includeFrozen=!0,this.includeMetaData=!0,this.nameKeyword=null,this.urlKeyword=null,this.customTypes=null,this.includeFrozen=null===(t=n.includeFrozen)||void 0===t||t,this.includeMetaData=null===(a=n.includeMetaData)||void 0===a||a,this.nameKeyword=null!==(s=n.nameKeyword)&&void 0!==s?s:null,this.urlKeyword=null!==(r=n.urlKeyword)&&void 0!==r?r:null,this.customTypes=null!==(i=n.customTypes)&&void 0!==i?i:null}_validate(){return super._validate()&&e.isTypeOf("boolean",this.includeFrozen)&&e.isTypeOf("boolean",this.includeMetaData)&&e.isTypeOf("string",this.nameKeyword,!0)&&e.isTypeOf("string",this.urlKeyword,!0)&&e.isArrayOf("string",this.customTypes,!0)}next(){return e.__awaiter(this,void 0,void 0,(function*(){if(this._validate()){if(this._isLoading)throw e.SendbirdError.queryInProgress;if(this._hasNext){this._isLoading=!0;const{requestQueue:n}=e.Vault.of(this._iid),t=new b(e.undefineNullProps(Object.assign(Object.assign({},this),{token:this._token}))),a=yield n.send(t),{channels:s,token:r}=a.as(O);this._token=r,this._hasNext=!!r;const i=_.of(this._iid);return yield i.upsertChannelsToCache(s),this._isLoading=!1,s}return[]}throw e.SendbirdError.invalidParameters}))}}class w extends e.Module{constructor(){super(...arguments),this.name="openChannel"}init(e,{sdkState:n,dispatcher:t,sessionManager:a,requestQueue:s,logger:r,onlineDetector:i,cacheContext:o}){super.init(e,{sdkState:n,dispatcher:t,sessionManager:a,requestQueue:s,logger:r,onlineDetector:i,cacheContext:o}),this._manager=new _(e,{sdkState:n,dispatcher:t,requestQueue:s,logger:r,cacheContext:o,sessionManager:a})}createOpenChannelListQuery(e={}){return new A(this._iid,e)}addOpenChannelHandler(e,n){this._manager.addHandler(e,n)}removeOpenChannelHandler(e){this._manager.removeHandler(e)}removeAllOpenChannelHandlers(){this._manager.clearHandler()}buildOpenChannelFromSerializedData(e){return this._manager.buildOpenChannelFromSerializedData(e)}getChannel(n){return e.__awaiter(this,void 0,void 0,(function*(){return this._manager.getChannel(n)}))}getChannelWithoutCache(n){return e.__awaiter(this,void 0,void 0,(function*(){return this._manager.getChannelWithoutCache(n)}))}createChannel(n={}){return e.__awaiter(this,void 0,void 0,(function*(){return this._manager.createChannel(n)}))}createChannelWithOperatorUserIds(n,t,a,s,r){return e.__awaiter(this,void 0,void 0,(function*(){const e=Object.assign({},i);return e.name=n,e.coverUrlOrImage=t,e.data=a,e.operatorUserIds=s,e.customType=r,this._manager.createChannel(e)}))}}exports.OpenChannel=T,exports.OpenChannelHandler=class extends P{constructor(e={}){super(),Object.keys(e).forEach((n=>{this.hasOwnProperty(n)&&(this[n]=e[n])}))}},exports.OpenChannelListQuery=A,exports.OpenChannelModule=w,exports.ParticipantListQuery=f;
diff --git a/cjs/package.json b/cjs/package.json
index 737df37..5838d29 100644
--- a/cjs/package.json
+++ b/cjs/package.json
@@ -1,5 +1,5 @@
{
- "version": "4.9.11",
+ "version": "4.9.12",
"description": "Sendbird SDK for JavaScript",
"name": "@sendbird/chat",
"author": "Sendbird ",
diff --git a/cjs/poll.js b/cjs/poll.js
index f105c80..a4685a5 100644
--- a/cjs/poll.js
+++ b/cjs/poll.js
@@ -1 +1 @@
-"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("./lib/__bundle-fc8b8d13.js"),t=require("./lib/__bundle-f6d4722d.js");class r extends e.Module{constructor(){super(...arguments),this.name="poll"}init(t,{sdkState:r,dispatcher:a,sessionManager:o,requestQueue:l,logger:s,onlineDetector:i,cacheContext:n}){super.init(t,{sdkState:r,dispatcher:a,sessionManager:o,requestQueue:l,logger:s,onlineDetector:i,cacheContext:n}),this._manager=new e.PollManager(t,{sdkState:r,dispatcher:a,sessionManager:o,requestQueue:l,logger:s,onlineDetector:i,cacheContext:n})}create(t){return e.__awaiter(this,void 0,void 0,(function*(){const r=Object.assign(Object.assign({},e.PollCreateParamsDefault),t);return e.unless(e.validatePollCreateParams(r)).throw(e.SendbirdError.invalidParameters),this._manager.create(r)}))}get(t){return e.__awaiter(this,void 0,void 0,(function*(){const r=Object.assign(Object.assign({},e.PollRetrievalParamsDefault),t);return e.unless(e.validatePollRetrievalParams(r)).throw(e.SendbirdError.invalidParameters),this._manager.get(r)}))}getOption(t){return e.__awaiter(this,void 0,void 0,(function*(){const r=Object.assign(Object.assign({},e.PollOptionRetrievalParamsDefault),t);return e.unless(e.validatePollOptionRetrievalParams(r)).throw(e.SendbirdError.invalidParameters),this._manager.getOption(r)}))}buildPollFromSerializedData(e){return this._manager.buildPollFromSerializedData(e)}}exports.Poll=e.Poll,exports.PollListQuery=e.PollListQuery,exports.PollOption=e.PollOption,Object.defineProperty(exports,"PollStatus",{enumerable:!0,get:function(){return e.PollStatus}}),exports.PollVoteEvent=e.PollVoteEvent,exports.PollVoterListQuery=e.PollVoterListQuery,exports.PollUpdateEvent=t.PollUpdateEvent,exports.PollModule=r;
+"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("./lib/__bundle-5d8ae943.js"),t=require("./lib/__bundle-f6d4722d.js");class r extends e.Module{constructor(){super(...arguments),this.name="poll"}init(t,{sdkState:r,dispatcher:a,sessionManager:o,requestQueue:l,logger:s,onlineDetector:i,cacheContext:n}){super.init(t,{sdkState:r,dispatcher:a,sessionManager:o,requestQueue:l,logger:s,onlineDetector:i,cacheContext:n}),this._manager=new e.PollManager(t,{sdkState:r,dispatcher:a,sessionManager:o,requestQueue:l,logger:s,onlineDetector:i,cacheContext:n})}create(t){return e.__awaiter(this,void 0,void 0,(function*(){const r=Object.assign(Object.assign({},e.PollCreateParamsDefault),t);return e.unless(e.validatePollCreateParams(r)).throw(e.SendbirdError.invalidParameters),this._manager.create(r)}))}get(t){return e.__awaiter(this,void 0,void 0,(function*(){const r=Object.assign(Object.assign({},e.PollRetrievalParamsDefault),t);return e.unless(e.validatePollRetrievalParams(r)).throw(e.SendbirdError.invalidParameters),this._manager.get(r)}))}getOption(t){return e.__awaiter(this,void 0,void 0,(function*(){const r=Object.assign(Object.assign({},e.PollOptionRetrievalParamsDefault),t);return e.unless(e.validatePollOptionRetrievalParams(r)).throw(e.SendbirdError.invalidParameters),this._manager.getOption(r)}))}buildPollFromSerializedData(e){return this._manager.buildPollFromSerializedData(e)}}exports.Poll=e.Poll,exports.PollListQuery=e.PollListQuery,exports.PollOption=e.PollOption,Object.defineProperty(exports,"PollStatus",{enumerable:!0,get:function(){return e.PollStatus}}),exports.PollVoteEvent=e.PollVoteEvent,exports.PollVoterListQuery=e.PollVoterListQuery,exports.PollUpdateEvent=t.PollUpdateEvent,exports.PollModule=r;
diff --git a/feedChannel.d.ts b/feedChannel.d.ts
index 0bf6e10..177f55a 100644
--- a/feedChannel.d.ts
+++ b/feedChannel.d.ts
@@ -14,6 +14,7 @@ export {
NotificationCollectionParams,
NotificationData,
NotificationEventContext,
+ NotificationMessage,
NotificationTemplate,
NotificationTemplateList,
NotificationTemplateListParams,
diff --git a/feedChannel.js b/feedChannel.js
index 7c00a47..f911d24 100644
--- a/feedChannel.js
+++ b/feedChannel.js
@@ -1 +1 @@
-import{e,u as n,_ as t,s as r,q as a,g as s,o as i,p as o,b as c,c as l,a8 as u,r as h,A as d,d as f,f as p,h as _,O as v,b1 as C,ap as m,a as g,ba as y,aH as b,K as E,V as M,x as w,X as N,Y as U,W as I,al as D,B as T,aL as A,aA as k,am as S,aq as x,aF as H,aN as L}from"./lib/__bundle-753d9ea0.js";import{i as P,ay as O,p as F,q as R,_ as j,$ as V,a0 as G,a1 as B,a2 as q,a3 as z,t as W}from"./lib/__bundle-2cf97ad3.js";import{F as Q,D as J,E as X,T as K,I as $,J as ee,p as ne,K as te,L as re,m as ae,N as se,V as ie,W as oe,c as ce,X as le}from"./lib/__bundle-6aed501c.js";export{Y as FeedChannelEventContext,Z as NotificationEventContext}from"./lib/__bundle-6aed501c.js";import{g as ue,N as he}from"./lib/__bundle-ccebf220.js";import{D as de}from"./lib/__bundle-743309b9.js";import{a as fe,C as pe,b as _e,U as ve,A as Ce,B as me}from"./lib/__bundle-b19328da.js";import"./lib/__bundle-c336221f.js";var ge=function(){function t(e){this.id=e.id,this.name=e.name,this.isDefault=e.is_default}return t.payloadify=function(t){return e(n({id:t.id,name:t.name,is_default:t.isDefault}))},Object.defineProperty(t.prototype,"customType",{get:function(){return this.isDefault?"*":String(this.id)},enumerable:!1,configurable:!0}),t}(),ye=function(n){function u(e,t){var r=t.sdkState,a=t.cacheContext,s=t.channelManager,i=n.call(this,e)||this;return i._channels=new Map,i._sdkState=r,i._cacheContext=a,i._channelManager=s,i}return t(u,n),Object.defineProperty(u.prototype,"collection",{get:function(){var e=this._cacheContext.nestdb;return r(!!e).throw(a.databaseError),e.collection(P)},enumerable:!1,configurable:!0}),Object.defineProperty(u.prototype,"localCacheEnabled",{get:function(){return this._cacheContext.localCacheEnabled&&!!this.collection},enumerable:!1,configurable:!0}),u.prototype._serialize=function(e,n){return void 0===n&&(n=0),s(s({},e.serialize()),{lastMessageUpdatedAt:e.lastMessage?e.lastMessage.createdAt:0,syncIndex:n})},u.prototype._deserialize=function(e){return this._channelManager.buildFeedChannelFromSerializedData(e)},Object.defineProperty(u.prototype,"channels",{get:function(){return i([],o(this._channels.values()),!1)},enumerable:!1,configurable:!0}),u.prototype.isCachedInMemory=function(e){return this._channels.has(e)},u.prototype.get=function(e){return c(this,void 0,void 0,(function(){var n;return l(this,(function(t){switch(t.label){case 0:return this._channels.has(e)?[3,3]:this.localCacheEnabled?[4,this.collection.getByKey(e)]:[3,2];case 1:if(n=t.sent())return this._channels.set(e,this._deserialize(n)),[2,this._channels.get(e)];t.label=2;case 2:return[2,void 0];case 3:return[2,this._channels.get(e)]}}))}))},u.prototype.fetch=function(e){var n=e.token,t=e.limit,r=void 0===t?O:t,a=e.backward,s=void 0!==a&&a,i=e.order,o=void 0===i?"latest_last_message":i,u=e.borderlineChannelUrl;return c(this,void 0,void 0,(function(){var e,t,a,i,c=this;return l(this,(function(l){switch(l.label){case 0:return this.localCacheEnabled?(e=ue(o),t={where:function(e){if(n&&"latest_last_message"===o){if(!s&&e.lastMessageUpdatedAt>n||s&&e.lastMessageUpdatedAt0&&this._dispatcher.dispatch(new J({channels:d,source:i})),f.length>0&&this._dispatcher.dispatch(new Q({channelUrls:f,source:i})),[2,{updatedChannels:d,deletedChannelUrls:f,hasMore:p,token:_}]}}))}))},u.prototype.getTotalUnreadMessageCount=function(e){return c(this,void 0,void 0,(function(){var n,t,i,o,c,u,h;return l(this,(function(l){switch(l.label){case 0:return n=s(s({},K),e),r($(n)).throw(a.invalidParameters),t=M.of(this._iid),i=t.sdkState,o=t.requestQueue,c=new ee({userId:i.userId,filter:n,includeFeedChannel:!0}),[4,o.send(c)];case 1:return u=l.sent(),h=u.as(X).unreadFeedCount,[2,void 0===h?0:h]}}))}))},u.prototype.getGlobalNotificationChannelSetting=function(){return c(this,void 0,void 0,(function(){var e,n;return l(this,(function(t){switch(t.label){case 0:return e=new ke,[4,this._requestQueue.send(e)];case 1:return n=t.sent(),[2,{jsonString:n.as(Se).jsonString}]}}))}))},u.prototype.getNotificationTemplateListByToken=function(e,n){return void 0===n&&(n={}),c(this,void 0,void 0,(function(){var t,i,o,c,u,h,d;return l(this,(function(l){switch(l.label){case 0:return t=s(s({},Le),n),r(g("string",e)&&function(e){return g("boolean",e.reverse,!0)&&E("string",e.keys,!0)&&g("number",e.limit,!0)}(t)).throw(a.invalidParameters),i=new xe({token:e,keys:t.keys,reverse:t.reverse,limit:t.limit}),[4,this._requestQueue.send(i)];case 1:return o=l.sent(),c=o.as(He),u=c.hasMore,h=c.nextToken,d=c.notificationTemplateList,[2,{hasMore:u,token:h,notificationTemplateList:d}]}}))}))},u.prototype.getNotificationTemplate=function(e){return c(this,void 0,void 0,(function(){var n,t;return l(this,(function(s){switch(s.label){case 0:return r(g("string",e)).throw(a.invalidParameters),n=new Pe({key:e}),[4,this._requestQueue.send(n)];case 1:return t=s.sent(),[2,{jsonString:t.as(Oe).jsonString}]}}))}))},u.prototype.upsertChannelsToCache=function(e){return c(this,void 0,void 0,(function(){return l(this,(function(n){switch(n.label){case 0:return[4,this._feedChannelCache.upsert(e)];case 1:return[2,n.sent()]}}))}))},u.prototype.removeChannelsFromCache=function(e){return c(this,void 0,void 0,(function(){return l(this,(function(n){switch(n.label){case 0:return[4,this._feedChannelCache.remove(e)];case 1:return n.sent(),[2]}}))}))},u.prototype.refreshChannel=function(e,n,t){return void 0===n&&(n=!0),void 0===t&&(t=N.REFRESH_CHANNEL),c(this,void 0,void 0,(function(){var r,a,s,i,o;return l(this,(function(c){switch(c.label){case 0:return c.trys.push([0,5,,6]),r=new Ne({channelUrl:e,isInternalCall:n}),[4,this._requestQueue.send(r)];case 1:return a=c.sent(),(s=a.as(Ue).channel).myMemberState!==ne.NONE?[3,2]:(this._dispatcher.dispatch(new Q({channelUrls:[s.url],source:t})),[3,4]);case 2:return[4,this.upsertChannelsToCache([s])];case 3:i=c.sent(),this._dispatcher.dispatch(new J({channels:i,source:t})),c.label=4;case 4:return[3,6];case 5:return(o=c.sent()).code!==D.NON_AUTHORIZED&&o.code!==D.NOT_FOUND_IN_DATABASE||this._dispatcher.dispatch(new Q({channelUrls:[e],source:t})),[3,6];case 6:return[2]}}))}))},u.prototype.refreshNotificationCollections=function(){this._dispatcher.dispatch(new he)},u.prototype.subscribeChannelEvent=function(e,n){this._feedChannelBroadcast.subscribe(e,n)},u.prototype.unsubscribeChannelEvent=function(e){this._feedChannelBroadcast.unsubscribe(e)},u.prototype._handleEvent=function(e){return c(this,void 0,void 0,(function(){var n,t,r,a,s,i,o,u,d,f,p,_,C,m,g,y,b,E,w,U,I=this;return l(this,(function(D){switch(D.label){case 0:switch(e.code){case"MESG":case"FILE":case"ADMM":case"BRDM":return[3,1];case"MEDI":case"FEDI":case"AEDI":return[3,4];case"DELM":return[3,7];case"READ":return[3,10];case"SYEV":return[3,13]}return[3,23];case 1:return(g="MESG"===e.code?e.as(q):"FILE"===e.code?e.as(z):"ADMM"===e.code||"BRDM"===e.code?e.as(Ce):null)&&g.message.channelType===this._channelType?(n=g.message,t=g.isMentioned,r=g.forceUpdateLastMessage,this._disableMack||v((function(){return c(I,void 0,void 0,(function(){var e;return l(this,(function(t){return e=new ie(n),this._requestQueue.send(e),[2]}))}))})),[4,this.getChannel(n.channelUrl,!0)]):[3,3];case 2:(a=D.sent())._runIfHandleableWithGroupChannel((function(e){var s,i,o,u=I._feedChannelCache.isCachedInMemory(n.channelUrl),d=n instanceof V&&n.sender.userId===I._sdkState.userId;if(e.hiddenState===ae.HIDDEN_ALLOW_AUTO_UNHIDE&&(e.hiddenState=ae.UNHIDDEN),n instanceof V){var f=M.of(I._iid).useMemberInfoInMessage;try{for(var p=h(e.members),_=p.next();!_.done;_=p.next()){var v=_.value;if(v.userId===n.sender.userId){f||(n.sender.nickname=v.nickname,n.sender.plainProfileUrl=v.plainProfileUrl,n.sender.metaData=v.metaData,n.sender.isBlockedByMe=v.isBlockedByMe);break}}}catch(e){s={error:e}}finally{try{_&&!_.done&&(i=p.return)&&i.call(p)}finally{if(s)throw s.error}}if(!f&&t&&(null===(o=n.mentionedUsers)||void 0===o||o.forEach((function(n){var t,r;try{for(var a=h(e.members),s=a.next();!s.done;s=a.next()){var i=s.value;if(n.userId===i.userId){n.nickname=i.nickname,n.plainProfileUrl=i.plainProfileUrl,n.metaData=i.metaData;break}}}catch(e){t={error:e}}finally{try{s&&!s.done&&(r=a.return)&&r.call(a)}finally{if(t)throw t.error}}}))),d){var C=I._sessionManager.currentUser;C&&(C.nickname=n.sender.nickname,C.plainProfileUrl=n.sender.plainProfileUrl,C.metaData=n.sender.metaData)}}n.silent&&!d||(e.isEphemeral||u)&&((!e.lastMessage||e.lastMessage.createdAt0||e.unreadMentionCount>0)&&(e._updateUnreadCount(0,0),I._dispatcher.dispatch(new J({channels:[m],source:N.EVENT_CHANNEL_READ})),T((function(){return c(I,void 0,void 0,(function(){var e,n,t,r,a;return l(this,(function(s){try{for(e=h(this._feedChannelHandlers.values()),n=e.next();!n.done;n=e.next())(t=n.value).onChannelChanged&&t.onChannelChanged(m)}catch(e){r={error:e}}finally{try{n&&!n.done&&(a=e.return)&&a.call(e)}finally{if(r)throw r.error}}return[2]}))}))}))):0!==e.unreadMessageCount&&0!==e.unreadMentionCount||(I._dispatcher.dispatch(new J({channels:[m],source:N.EVENT_CHANNEL_READ})),T((function(){return c(I,void 0,void 0,(function(){var e,n,t,r,a;return l(this,(function(s){try{for(e=h(this._feedChannelHandlers.values()),n=e.next();!n.done;n=e.next())(t=n.value).onChannelChanged&&t.onChannelChanged(m)}catch(e){r={error:e}}finally{try{n&&!n.done&&(a=e.return)&&a.call(e)}finally{if(r)throw r.error}}return[2]}))}))}))):(I._dispatcher.dispatch(new J({channels:[m],source:N.EVENT_CHANNEL_READ})),T((function(){return c(I,void 0,void 0,(function(){var e,n,t,r,a;return l(this,(function(s){try{for(e=h(this._feedChannelHandlers.values()),n=e.next();!n.done;n=e.next())(t=n.value).onUnreadMemberStatusUpdated&&t.onUnreadMemberStatusUpdated(m)}catch(e){r={error:e}}finally{try{n&&!n.done&&(a=e.return)&&a.call(e)}finally{if(r)throw r.error}}return[2]}))}))})))})),D.label=12;case 12:return[3,23];case 13:if(!(g="SYEV"===e.code?e.as(pe):null)||g.event.channelType!==this._channelType)return[3,22];switch(y=g.event,y.category){case _e.CHANNEL_INVITE:return[3,14];case _e.CHANNEL_DECLINE_INVITE:return[3,16];case _e.CHANNEL_DELETED:return[3,18];case _e.CHANNEL_PROP_CHANGED:return[3,20]}return[3,22];case 14:return[4,this.getChannel(y.channelUrl,!0)];case 15:return(b=D.sent())._runIfHandleableWithGroupChannel((function(n){var t,r,a=e.as(re),s=a.memberCount,i=a.joinedMemberCount,o=a.invitees;o.forEach((function(e){return e.state=ne.INVITED}));try{for(var c=h(o),l=c.next();!l.done;l=c.next()){var u=l.value;n.isExclusive||n.isSuper||n.isBroadcast?n._setLatestMemberCount(s,i,y.ts):n.addMember(u,y.ts),I._sdkState.userId===u.userId&&(n.hiddenState=ae.UNHIDDEN,n.myMemberState!==ne.JOINED&&(n.myMemberState=ne.INVITED),n.invitedAt=y.ts)}}catch(e){t={error:e}}finally{try{l&&!l.done&&(r=c.return)&&r.call(c)}finally{if(t)throw t.error}}I._dispatcher.dispatch(new J({channels:[b],source:N.EVENT_CHANNEL_INVITED}))})),[3,22];case 16:return[4,this.getChannel(y.channelUrl,!0)];case 17:return(E=D.sent())._runIfHandleableWithGroupChannel((function(n){var t=e.as(te),r=t.memberCount,a=t.joinedMemberCount,s=t.invitee;n.isExclusive||n.isSuper||n.isBroadcast?n._setLatestMemberCount(r,a,y.ts):n.removeMember(s),I._sdkState.userId===s.userId?(n.invitedAt=0,n.myMemberState=ne.NONE,n.isPublic?I._dispatcher.dispatch(new J({channels:[E],source:N.EVENT_CHANNEL_DECLINED_INVITE})):I._dispatcher.dispatch(new Q({channelUrls:[E.url],source:N.EVENT_CHANNEL_DECLINED_INVITE}))):I._dispatcher.dispatch(new J({channels:[E],source:N.EVENT_CHANNEL_DECLINED_INVITE}))})),[3,22];case 18:return[4,this.getChannel(y.channelUrl,!0)];case 19:return w=D.sent(),this._dispatcher.dispatch(new Q({channelUrls:[y.channelUrl],source:N.EVENT_CHANNEL_DELETED})),T((function(){return c(I,void 0,void 0,(function(){return l(this,(function(e){return this._feedChannelHandlers.forEach((function(e){e.onChannelDeleted&&e.onChannelDeleted(w.url,w.channelType)})),[2]}))}))})),[3,22];case 20:return[4,this.getChannelWithoutCache(y.channelUrl,!0)];case 21:return U=D.sent(),this._dispatcher.dispatch(new J({channels:[U],source:N.EVENT_CHANNEL_UPDATED})),T((function(){return c(I,void 0,void 0,(function(){return l(this,(function(e){return this._feedChannelHandlers.forEach((function(e){e.onChannelChanged&&e.onChannelChanged(U)})),[2]}))}))})),[3,22];case 22:return[3,23];case 23:return[2]}}))}))},u}(fe),je=function(e){function n(n,t){var r=e.call(this,n,s(s({},t),{channelManager:Re.of(n)}))||this,a=M.of(r._iid),i=a.connectionManager,o=a.dispatcher;return r._notificationCollectionEventContext=o.on((function(e){e instanceof he&&S(10).then((function(){i.isConnected||i.isConnecting||r.refresh()}))})),r}return t(n,e),n.prototype.dispose=function(){e.prototype.dispose.call(this),this._notificationCollectionEventContext.close()},n.prototype.setMessageCollectionHandler=function(e){this._setBaseMessageCollectionHandler(e)},n.prototype.refresh=function(){return c(this,void 0,void 0,(function(){return l(this,(function(e){switch(e.label){case 0:return[4,this._activate()];case 1:return e.sent(),[2]}}))}))},n}(oe),Ve=function(e){function n(n,t){var r,a,s=this;return(s=e.call(this,n,t)||this).channelType=U.FEED,s._groupChannel=new ce(n,t),s.isCategoryFilterEnabled=null!==(r=t.is_category_filter_enabled)&&void 0!==r&&r,s.isTemplateLabelEnabled=null===(a=t.is_template_label_enabled)||void 0===a||a,s.notificationCategories=t.categories?t.categories.map((function(e){return new ge(e)})):[],s}return t(n,e),n.payloadify=function(e){var n;return s(s({},ce.payloadify(null!==(n=e._groupChannel)&&void 0!==n?n:e)),{is_category_filter_enabled:e.isCategoryFilterEnabled,is_template_label_enabled:e.isTemplateLabelEnabled,categories:e.notificationCategories.map((function(e){return ge.payloadify(e)}))})},Object.defineProperty(n.prototype,"groupChannel",{get:function(){return this._groupChannel},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"url",{get:function(){return this._groupChannel.url},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"name",{get:function(){return this._groupChannel.name},set:function(e){this._groupChannel.name=e},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"createdAt",{get:function(){return this._groupChannel.createdAt},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"members",{get:function(){return this._groupChannel.members},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"memberCount",{get:function(){return this._groupChannel.memberCount},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"myMemberState",{get:function(){return this._groupChannel.myMemberState},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"myLastRead",{get:function(){return this._groupChannel.myLastRead},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"lastMessage",{get:function(){return this._groupChannel.lastMessage},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"unreadMessageCount",{get:function(){return this._groupChannel.unreadMessageCount},enumerable:!1,configurable:!0}),n.prototype.serialize=function(){return s({},this._groupChannel.serialize())},n.prototype.refresh=function(){return c(this,void 0,void 0,(function(){return l(this,(function(e){switch(e.label){case 0:return[4,this._groupChannel._refresh(!0)];case 1:return e.sent(),[2,this]}}))}))},n.prototype.markAsRead=function(){return c(this,void 0,void 0,(function(){var e,n,t,r,a,s,i,o=this;return l(this,(function(c){switch(c.label){case 0:return e=M.of(this._iid),n=e.sdkState,t=e.dispatcher,r=e.requestQueue,a=new le({channelUrl:this.url}),[4,r.send(a)];case 1:return s=c.sent(),i=s.as(se).readStatus,this._groupChannel._updateUnreadMemberState(n.userId,i.readAt),(this._groupChannel.unreadMessageCount>0||this._groupChannel.unreadMentionCount>0)&&(this._groupChannel._updateUnreadCount(0,0),Re.of(this._iid).handlers.map((function(e){e.onChannelChanged&&e.onChannelChanged(o)}))),t.dispatch(new J({channels:[this],source:N.EVENT_CHANNEL_READ})),[2]}}))}))},n.prototype.createNotificationCollection=function(e){return void 0===e&&(e={}),new je(this._iid,s({channel:this},e))},n}(W),Ge=["onUserMuted","onUserUnmuted","onUserBanned","onUserUnbanned","onChannelFrozen","onChannelUnfrozen","onOperatorUpdated","onMetaDataCreated","onMetaDataUpdated","onMetaDataDeleted","onMetaCounterCreated","onMetaCounterUpdated","onMetaCounterDeleted","onReactionUpdated","onThreadInfoUpdated"],Be=function(e){function n(n){void 0===n&&(n={});var t=e.call(this)||this;return Object.keys(n).forEach((function(e){Object.prototype.hasOwnProperty.call(t,e)&&-1===Ge.indexOf(e)&&(t[e]=n[e])})),t}return t(n,e),n}(function(e){function n(){var n=null!==e&&e.apply(this,arguments)||this;return n.onUnreadMemberStatusUpdated=x,n.onUserMuted=x,n.onUserUnmuted=x,n.onUserBanned=x,n.onUserUnbanned=x,n.onChannelFrozen=x,n.onChannelUnfrozen=x,n.onOperatorUpdated=x,n.onMetaDataCreated=x,n.onMetaDataUpdated=x,n.onMetaDataDeleted=x,n.onMetaCounterCreated=x,n.onMetaCounterUpdated=x,n.onMetaCounterDeleted=x,n.onReactionUpdated=x,n.onThreadInfoUpdated=x,n}return t(n,e),n}(me)),qe=function(e){function r(n,t){var r,a=this;return(a=e.call(this,n,t)||this).includeEmpty=be,a.includeEmpty=null!==(r=t.includeEmpty)&&void 0!==r?r:be,a}return t(r,e),r.prototype._validate=function(){return e.prototype._validate.call(this)&&g("boolean",this.includeEmpty)},r.prototype.next=function(){return c(this,void 0,void 0,(function(){var e,t,r,i,o;return l(this,(function(c){switch(c.label){case 0:return this._validate()?this._isLoading?[3,3]:this._hasNext?(this._isLoading=!0,e=Re.of(this._iid),t=n(s({},this)),[4,e.getMyFeedChannels(this._token,t,this.limit)]):[3,2]:[3,5];case 1:return r=c.sent(),i=r.channels,o=r.token,this._token=o,this._hasNext=!!o,this._isLoading=!1,[2,i];case 2:return[2,[]];case 3:throw a.queryInProgress;case 4:return[3,6];case 5:throw a.invalidParameters;case 6:return[2]}}))}))},r}(H),ze=function(e){function n(){var n=null!==e&&e.apply(this,arguments)||this;return n.name="feedChannel",n}return t(n,e),n.prototype.init=function(n,t){e.prototype.init.call(this,n,t),this._manager=new Re(n,t)},n.prototype.createMyFeedChannelListQuery=function(e){return void 0===e&&(e={}),new qe(this._iid,e)},n.prototype.addFeedChannelHandler=function(e,n){r(g("string",e)&&n instanceof Be).throw(a.invalidParameters),this._manager.addHandler(e,n)},n.prototype.removeFeedChannelHandler=function(e){r(g("string",e)).throw(a.invalidParameters),this._manager.removeHandler(e)},n.prototype.removeAllFeedChannelHandlers=function(){this._manager.clearHandler()},n.prototype.getChannel=function(e){return c(this,void 0,void 0,(function(){return l(this,(function(n){return r(g("string",e)).throw(a.invalidParameters),[2,this._manager.getChannel(e)]}))}))},n.prototype.getMyFeedChannelChangeLogsByTimestamp=function(e,n){return void 0===n&&(n={}),c(this,void 0,void 0,(function(){var t;return l(this,(function(i){switch(i.label){case 0:return t=s(s({},Ie),n),r(g("number",e)&&De(t)).throw(a.invalidParameters),[4,this._manager.getMyFeedChannelChangeLogs(e,t)];case 1:return[2,i.sent()]}}))}))},n.prototype.getMyFeedChannelChangeLogsByToken=function(e,n){return void 0===n&&(n={}),c(this,void 0,void 0,(function(){var t;return l(this,(function(i){switch(i.label){case 0:return t=s(s({},Ie),n),r(g("string",e)&&De(t)).throw(a.invalidParameters),[4,this._manager.getMyFeedChannelChangeLogs(e,t)];case 1:return[2,i.sent()]}}))}))},n.prototype.getTotalUnreadMessageCount=function(e){return void 0===e&&(e={}),c(this,void 0,void 0,(function(){return l(this,(function(n){switch(n.label){case 0:return[4,this._manager.getTotalUnreadMessageCount(e)];case 1:return[2,n.sent()]}}))}))},n.prototype.getGlobalNotificationChannelSetting=function(){return c(this,void 0,void 0,(function(){return l(this,(function(e){switch(e.label){case 0:return[4,this._manager.getGlobalNotificationChannelSetting()];case 1:return[2,e.sent()]}}))}))},n.prototype.getNotificationTemplateListByToken=function(e,n){return void 0===n&&(n={}),c(this,void 0,void 0,(function(){return l(this,(function(t){switch(t.label){case 0:return[4,this._manager.getNotificationTemplateListByToken(e,n)];case 1:return[2,t.sent()]}}))}))},n.prototype.getNotificationTemplate=function(e){return c(this,void 0,void 0,(function(){return l(this,(function(n){switch(n.label){case 0:return[4,this._manager.getNotificationTemplate(e)];case 1:return[2,n.sent()]}}))}))},n.prototype.refreshNotificationCollections=function(){this._manager.refreshNotificationCollections()},n}(L);export{Ve as FeedChannel,Be as FeedChannelHandler,qe as FeedChannelListQuery,ze as FeedChannelModule,ge as NotificationCategory,je as NotificationCollection};
+import{e,u as n,_ as t,s as r,q as a,g as i,o as s,p as o,b as c,c as u,a8 as l,r as h,O as d,A as f,d as p,f as v,h as g,b1 as y,ap as m,a as C,ba as b,aH as E,K as w,V as M,ak as N,W as k,x as T,X as U,Y as x,al as S,B as A,aA as I,b5 as D,am as F,aq as H,aF as L,aN as P}from"./lib/__bundle-0f850482.js";import{i as j,aD as O,a9 as R,aE as G,aF as V,J as B,w as q}from"./lib/__bundle-684d6267.js";export{a9 as NotificationMessage}from"./lib/__bundle-684d6267.js";import{F as Q,D as z,E as W,I as J,J as Y,K as X,p as K,L as $,N as ee,V as ne,W as te,c as re,X as ae,Y as ie}from"./lib/__bundle-37e3f19f.js";export{Z as FeedChannelEventContext,_ as NotificationEventContext}from"./lib/__bundle-37e3f19f.js";import{g as se,N as oe}from"./lib/__bundle-ce97f401.js";import{D as ce}from"./lib/__bundle-1ab3a4b7.js";import{B as ue,C as le,a as he}from"./lib/__bundle-fa60a3cc.js";import"./lib/__bundle-c336221f.js";var de=function(){function t(e){this.id=e.id,this.name=e.name,this.isDefault=e.is_default}return t.payloadify=function(t){return e(n({id:t.id,name:t.name,is_default:t.isDefault}))},Object.defineProperty(t.prototype,"customType",{get:function(){return this.isDefault?"*":String(this.id)},enumerable:!1,configurable:!0}),t}(),fe=function(n){function l(e,t){var r=t.sdkState,a=t.cacheContext,i=t.channelManager,s=n.call(this,e)||this;return s._channels=new Map,s._sdkState=r,s._cacheContext=a,s._channelManager=i,s}return t(l,n),Object.defineProperty(l.prototype,"collection",{get:function(){var e=this._cacheContext.nestdb;return r(!!e).throw(a.databaseError),e.collection(j)},enumerable:!1,configurable:!0}),Object.defineProperty(l.prototype,"localCacheEnabled",{get:function(){return this._cacheContext.localCacheEnabled&&!!this.collection},enumerable:!1,configurable:!0}),l.prototype._serialize=function(e,n){return void 0===n&&(n=0),i(i({},e.serialize()),{lastMessageUpdatedAt:e.lastMessage?e.lastMessage.createdAt:0,syncIndex:n})},l.prototype._deserialize=function(e){return this._channelManager.buildFeedChannelFromSerializedData(e)},Object.defineProperty(l.prototype,"channels",{get:function(){return s([],o(this._channels.values()),!1)},enumerable:!1,configurable:!0}),l.prototype.isCachedInMemory=function(e){return this._channels.has(e)},l.prototype.get=function(e){return c(this,void 0,void 0,(function(){var n;return u(this,(function(t){switch(t.label){case 0:return this._channels.has(e)?[3,3]:this.localCacheEnabled?[4,this.collection.getByKey(e)]:[3,2];case 1:if(n=t.sent())return this._channels.set(e,this._deserialize(n)),[2,this._channels.get(e)];t.label=2;case 2:return[2,void 0];case 3:return[2,this._channels.get(e)]}}))}))},l.prototype.fetch=function(e){var n=e.token,t=e.limit,r=void 0===t?O:t,a=e.backward,i=void 0!==a&&a,s=e.order,o=void 0===s?"latest_last_message":s,l=e.borderlineChannelUrl;return c(this,void 0,void 0,(function(){var e,t,a,s,c=this;return u(this,(function(u){switch(u.label){case 0:return this.localCacheEnabled?(e=se(o),t={where:function(e){if(n&&"latest_last_message"===o){if(!i&&e.lastMessageUpdatedAt>n||i&&e.lastMessageUpdatedAt0&&this._dispatcher.dispatch(new z({channels:d,source:s})),f.length>0&&this._dispatcher.dispatch(new Q({channelUrls:f,source:s})),[2,{updatedChannels:d,deletedChannelUrls:f,hasMore:p,token:v}]}}))}))},l.prototype.getTotalUnreadMessageCount=function(e){return c(this,void 0,void 0,(function(){var n,t,s,o,c,l,h;return u(this,(function(u){switch(u.label){case 0:return n=i(i({},J),e),r(Y(n)).throw(a.invalidParameters),t=M.of(this._iid),s=t.sdkState,o=t.requestQueue,c=new X({userId:s.userId,filter:n,includeFeedChannel:!0}),[4,o.send(c)];case 1:return l=u.sent(),h=l.as(W).unreadFeedCount,[2,void 0===h?0:h]}}))}))},l.prototype.getGlobalNotificationChannelSetting=function(){return c(this,void 0,void 0,(function(){var e,n;return u(this,(function(t){switch(t.label){case 0:return e=new Me,[4,this._requestQueue.send(e)];case 1:return n=t.sent(),[2,{jsonString:n.as(Ne).jsonString}]}}))}))},l.prototype.getNotificationTemplateListByToken=function(e,n){return void 0===n&&(n={}),c(this,void 0,void 0,(function(){var t,s,o,c,l,h,d;return u(this,(function(u){switch(u.label){case 0:return t=i(i({},Ue),n),r(C("string",e)&&function(e){return C("boolean",e.reverse,!0)&&w("string",e.keys,!0)&&C("number",e.limit,!0)}(t)).throw(a.invalidParameters),s=new ke({token:e,keys:t.keys,reverse:t.reverse,limit:t.limit}),[4,this._requestQueue.send(s)];case 1:return o=u.sent(),c=o.as(Te),l=c.hasMore,h=c.nextToken,d=c.notificationTemplateList,[2,{hasMore:l,token:h,notificationTemplateList:d}]}}))}))},l.prototype.getNotificationTemplate=function(e){return c(this,void 0,void 0,(function(){var n,t;return u(this,(function(i){switch(i.label){case 0:return r(C("string",e)).throw(a.invalidParameters),n=new xe({key:e}),[4,this._requestQueue.send(n)];case 1:return t=i.sent(),[2,{jsonString:t.as(Se).jsonString}]}}))}))},l.prototype.upsertChannelsToCache=function(e){return c(this,void 0,void 0,(function(){return u(this,(function(n){switch(n.label){case 0:return[4,this._feedChannelCache.upsert(e)];case 1:return[2,n.sent()]}}))}))},l.prototype.removeChannelsFromCache=function(e){return c(this,void 0,void 0,(function(){return u(this,(function(n){switch(n.label){case 0:return[4,this._feedChannelCache.remove(e)];case 1:return n.sent(),[2]}}))}))},l.prototype.refreshChannel=function(e,n,t){return void 0===n&&(n=!0),void 0===t&&(t=U.REFRESH_CHANNEL),c(this,void 0,void 0,(function(){var r,a,i,s,o;return u(this,(function(c){switch(c.label){case 0:return c.trys.push([0,5,,6]),r=new ye({channelUrl:e,isInternalCall:n}),[4,this._requestQueue.send(r)];case 1:return a=c.sent(),(i=a.as(me).channel).myMemberState!==K.NONE?[3,2]:(this._dispatcher.dispatch(new Q({channelUrls:[i.url],source:t})),[3,4]);case 2:return[4,this.upsertChannelsToCache([i])];case 3:s=c.sent(),this._dispatcher.dispatch(new z({channels:s,source:t})),c.label=4;case 4:return[3,6];case 5:return(o=c.sent()).code!==S.NON_AUTHORIZED&&o.code!==S.NOT_FOUND_IN_DATABASE||this._dispatcher.dispatch(new Q({channelUrls:[e],source:t})),[3,6];case 6:return[2]}}))}))},l.prototype.refreshNotificationCollections=function(){this._dispatcher.dispatch(new oe)},l.prototype.subscribeChannelEvent=function(e,n){this._feedChannelBroadcast.subscribe(e,n)},l.prototype.unsubscribeChannelEvent=function(e){this._feedChannelBroadcast.unsubscribe(e)},l.prototype._handleEvent=function(e){return c(this,void 0,void 0,(function(){var n,t,r,a,i,s,o,l,d,f,p=this;return u(this,(function(v){switch(v.label){case 0:switch(e.code){case"ADMM":case"BRDM":return[3,1];case"READ":return[3,4];case"SYEV":return[3,7]}return[3,13];case 1:return(o="ADMM"===e.code||"BRDM"===e.code?e.as(Ae):null)&&o.message.channelType===this._channelType?(n=o.message,t=o.isMentioned,[4,this.getChannel(n.channelUrl,!0)]):[3,3];case 2:(r=v.sent())._runIfHandleableWithGroupChannel((function(e){var a;n instanceof R&&t&&(null===(a=n.mentionedUsers)||void 0===a||a.forEach((function(n){var t,r;try{for(var a=h(e.members),i=a.next();!i.done;i=a.next()){var s=i.value;if(n.userId===s.userId){n.nickname=s.nickname,n.plainProfileUrl=s.plainProfileUrl,n.metaData=s.metaData;break}}}catch(e){t={error:e}}finally{try{i&&!i.done&&(r=a.return)&&r.call(a)}finally{if(t)throw t.error}}}))),p._dispatcher.dispatch(new z({channels:[r],source:U.EVENT_MESSAGE_RECEIVED})),p._dispatcher.dispatch(new I({messages:[n],source:U.EVENT_MESSAGE_RECEIVED})),A((function(){return c(p,void 0,void 0,(function(){var e,a,i,s,o;return u(this,(function(c){try{for(e=h(this._feedChannelHandlers.values()),a=e.next();!a.done;a=e.next())(i=a.value).onMessageReceived&&i.onMessageReceived(r,n),t&&i.onMentionReceived&&i.onMentionReceived(r,n)}catch(e){s={error:e}}finally{try{a&&!a.done&&(o=e.return)&&o.call(e)}finally{if(s)throw s.error}}return[2]}))}))}))})),v.label=3;case 3:return[3,13];case 4:return(o="READ"===e.code?e.as($):null)?(a=o.readStatus,i=this._feedChannelCache.isCachedInMemory(a.channelUrl),[4,this.getChannel(a.channelUrl,!0)]):[3,6];case 5:(s=v.sent())._runIfHandleableWithGroupChannel((function(e){i&&e._updateUnreadMemberState(a.reader.userId,a.readAt),a.reader.userId===p._sdkState.userId?i?(e.unreadMessageCount>0||e.unreadMentionCount>0)&&(e._updateUnreadCount(0,0),p._dispatcher.dispatch(new z({channels:[s],source:U.EVENT_CHANNEL_READ})),A((function(){return c(p,void 0,void 0,(function(){var e,n,t,r,a;return u(this,(function(i){try{for(e=h(this._feedChannelHandlers.values()),n=e.next();!n.done;n=e.next())(t=n.value).onChannelChanged&&t.onChannelChanged(s)}catch(e){r={error:e}}finally{try{n&&!n.done&&(a=e.return)&&a.call(e)}finally{if(r)throw r.error}}return[2]}))}))}))):0!==e.unreadMessageCount&&0!==e.unreadMentionCount||(p._dispatcher.dispatch(new z({channels:[s],source:U.EVENT_CHANNEL_READ})),A((function(){return c(p,void 0,void 0,(function(){var e,n,t,r,a;return u(this,(function(i){try{for(e=h(this._feedChannelHandlers.values()),n=e.next();!n.done;n=e.next())(t=n.value).onChannelChanged&&t.onChannelChanged(s)}catch(e){r={error:e}}finally{try{n&&!n.done&&(a=e.return)&&a.call(e)}finally{if(r)throw r.error}}return[2]}))}))}))):(p._dispatcher.dispatch(new z({channels:[s],source:U.EVENT_CHANNEL_READ})),A((function(){return c(p,void 0,void 0,(function(){var e,n,t,r,a;return u(this,(function(i){try{for(e=h(this._feedChannelHandlers.values()),n=e.next();!n.done;n=e.next())(t=n.value).onUnreadMemberStatusUpdated&&t.onUnreadMemberStatusUpdated(s)}catch(e){r={error:e}}finally{try{n&&!n.done&&(a=e.return)&&a.call(e)}finally{if(r)throw r.error}}return[2]}))}))})))})),v.label=6;case 6:return[3,13];case 7:if(!(o="SYEV"===e.code?e.as(le):null)||o.event.channelType!==this._channelType)return[3,12];switch(l=o.event,l.category){case he.CHANNEL_DELETED:return[3,8];case he.CHANNEL_PROP_CHANGED:return[3,10]}return[3,12];case 8:return[4,this.getChannel(l.channelUrl,!0)];case 9:return d=v.sent(),this._dispatcher.dispatch(new Q({channelUrls:[l.channelUrl],source:U.EVENT_CHANNEL_DELETED})),A((function(){return c(p,void 0,void 0,(function(){return u(this,(function(e){return this._feedChannelHandlers.forEach((function(e){e.onChannelDeleted&&e.onChannelDeleted(d.url,d.channelType)})),[2]}))}))})),[3,12];case 10:return[4,this.getChannelWithoutCache(l.channelUrl,!0)];case 11:return f=v.sent(),this._dispatcher.dispatch(new z({channels:[f],source:U.EVENT_CHANNEL_UPDATED})),A((function(){return c(p,void 0,void 0,(function(){return u(this,(function(e){return this._feedChannelHandlers.forEach((function(e){e.onChannelChanged&&e.onChannelChanged(f)})),[2]}))}))})),[3,12];case 12:return[3,13];case 13:return[2]}}))}))},l.prototype.getMessageFromCache=function(e){var n;return c(this,void 0,void 0,(function(){return u(this,(function(t){switch(t.label){case 0:return[4,this._notificationMessageCache.get(e)];case 1:return[2,null!==(n=t.sent())&&void 0!==n?n:null]}}))}))},l.prototype.getExactlyMatchingMessagesForTokenFromCache=function(e,n,t){return c(this,void 0,void 0,(function(){return u(this,(function(r){switch(r.label){case 0:return[4,this._notificationMessageCache.fetch({channelUrl:e,token:n,filter:t,exactMatch:!0})];case 1:return[2,r.sent()]}}))}))},l.prototype.getMessagesFromCache=function(e,n,t,r,a,i){return void 0===a&&(a=V),void 0===i&&(i=!0),c(this,void 0,void 0,(function(){return u(this,(function(s){switch(s.label){case 0:return[4,this._notificationMessageCache.fetch({channelUrl:e,token:n,limit:a,filter:r,backward:"next"===t,inclusive:i})];case 1:return[2,s.sent()]}}))}))},l}(ue),Fe=function(e){function n(n,t){var r=e.call(this,n,i(i({},t),{channelManager:De.of(n)}))||this,a=M.of(r._iid),s=a.connectionManager,o=a.dispatcher;return r._notificationCollectionEventContext=o.on((function(e){e instanceof oe&&F(10).then((function(){s.isConnected||s.isConnecting||r.refresh()}))})),r}return t(n,e),n.prototype.keyOf=function(e){return e.notificationId},n.prototype.dispose=function(){e.prototype.dispose.call(this),this._notificationCollectionEventContext.close()},n.prototype.setMessageCollectionHandler=function(e){this._setBaseMessageCollectionHandler(e)},n.prototype._addMessagesToView=function(e,n){var t,r,a=this,i=this._filterUnderOffsetMessage(e),s=[],o=[];try{for(var l=h(i),d=l.next();!d.done;d=l.next()){var f,p=d.value;if(n===U.SYNC_MESSAGE_FILL){if((f=ee(this._messages,p))<0){var v=ne(this._messages,p);this._messages.splice(v,0,p),s.push(p)}}else if((f=ee(this._messages,p))<0){v=ne(this._messages,p);this._messages.splice(v,0,p),s.push(p)}else this._messages[f]=p,o.push(p)}}catch(e){t={error:e}}finally{try{d&&!d.done&&(r=l.return)&&r.call(l)}finally{if(t)throw t.error}}D(n)&&A((function(){return c(a,void 0,void 0,(function(){var e,t,r,a,i;return u(this,(function(c){return e=this._createMessageEventContext(n),s.length>0&&(null===(r=null===(t=this._handler)||void 0===t?void 0:t.onMessagesAdded)||void 0===r||r.call(t,e,this.channel,s)),o.length>0&&(null===(i=null===(a=this._handler)||void 0===a?void 0:a.onMessagesUpdated)||void 0===i||i.call(a,e,this.channel,o)),[2]}))}))}))},n.prototype._updateMessagesToView=function(e,n){var t,r,a=this,i=[];try{for(var s=h(e),o=s.next();!o.done;o=s.next()){var l=o.value,d=ee(this._messages,l);d>=0&&(i.push(l),this._messages[d]=l)}}catch(e){t={error:e}}finally{try{o&&!o.done&&(r=s.return)&&r.call(s)}finally{if(t)throw t.error}}return D(n)&&A((function(){return c(a,void 0,void 0,(function(){var e,t,r;return u(this,(function(a){return e=this._createMessageEventContext(n),i.length>0&&(null===(r=null===(t=this._handler)||void 0===t?void 0:t.onMessagesUpdated)||void 0===r||r.call(t,e,this.channel,i)),[2]}))}))})),i},n.prototype.refresh=function(){return c(this,void 0,void 0,(function(){return u(this,(function(e){switch(e.label){case 0:return[4,this._activate()];case 1:return e.sent(),[2]}}))}))},n}(te),He=function(e){function n(n,t){var r,a,s=this;return(s=e.call(this,n,t)||this).channelType=x.FEED,s._groupChannel=new re(n,t),s.isCategoryFilterEnabled=null!==(r=t.is_category_filter_enabled)&&void 0!==r&&r,s.isTemplateLabelEnabled=null===(a=t.is_template_label_enabled)||void 0===a||a,s.notificationCategories=t.categories?t.categories.map((function(e){return new de(e)})):[],s.lastMessage=t.last_message?B(s._iid,i({channel_type:s.channelType},t.last_message)):null,s}return t(n,e),n.payloadify=function(e){var n;return i(i({},re.payloadify(null!==(n=e._groupChannel)&&void 0!==n?n:e)),{is_category_filter_enabled:e.isCategoryFilterEnabled,is_template_label_enabled:e.isTemplateLabelEnabled,categories:e.notificationCategories.map((function(e){return de.payloadify(e)})),last_message:e.lastMessage?R.payloadify(e.lastMessage):null})},Object.defineProperty(n.prototype,"groupChannel",{get:function(){return this._groupChannel},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"url",{get:function(){return this._groupChannel.url},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"name",{get:function(){return this._groupChannel.name},set:function(e){this._groupChannel.name=e},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"createdAt",{get:function(){return this._groupChannel.createdAt},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"members",{get:function(){return this._groupChannel.members},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"memberCount",{get:function(){return this._groupChannel.memberCount},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"myMemberState",{get:function(){return this._groupChannel.myMemberState},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"myLastRead",{get:function(){return this._groupChannel.myLastRead},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"unreadMessageCount",{get:function(){return this._groupChannel.unreadMessageCount},enumerable:!1,configurable:!0}),n.prototype.serialize=function(){return i(i({},this._groupChannel.serialize()),{notificationCategories:this.notificationCategories,lastMessage:this.lastMessage})},n.prototype.refresh=function(){return c(this,void 0,void 0,(function(){return u(this,(function(e){switch(e.label){case 0:return[4,this._groupChannel._refresh(!0)];case 1:return e.sent(),[2,this]}}))}))},n.prototype.markAsRead=function(){return c(this,void 0,void 0,(function(){var e,n,t,r,a,i,s,o=this;return u(this,(function(c){switch(c.label){case 0:return e=M.of(this._iid),n=e.sdkState,t=e.dispatcher,r=e.requestQueue,a=new ie({userId:n.userId,channelUrl:this.url,channelType:x.FEED}),[4,r.send(a)];case 1:return i=c.sent(),s=i.as(ae).readAt,this._groupChannel._updateUnreadMemberState(n.userId,s),(this._groupChannel.unreadMessageCount>0||this._groupChannel.unreadMentionCount>0)&&(this._groupChannel._updateUnreadCount(0,0),De.of(this._iid).handlers.map((function(e){e.onChannelChanged&&e.onChannelChanged(o)}))),t.dispatch(new z({channels:[this],source:U.EVENT_CHANNEL_READ})),[2]}}))}))},n.prototype.createNotificationCollection=function(e){return void 0===e&&(e={}),new Fe(this._iid,i({channel:this},e))},n}(q),Le=function(e){function n(n){void 0===n&&(n={});var t=e.call(this)||this;return Object.keys(n).forEach((function(e){Object.prototype.hasOwnProperty.call(t,e)&&(t[e]=n[e])})),t}return t(n,e),n}((function(){this.onChannelChanged=H,this.onChannelDeleted=H,this.onUnreadMemberStatusUpdated=H,this.onMessageReceived=H,this.onMentionReceived=H})),Pe=function(e){function r(n,t){var r,a=this;return(a=e.call(this,n,t)||this).includeEmpty=ve,a.includeEmpty=null!==(r=t.includeEmpty)&&void 0!==r?r:ve,a}return t(r,e),r.prototype._validate=function(){return e.prototype._validate.call(this)&&C("boolean",this.includeEmpty)},r.prototype.next=function(){return c(this,void 0,void 0,(function(){var e,t,r,s,o;return u(this,(function(c){switch(c.label){case 0:return this._validate()?this._isLoading?[3,3]:this._hasNext?(this._isLoading=!0,e=De.of(this._iid),t=n(i({},this)),[4,e.getMyFeedChannels(this._token,t,this.limit)]):[3,2]:[3,5];case 1:return r=c.sent(),s=r.channels,o=r.token,this._token=o,this._hasNext=!!o,this._isLoading=!1,[2,s];case 2:return[2,[]];case 3:throw a.queryInProgress;case 4:return[3,6];case 5:throw a.invalidParameters;case 6:return[2]}}))}))},r}(L),je=function(e){function n(){var n=null!==e&&e.apply(this,arguments)||this;return n.name="feedChannel",n}return t(n,e),n.prototype.init=function(n,t){e.prototype.init.call(this,n,t),this._manager=new De(n,t)},n.prototype.createMyFeedChannelListQuery=function(e){return void 0===e&&(e={}),new Pe(this._iid,e)},n.prototype.addFeedChannelHandler=function(e,n){r(C("string",e)&&n instanceof Le).throw(a.invalidParameters),this._manager.addHandler(e,n)},n.prototype.removeFeedChannelHandler=function(e){r(C("string",e)).throw(a.invalidParameters),this._manager.removeHandler(e)},n.prototype.removeAllFeedChannelHandlers=function(){this._manager.clearHandler()},n.prototype.getChannel=function(e){return c(this,void 0,void 0,(function(){return u(this,(function(n){return r(C("string",e)).throw(a.invalidParameters),[2,this._manager.getChannel(e)]}))}))},n.prototype.getMyFeedChannelChangeLogsByTimestamp=function(e,n){return void 0===n&&(n={}),c(this,void 0,void 0,(function(){var t;return u(this,(function(s){switch(s.label){case 0:return t=i(i({},Ce),n),r(C("number",e)&&be(t)).throw(a.invalidParameters),[4,this._manager.getMyFeedChannelChangeLogs(e,t)];case 1:return[2,s.sent()]}}))}))},n.prototype.getMyFeedChannelChangeLogsByToken=function(e,n){return void 0===n&&(n={}),c(this,void 0,void 0,(function(){var t;return u(this,(function(s){switch(s.label){case 0:return t=i(i({},Ce),n),r(C("string",e)&&be(t)).throw(a.invalidParameters),[4,this._manager.getMyFeedChannelChangeLogs(e,t)];case 1:return[2,s.sent()]}}))}))},n.prototype.getTotalUnreadMessageCount=function(e){return void 0===e&&(e={}),c(this,void 0,void 0,(function(){return u(this,(function(n){switch(n.label){case 0:return[4,this._manager.getTotalUnreadMessageCount(e)];case 1:return[2,n.sent()]}}))}))},n.prototype.getGlobalNotificationChannelSetting=function(){return c(this,void 0,void 0,(function(){return u(this,(function(e){switch(e.label){case 0:return[4,this._manager.getGlobalNotificationChannelSetting()];case 1:return[2,e.sent()]}}))}))},n.prototype.getNotificationTemplateListByToken=function(e,n){return void 0===n&&(n={}),c(this,void 0,void 0,(function(){return u(this,(function(t){switch(t.label){case 0:return[4,this._manager.getNotificationTemplateListByToken(e,n)];case 1:return[2,t.sent()]}}))}))},n.prototype.getNotificationTemplate=function(e){return c(this,void 0,void 0,(function(){return u(this,(function(n){switch(n.label){case 0:return[4,this._manager.getNotificationTemplate(e)];case 1:return[2,n.sent()]}}))}))},n.prototype.refreshNotificationCollections=function(){this._manager.refreshNotificationCollections()},n}(P);export{He as FeedChannel,Le as FeedChannelHandler,Pe as FeedChannelListQuery,je as FeedChannelModule,de as NotificationCategory,Fe as NotificationCollection};
diff --git a/groupChannel.js b/groupChannel.js
index 6088b30..a0fee8a 100644
--- a/groupChannel.js
+++ b/groupChannel.js
@@ -1 +1 @@
-import{b as i,V as s,c as h,y as f,z as v,q as _,o as g,p as E,X as L,H as T,r as F,B as N,m as D,aX as I,aY as V,u as K,g as j,al as W,O as Y,_ as X,A as J,ap as Z,e as $,f as ee,h as te,a as ne,K as ae,Q as re,aF as ie,aq as se,aZ as oe,af as le,s as ue,aN as ce}from"./lib/__bundle-753d9ea0.js";export{a_ as MessageEventSource,a$ as MutedState}from"./lib/__bundle-753d9ea0.js";import{S as he,G as de,s as pe,a as fe,b as me,P as ve,c as _e,d as ge,e as ye,f as Ce,v as be,g as Me,h as Se,i as Ee,j as we}from"./lib/__bundle-6aed501c.js";export{C as CountPreference,c as GroupChannel,b as GroupChannelEventContext,k as GroupChannelEventSource,a as GroupChannelFilter,e as GroupChannelListQuery,l as GroupChannelSearchField,H as HiddenChannelFilter,m as HiddenState,M as Member,n as MemberListOrder,o as MemberListQuery,p as MemberState,q as MemberStateFilter,t as MessageCollection,u as MessageCollectionInitHandler,w as MessageCollectionInitPolicy,x as MessageEventContext,y as MutedMemberFilter,r as MyMemberStateFilter,O as OperatorFilter,z as PinnedMessage,A as PinnedMessageListQuery,P as PublicChannelFilter,Q as QueryType,R as ReadStatus,d as SuperChannelFilter,U as UnreadChannelFilter,B as UnreadItemKey}from"./lib/__bundle-6aed501c.js";import{G as Le,P as Te,S as Ae}from"./lib/__bundle-743309b9.js";export{G as GroupChannelListOrder,P as PublicGroupChannelListOrder,S as ScheduledMessageListOrder}from"./lib/__bundle-743309b9.js";import{T as ke,B as Fe}from"./lib/__bundle-b19328da.js";import{D as Ne,E as Ge,G as xe}from"./lib/__bundle-2cf97ad3.js";export{z as MessageFilter,G as ScheduledStatus}from"./lib/__bundle-2cf97ad3.js";import"./lib/__bundle-c336221f.js";var Ue,Oe={},De=function(){function e(e){var t=e._iid,n=e.limit,a=void 0===n?100:n,r=this;this.ref=0,this._iid=t,this._limit=a;var o,l=s.of(this._iid),u=l.sdkState,c=l.dispatcher,d=l.logger,p=l.cacheContext;this._metadataKey=(o=u.userId,"sendbird:".concat(o,"@groupchannel/sync.meta"));var m=function(e){return"sendbird:".concat(e,"@groupchannel/sync")}(u.userId);this._sync=new he(m,(function(){return i(r,void 0,void 0,(function(){var e,t,n,a,r,i,s,o,l,c,f,m;return h(this,(function(h){switch(h.label){case 0:return e={hasNext:!0,nextToken:""},[4,this.loadMetadata()];case 1:if(h.sent(),d.debug("channel background sync from",null===(l=this._metadata)||void 0===l?void 0:l.token),null===(c=this._metadata)||void 0===c?void 0:c.completed)return[3,13];h.label=2;case 2:if(h.trys.push([2,9,,12]),(t={includeEmpty:!0,order:Le.CHRONOLOGICAL}).order!==Le.LATEST_LAST_MESSAGE)return[3,6];h.label=3;case 3:return h.trys.push([3,5,,6]),[4,p.preference.get(T(u.appId))];case 4:return n=h.sent(),t.includeChatNotification=Boolean(n),[3,6];case 5:return h.sent(),t.includeChatNotification=!1,[3,6];case 6:return[4,de.of(this._iid).getMyGroupChannels(null!==(m=null===(f=this._metadata)||void 0===f?void 0:f.token)&&void 0!==m?m:"",t,this._limit,L.SYNC_CHANNEL_BACKGROUND)];case 7:return a=h.sent(),r=a.channels,i=a.token,e.hasNext=r.length>=this._limit&&!!i,e.nextToken=i,this._metadata&&(this._metadata.token=i,(o=this._metadata.range).extends.apply(o,g([],E(r.map((function(e){return e.createdAt}))),!1)),this._metadata.completed=!e.hasNext),d.debug("channel background sync progress",e),[4,this.saveMetadata()];case 8:return h.sent(),[3,12];case 9:return s=h.sent(),d.debug("channel background sync error",s),s instanceof _&&s.isInvalidTokenError?[4,this.clearMetaData()]:[3,11];case 10:h.sent(),h.label=11;case 11:throw s;case 12:return[3,14];case 13:e.hasNext=!1,e.nextToken="",h.label=14;case 14:return[2,e]}}))}))})),this._connectionEventContext=c.on((function(e){if(e instanceof f)if(e.stateType===v.CONNECTED)r.resume();else r.pause()}))}return e.of=function(t){return Oe[t]||(Oe[t]=new e({_iid:t})),Oe[t].ref++,Oe[t]},e.clear=function(e){Oe[e]&&(Oe[e].close(),delete Oe[e])},Object.defineProperty(e.prototype,"range",{get:function(){var e,t;return null!==(t=null===(e=this._metadata)||void 0===e?void 0:e.range)&&void 0!==t?t:new ke({})},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"completed",{get:function(){var e;return!!(null===(e=this._metadata)||void 0===e?void 0:e.completed)},enumerable:!1,configurable:!0}),e.prototype.loadMetadata=function(){return i(this,void 0,void 0,(function(){var e;return h(this,(function(t){switch(t.label){case 0:return this._metadata?[3,2]:[4,s.of(this._iid).cacheContext.preference.get(this._metadataKey)];case 1:e=t.sent(),this._metadata={token:e?e.token:"",range:new ke(e?e.range:{top:Number.MAX_SAFE_INTEGER,bottom:0}),completed:!!e&&e.completed},t.label=2;case 2:return[2,this._metadata]}}))}))},e.prototype.saveMetadata=function(){return i(this,void 0,void 0,(function(){return h(this,(function(e){switch(e.label){case 0:return this._metadata?[4,s.of(this._iid).cacheContext.preference.set(this._metadataKey,this._metadata)]:[3,2];case 1:return e.sent(),[2,!0];case 2:return[2,!1]}}))}))},e.prototype.clearMetaData=function(){return i(this,void 0,void 0,(function(){return h(this,(function(e){switch(e.label){case 0:return[4,s.of(this._iid).cacheContext.preference.remove(this._metadataKey)];case 1:return e.sent(),this._metadata=void 0,[2]}}))}))},e.prototype.resume=function(){var e,t,n=s.of(this._iid),a=n.logger;n.connectionManager.isConnected&&(a.debug("channel background sync resume()"),this._sync.start(null!==(t=null===(e=this._metadata)||void 0===e?void 0:e.token)&&void 0!==t?t:""))},e.prototype.pause=function(){s.of(this._iid).logger.debug("channel background sync stop()"),this._sync.stop()},e.prototype.close=function(){this.ref--,this.ref<=0&&(this.ref=0,this.pause(),this._connectionEventContext.close(),delete Oe[this._iid])},e}(),Pe={},Ie=function(){function e(e){var t=e._iid,n=this;this.ref=0,this._iid=t;var a,r=s.of(this._iid),o=r.logger,l=r.sdkState,u=r.dispatcher,c=r.cacheContext;this._metadataKey=(a=l.userId,"sendbird:".concat(a,"@groupchannel/changelogs.meta"));var d=function(e){return"sendbird:".concat(e,"@groupchannel/changelogs")}(l.userId);this._sync=new he(d,(function(){return i(n,void 0,void 0,(function(){var e,t,n,a,r,i,s,u,d,p;return h(this,(function(h){switch(h.label){case 0:return e={hasNext:!0,nextToken:0},[4,this.loadMetadata()];case 1:h.sent(),o.debug("channel changelog sync from",null===(u=this._metadata)||void 0===u?void 0:u.token),h.label=2;case 2:h.trys.push([2,9,,12]),t={includeEmpty:!0},h.label=3;case 3:return h.trys.push([3,5,,6]),[4,c.preference.get(T(l.appId))];case 4:return n=h.sent(),t.includeChatNotification=Boolean(n),[3,6];case 5:return h.sent(),t.includeChatNotification=!1,[3,6];case 6:return[4,de.of(this._iid).getMyGroupChannelChangeLogs(null!==(p=null===(d=this._metadata)||void 0===d?void 0:d.token)&&void 0!==p?p:"",t,L.SYNC_CHANNEL_CHANGELOGS)];case 7:return a=h.sent(),r=a.hasMore,i=a.token,e.hasNext=r,e.nextToken=i,this._metadata&&(this._metadata.token=i),o.debug("channel changelog sync progress",e),[4,this.saveMetadata()];case 8:return h.sent(),[3,12];case 9:return s=h.sent(),o.debug("channel changelog sync error",s),s instanceof _&&s.isInvalidTokenError?[4,this.clearMetadata()]:[3,11];case 10:h.sent(),h.label=11;case 11:throw s;case 12:return[2,e]}}))}))})),this._connectionEventContext=u.on((function(e){if(e instanceof f)if(e.stateType===v.CONNECTED)n.resume();else n.pause()}))}return e.of=function(t){return Pe[t]||(Pe[t]=new e({_iid:t})),Pe[t].ref++,Pe[t]},e.clear=function(e){Pe[e]&&(Pe[e].close(),delete Pe[e])},e.prototype.loadMetadata=function(){return i(this,void 0,void 0,(function(){var e,t,n,a;return h(this,(function(r){switch(r.label){case 0:return this._metadata?[3,2]:(e=s.of(this._iid),t=e.cacheContext,n=e.firstConnectedAt,[4,t.preference.get(this._metadataKey)]);case 1:a=r.sent(),this._metadata={token:a?a.token:n},r.label=2;case 2:return[2,this._metadata]}}))}))},e.prototype.saveMetadata=function(){return i(this,void 0,void 0,(function(){return h(this,(function(e){switch(e.label){case 0:return this._metadata?[4,s.of(this._iid).cacheContext.preference.set(this._metadataKey,this._metadata)]:[3,2];case 1:return e.sent(),[2,!0];case 2:return[2,!1]}}))}))},e.prototype.clearMetadata=function(){return i(this,void 0,void 0,(function(){return h(this,(function(e){switch(e.label){case 0:return[4,s.of(this._iid).cacheContext.preference.remove(this._metadataKey)];case 1:return e.sent(),this._metadata=void 0,[2]}}))}))},e.prototype.resume=function(){s.of(this._iid).connectionManager.isConnected&&this._sync.start(0)},e.prototype.pause=function(){this._sync.stop()},e.prototype.close=function(){this.ref--,this.ref<=0&&(this.ref=0,this.pause(),this._connectionEventContext.close(),delete Pe[this._iid])},e}(),He=function(e,t){return e.findIndex((function(e){return e.isIdentical(t)}))},Re=function(e,t,n){if(e.length>0){for(var a=He(e,t),r=0,i=e.length-1,s=Math.floor((r+i)/2);r0)i=s,s=Math.floor((r+i)/2);else{if(!(o<0))return{place:s,oldPosition:a};r=s+1,s=Math.floor((r+i)/2)}}return{place:Ve(e[s],t,n)>=0?s:s+1,oldPosition:a}}return{place:e.length,oldPosition:-1}},Ve=function(e,t,n){switch(n){case Le.LATEST_LAST_MESSAGE:return e.lastMessage&&t.lastMessage?t.lastMessage.createdAt-e.lastMessage.createdAt:e.lastMessage?-1:t.lastMessage?1:t.createdAt-e.createdAt;case Le.CHRONOLOGICAL:return t.createdAt-e.createdAt;case Le.CHANNEL_NAME_ALPHABETICAL:var a=e.name.localeCompare(t.name);return 0===a?e.createdAt-t.createdAt:a;default:return 0}},Ke=function(){function e(e,t){var n=t.filter,a=t.order,r=t.limit,o=this;this.channels=[],this._iid=e,this._key="gcc-".concat(D()),this._isDisposed=!1,this._isGetRemoteChannelsSucceeded=!0,this.filter=null!=n?n:new fe,this.order=null!=a?a:Le.LATEST_LAST_MESSAGE,this._hasMore=!0,this._token="",this._limit=null!=r?r:Ne;var l=s.of(this._iid),u=l.sdkState,c=l.cacheContext,d=l.dispatcher;c.localCacheEnabled&&(this._backgroundSync=De.of(e),this._backgroundSync.resume()),this._changelogSync=Ie.of(e),this._changelogSync.resume(),de.of(this._iid).subscribeChannelEvent(this._key,{onUpdate:function(e,t){if(pe(t)){var n=e.filter((function(e){return o.filter.match(e,u.userId)})),a=e.filter((function(e){return!o.filter.match(e,u.userId)})).map((function(e){return e.url}));n.length>0&&o._addChannelsToView(n,t),a.length>0&&o._removeChannelsFromView(a,t)}},onRemove:function(e,t){o._removeChannelsFromView(e,t)}}),s.of(this._iid).statLogCollector.put(new I({type:V.FEATURE_LOCALCACHE,data:{use_local_cache:c.localCacheEnabled,collection_interface:{group_channel:!0}}})),d.on((function(e){e instanceof f&&(e.stateType===v.CONNECTED?o._isGetRemoteChannelsSucceeded||i(o,void 0,void 0,(function(){return h(this,(function(e){switch(e.label){case 0:return[4,this._revokeLoadMore()];case 1:return e.sent(),[2]}}))})):e.stateType===v.LOGOUT&&o.dispose())}))}return Object.defineProperty(e.prototype,"hasMore",{get:function(){return!this._isDisposed&&this._hasMore},enumerable:!1,configurable:!0}),e.prototype.setGroupChannelCollectionHandler=function(e){this._handler=e},e.prototype._addChannelsToView=function(e,t,n){var a,r,s,o,l=this;void 0===n&&(n=!1);var u=[],c=[],d=[];try{for(var p=F(e),f=p.next();!f.done;f=p.next()){var m=f.value,v=He(this.channels,m);v>=0&&this.channels.splice(v,1);var _=Re(this.channels,m,this.order).place;if(v<0)_===this.channels.length?!n&&this._hasMore||(u.push(m),this.channels.push(m)):(u.push(m),this.channels.splice(_,0,m));else switch(t){case L.EVENT_CHANNEL_UPDATED:case L.EVENT_MESSAGE_RECEIVED:case L.SYNC_CHANNEL_CHANGELOGS:case L.EVENT_MESSAGE_SENT:_!==v&&this._hasMore&&_===this.channels.length?d.push(m):(this.channels.splice(_,0,m),c.push(m));break;default:this.channels.splice(_,0,m),c.push(m)}}}catch(e){a={error:e}}finally{try{f&&!f.done&&(r=p.return)&&r.call(p)}finally{if(a)throw a.error}}if(d.length>0)try{for(var g=F(d),y=g.next();!y.done;y=g.next()){m=y.value;var C=He(this.channels,m);-1!==C&&this.channels.splice(C,1)}}catch(e){s={error:e}}finally{try{y&&!y.done&&(o=g.return)&&o.call(g)}finally{if(s)throw s.error}}pe(t)&&N((function(){return i(l,void 0,void 0,(function(){var e,n,a,r;return h(this,(function(i){return e=new me(t),u.length>0&&(null===(n=this._handler)||void 0===n?void 0:n.onChannelsAdded)&&this._handler.onChannelsAdded(e,u),c.length>0&&(null===(a=this._handler)||void 0===a?void 0:a.onChannelsUpdated)&&this._handler.onChannelsUpdated(e,c),d.length>0&&(null===(r=this._handler)||void 0===r?void 0:r.onChannelsDeleted)&&this._handler.onChannelsDeleted(e,d.map((function(e){return e.url}))),[2]}))}))}))},e.prototype._removeChannelsFromView=function(e,t){var n,a,r=this,s=[],o=function(e){var t=l.channels.findIndex((function(t){return t.url===e}));t>=0&&(s.push(l.channels[t].url),l.channels.splice(t,1))},l=this;try{for(var u=F(e),c=u.next();!c.done;c=u.next()){o(c.value)}}catch(e){n={error:e}}finally{try{c&&!c.done&&(a=u.return)&&a.call(u)}finally{if(n)throw n.error}}return pe(t)&&s.length>0&&N((function(){return i(r,void 0,void 0,(function(){var e,n;return h(this,(function(a){return e=new me(t),(null===(n=this._handler)||void 0===n?void 0:n.onChannelsDeleted)&&this._handler.onChannelsDeleted(e,s),[2]}))}))})),s},e.prototype._getLocalChannels=function(){return i(this,void 0,void 0,(function(){var e,t;return h(this,(function(n){switch(n.label){case 0:return e=de.of(this._iid),t=this.channels.length>0?function(e,t){var n,a,r,i;switch(t){case Le.LATEST_LAST_MESSAGE:return null!==(a=null===(n=e.lastMessage)||void 0===n?void 0:n.createdAt)&&void 0!==a?a:e.createdAt;case Le.CHRONOLOGICAL:return e.createdAt;case Le.CHANNEL_NAME_ALPHABETICAL:return e.name;default:return null!==(i=null===(r=e.lastMessage)||void 0===r?void 0:r.createdAt)&&void 0!==i?i:e.createdAt}}(this.channels[this.channels.length-1],this.order):null,[4,e.getChannelsFromCache(t,this.filter,this.order,this._limit,t?this.channels[this.channels.length-1].url:void 0)];case 1:return[2,n.sent()]}}))}))},e.prototype._getRemoteChannels=function(){return i(this,void 0,void 0,(function(){var e,t,n;return h(this,(function(a){switch(a.label){case 0:return[4,de.of(this._iid).getMyGroupChannels(this._token,K(j(j({},this.filter),{order:this.order})),this._limit)];case 1:return e=a.sent(),t=e.channels,n=e.token,this._token=n,this._hasMore=!!n,[2,t]}}))}))},e.prototype._revokeLoadMore=function(){return i(this,void 0,void 0,(function(){var e;return h(this,(function(t){switch(t.label){case 0:if(this._isDisposed)return[2];t.label=1;case 1:return t.trys.push([1,3,,4]),[4,this._getRemoteChannels()];case 2:return e=t.sent(),this._isGetRemoteChannelsSucceeded=!0,this._addChannelsToView(e,L.REQUEST_CHANNEL,!0),[3,4];case 3:return t.sent(),this._isGetRemoteChannelsSucceeded=!1,[3,4];case 4:return[2]}}))}))},e.prototype.loadMore=function(){return i(this,void 0,void 0,(function(){var e,t,n,a,r=this;return h(this,(function(o){switch(o.label){case 0:if(this._isDisposed)throw new _({code:W.COLLECTION_DISPOSED,message:"Collection has been disposed."});return this._hasMore?(e=s.of(this._iid),t=e.cacheContext,n=e.connectionManager,a=[],!t.localCacheEnabled||n.isConnected&&!this._backgroundSync.completed?[3,2]:[4,Y((function(){return i(r,void 0,void 0,(function(){return h(this,(function(e){switch(e.label){case 0:return[4,this._getLocalChannels()];case 1:return a=e.sent(),[2]}}))}))}))]):[3,6];case 1:return o.sent(),this._hasMore=a.length>=this._limit,[3,5];case 2:return o.trys.push([2,4,,5]),[4,this._getRemoteChannels()];case 3:return a=o.sent(),this._isGetRemoteChannelsSucceeded=!0,[3,5];case 4:return o.sent(),this._isGetRemoteChannelsSucceeded=!1,[3,5];case 5:return this._addChannelsToView(a,L.REQUEST_CHANNEL,!0),[2,a];case 6:return[2,[]]}}))}))},e.prototype.dispose=function(){var e,t;this._isDisposed||(this._isDisposed=!0,this.channels.length>0&&this.channels.splice(0,this.channels.length),null===(e=this._backgroundSync)||void 0===e||e.close(),null===(t=this._changelogSync)||void 0===t||t.close(),de.of(this._iid).unsubscribeChannelEvent(this._key))},e}(),Qe=function(e){function t(t){var n=this,a=t.token,r=t.limit,i=t.order,s=t.includeEmpty,o=t.membershipFilter,l=t.channelNameContainsFilter,u=t.channelUrlsFilter,c=t.customTypesFilter,h=t.customTypeStartsWithFilter,d=t.superChannelFilter,p=t.metadataOrderKeyFilter,f=t.metadataKey,m=t.metadataValues,v=t.metadataValueStartsWith,_=t.includeFrozen,g=t.includeMetaData;return(n=e.call(this)||this).method=J.GET,n.path=Z,n.params=$(K({token:a,limit:r,order:i,show_member:!0,show_read_receipt:!0,show_delivery_receipt:!0,show_empty:s,public_mode:ve.PUBLIC,public_membership_mode:o,name_contains:l,channel_urls:u,custom_types:c,custom_type_startswith:h,super_mode:d,metadata_order_key:p,metadata_key:f,metadata_values:m,metadata_value_startswith:v,show_frozen:_,show_metadata:g})),n}return X(t,e),t}(ee),je=function(e){function t(t,n){var a=e.call(this,t,n)||this;a.channels=[];var r=n.next,i=n.channels,s=n.ts;return a.token=r,i&&i.length>0&&(a.channels=i.map((function(e){return e.ts=s,new _e(t,e)}))),a.ts="number"==typeof s?s:0,a}return X(t,e),t}(te);!function(e){e.ALL="all",e.JOINED="joined"}(Ue||(Ue={}));var ze=function(e){function t(t,n){var a,r,i,s,o,l,u,c,h,d,p,f,m,v,_=this;return(_=e.call(this,t,n)||this).includeEmpty=!1,_.includeFrozen=!0,_.includeMetaData=!0,_.channelUrlsFilter=null,_.customTypesFilter=null,_.customTypeStartsWithFilter=null,_.channelNameContainsFilter=null,_.membershipFilter=Ue.ALL,_.superChannelFilter=ge.ALL,_.metadataKey=null,_.metadataValues=null,_.metadataOrderKeyFilter=null,_.metadataValueStartsWith=null,_.order=Te.CHRONOLOGICAL,_.includeEmpty=null!==(a=n.includeEmpty)&&void 0!==a&&a,_.includeFrozen=null===(r=n.includeFrozen)||void 0===r||r,_.includeMetaData=null===(i=n.includeMetaData)||void 0===i||i,_.channelUrlsFilter=null!==(s=n.channelUrlsFilter)&&void 0!==s?s:null,_.customTypesFilter=null!==(o=n.customTypesFilter)&&void 0!==o?o:null,_.customTypeStartsWithFilter=null!==(l=n.customTypeStartsWithFilter)&&void 0!==l?l:null,_.channelNameContainsFilter=null!==(u=n.channelNameContainsFilter)&&void 0!==u?u:null,_.membershipFilter=null!==(c=n.membershipFilter)&&void 0!==c?c:Ue.ALL,_.superChannelFilter=null!==(h=n.superChannelFilter)&&void 0!==h?h:ge.ALL,_.metadataKey=null!==(d=n.metadataKey)&&void 0!==d?d:null,_.metadataValues=null!==(p=n.metadataValues)&&void 0!==p?p:null,_.metadataOrderKeyFilter=null!==(f=n.metadataOrderKeyFilter)&&void 0!==f?f:null,_.metadataValueStartsWith=null!==(m=n.metadataValueStartsWith)&&void 0!==m?m:null,_.order=null!==(v=n.order)&&void 0!==v?v:Te.CHRONOLOGICAL,_}return X(t,e),t.prototype._validate=function(){return e.prototype._validate.call(this)&&ne("boolean",this.includeEmpty)&&ne("boolean",this.includeFrozen)&&ne("boolean",this.includeMetaData)&&ne("string",this.channelNameContainsFilter,!0)&&ae("string",this.channelUrlsFilter,!0)&&ae("string",this.customTypesFilter,!0)&&ne("string",this.customTypeStartsWithFilter,!0)&&re(Ue,this.membershipFilter)&&re(ge,this.superChannelFilter)&&re(Te,this.order)&&ne("string",this.metadataOrderKeyFilter,!0)&&ne("string",this.metadataKey,!0)&&ae("string",this.metadataValues,!0)&&ne("string",this.metadataValueStartsWith,!0)},t.prototype.next=function(){return i(this,void 0,void 0,(function(){var e,t,n,a,r,i,o,l;return h(this,(function(u){switch(u.label){case 0:return this._validate()?this._isLoading?[3,3]:(e=[],this._hasNext?(this._isLoading=!0,t=s.of(this._iid),n=t.requestQueue,t.dispatcher,a=new Qe(K(j(j({},this),{token:this._token}))),[4,n.send(a)]):[3,2]):[3,5];case 1:return r=u.sent(),i=r.as(je),o=i.channels,l=i.token,this._token=l,this._hasNext=!!l,this._isLoading=!1,[2,o];case 2:return[2,e];case 3:throw _.queryInProgress;case 4:return[3,6];case 5:throw _.invalidParameters;case 6:return[2]}}))}))},t}(ie),We=function(e){function t(t){void 0===t&&(t={});var n=e.call(this)||this;return Object.keys(t).forEach((function(e){n.hasOwnProperty(e)&&(n[e]=t[e])})),n}return X(t,e),t}(function(e){function t(){var t=null!==e&&e.apply(this,arguments)||this;return t.onUserJoined=se,t.onUserLeft=se,t.onUserReceivedInvitation=se,t.onUserDeclinedInvitation=se,t.onChannelHidden=se,t.onUnreadMemberStatusUpdated=se,t.onUndeliveredMemberStatusUpdated=se,t.onTypingStatusUpdated=se,t.onPollUpdated=se,t.onPollVoted=se,t.onPollDeleted=se,t.onPinnedMessageUpdated=se,t}return X(t,e),t}(Fe)),Be=function(e){function t(t){var n=this,a=t.token,r=t.limit,i=t.order,s=t.reverse,o=t.channelUrl,l=t.messageTypeFilter,u=t.scheduledStatus;return(n=e.call(this)||this).method=J.GET,n.path="".concat(oe),n.params=$(K({token:a,limit:r,reverse:s,channel_url:o,order:i,message_type:l,status:u})),n}return X(t,e),t}(ee),qe=function(e){function t(t,n){var a=e.call(this,t,n)||this;a.scheduledMessages=[];var r=n.next,i=n.scheduled_messages;return a.token=r,a.scheduledMessages=i.map((function(e){return Ge(t,e)})),a}return X(t,e),t}(te),Ye=function(e){function t(t,n){var a,r,i,s,o,l=this;return(l=e.call(this,t,n)||this).channelUrl=null,l.order=null,l.reverse=!1,l.scheduledStatus=null,l.messageTypeFilter=le.ALL,l.channelUrl=null!==(a=n.channelUrl)&&void 0!==a?a:null,l.order=null!==(r=n.order)&&void 0!==r?r:null,l.reverse=null!==(i=n.reverse)&&void 0!==i&&i,l.scheduledStatus=null!==(s=n.scheduledStatus)&&void 0!==s?s:null,l.messageTypeFilter=null!==(o=n.messageTypeFilter)&&void 0!==o?o:le.ALL,l}return X(t,e),t.prototype._validate=function(){return e.prototype._validate.call(this)&&ne("string",this.channelUrl,!0)&&(re(Ae,this.order)||null===this.order)&&ne("boolean",this.reverse)&&(ae(xe,this.scheduledStatus)||null===this.scheduledStatus)&&re(le,this.messageTypeFilter)},t.prototype.next=function(){return i(this,void 0,void 0,(function(){var e,t,n,a,r,i;return h(this,(function(o){switch(o.label){case 0:return this._validate()?this._isLoading?[3,3]:this._hasNext?(this._isLoading=!0,e=s.of(this._iid).requestQueue,t=new Be(K(j(j({},this),{token:this._token}))),[4,e.send(t)]):[3,2]:[3,5];case 1:return n=o.sent(),a=n.as(qe),r=a.scheduledMessages,i=a.token,this._token=i,this._hasNext=!!i,this._isLoading=!1,[2,r];case 2:return[2,[]];case 3:throw _.queryInProgress;case 4:return[3,6];case 5:throw _.invalidParameters;case 6:return[2]}}))}))},t}(ie),Xe=function(e){function t(){var t=null!==e&&e.apply(this,arguments)||this;return t.name="groupChannel",t}return X(t,e),t.prototype.init=function(t,n){var a=n.sdkState,r=n.dispatcher,i=n.sessionManager,s=n.requestQueue,o=n.logger,l=n.onlineDetector,u=n.cacheContext;e.prototype.init.call(this,t,{sdkState:a,dispatcher:r,sessionManager:i,requestQueue:s,logger:o,onlineDetector:l,cacheContext:u}),this._manager=new de(t,{sdkState:a,cacheContext:u,dispatcher:r,sessionManager:i,requestQueue:s,logger:o})},t.prototype.createGroupChannelCollection=function(e){return void 0===e&&(e={}),new Ke(this._iid,e)},t.prototype.createMyGroupChannelListQuery=function(e){return void 0===e&&(e={}),new ye(this._iid,e)},t.prototype.createPublicGroupChannelListQuery=function(e){return void 0===e&&(e={}),new ze(this._iid,e)},t.prototype.createScheduledMessageListQuery=function(e){return void 0===e&&(e={}),new Ye(this._iid,e)},t.prototype.addGroupChannelHandler=function(e,t){ue(ne("string",e)&&t instanceof We).throw(_.invalidParameters),this._manager.addHandler(e,t)},t.prototype.removeGroupChannelHandler=function(e){ue(ne("string",e)).throw(_.invalidParameters),this._manager.removeHandler(e)},t.prototype.removeAllGroupChannelHandlers=function(){this._manager.clearHandler()},t.prototype.buildGroupChannelFromSerializedData=function(e){return this._manager.buildGroupChannelFromSerializedData(e)},t.prototype.buildGroupChannelListQueryFromSerializedData=function(e){return this._manager.buildGroupChannelListQueryFromSerializedData(e)},t.prototype.buildMemberFromSerializedData=function(e){return this._manager.buildMemberFromSerializedData(e)},t.prototype.getChannel=function(e){return i(this,void 0,void 0,(function(){return h(this,(function(t){return ue(ne("string",e)).throw(_.invalidParameters),[2,this._manager.getChannel(e)]}))}))},t.prototype.getChannelWithoutCache=function(e){return i(this,void 0,void 0,(function(){return h(this,(function(t){return ue(ne("string",e)).throw(_.invalidParameters),[2,this._manager.getChannelWithoutCache(e)]}))}))},t.prototype.getMyGroupChannelChangeLogsByToken=function(e,t){return void 0===t&&(t={}),i(this,void 0,void 0,(function(){var n;return h(this,(function(a){switch(a.label){case 0:return n=j(j({},Ce),t),ue(ne("string",e)&&be(n)).throw(_.invalidParameters),[4,this._manager.getMyGroupChannelChangeLogs(e,n)];case 1:return[2,a.sent()]}}))}))},t.prototype.getMyGroupChannelChangeLogsByTimestamp=function(e,t){return void 0===t&&(t={}),i(this,void 0,void 0,(function(){var n;return h(this,(function(a){switch(a.label){case 0:return n=j(j({},Ce),t),ue(ne("number",e)&&be(n)).throw(_.invalidParameters),[4,this._manager.getMyGroupChannelChangeLogs(e,n)];case 1:return[2,a.sent()]}}))}))},t.prototype.getGroupChannelCount=function(e){return i(this,void 0,void 0,(function(){var t;return h(this,(function(n){return t=j(j({},Me),e),ue(Se(t)).throw(_.invalidParameters),[2,this._manager.getGroupChannelCount(t)]}))}))},t.prototype.getUnreadItemCount=function(e){return void 0===e&&(e={}),i(this,void 0,void 0,(function(){return h(this,(function(t){switch(t.label){case 0:return[4,this._manager.getUnreadItemCount(e)];case 1:return[2,t.sent()]}}))}))},t.prototype.getTotalUnreadChannelCount=function(){return i(this,void 0,void 0,(function(){return h(this,(function(e){switch(e.label){case 0:return[4,this._manager.getTotalUnreadChannelCount()];case 1:return[2,e.sent()]}}))}))},t.prototype.getTotalUnreadMessageCount=function(e){return void 0===e&&(e={}),i(this,void 0,void 0,(function(){return h(this,(function(t){switch(t.label){case 0:return[4,this._manager.getTotalUnreadMessageCount(e)];case 1:return[2,t.sent()]}}))}))},t.prototype.getTotalScheduledMessageCount=function(e){return void 0===e&&(e={}),i(this,void 0,void 0,(function(){return h(this,(function(t){switch(t.label){case 0:return[4,this._manager.getTotalScheduledMessageCount(e)];case 1:return[2,t.sent()]}}))}))},t.prototype.getSubscribedTotalUnreadMessageCount=function(){return this._manager.getSubscribedTotalUnreadMessageCount()},t.prototype.getSubscribedCustomTypeTotalUnreadMessageCount=function(){return this._manager.getSubscribedCustomTypeTotalUnreadMessageCount()},t.prototype.getSubscribedCustomTypeUnreadMessageCount=function(e){return this._manager.getSubscribedCustomTypeUnreadMessageCount(e)},t.prototype.createChannel=function(e){return void 0===e&&(e={}),i(this,void 0,void 0,(function(){var t;return h(this,(function(n){return t=j(j({},Ee),e),ue(we(t)).throw(_.invalidParameters),[2,this._manager.createChannel(t)]}))}))},t.prototype.createDistinctChannelIfNotExist=function(e){return void 0===e&&(e={}),i(this,void 0,void 0,(function(){var t;return h(this,(function(n){return t=j(j({},Ee),e),ue(we(t)).throw(_.invalidParameters),t&&(t.isDistinct=!0),[2,this.createChannel(t)]}))}))},t.prototype.createChannelWithUserIds=function(e,t,n,a,r,s){return void 0===t&&(t=!1),void 0===r&&(r=""),void 0===s&&(s=""),i(this,void 0,void 0,(function(){var i;return h(this,(function(o){return i=j(j({},Ee),{invitedUserIds:e,isDistinct:t,name:n,data:r,customType:s}),"string"==typeof a?i.coverUrl=a:i.coverImage=a,[2,this.createChannel(i)]}))}))},t.prototype.markAsReadAll=function(){return i(this,void 0,void 0,(function(){return h(this,(function(e){return this._manager.markAsReadAll(),[2]}))}))},t.prototype.markAsReadWithChannelUrls=function(e){return i(this,void 0,void 0,(function(){return h(this,(function(t){return ue(ae("string",e)).throw(_.invalidParameters),this._manager.markAsReadWithChannelUrls(e),[2]}))}))},t.prototype.markAsDelivered=function(e){return i(this,void 0,void 0,(function(){return h(this,(function(t){switch(t.label){case 0:return ue(ne("string",e)).throw(_.invalidParameters),[4,this.getChannel(e)];case 1:return[4,t.sent().markAsDelivered()];case 2:return t.sent(),[2]}}))}))},t}(ce);export{Ke as GroupChannelCollection,We as GroupChannelHandler,Xe as GroupChannelModule,Ue as MembershipFilter,ze as PublicGroupChannelListQuery,Ye as ScheduledMessageListQuery};
+import{b as i,V as s,c as h,y as f,z as v,q as _,o as g,p as E,X as L,H as T,r as F,B as N,m as D,aX as I,aY as V,u as j,g as W,al as Y,O as J,_ as X,A as Z,ap as $,e as ee,f as te,h as ne,a as ae,K as re,Q as ie,aF as se,aq as oe,aZ as le,af as ue,s as ce,aN as he}from"./lib/__bundle-0f850482.js";export{a_ as MessageEventSource,a$ as MutedState}from"./lib/__bundle-0f850482.js";import{S as de,T as pe,G as fe,s as me,a as ve,b as _e,P as ge,c as ye,d as Ce,e as be,f as Me,v as Se,g as Ee,h as we,i as Le,j as Te}from"./lib/__bundle-37e3f19f.js";export{C as CountPreference,c as GroupChannel,b as GroupChannelEventContext,k as GroupChannelEventSource,a as GroupChannelFilter,e as GroupChannelListQuery,l as GroupChannelSearchField,H as HiddenChannelFilter,m as HiddenState,M as Member,n as MemberListOrder,o as MemberListQuery,p as MemberState,q as MemberStateFilter,t as MessageCollection,u as MessageCollectionInitHandler,w as MessageCollectionInitPolicy,x as MessageEventContext,y as MutedMemberFilter,r as MyMemberStateFilter,O as OperatorFilter,z as PinnedMessage,A as PinnedMessageListQuery,P as PublicChannelFilter,Q as QueryType,R as ReadStatus,d as SuperChannelFilter,U as UnreadChannelFilter,B as UnreadItemKey}from"./lib/__bundle-37e3f19f.js";import{G as Ae,P as ke,S as Fe}from"./lib/__bundle-1ab3a4b7.js";export{G as GroupChannelListOrder,P as PublicGroupChannelListOrder,S as ScheduledMessageListOrder}from"./lib/__bundle-1ab3a4b7.js";import{H as Ne,J as Ge,K as xe}from"./lib/__bundle-684d6267.js";export{G as MessageFilter,K as ScheduledStatus}from"./lib/__bundle-684d6267.js";import{B as Ue}from"./lib/__bundle-cd042bbd.js";import"./lib/__bundle-fa60a3cc.js";import"./lib/__bundle-c336221f.js";var Oe,De={},Pe=function(){function e(e){var t=e._iid,n=e.limit,a=void 0===n?100:n,r=this;this.ref=0,this._iid=t,this._limit=a;var o,l=s.of(this._iid),u=l.sdkState,c=l.dispatcher,d=l.logger,p=l.cacheContext;this._metadataKey=(o=u.userId,"sendbird:".concat(o,"@groupchannel/sync.meta"));var m=function(e){return"sendbird:".concat(e,"@groupchannel/sync")}(u.userId);this._sync=new de(m,(function(){return i(r,void 0,void 0,(function(){var e,t,n,a,r,i,s,o,l,c,f,m;return h(this,(function(h){switch(h.label){case 0:return e={hasNext:!0,nextToken:""},[4,this.loadMetadata()];case 1:if(h.sent(),d.debug("channel background sync from",null===(l=this._metadata)||void 0===l?void 0:l.token),null===(c=this._metadata)||void 0===c?void 0:c.completed)return[3,13];h.label=2;case 2:if(h.trys.push([2,9,,12]),(t={includeEmpty:!0,order:Ae.CHRONOLOGICAL}).order!==Ae.LATEST_LAST_MESSAGE)return[3,6];h.label=3;case 3:return h.trys.push([3,5,,6]),[4,p.preference.get(T(u.appId))];case 4:return n=h.sent(),t.includeChatNotification=Boolean(n),[3,6];case 5:return h.sent(),t.includeChatNotification=!1,[3,6];case 6:return[4,fe.of(this._iid).getMyGroupChannels(null!==(m=null===(f=this._metadata)||void 0===f?void 0:f.token)&&void 0!==m?m:"",t,this._limit,L.SYNC_CHANNEL_BACKGROUND)];case 7:return a=h.sent(),r=a.channels,i=a.token,e.hasNext=r.length>=this._limit&&!!i,e.nextToken=i,this._metadata&&(this._metadata.token=i,(o=this._metadata.range).extends.apply(o,g([],E(r.map((function(e){return e.createdAt}))),!1)),this._metadata.completed=!e.hasNext),d.debug("channel background sync progress",e),[4,this.saveMetadata()];case 8:return h.sent(),[3,12];case 9:return s=h.sent(),d.debug("channel background sync error",s),s instanceof _&&s.isInvalidTokenError?[4,this.clearMetaData()]:[3,11];case 10:h.sent(),h.label=11;case 11:throw s;case 12:return[3,14];case 13:e.hasNext=!1,e.nextToken="",h.label=14;case 14:return[2,e]}}))}))})),this._connectionEventContext=c.on((function(e){if(e instanceof f)if(e.stateType===v.CONNECTED)r.resume();else r.pause()}))}return e.of=function(t){return De[t]||(De[t]=new e({_iid:t})),De[t].ref++,De[t]},e.clear=function(e){De[e]&&(De[e].close(),delete De[e])},Object.defineProperty(e.prototype,"range",{get:function(){var e,t;return null!==(t=null===(e=this._metadata)||void 0===e?void 0:e.range)&&void 0!==t?t:new pe({})},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"completed",{get:function(){var e;return!!(null===(e=this._metadata)||void 0===e?void 0:e.completed)},enumerable:!1,configurable:!0}),e.prototype.loadMetadata=function(){return i(this,void 0,void 0,(function(){var e;return h(this,(function(t){switch(t.label){case 0:return this._metadata?[3,2]:[4,s.of(this._iid).cacheContext.preference.get(this._metadataKey)];case 1:e=t.sent(),this._metadata={token:e?e.token:"",range:new pe(e?e.range:{top:Number.MAX_SAFE_INTEGER,bottom:0}),completed:!!e&&e.completed},t.label=2;case 2:return[2,this._metadata]}}))}))},e.prototype.saveMetadata=function(){return i(this,void 0,void 0,(function(){return h(this,(function(e){switch(e.label){case 0:return this._metadata?[4,s.of(this._iid).cacheContext.preference.set(this._metadataKey,this._metadata)]:[3,2];case 1:return e.sent(),[2,!0];case 2:return[2,!1]}}))}))},e.prototype.clearMetaData=function(){return i(this,void 0,void 0,(function(){return h(this,(function(e){switch(e.label){case 0:return[4,s.of(this._iid).cacheContext.preference.remove(this._metadataKey)];case 1:return e.sent(),this._metadata=void 0,[2]}}))}))},e.prototype.resume=function(){var e,t,n=s.of(this._iid),a=n.logger;n.sessionManager.session.hasSession&&(a.debug("channel background sync resume()"),this._sync.start(null!==(t=null===(e=this._metadata)||void 0===e?void 0:e.token)&&void 0!==t?t:""))},e.prototype.pause=function(){s.of(this._iid).logger.debug("channel background sync stop()"),this._sync.stop()},e.prototype.close=function(){this.ref--,this.ref<=0&&(this.ref=0,this.pause(),this._connectionEventContext.close(),delete De[this._iid])},e}(),Ie={},He=function(){function e(e){var t=e._iid,n=this;this.ref=0,this._iid=t;var a,r=s.of(this._iid),o=r.logger,l=r.sdkState,u=r.dispatcher,c=r.cacheContext;this._metadataKey=(a=l.userId,"sendbird:".concat(a,"@groupchannel/changelogs.meta"));var d=function(e){return"sendbird:".concat(e,"@groupchannel/changelogs")}(l.userId);this._sync=new de(d,(function(){return i(n,void 0,void 0,(function(){var e,t,n,a,r,i,s,u,d,p;return h(this,(function(h){switch(h.label){case 0:return e={hasNext:!0,nextToken:0},[4,this.loadMetadata()];case 1:h.sent(),o.debug("channel changelog sync from",null===(u=this._metadata)||void 0===u?void 0:u.token),h.label=2;case 2:h.trys.push([2,9,,12]),t={includeEmpty:!0},h.label=3;case 3:return h.trys.push([3,5,,6]),[4,c.preference.get(T(l.appId))];case 4:return n=h.sent(),t.includeChatNotification=Boolean(n),[3,6];case 5:return h.sent(),t.includeChatNotification=!1,[3,6];case 6:return[4,fe.of(this._iid).getMyGroupChannelChangeLogs(null!==(p=null===(d=this._metadata)||void 0===d?void 0:d.token)&&void 0!==p?p:"",t,L.SYNC_CHANNEL_CHANGELOGS)];case 7:return a=h.sent(),r=a.hasMore,i=a.token,e.hasNext=r,e.nextToken=i,this._metadata&&(this._metadata.token=i),o.debug("channel changelog sync progress",e),[4,this.saveMetadata()];case 8:return h.sent(),[3,12];case 9:return s=h.sent(),o.debug("channel changelog sync error",s),s instanceof _&&s.isInvalidTokenError?[4,this.clearMetadata()]:[3,11];case 10:h.sent(),h.label=11;case 11:throw s;case 12:return[2,e]}}))}))})),this._connectionEventContext=u.on((function(e){if(e instanceof f)if(e.stateType===v.CONNECTED)n.resume();else n.pause()}))}return e.of=function(t){return Ie[t]||(Ie[t]=new e({_iid:t})),Ie[t].ref++,Ie[t]},e.clear=function(e){Ie[e]&&(Ie[e].close(),delete Ie[e])},e.prototype.loadMetadata=function(){return i(this,void 0,void 0,(function(){var e,t,n,a;return h(this,(function(r){switch(r.label){case 0:return this._metadata?[3,2]:(e=s.of(this._iid),t=e.cacheContext,n=e.firstConnectedAt,[4,t.preference.get(this._metadataKey)]);case 1:a=r.sent(),this._metadata={token:a?a.token:n},r.label=2;case 2:return[2,this._metadata]}}))}))},e.prototype.saveMetadata=function(){return i(this,void 0,void 0,(function(){return h(this,(function(e){switch(e.label){case 0:return this._metadata?[4,s.of(this._iid).cacheContext.preference.set(this._metadataKey,this._metadata)]:[3,2];case 1:return e.sent(),[2,!0];case 2:return[2,!1]}}))}))},e.prototype.clearMetadata=function(){return i(this,void 0,void 0,(function(){return h(this,(function(e){switch(e.label){case 0:return[4,s.of(this._iid).cacheContext.preference.remove(this._metadataKey)];case 1:return e.sent(),this._metadata=void 0,[2]}}))}))},e.prototype.resume=function(){s.of(this._iid).sessionManager.session.hasSession&&this._sync.start(0)},e.prototype.pause=function(){this._sync.stop()},e.prototype.close=function(){this.ref--,this.ref<=0&&(this.ref=0,this.pause(),this._connectionEventContext.close(),delete Ie[this._iid])},e}(),Re=function(e,t){return e.findIndex((function(e){return e.isIdentical(t)}))},Ke=function(e,t,n){if(e.length>0){for(var a=Re(e,t),r=0,i=e.length-1,s=Math.floor((r+i)/2);r0)i=s,s=Math.floor((r+i)/2);else{if(!(o<0))return{place:s,oldPosition:a};r=s+1,s=Math.floor((r+i)/2)}}return{place:Ve(e[s],t,n)>=0?s:s+1,oldPosition:a}}return{place:e.length,oldPosition:-1}},Ve=function(e,t,n){switch(n){case Ae.LATEST_LAST_MESSAGE:return e.lastMessage&&t.lastMessage?t.lastMessage.createdAt-e.lastMessage.createdAt:e.lastMessage?-1:t.lastMessage?1:t.createdAt-e.createdAt;case Ae.CHRONOLOGICAL:return t.createdAt-e.createdAt;case Ae.CHANNEL_NAME_ALPHABETICAL:var a=e.name.localeCompare(t.name);return 0===a?e.createdAt-t.createdAt:a;default:return 0}},Qe=function(){function e(e,t){var n=t.filter,a=t.order,r=t.limit,o=this;this.channels=[],this._iid=e,this._key="gcc-".concat(D()),this._isDisposed=!1,this._isGetRemoteChannelsSucceeded=!0,this.filter=null!=n?n:new ve,this.order=null!=a?a:Ae.LATEST_LAST_MESSAGE,this._hasMore=!0,this._token="",this._limit=null!=r?r:Ne;var l=s.of(this._iid),u=l.sdkState,c=l.cacheContext,d=l.dispatcher;c.localCacheEnabled&&(this._backgroundSync=Pe.of(e),this._backgroundSync.resume()),this._changelogSync=He.of(e),this._changelogSync.resume(),fe.of(this._iid).subscribeChannelEvent(this._key,{onUpdate:function(e,t){if(me(t)){var n=e.filter((function(e){return o.filter.match(e,u.userId)})),a=e.filter((function(e){return!o.filter.match(e,u.userId)})).map((function(e){return e.url}));n.length>0&&o._addChannelsToView(n,t),a.length>0&&o._removeChannelsFromView(a,t)}},onRemove:function(e,t){o._removeChannelsFromView(e,t)}}),s.of(this._iid).statLogCollector.put(new I({type:V.FEATURE_LOCALCACHE,data:{use_local_cache:c.localCacheEnabled,collection_interface:{group_channel:!0}}})),d.on((function(e){e instanceof f&&(e.stateType===v.CONNECTED?o._isGetRemoteChannelsSucceeded||i(o,void 0,void 0,(function(){return h(this,(function(e){switch(e.label){case 0:return[4,this._revokeLoadMore()];case 1:return e.sent(),[2]}}))})):e.stateType===v.LOGOUT&&o.dispose())}))}return Object.defineProperty(e.prototype,"hasMore",{get:function(){return!this._isDisposed&&this._hasMore},enumerable:!1,configurable:!0}),e.prototype.setGroupChannelCollectionHandler=function(e){this._handler=e},e.prototype._addChannelsToView=function(e,t,n){var a,r,s,o,l=this;void 0===n&&(n=!1);var u=[],c=[],d=[];try{for(var p=F(e),f=p.next();!f.done;f=p.next()){var m=f.value,v=Re(this.channels,m);v>=0&&this.channels.splice(v,1);var _=Ke(this.channels,m,this.order).place;if(v<0)_===this.channels.length?!n&&this._hasMore||(u.push(m),this.channels.push(m)):(u.push(m),this.channels.splice(_,0,m));else switch(t){case L.EVENT_CHANNEL_UPDATED:case L.EVENT_MESSAGE_RECEIVED:case L.SYNC_CHANNEL_CHANGELOGS:case L.EVENT_MESSAGE_SENT:_!==v&&this._hasMore&&_===this.channels.length?d.push(m):(this.channels.splice(_,0,m),c.push(m));break;default:this.channels.splice(_,0,m),c.push(m)}}}catch(e){a={error:e}}finally{try{f&&!f.done&&(r=p.return)&&r.call(p)}finally{if(a)throw a.error}}if(d.length>0)try{for(var g=F(d),y=g.next();!y.done;y=g.next()){m=y.value;var C=Re(this.channels,m);-1!==C&&this.channels.splice(C,1)}}catch(e){s={error:e}}finally{try{y&&!y.done&&(o=g.return)&&o.call(g)}finally{if(s)throw s.error}}me(t)&&N((function(){return i(l,void 0,void 0,(function(){var e,n,a,r;return h(this,(function(i){return e=new _e(t),u.length>0&&(null===(n=this._handler)||void 0===n?void 0:n.onChannelsAdded)&&this._handler.onChannelsAdded(e,u),c.length>0&&(null===(a=this._handler)||void 0===a?void 0:a.onChannelsUpdated)&&this._handler.onChannelsUpdated(e,c),d.length>0&&(null===(r=this._handler)||void 0===r?void 0:r.onChannelsDeleted)&&this._handler.onChannelsDeleted(e,d.map((function(e){return e.url}))),[2]}))}))}))},e.prototype._removeChannelsFromView=function(e,t){var n,a,r=this,s=[],o=function(e){var t=l.channels.findIndex((function(t){return t.url===e}));t>=0&&(s.push(l.channels[t].url),l.channels.splice(t,1))},l=this;try{for(var u=F(e),c=u.next();!c.done;c=u.next()){o(c.value)}}catch(e){n={error:e}}finally{try{c&&!c.done&&(a=u.return)&&a.call(u)}finally{if(n)throw n.error}}return me(t)&&s.length>0&&N((function(){return i(r,void 0,void 0,(function(){var e,n;return h(this,(function(a){return e=new _e(t),(null===(n=this._handler)||void 0===n?void 0:n.onChannelsDeleted)&&this._handler.onChannelsDeleted(e,s),[2]}))}))})),s},e.prototype._getLocalChannels=function(){return i(this,void 0,void 0,(function(){var e,t;return h(this,(function(n){switch(n.label){case 0:return e=fe.of(this._iid),t=this.channels.length>0?function(e,t){var n,a,r,i;switch(t){case Ae.LATEST_LAST_MESSAGE:return null!==(a=null===(n=e.lastMessage)||void 0===n?void 0:n.createdAt)&&void 0!==a?a:e.createdAt;case Ae.CHRONOLOGICAL:return e.createdAt;case Ae.CHANNEL_NAME_ALPHABETICAL:return e.name;default:return null!==(i=null===(r=e.lastMessage)||void 0===r?void 0:r.createdAt)&&void 0!==i?i:e.createdAt}}(this.channels[this.channels.length-1],this.order):null,[4,e.getChannelsFromCache(t,this.filter,this.order,this._limit,t?this.channels[this.channels.length-1].url:void 0)];case 1:return[2,n.sent()]}}))}))},e.prototype._getRemoteChannels=function(){return i(this,void 0,void 0,(function(){var e,t,n;return h(this,(function(a){switch(a.label){case 0:return[4,fe.of(this._iid).getMyGroupChannels(this._token,j(W(W({},this.filter),{order:this.order})),this._limit)];case 1:return e=a.sent(),t=e.channels,n=e.token,this._token=n,this._hasMore=!!n,[2,t]}}))}))},e.prototype._revokeLoadMore=function(){return i(this,void 0,void 0,(function(){var e;return h(this,(function(t){switch(t.label){case 0:if(this._isDisposed)return[2];t.label=1;case 1:return t.trys.push([1,3,,4]),[4,this._getRemoteChannels()];case 2:return e=t.sent(),this._isGetRemoteChannelsSucceeded=!0,this._addChannelsToView(e,L.REQUEST_CHANNEL,!0),[3,4];case 3:return t.sent(),this._isGetRemoteChannelsSucceeded=!1,[3,4];case 4:return[2]}}))}))},e.prototype.loadMore=function(){return i(this,void 0,void 0,(function(){var e,t,n,a,r=this;return h(this,(function(o){switch(o.label){case 0:if(this._isDisposed)throw new _({code:Y.COLLECTION_DISPOSED,message:"Collection has been disposed."});return this._hasMore?(e=s.of(this._iid),t=e.cacheContext,n=e.connectionManager,a=[],!t.localCacheEnabled||n.isConnected&&!this._backgroundSync.completed?[3,2]:[4,J((function(){return i(r,void 0,void 0,(function(){return h(this,(function(e){switch(e.label){case 0:return[4,this._getLocalChannels()];case 1:return a=e.sent(),[2]}}))}))}))]):[3,6];case 1:return o.sent(),this._hasMore=a.length>=this._limit,[3,5];case 2:return o.trys.push([2,4,,5]),[4,this._getRemoteChannels()];case 3:return a=o.sent(),this._isGetRemoteChannelsSucceeded=!0,[3,5];case 4:return o.sent(),this._isGetRemoteChannelsSucceeded=!1,[3,5];case 5:return this._addChannelsToView(a,L.REQUEST_CHANNEL,!0),[2,a];case 6:return[2,[]]}}))}))},e.prototype.dispose=function(){var e,t;this._isDisposed||(this._isDisposed=!0,this.channels.length>0&&this.channels.splice(0,this.channels.length),null===(e=this._backgroundSync)||void 0===e||e.close(),null===(t=this._changelogSync)||void 0===t||t.close(),fe.of(this._iid).unsubscribeChannelEvent(this._key))},e}(),je=function(e){function t(t){var n=this,a=t.token,r=t.limit,i=t.order,s=t.includeEmpty,o=t.membershipFilter,l=t.channelNameContainsFilter,u=t.channelUrlsFilter,c=t.customTypesFilter,h=t.customTypeStartsWithFilter,d=t.superChannelFilter,p=t.metadataOrderKeyFilter,f=t.metadataKey,m=t.metadataValues,v=t.metadataValueStartsWith,_=t.includeFrozen,g=t.includeMetaData;return(n=e.call(this)||this).method=Z.GET,n.path=$,n.params=ee(j({token:a,limit:r,order:i,show_member:!0,show_read_receipt:!0,show_delivery_receipt:!0,show_empty:s,public_mode:ge.PUBLIC,public_membership_mode:o,name_contains:l,channel_urls:u,custom_types:c,custom_type_startswith:h,super_mode:d,metadata_order_key:p,metadata_key:f,metadata_values:m,metadata_value_startswith:v,show_frozen:_,show_metadata:g})),n}return X(t,e),t}(te),We=function(e){function t(t,n){var a=e.call(this,t,n)||this;a.channels=[];var r=n.next,i=n.channels,s=n.ts;return a.token=r,i&&i.length>0&&(a.channels=i.map((function(e){return e.ts=s,new ye(t,e)}))),a.ts="number"==typeof s?s:0,a}return X(t,e),t}(ne);!function(e){e.ALL="all",e.JOINED="joined"}(Oe||(Oe={}));var ze=function(e){function t(t,n){var a,r,i,s,o,l,u,c,h,d,p,f,m,v,_=this;return(_=e.call(this,t,n)||this).includeEmpty=!1,_.includeFrozen=!0,_.includeMetaData=!0,_.channelUrlsFilter=null,_.customTypesFilter=null,_.customTypeStartsWithFilter=null,_.channelNameContainsFilter=null,_.membershipFilter=Oe.ALL,_.superChannelFilter=Ce.ALL,_.metadataKey=null,_.metadataValues=null,_.metadataOrderKeyFilter=null,_.metadataValueStartsWith=null,_.order=ke.CHRONOLOGICAL,_.includeEmpty=null!==(a=n.includeEmpty)&&void 0!==a&&a,_.includeFrozen=null===(r=n.includeFrozen)||void 0===r||r,_.includeMetaData=null===(i=n.includeMetaData)||void 0===i||i,_.channelUrlsFilter=null!==(s=n.channelUrlsFilter)&&void 0!==s?s:null,_.customTypesFilter=null!==(o=n.customTypesFilter)&&void 0!==o?o:null,_.customTypeStartsWithFilter=null!==(l=n.customTypeStartsWithFilter)&&void 0!==l?l:null,_.channelNameContainsFilter=null!==(u=n.channelNameContainsFilter)&&void 0!==u?u:null,_.membershipFilter=null!==(c=n.membershipFilter)&&void 0!==c?c:Oe.ALL,_.superChannelFilter=null!==(h=n.superChannelFilter)&&void 0!==h?h:Ce.ALL,_.metadataKey=null!==(d=n.metadataKey)&&void 0!==d?d:null,_.metadataValues=null!==(p=n.metadataValues)&&void 0!==p?p:null,_.metadataOrderKeyFilter=null!==(f=n.metadataOrderKeyFilter)&&void 0!==f?f:null,_.metadataValueStartsWith=null!==(m=n.metadataValueStartsWith)&&void 0!==m?m:null,_.order=null!==(v=n.order)&&void 0!==v?v:ke.CHRONOLOGICAL,_}return X(t,e),t.prototype._validate=function(){return e.prototype._validate.call(this)&&ae("boolean",this.includeEmpty)&&ae("boolean",this.includeFrozen)&&ae("boolean",this.includeMetaData)&&ae("string",this.channelNameContainsFilter,!0)&&re("string",this.channelUrlsFilter,!0)&&re("string",this.customTypesFilter,!0)&&ae("string",this.customTypeStartsWithFilter,!0)&&ie(Oe,this.membershipFilter)&&ie(Ce,this.superChannelFilter)&&ie(ke,this.order)&&ae("string",this.metadataOrderKeyFilter,!0)&&ae("string",this.metadataKey,!0)&&re("string",this.metadataValues,!0)&&ae("string",this.metadataValueStartsWith,!0)},t.prototype.next=function(){return i(this,void 0,void 0,(function(){var e,t,n,a,r,i,o,l;return h(this,(function(u){switch(u.label){case 0:return this._validate()?this._isLoading?[3,3]:(e=[],this._hasNext?(this._isLoading=!0,t=s.of(this._iid),n=t.requestQueue,t.dispatcher,a=new je(j(W(W({},this),{token:this._token}))),[4,n.send(a)]):[3,2]):[3,5];case 1:return r=u.sent(),i=r.as(We),o=i.channels,l=i.token,this._token=l,this._hasNext=!!l,this._isLoading=!1,[2,o];case 2:return[2,e];case 3:throw _.queryInProgress;case 4:return[3,6];case 5:throw _.invalidParameters;case 6:return[2]}}))}))},t}(se),Be=function(e){function t(t){void 0===t&&(t={});var n=e.call(this)||this;return Object.keys(t).forEach((function(e){n.hasOwnProperty(e)&&(n[e]=t[e])})),n}return X(t,e),t}(function(e){function t(){var t=null!==e&&e.apply(this,arguments)||this;return t.onUserJoined=oe,t.onUserLeft=oe,t.onUserReceivedInvitation=oe,t.onUserDeclinedInvitation=oe,t.onChannelHidden=oe,t.onUnreadMemberStatusUpdated=oe,t.onUndeliveredMemberStatusUpdated=oe,t.onTypingStatusUpdated=oe,t.onPollUpdated=oe,t.onPollVoted=oe,t.onPollDeleted=oe,t.onPinnedMessageUpdated=oe,t}return X(t,e),t}(Ue)),qe=function(e){function t(t){var n=this,a=t.token,r=t.limit,i=t.order,s=t.reverse,o=t.channelUrl,l=t.messageTypeFilter,u=t.scheduledStatus;return(n=e.call(this)||this).method=Z.GET,n.path="".concat(le),n.params=ee(j({token:a,limit:r,reverse:s,channel_url:o,order:i,message_type:l,status:u})),n}return X(t,e),t}(te),Ye=function(e){function t(t,n){var a=e.call(this,t,n)||this;a.scheduledMessages=[];var r=n.next,i=n.scheduled_messages;return a.token=r,a.scheduledMessages=i.map((function(e){return Ge(t,e)})),a}return X(t,e),t}(ne),Je=function(e){function t(t,n){var a,r,i,s,o,l=this;return(l=e.call(this,t,n)||this).channelUrl=null,l.order=null,l.reverse=!1,l.scheduledStatus=null,l.messageTypeFilter=ue.ALL,l.channelUrl=null!==(a=n.channelUrl)&&void 0!==a?a:null,l.order=null!==(r=n.order)&&void 0!==r?r:null,l.reverse=null!==(i=n.reverse)&&void 0!==i&&i,l.scheduledStatus=null!==(s=n.scheduledStatus)&&void 0!==s?s:null,l.messageTypeFilter=null!==(o=n.messageTypeFilter)&&void 0!==o?o:ue.ALL,l}return X(t,e),t.prototype._validate=function(){return e.prototype._validate.call(this)&&ae("string",this.channelUrl,!0)&&(ie(Fe,this.order)||null===this.order)&&ae("boolean",this.reverse)&&(re(xe,this.scheduledStatus)||null===this.scheduledStatus)&&ie(ue,this.messageTypeFilter)},t.prototype.next=function(){return i(this,void 0,void 0,(function(){var e,t,n,a,r,i;return h(this,(function(o){switch(o.label){case 0:return this._validate()?this._isLoading?[3,3]:this._hasNext?(this._isLoading=!0,e=s.of(this._iid).requestQueue,t=new qe(j(W(W({},this),{token:this._token}))),[4,e.send(t)]):[3,2]:[3,5];case 1:return n=o.sent(),a=n.as(Ye),r=a.scheduledMessages,i=a.token,this._token=i,this._hasNext=!!i,this._isLoading=!1,[2,r];case 2:return[2,[]];case 3:throw _.queryInProgress;case 4:return[3,6];case 5:throw _.invalidParameters;case 6:return[2]}}))}))},t}(se),Xe=function(e){function t(){var t=null!==e&&e.apply(this,arguments)||this;return t.name="groupChannel",t}return X(t,e),t.prototype.init=function(t,n){var a=n.sdkState,r=n.dispatcher,i=n.sessionManager,s=n.requestQueue,o=n.logger,l=n.onlineDetector,u=n.cacheContext;e.prototype.init.call(this,t,{sdkState:a,dispatcher:r,sessionManager:i,requestQueue:s,logger:o,onlineDetector:l,cacheContext:u}),this._manager=new fe(t,{sdkState:a,cacheContext:u,dispatcher:r,sessionManager:i,requestQueue:s,logger:o})},t.prototype.createGroupChannelCollection=function(e){return void 0===e&&(e={}),new Qe(this._iid,e)},t.prototype.createMyGroupChannelListQuery=function(e){return void 0===e&&(e={}),new be(this._iid,e)},t.prototype.createPublicGroupChannelListQuery=function(e){return void 0===e&&(e={}),new ze(this._iid,e)},t.prototype.createScheduledMessageListQuery=function(e){return void 0===e&&(e={}),new Je(this._iid,e)},t.prototype.addGroupChannelHandler=function(e,t){ce(ae("string",e)&&t instanceof Be).throw(_.invalidParameters),this._manager.addHandler(e,t)},t.prototype.removeGroupChannelHandler=function(e){ce(ae("string",e)).throw(_.invalidParameters),this._manager.removeHandler(e)},t.prototype.removeAllGroupChannelHandlers=function(){this._manager.clearHandler()},t.prototype.buildGroupChannelFromSerializedData=function(e){return this._manager.buildGroupChannelFromSerializedData(e)},t.prototype.buildGroupChannelListQueryFromSerializedData=function(e){return this._manager.buildGroupChannelListQueryFromSerializedData(e)},t.prototype.buildMemberFromSerializedData=function(e){return this._manager.buildMemberFromSerializedData(e)},t.prototype.getChannel=function(e){return i(this,void 0,void 0,(function(){return h(this,(function(t){return ce(ae("string",e)).throw(_.invalidParameters),[2,this._manager.getChannel(e)]}))}))},t.prototype.getChannelWithoutCache=function(e){return i(this,void 0,void 0,(function(){return h(this,(function(t){return ce(ae("string",e)).throw(_.invalidParameters),[2,this._manager.getChannelWithoutCache(e)]}))}))},t.prototype.getMyGroupChannelChangeLogsByToken=function(e,t){return void 0===t&&(t={}),i(this,void 0,void 0,(function(){var n;return h(this,(function(a){switch(a.label){case 0:return n=W(W({},Me),t),ce(ae("string",e)&&Se(n)).throw(_.invalidParameters),[4,this._manager.getMyGroupChannelChangeLogs(e,n)];case 1:return[2,a.sent()]}}))}))},t.prototype.getMyGroupChannelChangeLogsByTimestamp=function(e,t){return void 0===t&&(t={}),i(this,void 0,void 0,(function(){var n;return h(this,(function(a){switch(a.label){case 0:return n=W(W({},Me),t),ce(ae("number",e)&&Se(n)).throw(_.invalidParameters),[4,this._manager.getMyGroupChannelChangeLogs(e,n)];case 1:return[2,a.sent()]}}))}))},t.prototype.getGroupChannelCount=function(e){return i(this,void 0,void 0,(function(){var t;return h(this,(function(n){return t=W(W({},Ee),e),ce(we(t)).throw(_.invalidParameters),[2,this._manager.getGroupChannelCount(t)]}))}))},t.prototype.getUnreadItemCount=function(e){return void 0===e&&(e={}),i(this,void 0,void 0,(function(){return h(this,(function(t){switch(t.label){case 0:return[4,this._manager.getUnreadItemCount(e)];case 1:return[2,t.sent()]}}))}))},t.prototype.getTotalUnreadChannelCount=function(){return i(this,void 0,void 0,(function(){return h(this,(function(e){switch(e.label){case 0:return[4,this._manager.getTotalUnreadChannelCount()];case 1:return[2,e.sent()]}}))}))},t.prototype.getTotalUnreadMessageCount=function(e){return void 0===e&&(e={}),i(this,void 0,void 0,(function(){return h(this,(function(t){switch(t.label){case 0:return[4,this._manager.getTotalUnreadMessageCount(e)];case 1:return[2,t.sent()]}}))}))},t.prototype.getTotalScheduledMessageCount=function(e){return void 0===e&&(e={}),i(this,void 0,void 0,(function(){return h(this,(function(t){switch(t.label){case 0:return[4,this._manager.getTotalScheduledMessageCount(e)];case 1:return[2,t.sent()]}}))}))},t.prototype.getSubscribedTotalUnreadMessageCount=function(){return this._manager.getSubscribedTotalUnreadMessageCount()},t.prototype.getSubscribedCustomTypeTotalUnreadMessageCount=function(){return this._manager.getSubscribedCustomTypeTotalUnreadMessageCount()},t.prototype.getSubscribedCustomTypeUnreadMessageCount=function(e){return this._manager.getSubscribedCustomTypeUnreadMessageCount(e)},t.prototype.createChannel=function(e){return void 0===e&&(e={}),i(this,void 0,void 0,(function(){var t;return h(this,(function(n){return t=W(W({},Le),e),ce(Te(t)).throw(_.invalidParameters),[2,this._manager.createChannel(t)]}))}))},t.prototype.createDistinctChannelIfNotExist=function(e){return void 0===e&&(e={}),i(this,void 0,void 0,(function(){var t;return h(this,(function(n){return t=W(W({},Le),e),ce(Te(t)).throw(_.invalidParameters),t&&(t.isDistinct=!0),[2,this.createChannel(t)]}))}))},t.prototype.createChannelWithUserIds=function(e,t,n,a,r,s){return void 0===t&&(t=!1),void 0===r&&(r=""),void 0===s&&(s=""),i(this,void 0,void 0,(function(){var i;return h(this,(function(o){return i=W(W({},Le),{invitedUserIds:e,isDistinct:t,name:n,data:r,customType:s}),"string"==typeof a?i.coverUrl=a:i.coverImage=a,[2,this.createChannel(i)]}))}))},t.prototype.markAsReadAll=function(){return i(this,void 0,void 0,(function(){return h(this,(function(e){return this._manager.markAsReadAll(),[2]}))}))},t.prototype.markAsReadWithChannelUrls=function(e){return i(this,void 0,void 0,(function(){return h(this,(function(t){return ce(re("string",e)).throw(_.invalidParameters),this._manager.markAsReadWithChannelUrls(e),[2]}))}))},t.prototype.markAsDelivered=function(e){return i(this,void 0,void 0,(function(){return h(this,(function(t){switch(t.label){case 0:return ce(ae("string",e)).throw(_.invalidParameters),[4,this.getChannel(e)];case 1:return[4,t.sent().markAsDelivered()];case 2:return t.sent(),[2]}}))}))},t}(he);export{Qe as GroupChannelCollection,Be as GroupChannelHandler,Xe as GroupChannelModule,Oe as MembershipFilter,ze as PublicGroupChannelListQuery,Je as ScheduledMessageListQuery};
diff --git a/index.js b/index.js
index 85b0dfe..d11a125 100644
--- a/index.js
+++ b/index.js
@@ -1 +1 @@
-import{i as e,a as n,_ as r,E as i,b as o,c as a,A as c,d,e as l,u as h,f,U as p,g,h as _,P as b,j as I,k as E,l as D,S as A,L as M,m as z,n as Q,V as j,o as H,p as G,v as W,C as K,q as V,r as J,s as ee,t as te,w as ne,x as re,y as ie,z as oe,W as se,B as ae,D as ue,F as ce,G as de,H as le,I as he,J as fe,K as pe,M as ve,N as ge,O as _e,Q as me,R as be,T as ye}from"./lib/__bundle-753d9ea0.js";export{Z as CachedChannelInfo,Y as ChannelType,X as CollectionEventSource,C as ConnectionState,a6 as DeviceOsPlatform,L as LocalCacheConfig,$ as LogLevel,a0 as NotificationInfo,T as PushTemplate,N as PushTokenRegistrationState,P as PushTokenType,R as PushTriggerOption,a1 as Role,S as SendbirdChatOptions,q as SendbirdError,a5 as SendbirdPlatform,a4 as SendbirdProduct,a2 as UIKitConfigInfo,U as User,a3 as UserOnlineState}from"./lib/__bundle-753d9ea0.js";import{N as we,a as Ie,b as ke,c as Ce,g as Se,M as Te,d as Ee,e as Ue,f as Pe,h as De,i as Oe,j as Ae,k as Le,A as Ne,I as Me,l as Re,U as ze,C as Qe,m as je,B as Fe,F as qe,n as He,S as xe,o as Ge,p as We,q as Be,r as Ke}from"./lib/__bundle-2cf97ad3.js";export{m as ApplicationUserListQuery,s as BannedUserListQuery,t as BaseChannel,B as BlockedUserListQuery,C as ConnectionHandler,F as FriendListQuery,k as MemoryStore,u as MutedUserListQuery,O as OperatorListQuery,P as Participant,v as Plugin,R as ReportCategory,w as RestrictedUser,x as RestrictionInfo,y as RestrictionType,S as SessionHandler,U as UserEventHandler}from"./lib/__bundle-2cf97ad3.js";import{PollModule as Ve}from"./poll.js";import{g as Je,G as Xe,A as Ye,U as Ze,a as $e,b as et,D as tt,R as nt}from"./lib/__bundle-743309b9.js";import{g as rt,N as it}from"./lib/__bundle-ccebf220.js";import"./lib/__bundle-c336221f.js";var ot=function(e){this.key=e.key,this.url=e.url},st=function(e){this.id=e.id,this.name=e.name,this.url=e.url,this.emojis=e.emojis?e.emojis.map((function(e){return new ot(e)})):[]},at=function(e){this.emojiHash=e.emoji_hash||"",this.emojiCategories=e.emoji_categories?e.emoji_categories.map((function(e){return new st(e)})):[]},ut={profileImage:void 0,profileUrl:void 0,nickname:void 0},ct=function(e){return{v2:e.commitSchema([{collectionName:we,keyName:Ie,index:[Je(Xe.LATEST_LAST_MESSAGE),Je(Xe.CHRONOLOGICAL),Je(Xe.CHANNEL_NAME_ALPHABETICAL)]},{collectionName:ke,keyName:Ce,index:[Se(Te.CHANNEL_LATEST),Se(Te.NEWEST_CHILD_MESSAGE)]},{collectionName:Ee,keyName:Ue,index:[Se(Te.CHANNEL_LATEST),Se(Te.NEWEST_CHILD_MESSAGE)]},{collectionName:Pe,keyName:De}]),v3:e.commitSchema([{collectionName:Oe,keyName:Ae,index:[rt("latest_last_message")]}])}},dt=function(e){return function(t,n){switch(t){case 1:e.clear().then((function(){ct(e).v2.then((function(){return n()})).catch((function(e){return n(e)}))})).catch((function(e){return n(e)}));break;case 2:ct(e).v3.then((function(){return n()})).catch((function(e){return n(e)}));break;default:n()}}},lt=function(){return"undefined"!=typeof document?document.visibilityState:"visible"},ht=function(e){function t(t){var n=t.getVisibilityState,r=void 0===n?lt:n,i=t.initialState,o=void 0===i?"visible":i,s=t.isEnabled,a=void 0===s||s,u=t.pauseCheckDelay,c=void 0===u?3e4:u,d=e.call(this)||this;return d._pauseCheckDelay=3e4,d._currentState="visible",d._getVisibilityState=r,d._pauseCheckDelay=c,d._currentState=o,d._isEnabled=a,d._boundToggleState=d._toggleState.bind(d),d}return r(t,e),Object.defineProperty(t.prototype,"currentState",{get:function(){return this._currentState},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"isAvailable",{get:function(){return"undefined"!=typeof window&&!!window.addEventListener&&!!window.removeEventListener},enumerable:!1,configurable:!0}),t.prototype._toggleState=function(){var e=this,t=this._getVisibilityState();"hidden"!==t?"hidden"===this._currentState&&(this._pauseDelayTimer&&(clearTimeout(this._pauseDelayTimer),this._pauseDelayTimer=void 0),this.dispatch("resume")):"hidden"!==this._currentState&&(this._pauseDelayTimer=setTimeout((function(){e._pauseDelayTimer=void 0,e.dispatch("pause")}),this._pauseCheckDelay)),this._currentState=t},t.prototype.start=function(){this._isEnabled&&this.isAvailable&&(this._boundToggleState=this._toggleState.bind(this),window.addEventListener("visibilitychange",this._boundToggleState,{capture:!0}))},t.prototype.stop=function(){this._isEnabled&&this.isAvailable&&this._boundToggleState&&window.removeEventListener("visibilitychange",this._boundToggleState,{capture:!0})},t}(i),ft=function(){function e(e){var t=e.logger,n=e.connectionDelegate,r=void 0===n?null:n,i=this;this._onlineWorker=function(){var e;return null===(e=i.connectionDelegate)||void 0===e?void 0:e.reconnect()},this._offlineWorker=function(){var e;return null===(e=i.connectionDelegate)||void 0===e?void 0:e.disconnect()},this.unsubscribes=[],this._onlineListener=function(e){if(i.isAvailableOnWeb)return window.addEventListener("online",e),function(){return window.removeEventListener("online",e,!1)}},this._offlineListener=function(e){if(i.isAvailableOnWeb)return window.addEventListener("offline",e),function(){return window.removeEventListener("offline",e,!1)}},this.logger=t,r&&(this.connectionDelegate=r)}return Object.defineProperty(e.prototype,"isAvailableOnWeb",{get:function(){return"undefined"!=typeof window&&!!window.addEventListener&&"ononline"in window&&"onoffline"in window&&"undefined"!=typeof navigator&&void 0!==navigator.onLine},enumerable:!1,configurable:!0}),e.prototype.setOnlineListener=function(e){Boolean(e)&&"function"==typeof e&&(this._onlineListener=e)},e.prototype.setOfflineListener=function(e){Boolean(e)&&"function"==typeof e&&(this._offlineListener=e)},e.prototype.start=function(){this.unsubscribes=[this._onlineListener(this._onlineWorker),this._offlineListener(this._offlineWorker)]},e.prototype.stop=function(){var e=this;this.unsubscribes.forEach((function(t){try{null==t||t()}catch(t){e.logger.warn(t.message)}})),this.unsubscribes=[]},e.prototype.isOnline=function(){return o(this,void 0,void 0,(function(){return a(this,(function(e){return this.isAvailableOnWeb?[2,navigator.onLine]:[2,new Promise((function(e){fetch("https://www.google.com",{method:c.GET,mode:"no-cors"}).then((function(){return e(!0)})).catch((function(){return e(!1)}))}))]}))}))},e}(),pt=function(e){function t(t){var n=t.userId,r=t.nickname,i=t.profileUrl,o=t.profileImage,s=t.preferredLanguages,a=e.call(this)||this;return a.method=c.PUT,a.path="".concat(d,"/").concat(encodeURIComponent(n)),a.params=l(h({nickname:r,profile_url:i,profile_file:o,preferred_languages:s})),a}return r(t,e),t}(f),vt=function(e){function t(t,n){var r=e.call(this,t,n)||this;return r.user=new p(t,g({},n)),r}return r(t,e),t}(_),gt=function(e){function t(t){var n=t.userId,r=t.token,i=e.call(this)||this;return i.method=c.POST,i.path="".concat(d,"/").concat(encodeURIComponent(n),"/push/apns"),i.params={apns_device_token:r,always_push:!0},i}return r(t,e),t}(f);!function(e){function t(t,n){var r=e.call(this,t,n)||this;return r.token=n.token,r.type=n.type?b[n.type.toLowerCase()]:b.UNKNOWN,r.user=new p(t,n.user),r}r(t,e)}(_);var _t=function(e){function t(t){var n=t.userId,r=t.token,i=e.call(this)||this;return i.method=c.POST,i.path="".concat(d,"/").concat(encodeURIComponent(n),"/push/gcm"),i.params={gcm_reg_token:r,always_push:!0},i}return r(t,e),t}(f);!function(e){function t(t,n){var r=e.call(this,t,n)||this;return r.token=n.token,r.type=n.type?b[n.type.toLowerCase()]:b.UNKNOWN,r.user=new p(t,n.user),r}r(t,e)}(_);var mt=function(e){function t(t){var n=t.userId,r=t.token,i=e.call(this)||this;return i.method=c.DELETE,i.path="".concat(d,"/").concat(encodeURIComponent(n),"/push/apns/").concat(encodeURIComponent(r)),i}return r(t,e),t}(f);!function(e){function t(t,n){var r=e.call(this,t,n)||this;return r.token=n.token,r.user=new p(t,n.user),r.lastDeletedAt=n.device_token_last_deleted_at,r}r(t,e)}(_);var bt=function(e){function t(t){var n=t.userId,r=t.token,i=e.call(this)||this;return i.method=c.DELETE,i.path="".concat(d,"/").concat(encodeURIComponent(n),"/push/gcm/").concat(encodeURIComponent(r)),i}return r(t,e),t}(f);!function(e){function t(t,n){var r=e.call(this,t,n)||this;return r.token=n.token,r.user=new p(t,n.user),r.lastDeletedAt=n.device_token_last_deleted_at,r}r(t,e)}(_);var yt=function(e){function t(t){var n=t.userId,r=e.call(this)||this;return r.method=c.DELETE,r.path="".concat(d,"/").concat(encodeURIComponent(n),"/push/apns"),r}return r(t,e),t}(f);!function(e){function t(t,n){var r=e.call(this,t,n)||this;return r.type=n.type?b[n.type.toLowerCase()]:b.UNKNOWN,r.user=new p(t,n.user),r.lastDeletedAt=n.device_token_last_deleted_at,r}r(t,e)}(_);var wt=function(e){function t(t){var n=t.userId,r=e.call(this)||this;return r.method=c.DELETE,r.path="".concat(d,"/").concat(encodeURIComponent(n),"/push/gcm"),r}return r(t,e),t}(f);!function(e){function t(t,n){var r=e.call(this,t,n)||this;return r.type=n.type?b[n.type.toLowerCase()]:b.UNKNOWN,r.user=new p(t,n.user),r.lastDeletedAt=n.device_token_last_deleted_at,r}r(t,e)}(_);var It=function(e){function t(t){var n=t.userId,r=t.type,i=t.token,o=t.ts,s=e.call(this)||this;return s.method=c.GET,s.path="".concat(d,"/").concat(encodeURIComponent(n),"/push/").concat(encodeURIComponent(r),"/device_tokens"),s.params={created_ts:o,token:i},s}return r(t,e),t}(f),kt=function(e){function t(t,n){var r=e.call(this,t,n)||this;return r.pushTokens={type:n.type?b[n.type.toLowerCase()]:b.UNKNOWN,deviceTokens:n.device_tokens,hasMore:n.has_more,token:n.token},r}return r(t,e),t}(_),Ct=function(e){function t(t){var n=t.userId,r=e.call(this)||this;return r.method=c.GET,r.path="".concat(d,"/").concat(encodeURIComponent(n),"/channel_invitation_preference"),r}return r(t,e),t}(f),St=function(e){function t(t,n){var r=e.call(this,t,n)||this;return r.autoAccept=n.auto_accept,r}return r(t,e),t}(_),Tt=function(e){function t(t){var n=t.userId,r=t.willAutoAccept,i=e.call(this)||this;return i.method=c.PUT,i.path="".concat(d,"/").concat(encodeURIComponent(n),"/channel_invitation_preference"),i.params={auto_accept:r},i}return r(t,e),t}(f),Et=function(e){function t(t,n){var r=e.call(this,t,n)||this;return r.autoAccept=n.auto_accept,r}return r(t,e),t}(_),Ut=function(e){function t(t){var n=t.userId,r=e.call(this)||this;return r.method=c.GET,r.path="".concat(d,"/").concat(encodeURIComponent(n),"/push_preference"),r}return r(t,e),t}(f),Pt=function(e){function t(t,n){var r=e.call(this,t,n)||this;return r.preference={doNotDisturbOn:n.do_not_disturb,startHour:n.start_hour,startMin:n.start_min,endHour:n.end_hour,endMin:n.end_min,timezone:n.timezone},r}return r(t,e),t}(_),Dt=function(e){function t(t){var n=t.userId,r=t.doNotDisturbOn,i=t.startHour,o=t.startMin,s=t.endHour,a=t.endMin,u=t.timezone,l=e.call(this)||this;return l.method=c.PUT,l.path="".concat(d,"/").concat(encodeURIComponent(n),"/push_preference"),l.params={do_not_disturb:r,start_hour:i,start_min:o,end_hour:s,end_min:a,timezone:u},l}return r(t,e),t}(f),Ot=function(e){function t(t,n){var r=e.call(this,t,n)||this;return r.preference={doNotDisturbOn:n.do_not_disturb,startHour:n.start_hour,startMin:n.start_min,endHour:n.end_hour,endMin:n.end_min,timezone:n.timezone},r}return r(t,e),t}(_),At=function(e){function t(t){var n=t.userId,r=e.call(this)||this;return r.method=c.GET,r.path="".concat(d,"/").concat(encodeURIComponent(n),"/push_preference"),r}return r(t,e),t}(f),Lt=function(e){function t(t,n){var r=e.call(this,t,n)||this;return r.snoozePeriod={isSnoozeOn:n.snooze_enabled},"number"==typeof n.snooze_start_ts&&(r.snoozePeriod.startTs=n.snooze_start_ts),"number"==typeof n.snooze_end_ts&&(r.snoozePeriod.endTs=n.snooze_end_ts),r}return r(t,e),t}(_),Nt=function(e){function t(t){var n=t.userId,r=t.snoozeOn,i=t.startTs,o=t.endTs,s=e.call(this)||this;return s.method=c.PUT,s.path="".concat(d,"/").concat(encodeURIComponent(n),"/push_preference"),s.params={snooze_enabled:r,snooze_start_ts:i,snooze_end_ts:o},s}return r(t,e),t}(f),Mt=function(e){function t(t,n){var r=e.call(this,t,n)||this;return r.snoozePeriod={isSnoozeOn:n.snooze_enabled},"number"==typeof n.snooze_start_ts&&(r.snoozePeriod.startTs=n.snooze_start_ts),"number"==typeof n.snooze_end_ts&&(r.snoozePeriod.endTs=n.snooze_end_ts),r}return r(t,e),t}(_),Rt=function(e){function t(t){var n=t.userId,r=t.blockedUserId,i=e.call(this)||this;return i.method=c.POST,i.path="".concat(d,"/").concat(encodeURIComponent(n),"/block"),i.params={target_id:r},i}return r(t,e),t}(f);!function(e){function t(t,n){var r=e.call(this,t,n)||this;return r.user=new p(t,n),r}r(t,e)}(_);var zt=function(e){function t(t){var n=t.userId,r=t.unblockedUserId,i=e.call(this)||this;return i.method=c.DELETE,i.path="".concat(d,"/").concat(encodeURIComponent(n),"/block/").concat(encodeURIComponent(r)),i}return r(t,e),t}(f);!function(e){function t(){return null!==e&&e.apply(this,arguments)||this}r(t,e)}(_);var Qt=function(e){function t(t){var n=t.userId,r=e.call(this)||this;return r.method=c.GET,r.path="".concat(d,"/").concat(encodeURIComponent(n),"/push_preference"),r}return r(t,e),t}(f),jt=function(e){function t(t,n){var r=e.call(this,t,n)||this;return r.pushTriggerOption=n.push_trigger_option,r}return r(t,e),t}(_),Ft=function(e){function t(t){var n=t.userId,r=t.pushTriggerOption,i=e.call(this)||this;return i.method=c.PUT,i.path="".concat(d,"/").concat(encodeURIComponent(n),"/push_preference"),i.params={push_trigger_option:r},i}return r(t,e),t}(f),qt=function(e){function t(t,n){var r=e.call(this,t,n)||this;return r.pushTriggerOption=n.push_trigger_option,r}return r(t,e),t}(_),Ht=function(e){function t(t){var n=t.userId,r=e.call(this)||this;return r.method=c.GET,r.path="".concat(d,"/").concat(encodeURIComponent(n),"/push/template"),r}return r(t,e),t}(f),xt=function(e){function t(t,n){var r=e.call(this,t,n)||this;return r.name=n.name,r}return r(t,e),t}(_),Gt=function(e){function t(t){var n=t.userId,r=t.templateName,i=e.call(this)||this;return i.method=c.PUT,i.path="".concat(d,"/").concat(encodeURIComponent(n),"/push/template"),i.params={name:r},i}return r(t,e),t}(f),Wt=function(e){function t(t,n){var r=e.call(this,t,n)||this;return r.name=n.name,r}return r(t,e),t}(_),Bt=function(e){function t(t){var n=t.userId,r=t.token,i=e.call(this)||this;return i.method=c.GET,i.path="".concat(d,"/").concat(encodeURIComponent(n),"/friends/changelogs"),i.params={token:r},i}return r(t,e),t}(f),Kt=function(e){function t(t,n){var r=e.call(this,t,n)||this;return r.changelogs={addedUsers:n.added.map((function(e){return new p(t,e)})),updatedUsers:n.updated.map((function(e){return new p(t,e)})),deletedUserIds:n.deleted,hasMore:n.has_more,token:n.next},r}return r(t,e),t}(_),Vt=function(e){function t(t){var n=t.userId,r=t.discoveries,i=e.call(this)||this;return i.method=c.PUT,i.path="".concat(d,"/").concat(encodeURIComponent(n),"/friend_discoveries"),i.params={friend_discoveries:r.map((function(e){return{friend_discovery_key:e.friendDiscoveryKey,friend_name:e.friendName}}))},i}return r(t,e),t}(f),Jt=function(e){function t(t,n){var r=e.call(this,t,n)||this;return r.friendDiscoveryRequestId=n.friend_discovery_request_id,r}return r(t,e),t}(_),Xt=function(e){function t(t){var n=t.userId,r=t.discoveryKeys,i=e.call(this)||this;return i.method=c.DELETE,i.path="".concat(d,"/").concat(encodeURIComponent(n),"/friend_discoveries"),i.params={friend_discovery_keys:r},i}return r(t,e),t}(f);!function(e){function t(){return null!==e&&e.apply(this,arguments)||this}r(t,e)}(_);var Yt=function(e){function t(t){var n=t.userId,r=t.userIds,i=e.call(this)||this;return i.method=c.POST,i.path="".concat(d,"/").concat(encodeURIComponent(n),"/friends"),i.params={user_ids:r},i}return r(t,e),t}(f),Zt=function(e){function t(t,n){var r=e.call(this,t,n)||this;return r.users=n.users.map((function(e){return new p(t,e)})),r}return r(t,e),t}(_),$t=function(e){function t(t){var n=t.userId,r=t.userIds,i=e.call(this)||this;return i.method=c.DELETE,i.path="".concat(d,"/").concat(encodeURIComponent(n),"/friends"),i.params={user_ids:r},i}return r(t,e),t}(f);!function(e){function t(){return null!==e&&e.apply(this,arguments)||this}r(t,e)}(_);var en=function(e){function t(t){var n=t.userId,r=e.call(this)||this;return r.method=c.GET,r.path="".concat(d,"/").concat(n,"/allow_friend_discovery"),r.params={},r}return r(t,e),t}(f),tn=function(e){function t(t,n){var r=e.call(this,t,n)||this;return r.allowFriendDiscovery=n.allow_friend_discovery,r}return r(t,e),t}(_),nn=function(e){function t(t){var n=t.userId,r=t.allowFriendDiscovery,i=e.call(this)||this;return i.method=c.PUT,i.path="".concat(d,"/").concat(n,"/allow_friend_discovery"),i.params={allow_friend_discovery:r},i}return r(t,e),t}(f);!function(e){function t(){return null!==e&&e.apply(this,arguments)||this}r(t,e)}(_);var rn,on=function(e){function t(){var t=e.call(this)||this;return t.method=c.GET,t.path=I,t}return r(t,e),t}(f),sn=function(e){function t(t,n){var r=e.call(this,t,n)||this;return r.emojiContainer=new at(n),r}return r(t,e),t}(_),an=function(e){function t(t){var n=t.categoryId,r=e.call(this)||this;return r.method=c.GET,r.path="".concat(I,"/").concat(n),r}return r(t,e),t}(f),un=function(e){function t(t,n){var r=e.call(this,t,n)||this;return r.emojiCategory=new st(n),r}return r(t,e),t}(_),cn=function(e){function t(t){var n=t.key,r=e.call(this)||this;return r.method=c.GET,r.path="".concat(E,"/").concat(n),r}return r(t,e),t}(f),dn=function(e){function t(t,n){var r=e.call(this,t,n)||this;return r.emoji=new ot(n),r}return r(t,e),t}(_),ln=function(e){function t(){var t=e.call(this)||this;return t.method=c.GET,t.path="".concat(D),t}return r(t,e),t}(f),hn=function(e){function t(t,n){var r,i=this,o=null!=n?n:{};return(i=e.call(this,t,n)||this).uikitConfiguration={string:JSON.stringify(o),json:o},i.updatedAt=null!==(r=null==n?void 0:n.updated_at)&&void 0!==r?r:0,i}return r(t,e),t}(_),fn=function(){function t(e,t,n){var r=this;this._storeInitialized=!1,this._iid=e,this.options=t;var i=j.of(e),s=i.sdkState,u=i.cacheContext,c=i.dispatcher,d=i.sessionManager,l=i.requestQueue,h=i.logger,f=i.userEventHandlers,p=i.appStateToggleEnabled;this._onlineDetector=new ft({logger:h,connectionDelegate:{reconnect:function(){var t=j.of(e),n=t.sdkState,r=t.connectionManager,i=t.sessionManager;i.session.hasSession?"foreground"===n.appState&&r.resetAndReconnect():r.connect(i.session.authToken),c.dispatch(new it)},disconnect:function(){j.of(e).connectionManager.disconnect()}}});var v=new Ye(e,{localCacheEnabled:u.localCacheEnabled,enableAutoResend:u.localCacheConfig.enableAutoResend,dispatcher:c,sdkState:s,logger:h});n.forEach((function(t){t.init(e,{sdkState:s,cacheContext:u,dispatcher:c,sessionManager:d,requestQueue:l,logger:h,onlineDetector:r._onlineDetector}),r[t.name]=t})),this._appStateChangeDetector=new ht({isEnabled:p}),this._appStateChangeDetector.on("resume",(function(){h.debug("the page resumes from freeze"),r.setForegroundState()})).on("pause",(function(){h.debug("the page freezes"),r.setBackgroundState()})),c.on((function(t){var n;if(t instanceof ie){if(t.stateType===oe.CONNECTED)v.processNonAutoResendRegisteredPendingMessages()}else if(t instanceof se){if("USEV"===t.code){var i=t.as(Ze).event;if(i.category===$e.FRIEND_DISCOVERED){var c=et.getDataAsFriendDiscoveredEvent(e,i).friendDiscoveries;ae((function(){return o(r,void 0,void 0,(function(){return a(this,(function(e){return[2,f.forEach((function(e){e.onFriendsDiscovered&&e.onFriendsDiscovered(c)}))]}))}))}))}}}else if(t instanceof ue){var d=j.of(r._iid).subscribedUnreadMessageCount,l=!1,p=t.ts;if("number"==typeof p&&p>d.ts){if(d.all!==t.all&&(l=!0),d.all=t.all>=0?t.all:0,t.customTypes)for(var g in t.customTypes)d.customTypes[g]!==t.customTypes[g]&&(l=!0),d.customTypes[g]=t.customTypes[g];l=l&&d.ts>0,d.ts=p}l&&ae((function(){return o(r,void 0,void 0,(function(){return a(this,(function(e){return[2,f.forEach((function(e){e.onTotalUnreadMessageCountChanged&&e.onTotalUnreadMessageCountChanged({groupChannelCount:d.all,feedChannelCount:d.feed,customTypeUnreadCount:d.customTypes}),e.onTotalUnreadMessageCountUpdated&&e.onTotalUnreadMessageCountUpdated(d.all,d.customTypes)}))]}))}))}))}else t instanceof ce?(u.preference.set(r._getUserProfileCacheKey(s.userId),de.payloadify(t.userProfile)),(null===(n=t.userProfile.appInfo.notificationInfo)||void 0===n?void 0:n.isEnabled)&&u.preference.set(le(r.appId),{value:!0})):t instanceof he&&t.error&&t.error.isSessionInvalidatedError&&(h.debug("session revoked."),r.disconnect())}))}return t.init=function(e){var n=e.appId,r=e.appVersion,i=e.modules,o=void 0===i?[]:i,s=e.options,a=void 0===s?new A:s,u=e.debugMode,c=void 0!==u&&u,d=e.customApiHost,l=e.customWebSocketHost,h=e.newInstance,f=void 0!==h&&h,p=e.logLevel,v=e.localCacheEnabled,g=void 0!==v&&v,_=e.localCacheConfig,m=void 0===_?new M:_,b=e.localCacheEncryption,y=e.useAsyncStorageStore,w=void 0===y?null:y,I=e.appStateToggleEnabled,k=void 0===I||I;if(!rn||f){var C="su-".concat(z()),S=null!=b?b:{encrypt:function(e){return e},decrypt:function(e){return e}},T=new Le({encryption:S});c||(T=Q()?w?new Ne({AsyncStorage:w,encryption:S}):new Le({encryption:S}):new Me({encryption:S})),new j(C,{appId:n,appVersion:r,options:a,apiHost:null!=d?d:"https://api-".concat(n,".sendbird.com"),websocketHost:null!=l?l:"wss://ws-".concat(n,".sendbird.com"),store:T,encryption:S,logLevel:p,localCacheEnabled:g,localCacheConfig:m,debugMode:c,appStateToggleEnabled:k});var E=[new Re,new Ve],U=new t(C,a,H(H([],G(o),!1),G(E),!1));return rn||(rn=U),U}return rn},Object.defineProperty(t,"instance",{get:function(){return rn},enumerable:!1,configurable:!0}),Object.defineProperty(t,"version",{get:function(){return W},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"appId",{get:function(){return j.of(this._iid).sdkState.appId},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"appInfo",{get:function(){var e=j.of(this._iid).appInfo;return null!=e?e:null},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"appVersion",{get:function(){var e;return null!==(e=j.of(this._iid).sdkState.appVersion)&&void 0!==e?e:""},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"debugMode",{get:function(){return!!j.of(this._iid).debugMode},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"logLevel",{get:function(){return j.of(this._iid).logger.level},set:function(e){j.of(this._iid).logger.level=e},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"isCacheEnabled",{get:function(){return j.of(this._iid).cacheContext.localCacheEnabled},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"localCacheConfig",{get:function(){var e=j.of(this._iid).cacheContext;return e.localCacheEnabled?e.localCacheConfig:null},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"ekey",{get:function(){return j.of(this._iid).sessionManager.ekey},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"currentUser",{get:function(){var e;return null!==(e=j.of(this._iid).sessionManager.currentUser)&&void 0!==e?e:null},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"connectionState",{get:function(){var e=j.of(this._iid).connectionManager;return e.isConnected?K.OPEN:e.isConnecting?K.CONNECTING:K.CLOSED},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"lastConnectedAt",{get:function(){var e=j.of(this._iid),t=e.connectedAt;return e.connectionManager.isConnected?t:0},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"fcmPushToken",{get:function(){var e;return null!==(e=this._fcmPushToken)&&void 0!==e?e:null},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"apnsPushToken",{get:function(){var e;return null!==(e=this._apnsPushToken)&&void 0!==e?e:null},enumerable:!1,configurable:!0}),t.prototype._getNestDBVersion=function(){return 3},t.prototype._getPreferenceCacheKey=function(e){return"sendbird@".concat(this.appId,"/").concat(e,".pref")},t.prototype._getUserProfileCacheKey=function(e){return"sendbird@".concat(this.appId,"/").concat(e,".profile")},t.prototype.getMemoryStoreForDebugging=function(){var e=j.of(this._iid),t=e.debugMode,n=e.cacheContext;if(t)return n.store instanceof Le?n.store:null;throw V.debugModeRequired},t.prototype.addExtension=function(e,t){var n=j.of(this._iid).sdkState;["sb_uikit","sb_syncmanager","device-os-platform"].indexOf(e)>-1&&n.extensions&&(n.extensions[e]=t)},t.prototype.addSendbirdExtensions=function(e,t,n){var r,i,o=j.of(this._iid),s=o.logger,a=o.sdkState,u=new RegExp(fe);if(0===e.length)return s.debug("sb.addSendbirdExtensions() has failed because the given sendbirdExtensions is empty."),!1;if(e.find((function(e){return!u.test(e.version)})))return s.debug("sb.addSendbirdExtensions() has failed because the given version did not satisfy the SemVer specification."),!1;if(n)try{for(var c=J(Object.entries(n)),d=c.next();!d.done;d=c.next()){var l=G(d.value,2),h=l[0],f=l[1];if(/&|=/.test(h)||/&|=/.test(f))return s.debug("sb.addSendbirdExtensions() has failed because the given customData includes at least one invalid character: = or &."),!1}}catch(e){r={error:e}}finally{try{d&&!d.done&&(i=c.return)&&i.call(c)}finally{if(r)throw r.error}}return a.sendbirdRuntimeEnvironment={sendbirdExtensions:e,deviceOS:t,customData:n},!0},t.prototype.setOnlineListener=function(e){this._onlineDetector.setOnlineListener(e)},t.prototype.setOfflineListener=function(e){this._onlineDetector.setOfflineListener(e)},t.prototype._safeInitializeStore=function(e){return o(this,void 0,void 0,(function(){var t;return a(this,(function(n){switch(n.label){case 0:t=j.of(this._iid).cacheContext,n.label=1;case 1:return n.trys.push([1,3,,5]),[4,t.store.init(e)];case 2:return n.sent(),this._storeInitialized=!0,[3,5];case 3:return n.sent(),t.replaceStore(new Le),[4,this._safeInitializeStore(e)];case 4:return n.sent(),[3,5];case 5:return[2]}}))}))},t.prototype.initializeCache=function(e){return o(this,void 0,void 0,(function(){var t,n,r,i,o,s,u,c;return a(this,(function(a){switch(a.label){case 0:if(t=j.of(this._iid),n=t.sdkState,r=t.cacheContext,i=t.dispatcher,o=t.logger,n.userId&&n.userId===e)return[3,9];if(s="sendbird@".concat(n.appId,"/").concat(e,".db"),!r.localCacheEnabled)return[3,7];a.label=1;case 1:return a.trys.push([1,4,,6]),r.nestdb&&r.nestdb.state!==Ke.CLOSED&&r.nestdb.name===s?[3,3]:((u=r.nestdb=new Ge({name:"sendbird@".concat(n.appId,"/").concat(e,".db"),version:this._getNestDBVersion(),store:r.store})).on("upgrade",dt(u)),u.on("storeReplaced",(function(e){r.replaceStore(e),r.localCacheEnabled=!1,u.on("upgrade",dt(u))})),[4,u.open()]);case 2:a.sent(),this._storeInitialized=!0,i.dispatch(new tt(this._iid,{userId:e})),a.label=3;case 3:return n.userId=e,[3,6];case 4:return c=a.sent(),o.warn("Nest DB Open Failed. ",c),[4,this._safeInitializeStore(s)];case 5:throw a.sent(),n.userId=e,V.databaseError;case 6:return[3,9];case 7:return[4,this._safeInitializeStore(s)];case 8:a.sent(),n.userId=e,a.label=9;case 9:return[2]}}))}))},t.prototype.getCacheDataSize=function(){return o(this,void 0,void 0,(function(){var e;return a(this,(function(t){switch(t.label){case 0:return(e=j.of(this._iid).cacheContext).localCacheEnabled&&e.nestdb?[4,e.nestdb.estimateUsage()]:[3,2];case 1:return[2,t.sent()];case 2:return[2,0]}}))}))},t.prototype.clearCachedData=function(){return o(this,void 0,void 0,(function(){var e;return a(this,(function(t){switch(t.label){case 0:return(e=j.of(this._iid).cacheContext).localCacheEnabled&&e.nestdb?[4,e.nestdb.clear()]:[3,2];case 1:t.sent(),t.label=2;case 2:return this._storeInitialized?[4,e.preference.clear()]:[3,4];case 3:t.sent(),t.label=4;case 4:return[2]}}))}))},t.prototype.clearCachedMessages=function(e){return o(this,void 0,void 0,(function(){var t,n,r=this;return a(this,(function(i){switch(i.label){case 0:return ee(pe("string",e)).throw(V.invalidParameters),t=We.of(this._iid),n=Be.of(this._iid),t&&n?[4,Promise.all(e.map((function(e){return o(r,void 0,void 0,(function(){return a(this,(function(r){switch(r.label){case 0:return[4,t.removeMessagesOfChannel(e)];case 1:return r.sent(),[4,n.removeMessagesOfChannel(e)];case 2:return r.sent(),[2]}}))}))})))]:[3,2];case 1:i.sent(),i.label=2;case 2:return[2]}}))}))},t.prototype._ready=function(e,t,r){return void 0===r&&(r={}),o(this,void 0,void 0,(function(){var i,o,s,u,c,d,l,h;return a(this,(function(a){switch(a.label){case 0:return ee(n("string",e)&&n("string",t,!0)).throw(V.invalidParameters),i=j.of(this._iid),o=i.sdkState,s=i.cacheContext,u=i.connectionManager,c=i.statLogCollector,d=r.errorForOtherUser,o.userId?[3,2]:[4,u.logout()];case 1:case 3:return a.sent(),[3,5];case 2:return o.userId===e?[3,5]:d?[3,4]:[4,u.logout()];case 4:throw d;case 5:return a.trys.push([5,7,,8]),[4,this.initializeCache(e)];case 6:return a.sent(),j.of(this._iid).dispatcher.dispatch(new nt),[3,8];case 7:return a.sent(),l=j.of(this._iid).logger,s.localCacheEnabled=!1,l.warn("Cache initialization failed - cache is not available."),[3,8];case 8:return[4,s.preference.init(this._getPreferenceCacheKey(e),this._getNestDBVersion())];case 9:return a.sent(),[4,s.preference.get(this._getUserProfileCacheKey(e))];case 10:return(h=a.sent())&&new de(this._iid,h).apply(),[4,c.init("sendbird@".concat(o.appId,"/").concat(e,".statlog"))];case 11:return a.sent(),[2]}}))}))},t.prototype.authenticateFeed=function(e,t){return o(this,void 0,void 0,(function(){var n,r,i;return a(this,(function(o){switch(o.label){case 0:return n=j.of(this._iid),r=n.sessionManager,i=n.connectionManager,[4,this._ready(e,t,{errorForOtherUser:i.isConnected?V.alreadyConnectedAsAnotherUser:void 0})];case 1:return o.sent(),r.session.hasLessServiceScopeThan([ve.FEED])?[4,r.authenticateFeed(e,t)]:[3,3];case 2:o.sent(),o.label=3;case 3:return[2,this.currentUser]}}))}))},t.prototype.connect=function(e,t){return o(this,void 0,void 0,(function(){return a(this,(function(n){switch(n.label){case 0:return[4,this._ready(e,t)];case 1:n.sent(),n.label=2;case 2:return n.trys.push([2,,4,5]),[4,j.of(this._iid).connectionManager.connect(t)];case 3:return n.sent(),[3,5];case 4:return this._onlineDetector.start(),this._appStateChangeDetector.start(),[7];case 5:return[2,this.currentUser]}}))}))},t.prototype.reconnect=function(){var e=j.of(this._iid),t=e.connectionManager,n=e.sdkState,r=e.sessionManager.session.hasSession;return r&&(this._appStateChangeDetector.start(),this._onlineDetector.start(),t.resetAndReconnect().then((function(){n.appState="foreground"})).catch((function(){}))),r},t.prototype.disconnect=function(){return o(this,void 0,void 0,(function(){var e,t,n;return a(this,(function(r){switch(r.label){case 0:return e=j.of(this._iid),t=e.connectionManager,n=e.requestQueue,e.sessionManager,this._appStateChangeDetector.stop(),this._onlineDetector.stop(),n.cancelAll(),[4,t.logout()];case 1:return r.sent(),[4,this.clearCachedData()];case 2:return r.sent(),[2]}}))}))},t.prototype.disconnectWebSocket=function(){return o(this,void 0,void 0,(function(){var e,t,n;return a(this,(function(r){switch(r.label){case 0:return e=j.of(this._iid),t=e.connectionManager,n=e.requestQueue,this._appStateChangeDetector.stop(),this._onlineDetector.stop(),n.cancelAll(),[4,t.disconnectWebSocket()];case 1:return r.sent(),[2]}}))}))},t.prototype.setBackgroundState=function(){var e=j.of(this._iid),t=e.connectionManager,n=e.sdkState,r=e.logger;"foreground"===n.appState&&(n.appState="background",r.debug("going background state"),t.background())},t.prototype.setForegroundState=function(){var e=j.of(this._iid),t=e.connectionManager,n=e.sdkState,r=e.dispatcher,i=e.logger;"background"===n.appState&&(n.appState="foreground",i.debug("going foreground state"),t.resetAndReconnect(),r.dispatch(new it))},t.prototype.setSessionHandler=function(e){ee(e instanceof xe).throw(V.invalidParameters),j.of(this._iid).sessionManager.handler=e},t.prototype.addUserEventHandler=function(e,t){ee(n("string",e)&&t instanceof ze).throw(V.invalidParameters),j.of(this._iid).userEventHandlers.set(e,t)},t.prototype.removeUserEventHandler=function(e){j.of(this._iid).userEventHandlers.delete(e)},t.prototype.removeAllUserEventHandler=function(){j.of(this._iid).userEventHandlers.clear()},t.prototype.addConnectionHandler=function(e,t){ee(n("string",e)&&t instanceof Qe).throw(V.invalidParameters),j.of(this._iid).connectionHandlers.set(e,t)},t.prototype.removeConnectionHandler=function(e){j.of(this._iid).connectionHandlers.delete(e)},t.prototype.removeAllConnectionHandler=function(){j.of(this._iid).connectionHandlers.clear()},t.prototype.createApplicationUserListQuery=function(e){return void 0===e&&(e={}),new je(this._iid,e)},t.prototype.createBlockedUserListQuery=function(e){return void 0===e&&(e={}),new Fe(this._iid,e)},t.prototype.createFriendListQuery=function(e){return void 0===e&&(e={}),new qe(this._iid,e)},t.prototype.createMessageSearchQuery=function(e){return new He(this._iid,e)},t.prototype.createPollListQuery=function(e){return new te(this._iid,g({},e))},t.prototype.createPollVoterListQuery=function(e){return new ne(this._iid,g({},e))},t.prototype.buildUserFromSerializedData=function(e){var t=re(e);return new p(this._iid,p.payloadify(t))},t.prototype.updateCurrentUserInfo=function(t){return void 0===t&&(t={}),o(this,void 0,void 0,(function(){var r,i,o,s,u,c,d;return a(this,(function(a){switch(a.label){case 0:return r=g(g({},ut),t),ee(function(t){return e(t.profileImage,!0)&&n("string",t.profileUrl,!0)&&n("string",t.nickname,!0)}(r)).throw(V.invalidParameters),this.currentUser?(i=j.of(this._iid),o=i.sdkState,s=i.requestQueue,u=new pt(g({userId:o.userId},r)),[4,s.send(u)]):[3,2];case 1:return c=a.sent(),d=c.as(vt).user,this.currentUser&&(r.nickname&&(this.currentUser.nickname=d.nickname),(r.profileUrl||r.profileImage)&&(this.currentUser.plainProfileUrl=d.profileUrl)),[2,d];case 2:throw V.connectionRequired}}))}))},t.prototype.updateCurrentUserInfoWithPreferredLanguages=function(e){return o(this,void 0,void 0,(function(){var t,n,r,i,o,s;return a(this,(function(a){switch(a.label){case 0:return ee(pe("string",e)).throw(V.invalidParameters),this.currentUser?(t=j.of(this._iid),n=t.sdkState,r=t.requestQueue,i=new pt({userId:n.userId,preferredLanguages:e}),[4,r.send(i)]):[3,2];case 1:return o=a.sent(),s=o.as(vt).user,this.currentUser&&(this.currentUser.preferredLanguages=s.preferredLanguages),[2,s];case 2:throw V.connectionRequired}}))}))},t.prototype.registerFCMPushTokenForCurrentUser=function(e){return o(this,void 0,void 0,(function(){var t,r,i,s,u,c=this;return a(this,(function(d){switch(d.label){case 0:if(ee(n("string",e)).throw(V.invalidParameters),!this.currentUser)return[3,6];d.label=1;case 1:return d.trys.push([1,4,,5]),t=j.of(this._iid),r=t.sessionManager,i=t.sdkState,s=t.requestQueue,r.hasDeviceToken(b.FCM,e)?[2,ge.SUCCESS]:(u=new _t({userId:i.userId,token:e}),[4,s.send(u)]);case 2:return d.sent(),[4,_e((function(){return o(c,void 0,void 0,(function(){return a(this,(function(t){switch(t.label){case 0:return r.setDeviceToken(b.FCM,e),[4,r.saveDeviceToken()];case 1:return t.sent(),[2]}}))}))}))];case 3:return d.sent(),this._fcmPushToken="",[2,ge.SUCCESS];case 4:return d.sent(),[2,ge.ERROR];case 5:return[3,7];case 6:return this._fcmPushToken=e,[2,ge.PENDING];case 7:return[2]}}))}))},t.prototype.unregisterFCMPushTokenForCurrentUser=function(e){return o(this,void 0,void 0,(function(){var t,r,i,s,u,c,d=this;return a(this,(function(l){switch(l.label){case 0:if(ee(n("string",e)).throw(V.invalidParameters),!this.currentUser)return[3,6];l.label=1;case 1:return l.trys.push([1,4,,5]),t=j.of(this._iid),r=t.sessionManager,i=t.sdkState,s=t.requestQueue,u=new bt({userId:i.userId,token:e}),[4,s.send(u)];case 2:return c=l.sent().lastDeletedAt,[4,_e((function(){return o(d,void 0,void 0,(function(){return a(this,(function(t){switch(t.label){case 0:return r.unsetDeviceToken(b.FCM,e),r.setDeviceTokenDeletedAt(c),[4,r.saveDeviceToken()];case 1:return t.sent(),[2]}}))}))}))];case 3:return l.sent(),this._fcmPushToken="",[2,ge.SUCCESS];case 4:return l.sent(),[2,ge.ERROR];case 5:return[3,7];case 6:return this._fcmPushToken=e,[2,ge.PENDING];case 7:return[2]}}))}))},t.prototype.unregisterFCMPushTokenAllForCurrentUser=function(){return o(this,void 0,void 0,(function(){var e,t,n,r,i,s,u=this;return a(this,(function(c){switch(c.label){case 0:return this.currentUser?(e=j.of(this._iid),t=e.sessionManager,n=e.sdkState,r=e.requestQueue,i=new wt({userId:n.userId}),[4,r.send(i)]):[3,3];case 1:return s=c.sent().lastDeletedAt,[4,_e((function(){return o(u,void 0,void 0,(function(){return a(this,(function(e){switch(e.label){case 0:return t.unsetDeviceTokens(b.FCM),t.setDeviceTokenDeletedAt(s),[4,t.saveDeviceToken()];case 1:return e.sent(),[2]}}))}))}))];case 2:c.sent(),c.label=3;case 3:return[2]}}))}))},t.prototype.registerAPNSPushTokenForCurrentUser=function(e){return o(this,void 0,void 0,(function(){var t,r,i,s,u,c=this;return a(this,(function(d){switch(d.label){case 0:if(ee(n("string",e)).throw(V.invalidParameters),!this.currentUser)return[3,6];d.label=1;case 1:return d.trys.push([1,4,,5]),t=j.of(this._iid),r=t.sessionManager,i=t.sdkState,s=t.requestQueue,r.hasDeviceToken(b.APNS,e)?[2,ge.SUCCESS]:(u=new gt({userId:i.userId,token:e}),[4,s.send(u)]);case 2:return d.sent(),[4,_e((function(){return o(c,void 0,void 0,(function(){return a(this,(function(t){switch(t.label){case 0:return r.setDeviceToken(b.APNS,e),[4,r.saveDeviceToken()];case 1:return t.sent(),[2]}}))}))}))];case 3:return d.sent(),this._apnsPushToken="",[2,ge.SUCCESS];case 4:return d.sent(),[2,ge.ERROR];case 5:return[3,7];case 6:return this._apnsPushToken=e,[2,ge.PENDING];case 7:return[2]}}))}))},t.prototype.unregisterAPNSPushTokenForCurrentUser=function(e){return o(this,void 0,void 0,(function(){var t,r,i,s,u,c,d=this;return a(this,(function(l){switch(l.label){case 0:if(ee(n("string",e)).throw(V.invalidParameters),!this.currentUser)return[3,6];l.label=1;case 1:return l.trys.push([1,4,,5]),t=j.of(this._iid),r=t.sessionManager,i=t.sdkState,s=t.requestQueue,u=new mt({userId:i.userId,token:e}),[4,s.send(u)];case 2:return c=l.sent().lastDeletedAt,[4,_e((function(){return o(d,void 0,void 0,(function(){return a(this,(function(t){switch(t.label){case 0:return r.unsetDeviceToken(b.APNS,e),r.setDeviceTokenDeletedAt(c),[4,r.saveDeviceToken()];case 1:return t.sent(),[2]}}))}))}))];case 3:return l.sent(),this._apnsPushToken="",[2,ge.SUCCESS];case 4:return l.sent(),[2,ge.ERROR];case 5:return[3,7];case 6:return this._apnsPushToken=e,[2,ge.PENDING];case 7:return[2]}}))}))},t.prototype.unregisterAPNSPushTokenAllForCurrentUser=function(){return o(this,void 0,void 0,(function(){var e,t,n,r,i,s,u=this;return a(this,(function(c){switch(c.label){case 0:return this.currentUser?(e=j.of(this._iid),t=e.sessionManager,n=e.sdkState,r=e.requestQueue,i=new yt({userId:n.userId}),[4,r.send(i)]):[3,3];case 1:return s=c.sent().lastDeletedAt,[4,_e((function(){return o(u,void 0,void 0,(function(){return a(this,(function(e){switch(e.label){case 0:return t.unsetDeviceTokens(b.APNS),t.setDeviceTokenDeletedAt(s),[4,t.saveDeviceToken()];case 1:return e.sent(),[2]}}))}))}))];case 2:c.sent(),c.label=3;case 3:return[2]}}))}))},t.prototype.getChannelInvitationPreference=function(){return o(this,void 0,void 0,(function(){var e,t,n,r,i;return a(this,(function(o){switch(o.label){case 0:return e=j.of(this._iid),t=e.sdkState,n=e.requestQueue,r=new Ct({userId:t.userId}),[4,n.send(r)];case 1:return i=o.sent(),[2,{autoAccept:i.as(St).autoAccept}]}}))}))},t.prototype.setChannelInvitationPreference=function(e){return o(this,void 0,void 0,(function(){var t,r,i,o,s;return a(this,(function(a){switch(a.label){case 0:return ee(n("boolean",e)).throw(V.invalidParameters),t=j.of(this._iid),r=t.sdkState,i=t.requestQueue,o=new Tt({userId:r.userId,willAutoAccept:e}),[4,i.send(o)];case 1:return s=a.sent(),[2,{autoAccept:s.as(Et).autoAccept}]}}))}))},t.prototype.getDoNotDisturb=function(){return o(this,void 0,void 0,(function(){var e,t,n,r,i;return a(this,(function(o){switch(o.label){case 0:return e=j.of(this._iid),t=e.sdkState,n=e.requestQueue,r=new Ut({userId:t.userId}),[4,n.send(r)];case 1:return i=o.sent(),[2,i.as(Pt).preference]}}))}))},t.prototype.setDoNotDisturb=function(e,t,r,i,s,u){return void 0===t&&(t=0),void 0===r&&(r=0),void 0===i&&(i=0),void 0===s&&(s=0),void 0===u&&(u=""),o(this,void 0,void 0,(function(){var o,c,d,l,h;return a(this,(function(a){switch(a.label){case 0:return ee(n("boolean",e)&&n("number",t)&&n("number",r)&&n("number",i)&&n("number",s)&&n("string",u)).throw(V.invalidParameters),o=j.of(this._iid),c=o.sdkState,d=o.requestQueue,l=new Dt({userId:c.userId,doNotDisturbOn:e,startHour:t,startMin:r,endHour:i,endMin:s,timezone:u}),[4,d.send(l)];case 1:return h=a.sent(),[2,h.as(Ot).preference]}}))}))},t.prototype.getSnoozePeriod=function(){return o(this,void 0,void 0,(function(){var e,t,n,r,i;return a(this,(function(o){switch(o.label){case 0:return e=j.of(this._iid),t=e.sdkState,n=e.requestQueue,r=new At({userId:t.userId}),[4,n.send(r)];case 1:return i=o.sent(),[2,i.as(Lt).snoozePeriod]}}))}))},t.prototype.setSnoozePeriod=function(e,t,r){return void 0===t&&(t=0),void 0===r&&(r=0),o(this,void 0,void 0,(function(){var i,o,s,u,c;return a(this,(function(a){switch(a.label){case 0:return ee(n("boolean",e)&&n("number",t)&&n("number",r)).throw(V.invalidParameters),i=j.of(this._iid),o=i.sdkState,s=i.requestQueue,u=new Nt({userId:o.userId,snoozeOn:e,startTs:t,endTs:r}),[4,s.send(u)];case 1:return c=a.sent(),[2,c.as(Mt).snoozePeriod]}}))}))},t.prototype.getMyPushTokensByToken=function(e,t){return o(this,void 0,void 0,(function(){var r,i,o,s,u,c,d,l,h,f,p,v;return a(this,(function(a){switch(a.label){case 0:return ee(n("string",e)&&me(b,t)).throw(V.invalidParameters),r=j.of(this._iid),i=r.sdkState,o=r.requestQueue,s=r.sessionManager,u=new It({userId:i.userId,type:t,token:e}),[4,o.send(u)];case 1:c=a.sent(),d=c.as(kt).pushTokens;try{for(l=J(d.deviceTokens),h=l.next();!h.done;h=l.next())f=h.value,s.setDeviceToken(d.type,f)}catch(e){p={error:e}}finally{try{h&&!h.done&&(v=l.return)&&v.call(l)}finally{if(p)throw p.error}}return[4,s.saveDeviceToken()];case 2:return a.sent(),[2,d]}}))}))},t.prototype.getPushTriggerOption=function(){return o(this,void 0,void 0,(function(){var e,t,n,r;return a(this,(function(i){switch(i.label){case 0:return e=j.of(this._iid),t=e.sdkState,n=e.requestQueue,r=new Qt({userId:t.userId}),[4,n.send(r)];case 1:return[2,i.sent().as(jt).pushTriggerOption]}}))}))},t.prototype.setPushTriggerOption=function(e){return o(this,void 0,void 0,(function(){var t,n,r,i;return a(this,(function(o){switch(o.label){case 0:return ee(me(be,e)).throw(V.invalidParameters),t=j.of(this._iid),n=t.sdkState,r=t.requestQueue,i=new Ft({userId:n.userId,pushTriggerOption:e}),[4,r.send(i)];case 1:return[2,o.sent().as(qt).pushTriggerOption]}}))}))},t.prototype.getPushTemplate=function(){return o(this,void 0,void 0,(function(){var e,t,n,r;return a(this,(function(i){switch(i.label){case 0:return e=j.of(this._iid),t=e.sdkState,n=e.requestQueue,r=new Ht({userId:t.userId}),[4,n.send(r)];case 1:return[2,i.sent().as(xt).name]}}))}))},t.prototype.setPushTemplate=function(e){return o(this,void 0,void 0,(function(){var t,n,r,i;return a(this,(function(o){switch(o.label){case 0:return ee(me(ye,e)).throw(V.invalidParameters),t=j.of(this._iid),n=t.sdkState,r=t.requestQueue,i=new Gt({userId:n.userId,templateName:e}),[4,r.send(i)];case 1:return[2,o.sent().as(Wt).name]}}))}))},t.prototype.blockUser=function(e){return o(this,void 0,void 0,(function(){var t,r,i,o;return a(this,(function(s){switch(s.label){case 0:return ee(e instanceof p||n("string",e)).throw(V.invalidParameters),t=j.of(this._iid),r=t.sdkState,i=t.requestQueue,o=new Rt({userId:r.userId,blockedUserId:e instanceof p?e.userId:e}),[4,i.send(o)];case 1:return s.sent(),[2]}}))}))},t.prototype.blockUserWithUserId=function(e){return o(this,void 0,void 0,(function(){return a(this,(function(t){return[2,this.blockUser(e)]}))}))},t.prototype.unblockUser=function(e){return o(this,void 0,void 0,(function(){var t,r,i,o;return a(this,(function(s){switch(s.label){case 0:return ee(e instanceof p||n("string",e)).throw(V.invalidParameters),t=j.of(this._iid),r=t.sdkState,i=t.requestQueue,o=new zt({userId:r.userId,unblockedUserId:e instanceof p?e.userId:e}),[4,i.send(o)];case 1:return s.sent(),[2]}}))}))},t.prototype.unblockUserWithUserId=function(e){return o(this,void 0,void 0,(function(){return a(this,(function(t){return[2,this.unblockUser(e)]}))}))},t.prototype.getFriendChangeLogsByToken=function(e){return o(this,void 0,void 0,(function(){var t,r,i,o,s;return a(this,(function(a){switch(a.label){case 0:return ee(n("string",e)).throw(V.invalidParameters),t=j.of(this._iid),r=t.sdkState,i=t.requestQueue,o=new Bt({userId:r.userId,token:e}),[4,i.send(o)];case 1:return s=a.sent(),[2,s.as(Kt).changelogs]}}))}))},t.prototype.getAllowFriendDiscovery=function(){return o(this,void 0,void 0,(function(){var e,t,n,r,i;return a(this,(function(o){switch(o.label){case 0:return e=j.of(this._iid),t=e.sdkState,n=e.requestQueue,r=new en({userId:t.userId}),[4,n.send(r)];case 1:return i=o.sent(),[2,i.as(tn).allowFriendDiscovery]}}))}))},t.prototype.setAllowFriendDiscovery=function(e){return o(this,void 0,void 0,(function(){var t,r,i,o;return a(this,(function(s){switch(s.label){case 0:return ee(n("boolean",e)).throw(V.invalidParameters),t=j.of(this._iid),r=t.sdkState,i=t.requestQueue,o=new nn({userId:r.userId,allowFriendDiscovery:e}),[4,i.send(o)];case 1:return s.sent(),[2,e]}}))}))},t.prototype.uploadFriendDiscoveries=function(e){return o(this,void 0,void 0,(function(){var t,n,r,i,o;return a(this,(function(s){switch(s.label){case 0:return t=j.of(this._iid),n=t.sdkState,r=t.requestQueue,i=new Vt({userId:n.userId,discoveries:e}),[4,r.send(i)];case 1:return o=s.sent(),[2,o.as(Jt).friendDiscoveryRequestId]}}))}))},t.prototype.deleteFriendDiscovery=function(e){return o(this,void 0,void 0,(function(){return a(this,(function(t){return[2,this.deleteFriendDiscoveries([e])]}))}))},t.prototype.deleteFriendDiscoveries=function(e){return o(this,void 0,void 0,(function(){var t,n,r,i;return a(this,(function(o){switch(o.label){case 0:return ee(pe("string",e)).throw(V.invalidParameters),t=j.of(this._iid),n=t.sdkState,r=t.requestQueue,i=new Xt({userId:n.userId,discoveryKeys:e}),[4,r.send(i)];case 1:return o.sent(),[2]}}))}))},t.prototype.addFriends=function(e){return o(this,void 0,void 0,(function(){var t,n,r,i,o;return a(this,(function(s){switch(s.label){case 0:return ee(pe("string",e)).throw(V.invalidParameters),t=j.of(this._iid),n=t.sdkState,r=t.requestQueue,i=new Yt({userId:n.userId,userIds:e}),[4,r.send(i)];case 1:return o=s.sent(),[2,o.as(Zt).users]}}))}))},t.prototype.deleteFriend=function(e){return o(this,void 0,void 0,(function(){return a(this,(function(t){return[2,this.deleteFriends([e])]}))}))},t.prototype.deleteFriends=function(e){return o(this,void 0,void 0,(function(){var t,n,r,i;return a(this,(function(o){switch(o.label){case 0:return ee(pe("string",e)).throw(V.invalidParameters),t=j.of(this._iid),n=t.sdkState,r=t.requestQueue,i=new $t({userId:n.userId,userIds:e}),[4,r.send(i)];case 1:return o.sent(),[2]}}))}))},t.prototype.getAllEmoji=function(){return o(this,void 0,void 0,(function(){var e,t,n;return a(this,(function(r){switch(r.label){case 0:return e=j.of(this._iid).requestQueue,t=new on,[4,e.send(t)];case 1:return n=r.sent(),[2,n.as(sn).emojiContainer]}}))}))},t.prototype.getEmojiCategory=function(e){return o(this,void 0,void 0,(function(){var t,n,r;return a(this,(function(i){switch(i.label){case 0:return t=j.of(this._iid).requestQueue,n=new an({categoryId:e}),[4,t.send(n)];case 1:return r=i.sent(),[2,r.as(un).emojiCategory]}}))}))},t.prototype.getEmoji=function(e){return o(this,void 0,void 0,(function(){var t,n,r;return a(this,(function(i){switch(i.label){case 0:return t=j.of(this._iid).requestQueue,n=new cn({key:e}),[4,t.send(n)];case 1:return r=i.sent(),[2,r.as(dn).emoji]}}))}))},t.prototype.getUIKitConfiguration=function(){return o(this,void 0,void 0,(function(){var e,t,n,r;return a(this,(function(i){switch(i.label){case 0:return e=j.of(this._iid),ee(e.hasExtension("sb_uikit")).throw(V.notSupportedError),t=e.requestQueue,n=new ln,[4,t.send(n)];case 1:return r=i.sent(),[2,r.as(hn).uikitConfiguration]}}))}))},t}();export{ot as Emoji,st as EmojiCategory,at as EmojiContainer,fn as default};
+import{i as e,a as t,_ as r,E as i,b as o,c as s,A as a,d as u,e as c,u as d,f as l,U as h,g as f,h as g,P as _,j as m,k as b,l as I,S as k,L as A,m as M,n as Q,V as j,o as H,p as G,v as W,C as K,q as V,r as J,s as ee,t as te,w as ne,x as re,y as ie,z as oe,W as se,B as ae,D as ue,F as ce,G as de,H as le,I as he,J as fe,K as pe,M as ve,N as ge,O as _e,Q as me,R as be,T as ye}from"./lib/__bundle-0f850482.js";export{Z as CachedChannelInfo,Y as ChannelType,X as CollectionEventSource,C as ConnectionState,a6 as DeviceOsPlatform,L as LocalCacheConfig,$ as LogLevel,a0 as NotificationInfo,T as PushTemplate,N as PushTokenRegistrationState,P as PushTokenType,R as PushTriggerOption,a1 as Role,S as SendbirdChatOptions,q as SendbirdError,a5 as SendbirdPlatform,a4 as SendbirdProduct,a2 as UIKitConfigInfo,U as User,a3 as UserOnlineState}from"./lib/__bundle-0f850482.js";import{N as we,a as Ie,b as ke,c as Ce,g as Se,M as Te,d as Ee,e as Pe,f as Ue,h as De,i as Oe,j as Ae,k as Ne,l as Le,m as Me,n as Re,A as ze,I as Qe,o as je,U as Fe,C as qe,p as xe,B as He,F as Ge,q as We,S as Be,r as Ke,s as Ve,t as Je,u as Xe}from"./lib/__bundle-684d6267.js";export{p as ApplicationUserListQuery,v as BannedUserListQuery,w as BaseChannel,B as BlockedUserListQuery,C as ConnectionHandler,F as FriendListQuery,n as MemoryStore,x as MutedUserListQuery,O as OperatorListQuery,P as Participant,y as Plugin,R as ReportCategory,z as RestrictedUser,D as RestrictionInfo,E as RestrictionType,S as SessionHandler,U as UserEventHandler}from"./lib/__bundle-684d6267.js";import{PollModule as Ye}from"./poll.js";import{g as Ze,G as $e,A as et,U as tt,a as nt,b as rt,D as it,R as ot}from"./lib/__bundle-1ab3a4b7.js";import{g as st,N as at}from"./lib/__bundle-ce97f401.js";import"./lib/__bundle-c336221f.js";var ut=function(e){this.key=e.key,this.url=e.url},ct=function(e){this.id=e.id,this.name=e.name,this.url=e.url,this.emojis=e.emojis?e.emojis.map((function(e){return new ut(e)})):[]},dt=function(e){this.emojiHash=e.emoji_hash||"",this.emojiCategories=e.emoji_categories?e.emoji_categories.map((function(e){return new ct(e)})):[]},lt={profileImage:void 0,profileUrl:void 0,nickname:void 0},ht=function(e){return{v2:e.commitSchema([{collectionName:we,keyName:Ie,index:[Ze($e.LATEST_LAST_MESSAGE),Ze($e.CHRONOLOGICAL),Ze($e.CHANNEL_NAME_ALPHABETICAL)]},{collectionName:ke,keyName:Ce,index:[Se(Te.CHANNEL_LATEST),Se(Te.NEWEST_CHILD_MESSAGE)]},{collectionName:Ee,keyName:Pe,index:[Se(Te.CHANNEL_LATEST),Se(Te.NEWEST_CHILD_MESSAGE)]},{collectionName:Ue,keyName:De}]),v3:e.commitSchema([{collectionName:Oe,keyName:Ae,index:[st("latest_last_message")]}]),v4:e.commitSchema([{collectionName:Ne,keyName:Le,index:[Me()]}])}},ft=function(e){return function(t,n){switch(t){case 1:e.clear().then((function(){ht(e).v2.then((function(){return n()})).catch((function(e){return n(e)}))})).catch((function(e){return n(e)}));break;case 2:ht(e).v3.then((function(){return n()})).catch((function(e){return n(e)}));break;case 3:ht(e).v4.then((function(){return n()})).catch((function(e){return n(e)}));break;default:n()}}},pt=function(){return"undefined"!=typeof document?document.visibilityState:"visible"},vt=function(e){function t(t){var n=t.getVisibilityState,r=void 0===n?pt:n,i=t.initialState,o=void 0===i?"visible":i,s=t.isEnabled,a=void 0===s||s,u=t.pauseCheckDelay,c=void 0===u?3e4:u,d=e.call(this)||this;return d._pauseCheckDelay=3e4,d._currentState="visible",d._getVisibilityState=r,d._pauseCheckDelay=c,d._currentState=o,d._isEnabled=a,d._boundToggleState=d._toggleState.bind(d),d}return r(t,e),Object.defineProperty(t.prototype,"currentState",{get:function(){return this._currentState},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"isAvailable",{get:function(){return"undefined"!=typeof window&&!!window.addEventListener&&!!window.removeEventListener},enumerable:!1,configurable:!0}),t.prototype._toggleState=function(){var e=this,t=this._getVisibilityState();"hidden"!==t?"hidden"===this._currentState&&(this._pauseDelayTimer&&(clearTimeout(this._pauseDelayTimer),this._pauseDelayTimer=void 0),this.dispatch("resume")):"hidden"!==this._currentState&&(this._pauseDelayTimer=setTimeout((function(){e._pauseDelayTimer=void 0,e.dispatch("pause")}),this._pauseCheckDelay)),this._currentState=t},t.prototype.start=function(){this._isEnabled&&this.isAvailable&&(this._boundToggleState=this._toggleState.bind(this),window.addEventListener("visibilitychange",this._boundToggleState,{capture:!0}))},t.prototype.stop=function(){this._isEnabled&&this.isAvailable&&this._boundToggleState&&window.removeEventListener("visibilitychange",this._boundToggleState,{capture:!0})},t}(i),gt=function(){function e(e){var t=e.logger,n=e.connectionDelegate,r=void 0===n?null:n,i=this;this._onlineWorker=function(){var e;return null===(e=i.connectionDelegate)||void 0===e?void 0:e.reconnect()},this._offlineWorker=function(){var e;return null===(e=i.connectionDelegate)||void 0===e?void 0:e.disconnect()},this.unsubscribes=[],this._onlineListener=function(e){if(i.isAvailableOnWeb)return window.addEventListener("online",e),function(){return window.removeEventListener("online",e,!1)}},this._offlineListener=function(e){if(i.isAvailableOnWeb)return window.addEventListener("offline",e),function(){return window.removeEventListener("offline",e,!1)}},this.logger=t,r&&(this.connectionDelegate=r)}return Object.defineProperty(e.prototype,"isAvailableOnWeb",{get:function(){return"undefined"!=typeof window&&!!window.addEventListener&&"ononline"in window&&"onoffline"in window&&"undefined"!=typeof navigator&&void 0!==navigator.onLine},enumerable:!1,configurable:!0}),e.prototype.setOnlineListener=function(e){Boolean(e)&&"function"==typeof e&&(this._onlineListener=e)},e.prototype.setOfflineListener=function(e){Boolean(e)&&"function"==typeof e&&(this._offlineListener=e)},e.prototype.start=function(){this.unsubscribes=[this._onlineListener(this._onlineWorker),this._offlineListener(this._offlineWorker)]},e.prototype.stop=function(){var e=this;this.unsubscribes.forEach((function(t){try{null==t||t()}catch(t){e.logger.warn(t.message)}})),this.unsubscribes=[]},e.prototype.isOnline=function(){return o(this,void 0,void 0,(function(){return s(this,(function(e){return this.isAvailableOnWeb?[2,navigator.onLine]:[2,new Promise((function(e){fetch("https://www.google.com",{method:a.GET,mode:"no-cors"}).then((function(){return e(!0)})).catch((function(){return e(!1)}))}))]}))}))},e}(),_t=function(e){function t(t){var n=t.userId,r=t.nickname,i=t.profileUrl,o=t.profileImage,s=t.preferredLanguages,l=e.call(this)||this;return l.method=a.PUT,l.path="".concat(u,"/").concat(encodeURIComponent(n)),l.params=c(d({nickname:r,profile_url:i,profile_file:o,preferred_languages:s})),l}return r(t,e),t}(l),mt=function(e){function t(t,n){var r=e.call(this,t,n)||this;return r.user=new h(t,f({},n)),r}return r(t,e),t}(g),bt=function(e){function t(t){var n=t.userId,r=t.token,i=e.call(this)||this;return i.method=a.POST,i.path="".concat(u,"/").concat(encodeURIComponent(n),"/push/apns"),i.params={apns_device_token:r,always_push:!0},i}return r(t,e),t}(l);!function(e){function t(t,n){var r=e.call(this,t,n)||this;return r.token=n.token,r.type=n.type?_[n.type.toLowerCase()]:_.UNKNOWN,r.user=new h(t,n.user),r}r(t,e)}(g);var yt=function(e){function t(t){var n=t.userId,r=t.token,i=e.call(this)||this;return i.method=a.POST,i.path="".concat(u,"/").concat(encodeURIComponent(n),"/push/gcm"),i.params={gcm_reg_token:r,always_push:!0},i}return r(t,e),t}(l);!function(e){function t(t,n){var r=e.call(this,t,n)||this;return r.token=n.token,r.type=n.type?_[n.type.toLowerCase()]:_.UNKNOWN,r.user=new h(t,n.user),r}r(t,e)}(g);var wt=function(e){function t(t){var n=t.userId,r=t.token,i=e.call(this)||this;return i.method=a.DELETE,i.path="".concat(u,"/").concat(encodeURIComponent(n),"/push/apns/").concat(encodeURIComponent(r)),i}return r(t,e),t}(l);!function(e){function t(t,n){var r=e.call(this,t,n)||this;return r.token=n.token,r.user=new h(t,n.user),r.lastDeletedAt=n.device_token_last_deleted_at,r}r(t,e)}(g);var It=function(e){function t(t){var n=t.userId,r=t.token,i=e.call(this)||this;return i.method=a.DELETE,i.path="".concat(u,"/").concat(encodeURIComponent(n),"/push/gcm/").concat(encodeURIComponent(r)),i}return r(t,e),t}(l);!function(e){function t(t,n){var r=e.call(this,t,n)||this;return r.token=n.token,r.user=new h(t,n.user),r.lastDeletedAt=n.device_token_last_deleted_at,r}r(t,e)}(g);var kt=function(e){function t(t){var n=t.userId,r=e.call(this)||this;return r.method=a.DELETE,r.path="".concat(u,"/").concat(encodeURIComponent(n),"/push/apns"),r}return r(t,e),t}(l);!function(e){function t(t,n){var r=e.call(this,t,n)||this;return r.type=n.type?_[n.type.toLowerCase()]:_.UNKNOWN,r.user=new h(t,n.user),r.lastDeletedAt=n.device_token_last_deleted_at,r}r(t,e)}(g);var Ct=function(e){function t(t){var n=t.userId,r=e.call(this)||this;return r.method=a.DELETE,r.path="".concat(u,"/").concat(encodeURIComponent(n),"/push/gcm"),r}return r(t,e),t}(l);!function(e){function t(t,n){var r=e.call(this,t,n)||this;return r.type=n.type?_[n.type.toLowerCase()]:_.UNKNOWN,r.user=new h(t,n.user),r.lastDeletedAt=n.device_token_last_deleted_at,r}r(t,e)}(g);var St=function(e){function t(t){var n=t.userId,r=t.type,i=t.token,o=t.ts,s=e.call(this)||this;return s.method=a.GET,s.path="".concat(u,"/").concat(encodeURIComponent(n),"/push/").concat(encodeURIComponent(r),"/device_tokens"),s.params={created_ts:o,token:i},s}return r(t,e),t}(l),Tt=function(e){function t(t,n){var r=e.call(this,t,n)||this;return r.pushTokens={type:n.type?_[n.type.toLowerCase()]:_.UNKNOWN,deviceTokens:n.device_tokens,hasMore:n.has_more,token:n.token},r}return r(t,e),t}(g),Et=function(e){function t(t){var n=t.userId,r=e.call(this)||this;return r.method=a.GET,r.path="".concat(u,"/").concat(encodeURIComponent(n),"/channel_invitation_preference"),r}return r(t,e),t}(l),Pt=function(e){function t(t,n){var r=e.call(this,t,n)||this;return r.autoAccept=n.auto_accept,r}return r(t,e),t}(g),Ut=function(e){function t(t){var n=t.userId,r=t.willAutoAccept,i=e.call(this)||this;return i.method=a.PUT,i.path="".concat(u,"/").concat(encodeURIComponent(n),"/channel_invitation_preference"),i.params={auto_accept:r},i}return r(t,e),t}(l),Dt=function(e){function t(t,n){var r=e.call(this,t,n)||this;return r.autoAccept=n.auto_accept,r}return r(t,e),t}(g),Ot=function(e){function t(t){var n=t.userId,r=e.call(this)||this;return r.method=a.GET,r.path="".concat(u,"/").concat(encodeURIComponent(n),"/push_preference"),r}return r(t,e),t}(l),At=function(e){function t(t,n){var r=e.call(this,t,n)||this;return r.preference={doNotDisturbOn:n.do_not_disturb,startHour:n.start_hour,startMin:n.start_min,endHour:n.end_hour,endMin:n.end_min,timezone:n.timezone},r}return r(t,e),t}(g),Nt=function(e){function t(t){var n=t.userId,r=t.doNotDisturbOn,i=t.startHour,o=t.startMin,s=t.endHour,c=t.endMin,d=t.timezone,l=e.call(this)||this;return l.method=a.PUT,l.path="".concat(u,"/").concat(encodeURIComponent(n),"/push_preference"),l.params={do_not_disturb:r,start_hour:i,start_min:o,end_hour:s,end_min:c,timezone:d},l}return r(t,e),t}(l),Lt=function(e){function t(t,n){var r=e.call(this,t,n)||this;return r.preference={doNotDisturbOn:n.do_not_disturb,startHour:n.start_hour,startMin:n.start_min,endHour:n.end_hour,endMin:n.end_min,timezone:n.timezone},r}return r(t,e),t}(g),Mt=function(e){function t(t){var n=t.userId,r=e.call(this)||this;return r.method=a.GET,r.path="".concat(u,"/").concat(encodeURIComponent(n),"/push_preference"),r}return r(t,e),t}(l),Rt=function(e){function t(t,n){var r=e.call(this,t,n)||this;return r.snoozePeriod={isSnoozeOn:n.snooze_enabled},"number"==typeof n.snooze_start_ts&&(r.snoozePeriod.startTs=n.snooze_start_ts),"number"==typeof n.snooze_end_ts&&(r.snoozePeriod.endTs=n.snooze_end_ts),r}return r(t,e),t}(g),zt=function(e){function t(t){var n=t.userId,r=t.snoozeOn,i=t.startTs,o=t.endTs,s=e.call(this)||this;return s.method=a.PUT,s.path="".concat(u,"/").concat(encodeURIComponent(n),"/push_preference"),s.params={snooze_enabled:r,snooze_start_ts:i,snooze_end_ts:o},s}return r(t,e),t}(l),Qt=function(e){function t(t,n){var r=e.call(this,t,n)||this;return r.snoozePeriod={isSnoozeOn:n.snooze_enabled},"number"==typeof n.snooze_start_ts&&(r.snoozePeriod.startTs=n.snooze_start_ts),"number"==typeof n.snooze_end_ts&&(r.snoozePeriod.endTs=n.snooze_end_ts),r}return r(t,e),t}(g),jt=function(e){function t(t){var n=t.userId,r=t.blockedUserId,i=e.call(this)||this;return i.method=a.POST,i.path="".concat(u,"/").concat(encodeURIComponent(n),"/block"),i.params={target_id:r},i}return r(t,e),t}(l);!function(e){function t(t,n){var r=e.call(this,t,n)||this;return r.user=new h(t,n),r}r(t,e)}(g);var Ft=function(e){function t(t){var n=t.userId,r=t.unblockedUserId,i=e.call(this)||this;return i.method=a.DELETE,i.path="".concat(u,"/").concat(encodeURIComponent(n),"/block/").concat(encodeURIComponent(r)),i}return r(t,e),t}(l);!function(e){function t(){return null!==e&&e.apply(this,arguments)||this}r(t,e)}(g);var qt=function(e){function t(t){var n=t.userId,r=e.call(this)||this;return r.method=a.GET,r.path="".concat(u,"/").concat(encodeURIComponent(n),"/push_preference"),r}return r(t,e),t}(l),xt=function(e){function t(t,n){var r=e.call(this,t,n)||this;return r.pushTriggerOption=n.push_trigger_option,r}return r(t,e),t}(g),Ht=function(e){function t(t){var n=t.userId,r=t.pushTriggerOption,i=e.call(this)||this;return i.method=a.PUT,i.path="".concat(u,"/").concat(encodeURIComponent(n),"/push_preference"),i.params={push_trigger_option:r},i}return r(t,e),t}(l),Gt=function(e){function t(t,n){var r=e.call(this,t,n)||this;return r.pushTriggerOption=n.push_trigger_option,r}return r(t,e),t}(g),Wt=function(e){function t(t){var n=t.userId,r=e.call(this)||this;return r.method=a.GET,r.path="".concat(u,"/").concat(encodeURIComponent(n),"/push/template"),r}return r(t,e),t}(l),Bt=function(e){function t(t,n){var r=e.call(this,t,n)||this;return r.name=n.name,r}return r(t,e),t}(g),Kt=function(e){function t(t){var n=t.userId,r=t.templateName,i=e.call(this)||this;return i.method=a.PUT,i.path="".concat(u,"/").concat(encodeURIComponent(n),"/push/template"),i.params={name:r},i}return r(t,e),t}(l),Vt=function(e){function t(t,n){var r=e.call(this,t,n)||this;return r.name=n.name,r}return r(t,e),t}(g),Jt=function(e){function t(t){var n=t.userId,r=t.token,i=e.call(this)||this;return i.method=a.GET,i.path="".concat(u,"/").concat(encodeURIComponent(n),"/friends/changelogs"),i.params={token:r},i}return r(t,e),t}(l),Xt=function(e){function t(t,n){var r=e.call(this,t,n)||this;return r.changelogs={addedUsers:n.added.map((function(e){return new h(t,e)})),updatedUsers:n.updated.map((function(e){return new h(t,e)})),deletedUserIds:n.deleted,hasMore:n.has_more,token:n.next},r}return r(t,e),t}(g),Yt=function(e){function t(t){var n=t.userId,r=t.discoveries,i=e.call(this)||this;return i.method=a.PUT,i.path="".concat(u,"/").concat(encodeURIComponent(n),"/friend_discoveries"),i.params={friend_discoveries:r.map((function(e){return{friend_discovery_key:e.friendDiscoveryKey,friend_name:e.friendName}}))},i}return r(t,e),t}(l),Zt=function(e){function t(t,n){var r=e.call(this,t,n)||this;return r.friendDiscoveryRequestId=n.friend_discovery_request_id,r}return r(t,e),t}(g),$t=function(e){function t(t){var n=t.userId,r=t.discoveryKeys,i=e.call(this)||this;return i.method=a.DELETE,i.path="".concat(u,"/").concat(encodeURIComponent(n),"/friend_discoveries"),i.params={friend_discovery_keys:r},i}return r(t,e),t}(l);!function(e){function t(){return null!==e&&e.apply(this,arguments)||this}r(t,e)}(g);var en=function(e){function t(t){var n=t.userId,r=t.userIds,i=e.call(this)||this;return i.method=a.POST,i.path="".concat(u,"/").concat(encodeURIComponent(n),"/friends"),i.params={user_ids:r},i}return r(t,e),t}(l),tn=function(e){function t(t,n){var r=e.call(this,t,n)||this;return r.users=n.users.map((function(e){return new h(t,e)})),r}return r(t,e),t}(g),nn=function(e){function t(t){var n=t.userId,r=t.userIds,i=e.call(this)||this;return i.method=a.DELETE,i.path="".concat(u,"/").concat(encodeURIComponent(n),"/friends"),i.params={user_ids:r},i}return r(t,e),t}(l);!function(e){function t(){return null!==e&&e.apply(this,arguments)||this}r(t,e)}(g);var rn=function(e){function t(t){var n=t.userId,r=e.call(this)||this;return r.method=a.GET,r.path="".concat(u,"/").concat(n,"/allow_friend_discovery"),r.params={},r}return r(t,e),t}(l),on=function(e){function t(t,n){var r=e.call(this,t,n)||this;return r.allowFriendDiscovery=n.allow_friend_discovery,r}return r(t,e),t}(g),sn=function(e){function t(t){var n=t.userId,r=t.allowFriendDiscovery,i=e.call(this)||this;return i.method=a.PUT,i.path="".concat(u,"/").concat(n,"/allow_friend_discovery"),i.params={allow_friend_discovery:r},i}return r(t,e),t}(l);!function(e){function t(){return null!==e&&e.apply(this,arguments)||this}r(t,e)}(g);var an,un=function(e){function t(){var t=e.call(this)||this;return t.method=a.GET,t.path=m,t}return r(t,e),t}(l),cn=function(e){function t(t,n){var r=e.call(this,t,n)||this;return r.emojiContainer=new dt(n),r}return r(t,e),t}(g),dn=function(e){function t(t){var n=t.categoryId,r=e.call(this)||this;return r.method=a.GET,r.path="".concat(m,"/").concat(n),r}return r(t,e),t}(l),ln=function(e){function t(t,n){var r=e.call(this,t,n)||this;return r.emojiCategory=new ct(n),r}return r(t,e),t}(g),hn=function(e){function t(t){var n=t.key,r=e.call(this)||this;return r.method=a.GET,r.path="".concat(b,"/").concat(n),r}return r(t,e),t}(l),fn=function(e){function t(t,n){var r=e.call(this,t,n)||this;return r.emoji=new ut(n),r}return r(t,e),t}(g),pn=function(e){function t(){var t=e.call(this)||this;return t.method=a.GET,t.path="".concat(I),t}return r(t,e),t}(l),vn=function(e){function t(t,n){var r,i=this,o=null!=n?n:{};return(i=e.call(this,t,n)||this).uikitConfiguration={string:JSON.stringify(o),json:o},i.updatedAt=null!==(r=null==n?void 0:n.updated_at)&&void 0!==r?r:0,i}return r(t,e),t}(g),gn=function(){function n(e,t,n){var r=this;this._storeInitialized=!1,this._iid=e,this.options=t;var i=j.of(e),a=i.sdkState,u=i.cacheContext,c=i.dispatcher,d=i.sessionManager,l=i.requestQueue,h=i.logger,f=i.userEventHandlers,p=i.appStateToggleEnabled;this._onlineDetector=new gt({logger:h,connectionDelegate:{reconnect:function(){var t=j.of(e),n=t.sdkState,r=t.connectionManager,i=t.sessionManager;i.session.hasSession?"foreground"===n.appState&&r.resetAndReconnect():r.connect(i.session.authToken),c.dispatch(new at)},disconnect:function(){j.of(e).connectionManager.disconnect()}}});var v=new et(e,{localCacheEnabled:u.localCacheEnabled,enableAutoResend:u.localCacheConfig.enableAutoResend,dispatcher:c,sdkState:a,logger:h});n.forEach((function(t){t.init(e,{sdkState:a,cacheContext:u,dispatcher:c,sessionManager:d,requestQueue:l,logger:h,onlineDetector:r._onlineDetector}),r[t.name]=t})),this._appStateChangeDetector=new vt({isEnabled:p}),this._appStateChangeDetector.on("resume",(function(){h.debug("the page resumes from freeze"),r.setForegroundState()})).on("pause",(function(){h.debug("the page freezes"),r.setBackgroundState()})),c.on((function(t){var n;if(t instanceof ie){if(t.stateType===oe.CONNECTED)v.processNonAutoResendRegisteredPendingMessages()}else if(t instanceof se){if("USEV"===t.code){var i=t.as(tt).event;if(i.category===nt.FRIEND_DISCOVERED){var c=rt.getDataAsFriendDiscoveredEvent(e,i).friendDiscoveries;ae((function(){return o(r,void 0,void 0,(function(){return s(this,(function(e){return[2,f.forEach((function(e){e.onFriendsDiscovered&&e.onFriendsDiscovered(c)}))]}))}))}))}}}else if(t instanceof ue){var d=j.of(r._iid).subscribedUnreadMessageCount,l=!1,p=t.ts;if("number"==typeof p&&p>d.ts){if(d.all!==t.all&&(l=!0),d.all=t.all>=0?t.all:0,t.customTypes)for(var g in t.customTypes)d.customTypes[g]!==t.customTypes[g]&&(l=!0),d.customTypes[g]=t.customTypes[g];l=l&&d.ts>0,d.ts=p}l&&ae((function(){return o(r,void 0,void 0,(function(){return s(this,(function(e){return[2,f.forEach((function(e){e.onTotalUnreadMessageCountChanged&&e.onTotalUnreadMessageCountChanged({groupChannelCount:d.all,feedChannelCount:d.feed,customTypeUnreadCount:d.customTypes}),e.onTotalUnreadMessageCountUpdated&&e.onTotalUnreadMessageCountUpdated(d.all,d.customTypes)}))]}))}))}))}else t instanceof ce?(u.preference.set(r._getUserProfileCacheKey(a.userId),de.payloadify(t.userProfile)),(null===(n=t.userProfile.appInfo.notificationInfo)||void 0===n?void 0:n.isEnabled)&&u.preference.set(le(r.appId),{value:!0})):t instanceof he&&t.error&&t.error.isSessionInvalidatedError&&(h.debug("session revoked."),r.disconnect())}))}return n.init=function(e){var t=e.appId,r=e.appVersion,i=e.modules,o=void 0===i?[]:i,s=e.options,a=void 0===s?new k:s,u=e.debugMode,c=void 0!==u&&u,d=e.customApiHost,l=e.customWebSocketHost,h=e.newInstance,f=void 0!==h&&h,p=e.logLevel,v=e.localCacheEnabled,g=void 0!==v&&v,_=e.localCacheConfig,m=void 0===_?new A:_,b=e.localCacheEncryption,y=e.useAsyncStorageStore,w=void 0===y?null:y,I=e.appStateToggleEnabled,C=void 0===I||I;if(!an||f){var S="su-".concat(M()),T=null!=b?b:{encrypt:function(e){return e},decrypt:function(e){return e}},E=new Re({encryption:T});c||(E=Q()?w?new ze({AsyncStorage:w,encryption:T}):new Re({encryption:T}):new Qe({encryption:T})),new j(S,{appId:t,appVersion:r,options:a,apiHost:null!=d?d:"https://api-".concat(t,".sendbird.com"),websocketHost:null!=l?l:"wss://ws-".concat(t,".sendbird.com"),store:E,encryption:T,logLevel:p,localCacheEnabled:g,localCacheConfig:m,debugMode:c,appStateToggleEnabled:C});var P=[new je,new Ye],U=new n(S,a,H(H([],G(o),!1),G(P),!1));return an||(an=U),U}return an},Object.defineProperty(n,"instance",{get:function(){return an},enumerable:!1,configurable:!0}),Object.defineProperty(n,"version",{get:function(){return W},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"appId",{get:function(){return j.of(this._iid).sdkState.appId},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"appInfo",{get:function(){var e=j.of(this._iid).appInfo;return null!=e?e:null},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"appVersion",{get:function(){var e;return null!==(e=j.of(this._iid).sdkState.appVersion)&&void 0!==e?e:""},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"debugMode",{get:function(){return!!j.of(this._iid).debugMode},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"logLevel",{get:function(){return j.of(this._iid).logger.level},set:function(e){j.of(this._iid).logger.level=e},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"isCacheEnabled",{get:function(){return j.of(this._iid).cacheContext.localCacheEnabled},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"localCacheConfig",{get:function(){var e=j.of(this._iid).cacheContext;return e.localCacheEnabled?e.localCacheConfig:null},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"ekey",{get:function(){return j.of(this._iid).sessionManager.ekey},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"currentUser",{get:function(){var e;return null!==(e=j.of(this._iid).sessionManager.currentUser)&&void 0!==e?e:null},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"connectionState",{get:function(){var e=j.of(this._iid).connectionManager;return e.isConnected?K.OPEN:e.isConnecting?K.CONNECTING:K.CLOSED},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"lastConnectedAt",{get:function(){var e=j.of(this._iid),t=e.connectedAt;return e.connectionManager.isConnected?t:0},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"fcmPushToken",{get:function(){var e;return null!==(e=this._fcmPushToken)&&void 0!==e?e:null},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"apnsPushToken",{get:function(){var e;return null!==(e=this._apnsPushToken)&&void 0!==e?e:null},enumerable:!1,configurable:!0}),n.prototype._getNestDBVersion=function(){return 4},n.prototype._getPreferenceCacheKey=function(e){return"sendbird@".concat(this.appId,"/").concat(e,".pref")},n.prototype._getUserProfileCacheKey=function(e){return"sendbird@".concat(this.appId,"/").concat(e,".profile")},n.prototype.getMemoryStoreForDebugging=function(){var e=j.of(this._iid),t=e.debugMode,n=e.cacheContext;if(t)return n.store instanceof Re?n.store:null;throw V.debugModeRequired},n.prototype.addExtension=function(e,t){var n=j.of(this._iid).sdkState;["sb_uikit","sb_syncmanager","device-os-platform"].indexOf(e)>-1&&n.extensions&&(n.extensions[e]=t)},n.prototype.addSendbirdExtensions=function(e,t,n){var r,i,o=j.of(this._iid),s=o.logger,a=o.sdkState,u=new RegExp(fe);if(0===e.length)return s.debug("sb.addSendbirdExtensions() has failed because the given sendbirdExtensions is empty."),!1;if(e.find((function(e){return!u.test(e.version)})))return s.debug("sb.addSendbirdExtensions() has failed because the given version did not satisfy the SemVer specification."),!1;if(n)try{for(var c=J(Object.entries(n)),d=c.next();!d.done;d=c.next()){var l=G(d.value,2),h=l[0],f=l[1];if(/&|=/.test(h)||/&|=/.test(f))return s.debug("sb.addSendbirdExtensions() has failed because the given customData includes at least one invalid character: = or &."),!1}}catch(e){r={error:e}}finally{try{d&&!d.done&&(i=c.return)&&i.call(c)}finally{if(r)throw r.error}}return a.sendbirdRuntimeEnvironment={sendbirdExtensions:e,deviceOS:t,customData:n},!0},n.prototype.setOnlineListener=function(e){this._onlineDetector.setOnlineListener(e)},n.prototype.setOfflineListener=function(e){this._onlineDetector.setOfflineListener(e)},n.prototype._safeInitializeStore=function(e){return o(this,void 0,void 0,(function(){var t;return s(this,(function(n){switch(n.label){case 0:t=j.of(this._iid).cacheContext,n.label=1;case 1:return n.trys.push([1,3,,5]),[4,t.store.init(e)];case 2:return n.sent(),this._storeInitialized=!0,[3,5];case 3:return n.sent(),t.replaceStore(new Re),[4,this._safeInitializeStore(e)];case 4:return n.sent(),[3,5];case 5:return[2]}}))}))},n.prototype.initializeCache=function(e){return o(this,void 0,void 0,(function(){var t,n,r,i,o,a,u,c;return s(this,(function(s){switch(s.label){case 0:if(t=j.of(this._iid),n=t.sdkState,r=t.cacheContext,i=t.dispatcher,o=t.logger,n.userId&&n.userId===e)return[3,11];if(a="sendbird@".concat(n.appId,"/").concat(e,".db"),!r.localCacheEnabled)return[3,7];s.label=1;case 1:return s.trys.push([1,4,,6]),r.nestdb&&r.nestdb.state!==Xe.CLOSED&&r.nestdb.name===a?[3,3]:((u=r.nestdb=new Ke({name:"sendbird@".concat(n.appId,"/").concat(e,".db"),version:this._getNestDBVersion(),store:r.store})).on("upgrade",ft(u)),u.on("storeReplaced",(function(e){r.replaceStore(e),r.localCacheEnabled=!1,u.on("upgrade",ft(u))})),[4,u.open()]);case 2:s.sent(),this._storeInitialized=!0,i.dispatch(new it(this._iid,{userId:e})),s.label=3;case 3:return n.userId=e,[3,6];case 4:return c=s.sent(),o.warn("Nest DB Open Failed. ",c),[4,this._safeInitializeStore(a)];case 5:throw s.sent(),n.userId=e,V.databaseError;case 6:return[3,9];case 7:return[4,this._safeInitializeStore(a)];case 8:s.sent(),n.userId=e,s.label=9;case 9:return[4,this._setupPreference(e)];case 10:s.sent(),s.label=11;case 11:return[2]}}))}))},n.prototype.getCacheDataSize=function(){return o(this,void 0,void 0,(function(){var e;return s(this,(function(t){switch(t.label){case 0:return(e=j.of(this._iid).cacheContext).localCacheEnabled&&e.nestdb?[4,e.nestdb.estimateUsage()]:[3,2];case 1:return[2,t.sent()];case 2:return[2,0]}}))}))},n.prototype.clearCachedData=function(){return o(this,void 0,void 0,(function(){var e;return s(this,(function(t){switch(t.label){case 0:return(e=j.of(this._iid).cacheContext).localCacheEnabled&&e.nestdb?[4,e.nestdb.clear()]:[3,2];case 1:t.sent(),t.label=2;case 2:return this._storeInitialized?[4,e.preference.clear()]:[3,4];case 3:t.sent(),t.label=4;case 4:return[2]}}))}))},n.prototype.clearCachedMessages=function(e){return o(this,void 0,void 0,(function(){var t,n,r=this;return s(this,(function(i){switch(i.label){case 0:return ee(pe("string",e)).throw(V.invalidParameters),t=Ve.of(this._iid),n=Je.of(this._iid),t&&n?[4,Promise.all(e.map((function(e){return o(r,void 0,void 0,(function(){return s(this,(function(r){switch(r.label){case 0:return[4,t.removeMessagesOfChannel(e)];case 1:return r.sent(),[4,n.removeMessagesOfChannel(e)];case 2:return r.sent(),[2]}}))}))})))]:[3,2];case 1:i.sent(),i.label=2;case 2:return[2]}}))}))},n.prototype._setupPreference=function(e){return o(this,void 0,void 0,(function(){var t,n,r,i,o;return s(this,(function(s){switch(s.label){case 0:return t=j.of(this._iid),n=t.sdkState,r=t.cacheContext,i=t.statLogCollector,[4,r.preference.init(this._getPreferenceCacheKey(e),this._getNestDBVersion())];case 1:return s.sent(),[4,r.preference.get(this._getUserProfileCacheKey(e))];case 2:return(o=s.sent())&&new de(this._iid,o).apply(),[4,i.init("sendbird@".concat(n.appId,"/").concat(e,".statlog"))];case 3:return s.sent(),[2]}}))}))},n.prototype._ready=function(e,n,r){return void 0===r&&(r={}),o(this,void 0,void 0,(function(){var i,o,a,u,c,d;return s(this,(function(s){switch(s.label){case 0:return ee(t("string",e)&&t("string",n,!0)).throw(V.invalidParameters),i=j.of(this._iid),o=i.sdkState,a=i.cacheContext,u=i.connectionManager,i.statLogCollector,c=r.errorForOtherUser,o.userId&&o.userId!==e?c?[3,2]:[4,u.logout()]:[3,3];case 1:return s.sent(),[3,3];case 2:throw c;case 3:return s.trys.push([3,5,,7]),[4,this.initializeCache(e)];case 4:return s.sent(),j.of(this._iid).dispatcher.dispatch(new ot),[3,7];case 5:return s.sent(),d=j.of(this._iid).logger,a.localCacheEnabled=!1,d.warn("Cache initialization failed - cache is not available."),[4,this._setupPreference(e)];case 6:return s.sent(),[3,7];case 7:return[2]}}))}))},n.prototype.authenticateFeed=function(e,t){return o(this,void 0,void 0,(function(){var n,r,i;return s(this,(function(o){switch(o.label){case 0:return n=j.of(this._iid),r=n.sessionManager,i=n.connectionManager,[4,this._ready(e,t,{errorForOtherUser:i.isConnected?V.alreadyConnectedAsAnotherUser:void 0})];case 1:return o.sent(),r.session.hasLessServiceScopeThan([ve.FEED])?[4,r.authenticateFeed(e,t)]:[3,3];case 2:o.sent(),o.label=3;case 3:return[2,this.currentUser]}}))}))},n.prototype.connect=function(e,t){return o(this,void 0,void 0,(function(){return s(this,(function(n){switch(n.label){case 0:return[4,this._ready(e,t)];case 1:n.sent(),n.label=2;case 2:return n.trys.push([2,,4,5]),[4,j.of(this._iid).connectionManager.connect(t)];case 3:return n.sent(),[3,5];case 4:return this._onlineDetector.start(),this._appStateChangeDetector.start(),[7];case 5:return[2,this.currentUser]}}))}))},n.prototype.reconnect=function(){var e=j.of(this._iid),t=e.connectionManager,n=e.sdkState,r=e.sessionManager.session.hasSession;return r&&(this._appStateChangeDetector.start(),this._onlineDetector.start(),t.resetAndReconnect().then((function(){n.appState="foreground"})).catch((function(){}))),r},n.prototype.disconnect=function(){return o(this,void 0,void 0,(function(){var e,t,n;return s(this,(function(r){switch(r.label){case 0:return e=j.of(this._iid),t=e.connectionManager,n=e.requestQueue,e.sessionManager,this._appStateChangeDetector.stop(),this._onlineDetector.stop(),n.cancelAll(),[4,t.logout()];case 1:return r.sent(),[4,this.clearCachedData()];case 2:return r.sent(),[2]}}))}))},n.prototype.disconnectWebSocket=function(){return o(this,void 0,void 0,(function(){var e,t,n;return s(this,(function(r){switch(r.label){case 0:return e=j.of(this._iid),t=e.connectionManager,n=e.requestQueue,this._appStateChangeDetector.stop(),this._onlineDetector.stop(),n.cancelAll(),[4,t.disconnectWebSocket()];case 1:return r.sent(),[2]}}))}))},n.prototype.setBackgroundState=function(){var e=j.of(this._iid),t=e.connectionManager,n=e.sdkState,r=e.logger;"foreground"===n.appState&&(n.appState="background",r.debug("going background state"),t.background())},n.prototype.setForegroundState=function(){var e=j.of(this._iid),t=e.connectionManager,n=e.sdkState,r=e.dispatcher,i=e.logger;"background"===n.appState&&(n.appState="foreground",i.debug("going foreground state"),t.resetAndReconnect(),r.dispatch(new at))},n.prototype.setSessionHandler=function(e){ee(e instanceof Be).throw(V.invalidParameters),j.of(this._iid).sessionManager.handler=e},n.prototype.addUserEventHandler=function(e,n){ee(t("string",e)&&n instanceof Fe).throw(V.invalidParameters),j.of(this._iid).userEventHandlers.set(e,n)},n.prototype.removeUserEventHandler=function(e){j.of(this._iid).userEventHandlers.delete(e)},n.prototype.removeAllUserEventHandler=function(){j.of(this._iid).userEventHandlers.clear()},n.prototype.addConnectionHandler=function(e,n){ee(t("string",e)&&n instanceof qe).throw(V.invalidParameters),j.of(this._iid).connectionHandlers.set(e,n)},n.prototype.removeConnectionHandler=function(e){j.of(this._iid).connectionHandlers.delete(e)},n.prototype.removeAllConnectionHandler=function(){j.of(this._iid).connectionHandlers.clear()},n.prototype.createApplicationUserListQuery=function(e){return void 0===e&&(e={}),new xe(this._iid,e)},n.prototype.createBlockedUserListQuery=function(e){return void 0===e&&(e={}),new He(this._iid,e)},n.prototype.createFriendListQuery=function(e){return void 0===e&&(e={}),new Ge(this._iid,e)},n.prototype.createMessageSearchQuery=function(e){return new We(this._iid,e)},n.prototype.createPollListQuery=function(e){return new te(this._iid,f({},e))},n.prototype.createPollVoterListQuery=function(e){return new ne(this._iid,f({},e))},n.prototype.buildUserFromSerializedData=function(e){var t=re(e);return new h(this._iid,h.payloadify(t))},n.prototype.updateCurrentUserInfo=function(n){return void 0===n&&(n={}),o(this,void 0,void 0,(function(){var r,i,o,a,u,c,d;return s(this,(function(s){switch(s.label){case 0:return r=f(f({},lt),n),ee(function(n){return e(n.profileImage,!0)&&t("string",n.profileUrl,!0)&&t("string",n.nickname,!0)}(r)).throw(V.invalidParameters),this.currentUser?(i=j.of(this._iid),o=i.sdkState,a=i.requestQueue,u=new _t(f({userId:o.userId},r)),[4,a.send(u)]):[3,2];case 1:return c=s.sent(),d=c.as(mt).user,this.currentUser&&(r.nickname&&(this.currentUser.nickname=d.nickname),(r.profileUrl||r.profileImage)&&(this.currentUser.plainProfileUrl=d.profileUrl)),[2,d];case 2:throw V.connectionRequired}}))}))},n.prototype.updateCurrentUserInfoWithPreferredLanguages=function(e){return o(this,void 0,void 0,(function(){var t,n,r,i,o,a;return s(this,(function(s){switch(s.label){case 0:return ee(pe("string",e)).throw(V.invalidParameters),this.currentUser?(t=j.of(this._iid),n=t.sdkState,r=t.requestQueue,i=new _t({userId:n.userId,preferredLanguages:e}),[4,r.send(i)]):[3,2];case 1:return o=s.sent(),a=o.as(mt).user,this.currentUser&&(this.currentUser.preferredLanguages=a.preferredLanguages),[2,a];case 2:throw V.connectionRequired}}))}))},n.prototype.registerFCMPushTokenForCurrentUser=function(e){return o(this,void 0,void 0,(function(){var n,r,i,a,u,c=this;return s(this,(function(d){switch(d.label){case 0:if(ee(t("string",e)).throw(V.invalidParameters),!this.currentUser)return[3,6];d.label=1;case 1:return d.trys.push([1,4,,5]),n=j.of(this._iid),r=n.sessionManager,i=n.sdkState,a=n.requestQueue,r.hasDeviceToken(_.FCM,e)?[2,ge.SUCCESS]:(u=new yt({userId:i.userId,token:e}),[4,a.send(u)]);case 2:return d.sent(),[4,_e((function(){return o(c,void 0,void 0,(function(){return s(this,(function(t){switch(t.label){case 0:return r.setDeviceToken(_.FCM,e),[4,r.saveDeviceToken()];case 1:return t.sent(),[2]}}))}))}))];case 3:return d.sent(),this._fcmPushToken="",[2,ge.SUCCESS];case 4:return d.sent(),[2,ge.ERROR];case 5:return[3,7];case 6:return this._fcmPushToken=e,[2,ge.PENDING];case 7:return[2]}}))}))},n.prototype.unregisterFCMPushTokenForCurrentUser=function(e){return o(this,void 0,void 0,(function(){var n,r,i,a,u,c,d=this;return s(this,(function(l){switch(l.label){case 0:if(ee(t("string",e)).throw(V.invalidParameters),!this.currentUser)return[3,6];l.label=1;case 1:return l.trys.push([1,4,,5]),n=j.of(this._iid),r=n.sessionManager,i=n.sdkState,a=n.requestQueue,u=new It({userId:i.userId,token:e}),[4,a.send(u)];case 2:return c=l.sent().lastDeletedAt,[4,_e((function(){return o(d,void 0,void 0,(function(){return s(this,(function(t){switch(t.label){case 0:return r.unsetDeviceToken(_.FCM,e),r.setDeviceTokenDeletedAt(c),[4,r.saveDeviceToken()];case 1:return t.sent(),[2]}}))}))}))];case 3:return l.sent(),this._fcmPushToken="",[2,ge.SUCCESS];case 4:return l.sent(),[2,ge.ERROR];case 5:return[3,7];case 6:return this._fcmPushToken=e,[2,ge.PENDING];case 7:return[2]}}))}))},n.prototype.unregisterFCMPushTokenAllForCurrentUser=function(){return o(this,void 0,void 0,(function(){var e,t,n,r,i,a,u=this;return s(this,(function(c){switch(c.label){case 0:return this.currentUser?(e=j.of(this._iid),t=e.sessionManager,n=e.sdkState,r=e.requestQueue,i=new Ct({userId:n.userId}),[4,r.send(i)]):[3,3];case 1:return a=c.sent().lastDeletedAt,[4,_e((function(){return o(u,void 0,void 0,(function(){return s(this,(function(e){switch(e.label){case 0:return t.unsetDeviceTokens(_.FCM),t.setDeviceTokenDeletedAt(a),[4,t.saveDeviceToken()];case 1:return e.sent(),[2]}}))}))}))];case 2:c.sent(),c.label=3;case 3:return[2]}}))}))},n.prototype.registerAPNSPushTokenForCurrentUser=function(e){return o(this,void 0,void 0,(function(){var n,r,i,a,u,c=this;return s(this,(function(d){switch(d.label){case 0:if(ee(t("string",e)).throw(V.invalidParameters),!this.currentUser)return[3,6];d.label=1;case 1:return d.trys.push([1,4,,5]),n=j.of(this._iid),r=n.sessionManager,i=n.sdkState,a=n.requestQueue,r.hasDeviceToken(_.APNS,e)?[2,ge.SUCCESS]:(u=new bt({userId:i.userId,token:e}),[4,a.send(u)]);case 2:return d.sent(),[4,_e((function(){return o(c,void 0,void 0,(function(){return s(this,(function(t){switch(t.label){case 0:return r.setDeviceToken(_.APNS,e),[4,r.saveDeviceToken()];case 1:return t.sent(),[2]}}))}))}))];case 3:return d.sent(),this._apnsPushToken="",[2,ge.SUCCESS];case 4:return d.sent(),[2,ge.ERROR];case 5:return[3,7];case 6:return this._apnsPushToken=e,[2,ge.PENDING];case 7:return[2]}}))}))},n.prototype.unregisterAPNSPushTokenForCurrentUser=function(e){return o(this,void 0,void 0,(function(){var n,r,i,a,u,c,d=this;return s(this,(function(l){switch(l.label){case 0:if(ee(t("string",e)).throw(V.invalidParameters),!this.currentUser)return[3,6];l.label=1;case 1:return l.trys.push([1,4,,5]),n=j.of(this._iid),r=n.sessionManager,i=n.sdkState,a=n.requestQueue,u=new wt({userId:i.userId,token:e}),[4,a.send(u)];case 2:return c=l.sent().lastDeletedAt,[4,_e((function(){return o(d,void 0,void 0,(function(){return s(this,(function(t){switch(t.label){case 0:return r.unsetDeviceToken(_.APNS,e),r.setDeviceTokenDeletedAt(c),[4,r.saveDeviceToken()];case 1:return t.sent(),[2]}}))}))}))];case 3:return l.sent(),this._apnsPushToken="",[2,ge.SUCCESS];case 4:return l.sent(),[2,ge.ERROR];case 5:return[3,7];case 6:return this._apnsPushToken=e,[2,ge.PENDING];case 7:return[2]}}))}))},n.prototype.unregisterAPNSPushTokenAllForCurrentUser=function(){return o(this,void 0,void 0,(function(){var e,t,n,r,i,a,u=this;return s(this,(function(c){switch(c.label){case 0:return this.currentUser?(e=j.of(this._iid),t=e.sessionManager,n=e.sdkState,r=e.requestQueue,i=new kt({userId:n.userId}),[4,r.send(i)]):[3,3];case 1:return a=c.sent().lastDeletedAt,[4,_e((function(){return o(u,void 0,void 0,(function(){return s(this,(function(e){switch(e.label){case 0:return t.unsetDeviceTokens(_.APNS),t.setDeviceTokenDeletedAt(a),[4,t.saveDeviceToken()];case 1:return e.sent(),[2]}}))}))}))];case 2:c.sent(),c.label=3;case 3:return[2]}}))}))},n.prototype.getChannelInvitationPreference=function(){return o(this,void 0,void 0,(function(){var e,t,n,r,i;return s(this,(function(o){switch(o.label){case 0:return e=j.of(this._iid),t=e.sdkState,n=e.requestQueue,r=new Et({userId:t.userId}),[4,n.send(r)];case 1:return i=o.sent(),[2,{autoAccept:i.as(Pt).autoAccept}]}}))}))},n.prototype.setChannelInvitationPreference=function(e){return o(this,void 0,void 0,(function(){var n,r,i,o,a;return s(this,(function(s){switch(s.label){case 0:return ee(t("boolean",e)).throw(V.invalidParameters),n=j.of(this._iid),r=n.sdkState,i=n.requestQueue,o=new Ut({userId:r.userId,willAutoAccept:e}),[4,i.send(o)];case 1:return a=s.sent(),[2,{autoAccept:a.as(Dt).autoAccept}]}}))}))},n.prototype.getDoNotDisturb=function(){return o(this,void 0,void 0,(function(){var e,t,n,r,i;return s(this,(function(o){switch(o.label){case 0:return e=j.of(this._iid),t=e.sdkState,n=e.requestQueue,r=new Ot({userId:t.userId}),[4,n.send(r)];case 1:return i=o.sent(),[2,i.as(At).preference]}}))}))},n.prototype.setDoNotDisturb=function(e,n,r,i,a,u){return void 0===n&&(n=0),void 0===r&&(r=0),void 0===i&&(i=0),void 0===a&&(a=0),void 0===u&&(u=""),o(this,void 0,void 0,(function(){var o,c,d,l,h;return s(this,(function(s){switch(s.label){case 0:return ee(t("boolean",e)&&t("number",n)&&t("number",r)&&t("number",i)&&t("number",a)&&t("string",u)).throw(V.invalidParameters),o=j.of(this._iid),c=o.sdkState,d=o.requestQueue,l=new Nt({userId:c.userId,doNotDisturbOn:e,startHour:n,startMin:r,endHour:i,endMin:a,timezone:u}),[4,d.send(l)];case 1:return h=s.sent(),[2,h.as(Lt).preference]}}))}))},n.prototype.getSnoozePeriod=function(){return o(this,void 0,void 0,(function(){var e,t,n,r,i;return s(this,(function(o){switch(o.label){case 0:return e=j.of(this._iid),t=e.sdkState,n=e.requestQueue,r=new Mt({userId:t.userId}),[4,n.send(r)];case 1:return i=o.sent(),[2,i.as(Rt).snoozePeriod]}}))}))},n.prototype.setSnoozePeriod=function(e,n,r){return void 0===n&&(n=0),void 0===r&&(r=0),o(this,void 0,void 0,(function(){var i,o,a,u,c;return s(this,(function(s){switch(s.label){case 0:return ee(t("boolean",e)&&t("number",n)&&t("number",r)).throw(V.invalidParameters),i=j.of(this._iid),o=i.sdkState,a=i.requestQueue,u=new zt({userId:o.userId,snoozeOn:e,startTs:n,endTs:r}),[4,a.send(u)];case 1:return c=s.sent(),[2,c.as(Qt).snoozePeriod]}}))}))},n.prototype.getMyPushTokensByToken=function(e,n){return o(this,void 0,void 0,(function(){var r,i,o,a,u,c,d,l,h,f,p,v;return s(this,(function(s){switch(s.label){case 0:return ee(t("string",e)&&me(_,n)).throw(V.invalidParameters),r=j.of(this._iid),i=r.sdkState,o=r.requestQueue,a=r.sessionManager,u=new St({userId:i.userId,type:n,token:e}),[4,o.send(u)];case 1:c=s.sent(),d=c.as(Tt).pushTokens;try{for(l=J(d.deviceTokens),h=l.next();!h.done;h=l.next())f=h.value,a.setDeviceToken(d.type,f)}catch(e){p={error:e}}finally{try{h&&!h.done&&(v=l.return)&&v.call(l)}finally{if(p)throw p.error}}return[4,a.saveDeviceToken()];case 2:return s.sent(),[2,d]}}))}))},n.prototype.getPushTriggerOption=function(){return o(this,void 0,void 0,(function(){var e,t,n,r;return s(this,(function(i){switch(i.label){case 0:return e=j.of(this._iid),t=e.sdkState,n=e.requestQueue,r=new qt({userId:t.userId}),[4,n.send(r)];case 1:return[2,i.sent().as(xt).pushTriggerOption]}}))}))},n.prototype.setPushTriggerOption=function(e){return o(this,void 0,void 0,(function(){var t,n,r,i;return s(this,(function(o){switch(o.label){case 0:return ee(me(be,e)).throw(V.invalidParameters),t=j.of(this._iid),n=t.sdkState,r=t.requestQueue,i=new Ht({userId:n.userId,pushTriggerOption:e}),[4,r.send(i)];case 1:return[2,o.sent().as(Gt).pushTriggerOption]}}))}))},n.prototype.getPushTemplate=function(){return o(this,void 0,void 0,(function(){var e,t,n,r;return s(this,(function(i){switch(i.label){case 0:return e=j.of(this._iid),t=e.sdkState,n=e.requestQueue,r=new Wt({userId:t.userId}),[4,n.send(r)];case 1:return[2,i.sent().as(Bt).name]}}))}))},n.prototype.setPushTemplate=function(e){return o(this,void 0,void 0,(function(){var t,n,r,i;return s(this,(function(o){switch(o.label){case 0:return ee(me(ye,e)).throw(V.invalidParameters),t=j.of(this._iid),n=t.sdkState,r=t.requestQueue,i=new Kt({userId:n.userId,templateName:e}),[4,r.send(i)];case 1:return[2,o.sent().as(Vt).name]}}))}))},n.prototype.blockUser=function(e){return o(this,void 0,void 0,(function(){var n,r,i,o;return s(this,(function(s){switch(s.label){case 0:return ee(e instanceof h||t("string",e)).throw(V.invalidParameters),n=j.of(this._iid),r=n.sdkState,i=n.requestQueue,o=new jt({userId:r.userId,blockedUserId:e instanceof h?e.userId:e}),[4,i.send(o)];case 1:return s.sent(),[2]}}))}))},n.prototype.blockUserWithUserId=function(e){return o(this,void 0,void 0,(function(){return s(this,(function(t){return[2,this.blockUser(e)]}))}))},n.prototype.unblockUser=function(e){return o(this,void 0,void 0,(function(){var n,r,i,o;return s(this,(function(s){switch(s.label){case 0:return ee(e instanceof h||t("string",e)).throw(V.invalidParameters),n=j.of(this._iid),r=n.sdkState,i=n.requestQueue,o=new Ft({userId:r.userId,unblockedUserId:e instanceof h?e.userId:e}),[4,i.send(o)];case 1:return s.sent(),[2]}}))}))},n.prototype.unblockUserWithUserId=function(e){return o(this,void 0,void 0,(function(){return s(this,(function(t){return[2,this.unblockUser(e)]}))}))},n.prototype.getFriendChangeLogsByToken=function(e){return o(this,void 0,void 0,(function(){var n,r,i,o,a;return s(this,(function(s){switch(s.label){case 0:return ee(t("string",e)).throw(V.invalidParameters),n=j.of(this._iid),r=n.sdkState,i=n.requestQueue,o=new Jt({userId:r.userId,token:e}),[4,i.send(o)];case 1:return a=s.sent(),[2,a.as(Xt).changelogs]}}))}))},n.prototype.getAllowFriendDiscovery=function(){return o(this,void 0,void 0,(function(){var e,t,n,r,i;return s(this,(function(o){switch(o.label){case 0:return e=j.of(this._iid),t=e.sdkState,n=e.requestQueue,r=new rn({userId:t.userId}),[4,n.send(r)];case 1:return i=o.sent(),[2,i.as(on).allowFriendDiscovery]}}))}))},n.prototype.setAllowFriendDiscovery=function(e){return o(this,void 0,void 0,(function(){var n,r,i,o;return s(this,(function(s){switch(s.label){case 0:return ee(t("boolean",e)).throw(V.invalidParameters),n=j.of(this._iid),r=n.sdkState,i=n.requestQueue,o=new sn({userId:r.userId,allowFriendDiscovery:e}),[4,i.send(o)];case 1:return s.sent(),[2,e]}}))}))},n.prototype.uploadFriendDiscoveries=function(e){return o(this,void 0,void 0,(function(){var t,n,r,i,o;return s(this,(function(s){switch(s.label){case 0:return t=j.of(this._iid),n=t.sdkState,r=t.requestQueue,i=new Yt({userId:n.userId,discoveries:e}),[4,r.send(i)];case 1:return o=s.sent(),[2,o.as(Zt).friendDiscoveryRequestId]}}))}))},n.prototype.deleteFriendDiscovery=function(e){return o(this,void 0,void 0,(function(){return s(this,(function(t){return[2,this.deleteFriendDiscoveries([e])]}))}))},n.prototype.deleteFriendDiscoveries=function(e){return o(this,void 0,void 0,(function(){var t,n,r,i;return s(this,(function(o){switch(o.label){case 0:return ee(pe("string",e)).throw(V.invalidParameters),t=j.of(this._iid),n=t.sdkState,r=t.requestQueue,i=new $t({userId:n.userId,discoveryKeys:e}),[4,r.send(i)];case 1:return o.sent(),[2]}}))}))},n.prototype.addFriends=function(e){return o(this,void 0,void 0,(function(){var t,n,r,i,o;return s(this,(function(s){switch(s.label){case 0:return ee(pe("string",e)).throw(V.invalidParameters),t=j.of(this._iid),n=t.sdkState,r=t.requestQueue,i=new en({userId:n.userId,userIds:e}),[4,r.send(i)];case 1:return o=s.sent(),[2,o.as(tn).users]}}))}))},n.prototype.deleteFriend=function(e){return o(this,void 0,void 0,(function(){return s(this,(function(t){return[2,this.deleteFriends([e])]}))}))},n.prototype.deleteFriends=function(e){return o(this,void 0,void 0,(function(){var t,n,r,i;return s(this,(function(o){switch(o.label){case 0:return ee(pe("string",e)).throw(V.invalidParameters),t=j.of(this._iid),n=t.sdkState,r=t.requestQueue,i=new nn({userId:n.userId,userIds:e}),[4,r.send(i)];case 1:return o.sent(),[2]}}))}))},n.prototype.getAllEmoji=function(){return o(this,void 0,void 0,(function(){var e,t,n;return s(this,(function(r){switch(r.label){case 0:return e=j.of(this._iid).requestQueue,t=new un,[4,e.send(t)];case 1:return n=r.sent(),[2,n.as(cn).emojiContainer]}}))}))},n.prototype.getEmojiCategory=function(e){return o(this,void 0,void 0,(function(){var t,n,r;return s(this,(function(i){switch(i.label){case 0:return t=j.of(this._iid).requestQueue,n=new dn({categoryId:e}),[4,t.send(n)];case 1:return r=i.sent(),[2,r.as(ln).emojiCategory]}}))}))},n.prototype.getEmoji=function(e){return o(this,void 0,void 0,(function(){var t,n,r;return s(this,(function(i){switch(i.label){case 0:return t=j.of(this._iid).requestQueue,n=new hn({key:e}),[4,t.send(n)];case 1:return r=i.sent(),[2,r.as(fn).emoji]}}))}))},n.prototype.getUIKitConfiguration=function(){return o(this,void 0,void 0,(function(){var e,t,n,r;return s(this,(function(i){switch(i.label){case 0:return e=j.of(this._iid),ee(e.hasExtension("sb_uikit")).throw(V.notSupportedError),t=e.requestQueue,n=new pn,[4,t.send(n)];case 1:return r=i.sent(),[2,r.as(vn).uikitConfiguration]}}))}))},n}();export{ut as Emoji,ct as EmojiCategory,dt as EmojiContainer,gn as default};
diff --git a/lib/__bundle-753d9ea0.js b/lib/__bundle-0f850482.js
similarity index 69%
rename from lib/__bundle-753d9ea0.js
rename to lib/__bundle-0f850482.js
index d9fa00b..f1e1830 100644
--- a/lib/__bundle-753d9ea0.js
+++ b/lib/__bundle-0f850482.js
@@ -1 +1 @@
-var e=function(t,n){return e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n])},e(t,n)};function t(t,n){if("function"!=typeof n&&null!==n)throw new TypeError("Class extends value "+String(n)+" is not a constructor or null");function i(){this.constructor=t}e(t,n),t.prototype=null===n?Object.create(n):(i.prototype=n.prototype,new i)}var n=function(){return n=Object.assign||function(e){for(var t,n=1,i=arguments.length;n0&&r[r.length-1])||6!==a[0]&&2!==a[0])){s=0;continue}if(3===a[0]&&(!r||a[1]>r[0]&&a[1]=e.length&&(e=void 0),{value:e&&e[i++],done:!e}}};throw new TypeError(t?"Object is not iterable.":"Symbol.iterator is not defined.")}function a(e,t){var n="function"==typeof Symbol&&e[Symbol.iterator];if(!n)return e;var i,r,o=n.call(e),s=[];try{for(;(void 0===t||t-- >0)&&!(i=o.next()).done;)s.push(i.value)}catch(e){r={error:e}}finally{try{i&&!i.done&&(n=o.return)&&n.call(o)}finally{if(r)throw r.error}}return s}function c(e,t,n){if(n||2===arguments.length)for(var i,r=0,o=t.length;r0&&b.indexOf(e)>=0},k=function(e){return e>0&&m.indexOf(e)>=0},O=function(e,t){if(void 0===t&&(t=!1),t&&null==e)return!0;var n="object"==typeof e&&null!==e&&e.hasOwnProperty("name")&&"string"==typeof e.name&&e.hasOwnProperty("uri")&&"string"==typeof e.uri&&e.hasOwnProperty("type")&&"string"==typeof e.type;if(!n){if("undefined"!=typeof Blob)return e instanceof Blob;if("undefined"!=typeof File)return e instanceof File}return n},I=function(e,t){if(e===t)return!0;if(null==e||null==t)return!1;if(e.length!==t.length)return!1;for(var n=c([],a(e),!1).sort(),i=c([],a(t),!1).sort(),r=0;r=1e3&&e<=9e3&&(this._typingIndicatorThrottle=e)},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"websocketResponseTimeout",{get:function(){return this._websocketResponseTimeout},set:function(e){w("number",e)&&e>=5e3&&e<=3e4&&(this._websocketResponseTimeout=e)},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"sessionTokenRefreshTimeout",{get:function(){return this._sessionTokenRefreshTimeout},set:function(e){w("number",e)&&(e<60?e=60:e>1800&&(e=1800),this._sessionTokenRefreshTimeout=e)},enumerable:!1,configurable:!0}),e}(),D={encrypt:function(e){return e},decrypt:function(e){return e}},L=function(){function e(e){var t=e.store;this._preference=new Map,this._store=t}return e.prototype._savePreferenceKeys=function(){return r(this,void 0,void 0,(function(){return o(this,(function(e){switch(e.label){case 0:return[4,this._store.set({key:this._keysAddress,value:c([],a(this._preference.keys()),!1)})];case 1:return e.sent(),[2]}}))}))},e.prototype.init=function(e,t){var n;return void 0===t&&(t=1),r(this,void 0,void 0,(function(){var i,r,a,c,u,l,h,d,_,f;return o(this,(function(o){switch(o.label){case 0:return this._version=t,this._keysAddress=e,i="".concat(e,".metadata.version"),[4,this._store.get(i)];case 1:return r=o.sent(),[4,this._store.get(e)];case 2:return a=null!==(n=o.sent())&&void 0!==n?n:[],!r||r.versiont.channel.messageCollectionLastAccessedAt?1:-1},this._maxSize=Math.max(i,64),s?(this._clearOrder=o,this._customClearOrderComparator=s):this._clearOrder=E.MESSAGE_COLLECTION_ACCESSED_AT,this._enableAutoResend=c}return Object.defineProperty(e.prototype,"maxSize",{get:function(){return this._maxSize},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"clearOrder",{get:function(){return this._clearOrder},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"clearOrderComparator",{get:function(){var e;return this._clearOrder===E.MESSAGE_COLLECTION_ACCESSED_AT?this._clearOrderComparatorUseMessageCollectionAccessedAt:null!==(e=this._customClearOrderComparator)&&void 0!==e?e:this._clearOrderComparatorUseMessageCollectionAccessedAt},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"enableAutoResend",{get:function(){return this._enableAutoResend},enumerable:!1,configurable:!0}),e}();!function(e){e.FEED="feed",e.CHAT="chat"}(U||(U={}));var z,F,H,V,q,G,j,K,B,Z,W=function(){function e(){this.isRefreshing=!1}return Object.defineProperty(e.prototype,"hasSession",{get:function(){return!!this.sessionKey},enumerable:!1,configurable:!0}),e.prototype.clear=function(){this.authToken=void 0,this.sessionKey=void 0,this.services=[]},e.prototype.hasLessServiceScopeThan=function(e){var t;return!this.sessionKey||!(null===(t=this.services)||void 0===t?void 0:t.includes(U.CHAT))||e.includes(U.CHAT)},e}(),Q=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)}))},Y=function(){function e(e){var t=e.container;this._container={},this._container=t,this.key=Q()}return e.prototype._register=function(e,t,n){var i;return e in this._container||(this._container[e]=new Map),null===(i=this._container[e])||void 0===i||i.set(this.key,{occurence:t,handler:n}),this},e.prototype.on=function(e,t){return this._register(e,-1,t)},e.prototype.once=function(e,t){return this._register(e,1,t)},e.prototype.close=function(){var e;for(var t in this._container)null===(e=this._container[t])||void 0===e||e.delete(this.key)},e}(),X=function(){function e(){this._container={}}return e.prototype.on=function(e,t){return new Y({container:this._container}).on(e,t)},e.prototype.once=function(e,t){return new Y({container:this._container}).once(e,t)},e.prototype.dispatch=function(e,t){var n,i,r=this._container[e];if(r){var o=[];try{for(var a=s(r.keys()),c=a.next();!c.done;c=a.next()){var u=c.value,l=r.get(u);l.handler(t),l.occurence>0&&(l.occurence--,0===l.occurence&&o.push(u))}}catch(e){n={error:e}}finally{try{c&&!c.done&&(i=a.return)&&i.call(a)}finally{if(n)throw n.error}}o.forEach((function(e){return r.delete(e)}))}},e}(),J=function(){function e(){this._dispatcher=new X}return e.prototype.on=function(e){return this._dispatcher.on("event",e)},e.prototype.once=function(e){return this._dispatcher.once("event",e)},e.prototype.dispatch=function(e){this._dispatcher.dispatch("event",e)},e}(),$=function(){},ee=function(e){var t={};return e&&Object.keys(e).forEach((function(n){void 0===e[n]||Number.isNaN(e[n])||null===e[n]||(t[n]=e[n])})),t},te=function(e){if(null!=e){if("object"==typeof e){if(Array.isArray(e)){var t=c([],a(e),!1);for(var n in t)t[n]=te(t[n]);return t}for(var i in e)null===e[i]&&delete e[i];return e}return e}};!function(e){e.BASE="base",e.GROUP="group",e.OPEN="open",e.FEED="feed"}(z||(z={})),function(e){e.OPERATOR="operator",e.NONE="none"}(F||(F={})),function(e){e.MUTED="muted",e.UNMUTED="unmuted"}(H||(H={})),function(e){e.BASE="base",e.USER="user",e.FILE="file",e.ADMIN="admin"}(V||(V={})),function(e){e.ALL="",e.USER="MESG",e.FILE="FILE",e.ADMIN="ADMM"}(q||(q={})),function(e){e.USER="MESG",e.FILE="FILE",e.ADMIN="ADMM"}(G||(G={})),function(e){e.USERS="users",e.CHANNEL="channel"}(j||(j={})),function(e){e.ALL="all",e.NONE="none",e.ONLY_REPLY_TO_CHANNEL="only_reply_to_channel"}(K||(K={})),function(e){e.DEFAULT="default",e.SUPPRESS="suppress"}(B||(B={})),function(e){e.PENDING="pending",e.SCHEDULED="scheduled",e.SUCCEEDED="succeeded",e.FAILED="failed",e.CANCELED="canceled"}(Z||(Z={}));var ne,ie="v3",re="/".concat(ie,"/users"),oe="/".concat(ie,"/storage/file"),se="/".concat(ie,"/group_channels"),ae="/".concat(ie,"/sdk/group_channels"),ce="/".concat(ie,"/open_channels"),ue="/".concat(ie,"/sdk/open_channels"),le="/".concat(ie,"/search"),he="/".concat(ie,"/report"),de="/".concat(ie,"/emojis"),_e="/".concat(ie,"/emoji_categories"),fe="/".concat(ie,"/polls"),pe="/".concat(ie,"/scheduled_messages"),Ee="/".concat(ie,"/sdk/ui_kit/configuration"),ve="/".concat(ie,"/sdk/statistics"),ge="/".concat(ie,"/notifications"),be=function(e){switch(e){case z.FEED:case z.GROUP:return se;case z.OPEN:return ce;default:return null}},me=function(e){switch(e){case z.GROUP:return"".concat(he,"/group_channels");case z.OPEN:return"".concat(he,"/open_channels");default:return null}},ye=function(e,t,n){var i,r;switch(e){case j.CHANNEL:return!0;case j.USERS:if(t)try{for(var o=s(t),a=o.next();!a.done;a=o.next()){if(a.value===n)return!0}}catch(e){i={error:e}}finally{try{a&&!a.done&&(r=o.return)&&r.call(o)}finally{if(i)throw i.error}}}return!1},we=function(e,t,n){var i,r,o,s,a=ye(null!==(i=e.mentionType)&&void 0!==i?i:null,null!==(r=e.mentionedUserIds)&&void 0!==r?r:[],n),c=ye(null!==(o=t.mentionType)&&void 0!==o?o:null,null!==(s=t.mentionedUserIds)&&void 0!==s?s:[],n);return!a&&c?1:a&&!c?-1:0},Se=function(e,t,n){var i,r=t||new FormData;for(var o in e)if(e.hasOwnProperty(o)){var s=e[o],a=n?"".concat(n,"[").concat(o,"]"):o;O(s)?r.append(a,s,null!==(i=s.name)&&void 0!==i?i:"filename"):"object"!=typeof s||null===s||Array.isArray(s)||s instanceof Blob?r.append(a,String(s)):r=Se(s,r,a)}return r};!function(e){e.GET="GET",e.POST="POST",e.PUT="PUT",e.DELETE="DELETE"}(ne||(ne={}));var Te,Ne=function(e){function n(){var t=null!==e&&e.apply(this,arguments)||this;return t.params={},t.requireAuth=!0,t.headers={},t.requestId=Q(),t}return t(n,e),n.prototype.encodeParams=function(e){var t=this;return null==e||""===e?encodeURIComponent(""):Array.isArray(e)?e.map((function(e){return t.encodeParams(e)})).join(","):"object"==typeof e?encodeURIComponent(JSON.stringify(e)):encodeURIComponent(String(e))},Object.defineProperty(n.prototype,"query",{get:function(){var e=this,t=ee(this.params);return"?".concat(Object.keys(t).map((function(n){return"".concat(encodeURIComponent(n),"=").concat(e.encodeParams(t[n]))})).join("&"))},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"payload",{get:function(){var e=ee(this.params);return Object.keys(e).some((function(t){return O(e[t])}))?Se(e):JSON.stringify(e)},enumerable:!1,configurable:!0}),n}($),Ae=function(e){function i(t,n){var i=e.call(this)||this;return i._iid=t,i._payload=n,i}return t(i,e),Object.defineProperty(i.prototype,"payload",{get:function(){return n({},this._payload)},enumerable:!1,configurable:!0}),i.prototype.as=function(e){return new e(this._iid,this.payload)},i}($),Ce=function(e){function n(t){var n=e.call(this)||this;return n.requestId=t,n}return t(n,e),n}($),ke=function(e){function n(t){var n=t.expires_in,i=t.reason,r=void 0===i?u.SESSION_KEY_EXPIRED:i,o=e.call(this)||this;switch(o.expiresIn=null!=n?n:0,r){case u.SESSION_KEY_EXPIRED:case u.SESSION_TOKEN_EXPIRED:case u.SESSION_REVOKED:case u.USER_AUTH_DEACTIVATED:case u.USER_AUTH_DELETED_OR_NOT_FOUND:o.error=new g({code:r})}return o}return t(n,e),Object.defineProperty(n.prototype,"invalidateSessionToken",{get:function(){var e;return!!(null===(e=this.error)||void 0===e?void 0:e.isSessionTokenExpiredError)},enumerable:!1,configurable:!0}),n}($),Oe=function(e){function n(t){var n=e.call(this)||this;return n.statLog=t,n}return t(n,e),n}($),Ie=function(e){function n(t){var n=t.request,i=t.deferred,r=t.error,o=void 0===r?g.requestFailed:r,s=e.call(this)||this;return s.request=n,s.deferred=i,s.error=o,s}return t(n,e),n}($);!function(e){e.FEATURE_LOCALCACHE="feature:local_cache",e.FEATURE_LOCALCACHE_EVENT="feature:local_cache_event",e.WEBSOCKET_CONNECT="ws:connect",e.API_RESULT="api:result"}(Te||(Te={}));var Re,De,Le,xe=function(){function e(e){var t=e.type,n=e.data,i=e.ts,r=void 0===i?Date.now():i;this.type=t,this.createdAt=r,this.data=n}return e.payloadify=function(e){return ee({stat_type:e.type,ts:e.createdAt,data:ee(e.data)})},e}(),Ue=function(){return"undefined"==typeof document&&"undefined"!=typeof navigator&&"ReactNative"==navigator.product},Pe=function(){return!("undefined"==typeof navigator||!/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini|Windows Phone/i.test(navigator.userAgent))};!function(e){e.CHAT="chat",e.CALLS="calls",e.DESK="desk",e.LIVE="live",e.UIKIT_CHAT="uikit-chat",e.UIKIT_LIVE="uikit-live"}(Re||(Re={})),function(e){e.ANDROID="android",e.IOS="ios",e.JS="js",e.UNREAL="unreal",e.UNITY="unity",e.REACT_NATIVE="react-native",e.FLUTTER="flutter"}(De||(De={})),function(e){e.ANDROID="android",e.IOS="ios",e.WEB="web",e.MOBILE_WEB="mobile_web",e.WINDOWS="windows"}(Le||(Le={}));var Me="^(0|[1-9]\\d*)\\.(0|[1-9]\\d*)\\.(0|[1-9]\\d*)(?:-((?:0|[1-9]\\d*|\\d*[a-zA-Z-][0-9a-zA-Z-]*)(?:\\.(?:0|[1-9]\\d*|\\d*[a-zA-Z-][0-9a-zA-Z-]*))*))?(?:\\+([0-9a-zA-Z-]+(?:\\.[0-9a-zA-Z-]+)*))?$",ze=function(){function e(){}return e.sendbirdSdkUserAgentWithExtension=function(e){var t=Ue()?De.REACT_NATIVE:De.JS,i={main_sdk_info:"chat/".concat(t,"/").concat(h.SDK_VERSION),device_os_platform:Pe()?"mobile-web":"web",os_version:h.OS_VERSION};if(e){var r=e.sendbirdExtensions,o=e.deviceOS,s=e.customData,c=void 0===s?{}:s;o.version&&(i.os_version=o.version),o.platform&&(i.device_os_platform=o.platform),r.length>0&&(i.extension_sdk_info=r.map((function(e){var t=e.product,n=e.platform,i=e.version;return"".concat(t,"/").concat(n,"/").concat(i)})).join(",")),Object.keys(i).forEach((function(e){return delete c[e]})),Object.keys(c).length>0&&(i=n(n({},i),c))}return Object.entries(i).map((function(e){var t=a(e,2),n=t[0],i=t[1];return"".concat(n,"=").concat(i)})).join("&")},e.userAgentWithExtension=function(e){var t=Ue()?"reactnative":"JS",n=e.sb_syncmanager?"s".concat(e.sb_syncmanager):"",i=e.sb_uikit?"u".concat(e.sb_uikit):"",r=e["device-os-platform"]?"o".concat(e["device-os-platform"]):Pe()?"omobile-web":"oweb";return"".concat(t,"/c").concat(h.SDK_VERSION,"/").concat(n,"/").concat(i,"/").concat(r)},e}(),Fe=function(){var e=this;this.promise=new Promise((function(t,n){e.resolve=t,e.reject=n}))},He=function(){function e(e,t){var n=t.session,i=t.sdkState,r=t.dispatcher,o=t.logger,s=t.useFetchCompat,a=void 0!==s&&s,c=this;this._abortControl=new Map,this._shouldImportFetchCompat=!1,this._iid=e,this._session=n,this._sdkState=i,this._dispatcher=r,this._dispatcher.on((function(e){e instanceof Ce&&c.cancel(e.requestId)})),this._logger=o,this._shouldImportFetchCompat=a}return e.prototype._createHeader=function(e,t){var i=this._sdkState,r=i.appId,o=i.appVersion,s=i.sendbirdRuntimeEnvironment,a=n(n({},e.headers),{SendBird:"JS,".concat(h.OS_VERSION,",").concat(h.SDK_VERSION,",").concat(r).concat(o?",".concat(o):""),"SB-User-Agent":ze.userAgentWithExtension(this._sdkState.extensions),"Request-Sent-Timestamp":Date.now().toString(),"SB-SDK-User-Agent":ze.sendbirdSdkUserAgentWithExtension(s)});return t||(a["Content-Type"]="application/json; charset=utf-8"),e.requireAuth&&this._session.hasSession&&(a["Session-Key"]=this._session.sessionKey),this._session&&this._session.authToken&&(a["App-Id"]=r,a["Access-Token"]=this._session.authToken),a},e.prototype._statLogApiResult=function(e,t,n){this._dispatcher.dispatch(new Oe(new xe({type:Te.API_RESULT,data:{endpoint:e.path,method:e.method,success:!n,latency:Date.now()-t,error_code:null==n?void 0:n.code,error_description:null==n?void 0:n.message}})))},e.prototype.send=function(e){return r(this,void 0,void 0,(function(){var t,n,i,r,s,a,c,u,l,h,d,_,f,p,E,v;return o(this,(function(o){switch(o.label){case 0:t=e.path,n=e.method,i=![ne.GET,ne.DELETE].includes(n),r=this._sdkState.api,s="".concat(r.host).concat(t).concat(i?"":e.query),a=i?e.payload:null,c=this._createHeader(e,a instanceof FormData?a:void 0),u=new AbortController,l=u.signal,this._abortControl.set(e.requestId,u),h=Date.now(),o.label=1;case 1:return o.trys.push([1,8,,9]),this._shouldImportFetchCompat&&(this._shouldImportFetchCompat=!1,("undefined"!=typeof globalThis&&globalThis||"undefined"!=typeof self&&self||"undefined"!=typeof global&&global||{fetch:null}).fetch=null),"undefined"!=typeof AbortController?[3,3]:[4,import("./__bundle-2aa1a987.js")];case 2:o.sent(),o.label=3;case 3:return"function"==typeof fetch?[3,5]:[4,import("./__bundle-40c7abbd.js")];case 4:o.sent(),o.label=5;case 5:return[4,fetch(s,{method:n,body:a,headers:c,signal:l})];case 6:return[4,(d=o.sent()).json()];case 7:if(_=o.sent(),d.ok||d.redirected)return this._logger.debug("receive api response",e.requestId),this._statLogApiResult(e,h),[2,new Ae(this._iid,_)];if(_){if((p=new g(_)).isSessionExpiredError)return f=new Fe,this._dispatcher.dispatch(new Ie({request:e,deferred:f,error:p})),this._dispatcher.dispatch(new ke({reason:p.code})),[2,f.promise];throw p.isSessionInvalidatedError?(this._dispatcher.dispatch(new ke({reason:p.code})),p):(this._statLogApiResult(e,h,p),p)}throw p=g.requestFailed,this._statLogApiResult(e,h,p),p;case 8:throw E=o.sent(),this._statLogApiResult(e,h,E),E instanceof g?(this._logger.debug("fail api request",E),E):"AbortError"===E.name?g.requestCanceled:(v=g.networkError,this._logger.debug("fail api request",v),v);case 9:return[2]}}))}))},e.prototype.cancel=function(e){this._abortControl.has(e)&&(this._abortControl.get(e).abort(),this._abortControl.delete(e))},e.prototype.cancelAll=function(){var e,t;try{for(var n=s(this._abortControl.values()),i=n.next();!i.done;i=n.next()){i.value.abort()}}catch(t){e={error:t}}finally{try{i&&!i.done&&(t=n.return)&&t.call(n)}finally{if(e)throw e.error}}this._abortControl.clear()},e}(),Ve=function(e){function n(t,n,i,r){void 0===r&&(r="");var o,s=this;return(s=e.call(this)||this)._iid=t,s.code=n,s.payload=i,s.requestId=null!==(o=i.req_id)&&void 0!==o?o:r,s}return t(n,e),n.createFromRawMessage=function(e,t){var i=t.substring(0,4),r={};try{r=JSON.parse(t.substring(4))}catch(e){i="NOOP"}finally{return new n(e,i,r)}},n.prototype.convertToMessage=function(){return"".concat(this.code).concat(JSON.stringify(this.payload),"\n")},n.prototype.as=function(e){return new e(this._iid,this.code,this.payload)},n}($),qe=function(){};function Ge(e){let t=e.length;for(;--t>=0;)e[t]=0}const je=256,Ke=286,Be=30,Ze=15,We=new Uint8Array([0,0,0,0,0,0,0,0,1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4,5,5,5,5,0]),Qe=new Uint8Array([0,0,0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9,9,10,10,11,11,12,12,13,13]),Ye=new Uint8Array([0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,3,7]),Xe=new Uint8Array([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),Je=new Array(576);Ge(Je);const $e=new Array(60);Ge($e);const et=new Array(512);Ge(et);const tt=new Array(256);Ge(tt);const nt=new Array(29);Ge(nt);const it=new Array(Be);function rt(e,t,n,i,r){this.static_tree=e,this.extra_bits=t,this.extra_base=n,this.elems=i,this.max_length=r,this.has_stree=e&&e.length}let ot,st,at;function ct(e,t){this.dyn_tree=e,this.max_code=0,this.stat_desc=t}Ge(it);const ut=e=>e<256?et[e]:et[256+(e>>>7)],lt=(e,t)=>{e.pending_buf[e.pending++]=255&t,e.pending_buf[e.pending++]=t>>>8&255},ht=(e,t,n)=>{e.bi_valid>16-n?(e.bi_buf|=t<>16-e.bi_valid,e.bi_valid+=n-16):(e.bi_buf|=t<