///
/// JHybridVideoViewViewManagerSpec.cpp
/// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
/// https://github.com/mrousavy/nitro
/// Copyright © 2025 Marc Rousavy @ Margelo
///

#include "JHybridVideoViewViewManagerSpec.hpp"

// Forward declaration of `HybridVideoPlayerSpec` to properly resolve imports.
namespace margelo::nitro::video { class HybridVideoPlayerSpec; }
// Forward declaration of `ResizeMode` to properly resolve imports.
namespace margelo::nitro::video { enum class ResizeMode; }

#include <memory>
#include "HybridVideoPlayerSpec.hpp"
#include <optional>
#include "JHybridVideoPlayerSpec.hpp"
#include "ResizeMode.hpp"
#include "JResizeMode.hpp"
#include <functional>
#include "JFunc_void_bool.hpp"
#include "JFunc_void.hpp"

namespace margelo::nitro::video {

  jni::local_ref<JHybridVideoViewViewManagerSpec::jhybriddata> JHybridVideoViewViewManagerSpec::initHybrid(jni::alias_ref<jhybridobject> jThis) {
    return makeCxxInstance(jThis);
  }

  void JHybridVideoViewViewManagerSpec::registerNatives() {
    registerHybrid({
      makeNativeMethod("initHybrid", JHybridVideoViewViewManagerSpec::initHybrid),
    });
  }

  size_t JHybridVideoViewViewManagerSpec::getExternalMemorySize() noexcept {
    static const auto method = javaClassStatic()->getMethod<jlong()>("getMemorySize");
    return method(_javaPart);
  }

  void JHybridVideoViewViewManagerSpec::dispose() noexcept {
    static const auto method = javaClassStatic()->getMethod<void()>("dispose");
    method(_javaPart);
  }

