import 'package:equatable/equatable.dart';

class CameraState extends Equatable {
  final int? selectedCameraId;
  final bool isConnecting;
  final String? error;
  final List<int> availableCameras;

  const CameraState({
    this.selectedCameraId,
    this.isConnecting = false,
    this.error,
    this.availableCameras = const [],
  });

  bool get hasSelection => selectedCameraId != null;

  CameraState copyWith({
    int? selectedCameraId,
    bool? isConnecting,
    String? error,
    List<int>? availableCameras,
    bool clearSelection = false,
  }) {
    return CameraState(
      selectedCameraId:
          clearSelection ? null : (selectedCameraId ?? this.selectedCameraId),
      isConnecting: isConnecting ?? this.isConnecting,
      error: error,
      availableCameras: availableCameras ?? this.availableCameras,
    );
  }

  @override
  List<Object?> get props =>
      [selectedCameraId, isConnecting, error, availableCameras];
}
