///
/// TextStyle.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 `FontWeight` to properly resolve imports.
namespace margelo::nitro::videopipeline { enum class FontWeight; }
// Forward declaration of `TextAlign` to properly resolve imports.
namespace margelo::nitro::videopipeline { enum class TextAlign; }
// Forward declaration of `TextShadow` to properly resolve imports.
namespace margelo::nitro::videopipeline { struct TextShadow; }

#include <string>
#include <optional>
#include "FontWeight.hpp"
#include "TextAlign.hpp"
#include "TextShadow.hpp"

namespace margelo::nitro::videopipeline {

  /**
   * A struct which can be represented as a JavaScript object (TextStyle).
   */
  struct TextStyle final {
  public:
    std::optional<std::string> fontFamily     SWIFT_PRIVATE;
    double fontSize     SWIFT_PRIVATE;
    std::string color     SWIFT_PRIVATE;
    std::optional<FontWeight> weight     SWIFT_PRIVATE;
    std::optional<TextAlign> align     SWIFT_PRIVATE;
    std::optional<TextShadow> shadow     SWIFT_PRIVATE;

  public:
    TextStyle() = default;
    explicit TextStyle(std::optional<std::string> fontFamily, double fontSize, std::string color, std::optional<FontWeight> weight, std::optional<TextAlign> align, std::optional<TextShadow> shadow): fontFamily(fontFamily), fontSize(fontSize), color(color), weight(weight), align(align), shadow(shadow) {}

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

} // namespace margelo::nitro::videopipeline

namespace margelo::nitro {

  // C++ TextStyle <> JS TextStyle (object)
  template <>
  struct JSIConverter<margelo::nitro::videopipeline::TextStyle> final {
    static inline margelo::nitro::videopipeline::TextStyle fromJSI(jsi::Runtime& runtime, const jsi::Value& arg) {
      jsi::Object obj = arg.asObject(runtime);
      return margelo::nitro::videopipeline::TextStyle(
        JSIConverter<std::optional<std::string>>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "fontFamily"))),
        JSIConverter<double>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "fontSize"))),
        JSIConverter<std::string>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "color"))),
        JSIConverter<std::optional<margelo::nitro::videopipeline::FontWeight>>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "weight"))),
        JSIConverter<std::optional<margelo::nitro::videopipeline::TextAlign>>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "align"))),
        JSIConverter<std::optional<margelo::nitro::videopipeline::TextShadow>>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "shadow")))
      );
    }
    static inline jsi::Value toJSI(jsi::Runtime& runtime, const margelo::nitro::videopipeline::TextStyle& arg) {
      jsi::Object obj(runtime);
      obj.setProperty(runtime, PropNameIDCache::get(runtime, "fontFamily"), JSIConverter<std::optional<std::string>>::toJSI(runtime, arg.fontFamily));
      obj.setProperty(runtime, PropNameIDCache::get(runtime, "fontSize"), JSIConverter<double>::toJSI(runtime, arg.fontSize));
      obj.setProperty(runtime, PropNameIDCache::get(runtime, "color"), JSIConverter<std::string>::toJSI(runtime, arg.color));
      obj.setProperty(runtime, PropNameIDCache::get(runtime, "weight"), JSIConverter<std::optional<margelo::nitro::videopipeline::FontWeight>>::toJSI(runtime, arg.weight));
      obj.setProperty(runtime, PropNameIDCache::get(runtime, "align"), JSIConverter<std::optional<margelo::nitro::videopipeline::TextAlign>>::toJSI(runtime, arg.align));
      obj.setProperty(runtime, PropNameIDCache::get(runtime, "shadow"), JSIConverter<std::optional<margelo::nitro::videopipeline::TextShadow>>::toJSI(runtime, arg.shadow));
      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<std::string>>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "fontFamily")))) return false;
      if (!JSIConverter<double>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "fontSize")))) return false;
      if (!JSIConverter<std::string>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "color")))) return false;
      if (!JSIConverter<std::optional<margelo::nitro::videopipeline::FontWeight>>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "weight")))) return false;
      if (!JSIConverter<std::optional<margelo::nitro::videopipeline::TextAlign>>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "align")))) return false;
      if (!JSIConverter<std::optional<margelo::nitro::videopipeline::TextShadow>>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "shadow")))) return false;
      return true;
    }
  };

} // namespace margelo::nitro
