import 'package:equatable/equatable.dart';
import '../../models/expense.dart';
import 'dart:io';

abstract class ExpenseEvent extends Equatable {
  const ExpenseEvent();

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

class LoadExpensesByGroup extends ExpenseEvent {
  final String groupId;

  const LoadExpensesByGroup(this.groupId);

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

class CreateExpense extends ExpenseEvent {
  final Expense expense;
  final File? receiptImage;

  const CreateExpense({
    required this.expense,
    this.receiptImage,
  });

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

class UpdateExpense extends ExpenseEvent {
  final Expense expense;
  final File? newReceiptImage;

  const UpdateExpense({
    required this.expense,
    this.newReceiptImage,
  });

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

class DeleteExpense extends ExpenseEvent {
  final String expenseId;

  const DeleteExpense(this.expenseId);

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

class MarkSplitAsPaid extends ExpenseEvent {
  final String expenseId;
  final String userId;

  const MarkSplitAsPaid({
    required this.expenseId,
    required this.userId,
  });

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

class ArchiveExpense extends ExpenseEvent {
  final String expenseId;

  const ArchiveExpense(this.expenseId);

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

// Événement privé pour les mises à jour du stream
class ExpensesUpdated extends ExpenseEvent {
  final List<Expense> expenses;
  final String? error;

  const ExpensesUpdated(this.expenses, {this.error});

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