package dev.ulfrx.recipe.shared.domain.model

import kotlinx.serialization.Serializable

/**
 * One stock row for an ingredient — optionally pinned to a specific [Product].
 *
 * The mockup's hybrid `Number-or-{total, items[]}` storage collapses to
 * multiple flat rows: one with `productId == null` for generic stock, plus a
 * row per tracked product. Aggregating "how much of X do I have?" is a sum
 * across the rows sharing an [ingredientId].
 */
@Serializable
public data class PantryItem(
    public val id: PantryItemId,
    public val sync: SyncMeta,
    public val ingredientId: IngredientId,
    public val productId: ProductId? = null,
    public val quantity: Quantity,
)

/**
 * A named shopping list (most households use the default "Kitchen" list;
 * additional lists are user-created). [ordinal] orders multiple lists in the
 * UI. [name] is plain `String` — user-supplied free text, not catalog-localized.
 */
@Serializable
public data class ShoppingList(
    public val id: ShoppingListId,
    public val sync: SyncMeta,
    public val name: String,
    public val ordinal: Int,
)

/**
 * One line on a shopping list. [productId] pins a specific brand when present.
 * [checked] tracks "bought" state; checking + later sync into pantry happens at
 * the repository layer. [sourceNote] is a free-text provenance hint ("From
 * plan", "Ze spiżarni"); the v1 UI surfaces it but doesn't filter on it.
 */
@Serializable
public data class ShoppingItem(
    public val id: ShoppingItemId,
    public val sync: SyncMeta,
    public val listId: ShoppingListId,
    public val ingredientId: IngredientId,
    public val productId: ProductId? = null,
    public val quantity: Quantity,
    public val checked: Boolean = false,
    public val sourceNote: String? = null,
    public val ordinal: Int,
)
