///
/// AccessControl.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::sensitiveinfo {

  /**
   * An enum which can be represented as a JavaScript union (AccessControl).
   */
  enum class AccessControl {
    SECUREENCLAVEBIOMETRY      SWIFT_NAME(secureenclavebiometry) = 0,
    BIOMETRYCURRENTSET      SWIFT_NAME(biometrycurrentset) = 1,
    BIOMETRYANY      SWIFT_NAME(biometryany) = 2,
    DEVICEPASSCODE      SWIFT_NAME(devicepasscode) = 3,
    NONE      SWIFT_NAME(none) = 4,
  } CLOSED_ENUM;

} // namespace margelo::nitro::sensitiveinfo

namespace margelo::nitro {

  // C++ AccessControl <> JS AccessControl (union)
  template <>
  struct JSIConverter<margelo::nitro::sensitiveinfo::AccessControl> final {
    static inline margelo::nitro::sensitiveinfo::AccessControl 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("secureEnclaveBiometry"): return margelo::nitro::sensitiveinfo::AccessControl::SECUREENCLAVEBIOMETRY;
        case hashString("biometryCurrentSet"): return margelo::nitro::sensitiveinfo::AccessControl::BIOMETRYCURRENTSET;
        case hashString("biometryAny"): return margelo::nitro::sensitiveinfo::AccessControl::BIOMETRYANY;
        case hashString("devicePasscode"): return margelo::nitro::sensitiveinfo::AccessControl::DEVICEPASSCODE;
        case hashString("none"): return margelo::nitro::sensitiveinfo::AccessControl::NONE;
        default: [[unlikely]]
          throw std::invalid_argument("Cannot convert \"" + unionValue + "\" to enum AccessControl - invalid value!");
      }
    }
    static inline jsi::Value toJSI(jsi::Runtime& runtime, margelo::nitro::sensitiveinfo::AccessControl arg) {
      switch (arg) {
        case margelo::nitro::sensitiveinfo::AccessControl::SECUREENCLAVEBIOMETRY: return JSIConverter<std::string>::toJSI(runtime, "secureEnclaveBiometry");
        case margelo::nitro::sensitiveinfo::AccessControl::BIOMETRYCURRENTSET: return JSIConverter<std::string>::toJSI(runtime, "biometryCurrentSet");
        case margelo::nitro::sensitiveinfo::AccessControl::BIOMETRYANY: return JSIConverter<std::string>::toJSI(runtime, "biometryAny");
        case margelo::nitro::sensitiveinfo::AccessControl::DEVICEPASSCODE: return JSIConverter<std::string>::toJSI(runtime, "devicePasscode");
        case margelo::nitro::sensitiveinfo::AccessControl::NONE: return JSIConverter<std::string>::toJSI(runtime, "none");
        default: [[unlikely]]
          throw std::invalid_argument("Cannot convert AccessControl 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("secureEnclaveBiometry"):
        case hashString("biometryCurrentSet"):
        case hashString("biometryAny"):
        case hashString("devicePasscode"):
        case hashString("none"):
          return true;
        default:
          return false;
      }
    }
  };

} // namespace margelo::nitro
