using System.Text;

namespace QCRPG.TSL.NFC.Packets;

public static class RfTechnologyAndModeInfo
{
	public static RfTechnologyAndModeEnum ValueToRfTechnologyAndMode(uint value)
	{
		switch (value)
		{
		case 0u:
			return RfTechnologyAndModeEnum.NFC_A_PASSIVE_POLL_MODE;
		case 1u:
			return RfTechnologyAndModeEnum.NFC_B_PASSIVE_POLL_MODE;
		case 2u:
			return RfTechnologyAndModeEnum.NFC_F_PASSIVE_POLL_MODE;
		case 3u:
			return RfTechnologyAndModeEnum.NFC_A_ACTIVE_POLL_MODE_RFU;
		case 4u:
			return RfTechnologyAndModeEnum.RFU;
		case 5u:
			return RfTechnologyAndModeEnum.NFC_F_ACTIVE_POLL_MODE_RFU;
		case 6u:
			return RfTechnologyAndModeEnum.NFC_15693_PASSIVE_POLL_MODE_RFU;
		default:
			if (value >= 7 && value <= 111)
			{
				return RfTechnologyAndModeEnum.RFU;
			}
			if (value >= 112 && value <= 127)
			{
				return RfTechnologyAndModeEnum.PROPRIETARY_IN_POLL_MODE;
			}
			if (value == 128)
			{
				return RfTechnologyAndModeEnum.NFC_A_PASSIVE_LISTEN_MODE;
			}
			if (value == 129)
			{
				return RfTechnologyAndModeEnum.NFC_B_PASSIVE_LISTEN_MODE;
			}
			if (value == 130)
			{
				return RfTechnologyAndModeEnum.NFC_F_PASSIVE_LISTEN_MODE;
			}
			if (value == 131)
			{
				return RfTechnologyAndModeEnum.NFC_A_ACTIVE_LISTEN_MODE_RFU;
			}
			if (value == 132)
			{
				return RfTechnologyAndModeEnum.RFU;
			}
			if (value == 133)
			{
				return RfTechnologyAndModeEnum.NFC_F_ACTIVE_LISTEN_MODE_RFU;
			}
			if (value == 134)
			{
				return RfTechnologyAndModeEnum.NFC_15693_PASSIVE_LISTEN_MODE_RFU;
			}
			if (value >= 135 && value <= 239)
			{
				return RfTechnologyAndModeEnum.RFU;
			}
			if (value >= 240 && value <= 255)
			{
				return RfTechnologyAndModeEnum.PROPRIETARY_IN_LISTEN_MODE;
			}
			return RfTechnologyAndModeEnum.InvalidRfTechnologyAndModeValue;
		}
	}

	public static uint RfTechnologyAndModeToValue(RfTechnologyAndModeEnum enumItem)
	{
		return enumItem switch
		{
			RfTechnologyAndModeEnum.NFC_A_PASSIVE_POLL_MODE => 0u, 
			RfTechnologyAndModeEnum.NFC_B_PASSIVE_POLL_MODE => 1u, 
			RfTechnologyAndModeEnum.NFC_F_PASSIVE_POLL_MODE => 2u, 
			RfTechnologyAndModeEnum.NFC_A_ACTIVE_POLL_MODE_RFU => 3u, 
			RfTechnologyAndModeEnum.RFU => 4u, 
			RfTechnologyAndModeEnum.NFC_F_ACTIVE_POLL_MODE_RFU => 5u, 
			RfTechnologyAndModeEnum.NFC_15693_PASSIVE_POLL_MODE_RFU => 6u, 
			_ => enumItem switch
			{
				RfTechnologyAndModeEnum.RFU => 7u, 
				RfTechnologyAndModeEnum.PROPRIETARY_IN_POLL_MODE => 112u, 
				RfTechnologyAndModeEnum.NFC_A_PASSIVE_LISTEN_MODE => 128u, 
				RfTechnologyAndModeEnum.NFC_B_PASSIVE_LISTEN_MODE => 129u, 
				RfTechnologyAndModeEnum.NFC_F_PASSIVE_LISTEN_MODE => 130u, 
				RfTechnologyAndModeEnum.NFC_A_ACTIVE_LISTEN_MODE_RFU => 131u, 
				_ => enumItem switch
				{
					RfTechnologyAndModeEnum.RFU => 132u, 
					RfTechnologyAndModeEnum.NFC_F_ACTIVE_LISTEN_MODE_RFU => 133u, 
					RfTechnologyAndModeEnum.NFC_15693_PASSIVE_LISTEN_MODE_RFU => 134u, 
					_ => enumItem switch
					{
						RfTechnologyAndModeEnum.RFU => 135u, 
						RfTechnologyAndModeEnum.PROPRIETARY_IN_LISTEN_MODE => 240u, 
						_ => uint.MaxValue, 
					}, 
				}, 
			}, 
		};
	}

