import 'dart:developer';

import 'package:mc_common_app/extensions/string_extensions.dart';
import 'package:mc_common_app/utils/enums.dart';

class VehicleDetailsModel {
  List<VehicleBrandsModel>? vehicleBrands;
  List<VehicleCategoryModel>? vehicleCategories;
  List<VehicleColorModel>? vehicleColors;
  List<VehicleConditionModel>? vehicleConditions;
  List<VehicleMileageModel>? vehicleMileages;
  List<VehicleModel>? vehicleModels;
  List<VehicleYearModel>? vehicleModelYears;
  List<VehiclePriceRangeModel>? vehiclePriceRanges;
  List<VehiclePricingMethodModel>? vehiclePricingMethods;
  List<VehicleSellerTypeModel>? vehicleSellerTypes;
  List<VehicleTransmissionModel>? vehicleTransmissions;
  List<VehicleCountryModel>? vehicleCountries;

  VehicleDetailsModel({
    this.vehicleBrands,
    this.vehicleCategories,
    this.vehicleColors,
    this.vehicleConditions,
    this.vehicleMileages,
    this.vehicleModels,
    this.vehicleModelYears,
    this.vehiclePriceRanges,
    this.vehiclePricingMethods,
    this.vehicleSellerTypes,
    this.vehicleTransmissions,
    this.vehicleCountries,
  });

  VehicleDetailsModel.fromJson(Map<String, dynamic> json) {
    vehicleBrands = List.generate((json['vehiclebrands']['data']).length, (index) => VehicleBrandsModel.fromJson(json['vehiclebrands']['data'][index]));
    vehicleCategories = List.generate((json['vehiclecategories']['data']).length, (index) => VehicleCategoryModel.fromJson(json['vehiclecategories']['data'][index]));
    vehicleColors = List.generate((json['vehiclecolors']['data']).length, (index) => VehicleColorModel.fromJson(json['vehiclecolors']['data'][index]));
    vehicleConditions = List.generate((json['vehicleconditions']['data']).length, (index) => VehicleConditionModel.fromJson(json['vehicleconditions']['data'][index]));
    vehicleMileages = List.generate((json['vehiclemileages']['data']).length, (index) => VehicleMileageModel.fromJson(json['vehiclemileages']['data'][index]));
    vehicleModels = List.generate((json['vehiclemodels']['data']).length, (index) => VehicleModel.fromJson(json['vehiclemodels']['data'][index]));
    vehicleModelYears = List.generate((json['vehiclemodelyears']['data']).length, (index) => VehicleYearModel.fromJson(json['vehiclemodelyears']['data'][index]));
    vehiclePriceRanges = List.generate((json['vehiclepriceranges']['data']).length, (index) => VehiclePriceRangeModel.fromJson(json['vehiclepriceranges']['data'][index]));
    vehiclePricingMethods = List.generate((json['vehiclepricingmethods']['data']).length, (index) => VehiclePricingMethodModel.fromJson(json['vehiclepricingmethods']['data'][index]));
    vehicleSellerTypes = List.generate((json['vehiclesellertypes']['data']).length, (index) => VehicleSellerTypeModel.fromJson(json['vehiclesellertypes']['data'][index]));
    vehicleTransmissions = List.generate((json['vehicletransmissions']['data']).length, (index) => VehicleTransmissionModel.fromJson(json['vehicletransmissions']['data'][index]));
    vehicleCountries = List.generate((json['countries']['data']).length, (index) => VehicleCountryModel.fromJson(json['countries']['data'][index]));
  }

  @override
  String toString() {
    return 'VehicleDetailsModel{vehicleBrands: $vehicleBrands, vehicleCategories: $vehicleCategories, vehicleColors: $vehicleColors, vehicleConditions: $vehicleConditions, vehicleMileages: $vehicleMileages, vehicleModels: $vehicleModels, vehicleModelYears: $vehicleModelYears, vehiclePriceRanges: $vehiclePriceRanges, vehiclePricingMethods: $vehiclePricingMethods, vehicleSellerTypes: $vehicleSellerTypes, vehicleTransmissions: $vehicleTransmissions, vehicleCountries: $vehicleCountries,}';
  }
}

