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

#include "Graph/Nodes/InworldNode_Routing.h"

#include "Graph/InworldData.h"
#include "Graph/InworldGraph.h"

UInworldNode_Routing::UInworldNode_Routing()
{
	NodeName = "Routing";

	bExecuteProcessInGameThread = false;
}

FInworldDataHandle UInworldNode_Routing::Process_Default(const FInworldDataHandle& Input) const
{
	return Input;
}

EInworldRuntimeErrors UInworldNode_Routing::GetJsonConfig(const TSharedRef<FJsonObject>& GraphJson)
{
	TSharedPtr<FJsonObject> NodeObj = MakeShared<FJsonObject>();
	NodeObj->SetStringField(TEXT("id"), GetNodeName());
	NodeObj->SetStringField(TEXT("type"), TEXT("ProxyNode"));

	TSharedPtr<FJsonObject> Main = GraphJson->GetObjectField(TEXT("main"));
	TArray<TSharedPtr<FJsonValue>> Nodes = Main->GetArrayField(TEXT("nodes"));
	Nodes.Add(MakeShared<FJsonValueObject>(NodeObj));
	Main->SetArrayField(TEXT("nodes"), Nodes);

	return EInworldRuntimeErrors::SUCCESS;
}
