package cy.hexor.furumi.domain.model

data class OfflineSettings(
    val offlineModeEnabled: Boolean = false,
    val saveListenedTracksEnabled: Boolean = false,
    val storageLimitBytes: Long = DEFAULT_STORAGE_LIMIT_BYTES
) {
    companion object {
        const val DEFAULT_STORAGE_LIMIT_BYTES: Long = 2L * 1024L * 1024L * 1024L
    }
}

data class OfflineState(
    val settings: OfflineSettings = OfflineSettings(),
    val isUsingNetworkFallback: Boolean = false,
    val isSyncing: Boolean = false,
    val lastSyncedAtMs: Long = 0L,
    val storageUsedBytes: Long = 0L,
    val cachedTrackCount: Int = 0,
    val lastError: String? = null
) {
    val isOfflineActive: Boolean
        get() = settings.offlineModeEnabled || isUsingNetworkFallback
}

data class OfflineSyncSummary(
    val trackCount: Int,
    val playlistCount: Int,
    val syncedAtMs: Long
)
