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

#pragma once

#include <optional>
#include <NitroModules/NitroDefines.hpp>
#include <NitroModules/NitroHash.hpp>
#include <NitroModules/CachedProp.hpp>
#include <react/renderer/core/ConcreteComponentDescriptor.h>
#include <react/renderer/core/PropsParserContext.h>
#include <react/renderer/components/view/ConcreteViewShadowNode.h>
#include <react/renderer/components/view/ViewProps.h>

#include <memory>
#include "HybridCameraPreviewOutputSpec.hpp"
#include <optional>
#include "PreviewResizeMode.hpp"
#include "PreviewImplementationMode.hpp"
#include "HybridGestureControllerSpec.hpp"
#include <vector>
#include <functional>
#include "HybridPreviewViewSpec.hpp"

namespace margelo::nitro::camera::views {

  using namespace facebook;

  /**
   * The name of the actual native View.
   */
  extern const char HybridPreviewViewComponentName[];

  /**
   * Props for the "PreviewView" View.
   */
  class HybridPreviewViewProps final: public react::ViewProps {
  public:
    HybridPreviewViewProps() = default;
    HybridPreviewViewProps(const react::PropsParserContext& context,
                           const HybridPreviewViewProps& sourceProps,
                           const react::RawProps& rawProps);

  public:
    CachedProp<std::optional<std::shared_ptr<HybridCameraPreviewOutputSpec>>> previewOutput;
    CachedProp<std::optional<PreviewResizeMode>> resizeMode;
    CachedProp<std::optional<PreviewImplementationMode>> implementationMode;
    CachedProp<std::optional<std::vector<std::shared_ptr<HybridGestureControllerSpec>>>> gestureControllers;
    CachedProp<std::optional<std::function<void()>>> onPreviewStarted;
    CachedProp<std::optional<std::function<void()>>> onPreviewStopped;
    CachedProp<std::optional<std::function<void(const std::shared_ptr<HybridPreviewViewSpec>& /* ref */)>>> hybridRef;

  private:
    static bool filterObjectKeys(const std::string& propName);
  };

  /**
   * State for the "PreviewView" View.
   */
  class HybridPreviewViewState final {
  public:
    HybridPreviewViewState() = default;
    explicit HybridPreviewViewState(const std::shared_ptr<HybridPreviewViewProps>& props):
      _props(props) {}

  public:
    [[nodiscard]]
    const std::shared_ptr<HybridPreviewViewProps>& getProps() const {
      return _props;
    }

  public:
#ifdef ANDROID
  HybridPreviewViewState(const HybridPreviewViewState& /* previousState */, folly::dynamic /* data */) {}
  folly::dynamic getDynamic() const {
    throw std::runtime_error("HybridPreviewViewState does not support folly!");
  }
  react::MapBuffer getMapBuffer() const {
    throw std::runtime_error("HybridPreviewViewState does not support MapBuffer!");
  };
#endif

  private:
    std::shared_ptr<HybridPreviewViewProps> _props;
  };

  /**
   * The Shadow Node for the "PreviewView" View.
   */
  using HybridPreviewViewShadowNode = react::ConcreteViewShadowNode<HybridPreviewViewComponentName /* "HybridPreviewView" */,
                                                                    HybridPreviewViewProps /* custom props */,
                                                                    react::ViewEventEmitter /* default */,
                                                                    HybridPreviewViewState /* custom state */>;

  /**
   * The Component Descriptor for the "PreviewView" View.
   */
  class HybridPreviewViewComponentDescriptor final: public react::ConcreteComponentDescriptor<HybridPreviewViewShadowNode> {
  public:
    explicit HybridPreviewViewComponentDescriptor(const react::ComponentDescriptorParameters& parameters);

  public:
    /**
     * A faster path for cloning props - reuses the caching logic from `HybridPreviewViewProps`.
     */
    std::shared_ptr<const react::Props> cloneProps(const react::PropsParserContext& context,
                                                   const std::shared_ptr<const react::Props>& props,
                                                   react::RawProps rawProps) const override;
#ifdef ANDROID
    void adopt(react::ShadowNode& shadowNode) const override;
#endif
  };

  /* The actual view for "PreviewView" needs to be implemented in platform-specific code. */

} // namespace margelo::nitro::camera::views
