/// A product image attached to a WooCommerce product.
class ProductImage {
  /// WooCommerce media attachment ID.
  final int id;

  /// Full URL of the image.
  final String url;

  /// Alt text for the image.
  final String alt;

  /// Display position (0 = featured/primary image).
  final int position;

  const ProductImage({
    required this.id,
    required this.url,
    required this.alt,
    required this.position,
  });

  /// Returns a copy of this [ProductImage] with the given fields replaced.
  ProductImage copyWith({int? id, String? url, String? alt, int? position}) {
    return ProductImage(
      id: id ?? this.id,
      url: url ?? this.url,
      alt: alt ?? this.alt,
      position: position ?? this.position,
    );
  }

  @override
  bool operator ==(Object other) =>
      identical(this, other) ||
      other is ProductImage &&
          runtimeType == other.runtimeType &&
          id == other.id &&
          url == other.url &&
          alt == other.alt &&
          position == other.position;

  @override
  int get hashCode => Object.hash(id, url, alt, position);

  @override
  String toString() => 'ProductImage(id: $id, url: $url, position: $position)';
}
