// Copyright (c) 2025 shibedrill
// SPDX-License-Identifier: MIT

use crate::format;
use crate::log::LogLevel;
use crate::memory::alloc::string::String;

pub static LOG_DEFAULT_LEVEL: LogLevel = LogLevel::Info;

pub static KERNEL_BUILD_PROFILE: &str = {
    if cfg!(debug_assertions) {
        "debug"
    } else {
        "release"
    }
};

pub static KERNEL_ARCH: &str = {
    if cfg!(target_arch = "x86_64") {
        "x86_64"
    } else if cfg!(target_arch = "aarch64") {
        "aarch64"
    } else if cfg!(target_arch = "loongarch64") {
        "loongarch64"
    } else if cfg!(target_arch = "riscv64") {
        "riscv64"
    } else {
        "unsupported"
    }
};

pub fn kernel_version_string() -> String {
    format!(
        "{KERNEL_VERSION_MAJOR}.{KERNEL_VERSION_MINOR}.{KERNEL_VERSION_PATCH}-{KERNEL_ARCH}-{KERNEL_BUILD_PROFILE}"
    )
}

pub static ASCII_LOGO: [&str; 6] = [
    "         _ __     ",
    "  ____ _(_) /___ _",
    " / __ `/ / / __ `/",
    "/ /_/ / / / /_/ / ",
    "\\__, /_/_/\\__,_/  ",
    "/___/             ",
];

// FUCKING ADD CONST UNWRAP!!!
pub static KERNEL_VERSION_MAJOR: u8 = match u8::from_str_radix(env!("CARGO_PKG_VERSION_MAJOR"), 10)
{
    Ok(ver) => ver,
    Err(_) => {
        panic!("Invalid major version number ")
    }
};
pub static KERNEL_VERSION_MINOR: u8 = match u8::from_str_radix(env!("CARGO_PKG_VERSION_MINOR"), 10)
{
    Ok(ver) => ver,
    Err(_) => {
        panic!("Invalid minor version number ")
    }
};
pub static KERNEL_VERSION_PATCH: u8 = match u8::from_str_radix(env!("CARGO_PKG_VERSION_PATCH"), 10)
{
    Ok(ver) => ver,
    Err(_) => {
        panic!("Invalid patch version number ")
    }
};
