import 'package:equatable/equatable.dart';
import 'package:syncrow_web/pages/space_tree/model/pagination_model.dart';
import 'package:syncrow_web/pages/spaces_management/all_spaces/model/community_model.dart';

class SpaceTreeState extends Equatable {
  final Map<String, List<String>> selectedCommunityAndSpaces;
  final List<CommunityModel> communityList;
  final List<CommunityModel> filteredCommunity;
  final List<String> expandedCommunities;
  final List<String> expandedSpaces;
  final List<String> selectedCommunities;
  final List<String> selectedSpaces;
  final List<String> soldCheck;
  final bool isSearching;
  final String searchQuery;
  final PaginationModel paginationModel;
  final bool paginationIsLoading;

  const SpaceTreeState(
      {this.communityList = const [],
      this.filteredCommunity = const [],
      this.expandedCommunities = const [],
      this.expandedSpaces = const [],
      this.selectedCommunities = const [],
      this.selectedSpaces = const [],
      this.soldCheck = const [],
      this.isSearching = false,
      this.selectedCommunityAndSpaces = const {},
      this.searchQuery = '',
      this.paginationModel = const PaginationModel.emptyConstructor(),
      this.paginationIsLoading = false});

  SpaceTreeState copyWith(
      {List<CommunityModel>? communitiesList,
      List<CommunityModel>? filteredCommunity,
      List<String>? expandedSpaces,
      List<String>? expandedCommunity,
      List<String>? selectedCommunities,
      List<String>? selectedSpaces,
      List<String>? soldCheck,
      bool? isSearching,
      Map<String, List<String>>? selectedCommunityAndSpaces,
      String? searchQuery,
      PaginationModel? paginationModel,
      bool? paginationIsLoading}) {
    return SpaceTreeState(
        communityList: communitiesList ?? this.communityList,
        filteredCommunity: filteredCommunity ?? this.filteredCommunity,
        expandedSpaces: expandedSpaces ?? this.expandedSpaces,
        expandedCommunities: expandedCommunity ?? this.expandedCommunities,
        selectedCommunities: selectedCommunities ?? this.selectedCommunities,
        selectedSpaces: selectedSpaces ?? this.selectedSpaces,
        soldCheck: soldCheck ?? this.soldCheck,
        isSearching: isSearching ?? this.isSearching,
        selectedCommunityAndSpaces: selectedCommunityAndSpaces ?? this.selectedCommunityAndSpaces,
        searchQuery: searchQuery ?? this.searchQuery,
        paginationModel: paginationModel ?? this.paginationModel,
        paginationIsLoading: paginationIsLoading ?? this.paginationIsLoading);
  }

  @override
  List<Object?> get props => [
        communityList,
        filteredCommunity,
        expandedSpaces,
        expandedCommunities,
        selectedCommunities,
        selectedSpaces,
        soldCheck,
        isSearching,
        selectedCommunityAndSpaces,
        searchQuery,
        paginationModel,
        paginationIsLoading
      ];
}

class SpaceTreeLoadingState extends SpaceTreeState {}

class SpaceTreeErrorState extends SpaceTreeState {
  final String message;
  const SpaceTreeErrorState(this.message);

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