///
/// KeyDetail.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



#include <optional>
#include <string>

namespace margelo::nitro::crypto {

  /**
   * A struct which can be represented as a JavaScript object (KeyDetail).
   */
  struct KeyDetail final {
  public:
    std::optional<double> length     SWIFT_PRIVATE;
    std::optional<double> publicExponent     SWIFT_PRIVATE;
    std::optional<double> modulusLength     SWIFT_PRIVATE;
    std::optional<std::string> hashAlgorithm     SWIFT_PRIVATE;
    std::optional<std::string> mgf1HashAlgorithm     SWIFT_PRIVATE;
    std::optional<double> saltLength     SWIFT_PRIVATE;
    std::optional<std::string> namedCurve     SWIFT_PRIVATE;

  public:
    KeyDetail() = default;
    explicit KeyDetail(std::optional<double> length, std::optional<double> publicExponent, std::optional<double> modulusLength, std::optional<std::string> hashAlgorithm, std::optional<std::string> mgf1HashAlgorithm, std::optional<double> saltLength, std::optional<std::string> namedCurve): length(length), publicExponent(publicExponent), modulusLength(modulusLength), hashAlgorithm(hashAlgorithm), mgf1HashAlgorithm(mgf1HashAlgorithm), saltLength(saltLength), namedCurve(namedCurve) {}

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

} // namespace margelo::nitro::crypto

namespace margelo::nitro {

  // C++ KeyDetail <> JS KeyDetail (object)
  template <>
  struct JSIConverter<margelo::nitro::crypto::KeyDetail> final {
    static inline margelo::nitro::crypto::KeyDetail fromJSI(jsi::Runtime& runtime, const jsi::Value& arg) {
      jsi::Object obj = arg.asObject(runtime);
      return margelo::nitro::crypto::KeyDetail(
        JSIConverter<std::optional<double>>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "length"))),
        JSIConverter<std::optional<double>>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "publicExponent"))),
        JSIConverter<std::optional<double>>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "modulusLength"))),
        JSIConverter<std::optional<std::string>>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "hashAlgorithm"))),
        JSIConverter<std::optional<std::string>>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "mgf1HashAlgorithm"))),
        JSIConverter<std::optional<double>>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "saltLength"))),
        JSIConverter<std::optional<std::string>>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "namedCurve")))
      );
    }
    static inline jsi::Value toJSI(jsi::Runtime& runtime, const margelo::nitro::crypto::KeyDetail& arg) {
      jsi::Object obj(runtime);
      obj.setProperty(runtime, PropNameIDCache::get(runtime, "length"), JSIConverter<std::optional<double>>::toJSI(runtime, arg.length));
      obj.setProperty(runtime, PropNameIDCache::get(runtime, "publicExponent"), JSIConverter<std::optional<double>>::toJSI(runtime, arg.publicExponent));
      obj.setProperty(runtime, PropNameIDCache::get(runtime, "modulusLength"), JSIConverter<std::optional<double>>::toJSI(runtime, arg.modulusLength));
      obj.setProperty(runtime, PropNameIDCache::get(runtime, "hashAlgorithm"), JSIConverter<std::optional<std::string>>::toJSI(runtime, arg.hashAlgorithm));
      obj.setProperty(runtime, PropNameIDCache::get(runtime, "mgf1HashAlgorithm"), JSIConverter<std::optional<std::string>>::toJSI(runtime, arg.mgf1HashAlgorithm));
      obj.setProperty(runtime, PropNameIDCache::get(runtime, "saltLength"), JSIConverter<std::optional<double>>::toJSI(runtime, arg.saltLength));
      obj.setProperty(runtime, PropNameIDCache::get(runtime, "namedCurve"), JSIConverter<std::optional<std::string>>::toJSI(runtime, arg.namedCurve));
      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<double>>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "length")))) return false;
      if (!JSIConverter<std::optional<double>>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "publicExponent")))) return false;
      if (!JSIConverter<std::optional<double>>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "modulusLength")))) return false;
      if (!JSIConverter<std::optional<std::string>>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "hashAlgorithm")))) return false;
      if (!JSIConverter<std::optional<std::string>>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "mgf1HashAlgorithm")))) return false;
      if (!JSIConverter<std::optional<double>>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "saltLength")))) return false;
      if (!JSIConverter<std::optional<std::string>>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "namedCurve")))) return false;
      return true;
    }
  };

} // namespace margelo::nitro