  // Properties
  std::optional<std::shared_ptr<HybridVideoPlayerSpec>> JHybridVideoViewViewManagerSpec::getPlayer() {
    static const auto method = javaClassStatic()->getMethod<jni::local_ref<JHybridVideoPlayerSpec::javaobject>()>("getPlayer");
    auto __result = method(_javaPart);
    return __result != nullptr ? std::make_optional(__result->cthis()->shared_cast<JHybridVideoPlayerSpec>()) : std::nullopt;
  }
  void JHybridVideoViewViewManagerSpec::setPlayer(const std::optional<std::shared_ptr<HybridVideoPlayerSpec>>& player) {
    static const auto method = javaClassStatic()->getMethod<void(jni::alias_ref<JHybridVideoPlayerSpec::javaobject> /* player */)>("setPlayer");
    method(_javaPart, player.has_value() ? std::dynamic_pointer_cast<JHybridVideoPlayerSpec>(player.value())->getJavaPart() : nullptr);
  }
  bool JHybridVideoViewViewManagerSpec::getControls() {
    static const auto method = javaClassStatic()->getMethod<jboolean()>("getControls");
    auto __result = method(_javaPart);
    return static_cast<bool>(__result);
  }
  void JHybridVideoViewViewManagerSpec::setControls(bool controls) {
    static const auto method = javaClassStatic()->getMethod<void(jboolean /* controls */)>("setControls");
    method(_javaPart, controls);
  }
  bool JHybridVideoViewViewManagerSpec::getPictureInPicture() {
    static const auto method = javaClassStatic()->getMethod<jboolean()>("getPictureInPicture");
    auto __result = method(_javaPart);
    return static_cast<bool>(__result);
  }
  void JHybridVideoViewViewManagerSpec::setPictureInPicture(bool pictureInPicture) {
    static const auto method = javaClassStatic()->getMethod<void(jboolean /* pictureInPicture */)>("setPictureInPicture");
    method(_javaPart, pictureInPicture);
  }
  bool JHybridVideoViewViewManagerSpec::getAutoEnterPictureInPicture() {
    static const auto method = javaClassStatic()->getMethod<jboolean()>("getAutoEnterPictureInPicture");
    auto __result = method(_javaPart);
    return static_cast<bool>(__result);
  }
  void JHybridVideoViewViewManagerSpec::setAutoEnterPictureInPicture(bool autoEnterPictureInPicture) {
    static const auto method = javaClassStatic()->getMethod<void(jboolean /* autoEnterPictureInPicture */)>("setAutoEnterPictureInPicture");
    method(_javaPart, autoEnterPictureInPicture);
  }
  ResizeMode JHybridVideoViewViewManagerSpec::getResizeMode() {
    static const auto method = javaClassStatic()->getMethod<jni::local_ref<JResizeMode>()>("getResizeMode");
    auto __result = method(_javaPart);
    return __result->toCpp();
  }
  void JHybridVideoViewViewManagerSpec::setResizeMode(ResizeMode resizeMode) {
    static const auto method = javaClassStatic()->getMethod<void(jni::alias_ref<JResizeMode> /* resizeMode */)>("setResizeMode");
    method(_javaPart, JResizeMode::fromCpp(resizeMode));
  }
  bool JHybridVideoViewViewManagerSpec::getKeepScreenAwake() {
    static const auto method = javaClassStatic()->getMethod<jboolean()>("getKeepScreenAwake");
    auto __result = method(_javaPart);
    return static_cast<bool>(__result);
  }
  void JHybridVideoViewViewManagerSpec::setKeepScreenAwake(bool keepScreenAwake) {
    static const auto method = javaClassStatic()->getMethod<void(jboolean /* keepScreenAwake */)>("setKeepScreenAwake");
    method(_javaPart, keepScreenAwake);
  }
  std::optional<std::function<void(bool /* isInPictureInPicture */)>> JHybridVideoViewViewManagerSpec::getOnPictureInPictureChange() {
    static const auto method = javaClassStatic()->getMethod<jni::local_ref<JFunc_void_bool::javaobject>()>("getOnPictureInPictureChange_cxx");
    auto __result = method(_javaPart);
    return __result != nullptr ? std::make_optional([&]() -> std::function<void(bool /* isInPictureInPicture */)> {
      if (__result->isInstanceOf(JFunc_void_bool_cxx::javaClassStatic())) [[likely]] {
        auto downcast = jni::static_ref_cast<JFunc_void_bool_cxx::javaobject>(__result);
        return downcast->cthis()->getFunction();
      } else {
        auto __resultRef = jni::make_global(__result);
        return [__resultRef](bool isInPictureInPicture) -> void {
          return __resultRef->invoke(isInPictureInPicture);
        };
      }
    }()) : std::nullopt;
  }
  void JHybridVideoViewViewManagerSpec::setOnPictureInPictureChange(const std::optional<std::function<void(bool /* isInPictureInPicture */)>>& onPictureInPictureChange) {
    static const auto method = javaClassStatic()->getMethod<void(jni::alias_ref<JFunc_void_bool::javaobject> /* onPictureInPictureChange */)>("setOnPictureInPictureChange_cxx");
    method(_javaPart, onPictureInPictureChange.has_value() ? JFunc_void_bool_cxx::fromCpp(onPictureInPictureChange.value()) : nullptr);
  }
  std::optional<std::function<void(bool /* fullscreen */)>> JHybridVideoViewViewManagerSpec::getOnFullscreenChange() {
    static const auto method = javaClassStatic()->getMethod<jni::local_ref<JFunc_void_bool::javaobject>()>("getOnFullscreenChange_cxx");
    auto __result = method(_javaPart);
    return __result != nullptr ? std::make_optional([&]() -> std::function<void(bool /* fullscreen */)> {
      if (__result->isInstanceOf(JFunc_void_bool_cxx::javaClassStatic())) [[likely]] {
        auto downcast = jni::static_ref_cast<JFunc_void_bool_cxx::javaobject>(__result);
        return downcast->cthis()->getFunction();
      } else {
        auto __resultRef = jni::make_global(__result);
        return [__resultRef](bool fullscreen) -> void {
          return __resultRef->invoke(fullscreen);
        };
      }
    }()) : std::nullopt;
  }
  void JHybridVideoViewViewManagerSpec::setOnFullscreenChange(const std::optional<std::function<void(bool /* fullscreen */)>>& onFullscreenChange) {
    static const auto method = javaClassStatic()->getMethod<void(jni::alias_ref<JFunc_void_bool::javaobject> /* onFullscreenChange */)>("setOnFullscreenChange_cxx");
    method(_javaPart, onFullscreenChange.has_value() ? JFunc_void_bool_cxx::fromCpp(onFullscreenChange.value()) : nullptr);
  }
  std::optional<std::function<void()>> JHybridVideoViewViewManagerSpec::getWillEnterFullscreen() {
    static const auto method = javaClassStatic()->getMethod<jni::local_ref<JFunc_void::javaobject>()>("getWillEnterFullscreen_cxx");
    auto __result = method(_javaPart);
    return __result != nullptr ? std::make_optional([&]() -> std::function<void()> {
      if (__result->isInstanceOf(JFunc_void_cxx::javaClassStatic())) [[likely]] {
        auto downcast = jni::static_ref_cast<JFunc_void_cxx::javaobject>(__result);
        return downcast->cthis()->getFunction();
      } else {
        auto __resultRef = jni::make_global(__result);
        return [__resultRef]() -> void {
          return __resultRef->invoke();
        };
      }
    }()) : std::nullopt;
  }
  void JHybridVideoViewViewManagerSpec::setWillEnterFullscreen(const std::optional<std::function<void()>>& willEnterFullscreen) {
    static const auto method = javaClassStatic()->getMethod<void(jni::alias_ref<JFunc_void::javaobject> /* willEnterFullscreen */)>("setWillEnterFullscreen_cxx");
    method(_javaPart, willEnterFullscreen.has_value() ? JFunc_void_cxx::fromCpp(willEnterFullscreen.value()) : nullptr);
  }
  std::optional<std::function<void()>> JHybridVideoViewViewManagerSpec::getWillExitFullscreen() {
    static const auto method = javaClassStatic()->getMethod<jni::local_ref<JFunc_void::javaobject>()>("getWillExitFullscreen_cxx");
    auto __result = method(_javaPart);
    return __result != nullptr ? std::make_optional([&]() -> std::function<void()> {
      if (__result->isInstanceOf(JFunc_void_cxx::javaClassStatic())) [[likely]] {
        auto downcast = jni::static_ref_cast<JFunc_void_cxx::javaobject>(__result);
        return downcast->cthis()->getFunction();
      } else {
        auto __resultRef = jni::make_global(__result);
        return [__resultRef]() -> void {
          return __resultRef->invoke();
        };
      }
    }()) : std::nullopt;
  }
  void JHybridVideoViewViewManagerSpec::setWillExitFullscreen(const std::optional<std::function<void()>>& willExitFullscreen) {
    static const auto method = javaClassStatic()->getMethod<void(jni::alias_ref<JFunc_void::javaobject> /* willExitFullscreen */)>("setWillExitFullscreen_cxx");
    method(_javaPart, willExitFullscreen.has_value() ? JFunc_void_cxx::fromCpp(willExitFullscreen.value()) : nullptr);
  }
  std::optional<std::function<void()>> JHybridVideoViewViewManagerSpec::getWillEnterPictureInPicture() {
    static const auto method = javaClassStatic()->getMethod<jni::local_ref<JFunc_void::javaobject>()>("getWillEnterPictureInPicture_cxx");
    auto __result = method(_javaPart);
    return __result != nullptr ? std::make_optional([&]() -> std::function<void()> {
      if (__result->isInstanceOf(JFunc_void_cxx::javaClassStatic())) [[likely]] {
        auto downcast = jni::static_ref_cast<JFunc_void_cxx::javaobject>(__result);
        return downcast->cthis()->getFunction();
      } else {
        auto __resultRef = jni::make_global(__result);
        return [__resultRef]() -> void {
          return __resultRef->invoke();
        };
      }
    }()) : std::nullopt;
  }
  void JHybridVideoViewViewManagerSpec::setWillEnterPictureInPicture(const std::optional<std::function<void()>>& willEnterPictureInPicture) {
    static const auto method = javaClassStatic()->getMethod<void(jni::alias_ref<JFunc_void::javaobject> /* willEnterPictureInPicture */)>("setWillEnterPictureInPicture_cxx");
    method(_javaPart, willEnterPictureInPicture.has_value() ? JFunc_void_cxx::fromCpp(willEnterPictureInPicture.value()) : nullptr);
  }
  std::optional<std::function<void()>> JHybridVideoViewViewManagerSpec::getWillExitPictureInPicture() {
    static const auto method = javaClassStatic()->getMethod<jni::local_ref<JFunc_void::javaobject>()>("getWillExitPictureInPicture_cxx");
    auto __result = method(_javaPart);
    return __result != nullptr ? std::make_optional([&]() -> std::function<void()> {
      if (__result->isInstanceOf(JFunc_void_cxx::javaClassStatic())) [[likely]] {
        auto downcast = jni::static_ref_cast<JFunc_void_cxx::javaobject>(__result);
        return downcast->cthis()->getFunction();
      } else {
        auto __resultRef = jni::make_global(__result);
        return [__resultRef]() -> void {
          return __resultRef->invoke();
        };
      }
    }()) : std::nullopt;
  }
  void JHybridVideoViewViewManagerSpec::setWillExitPictureInPicture(const std::optional<std::function<void()>>& willExitPictureInPicture) {
    static const auto method = javaClassStatic()->getMethod<void(jni::alias_ref<JFunc_void::javaobject> /* willExitPictureInPicture */)>("setWillExitPictureInPicture_cxx");
    method(_javaPart, willExitPictureInPicture.has_value() ? JFunc_void_cxx::fromCpp(willExitPictureInPicture.value()) : nullptr);
  }

  // Methods
  void JHybridVideoViewViewManagerSpec::enterFullscreen() {
    static const auto method = javaClassStatic()->getMethod<void()>("enterFullscreen");
    method(_javaPart);
  }
  void JHybridVideoViewViewManagerSpec::exitFullscreen() {
    static const auto method = javaClassStatic()->getMethod<void()>("exitFullscreen");
    method(_javaPart);
  }
  void JHybridVideoViewViewManagerSpec::enterPictureInPicture() {
    static const auto method = javaClassStatic()->getMethod<void()>("enterPictureInPicture");
    method(_javaPart);
  }
  void JHybridVideoViewViewManagerSpec::exitPictureInPicture() {
    static const auto method = javaClassStatic()->getMethod<void()>("exitPictureInPicture");
    method(_javaPart);
  }
  bool JHybridVideoViewViewManagerSpec::canEnterPictureInPicture() {
    static const auto method = javaClassStatic()->getMethod<jboolean()>("canEnterPictureInPicture");
    auto __result = method(_javaPart);
    return static_cast<bool>(__result);
  }

} // namespace margelo::nitro::video
