import 'package:equatable/equatable.dart';
import 'package:proxibuy/data/models/comment_model.dart'; // <-- این خط اضافه شد
import 'package:proxibuy/data/models/discount_info_model.dart';
import 'package:proxibuy/data/models/working_hours.dart';

class OfferModel extends Equatable {
  final String id;
  final String storeName;
  final String title;
  final String discount;
  final List<String> imageUrls;
  final String category;
  final int distanceInMeters;
  final DateTime expiryTime;
  final String address;
  final List<WorkingHours> workingHours;
  final String discountType;
  final bool isOpen;
  final double rating;
  final int ratingCount;
  final double latitude;
  final double longitude;
  final double originalPrice;
  final double finalPrice;
  final List<String> features;
  final DiscountInfoModel? discountInfo;
  final List<CommentModel> comments;
  final String qrCodeData; 

  const OfferModel({
    required this.id,
    required this.storeName,
    required this.title,
    required this.discount,
    required this.imageUrls,
    required this.category,
    required this.distanceInMeters,
    required this.expiryTime,
    required this.address,
    required this.workingHours,
    required this.discountType,
    required this.isOpen,
    required this.rating,
    required this.ratingCount,
    required this.latitude,
    required this.longitude,
    required this.originalPrice,
    required this.finalPrice,
    this.features = const [],
    this.discountInfo,
    this.comments = const [],
    required this.qrCodeData,
  });

  String get coverImageUrl =>
      imageUrls.isNotEmpty ? imageUrls.first : 'https://via.placeholder.com/400x200.png?text=No+Image';

  @override
  List<Object?> get props => [
        id,
        title,
        storeName,
        rating,
        ratingCount,
        latitude,
        longitude,
        features,
        discountInfo,
        comments,
        qrCodeData
      ];

  String get distanceAsString {
    if (distanceInMeters < 1000) {
      return "$distanceInMeters متر";
    } else {
      final distanceInKm = (distanceInMeters / 1000).toStringAsFixed(1);
      return "$distanceInKm کیلومتر";
    }
  }
}