///
/// MapRoute.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/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
#if __has_include(<NitroModules/JSIHelpers.hpp>)
#include <NitroModules/JSIHelpers.hpp>
#else
#error NitroModules cannot be found! Are you sure you installed NitroModules properly?
#endif
#if __has_include(<NitroModules/PropNameIDCache.hpp>)
#include <NitroModules/PropNameIDCache.hpp>
#else
#error NitroModules cannot be found! Are you sure you installed NitroModules properly?
#endif

// Forward declaration of `MapCoordinate` to properly resolve imports.
namespace margelo::nitro::one { struct MapCoordinate; }
// Forward declaration of `MapRouteStep` to properly resolve imports.
namespace margelo::nitro::one { struct MapRouteStep; }

#include "MapCoordinate.hpp"
#include <vector>
#include "MapRouteStep.hpp"

namespace margelo::nitro::one {

  /**
   * A struct which can be represented as a JavaScript object (MapRoute).
   */
  struct MapRoute final {
  public:
    double distanceMeters     SWIFT_PRIVATE;
    double expectedTravelTimeSeconds     SWIFT_PRIVATE;
    std::vector<MapCoordinate> polyline     SWIFT_PRIVATE;
    std::vector<MapRouteStep> steps     SWIFT_PRIVATE;

  public:
    MapRoute() = default;
    explicit MapRoute(double distanceMeters, double expectedTravelTimeSeconds, std::vector<MapCoordinate> polyline, std::vector<MapRouteStep> steps): distanceMeters(distanceMeters), expectedTravelTimeSeconds(expectedTravelTimeSeconds), polyline(polyline), steps(steps) {}

  public:
    friend bool operator==(const MapRoute& lhs, const MapRoute& rhs) = default;
  };

} // namespace margelo::nitro::one

namespace margelo::nitro {

  // C++ MapRoute <> JS MapRoute (object)
  template <>
  struct JSIConverter<margelo::nitro::one::MapRoute> final {
    static inline margelo::nitro::one::MapRoute fromJSI(jsi::Runtime& runtime, const jsi::Value& arg) {
      jsi::Object obj = arg.asObject(runtime);
      return margelo::nitro::one::MapRoute(
        JSIConverter<double>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "distanceMeters"))),
        JSIConverter<double>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "expectedTravelTimeSeconds"))),
        JSIConverter<std::vector<margelo::nitro::one::MapCoordinate>>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "polyline"))),
        JSIConverter<std::vector<margelo::nitro::one::MapRouteStep>>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "steps")))
      );
    }
    static inline jsi::Value toJSI(jsi::Runtime& runtime, const margelo::nitro::one::MapRoute& arg) {
      jsi::Object obj(runtime);
      obj.setProperty(runtime, PropNameIDCache::get(runtime, "distanceMeters"), JSIConverter<double>::toJSI(runtime, arg.distanceMeters));
      obj.setProperty(runtime, PropNameIDCache::get(runtime, "expectedTravelTimeSeconds"), JSIConverter<double>::toJSI(runtime, arg.expectedTravelTimeSeconds));
      obj.setProperty(runtime, PropNameIDCache::get(runtime, "polyline"), JSIConverter<std::vector<margelo::nitro::one::MapCoordinate>>::toJSI(runtime, arg.polyline));
      obj.setProperty(runtime, PropNameIDCache::get(runtime, "steps"), JSIConverter<std::vector<margelo::nitro::one::MapRouteStep>>::toJSI(runtime, arg.steps));
      return obj;
    }
    static inline bool canConvert(jsi::Runtime& runtime, const jsi::Value& value) {
      if (!value.isObject()) {
        return false;
      }
      jsi::Object obj = value.getObject(runtime);
      if (!nitro::isPlainObject(runtime, obj)) {
        return false;
      }
      if (!JSIConverter<double>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "distanceMeters")))) return false;
      if (!JSIConverter<double>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "expectedTravelTimeSeconds")))) return false;
      if (!JSIConverter<std::vector<margelo::nitro::one::MapCoordinate>>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "polyline")))) return false;
      if (!JSIConverter<std::vector<margelo::nitro::one::MapRouteStep>>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "steps")))) return false;
      return true;
    }
  };

} // namespace margelo::nitro
