///
/// GenerationStats.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





namespace margelo::nitro::mlxreactnative {

  /**
   * A struct which can be represented as a JavaScript object (GenerationStats).
   */
  struct GenerationStats final {
  public:
    double tokenCount     SWIFT_PRIVATE;
    double tokensPerSecond     SWIFT_PRIVATE;
    double timeToFirstToken     SWIFT_PRIVATE;
    double totalTime     SWIFT_PRIVATE;
    double toolExecutionTime     SWIFT_PRIVATE;

  public:
    GenerationStats() = default;
    explicit GenerationStats(double tokenCount, double tokensPerSecond, double timeToFirstToken, double totalTime, double toolExecutionTime): tokenCount(tokenCount), tokensPerSecond(tokensPerSecond), timeToFirstToken(timeToFirstToken), totalTime(totalTime), toolExecutionTime(toolExecutionTime) {}

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

} // namespace margelo::nitro::mlxreactnative

namespace margelo::nitro {

  // C++ GenerationStats <> JS GenerationStats (object)
  template <>
  struct JSIConverter<margelo::nitro::mlxreactnative::GenerationStats> final {
    static inline margelo::nitro::mlxreactnative::GenerationStats fromJSI(jsi::Runtime& runtime, const jsi::Value& arg) {
      jsi::Object obj = arg.asObject(runtime);
      return margelo::nitro::mlxreactnative::GenerationStats(
        JSIConverter<double>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "tokenCount"))),
        JSIConverter<double>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "tokensPerSecond"))),
        JSIConverter<double>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "timeToFirstToken"))),
        JSIConverter<double>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "totalTime"))),
        JSIConverter<double>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "toolExecutionTime")))
      );
    }
    static inline jsi::Value toJSI(jsi::Runtime& runtime, const margelo::nitro::mlxreactnative::GenerationStats& arg) {
      jsi::Object obj(runtime);
      obj.setProperty(runtime, PropNameIDCache::get(runtime, "tokenCount"), JSIConverter<double>::toJSI(runtime, arg.tokenCount));
      obj.setProperty(runtime, PropNameIDCache::get(runtime, "tokensPerSecond"), JSIConverter<double>::toJSI(runtime, arg.tokensPerSecond));
      obj.setProperty(runtime, PropNameIDCache::get(runtime, "timeToFirstToken"), JSIConverter<double>::toJSI(runtime, arg.timeToFirstToken));
      obj.setProperty(runtime, PropNameIDCache::get(runtime, "totalTime"), JSIConverter<double>::toJSI(runtime, arg.totalTime));
      obj.setProperty(runtime, PropNameIDCache::get(runtime, "toolExecutionTime"), JSIConverter<double>::toJSI(runtime, arg.toolExecutionTime));
      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, "tokenCount")))) return false;
      if (!JSIConverter<double>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "tokensPerSecond")))) return false;
      if (!JSIConverter<double>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "timeToFirstToken")))) return false;
      if (!JSIConverter<double>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "totalTime")))) return false;
      if (!JSIConverter<double>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "toolExecutionTime")))) return false;
      return true;
    }
  };

} // namespace margelo::nitro
