using System.Text;

namespace QCRPG.TSL.BT.Packets;

public static class KeypressNotificationTypeInfo
{
	public static KeypressNotificationTypeEnum ValueToKeypressNotificationType(uint value)
	{
		switch (value)
		{
		case 0u:
			return KeypressNotificationTypeEnum.Passkey_entry_started;
		case 1u:
			return KeypressNotificationTypeEnum.Passkey_digit_entered;
		case 2u:
			return KeypressNotificationTypeEnum.Passkey_digit_erased;
		case 3u:
			return KeypressNotificationTypeEnum.Passkey_cleared;
		case 4u:
			return KeypressNotificationTypeEnum.Passkey_entry_completed;
		default:
			if (value >= 5 && value <= 255)
			{
				return KeypressNotificationTypeEnum.Reserved_for_future_use;
			}
			return KeypressNotificationTypeEnum.InvalidKeypressNotificationTypeValue;
		}
	}

	public static uint KeypressNotificationTypeToValue(KeypressNotificationTypeEnum enumItem)
	{
		return enumItem switch
		{
			KeypressNotificationTypeEnum.Passkey_entry_started => 0u, 
			KeypressNotificationTypeEnum.Passkey_digit_entered => 1u, 
			KeypressNotificationTypeEnum.Passkey_digit_erased => 2u, 
			KeypressNotificationTypeEnum.Passkey_cleared => 3u, 
			KeypressNotificationTypeEnum.Passkey_entry_completed => 4u, 
			KeypressNotificationTypeEnum.Reserved_for_future_use => 5u, 
			_ => uint.MaxValue, 
		};
	}

	public static string KeypressNotificationTypeToString(KeypressNotificationTypeEnum enumItem)
	{
		return enumItem switch
		{
			KeypressNotificationTypeEnum.Passkey_entry_started => "Passkey entry started", 
			KeypressNotificationTypeEnum.Passkey_digit_entered => "Passkey digit entered", 
			KeypressNotificationTypeEnum.Passkey_digit_erased => "Passkey digit erased", 
			KeypressNotificationTypeEnum.Passkey_cleared => "Passkey cleared", 
			KeypressNotificationTypeEnum.Passkey_entry_completed => "Passkey entry completed", 
			KeypressNotificationTypeEnum.Reserved_for_future_use => "Reserved for future use", 
			_ => "Invalid KeypressNotificationType Value", 
		};
	}

	public static string KeypressNotificationTypeToDescription()
	{
		StringBuilder stringBuilder = new StringBuilder();
		stringBuilder.AppendLine("0x0 = Passkey entry started");
		stringBuilder.AppendLine("0x1 = Passkey digit entered");
		stringBuilder.AppendLine("0x2 = Passkey digit erased");
		stringBuilder.AppendLine("0x3 = Passkey cleared");
		stringBuilder.AppendLine("0x4 = Passkey entry completed");
		stringBuilder.AppendLine("0x5-0xFF = Reserved for future use");
		return stringBuilder.ToString();
	}
}
