part of 'chart_bloc.dart';

final class ChartState extends Equatable {
  final Map<String, Category> categories;
  final List<Transaction> transactions;
  final List<TransactionLine> transactionsLines;

  final double globalTotal;
  final Map<String, double> accountsTotals;

  final DateTime? firstDate;
  final DateTime? lastDate;

  final num currentYear;

  final Map<String, double> categoriesTotals;
  final List<FlSpot> monthlyTotals;
  final Map<String, Map<String, double>> categoriesMonthlyTotals;

  final List<ChartItem> scopedCategoriesPositiveTotals;
  final List<ChartItem> scopedCategoriesPositiveTotalsPercents;
  final List<ChartItem> scopedCategoriesNegativeTotals;
  final List<ChartItem> scopedCategoriesNegativeTotalsPercents;

  final List<ChartItem> scopedSimplifiedCategoriesPositiveTotals;
  final List<ChartItem> scopedSimplifiedCategoriesPositiveTotalsPercents;
  final List<ChartItem> scopedSimplifiedCategoriesNegativeTotals;
  final List<ChartItem> scopedSimplifiedCategoriesNegativeTotalsPercents;

  final List<FlSpot> scopedMonthlyTotals;
  final Map<int, MonthTotals> scopedCategoriesMonthlyTotals;
  final Map<int, double> scopedMonthlyPostitiveTotals;
  final Map<int, double> scopedMonthlyNegativeTotals;

  final double scoppedProfit;

  const ChartState({
    this.categories = const {},
    this.transactions = const [],
    this.transactionsLines = const [],
    this.globalTotal = 0,
    this.accountsTotals = const {},
    this.firstDate,
    this.lastDate,
    this.currentYear = 2000,
    this.categoriesTotals = const {},
    this.monthlyTotals = const [],
    this.categoriesMonthlyTotals = const {},
    this.scopedCategoriesPositiveTotals = const [],
    this.scopedCategoriesPositiveTotalsPercents = const [],
    this.scopedCategoriesNegativeTotals = const [],
    this.scopedCategoriesNegativeTotalsPercents = const [],
    this.scopedSimplifiedCategoriesPositiveTotals = const [],
    this.scopedSimplifiedCategoriesPositiveTotalsPercents = const [],
    this.scopedSimplifiedCategoriesNegativeTotals = const [],
    this.scopedSimplifiedCategoriesNegativeTotalsPercents = const [],
    this.scopedMonthlyTotals = const [],
    this.scopedCategoriesMonthlyTotals = const {},
    this.scoppedProfit = 0,
    this.scopedMonthlyPostitiveTotals = const {},
    this.scopedMonthlyNegativeTotals = const {},
  });

