use axum::{
    body::Body,
    http::header,
    response::{Html, IntoResponse},
};

pub async fn index() -> impl IntoResponse {
    (
        [(header::CACHE_CONTROL, "no-store")],
        Html(include_str!("../web/index.html")),
    )
}
pub async fn alpine() -> impl IntoResponse {
    (
        [(header::CONTENT_TYPE, "text/javascript; charset=utf-8")],
        include_str!("../web/alpine.min.js"),
    )
}
pub async fn dash() -> impl IntoResponse {
    javascript(include_str!("../web/dash.all.min.js"))
}
pub async fn dash_source_map() -> impl IntoResponse {
    (
        [(header::CONTENT_TYPE, "application/json; charset=utf-8")],
        r#"{"version":3,"sources":[],"names":[],"mappings":""}"#,
    )
}
pub async fn controlbar_javascript() -> impl IntoResponse {
    javascript(include_str!("../web/controlbar.min.js"))
}
pub async fn api_javascript() -> impl IntoResponse {
    javascript(include_str!("../web/js/api.js"))
}
pub async fn library_javascript() -> impl IntoResponse {
    javascript(include_str!("../web/js/library.js"))
}
pub async fn location_javascript() -> impl IntoResponse {
    javascript(include_str!("../web/js/location.js"))
}
pub async fn preferences_javascript() -> impl IntoResponse {
    javascript(include_str!("../web/js/preferences.js"))
}
pub async fn player_javascript() -> impl IntoResponse {
    javascript(include_str!("../web/js/player.js"))
}
fn javascript(source: &'static str) -> impl IntoResponse {
    (
        [
            (header::CONTENT_TYPE, "text/javascript; charset=utf-8"),
            (header::CACHE_CONTROL, "no-store"),
        ],
        source,
    )
}
pub async fn styles() -> impl IntoResponse {
    stylesheet(include_str!("../web/styles.css"))
}
pub async fn controlbar_styles() -> impl IntoResponse {
    stylesheet(include_str!("../web/vendor/controlbar/controlbar.css"))
}
pub async fn bootstrap_icon_styles() -> impl IntoResponse {
    stylesheet(include_str!(
        "../web/vendor/bootstrap-icons/bootstrap-icons.min.css"
    ))
}
pub async fn bootstrap_icon_font() -> impl IntoResponse {
    (
        [(header::CONTENT_TYPE, "font/woff2")],
        Body::from(
            include_bytes!("../web/vendor/bootstrap-icons/fonts/bootstrap-icons.woff2").as_slice(),
        ),
    )
}
fn stylesheet(source: &'static str) -> impl IntoResponse {
    (
        [
            (header::CONTENT_TYPE, "text/css; charset=utf-8"),
            (header::CACHE_CONTROL, "no-store"),
        ],
        source,
    )
}
