UNPKG

laudantiumculpa

Version:
1 lines 207 kB
var e,t=require("./__bundle-744bbd74.cjs");class s{constructor(e,t,s){var i,n;this.width=0,this.height=0,this.realWidth=0,this.realHeight=0,this._requireAuth=!1,this._iid=e,this.plainUrl=t.url,this.width=t.width,this.height=t.height,this.realWidth=null!==(i=t.real_width)&&void 0!==i?i:t.width,this.realHeight=null!==(n=t.real_height)&&void 0!==n?n:t.height,this._requireAuth=s}static payloadify(e){return e instanceof s?t.deundefined(t.undefineNullProps({url:e.plainUrl,width:e.width,height:e.height,real_width:e.realWidth,real_height:e.realHeight})):t.deundefined(t.undefineNullProps({url:"",width:e.maxWidth,height:e.maxHeight,real_width:0,real_height:0}))}get url(){const{sessionManager:e}=t.Vault.of(this._iid);return this._requireAuth&&e.ekey?`${this.plainUrl}?auth=${e.ekey}`:this.plainUrl}}class i extends t.APIRequestCommand{constructor(e){if(super(),this.method=t.APIRequestMethod.POST,this.path=`${t.API_PATH_UPLOAD}`,this.params=t.deundefined({file:e.file,channel_url:e.channelUrl}),e.thumbnailSizes)for(let t=0;t<e.thumbnailSizes.length;t++){const{maxWidth:s,maxHeight:i}=e.thumbnailSizes[t];this.params[`thumbnail${t+1}`]=`${s},${i}`}this.requestId=e.requestId}}class n extends t.APIResponseCommand{constructor(e,t){var i,n,a,r;super(e,t),this.url=t.url,this.fileSize=null!==(i=t.file_size)&&void 0!==i?i:0,this.thumbnails=null!==(a=null===(n=t.thumbnails)||void 0===n?void 0:n.map((t=>new s(e,t,!1))))&&void 0!==a?a:[],this.requireAuth=null!==(r=t.require_auth)&&void 0!==r&&r}}class a extends t.InstancedObject{constructor(e,s){var i,n,a,r,o;super(e),this.replyCount=0,this.memberCount=0,this.lastRepliedAt=0,this.updatedAt=0,this.replyCount=null!==(i=s.reply_count)&&void 0!==i?i:0,this.memberCount=null!==(n=s.member_count)&&void 0!==n?n:0,this.mostRepliedUsers=s.most_replies&&t.isArrayOf("object",s.most_replies)?s.most_replies.map((e=>new t.User(this._iid,e))):[],this.unreadReplyCount=null!==(a=s.unread_message_count)&&void 0!==a?a:0,this.isPushNotificationEnabled="number"==typeof s.push_enabled?s.push_enabled>0:void 0,this.lastRepliedAt=null!==(r=s.last_replied_at)&&void 0!==r?r:0,this.updatedAt=null!==(o=s.updated_at)&&void 0!==o?o:0}static payloadify(e){return t.deundefined(t.undefineNullProps(Object.assign(Object.assign({},super.payloadify(e)),{reply_count:e.replyCount,unread_message_count:e.unreadReplyCount,member_count:e.memberCount,most_replies:Array.isArray(e.mostRepliedUsers)?e.mostRepliedUsers.map((e=>t.User.payloadify(e))):[],push_enabled:"boolean"==typeof e.isPushNotificationEnabled?e.isPushNotificationEnabled?1:0:void 0,last_replied_at:e.lastRepliedAt,updated_at:e.updatedAt})))}get _isUpdateRequired(){return void 0===this.unreadReplyCount||void 0===this.isPushNotificationEnabled}_updateFrom(e){var t,s;this.unreadReplyCount=null!==(t=e.unreadReplyCount)&&void 0!==t?t:this.unreadReplyCount,this.isPushNotificationEnabled=null!==(s=e.isPushNotificationEnabled)&&void 0!==s?s:this.isPushNotificationEnabled}}exports.ReactionEventOperation=void 0,(e=exports.ReactionEventOperation||(exports.ReactionEventOperation={})).ADD="add",e.DELETE="delete";class r{constructor(e){this.messageId=0,this.operation=null,this.updatedAt=0;const s=t.isTypeOf("string",e.msg_id)?parseInt(e.msg_id):e.msg_id,i=e.user_id,n=e.operation?e.operation.toLowerCase():null,a=e.reaction,r=e.updated_at;s&&t.isTypeOf("string",i)&&t.isTypeOf("string",n)&&t.isEnumOf(exports.ReactionEventOperation,n)&&t.isTypeOf("string",a)&&a&&t.isTypeOf("number",r)&&(this.messageId=s,this.userId=i,this.key=a,this.operation=n,this.updatedAt=r)}}class o{constructor(e){var s;const i=e.key,n=null!==(s=[...e.user_ids])&&void 0!==s?s:[],a=e.updated_at;t.isTypeOf("string",i)&&i&&t.isArrayOf("string",n)&&n.length>0&&t.isTypeOf("number",a)&&(this.key=i,this.userIds=n,this.updatedAt=a);const r={};for(const e of this.userIds)r[e]=this.updatedAt;this._version=r}get isEmpty(){return 0===this.userIds.length}static payloadify(e){return t.deundefined(t.undefineNullProps({key:e.key,user_ids:e.userIds,updated_at:e.updatedAt}))}applyEvent(e){if(e.key===this.key&&this.updatedAt<=e.updatedAt){if(!this._version[e.userId]||this._version[e.userId]<=e.updatedAt){const t=this.userIds.indexOf(e.userId);switch(e.operation){case exports.ReactionEventOperation.ADD:t<0&&this.userIds.push(e.userId);break;case exports.ReactionEventOperation.DELETE:t>=0&&this.userIds.splice(t,1)}this._version[e.userId]=e.updatedAt}this.updatedAt=Math.max(this.updatedAt,e.updatedAt)}}}class l{constructor(e){this.secureUrl=null,this.type=null,this.width=0,this.height=0,this.alt=null,this.url=e.url,e.secure_url&&(this.secureUrl=e.secure_url),e.type&&(this.type=e.type),e.width&&(this.width=e.width),e.height&&(this.height=e.height),e.alt&&(this.alt=e.alt)}static payloadify(e){var s,i;return t.deundefined(t.undefineNullProps({url:e.url,secure_url:e.secureUrl,type:e.type,width:null!==(s=e.width)&&void 0!==s?s:0,height:null!==(i=e.height)&&void 0!==i?i:0,alt:e.alt}))}}class d{constructor(e){this.title=null,this.url=null,this.description=null,this.defaultImage=null,e["og:title"]&&(this.title=e["og:title"]),e["og:url"]&&(this.url=e["og:url"]),e["og:description"]&&(this.description=e["og:description"]),e["og:image"]&&(this.defaultImage=new l(e["og:image"]))}static payloadify(e){return t.deundefined(t.undefineNullProps({"og:title":e.title,"og:url":e.url,"og:description":e.description,"og:image":e.defaultImage?l.payloadify(e.defaultImage):null}))}}class u{constructor(e){var t,s;this.volume=0,this.name=null!==(t=e.name)&&void 0!==t?t:"default",this.volume=null!==(s=e.volume)&&void 0!==s?s:1}serialize(){return{name:this.name,volume:this.volume}}static payloadify(e){return t.deundefined(t.undefineNullProps({name:e.name,volume:e.volume}))}}var c;exports.FeedbackRating=void 0,(c=exports.FeedbackRating||(exports.FeedbackRating={})).GOOD="good",c.BAD="bad";class h{constructor(e){this.id=e.id,this.rating=e.rating,this.comment=e.comment}static parseFeedbackStatusFromPayload(e){return e&&null!==e.id&&null!==e.rating?"SUBMITTED":"NOT_APPLICABLE"}static payloadify(e){return t.deundefined(t.undefineNullProps({id:e.id,rating:e.rating,comment:e.comment}))}}class p extends t.User{constructor(e,s){var i;super(e,s),this.isBlockedByMe=!1,this.role=t.isEnumOf(t.Role,s.role)?s.role:t.Role.NONE,this.isBlockedByMe=null!==(i=s.is_blocked_by_me)&&void 0!==i&&i}static payloadify(e){return t.deundefined(t.undefineNullProps(Object.assign(Object.assign({},super.payloadify(e)),{role:e.role,is_blocked_by_me:e.isBlockedByMe})))}}class m{constructor(e){this.key=e.key,this.value=t.isArrayOf("string",e.value)?[...e.value]:[]}static payloadify(e){var s;return t.deundefined(t.undefineNullProps({key:e.key,value:null!==(s=e.value)&&void 0!==s?s:[]}))}}const _=e=>{switch(e){case t.MessageType.BASE:return"";case t.MessageType.USER:return"MESG";case t.MessageType.FILE:return"FILE";case t.MessageType.ADMIN:return"ADMM"}};class g extends t.InstancedObject{constructor(e,s){var i,n,a,r,o,l,d,u,c,h;super(e),this.channelType=t.ChannelType.BASE,this.messageType=t.MessageType.BASE,this.mentionType=null,this.mentionedUsers=null,this.mentionedUserIds=null,this.metaArrays=[],this.extendedMessage={},this.createdAt=0,this.updatedAt=0,this.channelUrl=s.channel_url,this.channelType=t.isEnumOf(t.ChannelType,s.channel_type)?s.channel_type:t.ChannelType.GROUP,s.channel&&(s.channel.channel_url&&(this.channelUrl=s.channel.channel_url),s.channel.channel_type&&(this.channelType=s.channel.channel_type)),this.data=null!==(i=s.data)&&void 0!==i?i:"",this.customType=null!==(n=s.custom_type)&&void 0!==n?n:"",this.mentionType=t.isEnumOf(t.MentionType,s.mention_type)?s.mention_type:null,this.mentionedUsers=s.mentioned_users?s.mentioned_users.map((e=>new t.User(this._iid,e))):null,this.mentionedUserIds=null!==(a=s.mentioned_user_ids)&&void 0!==a?a:null,this.mentionedUsers&&!this.mentionedUserIds&&(this.mentionedUserIds=this.mentionedUsers.map((e=>e.userId))),this.mentionedMessageTemplate=null!==(r=s.mentioned_message_template)&&void 0!==r?r:"";const p=null!==(o=s.metaarray)&&void 0!==o?o:{},_=null!==(l=s.metaarray_key_order)&&void 0!==l?l:Object.keys(p).sort(((e,t)=>e.localeCompare(t)));this.metaArrays=[];for(let e=0;e<_.length;e++){const t=_[e];this.metaArrays.push(new m({key:t,value:p[t]||[]}))}s.sorted_metaarray&&(this.metaArrays=s.sorted_metaarray.map((e=>new m(e)))),this.extendedMessage=null!==(d=s.extended_message)&&void 0!==d?d:{},this.extendedMessagePayload=s.extended_message_payload,this.createdAt=null!==(c=null!==(u=s.created_at)&&void 0!==u?u:s.ts)&&void 0!==c?c:0,this.updatedAt=null!==(h=s.updated_at)&&void 0!==h?h:0}static payloadify(e){var s,i;return t.deundefined(t.undefineNullProps(Object.assign(Object.assign({},super.payloadify(e)),{channel_url:e.channelUrl,channel_type:e.channelType,type:_(e.messageType),data:e.data,custom_type:e.customType,mention_type:e.mentionType,mentioned_user_ids:e.mentionedUserIds,mentioned_users:null===(s=e.mentionedUsers)||void 0===s?void 0:s.map((e=>t.User.payloadify(e))),mentioned_message_template:e.mentionedMessageTemplate,sorted_metaarray:null===(i=e.metaArrays)||void 0===i?void 0:i.map((e=>m.payloadify(e))),extended_message:e.extendedMessage,extended_message_payload:e.extendedMessagePayload,created_at:e.createdAt,updated_at:e.updatedAt})))}isIdentical(e){return!0}isEqual(e){return t.deepEqual(this,e)}isUserMessage(){return this.messageType===t.MessageType.USER}isFileMessage(){return this.messageType===t.MessageType.FILE&&!Object.prototype.hasOwnProperty.call(this,"fileInfoList")}isMultipleFilesMessage(){return this.messageType===t.MessageType.FILE&&Object.prototype.hasOwnProperty.call(this,"fileInfoList")}isAdminMessage(){return this.messageType===t.MessageType.ADMIN}hasForm(){var e,t;return!!(null===(t=null===(e=this.extendedMessagePayload)||void 0===e?void 0:e.forms)||void 0===t?void 0:t[0])}serialize(){return t.serialize(this)}getMetaArraysByKeys(e){return this.metaArrays.filter((t=>e.includes(t.key)))}}var y,f,v;exports.FormFieldInputType=void 0,(y=exports.FormFieldInputType||(exports.FormFieldInputType={})).Text="text",y.Phone="phone",y.Email="email",y.Password="password";class I{constructor(e,t,s){this.messageId=e,this.key=t,this.fields=s,this.formKey=t}get isSubmitted(){return void 0!==this.answers&&Object.keys(this.answers).length>0}get isSubmittable(){return this.fields.every((e=>e.isSubmittable))}getFieldAnswer(e){var t;return null===(t=this.answers)||void 0===t?void 0:t[e]}static payloadify(e){var s;return t.deundefined(t.undefineNullProps({key:null!==(s=e.formKey)&&void 0!==s?s:e.key,fields:e.fields.map((e=>E.payloadify(e)))}))}static isFormPayload(e){var t;return Boolean(null===(t=null==e?void 0:e.forms)||void 0===t?void 0:t[0])}}class E{constructor(e){this.key=e.key,this.inputType=e.input_type,this.title=e.title,this.required=e.required,this.regex=e.regex,this.placeholder=e.placeholder,this.fieldKey=e.key}isValid(e){if(!this.regex)return!0;try{return new RegExp(this.regex).test(e)}catch(e){return!0}}get isSubmittable(){return!(null!=this.temporaryAnswer&&!this.isValid(this.temporaryAnswer)||this.required&&null==this.temporaryAnswer)}static payloadify(e){var s;return t.deundefined(t.undefineNullProps({key:null!==(s=e.fieldKey)&&void 0!==s?s:e.key,input_type:e.inputType,title:e.title,required:e.required,regex:e.regex,placeholder:e.placeholder}))}}class T extends t.InstancedObject{constructor(e,s){var i,n;super(e),this.channelUrl=null!==(i=s.channel_url)&&void 0!==i?i:"",this.channelType=null!==(n=s.channel_type)&&void 0!==n?n:t.ChannelType.GROUP,this.reader=new t.User(this._iid,s.user),this.readAt=s.ts}}class b extends t.WebSocketRequestCommand{constructor({channelUrl:e}){super({code:"READ",ackRequired:!0,payload:{channel_url:e}})}}class S extends t.APIRequestCommand{constructor(e){super();const{channelUrl:s,channelType:i,userId:n,notificationIds:a}=e;this.method=t.APIRequestMethod.PUT,this.path=`${t.getChannelApiPathByType(i)}/${encodeURIComponent(s)}/messages/mark_as_read`,this.params=t.deundefined(t.undefineNullProps({user_id:n,message_ids:a}))}}class M extends t.WebSocketEventCommand{constructor(e,t,s){super(e,"READ",s),this.readStatus=new T(e,s)}}class A extends t.APIResponseCommand{constructor(e,t){super(e,t),this.readAt=t.ts,this.unreadMessageCount=t.unread_message_count}}class O extends t.WebSocketRequestCommand{constructor({channelUrl:e,messageId:t}){super({code:"READ",ackRequired:!0,payload:{channel_url:e,parent_message_id:t}})}}class C extends t.APIRequestCommand{constructor({channelType:e,channelUrl:s,messageId:i,pushEnabled:n}){super(),this.method=t.APIRequestMethod.PUT,this.path=`${t.getChannelApiPathByType(e)}/${encodeURIComponent(s)}/messages/${i}/thread_push`,this.params={push_enabled:n}}}class w extends t.APIRequestCommand{constructor(e){super(),this.method=t.APIRequestMethod.POST,this.path=`${t.API_PATH_GROUP_CHANNELS}/${encodeURIComponent(e.channelUrl)}/messages/${e.messageId}/submit_forms`,this.params=t.deundefined({forms:e.forms})}}class P extends t.APIRequestCommand{constructor({channelType:e,channelUrl:s,messageId:i,rating:n,comment:a}){super(),this.method=t.APIRequestMethod.POST,this.path=`${t.getChannelApiPathByType(e)}/${encodeURIComponent(s)}/messages/${i}/feedbacks`,this.params={rating:n,comment:a}}}class N extends t.APIResponseCommand{constructor(e,t){super(e,t),this.feedback=new h(t)}}class U extends t.APIRequestCommand{constructor({channelType:e,channelUrl:s,messageId:i,feedbackId:n,rating:a,comment:r}){super(),this.method=t.APIRequestMethod.PUT,this.path=`${t.getChannelApiPathByType(e)}/${encodeURIComponent(s)}/messages/${i}/feedbacks/${n}`,this.params={rating:a,comment:r}}}class R extends t.APIResponseCommand{constructor(e,t){super(e,t),this.feedback=new h(t)}}class x extends t.APIRequestCommand{constructor({channelType:e,channelUrl:s,messageId:i,feedbackId:n}){super(),this.method=t.APIRequestMethod.DELETE,this.path=`${t.getChannelApiPathByType(e)}/${encodeURIComponent(s)}/messages/${i}/feedbacks/${n}`}}class k extends t.InstancedObject{constructor(e,t){var i,n,a,r,o;super(e),this.plainUrl="",this.fileName=null,this.mimeType=null,this.fileSize=0,this.thumbnails=[],this._requireAuth=!1,this.plainUrl=null!==(i=t.url)&&void 0!==i?i:"",this.fileName=null!==(n=t.file_name)&&void 0!==n?n:null,this.mimeType=null!==(a=t.file_type)&&void 0!==a?a:null,this.fileSize=null!==(r=t.file_size)&&void 0!==r?r:0,this._requireAuth=null!==(o=t.require_auth)&&void 0!==o&&o,this.thumbnails=t.thumbnails?t.thumbnails.map((e=>{var t;return new s(this._iid,"string"==typeof e?{url:e,width:0,height:0}:Object.assign(Object.assign({},e),{url:(null!==(t=e.url)&&void 0!==t?t:"").split("auth=")[0]}),this._requireAuth)})):[]}static payloadify(e){var s;return t.deundefined(t.undefineNullProps({url:e.plainUrl,file_name:e.fileName,file_type:e.mimeType,file_size:e.fileSize,thumbnails:null===(s=e.thumbnails)||void 0===s?void 0:s.map((e=>{var t;return{url:(null!==(t=e.plainUrl)&&void 0!==t?t:"").split("auth=")[0],width:e.width,height:e.height,real_width:e.realWidth,real_height:e.realHeight}})),require_auth:e._requireAuth}))}get url(){const{sessionManager:e}=t.Vault.of(this._iid);return this._requireAuth&&e.ekey?`${this.plainUrl}?auth=${e.ekey}`:this.plainUrl}}class L{constructor({channelUrl:e,channelType:t,parentMessage:s}){this.channelUrl=e,this.channelType=t,this.parentMessage=s}}exports.ScheduledStatus=void 0,(f=exports.ScheduledStatus||(exports.ScheduledStatus={})).PENDING="pending",f.SENT="sent",f.FAILED="failed",f.CANCELED="canceled",exports.InternalScheduledStatus=void 0,(v=exports.InternalScheduledStatus||(exports.InternalScheduledStatus={})).PENDING="pending",v.IN_QUEUE="in_queue",v.SENT="sent",v.FAILED="failed",v.CANCELED="canceled",v.REMOVED="removed";class D extends g{constructor(e,t){var s,i,n,r,l,c,p,m,_,g;super(e,t),this.parentMessage=null,this.silent=!1,this.isOperatorMessage=!1,this.threadInfo=null,this.reactions=[],this.appleCriticalAlertOptions=null,this.scheduledInfo=null,this.suggestedReplies=null,this.myFeedback=null,this.myFeedbackStatus="NOT_APPLICABLE",this.forms=null,this._isContinuousMessages=!1,this._scheduledStatus=null,this.messageId=null!==(i=null!==(s=t.msg_id)&&void 0!==s?s:t.message_id)&&void 0!==i?i:0,this.parentMessageId=null!==(n="string"==typeof t.parent_message_id?parseInt(t.parent_message_id):t.parent_message_id)&&void 0!==n?n:0,this.threadInfo=t.thread_info?new a(this._iid,t.thread_info):null,this.reactions=t.reactions?t.reactions.map((e=>new o(e))):[],this.ogMetaData=t.og_tag?new d(t.og_tag):null,this.silent=null!==(r=t.silent)&&void 0!==r&&r,this.isOperatorMessage=null!==(l=t.is_op_msg)&&void 0!==l&&l,this.appleCriticalAlertOptions=t.apple_critical_alert_options?new u(t.apple_critical_alert_options):null,"number"==typeof t.scheduled_message_id&&"number"==typeof t.scheduled_at&&t.scheduled_status&&(this.scheduledInfo={scheduledMessageId:t.scheduled_message_id,scheduledAt:t.scheduled_at},this._scheduledStatus=t.scheduled_status),this._isContinuousMessages=null!==(c=t.is_continuous_messages)&&void 0!==c&&c,this.myFeedback=(null===(p=t.feedback)||void 0===p?void 0:p.id)?new h(t.feedback):null,this.myFeedbackStatus=null!==(m=t.my_feedback_status)&&void 0!==m?m:h.parseFeedbackStatusFromPayload(t.feedback),this.suggestedReplies=null!==(g=null===(_=t.extended_message_payload)||void 0===_?void 0:_.suggested_replies)&&void 0!==g?g:null,this.forms=I.isFormPayload(t.extended_message_payload)?t.extended_message_payload.forms.map((e=>new I(this.messageId,e.key,e.fields.map((e=>new E(e)))))):null}static payloadify(e){var s,i;return t.deundefined(t.undefineNullProps(Object.assign(Object.assign({},super.payloadify(e)),{message_id:e.messageId,parent_message_id:e.parentMessageId,thread_info:e.threadInfo?a.payloadify(e.threadInfo):null,reactions:e.reactions.map((e=>o.payloadify(e))),og_tag:e.ogMetaData?d.payloadify(e.ogMetaData):null,silent:e.silent,is_op_msg:e.isOperatorMessage,apple_critical_alert_options:e.appleCriticalAlertOptions?u.payloadify(e.appleCriticalAlertOptions):null,scheduled_message_id:null===(s=e.scheduledInfo)||void 0===s?void 0:s.scheduledMessageId,scheduled_at:null===(i=e.scheduledInfo)||void 0===i?void 0:i.scheduledAt,scheduled_status:e._scheduledStatus,feedback:e.myFeedback?h.payloadify(e.myFeedback):null,my_feedback_status:e.myFeedbackStatus,forms:e.forms?e.forms.map((e=>I.payloadify(e))):null})))}static _getParentMessageInfoPayload(e){return t.deundefined(t.undefineNullProps({type:_(e.messageType),ts:e.createdAt,user:e.sender?p.payloadify(e.sender):null,message:e.message,file:{url:e.plainUrl,name:e.name,type:e.type,require_auth:e.requireAuth},files:Array.isArray(e.fileInfoList)?e.fileInfoList.map((e=>k.payloadify(e))):null}))}isIdentical(e){return this.messageId===e.messageId}applyThreadInfoUpdateEvent(e){return this.messageId===e.targetMessageId&&(e.threadInfo._isUpdateRequired&&this.threadInfo&&e.threadInfo._updateFrom(this.threadInfo),this.threadInfo=e.threadInfo,!0)}applyReactionEvent(e){if(this.messageId===e.messageId){let t=!1;for(let s=0;s<this.reactions.length;s++)if(this.reactions[s].key===e.key){this.reactions[s].applyEvent(e),this.reactions[s].isEmpty&&this.reactions.splice(s,1),t=!0;break}t||"add"!==e.operation||this.reactions.push(new o(o.payloadify({key:e.key,userIds:[e.userId],updatedAt:e.updatedAt})))}}applyParentMessage(e){if(!this.parentMessage)return this.parentMessage=e,!0;if(this.parentMessageId===e.messageId){const t=this.parentMessage.updatedAt;if(e.updatedAt>=t)return this.parentMessage=e,!0}return!1}_triggerThreadInfoUpdatedEvent(){return t.__awaiter(this,void 0,void 0,(function*(){const{dispatcher:e}=t.Vault.of(this._iid);e.dispatch(new L({channelType:t.ChannelType.GROUP,channelUrl:this.channelUrl,parentMessage:this})),e.dispatch(new t.MessageUpdateEventCommand({messages:[this],source:t.CollectionEventSource.EVENT_THREAD_INFO_UPDATED}))}))}markThreadAsRead(){return t.__awaiter(this,void 0,void 0,(function*(){const{requestQueue:e}=t.Vault.of(this._iid),s=new O({channelUrl:this.channelUrl,messageId:this.messageId});yield e.send(s),this.threadInfo&&0!==this.threadInfo.unreadReplyCount&&(this.threadInfo.unreadReplyCount=0,yield this._triggerThreadInfoUpdatedEvent())}))}setPushNotificationEnabled(e){return t.__awaiter(this,void 0,void 0,(function*(){const{requestQueue:s}=t.Vault.of(this._iid),i=new C({channelUrl:this.channelUrl,channelType:this.channelType,messageId:this.messageId,pushEnabled:e});yield s.send(i),this.threadInfo&&this.threadInfo.isPushNotificationEnabled!==e&&(this.threadInfo.isPushNotificationEnabled=e)}))}submitForm(e){return t.__awaiter(this,void 0,void 0,(function*(){t.unless(e.form&&e.form instanceof I||t.isTypeOf("string",e.formId)&&t.isTypeOf("object",e.answers)).throw(t.SendbirdError.invalidParameters);const{requestQueue:s,sdkState:i,logger:n}=t.Vault.of(this._iid);if(e.form){const n=e.form;if(!n.isSubmittable)throw new t.SendbirdError({code:t.SendbirdErrorCode.INVALID_PARAMETER,message:"The given form is not submittable."});if(n.isSubmitted)throw new t.SendbirdError({code:t.SendbirdErrorCode.INVALID_PARAMETER,message:"The given form is already submitted."});if(n.messageId!=this.messageId)throw new t.SendbirdError({code:t.SendbirdErrorCode.INVALID_PARAMETER,message:"This form does not belong to the message."});const a=n.fields.reduce(((e,t)=>(e[t.key]=t.temporaryAnswer,e)),{}),r=new w({userId:i.userId,channelUrl:this.channelUrl,channelType:this.channelType,messageId:this.messageId,forms:[{form_key:n.key,data:a}]});yield s.send(r)}else if(e.formId&&e.answers){n.warn("The submitForm method with formId and answers is deprecated. Use submitForm({ form: Form }) instead.");const t=new w({userId:i.userId,channelUrl:this.channelUrl,channelType:this.channelType,messageId:this.messageId,forms:[{form_key:e.formId,data:e.answers}]});yield s.send(t)}}))}submitFeedback(e){return t.__awaiter(this,void 0,void 0,(function*(){const{requestQueue:s,dispatcher:i}=t.Vault.of(this._iid),n=new P({channelUrl:this.channelUrl,channelType:this.channelType,messageId:this.messageId,rating:e.rating,comment:e.comment}),a=(yield s.send(n)).as(N);this.myFeedback=a.feedback,this.myFeedbackStatus="SUBMITTED",i.dispatch(new t.MessageUpdateEventCommand({messages:[this],source:t.CollectionEventSource.EVENT_MESSAGE_FEEDBACK_ADDED}))}))}updateFeedback(e){return t.__awaiter(this,void 0,void 0,(function*(){const{requestQueue:s,dispatcher:i}=t.Vault.of(this._iid),n=new U({channelUrl:this.channelUrl,channelType:this.channelType,messageId:this.messageId,feedbackId:e.id,rating:e.rating,comment:e.comment}),a=(yield s.send(n)).as(R);this.myFeedback=a.feedback,this.myFeedbackStatus="SUBMITTED",i.dispatch(new t.MessageUpdateEventCommand({messages:[this],source:t.CollectionEventSource.EVENT_MESSAGE_FEEDBACK_UPDATED}))}))}deleteFeedback(e){return t.__awaiter(this,void 0,void 0,(function*(){const{requestQueue:s,dispatcher:i}=t.Vault.of(this._iid),n=new x({channelUrl:this.channelUrl,channelType:this.channelType,messageId:this.messageId,feedbackId:e});yield s.send(n),this.myFeedback=null,this.myFeedbackStatus="NO_FEEDBACK",i.dispatch(new t.MessageUpdateEventCommand({messages:[this],source:t.CollectionEventSource.EVENT_MESSAGE_FEEDBACK_DELETED}))}))}}class q extends D{constructor(e,s){var i,n,a,r;if(super(e,s),this.reqId="",this.replyToChannel=!1,this.errorCode=0,this.sender=s.user?new p(this._iid,s.user):s.sender_id,this.reqId=null!==(n=null!==(i=s.req_id)&&void 0!==i?i:s.request_id)&&void 0!==n?n:"",this.replyToChannel=null!==(a=s.is_reply_to_channel)&&void 0!==a&&a,s.request_state&&t.isEnumOf(t.SendingStatus,s.request_state)&&(this.sendingStatus=s.request_state),!this.sendingStatus)if(this.messageId>0)this.sendingStatus=t.SendingStatus.SUCCEEDED;else if(this.scheduledInfo)switch(s.scheduled_status&&(this._scheduledStatus=s.scheduled_status),s.scheduled_status){case exports.InternalScheduledStatus.SENT:case exports.InternalScheduledStatus.IN_QUEUE:this.sendingStatus=t.SendingStatus.SUCCEEDED;break;case exports.InternalScheduledStatus.PENDING:this.sendingStatus=t.SendingStatus.SCHEDULED;break;case exports.InternalScheduledStatus.FAILED:case exports.InternalScheduledStatus.REMOVED:this.sendingStatus=t.SendingStatus.FAILED;break;case exports.InternalScheduledStatus.CANCELED:this.sendingStatus=t.SendingStatus.CANCELED}else this.sendingStatus=t.SendingStatus.PENDING;this.errorCode=null!==(r=s.error_code)&&void 0!==r?r:0}static payloadify(e){return t.deundefined(t.undefineNullProps(Object.assign(Object.assign({},super.payloadify(e)),{user:p.payloadify(e.sender),req_id:e.reqId,is_reply_to_channel:e.replyToChannel,request_state:e.sendingStatus,error_code:e.errorCode})))}get isResendable(){return(this.sendingStatus===t.SendingStatus.FAILED||this.sendingStatus===t.SendingStatus.CANCELED)&&t.isResendableError(this.errorCode)}isIdentical(e){return this.messageId>0&&e.messageId>0?this.messageId===e.messageId:this.reqId===e.reqId}}const F={prevResultSize:0,nextResultSize:0,isInclusive:!1,reverse:!1,messageTypeFilter:t.MessageTypeFilter.ALL,customTypesFilter:void 0,senderUserIdsFilter:void 0,includeReactions:!1,includeMetaArray:!1,includeParentMessageInfo:!1},B=e=>t.isTypeOf("number",e.prevResultSize)&&t.isTypeOf("number",e.nextResultSize)&&t.isTypeOf("boolean",e.isInclusive)&&t.isTypeOf("boolean",e.reverse)&&t.isTypeOf("string",e.messageTypeFilter)&&t.isEnumOf(t.MessageTypeFilter,e.messageTypeFilter)&&t.isArrayOf("string",e.customTypesFilter,!0)&&t.isArrayOf("string",e.senderUserIdsFilter,!0)&&t.isTypeOf("boolean",e.includeMetaArray)&&t.isTypeOf("boolean",e.includeReactions)&&t.isTypeOf("boolean",e.includeParentMessageInfo);class j extends D{constructor(e,s){var i,n,a,r;if(super(e,s),this.translations={},this.message=null!==(i=s.message)&&void 0!==i?i:"",this.messageType=t.MessageType.ADMIN,this.translations=null!==(n=s.translations)&&void 0!==n?n:{},s.parent_message_info){const i=s.parent_message_info;this.parentMessage=H(e,t.deundefined(t.undefineNullProps(Object.assign(Object.assign({},i),{message_id:this.parentMessageId,channel_url:this.channelUrl,channel_type:this.channelType,file:i.file,url:null===(a=i.file)||void 0===a?void 0:a.url,require_auth:null===(r=i.file)||void 0===r?void 0:r.require_auth}))))}}static payloadify(e){return t.deundefined(t.undefineNullProps(Object.assign(Object.assign({},super.payloadify(e)),{message:e.message,translations:e.translations,parent_message_info:e.parentMessage?super._getParentMessageInfoPayload(e.parentMessage):null})))}getThreadedMessagesByTimestamp(e,s){return t.__awaiter(this,void 0,void 0,(function*(){const i=Object.assign(Object.assign({},F),s);t.unless(this.messageId>0&&t.isTypeOf("number",e)&&B(i)).throw(t.SendbirdError.invalidParameters);const n=qi.of(this._iid);return yield n.getThreadedMessagesByTimestamp(this,e,i)}))}}class V{constructor(e){var s,i;this.detail={},this.type=null!==(s=e.type)&&void 0!==s?s:"",this.vendor=null!==(i=e.vendor)&&void 0!==i?i:"",e.detail&&t.isTypeOf("object",e.detail)&&!Array.isArray(e.detail)&&(this.detail=e.detail)}static payloadify(e){return t.deundefined(t.undefineNullProps({type:e.type,vendor:e.vendor,detail:e.detail}))}}class z{constructor(e){this.status=e.status,e.original_message_info&&(this.originalMessageInfo={createdAt:e.original_message_info.ts,messageId:e.original_message_info.id})}static payloadify(e){return t.deundefined({status:e.status,original_message_info:e.originalMessageInfo?{id:e.originalMessageInfo.messageId,ts:e.originalMessageInfo.createdAt}:void 0})}}class $ extends q{constructor(e,s){var i,n,a,r,o;if(super(e,s),this.message="",this.messageParams=null,this.translations={},this.translationTargetLanguages=[],this.messageSurvivalSeconds=-1,this.plugins=[],this._poll=null,this.message=s.message,this.messageType=t.MessageType.USER,this.translations=null!==(i=s.translations)&&void 0!==i?i:{},this.translationTargetLanguages=null!==(n=s.target_langs)&&void 0!==n?n:[],0===Object.keys(this.translations).length&&this.translationTargetLanguages.length>0)for(const e of this.translationTargetLanguages)this.translations[e]="";if(this.messageSurvivalSeconds=null!==(a=s.message_survival_seconds)&&void 0!==a?a:-1,this.plugins=s.plugins?s.plugins.map((e=>new V(e))):[],this._poll=s.poll?new t.Poll(this._iid,s.poll):null,s.parent_message_info){const i=s.parent_message_info;this.parentMessage=H(e,t.deundefined(t.undefineNullProps(Object.assign(Object.assign({},i),{created_at:i.ts,message_id:this.parentMessageId,channel_url:this.channelUrl,channel_type:this.channelType,file:i.file,url:null===(r=i.file)||void 0===r?void 0:r.url,require_auth:null===(o=i.file)||void 0===o?void 0:o.require_auth}))))}s.review_info&&(this.messageReviewInfo=new z(s.review_info))}static payloadify(e){return t.deundefined(t.undefineNullProps(Object.assign(Object.assign({},super.payloadify(e)),{message:e.message,translations:e.translations,message_survival_seconds:e.messageSurvivalSeconds,plugins:e.plugins.map((e=>V.payloadify(e))),poll:e._poll?t.Poll.payloadify(e._poll):null,parent_message_info:e.parentMessage?super._getParentMessageInfoPayload(e.parentMessage):null,review_info:e.messageReviewInfo?z.payloadify(e.messageReviewInfo):void 0})))}getThreadedMessagesByTimestamp(e,s){return t.__awaiter(this,void 0,void 0,(function*(){const i=Object.assign(Object.assign({},F),s);t.unless(this.messageId>0&&t.isTypeOf("number",e)&&B(i)).throw(t.SendbirdError.invalidParameters);const n=qi.of(this._iid);return yield n.getThreadedMessagesByTimestamp(this,e,i)}))}applyPoll(e){return!(this._poll&&this._poll.id===e.id&&this._poll.updatedAt>e.updatedAt)&&(this._poll=e,!0)}get poll(){return this._poll}}class Q extends q{constructor(e,s){var i,n,a,r,o;if(super(e,s),this.messageParams=null,this.fileInfoList=[],this.messageSurvivalSeconds=-1,this.messageType=t.MessageType.FILE,this.fileInfoList=null!==(n=null===(i=s.files)||void 0===i?void 0:i.map((t=>new k(e,t))))&&void 0!==n?n:[],this.messageSurvivalSeconds=null!==(a=s.message_survival_seconds)&&void 0!==a?a:-1,s.parent_message_info){const i=s.parent_message_info;this.parentMessage=H(e,t.deundefined(t.undefineNullProps(Object.assign(Object.assign({},i),{created_at:i.ts,message_id:this.parentMessageId,channel_url:this.channelUrl,channel_type:this.channelType,file:i.file,url:null===(r=i.file)||void 0===r?void 0:r.url,require_auth:null===(o=i.file)||void 0===o?void 0:o.require_auth}))))}}getThreadedMessagesByTimestamp(e,s){return t.__awaiter(this,void 0,void 0,(function*(){const i=Object.assign(Object.assign({},F),s);t.unless(this.messageId>0&&t.isTypeOf("number",e)&&B(i)).throw(t.SendbirdError.invalidParameters);const n=qi.of(this._iid);return yield n.getThreadedMessagesByTimestamp(this,e,i)}))}static payloadify(e){return t.deundefined(t.undefineNullProps(Object.assign(Object.assign({},super.payloadify(e)),{files:Array.isArray(e.fileInfoList)?e.fileInfoList.map((e=>k.payloadify(e))):null,message_survival_seconds:e.messageSurvivalSeconds,parent_message_info:e.parentMessage?super._getParentMessageInfoPayload(e.parentMessage):null})))}static _isMultipleFilesMessagePayload(e){const t=e.files;return Array.isArray(t)&&t.length>=2}static _isMultipleFilesMessageSerializedData(e){const t=e.fileInfoList;return Array.isArray(t)}}var K;exports.NotificationMessageStatus=void 0,(K=exports.NotificationMessageStatus||(exports.NotificationMessageStatus={})).SENT="SENT",K.READ="READ";class G extends g{constructor(e,s){var i,n;if(super(e,s),this.notificationData=null,this.notificationId=s.notification_message_id,this.messageType=t.MessageType.ADMIN,this.messageStatus=null!==(i=s.message_status)&&void 0!==i?i:exports.NotificationMessageStatus.SENT,this.priority=null!==(n=s.priority)&&void 0!==n?n:t.NotificationPriority.NORMAL,0===this.extendedMessage.sub_type)try{const{label:e,tags:t=[],template_key:s,template_variables:i}=JSON.parse(this.extendedMessage.sub_data);this.notificationData={label:e,tags:t,templateKey:s,templateVariables:i}}catch(e){}}static payloadify(e){return t.deundefined(t.undefineNullProps(Object.assign(Object.assign({},super.payloadify(e)),{notification_message_id:e.notificationId,message_status:e.messageStatus,priority:e.priority})))}isIdentical(e){return this.notificationId===e.notificationId}}const H=(e,t)=>{if(t.notification_message_id)return new G(e,t);switch(t.type){case"MESG":return new $(e,t);case"FILE":return Q._isMultipleFilesMessagePayload(t)?new Q(e,t):new W(e,t);case"ADMM":case"BRDM":return new j(e,t);default:return null}};class W extends q{constructor(e,i){var n,a,r,o,l,d,u,c,h,p,m,_,g,y;super(e,i),this.messageParams=null,this.plainUrl="",this.requireAuth=!1,this.thumbnails=[],this.messageSurvivalSeconds=-1,this.messageType=t.MessageType.FILE;const f=i.file;if(this.plainUrl=(null!==(a=null!==(n=null==f?void 0:f.url)&&void 0!==n?n:i.url)&&void 0!==a?a:"").split("?auth=")[0],this.name=null!==(o=null!==(r=null==f?void 0:f.name)&&void 0!==r?r:i.name)&&void 0!==o?o:"File",this.size=null!==(d=null!==(l=null==f?void 0:f.size)&&void 0!==l?l:i.size)&&void 0!==d?d:0,this.data=null!==(c=null!==(u=null==f?void 0:f.data)&&void 0!==u?u:i.custom)&&void 0!==c?c:"",this.type=f?null!==(h=f.type)&&void 0!==h?h:"":null!==(p=i.type)&&void 0!==p?p:"",this.requireAuth=null!==(m=i.require_auth)&&void 0!==m&&m,this.thumbnails=i.thumbnails?i.thumbnails.map((e=>{var t;return new s(this._iid,"string"==typeof e?{url:e,width:0,height:0}:Object.assign(Object.assign({},e),{url:(null!==(t=e.url)&&void 0!==t?t:"").split("auth=")[0]}),this.requireAuth)})):[],this.messageSurvivalSeconds=null!==(_=i.message_survival_seconds)&&void 0!==_?_:-1,i.parent_message_info){const s=i.parent_message_info;this.parentMessage=H(e,t.deundefined(t.undefineNullProps(Object.assign(Object.assign({},s),{created_at:s.ts,message_id:this.parentMessageId,channel_url:this.channelUrl,channel_type:this.channelType,file:s.file,url:null===(g=s.file)||void 0===g?void 0:g.url,require_auth:null===(y=s.file)||void 0===y?void 0:y.require_auth}))))}}static payloadify(e){var s;return t.deundefined(t.undefineNullProps(Object.assign(Object.assign({},super.payloadify(e)),{url:e.plainUrl,require_auth:e.requireAuth,file:{name:e.name,size:e.size,type:e.type,data:e.data},thumbnails:null===(s=e.thumbnails)||void 0===s?void 0:s.map((e=>({url:e.plainUrl,width:e.width,height:e.height,real_width:e.realWidth,real_height:e.realHeight}))),message_survival_seconds:e.messageSurvivalSeconds,parent_message_info:e.parentMessage?super._getParentMessageInfoPayload(e.parentMessage):null})))}get url(){const{sessionManager:e}=t.Vault.of(this._iid);return this.requireAuth&&e.ekey?`${this.plainUrl}?auth=${e.ekey}`:this.plainUrl}getThreadedMessagesByTimestamp(e,s){return t.__awaiter(this,void 0,void 0,(function*(){const i=Object.assign(Object.assign({},F),s);t.unless(this.messageId>0&&t.isTypeOf("number",e)&&B(i)).throw(t.SendbirdError.invalidParameters);const n=qi.of(this._iid);return yield n.getThreadedMessagesByTimestamp(this,e,i)}))}}class Y extends t.InstancedObject{static getPlainUrl(e){return e instanceof Y?e._plainUrl:e.fileUrl}constructor(e,{file:t,fileUrl:s,fileName:i,fileSize:n,mimeType:a,thumbnailSizes:r,_uploadedMetaData:o,_thumbnails:l}){super(e),this._plainUrl=s,this.file=t,this.fileName=i,this.fileSize=n,this.mimeType=a,this.thumbnailSizes=r,this._uploadedMetaData=o,this._thumbnails=l}get fileUrl(){var e;const{sessionManager:s}=t.Vault.of(this._iid);return this._plainUrl&&(null===(e=this._uploadedMetaData)||void 0===e?void 0:e.requireAuth)&&s.ekey?`${this._plainUrl}?auth=${s.ekey}`:this._plainUrl}set fileUrl(e){this._plainUrl=e}toJSON(){return{file:this.file,fileUrl:this._plainUrl,fileName:this.fileName,fileSize:this.fileSize,mimeType:this.mimeType,thumbnailSizes:this.thumbnailSizes,_thumbnails:this._thumbnails,_uploadedMetaData:this._uploadedMetaData}}}class J extends t.WebSocketRequestCommand{constructor(e){var i,n,a,r;let o=[];e.mentionType===t.MentionType.USERS&&(e.mentionedUserIds?o=e.mentionedUserIds:e.mentionedUsers&&(o=e.mentionedUsers.map((e=>e.userId)))),super({code:"FILE",ackRequired:!0,payload:t.deundefined(t.undefineNullProps({channel_url:e.channelUrl,files:e.files?te(e.files):null,url:e.url,name:null!==(i=e.fileName)&&void 0!==i?i:"",type:null!==(n=e.mimeType)&&void 0!==n?n:"",size:null!==(a=e.fileSize)&&void 0!==a?a:0,custom:e.data,custom_type:e.customType,thumbnails:null===(r=e._thumbnails)||void 0===r?void 0:r.map((e=>s.payloadify(e))),require_auth:e.requireAuth,metaarray:e.metaArrays,mention_type:e.mentionType,mentioned_user_ids:o,push_option:e.pushNotificationDeliveryOption&&e.pushNotificationDeliveryOption!==t.PushNotificationDeliveryOption.DEFAULT?e.pushNotificationDeliveryOption:void 0,apple_critical_alert_options:e.appleCriticalAlertOptions?u.payloadify(e.appleCriticalAlertOptions):null,silent:e.silent,reply_to_channel:e.isReplyToChannel,parent_message_id:e.parentMessageId?e.parentMessageId:null,req_id:e.reqId,pin_message:e.isPinnedMessage}))})}}class X extends t.APIRequestCommand{constructor(e){var i,n;super();let a=[];e.mentionType===t.MentionType.USERS&&(e.mentionedUserIds?a=e.mentionedUserIds:e.mentionedUsers&&(a=e.mentionedUsers.map((e=>e.userId)))),this.method=t.APIRequestMethod.POST,this.path=`${t.getChannelApiPathByType(e.channelType)}/${encodeURIComponent(e.channelUrl)}/messages`,this.params=t.deundefined(t.undefineNullProps({message_type:t.MessageType.FILE,user_id:e.userId,files:e.files?te(e.files):null,url:e.fileUrl,mention_type:e.mentionType,mentioned_user_ids:a,file_name:e.fileName,file_size:e.fileSize,file_type:e.mimeType,data:e.data,custom_type:e.customType,thumbnails:null===(i=e._thumbnails)||void 0===i?void 0:i.map((e=>s.payloadify(e))),require_auth:e.requireAuth,sorted_metaarray:null===(n=e.metaArrays)||void 0===n?void 0:n.map((e=>m.payloadify(e))),push_option:e.pushNotificationDeliveryOption,parent_message_id:e.parentMessageId?e.parentMessageId:null,apple_critical_alert_options:e.appleCriticalAlertOptions?u.payloadify(e.appleCriticalAlertOptions):null,reply_to_channel:e.isReplyToChannel,req_id:e.reqId,pin_message:e.isPinnedMessage}))}}class Z extends t.WebSocketEventCommand{constructor(e,s,i){var n,a,r,o;super(e,"FILE",i),this.message=i.files&&i.files.length>=2?new Q(e,i):new W(e,i);const{sdkState:l}=t.Vault.of(e);this.isMentioned=t.checkIfMentioned(this.message.mentionType,null!==(r=null!==(n=this.message.mentionedUserIds)&&void 0!==n?n:null===(a=this.message.mentionedUsers)||void 0===a?void 0:a.map((e=>e.userId)))&&void 0!==r?r:[],l.userId),this.forceUpdateLastMessage=null!==(o=i.force_update_last_message)&&void 0!==o&&o}}class ee extends t.APIResponseCommand{constructor(e,s){var i,n,a,r;super(e,s),this.message=s.files&&s.files.length>=2?new Q(e,s):new W(e,s);const{sdkState:o}=t.Vault.of(e);this.isMentioned=t.checkIfMentioned(this.message.mentionType,null!==(a=null!==(i=this.message.mentionedUserIds)&&void 0!==i?i:null===(n=this.message.mentionedUsers)||void 0===n?void 0:n.map((e=>e.userId)))&&void 0!==a?a:[],o.userId),this.forceUpdateLastMessage=null!==(r=s.force_update_last_message)&&void 0!==r&&r}}function te(e){return e.map((e=>{var i,n;return t.deundefined(t.undefineNullProps({url:Y.getPlainUrl(e),file_name:e.fileName,file_type:e.mimeType,file_size:e.fileSize,thumbnails:null===(i=e._thumbnails)||void 0===i?void 0:i.map((e=>s.payloadify(e))),require_auth:null===(n=e._uploadedMetaData)||void 0===n?void 0:n.requireAuth}))}))}var se;!function(e){e[e.PENDING=0]="PENDING",e[e.UPLOADING=1]="UPLOADING",e[e.UPLOADED=2]="UPLOADED",e[e.SENDING=3]="SENDING",e[e.FAILED=4]="FAILED"}(se||(se={}));class ie{constructor(e,{sdkState:s,dispatcher:i,requestQueue:n,onlineDetector:a,cacheContext:r}){this._queueMap=new Map,this._iid=e,this._sdkState=s,this._requestQueue=n,this._cacheContext=r,this._dispatcher=i,this._dispatcher.on((e=>{e instanceof t.ConnectionStateChangeCommand&&(this._connectionState=e.stateType)})),this._onlineDetector=a}get _shouldSendThroughWebSocket(){return this._connectionState===t.ConnectionStateType.CONNECTED||this._connectionState===t.ConnectionStateType.CONNECTING||this._connectionState===t.ConnectionStateType.RECONNECTING}_sendFileMessage(e,s){return t.__awaiter(this,void 0,void 0,(function*(){const t=this._createSendFileMessageRequestParams(e,s);if(this._shouldSendThroughWebSocket){const e=new J(t),s=yield this._requestQueue.send(e),{message:i}=s.as(Z);return i}{const e=new X(Object.assign(Object.assign({},t),{userId:this._sdkState.userId})),s=yield this._requestQueue.send(e),{message:i}=s.as(ee);return i}}))}_createSendFileMessageRequestParams(e,t){const s=Object.assign(Object.assign({},t.params),{channelUrl:e.url,channelType:e.channelType,reqId:t.requestId,url:""});if(t.multipleFileUploadInfo){const e=t.params;s.files=e.fileInfoList}else{const e=t.params;s.url=e.fileUrl,s.requireAuth=e.requireAuth}return s}_resolveMessageQueue(e){var s;return t.__awaiter(this,void 0,void 0,(function*(){const i=this._queueMap.get(e.url);if(i)if(i.isResolving)i.isResolveRequestPending=!0;else{i.isResolving=!0;const n=[];let a=!0;for(const r of i.messageQueue)switch(r.state){case se.PENDING:case se.UPLOADING:a=!1,n.push(r);break;case se.UPLOADED:if(a)try{r.state=se.SENDING;const s=yield this._sendFileMessage(e,r);r.deferred.resolve(s),yield t.sleep(100)}catch(e){r.deferred.reject(e)}else n.push(r);break;case se.FAILED:{const e=null!==(s=r.error)&&void 0!==s?s:t.SendbirdError.unknown;r.deferred.reject(e.code===t.SendbirdErrorCode.REQUEST_CANCELED?t.SendbirdError.fileUploadCanceled:e);break}}const r=i.isResolveRequestPending;i.messageQueue=n,i.isResolving=!1,i.isResolveRequestPending=!1,r&&(yield this._resolveMessageQueue(e))}}))}_uploadNextPendingItem(e){var s;return t.__awaiter(this,void 0,void 0,(function*(){const i=this._queueMap.get(e.url);if(i){const n=i.messageQueue.find((e=>e.state===se.PENDING));if(n){if(n.multipleFileUploadInfo){const{uploadIndex:a,uploadCount:r,requestHandler:o}=n.multipleFileUploadInfo,l=n.params,d=l.fileInfoList[a];t.isFile(d.file)&&!(null===(s=d._uploadedMetaData)||void 0===s?void 0:s.isUploaded)?yield this._tryUploadNextItemAndUpdateItemState(e,i,n):n.state=a<r-1?se.PENDING:se.UPLOADED;const u=l.fileInfoList[a],c=n.multipleFileUploadInfo.uploadIndex++;n.multipleFileUploadInfo.isCopy||null==o||o._triggerOnFileUploaded(n.requestId,c,u,n.error)}else{const s=n.params;t.isFile(s.file)?yield this._tryUploadNextItemAndUpdateItemState(e,i,n):(s.thumbnailSizes=[],n.state=se.UPLOADED)}this._uploadNextPendingItem(e),yield this._resolveMessageQueue(e)}}}))}_tryUploadNextItemAndUpdateItemState(e,s,i){return t.__awaiter(this,void 0,void 0,(function*(){const n=yield this._onlineDetector.isOnline(),{sessionManager:a}=t.Vault.of(this._iid);if(!a.currentUser||!n)return i.error=t.SendbirdError.connectionRequired,void(i.state=se.FAILED);if(s.uploadQueue.length<6){i.state=se.UPLOADING,s.uploadQueue.push(i);try{if(i.multipleFileUploadInfo){const{uploadIndex:t,uploadCount:s}=i.multipleFileUploadInfo,n=i.params;yield this._uploadNextFileForMultipleFilesItemAndUpdateParams(e,i,n),i.state=t<s-1?se.PENDING:se.UPLOADED}else{const t=i.params;yield this._uploadNextFileForSingleFileItemAndUpdateParams(e,i,t),i.state=se.UPLOADED}}catch(e){switch(e.code){case t.SendbirdErrorCode.REQUEST_FAILED:i.error=new t.SendbirdError({code:t.SendbirdErrorCode.NETWORK_ERROR,message:"Failed to upload a file."});break;case t.SendbirdErrorCode.REQUEST_CANCELED:i.error=t.SendbirdError.fileUploadCanceled;break;default:i.error=e}i.state=se.FAILED}this._dequeueUploadItem(s,i)}}))}_dequeueUploadItem(e,t){const s=e.uploadQueue.findIndex((e=>e.requestId===t.requestId));s>=0&&e.uploadQueue.splice(s,1)}_uploadNextFileForSingleFileItemAndUpdateParams(e,s,a){var r,o,l;return t.__awaiter(this,void 0,void 0,(function*(){const t=new i({file:a.file,channelUrl:e.url,thumbnailSizes:a.thumbnailSizes,requestId:s.requestId}),d=yield this._requestQueue.send(t),{url:u,fileSize:c=a.fileSize,thumbnails:h=[],requireAuth:p=!1}=d.as(n);a.fileName=null!==(r=a.fileName)&&void 0!==r?r:a.file.name,a.mimeType=null!==(o=a.mimeType)&&void 0!==o?o:a.file.type,a.fileSize=null!==(l=a.fileSize)&&void 0!==l?l:a.file.size,a.fileUrl=u,a.fileSize=c,a.requireAuth=p,a._thumbnails=h}))}_uploadNextFileForMultipleFilesItemAndUpdateParams(e,s,a){var r,o,l;return t.__awaiter(this,void 0,void 0,(function*(){const{uploadIndex:t}=s.multipleFileUploadInfo,d=a.fileInfoList[t],u=new i({file:d.file,channelUrl:e.url,thumbnailSizes:d.thumbnailSizes,requestId:s.requestId}),c=yield this._requestQueue.send(u),{url:h,fileSize:p=d.fileSize,thumbnails:m,requireAuth:_=!1}=c.as(n);d.fileName=null!==(r=d.fileName)&&void 0!==r?r:d.file.name,d.mimeType=null!==(o=d.mimeType)&&void 0!==o?o:d.file.type,d.fileSize=null!==(l=d.fileSize)&&void 0!==l?l:d.file.size,d.file=void 0,d.fileUrl=h,d.fileSize=p,d._thumbnails=m,d._uploadedMetaData=Object.assign(Object.assign({},d._uploadedMetaData),{requireAuth:_,isUploaded:!0}),d instanceof Y||(a.fileInfoList[t]=new Y(this._iid,d))}))}request(e,s,i,n={}){return t.__awaiter(this,void 0,void 0,(function*(){if(!this._queueMap.has(e.url)){const t={messageQueue:[],uploadQueue:[],isResolving:!1,isResolveRequestPending:!1};this._queueMap.set(e.url,t)}const a=this._queueMap.get(e.url),r=new t.Deferred,o={requestId:s,params:i,state:se.PENDING,deferred:r};if(function(e){return"fileInfoList"in e}(i)){const e=i,t=Object.assign({uploadIndex:0,uploadCount:e.fileInfoList.length},n);o.multipleFileUploadInfo=t}return a.messageQueue.push(o),this._uploadNextPendingItem(e),r.promise}))}cancel(e,s){const i=this._queueMap.get(e.url);if(i){const n=s?[i.messageQueue.find((e=>e.requestId===s))]:[...i.messageQueue];for(const s of n)if(s)switch(s.state){case se.PENDING:if(s.state=se.FAILED,s.error=t.SendbirdError.requestCanceled,s.multipleFileUploadInfo&&!s.multipleFileUploadInfo.isCopy){const{uploadIndex:e,requestHandler:i}=s.multipleFileUploadInfo,n=s.params.fileInfoList[e];null==i||i._triggerOnFileUploaded(s.requestId,e,n,t.SendbirdError.fileUploadCanceled)}this._resolveMessageQueue(e);break;case se.UPLOADING:this._requestQueue.cancel(s.requestId),this._dispatcher.dispatch(new t.CancelXMLHttpRequestCommand({requestId:s.requestId}))}}else s&&(this._requestQueue.cancel(s),this._dispatcher.dispatch(new t.CancelXMLHttpRequestCommand({requestId:s})))}}const ne={prevResultSize:0,nextResultSize:0,isInclusive:!1,reverse:!1,messageTypeFilter:t.MessageTypeFilter.ALL,customTypesFilter:void 0,senderUserIdsFilter:void 0,replyType:t.ReplyType.NONE,includeReactions:!1,includeMetaArray:!1,includeParentMessageInfo:!1,includeThreadInfo:!1,showSubchannelMessagesOnly:!1},ae=e=>t.isTypeOf("number",e.prevResultSize)&&t.isTypeOf("number",e.nextResultSize)&&t.isTypeOf("boolean",e.isInclusive)&&t.isTypeOf("boolean",e.reverse)&&t.isTypeOf("string",e.messageTypeFilter)&&t.isEnumOf(t.MessageTypeFilter,e.messageTypeFilter)&&t.isArrayOf("string",e.customTypesFilter,!0)&&t.isArrayOf("string",e.senderUserIdsFilter,!0)&&t.isEnumOf(t.ReplyType,e.replyType)&&t.isTypeOf("boolean",e.includeMetaArray)&&t.isTypeOf("boolean",e.includeReactions)&&t.isTypeOf("boolean",e.includeParentMessageInfo)&&t.isTypeOf("boolean",e.includeThreadInfo)&&t.isTypeOf("boolean",e.showSubchannelMessagesOnly),re={replyType:t.ReplyType.NONE,includeReactions:!1,includeThreadInfo:!1,includeMetaArray:!1,includeParentMessageInfo:!1},oe=e=>t.isEnumOf(t.ReplyType,e.replyType)&&t.isTypeOf("boolean",e.includeReactions)&&t.isTypeOf("boolean",e.includeMetaArray)&&t.isTypeOf("boolean",e.includeParentMessageInfo)&&t.isTypeOf("boolean",e.includeThreadInfo);class le extends t.APIRequestCommand{constructor({channelType:e,channelUrl:s,messageId:i,includeMetaArray:n,includeReactions:a,includeThreadInfo:r,includeParentMessageInfo:o}){super(),this.method=t.APIRequestMethod.GET,this.path=`${t.getChannelApiPathByType(e)}/${encodeURIComponent(s)}/messages/${encodeURIComponent(i)}`,this.params={is_sdk:!0,with_sorted_meta_array:n,include_reactions:a,include_thread_info:r,include_parent_message_info:o,include_poll_details:!0}}}class de extends t.APIResponseCommand{constructor(e,t){super(e,t),this.message=t?H(e,Object.assign({},t)):null}}class ue extends t.APIRequestCommand{constructor({channelType:e,channelUrl:s,timestamp:i,token:n,prevResultSize:a,nextResultSize:r,isInclusive:o,reverse:l,messageTypeFilter:d,customTypesFilter:u,senderUserIdsFilter:c,replyType:h,includeMetaArray:p,includeReactions:m,parentMessageId:_,includeThreadInfo:g,includeParentMessageInfo:y,showSubchannelMessagesOnly:f,checkingHasNext:v,checkingContinuousMessages:I}){super(),this.method=t.APIRequestMethod.GET,this.path=`${t.getChannelApiPathByType(e)}/${encodeURIComponent(s)}/messages`,this.params=t.deundefined(t.undefineNullProps({is_sdk:!0,prev_limit:a,next_limit:r,include:o,reverse:l,message_ts:i,message_id:n,message_type:null!=d?d:null,custom_types:u,sender_ids:c,include_reply_type:h,with_sorted_meta_array:p,include_reactions:m,parent_message_id:_,include_thread_info:g,include_parent_message_info:y,show_subchannel_message_only:f,include_poll_details:!0,checking_has_next:v,checking_continuous_messages:I}))}}class ce extends t.APIResponseCommand{constructor(e,t){super(e,t),void 0!==t.is_continuous_messages&&(this.isContinuousMessages=t.is_continuous_messages),void 0!==t.has_next&&(this.hasNext=t.has_next),this.messages=t.messages.map((t=>H(e,t)))}}class he extends t.APIRequestCommand{constructor({channelType:e,channelUrl:s,timestamp:i,token:n,replyType:a,includeMetaArray:r,includeReactions:o,includeThreadInfo:l,includeParentMessageInfo:d}){super(),this.method=t.APIRequestMethod.GET,this.path=`${t.getChannelApiPathByType(e)}/${encodeURIComponent(s)}/messages/changelogs`,this.params={change_ts:i,token:n,with_sorted_meta_array:r,include_reactions:o,include_thread_info:l,include_reply_type:a,include_parent_message_info:d,include_poll_details:!0}}}class pe extends t.APIResponseCommand{constructor(e,t){super(e,t),this.updatedMessages=t.updated.map((t=>H(e,t))),this.deletedMessagesInfo=t.deleted.map((e=>({messageId:e.message_id,deletedAt:e.deleted_at}))),this.hasMore=t.has_more,this.nex