///
/// Link.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 <string>
#include <optional>
#include <vector>

namespace margelo::nitro::readium {

  /**
   * A struct which can be represented as a JavaScript object (Link).
   */
  struct Link final {
  public:
    std::string href     SWIFT_PRIVATE;
    std::optional<std::string> title     SWIFT_PRIVATE;
    std::optional<std::vector<std::string>> rels     SWIFT_PRIVATE;
    std::optional<std::vector<std::string>> languages     SWIFT_PRIVATE;
    std::optional<double> depth     SWIFT_PRIVATE;
    std::optional<bool> hasChildren     SWIFT_PRIVATE;
    std::optional<std::string> parentHref     SWIFT_PRIVATE;
    std::optional<double> position     SWIFT_PRIVATE;

  public:
    Link() = default;
    explicit Link(std::string href, std::optional<std::string> title, std::optional<std::vector<std::string>> rels, std::optional<std::vector<std::string>> languages, std::optional<double> depth, std::optional<bool> hasChildren, std::optional<std::string> parentHref, std::optional<double> position): href(href), title(title), rels(rels), languages(languages), depth(depth), hasChildren(hasChildren), parentHref(parentHref), position(position) {}

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

} // namespace margelo::nitro::readium

namespace margelo::nitro {

  // C++ Link <> JS Link (object)
  template <>
  struct JSIConverter<margelo::nitro::readium::Link> final {
    static inline margelo::nitro::readium::Link fromJSI(jsi::Runtime& runtime, const jsi::Value& arg) {
      jsi::Object obj = arg.asObject(runtime);
      return margelo::nitro::readium::Link(
        JSIConverter<std::string>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "href"))),
        JSIConverter<std::optional<std::string>>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "title"))),
        JSIConverter<std::optional<std::vector<std::string>>>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "rels"))),
        JSIConverter<std::optional<std::vector<std::string>>>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "languages"))),
        JSIConverter<std::optional<double>>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "depth"))),
        JSIConverter<std::optional<bool>>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "hasChildren"))),
        JSIConverter<std::optional<std::string>>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "parentHref"))),
        JSIConverter<std::optional<double>>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "position")))
      );
    }
    static inline jsi::Value toJSI(jsi::Runtime& runtime, const margelo::nitro::readium::Link& arg) {
      jsi::Object obj(runtime);
      obj.setProperty(runtime, PropNameIDCache::get(runtime, "href"), JSIConverter<std::string>::toJSI(runtime, arg.href));
      obj.setProperty(runtime, PropNameIDCache::get(runtime, "title"), JSIConverter<std::optional<std::string>>::toJSI(runtime, arg.title));
      obj.setProperty(runtime, PropNameIDCache::get(runtime, "rels"), JSIConverter<std::optional<std::vector<std::string>>>::toJSI(runtime, arg.rels));
      obj.setProperty(runtime, PropNameIDCache::get(runtime, "languages"), JSIConverter<std::optional<std::vector<std::string>>>::toJSI(runtime, arg.languages));
      obj.setProperty(runtime, PropNameIDCache::get(runtime, "depth"), JSIConverter<std::optional<double>>::toJSI(runtime, arg.depth));
      obj.setProperty(runtime, PropNameIDCache::get(runtime, "hasChildren"), JSIConverter<std::optional<bool>>::toJSI(runtime, arg.hasChildren));
      obj.setProperty(runtime, PropNameIDCache::get(runtime, "parentHref"), JSIConverter<std::optional<std::string>>::toJSI(runtime, arg.parentHref));
      obj.setProperty(runtime, PropNameIDCache::get(runtime, "position"), JSIConverter<std::optional<double>>::toJSI(runtime, arg.position));
      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::string>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "href")))) return false;
      if (!JSIConverter<std::optional<std::string>>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "title")))) return false;
      if (!JSIConverter<std::optional<std::vector<std::string>>>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "rels")))) return false;
      if (!JSIConverter<std::optional<std::vector<std::string>>>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "languages")))) return false;
      if (!JSIConverter<std::optional<double>>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "depth")))) return false;
      if (!JSIConverter<std::optional<bool>>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "hasChildren")))) return false;
      if (!JSIConverter<std::optional<std::string>>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "parentHref")))) return false;
      if (!JSIConverter<std::optional<double>>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "position")))) return false;
      return true;
    }
  };

} // namespace margelo::nitro
