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

class InspectionTopologyState extends Equatable {
  final bool isLoading;
  final String? error;
  final String deviceName;
  final String deviceModel;
  final List<TopologyNode> topologyNodes;
  final int deviceCount;
  final int connectionCount;
  final TopologyNode? selectedNode;

  const InspectionTopologyState({
    this.isLoading = false,
    this.error,
    this.deviceName = '',
    this.deviceModel = '',
    this.topologyNodes = const [],
    this.deviceCount = 0,
    this.connectionCount = 0,
    this.selectedNode,
  });

  InspectionTopologyState copyWith({
    bool? isLoading,
    String? error,
    String? deviceName,
    String? deviceModel,
    List<TopologyNode>? topologyNodes,
    int? deviceCount,
    int? connectionCount,
    TopologyNode? selectedNode,
  }) {
    return InspectionTopologyState(
      isLoading: isLoading ?? this.isLoading,
      error: error,
      deviceName: deviceName ?? this.deviceName,
      deviceModel: deviceModel ?? this.deviceModel,
      topologyNodes: topologyNodes ?? this.topologyNodes,
      deviceCount: deviceCount ?? this.deviceCount,
      connectionCount: connectionCount ?? this.connectionCount,
      selectedNode: selectedNode,
    );
  }

  @override
  List<Object?> get props => [
        isLoading,
        error,
        deviceName,
        deviceModel,
        topologyNodes,
        deviceCount,
        connectionCount,
        selectedNode,
      ];
}

class TopologyNode extends Equatable {
  final String id;
  final String name;
  final String status;
  final List<TopologyNode> children;
  final double x;
  final double y;

  const TopologyNode({
    required this.id,
    required this.name,
    required this.status,
    required this.children,
    required this.x,
    required this.y,
  });

  @override
  List<Object?> get props => [id, name, status, children, x, y];
}