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

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

namespace margelo::nitro::aviation {

  /**
   * A struct which can be represented as a JavaScript object (MediaItemConfig).
   */
  struct MediaItemConfig final {
  public:
    std::string uri     SWIFT_PRIVATE;
    MediaType mediaType     SWIFT_PRIVATE;
    std::optional<std::string> mimeType     SWIFT_PRIVATE;
    std::optional<std::string> title     SWIFT_PRIVATE;
    std::optional<std::string> artist     SWIFT_PRIVATE;
    std::optional<std::string> album     SWIFT_PRIVATE;
    std::optional<std::string> artworkUri     SWIFT_PRIVATE;
    std::optional<double> duration     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<double> endPositionMs     SWIFT_PRIVATE;

  public:
    MediaItemConfig() = default;
    explicit MediaItemConfig(std::string uri, MediaType mediaType, std::optional<std::string> mimeType, std::optional<std::string> title, std::optional<std::string> artist, std::optional<std::string> album, std::optional<std::string> artworkUri, std::optional<double> duration, 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<double> endPositionMs): uri(uri), mediaType(mediaType), mimeType(mimeType), title(title), artist(artist), album(album), artworkUri(artworkUri), duration(duration), headers(headers), drmType(drmType), drmLicenseUri(drmLicenseUri), drmHeaders(drmHeaders), startPositionMs(startPositionMs), endPositionMs(endPositionMs) {}

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

} // namespace margelo::nitro::aviation

namespace margelo::nitro {

  // C++ MediaItemConfig <> JS MediaItemConfig (object)
  template <>
  struct JSIConverter<margelo::nitro::aviation::MediaItemConfig> final {
    static inline margelo::nitro::aviation::MediaItemConfig fromJSI(jsi::Runtime& runtime, const jsi::Value& arg) {
      jsi::Object obj = arg.asObject(runtime);
      return margelo::nitro::aviation::MediaItemConfig(
        JSIConverter<std::string>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "uri"))),
        JSIConverter<margelo::nitro::aviation::MediaType>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "mediaType"))),
        JSIConverter<std::optional<std::string>>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "mimeType"))),
        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, "album"))),
        JSIConverter<std::optional<std::string>>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "artworkUri"))),
        JSIConverter<std::optional<double>>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "duration"))),
        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<double>>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "endPositionMs")))
      );
    }
    static inline jsi::Value toJSI(jsi::Runtime& runtime, const margelo::nitro::aviation::MediaItemConfig& 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::MediaType>::toJSI(runtime, arg.mediaType));
      obj.setProperty(runtime, PropNameIDCache::get(runtime, "mimeType"), JSIConverter<std::optional<std::string>>::toJSI(runtime, arg.mimeType));
      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, "album"), JSIConverter<std::optional<std::string>>::toJSI(runtime, arg.album));
      obj.setProperty(runtime, PropNameIDCache::get(runtime, "artworkUri"), JSIConverter<std::optional<std::string>>::toJSI(runtime, arg.artworkUri));
      obj.setProperty(runtime, PropNameIDCache::get(runtime, "duration"), JSIConverter<std::optional<double>>::toJSI(runtime, arg.duration));
      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, "endPositionMs"), JSIConverter<std::optional<double>>::toJSI(runtime, arg.endPositionMs));
      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::MediaType>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "mediaType")))) return false;
      if (!JSIConverter<std::optional<std::string>>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "mimeType")))) 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, "album")))) return false;
      if (!JSIConverter<std::optional<std::string>>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "artworkUri")))) return false;
      if (!JSIConverter<std::optional<double>>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "duration")))) 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<double>>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "endPositionMs")))) return false;
      return true;
    }
  };

} // namespace margelo::nitro
