import 'package:equatable/equatable.dart';

import '../../../domain/entities/wall_config.dart';

abstract class WallEvent extends Equatable {
  const WallEvent();

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

/// Load wall configuration
class LoadWallConfig extends WallEvent {
  final WallConfig? config;

  const LoadWallConfig([this.config]);

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

/// Select a viewer by tapping on it
class SelectViewer extends WallEvent {
  final int viewerId;

  const SelectViewer(this.viewerId);

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

/// Deselect current viewer
class DeselectViewer extends WallEvent {
  const DeselectViewer();
}

/// Update camera prefix for input
class SetCameraPrefix extends WallEvent {
  final int prefix; // 500, 501, 502

  const SetCameraPrefix(this.prefix);

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

/// Add digit to camera number input
class AddCameraDigit extends WallEvent {
  final int digit;

  const AddCameraDigit(this.digit);

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

/// Remove last digit from camera input (Backspace)
class BackspaceCameraDigit extends WallEvent {
  const BackspaceCameraDigit();
}

/// Cancel camera edit (Escape or timeout)
class CancelCameraEdit extends WallEvent {
  const CancelCameraEdit();
}

/// Cycle to next camera prefix (Prefix key)
class CycleCameraPrefix extends WallEvent {
  const CycleCameraPrefix();
}

/// Execute CrossSwitch with current camera input
class ExecuteCrossSwitch extends WallEvent {
  const ExecuteCrossSwitch();
}

/// Update viewer state (from WebSocket events)
class UpdateViewerCamera extends WallEvent {
  final int viewerId;
  final int cameraId;
  final bool isLive;

  const UpdateViewerCamera({
    required this.viewerId,
    required this.cameraId,
    this.isLive = true,
  });

  @override
  List<Object?> get props => [viewerId, cameraId, isLive];
}

/// Set alarm state on a viewer
class SetViewerAlarm extends WallEvent {
  final int viewerId;
  final bool hasAlarm;

  const SetViewerAlarm({
    required this.viewerId,
    required this.hasAlarm,
  });

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

/// Set lock state on a viewer's camera
class SetViewerLock extends WallEvent {
  final int viewerId;
  final bool isLocked;
  final String? lockedBy;

  const SetViewerLock({
    required this.viewerId,
    required this.isLocked,
    this.lockedBy,
  });

  @override
  List<Object?> get props => [viewerId, isLocked, lockedBy];
}

/// Toggle expanded section
class ToggleSectionExpanded extends WallEvent {
  final String sectionId;

  const ToggleSectionExpanded(this.sectionId);

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