package dev.ulfrx.recipe.ui.screens.mealplaneditor

import androidx.compose.foundation.layout.Arrangement
import androidx.compose.foundation.layout.FlowRow
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.runtime.Composable
import androidx.compose.ui.Modifier
import dev.ulfrx.recipe.ui.components.chips.MealSlotChip
import dev.ulfrx.recipe.ui.components.recipe.MealSlot
import dev.ulfrx.recipe.ui.theme.RecipeTheme
import org.jetbrains.compose.resources.stringResource

/**
 * Renders every meal slot as a chip; slots outside [allowedSlots] are visible
 * but disabled (recipe-specific availability signal). Selection is single-pick.
 */
@Composable
internal fun MealSlotChipsRow(
    allSlots: List<MealSlot>,
    allowedSlots: List<MealSlot>,
    selectedSlot: MealSlot,
    onSelectSlot: (MealSlot) -> Unit,
    modifier: Modifier = Modifier,
) {
    FlowRow(
        modifier = modifier.fillMaxWidth(),
        horizontalArrangement = Arrangement.spacedBy(RecipeTheme.spacing.sm),
        verticalArrangement = Arrangement.spacedBy(RecipeTheme.spacing.sm),
    ) {
        allSlots.forEach { slot ->
            val enabled = slot in allowedSlots
            MealSlotChip(
                label = stringResource(slot.labelRes),
                selected = slot == selectedSlot,
                enabled = enabled,
                onClick = { onSelectSlot(slot) },
            )
        }
    }
}
