using System.Text;

namespace QCRPG.TSL.BT.Packets;

public static class AdvertisingReportAddressTypeInfo
{
	public static AdvertisingReportAddressTypeEnum ValueToAdvertisingReportAddressType(uint value)
	{
		switch (value)
		{
		case 0u:
			return AdvertisingReportAddressTypeEnum.Public_Device_Address;
		case 1u:
			return AdvertisingReportAddressTypeEnum.Random_Device_Address;
		case 2u:
			return AdvertisingReportAddressTypeEnum.Public_Identity_Address_corresponds_to_Resolved_Private_Address;
		case 3u:
			return AdvertisingReportAddressTypeEnum.Random_static_Identity_Address_corresponds_to_Resolved_Private_Address;
		default:
			if (value >= 4 && value <= 254)
			{
				return AdvertisingReportAddressTypeEnum.Reserved_for_future_use;
			}
			if (value == 255)
			{
				return AdvertisingReportAddressTypeEnum.No_address_provided_anonymous_advertisement;
			}
			return AdvertisingReportAddressTypeEnum.InvalidAdvertisingReportAddressTypeValue;
		}
	}

	public static uint AdvertisingReportAddressTypeToValue(AdvertisingReportAddressTypeEnum enumItem)
	{
		return enumItem switch
		{
			AdvertisingReportAddressTypeEnum.Public_Device_Address => 0u, 
			AdvertisingReportAddressTypeEnum.Random_Device_Address => 1u, 
			AdvertisingReportAddressTypeEnum.Public_Identity_Address_corresponds_to_Resolved_Private_Address => 2u, 
			AdvertisingReportAddressTypeEnum.Random_static_Identity_Address_corresponds_to_Resolved_Private_Address => 3u, 
			AdvertisingReportAddressTypeEnum.Reserved_for_future_use => 4u, 
			AdvertisingReportAddressTypeEnum.No_address_provided_anonymous_advertisement => 255u, 
			_ => uint.MaxValue, 
		};
	}

	public static string AdvertisingReportAddressTypeToString(AdvertisingReportAddressTypeEnum enumItem)
	{
		return enumItem switch
		{
			AdvertisingReportAddressTypeEnum.Public_Device_Address => "Public Device Address", 
			AdvertisingReportAddressTypeEnum.Random_Device_Address => "Random Device Address", 
			AdvertisingReportAddressTypeEnum.Public_Identity_Address_corresponds_to_Resolved_Private_Address => "Public Identity Address (corresponds to Resolved Private Address)", 
			AdvertisingReportAddressTypeEnum.Random_static_Identity_Address_corresponds_to_Resolved_Private_Address => "Random (static) Identity Address (corresponds to Resolved Private Address)", 
			AdvertisingReportAddressTypeEnum.Reserved_for_future_use => "Reserved for future use", 
			AdvertisingReportAddressTypeEnum.No_address_provided_anonymous_advertisement => "No address provided (anonymous advertisement)", 
			_ => "Invalid AdvertisingReportAddressType Value", 
		};
	}

	public static string AdvertisingReportAddressTypeToDescription()
	{
		StringBuilder stringBuilder = new StringBuilder();
		stringBuilder.AppendLine("0x0 = Public Device Address");
		stringBuilder.AppendLine("0x1 = Random Device Address");
		stringBuilder.AppendLine("0x2 = Public Identity Address (corresponds to Resolved Private Address)");
		stringBuilder.AppendLine("0x3 = Random (static) Identity Address (corresponds to Resolved Private Address)");
		stringBuilder.AppendLine("0x4-0xFE = Reserved for future use");
		stringBuilder.AppendLine("0xFF = No address provided (anonymous advertisement)");
		return stringBuilder.ToString();
	}
}
