"""Genera el contenido de un manifest.json para Progressive Web Apps (W3C Web App Manifest)."""


def generate_pwa_manifest(
    name: str,
    short_name: str,
    description: str = "",
    start_url: str = "/",
    display: str = "standalone",
    orientation: str = "portrait",
    theme_color: str = "#000000",
    background_color: str = "#000000",
    icons: list[dict] | None = None,
    categories: list[str] | None = None,
    lang: str = "es",
) -> dict:
    """Genera el contenido de un manifest.json para Progressive Web Apps.

    Args:
        name: Nombre completo de la aplicacion.
        short_name: Nombre corto para launchers y pantallas de inicio.
        description: Descripcion de la aplicacion.
        start_url: URL de inicio de la PWA.
        display: Modo de visualizacion (standalone, fullscreen, minimal-ui, browser).
        orientation: Orientacion preferida (portrait, landscape, any).
        theme_color: Color del tema en hex.
        background_color: Color de fondo en hex.
        icons: Lista de iconos con src, sizes, type y purpose. Si es None, usa placeholders estandar.
        categories: Lista de categorias de la app. Si es None, usa lista vacia.
        lang: Idioma principal de la aplicacion (BCP 47).

    Returns:
        Dict listo para json.dumps() con la estructura estandar W3C Web App Manifest.
    """
    if icons is None:
        icons = [
            {
                "src": "/icons/icon-192x192.png",
                "sizes": "192x192",
                "type": "image/png",
                "purpose": "any maskable",
            },
            {
                "src": "/icons/icon-512x512.png",
                "sizes": "512x512",
                "type": "image/png",
                "purpose": "any maskable",
            },
        ]

    if categories is None:
        categories = []

    return {
        "name": name,
        "short_name": short_name,
        "description": description,
        "start_url": start_url,
        "scope": "/",
        "display": display,
        "orientation": orientation,
        "theme_color": theme_color,
        "background_color": background_color,
        "icons": icons,
        "categories": categories,
        "lang": lang,
    }
