///
/// VideoSource.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 `VideoMediaType` to properly resolve imports.
namespace margelo::nitro::aviation { enum class VideoMediaType; }
// Forward declaration of `DrmType` to properly resolve imports.
namespace margelo::nitro::aviation { enum class DrmType; }

#include <string>
#include "VideoMediaType.hpp"
#include <unordered_map>
#include <optional>
#include "DrmType.hpp"

namespace margelo::nitro::aviation {

  /**
   * A struct which can be represented as a JavaScript object (VideoSource).
   */
  struct VideoSource final {
  public:
    std::string uri     SWIFT_PRIVATE;
    VideoMediaType mediaType     SWIFT_PRIVATE;
    std::optional<std::unordered_map<std::string, std::string>> headers     SWIFT_PRIVATE;
    std::optional<DrmType> drmType     SWIFT_PRIVATE;
    std::optional<std::string> drmLicenseUri     SWIFT_PRIVATE;
    std::optional<std::unordered_map<std::string, std::string>> drmHeaders     SWIFT_PRIVATE;
    std::optional<double> startPositionMs     SWIFT_PRIVATE;
    std::optional<std::string> title     SWIFT_PRIVATE;
    std::optional<std::string> artist     SWIFT_PRIVATE;
    std::optional<std::string> artworkUri     SWIFT_PRIVATE;

  public:
    VideoSource() = default;
    explicit VideoSource(std::string uri, VideoMediaType mediaType, std::optional<std::unordered_map<std::string, std::string>> headers, std::optional<DrmType> drmType, std::optional<std::string> drmLicenseUri, std::optional<std::unordered_map<std::string, std::string>> drmHeaders, std::optional<double> startPositionMs, std::optional<std::string> title, std::optional<std::string> artist, std::optional<std::string> artworkUri): uri(uri), mediaType(mediaType), headers(headers), drmType(drmType), drmLicenseUri(drmLicenseUri), drmHeaders(drmHeaders), startPositionMs(startPositionMs), title(title), artist(artist), artworkUri(artworkUri) {}

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

} // namespace margelo::nitro::aviation

namespace margelo::nitro {

  // C++ VideoSource <> JS VideoSource (object)
  template <>
  struct JSIConverter<margelo::nitro::aviation::VideoSource> final {
    static inline margelo::nitro::aviation::VideoSource fromJSI(jsi::Runtime& runtime, const jsi::Value& arg) {
      jsi::Object obj = arg.asObject(runtime);
      return margelo::nitro::aviation::VideoSource(
        JSIConverter<std::string>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "uri"))),
        JSIConverter<margelo::nitro::aviation::VideoMediaType>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "mediaType"))),
        JSIConverter<std::optional<std::unordered_map<std::string, std::string>>>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "headers"))),
        JSIConverter<std::optional<margelo::nitro::aviation::DrmType>>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "drmType"))),
        JSIConverter<std::optional<std::string>>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "drmLicenseUri"))),
        JSIConverter<std::optional<std::unordered_map<std::string, std::string>>>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "drmHeaders"))),
        JSIConverter<std::optional<double>>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "startPositionMs"))),
        JSIConverter<std::optional<std::string>>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "title"))),
        JSIConverter<std::optional<std::string>>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "artist"))),
        JSIConverter<std::optional<std::string>>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "artworkUri")))
      );
    }
    static inline jsi::Value toJSI(jsi::Runtime& runtime, const margelo::nitro::aviation::VideoSource& 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, "mediaType"), JSIConverter<margelo::nitro::aviation::VideoMediaType>::toJSI(runtime, arg.mediaType));
      obj.setProperty(runtime, PropNameIDCache::get(runtime, "headers"), JSIConverter<std::optional<std::unordered_map<std::string, std::string>>>::toJSI(runtime, arg.headers));
      obj.setProperty(runtime, PropNameIDCache::get(runtime, "drmType"), JSIConverter<std::optional<margelo::nitro::aviation::DrmType>>::toJSI(runtime, arg.drmType));
      obj.setProperty(runtime, PropNameIDCache::get(runtime, "drmLicenseUri"), JSIConverter<std::optional<std::string>>::toJSI(runtime, arg.drmLicenseUri));
      obj.setProperty(runtime, PropNameIDCache::get(runtime, "drmHeaders"), JSIConverter<std::optional<std::unordered_map<std::string, std::string>>>::toJSI(runtime, arg.drmHeaders));
      obj.setProperty(runtime, PropNameIDCache::get(runtime, "startPositionMs"), JSIConverter<std::optional<double>>::toJSI(runtime, arg.startPositionMs));
      obj.setProperty(runtime, PropNameIDCache::get(runtime, "title"), JSIConverter<std::optional<std::string>>::toJSI(runtime, arg.title));
      obj.setProperty(runtime, PropNameIDCache::get(runtime, "artist"), JSIConverter<std::optional<std::string>>::toJSI(runtime, arg.artist));
      obj.setProperty(runtime, PropNameIDCache::get(runtime, "artworkUri"), JSIConverter<std::optional<std::string>>::toJSI(runtime, arg.artworkUri));
      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<margelo::nitro::aviation::VideoMediaType>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "mediaType")))) return false;
      if (!JSIConverter<std::optional<std::unordered_map<std::string, std::string>>>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "headers")))) return false;
      if (!JSIConverter<std::optional<margelo::nitro::aviation::DrmType>>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "drmType")))) return false;
      if (!JSIConverter<std::optional<std::string>>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "drmLicenseUri")))) return false;
      if (!JSIConverter<std::optional<std::unordered_map<std::string, std::string>>>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "drmHeaders")))) return false;
      if (!JSIConverter<std::optional<double>>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "startPositionMs")))) return false;
      if (!JSIConverter<std::optional<std::string>>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "title")))) return false;
      if (!JSIConverter<std::optional<std::string>>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "artist")))) return false;
      if (!JSIConverter<std::optional<std::string>>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "artworkUri")))) return false;
      return true;
    }
  };

} // namespace margelo::nitro
