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

#pragma once

#if __has_include(<NitroModules/JSIConverter.hpp>)
#include <NitroModules/JSIConverter.hpp>
#else
#error NitroModules cannot be found! Are you sure you installed NitroModules properly?
#endif
#if __has_include(<NitroModules/NitroDefines.hpp>)
#include <NitroModules/NitroDefines.hpp>
#else
#error NitroModules cannot be found! Are you sure you installed NitroModules properly?
#endif
#if __has_include(<NitroModules/JSIHelpers.hpp>)
#include <NitroModules/JSIHelpers.hpp>
#else
#error NitroModules cannot be found! Are you sure you installed NitroModules properly?
#endif
#if __has_include(<NitroModules/PropNameIDCache.hpp>)
#include <NitroModules/PropNameIDCache.hpp>
#else
#error NitroModules cannot be found! Are you sure you installed NitroModules properly?
#endif

// Forward declaration of `CropRatio` to properly resolve imports.
namespace margelo::nitro::multipleimagepicker { struct CropRatio; }

#include <optional>
#include "CropRatio.hpp"
#include <vector>

namespace margelo::nitro::multipleimagepicker {

  /**
   * A struct which can be represented as a JavaScript object (PickerCropConfig).
   */
  struct PickerCropConfig final {
  public:
    std::optional<bool> circle     SWIFT_PRIVATE;
    std::vector<CropRatio> ratio     SWIFT_PRIVATE;
    std::optional<CropRatio> defaultRatio     SWIFT_PRIVATE;
    std::optional<bool> freeStyle     SWIFT_PRIVATE;

  public:
    PickerCropConfig() = default;
    explicit PickerCropConfig(std::optional<bool> circle, std::vector<CropRatio> ratio, std::optional<CropRatio> defaultRatio, std::optional<bool> freeStyle): circle(circle), ratio(ratio), defaultRatio(defaultRatio), freeStyle(freeStyle) {}

  public:
    friend bool operator==(const PickerCropConfig& lhs, const PickerCropConfig& rhs) = default;
  };

} // namespace margelo::nitro::multipleimagepicker

namespace margelo::nitro {

  // C++ PickerCropConfig <> JS PickerCropConfig (object)
  template <>
  struct JSIConverter<margelo::nitro::multipleimagepicker::PickerCropConfig> final {
    static inline margelo::nitro::multipleimagepicker::PickerCropConfig fromJSI(jsi::Runtime& runtime, const jsi::Value& arg) {
      jsi::Object obj = arg.asObject(runtime);
      return margelo::nitro::multipleimagepicker::PickerCropConfig(
        JSIConverter<std::optional<bool>>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "circle"))),
        JSIConverter<std::vector<margelo::nitro::multipleimagepicker::CropRatio>>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "ratio"))),
        JSIConverter<std::optional<margelo::nitro::multipleimagepicker::CropRatio>>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "defaultRatio"))),
        JSIConverter<std::optional<bool>>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "freeStyle")))
      );
    }
    static inline jsi::Value toJSI(jsi::Runtime& runtime, const margelo::nitro::multipleimagepicker::PickerCropConfig& arg) {
      jsi::Object obj(runtime);
      obj.setProperty(runtime, PropNameIDCache::get(runtime, "circle"), JSIConverter<std::optional<bool>>::toJSI(runtime, arg.circle));
      obj.setProperty(runtime, PropNameIDCache::get(runtime, "ratio"), JSIConverter<std::vector<margelo::nitro::multipleimagepicker::CropRatio>>::toJSI(runtime, arg.ratio));
      obj.setProperty(runtime, PropNameIDCache::get(runtime, "defaultRatio"), JSIConverter<std::optional<margelo::nitro::multipleimagepicker::CropRatio>>::toJSI(runtime, arg.defaultRatio));
      obj.setProperty(runtime, PropNameIDCache::get(runtime, "freeStyle"), JSIConverter<std::optional<bool>>::toJSI(runtime, arg.freeStyle));
      return obj;
    }
    static inline bool canConvert(jsi::Runtime& runtime, const jsi::Value& value) {
      if (!value.isObject()) {
        return false;
      }
      jsi::Object obj = value.getObject(runtime);
      if (!nitro::isPlainObject(runtime, obj)) {
        return false;
      }
      if (!JSIConverter<std::optional<bool>>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "circle")))) return false;
      if (!JSIConverter<std::vector<margelo::nitro::multipleimagepicker::CropRatio>>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "ratio")))) return false;
      if (!JSIConverter<std::optional<margelo::nitro::multipleimagepicker::CropRatio>>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "defaultRatio")))) return false;
      if (!JSIConverter<std::optional<bool>>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "freeStyle")))) return false;
      return true;
    }
  };

} // namespace margelo::nitro
