using System.Text;

namespace QCRPG.TSL.BT.Packets;

public static class AssignedNumbersInfo
{
	public static AssignedNumbersEnum ValueToAssignedNumbers(uint value)
	{
		switch (value)
		{
		case 0u:
			return AssignedNumbersEnum.BT_CORE_10B;
		case 1u:
			return AssignedNumbersEnum.BT_CORE_11;
		case 2u:
			return AssignedNumbersEnum.BT_CORE_12;
		case 3u:
			return AssignedNumbersEnum.BT_CORE_20_EDR;
		case 4u:
			return AssignedNumbersEnum.BT_CORE_21_EDR;
		case 5u:
			return AssignedNumbersEnum.BT_CORE_30_HS;
		case 6u:
			return AssignedNumbersEnum.BT_CORE_40;
		case 7u:
			return AssignedNumbersEnum.BT_CORE_41;
		case 8u:
			return AssignedNumbersEnum.BT_CORE_42;
		default:
			if (value >= 9 && value <= 255)
			{
				return AssignedNumbersEnum.RESERVED;
			}
			return AssignedNumbersEnum.InvalidAssignedNumbersValue;
		}
	}

	public static uint AssignedNumbersToValue(AssignedNumbersEnum enumItem)
	{
		return enumItem switch
		{
			AssignedNumbersEnum.BT_CORE_10B => 0u, 
			AssignedNumbersEnum.BT_CORE_11 => 1u, 
			AssignedNumbersEnum.BT_CORE_12 => 2u, 
			AssignedNumbersEnum.BT_CORE_20_EDR => 3u, 
			AssignedNumbersEnum.BT_CORE_21_EDR => 4u, 
			AssignedNumbersEnum.BT_CORE_30_HS => 5u, 
			AssignedNumbersEnum.BT_CORE_40 => 6u, 
			AssignedNumbersEnum.BT_CORE_41 => 7u, 
			AssignedNumbersEnum.BT_CORE_42 => 8u, 
			AssignedNumbersEnum.RESERVED => 9u, 
			_ => uint.MaxValue, 
		};
	}

	public static string AssignedNumbersToString(AssignedNumbersEnum enumItem)
	{
		return enumItem switch
		{
			AssignedNumbersEnum.BT_CORE_10B => "Bluetooth Core Specification 1.0b", 
			AssignedNumbersEnum.BT_CORE_11 => "Bluetooth Core Specification 1.1", 
			AssignedNumbersEnum.BT_CORE_12 => "Bluetooth Core Specification 1.2", 
			AssignedNumbersEnum.BT_CORE_20_EDR => "Bluetooth Core Specification 2.0 + EDR", 
			AssignedNumbersEnum.BT_CORE_21_EDR => "Bluetooth Core Specification 2.1 + EDR", 
			AssignedNumbersEnum.BT_CORE_30_HS => "Bluetooth Core Specification 3.0 + HS", 
			AssignedNumbersEnum.BT_CORE_40 => "Bluetooth Core Specification 4.0", 
			AssignedNumbersEnum.BT_CORE_41 => "Bluetooth Core Specification 4.1", 
			AssignedNumbersEnum.BT_CORE_42 => "Bluetooth Core Specification 4.2", 
			AssignedNumbersEnum.RESERVED => "Reserved", 
			_ => "Invalid AssignedNumbers Value", 
		};
	}

	public static string AssignedNumbersToDescription()
	{
		StringBuilder stringBuilder = new StringBuilder();
		stringBuilder.AppendLine("0x0 = Bluetooth Core Specification 1.0b");
		stringBuilder.AppendLine("0x1 = Bluetooth Core Specification 1.1");
		stringBuilder.AppendLine("0x2 = Bluetooth Core Specification 1.2");
		stringBuilder.AppendLine("0x3 = Bluetooth Core Specification 2.0 + EDR");
		stringBuilder.AppendLine("0x4 = Bluetooth Core Specification 2.1 + EDR");
		stringBuilder.AppendLine("0x5 = Bluetooth Core Specification 3.0 + HS");
		stringBuilder.AppendLine("0x6 = Bluetooth Core Specification 4.0");
		stringBuilder.AppendLine("0x7 = Bluetooth Core Specification 4.1");
		stringBuilder.AppendLine("0x8 = Bluetooth Core Specification 4.2");
		stringBuilder.AppendLine("0x9-0xFF = Reserved");
		return stringBuilder.ToString();
	}
}
