@sendbird/chat
Advanced tools
Comparing version 4.0.0-beta.8 to 4.0.0-beta.9
@@ -1,1 +0,1 @@ | ||
import{d as e,e as n,V as a,ae as r,af as i,S as s,q as o,o as l,p as h,F as c,J as d,j as p,a6 as m,_ as f,n as v,A as y,ab as g,g as b,h as w,k,a as F,b as M,c as E,B as T,t as N,ao as P,s as D,M as j,x as q,aY as ee}from"./__bundle-c2d86ac8.js";export{ai as MessageEventSource}from"./__bundle-c2d86ac8.js";import{r as te,s as ne,G as ae,t as re,T as ie,u as se,v as oe,w as ue,x as le,y as he,z as ce,A as de,B as pe,S as me,C as fe,E as ve,F as _e,H as ye,I as ge,J as Ce}from"./__bundle-2c9a1186.js";export{K as CountPreference,B as GroupChannel,u as GroupChannelChangeLogsParams,L as GroupChannelChangeLogsParamsProperties,I as GroupChannelCountParams,Q as GroupChannelCountParamsProperties,J as GroupChannelCreateParams,O as GroupChannelCreateParamsProperties,z as GroupChannelEventContext,t as GroupChannelEventSource,x as GroupChannelFilter,R as GroupChannelHideParams,V as GroupChannelHideParamsProperties,G as GroupChannelListOrder,H as GroupChannelListQuery,W as GroupChannelSearchField,X as GroupChannelUpdateParams,Y as GroupChannelUpdateParamsProperties,Z as HiddenChannelFilter,_ as HiddenState,$ as Member,a0 as MemberListOrder,a1 as MemberListQuery,a2 as MemberState,a3 as MemberStateFilter,a4 as MessageCollection,a5 as MessageCollectionInitHandler,a6 as MessageCollectionInitPolicy,a7 as MessageEventContext,a8 as MessageFilter,a9 as MutedState,aa as OperatorFilter,A as PublicChannelFilter,C as PublicGroupChannelListOrder,ab as QueryType,ac as ReadStatus,S as SuperChannelFilter,ad as UnreadChannelFilter,U as UnreadItemKey}from"./__bundle-2c9a1186.js";import{B as be}from"./__bundle-404df74c.js";import"./__bundle-e1c90263.js";var we,ke={},Fe=function(){function t(t){var r=t._iid,i=this;this._sync=null,this._metadata=null,this._iid=r;var u,h=a.of(this._iid),c=h.sdkState,d=h.logger;this._metadataKey=(u=c.userId,"sendbird:".concat(u,"@groupchannel/sync.meta"));var p=function(e){return"sendbird:".concat(e,"@groupchannel/sync")}(c.userId);this._sync=new te(p,(function(){return e(i,void 0,void 0,(function(){var e,t,a,r,i,u;return n(this,(function(n){switch(n.label){case 0:return e={hasNext:!0,nextToken:""},[4,this.loadMetadata()];case 1:if(n.sent(),d.debug("channel background sync from",this._metadata.token),this._metadata.completed)return[3,9];n.label=2;case 2:return n.trys.push([2,5,,8]),[4,ne.of(this._iid).getMyGroupChannels(this._metadata.token,{includeEmpty:!0,order:ae.CHRONOLOGICAL},100,re.SYNC_CHANNEL_BACKGROUND)];case 3:return t=n.sent(),a=t.channels,r=t.token,e.hasNext=a.length>=100&&!!r,e.nextToken=r,this._metadata.token=r,(u=this._metadata.range).extends.apply(u,o([],l(a.map((function(e){return e.createdAt}))),!1)),this._metadata.completed=!e.hasNext,d.debug("channel background sync progress",e),[4,this.saveMetadata()];case 4:return n.sent(),[3,8];case 5:return(i=n.sent())instanceof s&&i.isInvalidTokenError?[4,this.clearMetaData()]:[3,7];case 6:n.sent(),n.label=7;case 7:return[3,8];case 8:return[3,10];case 9:e.hasNext=!1,e.nextToken="",n.label=10;case 10:return[2,e]}}))}))}))}return t.of=function(e){if(!ke[e]){var n=ke[e]=new t({_iid:e});a.of(e).dispatcher.on((function(e){if(e instanceof r)if(e.stateType===i.CONNECTED)n.resume();else n.pause()}))}return ke[e]},Object.defineProperty(t.prototype,"range",{get:function(){var e;return null===(e=this._metadata)||void 0===e?void 0:e.range},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"completed",{get:function(){var e;return!!(null===(e=this._metadata)||void 0===e?void 0:e.completed)},enumerable:!1,configurable:!0}),t.prototype.loadMetadata=function(){return e(this,void 0,void 0,(function(){var e;return n(this,(function(t){switch(t.label){case 0:return this._metadata?[3,2]:[4,a.of(this._iid).cacheContext.store.get(this._metadataKey)];case 1:e=t.sent(),this._metadata={token:e?e.token:"",range:new ie(e?e.range:{top:Number.MAX_SAFE_INTEGER,bottom:0}),completed:!!e&&e.completed},t.label=2;case 2:return[2]}}))}))},t.prototype.saveMetadata=function(){return e(this,void 0,void 0,(function(){return n(this,(function(e){switch(e.label){case 0:return this._metadata?[4,a.of(this._iid).cacheContext.store.set({key:this._metadataKey,value:this._metadata,generation:1})]:[3,2];case 1:e.sent(),e.label=2;case 2:return[2]}}))}))},t.prototype.clearMetaData=function(){return e(this,void 0,void 0,(function(){return n(this,(function(e){switch(e.label){case 0:return[4,a.of(this._iid).cacheContext.store.remove(this._metadataKey)];case 1:return e.sent(),[2]}}))}))},t.prototype.resume=function(){var e,t;a.of(this._iid).logger.debug("channel background sync resume()"),this._sync.start(null!==(t=null===(e=this._metadata)||void 0===e?void 0:e.token)&&void 0!==t?t:"")},t.prototype.pause=function(){a.of(this._iid).logger.debug("channel background sync stop()"),this._sync.stop()},t}(),Me={},Le=function(){function t(t){var r=t._iid,i=this;this._sync=null,this._metadataKey=null,this._metadata=null,this._iid=r;var o,u=a.of(this._iid).sdkState;this._metadataKey=(o=u.userId,"sendbird:".concat(o,"@groupchannel/changelogs.meta"));var l=function(e){return"sendbird:".concat(e,"@groupchannel/changelogs")}(u.userId);this._sync=new te(l,(function(){return e(i,void 0,void 0,(function(){var e,t,a,r,i;return n(this,(function(n){switch(n.label){case 0:return e={hasNext:!0,nextToken:0},[4,this.loadMetadata()];case 1:n.sent(),n.label=2;case 2:return n.trys.push([2,5,,8]),[4,ne.of(this._iid).getMyGroupChannelChangeLogs(this._metadata.token,new se,re.SYNC_CHANNEL_CHANGELOGS)];case 3:return t=n.sent(),a=t.hasMore,r=t.token,e.hasNext=a,e.nextToken=r,this._metadata.token=r,[4,this.saveMetadata()];case 4:return n.sent(),[3,8];case 5:return(i=n.sent())instanceof s&&i.isInvalidTokenError?[4,this.clearMetadata()]:[3,7];case 6:n.sent(),n.label=7;case 7:return e.hasNext=!1,e.nextToken="",[3,8];case 8:return[2,e]}}))}))}))}return t.of=function(e){if(!Me[e]){var n=Me[e]=new t({_iid:e});a.of(e).dispatcher.on((function(e){if(e instanceof r)if(e.stateType===i.CONNECTED)n.resume();else n.pause()}))}return Me[e]},t.prototype.loadMetadata=function(){return e(this,void 0,void 0,(function(){var e;return n(this,(function(t){switch(t.label){case 0:return this._metadata?[3,2]:[4,a.of(this._iid).cacheContext.store.get(this._metadataKey)];case 1:e=t.sent(),this._metadata={token:e?e.token:""},t.label=2;case 2:return[2]}}))}))},t.prototype.saveMetadata=function(){return e(this,void 0,void 0,(function(){return n(this,(function(e){switch(e.label){case 0:return this._metadata?[4,a.of(this._iid).cacheContext.store.set({key:this._metadataKey,value:this._metadata,generation:1})]:[3,2];case 1:e.sent(),e.label=2;case 2:return[2]}}))}))},t.prototype.clearMetadata=function(){return e(this,void 0,void 0,(function(){return n(this,(function(e){return a.of(this._iid).cacheContext.store.remove(this._metadataKey),[2]}))}))},t.prototype.resume=function(){this._sync.start(0)},t.prototype.pause=function(){this._sync.stop()},t}(),Se=function(){function t(e,t){var n=t.filter,r=t.order,i=t.limit,s=this;this.channels=[],this._iid=e,this._key="gcc-".concat(d()),this.filter=null!=n?n:new le,this.order=null!=r?r:ae.LATEST_LAST_MESSAGE,this._hasMore=!0,this._token="",this._limit=null!=i?i:he,Fe.of(e).resume(),Le.of(e).resume();var o=a.of(this._iid).sdkState;ne.of(this._iid).subscribeGroupChannelEvent(this._key,{onUpdate:function(e,t){var n=e.filter((function(e){return s.filter.match(e,o.userId)})),a=e.filter((function(e){return!s.filter.match(e,o.userId)})).map((function(e){return e.url}));n.length>0&&s._addChannelsToView(n,t),a.length>0&&s._removeChannelsFromView(a,t)},onRemove:function(e,t){s._removeChannelsFromView(e,t)}})}return Object.defineProperty(t.prototype,"hasMore",{get:function(){return this._hasMore},enumerable:!1,configurable:!0}),t.prototype.setGroupChannelCollectionHandler=function(e){this._handler=e},t.prototype._addChannelsToView=function(t,a,r){var i,s,o=this;void 0===r&&(r=!1);var u=[],l=[];try{for(var d=h(t),p=d.next();!p.done;p=d.next()){var m=p.value,f=oe(this.channels,m,this.order),v=f.place;if(f.contains)switch(l.push(m),a){case re.EVENT_CHANNEL_UPDATED:case re.EVENT_MESSAGE_RECEIVED:this.channels.splice(v,1);var _=oe(this.channels,m,this.order).place;this.channels.splice(_,0,m);break;default:this.channels[v]=m}else if(v===this.channels.length){var y=Fe.of(this._iid);(r||y.completed)&&(u.push(m),this.channels.push(m))}else u.push(m),this.channels.splice(v,0,m)}}catch(e){i={error:e}}finally{try{p&&!p.done&&(s=d.return)&&s.call(d)}finally{if(i)throw i.error}}ue(a)&&c((function(){return e(o,void 0,void 0,(function(){var e;return n(this,(function(t){return e=new ce(a),u.length>0&&this._handler.onChannelsAdded(e,u),l.length>0&&this._handler.onChannelsUpdated(e,l),[2]}))}))}))},t.prototype._removeChannelsFromView=function(t,a){var r,i,s=this,o=[],u=function(e){var t=l.channels.findIndex((function(t){return t.url===e}));t>=0&&(o.push(l.channels[t].url),l.channels.splice(t,1))},l=this;try{for(var d=h(t),p=d.next();!p.done;p=d.next()){u(p.value)}}catch(e){r={error:e}}finally{try{p&&!p.done&&(i=d.return)&&i.call(d)}finally{if(r)throw r.error}}return ue(a)&&o.length>0&&c((function(){return e(s,void 0,void 0,(function(){var e;return n(this,(function(t){return e=new ce(a),this._handler.onChannelsDeleted(e,o),[2]}))}))})),o},t.prototype._getLocalChannels=function(){return e(this,void 0,void 0,(function(){return n(this,(function(e){switch(e.label){case 0:return[4,ne.of(this._iid).getChannelsFromCache(this._token,this.filter,this.order)];case 1:return[2,e.sent()]}}))}))},t.prototype._getRemoteChannels=function(){return e(this,void 0,void 0,(function(){var e,t,a;return n(this,(function(n){switch(n.label){case 0:return[4,ne.of(this._iid).getMyGroupChannels(this._token,p(p({},this.filter),{order:this.order}),this._limit)];case 1:return e=n.sent(),t=e.channels,a=e.token,this._token=a,[2,t]}}))}))},t.prototype.loadMore=function(){return e(this,void 0,void 0,(function(){var t,a=this;return n(this,(function(r){switch(r.label){case 0:return this._hasMore?(t=[],[4,m((function(){return e(a,void 0,void 0,(function(){return n(this,(function(e){switch(e.label){case 0:return[4,this._getLocalChannels()];case 1:return t=e.sent(),[2]}}))}))}))]):[3,3];case 1:return r.sent(),[4,m((function(){return e(a,void 0,void 0,(function(){return n(this,(function(e){switch(e.label){case 0:return[4,this._getRemoteChannels()];case 1:return t=e.sent(),[2]}}))}))}))];case 2:return r.sent(),this._addChannelsToView(t,re.REQUEST_CHANNEL,!0),[2,t];case 3:return[2,[]]}}))}))},t.prototype.dispose=function(){ne.of(this._iid).unsubscribeGroupChannelEvent(this._key)},t}(),Ge=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 f(t,e),t}(function(e){function t(){var t=null!==e&&e.apply(this,arguments)||this;return t.onUserJoined=v,t.onUserLeft=v,t.onUserReceivedInvitation=v,t.onUserDeclinedInvitation=v,t.onChannelHidden=v,t.onUnreadMemberStatusUpdated=v,t.onUndeliveredMemberStatusUpdated=v,t.onTypingStatusUpdated=v,t}return f(t,e),t}(be)),Ee=function(e){function t(t){var n=this,a=t.token,r=t.limit,i=t.order,s=t.includeEmpty,o=t.membershipFilter,u=t.channelNameContainsFilter,l=t.channelUrlsFilter,h=t.customTypesFilter,c=t.customTypeStartsWithFilter,d=t.superChannelFilter,p=t.metadataOrderKeyFilter,m=t.metadataKey,f=t.metadataValues,v=t.metadataValueStartsWith,_=t.includeFrozen,C=t.includeMetaData;return(n=e.call(this)||this).method=y.GET,n.path=g,n.params=b({token:a,limit:r,order:i,show_member:!0,show_read_receipt:!0,show_delivery_receipt:!0,show_empty:s,public_mode:de.PUBLIC,public_membership_mode:o,name_contains:u,channel_urls:l,custom_types:h,custom_type_startswith:c,super_mode:d,metadata_order_key:p,metadata_key:m,metadata_values:f,metadata_value_startswith:v,show_frozen:_,show_metadata:C}),n}return f(t,e),t}(w),Te=function(e){function t(t,n){var a=e.call(this,t,n)||this;a.token=null,a.channels=[],a.ts=null;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 pe(t,e)}))),a.ts="number"==typeof s?s:null,a}return f(t,e),t}(k);!function(e){e.ALL="all",e.JOINED="joined"}(we||(we={}));var xe=function(t){function r(e,n){var a,r,i,s,o,u,l,h,c,d,p,m,f,v,_=this;return(_=t.call(this,e,n)||this).includeEmpty=!1,_.includeFrozen=!0,_.includeMetaData=!0,_.channelUrlsFilter=null,_.customTypesFilter=null,_.customTypeStartsWithFilter=null,_.nicknameContainsFilter=null,_.channelNameContainsFilter=null,_.membershipFilter=we.ALL,_.superChannelFilter=me.ALL,_.metadataKey=null,_.metadataValues=null,_.metadataOrderKeyFilter=null,_.metadataValueStartsWith=null,_.order=fe.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!==(u=n.customTypeStartsWithFilter)&&void 0!==u?u:null,_.channelNameContainsFilter=null!==(l=n.channelNameContainsFilter)&&void 0!==l?l:null,_.membershipFilter=null!==(h=n.membershipFilter)&&void 0!==h?h:we.ALL,_.superChannelFilter=null!==(c=n.superChannelFilter)&&void 0!==c?c:me.ALL,_.metadataKey=null!==(d=n.metadataKey)&&void 0!==d?d:null,_.metadataValues=null!==(p=n.metadataValues)&&void 0!==p?p:null,_.metadataOrderKeyFilter=null!==(m=n.metadataOrderKeyFilter)&&void 0!==m?m:null,_.metadataValueStartsWith=null!==(f=n.metadataValueStartsWith)&&void 0!==f?f:null,_.order=null!==(v=n.order)&&void 0!==v?v:fe.CHRONOLOGICAL,_}return f(r,t),r.prototype._validate=function(){return t.prototype._validate.call(this)&&F("boolean",this.includeEmpty)&&F("boolean",this.includeFrozen)&&F("boolean",this.includeMetaData)&&F("string",this.channelNameContainsFilter,!0)&&M("string",this.channelUrlsFilter,!0)&&M("string",this.customTypesFilter,!0)&&F("string",this.customTypeStartsWithFilter,!0)&&E(we,this.membershipFilter)&&E(me,this.superChannelFilter)&&E(fe,this.order)&&F("string",this.metadataOrderKeyFilter,!0)&&F("string",this.metadataKey,!0)&&M("string",this.metadataValues,!0)&&F("string",this.metadataValueStartsWith,!0)},r.prototype.next=function(){return e(this,void 0,void 0,(function(){var e,t,r,i,o,u,l,h,c;return n(this,(function(n){switch(n.label){case 0:return this._validate()?this._isLoading?[3,3]:(e=[],this._hasNext?(this._isLoading=!0,t=a.of(this._iid),r=t.requestQueue,i=t.dispatcher,o=new Ee(p(p({},this),{token:this._token})),[4,r.send(o)]):[3,2]):[3,5];case 1:return u=n.sent(),l=u.as(Te),h=l.channels,c=l.token,this._token=c,this._hasNext=!!c,i.dispatch(new ve({channels:h,source:re.REQUEST_CHANNEL})),this._isLoading=!1,[2,h];case 2:return[2,e];case 3:throw s.queryInProgress;case 4:return[3,6];case 5:throw s.invalidParameters;case 6:return[2]}}))}))},r}(T),Ne=function(e){function t(t){var n=this,a=t.token,r=t.limit,i=t.order,s=t.reverse,o=t.channelUrl,u=t.messageTypeFilter,l=t.scheduledStatus;return(n=e.call(this)||this).method=y.GET,n.path="".concat(N),n.params=b({limit:r,reverse:s,channel_url:o,order:i,status:l}),a&&(n.params.token=a),u&&(n.params.message_type_filter=u),n}return f(t,e),t}(w),Pe=function(e){function t(t,n){var a=e.call(this,t,n)||this;a.token=null,a.scheduledMessages=[];var r=n.next,i=n.scheduled_messages;return a.token=r,a.scheduledMessages=i.map((function(e){return P(t,e)})),a}return f(t,e),t}(k),Ae=function(t){function r(e,n){var a,r,i,s,o,u=this;return(u=t.call(this,e,n)||this).channelUrl=null,u.order=null,u.reverse=!1,u.scheduledStatus=null,u.messageTypeFilter=j.ALL,u.channelUrl=null!==(a=n.channelUrl)&&void 0!==a?a:null,u.order=null!==(r=n.order)&&void 0!==r?r:null,u.reverse=null!==(i=n.reverse)&&void 0!==i&&i,u.scheduledStatus=null!==(s=n.scheduledStatus)&&void 0!==s?s:null,u.messageTypeFilter=null!==(o=n.messageTypeFilter)&&void 0!==o?o:j.ALL,u}return f(r,t),r.prototype._validate=function(){return t.prototype._validate.call(this)&&F("string",this.channelUrl,!0)&&(E(_e,this.order)||null===this.order)&&F("boolean",this.reverse)&&(M(D,this.scheduledStatus)||null===this.scheduledStatus)&&E(j,this.messageTypeFilter)},r.prototype.next=function(){return e(this,void 0,void 0,(function(){var e,t,r,i,o,u;return n(this,(function(n){switch(n.label){case 0:return this._validate()?this._isLoading?[3,3]:this._hasNext?(this._isLoading=!0,e=a.of(this._iid).requestQueue,t=new Ne(p(p({},this),{token:this._token})),[4,e.send(t)]):[3,2]:[3,5];case 1:return r=n.sent(),i=r.as(Pe),o=i.scheduledMessages,u=i.token,this._token=u,this._hasNext=!!u,this._isLoading=!1,[2,o];case 2:return[2,[]];case 3:throw s.queryInProgress;case 4:return[3,6];case 5:throw s.invalidParameters;case 6:return[2]}}))}))},r}(T),Ue=function(t){function a(){var e=null!==t&&t.apply(this,arguments)||this;return e.name="groupChannel",e}return f(a,t),a.prototype.init=function(e,n){var a=n.sdkState,r=n.dispatcher,i=n.sessionManager,s=n.requestQueue,o=n.logger,u=n.cacheContext;t.prototype.init.call(this,e,{sdkState:a,dispatcher:r,sessionManager:i,requestQueue:s,logger:o,cacheContext:u}),this._manager=new ne(e,{sdkState:a,cacheContext:u,dispatcher:r,sessionManager:i,requestQueue:s,logger:o})},a.prototype.createGroupChannelCollection=function(e){return void 0===e&&(e={}),new Se(this._iid,e)},a.prototype.createMyGroupChannelListQuery=function(e){return void 0===e&&(e={}),new ye(this._iid,e)},a.prototype.createPublicGroupChannelListQuery=function(e){return void 0===e&&(e={}),new xe(this._iid,e)},a.prototype.createScheduledMessageListQuery=function(e){return void 0===e&&(e={}),new Ae(this._iid,e)},a.prototype.addGroupChannelHandler=function(e,t){q(F("string",e)&&t instanceof Ge).throw(s.invalidParameters),this._manager.addHandler(e,t)},a.prototype.removeGroupChannelHandler=function(e){q(F("string",e)).throw(s.invalidParameters),this._manager.removeHandler(e)},a.prototype.removeAllGroupChannelHandlers=function(){this._manager.clearHandler()},a.prototype.buildGroupChannelFromSerializedData=function(e){return this._manager.buildGroupChannelFromSerializedData(e)},a.prototype.buildGroupChannelListQueryFromSerializedData=function(e){return this._manager.buildGroupChannelListQueryFromSerializedData(e)},a.prototype.buildMemberFromSerializedData=function(e){return this._manager.buildMemberFromSerializedData(e)},a.prototype.getChannel=function(t){return e(this,void 0,void 0,(function(){return n(this,(function(e){return q(F("string",t)).throw(s.invalidParameters),[2,this._manager.getChannel(t)]}))}))},a.prototype.getChannelWithoutCache=function(t){return e(this,void 0,void 0,(function(){return n(this,(function(e){return q(F("string",t)).throw(s.invalidParameters),[2,this._manager.getChannelWithoutCache(t)]}))}))},a.prototype.getMyGroupChannelChangeLogsByToken=function(t,a){return e(this,void 0,void 0,(function(){return n(this,(function(e){switch(e.label){case 0:return q(F("string",t)&&a instanceof se&&a.validate()).throw(s.invalidParameters),[4,this._manager.getMyGroupChannelChangeLogs(t,a)];case 1:return[2,e.sent()]}}))}))},a.prototype.getMyGroupChannelChangeLogsByTimestamp=function(t,a){return e(this,void 0,void 0,(function(){return n(this,(function(e){switch(e.label){case 0:return q(F("number",t)&&a instanceof se&&a.validate()).throw(s.invalidParameters),[4,this._manager.getMyGroupChannelChangeLogs(t,a)];case 1:return[2,e.sent()]}}))}))},a.prototype.getGroupChannelCount=function(t){return e(this,void 0,void 0,(function(){return n(this,(function(e){return q(t instanceof ge&&t.validate()).throw(s.invalidParameters),[2,this._manager.getGroupChannelCount(t)]}))}))},a.prototype.createChannel=function(t){return e(this,void 0,void 0,(function(){return n(this,(function(e){return q(t instanceof Ce&&t.validate()).throw(s.invalidParameters),[2,this._manager.createChannel(t)]}))}))},a.prototype.createDistinctChannelIfNotExist=function(t){return e(this,void 0,void 0,(function(){return n(this,(function(e){return q(t instanceof Ce&&t.validate()).throw(s.invalidParameters),t&&(t.isDistinct=!0),[2,this.createChannel(t)]}))}))},a.prototype.createChannelWithUserIds=function(t,a,r,i,s,o){return void 0===a&&(a=!1),void 0===r&&(r=null),void 0===i&&(i=null),void 0===s&&(s=""),void 0===o&&(o=""),e(this,void 0,void 0,(function(){var e;return n(this,(function(n){return(e=new Ce).addUserIds(t),e.isDistinct=a,e.name=r,e.data=s,e.customType=o,"string"==typeof i?e.coverUrl=i:e.coverImage=i,[2,this.createChannel(e)]}))}))},a.prototype.markAsReadAll=function(){return e(this,void 0,void 0,(function(){return n(this,(function(e){return this._manager.markAsReadAll(),[2]}))}))},a.prototype.markAsReadWithChannelUrls=function(t){return e(this,void 0,void 0,(function(){return n(this,(function(e){return q(M("string",t)).throw(s.invalidParameters),this._manager.markAsReadWithChannelUrls(t),[2]}))}))},a.prototype.markAsDelivered=function(t){return e(this,void 0,void 0,(function(){return n(this,(function(e){switch(e.label){case 0:return q(F("string",t)).throw(s.invalidParameters),[4,this.getChannel(t)];case 1:return[4,e.sent().markAsDelivered()];case 2:return e.sent(),[2]}}))}))},a}(ee);export{Se as GroupChannelCollection,Ge as GroupChannelHandler,Ue as GroupChannelModule,xe as PublicGroupChannelListQuery}; | ||
import{d as e,e as n,V as a,ae as r,af as i,S as s,q as o,o as l,p as h,F as c,J as d,j as p,a6 as m,_ as f,n as v,A as y,ab as g,g as b,h as w,k,a as F,b as M,c as E,B as T,t as N,ao as P,s as D,M as j,x as q,aY as ee}from"./__bundle-368767fc.js";export{ai as MessageEventSource}from"./__bundle-368767fc.js";import{r as te,s as ne,G as ae,t as re,T as ie,u as se,v as oe,w as ue,x as le,y as he,z as ce,A as de,B as pe,S as me,C as fe,E as ve,F as _e,H as ye,I as ge,J as Ce}from"./__bundle-083b498b.js";export{K as CountPreference,B as GroupChannel,u as GroupChannelChangeLogsParams,L as GroupChannelChangeLogsParamsProperties,I as GroupChannelCountParams,Q as GroupChannelCountParamsProperties,J as GroupChannelCreateParams,O as GroupChannelCreateParamsProperties,z as GroupChannelEventContext,t as GroupChannelEventSource,x as GroupChannelFilter,R as GroupChannelHideParams,V as GroupChannelHideParamsProperties,G as GroupChannelListOrder,H as GroupChannelListQuery,W as GroupChannelSearchField,X as GroupChannelUpdateParams,Y as GroupChannelUpdateParamsProperties,Z as HiddenChannelFilter,_ as HiddenState,$ as Member,a0 as MemberListOrder,a1 as MemberListQuery,a2 as MemberState,a3 as MemberStateFilter,a4 as MessageCollection,a5 as MessageCollectionInitHandler,a6 as MessageCollectionInitPolicy,a7 as MessageEventContext,a8 as MessageFilter,a9 as MutedState,aa as OperatorFilter,A as PublicChannelFilter,C as PublicGroupChannelListOrder,ab as QueryType,ac as ReadStatus,S as SuperChannelFilter,ad as UnreadChannelFilter,U as UnreadItemKey}from"./__bundle-083b498b.js";import{B as be}from"./__bundle-96ae73c1.js";import"./__bundle-72d7e125.js";var we,ke={},Fe=function(){function t(t){var r=t._iid,i=this;this._sync=null,this._metadata=null,this._iid=r;var u,h=a.of(this._iid),c=h.sdkState,d=h.logger;this._metadataKey=(u=c.userId,"sendbird:".concat(u,"@groupchannel/sync.meta"));var p=function(e){return"sendbird:".concat(e,"@groupchannel/sync")}(c.userId);this._sync=new te(p,(function(){return e(i,void 0,void 0,(function(){var e,t,a,r,i,u;return n(this,(function(n){switch(n.label){case 0:return e={hasNext:!0,nextToken:""},[4,this.loadMetadata()];case 1:if(n.sent(),d.debug("channel background sync from",this._metadata.token),this._metadata.completed)return[3,9];n.label=2;case 2:return n.trys.push([2,5,,8]),[4,ne.of(this._iid).getMyGroupChannels(this._metadata.token,{includeEmpty:!0,order:ae.CHRONOLOGICAL},100,re.SYNC_CHANNEL_BACKGROUND)];case 3:return t=n.sent(),a=t.channels,r=t.token,e.hasNext=a.length>=100&&!!r,e.nextToken=r,this._metadata.token=r,(u=this._metadata.range).extends.apply(u,o([],l(a.map((function(e){return e.createdAt}))),!1)),this._metadata.completed=!e.hasNext,d.debug("channel background sync progress",e),[4,this.saveMetadata()];case 4:return n.sent(),[3,8];case 5:return(i=n.sent())instanceof s&&i.isInvalidTokenError?[4,this.clearMetaData()]:[3,7];case 6:n.sent(),n.label=7;case 7:return[3,8];case 8:return[3,10];case 9:e.hasNext=!1,e.nextToken="",n.label=10;case 10:return[2,e]}}))}))}))}return t.of=function(e){if(!ke[e]){var n=ke[e]=new t({_iid:e});a.of(e).dispatcher.on((function(e){if(e instanceof r)if(e.stateType===i.CONNECTED)n.resume();else n.pause()}))}return ke[e]},Object.defineProperty(t.prototype,"range",{get:function(){var e;return null===(e=this._metadata)||void 0===e?void 0:e.range},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"completed",{get:function(){var e;return!!(null===(e=this._metadata)||void 0===e?void 0:e.completed)},enumerable:!1,configurable:!0}),t.prototype.loadMetadata=function(){return e(this,void 0,void 0,(function(){var e;return n(this,(function(t){switch(t.label){case 0:return this._metadata?[3,2]:[4,a.of(this._iid).cacheContext.store.get(this._metadataKey)];case 1:e=t.sent(),this._metadata={token:e?e.token:"",range:new ie(e?e.range:{top:Number.MAX_SAFE_INTEGER,bottom:0}),completed:!!e&&e.completed},t.label=2;case 2:return[2]}}))}))},t.prototype.saveMetadata=function(){return e(this,void 0,void 0,(function(){return n(this,(function(e){switch(e.label){case 0:return this._metadata?[4,a.of(this._iid).cacheContext.store.set({key:this._metadataKey,value:this._metadata,generation:1})]:[3,2];case 1:e.sent(),e.label=2;case 2:return[2]}}))}))},t.prototype.clearMetaData=function(){return e(this,void 0,void 0,(function(){return n(this,(function(e){switch(e.label){case 0:return[4,a.of(this._iid).cacheContext.store.remove(this._metadataKey)];case 1:return e.sent(),[2]}}))}))},t.prototype.resume=function(){var e,t;a.of(this._iid).logger.debug("channel background sync resume()"),this._sync.start(null!==(t=null===(e=this._metadata)||void 0===e?void 0:e.token)&&void 0!==t?t:"")},t.prototype.pause=function(){a.of(this._iid).logger.debug("channel background sync stop()"),this._sync.stop()},t}(),Me={},Le=function(){function t(t){var r=t._iid,i=this;this._sync=null,this._metadataKey=null,this._metadata=null,this._iid=r;var o,u=a.of(this._iid).sdkState;this._metadataKey=(o=u.userId,"sendbird:".concat(o,"@groupchannel/changelogs.meta"));var l=function(e){return"sendbird:".concat(e,"@groupchannel/changelogs")}(u.userId);this._sync=new te(l,(function(){return e(i,void 0,void 0,(function(){var e,t,a,r,i;return n(this,(function(n){switch(n.label){case 0:return e={hasNext:!0,nextToken:0},[4,this.loadMetadata()];case 1:n.sent(),n.label=2;case 2:return n.trys.push([2,5,,8]),[4,ne.of(this._iid).getMyGroupChannelChangeLogs(this._metadata.token,new se,re.SYNC_CHANNEL_CHANGELOGS)];case 3:return t=n.sent(),a=t.hasMore,r=t.token,e.hasNext=a,e.nextToken=r,this._metadata.token=r,[4,this.saveMetadata()];case 4:return n.sent(),[3,8];case 5:return(i=n.sent())instanceof s&&i.isInvalidTokenError?[4,this.clearMetadata()]:[3,7];case 6:n.sent(),n.label=7;case 7:return e.hasNext=!1,e.nextToken="",[3,8];case 8:return[2,e]}}))}))}))}return t.of=function(e){if(!Me[e]){var n=Me[e]=new t({_iid:e});a.of(e).dispatcher.on((function(e){if(e instanceof r)if(e.stateType===i.CONNECTED)n.resume();else n.pause()}))}return Me[e]},t.prototype.loadMetadata=function(){return e(this,void 0,void 0,(function(){var e;return n(this,(function(t){switch(t.label){case 0:return this._metadata?[3,2]:[4,a.of(this._iid).cacheContext.store.get(this._metadataKey)];case 1:e=t.sent(),this._metadata={token:e?e.token:""},t.label=2;case 2:return[2]}}))}))},t.prototype.saveMetadata=function(){return e(this,void 0,void 0,(function(){return n(this,(function(e){switch(e.label){case 0:return this._metadata?[4,a.of(this._iid).cacheContext.store.set({key:this._metadataKey,value:this._metadata,generation:1})]:[3,2];case 1:e.sent(),e.label=2;case 2:return[2]}}))}))},t.prototype.clearMetadata=function(){return e(this,void 0,void 0,(function(){return n(this,(function(e){return a.of(this._iid).cacheContext.store.remove(this._metadataKey),[2]}))}))},t.prototype.resume=function(){this._sync.start(0)},t.prototype.pause=function(){this._sync.stop()},t}(),Se=function(){function t(e,t){var n=t.filter,r=t.order,i=t.limit,s=this;this.channels=[],this._iid=e,this._key="gcc-".concat(d()),this.filter=null!=n?n:new le,this.order=null!=r?r:ae.LATEST_LAST_MESSAGE,this._hasMore=!0,this._token="",this._limit=null!=i?i:he,Fe.of(e).resume(),Le.of(e).resume();var o=a.of(this._iid).sdkState;ne.of(this._iid).subscribeGroupChannelEvent(this._key,{onUpdate:function(e,t){var n=e.filter((function(e){return s.filter.match(e,o.userId)})),a=e.filter((function(e){return!s.filter.match(e,o.userId)})).map((function(e){return e.url}));n.length>0&&s._addChannelsToView(n,t),a.length>0&&s._removeChannelsFromView(a,t)},onRemove:function(e,t){s._removeChannelsFromView(e,t)}})}return Object.defineProperty(t.prototype,"hasMore",{get:function(){return this._hasMore},enumerable:!1,configurable:!0}),t.prototype.setGroupChannelCollectionHandler=function(e){this._handler=e},t.prototype._addChannelsToView=function(t,a,r){var i,s,o=this;void 0===r&&(r=!1);var u=[],l=[];try{for(var d=h(t),p=d.next();!p.done;p=d.next()){var m=p.value,f=oe(this.channels,m,this.order),v=f.place;if(f.contains)switch(l.push(m),a){case re.EVENT_CHANNEL_UPDATED:case re.EVENT_MESSAGE_RECEIVED:this.channels.splice(v,1);var _=oe(this.channels,m,this.order).place;this.channels.splice(_,0,m);break;default:this.channels[v]=m}else if(v===this.channels.length){var y=Fe.of(this._iid);(r||y.completed)&&(u.push(m),this.channels.push(m))}else u.push(m),this.channels.splice(v,0,m)}}catch(e){i={error:e}}finally{try{p&&!p.done&&(s=d.return)&&s.call(d)}finally{if(i)throw i.error}}ue(a)&&c((function(){return e(o,void 0,void 0,(function(){var e;return n(this,(function(t){return e=new ce(a),u.length>0&&this._handler.onChannelsAdded(e,u),l.length>0&&this._handler.onChannelsUpdated(e,l),[2]}))}))}))},t.prototype._removeChannelsFromView=function(t,a){var r,i,s=this,o=[],u=function(e){var t=l.channels.findIndex((function(t){return t.url===e}));t>=0&&(o.push(l.channels[t].url),l.channels.splice(t,1))},l=this;try{for(var d=h(t),p=d.next();!p.done;p=d.next()){u(p.value)}}catch(e){r={error:e}}finally{try{p&&!p.done&&(i=d.return)&&i.call(d)}finally{if(r)throw r.error}}return ue(a)&&o.length>0&&c((function(){return e(s,void 0,void 0,(function(){var e;return n(this,(function(t){return e=new ce(a),this._handler.onChannelsDeleted(e,o),[2]}))}))})),o},t.prototype._getLocalChannels=function(){return e(this,void 0,void 0,(function(){return n(this,(function(e){switch(e.label){case 0:return[4,ne.of(this._iid).getChannelsFromCache(this._token,this.filter,this.order)];case 1:return[2,e.sent()]}}))}))},t.prototype._getRemoteChannels=function(){return e(this,void 0,void 0,(function(){var e,t,a;return n(this,(function(n){switch(n.label){case 0:return[4,ne.of(this._iid).getMyGroupChannels(this._token,p(p({},this.filter),{order:this.order}),this._limit)];case 1:return e=n.sent(),t=e.channels,a=e.token,this._token=a,[2,t]}}))}))},t.prototype.loadMore=function(){return e(this,void 0,void 0,(function(){var t,a=this;return n(this,(function(r){switch(r.label){case 0:return this._hasMore?(t=[],[4,m((function(){return e(a,void 0,void 0,(function(){return n(this,(function(e){switch(e.label){case 0:return[4,this._getLocalChannels()];case 1:return t=e.sent(),[2]}}))}))}))]):[3,3];case 1:return r.sent(),[4,m((function(){return e(a,void 0,void 0,(function(){return n(this,(function(e){switch(e.label){case 0:return[4,this._getRemoteChannels()];case 1:return t=e.sent(),[2]}}))}))}))];case 2:return r.sent(),this._addChannelsToView(t,re.REQUEST_CHANNEL,!0),[2,t];case 3:return[2,[]]}}))}))},t.prototype.dispose=function(){ne.of(this._iid).unsubscribeGroupChannelEvent(this._key)},t}(),Ge=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 f(t,e),t}(function(e){function t(){var t=null!==e&&e.apply(this,arguments)||this;return t.onUserJoined=v,t.onUserLeft=v,t.onUserReceivedInvitation=v,t.onUserDeclinedInvitation=v,t.onChannelHidden=v,t.onUnreadMemberStatusUpdated=v,t.onUndeliveredMemberStatusUpdated=v,t.onTypingStatusUpdated=v,t}return f(t,e),t}(be)),Ee=function(e){function t(t){var n=this,a=t.token,r=t.limit,i=t.order,s=t.includeEmpty,o=t.membershipFilter,u=t.channelNameContainsFilter,l=t.channelUrlsFilter,h=t.customTypesFilter,c=t.customTypeStartsWithFilter,d=t.superChannelFilter,p=t.metadataOrderKeyFilter,m=t.metadataKey,f=t.metadataValues,v=t.metadataValueStartsWith,_=t.includeFrozen,C=t.includeMetaData;return(n=e.call(this)||this).method=y.GET,n.path=g,n.params=b({token:a,limit:r,order:i,show_member:!0,show_read_receipt:!0,show_delivery_receipt:!0,show_empty:s,public_mode:de.PUBLIC,public_membership_mode:o,name_contains:u,channel_urls:l,custom_types:h,custom_type_startswith:c,super_mode:d,metadata_order_key:p,metadata_key:m,metadata_values:f,metadata_value_startswith:v,show_frozen:_,show_metadata:C}),n}return f(t,e),t}(w),Te=function(e){function t(t,n){var a=e.call(this,t,n)||this;a.token=null,a.channels=[],a.ts=null;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 pe(t,e)}))),a.ts="number"==typeof s?s:null,a}return f(t,e),t}(k);!function(e){e.ALL="all",e.JOINED="joined"}(we||(we={}));var xe=function(t){function r(e,n){var a,r,i,s,o,u,l,h,c,d,p,m,f,v,_=this;return(_=t.call(this,e,n)||this).includeEmpty=!1,_.includeFrozen=!0,_.includeMetaData=!0,_.channelUrlsFilter=null,_.customTypesFilter=null,_.customTypeStartsWithFilter=null,_.nicknameContainsFilter=null,_.channelNameContainsFilter=null,_.membershipFilter=we.ALL,_.superChannelFilter=me.ALL,_.metadataKey=null,_.metadataValues=null,_.metadataOrderKeyFilter=null,_.metadataValueStartsWith=null,_.order=fe.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!==(u=n.customTypeStartsWithFilter)&&void 0!==u?u:null,_.channelNameContainsFilter=null!==(l=n.channelNameContainsFilter)&&void 0!==l?l:null,_.membershipFilter=null!==(h=n.membershipFilter)&&void 0!==h?h:we.ALL,_.superChannelFilter=null!==(c=n.superChannelFilter)&&void 0!==c?c:me.ALL,_.metadataKey=null!==(d=n.metadataKey)&&void 0!==d?d:null,_.metadataValues=null!==(p=n.metadataValues)&&void 0!==p?p:null,_.metadataOrderKeyFilter=null!==(m=n.metadataOrderKeyFilter)&&void 0!==m?m:null,_.metadataValueStartsWith=null!==(f=n.metadataValueStartsWith)&&void 0!==f?f:null,_.order=null!==(v=n.order)&&void 0!==v?v:fe.CHRONOLOGICAL,_}return f(r,t),r.prototype._validate=function(){return t.prototype._validate.call(this)&&F("boolean",this.includeEmpty)&&F("boolean",this.includeFrozen)&&F("boolean",this.includeMetaData)&&F("string",this.channelNameContainsFilter,!0)&&M("string",this.channelUrlsFilter,!0)&&M("string",this.customTypesFilter,!0)&&F("string",this.customTypeStartsWithFilter,!0)&&E(we,this.membershipFilter)&&E(me,this.superChannelFilter)&&E(fe,this.order)&&F("string",this.metadataOrderKeyFilter,!0)&&F("string",this.metadataKey,!0)&&M("string",this.metadataValues,!0)&&F("string",this.metadataValueStartsWith,!0)},r.prototype.next=function(){return e(this,void 0,void 0,(function(){var e,t,r,i,o,u,l,h,c;return n(this,(function(n){switch(n.label){case 0:return this._validate()?this._isLoading?[3,3]:(e=[],this._hasNext?(this._isLoading=!0,t=a.of(this._iid),r=t.requestQueue,i=t.dispatcher,o=new Ee(p(p({},this),{token:this._token})),[4,r.send(o)]):[3,2]):[3,5];case 1:return u=n.sent(),l=u.as(Te),h=l.channels,c=l.token,this._token=c,this._hasNext=!!c,i.dispatch(new ve({channels:h,source:re.REQUEST_CHANNEL})),this._isLoading=!1,[2,h];case 2:return[2,e];case 3:throw s.queryInProgress;case 4:return[3,6];case 5:throw s.invalidParameters;case 6:return[2]}}))}))},r}(T),Ne=function(e){function t(t){var n=this,a=t.token,r=t.limit,i=t.order,s=t.reverse,o=t.channelUrl,u=t.messageTypeFilter,l=t.scheduledStatus;return(n=e.call(this)||this).method=y.GET,n.path="".concat(N),n.params=b({limit:r,reverse:s,channel_url:o,order:i,status:l}),a&&(n.params.token=a),u&&(n.params.message_type_filter=u),n}return f(t,e),t}(w),Pe=function(e){function t(t,n){var a=e.call(this,t,n)||this;a.token=null,a.scheduledMessages=[];var r=n.next,i=n.scheduled_messages;return a.token=r,a.scheduledMessages=i.map((function(e){return P(t,e)})),a}return f(t,e),t}(k),Ae=function(t){function r(e,n){var a,r,i,s,o,u=this;return(u=t.call(this,e,n)||this).channelUrl=null,u.order=null,u.reverse=!1,u.scheduledStatus=null,u.messageTypeFilter=j.ALL,u.channelUrl=null!==(a=n.channelUrl)&&void 0!==a?a:null,u.order=null!==(r=n.order)&&void 0!==r?r:null,u.reverse=null!==(i=n.reverse)&&void 0!==i&&i,u.scheduledStatus=null!==(s=n.scheduledStatus)&&void 0!==s?s:null,u.messageTypeFilter=null!==(o=n.messageTypeFilter)&&void 0!==o?o:j.ALL,u}return f(r,t),r.prototype._validate=function(){return t.prototype._validate.call(this)&&F("string",this.channelUrl,!0)&&(E(_e,this.order)||null===this.order)&&F("boolean",this.reverse)&&(M(D,this.scheduledStatus)||null===this.scheduledStatus)&&E(j,this.messageTypeFilter)},r.prototype.next=function(){return e(this,void 0,void 0,(function(){var e,t,r,i,o,u;return n(this,(function(n){switch(n.label){case 0:return this._validate()?this._isLoading?[3,3]:this._hasNext?(this._isLoading=!0,e=a.of(this._iid).requestQueue,t=new Ne(p(p({},this),{token:this._token})),[4,e.send(t)]):[3,2]:[3,5];case 1:return r=n.sent(),i=r.as(Pe),o=i.scheduledMessages,u=i.token,this._token=u,this._hasNext=!!u,this._isLoading=!1,[2,o];case 2:return[2,[]];case 3:throw s.queryInProgress;case 4:return[3,6];case 5:throw s.invalidParameters;case 6:return[2]}}))}))},r}(T),Ue=function(t){function a(){var e=null!==t&&t.apply(this,arguments)||this;return e.name="groupChannel",e}return f(a,t),a.prototype.init=function(e,n){var a=n.sdkState,r=n.dispatcher,i=n.sessionManager,s=n.requestQueue,o=n.logger,u=n.cacheContext;t.prototype.init.call(this,e,{sdkState:a,dispatcher:r,sessionManager:i,requestQueue:s,logger:o,cacheContext:u}),this._manager=new ne(e,{sdkState:a,cacheContext:u,dispatcher:r,sessionManager:i,requestQueue:s,logger:o})},a.prototype.createGroupChannelCollection=function(e){return void 0===e&&(e={}),new Se(this._iid,e)},a.prototype.createMyGroupChannelListQuery=function(e){return void 0===e&&(e={}),new ye(this._iid,e)},a.prototype.createPublicGroupChannelListQuery=function(e){return void 0===e&&(e={}),new xe(this._iid,e)},a.prototype.createScheduledMessageListQuery=function(e){return void 0===e&&(e={}),new Ae(this._iid,e)},a.prototype.addGroupChannelHandler=function(e,t){q(F("string",e)&&t instanceof Ge).throw(s.invalidParameters),this._manager.addHandler(e,t)},a.prototype.removeGroupChannelHandler=function(e){q(F("string",e)).throw(s.invalidParameters),this._manager.removeHandler(e)},a.prototype.removeAllGroupChannelHandlers=function(){this._manager.clearHandler()},a.prototype.buildGroupChannelFromSerializedData=function(e){return this._manager.buildGroupChannelFromSerializedData(e)},a.prototype.buildGroupChannelListQueryFromSerializedData=function(e){return this._manager.buildGroupChannelListQueryFromSerializedData(e)},a.prototype.buildMemberFromSerializedData=function(e){return this._manager.buildMemberFromSerializedData(e)},a.prototype.getChannel=function(t){return e(this,void 0,void 0,(function(){return n(this,(function(e){return q(F("string",t)).throw(s.invalidParameters),[2,this._manager.getChannel(t)]}))}))},a.prototype.getChannelWithoutCache=function(t){return e(this,void 0,void 0,(function(){return n(this,(function(e){return q(F("string",t)).throw(s.invalidParameters),[2,this._manager.getChannelWithoutCache(t)]}))}))},a.prototype.getMyGroupChannelChangeLogsByToken=function(t,a){return e(this,void 0,void 0,(function(){return n(this,(function(e){switch(e.label){case 0:return q(F("string",t)&&a instanceof se&&a.validate()).throw(s.invalidParameters),[4,this._manager.getMyGroupChannelChangeLogs(t,a)];case 1:return[2,e.sent()]}}))}))},a.prototype.getMyGroupChannelChangeLogsByTimestamp=function(t,a){return e(this,void 0,void 0,(function(){return n(this,(function(e){switch(e.label){case 0:return q(F("number",t)&&a instanceof se&&a.validate()).throw(s.invalidParameters),[4,this._manager.getMyGroupChannelChangeLogs(t,a)];case 1:return[2,e.sent()]}}))}))},a.prototype.getGroupChannelCount=function(t){return e(this,void 0,void 0,(function(){return n(this,(function(e){return q(t instanceof ge&&t.validate()).throw(s.invalidParameters),[2,this._manager.getGroupChannelCount(t)]}))}))},a.prototype.createChannel=function(t){return e(this,void 0,void 0,(function(){return n(this,(function(e){return q(t instanceof Ce&&t.validate()).throw(s.invalidParameters),[2,this._manager.createChannel(t)]}))}))},a.prototype.createDistinctChannelIfNotExist=function(t){return e(this,void 0,void 0,(function(){return n(this,(function(e){return q(t instanceof Ce&&t.validate()).throw(s.invalidParameters),t&&(t.isDistinct=!0),[2,this.createChannel(t)]}))}))},a.prototype.createChannelWithUserIds=function(t,a,r,i,s,o){return void 0===a&&(a=!1),void 0===r&&(r=null),void 0===i&&(i=null),void 0===s&&(s=""),void 0===o&&(o=""),e(this,void 0,void 0,(function(){var e;return n(this,(function(n){return(e=new Ce).addUserIds(t),e.isDistinct=a,e.name=r,e.data=s,e.customType=o,"string"==typeof i?e.coverUrl=i:e.coverImage=i,[2,this.createChannel(e)]}))}))},a.prototype.markAsReadAll=function(){return e(this,void 0,void 0,(function(){return n(this,(function(e){return this._manager.markAsReadAll(),[2]}))}))},a.prototype.markAsReadWithChannelUrls=function(t){return e(this,void 0,void 0,(function(){return n(this,(function(e){return q(M("string",t)).throw(s.invalidParameters),this._manager.markAsReadWithChannelUrls(t),[2]}))}))},a.prototype.markAsDelivered=function(t){return e(this,void 0,void 0,(function(){return n(this,(function(e){switch(e.label){case 0:return q(F("string",t)).throw(s.invalidParameters),[4,this.getChannel(t)];case 1:return[4,e.sent().markAsDelivered()];case 2:return e.sent(),[2]}}))}))},a}(ee);export{Se as GroupChannelCollection,Ge as GroupChannelHandler,Ue as GroupChannelModule,xe as PublicGroupChannelListQuery}; |
@@ -0,1 +1,2 @@ | ||
export { | ||
@@ -2,0 +3,0 @@ ApplicationUserListQuery, |
@@ -1,1 +0,1 @@ | ||
export{aJ as AdminMessage,av as AppleCriticalAlertOptions,aX as BaseMessage,$ as FileMessage,a1 as FileMessageCreateParams,a$ as FileMessageCreateParamsProperties,aW as FileMessageUpdateParams,b0 as FileMessageUpdateParamsProperties,aG as MentionType,aU as MessageChangeLogsParams,b1 as MessageChangeLogsParamsProperties,aT as MessageListParams,b2 as MessageListParamsProperties,au as MessageMetaArray,K as MessageModule,aD as MessageRequestHandler,b3 as MessageRetrievalParams,b4 as MessageRetrievalParamsProperties,b5 as MessageSearchOrder,y as MessageSearchQuery,T as MessageType,M as MessageTypeFilter,b6 as OGImage,b7 as OGMetaData,aP as PreviousMessageListQuery,aH as PushNotificationDeliveryOption,b8 as Reaction,aL as ReactionEvent,b9 as ReactionEventOperation,Y as ReplyType,ba as ScheduledUserMessageParams,bb as ScheduledUserMessageParamsProperties,aQ as Sender,ah as SendingStatus,bc as ThreadInfo,aM as ThreadInfoUpdateEvent,bd as ThreadedMessageListParams,be as ThreadedMessageListParamsProperties,ay as Thumbnail,Z as UserMessage,a2 as UserMessageCreateParams,as as UserMessageCreateParamsProperties,aA as UserMessageUpdateParams,aB as UserMessageUpdateParamsProperties}from"./__bundle-c2d86ac8.js"; | ||
export{aJ as AdminMessage,av as AppleCriticalAlertOptions,aX as BaseMessage,$ as FileMessage,a1 as FileMessageCreateParams,a$ as FileMessageCreateParamsProperties,aW as FileMessageUpdateParams,b0 as FileMessageUpdateParamsProperties,aG as MentionType,aU as MessageChangeLogsParams,b1 as MessageChangeLogsParamsProperties,aT as MessageListParams,b2 as MessageListParamsProperties,au as MessageMetaArray,K as MessageModule,aD as MessageRequestHandler,b3 as MessageRetrievalParams,b4 as MessageRetrievalParamsProperties,b5 as MessageSearchOrder,y as MessageSearchQuery,T as MessageType,M as MessageTypeFilter,b6 as OGImage,b7 as OGMetaData,aP as PreviousMessageListQuery,aH as PushNotificationDeliveryOption,b8 as Reaction,aL as ReactionEvent,b9 as ReactionEventOperation,Y as ReplyType,ba as ScheduledUserMessageParams,bb as ScheduledUserMessageParamsProperties,aQ as Sender,ah as SendingStatus,bc as ThreadInfo,aM as ThreadInfoUpdateEvent,bd as ThreadedMessageListParams,be as ThreadedMessageListParamsProperties,ay as Thumbnail,Z as UserMessage,a2 as UserMessageCreateParams,as as UserMessageCreateParamsProperties,aA as UserMessageUpdateParams,aB as UserMessageUpdateParamsProperties}from"./__bundle-368767fc.js"; |
@@ -1,1 +0,1 @@ | ||
import{_ as n,d as e,e as t,I as r,b as a,a as i,i as s,A as o,aZ as u,a_ as c,h as l,k as h,ac as d,U as p,W as f,ae as v,af as C,p as _,z as y,ak as m,F as g,L as U,al as E,x as w,S as T,ar as N,V as H,j as I,ad as M,g as O,a0 as b,n as x,B as D,aY as A}from"./__bundle-c2d86ac8.js";import{U as P,e as L,F as k,h as R,g as F,f as S,i as q,j as Q,k as z,C as K,l as W,T as j,m as B,D as G,n as X,o as Z,p as V,q as Y,A as $,a as J}from"./__bundle-e1c90263.js";import{B as nn}from"./__bundle-404df74c.js";var en=function(r){function a(){var n=null!==r&&r.apply(this,arguments)||this;return n._channels=new Map,n._enteredChannelUrls=[],n}return n(a,r),Object.defineProperty(a.prototype,"enteredChannels",{get:function(){var n=this;return this._enteredChannelUrls.map((function(e){return n._channels.get(e)})).filter((function(n){return null!==n}))},enumerable:!1,configurable:!0}),a.prototype.isEnteredChannel=function(n){return this._enteredChannelUrls.includes(n)},a.prototype.enter=function(n){this._enteredChannelUrls.indexOf(n)<0&&this._enteredChannelUrls.push(n)},a.prototype.exit=function(n){var e=this._enteredChannelUrls.indexOf(n);e>=0&&this._enteredChannelUrls.splice(e,1)},a.prototype.exitAll=function(){this._enteredChannelUrls=[]},a.prototype.get=function(n){var r;return e(this,void 0,void 0,(function(){return t(this,(function(e){return[2,null!==(r=this._channels.get(n))&&void 0!==r?r:null]}))}))},a.prototype.upsert=function(n){return e(this,void 0,void 0,(function(){var e=this;return t(this,(function(t){return n.forEach((function(n){if(e._channels.has(n.url)){var t=e._channels.get(n.url);Object.assign(t,n)}else e._channels.set(n.url,n)})),[2]}))}))},a.prototype.remove=function(n){return e(this,void 0,void 0,(function(){return t(this,(function(e){return this._channels.delete(n),this.exit(n),[2]}))}))},a.prototype.clear=function(){return e(this,void 0,void 0,(function(){return t(this,(function(n){return this._channels.clear(),this._enteredChannelUrls=[],[2]}))}))},a}(r),tn=function(){this.channelUrl=null,this.name=null,this.coverUrlOrImage=null,this.data=null,this.customType=null,this.operatorUserIds=null},rn=function(e){function t(n){var t=e.call(this)||this;if(n)for(var r in n)t.hasOwnProperty(r)&&(t[r]=n[r]);return t}return n(t,e),t.prototype.validate=function(){return a("string",this.operatorUserIds,!0)&&(i("string",this.coverUrlOrImage)||s(this.coverUrlOrImage)||null===this.coverUrlOrImage)&&i("string",this.name,!0)&&i("string",this.data,!0)&&i("string",this.customType,!0)&&(i("string",this.channelUrl)&&/^\w+$/.test(this.channelUrl)||null===this.channelUrl)},t}(tn),an=function(e){function t(n){var t=n.channelUrl,r=n.isInternalCall,a=e.call(this)||this;return a.method=o.GET,a.path="".concat(r?u:c,"/").concat(encodeURIComponent(t)),a}return n(t,e),t}(l),sn=function(e){function t(n,t){var r=e.call(this,n,t)||this;return r.channel=null,r.channel=new En(n,t),r}return n(t,e),t}(h),on=function(e){function t(n){var t=this,r=n.channelUrl,a=n.coverUrlOrImage,u=n.name,l=n.data,h=n.customType,d=n.operatorUserIds;return(t=e.call(this)||this).method=o.POST,t.path=c,t.params={channel_url:r,cover_url:i("string",a)?a:null,cover_file:s(a)?a:null,name:u,data:l,custom_type:h,operators:d},t}return n(t,e),t}(l);!function(e){function t(n,t){var r=e.call(this,n,t)||this;return r.channel=new En(n,t),r}n(t,e)}(h);var un=function(e){function t(n){var t=n.channelUrl;return e.call(this,{code:"ENTR",payload:{channel_url:t},ackRequired:!0})||this}return n(t,e),t}(d),cn=function(e){function t(n,t,r){var a,i,s=this;return s=e.call(this,n,"ENTR",r)||this,r.data&&(s.participantCount=null!==(a=r.data.participant_count)&&void 0!==a?a:0,s.user=new p(n,r.data),s.ts=null!==(i=r.data.edge_ts)&&void 0!==i?i:0),s}return n(t,e),t}(f),ln=function(e){function t(n){var t=n.channelUrl;return e.call(this,{code:"EXIT",payload:{channel_url:t},ackRequired:!0})||this}return n(t,e),t}(d),hn=function(e){function t(n,t,r){var a,i,s=this;return s=e.call(this,n,"EXIT",r)||this,r.data&&(s.participantCount=null!==(a=r.data.participant_count)&&void 0!==a?a:0,s.user=new p(n,r.data),s.ts=null!==(i=r.data.edge_ts)&&void 0!==i?i:0),s}return n(t,e),t}(f),dn={},pn=function(){function n(n,e){var t=e.sdkState,r=e.dispatcher,a=e.requestQueue,i=this;this._sdkState=t,this._requestQueue=a,this._dispatcher=r,this._openChannelCache=new en(n),this._openChannelHandlers=new Map,this._dispatcher.on((function(n){var e,t;if(n instanceof f)i._handleEvent(n);else if(n instanceof v&&n.stateType===C.CONNECTED){var r=i._openChannelCache.enteredChannels;try{for(var a=_(r),s=a.next();!s.done;s=a.next()){s.value.enter()}}catch(n){e={error:n}}finally{try{s&&!s.done&&(t=a.return)&&t.call(a)}finally{if(e)throw e.error}}}})),dn[n]=this}return n.of=function(n){return dn[n]},n.prototype.buildOpenChannelFromSerializedData=function(n){var e=y(n);return new En(e._iid,En.payloadify(e))},n.prototype.getChannelFromCache=function(n){return e(this,void 0,void 0,(function(){return t(this,(function(e){switch(e.label){case 0:return[4,this._openChannelCache.get(n)];case 1:return[2,e.sent()]}}))}))},n.prototype.upsertChannelsToCache=function(n){return e(this,void 0,void 0,(function(){return t(this,(function(e){switch(e.label){case 0:return[4,this._openChannelCache.upsert(n)];case 1:return e.sent(),[2]}}))}))},n.prototype.removeChannelsFromCache=function(n){return e(this,void 0,void 0,(function(){var e,r,a,i,s,o;return t(this,(function(t){switch(t.label){case 0:t.trys.push([0,5,6,7]),e=_(n),r=e.next(),t.label=1;case 1:return r.done?[3,4]:(a=r.value,[4,this._openChannelCache.remove(a)]);case 2:t.sent(),t.label=3;case 3:return r=e.next(),[3,1];case 4:return[3,7];case 5:return i=t.sent(),s={error:i},[3,7];case 6:try{r&&!r.done&&(o=e.return)&&o.call(e)}finally{if(s)throw s.error}return[7];case 7:return[2]}}))}))},n.prototype.setEnteredToCache=function(n){this._openChannelCache.enter(n.url)},n.prototype.setExitedToCache=function(n){this._openChannelCache.exit(n.url)},n.prototype._handleEvent=function(n){return e(this,void 0,void 0,(function(){var r,a,i,s,o,u,c,l,h,d,p,f,v,C,y,w,T,N,H,I,M,O,b,x,D,A,J,nn,en,tn,rn,an,sn,on,un,ln,dn,pn,fn,vn,Cn,_n,yn,mn,gn,Un,En,wn,Tn,Nn,Hn,In,Mn,On,bn,xn,Dn,An,Pn,Ln=this;return t(this,(function(kn){switch(kn.label){case 0:switch(kn.trys.push([0,51,,52]),n.code){case"MESG":case"FILE":case"ADMM":case"BRDM":return[3,1];case"MEDI":case"FEDI":case"AEDI":return[3,4];case"DELM":return[3,7];case"MRCT":return[3,10];case"MTHD":return[3,13];case"MCNT":return[3,16];case"SYEV":return[3,27]}return[3,50];case 1:return s=null,"MESG"===n.code?s=n.as(Y):"FILE"===n.code?s=n.as(E):"ADMM"!==n.code&&"BRDM"!=n.code||(s=n.as($)),s?(r=s.message,a=s.isMentioned,r.channelType!==U.OPEN?[3,3]:[4,this.getChannel(r.channelUrl,!0)]):[3,3];case 2:i=kn.sent(),g((function(){return e(Ln,void 0,void 0,(function(){var n,e,s,o,u;return t(this,(function(t){try{for(n=_(this._openChannelHandlers.values()),e=n.next();!e.done;e=n.next())s=e.value,this._openChannelCache.isEnteredChannel(i.url)&&s.onMessageReceived(i,r),a&&s.onMentionReceived(i,r)}catch(n){o={error:n}}finally{try{e&&!e.done&&(u=n.return)&&u.call(n)}finally{if(o)throw o.error}}return[2]}))}))})),kn.label=3;case 3:return[3,50];case 4:return s=null,"MEDI"===n.code?s=n.as(X):"FEDI"===n.code?s=n.as(Z):"AEDI"===n.code&&(s=n.as(V)),s?(o=s.message).channelType!==U.OPEN?[3,6]:[4,this.getChannel(o.channelUrl,!0)]:[3,6];case 5:u=kn.sent(),g((function(){return e(Ln,void 0,void 0,(function(){var n,e,r,a,i;return t(this,(function(t){try{for(n=_(this._openChannelHandlers.values()),e=n.next();!e.done;e=n.next())r=e.value,this._openChannelCache.isEnteredChannel(u.url)&&r.onMessageUpdated(u,o)}catch(n){a={error:n}}finally{try{e&&!e.done&&(i=n.return)&&i.call(n)}finally{if(a)throw a.error}}return[2]}))}))})),kn.label=6;case 6:return[3,50];case 7:return c=n.as(G),M=c.channelUrl,p=c.channelType,l=c.messageId,p!==U.OPEN?[3,9]:[4,this.getChannel(M,!0)];case 8:h=kn.sent(),g((function(){return e(Ln,void 0,void 0,(function(){var n,e,r,a,i;return t(this,(function(t){try{for(n=_(this._openChannelHandlers.values()),e=n.next();!e.done;e=n.next())r=e.value,this._openChannelCache.isEnteredChannel(h.url)&&r.onMessageDeleted(h,l)}catch(n){a={error:n}}finally{try{e&&!e.done&&(i=n.return)&&i.call(n)}finally{if(a)throw a.error}}return[2]}))}))})),kn.label=9;case 9:return[3,50];case 10:return d=n.as(B),M=d.channelUrl,p=d.channelType,f=d.event,p!==U.OPEN?[3,12]:[4,this.getChannel(M,!0)];case 11:v=kn.sent(),g((function(){return e(Ln,void 0,void 0,(function(){var n,e,r,a;return t(this,(function(t){try{for(n=_(this._openChannelHandlers.values()),e=n.next();!e.done;e=n.next())e.value.onReactionUpdated(v,f)}catch(n){r={error:n}}finally{try{e&&!e.done&&(a=n.return)&&a.call(n)}finally{if(r)throw r.error}}return[2]}))}))})),kn.label=12;case 12:return[3,50];case 13:return(C=n.as(j).event).channelType!==U.OPEN?[3,15]:[4,this.getChannel(C.channelUrl,!0)];case 14:y=kn.sent(),g((function(){return e(Ln,void 0,void 0,(function(){var n,e,r,a;return t(this,(function(t){try{for(n=_(this._openChannelHandlers.values()),e=n.next();!e.done;e=n.next())e.value.onThreadInfoUpdated(y,C)}catch(n){r={error:n}}finally{try{e&&!e.done&&(a=n.return)&&a.call(n)}finally{if(r)throw r.error}}return[2]}))}))})),kn.label=15;case 15:return[3,50];case 16:w=n.as(W).openChannelMemberCounts,T=[],kn.label=17;case 17:kn.trys.push([17,22,23,24]),N=_(w),H=N.next(),kn.label=18;case 18:return H.done?[3,21]:(I=H.value,M=I.channelUrl,an=I.participantCount,O=I.updatedAt,[4,this.getChannelFromCache(M)]);case 19:(b=kn.sent())&&b._updateParticipantCount(an,O)&&T.push(b),kn.label=20;case 20:return H=N.next(),[3,18];case 21:return[3,24];case 22:return x=kn.sent(),An={error:x},[3,24];case 23:try{H&&!H.done&&(Pn=N.return)&&Pn.call(N)}finally{if(An)throw An.error}return[7];case 24:return T.length>0?[4,this.upsertChannelsToCache(T)]:[3,26];case 25:kn.sent(),g((function(){return e(Ln,void 0,void 0,(function(){var n,e,r,a;return t(this,(function(t){try{for(n=_(this._openChannelHandlers.values()),e=n.next();!e.done;e=n.next())e.value.onChannelMemberCountChanged(T)}catch(n){r={error:n}}finally{try{e&&!e.done&&(a=n.return)&&a.call(n)}finally{if(r)throw r.error}}return[2]}))}))})),kn.label=26;case 26:return[3,50];case 27:if(!(D=n.as(K).event).isOpenChannelEvent)return[3,49];switch(D.category){case R.CHANNEL_ENTER:return[3,28];case R.CHANNEL_EXIT:return[3,30];case R.CHANNEL_OPERATOR_UPDATE:return[3,32];case R.USER_CHANNEL_MUTE:case R.USER_CHANNEL_UNMUTE:return[3,34];case R.USER_CHANNEL_BAN:case R.USER_CHANNEL_UNBAN:return[3,36];case R.CHANNEL_FREEZE:case R.CHANNEL_UNFREEZE:return[3,38];case R.CHANNEL_DELETED:return[3,40];case R.CHANNEL_PROP_CHANGED:return[3,43];case R.CHANNEL_META_DATA_CHANGED:return[3,45];case R.CHANNEL_META_COUNTERS_CHANGED:return[3,47]}return[3,49];case 28:return[4,this.getChannel(D.channelUrl,!0)];case 29:return A=kn.sent(),J=n.as(cn),an=J.participantCount,nn=J.user,en=A._updateParticipantCount(an,D.ts),g((function(){return e(Ln,void 0,void 0,(function(){return t(this,(function(n){return this._openChannelHandlers.forEach((function(n){n.onUserEntered(A,nn),en&&n.onChannelParticipantCountChanged(A)})),[2]}))}))})),[3,49];case 30:return[4,this.getChannel(D.channelUrl,!0)];case 31:return tn=kn.sent(),rn=n.as(hn),an=rn.participantCount,sn=rn.user,on=tn._updateParticipantCount(an,D.ts),g((function(){return e(Ln,void 0,void 0,(function(){return t(this,(function(n){return this._openChannelHandlers.forEach((function(n){n.onUserExited(tn,sn),on&&n.onChannelParticipantCountChanged(tn)})),[2]}))}))})),[3,49];case 32:return[4,this.getChannel(D.channelUrl,!0)];case 33:return un=kn.sent(),ln=n.as(z).operators,un.operators=ln,this.upsertChannelsToCache([un]),g((function(){return e(Ln,void 0,void 0,(function(){return t(this,(function(n){return this._openChannelHandlers.forEach((function(n){n.onOperatorUpdated(un,ln)})),[2]}))}))})),[3,49];case 34:return[4,this.getChannel(D.channelUrl,!0)];case 35:return dn=kn.sent(),pn=D.category===R.USER_CHANNEL_MUTE,fn=n.as(pn?q:Q).user,g((function(){return e(Ln,void 0,void 0,(function(){return t(this,(function(n){return this._openChannelHandlers.forEach((function(n){pn?n.onUserMuted(dn,fn):n.onUserUnmuted(dn,fn)})),[2]}))}))})),[3,49];case 36:return[4,this.getChannel(D.channelUrl,!0)];case 37:return vn=kn.sent(),Cn=D.category===R.USER_CHANNEL_BAN,_n=n.as(Cn?F:S).user,g((function(){return e(Ln,void 0,void 0,(function(){return t(this,(function(n){return this._openChannelHandlers.forEach((function(n){Cn?n.onUserBanned(vn,_n):n.onUserUnbanned(vn,_n)})),[2]}))}))})),[3,49];case 38:return[4,this.getChannel(D.channelUrl,!0)];case 39:return yn=kn.sent(),mn=n.as(k).freeze,yn.isFrozen=mn,this.upsertChannelsToCache([yn]),g((function(){return e(Ln,void 0,void 0,(function(){return t(this,(function(n){return this._openChannelHandlers.forEach((function(n){mn?n.onChannelFrozen(yn):n.onChannelUnfrozen(yn)})),[2]}))}))})),[3,49];case 40:return[4,this.getChannel(D.channelUrl,!0)];case 41:return gn=kn.sent(),[4,this.removeChannelsFromCache([gn.url])];case 42:return kn.sent(),g((function(){return e(Ln,void 0,void 0,(function(){return t(this,(function(n){return this._openChannelHandlers.forEach((function(n){n.onChannelDeleted(gn.url,gn.channelType)})),[2]}))}))})),[3,49];case 43:return[4,this.getChannelWithoutCache(D.channelUrl,!0)];case 44:return Un=kn.sent(),g((function(){return e(Ln,void 0,void 0,(function(){return t(this,(function(n){return this._openChannelHandlers.forEach((function(n){n.onChannelChanged(Un)})),[2]}))}))})),[3,49];case 45:return[4,this.getChannel(D.channelUrl,!0)];case 46:return En=kn.sent(),wn=n.as(L),Tn=wn.created,Nn=wn.updated,Hn=wn.deleted,Tn&&En._upsertCachedMetaData(Tn,D.ts),Nn&&En._upsertCachedMetaData(Nn,D.ts),Hn&&En._removeFromCachedMetaData(Hn,D.ts),g((function(){return e(Ln,void 0,void 0,(function(){return t(this,(function(n){return this._openChannelHandlers.forEach((function(n){Tn&&n.onMetaDataCreated(En,Tn),Nn&&n.onMetaDataUpdated(En,Nn),Hn&&n.onMetaDataDeleted(En,Hn)})),[2]}))}))})),[3,49];case 47:return[4,this.getChannel(D.channelUrl,!0)];case 48:return In=kn.sent(),Mn=n.as(P),On=Mn.created,bn=Mn.updated,xn=Mn.deleted,g((function(){return e(Ln,void 0,void 0,(function(){return t(this,(function(n){return this._openChannelHandlers.forEach((function(n){On&&n.onMetaCounterCreated(In,On),bn&&n.onMetaCounterUpdated(In,bn),xn&&n.onMetaCounterDeleted(In,xn)})),[2]}))}))})),[3,49];case 49:return[3,50];case 50:return[3,52];case 51:if(Dn=kn.sent(),m(Dn))throw Dn;return[3,52];case 52:return[2]}}))}))},n.prototype.addHandler=function(n,e){this._openChannelHandlers.set(n,e)},n.prototype.removeHandler=function(n){this._openChannelHandlers.delete(n)},n.prototype.clearHandler=function(){this._openChannelHandlers.clear()},n.prototype.getChannel=function(n,r){return e(this,void 0,void 0,(function(){var e;return t(this,(function(t){switch(t.label){case 0:w(i("string",n)).throw(T.invalidParameters),t.label=1;case 1:return t.trys.push([1,3,,4]),[4,this.getChannelFromCache(n)];case 2:return(e=t.sent())?[2,e]:[3,4];case 3:return t.sent(),[3,4];case 4:return[4,this.getChannelWithoutCache(n)];case 5:return[2,t.sent()]}}))}))},n.prototype.getChannelWithoutCache=function(n,r){return void 0===r&&(r=!1),e(this,void 0,void 0,(function(){var e,a,s;return t(this,(function(t){switch(t.label){case 0:return w(i("string",n)).throw(T.invalidParameters),e=new an({channelUrl:n,isInternalCall:r}),[4,this._requestQueue.send(e)];case 1:return a=t.sent(),s=a.as(sn).channel,[4,this.upsertChannelsToCache([s])];case 2:return t.sent(),[2,s]}}))}))},n.prototype.createChannel=function(n){return e(this,void 0,void 0,(function(){var e,r,a;return t(this,(function(t){switch(t.label){case 0:return w(n instanceof rn&&n.validate()).throw(T.invalidParameters),e=new on(n),[4,this._requestQueue.send(e)];case 1:return r=t.sent(),a=r.as(sn).channel,this.upsertChannelsToCache([a]),[2,a]}}))}))},n}(),fn=function(){this.name=null,this.coverUrlOrImage=null,this.data=null,this.customType=null,this.operatorUserIds=null},vn=function(e){function t(n){var t=e.call(this)||this;if(n)for(var r in n)t.hasOwnProperty(r)&&(t[r]=n[r]);return t}return n(t,e),t.prototype.validate=function(){return a("string",this.operatorUserIds,!0)&&(i("string",this.coverUrlOrImage)||s(this.coverUrlOrImage)||null===this.coverUrlOrImage)&&i("string",this.name,!0)&&i("string",this.data,!0)&&i("string",this.customType,!0)},t}(fn),Cn=function(e){function t(n){var t=this,r=n.channelUrl,a=n.token,i=n.limit;return(t=e.call(this)||this).method=o.GET,t.path="".concat(c,"/").concat(encodeURIComponent(r),"/participants"),t.params={token:a,limit:i},t}return n(t,e),t}(l),_n=function(e){function t(n,t){var r=e.call(this,n,t)||this;r.token=null,r.participants=[];var a=t.next,i=t.participants;return r.token=a,r.participants=i.map((function(e){return new p(n,e)})),r}return n(t,e),t}(h),yn=function(r){function a(n,e,t){return r.call(this,n,e,U.OPEN,t)||this}return n(a,r),a.prototype._validate=function(){return r.prototype._validate.call(this)},a.prototype.next=function(){return e(this,void 0,void 0,(function(){var n,e,r,a,i,s;return t(this,(function(t){switch(t.label){case 0:return this._validate()?this._isLoading?[3,3]:this._hasNext?(this._isLoading=!0,n=H.of(this._iid).requestQueue,e=new Cn(I(I({},this),{token:this._token})),[4,n.send(e)]):[3,2]:[3,5];case 1:return r=t.sent(),a=r.as(_n),i=a.participants,s=a.token,this._token=s,this._hasNext=!!s,this._isLoading=!1,[2,i];case 2:return[2,[]];case 3:throw T.queryInProgress;case 4:return[3,6];case 5:throw T.invalidParameters;case 6:return[2]}}))}))},a}(N),mn=function(e){function t(n){var t=this,r=n.channelUrl,a=n.coverUrlOrImage,u=n.name,l=n.data,h=n.customType,d=n.operatorUserIds;return(t=e.call(this)||this).method=o.PUT,t.path="".concat(c,"/").concat(encodeURIComponent(r)),t.params={cover_url:i("string",a)?a:null,cover_file:s(a)?a:null,name:u,data:l,custom_type:h,operators:d},t}return n(t,e),t}(l),gn=function(e){function t(n,t){var r=e.call(this,n,t)||this;return r.channel=new En(n,t),r}return n(t,e),t}(h),Un=function(e){function t(n){var t=this,r=n.channelUrl;return(t=e.call(this)||this).method=o.DELETE,t.path="".concat(c,"/").concat(encodeURIComponent(r)),t}return n(t,e),t}(l);!function(e){function t(n,t){return e.call(this,n,t)||this}n(t,e)}(h);var En=function(r){function a(n,e){var t,a=this;return(a=r.call(this,n,e)||this)._lastParticipantCountUpdated=0,a.participantCount=0,a.operators=[],a.channelType=U.OPEN,a.participantCount=null!==(t=e.participant_count)&&void 0!==t?t:0,a.operators=Array.isArray(e.operators)?e.operators.map((function(e){return new p(n,e)})):[],a}return n(a,r),a.payloadify=function(n){return n?O(I(I({},J.payloadify(n)),{participant_count:n.participantCount,operators:n.operators.map((function(n){return p.payloadify(n)}))})):null},a.prototype.serialize=function(){return M(this)},a.prototype.isOperator=function(n){return n instanceof p?this.isOperator(n.userId):this.operators.some((function(e){return e.userId===n}))},a.prototype._updateParticipantCount=function(n,e){return e>this._lastParticipantCountUpdated&&(this.participantCount=n,this._lastParticipantCountUpdated=e,!0)},a.prototype.createParticipantListQuery=function(n){return new yn(this._iid,this.url,n)},a.prototype.refresh=function(){return e(this,void 0,void 0,(function(){return t(this,(function(n){switch(n.label){case 0:return[4,pn.of(this._iid).getChannelWithoutCache(this.url)];case 1:return[2,n.sent()]}}))}))},a.prototype.enter=function(){return e(this,void 0,void 0,(function(){var n,e,r,a,i,s;return t(this,(function(t){switch(t.label){case 0:return n=H.of(this._iid).requestQueue,e=new un({channelUrl:this.url}),[4,n.send(e)];case 1:return r=t.sent(),a=r.as(cn),i=a.participantCount,s=a.ts,this._updateParticipantCount(i,s),pn.of(this._iid).setEnteredToCache(this),[2]}}))}))},a.prototype.exit=function(){return e(this,void 0,void 0,(function(){var n,e,r,a,i,s;return t(this,(function(t){switch(t.label){case 0:return n=H.of(this._iid).requestQueue,e=new ln({channelUrl:this.url}),[4,n.send(e)];case 1:return r=t.sent(),a=r.as(hn),i=a.participantCount,s=a.ts,this._updateParticipantCount(i,s),pn.of(this._iid).setExitedToCache(this),b.of(this._iid).fileMessageQueue.cancel(this),[2]}}))}))},a.prototype.updateChannel=function(n){return e(this,void 0,void 0,(function(){var e,r,a,i;return t(this,(function(t){switch(t.label){case 0:return w(n instanceof vn&&n.validate()).throw(T.invalidParameters),e=H.of(this._iid).requestQueue,r=new mn(I({channelUrl:this.url},n)),[4,e.send(r)];case 1:return a=t.sent(),i=a.as(gn).channel,[4,pn.of(this._iid).upsertChannelsToCache([i])];case 2:return t.sent(),[2,i]}}))}))},a.prototype.updateChannelWithOperatorUserIds=function(n,r,a,i,s){return e(this,void 0,void 0,(function(){var e;return t(this,(function(t){return(e=new vn).name=n,e.coverUrlOrImage=r,e.data=a,e.operatorUserIds=i,e.customType=s,[2,this.updateChannel(e)]}))}))},a.prototype.delete=function(){return e(this,void 0,void 0,(function(){var n,e;return t(this,(function(t){switch(t.label){case 0:return n=H.of(this._iid).requestQueue,e=new Un({channelUrl:this.url}),[4,n.send(e)];case 1:return t.sent(),[4,pn.of(this._iid).removeChannelsFromCache([this.url])];case 2:return t.sent(),[2]}}))}))},a}(J),wn=function(e){function t(n){void 0===n&&(n={});var t=e.call(this)||this;return Object.keys(n).forEach((function(e){t.hasOwnProperty(e)&&(t[e]=n[e])})),t}return n(t,e),t}(function(e){function t(){var n=null!==e&&e.apply(this,arguments)||this;return n.onUserEntered=x,n.onUserExited=x,n.onChannelParticipantCountChanged=x,n}return n(t,e),t}(nn)),Tn=function(e){function t(n){var t=this,r=n.token,a=n.limit,i=n.nameKeyword,s=n.urlKeyword,u=n.customTypes,l=n.includeFrozen,h=n.includeMetaData;return(t=e.call(this)||this).method=o.GET,t.path=c,t.params=O({token:r,limit:a,name_contains:i,url_contains:s,custom_types:u,show_frozen:l,show_metadata:h}),t}return n(t,e),t}(l),Nn=function(e){function t(n,t){var r=e.call(this,n,t)||this;r.token=null,r.channels=[],r.ts=null;var a=t.next,i=t.channels,s=t.ts;return r.token=a,i&&i.length>0&&(r.channels=i.map((function(e){return new En(n,e)}))),r.ts="number"==typeof s?s:null,r}return n(t,e),t}(h),Hn=function(r){function s(n,e){var t,a,i,s,o,u=this;return(u=r.call(this,n,e)||this).includeFrozen=!0,u.includeMetaData=!0,u.nameKeyword=null,u.urlKeyword=null,u.customTypes=null,u.includeFrozen=null===(t=e.includeFrozen)||void 0===t||t,u.includeMetaData=null===(a=e.includeMetaData)||void 0===a||a,u.nameKeyword=null!==(i=e.nameKeyword)&&void 0!==i?i:null,u.urlKeyword=null!==(s=e.urlKeyword)&&void 0!==s?s:null,u.customTypes=null!==(o=e.customTypes)&&void 0!==o?o:null,u}return n(s,r),s.prototype._validate=function(){return r.prototype._validate.call(this)&&i("boolean",this.includeFrozen)&&i("boolean",this.includeMetaData)&&i("string",this.nameKeyword,!0)&&i("string",this.urlKeyword,!0)&&a("string",this.customTypes,!0)},s.prototype.next=function(){return e(this,void 0,void 0,(function(){var n,e,r,a,i,s;return t(this,(function(t){switch(t.label){case 0:return this._validate()?this._isLoading?[3,4]:this._hasNext?(this._isLoading=!0,n=H.of(this._iid).requestQueue,e=new Tn(I(I({},this),{token:this._token})),[4,n.send(e)]):[3,3]:[3,6];case 1:return r=t.sent(),a=r.as(Nn),i=a.channels,s=a.token,this._token=s,this._hasNext=!!s,[4,pn.of(this._iid).upsertChannelsToCache(i)];case 2:return t.sent(),this._isLoading=!1,[2,i];case 3:return[2,[]];case 4:throw T.queryInProgress;case 5:return[3,7];case 6:throw T.invalidParameters;case 7:return[2]}}))}))},s}(D),In=function(r){function a(){var n=null!==r&&r.apply(this,arguments)||this;return n.name="openChannel",n}return n(a,r),a.prototype.init=function(n,e){var t=e.sdkState,a=e.dispatcher,i=e.sessionManager,s=e.requestQueue,o=e.logger,u=e.cacheContext;r.prototype.init.call(this,n,{sdkState:t,dispatcher:a,sessionManager:i,requestQueue:s,logger:o,cacheContext:u}),this._manager=new pn(n,{sdkState:t,dispatcher:a,requestQueue:s})},a.prototype.createOpenChannelListQuery=function(n){return void 0===n&&(n={}),new Hn(this._iid,n)},a.prototype.addOpenChannelHandler=function(n,e){this._manager.addHandler(n,e)},a.prototype.removeOpenChannelHandler=function(n){this._manager.removeHandler(n)},a.prototype.removeAllOpenChannelHandlers=function(){this._manager.clearHandler()},a.prototype.buildOpenChannelFromSerializedData=function(n){return this._manager.buildOpenChannelFromSerializedData(n)},a.prototype.getChannel=function(n){return e(this,void 0,void 0,(function(){return t(this,(function(e){return[2,this._manager.getChannel(n)]}))}))},a.prototype.getChannelWithoutCache=function(n){return e(this,void 0,void 0,(function(){return t(this,(function(e){return[2,this._manager.getChannelWithoutCache(n)]}))}))},a.prototype.createChannel=function(n){return e(this,void 0,void 0,(function(){return t(this,(function(e){return[2,this._manager.createChannel(n)]}))}))},a.prototype.createChannelWithOperatorUserIds=function(n,r,a,i,s){return e(this,void 0,void 0,(function(){var e;return t(this,(function(t){return(e=new rn).name=n,e.coverUrlOrImage=r,e.data=a,e.operatorUserIds=i,e.customType=s,[2,this._manager.createChannel(e)]}))}))},a}(A);export{En as OpenChannel,rn as OpenChannelCreateParams,tn as OpenChannelCreateParamsProperties,wn as OpenChannelHandler,Hn as OpenChannelListQuery,In as OpenChannelModule,vn as OpenChannelUpdateParams,fn as OpenChannelUpdateParamsProperties,yn as ParticipantListQuery}; | ||
import{_ as n,d as e,e as t,I as r,b as a,a as i,i as s,A as o,aZ as u,a_ as c,h as l,k as h,ac as d,U as p,W as f,ae as v,af as C,p as _,z as y,ak as m,F as g,L as U,al as E,x as w,S as T,ar as N,V as H,j as I,ad as M,g as O,a0 as b,n as x,B as D,aY as A}from"./__bundle-368767fc.js";import{U as P,e as L,F as k,h as R,g as F,f as S,i as q,j as Q,k as z,C as K,l as W,T as j,m as B,D as G,n as X,o as Z,p as V,q as Y,A as $,a as J}from"./__bundle-72d7e125.js";import{B as nn}from"./__bundle-96ae73c1.js";var en=function(r){function a(){var n=null!==r&&r.apply(this,arguments)||this;return n._channels=new Map,n._enteredChannelUrls=[],n}return n(a,r),Object.defineProperty(a.prototype,"enteredChannels",{get:function(){var n=this;return this._enteredChannelUrls.map((function(e){return n._channels.get(e)})).filter((function(n){return null!==n}))},enumerable:!1,configurable:!0}),a.prototype.isEnteredChannel=function(n){return this._enteredChannelUrls.includes(n)},a.prototype.enter=function(n){this._enteredChannelUrls.indexOf(n)<0&&this._enteredChannelUrls.push(n)},a.prototype.exit=function(n){var e=this._enteredChannelUrls.indexOf(n);e>=0&&this._enteredChannelUrls.splice(e,1)},a.prototype.exitAll=function(){this._enteredChannelUrls=[]},a.prototype.get=function(n){var r;return e(this,void 0,void 0,(function(){return t(this,(function(e){return[2,null!==(r=this._channels.get(n))&&void 0!==r?r:null]}))}))},a.prototype.upsert=function(n){return e(this,void 0,void 0,(function(){var e=this;return t(this,(function(t){return n.forEach((function(n){if(e._channels.has(n.url)){var t=e._channels.get(n.url);Object.assign(t,n)}else e._channels.set(n.url,n)})),[2]}))}))},a.prototype.remove=function(n){return e(this,void 0,void 0,(function(){return t(this,(function(e){return this._channels.delete(n),this.exit(n),[2]}))}))},a.prototype.clear=function(){return e(this,void 0,void 0,(function(){return t(this,(function(n){return this._channels.clear(),this._enteredChannelUrls=[],[2]}))}))},a}(r),tn=function(){this.channelUrl=null,this.name=null,this.coverUrlOrImage=null,this.data=null,this.customType=null,this.operatorUserIds=null},rn=function(e){function t(n){var t=e.call(this)||this;if(n)for(var r in n)t.hasOwnProperty(r)&&(t[r]=n[r]);return t}return n(t,e),t.prototype.validate=function(){return a("string",this.operatorUserIds,!0)&&(i("string",this.coverUrlOrImage)||s(this.coverUrlOrImage)||null===this.coverUrlOrImage)&&i("string",this.name,!0)&&i("string",this.data,!0)&&i("string",this.customType,!0)&&(i("string",this.channelUrl)&&/^\w+$/.test(this.channelUrl)||null===this.channelUrl)},t}(tn),an=function(e){function t(n){var t=n.channelUrl,r=n.isInternalCall,a=e.call(this)||this;return a.method=o.GET,a.path="".concat(r?u:c,"/").concat(encodeURIComponent(t)),a}return n(t,e),t}(l),sn=function(e){function t(n,t){var r=e.call(this,n,t)||this;return r.channel=null,r.channel=new En(n,t),r}return n(t,e),t}(h),on=function(e){function t(n){var t=this,r=n.channelUrl,a=n.coverUrlOrImage,u=n.name,l=n.data,h=n.customType,d=n.operatorUserIds;return(t=e.call(this)||this).method=o.POST,t.path=c,t.params={channel_url:r,cover_url:i("string",a)?a:null,cover_file:s(a)?a:null,name:u,data:l,custom_type:h,operators:d},t}return n(t,e),t}(l);!function(e){function t(n,t){var r=e.call(this,n,t)||this;return r.channel=new En(n,t),r}n(t,e)}(h);var un=function(e){function t(n){var t=n.channelUrl;return e.call(this,{code:"ENTR",payload:{channel_url:t},ackRequired:!0})||this}return n(t,e),t}(d),cn=function(e){function t(n,t,r){var a,i,s=this;return s=e.call(this,n,"ENTR",r)||this,r.data&&(s.participantCount=null!==(a=r.data.participant_count)&&void 0!==a?a:0,s.user=new p(n,r.data),s.ts=null!==(i=r.data.edge_ts)&&void 0!==i?i:0),s}return n(t,e),t}(f),ln=function(e){function t(n){var t=n.channelUrl;return e.call(this,{code:"EXIT",payload:{channel_url:t},ackRequired:!0})||this}return n(t,e),t}(d),hn=function(e){function t(n,t,r){var a,i,s=this;return s=e.call(this,n,"EXIT",r)||this,r.data&&(s.participantCount=null!==(a=r.data.participant_count)&&void 0!==a?a:0,s.user=new p(n,r.data),s.ts=null!==(i=r.data.edge_ts)&&void 0!==i?i:0),s}return n(t,e),t}(f),dn={},pn=function(){function n(n,e){var t=e.sdkState,r=e.dispatcher,a=e.requestQueue,i=this;this._sdkState=t,this._requestQueue=a,this._dispatcher=r,this._openChannelCache=new en(n),this._openChannelHandlers=new Map,this._dispatcher.on((function(n){var e,t;if(n instanceof f)i._handleEvent(n);else if(n instanceof v&&n.stateType===C.CONNECTED){var r=i._openChannelCache.enteredChannels;try{for(var a=_(r),s=a.next();!s.done;s=a.next()){s.value.enter()}}catch(n){e={error:n}}finally{try{s&&!s.done&&(t=a.return)&&t.call(a)}finally{if(e)throw e.error}}}})),dn[n]=this}return n.of=function(n){return dn[n]},n.prototype.buildOpenChannelFromSerializedData=function(n){var e=y(n);return new En(e._iid,En.payloadify(e))},n.prototype.getChannelFromCache=function(n){return e(this,void 0,void 0,(function(){return t(this,(function(e){switch(e.label){case 0:return[4,this._openChannelCache.get(n)];case 1:return[2,e.sent()]}}))}))},n.prototype.upsertChannelsToCache=function(n){return e(this,void 0,void 0,(function(){return t(this,(function(e){switch(e.label){case 0:return[4,this._openChannelCache.upsert(n)];case 1:return e.sent(),[2]}}))}))},n.prototype.removeChannelsFromCache=function(n){return e(this,void 0,void 0,(function(){var e,r,a,i,s,o;return t(this,(function(t){switch(t.label){case 0:t.trys.push([0,5,6,7]),e=_(n),r=e.next(),t.label=1;case 1:return r.done?[3,4]:(a=r.value,[4,this._openChannelCache.remove(a)]);case 2:t.sent(),t.label=3;case 3:return r=e.next(),[3,1];case 4:return[3,7];case 5:return i=t.sent(),s={error:i},[3,7];case 6:try{r&&!r.done&&(o=e.return)&&o.call(e)}finally{if(s)throw s.error}return[7];case 7:return[2]}}))}))},n.prototype.setEnteredToCache=function(n){this._openChannelCache.enter(n.url)},n.prototype.setExitedToCache=function(n){this._openChannelCache.exit(n.url)},n.prototype._handleEvent=function(n){return e(this,void 0,void 0,(function(){var r,a,i,s,o,u,c,l,h,d,p,f,v,C,y,w,T,N,H,I,M,O,b,x,D,A,J,nn,en,tn,rn,an,sn,on,un,ln,dn,pn,fn,vn,Cn,_n,yn,mn,gn,Un,En,wn,Tn,Nn,Hn,In,Mn,On,bn,xn,Dn,An,Pn,Ln=this;return t(this,(function(kn){switch(kn.label){case 0:switch(kn.trys.push([0,51,,52]),n.code){case"MESG":case"FILE":case"ADMM":case"BRDM":return[3,1];case"MEDI":case"FEDI":case"AEDI":return[3,4];case"DELM":return[3,7];case"MRCT":return[3,10];case"MTHD":return[3,13];case"MCNT":return[3,16];case"SYEV":return[3,27]}return[3,50];case 1:return s=null,"MESG"===n.code?s=n.as(Y):"FILE"===n.code?s=n.as(E):"ADMM"!==n.code&&"BRDM"!=n.code||(s=n.as($)),s?(r=s.message,a=s.isMentioned,r.channelType!==U.OPEN?[3,3]:[4,this.getChannel(r.channelUrl,!0)]):[3,3];case 2:i=kn.sent(),g((function(){return e(Ln,void 0,void 0,(function(){var n,e,s,o,u;return t(this,(function(t){try{for(n=_(this._openChannelHandlers.values()),e=n.next();!e.done;e=n.next())s=e.value,this._openChannelCache.isEnteredChannel(i.url)&&s.onMessageReceived(i,r),a&&s.onMentionReceived(i,r)}catch(n){o={error:n}}finally{try{e&&!e.done&&(u=n.return)&&u.call(n)}finally{if(o)throw o.error}}return[2]}))}))})),kn.label=3;case 3:return[3,50];case 4:return s=null,"MEDI"===n.code?s=n.as(X):"FEDI"===n.code?s=n.as(Z):"AEDI"===n.code&&(s=n.as(V)),s?(o=s.message).channelType!==U.OPEN?[3,6]:[4,this.getChannel(o.channelUrl,!0)]:[3,6];case 5:u=kn.sent(),g((function(){return e(Ln,void 0,void 0,(function(){var n,e,r,a,i;return t(this,(function(t){try{for(n=_(this._openChannelHandlers.values()),e=n.next();!e.done;e=n.next())r=e.value,this._openChannelCache.isEnteredChannel(u.url)&&r.onMessageUpdated(u,o)}catch(n){a={error:n}}finally{try{e&&!e.done&&(i=n.return)&&i.call(n)}finally{if(a)throw a.error}}return[2]}))}))})),kn.label=6;case 6:return[3,50];case 7:return c=n.as(G),M=c.channelUrl,p=c.channelType,l=c.messageId,p!==U.OPEN?[3,9]:[4,this.getChannel(M,!0)];case 8:h=kn.sent(),g((function(){return e(Ln,void 0,void 0,(function(){var n,e,r,a,i;return t(this,(function(t){try{for(n=_(this._openChannelHandlers.values()),e=n.next();!e.done;e=n.next())r=e.value,this._openChannelCache.isEnteredChannel(h.url)&&r.onMessageDeleted(h,l)}catch(n){a={error:n}}finally{try{e&&!e.done&&(i=n.return)&&i.call(n)}finally{if(a)throw a.error}}return[2]}))}))})),kn.label=9;case 9:return[3,50];case 10:return d=n.as(B),M=d.channelUrl,p=d.channelType,f=d.event,p!==U.OPEN?[3,12]:[4,this.getChannel(M,!0)];case 11:v=kn.sent(),g((function(){return e(Ln,void 0,void 0,(function(){var n,e,r,a;return t(this,(function(t){try{for(n=_(this._openChannelHandlers.values()),e=n.next();!e.done;e=n.next())e.value.onReactionUpdated(v,f)}catch(n){r={error:n}}finally{try{e&&!e.done&&(a=n.return)&&a.call(n)}finally{if(r)throw r.error}}return[2]}))}))})),kn.label=12;case 12:return[3,50];case 13:return(C=n.as(j).event).channelType!==U.OPEN?[3,15]:[4,this.getChannel(C.channelUrl,!0)];case 14:y=kn.sent(),g((function(){return e(Ln,void 0,void 0,(function(){var n,e,r,a;return t(this,(function(t){try{for(n=_(this._openChannelHandlers.values()),e=n.next();!e.done;e=n.next())e.value.onThreadInfoUpdated(y,C)}catch(n){r={error:n}}finally{try{e&&!e.done&&(a=n.return)&&a.call(n)}finally{if(r)throw r.error}}return[2]}))}))})),kn.label=15;case 15:return[3,50];case 16:w=n.as(W).openChannelMemberCounts,T=[],kn.label=17;case 17:kn.trys.push([17,22,23,24]),N=_(w),H=N.next(),kn.label=18;case 18:return H.done?[3,21]:(I=H.value,M=I.channelUrl,an=I.participantCount,O=I.updatedAt,[4,this.getChannelFromCache(M)]);case 19:(b=kn.sent())&&b._updateParticipantCount(an,O)&&T.push(b),kn.label=20;case 20:return H=N.next(),[3,18];case 21:return[3,24];case 22:return x=kn.sent(),An={error:x},[3,24];case 23:try{H&&!H.done&&(Pn=N.return)&&Pn.call(N)}finally{if(An)throw An.error}return[7];case 24:return T.length>0?[4,this.upsertChannelsToCache(T)]:[3,26];case 25:kn.sent(),g((function(){return e(Ln,void 0,void 0,(function(){var n,e,r,a;return t(this,(function(t){try{for(n=_(this._openChannelHandlers.values()),e=n.next();!e.done;e=n.next())e.value.onChannelMemberCountChanged(T)}catch(n){r={error:n}}finally{try{e&&!e.done&&(a=n.return)&&a.call(n)}finally{if(r)throw r.error}}return[2]}))}))})),kn.label=26;case 26:return[3,50];case 27:if(!(D=n.as(K).event).isOpenChannelEvent)return[3,49];switch(D.category){case R.CHANNEL_ENTER:return[3,28];case R.CHANNEL_EXIT:return[3,30];case R.CHANNEL_OPERATOR_UPDATE:return[3,32];case R.USER_CHANNEL_MUTE:case R.USER_CHANNEL_UNMUTE:return[3,34];case R.USER_CHANNEL_BAN:case R.USER_CHANNEL_UNBAN:return[3,36];case R.CHANNEL_FREEZE:case R.CHANNEL_UNFREEZE:return[3,38];case R.CHANNEL_DELETED:return[3,40];case R.CHANNEL_PROP_CHANGED:return[3,43];case R.CHANNEL_META_DATA_CHANGED:return[3,45];case R.CHANNEL_META_COUNTERS_CHANGED:return[3,47]}return[3,49];case 28:return[4,this.getChannel(D.channelUrl,!0)];case 29:return A=kn.sent(),J=n.as(cn),an=J.participantCount,nn=J.user,en=A._updateParticipantCount(an,D.ts),g((function(){return e(Ln,void 0,void 0,(function(){return t(this,(function(n){return this._openChannelHandlers.forEach((function(n){n.onUserEntered(A,nn),en&&n.onChannelParticipantCountChanged(A)})),[2]}))}))})),[3,49];case 30:return[4,this.getChannel(D.channelUrl,!0)];case 31:return tn=kn.sent(),rn=n.as(hn),an=rn.participantCount,sn=rn.user,on=tn._updateParticipantCount(an,D.ts),g((function(){return e(Ln,void 0,void 0,(function(){return t(this,(function(n){return this._openChannelHandlers.forEach((function(n){n.onUserExited(tn,sn),on&&n.onChannelParticipantCountChanged(tn)})),[2]}))}))})),[3,49];case 32:return[4,this.getChannel(D.channelUrl,!0)];case 33:return un=kn.sent(),ln=n.as(z).operators,un.operators=ln,this.upsertChannelsToCache([un]),g((function(){return e(Ln,void 0,void 0,(function(){return t(this,(function(n){return this._openChannelHandlers.forEach((function(n){n.onOperatorUpdated(un,ln)})),[2]}))}))})),[3,49];case 34:return[4,this.getChannel(D.channelUrl,!0)];case 35:return dn=kn.sent(),pn=D.category===R.USER_CHANNEL_MUTE,fn=n.as(pn?q:Q).user,g((function(){return e(Ln,void 0,void 0,(function(){return t(this,(function(n){return this._openChannelHandlers.forEach((function(n){pn?n.onUserMuted(dn,fn):n.onUserUnmuted(dn,fn)})),[2]}))}))})),[3,49];case 36:return[4,this.getChannel(D.channelUrl,!0)];case 37:return vn=kn.sent(),Cn=D.category===R.USER_CHANNEL_BAN,_n=n.as(Cn?F:S).user,g((function(){return e(Ln,void 0,void 0,(function(){return t(this,(function(n){return this._openChannelHandlers.forEach((function(n){Cn?n.onUserBanned(vn,_n):n.onUserUnbanned(vn,_n)})),[2]}))}))})),[3,49];case 38:return[4,this.getChannel(D.channelUrl,!0)];case 39:return yn=kn.sent(),mn=n.as(k).freeze,yn.isFrozen=mn,this.upsertChannelsToCache([yn]),g((function(){return e(Ln,void 0,void 0,(function(){return t(this,(function(n){return this._openChannelHandlers.forEach((function(n){mn?n.onChannelFrozen(yn):n.onChannelUnfrozen(yn)})),[2]}))}))})),[3,49];case 40:return[4,this.getChannel(D.channelUrl,!0)];case 41:return gn=kn.sent(),[4,this.removeChannelsFromCache([gn.url])];case 42:return kn.sent(),g((function(){return e(Ln,void 0,void 0,(function(){return t(this,(function(n){return this._openChannelHandlers.forEach((function(n){n.onChannelDeleted(gn.url,gn.channelType)})),[2]}))}))})),[3,49];case 43:return[4,this.getChannelWithoutCache(D.channelUrl,!0)];case 44:return Un=kn.sent(),g((function(){return e(Ln,void 0,void 0,(function(){return t(this,(function(n){return this._openChannelHandlers.forEach((function(n){n.onChannelChanged(Un)})),[2]}))}))})),[3,49];case 45:return[4,this.getChannel(D.channelUrl,!0)];case 46:return En=kn.sent(),wn=n.as(L),Tn=wn.created,Nn=wn.updated,Hn=wn.deleted,Tn&&En._upsertCachedMetaData(Tn,D.ts),Nn&&En._upsertCachedMetaData(Nn,D.ts),Hn&&En._removeFromCachedMetaData(Hn,D.ts),g((function(){return e(Ln,void 0,void 0,(function(){return t(this,(function(n){return this._openChannelHandlers.forEach((function(n){Tn&&n.onMetaDataCreated(En,Tn),Nn&&n.onMetaDataUpdated(En,Nn),Hn&&n.onMetaDataDeleted(En,Hn)})),[2]}))}))})),[3,49];case 47:return[4,this.getChannel(D.channelUrl,!0)];case 48:return In=kn.sent(),Mn=n.as(P),On=Mn.created,bn=Mn.updated,xn=Mn.deleted,g((function(){return e(Ln,void 0,void 0,(function(){return t(this,(function(n){return this._openChannelHandlers.forEach((function(n){On&&n.onMetaCounterCreated(In,On),bn&&n.onMetaCounterUpdated(In,bn),xn&&n.onMetaCounterDeleted(In,xn)})),[2]}))}))})),[3,49];case 49:return[3,50];case 50:return[3,52];case 51:if(Dn=kn.sent(),m(Dn))throw Dn;return[3,52];case 52:return[2]}}))}))},n.prototype.addHandler=function(n,e){this._openChannelHandlers.set(n,e)},n.prototype.removeHandler=function(n){this._openChannelHandlers.delete(n)},n.prototype.clearHandler=function(){this._openChannelHandlers.clear()},n.prototype.getChannel=function(n,r){return e(this,void 0,void 0,(function(){var e;return t(this,(function(t){switch(t.label){case 0:w(i("string",n)).throw(T.invalidParameters),t.label=1;case 1:return t.trys.push([1,3,,4]),[4,this.getChannelFromCache(n)];case 2:return(e=t.sent())?[2,e]:[3,4];case 3:return t.sent(),[3,4];case 4:return[4,this.getChannelWithoutCache(n)];case 5:return[2,t.sent()]}}))}))},n.prototype.getChannelWithoutCache=function(n,r){return void 0===r&&(r=!1),e(this,void 0,void 0,(function(){var e,a,s;return t(this,(function(t){switch(t.label){case 0:return w(i("string",n)).throw(T.invalidParameters),e=new an({channelUrl:n,isInternalCall:r}),[4,this._requestQueue.send(e)];case 1:return a=t.sent(),s=a.as(sn).channel,[4,this.upsertChannelsToCache([s])];case 2:return t.sent(),[2,s]}}))}))},n.prototype.createChannel=function(n){return e(this,void 0,void 0,(function(){var e,r,a;return t(this,(function(t){switch(t.label){case 0:return w(n instanceof rn&&n.validate()).throw(T.invalidParameters),e=new on(n),[4,this._requestQueue.send(e)];case 1:return r=t.sent(),a=r.as(sn).channel,this.upsertChannelsToCache([a]),[2,a]}}))}))},n}(),fn=function(){this.name=null,this.coverUrlOrImage=null,this.data=null,this.customType=null,this.operatorUserIds=null},vn=function(e){function t(n){var t=e.call(this)||this;if(n)for(var r in n)t.hasOwnProperty(r)&&(t[r]=n[r]);return t}return n(t,e),t.prototype.validate=function(){return a("string",this.operatorUserIds,!0)&&(i("string",this.coverUrlOrImage)||s(this.coverUrlOrImage)||null===this.coverUrlOrImage)&&i("string",this.name,!0)&&i("string",this.data,!0)&&i("string",this.customType,!0)},t}(fn),Cn=function(e){function t(n){var t=this,r=n.channelUrl,a=n.token,i=n.limit;return(t=e.call(this)||this).method=o.GET,t.path="".concat(c,"/").concat(encodeURIComponent(r),"/participants"),t.params={token:a,limit:i},t}return n(t,e),t}(l),_n=function(e){function t(n,t){var r=e.call(this,n,t)||this;r.token=null,r.participants=[];var a=t.next,i=t.participants;return r.token=a,r.participants=i.map((function(e){return new p(n,e)})),r}return n(t,e),t}(h),yn=function(r){function a(n,e,t){return r.call(this,n,e,U.OPEN,t)||this}return n(a,r),a.prototype._validate=function(){return r.prototype._validate.call(this)},a.prototype.next=function(){return e(this,void 0,void 0,(function(){var n,e,r,a,i,s;return t(this,(function(t){switch(t.label){case 0:return this._validate()?this._isLoading?[3,3]:this._hasNext?(this._isLoading=!0,n=H.of(this._iid).requestQueue,e=new Cn(I(I({},this),{token:this._token})),[4,n.send(e)]):[3,2]:[3,5];case 1:return r=t.sent(),a=r.as(_n),i=a.participants,s=a.token,this._token=s,this._hasNext=!!s,this._isLoading=!1,[2,i];case 2:return[2,[]];case 3:throw T.queryInProgress;case 4:return[3,6];case 5:throw T.invalidParameters;case 6:return[2]}}))}))},a}(N),mn=function(e){function t(n){var t=this,r=n.channelUrl,a=n.coverUrlOrImage,u=n.name,l=n.data,h=n.customType,d=n.operatorUserIds;return(t=e.call(this)||this).method=o.PUT,t.path="".concat(c,"/").concat(encodeURIComponent(r)),t.params={cover_url:i("string",a)?a:null,cover_file:s(a)?a:null,name:u,data:l,custom_type:h,operators:d},t}return n(t,e),t}(l),gn=function(e){function t(n,t){var r=e.call(this,n,t)||this;return r.channel=new En(n,t),r}return n(t,e),t}(h),Un=function(e){function t(n){var t=this,r=n.channelUrl;return(t=e.call(this)||this).method=o.DELETE,t.path="".concat(c,"/").concat(encodeURIComponent(r)),t}return n(t,e),t}(l);!function(e){function t(n,t){return e.call(this,n,t)||this}n(t,e)}(h);var En=function(r){function a(n,e){var t,a=this;return(a=r.call(this,n,e)||this)._lastParticipantCountUpdated=0,a.participantCount=0,a.operators=[],a.channelType=U.OPEN,a.participantCount=null!==(t=e.participant_count)&&void 0!==t?t:0,a.operators=Array.isArray(e.operators)?e.operators.map((function(e){return new p(n,e)})):[],a}return n(a,r),a.payloadify=function(n){return n?O(I(I({},J.payloadify(n)),{participant_count:n.participantCount,operators:n.operators.map((function(n){return p.payloadify(n)}))})):null},a.prototype.serialize=function(){return M(this)},a.prototype.isOperator=function(n){return n instanceof p?this.isOperator(n.userId):this.operators.some((function(e){return e.userId===n}))},a.prototype._updateParticipantCount=function(n,e){return e>this._lastParticipantCountUpdated&&(this.participantCount=n,this._lastParticipantCountUpdated=e,!0)},a.prototype.createParticipantListQuery=function(n){return new yn(this._iid,this.url,n)},a.prototype.refresh=function(){return e(this,void 0,void 0,(function(){return t(this,(function(n){switch(n.label){case 0:return[4,pn.of(this._iid).getChannelWithoutCache(this.url)];case 1:return[2,n.sent()]}}))}))},a.prototype.enter=function(){return e(this,void 0,void 0,(function(){var n,e,r,a,i,s;return t(this,(function(t){switch(t.label){case 0:return n=H.of(this._iid).requestQueue,e=new un({channelUrl:this.url}),[4,n.send(e)];case 1:return r=t.sent(),a=r.as(cn),i=a.participantCount,s=a.ts,this._updateParticipantCount(i,s),pn.of(this._iid).setEnteredToCache(this),[2]}}))}))},a.prototype.exit=function(){return e(this,void 0,void 0,(function(){var n,e,r,a,i,s;return t(this,(function(t){switch(t.label){case 0:return n=H.of(this._iid).requestQueue,e=new ln({channelUrl:this.url}),[4,n.send(e)];case 1:return r=t.sent(),a=r.as(hn),i=a.participantCount,s=a.ts,this._updateParticipantCount(i,s),pn.of(this._iid).setExitedToCache(this),b.of(this._iid).fileMessageQueue.cancel(this),[2]}}))}))},a.prototype.updateChannel=function(n){return e(this,void 0,void 0,(function(){var e,r,a,i;return t(this,(function(t){switch(t.label){case 0:return w(n instanceof vn&&n.validate()).throw(T.invalidParameters),e=H.of(this._iid).requestQueue,r=new mn(I({channelUrl:this.url},n)),[4,e.send(r)];case 1:return a=t.sent(),i=a.as(gn).channel,[4,pn.of(this._iid).upsertChannelsToCache([i])];case 2:return t.sent(),[2,i]}}))}))},a.prototype.updateChannelWithOperatorUserIds=function(n,r,a,i,s){return e(this,void 0,void 0,(function(){var e;return t(this,(function(t){return(e=new vn).name=n,e.coverUrlOrImage=r,e.data=a,e.operatorUserIds=i,e.customType=s,[2,this.updateChannel(e)]}))}))},a.prototype.delete=function(){return e(this,void 0,void 0,(function(){var n,e;return t(this,(function(t){switch(t.label){case 0:return n=H.of(this._iid).requestQueue,e=new Un({channelUrl:this.url}),[4,n.send(e)];case 1:return t.sent(),[4,pn.of(this._iid).removeChannelsFromCache([this.url])];case 2:return t.sent(),[2]}}))}))},a}(J),wn=function(e){function t(n){void 0===n&&(n={});var t=e.call(this)||this;return Object.keys(n).forEach((function(e){t.hasOwnProperty(e)&&(t[e]=n[e])})),t}return n(t,e),t}(function(e){function t(){var n=null!==e&&e.apply(this,arguments)||this;return n.onUserEntered=x,n.onUserExited=x,n.onChannelParticipantCountChanged=x,n}return n(t,e),t}(nn)),Tn=function(e){function t(n){var t=this,r=n.token,a=n.limit,i=n.nameKeyword,s=n.urlKeyword,u=n.customTypes,l=n.includeFrozen,h=n.includeMetaData;return(t=e.call(this)||this).method=o.GET,t.path=c,t.params=O({token:r,limit:a,name_contains:i,url_contains:s,custom_types:u,show_frozen:l,show_metadata:h}),t}return n(t,e),t}(l),Nn=function(e){function t(n,t){var r=e.call(this,n,t)||this;r.token=null,r.channels=[],r.ts=null;var a=t.next,i=t.channels,s=t.ts;return r.token=a,i&&i.length>0&&(r.channels=i.map((function(e){return new En(n,e)}))),r.ts="number"==typeof s?s:null,r}return n(t,e),t}(h),Hn=function(r){function s(n,e){var t,a,i,s,o,u=this;return(u=r.call(this,n,e)||this).includeFrozen=!0,u.includeMetaData=!0,u.nameKeyword=null,u.urlKeyword=null,u.customTypes=null,u.includeFrozen=null===(t=e.includeFrozen)||void 0===t||t,u.includeMetaData=null===(a=e.includeMetaData)||void 0===a||a,u.nameKeyword=null!==(i=e.nameKeyword)&&void 0!==i?i:null,u.urlKeyword=null!==(s=e.urlKeyword)&&void 0!==s?s:null,u.customTypes=null!==(o=e.customTypes)&&void 0!==o?o:null,u}return n(s,r),s.prototype._validate=function(){return r.prototype._validate.call(this)&&i("boolean",this.includeFrozen)&&i("boolean",this.includeMetaData)&&i("string",this.nameKeyword,!0)&&i("string",this.urlKeyword,!0)&&a("string",this.customTypes,!0)},s.prototype.next=function(){return e(this,void 0,void 0,(function(){var n,e,r,a,i,s;return t(this,(function(t){switch(t.label){case 0:return this._validate()?this._isLoading?[3,4]:this._hasNext?(this._isLoading=!0,n=H.of(this._iid).requestQueue,e=new Tn(I(I({},this),{token:this._token})),[4,n.send(e)]):[3,3]:[3,6];case 1:return r=t.sent(),a=r.as(Nn),i=a.channels,s=a.token,this._token=s,this._hasNext=!!s,[4,pn.of(this._iid).upsertChannelsToCache(i)];case 2:return t.sent(),this._isLoading=!1,[2,i];case 3:return[2,[]];case 4:throw T.queryInProgress;case 5:return[3,7];case 6:throw T.invalidParameters;case 7:return[2]}}))}))},s}(D),In=function(r){function a(){var n=null!==r&&r.apply(this,arguments)||this;return n.name="openChannel",n}return n(a,r),a.prototype.init=function(n,e){var t=e.sdkState,a=e.dispatcher,i=e.sessionManager,s=e.requestQueue,o=e.logger,u=e.cacheContext;r.prototype.init.call(this,n,{sdkState:t,dispatcher:a,sessionManager:i,requestQueue:s,logger:o,cacheContext:u}),this._manager=new pn(n,{sdkState:t,dispatcher:a,requestQueue:s})},a.prototype.createOpenChannelListQuery=function(n){return void 0===n&&(n={}),new Hn(this._iid,n)},a.prototype.addOpenChannelHandler=function(n,e){this._manager.addHandler(n,e)},a.prototype.removeOpenChannelHandler=function(n){this._manager.removeHandler(n)},a.prototype.removeAllOpenChannelHandlers=function(){this._manager.clearHandler()},a.prototype.buildOpenChannelFromSerializedData=function(n){return this._manager.buildOpenChannelFromSerializedData(n)},a.prototype.getChannel=function(n){return e(this,void 0,void 0,(function(){return t(this,(function(e){return[2,this._manager.getChannel(n)]}))}))},a.prototype.getChannelWithoutCache=function(n){return e(this,void 0,void 0,(function(){return t(this,(function(e){return[2,this._manager.getChannelWithoutCache(n)]}))}))},a.prototype.createChannel=function(n){return e(this,void 0,void 0,(function(){return t(this,(function(e){return[2,this._manager.createChannel(n)]}))}))},a.prototype.createChannelWithOperatorUserIds=function(n,r,a,i,s){return e(this,void 0,void 0,(function(){var e;return t(this,(function(t){return(e=new rn).name=n,e.coverUrlOrImage=r,e.data=a,e.operatorUserIds=i,e.customType=s,[2,this._manager.createChannel(e)]}))}))},a}(A);export{En as OpenChannel,rn as OpenChannelCreateParams,tn as OpenChannelCreateParamsProperties,wn as OpenChannelHandler,Hn as OpenChannelListQuery,In as OpenChannelModule,vn as OpenChannelUpdateParams,fn as OpenChannelUpdateParamsProperties,yn as ParticipantListQuery}; |
{ | ||
"version": "4.0.0-beta.8", | ||
"version": "4.0.0-beta.9", | ||
"description": "Sendbird SDK for JavaScript", | ||
@@ -4,0 +4,0 @@ "name": "@sendbird/chat", |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
582655
18
3779
35