///
/// HybridRiveViewComponent.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 <string>
#include <optional>
#include <memory>
#include "HybridRiveFileSpec.hpp"
#include "Alignment.hpp"
#include "Fit.hpp"
#include "HybridViewModelInstanceSpec.hpp"
#include "DataBindMode.hpp"
#include "DataBindByName.hpp"
#include <variant>
#include "RiveError.hpp"
#include <functional>
#include "HybridRiveViewSpec.hpp"

namespace margelo::nitro::rive::views {

  using namespace facebook;

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

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

  public:
    CachedProp<std::optional<std::string>> artboardName;
    CachedProp<std::optional<std::string>> stateMachineName;
    CachedProp<std::optional<bool>> autoPlay;
    CachedProp<std::shared_ptr<HybridRiveFileSpec>> file;
    CachedProp<std::optional<Alignment>> alignment;
    CachedProp<std::optional<Fit>> fit;
    CachedProp<std::optional<double>> layoutScaleFactor;
    CachedProp<std::optional<std::variant<std::shared_ptr<HybridViewModelInstanceSpec>, DataBindMode, DataBindByName>>> dataBind;
    CachedProp<std::function<void(const RiveError& /* error */)>> onError;
    CachedProp<std::optional<std::function<void(const std::shared_ptr<HybridRiveViewSpec>& /* ref */)>>> hybridRef;

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

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

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

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

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

  /**
   * The Shadow Node for the "RiveView" View.
   */
  using HybridRiveViewShadowNode = react::ConcreteViewShadowNode<HybridRiveViewComponentName /* "HybridRiveView" */,
                                                                 HybridRiveViewProps /* custom props */,
                                                                 react::ViewEventEmitter /* default */,
                                                                 HybridRiveViewState /* custom state */>;

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

  public:
    /**
     * A faster path for cloning props - reuses the caching logic from `HybridRiveViewProps`.
     */
    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 "RiveView" needs to be implemented in platform-specific code. */

} // namespace margelo::nitro::rive::views
