///
/// JLDP_ConfigParams.hpp
/// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
/// https://github.com/mrousavy/nitro
/// Copyright © 2025 Marc Rousavy @ Margelo
///

#pragma once

#include <fbjni/fbjni.h>
#include "LDP_ConfigParams.hpp"

#include "JLDP_CustomLanguage.hpp"
#include "JLDP_CustomStyle.hpp"
#include "LDP_CustomLanguage.hpp"
#include "LDP_CustomStyle.hpp"
#include <optional>
#include <string>
#include <unordered_map>
#include <vector>

namespace margelo::nitro::lunardatepicker {

  using namespace facebook;

  /**
   * The C++ JNI bridge between the C++ struct "LDP_ConfigParams" and the the Kotlin data class "LDP_ConfigParams".
   */
  struct JLDP_ConfigParams final: public jni::JavaClass<JLDP_ConfigParams> {
  public:
    static auto constexpr kJavaDescriptor = "Lcom/margelo/nitro/lunardatepicker/LDP_ConfigParams;";

  public:
    /**
     * Convert this Java/Kotlin-based struct to the C++ struct LDP_ConfigParams by copying all values to C++.
     */
    [[maybe_unused]]
    [[nodiscard]]
    LDP_ConfigParams toCpp() const {
      static const auto clazz = javaClassStatic();
      static const auto fieldThemes = clazz->getField<jni::JMap<jni::JString, JLDP_CustomStyle>>("themes");
      jni::local_ref<jni::JMap<jni::JString, JLDP_CustomStyle>> themes = this->getFieldValue(fieldThemes);
      static const auto fieldLanguages = clazz->getField<jni::JMap<jni::JString, JLDP_CustomLanguage>>("languages");
      jni::local_ref<jni::JMap<jni::JString, JLDP_CustomLanguage>> languages = this->getFieldValue(fieldLanguages);
      static const auto fieldYearRangeOffset = clazz->getField<double>("yearRangeOffset");
      double yearRangeOffset = this->getFieldValue(fieldYearRangeOffset);
      static const auto fieldTimeZoneOffset = clazz->getField<double>("timeZoneOffset");
      double timeZoneOffset = this->getFieldValue(fieldTimeZoneOffset);
      static const auto fieldMonthVisibleDebounceDelaySeconds = clazz->getField<jni::JDouble>("monthVisibleDebounceDelaySeconds");
      jni::local_ref<jni::JDouble> monthVisibleDebounceDelaySeconds = this->getFieldValue(fieldMonthVisibleDebounceDelaySeconds);
      return LDP_ConfigParams(
        [&]() {
          std::unordered_map<std::string, LDP_CustomStyle> __map;
          __map.reserve(themes->size());
          for (const auto& __entry : *themes) {
            __map.emplace(__entry.first->toStdString(), __entry.second->toCpp());
          }
          return __map;
        }(),
        [&]() {
          std::unordered_map<std::string, LDP_CustomLanguage> __map;
          __map.reserve(languages->size());
          for (const auto& __entry : *languages) {
            __map.emplace(__entry.first->toStdString(), __entry.second->toCpp());
          }
          return __map;
        }(),
        yearRangeOffset,
        timeZoneOffset,
        monthVisibleDebounceDelaySeconds != nullptr ? std::make_optional(monthVisibleDebounceDelaySeconds->value()) : std::nullopt
      );
    }

  public:
    /**
     * Create a Java/Kotlin-based struct by copying all values from the given C++ struct to Java.
     */
    [[maybe_unused]]
    static jni::local_ref<JLDP_ConfigParams::javaobject> fromCpp(const LDP_ConfigParams& value) {
      return newInstance(
        [&]() -> jni::local_ref<jni::JMap<jni::JString, JLDP_CustomStyle>> {
          auto __map = jni::JHashMap<jni::JString, JLDP_CustomStyle>::create(value.themes.size());
          for (const auto& __entry : value.themes) {
            __map->put(jni::make_jstring(__entry.first), JLDP_CustomStyle::fromCpp(__entry.second));
          }
          return __map;
        }(),
        [&]() -> jni::local_ref<jni::JMap<jni::JString, JLDP_CustomLanguage>> {
          auto __map = jni::JHashMap<jni::JString, JLDP_CustomLanguage>::create(value.languages.size());
          for (const auto& __entry : value.languages) {
            __map->put(jni::make_jstring(__entry.first), JLDP_CustomLanguage::fromCpp(__entry.second));
          }
          return __map;
        }(),
        value.yearRangeOffset,
        value.timeZoneOffset,
        value.monthVisibleDebounceDelaySeconds.has_value() ? jni::JDouble::valueOf(value.monthVisibleDebounceDelaySeconds.value()) : nullptr
      );
    }
  };

} // namespace margelo::nitro::lunardatepicker