class VehicleTypeModel {
  int? id;
  String? vehicleTypeName;
  String? vehicleTypeNameN;
  bool? isActive;
  VehicleType? vehicleTypeEnum;
  bool? isSelected;

  VehicleTypeModel({
    this.id,
    this.vehicleTypeName,
    this.vehicleTypeNameN,
    this.isActive,
    this.vehicleTypeEnum = VehicleType.car,
    this.isSelected,
  });

  VehicleTypeModel.fromJson(Map<String, dynamic> json) {
    id = json['id'];
    vehicleTypeName = json['vehicleTypeName'];
    vehicleTypeNameN = json['vehicleTypeNameN'];
    isActive = json['isActive'];
    vehicleTypeEnum = (json['id'] as int).toVehicleTypeEnum();
    isSelected = false;
  }

  Map<String, dynamic> toJson() {
    final Map<String, dynamic> data = <String, dynamic>{};
    data['id'] = id;
    data['vehicleTypeName'] = vehicleTypeName;
    data['vehicleTypeNameN'] = vehicleTypeNameN;
    data['isActive'] = isActive;
    return data;
  }

  @override
  String toString() {
    return 'VehicleTypeModel{id: $id, vehicleTypeName: $vehicleTypeName, vehicleTypeNameN: $vehicleTypeNameN, isActive: $isActive}';
  }
}

class VehicleModel {
  int? id;
  int? vehicleType;
  String? vehicleTypeVal;
  String? model;
  String? modelN;
  int? vehicleBrandID;
  bool? isActive;

  VehicleModel({this.id, this.vehicleType, this.vehicleTypeVal, this.model, this.modelN, this.vehicleBrandID, this.isActive});

  VehicleModel.fromJson(Map<String, dynamic> json) {
    id = json['id'];
    vehicleType = json['vehicleType'];
    vehicleTypeVal = json['vehicleTypeVal'];
    model = json['model'];
    modelN = json['modelN'];
    vehicleBrandID = json['vehicleBrandID'];
    isActive = json['isActive'];
  }

  Map<String, dynamic> toJson() {
    final Map<String, dynamic> data = <String, dynamic>{};
    data['id'] = id;
    data['vehicleType'] = vehicleType;
    data['vehicleTypeVal'] = vehicleTypeVal;
    data['model'] = model;
    data['modelN'] = modelN;
    data['vehicleBrandID'] = vehicleBrandID;
    data['isActive'] = isActive;
    return data;
  }
}

class VehicleYearModel {
  int? id;
  int? vehicleType;
  String? vehicleTypeVal;
  String? modelYear;
  bool? isActive;

  VehicleYearModel({this.id, this.vehicleType, this.vehicleTypeVal, this.modelYear, this.isActive});

  VehicleYearModel.fromJson(Map<String, dynamic> json) {
    id = json['id'];
    vehicleType = json['vehicleType'];
    vehicleTypeVal = json['vehicleTypeVal'];
    modelYear = json['modelYear'];
    isActive = json['isActive'];
  }

  Map<String, dynamic> toJson() {
    final Map<String, dynamic> data = <String, dynamic>{};
    data['id'] = id;
    data['vehicleType'] = vehicleType;
    data['vehicleTypeVal'] = vehicleTypeVal;
    data['modelYear'] = modelYear;
    data['isActive'] = isActive;
    return data;
  }
}

class VehicleColorModel {
  int? id;
  int? vehicleType;
  String? vehicleTypeVal;
  String? color;
  String? colorN;
  bool? isActive;

  VehicleColorModel({this.id, this.vehicleType, this.vehicleTypeVal, this.color, this.colorN, this.isActive});

  VehicleColorModel.fromJson(Map<String, dynamic> json) {
    id = json['id'];
    vehicleType = json['vehicleType'];
    vehicleTypeVal = json['vehicleTypeVal'];
    color = json['color'];
    colorN = json['colorN'];
    isActive = json['isActive'];
  }

