///
/// LocationRegion.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 `RegionCenter` to properly resolve imports.
namespace margelo::nitro::one { struct RegionCenter; }
// Forward declaration of `RegionState` to properly resolve imports.
namespace margelo::nitro::one { enum class RegionState; }

#include <string>
#include "RegionCenter.hpp"
#include <optional>
#include "RegionState.hpp"

namespace margelo::nitro::one {

  /**
   * A struct which can be represented as a JavaScript object (LocationRegion).
   */
  struct LocationRegion final {
  public:
    std::string identifier     SWIFT_PRIVATE;
    RegionCenter center     SWIFT_PRIVATE;
    double radius     SWIFT_PRIVATE;
    std::optional<bool> notifyOnEntry     SWIFT_PRIVATE;
    std::optional<bool> notifyOnExit     SWIFT_PRIVATE;
    std::optional<RegionState> state     SWIFT_PRIVATE;

  public:
    LocationRegion() = default;
    explicit LocationRegion(std::string identifier, RegionCenter center, double radius, std::optional<bool> notifyOnEntry, std::optional<bool> notifyOnExit, std::optional<RegionState> state): identifier(identifier), center(center), radius(radius), notifyOnEntry(notifyOnEntry), notifyOnExit(notifyOnExit), state(state) {}

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

} // namespace margelo::nitro::one

namespace margelo::nitro {

  // C++ LocationRegion <> JS LocationRegion (object)
  template <>
  struct JSIConverter<margelo::nitro::one::LocationRegion> final {
    static inline margelo::nitro::one::LocationRegion fromJSI(jsi::Runtime& runtime, const jsi::Value& arg) {
      jsi::Object obj = arg.asObject(runtime);
      return margelo::nitro::one::LocationRegion(
        JSIConverter<std::string>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "identifier"))),
        JSIConverter<margelo::nitro::one::RegionCenter>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "center"))),
        JSIConverter<double>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "radius"))),
        JSIConverter<std::optional<bool>>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "notifyOnEntry"))),
        JSIConverter<std::optional<bool>>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "notifyOnExit"))),
        JSIConverter<std::optional<margelo::nitro::one::RegionState>>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "state")))
      );
    }
    static inline jsi::Value toJSI(jsi::Runtime& runtime, const margelo::nitro::one::LocationRegion& arg) {
      jsi::Object obj(runtime);
      obj.setProperty(runtime, PropNameIDCache::get(runtime, "identifier"), JSIConverter<std::string>::toJSI(runtime, arg.identifier));
      obj.setProperty(runtime, PropNameIDCache::get(runtime, "center"), JSIConverter<margelo::nitro::one::RegionCenter>::toJSI(runtime, arg.center));
      obj.setProperty(runtime, PropNameIDCache::get(runtime, "radius"), JSIConverter<double>::toJSI(runtime, arg.radius));
      obj.setProperty(runtime, PropNameIDCache::get(runtime, "notifyOnEntry"), JSIConverter<std::optional<bool>>::toJSI(runtime, arg.notifyOnEntry));
      obj.setProperty(runtime, PropNameIDCache::get(runtime, "notifyOnExit"), JSIConverter<std::optional<bool>>::toJSI(runtime, arg.notifyOnExit));
      obj.setProperty(runtime, PropNameIDCache::get(runtime, "state"), JSIConverter<std::optional<margelo::nitro::one::RegionState>>::toJSI(runtime, arg.state));
      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, "identifier")))) return false;
      if (!JSIConverter<margelo::nitro::one::RegionCenter>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "center")))) return false;
      if (!JSIConverter<double>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "radius")))) return false;
      if (!JSIConverter<std::optional<bool>>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "notifyOnEntry")))) return false;
      if (!JSIConverter<std::optional<bool>>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "notifyOnExit")))) return false;
      if (!JSIConverter<std::optional<margelo::nitro::one::RegionState>>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "state")))) return false;
      return true;
    }
  };

} // namespace margelo::nitro