  ChartState copyWith({
    Map<String, Category>? categories,
    List<Transaction>? transactions,
    List<TransactionLine>? transactionsLines,
    double? globalTotal,
    Map<String, double>? accountsTotals,
    DateTime? firstDate,
    DateTime? lastDate,
    num? currentYear,
    Map<String, double>? categoriesTotals,
    List<FlSpot>? monthlyTotals,
    Map<String, Map<String, double>>? categoriesMonthlyTotals,
    List<ChartItem>? scopedCategoriesPositiveTotals,
    List<ChartItem>? scopedCategoriesPositiveTotalsPercents,
    List<ChartItem>? scopedCategoriesNegativeTotals,
    List<ChartItem>? scopedCategoriesNegativeTotalsPercents,
    List<ChartItem>? scopedSimplifiedCategoriesPositiveTotals,
    List<ChartItem>? scopedSimplifiedCategoriesPositiveTotalsPercents,
    List<ChartItem>? scopedSimplifiedCategoriesNegativeTotals,
    List<ChartItem>? scopedSimplifiedCategoriesNegativeTotalsPercents,
    List<FlSpot>? scopedMonthlyTotals,
    Map<int, MonthTotals>? scopedCategoriesMonthlyTotals,
    double? scoppedProfit,
    Map<int, double>? scopedMonthlyPostitiveTotals,
    Map<int, double>? scopedMonthlyNegativeTotals,
  }) {
    return ChartState(
      categories: categories ?? this.categories,
      transactions: transactions ?? this.transactions,
      transactionsLines: transactionsLines ?? this.transactionsLines,
      globalTotal: globalTotal ?? this.globalTotal,
      accountsTotals: accountsTotals ?? this.accountsTotals,
      firstDate: firstDate ?? this.firstDate,
      lastDate: lastDate ?? this.lastDate,
      currentYear: currentYear ?? this.currentYear,
      categoriesTotals: categoriesTotals ?? this.categoriesTotals,
      monthlyTotals: monthlyTotals ?? this.monthlyTotals,
      categoriesMonthlyTotals: categoriesMonthlyTotals ?? this.categoriesMonthlyTotals,
      scopedCategoriesPositiveTotals: scopedCategoriesPositiveTotals ?? this.scopedCategoriesPositiveTotals,
      scopedCategoriesPositiveTotalsPercents: scopedCategoriesPositiveTotalsPercents ?? this.scopedCategoriesPositiveTotalsPercents,
      scopedCategoriesNegativeTotals: scopedCategoriesNegativeTotals ?? this.scopedCategoriesNegativeTotals,
      scopedCategoriesNegativeTotalsPercents: scopedCategoriesNegativeTotalsPercents ?? this.scopedCategoriesNegativeTotalsPercents,
      scopedSimplifiedCategoriesPositiveTotals: scopedSimplifiedCategoriesPositiveTotals ?? this.scopedSimplifiedCategoriesPositiveTotals,
      scopedSimplifiedCategoriesPositiveTotalsPercents: scopedSimplifiedCategoriesPositiveTotalsPercents ?? this.scopedSimplifiedCategoriesPositiveTotalsPercents,
      scopedSimplifiedCategoriesNegativeTotals: scopedSimplifiedCategoriesNegativeTotals ?? this.scopedSimplifiedCategoriesNegativeTotals,
      scopedSimplifiedCategoriesNegativeTotalsPercents: scopedSimplifiedCategoriesNegativeTotalsPercents ?? this.scopedSimplifiedCategoriesNegativeTotalsPercents,
      scopedMonthlyTotals: scopedMonthlyTotals ?? this.scopedMonthlyTotals,
      scopedCategoriesMonthlyTotals: scopedCategoriesMonthlyTotals ?? this.scopedCategoriesMonthlyTotals,
      scoppedProfit: scoppedProfit ?? this.scoppedProfit,
      scopedMonthlyPostitiveTotals: scopedMonthlyPostitiveTotals ?? this.scopedMonthlyPostitiveTotals,
      scopedMonthlyNegativeTotals: scopedMonthlyNegativeTotals ?? this.scopedMonthlyNegativeTotals,
    );
  }
  
  @override
  List<Object> get props => [
    categories,
    transactions,
    transactionsLines,
    globalTotal,
    accountsTotals,
    currentYear,
    categoriesTotals,
    monthlyTotals,
    categoriesMonthlyTotals,
    scopedCategoriesPositiveTotals,
    scopedCategoriesPositiveTotalsPercents,
    scopedCategoriesNegativeTotals,
    scopedCategoriesNegativeTotalsPercents,
    scopedSimplifiedCategoriesPositiveTotals,
    scopedSimplifiedCategoriesPositiveTotalsPercents,
    scopedSimplifiedCategoriesNegativeTotals,
    scopedSimplifiedCategoriesNegativeTotalsPercents,
    scopedMonthlyTotals,
    scopedCategoriesMonthlyTotals,
    scoppedProfit,
    scopedMonthlyPostitiveTotals,
    scopedMonthlyNegativeTotals,
  ];
}