  Map<String, dynamic> toJson() {
    final Map<String, dynamic> data = <String, dynamic>{};
    data['id'] = id;
    data['vehicleType'] = vehicleType;
    data['vehicleTypeVal'] = vehicleTypeVal;
    data['color'] = color;
    data['colorN'] = colorN;
    data['isActive'] = isActive;
    return data;
  }
}

class VehicleConditionModel {
  int? id;
  int? vehicleType;
  String? vehicleTypeVal;
  String? condition;
  String? conditionN;
  bool? isActive;

  VehicleConditionModel({this.id, this.vehicleType, this.vehicleTypeVal, this.condition, this.conditionN, this.isActive});

  VehicleConditionModel.fromJson(Map<String, dynamic> json) {
    id = json['id'];
    vehicleType = json['vehicleType'];
    vehicleTypeVal = json['vehicleTypeVal'];
    condition = json['condition'];
    conditionN = json['conditionN'];
    isActive = json['isActive'];
  }

  Map<String, dynamic> toJson() {
    final Map<String, dynamic> data = <String, dynamic>{};
    data['id'] = id;
    data['vehicleType'] = vehicleType;
    data['vehicleTypeVal'] = vehicleTypeVal;
    data['condition'] = condition;
    data['conditionN'] = conditionN;
    data['isActive'] = isActive;
    return data;
  }
}

class VehicleCategoryModel {
  int? id;
  int? vehicleType;
  String? vehicleTypeVal;
  String? category;
  String? categoryN;
  bool? isActive;

  VehicleCategoryModel({this.id, this.vehicleType, this.vehicleTypeVal, this.category, this.categoryN, this.isActive});

  VehicleCategoryModel.fromJson(Map<String, dynamic> json) {
    id = json['id'];
    vehicleType = json['vehicleType'];
    vehicleTypeVal = json['vehicleTypeVal'];
    category = json['category'];
    categoryN = json['categoryN'];
    isActive = json['isActive'];
  }

  Map<String, dynamic> toJson() {
    final Map<String, dynamic> data = <String, dynamic>{};
    data['id'] = id;
    data['vehicleType'] = vehicleType;
    data['vehicleTypeVal'] = vehicleTypeVal;
    data['category'] = category;
    data['categoryN'] = categoryN;
    data['isActive'] = isActive;
    return data;
  }
}

class VehicleMileageModel {
  int? id;
  int? vehicleType;
  String? vehicleTypeVal;
  String? mileageStart;
  String? mileageEnd;
  bool? isActive;

  VehicleMileageModel({this.id, this.vehicleType, this.vehicleTypeVal, this.mileageStart, this.mileageEnd, this.isActive});

  VehicleMileageModel.fromJson(Map<String, dynamic> json) {
    id = json['id'];
    vehicleType = json['vehicleType'];
    vehicleTypeVal = json['vehicleTypeVal'];
    mileageStart = json['mileageStart'];
    mileageEnd = json['mileageEnd'];
    isActive = json['isActive'];
  }

  Map<String, dynamic> toJson() {
    final Map<String, dynamic> data = <String, dynamic>{};
    data['id'] = id;
    data['vehicleType'] = vehicleType;
    data['vehicleTypeVal'] = vehicleTypeVal;
    data['mileageStart'] = mileageStart;
    data['mileageEnd'] = mileageEnd;
    data['isActive'] = isActive;
    return data;
  }
}

class VehicleTransmissionModel {
  int? id;
  String? transmission;
  String? transmissionN;
  int? vehicleType;
  String? vehicleTypeVal;
  bool? isActive;

  VehicleTransmissionModel({this.id, this.transmission, this.transmissionN, this.vehicleType, this.vehicleTypeVal, this.isActive});

  VehicleTransmissionModel.fromJson(Map<String, dynamic> json) {
    id = json['id'];
    transmission = json['transmission'];
    transmissionN = json['transmissionN'];
    vehicleType = json['vehicleType'];
    vehicleTypeVal = json['vehicleTypeVal'];
    isActive = json['isActive'];
  }

