-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCometChat.js
More file actions
1 lines (1 loc) · 457 KB
/
Copy pathCometChat.js
File metadata and controls
1 lines (1 loc) · 457 KB
1
!function(e,t){if("object"==typeof exports&&"object"==typeof module)module.exports=t();else if("function"==typeof define&&define.amd)define([],t);else{var n=t();for(var r in n)("object"==typeof exports?exports:e)[r]=n[r]}}(window,(function(){return function(e){var t={};function n(r){if(t[r])return t[r].exports;var s=t[r]={i:r,l:!1,exports:{}};return e[r].call(s.exports,s,s.exports,n),s.l=!0,s.exports}return n.m=e,n.c=t,n.d=function(e,t,r){n.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:r})},n.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},n.t=function(e,t){if(1&t&&(e=n(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var r=Object.create(null);if(n.r(r),Object.defineProperty(r,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var s in e)n.d(r,s,function(t){return e[t]}.bind(null,s));return r},n.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return n.d(t,"a",t),t},n.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},n.p="",n(n.s=44)}([function(e,t,n){"use strict";t.__esModule=!0;var r=n(2);t.constants={DEFAULT_STORE:"cometchat",MSG_VER_PRE:"store-ver-pre",MSG_VER_POST:"store-ver-post"},t.DEFAULT_VALUES={ZERO:0,MSGS_LIMIT:30,MSGS_MAX_LIMIT:100,USERS_LIMIT:30,USERS_MAX_LIMIT:100,GROUPS_LIMIT:30,GROUPS_MAX_LIMIT:100,CONVERSATION_MAX_LIMIT:50,CALL_TIMEOUT:45,DEFAULT_MSG_ID:0,DEFAULT_MAX_TYPING_INDICATOR_LIMIT:5,REGION_DEFAULT:"eu",REGION_DEFAULT_EU:"eu",REGION_DEFAULT_US:"us",REGION_DEFAULT_IN:"in",REGION_DEFAULT_PRIVATE:"private"},t.CALLING_COMPONENT_VERSION=4,function(e){e.Public="public",e.Private="private",e.Protected="protected",e.Password="password"}(t.GroupType||(t.GroupType={})),t.GROUP_TYPE={PUBLIC:"public",PRIVATE:"private",PROTECTED:"password",PASSWORD:"password"},function(e){e.Admin="admin",e.Moderator="moderator",e.Member="member"}(t.GroupMemberScope||(t.GroupMemberScope={})),t.GROUP_MEMBER_SCOPE={ADMIN:"admin",MODERATOR:"moderator",PARTICIPANT:"participant"},t.APPINFO={platform:"WEB",sdkVersion:"v2.4.1",apiVersion:"v2.0",sdkVersionWithUnderScore:"2_4_1"},t.SDKHeader={platform:"javascript",sdkVersion:"2.4.1",sdk:"%s@%s"},t.XMPP={host:"encke.cometchat.com",port:7443,ws_url:"/ws/",bind_url:"/http-bind/",deafult_password:"CometChat",PUBSUB_CHANNEL:"pubsub",jid_string:"[%s]%s@%s/%s",bare_jid_string:"[%s]%s@%s",username_string:"[%s]%s",muc_jid_string:"[%s]%s@%s.%s",pubsub_global_string:"[%s]global_presence",pubsub_default_string:"[%s]default",pubsub_role_string:"[%s]%s",xmpp_resource:"javascripts_"+(new Date).getTime(),CONVERSATION:{TYPE:{CHAT:"chat",GROUP_CHAT:"groupchat"}}},t.ANALYTICS={analyticsHost:"metrics-%s.cometchat.io",analyticsVersion:"v1"},t.LOCAL_STORE={COMMON_STORE:"common_store",MESSAGE_LISTENERS_LIST:"message_listeners_list",USERS_STORE:"users_store",MESSAGES_STORE:"messages_store",KEYS_STORE:"keys_store",STORE_STRING:"%s:%s"},t.ResponseConstants={RESPONSE_KEYS:{KEY_DATA:"data",KEY_META:"meta",KEY_CURSOR:"cursor",KEY_ACTION:"action",KEY_MESSAGE:"message",KEY_ERROR:"error",KEY_ERROR_DETAILS:"details",KEY_ERROR_CODE:"code",KEY_ERROR_MESSAGE:"message",KEY_AUTH_TOKEN:"authToken",KEY_WS_CHANNEL:"wsChannel",KEY_IDENTITY:"identity",KEY_SERVICE:"identity",KEY_ENTITIES:"entities",KEY_ENTITITY:"entity",KEY_ENTITYTYPE:"entityType",KEY_ATTACHMENTS:"attachments",CODE_REQUEST_OK:200,CODE_BAD_REQUEST:401,UNREAD_UNDELIVERED_KEYS:{ENTITY:"entity",ENTITY_TYPE:"entityType",ENTITY_Id:"entityId",COUNT:"count"},GROUP_MEMBERS_RESPONSE:{SUCCESS:"success",ERROR:"error",MESSAGE:"message"},KEY_ENTITY_TYPE:{USER:"user",GROUP:"group"}}},t.DELIVERY_RECEIPTS={RECEIVER_ID:"receiverId",RECEIVER_TYPE:"type",RECIPIENT:"recipient",MESSAGE_ID:"messageId",RECEIVED:"delivered",DELIVERED_AT:"deliveredAt",ID:"id",TIME:"time",DELIVERED_TO_ME_AT:"deliveredToMeAt"},t.READ_RECEIPTS={RECEIVER_ID:"receiverId",RECEIVER_TYPE:"type",RECIPIENT:"recipient",MESSAGE_ID:"messageId",READ:"read",READ_AT:"readAt",ID:"id",TIME:"time",READ_BY_ME_AT:"readByMeAt"},t.MessageConstatnts={XMPP_KEYS:{FROM:"from",TO:"to",TYPE:"type",TYPE_USER:"chat",TYPE_GROUP:"groupchat"},TYPE:{TEXT:"text",MEDIA:"media",IMAGE:"image",VIDEO:"video",AUDIO:"audio",FILE:"file",CUSTOM:"custom"},CATEGORY:{MESSAGE:"message",ACTION:"action",CALL:"call",CUSTOM:"custom"},RECEIVER_TYPE:{USER:"user",GROUP:"group"},KEYS:{ATTATCHMENT:"attatchment",ATTATCHMENTS:"attachments",ACTION:"action",TYPE:"type",DATA:"data",ID:"id",MUID:"muid",SENDER:"sender",RECEIVER:"receiver",RECEIVER_ID:"receiverId",CATEGORY:"category",RECEIVER_TYPE:"receiverType",SENT_AT:"sentAt",STATUS:"status",TEXT:"text",URL:"url",METADATA:"metadata",RECEIPTS:"receipts",MY_RECEIPTS:"myReceipt",CUSTOM_DATA:"customData",CUSTOM_SUB_TYPE:"subType",RESOURCE:"resource"},KNOWN_MEDIA_TYPE:{IMAGE:[],VIDEO:[],AUDIO:[],FILE:[]},PAGINATION:{AFFIX:{APPEND:"append",PREPEND:"prepend"},CURSOR_FILEDS:{ID:"id",SENT_AT:"sentAt"},CURSOR_AFFIX_DEFAULT:"prepend",CURSOR_FIELD_DEFAULT:"sentAt",KEYS:{PER_PAGE:"per_page",CURSOR_AFFIX:"cursorAffix",AFFIX:"affix",CURSOR_FIELD:"cursorField",CURSOR_VALUE:"cursorValue",UID:"uid",SENT_AT:"sentAt",ID:"id",CURRENT_PAGE:"page",UNREAD:"unread",HIDE_MESSAGES_FROM_BLOCKED_USER:"hideMessagesFromBlockedUsers",SEARCH_KEY:"searchKey",ONLY_UPDATES:"onlyUpdates",UPDATED_AT:"updatedAt",CATEGORY:"category",CATEGORIES:"categories",TYPE:"type",TYPES:"types",HIDE_REPLIES:"hideReplies",HIDE_DELETED_MESSAGES:"hideDeleted"}}},t.ATTACHMENTS_CONSTANTS={KEYS:{EXTENSION:"extension",MIME_TYPE:"mimeType",NAME:"name",SIZE:"size",URL:"url"}},function(e){e.ACTION="action",e.MESSAGE="message",e.CALL="call",e.CUSTOM="custom"}(t.MessageCategory||(t.MessageCategory={})),t.TYPING_NOTIFICATION={RECEIVER_ID:"receiverId",RECEIVER_TYPE:"receiverType",META:"metadata",KEYS:{TYPING_NOTIFICATION:"typingNotification",TIMESTAMP:"timestamp"},ACTIONS:{STARTED:"started",ENDED:"ended"}},t.ActionConstatnts={ACTION_SUBJECTS:{ACTION_ON:"on",ACTION_BY:"by",ACTION_FOR:"for"},ACTION_ENTITY_TYPE:{GROUP_USER:"groupuser",USER:"user",GROUP:"group",MESSAGE:"message"},ACTION_KEYS:{ACTION_CREATED:"created",ACTION_UPDATED:"updated",ACTION_DELETED:"deleted",ENTITIES:"entities",ENTITY:"entity",ENTITY_TYPE:"entityType",TYPE_MEMBER_JOINED:"joined",TYPE_MEMBER_LEFT:"left",TYPE_MEMBER_KICKED:"kicked",TYPE_MEMBER_BANNED:"banned",TYPE_MEMBER_UNBANNED:"unbanned",TYPE_MEMBER_INVITED:"invited",TYPE_MEMBER_ADDED:"added",ACTION_SCOPE_CHANGED:"scopeChanged",ACTION_TYPE_USER:"user",ACTION_TYPE_GROUP:"group",ACTION_TYPE_GROUP_MEMBER:"groupMember",TYPE_MESSAGE_EDITED:"edited",TYPE_MESSAGE_DELETED:"deleted",ACTION_TYPE_CALL:"call",EXTRAS:"extras",SCOPE:"scope",NEW:"new",OLD:"old"},ActionMessages:{ACTION_GROUP_JOINED_MESSAGE:"%s joined",ACTION_GROUP_LEFT_MESSAGE:"%s left",ACTION_MEMBER_KICKED_MESSAGE:"%s kicked %s",ACTION_MEMBER_BANNED_MESSAGE:"%s banned %s",ACTION_MEMBER_UNBANNED_MESSAGE:"%s unbanned %s",ACTION_MEMBER_INVITED_MESSAGE:"%s banned %s",ACTION_MESSAGE_EDITED_MESSAGE:" Message Edited",ACTION_MESSAGE_DELETED_MESSAGE:"Message Deleted",ACTION_MEMBER_SCOPE_CHANGED:"%s made %s %s",ACTION_MEMBER_ADDED_TO_GROUP:"%s added %s"},ACTION_TYPE:{TYPE_MEMBER_JOINED:"joined",TYPE_MEMBER_LEFT:"left",TYPE_MEMBER_KICKED:"kicked",TYPE_MEMBER_BANNED:"banned",TYPE_MEMBER_UNBANNED:"unbanned",TYPE_MEMBER_INVITED:"invited",TYPE_MEMBER_SCOPE_CHANGED:"scopeChanged",TYPE_MESSAGE:"message",TYPE_MESSAGE_EDITED:"edited",TYPE_MESSAGE_DELETED:"deleted",TYPE_MEMBER_ADDED:"added"},ACTIONS:{MEMBER_ADDED:"added",MEMBER_JOINED:"joined",MEMBER_LEFT:"left",MEMBER_KICKED:"kicked",MEMBER_BANNED:"banned",MEMBER_UNBANNED:"unbanned",MEMBER_INVITED:"invited",MEMBER_SCOPE_CHANGED:"scopeChanged",MESSAGE_EDITED:"edited",MESSSAGE_DELETED:"deleted",TYPE_USER:"user",TYPE_GROUP:"group",TYPE_GROUP_MEMBER:"groupMember"}},t.BlockedUsersConstants={REQUEST_KEYS:{DIRECTIONS:{BOTH:"both",HAS_BLOCKED_ME:"hasBlockedMe",BLOCKED_BY_ME:"blockedByMe"}}},t.CallConstants={CALL_MODE:{DEFAULT:"DEFAULT",SPOTLIGHT:"SPOTLIGHT",SINGLE:"SINGLE",TILE:"TILE",GRID:"GRID"},CALL_TYPE:{AUDIO:"audio",VIDEO:"video"},RECEIVER_TYPE_GROUP:"group",RECEIVER_TYPE_USER:"user",CALL_KEYS:{CALL_DATA:"data",CALL_ID:"id",CALL_SESSION_ID:"sessionid",CALL_RECEIVER:"receiver",CALL_SENDER:"sender",CALL_RECEIVER_TYPE:"receiverType",CALL_STATUS:"status",CALL_TYPE:"type",CALL_INITIATED_AT:"initiatedAt",CALL_JOINED_AT:"joinedAt",CALL_LEFT_AT:"leftAt",CALL_METADATA:"metadata",CALL_ENTITIES:"entities",CALL_ENTITY_TYPE:"entityType",CALL_ENTITY:"entity",CALL_ENTITY_USER:"user",CALL_ENTITY_GROUP:"group"},CALL_STATUS:{INITIATED:"initiated",ONGOING:"ongoing",UNANSWERED:"unanswered",REJECTED:"rejected",BUSY:"busy",CANCELLED:"cancelled",ENDED:"ended"},AUDIO_INPUT_DEVICES:"audioInputDevices",AUDIO_OUTPUT_DEVICES:"audioOutputDevices",VIDEO_INPUT_DEVICES:"videoInputDevices",POST_MESSAGES:{TYPES:{ACTION_MESSAGE:"cometchat_action_message",HANGUP:"hangup",COMETCHAT_RTC_SETTINGS:"cometchat_rtc_settings"},ACTIONS:{USER_JOINED:"onUserJoined",USER_LEFT:"onUserLeft",USER_LIST_CHANGED:"onUserListChanged",INITIAL_DEVICE_LIST:"initialDeviceList",DEVICE_CHANGE:"onDeviceChange",LOAD:"LOAD",CHANGE_AUDIO_INPUT:"changeAudioInput",CHANGE_AUDIO_OUTPUT:"changeAudioOutput",CHANGE_VIDEO_INPUT:"changeVideoInput",MUTE_AUDIO:"muteAudio",UNMUTE_AUDIO:"unMuteAudio",PAUSE_VIDEO:"pauseVideo",UNPAUSE_VIDEO:"unPauseVideo",SWITCH_MODE:"switchMode",START_SCREENSHARE:"startScreenShare",STOP_SCREENSHARE:"stopScreenShare",END_CALL:"endCall",START_RECORDING:"startRecording",STOP_RECORDING:"stopRecording",RECORDING_TOGGLED:"onRecordingToggled",USER_MUTED:"onUserMuted",SCREEN_SHARE_STARTED:"SCREEN_SHARE_STARTED",SCREEN_SHARE_STOPPED:"SCREEN_SHARE_ENDED"}},MEDIA_DEVICE:{ID:"id",NAME:"name",ACTIVE:"active"}},t.GroupConstants={KEYS:{NAME:"name",GUID:"guid",TYPE:"type",PASSWORD:"password",ICON:"icon",DESCRIPTION:"description",OWNER:"owner",METADATA:"metadata",CREATED_AT:"createdAt",UPDATED_AT:"updatedAt",HAS_JOINED:"hasJoined",WS_CHANNEL:"wsChannel",TAGS:"tags"}},t.GroupMemersConstans={KEYS:{SCOPE:"scope",UID:"uid",GUID:"guid",USER:"user",NAME:"name"}},t.UserConstants={UID:"uid",NAME:"name",AUTH_TOKEN:"authToken",AVATAR:"avatar",LAST_ACTIVE_AT:"lastActiveAt",LINK:"link",META_DATA:"metadata",ROLE:"role",STATUS:"status",STATUS_MESSAGE:"statusMessage",USER_NAME:"user_name",TAGS:"tags"},t.Errors={ERROR_IO_EXCEPTION:"ERROR_IO_EXCEPTION",ERROR_JSON_EXCEPTION:"ERROR_JSON_EXCEPTION",ERROR_PASSWORD_MISSING:"ERROR_PASSWORD_MISSING",ERROR_LIMIT_EXCEEDED:"ERROR_LIMIT_EXCEEDED",ERROR_USER_NOT_LOGGED_IN:"ERROR_USER_NOT_LOGGED_IN",ERROR_INVALID_GUID:"ERROR_INVALID_GUID",ERROR_PASSWORD_MISSING_MESSAGE:"Password is mandatory for a password group",ERROR_LIMIT_EXCEEDED_MESSAGE:"Limit Exceeded Max limit of %s",ERROR_USER_NOT_LOGGED_IN_MESSAGE:"Please log in to CometChat before calling this method",ERROR_INVALID_GUID_MESSAGE:"Please provide a valid GUID",ERROR_DEFAULT_MESSAGE:"Something went wrong",ERR_SETTINGS_HASH_OUTDATED:"ERR_SETTINGS_HASH_OUTDATED",ERR_NO_AUTH:"ERR_NO_AUTH",ERR_XMPP_CONFLICT:"conflict"},t.CALL_ERROR={CALL_ALREADY_INITIATED:{code:"CALL_ALREADY_INITIATED",name:"CALL_ALREADY_INITIATED",message:"There is already call in progress",details:{}},ERROR_IN_CALLING:{code:"CALL_IN_PROGRESS",name:"CALL_ALREADY_INITIATED",message:"There is already call in progress",details:{}},CANNOT_ACCEPT_CALL:{code:"CALL_IN_PROGRESS",name:"CALL_IN_PROGRESS",message:"There is already a call in progress",details:{}},NOT_INITIALIZED:{code:"NOT_INITIALIZED",name:"NOT_INITIALIZED",message:"Please call the CometChat.init() method before calling any other methods related to CometChat.",details:{}},NOT_LOGGED_IN:{code:"NOT_LOGGED_IN",name:"NOT_LOGGED_IN",message:"Please login before starting a call.",details:{}},SESSION_ID_REQUIRED:{code:"SESSION_ID_REQUIRED",name:"SESSION_ID_REQUIRED",message:"Please make sure you are passing correct session id.",details:{}},CALL_SETTINGS_REQUIRED:{code:"CALL_SETTINGS_REQUIRED",name:"CALL_SETTINGS_REQUIRED",message:"Please make sure you are passing the call settings object.",details:{}},JWT_NOT_FOUND:{code:"JWT_NOT_FOUND",name:"JWT_NOT_FOUND",message:"There was some issue while fetching JWT from API.",details:{}}},t.PARAMETER_ERROR={PARAMETER_REQUIRED:{code:"%s_NOT_PROVIDED",name:"%s_NOT_PROVIDED",message:"please provide the %s.",details:{}}},t.GENERAL_ERROR={MUST_BE_A_STRING:{code:"INVALID_%s",name:"INVALID_%s",message:"%s should be a string.",details:{}},MUST_BE_A_NUMBER:{code:"INVALID_%s",name:"INVALID_%s",message:"%s should be a number.",details:{}},MUST_BE_A_OBJECT:{code:"INVALID_%s",name:"INVALID_%s",message:"%s should be a object.",details:{}},MUST_BE_AN_ARRAY:{code:"INVALID_%s",name:"INVALID_%s",message:"%s should be an array.",details:{}},MUST_BE_A_BOOLEAN:{code:"INVALID_%s",name:"INVALID_%s",message:"%s should be a boolean.",details:{}},MUST_BE_A_BLOB:{code:"INVALID_%s",name:"INVALID_%s",message:"%s should be a blob.",details:{}},INVALID:{code:"INVALID_%s",name:"INVALID_%s",message:"Invalid %s. Please provide a valid %s.",details:{}},METHOD_COMPULSORY:{code:"%s_IS_COMPULSORY",name:"%s_IS_COMPULSORY",message:"%s is required.",details:{}},LIMIT_EXCEEDED:{code:"ERROR_%s_EXCEEDED",name:"ERROR_%s_EXCEEDED",message:"Limit exceeded max limit of %s.",details:{}},MUST_BE_A_POSITIVE_NUMBER:{code:"INVALID_%s",name:"INVALID_%s",message:"%s should be a postive integer greater than 0.",details:{}},INVALID_MEDIA_FILE:{code:"INVALID_%s",name:"INVALID_%s",message:"The message type does not match the file's mime type.",details:{}},EMPTY_STRING:{code:"INVALID_%s",name:"INVALID_%s",message:"%s cannot be empty.",details:{}},MISSING_KEY:{code:"MISSING_KEY",name:"MISSING_KEY",message:"The key %s is missing from the %s object.",details:{}},EMPTY_ARRAY:{code:"INVALID_%s",name:"INVALID_%s",message:"The parameter %s should be an array and it cannot be empty.",details:{}},INVALID_SEARCH_KEYWORD:{code:"INVALID_SEARCH_KEYWORD",name:"INVALID_SEARCH_KEYWORD",message:"Invalid search keyword. Please provide a valid search keyword.",details:{}},INVALID_GROUP_PROPERTY:{code:"INVALID_%s",name:"INVALID_%s",message:"Invalid %s provided for the group. Please provide a valid %s.",details:{}},INVALID_USER_PROPERTY:{code:"INVALID_%s",name:"INVALID_%s",message:"Invalid %s provided for a user. Please provide a valid %s.",details:{}},PARAMETER_MUST_BE_A_NUMBER:{code:"INVALID_%s",name:"INVALID_%s",message:"%s method accepts parameter as a number.",details:{}},PARAMETER_MUST_BE_AN_ARRAY:{code:"INVALID_%s",name:"INVALID_%s",message:"%s method accepts parameter as an array.",details:{}},PARAMETER_MUST_BE_A_BOOLEAN:{code:"INVALID_%s",name:"INVALID_%s",message:"%s method accepts parameter as a boolean.",details:{}},PARAMETER_MUST_BE_A_POSITIVE_NUMBER:{code:"INVALID_%s",name:"INVALID_%s",message:"%s method accepts parameter to be a positive number greater than 0.",details:{}},PARAMETER_MUST_BE_A_STRING:{code:"INVALID_%s",name:"INVALID_%s",message:"%s method accepts parameter as a string.",details:{}},PARAMETER_COMPULSORY:{code:"%s_IS_COMPULSORY",name:"%s_IS_COMPULSORY",message:"%s cannot be blank. Please provide a valid %s.",details:{}},PASSWORD_COMPULSORY:{code:"%s_IS_COMPULSORY",name:"%s_IS_COMPULSORY",message:"Password is mandatory for a password group.",details:{}},INVALID_ARRAY:{code:"INVALID_%s",name:"INVALID_%s",message:"%s",details:{}}},t.UserErrors={INVALID_STATUS:new r.CometChatException({code:"INVALID_STATUS_VALUE",name:"INVALID_STATUS_VALUE",message:"The `status` parameter accepts only `online` or `offline`.",details:""}),INVALID_DIRECTION:new r.CometChatException({code:"INVALID_DIRECTION_VALUE",name:"INVALID_DIRECTION_VALUE",message:"The `direction` parameter accepts only `both`, `blockeyByMe` or `hasBlockedMe`.",details:""}),USER_NOT_LOGGED_IN:new r.CometChatException({code:"USER_NOT_LOGGED_IN",name:"USER_NOT_LOGGED_IN",message:"Please log in to CometChat before calling this method.",details:""})},t.GroupErrors={NOT_A_GROUP:new r.CometChatException({code:"NOT_A_GROUP",message:"Please use group class to construct a new group."}),INVALID_SCOPE:new r.CometChatException({code:"INVALID_SCOPE_VALUE",name:"INVALID_SCOPE_VALUE",message:"Scope can be `admin`, `moderator` or `participant`.",details:""}),INVALID_GROUP_TYPE:new r.CometChatException({code:"INVALID_GROUP_TYPE",name:"INVALID_GROUP_TYPE",message:"Group type can be `public`, `private`, `protected` or `password`.",details:""})},t.ConversationErrors={INVALID_CONVERSATION_TYPE:{code:"INVALID_CONVERSATION_TYPE",name:"INVALID_CONVERSATION_TYPE",message:"Conversation type can be `user` or `group`.",details:"Please check the value of conversationType."},CONVERSATION_NOT_FOUND:{code:"CONVERSATION_NOT_FOUND",name:"CONVERSATION_NOT_FOUND",message:"Conversation for %s %s not found.",details:"Please check the value of conversationWith and conversationType."}},t.ExtensionErrors={INVALID_EXTENSION:{code:"ERROR_INVALID_EXTENSION",name:"ERROR_INVALID_EXTENSION",message:"The provided extension cannot be null or empty. Please provide a valid extension.",details:{}},EXTENSION_NOT_FOUND:{code:"ERROR_EXTENSION_NOT_FOUND",name:"ERROR_EXTENSION_NOT_FOUND",message:"The provided extension could not be found.",details:{}}},t.MessageErrors={INVALID_RECEIVER_TYPE:{code:"INVALID_RECEIVER_TYPE",name:"INVALID_RECEIVER_TYPE",message:"Receiver type can be `user` or `group`.",details:"Please check the value of receiverType."}},t.FeatureRestrictionErrors={INVALID_FEATURE:{code:"ERROR_INVALID_FEATURE",name:"ERROR_INVALID_FEATURE",message:"The provided feature cannot be null or empty. Please provide a valid feature.",details:{}},FEATURE_NOT_FOUND:{code:"ERROR_FEATURE_NOT_FOUND",name:"ERROR_FEATURE_NOT_FOUND",message:"The provided feature could not be found.",details:{}}},t.PresenceConstatnts={XMPP_KEYS:{FROM:"from",STATUS:"status",LAST_ACTIVE_AT:"lastActiveAt",TYPE:"type"},STATUS:{ONLINE:"online",AVAILABLE:"available",OFFLINE:"offline",JOINED:"JOINED",LEFT:"LEFT"}},t.APP_SETTINGS={APP_SETTINGS:"app_settings",KEYS:{CHAT_HOST:"CHAT_HOST",CHAT_USE_SSL:"CHAT_USE_SSL",GROUP_SERVICE:"GROUP_SERVICE",CALL_SERVICE:"CALL_SERVICE",CHAT_WS_PORT:"CHAT_WS_PORT",CHAT_WSS_PORT:"CHAT_WSS_PORT",CHAT_HTTP_BIND_PORT:"CHAT_HTTP_BIND_PORT",CHAT_HTTPS_BIND_PORT:"CHAT_HTTPS_BIND_PORT",ADMIN_API_HOST:"ADMIN_API_HOST",CLIENT_API_HOST:"CLIENT_API_HOST",WEBRTC_HOST:"WEBRTC_HOST",WEBRTC_USE_SSL:"WEBRTC_USE_SSL",WEBRTC_WS_PORT:"WEBRTC_WS_PORT",WEBRTC_WSS_PORT:"WEBRTC_WSS_PORT",WEBRTC_HTTP_BIND_PORT:"WEBRTC_HTTP_BIND_PORT",WEBRTC_HTTPS_BIND_PORT:"WEBRTC_HTTPS_BIND_PORT",EXTENSION_LIST:"extensions",EXTENSION_KEYS:{ID:"id",NAME:"name"},JID_HOST_OVERRIDE:"JID_HOST_OVERRIDE",CHAT_HOST_OVERRIDE:"CHAT_HOST_OVERRIDE",CHAT_HOST_APP_SPECIFIC:"CHAT_HOST_APP_SPECIFIC",MODE:"MODE",DEFAULT_MODE:"DEFAULT",HIGH_VOL_MODE:"HIGH_VOL",FLAKY_MODE:"FLAKY",POLLING_ENABLED:"POLLING_ENABLED",POLLING_INTERVAL:"POLLING_INTERVAL",ANALYTICS_PING_DISABLED:"ANALYTICS_PING_DISABLED",ANALYTICS_HOST:"ANALYTICS_HOST",ANALYTICS_VERSION:"ANALYTICS_VERSION",ANALYTICS_USE_SSL:"ANALYTICS_USE_SSL",SETTINGS_HASH:"settingsHash",SETTINGS_HASH_RECEIVED_AT:"settingsHashReceivedAt",DENY_FALLBACK_TO_POLLING:"DENY_FALLBACK_TO_POLLING"}},t.COMMON_UTILITY_CONSTANTS={TYPE_CONSTANTS:{BOOLEAN:"boolean",STRING:"string",OBJECT:"object",NUMBER:"number"}},t.CONNECTION_STATUS={CONNECTED:"connected",CONNECTING:"connecting",DISCONNECTED:"disconnected",FEATURE_THROTTLED:"featureThrottled"},t.SESSION_STORE={SESSION_ID:"sessionId"},t.API_ERROR_CODES={AUTH_ERR_AUTH_TOKEN_NOT_FOUND:"AUTH_ERR_AUTH_TOKEN_NOT_FOUND"},t.PROSODY_API={DOMAIN_PREFIX:"xmpp",PATH:{ROOM:"room",ROOM_SIZE:"room-size",SESSIONS:"sessions"},RESPONSE:{PARTICIPANTS:"participants"},QUERY_PARAMETERS:{DOMAIN:"domain",ROOM:"room"}},t.ProsodyApiErrors={INVALID_SESSIONID:{code:"ERROR_INVALID_SESSIONID",name:"ERROR_INVALID_SESSIONID",message:"The provided sessionId cannot be null or empty. Please provide a valid sessionId.",details:""},INVALID_TYPE:{code:"ERROR_INVALID_TYPE",name:"ERROR_INVALID_TYPE",message:"The provided type cannot be null or empty. Please provide a valid type.",details:""}},t.JWT_API={KEYS:{PASSTHROUGH:"passthrough",EXPAND:"expand"}}},function(e,t,n){"use strict";t.__esModule=!0;var r=n(9),s=n(0),o=n(5),i=n(2),a=n(18),c=n(19),u=n(21),l=n(3),E=n(13);function d(e){return null!=e&&("string"==typeof e&&(e=e.trim()),"object"==typeof e&&0===Object.keys(e).length&&(e=void 0)),["",0,"0",!1,null,"null",void 0,"undefined"].includes(e)}function h(e){for(var t=[],n=1;n<arguments.length;n++)t[n-1]=arguments[n];return e.split("%s").reduce((function(e,n,r){return e+n+(t[r]||"")}),"")}t.getChatHost=function(e){return e[s.APP_SETTINGS.KEYS.CHAT_HOST_OVERRIDE]?e[s.APP_SETTINGS.KEYS.CHAT_HOST_OVERRIDE]:e[s.APP_SETTINGS.KEYS.CHAT_HOST_APP_SPECIFIC]?e[s.APP_SETTINGS.KEYS.CHAT_HOST_APP_SPECIFIC]:e[s.APP_SETTINGS.KEYS.CHAT_HOST]},t.getJidHost=function(e){return e[s.APP_SETTINGS.KEYS.JID_HOST_OVERRIDE]?e[s.APP_SETTINGS.KEYS.JID_HOST_OVERRIDE]:e[s.APP_SETTINGS.KEYS.CHAT_HOST]},t.isObject=function(e){return e instanceof Object&&e.constructor===Object},t.isTruthy=function(e){return[!0,1,"1","true","TRUE"].includes(e)},t.isFalsy=d,t.getOrdinalSuffix=function(e){var t=e%10,n=e%100;return 1==t&&11!=n?e+"st":2==t&&12!=n?e+"nd":3==t&&13!=n?e+"rd":e+"th"},t.format=h,t.createUidFromJid=function(e){return e.substring(e.lastIndexOf("]")+1,e.lastIndexOf("@"))};var p=function(){function e(){}return e.log=function(e,t){},e.error=function(e,t){},e.info=function(e,t){},e}();function S(){return new Promise((function(e,t){o.makeApiCall("appSettings").then((function(t){r.LocalStorage.getInstance().set("app_settings",t.data),t.data.MODE&&l.CometChat.setMode(t.data.MODE),e(t.data)}),(function(e){t(new i.CometChatException(e.error))}))}))}t.Logger=p,t.getCurrentTime=function(){return(new Date).getTime()},t.getAppSettings=function(){return new Promise((function(e,t){r.LocalStorage.getInstance().get(s.APP_SETTINGS.APP_SETTINGS).then((function(n){d(n)?S().then((function(t){e(t)}),(function(e){t(e)})):e(n)}),(function(e){t(e)}))}))},t.getUpdatedSettings=S,t.isImage=function(e){var t;return e.type&&e.type.toLowerCase().includes("image")&&(t=!0),t},t.isVideo=function(e){var t;return e.type&&e.type.toLowerCase().includes("video")&&(t=!0),t},t.isAudio=function(e){var t;return e.type&&e.type.toLowerCase().includes("audio")&&(t=!0),t},t.validateScope=function(e){return typeof e!==s.COMMON_UTILITY_CONSTANTS.TYPE_CONSTANTS.STRING?new i.CometChatException(JSON.parse(h(JSON.stringify(s.GENERAL_ERROR.MUST_BE_A_STRING),"SCOPE","SCOPE","Scope"))):d(e)?new i.CometChatException(JSON.parse(h(JSON.stringify(s.GENERAL_ERROR.INVALID),"SCOPE","SCOPE","scope","scope"))):e!=l.CometChat.GROUP_MEMBER_SCOPE.ADMIN&&e!=l.CometChat.GROUP_MEMBER_SCOPE.MODERATOR&&e!=l.CometChat.GROUP_MEMBER_SCOPE.PARTICIPANT?new i.CometChatException(s.GroupErrors.INVALID_SCOPE):void 0},t.validateUpdateGroup=function(e){return e.hasOwnProperty(s.GroupConstants.KEYS.GUID)?typeof e[s.GroupConstants.KEYS.GUID]!==s.COMMON_UTILITY_CONSTANTS.TYPE_CONSTANTS.STRING?new i.CometChatException(JSON.parse(h(JSON.stringify(s.GENERAL_ERROR.MUST_BE_A_STRING),"GUID","GUID","GUID"))):d(e[s.GroupConstants.KEYS.GUID])?new i.CometChatException(JSON.parse(h(JSON.stringify(s.GENERAL_ERROR.INVALID_GROUP_PROPERTY),"GUID","GUID","GUID","GUID"))):e.hasOwnProperty(s.GroupConstants.KEYS.NAME)&&""===e[s.GroupConstants.KEYS.NAME]?new i.CometChatException(JSON.parse(h(JSON.stringify(s.GENERAL_ERROR.EMPTY_STRING),"GROUP_NAME","GROUP_NAME","Group name"))):void 0:new i.CometChatException(JSON.parse(h(JSON.stringify(s.GENERAL_ERROR.PARAMETER_COMPULSORY),"GUID","GUID","GUID","GUID")))},t.validateJoinGroup=function(e,t,n){if(typeof e==s.COMMON_UTILITY_CONSTANTS.TYPE_CONSTANTS.OBJECT){if(!e.hasOwnProperty(s.GroupConstants.KEYS.GUID))return new i.CometChatException(JSON.parse(h(JSON.stringify(s.GENERAL_ERROR.PARAMETER_COMPULSORY),"GUID","GUID","GUID","GUID")));if(typeof e[s.GroupConstants.KEYS.GUID]!==s.COMMON_UTILITY_CONSTANTS.TYPE_CONSTANTS.STRING)return new i.CometChatException(JSON.parse(h(JSON.stringify(s.GENERAL_ERROR.MUST_BE_A_STRING),"GUID","GUID","GUID")));if(d(e[s.GroupConstants.KEYS.GUID]))return new i.CometChatException(JSON.parse(h(JSON.stringify(s.GENERAL_ERROR.INVALID_GROUP_PROPERTY),"GUID","GUID","GUID","GUID")));if(!e.hasOwnProperty(s.GroupConstants.KEYS.TYPE))return new i.CometChatException(JSON.parse(h(JSON.stringify(s.GENERAL_ERROR.PARAMETER_COMPULSORY),"GROUP_TYPE","GROUP_TYPE","Group type","Group type")));if(typeof e[s.GroupConstants.KEYS.TYPE]!==s.COMMON_UTILITY_CONSTANTS.TYPE_CONSTANTS.STRING)return new i.CometChatException(JSON.parse(h(JSON.stringify(s.GENERAL_ERROR.MUST_BE_A_STRING),"GROUP_TYPE","GROUP_TYPE","Group type")));if(d(e[s.GroupConstants.KEYS.TYPE]))return new i.CometChatException(JSON.parse(h(JSON.stringify(s.GENERAL_ERROR.INVALID_GROUP_PROPERTY),"GROUP_TYPE","GROUP_TYPE","type","type")));if(e[s.GroupConstants.KEYS.TYPE].toLowerCase()!=l.CometChat.GROUP_TYPE.PUBLIC&&e[s.GroupConstants.KEYS.TYPE].toLowerCase()!=l.CometChat.GROUP_TYPE.PASSWORD&&e[s.GroupConstants.KEYS.TYPE].toLowerCase()!=l.CometChat.GROUP_TYPE.PROTECTED&&e[s.GroupConstants.KEYS.TYPE].toLowerCase()!=l.CometChat.GROUP_TYPE.PRIVATE)return new i.CometChatException(s.GroupErrors.INVALID_GROUP_TYPE);if(e[s.GroupConstants.KEYS.TYPE].toLowerCase()==l.CometChat.GROUP_TYPE.PASSWORD){if(!e.hasOwnProperty(s.GroupConstants.KEYS.PASSWORD))return new i.CometChatException(JSON.parse(h(JSON.stringify(s.GENERAL_ERROR.PASSWORD_COMPULSORY),"PASSWORD","PASSWORD")));if(typeof e[s.GroupConstants.KEYS.PASSWORD]!==s.COMMON_UTILITY_CONSTANTS.TYPE_CONSTANTS.STRING)return new i.CometChatException(JSON.parse(h(JSON.stringify(s.GENERAL_ERROR.MUST_BE_A_STRING),"PASSWORD","PASSWORD","Password")));if(d(e[s.GroupConstants.KEYS.PASSWORD]))return new i.CometChatException(JSON.parse(h(JSON.stringify(s.GENERAL_ERROR.INVALID_GROUP_PROPERTY),"PASSWORD","PASSWORD","password","password")))}}else{if(void 0!==e){if(typeof e!==s.COMMON_UTILITY_CONSTANTS.TYPE_CONSTANTS.STRING)return new i.CometChatException(JSON.parse(h(JSON.stringify(s.GENERAL_ERROR.MUST_BE_A_STRING),"GUID","GUID","GUID")));if(d(e))return new i.CometChatException(JSON.parse(h(JSON.stringify(s.GENERAL_ERROR.INVALID_GROUP_PROPERTY),"GUID","GUID","GUID","GUID")))}if(void 0!==t){if(typeof t!==s.COMMON_UTILITY_CONSTANTS.TYPE_CONSTANTS.STRING)return new i.CometChatException(JSON.parse(h(JSON.stringify(s.GENERAL_ERROR.MUST_BE_A_STRING),"GROUP_TYPE","GROUP_TYPE","Group type")));if(d(t))return new i.CometChatException(JSON.parse(h(JSON.stringify(s.GENERAL_ERROR.INVALID_GROUP_PROPERTY),"GROUP_TYPE","GROUP_TYPE","type","type")));if(t.toLowerCase()!=l.CometChat.GROUP_TYPE.PUBLIC&&t.toLowerCase()!=l.CometChat.GROUP_TYPE.PASSWORD&&t.toLowerCase()!=l.CometChat.GROUP_TYPE.PROTECTED&&t.toLowerCase()!=l.CometChat.GROUP_TYPE.PRIVATE)return new i.CometChatException(s.GroupErrors.INVALID_GROUP_TYPE);if(t.toLowerCase()==l.CometChat.GROUP_TYPE.PASSWORD){if(typeof n!==s.COMMON_UTILITY_CONSTANTS.TYPE_CONSTANTS.STRING)return new i.CometChatException(JSON.parse(h(JSON.stringify(s.GENERAL_ERROR.MUST_BE_A_STRING),"PASSWORD","PASSWORD","Password")));if(d(n))return new i.CometChatException(JSON.parse(h(JSON.stringify(s.GENERAL_ERROR.INVALID_GROUP_PROPERTY),"PASSWORD","PASSWORD","password","password")))}}}},t.validateCreateGroup=function(e){if(!e.hasOwnProperty(s.GroupConstants.KEYS.GUID))return new i.CometChatException(JSON.parse(h(JSON.stringify(s.GENERAL_ERROR.PARAMETER_COMPULSORY),"GUID","GUID","GUID","GUID")));if(typeof e[s.GroupConstants.KEYS.GUID]!==s.COMMON_UTILITY_CONSTANTS.TYPE_CONSTANTS.STRING)return new i.CometChatException(JSON.parse(h(JSON.stringify(s.GENERAL_ERROR.MUST_BE_A_STRING),"GUID","GUID","GUID")));if(d(e[s.GroupConstants.KEYS.GUID]))return new i.CometChatException(JSON.parse(h(JSON.stringify(s.GENERAL_ERROR.INVALID_GROUP_PROPERTY),"GUID","GUID","GUID","GUID")));if(!e.hasOwnProperty(s.GroupConstants.KEYS.NAME))return new i.CometChatException(JSON.parse(h(JSON.stringify(s.GENERAL_ERROR.PARAMETER_COMPULSORY),"GROUP_NAME","GROUP_NAME","Group name","Group name")));if(typeof e[s.GroupConstants.KEYS.NAME]!==s.COMMON_UTILITY_CONSTANTS.TYPE_CONSTANTS.STRING)return new i.CometChatException(JSON.parse(h(JSON.stringify(s.GENERAL_ERROR.MUST_BE_A_STRING),"GROUP_NAME","GROUP_NAME","Group name")));if(d(e[s.GroupConstants.KEYS.NAME]))return new i.CometChatException(JSON.parse(h(JSON.stringify(s.GENERAL_ERROR.INVALID_GROUP_PROPERTY),"GROUP_NAME","GROUP_NAME","name","name")));if(!e.hasOwnProperty(s.GroupConstants.KEYS.TYPE))return new i.CometChatException(JSON.parse(h(JSON.stringify(s.GENERAL_ERROR.PARAMETER_COMPULSORY),"GROUP_TYPE","GROUP_TYPE","Group type","Group type")));if(typeof e[s.GroupConstants.KEYS.TYPE]!==s.COMMON_UTILITY_CONSTANTS.TYPE_CONSTANTS.STRING)return new i.CometChatException(JSON.parse(h(JSON.stringify(s.GENERAL_ERROR.MUST_BE_A_STRING),"GROUP_TYPE","GROUP_TYPE","Group type")));if(d(e[s.GroupConstants.KEYS.TYPE]))return new i.CometChatException(JSON.parse(h(JSON.stringify(s.GENERAL_ERROR.INVALID_GROUP_PROPERTY),"GROUP_TYPE","GROUP_TYPE","type","type")));if(e[s.GroupConstants.KEYS.TYPE].toLowerCase()!=l.CometChat.GROUP_TYPE.PUBLIC&&e[s.GroupConstants.KEYS.TYPE].toLowerCase()!=l.CometChat.GROUP_TYPE.PASSWORD&&e[s.GroupConstants.KEYS.TYPE].toLowerCase()!=l.CometChat.GROUP_TYPE.PROTECTED&&e[s.GroupConstants.KEYS.TYPE].toLowerCase()!=l.CometChat.GROUP_TYPE.PRIVATE)return new i.CometChatException(s.GroupErrors.INVALID_GROUP_TYPE);if(e[s.GroupConstants.KEYS.TYPE].toLowerCase()==l.CometChat.GROUP_TYPE.PASSWORD){if(!e.hasOwnProperty(s.GroupConstants.KEYS.PASSWORD))return new i.CometChatException(JSON.parse(h(JSON.stringify(s.GENERAL_ERROR.PASSWORD_COMPULSORY),"PASSWORD","PASSWORD")));if(typeof e[s.GroupConstants.KEYS.PASSWORD]!==s.COMMON_UTILITY_CONSTANTS.TYPE_CONSTANTS.STRING)return new i.CometChatException(JSON.parse(h(JSON.stringify(s.GENERAL_ERROR.MUST_BE_A_STRING),"PASSWORD","PASSWORD","Password")));if(d(e[s.GroupConstants.KEYS.PASSWORD]))return new i.CometChatException(JSON.parse(h(JSON.stringify(s.GENERAL_ERROR.INVALID_GROUP_PROPERTY),"PASSWORD","PASSWORD","password","password")))}if(e.hasOwnProperty(s.GroupConstants.KEYS.TAGS)){if(!Array.isArray(e[s.GroupConstants.KEYS.TAGS]))return new i.CometChatException(JSON.parse(h(JSON.stringify(s.GENERAL_ERROR.MUST_BE_AN_ARRAY),"GROUP_TAGS","GROUP_TAGS","Group tags")));if(0===e[s.GroupConstants.KEYS.TAGS].length)return new i.CometChatException(JSON.parse(h(JSON.stringify(s.GENERAL_ERROR.EMPTY_ARRAY),"GROUP_TAGS","GROUP_TAGS","Group tags")))}},t.validateId=function(e,t){if("user"===t){if(typeof e!==s.COMMON_UTILITY_CONSTANTS.TYPE_CONSTANTS.STRING)return new i.CometChatException(JSON.parse(h(JSON.stringify(s.GENERAL_ERROR.MUST_BE_A_STRING),"UID","UID","UID")));if(d(e))return new i.CometChatException(JSON.parse(h(JSON.stringify(s.GENERAL_ERROR.INVALID),"UID","UID","UID","UID")))}if("group"===t){if(typeof e!==s.COMMON_UTILITY_CONSTANTS.TYPE_CONSTANTS.STRING)return new i.CometChatException(JSON.parse(h(JSON.stringify(s.GENERAL_ERROR.MUST_BE_A_STRING),"GUID","GUID","GUID")));if(d(e))return new i.CometChatException(JSON.parse(h(JSON.stringify(s.GENERAL_ERROR.INVALID),"GUID","GUID","GUID","GUID")))}},t.validateHideMessagesFromBlockedUsers=function(e){if(typeof e!==s.COMMON_UTILITY_CONSTANTS.TYPE_CONSTANTS.BOOLEAN)return new i.CometChatException(JSON.parse(h(JSON.stringify(s.GENERAL_ERROR.MUST_BE_A_BOOLEAN),"HIDE_MESSAGES_FROM_BLOCKED_USERS","HIDE_MESSAGES_FROM_BLOCKED_USERS","hideMessagesFromBlockedUsers")))},t.validateArray=function(e,t){var n="List should be an array.";return n="blockUsers"===t?"blockUsers() method accepts an array of users.":"unblockUsers"===t?"unblockUsers() method accepts an array of users.":"groupMembers"===t?"addMembersToGroup() method accepts members list as an array of users.":"addMembersToGroup() method accepts bannedMembers list as an array of users.",typeof e!=s.COMMON_UTILITY_CONSTANTS.TYPE_CONSTANTS.OBJECT?new i.CometChatException(JSON.parse(h(JSON.stringify(s.GENERAL_ERROR.INVALID_ARRAY),"USER_LIST","USER_LIST",n))):Array.isArray(e)?void 0:new i.CometChatException(JSON.parse(h(JSON.stringify(s.GENERAL_ERROR.INVALID_ARRAY),"USER_LIST","USER_LIST",n)))},t.validateMsgId=function(e){return isNaN(e)?new i.CometChatException(JSON.parse(h(JSON.stringify(s.GENERAL_ERROR.MUST_BE_A_NUMBER),"MESSAGE_ID","MESSAGE_ID","Message Id"))):d(e)?new i.CometChatException(E.ERRORS.PARAMETER_MISSING):void 0},t.validateChatType=function(e){return typeof e!==s.COMMON_UTILITY_CONSTANTS.TYPE_CONSTANTS.STRING?new i.CometChatException(JSON.parse(h(JSON.stringify(s.GENERAL_ERROR.MUST_BE_A_STRING),"RECEIVER_TYPE","RECEIVER_TYPE","Receiver type"))):d(e)?new i.CometChatException(JSON.parse(h(JSON.stringify(s.GENERAL_ERROR.INVALID),"RECEIVER_TYPE","RECEIVER_TYPE","receiver type","receiver type"))):e!=s.MessageConstatnts.RECEIVER_TYPE.GROUP&&e!=s.MessageConstatnts.RECEIVER_TYPE.USER?new i.CometChatException(s.MessageErrors.INVALID_RECEIVER_TYPE):void 0},t.validateMessage=function(e){var n=e;if(typeof n.getReceiverId()!==s.COMMON_UTILITY_CONSTANTS.TYPE_CONSTANTS.STRING)return new i.CometChatException(JSON.parse(h(JSON.stringify(s.GENERAL_ERROR.MUST_BE_A_STRING),"RECEIVER_ID","RECEIVER_ID","Receiver Id")));if(d(n.getReceiverId()))return new i.CometChatException(JSON.parse(h(JSON.stringify(s.GENERAL_ERROR.INVALID),"RECEIVER_ID","RECEIVER_ID","receiver id","receiver id")));if(typeof n.getReceiverType()!==s.COMMON_UTILITY_CONSTANTS.TYPE_CONSTANTS.STRING)return new i.CometChatException(JSON.parse(h(JSON.stringify(s.GENERAL_ERROR.MUST_BE_A_STRING),"RECEIVER_TYPE","RECEIVER_TYPE","Receiver Type")));if(d(n.getReceiverType()))return new i.CometChatException(JSON.parse(h(JSON.stringify(s.GENERAL_ERROR.INVALID),"RECEIVER_TYPE","RECEIVER_TYPE","receiver type","receiver type")));if(n.getReceiverType()!=s.MessageConstatnts.RECEIVER_TYPE.GROUP&&n.getReceiverType()!=s.MessageConstatnts.RECEIVER_TYPE.USER)return new i.CometChatException(s.MessageErrors.INVALID_RECEIVER_TYPE);if(e instanceof a.TextMessage){var r=e;if(typeof r.getText()!==s.COMMON_UTILITY_CONSTANTS.TYPE_CONSTANTS.STRING)return new i.CometChatException(JSON.parse(h(JSON.stringify(s.GENERAL_ERROR.MUST_BE_A_STRING),"MESSAGE_TEXT","MESSAGE_TEXT","Message text")));if(""===r.getText().trim())return new i.CometChatException(JSON.parse(h(JSON.stringify(s.GENERAL_ERROR.EMPTY_STRING),"MESSAGE_TEXT","MESSAGE_TEXT","Message text")))}if(e instanceof c.MediaMessage){var o=e;if(o.getData()&&o.getData().hasOwnProperty("attachments")){var l=o.getAttachment();if(!l.getExtension())return new i.CometChatException(JSON.parse(h(JSON.stringify(s.GENERAL_ERROR.MISSING_KEY),"extension","Attachment")));if(!l.getMimeType())return new i.CometChatException(JSON.parse(h(JSON.stringify(s.GENERAL_ERROR.MISSING_KEY),"mimeType","Attachment")));if(!l.getName())return new i.CometChatException(JSON.parse(h(JSON.stringify(s.GENERAL_ERROR.MISSING_KEY),"name","Attachment")));if(!l.getUrl())return new i.CometChatException(JSON.parse(h(JSON.stringify(s.GENERAL_ERROR.MISSING_KEY),"url","Attachment")))}else{if(!(o.file instanceof Blob))return new i.CometChatException(JSON.parse(h(JSON.stringify(s.GENERAL_ERROR.MUST_BE_A_BLOB),"MEDIA_OBJECT","MEDIA_OBJECT","Media object")));if("image"==o.getType()){if(!t.isImage(o.file))return new i.CometChatException(JSON.parse(h(JSON.stringify(s.GENERAL_ERROR.INVALID_MEDIA_FILE),"IMAGE_FILE","IMAGE_FILE")))}else if("video"==o.getType()){if(!t.isVideo(o.file))return new i.CometChatException(JSON.parse(h(JSON.stringify(s.GENERAL_ERROR.INVALID_MEDIA_FILE),"VIDEO_FILE","VIDEO_FILE")))}else if("audio"==o.getType()&&!t.isAudio(o.file))return new i.CometChatException(JSON.parse(h(JSON.stringify(s.GENERAL_ERROR.INVALID_MEDIA_FILE),"AUDIO_FILE","AUDIO_FILE")))}}if(e instanceof u.CustomMessage&&d(e.getCustomData()))return new i.CometChatException(JSON.parse(h(JSON.stringify(s.GENERAL_ERROR.INVALID),"CUSTOM_DATA","CUSTOM_DATA","custom data","custom data")))},t.validateCreateUser=function(e){if(!e.hasOwnProperty(s.UserConstants.UID))return new i.CometChatException(JSON.parse(h(JSON.stringify(s.GENERAL_ERROR.PARAMETER_COMPULSORY),"UID","UID","UID","UID")));if(typeof e[s.UserConstants.UID]!==s.COMMON_UTILITY_CONSTANTS.TYPE_CONSTANTS.STRING)return new i.CometChatException(JSON.parse(h(JSON.stringify(s.GENERAL_ERROR.MUST_BE_A_STRING),"UID","UID","UID")));if(d(e[s.UserConstants.UID]))return new i.CometChatException(JSON.parse(h(JSON.stringify(s.GENERAL_ERROR.INVALID_USER_PROPERTY),"UID","UID","UID","UID")));if(!e.hasOwnProperty(s.UserConstants.NAME))return new i.CometChatException(JSON.parse(h(JSON.stringify(s.GENERAL_ERROR.PARAMETER_COMPULSORY),"USER_NAME","USER_NAME","User name","User name")));if(typeof e[s.UserConstants.NAME]!==s.COMMON_UTILITY_CONSTANTS.TYPE_CONSTANTS.STRING)return new i.CometChatException(JSON.parse(h(JSON.stringify(s.GENERAL_ERROR.MUST_BE_A_STRING),"USER_NAME","USER_NAME","User name")));if(d(e[s.UserConstants.NAME]))return new i.CometChatException(JSON.parse(h(JSON.stringify(s.GENERAL_ERROR.INVALID_USER_PROPERTY),"USER_NAME","USER_NAME","name","name")));if(e.hasOwnProperty(s.UserConstants.AVATAR)&&""===e[s.UserConstants.AVATAR])return new i.CometChatException(JSON.parse(h(JSON.stringify(s.GENERAL_ERROR.EMPTY_STRING),"USER_AVATAR","USER_AVATAR","User avatar")));if(e.hasOwnProperty(s.UserConstants.META_DATA)&&""===e[s.UserConstants.META_DATA])return new i.CometChatException(JSON.parse(h(JSON.stringify(s.GENERAL_ERROR.EMPTY_STRING),"USER_METADATA","USER_METADATA","User metadata")));if(e.hasOwnProperty(s.UserConstants.LINK)&&""===e[s.UserConstants.LINK])return new i.CometChatException(JSON.parse(h(JSON.stringify(s.GENERAL_ERROR.EMPTY_STRING),"USER_LINK","USER_LINK","User link")));if(e.hasOwnProperty(s.UserConstants.STATUS_MESSAGE)&&""===e[s.UserConstants.STATUS_MESSAGE])return new i.CometChatException(JSON.parse(h(JSON.stringify(s.GENERAL_ERROR.EMPTY_STRING),"USER_STATUS_MESSAGE","USER_STATUS_MESSAGE","User status message")));if(e.hasOwnProperty(s.UserConstants.ROLE)&&""===e[s.UserConstants.ROLE])return new i.CometChatException(JSON.parse(h(JSON.stringify(s.GENERAL_ERROR.EMPTY_STRING),"USER_ROLE","USER_ROLE","User role")));if(e.hasOwnProperty(s.UserConstants.TAGS)){if(!Array.isArray(e[s.UserConstants.TAGS]))return new i.CometChatException(JSON.parse(h(JSON.stringify(s.GENERAL_ERROR.MUST_BE_AN_ARRAY),"USER_TAGS","USER_TAGS","User tags")));if(0===e[s.UserConstants.TAGS].length)return new i.CometChatException(JSON.parse(h(JSON.stringify(s.GENERAL_ERROR.EMPTY_ARRAY),"USER_TAGS","USER_TAGS","User tags")))}},t.validateUpdateUser=function(e){return e.hasOwnProperty(s.UserConstants.UID)?typeof e[s.UserConstants.UID]!==s.COMMON_UTILITY_CONSTANTS.TYPE_CONSTANTS.STRING?new i.CometChatException(JSON.parse(h(JSON.stringify(s.GENERAL_ERROR.MUST_BE_A_STRING),"UID","UID","UID"))):d(e[s.UserConstants.UID])?new i.CometChatException(JSON.parse(h(JSON.stringify(s.GENERAL_ERROR.INVALID_USER_PROPERTY),"UID","UID","UID","UID"))):e.hasOwnProperty(s.UserConstants.NAME)&&""===e[s.UserConstants.NAME]?new i.CometChatException(JSON.parse(h(JSON.stringify(s.GENERAL_ERROR.EMPTY_STRING),"USER_NAME","USER_NAME","User name"))):void 0:new i.CometChatException(JSON.parse(h(JSON.stringify(s.GENERAL_ERROR.PARAMETER_COMPULSORY),"UID","UID","UID","UID")))},t.validateConversationType=function(e){return typeof e!==s.COMMON_UTILITY_CONSTANTS.TYPE_CONSTANTS.STRING?new i.CometChatException(JSON.parse(h(JSON.stringify(s.GENERAL_ERROR.MUST_BE_A_STRING),"CONVERSATION_TYPE","CONVERSATION_TYPE","Conversation type"))):d(e)?new i.CometChatException(JSON.parse(h(JSON.stringify(s.GENERAL_ERROR.INVALID),"CONVERSATION_TYPE","CONVERSATION_TYPE","conversation type","conversation type"))):(e=e.toLowerCase())!=l.CometChat.RECEIVER_TYPE.USER&&e!=l.CometChat.RECEIVER_TYPE.GROUP?new i.CometChatException(s.ConversationErrors.INVALID_CONVERSATION_TYPE):void 0}},function(e,t,n){"use strict";t.__esModule=!0;var r=function(e){null!==e.code&&void 0!==e.code&&""!==e.code&&(this.code=e.code),null!==e.name&&void 0!==e.name&&""!==e.name&&(this.name=e.name),null!==e.message&&void 0!==e.message&&""!==e.message&&(this.message=e.message),null!==e.details&&void 0!==e.details&&""!==e.details&&(this.details=e.details)};t.CometChatException=r},function(e,t,n){"use strict";(function(e){var r=this&&this.__assign||function(){return r=Object.assign||function(e){for(var t,n=1,r=arguments.length;n<r;n++)for(var s in t=arguments[n])Object.prototype.hasOwnProperty.call(t,s)&&(e[s]=t[s]);return e},r.apply(this,arguments)},s=this&&this.__awaiter||function(e,t,n,r){return new(n||(n=Promise))((function(s,o){function i(e){try{c(r.next(e))}catch(e){o(e)}}function a(e){try{c(r.throw(e))}catch(e){o(e)}}function c(e){e.done?s(e.value):new n((function(t){t(e.value)})).then(i,a)}c((r=r.apply(e,t||[])).next())}))},o=this&&this.__generator||function(e,t){var n,r,s,o,i={label:0,sent:function(){if(1&s[0])throw s[1];return s[1]},trys:[],ops:[]};return o={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(o[Symbol.iterator]=function(){return this}),o;function a(o){return function(a){return function(o){if(n)throw new TypeError("Generator is already executing.");for(;i;)try{if(n=1,r&&(s=2&o[0]?r.return:o[0]?r.throw||((s=r.return)&&s.call(r),0):r.next)&&!(s=s.call(r,o[1])).done)return s;switch(r=0,s&&(o=[2&o[0],s.value]),o[0]){case 0:case 1:s=o;break;case 4:return i.label++,{value:o[1],done:!1};case 5:i.label++,r=o[1],o=[0];continue;case 7:o=i.ops.pop(),i.trys.pop();continue;default:if(!(s=i.trys,(s=s.length>0&&s[s.length-1])||6!==o[0]&&2!==o[0])){i=0;continue}if(3===o[0]&&(!s||o[1]>s[0]&&o[1]<s[3])){i.label=o[1];break}if(6===o[0]&&i.label<s[1]){i.label=s[1],s=o;break}if(s&&i.label<s[2]){i.label=s[2],i.ops.push(o);break}s[2]&&i.ops.pop(),i.trys.pop();continue}o=t.call(e,i)}catch(e){o=[6,e],r=0}finally{n=s=0}if(5&o[0])throw o[1];return{value:o[0]?o[1]:void 0,done:!0}}([o,a])}}};t.__esModule=!0;var i=n(30),a=n(1),c=n(2),u=n(5),l=n(4),E=n(14),d=n(15),h=n(9),p=n(19),S=n(18),g=n(7),C=n(23),_=n(8),f=n(0),T=n(6),m=n(16),A=n(40),I=n(51),R=n(22),N=n(25),O=n(34),y=n(13),P=n(24),M=n(52),v=n(53),L=n(55),D=n(56),U=n(57),w=n(26),b=n(36),G=n(37),Y=n(21),x=n(41),F=n(58),B=n(38),H=n(27),K=n(59),k=n(39),V=n(60),J=n(42),X=n(28),j=n(20),q=n(61),W=n(62),Q=n(63),z=n(31),$=n(35),Z=n(64),ee=E.XMPPConnectionHelper.getInstance(),te=function(){function t(r){try{"undefined"!=typeof document?a.Logger.info("This is browser","we have everything"):"undefined"!=typeof navigator&&"ReactNative"==navigator.product?(a.Logger.info("This is react-native","we do not have dom"),e.DOMParser=n(67).DOMParser,e.document=(new e.DOMParser).parseFromString("<?xml version='1.0'?>","text/xml"),t.isNative=!0):a.Logger.info("This is node","we do not have anything"),t.typingTimer(),t.appId=r,t.messagesStore=C.MessagesStore.getInstance(),t.localStorage=h.LocalStorage.getInstance(),t.userStore=A.UserStore.getInstance(),t.keyStore=I.KeyStore.getInstance(),t.messageListnerMaping=w.MessageListnerMaping.getInstance()}catch(e){a.Logger.error("CometChat: constructor",e)}}return t.setAuthToken=function(e){try{t.authToken=e}catch(e){a.Logger.error("CometChat: setAuthToken",e)}},t.prototype.getAuthToken=function(){try{return t.authToken}catch(e){a.Logger.error("CometChat: getAuthToken",e)}},t.getAppId=function(){try{return t.appId}catch(e){a.Logger.error("CometChat: getAppId",e)}},t.prototype.getApiKey=function(){try{return t.apiKey}catch(e){a.Logger.error("CometChat: getApiKey",e)}},t.getMode=function(){try{return t.mode}catch(e){a.Logger.error("CometChat: getMode",e)}},t.setMode=function(e){try{t.mode=e}catch(e){a.Logger.error("CometChat: getMode",e)}},t.getSessionId=function(){try{return t.sessionId}catch(e){a.Logger.error("CometChat: getAppId",e)}},t.getLastMessageId=function(){try{return t.lastMessageId}catch(e){a.Logger.error("CometChat: getLastMessageId",e)}},t.setLastMessageId=function(e){try{t.lastMessageId=e}catch(e){a.Logger.error("CometChat: getLastMessageId",e)}},t.setSuccessfulTimeStamp=function(e){try{t.successfulPingTimeStamp=e}catch(e){a.Logger.error("CometChat: setSuccessfulTimeStamp",e)}},t.getSuccessfultTimeStamp=function(){try{return t.successfulPingTimeStamp}catch(e){a.Logger.error("CometChat: getSuccessfultTimeStamp",e)}},t.onStorageEvent=function(e){var n=this;if(document&&!document.hasFocus()){var r=t.appId+":common_store/user";e.key===r&&null===e.newValue&&(t.authToken=void 0,t.didAnalyticsPingStart()&&t.clearAnalyticsPingTimer(),t.didMessagesPollingStart()&&t.clearMessagesTimer(),E.XMPPConnectionHelper.getInstance().XMPPDisconnect(),t.pushToLoginListener("","Logout_Success")),e.key===r&&null===e.oldValue&&h.LocalStorage.getInstance().get("user").then((function(e){e&&(t.user=new l.Me(e),t.setAuthToken(t.user.getAuthToken()),e.jwt&&(t.jwt=e.jwt),h.LocalStorage.getInstance().get("app_settings").then((function(e){if(e)if(e[f.APP_SETTINGS.KEYS.MODE]&&(t.mode=e[f.APP_SETTINGS.KEYS.MODE]),e[f.APP_SETTINGS.KEYS.SETTINGS_HASH]&&(t.settingsHash=e[f.APP_SETTINGS.KEYS.SETTINGS_HASH]),e[f.APP_SETTINGS.KEYS.SETTINGS_HASH_RECEIVED_AT]&&(t.settingsHashReceivedAt=e[f.APP_SETTINGS.KEYS.SETTINGS_HASH_RECEIVED_AT]),e[f.APP_SETTINGS.KEYS.ANALYTICS_HOST]&&(t.analyticsHost=e[f.APP_SETTINGS.KEYS.ANALYTICS_HOST]),e[f.APP_SETTINGS.KEYS.ANALYTICS_VERSION]&&(t.analyticsVersion=e[f.APP_SETTINGS.KEYS.ANALYTICS_VERSION]),e[f.APP_SETTINGS.KEYS.ANALYTICS_PING_DISABLED]?t.isAnalyticsDisabled=!0:t.isAnalyticsDisabled=!1,e.hasOwnProperty(f.APP_SETTINGS.KEYS.DENY_FALLBACK_TO_POLLING)&&(t.shouldFallBackToPolling=!1),t.didAnalyticsPingStart()||t.isAnalyticsDisabled||(t.pingAnalytics(),t.startAnalyticsPingTimer()),e[f.APP_SETTINGS.KEYS.POLLING_ENABLED])n.currentConnectionStatus=f.CONNECTION_STATUS.FEATURE_THROTTLED,t.pollingEnabled=!0,t.pollingInterval=e[f.APP_SETTINGS.KEYS.POLLING_INTERVAL],t.didMessagesPollingStart()||(ee.XMPPConnectionHandlers.map((function(e){try{e._XMPPeventListener&&(a.isFalsy(e._XMPPeventListener.onFeatureThrottled)||e._XMPPeventListener.onFeatureThrottled())}catch(e){a.Logger.error("XMPPConnectionHandlers: Feature Throttled Status",e)}})),t.fetchMessages(),t.startMessagesTimer());else if(t.getConnectionStatus()!==f.CONNECTION_STATUS.CONNECTED){var r=new l.User(t.user);t.pushToLoginListener(r,"Login_Success"),t.XMPPLogin(t.user,(function(){}),(function(){}))}})))}))}},t.beforeUnload=function(e){var n=t.getDataFromSessionStorage(f.SESSION_STORE.SESSION_ID);t.removeDataFromSessionStorage(f.SESSION_STORE.SESSION_ID),h.LocalStorage.getInstance().set(f.SESSION_STORE.SESSION_ID,n)},t.isPollingEnabled=function(){try{return t.pollingEnabled}catch(e){a.Logger.error("CometChat: isPollingEnabled",e)}},t.didMessagesPollingStart=function(){try{return t.isMessagesPollingStarted}catch(e){a.Logger.error("CometChat: didMessagesPollingStart",e)}},t.didAnalyticsPingStart=function(){try{return t.isAnalyticsPingStarted}catch(e){a.Logger.error("CometChat: didAnalyticsPingStart",e)}},t.getDataFromSessionStorage=function(e){if(window.sessionStorage)return window.sessionStorage.getItem(e)},t.addDataToSessionStorage=function(e,t){window.sessionStorage&&window.sessionStorage.setItem(e,t)},t.removeDataFromSessionStorage=function(e){window.sessionStorage&&window.sessionStorage.removeItem(e)},t.init=function(e,n){var r=this;return void 0===e&&(e=""),void 0===n&&(n={}),new Promise((function(s,o){try{t.pollingMessagesId=0,"object"==typeof e&&(e.hasOwnProperty("appId")&&(e=e.appId),e.hasOwnProperty("appSettings")&&(n=e.appSettings)),a.isFalsy(n)?n=(new k.AppSettingsBuilder).setRegion(k.AppSettings.REGION_EU).build():n.getRegion()==k.AppSettings.REGION_PRIVATE&&(n.region=e),r.appSettings=n,a.isFalsy(e)?o(new c.CometChatException(y.INIT_ERROR.NO_APP_ID)):(t.setSuccessfulTimeStamp((new Date).getTime()),window.addEventListener&&(window.addEventListener("storage",t.onStorageEvent,!1),window.addEventListener("beforeunload",t.beforeUnload,!1)),r.initialzed=!0,t.appId=e,t.getInstance(e),t.setLastMessageId(0),t.shouldFallBackToPolling=!0,h.LocalStorage.getInstance().get(f.SESSION_STORE.SESSION_ID).then((function(n){null==n||null==n?(t.sessionId=f.APPINFO.platform+"-"+f.APPINFO.sdkVersionWithUnderScore+"-"+Z()+"-"+(new Date).getTime(),t.addDataToSessionStorage(f.SESSION_STORE.SESSION_ID,t.getSessionId()),h.LocalStorage.getInstance().remove(f.SESSION_STORE.SESSION_ID)):(t.sessionId=n.toLocaleString(),h.LocalStorage.getInstance().remove(f.SESSION_STORE.SESSION_ID),t.addDataToSessionStorage(f.SESSION_STORE.SESSION_ID,t.getSessionId())),h.LocalStorage.getInstance().get("appId").then((function(n){if(null==n||null==n)t.appId=e,t.getInstance(e),h.LocalStorage.getInstance().set("appId",e),s(!0);else{var i=n.toLocaleString();i===e?(t.appId=i,t.getInstance(i),h.LocalStorage.getInstance().get("user").then((function(e){e?(t.isLoggedOut=!1,t.user=new l.Me(e),t.setAuthToken(t.user.getAuthToken()),e.jwt&&(t.jwt=e.jwt),s(!0),h.LocalStorage.getInstance().get("app_settings").then((function(e){e&&(e[f.APP_SETTINGS.KEYS.MODE]&&(t.mode=e[f.APP_SETTINGS.KEYS.MODE]),e[f.APP_SETTINGS.KEYS.SETTINGS_HASH]&&(t.settingsHash=e[f.APP_SETTINGS.KEYS.SETTINGS_HASH]),e[f.APP_SETTINGS.KEYS.SETTINGS_HASH_RECEIVED_AT]&&(t.settingsHashReceivedAt=e[f.APP_SETTINGS.KEYS.SETTINGS_HASH_RECEIVED_AT]),e[f.APP_SETTINGS.KEYS.ANALYTICS_HOST]&&(t.analyticsHost=e[f.APP_SETTINGS.KEYS.ANALYTICS_HOST]),e[f.APP_SETTINGS.KEYS.ANALYTICS_VERSION]&&(t.analyticsVersion=e[f.APP_SETTINGS.KEYS.ANALYTICS_VERSION]),e[f.APP_SETTINGS.KEYS.ANALYTICS_PING_DISABLED]?t.isAnalyticsDisabled=!0:t.isAnalyticsDisabled=!1,e.hasOwnProperty(f.APP_SETTINGS.KEYS.DENY_FALLBACK_TO_POLLING)&&(t.shouldFallBackToPolling=!1),t.didAnalyticsPingStart()||t.isAnalyticsDisabled||(t.pingAnalytics(),t.startAnalyticsPingTimer()),e[f.APP_SETTINGS.KEYS.POLLING_ENABLED]?(t.pollingEnabled=!0,e[f.APP_SETTINGS.KEYS.POLLING_INTERVAL]&&(t.pollingInterval=e[f.APP_SETTINGS.KEYS.POLLING_INTERVAL]),r.currentConnectionStatus=f.CONNECTION_STATUS.FEATURE_THROTTLED,t.didMessagesPollingStart()||(ee.XMPPConnectionHandlers.map((function(e){try{e._XMPPeventListener&&(a.isFalsy(e._XMPPeventListener.onFeatureThrottled)||e._XMPPeventListener.onFeatureThrottled())}catch(e){a.Logger.error("XMPPConnectionHandlers: Feature Throttled Status",e)}})),t.pollingMessagesTimestamp=Math.floor((new Date).getTime()/1e3),t.fetchMessages(),t.startMessagesTimer())):ee&&!ee.connection&&(t.pollingEnabled=!1,t.isConnectingFromInit=!0,t.XMPPLogin(t.user,(function(){s(!0)}),(function(){o("error in connecting to xmpp server")}))))}))):s(!0)}))):r.clearCache().then((function(){t.apiKey=void 0,t.user=void 0,t.authToken=void 0,t.cometChat=void 0,t.mode=void 0,E.XMPPConnectionHelper.getInstance().XMPPDisconnect(),t.appId=e,h.LocalStorage.getInstance().set("appId",e),t.getInstance(e),s(!0)}))}I.KeyStore.getInstance().get("deviceId").then((function(t){if(null==t){var n=Z(),r=(new Date).getTime(),s=e+"_"+n+"_"+r;I.KeyStore.getInstance().set("deviceId",s)}}))}))})))}catch(e){o(new c.CometChatException(e))}}))},t.isInitialized=function(){try{return this.initialzed}catch(e){a.Logger.error("CometChat: isInitialized",e)}},t.getInstance=function(e){try{return this.cometChat||(this.cometChat=new t(e)),this.cometChat}catch(e){a.Logger.error("CometChat: getInstance",e)}},t.registerTokenForPushNotification=function(e,n){var r=this;return new Promise((function(s,o){try{t.keyStore.get("deviceId").then((function(i){var a="",l=i,E=f.APPINFO.platform,d=f.APPINFO.sdkVersion,h=f.APPINFO.apiVersion;if(navigator&&(a=navigator.userAgent),null==l){var p=Z(),S=(new Date).getTime();l=r.appId+"_"+p+"_"+S,t.keyStore.set("deviceId",l)}var g={platform:E,deviceId:l,appInfo:{version:d,apiVersion:h,userAgent:a,pushNotification:{fcmDeviceToken:e,settings:n}}};u.makeApiCall("updateMyDetails",{},g,!1).then((function(e){s("Token Registration successful")}),(function(e){o(new c.CometChatException(e.error))})).catch((function(e){o(new c.CometChatException(e))}))}))}catch(e){o(new c.CometChatException(e))}}))},t.pushToLoginListener=function(e,t){ee.loginHandlers.map((function(n){try{if(n._eventListener)switch(t){case"Login_Success":a.isFalsy(n._eventListener.loginSuccess)||n._eventListener.loginSuccess(e);break;case"Login_Failure":a.isFalsy(n._eventListener.loginFailure)||n._eventListener.loginFailure(e);break;case"Logout_Success":a.isFalsy(n._eventListener.logoutSuccess)||n._eventListener.logoutSuccess()}}catch(e){a.Logger.error("XMPPConnectionHandlers: onConnected Status",e)}}))},t.login=function(){for(var e=this,n=[],r=0;r<arguments.length;r++)n[r]=arguments[r];return new Promise((function(r,s){try{if(t.isLoggedOut=!1,t.pollingMessagesId=0,t.loginInProgress){var o=new c.CometChatException(y.LOGIN_ERROR.REQUEST_IN_PROGRESS);return s(o)}t.loginInProgress=!0,t.isConnectingFromInit=!1,t.localStorage.get("appId").then((function(o){if(null==o||null==o){var i=new c.CometChatException(y.LOGIN_ERROR.NOT_INITIALIZED);return t.internalRestart||t.pushToLoginListener(i,"Login_Failure"),t.loginInProgress=!1,t.isLoggedOut=!0,s(i)}var u=o.toLocaleString();if(e.getInstance(u),t.appId=u,h.LocalStorage.getInstance().set("appId",u),"object"==typeof n[0]){var d=n[0];n[0].hasOwnProperty("authToken")?n[0]=d.authToken:n[0].hasOwnProperty("username")&&n[0].hasOwnProperty("apiKey")&&(n[0]=d.username,n[1]=d.apiKey)}if(2==n.length){if(a.isFalsy(n[0])||a.isFalsy(n[1])){i=new c.CometChatException(y.ERRORS.PARAMETER_MISSING);return t.internalRestart||t.pushToLoginListener(i,"Login_Failure"),t.loginInProgress=!1,t.isLoggedOut=!0,s(i)}}else{if(1!=n.length){i=new c.CometChatException(y.ERRORS.PARAMETER_MISSING);return t.internalRestart||t.pushToLoginListener(i,"Login_Failure"),t.loginInProgress=!1,t.isLoggedOut=!0,s(i)}if(a.isFalsy(n[0])){var i=new c.CometChatException(y.ERRORS.PARAMETER_MISSING);return t.internalRestart||t.pushToLoginListener(i,"Login_Failure"),t.loginInProgress=!1,t.isLoggedOut=!0,s(i)}}if(a.isFalsy(e.getAppId())){i=new c.CometChatException(y.LOGIN_ERROR.NOT_INITIALIZED);return t.internalRestart||t.pushToLoginListener(i,"Login_Failure"),t.loginInProgress=!1,t.isLoggedOut=!0,s(i)}return t.localStorage.get("user").then((function(o){if(2==n.length){t.isSecure=!1,t.apiKey=n[1];var i=n[0];if(null!=o&&o.uid!==n[0])t.messagesStore.clearStore().then((function(){t.userStore.clearStore().then((function(){t.localStorage.clearStore().then((function(){E.XMPPConnectionHelper.getInstance().XMPPDisconnect(),t.generateAuthToken(i).then((function(e){t.user=new l.Me(e),t.setAuthToken(t.user.getAuthToken()),t.getLoggedInUser().then((function(e){t.user=new l.Me(e),t.user.setAuthToken(t.authToken),t.setAuthToken(t.user.getAuthToken()),H.ExtensionController.hookOnLogin(t.user);var n=t.user;n.setStatus(f.PresenceConstatnts.STATUS.ONLINE),t.localStorage.set("user",n);var o=new l.User(n);r(o),t.isConnectingFromInit||t.internalRestart||t.pushToLoginListener(o,"Login_Success"),t.loginInProgress=!1,t.didAnalyticsPingStart()||t.isAnalyticsDisabled||(t.pingAnalytics(),t.startAnalyticsPingTimer()),t.isPollingEnabled()?(t.currentConnectionStatus=f.CONNECTION_STATUS.FEATURE_THROTTLED,t.didMessagesPollingStart()||(ee.XMPPConnectionHandlers.map((function(e){try{e._XMPPeventListener&&(a.isFalsy(e._XMPPeventListener.onFeatureThrottled)||e._XMPPeventListener.onFeatureThrottled())}catch(e){a.Logger.error("XMPPConnectionHandlers: Feature Throttled Status",e)}})),t.pollingMessagesTimestamp=Math.floor((new Date).getTime()/1e3),t.fetchMessages(),t.startMessagesTimer())):t.XMPPLogin(t.user,r,s)}),(function(e){return t.internalRestart||t.pushToLoginListener(e,"Login_Failure"),t.loginInProgress=!1,t.isLoggedOut=!0,s(e)}))}),(function(e){return t.internalRestart||t.pushToLoginListener(e,"Login_Failure"),t.loginInProgress=!1,t.isLoggedOut=!0,s(e)}))}))}))}));else{if(!a.isFalsy(t.authToken)){H.ExtensionController.hookOnLogin(t.user);var u=new l.User(e.user);return t.internalRestart||t.pushToLoginListener(u,"Login_Success"),t.loginInProgress=!1,r(u)}if(!a.isFalsy(i)){if(a.isFalsy(t.apiKey)){var d=new c.CometChatException(y.LOGIN_ERROR.UNAUTHORISED);return t.internalRestart||t.pushToLoginListener(d,"Login_Failure"),t.loginInProgress=!1,t.isLoggedOut=!0,s(d)}e.generateAuthToken(i).then((function(n){e.user=new l.Me(n),e.setAuthToken(t.user.getAuthToken()),e.getLoggedInUser().then((function(n){e.user=new l.Me(n),e.user.setAuthToken(t.authToken),e.setAuthToken(e.user.getAuthToken()),H.ExtensionController.hookOnLogin(t.user),E.XMPPConnectionHelper.getInstance().XMPPDisconnect();var o=e.user;o.setStatus(f.PresenceConstatnts.STATUS.ONLINE),e.localStorage.set("user",o);var i=new l.User(o);r(i),t.isConnectingFromInit||t.internalRestart||t.pushToLoginListener(i,"Login_Success"),t.loginInProgress=!1,t.didAnalyticsPingStart()||t.isAnalyticsDisabled||(t.pingAnalytics(),t.startAnalyticsPingTimer()),t.isPollingEnabled()?(e.currentConnectionStatus=f.CONNECTION_STATUS.FEATURE_THROTTLED,t.didMessagesPollingStart()||(ee.XMPPConnectionHandlers.map((function(e){try{e._XMPPeventListener&&(a.isFalsy(e._XMPPeventListener.onFeatureThrottled)||e._XMPPeventListener.onFeatureThrottled())}catch(e){a.Logger.error("XMPPConnectionHandlers: Feature Throttled Status",e)}})),t.pollingMessagesTimestamp=Math.floor((new Date).getTime()/1e3),t.fetchMessages(),t.startMessagesTimer())):e.XMPPLogin(e.user,r,s)}),(function(e){return t.internalRestart||t.pushToLoginListener(e,"Login_Failure"),t.loginInProgress=!1,t.isLoggedOut=!0,s(e)}))}),(function(e){return t.internalRestart||t.pushToLoginListener(e,"Login_Failure"),t.loginInProgress=!1,t.isLoggedOut=!0,s(e)}))}}}else t.authToken=n[0],t.isSecure=!0,e.getLoggedInUser().then((function(i){if(i.authToken!=n[0]){var c=e;c.messagesStore.clearStore().then((function(){c.userStore.clearStore().then((function(){c.localStorage.clearStore().then((function(){E.XMPPConnectionHelper.getInstance().XMPPDisconnect(),c.getLoggedInUser().then((function(e){t.user=new l.Me(e),t.user.setAuthToken(t.authToken),t.setAuthToken(t.user.getAuthToken());var n=t.user;n.setStatus(f.PresenceConstatnts.STATUS.ONLINE),c.localStorage.set("user",n);var o=new l.User(n);r(o),t.isConnectingFromInit||t.internalRestart||t.pushToLoginListener(o,"Login_Success"),t.loginInProgress=!1,t.didAnalyticsPingStart()||t.isAnalyticsDisabled||(t.pingAnalytics(),t.startAnalyticsPingTimer()),t.isPollingEnabled()?(c.currentConnectionStatus=f.CONNECTION_STATUS.FEATURE_THROTTLED,t.didMessagesPollingStart()||(ee.XMPPConnectionHandlers.map((function(e){try{e._XMPPeventListener&&(a.isFalsy(e._XMPPeventListener.onFeatureThrottled)||e._XMPPeventListener.onFeatureThrottled())}catch(e){a.Logger.error("XMPPConnectionHandlers: Feature Throttled Status",e)}})),t.pollingMessagesTimestamp=Math.floor((new Date).getTime()/1e3),t.fetchMessages(),t.startMessagesTimer())):t.XMPPLogin(new l.Me(e),r,s)}),(function(e){return t.internalRestart||t.pushToLoginListener(e,"Login_Failure"),t.loginInProgress=!1,t.isLoggedOut=!0,s(e)}))}))}))}))}else{if(o){var u=new l.User(i);return t.internalRestart||t.pushToLoginListener(u,"Login_Success"),t.loginInProgress=!1,r(u)}t.user=new l.Me(i),t.user.setAuthToken(t.authToken),t.setAuthToken(t.user.getAuthToken());var d=t.user;d.setStatus(f.PresenceConstatnts.STATUS.ONLINE),t.localStorage.set("user",d);var h=new l.User(d);r(h),t.isConnectingFromInit||t.internalRestart||t.pushToLoginListener(h,"Login_Success"),t.loginInProgress=!1,t.didAnalyticsPingStart()||t.isAnalyticsDisabled||(t.pingAnalytics(),t.startAnalyticsPingTimer()),t.isPollingEnabled()?(t.currentConnectionStatus=f.CONNECTION_STATUS.FEATURE_THROTTLED,t.didMessagesPollingStart()||(ee.XMPPConnectionHandlers.map((function(e){try{e._XMPPeventListener&&(a.isFalsy(e._XMPPeventListener.onFeatureThrottled)||e._XMPPeventListener.onFeatureThrottled())}catch(e){a.Logger.error("XMPPConnectionHandlers: Feature Throttled Status",e)}})),t.pollingMessagesTimestamp=Math.floor((new Date).getTime()/1e3),t.fetchMessages(),t.startMessagesTimer())):t.XMPPLogin(new l.Me(i),r,s)}}),(function(e){return t.internalRestart||t.pushToLoginListener(e,"Login_Failure"),t.loginInProgress=!1,t.isLoggedOut=!0,s(e)}))}))}))}catch(e){o=new c.CometChatException(e);return t.internalRestart||t.pushToLoginListener(o,"Login_Failure"),t.loginInProgress=!1,t.isLoggedOut=!0,s(o)}}))},t.sendMessage=function(e){var n=this;return new Promise((function(r,i){return s(n,void 0,void 0,(function(){var n,l,E,d,h,C=this;return o(this,(function(_){switch(_.label){case 0:return _.trys.push([0,2,,3]),e instanceof S.TextMessage||e instanceof p.MediaMessage||e instanceof Y.CustomMessage||(e[f.MessageConstatnts.KEYS.ATTATCHMENT]?(n=f.MessageConstatnts.TYPE.FILE,a.isImage(e[f.MessageConstatnts.KEYS.ATTATCHMENT])?n=f.MessageConstatnts.TYPE.IMAGE:a.isAudio(e[f.MessageConstatnts.KEYS.ATTATCHMENT])?n=f.MessageConstatnts.TYPE.AUDIO:a.isVideo(e[f.MessageConstatnts.KEYS.ATTATCHMENT])&&(n=f.MessageConstatnts.TYPE.VIDEO),e=new p.MediaMessage(e[f.MessageConstatnts.KEYS.RECEIVER_ID],e[f.MessageConstatnts.KEYS.ATTATCHMENT],n,e[f.MessageConstatnts.KEYS.RECEIVER_TYPE])):e=new S.TextMessage(e[f.MessageConstatnts.KEYS.RECEIVER_ID],e[f.MessageConstatnts.KEYS.TEXT],e[f.MessageConstatnts.KEYS.RECEIVER_TYPE])),[4,H.ExtensionController.hookBeforeMessageSent(e)];case 1:return l=_.sent(),e=l,(E=a.validateMessage(e))instanceof c.CometChatException?(i(E),[2]):(e.receiver=e.receiverId,delete e.receiverId,d=e.parentMessageId,[2,u.makeApiCall(d?"sendMessageInThread":"sendMessage",d?{parentId:d}:{},e,e instanceof p.MediaMessage).then((function(e){return s(C,void 0,void 0,(function(){var n,s;return o(this,(function(o){switch(o.label){case 0:return n=g.MessageController.trasformJSONMessge(e.data),[4,H.ExtensionController.hookAfterMessageSent(n)];case 1:return s=o.sent(),n=s,t.setLastMessageId(n.id),r(n),[2]}}))}))}),(function(e){i(new c.CometChatException(e.error))}))]);case 2:return h=_.sent(),i(new c.CometChatException(h)),[3,3];case 3:return[2]}}))}))}))},t.sendDirectMessage=function(e){try{return Object.assign(e,{receiverType:f.MessageConstatnts.RECEIVER_TYPE.USER}),this.sendMessage(e)}catch(e){a.Logger.error("CometChat: sendDirectMessage",e)}},t.sendGroupMessage=function(e){try{return Object.assign(e,{receiverType:f.MessageConstatnts.RECEIVER_TYPE.GROUP}),this.sendMessage(e)}catch(e){a.Logger.error("CometChat: sendGroupMessage",e)}},t.sendMediaMessage=function(e){try{return this.sendMessage(e)}catch(e){a.Logger.error("CometChat: sendMediaMessage",e)}},t.sendCustomMessage=function(e){try{return this.sendMessage(e)}catch(e){a.Logger.error("CometChat: sendCustomMessage",e)}},t.getLastDeliveredMessageId=function(){return s(this,void 0,void 0,(function(){var e;return o(this,(function(t){switch(t.label){case 0:return t.trys.push([0,2,,3]),[4,w.MessageListnerMaping.getInstance().get("all")];case 1:return[2,t.sent()];case 2:return e=t.sent(),a.Logger.error("CometChat: getLastDeliveredMessageId",e),[3,3];case 3:return[2]}}))}))},t.startTyping=function(e){try{if(a.isFalsy(e))return;var n,r=this.RECEIVER_TYPE.USER,s={};if(e instanceof b.TypingIndicator)n=e.getReceiverId(),r=e.getReceiverType(),s=e.getMetadata();else{if(!e.hasOwnProperty(f.TYPING_NOTIFICATION.RECEIVER_ID))return;n=e[f.TYPING_NOTIFICATION.RECEIVER_ID],e.hasOwnProperty(f.TYPING_NOTIFICATION.RECEIVER_TYPE)&&(r=e[f.TYPING_NOTIFICATION.RECEIVER_TYPE]),e.hasOwnProperty(f.TYPING_NOTIFICATION.META)&&(s=e[f.TYPING_NOTIFICATION.META])}if(a.isFalsy(n))return;r=r==this.RECEIVER_TYPE.USER?f.XMPP.CONVERSATION.TYPE.CHAT:f.XMPP.CONVERSATION.TYPE.GROUP_CHAT,(G.TypingNotificationController.getTypingStartedMap(n)&&a.getCurrentTime()-G.TypingNotificationController.getTypingStartedMap(n)>=1e3*f.DEFAULT_VALUES.DEFAULT_MAX_TYPING_INDICATOR_LIMIT||null==G.TypingNotificationController.getTypingStartedMap(n))&&a.getAppSettings().then((function(e){var o=t.getMode();if(a.isFalsy(o)||o&&o===f.APP_SETTINGS.KEYS.DEFAULT_MODE){switch(r){case f.XMPP.CONVERSATION.TYPE.CHAT:ee.sendTypingStarted(a.format(f.XMPP.bare_jid_string,t.getAppId(),n,a.getJidHost(e)),r,s);break;case f.XMPP.CONVERSATION.TYPE.GROUP_CHAT:ee.sendTypingStarted(a.format(f.XMPP.muc_jid_string,t.getAppId(),n,e[f.APP_SETTINGS.KEYS.GROUP_SERVICE],a.getJidHost(e)),r,s)}return G.TypingNotificationController.addTypingStarted(n),void G.TypingNotificationController.removeTypingEnded(n)}}),(function(e){}))}catch(e){a.Logger.error("CometChat: startTyping",e)}},t.endTyping=function(e){try{if(!a.isFalsy(e)){var n,r=this.RECEIVER_TYPE.USER,s={};if(e instanceof b.TypingIndicator)n=e.getReceiverId(),r=e.getReceiverType(),s=e.getMetadata();else{if(!e.hasOwnProperty(f.TYPING_NOTIFICATION.RECEIVER_ID))return;n=e[f.TYPING_NOTIFICATION.RECEIVER_ID],e.hasOwnProperty(f.TYPING_NOTIFICATION.RECEIVER_TYPE)&&(r=e[f.TYPING_NOTIFICATION.RECEIVER_TYPE]),r=r==this.RECEIVER_TYPE.USER?f.XMPP.CONVERSATION.TYPE.CHAT:f.XMPP.CONVERSATION.TYPE.GROUP_CHAT,e.hasOwnProperty(f.TYPING_NOTIFICATION.META)&&(s=e[f.TYPING_NOTIFICATION.META])}if(a.isFalsy(n))return;r=r==this.RECEIVER_TYPE.USER?f.XMPP.CONVERSATION.TYPE.CHAT:f.XMPP.CONVERSATION.TYPE.GROUP_CHAT,G.TypingNotificationController.getTypingStartedMap(n)&&a.getCurrentTime()-G.TypingNotificationController.getTypingStartedMap(n)<1e3*f.DEFAULT_VALUES.DEFAULT_MAX_TYPING_INDICATOR_LIMIT&&(G.TypingNotificationController.getTypingEndedMap(n)&&a.getCurrentTime()-G.TypingNotificationController.getTypingEndedMap(n)>=1e3*f.DEFAULT_VALUES.DEFAULT_MAX_TYPING_INDICATOR_LIMIT||null==G.TypingNotificationController.getTypingEndedMap(n))&&a.getAppSettings().then((function(e){var o=t.getMode();if(a.isFalsy(o)||o&&o===f.APP_SETTINGS.KEYS.DEFAULT_MODE){switch(r){case f.XMPP.CONVERSATION.TYPE.CHAT:ee.sendTypingPaused(a.format(f.XMPP.bare_jid_string,t.getAppId(),n,a.getJidHost(e)),r,s);break;case f.XMPP.CONVERSATION.TYPE.GROUP_CHAT:ee.sendTypingPaused(a.format(f.XMPP.muc_jid_string,t.getAppId(),n,e[f.APP_SETTINGS.KEYS.GROUP_SERVICE],a.getJidHost(e)),r,s)}return G.TypingNotificationController.addTypingEnded(n),void G.TypingNotificationController.removeTypingStarted(n)}}),(function(e){}))}}catch(e){a.Logger.error("CometChat: endTyping",e)}},t.markAsRead=function(e,t,n){try{E.XMPPConnectionHelper.getInstance().markAsRead(t,n,e)}catch(e){a.Logger.error("CometChat: markAsRead",e)}},t.markAsDelivered=function(e,t,n){try{E.XMPPConnectionHelper.getInstance().markAsDelivered(t,n,e)}catch(e){a.Logger.error("CometChat: markAsDelivered",e)}},t.getMessageDetails=function(e){return new Promise((function(t,n){try{a.isFalsy(e)?n(new c.CometChatException(y.ERRORS.PARAMETER_MISSING)):u.makeApiCall("getMessageDetails",{messageId:e}).then((function(e){t(g.MessageController.trasformJSONMessge(e.data))}),(function(e){a.Logger.error("CometChat:GetMessageDetails:",e),n(new c.CometChatException(e.error))}))}catch(e){n(new c.CometChatException(e))}}))},t.getMessageReceipts=function(e){return new Promise((function(t,n){try{var r=a.validateMsgId(e);if(r instanceof c.CometChatException)return void n(r);a.isFalsy(e)?n(new c.CometChatException(y.ERRORS.PARAMETER_MISSING)):u.makeApiCall("getMessageDetails",{messageId:e}).then((function(e){g.MessageController.getReceiptsFromJSON(e.data).then((function(e){t(e)}),(function(e){n(new c.CometChatException(e))}))}),(function(e){a.Logger.error("CometChat:GetMessageDetails:",e),n(new c.CometChatException(e.error))}))}catch(e){n(new c.CometChatException(e))}}))},t.getUnreadMessageCount=function(e){void 0===e&&(e=!1);var t=0;return new Promise((function(n,r){try{var s=a.validateHideMessagesFromBlockedUsers(e);if(s instanceof c.CometChatException)return void r(s);e&&(t=1),u.makeApiCall("getMessages",{},{unread:1,count:1,hideMessagesFromBlockedUsers:t}).then((function(e){var t={},r={};e.data.map((function(e){e[f.ResponseConstants.RESPONSE_KEYS.UNREAD_UNDELIVERED_KEYS.ENTITY_TYPE]==f.MessageConstatnts.RECEIVER_TYPE.GROUP?r[e[f.ResponseConstants.RESPONSE_KEYS.UNREAD_UNDELIVERED_KEYS.ENTITY_Id]]=e[f.ResponseConstants.RESPONSE_KEYS.UNREAD_UNDELIVERED_KEYS.COUNT]:t[e[f.ResponseConstants.RESPONSE_KEYS.UNREAD_UNDELIVERED_KEYS.ENTITY_Id]]=e[f.ResponseConstants.RESPONSE_KEYS.UNREAD_UNDELIVERED_KEYS.COUNT]})),n({users:t,groups:r})}),(function(e){r(new c.CometChatException(e.error))}))}catch(e){r(new c.CometChatException(e))}}))},t.getUnreadMessageCountForAllUsers=function(e){void 0===e&&(e=!1);var t=0;return new Promise((function(n,s){try{var o=a.validateHideMessagesFromBlockedUsers(e);if(o instanceof c.CometChatException)return void s(o);e&&(t=1),u.makeApiCall("getMessages",{},{hideMessagesFromBlockedUsers:t,receiverType:f.MessageConstatnts.RECEIVER_TYPE.USER,unread:1,count:1}).then((function(e){var t={};e.data.map((function(e){t[e[f.ResponseConstants.RESPONSE_KEYS.UNREAD_UNDELIVERED_KEYS.ENTITY_Id]]=e[f.ResponseConstants.RESPONSE_KEYS.UNREAD_UNDELIVERED_KEYS.COUNT]})),n(r({},t))}),(function(e){s(new c.CometChatException(e.error))}))}catch(e){s(new c.CometChatException(e))}}))},t.getUnreadMessageCountForAllGroups=function(e){void 0===e&&(e=!1);var t=0;return new Promise((function(n,s){try{var o=a.validateHideMessagesFromBlockedUsers(e);if(o instanceof c.CometChatException)return void s(o);e&&(t=1),u.makeApiCall("getMessages",{},{hideMessagesFromBlockedUsers:t,receiverType:f.MessageConstatnts.RECEIVER_TYPE.GROUP,unread:1,count:1}).then((function(e){var t={};e.data.map((function(e){e[f.ResponseConstants.RESPONSE_KEYS.UNREAD_UNDELIVERED_KEYS.ENTITY_TYPE]==f.MessageConstatnts.RECEIVER_TYPE.GROUP&&(t[e[f.ResponseConstants.RESPONSE_KEYS.UNREAD_UNDELIVERED_KEYS.ENTITY_Id]]=e[f.ResponseConstants.RESPONSE_KEYS.UNREAD_UNDELIVERED_KEYS.COUNT])})),n(r({},t))}),(function(e){s(new c.CometChatException(e.error))}))}catch(e){s(new c.CometChatException(e))}}))},t.getUnreadMessageCountForUser=function(e,t){void 0===t&&(t=!1);var n=0;return new Promise((function(s,o){try{var i=a.validateId(e,"user");if(i instanceof c.CometChatException)return void o(i);var l=a.validateHideMessagesFromBlockedUsers(t);if(l instanceof c.CometChatException)return void o(l);t&&(n=1),u.makeApiCall("getUserMessages",{listId:e},{hideMessagesFromBlockedUsers:n,unread:1,count:1,uid:e}).then((function(e){var t={};e.data.map((function(e){t[e[f.ResponseConstants.RESPONSE_KEYS.UNREAD_UNDELIVERED_KEYS.ENTITY_Id]]=e[f.ResponseConstants.RESPONSE_KEYS.UNREAD_UNDELIVERED_KEYS.COUNT]})),s(r({},t))}),(function(e){o(new c.CometChatException(e.error))}))}catch(e){o(new c.CometChatException(e))}}))},t.getUnreadMessageCountForGroup=function(e,t){void 0===t&&(t=!1);var n=0;return new Promise((function(s,o){try{var i=a.validateId(e,"group");if(i instanceof c.CometChatException)return void o(i);var l=a.validateHideMessagesFromBlockedUsers(t);if(l instanceof c.CometChatException)return void o(l);t&&(n=1),u.makeApiCall("getGroupMessages",{listId:e},{hideMessagesFromBlockedUsers:n,unread:1,count:1,guid:e}).then((function(e){var t={};e.data.map((function(e){e[f.ResponseConstants.RESPONSE_KEYS.UNREAD_UNDELIVERED_KEYS.ENTITY_TYPE]==f.MessageConstatnts.RECEIVER_TYPE.GROUP&&(t[e[f.ResponseConstants.RESPONSE_KEYS.UNREAD_UNDELIVERED_KEYS.ENTITY_Id]]=e[f.ResponseConstants.RESPONSE_KEYS.UNREAD_UNDELIVERED_KEYS.COUNT])})),s(r({},t))}),(function(e){o(new c.CometChatException(e.error))}))}catch(e){o(new c.CometChatException(e))}}))},t.editMessage=function(e){return new Promise((function(t,n){try{var r=a.validateMsgId(e.getId());if(r instanceof c.CometChatException)return void n(r);u.makeApiCall("updateMessage",{messageId:e.getId()},e).then((function(e){t(g.MessageController.trasformJSONMessge(e.data).getActionOn())}),(function(e){n(new c.CometChatException(e.error))}))}catch(e){n(new c.CometChatException(e))}}))},t.deleteMessage=function(e){return new Promise((function(t,n){try{var r=a.validateMsgId(e);if(r instanceof c.CometChatException)return void n(r);u.makeApiCall("deleteMessage",{messageId:e},{id:e}).then((function(e){t(g.MessageController.trasformJSONMessge(e.data).getActionOn())}),(function(e){n(new c.CometChatException(e.error))}))}catch(e){n(new c.CometChatException(e))}}))},t.getPreviousMessagesByTimestamp=function(e,t){return new Promise((function(n,r){try{a.isFalsy(t)?r(new c.CometChatException(JSON.parse(a.format(JSON.stringify(f.PARAMETER_ERROR.PARAMETER_REQUIRED),"TIMESTAMP","TIMESTAMP","timestamp")))):g.MessageController.getAllMessage(e,t,f.MessageConstatnts.PAGINATION.CURSOR_FILEDS.SENT_AT,f.MessageConstatnts.PAGINATION.AFFIX.PREPEND).then((function(e){return n(e)}),(function(e){return r(new c.CometChatException(e))}))}catch(e){r(new c.CometChatException(e))}}))},t.getPreviousMessagesById=function(e,t){return new Promise((function(n,r){try{a.isFalsy(t)?r(new c.CometChatException(JSON.parse(a.format(JSON.stringify(f.PARAMETER_ERROR.PARAMETER_REQUIRED),"MESSAGE_ID","MESSAGE_ID","messageId")))):g.MessageController.getAllMessage(e,t,f.MessageConstatnts.PAGINATION.CURSOR_FILEDS.ID,f.MessageConstatnts.PAGINATION.AFFIX.PREPEND).then((function(e){return n(e)}),(function(e){return r(new c.CometChatException(e))}))}catch(e){r(new c.CometChatException(e))}}))},t.getNextMessagesByTimestamp=function(e,t){return new Promise((function(n,r){try{a.isFalsy(t)?r(new c.CometChatException(JSON.parse(a.format(JSON.stringify(f.PARAMETER_ERROR.PARAMETER_REQUIRED),"TIMESTAMP","TIMESTAMP","timestamp")))):g.MessageController.getAllMessage(e,t,f.MessageConstatnts.PAGINATION.CURSOR_FILEDS.SENT_AT,f.MessageConstatnts.PAGINATION.AFFIX.APPEND).then((function(e){return n(e)}),(function(e){return r(new c.CometChatException(e))}))}catch(e){r(new c.CometChatException(e))}}))},t.getNextMessagesById=function(e,t){return new Promise((function(n,r){try{a.isFalsy(t)?r(new c.CometChatException(JSON.parse(a.format(JSON.stringify(f.PARAMETER_ERROR.PARAMETER_REQUIRED),"MESSAGE_ID","MESSAGE_ID","messageId")))):g.MessageController.getAllMessage(e,t,f.MessageConstatnts.PAGINATION.CURSOR_FILEDS.ID,f.MessageConstatnts.PAGINATION.AFFIX.APPEND).then((function(e){return n(e)}),(function(e){return r(new c.CometChatException(e))}))}catch(e){r(new c.CometChatException(e))}}))},t.createUser=function(e,n){return new Promise((function(r,s){try{if(a.isFalsy(n))return void s(new c.CometChatException(JSON.parse(a.format(JSON.stringify(f.GENERAL_ERROR.INVALID),"AUTH_KEY","AUTH_KEY","AUTH_KEY","AUTH_KEY"))));t.apiKey=n;var o=a.validateCreateUser(e);if(o instanceof c.CometChatException)return void s(o);if(!(e instanceof l.User)){var i=void 0;if(!e.hasOwnProperty(f.UserConstants.UID))return void s(new c.CometChatException(y.ERRORS.PARAMETER_MISSING));if(!e.hasOwnProperty(f.UserConstants.NAME))return void s(new c.CometChatException(y.ERRORS.PARAMETER_MISSING));i=new l.User(e[f.UserConstants.UID],e[f.UserConstants.NAME]),e.hasOwnProperty(f.UserConstants.AVATAR)&&i.setAvatar(e[f.UserConstants.AVATAR]),e.hasOwnProperty(f.UserConstants.ROLE)&&i.setRole(e[f.UserConstants.ROLE]),e.hasOwnProperty(f.UserConstants.META_DATA)&&i.setMetadata(e[f.UserConstants.META_DATA]),e.hasOwnProperty(f.UserConstants.LINK)&&i.setLink(e[f.UserConstants.LINK]),e.hasOwnProperty(f.UserConstants.STATUS_MESSAGE)&&i.setStatusMessage(e[f.UserConstants.STATUS_MESSAGE]),e.hasOwnProperty(f.UserConstants.TAGS)&&i.setTags(e[f.UserConstants.TAGS]),e=i}u.makeApiCall("createUser",{},e).then((function(e){var t=_.UsersController.trasformJSONUser(e.data);r(t)}),(function(e){s(new c.CometChatException(e.error))}))}catch(e){s(new c.CometChatException(e))}}))},t.updateUser=function(e,n){var r=this;return new Promise((function(s,o){try{if(a.isFalsy(n))return void o(new c.CometChatException(JSON.parse(a.format(JSON.stringify(f.GENERAL_ERROR.INVALID),"AUTH_KEY","AUTH_KEY","AUTH_KEY","AUTH_KEY"))));t.apiKey=n;var i=a.validateUpdateUser(e);if(i instanceof c.CometChatException)return void o(i);if(!(e instanceof l.User)){var E=void 0;if(!e.hasOwnProperty(f.UserConstants.UID))return void o(new c.CometChatException(y.ERRORS.PARAMETER_MISSING));E=new l.User(e[f.UserConstants.UID]),e.hasOwnProperty(f.UserConstants.NAME)&&E.setName(e[f.UserConstants.NAME]),e.hasOwnProperty(f.UserConstants.AVATAR)&&E.setAvatar(e[f.UserConstants.AVATAR]),e.hasOwnProperty(f.UserConstants.ROLE)&&E.setRole(e[f.UserConstants.ROLE]),e.hasOwnProperty(f.UserConstants.META_DATA)&&E.setMetadata(e[f.UserConstants.META_DATA]),e.hasOwnProperty(f.UserConstants.LINK)&&E.setLink(e[f.UserConstants.LINK]),e.hasOwnProperty(f.UserConstants.STATUS_MESSAGE)&&E.setStatusMessage(e[f.UserConstants.STATUS_MESSAGE]),e.hasOwnProperty(f.UserConstants.TAGS)&&E.setTags(e[f.UserConstants.TAGS]),e=E}var d=e.uid;u.makeApiCall("updateUser",{uid:d},e).then((function(e){if(r.user&&d.toLocaleLowerCase()===r.user.getUid().toLocaleLowerCase())h.LocalStorage.getInstance().get("user").then((function(n){if(n){var o=_.UsersController.trasformJSONUser(e.data),i=e.data;i.wsChannel=n.wsChannel,i.authToken=t.authToken,i.status=f.PresenceConstatnts.STATUS.ONLINE,n.jwt&&(i.jwt=n.jwt),t.user=new l.Me(i),r.localStorage.set("user",t.user),s(o)}}));else{var n=_.UsersController.trasformJSONUser(e.data);s(n)}}),(function(e){o(new c.CometChatException(e.error))}))}catch(e){o(new c.CometChatException(e))}}))},t.updateCurrentUserDetails=function(e){var n=this;return new Promise((function(r,s){try{e.uid=n.user.uid;var o=a.validateUpdateUser(e);if(o instanceof c.CometChatException)return void s(o);if(!(e instanceof l.User)){var i=void 0;e.hasOwnProperty(f.UserConstants.UID)&&(i=new l.User(e[f.UserConstants.UID])),e.hasOwnProperty(f.UserConstants.NAME)&&i.setName(e[f.UserConstants.NAME]),e.hasOwnProperty(f.UserConstants.AVATAR)&&i.setAvatar(e[f.UserConstants.AVATAR]),e.hasOwnProperty(f.UserConstants.ROLE)&&i.setRole(e[f.UserConstants.ROLE]),e.hasOwnProperty(f.UserConstants.META_DATA)&&i.setMetadata(e[f.UserConstants.META_DATA]),e.hasOwnProperty(f.UserConstants.LINK)&&i.setLink(e[f.UserConstants.LINK]),e.hasOwnProperty(f.UserConstants.STATUS_MESSAGE)&&i.setStatusMessage(e[f.UserConstants.STATUS_MESSAGE]),e.hasOwnProperty(f.UserConstants.TAGS)&&i.setTags(e[f.UserConstants.TAGS]),e=i}u.makeApiCall("updateMyDetails",{},e).then((function(e){var n=_.UsersController.trasformJSONUser(e.data);t.user=new l.Me(e.data);var s=t.user;s.setStatus(f.PresenceConstatnts.STATUS.ONLINE),t.localStorage.set("user",s),r(n)}),(function(e){s(new c.CometChatException(e.error))}))}catch(e){s(new c.CometChatException(e))}}))},t.getUser=function(e){return new Promise((function(t,n){try{"object"==typeof e&&e.hasOwnProperty("uid")&&(e=e.uid);var r=a.validateId(e,"user");if(r instanceof c.CometChatException)return void n(r);u.makeApiCall("user",{uid:e}).then((function(e){var n=_.UsersController.trasformJSONUser(e.data);t(n)})).catch((function(e){n(new c.CometChatException(e.error))}))}catch(e){n(new c.CometChatException(e))}}))},t.getLoggedInUser=function(){var e=this;return new Promise((function(n,r){try{t.localStorage.get("user").then((function(s){if(s)n(t.user=new l.Me(s));else{var o="",i="",E=f.APPINFO.platform,d=f.APPINFO.sdkVersion,p=f.APPINFO.apiVersion;t.keyStore.get("deviceId").then((function(s){if(i=s,navigator&&(o=navigator.userAgent),null==i){var S=Z(),g=(new Date).getTime();i=e.appId+"_"+S+"_"+g,t.keyStore.set("deviceId",i)}var C={version:d,apiVersion:p,userAgent:o};a.isFalsy(e.platform)||(C.platform=e.platform),a.isFalsy(e.language)||(C.language=e.language),a.isFalsy(e.resource)||(C.resource=e.resource);var _={platform:E,deviceId:i,appInfo:C};u.makeApiCall("updateMyDetails",{},_,!1).then((function(e){e.data.jwt&&(t.jwt=e.data.jwt);var r=e.data.settings;r&&(h.LocalStorage.getInstance().set("app_settings",r),r[f.APP_SETTINGS.KEYS.MODE]&&t.setMode(r[f.APP_SETTINGS.KEYS.MODE]),r[f.APP_SETTINGS.KEYS.SETTINGS_HASH]&&(t.settingsHash=r[f.APP_SETTINGS.KEYS.SETTINGS_HASH]),r[f.APP_SETTINGS.KEYS.SETTINGS_HASH_RECEIVED_AT]&&(t.settingsHashReceivedAt=r[f.APP_SETTINGS.KEYS.SETTINGS_HASH_RECEIVED_AT]),r[f.APP_SETTINGS.KEYS.ANALYTICS_HOST]&&(t.analyticsHost=r[f.APP_SETTINGS.KEYS.ANALYTICS_HOST]),r[f.APP_SETTINGS.KEYS.ANALYTICS_VERSION]&&(t.analyticsVersion=r[f.APP_SETTINGS.KEYS.ANALYTICS_VERSION]),r[f.APP_SETTINGS.KEYS.ANALYTICS_PING_DISABLED]?t.isAnalyticsDisabled=!0:t.isAnalyticsDisabled=!1,r.hasOwnProperty(f.APP_SETTINGS.KEYS.DENY_FALLBACK_TO_POLLING)&&(t.shouldFallBackToPolling=!1),t.pollingEnabled=r[f.APP_SETTINGS.KEYS.POLLING_ENABLED],t.isPollingEnabled()&&r[f.APP_SETTINGS.KEYS.POLLING_INTERVAL]&&(t.pollingInterval=r[f.APP_SETTINGS.KEYS.POLLING_INTERVAL])),n(new l.Me(e.data))}),(function(e){r(new c.CometChatException(e.error))})).catch((function(e){r(new c.CometChatException(e))}))}))}}))}catch(e){r(new c.CometChatException(e))}}))},t.getLoggedinUser=function(){return new Promise((function(e,n){try{t.localStorage.get("user").then((function(t){e(t?new l.User(t):null)}),(function(t){e(null)}))}catch(e){n(new c.CometChatException(e))}}))},t.blockUsers=function(e){return new Promise((function(t,n){try{var r=a.validateArray(e,"blockUsers");if(r instanceof c.CometChatException)return void n(r);a.isFalsy(e)?n(new c.CometChatException(y.USERS_REQUEST_ERRORS.EMPTY_USERS_LIST)):u.makeApiCall("blockUsers",{},{blockedUids:e}).then((function(e){t(e.data)}),(function(e){n(new c.CometChatException(e.error))}))}catch(e){n(new c.CometChatException(e))}}))},t.unblockUsers=function(e){return new Promise((function(t,n){try{var r=a.validateArray(e,"unblockUsers");if(r instanceof c.CometChatException)return void n(r);a.isFalsy(e)?n(new c.CometChatException(y.USERS_REQUEST_ERRORS.EMPTY_USERS_LIST)):u.makeApiCall("unblockUsers",{},{blockedUids:e}).then((function(e){t(e.data)}),(function(e){n(new c.CometChatException(e.error))}))}catch(e){n(new c.CometChatException(e))}}))},t.getConversation=function(e,t){return new Promise((function(n,r){try{var s=a.validateConversationType(t);if(s instanceof c.CometChatException)return void r(s);var o=a.validateId(e,t);if(o instanceof c.CometChatException)return void r(o);t=t.toLowerCase(),e=e.toLowerCase();var i={},l="";t===f.MessageConstatnts.RECEIVER_TYPE.GROUP?(l="getGroupConversation",i.guid=e):(l="getUserConversation",i.uid=e),u.makeApiCall(l,i).then((function(s){if(s.data){var o=s.data;n(X.ConversationController.trasformJSONConversation(o.conversationId,o.conversationType,o.lastMessage,o.conversationWith,o.unreadMessageCount))}else r(new c.CometChatException(JSON.parse(a.format(JSON.stringify(f.ConversationErrors.CONVERSATION_NOT_FOUND),t,e))))}),(function(e){r(new c.CometChatException(e.error))}))}catch(e){r(new c.CometChatException(e))}}))},t.deleteConversation=function(e,t){return new Promise((function(n,r){try{var s=a.validateConversationType(t);if(s instanceof c.CometChatException)return void r(s);var o=a.validateId(e,t);if(o instanceof c.CometChatException)return void r(o);var i={},l="";t=t.toLowerCase(),e=e.toLowerCase(),t===f.MessageConstatnts.RECEIVER_TYPE.GROUP?(l="deleteGroupConversation",i.guid=e):(l="deleteUserConversation",i.uid=e),u.makeApiCall(l,i).then((function(e){n("Conversation deleted successfully.")}),(function(e){r(new c.CometChatException(e.error))}))}catch(e){r(new c.CometChatException(e))}}))},t.createGroup=function(e){return new Promise((function(t,n){try{var r=a.validateCreateGroup(e);if(r instanceof c.CometChatException)return void n(r);if(!(e instanceof T.Group)){var s=void 0;if(!e.hasOwnProperty(f.GroupConstants.KEYS.GUID))return void n(new c.CometChatException(y.ERRORS.PARAMETER_MISSING));if(!e.hasOwnProperty(f.GroupConstants.KEYS.NAME))return void n(new c.CometChatException(y.ERRORS.PARAMETER_MISSING));if(s=new T.Group(e[f.GroupConstants.KEYS.GUID],e[f.GroupConstants.KEYS.NAME],""),e.hasOwnProperty(f.GroupConstants.KEYS.TYPE))if(e[f.GroupConstants.KEYS.TYPE].toLocaleLowerCase()==f.GroupType.Password){if(!e.hasOwnProperty(f.GroupConstants.KEYS.PASSWORD))return void n(new c.CometChatException(y.GROUP_CREATION_ERRORS.EMPTY_PASSWORD));s.setType(f.GROUP_TYPE.PASSWORD),s.setPassword(e[f.GroupConstants.KEYS.PASSWORD])}else s.setType(e[f.GroupConstants.KEYS.TYPE]);else s.setType(f.GROUP_TYPE.PUBLIC);e.hasOwnProperty(f.GroupConstants.KEYS.ICON)&&s.setIcon(e[f.GroupConstants.KEYS.ICON]),e.hasOwnProperty(f.GroupConstants.KEYS.DESCRIPTION)&&s.setDescription(e[f.GroupConstants.KEYS.DESCRIPTION]),e.hasOwnProperty(f.GroupConstants.KEYS.TAGS)&&s.setTags(e[f.GroupConstants.KEYS.TAGS]),e=s}u.makeApiCall("createGroup",{},e).then((function(n){ee.joinMuc(e),m.GroupsController.trasformJSONGroup(n.data).setHasJoined(!0),t(m.GroupsController.trasformJSONGroup(n.data))}),(function(e){n(new c.CometChatException(e.error))}))}catch(e){n(new c.CometChatException(e))}}))},t.getGroup=function(e){return new Promise((function(t,n){try{"object"==typeof e&&e.hasOwnProperty("guid")&&(e=e.guid);var r=a.validateId(e,"group");if(r instanceof c.CometChatException)return void n(r);u.makeApiCall("getGroup",{guid:e}).then((function(e){t(m.GroupsController.trasformJSONGroup(e.data))}),(function(e){n(new c.CometChatException(e.error))}))}catch(e){n(new c.CometChatException(e))}}))},t.getJoinedGroups=function(){return new Promise((function(e,t){try{ee.getRooms().then((function(t){e(t)}),(function(e){t(e)}))}catch(e){t(new c.CometChatException(e))}}))},t.joinGroup=function(e,t,n){return void 0===t&&(t=f.GroupType.Public),void 0===n&&(n=""),new Promise((function(r,s){try{var o,i=a.validateJoinGroup(e,t,n);if(i instanceof c.CometChatException)return void s(i);"object"==typeof e&&(e.hasOwnProperty(f.GroupConstants.KEYS.GUID)?(e.hasOwnProperty(f.GroupConstants.KEYS.TYPE)&&(t=e[f.GroupConstants.KEYS.TYPE],e[f.GroupConstants.KEYS.TYPE].toLocaleLowerCase()===f.GroupType.Password&&e.hasOwnProperty(f.GroupConstants.KEYS.PASSWORD)&&(n=e[f.GroupConstants.KEYS.PASSWORD])),e=e[f.GroupConstants.KEYS.GUID]):s(new c.CometChatException(y.ERRORS.PARAMETER_MISSING))),o=a.isFalsy(n)?new T.Group(e,"name",t):new T.Group(e,"name",t,n),u.makeApiCall("joinGroup",o,o).then((function(e){ee.joinMuc(o);var t=m.GroupsController.trasformJSONGroup(e.data[f.ResponseConstants.RESPONSE_KEYS.KEY_DATA][f.ActionConstatnts.ACTION_KEYS.ENTITIES][f.ActionConstatnts.ACTION_SUBJECTS.ACTION_FOR][f.ActionConstatnts.ACTION_KEYS.ENTITY]);t.setHasJoined(!0),r(t)}),(function(e){"ERR_ALREADY_JOINED"===e.error.code&&ee.joinMuc(o),s(new c.CometChatException(e.error))}))}catch(e){s(new c.CometChatException(e))}}))},t.updateGroup=function(e){return new Promise((function(t,n){try{var r=a.validateUpdateGroup(e);if(r instanceof c.CometChatException)return void n(r);if(!(e instanceof T.Group)){var s=void 0;if(!e.hasOwnProperty(f.GroupConstants.KEYS.GUID))return void n(new c.CometChatException(y.ERRORS.PARAMETER_MISSING));s=new T.Group(f.GroupConstants.KEYS.GUID,"",""),e.hasOwnProperty(f.GroupConstants.KEYS.TYPE)?s.setType(e[f.GroupConstants.KEYS.TYPE]):(e[f.GroupConstants.KEYS.TYPE]=f.GROUP_TYPE.PUBLIC,s.setType[f.GROUP_TYPE.PUBLIC]),e.hasOwnProperty(f.GroupConstants.KEYS.NAME)&&s.setName(e[f.GroupConstants.KEYS.NAME]),e.hasOwnProperty(f.GroupConstants.KEYS.ICON)&&s.setIcon(e[f.GroupConstants.KEYS.ICON]),e.hasOwnProperty(f.GroupConstants.KEYS.DESCRIPTION)&&s.setDescription(e[f.GroupConstants.KEYS.DESCRIPTION]),e.hasOwnProperty(f.GroupConstants.KEYS.TAGS)&&s.setTags(e[f.GroupConstants.KEYS.TAGS]),e=s}u.makeApiCall("updateGroup",e,e).then((function(e){t(m.GroupsController.trasformJSONGroup(e.data))}),(function(e){n(new c.CometChatException(e.error))}))}catch(e){n(new c.CometChatException(e))}}))},t.deleteGroup=function(e){return new Promise((function(t,n){try{var r=a.validateId(e,"group");if(r instanceof c.CometChatException)return void n(r);u.makeApiCall("deleteGroup",{guid:e}).then((function(e){t(!0)}),(function(e){n(new c.CometChatException(e.error))}))}catch(e){n(new c.CometChatException(e))}}))},t.leaveGroup=function(e){return new Promise((function(t,n){try{var r=a.validateId(e,"group");if(r instanceof c.CometChatException)return void n(r);u.makeApiCall("leaveGroup",{guid:e}).then((function(n){ee.leaveMuc(e),t(!0)}),(function(e){n(new c.CometChatException(e.error))}))}catch(e){n(new c.CometChatException(e))}}))},t.kickGroupMember=function(e,t){return new Promise((function(n,r){try{var s=a.validateId(e,"group");if(s instanceof c.CometChatException)return void r(s);var o=a.validateId(t,"user");if(o instanceof c.CometChatException)return void r(o);u.makeApiCall("kickGroupMembers",{guid:e,uid:t}).then((function(e){n(!0)}),(function(e){r(new c.CometChatException(e.error))}))}catch(e){r(new c.CometChatException(e))}}))},t.updateGroupMemberScope=function(e,t,n){return new Promise((function(r,s){try{var o=a.validateId(e,"group");if(o instanceof c.CometChatException)return void s(o);var i=a.validateId(t,"user");if(i instanceof c.CometChatException)return void s(i);var l=a.validateScope(n);if(l instanceof c.CometChatException)return void s(l);u.makeApiCall("changeScopeOfMember",{guid:e,uid:t},{scope:n}).then((function(e){r(!0)}),(function(e){s(new c.CometChatException(e.error))}))}catch(e){s(new c.CometChatException(e))}}))},t.banGroupMember=function(e,t){return new Promise((function(n,r){try{var s=a.validateId(e,"group");if(s instanceof c.CometChatException)return void r(s);var o=a.validateId(t,"user");if(o instanceof c.CometChatException)return void r(o);u.makeApiCall("banGroupMember",{guid:e,uid:t}).then((function(e){n(!0)}),(function(e){r(new c.CometChatException(e.error))}))}catch(e){r(new c.CometChatException(e))}}))},t.unbanGroupMember=function(e,t){return new Promise((function(n,r){try{var s=a.validateId(e,"group");if(s instanceof c.CometChatException)return void r(s);var o=a.validateId(t,"user");if(o instanceof c.CometChatException)return void r(o);u.makeApiCall("unbanGroupMember",{guid:e,uid:t}).then((function(e){n(!0)}),(function(e){r(new c.CometChatException(e.error))}))}catch(e){r(new c.CometChatException(e))}}))},t.addMembersToGroup=function(e,t,n){var s=[],o=[],i=[],l=[];return new Promise((function(E,d){try{var h=a.validateId(e,"group");if(h instanceof c.CometChatException)return void d(h);var p=a.validateArray(t,"groupMembers");if(p instanceof c.CometChatException)return void d(p);if(n){var S=a.validateArray(n,"bannedMembers");if(S instanceof c.CometChatException)return void d(S)}a.isFalsy(t)&&a.isFalsy(n)?d(new c.CometChatException({})):a.isFalsy(t)||a.isFalsy(n)?a.isFalsy(t)?n.map((function(e){l.push(e)})):(t.filter((function(e){if(e.getScope()==f.GROUP_MEMBER_SCOPE.ADMIN)return!0})).map((function(e){s.push(e.getUid())})),t.filter((function(e){if(e.getScope()==f.GROUP_MEMBER_SCOPE.MODERATOR)return!0})).map((function(e){o.push(e.getUid())})),t.filter((function(e){if(e.getScope()==f.GROUP_MEMBER_SCOPE.PARTICIPANT)return!0})).map((function(e){i.push(e.getUid())}))):(t.filter((function(e){if(e.getScope()==f.GROUP_MEMBER_SCOPE.ADMIN)return!0})).map((function(e){s.push(e.getUid())})),t.filter((function(e){if(e.getScope()==f.GROUP_MEMBER_SCOPE.MODERATOR)return!0})).map((function(e){o.push(e.getUid())})),t.filter((function(e){if(e.getScope()==f.GROUP_MEMBER_SCOPE.PARTICIPANT)return!0})).map((function(e){i.push(e.getUid())})),n.map((function(e){l.push(e)})));var g={};a.isFalsy(s)||(g=r({},g,{admins:s})),a.isFalsy(i)||(g=r({},g,{participants:i})),a.isFalsy(o)||(g=r({},g,{moderators:o})),a.isFalsy(l)||(g=r({},g,{usersToBan:l})),u.makeApiCall("addMemebersToGroup",{guid:e},g).then((function(e){var t={};Object.keys(e.data.admins).map((function(n){e.data.admins[n][f.ResponseConstants.RESPONSE_KEYS.GROUP_MEMBERS_RESPONSE.SUCCESS]?t[n]=f.ResponseConstants.RESPONSE_KEYS.GROUP_MEMBERS_RESPONSE.SUCCESS:t[n]=e.data.admins[n][f.ResponseConstants.RESPONSE_KEYS.GROUP_MEMBERS_RESPONSE.ERROR][f.ResponseConstants.RESPONSE_KEYS.GROUP_MEMBERS_RESPONSE.MESSAGE]})),Object.keys(e.data.participants).map((function(n){e.data.participants[n][f.ResponseConstants.RESPONSE_KEYS.GROUP_MEMBERS_RESPONSE.SUCCESS]?t[n]=f.ResponseConstants.RESPONSE_KEYS.GROUP_MEMBERS_RESPONSE.SUCCESS:t[n]=e.data.participants[n][f.ResponseConstants.RESPONSE_KEYS.GROUP_MEMBERS_RESPONSE.ERROR][f.ResponseConstants.RESPONSE_KEYS.GROUP_MEMBERS_RESPONSE.MESSAGE]})),Object.keys(e.data.moderators).map((function(n){e.data.moderators[n][f.ResponseConstants.RESPONSE_KEYS.GROUP_MEMBERS_RESPONSE.SUCCESS]?t[n]=f.ResponseConstants.RESPONSE_KEYS.GROUP_MEMBERS_RESPONSE.SUCCESS:t[n]=e.data.moderators[n][f.ResponseConstants.RESPONSE_KEYS.GROUP_MEMBERS_RESPONSE.ERROR][f.ResponseConstants.RESPONSE_KEYS.GROUP_MEMBERS_RESPONSE.MESSAGE]})),Object.keys(e.data.usersToBan).map((function(n){e.data.usersToBan[n][f.ResponseConstants.RESPONSE_KEYS.GROUP_MEMBERS_RESPONSE.SUCCESS]?t[n]=f.ResponseConstants.RESPONSE_KEYS.GROUP_MEMBERS_RESPONSE.SUCCESS:t[n]=e.data.usersToBan[n][f.ResponseConstants.RESPONSE_KEYS.GROUP_MEMBERS_RESPONSE.ERROR][f.ResponseConstants.RESPONSE_KEYS.GROUP_MEMBERS_RESPONSE.MESSAGE]})),E(t)}),(function(e){d(new c.CometChatException(e.error))}))}catch(e){d(new c.CometChatException(e))}}))},t.transferGroupOwnership=function(e,t){return new Promise((function(n,r){try{var s=a.validateId(e,"group");if(s instanceof c.CometChatException)return void r(s);var o=a.validateId(t,"user");if(o instanceof c.CometChatException)return void r(o);u.makeApiCall("transferOwnership",{guid:e},{owner:t}).then((function(r){var s;s=r&&r.data&&r.data.message?r.data.message:"Ownership transferred to user "+t+" for the group with guid "+e+".",n(s)}),(function(e){r(new c.CometChatException(e.error))}))}catch(e){r(new c.CometChatException(e))}}))},t.initiateCall=function(e){var t=this;return new Promise((function(n,r){if(null===t.getActiveCall())try{a.isFalsy(JSON.parse(JSON.stringify(e)).sender)?a.isFalsy(t.getActiveCall())?(e.setStatus(f.CallConstants.CALL_STATUS.INITIATED),e.receiver=e.receiverId.toString(),delete e.receiverId,u.makeApiCall("createCallSession",{},e).then((function(e){var t=g.MessageController.trasformJSONMessge(e[f.ResponseConstants.RESPONSE_KEYS.KEY_DATA]);O.CallController.getInstance().initiateCall(t).then((function(e){n(t)})).catch((function(e){r(new c.CometChatException(e))}))}),(function(e){r(new c.CometChatException(e.error))}))):r(new c.CometChatException(f.CALL_ERROR.ERROR_IN_CALLING)):O.CallController.getInstance().initiateCall(e).then((function(t){n(Object.assign(e))})).catch((function(e){r(new c.CometChatException(e))}))}catch(e){r(new c.CometChatException(e))}else r(new c.CometChatException(f.CALL_ERROR.CALL_ALREADY_INITIATED))}))},t.acceptCall=function(e){var t=this;return new Promise((function(n,r){if(null===t.getActiveCall())try{var s={};s[f.CallConstants.CALL_KEYS.CALL_STATUS]=f.CallConstants.CALL_STATUS.ONGOING,u.makeApiCall("updateCallSession",{sessionid:e},s).then((function(e){var t=g.MessageController.trasformJSONMessge(e[f.ResponseConstants.RESPONSE_KEYS.KEY_DATA]);O.CallController.getInstance().onCallStarted(t),n(t)}),(function(e){r(new c.CometChatException(e.error))}))}catch(e){r(new c.CometChatException(e))}else r(new c.CometChatException(f.CALL_ERROR.CANNOT_ACCEPT_CALL))}))},t.rejectCall=function(e,t){try{switch(t){case f.CallConstants.CALL_STATUS.REJECTED:return this.rejectIncomingCall(e);case f.CallConstants.CALL_STATUS.CANCELLED:return this.cancelCall(e);case f.CallConstants.CALL_STATUS.BUSY:return this.sendBusyResponse(e);default:return this.endCall(e,!0)}}catch(e){a.Logger.error("CometChat: rejectCall",e)}},t.endCall=function(e,t){var n=this;return new Promise((function(r,s){a.isFalsy(t)&&(t=!1);var o=n.getActiveCall();if(null!==o){if(o.getSessionId()===e)try{var i={};i[f.CallConstants.CALL_KEYS.CALL_STATUS]=f.CallConstants.CALL_STATUS.ENDED,o.getJoinedAt()&&(i[f.CallConstants.CALL_KEYS.CALL_JOINED_AT]=o.getJoinedAt()),u.makeApiCall("updateCallSession",{sessionid:e},i).then((function(e){t||O.CallController.getInstance().endSession();var n=g.MessageController.trasformJSONMessge(e[f.ResponseConstants.RESPONSE_KEYS.KEY_DATA]);r(n),O.CallController.getInstance().getCallListner()&&O.CallController.getInstance().getCallListner()._eventListener.onCallEnded(n),O.CallController.getInstance().endCall()}),(function(e){a.Logger.log("calling Log",{error:e}),t||O.CallController.getInstance().endSession(),o.setStatus(f.CallConstants.CALL_STATUS.ENDED),r(o),O.CallController.getInstance().getCallListner()&&O.CallController.getInstance().getCallListner()._eventListener.onCallEnded(o),O.CallController.getInstance().endCall()}))}catch(e){s(new c.CometChatException(e))}}else t||O.CallController.getInstance().endSession(),r(null),O.CallController.getInstance().getCallListner()&&O.CallController.getInstance().getCallListner()._eventListener.onCallEnded(null),O.CallController.getInstance().endCall()}))},t.getActiveCall=function(){try{return O.CallController.getInstance().getActiveCall()}catch(e){a.Logger.error("CometChat: getActiveCall",e)}},t.startCall=function(e,n,r,s){var o=this;try{var i,u,l,E,d,h,p,S,g=this.getActiveCall(),C=!1,_=!0,T=!0,m=!0,A=!0,I=!0,R=!0,N=!1,y=!1,P=f.CallConstants.CALL_MODE.DEFAULT,M=!1,v=!1,L=!0,D={},U=this.user;a.getAppSettings().then((function(s){if(h=s[f.APP_SETTINGS.KEYS.WEBRTC_HOST],s.hasOwnProperty(f.APP_SETTINGS.KEYS.ANALYTICS_HOST)?D[f.APP_SETTINGS.KEYS.ANALYTICS_HOST]=s[f.APP_SETTINGS.KEYS.ANALYTICS_HOST]:D[f.APP_SETTINGS.KEYS.ANALYTICS_HOST]=a.format(f.ANALYTICS.analyticsHost,t.appSettings.getRegion()),s.hasOwnProperty(f.APP_SETTINGS.KEYS.ANALYTICS_VERSION)?D[f.APP_SETTINGS.KEYS.ANALYTICS_VERSION]=s[f.APP_SETTINGS.KEYS.ANALYTICS_VERSION]:D[f.APP_SETTINGS.KEYS.ANALYTICS_VERSION]=f.ANALYTICS.analyticsVersion,s.hasOwnProperty(f.APP_SETTINGS.KEYS.ANALYTICS_PING_DISABLED)?D[f.APP_SETTINGS.KEYS.ANALYTICS_PING_DISABLED]=s[f.APP_SETTINGS.KEYS.ANALYTICS_PING_DISABLED]:D[f.APP_SETTINGS.KEYS.ANALYTICS_PING_DISABLED]=!1,s.hasOwnProperty(f.APP_SETTINGS.KEYS.ANALYTICS_USE_SSL)?D[f.APP_SETTINGS.KEYS.ANALYTICS_USE_SSL]=s[f.APP_SETTINGS.KEYS.ANALYTICS_USE_SSL]:D[f.APP_SETTINGS.KEYS.ANALYTICS_USE_SSL]=!0,a.isFalsy(r)||O.CallController.getInstance().setCallListner(r),a.isFalsy(o.appSettings))O.CallController.getInstance().getCallListner()&&O.CallController.getInstance().getCallListner()._eventListener.onError(new c.CometChatException(f.CALL_ERROR.NOT_INITIALIZED));else if(E=o.appSettings.getRegion())if(U)if((S=new W.RTCUser(U.getUid())).setName(U.getName()),S.setAvatar(U.getAvatar()),S.setResource(t.getSessionId()),t.appId)if(d=t.appId,"string"==typeof e){if(g){var w=g.getType();C=w===f.CallConstants.CALL_TYPE.AUDIO,u=g.getSessionId()}else{if(a.isFalsy(e))return void(O.CallController.getInstance().getCallListner()&&O.CallController.getInstance().getCallListner()._eventListener.onError(new c.CometChatException(f.CALL_ERROR.SESSION_ID_REQUIRED)));u=("v1."+E+"."+t.getAppId()+"."+e).toLowerCase()}if(!u)return void(O.CallController.getInstance().getCallListner()&&O.CallController.getInstance().getCallListner()._eventListener.onError(new c.CometChatException(f.CALL_ERROR.SESSION_ID_REQUIRED)));var b={uid:U.getUid(),sessionId:u};t.getJWT(b).then((function(e){e.hasOwnProperty("token")?(S.setJWT(e.token),i=(new q.CallSettingsBuilder).setSessionID(u).enableDefaultLayout(_).setIsAudioOnlyCall(C).setUser(S).setRegion(E).setAppId(d).setDomain(h).showEndCallButton(A).showMuteAudioButton(m).showPauseVideoButton(T).showScreenShareButton(I).showModeButton(R).setMode(P).setAnalyticsSettings(D).startWithAudioMuted(N).startWithVideoMuted(y).showRecordingButton(M).startRecordingOnCallStart(v).forceLegacyUI(L).build(),O.CallController.getInstance().startCall(i,n)):O.CallController.getInstance().getCallListner()&&O.CallController.getInstance().getCallListner()._eventListener.onError(new c.CometChatException(f.CALL_ERROR.JWT_NOT_FOUND))}),(function(e){O.CallController.getInstance().getCallListner()&&O.CallController.getInstance().getCallListner()._eventListener.onError(new c.CometChatException(e))}))}else{if(a.isFalsy(e))return void(O.CallController.getInstance().getCallListner()&&O.CallController.getInstance().getCallListner()._eventListener.onError(new c.CometChatException(f.CALL_ERROR.CALL_SETTINGS_REQUIRED)));if(g){w=g.getType();C=w===f.CallConstants.CALL_TYPE.AUDIO,u=g.getSessionId()}else{if(C=e.isAudioOnlyCall(),a.isFalsy(e.getSessionId()))return void(O.CallController.getInstance().getCallListner()&&O.CallController.getInstance().getCallListner()._eventListener.onError(new c.CometChatException(f.CALL_ERROR.SESSION_ID_REQUIRED)));u=("v1."+E+"."+t.getAppId()+"."+e.getSessionId()).toLowerCase()}if(!u)return void(O.CallController.getInstance().getCallListner()&&O.CallController.getInstance().getCallListner()._eventListener.onError(new c.CometChatException(f.CALL_ERROR.SESSION_ID_REQUIRED)));_=e.isDefaultLayoutEnabled(),T=e.isPauseVideoButtonEnabled(),m=e.isMuteAudioButtonEnabled(),A=e.isEndCallButtonEnabled(),I=e.isScreenShareButtonEnabled(),P=e.getMode(),p=e.getLocalizedStringObject(),l=e.getCustomCSS(),R=e.isModeButtonEnabled(),N=e.getStartWithAudioMuted(),y=e.getStartWithVideoMuted(),M=e.isRecordingButtonEnabled(),v=e.shouldStartRecordingOnCallStart(),L=e.shouldUseLegacyUI();b={uid:U.getUid(),sessionId:u};t.getJWT(b).then((function(e){e.hasOwnProperty("token")?(S.setJWT(e.token),i=(new q.CallSettingsBuilder).setSessionID(u).enableDefaultLayout(_).setIsAudioOnlyCall(C).setUser(S).setRegion(E).setAppId(d).setDomain(h).showEndCallButton(A).showMuteAudioButton(m).showPauseVideoButton(T).showScreenShareButton(I).showModeButton(R).setMode(P).setLocalizedStringObject(p).setCustomCSS(l).setAnalyticsSettings(D).startWithAudioMuted(N).startWithVideoMuted(y).showRecordingButton(M).startRecordingOnCallStart(v).forceLegacyUI(L).build(),O.CallController.getInstance().startCall(i,n)):O.CallController.getInstance().getCallListner()&&O.CallController.getInstance().getCallListner()._eventListener.onError(new c.CometChatException(f.CALL_ERROR.JWT_NOT_FOUND))}),(function(e){O.CallController.getInstance().getCallListner()&&O.CallController.getInstance().getCallListner()._eventListener.onError(new c.CometChatException(e))}))}else O.CallController.getInstance().getCallListner()&&O.CallController.getInstance().getCallListner()._eventListener.onError(new c.CometChatException(f.CALL_ERROR.NOT_INITIALIZED));else O.CallController.getInstance().getCallListner()&&O.CallController.getInstance().getCallListner()._eventListener.onError(new c.CometChatException(f.CALL_ERROR.NOT_LOGGED_IN));else O.CallController.getInstance().getCallListner()&&O.CallController.getInstance().getCallListner()._eventListener.onError(new c.CometChatException(f.CALL_ERROR.NOT_INITIALIZED))}),(function(e){a.Logger.error("CometChat: startCall",e)}))}catch(e){a.Logger.error("CometChat: startCall",e)}},t.getCallParticipantCount=function(e,n){var r=this;return new Promise((function(s,o){try{a.getAppSettings().then((function(l){if(a.isFalsy(e))return o(new c.CometChatException(f.ProsodyApiErrors.INVALID_SESSIONID));if(a.isFalsy(n))return o(new c.CometChatException(f.ProsodyApiErrors.INVALID_TYPE));var E=r.appSettings.getRegion(),d={},h=l[f.APP_SETTINGS.KEYS.WEBRTC_HOST],p=a.format((new i.EndpointFactory).prosodyApi,f.PROSODY_API.DOMAIN_PREFIX,h,f.PROSODY_API.PATH.ROOM_SIZE);"direct"===n.toLowerCase()&&(e=("v1."+E+"."+t.getAppId()+"."+e).toLowerCase()),d[f.PROSODY_API.QUERY_PARAMETERS.DOMAIN]=h,d[f.PROSODY_API.QUERY_PARAMETERS.ROOM]=e,u.postData(p,"GET",d,{},!1).then((function(e){return e.text()})).then((function(e){var t=e?JSON.parse(e):{};return t.hasOwnProperty(f.PROSODY_API.RESPONSE.PARTICIPANTS)?s(t[f.PROSODY_API.RESPONSE.PARTICIPANTS]):s(0)})).catch((function(){var e={error:y.FETCH_ERROR.ERROR_IN_API_CALL};return o(e)}))}),(function(e){return o(new c.CometChatException(e))}))}catch(e){return o(new c.CometChatException(e))}}))},t.createCallView=function(e){var n=this;try{return{prop1:this.makeCall,onMessage:function(e){O.CallController.getInstance().getCallListner()._eventListener.onCallEnded(n.getActiveCall()),t.endCall(n.getActiveCall().getSessionId(),!0).then((function(e){a.Logger.info("CometChat: createCallView",e)})).catch((function(e){a.Logger.error("CometChat: createCallView",e)}))}}}catch(e){a.Logger.error("CometChat: createCallView",e)}},t.makeCall=function(e,t){try{e.setState((function(e){return r({},e,{uri:t})}))}catch(e){a.Logger.error("CometChat: makeCall",e)}},t.rejectIncomingCall=function(e){return new Promise((function(t,n){try{var r={};r[f.CallConstants.CALL_KEYS.CALL_STATUS]=f.CallConstants.CALL_STATUS.REJECTED,u.makeApiCall("updateCallSession",{sessionid:e},r).then((function(e){var n=g.MessageController.trasformJSONMessge(e[f.ResponseConstants.RESPONSE_KEYS.KEY_DATA]);t(n)}),(function(e){n(new c.CometChatException(e.error))}))}catch(e){n(new c.CometChatException(e))}}))},t.cancelCall=function(e){var t=this;return new Promise((function(n,r){try{var s={};s[f.CallConstants.CALL_KEYS.CALL_STATUS]=f.CallConstants.CALL_STATUS.CANCELLED,u.makeApiCall("updateCallSession",{sessionid:e},s).then((function(r){var s=g.MessageController.trasformJSONMessge(r[f.ResponseConstants.RESPONSE_KEYS.KEY_DATA]);t.getActiveCall().getSessionId()===e&&O.CallController.getInstance().endCallSession(),n(s)}),(function(e){r(new c.CometChatException(e.error))}))}catch(e){r(new c.CometChatException(e))}}))},t.sendBusyResponse=function(e){return new Promise((function(t,n){try{var r={};r[f.CallConstants.CALL_KEYS.CALL_STATUS]=f.CallConstants.CALL_STATUS.BUSY,u.makeApiCall("updateCallSession",{sessionid:e},r).then((function(e){var n=g.MessageController.trasformJSONMessge(e[f.ResponseConstants.RESPONSE_KEYS.KEY_DATA]);t(n)}),(function(e){n(new c.CometChatException(e.error))}))}catch(e){n(new c.CometChatException(e))}}))},t.sendUnansweredResponse=function(e){return new Promise((function(t,n){try{var r={};r[f.CallConstants.CALL_KEYS.CALL_STATUS]=f.CallConstants.CALL_STATUS.UNANSWERED,u.makeApiCall("updateCallSession",{sessionid:e},r).then((function(e){var n=g.MessageController.trasformJSONMessge(e[f.ResponseConstants.RESPONSE_KEYS.KEY_DATA]);E.XMPPConnectionHelper.getInstance().trigerMessageHandler(Object.assign(n,e[f.ResponseConstants.RESPONSE_KEYS.KEY_DATA])),t(n)}),(function(e){n(new c.CometChatException(e.error))}))}catch(e){n(new c.CometChatException(e))}}))},t.addConnectionListener=function(e,t){try{ee.addXMPPConnectionEventListener(e,t)}catch(e){a.Logger.error("CometChat: addConnectionListener",e)}},t.removeConnectionListener=function(e){try{ee.removeXMPPConnectionEventListener(e)}catch(e){a.Logger.error("CometChat: removeConnectionListener",e)}},t.addMessageListener=function(e,t){try{ee.addMessageEventListener(e,t)}catch(e){a.Logger.error("CometChat: addMessageListener",e)}},t.removeMessageListener=function(e){try{ee.removeMessageEventListener(e)}catch(e){a.Logger.error("CometChat: removeMessageListener",e)}},t.addCallListener=function(e,t){try{ee.addCallEventListener(e,t)}catch(e){a.Logger.error("CometChat: addCallListener",e)}},t.removeCallListener=function(e){try{ee.removeCallEventListener(e)}catch(e){a.Logger.error("CometChat: removeCallListener",e)}},t.addUserListener=function(e,t){try{ee.addUserEventListener(e,t)}catch(e){a.Logger.error("CometChat: addUserListener",e)}},t.removeUserListener=function(e){try{ee.removeUserEventListener(e)}catch(e){a.Logger.error("CometChat: removeUserListener",e)}},t.addGroupListener=function(e,t){try{ee.addGroupEventListener(e,t)}catch(e){a.Logger.error("CometChat: addGroupListener",e)}},t.removeGroupListener=function(e){try{ee.removeGroupEventListener(e)}catch(e){a.Logger.error("CometChat: removeGroupListener",e)}},t.addLoginListener=function(e,t){try{ee.addLoginEventListener(e,t)}catch(e){a.Logger.error("CometChat: addLoginListener",e)}},t.removeLoginListener=function(e){try{ee.removeLoginEventListener(e)}catch(e){a.Logger.error("CometChat: removeLoginListener",e)}},t.generateAuthToken=function(e){var n=this;return new Promise((function(r,s){try{var o={},i="",l="",E=f.APPINFO.platform,d=f.APPINFO.sdkVersion,h=f.APPINFO.apiVersion;navigator&&(l=navigator.userAgent),t.keyStore.get("deviceId").then((function(a){if(null==(i=a)){var p=Z(),S=(new Date).getTime();i=n.appId+"_"+p+"_"+S,t.keyStore.set("deviceId",i)}o={platform:E,deviceId:i,appInfo:{version:d,apiVersion:h,userAgent:l}},u.makeApiCall("authToken",{uid:e},o).then((function(e){r(e.data)})).catch((function(e){s(new c.CometChatException(e.error))}))}),(function(e){a.Logger.error("Got error while fetching data from key store",e)}))}catch(e){s(new c.CometChatException(e))}}))},t.setAccidentalDisconnect=function(e){t.accidentalDisconnect=e},t.generateNewSessionId=function(){t.sessionId=f.APPINFO.platform+"-"+f.APPINFO.sdkVersionWithUnderScore+"-"+Z()+"-"+(new Date).getTime(),t.addDataToSessionStorage(f.SESSION_STORE.SESSION_ID,t.getSessionId())},t.tryReconnectingToWSOrStartPolling=function(){0===this.WSReconnectionStartTime&&(this.WSReconnectionStartTime=(new Date).getTime()),(new Date).getTime()-t.WSReconnectionStartTime<t.WSReconnectionPeriod&&t.WSCurrentReconnectionCount<t.WSMaxReconnectionLimit&&!t.pollingEnabledInternally&&!t.isPollingEnabled()?(t.WSCurrentReconnectionCount+=1,this.XMPPLogin(t.user,(function(){a.Logger.info("XMPPLogin","successful")}),(function(){a.Logger.info("XMPPLogin","unsuccessful")}))):(t.shouldFallBackToPolling&&(t.accidentalDisconnect?t.startPolling(!0):t.startPolling(!1)),t.WSReconnectionInProgress||t.startWSReconnectionTimer())},t.startPolling=function(e){if(t.currentConnectionStatus=f.CONNECTION_STATUS.FEATURE_THROTTLED,!t.didMessagesPollingStart()){ee.XMPPConnectionHandlers.map((function(e){try{e._XMPPeventListener&&(a.isFalsy(e._XMPPeventListener.onFeatureThrottled)||e._XMPPeventListener.onFeatureThrottled())}catch(e){a.Logger.error("XMPPConnectionHandlers: Feature Throttled Status",e)}}));var n=void 0;if(e){var r=t.getLastMessageId();t.pollingMessagesId=r||0,0===t.pollingMessagesId&&(n=t.getSuccessfultTimeStamp())}else n=t.WSReconnectionStartTime>0?t.WSReconnectionStartTime:(new Date).getTime();t.pollingEnabledInternally=!0,t.pollingEnabled=!0,t.pollingMessagesTimestamp=Math.floor(n/1e3),t.fetchMessages(),t.startMessagesTimer()}},t.prototype.makeXMPPConnection=function(){t.setAccidentalDisconnect(!1),t.XMPPLogin(t.user,(function(){a.Logger.info("XMPPLogin","successful")}),(function(){a.Logger.info("XMPPLogin","unsuccessful")}))},t.prototype.accidentallyDisconnected=function(){t.currentConnectionStatus=f.CONNECTION_STATUS.CONNECTING,ee.XMPPConnectionHandlers.map((function(e){try{e._XMPPeventListener&&(a.isFalsy(e._XMPPeventListener.inConnecting)||e._XMPPeventListener.inConnecting())}catch(e){a.Logger.error("XMPPConnectionHandlers: inConnecting Status",e)}})),t.setAccidentalDisconnect(!0),t.tryReconnectingToWSOrStartPolling()},t.XMPPLogin=function(e,n,r){var s=this;try{ee.XMMPLogin(e.getUid(),e.getWsChannel().secret,!1,(function(e,n){switch(n===f.Errors.ERR_XMPP_CONFLICT&&(ee.XMPPDisconnect(),t.generateNewSessionId()),e){case d.Strophe.Status.CONNFAIL:t.isLoggedOut||s.tryReconnectingToWSOrStartPolling();break;case d.Strophe.Status.CONNECTING:var r=t.getConnectionStatus();t.WSReconnectionInProgress||t.accidentalDisconnect||t.didMessagesPollingStart()||(s.currentConnectionStatus=f.CONNECTION_STATUS.CONNECTING,r==f.CONNECTION_STATUS.DISCONNECTED&&ee.XMPPConnectionHandlers.map((function(e){try{e._XMPPeventListener&&(a.isFalsy(e._XMPPeventListener.inConnecting)||e._XMPPeventListener.inConnecting())}catch(e){a.Logger.error("XMPPConnectionHandlers: inConnecting Status",e)}})));break;case d.Strophe.Status.CONNECTED:r=t.getConnectionStatus();s.currentConnectionStatus=f.CONNECTION_STATUS.CONNECTED,r!==f.CONNECTION_STATUS.FEATURE_THROTTLED&&t.didMessagesPollingStart(),r!=f.CONNECTION_STATUS.CONNECTING&&r!=f.CONNECTION_STATUS.FEATURE_THROTTLED||ee.XMPPConnectionHandlers.map((function(e){try{e._XMPPeventListener&&(a.isFalsy(e._XMPPeventListener.onConnected)||e._XMPPeventListener.onConnected())}catch(e){a.Logger.error("XMPPConnectionHandlers: onConnected Status",e)}})),t.WSReconnectionStartTime=0,t.pollingMessagesId=0,t.pollingEnabled=!1,t.pollingEnabledInternally=!1,t.WSCurrentReconnectionCount=0,t.setAccidentalDisconnect(!1),t.didMessagesPollingStart()&&t.clearMessagesTimer(),t.WSReconnectionInProgress&&t.clearWSReconnectionTimer();break;case d.Strophe.Status.DISCONNECTED:r=t.getConnectionStatus();t.WSReconnectionInProgress||t.accidentalDisconnect||t.didMessagesPollingStart()||(s.currentConnectionStatus=f.CONNECTION_STATUS.DISCONNECTED,r!==f.CONNECTION_STATUS.DISCONNECTED&&(ee.XMPPConnectionHandlers.map((function(e){try{e._XMPPeventListener&&(a.isFalsy(e._XMPPeventListener.onDisconnected)||e._XMPPeventListener.onDisconnected())}catch(e){a.Logger.error("XMPPConnectionHandlers: Disconnected Status",e)}})),t.isLoggedOut||s.tryReconnectingToWSOrStartPolling()));break;case d.Strophe.Status.DISCONNECTING:break;case d.Strophe.Status.AUTHFAIL:s.tryReconnectingToWSOrStartPolling()}}))}catch(e){return void(t.isLoggedOut||this.tryReconnectingToWSOrStartPolling())}},t.fetchMessages=function(){var e=this;try{var n={per_page:t.pollingLimit,affix:t.pollingAffix,polling:1};t.pollingMessagesId?n.id=t.pollingMessagesId:n.sentAt=t.pollingMessagesTimestamp,u.makeApiCall("getMessages",{},n).then((function(n){return s(e,void 0,void 0,(function(){var e,r,s,i;return o(this,(function(o){switch(o.label){case 0:if(e=n.data,!((r=n.data.length)>0))return[3,4];t.pollingMessagesId=e[r-1].id,s=Math.floor(t.pollingInterval/r),i=0,o.label=1;case 1:return i<r?t.isLoggedOut?[3,3]:(e[i]&&e[i][f.MessageConstatnts.KEYS.DATA]&&e[i][f.MessageConstatnts.KEYS.DATA][f.MessageConstatnts.KEYS.RESOURCE]&&e[i][f.MessageConstatnts.KEYS.DATA][f.MessageConstatnts.KEYS.RESOURCE]!==t.getSessionId()&&t.getConnectionStatus()!==f.CONNECTION_STATUS.CONNECTED&&(t.getLastMessageId()<=e[i].id&&t.setLastMessageId(e[i].id),w.MessageListnerMaping.getInstance().set("all",parseInt(e[i].id)),E.XMPPConnectionHelper.getInstance().trigerMessageHandler(e[i])),i<r-1?[4,t.timer(s)]:[3,3]):[3,4];case 2:o.sent(),o.label=3;case 3:return i++,[3,1];case 4:return[2]}}))}))}),(function(e){a.Logger.error("CometChat: fetchMessages: API Error",e)})).catch((function(e){a.Logger.error("CometChat: fetchMessages: API Error",e)}))}catch(e){a.Logger.error("CometChat: fetchMessages",e)}},t.fetchMissedMessages=function(){var e=this;try{var n={per_page:1e3,affix:f.MessageConstatnts.PAGINATION.AFFIX.APPEND,missedMessages:1};t.getLastMessageId()>0?n.id=t.getLastMessageId():t.getSuccessfultTimeStamp()>0?n.sentAt=Math.floor(t.getSuccessfultTimeStamp()/1e3):n.sentAt=Math.floor((new Date).getTime()/1e3),u.makeApiCall("getMessages",{},n).then((function(n){return s(e,void 0,void 0,(function(){var e,r,s;return o(this,(function(o){if(e=n.data,(r=n.data.length)>0)for(t.pollingMessagesId=e[r-1].id,s=0;s<r;s++)t.isLoggedOut||e[s]&&e[s][f.MessageConstatnts.KEYS.DATA]&&e[s][f.MessageConstatnts.KEYS.DATA][f.MessageConstatnts.KEYS.RESOURCE]&&e[s][f.MessageConstatnts.KEYS.DATA][f.MessageConstatnts.KEYS.RESOURCE]!==t.getSessionId()&&(t.getLastMessageId()<=e[s].id&&t.setLastMessageId(e[s].id),w.MessageListnerMaping.getInstance().set("all",parseInt(e[s].id)),e[s][f.MessageConstatnts.KEYS.CATEGORY]!==f.MessageConstatnts.CATEGORY.CALL||e[s][f.MessageConstatnts.KEYS.DATA][f.MessageConstatnts.KEYS.ACTION]!==f.CallConstants.CALL_STATUS.INITIATED?E.XMPPConnectionHelper.getInstance().trigerMessageHandler(e[s]):a.Logger.info("CometChat: fetchMissedMessages","Call Initiated Message"));return[2]}))}))}),(function(e){a.Logger.error("CometChat: fetchMissedMessages: API Error",e)})).catch((function(e){a.Logger.error("CometChat: fetchMissedMessages: API Error",e)}))}catch(e){a.Logger.error("CometChat: fetchMissedMessages",e)}},t.pingAnalytics=function(){var e=this;try{t.keyStore.get("deviceId").then((function(n){var r=null;window&&window.location&&window.location.origin&&(r=window.location.origin);var s="",o=n,i={version:f.SDKHeader.sdkVersion,apiVersion:f.APPINFO.apiVersion,origin:r,uts:(new Date).getTime()};a.isFalsy(e.resource)||(i.resource=e.resource),a.isFalsy(e.platform)||(i.platform=e.platform),a.isFalsy(e.language)||(i.language=e.language),navigator&&(s=navigator.userAgent);var l={appInfo:i,uid:t.user.getUid(),userAgent:s,deviceId:o,platform:f.SDKHeader.platform};a.isFalsy(t.getSessionId())||(l.wsId=t.getSessionId()),t.analyticsHost||(t.analyticsHost=a.format(f.ANALYTICS.analyticsHost,t.appSettings.getRegion())),t.analyticsVersion||(t.analyticsVersion=f.ANALYTICS.analyticsVersion);var E="https://"+t.analyticsHost+"/"+t.analyticsVersion+"/ping",d={appId:t.appId,sdk:a.format(f.SDKHeader.sdk,f.SDKHeader.platform,f.SDKHeader.sdkVersion),"Content-Type":"application/json"};t.settingsHash&&(d.settingsHash=t.settingsHash),t.settingsHashReceivedAt&&(d.settingsHashReceivedAt=t.settingsHashReceivedAt),t.jwt&&(d.Authorization="Bearer "+t.jwt),t.authToken&&(d.authToken=t.authToken),u.postData(E,"POST",l,d,!1).then((function(e){return e.json()})).then((function(n){if(n.hasOwnProperty(f.ResponseConstants.RESPONSE_KEYS.KEY_DATA))a.Logger.log("Analytics Ping Request Data",n[f.ResponseConstants.RESPONSE_KEYS.KEY_DATA]);else if(n.hasOwnProperty(f.ResponseConstants.RESPONSE_KEYS.KEY_ERROR)){var r=n[f.ResponseConstants.RESPONSE_KEYS.KEY_ERROR];a.Logger.log("Analytics Ping Request Error",new c.CometChatException(r));var s=r.code;if(s===f.Errors.ERR_SETTINGS_HASH_OUTDATED){var o=t.authToken;t.getInstance().internalLogout(!1).then((function(){t.internalRestart=!0,t.login(o).then((function(e){t.internalRestart=!1}))}))}s===f.Errors.ERR_NO_AUTH&&e.updateJWT()}})).catch((function(e){a.Logger.error("CometChat: pingAnalytics Fetch Error",e)}))}))}catch(e){a.Logger.error("CometChat: pingAnalytics",e)}},t.updateJWT=function(){u.makeApiCall("getMyDetails",{},{},!1).then((function(e){var n=e.data,r=n.settings,s=new l.Me(n);if(n.hasOwnProperty("jwt")&&n.jwt&&(t.jwt=n.jwt),h.LocalStorage.getInstance().set("user",s),r&&r[f.APP_SETTINGS.KEYS.SETTINGS_HASH]&&t.settingsHash!==r[f.APP_SETTINGS.KEYS.SETTINGS_HASH]){var o=t.getInstance().getAuthToken();t.getInstance().internalLogout(!1).then((function(){t.internalRestart=!0,t.login(o).then((function(e){t.internalRestart=!1}))}))}a.Logger.log("CometChat: updateJWT response",e)}),(function(e){a.Logger.error("CometChat: updateJWT Fetch Error",e)})).catch((function(e){a.Logger.error("CometChat: updateJWT",e)}))},t.startMessagesTimer=function(){var e=this;t.isMessagesPollingStarted=!0,t.messagesTimer=setInterval((function(){try{e.fetchMessages()}catch(e){a.Logger.error("CometChat: startMessagesTimer",e)}}),t.pollingInterval)},t.timer=function(e){return new Promise((function(t){return setTimeout(t,e)}))},t.startAnalyticsPingTimer=function(){var e=this;t.isAnalyticsPingStarted=!0,t.analyticsPingTimer=setInterval((function(){try{e.pingAnalytics()}catch(e){a.Logger.error("CometChat: startAnalyticsPingTimer",e)}}),t.settingsInterval)},t.clearMessagesTimer=function(){try{t.isMessagesPollingStarted=!1,clearInterval(t.messagesTimer)}catch(e){a.Logger.error("CometChat: clearMessagesTimer",e)}},t.clearAnalyticsPingTimer=function(){try{t.isAnalyticsPingStarted=!1,clearInterval(t.analyticsPingTimer)}catch(e){a.Logger.error("CometChat: clearAnalyticsPingTimer",e)}},t.startWSReconnectionTimer=function(){t.WSReconnectionInProgress=!0,t.WSReconnectionTimer=setInterval((function(){try{t.XMPPLogin(t.user,(function(){a.Logger.info("XMPPLogin","successful")}),(function(){a.Logger.info("XMPPLogin","unsuccessful")}))}catch(e){a.Logger.error("CometChat: startWSReconnectionTimer",e)}}),t.WSReconnectionTimerInterval)},t.clearWSReconnectionTimer=function(){t.WSReconnectionInProgress=!1,clearInterval(t.WSReconnectionTimer)},t.getJWT=function(e){return new Promise((function(n,r){try{z.getEndPoint("getJWT").then((function(s){var o={appId:t.appId,Accept:"application/json",authToken:t.authToken,resource:t.getSessionId(),sdk:a.format(f.SDKHeader.sdk,f.SDKHeader.platform,f.SDKHeader.sdkVersion),"Content-Type":"application/json"},i={};i[f.JWT_API.KEYS.PASSTHROUGH]=e,u.postData(s.endpoint,s.method,i,o,!1).then((function(e){return e.json()})).then((function(e){e.hasOwnProperty(f.ResponseConstants.RESPONSE_KEYS.KEY_DATA)?n(e[f.ResponseConstants.RESPONSE_KEYS.KEY_DATA]):r(new c.CometChatException(e.error))})).catch((function(e){var t={error:y.FETCH_ERROR.ERROR_IN_API_CALL};r(new c.CometChatException(t))}))}),(function(e){r(new c.CometChatException(e))}))}catch(e){r(new c.CometChatException(e))}}))},t.getConnectionStatus=function(){return this.currentConnectionStatus},t.prototype.setConnectionStatus=function(e){t.currentConnectionStatus=e},t.isExtensionEnabled=function(e){return new Promise((function(t,n){try{if(a.isFalsy(e))return n(new c.CometChatException(f.ExtensionErrors.INVALID_EXTENSION));a.getAppSettings().then((function(r){if(r.extensions){var s=r.extensions;if(s.length>0){var o=s.some((function(t){return t.id===e}));return t(o)}return t(!1)}return n(new c.CometChatException(f.ExtensionErrors.EXTENSION_NOT_FOUND))}),(function(e){return n(new c.CometChatException(e))}))}catch(e){return n(new c.CometChatException(e))}}))},t.getExtensionDetails=function(e){return new Promise((function(t,n){try{if(a.isFalsy(e))return n(new c.CometChatException(f.ExtensionErrors.INVALID_EXTENSION));a.getAppSettings().then((function(r){if(r.extensions){var s=r.extensions;if(s.length>0){var o=s.filter((function(t){return t.id===e}));if(o.length>0){var i=new Q.CCExtension(o[0]);return t(i)}return n(new c.CometChatException(f.ExtensionErrors.EXTENSION_NOT_FOUND))}return n(new c.CometChatException(f.ExtensionErrors.EXTENSION_NOT_FOUND))}return n(new c.CometChatException(f.ExtensionErrors.EXTENSION_NOT_FOUND))}),(function(e){return n(new c.CometChatException(e))}))}catch(e){return n(new c.CometChatException(e))}}))},t.getAppSettings=function(){return new Promise((function(e,t){try{u.makeApiCall("appSettings").then((function(t){h.LocalStorage.getInstance().set("app_settings",t.data),e(t.data)}),(function(e){t(new c.CometChatException(e.error))}))}catch(e){t(new c.CometChatException(e))}}))},t.isFeatureEnabled=function(e){return new Promise((function(t,n){try{if(a.isFalsy(e))return n(new c.CometChatException(f.FeatureRestrictionErrors.INVALID_FEATURE));a.getAppSettings().then((function(r){if(r.parameters){var s=r.parameters;return s.hasOwnProperty(e)?t(s[e]):t(!1)}return n(new c.CometChatException(f.FeatureRestrictionErrors.FEATURE_NOT_FOUND))}),(function(e){return n(new c.CometChatException(e))}))}catch(e){return n(new c.CometChatException(e))}}))},t.logout=function(){var e=this;return new Promise((function(n,r){try{t.didAnalyticsPingStart()&&t.clearAnalyticsPingTimer(),t.didMessagesPollingStart()&&t.clearMessagesTimer(),t.WSReconnectionInProgress&&t.clearWSReconnectionTimer(),t.isLoggedOut=!0,t.pollingMessagesId=0,t.pollingEnabled=!1,t.pollingInterval=5e3,t.pollingEnabledInternally=!1,t.WSReconnectionStartTime=0,t.WSReconnectionInProgress=!1,t.setLastMessageId(0),t.setAccidentalDisconnect(!1),t.isAnalyticsDisabled=!1,t.shouldFallBackToPolling=!0,u.makeApiCall("userLogout").then((function(r){e.clearCache().then((function(){t.apiKey=void 0,t.user=void 0,t.authToken=void 0,t.cometChat=void 0,t.mode=void 0,E.XMPPConnectionHelper.getInstance().XMPPDisconnect(),t.pushToLoginListener("","Logout_Success"),n(r.data)}))}),(function(s){e.clearCache().then((function(){t.apiKey=void 0,t.user=void 0,t.authToken=void 0,t.cometChat=void 0,t.mode=void 0,E.XMPPConnectionHelper.getInstance().XMPPDisconnect(),t.pushToLoginListener("","Logout_Success"),new c.CometChatException(s.error).code==y.SERVER_ERRORS.AUTH_ERR.code?n({}):r(new c.CometChatException(s.error))}))}))}catch(e){r(new c.CometChatException(e))}}))},t.callExtension=function(e,n,r,s){return void 0===s&&(s={}),new Promise((function(o,l){var E=a.format((new i.EndpointFactory).extensionApi,e,t.appSettings.getRegion(),r),d={appId:t.appId,Accept:"application/json",authToken:t.authToken,resource:t.getSessionId(),sdk:a.format(f.SDKHeader.sdk,f.SDKHeader.platform,f.SDKHeader.sdkVersion),"Content-Type":"application/json"};u.postData(E,n,s,d,!1).then((function(e){return e.json()})).then((function(e){e.hasOwnProperty(f.ResponseConstants.RESPONSE_KEYS.KEY_DATA)?o(e[f.ResponseConstants.RESPONSE_KEYS.KEY_DATA]):l(new c.CometChatException(e.error))})).catch((function(e){var t={error:y.FETCH_ERROR.ERROR_IN_API_CALL};l(t)}))}))},t.setSource=function(e,t,n){a.isFalsy(e)||(this.resource=e),a.isFalsy(t)||(this.platform=t),a.isFalsy(n)||(this.language=n)},t.clearCache=function(){return new Promise((function(e,n){try{h.LocalStorage.getInstance().clearStore().then((function(){A.UserStore.getInstance().clearStore().then((function(){C.MessagesStore.getInstance().clearStore().then((function(){t.removeDataFromSessionStorage(f.SESSION_STORE.SESSION_ID),a.Logger.info("CometChat: clearCache => All store cleared successfully","true"),e(!0)}))}))}))}catch(e){a.Logger.error("CometChat: clearCache",e),n(e)}}))},t.typingTimer=function(){try{setInterval((function(){G.TypingNotificationController.clearTimer()}),500)}catch(e){a.Logger.error("CometChat: typingTimer",e)}},t.prototype.internalLogout=function(e){return void 0===e&&(e=!0),new Promise((function(n,r){try{t.didAnalyticsPingStart()&&t.clearAnalyticsPingTimer(),t.didMessagesPollingStart()&&t.clearMessagesTimer(),t.WSReconnectionInProgress&&t.clearWSReconnectionTimer(),t.isLoggedOut=!0,t.pollingMessagesId=0,t.pollingEnabled=!1,t.pollingInterval=5e3,t.pollingEnabledInternally=!1,t.WSReconnectionStartTime=0,t.WSReconnectionInProgress=!1,t.setLastMessageId(0),t.setAccidentalDisconnect(!1),t.isAnalyticsDisabled=!1,t.shouldFallBackToPolling=!0,t.clearCache().then((function(){t.apiKey=void 0,t.user=void 0,t.authToken=void 0,t.cometChat=void 0,t.mode=void 0,E.XMPPConnectionHelper.getInstance().XMPPDisconnect(),e&&t.pushToLoginListener("","Logout_Success"),n(!0)}))}catch(e){a.Logger.error("CometChat: internalLogout",e),r(e)}}))},t.initialzed=!1,t.isNative=!1,t.CometChatException=c.CometChatException,t.TextMessage=S.TextMessage,t.MediaMessage=p.MediaMessage,t.CustomMessage=Y.CustomMessage,t.Action=P.Action,t.Call=N.Call,t.TypingIndicator=b.TypingIndicator,t.Group=T.Group,t.AppUser=l.User,t.User=l.User,t.GroupMember=x.GroupMember,t.Conversation=J.Conversation,t.USER_STATUS={ONLINE:f.PresenceConstatnts.STATUS.ONLINE,OFFLINE:f.PresenceConstatnts.STATUS.OFFLINE},t.MessagesRequest=U.DefaultMessagesRequest,t.MessagesRequestBuilder=U.DefaultMessagesRequestBuilder,t.UsersRequest=L.UsersRequest,t.UsersRequestBuilder=L.UsersRequestBuilder,t.ConversationsRequest=D.ConversationsRequest,t.ConversationsRequestBuilder=D.ConversationsRequestBuilder,t.BlockedUsersRequest=K.BlockedUsersRequest,t.BlockedUsersRequestBuilder=K.BlockedUsersRequestBuilder,t.GroupsRequest=M.GroupsRequest,t.GroupsRequestBuilder=M.GroupsRequestBuilder,t.GroupMembersRequest=v.GroupMembersRequest,t.GroupMembersRequestBuilder=v.GroupMembersRequestBuilder,t.BannedMembersRequest=v.GroupMembersRequest,t.BannedMembersRequestBuilder=v.GroupOutCastMembersRequestBuilder,t.AppSettings=k.AppSettings,t.AppSettingsBuilder=k.AppSettingsBuilder,t.MessageListener=R.MessageEventListener,t.UserListener=R.UserEventListener,t.GroupListener=R.GroupEventListener,t.OngoingCallListener=R.UserCallEventListener,t.CallListener=R.CallEventListener,t.ConnectionListener=E.XMPPConnectionEventListener,t.LoginListener=R.LoginEventListener,t.MESSAGE_TYPE=f.MessageConstatnts.TYPE,t.CATEGORY_MESSAGE=f.MessageConstatnts.CATEGORY.MESSAGE,t.CATEGORY_ACTION=f.MessageConstatnts.CATEGORY.ACTION,t.CATEGORY_CALL=f.MessageConstatnts.CATEGORY.CALL,t.CATEGORY_CUSTOM=f.MessageConstatnts.CATEGORY.CUSTOM,t.ACTION_TYPE=f.ActionConstatnts.ACTIONS,t.CALL_TYPE=f.CallConstants.CALL_TYPE,t.RECEIVER_TYPE=f.MessageConstatnts.RECEIVER_TYPE,t.CALL_STATUS=f.CallConstants.CALL_STATUS,t.CallController=O.CallController,t.GROUP_MEMBER_SCOPE=f.GROUP_MEMBER_SCOPE,t.GROUP_TYPE=f.GROUP_TYPE,t.MESSAGE_REQUEST=f.MessageConstatnts.PAGINATION.CURSOR_FILEDS,t.CometChatExtension=F.CometChatExtension,t.ExtensionManager=B.ExtensionManager,t.isCall=!1,t.endpointFactory=new i.EndpointFactory,t.startTypingCount=0,t.endTypingCount=0,t.CometChatHelper=V.CometChatHelper,t.WSReconnectionStartTime=0,t.WSMaxReconnectionLimit=10,t.WSCurrentReconnectionCount=0,t.WSReconnectionInProgress=!1,t.WSReconnectionPeriod=3e4,t.WSReconnectionTimerInterval=3e4,t.pollingEnabledInternally=!1,t.accidentalDisconnect=!1,t.successfulPingTimeStamp=0,t.currentConnectionStatus=f.CONNECTION_STATUS.DISCONNECTED,t.CONNECTION_STATUS=f.CONNECTION_STATUS,t.Attachment=j.Attachment,t.isConnectingFromInit=!1,t.loginInProgress=!1,t.lastMessageId=0,t.internalRestart=!1,t.pollingEnabled=!1,t.pollingInterval=5e3,t.pollingLimit=100,t.pollingAffix="append",t.pollingMessagesId=0,t.settingsInterval=6e4,t.isMessagesPollingStarted=!1,t.isAnalyticsPingStarted=!1,t.isLoggedOut=!0,t.isAnalyticsDisabled=!1,t.CallSettings=q.CallSettings,t.CallSettingsBuilder=q.CallSettingsBuilder,t.MediaDevice=$.MediaDevice,t.CALL_MODE=f.CallConstants.CALL_MODE,t.shouldFallBackToPolling=!0,t}();t.CometChat=te}).call(this,n(29))},function(e,t,n){"use strict";var r,s=this&&this.__extends||(r=function(e,t){return r=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)t.hasOwnProperty(n)&&(e[n]=t[n])},r(e,t)},function(e,t){function n(){this.constructor=e}r(e,t),e.prototype=null===t?Object.create(t):(n.prototype=t.prototype,new n)});t.__esModule=!0;var o=n(2),i=n(13),a=n(0),c=function(){function e(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];if(this.hasBlockedMe=!1,this.blockedByMe=!1,1===e.length)typeof e[0]===a.COMMON_UTILITY_CONSTANTS.TYPE_CONSTANTS.STRING?this.uid=e[0]:(this.uid=e[0].uid,this.name=e[0].name,e[0].authToken&&(this.authToken=e[0].authToken),e[0].avatar&&(this.avatar=e[0].avatar),e[0].lastActiveAt&&(this.lastActiveAt=e[0].lastActiveAt),e[0].link&&(this.link=e[0].link),e[0].metadata&&(this.metadata=e[0].metadata),e[0].role&&(this.role=e[0].role),e[0].statusMessage&&(this.statusMessage=e[0].statusMessage),e[0].status&&"offline"!==e[0].status?this.status="online":this.status="offline",e[0].tags&&(this.tags=e[0].tags));else{if(2!==e.length)throw new o.CometChatException(i.ERRORS.PARAMETER_MISSING);this.uid=e[0],this.name=e[1]}}return e.prototype.getUid=function(){return this.uid.toString()},e.prototype.setUid=function(e){this.uid=e},e.prototype.getName=function(){return this.name.toString()},e.prototype.setName=function(e){e&&(this.name=e)},e.prototype.getAuthToken=function(){return this.authToken},e.prototype.setAuthToken=function(e){this.authToken=e},e.prototype.getAvatar=function(){return this.avatar},e.prototype.setAvatar=function(e){this.avatar=e},e.prototype.getLastActiveAt=function(){return this.lastActiveAt},e.prototype.setLastActiveAt=function(e){this.lastActiveAt=e},e.prototype.getLink=function(){return this.link},e.prototype.setLink=function(e){return this.link=e},e.prototype.getMetadata=function(){return this.metadata},e.prototype.setMetadata=function(e){this.metadata=e},e.prototype.getRole=function(){return this.role},e.prototype.setRole=function(e){this.role=e},e.prototype.getStatus=function(){return this.status},e.prototype.setStatus=function(e){this.status=e},e.prototype.getStatusMessage=function(){return this.statusMessage},e.prototype.setStatusMessage=function(e){this.statusMessage=e},e.prototype.setBlockedByMe=function(e){this.blockedByMe=e},e.prototype.getBlockedByMe=function(){return this.blockedByMe},e.prototype.setHasBlockedMe=function(e){this.hasBlockedMe=e},e.prototype.getHasBlockedMe=function(){return this.hasBlockedMe},e.prototype.setTags=function(e){this.tags=e},e.prototype.getTags=function(){return this.tags},e}();t.User=c;var u=function(e){function t(t){var n=e.call(this,t)||this;return n.wsChannel=t.wsChannel,t.jwt&&(n.jwt=t.jwt),n}return s(t,e),t.prototype.getWsChannel=function(){return this.wsChannel},t.prototype.getJWT=function(){return this.jwt},t}(c);t.Me=u},function(e,t,n){"use strict";t.__esModule=!0;var r=n(31),s=n(3),o=n(1),i=n(2),a=n(13),c=n(0);function u(e,t,n,r,s){var i;return void 0===e&&(e=""),void 0===t&&(t="GET"),void 0===n&&(n={}),void 0===r&&(r={}),o.isFalsy(n)?n=void 0:("GET"==t&&(e+="?",Object.keys(n).map((function(t,r){e=r===Object.keys(n).length-1?e+t+"="+n[t]:e+t+"="+n[t]+"&"})),n=void 0),s&&(i=new FormData,Object.keys(n).map((function(e){"data"!=e?"metadata"!=e&&i.append(e,n[e]):i.append(e,JSON.stringify(n[e]))}))),n=JSON.stringify(n)),fetch(e,{method:t,mode:"cors",cache:"no-cache",headers:r,redirect:"follow",referrer:"no-referrer",body:s?i:n})}t.makeApiCall=function(e,t,n,l){void 0===e&&(e=""),void 0===t&&(t={}),void 0===n&&(n={});var E=s.CometChat.getInstance(s.CometChat.getAppId());return new Promise((function(d,h){try{r.getEndPoint(e,t).then((function(t){var r={resource:s.CometChat.getSessionId(),appId:s.CometChat.getAppId(),Accept:"application/json",sdk:o.format(c.SDKHeader.sdk,c.SDKHeader.platform,c.SDKHeader.sdkVersion)};l||(r["Content-Type"]="application/json"),t.hasOwnProperty("isAdminApi")&&t.isAdminApi?E.getApiKey()?r.apiKey=E.getApiKey():h({error:{code:"API_KEY_NOT_SET",message:"An apiKey is needed to use the "+e+" api.",name:"API_KEY_NOT_SET"}}):E.getAuthToken()?r.authToken=E.getAuthToken():h({error:{code:"USER_NOT_LOGED_IN",message:"An authToken is need to use the "+e+" end-point. PS- We are aware of the spelling mistake, but in order to maintain backward compatibility we cannot change it :(",name:"User not logged-in"}}),u(t.endpoint,t.method,n,r,l).then((function(e){return e.json()})).then((function(e){if(e.hasOwnProperty("data"))e.data.hasOwnProperty("authToken")&&s.CometChat.setAuthToken(e.data.authToken),d(e);else{if(e.hasOwnProperty("error")){var t=e.error;if(t.hasOwnProperty("code"))t.code===c.API_ERROR_CODES.AUTH_ERR_AUTH_TOKEN_NOT_FOUND&&s.CometChat.getInstance().internalLogout().then((function(){o.Logger.log("CometChat: makeApiCall","User logged out")}))}h(e)}})).catch((function(e){var t={error:a.FETCH_ERROR.ERROR_IN_API_CALL};h(t)}))})).catch((function(e){return h}))}catch(e){h(new i.CometChatException(e))}}))},t.makeAdminApiCall=function(e,t,n,i){void 0===e&&(e=""),void 0===t&&(t={}),void 0===n&&(n={});var l=s.CometChat.getInstance(s.CometChat.getAppId());return new Promise((function(E,d){r.getEndPoint(e,t).then((function(t){var r={appId:s.CometChat.getAppId(),Accept:"application/json",sdk:o.format(c.SDKHeader.sdk,c.SDKHeader.platform,c.SDKHeader.sdkVersion)};i||(r["Content-Type"]="application/json"),t.hasOwnProperty("isAdminApi")&&t.isAdminApi?l.getApiKey()?r.apiKey=l.getApiKey():d({error:"An apiKey is need to use the "+e+" api."}):l.getAuthToken()?r.authToken=l.getAuthToken():d({error:"An authToken is need to use the "+e+" api."}),u(t.endpoint,t.method,n,r,i).then((function(e){return e.json()})).then((function(e){e.hasOwnProperty("data")?(e.data.hasOwnProperty("authToken")&&s.CometChat.setAuthToken(e.data.authToken),E(e)):d(e)})).catch((function(e){var t={error:a.FETCH_ERROR.ERROR_IN_API_CALL};d(t)}))})).catch((function(e){return d}))}))},t.postData=u},function(e,t,n){"use strict";t.__esModule=!0;var r=n(0),s=function(){function e(e,t,n,r,s,o,i){this.hasJoined=!1,this.membersCount=0,this.guid=e,t&&(this.name=t),n&&(this.type=n),!r&&""!==r||"password"!=n||(this.password=r),(s||""===s)&&(this.icon=s),(o||""===o)&&(this.description=o),i&&(this.hasJoined=i)}return e.prototype.getGuid=function(){return this.guid},e.prototype.setGuid=function(e){this.guid=e},e.prototype.getName=function(){return this.name},e.prototype.setName=function(e){e&&(this.name=e)},e.prototype.getType=function(){return this.type},e.prototype.setType=function(e){this.type=e},e.prototype.setPassword=function(e){this.password=e},e.prototype.getIcon=function(){return this.icon},e.prototype.setIcon=function(e){this.icon=e},e.prototype.getDescription=function(){return this.description},e.prototype.setDescription=function(e){this.description=e},e.prototype.getOwner=function(){return this.owner},e.prototype.setOwner=function(e){this.owner=e},e.prototype.getMetadata=function(){return this.metadata},e.prototype.setMetadata=function(e){this.metadata=e},e.prototype.getCreatedAt=function(){return this.createdAt},e.prototype.setCreatedAt=function(e){this.createdAt=e},e.prototype.getUpdatedAt=function(){return this.updatedAt},e.prototype.setUpdatedAt=function(e){this.updatedAt=e},e.prototype.getHasJoined=function(){return this.hasJoined},e.prototype.setHasJoined=function(e){this.hasJoined=e},e.prototype.getWsChannel=function(){return this.wsChannel},e.prototype.setWsChannel=function(e){this.wsChannel=e},e.prototype.setScope=function(e){this.scope=e},e.prototype.getScope=function(){return this.scope},e.prototype.getJoinedAt=function(){return this.joinedAt},e.prototype.setJoinedAt=function(e){this.joinedAt=e},e.prototype.getMembersCount=function(){return this.membersCount},e.prototype.setMembersCount=function(e){this.membersCount=e},e.prototype.setTags=function(e){this.tags=e},e.prototype.getTags=function(){return this.tags},e.TYPE=r.GroupType,e.Type=e.TYPE,e}();t.Group=s},function(e,t,n){"use strict";t.__esModule=!0;var r=n(10),s=n(18),o=n(11),i=n(19),a=n(5),c=n(23),u=n(1),l=n(0),E=n(14),d=n(24),h=n(25),p=n(45),S=n(4),g=n(2),C=n(20),_=n(21),f=n(3),T=n(8),m=function(){function e(){}return e.trasformXMPPMessage=function(e){var t={};try{var n=JSON.parse(o.parseHTML(e.getElementsByTagName("body")[0]).trim().toString());t=this.trasformJSONMessge(n)}catch(e){u.Logger.error("MessageController: transformXMPPMessage",{e:e})}return t},e.checkIfCabon=function(e){try{return e.getElementsByTagName("forwarded").length>0&&e.getElementsByTagName("forwarded")[0],e.getElementsByTagName("forwarded").length>0}catch(e){u.Logger.error("MessageController: checkIfCabon",{e:e})}},e.trasformJSONMessge=function(e){try{var t=null;e.hasOwnProperty("rawMessage")||(t=JSON.parse(JSON.stringify(e)));var n=void 0;switch(e[l.MessageConstatnts.KEYS.CATEGORY]){case l.MessageConstatnts.CATEGORY.ACTION:n=d.Action.actionFromJSON(e);break;case l.MessageConstatnts.CATEGORY.CALL:n=h.Call.callFromJSON(e);break;case l.MessageConstatnts.CATEGORY.MESSAGE:switch(e[l.MessageConstatnts.KEYS.TYPE]){case l.MessageConstatnts.TYPE.TEXT:n=new s.TextMessage(e[l.MessageConstatnts.KEYS.RECEIVER],e[l.MessageConstatnts.KEYS.DATA][l.MessageConstatnts.KEYS.TEXT],e[l.MessageConstatnts.KEYS.RECEIVER_TYPE]);break;case l.MessageConstatnts.TYPE.CUSTOM:n=new _.CustomMessage(e[l.MessageConstatnts.KEYS.RECEIVER],e[l.MessageConstatnts.KEYS.DATA][l.MessageConstatnts.KEYS.CUSTOM_DATA],e[l.MessageConstatnts.KEYS.RECEIVER_TYPE]);break;default:if(n=new i.MediaMessage(e[l.MessageConstatnts.KEYS.RECEIVER],e[l.MessageConstatnts.KEYS.DATA][l.MessageConstatnts.KEYS.URL],e[l.MessageConstatnts.KEYS.TYPE],e[l.MessageConstatnts.KEYS.RECEIVER_TYPE]),e.hasOwnProperty(l.MessageConstatnts.KEYS.DATA)){var o=e[l.MessageConstatnts.KEYS.DATA];if(o.hasOwnProperty(l.MessageConstatnts.KEYS.ATTATCHMENTS)){var a,c=o[l.MessageConstatnts.KEYS.ATTATCHMENTS];new Array;c.map((function(e){a=new C.Attachment(e)})),n.setAttachment(a)}o.hasOwnProperty(l.MessageConstatnts.KEYS.TEXT)&&n.setCaption(o[l.MessageConstatnts.KEYS.TEXT])}n.hasOwnProperty("file")&&delete n.file}break;case l.MessageConstatnts.CATEGORY.CUSTOM:n=new _.CustomMessage(e[l.MessageConstatnts.KEYS.RECEIVER],e[l.MessageConstatnts.KEYS.DATA][l.MessageConstatnts.KEYS.CUSTOM_DATA],e[l.MessageConstatnts.KEYS.RECEIVER_TYPE],e.type)}e[l.MessageConstatnts.KEYS.MY_RECEIPTS]&&(e[l.MessageConstatnts.KEYS.MY_RECEIPTS]=e[l.MessageConstatnts.KEYS.MY_RECEIPTS],Object.keys(e[l.MessageConstatnts.KEYS.MY_RECEIPTS]).map((function(t){var n=new p.MessageReceipt;t==l.DELIVERY_RECEIPTS.DELIVERED_AT&&(n.setReceiptType(n.RECEIPT_TYPE.DELIVERY_RECEIPT),n.setDeliveredAt(e[l.MessageConstatnts.KEYS.MY_RECEIPTS][l.DELIVERY_RECEIPTS.DELIVERED_AT]),u.isFalsy(e[l.MessageConstatnts.KEYS.MY_RECEIPTS][l.DELIVERY_RECEIPTS.RECIPIENT])?e[l.DELIVERY_RECEIPTS.DELIVERED_TO_ME_AT]=e[l.MessageConstatnts.KEYS.MY_RECEIPTS][l.DELIVERY_RECEIPTS.DELIVERED_AT]:n.setSender(e[l.MessageConstatnts.KEYS.MY_RECEIPTS][l.DELIVERY_RECEIPTS.RECIPIENT]),n.setReceiverType(e[l.MessageConstatnts.KEYS.RECEIVER_TYPE]),n.setReceiver(e[l.MessageConstatnts.KEYS.RECEIVER])),e[l.MessageConstatnts.KEYS.MY_RECEIPTS][l.READ_RECEIPTS.READ_AT]&&(n.setReceiptType(n.RECEIPT_TYPE.READ_RECEIPT),n.setReadAt(e[l.MessageConstatnts.KEYS.MY_RECEIPTS][l.READ_RECEIPTS.READ_AT]),u.isFalsy(e[l.MessageConstatnts.KEYS.MY_RECEIPTS][l.READ_RECEIPTS.RECIPIENT])?e[l.READ_RECEIPTS.READ_BY_ME_AT]=e[l.MessageConstatnts.KEYS.MY_RECEIPTS][l.READ_RECEIPTS.READ_AT]:n.setSender(e[l.MessageConstatnts.KEYS.MY_RECEIPTS][l.READ_RECEIPTS.RECIPIENT]),n.setReceiverType(e[l.MessageConstatnts.KEYS.RECEIVER_TYPE]),n.setReceiver(e[l.MessageConstatnts.KEYS.RECEIVER]))})));try{if(Object.assign(n,e),(e=n).parentId&&(e.parentMessageId=e.parentId,delete e.parentId),e instanceof r.BaseMessage&&(u.isFalsy(t)||e.setRawMessage(t)),e instanceof s.TextMessage)e.setSender(e.getSender()),e.setReceiver(e.getReceiver()),e.getData()[l.MessageConstatnts.KEYS.METADATA]&&e.setMetadata(e.getData()[l.MessageConstatnts.KEYS.METADATA]);else if(e instanceof i.MediaMessage)e.getData()[l.MessageConstatnts.KEYS.METADATA]&&e.setMetadata(e.getData()[l.MessageConstatnts.KEYS.METADATA]),e.setSender(e.getSender()),e.setReceiver(e.getReceiver());else if(e instanceof d.Action)e.setSender(e.getSender()),e.setReceiver(e.getActionFor()),e.setActionBy(e.getActionBy()),e.setActionOn(e.getActionOn()),e.setActionFor(e.getActionFor()),e.setMessage(e.getMessage());else if(e instanceof h.Call){try{e.setSender(e.getSender())}catch(e){u.Logger.error("MessageController: trasformJSONMessge: setSender",e)}try{e.setCallInitiator(e.getCallInitiator())}catch(e){u.Logger.error("MessageController: trasformJSONMessge: setCallInitiator",e)}try{e.setReceiver(e.getCallReceiver()),e.setCallReceiver(e.getCallReceiver())}catch(e){u.Logger.error("MessageController: trasformJSONMessge: setCallreceiver",e)}}else e instanceof _.CustomMessage&&(e.getData()[l.MessageConstatnts.KEYS.METADATA]&&e.setMetadata(e.getData()[l.MessageConstatnts.KEYS.METADATA]),e.setSubType(e.getData()[l.MessageConstatnts.KEYS.CUSTOM_SUB_TYPE]),e.setSender(e.getSender()),e.setReceiver(e.getReceiver()))}catch(t){u.Logger.error("MessageController: trasformJSONMessge: Main",t),e=null}return e}catch(e){u.Logger.error("MessageController: trasformJSONMessge",e)}},e.getOfflineHistory=function(t,n){void 0===t&&(t=1e3),void 0===n&&(n=1);try{c.MessagesStore.getInstance();var r=[];a.makeApiCall("getMessages",{},this.createData(t,n)).then((function(t){return u.isFalsy(t.data)||t.data.map((function(t){E.XMPPConnectionHelper.getInstance().trigerMessageHandler(t),r.push(e.trasformJSONMessge(t))})),!0}))}catch(e){u.Logger.error("MessageController: getOfflineHistory",e)}},e.getAllMessage=function(t,n,r,s){var o=this;void 0===t&&(t=100);var i=[];return new Promise((function(c,l){try{a.makeApiCall("getMessages",{},o.createAllMessageData(t,n,r,s)).then((function(t){u.isFalsy(t.data)||(t.data.map((function(t){i.push(e.trasformJSONMessge(t))})),c(i))}),(function(e){u.Logger.error("Error on fetching all message",e),c([])}))}catch(e){l(new g.CometChatException(e))}}))},e.createData=function(e,t){return void 0===t&&(t=0),{per_page:e,cursorValue:t,cursorField:l.MessageConstatnts.PAGINATION.CURSOR_FILEDS.ID,cursorAffix:u.isFalsy(t)?l.MessageConstatnts.PAGINATION.AFFIX.PREPEND:l.MessageConstatnts.PAGINATION.AFFIX.APPEND}},e.createAllMessageData=function(e,t,n,r){return{per_page:e,cursorValue:t,cursorField:n,cursorAffix:r}},e.isDeliveryReceipt=function(e){try{return e.getElementsByTagName(l.DELIVERY_RECEIPTS.RECEIVED).length>0}catch(e){u.Logger.error("MessageController: isDeliveryReceipts",e)}},e.isReadRceipt=function(e){try{return e.getElementsByTagName(l.READ_RECEIPTS.READ).length>0}catch(e){u.Logger.error("MessageController: isDeliveryReceipts",e)}},e.processDeliveryReceipt=function(e){return new Promise((function(t,n){try{var r=e.getElementsByTagName(l.DELIVERY_RECEIPTS.RECEIVED)[0],s=e.getElementsByTagName(l.DELIVERY_RECEIPTS.DELIVERED_AT)[0],i=void 0;if(e.getElementsByTagName("user")[0]){delete(i=new S.User(JSON.parse(o.parseHTML(e.getElementsByTagName("user")[0]).trim().toString()))).authToken;var a=new p.MessageReceipt;a.setSender(i),r.getAttribute(l.DELIVERY_RECEIPTS.RECEIVER_TYPE)==l.MessageConstatnts.RECEIVER_TYPE.GROUP?(a.setReceiverType(l.MessageConstatnts.RECEIVER_TYPE.GROUP),a.setReceiver(r.getAttribute(l.DELIVERY_RECEIPTS.RECEIVER_ID))):(a.setReceiverType(l.MessageConstatnts.RECEIVER_TYPE.USER),a.setReceiver(o.getUidFromJid(e.getAttribute(l.MessageConstatnts.XMPP_KEYS.TO)))),a.setReceiptType(a.RECEIPT_TYPE.DELIVERY_RECEIPT),a.setMessageId(o.getmessageIdFromStanzaId(r.getAttribute(l.DELIVERY_RECEIPTS.ID))),a.setTimestamp(s.getAttribute(l.DELIVERY_RECEIPTS.TIME)),a.setDeliveredAt(s.getAttribute(l.DELIVERY_RECEIPTS.TIME)),t(a)}else E.XMPPConnectionHelper.getInstance().getUsersVCard(o.getUidFromJid(e.getAttribute(l.MessageConstatnts.XMPP_KEYS.FROM)),(function(n){var i=new p.MessageReceipt;i.setSender(n),r.getAttribute(l.DELIVERY_RECEIPTS.RECEIVER_TYPE)==l.MessageConstatnts.RECEIVER_TYPE.GROUP?(i.setReceiverType(l.MessageConstatnts.RECEIVER_TYPE.GROUP),i.setReceiver(r.getAttribute(l.DELIVERY_RECEIPTS.RECEIVER_ID))):(i.setReceiverType(l.MessageConstatnts.RECEIVER_TYPE.USER),i.setReceiver(o.getUidFromJid(e.getAttribute(l.MessageConstatnts.XMPP_KEYS.TO)))),i.setReceiptType(i.RECEIPT_TYPE.DELIVERY_RECEIPT),i.setMessageId(o.getmessageIdFromStanzaId(r.getAttribute(l.DELIVERY_RECEIPTS.ID))),i.setTimestamp(s.getAttribute(l.DELIVERY_RECEIPTS.TIME)),i.setDeliveredAt(s.getAttribute(l.DELIVERY_RECEIPTS.TIME)),t(i)}))}catch(e){n(new g.CometChatException(e))}}))},e.processReadReceipt=function(e){return new Promise((function(t,n){try{var r=e.getElementsByTagName(l.READ_RECEIPTS.READ)[0],s=e.getElementsByTagName(l.READ_RECEIPTS.READ_AT)[0],i=void 0;if(e.getElementsByTagName("user")[0]){delete(i=new S.User(JSON.parse(o.parseHTML(e.getElementsByTagName("user")[0]).trim().toString()))).authToken;var a=new p.MessageReceipt;a.setSender(i),r.getAttribute(l.READ_RECEIPTS.RECEIVER_TYPE)==l.MessageConstatnts.RECEIVER_TYPE.GROUP?(a.setReceiverType(l.MessageConstatnts.RECEIVER_TYPE.GROUP),a.setReceiver(r.getAttribute(l.READ_RECEIPTS.RECEIVER_ID))):(a.setReceiverType(l.MessageConstatnts.RECEIVER_TYPE.USER),a.setReceiver(o.getUidFromJid(e.getAttribute(l.MessageConstatnts.XMPP_KEYS.TO)))),a.setReceiptType(a.RECEIPT_TYPE.READ_RECEIPT),a.setMessageId(o.getmessageIdFromStanzaId(r.getAttribute(l.READ_RECEIPTS.ID))),a.setTimestamp(s.getAttribute(l.READ_RECEIPTS.TIME)),a.setReadAt(s.getAttribute(l.READ_RECEIPTS.TIME)),t(a)}else E.XMPPConnectionHelper.getInstance().getUsersVCard(o.getUidFromJid(e.getAttribute(l.MessageConstatnts.XMPP_KEYS.FROM)),(function(n){var i=new p.MessageReceipt;i.setSender(n),r.getAttribute(l.READ_RECEIPTS.RECEIVER_TYPE)==l.MessageConstatnts.RECEIVER_TYPE.GROUP?(i.setReceiverType(l.MessageConstatnts.RECEIVER_TYPE.GROUP),i.setReceiver(r.getAttribute(l.READ_RECEIPTS.RECEIVER_ID))):(i.setReceiverType(l.MessageConstatnts.RECEIVER_TYPE.USER),i.setReceiver(o.getUidFromJid(e.getAttribute(l.MessageConstatnts.XMPP_KEYS.TO)))),i.setReceiptType(i.RECEIPT_TYPE.READ_RECEIPT),i.setMessageId(o.getmessageIdFromStanzaId(r.getAttribute(l.READ_RECEIPTS.ID))),i.setTimestamp(s.getAttribute(l.READ_RECEIPTS.TIME)),i.setReadAt(s.getAttribute(l.READ_RECEIPTS.TIME)),t(i)}))}catch(e){n(new g.CometChatException(e))}}))},e.getReceiptsFromJSON=function(e){return new Promise((function(t,n){try{var r=[];f.CometChat.getLoggedInUser().then((function(n){u.isFalsy(e.receipts)?t([]):(e.receipts.data.map((function(t){var s=new p.MessageReceipt;t[l.DELIVERY_RECEIPTS.DELIVERED_AT]&&(s.setReceiptType(s.RECEIPT_TYPE.DELIVERY_RECEIPT),s.setDeliveredAt(t[l.DELIVERY_RECEIPTS.DELIVERED_AT]),s.setTimestamp(t[l.DELIVERY_RECEIPTS.DELIVERED_AT]),u.isFalsy(t[l.DELIVERY_RECEIPTS.RECIPIENT])?s.setSender(n):s.setSender(T.UsersController.trasformJSONUser(t[l.DELIVERY_RECEIPTS.RECIPIENT])),s.setReceiverType(e[l.MessageConstatnts.KEYS.RECEIVER_TYPE]),s.setReceiver(e[l.MessageConstatnts.KEYS.RECEIVER])),t[l.READ_RECEIPTS.READ_AT]&&(s.setReceiptType(s.RECEIPT_TYPE.READ_RECEIPT),s.setReadAt(t[l.READ_RECEIPTS.READ_AT]),s.setTimestamp(t[t[l.READ_RECEIPTS.READ_AT]]),u.isFalsy(t[l.READ_RECEIPTS.RECIPIENT])?s.setSender(n):s.setSender(T.UsersController.trasformJSONUser(t[l.READ_RECEIPTS.RECIPIENT])),s.setReceiverType(e[l.MessageConstatnts.KEYS.RECEIVER_TYPE]),s.setReceiver(e[l.MessageConstatnts.KEYS.RECEIVER])),r.push(s)})),t(r))}))}catch(e){n(new g.CometChatException(e))}}))},e}();t.MessageController=m},function(e,t,n){"use strict";t.__esModule=!0;var r=n(4),s=n(1),o=function(){function e(){}return e.trasformJSONUser=function(e){var t;try{e.uid=e.uid.toString(),e.name=e.name.toString(),e.status&&"offline"!==e.status?e.status="online":e.status="offline",t=new r.User(e),Object.assign(t,e),e=t}catch(e){s.Logger.error("UsersController:transformJSONUser",e)}return e},e}();t.UsersController=o},function(e,t,n){"use strict";t.__esModule=!0;var r=n(1),s=n(0),o=n(12),i=n(3),a=n(2),c=function(){function e(e){this.store=s.constants.DEFAULT_STORE,r.isFalsy(e)||(this.store=e),this.localStore=o.createInstance({name:r.format(s.LOCAL_STORE.STORE_STRING,i.CometChat.getAppId(),s.LOCAL_STORE.COMMON_STORE)}),this.localStore.setDriver([o.LOCALSTORAGE,o.INDEXEDDB,o.WEBSQL])}return e.getInstance=function(){return null==e.localStorage&&(e.localStorage=new e),e.localStorage},e.prototype.set=function(e,t){return this.localStore.setItem(e,JSON.stringify(t))},e.prototype.remove=function(e){this.localStore.removeItem(e)},e.prototype.update=function(e,t){this.remove(e),this.set(e,t)},e.prototype.get=function(e){var t=this;return new Promise((function(n,r){try{t.localStore.getItem(e).then((function(e){try{n(JSON.parse(e))}catch(t){n(e)}}),(function(e){r(e)}))}catch(e){r(new a.CometChatException(e))}}))},e.prototype.clearStore=function(){var e=this;return new Promise((function(t,n){try{e.localStore.keys().then((function(n){if(n.length>0)for(var r=0;r<n.length;r++)"appId"!==n[r]&&e.localStore.removeItem(n[r]),r===n.length-1&&t(!0)}))}catch(e){n(e)}}))},e.prototype.clear=function(e){},e.prototype.selectStore=function(e){this.store=e},e.localStorage=null,e}();t.LocalStorage=c},function(e,t,n){"use strict";t.__esModule=!0;var r=function(){function e(e,t,n,r){this.receiverId=e,this.type=t,this.receiverType=n,this.category=r}return e.prototype.getId=function(){return this.id},e.prototype.setId=function(e){this.id=e},e.prototype.getConversationId=function(){return this.conversationId},e.prototype.setConversationId=function(e){this.conversationId=e},e.prototype.getParentMessageId=function(){return this.parentMessageId},e.prototype.setParentMessageId=function(e){this.parentMessageId=e},e.prototype.getMuid=function(){return this.muid},e.prototype.setMuid=function(e){this.muid=e},e.prototype.getSender=function(){return this.sender},e.prototype.setSender=function(e){this.sender=e},e.prototype.getReceiver=function(){return this.receiver},e.prototype.setReceiver=function(e){this.receiver=e},e.prototype.getReceiverId=function(){return this.receiverId},e.prototype.setReceiverId=function(e){this.receiverId=e},e.prototype.getType=function(){return this.type},e.prototype.setType=function(e){this.type=e},e.prototype.get=function(){return this.id},e.prototype.setReceiverType=function(e){this.receiverType=e},e.prototype.getReceiverType=function(){return this.receiverType},e.prototype.setSentAt=function(e){this.sentAt=e},e.prototype.getSentAt=function(){return this.sentAt},e.prototype.getStatus=function(){return this.status},e.prototype.setStatus=function(e){this.status=e},e.prototype.getDeliveredAt=function(){return this.deliveredAt},e.prototype.setDeliveredAt=function(e){this.deliveredAt=e},e.prototype.getDeliveredToMeAt=function(){return this.deliveredToMeAt},e.prototype.setDeliveredToMeAt=function(e){this.deliveredToMeAt=e},e.prototype.getReadAt=function(){return this.readAt},e.prototype.setReadAt=function(e){this.readAt=e},e.prototype.getReadByMeAt=function(){return this.readByMeAt},e.prototype.setReadByMeAt=function(e){this.readByMeAt=e},e.prototype.getCategory=function(){return this.category},e.prototype.setCategory=function(e){this.category=e},e.prototype.setEditedAt=function(e){this.editedAt=e},e.prototype.getEditedAt=function(){return this.editedAt},e.prototype.setEditedBy=function(e){this.editedBy=e},e.prototype.getEditedBy=function(){return this.editedBy},e.prototype.setDeletedAt=function(e){this.deletedAt=e},e.prototype.getDeletedAt=function(){return this.deletedAt},e.prototype.setDeletedBy=function(e){this.deletedBy=e},e.prototype.getDeletedBy=function(){return this.deletedBy},e.prototype.getReplyCount=function(){return this.replyCount},e.prototype.setReplyCount=function(e){this.replyCount=e},e.prototype.getRawMessage=function(){return this.rawMessage},e.prototype.setRawMessage=function(e){this.rawMessage=e},e}();t.BaseMessage=r},function(e,t,n){"use strict";t.__esModule=!0;var r=n(0),s=n(1),o=n(3),i=n(2);t.getUidFromJid=function(e){try{return e.substring(e.lastIndexOf("]")+1,e.lastIndexOf("@"))}catch(e){s.Logger.error("XMPPUtils: getUidFromJid",e)}},t.getappIdFromJid=function(e){try{return e.substring(e.lastIndexOf("[")+1,e.lastIndexOf("]"))}catch(e){s.Logger.error("XMPPUtils: getappIdFromJid",e)}},t.getmessageIdFromStanzaId=function(e){try{return e?e.substring(e.lastIndexOf("]")+1,e.length):e}catch(t){return s.Logger.error("XMPPUtils: getmessageIdFromStanzaId",t),e}},t.parseHTML=function(e){try{return void 0!==e?e.textContent:e}catch(t){return s.Logger.error("XMPPUtils: parseHTML",t),e}},t.getJidFromUid=function(e){return new Promise((function(t,n){try{s.getAppSettings().then((function(n){t(s.format(r.XMPP.bare_jid_string,o.CometChat.getAppId(),e,s.getJidHost(n)))}),(function(n){t(s.format(r.XMPP.bare_jid_string,o.CometChat.getAppId(),e,r.XMPP.host))}))}catch(e){n(new i.CometChatException(e))}}))},t.getGUIDFromJID=function(e){try{return e.substring(e.indexOf("]")+1,e.indexOf("@"))}catch(e){s.Logger.error("XMPPUtils: getGUIDFromJID",e)}},t.getGroupJidFromGUID=function(e){return new Promise((function(t,n){try{s.getAppSettings().then((function(n){t(s.format(r.XMPP.muc_jid_string,o.CometChat.getAppId(),e,n[r.APP_SETTINGS.KEYS.GROUP_SERVICE],s.getJidHost(n)))}),(function(n){t(s.format(r.XMPP.muc_jid_string,o.CometChat.getAppId(),e,o.CometChat.getAppId(),r.XMPP.host))}))}catch(e){n(new i.CometChatException(e))}}))},t.getFullJidForGroup=function(e){try{return e.substring(e.indexOf("/")+1)}catch(e){s.Logger.error("XMPPUtils: getFullJidForGroup",e)}},t.getGroupJidFullGroupJid=function(e){try{return e.substring(0,e.indexOf("/"))}catch(e){s.Logger.error("XMPPUtils: getGroupJidFullGroupJid",e)}}},function(e,t,n){(function(t){e.exports=function e(t,n,r){function s(i,a){if(!n[i]){if(!t[i]){if(o)return o(i,!0);var c=new Error("Cannot find module '"+i+"'");throw c.code="MODULE_NOT_FOUND",c}var u=n[i]={exports:{}};t[i][0].call(u.exports,(function(e){var n=t[i][1][e];return s(n||e)}),u,u.exports,e,t,n,r)}return n[i].exports}for(var o=!1,i=0;i<r.length;i++)s(r[i]);return s}({1:[function(e,n,r){(function(e){"use strict";var t,r,s=e.MutationObserver||e.WebKitMutationObserver;if(s){var o=0,i=new s(l),a=e.document.createTextNode("");i.observe(a,{characterData:!0}),t=function(){a.data=o=++o%2}}else if(e.setImmediate||void 0===e.MessageChannel)t="document"in e&&"onreadystatechange"in e.document.createElement("script")?function(){var t=e.document.createElement("script");t.onreadystatechange=function(){l(),t.onreadystatechange=null,t.parentNode.removeChild(t),t=null},e.document.documentElement.appendChild(t)}:function(){setTimeout(l,0)};else{var c=new e.MessageChannel;c.port1.onmessage=l,t=function(){c.port2.postMessage(0)}}var u=[];function l(){var e,t;r=!0;for(var n=u.length;n;){for(t=u,u=[],e=-1;++e<n;)t[e]();n=u.length}r=!1}function E(e){1!==u.push(e)||r||t()}n.exports=E}).call(this,void 0!==t?t:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{}],2:[function(e,t,n){"use strict";var r=e(1);function s(){}var o={},i=["REJECTED"],a=["FULFILLED"],c=["PENDING"];function u(e){if("function"!=typeof e)throw new TypeError("resolver must be a function");this.state=c,this.queue=[],this.outcome=void 0,e!==s&&h(this,e)}function l(e,t,n){this.promise=e,"function"==typeof t&&(this.onFulfilled=t,this.callFulfilled=this.otherCallFulfilled),"function"==typeof n&&(this.onRejected=n,this.callRejected=this.otherCallRejected)}function E(e,t,n){r((function(){var r;try{r=t(n)}catch(t){return o.reject(e,t)}r===e?o.reject(e,new TypeError("Cannot resolve promise with itself")):o.resolve(e,r)}))}function d(e){var t=e&&e.then;if(e&&("object"==typeof e||"function"==typeof e)&&"function"==typeof t)return function(){t.apply(e,arguments)}}function h(e,t){var n=!1;function r(t){n||(n=!0,o.reject(e,t))}function s(t){n||(n=!0,o.resolve(e,t))}function i(){t(s,r)}var a=p(i);"error"===a.status&&r(a.value)}function p(e,t){var n={};try{n.value=e(t),n.status="success"}catch(e){n.status="error",n.value=e}return n}function S(e){return e instanceof this?e:o.resolve(new this(s),e)}function g(e){var t=new this(s);return o.reject(t,e)}function C(e){var t=this;if("[object Array]"!==Object.prototype.toString.call(e))return this.reject(new TypeError("must be an array"));var n=e.length,r=!1;if(!n)return this.resolve([]);for(var i=new Array(n),a=0,c=-1,u=new this(s);++c<n;)l(e[c],c);return u;function l(e,s){function c(e){i[s]=e,++a!==n||r||(r=!0,o.resolve(u,i))}t.resolve(e).then(c,(function(e){r||(r=!0,o.reject(u,e))}))}}function _(e){var t=this;if("[object Array]"!==Object.prototype.toString.call(e))return this.reject(new TypeError("must be an array"));var n=e.length,r=!1;if(!n)return this.resolve([]);for(var i=-1,a=new this(s);++i<n;)c(e[i]);return a;function c(e){t.resolve(e).then((function(e){r||(r=!0,o.resolve(a,e))}),(function(e){r||(r=!0,o.reject(a,e))}))}}t.exports=u,u.prototype.catch=function(e){return this.then(null,e)},u.prototype.then=function(e,t){if("function"!=typeof e&&this.state===a||"function"!=typeof t&&this.state===i)return this;var n=new this.constructor(s);return this.state!==c?E(n,this.state===a?e:t,this.outcome):this.queue.push(new l(n,e,t)),n},l.prototype.callFulfilled=function(e){o.resolve(this.promise,e)},l.prototype.otherCallFulfilled=function(e){E(this.promise,this.onFulfilled,e)},l.prototype.callRejected=function(e){o.reject(this.promise,e)},l.prototype.otherCallRejected=function(e){E(this.promise,this.onRejected,e)},o.resolve=function(e,t){var n=p(d,t);if("error"===n.status)return o.reject(e,n.value);var r=n.value;if(r)h(e,r);else{e.state=a,e.outcome=t;for(var s=-1,i=e.queue.length;++s<i;)e.queue[s].callFulfilled(t)}return e},o.reject=function(e,t){e.state=i,e.outcome=t;for(var n=-1,r=e.queue.length;++n<r;)e.queue[n].callRejected(t);return e},u.resolve=S,u.reject=g,u.all=C,u.race=_},{1:1}],3:[function(e,n,r){(function(t){"use strict";"function"!=typeof t.Promise&&(t.Promise=e(2))}).call(this,void 0!==t?t:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{2:2}],4:[function(e,t,n){"use strict";var r="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e};function s(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function o(){try{if("undefined"!=typeof indexedDB)return indexedDB;if("undefined"!=typeof webkitIndexedDB)return webkitIndexedDB;if("undefined"!=typeof mozIndexedDB)return mozIndexedDB;if("undefined"!=typeof OIndexedDB)return OIndexedDB;if("undefined"!=typeof msIndexedDB)return msIndexedDB}catch(e){return}}var i=o();function a(){try{if(!i)return!1;var e="undefined"!=typeof openDatabase&&/(Safari|iPhone|iPad|iPod)/.test(navigator.userAgent)&&!/Chrome/.test(navigator.userAgent)&&!/BlackBerry/.test(navigator.platform),t="function"==typeof fetch&&-1!==fetch.toString().indexOf("[native code");return(!e||t)&&"undefined"!=typeof indexedDB&&"undefined"!=typeof IDBKeyRange}catch(e){return!1}}function c(e,t){e=e||[],t=t||{};try{return new Blob(e,t)}catch(s){if("TypeError"!==s.name)throw s;for(var n=new("undefined"!=typeof BlobBuilder?BlobBuilder:"undefined"!=typeof MSBlobBuilder?MSBlobBuilder:"undefined"!=typeof MozBlobBuilder?MozBlobBuilder:WebKitBlobBuilder),r=0;r<e.length;r+=1)n.append(e[r]);return n.getBlob(t.type)}}"undefined"==typeof Promise&&e(3);var u=Promise;function l(e,t){t&&e.then((function(e){t(null,e)}),(function(e){t(e)}))}function E(e,t,n){"function"==typeof t&&e.then(t),"function"==typeof n&&e.catch(n)}function d(e){return"string"!=typeof e&&(e=String(e)),e}function h(){if(arguments.length&&"function"==typeof arguments[arguments.length-1])return arguments[arguments.length-1]}var p="local-forage-detect-blob-support",S=void 0,g={},C=Object.prototype.toString,_="readonly",f="readwrite";function T(e){for(var t=e.length,n=new ArrayBuffer(t),r=new Uint8Array(n),s=0;s<t;s++)r[s]=e.charCodeAt(s);return n}function m(e){return new u((function(t){var n=e.transaction(p,f),r=c([""]);n.objectStore(p).put(r,"key"),n.onabort=function(e){e.preventDefault(),e.stopPropagation(),t(!1)},n.oncomplete=function(){var e=navigator.userAgent.match(/Chrome\/(\d+)/),n=navigator.userAgent.match(/Edge\//);t(n||!e||parseInt(e[1],10)>=43)}})).catch((function(){return!1}))}function A(e){return"boolean"==typeof S?u.resolve(S):m(e).then((function(e){return S=e}))}function I(e){var t=g[e.name],n={};n.promise=new u((function(e,t){n.resolve=e,n.reject=t})),t.deferredOperations.push(n),t.dbReady?t.dbReady=t.dbReady.then((function(){return n.promise})):t.dbReady=n.promise}function R(e){var t=g[e.name].deferredOperations.pop();if(t)return t.resolve(),t.promise}function N(e,t){var n=g[e.name].deferredOperations.pop();if(n)return n.reject(t),n.promise}function O(e,t){return new u((function(n,r){if(g[e.name]=g[e.name]||G(),e.db){if(!t)return n(e.db);I(e),e.db.close()}var s=[e.name];t&&s.push(e.version);var o=i.open.apply(i,s);t&&(o.onupgradeneeded=function(t){var n=o.result;try{n.createObjectStore(e.storeName),t.oldVersion<=1&&n.createObjectStore(p)}catch(e){if("ConstraintError"!==e.name)throw e}}),o.onerror=function(e){e.preventDefault(),r(o.error)},o.onsuccess=function(){n(o.result),R(e)}}))}function y(e){return O(e,!1)}function P(e){return O(e,!0)}function M(e,t){if(!e.db)return!0;var n=!e.db.objectStoreNames.contains(e.storeName),r=e.version<e.db.version,s=e.version>e.db.version;if(r&&(e.version,e.version=e.db.version),s||n){if(n){var o=e.db.version+1;o>e.version&&(e.version=o)}return!0}return!1}function v(e){return new u((function(t,n){var r=new FileReader;r.onerror=n,r.onloadend=function(n){var r=btoa(n.target.result||"");t({__local_forage_encoded_blob:!0,data:r,type:e.type})},r.readAsBinaryString(e)}))}function L(e){return c([T(atob(e.data))],{type:e.type})}function D(e){return e&&e.__local_forage_encoded_blob}function U(e){var t=this,n=t._initReady().then((function(){var e=g[t._dbInfo.name];if(e&&e.dbReady)return e.dbReady}));return E(n,e,e),n}function w(e){I(e);for(var t=g[e.name],n=t.forages,r=0;r<n.length;r++){var s=n[r];s._dbInfo.db&&(s._dbInfo.db.close(),s._dbInfo.db=null)}return e.db=null,y(e).then((function(t){return e.db=t,M(e)?P(e):t})).then((function(r){e.db=t.db=r;for(var s=0;s<n.length;s++)n[s]._dbInfo.db=r})).catch((function(t){throw N(e,t),t}))}function b(e,t,n,r){void 0===r&&(r=1);try{var s=e.db.transaction(e.storeName,t);n(null,s)}catch(s){if(r>0&&(!e.db||"InvalidStateError"===s.name||"NotFoundError"===s.name))return u.resolve().then((function(){if(!e.db||"NotFoundError"===s.name&&!e.db.objectStoreNames.contains(e.storeName)&&e.version<=e.db.version)return e.db&&(e.version=e.db.version+1),P(e)})).then((function(){return w(e).then((function(){b(e,t,n,r-1)}))})).catch(n);n(s)}}function G(){return{forages:[],db:null,dbReady:null,deferredOperations:[]}}function Y(e){var t=this,n={db:null};if(e)for(var r in e)n[r]=e[r];var s=g[n.name];s||(s=G(),g[n.name]=s),s.forages.push(t),t._initReady||(t._initReady=t.ready,t.ready=U);var o=[];function i(){return u.resolve()}for(var a=0;a<s.forages.length;a++){var c=s.forages[a];c!==t&&o.push(c._initReady().catch(i))}var l=s.forages.slice(0);return u.all(o).then((function(){return n.db=s.db,y(n)})).then((function(e){return n.db=e,M(n,t._defaultConfig.version)?P(n):e})).then((function(e){n.db=s.db=e,t._dbInfo=n;for(var r=0;r<l.length;r++){var o=l[r];o!==t&&(o._dbInfo.db=n.db,o._dbInfo.version=n.version)}}))}function x(e,t){var n=this;e=d(e);var r=new u((function(t,r){n.ready().then((function(){b(n._dbInfo,_,(function(s,o){if(s)return r(s);try{var i=o.objectStore(n._dbInfo.storeName).get(e);i.onsuccess=function(){var e=i.result;void 0===e&&(e=null),D(e)&&(e=L(e)),t(e)},i.onerror=function(){r(i.error)}}catch(e){r(e)}}))})).catch(r)}));return l(r,t),r}function F(e,t){var n=this,r=new u((function(t,r){n.ready().then((function(){b(n._dbInfo,_,(function(s,o){if(s)return r(s);try{var i=o.objectStore(n._dbInfo.storeName).openCursor(),a=1;i.onsuccess=function(){var n=i.result;if(n){var r=n.value;D(r)&&(r=L(r));var s=e(r,n.key,a++);void 0!==s?t(s):n.continue()}else t()},i.onerror=function(){r(i.error)}}catch(e){r(e)}}))})).catch(r)}));return l(r,t),r}function B(e,t,n){var r=this;e=d(e);var s=new u((function(n,s){var o;r.ready().then((function(){return o=r._dbInfo,"[object Blob]"===C.call(t)?A(o.db).then((function(e){return e?t:v(t)})):t})).then((function(t){b(r._dbInfo,f,(function(o,i){if(o)return s(o);try{var a=i.objectStore(r._dbInfo.storeName);null===t&&(t=void 0);var c=a.put(t,e);i.oncomplete=function(){void 0===t&&(t=null),n(t)},i.onabort=i.onerror=function(){var e=c.error?c.error:c.transaction.error;s(e)}}catch(e){s(e)}}))})).catch(s)}));return l(s,n),s}function H(e,t){var n=this;e=d(e);var r=new u((function(t,r){n.ready().then((function(){b(n._dbInfo,f,(function(s,o){if(s)return r(s);try{var i=o.objectStore(n._dbInfo.storeName).delete(e);o.oncomplete=function(){t()},o.onerror=function(){r(i.error)},o.onabort=function(){var e=i.error?i.error:i.transaction.error;r(e)}}catch(e){r(e)}}))})).catch(r)}));return l(r,t),r}function K(e){var t=this,n=new u((function(e,n){t.ready().then((function(){b(t._dbInfo,f,(function(r,s){if(r)return n(r);try{var o=s.objectStore(t._dbInfo.storeName).clear();s.oncomplete=function(){e()},s.onabort=s.onerror=function(){var e=o.error?o.error:o.transaction.error;n(e)}}catch(e){n(e)}}))})).catch(n)}));return l(n,e),n}function k(e){var t=this,n=new u((function(e,n){t.ready().then((function(){b(t._dbInfo,_,(function(r,s){if(r)return n(r);try{var o=s.objectStore(t._dbInfo.storeName).count();o.onsuccess=function(){e(o.result)},o.onerror=function(){n(o.error)}}catch(e){n(e)}}))})).catch(n)}));return l(n,e),n}function V(e,t){var n=this,r=new u((function(t,r){e<0?t(null):n.ready().then((function(){b(n._dbInfo,_,(function(s,o){if(s)return r(s);try{var i=o.objectStore(n._dbInfo.storeName),a=!1,c=i.openCursor();c.onsuccess=function(){var n=c.result;n?0===e||a?t(n.key):(a=!0,n.advance(e)):t(null)},c.onerror=function(){r(c.error)}}catch(e){r(e)}}))})).catch(r)}));return l(r,t),r}function J(e){var t=this,n=new u((function(e,n){t.ready().then((function(){b(t._dbInfo,_,(function(r,s){if(r)return n(r);try{var o=s.objectStore(t._dbInfo.storeName).openCursor(),i=[];o.onsuccess=function(){var t=o.result;t?(i.push(t.key),t.continue()):e(i)},o.onerror=function(){n(o.error)}}catch(e){n(e)}}))})).catch(n)}));return l(n,e),n}function X(e,t){t=h.apply(this,arguments);var n=this.config();(e="function"!=typeof e&&e||{}).name||(e.name=e.name||n.name,e.storeName=e.storeName||n.storeName);var r,s=this;if(e.name){var o=e.name===n.name&&s._dbInfo.db?u.resolve(s._dbInfo.db):y(e).then((function(t){var n=g[e.name],r=n.forages;n.db=t;for(var s=0;s<r.length;s++)r[s]._dbInfo.db=t;return t}));r=e.storeName?o.then((function(t){if(t.objectStoreNames.contains(e.storeName)){var n=t.version+1;I(e);var r=g[e.name],s=r.forages;t.close();for(var o=0;o<s.length;o++){var a=s[o];a._dbInfo.db=null,a._dbInfo.version=n}var c=new u((function(t,r){var s=i.open(e.name,n);s.onerror=function(e){s.result.close(),r(e)},s.onupgradeneeded=function(){s.result.deleteObjectStore(e.storeName)},s.onsuccess=function(){var e=s.result;e.close(),t(e)}}));return c.then((function(e){r.db=e;for(var t=0;t<s.length;t++){var n=s[t];n._dbInfo.db=e,R(n._dbInfo)}})).catch((function(t){throw(N(e,t)||u.resolve()).catch((function(){})),t}))}})):o.then((function(t){I(e);var n=g[e.name],r=n.forages;t.close();for(var s=0;s<r.length;s++)r[s]._dbInfo.db=null;var o=new u((function(t,n){var r=i.deleteDatabase(e.name);r.onerror=r.onblocked=function(e){var t=r.result;t&&t.close(),n(e)},r.onsuccess=function(){var e=r.result;e&&e.close(),t(e)}}));return o.then((function(e){n.db=e;for(var t=0;t<r.length;t++)R(r[t]._dbInfo)})).catch((function(t){throw(N(e,t)||u.resolve()).catch((function(){})),t}))}))}else r=u.reject("Invalid arguments");return l(r,t),r}var j={_driver:"asyncStorage",_initStorage:Y,_support:a(),iterate:F,getItem:x,setItem:B,removeItem:H,clear:K,length:k,key:V,keys:J,dropInstance:X};function q(){return"function"==typeof openDatabase}var W="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",Q="~~local_forage_type~",z=/^~~local_forage_type~([^~]+)~/,$="__lfsc__:",Z=$.length,ee="arbf",te="blob",ne="si08",re="ui08",se="uic8",oe="si16",ie="si32",ae="ur16",ce="ui32",ue="fl32",le="fl64",Ee=Z+ee.length,de=Object.prototype.toString;function he(e){var t,n,r,s,o,i=.75*e.length,a=e.length,c=0;"="===e[e.length-1]&&(i--,"="===e[e.length-2]&&i--);var u=new ArrayBuffer(i),l=new Uint8Array(u);for(t=0;t<a;t+=4)n=W.indexOf(e[t]),r=W.indexOf(e[t+1]),s=W.indexOf(e[t+2]),o=W.indexOf(e[t+3]),l[c++]=n<<2|r>>4,l[c++]=(15&r)<<4|s>>2,l[c++]=(3&s)<<6|63&o;return u}function pe(e){var t,n=new Uint8Array(e),r="";for(t=0;t<n.length;t+=3)r+=W[n[t]>>2],r+=W[(3&n[t])<<4|n[t+1]>>4],r+=W[(15&n[t+1])<<2|n[t+2]>>6],r+=W[63&n[t+2]];return n.length%3==2?r=r.substring(0,r.length-1)+"=":n.length%3==1&&(r=r.substring(0,r.length-2)+"=="),r}function Se(e,t){var n="";if(e&&(n=de.call(e)),e&&("[object ArrayBuffer]"===n||e.buffer&&"[object ArrayBuffer]"===de.call(e.buffer))){var r,s=$;e instanceof ArrayBuffer?(r=e,s+=ee):(r=e.buffer,"[object Int8Array]"===n?s+=ne:"[object Uint8Array]"===n?s+=re:"[object Uint8ClampedArray]"===n?s+=se:"[object Int16Array]"===n?s+=oe:"[object Uint16Array]"===n?s+=ae:"[object Int32Array]"===n?s+=ie:"[object Uint32Array]"===n?s+=ce:"[object Float32Array]"===n?s+=ue:"[object Float64Array]"===n?s+=le:t(new Error("Failed to get type for BinaryArray"))),t(s+pe(r))}else if("[object Blob]"===n){var o=new FileReader;o.onload=function(){var n=Q+e.type+"~"+pe(this.result);t($+te+n)},o.readAsArrayBuffer(e)}else try{t(JSON.stringify(e))}catch(e){t(null,e)}}function ge(e){if(e.substring(0,Z)!==$)return JSON.parse(e);var t,n=e.substring(Ee),r=e.substring(Z,Ee);if(r===te&&z.test(n)){var s=n.match(z);t=s[1],n=n.substring(s[0].length)}var o=he(n);switch(r){case ee:return o;case te:return c([o],{type:t});case ne:return new Int8Array(o);case re:return new Uint8Array(o);case se:return new Uint8ClampedArray(o);case oe:return new Int16Array(o);case ae:return new Uint16Array(o);case ie:return new Int32Array(o);case ce:return new Uint32Array(o);case ue:return new Float32Array(o);case le:return new Float64Array(o);default:throw new Error("Unkown type: "+r)}}var Ce={serialize:Se,deserialize:ge,stringToBuffer:he,bufferToString:pe};function _e(e,t,n,r){e.executeSql("CREATE TABLE IF NOT EXISTS "+t.storeName+" (id INTEGER PRIMARY KEY, key unique, value)",[],n,r)}function fe(e){var t=this,n={db:null};if(e)for(var r in e)n[r]="string"!=typeof e[r]?e[r].toString():e[r];var s=new u((function(e,r){try{n.db=openDatabase(n.name,String(n.version),n.description,n.size)}catch(e){return r(e)}n.db.transaction((function(s){_e(s,n,(function(){t._dbInfo=n,e()}),(function(e,t){r(t)}))}),r)}));return n.serializer=Ce,s}function Te(e,t,n,r,s,o){e.executeSql(n,r,s,(function(e,i){i.code===i.SYNTAX_ERR?e.executeSql("SELECT name FROM sqlite_master WHERE type='table' AND name = ?",[t.storeName],(function(e,a){a.rows.length?o(e,i):_e(e,t,(function(){e.executeSql(n,r,s,o)}),o)}),o):o(e,i)}),o)}function me(e,t){var n=this;e=d(e);var r=new u((function(t,r){n.ready().then((function(){var s=n._dbInfo;s.db.transaction((function(n){Te(n,s,"SELECT * FROM "+s.storeName+" WHERE key = ? LIMIT 1",[e],(function(e,n){var r=n.rows.length?n.rows.item(0).value:null;r&&(r=s.serializer.deserialize(r)),t(r)}),(function(e,t){r(t)}))}))})).catch(r)}));return l(r,t),r}function Ae(e,t){var n=this,r=new u((function(t,r){n.ready().then((function(){var s=n._dbInfo;s.db.transaction((function(n){Te(n,s,"SELECT * FROM "+s.storeName,[],(function(n,r){for(var o=r.rows,i=o.length,a=0;a<i;a++){var c=o.item(a),u=c.value;if(u&&(u=s.serializer.deserialize(u)),void 0!==(u=e(u,c.key,a+1)))return void t(u)}t()}),(function(e,t){r(t)}))}))})).catch(r)}));return l(r,t),r}function Ie(e,t,n,r){var s=this;e=d(e);var o=new u((function(o,i){s.ready().then((function(){void 0===t&&(t=null);var a=t,c=s._dbInfo;c.serializer.serialize(t,(function(t,u){u?i(u):c.db.transaction((function(n){Te(n,c,"INSERT OR REPLACE INTO "+c.storeName+" (key, value) VALUES (?, ?)",[e,t],(function(){o(a)}),(function(e,t){i(t)}))}),(function(t){if(t.code===t.QUOTA_ERR){if(r>0)return void o(Ie.apply(s,[e,a,n,r-1]));i(t)}}))}))})).catch(i)}));return l(o,n),o}function Re(e,t,n){return Ie.apply(this,[e,t,n,1])}function Ne(e,t){var n=this;e=d(e);var r=new u((function(t,r){n.ready().then((function(){var s=n._dbInfo;s.db.transaction((function(n){Te(n,s,"DELETE FROM "+s.storeName+" WHERE key = ?",[e],(function(){t()}),(function(e,t){r(t)}))}))})).catch(r)}));return l(r,t),r}function Oe(e){var t=this,n=new u((function(e,n){t.ready().then((function(){var r=t._dbInfo;r.db.transaction((function(t){Te(t,r,"DELETE FROM "+r.storeName,[],(function(){e()}),(function(e,t){n(t)}))}))})).catch(n)}));return l(n,e),n}function ye(e){var t=this,n=new u((function(e,n){t.ready().then((function(){var r=t._dbInfo;r.db.transaction((function(t){Te(t,r,"SELECT COUNT(key) as c FROM "+r.storeName,[],(function(t,n){var r=n.rows.item(0).c;e(r)}),(function(e,t){n(t)}))}))})).catch(n)}));return l(n,e),n}function Pe(e,t){var n=this,r=new u((function(t,r){n.ready().then((function(){var s=n._dbInfo;s.db.transaction((function(n){Te(n,s,"SELECT key FROM "+s.storeName+" WHERE id = ? LIMIT 1",[e+1],(function(e,n){var r=n.rows.length?n.rows.item(0).key:null;t(r)}),(function(e,t){r(t)}))}))})).catch(r)}));return l(r,t),r}function Me(e){var t=this,n=new u((function(e,n){t.ready().then((function(){var r=t._dbInfo;r.db.transaction((function(t){Te(t,r,"SELECT key FROM "+r.storeName,[],(function(t,n){for(var r=[],s=0;s<n.rows.length;s++)r.push(n.rows.item(s).key);e(r)}),(function(e,t){n(t)}))}))})).catch(n)}));return l(n,e),n}function ve(e){return new u((function(t,n){e.transaction((function(r){r.executeSql("SELECT name FROM sqlite_master WHERE type='table' AND name <> '__WebKitDatabaseInfoTable__'",[],(function(n,r){for(var s=[],o=0;o<r.rows.length;o++)s.push(r.rows.item(o).name);t({db:e,storeNames:s})}),(function(e,t){n(t)}))}),(function(e){n(e)}))}))}function Le(e,t){t=h.apply(this,arguments);var n=this.config();(e="function"!=typeof e&&e||{}).name||(e.name=e.name||n.name,e.storeName=e.storeName||n.storeName);var r,s=this;return l(r=e.name?new u((function(t){var r;r=e.name===n.name?s._dbInfo.db:openDatabase(e.name,"","",0),e.storeName?t({db:r,storeNames:[e.storeName]}):t(ve(r))})).then((function(e){return new u((function(t,n){e.db.transaction((function(r){function s(e){return new u((function(t,n){r.executeSql("DROP TABLE IF EXISTS "+e,[],(function(){t()}),(function(e,t){n(t)}))}))}for(var o=[],i=0,a=e.storeNames.length;i<a;i++)o.push(s(e.storeNames[i]));u.all(o).then((function(){t()})).catch((function(e){n(e)}))}),(function(e){n(e)}))}))})):u.reject("Invalid arguments"),t),r}var De={_driver:"webSQLStorage",_initStorage:fe,_support:q(),iterate:Ae,getItem:me,setItem:Re,removeItem:Ne,clear:Oe,length:ye,key:Pe,keys:Me,dropInstance:Le};function Ue(){try{return"undefined"!=typeof localStorage&&"setItem"in localStorage&&!!localStorage.setItem}catch(e){return!1}}function we(e,t){var n=e.name+"/";return e.storeName!==t.storeName&&(n+=e.storeName+"/"),n}function be(){var e="_localforage_support_test";try{return localStorage.setItem(e,!0),localStorage.removeItem(e),!1}catch(e){return!0}}function Ge(){return!be()||localStorage.length>0}function Ye(e){var t=this,n={};if(e)for(var r in e)n[r]=e[r];return n.keyPrefix=we(e,t._defaultConfig),Ge()?(t._dbInfo=n,n.serializer=Ce,u.resolve()):u.reject()}function xe(e){var t=this,n=t.ready().then((function(){for(var e=t._dbInfo.keyPrefix,n=localStorage.length-1;n>=0;n--){var r=localStorage.key(n);0===r.indexOf(e)&&localStorage.removeItem(r)}}));return l(n,e),n}function Fe(e,t){var n=this;e=d(e);var r=n.ready().then((function(){var t=n._dbInfo,r=localStorage.getItem(t.keyPrefix+e);return r&&(r=t.serializer.deserialize(r)),r}));return l(r,t),r}function Be(e,t){var n=this,r=n.ready().then((function(){for(var t=n._dbInfo,r=t.keyPrefix,s=r.length,o=localStorage.length,i=1,a=0;a<o;a++){var c=localStorage.key(a);if(0===c.indexOf(r)){var u=localStorage.getItem(c);if(u&&(u=t.serializer.deserialize(u)),void 0!==(u=e(u,c.substring(s),i++)))return u}}}));return l(r,t),r}function He(e,t){var n=this,r=n.ready().then((function(){var t,r=n._dbInfo;try{t=localStorage.key(e)}catch(e){t=null}return t&&(t=t.substring(r.keyPrefix.length)),t}));return l(r,t),r}function Ke(e){var t=this,n=t.ready().then((function(){for(var e=t._dbInfo,n=localStorage.length,r=[],s=0;s<n;s++){var o=localStorage.key(s);0===o.indexOf(e.keyPrefix)&&r.push(o.substring(e.keyPrefix.length))}return r}));return l(n,e),n}function ke(e){var t=this.keys().then((function(e){return e.length}));return l(t,e),t}function Ve(e,t){var n=this;e=d(e);var r=n.ready().then((function(){var t=n._dbInfo;localStorage.removeItem(t.keyPrefix+e)}));return l(r,t),r}function Je(e,t,n){var r=this;e=d(e);var s=r.ready().then((function(){void 0===t&&(t=null);var n=t;return new u((function(s,o){var i=r._dbInfo;i.serializer.serialize(t,(function(t,r){if(r)o(r);else try{localStorage.setItem(i.keyPrefix+e,t),s(n)}catch(e){"QuotaExceededError"!==e.name&&"NS_ERROR_DOM_QUOTA_REACHED"!==e.name||o(e),o(e)}}))}))}));return l(s,n),s}function Xe(e,t){if(t=h.apply(this,arguments),!(e="function"!=typeof e&&e||{}).name){var n=this.config();e.name=e.name||n.name,e.storeName=e.storeName||n.storeName}var r,s=this;return r=e.name?new u((function(t){e.storeName?t(we(e,s._defaultConfig)):t(e.name+"/")})).then((function(e){for(var t=localStorage.length-1;t>=0;t--){var n=localStorage.key(t);0===n.indexOf(e)&&localStorage.removeItem(n)}})):u.reject("Invalid arguments"),l(r,t),r}var je={_driver:"localStorageWrapper",_initStorage:Ye,_support:Ue(),iterate:Be,getItem:Fe,setItem:Je,removeItem:Ve,clear:xe,length:ke,key:He,keys:Ke,dropInstance:Xe},qe=function(e,t){return e===t||"number"==typeof e&&"number"==typeof t&&isNaN(e)&&isNaN(t)},We=function(e,t){for(var n=e.length,r=0;r<n;){if(qe(e[r],t))return!0;r++}return!1},Qe=Array.isArray||function(e){return"[object Array]"===Object.prototype.toString.call(e)},ze={},$e={},Ze={INDEXEDDB:j,WEBSQL:De,LOCALSTORAGE:je},et=[Ze.INDEXEDDB._driver,Ze.WEBSQL._driver,Ze.LOCALSTORAGE._driver],tt=["dropInstance"],nt=["clear","getItem","iterate","key","keys","length","removeItem","setItem"].concat(tt),rt={description:"",driver:et.slice(),name:"localforage",size:4980736,storeName:"keyvaluepairs",version:1};function st(e,t){e[t]=function(){var n=arguments;return e.ready().then((function(){return e[t].apply(e,n)}))}}function ot(){for(var e=1;e<arguments.length;e++){var t=arguments[e];if(t)for(var n in t)t.hasOwnProperty(n)&&(Qe(t[n])?arguments[0][n]=t[n].slice():arguments[0][n]=t[n])}return arguments[0]}var it=function(){function e(t){for(var n in s(this,e),Ze)if(Ze.hasOwnProperty(n)){var r=Ze[n],o=r._driver;this[n]=o,ze[o]||this.defineDriver(r)}this._defaultConfig=ot({},rt),this._config=ot({},this._defaultConfig,t),this._driverSet=null,this._initDriver=null,this._ready=!1,this._dbInfo=null,this._wrapLibraryMethodsWithReady(),this.setDriver(this._config.driver).catch((function(){}))}return e.prototype.config=function(e){if("object"===(void 0===e?"undefined":r(e))){if(this._ready)return new Error("Can't call config() after localforage has been used.");for(var t in e){if("storeName"===t&&(e[t]=e[t].replace(/\W/g,"_")),"version"===t&&"number"!=typeof e[t])return new Error("Database version must be a number.");this._config[t]=e[t]}return!("driver"in e)||!e.driver||this.setDriver(this._config.driver)}return"string"==typeof e?this._config[e]:this._config},e.prototype.defineDriver=function(e,t,n){var r=new u((function(t,n){try{var r=e._driver,s=new Error("Custom driver not compliant; see https://mozilla.github.io/localForage/#definedriver");if(!e._driver)return void n(s);for(var o=nt.concat("_initStorage"),i=0,a=o.length;i<a;i++){var c=o[i];if((!We(tt,c)||e[c])&&"function"!=typeof e[c])return void n(s)}var E=function(){for(var t=function(e){return function(){var t=new Error("Method "+e+" is not implemented by the current driver"),n=u.reject(t);return l(n,arguments[arguments.length-1]),n}},n=0,r=tt.length;n<r;n++){var s=tt[n];e[s]||(e[s]=t(s))}};E();var d=function(n){ze[r],ze[r]=e,$e[r]=n,t()};"_support"in e?e._support&&"function"==typeof e._support?e._support().then(d,n):d(!!e._support):d(!0)}catch(e){n(e)}}));return E(r,t,n),r},e.prototype.driver=function(){return this._driver||null},e.prototype.getDriver=function(e,t,n){var r=ze[e]?u.resolve(ze[e]):u.reject(new Error("Driver not found."));return E(r,t,n),r},e.prototype.getSerializer=function(e){var t=u.resolve(Ce);return E(t,e),t},e.prototype.ready=function(e){var t=this,n=t._driverSet.then((function(){return null===t._ready&&(t._ready=t._initDriver()),t._ready}));return E(n,e,e),n},e.prototype.setDriver=function(e,t,n){var r=this;Qe(e)||(e=[e]);var s=this._getSupportedDrivers(e);function o(){r._config.driver=r.driver()}function i(e){return r._extend(e),o(),r._ready=r._initStorage(r._config),r._ready}function a(e){return function(){var t=0;function n(){for(;t<e.length;){var s=e[t];return t++,r._dbInfo=null,r._ready=null,r.getDriver(s).then(i).catch(n)}o();var a=new Error("No available storage method found.");return r._driverSet=u.reject(a),r._driverSet}return n()}}var c=null!==this._driverSet?this._driverSet.catch((function(){return u.resolve()})):u.resolve();return this._driverSet=c.then((function(){var e=s[0];return r._dbInfo=null,r._ready=null,r.getDriver(e).then((function(e){r._driver=e._driver,o(),r._wrapLibraryMethodsWithReady(),r._initDriver=a(s)}))})).catch((function(){o();var e=new Error("No available storage method found.");return r._driverSet=u.reject(e),r._driverSet})),E(this._driverSet,t,n),this._driverSet},e.prototype.supports=function(e){return!!$e[e]},e.prototype._extend=function(e){ot(this,e)},e.prototype._getSupportedDrivers=function(e){for(var t=[],n=0,r=e.length;n<r;n++){var s=e[n];this.supports(s)&&t.push(s)}return t},e.prototype._wrapLibraryMethodsWithReady=function(){for(var e=0,t=nt.length;e<t;e++)st(this,nt[e])},e.prototype.createInstance=function(t){return new e(t)},e}(),at=new it;t.exports=at},{3:3}]},{},[4])(4)}).call(this,n(29))},function(e,t,n){"use strict";t.__esModule=!0,t.SERVER_ERRORS={AUTH_ERR:{code:"AUTH_ERR_AUTH_TOKEN_NOT_FOUND",message:"The auth token %s% does not exist. Please make sure you are logged in and have a valid auth token or try login again."}},t.ERRORS={PARAMETER_MISSING:{code:"MISSING_PARAMETERS",name:"Invalid or no parameter passed to the method."}},t.INIT_ERROR={NO_APP_ID:{code:t.ERRORS.PARAMETER_MISSING.code,name:t.ERRORS.PARAMETER_MISSING.name,message:"AppID cannot be empty. Please specify a valid appID.",details:{}}},t.GROUP_CREATION_ERRORS={EMPTY_PASSWORD:{code:"ERR_EMPTY_GROUP_PASS",details:void 0,message:"Password is mandatory to join a group.",name:void 0}},t.USERS_REQUEST_ERRORS={EMPTY_USERS_LIST:{code:"EMPTY_USERS_LIST",name:"EMPTY_USERS_LIST",message:"The users list needs to have atleast one UID.",details:{}}},t.MESSAGES_REQUEST_ERRORS={REQUEST_IN_PROGRESS_ERROR:{code:"REQUEST_IN_PROGRESS",name:"REQUEST_IN_PROGRESS",message:"Request in progress.",details:{}},NOT_ENOUGH_PARAMS:{code:"NOT_ENOUGH_PARAMETERS",name:"NOT_ENOUGH_PARAMETERS",message:"`Timestamp`, `MessageId` or `updatedAfter` is required to use the 'fetchNext()' method.",details:{}}},t.MESSAGE_ERRORS={INVALID_CUSTOM_DATA:{code:"-1",name:"%s_CUSTOM_DATA",message:"",details:{}}},t.LOGIN_ERROR={NOT_INITIALIZED:{code:"-1",name:"COMETCHAT_INITIALIZATION_NOT_DONE",message:"please initialize the cometchat before using login method.",details:{}},UNAUTHORISED:{code:401,name:"USER_NOT_AUTHORISED",message:"The `authToken` of the user is not authorised. Please verify again.",details:{}},XMPP_CONNECTION_FAIL:{code:-1,name:"WS_CONNECTION_FAIL",message:"WS Connection failed. %s",details:{}},XMPP_CONNECTION_FAIL_PORT_ERROR:{code:-1,name:"WS_CONNECTION_FAIL",message:"WS Connection failed. Trying to connect with port: %s",details:{}},XMPP_CONNECTION_FALLBACK_FAIL_PORT_ERROR:{code:-1,name:"WS_CONNECTION_FALLBACK_FAIL",message:"WS Connection fallback failed. Trying to connect with port: %s",details:{}},XMPP_AUTH_FAIL:{code:-1,name:"WS_AUTH_FAIL",message:"WS username/password not correct.",details:{}},NO_INTERNET:{code:-1,name:"NO_INTERNET_CONNECTION",message:"You do not have internet connection.",details:{}},REQUEST_IN_PROGRESS:{code:-1,name:"LOGIN_IN_PROGRESS",message:"Please wait until the previous login request ends.",details:{}}},t.TYPINGNOTIFICATION_CONSTANTS={TOO_MANY_REQUEST:{code:"TOO_MANY_REQUEST",name:"TOO MANY REQUEST",message:"too many request, wait for `%s` seconds before sending next request.",details:{}}},t.FETCH_ERROR={ERROR_IN_API_CALL:{code:"FAILED_TO_FETCH",name:"FAILED_TO_FETCH",message:"There is an unknown issue with the API request. Please check your internet connection and verify the api call.",details:{}}}},function(e,t,n){"use strict";var r,s=this&&this.__extends||(r=function(e,t){return r=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)t.hasOwnProperty(n)&&(e[n]=t[n])},r(e,t)},function(e,t){function n(){this.constructor=e}r(e,t),e.prototype=null===t?Object.create(t):(n.prototype=t.prototype,new n)}),o=this&&this.__awaiter||function(e,t,n,r){return new(n||(n=Promise))((function(s,o){function i(e){try{c(r.next(e))}catch(e){o(e)}}function a(e){try{c(r.throw(e))}catch(e){o(e)}}function c(e){e.done?s(e.value):new n((function(t){t(e.value)})).then(i,a)}c((r=r.apply(e,t||[])).next())}))},i=this&&this.__generator||function(e,t){var n,r,s,o,i={label:0,sent:function(){if(1&s[0])throw s[1];return s[1]},trys:[],ops:[]};return o={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(o[Symbol.iterator]=function(){return this}),o;function a(o){return function(a){return function(o){if(n)throw new TypeError("Generator is already executing.");for(;i;)try{if(n=1,r&&(s=2&o[0]?r.return:o[0]?r.throw||((s=r.return)&&s.call(r),0):r.next)&&!(s=s.call(r,o[1])).done)return s;switch(r=0,s&&(o=[2&o[0],s.value]),o[0]){case 0:case 1:s=o;break;case 4:return i.label++,{value:o[1],done:!1};case 5:i.label++,r=o[1],o=[0];continue;case 7:o=i.ops.pop(),i.trys.pop();continue;default:if(!(s=i.trys,(s=s.length>0&&s[s.length-1])||6!==o[0]&&2!==o[0])){i=0;continue}if(3===o[0]&&(!s||o[1]>s[0]&&o[1]<s[3])){i.label=o[1];break}if(6===o[0]&&i.label<s[1]){i.label=s[1],s=o;break}if(s&&i.label<s[2]){i.label=s[2],i.ops.push(o);break}s[2]&&i.ops.pop(),i.trys.pop();continue}o=t.call(e,i)}catch(e){o=[6,e],r=0}finally{n=s=0}if(5&o[0])throw o[1];return{value:o[0]?o[1]:void 0,done:!0}}([o,a])}}};t.__esModule=!0;var a=n(1),c=n(32),u=n(3),l=n(22),E=n(7),d=n(0),h=n(33),p=(n(47),n(48),n(49),n(24)),S=n(11),g=n(50),C=n(4),_=n(25),f=n(34),T=n(9),m=n(36),A=n(26),I=n(37),R=n(27),N=n(8),O=n(39),y=n(2);c.Strophe.addConnectionPlugin("pubsub",{_connection:null,init:function(e){this._connection=e,c.Strophe.addNamespace("PUBSUB","http://jabber.org/protocol/pubsub"),c.Strophe.addNamespace("PUBSUB_SUBSCRIBE_OPTIONS",c.Strophe.NS.PUBSUB+"#subscribe_options"),c.Strophe.addNamespace("PUBSUB_ERRORS",c.Strophe.NS.PUBSUB+"#errors"),c.Strophe.addNamespace("PUBSUB_EVENT",c.Strophe.NS.PUBSUB+"#event"),c.Strophe.addNamespace("PUBSUB_OWNER",c.Strophe.NS.PUBSUB+"#owner"),c.Strophe.addNamespace("PUBSUB_AUTO_CREATE",c.Strophe.NS.PUBSUB+"#auto-create"),c.Strophe.addNamespace("PUBSUB_PUBLISH_OPTIONS",c.Strophe.NS.PUBSUB+"#publish-options"),c.Strophe.addNamespace("PUBSUB_NODE_CONFIG",c.Strophe.NS.PUBSUB+"#node_config"),c.Strophe.addNamespace("PUBSUB_CREATE_AND_CONFIGURE",c.Strophe.NS.PUBSUB+"#create-and-configure"),c.Strophe.addNamespace("PUBSUB_SUBSCRIBE_AUTHORIZATION",c.Strophe.NS.PUBSUB+"#subscribe_authorization"),c.Strophe.addNamespace("PUBSUB_GET_PENDING",c.Strophe.NS.PUBSUB+"#get-pending"),c.Strophe.addNamespace("PUBSUB_MANAGE_SUBSCRIPTIONS",c.Strophe.NS.PUBSUB+"#manage-subscriptions"),c.Strophe.addNamespace("PUBSUB_META_DATA",c.Strophe.NS.PUBSUB+"#meta-data")},createNode:function(e,t,n,r,s){var o=this._connection.getUniqueId("pubsubcreatenode"),i=c.$iq({from:e,to:t,type:"set",id:o}),a=c.Strophe.xmlElement("configure",[]),u=c.Strophe.xmlElement("x",[["xmlns","jabber:x:data"]]),l=c.Strophe.xmlElement("field",[["var","FORM_TYPE"],["type","hidden"]]),E=c.Strophe.xmlElement("value",[]),d=c.Strophe.xmlTextNode(c.Strophe.NS.PUBSUB+"#node_config");for(var h in E.appendChild(d),l.appendChild(E),u.appendChild(l),r){var p=r[h];u.appendChild(p)}return r.length&&0!=r.length&&a.appendChild(u),i.c("pubsub",{xmlns:c.Strophe.NS.PUBSUB}).c("create",{node:n}).up().cnode(a),this._connection.addHandler(s,null,"iq",null,o,null),this._connection.send(i.tree()),o},subscribe:function(e,t,n,r,s,o){var i=this._connection.getUniqueId("subscribenode"),a=c.Strophe.xmlElement("options",[]),u=c.Strophe.xmlElement("x",[["xmlns","jabber:x:data"]]),l=c.Strophe.xmlElement("field",[["var","FORM_TYPE"],["type","hidden"]]),E=c.Strophe.xmlElement("value",[]),d=c.Strophe.xmlTextNode(c.Strophe.NS.PUBSUB_SUBSCRIBE_OPTIONS);E.appendChild(d),l.appendChild(E),u.appendChild(l);var h=c.$iq({from:e,to:t,type:"set",id:i});if(r&&r.length&&0!==r.length){for(var p=0;p<r.length;p++){var S=r[p];u.appendChild(S)}a.appendChild(u),h.c("pubsub",{xmlns:c.Strophe.NS.PUBSUB}).c("subscribe",{node:n,jid:e}).up().cnode(a)}else h.c("pubsub",{xmlns:c.Strophe.NS.PUBSUB}).c("subscribe",{node:n,jid:e});return this._connection.addHandler(o,null,"iq",null,i,null),this._connection.addHandler(s,null,"message",null,null,null),this._connection.send(h.tree()),i},unsubscribe:function(e,t,n,r){var s=this._connection.getUniqueId("unsubscribenode"),o=c.$iq({from:e,to:t,type:"set",id:s});return o.c("pubsub",{xmlns:c.Strophe.NS.PUBSUB}).c("unsubscribe",{node:n,jid:e}),this._connection.addHandler(r,null,"iq",null,s,null),this._connection.send(o.tree()),s},publish:function(e,t,n,r,s){var o=this._connection.getUniqueId("publishnode"),i=c.Strophe.xmlElement("publish",[["node",n],["jid",e]]);for(var a in r){var u=c.Strophe.xmlElement("item",[]),l=c.Strophe.xmlElement("entry",[]),E=c.Strophe.xmlTextNode(r[a]);l.appendChild(E),u.appendChild(l),i.appendChild(u)}var d=c.$iq({from:e,to:t,type:"set",id:o});return d.c("pubsub",{xmlns:c.Strophe.NS.PUBSUB}).cnode(i),this._connection.addHandler(s,null,"iq",null,o,null),this._connection.send(d.tree()),o},items:function(e,t,n,r,s){var o=c.$iq({from:e,to:t,type:"get"});return o.c("pubsub",{xmlns:c.Strophe.NS.PUBSUB}).c("items",{node:n}),this._connection.sendIQ(o.tree(),r,s)}});var P=function(){function e(){this.messageHandlers=[],this.XMPPConnectionHandlers=[],this.userHandlers=[],this.callHandlers=[],this.groupHandlers=[],this.loginHandlers=[],this.joinedGroups=[],this.iqHandlers=[]}return e.getInstance=function(){try{return null!=this.xMPPConnectionHelper&&null!=this.xMPPConnectionHelper||(this.xMPPConnectionHelper=new e),this.xMPPConnectionHelper}catch(e){a.Logger.error("Error in getInstance",e)}},e.prototype.XMPPConnect=function(t,n){var r=this,s="wss://",o="/ws/";return t&&(s="https://",o="/http-bind/"),new Promise((function(i,u){try{a.isFalsy(n)&&(n=t?e.XMPP_BIND_URL_HTTPS:e.XMPP_BIND_URL_WS),T.LocalStorage.getInstance().get(d.APP_SETTINGS.APP_SETTINGS).then((function(t){a.isFalsy(t)?a.getAppSettings().then((function(t){e.XMPP_BIND_URL=s+a.getChatHost(t)+":"+t[d.APP_SETTINGS.KEYS.CHAT_HTTPS_BIND_PORT]+o,r.connection=new c.Strophe.Connection(e.XMPP_BIND_URL),i(!0)})):(e.XMPP_BIND_URL=s+a.getChatHost(t)+":"+t[d.APP_SETTINGS.KEYS.CHAT_HTTPS_BIND_PORT]+o,r.connection=new c.Strophe.Connection(e.XMPP_BIND_URL),i(!0))}))}catch(e){u(new y.CometChatException(e))}}))},e.prototype.XMPPDisconnect=function(){try{this.connection?(this.connection.flush(),this.connection.disconnect(),clearInterval(this.pingInterval)):a.Logger.info("XMPPPHelper","No connection object found")}catch(e){a.Logger.error("XMPPHelper: XMPPDisconnect",e)}},e.prototype.XMMPLogin=function(e,t,n,r){var s=this;void 0===t&&(t=d.XMPP.deafult_password);try{this.XMPPConnect(n).then((function(n){s.connection.connected?r(c.Strophe.Status.CONNECTED):(clearInterval(s.pingInterval),T.LocalStorage.getInstance().get(d.APP_SETTINGS.APP_SETTINGS).then((function(n){a.isFalsy(n)?a.getAppSettings().then((function(n){s.perfomAfterConnection(e,t,r,a.getChatHost(n),a.getJidHost(n))})):s.perfomAfterConnection(e,t,r,a.getChatHost(n),a.getJidHost(n))})))}))}catch(e){a.Logger.error("XMPPHelper: XMPPLogin",e)}},e.prototype.getPresenceInfo=function(e,t){var n=this;try{var r="somename"+(new Date).getTime();this.addIqHandler(r,(function(e){t(e)})),a.getAppSettings().then((function(t){var r=a.getJidHost(t),s=c.$iq({from:n.connection.jid,id:"CC^COMETCHAT-PRESENCE",type:"get",to:r}).c("query",{xmlns:"jabber:iq:presencereq",action:"presence"}).t(JSON.stringify(e));n.connection.send(s)}),(function(t){a.Logger.error("XMPPHelper: getPresenceInfo",t);var r=c.$iq({from:n.connection.jid,id:"CC^COMETCHAT-PRESENCE",type:"get",to:d.XMPP.host}).c("query",{xmlns:"jabber:iq:presencereq",action:"presence"}).t(JSON.stringify(e));n.connection.send(r)}))}catch(e){a.Logger.error("XMPPHelper: getPresenceInfo",e)}},e.prototype.sendTypingStarted=function(e,t,n){var r=this;void 0===t&&(t=d.XMPP.CONVERSATION.TYPE.CHAT);try{e&&this.connection&&!u.CometChat.didMessagesPollingStart()&&u.CometChat.getConnectionStatus()==d.CONNECTION_STATUS.CONNECTED&&u.CometChat.getLoggedInUser().then((function(s){var o=new C.User(s);o.setAuthToken(""),r.connection.chatstates.sendComposing(e,t,o,n)}))}catch(e){a.Logger.error("XMPPHelper: sendTypingStarted",e)}},e.prototype.sendTypingPaused=function(e,t,n){var r=this;void 0===t&&(t=d.XMPP.CONVERSATION.TYPE.CHAT);try{e&&this.connection&&!u.CometChat.didMessagesPollingStart()&&u.CometChat.getConnectionStatus()==d.CONNECTION_STATUS.CONNECTED&&u.CometChat.getLoggedInUser().then((function(s){var o=new C.User(s);o.setAuthToken(""),r.connection.chatstates.sendPaused(e,t,o,n)}))}catch(e){a.Logger.error("XMPPHelper: sendTypingPaused",e)}},e.prototype.addMessageEventListener=function(e,t){try{this.messageHandlers=this.messageHandlers.filter((function(t){return t._name!=e})),this.messageHandlers=this.messageHandlers.concat([new l.MessageListener(e,t)])}catch(e){a.Logger.error("XMPPHelper: addMessageEventListener",e)}},e.prototype.removeMessageEventListener=function(e){try{this.messageHandlers=this.messageHandlers.filter((function(t){return t._name!==e}))}catch(e){a.Logger.error("XMPPHelper: removeMessageEventListener",e)}},e.prototype.addXMPPConnectionEventListener=function(e,t){try{this.XMPPConnectionHandlers=this.XMPPConnectionHandlers.filter((function(t){return t._name!=e})),this.XMPPConnectionHandlers=this.XMPPConnectionHandlers.concat([new L(e,t)])}catch(e){a.Logger.error("XMPPHelper: addXMPPConnectionEventListener",e)}},e.prototype.removeXMPPConnectionEventListener=function(e){try{this.XMPPConnectionHandlers=this.XMPPConnectionHandlers.filter((function(t){return t._name!==e}))}catch(e){a.Logger.error("XMPPHelper: removeXMPPConnectionEventListener",e)}},e.prototype.addCallEventListener=function(e,t){try{this.callHandlers=this.callHandlers.filter((function(t){return t._name!=e})),this.callHandlers=this.callHandlers.concat([new l.CallListener(e,t)])}catch(e){a.Logger.error("XMPPHelper: addCallEventListener",e)}},e.prototype.removeCallEventListener=function(e){try{this.callHandlers=this.callHandlers.filter((function(t){return t._name!==e}))}catch(e){a.Logger.error("XMPPHelper: removeCallEventListener",e)}},e.prototype.addUserEventListener=function(e,t){try{this.userHandlers=this.userHandlers.filter((function(t){return t._name!=e})),this.userHandlers=this.userHandlers.concat([new l.UserListener(e,t)])}catch(e){a.Logger.error("XMPPHelper: addUserEventListener",e)}},e.prototype.removeUserEventListener=function(e){try{this.userHandlers=this.userHandlers.filter((function(t){return t._name!==e}))}catch(e){a.Logger.error("XMPPHelper: removeUserEventListener",e)}},e.prototype.addGroupEventListener=function(e,t){try{this.groupHandlers=this.groupHandlers.filter((function(t){return t._name!=e})),this.groupHandlers=this.groupHandlers.concat([new l.GroupListener(e,t)])}catch(e){a.Logger.error("XMPPHelper: addGroupEventListener",e)}},e.prototype.removeGroupEventListener=function(e){try{this.groupHandlers=this.groupHandlers.filter((function(t){return t._name!==e}))}catch(e){a.Logger.error("XMPPHelper: removeGroupEventListener",e)}},e.prototype.addLoginEventListener=function(e,t){try{this.loginHandlers=this.loginHandlers.filter((function(t){return t._name!=e})),this.loginHandlers=this.loginHandlers.concat([new l.LoginListener(e,t)])}catch(e){a.Logger.error("XMPPHelper: addLoginEventListener",e)}},e.prototype.removeLoginEventListener=function(e){try{this.loginHandlers=this.loginHandlers.filter((function(t){return t._name!==e}))}catch(e){a.Logger.error("XMPPHelper: removeLoginEventListener",e)}},e.prototype.addIqHandler=function(e,t){try{this.iqHandlers=this.iqHandlers.concat([new l.Listener(e,t)])}catch(e){a.Logger.error("XMPPHelper: addIqHandler",e)}},e.prototype.removeIqHandler=function(e){try{this.iqHandlers=this.iqHandlers.filter((function(t){return t._name!==e}))}catch(e){a.Logger.error("XMPPHelper: removeIqHandler",e)}},e.prototype.joinMuc=function(e){var t=this;try{!u.CometChat.didMessagesPollingStart()&&u.CometChat.getConnectionStatus()==d.CONNECTION_STATUS.CONNECTED&&this.connection&&a.getAppSettings().then((function(n){t.connection.muc.join(a.format(d.XMPP.muc_jid_string,u.CometChat.getAppId(),e.getGuid(),u.CometChat.getAppId(),a.getJidHost(n)),t.connection.jid,null,null,null,null,0)}))}catch(e){a.Logger.error("XMPPHelper: joinMuc",e)}},e.prototype.leaveMuc=function(e){var t=this;try{!u.CometChat.didMessagesPollingStart()&&u.CometChat.getConnectionStatus()==d.CONNECTION_STATUS.CONNECTED&&this.connection&&a.getAppSettings().then((function(n){t.connection.muc.leave(a.format(d.XMPP.muc_jid_string,u.CometChat.getAppId(),e,u.CometChat.getAppId(),a.getJidHost(n)),t.connection.jid)}))}catch(e){a.Logger.error("XMPPHelper: leaveMuc",e)}},e.prototype.getUsersVCard=function(e,t){var n=this;try{S.getJidFromUid(e).then((function(e){u.CometChat.getConnectionStatus()===d.CONNECTION_STATUS.CONNECTED&&n.connection.vcard.get((function(e){t(g.VCardController.transformVCard(e))}),e)}))}catch(e){a.Logger.error("XMPPHelper: getUsersVCard",e)}},e.prototype.trigerMessageHandler=function(e,t){if(a.isFalsy(t))e=E.MessageController.trasformJSONMessge(e),this.messageHandlers.map((function(t){try{if(t._eventListener)if(e instanceof p.Action);else if(e instanceof _.Call);else{var n=e;switch(n.getType()){case d.MessageConstatnts.TYPE.TEXT:a.isFalsy(t._eventListener.onTextMessageReceived)||t._eventListener.onTextMessageReceived(e);break;case d.MessageConstatnts.TYPE.CUSTOM:a.isFalsy(t._eventListener.onCustomMessageReceived)||t._eventListener.onCustomMessageReceived(e);break;default:n.getCategory()==d.MessageCategory.CUSTOM?a.isFalsy(t._eventListener.onCustomMessageReceived)||t._eventListener.onCustomMessageReceived(e):a.isFalsy(t._eventListener.onMediaMessageReceived)||t._eventListener.onMediaMessageReceived(e)}}}catch(e){a.Logger.error("XMPPHelper: trigerMessageHandler",e)}})),e instanceof _.Call&&this.publishCallEvents(e),e instanceof p.Action&&this.publishActionEvents(e);else if(e=E.MessageController.trasformJSONMessge(e),this.messageHandlers[t]._eventListener)try{if(this.messageHandlers[t]._eventListener)if(e instanceof p.Action);else if(e instanceof _.Call);else{var n=e;switch(n.getType()){case d.MessageConstatnts.TYPE.TEXT:a.isFalsy(this.messageHandlers[t]._eventListener.onTextMessageReceived)||this.messageHandlers[t]._eventListener.onTextMessageReceived(e);break;case d.MessageConstatnts.TYPE.CUSTOM:a.isFalsy(this.messageHandlers[t]._eventListener.onCustomMessageReceived)||this.messageHandlers[t]._eventListener.onCustomMessageReceived(e);break;default:n.getCategory()==d.MessageCategory.CUSTOM?a.isFalsy(this.messageHandlers[t]._eventListener.onCustomMessageReceived)||this.messageHandlers[t]._eventListener.onCustomMessageReceived(e):a.isFalsy(this.messageHandlers[t]._eventListener.onMediaMessageReceived)||this.messageHandlers[t]._eventListener.onMediaMessageReceived(e)}}}catch(e){a.Logger.error("XMPPHelper: trigerMessageHandler",e)}},e.prototype.publishActionEvents=function(e){var t=this;try{switch(e.getAction()){case d.ActionConstatnts.ACTION_TYPE.TYPE_MEMBER_JOINED:case d.ActionConstatnts.ACTION_TYPE.TYPE_MEMBER_INVITED:this.groupHandlers.map((function(t){a.isFalsy(t._eventListener.onUserJoined)||t._eventListener.onUserJoined(e,e.getActionBy(),e.getActionFor())}));break;case d.ActionConstatnts.ACTION_TYPE.TYPE_MEMBER_LEFT:this.groupHandlers.map((function(t){a.isFalsy(t._eventListener.onUserLeft)||t._eventListener.onUserLeft(e,e.getActionBy(),e.getActionFor())}));break;case d.ActionConstatnts.ACTION_TYPE.TYPE_MEMBER_BANNED:this.groupHandlers.map((function(t){a.isFalsy(t._eventListener.onUserBanned)||t._eventListener.onUserBanned(e,e.getActionOn(),e.getActionBy(),e.getActionFor())}));break;case d.ActionConstatnts.ACTION_TYPE.TYPE_MEMBER_KICKED:this.groupHandlers.map((function(t){a.isFalsy(t._eventListener.onUserKicked)||t._eventListener.onUserKicked(e,e.getActionOn(),e.getActionBy(),e.getActionFor())}));break;case d.ActionConstatnts.ACTION_TYPE.TYPE_MEMBER_UNBANNED:this.groupHandlers.map((function(t){a.isFalsy(t._eventListener.onUserUnbanned)||t._eventListener.onUserUnbanned(e,e.getActionOn(),e.getActionBy(),e.getActionFor())}));break;case d.ActionConstatnts.ACTION_TYPE.TYPE_MEMBER_SCOPE_CHANGED:this.groupHandlers.map((function(t){a.isFalsy(t._eventListener.onMemberScopeChanged)||t._eventListener.onMemberScopeChanged(e,e.getActionOn(),e.getNewScope(),e.getOldScope(),e.getActionFor())}));break;case d.ActionConstatnts.ACTION_TYPE.TYPE_MESSAGE_EDITED:this.messageHandlers.map((function(t){a.isFalsy(t._eventListener.onMessageEdited)||t._eventListener.onMessageEdited(e.getActionOn())}));break;case d.ActionConstatnts.ACTION_TYPE.TYPE_MESSAGE_DELETED:this.messageHandlers.map((function(t){a.isFalsy(t._eventListener.onMessageDeleted)||t._eventListener.onMessageDeleted(e.getActionOn())}));break;case d.ActionConstatnts.ACTION_TYPE.TYPE_MEMBER_ADDED:var n=e.getActionOn();S.getJidFromUid(n.getUid()).then((function(n){n==c.Strophe.getBareJidFromJid(t.connection.jid)&&(t.joinMuc(e.getActionFor()),t.markAsDelivered(e.getActionFor().guid,"group",e.getId()))})),this.groupHandlers.map((function(n){var r=e.getActionOn();S.getJidFromUid(r.getUid()).then((function(r){r==c.Strophe.getBareJidFromJid(t.connection.jid)&&t.joinMuc(e.getActionFor()),a.isFalsy(n._eventListener.onMemberAddedToGroup)||n._eventListener.onMemberAddedToGroup(e,e.getActionOn(),e.getActionBy(),e.getActionFor())}))}))}}catch(e){a.Logger.error("XMPPHelper: publishActionEvents",e)}},e.prototype.publishCallEvents=function(e){try{var t=f.CallController.getInstance().getActiveCall();switch(e.getStatus()){case d.CallConstants.CALL_STATUS.INITIATED:e.getReceiverType()==d.CallConstants.RECEIVER_TYPE_GROUP?this.callHandlers.map((function(t){e.getCallInitiator().getUid().toLocaleLowerCase()!=u.CometChat.user.getUid().toLocaleLowerCase()&&(a.isFalsy(t._eventListener.onIncomingCallReceived)||t._eventListener.onIncomingCallReceived(e))})):this.callHandlers.map((function(t){a.isFalsy(t._eventListener.onIncomingCallReceived)||t._eventListener.onIncomingCallReceived(e)}));break;case d.CallConstants.CALL_STATUS.ONGOING:e.getReceiverType()==d.CallConstants.RECEIVER_TYPE_GROUP?e.getCallInitiator().getUid().toLocaleLowerCase()==u.CometChat.user.getUid().toLocaleLowerCase()&&this.callHandlers.map((function(t){a.isFalsy(t._eventListener.onOutgoingCallAccepted)||t._eventListener.onOutgoingCallAccepted(e)})):this.callHandlers.map((function(t){a.isFalsy(t._eventListener.onOutgoingCallAccepted)||t._eventListener.onOutgoingCallAccepted(e)}));break;case d.CallConstants.CALL_STATUS.UNANSWERED:if(e.getCallInitiator().getUid().toLocaleLowerCase()==u.CometChat.user.getUid().toLocaleLowerCase())this.callHandlers.map((function(t){a.isFalsy(t._eventListener.onOutgoingCallRejected)||t._eventListener.onOutgoingCallRejected(e)}));else{if(null!==t&&t.getSessionId()===e.getSessionId())try{f.CallController.getInstance().endCall()}catch(e){a.Logger.error("CallError",e)}this.callHandlers.map((function(t){a.isFalsy(t._eventListener.onIncomingCallCancelled)||t._eventListener.onIncomingCallCancelled(e)}))}break;case d.CallConstants.CALL_STATUS.REJECTED:if(e.getReceiverType()==d.CallConstants.RECEIVER_TYPE_GROUP)e.getCallInitiator().getUid().toLocaleLowerCase()==u.CometChat.user.getUid().toLocaleLowerCase()&&this.callHandlers.map((function(t){a.isFalsy(t._eventListener.onOutgoingCallRejected)||t._eventListener.onOutgoingCallRejected(e)}));else{if(null!==t&&t.getSessionId()===e.getSessionId())try{f.CallController.getInstance().endCall()}catch(e){a.Logger.error("CallError",e)}this.callHandlers.map((function(t){a.isFalsy(t._eventListener.onOutgoingCallRejected)||t._eventListener.onOutgoingCallRejected(e)}))}break;case d.CallConstants.CALL_STATUS.BUSY:e.getReceiverType()==d.CallConstants.RECEIVER_TYPE_GROUP?e.getCallInitiator().getUid().toLocaleLowerCase()==u.CometChat.user.getUid().toLocaleLowerCase()&&this.callHandlers.map((function(t){a.isFalsy(t._eventListener.onOutgoingCallRejected)||t._eventListener.onOutgoingCallRejected(e)})):this.callHandlers.map((function(n){if(null!==t&&t.getSessionId()===e.getSessionId())try{f.CallController.getInstance().endCall()}catch(e){a.Logger.error("CallError",e)}a.isFalsy(n._eventListener.onOutgoingCallRejected)||n._eventListener.onOutgoingCallRejected(e)}));break;case d.CallConstants.CALL_STATUS.CANCELLED:if(this.callHandlers.map((function(t){a.isFalsy(t._eventListener.onIncomingCallCancelled)||t._eventListener.onIncomingCallCancelled(e)})),null!==t&&t.getSessionId()===e.getSessionId())try{f.CallController.getInstance().endCall()}catch(e){a.Logger.error("CallError",e)}break;case d.CallConstants.CALL_STATUS.ENDED:if(f.CallController.getInstance().getCallListner()&&f.CallController.getInstance().getCallListner()._eventListener.onCallEnded(e),null!==t&&t.getSessionId()===e.getSessionId())try{f.CallController.getInstance().endCall()}catch(e){a.Logger.error("CallError",e)}}}catch(e){a.Logger.error("XMPPHelper: publishCallEvents",e)}},e.prototype.publishTypinStatusNotification=function(e,t){try{switch(t){case d.TYPING_NOTIFICATION.ACTIONS.STARTED:this.messageHandlers.map((function(t){t._eventListener.onTypingStarted&&t._eventListener.onTypingStarted(e)})),I.TypingNotificationController.addIncomingTypingStarted(e);break;case d.TYPING_NOTIFICATION.ACTIONS.ENDED:this.messageHandlers.map((function(t){t._eventListener.onTypingEnded&&t._eventListener.onTypingEnded(e)})),I.TypingNotificationController.removeIncomingTypingStarted(e)}}catch(e){a.Logger.error("XMPPHelper: publishTypingStatusNotification",e)}},e.prototype.publishDeliveryReceipt=function(e){var t=this;try{e.getElementsByTagName("forwarded")[0]&&(e=e.getElementsByTagName("message")[0]),E.MessageController.processDeliveryReceipt(e).then((function(e){t.messageHandlers.map((function(t){t._eventListener.onMessagesDelivered&&t._eventListener.onMessagesDelivered(e)}))}),(function(e){a.Logger.error("Error in publish delivery",e)}))}catch(e){a.Logger.error("XMPPHelper: publishDeliveryReceipt",e)}},e.prototype.publishReadReceipt=function(e){var t=this;try{e.getElementsByTagName("forwarded")[0]&&(e=e.getElementsByTagName("message")[0]),E.MessageController.processReadReceipt(e).then((function(e){t.messageHandlers.map((function(t){t._eventListener.onMessagesRead&&t._eventListener.onMessagesRead(e)}))}),(function(e){a.Logger.error("Error in publish read",e)}))}catch(e){a.Logger.error("XMPPHelper: publishReadReceipt",e)}},e.prototype.markAsRead=function(e,t,n){var r=this;try{var s=u.CometChat.getMode();!u.CometChat.didMessagesPollingStart()&&u.CometChat.getConnectionStatus()==d.CONNECTION_STATUS.CONNECTED&&this.connection&&(a.isFalsy(s)||s&&s===d.APP_SETTINGS.KEYS.DEFAULT_MODE)&&u.CometChat.getLoggedInUser().then((function(s){var o=new C.User(s);o.setAuthToken("");var i=JSON.stringify(o);t==d.MessageConstatnts.RECEIVER_TYPE.USER?S.getJidFromUid(e).then((function(s){var o=c.$msg({to:s,from:r.connection.jid,id:r.connection.getUniqueId(),type:d.MessageConstatnts.XMPP_KEYS.TYPE_USER}).c("user",{xmlns:"com.cometchat.models:User"}).t(i).up(),a=c.Strophe.xmlElement("read",{type:t,receiverId:e,xmlns:"urn:xmpp:receipts",id:"["+u.CometChat.getAppId()+"]"+n});o.tree().appendChild(a),r.connection.send(o)})):S.getGroupJidFromGUID(e).then((function(s){var o=c.$msg({to:s,from:r.connection.jid,id:r.connection.getUniqueId(),type:d.MessageConstatnts.XMPP_KEYS.TYPE_GROUP}).c("user",{xmlns:"com.cometchat.models:User"}).t(i).up(),a=c.Strophe.xmlElement("read",{type:t,receiverId:e,xmlns:c.Strophe.NS.RECEIPTS,id:"["+u.CometChat.getAppId()+"]"+n});o.tree().appendChild(a),r.connection.send(o)}))}))}catch(e){a.Logger.error("XMPPHelper: markAsRead",e)}},e.prototype.markAsDelivered=function(e,t,n){var r=this;try{var s=u.CometChat.getMode();!u.CometChat.didMessagesPollingStart()&&u.CometChat.getConnectionStatus()==d.CONNECTION_STATUS.CONNECTED&&this.connection&&(a.isFalsy(s)||s&&s===d.APP_SETTINGS.KEYS.DEFAULT_MODE)&&u.CometChat.getLoggedInUser().then((function(s){var o=new C.User(s);o.setAuthToken("");var i=JSON.stringify(o);t==d.MessageConstatnts.RECEIVER_TYPE.USER?S.getJidFromUid(e).then((function(s){var o=c.$msg({to:s,from:r.connection.jid,id:r.connection.getUniqueId(),type:d.MessageConstatnts.XMPP_KEYS.TYPE_USER}).c("user",{xmlns:"com.cometchat.models:User"}).t(i).up(),a=c.Strophe.xmlElement("delivered",{type:t,receiverId:e,xmlns:"urn:xmpp:receipts",id:"["+u.CometChat.getAppId()+"]"+n});o.tree().appendChild(a),r.connection.send(o)})):S.getGroupJidFromGUID(e).then((function(s){var o=c.$msg({to:s,from:r.connection.jid,id:r.connection.getUniqueId(),type:d.MessageConstatnts.XMPP_KEYS.TYPE_GROUP}).c("user",{xmlns:"com.cometchat.models:User"}).t(i).up(),a=c.Strophe.xmlElement("delivered",{type:t,receiverId:e,xmlns:c.Strophe.NS.RECEIPTS,id:"["+u.CometChat.getAppId()+"]"+n});o.tree().appendChild(a),r.connection.send(o)}))}))}catch(e){a.Logger.error("XMPPHelper: markAsDelivered",e)}},e.prototype.subscribeToTopic=function(e){var t=this;try{T.LocalStorage.getInstance().get(d.APP_SETTINGS.APP_SETTINGS).then((function(n){a.isFalsy(n)?a.getAppSettings().then((function(n){t.connection.pubsub.subscribe(t.connection.jid,d.XMPP.PUBSUB_CHANNEL+"."+a.getJidHost(n),e,{},(function(){a.Logger.info("XMPPHelper: subscribeToTopic","onEvent")}),(function(){a.Logger.info("XMPPHelper: subscribeToTopic","onsubscribe")}))})):t.connection.pubsub.subscribe(t.connection.jid,d.XMPP.PUBSUB_CHANNEL+"."+a.getJidHost(n),e,{},(function(){a.Logger.info("XMPPHelper: subscribeToTopic","onEvent")}),(function(){a.Logger.info("XMPPHelper: subscribeToTopic","onsubscribe")}))}))}catch(e){a.Logger.error("XMPPHelper: subscribeToTopic",e)}},e.prototype.getRooms=function(){var e=this;return new Promise((function(t,n){try{u.CometChat.didMessagesPollingStart()||u.CometChat.getConnectionStatus()!=d.CONNECTION_STATUS.CONNECTED?a.Logger.info("getRooms()","No rooms found since WS is not connected"):void 0!==e.connection?T.LocalStorage.getInstance().get(d.APP_SETTINGS.APP_SETTINGS).then((function(n){a.isFalsy(n)?a.getAppSettings().then((function(n){e.connection.muc.listRooms(u.CometChat.getAppId()+"."+a.getJidHost(n),(function(n){var r=n.getElementsByTagName("item");r=Array.prototype.slice.call(r),e.joinedGroups=[],r.map((function(t){e.joinedGroups.push(S.getUidFromJid(t.getAttribute("jid")))})),t(e.joinedGroups)}))})):e.connection.muc.listRooms(u.CometChat.getAppId()+"."+a.getJidHost(n),(function(n){var r=n.getElementsByTagName("item");r=Array.prototype.slice.call(r),e.joinedGroups=[],r.map((function(t){e.joinedGroups.push(S.getUidFromJid(t.getAttribute("jid")))})),t(e.joinedGroups)}))}),(function(e){n(new y.CometChatException(e))})):e.addXMPPConnectionEventListener("XMPPConnectionListener",new M({onConnected:function(){e.getRooms().then((function(n){t(n),e.removeXMPPConnectionEventListener("XMPPConnectionListener")}))}}))}catch(e){n(new y.CometChatException(e))}}))},e.prototype.restart=function(){return o(this,void 0,void 0,(function(){var e,t;return i(this,(function(n){switch(n.label){case 0:return e=u.CometChat.getInstance(u.CometChat.getAppId()),t=e.getAuthToken(),[4,u.CometChat.logout()];case 1:return n.sent(),[4,u.CometChat.login(t)];case 2:return n.sent(),[2]}}))}))},e.prototype.pushToTypingListeners=function(e,t,n,r,s){n.setSender(e),t&&n.setMetadata(JSON.parse(t)),r.length>0&&I.TypingNotificationController.addIncomingTypingStarted(n),s.length>0&&I.TypingNotificationController.removeIncomingTypingStarted(n),this.messageHandlers.map((function(e){r.length>0&&e._eventListener.onTypingStarted&&e._eventListener.onTypingStarted(n),s.length>0&&e._eventListener.onTypingEnded&&e._eventListener.onTypingEnded(n)}))},e.prototype.perfomAfterConnection=function(t,n,r,s,l){var g=this;this.connection.connect(a.format(d.XMPP.jid_string,u.CometChat.getAppId(),t,s,u.CometChat.getSessionId()),n,(function(t,n){try{if(a.isFalsy(r)||r(t,n),t==c.Strophe.Status.CONNECTED){switch(u.CometChat.setSuccessfulTimeStamp((new Date).getTime()),g.connection.sendPresence(c.$pres().c("priority").t("1").up().c("status").t("online")),g.connection.muc.init(g.connection),g.connection.vcard.init(g.connection),g.connection.chatstates.init(g.connection),g.connection.receipts.init(g.connection),g.connection.pubsub.init(g.connection),g.pingInterval=setInterval((function(){g.connection&&g.connection._proto&&g.connection._proto.socket&&g.connection.ping.ping(l,(function(){return o(g,void 0,void 0,(function(){return i(this,(function(e){return a.Logger.info("ping result","successful"),u.CometChat.setSuccessfulTimeStamp((new Date).getTime()),u.CometChat.getConnectionStatus()!=d.CONNECTION_STATUS.CONNECTED&&(this.XMPPDisconnect(),u.CometChat.getInstance().makeXMPPConnection()),[2]}))}))}),(function(){a.Logger.info("ping result","unsuccessful"),u.CometChat.getInstance().setConnectionStatus(d.CONNECTION_STATUS.DISCONNECTED),g.XMPPConnectionHandlers.map((function(e){try{e._XMPPeventListener&&(a.isFalsy(e._XMPPeventListener.onDisconnected)||e._XMPPeventListener.onDisconnected())}catch(e){a.Logger.error("XMPPConnectionHandlers: Disconnected Status",e)}})),g.XMPPDisconnect(),u.CometChat.getInstance().accidentallyDisconnected()}),2e3)}),25e3),u.CometChat.appSettings.getIsAutoJoinEnabled()&&T.LocalStorage.getInstance().get(d.APP_SETTINGS.APP_SETTINGS).then((function(e){a.isFalsy(e)?a.getAppSettings().then((function(e){g.connection.muc.listRooms(u.CometChat.getAppId()+"."+a.getJidHost(e),(function(e){var t=e.getElementsByTagName("item");(t=Array.prototype.slice.call(t)).map((function(e){g.connection.muc.join(e.getAttribute("jid"),g.connection.jid)}))}))})):g.connection.muc.listRooms(u.CometChat.getAppId()+"."+a.getJidHost(e),(function(e){var t=e.getElementsByTagName("item");(t=Array.prototype.slice.call(t)).map((function(e){g.connection.muc.join(e.getAttribute("jid"),g.connection.jid,null,null,null,null,0,null)}))}))})),u.CometChat.appSettings.getSubscriptionType()){case O.AppSettings.SUBSCRIPTION_TYPE_ALL_USERS:g.subscribeToTopic(a.format(d.XMPP.pubsub_global_string,u.CometChat.getAppId()));break;case O.AppSettings.SUBSCRIPTION_TYPE_FRIENDS:case O.AppSettings.SUBSCRIPTION_TYPE_NONE:break;case O.AppSettings.SUBSCRIPTION_TYPE_ROLES:u.CometChat.appSettings.getRoles().map((function(e){g.subscribeToTopic(a.format(d.XMPP.pubsub_role_string,u.CometChat.getAppId(),e))}))}g.connection.send(c.$iq({from:c.Strophe.getBareJidFromJid(g.connection.jid),id:"enable1",type:"set"}).c("enable",{xmlns:"urn:xmpp:carbons:2"})),g.connection.addHandler((function(e){if(!(e.getElementsByTagName("x").length>0)){var t=h.PresenceController.transformPresence(e);g.getUsersVCard(t.getUid(),(function(e){a.isFalsy(e.getUid())||u.CometChat.appSettings.getSubscriptionType()==O.AppSettings.SUBSCRIPTION_TYPE_FRIENDS&&g.userHandlers.map((function(n){if(n)if(e.setLastActiveAt(t.getLastActiveAt()),t.getStatus()===d.PresenceConstatnts.STATUS.ONLINE)e.setStatus(d.PresenceConstatnts.STATUS.ONLINE),a.isFalsy(n._eventListener.onUserOnline)||n._eventListener.onUserOnline(e);else e.setStatus(d.PresenceConstatnts.STATUS.OFFLINE),a.isFalsy(n._eventListener.onUserOffline)||n._eventListener.onUserOffline(e)}))}))}return!0}),null,"presence"),g.connection.addHandler((function(e){e.getElementsByTagName("muc_join").length>0&&g.connection.muc.join(e.getAttribute(d.MessageConstatnts.XMPP_KEYS.FROM),g.connection.jid,null,null,null,null,0);var t=e.getElementsByTagName("presence");return(t=Array.prototype.slice.call(t)).length>0&&g.iqHandlers.map((function(e){e._callback(h.PresenceController.transformPresences(t))})),!0}),null,"iq"),g.connection.addHandler((function(e){return e.getElementsByTagName("settings").length>0&&g.restart(),!0}),null,"iq"),T.LocalStorage.getInstance().get(d.APP_SETTINGS.APP_SETTINGS).then((function(e){a.isFalsy(e)?a.getAppSettings().then((function(e){g.connection.addHandler((function(e){var t=JSON.parse(S.parseHTML(e.getElementsByTagName("body")[0]).trim().toString()),n=N.UsersController.trasformJSONUser(t);return g.userHandlers.map((function(e){if(e)if(n.getStatus()===d.PresenceConstatnts.STATUS.OFFLINE)a.isFalsy(e._eventListener.onUserOffline)||e._eventListener.onUserOffline(n);else a.isFalsy(e._eventListener.onUserOnline)||e._eventListener.onUserOnline(n)})),!0}),null,"message",null,null,d.XMPP.PUBSUB_CHANNEL+"."+a.getJidHost(e),null)})):g.connection.addHandler((function(e){var t=JSON.parse(S.parseHTML(e.getElementsByTagName("body")[0]).trim().toString()),n=N.UsersController.trasformJSONUser(t);return g.userHandlers.map((function(e){if(e)if(n.getStatus()===d.PresenceConstatnts.STATUS.OFFLINE)a.isFalsy(e._eventListener.onUserOffline)||e._eventListener.onUserOffline(n);else a.isFalsy(e._eventListener.onUserOnline)||e._eventListener.onUserOnline(n)})),!0}),null,"message",null,null,d.XMPP.PUBSUB_CHANNEL+"."+a.getJidHost(e),null)})),g.connection.addHandler((function(t){var n;try{if(u.CometChat.getConnectionStatus()==d.CONNECTION_STATUS.CONNECTED){try{if(n=E.MessageController.trasformXMPPMessage(t),a.isFalsy(n))if(E.MessageController.isDeliveryReceipt(t))t.getAttribute(d.MessageConstatnts.XMPP_KEYS.TYPE)==d.MessageConstatnts.XMPP_KEYS.TYPE_GROUP&&S.getFullJidForGroup(t.getAttribute(d.MessageConstatnts.XMPP_KEYS.FROM))==e.getInstance().connection.jid||g.publishDeliveryReceipt(t);else{if(!E.MessageController.isReadRceipt(t))return!0;t.getAttribute(d.MessageConstatnts.XMPP_KEYS.TYPE)==d.MessageConstatnts.XMPP_KEYS.TYPE_GROUP&&S.getFullJidForGroup(t.getAttribute(d.MessageConstatnts.XMPP_KEYS.FROM))==e.getInstance().connection.jid||g.publishReadReceipt(t)}else t.getAttribute(d.MessageConstatnts.XMPP_KEYS.TYPE)==d.MessageConstatnts.XMPP_KEYS.TYPE_GROUP?S.getFullJidForGroup(t.getAttribute(d.MessageConstatnts.XMPP_KEYS.FROM))==e.getInstance().connection.jid||E.MessageController.checkIfCabon(t)||g.connection.receipts._processReceipt(t,n.getId()):E.MessageController.checkIfCabon(t)?g.trigerMessageHandler(t):g.connection.receipts._processReceipt(t,n.getId());E.MessageController.isReadRceipt(t)||E.MessageController.isDeliveryReceipt(t)?t=n:t.getAttribute(d.MessageConstatnts.XMPP_KEYS.TYPE)==d.MessageConstatnts.XMPP_KEYS.TYPE_GROUP&&S.getFullJidForGroup(t.getAttribute(d.MessageConstatnts.XMPP_KEYS.FROM))==e.getInstance().connection.jid||(t=n)}catch(e){return a.Logger.error("Error in processing incoming message",{e:e,message:t}),!0}if(!a.isFalsy(t)){try{A.MessageListnerMaping.getInstance().set("all",parseInt(t.id)),u.CometChat.setLastMessageId(t.id)}catch(e){a.Logger.error("Error in storing incoming message id",{e:e})}g.messageHandlers.map((function(e){return o(g,void 0,void 0,(function(){var n,r,s;return i(this,(function(o){switch(o.label){case 0:return o.trys.push([0,5,,6]),e?t instanceof p.Action?[3,4]:[3,1]:[3,4];case 1:return t instanceof _.Call?[3,4]:[3,2];case 2:return n=t,r=E.MessageController.trasformJSONMessge(n),[4,R.ExtensionController.hookOnMessageReceived(r)];case 3:switch((n=o.sent()).getType()){case d.MessageConstatnts.TYPE.TEXT:a.isFalsy(e._eventListener.onTextMessageReceived)||e._eventListener.onTextMessageReceived(n);break;case d.MessageConstatnts.TYPE.CUSTOM:a.isFalsy(e._eventListener.onCustomMessageReceived)||e._eventListener.onCustomMessageReceived(n);break;default:n.getCategory()==d.MessageCategory.CUSTOM?a.isFalsy(e._eventListener.onCustomMessageReceived)||e._eventListener.onCustomMessageReceived(t):a.isFalsy(e._eventListener.onMediaMessageReceived)||e._eventListener.onMediaMessageReceived(t)}o.label=4;case 4:return[3,6];case 5:return s=o.sent(),a.Logger.error("Error in processing incoming message",{e:s}),[3,6];case 6:return[2]}}))}))})),t instanceof _.Call&&g.publishCallEvents(t),t instanceof p.Action&&g.publishActionEvents(t)}}}catch(e){a.Logger.error("Error in message processing",{error:e})}return!0}),null,"message"),g.connection.addHandler((function(t){try{if(t.getElementsByTagName("error").length>0)return!0;if(!t.getElementsByTagName("composing")&&!t.getElementsByTagName("paused"))return!0;t.getElementsByTagName("forwarded")[0]&&(t=t.getElementsByTagName("message")[0]);var n,r,s=t.getElementsByTagName("composing"),o=t.getElementsByTagName("paused"),i=t.getAttribute("from"),c=t.getAttribute("type"),u=t.getAttribute("to"),l=void 0;if(t.getElementsByTagName("body")[0]&&(n=S.parseHTML(t.getElementsByTagName("body")[0]).trim().toString()),s.length>0||o.length>0)switch(c){case d.XMPP.CONVERSATION.TYPE.CHAT:r=new m.TypingIndicator(S.getUidFromJid(u),d.MessageConstatnts.RECEIVER_TYPE.USER),t.getElementsByTagName("user")[0]?(delete(l=new C.User(JSON.parse(S.parseHTML(t.getElementsByTagName("user")[0]).trim().toString()))).authToken,g.pushToTypingListeners(l,n,r,s,o)):g.getUsersVCard(S.getUidFromJid(i),(function(e){g.pushToTypingListeners(e,n,r,s,o)}));break;case d.XMPP.CONVERSATION.TYPE.GROUP_CHAT:if(S.getFullJidForGroup(t.getAttribute(d.MessageConstatnts.XMPP_KEYS.FROM))==e.getInstance().connection.jid)return!0;r=new m.TypingIndicator(S.getGUIDFromJID(i),d.MessageConstatnts.RECEIVER_TYPE.GROUP),t.getElementsByTagName("user")[0]?(delete(l=new C.User(JSON.parse(S.parseHTML(t.getElementsByTagName("user")[0]).trim().toString()))).authToken,g.pushToTypingListeners(l,n,r,s,o)):g.getUsersVCard(S.getUidFromJid(i),(function(e){g.pushToTypingListeners(e,n,r,s,o)}))}}catch(e){a.Logger.error("error in message processing",{error:e})}return!0}),null,"message")}}catch(e){a.Logger.error("XMPPHelper: performAfterConnection",e)}}))},e.XMPP_HOST=d.XMPP.host,e.XMPP_PORT=d.XMPP.port,e.xMPPConnectionHelper=new e,e.XMPP_BIND_URL="wss://"+e.XMPP_HOST+":"+e.XMPP_PORT+d.XMPP.ws_url,e.XMPP_BIND_URL_WS="wss://"+e.XMPP_HOST+":"+e.XMPP_PORT+d.XMPP.ws_url,e.XMPP_BIND_URL_HTTPS="https://"+e.XMPP_HOST+":"+e.XMPP_PORT+d.XMPP.bind_url,e}();t.XMPPConnectionHelper=P;var M=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];this.onConnected=void 0,this.inConnecting=void 0,this.onDisconnected=void 0,this.onFeatureThrottled=void 0,a.isFalsy(e[0].onConnected)||(this.onConnected=e[0].onConnected),a.isFalsy(e[0].inConnecting)||(this.inConnecting=e[0].inConnecting),a.isFalsy(e[0].onDisconnected)||(this.onDisconnected=e[0].onDisconnected),a.isFalsy(e[0].onFeatureThrottled)||(this.onFeatureThrottled=e[0].onFeatureThrottled)};t.XMPPConnectionEventListener=M;var v=function(e,t){this._name=e,this._callback=t};t.XMPPListener=v;var L=function(e){function t(t,n,r,s){var o=e.call(this,t,s)||this;return o._XMPPeventListener=n,r&&(o._cursor=r),o}return s(t,e),t}(v);t.XMPPConnectionListener=L},function(e,t,n){var r;window,r=function(){return function(e){var t={};function n(r){if(t[r])return t[r].exports;var s=t[r]={i:r,l:!1,exports:{}};return e[r].call(s.exports,s,s.exports,n),s.l=!0,s.exports}return n.m=e,n.c=t,n.d=function(e,t,r){n.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:r})},n.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},n.t=function(e,t){if(1&t&&(e=n(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var r=Object.create(null);if(n.r(r),Object.defineProperty(r,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var s in e)n.d(r,s,function(t){return e[t]}.bind(null,s));return r},n.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return n.d(t,"a",t),t},n.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},n.p="",n(n.s="./src/strophe.js")}({"./src/bosh.js":function(e,t,n){"use strict";n.r(t);var r=n("./src/core.js"),s=r.default.Strophe,o=r.default.$build;s.Request=function(e,t,n,r){this.id=++s._requestId,this.xmlData=e,this.data=s.serialize(e),this.origFunc=t,this.func=t,this.rid=n,this.date=NaN,this.sends=r||0,this.abort=!1,this.dead=null,this.age=function(){return this.date?(new Date-this.date)/1e3:0},this.timeDead=function(){return this.dead?(new Date-this.dead)/1e3:0},this.xhr=this._newXHR()},s.Request.prototype={getResponse:function(){var e=null;if(this.xhr.responseXML&&this.xhr.responseXML.documentElement){if("parsererror"===(e=this.xhr.responseXML.documentElement).tagName)throw s.error("invalid response received"),s.error("responseText: "+this.xhr.responseText),s.error("responseXML: "+s.serialize(this.xhr.responseXML)),new Error("parsererror")}else if(this.xhr.responseText){if(s.debug("Got responseText but no responseXML; attempting to parse it with DOMParser..."),!(e=(new DOMParser).parseFromString(this.xhr.responseText,"application/xml").documentElement))throw new Error("Parsing produced null node");if(e.querySelector("parsererror")){s.error("invalid response received: "+e.querySelector("parsererror").textContent),s.error("responseText: "+this.xhr.responseText);var t=new Error;throw t.name=s.ErrorCondition.BAD_FORMAT,t}}return e},_newXHR:function(){var e=null;return window.XMLHttpRequest?(e=new XMLHttpRequest).overrideMimeType&&e.overrideMimeType("text/xml; charset=utf-8"):window.ActiveXObject&&(e=new ActiveXObject("Microsoft.XMLHTTP")),e.onreadystatechange=this.func.bind(null,this),e}},s.Bosh=function(e){this._conn=e,this.rid=Math.floor(4294967295*Math.random()),this.sid=null,this.hold=1,this.wait=60,this.window=5,this.errors=0,this.inactivity=null,this.lastResponseHeaders=null,this._requests=[]},s.Bosh.prototype={strip:null,_buildBody:function(){var e=o("body",{rid:this.rid++,xmlns:s.NS.HTTPBIND});return null!==this.sid&&e.attrs({sid:this.sid}),this._conn.options.keepalive&&this._conn._sessionCachingSupported()&&this._cacheSession(),e},_reset:function(){this.rid=Math.floor(4294967295*Math.random()),this.sid=null,this.errors=0,this._conn._sessionCachingSupported()&&window.sessionStorage.removeItem("strophe-bosh-session"),this._conn.nextValidRid(this.rid)},_connect:function(e,t,n){this.wait=e||this.wait,this.hold=t||this.hold,this.errors=0;var r=this._buildBody().attrs({to:this._conn.domain,"xml:lang":"en",wait:this.wait,hold:this.hold,content:"text/xml; charset=utf-8",ver:"1.6","xmpp:version":"1.0","xmlns:xmpp":s.NS.BOSH});n&&r.attrs({route:n});var o=this._conn._connect_cb;this._requests.push(new s.Request(r.tree(),this._onRequestStateChange.bind(this,o.bind(this._conn)),r.tree().getAttribute("rid"))),this._throttledRequestHandler()},_attach:function(e,t,n,r,o,i,a){this._conn.jid=e,this.sid=t,this.rid=n,this._conn.connect_callback=r,this._conn.domain=s.getDomainFromJid(this._conn.jid),this._conn.authenticated=!0,this._conn.connected=!0,this.wait=o||this.wait,this.hold=i||this.hold,this.window=a||this.window,this._conn._changeConnectStatus(s.Status.ATTACHED,null)},_restore:function(e,t,n,r,o){var i=JSON.parse(window.sessionStorage.getItem("strophe-bosh-session"));if(!(null!=i&&i.rid&&i.sid&&i.jid&&(null==e||s.getBareJidFromJid(i.jid)===s.getBareJidFromJid(e)||null===s.getNodeFromJid(e)&&s.getDomainFromJid(i.jid)===e))){var a=new Error("_restore: no restoreable session.");throw a.name="StropheSessionError",a}this._conn.restored=!0,this._attach(i.jid,i.sid,i.rid,t,n,r,o)},_cacheSession:function(){this._conn.authenticated?this._conn.jid&&this.rid&&this.sid&&window.sessionStorage.setItem("strophe-bosh-session",JSON.stringify({jid:this._conn.jid,rid:this.rid,sid:this.sid})):window.sessionStorage.removeItem("strophe-bosh-session")},_connect_cb:function(e){var t=e.getAttribute("type");if(null!==t&&"terminate"===t){var n=e.getAttribute("condition");s.error("BOSH-Connection failed: "+n);var r=e.getElementsByTagName("conflict");return null!==n?("remote-stream-error"===n&&r.length>0&&(n="conflict"),this._conn._changeConnectStatus(s.Status.CONNFAIL,n)):this._conn._changeConnectStatus(s.Status.CONNFAIL,"unknown"),this._conn._doDisconnect(n),s.Status.CONNFAIL}this.sid||(this.sid=e.getAttribute("sid"));var o=e.getAttribute("requests");o&&(this.window=parseInt(o,10));var i=e.getAttribute("hold");i&&(this.hold=parseInt(i,10));var a=e.getAttribute("wait");a&&(this.wait=parseInt(a,10));var c=e.getAttribute("inactivity");c&&(this.inactivity=parseInt(c,10))},_disconnect:function(e){this._sendTerminate(e)},_doDisconnect:function(){this.sid=null,this.rid=Math.floor(4294967295*Math.random()),this._conn._sessionCachingSupported()&&window.sessionStorage.removeItem("strophe-bosh-session"),this._conn.nextValidRid(this.rid)},_emptyQueue:function(){return 0===this._requests.length},_callProtocolErrorHandlers:function(e){var t=this._getRequestStatus(e),n=this._conn.protocolErrorHandlers.HTTP[t];n&&n.call(this,t)},_hitError:function(e){this.errors++,s.warn("request errored, status: "+e+", number of errors: "+this.errors),this.errors>4&&this._conn._onDisconnectTimeout()},_no_auth_received:function(e){s.warn("Server did not yet offer a supported authentication mechanism. Sending a blank poll request."),e=e?e.bind(this._conn):this._conn._connect_cb.bind(this._conn);var t=this._buildBody();this._requests.push(new s.Request(t.tree(),this._onRequestStateChange.bind(this,e),t.tree().getAttribute("rid"))),this._throttledRequestHandler()},_onDisconnectTimeout:function(){this._abortAllRequests()},_abortAllRequests:function(){for(;this._requests.length>0;){var e=this._requests.pop();e.abort=!0,e.xhr.abort(),e.xhr.onreadystatechange=function(){}}},_onIdle:function(){var e=this._conn._data;if(this._conn.authenticated&&0===this._requests.length&&0===e.length&&!this._conn.disconnecting&&(s.info("no requests during idle cycle, sending blank request"),e.push(null)),!this._conn.paused){if(this._requests.length<2&&e.length>0){for(var t=this._buildBody(),n=0;n<e.length;n++)null!==e[n]&&("restart"===e[n]?t.attrs({to:this._conn.domain,"xml:lang":"en","xmpp:restart":"true","xmlns:xmpp":s.NS.BOSH}):t.cnode(e[n]).up());delete this._conn._data,this._conn._data=[],this._requests.push(new s.Request(t.tree(),this._onRequestStateChange.bind(this,this._conn._dataRecv.bind(this._conn)),t.tree().getAttribute("rid"))),this._throttledRequestHandler()}if(this._requests.length>0){var r=this._requests[0].age();null!==this._requests[0].dead&&this._requests[0].timeDead()>Math.floor(s.SECONDARY_TIMEOUT*this.wait)&&this._throttledRequestHandler(),r>Math.floor(s.TIMEOUT*this.wait)&&(s.warn("Request "+this._requests[0].id+" timed out, over "+Math.floor(s.TIMEOUT*this.wait)+" seconds since last activity"),this._throttledRequestHandler())}}},_getRequestStatus:function(e,t){var n;if(4===e.xhr.readyState)try{n=e.xhr.status}catch(e){s.error("Caught an error while retrieving a request's status, reqStatus: "+n)}return void 0===n&&(n="number"==typeof t?t:0),n},_onRequestStateChange:function(e,t){if(s.debug("request id "+t.id+"."+t.sends+" state changed to "+t.xhr.readyState),t.abort)t.abort=!1;else if(4===t.xhr.readyState){var n=this._getRequestStatus(t);if(this.lastResponseHeaders=t.xhr.getAllResponseHeaders(),this.disconnecting&&n>=400)return this._hitError(n),void this._callProtocolErrorHandlers(t);var r=n>0&&n<500,o=t.sends>this._conn.maxRetries;if((r||o)&&(this._removeRequest(t),s.debug("request id "+t.id+" should now be removed")),200===n){var i=this._requests[0]===t;(this._requests[1]===t||i&&this._requests.length>0&&this._requests[0].age()>Math.floor(s.SECONDARY_TIMEOUT*this.wait))&&this._restartRequest(0),this._conn.nextValidRid(Number(t.rid)+1),s.debug("request id "+t.id+"."+t.sends+" got 200"),e(t),this.errors=0}else 0===n||n>=400&&n<600||n>=12e3?(s.error("request id "+t.id+"."+t.sends+" error "+n+" happened"),this._hitError(n),this._callProtocolErrorHandlers(t),n>=400&&n<500&&(this._conn._changeConnectStatus(s.Status.DISCONNECTING,null),this._conn._doDisconnect())):s.error("request id "+t.id+"."+t.sends+" error "+n+" happened");r||o?o&&!this._conn.connected&&this._conn._changeConnectStatus(s.Status.CONNFAIL,"giving-up"):this._throttledRequestHandler()}},_processRequest:function(e){var t=this,n=this._requests[e],r=this._getRequestStatus(n,-1);if(n.sends>this._conn.maxRetries)this._conn._onDisconnectTimeout();else{var o=n.age(),i=!isNaN(o)&&o>Math.floor(s.TIMEOUT*this.wait),a=null!==n.dead&&n.timeDead()>Math.floor(s.SECONDARY_TIMEOUT*this.wait),c=4===n.xhr.readyState&&(r<1||r>=500);if((i||a||c)&&(a&&s.error("Request ".concat(this._requests[e].id," timed out (secondary), restarting")),n.abort=!0,n.xhr.abort(),n.xhr.onreadystatechange=function(){},this._requests[e]=new s.Request(n.xmlData,n.origFunc,n.rid,n.sends),n=this._requests[e]),0===n.xhr.readyState){s.debug("request id "+n.id+"."+n.sends+" posting");try{var u=this._conn.options.contentType||"text/xml; charset=utf-8";n.xhr.open("POST",this._conn.service,!this._conn.options.sync),void 0!==n.xhr.setRequestHeader&&n.xhr.setRequestHeader("Content-Type",u),this._conn.options.withCredentials&&(n.xhr.withCredentials=!0)}catch(e){return s.error("XHR open failed: "+e.toString()),this._conn.connected||this._conn._changeConnectStatus(s.Status.CONNFAIL,"bad-service"),void this._conn.disconnect()}var l=function(){if(n.date=new Date,t._conn.options.customHeaders){var e=t._conn.options.customHeaders;for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&n.xhr.setRequestHeader(r,e[r])}n.xhr.send(n.data)};if(n.sends>1){var E=1e3*Math.min(Math.floor(s.TIMEOUT*this.wait),Math.pow(n.sends,3));setTimeout((function(){l()}),E)}else l();n.sends++,this._conn.xmlOutput!==s.Connection.prototype.xmlOutput&&(n.xmlData.nodeName===this.strip&&n.xmlData.childNodes.length?this._conn.xmlOutput(n.xmlData.childNodes[0]):this._conn.xmlOutput(n.xmlData)),this._conn.rawOutput!==s.Connection.prototype.rawOutput&&this._conn.rawOutput(n.data)}else s.debug("_processRequest: "+(0===e?"first":"second")+" request has readyState of "+n.xhr.readyState)}},_removeRequest:function(e){s.debug("removing request");for(var t=this._requests.length-1;t>=0;t--)e===this._requests[t]&&this._requests.splice(t,1);e.xhr.onreadystatechange=function(){},this._throttledRequestHandler()},_restartRequest:function(e){var t=this._requests[e];null===t.dead&&(t.dead=new Date),this._processRequest(e)},_reqToData:function(e){try{return e.getResponse()}catch(e){if("parsererror"!==e.message)throw e;this._conn.disconnect("strophe-parsererror")}},_sendTerminate:function(e){s.info("_sendTerminate was called");var t=this._buildBody().attrs({type:"terminate"});e&&t.cnode(e.tree());var n=new s.Request(t.tree(),this._onRequestStateChange.bind(this,this._conn._dataRecv.bind(this._conn)),t.tree().getAttribute("rid"));this._requests.push(n),this._throttledRequestHandler()},_send:function(){var e=this;clearTimeout(this._conn._idleTimeout),this._throttledRequestHandler(),this._conn._idleTimeout=setTimeout((function(){return e._conn._onIdle()}),100)},_sendRestart:function(){this._throttledRequestHandler(),clearTimeout(this._conn._idleTimeout)},_throttledRequestHandler:function(){this._requests?s.debug("_throttledRequestHandler called with "+this._requests.length+" requests"):s.debug("_throttledRequestHandler called with undefined requests"),this._requests&&0!==this._requests.length&&(this._requests.length>0&&this._processRequest(0),this._requests.length>1&&Math.abs(this._requests[0].rid-this._requests[1].rid)<this.window&&this._processRequest(1))}}},"./src/core.js":function(e,t,n){"use strict";n.r(t);var r=n("./src/md5.js"),s=n("./src/sha1.js"),o=n("./src/utils.js");function i(e){return function(e){if(Array.isArray(e)){for(var t=0,n=new Array(e.length);t<e.length;t++)n[t]=e[t];return n}}(e)||function(e){if(Symbol.iterator in Object(e)||"[object Arguments]"===Object.prototype.toString.call(e))return Array.from(e)}(e)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance")}()}function a(e){return a="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},a(e)}function c(e,t){return new E.Builder(e,t)}function u(e){return new E.Builder("iq",e)}function l(e){return new E.Builder("presence",e)}var E={VERSION:"1.3.0",NS:{HTTPBIND:"http://jabber.org/protocol/httpbind",BOSH:"urn:xmpp:xbosh",CLIENT:"jabber:client",AUTH:"jabber:iq:auth",ROSTER:"jabber:iq:roster",PROFILE:"jabber:iq:profile",DISCO_INFO:"http://jabber.org/protocol/disco#info",DISCO_ITEMS:"http://jabber.org/protocol/disco#items",MUC:"http://jabber.org/protocol/muc",SASL:"urn:ietf:params:xml:ns:xmpp-sasl",STREAM:"http://etherx.jabber.org/streams",FRAMING:"urn:ietf:params:xml:ns:xmpp-framing",BIND:"urn:ietf:params:xml:ns:xmpp-bind",SESSION:"urn:ietf:params:xml:ns:xmpp-session",VERSION:"jabber:iq:version",STANZAS:"urn:ietf:params:xml:ns:xmpp-stanzas",XHTML_IM:"http://jabber.org/protocol/xhtml-im",XHTML:"http://www.w3.org/1999/xhtml"},XHTML:{tags:["a","blockquote","br","cite","em","img","li","ol","p","span","strong","ul","body"],attributes:{a:["href"],blockquote:["style"],br:[],cite:["style"],em:[],img:["src","alt","style","height","width"],li:["style"],ol:["style"],p:["style"],span:["style"],strong:[],ul:["style"],body:[]},css:["background-color","color","font-family","font-size","font-style","font-weight","margin-left","margin-right","text-align","text-decoration"],validTag:function(e){for(var t=0;t<E.XHTML.tags.length;t++)if(e===E.XHTML.tags[t])return!0;return!1},validAttribute:function(e,t){if(void 0!==E.XHTML.attributes[e]&&E.XHTML.attributes[e].length>0)for(var n=0;n<E.XHTML.attributes[e].length;n++)if(t===E.XHTML.attributes[e][n])return!0;return!1},validCSS:function(e){for(var t=0;t<E.XHTML.css.length;t++)if(e===E.XHTML.css[t])return!0;return!1}},Status:{ERROR:0,CONNECTING:1,CONNFAIL:2,AUTHENTICATING:3,AUTHFAIL:4,CONNECTED:5,DISCONNECTED:6,DISCONNECTING:7,ATTACHED:8,REDIRECT:9,CONNTIMEOUT:10},ErrorCondition:{BAD_FORMAT:"bad-format",CONFLICT:"conflict",MISSING_JID_NODE:"x-strophe-bad-non-anon-jid",NO_AUTH_MECH:"no-auth-mech",UNKNOWN_REASON:"unknown"},LogLevel:{DEBUG:0,INFO:1,WARN:2,ERROR:3,FATAL:4},ElementType:{NORMAL:1,TEXT:3,CDATA:4,FRAGMENT:11},TIMEOUT:1.1,SECONDARY_TIMEOUT:.1,addNamespace:function(e,t){E.NS[e]=t},forEachChild:function(e,t,n){for(var r=0;r<e.childNodes.length;r++){var s=e.childNodes[r];s.nodeType!==E.ElementType.NORMAL||t&&!this.isTagEqual(s,t)||n(s)}},isTagEqual:function(e,t){return e.tagName===t},_xmlGenerator:null,_makeGenerator:function(){var e;return void 0===document.implementation.createDocument||document.implementation.createDocument&&document.documentMode&&document.documentMode<10?(e=this._getIEXmlDom()).appendChild(e.createElement("strophe")):e=document.implementation.createDocument("jabber:client","strophe",null),e},xmlGenerator:function(){return E._xmlGenerator||(E._xmlGenerator=E._makeGenerator()),E._xmlGenerator},_getIEXmlDom:function(){for(var e=null,t=["Msxml2.DOMDocument.6.0","Msxml2.DOMDocument.5.0","Msxml2.DOMDocument.4.0","MSXML2.DOMDocument.3.0","MSXML2.DOMDocument","MSXML.DOMDocument","Microsoft.XMLDOM"],n=0;n<t.length&&null===e;n++)try{e=new ActiveXObject(t[n])}catch(t){e=null}return e},xmlElement:function(e){if(!e)return null;for(var t=E.xmlGenerator().createElement(e),n=1;n<arguments.length;n++){var r=arguments[n];if(r)if("string"==typeof r||"number"==typeof r)t.appendChild(E.xmlTextNode(r));else if("object"===a(r)&&"function"==typeof r.sort)for(var s=0;s<r.length;s++){var o=r[s];"object"===a(o)&&"function"==typeof o.sort&&void 0!==o[1]&&null!==o[1]&&t.setAttribute(o[0],o[1])}else if("object"===a(r))for(var i in r)Object.prototype.hasOwnProperty.call(r,i)&&void 0!==r[i]&&null!==r[i]&&t.setAttribute(i,r[i])}return t},xmlescape:function(e){return e=(e=(e=(e=(e=e.replace(/\&/g,"&")).replace(/</g,"<")).replace(/>/g,">")).replace(/'/g,"'")).replace(/"/g,""")},xmlunescape:function(e){return e=(e=(e=(e=(e=e.replace(/\&/g,"&")).replace(/</g,"<")).replace(/>/g,">")).replace(/'/g,"'")).replace(/"/g,'"')},xmlTextNode:function(e){return E.xmlGenerator().createTextNode(e)},xmlHtmlNode:function(e){var t;return DOMParser?t=(new DOMParser).parseFromString(e,"text/xml"):((t=new ActiveXObject("Microsoft.XMLDOM")).async="false",t.loadXML(e)),t},getText:function(e){if(!e)return null;var t="";0===e.childNodes.length&&e.nodeType===E.ElementType.TEXT&&(t+=e.nodeValue);for(var n=0;n<e.childNodes.length;n++)e.childNodes[n].nodeType===E.ElementType.TEXT&&(t+=e.childNodes[n].nodeValue);return E.xmlescape(t)},copyElement:function(e){var t;if(e.nodeType===E.ElementType.NORMAL){t=E.xmlElement(e.tagName);for(var n=0;n<e.attributes.length;n++)t.setAttribute(e.attributes[n].nodeName,e.attributes[n].value);for(var r=0;r<e.childNodes.length;r++)t.appendChild(E.copyElement(e.childNodes[r]))}else e.nodeType===E.ElementType.TEXT&&(t=E.xmlGenerator().createTextNode(e.nodeValue));return t},createHtml:function(e){var t;if(e.nodeType===E.ElementType.NORMAL){var n=e.nodeName.toLowerCase();if(E.XHTML.validTag(n))try{t=E.xmlElement(n);for(var r=0;r<E.XHTML.attributes[n].length;r++){var s=E.XHTML.attributes[n][r],o=e.getAttribute(s);if(null!=o&&""!==o&&!1!==o&&0!==o)if("style"===s&&"object"===a(o)&&void 0!==o.cssText&&(o=o.cssText),"style"===s){for(var i=[],c=o.split(";"),u=0;u<c.length;u++){var l=c[u].split(":"),d=l[0].replace(/^\s*/,"").replace(/\s*$/,"").toLowerCase();if(E.XHTML.validCSS(d)){var h=l[1].replace(/^\s*/,"").replace(/\s*$/,"");i.push(d+": "+h)}}i.length>0&&(o=i.join("; "),t.setAttribute(s,o))}else t.setAttribute(s,o)}for(var p=0;p<e.childNodes.length;p++)t.appendChild(E.createHtml(e.childNodes[p]))}catch(e){t=E.xmlTextNode("")}else{t=E.xmlGenerator().createDocumentFragment();for(var S=0;S<e.childNodes.length;S++)t.appendChild(E.createHtml(e.childNodes[S]))}}else if(e.nodeType===E.ElementType.FRAGMENT){t=E.xmlGenerator().createDocumentFragment();for(var g=0;g<e.childNodes.length;g++)t.appendChild(E.createHtml(e.childNodes[g]))}else e.nodeType===E.ElementType.TEXT&&(t=E.xmlTextNode(e.nodeValue));return t},escapeNode:function(e){return"string"!=typeof e?e:e.replace(/^\s+|\s+$/g,"").replace(/\\/g,"\\5c").replace(/ /g,"\\20").replace(/\"/g,"\\22").replace(/\&/g,"\\26").replace(/\'/g,"\\27").replace(/\//g,"\\2f").replace(/:/g,"\\3a").replace(/</g,"\\3c").replace(/>/g,"\\3e").replace(/@/g,"\\40")},unescapeNode:function(e){return"string"!=typeof e?e:e.replace(/\\20/g," ").replace(/\\22/g,'"').replace(/\\26/g,"&").replace(/\\27/g,"'").replace(/\\2f/g,"/").replace(/\\3a/g,":").replace(/\\3c/g,"<").replace(/\\3e/g,">").replace(/\\40/g,"@").replace(/\\5c/g,"\\")},getNodeFromJid:function(e){return e.indexOf("@")<0?null:e.split("@")[0]},getDomainFromJid:function(e){var t=E.getBareJidFromJid(e);if(t.indexOf("@")<0)return t;var n=t.split("@");return n.splice(0,1),n.join("@")},getResourceFromJid:function(e){var t=e.split("/");return t.length<2?null:(t.splice(0,1),t.join("/"))},getBareJidFromJid:function(e){return e?e.split("/")[0]:null},_handleError:function(e){void 0!==e.stack&&E.fatal(e.stack),e.sourceURL?E.fatal("error: "+this.handler+" "+e.sourceURL+":"+e.line+" - "+e.name+": "+e.message):e.fileName?E.fatal("error: "+this.handler+" "+e.fileName+":"+e.lineNumber+" - "+e.name+": "+e.message):E.fatal("error: "+e.message)},log:function(e,t){e===this.LogLevel.FATAL&&"object"===a(window.console)&&"function"==typeof window.console.error&&window.console.error(t)},debug:function(e){this.log(this.LogLevel.DEBUG,e)},info:function(e){this.log(this.LogLevel.INFO,e)},warn:function(e){this.log(this.LogLevel.WARN,e)},error:function(e){this.log(this.LogLevel.ERROR,e)},fatal:function(e){this.log(this.LogLevel.FATAL,e)},serialize:function(e){if(!e)return null;"function"==typeof e.tree&&(e=e.tree());var t=i(Array(e.attributes.length).keys()).map((function(t){return e.attributes[t].nodeName}));t.sort();var n=t.reduce((function(t,n){return"".concat(t," ").concat(n,'="').concat(E.xmlescape(e.attributes.getNamedItem(n).value),'"')}),"<".concat(e.nodeName));if(e.childNodes.length>0){n+=">";for(var r=0;r<e.childNodes.length;r++){var s=e.childNodes[r];switch(s.nodeType){case E.ElementType.NORMAL:n+=E.serialize(s);break;case E.ElementType.TEXT:n+=E.xmlescape(s.nodeValue);break;case E.ElementType.CDATA:n+="<![CDATA["+s.nodeValue+"]]>"}}n+="</"+e.nodeName+">"}else n+="/>";return n},_requestId:0,_connectionPlugins:{},addConnectionPlugin:function(e,t){E._connectionPlugins[e]=t},Builder:function(e,t){"presence"!==e&&"message"!==e&&"iq"!==e||(t&&!t.xmlns?t.xmlns=E.NS.CLIENT:t||(t={xmlns:E.NS.CLIENT})),this.nodeTree=E.xmlElement(e,t),this.node=this.nodeTree}};E.Builder.prototype={tree:function(){return this.nodeTree},toString:function(){return E.serialize(this.nodeTree)},up:function(){return this.node=this.node.parentNode,this},root:function(){return this.node=this.nodeTree,this},attrs:function(e){for(var t in e)Object.prototype.hasOwnProperty.call(e,t)&&(void 0===e[t]?this.node.removeAttribute(t):this.node.setAttribute(t,e[t]));return this},c:function(e,t,n){var r=E.xmlElement(e,t,n);return this.node.appendChild(r),"string"!=typeof n&&"number"!=typeof n&&(this.node=r),this},cnode:function(e){var t,n=E.xmlGenerator();try{t=void 0!==n.importNode}catch(e){t=!1}var r=t?n.importNode(e,!0):E.copyElement(e);return this.node.appendChild(r),this.node=r,this},t:function(e){var t=E.xmlTextNode(e);return this.node.appendChild(t),this},h:function(e){var t=document.createElement("body");t.innerHTML=e;for(var n=E.createHtml(t);n.childNodes.length>0;)this.node.appendChild(n.childNodes[0]);return this}},E.Handler=function(e,t,n,r,s,o,i){this.handler=e,this.ns=t,this.name=n,this.type=r,this.id=s,this.options=i||{matchBareFromJid:!1,ignoreNamespaceFragment:!1},this.options.matchBare&&(E.warn('The "matchBare" option is deprecated, use "matchBareFromJid" instead.'),this.options.matchBareFromJid=this.options.matchBare,delete this.options.matchBare),this.options.matchBareFromJid?this.from=o?E.getBareJidFromJid(o):null:this.from=o,this.user=!0},E.Handler.prototype={getNamespace:function(e){var t=e.getAttribute("xmlns");return t&&this.options.ignoreNamespaceFragment&&(t=t.split("#")[0]),t},namespaceMatch:function(e){var t=this,n=!1;return!this.ns||(E.forEachChild(e,null,(function(e){t.getNamespace(e)===t.ns&&(n=!0)})),n||this.getNamespace(e)===this.ns)},isMatch:function(e){var t=e.getAttribute("from");this.options.matchBareFromJid&&(t=E.getBareJidFromJid(t));var n=e.getAttribute("type");return!(!this.namespaceMatch(e)||this.name&&!E.isTagEqual(e,this.name)||this.type&&(Array.isArray(this.type)?-1===this.type.indexOf(n):n!==this.type)||this.id&&e.getAttribute("id")!==this.id||this.from&&t!==this.from)},run:function(e){var t=null;try{t=this.handler(e)}catch(e){throw E._handleError(e),e}return t},toString:function(){return"{Handler: "+this.handler+"("+this.name+","+this.id+","+this.ns+")}"}},E.TimedHandler=function(e,t){this.period=e,this.handler=t,this.lastCalled=(new Date).getTime(),this.user=!0},E.TimedHandler.prototype={run:function(){return this.lastCalled=(new Date).getTime(),this.handler()},reset:function(){this.lastCalled=(new Date).getTime()},toString:function(){return"{TimedHandler: "+this.handler+"("+this.period+")}"}},E.Connection=function(e,t){var n=this;this.service=e,this.options=t||{};var r=this.options.protocol||"";for(var s in 0===e.indexOf("ws:")||0===e.indexOf("wss:")||0===r.indexOf("ws")?this._proto=new E.Websocket(this):this._proto=new E.Bosh(this),this.jid="",this.domain=null,this.features=null,this._sasl_data={},this.do_session=!1,this.do_bind=!1,this.timedHandlers=[],this.handlers=[],this.removeTimeds=[],this.removeHandlers=[],this.addTimeds=[],this.addHandlers=[],this.protocolErrorHandlers={HTTP:{},websocket:{}},this._idleTimeout=null,this._disconnectTimeout=null,this.authenticated=!1,this.connected=!1,this.disconnecting=!1,this.do_authentication=!0,this.paused=!1,this.restored=!1,this._data=[],this._uniqueId=0,this._sasl_success_handler=null,this._sasl_failure_handler=null,this._sasl_challenge_handler=null,this.maxRetries=5,this._idleTimeout=setTimeout((function(){return n._onIdle()}),100),o.default.addCookies(this.options.cookies),this.registerSASLMechanisms(this.options.mechanisms),E._connectionPlugins)if(Object.prototype.hasOwnProperty.call(E._connectionPlugins,s)){var i=function(){};i.prototype=E._connectionPlugins[s],this[s]=new i,this[s].init(this)}},E.Connection.prototype={reset:function(){this._proto._reset(),this.do_session=!1,this.do_bind=!1,this.timedHandlers=[],this.handlers=[],this.removeTimeds=[],this.removeHandlers=[],this.addTimeds=[],this.addHandlers=[],this.authenticated=!1,this.connected=!1,this.disconnecting=!1,this.restored=!1,this._data=[],this._requests=[],this._uniqueId=0},pause:function(){this.paused=!0},resume:function(){this.paused=!1},getUniqueId:function(e){var t="xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,(function(e){var t=16*Math.random()|0;return("x"===e?t:3&t|8).toString(16)}));return"string"==typeof e||"number"==typeof e?t+":"+e:t+""},addProtocolErrorHandler:function(e,t,n){this.protocolErrorHandlers[e][t]=n},connect:function(e,t,n,r,s,o,i){this.jid=e,this.authzid=E.getBareJidFromJid(this.jid),this.authcid=i||E.getNodeFromJid(this.jid),this.pass=t,this.servtype="xmpp",this.connect_callback=n,this.disconnecting=!1,this.connected=!1,this.authenticated=!1,this.restored=!1,this.domain=E.getDomainFromJid(this.jid),this._changeConnectStatus(E.Status.CONNECTING,null),this._proto._connect(r,s,o)},attach:function(e,t,n,r,s,o,i){if(!(this._proto instanceof E.Bosh)){var a=new Error('The "attach" method can only be used with a BOSH connection.');throw a.name="StropheSessionError",a}this._proto._attach(e,t,n,r,s,o,i)},restore:function(e,t,n,r,s){if(!this._sessionCachingSupported()){var o=new Error('The "restore" method can only be used with a BOSH connection.');throw o.name="StropheSessionError",o}this._proto._restore(e,t,n,r,s)},_sessionCachingSupported:function(){if(this._proto instanceof E.Bosh){if(!JSON)return!1;try{sessionStorage.setItem("_strophe_","_strophe_"),sessionStorage.removeItem("_strophe_")}catch(e){return!1}return!0}return!1},xmlInput:function(e){},xmlOutput:function(e){},rawInput:function(e){},rawOutput:function(e){},nextValidRid:function(e){},send:function(e){if(null!==e){if("function"==typeof e.sort)for(var t=0;t<e.length;t++)this._queueData(e[t]);else"function"==typeof e.tree?this._queueData(e.tree()):this._queueData(e);this._proto._send()}},flush:function(){clearTimeout(this._idleTimeout),this._onIdle()},sendPresence:function(e,t,n,r){var s=this,o=null;"function"==typeof e.tree&&(e=e.tree());var i=e.getAttribute("id");if(i||(i=this.getUniqueId("sendPresence"),e.setAttribute("id",i)),"function"==typeof t||"function"==typeof n){var a=this.addHandler((function(e){o&&s.deleteTimedHandler(o),"error"===e.getAttribute("type")?n&&n(e):t&&t(e)}),null,"presence",null,i);r&&(o=this.addTimedHandler(r,(function(){return s.deleteHandler(a),n&&n(null),!1})))}return this.send(e),i},sendIQ:function(e,t,n,r){var s=this,o=null;"function"==typeof e.tree&&(e=e.tree());var i=e.getAttribute("id");if(i||(i=this.getUniqueId("sendIQ"),e.setAttribute("id",i)),"function"==typeof t||"function"==typeof n){var a=this.addHandler((function(e){o&&s.deleteTimedHandler(o);var r=e.getAttribute("type");if("result"===r)t&&t(e);else{if("error"!==r){var i=new Error("Got bad IQ type of ".concat(r));throw i.name="StropheError",i}n&&n(e)}}),null,"iq",["error","result"],i);r&&(o=this.addTimedHandler(r,(function(){return s.deleteHandler(a),n&&n(null),!1})))}return this.send(e),i},_queueData:function(e){if(null===e||!e.tagName||!e.childNodes){var t=new Error("Cannot queue non-DOMElement.");throw t.name="StropheError",t}this._data.push(e)},_sendRestart:function(){var e=this;this._data.push("restart"),this._proto._sendRestart(),this._idleTimeout=setTimeout((function(){return e._onIdle()}),100)},addTimedHandler:function(e,t){var n=new E.TimedHandler(e,t);return this.addTimeds.push(n),n},deleteTimedHandler:function(e){this.removeTimeds.push(e)},addHandler:function(e,t,n,r,s,o,i){var a=new E.Handler(e,t,n,r,s,o,i);return this.addHandlers.push(a),a},deleteHandler:function(e){this.removeHandlers.push(e);var t=this.addHandlers.indexOf(e);t>=0&&this.addHandlers.splice(t,1)},registerSASLMechanisms:function(e){this.mechanisms={},(e=e||[E.SASLAnonymous,E.SASLExternal,E.SASLMD5,E.SASLOAuthBearer,E.SASLXOAuth2,E.SASLPlain,E.SASLSHA1]).forEach(this.registerSASLMechanism.bind(this))},registerSASLMechanism:function(e){this.mechanisms[e.prototype.name]=e},disconnect:function(e){if(this._changeConnectStatus(E.Status.DISCONNECTING,e),E.info("Disconnect was called because: "+e),this.connected){var t=!1;this.disconnecting=!0,this.authenticated&&(t=l({xmlns:E.NS.CLIENT,type:"unavailable"})),this._disconnectTimeout=this._addSysTimedHandler(3e3,this._onDisconnectTimeout.bind(this)),this._proto._disconnect(t)}else E.info("Disconnect was called before Strophe connected to the server"),this._proto._abortAllRequests(),this._doDisconnect()},_changeConnectStatus:function(e,t,n){for(var r in E._connectionPlugins)if(Object.prototype.hasOwnProperty.call(E._connectionPlugins,r)){var s=this[r];if(s.statusChanged)try{s.statusChanged(e,t)}catch(e){E.error("".concat(r," plugin caused an exception changing status: ").concat(e))}}if(this.connect_callback)try{this.connect_callback(e,t,n)}catch(e){E._handleError(e),E.error("User connection callback caused an exception: ".concat(e))}},_doDisconnect:function(e){"number"==typeof this._idleTimeout&&clearTimeout(this._idleTimeout),null!==this._disconnectTimeout&&(this.deleteTimedHandler(this._disconnectTimeout),this._disconnectTimeout=null),E.info("_doDisconnect was called"),this._proto._doDisconnect(),this.authenticated=!1,this.disconnecting=!1,this.restored=!1,this.handlers=[],this.timedHandlers=[],this.removeTimeds=[],this.removeHandlers=[],this.addTimeds=[],this.addHandlers=[],this._changeConnectStatus(E.Status.DISCONNECTED,e),this.connected=!1},_dataRecv:function(e,t){var n=this;E.info("_dataRecv called");var r=this._proto._reqToData(e);if(null!==r){for(this.xmlInput!==E.Connection.prototype.xmlInput&&(r.nodeName===this._proto.strip&&r.childNodes.length?this.xmlInput(r.childNodes[0]):this.xmlInput(r)),this.rawInput!==E.Connection.prototype.rawInput&&(t?this.rawInput(t):this.rawInput(E.serialize(r)));this.removeHandlers.length>0;){var s=this.removeHandlers.pop(),o=this.handlers.indexOf(s);o>=0&&this.handlers.splice(o,1)}for(;this.addHandlers.length>0;)this.handlers.push(this.addHandlers.pop());if(this.disconnecting&&this._proto._emptyQueue())this._doDisconnect();else{var i=r.getAttribute("type");if(null!==i&&"terminate"===i){if(this.disconnecting)return;var a=r.getAttribute("condition"),c=r.getElementsByTagName("conflict");return null!==a?("remote-stream-error"===a&&c.length>0&&(a="conflict"),this._changeConnectStatus(E.Status.CONNFAIL,a)):this._changeConnectStatus(E.Status.CONNFAIL,E.ErrorCondition.UNKOWN_REASON),void this._doDisconnect(a)}E.forEachChild(r,null,(function(e){var t=n.handlers;n.handlers=[];for(var r=0;r<t.length;r++){var s=t[r];try{(!s.isMatch(e)||!n.authenticated&&s.user||s.run(e))&&n.handlers.push(s)}catch(e){E.warn("Removing Strophe handlers due to uncaught exception: "+e.message)}}}))}}},mechanisms:{},_connect_cb:function(e,t,n){var r;E.info("_connect_cb was called"),this.connected=!0;try{r=this._proto._reqToData(e)}catch(e){if(e.name!==E.ErrorCondition.BAD_FORMAT)throw e;this._changeConnectStatus(E.Status.CONNFAIL,E.ErrorCondition.BAD_FORMAT),this._doDisconnect(E.ErrorCondition.BAD_FORMAT)}if(r&&(this.xmlInput!==E.Connection.prototype.xmlInput&&(r.nodeName===this._proto.strip&&r.childNodes.length?this.xmlInput(r.childNodes[0]):this.xmlInput(r)),this.rawInput!==E.Connection.prototype.rawInput&&(n?this.rawInput(n):this.rawInput(E.serialize(r))),this._proto._connect_cb(r)!==E.Status.CONNFAIL))if(r.getElementsByTagNameNS?r.getElementsByTagNameNS(E.NS.STREAM,"features").length>0:r.getElementsByTagName("stream:features").length>0||r.getElementsByTagName("features").length>0){var s=[],o=r.getElementsByTagName("mechanism");if(o.length>0)for(var i=0;i<o.length;i++){var a=E.getText(o[i]);this.mechanisms[a]&&s.push(this.mechanisms[a])}0!==s.length||0!==r.getElementsByTagName("auth").length?!1!==this.do_authentication&&this.authenticate(s):this._proto._no_auth_received(t)}else this._proto._no_auth_received(t)},sortMechanismsByPriority:function(e){for(var t=0;t<e.length-1;++t){for(var n=t,r=t+1;r<e.length;++r)e[r].prototype.priority>e[n].prototype.priority&&(n=r);if(n!==t){var s=e[t];e[t]=e[n],e[n]=s}}return e},_attemptSASLAuth:function(e){e=this.sortMechanismsByPriority(e||[]);for(var t=!1,n=0;n<e.length;++n)if(e[n].prototype.test(this)){this._sasl_success_handler=this._addSysHandler(this._sasl_success_cb.bind(this),null,"success",null,null),this._sasl_failure_handler=this._addSysHandler(this._sasl_failure_cb.bind(this),null,"failure",null,null),this._sasl_challenge_handler=this._addSysHandler(this._sasl_challenge_cb.bind(this),null,"challenge",null,null),this._sasl_mechanism=new e[n],this._sasl_mechanism.onStart(this);var r=c("auth",{xmlns:E.NS.SASL,mechanism:this._sasl_mechanism.name});if(this._sasl_mechanism.isClientFirst){var s=this._sasl_mechanism.onChallenge(this,null);r.t(btoa(s))}this.send(r.tree()),t=!0;break}return t},_attemptLegacyAuth:function(){null===E.getNodeFromJid(this.jid)?(this._changeConnectStatus(E.Status.CONNFAIL,E.ErrorCondition.MISSING_JID_NODE),this.disconnect(E.ErrorCondition.MISSING_JID_NODE)):(this._changeConnectStatus(E.Status.AUTHENTICATING,null),this._addSysHandler(this._auth1_cb.bind(this),null,null,null,"_auth_1"),this.send(u({type:"get",to:this.domain,id:"_auth_1"}).c("query",{xmlns:E.NS.AUTH}).c("username",{}).t(E.getNodeFromJid(this.jid)).tree()))},authenticate:function(e){this._attemptSASLAuth(e)||this._attemptLegacyAuth()},_sasl_challenge_cb:function(e){var t=atob(E.getText(e)),n=this._sasl_mechanism.onChallenge(this,t),r=c("response",{xmlns:E.NS.SASL});return""!==n&&r.t(btoa(n)),this.send(r.tree()),!0},_auth1_cb:function(e){var t=u({type:"set",id:"_auth_2"}).c("query",{xmlns:E.NS.AUTH}).c("username",{}).t(E.getNodeFromJid(this.jid)).up().c("password").t(this.pass);return E.getResourceFromJid(this.jid)||(this.jid=E.getBareJidFromJid(this.jid)+"/strophe"),t.up().c("resource",{}).t(E.getResourceFromJid(this.jid)),this._addSysHandler(this._auth2_cb.bind(this),null,null,null,"_auth_2"),this.send(t.tree()),!1},_sasl_success_cb:function(e){var t=this;if(this._sasl_data["server-signature"]){var n,r=atob(E.getText(e)).match(/([a-z]+)=([^,]+)(,|$)/);if("v"===r[1]&&(n=r[2]),n!==this._sasl_data["server-signature"])return this.deleteHandler(this._sasl_failure_handler),this._sasl_failure_handler=null,this._sasl_challenge_handler&&(this.deleteHandler(this._sasl_challenge_handler),this._sasl_challenge_handler=null),this._sasl_data={},this._sasl_failure_cb(null)}E.info("SASL authentication succeeded."),this._sasl_mechanism&&this._sasl_mechanism.onSuccess(),this.deleteHandler(this._sasl_failure_handler),this._sasl_failure_handler=null,this._sasl_challenge_handler&&(this.deleteHandler(this._sasl_challenge_handler),this._sasl_challenge_handler=null);var s=[],o=function(e,n){for(;e.length;)t.deleteHandler(e.pop());return t._sasl_auth1_cb(n),!1};return s.push(this._addSysHandler((function(e){return o(s,e)}),null,"stream:features",null,null)),s.push(this._addSysHandler((function(e){return o(s,e)}),E.NS.STREAM,"features",null,null)),this._sendRestart(),!1},_sasl_auth1_cb:function(e){this.features=e;for(var t=0;t<e.childNodes.length;t++){var n=e.childNodes[t];"bind"===n.nodeName&&(this.do_bind=!0),"session"===n.nodeName&&(this.do_session=!0)}if(!this.do_bind)return this._changeConnectStatus(E.Status.AUTHFAIL,null),!1;this._addSysHandler(this._sasl_bind_cb.bind(this),null,null,null,"_bind_auth_2");var r=E.getResourceFromJid(this.jid);return r?this.send(u({type:"set",id:"_bind_auth_2"}).c("bind",{xmlns:E.NS.BIND}).c("resource",{}).t(r).tree()):this.send(u({type:"set",id:"_bind_auth_2"}).c("bind",{xmlns:E.NS.BIND}).tree()),!1},_sasl_bind_cb:function(e){var t;if("error"===e.getAttribute("type"))return E.info("SASL binding failed."),e.getElementsByTagName("conflict").length>0&&(t=E.ErrorCondition.CONFLICT),this._changeConnectStatus(E.Status.AUTHFAIL,t,e),!1;var n=e.getElementsByTagName("bind");if(!(n.length>0))return E.info("SASL binding failed."),this._changeConnectStatus(E.Status.AUTHFAIL,null,e),!1;var r=n[0].getElementsByTagName("jid");r.length>0&&(this.jid=E.getText(r[0]),this.do_session?(this._addSysHandler(this._sasl_session_cb.bind(this),null,null,null,"_session_auth_2"),this.send(u({type:"set",id:"_session_auth_2"}).c("session",{xmlns:E.NS.SESSION}).tree())):(this.authenticated=!0,this._changeConnectStatus(E.Status.CONNECTED,null)))},_sasl_session_cb:function(e){if("result"===e.getAttribute("type"))this.authenticated=!0,this._changeConnectStatus(E.Status.CONNECTED,null);else if("error"===e.getAttribute("type"))return E.info("Session creation failed."),this._changeConnectStatus(E.Status.AUTHFAIL,null,e),!1;return!1},_sasl_failure_cb:function(e){return this._sasl_success_handler&&(this.deleteHandler(this._sasl_success_handler),this._sasl_success_handler=null),this._sasl_challenge_handler&&(this.deleteHandler(this._sasl_challenge_handler),this._sasl_challenge_handler=null),this._sasl_mechanism&&this._sasl_mechanism.onFailure(),this._changeConnectStatus(E.Status.AUTHFAIL,null,e),!1},_auth2_cb:function(e){return"result"===e.getAttribute("type")?(this.authenticated=!0,this._changeConnectStatus(E.Status.CONNECTED,null)):"error"===e.getAttribute("type")&&(this._changeConnectStatus(E.Status.AUTHFAIL,null,e),this.disconnect("authentication failed")),!1},_addSysTimedHandler:function(e,t){var n=new E.TimedHandler(e,t);return n.user=!1,this.addTimeds.push(n),n},_addSysHandler:function(e,t,n,r,s){var o=new E.Handler(e,t,n,r,s);return o.user=!1,this.addHandlers.push(o),o},_onDisconnectTimeout:function(){return E.info("_onDisconnectTimeout was called"),this._changeConnectStatus(E.Status.CONNTIMEOUT,null),this._proto._onDisconnectTimeout(),this._doDisconnect(),!1},_onIdle:function(){for(var e=this;this.addTimeds.length>0;)this.timedHandlers.push(this.addTimeds.pop());for(;this.removeTimeds.length>0;){var t=this.removeTimeds.pop(),n=this.timedHandlers.indexOf(t);n>=0&&this.timedHandlers.splice(n,1)}for(var r=(new Date).getTime(),s=[],o=0;o<this.timedHandlers.length;o++){var i=this.timedHandlers[o];!this.authenticated&&i.user||(i.lastCalled+i.period-r<=0?i.run()&&s.push(i):s.push(i))}this.timedHandlers=s,clearTimeout(this._idleTimeout),this._proto._onIdle(),this.connected&&(this._idleTimeout=setTimeout((function(){return e._onIdle()}),100))}},E.SASLMechanism=function(e,t,n){this.name=e,this.isClientFirst=t,this.priority=n},E.SASLMechanism.prototype={test:function(e){return!0},onStart:function(e){this._connection=e},onChallenge:function(e,t){throw new Error("You should implement challenge handling!")},onFailure:function(){this._connection=null},onSuccess:function(){this._connection=null}},E.SASLAnonymous=function(){},E.SASLAnonymous.prototype=new E.SASLMechanism("ANONYMOUS",!1,20),E.SASLAnonymous.prototype.test=function(e){return null===e.authcid},E.SASLPlain=function(){},E.SASLPlain.prototype=new E.SASLMechanism("PLAIN",!0,50),E.SASLPlain.prototype.test=function(e){return null!==e.authcid},E.SASLPlain.prototype.onChallenge=function(e){var t=e.authzid;return t+="\0",t+=e.authcid,t+="\0",t+=e.pass,o.default.utf16to8(t)},E.SASLSHA1=function(){},E.SASLSHA1.prototype=new E.SASLMechanism("SCRAM-SHA-1",!0,70),E.SASLSHA1.prototype.test=function(e){return null!==e.authcid},E.SASLSHA1.prototype.onChallenge=function(e,t,n){var i=n||r.default.hexdigest(1234567890*Math.random()),a="n="+o.default.utf16to8(e.authcid);return a+=",r=",a+=i,e._sasl_data.cnonce=i,e._sasl_data["client-first-message-bare"]=a,a="n,,"+a,this.onChallenge=function(e,t){for(var n,r,i,a,c,u,l,E,d="c=biws,",h="".concat(e._sasl_data["client-first-message-bare"],",").concat(t,","),p=e._sasl_data.cnonce,S=/([a-z]+)=([^,]+)(,|$)/;t.match(S);){var g=t.match(S);switch(t=t.replace(g[0],""),g[1]){case"r":n=g[2];break;case"s":r=g[2];break;case"i":i=g[2]}}if(n.substr(0,p.length)!==p)return e._sasl_data={},e._sasl_failure_cb();h+=d+="r="+n,r=atob(r),r+="\0\0\0";var C=o.default.utf16to8(e.pass);for(a=u=s.default.core_hmac_sha1(C,r),l=1;l<i;l++){for(c=s.default.core_hmac_sha1(C,s.default.binb2str(u)),E=0;E<5;E++)a[E]^=c[E];u=c}a=s.default.binb2str(a);var _=s.default.core_hmac_sha1(a,"Client Key"),f=s.default.str_hmac_sha1(a,"Server Key"),T=s.default.core_hmac_sha1(s.default.str_sha1(s.default.binb2str(_)),h);for(e._sasl_data["server-signature"]=s.default.b64_hmac_sha1(f,h),E=0;E<5;E++)_[E]^=T[E];return d+=",p="+btoa(s.default.binb2str(_))},a},E.SASLMD5=function(){},E.SASLMD5.prototype=new E.SASLMechanism("DIGEST-MD5",!1,60),E.SASLMD5.prototype.test=function(e){return null!==e.authcid},E.SASLMD5.prototype._quote=function(e){return'"'+e.replace(/\\/g,"\\\\").replace(/"/g,'\\"')+'"'},E.SASLMD5.prototype.onChallenge=function(e,t,n){for(var s=/([a-z]+)=("[^"]+"|[^,"]+)(?:,|$)/,i=n||r.default.hexdigest(""+1234567890*Math.random()),a="",c=null,u="";t.match(s);){var l=t.match(s);switch(t=t.replace(l[0],""),l[2]=l[2].replace(/^"(.+)"$/,"$1"),l[1]){case"realm":a=l[2];break;case"nonce":u=l[2];break;case"qop":l[2];break;case"host":c=l[2]}}var E=e.servtype+"/"+e.domain;null!==c&&(E=E+"/"+c);var d=o.default.utf16to8(e.authcid+":"+a+":"+this._connection.pass),h=r.default.hash(d)+":"+u+":"+i,p="AUTHENTICATE:"+E,S="";return S+="charset=utf-8,",S+="username="+this._quote(o.default.utf16to8(e.authcid))+",",S+="realm="+this._quote(a)+",",S+="nonce="+this._quote(u)+",",S+="nc=00000001,",S+="cnonce="+this._quote(i)+",",S+="digest-uri="+this._quote(E)+",",S+="response="+r.default.hexdigest(r.default.hexdigest(h)+":"+u+":00000001:"+i+":auth:"+r.default.hexdigest(p))+",",S+="qop=auth",this.onChallenge=function(){return""},S},E.SASLOAuthBearer=function(){},E.SASLOAuthBearer.prototype=new E.SASLMechanism("OAUTHBEARER",!0,40),E.SASLOAuthBearer.prototype.test=function(e){return null!==e.pass},E.SASLOAuthBearer.prototype.onChallenge=function(e){var t="n,";return null!==e.authcid&&(t=t+"a="+e.authzid),t+=",",t+="",t+="auth=Bearer ",t+=e.pass,t+="",t+="",o.default.utf16to8(t)},E.SASLExternal=function(){},E.SASLExternal.prototype=new E.SASLMechanism("EXTERNAL",!0,10),E.SASLExternal.prototype.onChallenge=function(e){return e.authcid===e.authzid?"":e.authzid},E.SASLXOAuth2=function(){},E.SASLXOAuth2.prototype=new E.SASLMechanism("X-OAUTH2",!0,30),E.SASLXOAuth2.prototype.test=function(e){return null!==e.pass},E.SASLXOAuth2.prototype.onChallenge=function(e){var t="\0";return null!==e.authcid&&(t+=e.authzid),t+="\0",t+=e.pass,o.default.utf16to8(t)},t.default={Strophe:E,$build:c,$iq:u,$msg:function(e){return new E.Builder("message",e)},$pres:l,SHA1:s.default,MD5:r.default,b64_hmac_sha1:s.default.b64_hmac_sha1,b64_sha1:s.default.b64_sha1,str_hmac_sha1:s.default.str_hmac_sha1,str_sha1:s.default.str_sha1}},"./src/md5.js":function(e,t,n){"use strict";n.r(t),n.d(t,"default",(function(){return E}));var r=function(e,t){var n=(65535&e)+(65535&t);return(e>>16)+(t>>16)+(n>>16)<<16|65535&n},s=function(e){for(var t=[],n=0;n<8*e.length;n+=8)t[n>>5]|=(255&e.charCodeAt(n/8))<<n%32;return t},o=function(e,t,n,s,o,i){return r((a=r(r(t,e),r(s,i)))<<(c=o)|a>>>32-c,n);var a,c},i=function(e,t,n,r,s,i,a){return o(t&n|~t&r,e,t,s,i,a)},a=function(e,t,n,r,s,i,a){return o(t&r|n&~r,e,t,s,i,a)},c=function(e,t,n,r,s,i,a){return o(t^n^r,e,t,s,i,a)},u=function(e,t,n,r,s,i,a){return o(n^(t|~r),e,t,s,i,a)},l=function(e,t){e[t>>5]|=128<<t%32,e[14+(t+64>>>9<<4)]=t;for(var n,s,o,l,E=1732584193,d=-271733879,h=-1732584194,p=271733878,S=0;S<e.length;S+=16)n=E,s=d,o=h,l=p,E=i(E,d,h,p,e[S+0],7,-680876936),p=i(p,E,d,h,e[S+1],12,-389564586),h=i(h,p,E,d,e[S+2],17,606105819),d=i(d,h,p,E,e[S+3],22,-1044525330),E=i(E,d,h,p,e[S+4],7,-176418897),p=i(p,E,d,h,e[S+5],12,1200080426),h=i(h,p,E,d,e[S+6],17,-1473231341),d=i(d,h,p,E,e[S+7],22,-45705983),E=i(E,d,h,p,e[S+8],7,1770035416),p=i(p,E,d,h,e[S+9],12,-1958414417),h=i(h,p,E,d,e[S+10],17,-42063),d=i(d,h,p,E,e[S+11],22,-1990404162),E=i(E,d,h,p,e[S+12],7,1804603682),p=i(p,E,d,h,e[S+13],12,-40341101),h=i(h,p,E,d,e[S+14],17,-1502002290),d=i(d,h,p,E,e[S+15],22,1236535329),E=a(E,d,h,p,e[S+1],5,-165796510),p=a(p,E,d,h,e[S+6],9,-1069501632),h=a(h,p,E,d,e[S+11],14,643717713),d=a(d,h,p,E,e[S+0],20,-373897302),E=a(E,d,h,p,e[S+5],5,-701558691),p=a(p,E,d,h,e[S+10],9,38016083),h=a(h,p,E,d,e[S+15],14,-660478335),d=a(d,h,p,E,e[S+4],20,-405537848),E=a(E,d,h,p,e[S+9],5,568446438),p=a(p,E,d,h,e[S+14],9,-1019803690),h=a(h,p,E,d,e[S+3],14,-187363961),d=a(d,h,p,E,e[S+8],20,1163531501),E=a(E,d,h,p,e[S+13],5,-1444681467),p=a(p,E,d,h,e[S+2],9,-51403784),h=a(h,p,E,d,e[S+7],14,1735328473),d=a(d,h,p,E,e[S+12],20,-1926607734),E=c(E,d,h,p,e[S+5],4,-378558),p=c(p,E,d,h,e[S+8],11,-2022574463),h=c(h,p,E,d,e[S+11],16,1839030562),d=c(d,h,p,E,e[S+14],23,-35309556),E=c(E,d,h,p,e[S+1],4,-1530992060),p=c(p,E,d,h,e[S+4],11,1272893353),h=c(h,p,E,d,e[S+7],16,-155497632),d=c(d,h,p,E,e[S+10],23,-1094730640),E=c(E,d,h,p,e[S+13],4,681279174),p=c(p,E,d,h,e[S+0],11,-358537222),h=c(h,p,E,d,e[S+3],16,-722521979),d=c(d,h,p,E,e[S+6],23,76029189),E=c(E,d,h,p,e[S+9],4,-640364487),p=c(p,E,d,h,e[S+12],11,-421815835),h=c(h,p,E,d,e[S+15],16,530742520),d=c(d,h,p,E,e[S+2],23,-995338651),E=u(E,d,h,p,e[S+0],6,-198630844),p=u(p,E,d,h,e[S+7],10,1126891415),h=u(h,p,E,d,e[S+14],15,-1416354905),d=u(d,h,p,E,e[S+5],21,-57434055),E=u(E,d,h,p,e[S+12],6,1700485571),p=u(p,E,d,h,e[S+3],10,-1894986606),h=u(h,p,E,d,e[S+10],15,-1051523),d=u(d,h,p,E,e[S+1],21,-2054922799),E=u(E,d,h,p,e[S+8],6,1873313359),p=u(p,E,d,h,e[S+15],10,-30611744),h=u(h,p,E,d,e[S+6],15,-1560198380),d=u(d,h,p,E,e[S+13],21,1309151649),E=u(E,d,h,p,e[S+4],6,-145523070),p=u(p,E,d,h,e[S+11],10,-1120210379),h=u(h,p,E,d,e[S+2],15,718787259),d=u(d,h,p,E,e[S+9],21,-343485551),E=r(E,n),d=r(d,s),h=r(h,o),p=r(p,l);return[E,d,h,p]},E={hexdigest:function(e){return function(e){for(var t="0123456789abcdef",n="",r=0;r<4*e.length;r++)n+=t.charAt(e[r>>2]>>r%4*8+4&15)+t.charAt(e[r>>2]>>r%4*8&15);return n}(l(s(e),8*e.length))},hash:function(e){return function(e){for(var t="",n=0;n<32*e.length;n+=8)t+=String.fromCharCode(e[n>>5]>>>n%32&255);return t}(l(s(e),8*e.length))}}},"./src/sha1.js":function(e,t,n){"use strict";function r(e,t){e[t>>5]|=128<<24-t%32,e[15+(t+64>>9<<4)]=t;var n,r,i,u,l,E,d,h,p=new Array(80),S=1732584193,g=-271733879,C=-1732584194,_=271733878,f=-1009589776;for(n=0;n<e.length;n+=16){for(u=S,l=g,E=C,d=_,h=f,r=0;r<80;r++)p[r]=r<16?e[n+r]:c(p[r-3]^p[r-8]^p[r-14]^p[r-16],1),i=a(a(c(S,5),s(r,g,C,_)),a(a(f,p[r]),o(r))),f=_,_=C,C=c(g,30),g=S,S=i;S=a(S,u),g=a(g,l),C=a(C,E),_=a(_,d),f=a(f,h)}return[S,g,C,_,f]}function s(e,t,n,r){return e<20?t&n|~t&r:e<40?t^n^r:e<60?t&n|t&r|n&r:t^n^r}function o(e){return e<20?1518500249:e<40?1859775393:e<60?-1894007588:-899497514}function i(e,t){var n=u(e);n.length>16&&(n=r(n,8*e.length));for(var s=new Array(16),o=new Array(16),i=0;i<16;i++)s[i]=909522486^n[i],o[i]=1549556828^n[i];var a=r(s.concat(u(t)),512+8*t.length);return r(o.concat(a),672)}function a(e,t){var n=(65535&e)+(65535&t);return(e>>16)+(t>>16)+(n>>16)<<16|65535&n}function c(e,t){return e<<t|e>>>32-t}function u(e){for(var t=[],n=0;n<8*e.length;n+=8)t[n>>5]|=(255&e.charCodeAt(n/8))<<24-n%32;return t}function l(e){for(var t,n,r="",s=0;s<4*e.length;s+=3)for(t=(e[s>>2]>>8*(3-s%4)&255)<<16|(e[s+1>>2]>>8*(3-(s+1)%4)&255)<<8|e[s+2>>2]>>8*(3-(s+2)%4)&255,n=0;n<4;n++)8*s+6*n>32*e.length?r+="=":r+="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/".charAt(t>>6*(3-n)&63);return r}function E(e){for(var t="",n=0;n<32*e.length;n+=8)t+=String.fromCharCode(e[n>>5]>>>24-n%32&255);return t}n.r(t),n.d(t,"default",(function(){return d}));var d={b64_hmac_sha1:function(e,t){return l(i(e,t))},b64_sha1:function(e){return l(r(u(e),8*e.length))},binb2str:E,core_hmac_sha1:i,str_hmac_sha1:function(e,t){return E(i(e,t))},str_sha1:function(e){return E(r(u(e),8*e.length))}}},"./src/strophe.js":function(e,t,n){"use strict";n.r(t),n("./src/bosh.js"),n("./src/websocket.js");var r=n("./src/core.js");n.d(t,"default",(function(){return r.default}))},"./src/utils.js":function(e,t,n){"use strict";function r(e){return r="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},r(e)}n.r(t),n.d(t,"default",(function(){return s}));var s={utf16to8:function(e){var t,n,r="",s=e.length;for(t=0;t<s;t++)(n=e.charCodeAt(t))>=0&&n<=127?r+=e.charAt(t):n>2047?(r+=String.fromCharCode(224|n>>12&15),r+=String.fromCharCode(128|n>>6&63),r+=String.fromCharCode(128|n>>0&63)):(r+=String.fromCharCode(192|n>>6&31),r+=String.fromCharCode(128|n>>0&63));return r},addCookies:function(e){for(var t in e=e||{})if(Object.prototype.hasOwnProperty.call(e,t)){var n="",s="",o="",i=e[t],a="object"===r(i),c=escape(unescape(a?i.value:i));a&&(n=i.expires?";expires="+i.expires:"",s=i.domain?";domain="+i.domain:"",o=i.path?";path="+i.path:""),document.cookie=t+"="+c+n+s+o}}}},"./src/websocket.js":function(e,t,n){"use strict";n.r(t);var r=n("./src/core.js"),s=r.default.Strophe,o=r.default.$build;s.Websocket=function(e){this._conn=e,this.strip="wrapper";var t=e.service;if(0!==t.indexOf("ws:")&&0!==t.indexOf("wss:")){var n="";"ws"===e.options.protocol&&"https:"!==window.location.protocol?n+="ws":n+="wss",n+="://"+window.location.host,0!==t.indexOf("/")?n+=window.location.pathname+t:n+=t,e.service=n}},s.Websocket.prototype={_buildStream:function(){return o("open",{xmlns:s.NS.FRAMING,to:this._conn.domain,version:"1.0"})},_check_streamerror:function(e,t){var n;if(0===(n=e.getElementsByTagNameNS?e.getElementsByTagNameNS(s.NS.STREAM,"error"):e.getElementsByTagName("stream:error")).length)return!1;for(var r=n[0],o="",i="",a=0;a<r.childNodes.length;a++){var c=r.childNodes[a];if("urn:ietf:params:xml:ns:xmpp-streams"!==c.getAttribute("xmlns"))break;"text"===c.nodeName?i=c.textContent:o=c.nodeName}var u="WebSocket stream error: ";return u+=o||"unknown",i&&(u+=" - "+i),s.error(u),this._conn._changeConnectStatus(t,o),this._conn._doDisconnect(),!0},_reset:function(){},_connect:function(){this._closeSocket(),this.socket=new WebSocket(this._conn.service,"xmpp"),this.socket.onopen=this._onOpen.bind(this),this.socket.onerror=this._onError.bind(this),this.socket.onclose=this._onClose.bind(this),this.socket.onmessage=this._connect_cb_wrapper.bind(this)},_connect_cb:function(e){if(this._check_streamerror(e,s.Status.CONNFAIL))return s.Status.CONNFAIL},_handleStreamStart:function(e){var t=!1,n=e.getAttribute("xmlns");"string"!=typeof n?t="Missing xmlns in <open />":n!==s.NS.FRAMING&&(t="Wrong xmlns in <open />: "+n);var r=e.getAttribute("version");return"string"!=typeof r?t="Missing version in <open />":"1.0"!==r&&(t="Wrong version in <open />: "+r),!t||(this._conn._changeConnectStatus(s.Status.CONNFAIL,t),this._conn._doDisconnect(),!1)},_connect_cb_wrapper:function(e){if(0===e.data.indexOf("<open ")||0===e.data.indexOf("<?xml")){var t=e.data.replace(/^(<\?.*?\?>\s*)*/,"");if(""===t)return;var n=(new DOMParser).parseFromString(t,"text/xml").documentElement;this._conn.xmlInput(n),this._conn.rawInput(e.data),this._handleStreamStart(n)&&this._connect_cb(n)}else if(0===e.data.indexOf("<close ")){var r=(new DOMParser).parseFromString(e.data,"text/xml").documentElement;this._conn.xmlInput(r),this._conn.rawInput(e.data);var o=r.getAttribute("see-other-uri");if(o){var i=this._conn.service;(i.indexOf("wss:")>=0&&o.indexOf("wss:")>=0||i.indexOf("ws:")>=0)&&(this._conn._changeConnectStatus(s.Status.REDIRECT,"Received see-other-uri, resetting connection"),this._conn.reset(),this._conn.service=o,this._connect())}else this._conn._changeConnectStatus(s.Status.CONNFAIL,"Received closing stream"),this._conn._doDisconnect()}else{var a=this._streamWrap(e.data),c=(new DOMParser).parseFromString(a,"text/xml").documentElement;this.socket.onmessage=this._onMessage.bind(this),this._conn._connect_cb(c,null,e.data)}},_disconnect:function(e){if(this.socket&&this.socket.readyState!==WebSocket.CLOSED){e&&this._conn.send(e);var t=o("close",{xmlns:s.NS.FRAMING});this._conn.xmlOutput(t.tree());var n=s.serialize(t);this._conn.rawOutput(n);try{this.socket.send(n)}catch(e){s.info("Couldn't send <close /> tag.")}}this._conn._doDisconnect()},_doDisconnect:function(){s.info("WebSockets _doDisconnect was called"),this._closeSocket()},_streamWrap:function(e){return"<wrapper>"+e+"</wrapper>"},_closeSocket:function(){if(this.socket)try{this.socket.onerror=null,this.socket.close()}catch(e){s.debug(e.message)}this.socket=null},_emptyQueue:function(){return!0},_onClose:function(e){this._conn.connected&&!this._conn.disconnecting?(s.error("Websocket closed unexpectedly"),this._conn._doDisconnect()):e&&1006===e.code&&!this._conn.connected&&this.socket?(s.error("Websocket closed unexcectedly"),this._conn._changeConnectStatus(s.Status.CONNFAIL,"The WebSocket connection could not be established or was disconnected."),this._conn._doDisconnect()):s.info("Websocket closed")},_no_auth_received:function(e){s.error("Server did not offer a supported authentication mechanism"),this._changeConnectStatus(s.Status.CONNFAIL,s.ErrorCondition.NO_AUTH_MECH),e&&e.call(this._conn),this._conn._doDisconnect()},_onDisconnectTimeout:function(){},_abortAllRequests:function(){},_onError:function(e){s.error("Websocket error "+e),this._conn._changeConnectStatus(s.Status.CONNFAIL,"The WebSocket connection could not be established or was disconnected."),this._disconnect()},_onIdle:function(){var e=this._conn._data;if(e.length>0&&!this._conn.paused){for(var t=0;t<e.length;t++)if(null!==e[t]){var n=void 0;n="restart"===e[t]?this._buildStream().tree():e[t];var r=s.serialize(n);this._conn.xmlOutput(n),this._conn.rawOutput(r),this.socket.send(r)}this._conn._data=[]}},_onMessage:function(e){var t,n='<close xmlns="urn:ietf:params:xml:ns:xmpp-framing" />';if(e.data===n)return this._conn.rawInput(n),this._conn.xmlInput(e),void(this._conn.disconnecting||this._conn._doDisconnect());if(0===e.data.search("<open ")){if(t=(new DOMParser).parseFromString(e.data,"text/xml").documentElement,!this._handleStreamStart(t))return}else{var r=this._streamWrap(e.data);t=(new DOMParser).parseFromString(r,"text/xml").documentElement}return this._check_streamerror(t,s.Status.ERROR)?void 0:this._conn.disconnecting&&"presence"===t.firstChild.nodeName&&"unavailable"===t.firstChild.getAttribute("type")?(this._conn.xmlInput(t),void this._conn.rawInput(s.serialize(t))):void this._conn._dataRecv(t,e.data)},_onOpen:function(){s.info("Websocket open");var e=this._buildStream();this._conn.xmlOutput(e.tree());var t=s.serialize(e);this._conn.rawOutput(t),this.socket.send(t)},_reqToData:function(e){return e},_send:function(){this._conn.flush()},_sendRestart:function(){clearTimeout(this._conn._idleTimeout),this._conn._onIdle.bind(this._conn)()}}}}).default},e.exports=r()},function(e,t,n){"use strict";t.__esModule=!0;var r=n(6),s=n(0),o=n(1),i=function(){function e(){}return e.trasformJSONGroup=function(e){var t;try{t=new r.Group(e[s.GroupConstants.KEYS.GUID],e[s.GroupConstants.KEYS.NAME],e[s.GroupConstants.KEYS.TYPE]),e.wsChannel&&delete e.wsChannel,Object.assign(t,e),e=t}catch(e){o.Logger.error("GroupsController:transformJSONGroup",e)}return e},e}();t.GroupsController=i},function(e,t,n){"use strict";function r(e,t){return void 0===t&&(t=Object),t&&"function"==typeof t.freeze?t.freeze(e):e}var s=r({HTML:"text/html",isHTML:function(e){return e===s.HTML},XML_APPLICATION:"application/xml",XML_TEXT:"text/xml",XML_XHTML_APPLICATION:"application/xhtml+xml",XML_SVG_IMAGE:"image/svg+xml"}),o=r({HTML:"http://www.w3.org/1999/xhtml",isHTML:function(e){return e===o.HTML},SVG:"http://www.w3.org/2000/svg",XML:"http://www.w3.org/XML/1998/namespace",XMLNS:"http://www.w3.org/2000/xmlns/"});t.freeze=r,t.MIME_TYPE=s,t.NAMESPACE=o},function(e,t,n){"use strict";var r,s=this&&this.__extends||(r=function(e,t){return r=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)t.hasOwnProperty(n)&&(e[n]=t[n])},r(e,t)},function(e,t){function n(){this.constructor=e}r(e,t),e.prototype=null===t?Object.create(t):(n.prototype=t.prototype,new n)}),o=this&&this.__assign||function(){return o=Object.assign||function(e){for(var t,n=1,r=arguments.length;n<r;n++)for(var s in t=arguments[n])Object.prototype.hasOwnProperty.call(t,s)&&(e[s]=t[s]);return e},o.apply(this,arguments)};t.__esModule=!0;var i=n(10),a=n(0),c=n(4),u=n(6),l=n(1),E=function(e){function t(t,n,r){var s=e.call(this,t,"text",r,a.MessageCategory.MESSAGE)||this;return s.type="text",s.data={text:n},s.text=n,s}return s(t,e),t.prototype.getSender=function(){try{return this.getSenderFromData()}catch(e){return this.sender}},t.prototype.getReceiver=function(){try{return this.getReceiverFromData()}catch(e){return this.receiver}},t.prototype.getMetadata=function(){return this.data.metadata&&(this.metadata=this.data.metadata),this.metadata},t.prototype.setMetadata=function(e){this.metadata=e,this.data=o({},this.data,{metadata:e})},t.prototype.getData=function(){return this.data},t.prototype.setData=function(e){this.data=e},t.prototype.getText=function(){return this.text},t.prototype.setText=function(e){this.text=e,this.data.text=e},t.prototype.setProcessedText=function(e){this.processedText=e},t.prototype.getProcessedText=function(){return this.processedText},t.prototype.getSenderFromData=function(){try{var e=this.getData();if(e[a.ResponseConstants.RESPONSE_KEYS.KEY_ENTITIES][a.MessageConstatnts.KEYS.SENDER][a.ResponseConstants.RESPONSE_KEYS.KEY_ENTITITY])return new c.User(e[a.ResponseConstants.RESPONSE_KEYS.KEY_ENTITIES][a.MessageConstatnts.KEYS.SENDER][a.ResponseConstants.RESPONSE_KEYS.KEY_ENTITITY])}catch(e){l.Logger.error("TextMessageModel: getSenderFromData",e)}},t.prototype.getReceiverFromData=function(){try{var e=this.getData(),t=e[a.ResponseConstants.RESPONSE_KEYS.KEY_ENTITIES][a.MessageConstatnts.KEYS.RECEIVER][a.ResponseConstants.RESPONSE_KEYS.KEY_ENTITITY];if(e[a.ResponseConstants.RESPONSE_KEYS.KEY_ENTITIES][a.MessageConstatnts.KEYS.RECEIVER][a.ResponseConstants.RESPONSE_KEYS.KEY_ENTITYTYPE]==[a.ResponseConstants.RESPONSE_KEYS.KEY_ENTITY_TYPE.USER])return new c.User(t);var n=new u.Group(t[a.GroupConstants.KEYS.GUID],t[a.GroupConstants.KEYS.NAME],t[a.MessageConstatnts.KEYS.TYPE]);return Object.assign(n,t)}catch(e){l.Logger.error("TextMessageModel: getReceiverFromData",e)}},t.TYPE=a.MessageConstatnts.TYPE.TEXT,t.RECEIVER_TYPE=a.MessageConstatnts.RECEIVER_TYPE,t.CATEGORY=a.MessageConstatnts.CATEGORY.MESSAGE,t}(i.BaseMessage);t.TextMessage=E},function(e,t,n){"use strict";var r,s=this&&this.__extends||(r=function(e,t){return r=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)t.hasOwnProperty(n)&&(e[n]=t[n])},r(e,t)},function(e,t){function n(){this.constructor=e}r(e,t),e.prototype=null===t?Object.create(t):(n.prototype=t.prototype,new n)}),o=this&&this.__assign||function(){return o=Object.assign||function(e){for(var t,n=1,r=arguments.length;n<r;n++)for(var s in t=arguments[n])Object.prototype.hasOwnProperty.call(t,s)&&(e[s]=t[s]);return e},o.apply(this,arguments)};t.__esModule=!0;var i=n(10),a=n(0),c=n(4),u=n(20),l=n(6),E=n(1),d=function(e){function t(t,n,r,s){var o=e.call(this,t,r,s,a.MessageCategory.MESSAGE)||this;return o.data={},"object"!=typeof n?o.data={url:n}:o.file=n,o}return s(t,e),t.prototype.setCaption=function(e){this.caption=e,this.data[a.MessageConstatnts.KEYS.TEXT]=e},t.prototype.getCaption=function(){return this.data[a.MessageConstatnts.KEYS.TEXT]},t.prototype.getSender=function(){try{return this.getSenderFromData()}catch(e){return this.sender}},t.prototype.getReceiver=function(){try{return this.getReceiverFromData()}catch(e){return this.receiver}},t.prototype.getMetadata=function(){return this.data.metadata&&(this.metadata=this.data.metadata),this.metadata},t.prototype.setMetadata=function(e){this.metadata=e,this.data=o({},this.data,{metadata:e})},t.prototype.getData=function(){return this.data},t.prototype.setData=function(e){this.data=e},t.prototype.getAttachment=function(){return new u.Attachment(this.data.attachments[0])},t.prototype.setAttachment=function(e){this.data.attachments=[e.toJSON(e)]},t.prototype.getURL=function(){try{var e=this.getData();if(e[a.MessageConstatnts.KEYS.URL])return e[a.MessageConstatnts.KEYS.URL]}catch(e){E.Logger.error("MediaMessageModel: getURL",e)}},t.prototype.getSenderFromData=function(){try{var e=this.getData();if(e[a.ResponseConstants.RESPONSE_KEYS.KEY_ENTITIES][a.MessageConstatnts.KEYS.SENDER][a.ResponseConstants.RESPONSE_KEYS.KEY_ENTITITY])return new c.User(e[a.ResponseConstants.RESPONSE_KEYS.KEY_ENTITIES][a.MessageConstatnts.KEYS.SENDER][a.ResponseConstants.RESPONSE_KEYS.KEY_ENTITITY])}catch(e){E.Logger.error("MediaMessageModel: getSenderFromData",e)}},t.prototype.getReceiverFromData=function(){try{var e=this.getData(),t=e[a.ResponseConstants.RESPONSE_KEYS.KEY_ENTITIES][a.MessageConstatnts.KEYS.RECEIVER][a.ResponseConstants.RESPONSE_KEYS.KEY_ENTITITY];if(e[a.ResponseConstants.RESPONSE_KEYS.KEY_ENTITIES][a.MessageConstatnts.KEYS.RECEIVER][a.ResponseConstants.RESPONSE_KEYS.KEY_ENTITYTYPE]==[a.ResponseConstants.RESPONSE_KEYS.KEY_ENTITY_TYPE.USER])return new c.User(t);var n=new l.Group(t[a.GroupConstants.KEYS.GUID],t[a.GroupConstants.KEYS.NAME],t[a.MessageConstatnts.KEYS.TYPE]);return Object.assign(n,t)}catch(e){E.Logger.error("MediaMessageModel: getReceiverFromData",e)}},t.TYPE=a.MessageConstatnts.TYPE,t.RECEIVER_TYPE=a.MessageConstatnts.RECEIVER_TYPE,t.CATEGORY=a.MessageConstatnts.CATEGORY,t}(i.BaseMessage);t.MediaMessage=d},function(e,t,n){"use strict";t.__esModule=!0;var r=n(0),s=function(){function e(e){e.hasOwnProperty(r.ATTACHMENTS_CONSTANTS.KEYS.EXTENSION)&&(this.extension=e[r.ATTACHMENTS_CONSTANTS.KEYS.EXTENSION]),e.hasOwnProperty(r.ATTACHMENTS_CONSTANTS.KEYS.MIME_TYPE)&&(this.mimeType=e[r.ATTACHMENTS_CONSTANTS.KEYS.MIME_TYPE]),e.hasOwnProperty(r.ATTACHMENTS_CONSTANTS.KEYS.NAME)&&(this.name=e[r.ATTACHMENTS_CONSTANTS.KEYS.NAME]),e.hasOwnProperty(r.ATTACHMENTS_CONSTANTS.KEYS.SIZE)&&(this.size=e[r.ATTACHMENTS_CONSTANTS.KEYS.SIZE]),e.hasOwnProperty(r.ATTACHMENTS_CONSTANTS.KEYS.URL)&&(this.url=e[r.ATTACHMENTS_CONSTANTS.KEYS.URL])}return e.prototype.createFileFromJSON=function(t){return new e(t)},e.prototype.toJSON=function(e){return{extension:e.getExtension(),mimeType:e.getMimeType(),name:e.getName(),url:e.getUrl(),size:e.getSize()}},e.prototype.getExtension=function(){return this.extension},e.prototype.setExtension=function(e){this.extension=e},e.prototype.getMimeType=function(){return this.mimeType},e.prototype.setMimeType=function(e){this.mimeType=e},e.prototype.getName=function(){return this.name},e.prototype.setName=function(e){this.name=e},e.prototype.getSize=function(){return this.size},e.prototype.setSize=function(e){this.size=e},e.prototype.getUrl=function(){return this.url},e.prototype.setUrl=function(e){this.url=e},e}();t.Attachment=s},function(e,t,n){"use strict";var r,s=this&&this.__extends||(r=function(e,t){return r=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)t.hasOwnProperty(n)&&(e[n]=t[n])},r(e,t)},function(e,t){function n(){this.constructor=e}r(e,t),e.prototype=null===t?Object.create(t):(n.prototype=t.prototype,new n)}),o=this&&this.__assign||function(){return o=Object.assign||function(e){for(var t,n=1,r=arguments.length;n<r;n++)for(var s in t=arguments[n])Object.prototype.hasOwnProperty.call(t,s)&&(e[s]=t[s]);return e},o.apply(this,arguments)};t.__esModule=!0;var i=n(10),a=n(0),c=n(4),u=n(1),l=n(6),E=function(e){function t(){for(var t=[],n=0;n<arguments.length;n++)t[n]=arguments[n];var r=this;if(3==t.length){var s=t[0],o=t[1],i=t[2];r=e.call(this,s,a.MessageConstatnts.TYPE.CUSTOM,o,a.MessageCategory.MESSAGE)||this,("object"!=typeof i||Array.isArray(i))&&(i={}),r.customData=i,u.isFalsy(r.data)&&(r.data={}),r.data[a.MessageConstatnts.KEYS.CUSTOM_DATA]=i}if(4==t.length){s=t[0],o=t[1];var c=t[2];i=t[3];r=e.call(this,s,c,o,a.MessageCategory.CUSTOM)||this,("object"!=typeof i||Array.isArray(i))&&(i={}),r.customData=i,u.isFalsy(r.data)&&(r.data={}),r.data[a.MessageConstatnts.KEYS.CUSTOM_DATA]=i}return r}return s(t,e),t.prototype.getCustomData=function(){return this.customData},t.prototype.setCustomData=function(e){this.customData=e,this.data[a.MessageConstatnts.KEYS.CUSTOM_DATA]=e},t.prototype.getSender=function(){try{return this.getSenderFromData()}catch(e){return this.sender}},t.prototype.getReceiver=function(){try{return this.getReceiverFromData()}catch(e){return this.receiver}},t.prototype.getSubType=function(){return this.subType},t.prototype.setSubType=function(e){this.subType=e,this.data=o({},this.data,{subType:e})},t.prototype.getMetadata=function(){return this.metadata},t.prototype.setMetadata=function(e){this.metadata=e,this.data=o({},this.data,{metadata:e})},t.prototype.getData=function(){return this.data},t.prototype.getSenderFromData=function(){try{var e=this.getData();if(e[a.ResponseConstants.RESPONSE_KEYS.KEY_ENTITIES][a.MessageConstatnts.KEYS.SENDER][a.ResponseConstants.RESPONSE_KEYS.KEY_ENTITITY])return new c.User(e[a.ResponseConstants.RESPONSE_KEYS.KEY_ENTITIES][a.MessageConstatnts.KEYS.SENDER][a.ResponseConstants.RESPONSE_KEYS.KEY_ENTITITY])}catch(e){u.Logger.error("CustomMessageModel: getSenderFromData",e)}},t.prototype.getReceiverFromData=function(){try{var e=this.getData(),t=e[a.ResponseConstants.RESPONSE_KEYS.KEY_ENTITIES][a.MessageConstatnts.KEYS.RECEIVER][a.ResponseConstants.RESPONSE_KEYS.KEY_ENTITITY];if(e[a.ResponseConstants.RESPONSE_KEYS.KEY_ENTITIES][a.MessageConstatnts.KEYS.RECEIVER][a.ResponseConstants.RESPONSE_KEYS.KEY_ENTITYTYPE]==[a.ResponseConstants.RESPONSE_KEYS.KEY_ENTITY_TYPE.USER])return new c.User(t);var n=new l.Group(t[a.GroupConstants.KEYS.GUID],t[a.GroupConstants.KEYS.NAME],t[a.MessageConstatnts.KEYS.TYPE]);return Object.assign(n,t)}catch(e){u.Logger.error("CustomMessageModel: getReceiverFromData",e)}},t}(i.BaseMessage);t.CustomMessage=E},function(e,t,n){"use strict";var r,s=this&&this.__extends||(r=function(e,t){return r=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)t.hasOwnProperty(n)&&(e[n]=t[n])},r(e,t)},function(e,t){function n(){this.constructor=e}r(e,t),e.prototype=null===t?Object.create(t):(n.prototype=t.prototype,new n)});t.__esModule=!0;var o=n(1),i=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];this.onAction=void 0,this.onTextMessageReceived=void 0,this.onMediaMessageReceived=void 0,this.onCustomMessageReceived=void 0,this.onCall=void 0,this.onTypingStarted=void 0,this.onTypingEnded=void 0,this.onMessagesDelivered=void 0,this.onMessagesRead=void 0,this.onMessageEdited=void 0,this.onMessageDeleted=void 0,o.isFalsy(e[0].onAction)||(this.onAction=e[0].onAction),o.isFalsy(e[0].onTextMessageReceived)||(this.onTextMessageReceived=e[0].onTextMessageReceived),o.isFalsy(e[0].onMediaMessageReceived)||(this.onMediaMessageReceived=e[0].onMediaMessageReceived),o.isFalsy(e[0].onCall)||(this.onCall=e[0].onCall),o.isFalsy(e[0].onTypingStarted)||(this.onTypingStarted=e[0].onTypingStarted),o.isFalsy(e[0].onTypingEnded)||(this.onTypingEnded=e[0].onTypingEnded),o.isFalsy(e[0].onMessagesDelivered)||(this.onMessagesDelivered=e[0].onMessagesDelivered),o.isFalsy(e[0].onMessagesRead)||(this.onMessagesRead=e[0].onMessagesRead),o.isFalsy(e[0].onCustomMessageReceived)||(this.onCustomMessageReceived=e[0].onCustomMessageReceived),o.isFalsy(e[0].onMessageEdited)||(this.onMessageEdited=e[0].onMessageEdited),o.isFalsy(e[0].onMessageDeleted)||(this.onMessageDeleted=e[0].onMessageDeleted)};t.MessageEventListener=i;var a=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];this.onIncomingCallReceived=void 0,this.onOutgoingCallAccepted=void 0,this.onOutgoingCallRejected=void 0,this.onIncomingCallCancelled=void 0,o.isFalsy(e[0].onIncomingCallReceived)||(this.onIncomingCallReceived=e[0].onIncomingCallReceived),o.isFalsy(e[0].onOutgoingCallAccepted)||(this.onOutgoingCallAccepted=e[0].onOutgoingCallAccepted),o.isFalsy(e[0].onOutgoingCallRejected)||(this.onOutgoingCallRejected=e[0].onOutgoingCallRejected),o.isFalsy(e[0].onIncomingCallCancelled)||(this.onIncomingCallCancelled=e[0].onIncomingCallCancelled)};t.CallEventListener=a;var c=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];o.isFalsy(e[0].onUserOnline)||(this.onUserOnline=e[0].onUserOnline),o.isFalsy(e[0].onUserOffline)||(this.onUserOffline=e[0].onUserOffline)};t.UserEventListener=c;var u=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];o.isFalsy(e[0].onGroupMemberJoined)||(this.onUserJoined=e[0].onGroupMemberJoined),o.isFalsy(e[0].onGroupMemberLeft)||(this.onUserLeft=e[0].onGroupMemberLeft),o.isFalsy(e[0].onGroupMemberKicked)||(this.onUserKicked=e[0].onGroupMemberKicked),o.isFalsy(e[0].onGroupMemberBanned)||(this.onUserBanned=e[0].onGroupMemberBanned),o.isFalsy(e[0].onGroupMemberUnbanned)||(this.onUserUnbanned=e[0].onGroupMemberUnbanned),o.isFalsy(e[0].onGroupMemberScopeChanged)||(this.onMemberScopeChanged=e[0].onGroupMemberScopeChanged),o.isFalsy(e[0].onMemberAddedToGroup)||(this.onMemberAddedToGroup=e[0].onMemberAddedToGroup)};t.GroupEventListener=u;var l=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];o.isFalsy(e[0].onYouLeft)||(this.onYouLeft=e[0].onYouLeft),o.isFalsy(e[0].onYouJoined)||(this.onYouJoined=e[0].onYouJoined),o.isFalsy(e[0].onUserJoined)||(this.onUserJoined=e[0].onUserJoined),o.isFalsy(e[0].onUserLeft)||(this.onUserLeft=e[0].onUserLeft),o.isFalsy(e[0].onUserListUpdated)||(this.onUserListUpdated=e[0].onUserListUpdated),o.isFalsy(e[0].onMediaDeviceListUpdated)||(this.onMediaDeviceListUpdated=e[0].onMediaDeviceListUpdated),o.isFalsy(e[0].onRecordingStarted)||(this.onRecordingStarted=e[0].onRecordingStarted),o.isFalsy(e[0].onRecordingStopped)||(this.onRecordingStopped=e[0].onRecordingStopped),o.isFalsy(e[0].onScreenShareStarted)||(this.onScreenShareStarted=e[0].onScreenShareStarted),o.isFalsy(e[0].onScreenShareStopped)||(this.onScreenShareStopped=e[0].onScreenShareStopped),o.isFalsy(e[0].onUserMuted)||(this.onUserMuted=e[0].onUserMuted),o.isFalsy(e[0].onCallEnded)||(this.onCallEnded=e[0].onCallEnded),o.isFalsy(e[0].onError)||(this.onError=e[0].onError)};t.UserCallEventListener=l;var E=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];o.isFalsy(e[0].loginSuccess)||(this.loginSuccess=e[0].loginSuccess),o.isFalsy(e[0].loginFailure)||(this.loginFailure=e[0].loginFailure),o.isFalsy(e[0].logoutSuccess)||(this.logoutSuccess=e[0].logoutSuccess),o.isFalsy(e[0].logoutFailure)||(this.logoutFailure=e[0].logoutFailure)};t.LoginEventListener=E;var d=function(e,t){this._name=e,this._callback=t};t.Listener=d;var h=function(e){function t(t,n,r,s){var o=e.call(this,t,s)||this;return o._eventListener=n,r&&(o._cursor=r),o}return s(t,e),t}(d);t.MessageListener=h;var p=function(e){function t(t,n,r,s){var o=e.call(this,t,s)||this;return o._eventListener=n,r&&(o._cursor=r),o}return s(t,e),t}(d);t.UserListener=p;var S=function(e){function t(t,n,r,s){var o=e.call(this,t,s)||this;return o._eventListener=n,r&&(o._cursor=r),o}return s(t,e),t}(d);t.GroupListener=S;var g=function(e){function t(t,n,r){var s=e.call(this,"callListner",r)||this;return s._eventListener=t,s}return s(t,e),t}(d);t.UserCallListener=g;var C=function(e){function t(t,n,r,s){var o=e.call(this,t,s)||this;return o._eventListener=n,o}return s(t,e),t}(d);t.CallListener=C;var _=function(e){function t(t,n,r,s){var o=e.call(this,t,s)||this;return o._eventListener=n,r&&(o._cursor=r),o}return s(t,e),t}(d);t.LoginListener=_},function(e,t,n){"use strict";var r=this&&this.__assign||function(){return r=Object.assign||function(e){for(var t,n=1,r=arguments.length;n<r;n++)for(var s in t=arguments[n])Object.prototype.hasOwnProperty.call(t,s)&&(e[s]=t[s]);return e},r.apply(this,arguments)};t.__esModule=!0;var s=n(3),o=n(1),i=n(0),a=n(12),c=function(){function e(e){this.store=i.constants.DEFAULT_STORE,o.isFalsy(e)||(this.store=e),this.messagesStore=a.createInstance({name:o.format(i.LOCAL_STORE.STORE_STRING,s.CometChat.getAppId(),i.LOCAL_STORE.MESSAGES_STORE)}),this.messagesStore.setDriver([a.LOCALSTORAGE,a.INDEXEDDB,a.WEBSQL])}return e.getInstance=function(){return null==e.MessagesStore&&(e.MessagesStore=new e),e.MessagesStore},e.prototype.set=function(e,t){return this.messagesStore.setItem(e,t)},e.prototype.remove=function(e){this.messagesStore.removeItem(e)},e.prototype.get=function(e){return this.messagesStore.getItem(e)},e.prototype.clearStore=function(){var e=this;return new Promise((function(t,n){e.messagesStore.clear().then((function(){t(!0)})).catch((function(e){n(e)}))}))},e.prototype.getAllMessages=function(){var e=this,t={};return new Promise((function(n,s){e.messagesStore.iterate((function(e,n,s){n!=i.constants.MSG_VER_POST&&n!=i.constants.MSG_VER_POST&&(t=r({},t,e))})).then((function(){n(t)}))}))},e.prototype.clear=function(e){},e.prototype.selectStore=function(e){this.store=e},e.prototype.storeMessages=function(e){var t=this;if(s.CometChat.user.getUid()){var n=s.CometChat.user.getUid(),a={},c=0;return this.get(i.constants.MSG_VER_POST).then((function(s){e.map((function(e){var t;if(!o.isFalsy(e)){0==c&&(c=parseInt(e.getId().toString())),c>e.getId()&&(c=parseInt(e.getId().toString())),s<e.getId()&&(s=parseInt(e.getId().toString()));var u=void 0;u=e.getSender()instanceof Object?e.getSender().getUid():e.getSender(),e.getReceiverType()==i.MessageConstatnts.RECEIVER_TYPE.GROUP&&(u=e.getReceiver()),e.getSender()instanceof Object?e.getSender().getUid()==n&&(u=e.getReceiver()):e.getSender()==n&&(u=e.getReceiver()),a[u]||(a[u]={}),a[u]=r({},a[u],((t={})[e.getId()]=e,t))}})),t.get(i.constants.MSG_VER_PRE).then((function(e){(c>0&&e>c||null==e)&&t.set(i.constants.MSG_VER_PRE,c)}))&&s>0&&t.set(i.constants.MSG_VER_POST,s),Object.keys(a).map((function(e){t.get(e).then((function(n){null==n&&(n={}),t.set(e,r({},a[e],n))}))}))})),!0}},e}();t.MessagesStore=c},function(e,t,n){"use strict";var r,s=this&&this.__extends||(r=function(e,t){return r=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)t.hasOwnProperty(n)&&(e[n]=t[n])},r(e,t)},function(e,t){function n(){this.constructor=e}r(e,t),e.prototype=null===t?Object.create(t):(n.prototype=t.prototype,new n)}),o=this&&this.__assign||function(){return o=Object.assign||function(e){for(var t,n=1,r=arguments.length;n<r;n++)for(var s in t=arguments[n])Object.prototype.hasOwnProperty.call(t,s)&&(e[s]=t[s]);return e},o.apply(this,arguments)};t.__esModule=!0;var i=n(10),a=n(6),c=n(4),u=n(0),l=n(1),E=n(7),d=function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return s(t,e),t.actionFromJSON=function(e){var t=new this(e[u.MessageConstatnts.KEYS.RECEIVER],e[u.MessageConstatnts.KEYS.TYPE],e[u.MessageConstatnts.KEYS.RECEIVER_TYPE],u.MessageCategory.ACTION),n=e[u.MessageConstatnts.KEYS.DATA];if(t.data=n,t.setAction(n[u.MessageConstatnts.KEYS.ACTION]),n[u.ActionConstatnts.ACTION_KEYS.EXTRAS]){var r=n[u.ActionConstatnts.ACTION_KEYS.EXTRAS];if(r[u.ActionConstatnts.ACTION_KEYS.SCOPE]){var s=r[u.ActionConstatnts.ACTION_KEYS.SCOPE];s[u.ActionConstatnts.ACTION_KEYS.NEW]&&s[u.ActionConstatnts.ACTION_KEYS.OLD]&&(t.setOldScope(s[u.ActionConstatnts.ACTION_KEYS.OLD]),t.setNewScope(s[u.ActionConstatnts.ACTION_KEYS.NEW]))}}n[u.MessageConstatnts.KEYS.METADATA]&&t.setMetadata(n[u.MessageConstatnts.KEYS.METADATA]);var o=n[u.ActionConstatnts.ACTION_KEYS.ENTITIES];if(o[u.ActionConstatnts.ACTION_SUBJECTS.ACTION_BY])if(o[u.ActionConstatnts.ACTION_SUBJECTS.ACTION_BY][u.ActionConstatnts.ACTION_KEYS.ENTITY_TYPE]==u.ActionConstatnts.ACTION_ENTITY_TYPE.USER){var i=new c.User(o[u.ActionConstatnts.ACTION_SUBJECTS.ACTION_BY][u.ActionConstatnts.ACTION_KEYS.ENTITY]);Object.assign(i,o[u.ActionConstatnts.ACTION_SUBJECTS.ACTION_BY][u.ActionConstatnts.ACTION_KEYS.ENTITY]),t.actionBy=i,t.setSender(i)}else{var l=new a.Group("","","");Object.assign(l,o[u.ActionConstatnts.ACTION_SUBJECTS.ACTION_BY][u.ActionConstatnts.ACTION_KEYS.ENTITY]),t.actionBy=l}if(o[u.ActionConstatnts.ACTION_SUBJECTS.ACTION_FOR])if(o[u.ActionConstatnts.ACTION_SUBJECTS.ACTION_FOR][u.ActionConstatnts.ACTION_KEYS.ENTITY_TYPE]==u.ActionConstatnts.ACTION_ENTITY_TYPE.USER){i=new c.User(o[u.ActionConstatnts.ACTION_SUBJECTS.ACTION_FOR][u.ActionConstatnts.ACTION_KEYS.ENTITY]);Object.assign(i,o[u.ActionConstatnts.ACTION_SUBJECTS.ACTION_FOR][u.ActionConstatnts.ACTION_KEYS.ENTITY]),t.actionFor=i}else{l=new a.Group("","","");Object.assign(l,o[u.ActionConstatnts.ACTION_SUBJECTS.ACTION_FOR][u.ActionConstatnts.ACTION_KEYS.ENTITY]),t.actionFor=l}if(o[u.ActionConstatnts.ACTION_SUBJECTS.ACTION_ON])if(o[u.ActionConstatnts.ACTION_SUBJECTS.ACTION_ON][u.ActionConstatnts.ACTION_KEYS.ENTITY_TYPE]==u.ActionConstatnts.ACTION_ENTITY_TYPE.USER){i=new c.User(o[u.ActionConstatnts.ACTION_SUBJECTS.ACTION_ON][u.ActionConstatnts.ACTION_KEYS.ENTITY]);Object.assign(i,o[u.ActionConstatnts.ACTION_SUBJECTS.ACTION_ON][u.ActionConstatnts.ACTION_KEYS.ENTITY]),t.actionOn=i}else if(o[u.ActionConstatnts.ACTION_SUBJECTS.ACTION_ON][u.ActionConstatnts.ACTION_KEYS.ENTITY_TYPE]==u.ActionConstatnts.ACTION_ENTITY_TYPE.GROUP){l=new a.Group("","","");Object.assign(l,o[u.ActionConstatnts.ACTION_SUBJECTS.ACTION_ON][u.ActionConstatnts.ACTION_KEYS.ENTITY]),t.actionOn=l}else if(o[u.ActionConstatnts.ACTION_SUBJECTS.ACTION_ON][u.ActionConstatnts.ACTION_KEYS.ENTITY_TYPE]==u.ActionConstatnts.ACTION_ENTITY_TYPE.MESSAGE){var d=E.MessageController.trasformJSONMessge(o[u.ActionConstatnts.ACTION_SUBJECTS.ACTION_ON][u.ActionConstatnts.ACTION_KEYS.ENTITY]);t.actionOn=d}return t.setMessage(t.getActionMessage(t)),t},t.prototype.getOldScope=function(){return this.oldScope},t.prototype.getNewScope=function(){return this.newScope},t.prototype.setNewScope=function(e){this.newScope=e},t.prototype.setOldScope=function(e){this.oldScope=e},t.prototype.setRawData=function(e){this.rawData=e},t.prototype.getRawData=function(){return this.rawData},t.prototype.setMessage=function(e){this.message=e},t.prototype.getMessage=function(){return this.message},t.prototype.setAction=function(e){this.action=e},t.prototype.getAction=function(){return this.action},t.prototype.getSender=function(){try{return this.getSenderFromData()}catch(e){return this.sender}},t.prototype.setActionBy=function(e){this.actionBy=e},t.prototype.getActionBy=function(){return this.actionBy},t.prototype.setActionOn=function(e){this.actionOn=e},t.prototype.getActionOn=function(){return this.actionOn},t.prototype.setActionFor=function(e){this.actionFor=e},t.prototype.getActionFor=function(){return this.actionFor},t.prototype.getMetadata=function(){return this.data.metadata&&(this.metadata=this.data.metadata),this.metadata},t.prototype.setMetadata=function(e){this.metadata=e,this.data=o({},this.data,{metadata:e})},t.prototype.getActionMessage=function(e){var t="";switch(e.getType()){case u.ActionConstatnts.ACTION_KEYS.ACTION_TYPE_USER:case u.ActionConstatnts.ACTION_KEYS.ACTION_TYPE_GROUP:switch(e.getAction()){case u.ActionConstatnts.ACTION_KEYS.ACTION_CREATED:case u.ActionConstatnts.ACTION_KEYS.ACTION_UPDATED:case u.ActionConstatnts.ACTION_KEYS.ACTION_DELETED:}break;case u.ActionConstatnts.ACTION_KEYS.ACTION_TYPE_GROUP_MEMBER:switch(e.getAction()){case u.ActionConstatnts.ACTION_KEYS.TYPE_MEMBER_JOINED:var n=e.getActionBy();t=l.format(u.ActionConstatnts.ActionMessages.ACTION_GROUP_JOINED_MESSAGE,n.getName());break;case u.ActionConstatnts.ACTION_KEYS.TYPE_MEMBER_LEFT:n=e.getActionBy();t=l.format(u.ActionConstatnts.ActionMessages.ACTION_GROUP_LEFT_MESSAGE,n.getName());break;case u.ActionConstatnts.ACTION_KEYS.TYPE_MEMBER_KICKED:n=e.getActionBy();var r=e.getActionOn();t=l.format(u.ActionConstatnts.ActionMessages.ACTION_MEMBER_KICKED_MESSAGE,n.getName(),r.getName());break;case u.ActionConstatnts.ACTION_KEYS.TYPE_MEMBER_BANNED:n=e.getActionBy(),r=e.getActionOn();t=l.format(u.ActionConstatnts.ActionMessages.ACTION_MEMBER_BANNED_MESSAGE,n.getName(),r.getName());break;case u.ActionConstatnts.ACTION_KEYS.TYPE_MEMBER_UNBANNED:n=e.getActionBy(),r=e.getActionOn();t=l.format(u.ActionConstatnts.ActionMessages.ACTION_MEMBER_UNBANNED_MESSAGE,n.getName(),r.getName());break;case u.ActionConstatnts.ACTION_KEYS.ACTION_SCOPE_CHANGED:n=e.getActionBy(),r=e.getActionOn();var s=e.getNewScope();t=l.format(u.ActionConstatnts.ActionMessages.ACTION_MEMBER_SCOPE_CHANGED,n.getName(),r.getName(),s);break;case u.ActionConstatnts.ACTION_KEYS.TYPE_MEMBER_ADDED:n=e.getActionBy(),r=e.getActionOn();t=l.format(u.ActionConstatnts.ActionMessages.ACTION_MEMBER_ADDED_TO_GROUP,n.getName(),r.getName());break;case u.ActionConstatnts.ACTION_KEYS.TYPE_MESSAGE_EDITED:t=l.format(u.ActionConstatnts.ActionMessages.ACTION_MESSAGE_EDITED_MESSAGE,"");break;case u.ActionConstatnts.ACTION_KEYS.TYPE_MESSAGE_DELETED:t=l.format(u.ActionConstatnts.ActionMessages.ACTION_MESSAGE_DELETED_MESSAGE,"")}}return t},t.prototype.getSenderFromData=function(){var e=this.data[u.ActionConstatnts.ACTION_KEYS.ENTITIES];if(e[u.ActionConstatnts.ACTION_SUBJECTS.ACTION_BY]&&e[u.ActionConstatnts.ACTION_SUBJECTS.ACTION_BY][u.ActionConstatnts.ACTION_KEYS.ENTITY_TYPE]==u.ActionConstatnts.ACTION_ENTITY_TYPE.USER){var t=new c.User(e[u.ActionConstatnts.ACTION_SUBJECTS.ACTION_BY][u.ActionConstatnts.ACTION_KEYS.ENTITY]);return Object.assign(t,e[u.ActionConstatnts.ACTION_SUBJECTS.ACTION_BY][u.ActionConstatnts.ACTION_KEYS.ENTITY]),t}},t.TYPE=u.MessageConstatnts.TYPE,t.RECEIVER_TYPE=u.MessageConstatnts.RECEIVER_TYPE,t.CATEGORY=u.MessageConstatnts.CATEGORY,t.ACTION_TYPE=u.ActionConstatnts.ACTION_TYPE,t}(i.BaseMessage);t.Action=d},function(e,t,n){"use strict";var r,s=this&&this.__extends||(r=function(e,t){return r=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)t.hasOwnProperty(n)&&(e[n]=t[n])},r(e,t)},function(e,t){function n(){this.constructor=e}r(e,t),e.prototype=null===t?Object.create(t):(n.prototype=t.prototype,new n)}),o=this&&this.__assign||function(){return o=Object.assign||function(e){for(var t,n=1,r=arguments.length;n<r;n++)for(var s in t=arguments[n])Object.prototype.hasOwnProperty.call(t,s)&&(e[s]=t[s]);return e},o.apply(this,arguments)};t.__esModule=!0;var i=n(10),a=n(6),c=n(0),u=n(1),l=n(4),E=function(e){function t(t,n,r,s){return u.isFalsy(s)?e.call(this,t,n,r,c.MessageCategory.CALL)||this:e.call(this,t,n,r,s)||this}return s(t,e),t.prototype.getCallInitiator=function(){return this.getCallInitiatedByFromData()},t.prototype.getCallReceiver=function(){return this.getCallReceivedByFromData()},t.prototype.setCallInitiator=function(e){this.callInitiator=e},t.prototype.setCallReceiver=function(e){this.callReceiver=e},t.prototype.getData=function(){return this.data},t.prototype.setData=function(e){this.data=e},t.prototype.getSessionId=function(){return this.sessionId},t.prototype.setSessionId=function(e){this.sessionId=e},t.prototype.getMetadata=function(){return this.data.metadata&&(this.metadata=this.data.metadata),this.metadata},t.prototype.getSender=function(){try{return this.getSenderFromData()}catch(e){return this.sender}},t.prototype.setMetadata=function(e){this.metadata=e,this.data=o({},this.data,{metadata:e})},t.prototype.getAction=function(){return this.action},t.prototype.setAction=function(e){this.action=e},t.prototype.getInitiatedAt=function(){return this.initiatedAt},t.prototype.setInitiatedAt=function(e){this.initiatedAt=e},t.prototype.getJoinedAt=function(){return this.joinedAt},t.prototype.setJoinedAt=function(e){this.joinedAt=e},t.prototype.setRawData=function(e){this.rawData=e},t.prototype.getRawData=function(){return this.rawData},t.prototype.setSender=function(e){this.sender=e},t.prototype.setReceiver=function(e){this.receiver=e},t.callFromJSON=function(e){try{var t=new this(e[c.MessageConstatnts.KEYS.RECEIVER],e[c.MessageConstatnts.KEYS.TYPE],e[c.MessageConstatnts.KEYS.RECEIVER_TYPE],c.MessageCategory.CALL),n=e[c.MessageConstatnts.KEYS.DATA];t.setAction(n[c.MessageConstatnts.KEYS.ACTION]),n[c.MessageConstatnts.KEYS.METADATA]&&t.setMetadata(n[c.MessageConstatnts.KEYS.METADATA]);var r=n[c.ActionConstatnts.ACTION_KEYS.ENTITIES];if(r[c.ActionConstatnts.ACTION_SUBJECTS.ACTION_BY])r[c.ActionConstatnts.ACTION_SUBJECTS.ACTION_BY];if(r[c.ActionConstatnts.ACTION_SUBJECTS.ACTION_ON]){var s=r[c.ActionConstatnts.ACTION_SUBJECTS.ACTION_ON];if(s[c.CallConstants.CALL_KEYS.CALL_ENTITY]){var o=s[c.CallConstants.CALL_KEYS.CALL_ENTITY];if(o[c.CallConstants.CALL_KEYS.CALL_SESSION_ID]&&(t.sessionId=o[c.CallConstants.CALL_KEYS.CALL_SESSION_ID]),o[c.CallConstants.CALL_KEYS.CALL_STATUS]&&(t.status=o[c.CallConstants.CALL_KEYS.CALL_STATUS]),o[c.CallConstants.CALL_KEYS.CALL_DATA]){var i=o[c.CallConstants.CALL_KEYS.CALL_DATA];if(i[c.CallConstants.CALL_KEYS.CALL_METADATA]&&(t.metadata=i[c.CallConstants.CALL_KEYS.CALL_METADATA]),i[c.ResponseConstants.RESPONSE_KEYS.KEY_ENTITIES])i[c.ResponseConstants.RESPONSE_KEYS.KEY_ENTITIES]}o[c.CallConstants.CALL_KEYS.CALL_INITIATED_AT]&&(t.initiatedAt=o[c.CallConstants.CALL_KEYS.CALL_INITIATED_AT]),o[c.CallConstants.CALL_KEYS.CALL_JOINED_AT]&&(t.joinedAt=o[c.CallConstants.CALL_KEYS.CALL_JOINED_AT]),o[c.CallConstants.CALL_KEYS.CALL_LEFT_AT]&&(t.joinedAt=o[c.CallConstants.CALL_KEYS.CALL_LEFT_AT])}}return t}catch(e){u.Logger.error("CallModel: callFromJSON",e)}},t.prototype.getSenderFromData=function(){try{var e=this.getData();if((e=e[c.ActionConstatnts.ACTION_KEYS.ENTITIES])[c.ActionConstatnts.ACTION_SUBJECTS.ACTION_BY][c.CallConstants.CALL_KEYS.CALL_ENTITY])return new l.User(e[c.ActionConstatnts.ACTION_SUBJECTS.ACTION_BY][c.CallConstants.CALL_KEYS.CALL_ENTITY])}catch(e){u.Logger.error("CallModel:getSenderFromData",e)}},t.prototype.getCallInitiatedByFromData=function(){try{var e=this.getData();if((e=e[c.ActionConstatnts.ACTION_KEYS.ENTITIES])[c.ActionConstatnts.ACTION_SUBJECTS.ACTION_ON][c.CallConstants.CALL_KEYS.CALL_ENTITY][c.CallConstants.CALL_KEYS.CALL_DATA][c.ActionConstatnts.ACTION_KEYS.ENTITIES][c.CallConstants.CALL_KEYS.CALL_SENDER])return new l.User(e[c.ActionConstatnts.ACTION_SUBJECTS.ACTION_ON][c.CallConstants.CALL_KEYS.CALL_ENTITY][c.CallConstants.CALL_KEYS.CALL_DATA][c.ActionConstatnts.ACTION_KEYS.ENTITIES][c.CallConstants.CALL_KEYS.CALL_SENDER][c.CallConstants.CALL_KEYS.CALL_ENTITY])}catch(e){u.Logger.error("CallModel:getCallInitiatedByFromData",e)}},t.prototype.getCallReceivedByFromData=function(){try{var e=this.getData();if((e=e[c.ActionConstatnts.ACTION_KEYS.ENTITIES])[c.ActionConstatnts.ACTION_SUBJECTS.ACTION_FOR][c.CallConstants.CALL_KEYS.CALL_ENTITY]){if(e[c.ActionConstatnts.ACTION_SUBJECTS.ACTION_FOR][c.CallConstants.CALL_KEYS.CALL_ENTITY_TYPE]==c.CallConstants.CALL_KEYS.CALL_ENTITY_USER)return new l.User(e[c.ActionConstatnts.ACTION_SUBJECTS.ACTION_FOR][c.CallConstants.CALL_KEYS.CALL_ENTITY]);var t=new a.Group(e[c.ActionConstatnts.ACTION_SUBJECTS.ACTION_FOR][c.CallConstants.CALL_KEYS.CALL_ENTITY][c.GroupConstants.KEYS.GUID],e[c.ActionConstatnts.ACTION_SUBJECTS.ACTION_FOR][c.CallConstants.CALL_KEYS.CALL_ENTITY][c.GroupConstants.KEYS.NAME],e[c.ActionConstatnts.ACTION_SUBJECTS.ACTION_FOR][c.CallConstants.CALL_KEYS.CALL_ENTITY][c.GroupConstants.KEYS.TYPE]);return Object.assign(t,e[c.ActionConstatnts.ACTION_SUBJECTS.ACTION_FOR][c.CallConstants.CALL_KEYS.CALL_ENTITY])}}catch(e){u.Logger.error("CallModel:getCallReceivedByFromData",e)}},t.TYPE=c.MessageConstatnts.TYPE,t.RECEIVER_TYPE=c.MessageConstatnts.RECEIVER_TYPE,t.CATEGORY=c.MessageConstatnts.CATEGORY,t.ACTION_TYPE=c.ActionConstatnts.ACTION_TYPE,t}(i.BaseMessage);t.Call=E},function(e,t,n){"use strict";t.__esModule=!0;var r=n(1),s=n(0),o=n(12),i=n(3),a=function(){function e(e){this.store=s.constants.DEFAULT_STORE,r.isFalsy(e)||(this.store=e),this.settingsStore=o.createInstance({name:r.format(s.LOCAL_STORE.STORE_STRING,i.CometChat.getAppId(),s.LOCAL_STORE.MESSAGE_LISTENERS_LIST)}),this.settingsStore.setDriver([o.LOCALSTORAGE,o.INDEXEDDB,o.WEBSQL])}return e.getInstance=function(){return null==e.settingsStore&&(e.settingsStore=new e),e.settingsStore},e.prototype.set=function(e,t){return this.settingsStore.setItem(e,t)},e.prototype.remove=function(e){this.settingsStore.removeItem(e)},e.prototype.get=function(e){return this.settingsStore.getItem(e)},e.prototype.clearStore=function(){return this.settingsStore.clear()},e.prototype.clear=function(e){},e.prototype.selectStore=function(e){this.store=e},e.settingsStore=null,e}();t.MessageListnerMaping=a},function(e,t,n){"use strict";var r=this&&this.__awaiter||function(e,t,n,r){return new(n||(n=Promise))((function(s,o){function i(e){try{c(r.next(e))}catch(e){o(e)}}function a(e){try{c(r.throw(e))}catch(e){o(e)}}function c(e){e.done?s(e.value):new n((function(t){t(e.value)})).then(i,a)}c((r=r.apply(e,t||[])).next())}))},s=this&&this.__generator||function(e,t){var n,r,s,o,i={label:0,sent:function(){if(1&s[0])throw s[1];return s[1]},trys:[],ops:[]};return o={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(o[Symbol.iterator]=function(){return this}),o;function a(o){return function(a){return function(o){if(n)throw new TypeError("Generator is already executing.");for(;i;)try{if(n=1,r&&(s=2&o[0]?r.return:o[0]?r.throw||((s=r.return)&&s.call(r),0):r.next)&&!(s=s.call(r,o[1])).done)return s;switch(r=0,s&&(o=[2&o[0],s.value]),o[0]){case 0:case 1:s=o;break;case 4:return i.label++,{value:o[1],done:!1};case 5:i.label++,r=o[1],o=[0];continue;case 7:o=i.ops.pop(),i.trys.pop();continue;default:if(!(s=i.trys,(s=s.length>0&&s[s.length-1])||6!==o[0]&&2!==o[0])){i=0;continue}if(3===o[0]&&(!s||o[1]>s[0]&&o[1]<s[3])){i.label=o[1];break}if(6===o[0]&&i.label<s[1]){i.label=s[1],s=o;break}if(s&&i.label<s[2]){i.label=s[2],i.ops.push(o);break}s[2]&&i.ops.pop(),i.trys.pop();continue}o=t.call(e,i)}catch(e){o=[6,e],r=0}finally{n=s=0}if(5&o[0])throw o[1];return{value:o[0]?o[1]:void 0,done:!0}}([o,a])}}};t.__esModule=!0;var o=n(38),i=n(1),a=n(7),c=n(0),u=function(){function e(){}return e.executeInSync=function(e,t){var n=this;return new Promise((function(o,i){return r(n,void 0,void 0,(function(){var n,r;return s(this,(function(s){switch(s.label){case 0:return n=e,t?(r=setTimeout((function(){o(e)}),this.SMALL_TIMEOUT),[4,t(e)]):[3,2];case 1:n=s.sent(),s.label=2;case 2:return clearTimeout(r),o(n),[2]}}))}))}))},e.hookBeforeMessageSent=function(e){return r(this,void 0,void 0,(function(){var t,n;return s(this,(function(r){switch(r.label){case 0:t=0,r.label=1;case 1:return t<o.ExtensionManager.cometChatExtensionList.length?[4,this.getExtensionList()]:[3,7];case 2:if(!r.sent()[o.ExtensionManager.cometChatExtensionList[t].getExtensionId()])return[3,6];if(!o.ExtensionManager.cometChatExtensionList[t].beforeMessageSent)return[3,6];r.label=3;case 3:return r.trys.push([3,5,,6]),[4,this.executeInSync(e,o.ExtensionManager.cometChatExtensionList[t].beforeMessageSent)];case 4:return e=r.sent(),[3,6];case 5:return n=r.sent(),i.Logger.error("Logging error",n),[3,6];case 6:return t++,[3,1];case 7:return[2,e]}}))}))},e.hookAfterMessageSent=function(e){return r(this,void 0,void 0,(function(){var t,n;return s(this,(function(r){switch(r.label){case 0:t=0,r.label=1;case 1:return t<o.ExtensionManager.cometChatExtensionList.length?[4,this.getExtensionList()]:[3,7];case 2:if(!r.sent()[o.ExtensionManager.cometChatExtensionList[t].getExtensionId()])return[3,6];if(!o.ExtensionManager.cometChatExtensionList[t].afterMessageSent)return[3,6];r.label=3;case 3:return r.trys.push([3,5,,6]),[4,this.executeInSync(e,o.ExtensionManager.cometChatExtensionList[t].afterMessageSent)];case 4:return e=r.sent(),[3,6];case 5:return n=r.sent(),i.Logger.error("Logging error",n),[3,6];case 6:return t++,[3,1];case 7:return[2,e]}}))}))},e.hookOnInit=function(e,t){return r(this,void 0,void 0,(function(){var n=this;return s(this,(function(i){return o.ExtensionManager.cometChatExtensionList.map((function(o){return r(n,void 0,void 0,(function(){return s(this,(function(n){switch(n.label){case 0:return[4,this.getExtensionList()];case 1:return n.sent()[o.getExtensionId()]?e&&t&&o.onInit?[4,o.onInit(e,t)]:[3,3]:[3,5];case 2:return n.sent(),[3,5];case 3:return e&&o.onInit?[4,o.onInit(e)]:[3,5];case 4:n.sent(),n.label=5;case 5:return[2]}}))}))})),[2]}))}))},e.hookOnMessageReceived=function(e){return r(this,void 0,void 0,(function(){var t,n,r;return s(this,(function(s){switch(s.label){case 0:t=a.MessageController.trasformJSONMessge(e),n=0,s.label=1;case 1:return n<o.ExtensionManager.cometChatExtensionList.length?[4,this.getExtensionList()]:[3,7];case 2:if(!s.sent()[o.ExtensionManager.cometChatExtensionList[n].getExtensionId()])return[3,6];if(!o.ExtensionManager.cometChatExtensionList[n].onMessageReceived)return[3,6];s.label=3;case 3:return s.trys.push([3,5,,6]),[4,this.executeInSync(t,o.ExtensionManager.cometChatExtensionList[n].onMessageReceived)];case 4:return e=s.sent(),[3,6];case 5:return r=s.sent(),i.Logger.error("Logging error",r),[3,6];case 6:return n++,[3,1];case 7:return[2,e]}}))}))},e.hookOnLogin=function(e){return r(this,void 0,void 0,(function(){var t=this;return s(this,(function(n){return o.ExtensionManager.cometChatExtensionList.map((function(n){return r(t,void 0,void 0,(function(){return s(this,(function(t){switch(t.label){case 0:return[4,this.getExtensionList()];case 1:return t.sent()[n.getExtensionId()]&&(e&&n.onLogin)?[4,n.onLogin(e)]:[3,3];case 2:t.sent(),t.label=3;case 3:return[2]}}))}))})),[2]}))}))},e.executeInSyncBulk=function(e,t){var n=this;return new Promise((function(o,i){return r(n,void 0,void 0,(function(){var n,r;return s(this,(function(s){switch(s.label){case 0:return n=e,t?(r=setTimeout((function(){o(e)}),this.BIG_TIMEOUT),[4,t(e)]):[3,2];case 1:n=s.sent(),s.label=2;case 2:return clearTimeout(r),o(n),[2]}}))}))}))},e.hookOnMessageListIsFetched=function(e){return r(this,void 0,void 0,(function(){var t,n;return s(this,(function(r){switch(r.label){case 0:t=0,r.label=1;case 1:return t<o.ExtensionManager.cometChatExtensionList.length?[4,this.getExtensionList()]:[3,7];case 2:if(!r.sent()[o.ExtensionManager.cometChatExtensionList[t].getExtensionId()])return[3,6];if(!o.ExtensionManager.cometChatExtensionList[t].onMessageListFetched)return[3,6];r.label=3;case 3:return r.trys.push([3,5,,6]),[4,this.executeInSyncBulk(e,o.ExtensionManager.cometChatExtensionList[t].onMessageListFetched)];case 4:return e=r.sent(),[3,6];case 5:return n=r.sent(),i.Logger.error("Logging error",n),[3,6];case 6:return t++,[3,1];case 7:return[2,e]}}))}))},e.getExtensionList=function(){return r(this,void 0,void 0,(function(){var e=this;return s(this,(function(t){switch(t.label){case 0:return i.isFalsy(this.extentionList)?[4,i.getAppSettings()]:[3,2];case 1:t.sent()[c.APP_SETTINGS.KEYS.EXTENSION_LIST].map((function(t){e.extentionList[t.id]=t})),t.label=2;case 2:return[2,this.extentionList]}}))}))},e.SMALL_TIMEOUT=5e3,e.BIG_TIMEOUT=2e4,e.extentionList={},e}();t.ExtensionController=u},function(e,t,n){"use strict";t.__esModule=!0;var r=n(42),s=n(1),o=function(){function e(){}return e.trasformJSONConversation=function(e,t,n,o,i){var a;try{a=new r.Conversation(e,t,n,o,i)}catch(e){s.Logger.error("ConversationController:transformJSONConversation",e)}return a},e}();t.ConversationController=o},function(e,t){var n;n=function(){return this}();try{n=n||new Function("return this")()}catch(e){"object"==typeof window&&(n=window)}e.exports=n},function(e,t,n){"use strict";t.__esModule=!0;var r=n(1),s=n(0),o=n(9),i=n(3),a=n(2),c=function(){function e(){this.baseUrl="https://apiclient-%s.cometchat.io/",this.apiVersion="v2.0",this.apiBaseUrl=this.baseUrl+this.apiVersion+"/",this.adminApiUrl="https://api-%s.cometchat.io/",this.adminApiVersion="v2.0",this.extensionApi="https://%s-%s.cometchat.io/%s",this.prosodyApi="https://%s.%s/%s",this.uriEndpoints={authToken:{endpoint:"users/{{uid}}/auth_tokens",method:"POST",data:{uid:"string|max:100"},isAdminApi:!0},appSettings:{endpoint:"settings",method:"GET"},login:{endpoint:"admin/users/auth",method:"POST",data:{uid:"string|max:100"}},logout:{endpoint:"admin/users/auth/{{authToken}}",method:"DELETE"},getMyDetails:{endpoint:"me",method:"GET"},updateMyDetails:{endpoint:"me",method:"PUT"},getJWT:{endpoint:"me/jwt",method:"POST"},users:{endpoint:"users",method:"GET"},user:{endpoint:"users/{{uid}}",method:"GET"},blockUsers:{endpoint:"blockedusers",method:"POST"},blockedUsersList:{endpoint:"blockedusers",method:"GET"},unblockUsers:{endpoint:"blockedusers",method:"DELETE"},userLogout:{endpoint:"me",method:"DELETE"},createUser:{endpoint:"users",method:"POST",isAdminApi:!0},updateUser:{endpoint:"users/{{uid}}",method:"PUT",isAdminApi:!0},sendFriendRequests:{endpoint:"user/friends",method:"POST",data:{uids:"array<string|max:100>"}},getFriends:{endpoint:"user/friends",method:"GET"},unfriend:{endpoint:"user/friends/{{uid}}/{{gid}}",method:"DELETE",data:{uids:"array<string|max:100>"}},acceptFriendRequest:{endpoint:"user/friends/{{uid}}/accept",method:"PUT",data:{uids:"array<string|max:100>"}},rejectFriendRequest:{endpoint:"user/friends/{{uid}}/reject",method:"DELETE",data:{uids:"array<string|max:100>"}},createGroup:{endpoint:"groups",method:"POST",data:{guid:"required|string|max:100",name:"required|string|max:100",type:"enum|public,protected,password",password:"filled|string|max:100"}},getGroups:{endpoint:"groups",method:"GET"},getGroup:{endpoint:"groups/{{guid}}",method:"GET"},updateGroup:{endpoint:"groups/{{guid}}",method:"PUT"},deleteGroup:{endpoint:"groups/{{guid}}",method:"DELETE"},addGroupMembers:{endpoint:"groups/{{guid}}/members",method:"POST",data:{uids:"array<string|max:100>"}},getGroupMembers:{endpoint:"groups/{{guid}}/members",method:"GET"},joinGroup:{endpoint:"groups/{{guid}}/members",method:"POST"},leaveGroup:{endpoint:"groups/{{guid}}/members",method:"DELETE"},kickGroupMembers:{endpoint:"groups/{{guid}}/members/{{uid}}",method:"DELETE",data:{uids:"array<string|max:100>"}},changeScopeOfMember:{endpoint:"groups/{{guid}}/members/{{uid}}",method:"PUT",data:{uids:"array<string|max:100>"}},banGroupMember:{endpoint:"groups/{{guid}}/bannedusers/{{uid}}",method:"POST",data:{uids:"array<string|max:100>"}},unbanGroupMember:{endpoint:"groups/{{guid}}/bannedusers/{{uid}}",method:"DELETE",data:{uids:"array<string|max:100>"}},addMemebersToGroup:{endpoint:"groups/{{guid}}/members",method:"PUT"},getBannedGroupMembers:{endpoint:"groups/{{guid}}/bannedusers",method:"GET"},promotemoteGroupMember:{endpoint:"groups/{{guid}}/promote",method:"PUT",data:{uids:"array<string|max:100>"}},demoteGroupMember:{endpoint:"groups/{{guid}}/demote",method:"DELETE",data:{uids:"array<string|max:100>"}},transferOwnership:{endpoint:"groups/{{guid}}/owner",method:"PATCH"},sendMessage:{endpoint:"messages",method:"POST",data:{sender:"array:string:max:100>",isGroupMember:"filled|boolean|bail",data:"required|json"}},sendMessageInThread:{endpoint:"messages/{{parentId}}/thread",method:"POST",data:{sender:"array:string:max:100>",isGroupMember:"filled|boolean|bail",data:"required|json"}},getMessages:{endpoint:"messages",method:"GET"},getMessageDetails:{endpoint:"messages/{{messageId}}",method:"GET"},getUserMessages:{endpoint:"users/{{listId}}/messages",method:"GET"},getGroupMessages:{endpoint:"groups/{{listId}}/messages",method:"GET"},getThreadMessages:{endpoint:"messages/{{listId}}/thread",method:"GET"},getMessage:{endpoint:"user/messages/{{muid}}",method:"GET"},updateMessage:{endpoint:"messages/{{messageId}}",method:"PUT"},deleteMessage:{endpoint:"messages/{{messageId}}",method:"DELETE"},createCallSession:{endpoint:"calls",method:"POST",data:{}},updateCallSession:{endpoint:"calls/{{sessionid}}",method:"put",data:{}},getConversations:{endpoint:"conversations",method:"GET"},getUserConversation:{endpoint:"users/{{uid}}/conversation",method:"GET"},getGroupConversation:{endpoint:"groups/{{guid}}/conversation",method:"GET"},deleteUserConversation:{endpoint:"users/{{uid}}/conversation",method:"DELETE"},deleteGroupConversation:{endpoint:"groups/{{guid}}/conversation",method:"DELETE"}}}return e.prototype.getEndpointData=function(t){return new Promise((function(n,c){try{o.LocalStorage.getInstance().get(s.APP_SETTINGS.APP_SETTINGS).then((function(o){if(r.isFalsy(o)){var a={};if((new e).uriEndpoints.hasOwnProperty(t))if((a=(new e).uriEndpoints[t]).hasOwnProperty("isAdminApi")){var c=r.format((new e).adminApiUrl,i.CometChat.appSettings.getRegion())+(new e).adminApiVersion+"/"+a.endpoint;a.endpoint=c}else{c=r.format((new e).baseUrl,i.CometChat.appSettings.getRegion())+(new e).apiVersion+"/"+a.endpoint;a.endpoint=c}n(a)}else{a={};if((new e).uriEndpoints.hasOwnProperty(t))if((a=(new e).uriEndpoints[t]).hasOwnProperty("isAdminApi"))a.endpoint="https://"+o[s.APP_SETTINGS.KEYS.ADMIN_API_HOST]+"/"+(new e).adminApiVersion+"/"+a.endpoint;else{c="https://"+o[s.APP_SETTINGS.KEYS.CLIENT_API_HOST]+"/"+(new e).apiVersion+"/"+a.endpoint;a.endpoint=c}n(a)}}),(function(s){var o;(new e).uriEndpoints.hasOwnProperty(t)&&((o=(new e).uriEndpoints[t]).hasOwnProperty(["isAdminApi"])?o.endpoint=r.format((new e).adminApiUrl,i.CometChat.appSettings.getRegion())+(new e).adminApiVersion+"/"+o.endpoint:o.endpoint=r.format((new e).baseUrl,i.CometChat.appSettings.getRegion())+(new e).apiVersion+"/"+o.endpoint),n(o)}))}catch(e){c(new a.CometChatException(e))}}))},e}();t.EndpointFactory=c},function(e,t,n){"use strict";t.__esModule=!0;var r=n(30),s=n(2);t.getEndPoint=function(e,t){void 0===e&&(e=""),void 0===t&&(t={});var n=new r.EndpointFactory;return new Promise((function(r,o){try{n.getEndpointData(e).then((function(e){var n=e;if(n){for(var s in t)n.endpoint=n.endpoint.replace("{{"+s+"}}",t[s]);r(n)}else o({error:"Unknown endPoint name."})}))}catch(e){o(new s.CometChatException(e))}}))}},function(e,t,n){"use strict";var r=this&&this.__awaiter||function(e,t,n,r){return new(n||(n=Promise))((function(s,o){function i(e){try{c(r.next(e))}catch(e){o(e)}}function a(e){try{c(r.throw(e))}catch(e){o(e)}}function c(e){e.done?s(e.value):new n((function(t){t(e.value)})).then(i,a)}c((r=r.apply(e,t||[])).next())}))},s=this&&this.__generator||function(e,t){var n,r,s,o,i={label:0,sent:function(){if(1&s[0])throw s[1];return s[1]},trys:[],ops:[]};return o={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(o[Symbol.iterator]=function(){return this}),o;function a(o){return function(a){return function(o){if(n)throw new TypeError("Generator is already executing.");for(;i;)try{if(n=1,r&&(s=2&o[0]?r.return:o[0]?r.throw||((s=r.return)&&s.call(r),0):r.next)&&!(s=s.call(r,o[1])).done)return s;switch(r=0,s&&(o=[2&o[0],s.value]),o[0]){case 0:case 1:s=o;break;case 4:return i.label++,{value:o[1],done:!1};case 5:i.label++,r=o[1],o=[0];continue;case 7:o=i.ops.pop(),i.trys.pop();continue;default:if(!(s=i.trys,(s=s.length>0&&s[s.length-1])||6!==o[0]&&2!==o[0])){i=0;continue}if(3===o[0]&&(!s||o[1]>s[0]&&o[1]<s[3])){i.label=o[1];break}if(6===o[0]&&i.label<s[1]){i.label=s[1],s=o;break}if(s&&i.label<s[2]){i.label=s[2],i.ops.push(o);break}s[2]&&i.ops.pop(),i.trys.pop();continue}o=t.call(e,i)}catch(e){o=[6,e],r=0}finally{n=s=0}if(5&o[0])throw o[1];return{value:o[0]?o[1]:void 0,done:!0}}([o,a])}}};t.__esModule=!0;var o=n(15),i=n(11),a=n(0),c=n(1),u=n(3),l=n(4);t.$iq=o.$iq,t.$build=o.$build,t.$msg=o.$msg,t.$pres=o.$pres,t.Strophe=o.Strophe,t.NS=o.Strophe.NS,t.Status=o.Strophe.Status,window.Strophe=t.Strophe,window.$iq=t.$iq,window.$msg=t.$msg,t.Strophe.addConnectionPlugin("chatstates",{init:function(e){this._connection=e,t.Strophe.addNamespace("CHATSTATES","http://jabber.org/protocol/chatstates")},statusChanged:function(e){},addActive:function(e){return e.c("active",{xmlns:t.Strophe.NS.CHATSTATES}).up()},_notificationReceived:function(e){var t=e.getElementsByTagName("composing"),n=e.getElementsByTagName("paused");e.getAttribute("from");return t.length>0&&JSON.stringify(i.parseHTML(e.getElementsByTagName("body")[0])),n.length,!0},sendActive:function(e,t,n){this._sendNotification(e,t,"active",n)},sendComposing:function(e,t,n,r){this._sendNotification(e,t,"composing",n,r)},sendPaused:function(e,t,n,r){this._sendNotification(e,t,"paused",n,r)},sendInactive:function(e,t){this._sendNotification(e,t,"inactive")},sendGone:function(e,t){this._sendNotification(e,t,"gone")},_sendNotification:function(e,n,r,s,o){var i="";n||(n="chat"),"composing"!==r&&"paused"!==r||s&&(i=JSON.stringify(s)),c.isFalsy(o)?this._connection.send(t.$msg({to:e,from:this._connection.jid,type:n}).c("user",{xmlns:"com.cometchat.models:User"}).t(i).up().c(r,{xmlns:t.Strophe.NS.CHATSTATES})):this._connection.send(t.$msg({to:e,from:this._connection.jid,type:n}).c("user",{xmlns:"com.cometchat.models:User"}).t(i).up().c("body",JSON.stringify(o)).up().c(r,{xmlns:t.Strophe.NS.CHATSTATES}))}}),t.Strophe.addConnectionPlugin("receipts",{_conn:null,_msgQueue:{},_retries:{},_resendCount:10,_resendTime:9e3,init:function(e){this._conn=e,t.Strophe.addNamespace("RECEIPTS","urn:xmpp:receipts")},statusChanged:function(e){if(e===t.Strophe.Status.CONNECTED||e===t.Strophe.Status.ATTACHED){this._conn.addHandler(this._onRequestReceived.bind(this),t.Strophe.NS.RECEIPTS,"message");var n=this;setTimeout((function(){n.resendQueue()}),5e3)}},sendMessage:function(e){var n=this._conn.getUniqaueId();e.tree().setAttribute("id",n);var r=t.Strophe.xmlElement("request",{xmlns:t.Strophe.NS.RECEIPTS});return e.tree().appendChild(r),this._msgQueue[n]=e,this._retries[n]=0,this._conn.send(e),this.resendMessage(n),n},resendMessage:function(e){var t=this;setTimeout((function(){if(t._msgQueue[e]){if(!t._conn.connected)return void t.resendMessage(e);if(t._retries[e]++,t._retries[e]>t._resendCount)return;t._msgQueue[e].tree().setAttribute("from",t._conn.jid),t._conn.send(t._msgQueue[e]),t.resendMessage(e)}}),this._resendTime)},addReceiptHandler:function(e,n,r,s){var o=this;this._conn.addHandler((function(t){return o._processReceipt(t),e(t)}),t.Strophe.NS.RECEIPTS,"message",n,null,r,s)},_processReceipt:function(e,n){return void 0===n&&(n=0),r(this,void 0,void 0,(function(){var n,r,o,E,d,h,p,S,g,C,_,f=this;return s(this,(function(s){if(u.CometChat.getConnectionStatus()==a.CONNECTION_STATUS.CONNECTED){n=e.getAttribute(a.DELIVERY_RECEIPTS.ID),r=t.Strophe.getBareJidFromJid(e.getAttribute(a.MessageConstatnts.XMPP_KEYS.FROM)),o=i.getUidFromJid(r),E=a.MessageConstatnts.XMPP_KEYS.TYPE_USER,d=a.MessageConstatnts.RECEIVER_TYPE.USER,h=e.getElementsByTagName("request"),p=e.getElementsByTagName("received");try{S=e.getElementsByTagName("body")[0].innerHTML}catch(e){S=void 0,g=void 0}void 0!==S&&(g=JSON.parse(S).receiverType),C=u.CometChat.getMode(),(c.isFalsy(C)||C&&C===a.APP_SETTINGS.KEYS.DEFAULT_MODE)&&u.CometChat.getLoggedinUser().then((function(s){var c=new l.User(s);c.setAuthToken("");var u=JSON.stringify(c);if(e.getAttribute(a.MessageConstatnts.XMPP_KEYS.TYPE)==a.MessageConstatnts.XMPP_KEYS.TYPE_GROUP||void 0!==g&&g==a.MessageConstatnts.RECEIVER_TYPE.GROUP){if(d=a.MessageConstatnts.RECEIVER_TYPE.GROUP,r=i.getGroupJidFullGroupJid(e.getAttribute(a.MessageConstatnts.XMPP_KEYS.FROM)),E=a.MessageConstatnts.XMPP_KEYS.TYPE_GROUP,r.trim().length>0&&h.length>0){var p=t.$msg({to:r,type:E,from:f._conn.jid,id:f._conn.getUniqueId()}).c("user",{xmlns:"com.cometchat.models:User"}).t(u).up(),S=t.Strophe.xmlElement("delivered",{type:d,receiverId:o,xmlns:t.Strophe.NS.RECEIPTS,id:n});p.tree().appendChild(S),f._conn.send(p)}}else if(h.length>0){p=t.$msg({to:r,type:E,from:f._conn.jid,id:f._conn.getUniqueId()}).c("user",{xmlns:"com.cometchat.models:User"}).t(u).up(),S=t.Strophe.xmlElement("delivered",{type:d,receiverId:o,xmlns:t.Strophe.NS.RECEIPTS,id:n});p.tree().appendChild(S),f._conn.send(p)}})),p.length>0&&(_=p[0].getAttribute(a.DELIVERY_RECEIPTS.ID))&&(delete this._msgQueue[_],delete this._retries[_])}return[2]}))}))},resendQueue:function(){if(this._conn.connected)for(var e in this._msgQueue)this._msgQueue.hasOwnProperty(e)&&this._conn.send(this._msgQueue[e]);else{var t=this;setTimeout((function(){t.resendQueue()}),5e3)}},getUnreceivedMsgs:function(){var e=[];for(var t in this._msgQueue)this._msgQueue.hasOwnProperty(t)&&e.push(this._msgQueue[t]);return e},clearMessages:function(){this._msgQueue={}}})},function(e,t,n){"use strict";t.__esModule=!0;var r=n(46),s=n(0),o=n(1),i=function(){function e(){}return e.transformPresence=function(e){return e.getAttribute("type")?new r.UserPresence(e.getAttribute(s.PresenceConstatnts.XMPP_KEYS.FROM),s.PresenceConstatnts.STATUS.OFFLINE,(new Date).getTime()):new r.UserPresence(e.getAttribute(s.PresenceConstatnts.XMPP_KEYS.FROM),s.PresenceConstatnts.STATUS.ONLINE,(new Date).getTime())},e.transformPresences=function(e){var t=[];return e.map((function(e){try{t.push(new r.UserPresence(e.getAttribute(s.PresenceConstatnts.XMPP_KEYS.FROM),e.getAttribute(s.PresenceConstatnts.XMPP_KEYS.STATUS),e.getAttribute(s.PresenceConstatnts.XMPP_KEYS.LAST_ACTIVE_AT)))}catch(e){o.Logger.error("PresenceController:transformPresences",e)}})),t},e.transformMUCUserPresence=function(e){return e.getAttribute("type")?new r.UserPresence(e.getAttribute(s.PresenceConstatnts.XMPP_KEYS.FROM),s.PresenceConstatnts.STATUS.LEFT,(new Date).getTime()):new r.UserPresence(e.getAttribute(s.PresenceConstatnts.XMPP_KEYS.FROM),s.PresenceConstatnts.STATUS.JOINED,(new Date).getTime())},e.trandformMUCPresence=function(e){e.getElementsByTagName("x").length>0&&this.transformMUCUserPresence(e)},e}();t.PresenceController=i},function(e,t,n){"use strict";t.__esModule=!0;var r=n(4),s=n(0),o=n(14),i=n(1),a=n(3),c=n(33),u=n(2),l=n(22),E=n(9),d=n(35),h=function(){function e(){this.TAG="calling Log",this.CALL_NO_ANSWER_INTERVAL=45e3,this.view=void 0,this.isDev=!1,this.scrollHight=0,this.scrollHight=0}return e.prototype.getCallListner=function(){return e.callListner},e.prototype.setCallListner=function(t){e.callListner=new l.UserCallListener(t)},e.getInstance=function(){try{return null!=this.callController&&null!=this.callController||(this.callController=new e),this.callController}catch(e){i.Logger.error("CallController: getInstance",e)}},e.prototype.getActiveCall=function(){try{return i.isFalsy(this.call)?null:this.call}catch(e){i.Logger.error("CallController: getActiveCall",e)}},e.prototype.initiateCall=function(e){var t=this;return new Promise((function(n,r){try{i.isFalsy(t.call)?null!=e&&null!=e?(t.call=e,t.joinCallMuc(e.getSessionId()),t.startCallTimer(),n(e)):r(new u.CometChatException(s.CALL_ERROR.ERROR_IN_CALLING)):r(new u.CometChatException(s.CALL_ERROR.CALL_ALREADY_INITIATED))}catch(e){r(new u.CometChatException(e))}}))},e.prototype.onCallInitialized=function(){},e.prototype.joinCall=function(e){i.Logger.log(this.TAG,e)},e.prototype.cancelCall=function(){i.Logger.log(this.TAG,"calceling the call"),this.stopCallTimer()},e.prototype.rejectCall=function(){i.Logger.log(this.TAG,"rejectCall")},e.prototype.sendBusyResponse=function(){i.Logger.log(this.TAG,"sendBusyResponse")},e.prototype.endCall=function(e){var t=this;try{document.getElementsByName("frame").forEach((function(e){t.view&&(t.view.removeChild(e),t.view=void 0)})),this.endCallSession()}catch(e){i.Logger.error("CallController: endCall",e)}},e.prototype.onCallEnded=function(){var e=this;try{if(!i.isFalsy(this.call))if(this.call.getReceiverType()==s.CallConstants.RECEIVER_TYPE_GROUP)i.Logger.info(this.TAG,JSON.stringify(this.call)+"This call ended");else document.getElementsByName("frame").forEach((function(t){e.view.removeChild(t),e.view=void 0})),this.endCallSession()}catch(e){i.Logger.error("CallController:onCallEnded",e)}},e.prototype.unAnswerCall=function(){i.Logger.log(this.TAG,"unAnswerCall")},e.prototype.onCallStarted=function(e){var t=this;return new Promise((function(n,r){try{i.isFalsy(t.call)?null!=e&&null!=e?(t.call=e,t.joinCallMuc(e.getSessionId()),n(e)):r(new u.CometChatException(s.CALL_ERROR.ERROR_IN_CALLING)):r(new u.CometChatException(s.CALL_ERROR.CALL_ALREADY_INITIATED))}catch(e){r(new u.CometChatException(e))}}))},e.prototype.endCallSession=function(){try{this.call&&this.leaveCallMuc(this.call.getSessionId()),this.call=void 0,e.callController=void 0,this.timer&&this.stopCallTimer(),this.view=void 0,this.removeListener(),e.callScreen=null,e.callSettings=null}catch(e){i.Logger.error("CallController:EndCallSession",{e:e})}},e.prototype.joinCallMuc=function(e){try{!a.CometChat.didMessagesPollingStart()&&a.CometChat.getConnectionStatus()==s.CONNECTION_STATUS.CONNECTED&&o.XMPPConnectionHelper.getInstance().connection?i.getAppSettings().then((function(t){o.XMPPConnectionHelper.getInstance().connection.muc.join(i.format(s.XMPP.muc_jid_string,a.CometChat.getAppId(),e,a.CometChat.getAppId(),"call."+i.getJidHost(t)),o.XMPPConnectionHelper.getInstance().connection.jid,null,(function(e){var t=c.PresenceController.transformPresence(e);return o.XMPPConnectionHelper.getInstance().getUsersVCard(t.getUid(),(function(e){if(!i.isFalsy(e.getUid()))if(e.setLastActiveAt(t.getLastActiveAt()),t.getStatus()===s.PresenceConstatnts.STATUS.ONLINE)e.setStatus(s.PresenceConstatnts.STATUS.ONLINE);else e.setStatus(s.PresenceConstatnts.STATUS.OFFLINE)})),!0}))})):i.Logger.log("CallController: joinCallMuc","Currently the system is on polling mechanism")}catch(e){i.Logger.error("CallController: joinCallMuc",e)}},e.prototype.leaveCallMuc=function(e){try{!a.CometChat.didMessagesPollingStart()&&a.CometChat.getConnectionStatus()==s.CONNECTION_STATUS.CONNECTED&&o.XMPPConnectionHelper.getInstance().connection?i.getAppSettings().then((function(t){o.XMPPConnectionHelper.getInstance().connection.muc.leave(i.format(s.XMPP.muc_jid_string,a.CometChat.getAppId(),e,a.CometChat.getAppId(),"call."+i.getJidHost(t)),o.XMPPConnectionHelper.getInstance().connection.jid)})):i.Logger.log("CallController: leaveCallMuc","Currently the system is on polling mechanism")}catch(e){i.Logger.error("CallController: leaveCallMuc",e)}},e.prototype.startCallTimer=function(){var e=this;try{this.timer=setTimeout((function(){e.call?a.CometChat.sendUnansweredResponse(e.call.getSessionId()).then((function(t){e.endCallSession()})):e.endCallSession()}),this.CALL_NO_ANSWER_INTERVAL)}catch(e){i.Logger.error("CallController: startCallTimer",e)}},e.prototype.stopCallTimer=function(){try{clearTimeout(this.timer)}catch(e){i.Logger.error("CallController: stopCallTimer",e)}},e.prototype.startCall=function(t,n){var r=this;try{this.timer&&this.stopCallTimer();var s=document.createElement("iframe");this.getCallUrl().then((function(o){s.src=o+"",s.name="frame",s.setAttribute("allow","camera; microphone; display-capture;"),s.setAttribute("width","100%"),s.setAttribute("height","100%"),e.callScreen=s,e.callSettings=t,n&&(r.view=n),n.appendChild(s),r.addListener()}))}catch(e){i.Logger.error("CallController: startCall",e)}},e.prototype.addListener=function(){window.addEventListener("message",this.handler,!0)},e.prototype.removeListener=function(){window.removeEventListener("message",this.handler,!0)},e.prototype.handler=function(t){var n,o=this,c=e.callSettings,u=e.callScreen,l=e.getInstance().getActiveCall();try{if(void 0!==(n=JSON.parse(t.data))&&n.type==s.CallConstants.POST_MESSAGES.TYPES.HANGUP)e.deviceList=null,l?(i.Logger.info(this.TAG,e.callListner),e.getInstance().leaveCallMuc(l.getSessionId()),window.setTimeout((function(){a.CometChat.endCall(l.getSessionId(),!0).then((function(e){i.Logger.info(o.TAG,{call:e})})).catch((function(e){i.Logger.info(o.TAG,"The Call Was Already Ended")}))}),1e3)):a.CometChat.endCall(c.getSessionId(),!0).then((function(e){i.Logger.info(o.TAG,{call:e})})).catch((function(e){i.Logger.info(o.TAG,"The Call Was Already Ended")}));else if(void 0!==n&&n.type==s.CallConstants.POST_MESSAGES.TYPES.ACTION_MESSAGE&&n.action==s.CallConstants.POST_MESSAGES.ACTIONS.USER_JOINED){if(n.value){var E=void 0,d=n.value;i.isFalsy(d.uid)||i.isFalsy(d.name)||((E=new r.User(d)).setStatus("online"),a.CometChat.user.getUid().toLowerCase()!=E.getUid().toLowerCase()&&e.callListner&&(i.isFalsy(e.callListner._eventListener.onUserJoined)||e.callListner._eventListener.onUserJoined(E)))}}else if(void 0!==n&&n.type==s.CallConstants.POST_MESSAGES.TYPES.ACTION_MESSAGE&&n.action==s.CallConstants.POST_MESSAGES.ACTIONS.USER_LEFT){if(n.value){E=void 0,d=n.value;i.isFalsy(d.uid)||i.isFalsy(d.name)||((E=new r.User(d)).setStatus("online"),a.CometChat.user.getUid().toLowerCase()!=E.getUid().toLowerCase()&&e.callListner&&(i.isFalsy(e.callListner._eventListener.onUserLeft)||e.callListner._eventListener.onUserLeft(E)))}}else if(void 0!==n&&n.type==s.CallConstants.POST_MESSAGES.TYPES.ACTION_MESSAGE&&n.action==s.CallConstants.POST_MESSAGES.ACTIONS.USER_LIST_CHANGED){var h=[];if(n.value&&n.value.length>0)n.value.map((function(e){if(!i.isFalsy(e.uid)&&!i.isFalsy(e.name)){var t=new r.User(e);t.setStatus("online"),h.push(t)}})),e.callListner&&(i.isFalsy(e.callListner._eventListener.onUserListUpdated)||e.callListner._eventListener.onUserListUpdated(h))}else if(void 0!==n&&n.type==s.CallConstants.POST_MESSAGES.TYPES.ACTION_MESSAGE&&n.action==s.CallConstants.POST_MESSAGES.ACTIONS.INITIAL_DEVICE_LIST)i.Logger.info("initialDeviceList received in SDK = ",n),n.value&&(e.deviceList=n.value);else if(void 0!==n&&n.type==s.CallConstants.POST_MESSAGES.TYPES.ACTION_MESSAGE&&n.action==s.CallConstants.POST_MESSAGES.ACTIONS.DEVICE_CHANGE){if(i.Logger.info("onDeviceChange received in SDK = ",n),n.value){e.deviceList=n.value;var p=e.getAvailableDeviceObject(e.deviceList);e.callListner&&(i.isFalsy(e.callListner._eventListener.onMediaDeviceListUpdated)||e.callListner._eventListener.onMediaDeviceListUpdated(p))}}else if(void 0!==n&&n.type==s.CallConstants.POST_MESSAGES.TYPES.ACTION_MESSAGE&&n.action==s.CallConstants.POST_MESSAGES.ACTIONS.RECORDING_TOGGLED){if(i.Logger.info("onRecordingToggled received in SDK = ",n),n.value)if((C=n.value).hasOwnProperty("user")&&C.hasOwnProperty("recordingStarted")&&!i.isFalsy(C.user.uid)&&!i.isFalsy(C.user.name)){var S=new r.User(C.user);S.setStatus("online");var g=C.recordingStarted;e.callListner&&(g?i.isFalsy(e.callListner._eventListener.onRecordingStarted)||e.callListner._eventListener.onRecordingStarted(S):i.isFalsy(e.callListner._eventListener.onRecordingStopped)||e.callListner._eventListener.onRecordingStopped(S))}}else if(void 0!==n&&n.type==s.CallConstants.POST_MESSAGES.TYPES.ACTION_MESSAGE&&n.action==s.CallConstants.POST_MESSAGES.ACTIONS.USER_MUTED){var C;if(i.Logger.info("onUserMuted received in SDK = ",n),n.value)if((C=n.value).hasOwnProperty("muted")&&C.hasOwnProperty("mutedBy")&&!i.isFalsy(C.muted.uid)&&!i.isFalsy(C.muted.name)&&!i.isFalsy(C.mutedBy.uid)&&!i.isFalsy(C.mutedBy.name)){var _=new r.User(C.muted);_.setStatus("online");var f=new r.User(C.mutedBy);f.setStatus("online"),e.callListner&&(i.isFalsy(e.callListner._eventListener.onUserMuted)||e.callListner._eventListener.onUserMuted(_,f))}}else void 0!==n&&n.type==s.CallConstants.POST_MESSAGES.TYPES.ACTION_MESSAGE&&n.action==s.CallConstants.POST_MESSAGES.ACTIONS.SCREEN_SHARE_STARTED?e.callListner&&(i.isFalsy(e.callListner._eventListener.onScreenShareStarted)||e.callListner._eventListener.onScreenShareStarted(null)):void 0!==n&&n.type==s.CallConstants.POST_MESSAGES.TYPES.ACTION_MESSAGE&&n.action==s.CallConstants.POST_MESSAGES.ACTIONS.SCREEN_SHARE_STOPPED?e.callListner&&(i.isFalsy(e.callListner._eventListener.onScreenShareStopped)||e.callListner._eventListener.onScreenShareStopped(null)):void 0!==n&&n.type&&n.action&&n.type==s.CallConstants.POST_MESSAGES.TYPES.ACTION_MESSAGE&&n.action==s.CallConstants.POST_MESSAGES.ACTIONS.LOAD&&null!=u.contentWindow&&u.contentWindow.postMessage({type:s.CallConstants.POST_MESSAGES.TYPES.COMETCHAT_RTC_SETTINGS,callsettings:JSON.stringify(c)},"*")}catch(e){n=void 0,i.Logger.error("CallController: startCall",e)}},e.prototype.getCallUrl=function(){var e=this,t=void 0;return new Promise((function(n,r){try{e.isDev?(t="http://localhost:3000/?v="+s.CALLING_COMPONENT_VERSION,n(t)):E.LocalStorage.getInstance().get(s.APP_SETTINGS.APP_SETTINGS).then((function(e){if(i.isFalsy(e))i.getAppSettings().then((function(e){var r="rtc-web"+e[s.APP_SETTINGS.KEYS.WEBRTC_HOST].slice(3);t="https://"+r+"/?v="+s.CALLING_COMPONENT_VERSION,n(t)}));else{var r="rtc-web"+e[s.APP_SETTINGS.KEYS.WEBRTC_HOST].slice(3);t="https://"+r+"/?v="+s.CALLING_COMPONENT_VERSION,n(t)}}))}catch(e){r(new u.CometChatException(e))}}))},e.getAvailableDeviceArray=function(e){var t=[];try{return e&&e.length>0&&e.map((function(e){t.push(new d.MediaDevice(e.deviceId,e.label,e.active))})),t}catch(e){return i.Logger.error("CallController: getAvailableDeviceArray",e),t}},e.getAvailableDeviceObject=function(t){var n=[],r=[],o=[];try{return i.isFalsy(t)||i.isFalsy(t[s.CallConstants.AUDIO_INPUT_DEVICES])||(n=e.getAvailableDeviceArray(t[s.CallConstants.AUDIO_INPUT_DEVICES])),i.isFalsy(t)||i.isFalsy(t[s.CallConstants.AUDIO_OUTPUT_DEVICES])||(r=e.getAvailableDeviceArray(t[s.CallConstants.AUDIO_OUTPUT_DEVICES])),i.isFalsy(t)||i.isFalsy(t[s.CallConstants.VIDEO_INPUT_DEVICES])||(o=e.getAvailableDeviceArray(t[s.CallConstants.VIDEO_INPUT_DEVICES])),{audioInputDevices:n,audioOutputDevices:r,videoInputDevices:o}}catch(e){return i.Logger.error("CallController: getAvailableDeviceObject",e),{audioInputDevices:n,audioOutputDevices:r,videoInputDevices:o}}},e.prototype.getAudioInputDevices=function(){var t=[];try{return i.isFalsy(e.deviceList)||i.isFalsy(e.deviceList[s.CallConstants.AUDIO_INPUT_DEVICES])||(t=e.getAvailableDeviceArray(e.deviceList[s.CallConstants.AUDIO_INPUT_DEVICES])),t}catch(e){return i.Logger.error("CallController: getAudioInputDevices",e),t}},e.prototype.getAudioOutputDevices=function(){var t=[];try{return i.isFalsy(e.deviceList)||i.isFalsy(e.deviceList[s.CallConstants.AUDIO_OUTPUT_DEVICES])||(t=e.getAvailableDeviceArray(e.deviceList[s.CallConstants.AUDIO_OUTPUT_DEVICES])),t}catch(e){return i.Logger.error("CallController: getAudioOutputDevices",e),t}},e.prototype.getVideoInputDevices=function(){var t=[];try{return i.isFalsy(e.deviceList)||i.isFalsy(e.deviceList[s.CallConstants.VIDEO_INPUT_DEVICES])||(t=e.getAvailableDeviceArray(e.deviceList[s.CallConstants.VIDEO_INPUT_DEVICES])),t}catch(e){return i.Logger.error("CallController: getVideoInputDevices",e),t}},e.prototype.setAudioInputDevice=function(t){try{if(e.callScreen&&!i.isFalsy(t)){var n=e.getAvailableDeviceArray(e.deviceList[s.CallConstants.AUDIO_INPUT_DEVICES]).filter((function(e){return e[s.CallConstants.MEDIA_DEVICE.ID]===t&&!e[s.CallConstants.MEDIA_DEVICE.ACTIVE]}));n&&n.length>0&&e.callScreen.contentWindow.postMessage({type:s.CallConstants.POST_MESSAGES.TYPES.ACTION_MESSAGE,action:s.CallConstants.POST_MESSAGES.ACTIONS.CHANGE_AUDIO_INPUT,value:t},"*")}}catch(e){i.Logger.error("CallController: setAudioInputDevice",e)}},e.prototype.setAudioOutputDevice=function(t){try{if(e.callScreen&&!i.isFalsy(t)){var n=e.getAvailableDeviceArray(e.deviceList[s.CallConstants.AUDIO_OUTPUT_DEVICES]).filter((function(e){return e[s.CallConstants.MEDIA_DEVICE.ID]===t&&!e[s.CallConstants.MEDIA_DEVICE.ACTIVE]}));n&&n.length>0&&e.callScreen.contentWindow.postMessage({type:s.CallConstants.POST_MESSAGES.TYPES.ACTION_MESSAGE,action:s.CallConstants.POST_MESSAGES.ACTIONS.CHANGE_AUDIO_OUTPUT,value:t},"*")}}catch(e){i.Logger.error("CallController: setAudioOutputDevice",e)}},e.prototype.setVideoInputDevice=function(t){try{if(e.callScreen&&!i.isFalsy(t)){var n=e.getAvailableDeviceArray(e.deviceList[s.CallConstants.VIDEO_INPUT_DEVICES]).filter((function(e){return e[s.CallConstants.MEDIA_DEVICE.ID]===t&&!e[s.CallConstants.MEDIA_DEVICE.ACTIVE]}));n&&n.length>0&&e.callScreen.contentWindow.postMessage({type:s.CallConstants.POST_MESSAGES.TYPES.ACTION_MESSAGE,action:s.CallConstants.POST_MESSAGES.ACTIONS.CHANGE_VIDEO_INPUT,value:t},"*")}}catch(e){i.Logger.error("CallController: setVideoInputDevice",e)}},e.prototype.muteAudio=function(t){try{e.callScreen&&(t?e.callScreen.contentWindow.postMessage({type:s.CallConstants.POST_MESSAGES.TYPES.ACTION_MESSAGE,action:s.CallConstants.POST_MESSAGES.ACTIONS.MUTE_AUDIO},"*"):e.callScreen.contentWindow.postMessage({type:s.CallConstants.POST_MESSAGES.TYPES.ACTION_MESSAGE,action:s.CallConstants.POST_MESSAGES.ACTIONS.UNMUTE_AUDIO},"*"))}catch(e){i.Logger.error("CallController: muteAudio",e)}},e.prototype.pauseVideo=function(t){try{e.callScreen&&(t?e.callScreen.contentWindow.postMessage({type:s.CallConstants.POST_MESSAGES.TYPES.ACTION_MESSAGE,action:s.CallConstants.POST_MESSAGES.ACTIONS.PAUSE_VIDEO},"*"):e.callScreen.contentWindow.postMessage({type:s.CallConstants.POST_MESSAGES.TYPES.ACTION_MESSAGE,action:s.CallConstants.POST_MESSAGES.ACTIONS.UNPAUSE_VIDEO},"*"))}catch(e){i.Logger.error("CallController: pauseVideo",e)}},e.prototype.setMode=function(t){try{e.callScreen&&!i.isFalsy(t)&&(t=t.toUpperCase(),Object.values(s.CallConstants.CALL_MODE).indexOf(t)>-1&&t!=s.CallConstants.CALL_MODE.SINGLE&&e.callScreen.contentWindow.postMessage({type:s.CallConstants.POST_MESSAGES.TYPES.ACTION_MESSAGE,action:s.CallConstants.POST_MESSAGES.ACTIONS.SWITCH_MODE,value:t},"*"))}catch(e){i.Logger.error("CallController: setMode",e)}},e.prototype.startScreenShare=function(){try{e.callScreen&&e.callScreen.contentWindow.postMessage({type:s.CallConstants.POST_MESSAGES.TYPES.ACTION_MESSAGE,action:s.CallConstants.POST_MESSAGES.ACTIONS.START_SCREENSHARE},"*")}catch(e){i.Logger.error("CallController: startScreenShare",e)}},e.prototype.stopScreenShare=function(){try{e.callScreen&&e.callScreen.contentWindow.postMessage({type:s.CallConstants.POST_MESSAGES.TYPES.ACTION_MESSAGE,action:s.CallConstants.POST_MESSAGES.ACTIONS.STOP_SCREENSHARE},"*")}catch(e){i.Logger.error("CallController: stopScreenShare",e)}},e.prototype.startRecording=function(){try{e.callScreen&&e.callScreen.contentWindow.postMessage({type:s.CallConstants.POST_MESSAGES.TYPES.ACTION_MESSAGE,action:s.CallConstants.POST_MESSAGES.ACTIONS.START_RECORDING},"*")}catch(e){i.Logger.error("CallController: startRecording",e)}},e.prototype.stopRecording=function(){try{e.callScreen&&e.callScreen.contentWindow.postMessage({type:s.CallConstants.POST_MESSAGES.TYPES.ACTION_MESSAGE,action:s.CallConstants.POST_MESSAGES.ACTIONS.STOP_RECORDING},"*")}catch(e){i.Logger.error("CallController: stopRecording",e)}},e.prototype.endSession=function(){try{e.callScreen&&e.callScreen.contentWindow.postMessage({type:s.CallConstants.POST_MESSAGES.TYPES.ACTION_MESSAGE,action:s.CallConstants.POST_MESSAGES.ACTIONS.END_CALL},"*")}catch(e){i.Logger.error("CallController: endSession",e)}},e.prototype.destroy=function(){try{i.isFalsy(this.call)||(this.call=void 0),i.isFalsy(this.timer)||(this.timer=void 0),i.isFalsy(this.view)||(this.view=void 0)}catch(e){i.Logger.error("CallController: destroy",e)}},e.callController=void 0,e.callListner=void 0,e}();t.CallController=h},function(e,t,n){"use strict";t.__esModule=!0;var r=n(1),s=function(){function e(e,t,n){this.id="",this.name="",this.active=!1,r.isFalsy(e)||(this.id=e),r.isFalsy(t)||(this.name=t),this.active=!!n}return e.prototype.getId=function(){return this.id},e.prototype.setId=function(e){this.id=e||""},e.prototype.getName=function(){return this.name},e.prototype.setName=function(e){this.name=e||""},e.prototype.getIsActive=function(){return this.active},e.prototype.setIsActive=function(e){this.active=!!e},e}();t.MediaDevice=s},function(e,t,n){"use strict";t.__esModule=!0;var r=function(){function e(e,t,n){this.receiverId=e,this.receiverType=t,this.metadata=n}return e.prototype.getReceiverType=function(){return this.receiverType},e.prototype.setReceiverType=function(e){this.receiverType=e},e.prototype.getReceiverId=function(){return this.receiverId},e.prototype.setReceiverId=function(e){this.receiverId=e},e.prototype.getMetadata=function(){return this.metadata},e.prototype.setMetadata=function(e){this.metadata=e},e.prototype.getSender=function(){return this.sender},e.prototype.setSender=function(e){this.sender=e},e}();t.TypingIndicator=r},function(e,t,n){"use strict";t.__esModule=!0;var r=n(1),s=n(0),o=n(14),i=function(){function e(){}return e.addTypingStarted=function(e){this.TYPING_STARTED_MAP[e]=r.getCurrentTime()},e.removeTypingStarted=function(e){delete this.TYPING_STARTED_MAP[e]},e.getTypingStartedMap=function(e){if(e)return this.TYPING_STARTED_MAP[e]},e.addTypingEnded=function(e){this.TYPING_ENDED_MAP[e]=r.getCurrentTime()},e.removeTypingEnded=function(e){delete this.TYPING_ENDED_MAP[e]},e.getTypingEndedMap=function(e){if(e)return this.TYPING_ENDED_MAP[e]},e.addIncomingTypingStarted=function(e){this.INCOMING_TYPING_STARTED_MAP[e.getReceiverId()]={typingNotification:e,timestamp:r.getCurrentTime()}},e.removeIncomingTypingStarted=function(e){delete this.INCOMING_TYPING_STARTED_MAP[e.getReceiverId()]},e.clearTimer=function(){var e=this;new Promise((function(t,n){Object.keys(e.TYPING_STARTED_MAP).map((function(t){r.getCurrentTime()-e.TYPING_STARTED_MAP[t]>=1e3*s.DEFAULT_VALUES.DEFAULT_MAX_TYPING_INDICATOR_LIMIT&&delete e.TYPING_STARTED_MAP[t]}))})),new Promise((function(t,n){Object.keys(e.TYPING_ENDED_MAP).map((function(t){r.getCurrentTime()-e.TYPING_ENDED_MAP[t]>=1e3*s.DEFAULT_VALUES.DEFAULT_MAX_TYPING_INDICATOR_LIMIT&&delete e.TYPING_ENDED_MAP[t]}))})),new Promise((function(t,n){Object.keys(e.INCOMING_TYPING_STARTED_MAP).map((function(t){r.getCurrentTime()-e.INCOMING_TYPING_STARTED_MAP[t][s.TYPING_NOTIFICATION.KEYS.TIMESTAMP]>=1e3*s.DEFAULT_VALUES.DEFAULT_MAX_TYPING_INDICATOR_LIMIT&&(o.XMPPConnectionHelper.getInstance().publishTypinStatusNotification(e.INCOMING_TYPING_STARTED_MAP[t][s.TYPING_NOTIFICATION.KEYS.TYPING_NOTIFICATION],s.TYPING_NOTIFICATION.ACTIONS.ENDED),delete e.INCOMING_TYPING_STARTED_MAP[t])}))}))},e.TYPING_STARTED_MAP={},e.TYPING_ENDED_MAP={},e.INCOMING_TYPING_STARTED_MAP={},e}();t.TypingNotificationController=i},function(e,t,n){"use strict";var r=this&&this.__awaiter||function(e,t,n,r){return new(n||(n=Promise))((function(s,o){function i(e){try{c(r.next(e))}catch(e){o(e)}}function a(e){try{c(r.throw(e))}catch(e){o(e)}}function c(e){e.done?s(e.value):new n((function(t){t(e.value)})).then(i,a)}c((r=r.apply(e,t||[])).next())}))},s=this&&this.__generator||function(e,t){var n,r,s,o,i={label:0,sent:function(){if(1&s[0])throw s[1];return s[1]},trys:[],ops:[]};return o={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(o[Symbol.iterator]=function(){return this}),o;function a(o){return function(a){return function(o){if(n)throw new TypeError("Generator is already executing.");for(;i;)try{if(n=1,r&&(s=2&o[0]?r.return:o[0]?r.throw||((s=r.return)&&s.call(r),0):r.next)&&!(s=s.call(r,o[1])).done)return s;switch(r=0,s&&(o=[2&o[0],s.value]),o[0]){case 0:case 1:s=o;break;case 4:return i.label++,{value:o[1],done:!1};case 5:i.label++,r=o[1],o=[0];continue;case 7:o=i.ops.pop(),i.trys.pop();continue;default:if(!(s=i.trys,(s=s.length>0&&s[s.length-1])||6!==o[0]&&2!==o[0])){i=0;continue}if(3===o[0]&&(!s||o[1]>s[0]&&o[1]<s[3])){i.label=o[1];break}if(6===o[0]&&i.label<s[1]){i.label=s[1],s=o;break}if(s&&i.label<s[2]){i.label=s[2],i.ops.push(o);break}s[2]&&i.ops.pop(),i.trys.pop();continue}o=t.call(e,i)}catch(e){o=[6,e],r=0}finally{n=s=0}if(5&o[0])throw o[1];return{value:o[0]?o[1]:void 0,done:!0}}([o,a])}}};t.__esModule=!0;var o=n(3),i=function(){function e(){}return e.addCometChatExtension=function(t){return r(this,void 0,void 0,(function(){return s(this,(function(n){switch(n.label){case 0:return e.cometChatExtensionList.push(t),o.CometChat.user?[4,t.onInit(o.CometChat.getAppId(),o.CometChat.user)]:[3,2];case 1:return n.sent(),[3,4];case 2:return[4,t.onInit(o.CometChat.getAppId())];case 3:n.sent(),n.label=4;case 4:return[2]}}))}))},e.cometChatExtensionList=[],e}();t.ExtensionManager=i},function(e,t,n){"use strict";t.__esModule=!0;var r=n(0),s=function(){function e(t){this.subscriptionType=e.SUBSCRIPTION_TYPE_NONE,this.roles=null,this.region=r.DEFAULT_VALUES.REGION_DEFAULT,this.autoJoinGroup=!0,this.subscriptionType=t.subscriptionType,this.roles=t.roles,this.region=t.region,this.autoJoinGroup=t.autoJoinGroup}return e.prototype.getSubscriptionType=function(){return this.subscriptionType},e.prototype.getRoles=function(){return this.roles},e.prototype.getRegion=function(){return this.region},e.prototype.getIsAutoJoinEnabled=function(){return this.autoJoinGroup},e.SUBSCRIPTION_TYPE_NONE="NONE",e.SUBSCRIPTION_TYPE_ALL_USERS="ALL_USERS",e.SUBSCRIPTION_TYPE_ROLES="ROLES",e.SUBSCRIPTION_TYPE_FRIENDS="FRIENDS",e.REGION_EU=r.DEFAULT_VALUES.REGION_DEFAULT_EU,e.REGION_US=r.DEFAULT_VALUES.REGION_DEFAULT_US,e.REGION_IN=r.DEFAULT_VALUES.REGION_DEFAULT_IN,e.REGION_PRIVATE=r.DEFAULT_VALUES.REGION_DEFAULT_PRIVATE,e}();t.AppSettings=s;var o=function(){function e(){this.subscriptionType=s.SUBSCRIPTION_TYPE_NONE,this.roles=null,this.region=r.DEFAULT_VALUES.REGION_DEFAULT,this.autoJoinGroup=!0}return e.prototype.subscribePresenceForAllUsers=function(){return this.subscriptionType=s.SUBSCRIPTION_TYPE_ALL_USERS,this},e.prototype.subscribePresenceForRoles=function(e){return this.subscriptionType=s.SUBSCRIPTION_TYPE_ROLES,this.roles=e,this},e.prototype.subscribePresenceForFriends=function(){return this.subscriptionType=s.SUBSCRIPTION_TYPE_FRIENDS,this},e.prototype.setRegion=function(e){return void 0===e&&(e=r.DEFAULT_VALUES.REGION_DEFAULT),this.region=e.toLowerCase(),this},e.prototype.enableAutoJoinForGroups=function(e){return void 0===e&&(e=!0),this.autoJoinGroup=e,this},e.prototype.build=function(){return new s(this)},e}();t.AppSettingsBuilder=o},function(e,t,n){"use strict";t.__esModule=!0;var r=n(3),s=n(1),o=n(0),i=n(12),a=function(){function e(e){this.store=o.constants.DEFAULT_STORE,s.isFalsy(e)||(this.store=e),this.userStore=i.createInstance({name:s.format(o.LOCAL_STORE.STORE_STRING,r.CometChat.getAppId(),o.LOCAL_STORE.USERS_STORE)}),this.userStore.setDriver([i.LOCALSTORAGE,i.INDEXEDDB,i.WEBSQL])}return e.getInstance=function(){return null==e.UserStore&&(e.UserStore=new e),e.UserStore},e.prototype.set=function(e,t){return this.userStore.setItem(e,t)},e.prototype.remove=function(e){this.userStore.removeItem(e)},e.prototype.get=function(e){return this.userStore.getItem(e)},e.prototype.clearStore=function(){var e=this;return new Promise((function(t,n){e.userStore.clear().then((function(){t(!0)})).catch((function(e){n(e)}))}))},e.prototype.clear=function(e){},e.prototype.selectStore=function(e){this.store=e},e.prototype.storeUsers=function(e){var t=this;return e.map((function(e){t.set(e.getUid(),e)})),!0},e.prototype.storeUser=function(e){return this.set(e.getUid(),e),!0},e}();t.UserStore=a},function(e,t,n){"use strict";t.__esModule=!0;var r=n(0),s=function(){function e(e,t){this.joinedAt=0,this.isBanned=0,this.uid=e,t&&(this.scope=t)}return e.prototype.getName=function(){return this.name},e.prototype.setName=function(e){this.name=e},e.prototype.getAvatar=function(){return this.avatar},e.prototype.setAvatar=function(e){this.avatar=e},e.prototype.getLastActiveAt=function(){return this.lastActiveAt},e.prototype.setLastActiveAt=function(e){this.lastActiveAt=e},e.prototype.getLink=function(){return this.link},e.prototype.setLink=function(e){this.link=e},e.prototype.getMetadata=function(){return this.metadata},e.prototype.setMetadata=function(e){this.metadata=e},e.prototype.getRole=function(){return this.role},e.prototype.setRole=function(e){this.role=e},e.prototype.getStatus=function(){return this.status},e.prototype.setStatus=function(e){this.status=e},e.prototype.getStatusMessage=function(){return this.statusMessage},e.prototype.setStatusMessage=function(e){this.statusMessage=e},e.prototype.setGuid=function(e){this.guid=e},e.prototype.setUid=function(e){this.uid=e},e.prototype.setScope=function(e){this.scope=e},e.prototype.setJoinedAt=function(e){this.joinedAt=e},e.prototype.setIsBanned=function(e){this.isBanned=e},e.prototype.setUser=function(e){this.user=e},e.prototype.getGuid=function(){return this.guid},e.prototype.getUid=function(){return this.uid},e.prototype.getuser=function(){return this.user},e.prototype.getScope=function(){return this.scope},e.prototype.getJoinedAt=function(){return this.joinedAt},e.prototype.getIsBanned=function(){return this.isBanned},e.GroupMemberScope=r.GroupMemberScope,e}();t.GroupMember=s},function(e,t,n){"use strict";t.__esModule=!0;var r=n(7),s=n(0),o=n(8),i=n(16),a=function(){function e(e,t,n,a,c){this.conversationId=e,this.conversationType=t,void 0!==n&&(this.lastMessage=n,void 0!==n.id&&(this.lastMessage=r.MessageController.trasformJSONMessge(n))),this.conversationType==s.MessageConstatnts.RECEIVER_TYPE.USER?this.conversationWith=o.UsersController.trasformJSONUser(a):this.conversationWith=i.GroupsController.trasformJSONGroup(a),this.unreadMessageCount=void 0!==c?parseInt(c):0}return e.prototype.setConversationId=function(e){this.conversationId=e},e.prototype.setConversationType=function(e){this.conversationType=e},e.prototype.setLastMessage=function(e){this.lastMessage=e},e.prototype.setConversationWith=function(e){this.conversationWith=e},e.prototype.setUnreadMessageCount=function(e){this.unreadMessageCount=e},e.prototype.getConversationId=function(){return this.conversationId},e.prototype.getConversationType=function(){return this.conversationType},e.prototype.getLastMessage=function(){return this.lastMessage},e.prototype.getConversationWith=function(){return this.conversationWith},e.prototype.getUnreadMessageCount=function(){return this.unreadMessageCount},e}();t.Conversation=a},function(e,t,n){var r=n(17).NAMESPACE;function s(e){return""!==e}function o(e,t){return e.hasOwnProperty(t)||(e[t]=!0),e}function i(e){if(!e)return[];var t=function(e){return e?e.split(/[\t\n\f\r ]+/).filter(s):[]}(e);return Object.keys(t.reduce(o,{}))}function a(e,t){for(var n in e)t[n]=e[n]}function c(e,t){var n=e.prototype;if(!(n instanceof t)){function r(){}r.prototype=t.prototype,a(n,r=new r),e.prototype=n=r}n.constructor!=e&&(n.constructor=e)}var u={},l=u.ELEMENT_NODE=1,E=u.ATTRIBUTE_NODE=2,d=u.TEXT_NODE=3,h=u.CDATA_SECTION_NODE=4,p=u.ENTITY_REFERENCE_NODE=5,S=u.ENTITY_NODE=6,g=u.PROCESSING_INSTRUCTION_NODE=7,C=u.COMMENT_NODE=8,_=u.DOCUMENT_NODE=9,f=u.DOCUMENT_TYPE_NODE=10,T=u.DOCUMENT_FRAGMENT_NODE=11,m=u.NOTATION_NODE=12,A={},I={},R=(A.INDEX_SIZE_ERR=(I[1]="Index size error",1),A.DOMSTRING_SIZE_ERR=(I[2]="DOMString size error",2),A.HIERARCHY_REQUEST_ERR=(I[3]="Hierarchy request error",3)),N=(A.WRONG_DOCUMENT_ERR=(I[4]="Wrong document",4),A.INVALID_CHARACTER_ERR=(I[5]="Invalid character",5),A.NO_DATA_ALLOWED_ERR=(I[6]="No data allowed",6),A.NO_MODIFICATION_ALLOWED_ERR=(I[7]="No modification allowed",7),A.NOT_FOUND_ERR=(I[8]="Not found",8)),O=(A.NOT_SUPPORTED_ERR=(I[9]="Not supported",9),A.INUSE_ATTRIBUTE_ERR=(I[10]="Attribute in use",10));A.INVALID_STATE_ERR=(I[11]="Invalid state",11),A.SYNTAX_ERR=(I[12]="Syntax error",12),A.INVALID_MODIFICATION_ERR=(I[13]="Invalid modification",13),A.NAMESPACE_ERR=(I[14]="Invalid namespace",14),A.INVALID_ACCESS_ERR=(I[15]="Invalid access",15);function y(e,t){if(t instanceof Error)var n=t;else n=this,Error.call(this,I[e]),this.message=I[e],Error.captureStackTrace&&Error.captureStackTrace(this,y);return n.code=e,t&&(this.message=this.message+": "+t),n}function P(){}function M(e,t){this._node=e,this._refresh=t,v(this)}function v(e){var t=e._node._inc||e._node.ownerDocument._inc;if(e._inc!=t){var n=e._refresh(e._node);ue(e,"length",n.length),a(n,e),e._inc=t}}function L(){}function D(e,t){for(var n=e.length;n--;)if(e[n]===t)return n}function U(e,t,n,s){if(s?t[D(t,s)]=n:t[t.length++]=n,e){n.ownerElement=e;var o=e.ownerDocument;o&&(s&&B(o,e,s),function(e,t,n){e&&e._inc++,n.namespaceURI===r.XMLNS&&(t._nsMap[n.prefix?n.localName:""]=n.value)}(o,e,n))}}function w(e,t,n){var r=D(t,n);if(!(r>=0))throw y(N,new Error(e.tagName+"@"+n));for(var s=t.length-1;r<s;)t[r]=t[++r];if(t.length=s,e){var o=e.ownerDocument;o&&(B(o,e,n),n.ownerElement=null)}}function b(){}function G(){}function Y(e){return("<"==e?"<":">"==e&&">")||"&"==e&&"&"||'"'==e&&"""||"&#"+e.charCodeAt()+";"}function x(e,t){if(t(e))return!0;if(e=e.firstChild)do{if(x(e,t))return!0}while(e=e.nextSibling)}function F(){}function B(e,t,n,s){e&&e._inc++,n.namespaceURI===r.XMLNS&&delete t._nsMap[n.prefix?n.localName:""]}function H(e,t,n){if(e&&e._inc){e._inc++;var r=t.childNodes;if(n)r[r.length++]=n;else{for(var s=t.firstChild,o=0;s;)r[o++]=s,s=s.nextSibling;r.length=o}}}function K(e,t){var n=t.previousSibling,r=t.nextSibling;return n?n.nextSibling=r:e.firstChild=r,r?r.previousSibling=n:e.lastChild=n,H(e.ownerDocument,e),t}function k(e,t,n){var r=t.parentNode;if(r&&r.removeChild(t),t.nodeType===T){var s=t.firstChild;if(null==s)return t;var o=t.lastChild}else s=o=t;var i=n?n.previousSibling:e.lastChild;s.previousSibling=i,o.nextSibling=n,i?i.nextSibling=s:e.firstChild=s,null==n?e.lastChild=o:n.previousSibling=o;do{s.parentNode=e}while(s!==o&&(s=s.nextSibling));return H(e.ownerDocument||e,e),t.nodeType==T&&(t.firstChild=t.lastChild=null),t}function V(){this._nsMap={}}function J(){}function X(){}function j(){}function q(){}function W(){}function Q(){}function z(){}function $(){}function Z(){}function ee(){}function te(){}function ne(){}function re(e,t){var n=[],r=9==this.nodeType&&this.documentElement||this,s=r.prefix,o=r.namespaceURI;if(o&&null==s&&null==(s=r.lookupPrefix(o)))var i=[{namespace:o,prefix:null}];return ie(this,n,e,t,i),n.join("")}function se(e,t,n){var s=e.prefix||"",o=e.namespaceURI;if(!o)return!1;if("xml"===s&&o===r.XML||o===r.XMLNS)return!1;for(var i=n.length;i--;){var a=n[i];if(a.prefix===s)return a.namespace!==o}return!0}function oe(e,t,n){e.push(" ",t,'="',n.replace(/[<&"]/g,Y),'"')}function ie(e,t,n,s,o){if(o||(o=[]),s){if(!(e=s(e)))return;if("string"==typeof e)return void t.push(e)}switch(e.nodeType){case l:var i=e.attributes,a=i.length,c=e.firstChild,u=e.tagName,S=u;if(!(n=r.isHTML(e.namespaceURI)||n)&&!e.prefix&&e.namespaceURI){for(var m,A=0;A<i.length;A++)if("xmlns"===i.item(A).name){m=i.item(A).value;break}if(m!==e.namespaceURI)for(var I=o.length-1;I>=0;I--){var R=o[I];if(R.namespace===e.namespaceURI){R.prefix&&(S=R.prefix+":"+u);break}}}t.push("<",S);for(var N=0;N<a;N++){"xmlns"==(O=i.item(N)).prefix?o.push({prefix:O.localName,namespace:O.value}):"xmlns"==O.nodeName&&o.push({prefix:"",namespace:O.value})}for(N=0;N<a;N++){var O,y,P;if(se(O=i.item(N),0,o))oe(t,(y=O.prefix||"")?"xmlns:"+y:"xmlns",P=O.namespaceURI),o.push({prefix:y,namespace:P});ie(O,t,n,s,o)}if(u===S&&se(e,0,o))oe(t,(y=e.prefix||"")?"xmlns:"+y:"xmlns",P=e.namespaceURI),o.push({prefix:y,namespace:P});if(c||n&&!/^(?:meta|link|img|br|hr|input)$/i.test(u)){if(t.push(">"),n&&/^script$/i.test(u))for(;c;)c.data?t.push(c.data):ie(c,t,n,s,o.slice()),c=c.nextSibling;else for(;c;)ie(c,t,n,s,o.slice()),c=c.nextSibling;t.push("</",S,">")}else t.push("/>");return;case _:case T:for(c=e.firstChild;c;)ie(c,t,n,s,o.slice()),c=c.nextSibling;return;case E:return oe(t,e.name,e.value);case d:return t.push(e.data.replace(/[<&]/g,Y).replace(/]]>/g,"]]>"));case h:return t.push("<![CDATA[",e.data,"]]>");case C:return t.push("\x3c!--",e.data,"--\x3e");case f:var M=e.publicId,v=e.systemId;if(t.push("<!DOCTYPE ",e.name),M)t.push(" PUBLIC ",M),v&&"."!=v&&t.push(" ",v),t.push(">");else if(v&&"."!=v)t.push(" SYSTEM ",v,">");else{var L=e.internalSubset;L&&t.push(" [",L,"]"),t.push(">")}return;case g:return t.push("<?",e.target," ",e.data,"?>");case p:return t.push("&",e.nodeName,";");default:t.push("??",e.nodeName)}}function ae(e,t,n){var r;switch(t.nodeType){case l:(r=t.cloneNode(!1)).ownerDocument=e;case T:break;case E:n=!0}if(r||(r=t.cloneNode(!1)),r.ownerDocument=e,r.parentNode=null,n)for(var s=t.firstChild;s;)r.appendChild(ae(e,s,n)),s=s.nextSibling;return r}function ce(e,t,n){var r=new t.constructor;for(var s in t){var o=t[s];"object"!=typeof o&&o!=r[s]&&(r[s]=o)}switch(t.childNodes&&(r.childNodes=new P),r.ownerDocument=e,r.nodeType){case l:var i=t.attributes,a=r.attributes=new L,c=i.length;a._ownerElement=r;for(var u=0;u<c;u++)r.setAttributeNode(ce(e,i.item(u),!0));break;case E:n=!0}if(n)for(var d=t.firstChild;d;)r.appendChild(ce(e,d,n)),d=d.nextSibling;return r}function ue(e,t,n){e[t]=n}y.prototype=Error.prototype,a(A,y),P.prototype={length:0,item:function(e){return this[e]||null},toString:function(e,t){for(var n=[],r=0;r<this.length;r++)ie(this[r],n,e,t);return n.join("")}},M.prototype.item=function(e){return v(this),this[e]},c(M,P),L.prototype={length:0,item:P.prototype.item,getNamedItem:function(e){for(var t=this.length;t--;){var n=this[t];if(n.nodeName==e)return n}},setNamedItem:function(e){var t=e.ownerElement;if(t&&t!=this._ownerElement)throw new y(O);var n=this.getNamedItem(e.nodeName);return U(this._ownerElement,this,e,n),n},setNamedItemNS:function(e){var t,n=e.ownerElement;if(n&&n!=this._ownerElement)throw new y(O);return t=this.getNamedItemNS(e.namespaceURI,e.localName),U(this._ownerElement,this,e,t),t},removeNamedItem:function(e){var t=this.getNamedItem(e);return w(this._ownerElement,this,t),t},removeNamedItemNS:function(e,t){var n=this.getNamedItemNS(e,t);return w(this._ownerElement,this,n),n},getNamedItemNS:function(e,t){for(var n=this.length;n--;){var r=this[n];if(r.localName==t&&r.namespaceURI==e)return r}return null}},b.prototype={hasFeature:function(e,t){return!0},createDocument:function(e,t,n){var r=new F;if(r.implementation=this,r.childNodes=new P,r.doctype=n||null,n&&r.appendChild(n),t){var s=r.createElementNS(e,t);r.appendChild(s)}return r},createDocumentType:function(e,t,n){var r=new Q;return r.name=e,r.nodeName=e,r.publicId=t||"",r.systemId=n||"",r}},G.prototype={firstChild:null,lastChild:null,previousSibling:null,nextSibling:null,attributes:null,parentNode:null,childNodes:null,ownerDocument:null,nodeValue:null,namespaceURI:null,prefix:null,localName:null,insertBefore:function(e,t){return k(this,e,t)},replaceChild:function(e,t){this.insertBefore(e,t),t&&this.removeChild(t)},removeChild:function(e){return K(this,e)},appendChild:function(e){return this.insertBefore(e,null)},hasChildNodes:function(){return null!=this.firstChild},cloneNode:function(e){return ce(this.ownerDocument||this,this,e)},normalize:function(){for(var e=this.firstChild;e;){var t=e.nextSibling;t&&t.nodeType==d&&e.nodeType==d?(this.removeChild(t),e.appendData(t.data)):(e.normalize(),e=t)}},isSupported:function(e,t){return this.ownerDocument.implementation.hasFeature(e,t)},hasAttributes:function(){return this.attributes.length>0},lookupPrefix:function(e){for(var t=this;t;){var n=t._nsMap;if(n)for(var r in n)if(n[r]==e)return r;t=t.nodeType==E?t.ownerDocument:t.parentNode}return null},lookupNamespaceURI:function(e){for(var t=this;t;){var n=t._nsMap;if(n&&e in n)return n[e];t=t.nodeType==E?t.ownerDocument:t.parentNode}return null},isDefaultNamespace:function(e){return null==this.lookupPrefix(e)}},a(u,G),a(u,G.prototype),F.prototype={nodeName:"#document",nodeType:_,doctype:null,documentElement:null,_inc:1,insertBefore:function(e,t){if(e.nodeType==T){for(var n=e.firstChild;n;){var r=n.nextSibling;this.insertBefore(n,t),n=r}return e}return null==this.documentElement&&e.nodeType==l&&(this.documentElement=e),k(this,e,t),e.ownerDocument=this,e},removeChild:function(e){return this.documentElement==e&&(this.documentElement=null),K(this,e)},importNode:function(e,t){return ae(this,e,t)},getElementById:function(e){var t=null;return x(this.documentElement,(function(n){if(n.nodeType==l&&n.getAttribute("id")==e)return t=n,!0})),t},getElementsByClassName:function(e){var t=i(e);return new M(this,(function(n){var r=[];return t.length>0&&x(n.documentElement,(function(s){if(s!==n&&s.nodeType===l){var o=s.getAttribute("class");if(o){var a=e===o;if(!a){var c=i(o);a=t.every((u=c,function(e){return u&&-1!==u.indexOf(e)}))}a&&r.push(s)}}var u})),r}))},createElement:function(e){var t=new V;return t.ownerDocument=this,t.nodeName=e,t.tagName=e,t.localName=e,t.childNodes=new P,(t.attributes=new L)._ownerElement=t,t},createDocumentFragment:function(){var e=new ee;return e.ownerDocument=this,e.childNodes=new P,e},createTextNode:function(e){var t=new j;return t.ownerDocument=this,t.appendData(e),t},createComment:function(e){var t=new q;return t.ownerDocument=this,t.appendData(e),t},createCDATASection:function(e){var t=new W;return t.ownerDocument=this,t.appendData(e),t},createProcessingInstruction:function(e,t){var n=new te;return n.ownerDocument=this,n.tagName=n.target=e,n.nodeValue=n.data=t,n},createAttribute:function(e){var t=new J;return t.ownerDocument=this,t.name=e,t.nodeName=e,t.localName=e,t.specified=!0,t},createEntityReference:function(e){var t=new Z;return t.ownerDocument=this,t.nodeName=e,t},createElementNS:function(e,t){var n=new V,r=t.split(":"),s=n.attributes=new L;return n.childNodes=new P,n.ownerDocument=this,n.nodeName=t,n.tagName=t,n.namespaceURI=e,2==r.length?(n.prefix=r[0],n.localName=r[1]):n.localName=t,s._ownerElement=n,n},createAttributeNS:function(e,t){var n=new J,r=t.split(":");return n.ownerDocument=this,n.nodeName=t,n.name=t,n.namespaceURI=e,n.specified=!0,2==r.length?(n.prefix=r[0],n.localName=r[1]):n.localName=t,n}},c(F,G),V.prototype={nodeType:l,hasAttribute:function(e){return null!=this.getAttributeNode(e)},getAttribute:function(e){var t=this.getAttributeNode(e);return t&&t.value||""},getAttributeNode:function(e){return this.attributes.getNamedItem(e)},setAttribute:function(e,t){var n=this.ownerDocument.createAttribute(e);n.value=n.nodeValue=""+t,this.setAttributeNode(n)},removeAttribute:function(e){var t=this.getAttributeNode(e);t&&this.removeAttributeNode(t)},appendChild:function(e){return e.nodeType===T?this.insertBefore(e,null):function(e,t){var n=t.parentNode;if(n){var r=e.lastChild;n.removeChild(t),r=e.lastChild}return r=e.lastChild,t.parentNode=e,t.previousSibling=r,t.nextSibling=null,r?r.nextSibling=t:e.firstChild=t,e.lastChild=t,H(e.ownerDocument,e,t),t}(this,e)},setAttributeNode:function(e){return this.attributes.setNamedItem(e)},setAttributeNodeNS:function(e){return this.attributes.setNamedItemNS(e)},removeAttributeNode:function(e){return this.attributes.removeNamedItem(e.nodeName)},removeAttributeNS:function(e,t){var n=this.getAttributeNodeNS(e,t);n&&this.removeAttributeNode(n)},hasAttributeNS:function(e,t){return null!=this.getAttributeNodeNS(e,t)},getAttributeNS:function(e,t){var n=this.getAttributeNodeNS(e,t);return n&&n.value||""},setAttributeNS:function(e,t,n){var r=this.ownerDocument.createAttributeNS(e,t);r.value=r.nodeValue=""+n,this.setAttributeNode(r)},getAttributeNodeNS:function(e,t){return this.attributes.getNamedItemNS(e,t)},getElementsByTagName:function(e){return new M(this,(function(t){var n=[];return x(t,(function(r){r===t||r.nodeType!=l||"*"!==e&&r.tagName!=e||n.push(r)})),n}))},getElementsByTagNameNS:function(e,t){return new M(this,(function(n){var r=[];return x(n,(function(s){s===n||s.nodeType!==l||"*"!==e&&s.namespaceURI!==e||"*"!==t&&s.localName!=t||r.push(s)})),r}))}},F.prototype.getElementsByTagName=V.prototype.getElementsByTagName,F.prototype.getElementsByTagNameNS=V.prototype.getElementsByTagNameNS,c(V,G),J.prototype.nodeType=E,c(J,G),X.prototype={data:"",substringData:function(e,t){return this.data.substring(e,e+t)},appendData:function(e){e=this.data+e,this.nodeValue=this.data=e,this.length=e.length},insertData:function(e,t){this.replaceData(e,0,t)},appendChild:function(e){throw new Error(I[R])},deleteData:function(e,t){this.replaceData(e,t,"")},replaceData:function(e,t,n){n=this.data.substring(0,e)+n+this.data.substring(e+t),this.nodeValue=this.data=n,this.length=n.length}},c(X,G),j.prototype={nodeName:"#text",nodeType:d,splitText:function(e){var t=this.data,n=t.substring(e);t=t.substring(0,e),this.data=this.nodeValue=t,this.length=t.length;var r=this.ownerDocument.createTextNode(n);return this.parentNode&&this.parentNode.insertBefore(r,this.nextSibling),r}},c(j,X),q.prototype={nodeName:"#comment",nodeType:C},c(q,X),W.prototype={nodeName:"#cdata-section",nodeType:h},c(W,X),Q.prototype.nodeType=f,c(Q,G),z.prototype.nodeType=m,c(z,G),$.prototype.nodeType=S,c($,G),Z.prototype.nodeType=p,c(Z,G),ee.prototype.nodeName="#document-fragment",ee.prototype.nodeType=T,c(ee,G),te.prototype.nodeType=g,c(te,G),ne.prototype.serializeToString=function(e,t,n){return re.call(e,t,n)},G.prototype.toString=re;try{if(Object.defineProperty){function le(e){switch(e.nodeType){case l:case T:var t=[];for(e=e.firstChild;e;)7!==e.nodeType&&8!==e.nodeType&&t.push(le(e)),e=e.nextSibling;return t.join("");default:return e.nodeValue}}Object.defineProperty(M.prototype,"length",{get:function(){return v(this),this.$$length}}),Object.defineProperty(G.prototype,"textContent",{get:function(){return le(this)},set:function(e){switch(this.nodeType){case l:case T:for(;this.firstChild;)this.removeChild(this.firstChild);(e||String(e))&&this.appendChild(this.ownerDocument.createTextNode(e));break;default:this.data=e,this.value=e,this.nodeValue=e}}}),ue=function(e,t,n){e["$$"+t]=n}}}catch(e){}t.DocumentType=Q,t.DOMException=y,t.DOMImplementation=b,t.Element=V,t.Node=G,t.NodeList=P,t.XMLSerializer=ne},function(e,t,n){"use strict";t.__esModule=!0;var r=n(3);t.init=function(e){return r.CometChat.getInstance(e)},t.CometChat=r.CometChat},function(e,t,n){"use strict";t.__esModule=!0;var r=function(){function e(){this.RECEIPT_TYPE={READ_RECEIPT:"read",DELIVERY_RECEIPT:"delivery"},this.receiptType=this.RECEIPT_TYPE.DELIVERY_RECEIPT}return e.prototype.getReceiverType=function(){return this.receiverType},e.prototype.setReceiverType=function(e){this.receiverType=e},e.prototype.getSender=function(){return this.sender},e.prototype.setSender=function(e){this.sender=e},e.prototype.getReceiver=function(){return this.receiver},e.prototype.setReceiver=function(e){this.receiver=e},e.prototype.getTimestamp=function(){return this.timestamp},e.prototype.setTimestamp=function(e){this.timestamp=e},e.prototype.setReadAt=function(e){this.readAt=e},e.prototype.getReadAt=function(){return this.readAt},e.prototype.setDeliveredAt=function(e){this.deliveredAt=e},e.prototype.getDeliveredAt=function(){return this.deliveredAt},e.prototype.getMessageId=function(){return this.messageId},e.prototype.setMessageId=function(e){this.messageId=e},e.prototype.getReceiptType=function(){return this.receiptType},e.prototype.setReceiptType=function(e){void 0===e&&(e=this.RECEIPT_TYPE.DELIVERY_RECEIPT),this.receiptType=e},e}();t.MessageReceipt=r},function(e,t,n){"use strict";t.__esModule=!0;var r=n(1),s=n(11),o=function(){function e(e,t,n,o){r.isFalsy(e)||(this.jid=e,this.uid=s.getUidFromJid(e),r.isFalsy(o)||(this.priority=o),r.isFalsy(t)||(this.status=t),r.isFalsy(n)||(this.lastActiveAt=n))}return e.prototype.getUid=function(){return this.uid},e.prototype.setUid=function(e){this.uid=e},e.prototype.getJid=function(){return this.jid},e.prototype.setJid=function(e){this.jid=e},e.prototype.getPriority=function(){return this.priority},e.prototype.setPriority=function(e){this.priority=e},e.prototype.getStatus=function(){return this.status},e.prototype.setStatus=function(e){this.status=e},e.prototype.getLastActiveAt=function(){return this.lastActiveAt},e.prototype.setLastActiveAt=function(e){this.lastActiveAt=e},e.prototype.getStatusMessage=function(){return this.statusMessage},e.prototype.setStatusMessage=function(e){this.statusMessage=e},e}();t.UserPresence=o},function(e,t,n){!function(e){"use strict";var t,n,r={}.hasOwnProperty,s=function(e,t){return function(){return e.apply(t,arguments)}};e.Strophe.addConnectionPlugin("muc",{_connection:null,rooms:{},roomNames:[],init:function(t){return this._connection=t,this._muc_handler=null,e.Strophe.addNamespace("MUC_OWNER",e.Strophe.NS.MUC+"#owner"),e.Strophe.addNamespace("MUC_ADMIN",e.Strophe.NS.MUC+"#admin"),e.Strophe.addNamespace("MUC_USER",e.Strophe.NS.MUC+"#user"),e.Strophe.addNamespace("MUC_ROOMCONF",e.Strophe.NS.MUC+"#roomconfig"),e.Strophe.addNamespace("MUC_REGISTER","jabber:iq:register")},join:function(t,r,s,o,i,a,c,u){var l,E,d;return E=this.test_append_nick(t,r),l=e.$pres({from:this._connection.jid,to:E}).c("x",{xmlns:e.Strophe.NS.MUC}),null!=c&&(l=l.c("history",c).up()),null!=a&&l.cnode(e.Strophe.xmlElement("password",[],a)),null!=u&&l.up().cnode(u),null==this._muc_handler&&(this._muc_handler=this._connection.addHandler((d=this,function(n){var r,s,o,i,a,c,u,l;if(!(r=n.getAttribute("from")))return!0;if(c=r.split("/")[0],!d.rooms[c])return!0;if(t=d.rooms[c],s={},"message"===n.nodeName)s=t._message_handlers;else if("presence"===n.nodeName&&(l=n.getElementsByTagName("x")).length>0)for(o=0,a=l.length;o<a;o++)if((u=l[o].getAttribute("xmlns"))&&u.match(e.Strophe.NS.MUC)){s=t._presence_handlers;break}for(i in s)(0,s[i])(n,t)||delete s[i];return!0}))),this.rooms.hasOwnProperty(t)||(this.rooms[t]=new n(this,t,r,a),o&&this.rooms[t].addHandler("presence",o),s&&this.rooms[t].addHandler("message",s),i&&this.rooms[t].addHandler("roster",i),this.roomNames.push(t)),this._connection.send(l)},leave:function(t,n,r,s){var o,i,a,c;return o=this.roomNames.indexOf(t),delete this.rooms[t],o>=0&&(this.roomNames.splice(o,1),0===this.roomNames.length&&(this._connection.deleteHandler(this._muc_handler),this._muc_handler=null)),c=this.test_append_nick(t,n),a=this._connection.getUniqueId(),i=e.$pres({type:"unavailable",id:a,from:this._connection.jid,to:c}),null!=s&&i.c("status",s),null!=r&&this._connection.addHandler(r,null,"presence",null,a),this._connection.send(i),a},message:function(t,n,r,s,o,i){var a,c,u;return u=this.test_append_nick(t,n),o=o||(null!=n?"chat":"groupchat"),i=i||this._connection.getUniqueId(),(a=e.$msg({to:u,from:this._connection.jid,type:o,id:i}).c("body").t(r)).up(),null!=s&&(a.c("html",{xmlns:e.Strophe.NS.XHTML_IM}).c("body",{xmlns:e.Strophe.NS.XHTML}).h(s),0===a.node.childNodes.length?(c=a.node.parentNode,a.up().up(),a.node.removeChild(c)):a.up().up()),a.c("x",{xmlns:"jabber:x:event"}).c("composing"),this._connection.send(a),i},groupchat:function(e,t,n,r){return this.message(e,null,t,n,void 0,r)},invite:function(t,n,r){var s,o;return o=this._connection.getUniqueId(),s=e.$msg({from:this._connection.jid,to:t,id:o}).c("x",{xmlns:e.Strophe.NS.MUC_USER}).c("invite",{to:n}),null!=r&&s.c("reason",r),this._connection.send(s),o},multipleInvites:function(t,n,r){var s,o,i,a,c;for(a=this._connection.getUniqueId(),o=e.$msg({from:this._connection.jid,to:t,id:a}).c("x",{xmlns:e.Strophe.NS.MUC_USER}),s=0,i=n.length;s<i;s++)c=n[s],o.c("invite",{to:c}),null!=r&&(o.c("reason",r),o.up()),o.up();return this._connection.send(o),a},directInvite:function(t,n,r,s){var o,i,a;return a=this._connection.getUniqueId(),o={xmlns:"jabber:x:conference",jid:t},null!=r&&(o.reason=r),null!=s&&(o.password=s),i=e.$msg({from:this._connection.jid,to:n,id:a}).c("x",o),this._connection.send(i),a},queryOccupants:function(t,n,r){var s,o;return s={xmlns:e.Strophe.NS.DISCO_ITEMS},o=e.$iq({from:this._connection.jid,to:t,type:"get"}).c("query",s),this._connection.sendIQ(o,n,r)},configure:function(t,n,r){var s;return s=e.$iq({to:t,type:"get"}).c("query",{xmlns:e.Strophe.NS.MUC_OWNER}).tree(),this._connection.sendIQ(s,n,r)},cancelConfigure:function(t){var n;return n=e.$iq({to:t,type:"set"}).c("query",{xmlns:e.Strophe.NS.MUC_OWNER}).c("x",{xmlns:"jabber:x:data",type:"cancel"}).tree(),this._connection.sendIQ(n)},saveConfiguration:function(t,n,r,s){var o,i,a,c,u;if(a=e.$iq({to:t,type:"set"}).c("query",{xmlns:e.Strophe.NS.MUC_OWNER}),void 0!==e.Strophe.x&&void 0!==e.Strophe.x.Form&&n instanceof e.Strophe.x.Form)n.type="submit",a.cnode(n.toXML());else for(a.c("x",{xmlns:"jabber:x:data",type:"submit"}),i=0,c=n.length;i<c;i++)o=n[i],a.cnode(o).up();return u=a.tree(),this._connection.sendIQ(u,r,s)},createInstantRoom:function(t,n,r){var s;return s=e.$iq({to:t,type:"set"}).c("query",{xmlns:e.Strophe.NS.MUC_OWNER}).c("x",{xmlns:"jabber:x:data",type:"submit"}),this._connection.sendIQ(s.tree(),n,r)},createConfiguredRoom:function(t,n,s,o){var i,a,c;for(i in(a=e.$iq({to:t,type:"set"}).c("query",{xmlns:e.Strophe.NS.MUC_OWNER}).c("x",{xmlns:"jabber:x:data",type:"submit"})).c("field",{var:"FORM_TYPE"}).c("value").t("http://jabber.org/protocol/muc#roomconfig").up().up(),n)r.call(n,i)&&(c=n[i],a.c("field",{var:i}).c("value").t(c).up().up());return this._connection.sendIQ(a.tree(),s,o)},setTopic:function(t,n){var r;return r=e.$msg({to:t,from:this._connection.jid,type:"groupchat"}).c("subject",{xmlns:"jabber:client"}).t(n),this._connection.send(r.tree())},_modifyPrivilege:function(t,n,r,s,o){var i;return i=e.$iq({to:t,type:"set"}).c("query",{xmlns:e.Strophe.NS.MUC_ADMIN}).cnode(n.node),null!=r&&i.c("reason",r),this._connection.sendIQ(i.tree(),s,o)},modifyRole:function(t,n,r,s,o,i){var a;return a=e.$build("item",{nick:n,role:r}),this._modifyPrivilege(t,a,s,o,i)},kick:function(e,t,n,r,s){return this.modifyRole(e,t,"none",n,r,s)},voice:function(e,t,n,r,s){return this.modifyRole(e,t,"participant",n,r,s)},mute:function(e,t,n,r,s){return this.modifyRole(e,t,"visitor",n,r,s)},op:function(e,t,n,r,s){return this.modifyRole(e,t,"moderator",n,r,s)},deop:function(e,t,n,r,s){return this.modifyRole(e,t,"participant",n,r,s)},modifyAffiliation:function(t,n,r,s,o,i){var a;return a=e.$build("item",{jid:n,affiliation:r}),this._modifyPrivilege(t,a,s,o,i)},ban:function(e,t,n,r,s){return this.modifyAffiliation(e,t,"outcast",n,r,s)},member:function(e,t,n,r,s){return this.modifyAffiliation(e,t,"member",n,r,s)},revoke:function(e,t,n,r,s){return this.modifyAffiliation(e,t,"none",n,r,s)},owner:function(e,t,n,r,s){return this.modifyAffiliation(e,t,"owner",n,r,s)},admin:function(e,t,n,r,s){return this.modifyAffiliation(e,t,"admin",n,r,s)},changeNick:function(t,n){var r,s;return s=this.test_append_nick(t,n),r=e.$pres({from:this._connection.jid,to:s,id:this._connection.getUniqueId()}),this._connection.send(r.tree())},setStatus:function(t,n,r,s){var o,i;return i=this.test_append_nick(t,n),o=e.$pres({from:this._connection.jid,to:i}),null!=r&&o.c("show",r).up(),null!=s&&o.c("status",s),this._connection.send(o.tree())},registrationRequest:function(t,n,r){var s;return s=e.$iq({to:t,from:this._connection.jid,type:"get"}).c("query",{xmlns:e.Strophe.NS.MUC_REGISTER}),this._connection.sendIQ(s,(function(e){var t,r,s,o,i,a;for((r=e.getElementsByTagName("field")).length,o={required:[],optional:[]},i=0,a=r.length;i<a;i++)s={var:(t=r[i]).getAttribute("var"),label:t.getAttribute("label"),type:t.getAttribute("type")},t.getElementsByTagName("required").length>0?o.required.push(s):o.optional.push(s);return n(o)}),r)},submitRegistrationForm:function(t,n,r,s){var o,i,a;for(i in(o=e.$iq({to:t,type:"set"}).c("query",{xmlns:e.Strophe.NS.MUC_REGISTER})).c("x",{xmlns:"jabber:x:data",type:"submit"}),o.c("field",{var:"FORM_TYPE"}).c("value").t("http://jabber.org/protocol/muc#register").up().up(),n)a=n[i],o.c("field",{var:i}).c("value").t(a).up().up();return this._connection.sendIQ(o,r,s)},listRooms:function(t,n,r){var s;return s=e.$iq({to:t,from:this._connection.jid,type:"get"}).c("query",{xmlns:e.Strophe.NS.DISCO_ITEMS}),this._connection.sendIQ(s,n,r)},test_append_nick:function(t,n){return e.Strophe.escapeNode(e.Strophe.getNodeFromJid(t))+"@"+e.Strophe.getDomainFromJid(t)+(null!=n?"/"+n:"")}}),n=function(){function n(t,n,r,o){this.client=t,this.name=n,this.nick=r,this.password=o,this._roomRosterHandler=s(this._roomRosterHandler,this),this._addOccupant=s(this._addOccupant,this),this.roster={},this._message_handlers={},this._presence_handlers={},this._roster_handlers={},this._handler_ids=0,this.client.muc&&(this.client=this.client.muc),this.name=e.Strophe.getBareJidFromJid(this.name),this.addHandler("presence",this._roomRosterHandler)}return n.prototype.join=function(e,t,n){return this.client.join(this.name,this.nick,e,t,n,this.password)},n.prototype.leave=function(e,t){return this.client.leave(this.name,this.nick,e,t),delete this.client.rooms[this.name]},n.prototype.message=function(e,t,n,r){return this.client.message(this.name,e,t,n,r)},n.prototype.groupchat=function(e,t){return this.client.groupchat(this.name,e,t)},n.prototype.invite=function(e,t){return this.client.invite(this.name,e,t)},n.prototype.multipleInvites=function(e,t){return this.client.invite(this.name,e,t)},n.prototype.directInvite=function(e,t){return this.client.directInvite(this.name,e,t,this.password)},n.prototype.configure=function(e){return this.client.configure(this.name,e)},n.prototype.cancelConfigure=function(){return this.client.cancelConfigure(this.name)},n.prototype.saveConfiguration=function(e){return this.client.saveConfiguration(this.name,e)},n.prototype.queryOccupants=function(e,t){return this.client.queryOccupants(this.name,e,t)},n.prototype.setTopic=function(e){return this.client.setTopic(this.name,e)},n.prototype.modifyRole=function(e,t,n,r,s){return this.client.modifyRole(this.name,e,t,n,r,s)},n.prototype.kick=function(e,t,n,r){return this.client.kick(this.name,e,t,n,r)},n.prototype.voice=function(e,t,n,r){return this.client.voice(this.name,e,t,n,r)},n.prototype.mute=function(e,t,n,r){return this.client.mute(this.name,e,t,n,r)},n.prototype.op=function(e,t,n,r){return this.client.op(this.name,e,t,n,r)},n.prototype.deop=function(e,t,n,r){return this.client.deop(this.name,e,t,n,r)},n.prototype.modifyAffiliation=function(e,t,n,r,s){return this.client.modifyAffiliation(this.name,e,t,n,r,s)},n.prototype.ban=function(e,t,n,r){return this.client.ban(this.name,e,t,n,r)},n.prototype.member=function(e,t,n,r){return this.client.member(this.name,e,t,n,r)},n.prototype.revoke=function(e,t,n,r){return this.client.revoke(this.name,e,t,n,r)},n.prototype.owner=function(e,t,n,r){return this.client.owner(this.name,e,t,n,r)},n.prototype.admin=function(e,t,n,r){return this.client.admin(this.name,e,t,n,r)},n.prototype.changeNick=function(e){return this.nick=e,this.client.changeNick(this.name,nick)},n.prototype.setStatus=function(e,t){return this.client.setStatus(this.name,this.nick,e,t)},n.prototype.addHandler=function(e,t){var n;switch(n=this._handler_ids++,e){case"presence":this._presence_handlers[n]=t;break;case"message":this._message_handlers[n]=t;break;case"roster":this._roster_handlers[n]=t;break;default:return this._handler_ids--,null}return n},n.prototype.removeHandler=function(e){return delete this._presence_handlers[e],delete this._message_handlers[e],delete this._roster_handlers[e]},n.prototype._addOccupant=function(e){var n;return n=new t(e,this),this.roster[n.nick]=n,n},n.prototype._roomRosterHandler=function(e){var t,r,s,o,i;switch(o=(t=n._parsePresence(e)).nick,s=t.newnick||null,t.type){case"error":return!0;case"unavailable":s&&(t.nick=s,this.roster[o]&&this.roster[s]&&(this.roster[o].update(this.roster[s]),this.roster[s]=this.roster[o]),this.roster[o]&&!this.roster[s]&&(this.roster[s]=this.roster[o].update(t))),delete this.roster[o];break;default:this.roster[o]?this.roster[o].update(t):this._addOccupant(t)}for(r in i=this._roster_handlers)(0,i[r])(this.roster,this)||delete this._roster_handlers[r];return!0},n._parsePresence=function(t){var n,r,s,o,i,a,c,u,l,E;for((s={}).nick=e.Strophe.getResourceFromJid(t.getAttribute("from")),s.type=t.getAttribute("type"),s.states=[],o=0,a=(u=t.childNodes).length;o<a;o++)switch((n=u[o]).nodeName){case"error":s.errorcode=n.getAttribute("code"),s.error=null!=(l=n.childNodes[0])?l.nodeName:void 0;break;case"status":s.status=n.textContent||null;break;case"show":s.show=n.textContent||null;break;case"x":if(n.getAttribute("xmlns")===e.Strophe.NS.MUC_USER)for(i=0,c=(E=n.childNodes).length;i<c;i++)switch((r=E[i]).nodeName){case"item":s.affiliation=r.getAttribute("affiliation"),s.role=r.getAttribute("role"),s.jid=r.getAttribute("jid"),s.newnick=r.getAttribute("nick");break;case"status":r.getAttribute("code")&&s.states.push(r.getAttribute("code"))}}return s},n}(),function(){function e(e){this.parse=s(this.parse,this),null!=e&&this.parse(e)}e.prototype.parse=function(e){var t,n,r,s,o,i,a,c,u,l,E,d,h;for(d=e.getElementsByTagName("query")[0].childNodes,this.identities=[],this.features=[],this.x=[],o=0,u=d.length;o<u;o++)switch(n=(r=d[o]).attributes,r.nodeName){case"identity":for(i={},a=0,l=n.length;a<l;a++)i[(t=n[a]).name]=t.textContent;this.identities.push(i);break;case"feature":this.features.push(r.getAttribute("var"));break;case"x":if("FORM_TYPE"===!r.childNodes[0].getAttribute("var")||"hidden"===!r.childNodes[0].getAttribute("type"))break;for(c=0,E=(h=r.childNodes).length;c<E;c++)(s=h[c]).attributes.type||this.x.push({var:s.getAttribute("var"),label:s.getAttribute("label")||"",value:s.firstChild.textContent||""})}return{identities:this.identities,features:this.features,x:this.x}}}(),t=function(){function e(e,t){this.room=t,this.update=s(this.update,this),this.admin=s(this.admin,this),this.owner=s(this.owner,this),this.revoke=s(this.revoke,this),this.member=s(this.member,this),this.ban=s(this.ban,this),this.modifyAffiliation=s(this.modifyAffiliation,this),this.deop=s(this.deop,this),this.op=s(this.op,this),this.mute=s(this.mute,this),this.voice=s(this.voice,this),this.kick=s(this.kick,this),this.modifyRole=s(this.modifyRole,this),this.update(e)}return e.prototype.modifyRole=function(e,t,n,r){return this.room.modifyRole(this.nick,e,t,n,r)},e.prototype.kick=function(e,t,n){return this.room.kick(this.nick,e,t,n)},e.prototype.voice=function(e,t,n){return this.room.voice(this.nick,e,t,n)},e.prototype.mute=function(e,t,n){return this.room.mute(this.nick,e,t,n)},e.prototype.op=function(e,t,n){return this.room.op(this.nick,e,t,n)},e.prototype.deop=function(e,t,n){return this.room.deop(this.nick,e,t,n)},e.prototype.modifyAffiliation=function(e,t,n,r){return this.room.modifyAffiliation(this.jid,e,t,n,r)},e.prototype.ban=function(e,t,n){return this.room.ban(this.jid,e,t,n)},e.prototype.member=function(e,t,n){return this.room.member(this.jid,e,t,n)},e.prototype.revoke=function(e,t,n){return this.room.revoke(this.jid,e,t,n)},e.prototype.owner=function(e,t,n){return this.room.owner(this.jid,e,t,n)},e.prototype.admin=function(e,t,n){return this.room.admin(this.jid,e,t,n)},e.prototype.update=function(e){return this.nick=e.nick||null,this.affiliation=e.affiliation||null,this.role=e.role||null,this.jid=e.jid||null,this.status=e.status||null,this.show=e.show||null,this},e}()}(n(15))},function(e,t,n){var r,s;r=[n(15)],void 0===(s=function(e){return function(e,t,n,r,s){var o=function(t,r,s){var o=n(r?{type:t,to:r}:{type:t});return o.c("vCard",{xmlns:e.NS.VCARD}),s&&o.cnode(s),o};e.addConnectionPlugin("vcard",{_connection:null,init:function(t){return this._connection=t,e.addNamespace("VCARD","vcard-temp")},get:function(e,t,n){var r=o("get",t);return this._connection.sendIQ(r,e,n)},set:function(e,t,n,r){var s=o("set",n,t);return this._connection.sendIQ(s,e,r)}})}(e.Strophe,e.$build,e.$iq,e.$msg,e.$pres),e}.apply(t,r))||(e.exports=s)},function(e,t,n){var r,s;r=[n(15)],void 0===(s=function(e){return function(e,t,n,r,s){e.addConnectionPlugin("ping",{_c:null,init:function(t){this._c=t,e.addNamespace("PING","urn:xmpp:ping")},ping:function(t,r,s,o){var i=this._c.getUniqueId("ping"),a=n({type:"get",to:t,id:i}).c("ping",{xmlns:e.NS.PING});this._c.sendIQ(a,r,s,o)},pong:function(e){var t=e.getAttribute("from"),r=e.getAttribute("id"),s=n({type:"result",to:t,id:r});this._c.sendIQ(s)},addPingHandler:function(t){return this._c.addHandler(t,e.NS.PING,"iq","get")}})}(e.Strophe,e.$build,e.$iq,e.$msg,e.$pres),e}.apply(t,r))||(e.exports=s)},function(e,t,n){"use strict";t.__esModule=!0;var r=n(4),s=n(0),o=n(11),i=function(){function e(){}return e.transformVCard=function(e){var t={};return t[s.UserConstants.NAME]=o.parseHTML(e.getElementsByTagName(s.UserConstants.NAME)[0]),t[s.UserConstants.UID]=o.parseHTML(e.getElementsByTagName(s.UserConstants.UID)[0]),t[s.UserConstants.AVATAR]=o.parseHTML(e.getElementsByTagName(s.UserConstants.AVATAR)[0]),t[s.UserConstants.LINK]=o.parseHTML(e.getElementsByTagName(s.UserConstants.LINK)[0]),t[s.UserConstants.STATUS]=o.parseHTML(e.getElementsByTagName(s.UserConstants.STATUS)[0]),t[s.UserConstants.LAST_ACTIVE_AT]=o.parseHTML(e.getElementsByTagName(s.UserConstants.LAST_ACTIVE_AT)[0]),t[s.UserConstants.ROLE]=o.parseHTML(e.getElementsByTagName(s.UserConstants.ROLE)[0]),t[s.UserConstants.USER_NAME]=o.parseHTML(e.getElementsByTagName(s.UserConstants.USER_NAME)[0]),new r.User(t)},e}();t.VCardController=i},function(e,t,n){"use strict";t.__esModule=!0;var r=n(3),s=n(1),o=n(0),i=n(12),a=n(2),c=function(){function e(e){this.store=o.constants.DEFAULT_STORE,s.isFalsy(e)||(this.store=e),this.keyStore=i.createInstance({name:s.format(o.LOCAL_STORE.STORE_STRING,r.CometChat.getAppId(),o.LOCAL_STORE.KEYS_STORE)}),this.keyStore.setDriver([i.LOCALSTORAGE,i.INDEXEDDB,i.WEBSQL])}return e.getInstance=function(){return null==e.KeyStore&&(e.KeyStore=new e),e.KeyStore},e.prototype.set=function(e,t){return this.keyStore.setItem(e,t)},e.prototype.remove=function(e){this.keyStore.removeItem(e)},e.prototype.get=function(e){var t=this;return new Promise((function(n,r){try{t.keyStore.getItem(e).then((function(e){try{n(JSON.parse(e))}catch(t){n(e)}}),(function(e){r(e)}))}catch(e){r(new a.CometChatException(e))}}))},e.prototype.clearStore=function(){return this.keyStore.clear()},e}();t.KeyStore=c},function(e,t,n){"use strict";t.__esModule=!0;var r=n(5),s=n(1),o=n(2),i=n(16),a=n(0),c=function(){function e(e){this.cursor=-1,this.total=-1,this.next_page=1,this.last_page=-1,this.current_page=1,this.total_pages=-1,this.hasJoined=0,this.withTags=!1,this.pagination={total:0,count:0,per_page:0,current_page:0,total_pages:0,links:[]},s.isFalsy(e)||(s.isFalsy(e.limit)||(this.limit=e.limit),s.isFalsy(e.searchKeyword)||(this.searchKeyword=e.searchKeyword),s.isFalsy(e.hasJoined)||(this.hasJoined=1),s.isFalsy(e.tags)||(this.tags=e.tags),s.isFalsy(e.showTags)||(this.withTags=e.showTags))}return e.prototype.validateGroupBuilder=function(){if(void 0===this.limit)return new o.CometChatException(JSON.parse(s.format(JSON.stringify(a.GENERAL_ERROR.METHOD_COMPULSORY),"SET_LIMIT","SET_LIMIT","Set Limit")));if(isNaN(this.limit))return new o.CometChatException(JSON.parse(s.format(JSON.stringify(a.GENERAL_ERROR.PARAMETER_MUST_BE_A_NUMBER),"SET_LIMIT","SET_LIMIT","setLimit()")));if(this.limit>a.DEFAULT_VALUES.GROUPS_MAX_LIMIT)return new o.CometChatException(JSON.parse(s.format(JSON.stringify(a.GENERAL_ERROR.LIMIT_EXCEEDED),"SET_LIMIT","SET_LIMIT",a.DEFAULT_VALUES.GROUPS_MAX_LIMIT)));if(this.limit<a.DEFAULT_VALUES.ZERO)return new o.CometChatException(JSON.parse(s.format(JSON.stringify(a.GENERAL_ERROR.PARAMETER_MUST_BE_A_POSITIVE_NUMBER),"SET_LIMIT","SET_LIMIT","setLimit()")));if(void 0!==this.searchKeyword){if(typeof this.searchKeyword!==a.COMMON_UTILITY_CONSTANTS.TYPE_CONSTANTS.STRING)return new o.CometChatException(JSON.parse(s.format(JSON.stringify(a.GENERAL_ERROR.PARAMETER_MUST_BE_A_STRING),"SET_SEARCH_KEYWORD","SET_SEARCH_KEYWORD","setSearchKeyword()")));if(s.isFalsy(this.searchKeyword.trim()))return new o.CometChatException(JSON.parse(s.format(JSON.stringify(a.GENERAL_ERROR.INVALID),"SET_SEARCH_KEYWORD","SET_SEARCH_KEYWORD","search keyword","search keyword")));this.searchKeyword=this.searchKeyword.trim()}if(void 0!==this.withTags){if(typeof this.withTags!==a.COMMON_UTILITY_CONSTANTS.TYPE_CONSTANTS.BOOLEAN)return new o.CometChatException(JSON.parse(s.format(JSON.stringify(a.GENERAL_ERROR.PARAMETER_MUST_BE_A_BOOLEAN),"WITH_TAGS","WITH_TAGS","withTags()")));1==this.withTags?this.withTags=!0:this.withTags=!1}return void 0===this.tags||Array.isArray(this.tags)?void 0:new o.CometChatException(JSON.parse(s.format(JSON.stringify(a.GENERAL_ERROR.PARAMETER_MUST_BE_AN_ARRAY),"TAGS","TAGS","setTags()")))},e.prototype.fetchPrevious=function(){var e=this;return new Promise((function(t,n){try{0==e.next_page&&t([]);var s=e.validateGroupBuilder();return s instanceof o.CometChatException?void n(s):r.makeApiCall("groups",{},e.getPreData()).then((function(n){if(n.meta&&(e.total_pages=n.meta.pagination.total_pages),n.data.length>0){e.pagination=n.meta.pagination;var r=[];n.data.map((function(e,t){r.push(i.GroupsController.trasformJSONGroup(e))})),t(r)}t([])}),(function(e){n(new o.CometChatException(e.error))}))}catch(e){n(new o.CometChatException(e))}}))},e.prototype.fetchNext=function(){var e=this;return new Promise((function(t,n){try{var s=e.validateGroupBuilder();if(s instanceof o.CometChatException)return void n(s);r.makeApiCall("getGroups",{},e.getNextData()).then((function(n){if(n.meta&&(e.total_pages=n.meta.pagination.total_pages),n.data.length>0){e.pagination=n.meta.pagination;var r=[];n.data.map((function(e,t){r.push(i.GroupsController.trasformJSONGroup(e))})),t(r)}t([])}),(function(e){n(new o.CometChatException(e.error))}))}catch(e){n(new o.CometChatException(e))}}))},e.prototype.getNextData=function(){var e={};if(e.per_page=this.limit,s.isFalsy(this.searchKeyword)||(e.searchKey=this.searchKeyword),s.isFalsy(this.hasJoined)||(e.hasJoined=1),s.isFalsy(this.tags)||(e.tags=this.tags),s.isFalsy(this.withTags)||(e.withTags=1),1==this.current_page)e.page=this.next_page,this.next_page++,this.current_page++;else{if(this.next_page>this.total_pages)return e.page=this.next_page,e;e.page=this.next_page++}return e},e.prototype.getPreData=function(){var e={};return e.per_page=this.limit,this.next_page>=0?(this.next_page>0&&(e.page=--this.next_page),e):e},e.MAX_LIMIT=100,e.DEFAULT_LIMIT=30,e}();t.GroupsRequest=c;var u=function(){function e(){}return e.prototype.setLimit=function(e){return this.limit=e,this},e.prototype.setSearchKeyword=function(e){return this.searchKeyword=e,this},e.prototype.joinedOnly=function(e){return this.hasJoined=e,this},e.prototype.setTags=function(e){return this.tags=e,this},e.prototype.withTags=function(e){return this.showTags=e,this},e.prototype.build=function(){return new c(this)},e}();t.GroupsRequestBuilder=u},function(e,t,n){"use strict";var r,s=this&&this.__extends||(r=function(e,t){return r=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)t.hasOwnProperty(n)&&(e[n]=t[n])},r(e,t)},function(e,t){function n(){this.constructor=e}r(e,t),e.prototype=null===t?Object.create(t):(n.prototype=t.prototype,new n)});t.__esModule=!0;var o=n(5),i=n(1),a=n(9),c=n(2),u=n(54),l=n(0),E=function(){function e(e){this.cursor=-1,this.total=-1,this.next_page=1,this.last_page=-1,this.current_page=1,this.total_pages=-1,this.isOutCastReq=!1,this.pagination={total:0,count:0,per_page:0,current_page:0,total_pages:0,links:[]},this.store=a.LocalStorage.getInstance(),i.isFalsy(e)||(this.limit=e.limit,this.guid=e.guid,i.isFalsy(e.searchKeyword)||(this.searchKeyword=e.searchKeyword),i.isFalsy(e.scopes)||(this.scopes=e.scopes),e instanceof h&&(this.isOutCastReq=e.isOutCastReq))}return e.prototype.validateGroupMembersBuilder=function(){if(void 0===this.limit)return new c.CometChatException(JSON.parse(i.format(JSON.stringify(l.GENERAL_ERROR.METHOD_COMPULSORY),"SET_LIMIT","SET_LIMIT","Set Limit")));if(isNaN(this.limit))return new c.CometChatException(JSON.parse(i.format(JSON.stringify(l.GENERAL_ERROR.PARAMETER_MUST_BE_A_NUMBER),"SET_LIMIT","SET_LIMIT","setLimit()")));if(this.limit>l.DEFAULT_VALUES.USERS_MAX_LIMIT)return new c.CometChatException(JSON.parse(i.format(JSON.stringify(l.GENERAL_ERROR.LIMIT_EXCEEDED),"SET_LIMIT","SET_LIMIT",l.DEFAULT_VALUES.USERS_MAX_LIMIT)));if(this.limit<l.DEFAULT_VALUES.ZERO)return new c.CometChatException(JSON.parse(i.format(JSON.stringify(l.GENERAL_ERROR.PARAMETER_MUST_BE_A_POSITIVE_NUMBER),"SET_LIMIT","SET_LIMIT","setLimit()")));if(void 0!==this.searchKeyword){if(typeof this.searchKeyword!==l.COMMON_UTILITY_CONSTANTS.TYPE_CONSTANTS.STRING)return new c.CometChatException(JSON.parse(i.format(JSON.stringify(l.GENERAL_ERROR.PARAMETER_MUST_BE_A_STRING),"SET_SEARCH_KEYWORD","SET_SEARCH_KEYWORD","setSearchKeyword()")));if(i.isFalsy(this.searchKeyword.trim()))return new c.CometChatException(JSON.parse(i.format(JSON.stringify(l.GENERAL_ERROR.INVALID),"SET_SEARCH_KEYWORD","SET_SEARCH_KEYWORD","search keyword","search keyword")));this.searchKeyword=this.searchKeyword.trim()}if(void 0!==this.guid){if(typeof this.guid!==l.COMMON_UTILITY_CONSTANTS.TYPE_CONSTANTS.STRING)return new c.CometChatException(JSON.parse(i.format(JSON.stringify(l.GENERAL_ERROR.PARAMETER_MUST_BE_A_STRING),"GUID","GUID","GroupMembersRequestBuilder()")));if(i.isFalsy(this.guid))return new c.CometChatException(JSON.parse(i.format(JSON.stringify(l.GENERAL_ERROR.INVALID),"GUID","GUID","GUID","GUID")))}return void 0===this.scopes||Array.isArray(this.scopes)?void 0:new c.CometChatException(JSON.parse(i.format(JSON.stringify(l.GENERAL_ERROR.PARAMETER_MUST_BE_AN_ARRAY),"SET_SCOPES","SET_SCOPES","setScopes()")))},e.prototype.fetchPrevious=function(){var e=this;return new Promise((function(t,n){try{0==e.next_page&&t([]);var r=e.validateGroupMembersBuilder();return r instanceof c.CometChatException?void n(r):o.makeApiCall(e.isOutCastReq?"getBannedGroupMembers":"getGroupMembers",{guid:e.guid},e.getPreData()).then((function(n){if(n.meta&&(e.total_pages=n.meta.pagination.total_pages),n.data.length>0){e.pagination=n.meta.pagination;var r=[];n.data.map((function(t){t.guid=e.guid,r.push(u.GroupMembersController.trasformJSONGroupMember(t))})),t(r)}t([])}),(function(e){n(new c.CometChatException(e.error))}))}catch(e){n(new c.CometChatException(e))}}))},e.prototype.fetchNext=function(){var e=this;return new Promise((function(t,n){try{var r=e.validateGroupMembersBuilder();if(r instanceof c.CometChatException)return void n(r);o.makeApiCall(e.isOutCastReq?"getBannedGroupMembers":"getGroupMembers",{guid:e.guid},e.getNextData()).then((function(n){if(n.meta&&(e.total_pages=n.meta.pagination.total_pages),n.data.length>0){e.pagination=n.meta.pagination;var r=[];n.data.map((function(t){t.guid=e.guid,r.push(u.GroupMembersController.trasformJSONGroupMember(t))})),t(r)}else t([])}),(function(e){n(new c.CometChatException(e.error))}))}catch(e){n(new c.CometChatException(e))}}))},e.prototype.getNextData=function(){var e={};if(e.per_page=this.limit,i.isFalsy(this.searchKeyword)||(e.searchKey=this.searchKeyword),i.isFalsy(this.scopes)||(e.scopes=this.scopes),1==this.current_page)e.page=this.next_page,this.next_page++,this.current_page++;else{if(this.next_page>this.total_pages)return e.page=this.next_page,e;e.page=this.next_page++}return e},e.prototype.getPreData=function(){var e={};return e.per_page=this.limit,this.next_page>=0?(this.next_page>0&&(e.page=--this.next_page),e):e},e.MAX_LIMIT=2,e.DEFAULT_LIMIT=1,e}();t.GroupMembersRequest=E;var d=function(){function e(e){this.guid=e}return e.prototype.setLimit=function(e){return this.limit=e,this},e.prototype.setSearchKeyword=function(e){return this.searchKeyword=e,this},e.prototype.setScopes=function(e){return this.scopes=e,this},e.prototype.build=function(){return new E(this)},e}();t.GroupMembersRequestBuilder=d;var h=function(e){function t(t){var n=e.call(this,t)||this;return n.isOutCastReq=!0,n}return s(t,e),t.prototype.build=function(){return new E(this)},t}(d);t.GroupOutCastMembersRequestBuilder=h},function(e,t,n){"use strict";t.__esModule=!0;var r=n(41),s=n(0),o=n(1),i=function(){function e(){}return e.trasformJSONGroupMember=function(e){var t;try{return e.status&&"offline"!==e.status?e.status="online":e.status="offline",t=new r.GroupMember(e[s.GroupMemersConstans.KEYS.UID]),Object.assign(t,e),t}catch(t){return o.Logger.error("GroupMembersController:trasformJSONGroupMember",{e:t,groupMember:e}),e}},e}();t.GroupMembersController=i},function(e,t,n){"use strict";t.__esModule=!0;var r=n(5),s=n(1),o=n(8),i=n(2),a=n(40),c=n(0),u=n(3),l=function(){function e(t){this.next_page=1,this.current_page=1,this.total_pages=-1,this.hideBlockedUsers=!1,this.friendsOnly=!1,this.fetchingInProgress=!1,this.withTags=!1,this.pagination={total:0,count:0,per_page:0,current_page:0,total_pages:0,links:[]},e.userStore=a.UserStore.getInstance(),s.isFalsy(t)||(this.limit=t.limit,s.isFalsy(t.searchKeyword)||(this.searchKeyword=t.searchKeyword),s.isFalsy(t.status)||(t.status==e.USER_STATUS.ONLINE?this.status=c.PresenceConstatnts.STATUS.AVAILABLE:this.status=t.status),s.isFalsy(t.shouldHideBlockedUsers)||(this.hideBlockedUsers=t.shouldHideBlockedUsers),s.isFalsy(t.showFriendsOnly)||(this.friendsOnly=t.showFriendsOnly),s.isFalsy(t.showTags)||(this.withTags=t.showTags),s.isFalsy(t.role)||(this.role=t.role),s.isFalsy(t.roles)||(this.roles=t.roles),s.isFalsy(t.tags)||(this.tags=t.tags),s.isFalsy(t.UIDs)||(this.UIDs=t.UIDs))}return e.prototype.validateUserBuilder=function(){if(void 0===this.limit)return new i.CometChatException(JSON.parse(s.format(JSON.stringify(c.GENERAL_ERROR.METHOD_COMPULSORY),"SET_LIMIT","SET_LIMIT","Set Limit")));if(isNaN(this.limit))return new i.CometChatException(JSON.parse(s.format(JSON.stringify(c.GENERAL_ERROR.PARAMETER_MUST_BE_A_NUMBER),"SET_LIMIT","SET_LIMIT","setLimit()")));if(this.limit>c.DEFAULT_VALUES.USERS_MAX_LIMIT)return new i.CometChatException(JSON.parse(s.format(JSON.stringify(c.GENERAL_ERROR.LIMIT_EXCEEDED),"SET_LIMIT","SET_LIMIT",c.DEFAULT_VALUES.USERS_MAX_LIMIT)));if(this.limit<c.DEFAULT_VALUES.ZERO)return new i.CometChatException(JSON.parse(s.format(JSON.stringify(c.GENERAL_ERROR.PARAMETER_MUST_BE_A_POSITIVE_NUMBER),"SET_LIMIT","SET_LIMIT","setLimit()")));if(void 0!==this.searchKeyword){if(typeof this.searchKeyword!==c.COMMON_UTILITY_CONSTANTS.TYPE_CONSTANTS.STRING)return new i.CometChatException(JSON.parse(s.format(JSON.stringify(c.GENERAL_ERROR.PARAMETER_MUST_BE_A_STRING),"SET_SEARCH_KEYWORD","SET_SEARCH_KEYWORD","setSearchKeyword()")));if(s.isFalsy(this.searchKeyword.trim()))return new i.CometChatException(JSON.parse(s.format(JSON.stringify(c.GENERAL_ERROR.INVALID),"SET_SEARCH_KEYWORD","SET_SEARCH_KEYWORD","search keyword","search keyword")));this.searchKeyword=this.searchKeyword.trim()}if(this.status){if(typeof this.status!==c.COMMON_UTILITY_CONSTANTS.TYPE_CONSTANTS.STRING)return new i.CometChatException(JSON.parse(s.format(JSON.stringify(c.GENERAL_ERROR.PARAMETER_MUST_BE_A_STRING),"SET_STATUS","SET_STATUS","setStatus()")));if("available"!=this.status.toLowerCase()&&"offline"!=this.status.toLowerCase())return new i.CometChatException(c.UserErrors.INVALID_STATUS)}if(void 0!==this.hideBlockedUsers){if(typeof this.hideBlockedUsers!==c.COMMON_UTILITY_CONSTANTS.TYPE_CONSTANTS.BOOLEAN)return new i.CometChatException(JSON.parse(s.format(JSON.stringify(c.GENERAL_ERROR.PARAMETER_MUST_BE_A_BOOLEAN),"HIDE_BLOCKED_USERS","HIDE_BLOCKED_USERS","hideBlockedUsers()")));1==this.hideBlockedUsers?this.hideBlockedUsers=!0:this.hideBlockedUsers=!1}if(void 0!==this.friendsOnly){if(typeof this.friendsOnly!==c.COMMON_UTILITY_CONSTANTS.TYPE_CONSTANTS.BOOLEAN)return new i.CometChatException(JSON.parse(s.format(JSON.stringify(c.GENERAL_ERROR.PARAMETER_MUST_BE_A_BOOLEAN),"FRIENDS_ONLY","FRIENDS_ONLY","friendsOnly()")));1==this.friendsOnly?this.friendsOnly=!0:this.friendsOnly=!1}if(void 0!==this.withTags){if(typeof this.withTags!==c.COMMON_UTILITY_CONSTANTS.TYPE_CONSTANTS.BOOLEAN)return new i.CometChatException(JSON.parse(s.format(JSON.stringify(c.GENERAL_ERROR.MUST_BE_A_BOOLEAN),"WITH_TAGS","WITH_TAGS","withTags()")));1==this.withTags?this.withTags=!0:this.withTags=!1}return void 0===this.roles||Array.isArray(this.roles)?void 0===this.tags||Array.isArray(this.tags)?void 0===this.UIDs||Array.isArray(this.UIDs)?void 0:new i.CometChatException(JSON.parse(s.format(JSON.stringify(c.GENERAL_ERROR.PARAMETER_MUST_BE_AN_ARRAY),"UIDs","UIDs","setUIDs()"))):new i.CometChatException(JSON.parse(s.format(JSON.stringify(c.GENERAL_ERROR.PARAMETER_MUST_BE_AN_ARRAY),"TAGS","TAGS","setTags()"))):new i.CometChatException(JSON.parse(s.format(JSON.stringify(c.GENERAL_ERROR.PARAMETER_MUST_BE_AN_ARRAY),"ROLES","ROLES","setRoles()")))},e.prototype.fetchPrevious=function(){var t=this;return this.fetchingInProgress=!0,new Promise((function(n,s){try{0==t.next_page&&(n([]),t.fetchingInProgress=!1);var a=t.validateUserBuilder();if(a instanceof i.CometChatException)return void s(a);if(!t.fetchingInProgress)return r.makeApiCall("users",{},t.getPreData()).then((function(r){if(r.meta&&(t.total_pages=r.meta.pagination.total_pages),r.data.length>0){t.pagination=r.meta.pagination;var s=[];r.data.map((function(e,t){s.push(o.UsersController.trasformJSONUser(e))})),e.userStore.storeUsers(s),n(s),t.fetchingInProgress=!1}n([]),t.fetchingInProgress=!1}),(function(e){s(new i.CometChatException(e.error)),t.fetchingInProgress=!1}));n([])}catch(e){t.fetchingInProgress=!1,s(new i.CometChatException(e))}}))},e.prototype.fetchNext=function(){var e=this;return new Promise((function(t,n){try{if(e.fetchingInProgress)e.fetchingInProgress=!1,t([]);else{e.fetchingInProgress=!0;var a=e.validateUserBuilder();if(a instanceof i.CometChatException)return void n(a);r.makeApiCall("users",{},e.getNextData()).then((function(n){if(n.meta&&(e.total_pages=n.meta.pagination.total_pages),n.data.length>0){e.pagination=n.meta.pagination;var r=[],i=[];n.data.map((function(e){r.push(o.UsersController.trasformJSONUser(e)),i.push(s.format(c.XMPP.username_string,u.CometChat.getAppId(),e[c.UserConstants.UID]))})),t(r)}else t([]);e.fetchingInProgress=!1}),(function(t){e.fetchingInProgress=!1,n(new i.CometChatException(t.error))}))}}catch(t){e.fetchingInProgress=!1,n(new i.CometChatException(t))}}))},e.prototype.getNextData=function(){var e={};if(e.per_page=this.limit,s.isFalsy(this.searchKeyword)||(e.searchKey=this.searchKeyword),s.isFalsy(this.status)||(e.status=this.status),s.isFalsy(this.hideBlockedUsers)||(e.hideBlockedUsers=1),s.isFalsy(this.role)||(e.roles=this.role),s.isFalsy(this.roles)||(e.roles=this.roles),s.isFalsy(this.tags)||(e.tags=this.tags),s.isFalsy(this.friendsOnly)||(e.friendsOnly=1),s.isFalsy(this.withTags)||(e.withTags=1),s.isFalsy(this.UIDs)||(e.uids=this.UIDs),1==this.current_page)e.page=this.next_page,this.next_page++,this.current_page++;else{if(this.next_page>this.total_pages)return e.page=this.next_page,e;e.page=this.next_page++}return e},e.prototype.getPreData=function(){var e={};return e.per_page=this.limit,this.next_page>=0?(this.next_page>0&&(e.page=--this.next_page),e):e},e.USER_STATUS={ONLINE:c.PresenceConstatnts.STATUS.ONLINE,OFFLINE:c.PresenceConstatnts.STATUS.OFFLINE},e}();t.UsersRequest=l;var E=function(){function e(){this.shouldHideBlockedUsers=!1}return e.prototype.setLimit=function(e){return this.limit=e,this},e.prototype.setStatus=function(e){return this.status=e,this},e.prototype.setSearchKeyword=function(e){return this.searchKeyword=e,this},e.prototype.hideBlockedUsers=function(e){return this.shouldHideBlockedUsers=e,this},e.prototype.setRole=function(e){return this.role=e,this},e.prototype.setRoles=function(e){return this.roles=e,this},e.prototype.friendsOnly=function(e){return this.showFriendsOnly=e,this},e.prototype.setTags=function(e){return this.tags=e,this},e.prototype.withTags=function(e){return this.showTags=e,this},e.prototype.setUIDs=function(e){return this.UIDs=e,this},e.prototype.build=function(){return this.role&&this.roles&&this.roles.push(this.role),new l(this)},e}();t.UsersRequestBuilder=E},function(e,t,n){"use strict";t.__esModule=!0;var r=n(5),s=n(1),o=n(2),i=n(28),a=n(0),c=function(){function e(e){this.limit=100,this.next_page=1,this.current_page=1,this.total_pages=-1,this.fetchingInProgress=!1,this.pagination={total:0,count:0,per_page:0,current_page:0,total_pages:0,links:[]},s.isFalsy(e)||(this.limit=e.limit,s.isFalsy(e.conversationType)||(this.conversationType=e.conversationType))}return e.prototype.validateConversationBuilder=function(){return void 0===this.limit?new o.CometChatException(JSON.parse(s.format(JSON.stringify(a.GENERAL_ERROR.METHOD_COMPULSORY),"SET_LIMIT","SET_LIMIT","Set Limit"))):isNaN(this.limit)?new o.CometChatException(JSON.parse(s.format(JSON.stringify(a.GENERAL_ERROR.PARAMETER_MUST_BE_A_NUMBER),"SET_LIMIT","SET_LIMIT","setLimit()"))):this.limit>a.DEFAULT_VALUES.CONVERSATION_MAX_LIMIT?new o.CometChatException(JSON.parse(s.format(JSON.stringify(a.GENERAL_ERROR.LIMIT_EXCEEDED),"SET_LIMIT","SET_LIMIT",a.DEFAULT_VALUES.CONVERSATION_MAX_LIMIT))):this.limit<a.DEFAULT_VALUES.ZERO?new o.CometChatException(JSON.parse(s.format(JSON.stringify(a.GENERAL_ERROR.PARAMETER_MUST_BE_A_POSITIVE_NUMBER),"SET_LIMIT","SET_LIMIT","setLimit()"))):void 0},e.prototype.fetchNext=function(){var e=this;return new Promise((function(t,n){try{if(e.fetchingInProgress)e.fetchingInProgress=!1,t([]);else{e.fetchingInProgress=!0;var s=e.validateConversationBuilder();if(s instanceof o.CometChatException)return void n(s);r.makeApiCall("getConversations",{},e.getNextData()).then((function(n){if(n.meta&&(e.total_pages=n.meta.pagination.total_pages),n.data.length>0){e.pagination=n.meta.pagination;var r=[];n.data.map((function(e){r.push(i.ConversationController.trasformJSONConversation(e.conversationId,e.conversationType,e.lastMessage,e.conversationWith,e.unreadMessageCount))})),t(r)}else t([]);e.fetchingInProgress=!1}),(function(t){e.fetchingInProgress=!1,n(new o.CometChatException(t.error))}))}}catch(t){e.fetchingInProgress=!1,n(new o.CometChatException(t))}}))},e.prototype.getNextData=function(){var e={};if(e.per_page=this.limit,s.isFalsy(this.conversationType)||(e.conversationType=this.conversationType),1==this.current_page)e.page=this.next_page,this.next_page++,this.current_page++;else{if(this.next_page>this.total_pages)return e.page=this.next_page,e;e.page=this.next_page++}return e},e}();t.ConversationsRequest=c;var u=function(){function e(){}return e.prototype.setLimit=function(e){return this.limit=e,this},e.prototype.setConversationType=function(e){return this.conversationType=e,this},e.prototype.build=function(){return new c(this)},e}();t.ConversationsRequestBuilder=u},function(e,t,n){"use strict";var r=this&&this.__awaiter||function(e,t,n,r){return new(n||(n=Promise))((function(s,o){function i(e){try{c(r.next(e))}catch(e){o(e)}}function a(e){try{c(r.throw(e))}catch(e){o(e)}}function c(e){e.done?s(e.value):new n((function(t){t(e.value)})).then(i,a)}c((r=r.apply(e,t||[])).next())}))},s=this&&this.__generator||function(e,t){var n,r,s,o,i={label:0,sent:function(){if(1&s[0])throw s[1];return s[1]},trys:[],ops:[]};return o={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(o[Symbol.iterator]=function(){return this}),o;function a(o){return function(a){return function(o){if(n)throw new TypeError("Generator is already executing.");for(;i;)try{if(n=1,r&&(s=2&o[0]?r.return:o[0]?r.throw||((s=r.return)&&s.call(r),0):r.next)&&!(s=s.call(r,o[1])).done)return s;switch(r=0,s&&(o=[2&o[0],s.value]),o[0]){case 0:case 1:s=o;break;case 4:return i.label++,{value:o[1],done:!1};case 5:i.label++,r=o[1],o=[0];continue;case 7:o=i.ops.pop(),i.trys.pop();continue;default:if(!(s=i.trys,(s=s.length>0&&s[s.length-1])||6!==o[0]&&2!==o[0])){i=0;continue}if(3===o[0]&&(!s||o[1]>s[0]&&o[1]<s[3])){i.label=o[1];break}if(6===o[0]&&i.label<s[1]){i.label=s[1],s=o;break}if(s&&i.label<s[2]){i.label=s[2],i.ops.push(o);break}s[2]&&i.ops.pop(),i.trys.pop();continue}o=t.call(e,i)}catch(e){o=[6,e],r=0}finally{n=s=0}if(5&o[0])throw o[1];return{value:o[0]?o[1]:void 0,done:!0}}([o,a])}}};t.__esModule=!0;var o=n(2),i=n(5),a=n(7),c=n(1),u=n(23),l=n(0),E=n(13),d=n(3),h=n(14),p=n(11),S=n(26),g=n(27),C=n(4),_=n(32),f=function(){function e(e){this.limit=l.DEFAULT_VALUES.MSGS_LIMIT,this.timestamp=0,this.id=l.DEFAULT_VALUES.DEFAULT_MSG_ID,this.messageStore=u.MessagesStore.getInstance(),this.endpointName="getUserMessages",this.listId="",this.totalPages=0,this.unread=!1,this.inProgress=!1,this.hideMessagesFromBlockedUsers=!1,this.updatedAt=0,this.onlyUpdates=0,this.paginationMeta={},this.hideDeletedMessages=!1,this.limit=e.limit,this.paginationMeta[l.MessageConstatnts.PAGINATION.KEYS.PER_PAGE]=this.limit,this.uid=e.uid,this.guid=e.guid,this.parentMessageId=e.parentMessageId,this.timestamp=e.timestamp,this.timestamp&&(this.paginationMeta[l.MessageConstatnts.PAGINATION.KEYS.SENT_AT]=this.timestamp),this.id=e.id,this.id!=l.DEFAULT_VALUES.DEFAULT_MSG_ID&&(this.paginationMeta[l.MessageConstatnts.PAGINATION.KEYS.ID]=this.id),this.hideMessagesFromBlockedUsers=e.HideMessagesFromBlockedUsers,this.hideMessagesFromBlockedUsers&&(this.paginationMeta[l.MessageConstatnts.PAGINATION.KEYS.HIDE_MESSAGES_FROM_BLOCKED_USER]=this.hideMessagesFromBlockedUsers),this.unread=e.unread,this.unread&&(this.paginationMeta[l.MessageConstatnts.PAGINATION.KEYS.UNREAD]=this.unread),e.searchKey&&(this.searchKey=e.searchKey,this.paginationMeta[l.MessageConstatnts.PAGINATION.KEYS.SEARCH_KEY]=this.searchKey),e.onlyUpdate&&(this.onlyUpdates=e.onlyUpdate,this.paginationMeta[l.MessageConstatnts.PAGINATION.KEYS.ONLY_UPDATES]=this.onlyUpdates),e.updatedAt&&(this.updatedAt=e.updatedAt,this.paginationMeta[l.MessageConstatnts.PAGINATION.KEYS.UPDATED_AT]=this.updatedAt),e.category&&(this.category=e.category),e.categories&&(this.categories=e.categories),e.type&&(this.type=e.type),e.types&&(this.types=e.types),e.HideReplies&&(this.hideReplies=e.HideReplies,this.paginationMeta[l.MessageConstatnts.PAGINATION.KEYS.HIDE_REPLIES]=this.hideReplies),this.hideDeletedMessages=e.HideDeletedMessages,this.hideDeletedMessages&&(this.paginationMeta[l.MessageConstatnts.PAGINATION.KEYS.HIDE_DELETED_MESSAGES]=this.hideDeletedMessages)}return e.prototype.fetchNext=function(){var e=this;return new Promise((function(t,n){return r(e,void 0,void 0,(function(){var e,r,i,a;return s(this,(function(s){switch(s.label){case 0:if(s.trys.push([0,6,,7]),this.inProgress)return this.inProgress=!1,n(new o.CometChatException(E.MESSAGES_REQUEST_ERRORS.REQUEST_IN_PROGRESS_ERROR)),[2];if(this.inProgress=!0,this.onlyUpdates){if(0==this.updatedAt)return this.inProgress=!1,n(new o.CometChatException(E.MESSAGES_REQUEST_ERRORS.NOT_ENOUGH_PARAMS)),[2]}else if(0==this.timestamp&&0==this.id&&0==this.updatedAt)return this.inProgress=!1,n(new o.CometChatException(E.MESSAGES_REQUEST_ERRORS.NOT_ENOUGH_PARAMS)),[2];this.affix=l.MessageConstatnts.PAGINATION.AFFIX.APPEND,this.paginationMeta[l.MessageConstatnts.PAGINATION.KEYS.AFFIX]=this.affix,this.currentMethod=l.MessageConstatnts.PAGINATION.AFFIX.APPEND,s.label=1;case 1:return s.trys.push([1,4,,5]),[4,this.makeAPICall()];case 2:return e=s.sent(),[4,g.ExtensionController.hookOnMessageListIsFetched(e)];case 3:return r=s.sent(),t(r),this.inProgress=!1,[3,5];case 4:return i=s.sent(),this.inProgress=!1,n(new o.CometChatException(i)),[3,5];case 5:return[3,7];case 6:return a=s.sent(),this.inProgress=!1,n(new o.CometChatException(a)),[3,7];case 7:return[2]}}))}))}))},e.prototype.fetchPrevious=function(){var e=this;return new Promise((function(t,n){return r(e,void 0,void 0,(function(){var e,r,i,a;return s(this,(function(s){switch(s.label){case 0:if(s.trys.push([0,6,,7]),this.inProgress)return n(new o.CometChatException(E.MESSAGES_REQUEST_ERRORS.REQUEST_IN_PROGRESS_ERROR)),this.inProgress=!1,[2];if(this.inProgress=!0,this.onlyUpdates&&0==this.updatedAt)return this.inProgress=!1,n(new o.CometChatException(E.MESSAGES_REQUEST_ERRORS.NOT_ENOUGH_PARAMS)),[2];this.affix=l.MessageConstatnts.PAGINATION.AFFIX.PREPEND,this.paginationMeta[l.MessageConstatnts.PAGINATION.KEYS.AFFIX]=this.affix,this.currentMethod=l.MessageConstatnts.PAGINATION.AFFIX.PREPEND,s.label=1;case 1:return s.trys.push([1,4,,5]),[4,this.makeAPICall()];case 2:return e=s.sent(),[4,g.ExtensionController.hookOnMessageListIsFetched(e)];case 3:return r=s.sent(),t(r),this.inProgress=!1,[3,5];case 4:return i=s.sent(),this.inProgress=!1,n(new o.CometChatException(i)),[3,5];case 5:return[3,7];case 6:return a=s.sent(),this.inProgress=!1,n(new o.CometChatException(a)),[3,7];case 7:return[2]}}))}))}))},e.prototype.makeAPICall=function(){var e=this;return new Promise((function(t,n){try{var r=e.uid;if(void 0!==r){if(typeof r!==l.COMMON_UTILITY_CONSTANTS.TYPE_CONSTANTS.STRING)return void n(new o.CometChatException(JSON.parse(c.format(JSON.stringify(l.GENERAL_ERROR.PARAMETER_MUST_BE_A_STRING),"UID","UID","setUID()"))));if(c.isFalsy(r.trim()))return void n(new o.CometChatException(JSON.parse(c.format(JSON.stringify(l.GENERAL_ERROR.INVALID),"UID","UID","UID","UID"))));e.uid=r.trim()}var s=e.guid;if(void 0!==s){if(typeof s!==l.COMMON_UTILITY_CONSTANTS.TYPE_CONSTANTS.STRING)return void n(new o.CometChatException(JSON.parse(c.format(JSON.stringify(l.GENERAL_ERROR.PARAMETER_MUST_BE_A_STRING),"GUID","GUID","setGUID()"))));if(c.isFalsy(s.trim()))return void n(new o.CometChatException(JSON.parse(c.format(JSON.stringify(l.GENERAL_ERROR.INVALID),"GUID","GUID","GUID","GUID"))));e.guid=s.trim()}var u=e.parentMessageId;if(void 0!==u){if(isNaN(u))return void n(new o.CometChatException(JSON.parse(c.format(JSON.stringify(l.GENERAL_ERROR.PARAMETER_MUST_BE_A_NUMBER),"PARENT_MESSAGE_ID","PARENT_MESSAGE_ID","setParentMessageId()"))));if(u<l.DEFAULT_VALUES.ZERO)return void n(new o.CometChatException(JSON.parse(c.format(JSON.stringify(l.GENERAL_ERROR.PARAMETER_MUST_BE_A_POSITIVE_NUMBER),"PARENT_MESSAGE_ID","PARENT_MESSAGE_ID","setParentMessageId()"))))}var E=e.paginationMeta[l.MessageConstatnts.PAGINATION.KEYS.PER_PAGE];if(void 0===E)return void n(new o.CometChatException(JSON.parse(c.format(JSON.stringify(l.GENERAL_ERROR.METHOD_COMPULSORY),"SET_LIMIT","SET_LIMIT","Set Limit"))));if(isNaN(E))return void n(new o.CometChatException(JSON.parse(c.format(JSON.stringify(l.GENERAL_ERROR.PARAMETER_MUST_BE_A_NUMBER),"SET_LIMIT","SET_LIMIT","setLimit()"))));if(E>l.DEFAULT_VALUES.MSGS_MAX_LIMIT)return void n(new o.CometChatException(JSON.parse(c.format(JSON.stringify(l.GENERAL_ERROR.LIMIT_EXCEEDED),"SET_LIMIT","SET_LIMIT",l.DEFAULT_VALUES.MSGS_MAX_LIMIT))));if(E<l.DEFAULT_VALUES.ZERO)return void n(new o.CometChatException(JSON.parse(c.format(JSON.stringify(l.GENERAL_ERROR.PARAMETER_MUST_BE_A_POSITIVE_NUMBER),"SET_LIMIT","SET_LIMIT","setLimit()"))));var g=e.paginationMeta[l.MessageConstatnts.PAGINATION.KEYS.SEARCH_KEY];if(void 0!==g){if(typeof g!==l.COMMON_UTILITY_CONSTANTS.TYPE_CONSTANTS.STRING)return void n(new o.CometChatException(JSON.parse(c.format(JSON.stringify(l.GENERAL_ERROR.PARAMETER_MUST_BE_A_STRING),"SET_SEARCH_KEYWORD","SET_SEARCH_KEYWORD","setSearchKeyword()"))));if(c.isFalsy(g.trim()))return void n(new o.CometChatException(JSON.parse(c.format(JSON.stringify(l.GENERAL_ERROR.INVALID),"SET_SEARCH_KEYWORD","SET_SEARCH_KEYWORD","search keyword","search keyword"))));e.paginationMeta[l.MessageConstatnts.PAGINATION.KEYS.SEARCH_KEY]=g.trim()}var f=e.paginationMeta[l.MessageConstatnts.PAGINATION.KEYS.ID];if(void 0!==f){if(isNaN(f))return void n(new o.CometChatException(JSON.parse(c.format(JSON.stringify(l.GENERAL_ERROR.PARAMETER_MUST_BE_A_NUMBER),"MESSAGE_ID","MESSAGE_ID","setMessageId()"))));if(f<l.DEFAULT_VALUES.ZERO)return void n(new o.CometChatException(JSON.parse(c.format(JSON.stringify(l.GENERAL_ERROR.PARAMETER_MUST_BE_A_POSITIVE_NUMBER),"MESSAGE_ID","MESSAGE_ID","setMessageId()"))))}var T=e.paginationMeta[l.MessageConstatnts.PAGINATION.KEYS.SENT_AT];if(void 0!==T){if(isNaN(T))return void n(new o.CometChatException(JSON.parse(c.format(JSON.stringify(l.GENERAL_ERROR.PARAMETER_MUST_BE_A_NUMBER),"TIMESTAMP","TIMESTAMP","setTimestamp()"))));if(T<l.DEFAULT_VALUES.ZERO)return void n(new o.CometChatException(JSON.parse(c.format(JSON.stringify(l.GENERAL_ERROR.PARAMETER_MUST_BE_A_POSITIVE_NUMBER),"TIMESTAMP","TIMESTAMP","setTimestamp()"))))}var m=e.hideMessagesFromBlockedUsers;if(void 0!==m){if(typeof m!==l.COMMON_UTILITY_CONSTANTS.TYPE_CONSTANTS.BOOLEAN)return void n(new o.CometChatException(JSON.parse(c.format(JSON.stringify(l.GENERAL_ERROR.PARAMETER_MUST_BE_A_BOOLEAN),"HIDE_MESSAGES_FROM_BLOCKED_USERS","HIDE_MESSAGES_FROM_BLOCKED_USERS","hideMessagesFromBlockedUsers()"))));e.paginationMeta[l.MessageConstatnts.PAGINATION.KEYS.HIDE_MESSAGES_FROM_BLOCKED_USER]=1==m?1:0}var A=e.unread;if(void 0!==A){if(typeof A!==l.COMMON_UTILITY_CONSTANTS.TYPE_CONSTANTS.BOOLEAN)return void n(new o.CometChatException(JSON.parse(c.format(JSON.stringify(l.GENERAL_ERROR.PARAMETER_MUST_BE_A_BOOLEAN),"UNREAD","UNREAD","setUnread()"))));e.paginationMeta[l.MessageConstatnts.PAGINATION.KEYS.UNREAD]=1==A?1:0}var I=e.category;if(void 0!==I){if(typeof I!==l.COMMON_UTILITY_CONSTANTS.TYPE_CONSTANTS.STRING)return void n(new o.CometChatException(JSON.parse(c.format(JSON.stringify(l.GENERAL_ERROR.PARAMETER_MUST_BE_A_STRING),"SET_CATEGORY","SET_CATEGORY","setCategory()"))));if(c.isFalsy(I.trim()))return void n(new o.CometChatException(JSON.parse(c.format(JSON.stringify(l.GENERAL_ERROR.INVALID),"SET_CATEGORY","SET_CATEGORY","category","category"))));e.paginationMeta[l.MessageConstatnts.PAGINATION.KEYS.CATEGORIES]=I.trim()}var R=e.categories;if(void 0!==R){if(!Array.isArray(R))return void n(new o.CometChatException(JSON.parse(c.format(JSON.stringify(l.GENERAL_ERROR.PARAMETER_MUST_BE_AN_ARRAY),"SET_CATEGORIES","SET_CATEGORIES","setCategories()"))));R.length>0&&(e.paginationMeta[l.MessageConstatnts.PAGINATION.KEYS.CATEGORIES]=R)}var N=e.type;if(void 0!==N){if(typeof N!==l.COMMON_UTILITY_CONSTANTS.TYPE_CONSTANTS.STRING)return void n(new o.CometChatException(JSON.parse(c.format(JSON.stringify(l.GENERAL_ERROR.PARAMETER_MUST_BE_A_STRING),"SET_TYPE","SET_TYPE","setType()"))));if(c.isFalsy(N.trim()))return void n(new o.CometChatException(JSON.parse(c.format(JSON.stringify(l.GENERAL_ERROR.INVALID),"SET_TYPE","SET_TYPE","type","type"))));e.paginationMeta[l.MessageConstatnts.PAGINATION.KEYS.TYPES]=N.trim()}var O=e.types;if(void 0!==O){if(!Array.isArray(O))return void n(new o.CometChatException(JSON.parse(c.format(JSON.stringify(l.GENERAL_ERROR.PARAMETER_MUST_BE_AN_ARRAY),"SET_TYPES","SET_TYPES","setTypes()"))));O.length>0&&(e.paginationMeta[l.MessageConstatnts.PAGINATION.KEYS.TYPES]=O)}var y=e.hideDeletedMessages;if(void 0!==y){if(typeof y!==l.COMMON_UTILITY_CONSTANTS.TYPE_CONSTANTS.BOOLEAN)return void n(new o.CometChatException(JSON.parse(c.format(JSON.stringify(l.GENERAL_ERROR.PARAMETER_MUST_BE_A_BOOLEAN),"HIDE_DELETED_MESSAGES","HIDE_DELETED_MESSAGES","hideDeletedMessages()"))));e.paginationMeta[l.MessageConstatnts.PAGINATION.KEYS.HIDE_DELETED_MESSAGES]=1==y?1:0}if(e.createEndpoint(),e.totalPages)if(1!=e.totalPages);else if(e.lastAffix==e.affix)return void t([]);i.makeApiCall(e.endpointName,{listId:e.listId},e.paginationMeta).then((function(n){var r=[];if(n[l.ResponseConstants.RESPONSE_KEYS.KEY_META][l.ResponseConstants.RESPONSE_KEYS.KEY_CURSOR].hasOwnProperty(l.MessageConstatnts.PAGINATION.KEYS.ID)&&0==e.id&&(e.id=parseInt(n.meta.cursor[l.MessageConstatnts.PAGINATION.KEYS.ID])),n[l.ResponseConstants.RESPONSE_KEYS.KEY_META][l.ResponseConstants.RESPONSE_KEYS.KEY_CURSOR].hasOwnProperty(l.MessageConstatnts.PAGINATION.KEYS.SENT_AT)&&0==e.timestamp&&(e.timestamp=n.meta.cursor[l.MessageConstatnts.PAGINATION.KEYS.SENT_AT]),n.meta.pagination.hasOwnProperty("total_pages")&&(e.totalPages=n.meta.pagination.total_pages),n.meta.cursor.hasOwnProperty("affix")&&(e.lastAffix=n.meta.cursor.affix),n.data[0]){e.id>0&&(e.id=parseInt(n.data[0].id)),e.timestamp>0&&(e.timestamp=n.data[0].sentAt);var s=n.data[n.data.length-1];if(!d.CometChat.didMessagesPollingStart()&&d.CometChat.getConnectionStatus()==l.CONNECTION_STATUS.CONNECTED&&h.XMPPConnectionHelper.getInstance().connection&&s.sender.toLowerCase()!=p.getUidFromJid(h.XMPPConnectionHelper.getInstance().connection.jid).toLowerCase()&&(void 0!==e.guid||void 0!==e.uid||void 0!==e.parentMessageId)&&void 0!==s){var o=s.receiverType,i=d.CometChat.getMode();(c.isFalsy(i)||i&&i===l.APP_SETTINGS.KEYS.DEFAULT_MODE)&&d.CometChat.getLoggedInUser().then((function(e){var t=new C.User(e);t.setAuthToken("");var n=JSON.stringify(t);if(o==l.MessageConstatnts.RECEIVER_TYPE.USER){if(c.isFalsy(s.deliveredAt)){var r=s.receiver,i=s.id,a=s.sender;p.getJidFromUid(a).then((function(e){var t=_.$msg({to:e,from:h.XMPPConnectionHelper.getInstance().connection.jid,id:h.XMPPConnectionHelper.getInstance().connection.getUniqueId(),type:l.MessageConstatnts.XMPP_KEYS.TYPE_USER}).c("user",{xmlns:"com.cometchat.models:User"}).t(n).up(),s=_.Strophe.xmlElement("delivered",{type:o,receiverId:r,xmlns:"urn:xmpp:receipts",id:"["+d.CometChat.getAppId()+"]"+i});t.tree().appendChild(s),h.XMPPConnectionHelper.getInstance().connection.send(t)}))}}else{var u=s.receiver;f=s.id,p.getGroupJidFromGUID(u).then((function(e){var t=_.$msg({to:e,from:h.XMPPConnectionHelper.getInstance().connection.jid,id:h.XMPPConnectionHelper.getInstance().connection.getUniqueId(),type:l.MessageConstatnts.XMPP_KEYS.TYPE_GROUP}).c("user",{xmlns:"com.cometchat.models:User"}).t(n).up(),r=_.Strophe.xmlElement("delivered",{type:o,receiverId:u,xmlns:"urn:xmpp:receipts",id:"["+d.CometChat.getAppId()+"]"+f});t.tree().appendChild(r),h.XMPPConnectionHelper.getInstance().connection.send(t)}))}}))}n.data.map((function(t){if(!d.CometChat.didMessagesPollingStart()&&d.CometChat.getConnectionStatus()==l.CONNECTION_STATUS.CONNECTED&&h.XMPPConnectionHelper.getInstance().connection&&t.sender.toLowerCase()!=p.getUidFromJid(h.XMPPConnectionHelper.getInstance().connection.jid).toLowerCase()&&void 0===e.guid&&void 0===e.uid&&void 0===e.parentMessageId){var n=t.receiverType,o=d.CometChat.getMode();(c.isFalsy(o)||o&&o===l.APP_SETTINGS.KEYS.DEFAULT_MODE)&&d.CometChat.getLoggedInUser().then((function(e){var r=new C.User(e);r.setAuthToken("");var o=JSON.stringify(r);if(n==l.MessageConstatnts.RECEIVER_TYPE.USER){if(c.isFalsy(t.deliveredAt)){var i=s.receiver,a=s.id,u=s.sender,E=l.MessageConstatnts.XMPP_KEYS.TYPE_USER;p.getJidFromUid(u).then((function(e){var t=_.$msg({to:e,from:h.XMPPConnectionHelper.getInstance().connection.jid,id:h.XMPPConnectionHelper.getInstance().connection.getUniqueId(),type:E}).c("user",{xmlns:"com.cometchat.models:User"}).t(o).up(),n=_.Strophe.xmlElement("delivered",{type:E,receiverId:i,xmlns:"urn:xmpp:receipts",id:"["+d.CometChat.getAppId()+"]"+a});t.tree().appendChild(n),h.XMPPConnectionHelper.getInstance().connection.send(t)}))}}else if(c.isFalsy(t.myReceipt)){var S=t.receiver,g=s.id,f=l.MessageConstatnts.XMPP_KEYS.TYPE_GROUP;p.getGroupJidFromGUID(S).then((function(e){var t=_.$msg({to:e,from:h.XMPPConnectionHelper.getInstance().connection.jid,id:h.XMPPConnectionHelper.getInstance().connection.getUniqueId(),type:f}).c("user",{xmlns:"com.cometchat.models:User"}).t(o).up(),n=_.Strophe.xmlElement("delivered",{type:f,receiverId:S,xmlns:"urn:xmpp:receipts",id:"["+d.CometChat.getAppId()+"]"+g});t.tree().appendChild(n),h.XMPPConnectionHelper.getInstance().connection.send(t)}))}}))}S.MessageListnerMaping.getInstance().get("all").then((function(e){parseInt(t.id)>e&&S.MessageListnerMaping.getInstance().set("all",parseInt(t.id))}),(function(e){S.MessageListnerMaping.getInstance().set("all",parseInt(t.id))})),e.affix==l.MessageConstatnts.PAGINATION.AFFIX.APPEND?(e.id<parseInt(t.id)&&e.id>0&&(e.id=parseInt(t.id)),e.timestamp<t.sentAt&&e.timestamp>0&&(e.timestamp=t.sentAt),e.updatedAt<t.updatedAt&&e.updatedAt>0&&(e.updatedAt=t.updatedAt)):(e.id>parseInt(t.id)&&(e.id=parseInt(t.id)),e.timestamp>t.sentAt&&(e.timestamp=t.sentAt),e.updatedAt>t.updatedAt&&(e.updatedAt=t.updatedAt)),e.id&&(e.paginationMeta[l.MessageConstatnts.PAGINATION.KEYS.ID]=e.id),e.timestamp&&(e.paginationMeta[l.MessageConstatnts.PAGINATION.KEYS.SENT_AT]=e.timestamp),e.updatedAt&&(e.paginationMeta[l.MessageConstatnts.PAGINATION.KEYS.UPDATED_AT]=e.updatedAt),r.push(a.MessageController.trasformJSONMessge(t))}))}else r=[];t(r)}),(function(e){n(new o.CometChatException(e.error))}))}catch(e){n(new o.CometChatException(e))}}))},e.prototype.createEndpoint=function(){this.parentMessageId?(this.endpointName="getThreadMessages",this.listId=this.parentMessageId.toString(),this.hideReplies&&(this.hideReplies=!1,delete this.paginationMeta[l.MessageConstatnts.PAGINATION.KEYS.HIDE_REPLIES])):(c.isFalsy(this.guid)||c.isFalsy(this.uid))&&c.isFalsy(this.guid)?c.isFalsy(this.uid)?(this.endpointName="getMessages",this.listId=this.uid):(this.endpointName="getUserMessages",this.listId=this.uid):(this.endpointName="getGroupMessages",this.listId=this.guid)},e.prototype.makeData=function(){var e={};e[l.MessageConstatnts.PAGINATION.KEYS.PER_PAGE]=this.limit,e[l.MessageConstatnts.PAGINATION.KEYS.AFFIX]=this.affix,(c.isFalsy(this.guid)||c.isFalsy(this.uid))&&c.isFalsy(this.guid)&&c.isFalsy(this.uid)},e.prototype.getFilteredPreviousDataByReceiverId=function(e){return r(this,void 0,void 0,(function(){var t,n=this;return s(this,(function(r){switch(r.label){case 0:switch(t=[],e){case"user":return[3,1];case"group":return[3,3];case"both":return[3,5]}return[3,7];case 1:return[4,u.MessagesStore.getInstance().get(this.uid).then((function(e){Object.keys(e).filter((function(e){return parseInt(e)>n.id})).map((function(n){t=t.concat([e[n]])}))}))];case 2:return r.sent(),[3,9];case 3:return[4,u.MessagesStore.getInstance().get(this.guid).then((function(e){Object.keys(e).filter((function(e){return parseInt(e)>n.id})).map((function(n){t=t.concat([e[n]])}))}))];case 4:r.sent(),r.label=5;case 5:return[4,u.MessagesStore.getInstance().get(this.guid).then((function(e){Object.keys(e).filter((function(e){return parseInt(e)>n.id})).filter((function(t){return e[t].sender.uid==n.uid})).map((function(n){t=t.concat([e[n]])}))}))];case 6:return r.sent(),[3,9];case 7:return[4,u.MessagesStore.getInstance().getAllMessages().then((function(e){Object.keys(e).filter((function(e){return parseInt(e)>n.id})).map((function(n){t=t.concat([e[n]])}))}))];case 8:return r.sent(),[3,9];case 9:return[2,t]}}))}))},e.prototype.getFilteredNextDataByReceiverId=function(e){return r(this,void 0,void 0,(function(){var t,n=this;return s(this,(function(r){switch(r.label){case 0:switch(t=[],e){case"user":return[3,1];case"group":return[3,3];case"both":return[3,5]}return[3,7];case 1:return[4,u.MessagesStore.getInstance().get(this.uid).then((function(e){Object.keys(e).filter((function(e){return parseInt(e)>n.id})).map((function(n){t=t.concat([e[n]])}))}))];case 2:return r.sent(),[3,9];case 3:return[4,u.MessagesStore.getInstance().get(this.guid).then((function(e){Object.keys(e).filter((function(e){return parseInt(e)>n.id})).map((function(n){t=t.concat([e[n]])}))}))];case 4:r.sent(),r.label=5;case 5:return[4,u.MessagesStore.getInstance().get(this.guid).then((function(e){Object.keys(e).filter((function(e){return parseInt(e)>n.id})).filter((function(t){return e[t].sender.uid==n.uid})).map((function(n){t=t.concat([e[n]])}))}))];case 6:return r.sent(),[3,9];case 7:return[4,u.MessagesStore.getInstance().getAllMessages().then((function(e){Object.keys(e).filter((function(e){return parseInt(e)>n.id})).map((function(n){t=t.concat([e[n]])}))}))];case 8:return r.sent(),[3,9];case 9:return[2,t]}}))}))},e}();t.DefaultMessagesRequest=f;var T=function(){function e(){this.maxLimit=l.DEFAULT_VALUES.MSGS_MAX_LIMIT,this.timestamp=0,this.id=l.DEFAULT_VALUES.DEFAULT_MSG_ID,this.unread=!1,this.HideMessagesFromBlockedUsers=!1,this.onlyUpdate=0,this.HideDeletedMessages=!1}return e.prototype.setLimit=function(e){return this.limit=e,this},e.prototype.setGUID=function(e){return this.guid=e,this},e.prototype.setUID=function(e){return this.uid=e,this},e.prototype.setParentMessageId=function(e){return this.parentMessageId=e,this},e.prototype.setTimestamp=function(e){return void 0===e&&(e=c.getCurrentTime()),this.timestamp=e,this},e.prototype.setMessageId=function(e){return void 0===e&&(e=l.DEFAULT_VALUES.DEFAULT_MSG_ID),this.id=e,this},e.prototype.setUnread=function(e){return void 0===e&&(e=!1),this.unread=e,this},e.prototype.hideMessagesFromBlockedUsers=function(e){return void 0===e&&(e=!1),this.HideMessagesFromBlockedUsers=e,this},e.prototype.setSearchKeyword=function(e){return this.searchKey=e,this},e.prototype.setUpdatedAfter=function(e){return this.updatedAt=e,this},e.prototype.updatesOnly=function(e){return e&&(this.onlyUpdate=1),this},e.prototype.setCategory=function(e){return this.category=e,this},e.prototype.setCategories=function(e){return this.categories=e,this},e.prototype.setType=function(e){return this.type=e,this},e.prototype.setTypes=function(e){return this.types=e,this},e.prototype.hideReplies=function(e){return this.HideReplies=e,this},e.prototype.hideDeletedMessages=function(e){return this.HideDeletedMessages=e,this},e.prototype.build=function(){return this.category&&this.categories&&this.categories.push(this.category),this.type&&this.types&&this.types.push(this.type),new f(this)},e}();t.DefaultMessagesRequestBuilder=T},function(e,t,n){"use strict";t.__esModule=!0;var r=function(e){};t.CometChatExtension=r},function(e,t,n){"use strict";t.__esModule=!0;var r=n(5),s=n(1),o=n(8),i=n(2),a=n(0),c=function(){function e(e){this.next_page=1,this.current_page=1,this.total_pages=-1,this.fetchingInProgress=!1,this.pagination={total:0,count:0,per_page:0,current_page:0,total_pages:0,links:[]},s.isFalsy(e)||(this.limit=e.limit,s.isFalsy(e.searchKeyword)||(this.searchKeyword=e.searchKeyword),s.isFalsy(e.direction)||(this.direction=e.direction))}return e.prototype.validateBlockedUsersBuilder=function(){if(void 0===this.limit)return new i.CometChatException(JSON.parse(s.format(JSON.stringify(a.GENERAL_ERROR.METHOD_COMPULSORY),"SET_LIMIT","SET_LIMIT","Set Limit")));if(isNaN(this.limit))return new i.CometChatException(JSON.parse(s.format(JSON.stringify(a.GENERAL_ERROR.PARAMETER_MUST_BE_A_NUMBER),"SET_LIMIT","SET_LIMIT","setLimit()")));if(this.limit>a.DEFAULT_VALUES.USERS_MAX_LIMIT)return new i.CometChatException(JSON.parse(s.format(JSON.stringify(a.GENERAL_ERROR.LIMIT_EXCEEDED),"SET_LIMIT","SET_LIMIT",a.DEFAULT_VALUES.USERS_MAX_LIMIT)));if(this.limit<a.DEFAULT_VALUES.ZERO)return new i.CometChatException(JSON.parse(s.format(JSON.stringify(a.GENERAL_ERROR.PARAMETER_MUST_BE_A_POSITIVE_NUMBER),"SET_LIMIT","SET_LIMIT","setLimit()")));if(void 0!==this.searchKeyword){if(typeof this.searchKeyword!==a.COMMON_UTILITY_CONSTANTS.TYPE_CONSTANTS.STRING)return new i.CometChatException(JSON.parse(s.format(JSON.stringify(a.GENERAL_ERROR.PARAMETER_MUST_BE_A_STRING),"SET_SEARCH_KEYWORD","SET_SEARCH_KEYWORD","setSearchKeyword()")));if(s.isFalsy(this.searchKeyword.trim()))return new i.CometChatException(JSON.parse(s.format(JSON.stringify(a.GENERAL_ERROR.INVALID),"SET_SEARCH_KEYWORD","SET_SEARCH_KEYWORD","search keyword","search keyword")));this.searchKeyword=this.searchKeyword.trim()}if(void 0!==this.direction){if(typeof this.direction!==a.COMMON_UTILITY_CONSTANTS.TYPE_CONSTANTS.STRING)return new i.CometChatException(JSON.parse(s.format(JSON.stringify(a.GENERAL_ERROR.PARAMETER_MUST_BE_A_STRING),"SET_DIRECTION","SET_DIRECTION","setDirection()")));if(this.direction!=a.BlockedUsersConstants.REQUEST_KEYS.DIRECTIONS.BOTH&&this.direction!=a.BlockedUsersConstants.REQUEST_KEYS.DIRECTIONS.BLOCKED_BY_ME&&this.direction!=a.BlockedUsersConstants.REQUEST_KEYS.DIRECTIONS.HAS_BLOCKED_ME)return new i.CometChatException(a.UserErrors.INVALID_DIRECTION)}},e.prototype.fetchPrevious=function(){var e=this;return this.fetchingInProgress=!0,new Promise((function(t,n){try{0==e.next_page&&(t([]),e.fetchingInProgress=!1);var s=e.validateBlockedUsersBuilder();if(s instanceof i.CometChatException)return void n(s);if(!e.fetchingInProgress)return r.makeApiCall("blockedUsersList",{},e.getPreData()).then((function(n){if(n.meta&&(e.total_pages=n.meta.pagination.total_pages),n.data.length>0){e.pagination=n.meta.pagination;var r=[];n.data.map((function(e,t){r.push(o.UsersController.trasformJSONUser(e))})),t(r),e.fetchingInProgress=!1}t([]),e.fetchingInProgress=!1}),(function(t){n(new i.CometChatException(t.error)),e.fetchingInProgress=!1}));t([])}catch(t){e.fetchingInProgress=!1,n(new i.CometChatException(t))}}))},e.prototype.fetchNext=function(){var e=this;return new Promise((function(t,n){try{if(e.fetchingInProgress)e.fetchingInProgress=!1,t([]);else{e.fetchingInProgress=!0;var s=e.validateBlockedUsersBuilder();if(s instanceof i.CometChatException)return void n(s);r.makeApiCall("blockedUsersList",{},e.getNextData()).then((function(n){if(n.meta&&(e.total_pages=n.meta.pagination.total_pages),n.data.length>0){e.pagination=n.meta.pagination;var r=[];n.data.map((function(e){r.push(o.UsersController.trasformJSONUser(e))})),t(r)}else t([]);e.fetchingInProgress=!1}),(function(t){e.fetchingInProgress=!1,n(new i.CometChatException(t.error))}))}}catch(t){e.fetchingInProgress=!1,n(new i.CometChatException(t))}}))},e.prototype.getNextData=function(){var e={};if(e.per_page=this.limit,s.isFalsy(this.direction)||(e.direction=this.direction),s.isFalsy(this.searchKeyword)||(e.searchKey=this.searchKeyword),1==this.current_page)e.page=this.next_page,this.next_page++,this.current_page++;else{if(this.next_page>this.total_pages)return e.page=this.next_page,e;e.page=this.next_page++}return e},e.prototype.getPreData=function(){var e={};return e.per_page=this.limit,this.next_page>=0?(this.next_page>0&&(e.page=--this.next_page),e):e},e.MAX_LIMIT=2,e.DEFAULT_LIMIT=1,e.directions=a.BlockedUsersConstants.REQUEST_KEYS.DIRECTIONS,e}();t.BlockedUsersRequest=c;var u=function(){function e(){}return e.prototype.setLimit=function(e){return this.limit=e,this},e.prototype.setSearchKeyword=function(e){return this.searchKeyword=e,this},e.prototype.setDirection=function(e){return this.direction=e,this},e.prototype.blockedByMe=function(){return this.direction=a.BlockedUsersConstants.REQUEST_KEYS.DIRECTIONS.BLOCKED_BY_ME,this},e.prototype.hasBlockedMe=function(){return this.direction=a.BlockedUsersConstants.REQUEST_KEYS.DIRECTIONS.HAS_BLOCKED_ME,this},e.prototype.build=function(){return new c(this)},e}();t.BlockedUsersRequestBuilder=u},function(e,t,n){"use strict";t.__esModule=!0;var r=n(7),s=n(0),o=n(8),i=n(16),a=n(28),c=n(3),u=n(2),l=n(1),E=function(){function e(){}return e.processMessage=function(e){try{return r.MessageController.trasformJSONMessge(e)}catch(e){l.Logger.error("CometChatHelper: processMessage",e)}},e.getConversationFromMessage=function(e){return new Promise((function(t,n){try{c.CometChat.getLoggedinUser().then((function(c){if(null!==c){var u=r.MessageController.trasformJSONMessge(e),l=u.receiverType,E=u.conversationId,d=void 0,h=r.MessageController.trasformJSONMessge(e);if(l==s.MessageConstatnts.RECEIVER_TYPE.USER){var p=o.UsersController.trasformJSONUser(u[s.MessageConstatnts.KEYS.SENDER]);d=p.getUid()==c.getUid()?o.UsersController.trasformJSONUser(u[s.MessageConstatnts.KEYS.RECEIVER]):p}else d=i.GroupsController.trasformJSONGroup(u[s.MessageConstatnts.KEYS.RECEIVER]);var S=a.ConversationController.trasformJSONConversation(E,l,h,d,0);t(S)}else n(s.UserErrors.USER_NOT_LOGGED_IN)}),(function(e){n(new u.CometChatException(e.error))}))}catch(e){n(new u.CometChatException(e))}}))},e}();t.CometChatHelper=E},function(e,t,n){"use strict";t.__esModule=!0;var r=n(0),s=function(){function e(e){this.sessionID=e.sessionID,this.defaultLayout=e.defaultLayout,this.isAudioOnly=e.isAudioOnly,this.region=e.region,this.user=e.user,this.mode=e.mode,this.domain=e.domain,this.ShowEndCallButton=e.ShowEndCallButton,this.ShowMuteAudioButton=e.ShowMuteAudioButton,this.ShowPauseVideoButton=e.ShowPauseVideoButton,this.ShowScreenShareButton=e.ShowScreenShareButton,this.ShowSwitchModeButton=e.ShowSwitchModeButton,this.StartAudioMuted=e.StartAudioMuted,this.StartVideoMuted=e.StartVideoMuted,this.localizedObject=e.localizedObject,this.analyticsSettings=e.analyticsSettings,this.appId=e.appId,this.customCSS=e.customCSS,this.ShowRecordingButton=e.ShowRecordingButton,this.StartRecordingOnCallStart=e.StartRecordingOnCallStart,this.useLegacyUI=e.useLegacyUI}return e.prototype.shouldUseLegacyUI=function(){return this.useLegacyUI},e.prototype.isRecordingButtonEnabled=function(){return this.ShowRecordingButton},e.prototype.shouldStartRecordingOnCallStart=function(){return this.StartRecordingOnCallStart},e.prototype.getCustomCSS=function(){return this.customCSS},e.prototype.getSessionId=function(){return this.sessionID},e.prototype.isAudioOnlyCall=function(){return this.isAudioOnly},e.prototype.getUser=function(){return this.user},e.prototype.getRegion=function(){return this.region},e.prototype.getAppId=function(){return this.appId},e.prototype.getDomain=function(){return this.domain},e.prototype.isDefaultLayoutEnabled=function(){return this.defaultLayout},e.prototype.getMode=function(){return this.mode},e.prototype.getStartWithAudioMuted=function(){return this.StartAudioMuted},e.prototype.getStartWithVideoMuted=function(){return this.StartVideoMuted},e.prototype.isEndCallButtonEnabled=function(){return this.ShowEndCallButton},e.prototype.isMuteAudioButtonEnabled=function(){return this.ShowMuteAudioButton},e.prototype.isPauseVideoButtonEnabled=function(){return this.ShowPauseVideoButton},e.prototype.isScreenShareButtonEnabled=function(){return this.ShowScreenShareButton},e.prototype.isModeButtonEnabled=function(){return this.ShowSwitchModeButton},e.prototype.getLocalizedStringObject=function(){return this.localizedObject},e.prototype.getAnalyticsSettings=function(){return this.analyticsSettings},e}();t.CallSettings=s;var o=function(){function e(){this.defaultLayout=!0,this.isAudioOnly=!1,this.mode=r.CallConstants.CALL_MODE.DEFAULT,this.ShowEndCallButton=!0,this.ShowMuteAudioButton=!0,this.ShowPauseVideoButton=!0,this.ShowScreenShareButton=!0,this.ShowSwitchModeButton=!0,this.StartAudioMuted=!1,this.StartVideoMuted=!1,this.localizedObject={},this.analyticsSettings={},this.ShowRecordingButton=!1,this.StartRecordingOnCallStart=!1,this.useLegacyUI=!0}return e.prototype.setSessionID=function(e){return this.sessionID=e,this},e.prototype.enableDefaultLayout=function(e){return this.defaultLayout=e,this},e.prototype.setIsAudioOnlyCall=function(e){return this.isAudioOnly=e,this},e.prototype.setRegion=function(e){return this.region=e,this},e.prototype.setDomain=function(e){return this.domain=e,this},e.prototype.setUser=function(e){return this.user=e,this},e.prototype.setMode=function(e){return this.mode=e,this},e.prototype.showEndCallButton=function(e){return this.ShowEndCallButton=e,this},e.prototype.showMuteAudioButton=function(e){return this.ShowMuteAudioButton=e,this},e.prototype.showPauseVideoButton=function(e){return this.ShowPauseVideoButton=e,this},e.prototype.showScreenShareButton=function(e){return this.ShowScreenShareButton=e,this},e.prototype.showModeButton=function(e){return this.ShowSwitchModeButton=e,this},e.prototype.setLocalizedStringObject=function(e){return this.localizedObject=e,this},e.prototype.setAnalyticsSettings=function(e){return this.analyticsSettings=e,this},e.prototype.setAppId=function(e){return this.appId=e,this},e.prototype.startWithAudioMuted=function(e){return this.StartAudioMuted=e,this},e.prototype.startWithVideoMuted=function(e){return this.StartVideoMuted=e,this},e.prototype.setCustomCSS=function(e){return this.customCSS=e,this},e.prototype.showRecordingButton=function(e){return this.ShowRecordingButton=e,this},e.prototype.startRecordingOnCallStart=function(e){return this.StartRecordingOnCallStart=e,this},e.prototype.forceLegacyUI=function(e){return this.useLegacyUI=e,this},e.prototype.build=function(){return new s(this)},e}();t.CallSettingsBuilder=o},function(e,t,n){"use strict";t.__esModule=!0;var r=n(1),s=function(){function e(e){this.avatar="",r.isFalsy(e)||(this.uid=e.toString())}return e.prototype.setUID=function(e){this.uid=e?e.toString():""},e.prototype.getUID=function(){return this.uid.toString()},e.prototype.setName=function(e){this.name=e?e.toString():""},e.prototype.getName=function(){return this.name.toString()},e.prototype.setAvatar=function(e){this.avatar=e?e.toString():""},e.prototype.getAvatar=function(){return this.avatar.toString()},e.prototype.setJWT=function(e){this.jwt=e?e.toString():""},e.prototype.getJWT=function(){return this.jwt.toString()},e.prototype.setResource=function(e){this.resource=e?e.toString():""},e.prototype.getResource=function(){return this.resource.toString()},e}();t.RTCUser=s},function(e,t,n){"use strict";t.__esModule=!0;var r=n(1),s=function(){function e(e){this.id="",this.name="",e&&(r.isFalsy(e.id)||(this.id=e.id),r.isFalsy(e.name)||(this.name=e.name))}return e.prototype.getId=function(){return this.id},e.prototype.getName=function(){return this.name},e}();t.CCExtension=s},function(e,t,n){var r=n(65),s=n(66);e.exports=function(e,t,n){var o=t&&n||0;"string"==typeof e&&(t="binary"===e?new Array(16):null,e=null);var i=(e=e||{}).random||(e.rng||r)();if(i[6]=15&i[6]|64,i[8]=63&i[8]|128,t)for(var a=0;a<16;++a)t[o+a]=i[a];return t||s(i)}},function(e,t){var n="undefined"!=typeof crypto&&crypto.getRandomValues&&crypto.getRandomValues.bind(crypto)||"undefined"!=typeof msCrypto&&"function"==typeof window.msCrypto.getRandomValues&&msCrypto.getRandomValues.bind(msCrypto);if(n){var r=new Uint8Array(16);e.exports=function(){return n(r),r}}else{var s=new Array(16);e.exports=function(){for(var e,t=0;t<16;t++)0==(3&t)&&(e=4294967296*Math.random()),s[t]=e>>>((3&t)<<3)&255;return s}}},function(e,t){for(var n=[],r=0;r<256;++r)n[r]=(r+256).toString(16).substr(1);e.exports=function(e,t){var r=t||0,s=n;return[s[e[r++]],s[e[r++]],s[e[r++]],s[e[r++]],"-",s[e[r++]],s[e[r++]],"-",s[e[r++]],s[e[r++]],"-",s[e[r++]],s[e[r++]],"-",s[e[r++]],s[e[r++]],s[e[r++]],s[e[r++]],s[e[r++]],s[e[r++]]].join("")}},function(e,t,n){var r=n(17),s=n(68),o=r.NAMESPACE;function i(e){this.options=e||{locator:{}}}function a(){this.cdata=!1}function c(e,t){t.lineNumber=e.lineNumber,t.columnNumber=e.columnNumber}function u(e,t,n){return"string"==typeof e?e.substr(t,n):e.length>=t+n||t?new java.lang.String(e,t,n)+"":e}function l(e,t){e.currentElement?e.currentElement.appendChild(t):e.doc.appendChild(t)}i.prototype.parseFromString=function(e,t){var n=this.options,r=new d,i=n.domBuilder||new a,c=n.errorHandler,u=n.locator,l=n.xmlns||{},E=/\/x?html?$/.test(t),h=E?s.HTML_ENTITIES:s.XML_ENTITIES;return u&&i.setDocumentLocator(u),r.errorHandler=function(e,t,n){if(!e){if(t instanceof a)return t;e=t}var r={},s=e instanceof Function;function o(t){var o=e[t];!o&&s&&(o=2==e.length?function(n){e(t,n)}:e),r[t]=o&&function(e){o("[xmldom "+t+"]\t"+e+function(e){if(e)return"\n@"+(e.systemId||"")+"#[line:"+e.lineNumber+",col:"+e.columnNumber+"]"}(n))}||function(){}}return n=n||{},o("warning"),o("error"),o("fatalError"),r}(c,i,u),r.domBuilder=n.domBuilder||i,E&&(l[""]=o.HTML),l.xml=l.xml||o.XML,e&&"string"==typeof e?r.parse(e,l,h):r.errorHandler.error("invalid doc source"),i.doc},a.prototype={startDocument:function(){this.doc=(new p).createDocument(null,null,null),this.locator&&(this.doc.documentURI=this.locator.systemId)},startElement:function(e,t,n,r){var s=this.doc,o=s.createElementNS(e,n||t),i=r.length;l(this,o),this.currentElement=o,this.locator&&c(this.locator,o);for(var a=0;a<i;a++){e=r.getURI(a);var u=r.getValue(a),E=(n=r.getQName(a),s.createAttributeNS(e,n));this.locator&&c(r.getLocator(a),E),E.value=E.nodeValue=u,o.setAttributeNode(E)}},endElement:function(e,t,n){var r=this.currentElement;r.tagName;this.currentElement=r.parentNode},startPrefixMapping:function(e,t){},endPrefixMapping:function(e){},processingInstruction:function(e,t){var n=this.doc.createProcessingInstruction(e,t);this.locator&&c(this.locator,n),l(this,n)},ignorableWhitespace:function(e,t,n){},characters:function(e,t,n){if(e=u.apply(this,arguments)){if(this.cdata)var r=this.doc.createCDATASection(e);else r=this.doc.createTextNode(e);this.currentElement?this.currentElement.appendChild(r):/^\s*$/.test(e)&&this.doc.appendChild(r),this.locator&&c(this.locator,r)}},skippedEntity:function(e){},endDocument:function(){this.doc.normalize()},setDocumentLocator:function(e){(this.locator=e)&&(e.lineNumber=0)},comment:function(e,t,n){e=u.apply(this,arguments);var r=this.doc.createComment(e);this.locator&&c(this.locator,r),l(this,r)},startCDATA:function(){this.cdata=!0},endCDATA:function(){this.cdata=!1},startDTD:function(e,t,n){var r=this.doc.implementation;if(r&&r.createDocumentType){var s=r.createDocumentType(e,t,n);this.locator&&c(this.locator,s),l(this,s)}},warning:function(e){},error:function(e){},fatalError:function(e){throw new h(e,this.locator)}},"endDTD,startEntity,endEntity,attributeDecl,elementDecl,externalEntityDecl,internalEntityDecl,resolveEntity,getExternalSubset,notationDecl,unparsedEntityDecl".replace(/\w+/g,(function(e){a.prototype[e]=function(){return null}}));var E=n(69),d=E.XMLReader,h=E.ParseError,p=t.DOMImplementation=n(43).DOMImplementation;t.XMLSerializer=n(43).XMLSerializer,t.DOMParser=i,t.__DOMHandler=a},function(e,t,n){var r=n(17).freeze;t.XML_ENTITIES=r({amp:"&",apos:"'",gt:">",lt:"<",quot:'"'}),t.HTML_ENTITIES=r({lt:"<",gt:">",amp:"&",quot:'"',apos:"'",Agrave:"À",Aacute:"Á",Acirc:"Â",Atilde:"Ã",Auml:"Ä",Aring:"Å",AElig:"Æ",Ccedil:"Ç",Egrave:"È",Eacute:"É",Ecirc:"Ê",Euml:"Ë",Igrave:"Ì",Iacute:"Í",Icirc:"Î",Iuml:"Ï",ETH:"Ð",Ntilde:"Ñ",Ograve:"Ò",Oacute:"Ó",Ocirc:"Ô",Otilde:"Õ",Ouml:"Ö",Oslash:"Ø",Ugrave:"Ù",Uacute:"Ú",Ucirc:"Û",Uuml:"Ü",Yacute:"Ý",THORN:"Þ",szlig:"ß",agrave:"à",aacute:"á",acirc:"â",atilde:"ã",auml:"ä",aring:"å",aelig:"æ",ccedil:"ç",egrave:"è",eacute:"é",ecirc:"ê",euml:"ë",igrave:"ì",iacute:"í",icirc:"î",iuml:"ï",eth:"ð",ntilde:"ñ",ograve:"ò",oacute:"ó",ocirc:"ô",otilde:"õ",ouml:"ö",oslash:"ø",ugrave:"ù",uacute:"ú",ucirc:"û",uuml:"ü",yacute:"ý",thorn:"þ",yuml:"ÿ",nbsp:" ",iexcl:"¡",cent:"¢",pound:"£",curren:"¤",yen:"¥",brvbar:"¦",sect:"§",uml:"¨",copy:"©",ordf:"ª",laquo:"«",not:"¬",shy:"",reg:"®",macr:"¯",deg:"°",plusmn:"±",sup2:"²",sup3:"³",acute:"´",micro:"µ",para:"¶",middot:"·",cedil:"¸",sup1:"¹",ordm:"º",raquo:"»",frac14:"¼",frac12:"½",frac34:"¾",iquest:"¿",times:"×",divide:"÷",forall:"∀",part:"∂",exist:"∃",empty:"∅",nabla:"∇",isin:"∈",notin:"∉",ni:"∋",prod:"∏",sum:"∑",minus:"−",lowast:"∗",radic:"√",prop:"∝",infin:"∞",ang:"∠",and:"∧",or:"∨",cap:"∩",cup:"∪",int:"∫",there4:"∴",sim:"∼",cong:"≅",asymp:"≈",ne:"≠",equiv:"≡",le:"≤",ge:"≥",sub:"⊂",sup:"⊃",nsub:"⊄",sube:"⊆",supe:"⊇",oplus:"⊕",otimes:"⊗",perp:"⊥",sdot:"⋅",Alpha:"Α",Beta:"Β",Gamma:"Γ",Delta:"Δ",Epsilon:"Ε",Zeta:"Ζ",Eta:"Η",Theta:"Θ",Iota:"Ι",Kappa:"Κ",Lambda:"Λ",Mu:"Μ",Nu:"Ν",Xi:"Ξ",Omicron:"Ο",Pi:"Π",Rho:"Ρ",Sigma:"Σ",Tau:"Τ",Upsilon:"Υ",Phi:"Φ",Chi:"Χ",Psi:"Ψ",Omega:"Ω",alpha:"α",beta:"β",gamma:"γ",delta:"δ",epsilon:"ε",zeta:"ζ",eta:"η",theta:"θ",iota:"ι",kappa:"κ",lambda:"λ",mu:"μ",nu:"ν",xi:"ξ",omicron:"ο",pi:"π",rho:"ρ",sigmaf:"ς",sigma:"σ",tau:"τ",upsilon:"υ",phi:"φ",chi:"χ",psi:"ψ",omega:"ω",thetasym:"ϑ",upsih:"ϒ",piv:"ϖ",OElig:"Œ",oelig:"œ",Scaron:"Š",scaron:"š",Yuml:"Ÿ",fnof:"ƒ",circ:"ˆ",tilde:"˜",ensp:" ",emsp:" ",thinsp:" ",zwnj:"",zwj:"",lrm:"",rlm:"",ndash:"–",mdash:"—",lsquo:"‘",rsquo:"’",sbquo:"‚",ldquo:"“",rdquo:"”",bdquo:"„",dagger:"†",Dagger:"‡",bull:"•",hellip:"…",permil:"‰",prime:"′",Prime:"″",lsaquo:"‹",rsaquo:"›",oline:"‾",euro:"€",trade:"™",larr:"←",uarr:"↑",rarr:"→",darr:"↓",harr:"↔",crarr:"↵",lceil:"⌈",rceil:"⌉",lfloor:"⌊",rfloor:"⌋",loz:"◊",spades:"♠",clubs:"♣",hearts:"♥",diams:"♦"}),t.entityMap=t.HTML_ENTITIES},function(e,t,n){var r=n(17).NAMESPACE,s=/[A-Z_a-z\xC0-\xD6\xD8-\xF6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD]/,o=new RegExp("[\\-\\.0-9"+s.source.slice(1,-1)+"\\u00B7\\u0300-\\u036F\\u203F-\\u2040]"),i=new RegExp("^"+s.source+o.source+"*(?::"+s.source+o.source+"*)?$");function a(e,t){this.message=e,this.locator=t,Error.captureStackTrace&&Error.captureStackTrace(this,a)}function c(){}function u(e,t){return t.lineNumber=e.lineNumber,t.columnNumber=e.columnNumber,t}function l(e,t,n,s,o,i){function a(e,t,r){e in n.attributeNames&&i.fatalError("Attribute "+e+" redefined"),n.addValue(e,t,r)}for(var c,u=++t,l=0;;){var E=e.charAt(u);switch(E){case"=":if(1===l)c=e.slice(t,u),l=3;else{if(2!==l)throw new Error("attribute equal must after attrName");l=3}break;case"'":case'"':if(3===l||1===l){if(1===l&&(i.warning('attribute value must after "="'),c=e.slice(t,u)),t=u+1,!((u=e.indexOf(E,t))>0))throw new Error("attribute value no end '"+E+"' match");a(c,d=e.slice(t,u).replace(/&#?\w+;/g,o),t-1),l=5}else{if(4!=l)throw new Error('attribute value must after "="');a(c,d=e.slice(t,u).replace(/&#?\w+;/g,o),t),i.warning('attribute "'+c+'" missed start quot('+E+")!!"),t=u+1,l=5}break;case"/":switch(l){case 0:n.setTagName(e.slice(t,u));case 5:case 6:case 7:l=7,n.closed=!0;case 4:case 1:case 2:break;default:throw new Error("attribute invalid close char('/')")}break;case"":return i.error("unexpected end of input"),0==l&&n.setTagName(e.slice(t,u)),u;case">":switch(l){case 0:n.setTagName(e.slice(t,u));case 5:case 6:case 7:break;case 4:case 1:"/"===(d=e.slice(t,u)).slice(-1)&&(n.closed=!0,d=d.slice(0,-1));case 2:2===l&&(d=c),4==l?(i.warning('attribute "'+d+'" missed quot(")!'),a(c,d.replace(/&#?\w+;/g,o),t)):(r.isHTML(s[""])&&d.match(/^(?:disabled|checked|selected)$/i)||i.warning('attribute "'+d+'" missed value!! "'+d+'" instead!!'),a(d,d,t));break;case 3:throw new Error("attribute value missed!!")}return u;case"":E=" ";default:if(E<=" ")switch(l){case 0:n.setTagName(e.slice(t,u)),l=6;break;case 1:c=e.slice(t,u),l=2;break;case 4:var d=e.slice(t,u).replace(/&#?\w+;/g,o);i.warning('attribute "'+d+'" missed quot(")!!'),a(c,d,t);case 5:l=6}else switch(l){case 2:n.tagName;r.isHTML(s[""])&&c.match(/^(?:disabled|checked|selected)$/i)||i.warning('attribute "'+c+'" missed value!! "'+c+'" instead2!!'),a(c,c,t),t=u,l=1;break;case 5:i.warning('attribute space is required"'+c+'"!!');case 6:l=1,t=u;break;case 3:l=4,t=u;break;case 7:throw new Error("elements closed character '/' and '>' must be connected to")}}u++}}function E(e,t,n){for(var s=e.tagName,o=null,i=e.length;i--;){var a=e[i],c=a.qName,u=a.value;if((h=c.indexOf(":"))>0)var l=a.prefix=c.slice(0,h),E=c.slice(h+1),d="xmlns"===l&&E;else E=c,l=null,d="xmlns"===c&&"";a.localName=E,!1!==d&&(null==o&&(o={},p(n,n={})),n[d]=o[d]=u,a.uri=r.XMLNS,t.startPrefixMapping(d,u))}for(i=e.length;i--;){(l=(a=e[i]).prefix)&&("xml"===l&&(a.uri=r.XML),"xmlns"!==l&&(a.uri=n[l||""]))}var h;(h=s.indexOf(":"))>0?(l=e.prefix=s.slice(0,h),E=e.localName=s.slice(h+1)):(l=null,E=e.localName=s);var S=e.uri=n[l||""];if(t.startElement(S,E,s,e),!e.closed)return e.currentNSMap=n,e.localNSMap=o,!0;if(t.endElement(S,E,s),o)for(l in o)t.endPrefixMapping(l)}function d(e,t,n,r,s){if(/^(?:script|textarea)$/i.test(n)){var o=e.indexOf("</"+n+">",t),i=e.substring(t+1,o);if(/[&<]/.test(i))return/^script$/i.test(n)?(s.characters(i,0,i.length),o):(i=i.replace(/&#?\w+;/g,r),s.characters(i,0,i.length),o)}return t+1}function h(e,t,n,r){var s=r[n];return null==s&&((s=e.lastIndexOf("</"+n+">"))<t&&(s=e.lastIndexOf("</"+n)),r[n]=s),s<t}function p(e,t){for(var n in e)t[n]=e[n]}function S(e,t,n,r){if("-"===e.charAt(t+2))return"-"===e.charAt(t+3)?(s=e.indexOf("--\x3e",t+4))>t?(n.comment(e,t+4,s-t-4),s+3):(r.error("Unclosed comment"),-1):-1;if("CDATA["==e.substr(t+3,6)){var s=e.indexOf("]]>",t+9);return n.startCDATA(),n.characters(e,t+9,s-t-9),n.endCDATA(),s+3}var o=function(e,t){var n,r=[],s=/'[^']+'|"[^"]+"|[^\s<>\/=]+=?|(\/?\s*>|<)/g;s.lastIndex=t,s.exec(e);for(;n=s.exec(e);)if(r.push(n),n[1])return r}(e,t),i=o.length;if(i>1&&/!doctype/i.test(o[0][0])){var a=o[1][0],c=!1,u=!1;i>3&&(/^public$/i.test(o[2][0])?(c=o[3][0],u=i>4&&o[4][0]):/^system$/i.test(o[2][0])&&(u=o[3][0]));var l=o[i-1];return n.startDTD(a,c,u),n.endDTD(),l.index+l[0].length}return-1}function g(e,t,n){var r=e.indexOf("?>",t);if(r){var s=e.substring(t,r).match(/^<\?(\S*)\s*([\s\S]*?)\s*$/);if(s){s[0].length;return n.processingInstruction(s[1],s[2]),r+2}return-1}return-1}function C(){this.attributeNames={}}a.prototype=new Error,a.prototype.name=a.name,c.prototype={parse:function(e,t,n){var s=this.domBuilder;s.startDocument(),p(t,t={}),function(e,t,n,s,o){function i(e){if(e>65535){var t=55296+((e-=65536)>>10),n=56320+(1023&e);return String.fromCharCode(t,n)}return String.fromCharCode(e)}function c(e){var t=e.slice(1,-1);return t in n?n[t]:"#"===t.charAt(0)?i(parseInt(t.substr(1).replace("x","0x"))):(o.error("entity not found:"+e),e)}function p(t){if(t>N){var n=e.substring(N,t).replace(/&#?\w+;/g,c);A&&_(N),s.characters(n,0,t-N),N=t}}function _(t,n){for(;t>=T&&(n=m.exec(e));)f=n.index,T=f+n[0].length,A.lineNumber++;A.columnNumber=t-f+1}var f=0,T=0,m=/.*(?:\r\n?|\n)|.*$/g,A=s.locator,I=[{currentNSMap:t}],R={},N=0;for(;;){try{var O=e.indexOf("<",N);if(O<0){if(!e.substr(N).match(/^\s*$/)){var y=s.doc,P=y.createTextNode(e.substr(N));y.appendChild(P),s.currentElement=P}return}switch(O>N&&p(O),e.charAt(O+1)){case"/":var M=e.indexOf(">",O+3),v=e.substring(O+2,M).replace(/[ \t\n\r]+$/g,""),L=I.pop();M<0?(v=e.substring(O+2).replace(/[\s<].*/,""),o.error("end tag name: "+v+" is not complete:"+L.tagName),M=O+1+v.length):v.match(/\s</)&&(v=v.replace(/[\s<].*/,""),o.error("end tag name: "+v+" maybe not complete"),M=O+1+v.length);var D=L.localNSMap,U=L.tagName==v;if(U||L.tagName&&L.tagName.toLowerCase()==v.toLowerCase()){if(s.endElement(L.uri,L.localName,v),D)for(var w in D)s.endPrefixMapping(w);U||o.fatalError("end tag name: "+v+" is not match the current start tagName:"+L.tagName)}else I.push(L);M++;break;case"?":A&&_(O),M=g(e,O,s);break;case"!":A&&_(O),M=S(e,O,s,o);break;default:A&&_(O);var b=new C,G=I[I.length-1].currentNSMap,Y=(M=l(e,O,b,G,c,o),b.length);if(!b.closed&&h(e,M,b.tagName,R)&&(b.closed=!0,n.nbsp||o.warning("unclosed xml attribute")),A&&Y){for(var x=u(A,{}),F=0;F<Y;F++){var B=b[F];_(B.offset),B.locator=u(A,{})}s.locator=x,E(b,s,G)&&I.push(b),s.locator=A}else E(b,s,G)&&I.push(b);r.isHTML(b.uri)&&!b.closed?M=d(e,M,b.tagName,c,s):M++}}catch(e){if(e instanceof a)throw e;o.error("element parse error: "+e),M=-1}M>N?N=M:p(Math.max(O,N)+1)}}(e,t,n,s,this.errorHandler),s.endDocument()}},C.prototype={setTagName:function(e){if(!i.test(e))throw new Error("invalid tagName:"+e);this.tagName=e},addValue:function(e,t,n){if(!i.test(e))throw new Error("invalid attribute:"+e);this.attributeNames[e]=this.length,this[this.length++]={qName:e,value:t,offset:n}},length:0,getLocalName:function(e){return this[e].localName},getLocator:function(e){return this[e].locator},getQName:function(e){return this[e].qName},getURI:function(e){return this[e].uri},getValue:function(e){return this[e].value}},t.XMLReader=c,t.ParseError=a}])}));