import type { ServingUnit, ProductCategory } from '../enums/product.enums.js';
import type { ShoppingListStatus, ShoppingListSourceType } from '../enums/shopping-list.enums.js';

/**
 * Captures a targeted purchasable item within a shopping checklist
 */
export interface ShoppingItem {
  id: string; // Random reference token for live sync transactions
  productId?: string; // Reference to general inventory product
  customName?: string; // Arbitrary string label for custom ad-hoc additions
  quantity: number;
  unit: ServingUnit;
  checked: boolean;
  checkedAt?: Date;
  checkedBy?: string;
  estimatedPrice?: number; // Guessed via historical lookup
  actualPrice?: number; // Final value input by active shopper
  storeId?: string; // Local target retail outlet
  notes?: string;
  category?: ProductCategory; // Logical aisle group
  addedToPantry: boolean; // Tracking bit for pantry inventory migrations
}

/**
 * Encodes generating origins for auto-lists
 */
export interface ShoppingListSource {
  type: ShoppingListSourceType;
  referenceId?: string; // ID pointing to generating instance (e.g. MealPlan ID)
}

/**
 * Structured grocery list managing household inventory provisioning
 */
export interface ShoppingList {
  id: string;
  householdId: string;
  name: string;
  items: ShoppingItem[];
  status: ShoppingListStatus;
  createdFrom?: ShoppingListSource;
  mealPlanId?: string; // Explicit quick reference pointer if derived from plan
  totalEstimatedCost?: number; // Summed pre-checkout estimates
  preferredStoreId?: string;
  completedAt?: Date;
  createdBy: string;
  createdAt: Date;
  updatedAt: Date;
}
