using System.Collections.Generic;

namespace NodePipeline.Constants.Exceptions;

public static class NodeFactory
{
    public const string NodeCanNotBeInitializedWithoutFactoryException =
        "NodePipeline.Constants.Exceptions.NodeFactory." + nameof(NodeCanNotBeInitializedWithoutFactoryException);

    public const string NodeNotFoundException =
        "NodePipeline.Constants.Exceptions.NodeFactory." + nameof(NodeNotFoundException);

    public const string NodeTypeNotFoundException =
        "NodePipeline.Constants.Exceptions.NodeFactory." + nameof(NodeTypeNotFoundException);

    public const string NodeWasNotInitializedException =
        "NodePipeline.Constants.Exceptions.NodeFactory." + nameof(NodeWasNotInitializedException);

    public const string NodeParameterNotFoundException =
        "NodePipeline.Constants.Exceptions.NodeFactory." + nameof(NodeParameterNotFoundException);

    public const string NodeParameterNotFoundExceptionShort = "NodePipeline.Constants.Exceptions.NodeFactory." +
                                                              nameof(NodeParameterNotFoundExceptionShort);

    public const string NonNullableInputRestrictsConnectionToNullableOutputException =
        "NodePipeline.Constants.Exceptions.NodeFactory." +
        nameof(NonNullableInputRestrictsConnectionToNullableOutputException);

    public const string PortsTypeMismatchException =
        "NodePipeline.Constants.Exceptions.NodeFactory." + nameof(PortsTypeMismatchException);

    public const string InputPortHasNoRequiredConnectionException =
        "NodePipeline.Constants.Exceptions.NodeFactory." + nameof(InputPortHasNoRequiredConnectionException);

    public const string InputPortNotFoundException =
        "NodePipeline.Constants.Exceptions.NodeFactory." + nameof(InputPortNotFoundException);

    public const string OutputPortNodeNotFoundException =
        "NodePipeline.Constants.Exceptions.NodeFactory." + nameof(OutputPortNodeNotFoundException);

    public const string OutputPortNotFoundException =
        "NodePipeline.Constants.Exceptions.NodeFactory." + nameof(OutputPortNotFoundException);

    public static readonly Dictionary<string, string> MessagesEn = new()
    {
        {
            NodeCanNotBeInitializedWithoutFactoryException,
            "Node [{0}] of type [{1}] can not be initialized because has no parameterless constructor and appropriate factory is not specified."
        },
        { NodeNotFoundException, "Unknown node type [{0}] of node [{1}]" },
        { NodeTypeNotFoundException, "Unknown node type [{0}]" },
        { NodeWasNotInitializedException, "Node [{0}] of type [{1}] was not initialized" },
        { NodeParameterNotFoundException, "Parameter [{0}] for node [{1}] of type [{2}] was not found" },
        { NodeParameterNotFoundExceptionShort, "Parameter [{0}] for node type [{1}] was not found" },
        {
            NonNullableInputRestrictsConnectionToNullableOutputException,
            "Non-nullable input port [{0}] of [{1}] restricts connection to nullable output port [{2}] of [{3}] node. Check [{1}] node connection"
        },
        {
            PortsTypeMismatchException,
            "Input port [{0}] of [{1}] node with type [{2}] is connected to [{3}] output port of node [{4}] with type [{5}]. Port types are incompatible. Check [{1}] node connection."
        },
        {
            InputPortHasNoRequiredConnectionException,
            "Input port [{0}] of node [{1}] with type [{2}] has no connection but connection is required."
        },
        { InputPortNotFoundException, "Input port [{0}] was not found for node [{1}] with type [{2}]." },
        { OutputPortNodeNotFoundException, "Source node [{0}] was not found. Check [{1}] node connection." },
        {
            OutputPortNotFoundException,
            "Output port [{0}] of node [{1}] was not found. Check [{2}] node connection."
        }
    };

    public static readonly Dictionary<string, string> MessagesRu = new()
    {
        {
            NodeCanNotBeInitializedWithoutFactoryException,
            "Нода [{0}] типа [{1}] не может быть инициализирована, так как она не имеет конструктора без параметров, а подходящая фабрика не определена."
        },
        { NodeNotFoundException, "Неизвестный тип ноды [{0}] для ноды [{1}]" },
        { NodeTypeNotFoundException, "Неизвестный тип ноды [{0}]" },
        { NodeWasNotInitializedException, "Нода [{0}] типа [{1}] не была инициализирована" },
        { NodeParameterNotFoundException, "Параметр [{0}] ноды [{1}] типа [{2}] не найден" },
        { NodeParameterNotFoundExceptionShort, "Параметр [{0}] для ноды типа [{1}] не найден" },
        {
            NonNullableInputRestrictsConnectionToNullableOutputException,
            "Входной порт [{0}], не допускающий null, ноды [{1}] запрещает соединение с допускающим null выходным портом [{2}] ноды [{3}]. Проверьте связи [{1}] ноды."
        },
        {
            PortsTypeMismatchException,
            "Входной порт [{0}] ноды [{1}] типа [{2}] соединён с выходным портом [{3}] ноды [{4}] типа [{5}]. Типы портов несовместимы. Проверьте связи [{1}] ноды."
        },
        {
            InputPortHasNoRequiredConnectionException,
            "Нет обязательного соединения для входного порта [{0}] ноды [{1}] типа [{2}]."
        },
        { InputPortNotFoundException, "Входной порт [{0}] не найден для ноды [{1}] с типом [{2}]." },
        { OutputPortNodeNotFoundException, "Нода-источник [{0}] не найдена. Проверьте соединение [{1}] ноды." },
        {
            OutputPortNotFoundException,
            "Выходной параметр [{0}] ноды [{1}] не найден. Проверьте соединение [{2}] ноды."
        }
    };
}