// lib/pages/device_managment/garage_door/bloc/event.dart

import 'package:equatable/equatable.dart';
import 'package:flutter/material.dart';
import 'package:syncrow_web/pages/device_managment/all_devices/models/factory_reset_model.dart';
import 'package:syncrow_web/pages/device_managment/garage_door/models/garage_door_model.dart';

abstract class GarageDoorEvent extends Equatable {
  const GarageDoorEvent();

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

class GarageDoorInitialEvent extends GarageDoorEvent {
  final String deviceId;

  const GarageDoorInitialEvent(this.deviceId);

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

class GarageDoorControlEvent extends GarageDoorEvent {
  final String deviceId;
  final dynamic value;
  final String code;

  const GarageDoorControlEvent(
      {required this.deviceId, required this.value, required this.code});

  @override
  List<Object?> get props => [deviceId, value];
}

class AddGarageDoorScheduleEvent extends GarageDoorEvent {
  final String category;
  final TimeOfDay time;
  final bool functionOn;
  final List<bool> selectedDays;

  const AddGarageDoorScheduleEvent({
    required this.category,
    required this.time,
    required this.functionOn,
    required this.selectedDays,
  });
}

class EditGarageDoorScheduleEvent extends GarageDoorEvent {
  final String scheduleId;
  final String category;
  final TimeOfDay time;
  final bool functionOn;
  final List<bool> selectedDays;

  const EditGarageDoorScheduleEvent({
    required this.scheduleId,
    required this.category,
    required this.time,
    required this.functionOn,
    required this.selectedDays,
  });
}

class UpdateGarageDoorScheduleEvent extends GarageDoorEvent {
  final String deviceId;
  final String scheduleId;
  final bool enable;
  final bool functionOn;
  final int index;

  const UpdateGarageDoorScheduleEvent({
    required this.deviceId,
    required this.scheduleId,
    required this.enable,
    required this.functionOn,
    required this.index,
  });
}

class DeleteGarageDoorScheduleEvent extends GarageDoorEvent {
  final String deviceId;
  final String scheduleId;
  final int index;

  const DeleteGarageDoorScheduleEvent({
    required this.deviceId,
    required this.scheduleId,
    required this.index,
  });
}

class FetchGarageDoorSchedulesEvent extends GarageDoorEvent {
  final String deviceId;
  final String category;

  const FetchGarageDoorSchedulesEvent({
    required this.deviceId,
    required this.category,
  });
}

class IncreaseGarageDoorDelayEvent extends GarageDoorEvent {
  final String deviceId;

  const IncreaseGarageDoorDelayEvent({required this.deviceId});

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

class DecreaseGarageDoorDelayEvent extends GarageDoorEvent {
  final String deviceId;

  const DecreaseGarageDoorDelayEvent({required this.deviceId});

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

class FetchGarageDoorRecordsEvent extends GarageDoorEvent {
  final String deviceId;
  final String code;

  const FetchGarageDoorRecordsEvent(
      {required this.deviceId, required this.code});

  @override
  List<Object?> get props => [deviceId, code];
}

class BackToGarageDoorGridViewEvent extends GarageDoorEvent {}

class GarageDoorUpdatedEvent extends GarageDoorEvent {}

class UpdateSelectedTimeEvent extends GarageDoorEvent {
  final TimeOfDay? selectedTime;

  const UpdateSelectedTimeEvent(this.selectedTime);

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

class UpdateSelectedDayEvent extends GarageDoorEvent {
  final int dayIndex;
  final bool isSelected;

  const UpdateSelectedDayEvent(this.dayIndex, this.isSelected);

  @override
  List<Object?> get props => [dayIndex, isSelected];
}

class UpdateFunctionOnEvent extends GarageDoorEvent {
  final bool functionOn;

  const UpdateFunctionOnEvent({required this.functionOn});

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

class InitializeAddScheduleEvent extends GarageDoorEvent {
  final TimeOfDay? selectedTime;
  final List<bool> selectedDays;
  final bool functionOn;
  final bool isEditing;
  final int? index;

  const InitializeAddScheduleEvent({
    required this.selectedTime,
    required this.selectedDays,
    required this.functionOn,
    required this.isEditing,
    this.index,
  });

  @override
  List<Object?> get props => [
        selectedTime,
        selectedDays,
        functionOn,
        isEditing,
        index,
      ];
}

class UpdateCountdownAlarmEvent extends GarageDoorEvent {
  final int countdownAlarm;

  const UpdateCountdownAlarmEvent(this.countdownAlarm);
}

class UpdateTrTimeConEvent extends GarageDoorEvent {
  final int trTimeCon;

  const UpdateTrTimeConEvent(this.trTimeCon);
}

class GarageDoorBatchControlEvent extends GarageDoorEvent {
  final List<String> deviceIds;
  final String code;
  final bool value;

  const GarageDoorBatchControlEvent({
    required this.deviceIds,
    required this.code,
    required this.value,
  });

  @override
  List<Object?> get props => [deviceIds, code, value];
}

class GarageDoorFetchBatchStatusEvent extends GarageDoorEvent {
  final List<String> deviceIds;

  const GarageDoorFetchBatchStatusEvent(this.deviceIds);

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

class GarageDoorFactoryResetEvent extends GarageDoorEvent {
  final FactoryResetModel factoryReset;
  final String deviceId;

  const GarageDoorFactoryResetEvent({
    required this.factoryReset,
    required this.deviceId,
  });

  @override
  List<Object?> get props => [factoryReset, deviceId];
}

class StatusUpdated extends GarageDoorEvent {
  final GarageDoorStatusModel deviceStatus;
  const StatusUpdated(this.deviceStatus);
  @override
  List<Object> get props => [deviceStatus];
}
