///
/// ImagePickerNativeResult.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 `ImagePickerAsset` to properly resolve imports.
namespace margelo::nitro::one { struct ImagePickerAsset; }

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

namespace margelo::nitro::one {

  /**
   * A struct which can be represented as a JavaScript object (ImagePickerNativeResult).
   */
  struct ImagePickerNativeResult final {
  public:
    bool canceled     SWIFT_PRIVATE;
    std::optional<std::vector<ImagePickerAsset>> assets     SWIFT_PRIVATE;

  public:
    ImagePickerNativeResult() = default;
    explicit ImagePickerNativeResult(bool canceled, std::optional<std::vector<ImagePickerAsset>> assets): canceled(canceled), assets(assets) {}

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

} // namespace margelo::nitro::one

namespace margelo::nitro {

  // C++ ImagePickerNativeResult <> JS ImagePickerNativeResult (object)
  template <>
  struct JSIConverter<margelo::nitro::one::ImagePickerNativeResult> final {
    static inline margelo::nitro::one::ImagePickerNativeResult fromJSI(jsi::Runtime& runtime, const jsi::Value& arg) {
      jsi::Object obj = arg.asObject(runtime);
      return margelo::nitro::one::ImagePickerNativeResult(
        JSIConverter<bool>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "canceled"))),
        JSIConverter<std::optional<std::vector<margelo::nitro::one::ImagePickerAsset>>>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "assets")))
      );
    }
    static inline jsi::Value toJSI(jsi::Runtime& runtime, const margelo::nitro::one::ImagePickerNativeResult& arg) {
      jsi::Object obj(runtime);
      obj.setProperty(runtime, PropNameIDCache::get(runtime, "canceled"), JSIConverter<bool>::toJSI(runtime, arg.canceled));
      obj.setProperty(runtime, PropNameIDCache::get(runtime, "assets"), JSIConverter<std::optional<std::vector<margelo::nitro::one::ImagePickerAsset>>>::toJSI(runtime, arg.assets));
      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<bool>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "canceled")))) return false;
      if (!JSIConverter<std::optional<std::vector<margelo::nitro::one::ImagePickerAsset>>>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "assets")))) return false;
      return true;
    }
  };

} // namespace margelo::nitro
