using System.Text;

namespace QCRPG.TSL.BT.Packets;

public static class AuthenticationRequirementsInfo
{
	public static AuthenticationRequirementsEnum ValueToAuthenticationRequirements(uint value)
	{
		switch (value)
		{
		case 0u:
			return AuthenticationRequirementsEnum.MITM_Protection_Not_Required_No_Bonding;
		case 1u:
			return AuthenticationRequirementsEnum.MITM_Protection_Required_No_Bonding;
		case 2u:
			return AuthenticationRequirementsEnum.MITM_Protection_Not_Required_Dedicated_Bonding;
		case 3u:
			return AuthenticationRequirementsEnum.MITM_Protection_Required_Dedicated_Bonding;
		case 4u:
			return AuthenticationRequirementsEnum.MITM_Protection_Not_Required_General_Bonding;
		case 5u:
			return AuthenticationRequirementsEnum.MITM_Protection_Required_General_Bonding;
		default:
			if (value >= 6 && value <= 255)
			{
				return AuthenticationRequirementsEnum.Reserved_for_future_use;
			}
			return AuthenticationRequirementsEnum.InvalidAuthenticationRequirementsValue;
		}
	}

	public static uint AuthenticationRequirementsToValue(AuthenticationRequirementsEnum enumItem)
	{
		return enumItem switch
		{
			AuthenticationRequirementsEnum.MITM_Protection_Not_Required_No_Bonding => 0u, 
			AuthenticationRequirementsEnum.MITM_Protection_Required_No_Bonding => 1u, 
			AuthenticationRequirementsEnum.MITM_Protection_Not_Required_Dedicated_Bonding => 2u, 
			AuthenticationRequirementsEnum.MITM_Protection_Required_Dedicated_Bonding => 3u, 
			AuthenticationRequirementsEnum.MITM_Protection_Not_Required_General_Bonding => 4u, 
			AuthenticationRequirementsEnum.MITM_Protection_Required_General_Bonding => 5u, 
			AuthenticationRequirementsEnum.Reserved_for_future_use => 6u, 
			_ => uint.MaxValue, 
		};
	}

	public static string AuthenticationRequirementsToString(AuthenticationRequirementsEnum enumItem)
	{
		return enumItem switch
		{
			AuthenticationRequirementsEnum.MITM_Protection_Not_Required_No_Bonding => "MITM Protection Not Required - No Bonding. Numeric comparison with automatic accept allowed.", 
			AuthenticationRequirementsEnum.MITM_Protection_Required_No_Bonding => "MITM Protection Required - No Bonding. Use IO Capabilities to determine authentication procedure.", 
			AuthenticationRequirementsEnum.MITM_Protection_Not_Required_Dedicated_Bonding => "MITM Protection Not Required - Dedicated Bonding. Numeric comparison with automatic accept allowed.", 
			AuthenticationRequirementsEnum.MITM_Protection_Required_Dedicated_Bonding => "MITM Protection Required - Dedicated Bonding. Use IO Capabilities to determine authentication procedure.", 
			AuthenticationRequirementsEnum.MITM_Protection_Not_Required_General_Bonding => "MITM Protection Not Required - General Bonding. Numeric comparison with automatic accept allowed.", 
			AuthenticationRequirementsEnum.MITM_Protection_Required_General_Bonding => "MITM Protection Required - General Bonding. Use IO Capabilities to determine authentication procedure.", 
			AuthenticationRequirementsEnum.Reserved_for_future_use => "Reserved for future use", 
			_ => "Invalid AuthenticationRequirements Value", 
		};
	}

	public static string AuthenticationRequirementsToDescription()
	{
		StringBuilder stringBuilder = new StringBuilder();
		stringBuilder.AppendLine("0x0 = MITM Protection Not Required - No Bonding. Numeric comparison with automatic accept allowed.");
		stringBuilder.AppendLine("0x1 = MITM Protection Required - No Bonding. Use IO Capabilities to determine authentication procedure.");
		stringBuilder.AppendLine("0x2 = MITM Protection Not Required - Dedicated Bonding. Numeric comparison with automatic accept allowed.");
		stringBuilder.AppendLine("0x3 = MITM Protection Required - Dedicated Bonding. Use IO Capabilities to determine authentication procedure.");
		stringBuilder.AppendLine("0x4 = MITM Protection Not Required - General Bonding. Numeric comparison with automatic accept allowed.");
		stringBuilder.AppendLine("0x5 = MITM Protection Required - General Bonding. Use IO Capabilities to determine authentication procedure.");
		stringBuilder.AppendLine("0x6-0xFF = Reserved for future use");
		return stringBuilder.ToString();
	}
}