	public static string RfTechnologyAndModeToString(RfTechnologyAndModeEnum enumItem)
	{
		return enumItem switch
		{
			RfTechnologyAndModeEnum.NFC_A_PASSIVE_POLL_MODE => "NFC_A_PASSIVE_POLL_MODE", 
			RfTechnologyAndModeEnum.NFC_B_PASSIVE_POLL_MODE => "NFC_B_PASSIVE_POLL_MODE", 
			RfTechnologyAndModeEnum.NFC_F_PASSIVE_POLL_MODE => "NFC_F_PASSIVE_POLL_MODE", 
			RfTechnologyAndModeEnum.NFC_A_ACTIVE_POLL_MODE_RFU => "NFC_A_ACTIVE_POLL_MODE_RFU", 
			RfTechnologyAndModeEnum.RFU => "RFU", 
			RfTechnologyAndModeEnum.NFC_F_ACTIVE_POLL_MODE_RFU => "NFC_F_ACTIVE_POLL_MODE_RFU", 
			RfTechnologyAndModeEnum.NFC_15693_PASSIVE_POLL_MODE_RFU => "NFC_15693_PASSIVE_POLL_MODE_RFU", 
			_ => enumItem switch
			{
				RfTechnologyAndModeEnum.RFU => "RFU", 
				RfTechnologyAndModeEnum.PROPRIETARY_IN_POLL_MODE => "PROPRIETARY_IN_POLL_MODE", 
				RfTechnologyAndModeEnum.NFC_A_PASSIVE_LISTEN_MODE => "NFC_A_PASSIVE_LISTEN_MODE", 
				RfTechnologyAndModeEnum.NFC_B_PASSIVE_LISTEN_MODE => "NFC_B_PASSIVE_LISTEN_MODE", 
				RfTechnologyAndModeEnum.NFC_F_PASSIVE_LISTEN_MODE => "NFC_F_PASSIVE_LISTEN_MODE", 
				RfTechnologyAndModeEnum.NFC_A_ACTIVE_LISTEN_MODE_RFU => "NFC_A_ACTIVE_LISTEN_MODE_RFU", 
				_ => enumItem switch
				{
					RfTechnologyAndModeEnum.RFU => "RFU", 
					RfTechnologyAndModeEnum.NFC_F_ACTIVE_LISTEN_MODE_RFU => "NFC_F_ACTIVE_LISTEN_MODE_RFU", 
					RfTechnologyAndModeEnum.NFC_15693_PASSIVE_LISTEN_MODE_RFU => "NFC_15693_PASSIVE_LISTEN_MODE_RFU", 
					_ => enumItem switch
					{
						RfTechnologyAndModeEnum.RFU => "RFU", 
						RfTechnologyAndModeEnum.PROPRIETARY_IN_LISTEN_MODE => "PROPRIETARY_IN_LISTEN_MODE", 
						_ => "Invalid RfTechnologyAndMode Value", 
					}, 
				}, 
			}, 
		};
	}

	public static string RfTechnologyAndModeToDescription()
	{
		StringBuilder stringBuilder = new StringBuilder();
		stringBuilder.AppendLine("0x0 = NFC_A_PASSIVE_POLL_MODE");
		stringBuilder.AppendLine("0x1 = NFC_B_PASSIVE_POLL_MODE");
		stringBuilder.AppendLine("0x2 = NFC_F_PASSIVE_POLL_MODE");
		stringBuilder.AppendLine("0x3 = NFC_A_ACTIVE_POLL_MODE_RFU");
		stringBuilder.AppendLine("0x4 = RFU");
		stringBuilder.AppendLine("0x5 = NFC_F_ACTIVE_POLL_MODE_RFU");
		stringBuilder.AppendLine("0x6 = NFC_15693_PASSIVE_POLL_MODE_RFU");
		stringBuilder.AppendLine("0x7-0x6F = RFU");
		stringBuilder.AppendLine("0x70-0x7F = PROPRIETARY_IN_POLL_MODE");
		stringBuilder.AppendLine("0x80 = NFC_A_PASSIVE_LISTEN_MODE");
		stringBuilder.AppendLine("0x81 = NFC_B_PASSIVE_LISTEN_MODE");
		stringBuilder.AppendLine("0x82 = NFC_F_PASSIVE_LISTEN_MODE");
		stringBuilder.AppendLine("0x83 = NFC_A_ACTIVE_LISTEN_MODE_RFU");
		stringBuilder.AppendLine("0x84 = RFU");
		stringBuilder.AppendLine("0x85 = NFC_F_ACTIVE_LISTEN_MODE_RFU");
		stringBuilder.AppendLine("0x86 = NFC_15693_PASSIVE_LISTEN_MODE_RFU");
		stringBuilder.AppendLine("0x87-0xEF = RFU");
		stringBuilder.AppendLine("0xF0-0xFF = PROPRIETARY_IN_LISTEN_MODE");
		return stringBuilder.ToString();
	}
}
