///
/// VideoSrc.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



#include <string>
#include <optional>
#include <unordered_map>

namespace margelo::nitro::omni {

  /**
   * A struct which can be represented as a JavaScript object (VideoSrc).
   */
  struct VideoSrc final {
  public:
    std::string uri     SWIFT_PRIVATE;
    std::optional<std::string> mimeType     SWIFT_PRIVATE;
    std::unordered_map<std::string, std::string> headers     SWIFT_PRIVATE;

  public:
    VideoSrc() = default;
    explicit VideoSrc(std::string uri, std::optional<std::string> mimeType, std::unordered_map<std::string, std::string> headers): uri(uri), mimeType(mimeType), headers(headers) {}

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

} // namespace margelo::nitro::omni

namespace margelo::nitro {

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

} // namespace margelo::nitro
