class Photo {
  final String id;
  final String tripId;
  final String authorParticipantId;
  final String contentUri;
  final String displayName;
  final String mimeType;
  final int sizeBytes;
  final int? dateTakenUtc;
  final int? dateAddedUtc;
  final double? latitude;
  final double? longitude;
  final double? altitude;
  final int? width;
  final int? height;
  final int? orientation;
  final String? cameraMake;
  final String? cameraModel;
  final String? relativePath;
  final String? ownerPackageName;
  final String? sha256;
  final String? perceptualHash;
  final bool isLocalOriginal;
  final String sourceDeviceId;
  final String importState;
  final String shareState;

  Photo({
    required this.id,
    required this.tripId,
    required this.authorParticipantId,
    required this.contentUri,
    required this.displayName,
    required this.mimeType,
    required this.sizeBytes,
    this.dateTakenUtc,
    this.dateAddedUtc,
    this.latitude,
    this.longitude,
    this.altitude,
    this.width,
    this.height,
    this.orientation,
    this.cameraMake,
    this.cameraModel,
    this.relativePath,
    this.ownerPackageName,
    this.sha256,
    this.perceptualHash,
    required this.isLocalOriginal,
    required this.sourceDeviceId,
    required this.importState,
    required this.shareState,
  });

  Map<String, dynamic> toMap() {
    return {
      'id': id,
      'tripId': tripId,
      'authorParticipantId': authorParticipantId,
      'contentUri': contentUri,
      'displayName': displayName,
      'mimeType': mimeType,
      'sizeBytes': sizeBytes,
      'dateTakenUtc': dateTakenUtc,
      'dateAddedUtc': dateAddedUtc,
      'latitude': latitude,
      'longitude': longitude,
      'altitude': altitude,
      'width': width,
      'height': height,
      'orientation': orientation,
      'cameraMake': cameraMake,
      'cameraModel': cameraModel,
      'relativePath': relativePath,
      'ownerPackageName': ownerPackageName,
      'sha256': sha256,
      'perceptualHash': perceptualHash,
      'isLocalOriginal': isLocalOriginal ? 1 : 0,
      'sourceDeviceId': sourceDeviceId,
      'importState': importState,
      'shareState': shareState,
    };
  }

  factory Photo.fromMap(Map<String, dynamic> map) {
    return Photo(
      id: map['id'] as String,
      tripId: map['tripId'] as String,
      authorParticipantId: map['authorParticipantId'] as String,
      contentUri: map['contentUri'] as String,
      displayName: map['displayName'] as String,
      mimeType: map['mimeType'] as String,
      sizeBytes: map['sizeBytes'] as int,
      dateTakenUtc: map['dateTakenUtc'] as int?,
      dateAddedUtc: map['dateAddedUtc'] as int?,
      latitude: map['latitude'] as double?,
      longitude: map['longitude'] as double?,
      altitude: map['altitude'] as double?,
      width: map['width'] as int?,
      height: map['height'] as int?,
      orientation: map['orientation'] as int?,
      cameraMake: map['cameraMake'] as String?,
      cameraModel: map['cameraModel'] as String?,
      relativePath: map['relativePath'] as String?,
      ownerPackageName: map['ownerPackageName'] as String?,
      sha256: map['sha256'] as String?,
      perceptualHash: map['perceptualHash'] as String?,
      isLocalOriginal: (map['isLocalOriginal'] as int) == 1,
      sourceDeviceId: map['sourceDeviceId'] as String,
      importState: map['importState'] as String,
      shareState: map['shareState'] as String,
    );
  }
}
