using System.Text;

namespace QCRPG.TSL.NFC.Packets;

public static class ConfigurationStatusInfo
{
	public static ConfigurationStatusEnum ValueToConfigurationStatus(uint value)
	{
		switch (value)
		{
		case 0u:
			return ConfigurationStatusEnum.NCI_RF_CONFIGURATION_KEPT;
		case 1u:
			return ConfigurationStatusEnum.NCI_RF_CONFIGURATION_RESET;
		default:
			if (value >= 2 && value <= 255)
			{
				return ConfigurationStatusEnum.RFU;
			}
			return ConfigurationStatusEnum.InvalidConfigurationStatusValue;
		}
	}

	public static uint ConfigurationStatusToValue(ConfigurationStatusEnum enumItem)
	{
		return enumItem switch
		{
			ConfigurationStatusEnum.NCI_RF_CONFIGURATION_KEPT => 0u, 
			ConfigurationStatusEnum.NCI_RF_CONFIGURATION_RESET => 1u, 
			ConfigurationStatusEnum.RFU => 2u, 
			_ => uint.MaxValue, 
		};
	}

	public static string ConfigurationStatusToString(ConfigurationStatusEnum enumItem)
	{
		return enumItem switch
		{
			ConfigurationStatusEnum.NCI_RF_CONFIGURATION_KEPT => "NCI RF Configuration has been kept.", 
			ConfigurationStatusEnum.NCI_RF_CONFIGURATION_RESET => "NCI RF Configuration has been reset.", 
			ConfigurationStatusEnum.RFU => "RFU", 
			_ => "Invalid ConfigurationStatus Value", 
		};
	}

	public static string ConfigurationStatusToDescription()
	{
		StringBuilder stringBuilder = new StringBuilder();
		stringBuilder.AppendLine("0x0 = NCI RF Configuration has been kept.");
		stringBuilder.AppendLine("0x1 = NCI RF Configuration has been reset.");
		stringBuilder.AppendLine("0x2-0xFF = RFU");
		return stringBuilder.ToString();
	}
}
