///
/// Clip.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 `ClipTransform` to properly resolve imports.
namespace margelo::nitro::videopipeline { struct ClipTransform; }
// Forward declaration of `TrackFrame` to properly resolve imports.
namespace margelo::nitro::videopipeline { struct TrackFrame; }

#include <string>
#include "ClipTransform.hpp"
#include <optional>
#include "TrackFrame.hpp"

namespace margelo::nitro::videopipeline {

  /**
   * A struct which can be represented as a JavaScript object (Clip).
   */
  struct Clip final {
  public:
    std::string uri     SWIFT_PRIVATE;
    double sourceStart     SWIFT_PRIVATE;
    double sourceDuration     SWIFT_PRIVATE;
    double outputStart     SWIFT_PRIVATE;
    std::optional<ClipTransform> transform     SWIFT_PRIVATE;
    std::optional<double> track     SWIFT_PRIVATE;
    std::optional<TrackFrame> frame     SWIFT_PRIVATE;

  public:
    Clip() = default;
    explicit Clip(std::string uri, double sourceStart, double sourceDuration, double outputStart, std::optional<ClipTransform> transform, std::optional<double> track, std::optional<TrackFrame> frame): uri(uri), sourceStart(sourceStart), sourceDuration(sourceDuration), outputStart(outputStart), transform(transform), track(track), frame(frame) {}

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

} // namespace margelo::nitro::videopipeline

namespace margelo::nitro {

  // C++ Clip <> JS Clip (object)
  template <>
  struct JSIConverter<margelo::nitro::videopipeline::Clip> final {
    static inline margelo::nitro::videopipeline::Clip fromJSI(jsi::Runtime& runtime, const jsi::Value& arg) {
      jsi::Object obj = arg.asObject(runtime);
      return margelo::nitro::videopipeline::Clip(
        JSIConverter<std::string>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "uri"))),
        JSIConverter<double>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "sourceStart"))),
        JSIConverter<double>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "sourceDuration"))),
        JSIConverter<double>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "outputStart"))),
        JSIConverter<std::optional<margelo::nitro::videopipeline::ClipTransform>>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "transform"))),
        JSIConverter<std::optional<double>>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "track"))),
        JSIConverter<std::optional<margelo::nitro::videopipeline::TrackFrame>>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "frame")))
      );
    }
    static inline jsi::Value toJSI(jsi::Runtime& runtime, const margelo::nitro::videopipeline::Clip& arg) {
      jsi::Object obj(runtime);
      obj.setProperty(runtime, PropNameIDCache::get(runtime, "uri"), JSIConverter<std::string>::toJSI(runtime, arg.uri));
      obj.setProperty(runtime, PropNameIDCache::get(runtime, "sourceStart"), JSIConverter<double>::toJSI(runtime, arg.sourceStart));
      obj.setProperty(runtime, PropNameIDCache::get(runtime, "sourceDuration"), JSIConverter<double>::toJSI(runtime, arg.sourceDuration));
      obj.setProperty(runtime, PropNameIDCache::get(runtime, "outputStart"), JSIConverter<double>::toJSI(runtime, arg.outputStart));
      obj.setProperty(runtime, PropNameIDCache::get(runtime, "transform"), JSIConverter<std::optional<margelo::nitro::videopipeline::ClipTransform>>::toJSI(runtime, arg.transform));
      obj.setProperty(runtime, PropNameIDCache::get(runtime, "track"), JSIConverter<std::optional<double>>::toJSI(runtime, arg.track));
      obj.setProperty(runtime, PropNameIDCache::get(runtime, "frame"), JSIConverter<std::optional<margelo::nitro::videopipeline::TrackFrame>>::toJSI(runtime, arg.frame));
      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, "uri")))) return false;
      if (!JSIConverter<double>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "sourceStart")))) return false;
      if (!JSIConverter<double>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "sourceDuration")))) return false;
      if (!JSIConverter<double>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "outputStart")))) return false;
      if (!JSIConverter<std::optional<margelo::nitro::videopipeline::ClipTransform>>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "transform")))) return false;
      if (!JSIConverter<std::optional<double>>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "track")))) return false;
      if (!JSIConverter<std::optional<margelo::nitro::videopipeline::TrackFrame>>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "frame")))) return false;
      return true;
    }
  };

} // namespace margelo::nitro
