///
/// ImageOverlay.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 `OverlayKind` to properly resolve imports.
namespace margelo::nitro::videopipeline { enum class OverlayKind; }
// Forward declaration of `AnchorPoint` to properly resolve imports.
namespace margelo::nitro::videopipeline { struct AnchorPoint; }
// Forward declaration of `ImageOverlaySize` to properly resolve imports.
namespace margelo::nitro::videopipeline { struct ImageOverlaySize; }
// Forward declaration of `TimeRange` to properly resolve imports.
namespace margelo::nitro::videopipeline { struct TimeRange; }

#include "OverlayKind.hpp"
#include <string>
#include "AnchorPoint.hpp"
#include "ImageOverlaySize.hpp"
#include <optional>
#include "TimeRange.hpp"

namespace margelo::nitro::videopipeline {

  /**
   * A struct which can be represented as a JavaScript object (ImageOverlay).
   */
  struct ImageOverlay final {
  public:
    OverlayKind kind     SWIFT_PRIVATE;
    std::string uri     SWIFT_PRIVATE;
    AnchorPoint anchor     SWIFT_PRIVATE;
    ImageOverlaySize size     SWIFT_PRIVATE;
    std::optional<double> opacity     SWIFT_PRIVATE;
    std::optional<TimeRange> timeRange     SWIFT_PRIVATE;

  public:
    ImageOverlay() = default;
    explicit ImageOverlay(OverlayKind kind, std::string uri, AnchorPoint anchor, ImageOverlaySize size, std::optional<double> opacity, std::optional<TimeRange> timeRange): kind(kind), uri(uri), anchor(anchor), size(size), opacity(opacity), timeRange(timeRange) {}

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

} // namespace margelo::nitro::videopipeline

namespace margelo::nitro {

  // C++ ImageOverlay <> JS ImageOverlay (object)
  template <>
  struct JSIConverter<margelo::nitro::videopipeline::ImageOverlay> final {
    static inline margelo::nitro::videopipeline::ImageOverlay fromJSI(jsi::Runtime& runtime, const jsi::Value& arg) {
      jsi::Object obj = arg.asObject(runtime);
      return margelo::nitro::videopipeline::ImageOverlay(
        JSIConverter<margelo::nitro::videopipeline::OverlayKind>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "kind"))),
        JSIConverter<std::string>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "uri"))),
        JSIConverter<margelo::nitro::videopipeline::AnchorPoint>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "anchor"))),
        JSIConverter<margelo::nitro::videopipeline::ImageOverlaySize>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "size"))),
        JSIConverter<std::optional<double>>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "opacity"))),
        JSIConverter<std::optional<margelo::nitro::videopipeline::TimeRange>>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "timeRange")))
      );
    }
    static inline jsi::Value toJSI(jsi::Runtime& runtime, const margelo::nitro::videopipeline::ImageOverlay& arg) {
      jsi::Object obj(runtime);
      obj.setProperty(runtime, PropNameIDCache::get(runtime, "kind"), JSIConverter<margelo::nitro::videopipeline::OverlayKind>::toJSI(runtime, arg.kind));
      obj.setProperty(runtime, PropNameIDCache::get(runtime, "uri"), JSIConverter<std::string>::toJSI(runtime, arg.uri));
      obj.setProperty(runtime, PropNameIDCache::get(runtime, "anchor"), JSIConverter<margelo::nitro::videopipeline::AnchorPoint>::toJSI(runtime, arg.anchor));
      obj.setProperty(runtime, PropNameIDCache::get(runtime, "size"), JSIConverter<margelo::nitro::videopipeline::ImageOverlaySize>::toJSI(runtime, arg.size));
      obj.setProperty(runtime, PropNameIDCache::get(runtime, "opacity"), JSIConverter<std::optional<double>>::toJSI(runtime, arg.opacity));
      obj.setProperty(runtime, PropNameIDCache::get(runtime, "timeRange"), JSIConverter<std::optional<margelo::nitro::videopipeline::TimeRange>>::toJSI(runtime, arg.timeRange));
      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<margelo::nitro::videopipeline::OverlayKind>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "kind")))) return false;
      if (!JSIConverter<std::string>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "uri")))) return false;
      if (!JSIConverter<margelo::nitro::videopipeline::AnchorPoint>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "anchor")))) return false;
      if (!JSIConverter<margelo::nitro::videopipeline::ImageOverlaySize>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "size")))) return false;
      if (!JSIConverter<std::optional<double>>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "opacity")))) return false;
      if (!JSIConverter<std::optional<margelo::nitro::videopipeline::TimeRange>>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "timeRange")))) return false;
      return true;
    }
  };

} // namespace margelo::nitro
