///
/// TimedMetadata.hpp
/// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
/// https://github.com/mrousavy/nitro
/// Copyright © 2025 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

// Forward declaration of `TimedMetadataObject` to properly resolve imports.
namespace margelo::nitro::video { struct TimedMetadataObject; }

#include "TimedMetadataObject.hpp"
#include <vector>

namespace margelo::nitro::video {

  /**
   * A struct which can be represented as a JavaScript object (TimedMetadata).
   */
  struct TimedMetadata {
  public:
    std::vector<TimedMetadataObject> metadata     SWIFT_PRIVATE;

  public:
    TimedMetadata() = default;
    explicit TimedMetadata(std::vector<TimedMetadataObject> metadata): metadata(metadata) {}
  };

} // namespace margelo::nitro::video

namespace margelo::nitro {

  // C++ TimedMetadata <> JS TimedMetadata (object)
  template <>
  struct JSIConverter<margelo::nitro::video::TimedMetadata> final {
    static inline margelo::nitro::video::TimedMetadata fromJSI(jsi::Runtime& runtime, const jsi::Value& arg) {
      jsi::Object obj = arg.asObject(runtime);
      return margelo::nitro::video::TimedMetadata(
        JSIConverter<std::vector<margelo::nitro::video::TimedMetadataObject>>::fromJSI(runtime, obj.getProperty(runtime, "metadata"))
      );
    }
    static inline jsi::Value toJSI(jsi::Runtime& runtime, const margelo::nitro::video::TimedMetadata& arg) {
      jsi::Object obj(runtime);
      obj.setProperty(runtime, "metadata", JSIConverter<std::vector<margelo::nitro::video::TimedMetadataObject>>::toJSI(runtime, arg.metadata));
      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 (!JSIConverter<std::vector<margelo::nitro::video::TimedMetadataObject>>::canConvert(runtime, obj.getProperty(runtime, "metadata"))) return false;
      return true;
    }
  };

} // namespace margelo::nitro
