idf_component_register(
    SRCS
        "main.c"
        "sx126x.c"
        "wmbus.c"
        "repeater.c"
        "duty_ledger.c"
        "console.c"
        "led.c"
        "cfg_store.c"
        "ui.c"
        "debug_history.c"
        "wifi_debug.c"
        "settings.c"
        "settings_http.c"
        "wifi_qr.c"
        "vendor/qrcodegen.c"
    INCLUDE_DIRS "."
    REQUIRES driver esp_timer esp_lcd esp_wifi esp_netif esp_event esp_http_server
             nvs_flash bootloader_support json
)

# Ship compressed assets to retain the existing app/NVS partition layout.
# Python and gzip are host build tools only; ESP32 serves these bytes directly.
foreach(asset index.html dashboard.css dashboard.js identity.js manufacturers.js)
    set(source "${CMAKE_CURRENT_SOURCE_DIR}/web/${asset}")
    set(compressed "${CMAKE_CURRENT_BINARY_DIR}/web/${asset}.gz")
    add_custom_command(
        OUTPUT "${compressed}"
        COMMAND "${PYTHON}" "${CMAKE_CURRENT_SOURCE_DIR}/../../tools/compress_web_asset.py"
                "${source}" "${compressed}"
        DEPENDS "${source}" "${CMAKE_CURRENT_SOURCE_DIR}/../../tools/compress_web_asset.py"
        VERBATIM
    )
    target_add_binary_data(${COMPONENT_LIB} "${compressed}" BINARY)
endforeach()
