/// Événements du BLoC Messaging
library messaging_event;

import 'package:equatable/equatable.dart';
import '../../domain/entities/message.dart';

abstract class MessagingEvent extends Equatable {
  const MessagingEvent();

  @override
  List<Object?> get props => [];
}

/// Charger les conversations
class LoadConversations extends MessagingEvent {
  final String? organizationId;
  final bool includeArchived;

  const LoadConversations({
    this.organizationId,
    this.includeArchived = false,
  });

  @override
  List<Object?> get props => [organizationId, includeArchived];
}

/// Charger les messages d'une conversation
class LoadMessages extends MessagingEvent {
  final String conversationId;
  final int? limit;
  final String? beforeMessageId;

  const LoadMessages({
    required this.conversationId,
    this.limit,
    this.beforeMessageId,
  });

  @override
  List<Object?> get props => [conversationId, limit, beforeMessageId];
}

/// Envoyer un message
class SendMessageEvent extends MessagingEvent {
  final String conversationId;
  final String content;
  final List<String>? attachments;
  final MessagePriority priority;

  const SendMessageEvent({
    required this.conversationId,
    required this.content,
    this.attachments,
    this.priority = MessagePriority.normal,
  });

  @override
  List<Object?> get props => [conversationId, content, attachments, priority];
}

/// Envoyer un broadcast
class SendBroadcastEvent extends MessagingEvent {
  final String organizationId;
  final String subject;
  final String content;
  final MessagePriority priority;
  final List<String>? attachments;

  const SendBroadcastEvent({
    required this.organizationId,
    required this.subject,
    required this.content,
    this.priority = MessagePriority.normal,
    this.attachments,
  });

  @override
  List<Object?> get props => [organizationId, subject, content, priority, attachments];
}

/// Marquer un message comme lu
class MarkMessageAsReadEvent extends MessagingEvent {
  final String messageId;

  const MarkMessageAsReadEvent(this.messageId);

  @override
  List<Object?> get props => [messageId];
}

/// Charger le nombre de messages non lus
class LoadUnreadCount extends MessagingEvent {
  final String? organizationId;

  const LoadUnreadCount({this.organizationId});

  @override
  List<Object?> get props => [organizationId];
}

/// Créer une nouvelle conversation
class CreateConversationEvent extends MessagingEvent {
  final String name;
  final List<String> participantIds;
  final String? organizationId;
  final String? description;

  const CreateConversationEvent({
    required this.name,
    required this.participantIds,
    this.organizationId,
    this.description,
  });

  @override
  List<Object?> get props => [name, participantIds, organizationId, description];
}
