"use strict";

import { useCallback } from 'react';
export const useEventHandlers = config => {
  const handleMessageSent = useCallback(async event => {
    try {
      if (config?.eventHandlers?.onMessageSent) {
        await config.eventHandlers.onMessageSent(event);
      }
    } catch (error) {
      console.error('Error in message sent handler:', error);
      throw error;
    }
  }, [config]);
  const handleMessageFailed = useCallback(event => {
    try {
      if (config?.eventHandlers?.onMessageFailed) {
        config.eventHandlers.onMessageFailed(event);
      }
      console.error('Message failed details:', {
        message: event.message,
        roomJID: event.roomJID,
        messageType: event.messageType,
        error: event.error?.message,
        timestamp: new Date().toISOString()
      });
    } catch (handlerError) {
      console.error('Error in message failed handler:', handlerError);
    }
  }, [config]);
  const handleMessageEdited = useCallback(event => {
    try {
      if (config?.eventHandlers?.onMessageEdited) {
        config.eventHandlers.onMessageEdited(event);
      }
    } catch (error) {
      console.error('Error in message edited handler:', error);
    }
  }, [config]);
  return {
    handleMessageSent,
    handleMessageFailed,
    handleMessageEdited
  };
};
//# sourceMappingURL=useEventHandlers.js.map