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

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

namespace margelo::nitro::videopipeline {

  /**
   * A struct which can be represented as a JavaScript object (TextOverlay).
   */
  struct TextOverlay final {
  public:
    OverlayKind kind     SWIFT_PRIVATE;
    std::string text     SWIFT_PRIVATE;
    TextStyle style     SWIFT_PRIVATE;
    AnchorPoint anchor     SWIFT_PRIVATE;
    std::optional<TimeRange> timeRange     SWIFT_PRIVATE;

  public:
    TextOverlay() = default;
    explicit TextOverlay(OverlayKind kind, std::string text, TextStyle style, AnchorPoint anchor, std::optional<TimeRange> timeRange): kind(kind), text(text), style(style), anchor(anchor), timeRange(timeRange) {}

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

} // namespace margelo::nitro::videopipeline

namespace margelo::nitro {

  // C++ TextOverlay <> JS TextOverlay (object)
  template <>
  struct JSIConverter<margelo::nitro::videopipeline::TextOverlay> final {
    static inline margelo::nitro::videopipeline::TextOverlay fromJSI(jsi::Runtime& runtime, const jsi::Value& arg) {
      jsi::Object obj = arg.asObject(runtime);
      return margelo::nitro::videopipeline::TextOverlay(
        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, "text"))),
        JSIConverter<margelo::nitro::videopipeline::TextStyle>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "style"))),
        JSIConverter<margelo::nitro::videopipeline::AnchorPoint>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "anchor"))),
        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::TextOverlay& 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, "text"), JSIConverter<std::string>::toJSI(runtime, arg.text));
      obj.setProperty(runtime, PropNameIDCache::get(runtime, "style"), JSIConverter<margelo::nitro::videopipeline::TextStyle>::toJSI(runtime, arg.style));
      obj.setProperty(runtime, PropNameIDCache::get(runtime, "anchor"), JSIConverter<margelo::nitro::videopipeline::AnchorPoint>::toJSI(runtime, arg.anchor));
      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, "text")))) return false;
      if (!JSIConverter<margelo::nitro::videopipeline::TextStyle>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "style")))) return false;
      if (!JSIConverter<margelo::nitro::videopipeline::AnchorPoint>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "anchor")))) 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
