use std::env;

fn use_ubuntu_page_navigation_defaults() -> bool {
    if !cfg!(target_os = "linux") {
        return false;
    }
    [
        "XDG_CURRENT_DESKTOP",
        "XDG_SESSION_DESKTOP",
        "DESKTOP_SESSION",
    ]
    .iter()
    .filter_map(|key| env::var(key).ok())
    .any(|value| {
        let value = value.to_lowercase();
        value.contains("ubuntu") || value.contains("gnome")
    })
}

pub(crate) fn default_toggle_whiteboard() -> Vec<String> {
    vec!["Ctrl+W".to_string()]
}

pub(crate) fn default_toggle_blackboard() -> Vec<String> {
    vec!["Ctrl+B".to_string()]
}

pub(crate) fn default_return_to_transparent() -> Vec<String> {
    vec!["Ctrl+Shift+T".to_string()]
}

pub(crate) fn default_page_prev() -> Vec<String> {
    if use_ubuntu_page_navigation_defaults() {
        vec!["Ctrl+ArrowLeft".to_string(), "Ctrl+PageUp".to_string()]
    } else {
        vec![
            "Ctrl+Alt+ArrowLeft".to_string(),
            "Ctrl+Alt+PageUp".to_string(),
        ]
    }
}

pub(crate) fn default_page_next() -> Vec<String> {
    if use_ubuntu_page_navigation_defaults() {
        vec!["Ctrl+ArrowRight".to_string(), "Ctrl+PageDown".to_string()]
    } else {
        vec![
            "Ctrl+Alt+ArrowRight".to_string(),
            "Ctrl+Alt+PageDown".to_string(),
        ]
    }
}

pub(crate) fn default_page_new() -> Vec<String> {
    vec!["Ctrl+Alt+N".to_string()]
}

pub(crate) fn default_page_duplicate() -> Vec<String> {
    vec!["Ctrl+Alt+D".to_string()]
}

pub(crate) fn default_page_delete() -> Vec<String> {
    vec!["Ctrl+Alt+Delete".to_string()]
}

pub(crate) fn default_board_1() -> Vec<String> {
    vec!["Ctrl+Shift+1".to_string()]
}

pub(crate) fn default_board_2() -> Vec<String> {
    vec!["Ctrl+Shift+2".to_string()]
}

pub(crate) fn default_board_3() -> Vec<String> {
    vec!["Ctrl+Shift+3".to_string()]
}

pub(crate) fn default_board_4() -> Vec<String> {
    vec!["Ctrl+Shift+4".to_string()]
}

pub(crate) fn default_board_5() -> Vec<String> {
    vec!["Ctrl+Shift+5".to_string()]
}

pub(crate) fn default_board_6() -> Vec<String> {
    vec!["Ctrl+Shift+6".to_string()]
}

pub(crate) fn default_board_7() -> Vec<String> {
    vec!["Ctrl+Shift+7".to_string()]
}

pub(crate) fn default_board_8() -> Vec<String> {
    vec!["Ctrl+Shift+8".to_string()]
}

pub(crate) fn default_board_9() -> Vec<String> {
    vec!["Ctrl+Shift+9".to_string()]
}

pub(crate) fn default_board_next() -> Vec<String> {
    vec!["Ctrl+Shift+ArrowRight".to_string()]
}

pub(crate) fn default_board_prev() -> Vec<String> {
    vec!["Ctrl+Shift+ArrowLeft".to_string()]
}

pub(crate) fn default_board_new() -> Vec<String> {
    vec!["Ctrl+Shift+N".to_string()]
}

pub(crate) fn default_board_duplicate() -> Vec<String> {
    vec!["Ctrl+Shift+D".to_string()]
}

pub(crate) fn default_board_delete() -> Vec<String> {
    vec!["Ctrl+Shift+Delete".to_string()]
}

pub(crate) fn default_board_picker() -> Vec<String> {
    vec!["Ctrl+Shift+B".to_string()]
}
