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

#pragma once

#include "HybridNitroShareIntentSpec.hpp"

// Forward declaration of `HybridNitroShareIntentSpec_cxx` to properly resolve imports.
namespace NitroShareIntent { class HybridNitroShareIntentSpec_cxx; }

// Forward declaration of `SharePayload` to properly resolve imports.
namespace margelo::nitro::nitroshareintent { struct SharePayload; }
// Forward declaration of `ShareType` to properly resolve imports.
namespace margelo::nitro::nitroshareintent { enum class ShareType; }

#include "SharePayload.hpp"
#include <optional>
#include <NitroModules/Promise.hpp>
#include "ShareType.hpp"
#include <string>
#include <vector>
#include <unordered_map>
#include <functional>

#include "NitroShareIntent-Swift-Cxx-Umbrella.hpp"

namespace margelo::nitro::nitroshareintent {

  /**
   * The C++ part of HybridNitroShareIntentSpec_cxx.swift.
   *
   * HybridNitroShareIntentSpecSwift (C++) accesses HybridNitroShareIntentSpec_cxx (Swift), and might
   * contain some additional bridging code for C++ <> Swift interop.
   *
   * Since this obviously introduces an overhead, I hope at some point in
   * the future, HybridNitroShareIntentSpec_cxx can directly inherit from the C++ class HybridNitroShareIntentSpec
   * to simplify the whole structure and memory management.
   */
  class HybridNitroShareIntentSpecSwift: public virtual HybridNitroShareIntentSpec {
  public:
    // Constructor from a Swift instance
    explicit HybridNitroShareIntentSpecSwift(const NitroShareIntent::HybridNitroShareIntentSpec_cxx& swiftPart):
      HybridObject(HybridNitroShareIntentSpec::TAG),
      _swiftPart(swiftPart) { }

  public:
    // Get the Swift part
    inline NitroShareIntent::HybridNitroShareIntentSpec_cxx& getSwiftPart() noexcept {
      return _swiftPart;
    }

  public:
    inline size_t getExternalMemorySize() noexcept override {
      return _swiftPart.getMemorySize();
    }
    void dispose() noexcept override {
      _swiftPart.dispose();
    }
    std::string toString() override {
      return _swiftPart.toString();
    }

  public:
    // Properties
    

  public:
    // Methods
    inline std::shared_ptr<Promise<std::optional<SharePayload>>> getInitialShare() override {
      auto __result = _swiftPart.getInitialShare();
      if (__result.hasError()) [[unlikely]] {
        std::rethrow_exception(__result.error());
      }
      auto __value = std::move(__result.value());
      return __value;
    }
    inline double onIntentListener(const std::function<void(const SharePayload& /* payload */)>& listener) override {
      auto __result = _swiftPart.onIntentListener(listener);
      if (__result.hasError()) [[unlikely]] {
        std::rethrow_exception(__result.error());
      }
      auto __value = std::move(__result.value());
      return __value;
    }
    inline double onErrorListener(const std::function<void(const std::string& /* message */)>& listener) override {
      auto __result = _swiftPart.onErrorListener(listener);
      if (__result.hasError()) [[unlikely]] {
        std::rethrow_exception(__result.error());
      }
      auto __value = std::move(__result.value());
      return __value;
    }
    inline void removeListener(double listenerId) override {
      auto __result = _swiftPart.removeListener(std::forward<decltype(listenerId)>(listenerId));
      if (__result.hasError()) [[unlikely]] {
        std::rethrow_exception(__result.error());
      }
    }
    inline void clearShareIntent() override {
      auto __result = _swiftPart.clearShareIntent();
      if (__result.hasError()) [[unlikely]] {
        std::rethrow_exception(__result.error());
      }
    }

  private:
    NitroShareIntent::HybridNitroShareIntentSpec_cxx _swiftPart;
  };

} // namespace margelo::nitro::nitroshareintent