  Map<String, dynamic> toJson() {
    final Map<String, dynamic> data = <String, dynamic>{};
    data['id'] = id;
    data['transmission'] = transmission;
    data['transmissionN'] = transmissionN;
    data['vehicleType'] = vehicleType;
    data['vehicleTypeVal'] = vehicleTypeVal;
    data['isActive'] = isActive;
    return data;
  }
}

class VehicleSellerTypeModel {
  int? id;
  String? sellerType;
  String? sellerTypeN;
  int? vehicleType;
  String? vehicleTypeVal;
  bool? isActive;

  VehicleSellerTypeModel({this.id, this.sellerType, this.sellerTypeN, this.vehicleType, this.vehicleTypeVal, this.isActive});

  VehicleSellerTypeModel.fromJson(Map<String, dynamic> json) {
    id = json['id'];
    sellerType = json['sellerType'];
    sellerTypeN = json['sellerTypeN'];
    vehicleType = json['vehicleType'];
    vehicleTypeVal = json['vehicleTypeVal'];
    isActive = json['isActive'];
  }

  Map<String, dynamic> toJson() {
    final Map<String, dynamic> data = <String, dynamic>{};
    data['id'] = id;
    data['sellerType'] = sellerType;
    data['sellerTypeN'] = sellerTypeN;
    data['vehicleType'] = vehicleType;
    data['vehicleTypeVal'] = vehicleTypeVal;
    data['isActive'] = isActive;
    return data;
  }
}

class VehicleCountryModel {
  int? id;
  String? countryName;
  String? countryNameN;
  String? nationality;
  String? nationalityN;
  String? countryCode;
  String? alpha2Code;
  String? alpha3Code;
  String? currency;
  bool? isActive;

  VehicleCountryModel({this.id, this.countryName, this.countryNameN, this.nationality, this.nationalityN, this.countryCode, this.alpha2Code, this.alpha3Code, this.currency, this.isActive});

  VehicleCountryModel.fromJson(Map<String, dynamic> json) {
    id = json['id'];
    countryName = json['countryName'];
    countryNameN = json['countryNameN'];
    nationality = json['nationality'];
    nationalityN = json['nationalityN'];
    countryCode = json['countryCode'];
    alpha2Code = json['alpha2Code'];
    alpha3Code = json['alpha3Code'];
    currency = json['currency'];
    isActive = json['isActive'];
  }

  Map<String, dynamic> toJson() {
    final Map<String, dynamic> data = <String, dynamic>{};
    data['id'] = id;
    data['countryName'] = countryName;
    data['countryNameN'] = countryNameN;
    data['nationality'] = nationality;
    data['nationalityN'] = nationalityN;
    data['countryCode'] = countryCode;
    data['alpha2Code'] = alpha2Code;
    data['alpha3Code'] = alpha3Code;
    data['currency'] = currency;
    data['isActive'] = isActive;
    return data;
  }
}

class VehicleCityModel {
  int? id;
  String? cityName;
  String? cityNameN;
  int? countryID;
  bool? isActive;

  VehicleCityModel({this.id, this.cityName, this.cityNameN, this.countryID, this.isActive});

  VehicleCityModel.fromJson(Map<String, dynamic> json) {
    id = json['id'];
    cityName = json['cityName'];
    cityNameN = json['cityNameN'];
    countryID = json['countryID'];
    isActive = json['isActive'];
  }

  Map<String, dynamic> toJson() {
    final Map<String, dynamic> data = <String, dynamic>{};
    data['id'] = id;
    data['cityName'] = cityName;
    data['cityNameN'] = cityNameN;
    data['countryID'] = countryID;
    data['isActive'] = isActive;
    return data;
  }
}

class VehiclePartModel {
  int? id;
  int? partNo;
  String? partName;
  String? description;
  bool? isActive;
  bool? isSelected;
  bool? isChecked;

  VehiclePartModel({this.id, this.partNo, this.partName, this.description, this.isActive, this.isSelected});

