///
/// TargetColorSpace.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 (TargetColorSpace).
   */
  enum class TargetColorSpace {
    SRGB      SWIFT_NAME(srgb) = 0,
    DOLBY_VISION      SWIFT_NAME(dolbyVision) = 1,
    P3_D65      SWIFT_NAME(p3D65) = 2,
    HLG_BT2020      SWIFT_NAME(hlgBt2020) = 3,
    APPLE_LOG      SWIFT_NAME(appleLog) = 4,
    APPLE_LOG_2      SWIFT_NAME(appleLog2) = 5,
  } CLOSED_ENUM;

} // namespace margelo::nitro::camera

namespace margelo::nitro {

  // C++ TargetColorSpace <> JS TargetColorSpace (union)
  template <>
  struct JSIConverter<margelo::nitro::camera::TargetColorSpace> final {
    static inline margelo::nitro::camera::TargetColorSpace 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("srgb"): return margelo::nitro::camera::TargetColorSpace::SRGB;
        case hashString("dolby-vision"): return margelo::nitro::camera::TargetColorSpace::DOLBY_VISION;
        case hashString("p3-d65"): return margelo::nitro::camera::TargetColorSpace::P3_D65;
        case hashString("hlg-bt2020"): return margelo::nitro::camera::TargetColorSpace::HLG_BT2020;
        case hashString("apple-log"): return margelo::nitro::camera::TargetColorSpace::APPLE_LOG;
        case hashString("apple-log-2"): return margelo::nitro::camera::TargetColorSpace::APPLE_LOG_2;
        default: [[unlikely]]
          throw std::invalid_argument("Cannot convert \"" + unionValue + "\" to enum TargetColorSpace - invalid value!");
      }
    }
    static inline jsi::Value toJSI(jsi::Runtime& runtime, margelo::nitro::camera::TargetColorSpace arg) {
      switch (arg) {
        case margelo::nitro::camera::TargetColorSpace::SRGB: return JSIConverter<std::string>::toJSI(runtime, "srgb");
        case margelo::nitro::camera::TargetColorSpace::DOLBY_VISION: return JSIConverter<std::string>::toJSI(runtime, "dolby-vision");
        case margelo::nitro::camera::TargetColorSpace::P3_D65: return JSIConverter<std::string>::toJSI(runtime, "p3-d65");
        case margelo::nitro::camera::TargetColorSpace::HLG_BT2020: return JSIConverter<std::string>::toJSI(runtime, "hlg-bt2020");
        case margelo::nitro::camera::TargetColorSpace::APPLE_LOG: return JSIConverter<std::string>::toJSI(runtime, "apple-log");
        case margelo::nitro::camera::TargetColorSpace::APPLE_LOG_2: return JSIConverter<std::string>::toJSI(runtime, "apple-log-2");
        default: [[unlikely]]
          throw std::invalid_argument("Cannot convert TargetColorSpace 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("srgb"):
        case hashString("dolby-vision"):
        case hashString("p3-d65"):
        case hashString("hlg-bt2020"):
        case hashString("apple-log"):
        case hashString("apple-log-2"):
          return true;
        default:
          return false;
      }
    }
  };

} // namespace margelo::nitro
