///
/// VideoCodec.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::camera {

  /**
   * An enum which can be represented as a JavaScript union (VideoCodec).
   */
  enum class VideoCodec {
    UNKNOWN      SWIFT_NAME(unknown) = 0,
    JPEG      SWIFT_NAME(jpeg) = 1,
    H264      SWIFT_NAME(h264) = 2,
    H265      SWIFT_NAME(h265) = 3,
    H265_WITH_ALPHA      SWIFT_NAME(h265WithAlpha) = 4,
    PRO_RES_422_PROXY      SWIFT_NAME(proRes422Proxy) = 5,
    PRO_RES_422_LT      SWIFT_NAME(proRes422Lt) = 6,
    PRO_RES_422      SWIFT_NAME(proRes422) = 7,
    PRO_RES_422_HQ      SWIFT_NAME(proRes422Hq) = 8,
    PRO_RES_4444      SWIFT_NAME(proRes4444) = 9,
    PRO_RES_4444_XQ      SWIFT_NAME(proRes4444Xq) = 10,
    PRO_RES_RAW      SWIFT_NAME(proResRaw) = 11,
    PRO_RES_RAW_HQ      SWIFT_NAME(proResRawHq) = 12,
  } CLOSED_ENUM;

} // namespace margelo::nitro::camera

namespace margelo::nitro {

  // C++ VideoCodec <> JS VideoCodec (union)
  template <>
  struct JSIConverter<margelo::nitro::camera::VideoCodec> final {
    static inline margelo::nitro::camera::VideoCodec 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("unknown"): return margelo::nitro::camera::VideoCodec::UNKNOWN;
        case hashString("jpeg"): return margelo::nitro::camera::VideoCodec::JPEG;
        case hashString("h264"): return margelo::nitro::camera::VideoCodec::H264;
        case hashString("h265"): return margelo::nitro::camera::VideoCodec::H265;
        case hashString("h265-with-alpha"): return margelo::nitro::camera::VideoCodec::H265_WITH_ALPHA;
        case hashString("pro-res-422-proxy"): return margelo::nitro::camera::VideoCodec::PRO_RES_422_PROXY;
        case hashString("pro-res-422-lt"): return margelo::nitro::camera::VideoCodec::PRO_RES_422_LT;
        case hashString("pro-res-422"): return margelo::nitro::camera::VideoCodec::PRO_RES_422;
        case hashString("pro-res-422-hq"): return margelo::nitro::camera::VideoCodec::PRO_RES_422_HQ;
        case hashString("pro-res-4444"): return margelo::nitro::camera::VideoCodec::PRO_RES_4444;
        case hashString("pro-res-4444-xq"): return margelo::nitro::camera::VideoCodec::PRO_RES_4444_XQ;
        case hashString("pro-res-raw"): return margelo::nitro::camera::VideoCodec::PRO_RES_RAW;
        case hashString("pro-res-raw-hq"): return margelo::nitro::camera::VideoCodec::PRO_RES_RAW_HQ;
        default: [[unlikely]]
          throw std::invalid_argument("Cannot convert \"" + unionValue + "\" to enum VideoCodec - invalid value!");
      }
    }
    static inline jsi::Value toJSI(jsi::Runtime& runtime, margelo::nitro::camera::VideoCodec arg) {
      switch (arg) {
        case margelo::nitro::camera::VideoCodec::UNKNOWN: return JSIConverter<std::string>::toJSI(runtime, "unknown");
        case margelo::nitro::camera::VideoCodec::JPEG: return JSIConverter<std::string>::toJSI(runtime, "jpeg");
        case margelo::nitro::camera::VideoCodec::H264: return JSIConverter<std::string>::toJSI(runtime, "h264");
        case margelo::nitro::camera::VideoCodec::H265: return JSIConverter<std::string>::toJSI(runtime, "h265");
        case margelo::nitro::camera::VideoCodec::H265_WITH_ALPHA: return JSIConverter<std::string>::toJSI(runtime, "h265-with-alpha");
        case margelo::nitro::camera::VideoCodec::PRO_RES_422_PROXY: return JSIConverter<std::string>::toJSI(runtime, "pro-res-422-proxy");
        case margelo::nitro::camera::VideoCodec::PRO_RES_422_LT: return JSIConverter<std::string>::toJSI(runtime, "pro-res-422-lt");
        case margelo::nitro::camera::VideoCodec::PRO_RES_422: return JSIConverter<std::string>::toJSI(runtime, "pro-res-422");
        case margelo::nitro::camera::VideoCodec::PRO_RES_422_HQ: return JSIConverter<std::string>::toJSI(runtime, "pro-res-422-hq");
        case margelo::nitro::camera::VideoCodec::PRO_RES_4444: return JSIConverter<std::string>::toJSI(runtime, "pro-res-4444");
        case margelo::nitro::camera::VideoCodec::PRO_RES_4444_XQ: return JSIConverter<std::string>::toJSI(runtime, "pro-res-4444-xq");
        case margelo::nitro::camera::VideoCodec::PRO_RES_RAW: return JSIConverter<std::string>::toJSI(runtime, "pro-res-raw");
        case margelo::nitro::camera::VideoCodec::PRO_RES_RAW_HQ: return JSIConverter<std::string>::toJSI(runtime, "pro-res-raw-hq");
        default: [[unlikely]]
          throw std::invalid_argument("Cannot convert VideoCodec 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("unknown"):
        case hashString("jpeg"):
        case hashString("h264"):
        case hashString("h265"):
        case hashString("h265-with-alpha"):
        case hashString("pro-res-422-proxy"):
        case hashString("pro-res-422-lt"):
        case hashString("pro-res-422"):
        case hashString("pro-res-422-hq"):
        case hashString("pro-res-4444"):
        case hashString("pro-res-4444-xq"):
        case hashString("pro-res-raw"):
        case hashString("pro-res-raw-hq"):
          return true;
        default:
          return false;
      }
    }
  };

} // namespace margelo::nitro
