///
/// RouteChangeReason.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::aviation {

  /**
   * An enum which can be represented as a JavaScript union (RouteChangeReason).
   */
  enum class RouteChangeReason {
    NEWDEVICEAVAILABLE      SWIFT_NAME(newdeviceavailable) = 0,
    OLDDEVICEUNAVAILABLE      SWIFT_NAME(olddeviceunavailable) = 1,
    CATEGORYCHANGE      SWIFT_NAME(categorychange) = 2,
    OVERRIDE      SWIFT_NAME(override) = 3,
    UNKNOWN      SWIFT_NAME(unknown) = 4,
  } CLOSED_ENUM;

} // namespace margelo::nitro::aviation

namespace margelo::nitro {

  // C++ RouteChangeReason <> JS RouteChangeReason (union)
  template <>
  struct JSIConverter<margelo::nitro::aviation::RouteChangeReason> final {
    static inline margelo::nitro::aviation::RouteChangeReason 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("newDeviceAvailable"): return margelo::nitro::aviation::RouteChangeReason::NEWDEVICEAVAILABLE;
        case hashString("oldDeviceUnavailable"): return margelo::nitro::aviation::RouteChangeReason::OLDDEVICEUNAVAILABLE;
        case hashString("categoryChange"): return margelo::nitro::aviation::RouteChangeReason::CATEGORYCHANGE;
        case hashString("override"): return margelo::nitro::aviation::RouteChangeReason::OVERRIDE;
        case hashString("unknown"): return margelo::nitro::aviation::RouteChangeReason::UNKNOWN;
        default: [[unlikely]]
          throw std::invalid_argument("Cannot convert \"" + unionValue + "\" to enum RouteChangeReason - invalid value!");
      }
    }
    static inline jsi::Value toJSI(jsi::Runtime& runtime, margelo::nitro::aviation::RouteChangeReason arg) {
      switch (arg) {
        case margelo::nitro::aviation::RouteChangeReason::NEWDEVICEAVAILABLE: return JSIConverter<std::string>::toJSI(runtime, "newDeviceAvailable");
        case margelo::nitro::aviation::RouteChangeReason::OLDDEVICEUNAVAILABLE: return JSIConverter<std::string>::toJSI(runtime, "oldDeviceUnavailable");
        case margelo::nitro::aviation::RouteChangeReason::CATEGORYCHANGE: return JSIConverter<std::string>::toJSI(runtime, "categoryChange");
        case margelo::nitro::aviation::RouteChangeReason::OVERRIDE: return JSIConverter<std::string>::toJSI(runtime, "override");
        case margelo::nitro::aviation::RouteChangeReason::UNKNOWN: return JSIConverter<std::string>::toJSI(runtime, "unknown");
        default: [[unlikely]]
          throw std::invalid_argument("Cannot convert RouteChangeReason 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("newDeviceAvailable"):
        case hashString("oldDeviceUnavailable"):
        case hashString("categoryChange"):
        case hashString("override"):
        case hashString("unknown"):
          return true;
        default:
          return false;
      }
    }
  };

} // namespace margelo::nitro
