import 'package:equatable/equatable.dart';

abstract class Annotation extends Equatable {
  final String id;
  final int pageIndex;

  const Annotation({required this.id, required this.pageIndex});

  @override
  List<Object?> get props => [id, pageIndex];

  Map<String, dynamic> toJson();
}

class TextAnnotation extends Annotation {
  final String text;
  final double x;
  final double y;
  final double width;
  final double height;

  const TextAnnotation({
    required super.id,
    required super.pageIndex,
    required this.text,
    required this.x,
    required this.y,
    required this.width,
    required this.height,
  });

  @override
  List<Object?> get props => super.props + [text, x, y, width, height];

  @override
  Map<String, dynamic> toJson() {
    return {
      'type': 'text',
      'id': id,
      'pageIndex': pageIndex,
      'text': text,
      'x': x,
      'y': y,
      'width': width,
      'height': height,
    };
  }
}

class HighlightAnnotation extends Annotation {
  final List<double> points; // List of x,y coordinates

  const HighlightAnnotation({
    required super.id,
    required super.pageIndex,
    required this.points,
  });

  @override
  List<Object?> get props => super.props + [points];

  @override
  Map<String, dynamic> toJson() {
    return {
      'type': 'highlight',
      'id': id,
      'pageIndex': pageIndex,
      'points': points,
    };
  }
}

class SignatureAnnotation extends Annotation {
  final String imagePath; // or bytes, but for simplicity
  final double x;
  final double y;
  final double width;
  final double height;

  const SignatureAnnotation({
    required super.id,
    required super.pageIndex,
    required this.imagePath,
    required this.x,
    required this.y,
    required this.width,
    required this.height,
  });

  @override
  List<Object?> get props => super.props + [imagePath, x, y, width, height];

  @override
  Map<String, dynamic> toJson() {
    return {
      'type': 'signature',
      'id': id,
      'pageIndex': pageIndex,
      'imagePath': imagePath,
      'x': x,
      'y': y,
      'width': width,
      'height': height,
    };
  }
}
