#pragma once

#include "Psc_Cpp_Core/Base/JSON.h"
#include "adminive/managed.hpp"

struct MLAT_Config_Data {
    bool merge{};
    PSC_USE_JSON
};

namespace adminive {
template <>
struct Type_Descriptor<MLAT_Config_Data> {
    static auto get() {
        using T = MLAT_Config_Data;
        return object<T>("mlat_config", "MLAT 配置",
                         ADMINIVE_FIELD_LABEL(T, merge, "合并 MLAT").editable().boolean_input());
    }
};
}

class MLAT_Config {
public:
    adminive::Managed_Value<MLAT_Config_Data> settings;

    [[nodiscard]] Psc::JSON to_base_json() const {
        return settings.read([](const auto& value) {
            return value.to_base_json();
        });
    }

    void from_json(const Psc::JSON* that_json) {
        settings.write([&](auto& value) {
            value.from_base_json(that_json);
        });
    }
};
