import 'package:equatable/equatable.dart';
import 'package:krow_domain/krow_domain.dart';
import 'package:geolocator/geolocator.dart';


enum ClockInStatus { initial, loading, success, failure, actionInProgress }

class ClockInState extends Equatable {
  final ClockInStatus status;
  final Shift? todayShift;
  final AttendanceStatus attendance;
  final List<Map<String, dynamic>> activityLog;
  final DateTime selectedDate;
  final String checkInMode;
  final String? errorMessage;

  final Position? currentLocation;
  final double? distanceFromVenue;
  final bool isLocationVerified;
  final bool isCommuteModeOn;
  final bool hasLocationConsent;
  final int? etaMinutes;

  const ClockInState({
    this.status = ClockInStatus.initial,
    this.todayShift,
    this.attendance = const AttendanceStatus(),
    this.activityLog = const [],
    required this.selectedDate,
    this.checkInMode = 'swipe',
    this.errorMessage,
    this.currentLocation,
    this.distanceFromVenue,
    this.isLocationVerified = false,
    this.isCommuteModeOn = false,
    this.hasLocationConsent = false,
    this.etaMinutes,
  });

  ClockInState copyWith({
    ClockInStatus? status,
    Shift? todayShift,
    AttendanceStatus? attendance,
    List<Map<String, dynamic>>? activityLog,
    DateTime? selectedDate,
    String? checkInMode,
    String? errorMessage,
    Position? currentLocation,
    double? distanceFromVenue,
    bool? isLocationVerified,
    bool? isCommuteModeOn,
    bool? hasLocationConsent,
    int? etaMinutes,
  }) {
    return ClockInState(
      status: status ?? this.status,
      todayShift: todayShift ?? this.todayShift,
      attendance: attendance ?? this.attendance,
      activityLog: activityLog ?? this.activityLog,
      selectedDate: selectedDate ?? this.selectedDate,
      checkInMode: checkInMode ?? this.checkInMode,
      errorMessage: errorMessage,
      currentLocation: currentLocation ?? this.currentLocation,
      distanceFromVenue: distanceFromVenue ?? this.distanceFromVenue,
      isLocationVerified: isLocationVerified ?? this.isLocationVerified,
      isCommuteModeOn: isCommuteModeOn ?? this.isCommuteModeOn,
      hasLocationConsent: hasLocationConsent ?? this.hasLocationConsent,
      etaMinutes: etaMinutes ?? this.etaMinutes,
    );
  }

  @override
  List<Object?> get props => [
        status,
        todayShift,
        attendance,
        activityLog,
        selectedDate,
        checkInMode,
        errorMessage,
        currentLocation,
        distanceFromVenue,
        isLocationVerified,
        isCommuteModeOn,
        hasLocationConsent,
        etaMinutes,
      ];
}
