///
/// ContactUINameKey.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::one {

  /**
   * An enum which can be represented as a JavaScript union (ContactUINameKey).
   */
  enum class ContactUINameKey {
    NAMEPREFIX      SWIFT_NAME(nameprefix) = 0,
    GIVENNAME      SWIFT_NAME(givenname) = 1,
    MIDDLENAME      SWIFT_NAME(middlename) = 2,
    FAMILYNAME      SWIFT_NAME(familyname) = 3,
    NAMESUFFIX      SWIFT_NAME(namesuffix) = 4,
    NICKNAME      SWIFT_NAME(nickname) = 5,
    ORGANIZATIONNAME      SWIFT_NAME(organizationname) = 6,
    JOBTITLE      SWIFT_NAME(jobtitle) = 7,
  } CLOSED_ENUM;

} // namespace margelo::nitro::one

namespace margelo::nitro {

  // C++ ContactUINameKey <> JS ContactUINameKey (union)
  template <>
  struct JSIConverter<margelo::nitro::one::ContactUINameKey> final {
    static inline margelo::nitro::one::ContactUINameKey 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("namePrefix"): return margelo::nitro::one::ContactUINameKey::NAMEPREFIX;
        case hashString("givenName"): return margelo::nitro::one::ContactUINameKey::GIVENNAME;
        case hashString("middleName"): return margelo::nitro::one::ContactUINameKey::MIDDLENAME;
        case hashString("familyName"): return margelo::nitro::one::ContactUINameKey::FAMILYNAME;
        case hashString("nameSuffix"): return margelo::nitro::one::ContactUINameKey::NAMESUFFIX;
        case hashString("nickname"): return margelo::nitro::one::ContactUINameKey::NICKNAME;
        case hashString("organizationName"): return margelo::nitro::one::ContactUINameKey::ORGANIZATIONNAME;
        case hashString("jobTitle"): return margelo::nitro::one::ContactUINameKey::JOBTITLE;
        default: [[unlikely]]
          throw std::invalid_argument("Cannot convert \"" + unionValue + "\" to enum ContactUINameKey - invalid value!");
      }
    }
    static inline jsi::Value toJSI(jsi::Runtime& runtime, margelo::nitro::one::ContactUINameKey arg) {
      switch (arg) {
        case margelo::nitro::one::ContactUINameKey::NAMEPREFIX: return JSIConverter<std::string>::toJSI(runtime, "namePrefix");
        case margelo::nitro::one::ContactUINameKey::GIVENNAME: return JSIConverter<std::string>::toJSI(runtime, "givenName");
        case margelo::nitro::one::ContactUINameKey::MIDDLENAME: return JSIConverter<std::string>::toJSI(runtime, "middleName");
        case margelo::nitro::one::ContactUINameKey::FAMILYNAME: return JSIConverter<std::string>::toJSI(runtime, "familyName");
        case margelo::nitro::one::ContactUINameKey::NAMESUFFIX: return JSIConverter<std::string>::toJSI(runtime, "nameSuffix");
        case margelo::nitro::one::ContactUINameKey::NICKNAME: return JSIConverter<std::string>::toJSI(runtime, "nickname");
        case margelo::nitro::one::ContactUINameKey::ORGANIZATIONNAME: return JSIConverter<std::string>::toJSI(runtime, "organizationName");
        case margelo::nitro::one::ContactUINameKey::JOBTITLE: return JSIConverter<std::string>::toJSI(runtime, "jobTitle");
        default: [[unlikely]]
          throw std::invalid_argument("Cannot convert ContactUINameKey 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("namePrefix"):
        case hashString("givenName"):
        case hashString("middleName"):
        case hashString("familyName"):
        case hashString("nameSuffix"):
        case hashString("nickname"):
        case hashString("organizationName"):
        case hashString("jobTitle"):
          return true;
        default:
          return false;
      }
    }
  };

} // namespace margelo::nitro
