/*
 * Book's Story — free and open-source Material You eBook reader.
 * Copyright (C) 2024-2026 Acclorite
 * SPDX-License-Identifier: GPL-3.0-only
 */

package org.dueattendant149.bookshelf.ui.theme

import androidx.compose.material3.ColorScheme
import androidx.compose.runtime.Composable
import org.dueattendant149.bookshelf.ui.theme.color.aquaTheme
import org.dueattendant149.bookshelf.ui.theme.color.blackTheme
import org.dueattendant149.bookshelf.ui.theme.color.blueTheme
import org.dueattendant149.bookshelf.ui.theme.color.dynamicTheme
import org.dueattendant149.bookshelf.ui.theme.color.grayTheme
import org.dueattendant149.bookshelf.ui.theme.color.green2Theme
import org.dueattendant149.bookshelf.ui.theme.color.greenGrayTheme
import org.dueattendant149.bookshelf.ui.theme.color.greenTheme
import org.dueattendant149.bookshelf.ui.theme.color.lavenderTheme
import org.dueattendant149.bookshelf.ui.theme.color.marshTheme
import org.dueattendant149.bookshelf.ui.theme.color.pink2Theme
import org.dueattendant149.bookshelf.ui.theme.color.pinkTheme
import org.dueattendant149.bookshelf.ui.theme.color.purpleGrayTheme
import org.dueattendant149.bookshelf.ui.theme.color.purpleTheme
import org.dueattendant149.bookshelf.ui.theme.color.redGrayTheme
import org.dueattendant149.bookshelf.ui.theme.color.redTheme
import org.dueattendant149.bookshelf.ui.theme.color.yellow2Theme
import org.dueattendant149.bookshelf.ui.theme.color.yellowTheme
import org.dueattendant149.bookshelf.ui.theme.model.Theme
import org.dueattendant149.bookshelf.ui.theme.model.ThemeContrast


@Composable
fun colorScheme(
    theme: Theme,
    darkTheme: Boolean,
    isPureDark: Boolean,
    themeContrast: ThemeContrast
): ColorScheme {
    val colorScheme = when (theme) {
        Theme.DYNAMIC -> {
            /* Dynamic Theme */
            dynamicTheme(isDark = darkTheme)
        }

        Theme.BLUE -> {
            /* Blue Theme */
            blueTheme(isDark = darkTheme, themeContrast = themeContrast)
        }

        Theme.PURPLE -> {
            /* Purple Theme */
            purpleTheme(isDark = darkTheme, themeContrast = themeContrast)
        }

        Theme.PURPLE_GRAY -> {
            /* Purple Gray Theme */
            purpleGrayTheme(isDark = darkTheme)
        }

        Theme.GREEN -> {
            /* Green Theme */
            greenTheme(isDark = darkTheme, themeContrast = themeContrast)
        }

        Theme.GREEN2 -> {
            /* Green2 Theme */
            green2Theme(isDark = darkTheme)
        }

        Theme.GREEN_GRAY -> {
            /* Green Gray Theme */
            greenGrayTheme(isDark = darkTheme)
        }

        Theme.MARSH -> {
            /* Marsh Theme */
            marshTheme(isDark = darkTheme, themeContrast = themeContrast)
        }

        Theme.PINK -> {
            /* Pink Theme */
            pinkTheme(isDark = darkTheme, themeContrast = themeContrast)
        }

        Theme.PINK2 -> {
            /* Pink2 Theme */
            pink2Theme(isDark = darkTheme)
        }

        Theme.LAVENDER -> {
            /* Lavender Theme */
            lavenderTheme(isDark = darkTheme, themeContrast = themeContrast)
        }

        Theme.YELLOW -> {
            /* Yellow Theme */
            yellowTheme(isDark = darkTheme, themeContrast = themeContrast)
        }

        Theme.YELLOW2 -> {
            /* Yellow2 Theme */
            yellow2Theme(isDark = darkTheme)
        }

        Theme.RED -> {
            /* Red Theme */
            redTheme(isDark = darkTheme, themeContrast = themeContrast)
        }

        Theme.RED_GRAY -> {
            /* Red Gray Theme */
            redGrayTheme(isDark = darkTheme)
        }

        Theme.AQUA -> {
            /* Aqua Theme */
            aquaTheme(isDark = darkTheme, themeContrast = themeContrast)
        }

        Theme.GRAY -> {
            /* Gray Theme */
            grayTheme(isDark = darkTheme)
        }
    }

    return if (isPureDark && darkTheme) {
        blackTheme(initialTheme = colorScheme)
    } else {
        colorScheme
    }
}