  VehiclePartModel.fromJson(Map<String, dynamic> json) {
    id = json['id'];
    partNo = json['partNo'];
    partName = json['partName'];
    description = json['description'];
    isActive = json['isActive'];
    isSelected = false;
    isChecked = false;
  }

  Map<String, dynamic> toJson() {
    final Map<String, dynamic> data = <String, dynamic>{};
    data['id'] = id;
    data['partNo'] = partNo;
    data['partName'] = partName;
    data['description'] = description;
    data['isActive'] = isActive;
    return data;
  }
}

class VehicleBrandsModel {
  int? id;
  int? vehicleType;
  String? vehicleTypeVal;
  String? vehicleBrandDescription;
  String? vehicleBrandDescriptionN;
  bool? isActive;
  bool? isSelected;

  VehicleBrandsModel({this.id, this.vehicleType, this.vehicleTypeVal, this.vehicleBrandDescription, this.vehicleBrandDescriptionN, this.isActive, this.isSelected});

  VehicleBrandsModel.fromJson(Map<String, dynamic> json) {
    id = json['id'];
    vehicleType = json['vehicleType'];
    vehicleTypeVal = json['vehicleTypeVal'];
    vehicleBrandDescription = json['vehicleBrand_Description'];
    vehicleBrandDescriptionN = json['vehicleBrand_DescriptionN'];
    isActive = json['isActive'];
    isSelected = false;
  }

  Map<String, dynamic> toJson() {
    final Map<String, dynamic> data = <String, dynamic>{};
    data['id'] = id;
    data['vehicleType'] = vehicleType;
    data['vehicleTypeVal'] = vehicleTypeVal;
    data['vehicleBrand_Description'] = vehicleBrandDescription;
    data['vehicleBrand_DescriptionN'] = vehicleBrandDescriptionN;
    data['isActive'] = isActive;
    return data;
  }
}

class VehiclePriceRangeModel {
  int? id;
  String? priceRangeStart;
  String? priceRangeEnd;
  int? vehicleType;
  String? vehicleTypeVal;
  bool? isActive;

  VehiclePriceRangeModel({this.id, this.priceRangeStart, this.priceRangeEnd, this.vehicleType, this.vehicleTypeVal, this.isActive});

  VehiclePriceRangeModel.fromJson(Map<String, dynamic> json) {
    id = json['id'];
    priceRangeStart = json['priceRangeStart'];
    priceRangeEnd = json['priceRangeEnd'];
    vehicleType = json['vehicleType'];
    vehicleTypeVal = json['vehicleTypeVal'];
    isActive = json['isActive'];
  }

  Map<String, dynamic> toJson() {
    final Map<String, dynamic> data = <String, dynamic>{};
    data['id'] = id;
    data['priceRangeStart'] = priceRangeStart;
    data['priceRangeEnd'] = priceRangeEnd;
    data['vehicleType'] = vehicleType;
    data['vehicleTypeVal'] = vehicleTypeVal;
    data['isActive'] = isActive;
    return data;
  }
}

class VehiclePricingMethodModel {
  int? id;
  String? pricingMethod;
  String? pricingMethodN;
  int? vehicleType;
  String? vehicleTypeVal;
  bool? isActive;

  VehiclePricingMethodModel({this.id, this.pricingMethod, this.pricingMethodN, this.vehicleType, this.vehicleTypeVal, this.isActive});

  VehiclePricingMethodModel.fromJson(Map<String, dynamic> json) {
    id = json['id'];
    pricingMethod = json['pricingMethod'];
    pricingMethodN = json['pricingMethodN'];
    vehicleType = json['vehicleType'];
    vehicleTypeVal = json['vehicleTypeVal'];
    isActive = json['isActive'];
  }

  Map<String, dynamic> toJson() {
    final Map<String, dynamic> data = <String, dynamic>{};
    data['id'] = id;
    data['pricingMethod'] = pricingMethod;
    data['pricingMethodN'] = pricingMethodN;
    data['vehicleType'] = vehicleType;
    data['vehicleTypeVal'] = vehicleTypeVal;
    data['isActive'] = isActive;
    return data;
  }
}
