import 'package:equatable/equatable.dart';
import 'package:flutter/material.dart';

enum RoomStatus {
  vacant,
  occupied,
  reserved,
  warning,
  temperature,
}

class RoomDeviceStatus {
  final bool hasPerson;
  final bool powerOn;
  final bool wifiNormal;
  final bool acOn;
  final String acTemperature;
  final bool lightOn;
  final bool tvOn;
  final bool curtainOn;

  const RoomDeviceStatus({
    this.hasPerson = true,
    this.powerOn = true,
    this.wifiNormal = true,
    this.acOn = false,
    this.acTemperature = '24',
    this.lightOn = false,
    this.tvOn = false,
    this.curtainOn = false,
  });

  RoomDeviceStatus copyWith({
    bool? hasPerson,
    bool? powerOn,
    bool? wifiNormal,
    bool? acOn,
    String? acTemperature,
    bool? lightOn,
    bool? tvOn,
    bool? curtainOn,
  }) {
    return RoomDeviceStatus(
      hasPerson: hasPerson ?? this.hasPerson,
      powerOn: powerOn ?? this.powerOn,
      wifiNormal: wifiNormal ?? this.wifiNormal,
      acOn: acOn ?? this.acOn,
      acTemperature: acTemperature ?? this.acTemperature,
      lightOn: lightOn ?? this.lightOn,
      tvOn: tvOn ?? this.tvOn,
      curtainOn: curtainOn ?? this.curtainOn,
    );
  }
}

class RoomInfo {
  final String roomNumber;
  final RoomStatus status;
  final String statusText;
  final RoomDeviceStatus deviceStatus;

  const RoomInfo({
    required this.roomNumber,
    required this.status,
    required this.statusText,
    this.deviceStatus = const RoomDeviceStatus(),
  });

  RoomInfo copyWith({
    String? roomNumber,
    RoomStatus? status,
    String? statusText,
    RoomDeviceStatus? deviceStatus,
  }) {
    return RoomInfo(
      roomNumber: roomNumber ?? this.roomNumber,
      status: status ?? this.status,
      statusText: statusText ?? this.statusText,
      deviceStatus: deviceStatus ?? this.deviceStatus,
    );
  }
}

class FloorInfo {
  final String floorName;
  final List<RoomInfo> rooms;

  const FloorInfo({
    required this.floorName,
    required this.rooms,
  });

  FloorInfo copyWith({
    String? floorName,
    List<RoomInfo>? rooms,
  }) {
    return FloorInfo(
      floorName: floorName ?? this.floorName,
      rooms: rooms ?? this.rooms,
    );
  }
}

class StatusStat {
  final String label;
  final int count;
  final Color color;

  const StatusStat({
    required this.label,
    required this.count,
    required this.color,
  });
}

class RoomReportState extends Equatable {
  final List<FloorInfo> floors;
  final int selectedFloorIndex;
  final List<StatusStat> statusStats;
  final List<RoomInfo> detailRooms;

  const RoomReportState({
    this.floors = const [],
    this.selectedFloorIndex = 2,
    this.statusStats = const [],
    this.detailRooms = const [],
  });

  RoomReportState copyWith({
    List<FloorInfo>? floors,
    int? selectedFloorIndex,
    List<StatusStat>? statusStats,
    List<RoomInfo>? detailRooms,
  }) {
    return RoomReportState(
      floors: floors ?? this.floors,
      selectedFloorIndex: selectedFloorIndex ?? this.selectedFloorIndex,
      statusStats: statusStats ?? this.statusStats,
      detailRooms: detailRooms ?? this.detailRooms,
    );
  }

  @override
  List<Object?> get props => [
        floors,
        selectedFloorIndex,
        statusStats,
        detailRooms,
      ];
}