///
/// AVEncodingOption.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/NitroHash.hpp>)
#include <NitroModules/NitroHash.hpp>
#else
#error NitroModules cannot be found! Are you sure you installed NitroModules properly?
#endif
#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

namespace margelo::nitro::sound {

  /**
   * An enum which can be represented as a JavaScript union (AVEncodingOption).
   */
  enum class AVEncodingOption {
    LPCM      SWIFT_NAME(lpcm) = 0,
    IMA4      SWIFT_NAME(ima4) = 1,
    AAC      SWIFT_NAME(aac) = 2,
    MAC3      SWIFT_NAME(mac3) = 3,
    MAC6      SWIFT_NAME(mac6) = 4,
    ULAW      SWIFT_NAME(ulaw) = 5,
    ALAW      SWIFT_NAME(alaw) = 6,
    MP1      SWIFT_NAME(mp1) = 7,
    MP2      SWIFT_NAME(mp2) = 8,
    MP4      SWIFT_NAME(mp4) = 9,
    ALAC      SWIFT_NAME(alac) = 10,
    AMR      SWIFT_NAME(amr) = 11,
    FLAC      SWIFT_NAME(flac) = 12,
    OPUS      SWIFT_NAME(opus) = 13,
  } CLOSED_ENUM;

} // namespace margelo::nitro::sound

namespace margelo::nitro {

  // C++ AVEncodingOption <> JS AVEncodingOption (union)
  template <>
  struct JSIConverter<margelo::nitro::sound::AVEncodingOption> final {
    static inline margelo::nitro::sound::AVEncodingOption fromJSI(jsi::Runtime& runtime, const jsi::Value& arg) {
      std::string unionValue = JSIConverter<std::string>::fromJSI(runtime, arg);
      switch (hashString(unionValue.c_str(), unionValue.size())) {
        case hashString("lpcm"): return margelo::nitro::sound::AVEncodingOption::LPCM;
        case hashString("ima4"): return margelo::nitro::sound::AVEncodingOption::IMA4;
        case hashString("aac"): return margelo::nitro::sound::AVEncodingOption::AAC;
        case hashString("MAC3"): return margelo::nitro::sound::AVEncodingOption::MAC3;
        case hashString("MAC6"): return margelo::nitro::sound::AVEncodingOption::MAC6;
        case hashString("ulaw"): return margelo::nitro::sound::AVEncodingOption::ULAW;
        case hashString("alaw"): return margelo::nitro::sound::AVEncodingOption::ALAW;
        case hashString("mp1"): return margelo::nitro::sound::AVEncodingOption::MP1;
        case hashString("mp2"): return margelo::nitro::sound::AVEncodingOption::MP2;
        case hashString("mp4"): return margelo::nitro::sound::AVEncodingOption::MP4;
        case hashString("alac"): return margelo::nitro::sound::AVEncodingOption::ALAC;
        case hashString("amr"): return margelo::nitro::sound::AVEncodingOption::AMR;
        case hashString("flac"): return margelo::nitro::sound::AVEncodingOption::FLAC;
        case hashString("opus"): return margelo::nitro::sound::AVEncodingOption::OPUS;
        default: [[unlikely]]
          throw std::invalid_argument("Cannot convert \"" + unionValue + "\" to enum AVEncodingOption - invalid value!");
      }
    }
    static inline jsi::Value toJSI(jsi::Runtime& runtime, margelo::nitro::sound::AVEncodingOption arg) {
      switch (arg) {
        case margelo::nitro::sound::AVEncodingOption::LPCM: return JSIConverter<std::string>::toJSI(runtime, "lpcm");
        case margelo::nitro::sound::AVEncodingOption::IMA4: return JSIConverter<std::string>::toJSI(runtime, "ima4");
        case margelo::nitro::sound::AVEncodingOption::AAC: return JSIConverter<std::string>::toJSI(runtime, "aac");
        case margelo::nitro::sound::AVEncodingOption::MAC3: return JSIConverter<std::string>::toJSI(runtime, "MAC3");
        case margelo::nitro::sound::AVEncodingOption::MAC6: return JSIConverter<std::string>::toJSI(runtime, "MAC6");
        case margelo::nitro::sound::AVEncodingOption::ULAW: return JSIConverter<std::string>::toJSI(runtime, "ulaw");
        case margelo::nitro::sound::AVEncodingOption::ALAW: return JSIConverter<std::string>::toJSI(runtime, "alaw");
        case margelo::nitro::sound::AVEncodingOption::MP1: return JSIConverter<std::string>::toJSI(runtime, "mp1");
        case margelo::nitro::sound::AVEncodingOption::MP2: return JSIConverter<std::string>::toJSI(runtime, "mp2");
        case margelo::nitro::sound::AVEncodingOption::MP4: return JSIConverter<std::string>::toJSI(runtime, "mp4");
        case margelo::nitro::sound::AVEncodingOption::ALAC: return JSIConverter<std::string>::toJSI(runtime, "alac");
        case margelo::nitro::sound::AVEncodingOption::AMR: return JSIConverter<std::string>::toJSI(runtime, "amr");
        case margelo::nitro::sound::AVEncodingOption::FLAC: return JSIConverter<std::string>::toJSI(runtime, "flac");
        case margelo::nitro::sound::AVEncodingOption::OPUS: return JSIConverter<std::string>::toJSI(runtime, "opus");
        default: [[unlikely]]
          throw std::invalid_argument("Cannot convert AVEncodingOption to JS - invalid value: "
                                    + std::to_string(static_cast<int>(arg)) + "!");
      }
    }
    static inline bool canConvert(jsi::Runtime& runtime, const jsi::Value& value) {
      if (!value.isString()) {
        return false;
      }
      std::string unionValue = JSIConverter<std::string>::fromJSI(runtime, value);
      switch (hashString(unionValue.c_str(), unionValue.size())) {
        case hashString("lpcm"):
        case hashString("ima4"):
        case hashString("aac"):
        case hashString("MAC3"):
        case hashString("MAC6"):
        case hashString("ulaw"):
        case hashString("alaw"):
        case hashString("mp1"):
        case hashString("mp2"):
        case hashString("mp4"):
        case hashString("alac"):
        case hashString("amr"):
        case hashString("flac"):
        case hashString("opus"):
          return true;
        default:
          return false;
      }
    }
  };

} // namespace margelo::nitro
