///
/// RecorderSettings.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 `HybridLocationSpec` to properly resolve imports.
namespace margelo::nitro::camera { class HybridLocationSpec; }

#include <memory>
#include "HybridLocationSpec.hpp"
#include <optional>
#include <string>

namespace margelo::nitro::camera {

  /**
   * A struct which can be represented as a JavaScript object (RecorderSettings).
   */
  struct RecorderSettings final {
  public:
    std::optional<std::shared_ptr<HybridLocationSpec>> location     SWIFT_PRIVATE;
    std::optional<std::string> filePath     SWIFT_PRIVATE;
    std::optional<double> maxDuration     SWIFT_PRIVATE;
    std::optional<double> maxFileSize     SWIFT_PRIVATE;

  public:
    RecorderSettings() = default;
    explicit RecorderSettings(std::optional<std::shared_ptr<HybridLocationSpec>> location, std::optional<std::string> filePath, std::optional<double> maxDuration, std::optional<double> maxFileSize): location(location), filePath(filePath), maxDuration(maxDuration), maxFileSize(maxFileSize) {}

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

} // namespace margelo::nitro::camera

namespace margelo::nitro {

  // C++ RecorderSettings <> JS RecorderSettings (object)
  template <>
  struct JSIConverter<margelo::nitro::camera::RecorderSettings> final {
    static inline margelo::nitro::camera::RecorderSettings fromJSI(jsi::Runtime& runtime, const jsi::Value& arg) {
      jsi::Object obj = arg.asObject(runtime);
      return margelo::nitro::camera::RecorderSettings(
        JSIConverter<std::optional<std::shared_ptr<margelo::nitro::camera::HybridLocationSpec>>>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "location"))),
        JSIConverter<std::optional<std::string>>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "filePath"))),
        JSIConverter<std::optional<double>>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "maxDuration"))),
        JSIConverter<std::optional<double>>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "maxFileSize")))
      );
    }
    static inline jsi::Value toJSI(jsi::Runtime& runtime, const margelo::nitro::camera::RecorderSettings& arg) {
      jsi::Object obj(runtime);
      obj.setProperty(runtime, PropNameIDCache::get(runtime, "location"), JSIConverter<std::optional<std::shared_ptr<margelo::nitro::camera::HybridLocationSpec>>>::toJSI(runtime, arg.location));
      obj.setProperty(runtime, PropNameIDCache::get(runtime, "filePath"), JSIConverter<std::optional<std::string>>::toJSI(runtime, arg.filePath));
      obj.setProperty(runtime, PropNameIDCache::get(runtime, "maxDuration"), JSIConverter<std::optional<double>>::toJSI(runtime, arg.maxDuration));
      obj.setProperty(runtime, PropNameIDCache::get(runtime, "maxFileSize"), JSIConverter<std::optional<double>>::toJSI(runtime, arg.maxFileSize));
      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::optional<std::shared_ptr<margelo::nitro::camera::HybridLocationSpec>>>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "location")))) return false;
      if (!JSIConverter<std::optional<std::string>>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "filePath")))) return false;
      if (!JSIConverter<std::optional<double>>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "maxDuration")))) return false;
      if (!JSIConverter<std::optional<double>>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "maxFileSize")))) return false;
      return true;
    }
  };

} // namespace margelo::nitro
