///
/// JNitroCameraConfig.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 "NitroCameraConfig.hpp"

#include "CameraDevice.hpp"
#include "CropRatio.hpp"
#include "JCameraDevice.hpp"
#include "JCropRatio.hpp"
#include "JLanguage.hpp"
#include "JMediaType.hpp"
#include "JPickerCropConfig.hpp"
#include "JPresentation.hpp"
#include "Language.hpp"
#include "MediaType.hpp"
#include "PickerCropConfig.hpp"
#include "Presentation.hpp"
#include <optional>
#include <string>
#include <vector>

namespace margelo::nitro::multipleimagepicker {

  using namespace facebook;

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

  public:
    /**
     * Convert this Java/Kotlin-based struct to the C++ struct NitroCameraConfig by copying all values to C++.
     */
    [[maybe_unused]]
    [[nodiscard]]
    NitroCameraConfig toCpp() const {
      static const auto clazz = javaClassStatic();
      static const auto fieldMediaType = clazz->getField<JMediaType>("mediaType");
      jni::local_ref<JMediaType> mediaType = this->getFieldValue(fieldMediaType);
      static const auto fieldPresentation = clazz->getField<JPresentation>("presentation");
      jni::local_ref<JPresentation> presentation = this->getFieldValue(fieldPresentation);
      static const auto fieldLanguage = clazz->getField<JLanguage>("language");
      jni::local_ref<JLanguage> language = this->getFieldValue(fieldLanguage);
      static const auto fieldCrop = clazz->getField<JPickerCropConfig>("crop");
      jni::local_ref<JPickerCropConfig> crop = this->getFieldValue(fieldCrop);
      static const auto fieldIsSaveSystemAlbum = clazz->getField<jni::JBoolean>("isSaveSystemAlbum");
      jni::local_ref<jni::JBoolean> isSaveSystemAlbum = this->getFieldValue(fieldIsSaveSystemAlbum);
      static const auto fieldColor = clazz->getField<jni::JDouble>("color");
      jni::local_ref<jni::JDouble> color = this->getFieldValue(fieldColor);
      static const auto fieldCameraDevice = clazz->getField<JCameraDevice>("cameraDevice");
      jni::local_ref<JCameraDevice> cameraDevice = this->getFieldValue(fieldCameraDevice);
      static const auto fieldVideoMaximumDuration = clazz->getField<jni::JDouble>("videoMaximumDuration");
      jni::local_ref<jni::JDouble> videoMaximumDuration = this->getFieldValue(fieldVideoMaximumDuration);
      return NitroCameraConfig(
        mediaType->toCpp(),
        presentation->toCpp(),
        language->toCpp(),
        crop != nullptr ? std::make_optional(crop->toCpp()) : std::nullopt,
        isSaveSystemAlbum != nullptr ? std::make_optional(static_cast<bool>(isSaveSystemAlbum->value())) : std::nullopt,
        color != nullptr ? std::make_optional(color->value()) : std::nullopt,
        cameraDevice != nullptr ? std::make_optional(cameraDevice->toCpp()) : std::nullopt,
        videoMaximumDuration != nullptr ? std::make_optional(videoMaximumDuration->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<JNitroCameraConfig::javaobject> fromCpp(const NitroCameraConfig& value) {
      return newInstance(
        JMediaType::fromCpp(value.mediaType),
        JPresentation::fromCpp(value.presentation),
        JLanguage::fromCpp(value.language),
        value.crop.has_value() ? JPickerCropConfig::fromCpp(value.crop.value()) : nullptr,
        value.isSaveSystemAlbum.has_value() ? jni::JBoolean::valueOf(value.isSaveSystemAlbum.value()) : nullptr,
        value.color.has_value() ? jni::JDouble::valueOf(value.color.value()) : nullptr,
        value.cameraDevice.has_value() ? JCameraDevice::fromCpp(value.cameraDevice.value()) : nullptr,
        value.videoMaximumDuration.has_value() ? jni::JDouble::valueOf(value.videoMaximumDuration.value()) : nullptr
      );
    }
  };

} // namespace margelo::nitro::multipleimagepicker
