import { CometChat } from "@cometchat/chat-sdk-react-native";
import { MessageTypeConstants } from "../constants/UIKitConstants";
import { CometChatUIEventHandler } from "./CometChatUIEventHandler/CometChatUIEventHandler";
import { MessageEvents } from "./messages";
export class ListenerInitializer {
    static messageListenerId = `ListenerInitializer_listener`;
    static attachListeners() {
        CometChat.addMessageListener(this.messageListenerId, this.getMessageListenerObject());
    }
    static detachListeners() {
        CometChat.removeMessageListener(this.messageListenerId);
    }
    static getMessageListenerObject() {
        return new CometChat.MessageListener({
            onTextMessageReceived: (textMessage) => {
                CometChatUIEventHandler.emitMessageEvent(MessageEvents.onTextMessageReceived, textMessage);
            },
            onMediaMessageReceived: (mediaMessage) => {
                CometChatUIEventHandler.emitMessageEvent(MessageEvents.onMediaMessageReceived, mediaMessage);
            },
            onCustomMessageReceived: (customMessage) => {
                CometChatUIEventHandler.emitMessageEvent(MessageEvents.onCustomMessageReceived, customMessage);
            },
            onTypingStarted: (typingIndicator) => {
                CometChatUIEventHandler.emitMessageEvent(MessageEvents.onTypingStarted, typingIndicator);
            },
            onTypingEnded: (typingIndicator) => {
                CometChatUIEventHandler.emitMessageEvent(MessageEvents.onTypingEnded, typingIndicator);
            },
            onMessagesDelivered: (messageReceipt) => {
                CometChatUIEventHandler.emitMessageEvent(MessageEvents.onMessagesDelivered, messageReceipt);
            },
            onMessagesRead: (messageReceipt) => {
                CometChatUIEventHandler.emitMessageEvent(MessageEvents.onMessagesRead, messageReceipt);
            },
            onMessageEdited: (message) => {
                CometChatUIEventHandler.emitMessageEvent(MessageEvents.onMessageEdited, message);
            },
            onMessageDeleted: (message) => {
                CometChatUIEventHandler.emitMessageEvent(MessageEvents.onMessageDeleted, message);
            },
            onTransientMessageReceived: (message) => {
                CometChatUIEventHandler.emitMessageEvent(MessageEvents.onTransientMessageReceived, message);
            },
            onInteractiveMessageReceived: (message) => {
                switch (message.getType()) {
                    case MessageTypeConstants.form:
                        CometChatUIEventHandler.emitMessageEvent(MessageEvents.onFormMessageReceived, message);
                        break;
                    case MessageTypeConstants.card:
                        CometChatUIEventHandler.emitMessageEvent(MessageEvents.onCardMessageReceived, message);
                        break;
                    case MessageTypeConstants.scheduler:
                        CometChatUIEventHandler.emitMessageEvent(MessageEvents.onSchedulerMessageReceived, message);
                        break;
                    default:
                        CometChatUIEventHandler.emitMessageEvent(MessageEvents.onCustomInteractiveMessageReceived, message);
                        break;
                }
            },
            onInteractionGoalCompleted: (reciept) => {
                CometChatUIEventHandler.emitMessageEvent(MessageEvents.onInteractionGoalCompleted, reciept);
            },
            onMessageReactionAdded: (message) => {
                CometChatUIEventHandler.emitMessageEvent(MessageEvents.onMessageReactionAdded, message);
            },
            onMessageReactionRemoved: (message) => {
                CometChatUIEventHandler.emitMessageEvent(MessageEvents.onMessageReactionRemoved, message);
            }
        });
    }
}
//# sourceMappingURL=ListenerInitializer.js.map