/**
 * Copyright 2022-2025 Theai, Inc. dba Inworld AI
 */
#pragma once

#include "CoreMinimal.h"
#include "SGraphNode.h"
#include "Runtime/Launch/Resources/Version.h"

class UEdNode_InworldGraphNode;
class SHorizontalBox;

class INWORLDRUNTIMEEDITOR_API SEdNode_InworldGraphNode : public SGraphNode
{
public:
	SLATE_BEGIN_ARGS(SEdNode_InworldGraphNode)
	{
	}
	SLATE_END_ARGS()

	void Construct(const FArguments& InArgs, UEdNode_InworldGraphNode* InNode);

	void ForceUpdateGraphNode();
	virtual void UpdateGraphNode() override;
	virtual void CreatePinWidgets() override;
	virtual void AddPin(const TSharedRef<SGraphPin>& PinToAdd) override;
	virtual bool IsNameReadOnly() const override;

	void OnNameTextCommited(const FText& InText, ETextCommit::Type CommitInfo);

	virtual FSlateColor GetBackgroundColor() const;
	virtual EVisibility GetDragOverMarkerVisibility() const;

	virtual const FSlateBrush* GetNameIcon() const;


protected:

	EVisibility GetStartVisibility() const;
	EVisibility GetEndVisibility() const;
	TSharedPtr<SHorizontalBox> InputPinsBox;
	TSharedPtr<SHorizontalBox> OutputPinsBox;
	FText GetNodeToolTip() const;

	EVisibility GetNativeNodeIdVisibility() const;
	FText GetNativeNodeIdLabel() const;
	
#if ENGINE_MAJOR_VERSION == 5 && ENGINE_MINOR_VERSION < 6
	FVector2D GetStartSlotOffset() const;
	FVector2D GetEndSlotOffset() const;
#else
	FVector2f GetStartSlotOffset2f() const;
	FVector2f GetEndSlotOffset2f() const;
#endif
private:
	bool bForceRebuildFlag = false;
};
