class AdminAiCategorizeResult {
  final int productId;
  final String productName;
  final int categoryId;
  final String categoryPath;
  final String confidence;
  final bool usedFallback;

  const AdminAiCategorizeResult({
    required this.productId,
    required this.productName,
    required this.categoryId,
    required this.categoryPath,
    required this.confidence,
    required this.usedFallback,
  });

  factory AdminAiCategorizeResult.fromJson(Map<String, dynamic> json) {
    final suggestion = (json['suggestion'] as Map<String, dynamic>? ?? const {});
    return AdminAiCategorizeResult(
      productId: (json['productId'] as num?)?.toInt() ?? 0,
      productName: (json['productName'] ?? '').toString(),
      categoryId: (suggestion['categoryId'] as num?)?.toInt() ?? 0,
      categoryPath: (suggestion['path'] ?? '').toString(),
      confidence: (suggestion['confidence'] ?? '').toString(),
      usedFallback: suggestion['usedFallback'] == true,
    );
  }
}