///
/// PhotoContainerFormat.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 (PhotoContainerFormat).
   */
  enum class PhotoContainerFormat {
    UNKNOWN      SWIFT_NAME(unknown) = 0,
    JPEG      SWIFT_NAME(jpeg) = 1,
    HEIC      SWIFT_NAME(heic) = 2,
    DNG      SWIFT_NAME(dng) = 3,
    TIFF      SWIFT_NAME(tiff) = 4,
    DCM      SWIFT_NAME(dcm) = 5,
  } CLOSED_ENUM;

} // namespace margelo::nitro::camera

namespace margelo::nitro {

  // C++ PhotoContainerFormat <> JS PhotoContainerFormat (union)
  template <>
  struct JSIConverter<margelo::nitro::camera::PhotoContainerFormat> final {
    static inline margelo::nitro::camera::PhotoContainerFormat 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::PhotoContainerFormat::UNKNOWN;
        case hashString("jpeg"): return margelo::nitro::camera::PhotoContainerFormat::JPEG;
        case hashString("heic"): return margelo::nitro::camera::PhotoContainerFormat::HEIC;
        case hashString("dng"): return margelo::nitro::camera::PhotoContainerFormat::DNG;
        case hashString("tiff"): return margelo::nitro::camera::PhotoContainerFormat::TIFF;
        case hashString("dcm"): return margelo::nitro::camera::PhotoContainerFormat::DCM;
        default: [[unlikely]]
          throw std::invalid_argument("Cannot convert \"" + unionValue + "\" to enum PhotoContainerFormat - invalid value!");
      }
    }
    static inline jsi::Value toJSI(jsi::Runtime& runtime, margelo::nitro::camera::PhotoContainerFormat arg) {
      switch (arg) {
        case margelo::nitro::camera::PhotoContainerFormat::UNKNOWN: return JSIConverter<std::string>::toJSI(runtime, "unknown");
        case margelo::nitro::camera::PhotoContainerFormat::JPEG: return JSIConverter<std::string>::toJSI(runtime, "jpeg");
        case margelo::nitro::camera::PhotoContainerFormat::HEIC: return JSIConverter<std::string>::toJSI(runtime, "heic");
        case margelo::nitro::camera::PhotoContainerFormat::DNG: return JSIConverter<std::string>::toJSI(runtime, "dng");
        case margelo::nitro::camera::PhotoContainerFormat::TIFF: return JSIConverter<std::string>::toJSI(runtime, "tiff");
        case margelo::nitro::camera::PhotoContainerFormat::DCM: return JSIConverter<std::string>::toJSI(runtime, "dcm");
        default: [[unlikely]]
          throw std::invalid_argument("Cannot convert PhotoContainerFormat 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("heic"):
        case hashString("dng"):
        case hashString("tiff"):
        case hashString("dcm"):
          return true;
        default:
          return false;
      }
    }
  };

} // namespace margelo::nitro
