
/**
 * This code was generated by
 * [react-native-codegen](https://www.npmjs.com/package/react-native-codegen).
 *
 * Do not edit this file as changes may cause incorrect behavior and will be
 * lost once the code is regenerated.
 *
 * @generated by codegen project: GenerateShadowNodeH.js
 */

#pragma once

#include <jsi/jsi.h>
#include <react/renderer/components/rngesturehandler_codegen/EventEmitters.h>
#include <react/renderer/components/rngesturehandler_codegen/Props.h>
#include <react/renderer/components/view/ConcreteViewShadowNode.h>
#include <react/renderer/core/LayoutContext.h>

#include "RNGestureHandlerDetectorState.h"

namespace facebook::react {

JSI_EXPORT extern const char RNGestureHandlerDetectorComponentName[];

/*
 * `ShadowNode` for <RNGestureHandlerDetector> component.
 */
class RNGestureHandlerDetectorShadowNode final
    : public ConcreteViewShadowNode<
          RNGestureHandlerDetectorComponentName,
          RNGestureHandlerDetectorProps,
          RNGestureHandlerDetectorEventEmitter,
          RNGestureHandlerDetectorState> {
 public:
  RNGestureHandlerDetectorShadowNode(
      const ShadowNodeFragment &fragment,
      const ShadowNodeFamily::Shared &family,
      ShadowNodeTraits traits)
      : ConcreteViewShadowNode(fragment, family, traits) {
    initialize();
  }

  RNGestureHandlerDetectorShadowNode(
      const ShadowNode &sourceShadowNode,
      const ShadowNodeFragment &fragment)
      : ConcreteViewShadowNode(sourceShadowNode, fragment) {
    const auto &sourceDetectorNode =
        static_cast<const RNGestureHandlerDetectorShadowNode &>(
            sourceShadowNode);
    previousLayoutMetrics_ = sourceDetectorNode.getLayoutMetrics();

    initialize();
  }

  void appendChild(const std::shared_ptr<const ShadowNode> &child) override;
  void replaceChild(
      const ShadowNode &oldChild,
      const std::shared_ptr<const ShadowNode> &newChild,
      size_t suggestedIndex = SIZE_MAX) override;

  void layout(LayoutContext layoutContext) override;

 private:
  std::shared_ptr<const ShadowNode> unflattenNode(
      const std::shared_ptr<const ShadowNode> &node);
  void initialize();
  void updateOrderIndexFromChildren();

  std::optional<LayoutMetrics> previousLayoutMetrics_;
};

} // namespace facebook::react
