package com.fabledsword.minstrel.player

import com.fabledsword.minstrel.models.TrackRef

/**
 * Cycle on the repeat button: off → all → one → off. Mirrors
 * `AudioServiceRepeatMode` in flutter_client and maps directly to
 * the three Media3 `Player.REPEAT_MODE_*` int constants.
 */
enum class RepeatMode { OFF, ALL, ONE }

/**
 * Snapshot of what the player is doing, for the UI to read via
 * [PlayerController.uiState]. Replaces the audio_service-style
 * `PlaybackState + MediaItem` split — Media3 has those internally;
 * this is the projection we hand to ViewModels.
 */
data class PlayerUiState(
    val currentTrack: TrackRef? = null,
    val queue: List<TrackRef> = emptyList(),
    val queueIndex: Int = -1,
    val isPlaying: Boolean = false,
    val isBuffering: Boolean = false,
    val positionMs: Long = 0,
    val durationMs: Long = 0,
    val bufferedPositionMs: Long = 0,
    val playbackError: String? = null,
    val currentSource: String? = null,
    val shuffleEnabled: Boolean = false,
    val repeatMode: RepeatMode = RepeatMode.OFF,
    /** True while the UPnP initial-batch load is in progress (target set, active not yet wired). */
    val isUpnpLoading: Boolean = false,
)
