using System.Text;

namespace QCRPG.TSL.NFC.Packets;

public static class DeactivationReasonsInfo
{
	public static DeactivationReasonsEnum ValueToDeactivationReasons(uint value)
	{
		switch (value)
		{
		case 0u:
			return DeactivationReasonsEnum.DH_REQUEST;
		case 1u:
			return DeactivationReasonsEnum.ENDPOINT_REQUEST;
		case 2u:
			return DeactivationReasonsEnum.RF_LINK_LOSS;
		case 3u:
			return DeactivationReasonsEnum.NFC_B_BAD_AFI;
		default:
			if (value >= 4 && value <= 255)
			{
				return DeactivationReasonsEnum.RFU;
			}
			return DeactivationReasonsEnum.InvalidDeactivationReasonsValue;
		}
	}

	public static uint DeactivationReasonsToValue(DeactivationReasonsEnum enumItem)
	{
		return enumItem switch
		{
			DeactivationReasonsEnum.DH_REQUEST => 0u, 
			DeactivationReasonsEnum.ENDPOINT_REQUEST => 1u, 
			DeactivationReasonsEnum.RF_LINK_LOSS => 2u, 
			DeactivationReasonsEnum.NFC_B_BAD_AFI => 3u, 
			DeactivationReasonsEnum.RFU => 4u, 
			_ => uint.MaxValue, 
		};
	}

	public static string DeactivationReasonsToString(DeactivationReasonsEnum enumItem)
	{
		return enumItem switch
		{
			DeactivationReasonsEnum.DH_REQUEST => "DH_REQUEST", 
			DeactivationReasonsEnum.ENDPOINT_REQUEST => "ENDPOINT_REQUEST", 
			DeactivationReasonsEnum.RF_LINK_LOSS => "RF_LINK_LOSS", 
			DeactivationReasonsEnum.NFC_B_BAD_AFI => "NFC_B_BAD_AFI", 
			DeactivationReasonsEnum.RFU => "RFU", 
			_ => "Invalid DeactivationReasons Value", 
		};
	}

	public static string DeactivationReasonsToDescription()
	{
		StringBuilder stringBuilder = new StringBuilder();
		stringBuilder.AppendLine("0x0 = DH_REQUEST");
		stringBuilder.AppendLine("0x1 = ENDPOINT_REQUEST");
		stringBuilder.AppendLine("0x2 = RF_LINK_LOSS");
		stringBuilder.AppendLine("0x3 = NFC_B_BAD_AFI");
		stringBuilder.AppendLine("0x4-0xFF = RFU");
		return stringBuilder.ToString();
	}
}
