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

import kotlinx.serialization.SerialName
import kotlinx.serialization.Serializable

/**
 * The three canonical units the whole system computes on. Polish vocabulary
 * like `"łyżka"`, `"puszka"`, `"szczypta"` is NOT a unit — it lives in
 * [Quantity.displayHint] as render-only metadata while the math runs on this
 * fixed enum.
 */
@Serializable
public enum class MeasurementUnit {
    @SerialName("gram")
    GRAM,

    @SerialName("milliliter")
    MILLILITER,

    @SerialName("piece")
    PIECE,
}

/**
 * Canonical [amount] in a fixed [unit], with an optional human-readable
 * [displayHint] for UI rendering.
 *
 * The hint lets a recipe say "2 łyżki oleju" (stored as
 * `Quantity(30.0, MILLILITER, {"pl": "2 łyżki"})`) and still aggregate cleanly
 * with another row's `100ml` because both are millilitres internally. Catalog
 * ingest is responsible for choosing the canonical amount; the domain model
 * just stores the result.
 */
@Serializable
public data class Quantity(
    public val amount: Double,
    public val unit: MeasurementUnit,
    public val displayHint: LocalizedString? = null,
)
