#include "adapters/config/EspConfigAdapter.h"

namespace ta::adapters::config
{
    EspConfigAdapter::EspConfigAdapter()
        : ta::application::config::ConfigOwner("esp", "ESP", ta::application::config::ConfigCategory::Visuals)
    {
    }

    ta::features::esp::EspSettingsSnapshot EspConfigAdapter::read() const
    {
        ta::features::esp::EspSettingsSnapshot settings;
        settings.extracts_enabled = extracts_->get_value();
        settings.extracts_color = ta::foundation::to_rgba(extracts_color_->get_value());
        settings.transits_enabled = transits_->get_value();
        settings.transits_color = ta::foundation::to_rgba(transits_color_->get_value());
        settings.pmc_enabled = pmc_->get_value();
        settings.pmc_color = ta::foundation::to_rgba(pmc_color_->get_value());
        settings.scav_enabled = scav_->get_value();
        settings.scav_color = ta::foundation::to_rgba(scav_color_->get_value());
        settings.normal_items_enabled = normal_item_esp_->get_value();
        settings.normal_item_color = ta::foundation::to_rgba(normal_item_color_->get_value());
        settings.normal_item_distance = normal_item_distance_->get_value();
        settings.loot_min_distance = loot_min_distance_->get_value();
        settings.wishlist_items_enabled = wishlist_item_esp_->get_value();
        settings.wishlist_item_color = ta::foundation::to_rgba(wishlist_item_color_->get_value());
        settings.wishlist_item_distance = wishlist_item_distance_->get_value();
        settings.quest_items_enabled = quest_item_esp_->get_value();
        settings.quest_item_color = ta::foundation::to_rgba(quest_item_color_->get_value());
        settings.quest_item_distance = quest_item_distance_->get_value();
        settings.corpses_enabled = corpse_esp_->get_value();
        settings.corpse_color = ta::foundation::to_rgba(corpse_color_->get_value());
        settings.corpse_distance = corpse_distance_->get_value();
        settings.containers_enabled = container_esp_->get_value();
        settings.container_color = ta::foundation::to_rgba(container_color_->get_value());
        settings.container_distance = container_distance_->get_value();
        settings.font_size = font_size_->get_value();
        settings.advanced.local_position_interval_ms = local_position_interval_ms_->get_value();
        settings.advanced.player_scan_interval_ms = player_scan_interval_ms_->get_value();
        settings.advanced.dynamic_loot_interval_ms = dynamic_loot_interval_ms_->get_value();
        settings.advanced.exfil_status_interval_ms = exfil_status_interval_ms_->get_value();
        settings.advanced.static_discovery_interval_ms = static_discovery_interval_ms_->get_value();
        settings.advanced.wishlist_fallback_interval_ms = wishlist_fallback_interval_ms_->get_value();
        settings.advanced.distance_hysteresis_percent = distance_hysteresis_percent_->get_value();
        settings.advanced.missing_scans_before_removal = missing_scans_before_removal_->get_value();
        settings.advanced.metadata_resolves_per_tick = metadata_resolves_per_tick_->get_value();
        settings.advanced.metadata_time_budget_us = metadata_time_budget_us_->get_value();
        ta::features::esp::sanitize_esp_settings(settings.advanced);
        return settings;
    }
}
