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

#pragma once

#include "HybridInappbrowserNitroSpec.hpp"

// Forward declaration of `HybridInappbrowserNitroSpec_cxx` to properly resolve imports.
namespace InappbrowserNitro { class HybridInappbrowserNitroSpec_cxx; }

// Forward declaration of `InAppBrowserResult` to properly resolve imports.
namespace margelo::nitro::inappbrowsernitro { struct InAppBrowserResult; }
// Forward declaration of `BrowserResultType` to properly resolve imports.
namespace margelo::nitro::inappbrowsernitro { enum class BrowserResultType; }
// Forward declaration of `InAppBrowserOptions` to properly resolve imports.
namespace margelo::nitro::inappbrowsernitro { struct InAppBrowserOptions; }
// Forward declaration of `DismissButtonStyle` to properly resolve imports.
namespace margelo::nitro::inappbrowsernitro { enum class DismissButtonStyle; }
// Forward declaration of `DynamicColor` to properly resolve imports.
namespace margelo::nitro::inappbrowsernitro { struct DynamicColor; }
// Forward declaration of `StatusBarStyle` to properly resolve imports.
namespace margelo::nitro::inappbrowsernitro { enum class StatusBarStyle; }
// Forward declaration of `ModalPresentationStyle` to properly resolve imports.
namespace margelo::nitro::inappbrowsernitro { enum class ModalPresentationStyle; }
// Forward declaration of `ModalTransitionStyle` to properly resolve imports.
namespace margelo::nitro::inappbrowsernitro { enum class ModalTransitionStyle; }
// Forward declaration of `UserInterfaceStyle` to properly resolve imports.
namespace margelo::nitro::inappbrowsernitro { enum class UserInterfaceStyle; }
// Forward declaration of `FormSheetContentSize` to properly resolve imports.
namespace margelo::nitro::inappbrowsernitro { struct FormSheetContentSize; }
// Forward declaration of `BrowserShareState` to properly resolve imports.
namespace margelo::nitro::inappbrowsernitro { enum class BrowserShareState; }
// Forward declaration of `BrowserColorScheme` to properly resolve imports.
namespace margelo::nitro::inappbrowsernitro { enum class BrowserColorScheme; }
// Forward declaration of `BrowserAnimations` to properly resolve imports.
namespace margelo::nitro::inappbrowsernitro { struct BrowserAnimations; }
// Forward declaration of `InAppBrowserAuthResult` to properly resolve imports.
namespace margelo::nitro::inappbrowsernitro { struct InAppBrowserAuthResult; }

#include <NitroModules/Promise.hpp>
#include "InAppBrowserResult.hpp"
#include "BrowserResultType.hpp"
#include <string>
#include <optional>
#include "InAppBrowserOptions.hpp"
#include "DismissButtonStyle.hpp"
#include "DynamicColor.hpp"
#include "StatusBarStyle.hpp"
#include "ModalPresentationStyle.hpp"
#include "ModalTransitionStyle.hpp"
#include "UserInterfaceStyle.hpp"
#include "FormSheetContentSize.hpp"
#include "BrowserShareState.hpp"
#include "BrowserColorScheme.hpp"
#include <unordered_map>
#include "BrowserAnimations.hpp"
#include "InAppBrowserAuthResult.hpp"

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

namespace margelo::nitro::inappbrowsernitro {

  /**
   * The C++ part of HybridInappbrowserNitroSpec_cxx.swift.
   *
   * HybridInappbrowserNitroSpecSwift (C++) accesses HybridInappbrowserNitroSpec_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, HybridInappbrowserNitroSpec_cxx can directly inherit from the C++ class HybridInappbrowserNitroSpec
   * to simplify the whole structure and memory management.
   */
  class HybridInappbrowserNitroSpecSwift: public virtual HybridInappbrowserNitroSpec {
  public:
    // Constructor from a Swift instance
    explicit HybridInappbrowserNitroSpecSwift(const InappbrowserNitro::HybridInappbrowserNitroSpec_cxx& swiftPart):
      HybridObject(HybridInappbrowserNitroSpec::TAG),
      _swiftPart(swiftPart) { }

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

  public:
    inline size_t getExternalMemorySize() noexcept override {
      return _swiftPart.getMemorySize();
    }
    bool equals(const std::shared_ptr<HybridObject>& other) override {
      if (auto otherCast = std::dynamic_pointer_cast<HybridInappbrowserNitroSpecSwift>(other)) {
        return _swiftPart.equals(otherCast->_swiftPart);
      }
      return false;
    }
    void dispose() noexcept override {
      _swiftPart.dispose();
    }
    std::string toString() override {
      return _swiftPart.toString();
    }

  public:
    // Properties
    

  public:
    // Methods
    inline std::shared_ptr<Promise<bool>> isAvailable() override {
      auto __result = _swiftPart.isAvailable();
      if (__result.hasError()) [[unlikely]] {
        std::rethrow_exception(__result.error());
      }
      auto __value = std::move(__result.value());
      return __value;
    }
    inline std::shared_ptr<Promise<InAppBrowserResult>> open(const std::string& url, const std::optional<InAppBrowserOptions>& options) override {
      auto __result = _swiftPart.open(url, options);
      if (__result.hasError()) [[unlikely]] {
        std::rethrow_exception(__result.error());
      }
      auto __value = std::move(__result.value());
      return __value;
    }
    inline std::shared_ptr<Promise<InAppBrowserAuthResult>> openAuth(const std::string& url, const std::string& redirectUrl, const std::optional<InAppBrowserOptions>& options) override {
      auto __result = _swiftPart.openAuth(url, redirectUrl, options);
      if (__result.hasError()) [[unlikely]] {
        std::rethrow_exception(__result.error());
      }
      auto __value = std::move(__result.value());
      return __value;
    }
    inline std::shared_ptr<Promise<void>> close() override {
      auto __result = _swiftPart.close();
      if (__result.hasError()) [[unlikely]] {
        std::rethrow_exception(__result.error());
      }
      auto __value = std::move(__result.value());
      return __value;
    }
    inline std::shared_ptr<Promise<void>> closeAuth() override {
      auto __result = _swiftPart.closeAuth();
      if (__result.hasError()) [[unlikely]] {
        std::rethrow_exception(__result.error());
      }
      auto __value = std::move(__result.value());
      return __value;
    }

  private:
    InappbrowserNitro::HybridInappbrowserNitroSpec_cxx _swiftPart;
  };

} // namespace margelo::nitro::inappbrowsernitro
