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

#include "AudioSessionCategory.hpp"
#include <optional>
#include "AudioSessionMode.hpp"
#include "AudioCoexistence.hpp"

namespace margelo::nitro::aviation {

  /**
   * A struct which can be represented as a JavaScript object (AudioSessionConfig).
   */
  struct AudioSessionConfig final {
  public:
    std::optional<AudioSessionCategory> category     SWIFT_PRIVATE;
    std::optional<AudioSessionMode> mode     SWIFT_PRIVATE;
    std::optional<AudioCoexistence> coexistence     SWIFT_PRIVATE;
    std::optional<bool> allowBluetooth     SWIFT_PRIVATE;
    std::optional<bool> allowAirPlay     SWIFT_PRIVATE;

  public:
    AudioSessionConfig() = default;
    explicit AudioSessionConfig(std::optional<AudioSessionCategory> category, std::optional<AudioSessionMode> mode, std::optional<AudioCoexistence> coexistence, std::optional<bool> allowBluetooth, std::optional<bool> allowAirPlay): category(category), mode(mode), coexistence(coexistence), allowBluetooth(allowBluetooth), allowAirPlay(allowAirPlay) {}

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

} // namespace margelo::nitro::aviation

namespace margelo::nitro {

  // C++ AudioSessionConfig <> JS AudioSessionConfig (object)
  template <>
  struct JSIConverter<margelo::nitro::aviation::AudioSessionConfig> final {
    static inline margelo::nitro::aviation::AudioSessionConfig fromJSI(jsi::Runtime& runtime, const jsi::Value& arg) {
      jsi::Object obj = arg.asObject(runtime);
      return margelo::nitro::aviation::AudioSessionConfig(
        JSIConverter<std::optional<margelo::nitro::aviation::AudioSessionCategory>>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "category"))),
        JSIConverter<std::optional<margelo::nitro::aviation::AudioSessionMode>>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "mode"))),
        JSIConverter<std::optional<margelo::nitro::aviation::AudioCoexistence>>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "coexistence"))),
        JSIConverter<std::optional<bool>>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "allowBluetooth"))),
        JSIConverter<std::optional<bool>>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "allowAirPlay")))
      );
    }
    static inline jsi::Value toJSI(jsi::Runtime& runtime, const margelo::nitro::aviation::AudioSessionConfig& arg) {
      jsi::Object obj(runtime);
      obj.setProperty(runtime, PropNameIDCache::get(runtime, "category"), JSIConverter<std::optional<margelo::nitro::aviation::AudioSessionCategory>>::toJSI(runtime, arg.category));
      obj.setProperty(runtime, PropNameIDCache::get(runtime, "mode"), JSIConverter<std::optional<margelo::nitro::aviation::AudioSessionMode>>::toJSI(runtime, arg.mode));
      obj.setProperty(runtime, PropNameIDCache::get(runtime, "coexistence"), JSIConverter<std::optional<margelo::nitro::aviation::AudioCoexistence>>::toJSI(runtime, arg.coexistence));
      obj.setProperty(runtime, PropNameIDCache::get(runtime, "allowBluetooth"), JSIConverter<std::optional<bool>>::toJSI(runtime, arg.allowBluetooth));
      obj.setProperty(runtime, PropNameIDCache::get(runtime, "allowAirPlay"), JSIConverter<std::optional<bool>>::toJSI(runtime, arg.allowAirPlay));
      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<margelo::nitro::aviation::AudioSessionCategory>>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "category")))) return false;
      if (!JSIConverter<std::optional<margelo::nitro::aviation::AudioSessionMode>>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "mode")))) return false;
      if (!JSIConverter<std::optional<margelo::nitro::aviation::AudioCoexistence>>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "coexistence")))) return false;
      if (!JSIConverter<std::optional<bool>>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "allowBluetooth")))) return false;
      if (!JSIConverter<std::optional<bool>>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "allowAirPlay")))) return false;
      return true;
    }
  };

} // namespace margelo::nitro
